@visulima/vis 3.0.5 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/LICENSE.md +0 -116
  3. package/README.md +3 -2
  4. package/dist/bin.js +1 -1
  5. package/dist/binx.js +1 -1
  6. package/dist/config/index.d.ts +24 -4
  7. package/dist/packem_chunks/CONFIG_FILES.js +6 -5
  8. package/dist/packem_chunks/catalog.js +32 -32
  9. package/dist/packem_chunks/cli-exec.js +1 -1
  10. package/dist/packem_chunks/cli-main.js +153 -152
  11. package/dist/packem_chunks/handler12.js +25 -10
  12. package/dist/packem_chunks/handler2.js +1 -1
  13. package/dist/packem_chunks/handler28.js +1 -1
  14. package/dist/packem_chunks/handler3.js +2 -2
  15. package/dist/packem_chunks/handler55.js +1 -1
  16. package/dist/packem_chunks/handler59.js +1 -1
  17. package/dist/packem_chunks/handler6.js +1 -1
  18. package/dist/packem_chunks/handler67.js +28 -25
  19. package/dist/packem_chunks/handler68.js +25 -153
  20. package/dist/packem_chunks/handler69.js +153 -10
  21. package/dist/packem_chunks/handler70.js +10 -22
  22. package/dist/packem_chunks/handler71.js +21 -22
  23. package/dist/packem_chunks/handler72.js +23 -322
  24. package/dist/packem_chunks/handler73.js +273 -659
  25. package/dist/packem_chunks/handler74.js +708 -48
  26. package/dist/packem_chunks/handler75.js +48 -27
  27. package/dist/packem_chunks/handler76.js +27 -3
  28. package/dist/packem_chunks/handler77.js +3 -189
  29. package/dist/packem_chunks/handler78.js +188 -39
  30. package/dist/packem_chunks/help-command.js +1 -1
  31. package/dist/packem_shared/{affected-selection-DIgAsQTu.js → affected-selection-BmUh3_Qp.js} +1 -1
  32. package/dist/packem_shared/{bin-CVfNImCA.js → bin-D-Es9mva.js} +1 -1
  33. package/dist/packem_shared/{index-5GrALmsb.js → index-BvYJA7e5.js} +1 -1
  34. package/dist/packem_shared/lockfile-DVFySxTS.js +1 -0
  35. package/dist/packem_shared/{package-version-CIhwFJn3.js → package-version-B_KfpWKC.js} +1 -1
  36. package/dist/packem_shared/{project-name-filter-sYH4Zvsm.js → project-name-filter-D6uEN2ot.js} +1 -1
  37. package/dist/packem_shared/vis-user-error-By2ZNeEA.js +31 -0
  38. package/index.d.ts +204 -204
  39. package/index.js +26 -26
  40. package/package.json +13 -13
  41. package/schemas/project.schema.json +2 -2
  42. package/schemas/vis-config.schema.json +8 -9
  43. package/skills/vis/SKILL.md +1 -1
  44. package/dist/packem_shared/lockfile-35RFsJDs.js +0 -1
  45. package/dist/packem_shared/vis-user-error-CgyYA29v.js +0 -30
@@ -1,27 +1,27 @@
1
- import{createRequire as Sf}from"node:module";import{n as Ef,b as R,d as Cf,a as Rf,w as Of,r as jf,i as Tf}from"../packem_shared/vis-user-error-CgyYA29v.js";import{k as pl,e as m,h as or,m as st,z as J,v as Qr,l as It,a as rs,b as If,U as dn}from"../packem_shared/index-DHD8wb6Z.js";import{N as fl,p as de}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{u as k,y as v,X as W,m as O,S as Af,U as Ko,V as $e,W as Pf,Y as Bf,Z as Ue,_ as Nf,$ as Df,a0 as Lf,a1 as Mf,a2 as _f,a3 as Ff,a4 as Vf,a5 as Wf,z as hl,F as Ye,d as Hf,a6 as Uf,j as Yo,i as Gf,x as zf,p as ar,D as Xo,R as Jf,c as qf,h as Kf,a7 as cr,a8 as lr,a9 as Yf,aa as Xf}from"./catalog.js";import{parseStacktrace as Zf}from"@visulima/error/stacktrace";import{i as dt}from"../packem_shared/index-BjdW45xX.js";import{y as $}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{U as ye,h as gt}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{findVisConfigFile as Mt,loadVisConfig as Qo}from"./CONFIG_FILES.js";import{S as rh}from"../packem_shared/index-BisalDCf.js";import{T as oh}from"../packem_shared/target-merge-B4No-LHM.js";import{s as ah}from"../packem_shared/bin-CVfNImCA.js";import{X as Si,j as Le,b as Pn,q as et,F as sn,T as ch,t as si,J as lh}from"../packem_shared/index.server-BAjDJSEu.js";import{s as ur}from"../packem_shared/index-B4AjSxHU.js";import{g as Vs}from"../packem_shared/package-version-CIhwFJn3.js";import{l as mt,k as ea,ad as fh,ae as wl,g as hh,d as yt,af as pr,ag as gh,$ as pn,c as Vn,ah as kl}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{d as ta}from"../packem_shared/pm-runner-d93_73O6.js";import{m as mh}from"./ts-loader.js";import{getMainWorktreeRoot as yh,Cache as Ws,readLastRunSummary as Sl,getLastRunSummaryPath as fr,parseCacheSize as vh,digestFile as xl}from"@visulima/task-runner";import{e as Rh}from"../packem_shared/index-5GrALmsb.js";let xf;const $f=e=>(xf??=Sf(import.meta.url))(e),Sn=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ce=e=>{if(typeof Sn<"u"&&Sn.versions&&Sn.versions.node){const[t,n]=Sn.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Sn.getBuiltinModule(e)}return $f(e)},{createRequire:Ne}=Ce("node:module"),{spawnSync:rt,execSync:gl,execFileSync:Qf,execFile:eh}=Ce("node:child_process"),{writeFileSync:ce,existsSync:dr,renameSync:ml,readFileSync:yl,readdirSync:Ee,statSync:At,rmSync:un,copyFileSync:th,unlinkSync:ht,mkdirSync:nh,cpSync:sh,watch:ih}=Ce("node:fs"),{dirname:vl,delimiter:Zo,resolve:Fs}=Ce("node:path"),{createInterface:bl}=Ce("node:readline"),{homedir:dh,platform:uh,tmpdir:ph}=Ce("node:os"),{readFile:$l,readdir:os,stat:mn,realpath:na,rm:eo,mkdtemp:bh,mkdir:wh}=Ce("node:fs/promises"),{isIP:kh}=Ce("node:net"),{createServer:Sh,STATUS_CODES:xh}=Ce("node:http"),{Http2ServerRequest:rn,constants:$h}=Ce("node:http2"),{Readable:sa}=Ce("node:stream"),{randomUUID:Eh}=Ce("node:crypto"),{fileURLToPath:Ch}=Ce("node:url"),Oh=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"];let jh;const Th=e=>(jh??=Ne(import.meta.url))(e),xn=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,El=e=>{if(typeof xn<"u"&&xn.versions&&xn.versions.node){const[t,n]=xn.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return xn.getBuiltinModule(e)}return Th(e)},{execFileSync:Ih}=El("node:child_process"),{existsSync:ia,readFileSync:Ah}=El("node:fs"),Ph=[...Oh],ra=new Set(["bun","npm","pnpm","yarn"]),Cl=e=>{const t=fl(Ah(e,"utf8"));return typeof t?.packageManager=="string"?t.packageManager:void 0},Bh=e=>{let t;if(Ph.forEach(s=>{!t&&ia(m(e,s))&&(t=m(e,s))}),t)return t;const n=m(e,"package.json");if(ia(n)&&Cl(n)!==void 0)return n},Nh=e=>{if(!e)throw new or("Could not find a package manager");if(e.endsWith("package.json")){const t=Cl(e);if(t){const n=["npm","yarn","pnpm","bun"].find(s=>t.startsWith(s));if(n)return{packageManager:n,path:st(e)}}}if(e.endsWith("yarn.lock"))return{packageManager:"yarn",path:st(e)};if(e.endsWith("package-lock.json")||e.endsWith("npm-shrinkwrap.json"))return{packageManager:"npm",path:st(e)};if(e.endsWith("pnpm-lock.yaml"))return{packageManager:"pnpm",path:st(e)};if(e.endsWith("bun.lock")||e.endsWith("bun.lockb"))return{packageManager:"bun",path:st(e)};throw new or("Could not find a package manager")},Dh=e=>{const t=pl(Bh,{...e&&{cwd:e}});return Nh(t)},e4=e=>{if(!ra.has(e))throw new Error(`Unsupported package manager "${e}". Expected one of: ${[...ra].join(", ")}.`);return Ih(e,["--version"]).toString("utf8").trim()};let Lh;const Mh=e=>(Lh??=Ne(import.meta.url))(e),$n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_h=e=>{if(typeof $n<"u"&&$n.versions&&$n.versions.node){const[t,n]=$n.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return $n.getBuiltinModule(e)}return Mh(e)},{existsSync:oa,readFileSync:Fh}=_h("node:fs"),Vh=e=>{let t;try{t=fl(e)}catch{return!1}if(!t||typeof t!="object"||Array.isArray(t))return!1;const{workspaces:n}=t;return typeof n=="object"&&n!==null},Rl=e=>{const t=pl(["lerna.json","turbo.json"],{type:"file",...e&&{cwd:e}});if(t?.endsWith("lerna.json")){const s=de(t);if(s&&typeof s=="object"&&!Array.isArray(s)){const i=s;if(i.useWorkspaces||i.packages)return{path:st(t),strategy:"lerna"}}}const n=t?.endsWith("turbo.json");try{const{packageManager:s,path:i}=Dh(e);if(["npm","yarn"].includes(s)){const r=m(i,"package.json");if(oa(r)){const o=Fh(m(i,"package.json"),"utf8");if(Vh(o))return{path:i,strategy:n?"turbo":s}}}else if(s==="pnpm"){const r=m(i,"pnpm-workspace.yaml");if(oa(r))return{path:i,strategy:n?"turbo":"pnpm"}}}catch(s){if(!(s instanceof or))throw s}throw new Error(`No monorepo root could be found upwards from the directory ${String(e??process.cwd())} using lerna, yarn, pnpm, or npm as indicators.`)};function Ol(e,t,n,s){let i,r,o;r=n,o=s;const a=rh(t,r,o??i);ye(e,a,i)}const G=(e,t)=>async()=>({default:(await e())[t]}),Wh=new Set(["--cwd"]),Hh=new Set(["--help","--version","-h","-V"]),Uh=e=>{const t=[];for(let n=0;n<e.length;n+=1){const s=e[n];if(s!==void 0){if(Hh.has(s))return!1;if(s.startsWith("-")){const i=s.indexOf("="),r=i===-1?s:s.slice(0,i);if(Wh.has(r)&&i===-1){const o=e[n+1];o!==void 0&&!o.startsWith("-")&&(n+=1)}continue}t.push(s)}}return t.length===1&&t[0]==="migrate"},Gh=e=>{if(e.length===0)return!1;for(const t of e){const n=t.codePointAt(0)??0;return!(n<=127||n<=255)}return!1};let zh=class{buffer="";timer;onFlush;timeout;constructor({onFlush:t,timeout:n}){this.onFlush=t,this.timeout=n}add(t){this.buffer+=t,this.timer!==void 0&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush()},this.timeout)}flush(){if(this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.buffer.length>0){const t=this.buffer;this.buffer="",this.onFlush(t)}}destroy(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.buffer=""}};const Jh={disambiguateEscapeCodes:1,reportAllKeysAsEscapeCodes:8,reportAlternateKeys:4,reportAssociatedText:16,reportEventTypes:2};function aa(e){let t=0;for(const n of e)t|=Jh[n];return t}const Xe={alt:2,capsLock:64,ctrl:4,hyper:16,meta:32,numLock:128,shift:1,super:8},qh="\x1B",ue="\x1B[",Kh=";",ca=`${ue}?1049h`,la=`${ue}?1049l`,jl=typeof globalThis<"u"&&typeof globalThis.window=="object"&&globalThis.window.document!==void 0,Yh=/^(?:msys|cygwin)$/,Tl=process,hr=Tl?.env??{};!jl&&hr.TERM_PROGRAM;const Xh=!jl&&(Tl?.platform==="win32"||hr.OSTYPE!==void 0&&Yh.test(hr.OSTYPE)),Zh=(e=1)=>`${ue}${String(e)}B`,qn=`${ue}?25l`,Qh=`${ue}G`,eg=(e=1)=>`${ue}${String(e)}G`,tg=(e=1)=>`${ue}${String(e)}E`,Kn=`${ue}?25h`,ii=(e,t)=>t===void 0?eg(e+1):`${ue}${String(t+1)}${Kh}${String(e+1)}H`,Hs=(e=1)=>`${ue}${String(e)}A`;var ng=(e=>(e[e.Default=0]="Default",e[e.BlinkingBlock=1]="BlinkingBlock",e[e.SteadyBlock=2]="SteadyBlock",e[e.BlinkingUnderline=3]="BlinkingUnderline",e[e.SteadyUnderline=4]="SteadyUnderline",e[e.BlinkingBar=5]="BlinkingBar",e[e.SteadyBar=6]="SteadyBar",e))(ng||{});const sg=e=>`${ue}${String(e)} q`;var on=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(on||{});const Wn=e=>{const t=e>=0&&e<=3?e:0;return`${ue}${t===0?"":String(t)}J`};var Il=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(Il||{});const to=e=>{const t=e>=0&&e<=2?e:0;return`${ue}${t===0?"":String(t)}K`},ig=to(2),rg=to(0),Yn=e=>{if(e<=0)return"";let t="";for(let n=0;n<e;n+=1)t+=ig,n<e-1&&(t+=Hs());return t+=Qh,t};ii(0,0)+Wn(on.ToEnd);`${to(Il.EntireLine)}${ue}`;const og=`${ue}H${Wn(on.EntireScreen)}`;Xh?`${Wn(on.EntireScreen)}${ue}`:`${Wn(on.EntireScreen)}${Wn(on.EntireScreenAndScrollback)}${ue}${qh}`;let ag=class{code;isDecMode=!0;constructor(t){this.code=t}};const Al=(e,...t)=>{if(t.length===0)return"";const n=e?"l":"h";if(t.length===1){const o=t[0];let a=ue;return o.isDecMode&&(a+="?"),a+String(o.code)+n}const s=t.filter(o=>!o.isDecMode).map(o=>o.code),i=t.filter(o=>o.isDecMode).map(o=>o.code);let r="";return s.length>0&&(r+=`${ue}${s.join(";")}${n}`),i.length>0&&(r+=`${ue}?${i.join(";")}${n}`),r};var cg=(e=>(e[e.NotRecognized=0]="NotRecognized",e[e.Set=1]="Set",e[e.Reset=2]="Reset",e[e.PermanentlySet=3]="PermanentlySet",e[e.PermanentlyReset=4]="PermanentlyReset",e))(cg||{});const Pl=e=>new ag(e),Bl=(...e)=>Al(!1,...e),Nl=(...e)=>Al(!0,...e),Dl=Pl(2004),lg={aliceblue:"f0f8ff",antiquewhite:"faebd7",antiquewhite1:"ffefdb",antiquewhite2:"eedfcc",antiquewhite3:"cdc0b0",antiquewhite4:"8b8378",aqua:"00ffff",aquamarine:"7fffd4",aquamarine1:"7fffd4",aquamarine2:"76eec6",aquamarine3:"66cdaa",aquamarine4:"458b74",azure:"f0ffff",azure1:"f0ffff",azure2:"e0eeee",azure3:"c1cdcd",azure4:"838b8b",beige:"f5f5dc",bisque:"ffe4c4",bisque1:"ffe4c4",bisque2:"eed5b7",bisque3:"cdb79e",bisque4:"8b7d6b",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blue1:"0000ff",blue2:"0000ee",blue3:"0000cd",blue4:"00008b",blueviolet:"8a2be2",brown:"a52a2a",brown1:"ff4040",brown2:"ee3b3b",brown3:"cd3333",brown4:"8b2323",burlywood:"deb887",burlywood1:"ffd39b",burlywood2:"eec591",burlywood3:"cdaa7d",burlywood4:"8b7355",cadetblue:"5f9ea0",cadetblue1:"98f5ff",cadetblue2:"8ee5ee",cadetblue3:"7ac5cd",cadetblue4:"53868b",chartreuse:"7fff00",chartreuse1:"7fff00",chartreuse2:"76ee00",chartreuse3:"66cd00",chartreuse4:"458b00",chocolate:"d2691e",chocolate1:"ff7f24",chocolate2:"ee7621",chocolate3:"cd661d",chocolate4:"8b4513",coral:"ff7f50",coral1:"ff7256",coral2:"ee6a50",coral3:"cd5b45",coral4:"8b3e2f",cornflowerblue:"6495ed",cornsilk:"fff8dc",cornsilk1:"fff8dc",cornsilk2:"eee8cd",cornsilk3:"cdc8b1",cornsilk4:"8b8878",crimson:"dc143c",cyan:"00ffff",cyan1:"00ffff",cyan2:"00eeee",cyan3:"00cdcd",cyan4:"008b8b",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgoldenrod1:"ffb90f",darkgoldenrod2:"eead0e",darkgoldenrod3:"cd950c",darkgoldenrod4:"8b6508",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkolivegreen1:"caff70",darkolivegreen2:"bcee68",darkolivegreen3:"a2cd5a",darkolivegreen4:"6e8b3d",darkorange:"ff8c00",darkorange1:"ff7f00",darkorange2:"ee7600",darkorange3:"cd6600",darkorange4:"8b4500",darkorchid:"9932cc",darkorchid1:"bf3eff",darkorchid2:"b23aee",darkorchid3:"9a32cd",darkorchid4:"68228b",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkseagreen1:"c1ffc1",darkseagreen2:"b4eeb4",darkseagreen3:"9bcd9b",darkseagreen4:"698b69",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategray1:"97ffff",darkslategray2:"8deeee",darkslategray3:"79cdcd",darkslategray4:"528b8b",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deeppink1:"ff1493",deeppink2:"ee1289",deeppink3:"cd1076",deeppink4:"8b0a50",deepskyblue:"00bfff",deepskyblue1:"00bfff",deepskyblue2:"00b2ee",deepskyblue3:"009acd",deepskyblue4:"00688b",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",dodgerblue1:"1e90ff",dodgerblue2:"1c86ee",dodgerblue3:"1874cd",dodgerblue4:"104e8b",firebrick:"b22222",firebrick1:"ff3030",firebrick2:"ee2c2c",firebrick3:"cd2626",firebrick4:"8b1a1a",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",gold1:"ffd700",gold2:"eec900",gold3:"cdad00",gold4:"8b7500",goldenrod:"daa520",goldenrod1:"ffc125",goldenrod2:"eeb422",goldenrod3:"cd9b1d",goldenrod4:"8b6914",gray:"bebebe",gray0:"000000",gray1:"030303",gray2:"050505",gray3:"080808",gray4:"0a0a0a",gray5:"0d0d0d",gray6:"0f0f0f",gray7:"121212",gray8:"141414",gray9:"171717",gray10:"1a1a1a",gray11:"1c1c1c",gray12:"1f1f1f",gray13:"212121",gray14:"242424",gray15:"262626",gray16:"292929",gray17:"2b2b2b",gray18:"2e2e2e",gray19:"303030",gray20:"333333",gray21:"363636",gray22:"383838",gray23:"3b3b3b",gray24:"3d3d3d",gray25:"404040",gray26:"424242",gray27:"454545",gray28:"474747",gray29:"4a4a4a",gray30:"4d4d4d",gray31:"4f4f4f",gray32:"525252",gray33:"545454",gray34:"575757",gray35:"595959",gray36:"5c5c5c",gray37:"5e5e5e",gray38:"616161",gray39:"636363",gray40:"666666",gray41:"696969",gray42:"6b6b6b",gray43:"6e6e6e",gray44:"707070",gray45:"737373",gray46:"757575",gray47:"787878",gray48:"7a7a7a",gray49:"7d7d7d",gray50:"7f7f7f",gray51:"828282",gray52:"858585",gray53:"878787",gray54:"8a8a8a",gray55:"8c8c8c",gray56:"8f8f8f",gray57:"919191",gray58:"949494",gray59:"969696",gray60:"999999",gray61:"9c9c9c",gray62:"9e9e9e",gray63:"a1a1a1",gray64:"a3a3a3",gray65:"a6a6a6",gray66:"a8a8a8",gray67:"ababab",gray68:"adadad",gray69:"b0b0b0",gray70:"b3b3b3",gray71:"b5b5b5",gray72:"b8b8b8",gray73:"bababa",gray74:"bdbdbd",gray75:"bfbfbf",gray76:"c2c2c2",gray77:"c4c4c4",gray78:"c7c7c7",gray79:"c9c9c9",gray80:"cccccc",gray81:"cfcfcf",gray82:"d1d1d1",gray83:"d4d4d4",gray84:"d6d6d6",gray85:"d9d9d9",gray86:"dbdbdb",gray87:"dedede",gray88:"e0e0e0",gray89:"e3e3e3",gray90:"e5e5e5",gray91:"e8e8e8",gray92:"ebebeb",gray93:"ededed",gray94:"f0f0f0",gray95:"f2f2f2",gray96:"f5f5f5",gray97:"f7f7f7",gray98:"fafafa",gray99:"fcfcfc",gray100:"ffffff",green:"00ff00",green1:"00ff00",green2:"00ee00",green3:"00cd00",green4:"008b00",greenyellow:"adff2f",grey:"bebebe",grey0:"000000",grey1:"030303",grey2:"050505",grey3:"080808",grey4:"0a0a0a",grey5:"0d0d0d",grey6:"0f0f0f",grey7:"121212",grey8:"141414",grey9:"171717",grey10:"1a1a1a",grey11:"1c1c1c",grey12:"1f1f1f",grey13:"212121",grey14:"242424",grey15:"262626",grey16:"292929",grey17:"2b2b2b",grey18:"2e2e2e",grey19:"303030",grey20:"333333",grey21:"363636",grey22:"383838",grey23:"3b3b3b",grey24:"3d3d3d",grey25:"404040",grey26:"424242",grey27:"454545",grey28:"474747",grey29:"4a4a4a",grey30:"4d4d4d",grey31:"4f4f4f",grey32:"525252",grey33:"545454",grey34:"575757",grey35:"595959",grey36:"5c5c5c",grey37:"5e5e5e",grey38:"616161",grey39:"636363",grey40:"666666",grey41:"696969",grey42:"6b6b6b",grey43:"6e6e6e",grey44:"707070",grey45:"737373",grey46:"757575",grey47:"787878",grey48:"7a7a7a",grey49:"7d7d7d",grey50:"7f7f7f",grey51:"828282",grey52:"858585",grey53:"878787",grey54:"8a8a8a",grey55:"8c8c8c",grey56:"8f8f8f",grey57:"919191",grey58:"949494",grey59:"969696",grey60:"999999",grey61:"9c9c9c",grey62:"9e9e9e",grey63:"a1a1a1",grey64:"a3a3a3",grey65:"a6a6a6",grey66:"a8a8a8",grey67:"ababab",grey68:"adadad",grey69:"b0b0b0",grey70:"b3b3b3",grey71:"b5b5b5",grey72:"b8b8b8",grey73:"bababa",grey74:"bdbdbd",grey75:"bfbfbf",grey76:"c2c2c2",grey77:"c4c4c4",grey78:"c7c7c7",grey79:"c9c9c9",grey80:"cccccc",grey81:"cfcfcf",grey82:"d1d1d1",grey83:"d4d4d4",grey84:"d6d6d6",grey85:"d9d9d9",grey86:"dbdbdb",grey87:"dedede",grey88:"e0e0e0",grey89:"e3e3e3",grey90:"e5e5e5",grey91:"e8e8e8",grey92:"ebebeb",grey93:"ededed",grey94:"f0f0f0",grey95:"f2f2f2",grey96:"f5f5f5",grey97:"f7f7f7",grey98:"fafafa",grey99:"fcfcfc",grey100:"ffffff",honeydew:"f0fff0",honeydew1:"f0fff0",honeydew2:"e0eee0",honeydew3:"c1cdc1",honeydew4:"838b83",hotpink:"ff69b4",hotpink1:"ff6eb4",hotpink2:"ee6aa7",hotpink3:"cd6090",hotpink4:"8b3a62",indianred:"cd5c5c",indianred1:"ff6a6a",indianred2:"ee6363",indianred3:"cd5555",indianred4:"8b3a3a",indigo:"4b0082",ivory:"fffff0",ivory1:"fffff0",ivory2:"eeeee0",ivory3:"cdcdc1",ivory4:"8b8b83",khaki:"f0e68c",khaki1:"fff68f",khaki2:"eee685",khaki3:"cdc673",khaki4:"8b864e",lavender:"e6e6fa",lavenderblush:"fff0f5",lavenderblush1:"fff0f5",lavenderblush2:"eee0e5",lavenderblush3:"cdc1c5",lavenderblush4:"8b8386",lawngreen:"7cfc00",lemonchiffon:"fffacd",lemonchiffon1:"fffacd",lemonchiffon2:"eee9bf",lemonchiffon3:"cdc9a5",lemonchiffon4:"8b8970",lightblue:"add8e6",lightblue1:"bfefff",lightblue2:"b2dfee",lightblue3:"9ac0cd",lightblue4:"68838b",lightcoral:"f08080",lightcyan:"e0ffff",lightcyan1:"e0ffff",lightcyan2:"d1eeee",lightcyan3:"b4cdcd",lightcyan4:"7a8b8b",lightgoldenrod:"eedd82",lightgoldenrod1:"ffec8b",lightgoldenrod2:"eedc82",lightgoldenrod3:"cdbe70",lightgoldenrod4:"8b814c",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightpink1:"ffaeb9",lightpink2:"eea2ad",lightpink3:"cd8c95",lightpink4:"8b5f65",lightsalmon:"ffa07a",lightsalmon1:"ffa07a",lightsalmon2:"ee9572",lightsalmon3:"cd8162",lightsalmon4:"8b5742",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightskyblue1:"b0e2ff",lightskyblue2:"a4d3ee",lightskyblue3:"8db6cd",lightskyblue4:"607b8b",lightslateblue:"8470ff",lightslategray:"778899",lightslategrey:"778899",lightsteelblue:"b0c4de",lightsteelblue1:"cae1ff",lightsteelblue2:"bcd2ee",lightsteelblue3:"a2b5cd",lightsteelblue4:"6e7b8b",lightyellow:"ffffe0",lightyellow1:"ffffe0",lightyellow2:"eeeed1",lightyellow3:"cdcdb4",lightyellow4:"8b8b7a",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",magenta1:"ff00ff",magenta2:"ee00ee",magenta3:"cd00cd",magenta4:"8b008b",maroon:"b03060",maroon1:"ff34b3",maroon2:"ee30a7",maroon3:"cd2990",maroon4:"8b1c62",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumorchid1:"e066ff",mediumorchid2:"d15fee",mediumorchid3:"b452cd",mediumorchid4:"7a378b",mediumpurple:"9370db",mediumpurple1:"ab82ff",mediumpurple2:"9f79ee",mediumpurple3:"8968cd",mediumpurple4:"5d478b",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",mistyrose1:"ffe4e1",mistyrose2:"eed5d2",mistyrose3:"cdb7b5",mistyrose4:"8b7d7b",moccasin:"ffe4b5",navajowhite:"ffdead",navajowhite1:"ffdead",navajowhite2:"eecfa1",navajowhite3:"cdb38b",navajowhite4:"8b795e",navy:"000080",navyblue:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",olivedrab1:"c0ff3e",olivedrab2:"b3ee3a",olivedrab3:"9acd32",olivedrab4:"698b22",orange:"ffa500",orange1:"ffa500",orange2:"ee9a00",orange3:"cd8500",orange4:"8b5a00",orangered:"ff4500",orangered1:"ff4500",orangered2:"ee4000",orangered3:"cd3700",orangered4:"8b2500",orchid:"da70d6",orchid1:"ff83fa",orchid2:"ee7ae9",orchid3:"cd69c9",orchid4:"8b4789",palegoldenrod:"eee8aa",palegreen:"98fb98",palegreen1:"9aff9a",palegreen2:"90ee90",palegreen3:"7ccd7c",palegreen4:"548b54",paleturquoise:"afeeee",paleturquoise1:"bbffff",paleturquoise2:"aeeeee",paleturquoise3:"96cdcd",paleturquoise4:"668b8b",palevioletred:"db7093",palevioletred1:"ff82ab",palevioletred2:"ee799f",palevioletred3:"cd6889",palevioletred4:"8b475d",papayawhip:"ffefd5",peachpuff:"ffdab9",peachpuff1:"ffdab9",peachpuff2:"eecbad",peachpuff3:"cdaf95",peachpuff4:"8b7765",peru:"cd853f",pink:"ffc0cb",pink1:"ffb5c5",pink2:"eea9b8",pink3:"cd919e",pink4:"8b636c",plum:"dda0dd",plum1:"ffbbff",plum2:"eeaeee",plum3:"cd96cd",plum4:"8b668b",powderblue:"b0e0e6",purple:"a020f0",purple1:"9b30ff",purple2:"912cee",purple3:"7d26cd",purple4:"551a8b",rebeccapurple:"663399",red:"ff0000",red1:"ff0000",red2:"ee0000",red3:"cd0000",red4:"8b0000",rosybrown:"bc8f8f",rosybrown1:"ffc1c1",rosybrown2:"eeb4b4",rosybrown3:"cd9b9b",rosybrown4:"8b6969",royalblue:"4169e1",royalblue1:"4876ff",royalblue2:"436eee",royalblue3:"3a5fcd",royalblue4:"27408b",saddlebrown:"8b4513",salmon:"fa8072",salmon1:"ff8c69",salmon2:"ee8262",salmon3:"cd7054",salmon4:"8b4c39",sandybrown:"f4a460",seagreen:"2e8b57",seagreen1:"54ff9f",seagreen2:"4eee94",seagreen3:"43cd80",seagreen4:"2e8b57",seashell:"fff5ee",seashell1:"fff5ee",seashell2:"eee5de",seashell3:"cdc5bf",seashell4:"8b8682",sienna:"a0522d",sienna1:"ff8247",sienna2:"ee7942",sienna3:"cd6839",sienna4:"8b4726",silver:"c0c0c0",skyblue:"87ceeb",skyblue1:"87ceff",skyblue2:"7ec0ee",skyblue3:"6ca6cd",skyblue4:"4a708b",slateblue:"6a5acd",slateblue1:"836fff",slateblue2:"7a67ee",slateblue3:"6959cd",slateblue4:"473c8b",slategray:"708090",slategray1:"c6e2ff",slategray2:"b9d3ee",slategray3:"9fb6cd",slategray4:"6c7b8b",slategrey:"708090",snow:"fffafa",snow1:"fffafa",snow2:"eee9e9",snow3:"cdc9c9",snow4:"8b8989",springgreen:"00ff7f",springgreen1:"00ff7f",springgreen2:"00ee76",springgreen3:"00cd66",springgreen4:"008b45",steelblue:"4682b4",steelblue1:"63b8ff",steelblue2:"5cacee",steelblue3:"4f94cd",steelblue4:"36648b",tan:"d2b48c",tan1:"ffa54f",tan2:"ee9a49",tan3:"cd853f",tan4:"8b5a2b",teal:"008080",thistle:"d8bfd8",thistle1:"ffe1ff",thistle2:"eed2ee",thistle3:"cdb5cd",thistle4:"8b7b8b",tomato:"ff6347",tomato1:"ff6347",tomato2:"ee5c42",tomato3:"cd4f39",tomato4:"8b3626",turquoise:"40e0d0",turquoise1:"00f5ff",turquoise2:"00e5ee",turquoise3:"00c5cd",turquoise4:"00868b",violet:"ee82ee",violetred:"d02090",violetred1:"ff3e96",violetred2:"ee3a8c",violetred3:"cd3278",violetred4:"8b2252",webgray:"808080",webgreen:"008000",webgrey:"808080",webmaroon:"800000",webpurple:"800080",wheat:"f5deb3",wheat1:"ffe7ba",wheat2:"eed8ae",wheat3:"cdba96",wheat4:"8b7e66",white:"ffffff",whitesmoke:"f5f5f5",x11gray:"bebebe",x11green:"00ff00",x11grey:"bebebe",x11maroon:"b03060",x11purple:"a020f0",yellow:"ffff00",yellow1:"ffff00",yellow2:"eeee00",yellow3:"cdcd00",yellow4:"8b8b00",yellowgreen:"9acd32"},dg=e=>{const t=lg[e.toLowerCase().replaceAll(" ","")];return t===void 0?void 0:`#${t}`},ug=/^rgba?:([\da-f]{1,4})\/([\da-f]{1,4})\/([\da-f]{1,4})(?:\/[\da-f]{1,4})?$/i,pg=/^#((?:[\da-f]{3}){1,4})$/i,Ht=e=>{const t=16**e.length-1;return Math.round(Number.parseInt(e,16)/t*255)},fg=e=>{const t=e.trim(),n=ug.exec(t);if(n)return{b:Ht(n[3]),g:Ht(n[2]),r:Ht(n[1])};const s=t.startsWith("#")?t:dg(t);if(s===void 0)return;const i=pg.exec(s);if(!i)return;const r=i[1],o=r.length/3;return{b:Ht(r.slice(o*2)),g:Ht(r.slice(o,o*2)),r:Ht(r.slice(0,o))}},Ll=k.createContext({renderThrottleMs:0,subscribe(){return{startTime:0,unsubscribe(){}}}});Ll.displayName="InternalAnimationContext";const no=k.createContext({exit(){},suspendTerminal:(()=>Promise.resolve(void 0)),async waitUntilRenderFlush(){}});no.displayName="InternalAppContext";const Ml=k.createContext({setCursorPosition(){}});Ml.displayName="InternalCursorContext";let hg;const gg=e=>(hg??=Ne(import.meta.url))(e),Jt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,mg=e=>{if(typeof Jt<"u"&&Jt.versions&&Jt.versions.node){const[t,n]=Jt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Jt.getBuiltinModule(e)}return gg(e)},{existsSync:yg,readFileSync:vg}=mg("node:fs"),{cwd:bg}=Jt,wg=(e,t=2)=>e.replace(/^\t+/gm,n=>" ".repeat(n.length*t)),kg=(e,t)=>{const n=[],s=e-t,i=e+t;for(let r=s;r<=i;r++)n.push(r);return n},Sg=(e,t,n={})=>{var s;if(typeof e!="string")throw new TypeError("Source code is missing.");if(!t||t<1)throw new TypeError("Line number must start from `1`.");const i=wg(e).split(/\r?\n/);if(!(t>i.length))return kg(t,(s=n.around)!==null&&s!==void 0?s:3).filter(r=>i[r-1]!==void 0).map(r=>({line:r,value:i[r-1]}))},xi=e=>{if(!e)return e;const t=bg();return e.replace(`file://${t}/`,"").replace(`${t}/`,"")};function xg({error:e}){const t=Zf(e),n=new Map,s=t.map(c=>{const l=!c.methodName&&!c.file?`raw:${c.raw}`:`${xi(c.file)??""}:${c.line}:${c.column}:${c.methodName??""}`,d=n.get(l)??0;return n.set(l,d+1),{key:`${l}#${d}`,trace:c}}),i=t[0],r=xi(i?.file);let o,a=0;if(r&&i?.line&&yg(r)){const c=vg(r,"utf8");if(o=Sg(c,i.line),o)for(const{line:l}of o)a=Math.max(a,String(l).length)}return v.jsxs(W,{flexDirection:"column",padding:1,children:[v.jsxs(W,{children:[v.jsxs(O,{backgroundColor:"red",color:"white",children:[" ","ERROR"," "]}),v.jsxs(O,{children:[" ",e.message]})]}),i&&r?v.jsx(W,{marginTop:1,children:v.jsxs(O,{dimColor:!0,children:[r,":",i.line,":",i.column]})}):null,i&&o?v.jsx(W,{flexDirection:"column",marginTop:1,children:o.map(({line:c,value:l})=>v.jsxs(W,{children:[v.jsx(W,{width:a+1,children:v.jsxs(O,{"aria-label":c===i.line?`Line ${c}, error`:`Line ${c}`,backgroundColor:c===i.line?"red":void 0,color:c===i.line?"white":void 0,dimColor:c!==i.line,children:[String(c).padStart(a," "),":"]})}),v.jsx(O,{backgroundColor:c===i.line?"red":void 0,color:c===i.line?"white":void 0,children:` ${l}`})]},`excerpt-${c}`))}):null,t.length>0?v.jsx(W,{flexDirection:"column",marginTop:1,children:s.map(({key:c,trace:l})=>{const d=xi(l.file)??"";return!l.methodName&&!l.file?v.jsxs(W,{children:[v.jsx(O,{dimColor:!0,children:"- "}),v.jsx(O,{bold:!0,dimColor:!0,children:l.raw})]},c):v.jsxs(W,{children:[v.jsx(O,{dimColor:!0,children:"- "}),v.jsx(O,{bold:!0,dimColor:!0,children:l.methodName??"<anonymous>"}),v.jsxs(O,{"aria-label":`at ${d} line ${l.line} column ${l.column}`,color:"gray",dimColor:!0,children:[" ","(",d,":",l.line,":",l.column,")"]})]},c)})}):null]})}let $g=class extends k.PureComponent{static displayName="InternalErrorBoundary";static getDerivedStateFromError(t){return{error:t}}state={error:void 0};componentDidCatch(t){this.props.onError(t)}render(){return this.state.error?v.jsx(xg,{error:this.state.error}):this.props.children}};const so=k.createContext({activate(){},activeId:void 0,add(){},deactivate(){},disableFocus(){},enableFocus(){},focus(){},focusNext(){},focusPrevious(){},remove(){}});so.displayName="InternalFocusContext";const Eg=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:_l,_l=Eg,Fl=k.createContext({stderr:_l.stderr,write(){}});Fl.displayName="InternalStderrContext";let Cg;const Rg=e=>(Cg??=Ne(import.meta.url))(e),qt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:Vl,Og=e=>{if(typeof qt<"u"&&qt.versions&&qt.versions.node){const[t,n]=qt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return qt.getBuiltinModule(e)}return Rg(e)},{EventEmitter:jg}=Og("node:events"),Vl=qt,ri=k.createContext({internal_eventEmitter:new jg,internal_exitOnCtrlC:!0,isRawModeSupported:!1,setBracketedPasteMode(){},setRawMode(){},stdin:Vl.stdin});ri.displayName="InternalStdinContext";const Tg=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:Wl,Wl=Tg,io=k.createContext({stdout:Wl.stdout,write(){}});io.displayName="InternalStdoutContext";const Ig={bar:6,"blinking-bar":5,"blinking-block":1,"blinking-underline":3,block:2,default:0,underline:4},da=e=>sg(Ig[e]),ua=(e,t)=>e?.x!==t?.x||e?.y!==t?.y,oi=(e,t)=>{if(!t)return"";const n=e-t.y;return(n>0?Hs(n):"")+ii(t.x)+Kn},Hl=(e,t)=>{if(!t)return"";const n=e-1-t.y;return(n>0?Zh(n):"")+ii(0)},Ag=e=>{const t=e.cursorWasShown?qn:"",n=Hl(e.previousLineCount,e.previousCursorPosition),s=oi(e.visibleLineCount,e.cursorPosition);return t+n+s},pa=(e,t,n)=>e?qn+Hl(t,n):"";let Pg;const Bg=e=>(Pg??=Ne(import.meta.url))(e),En=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ai=e=>{if(typeof En<"u"&&En.versions&&En.versions.node){const[t,n]=En.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return En.getBuiltinModule(e)}return Bg(e)},{existsSync:fa}=ai("node:fs"),{createRequire:Ng}=ai("node:module"),{dirname:ha,join:ys}=ai("node:path"),{fileURLToPath:Dg}=ai("node:url"),Lg=12,Mg=e=>{const t=Ng(e),n=ha(Dg(e));let s=n;for(let i=0;i<Lg;i+=1){if(fa(ys(s,"package.json"))&&fa(ys(s,"index.js")))return t(ys(s,"index.js"));const r=ha(s);if(r===s)break;s=r}return t(ys(n,"..","index.js"))},vs=new WeakMap,_g=async(e,t)=>(await e,t()),Ul=(e,t)=>{const n=vs.get(e),s=n===void 0?t():_g(n,t);let i;return i=(async()=>{try{await s}catch{}vs.get(e)===i&&vs.delete(e)})(),vs.set(e,i),s};let Fg=class{constructor(t,n){this.target=t,this.contentRect=n}target;contentRect};function Vg(e,t,n=!1){const s=e.resizeObservers&&e.resizeObservers.size>0;if((s||n)&&e.yogaNode){const i=Math.round(e.yogaNode.getComputedWidth()),r=Math.round(e.yogaNode.getComputedHeight());if(!Number.isNaN(i)&&!Number.isNaN(r)){const o=e.internal_lastMeasuredSize;if((o?.width!==i||o.height!==r)&&(e.internal_lastMeasuredSize={height:r,width:i},s)){const a=new Fg(e,{height:r,width:i});for(const c of e.resizeObservers)t.has(c)||t.set(c,[]),t.get(c).push(a)}}}}let Wg;const Hg=e=>(Wg??=Ne(import.meta.url))(e),Kt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:ot,ro=e=>{if(typeof Kt<"u"&&Kt.versions&&Kt.versions.node){const[t,n]=Kt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Kt.getBuiltinModule(e)}return Hg(e)},ot=Kt,{execFileSync:Ug}=ro("node:child_process"),Bn=ro("node:fs"),Gg=ro("node:tty"),Gl=80,zl=24,gr=(e,t,{shell:n,env:s}={})=>Ug(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:s}).trim(),As=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),Jl=(e,t)=>{const{columns:n,rows:s}=As(e,t);if(!(Number.isNaN(n)||Number.isNaN(s))&&!(n===Gl&&s===zl))return{columns:n,rows:s}},zg=()=>{if(ot.platform!=="linux")return!0;try{const e=Bn.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const n=e.slice(t+2).trim().split(/\s+/),s=Number.parseInt(n[2],10),i=Number.parseInt(n[5],10);return Number.isNaN(s)||Number.isNaN(i)||i<=0?!1:s===i}catch{return!1}};function Jg(){const{env:e,stdout:t,stderr:n}=ot;if(t?.columns&&t?.rows)return As(t.columns,t.rows);if(n?.columns&&n?.rows)return As(n.columns,n.rows);if(e.COLUMNS&&e.LINES)return As(e.COLUMNS,e.LINES);const s={columns:Gl,rows:zl};return ot.platform==="win32"?$i()??s:ot.platform==="darwin"?ga()??$i()??s:ga()??$i()??qg()??s}const ga=()=>{try{const e=ot.platform==="darwin"?Bn.constants.O_EVTONLY|Bn.constants.O_NONBLOCK:Bn.constants.O_NONBLOCK,{columns:t,rows:n}=Gg.WriteStream(Bn.openSync("/dev/tty",e));return{columns:t,rows:n}}catch{}},$i=()=>{try{const e=gr("tput",["cols"],{env:{TERM:"dumb",...ot.env}}),t=gr("tput",["lines"],{env:{TERM:"dumb",...ot.env}});if(e&&t)return Jl(e,t)}catch{}},qg=()=>{try{if(!zg())return;const e=gr("resize",["-u"]).match(/\d+/g);if(e.length===2)return Jl(e[0],e[1])}catch{}},tt=e=>{const{columns:t,rows:n}=e;if(t&&n)return{columns:t,rows:n};const s=Jg();return{columns:t||s.columns||80,rows:n||s.rows||24}};let Kg;const Yg=e=>(Kg??=Ne(import.meta.url))(e),Yt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ci=e=>{if(typeof Yt<"u"&&Yt.versions&&Yt.versions.node){const[t,n]=Yt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Yt.getBuiltinModule(e)}return Yg(e)},Te=Yt,{env:Ei}=Te,{PassThrough:ma,Stream:Xg}=ci("node:stream"),{Buffer:ya}=ci("node:buffer"),{Console:Zg}=ci("node:console"),{EventEmitter:Qg}=ci("node:events"),va=e=>e in Ei&&Ei[e]!=="0"&&Ei[e]!=="false",ql=va("CI")||va("CONTINUOUS_INTEGRATION"),ba=["assert","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"];let Ci={};const em=e=>{const t=new ma,n=new ma;t.write=i=>{e("stdout",i)},n.write=i=>{e("stderr",i)};const s=new console.Console(t,n);for(const i of ba)Ci[i]=console[i],console[i]=s[i];return()=>{for(const i of ba)console[i]=Ci[i];Ci={}}},an=[];an.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&an.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&an.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const Ps=e=>!!e&&!0&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",Ri=Symbol.for("signal-exit emitter"),Oi=globalThis,tm=Object.defineProperty.bind(Object);class nm{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Oi[Ri])return Oi[Ri];tm(Oi,Ri,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,n){this.listeners[t].push(n)}removeListener(t,n){const s=this.listeners[t],i=s.indexOf(n);i!==-1&&(i===0&&s.length===1?s.length=0:s.splice(i,1))}emit(t,n,s){if(this.emitted[t])return!1;this.emitted[t]=!0;let i=!1;for(const r of this.listeners[t])i=r(n,s)===!0||i;return t==="exit"&&(i=this.emit("afterExit",n,s)||i),i}}let Kl=class{};const sm=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});class im extends Kl{onExit(){return()=>{}}load(){}unload(){}}class rm extends Kl{#e=mr.platform==="win32"?"SIGINT":"SIGHUP";#t=new nm;#n;#r;#s;#i={};#o=!1;constructor(t){super(),this.#n=t,this.#i={};for(const n of an)this.#i[n]=()=>{const s=this.#n.listeners(n);let{count:i}=this.#t;const r=t;if(typeof r.__signal_exit_emitter__=="object"&&typeof r.__signal_exit_emitter__.count=="number"&&(i+=r.__signal_exit_emitter__.count),s.length===i){this.unload();const o=this.#t.emit("exit",null,n),a=n==="SIGHUP"?this.#e:n;o||t.kill(t.pid,a)}};this.#s=t.reallyExit,this.#r=t.emit}onExit(t,n){if(!Ps(this.#n))return()=>{};this.#o===!1&&this.load();const s=n?.alwaysLast?"afterExit":"exit";return this.#t.on(s,t),()=>{this.#t.removeListener(s,t),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(const t of an)try{const n=this.#i[t];n&&this.#n.on(t,n)}catch{}this.#n.emit=(t,...n)=>this.#c(t,...n),this.#n.reallyExit=t=>this.#a(t)}}unload(){this.#o&&(this.#o=!1,an.forEach(t=>{const n=this.#i[t];if(!n)throw new Error("Listener not defined for signal: "+t);try{this.#n.removeListener(t,n)}catch{}}),this.#n.emit=this.#r,this.#n.reallyExit=this.#s,this.#t.count-=1)}#a(t){return Ps(this.#n)?(this.#n.exitCode=t||0,this.#t.emit("exit",this.#n.exitCode,null),this.#s.call(this.#n,this.#n.exitCode)):0}#c(t,...n){const s=this.#r;if(t==="exit"&&Ps(this.#n)){typeof n[0]=="number"&&(this.#n.exitCode=n[0]);const i=s.call(this.#n,t,...n);return this.#t.emit("exit",this.#n.exitCode,null),i}else return s.call(this.#n,t,...n)}}const mr=globalThis.process,{onExit:om}=sm(Ps(mr)?new rm(mr):new im),Us="\x1B",Yl="\x1B[200~",wa="\x1B[201~",am=e=>e>=48&&e<=63,cm=e=>e>=32&&e<=47,Xl=e=>e>=64&&e<=126,lm=(e,t,n)=>{const s=t+n+1;let i=s;for(;i<e.length;i++){const r=e.codePointAt(i);if(r===void 0)return"pending";if(!(am(r)||cm(r))&&!(r===91&&i===s))return Xl(r)?{nextIndex:i+1,sequence:e.slice(t,i+1)}:void 0}return"pending"},dm=(e,t,n)=>{const s=t+n+2;if(s>e.length)return"pending";const i=e.codePointAt(s-1);if(!(i===void 0||!Xl(i)))return{nextIndex:s,sequence:e.slice(t,s)}},ka=(e,t,n)=>{const s=e[t+n];if(s===void 0)return"pending";if(s==="[")return lm(e,t,n);if(s==="O")return dm(e,t,n)},um=(e,t)=>{const n=e.codePointAt(t+1),s=n!==void 0&&n>65535?2:1,i=t+1+s;return{nextIndex:i,sequence:e.slice(t,i)}},pm=(e,t)=>{if(t===e.length-1)return"pending";if(e[t+1]===Us){if(t+2>=e.length)return"pending";const s=ka(e,t,2);return s==="pending"?"pending":s||{nextIndex:t+2,sequence:e.slice(t,t+2)}}const n=ka(e,t,1);return n==="pending"?"pending":n||um(e,t)},Sa=(e,t)=>{let n=0;for(let s=0;s<e.length;s++){const i=e[s];(i===""||i==="\b")&&(s>n&&t.push(e.slice(n,s)),t.push(i),n=s+1)}n<e.length&&t.push(e.slice(n))},fm=e=>{const t=[];let n=0;const s=i=>({events:t,pending:e.slice(i)});for(;n<e.length;){const i=e.indexOf(Us,n);if(i===-1)return Sa(e.slice(n),t),{events:t,pending:""};i>n&&Sa(e.slice(n,i),t);const r=pm(e,i);if(r==="pending")return s(i);if(r.sequence===Yl){const o=r.nextIndex,a=e.indexOf(wa,o);if(a===-1)return s(i);t.push({paste:e.slice(o,a)}),n=a+wa.length;continue}t.push(r.sequence),n=r.nextIndex}return{events:t,pending:""}},hm=()=>{let e="";return{flushPendingEscape(){if(!e.startsWith(Us))return;const t=e;return e="",t},hasPendingEscape(){return e.startsWith(Us)&&!e.startsWith(Yl)&&e!=="\x1B[200"},push(t){const n=fm(e+t);return e=n.pending,n.events},reset(){e=""}}},gm=" ",mm="\x1B[Z",ym="\x1B",xa=Bl(Dl),ji=Nl(Dl),Zl=({children:e,exitOnCtrlC:t,interactive:n,onExit:s,onRegisterInputControl:i,onSuspendTerminal:r,onWaitUntilRenderFlush:o,renderThrottleMs:a,setCursorPosition:c,stderr:l,stdin:d,stdout:u,writeToStderr:p,writeToStdout:f})=>{const[h,g]=k.useState(!0),[y,x]=k.useState(void 0),[,b]=k.useState([]),S=k.useRef(0),C=k.useRef([]),N=k.useRef(new Map),T=k.useRef(void 0),D=k.useRef(0),F=k.useRef(!1),V=k.useRef(0),[Z]=k.useState(()=>{const L=new Qg;return L.setMaxListeners(1/0),L}),re=k.useRef(void 0),te=k.useRef(void 0);te.current??=hm();const ne=k.useRef(void 0),ie=k.useRef(!1),M=20,w=k.useCallback(()=>{ne.current&&(clearTimeout(ne.current),ne.current=void 0)},[]),A=k.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=void 0)},[]),U=k.useCallback(()=>{if(A(),N.current.size===0)return;let L=Number.POSITIVE_INFINITY;for(const X of N.current.values())L=Math.min(L,X.nextDueTime);const Q=Math.max(0,L-performance.now());T.current=setTimeout(()=>{T.current=void 0;const X=performance.now(),pe=[...N.current.values()];for(const xe of pe){if(X<xe.nextDueTime)continue;xe.callback(X);const wf=X-xe.startTime,kf=Math.floor(wf/xe.interval)+1;xe.nextDueTime=xe.startTime+kf*xe.interval}U()},Q)},[A]),I=k.useCallback((L,Q)=>{const X=performance.now();return N.current.set(L,{callback:L,interval:Q,nextDueTime:X+Q,startTime:X}),U(),{startTime:X,unsubscribe(){if(N.current.delete(L),N.current.size===0){A();return}U()}}},[A,U]);k.useEffect(()=>()=>{A()},[A]);const P=d.isTTY,j=k.useCallback(()=>{re.current&&(d.removeListener("readable",re.current),re.current=void 0)},[d]),_=k.useCallback(()=>{te.current?.reset(),w(),j()},[w,j]),H=k.useCallback(()=>{F.current=!1,d.setRawMode(!1),d.unref(),D.current=0,_()},[d,_]),z=k.useCallback(L=>{P&&(D.current>0||F.current)&&H(),s(L)},[P,H,s]),Y=k.useCallback(L=>{if(L.includes("")&&t){z();return}L===ym&&h&&x(Q=>{if(!Q)return Q})},[t,z,h]),B=k.useCallback(L=>{Y(L),Z.emit("input",L)},[Y,Z]),K=k.useCallback(()=>{w(),ne.current=setTimeout(()=>{ne.current=void 0;const L=te.current.flushPendingEscape();L&&B(L)},M)},[w,B]),ae=k.useCallback(()=>{w();let L;for(;(L=d.read())!==null;){const Q=te.current.push(L);for(const X of Q)if(typeof X=="string")B(X);else{if(Z.listenerCount("paste")===0){ie.current||(ie.current=!0,p(`Warning: useInput() received bracketed paste because no usePaste() handler is active. This fallback is deprecated and will be removed in the next major version. Migrate paste handling to usePaste().
2
- `)),B(X.paste);continue}Z.emit("paste",X.paste)}}te.current.hasPendingEscape()&&K()},[d,B,w,K,p,Z]),le=k.useCallback(()=>{re.current||(re.current=ae,d.addListener("readable",ae))},[d,ae]),ge=k.useCallback(L=>{if(!P)throw d===Te.stdin?new Error(`Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.
1
+ import{createRequire as Cf}from"node:module";import{n as jf,b as R,d as Tf,a as If,x as Af,r as Bf,i as Pf}from"../packem_shared/vis-user-error-By2ZNeEA.js";import{k as gl,e as m,h as ar,m as it,z as J,v as eo,l as At,a as as,b as Nf,U as un}from"../packem_shared/index-DHD8wb6Z.js";import{N as ml,p as de}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{u as k,y as v,X as W,m as O,S as Df,U as Xo,V as Ee,W as Lf,Y as Mf,Z as Ue,_ as _f,$ as Ff,a0 as Vf,a1 as Wf,a2 as Hf,a3 as Uf,a4 as Gf,a5 as zf,z as yl,F as Ye,d as Jf,a6 as qf,j as Zo,i as Kf,x as Yf,p as cr,D as Qo,R as Xf,c as Zf,h as Qf,a7 as lr,a8 as dr,a9 as eh,aa as th}from"./catalog.js";import{parseStacktrace as nh}from"@visulima/error/stacktrace";import{i as ut}from"../packem_shared/index-BjdW45xX.js";import{y as $}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{U as ye,h as mt}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{findVisConfigFile as _t,loadVisConfig as ta}from"./CONFIG_FILES.js";import{S as lh}from"../packem_shared/index-BisalDCf.js";import{T as dh}from"../packem_shared/target-merge-B4No-LHM.js";import{s as uh}from"../packem_shared/bin-D-Es9mva.js";import{X as xi,j as Le,b as Bn,q as et,F as rn,T as ph,t as ii,J as fh}from"../packem_shared/index.server-BAjDJSEu.js";import{s as pr}from"../packem_shared/index-B4AjSxHU.js";import{g as Ws}from"../packem_shared/package-version-B_KfpWKC.js";import{l as yt,k as na,ad as yh,ae as xl,g as vh,d as vt,af as fr,ag as bh,$ as Kn,c as Wn,ah as $l}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{d as sa}from"../packem_shared/pm-runner-d93_73O6.js";import{m as wh}from"./ts-loader.js";import{getMainWorktreeRoot as kh,Cache as Hs,readLastRunSummary as El,getLastRunSummaryPath as hr,parseCacheSize as Sh,digestFile as Cl}from"@visulima/task-runner";import{e as Ih}from"../packem_shared/index-BvYJA7e5.js";let Rf;const Of=e=>(Rf??=Cf(import.meta.url))(e),Sn=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ce=e=>{if(typeof Sn<"u"&&Sn.versions&&Sn.versions.node){const[t,n]=Sn.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Sn.getBuiltinModule(e)}return Of(e)},{createRequire:Ne}=Ce("node:module"),{spawnSync:ot,execSync:vl,execFileSync:sh,execFile:ih}=Ce("node:child_process"),{writeFileSync:ce,existsSync:ur,renameSync:bl,readFileSync:wl,readdirSync:we,statSync:Bt,rmSync:pn,copyFileSync:rh,unlinkSync:gt,mkdirSync:oh,cpSync:ah,watch:ch}=Ce("node:fs"),{dirname:kl,delimiter:ea,resolve:Vs}=Ce("node:path"),{createInterface:Sl}=Ce("node:readline"),{homedir:hh,platform:gh,tmpdir:mh}=Ce("node:os"),{readFile:Rl,readdir:cs,stat:mn,realpath:ia,rm:to,mkdtemp:xh,mkdir:$h}=Ce("node:fs/promises"),{isIP:Eh}=Ce("node:net"),{createServer:Ch,STATUS_CODES:Rh}=Ce("node:http"),{Http2ServerRequest:on,constants:Oh}=Ce("node:http2"),{Readable:ra}=Ce("node:stream"),{randomUUID:jh}=Ce("node:crypto"),{fileURLToPath:Th}=Ce("node:url"),Ah=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"];let Bh;const Ph=e=>(Bh??=Ne(import.meta.url))(e),xn=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ol=e=>{if(typeof xn<"u"&&xn.versions&&xn.versions.node){const[t,n]=xn.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return xn.getBuiltinModule(e)}return Ph(e)},{execFileSync:Nh}=Ol("node:child_process"),{existsSync:oa,readFileSync:Dh}=Ol("node:fs"),Lh=[...Ah],aa=new Set(["bun","npm","pnpm","yarn"]),jl=e=>{const t=ml(Dh(e,"utf8"));return typeof t?.packageManager=="string"?t.packageManager:void 0},Mh=e=>{let t;if(Lh.forEach(s=>{!t&&oa(m(e,s))&&(t=m(e,s))}),t)return t;const n=m(e,"package.json");if(oa(n)&&jl(n)!==void 0)return n},_h=e=>{if(!e)throw new ar("Could not find a package manager");if(e.endsWith("package.json")){const t=jl(e);if(t){const n=["npm","yarn","pnpm","bun"].find(s=>t.startsWith(s));if(n)return{packageManager:n,path:it(e)}}}if(e.endsWith("yarn.lock"))return{packageManager:"yarn",path:it(e)};if(e.endsWith("package-lock.json")||e.endsWith("npm-shrinkwrap.json"))return{packageManager:"npm",path:it(e)};if(e.endsWith("pnpm-lock.yaml"))return{packageManager:"pnpm",path:it(e)};if(e.endsWith("bun.lock")||e.endsWith("bun.lockb"))return{packageManager:"bun",path:it(e)};throw new ar("Could not find a package manager")},Fh=e=>{const t=gl(Mh,{...e&&{cwd:e}});return _h(t)},r4=e=>{if(!aa.has(e))throw new Error(`Unsupported package manager "${e}". Expected one of: ${[...aa].join(", ")}.`);return Nh(e,["--version"]).toString("utf8").trim()};let Vh;const Wh=e=>(Vh??=Ne(import.meta.url))(e),$n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Hh=e=>{if(typeof $n<"u"&&$n.versions&&$n.versions.node){const[t,n]=$n.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return $n.getBuiltinModule(e)}return Wh(e)},{existsSync:ca,readFileSync:Uh}=Hh("node:fs"),Gh=e=>{let t;try{t=ml(e)}catch{return!1}if(!t||typeof t!="object"||Array.isArray(t))return!1;const{workspaces:n}=t;return typeof n=="object"&&n!==null},Tl=e=>{const t=gl(["lerna.json","turbo.json"],{type:"file",...e&&{cwd:e}});if(t?.endsWith("lerna.json")){const s=de(t);if(s&&typeof s=="object"&&!Array.isArray(s)){const i=s;if(i.useWorkspaces||i.packages)return{path:it(t),strategy:"lerna"}}}const n=t?.endsWith("turbo.json");try{const{packageManager:s,path:i}=Fh(e);if(["npm","yarn"].includes(s)){const r=m(i,"package.json");if(ca(r)){const o=Uh(m(i,"package.json"),"utf8");if(Gh(o))return{path:i,strategy:n?"turbo":s}}}else if(s==="pnpm"){const r=m(i,"pnpm-workspace.yaml");if(ca(r))return{path:i,strategy:n?"turbo":"pnpm"}}}catch(s){if(!(s instanceof ar))throw s}throw new Error(`No monorepo root could be found upwards from the directory ${String(e??process.cwd())} using lerna, yarn, pnpm, or npm as indicators.`)};function Il(e,t,n,s){let i,r,o;r=n,o=s;const a=lh(t,r,o??i);ye(e,a,i)}const G=(e,t)=>async()=>({default:(await e())[t]}),zh=new Set(["--cwd"]),Jh=new Set(["--help","--version","-h","-V"]),qh=e=>{const t=[];for(let n=0;n<e.length;n+=1){const s=e[n];if(s!==void 0){if(Jh.has(s))return!1;if(s.startsWith("-")){const i=s.indexOf("="),r=i===-1?s:s.slice(0,i);if(zh.has(r)&&i===-1){const o=e[n+1];o!==void 0&&!o.startsWith("-")&&(n+=1)}continue}t.push(s)}}return t.length===1&&t[0]==="migrate"},Kh=e=>{if(e.length===0)return!1;for(const t of e){const n=t.codePointAt(0)??0;return!(n<=127||n<=255)}return!1};let Yh=class{buffer="";timer;onFlush;timeout;constructor({onFlush:t,timeout:n}){this.onFlush=t,this.timeout=n}add(t){this.buffer+=t,this.timer!==void 0&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush()},this.timeout)}flush(){if(this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.buffer.length>0){const t=this.buffer;this.buffer="",this.onFlush(t)}}destroy(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0),this.buffer=""}};const Xh={disambiguateEscapeCodes:1,reportAllKeysAsEscapeCodes:8,reportAlternateKeys:4,reportAssociatedText:16,reportEventTypes:2};function la(e){let t=0;for(const n of e)t|=Xh[n];return t}const Xe={alt:2,capsLock:64,ctrl:4,hyper:16,meta:32,numLock:128,shift:1,super:8},Zh="\x1B",ue="\x1B[",Qh=";",da=`${ue}?1049h`,ua=`${ue}?1049l`,Al=typeof globalThis<"u"&&typeof globalThis.window=="object"&&globalThis.window.document!==void 0,eg=/^(?:msys|cygwin)$/,Bl=process,gr=Bl?.env??{};!Al&&gr.TERM_PROGRAM;const tg=!Al&&(Bl?.platform==="win32"||gr.OSTYPE!==void 0&&eg.test(gr.OSTYPE)),ng=(e=1)=>`${ue}${String(e)}B`,Yn=`${ue}?25l`,sg=`${ue}G`,ig=(e=1)=>`${ue}${String(e)}G`,rg=(e=1)=>`${ue}${String(e)}E`,Xn=`${ue}?25h`,ri=(e,t)=>t===void 0?ig(e+1):`${ue}${String(t+1)}${Qh}${String(e+1)}H`,Us=(e=1)=>`${ue}${String(e)}A`;var og=(e=>(e[e.Default=0]="Default",e[e.BlinkingBlock=1]="BlinkingBlock",e[e.SteadyBlock=2]="SteadyBlock",e[e.BlinkingUnderline=3]="BlinkingUnderline",e[e.SteadyUnderline=4]="SteadyUnderline",e[e.BlinkingBar=5]="BlinkingBar",e[e.SteadyBar=6]="SteadyBar",e))(og||{});const ag=e=>`${ue}${String(e)} q`;var an=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(an||{});const Hn=e=>{const t=e>=0&&e<=3?e:0;return`${ue}${t===0?"":String(t)}J`};var Pl=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(Pl||{});const no=e=>{const t=e>=0&&e<=2?e:0;return`${ue}${t===0?"":String(t)}K`},cg=no(2),lg=no(0),Zn=e=>{if(e<=0)return"";let t="";for(let n=0;n<e;n+=1)t+=cg,n<e-1&&(t+=Us());return t+=sg,t};ri(0,0)+Hn(an.ToEnd);`${no(Pl.EntireLine)}${ue}`;const dg=`${ue}H${Hn(an.EntireScreen)}`;tg?`${Hn(an.EntireScreen)}${ue}`:`${Hn(an.EntireScreen)}${Hn(an.EntireScreenAndScrollback)}${ue}${Zh}`;let ug=class{code;isDecMode=!0;constructor(t){this.code=t}};const Nl=(e,...t)=>{if(t.length===0)return"";const n=e?"l":"h";if(t.length===1){const o=t[0];let a=ue;return o.isDecMode&&(a+="?"),a+String(o.code)+n}const s=t.filter(o=>!o.isDecMode).map(o=>o.code),i=t.filter(o=>o.isDecMode).map(o=>o.code);let r="";return s.length>0&&(r+=`${ue}${s.join(";")}${n}`),i.length>0&&(r+=`${ue}?${i.join(";")}${n}`),r};var pg=(e=>(e[e.NotRecognized=0]="NotRecognized",e[e.Set=1]="Set",e[e.Reset=2]="Reset",e[e.PermanentlySet=3]="PermanentlySet",e[e.PermanentlyReset=4]="PermanentlyReset",e))(pg||{});const Dl=e=>new ug(e),Ll=(...e)=>Nl(!1,...e),Ml=(...e)=>Nl(!0,...e),_l=Dl(2004),fg={aliceblue:"f0f8ff",antiquewhite:"faebd7",antiquewhite1:"ffefdb",antiquewhite2:"eedfcc",antiquewhite3:"cdc0b0",antiquewhite4:"8b8378",aqua:"00ffff",aquamarine:"7fffd4",aquamarine1:"7fffd4",aquamarine2:"76eec6",aquamarine3:"66cdaa",aquamarine4:"458b74",azure:"f0ffff",azure1:"f0ffff",azure2:"e0eeee",azure3:"c1cdcd",azure4:"838b8b",beige:"f5f5dc",bisque:"ffe4c4",bisque1:"ffe4c4",bisque2:"eed5b7",bisque3:"cdb79e",bisque4:"8b7d6b",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blue1:"0000ff",blue2:"0000ee",blue3:"0000cd",blue4:"00008b",blueviolet:"8a2be2",brown:"a52a2a",brown1:"ff4040",brown2:"ee3b3b",brown3:"cd3333",brown4:"8b2323",burlywood:"deb887",burlywood1:"ffd39b",burlywood2:"eec591",burlywood3:"cdaa7d",burlywood4:"8b7355",cadetblue:"5f9ea0",cadetblue1:"98f5ff",cadetblue2:"8ee5ee",cadetblue3:"7ac5cd",cadetblue4:"53868b",chartreuse:"7fff00",chartreuse1:"7fff00",chartreuse2:"76ee00",chartreuse3:"66cd00",chartreuse4:"458b00",chocolate:"d2691e",chocolate1:"ff7f24",chocolate2:"ee7621",chocolate3:"cd661d",chocolate4:"8b4513",coral:"ff7f50",coral1:"ff7256",coral2:"ee6a50",coral3:"cd5b45",coral4:"8b3e2f",cornflowerblue:"6495ed",cornsilk:"fff8dc",cornsilk1:"fff8dc",cornsilk2:"eee8cd",cornsilk3:"cdc8b1",cornsilk4:"8b8878",crimson:"dc143c",cyan:"00ffff",cyan1:"00ffff",cyan2:"00eeee",cyan3:"00cdcd",cyan4:"008b8b",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgoldenrod1:"ffb90f",darkgoldenrod2:"eead0e",darkgoldenrod3:"cd950c",darkgoldenrod4:"8b6508",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkolivegreen1:"caff70",darkolivegreen2:"bcee68",darkolivegreen3:"a2cd5a",darkolivegreen4:"6e8b3d",darkorange:"ff8c00",darkorange1:"ff7f00",darkorange2:"ee7600",darkorange3:"cd6600",darkorange4:"8b4500",darkorchid:"9932cc",darkorchid1:"bf3eff",darkorchid2:"b23aee",darkorchid3:"9a32cd",darkorchid4:"68228b",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkseagreen1:"c1ffc1",darkseagreen2:"b4eeb4",darkseagreen3:"9bcd9b",darkseagreen4:"698b69",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategray1:"97ffff",darkslategray2:"8deeee",darkslategray3:"79cdcd",darkslategray4:"528b8b",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deeppink1:"ff1493",deeppink2:"ee1289",deeppink3:"cd1076",deeppink4:"8b0a50",deepskyblue:"00bfff",deepskyblue1:"00bfff",deepskyblue2:"00b2ee",deepskyblue3:"009acd",deepskyblue4:"00688b",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",dodgerblue1:"1e90ff",dodgerblue2:"1c86ee",dodgerblue3:"1874cd",dodgerblue4:"104e8b",firebrick:"b22222",firebrick1:"ff3030",firebrick2:"ee2c2c",firebrick3:"cd2626",firebrick4:"8b1a1a",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",gold1:"ffd700",gold2:"eec900",gold3:"cdad00",gold4:"8b7500",goldenrod:"daa520",goldenrod1:"ffc125",goldenrod2:"eeb422",goldenrod3:"cd9b1d",goldenrod4:"8b6914",gray:"bebebe",gray0:"000000",gray1:"030303",gray2:"050505",gray3:"080808",gray4:"0a0a0a",gray5:"0d0d0d",gray6:"0f0f0f",gray7:"121212",gray8:"141414",gray9:"171717",gray10:"1a1a1a",gray11:"1c1c1c",gray12:"1f1f1f",gray13:"212121",gray14:"242424",gray15:"262626",gray16:"292929",gray17:"2b2b2b",gray18:"2e2e2e",gray19:"303030",gray20:"333333",gray21:"363636",gray22:"383838",gray23:"3b3b3b",gray24:"3d3d3d",gray25:"404040",gray26:"424242",gray27:"454545",gray28:"474747",gray29:"4a4a4a",gray30:"4d4d4d",gray31:"4f4f4f",gray32:"525252",gray33:"545454",gray34:"575757",gray35:"595959",gray36:"5c5c5c",gray37:"5e5e5e",gray38:"616161",gray39:"636363",gray40:"666666",gray41:"696969",gray42:"6b6b6b",gray43:"6e6e6e",gray44:"707070",gray45:"737373",gray46:"757575",gray47:"787878",gray48:"7a7a7a",gray49:"7d7d7d",gray50:"7f7f7f",gray51:"828282",gray52:"858585",gray53:"878787",gray54:"8a8a8a",gray55:"8c8c8c",gray56:"8f8f8f",gray57:"919191",gray58:"949494",gray59:"969696",gray60:"999999",gray61:"9c9c9c",gray62:"9e9e9e",gray63:"a1a1a1",gray64:"a3a3a3",gray65:"a6a6a6",gray66:"a8a8a8",gray67:"ababab",gray68:"adadad",gray69:"b0b0b0",gray70:"b3b3b3",gray71:"b5b5b5",gray72:"b8b8b8",gray73:"bababa",gray74:"bdbdbd",gray75:"bfbfbf",gray76:"c2c2c2",gray77:"c4c4c4",gray78:"c7c7c7",gray79:"c9c9c9",gray80:"cccccc",gray81:"cfcfcf",gray82:"d1d1d1",gray83:"d4d4d4",gray84:"d6d6d6",gray85:"d9d9d9",gray86:"dbdbdb",gray87:"dedede",gray88:"e0e0e0",gray89:"e3e3e3",gray90:"e5e5e5",gray91:"e8e8e8",gray92:"ebebeb",gray93:"ededed",gray94:"f0f0f0",gray95:"f2f2f2",gray96:"f5f5f5",gray97:"f7f7f7",gray98:"fafafa",gray99:"fcfcfc",gray100:"ffffff",green:"00ff00",green1:"00ff00",green2:"00ee00",green3:"00cd00",green4:"008b00",greenyellow:"adff2f",grey:"bebebe",grey0:"000000",grey1:"030303",grey2:"050505",grey3:"080808",grey4:"0a0a0a",grey5:"0d0d0d",grey6:"0f0f0f",grey7:"121212",grey8:"141414",grey9:"171717",grey10:"1a1a1a",grey11:"1c1c1c",grey12:"1f1f1f",grey13:"212121",grey14:"242424",grey15:"262626",grey16:"292929",grey17:"2b2b2b",grey18:"2e2e2e",grey19:"303030",grey20:"333333",grey21:"363636",grey22:"383838",grey23:"3b3b3b",grey24:"3d3d3d",grey25:"404040",grey26:"424242",grey27:"454545",grey28:"474747",grey29:"4a4a4a",grey30:"4d4d4d",grey31:"4f4f4f",grey32:"525252",grey33:"545454",grey34:"575757",grey35:"595959",grey36:"5c5c5c",grey37:"5e5e5e",grey38:"616161",grey39:"636363",grey40:"666666",grey41:"696969",grey42:"6b6b6b",grey43:"6e6e6e",grey44:"707070",grey45:"737373",grey46:"757575",grey47:"787878",grey48:"7a7a7a",grey49:"7d7d7d",grey50:"7f7f7f",grey51:"828282",grey52:"858585",grey53:"878787",grey54:"8a8a8a",grey55:"8c8c8c",grey56:"8f8f8f",grey57:"919191",grey58:"949494",grey59:"969696",grey60:"999999",grey61:"9c9c9c",grey62:"9e9e9e",grey63:"a1a1a1",grey64:"a3a3a3",grey65:"a6a6a6",grey66:"a8a8a8",grey67:"ababab",grey68:"adadad",grey69:"b0b0b0",grey70:"b3b3b3",grey71:"b5b5b5",grey72:"b8b8b8",grey73:"bababa",grey74:"bdbdbd",grey75:"bfbfbf",grey76:"c2c2c2",grey77:"c4c4c4",grey78:"c7c7c7",grey79:"c9c9c9",grey80:"cccccc",grey81:"cfcfcf",grey82:"d1d1d1",grey83:"d4d4d4",grey84:"d6d6d6",grey85:"d9d9d9",grey86:"dbdbdb",grey87:"dedede",grey88:"e0e0e0",grey89:"e3e3e3",grey90:"e5e5e5",grey91:"e8e8e8",grey92:"ebebeb",grey93:"ededed",grey94:"f0f0f0",grey95:"f2f2f2",grey96:"f5f5f5",grey97:"f7f7f7",grey98:"fafafa",grey99:"fcfcfc",grey100:"ffffff",honeydew:"f0fff0",honeydew1:"f0fff0",honeydew2:"e0eee0",honeydew3:"c1cdc1",honeydew4:"838b83",hotpink:"ff69b4",hotpink1:"ff6eb4",hotpink2:"ee6aa7",hotpink3:"cd6090",hotpink4:"8b3a62",indianred:"cd5c5c",indianred1:"ff6a6a",indianred2:"ee6363",indianred3:"cd5555",indianred4:"8b3a3a",indigo:"4b0082",ivory:"fffff0",ivory1:"fffff0",ivory2:"eeeee0",ivory3:"cdcdc1",ivory4:"8b8b83",khaki:"f0e68c",khaki1:"fff68f",khaki2:"eee685",khaki3:"cdc673",khaki4:"8b864e",lavender:"e6e6fa",lavenderblush:"fff0f5",lavenderblush1:"fff0f5",lavenderblush2:"eee0e5",lavenderblush3:"cdc1c5",lavenderblush4:"8b8386",lawngreen:"7cfc00",lemonchiffon:"fffacd",lemonchiffon1:"fffacd",lemonchiffon2:"eee9bf",lemonchiffon3:"cdc9a5",lemonchiffon4:"8b8970",lightblue:"add8e6",lightblue1:"bfefff",lightblue2:"b2dfee",lightblue3:"9ac0cd",lightblue4:"68838b",lightcoral:"f08080",lightcyan:"e0ffff",lightcyan1:"e0ffff",lightcyan2:"d1eeee",lightcyan3:"b4cdcd",lightcyan4:"7a8b8b",lightgoldenrod:"eedd82",lightgoldenrod1:"ffec8b",lightgoldenrod2:"eedc82",lightgoldenrod3:"cdbe70",lightgoldenrod4:"8b814c",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightpink1:"ffaeb9",lightpink2:"eea2ad",lightpink3:"cd8c95",lightpink4:"8b5f65",lightsalmon:"ffa07a",lightsalmon1:"ffa07a",lightsalmon2:"ee9572",lightsalmon3:"cd8162",lightsalmon4:"8b5742",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightskyblue1:"b0e2ff",lightskyblue2:"a4d3ee",lightskyblue3:"8db6cd",lightskyblue4:"607b8b",lightslateblue:"8470ff",lightslategray:"778899",lightslategrey:"778899",lightsteelblue:"b0c4de",lightsteelblue1:"cae1ff",lightsteelblue2:"bcd2ee",lightsteelblue3:"a2b5cd",lightsteelblue4:"6e7b8b",lightyellow:"ffffe0",lightyellow1:"ffffe0",lightyellow2:"eeeed1",lightyellow3:"cdcdb4",lightyellow4:"8b8b7a",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",magenta1:"ff00ff",magenta2:"ee00ee",magenta3:"cd00cd",magenta4:"8b008b",maroon:"b03060",maroon1:"ff34b3",maroon2:"ee30a7",maroon3:"cd2990",maroon4:"8b1c62",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumorchid1:"e066ff",mediumorchid2:"d15fee",mediumorchid3:"b452cd",mediumorchid4:"7a378b",mediumpurple:"9370db",mediumpurple1:"ab82ff",mediumpurple2:"9f79ee",mediumpurple3:"8968cd",mediumpurple4:"5d478b",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",mistyrose1:"ffe4e1",mistyrose2:"eed5d2",mistyrose3:"cdb7b5",mistyrose4:"8b7d7b",moccasin:"ffe4b5",navajowhite:"ffdead",navajowhite1:"ffdead",navajowhite2:"eecfa1",navajowhite3:"cdb38b",navajowhite4:"8b795e",navy:"000080",navyblue:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",olivedrab1:"c0ff3e",olivedrab2:"b3ee3a",olivedrab3:"9acd32",olivedrab4:"698b22",orange:"ffa500",orange1:"ffa500",orange2:"ee9a00",orange3:"cd8500",orange4:"8b5a00",orangered:"ff4500",orangered1:"ff4500",orangered2:"ee4000",orangered3:"cd3700",orangered4:"8b2500",orchid:"da70d6",orchid1:"ff83fa",orchid2:"ee7ae9",orchid3:"cd69c9",orchid4:"8b4789",palegoldenrod:"eee8aa",palegreen:"98fb98",palegreen1:"9aff9a",palegreen2:"90ee90",palegreen3:"7ccd7c",palegreen4:"548b54",paleturquoise:"afeeee",paleturquoise1:"bbffff",paleturquoise2:"aeeeee",paleturquoise3:"96cdcd",paleturquoise4:"668b8b",palevioletred:"db7093",palevioletred1:"ff82ab",palevioletred2:"ee799f",palevioletred3:"cd6889",palevioletred4:"8b475d",papayawhip:"ffefd5",peachpuff:"ffdab9",peachpuff1:"ffdab9",peachpuff2:"eecbad",peachpuff3:"cdaf95",peachpuff4:"8b7765",peru:"cd853f",pink:"ffc0cb",pink1:"ffb5c5",pink2:"eea9b8",pink3:"cd919e",pink4:"8b636c",plum:"dda0dd",plum1:"ffbbff",plum2:"eeaeee",plum3:"cd96cd",plum4:"8b668b",powderblue:"b0e0e6",purple:"a020f0",purple1:"9b30ff",purple2:"912cee",purple3:"7d26cd",purple4:"551a8b",rebeccapurple:"663399",red:"ff0000",red1:"ff0000",red2:"ee0000",red3:"cd0000",red4:"8b0000",rosybrown:"bc8f8f",rosybrown1:"ffc1c1",rosybrown2:"eeb4b4",rosybrown3:"cd9b9b",rosybrown4:"8b6969",royalblue:"4169e1",royalblue1:"4876ff",royalblue2:"436eee",royalblue3:"3a5fcd",royalblue4:"27408b",saddlebrown:"8b4513",salmon:"fa8072",salmon1:"ff8c69",salmon2:"ee8262",salmon3:"cd7054",salmon4:"8b4c39",sandybrown:"f4a460",seagreen:"2e8b57",seagreen1:"54ff9f",seagreen2:"4eee94",seagreen3:"43cd80",seagreen4:"2e8b57",seashell:"fff5ee",seashell1:"fff5ee",seashell2:"eee5de",seashell3:"cdc5bf",seashell4:"8b8682",sienna:"a0522d",sienna1:"ff8247",sienna2:"ee7942",sienna3:"cd6839",sienna4:"8b4726",silver:"c0c0c0",skyblue:"87ceeb",skyblue1:"87ceff",skyblue2:"7ec0ee",skyblue3:"6ca6cd",skyblue4:"4a708b",slateblue:"6a5acd",slateblue1:"836fff",slateblue2:"7a67ee",slateblue3:"6959cd",slateblue4:"473c8b",slategray:"708090",slategray1:"c6e2ff",slategray2:"b9d3ee",slategray3:"9fb6cd",slategray4:"6c7b8b",slategrey:"708090",snow:"fffafa",snow1:"fffafa",snow2:"eee9e9",snow3:"cdc9c9",snow4:"8b8989",springgreen:"00ff7f",springgreen1:"00ff7f",springgreen2:"00ee76",springgreen3:"00cd66",springgreen4:"008b45",steelblue:"4682b4",steelblue1:"63b8ff",steelblue2:"5cacee",steelblue3:"4f94cd",steelblue4:"36648b",tan:"d2b48c",tan1:"ffa54f",tan2:"ee9a49",tan3:"cd853f",tan4:"8b5a2b",teal:"008080",thistle:"d8bfd8",thistle1:"ffe1ff",thistle2:"eed2ee",thistle3:"cdb5cd",thistle4:"8b7b8b",tomato:"ff6347",tomato1:"ff6347",tomato2:"ee5c42",tomato3:"cd4f39",tomato4:"8b3626",turquoise:"40e0d0",turquoise1:"00f5ff",turquoise2:"00e5ee",turquoise3:"00c5cd",turquoise4:"00868b",violet:"ee82ee",violetred:"d02090",violetred1:"ff3e96",violetred2:"ee3a8c",violetred3:"cd3278",violetred4:"8b2252",webgray:"808080",webgreen:"008000",webgrey:"808080",webmaroon:"800000",webpurple:"800080",wheat:"f5deb3",wheat1:"ffe7ba",wheat2:"eed8ae",wheat3:"cdba96",wheat4:"8b7e66",white:"ffffff",whitesmoke:"f5f5f5",x11gray:"bebebe",x11green:"00ff00",x11grey:"bebebe",x11maroon:"b03060",x11purple:"a020f0",yellow:"ffff00",yellow1:"ffff00",yellow2:"eeee00",yellow3:"cdcd00",yellow4:"8b8b00",yellowgreen:"9acd32"},hg=e=>{const t=fg[e.toLowerCase().replaceAll(" ","")];return t===void 0?void 0:`#${t}`},gg=/^rgba?:([\da-f]{1,4})\/([\da-f]{1,4})\/([\da-f]{1,4})(?:\/[\da-f]{1,4})?$/i,mg=/^#((?:[\da-f]{3}){1,4})$/i,Ut=e=>{const t=16**e.length-1;return Math.round(Number.parseInt(e,16)/t*255)},yg=e=>{const t=e.trim(),n=gg.exec(t);if(n)return{b:Ut(n[3]),g:Ut(n[2]),r:Ut(n[1])};const s=t.startsWith("#")?t:hg(t);if(s===void 0)return;const i=mg.exec(s);if(!i)return;const r=i[1],o=r.length/3;return{b:Ut(r.slice(o*2)),g:Ut(r.slice(o,o*2)),r:Ut(r.slice(0,o))}},Fl=k.createContext({renderThrottleMs:0,subscribe(){return{startTime:0,unsubscribe(){}}}});Fl.displayName="InternalAnimationContext";const so=k.createContext({exit(){},suspendTerminal:(()=>Promise.resolve(void 0)),async waitUntilRenderFlush(){}});so.displayName="InternalAppContext";const Vl=k.createContext({setCursorPosition(){}});Vl.displayName="InternalCursorContext";let vg;const bg=e=>(vg??=Ne(import.meta.url))(e),qt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,wg=e=>{if(typeof qt<"u"&&qt.versions&&qt.versions.node){const[t,n]=qt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return qt.getBuiltinModule(e)}return bg(e)},{existsSync:kg,readFileSync:Sg}=wg("node:fs"),{cwd:xg}=qt,$g=(e,t=2)=>e.replace(/^\t+/gm,n=>" ".repeat(n.length*t)),Eg=(e,t)=>{const n=[],s=e-t,i=e+t;for(let r=s;r<=i;r++)n.push(r);return n},Cg=(e,t,n={})=>{var s;if(typeof e!="string")throw new TypeError("Source code is missing.");if(!t||t<1)throw new TypeError("Line number must start from `1`.");const i=$g(e).split(/\r?\n/);if(!(t>i.length))return Eg(t,(s=n.around)!==null&&s!==void 0?s:3).filter(r=>i[r-1]!==void 0).map(r=>({line:r,value:i[r-1]}))},$i=e=>{if(!e)return e;const t=xg();return e.replace(`file://${t}/`,"").replace(`${t}/`,"")};function Rg({error:e}){const t=nh(e),n=new Map,s=t.map(c=>{const l=!c.methodName&&!c.file?`raw:${c.raw}`:`${$i(c.file)??""}:${c.line}:${c.column}:${c.methodName??""}`,d=n.get(l)??0;return n.set(l,d+1),{key:`${l}#${d}`,trace:c}}),i=t[0],r=$i(i?.file);let o,a=0;if(r&&i?.line&&kg(r)){const c=Sg(r,"utf8");if(o=Cg(c,i.line),o)for(const{line:l}of o)a=Math.max(a,String(l).length)}return v.jsxs(W,{flexDirection:"column",padding:1,children:[v.jsxs(W,{children:[v.jsxs(O,{backgroundColor:"red",color:"white",children:[" ","ERROR"," "]}),v.jsxs(O,{children:[" ",e.message]})]}),i&&r?v.jsx(W,{marginTop:1,children:v.jsxs(O,{dimColor:!0,children:[r,":",i.line,":",i.column]})}):null,i&&o?v.jsx(W,{flexDirection:"column",marginTop:1,children:o.map(({line:c,value:l})=>v.jsxs(W,{children:[v.jsx(W,{width:a+1,children:v.jsxs(O,{"aria-label":c===i.line?`Line ${c}, error`:`Line ${c}`,backgroundColor:c===i.line?"red":void 0,color:c===i.line?"white":void 0,dimColor:c!==i.line,children:[String(c).padStart(a," "),":"]})}),v.jsx(O,{backgroundColor:c===i.line?"red":void 0,color:c===i.line?"white":void 0,children:` ${l}`})]},`excerpt-${c}`))}):null,t.length>0?v.jsx(W,{flexDirection:"column",marginTop:1,children:s.map(({key:c,trace:l})=>{const d=$i(l.file)??"";return!l.methodName&&!l.file?v.jsxs(W,{children:[v.jsx(O,{dimColor:!0,children:"- "}),v.jsx(O,{bold:!0,dimColor:!0,children:l.raw})]},c):v.jsxs(W,{children:[v.jsx(O,{dimColor:!0,children:"- "}),v.jsx(O,{bold:!0,dimColor:!0,children:l.methodName??"<anonymous>"}),v.jsxs(O,{"aria-label":`at ${d} line ${l.line} column ${l.column}`,color:"gray",dimColor:!0,children:[" ","(",d,":",l.line,":",l.column,")"]})]},c)})}):null]})}let Og=class extends k.PureComponent{static displayName="InternalErrorBoundary";static getDerivedStateFromError(t){return{error:t}}state={error:void 0};componentDidCatch(t){this.props.onError(t)}render(){return this.state.error?v.jsx(Rg,{error:this.state.error}):this.props.children}};const io=k.createContext({activate(){},activeId:void 0,add(){},deactivate(){},disableFocus(){},enableFocus(){},focus(){},focusNext(){},focusPrevious(){},remove(){}});io.displayName="InternalFocusContext";const jg=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:Wl,Wl=jg,Hl=k.createContext({stderr:Wl.stderr,write(){}});Hl.displayName="InternalStderrContext";let Tg;const Ig=e=>(Tg??=Ne(import.meta.url))(e),Kt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:Ul,Ag=e=>{if(typeof Kt<"u"&&Kt.versions&&Kt.versions.node){const[t,n]=Kt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Kt.getBuiltinModule(e)}return Ig(e)},{EventEmitter:Bg}=Ag("node:events"),Ul=Kt,oi=k.createContext({internal_eventEmitter:new Bg,internal_exitOnCtrlC:!0,isRawModeSupported:!1,setBracketedPasteMode(){},setRawMode(){},stdin:Ul.stdin});oi.displayName="InternalStdinContext";const Pg=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:Gl,Gl=Pg,ro=k.createContext({stdout:Gl.stdout,write(){}});ro.displayName="InternalStdoutContext";const Ng={bar:6,"blinking-bar":5,"blinking-block":1,"blinking-underline":3,block:2,default:0,underline:4},pa=e=>ag(Ng[e]),fa=(e,t)=>e?.x!==t?.x||e?.y!==t?.y,ai=(e,t)=>{if(!t)return"";const n=e-t.y;return(n>0?Us(n):"")+ri(t.x)+Xn},zl=(e,t)=>{if(!t)return"";const n=e-1-t.y;return(n>0?ng(n):"")+ri(0)},Dg=e=>{const t=e.cursorWasShown?Yn:"",n=zl(e.previousLineCount,e.previousCursorPosition),s=ai(e.visibleLineCount,e.cursorPosition);return t+n+s},ha=(e,t,n)=>e?Yn+zl(t,n):"";let Lg;const Mg=e=>(Lg??=Ne(import.meta.url))(e),En=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ci=e=>{if(typeof En<"u"&&En.versions&&En.versions.node){const[t,n]=En.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return En.getBuiltinModule(e)}return Mg(e)},{existsSync:ga}=ci("node:fs"),{createRequire:_g}=ci("node:module"),{dirname:ma,join:bs}=ci("node:path"),{fileURLToPath:Fg}=ci("node:url"),Vg=12,Wg=e=>{const t=_g(e),n=ma(Fg(e));let s=n;for(let i=0;i<Vg;i+=1){if(ga(bs(s,"package.json"))&&ga(bs(s,"index.js")))return t(bs(s,"index.js"));const r=ma(s);if(r===s)break;s=r}return t(bs(n,"..","index.js"))},ws=new WeakMap,Hg=async(e,t)=>(await e,t()),Jl=(e,t)=>{const n=ws.get(e),s=n===void 0?t():Hg(n,t);let i;return i=(async()=>{try{await s}catch{}ws.get(e)===i&&ws.delete(e)})(),ws.set(e,i),s};let Ug=class{constructor(t,n){this.target=t,this.contentRect=n}target;contentRect};function Gg(e,t,n=!1){const s=e.resizeObservers&&e.resizeObservers.size>0;if((s||n)&&e.yogaNode){const i=Math.round(e.yogaNode.getComputedWidth()),r=Math.round(e.yogaNode.getComputedHeight());if(!Number.isNaN(i)&&!Number.isNaN(r)){const o=e.internal_lastMeasuredSize;if((o?.width!==i||o.height!==r)&&(e.internal_lastMeasuredSize={height:r,width:i},s)){const a=new Ug(e,{height:r,width:i});for(const c of e.resizeObservers)t.has(c)||t.set(c,[]),t.get(c).push(a)}}}}let zg;const Jg=e=>(zg??=Ne(import.meta.url))(e),Yt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:at,oo=e=>{if(typeof Yt<"u"&&Yt.versions&&Yt.versions.node){const[t,n]=Yt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Yt.getBuiltinModule(e)}return Jg(e)},at=Yt,{execFileSync:qg}=oo("node:child_process"),Pn=oo("node:fs"),Kg=oo("node:tty"),ql=80,Kl=24,mr=(e,t,{shell:n,env:s}={})=>qg(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:s}).trim(),Bs=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),Yl=(e,t)=>{const{columns:n,rows:s}=Bs(e,t);if(!(Number.isNaN(n)||Number.isNaN(s))&&!(n===ql&&s===Kl))return{columns:n,rows:s}},Yg=()=>{if(at.platform!=="linux")return!0;try{const e=Pn.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const n=e.slice(t+2).trim().split(/\s+/),s=Number.parseInt(n[2],10),i=Number.parseInt(n[5],10);return Number.isNaN(s)||Number.isNaN(i)||i<=0?!1:s===i}catch{return!1}};function Xg(){const{env:e,stdout:t,stderr:n}=at;if(t?.columns&&t?.rows)return Bs(t.columns,t.rows);if(n?.columns&&n?.rows)return Bs(n.columns,n.rows);if(e.COLUMNS&&e.LINES)return Bs(e.COLUMNS,e.LINES);const s={columns:ql,rows:Kl};return at.platform==="win32"?Ei()??s:at.platform==="darwin"?ya()??Ei()??s:ya()??Ei()??Zg()??s}const ya=()=>{try{const e=at.platform==="darwin"?Pn.constants.O_EVTONLY|Pn.constants.O_NONBLOCK:Pn.constants.O_NONBLOCK,{columns:t,rows:n}=Kg.WriteStream(Pn.openSync("/dev/tty",e));return{columns:t,rows:n}}catch{}},Ei=()=>{try{const e=mr("tput",["cols"],{env:{TERM:"dumb",...at.env}}),t=mr("tput",["lines"],{env:{TERM:"dumb",...at.env}});if(e&&t)return Yl(e,t)}catch{}},Zg=()=>{try{if(!Yg())return;const e=mr("resize",["-u"]).match(/\d+/g);if(e.length===2)return Yl(e[0],e[1])}catch{}},tt=e=>{const{columns:t,rows:n}=e;if(t&&n)return{columns:t,rows:n};const s=Xg();return{columns:t||s.columns||80,rows:n||s.rows||24}};let Qg;const em=e=>(Qg??=Ne(import.meta.url))(e),Xt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,li=e=>{if(typeof Xt<"u"&&Xt.versions&&Xt.versions.node){const[t,n]=Xt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Xt.getBuiltinModule(e)}return em(e)},Te=Xt,{env:Ci}=Te,{PassThrough:va,Stream:tm}=li("node:stream"),{Buffer:ba}=li("node:buffer"),{Console:nm}=li("node:console"),{EventEmitter:sm}=li("node:events"),wa=e=>e in Ci&&Ci[e]!=="0"&&Ci[e]!=="false",Xl=wa("CI")||wa("CONTINUOUS_INTEGRATION"),ka=["assert","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"];let Ri={};const im=e=>{const t=new va,n=new va;t.write=i=>{e("stdout",i)},n.write=i=>{e("stderr",i)};const s=new console.Console(t,n);for(const i of ka)Ri[i]=console[i],console[i]=s[i];return()=>{for(const i of ka)console[i]=Ri[i];Ri={}}},cn=[];cn.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&cn.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&cn.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const Ps=e=>!!e&&!0&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",Oi=Symbol.for("signal-exit emitter"),ji=globalThis,rm=Object.defineProperty.bind(Object);class om{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ji[Oi])return ji[Oi];rm(ji,Oi,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,n){this.listeners[t].push(n)}removeListener(t,n){const s=this.listeners[t],i=s.indexOf(n);i!==-1&&(i===0&&s.length===1?s.length=0:s.splice(i,1))}emit(t,n,s){if(this.emitted[t])return!1;this.emitted[t]=!0;let i=!1;for(const r of this.listeners[t])i=r(n,s)===!0||i;return t==="exit"&&(i=this.emit("afterExit",n,s)||i),i}}let Zl=class{};const am=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});class cm extends Zl{onExit(){return()=>{}}load(){}unload(){}}class lm extends Zl{#e=yr.platform==="win32"?"SIGINT":"SIGHUP";#t=new om;#n;#r;#s;#i={};#o=!1;constructor(t){super(),this.#n=t,this.#i={};for(const n of cn)this.#i[n]=()=>{const s=this.#n.listeners(n);let{count:i}=this.#t;const r=t;if(typeof r.__signal_exit_emitter__=="object"&&typeof r.__signal_exit_emitter__.count=="number"&&(i+=r.__signal_exit_emitter__.count),s.length===i){this.unload();const o=this.#t.emit("exit",null,n),a=n==="SIGHUP"?this.#e:n;o||t.kill(t.pid,a)}};this.#s=t.reallyExit,this.#r=t.emit}onExit(t,n){if(!Ps(this.#n))return()=>{};this.#o===!1&&this.load();const s=n?.alwaysLast?"afterExit":"exit";return this.#t.on(s,t),()=>{this.#t.removeListener(s,t),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(const t of cn)try{const n=this.#i[t];n&&this.#n.on(t,n)}catch{}this.#n.emit=(t,...n)=>this.#c(t,...n),this.#n.reallyExit=t=>this.#a(t)}}unload(){this.#o&&(this.#o=!1,cn.forEach(t=>{const n=this.#i[t];if(!n)throw new Error("Listener not defined for signal: "+t);try{this.#n.removeListener(t,n)}catch{}}),this.#n.emit=this.#r,this.#n.reallyExit=this.#s,this.#t.count-=1)}#a(t){return Ps(this.#n)?(this.#n.exitCode=t||0,this.#t.emit("exit",this.#n.exitCode,null),this.#s.call(this.#n,this.#n.exitCode)):0}#c(t,...n){const s=this.#r;if(t==="exit"&&Ps(this.#n)){typeof n[0]=="number"&&(this.#n.exitCode=n[0]);const i=s.call(this.#n,t,...n);return this.#t.emit("exit",this.#n.exitCode,null),i}else return s.call(this.#n,t,...n)}}const yr=globalThis.process,{onExit:dm}=am(Ps(yr)?new lm(yr):new cm),Gs="\x1B",Ql="\x1B[200~",Sa="\x1B[201~",um=e=>e>=48&&e<=63,pm=e=>e>=32&&e<=47,ed=e=>e>=64&&e<=126,fm=(e,t,n)=>{const s=t+n+1;let i=s;for(;i<e.length;i++){const r=e.codePointAt(i);if(r===void 0)return"pending";if(!(um(r)||pm(r))&&!(r===91&&i===s))return ed(r)?{nextIndex:i+1,sequence:e.slice(t,i+1)}:void 0}return"pending"},hm=(e,t,n)=>{const s=t+n+2;if(s>e.length)return"pending";const i=e.codePointAt(s-1);if(!(i===void 0||!ed(i)))return{nextIndex:s,sequence:e.slice(t,s)}},xa=(e,t,n)=>{const s=e[t+n];if(s===void 0)return"pending";if(s==="[")return fm(e,t,n);if(s==="O")return hm(e,t,n)},gm=(e,t)=>{const n=e.codePointAt(t+1),s=n!==void 0&&n>65535?2:1,i=t+1+s;return{nextIndex:i,sequence:e.slice(t,i)}},mm=(e,t)=>{if(t===e.length-1)return"pending";if(e[t+1]===Gs){if(t+2>=e.length)return"pending";const s=xa(e,t,2);return s==="pending"?"pending":s||{nextIndex:t+2,sequence:e.slice(t,t+2)}}const n=xa(e,t,1);return n==="pending"?"pending":n||gm(e,t)},$a=(e,t)=>{let n=0;for(let s=0;s<e.length;s++){const i=e[s];(i===""||i==="\b")&&(s>n&&t.push(e.slice(n,s)),t.push(i),n=s+1)}n<e.length&&t.push(e.slice(n))},ym=e=>{const t=[];let n=0;const s=i=>({events:t,pending:e.slice(i)});for(;n<e.length;){const i=e.indexOf(Gs,n);if(i===-1)return $a(e.slice(n),t),{events:t,pending:""};i>n&&$a(e.slice(n,i),t);const r=mm(e,i);if(r==="pending")return s(i);if(r.sequence===Ql){const o=r.nextIndex,a=e.indexOf(Sa,o);if(a===-1)return s(i);t.push({paste:e.slice(o,a)}),n=a+Sa.length;continue}t.push(r.sequence),n=r.nextIndex}return{events:t,pending:""}},vm=()=>{let e="";return{flushPendingEscape(){if(!e.startsWith(Gs))return;const t=e;return e="",t},hasPendingEscape(){return e.startsWith(Gs)&&!e.startsWith(Ql)&&e!=="\x1B[200"},push(t){const n=ym(e+t);return e=n.pending,n.events},reset(){e=""}}},bm=" ",wm="\x1B[Z",km="\x1B",Ea=Ll(_l),Ti=Ml(_l),td=({children:e,exitOnCtrlC:t,interactive:n,onExit:s,onRegisterInputControl:i,onSuspendTerminal:r,onWaitUntilRenderFlush:o,renderThrottleMs:a,setCursorPosition:c,stderr:l,stdin:d,stdout:u,writeToStderr:p,writeToStdout:f})=>{const[h,g]=k.useState(!0),[y,x]=k.useState(void 0),[,b]=k.useState([]),S=k.useRef(0),C=k.useRef([]),N=k.useRef(new Map),T=k.useRef(void 0),D=k.useRef(0),F=k.useRef(!1),V=k.useRef(0),[Z]=k.useState(()=>{const L=new sm;return L.setMaxListeners(1/0),L}),re=k.useRef(void 0),te=k.useRef(void 0);te.current??=vm();const ne=k.useRef(void 0),ie=k.useRef(!1),M=20,w=k.useCallback(()=>{ne.current&&(clearTimeout(ne.current),ne.current=void 0)},[]),A=k.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=void 0)},[]),U=k.useCallback(()=>{if(A(),N.current.size===0)return;let L=Number.POSITIVE_INFINITY;for(const X of N.current.values())L=Math.min(L,X.nextDueTime);const Q=Math.max(0,L-performance.now());T.current=setTimeout(()=>{T.current=void 0;const X=performance.now(),pe=[...N.current.values()];for(const $e of pe){if(X<$e.nextDueTime)continue;$e.callback(X);const $f=X-$e.startTime,Ef=Math.floor($f/$e.interval)+1;$e.nextDueTime=$e.startTime+Ef*$e.interval}U()},Q)},[A]),I=k.useCallback((L,Q)=>{const X=performance.now();return N.current.set(L,{callback:L,interval:Q,nextDueTime:X+Q,startTime:X}),U(),{startTime:X,unsubscribe(){if(N.current.delete(L),N.current.size===0){A();return}U()}}},[A,U]);k.useEffect(()=>()=>{A()},[A]);const B=d.isTTY,j=k.useCallback(()=>{re.current&&(d.removeListener("readable",re.current),re.current=void 0)},[d]),_=k.useCallback(()=>{te.current?.reset(),w(),j()},[w,j]),H=k.useCallback(()=>{F.current=!1,d.setRawMode(!1),d.unref(),D.current=0,_()},[d,_]),z=k.useCallback(L=>{B&&(D.current>0||F.current)&&H(),s(L)},[B,H,s]),Y=k.useCallback(L=>{if(L.includes("")&&t){z();return}L===km&&h&&x(Q=>{if(!Q)return Q})},[t,z,h]),P=k.useCallback(L=>{Y(L),Z.emit("input",L)},[Y,Z]),K=k.useCallback(()=>{w(),ne.current=setTimeout(()=>{ne.current=void 0;const L=te.current.flushPendingEscape();L&&P(L)},M)},[w,P]),ae=k.useCallback(()=>{w();let L;for(;(L=d.read())!==null;){const Q=te.current.push(L);for(const X of Q)if(typeof X=="string")P(X);else{if(Z.listenerCount("paste")===0){ie.current||(ie.current=!0,p(`Warning: useInput() received bracketed paste because no usePaste() handler is active. This fallback is deprecated and will be removed in the next major version. Migrate paste handling to usePaste().
2
+ `)),P(X.paste);continue}Z.emit("paste",X.paste)}}te.current.hasPendingEscape()&&K()},[d,P,w,K,p,Z]),le=k.useCallback(()=>{re.current||(re.current=ae,d.addListener("readable",ae))},[d,ae]),ge=k.useCallback(L=>{if(!B)throw d===Te.stdin?new Error(`Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.
3
3
  Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`):new Error(`Raw mode is not supported on the stdin provided to Ink.
4
- Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(d.setEncoding("utf8"),L){if(D.current===0){const Q=F.current;F.current=!1,Q||(d.ref(),d.setRawMode(!0)),le()}D.current++;return}D.current!==0&&--D.current===0&&(_(),F.current=!0,queueMicrotask(()=>{F.current&&H()}))},[P,d,le,_,H]),ke=k.useCallback(L=>{if(u.isTTY){if(L){V.current===0&&u.write(xa),V.current++;return}V.current!==0&&--V.current===0&&u.write(ji)}},[u]),Se=k.useRef({bracketedPaste:!1,rawMode:!1}),wt=k.useCallback(()=>{const L=P&&(D.current>0||F.current),Q=V.current>0;Se.current={bracketedPaste:Q,rawMode:L},Q&&u.isTTY&&u.write(ji),L&&(F.current=!1,_(),d.setRawMode(!1),d.unref())},[P,u,d,_]),_o=k.useCallback(()=>{const{bracketedPaste:L,rawMode:Q}=Se.current;Q&&(d.ref(),d.setRawMode(!0),d.setEncoding("utf8"),le()),L&&u.isTTY&&u.write(xa)},[d,u,le]);k.useEffect(()=>{i(wt,_o)},[i,wt,_o]);const Fo=k.useCallback((L,Q)=>{const X=L.findIndex(pe=>pe.id===Q);for(let pe=X+1;pe<L.length;pe++){const xe=L[pe];if(xe?.isActive)return xe.id}},[]),Vo=k.useCallback((L,Q)=>{const X=L.findIndex(pe=>pe.id===Q);for(let pe=X-1;pe>=0;pe--){const xe=L[pe];if(xe?.isActive)return xe.id}},[]),gs=k.useCallback(()=>{const L=C.current;x(Q=>{const X=L.find(pe=>pe.isActive)?.id;return Fo(L,Q)??X})},[Fo]),ms=k.useCallback(()=>{const L=C.current;x(Q=>{const X=L.findLast(pe=>pe.isActive)?.id;return Vo(L,Q)??X})},[Vo]);k.useEffect(()=>{const L=X=>{!h||S.current===0||(X===gm&&gs(),X===mm&&ms())};Z.on("input",L);const Q=Z;return()=>{Q.off("input",L)}},[h,gs,ms,Z]);const Wo=k.useCallback(()=>{g(!0)},[]),Ho=k.useCallback(()=>{g(!1)},[]),Uo=k.useCallback(L=>{C.current.some(Q=>Q?.id===L)&&x(L)},[]),Go=k.useCallback((L,{autoFocus:Q})=>{const X=[...C.current,{id:L,isActive:!0}];S.current=X.length,C.current=X,b(X),Q&&x(pe=>pe||L)},[]),zo=k.useCallback(L=>{x(X=>{if(X!==L)return X});const Q=C.current.filter(X=>X.id!==L);S.current=Q.length,C.current=Q,b(Q)},[]),Jo=k.useCallback(L=>{const Q=C.current.map(X=>X.id!==L?X:{id:L,isActive:!0});C.current=Q,b(Q)},[]),qo=k.useCallback(L=>{x(X=>{if(X!==L)return X});const Q=C.current.map(X=>X.id!==L?X:{id:L,isActive:!1});C.current=Q,b(Q)},[]);k.useEffect(()=>()=>{const L=!u.destroyed&&!u.writableEnded;n&&L&&u.write(Kn),P&&(D.current>0||F.current)&&H(),V.current>0&&(u.isTTY&&L&&u.write(ji),V.current=0)},[u,P,H,n]);const ff=k.useMemo(()=>({exit:z,suspendTerminal:r,waitUntilRenderFlush:o}),[z,r,o]),hf=k.useMemo(()=>({internal_eventEmitter:Z,internal_exitOnCtrlC:t,isRawModeSupported:P,setBracketedPasteMode:ke,setRawMode:ge,stdin:d}),[d,ge,ke,P,t,Z]),gf=k.useMemo(()=>({stdout:u,write:f}),[u,f]),mf=k.useMemo(()=>({stderr:l,write:p}),[l,p]),yf=k.useMemo(()=>({setCursorPosition:c}),[c]),vf=k.useMemo(()=>({activate:Jo,activeId:y,add:Go,deactivate:qo,disableFocus:Ho,enableFocus:Wo,focus:Uo,focusNext:gs,focusPrevious:ms,remove:zo}),[y,Go,zo,Jo,qo,Wo,Ho,gs,ms,Uo]),bf=k.useMemo(()=>({renderThrottleMs:a,subscribe:I}),[I,a]);return v.jsx(no.Provider,{value:ff,children:v.jsx(ri.Provider,{value:hf,children:v.jsx(io.Provider,{value:gf,children:v.jsx(Fl.Provider,{value:mf,children:v.jsx(so.Provider,{value:vf,children:v.jsx(Ll.Provider,{value:bf,children:v.jsx(Ml.Provider,{value:yf,children:v.jsx($g,{onError:z,children:e})})})})})})})})};Zl.displayName="InternalApp";const vm=(e,t,n)=>{if(n<=0||!e.yogaNode)return"";const{yogaNode:s}=e,i=s.getComputedBorder(Ue.EDGE_LEFT),r=s.getComputedBorder(Ue.EDGE_RIGHT),o=s.getComputedBorder(Ue.EDGE_TOP),a=s.getComputedPadding(Ue.EDGE_LEFT),c=s.getComputedPadding(Ue.EDGE_RIGHT),l=s.getComputedPadding(Ue.EDGE_TOP),d=Math.round(s.getComputedWidth()-i-r-a-c);if(d<=0)return"";const u=new Vf({height:n,width:d}),p=-(e.internal_scrollState?.scrollLeft??0)-i-a,f=-t-o-l;for(const h of e.childNodes)Wf(h,u,{absoluteOffsetX:p,absoluteOffsetY:f,offsetX:p,offsetY:f,skipStaticElements:!1});return u.get().output},yr=new WeakMap,Ut=e=>e??"default",bm=()=>{let e,t;return{consumeDelta:()=>{if(Ut(t)===Ut(e))return"";const n=Ut(t);return e=t,da(n)},consumeRestoreOnDone:()=>{const n=Ut(e)!=="default";return e=void 0,t=void 0,n?da("default"):""},isDirty:()=>Ut(t)!==Ut(e),setPending:n=>{t=n}}},Xn=(e,t)=>t.endsWith(`
5
- `)?e.length-1:e.length,Ql=e=>e.rows||1/0,ed=(e,t)=>Math.min(e,Ql(t)),td=(e,t)=>{const{activeCursor:n,content:s,contentLines:i,previousLines:r,returnPrefix:o,shapeDelta:a}=e,c=oi(Xn(i,s),n);t.write(a+o+Yn(ed(r.length,t))+s+c)},wm=(e,t)=>{const{activeCursor:n,content:s,contentLines:i,previous:r,previousLines:o,returnPrefix:a,shapeDelta:c}=e,l=Xn(i,s);if(s===`
6
- `||r.length===0){td(e,t);return}const d=Xn(o,r),u=s.endsWith(`
7
- `),p=[c,a],f=Ql(t);if(l<d){const h=r.endsWith(`
8
- `)?1:0;p.push(Yn(Math.min(d-l+h,f)),Hs(Math.min(l,f-1)))}else p.push(Hs(Math.min(d-1,f-1)));for(let h=0;h<l;h+=1){const g=h===l-1;if(i[h]===o[h]){(!g||u)&&p.push(tg());continue}p.push(ii(0)+i[h]+rg+(g&&!u?"":`
9
- `))}p.push(oi(l,n)),t.write(p.join(""))},km=(e,{showCursor:t=!1},n)=>{let s=[],i="",r=!1,o,a=!1,c,l=!1;const d=bm(),u=()=>a?o:void 0,p=(y,x)=>{const b=ua(x,c);return y!==i||b||d.isDirty()},f=y=>{c=y?{...y}:void 0,l=y!==void 0},h=()=>{i="",s=[],c=void 0,l=!1},g=y=>{!t&&!r&&(e.write(qn),r=!0);const x=u();a=!1;const b=ua(x,c);if(!p(y,x))return!1;const S=d.consumeDelta(),C=y.split(`
10
- `),N=Xn(C,y);return y===i&&b?(e.write(S+Ag({cursorPosition:x,cursorWasShown:l,previousCursorPosition:c,previousLineCount:s.length,visibleLineCount:N})),f(x),!0):y===i&&S!==""?(e.write(S),f(x),!0):(n({activeCursor:x,content:y,contentLines:C,previous:i,previousLines:s,returnPrefix:pa(l,s.length,c),shapeDelta:S},e),i=y,s=C,f(x),!0)};return g.clear=()=>{const y=pa(l,s.length,c);e.write(y+Yn(ed(s.length,e))),h()},g.done=()=>{h();const y=d.consumeRestoreOnDone();y!==""&&e.write(y),t||(e.write(Kn),r=!1)},g.reset=h,g.sync=y=>{const x=u();a=!1;const b=y.split(`
11
- `);i=y,s=b;const S=d.consumeDelta();S!==""&&e.write(S),!x&&l&&e.write(qn),x&&e.write(oi(Xn(b,y),x)),f(x)},g.setCursorPosition=y=>{o=y,a=!0},g.setCursorShape=d.setPending,g.isCursorDirty=()=>a||d.isDirty(),g.willRender=y=>p(y,u()),g},Sm=(e,{incremental:t=!1,showCursor:n=!1}={})=>km(e,{showCursor:n},t?wm:td),xm={create:Sm},nd=Pl(2026),St=Bl(nd),Qe=Nl(nd);function $m(e,t){return"isTTY"in e&&e.isTTY&&(t??!ql)}let Gt;const Em=()=>{if(Gt!==!1){if(Gt!==void 0)return Gt;try{return Gt=Mg(import.meta.url).Renderer,Gt}catch{Gt=!1;return}}},Cm=e=>{const t=Em();if(!t)return;let n,s=0,i=0;const r=(o,a)=>{(!n||s!==o||i!==a)&&(n?n.resize(o,a):n=new t(o,a),s=o,i=a)};return{clear(){if(n){const o=new Uint32Array(s*i*2),a=65535;for(let c=0;c<o.length;c+=2)o[c]=32,o[c+1]=a;n.render(o)}},destroy(){n=void 0},render(o,a,c){if(r(a,c),!!n){e.isTTY&&n.writeRaw(St);try{n.render(o)}finally{e.isTTY&&n.writeRaw(Qe)}}},resize(o,a){r(o,a)}}};function $a(e,t=0,n={}){const s=n.leading??!0,i=n.trailing??!0;let r,o,a,c;const l=()=>{if(o===void 0)return;const h=o;o=void 0,c=e(...h)},d=()=>{r!==void 0&&(clearTimeout(r),r=void 0)},u=()=>{r=void 0,i&&l(),o=void 0,a=void 0},p=()=>{d(),r=setTimeout(u,t)},f=function(...h){const g=Date.now();if(a??=g,g-a>=t)return o=h,l(),a=g,p(),c;o=h;const y=r===void 0;return p(),s&&y&&l(),c};return f.cancel=()=>{d(),o=void 0,a=void 0},f.flush=()=>(d(),l(),a=void 0,c),f}console.Console||(console.Console=Zg);const Cn=()=>{},Ea=async()=>new Promise(e=>{setImmediate(e)}),Rm=27,Om=91,jm=63,Tm=117,Im=48,Am=57,Pm=e=>e>=Im&&e<=Am,sd=(e,t)=>{if(e[t]!==Rm||e[t+1]!==Om||e[t+2]!==jm)return;let n=t+3;const s=n;for(;n<e.length&&Pm(e[n]);)n++;if(n!==s){if(n===e.length)return{state:"partial"};if(e[n]===Tm)return{endIndex:n,state:"complete"}}},Bm=e=>{for(let t=0;t<e.length;t++)if(sd(e,t)?.state==="complete")return!0;return!1},Nm=e=>{const t=[];let n=0;for(;n<e.length;){const s=sd(e,n);if(s?.state==="complete"){n=s.endIndex+1;continue}if(s?.state==="partial")break;t.push(e[n]),n++}return t},Dm=({isTty:e,isUnmounting:t,isWindows:n,nextOutputHeight:s,previousOutputHeight:i,viewportRows:r})=>{if(!e)return!1;const o=i>0,a=i>=r,c=s>=r,l=i>r,d=s>r,u=a&&s<r;return l||d&&o||u||t&&a||n&&(c||a)},Ti=e=>e instanceof Error||Object.prototype.toString.call(e)==="[object Error]",Ca=e=>{const t=!e.destroyed&&!e.writableEnded&&(e.writable??!0),n=e._writableState!==void 0||e.writableLength!==void 0;return{canWriteToStdout:t,hasWritableState:n}},bs=(e,t)=>{if(!e||typeof e.flush!="function")return;const n=e;t?n.flush():typeof n.cancel=="function"&&n.cancel()};class Lm{isConcurrent;options;log;manualCursorPosition;renderedCursorPosition;renderedCursorRequested;throttledLog;isScreenReaderEnabled;interactive;renderThrottleMs;alternateScreen;isUnmounted;isUnmounting;lastOutput;lastOutputToRender;lastOutputHeight;lastTerminalWidth;nativeLog;useNativeRenderer;container;rootNode;fullStaticOutput;backbufferNode;backbufferMultiWarned=!1;exitPromise;exitResult;beforeExitHandler;restoreConsole;unsubscribeResize;throttledOnRender;hasPendingThrottledRender=!1;kittyProtocolEnabled=!1;kittyFlags;isSuspended=!1;pauseInput;resumeInput;cancelKittyDetection;nextRenderCommit;deferredInitDone=!1;constructor(t){this.options=t,this.rootNode=Af("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.isScreenReaderEnabled=t.isScreenReaderEnabled??Te.env.INK_SCREEN_READER==="true",this.interactive=this.resolveInteractiveOption(t.interactive),this.alternateScreen=!1;const n=t.debug||this.isScreenReaderEnabled,s=t.maxFps??30,i=s>0?Math.max(1,Math.ceil(1e3/s)):0;this.renderThrottleMs=n?0:i;const r=n?this.onRender:(()=>{const a=$a(this.onRender,i,{leading:!0,trailing:!0});return this.throttledOnRender=a,()=>{this.hasPendingThrottledRender=!0,a()}})();if(n&&(this.throttledOnRender=void 0),t.standardReactLayoutTiming){let a=!1;const c=()=>{a||(a=!0,queueMicrotask(()=>{a=!1,this.onRender()}))};this.rootNode.onRender=c,this.rootNode.onImmediateRender=c}else this.rootNode.onRender=r,this.rootNode.onImmediateRender=this.onRender;this.rootNode.onStaticChange=this.handleStaticChange,this.log=xm.create(t.stdout,{incremental:t.incrementalRendering}),this.useNativeRenderer=t.useNativeRenderer??!1,this.useNativeRenderer&&(this.nativeLog=Cm(t.stdout),this.nativeLog||(this.useNativeRenderer=!1)),this.manualCursorPosition=void 0,this.renderedCursorPosition=void 0,this.renderedCursorRequested=!1,this.throttledLog=n?this.log:$a(a=>{const c=this.log.willRender(a),l=this.shouldSync();l&&c&&this.options.stdout.write(St),this.log(a),l&&c&&this.options.stdout.write(Qe)},void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.isUnmounting=!1,this.isConcurrent=t.concurrent??!1,this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.lastTerminalWidth=tt(this.options.stdout).columns,this.fullStaticOutput="";const o=t.concurrent?Ko.ConcurrentRoot:Ko.LegacyRoot;this.container=$e.createContainer(this.rootNode,o,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{}),this.unsubscribeExit=om(this.unmount,{alwaysLast:!1}),this.setAlternateScreen(!!t.alternateScreen),t.patchConsole&&this.patchConsole(),this.interactive&&(t.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{t.stdout.off("resize",this.resized)}),this.initImmediateKittyKeyboard(),Te.env.DEV==="true"&&$e.injectIntoDevTools(),this.exitPromise=new Promise((a,c)=>{this.resolveExitPromise=a,this.rejectExitPromise=c}),this.exitPromise.catch(Cn)}runDeferredInit(){this.deferredInitDone||(this.deferredInitDone=!0,this.initDeferredKittyKeyboard())}resized=()=>{const t=tt(this.options.stdout).columns;t<this.lastTerminalWidth&&(this.log.clear(),this.lastOutput="",this.lastOutputToRender=""),Pf(),this.calculateLayout(),Bf(this.rootNode),this.onRender(),this.lastTerminalWidth=t};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};handleAppExit=t=>{if(!(this.isUnmounted||this.isUnmounting)){if(Ti(t)){this.unmount(t);return}this.exitResult=t,this.unmount()}};getActiveCursorPosition=()=>this.renderedCursorRequested?this.renderedCursorPosition:this.manualCursorPosition;setCursorPosition=t=>{this.manualCursorPosition=t,this.log.setCursorPosition(this.getActiveCursorPosition())};restoreLastOutput=()=>{this.interactive&&(this.log.setCursorPosition(this.getActiveCursorPosition()),this.log(this.lastOutputToRender||`${this.lastOutput}
12
- `))};calculateLayout=()=>{const t=s=>{const i=new Map;this.calculateScrollAndTriggerObservers(s,i);for(const[r,o]of i)r.internalTrigger(o)};this.backbufferNode=void 0,this.prepareYogaTree(this.rootNode,t);const n=tt(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(n),this.rootNode.yogaNode.calculateLayout(void 0,void 0,Ue.DIRECTION_LTR),t(this.rootNode)};calculateScrollAndTriggerObservers(t,n){if(t.nodeName==="ink-box"){const{style:s}=t,i=s.overflow??"visible",r=s.overflowX??i,o=s.overflowY??i;r==="scroll"||o==="scroll"?(Nf(t),s.overflowToBackbuffer&&(this.backbufferNode&&this.backbufferNode!==t&&!this.backbufferMultiWarned&&(this.backbufferMultiWarned=!0,console.warn("[@visulima/tui] Multiple scrollable regions have `overflowToBackbuffer` enabled; only one is supported. The last one in render order wins.")),this.backbufferNode=t)):t.internal_scrollState&&delete t.internal_scrollState}if(Vg(t,n),!t.internal_static)for(const s of t.childNodes)s.nodeName!=="#text"&&this.calculateScrollAndTriggerObservers(s,n)}recalculateLayout(){this.markAllTextNodesDirty(this.rootNode),this.calculateLayout(),this.onRender()}prepareYogaTree(t,n){if(t.isYogaTreeDetached&&!t.cachedRender&&t.yogaNode){for(t.yogaNode.setWidthAuto(),t.yogaNode.setHeightAuto(),Df(t.yogaNode,t.style);t.yogaNode.getChildCount()>0;)t.yogaNode.getChild(0).remove();let s=0;for(const i of t.childNodes){const r=i;i.nodeName!=="#text"&&r.yogaNode&&(t.yogaNode.insertChild(r.yogaNode,s),s++)}t.isYogaTreeDetached=!1,this.markAllTextNodesDirty(t)}for(const s of t.childNodes)s.nodeName!=="#text"&&this.prepareYogaTree(s,n);if(t.nodeName==="ink-static-render"&&!t.cachedRender){const s=tt(this.options.stdout).columns,{width:i}=t.style;t.yogaNode&&(t.yogaNode.setWidth(typeof i=="number"?i:s),t.yogaNode.calculateLayout(void 0,void 0,Ue.DIRECTION_LTR)),n(t),Lf(t,{skipStaticElements:!1,trackSelection:this.options.trackSelection}),t.internal_onRendered?.()}}markAllTextNodesDirty(t){if(!t.cachedRender){t.nodeName==="ink-text"&&t.yogaNode&&t.yogaNode.markDirty();for(const n of t.childNodes)n.nodeName!=="#text"&&this.markAllTextNodesDirty(n)}}handleStaticChange=()=>{this.fullStaticOutput=""};computeBackbufferOutput(){const t=this.backbufferNode;if(!t?.internal_scrollState||!this.interactive||!this.options.stdout.isTTY||this.alternateScreen||this.isScreenReaderEnabled||this.options.debug)return"";const n=Math.round(t.internal_scrollState.scrollTop),s=t.yogaNode?.getComputedPadding(Ue.EDGE_TOP)??0,i=Math.max(0,n-Math.round(s)),r=t.internal_maxPushedScrollTop??0,{maxScrollbackLength:o}=t.style,a=o===void 0?r:Math.max(r,i-Math.max(0,o)),c=i-a;if(c<=0)return"";const l=vm(t,a,c);return l===""?"":(t.internal_maxPushedScrollTop=i,`${l}\x1B[0m
13
- `)}onRender=()=>{if(this.hasPendingThrottledRender=!1,this.isUnmounted)return;this.deferredInitDone||this.runDeferredInit(),this.nextRenderCommit&&(this.nextRenderCommit.resolve(),this.nextRenderCommit=void 0);const t=Mf(this.rootNode,this.isScreenReaderEnabled,{useNativeRenderer:this.useNativeRenderer}),{cursorPosition:n,cursorRequested:s,cursorShape:i,output:r,outputBuffer:o,outputHeight:a,outputWidth:c,staticOutput:l}=t;this.renderedCursorRequested=s,this.renderedCursorPosition=n,this.log.setCursorShape(s?i:void 0);const d=this.computeBackbufferOutput();if(this.useNativeRenderer&&this.nativeLog&&o&&c){l&&l!==`
4
+ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(d.setEncoding("utf8"),L){if(D.current===0){const Q=F.current;F.current=!1,Q||(d.ref(),d.setRawMode(!0)),le()}D.current++;return}D.current!==0&&--D.current===0&&(_(),F.current=!0,queueMicrotask(()=>{F.current&&H()}))},[B,d,le,_,H]),Se=k.useCallback(L=>{if(u.isTTY){if(L){V.current===0&&u.write(Ea),V.current++;return}V.current!==0&&--V.current===0&&u.write(Ti)}},[u]),xe=k.useRef({bracketedPaste:!1,rawMode:!1}),kt=k.useCallback(()=>{const L=B&&(D.current>0||F.current),Q=V.current>0;xe.current={bracketedPaste:Q,rawMode:L},Q&&u.isTTY&&u.write(Ti),L&&(F.current=!1,_(),d.setRawMode(!1),d.unref())},[B,u,d,_]),Vo=k.useCallback(()=>{const{bracketedPaste:L,rawMode:Q}=xe.current;Q&&(d.ref(),d.setRawMode(!0),d.setEncoding("utf8"),le()),L&&u.isTTY&&u.write(Ea)},[d,u,le]);k.useEffect(()=>{i(kt,Vo)},[i,kt,Vo]);const Wo=k.useCallback((L,Q)=>{const X=L.findIndex(pe=>pe.id===Q);for(let pe=X+1;pe<L.length;pe++){const $e=L[pe];if($e?.isActive)return $e.id}},[]),Ho=k.useCallback((L,Q)=>{const X=L.findIndex(pe=>pe.id===Q);for(let pe=X-1;pe>=0;pe--){const $e=L[pe];if($e?.isActive)return $e.id}},[]),ys=k.useCallback(()=>{const L=C.current;x(Q=>{const X=L.find(pe=>pe.isActive)?.id;return Wo(L,Q)??X})},[Wo]),vs=k.useCallback(()=>{const L=C.current;x(Q=>{const X=L.findLast(pe=>pe.isActive)?.id;return Ho(L,Q)??X})},[Ho]);k.useEffect(()=>{const L=X=>{!h||S.current===0||(X===bm&&ys(),X===wm&&vs())};Z.on("input",L);const Q=Z;return()=>{Q.off("input",L)}},[h,ys,vs,Z]);const Uo=k.useCallback(()=>{g(!0)},[]),Go=k.useCallback(()=>{g(!1)},[]),zo=k.useCallback(L=>{C.current.some(Q=>Q?.id===L)&&x(L)},[]),Jo=k.useCallback((L,{autoFocus:Q})=>{const X=[...C.current,{id:L,isActive:!0}];S.current=X.length,C.current=X,b(X),Q&&x(pe=>pe||L)},[]),qo=k.useCallback(L=>{x(X=>{if(X!==L)return X});const Q=C.current.filter(X=>X.id!==L);S.current=Q.length,C.current=Q,b(Q)},[]),Ko=k.useCallback(L=>{const Q=C.current.map(X=>X.id!==L?X:{id:L,isActive:!0});C.current=Q,b(Q)},[]),Yo=k.useCallback(L=>{x(X=>{if(X!==L)return X});const Q=C.current.map(X=>X.id!==L?X:{id:L,isActive:!1});C.current=Q,b(Q)},[]);k.useEffect(()=>()=>{const L=!u.destroyed&&!u.writableEnded;n&&L&&u.write(Xn),B&&(D.current>0||F.current)&&H(),V.current>0&&(u.isTTY&&L&&u.write(Ti),V.current=0)},[u,B,H,n]);const yf=k.useMemo(()=>({exit:z,suspendTerminal:r,waitUntilRenderFlush:o}),[z,r,o]),vf=k.useMemo(()=>({internal_eventEmitter:Z,internal_exitOnCtrlC:t,isRawModeSupported:B,setBracketedPasteMode:Se,setRawMode:ge,stdin:d}),[d,ge,Se,B,t,Z]),bf=k.useMemo(()=>({stdout:u,write:f}),[u,f]),wf=k.useMemo(()=>({stderr:l,write:p}),[l,p]),kf=k.useMemo(()=>({setCursorPosition:c}),[c]),Sf=k.useMemo(()=>({activate:Ko,activeId:y,add:Jo,deactivate:Yo,disableFocus:Go,enableFocus:Uo,focus:zo,focusNext:ys,focusPrevious:vs,remove:qo}),[y,Jo,qo,Ko,Yo,Uo,Go,ys,vs,zo]),xf=k.useMemo(()=>({renderThrottleMs:a,subscribe:I}),[I,a]);return v.jsx(so.Provider,{value:yf,children:v.jsx(oi.Provider,{value:vf,children:v.jsx(ro.Provider,{value:bf,children:v.jsx(Hl.Provider,{value:wf,children:v.jsx(io.Provider,{value:Sf,children:v.jsx(Fl.Provider,{value:xf,children:v.jsx(Vl.Provider,{value:kf,children:v.jsx(Og,{onError:z,children:e})})})})})})})})};td.displayName="InternalApp";const Sm=(e,t,n)=>{if(n<=0||!e.yogaNode)return"";const{yogaNode:s}=e,i=s.getComputedBorder(Ue.EDGE_LEFT),r=s.getComputedBorder(Ue.EDGE_RIGHT),o=s.getComputedBorder(Ue.EDGE_TOP),a=s.getComputedPadding(Ue.EDGE_LEFT),c=s.getComputedPadding(Ue.EDGE_RIGHT),l=s.getComputedPadding(Ue.EDGE_TOP),d=Math.round(s.getComputedWidth()-i-r-a-c);if(d<=0)return"";const u=new Gf({height:n,width:d}),p=-(e.internal_scrollState?.scrollLeft??0)-i-a,f=-t-o-l;for(const h of e.childNodes)zf(h,u,{absoluteOffsetX:p,absoluteOffsetY:f,offsetX:p,offsetY:f,skipStaticElements:!1});return u.get().output},vr=new WeakMap,Gt=e=>e??"default",xm=()=>{let e,t;return{consumeDelta:()=>{if(Gt(t)===Gt(e))return"";const n=Gt(t);return e=t,pa(n)},consumeRestoreOnDone:()=>{const n=Gt(e)!=="default";return e=void 0,t=void 0,n?pa("default"):""},isDirty:()=>Gt(t)!==Gt(e),setPending:n=>{t=n}}},Qn=(e,t)=>t.endsWith(`
5
+ `)?e.length-1:e.length,nd=e=>e.rows||1/0,sd=(e,t)=>Math.min(e,nd(t)),id=(e,t)=>{const{activeCursor:n,content:s,contentLines:i,previousLines:r,returnPrefix:o,shapeDelta:a}=e,c=ai(Qn(i,s),n);t.write(a+o+Zn(sd(r.length,t))+s+c)},$m=(e,t)=>{const{activeCursor:n,content:s,contentLines:i,previous:r,previousLines:o,returnPrefix:a,shapeDelta:c}=e,l=Qn(i,s);if(s===`
6
+ `||r.length===0){id(e,t);return}const d=Qn(o,r),u=s.endsWith(`
7
+ `),p=[c,a],f=nd(t);if(l<d){const h=r.endsWith(`
8
+ `)?1:0;p.push(Zn(Math.min(d-l+h,f)),Us(Math.min(l,f-1)))}else p.push(Us(Math.min(d-1,f-1)));for(let h=0;h<l;h+=1){const g=h===l-1;if(i[h]===o[h]){(!g||u)&&p.push(rg());continue}p.push(ri(0)+i[h]+lg+(g&&!u?"":`
9
+ `))}p.push(ai(l,n)),t.write(p.join(""))},Em=(e,{showCursor:t=!1},n)=>{let s=[],i="",r=!1,o,a=!1,c,l=!1;const d=xm(),u=()=>a?o:void 0,p=(y,x)=>{const b=fa(x,c);return y!==i||b||d.isDirty()},f=y=>{c=y?{...y}:void 0,l=y!==void 0},h=()=>{i="",s=[],c=void 0,l=!1},g=y=>{!t&&!r&&(e.write(Yn),r=!0);const x=u();a=!1;const b=fa(x,c);if(!p(y,x))return!1;const S=d.consumeDelta(),C=y.split(`
10
+ `),N=Qn(C,y);return y===i&&b?(e.write(S+Dg({cursorPosition:x,cursorWasShown:l,previousCursorPosition:c,previousLineCount:s.length,visibleLineCount:N})),f(x),!0):y===i&&S!==""?(e.write(S),f(x),!0):(n({activeCursor:x,content:y,contentLines:C,previous:i,previousLines:s,returnPrefix:ha(l,s.length,c),shapeDelta:S},e),i=y,s=C,f(x),!0)};return g.clear=()=>{const y=ha(l,s.length,c);e.write(y+Zn(sd(s.length,e))),h()},g.done=()=>{h();const y=d.consumeRestoreOnDone();y!==""&&e.write(y),t||(e.write(Xn),r=!1)},g.reset=h,g.sync=y=>{const x=u();a=!1;const b=y.split(`
11
+ `);i=y,s=b;const S=d.consumeDelta();S!==""&&e.write(S),!x&&l&&e.write(Yn),x&&e.write(ai(Qn(b,y),x)),f(x)},g.setCursorPosition=y=>{o=y,a=!0},g.setCursorShape=d.setPending,g.isCursorDirty=()=>a||d.isDirty(),g.willRender=y=>p(y,u()),g},Cm=(e,{incremental:t=!1,showCursor:n=!1}={})=>Em(e,{showCursor:n},t?$m:id),Rm={create:Cm},rd=Dl(2026),xt=Ll(rd),Qe=Ml(rd);function Om(e,t){return"isTTY"in e&&e.isTTY&&(t??!Xl)}let zt;const jm=()=>{if(zt!==!1){if(zt!==void 0)return zt;try{return zt=Wg(import.meta.url).Renderer,zt}catch{zt=!1;return}}},Tm=e=>{const t=jm();if(!t)return;let n,s=0,i=0;const r=(o,a)=>{(!n||s!==o||i!==a)&&(n?n.resize(o,a):n=new t(o,a),s=o,i=a)};return{clear(){if(n){const o=new Uint32Array(s*i*2),a=65535;for(let c=0;c<o.length;c+=2)o[c]=32,o[c+1]=a;n.render(o)}},destroy(){n=void 0},render(o,a,c){if(r(a,c),!!n){e.isTTY&&n.writeRaw(xt);try{n.render(o)}finally{e.isTTY&&n.writeRaw(Qe)}}},resize(o,a){r(o,a)}}};function Ca(e,t=0,n={}){const s=n.leading??!0,i=n.trailing??!0;let r,o,a,c;const l=()=>{if(o===void 0)return;const h=o;o=void 0,c=e(...h)},d=()=>{r!==void 0&&(clearTimeout(r),r=void 0)},u=()=>{r=void 0,i&&l(),o=void 0,a=void 0},p=()=>{d(),r=setTimeout(u,t)},f=function(...h){const g=Date.now();if(a??=g,g-a>=t)return o=h,l(),a=g,p(),c;o=h;const y=r===void 0;return p(),s&&y&&l(),c};return f.cancel=()=>{d(),o=void 0,a=void 0},f.flush=()=>(d(),l(),a=void 0,c),f}console.Console||(console.Console=nm);const Cn=()=>{},Ra=async()=>new Promise(e=>{setImmediate(e)}),Im=27,Am=91,Bm=63,Pm=117,Nm=48,Dm=57,Lm=e=>e>=Nm&&e<=Dm,od=(e,t)=>{if(e[t]!==Im||e[t+1]!==Am||e[t+2]!==Bm)return;let n=t+3;const s=n;for(;n<e.length&&Lm(e[n]);)n++;if(n!==s){if(n===e.length)return{state:"partial"};if(e[n]===Pm)return{endIndex:n,state:"complete"}}},Mm=e=>{for(let t=0;t<e.length;t++)if(od(e,t)?.state==="complete")return!0;return!1},_m=e=>{const t=[];let n=0;for(;n<e.length;){const s=od(e,n);if(s?.state==="complete"){n=s.endIndex+1;continue}if(s?.state==="partial")break;t.push(e[n]),n++}return t},Fm=({isTty:e,isUnmounting:t,isWindows:n,nextOutputHeight:s,previousOutputHeight:i,viewportRows:r})=>{if(!e)return!1;const o=i>0,a=i>=r,c=s>=r,l=i>r,d=s>r,u=a&&s<r;return l||d&&o||u||t&&a||n&&(c||a)},Ii=e=>e instanceof Error||Object.prototype.toString.call(e)==="[object Error]",Oa=e=>{const t=!e.destroyed&&!e.writableEnded&&(e.writable??!0),n=e._writableState!==void 0||e.writableLength!==void 0;return{canWriteToStdout:t,hasWritableState:n}},ks=(e,t)=>{if(!e||typeof e.flush!="function")return;const n=e;t?n.flush():typeof n.cancel=="function"&&n.cancel()};class Vm{isConcurrent;options;log;manualCursorPosition;renderedCursorPosition;renderedCursorRequested;throttledLog;isScreenReaderEnabled;interactive;renderThrottleMs;alternateScreen;isUnmounted;isUnmounting;lastOutput;lastOutputToRender;lastOutputHeight;lastTerminalWidth;nativeLog;useNativeRenderer;container;rootNode;fullStaticOutput;backbufferNode;backbufferMultiWarned=!1;exitPromise;exitResult;beforeExitHandler;restoreConsole;unsubscribeResize;throttledOnRender;hasPendingThrottledRender=!1;kittyProtocolEnabled=!1;kittyFlags;isSuspended=!1;pauseInput;resumeInput;cancelKittyDetection;nextRenderCommit;deferredInitDone=!1;constructor(t){this.options=t,this.rootNode=Df("ink-root"),this.rootNode.onComputeLayout=this.calculateLayout,this.isScreenReaderEnabled=t.isScreenReaderEnabled??Te.env.INK_SCREEN_READER==="true",this.interactive=this.resolveInteractiveOption(t.interactive),this.alternateScreen=!1;const n=t.debug||this.isScreenReaderEnabled,s=t.maxFps??30,i=s>0?Math.max(1,Math.ceil(1e3/s)):0;this.renderThrottleMs=n?0:i;const r=n?this.onRender:(()=>{const a=Ca(this.onRender,i,{leading:!0,trailing:!0});return this.throttledOnRender=a,()=>{this.hasPendingThrottledRender=!0,a()}})();if(n&&(this.throttledOnRender=void 0),t.standardReactLayoutTiming){let a=!1;const c=()=>{a||(a=!0,queueMicrotask(()=>{a=!1,this.onRender()}))};this.rootNode.onRender=c,this.rootNode.onImmediateRender=c}else this.rootNode.onRender=r,this.rootNode.onImmediateRender=this.onRender;this.rootNode.onStaticChange=this.handleStaticChange,this.log=Rm.create(t.stdout,{incremental:t.incrementalRendering}),this.useNativeRenderer=t.useNativeRenderer??!1,this.useNativeRenderer&&(this.nativeLog=Tm(t.stdout),this.nativeLog||(this.useNativeRenderer=!1)),this.manualCursorPosition=void 0,this.renderedCursorPosition=void 0,this.renderedCursorRequested=!1,this.throttledLog=n?this.log:Ca(a=>{const c=this.log.willRender(a),l=this.shouldSync();l&&c&&this.options.stdout.write(xt),this.log(a),l&&c&&this.options.stdout.write(Qe)},void 0,{leading:!0,trailing:!0}),this.isUnmounted=!1,this.isUnmounting=!1,this.isConcurrent=t.concurrent??!1,this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.lastTerminalWidth=tt(this.options.stdout).columns,this.fullStaticOutput="";const o=t.concurrent?Xo.ConcurrentRoot:Xo.LegacyRoot;this.container=Ee.createContainer(this.rootNode,o,null,!1,null,"id",()=>{},()=>{},()=>{},()=>{}),this.unsubscribeExit=dm(this.unmount,{alwaysLast:!1}),this.setAlternateScreen(!!t.alternateScreen),t.patchConsole&&this.patchConsole(),this.interactive&&(t.stdout.on("resize",this.resized),this.unsubscribeResize=()=>{t.stdout.off("resize",this.resized)}),this.initImmediateKittyKeyboard(),Te.env.DEV==="true"&&Ee.injectIntoDevTools(),this.exitPromise=new Promise((a,c)=>{this.resolveExitPromise=a,this.rejectExitPromise=c}),this.exitPromise.catch(Cn)}runDeferredInit(){this.deferredInitDone||(this.deferredInitDone=!0,this.initDeferredKittyKeyboard())}resized=()=>{const t=tt(this.options.stdout).columns;t<this.lastTerminalWidth&&(this.log.clear(),this.lastOutput="",this.lastOutputToRender=""),Lf(),this.calculateLayout(),Mf(this.rootNode),this.onRender(),this.lastTerminalWidth=t};resolveExitPromise=()=>{};rejectExitPromise=()=>{};unsubscribeExit=()=>{};handleAppExit=t=>{if(!(this.isUnmounted||this.isUnmounting)){if(Ii(t)){this.unmount(t);return}this.exitResult=t,this.unmount()}};getActiveCursorPosition=()=>this.renderedCursorRequested?this.renderedCursorPosition:this.manualCursorPosition;setCursorPosition=t=>{this.manualCursorPosition=t,this.log.setCursorPosition(this.getActiveCursorPosition())};restoreLastOutput=()=>{this.interactive&&(this.log.setCursorPosition(this.getActiveCursorPosition()),this.log(this.lastOutputToRender||`${this.lastOutput}
12
+ `))};calculateLayout=()=>{const t=s=>{const i=new Map;this.calculateScrollAndTriggerObservers(s,i);for(const[r,o]of i)r.internalTrigger(o)};this.backbufferNode=void 0,this.prepareYogaTree(this.rootNode,t);const n=tt(this.options.stdout).columns;this.rootNode.yogaNode.setWidth(n),this.rootNode.yogaNode.calculateLayout(void 0,void 0,Ue.DIRECTION_LTR),t(this.rootNode)};calculateScrollAndTriggerObservers(t,n){if(t.nodeName==="ink-box"){const{style:s}=t,i=s.overflow??"visible",r=s.overflowX??i,o=s.overflowY??i;r==="scroll"||o==="scroll"?(_f(t),s.overflowToBackbuffer&&(this.backbufferNode&&this.backbufferNode!==t&&!this.backbufferMultiWarned&&(this.backbufferMultiWarned=!0,console.warn("[@visulima/tui] Multiple scrollable regions have `overflowToBackbuffer` enabled; only one is supported. The last one in render order wins.")),this.backbufferNode=t)):t.internal_scrollState&&delete t.internal_scrollState}if(Gg(t,n),!t.internal_static)for(const s of t.childNodes)s.nodeName!=="#text"&&this.calculateScrollAndTriggerObservers(s,n)}recalculateLayout(){this.markAllTextNodesDirty(this.rootNode),this.calculateLayout(),this.onRender()}prepareYogaTree(t,n){if(t.isYogaTreeDetached&&!t.cachedRender&&t.yogaNode){for(t.yogaNode.setWidthAuto(),t.yogaNode.setHeightAuto(),Ff(t.yogaNode,t.style);t.yogaNode.getChildCount()>0;)t.yogaNode.getChild(0).remove();let s=0;for(const i of t.childNodes){const r=i;i.nodeName!=="#text"&&r.yogaNode&&(t.yogaNode.insertChild(r.yogaNode,s),s++)}t.isYogaTreeDetached=!1,this.markAllTextNodesDirty(t)}for(const s of t.childNodes)s.nodeName!=="#text"&&this.prepareYogaTree(s,n);if(t.nodeName==="ink-static-render"&&!t.cachedRender){const s=tt(this.options.stdout).columns,{width:i}=t.style;t.yogaNode&&(t.yogaNode.setWidth(typeof i=="number"?i:s),t.yogaNode.calculateLayout(void 0,void 0,Ue.DIRECTION_LTR)),n(t),Vf(t,{skipStaticElements:!1,trackSelection:this.options.trackSelection}),t.internal_onRendered?.()}}markAllTextNodesDirty(t){if(!t.cachedRender){t.nodeName==="ink-text"&&t.yogaNode&&t.yogaNode.markDirty();for(const n of t.childNodes)n.nodeName!=="#text"&&this.markAllTextNodesDirty(n)}}handleStaticChange=()=>{this.fullStaticOutput=""};computeBackbufferOutput(){const t=this.backbufferNode;if(!t?.internal_scrollState||!this.interactive||!this.options.stdout.isTTY||this.alternateScreen||this.isScreenReaderEnabled||this.options.debug)return"";const n=Math.round(t.internal_scrollState.scrollTop),s=t.yogaNode?.getComputedPadding(Ue.EDGE_TOP)??0,i=Math.max(0,n-Math.round(s)),r=t.internal_maxPushedScrollTop??0,{maxScrollbackLength:o}=t.style,a=o===void 0?r:Math.max(r,i-Math.max(0,o)),c=i-a;if(c<=0)return"";const l=Sm(t,a,c);return l===""?"":(t.internal_maxPushedScrollTop=i,`${l}\x1B[0m
13
+ `)}onRender=()=>{if(this.hasPendingThrottledRender=!1,this.isUnmounted)return;this.deferredInitDone||this.runDeferredInit(),this.nextRenderCommit&&(this.nextRenderCommit.resolve(),this.nextRenderCommit=void 0);const t=Wf(this.rootNode,this.isScreenReaderEnabled,{useNativeRenderer:this.useNativeRenderer}),{cursorPosition:n,cursorRequested:s,cursorShape:i,output:r,outputBuffer:o,outputHeight:a,outputWidth:c,staticOutput:l}=t;this.renderedCursorRequested=s,this.renderedCursorPosition=n,this.log.setCursorShape(s?i:void 0);const d=this.computeBackbufferOutput();if(this.useNativeRenderer&&this.nativeLog&&o&&c){l&&l!==`
14
14
  `&&this.options.stdout.write(l),d&&this.options.stdout.write(d),this.nativeLog.render(o,c,a),this.lastOutputHeight=a;return}s&&this.log.setCursorPosition(this.getActiveCursorPosition());const u=l&&l!==`
15
15
  `;if(this.options.debug){u&&(this.fullStaticOutput+=l),this.lastOutput=r,this.lastOutputToRender=r,this.lastOutputHeight=a,this.options.stdout.write(this.fullStaticOutput+r);return}if(!this.interactive){u&&this.options.stdout.write(l),this.lastOutput=r,this.lastOutputToRender=`${r}
16
- `,this.lastOutputHeight=a;return}if(this.isScreenReaderEnabled){const p=this.shouldSync();if(p&&this.options.stdout.write(St),u){const g=this.lastOutputHeight>0?Yn(this.lastOutputHeight):"";this.options.stdout.write(g+l),this.lastOutputHeight=0}if(r===this.lastOutput&&!u){p&&this.options.stdout.write(Qe);return}const f=tt(this.options.stdout).columns,h=_f(r,{trim:!1,width:f,wrapMode:"BREAK_WORDS"}).replace(/\n$/,"");if(u)this.options.stdout.write(h);else{const g=this.lastOutputHeight>0?Yn(this.lastOutputHeight):"";this.options.stdout.write(g+h)}this.lastOutput=r,this.lastOutputToRender=h,this.lastOutputHeight=h===""?0:h.split(`
17
- `).length,p&&this.options.stdout.write(Qe);return}u&&(this.fullStaticOutput+=l),this.renderInteractiveFrame(r,a,u?l:"",d)};accessibilityContextValue;render(t){this.accessibilityContextValue??={isScreenReaderEnabled:this.isScreenReaderEnabled};const n=v.jsx(Ff.Provider,{value:this.accessibilityContextValue,children:v.jsx(Zl,{exitOnCtrlC:this.options.exitOnCtrlC,interactive:this.interactive,onExit:this.handleAppExit,onRegisterInputControl:this.registerInputControl,onSuspendTerminal:this.suspendTerminal,onWaitUntilRenderFlush:this.waitUntilRenderFlush,renderThrottleMs:this.renderThrottleMs,setCursorPosition:this.setCursorPosition,stderr:this.options.stderr,stdin:this.options.stdin,stdout:this.options.stdout,writeToStderr:this.writeToStderr,writeToStdout:this.writeToStdout,children:t})});this.options.concurrent?$e.updateContainer(n,this.container,null,Cn):($e.updateContainerSync(n,this.container,null,Cn),$e.flushSyncWork())}writeToStdout=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stdout.write(t+this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stdout.write(t);return}const n=this.shouldSync();n&&this.options.stdout.write(St),this.log.clear(),this.options.stdout.write(t),this.restoreLastOutput(),n&&this.options.stdout.write(Qe)};writeToStderr=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stderr.write(t),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stderr.write(t);return}const n=this.shouldSync();n&&this.options.stdout.write(St),this.log.clear(),this.options.stderr.write(t),this.restoreLastOutput(),n&&this.options.stdout.write(Qe)};unmount=t=>{if(this.isUnmounted||this.isUnmounting)return;this.isUnmounting=!0,this.beforeExitHandler&&(Te.off("beforeExit",this.beforeExitHandler),this.beforeExitHandler=void 0);const n=this.options.stdout,{canWriteToStdout:s,hasWritableState:i}=Ca(n);bs(this.throttledOnRender,s),s&&!this.alternateScreen&&(!this.throttledOnRender||!this.hasPendingThrottledRender&&this.fullStaticOutput==="")&&(this.calculateLayout(),this.onRender()),this.isUnmounted=!0,this.unsubscribeExit(),bs(this.throttledLog,s),typeof this.restoreConsole=="function"&&this.restoreConsole();const r=()=>{typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),this.cancelKittyDetection&&this.cancelKittyDetection(),s&&(this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen?(this.log.clear(),this.log.done(),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.fullStaticOutput="",this.writeBestEffort(this.options.stdout,la),this.writeBestEffort(this.options.stdout,Kn),this.alternateScreen=!1):this.interactive?this.options.debug||this.log.done():this.options.stdout.write(this.options.debug?`
16
+ `,this.lastOutputHeight=a;return}if(this.isScreenReaderEnabled){const p=this.shouldSync();if(p&&this.options.stdout.write(xt),u){const g=this.lastOutputHeight>0?Zn(this.lastOutputHeight):"";this.options.stdout.write(g+l),this.lastOutputHeight=0}if(r===this.lastOutput&&!u){p&&this.options.stdout.write(Qe);return}const f=tt(this.options.stdout).columns,h=Hf(r,{trim:!1,width:f,wrapMode:"BREAK_WORDS"}).replace(/\n$/,"");if(u)this.options.stdout.write(h);else{const g=this.lastOutputHeight>0?Zn(this.lastOutputHeight):"";this.options.stdout.write(g+h)}this.lastOutput=r,this.lastOutputToRender=h,this.lastOutputHeight=h===""?0:h.split(`
17
+ `).length,p&&this.options.stdout.write(Qe);return}u&&(this.fullStaticOutput+=l),this.renderInteractiveFrame(r,a,u?l:"",d)};accessibilityContextValue;render(t){this.accessibilityContextValue??={isScreenReaderEnabled:this.isScreenReaderEnabled};const n=v.jsx(Uf.Provider,{value:this.accessibilityContextValue,children:v.jsx(td,{exitOnCtrlC:this.options.exitOnCtrlC,interactive:this.interactive,onExit:this.handleAppExit,onRegisterInputControl:this.registerInputControl,onSuspendTerminal:this.suspendTerminal,onWaitUntilRenderFlush:this.waitUntilRenderFlush,renderThrottleMs:this.renderThrottleMs,setCursorPosition:this.setCursorPosition,stderr:this.options.stderr,stdin:this.options.stdin,stdout:this.options.stdout,writeToStderr:this.writeToStderr,writeToStdout:this.writeToStdout,children:t})});this.options.concurrent?Ee.updateContainer(n,this.container,null,Cn):(Ee.updateContainerSync(n,this.container,null,Cn),Ee.flushSyncWork())}writeToStdout=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stdout.write(t+this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stdout.write(t);return}const n=this.shouldSync();n&&this.options.stdout.write(xt),this.log.clear(),this.options.stdout.write(t),this.restoreLastOutput(),n&&this.options.stdout.write(Qe)};writeToStderr=t=>{if(this.isUnmounted)return;if(this.options.debug){this.options.stderr.write(t),this.options.stdout.write(this.fullStaticOutput+this.lastOutput);return}if(!this.interactive){this.options.stderr.write(t);return}const n=this.shouldSync();n&&this.options.stdout.write(xt),this.log.clear(),this.options.stderr.write(t),this.restoreLastOutput(),n&&this.options.stdout.write(Qe)};unmount=t=>{if(this.isUnmounted||this.isUnmounting)return;this.isUnmounting=!0,this.beforeExitHandler&&(Te.off("beforeExit",this.beforeExitHandler),this.beforeExitHandler=void 0);const n=this.options.stdout,{canWriteToStdout:s,hasWritableState:i}=Oa(n);ks(this.throttledOnRender,s),s&&!this.alternateScreen&&(!this.throttledOnRender||!this.hasPendingThrottledRender&&this.fullStaticOutput==="")&&(this.calculateLayout(),this.onRender()),this.isUnmounted=!0,this.unsubscribeExit(),ks(this.throttledLog,s),typeof this.restoreConsole=="function"&&this.restoreConsole();const r=()=>{typeof this.unsubscribeResize=="function"&&this.unsubscribeResize(),this.cancelKittyDetection&&this.cancelKittyDetection(),s&&(this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen?(this.log.clear(),this.log.done(),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.fullStaticOutput="",this.writeBestEffort(this.options.stdout,ua),this.writeBestEffort(this.options.stdout,Xn),this.alternateScreen=!1):this.interactive?this.options.debug||this.log.done():this.options.stdout.write(this.options.debug?`
18
18
  `:`${this.lastOutput}
19
- `)),this.kittyProtocolEnabled=!1,yr.delete(this.options.stdout);const{exitResult:a}=this,c=()=>{Ti(t)?this.rejectExitPromise(t):this.resolveExitPromise(a)};t!==void 0&&!Ti(t)?c():s&&i?this.options.stdout.write("",c):setImmediate(c)},o=$e;this.options.concurrent?($e.updateContainerSync(null,this.container,null,Cn),$e.flushSyncWork(),o.flushPassiveEffects?.(),r()):($e.updateContainerSync(null,this.container,null,Cn),$e.flushSyncWork(),r())};async waitUntilExit(){return this.beforeExitHandler||(this.beforeExitHandler=()=>{this.unmount()},Te.on("beforeExit",this.beforeExitHandler)),this.exitPromise}async waitUntilRenderFlush(){if(this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(await Ea(),this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(this.isConcurrent&&this.hasPendingConcurrentWork()&&(await Promise.race([this.awaitNextRender(),this.awaitExit()]),this.isUnmounted||this.isUnmounting)){this.nextRenderCommit=void 0,await this.awaitExit();return}$e.flushSyncWork();const t=this.options.stdout,{canWriteToStdout:n,hasWritableState:s}=Ca(t);if(bs(this.throttledOnRender,n),bs(this.throttledLog,n),n&&s){await new Promise(i=>{this.options.stdout.write("",()=>{i()})});return}await Ea()}clear(){!this.interactive||this.options.debug||(this.log.clear(),this.log.sync(this.lastOutputToRender||`${this.lastOutput}
20
- `))}patchConsole(){this.options.debug||(this.restoreConsole=em((t,n)=>{t==="stdout"&&this.writeToStdout(n),t==="stderr"&&(n.startsWith("The above error occurred")||this.writeToStderr(n))}))}setAlternateScreen(t){this.alternateScreen=this.resolveAlternateScreenOption(t,this.interactive),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,ca),this.writeBestEffort(this.options.stdout,qn))}resolveInteractiveOption(t){return t??(!ql&&this.options.stdout.isTTY)}resolveAlternateScreenOption(t,n){return!!t&&n&&this.options.stdout.isTTY}shouldSync(){return $m(this.options.stdout,this.interactive)}writeBestEffort(t,n){try{t.write(n)}catch{}}async awaitExit(){try{await this.exitPromise}catch{}}hasPendingConcurrentWork(){const t=this.container;return(t.pendingLanes??0)!==0&&t.callbackNode!==void 0&&t.callbackNode!==null}async awaitNextRender(){if(!this.nextRenderCommit){let t;const n=new Promise(s=>{t=s});this.nextRenderCommit={promise:n,resolve:t}}return this.nextRenderCommit.promise}renderInteractiveFrame(t,n,s,i=""){const r=s+i,o=r!=="",a=this.options.stdout.isTTY,c=a?tt(this.options.stdout).rows:24,l=a&&n>=c,d=l?t:`${t}
21
- `,u=Te.platform==="win32",p=a&&u&&(l||this.lastOutputHeight>=c);if(Dm({isTty:a,isUnmounting:this.isUnmounting,isWindows:u,nextOutputHeight:n,previousOutputHeight:this.lastOutputHeight,viewportRows:c})){if(this.options.incrementalRendering&&!p){o&&(this.log.clear(),this.options.stdout.write(r)),(t!==this.lastOutput||this.log.isCursorDirty()||o)&&this.throttledLog(d),this.lastOutput=t,this.lastOutputToRender=d,this.lastOutputHeight=n;return}const f=this.shouldSync();f&&this.options.stdout.write(St),this.options.stdout.write(og+this.fullStaticOutput+i+d),this.lastOutput=t,this.lastOutputToRender=d,this.lastOutputHeight=n,this.log.sync(d),f&&this.options.stdout.write(Qe);return}if(o){const f=this.shouldSync();f&&this.options.stdout.write(St),this.log.clear(),this.options.stdout.write(r),this.log(d),f&&this.options.stdout.write(Qe)}else(t!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(d);this.lastOutput=t,this.lastOutputToRender=d,this.lastOutputHeight=n}initImmediateKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="enabled")return;const n=t.flags??["disambiguateEscapeCodes"];this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(n)}initDeferredKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="auto")return;const n=t.flags??["disambiguateEscapeCodes"];!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(n)}confirmKittySupport(t){Ul(this.options.stdin,async()=>this.runKittySupportQuery(t))}async runKittySupportQuery(t){const{stdin:n,stdout:s}=this.options;let i=[],r,o;const a=()=>{this.cancelKittyDetection=void 0,r&&clearTimeout(r),n.removeListener("data",c);const l=Nm(i);i=[],l.length>0&&n.unshift(ya.from(l))},c=l=>{const d=typeof l=="string"?ya.from(l):l;for(const u of d)i.push(u);Bm(i)&&(a(),this.isUnmounted||this.enableKittyProtocol(t),o?.())};return n.on("data",c),s.write("\x1B[?u"),new Promise(l=>{o=l,r=setTimeout(()=>{a(),l()},200),this.cancelKittyDetection=()=>{a(),l()}})}registerInputControl=(t,n)=>{this.pauseInput=t,this.resumeInput=n};suspendTerminal=(async t=>{if(this.beginSuspend(),t){try{await t()}finally{await this.endSuspend()}return}const n=async()=>{await this.endSuspend()};return{resume:n,[Symbol.asyncDispose]:n}});beginSuspend(){if(this.isSuspended)throw new Error("The terminal is already suspended. Resume the current suspension before suspending again.");if(this.isSuspended=!0,!(!this.interactive||this.isUnmounted||this.isUnmounting))try{this.log.clear(),this.log.done(),this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,la),this.writeBestEffort(this.options.stdout,Kn)),this.pauseInput?.()}catch(t){this.isSuspended=!1;try{this.resumeInput?.()}catch{}throw t}}async endSuspend(){if(this.isSuspended&&(this.isSuspended=!1,this.resumeInput?.(),!(!this.interactive||this.isUnmounted||this.isUnmounting))){this.alternateScreen&&this.writeBestEffort(this.options.stdout,ca),this.kittyProtocolEnabled&&this.kittyFlags&&this.writeBestEffort(this.options.stdout,`\x1B[>${aa(this.kittyFlags)}u`),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.log.reset();try{this.calculateLayout(),this.onRender(),await this.waitUntilRenderFlush()}catch{}}}enableKittyProtocol(t){this.kittyFlags=t,this.options.stdout.write(`\x1B[>${aa(t)}u`),this.kittyProtocolEnabled=!0}}const Mm=(e,t)=>{const n={alternateScreen:!1,concurrent:!1,debug:!1,exitOnCtrlC:!0,incrementalRendering:!1,maxFps:30,patchConsole:!0,stderr:Te.stderr,stdin:Te.stdin,stdout:Te.stdout,..._m(t)},s=Fm(n.stdout,()=>new Lm(n));return s.render(e),{cleanup(){s.unmount()},clear(){s.clear()},rerender(i){s.render(i)},rootNode:s.rootNode,unmount(){s.unmount()},waitUntilExit(){return s.waitUntilExit()},waitUntilRenderFlush(){return s.waitUntilRenderFlush()}}},_m=(e={})=>e instanceof Xg?{stdin:Te.stdin,stdout:e}:e,Fm=(e,t)=>{const n=yr.get(e);if(n===void 0){const s=t();return yr.set(e,s),s}return Te.stderr.write(`Warning: render() was called again for the same stdout before the previous Ink instance was unmounted. Reusing stdout across multiple render() calls is unsupported. Call unmount() first.
22
- `),n},Qt="\x07",oo="\x1B",en=`${oo}]`,Ra=`${oo}\\`,li=16,Vm=3+li,Wm=8192,Hm=e=>{const t=e.lastIndexOf(";"),n=fg(t===-1?e:e.slice(t+1));if(n===void 0)return null;const s=i=>i.toString(16).padStart(2,"0");return`#${s(n.r)}${s(n.g)}${s(n.b)}`},Um=()=>{const e=process.env.TERM_PROGRAM??"";return new Set(["Alacritty","contour","foot","Ghostty","iTerm2","iTerm.app","kitty","rio","WezTerm"]).has(e)?!0:(process.env.TERM??"").startsWith("xterm")||!!process.env.WT_SESSION},Gm=(e,t)=>{const n=Hm(e);if(n===null)return!1;if(e.startsWith("10;"))return t.foreground=n,!0;if(e.startsWith("11;"))return t.background=n,!0;if(e.startsWith("12;"))return t.cursor=n,!0;if(e.startsWith("4;")){const s=e.indexOf(";",2),i=Number(e.slice(2,s===-1?e.length:s));if(Number.isSafeInteger(i)&&i>=0&&i<li)return t.colors[i]=n,!0}return!1},zm=()=>{const e=[`${en}10;?${Qt}`,`${en}11;?${Qt}`,`${en}12;?${Qt}`];for(let t=0;t<li;t+=1)e.push(`${en}4;${String(t)};?${Qt}`);return e.join("")},Gs=new WeakMap,Jm=e=>{const t=[];let n="",s=e;for(;;){const i=s.indexOf(en);if(i===-1){const d=s.endsWith(oo)?1:0;return n+=s.slice(0,s.length-d),{answers:t,foreign:n,rest:s.slice(s.length-d)}}n+=s.slice(0,i),s=s.slice(i);const r=s.indexOf(Qt),o=s.indexOf(Ra),a=r!==-1,c=o!==-1;if(!a&&!c)return{answers:t,foreign:n,rest:s};const l=a&&(!c||r<o)?r:o;t.push(s.slice(en.length,l)),s=s.slice(l+(l===r?Qt.length:Ra.length))}},qm=async(e,t,n)=>new Promise(s=>{const i={colors:Array.from({length:li})};let r="",o="",a=0,c=!1;const l=e.listenerCount("data")===0;let d;const u=f=>{const h=Jm(o+f.toString());r+=h.foreign,o=h.rest;for(const g of h.answers)Gm(g,i)&&(a+=1);(a>=Vm||o.length+r.length>Wm)&&p()};function p(){if(c)return;c=!0,d&&clearTimeout(d);const f=e.listenerCount("data")===1;e.removeListener("data",u);const h=r+o;if(l&&f&&h.length>0)try{e.pause(),e.unshift(h)}catch{}const g={};i.foreground&&(g.foreground=i.foreground),i.background&&(g.background=i.background),i.cursor&&(g.cursor=i.cursor),i.colors.some(Boolean)&&(g.colors=i.colors.map(y=>y??"")),s(g)}e.on("data",u),d=setTimeout(p,n),t.write(zm())}),Km=async(e,t)=>{const n=Promise.withResolvers(),s=()=>{n.resolve({})};t.addEventListener("abort",s,{once:!0});try{return await Promise.race([e,n.promise])}finally{t.removeEventListener("abort",s)}},Ym=async(e,t,n)=>{let s;try{s=await Ul(e,async()=>qm(e,t,n))}catch(i){throw Gs.delete(t),i}return Object.keys(s).length===0&&Gs.delete(t),s},Xm=async(e,t,n=500,s)=>{if(s?.aborted)return{};let i=Gs.get(t);return i||(i=Ym(e,t,n),Gs.set(t,i)),s?Km(i,s):i},id=()=>k.useContext(io),rd=()=>{const{stdout:e}=id(),[t,n]=k.useState(()=>tt(e));return k.useEffect(()=>{const s=()=>{n(tt(e))};return e.on("resize",s),()=>{e.off("resize",s)}},[e]),t},Zm=()=>k.useContext(ri),od=()=>k.useContext(ri);class Qm{#e;#t=new Set;constructor(t){this.#e={applyProgress:null,checkedItems:new Set(t.map(n=>n.entry.id)),error:null,focusedPanel:"list",items:t,phase:"browsing",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#t.add(t),()=>{this.#t.delete(t)});getCheckedItems(){return this.#e.items.filter(t=>this.#e.checkedItems.has(t.entry.id))}getSelectedItem(){return this.#e.items[this.#e.selectedIndex]??null}setSelectedIndex(t){const n=Math.max(0,Math.min(t,this.#e.items.length-1));n!==this.#e.selectedIndex&&this.#n({...this.#e,selectedIndex:n})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#n({...this.#e,focusedPanel:t})}toggleCheck(t){const n=new Set(this.#e.checkedItems);n.has(t)?n.delete(t):n.add(t),this.#n({...this.#e,checkedItems:n})}checkAll(){this.#n({...this.#e,checkedItems:new Set(this.#e.items.map(t=>t.entry.id))})}uncheckAll(){this.#n({...this.#e,checkedItems:new Set})}toggleAll(){this.#e.checkedItems.size===this.#e.items.length?this.uncheckAll():this.checkAll()}startApply(){const t=this.getCheckedItems().length;this.#n({...this.#e,applyProgress:{current:0,total:t},phase:"applying"})}updateApplyProgress(t){this.#e.applyProgress&&this.#n({...this.#e,applyProgress:{...this.#e.applyProgress,current:t}})}markDone(){this.#n({...this.#e,phase:"done"})}setError(t){this.#n({...this.#e,error:t,phase:"error"})}#n(t){this.#e=t;for(const n of this.#t)try{n()}catch{}}}const ad=()=>k.useContext(no);let ey;const ty=e=>(ey??=Ne(import.meta.url))(e),Rn=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ny=e=>{if(typeof Rn<"u"&&Rn.versions&&Rn.versions.node){const[t,n]=Rn.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Rn.getBuiltinModule(e)}return ty(e)},{Buffer:sy}=ny("node:buffer"),iy=/^\u001B([a-z0-9])$/i,ry=/^\u001B+([ON[]|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,cd={"[1~":"home","[2$":"insert","[2^":"insert","[2~":"insert","[3$":"delete","[3^":"delete","[3~":"delete","[4~":"end","[5$":"pageup","[5^":"pageup","[5~":"pageup","[6$":"pagedown","[6^":"pagedown","[6~":"pagedown","[7$":"home","[7^":"home","[7~":"home","[8$":"end","[8^":"end","[8~":"end","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[[5~":"pageup","[[6~":"pagedown","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[A":"up","[a":"up","[B":"down","[b":"down","[C":"right","[c":"right","[D":"left","[d":"left","[E":"clear","[e":"clear","[F":"end","[H":"home","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[Z":"tab",OA:"up",Oa:"up",OB:"down",Ob:"down",OC:"right",Oc:"right",OD:"left",Od:"left",OE:"clear",Oe:"clear",OF:"end",OH:"home",OP:"f1",OQ:"f2",OR:"f3",OS:"f4"},oy=[...Object.values(cd),"backspace"],ay=e=>["[2$","[3$","[5$","[6$","[7$","[8$","[a","[b","[c","[d","[e","[Z"].includes(e),cy=e=>["[2^","[3^","[5^","[6^","[7^","[8^","Oa","Ob","Oc","Od","Oe"].includes(e),ld=/^\u001B\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,ly=/^\u001B\[(\d+);(\d+):(\d+)([A-Z~])$/i,dy={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},uy={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},Oa={8:"backspace",9:"tab",27:"escape",127:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},dd=e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),Ii=e=>dd(e)?String.fromCodePoint(e):"?";function ud(e){return e===3?"release":e===2?"repeat":"press"}function pd(e){return{capsLock:!!(e&Xe.capsLock),ctrl:!!(e&Xe.ctrl),hyper:!!(e&Xe.hyper),meta:!!(e&Xe.meta),numLock:!!(e&Xe.numLock),option:!!(e&Xe.alt),shift:!!(e&Xe.shift),super:!!(e&Xe.super)}}const py=e=>{const t=ld.exec(e);if(!t)return null;const n=Number.parseInt(t[1],10),s=t[2]?Math.max(0,Number.parseInt(t[2],10)-1):0,i=t[3]?Number.parseInt(t[3],10):1,r=t[4];if(!dd(n))return null;let o;r&&(o=r.split(":").map(l=>Ii(Number.parseInt(l,10))).join(""));let a,c;return n===32?(a="space",c=!0):n===13?(a="return",c=!0):Oa[n]?(a=Oa[n],c=!1):n>=1&&n<=26?(a=String.fromCodePoint(n+96),c=!1):(a=Ii(n).toLowerCase(),c=!0),c&&!o&&(o=Ii(n)),{name:a,...pd(s),eventType:ud(i),isKittyProtocol:!0,isPrintable:c,raw:e,sequence:e,text:o}},fy=e=>{const t=ly.exec(e);if(!t)return null;const n=Number.parseInt(t[1],10),s=Math.max(0,Number.parseInt(t[2],10)-1),i=Number.parseInt(t[3],10),r=t[4],o=r==="~"?uy[n]:dy[r];return o?{name:o,...pd(s),eventType:ud(i),isKittyProtocol:!0,isPrintable:!1,raw:e,sequence:e}:null},hy=(e="")=>{let t;sy.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B${String(e)}`):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");const n=py(e);if(n)return n;const s=fy(e);if(s)return s;if(ld.test(e))return{ctrl:!1,isKittyProtocol:!0,isPrintable:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};const i={ctrl:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};switch(i.sequence=i.sequence||e||i.name,e){case"\r":case"\x1B\r":{i.raw=void 0,i.name="return",i.option=e.length===2;break}case`
23
- `:{i.name="enter";break}case" ":{i.name="tab";break}case" ":case"\x1B ":{i.name="space",i.meta=e.length===2;break}case"\b":case"\x1B\b":{i.name="backspace",i.meta=e.charAt(0)==="\x1B";break}case"\x1B":case"\x1B\x1B":{i.name="escape",i.meta=e.length===2;break}case"\x1B":case"":{i.name="backspace",i.meta=e.charAt(0)==="\x1B";break}default:if(e.length===1&&e<="")i.name=String.fromCharCode(e.charCodeAt(0)+97-1),i.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")i.name="number";else if(e.length===1&&e>="a"&&e<="z")i.name=e;else if(e.length===1&&e>="A"&&e<="Z")i.name=e.toLowerCase(),i.shift=!0;else if(t=iy.exec(e))i.meta=!0,i.shift=/^[A-Z]$/.test(t[1]);else if(t=ry.exec(e)){const r=[...e];r[0]==="\x1B"&&r[1]==="\x1B"&&(i.option=!0);const o=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;i.ctrl=!!(a&4),i.meta=!!(a&10),i.shift=!!(a&1),i.code=o,i.name=cd[o]??"",i.shift=ay(o)||i.shift,i.ctrl=cy(o)||i.ctrl}}return i},ao=(e,t={})=>{const{internal_eventEmitter:n,internal_exitOnCtrlC:s,setRawMode:i,stdin:r}=od(),o=t.imeEnabled??!0,a=t.imeTimeout??50,c=k.useRef(void 0),l=k.useEffectEvent(e);k.useEffect(()=>{if(o)return c.current=new zh({onFlush:d=>{const u={backspace:!1,capsLock:!1,ctrl:!1,delete:!1,downArrow:!1,end:!1,escape:!1,home:!1,hyper:!1,leftArrow:!1,meta:!1,numLock:!1,pageDown:!1,pageUp:!1,return:!1,rightArrow:!1,shift:!1,super:!1,tab:!1,upArrow:!1};$e.discreteUpdates(()=>{l(d,u)})},timeout:a}),()=>{c.current?.destroy(),c.current=void 0}},[o,a]),k.useEffect(()=>{if(t.isActive!==!1)return i(!0),()=>{i(!1)}},[t.isActive,i]),k.useLayoutEffect(()=>{if(t.isActive===!1)return;const d=u=>{if(o&&Gh(u)){c.current?.add(u);return}c.current?.flush();const p=hy(u),f={backspace:p.name==="backspace",capsLock:p.capsLock??!1,ctrl:p.ctrl,delete:p.name==="delete",downArrow:p.name==="down",end:p.name==="end",escape:p.name==="escape",eventType:p.eventType,home:p.name==="home",hyper:p.hyper??!1,leftArrow:p.name==="left",meta:p.meta||p.option,numLock:p.numLock??!1,pageDown:p.name==="pagedown",pageUp:p.name==="pageup",return:p.name==="return",rightArrow:p.name==="right",shift:p.shift,super:p.super??!1,tab:p.name==="tab",upArrow:p.name==="up"};let h;p.isKittyProtocol?p.isPrintable?h=p.text??p.name:p.ctrl&&p.name.length===1?h=p.name:h="":p.ctrl?h=p.name:h=p.sequence,!p.isKittyProtocol&&oy.includes(p.name)&&(h=""),h.startsWith("\x1B")&&(h=h.slice(1)),h.length===1&&typeof h[0]=="string"&&/[A-Z]/.test(h[0])&&(f.shift=!0),!(h==="c"&&f.ctrl&&s)&&(!p.name&&h===""||$e.discreteUpdates(()=>{l(h,f)}))};return n.on("input",d),()=>{n.removeListener("input",d)}},[t.isActive,r,s,o])},gy=()=>{const{stdin:e}=od(),{stdout:t}=id(),[n,s]=k.useState(null),[i,r]=k.useState(!0),o=k.useMemo(()=>Um(),[]);return k.useEffect(()=>{if(!o||!e||!t){r(!1);return}const a=new AbortController;return(async()=>{try{const c=await Xm(e,t,200,a.signal);a.signal.aborted||s(c)}catch{}finally{a.signal.aborted||r(!1)}})(),()=>{a.abort()}},[o,e,t]),{isLoading:i,isSupported:o,palette:n}},my=({autoFocus:e=!1,id:t,isActive:n=!0}={})=>{const{isRawModeSupported:s,setRawMode:i}=Zm(),{activate:r,activeId:o,add:a,deactivate:c,focus:l,remove:d}=k.useContext(so),u=k.useMemo(()=>t??Math.random().toString().slice(2,7),[t]);return k.useEffect(()=>(a(u,{autoFocus:e}),()=>{d(u)}),[u,e]),k.useEffect(()=>{n?r(u):c(u)},[n,u]),k.useEffect(()=>{if(!(!s||!n))return i(!0),()=>{i(!1)}},[n]),{focus:l,isFocused:!!u&&o===u}},yy=e=>{const{getViewportHeight:t,isActive:n=!0,scrollBy:s,scrollToBottom:i,scrollToTop:r,vimBindings:o=!1}=e,{isFocused:a}=my({isActive:n});return ao((c,l)=>{if(l.upArrow){s(-1);return}if(l.downArrow){s(1);return}if(l.pageUp){s(-t());return}if(l.pageDown){s(t());return}if(l.home){r();return}if(l.end){i();return}if(l.ctrl&&c==="u"){s(-Math.floor(t()/2));return}if(l.ctrl&&c==="d"){s(Math.floor(t()/2));return}if(o){if(c==="k"){s(-1);return}if(c==="j"){s(1);return}if(c==="G"&&l.shift){i();return}if(c==="g"&&!l.shift){r();return}if(c==="u"&&!l.ctrl){s(-Math.floor(t()/2));return}c==="d"&&!l.ctrl&&s(Math.floor(t()/2))}},{isActive:n}),{isFocused:a}},vr=e=>{const[t,n]=k.useState(e),s=k.useRef(e),i=k.useCallback(o=>{const a=typeof o=="function"?o(s.current):o;s.current=a,n(a)},[]),r=k.useCallback(()=>s.current,[]);return[t,i,r]},vy=({children:e,index:t,measureKey:n,onMeasure:s,width:i})=>{const r=k.useRef(null);return k.useLayoutEffect(()=>{if(r.current){const{height:o}=hl(r.current);s(t,o)}},[t,s,i,n,e]),v.jsx(W,{flexDirection:"column",flexShrink:0,ref:r,width:"100%",children:e})},zs=e=>{if(e==null)return[];if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n+=1){const s=e[n];k.isValidElement(s)&&s.type===k.Fragment?t.push(...zs(s.props.children)):t.push(s)}return t}return k.isValidElement(e)&&e.type===k.Fragment?zs(e.props.children):[e]},ja=({children:e,debug:t=!1,onContentHeightChange:n,onItemHeightChange:s,onViewportSizeChange:i,overscan:r=3,ref:o,scrollOffset:a,virtualize:c=!1,...l})=>{const d=k.useRef(!1),[u,p,f]=vr({height:0,width:0}),[h,g,y]=vr(0),[x,b]=k.useState({}),S=k.useRef(null),C=k.useRef(0);k.useLayoutEffect(()=>{h!==C.current&&(n?.(h,C.current),C.current=h)},[h,n]);const N=k.useRef({}),T=k.useRef([]),D=k.useRef([]),F=k.useRef(0),V=k.useCallback((I,P)=>{const j=T.current[I]??I;if(N.current[j]!==P){const _=N.current[j]??0;N.current={...N.current,[j]:P};let H=0;for(let Y=0;Y<T.current.length;Y+=1){const B=T.current[Y];B!=null&&(H+=N.current[B]??0)}const z=y();H!==z&&g(H),s?.(I,P,_),F.current=Math.min(F.current,I+1)}},[s,y,g]),Z=k.useCallback(()=>{if(S.current){const{height:I,width:P}=hl(S.current),j=f();(P!==j.width||I!==j.height)&&(i?.({height:I,width:P},j),p({height:I,width:P}))}},[S,i,f,p]);k.useLayoutEffect(()=>{Z()});const re=k.useRef(null);if(re.current!==e){re.current=e;const I=[],P={};zs(e).forEach((H,z)=>{if(!H)return;const Y=(k.isValidElement(H)?H.key:null)??z;I[z]=Y;const B=N.current[Y]??0;P[Y]=B}),N.current=P,T.current=I,D.current=Array.from({length:I.length}).fill(0),F.current=0;let j=0;I.forEach(H=>{j+=P[H]??0});const _=y();j!==_&&g(j)}k.useImperativeHandle(o,()=>({getBottomOffset:()=>Math.max(0,y()-f().height),getContentHeight:y,getItemHeight:I=>{const P=T.current[I]??I;return N.current[P]??0},getItemPosition:I=>{if(I<0||I>=T.current.length)return null;if(I>=F.current){let _=0,H=0;if(F.current>0){H=F.current;const z=H-1,Y=T.current[z]??z,B=N.current[Y]??0;_=(D.current[z]??0)+B}for(let z=H;z<=I;z+=1){D.current[z]=_;const Y=T.current[z]??z,B=N.current[Y]??0;_+=B}F.current=I+1}const P=D.current[I]??0,j=T.current[I]??I;return{height:N.current[j]??0,top:P}},getViewportHeight:()=>f().height,remeasure:Z,remeasureItem:I=>{b(P=>({...P,[I]:(P[I]??0)+1}))}}),[Z,y,f,b]);const te=zs(e);!d.current&&h>0&&(d.current=!0);let ne=0,ie=te.length-1,M=0,w=0;const A=te.length>0&&te.every((I,P)=>{const j=T.current[P]??P;return(N.current[j]??0)>0}),U=c&&d.current&&A;if(U){const I=T.current.length;if(F.current<I){let j=0,_=0;if(F.current>0){_=F.current;const H=_-1,z=T.current[H]??H,Y=N.current[z]??0;j=(D.current[H]??0)+Y}for(let H=_;H<I;H+=1){D.current[H]=j;const z=T.current[H]??H;j+=N.current[z]??0}F.current=I}const P=a+u.height;ne=te.length,ie=-1;for(let j=0;j<I;j+=1){const _=D.current[j]??0,H=T.current[j]??j,z=N.current[H]??0;_+z>a&&_<P&&(j<ne&&(ne=j),ie=j)}if(ne>ie&&(ne=0,ie=-1),ne=Math.max(0,ne-r),ie=Math.min(te.length-1,Math.max(-1,ie)+r),M=D.current[ne]??0,ie<te.length-1){const j=T.current[ie]??ie,_=(D.current[ie]??0)+(N.current[j]??0);w=h-_}}return v.jsx(W,{...l,children:v.jsx(W,{ref:S,width:"100%",children:v.jsx(W,{overflow:t?void 0:"hidden",width:"100%",children:v.jsxs(W,{flexDirection:"column",marginTop:-a,width:"100%",children:[U&&M>0&&v.jsx(W,{height:M}),te.map((I,P)=>!I||U&&(P<ne||P>ie)?null:v.jsx(vy,{index:P,measureKey:x[P],onMeasure:V,width:u.width,children:I},k.isValidElement(I)?I.key??P:P)),U&&w>0&&v.jsx(W,{height:w})]})})})})},Ta={arrow:{lowerThumb:"╽",thumb:"┃",track:"|",upperThumb:"╿"},block:{thumb:"█",track:"░"},bold:{lowerThumb:"╿",thumb:"│",track:"┃",upperThumb:"╽"},classic:{thumb:"┃",track:"|"},dots:{thumb:"●",track:"·"},double:{thumb:"┃",track:"║"},doubleSingle:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},line:{thumb:"│",track:" "},round:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},single:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},singleDouble:{thumb:"┃",track:"║"},thick:{thumb:"┃",track:"╏"}},Ia={arrow:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},bold:{bottomLeft:"┗",bottomRight:"┛",topLeft:"┏",topRight:"┓"},classic:{bottomLeft:"+",bottomRight:"+",topLeft:"+",topRight:"+"},double:{bottomLeft:"╚",bottomRight:"╝",topLeft:"╔",topRight:"╗"},doubleSingle:{bottomLeft:"╘",bottomRight:"╛",topLeft:"╒",topRight:"╕"},round:{bottomLeft:"╰",bottomRight:"╯",topLeft:"╭",topRight:"╮"},single:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},singleDouble:{bottomLeft:"╙",bottomRight:"╜",topLeft:"╓",topRight:"╖"}},by=e=>Ta[typeof e=="string"?e:"single"]??Ta.single??{thumb:"┃",track:"│"},wy=e=>Ia[typeof e=="string"?e:"single"]??Ia.single??{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},fd=({autoHide:e=!1,color:t,contentHeight:n,dimColor:s,placement:i="right",scrollOffset:r,style:o,thumbChar:a,trackChar:c,viewportHeight:l})=>{const d=k.useMemo(()=>{const h=Math.max(n,l);if(e&&h<=l)return null;const g=by(o),y=a??g.thumb,x=c??g.track,b=l*2,S=Math.min(l/h,1),C=Math.max(2,Math.round(b*S)),N=h-l,T=N>0?Math.min(Math.max(r/N,0),1):0,D=b-C,F=Math.round(T*D),V=F+C,Z=[];for(let re=0;re<l;re+=1){const te=re*2,ne=re*2+1,ie=te>=F&&te<V,M=ne>=F&&ne<V;ie&&M?Z.push(y):ie&&!M?Z.push(g.lowerThumb??y):!ie&&M?Z.push(g.upperThumb??y):Z.push(x)}return Z},[n,l,r,o,a,c,e]);if(d===null)return null;if(i==="inset")return v.jsx(W,{flexDirection:"column",flexShrink:0,width:1,children:d.map((h,g)=>v.jsx(O,{color:t,dimColor:s,children:h},g))});const u=wy(o),p=i==="left"?u.topLeft:u.topRight,f=i==="left"?u.bottomLeft:u.bottomRight;return v.jsxs(W,{flexDirection:"column",flexShrink:0,width:1,children:[v.jsx(O,{color:t,dimColor:s,children:p}),d.map((h,g)=>v.jsx(O,{color:t,dimColor:s,children:h},g)),v.jsx(O,{color:t,dimColor:s,children:f})]})},hd=({children:e,debug:t=!1,followOutput:n=!1,followThreshold:s=3,keyboard:i=!1,onContentHeightChange:r,onItemHeightChange:o,onReachEnd:a,onReachStart:c,onScroll:l,onViewportSizeChange:d,overscan:u,reachThreshold:p=5,ref:f,scrollbar:h=!1,scrollbarColor:g,scrollbarStyle:y="line",vimBindings:x=!1,virtualize:b,...S})=>{const[C,N,T]=vr(0),D=k.useRef(null),F=k.useRef(0),V=k.useRef(0),[Z,re]=k.useState(0),[te,ne]=k.useState(0),ie=k.useRef(!1),M=k.useRef(!1),w=k.useCallback(()=>Math.max(0,F.current-V.current),[]),A=k.useCallback(B=>{const K=w();a&&B>=K-p&&!ie.current?(ie.current=!0,a()):B<K-p&&(ie.current=!1),c&&B<=p&&!M.current?(M.current=!0,c()):B>p&&(M.current=!1)},[a,c,p,w]),U=k.useCallback(B=>{B!==T()&&(N(B),l?.(B),A(B))},[T,N,l,A]),I=k.useCallback((B,K)=>{const ae=T()>=w()-s;if(F.current=B,re(B),r?.(B,K),n&&ae&&B>K){const le=Math.max(0,B-V.current);U(le)}else{const le=Math.max(0,B-V.current);T()>le&&U(le)}},[r,n,s,T,w,U]),P=k.useCallback((B,K)=>{V.current=B.height,ne(B.height),d?.(B,K)},[d]),j=k.useCallback(B=>{if(typeof B!="number"||Number.isNaN(B))return;const K=Math.max(0,F.current-V.current),ae=Math.max(0,Math.min(T()+B,K));U(ae)},[T,U]),_=k.useCallback(B=>{if(typeof B!="number"||Number.isNaN(B))return;const K=Math.max(0,F.current-V.current),ae=Math.max(0,Math.min(B,K));U(ae)},[U]),H=k.useCallback(()=>{const B=w();U(B)},[w,U]),z=k.useCallback(()=>{U(0)},[U]),Y=k.useCallback(()=>V.current,[]);return yy({getViewportHeight:Y,isActive:i,scrollBy:j,scrollToBottom:H,scrollToTop:z,vimBindings:x}),k.useImperativeHandle(f,()=>({getBottomOffset:w,getContentHeight:()=>F.current,getItemHeight:B=>D.current?.getItemHeight(B)??0,getItemPosition:B=>D.current?.getItemPosition(B)??null,getScrollOffset:T,getViewportHeight:()=>V.current,remeasure:()=>D.current?.remeasure(),remeasureItem:B=>D.current?.remeasureItem(B),scrollBy:j,scrollTo:_,scrollToBottom:H,scrollToTop:z}),[w,T,j,_,H,z]),h&&Z>te&&te>0?v.jsxs(W,{flexDirection:"row",flexGrow:S.flexGrow,flexShrink:S.flexShrink,overflow:"hidden",children:[v.jsx(ja,{children:e,debug:t,onContentHeightChange:I,onItemHeightChange:o,onViewportSizeChange:P,overscan:u,ref:D,scrollOffset:C,virtualize:b,...S,flexGrow:1}),v.jsx(fd,{color:g,contentHeight:Z,placement:"inset",scrollOffset:C,style:y,viewportHeight:te})]}):v.jsx(ja,{children:e,debug:t,onContentHeightChange:I,onItemHeightChange:o,onViewportSizeChange:P,overscan:u,ref:D,scrollOffset:C,virtualize:b,...S})},br=({backgroundColor:e,borderColor:t="cyan",borderStyle:n="round",children:s,columns:i,footer:r,maxHeight:o=.8,paddingX:a=2,paddingY:c=1,rows:l,scrollbarStyle:d="block",scrollRef:u,title:p,visible:f=!0,width:h=60})=>{const g=rd(),{isLoading:y,palette:x}=gy(),b=k.useRef(null),S=u??b;if(!f)return null;const C=i??(g.columns||80),N=l??(g.rows||24),T=e??(y?"black":x?.background??"black"),D=o<=1?Math.floor(N*o):Math.min(o,N-2),F=typeof p=="string"?v.jsx(W,{marginBottom:1,children:v.jsx(O,{bold:!0,color:t,children:p})}):p??null;return v.jsx(W,{alignItems:"center",height:N,justifyContent:"center",position:"absolute",width:C,children:v.jsxs(W,{backgroundColor:T,borderBackgroundColor:T,borderColor:t,borderStyle:n,flexDirection:"column",maxHeight:D,opaque:!0,paddingY:c,width:Math.min(h,C-4),children:[F!=null&&v.jsx(W,{flexShrink:0,paddingX:a,children:F}),v.jsx(hd,{flexGrow:1,flexShrink:1,paddingX:a,ref:S,scrollbar:!0,scrollbarColor:t,scrollbarStyle:d,children:s}),r!=null&&v.jsx(W,{alignItems:"center",flexDirection:"column",flexShrink:0,marginTop:1,paddingX:a,children:r})]})})},Aa=({autoExitSeconds:e,onCancel:t,visible:n})=>{const{exit:s}=ad(),[i,r]=k.useState(e||3),o=k.useRef(null),a=k.useRef(0);k.useEffect(()=>{if(!n)return;const l=e||3;r(l),a.current=Date.now();let d=l;return o.current=setInterval(()=>{d-=1,d<=0?(o.current&&(clearInterval(o.current),o.current=null),r(0),s()):r(d)},1e3),()=>{o.current&&(clearInterval(o.current),o.current=null)}},[n,e,s]);const c=k.useCallback(()=>{o.current&&(clearInterval(o.current),o.current=null),t()},[t]);return ao((l,d)=>{Date.now()-a.current<200||(l==="q"?s():c())},{isActive:n}),v.jsx(br,{backgroundColor:"#1e1e1e",footer:v.jsxs(O,{dimColor:!0,children:["Press"," ",v.jsx(O,{bold:!0,color:"white",children:"q"})," ","to exit,"," ",v.jsx(O,{bold:!0,color:"white",children:"any key"})," ","to stay"]}),title:`Exiting in ${i}…`,visible:n,width:50,children:v.jsx(O,{dimColor:!0,children:"Stay to explore the results interactively."})})},ky=e=>{if(e.startsWith("⚠"))return"yellow";e.startsWith("── ")||e.startsWith("[dry-run]")},Sy=({focused:e,item:t,scrollRef:n})=>{const s=e?"white":"gray";return t?v.jsxs(W,{borderColor:s,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[v.jsx(W,{flexShrink:0,paddingTop:1,paddingX:2,children:v.jsx(O,{bold:!0,color:"white",children:t.entry.title})}),v.jsx(W,{flexShrink:0,paddingBottom:1,paddingX:2,children:v.jsx(O,{dimColor:!0,children:t.entry.description})}),v.jsx(hd,{flexGrow:1,flexShrink:1,paddingX:2,ref:n,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:v.jsxs(W,{flexDirection:"column",children:[v.jsx(O,{dimColor:!0,children:"── What will change ──"}),v.jsx(O,{}),t.preview.length===0&&v.jsx(O,{dimColor:!0,children:"(no preview available)"}),t.preview.map((i,r)=>{const o=ky(i);return i===""?v.jsx(O,{},`blank-${String(r)}`):v.jsx(O,{color:o,children:i},`${String(r)}-${i.slice(0,20)}`)})]})})]}):v.jsx(W,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:v.jsx(O,{dimColor:!0,children:"No migration selected"})})},xy=({checked:e,isSelected:t,item:n})=>{const s=e?"☑":"☐",i=n.preview.length;return v.jsxs(W,{flexShrink:0,height:1,children:[v.jsx(O,{children:t?">":" "}),v.jsxs(O,{color:e?"white":"gray",children:[" ",s," "]}),v.jsx(W,{flexGrow:1,children:v.jsx(O,{bold:t,inverse:t,wrap:"truncate",children:n.entry.title})}),v.jsxs(O,{dimColor:!0,children:[" ",i," ","change",i===1?"":"s"," "]})]})},$y=({checkedItems:e,focused:t,isDryRun:n,items:s,scrollOffset:i,selectedIndex:r,viewportHeight:o})=>{const a=t?"white":"gray",c=s.filter(p=>e.has(p.entry.id)).length,l=s.map((p,f)=>v.jsx(xy,{checked:e.has(p.entry.id),isSelected:f===r,item:p},p.entry.id)),d=s.length,u=d>o&&o>0;return v.jsxs(W,{borderColor:a,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[v.jsxs(W,{flexShrink:0,gap:1,paddingX:1,children:[v.jsx(O,{bold:!0,inverse:!0,children:" MIGRATE "}),v.jsxs(O,{wrap:"truncate",children:[s.length," ","applicable"]}),c>0&&v.jsxs(O,{dimColor:!0,children:[" — ",c," selected"]}),n&&v.jsx(O,{color:"yellow",children:" (dry-run)"})]}),v.jsxs(W,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[v.jsx(W,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:v.jsx(W,{flexDirection:"column",marginTop:-i,children:l})}),u&&v.jsx(W,{flexShrink:0,marginLeft:1,marginRight:1,children:v.jsx(fd,{contentHeight:d,placement:"inset",scrollOffset:i,style:"block",viewportHeight:o})})]})]})},Ey=100,Cy=40,Ry=10,Oy=({autoExitSeconds:e=0,isDryRun:t,store:n})=>{const{exit:s}=ad(),{columns:i,rows:r}=rd(),o=k.useSyncExternalStore(n.subscribe,n.getSnapshot),[a,c]=k.useState(!1),[l,d]=k.useState(!1),[u,p]=k.useState(!1),[f,h]=k.useState(0),g=k.useRef(null),y=k.useRef(null),x=k.useRef(null),b=o.items[o.selectedIndex]??null,S=Math.max(1,r-6),C=k.useCallback(M=>{h(w=>M>=w+S?Math.max(0,M-S+1):M<w?Math.max(0,M):w)},[S]);if(k.useEffect(()=>{y.current?.scrollToTop()},[b?.entry.id]),ao((M,w)=>{if(M==="c"&&w.ctrl){s();return}if(!u){if(l){M==="u"||w.return?(d(!1),n.startApply(),s(n.getCheckedItems())):w.escape||M==="q"?d(!1):w.downArrow||M==="j"?x.current?.scrollBy(1):(w.upArrow||M==="k")&&x.current?.scrollBy(-1);return}if(a){w.escape||M==="?"?c(!1):M==="q"?(c(!1),p(!0)):w.downArrow||M==="j"?g.current?.scrollBy(1):(w.upArrow||M==="k")&&g.current?.scrollBy(-1);return}if(M==="?"){c(!0);return}if(M==="q"){p(!0);return}if(w.tab){n.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}if(o.focusedPanel==="list"){if(w.downArrow||M==="j"){const A=Math.min(o.selectedIndex+1,o.items.length-1);n.setSelectedIndex(A),C(A);return}if(w.upArrow||M==="k"){const A=Math.max(o.selectedIndex-1,0);n.setSelectedIndex(A),C(A);return}if(w.pageDown){const A=Math.min(o.selectedIndex+10,o.items.length-1);n.setSelectedIndex(A),C(A);return}if(w.pageUp){const A=Math.max(o.selectedIndex-10,0);n.setSelectedIndex(A),C(A);return}if(w.home){n.setSelectedIndex(0),h(0);return}if(w.end){const A=o.items.length-1;n.setSelectedIndex(A),C(A);return}if(M===" "||w.return){b&&n.toggleCheck(b.entry.id);return}if(M==="a"){n.toggleAll();return}if(M==="u"&&!t&&o.checkedItems.size>0){d(!0);return}w.rightArrow&&n.setFocusedPanel("detail");return}if(o.focusedPanel==="detail"){if(w.escape||w.leftArrow){n.setFocusedPanel("list");return}if(w.downArrow||M==="j"){y.current?.scrollBy(1);return}if(w.upArrow||M==="k"){y.current?.scrollBy(-1);return}if(w.pageDown){y.current?.scrollBy(10);return}if(w.pageUp){y.current?.scrollBy(-10);return}if(w.home){y.current?.scrollToTop();return}w.end&&y.current?.scrollToBottom()}}},{isActive:!0}),i<Cy||r<Ry)return v.jsx(W,{alignItems:"center",height:r,justifyContent:"center",width:i,children:v.jsxs(O,{color:"yellow",children:["Terminal too small (",i,"x",r,")"]})});const N=i>=Ey,T=[v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"white",children:"q"}),v.jsx(O,{dimColor:!0,children:"QUIT"})]},"q"),v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"white",children:"?"}),v.jsx(O,{dimColor:!0,children:"HELP"})]},"?"),v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"white",children:"↑↓"}),v.jsx(O,{dimColor:!0,children:"NAV"})]},"nav"),v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"white",children:"Space"}),v.jsx(O,{dimColor:!0,children:"CHECK"})]},"sp"),v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"white",children:"a"}),v.jsx(O,{dimColor:!0,children:"ALL"})]},"a")];!t&&o.checkedItems.size>0&&T.push(v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"green",children:"u"}),v.jsx(O,{dimColor:!0,children:"APPLY"})]},"u")),T.push(v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"white",children:"Tab"}),v.jsx(O,{dimColor:!0,children:"PANEL"})]},"tab"));const D=v.jsx(W,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:v.jsx(W,{flexWrap:"wrap",gap:2,paddingX:1,children:T})}),F=v.jsxs(br,{footer:v.jsxs(O,{dimColor:!0,children:[v.jsx(O,{bold:!0,color:"white",children:"↑↓"})," scroll ",v.jsx(O,{bold:!0,color:"white",children:"?"}),"/",v.jsx(O,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:g,title:"KEYBOARD SHORTCUTS",visible:a,width:52,children:[v.jsxs(W,{flexDirection:"column",marginBottom:1,children:[v.jsx(O,{bold:!0,color:"white",children:"NAVIGATION"}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" ↑/k"}),v.jsx(O,{dimColor:!0,children:" Move up"})]}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" ↓/j"}),v.jsx(O,{dimColor:!0,children:" Move down"})]}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" Tab"}),v.jsx(O,{dimColor:!0,children:" Switch panel"})]}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" →/←"}),v.jsx(O,{dimColor:!0,children:" Focus detail/list"})]})]}),v.jsxs(W,{flexDirection:"column",marginBottom:1,children:[v.jsx(O,{bold:!0,color:"white",children:"SELECTION"}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" Space"}),v.jsx(O,{dimColor:!0,children:" Toggle migration"})]}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" a"}),v.jsx(O,{dimColor:!0,children:" Toggle all"})]})]}),v.jsxs(W,{flexDirection:"column",children:[v.jsx(O,{bold:!0,color:"white",children:"ACTIONS"}),!t&&v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" u"}),v.jsx(O,{dimColor:!0,children:" Apply selected migrations"})]}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" q"}),v.jsx(O,{dimColor:!0,children:" Quit"})]}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" ?"}),v.jsx(O,{dimColor:!0,children:" Toggle help"})]})]})]}),V=n.getCheckedItems(),Z=v.jsx(W,{alignItems:"center",flexDirection:"column",children:v.jsxs(O,{dimColor:!0,children:["Press ",v.jsx(O,{bold:!0,color:"white",children:"u"})," or ",v.jsx(O,{bold:!0,color:"white",children:"Enter"})," to confirm, ",v.jsx(O,{bold:!0,color:"white",children:"Esc"})," to cancel"]})}),re=v.jsx(br,{footer:Z,scrollRef:x,title:`Apply ${String(V.length)} migration${V.length===1?"":"s"}?`,visible:l,width:70,children:V.map(M=>v.jsxs(W,{gap:1,children:[v.jsxs(O,{children:[" ",M.entry.title]}),v.jsxs(O,{dimColor:!0,children:["(",M.preview.length," ","change",M.preview.length===1?"":"s",")"]})]},M.entry.id))}),te=v.jsx($y,{checkedItems:o.checkedItems,focused:o.focusedPanel==="list",isDryRun:t,items:o.items,scrollOffset:f,selectedIndex:o.selectedIndex,viewportHeight:S}),ne=v.jsx(Sy,{focused:o.focusedPanel==="detail",item:b,scrollRef:y});if(N){const M=Math.floor(i*.55);return v.jsxs(W,{flexDirection:"column",height:r,width:i,children:[v.jsxs(W,{flexDirection:"row",flexGrow:1,children:[v.jsx(W,{flexGrow:1,children:te}),v.jsx(W,{width:M,children:ne})]}),D,re,v.jsx(Aa,{autoExitSeconds:e||3,onCancel:()=>{p(!1)},visible:u}),F]})}const ie=Math.floor(r*.45);return v.jsxs(W,{flexDirection:"column",height:r,width:i,children:[v.jsx(W,{height:ie,children:te}),v.jsx(W,{flexGrow:1,children:ne}),D,re,v.jsx(Aa,{autoExitSeconds:e||3,onCancel:()=>{p(!1)},visible:u}),F]})},gd=[".lintstagedrc.json",".lintstagedrc"],md=[".lintstagedrc.yaml",".lintstagedrc.yml",".lintstagedrc.mjs","lint-staged.config.mjs",".lintstagedrc.cjs","lint-staged.config.cjs",".lintstagedrc.js","lint-staged.config.js",".lintstagedrc.ts","lint-staged.config.ts",".lintstagedrc.mts","lint-staged.config.mts",".lintstagedrc.cts","lint-staged.config.cts"],yd=[...gd,...md],jy=[/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)(pnpm|pnpm exec|npx|yarn|yarn run|npm exec|npm run|bunx|bun run|bun x)\s+lint-staged\b/,/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)lint-staged\b/],vd=[".nano-staged.json",".nanostagedrc"],bd=[".nano-staged.mjs",".nano-staged.cjs",".nano-staged.js","nano-staged.config.mjs","nano-staged.config.cjs","nano-staged.config.js","nano-staged.config.mts","nano-staged.config.cts","nano-staged.config.ts"],wd=[...vd,...bd],Ty=[/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)(pnpm|pnpm exec|npx|yarn|yarn run|npm exec|npm run|bunx|bun run|bun x)\s+nano-staged\b/,/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)nano-staged\b/],kd=["husky","lint-staged","nano-staged"],Iy=/\(is-ci \|\| husky \|\| exit 0\)\s*&&\s*/g,Ay=/\bhusky(?:\s+install)?\s*&&\s*/g,Py=/\s*&&\s*husky(?:\s+install)?/g,By=/\s*\|\|\s*husky(?:\s+install)?/g,Ny=[Iy,Ay,Py,By],Sd=e=>{if(e==="husky"||e==="husky install")return;let t=e;for(const n of Ny)t=t.replace(n,"");return t=t.trim(),t===e?e:t||void 0},xd=["pre-commit","pre-merge-commit","prepare-commit-msg","commit-msg","post-commit","applypatch-msg","pre-applypatch","post-applypatch","pre-rebase","post-rewrite","post-checkout","post-merge","pre-push","pre-auto-gc"],co=".vis/hooks",Nn=".vis-hooks",o4=[".pre-commit-config.yaml",".pre-commit-config.yml","prek.toml"],a4={commit:"pre-commit","merge-commit":"pre-merge-commit",push:"pre-push"},c4=new Set(["commit-msg","post-checkout","post-commit","post-merge","post-rewrite","pre-commit","pre-merge-commit","pre-push","pre-rebase","prepare-commit-msg"]),l4=new Set(["commit-msg","post-checkout","post-merge","post-rewrite","pre-rebase","prepare-commit-msg"]),d4=new Set(["fail","script","system"]),Dy="config.json",Ai=1,Ly=new Set(["alwaysRun","args","builtin","entry","exclude","excludeTypes","fail","files","id","name","passFilenames","types","typesOr","verbose"]),My=new Set(["failFast","skipInCI","stages","version"]),_y=["args","exclude","excludeTypes","files","passFilenames","types","typesOr"],$d=(e,t)=>m(e,t,Dy),wr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ws=e=>{if(!Array.isArray(e))return;const t=[];for(const n of e){if(typeof n!="string")return;t.push(n)}return t},Hn=e=>typeof e=="boolean"?e:void 0,zt=e=>typeof e=="string"&&e.length>0?e:void 0,Fy=(e,t,n)=>{if(!wr(e))throw new TypeError("hook entry must be an object");if(typeof e.id!="string"||e.id.length===0)throw new TypeError("hook entry is missing `id`");const s={id:e.id},i=Hn(e.alwaysRun);i!==void 0&&(s.alwaysRun=i);const r=ws(e.args);r&&(s.args=r);const o=zt(e.builtin);o&&(s.builtin=o);const a=zt(e.entry);a&&(s.entry=a);const c=zt(e.exclude);c&&(s.exclude=c);const l=ws(e.excludeTypes);l&&(s.excludeTypes=l);const d=zt(e.fail);d&&(s.fail=d);const u=zt(e.files);u&&(s.files=u);const p=zt(e.name);p&&(s.name=p);const f=Hn(e.passFilenames);f!==void 0&&(s.passFilenames=f);const h=ws(e.types);h&&(s.types=h);const g=ws(e.typesOr);g&&(s.typesOr=g);const y=Hn(e.verbose);if(y!==void 0&&(s.verbose=y),[s.builtin,s.entry,s.fail].filter(b=>b!==void 0).length!==1)throw new TypeError(`hook "${s.id}" must set exactly one of \`builtin\`, \`entry\`, \`fail\``);if(s.fail!==void 0){const b=_y.filter(S=>s[S]!==void 0);if(b.length>0)throw new TypeError(`hook "${s.id}" is a \`fail\` entry — remove ${b.join(", ")} (filters do not apply)`)}for(const b of Object.keys(e))Ly.has(b)||t.push({hookId:s.id,message:`unknown field "${b}" ignored`,stage:n});return s},Vy=(e,t)=>{if(!wr(e))throw new TypeError("hook config must be an object");if(e.version!==Ai)throw new TypeError(`unsupported hook config version: expected ${Ai}, got ${String(e.version)}`);if(!wr(e.stages))throw new TypeError("hook config is missing `stages` map");const n={};for(const[o,a]of Object.entries(e.stages)){if(!Array.isArray(a))throw new TypeError(`hook config: stage "${o}" must be an array`);n[o]=a.map(c=>Fy(c,t,o))}const s={stages:n,version:Ai},i=Hn(e.failFast);i!==void 0&&(s.failFast=i);const r=Hn(e.skipInCI);r!==void 0&&(s.skipInCI=r);for(const o of Object.keys(e))My.has(o)||t.push({message:`unknown top-level field "${o}" ignored`});return s},Wy=(e,t=co,n)=>{const s=$d(e,t);if(!$(s))return;const i=J(s);let r;try{r=JSON.parse(i)}catch(o){const a=o instanceof Error?o.message:String(o);throw new TypeError(`failed to parse ${s}: ${a}`,{cause:o})}return Vy(r,[])},u4=(e,t,n)=>{const s=$d(e,t);ce(s,`${JSON.stringify(n,void 0,4)}
24
- `,"utf8")},Hy=/\/$/,Pa="worktree ",Uy=e=>{if(e===Nn||!dr(Nn)||dr(e))return;const t=vl(e);return t&&t!=="."&&gt(t),ml(Nn,e),`migrated ${Nn} → ${e}`},Gy=e=>{let t='"$0"';for(let n=0;n<e;n+=1)t=`"$(dirname ${t})"`;return t},zy=(e,t={})=>{const s=e.split("/").filter(o=>o!==""&&o!==".").length+2,i=Gy(s);return`#!/usr/bin/env sh
19
+ `)),this.kittyProtocolEnabled=!1,vr.delete(this.options.stdout);const{exitResult:a}=this,c=()=>{Ii(t)?this.rejectExitPromise(t):this.resolveExitPromise(a)};t!==void 0&&!Ii(t)?c():s&&i?this.options.stdout.write("",c):setImmediate(c)},o=Ee;this.options.concurrent?(Ee.updateContainerSync(null,this.container,null,Cn),Ee.flushSyncWork(),o.flushPassiveEffects?.(),r()):(Ee.updateContainerSync(null,this.container,null,Cn),Ee.flushSyncWork(),r())};async waitUntilExit(){return this.beforeExitHandler||(this.beforeExitHandler=()=>{this.unmount()},Te.on("beforeExit",this.beforeExitHandler)),this.exitPromise}async waitUntilRenderFlush(){if(this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(await Ra(),this.isUnmounted||this.isUnmounting){await this.awaitExit();return}if(this.isConcurrent&&this.hasPendingConcurrentWork()&&(await Promise.race([this.awaitNextRender(),this.awaitExit()]),this.isUnmounted||this.isUnmounting)){this.nextRenderCommit=void 0,await this.awaitExit();return}Ee.flushSyncWork();const t=this.options.stdout,{canWriteToStdout:n,hasWritableState:s}=Oa(t);if(ks(this.throttledOnRender,n),ks(this.throttledLog,n),n&&s){await new Promise(i=>{this.options.stdout.write("",()=>{i()})});return}await Ra()}clear(){!this.interactive||this.options.debug||(this.log.clear(),this.log.sync(this.lastOutputToRender||`${this.lastOutput}
20
+ `))}patchConsole(){this.options.debug||(this.restoreConsole=im((t,n)=>{t==="stdout"&&this.writeToStdout(n),t==="stderr"&&(n.startsWith("The above error occurred")||this.writeToStderr(n))}))}setAlternateScreen(t){this.alternateScreen=this.resolveAlternateScreenOption(t,this.interactive),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,da),this.writeBestEffort(this.options.stdout,Yn))}resolveInteractiveOption(t){return t??(!Xl&&this.options.stdout.isTTY)}resolveAlternateScreenOption(t,n){return!!t&&n&&this.options.stdout.isTTY}shouldSync(){return Om(this.options.stdout,this.interactive)}writeBestEffort(t,n){try{t.write(n)}catch{}}async awaitExit(){try{await this.exitPromise}catch{}}hasPendingConcurrentWork(){const t=this.container;return(t.pendingLanes??0)!==0&&t.callbackNode!==void 0&&t.callbackNode!==null}async awaitNextRender(){if(!this.nextRenderCommit){let t;const n=new Promise(s=>{t=s});this.nextRenderCommit={promise:n,resolve:t}}return this.nextRenderCommit.promise}renderInteractiveFrame(t,n,s,i=""){const r=s+i,o=r!=="",a=this.options.stdout.isTTY,c=a?tt(this.options.stdout).rows:24,l=a&&n>=c,d=l?t:`${t}
21
+ `,u=Te.platform==="win32",p=a&&u&&(l||this.lastOutputHeight>=c);if(Fm({isTty:a,isUnmounting:this.isUnmounting,isWindows:u,nextOutputHeight:n,previousOutputHeight:this.lastOutputHeight,viewportRows:c})){if(this.options.incrementalRendering&&!p){o&&(this.log.clear(),this.options.stdout.write(r)),(t!==this.lastOutput||this.log.isCursorDirty()||o)&&this.throttledLog(d),this.lastOutput=t,this.lastOutputToRender=d,this.lastOutputHeight=n;return}const f=this.shouldSync();f&&this.options.stdout.write(xt),this.options.stdout.write(dg+this.fullStaticOutput+i+d),this.lastOutput=t,this.lastOutputToRender=d,this.lastOutputHeight=n,this.log.sync(d),f&&this.options.stdout.write(Qe);return}if(o){const f=this.shouldSync();f&&this.options.stdout.write(xt),this.log.clear(),this.options.stdout.write(r),this.log(d),f&&this.options.stdout.write(Qe)}else(t!==this.lastOutput||this.log.isCursorDirty())&&this.throttledLog(d);this.lastOutput=t,this.lastOutputToRender=d,this.lastOutputHeight=n}initImmediateKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="enabled")return;const n=t.flags??["disambiguateEscapeCodes"];this.options.stdin.isTTY&&this.options.stdout.isTTY&&this.enableKittyProtocol(n)}initDeferredKittyKeyboard(){if(!this.options.kittyKeyboard)return;const t=this.options.kittyKeyboard;if((t.mode??"auto")!=="auto")return;const n=t.flags??["disambiguateEscapeCodes"];!this.interactive||!this.options.stdin.isTTY||!this.options.stdout.isTTY||this.confirmKittySupport(n)}confirmKittySupport(t){Jl(this.options.stdin,async()=>this.runKittySupportQuery(t))}async runKittySupportQuery(t){const{stdin:n,stdout:s}=this.options;let i=[],r,o;const a=()=>{this.cancelKittyDetection=void 0,r&&clearTimeout(r),n.removeListener("data",c);const l=_m(i);i=[],l.length>0&&n.unshift(ba.from(l))},c=l=>{const d=typeof l=="string"?ba.from(l):l;for(const u of d)i.push(u);Mm(i)&&(a(),this.isUnmounted||this.enableKittyProtocol(t),o?.())};return n.on("data",c),s.write("\x1B[?u"),new Promise(l=>{o=l,r=setTimeout(()=>{a(),l()},200),this.cancelKittyDetection=()=>{a(),l()}})}registerInputControl=(t,n)=>{this.pauseInput=t,this.resumeInput=n};suspendTerminal=(async t=>{if(this.beginSuspend(),t){try{await t()}finally{await this.endSuspend()}return}const n=async()=>{await this.endSuspend()};return{resume:n,[Symbol.asyncDispose]:n}});beginSuspend(){if(this.isSuspended)throw new Error("The terminal is already suspended. Resume the current suspension before suspending again.");if(this.isSuspended=!0,!(!this.interactive||this.isUnmounted||this.isUnmounting))try{this.log.clear(),this.log.done(),this.kittyProtocolEnabled&&this.writeBestEffort(this.options.stdout,"\x1B[<u"),this.alternateScreen&&(this.writeBestEffort(this.options.stdout,ua),this.writeBestEffort(this.options.stdout,Xn)),this.pauseInput?.()}catch(t){this.isSuspended=!1;try{this.resumeInput?.()}catch{}throw t}}async endSuspend(){if(this.isSuspended&&(this.isSuspended=!1,this.resumeInput?.(),!(!this.interactive||this.isUnmounted||this.isUnmounting))){this.alternateScreen&&this.writeBestEffort(this.options.stdout,da),this.kittyProtocolEnabled&&this.kittyFlags&&this.writeBestEffort(this.options.stdout,`\x1B[>${la(this.kittyFlags)}u`),this.lastOutput="",this.lastOutputToRender="",this.lastOutputHeight=0,this.log.reset();try{this.calculateLayout(),this.onRender(),await this.waitUntilRenderFlush()}catch{}}}enableKittyProtocol(t){this.kittyFlags=t,this.options.stdout.write(`\x1B[>${la(t)}u`),this.kittyProtocolEnabled=!0}}const Wm=(e,t)=>{const n={alternateScreen:!1,concurrent:!1,debug:!1,exitOnCtrlC:!0,incrementalRendering:!1,maxFps:30,patchConsole:!0,stderr:Te.stderr,stdin:Te.stdin,stdout:Te.stdout,...Hm(t)},s=Um(n.stdout,()=>new Vm(n));return s.render(e),{cleanup(){s.unmount()},clear(){s.clear()},rerender(i){s.render(i)},rootNode:s.rootNode,unmount(){s.unmount()},waitUntilExit(){return s.waitUntilExit()},waitUntilRenderFlush(){return s.waitUntilRenderFlush()}}},Hm=(e={})=>e instanceof tm?{stdin:Te.stdin,stdout:e}:e,Um=(e,t)=>{const n=vr.get(e);if(n===void 0){const s=t();return vr.set(e,s),s}return Te.stderr.write(`Warning: render() was called again for the same stdout before the previous Ink instance was unmounted. Reusing stdout across multiple render() calls is unsupported. Call unmount() first.
22
+ `),n},en="\x07",ao="\x1B",tn=`${ao}]`,ja=`${ao}\\`,di=16,Gm=3+di,zm=8192,Jm=e=>{const t=e.lastIndexOf(";"),n=yg(t===-1?e:e.slice(t+1));if(n===void 0)return null;const s=i=>i.toString(16).padStart(2,"0");return`#${s(n.r)}${s(n.g)}${s(n.b)}`},qm=()=>{const e=process.env.TERM_PROGRAM??"";return new Set(["Alacritty","contour","foot","Ghostty","iTerm2","iTerm.app","kitty","rio","WezTerm"]).has(e)?!0:(process.env.TERM??"").startsWith("xterm")||!!process.env.WT_SESSION},Km=(e,t)=>{const n=Jm(e);if(n===null)return!1;if(e.startsWith("10;"))return t.foreground=n,!0;if(e.startsWith("11;"))return t.background=n,!0;if(e.startsWith("12;"))return t.cursor=n,!0;if(e.startsWith("4;")){const s=e.indexOf(";",2),i=Number(e.slice(2,s===-1?e.length:s));if(Number.isSafeInteger(i)&&i>=0&&i<di)return t.colors[i]=n,!0}return!1},Ym=()=>{const e=[`${tn}10;?${en}`,`${tn}11;?${en}`,`${tn}12;?${en}`];for(let t=0;t<di;t+=1)e.push(`${tn}4;${String(t)};?${en}`);return e.join("")},zs=new WeakMap,Xm=e=>{const t=[];let n="",s=e;for(;;){const i=s.indexOf(tn);if(i===-1){const d=s.endsWith(ao)?1:0;return n+=s.slice(0,s.length-d),{answers:t,foreign:n,rest:s.slice(s.length-d)}}n+=s.slice(0,i),s=s.slice(i);const r=s.indexOf(en),o=s.indexOf(ja),a=r!==-1,c=o!==-1;if(!a&&!c)return{answers:t,foreign:n,rest:s};const l=a&&(!c||r<o)?r:o;t.push(s.slice(tn.length,l)),s=s.slice(l+(l===r?en.length:ja.length))}},Zm=async(e,t,n)=>new Promise(s=>{const i={colors:Array.from({length:di})};let r="",o="",a=0,c=!1;const l=e.listenerCount("data")===0;let d;const u=f=>{const h=Xm(o+f.toString());r+=h.foreign,o=h.rest;for(const g of h.answers)Km(g,i)&&(a+=1);(a>=Gm||o.length+r.length>zm)&&p()};function p(){if(c)return;c=!0,d&&clearTimeout(d);const f=e.listenerCount("data")===1;e.removeListener("data",u);const h=r+o;if(l&&f&&h.length>0)try{e.pause(),e.unshift(h)}catch{}const g={};i.foreground&&(g.foreground=i.foreground),i.background&&(g.background=i.background),i.cursor&&(g.cursor=i.cursor),i.colors.some(Boolean)&&(g.colors=i.colors.map(y=>y??"")),s(g)}e.on("data",u),d=setTimeout(p,n),t.write(Ym())}),Qm=async(e,t)=>{const n=Promise.withResolvers(),s=()=>{n.resolve({})};t.addEventListener("abort",s,{once:!0});try{return await Promise.race([e,n.promise])}finally{t.removeEventListener("abort",s)}},ey=async(e,t,n)=>{let s;try{s=await Jl(e,async()=>Zm(e,t,n))}catch(i){throw zs.delete(t),i}return Object.keys(s).length===0&&zs.delete(t),s},ty=async(e,t,n=500,s)=>{if(s?.aborted)return{};let i=zs.get(t);return i||(i=ey(e,t,n),zs.set(t,i)),s?Qm(i,s):i},ad=()=>k.useContext(ro),cd=()=>{const{stdout:e}=ad(),[t,n]=k.useState(()=>tt(e));return k.useEffect(()=>{const s=()=>{n(tt(e))};return e.on("resize",s),()=>{e.off("resize",s)}},[e]),t},ny=()=>k.useContext(oi),ld=()=>k.useContext(oi);class sy{#e;#t=new Set;constructor(t){this.#e={applyProgress:null,checkedItems:new Set(t.map(n=>n.entry.id)),error:null,focusedPanel:"list",items:t,phase:"browsing",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#t.add(t),()=>{this.#t.delete(t)});getCheckedItems(){return this.#e.items.filter(t=>this.#e.checkedItems.has(t.entry.id))}getSelectedItem(){return this.#e.items[this.#e.selectedIndex]??null}setSelectedIndex(t){const n=Math.max(0,Math.min(t,this.#e.items.length-1));n!==this.#e.selectedIndex&&this.#n({...this.#e,selectedIndex:n})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#n({...this.#e,focusedPanel:t})}toggleCheck(t){const n=new Set(this.#e.checkedItems);n.has(t)?n.delete(t):n.add(t),this.#n({...this.#e,checkedItems:n})}checkAll(){this.#n({...this.#e,checkedItems:new Set(this.#e.items.map(t=>t.entry.id))})}uncheckAll(){this.#n({...this.#e,checkedItems:new Set})}toggleAll(){this.#e.checkedItems.size===this.#e.items.length?this.uncheckAll():this.checkAll()}startApply(){const t=this.getCheckedItems().length;this.#n({...this.#e,applyProgress:{current:0,total:t},phase:"applying"})}updateApplyProgress(t){this.#e.applyProgress&&this.#n({...this.#e,applyProgress:{...this.#e.applyProgress,current:t}})}markDone(){this.#n({...this.#e,phase:"done"})}setError(t){this.#n({...this.#e,error:t,phase:"error"})}#n(t){this.#e=t;for(const n of this.#t)try{n()}catch{}}}const dd=()=>k.useContext(so);let iy;const ry=e=>(iy??=Ne(import.meta.url))(e),Rn=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,oy=e=>{if(typeof Rn<"u"&&Rn.versions&&Rn.versions.node){const[t,n]=Rn.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Rn.getBuiltinModule(e)}return ry(e)},{Buffer:ay}=oy("node:buffer"),cy=/^\u001B([a-z0-9])$/i,ly=/^\u001B+([ON[]|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,ud={"[1~":"home","[2$":"insert","[2^":"insert","[2~":"insert","[3$":"delete","[3^":"delete","[3~":"delete","[4~":"end","[5$":"pageup","[5^":"pageup","[5~":"pageup","[6$":"pagedown","[6^":"pagedown","[6~":"pagedown","[7$":"home","[7^":"home","[7~":"home","[8$":"end","[8^":"end","[8~":"end","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[[5~":"pageup","[[6~":"pagedown","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[A":"up","[a":"up","[B":"down","[b":"down","[C":"right","[c":"right","[D":"left","[d":"left","[E":"clear","[e":"clear","[F":"end","[H":"home","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[Z":"tab",OA:"up",Oa:"up",OB:"down",Ob:"down",OC:"right",Oc:"right",OD:"left",Od:"left",OE:"clear",Oe:"clear",OF:"end",OH:"home",OP:"f1",OQ:"f2",OR:"f3",OS:"f4"},dy=[...Object.values(ud),"backspace"],uy=e=>["[2$","[3$","[5$","[6$","[7$","[8$","[a","[b","[c","[d","[e","[Z"].includes(e),py=e=>["[2^","[3^","[5^","[6^","[7^","[8^","Oa","Ob","Oc","Od","Oe"].includes(e),pd=/^\u001B\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,fy=/^\u001B\[(\d+);(\d+):(\d+)([A-Z~])$/i,hy={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},gy={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},Ta={8:"backspace",9:"tab",27:"escape",127:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},fd=e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),Ai=e=>fd(e)?String.fromCodePoint(e):"?";function hd(e){return e===3?"release":e===2?"repeat":"press"}function gd(e){return{capsLock:!!(e&Xe.capsLock),ctrl:!!(e&Xe.ctrl),hyper:!!(e&Xe.hyper),meta:!!(e&Xe.meta),numLock:!!(e&Xe.numLock),option:!!(e&Xe.alt),shift:!!(e&Xe.shift),super:!!(e&Xe.super)}}const my=e=>{const t=pd.exec(e);if(!t)return null;const n=Number.parseInt(t[1],10),s=t[2]?Math.max(0,Number.parseInt(t[2],10)-1):0,i=t[3]?Number.parseInt(t[3],10):1,r=t[4];if(!fd(n))return null;let o;r&&(o=r.split(":").map(l=>Ai(Number.parseInt(l,10))).join(""));let a,c;return n===32?(a="space",c=!0):n===13?(a="return",c=!0):Ta[n]?(a=Ta[n],c=!1):n>=1&&n<=26?(a=String.fromCodePoint(n+96),c=!1):(a=Ai(n).toLowerCase(),c=!0),c&&!o&&(o=Ai(n)),{name:a,...gd(s),eventType:hd(i),isKittyProtocol:!0,isPrintable:c,raw:e,sequence:e,text:o}},yy=e=>{const t=fy.exec(e);if(!t)return null;const n=Number.parseInt(t[1],10),s=Math.max(0,Number.parseInt(t[2],10)-1),i=Number.parseInt(t[3],10),r=t[4],o=r==="~"?gy[n]:hy[r];return o?{name:o,...gd(s),eventType:hd(i),isKittyProtocol:!0,isPrintable:!1,raw:e,sequence:e}:null},vy=(e="")=>{let t;ay.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B${String(e)}`):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");const n=my(e);if(n)return n;const s=yy(e);if(s)return s;if(pd.test(e))return{ctrl:!1,isKittyProtocol:!0,isPrintable:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};const i={ctrl:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};switch(i.sequence=i.sequence||e||i.name,e){case"\r":case"\x1B\r":{i.raw=void 0,i.name="return",i.option=e.length===2;break}case`
23
+ `:{i.name="enter";break}case" ":{i.name="tab";break}case" ":case"\x1B ":{i.name="space",i.meta=e.length===2;break}case"\b":case"\x1B\b":{i.name="backspace",i.meta=e.charAt(0)==="\x1B";break}case"\x1B":case"\x1B\x1B":{i.name="escape",i.meta=e.length===2;break}case"\x1B":case"":{i.name="backspace",i.meta=e.charAt(0)==="\x1B";break}default:if(e.length===1&&e<="")i.name=String.fromCharCode(e.charCodeAt(0)+97-1),i.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")i.name="number";else if(e.length===1&&e>="a"&&e<="z")i.name=e;else if(e.length===1&&e>="A"&&e<="Z")i.name=e.toLowerCase(),i.shift=!0;else if(t=cy.exec(e))i.meta=!0,i.shift=/^[A-Z]$/.test(t[1]);else if(t=ly.exec(e)){const r=[...e];r[0]==="\x1B"&&r[1]==="\x1B"&&(i.option=!0);const o=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;i.ctrl=!!(a&4),i.meta=!!(a&10),i.shift=!!(a&1),i.code=o,i.name=ud[o]??"",i.shift=uy(o)||i.shift,i.ctrl=py(o)||i.ctrl}}return i},co=(e,t={})=>{const{internal_eventEmitter:n,internal_exitOnCtrlC:s,setRawMode:i,stdin:r}=ld(),o=t.imeEnabled??!0,a=t.imeTimeout??50,c=k.useRef(void 0),l=k.useEffectEvent(e);k.useEffect(()=>{if(o)return c.current=new Yh({onFlush:d=>{const u={backspace:!1,capsLock:!1,ctrl:!1,delete:!1,downArrow:!1,end:!1,escape:!1,home:!1,hyper:!1,leftArrow:!1,meta:!1,numLock:!1,pageDown:!1,pageUp:!1,return:!1,rightArrow:!1,shift:!1,super:!1,tab:!1,upArrow:!1};Ee.discreteUpdates(()=>{l(d,u)})},timeout:a}),()=>{c.current?.destroy(),c.current=void 0}},[o,a]),k.useEffect(()=>{if(t.isActive!==!1)return i(!0),()=>{i(!1)}},[t.isActive,i]),k.useLayoutEffect(()=>{if(t.isActive===!1)return;const d=u=>{if(o&&Kh(u)){c.current?.add(u);return}c.current?.flush();const p=vy(u),f={backspace:p.name==="backspace",capsLock:p.capsLock??!1,ctrl:p.ctrl,delete:p.name==="delete",downArrow:p.name==="down",end:p.name==="end",escape:p.name==="escape",eventType:p.eventType,home:p.name==="home",hyper:p.hyper??!1,leftArrow:p.name==="left",meta:p.meta||p.option,numLock:p.numLock??!1,pageDown:p.name==="pagedown",pageUp:p.name==="pageup",return:p.name==="return",rightArrow:p.name==="right",shift:p.shift,super:p.super??!1,tab:p.name==="tab",upArrow:p.name==="up"};let h;p.isKittyProtocol?p.isPrintable?h=p.text??p.name:p.ctrl&&p.name.length===1?h=p.name:h="":p.ctrl?h=p.name:h=p.sequence,!p.isKittyProtocol&&dy.includes(p.name)&&(h=""),h.startsWith("\x1B")&&(h=h.slice(1)),h.length===1&&typeof h[0]=="string"&&/[A-Z]/.test(h[0])&&(f.shift=!0),!(h==="c"&&f.ctrl&&s)&&(!p.name&&h===""||Ee.discreteUpdates(()=>{l(h,f)}))};return n.on("input",d),()=>{n.removeListener("input",d)}},[t.isActive,r,s,o])},by=()=>{const{stdin:e}=ld(),{stdout:t}=ad(),[n,s]=k.useState(null),[i,r]=k.useState(!0),o=k.useMemo(()=>qm(),[]);return k.useEffect(()=>{if(!o||!e||!t){r(!1);return}const a=new AbortController;return(async()=>{try{const c=await ty(e,t,200,a.signal);a.signal.aborted||s(c)}catch{}finally{a.signal.aborted||r(!1)}})(),()=>{a.abort()}},[o,e,t]),{isLoading:i,isSupported:o,palette:n}},wy=({autoFocus:e=!1,id:t,isActive:n=!0}={})=>{const{isRawModeSupported:s,setRawMode:i}=ny(),{activate:r,activeId:o,add:a,deactivate:c,focus:l,remove:d}=k.useContext(io),u=k.useMemo(()=>t??Math.random().toString().slice(2,7),[t]);return k.useEffect(()=>(a(u,{autoFocus:e}),()=>{d(u)}),[u,e]),k.useEffect(()=>{n?r(u):c(u)},[n,u]),k.useEffect(()=>{if(!(!s||!n))return i(!0),()=>{i(!1)}},[n]),{focus:l,isFocused:!!u&&o===u}},ky=e=>{const{getViewportHeight:t,isActive:n=!0,scrollBy:s,scrollToBottom:i,scrollToTop:r,vimBindings:o=!1}=e,{isFocused:a}=wy({isActive:n});return co((c,l)=>{if(l.upArrow){s(-1);return}if(l.downArrow){s(1);return}if(l.pageUp){s(-t());return}if(l.pageDown){s(t());return}if(l.home){r();return}if(l.end){i();return}if(l.ctrl&&c==="u"){s(-Math.floor(t()/2));return}if(l.ctrl&&c==="d"){s(Math.floor(t()/2));return}if(o){if(c==="k"){s(-1);return}if(c==="j"){s(1);return}if(c==="G"&&l.shift){i();return}if(c==="g"&&!l.shift){r();return}if(c==="u"&&!l.ctrl){s(-Math.floor(t()/2));return}c==="d"&&!l.ctrl&&s(Math.floor(t()/2))}},{isActive:n}),{isFocused:a}},br=e=>{const[t,n]=k.useState(e),s=k.useRef(e),i=k.useCallback(o=>{const a=typeof o=="function"?o(s.current):o;s.current=a,n(a)},[]),r=k.useCallback(()=>s.current,[]);return[t,i,r]},Sy=({children:e,index:t,measureKey:n,onMeasure:s,width:i})=>{const r=k.useRef(null);return k.useLayoutEffect(()=>{if(r.current){const{height:o}=yl(r.current);s(t,o)}},[t,s,i,n,e]),v.jsx(W,{flexDirection:"column",flexShrink:0,ref:r,width:"100%",children:e})},Js=e=>{if(e==null)return[];if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n+=1){const s=e[n];k.isValidElement(s)&&s.type===k.Fragment?t.push(...Js(s.props.children)):t.push(s)}return t}return k.isValidElement(e)&&e.type===k.Fragment?Js(e.props.children):[e]},Ia=({children:e,debug:t=!1,onContentHeightChange:n,onItemHeightChange:s,onViewportSizeChange:i,overscan:r=3,ref:o,scrollOffset:a,virtualize:c=!1,...l})=>{const d=k.useRef(!1),[u,p,f]=br({height:0,width:0}),[h,g,y]=br(0),[x,b]=k.useState({}),S=k.useRef(null),C=k.useRef(0);k.useLayoutEffect(()=>{h!==C.current&&(n?.(h,C.current),C.current=h)},[h,n]);const N=k.useRef({}),T=k.useRef([]),D=k.useRef([]),F=k.useRef(0),V=k.useCallback((I,B)=>{const j=T.current[I]??I;if(N.current[j]!==B){const _=N.current[j]??0;N.current={...N.current,[j]:B};let H=0;for(let Y=0;Y<T.current.length;Y+=1){const P=T.current[Y];P!=null&&(H+=N.current[P]??0)}const z=y();H!==z&&g(H),s?.(I,B,_),F.current=Math.min(F.current,I+1)}},[s,y,g]),Z=k.useCallback(()=>{if(S.current){const{height:I,width:B}=yl(S.current),j=f();(B!==j.width||I!==j.height)&&(i?.({height:I,width:B},j),p({height:I,width:B}))}},[S,i,f,p]);k.useLayoutEffect(()=>{Z()});const re=k.useRef(null);if(re.current!==e){re.current=e;const I=[],B={};Js(e).forEach((H,z)=>{if(!H)return;const Y=(k.isValidElement(H)?H.key:null)??z;I[z]=Y;const P=N.current[Y]??0;B[Y]=P}),N.current=B,T.current=I,D.current=Array.from({length:I.length}).fill(0),F.current=0;let j=0;I.forEach(H=>{j+=B[H]??0});const _=y();j!==_&&g(j)}k.useImperativeHandle(o,()=>({getBottomOffset:()=>Math.max(0,y()-f().height),getContentHeight:y,getItemHeight:I=>{const B=T.current[I]??I;return N.current[B]??0},getItemPosition:I=>{if(I<0||I>=T.current.length)return null;if(I>=F.current){let _=0,H=0;if(F.current>0){H=F.current;const z=H-1,Y=T.current[z]??z,P=N.current[Y]??0;_=(D.current[z]??0)+P}for(let z=H;z<=I;z+=1){D.current[z]=_;const Y=T.current[z]??z,P=N.current[Y]??0;_+=P}F.current=I+1}const B=D.current[I]??0,j=T.current[I]??I;return{height:N.current[j]??0,top:B}},getViewportHeight:()=>f().height,remeasure:Z,remeasureItem:I=>{b(B=>({...B,[I]:(B[I]??0)+1}))}}),[Z,y,f,b]);const te=Js(e);!d.current&&h>0&&(d.current=!0);let ne=0,ie=te.length-1,M=0,w=0;const A=te.length>0&&te.every((I,B)=>{const j=T.current[B]??B;return(N.current[j]??0)>0}),U=c&&d.current&&A;if(U){const I=T.current.length;if(F.current<I){let j=0,_=0;if(F.current>0){_=F.current;const H=_-1,z=T.current[H]??H,Y=N.current[z]??0;j=(D.current[H]??0)+Y}for(let H=_;H<I;H+=1){D.current[H]=j;const z=T.current[H]??H;j+=N.current[z]??0}F.current=I}const B=a+u.height;ne=te.length,ie=-1;for(let j=0;j<I;j+=1){const _=D.current[j]??0,H=T.current[j]??j,z=N.current[H]??0;_+z>a&&_<B&&(j<ne&&(ne=j),ie=j)}if(ne>ie&&(ne=0,ie=-1),ne=Math.max(0,ne-r),ie=Math.min(te.length-1,Math.max(-1,ie)+r),M=D.current[ne]??0,ie<te.length-1){const j=T.current[ie]??ie,_=(D.current[ie]??0)+(N.current[j]??0);w=h-_}}return v.jsx(W,{...l,children:v.jsx(W,{ref:S,width:"100%",children:v.jsx(W,{overflow:t?void 0:"hidden",width:"100%",children:v.jsxs(W,{flexDirection:"column",marginTop:-a,width:"100%",children:[U&&M>0&&v.jsx(W,{height:M}),te.map((I,B)=>!I||U&&(B<ne||B>ie)?null:v.jsx(Sy,{index:B,measureKey:x[B],onMeasure:V,width:u.width,children:I},k.isValidElement(I)?I.key??B:B)),U&&w>0&&v.jsx(W,{height:w})]})})})})},Aa={arrow:{lowerThumb:"╽",thumb:"┃",track:"|",upperThumb:"╿"},block:{thumb:"█",track:"░"},bold:{lowerThumb:"╿",thumb:"│",track:"┃",upperThumb:"╽"},classic:{thumb:"┃",track:"|"},dots:{thumb:"●",track:"·"},double:{thumb:"┃",track:"║"},doubleSingle:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},line:{thumb:"│",track:" "},round:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},single:{lowerThumb:"╽",thumb:"┃",track:"│",upperThumb:"╿"},singleDouble:{thumb:"┃",track:"║"},thick:{thumb:"┃",track:"╏"}},Ba={arrow:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},bold:{bottomLeft:"┗",bottomRight:"┛",topLeft:"┏",topRight:"┓"},classic:{bottomLeft:"+",bottomRight:"+",topLeft:"+",topRight:"+"},double:{bottomLeft:"╚",bottomRight:"╝",topLeft:"╔",topRight:"╗"},doubleSingle:{bottomLeft:"╘",bottomRight:"╛",topLeft:"╒",topRight:"╕"},round:{bottomLeft:"╰",bottomRight:"╯",topLeft:"╭",topRight:"╮"},single:{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},singleDouble:{bottomLeft:"╙",bottomRight:"╜",topLeft:"╓",topRight:"╖"}},xy=e=>Aa[typeof e=="string"?e:"single"]??Aa.single??{thumb:"┃",track:"│"},$y=e=>Ba[typeof e=="string"?e:"single"]??Ba.single??{bottomLeft:"└",bottomRight:"┘",topLeft:"┌",topRight:"┐"},md=({autoHide:e=!1,color:t,contentHeight:n,dimColor:s,placement:i="right",scrollOffset:r,style:o,thumbChar:a,trackChar:c,viewportHeight:l})=>{const d=k.useMemo(()=>{const h=Math.max(n,l);if(e&&h<=l)return null;const g=xy(o),y=a??g.thumb,x=c??g.track,b=l*2,S=Math.min(l/h,1),C=Math.max(2,Math.round(b*S)),N=h-l,T=N>0?Math.min(Math.max(r/N,0),1):0,D=b-C,F=Math.round(T*D),V=F+C,Z=[];for(let re=0;re<l;re+=1){const te=re*2,ne=re*2+1,ie=te>=F&&te<V,M=ne>=F&&ne<V;ie&&M?Z.push(y):ie&&!M?Z.push(g.lowerThumb??y):!ie&&M?Z.push(g.upperThumb??y):Z.push(x)}return Z},[n,l,r,o,a,c,e]);if(d===null)return null;if(i==="inset")return v.jsx(W,{flexDirection:"column",flexShrink:0,width:1,children:d.map((h,g)=>v.jsx(O,{color:t,dimColor:s,children:h},g))});const u=$y(o),p=i==="left"?u.topLeft:u.topRight,f=i==="left"?u.bottomLeft:u.bottomRight;return v.jsxs(W,{flexDirection:"column",flexShrink:0,width:1,children:[v.jsx(O,{color:t,dimColor:s,children:p}),d.map((h,g)=>v.jsx(O,{color:t,dimColor:s,children:h},g)),v.jsx(O,{color:t,dimColor:s,children:f})]})},yd=({children:e,debug:t=!1,followOutput:n=!1,followThreshold:s=3,keyboard:i=!1,onContentHeightChange:r,onItemHeightChange:o,onReachEnd:a,onReachStart:c,onScroll:l,onViewportSizeChange:d,overscan:u,reachThreshold:p=5,ref:f,scrollbar:h=!1,scrollbarColor:g,scrollbarStyle:y="line",vimBindings:x=!1,virtualize:b,...S})=>{const[C,N,T]=br(0),D=k.useRef(null),F=k.useRef(0),V=k.useRef(0),[Z,re]=k.useState(0),[te,ne]=k.useState(0),ie=k.useRef(!1),M=k.useRef(!1),w=k.useCallback(()=>Math.max(0,F.current-V.current),[]),A=k.useCallback(P=>{const K=w();a&&P>=K-p&&!ie.current?(ie.current=!0,a()):P<K-p&&(ie.current=!1),c&&P<=p&&!M.current?(M.current=!0,c()):P>p&&(M.current=!1)},[a,c,p,w]),U=k.useCallback(P=>{P!==T()&&(N(P),l?.(P),A(P))},[T,N,l,A]),I=k.useCallback((P,K)=>{const ae=T()>=w()-s;if(F.current=P,re(P),r?.(P,K),n&&ae&&P>K){const le=Math.max(0,P-V.current);U(le)}else{const le=Math.max(0,P-V.current);T()>le&&U(le)}},[r,n,s,T,w,U]),B=k.useCallback((P,K)=>{V.current=P.height,ne(P.height),d?.(P,K)},[d]),j=k.useCallback(P=>{if(typeof P!="number"||Number.isNaN(P))return;const K=Math.max(0,F.current-V.current),ae=Math.max(0,Math.min(T()+P,K));U(ae)},[T,U]),_=k.useCallback(P=>{if(typeof P!="number"||Number.isNaN(P))return;const K=Math.max(0,F.current-V.current),ae=Math.max(0,Math.min(P,K));U(ae)},[U]),H=k.useCallback(()=>{const P=w();U(P)},[w,U]),z=k.useCallback(()=>{U(0)},[U]),Y=k.useCallback(()=>V.current,[]);return ky({getViewportHeight:Y,isActive:i,scrollBy:j,scrollToBottom:H,scrollToTop:z,vimBindings:x}),k.useImperativeHandle(f,()=>({getBottomOffset:w,getContentHeight:()=>F.current,getItemHeight:P=>D.current?.getItemHeight(P)??0,getItemPosition:P=>D.current?.getItemPosition(P)??null,getScrollOffset:T,getViewportHeight:()=>V.current,remeasure:()=>D.current?.remeasure(),remeasureItem:P=>D.current?.remeasureItem(P),scrollBy:j,scrollTo:_,scrollToBottom:H,scrollToTop:z}),[w,T,j,_,H,z]),h&&Z>te&&te>0?v.jsxs(W,{flexDirection:"row",flexGrow:S.flexGrow,flexShrink:S.flexShrink,overflow:"hidden",children:[v.jsx(Ia,{children:e,debug:t,onContentHeightChange:I,onItemHeightChange:o,onViewportSizeChange:B,overscan:u,ref:D,scrollOffset:C,virtualize:b,...S,flexGrow:1}),v.jsx(md,{color:g,contentHeight:Z,placement:"inset",scrollOffset:C,style:y,viewportHeight:te})]}):v.jsx(Ia,{children:e,debug:t,onContentHeightChange:I,onItemHeightChange:o,onViewportSizeChange:B,overscan:u,ref:D,scrollOffset:C,virtualize:b,...S})},wr=({backgroundColor:e,borderColor:t="cyan",borderStyle:n="round",children:s,columns:i,footer:r,maxHeight:o=.8,paddingX:a=2,paddingY:c=1,rows:l,scrollbarStyle:d="block",scrollRef:u,title:p,visible:f=!0,width:h=60})=>{const g=cd(),{isLoading:y,palette:x}=by(),b=k.useRef(null),S=u??b;if(!f)return null;const C=i??(g.columns||80),N=l??(g.rows||24),T=e??(y?"black":x?.background??"black"),D=o<=1?Math.floor(N*o):Math.min(o,N-2),F=typeof p=="string"?v.jsx(W,{marginBottom:1,children:v.jsx(O,{bold:!0,color:t,children:p})}):p??null;return v.jsx(W,{alignItems:"center",height:N,justifyContent:"center",position:"absolute",width:C,children:v.jsxs(W,{backgroundColor:T,borderBackgroundColor:T,borderColor:t,borderStyle:n,flexDirection:"column",maxHeight:D,opaque:!0,paddingY:c,width:Math.min(h,C-4),children:[F!=null&&v.jsx(W,{flexShrink:0,paddingX:a,children:F}),v.jsx(yd,{flexGrow:1,flexShrink:1,paddingX:a,ref:S,scrollbar:!0,scrollbarColor:t,scrollbarStyle:d,children:s}),r!=null&&v.jsx(W,{alignItems:"center",flexDirection:"column",flexShrink:0,marginTop:1,paddingX:a,children:r})]})})},Pa=({autoExitSeconds:e,onCancel:t,visible:n})=>{const{exit:s}=dd(),[i,r]=k.useState(e||3),o=k.useRef(null),a=k.useRef(0);k.useEffect(()=>{if(!n)return;const l=e||3;r(l),a.current=Date.now();let d=l;return o.current=setInterval(()=>{d-=1,d<=0?(o.current&&(clearInterval(o.current),o.current=null),r(0),s()):r(d)},1e3),()=>{o.current&&(clearInterval(o.current),o.current=null)}},[n,e,s]);const c=k.useCallback(()=>{o.current&&(clearInterval(o.current),o.current=null),t()},[t]);return co((l,d)=>{Date.now()-a.current<200||(l==="q"?s():c())},{isActive:n}),v.jsx(wr,{backgroundColor:"#1e1e1e",footer:v.jsxs(O,{dimColor:!0,children:["Press"," ",v.jsx(O,{bold:!0,color:"white",children:"q"})," ","to exit,"," ",v.jsx(O,{bold:!0,color:"white",children:"any key"})," ","to stay"]}),title:`Exiting in ${i}…`,visible:n,width:50,children:v.jsx(O,{dimColor:!0,children:"Stay to explore the results interactively."})})},Ey=e=>{if(e.startsWith("⚠"))return"yellow";e.startsWith("── ")||e.startsWith("[dry-run]")},Cy=({focused:e,item:t,scrollRef:n})=>{const s=e?"white":"gray";return t?v.jsxs(W,{borderColor:s,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[v.jsx(W,{flexShrink:0,paddingTop:1,paddingX:2,children:v.jsx(O,{bold:!0,color:"white",children:t.entry.title})}),v.jsx(W,{flexShrink:0,paddingBottom:1,paddingX:2,children:v.jsx(O,{dimColor:!0,children:t.entry.description})}),v.jsx(yd,{flexGrow:1,flexShrink:1,paddingX:2,ref:n,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:v.jsxs(W,{flexDirection:"column",children:[v.jsx(O,{dimColor:!0,children:"── What will change ──"}),v.jsx(O,{}),t.preview.length===0&&v.jsx(O,{dimColor:!0,children:"(no preview available)"}),t.preview.map((i,r)=>{const o=Ey(i);return i===""?v.jsx(O,{},`blank-${String(r)}`):v.jsx(O,{color:o,children:i},`${String(r)}-${i.slice(0,20)}`)})]})})]}):v.jsx(W,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:v.jsx(O,{dimColor:!0,children:"No migration selected"})})},Ry=({checked:e,isSelected:t,item:n})=>{const s=e?"☑":"☐",i=n.preview.length;return v.jsxs(W,{flexShrink:0,height:1,children:[v.jsx(O,{children:t?">":" "}),v.jsxs(O,{color:e?"white":"gray",children:[" ",s," "]}),v.jsx(W,{flexGrow:1,children:v.jsx(O,{bold:t,inverse:t,wrap:"truncate",children:n.entry.title})}),v.jsxs(O,{dimColor:!0,children:[" ",i," ","change",i===1?"":"s"," "]})]})},Oy=({checkedItems:e,focused:t,isDryRun:n,items:s,scrollOffset:i,selectedIndex:r,viewportHeight:o})=>{const a=t?"white":"gray",c=s.filter(p=>e.has(p.entry.id)).length,l=s.map((p,f)=>v.jsx(Ry,{checked:e.has(p.entry.id),isSelected:f===r,item:p},p.entry.id)),d=s.length,u=d>o&&o>0;return v.jsxs(W,{borderColor:a,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[v.jsxs(W,{flexShrink:0,gap:1,paddingX:1,children:[v.jsx(O,{bold:!0,inverse:!0,children:" MIGRATE "}),v.jsxs(O,{wrap:"truncate",children:[s.length," ","applicable"]}),c>0&&v.jsxs(O,{dimColor:!0,children:[" — ",c," selected"]}),n&&v.jsx(O,{color:"yellow",children:" (dry-run)"})]}),v.jsxs(W,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[v.jsx(W,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:v.jsx(W,{flexDirection:"column",marginTop:-i,children:l})}),u&&v.jsx(W,{flexShrink:0,marginLeft:1,marginRight:1,children:v.jsx(md,{contentHeight:d,placement:"inset",scrollOffset:i,style:"block",viewportHeight:o})})]})]})},jy=100,Ty=40,Iy=10,Ay=({autoExitSeconds:e=0,isDryRun:t,store:n})=>{const{exit:s}=dd(),{columns:i,rows:r}=cd(),o=k.useSyncExternalStore(n.subscribe,n.getSnapshot),[a,c]=k.useState(!1),[l,d]=k.useState(!1),[u,p]=k.useState(!1),[f,h]=k.useState(0),g=k.useRef(null),y=k.useRef(null),x=k.useRef(null),b=o.items[o.selectedIndex]??null,S=Math.max(1,r-6),C=k.useCallback(M=>{h(w=>M>=w+S?Math.max(0,M-S+1):M<w?Math.max(0,M):w)},[S]);if(k.useEffect(()=>{y.current?.scrollToTop()},[b?.entry.id]),co((M,w)=>{if(M==="c"&&w.ctrl){s();return}if(!u){if(l){M==="u"||w.return?(d(!1),n.startApply(),s(n.getCheckedItems())):w.escape||M==="q"?d(!1):w.downArrow||M==="j"?x.current?.scrollBy(1):(w.upArrow||M==="k")&&x.current?.scrollBy(-1);return}if(a){w.escape||M==="?"?c(!1):M==="q"?(c(!1),p(!0)):w.downArrow||M==="j"?g.current?.scrollBy(1):(w.upArrow||M==="k")&&g.current?.scrollBy(-1);return}if(M==="?"){c(!0);return}if(M==="q"){p(!0);return}if(w.tab){n.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}if(o.focusedPanel==="list"){if(w.downArrow||M==="j"){const A=Math.min(o.selectedIndex+1,o.items.length-1);n.setSelectedIndex(A),C(A);return}if(w.upArrow||M==="k"){const A=Math.max(o.selectedIndex-1,0);n.setSelectedIndex(A),C(A);return}if(w.pageDown){const A=Math.min(o.selectedIndex+10,o.items.length-1);n.setSelectedIndex(A),C(A);return}if(w.pageUp){const A=Math.max(o.selectedIndex-10,0);n.setSelectedIndex(A),C(A);return}if(w.home){n.setSelectedIndex(0),h(0);return}if(w.end){const A=o.items.length-1;n.setSelectedIndex(A),C(A);return}if(M===" "||w.return){b&&n.toggleCheck(b.entry.id);return}if(M==="a"){n.toggleAll();return}if(M==="u"&&!t&&o.checkedItems.size>0){d(!0);return}w.rightArrow&&n.setFocusedPanel("detail");return}if(o.focusedPanel==="detail"){if(w.escape||w.leftArrow){n.setFocusedPanel("list");return}if(w.downArrow||M==="j"){y.current?.scrollBy(1);return}if(w.upArrow||M==="k"){y.current?.scrollBy(-1);return}if(w.pageDown){y.current?.scrollBy(10);return}if(w.pageUp){y.current?.scrollBy(-10);return}if(w.home){y.current?.scrollToTop();return}w.end&&y.current?.scrollToBottom()}}},{isActive:!0}),i<Ty||r<Iy)return v.jsx(W,{alignItems:"center",height:r,justifyContent:"center",width:i,children:v.jsxs(O,{color:"yellow",children:["Terminal too small (",i,"x",r,")"]})});const N=i>=jy,T=[v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"white",children:"q"}),v.jsx(O,{dimColor:!0,children:"QUIT"})]},"q"),v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"white",children:"?"}),v.jsx(O,{dimColor:!0,children:"HELP"})]},"?"),v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"white",children:"↑↓"}),v.jsx(O,{dimColor:!0,children:"NAV"})]},"nav"),v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"white",children:"Space"}),v.jsx(O,{dimColor:!0,children:"CHECK"})]},"sp"),v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"white",children:"a"}),v.jsx(O,{dimColor:!0,children:"ALL"})]},"a")];!t&&o.checkedItems.size>0&&T.push(v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"green",children:"u"}),v.jsx(O,{dimColor:!0,children:"APPLY"})]},"u")),T.push(v.jsxs(W,{gap:1,children:[v.jsx(O,{bold:!0,color:"white",children:"Tab"}),v.jsx(O,{dimColor:!0,children:"PANEL"})]},"tab"));const D=v.jsx(W,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:v.jsx(W,{flexWrap:"wrap",gap:2,paddingX:1,children:T})}),F=v.jsxs(wr,{footer:v.jsxs(O,{dimColor:!0,children:[v.jsx(O,{bold:!0,color:"white",children:"↑↓"})," scroll ",v.jsx(O,{bold:!0,color:"white",children:"?"}),"/",v.jsx(O,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:g,title:"KEYBOARD SHORTCUTS",visible:a,width:52,children:[v.jsxs(W,{flexDirection:"column",marginBottom:1,children:[v.jsx(O,{bold:!0,color:"white",children:"NAVIGATION"}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" ↑/k"}),v.jsx(O,{dimColor:!0,children:" Move up"})]}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" ↓/j"}),v.jsx(O,{dimColor:!0,children:" Move down"})]}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" Tab"}),v.jsx(O,{dimColor:!0,children:" Switch panel"})]}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" →/←"}),v.jsx(O,{dimColor:!0,children:" Focus detail/list"})]})]}),v.jsxs(W,{flexDirection:"column",marginBottom:1,children:[v.jsx(O,{bold:!0,color:"white",children:"SELECTION"}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" Space"}),v.jsx(O,{dimColor:!0,children:" Toggle migration"})]}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" a"}),v.jsx(O,{dimColor:!0,children:" Toggle all"})]})]}),v.jsxs(W,{flexDirection:"column",children:[v.jsx(O,{bold:!0,color:"white",children:"ACTIONS"}),!t&&v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" u"}),v.jsx(O,{dimColor:!0,children:" Apply selected migrations"})]}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" q"}),v.jsx(O,{dimColor:!0,children:" Quit"})]}),v.jsxs(O,{children:[v.jsx(O,{bold:!0,color:"white",children:" ?"}),v.jsx(O,{dimColor:!0,children:" Toggle help"})]})]})]}),V=n.getCheckedItems(),Z=v.jsx(W,{alignItems:"center",flexDirection:"column",children:v.jsxs(O,{dimColor:!0,children:["Press ",v.jsx(O,{bold:!0,color:"white",children:"u"})," or ",v.jsx(O,{bold:!0,color:"white",children:"Enter"})," to confirm, ",v.jsx(O,{bold:!0,color:"white",children:"Esc"})," to cancel"]})}),re=v.jsx(wr,{footer:Z,scrollRef:x,title:`Apply ${String(V.length)} migration${V.length===1?"":"s"}?`,visible:l,width:70,children:V.map(M=>v.jsxs(W,{gap:1,children:[v.jsxs(O,{children:[" ",M.entry.title]}),v.jsxs(O,{dimColor:!0,children:["(",M.preview.length," ","change",M.preview.length===1?"":"s",")"]})]},M.entry.id))}),te=v.jsx(Oy,{checkedItems:o.checkedItems,focused:o.focusedPanel==="list",isDryRun:t,items:o.items,scrollOffset:f,selectedIndex:o.selectedIndex,viewportHeight:S}),ne=v.jsx(Cy,{focused:o.focusedPanel==="detail",item:b,scrollRef:y});if(N){const M=Math.floor(i*.55);return v.jsxs(W,{flexDirection:"column",height:r,width:i,children:[v.jsxs(W,{flexDirection:"row",flexGrow:1,children:[v.jsx(W,{flexGrow:1,children:te}),v.jsx(W,{width:M,children:ne})]}),D,re,v.jsx(Pa,{autoExitSeconds:e||3,onCancel:()=>{p(!1)},visible:u}),F]})}const ie=Math.floor(r*.45);return v.jsxs(W,{flexDirection:"column",height:r,width:i,children:[v.jsx(W,{height:ie,children:te}),v.jsx(W,{flexGrow:1,children:ne}),D,re,v.jsx(Pa,{autoExitSeconds:e||3,onCancel:()=>{p(!1)},visible:u}),F]})},vd=[".lintstagedrc.json",".lintstagedrc"],bd=[".lintstagedrc.yaml",".lintstagedrc.yml",".lintstagedrc.mjs","lint-staged.config.mjs",".lintstagedrc.cjs","lint-staged.config.cjs",".lintstagedrc.js","lint-staged.config.js",".lintstagedrc.ts","lint-staged.config.ts",".lintstagedrc.mts","lint-staged.config.mts",".lintstagedrc.cts","lint-staged.config.cts"],wd=[...vd,...bd],By=[/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)(pnpm|pnpm exec|npx|yarn|yarn run|npm exec|npm run|bunx|bun run|bun x)\s+lint-staged\b/,/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)lint-staged\b/],kd=[".nano-staged.json",".nanostagedrc"],Sd=[".nano-staged.mjs",".nano-staged.cjs",".nano-staged.js","nano-staged.config.mjs","nano-staged.config.cjs","nano-staged.config.js","nano-staged.config.mts","nano-staged.config.cts","nano-staged.config.ts"],xd=[...kd,...Sd],Py=[/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)(pnpm|pnpm exec|npx|yarn|yarn run|npm exec|npm run|bunx|bun run|bun x)\s+nano-staged\b/,/^((?:[A-Z_][A-Z0-9_]*(?:=\S*)?\s+)*)nano-staged\b/],$d=["husky","lint-staged","nano-staged"],Ny=/\(is-ci \|\| husky \|\| exit 0\)\s*&&\s*/g,Dy=/\bhusky(?:\s+install)?\s*&&\s*/g,Ly=/\s*&&\s*husky(?:\s+install)?/g,My=/\s*\|\|\s*husky(?:\s+install)?/g,_y=[Ny,Dy,Ly,My],Ed=e=>{if(e==="husky"||e==="husky install")return;let t=e;for(const n of _y)t=t.replace(n,"");return t=t.trim(),t===e?e:t||void 0},Cd=["pre-commit","pre-merge-commit","prepare-commit-msg","commit-msg","post-commit","applypatch-msg","pre-applypatch","post-applypatch","pre-rebase","post-rewrite","post-checkout","post-merge","pre-push","pre-auto-gc"],lo=".vis/hooks",Nn=".vis-hooks",u4=[".pre-commit-config.yaml",".pre-commit-config.yml","prek.toml"],p4={commit:"pre-commit","merge-commit":"pre-merge-commit",push:"pre-push"},f4=new Set(["commit-msg","post-checkout","post-commit","post-merge","post-rewrite","pre-commit","pre-merge-commit","pre-push","pre-rebase","prepare-commit-msg"]),h4=new Set(["commit-msg","post-checkout","post-merge","post-rewrite","pre-rebase","prepare-commit-msg"]),g4=new Set(["fail","script","system"]),Fy="config.json",Bi=1,Vy=new Set(["alwaysRun","args","builtin","entry","exclude","excludeTypes","fail","files","id","name","passFilenames","types","typesOr","verbose"]),Wy=new Set(["failFast","skipInCI","stages","version"]),Hy=["args","exclude","excludeTypes","files","passFilenames","types","typesOr"],Rd=(e,t)=>m(e,t,Fy),kr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ss=e=>{if(!Array.isArray(e))return;const t=[];for(const n of e){if(typeof n!="string")return;t.push(n)}return t},Un=e=>typeof e=="boolean"?e:void 0,Jt=e=>typeof e=="string"&&e.length>0?e:void 0,Uy=(e,t,n)=>{if(!kr(e))throw new TypeError("hook entry must be an object");if(typeof e.id!="string"||e.id.length===0)throw new TypeError("hook entry is missing `id`");const s={id:e.id},i=Un(e.alwaysRun);i!==void 0&&(s.alwaysRun=i);const r=Ss(e.args);r&&(s.args=r);const o=Jt(e.builtin);o&&(s.builtin=o);const a=Jt(e.entry);a&&(s.entry=a);const c=Jt(e.exclude);c&&(s.exclude=c);const l=Ss(e.excludeTypes);l&&(s.excludeTypes=l);const d=Jt(e.fail);d&&(s.fail=d);const u=Jt(e.files);u&&(s.files=u);const p=Jt(e.name);p&&(s.name=p);const f=Un(e.passFilenames);f!==void 0&&(s.passFilenames=f);const h=Ss(e.types);h&&(s.types=h);const g=Ss(e.typesOr);g&&(s.typesOr=g);const y=Un(e.verbose);if(y!==void 0&&(s.verbose=y),[s.builtin,s.entry,s.fail].filter(b=>b!==void 0).length!==1)throw new TypeError(`hook "${s.id}" must set exactly one of \`builtin\`, \`entry\`, \`fail\``);if(s.fail!==void 0){const b=Hy.filter(S=>s[S]!==void 0);if(b.length>0)throw new TypeError(`hook "${s.id}" is a \`fail\` entry — remove ${b.join(", ")} (filters do not apply)`)}for(const b of Object.keys(e))Vy.has(b)||t.push({hookId:s.id,message:`unknown field "${b}" ignored`,stage:n});return s},Gy=(e,t)=>{if(!kr(e))throw new TypeError("hook config must be an object");if(e.version!==Bi)throw new TypeError(`unsupported hook config version: expected ${Bi}, got ${String(e.version)}`);if(!kr(e.stages))throw new TypeError("hook config is missing `stages` map");const n={};for(const[o,a]of Object.entries(e.stages)){if(!Array.isArray(a))throw new TypeError(`hook config: stage "${o}" must be an array`);n[o]=a.map(c=>Uy(c,t,o))}const s={stages:n,version:Bi},i=Un(e.failFast);i!==void 0&&(s.failFast=i);const r=Un(e.skipInCI);r!==void 0&&(s.skipInCI=r);for(const o of Object.keys(e))Wy.has(o)||t.push({message:`unknown top-level field "${o}" ignored`});return s},zy=(e,t=lo,n)=>{const s=Rd(e,t);if(!$(s))return;const i=J(s);let r;try{r=JSON.parse(i)}catch(o){const a=o instanceof Error?o.message:String(o);throw new TypeError(`failed to parse ${s}: ${a}`,{cause:o})}return Gy(r,[])},m4=(e,t,n)=>{const s=Rd(e,t);ce(s,`${JSON.stringify(n,void 0,4)}
24
+ `,"utf8")},Jy=/\/$/,Na="worktree ",qy=e=>{if(e===Nn||!ur(Nn)||ur(e))return;const t=kl(e);return t&&t!=="."&&mt(t),bl(Nn,e),`migrated ${Nn} → ${e}`},Ky=e=>{let t='"$0"';for(let n=0;n<e;n+=1)t=`"$(dirname ${t})"`;return t},Yy=(e,t={})=>{const s=e.split("/").filter(o=>o!==""&&o!==".").length+2,i=Ky(s);return`#!/usr/bin/env sh
25
25
  { [ "$VIS_GIT_HOOKS" = "2" ]; } && set -x
26
26
  n=$(basename "$0")
27
27
  s=$(dirname "$(dirname "$0")")/$n
@@ -37,54 +37,54 @@ c=$?
37
37
 
38
38
  [ $c != 0 ] && echo "vis - $n script failed (code $c)"
39
39
  [ $c = 127 ] && echo "vis - command not found in PATH=$PATH"
40
- exit $c`},Ba=(e,t,n)=>{gt(e),ce(m(e,".gitignore"),"*"),ce(m(e,"h"),zy(t,{skipInCI:n}),{mode:493});for(const s of xd)ce(m(e,s),`#!/usr/bin/env sh
41
- . "$(dirname "$0")/h"`,{mode:493})},Jy=e=>{const t=rt("git",["worktree","list","--porcelain"],{cwd:e,encoding:"utf8"}),n=[];if(t.status===0){let i;for(const r of t.stdout.split(`
42
- `))r.startsWith(Pa)?i=r.slice(Pa.length).trim()||void 0:r==="bare"||r==="locked"||r.startsWith("locked ")||r.startsWith("prunable")?i=void 0:r===""&&i&&(n.push(i),i=void 0);i&&n.push(i)}const s=n.filter(i=>dr(i));return s.length>0?s:[e??process.cwd()]},qy=(e,t)=>Jy(t).map(n=>m(n,e)),Ed=(e,t)=>Qr(e)?e:m(t,e),Na=(e,t)=>e===`${t}/_`||e.endsWith(`/${t}/_`),Ky=(e,t)=>{try{return yl(m(Ed(e,t),"h"),"utf8").includes("VIS_GIT_HOOKS")}catch{return!1}},Yy=(e,t)=>{let n;try{n=Ee(Ed(e,t))}catch{return"missing"}return n.some(s=>!s.startsWith(".")&&!s.endsWith(".sample"))?"populated":"empty"},Xy=(e,t,n,s)=>{const i=rt("git",["config","--local","core.hooksPath"]),r=i.status===0?i.stdout?.toString().trim()??"":"";return!r||s?{target:t}:Na(r,e)?{target:r}:Na(r,Nn)||Ky(r,n)?{target:t}:Yy(r,n)==="empty"?{yielded:{isError:!0,message:`core.hooksPath is set to "${r}", which holds no hooks — git is currently running none. Re-run with \`vis hook install --force\` to take it over, unset it with \`git config --local --unset core.hooksPath\`, or set VIS_GIT_HOOKS=0 to skip installing hooks entirely.`}}:{yielded:{isError:!1,isWarning:!0,message:`core.hooksPath is already set to "${r}" by another tool, skipping. Re-run with \`vis hook install --force\` to take it over.`}}},Zy=(e=co,t={})=>{if(process.env.VIS_GIT_HOOKS==="0")return{isError:!1,message:"skip install (git hooks disabled via VIS_GIT_HOOKS=0)"};if(e.includes(".."))return{isError:!0,message:'".." is not allowed in hooks directory path'};const n=rt("git",["rev-parse","--show-prefix"]);if(n.status===null)return{isError:!0,message:"git command not found"};if(n.status!==0)return{isError:!1,message:".git directory not found (not a git repository)"};const s=Uy(e),i=n.stdout.toString().trim().replace(Hy,""),r=rt("git",["rev-parse","--show-toplevel"],{encoding:"utf8"}),o=r.status===0&&r.stdout.trim()?r.stdout.trim():process.cwd(),a=Xy(e,i?`${i}/${e}/_`:`${e}/_`,o,!!t.force);if("yielded"in a)return a.yielded;const{target:c}=a,l=(()=>{try{return Wy(process.cwd(),e)?.skipInCI??!1}catch{return!1}})(),d=m(o,c);try{Ba(d,e,l)}catch(y){return{isError:!0,message:`failed to write ${d}: ${y instanceof Error?y.message:String(y)}`}}const u=[];let p=0;for(const y of qy(c,o))if(y!==d)try{Ba(y,e,l),p+=1}catch(x){u.push(`${y} (${x instanceof Error?x.message:String(x)})`)}const{status:f,stderr:h}=rt("git",["config","core.hooksPath",c]);if(f===null)return{isError:!0,message:"git command not found"};if(f)return{isError:!0,message:String(h)};const g=[s,p>0?`installed dispatchers in ${p} linked worktree(s)`:void 0].filter(Boolean);return u.length>0?{installed:!0,isError:!1,isWarning:!0,message:`could not install hooks in ${u.length} linked worktree(s) — they will run no hooks until \`vis hook install\` succeeds there: ${u.join(", ")}`}:{installed:!0,isError:!1,message:g.join("; ")}},Qy=[".husky",".config/husky"],ev=/^\. "\$\(dirname "\$0"\)\/common\.sh"\s*/m,tv=e=>{for(const t of Qy)if($(m(e,t))&&At(m(e,t)).isDirectory())return t},nv=(e,t)=>{const n=new Map,s=m(e,t),i=new Set(xd);for(const r of Ee(s)){if(r==="_"||r===".gitignore"||r.startsWith("."))continue;const o=m(s,r);At(o).isFile()&&(!i.has(r)&&r!=="common.sh"||n.set(r,J(o)))}return n},sv=e=>e.replace(ev,""),Cd=e=>$(m(e,"pnpm-lock.yaml"))||$(m(e,"pnpm-workspace.yaml"))?"pnpm":$(m(e,"yarn.lock"))?"yarn":$(m(e,"bun.lockb"))||$(m(e,"bun.lock"))?"bun":"npm",iv=(e,t)=>{const n=Cd(e),s={bun:["bun","remove","husky"],npm:["npm","uninstall","husky"],pnpm:["pnpm","remove","husky"],yarn:["yarn","remove","husky"]},[i,...r]=s[n];t.info(`Removing husky package via ${n}...`);const o=rt(i,r,{cwd:e,encoding:"utf8",stdio:"pipe"});return o.status!==0?(t.info(`Warning: failed to remove husky via ${n} (${o.stderr?.trim()??"unknown error"})`),!1):!0},rv=(e,t,n)=>{const s=Sd(n);if(s!==n)return s?(e[t]=s,`updated "${t}" script`):(delete e[t],`removed "${t}" script (was: "${n}")`)},ov=(e,t)=>{const n=m(e,"package.json");if(!$(n))return{modified:!1,removedScriptReferences:[]};const s=J(n),i=JSON.parse(s),r=[],o=i.scripts;if(o)for(const[a,c]of Object.entries(o)){if(typeof c!="string")continue;const l=rv(o,a,c);l&&r.push(l)}if(r.length>0){const a=Ye(n,s,{defaultIndent:" ",useEditorconfig:t});ce(n,`${JSON.stringify(i,void 0,a)}
43
- `,"utf8")}return{modified:r.length>0,removedScriptReferences:r}},p4=(e,t,n,s={})=>{const i=tv(e),r=s.dryRun===!0;if(!i)return{isError:!0,message:"No husky installation found (.husky/ or .config/husky/)"};n.info(`Found husky at ${i}/`);const o=nv(e,i);if(o.size===0&&n.info("No user-defined hooks found in husky directory."),!r){const d=rt("git",["config","--local","core.hooksPath"]),u=d.status===0?d.stdout?.toString().trim():"";u&&(u===".husky/_"||u.startsWith(".husky"))&&rt("git",["config","--local","--unset","core.hooksPath"]);const p=Zy(t);if(p.isError)return p;p.message&&(p.isWarning?n.warn(p.message):n.info(p.message))}const a=m(e,t);r||gt(a);let c=0;for(const[d,u]of o){if(d==="common.sh"){r?n.info(" (would copy) common.sh"):(ce(m(a,d),u,{mode:493}),n.info(" Copied common.sh"));continue}if(r)n.info(` (would migrate) ${d}`);else{const p=sv(u);ce(m(a,d),p,{mode:493}),n.info(` Migrated ${d}`)}c+=1}if(r)n.info(" (would remove) husky npm package and clean package.json scripts"),n.info(` (would remove) ${i}/ directory`);else{iv(e,n);const d=ov(e,s.useEditorconfig);if(d.modified){n.info("Updated package.json scripts:");for(const p of d.removedScriptReferences)n.info(` ${p}`)}const u=m(e,i);un(u,{force:!0,recursive:!0}),n.info(`Removed ${i}/`)}return{isError:!1,message:`${r?"would migrate":"Migration complete:"} ${c} hook${c===1?"":"s"} ${r?"from":"migrated from"} ${i}/ to ${t}/`}},oe=(e,t)=>{if(!$(e))return;const n=`${e}.bak`;$(n)||(t?.backupsCreated.includes(n)??!1)||(th(e,n),t&&t.backupsCreated.push(n))},he=e=>{try{const t=J(e);return JSON.parse(t)}catch{return}},yn=e=>{if(!$(e))return!1;try{return JSON.parse(J(e)),!0}catch{return!1}},as=(e,t,n={})=>Ye(e,t,{defaultIndent:" ",useEditorconfig:n.useEditorconfig}),Pt=(e,t,n,s={})=>{if(!$(e))return!1;const i=J(e);let r;try{r=JSON.parse(i)}catch{return!1}const o=t(r);if(o===void 0)return!1;const a=as(e,i,s);return n&&oe(e,n),ce(e,`${JSON.stringify(o,void 0,a)}
44
- `,"utf8"),!0},av=/\blint-staged\b/g,cv=(e,t)=>{let n=!1;const s={...e};for(const[i,r]of Object.entries(s)){if(typeof r!="string")continue;let o=Sd(r);o&&(o=o.replaceAll(av,"vis staged").trim()||void 0),o!==r&&(o?s[i]=o:delete s[i],n=!0,t.rewrittenScriptCount+=1)}return{modified:n,scripts:s}},Rd=(e,t,n,s)=>{const i=m(e,"package.json");$(i)&&Pt(i,r=>{let o=!1;for(const c of kd){const l=r.dependencies,d=r.devDependencies;l?.[c]&&(delete l[c],o=!0,s.removedPackageCount+=1),d?.[c]&&(delete d[c],o=!0,s.removedPackageCount+=1)}if(Object.keys(n).length>0)switch(t){case"bun":{const c=r.workspaces,l=c&&!Array.isArray(c)?c:void 0,d={...l?.catalog??r.catalog};for(const[p,f]of Object.entries(n))d[p]=f;l?.catalog===void 0?r.catalog=d:l.catalog=d;const u=r.overrides??{};for(const p of Object.keys(n))u[p]="catalog:";r.overrides=u,o=!0;break}case"npm":{const c=r.overrides??{};r.overrides={...c,...n},o=!0;break}case"pnpm":{const c=r.pnpm??{},l=c.overrides??{};c.overrides={...l,...n},r.pnpm=c,o=!0;break}case"yarn":{const c=r.resolutions??{};r.resolutions={...c,...n},o=!0;break}}const a=r.scripts;if(a){const c=cv(a,s);c.modified&&(r.scripts=c.scripts,o=!0)}return o?r:void 0})},lv=(e,t,n,s)=>{try{const{workspace:i}=Hf(e);for(const r of Object.values(i.projects)){const o=m(e,r.root);Rd(o,t,n,s)}}catch{}},dv=e=>e.startsWith("- ")||e!==""&&!e.includes(":")&&!e.startsWith("#"),uv=e=>{let t=!1,n="";const s=new Set;for(const i of e){const r=i.trim();if(r==="catalog:"){t=!0;continue}if(!t)continue;if(dv(r))break;const o=r.includes(":")?r.split(":")[0]?.trim():void 0;o&&(s.add(o),n=n||i.slice(0,i.indexOf(r)))}return{entries:s,indent:n||" "}},pv=(e,t,n)=>{const s=[];let i=!1,r=!1;for(let o=0;o<e.length;o+=1){const a=e[o],c=a.trim();if(s.push(a),c==="catalog:"){r=!0;continue}if(r&&!i){const d=e[o+1]?.trim()??"";(!d.includes(":")||d.startsWith("- ")||!d||d==="catalog:")&&(s.push(...t),i=!0,r=!1)}}return i||(n.includes("catalog:")||s.push("catalog:"),s.push(...t)),s},fv=(e,t)=>{const n=m(e,"pnpm-workspace.yaml");if(!$(n)||Object.keys(t).length===0)return;const s=J(n),i=s.split(`
45
- `),{entries:r,indent:o}=uv(i),a=[];for(const[l,d]of Object.entries(t))r.has(l)||a.push(`${o}${l}: "${d}"`);if(a.length===0)return;const c=pv(i,a,s);oe(n),ce(n,c.join(`
46
- `),"utf8")},Da=(e,t,n,s,i,r)=>{const o=n.overrides??{};if(s.dryRun){i.info("[dry-run] Would rewrite package.json files (remove husky/lint-staged, rewrite scripts)"),Object.keys(o).length>0&&i.info(`[dry-run] Would add overrides: ${JSON.stringify(o)}`);return}Rd(e,t,o,r),i.info("Rewritten root package.json"),lv(e,t,o,r),t==="pnpm"&&fv(e,o)},Oe=()=>({backupsCreated:[],gitHooksConfigured:!1,inlinedLintStagedConfigCount:0,manualSteps:[],mergedStagedConfigCount:0,perMigration:{},removedConfigCount:0,removedPackageCount:0,rewrittenScriptCount:0,warnings:[]}),ee=(e,t)=>{!e||e.warnings.includes(t)||e.warnings.push(t)},se=(e,t)=>{!e||e.manualSteps.includes(t)||e.manualSteps.push(t)},me=(e,t,n,s=1)=>{const i=e.perMigration[t]??{removedConfigCount:0,removedPackageCount:0,rewrittenScriptCount:0};i[n]+=s,e.perMigration[t]=i,e[n]+=s},hv=["gitleaks.toml",".gitleaks.toml"],gv=["gitleaks-report.json",".gitleaks-report.json","baseline.json"],di=e=>hv.find(t=>$(m(e,t))),lo=e=>{const t=m(e,".gitleaksignore");return $(t)?t:void 0},uo=e=>{for(const t of gv){const n=m(e,t);if($(n))try{const s=JSON.parse(J(n));if(Array.isArray(s)&&s.length>0&&typeof s[0]=="object"&&s[0]!==null&&"RuleID"in s[0])return n}catch{}}},mv=e=>e.map(t=>({description:t.Description??"",endColumn:t.EndColumn??0,endLine:t.EndLine??t.StartLine??0,entropy:t.Entropy??0,file:t.File??"",match:t.Match??"",ruleId:t.RuleID??"",secret:t.Secret??"",startColumn:t.StartColumn??0,startLine:t.StartLine??0,tags:t.Tags??[]})),yv=(e,t,n,s,i)=>{const r=uo(e);if(!r)return;const o=m(e,".secrets-baseline.json");if($(o)&&r!==o){ee(s,`.secrets-baseline.json already exists — leaving ${r} in place`);return}const a=he(r);if(!Array.isArray(a)){ee(s,`Could not parse ${r} as a gitleaks baseline`);return}const c=mv(a);if(t){n.info(`[dry-run] Would convert ${r} -> ${o} (${String(c.length)} findings)`);return}oe(r,s),ye(o,`${JSON.stringify(c,null,Ye(o,void 0,{defaultIndent:" ",useEditorconfig:i}))}
47
- `),n.info(`Converted ${r} -> ${o} (${String(c.length)} findings)`),me(s,"gitleaks","rewrittenScriptCount")},vv=(e,t,n,s,i)=>{const r=m(e,"package.json");if(!$(r))return;const o=he(r);if(!o)return;const a=di(e),c=a?`vis secrets --config ${a}`:"vis secrets";let l=!1;if(o.scripts){for(const[u,p]of Object.entries(o.scripts))if(typeof p=="string"&&/\bgitleaks\b/.test(p)){const f=p.replaceAll(/\bgitleaks(?:\s+(?:detect|protect))?\b[^\n&|;]*/g,c).trim();f!==p&&(o.scripts[u]=f,l=!0,n.info(` scripts.${u}: "${p}" -> "${f}"`),me(s,"gitleaks","rewrittenScriptCount"))}}if(o.devDependencies){const u=o.devDependencies;for(const p of["gitleaks","@gitleaks/cli"])p in u&&(delete u[p],l=!0,me(s,"gitleaks","removedPackageCount"),n.info(` removed devDependency: ${p}`))}if(!l)return;if(t){n.info(`[dry-run] Would update ${r}`);return}const d=Ye(r,J(r),{defaultIndent:" ",useEditorconfig:i});oe(r,s),ye(r,`${JSON.stringify(o,null,d)}
48
- `)},bv=(e,t,n,s)=>{const i=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],r=di(e),o=r?`vis secrets --staged --config ${r}`:"vis secrets --staged";for(const a of i){const c=m(e,a);if(!$(c))continue;const l=J(c);if(!/\bgitleaks\b/.test(l))continue;const d=l.replaceAll(/\bgitleaks(?:\s+(?:detect|protect))?\b[^\n&|;]*/g,o);if(t){n.info(`[dry-run] Would rewrite ${c}`);continue}oe(c,s),ye(c,d),s.gitHooksConfigured=!0,n.info(`Rewrote gitleaks invocation in ${a}`)}},wv=/^([^:#][^:]*):([^:]+):(\d+)$/,kv=e=>{const t=wv.exec(e.trim());if(!t)return;const[,n,s,i]=t,r=Number.parseInt(i??"0",10);return{description:"",endColumn:0,endLine:r,entropy:0,file:n??"",match:"",ruleId:s??"",secret:"",startColumn:0,startLine:r,tags:[]}},Sv=(e,t,n,s,i)=>{const r=lo(e);if(!r)return;const c=J(r).split(/\r?\n/).map(g=>g.trim()).filter(g=>g.length>0&&!g.startsWith("#")).map(g=>kv(g)).filter(g=>g!==void 0);c.length===0&&ee(s,`${r} contained no recognisable fingerprint lines — deleting it.`);const l=m(e,".secrets-baseline.json"),d=$(l)?he(l)??[]:[],u=new Set(d.map(g=>`${g.file}:${g.ruleId}:${String(g.startLine)}`)),p=[...d];for(const g of c){const y=`${g.file}:${g.ruleId}:${String(g.startLine)}`;u.has(y)||(u.add(y),p.push(g))}if(t){n.info(`[dry-run] Would merge ${String(c.length)} .gitleaksignore fingerprint(s) into ${l}, then delete ${r}.`);return}oe(r,s);const f=$(l)?J(l):void 0;f!==void 0&&oe(l,s);const h=Ye(l,f,{defaultIndent:" ",useEditorconfig:i});ye(l,`${JSON.stringify(p,null,h)}
49
- `),ht(r),n.info(`Merged ${String(c.length)} fingerprint(s) from ${r} into ${l}; removed .gitleaksignore.`),me(s,"gitleaks","rewrittenScriptCount",c.length)},La=(e,t,n,s)=>{const i=di(e),r=lo(e);return!(i??r??uo(e))?(t.silent||n.info("No gitleaks artifacts found — nothing to migrate."),!1):(i&&(n.info(`Keeping ${i} as-is (compatible with vis secrets --config).`),se(s,`Run \`vis secrets --config ${i}\` or rename to .gitleaksignore-compatible defaults.`)),r&&Sv(e,t.dryRun,n,s,t.useEditorconfig),yv(e,t.dryRun,n,s,t.useEditorconfig),vv(e,t.dryRun,n,s,t.useEditorconfig),bv(e,t.dryRun,n,s),se(s,"Review CI workflows (.github/workflows/*.yml) for gitleaks-action calls — replace with `vis secrets`."),!0)},xv=["kingfisher-baseline.yaml",".kingfisher-baseline.yaml","kingfisher-baseline.yml",".kingfisher-baseline.yml"],$v=["kingfisher-rules.yml","kingfisher-rules.yaml",".kingfisher-rules.yml",".kingfisher-rules.yaml"],po=e=>xv.find(t=>$(m(e,t))),ui=e=>$v.find(t=>$(m(e,t))),Ev=e=>{const t=[];let n={};for(const s of e.split(/\r?\n/)){const i=s.replace(/#.*$/,"");(/^\s*-\s*filepath\s*:/.test(i)||/^\s*-\s*$/.test(i))&&(n.filepath&&typeof n.linenum=="number"&&n.fingerprint&&t.push(n),n={});const r=/filepath\s*:\s*(.+?)\s*$/.exec(i);if(r?.[1]){n.filepath=r[1].replaceAll(/^["']|["']$/g,"");continue}const o=/fingerprint\s*:\s*(.+?)\s*$/.exec(i);if(o?.[1]){n.fingerprint=o[1].replaceAll(/^["']|["']$/g,"");continue}const a=/linenum\s*:\s*(\d+)/.exec(i);a?.[1]&&(n.linenum=Number.parseInt(a[1],10))}return n.filepath&&typeof n.linenum=="number"&&n.fingerprint&&t.push(n),t},Cv=e=>({_kingfisherMigration:{legacyFingerprint:e.fingerprint,note:"Kingfisher xxhash — regenerate by running `vis secrets --update-baseline`."},description:"",endColumn:0,endLine:e.linenum,entropy:0,file:e.filepath,match:"",ruleId:"",secret:"",startColumn:0,startLine:e.linenum,tags:[]}),Rv=(e,t,n,s,i)=>{const r=po(e);if(!r)return;const o=m(e,r);let a;try{a=Ev(J(o))}catch(d){const u=d instanceof Error?d.message:String(d);ee(s,`Could not parse ${r} as a Kingfisher baseline: ${u}`);return}if(a.length===0){ee(s,`${r} contained no recognisable records — leaving it in place for manual review.`);return}const c=m(e,".secrets-baseline.json");if($(c)){ee(s,`.secrets-baseline.json already exists — leaving Kingfisher baseline at ${r} for manual merge.`);return}const l=a.map(d=>Cv(d));if(t){n.info(`[dry-run] Would convert ${r} -> .secrets-baseline.json (${String(l.length)} placeholder finding(s))`),se(s,"Run `vis secrets --update-baseline` after migration — Kingfisher xxhash fingerprints aren't interchangeable with our content-hash.");return}oe(o,s),ye(c,`${JSON.stringify(l,null,Ye(c,void 0,{defaultIndent:" ",useEditorconfig:i}))}
50
- `),n.info(`Converted ${r} -> .secrets-baseline.json (${String(l.length)} placeholder finding(s))`),se(s,"Run `vis secrets --update-baseline` — the converted entries are placeholders until the scanner computes real fingerprints."),me(s,"kingfisher","rewrittenScriptCount")},Od=/\bkingfisher(?:\s+(?:scan|validate|rules|update|manage-baseline|report|github|gitlab|bitbucket))?\b[^\n&|;]*/g,Ov=(e,t,n,s,i)=>{const r=m(e,"package.json");if(!$(r))return;const o=he(r);if(!o)return;const a=ui(e),c=a?`vis secrets --config ${a}`:"vis secrets";let l=!1;if(o.scripts)for(const[u,p]of Object.entries(o.scripts)){if(typeof p!="string"||!/\bkingfisher\b/.test(p))continue;const f=p.replaceAll(Od,h=>h.includes("validate")?`${c} --validate`:c).trim();f!==p&&(o.scripts[u]=f,l=!0,n.info(` scripts.${u}: "${p}" -> "${f}"`),me(s,"kingfisher","rewrittenScriptCount"))}if(o.devDependencies){const u=o.devDependencies;for(const p of["kingfisher","@mongodb/kingfisher","kingfisher-scanner"])p in u&&(delete u[p],l=!0,me(s,"kingfisher","removedPackageCount"),n.info(` removed devDependency: ${p}`))}if(!l)return;if(t){n.info(`[dry-run] Would update ${r}`);return}const d=Ye(r,J(r),{defaultIndent:" ",useEditorconfig:i});oe(r,s),ye(r,`${JSON.stringify(o,null,d)}
51
- `)},jv=(e,t,n,s)=>{const i=ui(e),r=i?`vis secrets --staged --config ${i}`:"vis secrets --staged";for(const o of jd){const a=m(e,o);if(!$(a))continue;const c=J(a);if(!/\bkingfisher\b/.test(c))continue;const l=c.replaceAll(Od,r);if(t){n.info(`[dry-run] Would rewrite ${a}`);continue}oe(a,s),ye(a,l),s.gitHooksConfigured=!0,n.info(`Rewrote kingfisher invocation in ${o}`)}},jd=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],Ma=e=>{if(!$(e))return!1;try{return/\bkingfisher\b/.test(J(e))}catch{return!1}},_a=(e,t,n,s)=>{const i=po(e),r=ui(e),o=Ma(m(e,"package.json")),a=jd.some(l=>Ma(m(e,l)));return!!(i??r)||o||a?(r&&(n.info(`Found custom Kingfisher ruleset at ${r} — keeping it for now.`),se(s,`Convert ${r} to gitleaks-shaped JSON using \`packages/tooling/secret-scanner/scripts/kingfisher-converter.mjs\`, then point \`vis secrets --config\` at the result.`)),i&&Rv(e,t.dryRun,n,s,t.useEditorconfig),Ov(e,t.dryRun,n,s,t.useEditorconfig),jv(e,t.dryRun,n,s),se(s,"Replace `# kingfisher:ignore` markers with `# secret-scanner:allow` (or keep `# gitleaks:allow` — the scanner accepts both)."),se(s,"Review CI workflows (.github/workflows/*.yml) for Kingfisher action/docker invocations — replace with `vis secrets`."),!0):(t.silent||n.info("No Kingfisher artifacts found — nothing to migrate."),!1)},Tv=/\bstaged\s*:/,Fa=/(defineConfig\(\{)/,Va=/(export\s+default\s+\{)/,Iv=e=>{for(const n of md)if($(m(e,n)))return!0;const t=m(e,".lintstagedrc");return $(t)&&!yn(t)},Av=e=>{const t=Mt(e);if(!t)return!1;const n=J(t);return Tv.test(n)},Td=e=>{const t=m(e,"package.json");if($(t)&&he(t)?.["lint-staged"])return"package.json";for(const n of yd)if($(m(e,n)))return n},Pv=e=>he(m(e,"package.json"))?.["lint-staged"],Bv=e=>he(e),kr=e=>` staged: {
40
+ exit $c`},Da=(e,t,n)=>{mt(e),ce(m(e,".gitignore"),"*"),ce(m(e,"h"),Yy(t,{skipInCI:n}),{mode:493});for(const s of Cd)ce(m(e,s),`#!/usr/bin/env sh
41
+ . "$(dirname "$0")/h"`,{mode:493})},Xy=e=>{const t=ot("git",["worktree","list","--porcelain"],{cwd:e,encoding:"utf8"}),n=[];if(t.status===0){let i;for(const r of t.stdout.split(`
42
+ `))r.startsWith(Na)?i=r.slice(Na.length).trim()||void 0:r==="bare"||r==="locked"||r.startsWith("locked ")||r.startsWith("prunable")?i=void 0:r===""&&i&&(n.push(i),i=void 0);i&&n.push(i)}const s=n.filter(i=>ur(i));return s.length>0?s:[e??process.cwd()]},Zy=(e,t)=>Xy(t).map(n=>m(n,e)),Od=(e,t)=>eo(e)?e:m(t,e),La=(e,t)=>e===`${t}/_`||e.endsWith(`/${t}/_`),Qy=(e,t)=>{try{return wl(m(Od(e,t),"h"),"utf8").includes("VIS_GIT_HOOKS")}catch{return!1}},ev=(e,t)=>{let n;try{n=we(Od(e,t))}catch{return"missing"}return n.some(s=>!s.startsWith(".")&&!s.endsWith(".sample"))?"populated":"empty"},tv=(e,t,n,s)=>{const i=ot("git",["config","--local","core.hooksPath"]),r=i.status===0?i.stdout?.toString().trim()??"":"";return!r||s?{target:t}:La(r,e)?{target:r}:La(r,Nn)||Qy(r,n)?{target:t}:ev(r,n)==="empty"?{yielded:{isError:!0,message:`core.hooksPath is set to "${r}", which holds no hooks — git is currently running none. Re-run with \`vis hook install --force\` to take it over, unset it with \`git config --local --unset core.hooksPath\`, or set VIS_GIT_HOOKS=0 to skip installing hooks entirely.`}}:{yielded:{isError:!1,isWarning:!0,message:`core.hooksPath is already set to "${r}" by another tool, skipping. Re-run with \`vis hook install --force\` to take it over.`}}},nv=(e=lo,t={})=>{if(process.env.VIS_GIT_HOOKS==="0")return{isError:!1,message:"skip install (git hooks disabled via VIS_GIT_HOOKS=0)"};if(e.includes(".."))return{isError:!0,message:'".." is not allowed in hooks directory path'};const n=ot("git",["rev-parse","--show-prefix"]);if(n.status===null)return{isError:!0,message:"git command not found"};if(n.status!==0)return{isError:!1,message:".git directory not found (not a git repository)"};const s=qy(e),i=n.stdout.toString().trim().replace(Jy,""),r=ot("git",["rev-parse","--show-toplevel"],{encoding:"utf8"}),o=r.status===0&&r.stdout.trim()?r.stdout.trim():process.cwd(),a=tv(e,i?`${i}/${e}/_`:`${e}/_`,o,!!t.force);if("yielded"in a)return a.yielded;const{target:c}=a,l=(()=>{try{return zy(process.cwd(),e)?.skipInCI??!1}catch{return!1}})(),d=m(o,c);try{Da(d,e,l)}catch(y){return{isError:!0,message:`failed to write ${d}: ${y instanceof Error?y.message:String(y)}`}}const u=[];let p=0;for(const y of Zy(c,o))if(y!==d)try{Da(y,e,l),p+=1}catch(x){u.push(`${y} (${x instanceof Error?x.message:String(x)})`)}const{status:f,stderr:h}=ot("git",["config","core.hooksPath",c]);if(f===null)return{isError:!0,message:"git command not found"};if(f)return{isError:!0,message:String(h)};const g=[s,p>0?`installed dispatchers in ${p} linked worktree(s)`:void 0].filter(Boolean);return u.length>0?{installed:!0,isError:!1,isWarning:!0,message:`could not install hooks in ${u.length} linked worktree(s) — they will run no hooks until \`vis hook install\` succeeds there: ${u.join(", ")}`}:{installed:!0,isError:!1,message:g.join("; ")}},sv=[".husky",".config/husky"],iv=/^\. "\$\(dirname "\$0"\)\/common\.sh"\s*/m,rv=e=>{for(const t of sv)if($(m(e,t))&&Bt(m(e,t)).isDirectory())return t},ov=(e,t)=>{const n=new Map,s=m(e,t),i=new Set(Cd);for(const r of we(s)){if(r==="_"||r===".gitignore"||r.startsWith("."))continue;const o=m(s,r);Bt(o).isFile()&&(!i.has(r)&&r!=="common.sh"||n.set(r,J(o)))}return n},av=e=>e.replace(iv,""),jd=e=>$(m(e,"pnpm-lock.yaml"))||$(m(e,"pnpm-workspace.yaml"))?"pnpm":$(m(e,"yarn.lock"))?"yarn":$(m(e,"bun.lockb"))||$(m(e,"bun.lock"))?"bun":"npm",cv=(e,t)=>{const n=jd(e),s={bun:["bun","remove","husky"],npm:["npm","uninstall","husky"],pnpm:["pnpm","remove","husky"],yarn:["yarn","remove","husky"]},[i,...r]=s[n];t.info(`Removing husky package via ${n}...`);const o=ot(i,r,{cwd:e,encoding:"utf8",stdio:"pipe"});return o.status!==0?(t.info(`Warning: failed to remove husky via ${n} (${o.stderr?.trim()??"unknown error"})`),!1):!0},lv=(e,t,n)=>{const s=Ed(n);if(s!==n)return s?(e[t]=s,`updated "${t}" script`):(delete e[t],`removed "${t}" script (was: "${n}")`)},dv=(e,t)=>{const n=m(e,"package.json");if(!$(n))return{modified:!1,removedScriptReferences:[]};const s=J(n),i=JSON.parse(s),r=[],o=i.scripts;if(o)for(const[a,c]of Object.entries(o)){if(typeof c!="string")continue;const l=lv(o,a,c);l&&r.push(l)}if(r.length>0){const a=Ye(n,s,{defaultIndent:" ",useEditorconfig:t});ce(n,`${JSON.stringify(i,void 0,a)}
43
+ `,"utf8")}return{modified:r.length>0,removedScriptReferences:r}},y4=(e,t,n,s={})=>{const i=rv(e),r=s.dryRun===!0;if(!i)return{isError:!0,message:"No husky installation found (.husky/ or .config/husky/)"};n.info(`Found husky at ${i}/`);const o=ov(e,i);if(o.size===0&&n.info("No user-defined hooks found in husky directory."),!r){const d=ot("git",["config","--local","core.hooksPath"]),u=d.status===0?d.stdout?.toString().trim():"";u&&(u===".husky/_"||u.startsWith(".husky"))&&ot("git",["config","--local","--unset","core.hooksPath"]);const p=nv(t);if(p.isError)return p;p.message&&(p.isWarning?n.warn(p.message):n.info(p.message))}const a=m(e,t);r||mt(a);let c=0;for(const[d,u]of o){if(d==="common.sh"){r?n.info(" (would copy) common.sh"):(ce(m(a,d),u,{mode:493}),n.info(" Copied common.sh"));continue}if(r)n.info(` (would migrate) ${d}`);else{const p=av(u);ce(m(a,d),p,{mode:493}),n.info(` Migrated ${d}`)}c+=1}if(r)n.info(" (would remove) husky npm package and clean package.json scripts"),n.info(` (would remove) ${i}/ directory`);else{cv(e,n);const d=dv(e,s.useEditorconfig);if(d.modified){n.info("Updated package.json scripts:");for(const p of d.removedScriptReferences)n.info(` ${p}`)}const u=m(e,i);pn(u,{force:!0,recursive:!0}),n.info(`Removed ${i}/`)}return{isError:!1,message:`${r?"would migrate":"Migration complete:"} ${c} hook${c===1?"":"s"} ${r?"from":"migrated from"} ${i}/ to ${t}/`}},oe=(e,t)=>{if(!$(e))return;const n=`${e}.bak`;$(n)||(t?.backupsCreated.includes(n)??!1)||(rh(e,n),t&&t.backupsCreated.push(n))},he=e=>{try{const t=J(e);return JSON.parse(t)}catch{return}},yn=e=>{if(!$(e))return!1;try{return JSON.parse(J(e)),!0}catch{return!1}},ls=(e,t,n={})=>Ye(e,t,{defaultIndent:" ",useEditorconfig:n.useEditorconfig}),Pt=(e,t,n,s={})=>{if(!$(e))return!1;const i=J(e);let r;try{r=JSON.parse(i)}catch{return!1}const o=t(r);if(o===void 0)return!1;const a=ls(e,i,s);return n&&oe(e,n),ce(e,`${JSON.stringify(o,void 0,a)}
44
+ `,"utf8"),!0},uv=/\blint-staged\b/g,pv=(e,t)=>{let n=!1;const s={...e};for(const[i,r]of Object.entries(s)){if(typeof r!="string")continue;let o=Ed(r);o&&(o=o.replaceAll(uv,"vis staged").trim()||void 0),o!==r&&(o?s[i]=o:delete s[i],n=!0,t.rewrittenScriptCount+=1)}return{modified:n,scripts:s}},Td=(e,t,n,s)=>{const i=m(e,"package.json");$(i)&&Pt(i,r=>{let o=!1;for(const c of $d){const l=r.dependencies,d=r.devDependencies;l?.[c]&&(delete l[c],o=!0,s.removedPackageCount+=1),d?.[c]&&(delete d[c],o=!0,s.removedPackageCount+=1)}if(Object.keys(n).length>0)switch(t){case"bun":{const c=r.workspaces,l=c&&!Array.isArray(c)?c:void 0,d={...l?.catalog??r.catalog};for(const[p,f]of Object.entries(n))d[p]=f;l?.catalog===void 0?r.catalog=d:l.catalog=d;const u=r.overrides??{};for(const p of Object.keys(n))u[p]="catalog:";r.overrides=u,o=!0;break}case"npm":{const c=r.overrides??{};r.overrides={...c,...n},o=!0;break}case"pnpm":{const c=r.pnpm??{},l=c.overrides??{};c.overrides={...l,...n},r.pnpm=c,o=!0;break}case"yarn":{const c=r.resolutions??{};r.resolutions={...c,...n},o=!0;break}}const a=r.scripts;if(a){const c=pv(a,s);c.modified&&(r.scripts=c.scripts,o=!0)}return o?r:void 0})},fv=(e,t,n,s)=>{try{const{workspace:i}=Jf(e);for(const r of Object.values(i.projects)){const o=m(e,r.root);Td(o,t,n,s)}}catch{}},hv=e=>e.startsWith("- ")||e!==""&&!e.includes(":")&&!e.startsWith("#"),gv=e=>{let t=!1,n="";const s=new Set;for(const i of e){const r=i.trim();if(r==="catalog:"){t=!0;continue}if(!t)continue;if(hv(r))break;const o=r.includes(":")?r.split(":")[0]?.trim():void 0;o&&(s.add(o),n=n||i.slice(0,i.indexOf(r)))}return{entries:s,indent:n||" "}},mv=(e,t,n)=>{const s=[];let i=!1,r=!1;for(let o=0;o<e.length;o+=1){const a=e[o],c=a.trim();if(s.push(a),c==="catalog:"){r=!0;continue}if(r&&!i){const d=e[o+1]?.trim()??"";(!d.includes(":")||d.startsWith("- ")||!d||d==="catalog:")&&(s.push(...t),i=!0,r=!1)}}return i||(n.includes("catalog:")||s.push("catalog:"),s.push(...t)),s},yv=(e,t)=>{const n=m(e,"pnpm-workspace.yaml");if(!$(n)||Object.keys(t).length===0)return;const s=J(n),i=s.split(`
45
+ `),{entries:r,indent:o}=gv(i),a=[];for(const[l,d]of Object.entries(t))r.has(l)||a.push(`${o}${l}: "${d}"`);if(a.length===0)return;const c=mv(i,a,s);oe(n),ce(n,c.join(`
46
+ `),"utf8")},Ma=(e,t,n,s,i,r)=>{const o=n.overrides??{};if(s.dryRun){i.info("[dry-run] Would rewrite package.json files (remove husky/lint-staged, rewrite scripts)"),Object.keys(o).length>0&&i.info(`[dry-run] Would add overrides: ${JSON.stringify(o)}`);return}Td(e,t,o,r),i.info("Rewritten root package.json"),fv(e,t,o,r),t==="pnpm"&&yv(e,o)},Oe=()=>({backupsCreated:[],gitHooksConfigured:!1,inlinedLintStagedConfigCount:0,manualSteps:[],mergedStagedConfigCount:0,perMigration:{},removedConfigCount:0,removedPackageCount:0,rewrittenScriptCount:0,warnings:[]}),ee=(e,t)=>{!e||e.warnings.includes(t)||e.warnings.push(t)},se=(e,t)=>{!e||e.manualSteps.includes(t)||e.manualSteps.push(t)},me=(e,t,n,s=1)=>{const i=e.perMigration[t]??{removedConfigCount:0,removedPackageCount:0,rewrittenScriptCount:0};i[n]+=s,e.perMigration[t]=i,e[n]+=s},vv=["gitleaks.toml",".gitleaks.toml"],bv=["gitleaks-report.json",".gitleaks-report.json","baseline.json"],ui=e=>vv.find(t=>$(m(e,t))),uo=e=>{const t=m(e,".gitleaksignore");return $(t)?t:void 0},po=e=>{for(const t of bv){const n=m(e,t);if($(n))try{const s=JSON.parse(J(n));if(Array.isArray(s)&&s.length>0&&typeof s[0]=="object"&&s[0]!==null&&"RuleID"in s[0])return n}catch{}}},wv=e=>e.map(t=>({description:t.Description??"",endColumn:t.EndColumn??0,endLine:t.EndLine??t.StartLine??0,entropy:t.Entropy??0,file:t.File??"",match:t.Match??"",ruleId:t.RuleID??"",secret:t.Secret??"",startColumn:t.StartColumn??0,startLine:t.StartLine??0,tags:t.Tags??[]})),kv=(e,t,n,s,i)=>{const r=po(e);if(!r)return;const o=m(e,".secrets-baseline.json");if($(o)&&r!==o){ee(s,`.secrets-baseline.json already exists — leaving ${r} in place`);return}const a=he(r);if(!Array.isArray(a)){ee(s,`Could not parse ${r} as a gitleaks baseline`);return}const c=wv(a);if(t){n.info(`[dry-run] Would convert ${r} -> ${o} (${String(c.length)} findings)`);return}oe(r,s),ye(o,`${JSON.stringify(c,null,Ye(o,void 0,{defaultIndent:" ",useEditorconfig:i}))}
47
+ `),n.info(`Converted ${r} -> ${o} (${String(c.length)} findings)`),me(s,"gitleaks","rewrittenScriptCount")},Sv=(e,t,n,s,i)=>{const r=m(e,"package.json");if(!$(r))return;const o=he(r);if(!o)return;const a=ui(e),c=a?`vis secrets --config ${a}`:"vis secrets";let l=!1;if(o.scripts){for(const[u,p]of Object.entries(o.scripts))if(typeof p=="string"&&/\bgitleaks\b/.test(p)){const f=p.replaceAll(/\bgitleaks(?:\s+(?:detect|protect))?\b[^\n&|;]*/g,c).trim();f!==p&&(o.scripts[u]=f,l=!0,n.info(` scripts.${u}: "${p}" -> "${f}"`),me(s,"gitleaks","rewrittenScriptCount"))}}if(o.devDependencies){const u=o.devDependencies;for(const p of["gitleaks","@gitleaks/cli"])p in u&&(delete u[p],l=!0,me(s,"gitleaks","removedPackageCount"),n.info(` removed devDependency: ${p}`))}if(!l)return;if(t){n.info(`[dry-run] Would update ${r}`);return}const d=Ye(r,J(r),{defaultIndent:" ",useEditorconfig:i});oe(r,s),ye(r,`${JSON.stringify(o,null,d)}
48
+ `)},xv=(e,t,n,s)=>{const i=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],r=ui(e),o=r?`vis secrets --staged --config ${r}`:"vis secrets --staged";for(const a of i){const c=m(e,a);if(!$(c))continue;const l=J(c);if(!/\bgitleaks\b/.test(l))continue;const d=l.replaceAll(/\bgitleaks(?:\s+(?:detect|protect))?\b[^\n&|;]*/g,o);if(t){n.info(`[dry-run] Would rewrite ${c}`);continue}oe(c,s),ye(c,d),s.gitHooksConfigured=!0,n.info(`Rewrote gitleaks invocation in ${a}`)}},$v=/^([^:#][^:]*):([^:]+):(\d+)$/,Ev=e=>{const t=$v.exec(e.trim());if(!t)return;const[,n,s,i]=t,r=Number.parseInt(i??"0",10);return{description:"",endColumn:0,endLine:r,entropy:0,file:n??"",match:"",ruleId:s??"",secret:"",startColumn:0,startLine:r,tags:[]}},Cv=(e,t,n,s,i)=>{const r=uo(e);if(!r)return;const c=J(r).split(/\r?\n/).map(g=>g.trim()).filter(g=>g.length>0&&!g.startsWith("#")).map(g=>Ev(g)).filter(g=>g!==void 0);c.length===0&&ee(s,`${r} contained no recognisable fingerprint lines — deleting it.`);const l=m(e,".secrets-baseline.json"),d=$(l)?he(l)??[]:[],u=new Set(d.map(g=>`${g.file}:${g.ruleId}:${String(g.startLine)}`)),p=[...d];for(const g of c){const y=`${g.file}:${g.ruleId}:${String(g.startLine)}`;u.has(y)||(u.add(y),p.push(g))}if(t){n.info(`[dry-run] Would merge ${String(c.length)} .gitleaksignore fingerprint(s) into ${l}, then delete ${r}.`);return}oe(r,s);const f=$(l)?J(l):void 0;f!==void 0&&oe(l,s);const h=Ye(l,f,{defaultIndent:" ",useEditorconfig:i});ye(l,`${JSON.stringify(p,null,h)}
49
+ `),gt(r),n.info(`Merged ${String(c.length)} fingerprint(s) from ${r} into ${l}; removed .gitleaksignore.`),me(s,"gitleaks","rewrittenScriptCount",c.length)},_a=(e,t,n,s)=>{const i=ui(e),r=uo(e);return!(i??r??po(e))?(t.silent||n.info("No gitleaks artifacts found — nothing to migrate."),!1):(i&&(n.info(`Keeping ${i} as-is (compatible with vis secrets --config).`),se(s,`Run \`vis secrets --config ${i}\` or rename to .gitleaksignore-compatible defaults.`)),r&&Cv(e,t.dryRun,n,s,t.useEditorconfig),kv(e,t.dryRun,n,s,t.useEditorconfig),Sv(e,t.dryRun,n,s,t.useEditorconfig),xv(e,t.dryRun,n,s),se(s,"Review CI workflows (.github/workflows/*.yml) for gitleaks-action calls — replace with `vis secrets`."),!0)},Rv=["kingfisher-baseline.yaml",".kingfisher-baseline.yaml","kingfisher-baseline.yml",".kingfisher-baseline.yml"],Ov=["kingfisher-rules.yml","kingfisher-rules.yaml",".kingfisher-rules.yml",".kingfisher-rules.yaml"],fo=e=>Rv.find(t=>$(m(e,t))),pi=e=>Ov.find(t=>$(m(e,t))),jv=e=>{const t=[];let n={};for(const s of e.split(/\r?\n/)){const i=s.replace(/#.*$/,"");(/^\s*-\s*filepath\s*:/.test(i)||/^\s*-\s*$/.test(i))&&(n.filepath&&typeof n.linenum=="number"&&n.fingerprint&&t.push(n),n={});const r=/filepath\s*:\s*(.+?)\s*$/.exec(i);if(r?.[1]){n.filepath=r[1].replaceAll(/^["']|["']$/g,"");continue}const o=/fingerprint\s*:\s*(.+?)\s*$/.exec(i);if(o?.[1]){n.fingerprint=o[1].replaceAll(/^["']|["']$/g,"");continue}const a=/linenum\s*:\s*(\d+)/.exec(i);a?.[1]&&(n.linenum=Number.parseInt(a[1],10))}return n.filepath&&typeof n.linenum=="number"&&n.fingerprint&&t.push(n),t},Tv=e=>({_kingfisherMigration:{legacyFingerprint:e.fingerprint,note:"Kingfisher xxhash — regenerate by running `vis secrets --update-baseline`."},description:"",endColumn:0,endLine:e.linenum,entropy:0,file:e.filepath,match:"",ruleId:"",secret:"",startColumn:0,startLine:e.linenum,tags:[]}),Iv=(e,t,n,s,i)=>{const r=fo(e);if(!r)return;const o=m(e,r);let a;try{a=jv(J(o))}catch(d){const u=d instanceof Error?d.message:String(d);ee(s,`Could not parse ${r} as a Kingfisher baseline: ${u}`);return}if(a.length===0){ee(s,`${r} contained no recognisable records — leaving it in place for manual review.`);return}const c=m(e,".secrets-baseline.json");if($(c)){ee(s,`.secrets-baseline.json already exists — leaving Kingfisher baseline at ${r} for manual merge.`);return}const l=a.map(d=>Tv(d));if(t){n.info(`[dry-run] Would convert ${r} -> .secrets-baseline.json (${String(l.length)} placeholder finding(s))`),se(s,"Run `vis secrets --update-baseline` after migration — Kingfisher xxhash fingerprints aren't interchangeable with our content-hash.");return}oe(o,s),ye(c,`${JSON.stringify(l,null,Ye(c,void 0,{defaultIndent:" ",useEditorconfig:i}))}
50
+ `),n.info(`Converted ${r} -> .secrets-baseline.json (${String(l.length)} placeholder finding(s))`),se(s,"Run `vis secrets --update-baseline` — the converted entries are placeholders until the scanner computes real fingerprints."),me(s,"kingfisher","rewrittenScriptCount")},Id=/\bkingfisher(?:\s+(?:scan|validate|rules|update|manage-baseline|report|github|gitlab|bitbucket))?\b[^\n&|;]*/g,Av=(e,t,n,s,i)=>{const r=m(e,"package.json");if(!$(r))return;const o=he(r);if(!o)return;const a=pi(e),c=a?`vis secrets --config ${a}`:"vis secrets";let l=!1;if(o.scripts)for(const[u,p]of Object.entries(o.scripts)){if(typeof p!="string"||!/\bkingfisher\b/.test(p))continue;const f=p.replaceAll(Id,h=>h.includes("validate")?`${c} --validate`:c).trim();f!==p&&(o.scripts[u]=f,l=!0,n.info(` scripts.${u}: "${p}" -> "${f}"`),me(s,"kingfisher","rewrittenScriptCount"))}if(o.devDependencies){const u=o.devDependencies;for(const p of["kingfisher","@mongodb/kingfisher","kingfisher-scanner"])p in u&&(delete u[p],l=!0,me(s,"kingfisher","removedPackageCount"),n.info(` removed devDependency: ${p}`))}if(!l)return;if(t){n.info(`[dry-run] Would update ${r}`);return}const d=Ye(r,J(r),{defaultIndent:" ",useEditorconfig:i});oe(r,s),ye(r,`${JSON.stringify(o,null,d)}
51
+ `)},Bv=(e,t,n,s)=>{const i=pi(e),r=i?`vis secrets --staged --config ${i}`:"vis secrets --staged";for(const o of Ad){const a=m(e,o);if(!$(a))continue;const c=J(a);if(!/\bkingfisher\b/.test(c))continue;const l=c.replaceAll(Id,r);if(t){n.info(`[dry-run] Would rewrite ${a}`);continue}oe(a,s),ye(a,l),s.gitHooksConfigured=!0,n.info(`Rewrote kingfisher invocation in ${o}`)}},Ad=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],Fa=e=>{if(!$(e))return!1;try{return/\bkingfisher\b/.test(J(e))}catch{return!1}},Va=(e,t,n,s)=>{const i=fo(e),r=pi(e),o=Fa(m(e,"package.json")),a=Ad.some(l=>Fa(m(e,l)));return!!(i??r)||o||a?(r&&(n.info(`Found custom Kingfisher ruleset at ${r} — keeping it for now.`),se(s,`Convert ${r} to gitleaks-shaped JSON using \`packages/tooling/secret-scanner/scripts/kingfisher-converter.mjs\`, then point \`vis secrets --config\` at the result.`)),i&&Iv(e,t.dryRun,n,s,t.useEditorconfig),Av(e,t.dryRun,n,s,t.useEditorconfig),Bv(e,t.dryRun,n,s),se(s,"Replace `# kingfisher:ignore` markers with `# secret-scanner:allow` (or keep `# gitleaks:allow` — the scanner accepts both)."),se(s,"Review CI workflows (.github/workflows/*.yml) for Kingfisher action/docker invocations — replace with `vis secrets`."),!0):(t.silent||n.info("No Kingfisher artifacts found — nothing to migrate."),!1)},Pv=/\bstaged\s*:/,Wa=/(defineConfig\(\{)/,Ha=/(export\s+default\s+\{)/,Nv=e=>{for(const n of bd)if($(m(e,n)))return!0;const t=m(e,".lintstagedrc");return $(t)&&!yn(t)},Dv=e=>{const t=_t(e);if(!t)return!1;const n=J(t);return Pv.test(n)},Bd=e=>{const t=m(e,"package.json");if($(t)&&he(t)?.["lint-staged"])return"package.json";for(const n of wd)if($(m(e,n)))return n},Lv=e=>he(m(e,"package.json"))?.["lint-staged"],Mv=e=>he(e),Sr=e=>` staged: {
52
52
  ${Object.entries(e).map(([n,s])=>{const i=Array.isArray(s)?`[${s.map(r=>JSON.stringify(r)).join(", ")}]`:JSON.stringify(s);return` ${JSON.stringify(n)}: ${i}`}).join(`,
53
53
  `)},
54
- }`,Nv=(e,t,n)=>{const s=Mt(e);if(s){const a=J(s),c=kr(t);let l;return Fa.test(a)?l=a.replace(Fa,`$1
55
- ${c},`):Va.test(a)&&(l=a.replace(Va,`$1
54
+ }`,_v=(e,t,n)=>{const s=_t(e);if(s){const a=J(s),c=Sr(t);let l;return Wa.test(a)?l=a.replace(Wa,`$1
55
+ ${c},`):Ha.test(a)&&(l=a.replace(Ha,`$1
56
56
  ${c},`)),l?(oe(s),ce(s,l,"utf8"),n.info(`Merged staged config into ${s}`),!0):(n.warn(`Could not auto-insert staged config into ${s} — please add manually`),!1)}const i=m(e,"vis.config.ts"),o=`import { defineConfig } from "@visulima/vis/config";
57
57
 
58
58
  export default defineConfig({
59
- ${kr(t)},
59
+ ${Sr(t)},
60
60
  });
61
- `;return ce(i,o,"utf8"),n.info(`Created ${i} with staged config`),!0},Dv=(e,t)=>{const n=m(e,"package.json"),s={configRemoved:!1,dependencyRemoved:!1};if(!$(n))return s;const i=J(n),r=JSON.parse(i);let o=!1;r["lint-staged"]&&(delete r["lint-staged"],o=!0,s.configRemoved=!0);const a=r.devDependencies,c=r.dependencies;if(a?.["lint-staged"]&&(delete a["lint-staged"],o=!0,s.dependencyRemoved=!0),c?.["lint-staged"]&&(delete c["lint-staged"],o=!0,s.dependencyRemoved=!0),o){const l=as(n,i,{useEditorconfig:t});oe(n),ce(n,`${JSON.stringify(r,void 0,l)}
62
- `,"utf8")}return s},Lv=(e,t)=>{for(const n of yd){const s=m(e,n);$(s)&&(oe(s,t),ht(s),t.removedConfigCount+=1)}},Mv=(e,t)=>{const n=m(e,t,"pre-commit");if(!$(n))return!1;const s=J(n);if(s.includes("vis staged"))return!1;const i=s.split(`
63
- `);let r=!1;const o=[];for(const a of i){const c=a.trim();if(!r){let l=!1;for(const d of jy){const u=d.exec(c);if(u){const p=a.slice(0,a.length-a.trimStart().length),f=u[1]?.trim()??"",h=c.slice(u[0].length).trim(),g=[f,"vis staged",h].filter(Boolean);o.push(`${p}${g.join(" ")}`),r=!0,l=!0;break}}if(l)continue}o.push(a)}return r?(oe(n),ce(n,o.join(`
64
- `)),!0):!1},_v=(e,t,n)=>{if(t==="package.json")return Pv(e);const s=m(e,t);if(!gd.includes(t)){ee(n,`${t} cannot be auto-migrated — please add "staged" config to vis.config.ts manually`),se(n,`Manually convert ${t} to staged config in vis.config.ts`);return}if(t===".lintstagedrc"&&!yn(s)){ee(n,".lintstagedrc is not JSON format — please migrate manually");return}return Bv(s)},Id=(e,t,n)=>{const{configRemoved:s,dependencyRemoved:i}=Dv(e,n);s&&(t.inlinedLintStagedConfigCount+=1),i&&(t.removedPackageCount+=1),Lv(e,t)},Fv=(e,t,n,s)=>{const i=[".vis/hooks",".husky"];for(const r of i)$(m(e,r))&&Mv(e,r)&&(s.gitHooksConfigured=!0,t.silent||n.info(`Rewrote pre-commit hook in ${r}/ to use "vis staged"`))},Vv=(e,t,n,s,i)=>{Nv(e,t,s)&&(i.mergedStagedConfigCount+=1),Id(e,i,n.useEditorconfig),Fv(e,n,s,i)},Wa=(e,t,n,s)=>{const i=Td(e);if(!i)return t.silent||n.info("No lint-staged configuration found — nothing to migrate."),!1;if(Iv(e)&&(ee(s,'Non-JSON lint-staged config found — please migrate to "staged" in vis.config.ts manually'),se(s,"Convert your lint-staged config file to JSON format or add staged config to vis.config.ts manually")),Av(e))return ee(s,'vis.config.ts already has a "staged" config — skipping lint-staged merge'),t.silent||n.warn('vis.config.ts already has a "staged" config — skipping'),t.dryRun||Id(e,s,t.useEditorconfig),!0;const r=_v(e,i,s);return!r||Object.keys(r).length===0?(t.silent||n.warn("lint-staged config is empty — skipping"),!1):t.dryRun?(t.silent||(n.info("[dry-run] Would insert staged config into vis.config.ts:"),n.info(kr(r))),!0):(Vv(e,r,t,n,s),!0)},fo=(e,t,n)=>{const s=t?Ye(t,void 0,{defaultIndent:" ",useEditorconfig:n}):" ";return JSON.stringify(e,null,s).replaceAll(/"(\w+)":/g,"$1:")},ho=(e,t,n,s,i)=>{const r=m(e,"vis.config.ts"),o=$(r);return o&&!n.dryRun&&!n.force?(s.warn("vis.config.ts already exists — refusing to overwrite. Re-run with --force to replace it (a .bak is taken first), or run with --dry-run to preview."),i.warnings.push("vis.config.ts already exists; migration skipped writing the file. Re-run with --force to overwrite."),!1):(n.dryRun?(s.info("── vis.config.ts (preview) ──"),s.info(t),s.info("── end preview ──")):(o&&n.force&&(oe(r,i),s.info(`Replacing ${r} (backup at ${r}.bak)`)),ye(r,t),s.info(`Wrote ${r}`)),!0)},Ad=(e,t)=>{const n=m(e,t);if($(n))try{return JSON.parse(J(n))}catch(s){throw new Error(`Failed to parse ${n}: ${s.message}`,{cause:s})}},Wv=e=>{const t={};return e.command&&(t.command=Array.isArray(e.args)?`${e.command} ${e.args.join(" ")}`:e.args?`${e.command} ${e.args}`:e.command),e.deps&&e.deps.length>0&&(t.dependsOn=e.deps),e.inputs&&e.inputs.length>0&&(t.inputs=e.inputs),e.outputs&&e.outputs.length>0&&(t.outputs=e.outputs),e.type&&(t.type=e.type),e.preset&&(t.preset=e.preset),e.options&&(t.options=e.options),t},Hv=(e,t,n)=>{const s={};e.fileGroups&&(s.fileGroups=e.fileGroups);const i={};for(const[o,a]of Object.entries(e.tasks??{}))i[o]=Wv(a);return Object.keys(i).length>0&&(s.tasks=i),e.implicitInputs&&e.implicitInputs.length>0&&(s.namedInputs={default:e.implicitInputs}),["// Migrated from moon's .moon/tasks.yml by `vis migrate moon`.","// Per-project moon.yml files can be converted to project.json —","// review the generated file and move project-specific tasks there.","",'import { defineConfig } from "@visulima/vis/config";',"",`export default defineConfig(${fo(s,m(t,"vis.config.ts"),n)});`,""].join(`
65
- `)},Uv=e=>{const t=m(e,".moon");if(!$(t))return;for(const s of["tasks.yml","tasks.yaml"]){const i=m(t,s);if($(i))return i}const n=m(t,"tasks");if($(n)){const s=Ee(n).filter(i=>i.endsWith(".yml")||i.endsWith(".yaml")).sort();if(s.length>0)return m(n,s[0])}},Gv=e=>{const t=m(e,".moon","templates");if(!$(t))return[];const n=[];try{for(const s of Ee(t,{withFileTypes:!0}))s.isDirectory()&&$(m(t,s.name,"template.yml"))&&n.push(s.name)}catch{}return n.sort()},zv=(e,t,n,s,i)=>{const r=m(e,".moon","templates"),o=m(e,".vis","templates");n||nh(o,{recursive:!0});for(const a of t){const c=m(r,a),l=m(o,a);if($(l)){i.warnings.push(`Template "${a}" already exists at .vis/templates/${a} — left untouched. Remove or rename either copy to resolve.`);continue}if(n){s.info(`Would copy .moon/templates/${a} → .vis/templates/${a}`);continue}try{sh(c,l,{recursive:!0}),s.info(`Copied .moon/templates/${a} → .vis/templates/${a}`)}catch(d){const u=d instanceof Error?d.message:String(d);i.warnings.push(`Failed to copy template "${a}": ${u}`)}}!n&&t.length>0&&i.manualSteps.push(`Copied ${String(t.length)} template${t.length===1?"":"s"} from .moon/templates/ to .vis/templates/. Remove the .moon/templates/ directory when ready.`)},Ha=(e,t,n,s)=>{const i=Uv(e);if(!i){n.warn("No .moon/tasks.yml (or .moon/tasks/<scope>.yml) found — nothing to migrate."),s.warnings.push("No moon tasks file at workspace root.");return}let r;try{r=It(i)}catch(l){throw new Error(`Failed to parse ${i}: ${l.message}`,{cause:l})}for(const[l,d]of Object.entries(r.tasks??{}))d.env&&Object.keys(d.env).length>0&&s.warnings.push(`Task "${l}" has an \`env\` block which vis does not support — set environment variables in the command or a wrapper script.`),d.platform&&s.warnings.push(`Task "${l}" has a \`platform\` field ("${d.platform}") which vis does not support — review and remove.`),d.toolchain&&s.warnings.push(`Task "${l}" has a \`toolchain\` field ("${d.toolchain}") which vis does not support — review and remove.`),Array.isArray(d.args)&&d.args.some(p=>p.includes(" "))&&s.warnings.push(`Task "${l}" has \`args\` entries containing spaces — vis flattens args into the command string so quoting may need manual adjustment.`);r.extends&&r.extends.length>0&&s.warnings.push("`extends` was found in the moon config but has no direct vis equivalent — inline the referenced files or use vis's `scopedTasks` blocks."),r.implicitDeps&&r.implicitDeps.length>0&&s.warnings.push("`implicitDeps` was found in the moon config but has no direct vis equivalent — add explicit `dependsOn` entries in project.json instead."),r.taskOptions&&Object.keys(r.taskOptions).length>0&&s.warnings.push("`taskOptions` was found in the moon config but has no direct vis equivalent — review and apply settings per-target in vis.config.ts.");const o=Hv(r,e,t.useEditorconfig);if(!ho(e,o,t,n,s))return;s.manualSteps.push("moon's per-project `moon.yml` files should be converted to `project.json`. vis reads targets, tags, layer, stack, language, and owners from project.json — the field names match."),s.manualSteps.push("Scoped `.moon/tasks/<scope>.yml` files map to vis's `scopedTasks` with a `match` block. Only the first scope file was parsed — review the generated file."),s.manualSteps.push("vis tasks support `when: { os, env, branch, ci, not.* }` for conditional execution and `always: true` for cleanup tasks that fire even when upstream fails. Review tasks that used moon's `local: true`, `options.runInCI`, or shell-based platform gating — the new surface is more expressive and may simplify them. See docs/guides/conditional-and-finally-tasks.mdx.");const a=Gv(e);if(a.length===0)return;const c=a.map(l=>`"${l}"`).join(", ");t.copyTemplates?zv(e,a,!!t.dryRun,n,s):s.manualSteps.push(`Detected ${String(a.length)} template${a.length===1?"":"s"} under .moon/templates/ (${c}). They are already usable via \`vis generate <name>\` — vis auto-discovers moon-format template directories at runtime. To decouple from moon entirely, re-run \`vis migrate moon --copy-templates\` to physically move them to .vis/templates/.`)},Jv=/\bstaged\s*:/,Ua=/(defineConfig\(\{)/,Ga=/(export\s+default\s+\{)/,qv=e=>{for(const n of bd)if($(m(e,n)))return!0;const t=m(e,".nanostagedrc");return $(t)&&!yn(t)},Kv=e=>{const t=Mt(e);return t?Jv.test(J(t)):!1},Pd=e=>{const t=m(e,"package.json");if($(t)&&he(t)?.["nano-staged"])return"package.json";for(const n of wd)if($(m(e,n)))return n},Yv=e=>he(m(e,"package.json"))?.["nano-staged"],Xv=e=>he(e),Sr=e=>` staged: {
61
+ `;return ce(i,o,"utf8"),n.info(`Created ${i} with staged config`),!0},Fv=(e,t)=>{const n=m(e,"package.json"),s={configRemoved:!1,dependencyRemoved:!1};if(!$(n))return s;const i=J(n),r=JSON.parse(i);let o=!1;r["lint-staged"]&&(delete r["lint-staged"],o=!0,s.configRemoved=!0);const a=r.devDependencies,c=r.dependencies;if(a?.["lint-staged"]&&(delete a["lint-staged"],o=!0,s.dependencyRemoved=!0),c?.["lint-staged"]&&(delete c["lint-staged"],o=!0,s.dependencyRemoved=!0),o){const l=ls(n,i,{useEditorconfig:t});oe(n),ce(n,`${JSON.stringify(r,void 0,l)}
62
+ `,"utf8")}return s},Vv=(e,t)=>{for(const n of wd){const s=m(e,n);$(s)&&(oe(s,t),gt(s),t.removedConfigCount+=1)}},Wv=(e,t)=>{const n=m(e,t,"pre-commit");if(!$(n))return!1;const s=J(n);if(s.includes("vis staged"))return!1;const i=s.split(`
63
+ `);let r=!1;const o=[];for(const a of i){const c=a.trim();if(!r){let l=!1;for(const d of By){const u=d.exec(c);if(u){const p=a.slice(0,a.length-a.trimStart().length),f=u[1]?.trim()??"",h=c.slice(u[0].length).trim(),g=[f,"vis staged",h].filter(Boolean);o.push(`${p}${g.join(" ")}`),r=!0,l=!0;break}}if(l)continue}o.push(a)}return r?(oe(n),ce(n,o.join(`
64
+ `)),!0):!1},Hv=(e,t,n)=>{if(t==="package.json")return Lv(e);const s=m(e,t);if(!vd.includes(t)){ee(n,`${t} cannot be auto-migrated — please add "staged" config to vis.config.ts manually`),se(n,`Manually convert ${t} to staged config in vis.config.ts`);return}if(t===".lintstagedrc"&&!yn(s)){ee(n,".lintstagedrc is not JSON format — please migrate manually");return}return Mv(s)},Pd=(e,t,n)=>{const{configRemoved:s,dependencyRemoved:i}=Fv(e,n);s&&(t.inlinedLintStagedConfigCount+=1),i&&(t.removedPackageCount+=1),Vv(e,t)},Uv=(e,t,n,s)=>{const i=[".vis/hooks",".husky"];for(const r of i)$(m(e,r))&&Wv(e,r)&&(s.gitHooksConfigured=!0,t.silent||n.info(`Rewrote pre-commit hook in ${r}/ to use "vis staged"`))},Gv=(e,t,n,s,i)=>{_v(e,t,s)&&(i.mergedStagedConfigCount+=1),Pd(e,i,n.useEditorconfig),Uv(e,n,s,i)},Ua=(e,t,n,s)=>{const i=Bd(e);if(!i)return t.silent||n.info("No lint-staged configuration found — nothing to migrate."),!1;if(Nv(e)&&(ee(s,'Non-JSON lint-staged config found — please migrate to "staged" in vis.config.ts manually'),se(s,"Convert your lint-staged config file to JSON format or add staged config to vis.config.ts manually")),Dv(e))return ee(s,'vis.config.ts already has a "staged" config — skipping lint-staged merge'),t.silent||n.warn('vis.config.ts already has a "staged" config — skipping'),t.dryRun||Pd(e,s,t.useEditorconfig),!0;const r=Hv(e,i,s);return!r||Object.keys(r).length===0?(t.silent||n.warn("lint-staged config is empty — skipping"),!1):t.dryRun?(t.silent||(n.info("[dry-run] Would insert staged config into vis.config.ts:"),n.info(Sr(r))),!0):(Gv(e,r,t,n,s),!0)},ho=(e,t,n)=>{const s=t?Ye(t,void 0,{defaultIndent:" ",useEditorconfig:n}):" ";return JSON.stringify(e,null,s).replaceAll(/"(\w+)":/g,"$1:")},go=(e,t,n,s,i)=>{const r=m(e,"vis.config.ts"),o=$(r);return o&&!n.dryRun&&!n.force?(s.warn("vis.config.ts already exists — refusing to overwrite. Re-run with --force to replace it (a .bak is taken first), or run with --dry-run to preview."),i.warnings.push("vis.config.ts already exists; migration skipped writing the file. Re-run with --force to overwrite."),!1):(n.dryRun?(s.info("── vis.config.ts (preview) ──"),s.info(t),s.info("── end preview ──")):(o&&n.force&&(oe(r,i),s.info(`Replacing ${r} (backup at ${r}.bak)`)),ye(r,t),s.info(`Wrote ${r}`)),!0)},Nd=(e,t)=>{const n=m(e,t);if($(n))try{return JSON.parse(J(n))}catch(s){throw new Error(`Failed to parse ${n}: ${s.message}`,{cause:s})}},zv=e=>{const t={};return e.command&&(t.command=Array.isArray(e.args)?`${e.command} ${e.args.join(" ")}`:e.args?`${e.command} ${e.args}`:e.command),e.deps&&e.deps.length>0&&(t.dependsOn=e.deps),e.inputs&&e.inputs.length>0&&(t.inputs=e.inputs),e.outputs&&e.outputs.length>0&&(t.outputs=e.outputs),e.type&&(t.type=e.type),e.preset&&(t.preset=e.preset),e.options&&(t.options=e.options),t},Jv=(e,t,n)=>{const s={};e.fileGroups&&(s.fileGroups=e.fileGroups);const i={};for(const[o,a]of Object.entries(e.tasks??{}))i[o]=zv(a);return Object.keys(i).length>0&&(s.tasks=i),e.implicitInputs&&e.implicitInputs.length>0&&(s.namedInputs={default:e.implicitInputs}),["// Migrated from moon's .moon/tasks.yml by `vis migrate moon`.","// Per-project moon.yml files can be converted to project.json —","// review the generated file and move project-specific tasks there.","",'import { defineConfig } from "@visulima/vis/config";',"",`export default defineConfig(${ho(s,m(t,"vis.config.ts"),n)});`,""].join(`
65
+ `)},qv=e=>{const t=m(e,".moon");if(!$(t))return;for(const s of["tasks.yml","tasks.yaml"]){const i=m(t,s);if($(i))return i}const n=m(t,"tasks");if($(n)){const s=we(n).filter(i=>i.endsWith(".yml")||i.endsWith(".yaml")).sort();if(s.length>0)return m(n,s[0])}},Kv=e=>{const t=m(e,".moon","templates");if(!$(t))return[];const n=[];try{for(const s of we(t,{withFileTypes:!0}))s.isDirectory()&&$(m(t,s.name,"template.yml"))&&n.push(s.name)}catch{}return n.sort()},Yv=(e,t,n,s,i)=>{const r=m(e,".moon","templates"),o=m(e,".vis","templates");n||oh(o,{recursive:!0});for(const a of t){const c=m(r,a),l=m(o,a);if($(l)){i.warnings.push(`Template "${a}" already exists at .vis/templates/${a} — left untouched. Remove or rename either copy to resolve.`);continue}if(n){s.info(`Would copy .moon/templates/${a} → .vis/templates/${a}`);continue}try{ah(c,l,{recursive:!0}),s.info(`Copied .moon/templates/${a} → .vis/templates/${a}`)}catch(d){const u=d instanceof Error?d.message:String(d);i.warnings.push(`Failed to copy template "${a}": ${u}`)}}!n&&t.length>0&&i.manualSteps.push(`Copied ${String(t.length)} template${t.length===1?"":"s"} from .moon/templates/ to .vis/templates/. Remove the .moon/templates/ directory when ready.`)},Ga=(e,t,n,s)=>{const i=qv(e);if(!i){n.warn("No .moon/tasks.yml (or .moon/tasks/<scope>.yml) found — nothing to migrate."),s.warnings.push("No moon tasks file at workspace root.");return}let r;try{r=At(i)}catch(l){throw new Error(`Failed to parse ${i}: ${l.message}`,{cause:l})}for(const[l,d]of Object.entries(r.tasks??{}))d.env&&Object.keys(d.env).length>0&&s.warnings.push(`Task "${l}" has an \`env\` block which vis does not support — set environment variables in the command or a wrapper script.`),d.platform&&s.warnings.push(`Task "${l}" has a \`platform\` field ("${d.platform}") which vis does not support — review and remove.`),d.toolchain&&s.warnings.push(`Task "${l}" has a \`toolchain\` field ("${d.toolchain}") which vis does not support — review and remove.`),Array.isArray(d.args)&&d.args.some(p=>p.includes(" "))&&s.warnings.push(`Task "${l}" has \`args\` entries containing spaces — vis flattens args into the command string so quoting may need manual adjustment.`);r.extends&&r.extends.length>0&&s.warnings.push("`extends` was found in the moon config but has no direct vis equivalent — inline the referenced files or use vis's `scopedTasks` blocks."),r.implicitDeps&&r.implicitDeps.length>0&&s.warnings.push("`implicitDeps` was found in the moon config but has no direct vis equivalent — add explicit `dependsOn` entries in project.json instead."),r.taskOptions&&Object.keys(r.taskOptions).length>0&&s.warnings.push("`taskOptions` was found in the moon config but has no direct vis equivalent — review and apply settings per-target in vis.config.ts.");const o=Jv(r,e,t.useEditorconfig);if(!go(e,o,t,n,s))return;s.manualSteps.push("moon's per-project `moon.yml` files should be converted to `project.json`. vis reads targets, tags, layer, stack, language, and owners from project.json — the field names match."),s.manualSteps.push("Scoped `.moon/tasks/<scope>.yml` files map to vis's `scopedTasks` with a `match` block. Only the first scope file was parsed — review the generated file."),s.manualSteps.push("vis tasks support `when: { os, env, branch, ci, not.* }` for conditional execution and `always: true` for cleanup tasks that fire even when upstream fails. Review tasks that used moon's `local: true`, `options.runInCI`, or shell-based platform gating — the new surface is more expressive and may simplify them. See docs/guides/conditional-and-finally-tasks.mdx.");const a=Kv(e);if(a.length===0)return;const c=a.map(l=>`"${l}"`).join(", ");t.copyTemplates?Yv(e,a,!!t.dryRun,n,s):s.manualSteps.push(`Detected ${String(a.length)} template${a.length===1?"":"s"} under .moon/templates/ (${c}). They are already usable via \`vis generate <name>\` — vis auto-discovers moon-format template directories at runtime. To decouple from moon entirely, re-run \`vis migrate moon --copy-templates\` to physically move them to .vis/templates/.`)},Xv=/\bstaged\s*:/,za=/(defineConfig\(\{)/,Ja=/(export\s+default\s+\{)/,Zv=e=>{for(const n of Sd)if($(m(e,n)))return!0;const t=m(e,".nanostagedrc");return $(t)&&!yn(t)},Qv=e=>{const t=_t(e);return t?Xv.test(J(t)):!1},Dd=e=>{const t=m(e,"package.json");if($(t)&&he(t)?.["nano-staged"])return"package.json";for(const n of xd)if($(m(e,n)))return n},eb=e=>he(m(e,"package.json"))?.["nano-staged"],tb=e=>he(e),xr=e=>` staged: {
66
66
  ${Object.entries(e).map(([n,s])=>{const i=Array.isArray(s)?`[${s.map(r=>JSON.stringify(r)).join(", ")}]`:JSON.stringify(s);return` ${JSON.stringify(n)}: ${i}`}).join(`,
67
67
  `)},
68
- }`,Zv=(e,t,n)=>{const s=Mt(e);if(s){const a=J(s),c=Sr(t);let l;return Ua.test(a)?l=a.replace(Ua,`$1
69
- ${c},`):Ga.test(a)&&(l=a.replace(Ga,`$1
68
+ }`,nb=(e,t,n)=>{const s=_t(e);if(s){const a=J(s),c=xr(t);let l;return za.test(a)?l=a.replace(za,`$1
69
+ ${c},`):Ja.test(a)&&(l=a.replace(Ja,`$1
70
70
  ${c},`)),l?(oe(s),ce(s,l,"utf8"),n.info(`Merged staged config into ${s}`),!0):(n.warn(`Could not auto-insert staged config into ${s} — please add manually`),!1)}const i=m(e,"vis.config.ts"),o=`import { defineConfig } from "@visulima/vis/config";
71
71
 
72
72
  export default defineConfig({
73
- ${Sr(t)},
73
+ ${xr(t)},
74
74
  });
75
- `;return ce(i,o,"utf8"),n.info(`Created ${i} with staged config`),!0},Qv=(e,t)=>{const n=m(e,"package.json"),s={configRemoved:!1,dependencyRemoved:!1};if(!$(n))return s;const i=J(n),r=JSON.parse(i);let o=!1;r["nano-staged"]&&(delete r["nano-staged"],o=!0,s.configRemoved=!0);const a=r.devDependencies,c=r.dependencies;if(a?.["nano-staged"]&&(delete a["nano-staged"],o=!0,s.dependencyRemoved=!0),c?.["nano-staged"]&&(delete c["nano-staged"],o=!0,s.dependencyRemoved=!0),o){const l=as(n,i,{useEditorconfig:t});oe(n),ce(n,`${JSON.stringify(r,void 0,l)}
76
- `,"utf8")}return s},eb=(e,t)=>{for(const n of wd){const s=m(e,n);$(s)&&(oe(s,t),ht(s),t.removedConfigCount+=1)}},tb=(e,t)=>{const n=m(e,t,"pre-commit");if(!$(n))return!1;const s=J(n);if(s.includes("vis staged"))return!1;const i=s.split(`
77
- `);let r=!1;const o=[];for(const a of i){const c=a.trim();if(!r){let l=!1;for(const d of Ty){const u=d.exec(c);if(u){const p=a.slice(0,a.length-a.trimStart().length),f=u[1]?.trim()??"",h=c.slice(u[0].length).trim(),g=[f,"vis staged",h].filter(Boolean);o.push(`${p}${g.join(" ")}`),r=!0,l=!0;break}}if(l)continue}o.push(a)}return r?(oe(n),ce(n,o.join(`
78
- `)),!0):!1},nb=(e,t,n)=>{if(t==="package.json")return Yv(e);const s=m(e,t);if(!vd.includes(t)){ee(n,`${t} cannot be auto-migrated — please add "staged" config to vis.config.ts manually`),se(n,`Manually convert ${t} to staged config in vis.config.ts`);return}if(t===".nanostagedrc"&&!yn(s)){ee(n,".nanostagedrc is not JSON format — please migrate manually");return}return Xv(s)},Bd=(e,t,n)=>{const{configRemoved:s,dependencyRemoved:i}=Qv(e,n);s&&(t.inlinedLintStagedConfigCount+=1),i&&(t.removedPackageCount+=1),eb(e,t)},sb=(e,t,n,s)=>{const i=[".vis/hooks",".husky"];for(const r of i)$(m(e,r))&&tb(e,r)&&(s.gitHooksConfigured=!0,t.silent||n.info(`Rewrote pre-commit hook in ${r}/ to use "vis staged"`))},ib=(e,t,n,s,i)=>{Zv(e,t,s)&&(i.mergedStagedConfigCount+=1),Bd(e,i,n.useEditorconfig),sb(e,n,s,i)},za=(e,t,n,s)=>{const i=Pd(e);if(!i)return t.silent||n.info("No nano-staged configuration found — nothing to migrate."),!1;if(qv(e)&&(ee(s,'Non-JSON nano-staged config found — please migrate to "staged" in vis.config.ts manually'),se(s,"Convert your nano-staged config file to JSON format or add staged config to vis.config.ts manually")),Kv(e))return ee(s,'vis.config.ts already has a "staged" config — skipping nano-staged merge'),t.silent||n.warn('vis.config.ts already has a "staged" config — skipping'),t.dryRun||Bd(e,s,t.useEditorconfig),!0;const r=nb(e,i,s);return!r||Object.keys(r).length===0?(t.silent||n.warn("nano-staged config is empty — skipping"),!1):t.dryRun?(t.silent||(n.info("[dry-run] Would insert staged config into vis.config.ts:"),n.info(Sr(r))),!0):(ib(e,r,t,n,s),!0)},Nd=[".vis/last-summary.json",".vis/last-failures/"],Dd=(e,t)=>{const n=t.replace(/\/$/,"");return e.some(s=>{const i=s.trim();return i===""||i.startsWith("#")?!1:i===t||i===n?!0:/^\*{0,2}\/?\.vis(?:\/\*{0,2})?$/.test(i)})},rb=(e,t={})=>{const{create:n=!0}=t,s=m(e,".gitignore"),i=$(s);if(!i&&!n)return{added:[],changed:!1};const r=i?J(s):"",o=r.includes(`\r
75
+ `;return ce(i,o,"utf8"),n.info(`Created ${i} with staged config`),!0},sb=(e,t)=>{const n=m(e,"package.json"),s={configRemoved:!1,dependencyRemoved:!1};if(!$(n))return s;const i=J(n),r=JSON.parse(i);let o=!1;r["nano-staged"]&&(delete r["nano-staged"],o=!0,s.configRemoved=!0);const a=r.devDependencies,c=r.dependencies;if(a?.["nano-staged"]&&(delete a["nano-staged"],o=!0,s.dependencyRemoved=!0),c?.["nano-staged"]&&(delete c["nano-staged"],o=!0,s.dependencyRemoved=!0),o){const l=ls(n,i,{useEditorconfig:t});oe(n),ce(n,`${JSON.stringify(r,void 0,l)}
76
+ `,"utf8")}return s},ib=(e,t)=>{for(const n of xd){const s=m(e,n);$(s)&&(oe(s,t),gt(s),t.removedConfigCount+=1)}},rb=(e,t)=>{const n=m(e,t,"pre-commit");if(!$(n))return!1;const s=J(n);if(s.includes("vis staged"))return!1;const i=s.split(`
77
+ `);let r=!1;const o=[];for(const a of i){const c=a.trim();if(!r){let l=!1;for(const d of Py){const u=d.exec(c);if(u){const p=a.slice(0,a.length-a.trimStart().length),f=u[1]?.trim()??"",h=c.slice(u[0].length).trim(),g=[f,"vis staged",h].filter(Boolean);o.push(`${p}${g.join(" ")}`),r=!0,l=!0;break}}if(l)continue}o.push(a)}return r?(oe(n),ce(n,o.join(`
78
+ `)),!0):!1},ob=(e,t,n)=>{if(t==="package.json")return eb(e);const s=m(e,t);if(!kd.includes(t)){ee(n,`${t} cannot be auto-migrated — please add "staged" config to vis.config.ts manually`),se(n,`Manually convert ${t} to staged config in vis.config.ts`);return}if(t===".nanostagedrc"&&!yn(s)){ee(n,".nanostagedrc is not JSON format — please migrate manually");return}return tb(s)},Ld=(e,t,n)=>{const{configRemoved:s,dependencyRemoved:i}=sb(e,n);s&&(t.inlinedLintStagedConfigCount+=1),i&&(t.removedPackageCount+=1),ib(e,t)},ab=(e,t,n,s)=>{const i=[".vis/hooks",".husky"];for(const r of i)$(m(e,r))&&rb(e,r)&&(s.gitHooksConfigured=!0,t.silent||n.info(`Rewrote pre-commit hook in ${r}/ to use "vis staged"`))},cb=(e,t,n,s,i)=>{nb(e,t,s)&&(i.mergedStagedConfigCount+=1),Ld(e,i,n.useEditorconfig),ab(e,n,s,i)},qa=(e,t,n,s)=>{const i=Dd(e);if(!i)return t.silent||n.info("No nano-staged configuration found — nothing to migrate."),!1;if(Zv(e)&&(ee(s,'Non-JSON nano-staged config found — please migrate to "staged" in vis.config.ts manually'),se(s,"Convert your nano-staged config file to JSON format or add staged config to vis.config.ts manually")),Qv(e))return ee(s,'vis.config.ts already has a "staged" config — skipping nano-staged merge'),t.silent||n.warn('vis.config.ts already has a "staged" config — skipping'),t.dryRun||Ld(e,s,t.useEditorconfig),!0;const r=ob(e,i,s);return!r||Object.keys(r).length===0?(t.silent||n.warn("nano-staged config is empty — skipping"),!1):t.dryRun?(t.silent||(n.info("[dry-run] Would insert staged config into vis.config.ts:"),n.info(xr(r))),!0):(cb(e,r,t,n,s),!0)},Md=[".vis/last-summary.json",".vis/last-failures/",".vis/runs/"],_d=(e,t)=>{const n=t.replace(/\/$/,"");return e.some(s=>{const i=s.trim();return i===""||i.startsWith("#")?!1:i===t||i===n?!0:/^\*{0,2}\/?\.vis(?:\/\*{0,2})?$/.test(i)})},lb=(e,t={})=>{const{create:n=!0}=t,s=m(e,".gitignore"),i=$(s);if(!i&&!n)return{added:[],changed:!1};const r=i?J(s):"",o=r.includes(`\r
79
79
  `)?`\r
80
80
  `:`
81
- `,a=r.split(/\r?\n/),c=Nd.filter(d=>!Dd(a,d));if(c.length===0)return{added:[],changed:!1};const l=[...a];for(;l.length>0&&l[l.length-1].trim()==="";)l.pop();return l.length>0&&l.push(""),l.push("# vis run state (.vis/templates and .vis/hooks are tracked — do not ignore .vis/ wholesale)",...c),ye(s,`${l.join(o)}${o}`),{added:[...c],changed:!0}},ob=(e,t,n)=>{if(t.dryRun){const i=m(e,".gitignore"),r=$(i)?J(i).split(/\r?\n/):[],o=Nd.filter(a=>!Dd(r,a));o.length>0&&n.info(`Would add to .gitignore: ${o.join(", ")}.`);return}const s=rb(e,{create:!1});s.added.length>0&&n.info(`Added to .gitignore: ${s.added.join(", ")}.`)},we=(e,t)=>{const n=rs(e,t);return n.startsWith("..")?t:n.split(If).join("/")},ab=new Set([".cache",".git",".next",".nx",".output",".svelte-kit",".turbo",".vercel",".vis","build","coverage","dist","node_modules"]),cb=(e,t=8)=>{const n=[],s=(i,r)=>{if(r>t)return;let o;try{o=Ee(i)}catch{return}for(const a of o){if(ab.has(a)||a.startsWith("."))continue;const c=m(i,a);let l;try{l=At(c)}catch{continue}l.isDirectory()?s(c,r+1):a==="project.json"&&n.push(c)}};return s(e,0),n},lb={"@nx/eslint:lint":"lint:eslint","@nx/jest:jest":"test","@nx/js:tsc":"build","@nx/next:build":"build","@nx/playwright:playwright":"test:e2e","@nx/storybook:build":"build-storybook","@nx/vite:build":"build","@nx/vite:test":"test","@nx/webpack:webpack":"build"},db=["cache","dependsOn","inputs","outputs","persistent"],ub=(e,t,n)=>{const s={};for(const[i,r]of Object.entries(e))i.includes(":")||(s[i]=r);for(const[i,r]of Object.entries(e)){if(!i.includes(":"))continue;const o=lb[i];if(!o){t.warnings.push(`Dropped \`${i}\` from tasks — vis only supports script-name targets, not nx-namespaced executors.`);continue}if(s[o]){t.warnings.push(`Dropped \`${i}\` from tasks — \`${o}\` already has an explicit entry; the explicit one was kept.`);continue}const a={},c=[];for(const d of db)r[d]!==void 0&&(a[d]=r[d],c.push(d));s[o]=a;const l=c.length>0?`carried ${c.join(", ")}`:"no settings to carry";n?.info(`Translated \`${i}\` → \`${o}\` in tasks (${l}).`)}return s},pb=(e,t,n)=>{const s={},i=e.affected?.defaultBase??e.defaultBase;return typeof i=="string"&&i.length>0&&i!=="main"&&(s.defaultBase=i),e.namedInputs&&Object.keys(e.namedInputs).length>0&&(s.namedInputs=e.namedInputs),e.targetDefaults&&Object.keys(e.targetDefaults).length>0&&(s.tasks=e.targetDefaults),["// Migrated from nx.json by `vis migrate nx`.","// Per-project project.json files are compatible with vis and do not need to be rewritten —","// vis already reads targets, tags, implicitDependencies, and sourceRoot.","",'import { defineConfig } from "@visulima/vis/config";',"",`export default defineConfig(${fo(s,m(t,"vis.config.ts"),n)});`,""].join(`
82
- `)},Pi=/node_modules\/nx\/schemas\/project-schema\.json$/u,fb=(e,t,n,s)=>{let i=0;for(const r of e){if(t.dryRun){const a=go(r);a?.$schema&&Pi.test(a.$schema)&&(n.info(`Would rewrite $schema in ${r}`),i+=1);continue}Pt(r,a=>{if(!(!a.$schema||!Pi.test(a.$schema)))return a.$schema=a.$schema.replace(Pi,"node_modules/@visulima/vis/schemas/project.schema.json"),a},s,{useEditorconfig:t.useEditorconfig})&&(i+=1)}return i>0&&n.info(`Rewrote $schema in ${String(i)} project.json file(s).`),i},go=e=>{if($(e))try{return JSON.parse(J(e))}catch{return}},hb=e=>{const t=new Map,n=new Set;for(const s of e){const i=go(s);if(!i?.name)continue;n.add(i.name);const r=m(st(s),"package.json");if($(r))try{const o=JSON.parse(J(r));o.name&&o.name!==i.name&&t.set(o.name,i.name)}catch{}}return{knownProjects:n,pkgToProject:t}},gb=/&&|\|\||[;|><`]|\$\(/u,mb=/[*[\]^.]/u,Bi=(e,t)=>{if(t===""){e.complex=!0;return}if(t.startsWith("!")){e.hasExclusion=!0;return}if(mb.test(t)||t.includes("...")){e.hasGlob=!0;return}e.filters.push(t)},yb=e=>{if(typeof e!="string"||e.trim()===""||gb.test(e)||/['"]/u.test(e))return null;const t=e.trim().split(/\s+/u);if(t[0]!=="pnpm"&&t[0]!=="pnpm.cmd")return null;const n={complex:!1,filters:[],hasExclusion:!1,hasGlob:!1,parallel:!1,recursive:!1,target:""};let s=1;for(;s<t.length;){const i=t[s];if(i==="--filter"||i==="-F"){const r=t[s+1];if(r===void 0)return n.complex=!0,n;Bi(n,r),s+=2;continue}if(i.startsWith("--filter=")){Bi(n,i.slice(9)),s+=1;continue}if(i.startsWith("-F=")){Bi(n,i.slice(3)),s+=1;continue}if(i==="--parallel"){n.parallel=!0,s+=1;continue}if(i==="-r"||i==="--recursive"){n.recursive=!0,s+=1;continue}if(i==="--workspace-root"||i==="-w")return n.complex=!0,n;if(i==="run"||i==="exec"){if(i==="exec")return n.complex=!0,n;s+=1;continue}return i.startsWith("-")?(n.complex=!0,n):(n.target=i,s+=1,s<t.length&&(n.complex=!0),n)}return n.complex=!0,n},vb=(e,t)=>{const n=[],s=[];for(const i of e){const r=t.pkgToProject.get(i);if(r!==void 0){n.push(r);continue}if(t.knownProjects.has(i)){n.push(i);continue}s.push(i)}return{mapped:n,unmapped:s}},bb=(e,t)=>{const n=["vis","run",e.target];if(t.length>0){const s=[...t].sort((i,r)=>i.localeCompare(r)).join(",");n.push(`--projects=${s}`)}return n.join(" ")},wb=new Set(["dev","dev:server","dev:watch","serve","start:dev","storybook","watch"]),kb=(e,t,n,s,i)=>{const r={rewrittenTargets:new Set,unmappedHits:[]},o=m(e,"package.json");if(!$(o))return r;let a;try{a=JSON.parse(J(o))}catch{return r}if(!a.scripts)return r;const c=new Map;for(const[l,d]of Object.entries(a.scripts)){const u=yb(d);if(!u||u.target===""||u.complex)continue;if(u.hasExclusion||u.hasGlob){i.warnings.push(`pnpm filter in scripts.${l} uses ${u.hasExclusion?"an exclusion (!)":"a glob/dependency selector"} — left untouched. Translate by hand to \`vis run ${u.target} --projects=...\` once you decide which projects should be selected.`);continue}if(u.filters.length===0&&!u.recursive)continue;const p=vb(u.filters,t);if(p.unmapped.length>0){r.unmappedHits.push({filters:p.unmapped,script:l});continue}const f=bb(u,p.mapped);f!==d&&(c.set(l,f),r.rewrittenTargets.add(u.target))}if(c.size===0)return r;if(n.dryRun){for(const[l,d]of c){const u=a.scripts[l];s.info(`Would rewrite scripts.${l}: \`${u??""}\` → \`${d}\``)}return r}return Pt(o,l=>{if(!l.scripts)return;const d={...l.scripts};let u=!1;for(const[p,f]of c)d[p]!==void 0&&d[p]!==f&&(d[p]=f,u=!0);if(u)return l.scripts=d,l},i,{useEditorconfig:n.useEditorconfig}),s.info(`Rewrote ${String(c.size)} pnpm-filter script(s) in package.json to use \`vis run\`.`),r},Sb=(e,t,n)=>{let s=e.targetDefaults??{},i=!1;for(const r of t){if(!wb.has(r))continue;const a={...s[r]??{}};let c=!1;a.persistent!==!0&&(a.persistent=!0,c=!0),a.cache!==!1&&(a.cache=!1,c=!0),c&&(s={...s,[r]:a},i=!0,n.manualSteps.push(`tasks.${r} set to { persistent: true, cache: false } — long-running task auto-detected from rewritten pnpm filter scripts. Adjust if your ${r} is actually short-lived.`))}i&&(e.targetDefaults=s)},xb=e=>{if(e.executor!=="nx:run-script")return!1;const t=Object.keys(e.options??{});return t.length===0||t.length===1&&t[0]==="script"},$b=(e,t,n,s)=>{let i=0,r=0,o=0;const a=[];for(const c of e){const l=go(c);if(!l?.targets||Object.keys(l.targets).length===0)continue;const d=l.name??"<unnamed>",u=[],p=[],f=[];for(const[y,x]of Object.entries(l.targets))x.syncGenerators&&x.syncGenerators.length>0&&f.push({sync:[...x.syncGenerators],target:y}),xb(x)?p.push(y):u.push(y);const h=u.length===0&&p.length>0,g=p.length>0;h?(t.dryRun?(n.info(`Would remove targets block from ${c} (all entries are nx:run-script shims).`),i+=1):(Pt(c,y=>{if(y.targets)return delete y.targets,y},s,{useEditorconfig:t.useEditorconfig}),i+=1),f.length>0&&a.push({file:c,name:d,nonShimTargets:[],syncGenerators:f})):g?(t.dryRun?n.info(`Would strip ${String(p.length)} nx:run-script shim entr(y/ies) from ${c} (non-shim entries kept: ${u.join(", ")}).`):Pt(c,y=>{if(y.targets){for(const x of p)Reflect.deleteProperty(y.targets,x);return y}},s,{useEditorconfig:t.useEditorconfig}),r+=1,o+=p.length,a.push({file:c,name:d,nonShimTargets:u,syncGenerators:f})):a.push({file:c,name:d,nonShimTargets:u,syncGenerators:f})}return i>0&&n.info(`Removed targets block from ${String(i)} project.json file(s) (entries were nx:run-script shims).`),o>0&&!t.dryRun&&n.info(`Stripped ${String(o)} nx:run-script shim entr(y/ies) across ${String(r)} project.json file(s) (non-shim entries remain for manual review).`),{droppedTargetBlocks:i,partialTargetBlocks:r,punchList:a,strippedShimEntries:o}},Eb=(e,t,n,s)=>{const i=m(e,"pnpm-workspace.yaml");if(!$(i))return{catalogEntriesRemoved:0,onlyBuiltRemoved:!1};let r;try{r=It(i)}catch{return{catalogEntriesRemoved:0,onlyBuiltRemoved:!1}}if(!r||typeof r!="object")return{catalogEntriesRemoved:0,onlyBuiltRemoved:!1};let o=0;const a=f=>f==="nx"||f.startsWith("@nx/"),c=(f,h,g)=>{if(!f||typeof f!="object")return;const y=Object.keys(f).length,x=Object.fromEntries(Object.entries(f).filter(([S])=>!a(S))),b=y-Object.keys(x).length;b>0&&(o+=b,h[g]=x)};c(r.catalog,r,"catalog");const l=r.catalogs;if(l&&typeof l=="object")for(const[f,h]of Object.entries(l))c(h,l,f);let d=!1;const u=r.onlyBuiltDependencies;if(Array.isArray(u)){const f=u.filter(h=>h!=="nx");f.length!==u.length&&(r.onlyBuiltDependencies=f,d=!0)}return(o>0||d)&&(t.dryRun?(o>0&&n.info(`Would remove ${String(o)} nx-related catalog entr(y/ies) from pnpm-workspace.yaml.`),d&&n.info("Would remove `nx` from pnpm-workspace.yaml#onlyBuiltDependencies.")):(oe(i,s),Ol(i,r),o>0&&n.info(`Removed ${String(o)} nx-related catalog entr(y/ies) from pnpm-workspace.yaml.`),d&&n.info("Removed `nx` from pnpm-workspace.yaml#onlyBuiltDependencies."))),{catalogEntriesRemoved:o,onlyBuiltRemoved:d}},Cb=(e,t,n,s,i,r,o)=>{const a=m(st(e),"package.json");if(!$(a))return{reason:"no sibling package.json"};const c=`pre${n}`,l=`echo "TODO(vis): replace with logic equivalent to nx syncGenerators: ${s.join(", ")}" && exit 1`;if(i.dryRun){let p;try{p=JSON.parse(J(a)).scripts}catch{return{reason:"package.json unreadable"}}return p?.[c]?{reason:`\`${c}\` script already exists in ${we(t,a)}`}:(r.info(`Would add \`${c}\` script to ${we(t,a)} (TODO for nx syncGenerators: ${s.join(", ")}).`),{pkgPath:we(t,a),preScript:c})}let d;return Pt(a,p=>{if(p.scripts?.[c]){d=`\`${c}\` script already exists in ${we(t,a)}`;return}return p.scripts={...p.scripts,[c]:l},p},o,{useEditorconfig:i.useEditorconfig})?(r.info(`Added \`${c}\` script (TODO) to ${we(t,a)} — wire up replacement for: ${s.join(", ")}.`),{pkgPath:we(t,a),preScript:c}):{reason:d??"package.json unwritable"}},Rb=/^nx\s+(?:run-many|run|affected|reset|repair)\b|^nx\s+exec\b/u,Ob=new Set(["affected","exec","repair","reset","run","run-many"]),jb=(e,t)=>{const n=e.trim();if(/[;&|"']/u.test(n))return;const s=/^nx\s+run-many\s+(?:-t|--target=?)\s*([\w:-]+)\s*$/u.exec(n);if(s)return`vis run ${s[1]}`;const i=/^nx\s+affected\s+(?:-t|--target=?)\s*([\w:-]+)\s*$/u.exec(n);if(i)return`vis run ${i[1]} --affected`;const r=/^nx\s+run\s+([\w@/-]+):([\w:-]+)\s*$/u.exec(n);if(r?.[1]&&r[2]&&t.has(r[1]))return`vis run ${r[2]} --projects=${r[1]}`;const o=/^nx\s+([\w:-]+)\s*$/u.exec(n);if(o?.[1]&&!Ob.has(o[1]))return`vis run ${o[1]}`},Tb=(e,t,n,s,i)=>{const r={deletedFiles:[],rewrittenScripts:[],skippedScripts:[],strippedDevDeps:[]},o=m(e,".github","ignore-files-for-nx-affected.yml");if($(o))if(n.dryRun)s.info(`Would delete ${we(e,o)}.`),r.deletedFiles.push(we(e,o));else{oe(o,i);try{ht(o),s.info(`Removed ${we(e,o)} (backup at \`${we(e,o)}.bak\`).`),r.deletedFiles.push(we(e,o))}catch{}}const a=m(e,"package.json");if(!$(a))return r;if(Pt(a,c=>{let l=!1;if(c.devDependencies)for(const d of Object.keys(c.devDependencies))(d==="nx"||d.startsWith("@nx/")||d.startsWith("@nrwl/"))&&(n.dryRun||Reflect.deleteProperty(c.devDependencies,d),r.strippedDevDeps.push(d),l=!0);if(c.scripts)for(const[d,u]of Object.entries(c.scripts)){if(typeof u!="string"||!(Rb.test(u)||u.startsWith("nx ")))continue;const f=jb(u,t);if(f===void 0){r.skippedScripts.push(d);continue}n.dryRun||(c.scripts[d]=f),r.rewrittenScripts.push({from:u,name:d,to:f}),l=!0}return l?c:void 0},n.dryRun?void 0:i,{useEditorconfig:n.useEditorconfig}),r.strippedDevDeps.length>0){const c=n.dryRun?"Would strip":"Stripped";s.info(`${c} ${String(r.strippedDevDeps.length)} nx-related devDependenc(y/ies) from package.json: ${r.strippedDevDeps.join(", ")}.`)}for(const c of r.rewrittenScripts){const l=n.dryRun?"Would rewrite":"Rewrote";s.info(`${l} \`scripts.${c.name}\`: \`${c.from}\` -> \`${c.to}\``)}return r.skippedScripts.length>0&&i.manualSteps.push(`--aggressive could not rewrite these package.json scripts (they have shell complexity or unknown flags): ${r.skippedScripts.join(", ")}. Rewrite them manually to use \`vis run\`.`),r},Ib=e=>{const t={eslintHits:[],ignoreFile:!1,nxJson:!1,pkgDevDeps:[],pkgScripts:[],workflowHits:[]};$(m(e,"nx.json"))&&(t.nxJson=!0),$(m(e,".github/ignore-files-for-nx-affected.yml"))&&(t.ignoreFile=!0);const n=m(e,"package.json");if($(n))try{const i=JSON.parse(J(n));if(i.devDependencies)for(const r of Object.keys(i.devDependencies))(r==="nx"||r.startsWith("@nx/")||r.startsWith("@nrwl/"))&&t.pkgDevDeps.push(r);if(i.scripts)for(const[r,o]of Object.entries(i.scripts))typeof o=="string"&&(/\bnx\s+(?:run-many|run|affected|exec|reset|repair)\b/u.test(o)||o.startsWith("nx "))&&t.pkgScripts.push(r)}catch{}const s=m(e,".github/workflows");if($(s))try{for(const i of Ee(s)){if(!i.endsWith(".yml")&&!i.endsWith(".yaml"))continue;const r=m(s,i),o=J(r);/nrwl\/nx-set-shas/u.test(o)&&t.workflowHits.push({file:`.github/workflows/${i}`,reason:"uses nrwl/nx-set-shas action"}),/\bNX_BRANCH\b|\bNX_RUN_GROUP\b/u.test(o)&&t.workflowHits.push({file:`.github/workflows/${i}`,reason:"sets NX_BRANCH / NX_RUN_GROUP env"}),(/--files=\$\{\{[^}]*tj-actions/u.test(o)||/tj-actions\/changed-files/u.test(o))&&t.workflowHits.push({file:`.github/workflows/${i}`,reason:"uses tj-actions/changed-files (no longer needed; vis does its own affected diff)"})}}catch{}for(const i of["eslint.config.mjs","eslint.config.js","eslint.config.cjs","eslint.config.ts",".eslintrc.json",".eslintrc.js"]){const r=m(e,i);if(!$(r))continue;const o=J(r);/@nx\/eslint-plugin|@nx\/enforce-module-boundaries|@nx\/dependency-checks|@nx\/nx-plugin-checks/u.test(o)&&t.eslintHits.push(i)}return t},Ab=(e,t,n)=>{const s=[];if(e.nxJson&&!n.backedUpNxJson&&s.push(`Remove ${m(t,"nx.json")} once you're satisfied with vis.config.ts.`),e.ignoreFile&&s.push("Delete .github/ignore-files-for-nx-affected.yml — vis uses git-based affected diff and has no equivalent."),e.pkgDevDeps.length>0&&s.push(`Remove these nx devDependencies from package.json: ${e.pkgDevDeps.join(", ")}.`),e.pkgScripts.length>0&&s.push(`Rewrite these package.json scripts to use \`vis run\`: ${e.pkgScripts.join(", ")}.`),e.workflowHits.length>0){const i=new Map;for(const r of e.workflowHits){const o=i.get(r.file)??new Set;o.add(r.reason),i.set(r.file,o)}for(const[r,o]of i)s.push(`Update ${r}: ${[...o].join("; ")}.`)}return e.eslintHits.length>0&&s.push(`Remove @nx/eslint-plugin imports + rules (enforce-module-boundaries, dependency-checks, nx-plugin-checks) from: ${e.eslintHits.join(", ")}. There is no vis equivalent yet.`),s.map((i,r)=>`${String(r+1)}. ${i}`)},Pb=(e,t)=>{if(e.length!==0){t.info(""),t.info("── Post-migrate cleanup ──");for(const n of e)t.info(n)}},Ja=(e,t,n,s)=>{t.aggressive&&(t={...t,force:!0,rewriteSyncGenerators:!0});const i=Ad(e,"nx.json");if(!i){n.warn("No nx.json found in workspace root — nothing to migrate."),s.warnings.push("No nx.json at workspace root.");return}i.targetDefaults&&(i.targetDefaults=ub(i.targetDefaults,s,n));const r=cb(e),o=hb(r),a=kb(e,o,t,n,s);Sb(i,a.rewrittenTargets,s);for(const f of a.unmappedHits)s.warnings.push(`scripts.${f.script}: pnpm filter(s) ${f.filters.map(h=>`\`${h}\``).join(", ")} don't match any known project.json#name or sibling package.json#name. Left untouched — fix the filter or add the missing project.json before re-running.`);const c=pb(i,e,t.useEditorconfig);if(!ho(e,c,t,n,s))return;fb(r,t,n,s);const{punchList:l}=$b(r,t,n,s);for(const f of l){f.nonShimTargets.length>0&&s.manualSteps.push(`Review targets in ${we(e,f.file)} (project: ${f.name}) — non-shim targets need manual review: ${f.nonShimTargets.join(", ")}.`);for(const h of f.syncGenerators){if(t.rewriteSyncGenerators){const g=Cb(f.file,e,h.target,h.sync,t,n,s);if("preScript"in g){s.manualSteps.push(`${g.pkgPath} now has a \`${g.preScript}\` script that fails with a TODO. Replace it with the real equivalent of nx syncGenerators: ${h.sync.join(", ")}.`);continue}s.warnings.push(`syncGenerators on \`${f.name}#${h.target}\` (${we(e,f.file)}) not auto-rewritten — ${g.reason}. Move ${h.sync.join(", ")} into a \`pre${h.target}\` script in package.json manually.`);continue}s.warnings.push(`syncGenerators on \`${f.name}#${h.target}\` (${we(e,f.file)}) has no vis equivalent. Move ${h.sync.join(", ")} into a \`pre${h.target}\` script in package.json (or re-run with --rewrite-sync-generators to insert a TODO automatically).`)}}Eb(e,t,n,s),t.aggressive&&Tb(e,o.knownProjects,t,n,s),s.manualSteps.push("vis adds two task primitives nx doesn't expose declaratively: `when: { os, env, branch, ci, not.* }` for conditional execution (replaces ad-hoc `configurations`) and `always: true` for finally/teardown tasks that run even when upstream fails. See docs/guides/conditional-and-finally-tasks.mdx.");const d=i.affected?.defaultBase??i.defaultBase;typeof d=="string"&&d.length>0&&d!=="main"&&n.info(`Translated nx's default base branch (${d}) into vis.config.ts#defaultBase.`),ob(e,{dryRun:t.dryRun},n);const u=Ib(e),p=Ab(u,e,{});if(Pb(p,n),t.force&&!t.dryRun&&u.nxJson){const f=m(e,"nx.json");oe(f,s);try{ht(f),n.info(`Removed ${f} (backup at ${f}.bak).`)}catch{}}},Ld=[".secretlintrc",".secretlintrc.json",".secretlintrc.js",".secretlintrc.mjs",".secretlintrc.cjs",".secretlintrc.yml",".secretlintrc.yaml"],Md=[".secretlintignore"],_d=e=>Ld.find(t=>$(m(e,t))),Fd=e=>Md.find(t=>$(m(e,t))),Bb=(e,t,n)=>{if(t.endsWith(".js")||t.endsWith(".mjs")||t.endsWith(".cjs"))return ee(n,`${t} is a JS config — cannot auto-extract rule IDs. Review manually to confirm coverage.`),[];if(t.endsWith(".yml")||t.endsWith(".yaml"))return ee(n,`${t} is YAML — cannot auto-extract rule IDs without a YAML parser. Review manually.`),[];const s=he(m(e,t));if(!s)return[];const i=new Set,r=o=>{if(o)for(const a of o)a.id&&i.add(a.id),a.rules&&r(a.rules)};return r(s.rules),[...i]},Nb=(e,t,n,s)=>{for(const i of[...Ld,...Md]){const r=m(e,i);if($(r)){if(t){n.info(`[dry-run] Would remove ${r}`);continue}oe(r,s),ht(r),me(s,"secretlint","removedConfigCount"),n.info(`Removed ${r}`)}}},Db=(e,t,n,s)=>{const i=m(e,".secretlintignore");if(!$(i))return;const o=J(i).split(/\r?\n/).map(a=>a.trim()).filter(a=>a&&!a.startsWith("#"));o.length!==0&&(se(s,`.secretlintignore contained ${String(o.length)} path pattern(s). vis secrets uses .gitignore + --exclude / --exclude-from; add these globs to your .gitignore or pass --exclude: ${o.slice(0,5).join(", ")}${o.length>5?", ...":""}`),t&&n.info(`[dry-run] Would consume ${i} (${String(o.length)} patterns) and surface as manual step.`))},Lb=(e,t,n,s,i)=>{const r=m(e,"package.json");if(!$(r))return;const o=he(r);if(!o)return;let a=!1;if(o.scripts){for(const[l,d]of Object.entries(o.scripts))if(typeof d=="string"&&/\bsecretlint\b/.test(d)){const u=d.replaceAll(/\bsecretlint\b[^\n&|;]*/g,"vis secrets").trim();u!==d&&(o.scripts[l]=u,a=!0,me(s,"secretlint","rewrittenScriptCount"),n.info(` scripts.${l}: "${d}" -> "${u}"`))}}if(o.devDependencies){const l=o.devDependencies,d=[];for(const u of Object.keys(l))(u==="secretlint"||u.startsWith("@secretlint/"))&&(delete l[u],d.push(u),a=!0,me(s,"secretlint","removedPackageCount"));d.length>0&&n.info(` removed ${String(d.length)} secretlint devDependencies: ${d.join(", ")}`)}if(!a)return;if(t){n.info(`[dry-run] Would update ${r}`);return}const c=Ye(r,J(r),{defaultIndent:" ",useEditorconfig:i});oe(r,s),ye(r,`${JSON.stringify(o,null,c)}
83
- `)},Mb=(e,t,n,s)=>{const i=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"];for(const r of i){const o=m(e,r);if(!$(o))continue;const a=J(o);if(!/\bsecretlint\b/.test(a))continue;const c=a.replaceAll(/\bsecretlint\b[^\n&|;]*/g,"vis secrets --staged");if(t){n.info(`[dry-run] Would rewrite ${o}`);continue}oe(o,s),ye(o,c),s.gitHooksConfigured=!0,n.info(`Rewrote secretlint invocation in ${r}`)}},qa=(e,t,n,s)=>{const i=_d(e),r=Fd(e);if(!!!(i??r))return t.silent||n.info("No secretlint artifacts found — nothing to migrate."),!1;if(i){const a=Bb(e,i,s);n.info(`Found ${i}`),a.length>0?(n.info(` active rules/presets: ${a.join(", ")}`),se(s,`secretlint used these rules: ${a.join(", ")}. vis secrets ships the gitleaks ruleset (177 rules covering AWS/GCP/Azure/GitHub/Slack/Stripe and more). Verify parity before removing secretlint.`)):se(s,`Rule IDs could not be auto-extracted from ${i}. Verify that the bundled gitleaks ruleset covers your secretlint rule set.`)}return Db(e,t.dryRun,n,s),Lb(e,t.dryRun,n,s,t.useEditorconfig),Mb(e,t.dryRun,n,s),Nb(e,t.dryRun,n,s),!0},Ni="sherif",pi=/\bsherif\b/,xr={"empty-dependencies":"empty-deps","multiple-dependency-versions":"workspace-versions","non-existant-packages":"dead-workspace-patterns","packages-without-package-json":"missing-package-json","root-package-dependencies":"root-deps","root-package-manager-field":"root-package-manager","root-package-private-field":"root-private","types-in-dependencies":"types-in-deps","unordered-dependencies":void 0,"unsync-similar-dependencies":"similar-deps"},_b=Object.values(xr).filter(e=>e!==void 0),Vd=e=>{const t=m(e,"package.json");return $(t)&&he(t)?.sherif?"package.json":void 0},Wd=e=>{const t=m(e,"package.json");if(!$(t))return!1;const n=he(t);if(!n)return!1;if(n.devDependencies?.sherif||n.dependencies?.sherif)return!0;if(n.scripts){for(const s of Object.values(n.scripts))if(typeof s=="string"&&pi.test(s))return!0}return!1},Fb=e=>he(m(e,"package.json"))?.sherif,Hd=(e,t)=>{const n={unmapped:[],visDisabled:[]};if(!Array.isArray(e["ignore-rules"]))return n;for(const s of e["ignore-rules"]){if(typeof s!="string"||s.length===0)continue;const i=xr[s];if(i===void 0){s==="unordered-dependencies"?ee(t,"sherif rule `unordered-dependencies` has no `vis lint` equivalent — vis covers ordering via `vis sort-package-json` (separate command). No migration needed; skip running it if you don't want it."):Object.hasOwn(xr,s)?n.unmapped.push(s):ee(t,`sherif rule \`${s}\` is unknown to vis migrate — skipped.`);continue}n.visDisabled.push(i)}return n},Ud=e=>{const t=_b.filter(n=>!e.includes(n));return t.length===0?"vis lint":`vis lint ${t.map(n=>`--${n}`).join(" ")}`},Vb=(e,t)=>{const n=m(e,"package.json"),s={configRemoved:!1,dependencyRemoved:!1,removedScripts:[],scriptCount:0};if(!$(n))return s;const i=J(n),r=JSON.parse(i);let o=!1;r.sherif&&(delete r.sherif,o=!0,s.configRemoved=!0);for(const c of["dependencies","devDependencies"]){const l=r[c];l?.sherif&&(delete l.sherif,o=!0,s.dependencyRemoved=!0)}const a=r.scripts;if(a){const c={};for(const[l,d]of Object.entries(a))typeof d=="string"&&pi.test(d)?(s.scriptCount+=1,s.removedScripts.push({name:l,value:d}),o=!0):c[l]=d;s.scriptCount>0&&(Object.keys(c).length===0?delete r.scripts:r.scripts=c)}if(o){const c=as(n,i,{useEditorconfig:t});oe(n),ce(n,`${JSON.stringify(r,void 0,c)}
84
- `,"utf8")}return s},Wb=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],Hb=[".github/workflows",".gitlab-ci.yml",".circleci/config.yml",".woodpecker.yml",".drone.yml"],Gd=(e,t)=>{const n=[];for(const s of Wb){const i=m(e,s);$(i)&&pi.test(J(i))&&(n.push(s),se(t,`Update ${s} — replace \`sherif\` invocation with \`vis lint\`.`))}return n},zd=(e,t)=>{const n=[],s=i=>{const r=m(e,i);$(r)&&pi.test(J(r))&&(n.push(i),se(t,`Update ${i} — replace \`sherif\` invocation with \`vis lint\`.`))};for(const i of Hb){const r=m(e,i);if($(r)){if(i===".github/workflows"){try{for(const o of Ee(r))(o.endsWith(".yml")||o.endsWith(".yaml"))&&s(`.github/workflows/${o}`)}catch{}continue}s(i)}}return n},Ub=(e,t,n,s,i)=>{const r=Hd(t,i);if(r.visDisabled.length>0){const p=Ud(r.visDisabled);se(i,`sherif's \`ignore-rules\` was set to [${r.visDisabled.map(f=>JSON.stringify(f)).join(", ")}] (vis names). vis has no global rule-disable; replace any \`sherif\` script with the explicit positive list: \`${p}\`.`)}r.unmapped.length>0&&ee(i,`sherif rule(s) [${r.unmapped.map(p=>JSON.stringify(p)).join(", ")}] could not be mapped — please re-evaluate manually.`),Array.isArray(t["ignore-dependencies"])&&t["ignore-dependencies"].length>0&&se(i,`sherif's \`ignore-dependencies\` was set to [${t["ignore-dependencies"].map(p=>JSON.stringify(p)).join(", ")}]. Mirror this in vis.config.ts under \`policy.workspaceVersions.ignore\`, \`policy.customTypes.ignore\`, \`policy.typesInDeps.ignore\` (and \`policy.redefineRoot.ignore\`) for the lints where it applies.`),Array.isArray(t["ignore-packages"])&&t["ignore-packages"].length>0&&(ee(i,`sherif's \`ignore-packages\` was set to [${t["ignore-packages"].map(p=>JSON.stringify(p)).join(", ")}] — vis has no global package-skip yet (only per-rule scoping via policy.bannedDeps.{packages,paths}). Tracked alongside the dep filter work.`),se(i,"Re-evaluate sherif `ignore-packages` — vis has no equivalent global filter yet.")),Array.isArray(t["ignore-paths"])&&t["ignore-paths"].length>0&&(ee(i,`sherif's \`ignore-paths\` was set to [${t["ignore-paths"].map(p=>JSON.stringify(p)).join(", ")}] — vis has no global path-skip yet.`),se(i,"Re-evaluate sherif `ignore-paths` — vis has no equivalent global filter yet."));const o=Gd(e,i);o.length>0&&!n.silent&&s.warn(`Found sherif reference in ${String(o.length)} hook file(s) — see manualSteps for details.`);const a=zd(e,i);a.length>0&&!n.silent&&s.warn(`Found sherif reference in ${String(a.length)} CI file(s) — see manualSteps for details.`);const{configRemoved:c,dependencyRemoved:l,removedScripts:d,scriptCount:u}=Vb(e,n.useEditorconfig);if(c&&!n.silent&&s.info("Removed `sherif` block from package.json"),c&&me(i,Ni,"removedConfigCount"),l&&me(i,Ni,"removedPackageCount"),u>0){me(i,Ni,"rewrittenScriptCount",u);for(const{name:p,value:f}of d)se(i,`Recreate script \`${p}\` (removed; was \`${f}\`). Replace \`sherif\` with \`vis lint\` (sherif's lint surface ≈ \`vis lint\`).`);n.silent||s.info(`Removed ${String(u)} script(s) referencing \`sherif\`. Replace with \`vis lint\`.`)}},Ka=(e,t,n,s)=>{const i=Vd(e),r=Wd(e);if(!i&&!r)return t.silent||n.info("No sherif configuration or installation found — nothing to migrate."),!1;const o=Fb(e)??{};if(t.dryRun){const a=Hd(o,s);if(Gd(e,s),zd(e,s),!t.silent&&(i&&n.info("[dry-run] Would remove `sherif` block from package.json"),r&&n.info("[dry-run] Would strip `sherif` from devDependencies/scripts"),a.visDisabled.length>0)){const c=Ud(a.visDisabled);n.info(`[dry-run] Suggested replacement script: ${c}`)}return!0}return Ub(e,o,t,n,s),!0},Gb=["dependencies","devDependencies","peerDependencies","optionalDependencies","overrides","resolutions","pnpm.overrides"],zb=(e,t)=>{const n=t.split(".");let s=e;for(const i of n){if(typeof s!="object"||s===null)return;s=s[i]}return typeof s=="object"&&s!==null?s:void 0},mo=e=>{const t=m(e,"package.json");if(!$(t))return["."];const s=de(t).workspaces;let i=[];if(s){const r=Array.isArray(s)?s:s.packages;r&&(i=Yo(e,r))}if(i.length===0){const r=Gf(e);r&&(i=Yo(e,r))}return[".",...i]},fi=e=>{if($(e))try{return de(e)}catch{return}},Jb=e=>{const t=new Set,n=mo(e);for(const s of n){const i=fi(m(e,s,"package.json"));i&&typeof i.name=="string"&&t.add(i.name)}return t},f4=(e,t={})=>{const n=t.includeInternal??!0,s=t.depTypes??Gb,i=mo(e),r=Jb(e),o=[],c=s.includes("pnpm.overrides")?Uf(e):void 0,l=c?m(e,"pnpm-workspace.yaml"):void 0;for(const d of i){const u=m(e,d,"package.json"),p=fi(u);if(!p)continue;const f=typeof p.name=="string"?p.name:void 0,h=d==="."?".":rs(e,m(e,d));for(const g of s){const y=g.includes(".")?zb(p,g):p[g];if(!(!y||typeof y!="object"))for(const[x,b]of Object.entries(y)){if(typeof b!="string")continue;const S=r.has(x);!n&&S||o.push({depName:x,depType:g,isInternal:S,packageDir:h,packageJsonPath:u,packageName:f,specifier:b})}}}if(c&&l)for(const[d,u]of Object.entries(c)){const p=r.has(d);!n&&p||o.push({depName:d,depType:"pnpm.overrides",isInternal:p,packageDir:".",packageJsonPath:l,packageName:void 0,specifier:u})}return o},yo=new Set(["devEngines.packageManager","devEngines.runtime","engines","packageManager","volta"]),qb=["engines","volta"],Kb=new Set(["extends"]),Yb=/^([@\w./-]+?)@([^+]+)(\+.+)?$/,Xb=/^([@\w./-]+)~(.+)$/,hi=e=>{const t=Yb.exec(e.trim());if(!(!t?.[1]||!t[2]))return{hash:t[3]??"",name:t[1],version:t[2]}},Jd=e=>{const t=Xb.exec(e.trim());if(!(!t?.[1]||!t[2]))return{name:t[1],version:t[2]}},Zn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),qd=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.name=="string",Zb=new Set(["name@version","name~version","string","versionsByName"]),h4=e=>{const t=[];if(!e)return t;const n=new Set;for(const s of e){const i=typeof s?.name=="string"&&s.name.length>0?s.name:"<unnamed>";if(typeof s?.name!="string"||s.name.length===0){t.push("extraTypes entry missing 'name'");continue}yo.has(s.name)&&t.push(`extraTypes[${i}]: name collides with a built-in customType`),n.has(s.name)&&t.push(`extraTypes[${i}]: duplicate name`),n.add(s.name),(typeof s.path!="string"||s.path.length===0)&&t.push(`extraTypes[${i}]: missing 'path'`),Zb.has(s.strategy)||t.push(`extraTypes[${i}]: invalid strategy "${String(s.strategy)}" (expected name@version | name~version | string | versionsByName)`),s.strategy==="string"&&(typeof s.depName!="string"||s.depName.length===0)&&t.push(`extraTypes[${i}]: strategy 'string' requires 'depName'`)}return t},Qb=(e,t)=>{if(t.length===0)return;let n=e;for(const s of t.split(".")){if(typeof n!="object"||n===null||Array.isArray(n))return;n=n[s]}return n},e0=(e,t,n,s,i)=>{const r=Qb(t,e.path);if(r===void 0)return[];const o=Object.freeze({depName:e.depName,path:e.path,strategy:e.strategy});if(e.strategy==="versionsByName"){if(!Zn(r))return[];const a=[];for(const[c,l]of Object.entries(r))typeof l=="string"&&a.push({customType:e.name,depName:c,extra:o,packageDir:n,packageJsonPath:s,packageName:i,rawValue:l,specifier:l});return a}if(e.strategy==="name@version"){if(typeof r!="string")return[];const a=hi(r);return a?[{customType:e.name,depName:a.name,extra:o,packageDir:n,packageJsonPath:s,packageName:i,rawValue:r,specifier:a.version}]:[]}if(e.strategy==="name~version"){if(typeof r!="string")return[];const a=Jd(r);return a?[{customType:e.name,depName:a.name,extra:o,packageDir:n,packageJsonPath:s,packageName:i,rawValue:r,specifier:a.version}]:[]}return typeof r!="string"||typeof e.depName!="string"||e.depName.length===0?[]:[{customType:e.name,depName:e.depName,extra:o,packageDir:n,packageJsonPath:s,packageName:i,rawValue:r,specifier:r}]},g4=(e,t)=>{const n=mo(e),s=[];for(const i of n){const r=m(e,i,"package.json"),o=fi(r);if(!o)continue;const a=typeof o.name=="string"?o.name:void 0,c=i==="."?".":rs(e,m(e,i));for(const d of qb){const u=o[d];if(Zn(u))for(const[p,f]of Object.entries(u))typeof f=="string"&&(d==="volta"&&Kb.has(p)||s.push({customType:d,depName:p,packageDir:c,packageJsonPath:r,packageName:a,rawValue:f,specifier:f}))}if(typeof o.packageManager=="string"){const d=hi(o.packageManager);d&&s.push({customType:"packageManager",depName:d.name,packageDir:c,packageJsonPath:r,packageName:a,rawValue:o.packageManager,specifier:d.version})}const{devEngines:l}=o;if(typeof l=="object"&&l!==null&&!Array.isArray(l))for(const d of["runtime","packageManager"]){const u=l[d];if(u===void 0)continue;const p=Array.isArray(u)?u:[u];for(const f of p)!qd(f)||typeof f.version!="string"||s.push({customType:d==="runtime"?"devEngines.runtime":"devEngines.packageManager",depName:f.name,packageDir:c,packageJsonPath:r,packageName:a,rawValue:f.version,specifier:f.version})}if(t){for(const d of t)if(!(typeof d?.name!="string"||d.name.length===0)&&!yo.has(d.name))for(const u of e0(d,o,c,r,a))s.push(u)}}return s},t0=(e,t)=>`${e} ${t}`,n0=(e,t)=>{const n=[...e].sort((i,r)=>(i.packageName??i.packageDir).localeCompare(r.packageName??r.packageDir));let s;for(const i of n){const r=ar(i.specifier);if(!r)continue;if(!s){s=i;continue}const o=ar(s.specifier);if(!o){s=i;continue}const a=Xo(o,r),c=Xo(r,o);(t==="highest"&&a||t==="lowest"&&c)&&(s=i)}return s},m4=(e,t={})=>{const n=new Set(t.ignoreDeps),s=t.resolve??"highest",i=[],r=e.filter(a=>t.dep!==void 0&&a.depName!==t.dep?!1:!n.has(a.depName)),o=new Map;for(const a of r){const c=t0(a.customType,a.depName),l=o.get(c);l?l.push(a):o.set(c,[a])}for(const[,a]of o){if(a.length<2||new Set(a.map(d=>d.specifier)).size<=1)continue;const l=n0(a,s);if(l)for(const d of a)d.specifier!==l.specifier&&ar(d.specifier)!==void 0&&i.push({canonicalSource:l.packageName??l.packageDir,customType:d.customType,depName:d.depName,...d.extra?{extra:d.extra}:{},fix:l.specifier,packageDir:d.packageDir,packageJsonPath:d.packageJsonPath,packageName:d.packageName,specifier:d.specifier})}return i},s0=(e,t)=>{const n=t.extra;if(!n)return!1;const s=n.path.split(".");if(s.length===0||s.some(o=>o.length===0))return!1;let i=e;for(let o=0;o<s.length-1;o+=1){const a=i[s[o]];if(typeof a!="object"||a===null||Array.isArray(a))return!1;i=a}const r=s.at(-1);if(n.strategy==="versionsByName"){const o=i[r];return Zn(o)?(o[t.depName]=t.fix,!0):!1}if(n.strategy==="name@version"){const o=i[r];if(typeof o!="string")return!1;const a=hi(o);return a?(i[r]=`${a.name}@${t.fix}`,!0):!1}if(n.strategy==="name~version"){const o=i[r];if(typeof o!="string")return!1;const a=Jd(o);return a?(i[r]=`${a.name}~${t.fix}`,!0):!1}return typeof i[r]!="string"?!1:(i[r]=t.fix,!0)},y4=(e,t={})=>{const{useEditorconfig:n}=t,s=new Map;for(const r of e){const o=s.get(r.packageJsonPath);o?o.push(r):s.set(r.packageJsonPath,[r])}const i=[];for(const[r,o]of s){const a=fi(r);if(!a)continue;let c=!1;for(const l of o){if(l.extra){s0(a,l)&&(c=!0);continue}if(l.customType==="engines"||l.customType==="volta"){const h=a[l.customType];Zn(h)&&(h[l.depName]=l.fix,c=!0);continue}if(l.customType==="packageManager"){const h=a.packageManager;if(typeof h=="string"){const g=hi(h);g&&(a.packageManager=`${g.name}@${l.fix}`,c=!0)}continue}const d=l.customType==="devEngines.runtime"?"runtime":"packageManager",{devEngines:u}=a;if(!Zn(u))continue;const p=u[d];if(p===void 0)continue;const f=Array.isArray(p)?p:[p];for(const h of f)qd(h)&&h.name===l.depName&&(h.version=l.fix,c=!0)}c&&(oh(r,a,{indent:zf(r,{useEditorconfig:n}),overwrite:!0}),i.push(r))}return i},$r="syncpack",Kd=[".syncpackrc",".syncpackrc.json"],vo=[".syncpackrc.yaml",".syncpackrc.yml"],bo=[".syncpackrc.cjs",".syncpackrc.js",".syncpackrc.mjs",".syncpackrc.ts","syncpack.config.cjs","syncpack.config.js","syncpack.config.mjs","syncpack.config.ts"],i0=[...Kd,...vo,...bo],r0=/\bextraTypes\s*:/,o0=/\bpolicy\s*:/,Ya=/(defineConfig\(\{)/,Xa=/(export\s+default\s+\{)/,wo=/\bsyncpack\b/,Yd=e=>{const t=m(e,"package.json");if($(t)&&he(t)?.syncpack)return"package.json";for(const n of i0)if($(m(e,n)))return n},a0=e=>{for(const n of bo)if($(m(e,n)))return n;const t=m(e,".syncpackrc");if($(t)&&!yn(t))try{It(t);return}catch{return".syncpackrc"}},c0=e=>{const t=Mt(e);return t?r0.test(J(t)):!1},l0=e=>he(m(e,"package.json"))?.syncpack,d0=e=>he(e),Za=e=>{try{return It(e)}catch{return}},u0=(e,t,n)=>{if(t==="package.json")return l0(e);if(bo.includes(t)){ee(n,`${t} is a TS/JS config and cannot be auto-migrated — vis migrate does not load executable config. Convert to .syncpackrc.json and re-run, or translate directly into vis.config.ts. Tracked in https://github.com/visulima/visulima/issues/622.`),se(n,`Translate ${t} into vis.config.ts (policy.* and security.*) — see https://github.com/visulima/visulima/issues/622`);return}const s=m(e,t);if(vo.includes(t))return Za(s);if(t===".syncpackrc"&&!yn(s)){const i=Za(s);if(i)return i;ee(n,".syncpackrc is neither valid JSON nor YAML — please migrate manually.");return}return d0(s)},Xd=(e,t)=>{const n=[];if(!e.customTypes)return n;for(const[s,i]of Object.entries(e.customTypes)){if(!i||typeof i!="object")continue;const{strategy:r}=i,{path:o}=i;if(typeof o!="string"||o.length===0){ee(t,`customType "${s}" has no \`path\` — skipped.`);continue}if(r!=="name@version"&&r!=="string"&&r!=="versionsByName"){ee(t,`customType "${s}" has unsupported strategy ${JSON.stringify(r)} — skipped.`);continue}if(yo.has(s)){ee(t,`customType "${s}" collides with a vis built-in and was dropped — vis already lints this surface.`);continue}const a={name:s,path:o,strategy:r};if(r==="string"){const{depName:c}=i;typeof c=="string"&&c.length>0?a.depName=c:(ee(t,`customType "${s}" uses strategy "string" but has no \`depName\` — vis requires it. Add it manually after migration.`),se(t,`Set policy.customTypes.extraTypes[name="${s}"].depName before running vis lint`))}n.push(a)}return n},Zd=e=>e.isBanned===!0,Qd=(e,t)=>{if(Array.isArray(e.versionGroups)&&e.versionGroups.length>0){const n=e.versionGroups.filter(s=>s&&typeof s=="object"&&!Zd(s));n.length>0&&(ee(t,`${String(n.length)} versionGroups rule(s) cannot be migrated — \`pinVersion\`, \`snapTo\`, and \`policy: "sameRange"\` (and other versionGroups DSL surfaces) are tracked in https://github.com/visulima/visulima/issues/622.`),se(t,'Re-implement versionGroups rules using `pinVersion` / `snapTo` / `policy: "sameRange"` once the vis DSL ships (issue #622).'))}Array.isArray(e.semverGroups)&&e.semverGroups.length>0&&(ee(t,`${String(e.semverGroups.length)} semverGroups rule(s) cannot be migrated — semverGroups DSL is tracked in https://github.com/visulima/visulima/issues/622.`),se(t,"Re-implement semverGroups rules manually once the vis DSL ships (issue #622)")),Array.isArray(e.dependencyTypes)&&e.dependencyTypes.length>0&&se(t,"Review syncpack `dependencyTypes` — vis applies policies to dependencies/devDependencies/peerDependencies/optionalDependencies/overrides by default. Narrow via policy.* filters if needed."),Array.isArray(e.specifierTypes)&&e.specifierTypes.length>0&&se(t,"Review syncpack `specifierTypes` — vis has no direct equivalent today; specifier filtering belongs in versionGroups (issue #622)."),typeof e.filter=="string"&&e.filter.length>0&&se(t,`Re-implement syncpack \`filter\` regex (${e.filter}) once vis exposes a top-level dep filter.`),(Array.isArray(e.sortAz)&&e.sortAz.length>0||Array.isArray(e.sortFirst)&&e.sortFirst.length>0||Array.isArray(e.sortExports)&&e.sortExports.length>0)&&ee(t,"syncpack sort options (sortAz / sortFirst / sortExports) are superseded by `vis sort-package-json` — no migration needed."),(e.sortPackages!==void 0||e.formatBugs!==void 0||e.formatRepository!==void 0)&&ee(t,"syncpack package.json shape options (sortPackages / formatBugs / formatRepository) are superseded by `vis sort-package-json` — no migration needed."),(e.lintFormatting!==void 0||e.lintSemverRanges!==void 0||e.lintVersions!==void 0)&&ee(t,"syncpack lint toggles (lintFormatting / lintSemverRanges / lintVersions) are covered by `vis lint` by default — no migration needed."),Array.isArray(e.source)&&e.source.length>0&&se(t,`syncpack \`source\` was set to [${e.source.map(n=>JSON.stringify(n)).join(", ")}]. vis derives workspace globs from pnpm-workspace.yaml / package.json#workspaces — verify they match before relying on \`vis lint\`.`),typeof e.indent=="string"&&e.indent.length>0&&ee(t,"syncpack `indent` is implicit in vis — JSON writers honor `.editorconfig` (and the source file's existing indentation). No migration needed.")},eu=(e,t)=>{const n={};if(!Array.isArray(e.versionGroups))return n;for(const s of e.versionGroups){if(!s||typeof s!="object")continue;const i=s;if(!Zd(i))continue;const r=Array.isArray(i.dependencies)?i.dependencies.filter(l=>typeof l=="string"&&l.length>0):[];if(r.length===0){ee(t,"versionGroup with `isBanned: true` has no `dependencies` entries — skipped.");continue}const o=Array.isArray(i.packages)?i.packages.filter(l=>typeof l=="string"&&l.length>0):[],a=i.label,c=typeof a=="string"&&a.length>0?a:"banned via syncpack versionGroups";for(const l of r){if(n[l]!==void 0){ee(t,`Multiple banned versionGroups target "${l}" — kept the first match; merge manually if needed.`);continue}n[l]=o.length>0?{packages:o,reason:c}:c}}return n},p0=e=>{const t=[`name: ${JSON.stringify(e.name)}`,`path: ${JSON.stringify(e.path)}`,`strategy: ${JSON.stringify(e.strategy)}`];return e.depName!==void 0&&t.push(`depName: ${JSON.stringify(e.depName)}`),` { ${t.join(", ")} }`},f0=(e,t)=>{if(typeof t=="string")return` ${JSON.stringify(e)}: ${JSON.stringify(t)}`;const n=[`reason: ${JSON.stringify(t.reason)}`];return t.packages&&t.packages.length>0&&n.push(`packages: [${t.packages.map(s=>JSON.stringify(s)).join(", ")}]`),t.paths&&t.paths.length>0&&n.push(`paths: [${t.paths.map(s=>JSON.stringify(s)).join(", ")}]`),t.replacement!==void 0&&n.push(`replacement: ${JSON.stringify(t.replacement)}`),` ${JSON.stringify(e)}: { ${n.join(", ")} }`},Er=(e,t={})=>{const n=[],s=Object.entries(t);if(s.length>0){const i=s.map(([r,o])=>f0(r,o)).join(`,
81
+ `,a=r.split(/\r?\n/),c=Md.filter(d=>!_d(a,d));if(c.length===0)return{added:[],changed:!1};const l=[...a];for(;l.length>0&&l[l.length-1].trim()==="";)l.pop();return l.length>0&&l.push(""),l.push("# vis run state (.vis/templates and .vis/hooks are tracked — do not ignore .vis/ wholesale)",...c),ye(s,`${l.join(o)}${o}`),{added:[...c],changed:!0}},db=(e,t,n)=>{if(t.dryRun){const i=m(e,".gitignore"),r=$(i)?J(i).split(/\r?\n/):[],o=Md.filter(a=>!_d(r,a));o.length>0&&n.info(`Would add to .gitignore: ${o.join(", ")}.`);return}const s=lb(e,{create:!1});s.added.length>0&&n.info(`Added to .gitignore: ${s.added.join(", ")}.`)},ke=(e,t)=>{const n=as(e,t);return n.startsWith("..")?t:n.split(Nf).join("/")},ub=new Set([".cache",".git",".next",".nx",".output",".svelte-kit",".turbo",".vercel",".vis","build","coverage","dist","node_modules"]),pb=(e,t=8)=>{const n=[],s=(i,r)=>{if(r>t)return;let o;try{o=we(i)}catch{return}for(const a of o){if(ub.has(a)||a.startsWith("."))continue;const c=m(i,a);let l;try{l=Bt(c)}catch{continue}l.isDirectory()?s(c,r+1):a==="project.json"&&n.push(c)}};return s(e,0),n},fb={"@nx/eslint:lint":"lint:eslint","@nx/jest:jest":"test","@nx/js:tsc":"build","@nx/next:build":"build","@nx/playwright:playwright":"test:e2e","@nx/storybook:build":"build-storybook","@nx/vite:build":"build","@nx/vite:test":"test","@nx/webpack:webpack":"build"},hb=["cache","dependsOn","inputs","outputs","persistent"],gb=(e,t,n)=>{const s={};for(const[i,r]of Object.entries(e))i.includes(":")||(s[i]=r);for(const[i,r]of Object.entries(e)){if(!i.includes(":"))continue;const o=fb[i];if(!o){t.warnings.push(`Dropped \`${i}\` from tasks — vis only supports script-name targets, not nx-namespaced executors.`);continue}if(s[o]){t.warnings.push(`Dropped \`${i}\` from tasks — \`${o}\` already has an explicit entry; the explicit one was kept.`);continue}const a={},c=[];for(const d of hb)r[d]!==void 0&&(a[d]=r[d],c.push(d));s[o]=a;const l=c.length>0?`carried ${c.join(", ")}`:"no settings to carry";n?.info(`Translated \`${i}\` → \`${o}\` in tasks (${l}).`)}return s},mb=(e,t,n)=>{const s={},i=e.affected?.defaultBase??e.defaultBase;return typeof i=="string"&&i.length>0&&i!=="main"&&(s.defaultBase=i),e.namedInputs&&Object.keys(e.namedInputs).length>0&&(s.namedInputs=e.namedInputs),e.targetDefaults&&Object.keys(e.targetDefaults).length>0&&(s.tasks=e.targetDefaults),["// Migrated from nx.json by `vis migrate nx`.","// Per-project project.json files are compatible with vis and do not need to be rewritten —","// vis already reads targets, tags, implicitDependencies, and sourceRoot.","",'import { defineConfig } from "@visulima/vis/config";',"",`export default defineConfig(${ho(s,m(t,"vis.config.ts"),n)});`,""].join(`
82
+ `)},Pi=/node_modules\/nx\/schemas\/project-schema\.json$/u,yb=(e,t,n,s)=>{let i=0;for(const r of e){if(t.dryRun){const a=mo(r);a?.$schema&&Pi.test(a.$schema)&&(n.info(`Would rewrite $schema in ${r}`),i+=1);continue}Pt(r,a=>{if(!(!a.$schema||!Pi.test(a.$schema)))return a.$schema=a.$schema.replace(Pi,"node_modules/@visulima/vis/schemas/project.schema.json"),a},s,{useEditorconfig:t.useEditorconfig})&&(i+=1)}return i>0&&n.info(`Rewrote $schema in ${String(i)} project.json file(s).`),i},mo=e=>{if($(e))try{return JSON.parse(J(e))}catch{return}},vb=e=>{const t=new Map,n=new Set;for(const s of e){const i=mo(s);if(!i?.name)continue;n.add(i.name);const r=m(it(s),"package.json");if($(r))try{const o=JSON.parse(J(r));o.name&&o.name!==i.name&&t.set(o.name,i.name)}catch{}}return{knownProjects:n,pkgToProject:t}},bb=/&&|\|\||[;|><`]|\$\(/u,wb=/[*[\]^.]/u,Ni=(e,t)=>{if(t===""){e.complex=!0;return}if(t.startsWith("!")){e.hasExclusion=!0;return}if(wb.test(t)||t.includes("...")){e.hasGlob=!0;return}e.filters.push(t)},kb=e=>{if(typeof e!="string"||e.trim()===""||bb.test(e)||/['"]/u.test(e))return null;const t=e.trim().split(/\s+/u);if(t[0]!=="pnpm"&&t[0]!=="pnpm.cmd")return null;const n={complex:!1,filters:[],hasExclusion:!1,hasGlob:!1,parallel:!1,recursive:!1,target:""};let s=1;for(;s<t.length;){const i=t[s];if(i==="--filter"||i==="-F"){const r=t[s+1];if(r===void 0)return n.complex=!0,n;Ni(n,r),s+=2;continue}if(i.startsWith("--filter=")){Ni(n,i.slice(9)),s+=1;continue}if(i.startsWith("-F=")){Ni(n,i.slice(3)),s+=1;continue}if(i==="--parallel"){n.parallel=!0,s+=1;continue}if(i==="-r"||i==="--recursive"){n.recursive=!0,s+=1;continue}if(i==="--workspace-root"||i==="-w")return n.complex=!0,n;if(i==="run"||i==="exec"){if(i==="exec")return n.complex=!0,n;s+=1;continue}return i.startsWith("-")?(n.complex=!0,n):(n.target=i,s+=1,s<t.length&&(n.complex=!0),n)}return n.complex=!0,n},Sb=(e,t)=>{const n=[],s=[];for(const i of e){const r=t.pkgToProject.get(i);if(r!==void 0){n.push(r);continue}if(t.knownProjects.has(i)){n.push(i);continue}s.push(i)}return{mapped:n,unmapped:s}},xb=(e,t)=>{const n=["vis","run",e.target];if(t.length>0){const s=[...t].sort((i,r)=>i.localeCompare(r)).join(",");n.push(`--projects=${s}`)}return n.join(" ")},$b=new Set(["dev","dev:server","dev:watch","serve","start:dev","storybook","watch"]),Eb=(e,t,n,s,i)=>{const r={rewrittenTargets:new Set,unmappedHits:[]},o=m(e,"package.json");if(!$(o))return r;let a;try{a=JSON.parse(J(o))}catch{return r}if(!a.scripts)return r;const c=new Map;for(const[l,d]of Object.entries(a.scripts)){const u=kb(d);if(!u||u.target===""||u.complex)continue;if(u.hasExclusion||u.hasGlob){i.warnings.push(`pnpm filter in scripts.${l} uses ${u.hasExclusion?"an exclusion (!)":"a glob/dependency selector"} — left untouched. Translate by hand to \`vis run ${u.target} --projects=...\` once you decide which projects should be selected.`);continue}if(u.filters.length===0&&!u.recursive)continue;const p=Sb(u.filters,t);if(p.unmapped.length>0){r.unmappedHits.push({filters:p.unmapped,script:l});continue}const f=xb(u,p.mapped);f!==d&&(c.set(l,f),r.rewrittenTargets.add(u.target))}if(c.size===0)return r;if(n.dryRun){for(const[l,d]of c){const u=a.scripts[l];s.info(`Would rewrite scripts.${l}: \`${u??""}\` → \`${d}\``)}return r}return Pt(o,l=>{if(!l.scripts)return;const d={...l.scripts};let u=!1;for(const[p,f]of c)d[p]!==void 0&&d[p]!==f&&(d[p]=f,u=!0);if(u)return l.scripts=d,l},i,{useEditorconfig:n.useEditorconfig}),s.info(`Rewrote ${String(c.size)} pnpm-filter script(s) in package.json to use \`vis run\`.`),r},Cb=(e,t,n)=>{let s=e.targetDefaults??{},i=!1;for(const r of t){if(!$b.has(r))continue;const a={...s[r]??{}};let c=!1;a.persistent!==!0&&(a.persistent=!0,c=!0),a.cache!==!1&&(a.cache=!1,c=!0),c&&(s={...s,[r]:a},i=!0,n.manualSteps.push(`tasks.${r} set to { persistent: true, cache: false } — long-running task auto-detected from rewritten pnpm filter scripts. Adjust if your ${r} is actually short-lived.`))}i&&(e.targetDefaults=s)},Rb=e=>{if(e.executor!=="nx:run-script")return!1;const t=Object.keys(e.options??{});return t.length===0||t.length===1&&t[0]==="script"},Ob=(e,t,n,s)=>{let i=0,r=0,o=0;const a=[];for(const c of e){const l=mo(c);if(!l?.targets||Object.keys(l.targets).length===0)continue;const d=l.name??"<unnamed>",u=[],p=[],f=[];for(const[y,x]of Object.entries(l.targets))x.syncGenerators&&x.syncGenerators.length>0&&f.push({sync:[...x.syncGenerators],target:y}),Rb(x)?p.push(y):u.push(y);const h=u.length===0&&p.length>0,g=p.length>0;h?(t.dryRun?(n.info(`Would remove targets block from ${c} (all entries are nx:run-script shims).`),i+=1):(Pt(c,y=>{if(y.targets)return delete y.targets,y},s,{useEditorconfig:t.useEditorconfig}),i+=1),f.length>0&&a.push({file:c,name:d,nonShimTargets:[],syncGenerators:f})):g?(t.dryRun?n.info(`Would strip ${String(p.length)} nx:run-script shim entr(y/ies) from ${c} (non-shim entries kept: ${u.join(", ")}).`):Pt(c,y=>{if(y.targets){for(const x of p)Reflect.deleteProperty(y.targets,x);return y}},s,{useEditorconfig:t.useEditorconfig}),r+=1,o+=p.length,a.push({file:c,name:d,nonShimTargets:u,syncGenerators:f})):a.push({file:c,name:d,nonShimTargets:u,syncGenerators:f})}return i>0&&n.info(`Removed targets block from ${String(i)} project.json file(s) (entries were nx:run-script shims).`),o>0&&!t.dryRun&&n.info(`Stripped ${String(o)} nx:run-script shim entr(y/ies) across ${String(r)} project.json file(s) (non-shim entries remain for manual review).`),{droppedTargetBlocks:i,partialTargetBlocks:r,punchList:a,strippedShimEntries:o}},jb=(e,t,n,s)=>{const i=m(e,"pnpm-workspace.yaml");if(!$(i))return{catalogEntriesRemoved:0,onlyBuiltRemoved:!1};let r;try{r=At(i)}catch{return{catalogEntriesRemoved:0,onlyBuiltRemoved:!1}}if(!r||typeof r!="object")return{catalogEntriesRemoved:0,onlyBuiltRemoved:!1};let o=0;const a=f=>f==="nx"||f.startsWith("@nx/"),c=(f,h,g)=>{if(!f||typeof f!="object")return;const y=Object.keys(f).length,x=Object.fromEntries(Object.entries(f).filter(([S])=>!a(S))),b=y-Object.keys(x).length;b>0&&(o+=b,h[g]=x)};c(r.catalog,r,"catalog");const l=r.catalogs;if(l&&typeof l=="object")for(const[f,h]of Object.entries(l))c(h,l,f);let d=!1;const u=r.onlyBuiltDependencies;if(Array.isArray(u)){const f=u.filter(h=>h!=="nx");f.length!==u.length&&(r.onlyBuiltDependencies=f,d=!0)}return(o>0||d)&&(t.dryRun?(o>0&&n.info(`Would remove ${String(o)} nx-related catalog entr(y/ies) from pnpm-workspace.yaml.`),d&&n.info("Would remove `nx` from pnpm-workspace.yaml#onlyBuiltDependencies.")):(oe(i,s),Il(i,r),o>0&&n.info(`Removed ${String(o)} nx-related catalog entr(y/ies) from pnpm-workspace.yaml.`),d&&n.info("Removed `nx` from pnpm-workspace.yaml#onlyBuiltDependencies."))),{catalogEntriesRemoved:o,onlyBuiltRemoved:d}},Tb=(e,t,n,s,i,r,o)=>{const a=m(it(e),"package.json");if(!$(a))return{reason:"no sibling package.json"};const c=`pre${n}`,l=`echo "TODO(vis): replace with logic equivalent to nx syncGenerators: ${s.join(", ")}" && exit 1`;if(i.dryRun){let p;try{p=JSON.parse(J(a)).scripts}catch{return{reason:"package.json unreadable"}}return p?.[c]?{reason:`\`${c}\` script already exists in ${ke(t,a)}`}:(r.info(`Would add \`${c}\` script to ${ke(t,a)} (TODO for nx syncGenerators: ${s.join(", ")}).`),{pkgPath:ke(t,a),preScript:c})}let d;return Pt(a,p=>{if(p.scripts?.[c]){d=`\`${c}\` script already exists in ${ke(t,a)}`;return}return p.scripts={...p.scripts,[c]:l},p},o,{useEditorconfig:i.useEditorconfig})?(r.info(`Added \`${c}\` script (TODO) to ${ke(t,a)} — wire up replacement for: ${s.join(", ")}.`),{pkgPath:ke(t,a),preScript:c}):{reason:d??"package.json unwritable"}},Ib=/^nx\s+(?:run-many|run|affected|reset|repair)\b|^nx\s+exec\b/u,Ab=new Set(["affected","exec","repair","reset","run","run-many"]),Bb=(e,t)=>{const n=e.trim();if(/[;&|"']/u.test(n))return;const s=/^nx\s+run-many\s+(?:-t|--target=?)\s*([\w:-]+)\s*$/u.exec(n);if(s)return`vis run ${s[1]}`;const i=/^nx\s+affected\s+(?:-t|--target=?)\s*([\w:-]+)\s*$/u.exec(n);if(i)return`vis run ${i[1]} --affected`;const r=/^nx\s+run\s+([\w@/-]+):([\w:-]+)\s*$/u.exec(n);if(r?.[1]&&r[2]&&t.has(r[1]))return`vis run ${r[2]} --projects=${r[1]}`;const o=/^nx\s+([\w:-]+)\s*$/u.exec(n);if(o?.[1]&&!Ab.has(o[1]))return`vis run ${o[1]}`},Pb=(e,t,n,s,i)=>{const r={deletedFiles:[],rewrittenScripts:[],skippedScripts:[],strippedDevDeps:[]},o=m(e,".github","ignore-files-for-nx-affected.yml");if($(o))if(n.dryRun)s.info(`Would delete ${ke(e,o)}.`),r.deletedFiles.push(ke(e,o));else{oe(o,i);try{gt(o),s.info(`Removed ${ke(e,o)} (backup at \`${ke(e,o)}.bak\`).`),r.deletedFiles.push(ke(e,o))}catch{}}const a=m(e,"package.json");if(!$(a))return r;if(Pt(a,c=>{let l=!1;if(c.devDependencies)for(const d of Object.keys(c.devDependencies))(d==="nx"||d.startsWith("@nx/")||d.startsWith("@nrwl/"))&&(n.dryRun||Reflect.deleteProperty(c.devDependencies,d),r.strippedDevDeps.push(d),l=!0);if(c.scripts)for(const[d,u]of Object.entries(c.scripts)){if(typeof u!="string"||!(Ib.test(u)||u.startsWith("nx ")))continue;const f=Bb(u,t);if(f===void 0){r.skippedScripts.push(d);continue}n.dryRun||(c.scripts[d]=f),r.rewrittenScripts.push({from:u,name:d,to:f}),l=!0}return l?c:void 0},n.dryRun?void 0:i,{useEditorconfig:n.useEditorconfig}),r.strippedDevDeps.length>0){const c=n.dryRun?"Would strip":"Stripped";s.info(`${c} ${String(r.strippedDevDeps.length)} nx-related devDependenc(y/ies) from package.json: ${r.strippedDevDeps.join(", ")}.`)}for(const c of r.rewrittenScripts){const l=n.dryRun?"Would rewrite":"Rewrote";s.info(`${l} \`scripts.${c.name}\`: \`${c.from}\` -> \`${c.to}\``)}return r.skippedScripts.length>0&&i.manualSteps.push(`--aggressive could not rewrite these package.json scripts (they have shell complexity or unknown flags): ${r.skippedScripts.join(", ")}. Rewrite them manually to use \`vis run\`.`),r},Nb=e=>{const t={eslintHits:[],ignoreFile:!1,nxJson:!1,pkgDevDeps:[],pkgScripts:[],workflowHits:[]};$(m(e,"nx.json"))&&(t.nxJson=!0),$(m(e,".github/ignore-files-for-nx-affected.yml"))&&(t.ignoreFile=!0);const n=m(e,"package.json");if($(n))try{const i=JSON.parse(J(n));if(i.devDependencies)for(const r of Object.keys(i.devDependencies))(r==="nx"||r.startsWith("@nx/")||r.startsWith("@nrwl/"))&&t.pkgDevDeps.push(r);if(i.scripts)for(const[r,o]of Object.entries(i.scripts))typeof o=="string"&&(/\bnx\s+(?:run-many|run|affected|exec|reset|repair)\b/u.test(o)||o.startsWith("nx "))&&t.pkgScripts.push(r)}catch{}const s=m(e,".github/workflows");if($(s))try{for(const i of we(s)){if(!i.endsWith(".yml")&&!i.endsWith(".yaml"))continue;const r=m(s,i),o=J(r);/nrwl\/nx-set-shas/u.test(o)&&t.workflowHits.push({file:`.github/workflows/${i}`,reason:"uses nrwl/nx-set-shas action"}),/\bNX_BRANCH\b|\bNX_RUN_GROUP\b/u.test(o)&&t.workflowHits.push({file:`.github/workflows/${i}`,reason:"sets NX_BRANCH / NX_RUN_GROUP env"}),(/--files=\$\{\{[^}]*tj-actions/u.test(o)||/tj-actions\/changed-files/u.test(o))&&t.workflowHits.push({file:`.github/workflows/${i}`,reason:"uses tj-actions/changed-files (no longer needed; vis does its own affected diff)"})}}catch{}for(const i of["eslint.config.mjs","eslint.config.js","eslint.config.cjs","eslint.config.ts",".eslintrc.json",".eslintrc.js"]){const r=m(e,i);if(!$(r))continue;const o=J(r);/@nx\/eslint-plugin|@nx\/enforce-module-boundaries|@nx\/dependency-checks|@nx\/nx-plugin-checks/u.test(o)&&t.eslintHits.push(i)}return t},Db=(e,t,n)=>{const s=[];if(e.nxJson&&!n.backedUpNxJson&&s.push(`Remove ${m(t,"nx.json")} once you're satisfied with vis.config.ts.`),e.ignoreFile&&s.push("Delete .github/ignore-files-for-nx-affected.yml — vis uses git-based affected diff and has no equivalent."),e.pkgDevDeps.length>0&&s.push(`Remove these nx devDependencies from package.json: ${e.pkgDevDeps.join(", ")}.`),e.pkgScripts.length>0&&s.push(`Rewrite these package.json scripts to use \`vis run\`: ${e.pkgScripts.join(", ")}.`),e.workflowHits.length>0){const i=new Map;for(const r of e.workflowHits){const o=i.get(r.file)??new Set;o.add(r.reason),i.set(r.file,o)}for(const[r,o]of i)s.push(`Update ${r}: ${[...o].join("; ")}.`)}return e.eslintHits.length>0&&s.push(`Remove @nx/eslint-plugin imports + rules (enforce-module-boundaries, dependency-checks, nx-plugin-checks) from: ${e.eslintHits.join(", ")}. There is no vis equivalent yet.`),s.map((i,r)=>`${String(r+1)}. ${i}`)},Lb=(e,t)=>{if(e.length!==0){t.info(""),t.info("── Post-migrate cleanup ──");for(const n of e)t.info(n)}},Ka=(e,t,n,s)=>{t.aggressive&&(t={...t,force:!0,rewriteSyncGenerators:!0});const i=Nd(e,"nx.json");if(!i){n.warn("No nx.json found in workspace root — nothing to migrate."),s.warnings.push("No nx.json at workspace root.");return}i.targetDefaults&&(i.targetDefaults=gb(i.targetDefaults,s,n));const r=pb(e),o=vb(r),a=Eb(e,o,t,n,s);Cb(i,a.rewrittenTargets,s);for(const f of a.unmappedHits)s.warnings.push(`scripts.${f.script}: pnpm filter(s) ${f.filters.map(h=>`\`${h}\``).join(", ")} don't match any known project.json#name or sibling package.json#name. Left untouched — fix the filter or add the missing project.json before re-running.`);const c=mb(i,e,t.useEditorconfig);if(!go(e,c,t,n,s))return;yb(r,t,n,s);const{punchList:l}=Ob(r,t,n,s);for(const f of l){f.nonShimTargets.length>0&&s.manualSteps.push(`Review targets in ${ke(e,f.file)} (project: ${f.name}) — non-shim targets need manual review: ${f.nonShimTargets.join(", ")}.`);for(const h of f.syncGenerators){if(t.rewriteSyncGenerators){const g=Tb(f.file,e,h.target,h.sync,t,n,s);if("preScript"in g){s.manualSteps.push(`${g.pkgPath} now has a \`${g.preScript}\` script that fails with a TODO. Replace it with the real equivalent of nx syncGenerators: ${h.sync.join(", ")}.`);continue}s.warnings.push(`syncGenerators on \`${f.name}#${h.target}\` (${ke(e,f.file)}) not auto-rewritten — ${g.reason}. Move ${h.sync.join(", ")} into a \`pre${h.target}\` script in package.json manually.`);continue}s.warnings.push(`syncGenerators on \`${f.name}#${h.target}\` (${ke(e,f.file)}) has no vis equivalent. Move ${h.sync.join(", ")} into a \`pre${h.target}\` script in package.json (or re-run with --rewrite-sync-generators to insert a TODO automatically).`)}}jb(e,t,n,s),t.aggressive&&Pb(e,o.knownProjects,t,n,s),s.manualSteps.push("vis adds two task primitives nx doesn't expose declaratively: `when: { os, env, branch, ci, not.* }` for conditional execution (replaces ad-hoc `configurations`) and `always: true` for finally/teardown tasks that run even when upstream fails. See docs/guides/conditional-and-finally-tasks.mdx.");const d=i.affected?.defaultBase??i.defaultBase;typeof d=="string"&&d.length>0&&d!=="main"&&n.info(`Translated nx's default base branch (${d}) into vis.config.ts#defaultBase.`),db(e,{dryRun:t.dryRun},n);const u=Nb(e),p=Db(u,e,{});if(Lb(p,n),t.force&&!t.dryRun&&u.nxJson){const f=m(e,"nx.json");oe(f,s);try{gt(f),n.info(`Removed ${f} (backup at ${f}.bak).`)}catch{}}},Fd=[".secretlintrc",".secretlintrc.json",".secretlintrc.js",".secretlintrc.mjs",".secretlintrc.cjs",".secretlintrc.yml",".secretlintrc.yaml"],Vd=[".secretlintignore"],Wd=e=>Fd.find(t=>$(m(e,t))),Hd=e=>Vd.find(t=>$(m(e,t))),Mb=(e,t,n)=>{if(t.endsWith(".js")||t.endsWith(".mjs")||t.endsWith(".cjs"))return ee(n,`${t} is a JS config — cannot auto-extract rule IDs. Review manually to confirm coverage.`),[];if(t.endsWith(".yml")||t.endsWith(".yaml"))return ee(n,`${t} is YAML — cannot auto-extract rule IDs without a YAML parser. Review manually.`),[];const s=he(m(e,t));if(!s)return[];const i=new Set,r=o=>{if(o)for(const a of o)a.id&&i.add(a.id),a.rules&&r(a.rules)};return r(s.rules),[...i]},_b=(e,t,n,s)=>{for(const i of[...Fd,...Vd]){const r=m(e,i);if($(r)){if(t){n.info(`[dry-run] Would remove ${r}`);continue}oe(r,s),gt(r),me(s,"secretlint","removedConfigCount"),n.info(`Removed ${r}`)}}},Fb=(e,t,n,s)=>{const i=m(e,".secretlintignore");if(!$(i))return;const o=J(i).split(/\r?\n/).map(a=>a.trim()).filter(a=>a&&!a.startsWith("#"));o.length!==0&&(se(s,`.secretlintignore contained ${String(o.length)} path pattern(s). vis secrets uses .gitignore + --exclude / --exclude-from; add these globs to your .gitignore or pass --exclude: ${o.slice(0,5).join(", ")}${o.length>5?", ...":""}`),t&&n.info(`[dry-run] Would consume ${i} (${String(o.length)} patterns) and surface as manual step.`))},Vb=(e,t,n,s,i)=>{const r=m(e,"package.json");if(!$(r))return;const o=he(r);if(!o)return;let a=!1;if(o.scripts){for(const[l,d]of Object.entries(o.scripts))if(typeof d=="string"&&/\bsecretlint\b/.test(d)){const u=d.replaceAll(/\bsecretlint\b[^\n&|;]*/g,"vis secrets").trim();u!==d&&(o.scripts[l]=u,a=!0,me(s,"secretlint","rewrittenScriptCount"),n.info(` scripts.${l}: "${d}" -> "${u}"`))}}if(o.devDependencies){const l=o.devDependencies,d=[];for(const u of Object.keys(l))(u==="secretlint"||u.startsWith("@secretlint/"))&&(delete l[u],d.push(u),a=!0,me(s,"secretlint","removedPackageCount"));d.length>0&&n.info(` removed ${String(d.length)} secretlint devDependencies: ${d.join(", ")}`)}if(!a)return;if(t){n.info(`[dry-run] Would update ${r}`);return}const c=Ye(r,J(r),{defaultIndent:" ",useEditorconfig:i});oe(r,s),ye(r,`${JSON.stringify(o,null,c)}
83
+ `)},Wb=(e,t,n,s)=>{const i=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"];for(const r of i){const o=m(e,r);if(!$(o))continue;const a=J(o);if(!/\bsecretlint\b/.test(a))continue;const c=a.replaceAll(/\bsecretlint\b[^\n&|;]*/g,"vis secrets --staged");if(t){n.info(`[dry-run] Would rewrite ${o}`);continue}oe(o,s),ye(o,c),s.gitHooksConfigured=!0,n.info(`Rewrote secretlint invocation in ${r}`)}},Ya=(e,t,n,s)=>{const i=Wd(e),r=Hd(e);if(!!!(i??r))return t.silent||n.info("No secretlint artifacts found — nothing to migrate."),!1;if(i){const a=Mb(e,i,s);n.info(`Found ${i}`),a.length>0?(n.info(` active rules/presets: ${a.join(", ")}`),se(s,`secretlint used these rules: ${a.join(", ")}. vis secrets ships the gitleaks ruleset (177 rules covering AWS/GCP/Azure/GitHub/Slack/Stripe and more). Verify parity before removing secretlint.`)):se(s,`Rule IDs could not be auto-extracted from ${i}. Verify that the bundled gitleaks ruleset covers your secretlint rule set.`)}return Fb(e,t.dryRun,n,s),Vb(e,t.dryRun,n,s,t.useEditorconfig),Wb(e,t.dryRun,n,s),_b(e,t.dryRun,n,s),!0},Di="sherif",fi=/\bsherif\b/,$r={"empty-dependencies":"empty-deps","multiple-dependency-versions":"workspace-versions","non-existant-packages":"dead-workspace-patterns","packages-without-package-json":"missing-package-json","root-package-dependencies":"root-deps","root-package-manager-field":"root-package-manager","root-package-private-field":"root-private","types-in-dependencies":"types-in-deps","unordered-dependencies":void 0,"unsync-similar-dependencies":"similar-deps"},Hb=Object.values($r).filter(e=>e!==void 0),Ud=e=>{const t=m(e,"package.json");return $(t)&&he(t)?.sherif?"package.json":void 0},Gd=e=>{const t=m(e,"package.json");if(!$(t))return!1;const n=he(t);if(!n)return!1;if(n.devDependencies?.sherif||n.dependencies?.sherif)return!0;if(n.scripts){for(const s of Object.values(n.scripts))if(typeof s=="string"&&fi.test(s))return!0}return!1},Ub=e=>he(m(e,"package.json"))?.sherif,zd=(e,t)=>{const n={unmapped:[],visDisabled:[]};if(!Array.isArray(e["ignore-rules"]))return n;for(const s of e["ignore-rules"]){if(typeof s!="string"||s.length===0)continue;const i=$r[s];if(i===void 0){s==="unordered-dependencies"?ee(t,"sherif rule `unordered-dependencies` has no `vis lint` equivalent — vis covers ordering via `vis sort-package-json` (separate command). No migration needed; skip running it if you don't want it."):Object.hasOwn($r,s)?n.unmapped.push(s):ee(t,`sherif rule \`${s}\` is unknown to vis migrate — skipped.`);continue}n.visDisabled.push(i)}return n},Jd=e=>{const t=Hb.filter(n=>!e.includes(n));return t.length===0?"vis lint":`vis lint ${t.map(n=>`--${n}`).join(" ")}`},Gb=(e,t)=>{const n=m(e,"package.json"),s={configRemoved:!1,dependencyRemoved:!1,removedScripts:[],scriptCount:0};if(!$(n))return s;const i=J(n),r=JSON.parse(i);let o=!1;r.sherif&&(delete r.sherif,o=!0,s.configRemoved=!0);for(const c of["dependencies","devDependencies"]){const l=r[c];l?.sherif&&(delete l.sherif,o=!0,s.dependencyRemoved=!0)}const a=r.scripts;if(a){const c={};for(const[l,d]of Object.entries(a))typeof d=="string"&&fi.test(d)?(s.scriptCount+=1,s.removedScripts.push({name:l,value:d}),o=!0):c[l]=d;s.scriptCount>0&&(Object.keys(c).length===0?delete r.scripts:r.scripts=c)}if(o){const c=ls(n,i,{useEditorconfig:t});oe(n),ce(n,`${JSON.stringify(r,void 0,c)}
84
+ `,"utf8")}return s},zb=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],Jb=[".github/workflows",".gitlab-ci.yml",".circleci/config.yml",".woodpecker.yml",".drone.yml"],qd=(e,t)=>{const n=[];for(const s of zb){const i=m(e,s);$(i)&&fi.test(J(i))&&(n.push(s),se(t,`Update ${s} — replace \`sherif\` invocation with \`vis lint\`.`))}return n},Kd=(e,t)=>{const n=[],s=i=>{const r=m(e,i);$(r)&&fi.test(J(r))&&(n.push(i),se(t,`Update ${i} — replace \`sherif\` invocation with \`vis lint\`.`))};for(const i of Jb){const r=m(e,i);if($(r)){if(i===".github/workflows"){try{for(const o of we(r))(o.endsWith(".yml")||o.endsWith(".yaml"))&&s(`.github/workflows/${o}`)}catch{}continue}s(i)}}return n},qb=(e,t,n,s,i)=>{const r=zd(t,i);if(r.visDisabled.length>0){const p=Jd(r.visDisabled);se(i,`sherif's \`ignore-rules\` was set to [${r.visDisabled.map(f=>JSON.stringify(f)).join(", ")}] (vis names). vis has no global rule-disable; replace any \`sherif\` script with the explicit positive list: \`${p}\`.`)}r.unmapped.length>0&&ee(i,`sherif rule(s) [${r.unmapped.map(p=>JSON.stringify(p)).join(", ")}] could not be mapped — please re-evaluate manually.`),Array.isArray(t["ignore-dependencies"])&&t["ignore-dependencies"].length>0&&se(i,`sherif's \`ignore-dependencies\` was set to [${t["ignore-dependencies"].map(p=>JSON.stringify(p)).join(", ")}]. Mirror this in vis.config.ts under \`policy.workspaceVersions.ignore\`, \`policy.customTypes.ignore\`, \`policy.typesInDeps.ignore\` (and \`policy.redefineRoot.ignore\`) for the lints where it applies.`),Array.isArray(t["ignore-packages"])&&t["ignore-packages"].length>0&&(ee(i,`sherif's \`ignore-packages\` was set to [${t["ignore-packages"].map(p=>JSON.stringify(p)).join(", ")}] — vis has no global package-skip yet (only per-rule scoping via policy.bannedDeps.{packages,paths}). Tracked alongside the dep filter work.`),se(i,"Re-evaluate sherif `ignore-packages` — vis has no equivalent global filter yet.")),Array.isArray(t["ignore-paths"])&&t["ignore-paths"].length>0&&(ee(i,`sherif's \`ignore-paths\` was set to [${t["ignore-paths"].map(p=>JSON.stringify(p)).join(", ")}] — vis has no global path-skip yet.`),se(i,"Re-evaluate sherif `ignore-paths` — vis has no equivalent global filter yet."));const o=qd(e,i);o.length>0&&!n.silent&&s.warn(`Found sherif reference in ${String(o.length)} hook file(s) — see manualSteps for details.`);const a=Kd(e,i);a.length>0&&!n.silent&&s.warn(`Found sherif reference in ${String(a.length)} CI file(s) — see manualSteps for details.`);const{configRemoved:c,dependencyRemoved:l,removedScripts:d,scriptCount:u}=Gb(e,n.useEditorconfig);if(c&&!n.silent&&s.info("Removed `sherif` block from package.json"),c&&me(i,Di,"removedConfigCount"),l&&me(i,Di,"removedPackageCount"),u>0){me(i,Di,"rewrittenScriptCount",u);for(const{name:p,value:f}of d)se(i,`Recreate script \`${p}\` (removed; was \`${f}\`). Replace \`sherif\` with \`vis lint\` (sherif's lint surface ≈ \`vis lint\`).`);n.silent||s.info(`Removed ${String(u)} script(s) referencing \`sherif\`. Replace with \`vis lint\`.`)}},Xa=(e,t,n,s)=>{const i=Ud(e),r=Gd(e);if(!i&&!r)return t.silent||n.info("No sherif configuration or installation found — nothing to migrate."),!1;const o=Ub(e)??{};if(t.dryRun){const a=zd(o,s);if(qd(e,s),Kd(e,s),!t.silent&&(i&&n.info("[dry-run] Would remove `sherif` block from package.json"),r&&n.info("[dry-run] Would strip `sherif` from devDependencies/scripts"),a.visDisabled.length>0)){const c=Jd(a.visDisabled);n.info(`[dry-run] Suggested replacement script: ${c}`)}return!0}return qb(e,o,t,n,s),!0},Kb=["dependencies","devDependencies","peerDependencies","optionalDependencies","overrides","resolutions","pnpm.overrides"],Yb=(e,t)=>{const n=t.split(".");let s=e;for(const i of n){if(typeof s!="object"||s===null)return;s=s[i]}return typeof s=="object"&&s!==null?s:void 0},yo=e=>{const t=m(e,"package.json");if(!$(t))return["."];const s=de(t).workspaces;let i=[];if(s){const r=Array.isArray(s)?s:s.packages;r&&(i=Zo(e,r))}if(i.length===0){const r=Kf(e);r&&(i=Zo(e,r))}return[".",...i]},hi=e=>{if($(e))try{return de(e)}catch{return}},Xb=e=>{const t=new Set,n=yo(e);for(const s of n){const i=hi(m(e,s,"package.json"));i&&typeof i.name=="string"&&t.add(i.name)}return t},v4=(e,t={})=>{const n=t.includeInternal??!0,s=t.depTypes??Kb,i=yo(e),r=Xb(e),o=[],c=s.includes("pnpm.overrides")?qf(e):void 0,l=c?m(e,"pnpm-workspace.yaml"):void 0;for(const d of i){const u=m(e,d,"package.json"),p=hi(u);if(!p)continue;const f=typeof p.name=="string"?p.name:void 0,h=d==="."?".":as(e,m(e,d));for(const g of s){const y=g.includes(".")?Yb(p,g):p[g];if(!(!y||typeof y!="object"))for(const[x,b]of Object.entries(y)){if(typeof b!="string")continue;const S=r.has(x);!n&&S||o.push({depName:x,depType:g,isInternal:S,packageDir:h,packageJsonPath:u,packageName:f,specifier:b})}}}if(c&&l)for(const[d,u]of Object.entries(c)){const p=r.has(d);!n&&p||o.push({depName:d,depType:"pnpm.overrides",isInternal:p,packageDir:".",packageJsonPath:l,packageName:void 0,specifier:u})}return o},vo=new Set(["devEngines.packageManager","devEngines.runtime","engines","packageManager","volta"]),Zb=["engines","volta"],Qb=new Set(["extends"]),e0=/^([@\w./-]+?)@([^+]+)(\+.+)?$/,t0=/^([@\w./-]+)~(.+)$/,gi=e=>{const t=e0.exec(e.trim());if(!(!t?.[1]||!t[2]))return{hash:t[3]??"",name:t[1],version:t[2]}},Yd=e=>{const t=t0.exec(e.trim());if(!(!t?.[1]||!t[2]))return{name:t[1],version:t[2]}},es=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Xd=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e.name=="string",n0=new Set(["name@version","name~version","string","versionsByName"]),b4=e=>{const t=[];if(!e)return t;const n=new Set;for(const s of e){const i=typeof s?.name=="string"&&s.name.length>0?s.name:"<unnamed>";if(typeof s?.name!="string"||s.name.length===0){t.push("extraTypes entry missing 'name'");continue}vo.has(s.name)&&t.push(`extraTypes[${i}]: name collides with a built-in customType`),n.has(s.name)&&t.push(`extraTypes[${i}]: duplicate name`),n.add(s.name),(typeof s.path!="string"||s.path.length===0)&&t.push(`extraTypes[${i}]: missing 'path'`),n0.has(s.strategy)||t.push(`extraTypes[${i}]: invalid strategy "${String(s.strategy)}" (expected name@version | name~version | string | versionsByName)`),s.strategy==="string"&&(typeof s.depName!="string"||s.depName.length===0)&&t.push(`extraTypes[${i}]: strategy 'string' requires 'depName'`)}return t},s0=(e,t)=>{if(t.length===0)return;let n=e;for(const s of t.split(".")){if(typeof n!="object"||n===null||Array.isArray(n))return;n=n[s]}return n},i0=(e,t,n,s,i)=>{const r=s0(t,e.path);if(r===void 0)return[];const o=Object.freeze({depName:e.depName,path:e.path,strategy:e.strategy});if(e.strategy==="versionsByName"){if(!es(r))return[];const a=[];for(const[c,l]of Object.entries(r))typeof l=="string"&&a.push({customType:e.name,depName:c,extra:o,packageDir:n,packageJsonPath:s,packageName:i,rawValue:l,specifier:l});return a}if(e.strategy==="name@version"){if(typeof r!="string")return[];const a=gi(r);return a?[{customType:e.name,depName:a.name,extra:o,packageDir:n,packageJsonPath:s,packageName:i,rawValue:r,specifier:a.version}]:[]}if(e.strategy==="name~version"){if(typeof r!="string")return[];const a=Yd(r);return a?[{customType:e.name,depName:a.name,extra:o,packageDir:n,packageJsonPath:s,packageName:i,rawValue:r,specifier:a.version}]:[]}return typeof r!="string"||typeof e.depName!="string"||e.depName.length===0?[]:[{customType:e.name,depName:e.depName,extra:o,packageDir:n,packageJsonPath:s,packageName:i,rawValue:r,specifier:r}]},w4=(e,t)=>{const n=yo(e),s=[];for(const i of n){const r=m(e,i,"package.json"),o=hi(r);if(!o)continue;const a=typeof o.name=="string"?o.name:void 0,c=i==="."?".":as(e,m(e,i));for(const d of Zb){const u=o[d];if(es(u))for(const[p,f]of Object.entries(u))typeof f=="string"&&(d==="volta"&&Qb.has(p)||s.push({customType:d,depName:p,packageDir:c,packageJsonPath:r,packageName:a,rawValue:f,specifier:f}))}if(typeof o.packageManager=="string"){const d=gi(o.packageManager);d&&s.push({customType:"packageManager",depName:d.name,packageDir:c,packageJsonPath:r,packageName:a,rawValue:o.packageManager,specifier:d.version})}const{devEngines:l}=o;if(typeof l=="object"&&l!==null&&!Array.isArray(l))for(const d of["runtime","packageManager"]){const u=l[d];if(u===void 0)continue;const p=Array.isArray(u)?u:[u];for(const f of p)!Xd(f)||typeof f.version!="string"||s.push({customType:d==="runtime"?"devEngines.runtime":"devEngines.packageManager",depName:f.name,packageDir:c,packageJsonPath:r,packageName:a,rawValue:f.version,specifier:f.version})}if(t){for(const d of t)if(!(typeof d?.name!="string"||d.name.length===0)&&!vo.has(d.name))for(const u of i0(d,o,c,r,a))s.push(u)}}return s},r0=(e,t)=>`${e} ${t}`,o0=(e,t)=>{const n=[...e].sort((i,r)=>(i.packageName??i.packageDir).localeCompare(r.packageName??r.packageDir));let s;for(const i of n){const r=cr(i.specifier);if(!r)continue;if(!s){s=i;continue}const o=cr(s.specifier);if(!o){s=i;continue}const a=Qo(o,r),c=Qo(r,o);(t==="highest"&&a||t==="lowest"&&c)&&(s=i)}return s},k4=(e,t={})=>{const n=new Set(t.ignoreDeps),s=t.resolve??"highest",i=[],r=e.filter(a=>t.dep!==void 0&&a.depName!==t.dep?!1:!n.has(a.depName)),o=new Map;for(const a of r){const c=r0(a.customType,a.depName),l=o.get(c);l?l.push(a):o.set(c,[a])}for(const[,a]of o){if(a.length<2||new Set(a.map(d=>d.specifier)).size<=1)continue;const l=o0(a,s);if(l)for(const d of a)d.specifier!==l.specifier&&cr(d.specifier)!==void 0&&i.push({canonicalSource:l.packageName??l.packageDir,customType:d.customType,depName:d.depName,...d.extra?{extra:d.extra}:{},fix:l.specifier,packageDir:d.packageDir,packageJsonPath:d.packageJsonPath,packageName:d.packageName,specifier:d.specifier})}return i},a0=(e,t)=>{const n=t.extra;if(!n)return!1;const s=n.path.split(".");if(s.length===0||s.some(o=>o.length===0))return!1;let i=e;for(let o=0;o<s.length-1;o+=1){const a=i[s[o]];if(typeof a!="object"||a===null||Array.isArray(a))return!1;i=a}const r=s.at(-1);if(n.strategy==="versionsByName"){const o=i[r];return es(o)?(o[t.depName]=t.fix,!0):!1}if(n.strategy==="name@version"){const o=i[r];if(typeof o!="string")return!1;const a=gi(o);return a?(i[r]=`${a.name}@${t.fix}`,!0):!1}if(n.strategy==="name~version"){const o=i[r];if(typeof o!="string")return!1;const a=Yd(o);return a?(i[r]=`${a.name}~${t.fix}`,!0):!1}return typeof i[r]!="string"?!1:(i[r]=t.fix,!0)},S4=(e,t={})=>{const{useEditorconfig:n}=t,s=new Map;for(const r of e){const o=s.get(r.packageJsonPath);o?o.push(r):s.set(r.packageJsonPath,[r])}const i=[];for(const[r,o]of s){const a=hi(r);if(!a)continue;let c=!1;for(const l of o){if(l.extra){a0(a,l)&&(c=!0);continue}if(l.customType==="engines"||l.customType==="volta"){const h=a[l.customType];es(h)&&(h[l.depName]=l.fix,c=!0);continue}if(l.customType==="packageManager"){const h=a.packageManager;if(typeof h=="string"){const g=gi(h);g&&(a.packageManager=`${g.name}@${l.fix}`,c=!0)}continue}const d=l.customType==="devEngines.runtime"?"runtime":"packageManager",{devEngines:u}=a;if(!es(u))continue;const p=u[d];if(p===void 0)continue;const f=Array.isArray(p)?p:[p];for(const h of f)Xd(h)&&h.name===l.depName&&(h.version=l.fix,c=!0)}c&&(dh(r,a,{indent:Yf(r,{useEditorconfig:n}),overwrite:!0}),i.push(r))}return i},Er="syncpack",Zd=[".syncpackrc",".syncpackrc.json"],bo=[".syncpackrc.yaml",".syncpackrc.yml"],wo=[".syncpackrc.cjs",".syncpackrc.js",".syncpackrc.mjs",".syncpackrc.ts","syncpack.config.cjs","syncpack.config.js","syncpack.config.mjs","syncpack.config.ts"],c0=[...Zd,...bo,...wo],l0=/\bextraTypes\s*:/,d0=/\bpolicy\s*:/,Za=/(defineConfig\(\{)/,Qa=/(export\s+default\s+\{)/,ko=/\bsyncpack\b/,Qd=e=>{const t=m(e,"package.json");if($(t)&&he(t)?.syncpack)return"package.json";for(const n of c0)if($(m(e,n)))return n},u0=e=>{for(const n of wo)if($(m(e,n)))return n;const t=m(e,".syncpackrc");if($(t)&&!yn(t))try{At(t);return}catch{return".syncpackrc"}},p0=e=>{const t=_t(e);return t?l0.test(J(t)):!1},f0=e=>he(m(e,"package.json"))?.syncpack,h0=e=>he(e),ec=e=>{try{return At(e)}catch{return}},g0=(e,t,n)=>{if(t==="package.json")return f0(e);if(wo.includes(t)){ee(n,`${t} is a TS/JS config and cannot be auto-migrated — vis migrate does not load executable config. Convert to .syncpackrc.json and re-run, or translate directly into vis.config.ts. Tracked in https://github.com/visulima/visulima/issues/622.`),se(n,`Translate ${t} into vis.config.ts (policy.* and security.*) — see https://github.com/visulima/visulima/issues/622`);return}const s=m(e,t);if(bo.includes(t))return ec(s);if(t===".syncpackrc"&&!yn(s)){const i=ec(s);if(i)return i;ee(n,".syncpackrc is neither valid JSON nor YAML — please migrate manually.");return}return h0(s)},eu=(e,t)=>{const n=[];if(!e.customTypes)return n;for(const[s,i]of Object.entries(e.customTypes)){if(!i||typeof i!="object")continue;const{strategy:r}=i,{path:o}=i;if(typeof o!="string"||o.length===0){ee(t,`customType "${s}" has no \`path\` — skipped.`);continue}if(r!=="name@version"&&r!=="string"&&r!=="versionsByName"){ee(t,`customType "${s}" has unsupported strategy ${JSON.stringify(r)} — skipped.`);continue}if(vo.has(s)){ee(t,`customType "${s}" collides with a vis built-in and was dropped — vis already lints this surface.`);continue}const a={name:s,path:o,strategy:r};if(r==="string"){const{depName:c}=i;typeof c=="string"&&c.length>0?a.depName=c:(ee(t,`customType "${s}" uses strategy "string" but has no \`depName\` — vis requires it. Add it manually after migration.`),se(t,`Set policy.customTypes.extraTypes[name="${s}"].depName before running vis lint`))}n.push(a)}return n},tu=e=>e.isBanned===!0,nu=(e,t)=>{if(Array.isArray(e.versionGroups)&&e.versionGroups.length>0){const n=e.versionGroups.filter(s=>s&&typeof s=="object"&&!tu(s));n.length>0&&(ee(t,`${String(n.length)} versionGroups rule(s) cannot be migrated — \`pinVersion\`, \`snapTo\`, and \`policy: "sameRange"\` (and other versionGroups DSL surfaces) are tracked in https://github.com/visulima/visulima/issues/622.`),se(t,'Re-implement versionGroups rules using `pinVersion` / `snapTo` / `policy: "sameRange"` once the vis DSL ships (issue #622).'))}Array.isArray(e.semverGroups)&&e.semverGroups.length>0&&(ee(t,`${String(e.semverGroups.length)} semverGroups rule(s) cannot be migrated — semverGroups DSL is tracked in https://github.com/visulima/visulima/issues/622.`),se(t,"Re-implement semverGroups rules manually once the vis DSL ships (issue #622)")),Array.isArray(e.dependencyTypes)&&e.dependencyTypes.length>0&&se(t,"Review syncpack `dependencyTypes` — vis applies policies to dependencies/devDependencies/peerDependencies/optionalDependencies/overrides by default. Narrow via policy.* filters if needed."),Array.isArray(e.specifierTypes)&&e.specifierTypes.length>0&&se(t,"Review syncpack `specifierTypes` — vis has no direct equivalent today; specifier filtering belongs in versionGroups (issue #622)."),typeof e.filter=="string"&&e.filter.length>0&&se(t,`Re-implement syncpack \`filter\` regex (${e.filter}) once vis exposes a top-level dep filter.`),(Array.isArray(e.sortAz)&&e.sortAz.length>0||Array.isArray(e.sortFirst)&&e.sortFirst.length>0||Array.isArray(e.sortExports)&&e.sortExports.length>0)&&ee(t,"syncpack sort options (sortAz / sortFirst / sortExports) are superseded by `vis sort-package-json` — no migration needed."),(e.sortPackages!==void 0||e.formatBugs!==void 0||e.formatRepository!==void 0)&&ee(t,"syncpack package.json shape options (sortPackages / formatBugs / formatRepository) are superseded by `vis sort-package-json` — no migration needed."),(e.lintFormatting!==void 0||e.lintSemverRanges!==void 0||e.lintVersions!==void 0)&&ee(t,"syncpack lint toggles (lintFormatting / lintSemverRanges / lintVersions) are covered by `vis lint` by default — no migration needed."),Array.isArray(e.source)&&e.source.length>0&&se(t,`syncpack \`source\` was set to [${e.source.map(n=>JSON.stringify(n)).join(", ")}]. vis derives workspace globs from pnpm-workspace.yaml / package.json#workspaces — verify they match before relying on \`vis lint\`.`),typeof e.indent=="string"&&e.indent.length>0&&ee(t,"syncpack `indent` is implicit in vis — JSON writers honor `.editorconfig` (and the source file's existing indentation). No migration needed.")},su=(e,t)=>{const n={};if(!Array.isArray(e.versionGroups))return n;for(const s of e.versionGroups){if(!s||typeof s!="object")continue;const i=s;if(!tu(i))continue;const r=Array.isArray(i.dependencies)?i.dependencies.filter(l=>typeof l=="string"&&l.length>0):[];if(r.length===0){ee(t,"versionGroup with `isBanned: true` has no `dependencies` entries — skipped.");continue}const o=Array.isArray(i.packages)?i.packages.filter(l=>typeof l=="string"&&l.length>0):[],a=i.label,c=typeof a=="string"&&a.length>0?a:"banned via syncpack versionGroups";for(const l of r){if(n[l]!==void 0){ee(t,`Multiple banned versionGroups target "${l}" — kept the first match; merge manually if needed.`);continue}n[l]=o.length>0?{packages:o,reason:c}:c}}return n},m0=e=>{const t=[`name: ${JSON.stringify(e.name)}`,`path: ${JSON.stringify(e.path)}`,`strategy: ${JSON.stringify(e.strategy)}`];return e.depName!==void 0&&t.push(`depName: ${JSON.stringify(e.depName)}`),` { ${t.join(", ")} }`},y0=(e,t)=>{if(typeof t=="string")return` ${JSON.stringify(e)}: ${JSON.stringify(t)}`;const n=[`reason: ${JSON.stringify(t.reason)}`];return t.packages&&t.packages.length>0&&n.push(`packages: [${t.packages.map(s=>JSON.stringify(s)).join(", ")}]`),t.paths&&t.paths.length>0&&n.push(`paths: [${t.paths.map(s=>JSON.stringify(s)).join(", ")}]`),t.replacement!==void 0&&n.push(`replacement: ${JSON.stringify(t.replacement)}`),` ${JSON.stringify(e)}: { ${n.join(", ")} }`},Cr=(e,t={})=>{const n=[],s=Object.entries(t);if(s.length>0){const i=s.map(([r,o])=>y0(r,o)).join(`,
85
85
  `);n.push(` bannedDeps: {
86
86
  ${i},
87
- }`)}if(e.length>0){const i=e.map(r=>p0(r)).join(`,
87
+ }`)}if(e.length>0){const i=e.map(r=>m0(r)).join(`,
88
88
  `);n.push(` customTypes: {
89
89
  extraTypes: [
90
90
  ${i},
@@ -92,135 +92,136 @@ ${i},
92
92
  }`)}return` policy: {
93
93
  ${n.join(`,
94
94
  `)},
95
- }`},tu=(e,t)=>{const n=[],s=Object.keys(t).length;return e.length>0&&n.push(`${String(e.length)} customType(s)`),s>0&&n.push(`${String(s)} bannedDep(s)`),n.join(" + ")},h0=(e,t,n,s={})=>{const i=tu(t,s);if(i==="")return!1;const r=Mt(e);if(r){const l=J(r);if(o0.test(l))return n.warn(`vis.config.ts already has a "policy" block — please merge ${i} manually.`),!1;const d=Er(t,s);let u;return Ya.test(l)?u=l.replace(Ya,`$1
96
- ${d},`):Xa.test(l)&&(u=l.replace(Xa,`$1
95
+ }`},iu=(e,t)=>{const n=[],s=Object.keys(t).length;return e.length>0&&n.push(`${String(e.length)} customType(s)`),s>0&&n.push(`${String(s)} bannedDep(s)`),n.join(" + ")},v0=(e,t,n,s={})=>{const i=iu(t,s);if(i==="")return!1;const r=_t(e);if(r){const l=J(r);if(d0.test(l))return n.warn(`vis.config.ts already has a "policy" block — please merge ${i} manually.`),!1;const d=Cr(t,s);let u;return Za.test(l)?u=l.replace(Za,`$1
96
+ ${d},`):Qa.test(l)&&(u=l.replace(Qa,`$1
97
97
  ${d},`)),u?(oe(r),ce(r,u,"utf8"),n.info(`Merged ${i} into ${r}`),!0):(n.warn(`Could not auto-insert policy block into ${r} — please add manually`),!1)}const o=m(e,"vis.config.ts"),c=`import { defineConfig } from "@visulima/vis/config";
98
98
 
99
99
  export default defineConfig({
100
- ${Er(t,s)},
100
+ ${Cr(t,s)},
101
101
  });
102
- `;return ce(o,c,"utf8"),n.info(`Created ${o} with ${i}`),!0},g0=(e,t)=>{const n=m(e,"package.json"),s={catalogStripped:!1,configRemoved:!1,dependencyRemoved:!1,removedScripts:[],scriptCount:0};if(!$(n))return s;const i=J(n),r=JSON.parse(i);let o=!1;r.syncpack&&(delete r.syncpack,o=!0,s.configRemoved=!0);for(const d of["dependencies","devDependencies"]){const u=r[d];u?.syncpack&&(delete u.syncpack,o=!0,s.dependencyRemoved=!0)}const a=r.workspaces;if(a&&typeof a=="object"&&!Array.isArray(a)){const d=a.catalog;d&&typeof d.syncpack=="string"&&(delete d.syncpack,o=!0,s.catalogStripped=!0);const u=a.catalogs;if(u&&typeof u=="object")for(const p of Object.values(u))p&&typeof p.syncpack=="string"&&(delete p.syncpack,o=!0,s.catalogStripped=!0)}const c=r.catalog;c&&typeof c.syncpack=="string"&&(delete c.syncpack,o=!0,s.catalogStripped=!0);const l=r.scripts;if(l){const d={};for(const[u,p]of Object.entries(l))typeof p=="string"&&wo.test(p)?(s.scriptCount+=1,s.removedScripts.push({name:u,value:p}),o=!0):d[u]=p;s.scriptCount>0&&(Object.keys(d).length===0?delete r.scripts:r.scripts=d)}if(o){const d=as(n,i,{useEditorconfig:t});oe(n),ce(n,`${JSON.stringify(r,void 0,d)}
103
- `,"utf8")}return s},m0=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],y0=[".github/workflows",".gitlab-ci.yml",".circleci/config.yml",".woodpecker.yml",".drone.yml"],nu=(e,t)=>{const n=[],s=i=>{const r=m(e,i);$(r)&&wo.test(J(r))&&(n.push(i),se(t,`Update ${i} — replace \`syncpack\` invocation(s) with \`vis lint\` / \`vis sort-package-json\` as appropriate.`))};for(const i of y0){const r=m(e,i);if($(r)){if(i===".github/workflows"){try{for(const o of Ee(r))(o.endsWith(".yml")||o.endsWith(".yaml"))&&s(`.github/workflows/${o}`)}catch{}continue}s(i)}}return n},su=(e,t)=>{const n=[];for(const s of m0){const i=m(e,s);$(i)&&wo.test(J(i))&&(n.push(s),se(t,`Update ${s} — replace \`syncpack\` invocation with \`vis lint\` / \`vis sort-package-json\` as appropriate.`))}return n},v0=e=>{const t=m(e,"pnpm-workspace.yaml");if(!$(t))return!1;let n;try{n=It(t)}catch{return!1}if(!n||typeof n!="object")return!1;let s=!1;const i=n.catalog;i&&typeof i.syncpack=="string"&&(delete i.syncpack,s=!0);const r=n.catalogs;if(r&&typeof r=="object")for(const o of Object.values(r))o&&typeof o.syncpack=="string"&&(delete o.syncpack,s=!0);return s&&(oe(t),Ol(t,n)),s},b0=(e,t)=>{for(const n of[...Kd,...vo]){const s=m(e,n);$(s)&&(oe(s,t),ht(s),me(t,$r,"removedConfigCount"))}},w0=(e,t,n,s,i)=>{const r=Xd(t,i);Qd(t,i);const o=su(e,i);o.length>0&&!n.silent&&s.warn(`Found syncpack reference in ${String(o.length)} hook file(s) — see manualSteps for details.`);const a=nu(e,i);a.length>0&&!n.silent&&s.warn(`Found syncpack reference in ${String(a.length)} CI file(s) — see manualSteps for details.`);const c=eu(t,i);(r.length>0||Object.keys(c).length>0)&&h0(e,r,s,c);const{catalogStripped:l,configRemoved:d,dependencyRemoved:u,removedScripts:p,scriptCount:f}=g0(e,n.useEditorconfig);d&&!n.silent&&s.info("Removed `syncpack` block from package.json"),u&&me(i,$r,"removedPackageCount");const h=v0(e);if((l||h)&&!n.silent&&s.info("Stripped `syncpack` from catalog protocol entries."),f>0){me(i,$r,"rewrittenScriptCount",f);for(const{name:g,value:y}of p)se(i,`Recreate script \`${g}\` (removed; was \`${y}\`). Replace \`syncpack\` with \`vis lint\` / \`vis sort-package-json\` as appropriate.`);n.silent||s.info(`Removed ${String(f)} script(s) referencing \`syncpack\`. Replace with \`vis lint\` / \`vis sort-package-json\` as appropriate.`)}b0(e,i)},Qa=(e,t,n,s)=>{const i=Yd(e);if(!i)return t.silent||n.info("No syncpack configuration found — nothing to migrate."),!1;const r=a0(e);r&&(ee(s,`Syncpack config ${r} is a TS/JS format vis migrate cannot load — executable config support is tracked in https://github.com/visulima/visulima/issues/622. Convert to .syncpackrc.json and re-run.`),se(s,`Convert ${r} to .syncpackrc.json (or translate it directly into policy.customTypes.extraTypes in vis.config.ts) — see https://github.com/visulima/visulima/issues/622`),t.silent||n.warn(`Cannot read ${r} — manual migration required (https://github.com/visulima/visulima/issues/622).`)),c0(e)&&(ee(s,"vis.config.ts already declares `policy.customTypes.extraTypes` — skipping syncpack customTypes merge to avoid duplicates."),t.silent||n.warn("vis.config.ts already has policy.customTypes.extraTypes — skipping merge"));const o=u0(e,i,s);if(!o)return!1;if(t.dryRun){const a=Xd(o,s),c=eu(o,s);Qd(o,s),su(e,s),nu(e,s);const l=tu(a,c);return t.silent||(l===""?n.info("[dry-run] No policy entries to merge — manualSteps will surface the rest."):(n.info(`[dry-run] Would merge ${l} into vis.config.ts:`),n.info(Er(a,c)))),!0}return w0(e,o,t,n,s),!0},k0=e=>e.map(t=>{if(t.startsWith("^"))return{dependencies:!0,target:t.slice(1)};if(t.includes("#")){const[n,s]=t.split("#");return{projects:n,target:s}}return t}),S0=(e,t,n)=>{const s=e.tasks??e.pipeline??{},i={};for(const[c,l]of Object.entries(s)){if(c.includes("#"))continue;const d={};l.persistent&&(d.persistent=!0),l.interactive&&(d.interactive=!0);const u={};l.cache===!1&&(u.cache=!1),l.dependsOn&&l.dependsOn.length>0&&(u.dependsOn=k0(l.dependsOn)),l.inputs&&l.inputs.length>0&&(u.inputs=l.inputs),l.outputs&&l.outputs.length>0&&(u.outputs=l.outputs),l.env&&l.env.length>0&&(u.env=l.env),l.passThroughEnv&&l.passThroughEnv.length>0&&(u.passThroughEnv=l.passThroughEnv),Object.keys(d).length>0&&(u.options=d),i[c]=u}const r={};Object.keys(i).length>0&&(r.tasks=i);const o={};return e.globalDependencies&&e.globalDependencies.length>0&&(o.globalInputs=e.globalDependencies),e.globalEnv&&e.globalEnv.length>0&&(o.globalEnv=e.globalEnv),e.globalPassThroughEnv&&e.globalPassThroughEnv.length>0&&(o.globalPassThroughEnv=e.globalPassThroughEnv),Object.keys(o).length>0&&(r.taskRunner=o),["// Migrated from turbo.json by `vis migrate turborepo`.","// Review the generated `tasks` block and move project-specific tasks","// into each project's project.json.","",'import { defineConfig } from "@visulima/vis/config";',"",`export default defineConfig(${fo(r,m(t,"vis.config.ts"),n)});`,""].join(`
104
- `)},ec=(e,t,n,s)=>{const i=Ad(e,"turbo.json");if(!i){n.warn("No turbo.json found in workspace root — nothing to migrate."),s.warnings.push("No turbo.json at workspace root.");return}const r=S0(i,e,t.useEditorconfig);if(!ho(e,r,t,n,s))return;s.manualSteps.push("Review the `tasks` block in vis.config.ts — project-specific tasks (turbo's project#task syntax) were skipped and should be moved into each project's project.json."),s.manualSteps.push("vis adds two task primitives turbo doesn't have: `when: { os, env, branch, ci, not.* }` for conditional execution and `always: true` for finally/teardown tasks that run even when upstream fails. See docs/guides/conditional-and-finally-tasks.mdx.");const o=i.tasks??i.pipeline??{};Object.values(o).some(c=>c.outputLogs!==void 0)&&s.warnings.push("`outputLogs` was found on one or more tasks but vis has no equivalent setting — review and remove."),i.remoteCache?.enabled&&s.manualSteps.push("turbo remote cache detected. vis speaks the same HTTP protocol — set taskRunner.remoteCache { url, token, teamId } in vis.config.ts, or keep your TURBO_API / TURBO_TOKEN / TURBO_TEAM env vars (vis honours them as fallbacks).")},x0=/\b(?:husky|lint-staged|nano-staged)\b/,$0=e=>{const t=m(e,"package.json");if($(t))try{return JSON.parse(J(t))}catch{return}},E0=(e,t)=>{const n=$0(e);if(!n)return!1;const s={...n.dependencies,...n.devDependencies};for(const r of kd)if(s[r])return!0;if(n.scripts){for(const r of Object.values(n.scripts))if(typeof r=="string"&&x0.test(r))return!0}const{overrides:i}=t;return i?Object.keys(i).length>0:!1},C0=e=>$(m(e,"turbo.json")),R0=e=>$(m(e,"nx.json")),O0=e=>$(m(e,".moon")),Ae=()=>{const e=[];return{lines:e,logger:{info:t=>{e.push(t)},warn:t=>{e.push(`⚠ ${t}`)}}}},j0=[{apply:({packageManager:e,root:t,visConfig:n},s,i)=>{Da(t,e,n,{dryRun:!1},i,s)},description:"Remove husky/lint-staged/nano-staged from package.json and rewrite scripts to `vis staged`.",detect:({root:e,visConfig:t})=>E0(e,t),id:"deps",probe:({packageManager:e,root:t,visConfig:n})=>{const{lines:s,logger:i}=Ae(),r=Oe();return Da(t,e,n,{dryRun:!0},i,r),s},title:"Dependencies & scripts"},{apply:({root:e},t,n)=>{Wa(e,{dryRun:!1},n,t)},description:"Inline lint-staged configuration into vis.config.ts.",detect:({root:e})=>!!Td(e),id:"lint-staged",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return Wa(e,{dryRun:!0},n,s),t},title:"lint-staged"},{apply:({root:e},t,n)=>{za(e,{dryRun:!1},n,t)},description:"Inline nano-staged configuration into vis.config.ts.",detect:({root:e})=>!!Pd(e),id:"nano-staged",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return za(e,{dryRun:!0},n,s),t},title:"nano-staged"},{apply:({root:e},t,n)=>{ec(e,{dryRun:!1},n,t)},description:"Translate turbo.json tasks into vis.config.ts.",detect:({root:e})=>C0(e),id:"turborepo",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return ec(e,{dryRun:!0},n,s),t},title:"Turborepo"},{apply:({root:e},t,n)=>{Ja(e,{dryRun:!1},n,t)},description:"Translate nx.json targets into vis.config.ts.",detect:({root:e})=>R0(e),id:"nx",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return Ja(e,{dryRun:!0},n,s),t},title:"Nx"},{apply:({root:e},t,n)=>{Ha(e,{copyTemplates:!1,dryRun:!1},n,t)},description:"Translate .moon/tasks.yml into vis.config.ts.",detect:({root:e})=>O0(e),id:"moon",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return Ha(e,{copyTemplates:!1,dryRun:!0},n,s),t},title:"Moon"},{apply:({root:e},t,n)=>{La(e,{dryRun:!1},n,t)},description:"Convert gitleaks config/baseline/hooks to `vis secrets`.",detect:({root:e})=>!!(di(e)??lo(e)??uo(e)),id:"gitleaks",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return La(e,{dryRun:!0},n,s),t},title:"Gitleaks"},{apply:({root:e},t,n)=>{_a(e,{dryRun:!1},n,t)},description:"Convert Kingfisher baseline/rules/hooks to `vis secrets`.",detect:({root:e})=>!!(po(e)??ui(e)),id:"kingfisher",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return _a(e,{dryRun:!0},n,s),t},title:"Kingfisher"},{apply:({root:e},t,n)=>{qa(e,{dryRun:!1},n,t)},description:"Replace secretlint config/hooks with `vis secrets`.",detect:({root:e})=>!!(_d(e)??Fd(e)),id:"secretlint",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return qa(e,{dryRun:!0},n,s),t},title:"Secretlint"},{apply:({root:e},t,n)=>{Qa(e,{dryRun:!1},n,t)},description:"Translate syncpack customTypes into policy.customTypes.extraTypes and strip the syncpack dep/scripts.",detect:({root:e})=>!!Yd(e),id:"syncpack",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return Qa(e,{dryRun:!0},n,s),t},title:"Syncpack"},{apply:({root:e},t,n)=>{Ka(e,{dryRun:!1},n,t)},description:"Strip sherif config/dep/scripts and surface ignore-rules as a positive `vis lint --<rule>` command.",detect:({root:e})=>!!Vd(e)||Wd(e),id:"sherif",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return Ka(e,{dryRun:!0},n,s),t},title:"Sherif"}],T0=e=>j0.filter(t=>t.detect(e)),I0=(e,t)=>({packageManager:Cd(e),root:e,visConfig:t}),A0=(e,t)=>{t.info("── Migration Summary ──");const n=[["Staged configs merged into vis.config.ts",e.mergedStagedConfigCount],["Lint-staged configs inlined",e.inlinedLintStagedConfigCount],["Config files removed",e.removedConfigCount],["Packages removed",e.removedPackageCount],["Scripts rewritten",e.rewrittenScriptCount]];for(const[i,r]of n)r>0&&t.info(` ${i}: ${String(r)}`);e.gitHooksConfigured&&t.info(" Pre-commit hook updated to use vis staged");const s=Object.entries(e.perMigration);if(s.length>0){t.info(""),t.info("By migration:");for(const[i,r]of s){const o=[];r.removedConfigCount>0&&o.push(`${String(r.removedConfigCount)} config(s) removed`),r.removedPackageCount>0&&o.push(`${String(r.removedPackageCount)} package(s) removed`),r.rewrittenScriptCount>0&&o.push(`${String(r.rewrittenScriptCount)} script(s) rewritten`),t.info(` ${i}: ${o.join(", ")||"no changes"}`)}}if(e.backupsCreated.length>0&&(t.info(""),t.info(`Created ${String(e.backupsCreated.length)} .bak file(s) for rollback. Remove them once you're happy.`)),e.warnings.length>0){t.info(""),t.warn("Warnings:");for(const i of e.warnings)t.warn(` - ${i}`)}if(e.manualSteps.length>0){t.info(""),t.info("Manual steps required:");for(const i of e.manualSteps)t.info(` - ${i}`)}},P0=(e,t)=>{if(e.length===0){t.info("No applicable migrations detected in this workspace.");return}t.info(`Detected migrations (non-interactive preview):
105
- `);for(const n of e){t.info(` • ${n.entry.title} — ${n.entry.description}`);for(const s of n.preview)t.info(` ${s}`);t.info("")}t.info("Run a specific migration with `vis migrate <name>` (e.g. `vis migrate deps`).")},B0=async e=>{const t=e.workspaceRoot??process.cwd(),n=e.visConfig??{},s=I0(t,n),r=T0(s).map(h=>({entry:h,preview:h.probe(s)}));if(!(!!process.stdout.isTTY&&!dt)){P0(r,e.logger);return}if(r.length===0){e.logger.info("No applicable migrations detected in this workspace.");return}const a=new Qm(r),c=n.tui?.autoExit??!1,l=c===!0?3:typeof c=="number"?c:0,u=await Mm(Jf.createElement(Oy,{autoExitSeconds:l,isDryRun:!1,store:a}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();if(!u||u.length===0){e.logger.info("No migrations selected — exiting.");return}const p=Oe(),f=[];for(const h of u)try{e.logger.info(`── Applying ${h.entry.title} ──`),h.entry.apply(s,p,e.logger),e.logger.info("")}catch(g){f.push({entry:h.entry,error:g}),e.logger.warn(`Failed to apply ${h.entry.title}: ${g.message}`)}A0(p,e.logger),f.length>0&&(e.logger.warn(""),e.logger.warn(`${String(f.length)} migration(s) failed — see messages above.`),process.exitCode=1)},N0={beforeCommand:async e=>{try{const t=e.options?.cwd,n=e.options?.config;let s;if(t)s=dn(process.cwd(),t);else{const c=process.env.VIS_MONOREPO_ROOT;s=c&&c.length>0?c:Rl(process.cwd()).path}e.workspaceRoot=s;const i=n?dn(process.cwd(),n):void 0;let r=i??Mt(s);try{e.visConfig=await Qo(s,i?{explicitConfigPath:i}:void 0);const c=e.visConfig?.versionConstraint;if(c&&!ur.validRange(c)){e.logger.error(""),e.logger.error(Si(Le("✖ Invalid versionConstraint"))),e.logger.error(` vis.config.ts has versionConstraint ${Le(JSON.stringify(c))}, which is not a valid semver range.`),e.logger.error(""),process.exitCode=1;return}if(c&&!ur.satisfies(Vs(),c)){e.logger.error(""),e.logger.error(Si(Le("✖ vis version too old"))),e.logger.error(` vis.config.ts requires vis ${Le(c)}, but the current version is ${Le(Vs())}.`),e.logger.error(` ${Pn("→")} Upgrade: ${et("pnpm add -D @visulima/vis@latest")}`),e.logger.error(""),process.exitCode=1;return}}catch(c){const l=r,d=c instanceof Error?c.message:String(c);e.visConfigError={file:l??void 0,message:d};const u=!!process.stdout.isTTY&&!dt;if(l&&!u){if(e.logger.error(""),e.logger.error(Si(Le(`✖ Failed to load ${l}`))),e.logger.error(` ${d}`),e.logger.error(""),d.includes("Cannot find module")){const f=/Cannot find module '([^']+)'/.exec(d)?.[1]??"unknown";e.logger.error(`${Pn("→ Hint:")} The module ${Le(f)} could not be resolved.`),f.includes("@visulima/vis")?(e.logger.error(" This usually means the package isn't installed or the export path changed."),e.logger.error(` Try: ${et("pnpm add @visulima/vis")}`),e.logger.error(` Or regenerate: ${et("vis init --force")}`)):e.logger.error(` Try: ${et(`pnpm add ${f}`)}`)}else d.includes("SyntaxError")||d.includes("Unexpected token")?(e.logger.error(`${Pn("→ Hint:")} The config file has a syntax error.`),e.logger.error(" Check your config for typos or invalid syntax."),e.logger.error(` Or regenerate: ${et("vis init --force")}`)):(e.logger.error(`${Pn("→ Hint:")} Delete the broken config and recreate it:`),e.logger.error(` ${et(`rm ${l} && vis init`)}`));e.logger.error(""),e.logger.error(` Continuing with default settings.
106
- `)}e.visConfig={}}const o=process.argv[2]??"";if(!new Set(["--help","--version","-h","-V","create","help","implode","init"]).has(o)&&!r&&!dt)if(process.stdin.isTTY){const c=bl({input:process.stdin,output:process.stderr}),l=await new Promise(u=>{c.question("\x1B[36;1m?\x1B[0m \x1B[1mNo vis.config.ts found. Create one with best-practice security defaults?\x1B[0m \x1B[90m(\x1B[92mY\x1B[90m/n)\x1B[0m ",u),c.on("SIGINT",()=>{c.close(),u("n")})});if(c.close(),!l.trim()||l.trim().toLowerCase()==="y"||l.trim().toLowerCase()==="yes"){const u=m(s,"vis.config.ts"),p=['import { defineConfig } from "@visulima/vis/config";',"","// Secure defaults are applied automatically by defineConfig().","// You only need to add allowBuilds for packages with build scripts.","// Run 'vis check --security-config' to see all active settings.","export default defineConfig({"," security: {"," allowBuilds: {",' // "esbuild": true,'," },"," },","});",""].join(`
102
+ `;return ce(o,c,"utf8"),n.info(`Created ${o} with ${i}`),!0},b0=(e,t)=>{const n=m(e,"package.json"),s={catalogStripped:!1,configRemoved:!1,dependencyRemoved:!1,removedScripts:[],scriptCount:0};if(!$(n))return s;const i=J(n),r=JSON.parse(i);let o=!1;r.syncpack&&(delete r.syncpack,o=!0,s.configRemoved=!0);for(const d of["dependencies","devDependencies"]){const u=r[d];u?.syncpack&&(delete u.syncpack,o=!0,s.dependencyRemoved=!0)}const a=r.workspaces;if(a&&typeof a=="object"&&!Array.isArray(a)){const d=a.catalog;d&&typeof d.syncpack=="string"&&(delete d.syncpack,o=!0,s.catalogStripped=!0);const u=a.catalogs;if(u&&typeof u=="object")for(const p of Object.values(u))p&&typeof p.syncpack=="string"&&(delete p.syncpack,o=!0,s.catalogStripped=!0)}const c=r.catalog;c&&typeof c.syncpack=="string"&&(delete c.syncpack,o=!0,s.catalogStripped=!0);const l=r.scripts;if(l){const d={};for(const[u,p]of Object.entries(l))typeof p=="string"&&ko.test(p)?(s.scriptCount+=1,s.removedScripts.push({name:u,value:p}),o=!0):d[u]=p;s.scriptCount>0&&(Object.keys(d).length===0?delete r.scripts:r.scripts=d)}if(o){const d=ls(n,i,{useEditorconfig:t});oe(n),ce(n,`${JSON.stringify(r,void 0,d)}
103
+ `,"utf8")}return s},w0=[".husky/pre-commit",".vis/hooks/pre-commit",".git/hooks/pre-commit"],k0=[".github/workflows",".gitlab-ci.yml",".circleci/config.yml",".woodpecker.yml",".drone.yml"],ru=(e,t)=>{const n=[],s=i=>{const r=m(e,i);$(r)&&ko.test(J(r))&&(n.push(i),se(t,`Update ${i} — replace \`syncpack\` invocation(s) with \`vis lint\` / \`vis sort-package-json\` as appropriate.`))};for(const i of k0){const r=m(e,i);if($(r)){if(i===".github/workflows"){try{for(const o of we(r))(o.endsWith(".yml")||o.endsWith(".yaml"))&&s(`.github/workflows/${o}`)}catch{}continue}s(i)}}return n},ou=(e,t)=>{const n=[];for(const s of w0){const i=m(e,s);$(i)&&ko.test(J(i))&&(n.push(s),se(t,`Update ${s} — replace \`syncpack\` invocation with \`vis lint\` / \`vis sort-package-json\` as appropriate.`))}return n},S0=e=>{const t=m(e,"pnpm-workspace.yaml");if(!$(t))return!1;let n;try{n=At(t)}catch{return!1}if(!n||typeof n!="object")return!1;let s=!1;const i=n.catalog;i&&typeof i.syncpack=="string"&&(delete i.syncpack,s=!0);const r=n.catalogs;if(r&&typeof r=="object")for(const o of Object.values(r))o&&typeof o.syncpack=="string"&&(delete o.syncpack,s=!0);return s&&(oe(t),Il(t,n)),s},x0=(e,t)=>{for(const n of[...Zd,...bo]){const s=m(e,n);$(s)&&(oe(s,t),gt(s),me(t,Er,"removedConfigCount"))}},$0=(e,t,n,s,i)=>{const r=eu(t,i);nu(t,i);const o=ou(e,i);o.length>0&&!n.silent&&s.warn(`Found syncpack reference in ${String(o.length)} hook file(s) — see manualSteps for details.`);const a=ru(e,i);a.length>0&&!n.silent&&s.warn(`Found syncpack reference in ${String(a.length)} CI file(s) — see manualSteps for details.`);const c=su(t,i);(r.length>0||Object.keys(c).length>0)&&v0(e,r,s,c);const{catalogStripped:l,configRemoved:d,dependencyRemoved:u,removedScripts:p,scriptCount:f}=b0(e,n.useEditorconfig);d&&!n.silent&&s.info("Removed `syncpack` block from package.json"),u&&me(i,Er,"removedPackageCount");const h=S0(e);if((l||h)&&!n.silent&&s.info("Stripped `syncpack` from catalog protocol entries."),f>0){me(i,Er,"rewrittenScriptCount",f);for(const{name:g,value:y}of p)se(i,`Recreate script \`${g}\` (removed; was \`${y}\`). Replace \`syncpack\` with \`vis lint\` / \`vis sort-package-json\` as appropriate.`);n.silent||s.info(`Removed ${String(f)} script(s) referencing \`syncpack\`. Replace with \`vis lint\` / \`vis sort-package-json\` as appropriate.`)}x0(e,i)},tc=(e,t,n,s)=>{const i=Qd(e);if(!i)return t.silent||n.info("No syncpack configuration found — nothing to migrate."),!1;const r=u0(e);r&&(ee(s,`Syncpack config ${r} is a TS/JS format vis migrate cannot load — executable config support is tracked in https://github.com/visulima/visulima/issues/622. Convert to .syncpackrc.json and re-run.`),se(s,`Convert ${r} to .syncpackrc.json (or translate it directly into policy.customTypes.extraTypes in vis.config.ts) — see https://github.com/visulima/visulima/issues/622`),t.silent||n.warn(`Cannot read ${r} — manual migration required (https://github.com/visulima/visulima/issues/622).`)),p0(e)&&(ee(s,"vis.config.ts already declares `policy.customTypes.extraTypes` — skipping syncpack customTypes merge to avoid duplicates."),t.silent||n.warn("vis.config.ts already has policy.customTypes.extraTypes — skipping merge"));const o=g0(e,i,s);if(!o)return!1;if(t.dryRun){const a=eu(o,s),c=su(o,s);nu(o,s),ou(e,s),ru(e,s);const l=iu(a,c);return t.silent||(l===""?n.info("[dry-run] No policy entries to merge — manualSteps will surface the rest."):(n.info(`[dry-run] Would merge ${l} into vis.config.ts:`),n.info(Cr(a,c)))),!0}return $0(e,o,t,n,s),!0},E0=e=>e.map(t=>{if(t.startsWith("^"))return{dependencies:!0,target:t.slice(1)};if(t.includes("#")){const[n,s]=t.split("#");return{projects:n,target:s}}return t}),C0=(e,t,n)=>{const s=e.tasks??e.pipeline??{},i={};for(const[c,l]of Object.entries(s)){if(c.includes("#"))continue;const d={};l.persistent&&(d.persistent=!0),l.interactive&&(d.interactive=!0);const u={};l.cache===!1&&(u.cache=!1),l.dependsOn&&l.dependsOn.length>0&&(u.dependsOn=E0(l.dependsOn)),l.inputs&&l.inputs.length>0&&(u.inputs=l.inputs),l.outputs&&l.outputs.length>0&&(u.outputs=l.outputs),l.env&&l.env.length>0&&(u.env=l.env),l.passThroughEnv&&l.passThroughEnv.length>0&&(u.passThroughEnv=l.passThroughEnv),Object.keys(d).length>0&&(u.options=d),i[c]=u}const r={};Object.keys(i).length>0&&(r.tasks=i);const o={};return e.globalDependencies&&e.globalDependencies.length>0&&(o.globalInputs=e.globalDependencies),e.globalEnv&&e.globalEnv.length>0&&(o.globalEnv=e.globalEnv),e.globalPassThroughEnv&&e.globalPassThroughEnv.length>0&&(o.globalPassThroughEnv=e.globalPassThroughEnv),Object.keys(o).length>0&&(r.taskRunner=o),["// Migrated from turbo.json by `vis migrate turborepo`.","// Review the generated `tasks` block and move project-specific tasks","// into each project's project.json.","",'import { defineConfig } from "@visulima/vis/config";',"",`export default defineConfig(${ho(r,m(t,"vis.config.ts"),n)});`,""].join(`
104
+ `)},nc=(e,t,n,s)=>{const i=Nd(e,"turbo.json");if(!i){n.warn("No turbo.json found in workspace root — nothing to migrate."),s.warnings.push("No turbo.json at workspace root.");return}const r=C0(i,e,t.useEditorconfig);if(!go(e,r,t,n,s))return;s.manualSteps.push("Review the `tasks` block in vis.config.ts — project-specific tasks (turbo's project#task syntax) were skipped and should be moved into each project's project.json."),s.manualSteps.push("vis adds two task primitives turbo doesn't have: `when: { os, env, branch, ci, not.* }` for conditional execution and `always: true` for finally/teardown tasks that run even when upstream fails. See docs/guides/conditional-and-finally-tasks.mdx.");const o=i.tasks??i.pipeline??{};Object.values(o).some(c=>c.outputLogs!==void 0)&&s.warnings.push("`outputLogs` was found on one or more tasks but vis has no equivalent setting — review and remove."),i.remoteCache?.enabled&&s.manualSteps.push("turbo remote cache detected. vis speaks the same HTTP protocol — set taskRunner.remoteCache { url, token, teamId } in vis.config.ts, or keep your TURBO_API / TURBO_TOKEN / TURBO_TEAM env vars (vis honours them as fallbacks).")},R0=/\b(?:husky|lint-staged|nano-staged)\b/,O0=e=>{const t=m(e,"package.json");if($(t))try{return JSON.parse(J(t))}catch{return}},j0=(e,t)=>{const n=O0(e);if(!n)return!1;const s={...n.dependencies,...n.devDependencies};for(const r of $d)if(s[r])return!0;if(n.scripts){for(const r of Object.values(n.scripts))if(typeof r=="string"&&R0.test(r))return!0}const{overrides:i}=t;return i?Object.keys(i).length>0:!1},T0=e=>$(m(e,"turbo.json")),I0=e=>$(m(e,"nx.json")),A0=e=>$(m(e,".moon")),Ae=()=>{const e=[];return{lines:e,logger:{info:t=>{e.push(t)},warn:t=>{e.push(`⚠ ${t}`)}}}},B0=[{apply:({packageManager:e,root:t,visConfig:n},s,i)=>{Ma(t,e,n,{dryRun:!1},i,s)},description:"Remove husky/lint-staged/nano-staged from package.json and rewrite scripts to `vis staged`.",detect:({root:e,visConfig:t})=>j0(e,t),id:"deps",probe:({packageManager:e,root:t,visConfig:n})=>{const{lines:s,logger:i}=Ae(),r=Oe();return Ma(t,e,n,{dryRun:!0},i,r),s},title:"Dependencies & scripts"},{apply:({root:e},t,n)=>{Ua(e,{dryRun:!1},n,t)},description:"Inline lint-staged configuration into vis.config.ts.",detect:({root:e})=>!!Bd(e),id:"lint-staged",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return Ua(e,{dryRun:!0},n,s),t},title:"lint-staged"},{apply:({root:e},t,n)=>{qa(e,{dryRun:!1},n,t)},description:"Inline nano-staged configuration into vis.config.ts.",detect:({root:e})=>!!Dd(e),id:"nano-staged",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return qa(e,{dryRun:!0},n,s),t},title:"nano-staged"},{apply:({root:e},t,n)=>{nc(e,{dryRun:!1},n,t)},description:"Translate turbo.json tasks into vis.config.ts.",detect:({root:e})=>T0(e),id:"turborepo",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return nc(e,{dryRun:!0},n,s),t},title:"Turborepo"},{apply:({root:e},t,n)=>{Ka(e,{dryRun:!1},n,t)},description:"Translate nx.json targets into vis.config.ts.",detect:({root:e})=>I0(e),id:"nx",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return Ka(e,{dryRun:!0},n,s),t},title:"Nx"},{apply:({root:e},t,n)=>{Ga(e,{copyTemplates:!1,dryRun:!1},n,t)},description:"Translate .moon/tasks.yml into vis.config.ts.",detect:({root:e})=>A0(e),id:"moon",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return Ga(e,{copyTemplates:!1,dryRun:!0},n,s),t},title:"Moon"},{apply:({root:e},t,n)=>{_a(e,{dryRun:!1},n,t)},description:"Convert gitleaks config/baseline/hooks to `vis secrets`.",detect:({root:e})=>!!(ui(e)??uo(e)??po(e)),id:"gitleaks",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return _a(e,{dryRun:!0},n,s),t},title:"Gitleaks"},{apply:({root:e},t,n)=>{Va(e,{dryRun:!1},n,t)},description:"Convert Kingfisher baseline/rules/hooks to `vis secrets`.",detect:({root:e})=>!!(fo(e)??pi(e)),id:"kingfisher",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return Va(e,{dryRun:!0},n,s),t},title:"Kingfisher"},{apply:({root:e},t,n)=>{Ya(e,{dryRun:!1},n,t)},description:"Replace secretlint config/hooks with `vis secrets`.",detect:({root:e})=>!!(Wd(e)??Hd(e)),id:"secretlint",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return Ya(e,{dryRun:!0},n,s),t},title:"Secretlint"},{apply:({root:e},t,n)=>{tc(e,{dryRun:!1},n,t)},description:"Translate syncpack customTypes into policy.customTypes.extraTypes and strip the syncpack dep/scripts.",detect:({root:e})=>!!Qd(e),id:"syncpack",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return tc(e,{dryRun:!0},n,s),t},title:"Syncpack"},{apply:({root:e},t,n)=>{Xa(e,{dryRun:!1},n,t)},description:"Strip sherif config/dep/scripts and surface ignore-rules as a positive `vis lint --<rule>` command.",detect:({root:e})=>!!Ud(e)||Gd(e),id:"sherif",probe:({root:e})=>{const{lines:t,logger:n}=Ae(),s=Oe();return Xa(e,{dryRun:!0},n,s),t},title:"Sherif"}],P0=e=>B0.filter(t=>t.detect(e)),N0=(e,t)=>({packageManager:jd(e),root:e,visConfig:t}),D0=(e,t)=>{t.info("── Migration Summary ──");const n=[["Staged configs merged into vis.config.ts",e.mergedStagedConfigCount],["Lint-staged configs inlined",e.inlinedLintStagedConfigCount],["Config files removed",e.removedConfigCount],["Packages removed",e.removedPackageCount],["Scripts rewritten",e.rewrittenScriptCount]];for(const[i,r]of n)r>0&&t.info(` ${i}: ${String(r)}`);e.gitHooksConfigured&&t.info(" Pre-commit hook updated to use vis staged");const s=Object.entries(e.perMigration);if(s.length>0){t.info(""),t.info("By migration:");for(const[i,r]of s){const o=[];r.removedConfigCount>0&&o.push(`${String(r.removedConfigCount)} config(s) removed`),r.removedPackageCount>0&&o.push(`${String(r.removedPackageCount)} package(s) removed`),r.rewrittenScriptCount>0&&o.push(`${String(r.rewrittenScriptCount)} script(s) rewritten`),t.info(` ${i}: ${o.join(", ")||"no changes"}`)}}if(e.backupsCreated.length>0&&(t.info(""),t.info(`Created ${String(e.backupsCreated.length)} .bak file(s) for rollback. Remove them once you're happy.`)),e.warnings.length>0){t.info(""),t.warn("Warnings:");for(const i of e.warnings)t.warn(` - ${i}`)}if(e.manualSteps.length>0){t.info(""),t.info("Manual steps required:");for(const i of e.manualSteps)t.info(` - ${i}`)}},L0=(e,t)=>{if(e.length===0){t.info("No applicable migrations detected in this workspace.");return}t.info(`Detected migrations (non-interactive preview):
105
+ `);for(const n of e){t.info(` • ${n.entry.title} — ${n.entry.description}`);for(const s of n.preview)t.info(` ${s}`);t.info("")}t.info("Run a specific migration with `vis migrate <name>` (e.g. `vis migrate deps`).")},M0=async e=>{const t=e.workspaceRoot??process.cwd(),n=e.visConfig??{},s=N0(t,n),r=P0(s).map(h=>({entry:h,preview:h.probe(s)}));if(!(!!process.stdout.isTTY&&!ut)){L0(r,e.logger);return}if(r.length===0){e.logger.info("No applicable migrations detected in this workspace.");return}const a=new sy(r),c=n.tui?.autoExit??!1,l=c===!0?3:typeof c=="number"?c:0,u=await Wm(Xf.createElement(Ay,{autoExitSeconds:l,isDryRun:!1,store:a}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();if(!u||u.length===0){e.logger.info("No migrations selected — exiting.");return}const p=Oe(),f=[];for(const h of u)try{e.logger.info(`── Applying ${h.entry.title} ──`),h.entry.apply(s,p,e.logger),e.logger.info("")}catch(g){f.push({entry:h.entry,error:g}),e.logger.warn(`Failed to apply ${h.entry.title}: ${g.message}`)}D0(p,e.logger),f.length>0&&(e.logger.warn(""),e.logger.warn(`${String(f.length)} migration(s) failed — see messages above.`),process.exitCode=1)},_0={beforeCommand:async e=>{try{const t=e.options?.cwd,n=e.options?.config;let s;if(t)s=un(process.cwd(),t);else{const c=process.env.VIS_MONOREPO_ROOT;s=c&&c.length>0?c:Tl(process.cwd()).path}e.workspaceRoot=s;const i=n?un(process.cwd(),n):void 0;let r=i??_t(s);try{e.visConfig=await ta(s,i?{explicitConfigPath:i}:void 0);const c=e.visConfig?.versionConstraint;if(c&&!pr.validRange(c)){e.logger.error(""),e.logger.error(xi(Le("✖ Invalid versionConstraint"))),e.logger.error(` vis.config.ts has versionConstraint ${Le(JSON.stringify(c))}, which is not a valid semver range.`),e.logger.error(""),process.exitCode=1;return}if(c&&!pr.satisfies(Ws(),c)){e.logger.error(""),e.logger.error(xi(Le("✖ vis version too old"))),e.logger.error(` vis.config.ts requires vis ${Le(c)}, but the current version is ${Le(Ws())}.`),e.logger.error(` ${Bn("→")} Upgrade: ${et("pnpm add -D @visulima/vis@latest")}`),e.logger.error(""),process.exitCode=1;return}}catch(c){const l=r,d=c instanceof Error?c.message:String(c);e.visConfigError={file:l??void 0,message:d};const u=!!process.stdout.isTTY&&!ut;if(l&&!u){if(e.logger.error(""),e.logger.error(xi(Le(`✖ Failed to load ${l}`))),e.logger.error(` ${d}`),e.logger.error(""),d.includes("Cannot find module")){const f=/Cannot find module '([^']+)'/.exec(d)?.[1]??"unknown";e.logger.error(`${Bn("→ Hint:")} The module ${Le(f)} could not be resolved.`),f.includes("@visulima/vis")?(e.logger.error(" This usually means the package isn't installed or the export path changed."),e.logger.error(` Try: ${et("pnpm add @visulima/vis")}`),e.logger.error(` Or regenerate: ${et("vis init --force")}`)):e.logger.error(` Try: ${et(`pnpm add ${f}`)}`)}else d.includes("SyntaxError")||d.includes("Unexpected token")?(e.logger.error(`${Bn("→ Hint:")} The config file has a syntax error.`),e.logger.error(" Check your config for typos or invalid syntax."),e.logger.error(` Or regenerate: ${et("vis init --force")}`)):(e.logger.error(`${Bn("→ Hint:")} Delete the broken config and recreate it:`),e.logger.error(` ${et(`rm ${l} && vis init`)}`));e.logger.error(""),e.logger.error(` Continuing with default settings.
106
+ `)}e.visConfig={}}const o=process.argv[2]??"";if(!new Set(["--help","--version","-h","-V","create","help","implode","init"]).has(o)&&!r&&!ut)if(process.stdin.isTTY){const c=Sl({input:process.stdin,output:process.stderr}),l=await new Promise(u=>{c.question("\x1B[36;1m?\x1B[0m \x1B[1mNo vis.config.ts found. Create one with best-practice security defaults?\x1B[0m \x1B[90m(\x1B[92mY\x1B[90m/n)\x1B[0m ",u),c.on("SIGINT",()=>{c.close(),u("n")})});if(c.close(),!l.trim()||l.trim().toLowerCase()==="y"||l.trim().toLowerCase()==="yes"){const u=m(s,"vis.config.ts"),p=['import { defineConfig } from "@visulima/vis/config";',"","// Secure defaults are applied automatically by defineConfig().","// You only need to add allowBuilds for packages with build scripts.","// Run 'vis check --security-config' to see all active settings.","export default defineConfig({"," security: {"," allowBuilds: {",' // "esbuild": true,'," },"," },","});",""].join(`
107
107
  `);ce(u,p),e.logger.info(`✓ Created ${u}
108
- `),e.visConfig=await Qo(s),r=u}}else e.logger.warn("No vis.config.ts found. Run 'vis init' to create one with best-practice security defaults.")}catch(t){t instanceof Error&&!t.message.includes("monorepo root")&&e.logger.warn(`Failed to detect workspace: ${t.message}`),e.visConfig={}}},name:"config-loader"},D0=336*60*60*1e3,Cr=m(mt(),"mcp-promote.json"),vt="@visulima/vis-mcp",L0=new Set(["--help","--version","-h","-V","ai","help","implode","mcp"]),M0=()=>{try{if($(Cr))return de(Cr)}catch{}return{lastShown:0}},_0=e=>{try{gt(mt()),ye(Cr,JSON.stringify(e))}catch{}},vn=e=>{try{return $(e)?de(e):void 0}catch{return}},bn=e=>{if(typeof e!="object"||e===null)return!1;for(const t of Object.values(e)){if(typeof t!="object"||t===null)continue;const n=t,s=Array.isArray(n.args)?n.args.join(" "):"",i=`${typeof n.command=="string"?n.command:""} ${s}`;if(i.includes(vt)||i.includes("vis-mcp"))return!0}return!1},F0=e=>{if(!Array.isArray(e))return!1;for(const t of e){if(typeof t!="object"||t===null)continue;const n=t,s=Array.isArray(n.args)?n.args.join(" "):"",i=`${typeof n.command=="string"?n.command:""} ${s} ${typeof n.name=="string"?n.name:""}`;if(i.includes(vt)||i.includes("vis-mcp"))return!0}return!1},V0=e=>{const t=m(e,".claude"),n=m(e,".claude.json"),s=$(t)||$(n);let i=!1;if(s){const r=vn(n);i=bn(r?.mcpServers)}return{displayName:"Claude Code",id:"claude-code",installCommand:`claude mcp add vis -- npx -y ${vt}@latest`,isConfigured:i,isInstalled:s}},W0=e=>{const t=m(e,".cursor","mcp.json"),n=$(m(e,".cursor"));let s=!1;if(n){const i=vn(t);s=bn(i?.mcpServers)}return{displayName:"Cursor",id:"cursor",installCommand:`Add to ~/.cursor/mcp.json: "vis": { "command": "npx", "args": ["-y", "${vt}@latest"] }`,isConfigured:s,isInstalled:n}},H0=e=>{const t=m(e,".codeium","windsurf"),n=m(t,"mcp_config.json"),s=$(t);let i=!1;if(s){const r=vn(n);i=bn(r?.mcpServers)}return{displayName:"Windsurf",id:"windsurf",installCommand:`Add to ~/.codeium/windsurf/mcp_config.json: "vis": { "command": "npx", "args": ["-y", "${vt}@latest"] }`,isConfigured:i,isInstalled:s}},U0=e=>{const t=m(e,".continue"),n=m(t,"config.json"),s=$(t);let i=!1;if(s){const r=vn(n);i=bn(r?.mcpServers)||F0(r?.mcpServers)}return{displayName:"Continue",id:"continue",installCommand:`Add to ~/.continue/config.json mcpServers: { "name": "vis", "command": "npx", "args": ["-y", "${vt}@latest"] }`,isConfigured:i,isInstalled:s}},G0=e=>{const t=m(e,"Library","Application Support","Zed","settings.json"),n=m(e,".config","zed","settings.json"),s=uh()==="darwin"?t:n,i=$(s);let r=!1;if(i){const o=vn(s);r=bn(o?.context_servers)}return{displayName:"Zed",id:"zed",installCommand:`Add to Zed settings.json under context_servers: "vis": { "command": "npx", "args": ["-y", "${vt}@latest"] }`,isConfigured:r,isInstalled:i}},z0=e=>{const t=[m(e,".config","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"),m(e,"Library","Application Support","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json")];let n;for(const r of t)if($(r)){n=r;break}const s=n!==void 0;let i=!1;if(n!==void 0){const r=vn(n);i=bn(r?.mcpServers)}return{displayName:"Cline",id:"cline",installCommand:`In VS Code: open Cline > MCP Servers, add "vis" with command "npx" and args ["-y", "${vt}@latest"]`,isConfigured:i,isInstalled:s}},J0=()=>{const e=dh();return[V0(e),W0(e),H0(e),U0(e),G0(e),z0(e)]},q0=e=>{if(!e.success||process.env.VIS_CLI_TEST||dt||process.env.VIS_NO_MCP_PROMOTE==="1"||e.visConfig?.mcpPromote?.enabled===!1||!process.stderr.isTTY||e.command!==void 0&&L0.has(e.command))return!1;const t=new Set(process.argv.slice(2));return!(t.has("--silent")||t.has("-s")||t.has("--json"))},K0=e=>{if(!q0(e))return;const t=Date.now(),n=M0();if(t-n.lastShown<D0)return;const i=J0().find(r=>r.isInstalled&&!r.isConfigured);i!==void 0&&(process.stderr.write(`
108
+ `),e.visConfig=await ta(s),r=u}}else e.logger.warn("No vis.config.ts found. Run 'vis init' to create one with best-practice security defaults.")}catch(t){t instanceof Error&&!t.message.includes("monorepo root")&&e.logger.warn(`Failed to detect workspace: ${t.message}`),e.visConfig={}}},name:"config-loader"},F0=336*60*60*1e3,Rr=m(yt(),"mcp-promote.json"),bt="@visulima/vis-mcp",V0=new Set(["--help","--version","-h","-V","ai","help","implode","mcp"]),W0=()=>{try{if($(Rr))return de(Rr)}catch{}return{lastShown:0}},H0=e=>{try{mt(yt()),ye(Rr,JSON.stringify(e))}catch{}},vn=e=>{try{return $(e)?de(e):void 0}catch{return}},bn=e=>{if(typeof e!="object"||e===null)return!1;for(const t of Object.values(e)){if(typeof t!="object"||t===null)continue;const n=t,s=Array.isArray(n.args)?n.args.join(" "):"",i=`${typeof n.command=="string"?n.command:""} ${s}`;if(i.includes(bt)||i.includes("vis-mcp"))return!0}return!1},U0=e=>{if(!Array.isArray(e))return!1;for(const t of e){if(typeof t!="object"||t===null)continue;const n=t,s=Array.isArray(n.args)?n.args.join(" "):"",i=`${typeof n.command=="string"?n.command:""} ${s} ${typeof n.name=="string"?n.name:""}`;if(i.includes(bt)||i.includes("vis-mcp"))return!0}return!1},G0=e=>{const t=m(e,".claude"),n=m(e,".claude.json"),s=$(t)||$(n);let i=!1;if(s){const r=vn(n);i=bn(r?.mcpServers)}return{displayName:"Claude Code",id:"claude-code",installCommand:`claude mcp add vis -- npx -y ${bt}@latest`,isConfigured:i,isInstalled:s}},z0=e=>{const t=m(e,".cursor","mcp.json"),n=$(m(e,".cursor"));let s=!1;if(n){const i=vn(t);s=bn(i?.mcpServers)}return{displayName:"Cursor",id:"cursor",installCommand:`Add to ~/.cursor/mcp.json: "vis": { "command": "npx", "args": ["-y", "${bt}@latest"] }`,isConfigured:s,isInstalled:n}},J0=e=>{const t=m(e,".codeium","windsurf"),n=m(t,"mcp_config.json"),s=$(t);let i=!1;if(s){const r=vn(n);i=bn(r?.mcpServers)}return{displayName:"Windsurf",id:"windsurf",installCommand:`Add to ~/.codeium/windsurf/mcp_config.json: "vis": { "command": "npx", "args": ["-y", "${bt}@latest"] }`,isConfigured:i,isInstalled:s}},q0=e=>{const t=m(e,".continue"),n=m(t,"config.json"),s=$(t);let i=!1;if(s){const r=vn(n);i=bn(r?.mcpServers)||U0(r?.mcpServers)}return{displayName:"Continue",id:"continue",installCommand:`Add to ~/.continue/config.json mcpServers: { "name": "vis", "command": "npx", "args": ["-y", "${bt}@latest"] }`,isConfigured:i,isInstalled:s}},K0=e=>{const t=m(e,"Library","Application Support","Zed","settings.json"),n=m(e,".config","zed","settings.json"),s=gh()==="darwin"?t:n,i=$(s);let r=!1;if(i){const o=vn(s);r=bn(o?.context_servers)}return{displayName:"Zed",id:"zed",installCommand:`Add to Zed settings.json under context_servers: "vis": { "command": "npx", "args": ["-y", "${bt}@latest"] }`,isConfigured:r,isInstalled:i}},Y0=e=>{const t=[m(e,".config","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json"),m(e,"Library","Application Support","Code","User","globalStorage","saoudrizwan.claude-dev","settings","cline_mcp_settings.json")];let n;for(const r of t)if($(r)){n=r;break}const s=n!==void 0;let i=!1;if(n!==void 0){const r=vn(n);i=bn(r?.mcpServers)}return{displayName:"Cline",id:"cline",installCommand:`In VS Code: open Cline > MCP Servers, add "vis" with command "npx" and args ["-y", "${bt}@latest"]`,isConfigured:i,isInstalled:s}},X0=()=>{const e=hh();return[G0(e),z0(e),J0(e),q0(e),K0(e),Y0(e)]},Z0=e=>{if(!e.success||process.env.VIS_CLI_TEST||ut||process.env.VIS_NO_MCP_PROMOTE==="1"||e.visConfig?.mcpPromote?.enabled===!1||!process.stderr.isTTY||e.command!==void 0&&V0.has(e.command))return!1;const t=new Set(process.argv.slice(2));return!(t.has("--silent")||t.has("-s")||t.has("--json"))},Q0=e=>{if(!Z0(e))return;const t=Date.now(),n=W0();if(t-n.lastShown<F0)return;const i=X0().find(r=>r.isInstalled&&!r.isConfigured);i!==void 0&&(process.stderr.write(`
109
109
  ${et("✨")} ${Le(`vis ships an MCP server for ${i.displayName}.`)}
110
110
  ${i.installCommand}
111
- ${sn("Hide this with VIS_NO_MCP_PROMOTE=1 or mcpPromote: { enabled: false } in vis.config.ts")}
112
- `),_0({lastShown:t}))},Y0=336*60*60*1e3,X0="https://github.com/sponsors/prisis",Rr=m(mt(),"sponsor.json"),Z0=()=>{try{if($(Rr))return de(Rr)}catch{}return{lastShown:0}},Q0=e=>{try{gt(mt()),ye(Rr,JSON.stringify(e))}catch{}},ew=e=>{if(!e.success||process.env.VIS_CLI_TEST||dt||process.env.VIS_NO_SPONSOR==="1"||e.visConfig?.sponsor?.enabled===!1||!process.stderr.isTTY)return;const t=Date.now(),n=Z0();t-n.lastShown<Y0||(process.stderr.write(`
113
- ${ch("♥")} ${Le("Enjoying visulima?")} ${sn(`Consider sponsoring at ${X0}`)}
114
- ${sn(" Hide this with VIS_NO_SPONSOR=1 or sponsor.enabled = false in vis.config.ts")}
115
- `),Q0({lastShown:t}))},tc=300*1e3,Or=m(mt(),"tips.json"),tw=()=>{try{if($(Or))return de(Or)}catch{}return{lastGlobal:0,perTip:{}}},nw=e=>{try{gt(mt()),ye(Or,JSON.stringify(e))}catch{}},sw=[{cooldownMs:1800*1e3,id:"short-aliases",matches:e=>["install","link","remove","uninstall","update"].includes(e.command),message:e=>{const n={install:"i",link:"ln",remove:"rm",uninstall:"rm",update:"up"}[e.command];return n?`You can use 'vis ${n}' as a shorthand for 'vis ${e.command}'`:""},probability:.5},{id:"use-exec",matches:e=>e.command==="dlx"&&e.success,message:()=>"Use 'vis exec' to run locally installed binaries without downloading."},{id:"security-check",matches:e=>(e.command==="check"||e.command==="update")&&e.success&&!e.args.includes("--security"),message:()=>"Add --security to check for known vulnerabilities via OSV.dev",probability:.3},{cooldownMs:3600*1e3,id:"ai-analysis",matches:e=>(e.command==="check"||e.command==="update")&&e.success&&!e.args.includes("--ai"),message:()=>"Add --ai to run AI analysis on outdated packages before updating.",probability:.2},{cooldownMs:1440*60*1e3,id:"socket-security",matches:e=>(e.command==="install"||e.command==="update"||e.command==="check")&&e.success,message:()=>"Enable Socket.dev in vis.config.ts for security scores and supply chain alerts: security.socket.enabled = true",probability:.15},{id:"dedupe-after-install",matches:e=>e.command==="install"&&e.success,message:()=>"Run 'vis dedupe' periodically to remove duplicate dependencies.",probability:.15},{cooldownMs:720*60*1e3,id:"doctor-checkup",matches:e=>(e.command==="install"||e.command==="add"||e.command==="update")&&e.success,message:()=>"Run 'vis doctor' for a full project health check — outdated, security, duplicates, and optimizations in one view.",probability:.25},{cooldownMs:10080*60*1e3,id:"init-config",matches:e=>(e.command==="install"||e.command==="run")&&e.success&&!e.hasVisConfig,message:()=>"Run 'vis init' to create a vis.config.ts with secure defaults — supply chain protection enabled automatically.",probability:.4},{id:"why-command",matches:e=>e.command==="outdated"&&e.success,message:()=>"Use 'vis why <package>' to understand why a dependency is installed.",probability:.3},{id:"graph-command",matches:e=>e.command==="run"&&e.success,message:()=>"Use 'vis graph' to visualize your project dependency graph.",probability:.1},{id:"affected-command",matches:e=>e.command==="run"&&e.success&&!e.args.includes("--projects"),message:()=>"Use 'vis affected <target>' to run tasks only on changed projects.",probability:.2},{id:"pm-cache",matches:e=>e.command==="install"&&e.success,message:()=>"Use 'vis pm cache dir' to find your package manager's cache location.",probability:.1},{id:"create-editor",matches:e=>e.command==="create"&&e.success,message:()=>"Add --editor vscode to generate VS Code configuration during project creation.",probability:.5},{id:"env-pin",matches:e=>e.command==="env"&&e.args.includes("install")&&e.success,message:()=>"Use 'vis env pin <version>' to pin the Node.js version for your project.",probability:.5},{cooldownMs:720*60*1e3,id:"docker-lint",matches:e=>!!e.hasDockerfile&&e.success&&e.command!=="docker",message:()=>"Found a Dockerfile — run 'vis docker lint' to check it against hadolint best practices.",probability:.3},{cooldownMs:1440*60*1e3,id:"docker-ignore",matches:e=>!!e.hasDockerfile&&!e.hasDockerignore&&e.success&&e.command!=="ignore",message:()=>"No .dockerignore next to your Dockerfile — run 'vis ignore --write' to shrink the build context.",probability:.4},{cooldownMs:1440*60*1e3,id:"vercel-ignore",matches:e=>!!e.hasVercelConfig&&e.success&&e.command!=="ignore",message:()=>"Deploying to Vercel? Run 'vis ignore --target=vercel --write' to generate a deduped .vercelignore.",probability:.25},{id:"upgrade-check",matches:e=>e.command!=="self-update"&&e.success,message:()=>"Run 'vis self-update --check' to see if a newer version of vis is available.",probability:.05}],iw=e=>{if(process.env.VIS_CLI_TEST||dt)return;const t=Date.now(),n=tw();if(t-n.lastGlobal<tc)return;const s=sw.filter(o=>{if(!o.matches(e))return!1;const a=n.perTip[o.id]??0,c=o.cooldownMs??tc;return t-a>=c});if(s.length===0)return;const i=s.find(o=>{const a=o.probability??1;return Math.random()<a});if(!i)return;const r=i.message(e);r&&(process.stderr.write(`
111
+ ${rn("Hide this with VIS_NO_MCP_PROMOTE=1 or mcpPromote: { enabled: false } in vis.config.ts")}
112
+ `),H0({lastShown:t}))},ew=336*60*60*1e3,tw="https://github.com/sponsors/prisis",Or=m(yt(),"sponsor.json"),nw=()=>{try{if($(Or))return de(Or)}catch{}return{lastShown:0}},sw=e=>{try{mt(yt()),ye(Or,JSON.stringify(e))}catch{}},iw=e=>{if(!e.success||process.env.VIS_CLI_TEST||ut||process.env.VIS_NO_SPONSOR==="1"||e.visConfig?.sponsor?.enabled===!1||!process.stderr.isTTY)return;const t=Date.now(),n=nw();t-n.lastShown<ew||(process.stderr.write(`
113
+ ${ph("♥")} ${Le("Enjoying visulima?")} ${rn(`Consider sponsoring at ${tw}`)}
114
+ ${rn(" Hide this with VIS_NO_SPONSOR=1 or sponsor.enabled = false in vis.config.ts")}
115
+ `),sw({lastShown:t}))},sc=300*1e3,jr=m(yt(),"tips.json"),rw=()=>{try{if($(jr))return de(jr)}catch{}return{lastGlobal:0,perTip:{}}},ow=e=>{try{mt(yt()),ye(jr,JSON.stringify(e))}catch{}},aw=[{cooldownMs:1800*1e3,id:"short-aliases",matches:e=>["install","link","remove","uninstall","update"].includes(e.command),message:e=>{const n={install:"i",link:"ln",remove:"rm",uninstall:"rm",update:"up"}[e.command];return n?`You can use 'vis ${n}' as a shorthand for 'vis ${e.command}'`:""},probability:.5},{id:"use-exec",matches:e=>e.command==="dlx"&&e.success,message:()=>"Use 'vis exec' to run locally installed binaries without downloading."},{id:"security-check",matches:e=>(e.command==="check"||e.command==="update")&&e.success&&!e.args.includes("--security"),message:()=>"Add --security to check for known vulnerabilities via OSV.dev",probability:.3},{cooldownMs:3600*1e3,id:"ai-analysis",matches:e=>(e.command==="check"||e.command==="update")&&e.success&&!e.args.includes("--ai"),message:()=>"Add --ai to run AI analysis on outdated packages before updating.",probability:.2},{cooldownMs:1440*60*1e3,id:"socket-security",matches:e=>(e.command==="install"||e.command==="update"||e.command==="check")&&e.success,message:()=>"Enable Socket.dev in vis.config.ts for security scores and supply chain alerts: security.socket.enabled = true",probability:.15},{id:"dedupe-after-install",matches:e=>e.command==="install"&&e.success,message:()=>"Run 'vis dedupe' periodically to remove duplicate dependencies.",probability:.15},{cooldownMs:720*60*1e3,id:"doctor-checkup",matches:e=>(e.command==="install"||e.command==="add"||e.command==="update")&&e.success,message:()=>"Run 'vis doctor' for a full project health check — outdated, security, duplicates, and optimizations in one view.",probability:.25},{cooldownMs:10080*60*1e3,id:"init-config",matches:e=>(e.command==="install"||e.command==="run")&&e.success&&!e.hasVisConfig,message:()=>"Run 'vis init' to create a vis.config.ts with secure defaults — supply chain protection enabled automatically.",probability:.4},{id:"why-command",matches:e=>e.command==="outdated"&&e.success,message:()=>"Use 'vis why <package>' to understand why a dependency is installed.",probability:.3},{id:"graph-command",matches:e=>e.command==="run"&&e.success,message:()=>"Use 'vis graph' to visualize your project dependency graph.",probability:.1},{id:"affected-command",matches:e=>e.command==="run"&&e.success&&!e.args.includes("--projects"),message:()=>"Use 'vis affected <target>' to run tasks only on changed projects.",probability:.2},{id:"pm-cache",matches:e=>e.command==="install"&&e.success,message:()=>"Use 'vis pm cache dir' to find your package manager's cache location.",probability:.1},{id:"create-editor",matches:e=>e.command==="create"&&e.success,message:()=>"Add --editor vscode to generate VS Code configuration during project creation.",probability:.5},{id:"env-pin",matches:e=>e.command==="env"&&e.args.includes("install")&&e.success,message:()=>"Use 'vis env pin <version>' to pin the Node.js version for your project.",probability:.5},{cooldownMs:720*60*1e3,id:"docker-lint",matches:e=>!!e.hasDockerfile&&e.success&&e.command!=="docker",message:()=>"Found a Dockerfile — run 'vis docker lint' to check it against hadolint best practices.",probability:.3},{cooldownMs:1440*60*1e3,id:"docker-ignore",matches:e=>!!e.hasDockerfile&&!e.hasDockerignore&&e.success&&e.command!=="ignore",message:()=>"No .dockerignore next to your Dockerfile — run 'vis ignore --write' to shrink the build context.",probability:.4},{cooldownMs:1440*60*1e3,id:"vercel-ignore",matches:e=>!!e.hasVercelConfig&&e.success&&e.command!=="ignore",message:()=>"Deploying to Vercel? Run 'vis ignore --target=vercel --write' to generate a deduped .vercelignore.",probability:.25},{id:"upgrade-check",matches:e=>e.command!=="self-update"&&e.success,message:()=>"Run 'vis self-update --check' to see if a newer version of vis is available.",probability:.05}],cw=e=>{if(process.env.VIS_CLI_TEST||ut)return;const t=Date.now(),n=rw();if(t-n.lastGlobal<sc)return;const s=aw.filter(o=>{if(!o.matches(e))return!1;const a=n.perTip[o.id]??0,c=o.cooldownMs??sc;return t-a>=c});if(s.length===0)return;const i=s.find(o=>{const a=o.probability??1;return Math.random()<a});if(!i)return;const r=i.message(e);r&&(process.stderr.write(`
116
116
  \x1B[2mtip: ${r}\x1B[0m
117
- `),n.lastGlobal=t,n.perTip[i.id]=t,nw(n))},rw=e=>({afterCommand:async t=>{const n=process.argv.slice(2),s=n[0]??"",i=process.exitCode===void 0||process.exitCode===0;e&&e();const r=t.workspaceRoot??process.cwd();iw({args:n,command:s,hasDockerfile:$(m(r,"Dockerfile")),hasDockerignore:$(m(r,".dockerignore")),hasVercelConfig:$(m(r,"vercel.json"))||$(m(r,".vercel")),hasVisConfig:t.visConfig!==void 0&&Object.keys(t.visConfig).length>0,success:i}),ew({success:i,visConfig:t.visConfig}),K0({command:s,success:i,visConfig:t.visConfig})},name:"post-command"});let ow;const aw=e=>(ow??=Ne(import.meta.url))(e),Xt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ko=e=>{if(typeof Xt<"u"&&Xt.versions&&Xt.versions.node){const[t,n]=Xt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Xt.getBuiltinModule(e)}return aw(e)},Ot=Xt,{execFileSync:cw}=ko("node:child_process"),Dn=ko("node:fs"),lw=ko("node:tty"),dw=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],uw=12288,pw=65510,fw=[12288,12288,65281,65376,65504,65510],hw=8361,gw=65518,mw=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],yw=32,vw=10630,bw=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],ww=4352,kw=262141,iu=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],cs=(e,t)=>{let n=0,s=Math.floor(e.length/2)-1;for(;n<=s;){const i=Math.floor((n+s)/2),r=i*2;if(t<e[r])s=i-1;else if(t>e[r+1])n=i+1;else return!0}return!1},nc=19968,[Sw,xw]=$w(iu);function $w(e){let t=e[0],n=e[1];for(let s=0;s<e.length;s+=2){const i=e[s],r=e[s+1];if(nc>=i&&nc<=r)return[i,r];r-i>n-t&&(t=i,n=r)}return[t,n]}const Ew=e=>e<161||e>1114109?!1:cs(dw,e),Cw=e=>e<uw||e>pw?!1:cs(fw,e),Rw=e=>e<hw||e>gw?!1:cs(mw,e),Ow=e=>e<yw||e>vw?!1:cs(bw,e),jw=e=>e>=Sw&&e<=xw?!0:e<ww||e>kw?!1:cs(iu,e);function Tw(e){return Ew(e)?"ambiguous":Cw(e)?"fullwidth":Rw(e)?"halfwidth":Ow(e)?"narrow":jw(e)?"wide":"neutral"}function Iw(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function ru(e){return Iw(e),Tw(e)}const ou=String.raw,sc=ou`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Aw=()=>new RegExp(ou`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${sc}(?:\u200D${sc})*`,"gu"),wn=new Set(["\x1B","›"]),gi="\x07",au="[",So="m",Qn="]8;;",Pw=39,Bw=/[\u200B\uFEFF\u2060-\u2064]/g,Nw=new RegExp(`(?:\\${au}(?<code>\\d+)m|\\${Qn}(?<uri>.*)${gi})`),Dw=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),cu=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,ks=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,Lw=Aw(),ic=new Map,Mw=e=>[e.ambiguousIsNarrow?1:0,e.control,e.fullWidth,e.regular,e.wide].join("|"),_w=e=>{const t=Mw(e.width);let n=ic.get(t);return n||(n=new Map,ic.set(t,n)),n},Ss=new RegExp(cu.source,"y"),Di=new RegExp(Lw.source,"uy"),xs=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,lu=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",Fw=(e,t)=>{const n=_w(t),s=Math.floor(e/65536),i=e%65536;let r=n.get(s);if(r||(r=new Map,n.set(s,r)),r.has(i))return r.get(i);let o;switch(lu(e)){case"control":{o=t.width.control;break}case"latin":{o=t.width.regular;break}case"wide":{o=t.width.wide;break}case"zero":{o=0;break}default:switch(ru(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}}return r.set(i,o),o},Vw=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,jr=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?jr(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},s=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:i}=e,r=i>1e4;let o=0,a=0,c=i,l=!1;const d=e.includes("\x1B")||e.includes("›");for(;o<i;){if(d&&(e[o]==="\x1B"||e[o]==="›")){if(e.startsWith("\x1B]8;;",o)){const y="\x1B]8;;\x07",x=y.length,b=e.indexOf("\x07",o+5);if(b!==-1){const S=e.indexOf(y,b+1);if(S!==-1){const C=S+x,N=e.slice(b+1,S).replace(cu,""),T=jr(N,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,s-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),D=T.width;if(T.truncated)l=!0,c=Math.min(c,o);else if(a+D>s&&(c=Math.min(c,o),l=!0,a+D>n.truncation.limit))break;if(a+=D,o=C,l&&a>=n.truncation.limit)break;continue}}}if(Ss.lastIndex=o,Ss.test(e)){const y=Ss.lastIndex-o,x=n.truncation.countAnsiEscapeCodes?y:n.width.ansi;if(a+x>s&&(c=Math.min(c,o),a+x>n.truncation.limit)){l=!0;break}a+=x,o=Ss.lastIndex;continue}}const f=e.codePointAt(o);if(f===8203||f===65279||f>=8288&&f<=8292){o+=1;continue}if(f===9){if(a+n.width.tab>s&&(c=Math.min(c,o),a+n.width.tab>n.truncation.limit)){l=!0;break}a+=n.width.tab,o+=1;continue}if(xs.lastIndex=o,xs.test(e)){const y=(xs.lastIndex-o)*n.width.regular;if(a+y>s){const x=n.width.regular>0?Math.floor((s-a)/n.width.regular):0;if(c=Math.min(c,o+x),a+y>n.truncation.limit){l=!0;break}}a+=y,o=xs.lastIndex;continue}if((f<=31||f>=127&&f<=159)&&(ks.lastIndex=o,ks.test(e))){const y=(ks.lastIndex-o)*n.width.control;if(a+y>s){const x=n.width.control>0?Math.floor((s-a)/n.width.control):0;if(c=Math.min(c,o+x),a+y>n.truncation.limit){l=!0;break}}a+=y,o=ks.lastIndex;continue}if(Di.lastIndex=o,Di.test(e)){if(a+n.width.emoji>s&&(c=Math.min(c,o),a+n.width.emoji>n.truncation.limit)){l=!0;break}a+=n.width.emoji,o=Di.lastIndex;continue}const h=e.codePointAt(o)??0;if(Vw(h)){o+=h>65535?2:1;continue}let g;if(r)g=Fw(h,n);else switch(lu(h)){case"control":{g=n.width.control;break}case"latin":{g=n.width.regular;break}case"wide":{g=n.width.wide;break}case"zero":{g=0;break}default:switch(ru(h)){case"ambiguous":{g=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{g=n.width.fullWidth;break}case"wide":{g=n.width.wide;break}default:g=n.width.regular}}if(a+g>s&&(c=Math.min(c,o),a+g>n.truncation.limit)){l=!0;break}a+=g,o+=h>65535?2:1}let u=a,p=!1;return l&&n.truncation.limit>=n.truncation.ellipsisWidth&&(u=n.truncation.limit,p=!0),{ellipsed:p,index:l?c:i,truncated:l,width:u}},ut=(e,t={})=>jr(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,Ww=/\x1B\[(\d+)m/;let du=class{activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const n=Ww.exec(t);if(!n)return;const s=Number.parseInt(n[1],10);switch(s){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(s>=30&&s<=37||s>=90&&s<=97)this.activeForeground=t;else if(s>=40&&s<=47||s>=100&&s<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(s))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(s)){const i={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[s];i&&(this.activeFormatting=this.activeFormatting.filter(r=>!r.includes(i)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const n={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(s=>{const i=n[s];i&&t.push(i)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}};const Hw=(e,t)=>{if(!wn.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const n=!0,s=e.slice(t+1,t+1+Qn.length).join("")===Qn;return{isInsideEscape:n,isInsideLinkEscape:s}},Uw=(e,t={})=>{const n=new du;let s="",i=!1,r="",o="",a=!1;const c=[...e];for(let l=0;l<c.length;l++){const d=c[l];if(d&&wn.has(d)){if(s){const g=t.getWidth?.(s)??0,y={isEscapeSequence:!1,isGrapheme:!0,text:s,width:g};if(a&&(y.isHyperlink=!0,y.hyperlinkUrl=o),t.onSegment?.(y,n)===!1)return;s=""}i=!0,r=d;const f=Hw(c,l),{isInsideLinkEscape:h}=f;if(h){let g=l+1;for(o="";g<c.length;){const x=c[g];if(x===gi)break;o+=x,g+=1}o=o.slice(4);const y={hyperlinkUrl:o,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(y,n)===!1)return;l=g,a=!0,i=!1,r="";continue}if(l+1<c.length&&c[l+1]==="\\"&&a){const g={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(g,n)===!1)return;a=!1,o="",l+=1,i=!1,r="";continue}}if(i){if(r!==d&&(r+=d),d===So){i=!1,n.processEscape(r);const f={isEscapeSequence:!0,isGrapheme:!1,text:r,width:0};if(t.onSegment?.(f,n)===!1)return;r=""}continue}s+=d;const u=t.getWidth?.(s)??0,p={isEscapeSequence:!1,isGrapheme:!0,text:s,width:u};if(a&&(p.isHyperlink=!0,p.hyperlinkUrl=o),t.onSegment?.(p,n)===!1)return;s=""}if(s){const l=t.getWidth?.(s)??0,d={isEscapeSequence:!1,isGrapheme:!0,text:s,width:l};a&&(d.isHyperlink=!0,d.hyperlinkUrl=o),t.onSegment?.(d,n)}if(r){const l={isEscapeSequence:!0,isGrapheme:!1,text:r,width:0};t.onSegment?.(l,n)}},rc=e=>`${wn.values().next().value}${au}${String(e)}${So}`,oc=e=>`${wn.values().next().value}${Qn}${e}${gi}`,Gw=e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",n,s;const i=e.join(`
118
- `),r=[...i];let o=0;for(const[a,c]of r.entries()){if(t+=c,wn.has(c)){const d=Nw.exec(i.slice(o))?.groups??{};if(d.code!==void 0){const u=Number.parseFloat(d.code);n=u===Pw?void 0:u}else d.uri!==void 0&&(s=d.uri.length===0?void 0:d.uri)}const l=Dw.get(Number(n));r[a+1]===`
119
- `?(s&&(t+=oc("")),n&&l&&(t+=rc(l))):c===`
120
- `&&(n&&l&&(t+=rc(n)),s&&(t+=oc(s))),o+=c.length}return t},uu=/(?=\s)|(?<=\s)/,pu=/^\s+$/,ac=new Map,zw=e=>{const t=ac.get(e);if(t!==void 0)return t;const n=ut(e);return ac.set(e,n),n},Li=e=>{if(!e.includes("\x1B"))return e;let t=e;return e.includes("\x1B[30m")&&(t+="\x1B[39m"),e.includes("\x1B[42m")&&(t+="\x1B[49m"),t},jt=e=>{const t=e.split(" ");let n=t.length;for(;n>0&&ut(t[n-1])===0;)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},fu=(e,t,n)=>{if(e.length===0)return[""];if(t<=0)return[e];const s=[],i=new du;let r="",o=0,a=!1,c=!1,l="",d=0;for(;d<e.length;){const u=e.codePointAt(d),p=String.fromCodePoint(u),f=p.length;if(wn.has(p)){a=!0,l=p,r+=p,c=e.startsWith(Qn,d+1),d+=1;continue}if(a){l+=p,r+=p,c?p===gi&&(a=c=!1):p===So&&(a=!1,i.processEscape(l)),d+=1;continue}const h=zw(p),g=p===" ";if(h===0){r+=p,d+=f;continue}if(o+h>t&&(r&&s.push(r+i.getEndEscapesForAllActiveAttributes()),r=i.getStartEscapesForAllActiveAttributes(),o=ut(r),g&&n)){for(;d<e.length&&e[d]===" ";)d+=1;continue}if(r+=p,o+=h,o===t&&d+f<e.length&&(s.push(r+i.getEndEscapesForAllActiveAttributes()),r=i.getStartEscapesForAllActiveAttributes(),o=ut(r),d+f<e.length&&e[d+f]===" "&&n)){for(d+=f;d<e.length&&e[d]===" ";)d+=1;continue}d+=f}return r&&s.push(r+i.getEndEscapesForAllActiveAttributes()),n?s.map(u=>jt(u)):s},Jw=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const i=[];let r="",o=0;return Uw(s,{getWidth:ut,onSegment:(a,c)=>{const l=a.text??"";if(a.isEscapeSequence)r+=l;else{const d=l===" ";if(a.width===0)return r+=l,!0;if(o+a.width>t&&(r&&i.push(r),r=c.getStartEscapesForAllActiveAttributes(),o=0,d))return n||i.push(c.getStartEscapesForAllActiveAttributes()+l),!0;r+=l,o+=a.width}return!0}}),r&&i.push(r),n?i.map(a=>jt(a)):i},qw=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const i=s.split(uu),r=[];let o="",a=0,c=0;for(;c<i.length;){const l=i[c],d=pu.test(l),u=ut(l);if(l.length===0){c+=1;continue}if(n&&d&&a===0){c+=1;continue}if(a+u>t&&a>0){n?r.push(jt(o)):r.push(o),o="",a=0;continue}o+=l,a+=u,c+=1}return o&&(n?r.push(jt(o)):r.push(o)),r},Kw=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const i=s.split(uu),r=[];let o="",a=0,c=0;for(;c<i.length;){const l=i[c],d=pu.test(l),u=ut(l);if(l.length===0){c+=1;continue}if(n&&d&&a===0){c+=1;continue}if(u>t){o&&r.push(Li(n?jt(o):o));const p=fu(l,t,n);if(p.length>0){for(let f=0;f<p.length-1;f+=1)r.push(p[f]);o=p.at(-1),a=ut(o)}else o="",a=0;c+=1;continue}if(a+u>t&&a>0&&(r.push(Li(n?jt(o):o)),o="",a=0,n&&d)){c+=1;continue}o+=l,a+=u,c+=1}return o&&r.push(Li(n?jt(o):o)),r},Ln={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},Yw=(e,t={})=>{const{removeZeroWidthCharacters:n=!0,trim:s=!0,width:i=80,wrapMode:r=Ln.PRESERVE_WORDS}=t;if(s&&e.trim()==="")return"";let o=e.normalize("NFC").replaceAll(`\r
117
+ `),n.lastGlobal=t,n.perTip[i.id]=t,ow(n))},lw=e=>({afterCommand:async t=>{const n=process.argv.slice(2),s=n[0]??"",i=process.exitCode===void 0||process.exitCode===0;e&&e();const r=t.workspaceRoot??process.cwd();cw({args:n,command:s,hasDockerfile:$(m(r,"Dockerfile")),hasDockerignore:$(m(r,".dockerignore")),hasVercelConfig:$(m(r,"vercel.json"))||$(m(r,".vercel")),hasVisConfig:t.visConfig!==void 0&&Object.keys(t.visConfig).length>0,success:i}),iw({success:i,visConfig:t.visConfig}),Q0({command:s,success:i,visConfig:t.visConfig})},name:"post-command"});let dw;const uw=e=>(dw??=Ne(import.meta.url))(e),Zt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,So=e=>{if(typeof Zt<"u"&&Zt.versions&&Zt.versions.node){const[t,n]=Zt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Zt.getBuiltinModule(e)}return uw(e)},jt=Zt,{execFileSync:pw}=So("node:child_process"),Dn=So("node:fs"),fw=So("node:tty"),hw=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],gw=12288,mw=65510,yw=[12288,12288,65281,65376,65504,65510],vw=8361,bw=65518,ww=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],kw=32,Sw=10630,xw=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],$w=4352,Ew=262141,au=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],ds=(e,t)=>{let n=0,s=Math.floor(e.length/2)-1;for(;n<=s;){const i=Math.floor((n+s)/2),r=i*2;if(t<e[r])s=i-1;else if(t>e[r+1])n=i+1;else return!0}return!1},ic=19968,[Cw,Rw]=Ow(au);function Ow(e){let t=e[0],n=e[1];for(let s=0;s<e.length;s+=2){const i=e[s],r=e[s+1];if(ic>=i&&ic<=r)return[i,r];r-i>n-t&&(t=i,n=r)}return[t,n]}const jw=e=>e<161||e>1114109?!1:ds(hw,e),Tw=e=>e<gw||e>mw?!1:ds(yw,e),Iw=e=>e<vw||e>bw?!1:ds(ww,e),Aw=e=>e<kw||e>Sw?!1:ds(xw,e),Bw=e=>e>=Cw&&e<=Rw?!0:e<$w||e>Ew?!1:ds(au,e);function Pw(e){return jw(e)?"ambiguous":Tw(e)?"fullwidth":Iw(e)?"halfwidth":Aw(e)?"narrow":Bw(e)?"wide":"neutral"}function Nw(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function cu(e){return Nw(e),Pw(e)}const lu=String.raw,rc=lu`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Dw=()=>new RegExp(lu`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${rc}(?:\u200D${rc})*`,"gu"),wn=new Set(["\x1B","›"]),mi="\x07",du="[",xo="m",ts="]8;;",Lw=39,Mw=/[\u200B\uFEFF\u2060-\u2064]/g,_w=new RegExp(`(?:\\${du}(?<code>\\d+)m|\\${ts}(?<uri>.*)${mi})`),Fw=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),uu=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,xs=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,Vw=Dw(),oc=new Map,Ww=e=>[e.ambiguousIsNarrow?1:0,e.control,e.fullWidth,e.regular,e.wide].join("|"),Hw=e=>{const t=Ww(e.width);let n=oc.get(t);return n||(n=new Map,oc.set(t,n)),n},$s=new RegExp(uu.source,"y"),Li=new RegExp(Vw.source,"uy"),Es=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,pu=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",Uw=(e,t)=>{const n=Hw(t),s=Math.floor(e/65536),i=e%65536;let r=n.get(s);if(r||(r=new Map,n.set(s,r)),r.has(i))return r.get(i);let o;switch(pu(e)){case"control":{o=t.width.control;break}case"latin":{o=t.width.regular;break}case"wide":{o=t.width.wide;break}case"zero":{o=0;break}default:switch(cu(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}}return r.set(i,o),o},Gw=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,Tr=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?Tr(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},s=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:i}=e,r=i>1e4;let o=0,a=0,c=i,l=!1;const d=e.includes("\x1B")||e.includes("›");for(;o<i;){if(d&&(e[o]==="\x1B"||e[o]==="›")){if(e.startsWith("\x1B]8;;",o)){const y="\x1B]8;;\x07",x=y.length,b=e.indexOf("\x07",o+5);if(b!==-1){const S=e.indexOf(y,b+1);if(S!==-1){const C=S+x,N=e.slice(b+1,S).replace(uu,""),T=Tr(N,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,s-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),D=T.width;if(T.truncated)l=!0,c=Math.min(c,o);else if(a+D>s&&(c=Math.min(c,o),l=!0,a+D>n.truncation.limit))break;if(a+=D,o=C,l&&a>=n.truncation.limit)break;continue}}}if($s.lastIndex=o,$s.test(e)){const y=$s.lastIndex-o,x=n.truncation.countAnsiEscapeCodes?y:n.width.ansi;if(a+x>s&&(c=Math.min(c,o),a+x>n.truncation.limit)){l=!0;break}a+=x,o=$s.lastIndex;continue}}const f=e.codePointAt(o);if(f===8203||f===65279||f>=8288&&f<=8292){o+=1;continue}if(f===9){if(a+n.width.tab>s&&(c=Math.min(c,o),a+n.width.tab>n.truncation.limit)){l=!0;break}a+=n.width.tab,o+=1;continue}if(Es.lastIndex=o,Es.test(e)){const y=(Es.lastIndex-o)*n.width.regular;if(a+y>s){const x=n.width.regular>0?Math.floor((s-a)/n.width.regular):0;if(c=Math.min(c,o+x),a+y>n.truncation.limit){l=!0;break}}a+=y,o=Es.lastIndex;continue}if((f<=31||f>=127&&f<=159)&&(xs.lastIndex=o,xs.test(e))){const y=(xs.lastIndex-o)*n.width.control;if(a+y>s){const x=n.width.control>0?Math.floor((s-a)/n.width.control):0;if(c=Math.min(c,o+x),a+y>n.truncation.limit){l=!0;break}}a+=y,o=xs.lastIndex;continue}if(Li.lastIndex=o,Li.test(e)){if(a+n.width.emoji>s&&(c=Math.min(c,o),a+n.width.emoji>n.truncation.limit)){l=!0;break}a+=n.width.emoji,o=Li.lastIndex;continue}const h=e.codePointAt(o)??0;if(Gw(h)){o+=h>65535?2:1;continue}let g;if(r)g=Uw(h,n);else switch(pu(h)){case"control":{g=n.width.control;break}case"latin":{g=n.width.regular;break}case"wide":{g=n.width.wide;break}case"zero":{g=0;break}default:switch(cu(h)){case"ambiguous":{g=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{g=n.width.fullWidth;break}case"wide":{g=n.width.wide;break}default:g=n.width.regular}}if(a+g>s&&(c=Math.min(c,o),a+g>n.truncation.limit)){l=!0;break}a+=g,o+=h>65535?2:1}let u=a,p=!1;return l&&n.truncation.limit>=n.truncation.ellipsisWidth&&(u=n.truncation.limit,p=!0),{ellipsed:p,index:l?c:i,truncated:l,width:u}},pt=(e,t={})=>Tr(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,zw=/\x1B\[(\d+)m/;let fu=class{activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const n=zw.exec(t);if(!n)return;const s=Number.parseInt(n[1],10);switch(s){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(s>=30&&s<=37||s>=90&&s<=97)this.activeForeground=t;else if(s>=40&&s<=47||s>=100&&s<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(s))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(s)){const i={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[s];i&&(this.activeFormatting=this.activeFormatting.filter(r=>!r.includes(i)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const n={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(s=>{const i=n[s];i&&t.push(i)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}};const Jw=(e,t)=>{if(!wn.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const n=!0,s=e.slice(t+1,t+1+ts.length).join("")===ts;return{isInsideEscape:n,isInsideLinkEscape:s}},qw=(e,t={})=>{const n=new fu;let s="",i=!1,r="",o="",a=!1;const c=[...e];for(let l=0;l<c.length;l++){const d=c[l];if(d&&wn.has(d)){if(s){const g=t.getWidth?.(s)??0,y={isEscapeSequence:!1,isGrapheme:!0,text:s,width:g};if(a&&(y.isHyperlink=!0,y.hyperlinkUrl=o),t.onSegment?.(y,n)===!1)return;s=""}i=!0,r=d;const f=Jw(c,l),{isInsideLinkEscape:h}=f;if(h){let g=l+1;for(o="";g<c.length;){const x=c[g];if(x===mi)break;o+=x,g+=1}o=o.slice(4);const y={hyperlinkUrl:o,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(y,n)===!1)return;l=g,a=!0,i=!1,r="";continue}if(l+1<c.length&&c[l+1]==="\\"&&a){const g={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(g,n)===!1)return;a=!1,o="",l+=1,i=!1,r="";continue}}if(i){if(r!==d&&(r+=d),d===xo){i=!1,n.processEscape(r);const f={isEscapeSequence:!0,isGrapheme:!1,text:r,width:0};if(t.onSegment?.(f,n)===!1)return;r=""}continue}s+=d;const u=t.getWidth?.(s)??0,p={isEscapeSequence:!1,isGrapheme:!0,text:s,width:u};if(a&&(p.isHyperlink=!0,p.hyperlinkUrl=o),t.onSegment?.(p,n)===!1)return;s=""}if(s){const l=t.getWidth?.(s)??0,d={isEscapeSequence:!1,isGrapheme:!0,text:s,width:l};a&&(d.isHyperlink=!0,d.hyperlinkUrl=o),t.onSegment?.(d,n)}if(r){const l={isEscapeSequence:!0,isGrapheme:!1,text:r,width:0};t.onSegment?.(l,n)}},ac=e=>`${wn.values().next().value}${du}${String(e)}${xo}`,cc=e=>`${wn.values().next().value}${ts}${e}${mi}`,Kw=e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",n,s;const i=e.join(`
118
+ `),r=[...i];let o=0;for(const[a,c]of r.entries()){if(t+=c,wn.has(c)){const d=_w.exec(i.slice(o))?.groups??{};if(d.code!==void 0){const u=Number.parseFloat(d.code);n=u===Lw?void 0:u}else d.uri!==void 0&&(s=d.uri.length===0?void 0:d.uri)}const l=Fw.get(Number(n));r[a+1]===`
119
+ `?(s&&(t+=cc("")),n&&l&&(t+=ac(l))):c===`
120
+ `&&(n&&l&&(t+=ac(n)),s&&(t+=cc(s))),o+=c.length}return t},hu=/(?=\s)|(?<=\s)/,gu=/^\s+$/,lc=new Map,Yw=e=>{const t=lc.get(e);if(t!==void 0)return t;const n=pt(e);return lc.set(e,n),n},Mi=e=>{if(!e.includes("\x1B"))return e;let t=e;return e.includes("\x1B[30m")&&(t+="\x1B[39m"),e.includes("\x1B[42m")&&(t+="\x1B[49m"),t},Tt=e=>{const t=e.split(" ");let n=t.length;for(;n>0&&pt(t[n-1])===0;)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},mu=(e,t,n)=>{if(e.length===0)return[""];if(t<=0)return[e];const s=[],i=new fu;let r="",o=0,a=!1,c=!1,l="",d=0;for(;d<e.length;){const u=e.codePointAt(d),p=String.fromCodePoint(u),f=p.length;if(wn.has(p)){a=!0,l=p,r+=p,c=e.startsWith(ts,d+1),d+=1;continue}if(a){l+=p,r+=p,c?p===mi&&(a=c=!1):p===xo&&(a=!1,i.processEscape(l)),d+=1;continue}const h=Yw(p),g=p===" ";if(h===0){r+=p,d+=f;continue}if(o+h>t&&(r&&s.push(r+i.getEndEscapesForAllActiveAttributes()),r=i.getStartEscapesForAllActiveAttributes(),o=pt(r),g&&n)){for(;d<e.length&&e[d]===" ";)d+=1;continue}if(r+=p,o+=h,o===t&&d+f<e.length&&(s.push(r+i.getEndEscapesForAllActiveAttributes()),r=i.getStartEscapesForAllActiveAttributes(),o=pt(r),d+f<e.length&&e[d+f]===" "&&n)){for(d+=f;d<e.length&&e[d]===" ";)d+=1;continue}d+=f}return r&&s.push(r+i.getEndEscapesForAllActiveAttributes()),n?s.map(u=>Tt(u)):s},Xw=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const i=[];let r="",o=0;return qw(s,{getWidth:pt,onSegment:(a,c)=>{const l=a.text??"";if(a.isEscapeSequence)r+=l;else{const d=l===" ";if(a.width===0)return r+=l,!0;if(o+a.width>t&&(r&&i.push(r),r=c.getStartEscapesForAllActiveAttributes(),o=0,d))return n||i.push(c.getStartEscapesForAllActiveAttributes()+l),!0;r+=l,o+=a.width}return!0}}),r&&i.push(r),n?i.map(a=>Tt(a)):i},Zw=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const i=s.split(hu),r=[];let o="",a=0,c=0;for(;c<i.length;){const l=i[c],d=gu.test(l),u=pt(l);if(l.length===0){c+=1;continue}if(n&&d&&a===0){c+=1;continue}if(a+u>t&&a>0){n?r.push(Tt(o)):r.push(o),o="",a=0;continue}o+=l,a+=u,c+=1}return o&&(n?r.push(Tt(o)):r.push(o)),r},Qw=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const i=s.split(hu),r=[];let o="",a=0,c=0;for(;c<i.length;){const l=i[c],d=gu.test(l),u=pt(l);if(l.length===0){c+=1;continue}if(n&&d&&a===0){c+=1;continue}if(u>t){o&&r.push(Mi(n?Tt(o):o));const p=mu(l,t,n);if(p.length>0){for(let f=0;f<p.length-1;f+=1)r.push(p[f]);o=p.at(-1),a=pt(o)}else o="",a=0;c+=1;continue}if(a+u>t&&a>0&&(r.push(Mi(n?Tt(o):o)),o="",a=0,n&&d)){c+=1;continue}o+=l,a+=u,c+=1}return o&&r.push(Mi(n?Tt(o):o)),r},Ln={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},ek=(e,t={})=>{const{removeZeroWidthCharacters:n=!0,trim:s=!0,width:i=80,wrapMode:r=Ln.PRESERVE_WORDS}=t;if(s&&e.trim()==="")return"";let o=e.normalize("NFC").replaceAll(`\r
121
121
  `,`
122
- `);return n&&(o=o.replaceAll(Bw,"")),o.split(`
123
- `).map(a=>{if(s&&a.trim()==="")return"";let c;switch(r){case Ln.BREAK_AT_CHARACTERS:{c=Jw(a,i,s);break}case Ln.BREAK_WORDS:{c=Kw(a,i,s);break}case Ln.STRICT_WIDTH:{c=fu(a,i,s);break}default:c=qw(a,i,s)}return Gw(c)}).join(`
124
- `)},hu=80,gu=24,Tr=(e,t,{shell:n,env:s}={})=>cw(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:s}).trim(),Bs=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),mu=(e,t)=>{const{columns:n,rows:s}=Bs(e,t);if(!(Number.isNaN(n)||Number.isNaN(s))&&!(n===hu&&s===gu))return{columns:n,rows:s}},Xw=()=>{if(Ot.platform!=="linux")return!0;try{const e=Dn.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const n=e.slice(t+2).trim().split(/\s+/),s=Number.parseInt(n[2],10),i=Number.parseInt(n[5],10);return Number.isNaN(s)||Number.isNaN(i)||i<=0?!1:s===i}catch{return!1}};function Mi(){const{env:e,stdout:t,stderr:n}=Ot;if(t?.columns&&t?.rows)return Bs(t.columns,t.rows);if(n?.columns&&n?.rows)return Bs(n.columns,n.rows);if(e.COLUMNS&&e.LINES)return Bs(e.COLUMNS,e.LINES);const s={columns:hu,rows:gu};return Ot.platform==="win32"?_i()??s:Ot.platform==="darwin"?cc()??_i()??s:cc()??_i()??Zw()??s}const cc=()=>{try{const e=Ot.platform==="darwin"?Dn.constants.O_EVTONLY|Dn.constants.O_NONBLOCK:Dn.constants.O_NONBLOCK,{columns:t,rows:n}=lw.WriteStream(Dn.openSync("/dev/tty",e));return{columns:t,rows:n}}catch{}},_i=()=>{try{const e=Tr("tput",["cols"],{env:{TERM:"dumb",...Ot.env}}),t=Tr("tput",["lines"],{env:{TERM:"dumb",...Ot.env}});if(e&&t)return mu(e,t)}catch{}},Zw=()=>{try{if(!Xw())return;const e=Tr("resize",["-u"]).match(/\d+/g);if(e.length===2)return mu(e[0],e[1])}catch{}};let Qw=class{#e;#t=!1;#n=!1;#r=0;#s=0;#i;#o;constructor(t,n){this.#e={stderr:n,stdout:t},this.#i=Mi(),this.#o=()=>{this.#i=Mi()};for(const s of Object.keys(this.#e))this.#e[s].onEarlyFlush(()=>{this.erase(s),this.#r=0,this.#s=0})}get lastLength(){return this.#r}get outside(){return this.#s}get isHooked(){return this.#t}get isSuspended(){return this.#n}clear(t){this.erase(t),this.#r=0,this.#s=0}done(t){this.#r=0,this.#s=0}erase(t,n=this.#r){this.#e[t].erase(n)}hook(){if(this.#t)return!1;const t=Object.values(this.#e);for(const n of t)n.active();return this.#i=Mi(),process.stdout.isTTY&&typeof process.stdout.on=="function"&&process.stdout.on("resize",this.#o),this.#a(!0),!0}resume(t,n){if(this.#n&&this.#t){this.#n=!1,n&&this.erase(t,n),this.#r=0,this.#s=0;const s=Object.values(this.#e);for(const i of s)i.active()}}suspend(t,n=!0){if(!this.#n){this.#n=!0,n&&this.erase(t);const s=Object.values(this.#e);for(const i of s)i.renew()}}unhook(t=!0){if(!this.#t)return!1;const n=Object.values(this.#e);for(const s of n)s.inactive(t);return typeof process.stdout.off=="function"&&process.stdout.off("resize",this.#o),this.#a(),!0}update(t,n,s=0){if(this.#n)return;if(n.length===0){this.clear(t);return}const i=this.#e[t],{columns:r,rows:o}=this.#i,a=Math.max(0,Math.min(o-1,s)),c=this.lastLength-a,l=Math.max(c-o,this.outside);let d=n.flatMap(u=>Yw(u,{trim:!1,width:r,wrapMode:Ln.STRICT_WIDTH}).split(`
122
+ `);return n&&(o=o.replaceAll(Mw,"")),o.split(`
123
+ `).map(a=>{if(s&&a.trim()==="")return"";let c;switch(r){case Ln.BREAK_AT_CHARACTERS:{c=Xw(a,i,s);break}case Ln.BREAK_WORDS:{c=Qw(a,i,s);break}case Ln.STRICT_WIDTH:{c=mu(a,i,s);break}default:c=Zw(a,i,s)}return Kw(c)}).join(`
124
+ `)},yu=80,vu=24,Ir=(e,t,{shell:n,env:s}={})=>pw(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:s}).trim(),Ns=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),bu=(e,t)=>{const{columns:n,rows:s}=Ns(e,t);if(!(Number.isNaN(n)||Number.isNaN(s))&&!(n===yu&&s===vu))return{columns:n,rows:s}},tk=()=>{if(jt.platform!=="linux")return!0;try{const e=Dn.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const n=e.slice(t+2).trim().split(/\s+/),s=Number.parseInt(n[2],10),i=Number.parseInt(n[5],10);return Number.isNaN(s)||Number.isNaN(i)||i<=0?!1:s===i}catch{return!1}};function _i(){const{env:e,stdout:t,stderr:n}=jt;if(t?.columns&&t?.rows)return Ns(t.columns,t.rows);if(n?.columns&&n?.rows)return Ns(n.columns,n.rows);if(e.COLUMNS&&e.LINES)return Ns(e.COLUMNS,e.LINES);const s={columns:yu,rows:vu};return jt.platform==="win32"?Fi()??s:jt.platform==="darwin"?dc()??Fi()??s:dc()??Fi()??nk()??s}const dc=()=>{try{const e=jt.platform==="darwin"?Dn.constants.O_EVTONLY|Dn.constants.O_NONBLOCK:Dn.constants.O_NONBLOCK,{columns:t,rows:n}=fw.WriteStream(Dn.openSync("/dev/tty",e));return{columns:t,rows:n}}catch{}},Fi=()=>{try{const e=Ir("tput",["cols"],{env:{TERM:"dumb",...jt.env}}),t=Ir("tput",["lines"],{env:{TERM:"dumb",...jt.env}});if(e&&t)return bu(e,t)}catch{}},nk=()=>{try{if(!tk())return;const e=Ir("resize",["-u"]).match(/\d+/g);if(e.length===2)return bu(e[0],e[1])}catch{}};let sk=class{#e;#t=!1;#n=!1;#r=0;#s=0;#i;#o;constructor(t,n){this.#e={stderr:n,stdout:t},this.#i=_i(),this.#o=()=>{this.#i=_i()};for(const s of Object.keys(this.#e))this.#e[s].onEarlyFlush(()=>{this.erase(s),this.#r=0,this.#s=0})}get lastLength(){return this.#r}get outside(){return this.#s}get isHooked(){return this.#t}get isSuspended(){return this.#n}clear(t){this.erase(t),this.#r=0,this.#s=0}done(t){this.#r=0,this.#s=0}erase(t,n=this.#r){this.#e[t].erase(n)}hook(){if(this.#t)return!1;const t=Object.values(this.#e);for(const n of t)n.active();return this.#i=_i(),process.stdout.isTTY&&typeof process.stdout.on=="function"&&process.stdout.on("resize",this.#o),this.#a(!0),!0}resume(t,n){if(this.#n&&this.#t){this.#n=!1,n&&this.erase(t,n),this.#r=0,this.#s=0;const s=Object.values(this.#e);for(const i of s)i.active()}}suspend(t,n=!0){if(!this.#n){this.#n=!0,n&&this.erase(t);const s=Object.values(this.#e);for(const i of s)i.renew()}}unhook(t=!0){if(!this.#t)return!1;const n=Object.values(this.#e);for(const s of n)s.inactive(t);return typeof process.stdout.off=="function"&&process.stdout.off("resize",this.#o),this.#a(),!0}update(t,n,s=0){if(this.#n)return;if(n.length===0){this.clear(t);return}const i=this.#e[t],{columns:r,rows:o}=this.#i,a=Math.max(0,Math.min(o-1,s)),c=this.lastLength-a,l=Math.max(c-o,this.outside);let d=n.flatMap(u=>ek(u,{trim:!1,width:r,wrapMode:Ln.STRICT_WIDTH}).split(`
125
125
  `));o<=c?(i.erase(o),a<l&&(d=d.slice(l-a+1))):c&&i.erase(c),i.write(`${d.join(`
126
126
  `)}
127
- `),this.#r=l?l+d.length+1:a+d.length,this.#s=Math.max(this.lastLength-o,this.outside)}#a(t=!1){this.#t=t,this.#r=0,this.#s=0}},ek;const tk=e=>(ek??=Ne(import.meta.url))(e),On=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,nk=e=>{if(typeof On<"u"&&On.versions&&On.versions.node){const[t,n]=On.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return On.getBuiltinModule(e)}return tk(e)},{StringDecoder:sk}=nk("node:string_decoder"),ls="\x1B[",yu=typeof globalThis<"u"&&typeof globalThis.window=="object"&&globalThis.window.document!==void 0,ik=/^(?:msys|cygwin)$/,vu=process,Ir=vu?.env??{};!yu&&Ir.TERM_PROGRAM;!yu&&(vu?.platform==="win32"||Ir.OSTYPE!==void 0&&ik.test(Ir.OSTYPE));const rk=`${ls}?25l`,ok=`${ls}G`,ak=`${ls}?25h`,ck=(e=1)=>`${ls}${String(e)}A`;var lk=(e=>(e[e.Default=0]="Default",e[e.BlinkingBlock=1]="BlinkingBlock",e[e.SteadyBlock=2]="SteadyBlock",e[e.BlinkingUnderline=3]="BlinkingUnderline",e[e.SteadyUnderline=4]="SteadyUnderline",e[e.BlinkingBar=5]="BlinkingBar",e[e.SteadyBar=6]="SteadyBar",e))(lk||{}),dk=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(dk||{}),uk=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(uk||{});const pk=e=>`${ls}${String(e)}K`,fk=pk(2),hk=e=>{if(e<=0)return"";let t="";for(let n=0;n<e;n+=1)t+=fk,n<e-1&&(t+=ck());return t+=ok,t},gk=1e4;class Js{static DRAIN=!0;#e=new sk;#t=[];#n;#r;#s;#i;#o;isTTY;constructor(t,n={}){this.#i=t.write.bind(t),this.#o=t,this.#s=n.maxHistory??gk,this.isTTY=t.isTTY}active(){this.isTTY&&this.write(rk);const t=(n,...s)=>{const i=s.at(-1);return this.#t.push(typeof n=="string"?n:this.#e.write(Buffer.from(n))),this.#t.length>this.#s&&(this.isTTY&&this.#r!==void 0&&this.#r(),this.#a(this.#t.length-Math.floor(this.#s/2))),typeof i=="function"&&i(),Js.DRAIN};this.#n=t,this.#o.write=this.#n}erase(t){t>0&&this.isTTY&&this.write(hk(t+1))}inactive(t=!1){this.#t.length>0&&(t&&this.write(`
128
- `),this.#a(this.#t.length));const n=this.#e.end();n&&this.write(n),this.renew()}renew(){this.#n===void 0||this.#o.write===this.#n?this.#o.write=this.#i:console.warn("[@visulima/interactive-manager] stream.write was replaced by a third party while the hook was active; leaving it untouched to avoid stomping the other patch."),this.#n=void 0,this.isTTY&&this.write(ak)}onEarlyFlush(t){this.#r=t}write(t){this.#i.apply(this.#o,[t])}#a(t){if(t<=0)return;const n=this.#t.splice(0,t);for(const s of n)this.write(s)}}let mk;const yk=e=>(mk??=Ne(import.meta.url))(e),Zt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:at,xo=e=>{if(typeof Zt<"u"&&Zt.versions&&Zt.versions.node){const[t,n]=Zt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Zt.getBuiltinModule(e)}return yk(e)},at=Zt,{execFileSync:vk}=xo("node:child_process"),Mn=xo("node:fs"),bk=xo("node:tty"),wk={alert:7,critical:6,debug:1,emergency:8,error:5,informational:2,notice:3,trace:2,warning:4},bu={alert:{color:"red",label:"alert",logLevel:"alert"},await:{color:"blue",label:"awaiting",logLevel:"informational"},complete:{color:"cyan",label:"complete",logLevel:"informational"},critical:{color:"redBright",label:"critical",logLevel:"critical"},debug:{color:"gray",label:"debug",logLevel:"debug"},emergency:{color:"redBright",label:"emergency",logLevel:"emergency"},error:{color:"red",label:"error",logLevel:"error"},info:{color:"blueBright",label:"info",logLevel:"informational"},log:{label:"",logLevel:"informational"},notice:{color:"magentaBright",label:"notice",logLevel:"notice"},pending:{color:"magenta",label:"pending",logLevel:"informational"},start:{color:"greenBright",label:"start",logLevel:"informational"},stop:{color:"red",label:"stop",logLevel:"informational"},success:{color:"green",label:"success",logLevel:"informational"},trace:{color:"cyanBright",label:"trace",logLevel:"trace"},wait:{color:"blue",label:"waiting",logLevel:"informational"},warn:{color:"yellow",label:"warning",logLevel:"warning"},warning:{color:"yellow",label:"warning",logLevel:"warning"},watch:{color:"yellowBright",label:"watching",logLevel:"informational"}},$o=Symbol("EMPTY"),Ar=e=>{const t=Object.keys(e).map(n=>e[n].label??"");return t.length===0?"":t.reduce((n,s)=>n.length>s.length?n:s,"")},Ke="[Inspection threw]",Be=(e,t,n,s,i,r=", ",o=Number.POSITIVE_INFINITY)=>{const a=e.length;if(a===0)return"";const c=Number.isFinite(o)&&a>o,l=c?Math.max(0,Math.floor(o)):a;if(l===0)return`…(${String(a)})`;let d=s;i!==void 0&&(d=i);const u=n.truncate,p=Number.isFinite(u);let f="",h="",g="";for(let y=0;y<l;y+=1){const x=y+1===l,b=y+2===l;p&&(g=`…(${String(l-y)})`);let S=e[y];n.truncate=u-f.length-(x?0:r.length);const C=h||d(S,t,n,s)+(x?"":r),N=f.length+C.length,T=N+g.length;if(x&&N>u&&f.length+g.length<=u||!x&&!b&&T>u)break;S=e[y+1];const D=b?"":r;if(x?h="":h=d(S,t,n,s)+D,!x&&b&&T>u&&N+h.length>u)break;if(f+=C,!x&&!b&&N+h.length>=u){g=`…(${String(l-y-1)})`;break}g=""}return c&&g===""&&(g=`${r}… ${String(a-l)} more`),`${f}${g}`},kk=([e,t],n,s)=>(s.truncate-=3,t?`${s.stylize(String(e),"yellow")}=${s.stylize(`"${t}"`,"string")}`:s.stylize(String(e),"yellow")),wu=e=>{try{return Object.create(e,{length:{value:e.length}})}catch{return}},Sk=(e,t,n,s)=>{let i;try{i=e.nodeType}catch{return Ke}if(i===1)return ku(e,e,n,s);if(i===3){let r;try{r=e.data}catch{return Ke}return s(r,void 0,n)}return s(e,void 0,n)},Pr=(e,t,n,s)=>{const i=wu(e);return i===void 0?Ke:Be(i,e,t,n,Sk,`
129
- `)},ku=(e,t,n,s)=>{let i,r;try{i=e.getAttributeNames().map(f=>[f,e.getAttribute(f)]),r=e.tagName.toLowerCase()}catch{return Ke}const o=n.stylize(`<${r}`,"special"),a=n.stylize(">","special"),c=n.stylize(`</${r}>`,"special");n.truncate-=r.length*2+5;let l="";i.length>0&&(l+=" ",l+=Be(i,t,n,s,kk," ")),n.truncate-=l.length;const{truncate:d}=n;let u;try{u=wu(e.children)}catch{u=void 0}let p;return u===void 0?p=Ke:(p=Pr(u,n,s),p&&p.length>d&&(p=`…(${String(u.length)})`)),`${o}${l}${a}${p}${c}`},xk=(e,t,n)=>e.length===0?"Arguments []":(t.truncate-=13,`Arguments [ ${Be(e,e,t,n,void 0,", ",t.maxArrayLength)} ]`),$k=(e,t)=>{let n;if(e===" ")n=" ";else if(typeof e=="number"&&e>0)n=Array.from({length:e+1}).join(" ");else return;return{base:n,prev:`
130
- ${Array.from({length:t+1}).join(n)}`}},mi=(e,t)=>{if(e.length===0)return"";const n=t.prev+t.base;return n+e.split("\0\0").join(`,${n}`)+t.prev},Ek=/^[a-z_]\w*$/i,Ck=/^"|"$/g,Rk=(e,t)=>{if(Ek.test(e))return e;const n=JSON.stringify(e);return t.quoteStyle==="double"?n.replaceAll('"',String.raw`\"`):n.replaceAll("'",String.raw`\'`).replaceAll(String.raw`\"`,'"').replaceAll(Ck,"'")},es=([e,t],n,s,i)=>{s.truncate-=2;let r;typeof e=="string"?r=Rk(e,s):typeof e=="number"?r=String(e):r=`[${i(e,n,s)}]`,s.truncate-=r.length;const o=i(t,n,s);return`${r}: ${o}`},Ok=Symbol.for("chai/inspect"),Fi=e=>({[Ok]:()=>e}),ts=(e,t)=>{let n;try{n=Object.getOwnPropertyDescriptor(e,t)}catch{n=void 0}if(n===void 0||"value"in n)try{return e[t]}catch{return Fi(Ke)}if(n.get===void 0)return Fi("[Setter]");try{return e[t]}catch{return Fi(Ke)}},jk=e=>{for(const t of e)if(Array.isArray(t)||typeof t=="object"&&t!==null)return!0;return!1},Tk=e=>{const t=[];for(const n of Object.keys(e)){const s=Number(n);Number.isInteger(s)&&s>=0&&String(s)===n&&s<4294967295||t.push(n)}return t},Ik=(e,t,n,s)=>{const i=Tk(e);if(e.length===0&&i.length===0)return"[]";t.truncate-=4;const r=!!s&&jk(e);let o=Be(e,e,t,n,void 0,r?"\0\0":", ",t.maxArrayLength);t.truncate-=o.length;let a="";return i.length>0&&(a=Be(i.map(c=>[c,ts(e,c)]),e,t,n,es)),r&&s&&(o=mi(o,s)),`[${r?"":" "}${o}${a?`, ${a}`:""}${r?"":" "}]`},Ak=50,lc=(e,t)=>{const n=new Uint8Array(e),s=Math.min(n.length,Ak);let i="",r=!1;for(let l=0;l<s;l+=1){const d=n[l];d!==0&&(r=!0),i+=(l===0?"":" ")+d.toString(16).padStart(2,"0")}n.length>s&&(i+=` ... ${String(n.length-s)} more byte${n.length-s===1?"":"s"}`);const o=e instanceof ArrayBuffer?"ArrayBuffer":"SharedArrayBuffer",a=r||n.length>s,c=i!==""&&a?`[Uint8Contents]: <${i}>, `:"";return`${t.stylize(o,"special")} { ${c}byteLength: ${t.stylize(String(e.byteLength),"number")} }`},dc=/\d(?=(?:\d{3})+(?!\d))/g,Pk=/\d{3}/g,Bk=/_$/,Su=(e,t)=>{if(t.length<4||t.length===4&&t.codePointAt(0)===45||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY||t.includes("e"))return t;if(typeof e=="number"){const n=e<0?-Math.floor(-e):Math.floor(e);if(n!==e){const s=String(n),i=t.slice(s.length+1);return`${s.replace(dc,"$&_")}.${i.replace(Pk,"$&_").replace(Bk,"")}`}}return t.replace(dc,"$&_")},Nk=e=>e>="\uD800"&&e<="\uDBFF",bt=(e,t,n="…")=>{e=String(e);const s=n.length,i=e.length;if(s>t&&i>s)return n;if(i>t&&i>s){let r=t-s;return r>0&&Nk(e[r-1])&&(r-=1),`${e.slice(0,r)}${n}`}return e},uc=(e,t)=>{let n=bt(e.toString(),t.truncate-1);return n!=="…"&&(n+="n"),t.stylize(t.numericSeparator?Su(e,n):n,"bigint")},xu=e=>{try{return Array.isArray(e)}catch{return!1}},Ct=(e,t)=>{try{return e[t]}catch{return}},Dk=(e,t)=>{try{return e instanceof t}catch{return!1}},pc=(e,t)=>{try{return Object.getOwnPropertyDescriptor(e,t)?.enumerable??!1}catch{return!0}},Lk=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:void 0),Ns=(e,t,n,s)=>{if("window"in globalThis&&e===globalThis)return"{ [object Window] }";if(e===globalThis)return"{ [object globalThis] }";let i,r;try{i=Object.getOwnPropertyNames(e),r=Object.getOwnPropertySymbols(e)}catch{return Ke}let o,a;try{o=t.showHidden?i:i.filter(f=>Object.getOwnPropertyDescriptor(e,f)?.enumerable)}catch{o=i.filter(f=>pc(e,f))}try{a=r.filter(f=>t.showHidden||Object.getOwnPropertyDescriptor(e,f)?.enumerable)}catch{a=r.filter(f=>pc(e,f))}let c;try{const f=Lk(e)===Object.prototype||e.constructor===Object,h=e instanceof Object?"":"null prototype";let g;!f&&Symbol.toStringTag in e?g=e[Symbol.toStringTag]:g=h?"Object":"",c=g||h?`[${[g,h].filter(Boolean).join(": ")}] `:""}catch{c=""}if(o.length===0&&a.length===0)return`${c}{}`;t.truncate-=4;const l=s?"\0\0":", ",d=Be(o.map(f=>[f,ts(e,f)]),e,t,n,es,l),u=Be(a.map(f=>[f,ts(e,f)]),e,t,n,es,l);let p="";return d&&u&&(p=l),s?`${c}{${mi(d+p+u,s)}}`:`${c}{ ${d}${p}${u} }`},Mk=(e,t,n,s)=>{let i;try{i=typeof e.constructor=="function"?e.constructor.name:""}catch{i=""}return(!i||i==="_class")&&(i="<Anonymous Class>"),t.truncate-=i.length,`${i} ${Ns(e,t,n,s)}`},_k=(e,t)=>{const n=t.stylize(String(e.byteLength),"number"),s=t.stylize(String(e.byteOffset),"number"),i=t.stylize(String(e.buffer.byteLength),"number");return`${t.stylize("DataView","special")} { byteLength: ${n}, byteOffset: ${s}, buffer: ArrayBuffer { byteLength: ${i} } }`},Fk=(e,t)=>{const n=e.toJSON();if(n===null)return"Invalid Date";const s=n.split("T"),i=s[0];return t.stylize(`${i}T${bt(s[1],t.truncate-i.length-1)}`,"date")},Vk=new Set(["column","columnNumber","description","fileName","line","lineNumber","message","name","number","stack"]),Wk=(e,t,n)=>{const s=Object.getOwnPropertyNames(e).filter(a=>!Vk.has(a)),{name:i}=e;t.truncate-=i.length;let r="";typeof e.message=="string"?r=bt(e.message,t.truncate):s.unshift("message"),r=r?`: ${r}`:"",t.truncate-=r.length+5;const o=Be(s.map(a=>[a,ts(e,a)]),e,t,n,es);return`${i}${r}${o?` { ${o} }`:""}`},fc=(e,t)=>{let n,s,i;try{n=e[Symbol.toStringTag]||"Function",s=e.toString(),{name:i}=e}catch{return t.stylize(Ke,"special")}return s.length<t.truncate-12?t.stylize(`[${n}: ${s}]`,"special"):i?t.stylize(`[${n} ${bt(i,t.truncate-11)}]`,"special"):t.stylize(`[${n}]`,"special")},hc=(e,t)=>{const n=Ct(e,Symbol.toStringTag),s=typeof n=="string"?n:"Generator";return`${t.stylize(`Object [${s}]`,"special")} {}`},Hk=([e,t],n,s,i)=>(s.truncate-=4,e=i(e,n,s),s.truncate-=e.length,`${e} => ${i(t,n,s)}`),Uk=(e,t,n,s)=>{if(e.size<=0)return"Map (0) {}";t.truncate-=7;let i=Be([...e.entries()],e,t,n,Hk,s?"\0\0":", ",t.maxArrayLength);return s&&(i=mi(i,s)),`Map (${String(e.size)}) {${s?"":" "}${i}${s?"":" "}}`};function gc(e,t){return Number.isNaN(e)?t.stylize("NaN","number"):e===Number.POSITIVE_INFINITY?t.stylize("Infinity","number"):e===Number.NEGATIVE_INFINITY?t.stylize("-Infinity","number"):e===0?t.stylize(1/e===Number.POSITIVE_INFINITY?"+0":"-0","number"):t.stylize(bt(t.numericSeparator?Su(e,e.toString()):e.toString(),t.truncate),"number")}const Gk=()=>"Promise{…}",zk=(e,t)=>{const n=t.truncate-(2+e.flags.length);return t.stylize(`/${bt(e.source,n)}/${e.flags}`,"regexp")},Jk=(e,t,n,s)=>{if(e.size===0)return"Set (0) {}";t.truncate-=7;let i=Be([...e],e,t,n,void 0,s?"\0\0":", ",t.maxArrayLength);return s&&(i=mi(i,s)),`Set (${String(e.size)}) {${s?"":" "}${i}${s?"":" "}}`},qk=(e,t)=>{const n=t.quoteStyle==="double"?'"':"'";return n+e+n},mc=new RegExp(String.raw`['\0-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5`+String.raw`\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]`,"g"),Kk={" ":String.raw`\t`,"\n":String.raw`\n`,"\f":String.raw`\f`,"\r":String.raw`\r`,"\b":String.raw`\b`,"'":String.raw`\'`,"\\":"\\\\"},Yk=16,Xk=e=>Kk[e]||String.raw`\u${`0000${e.codePointAt(0).toString(Yk)}`.slice(-4)}`,yc=(e,t)=>(mc.test(e)&&(e=e.replaceAll(mc,Xk)),t.stylize(qk(bt(e,t.truncate-2),t),"string")),vc=e=>"description"in Symbol.prototype?e.description?`Symbol(${e.description})`:"Symbol()":e.toString(),Zk=e=>typeof Buffer=="function"&&e instanceof Buffer?"Buffer":e[Symbol.toStringTag],We=(e,t,n)=>{const s=Zk(e);t.truncate-=s.length+4;const i=Object.keys(e).slice(e.length);if(e.length===0&&i.length===0)return`${s}[]`;let r="";const o=Number.isFinite(t.maxArrayLength)?Math.min(e.length,Math.max(0,Math.floor(t.maxArrayLength))):e.length;for(let c=0;c<o;c++){const l=`${t.stylize(bt(e[c],t.truncate),"number")}${c===o-1?"":", "}`;if(t.truncate-=l.length,c!==o-1&&t.truncate<=3){r+=`…(${String(e.length-c)})`;break}r+=l}o<e.length&&(r+=`${r?", ":""}… ${String(e.length-o)} more`);let a="";return i.length>0&&(a=Be(i.map(c=>[c,ts(e,c)]),e,t,n,es)),`${s}[ ${r}${a?`, ${a}`:""} ]`},bc=e=>typeof Ct(e,Symbol.toStringTag)!="string",Qk=e=>typeof e=="function",$u=(e,t,n)=>{if(e==null)return;const s=Object.getOwnPropertyDescriptor(e,t);if(s===void 0)return;const i=n==="get"?s.get:s.value;return typeof i=="function"?i:void 0},Eu=(e,t)=>{if(e!==void 0)return n=>{try{return e.call(n,t),!0}catch{return!1}}},xt=(e,t)=>Eu($u(e,t,"get")),Ze=(e,t,n)=>Eu($u(e,t,"value"),n),wc=Object.freeze({}),He=xt(Reflect.getPrototypeOf(Int8Array.prototype),"length"),e1=typeof SharedArrayBuffer=="function"?SharedArrayBuffer.prototype:void 0,t1=Object.assign(Object.create(null),{Arguments:bc,Array:xu,ArrayBuffer:xt(ArrayBuffer.prototype,"byteLength"),BigInt:Ze(BigInt.prototype,"valueOf"),Boolean:Ze(Boolean.prototype,"valueOf"),DataView:xt(DataView.prototype,"byteLength"),Date:Ze(Date.prototype,"valueOf"),Error:bc,Float32Array:He,Float64Array:He,Function:Qk,Int8Array:He,Int16Array:He,Int32Array:He,Map:xt(Map.prototype,"size"),Number:Ze(Number.prototype,"valueOf"),RegExp:xt(RegExp.prototype,"source"),Set:xt(Set.prototype,"size"),SharedArrayBuffer:xt(e1,"byteLength"),String:Ze(String.prototype,"valueOf"),Symbol:Ze(Symbol.prototype,"valueOf"),Uint8Array:He,Uint8ClampedArray:He,Uint16Array:He,Uint32Array:He,WeakMap:Ze(WeakMap.prototype,"has",wc),WeakSet:Ze(WeakSet.prototype,"has",wc)}),n1=(e,t)=>{const n=t1[t];return n===void 0||n(e)},kc=new WeakMap,Sc=Object.create(null),s1=Object.assign(Object.create(null),{Arguments:xk,Array:Ik,ArrayBuffer:lc,AsyncGenerator:hc,BigInt:uc,bigint:uc,Boolean:(e,t)=>t.stylize(String(e),"boolean"),boolean:(e,t)=>t.stylize(String(e),"boolean"),DataView:_k,Date:Fk,Error:Wk,Float32Array:We,Float64Array:We,Function:fc,function:fc,Generator:hc,HTMLCollection:Pr,Int8Array:We,Int16Array:We,Int32Array:We,Map:Uk,NodeList:Pr,null:(e,t)=>t.stylize("null","null"),Number:gc,number:gc,Promise:Gk,RegExp:zk,Set:Jk,SharedArrayBuffer:lc,String:yc,string:yc,Symbol:vc,symbol:vc,Uint8Array:We,Uint8ClampedArray:We,Uint16Array:We,Uint32Array:We,undefined:(e,t)=>t.stylize("undefined","undefined"),WeakMap:(e,t)=>t.stylize("WeakMap{…}","special"),WeakSet:(e,t)=>t.stylize("WeakSet{…}","special")}),i1=Symbol.for("nodejs.util.inspect.custom"),r1=Symbol.for("chai/inspect"),o1=(e,t,n,s)=>{const i=Ct(e,r1);if(typeof i=="function")return i.call(e,t);if(!("window"in globalThis)){const c=Ct(e,i1);if(typeof c=="function")return c.call(e,s,t)}const r=Ct(e,"inspect");if(typeof r=="function")return r.call(e,s,t);const o=Ct(e,"constructor");if(typeof o=="function"&&kc.has(o))return kc.get(o)?.(e,t)??"unknown";const a=Object.hasOwn(Sc,n)?Sc[n]:void 0;return a?a(e,t):""},Vi=(e,t,n)=>{const{depth:s,inspect:i,seen:r}=n;if(r.includes(e))return"[Circular]";if(s>=t.depth&&t.depth>0&&typeof e=="object"&&e!==null)return xu(e)?"[Array]":"[Object]";const o=t.indent?$k(t.indent,s):void 0;let a=e===null?"null":typeof e;if(a==="object")try{a=Object.prototype.toString.call(e).slice(8,-1)}catch{a="Object"}let c=s1[a];if(c!==void 0&&typeof e=="object"&&e!==null&&!n1(e,a)&&(c=void 0),c!==void 0)return c(e,t,i,o);if(t.customInspect&&e){const u=o1(e,t,a,t.depth-s);if(u)return typeof u=="string"?u:i(u,e,t)}let l=!1;if(e)try{l=Object.getPrototypeOf(e)}catch{l=Object.prototype}if(l===Object.prototype||l===null)return Ns(e,t,i,o);if(e&&typeof HTMLElement=="function"&&Dk(e,HTMLElement))return ku(e,e,t,i);const d=Ct(e,"constructor");return d!==void 0?d!==Object?Mk(e,t,i,o):Ns(e,t,i,o):e===Object(e)?Ns(e,t,i,o):t.stylize(String(e),a)},qs=(e,t={})=>{const n={customInspect:!0,depth:5,indent:void 0,maxArrayLength:Number.POSITIVE_INFINITY,numericSeparator:!0,quoteStyle:"single",showHidden:!1,stylize:i=>i,truncate:Number.POSITIVE_INFINITY,...t};if(n.indent!==void 0&&n.indent!==" "&&!(Number.parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `undefined`');const s={depth:0,inspect:void 0,seen:[]};return s.inspect=(i,r,o)=>{if(r==null){s.depth+=1;const c=Vi(i,o,s);return s.depth-=1,c}s.seen.push(r),s.depth+=1;const a=Vi(i,o,s);return s.depth-=1,s.seen.pop(),a},Vi(e,n,s)},a1=new Set(["alert","critical","emergency","error","trace","warning"]),Cu=e=>a1.has(e),Ru=(e,t)=>t?(t.__write??t.write.bind(t)).call(t,e):!1,c1=globalThis.process??Object.create(null),xc={versions:{}},ns=new Proxy(c1,{get(e,t){if(t in e)return e[t];if(t in xc)return xc[t]}}),yi=e=>{let t;return()=>{if(t===void 0){if(typeof ns.getBuiltinModule!="function")throw new TypeError(`[@visulima/error] Cannot load ${e}: this runtime implements no process.getBuiltinModule(). Requires Node ^22.14.0 || >=24.10.0, or another runtime providing process.getBuiltinModule().`);t=ns.getBuiltinModule(e)}return t}},l1=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
131
- `),d1=(e,t,n,s)=>{const i={column:0,line:-1,...e.start},r={...i,...e.end},o=i.line,a=i.column,c=r.line,l=r.column;let d=Math.max(o-(n+1),0),u=Math.min(t.length,c+s);o===-1&&(d=0),c===-1&&(u=t.length);const p=c-o,f={};if(p)for(let h=0;h<=p;h++){const g=h+o;if(!a)f[g]=!0;else if(h===0){const y=t[g-1]?.length;f[g]=[a,(y??0)-a+1]}else if(h===p)f[g]=[0,l];else{const y=t[g-h]?.length;f[g]=[0,y]}}else a===l?f[o]=a?[a,0]:!0:f[o]=[a,(l??0)-(a??0)];return{end:u,markerLines:f,start:d}},u1=ns.platform==="win32"&&!ns.env?.WT_SESSION?">":"❯",p1=(e,t,n)=>{const s={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...n,color:{gutter:h=>h,marker:h=>h,message:h=>h,...n?.color}},i=typeof t.start.column=="number";let r=(e.includes("\r")?l1(e):e).split(`
132
- `);typeof s.tabWidth=="number"&&e.includes(" ")&&(r=r.map(h=>h.replaceAll(" "," ".repeat(s.tabWidth))));const{end:o,markerLines:a,start:c}=d1(t,r,s.linesAbove,s.linesBelow),l=String(o).length,{gutter:d,marker:u,message:p}=s.color;let f=r.slice(c,o).map((h,g)=>{const y=c+1+g,x=a[y],b=String(y).padStart(l),S=!a[y+1],C=` ${b}${s.showGutter?" |":""}`;if(x){let N="";if(Array.isArray(x)){const T=h.replaceAll(/[^\t]/g," ").slice(0,Math.max(x[0]-1,0)),D=x[1]||1;N=[`
133
- `,s.prefix+d(C.replaceAll(/\d/g," "))," ",T,u("^").repeat(D)].join(""),S&&s.message&&(N+=` ${p(s.message)}`)}return[s.prefix+u(u1),d(C),h.length>0?` ${h}`:"",N].join("")}return`${s.prefix} ${d(C)}${h.length>0?` ${h}`:""}`}).join(`
127
+ `),this.#r=l?l+d.length+1:a+d.length,this.#s=Math.max(this.lastLength-o,this.outside)}#a(t=!1){this.#t=t,this.#r=0,this.#s=0}},ik;const rk=e=>(ik??=Ne(import.meta.url))(e),On=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ok=e=>{if(typeof On<"u"&&On.versions&&On.versions.node){const[t,n]=On.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return On.getBuiltinModule(e)}return rk(e)},{StringDecoder:ak}=ok("node:string_decoder"),us="\x1B[",wu=typeof globalThis<"u"&&typeof globalThis.window=="object"&&globalThis.window.document!==void 0,ck=/^(?:msys|cygwin)$/,ku=process,Ar=ku?.env??{};!wu&&Ar.TERM_PROGRAM;!wu&&(ku?.platform==="win32"||Ar.OSTYPE!==void 0&&ck.test(Ar.OSTYPE));const lk=`${us}?25l`,dk=`${us}G`,uk=`${us}?25h`,pk=(e=1)=>`${us}${String(e)}A`;var fk=(e=>(e[e.Default=0]="Default",e[e.BlinkingBlock=1]="BlinkingBlock",e[e.SteadyBlock=2]="SteadyBlock",e[e.BlinkingUnderline=3]="BlinkingUnderline",e[e.SteadyUnderline=4]="SteadyUnderline",e[e.BlinkingBar=5]="BlinkingBar",e[e.SteadyBar=6]="SteadyBar",e))(fk||{}),hk=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(hk||{}),gk=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(gk||{});const mk=e=>`${us}${String(e)}K`,yk=mk(2),vk=e=>{if(e<=0)return"";let t="";for(let n=0;n<e;n+=1)t+=yk,n<e-1&&(t+=pk());return t+=dk,t},bk=1e4;class qs{static DRAIN=!0;#e=new ak;#t=[];#n;#r;#s;#i;#o;isTTY;constructor(t,n={}){this.#i=t.write.bind(t),this.#o=t,this.#s=n.maxHistory??bk,this.isTTY=t.isTTY}active(){this.isTTY&&this.write(lk);const t=(n,...s)=>{const i=s.at(-1);return this.#t.push(typeof n=="string"?n:this.#e.write(Buffer.from(n))),this.#t.length>this.#s&&(this.isTTY&&this.#r!==void 0&&this.#r(),this.#a(this.#t.length-Math.floor(this.#s/2))),typeof i=="function"&&i(),qs.DRAIN};this.#n=t,this.#o.write=this.#n}erase(t){t>0&&this.isTTY&&this.write(vk(t+1))}inactive(t=!1){this.#t.length>0&&(t&&this.write(`
128
+ `),this.#a(this.#t.length));const n=this.#e.end();n&&this.write(n),this.renew()}renew(){this.#n===void 0||this.#o.write===this.#n?this.#o.write=this.#i:console.warn("[@visulima/interactive-manager] stream.write was replaced by a third party while the hook was active; leaving it untouched to avoid stomping the other patch."),this.#n=void 0,this.isTTY&&this.write(uk)}onEarlyFlush(t){this.#r=t}write(t){this.#i.apply(this.#o,[t])}#a(t){if(t<=0)return;const n=this.#t.splice(0,t);for(const s of n)this.write(s)}}let wk;const kk=e=>(wk??=Ne(import.meta.url))(e),Qt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:ct,$o=e=>{if(typeof Qt<"u"&&Qt.versions&&Qt.versions.node){const[t,n]=Qt.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return Qt.getBuiltinModule(e)}return kk(e)},ct=Qt,{execFileSync:Sk}=$o("node:child_process"),Mn=$o("node:fs"),xk=$o("node:tty"),$k={alert:7,critical:6,debug:1,emergency:8,error:5,informational:2,notice:3,trace:2,warning:4},Su={alert:{color:"red",label:"alert",logLevel:"alert"},await:{color:"blue",label:"awaiting",logLevel:"informational"},complete:{color:"cyan",label:"complete",logLevel:"informational"},critical:{color:"redBright",label:"critical",logLevel:"critical"},debug:{color:"gray",label:"debug",logLevel:"debug"},emergency:{color:"redBright",label:"emergency",logLevel:"emergency"},error:{color:"red",label:"error",logLevel:"error"},info:{color:"blueBright",label:"info",logLevel:"informational"},log:{label:"",logLevel:"informational"},notice:{color:"magentaBright",label:"notice",logLevel:"notice"},pending:{color:"magenta",label:"pending",logLevel:"informational"},start:{color:"greenBright",label:"start",logLevel:"informational"},stop:{color:"red",label:"stop",logLevel:"informational"},success:{color:"green",label:"success",logLevel:"informational"},trace:{color:"cyanBright",label:"trace",logLevel:"trace"},wait:{color:"blue",label:"waiting",logLevel:"informational"},warn:{color:"yellow",label:"warning",logLevel:"warning"},warning:{color:"yellow",label:"warning",logLevel:"warning"},watch:{color:"yellowBright",label:"watching",logLevel:"informational"}},Eo=Symbol("EMPTY"),Br=e=>{const t=Object.keys(e).map(n=>e[n].label??"");return t.length===0?"":t.reduce((n,s)=>n.length>s.length?n:s,"")},Ke="[Inspection threw]",Pe=(e,t,n,s,i,r=", ",o=Number.POSITIVE_INFINITY)=>{const a=e.length;if(a===0)return"";const c=Number.isFinite(o)&&a>o,l=c?Math.max(0,Math.floor(o)):a;if(l===0)return`…(${String(a)})`;let d=s;i!==void 0&&(d=i);const u=n.truncate,p=Number.isFinite(u);let f="",h="",g="";for(let y=0;y<l;y+=1){const x=y+1===l,b=y+2===l;p&&(g=`…(${String(l-y)})`);let S=e[y];n.truncate=u-f.length-(x?0:r.length);const C=h||d(S,t,n,s)+(x?"":r),N=f.length+C.length,T=N+g.length;if(x&&N>u&&f.length+g.length<=u||!x&&!b&&T>u)break;S=e[y+1];const D=b?"":r;if(x?h="":h=d(S,t,n,s)+D,!x&&b&&T>u&&N+h.length>u)break;if(f+=C,!x&&!b&&N+h.length>=u){g=`…(${String(l-y-1)})`;break}g=""}return c&&g===""&&(g=`${r}… ${String(a-l)} more`),`${f}${g}`},Ek=([e,t],n,s)=>(s.truncate-=3,t?`${s.stylize(String(e),"yellow")}=${s.stylize(`"${t}"`,"string")}`:s.stylize(String(e),"yellow")),xu=e=>{try{return Object.create(e,{length:{value:e.length}})}catch{return}},Ck=(e,t,n,s)=>{let i;try{i=e.nodeType}catch{return Ke}if(i===1)return $u(e,e,n,s);if(i===3){let r;try{r=e.data}catch{return Ke}return s(r,void 0,n)}return s(e,void 0,n)},Pr=(e,t,n,s)=>{const i=xu(e);return i===void 0?Ke:Pe(i,e,t,n,Ck,`
129
+ `)},$u=(e,t,n,s)=>{let i,r;try{i=e.getAttributeNames().map(f=>[f,e.getAttribute(f)]),r=e.tagName.toLowerCase()}catch{return Ke}const o=n.stylize(`<${r}`,"special"),a=n.stylize(">","special"),c=n.stylize(`</${r}>`,"special");n.truncate-=r.length*2+5;let l="";i.length>0&&(l+=" ",l+=Pe(i,t,n,s,Ek," ")),n.truncate-=l.length;const{truncate:d}=n;let u;try{u=xu(e.children)}catch{u=void 0}let p;return u===void 0?p=Ke:(p=Pr(u,n,s),p&&p.length>d&&(p=`…(${String(u.length)})`)),`${o}${l}${a}${p}${c}`},Rk=(e,t,n)=>e.length===0?"Arguments []":(t.truncate-=13,`Arguments [ ${Pe(e,e,t,n,void 0,", ",t.maxArrayLength)} ]`),Ok=(e,t)=>{let n;if(e===" ")n=" ";else if(typeof e=="number"&&e>0)n=Array.from({length:e+1}).join(" ");else return;return{base:n,prev:`
130
+ ${Array.from({length:t+1}).join(n)}`}},yi=(e,t)=>{if(e.length===0)return"";const n=t.prev+t.base;return n+e.split("\0\0").join(`,${n}`)+t.prev},jk=/^[a-z_]\w*$/i,Tk=/^"|"$/g,Ik=(e,t)=>{if(jk.test(e))return e;const n=JSON.stringify(e);return t.quoteStyle==="double"?n.replaceAll('"',String.raw`\"`):n.replaceAll("'",String.raw`\'`).replaceAll(String.raw`\"`,'"').replaceAll(Tk,"'")},ns=([e,t],n,s,i)=>{s.truncate-=2;let r;typeof e=="string"?r=Ik(e,s):typeof e=="number"?r=String(e):r=`[${i(e,n,s)}]`,s.truncate-=r.length;const o=i(t,n,s);return`${r}: ${o}`},Ak=Symbol.for("chai/inspect"),Vi=e=>({[Ak]:()=>e}),ss=(e,t)=>{let n;try{n=Object.getOwnPropertyDescriptor(e,t)}catch{n=void 0}if(n===void 0||"value"in n)try{return e[t]}catch{return Vi(Ke)}if(n.get===void 0)return Vi("[Setter]");try{return e[t]}catch{return Vi(Ke)}},Bk=e=>{for(const t of e)if(Array.isArray(t)||typeof t=="object"&&t!==null)return!0;return!1},Pk=e=>{const t=[];for(const n of Object.keys(e)){const s=Number(n);Number.isInteger(s)&&s>=0&&String(s)===n&&s<4294967295||t.push(n)}return t},Nk=(e,t,n,s)=>{const i=Pk(e);if(e.length===0&&i.length===0)return"[]";t.truncate-=4;const r=!!s&&Bk(e);let o=Pe(e,e,t,n,void 0,r?"\0\0":", ",t.maxArrayLength);t.truncate-=o.length;let a="";return i.length>0&&(a=Pe(i.map(c=>[c,ss(e,c)]),e,t,n,ns)),r&&s&&(o=yi(o,s)),`[${r?"":" "}${o}${a?`, ${a}`:""}${r?"":" "}]`},Dk=50,uc=(e,t)=>{const n=new Uint8Array(e),s=Math.min(n.length,Dk);let i="",r=!1;for(let l=0;l<s;l+=1){const d=n[l];d!==0&&(r=!0),i+=(l===0?"":" ")+d.toString(16).padStart(2,"0")}n.length>s&&(i+=` ... ${String(n.length-s)} more byte${n.length-s===1?"":"s"}`);const o=e instanceof ArrayBuffer?"ArrayBuffer":"SharedArrayBuffer",a=r||n.length>s,c=i!==""&&a?`[Uint8Contents]: <${i}>, `:"";return`${t.stylize(o,"special")} { ${c}byteLength: ${t.stylize(String(e.byteLength),"number")} }`},pc=/\d(?=(?:\d{3})+(?!\d))/g,Lk=/\d{3}/g,Mk=/_$/,Eu=(e,t)=>{if(t.length<4||t.length===4&&t.codePointAt(0)===45||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY||t.includes("e"))return t;if(typeof e=="number"){const n=e<0?-Math.floor(-e):Math.floor(e);if(n!==e){const s=String(n),i=t.slice(s.length+1);return`${s.replace(pc,"$&_")}.${i.replace(Lk,"$&_").replace(Mk,"")}`}}return t.replace(pc,"$&_")},_k=e=>e>="\uD800"&&e<="\uDBFF",wt=(e,t,n="…")=>{e=String(e);const s=n.length,i=e.length;if(s>t&&i>s)return n;if(i>t&&i>s){let r=t-s;return r>0&&_k(e[r-1])&&(r-=1),`${e.slice(0,r)}${n}`}return e},fc=(e,t)=>{let n=wt(e.toString(),t.truncate-1);return n!=="…"&&(n+="n"),t.stylize(t.numericSeparator?Eu(e,n):n,"bigint")},Cu=e=>{try{return Array.isArray(e)}catch{return!1}},Rt=(e,t)=>{try{return e[t]}catch{return}},Fk=(e,t)=>{try{return e instanceof t}catch{return!1}},hc=(e,t)=>{try{return Object.getOwnPropertyDescriptor(e,t)?.enumerable??!1}catch{return!0}},Vk=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:void 0),Ds=(e,t,n,s)=>{if("window"in globalThis&&e===globalThis)return"{ [object Window] }";if(e===globalThis)return"{ [object globalThis] }";let i,r;try{i=Object.getOwnPropertyNames(e),r=Object.getOwnPropertySymbols(e)}catch{return Ke}let o,a;try{o=t.showHidden?i:i.filter(f=>Object.getOwnPropertyDescriptor(e,f)?.enumerable)}catch{o=i.filter(f=>hc(e,f))}try{a=r.filter(f=>t.showHidden||Object.getOwnPropertyDescriptor(e,f)?.enumerable)}catch{a=r.filter(f=>hc(e,f))}let c;try{const f=Vk(e)===Object.prototype||e.constructor===Object,h=e instanceof Object?"":"null prototype";let g;!f&&Symbol.toStringTag in e?g=e[Symbol.toStringTag]:g=h?"Object":"",c=g||h?`[${[g,h].filter(Boolean).join(": ")}] `:""}catch{c=""}if(o.length===0&&a.length===0)return`${c}{}`;t.truncate-=4;const l=s?"\0\0":", ",d=Pe(o.map(f=>[f,ss(e,f)]),e,t,n,ns,l),u=Pe(a.map(f=>[f,ss(e,f)]),e,t,n,ns,l);let p="";return d&&u&&(p=l),s?`${c}{${yi(d+p+u,s)}}`:`${c}{ ${d}${p}${u} }`},Wk=(e,t,n,s)=>{let i;try{i=typeof e.constructor=="function"?e.constructor.name:""}catch{i=""}return(!i||i==="_class")&&(i="<Anonymous Class>"),t.truncate-=i.length,`${i} ${Ds(e,t,n,s)}`},Hk=(e,t)=>{const n=t.stylize(String(e.byteLength),"number"),s=t.stylize(String(e.byteOffset),"number"),i=t.stylize(String(e.buffer.byteLength),"number");return`${t.stylize("DataView","special")} { byteLength: ${n}, byteOffset: ${s}, buffer: ArrayBuffer { byteLength: ${i} } }`},Uk=(e,t)=>{const n=e.toJSON();if(n===null)return"Invalid Date";const s=n.split("T"),i=s[0];return t.stylize(`${i}T${wt(s[1],t.truncate-i.length-1)}`,"date")},Gk=new Set(["column","columnNumber","description","fileName","line","lineNumber","message","name","number","stack"]),zk=(e,t,n)=>{const s=Object.getOwnPropertyNames(e).filter(a=>!Gk.has(a)),{name:i}=e;t.truncate-=i.length;let r="";typeof e.message=="string"?r=wt(e.message,t.truncate):s.unshift("message"),r=r?`: ${r}`:"",t.truncate-=r.length+5;const o=Pe(s.map(a=>[a,ss(e,a)]),e,t,n,ns);return`${i}${r}${o?` { ${o} }`:""}`},gc=(e,t)=>{let n,s,i;try{n=e[Symbol.toStringTag]||"Function",s=e.toString(),{name:i}=e}catch{return t.stylize(Ke,"special")}return s.length<t.truncate-12?t.stylize(`[${n}: ${s}]`,"special"):i?t.stylize(`[${n} ${wt(i,t.truncate-11)}]`,"special"):t.stylize(`[${n}]`,"special")},mc=(e,t)=>{const n=Rt(e,Symbol.toStringTag),s=typeof n=="string"?n:"Generator";return`${t.stylize(`Object [${s}]`,"special")} {}`},Jk=([e,t],n,s,i)=>(s.truncate-=4,e=i(e,n,s),s.truncate-=e.length,`${e} => ${i(t,n,s)}`),qk=(e,t,n,s)=>{if(e.size<=0)return"Map (0) {}";t.truncate-=7;let i=Pe([...e.entries()],e,t,n,Jk,s?"\0\0":", ",t.maxArrayLength);return s&&(i=yi(i,s)),`Map (${String(e.size)}) {${s?"":" "}${i}${s?"":" "}}`};function yc(e,t){return Number.isNaN(e)?t.stylize("NaN","number"):e===Number.POSITIVE_INFINITY?t.stylize("Infinity","number"):e===Number.NEGATIVE_INFINITY?t.stylize("-Infinity","number"):e===0?t.stylize(1/e===Number.POSITIVE_INFINITY?"+0":"-0","number"):t.stylize(wt(t.numericSeparator?Eu(e,e.toString()):e.toString(),t.truncate),"number")}const Kk=()=>"Promise{…}",Yk=(e,t)=>{const n=t.truncate-(2+e.flags.length);return t.stylize(`/${wt(e.source,n)}/${e.flags}`,"regexp")},Xk=(e,t,n,s)=>{if(e.size===0)return"Set (0) {}";t.truncate-=7;let i=Pe([...e],e,t,n,void 0,s?"\0\0":", ",t.maxArrayLength);return s&&(i=yi(i,s)),`Set (${String(e.size)}) {${s?"":" "}${i}${s?"":" "}}`},Zk=(e,t)=>{const n=t.quoteStyle==="double"?'"':"'";return n+e+n},vc=new RegExp(String.raw`['\0-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5`+String.raw`\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]`,"g"),Qk={" ":String.raw`\t`,"\n":String.raw`\n`,"\f":String.raw`\f`,"\r":String.raw`\r`,"\b":String.raw`\b`,"'":String.raw`\'`,"\\":"\\\\"},e1=16,t1=e=>Qk[e]||String.raw`\u${`0000${e.codePointAt(0).toString(e1)}`.slice(-4)}`,bc=(e,t)=>(vc.test(e)&&(e=e.replaceAll(vc,t1)),t.stylize(Zk(wt(e,t.truncate-2),t),"string")),wc=e=>"description"in Symbol.prototype?e.description?`Symbol(${e.description})`:"Symbol()":e.toString(),n1=e=>typeof Buffer=="function"&&e instanceof Buffer?"Buffer":e[Symbol.toStringTag],We=(e,t,n)=>{const s=n1(e);t.truncate-=s.length+4;const i=Object.keys(e).slice(e.length);if(e.length===0&&i.length===0)return`${s}[]`;let r="";const o=Number.isFinite(t.maxArrayLength)?Math.min(e.length,Math.max(0,Math.floor(t.maxArrayLength))):e.length;for(let c=0;c<o;c++){const l=`${t.stylize(wt(e[c],t.truncate),"number")}${c===o-1?"":", "}`;if(t.truncate-=l.length,c!==o-1&&t.truncate<=3){r+=`…(${String(e.length-c)})`;break}r+=l}o<e.length&&(r+=`${r?", ":""}… ${String(e.length-o)} more`);let a="";return i.length>0&&(a=Pe(i.map(c=>[c,ss(e,c)]),e,t,n,ns)),`${s}[ ${r}${a?`, ${a}`:""} ]`},kc=e=>typeof Rt(e,Symbol.toStringTag)!="string",s1=e=>typeof e=="function",Ru=(e,t,n)=>{if(e==null)return;const s=Object.getOwnPropertyDescriptor(e,t);if(s===void 0)return;const i=n==="get"?s.get:s.value;return typeof i=="function"?i:void 0},Ou=(e,t)=>{if(e!==void 0)return n=>{try{return e.call(n,t),!0}catch{return!1}}},$t=(e,t)=>Ou(Ru(e,t,"get")),Ze=(e,t,n)=>Ou(Ru(e,t,"value"),n),Sc=Object.freeze({}),He=$t(Reflect.getPrototypeOf(Int8Array.prototype),"length"),i1=typeof SharedArrayBuffer=="function"?SharedArrayBuffer.prototype:void 0,r1=Object.assign(Object.create(null),{Arguments:kc,Array:Cu,ArrayBuffer:$t(ArrayBuffer.prototype,"byteLength"),BigInt:Ze(BigInt.prototype,"valueOf"),Boolean:Ze(Boolean.prototype,"valueOf"),DataView:$t(DataView.prototype,"byteLength"),Date:Ze(Date.prototype,"valueOf"),Error:kc,Float32Array:He,Float64Array:He,Function:s1,Int8Array:He,Int16Array:He,Int32Array:He,Map:$t(Map.prototype,"size"),Number:Ze(Number.prototype,"valueOf"),RegExp:$t(RegExp.prototype,"source"),Set:$t(Set.prototype,"size"),SharedArrayBuffer:$t(i1,"byteLength"),String:Ze(String.prototype,"valueOf"),Symbol:Ze(Symbol.prototype,"valueOf"),Uint8Array:He,Uint8ClampedArray:He,Uint16Array:He,Uint32Array:He,WeakMap:Ze(WeakMap.prototype,"has",Sc),WeakSet:Ze(WeakSet.prototype,"has",Sc)}),o1=(e,t)=>{const n=r1[t];return n===void 0||n(e)},xc=new WeakMap,$c=Object.create(null),a1=Object.assign(Object.create(null),{Arguments:Rk,Array:Nk,ArrayBuffer:uc,AsyncGenerator:mc,BigInt:fc,bigint:fc,Boolean:(e,t)=>t.stylize(String(e),"boolean"),boolean:(e,t)=>t.stylize(String(e),"boolean"),DataView:Hk,Date:Uk,Error:zk,Float32Array:We,Float64Array:We,Function:gc,function:gc,Generator:mc,HTMLCollection:Pr,Int8Array:We,Int16Array:We,Int32Array:We,Map:qk,NodeList:Pr,null:(e,t)=>t.stylize("null","null"),Number:yc,number:yc,Promise:Kk,RegExp:Yk,Set:Xk,SharedArrayBuffer:uc,String:bc,string:bc,Symbol:wc,symbol:wc,Uint8Array:We,Uint8ClampedArray:We,Uint16Array:We,Uint32Array:We,undefined:(e,t)=>t.stylize("undefined","undefined"),WeakMap:(e,t)=>t.stylize("WeakMap{…}","special"),WeakSet:(e,t)=>t.stylize("WeakSet{…}","special")}),c1=Symbol.for("nodejs.util.inspect.custom"),l1=Symbol.for("chai/inspect"),d1=(e,t,n,s)=>{const i=Rt(e,l1);if(typeof i=="function")return i.call(e,t);if(!("window"in globalThis)){const c=Rt(e,c1);if(typeof c=="function")return c.call(e,s,t)}const r=Rt(e,"inspect");if(typeof r=="function")return r.call(e,s,t);const o=Rt(e,"constructor");if(typeof o=="function"&&xc.has(o))return xc.get(o)?.(e,t)??"unknown";const a=Object.hasOwn($c,n)?$c[n]:void 0;return a?a(e,t):""},Wi=(e,t,n)=>{const{depth:s,inspect:i,seen:r}=n;if(r.includes(e))return"[Circular]";if(s>=t.depth&&t.depth>0&&typeof e=="object"&&e!==null)return Cu(e)?"[Array]":"[Object]";const o=t.indent?Ok(t.indent,s):void 0;let a=e===null?"null":typeof e;if(a==="object")try{a=Object.prototype.toString.call(e).slice(8,-1)}catch{a="Object"}let c=a1[a];if(c!==void 0&&typeof e=="object"&&e!==null&&!o1(e,a)&&(c=void 0),c!==void 0)return c(e,t,i,o);if(t.customInspect&&e){const u=d1(e,t,a,t.depth-s);if(u)return typeof u=="string"?u:i(u,e,t)}let l=!1;if(e)try{l=Object.getPrototypeOf(e)}catch{l=Object.prototype}if(l===Object.prototype||l===null)return Ds(e,t,i,o);if(e&&typeof HTMLElement=="function"&&Fk(e,HTMLElement))return $u(e,e,t,i);const d=Rt(e,"constructor");return d!==void 0?d!==Object?Wk(e,t,i,o):Ds(e,t,i,o):e===Object(e)?Ds(e,t,i,o):t.stylize(String(e),a)},Ks=(e,t={})=>{const n={customInspect:!0,depth:5,indent:void 0,maxArrayLength:Number.POSITIVE_INFINITY,numericSeparator:!0,quoteStyle:"single",showHidden:!1,stylize:i=>i,truncate:Number.POSITIVE_INFINITY,...t};if(n.indent!==void 0&&n.indent!==" "&&!(Number.parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `undefined`');const s={depth:0,inspect:void 0,seen:[]};return s.inspect=(i,r,o)=>{if(r==null){s.depth+=1;const c=Wi(i,o,s);return s.depth-=1,c}s.seen.push(r),s.depth+=1;const a=Wi(i,o,s);return s.depth-=1,s.seen.pop(),a},Wi(e,n,s)},u1=new Set(["alert","critical","emergency","error","trace","warning"]),ju=e=>u1.has(e),Tu=(e,t)=>t?(t.__write??t.write.bind(t)).call(t,e):!1,p1=globalThis.process??Object.create(null),Ec={versions:{}},is=new Proxy(p1,{get(e,t){if(t in e)return e[t];if(t in Ec)return Ec[t]}}),vi=e=>{let t;return()=>{if(t===void 0){if(typeof is.getBuiltinModule!="function")throw new TypeError(`[@visulima/error] Cannot load ${e}: this runtime implements no process.getBuiltinModule(). Requires Node ^22.14.0 || >=24.10.0, or another runtime providing process.getBuiltinModule().`);t=is.getBuiltinModule(e)}return t}},f1=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
131
+ `),h1=(e,t,n,s)=>{const i={column:0,line:-1,...e.start},r={...i,...e.end},o=i.line,a=i.column,c=r.line,l=r.column;let d=Math.max(o-(n+1),0),u=Math.min(t.length,c+s);o===-1&&(d=0),c===-1&&(u=t.length);const p=c-o,f={};if(p)for(let h=0;h<=p;h++){const g=h+o;if(!a)f[g]=!0;else if(h===0){const y=t[g-1]?.length;f[g]=[a,(y??0)-a+1]}else if(h===p)f[g]=[0,l];else{const y=t[g-h]?.length;f[g]=[0,y]}}else a===l?f[o]=a?[a,0]:!0:f[o]=[a,(l??0)-(a??0)];return{end:u,markerLines:f,start:d}},g1=is.platform==="win32"&&!is.env?.WT_SESSION?">":"❯",m1=(e,t,n)=>{const s={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...n,color:{gutter:h=>h,marker:h=>h,message:h=>h,...n?.color}},i=typeof t.start.column=="number";let r=(e.includes("\r")?f1(e):e).split(`
132
+ `);typeof s.tabWidth=="number"&&e.includes(" ")&&(r=r.map(h=>h.replaceAll(" "," ".repeat(s.tabWidth))));const{end:o,markerLines:a,start:c}=h1(t,r,s.linesAbove,s.linesBelow),l=String(o).length,{gutter:d,marker:u,message:p}=s.color;let f=r.slice(c,o).map((h,g)=>{const y=c+1+g,x=a[y],b=String(y).padStart(l),S=!a[y+1],C=` ${b}${s.showGutter?" |":""}`;if(x){let N="";if(Array.isArray(x)){const T=h.replaceAll(/[^\t]/g," ").slice(0,Math.max(x[0]-1,0)),D=x[1]||1;N=[`
133
+ `,s.prefix+d(C.replaceAll(/\d/g," "))," ",T,u("^").repeat(D)].join(""),S&&s.message&&(N+=` ${p(s.message)}`)}return[s.prefix+u(g1),d(C),h.length>0?` ${h}`:"",N].join("")}return`${s.prefix} ${d(C)}${h.length>0?` ${h}`:""}`}).join(`
134
134
  `);return s.message&&!i&&(f=`${s.prefix+" ".repeat(l+1)+s.message}
135
- ${f}`),f},f1=()=>ns.env?.DEBUG==="true",Bt=(e,...t)=>{if(f1()){const n=t.map(s=>typeof s=="function"?s():s);console.debug(`error:parse-stacktrace: ${e}`,...n)}},Nt="<unknown>",h1=/^(?:node:internal\/|node:|internal\/)/,g1=e=>e!==void 0&&h1.test(e),m1=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,y1=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,v1=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,b1=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,w1=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,k1=/in\s(.*)\s\(at\s(.+)\)\sat/,S1=/^(?:.*@)?(.*):(\d+):(\d+)$/,x1=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,$1=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,E1=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,$c=/\(error: ([^)]*)\)/,C1=/at\s/,R1=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,O1=/Error: |AggregateError:/,Ou=/^Anonymous function$/,j1=/^\s*in\s.*/,T1=/^.*?\s*at\s.*/,I1=/^.*?\s*@.*|\[native code\]/,ju=(e,t)=>{const n=e.includes("safari-extension"),s=e.includes("safari-web-extension");return n||s?[e.includes("@")?e.split("@")[0]:Nt,n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Tu=(e,t)=>{const n=v1.exec(t);n&&(e.file=n[1],e.line=+n[2],e.column=+n[3])},A1=e=>{const t=k1.exec(e);if(t){Bt(`parse nested node error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const s=t[2].split(":");return{column:s[2]?+s[2]:void 0,file:s[0],line:s[1]?+s[1]:void 0,methodName:t[1]??Nt,raw:e,type:void 0}}const n=w1.exec(e);if(n){Bt(`parse node error stack line: "${e}"`,()=>`found: ${JSON.stringify(n)}`);const s={column:n[4]?+n[4]:void 0,file:n[2]?n[2].replace(C1,""):void 0,line:n[3]?+n[3]:void 0,methodName:n[1]??Nt,raw:e,type:e.startsWith("internal")?"internal":void 0};return Tu(s,`${n[2]}:${n[3]}:${n[4]}`),s}},P1=e=>{const t=m1.exec(e);if(t){Bt(`parse chrome error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const n=t[2]?.startsWith("native"),s=t[2]?.startsWith("eval")||t[1]?.startsWith("eval");let i,r;if(s){const l=y1.exec(e);if(l){const d=R1.exec(l[1]);d?(t[2]=d[4]??d[1],t[3]=d[5]??d[2],t[4]=d[3]):l[2]&&(t[2]=l[1]),l[2]&&(i={column:l[4]?+l[4]:void 0,file:l[2],line:l[3]?+l[3]:void 0,methodName:"eval",raw:e,type:"eval"})}else{const d=b1.exec(e);d&&(r={column:d[4]?+d[4]:void 0,file:d[2],line:d[3]?+d[3]:void 0},i={column:d[6]?+d[6]:void 0,file:d[1],line:d[5]?+d[5]:void 0,methodName:"eval",raw:d[0],type:"eval"})}}const[o,a]=ju(t[1]?t[1].replace(Ou,"<anonymous>"):Nt,t[2]),c={column:t[4]?+t[4]:void 0,evalOrigin:i,file:a,line:t[3]?+t[3]:void 0,methodName:o,raw:e,type:s?"eval":n?"native":g1(a)?"internal":void 0};return r?(c.column=r.column,c.file=r.file,c.line=r.line):Tu(c,`${a}:${t[3]}:${t[4]}`),c}},B1=(e,t)=>{const n=x1.exec(e);if(n){Bt(`parse gecko error stack line: "${e}"`,()=>`found: ${JSON.stringify(n)}`);const s=n[3]?.includes(" > eval"),i=s&&n[3]&&$1.exec(n[3]);let r;s&&i&&(n[3]=i[1],r={column:n[5]?+n[5]:void 0,file:n[3],line:n[4]?+n[4]:void 0,methodName:"eval",raw:e,type:"eval"},n[4]=i[2]);const[o,a]=ju(n[1]?n[1].replace(Ou,"<anonymous>"):Nt,n[3]);let c;(t?.type==="safari"||!s&&t?.type==="firefox")&&t.column?c=t.column:!s&&n[5]&&(c=+n[5]);let l;return(t?.type==="safari"||!s&&t?.type==="firefox")&&t.line?l=t.line:n[4]&&(l=+n[4]),{column:c,evalOrigin:r,file:a,line:l,methodName:o,raw:e,type:s?"eval":a.includes("[native code]")?"native":void 0}}},N1=(e,t)=>{const n=E1.exec(e);if(!(n&&n[2].includes(" > eval"))&&n)return Bt(`parse firefox error stack line: "${e}"`,()=>`found: ${JSON.stringify(n)}`),{column:n[4]?+n[4]:t?.column??void 0,file:n[2],line:n[3]?+n[3]:t?.line??void 0,methodName:n[1]||Nt,raw:e,type:void 0}},D1=e=>{const t=S1.exec(e);if(t)return Bt(`parse react android native error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`),{column:t[3]?+t[3]:void 0,file:t[1],line:t[2]?+t[2]:void 0,methodName:Nt,raw:e,type:void 0}},Iu=(e,{filter:t,frameLimit:n=50}={})=>{const s=e;let i=(typeof s.stacktrace=="string"?s.stacktrace:e.stack??"").split(`
136
- `).map(r=>($c.test(r)?r.replace($c,"$1"):r).trim()).filter(r=>!O1.test(r)&&r!=="eval code");return t&&(i=i.filter(r=>t(r))),i=i.slice(0,n),i.reduce((r,o,a)=>{if(!o||o.length>1024)return r;let c;if(j1.test(o))c=A1(o);else if(T1.test(o))c=P1(o);else if(I1.test(o)){let l;if(a===0){const d=e,u=d.columnNumber,p=d.lineNumber,f=d.line,h=d.column;u||p?l={column:u,line:p,type:"firefox"}:(f||h)&&(l={column:h,line:f,type:"safari"})}c=N1(o,l)??B1(o,l)}else c=D1(o);return c?r.push(c):Bt(`parse error stack line: "${o}"`,"not parser found"),r},[])},Ec=yi("node:fs"),Ds=yi("node:path"),L1=yi("node:process"),M1=yi("node:url"),ct=(e,t,n)=>n===0?e:t===" "?e+" ".repeat(n):e+" ".repeat(t*n),Au=e=>e.replaceAll("\\","/"),_1=e=>{if(!e.startsWith("file:"))return e;try{return M1().fileURLToPath(e)}catch{return e}},F1=(e,t)=>{const n=e.replace("async file:","file:");return Au(Ds().relative(t,_1(n)))},V1=(e,t,n)=>{if(t)return n.title(e.message);const s=e.message?`: ${e.message}`:"";return n.title(e.name+s)},Pu=(e,{color:t,hideErrorTitle:n,indentation:s,prefix:i},r)=>`${ct(i,s,r)}${V1(e,n,t)}
137
- `,Bu=(e,{color:t,indentation:n,prefix:s},i)=>{if(e.hint===void 0)return;const r=ct(s,n,i);let o="";if(Array.isArray(e.hint))for(const a of e.hint)o+=`${r+a}
138
- `;else o+=r+e.hint;return t.hint(o)},Eo=(e,t)=>{if(!t||e.file===void 0||e.line===void 0)return{trace:e};try{const n=t({column:e.column,file:e.file,line:e.line});return n?{source:n.source,trace:{...e,column:n.column??e.column,file:n.file??e.file,line:n.line??e.line}}:{trace:e}}catch{return{trace:e}}},Co=(e,t,n=0)=>{const{color:s,cwd:i,displayShortPath:r,indentation:o,prefix:a}=t,{trace:c}=e;let l;c.file===void 0?l="<unknown>":l=r?F1(c.file,i):Au(c.file);const{fileLine:d,method:u}=s;return`${ct(a,o,n)}at ${c.methodName?`${u(c.methodName)} `:""}${d(l)}:${d(c.line?.toString()??"")}`},W1=(e,t)=>{if(t.allowAllFilePaths)return!0;const n=Ds().resolve(t.cwd),s=Ds().resolve(n,e);return s===n||s.startsWith(n+Ds().sep)},H1=e=>{try{return Ec().existsSync(e)?Ec().readFileSync(e,"utf8"):void 0}catch{return}},Nu=(e,t,n)=>{const{color:s,indentation:i,linesAbove:r,linesBelow:o,prefix:a,showGutter:c,showLineNumbers:l,tabWidth:d}=t,{source:u,trace:p}=e;if(p.file===void 0)return;let f;if(u===void 0){const h=p.file.replace("file://","");if(!W1(h,t))return;const g=H1(h);if(g===void 0)return;f=g}else f=u;return p1(f,{start:{column:p.column,line:p.line}},{color:s,linesAbove:r,linesBelow:o,prefix:ct(a,i,n),showGutter:c,showLineNumbers:l,tabWidth:d})},Du=(e,t,n)=>{if(e.errors.length===0)return;let s=`${ct(t.prefix,t.indentation,n)}Errors:
135
+ ${f}`),f},y1=()=>is.env?.DEBUG==="true",Nt=(e,...t)=>{if(y1()){const n=t.map(s=>typeof s=="function"?s():s);console.debug(`error:parse-stacktrace: ${e}`,...n)}},Dt="<unknown>",v1=/^(?:node:internal\/|node:|internal\/)/,b1=e=>e!==void 0&&v1.test(e),w1=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,k1=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,S1=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,x1=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,$1=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,E1=/in\s(.*)\s\(at\s(.+)\)\sat/,C1=/^(?:.*@)?(.*):(\d+):(\d+)$/,R1=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,O1=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,j1=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,Cc=/\(error: ([^)]*)\)/,T1=/at\s/,I1=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,A1=/Error: |AggregateError:/,Iu=/^Anonymous function$/,B1=/^\s*in\s.*/,P1=/^.*?\s*at\s.*/,N1=/^.*?\s*@.*|\[native code\]/,Au=(e,t)=>{const n=e.includes("safari-extension"),s=e.includes("safari-web-extension");return n||s?[e.includes("@")?e.split("@")[0]:Dt,n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Bu=(e,t)=>{const n=S1.exec(t);n&&(e.file=n[1],e.line=+n[2],e.column=+n[3])},D1=e=>{const t=E1.exec(e);if(t){Nt(`parse nested node error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const s=t[2].split(":");return{column:s[2]?+s[2]:void 0,file:s[0],line:s[1]?+s[1]:void 0,methodName:t[1]??Dt,raw:e,type:void 0}}const n=$1.exec(e);if(n){Nt(`parse node error stack line: "${e}"`,()=>`found: ${JSON.stringify(n)}`);const s={column:n[4]?+n[4]:void 0,file:n[2]?n[2].replace(T1,""):void 0,line:n[3]?+n[3]:void 0,methodName:n[1]??Dt,raw:e,type:e.startsWith("internal")?"internal":void 0};return Bu(s,`${n[2]}:${n[3]}:${n[4]}`),s}},L1=e=>{const t=w1.exec(e);if(t){Nt(`parse chrome error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const n=t[2]?.startsWith("native"),s=t[2]?.startsWith("eval")||t[1]?.startsWith("eval");let i,r;if(s){const l=k1.exec(e);if(l){const d=I1.exec(l[1]);d?(t[2]=d[4]??d[1],t[3]=d[5]??d[2],t[4]=d[3]):l[2]&&(t[2]=l[1]),l[2]&&(i={column:l[4]?+l[4]:void 0,file:l[2],line:l[3]?+l[3]:void 0,methodName:"eval",raw:e,type:"eval"})}else{const d=x1.exec(e);d&&(r={column:d[4]?+d[4]:void 0,file:d[2],line:d[3]?+d[3]:void 0},i={column:d[6]?+d[6]:void 0,file:d[1],line:d[5]?+d[5]:void 0,methodName:"eval",raw:d[0],type:"eval"})}}const[o,a]=Au(t[1]?t[1].replace(Iu,"<anonymous>"):Dt,t[2]),c={column:t[4]?+t[4]:void 0,evalOrigin:i,file:a,line:t[3]?+t[3]:void 0,methodName:o,raw:e,type:s?"eval":n?"native":b1(a)?"internal":void 0};return r?(c.column=r.column,c.file=r.file,c.line=r.line):Bu(c,`${a}:${t[3]}:${t[4]}`),c}},M1=(e,t)=>{const n=R1.exec(e);if(n){Nt(`parse gecko error stack line: "${e}"`,()=>`found: ${JSON.stringify(n)}`);const s=n[3]?.includes(" > eval"),i=s&&n[3]&&O1.exec(n[3]);let r;s&&i&&(n[3]=i[1],r={column:n[5]?+n[5]:void 0,file:n[3],line:n[4]?+n[4]:void 0,methodName:"eval",raw:e,type:"eval"},n[4]=i[2]);const[o,a]=Au(n[1]?n[1].replace(Iu,"<anonymous>"):Dt,n[3]);let c;(t?.type==="safari"||!s&&t?.type==="firefox")&&t.column?c=t.column:!s&&n[5]&&(c=+n[5]);let l;return(t?.type==="safari"||!s&&t?.type==="firefox")&&t.line?l=t.line:n[4]&&(l=+n[4]),{column:c,evalOrigin:r,file:a,line:l,methodName:o,raw:e,type:s?"eval":a.includes("[native code]")?"native":void 0}}},_1=(e,t)=>{const n=j1.exec(e);if(!(n&&n[2].includes(" > eval"))&&n)return Nt(`parse firefox error stack line: "${e}"`,()=>`found: ${JSON.stringify(n)}`),{column:n[4]?+n[4]:t?.column??void 0,file:n[2],line:n[3]?+n[3]:t?.line??void 0,methodName:n[1]||Dt,raw:e,type:void 0}},F1=e=>{const t=C1.exec(e);if(t)return Nt(`parse react android native error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`),{column:t[3]?+t[3]:void 0,file:t[1],line:t[2]?+t[2]:void 0,methodName:Dt,raw:e,type:void 0}},Pu=(e,{filter:t,frameLimit:n=50}={})=>{const s=e;let i=(typeof s.stacktrace=="string"?s.stacktrace:e.stack??"").split(`
136
+ `).map(r=>(Cc.test(r)?r.replace(Cc,"$1"):r).trim()).filter(r=>!A1.test(r)&&r!=="eval code");return t&&(i=i.filter(r=>t(r))),i=i.slice(0,n),i.reduce((r,o,a)=>{if(!o||o.length>1024)return r;let c;if(B1.test(o))c=D1(o);else if(P1.test(o))c=L1(o);else if(N1.test(o)){let l;if(a===0){const d=e,u=d.columnNumber,p=d.lineNumber,f=d.line,h=d.column;u||p?l={column:u,line:p,type:"firefox"}:(f||h)&&(l={column:h,line:f,type:"safari"})}c=_1(o,l)??M1(o,l)}else c=F1(o);return c?r.push(c):Nt(`parse error stack line: "${o}"`,"not parser found"),r},[])},Rc=vi("node:fs"),Ls=vi("node:path"),V1=vi("node:process"),W1=vi("node:url"),lt=(e,t,n)=>n===0?e:t===" "?e+" ".repeat(n):e+" ".repeat(t*n),Nu=e=>e.replaceAll("\\","/"),H1=e=>{if(!e.startsWith("file:"))return e;try{return W1().fileURLToPath(e)}catch{return e}},U1=(e,t)=>{const n=e.replace("async file:","file:");return Nu(Ls().relative(t,H1(n)))},G1=(e,t,n)=>{if(t)return n.title(e.message);const s=e.message?`: ${e.message}`:"";return n.title(e.name+s)},Du=(e,{color:t,hideErrorTitle:n,indentation:s,prefix:i},r)=>`${lt(i,s,r)}${G1(e,n,t)}
137
+ `,Lu=(e,{color:t,indentation:n,prefix:s},i)=>{if(e.hint===void 0)return;const r=lt(s,n,i);let o="";if(Array.isArray(e.hint))for(const a of e.hint)o+=`${r+a}
138
+ `;else o+=r+e.hint;return t.hint(o)},Co=(e,t)=>{if(!t||e.file===void 0||e.line===void 0)return{trace:e};try{const n=t({column:e.column,file:e.file,line:e.line});return n?{source:n.source,trace:{...e,column:n.column??e.column,file:n.file??e.file,line:n.line??e.line}}:{trace:e}}catch{return{trace:e}}},Ro=(e,t,n=0)=>{const{color:s,cwd:i,displayShortPath:r,indentation:o,prefix:a}=t,{trace:c}=e;let l;c.file===void 0?l="<unknown>":l=r?U1(c.file,i):Nu(c.file);const{fileLine:d,method:u}=s;return`${lt(a,o,n)}at ${c.methodName?`${u(c.methodName)} `:""}${d(l)}:${d(c.line?.toString()??"")}`},z1=(e,t)=>{if(t.allowAllFilePaths)return!0;const n=Ls().resolve(t.cwd),s=Ls().resolve(n,e);return s===n||s.startsWith(n+Ls().sep)},J1=e=>{try{return Rc().existsSync(e)?Rc().readFileSync(e,"utf8"):void 0}catch{return}},Mu=(e,t,n)=>{const{color:s,indentation:i,linesAbove:r,linesBelow:o,prefix:a,showGutter:c,showLineNumbers:l,tabWidth:d}=t,{source:u,trace:p}=e;if(p.file===void 0)return;let f;if(u===void 0){const h=p.file.replace("file://","");if(!z1(h,t))return;const g=J1(h);if(g===void 0)return;f=g}else f=u;return m1(f,{start:{column:p.column,line:p.line}},{color:s,linesAbove:r,linesBelow:o,prefix:lt(a,i,n),showGutter:c,showLineNumbers:l,tabWidth:d})},_u=(e,t,n)=>{if(e.errors.length===0)return;let s=`${lt(t.prefix,t.indentation,n)}Errors:
139
139
 
140
140
  `,i=!0;for(const r of e.errors)i?i=!1:s+=`
141
141
 
142
- `,s+=Mu(r,{...t,framesMaxLimit:1,hideErrorCodeView:t.hideErrorErrorsCodeView},n+1);return`
143
- ${s}`},U1=e=>{if(typeof e=="object"&&e!==null)try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}return String(e)},Lu=(e,t,n,s=new Set)=>{s.add(e);let i=`${ct(t.prefix,t.indentation,n)}Caused by:
142
+ `,s+=Vu(r,{...t,framesMaxLimit:1,hideErrorCodeView:t.hideErrorErrorsCodeView},n+1);return`
143
+ ${s}`},q1=e=>{if(typeof e=="object"&&e!==null)try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}return String(e)},Fu=(e,t,n,s=new Set)=>{s.add(e);let i=`${lt(t.prefix,t.indentation,n)}Caused by:
144
144
 
145
- `;const{cause:r}=e;if(!(r instanceof Error)){const c=U1(r);return i+=`${ct(t.prefix,t.indentation,n)}${t.color.title(c)}
145
+ `;const{cause:r}=e;if(!(r instanceof Error)){const c=q1(r);return i+=`${lt(t.prefix,t.indentation,n)}${t.color.title(c)}
146
146
  `,`
147
- ${i}`}i+=Pu(r,t,n);const o=Iu(r).shift(),a=Bu(r,t,n);if(a&&(i+=`${a}
148
- `),o){const c=Eo(o,t.sourceMap);if(i+=Co(c,t,n),!t.hideErrorCauseCodeView){const l=Nu(c,t,n);l!==void 0&&(i+=`
149
- ${l}`)}}if(r instanceof AggregateError){const c=Du(r,t,n);c!==void 0&&(i+=`
147
+ ${i}`}i+=Du(r,t,n);const o=Pu(r).shift(),a=Lu(r,t,n);if(a&&(i+=`${a}
148
+ `),o){const c=Co(o,t.sourceMap);if(i+=Ro(c,t,n),!t.hideErrorCauseCodeView){const l=Mu(c,t,n);l!==void 0&&(i+=`
149
+ ${l}`)}}if(r instanceof AggregateError){const c=_u(r,t,n);c!==void 0&&(i+=`
150
150
  ${c}`)}return r.cause&&(i+=s.has(r)?`
151
- ${ct(t.prefix,t.indentation,n+1)}Caused by: [Circular]`:`
152
- ${Lu(r,t,n+1,s)}`),`
153
- ${i}`},G1=(e,t)=>(e.length>0?`
154
- `:"")+e.map(n=>Co(Eo(n,t.sourceMap),t)).join(`
155
- `),Mu=(e,t,n)=>{const s={allowAllFilePaths:!1,cwd:L1().cwd(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...t,color:{fileLine:a=>a,gutter:a=>a,hint:a=>a,marker:a=>a,message:a=>a,method:a=>a,title:a=>a,...t.color}},i=Iu(e,{filter:t.filterStacktrace,frameLimit:s.framesMaxLimit}),r=i.shift(),o=r?Eo(r,s.sourceMap):void 0;return[t.hideMessage?void 0:Pu(e,s,n),Bu(e,s,n),o?Co(o,s,n):void 0,o&&!s.hideErrorCodeView?Nu(o,s,n):void 0,e instanceof AggregateError?Du(e,s,n):void 0,e.cause===void 0||e.cause===null?void 0:Lu(e,s,n),i.length>0?G1(i,s):void 0].filter(Boolean).join(`
156
- `)},Wi=(e,t={})=>{if(t.framesMaxLimit!==void 0&&t.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return Mu(e,t,0)},z1=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],J1=12288,q1=65510,K1=[12288,12288,65281,65376,65504,65510],Y1=8361,X1=65518,Z1=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],Q1=32,eS=10630,tS=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],nS=4352,sS=262141,_u=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],ds=(e,t)=>{let n=0,s=Math.floor(e.length/2)-1;for(;n<=s;){const i=Math.floor((n+s)/2),r=i*2;if(t<e[r])s=i-1;else if(t>e[r+1])n=i+1;else return!0}return!1},Cc=19968,[iS,rS]=oS(_u);function oS(e){let t=e[0],n=e[1];for(let s=0;s<e.length;s+=2){const i=e[s],r=e[s+1];if(Cc>=i&&Cc<=r)return[i,r];r-i>n-t&&(t=i,n=r)}return[t,n]}const aS=e=>e<161||e>1114109?!1:ds(z1,e),cS=e=>e<J1||e>q1?!1:ds(K1,e),lS=e=>e<Y1||e>X1?!1:ds(Z1,e),dS=e=>e<Q1||e>eS?!1:ds(tS,e),uS=e=>e>=iS&&e<=rS?!0:e<nS||e>sS?!1:ds(_u,e);function pS(e){return aS(e)?"ambiguous":cS(e)?"fullwidth":lS(e)?"halfwidth":dS(e)?"narrow":uS(e)?"wide":"neutral"}function fS(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Fu(e){return fS(e),pS(e)}const Vu=String.raw,Rc=Vu`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,hS=()=>new RegExp(Vu`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${Rc}(?:\u200D${Rc})*`,"gu"),kn=new Set(["\x1B","›"]),vi="\x07",Wu="[",Ro="m",ss="]8;;",gS=39,mS=/[\u200B\uFEFF\u2060-\u2064]/g,yS=new RegExp(`(?:\\${Wu}(?<code>\\d+)m|\\${ss}(?<uri>.*)${vi})`),vS=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),Hu=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,$s=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,bS=hS(),Oc=new Map,wS=e=>[e.ambiguousIsNarrow?1:0,e.control,e.fullWidth,e.regular,e.wide].join("|"),kS=e=>{const t=wS(e.width);let n=Oc.get(t);return n||(n=new Map,Oc.set(t,n)),n},Es=new RegExp(Hu.source,"y"),Hi=new RegExp(bS.source,"uy"),Cs=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Uu=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",SS=(e,t)=>{const n=kS(t),s=Math.floor(e/65536),i=e%65536;let r=n.get(s);if(r||(r=new Map,n.set(s,r)),r.has(i))return r.get(i);let o;switch(Uu(e)){case"control":{o=t.width.control;break}case"latin":{o=t.width.regular;break}case"wide":{o=t.width.wide;break}case"zero":{o=0;break}default:switch(Fu(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}}return r.set(i,o),o},xS=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,Br=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?Br(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},s=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:i}=e,r=i>1e4;let o=0,a=0,c=i,l=!1;const d=e.includes("\x1B")||e.includes("›");for(;o<i;){if(d&&(e[o]==="\x1B"||e[o]==="›")){if(e.startsWith("\x1B]8;;",o)){const y="\x1B]8;;\x07",x=y.length,b=e.indexOf("\x07",o+5);if(b!==-1){const S=e.indexOf(y,b+1);if(S!==-1){const C=S+x,N=e.slice(b+1,S).replace(Hu,""),T=Br(N,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,s-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),D=T.width;if(T.truncated)l=!0,c=Math.min(c,o);else if(a+D>s&&(c=Math.min(c,o),l=!0,a+D>n.truncation.limit))break;if(a+=D,o=C,l&&a>=n.truncation.limit)break;continue}}}if(Es.lastIndex=o,Es.test(e)){const y=Es.lastIndex-o,x=n.truncation.countAnsiEscapeCodes?y:n.width.ansi;if(a+x>s&&(c=Math.min(c,o),a+x>n.truncation.limit)){l=!0;break}a+=x,o=Es.lastIndex;continue}}const f=e.codePointAt(o);if(f===8203||f===65279||f>=8288&&f<=8292){o+=1;continue}if(f===9){if(a+n.width.tab>s&&(c=Math.min(c,o),a+n.width.tab>n.truncation.limit)){l=!0;break}a+=n.width.tab,o+=1;continue}if(Cs.lastIndex=o,Cs.test(e)){const y=(Cs.lastIndex-o)*n.width.regular;if(a+y>s){const x=n.width.regular>0?Math.floor((s-a)/n.width.regular):0;if(c=Math.min(c,o+x),a+y>n.truncation.limit){l=!0;break}}a+=y,o=Cs.lastIndex;continue}if((f<=31||f>=127&&f<=159)&&($s.lastIndex=o,$s.test(e))){const y=($s.lastIndex-o)*n.width.control;if(a+y>s){const x=n.width.control>0?Math.floor((s-a)/n.width.control):0;if(c=Math.min(c,o+x),a+y>n.truncation.limit){l=!0;break}}a+=y,o=$s.lastIndex;continue}if(Hi.lastIndex=o,Hi.test(e)){if(a+n.width.emoji>s&&(c=Math.min(c,o),a+n.width.emoji>n.truncation.limit)){l=!0;break}a+=n.width.emoji,o=Hi.lastIndex;continue}const h=e.codePointAt(o)??0;if(xS(h)){o+=h>65535?2:1;continue}let g;if(r)g=SS(h,n);else switch(Uu(h)){case"control":{g=n.width.control;break}case"latin":{g=n.width.regular;break}case"wide":{g=n.width.wide;break}case"zero":{g=0;break}default:switch(Fu(h)){case"ambiguous":{g=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{g=n.width.fullWidth;break}case"wide":{g=n.width.wide;break}default:g=n.width.regular}}if(a+g>s&&(c=Math.min(c,o),a+g>n.truncation.limit)){l=!0;break}a+=g,o+=h>65535?2:1}let u=a,p=!1;return l&&n.truncation.limit>=n.truncation.ellipsisWidth&&(u=n.truncation.limit,p=!0),{ellipsed:p,index:l?c:i,truncated:l,width:u}},Ie=(e,t={})=>Br(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,$S=/\x1B\[(\d+)m/;let Gu=class{activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const n=$S.exec(t);if(!n)return;const s=Number.parseInt(n[1],10);switch(s){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(s>=30&&s<=37||s>=90&&s<=97)this.activeForeground=t;else if(s>=40&&s<=47||s>=100&&s<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(s))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(s)){const i={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[s];i&&(this.activeFormatting=this.activeFormatting.filter(r=>!r.includes(i)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const n={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(s=>{const i=n[s];i&&t.push(i)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}};const ES=(e,t)=>{if(!kn.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const n=!0,s=e.slice(t+1,t+1+ss.length).join("")===ss;return{isInsideEscape:n,isInsideLinkEscape:s}},CS=(e,t={})=>{const n=new Gu;let s="",i=!1,r="",o="",a=!1;const c=[...e];for(let l=0;l<c.length;l++){const d=c[l];if(d&&kn.has(d)){if(s){const g=t.getWidth?.(s)??0,y={isEscapeSequence:!1,isGrapheme:!0,text:s,width:g};if(a&&(y.isHyperlink=!0,y.hyperlinkUrl=o),t.onSegment?.(y,n)===!1)return;s=""}i=!0,r=d;const f=ES(c,l),{isInsideLinkEscape:h}=f;if(h){let g=l+1;for(o="";g<c.length;){const x=c[g];if(x===vi)break;o+=x,g+=1}o=o.slice(4);const y={hyperlinkUrl:o,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(y,n)===!1)return;l=g,a=!0,i=!1,r="";continue}if(l+1<c.length&&c[l+1]==="\\"&&a){const g={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(g,n)===!1)return;a=!1,o="",l+=1,i=!1,r="";continue}}if(i){if(r!==d&&(r+=d),d===Ro){i=!1,n.processEscape(r);const f={isEscapeSequence:!0,isGrapheme:!1,text:r,width:0};if(t.onSegment?.(f,n)===!1)return;r=""}continue}s+=d;const u=t.getWidth?.(s)??0,p={isEscapeSequence:!1,isGrapheme:!0,text:s,width:u};if(a&&(p.isHyperlink=!0,p.hyperlinkUrl=o),t.onSegment?.(p,n)===!1)return;s=""}if(s){const l=t.getWidth?.(s)??0,d={isEscapeSequence:!1,isGrapheme:!0,text:s,width:l};a&&(d.isHyperlink=!0,d.hyperlinkUrl=o),t.onSegment?.(d,n)}if(r){const l={isEscapeSequence:!0,isGrapheme:!1,text:r,width:0};t.onSegment?.(l,n)}},jc=e=>`${kn.values().next().value}${Wu}${String(e)}${Ro}`,Tc=e=>`${kn.values().next().value}${ss}${e}${vi}`,RS=e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",n,s;const i=e.join(`
157
- `),r=[...i];let o=0;for(const[a,c]of r.entries()){if(t+=c,kn.has(c)){const d=yS.exec(i.slice(o))?.groups??{};if(d.code!==void 0){const u=Number.parseFloat(d.code);n=u===gS?void 0:u}else d.uri!==void 0&&(s=d.uri.length===0?void 0:d.uri)}const l=vS.get(Number(n));r[a+1]===`
158
- `?(s&&(t+=Tc("")),n&&l&&(t+=jc(l))):c===`
159
- `&&(n&&l&&(t+=jc(n)),s&&(t+=Tc(s))),o+=c.length}return t},zu=/(?=\s)|(?<=\s)/,Ju=/^\s+$/,Ic=new Map,OS=e=>{const t=Ic.get(e);if(t!==void 0)return t;const n=Ie(e);return Ic.set(e,n),n},Ui=e=>{if(!e.includes("\x1B"))return e;let t=e;return e.includes("\x1B[30m")&&(t+="\x1B[39m"),e.includes("\x1B[42m")&&(t+="\x1B[49m"),t},Tt=e=>{const t=e.split(" ");let n=t.length;for(;n>0&&Ie(t[n-1])===0;)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},qu=(e,t,n)=>{if(e.length===0)return[""];if(t<=0)return[e];const s=[],i=new Gu;let r="",o=0,a=!1,c=!1,l="",d=0;for(;d<e.length;){const u=e.codePointAt(d),p=String.fromCodePoint(u),f=p.length;if(kn.has(p)){a=!0,l=p,r+=p,c=e.startsWith(ss,d+1),d+=1;continue}if(a){l+=p,r+=p,c?p===vi&&(a=c=!1):p===Ro&&(a=!1,i.processEscape(l)),d+=1;continue}const h=OS(p),g=p===" ";if(h===0){r+=p,d+=f;continue}if(o+h>t&&(r&&s.push(r+i.getEndEscapesForAllActiveAttributes()),r=i.getStartEscapesForAllActiveAttributes(),o=Ie(r),g&&n)){for(;d<e.length&&e[d]===" ";)d+=1;continue}if(r+=p,o+=h,o===t&&d+f<e.length&&(s.push(r+i.getEndEscapesForAllActiveAttributes()),r=i.getStartEscapesForAllActiveAttributes(),o=Ie(r),d+f<e.length&&e[d+f]===" "&&n)){for(d+=f;d<e.length&&e[d]===" ";)d+=1;continue}d+=f}return r&&s.push(r+i.getEndEscapesForAllActiveAttributes()),n?s.map(u=>Tt(u)):s},jS=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const i=[];let r="",o=0;return CS(s,{getWidth:Ie,onSegment:(a,c)=>{const l=a.text??"";if(a.isEscapeSequence)r+=l;else{const d=l===" ";if(a.width===0)return r+=l,!0;if(o+a.width>t&&(r&&i.push(r),r=c.getStartEscapesForAllActiveAttributes(),o=0,d))return n||i.push(c.getStartEscapesForAllActiveAttributes()+l),!0;r+=l,o+=a.width}return!0}}),r&&i.push(r),n?i.map(a=>Tt(a)):i},TS=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const i=s.split(zu),r=[];let o="",a=0,c=0;for(;c<i.length;){const l=i[c],d=Ju.test(l),u=Ie(l);if(l.length===0){c+=1;continue}if(n&&d&&a===0){c+=1;continue}if(a+u>t&&a>0){n?r.push(Tt(o)):r.push(o),o="",a=0;continue}o+=l,a+=u,c+=1}return o&&(n?r.push(Tt(o)):r.push(o)),r},IS=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const i=s.split(zu),r=[];let o="",a=0,c=0;for(;c<i.length;){const l=i[c],d=Ju.test(l),u=Ie(l);if(l.length===0){c+=1;continue}if(n&&d&&a===0){c+=1;continue}if(u>t){o&&r.push(Ui(n?Tt(o):o));const p=qu(l,t,n);if(p.length>0){for(let f=0;f<p.length-1;f+=1)r.push(p[f]);o=p.at(-1),a=Ie(o)}else o="",a=0;c+=1;continue}if(a+u>t&&a>0&&(r.push(Ui(n?Tt(o):o)),o="",a=0,n&&d)){c+=1;continue}o+=l,a+=u,c+=1}return o&&r.push(Ui(n?Tt(o):o)),r},_n={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},AS=(e,t={})=>{const{removeZeroWidthCharacters:n=!0,trim:s=!0,width:i=80,wrapMode:r=_n.PRESERVE_WORDS}=t;if(s&&e.trim()==="")return"";let o=e.normalize("NFC").replaceAll(`\r
151
+ ${lt(t.prefix,t.indentation,n+1)}Caused by: [Circular]`:`
152
+ ${Fu(r,t,n+1,s)}`),`
153
+ ${i}`},K1=(e,t)=>(e.length>0?`
154
+ `:"")+e.map(n=>Ro(Co(n,t.sourceMap),t)).join(`
155
+ `),Vu=(e,t,n)=>{const s={allowAllFilePaths:!1,cwd:V1().cwd(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...t,color:{fileLine:a=>a,gutter:a=>a,hint:a=>a,marker:a=>a,message:a=>a,method:a=>a,title:a=>a,...t.color}},i=Pu(e,{filter:t.filterStacktrace,frameLimit:s.framesMaxLimit}),r=i.shift(),o=r?Co(r,s.sourceMap):void 0;return[t.hideMessage?void 0:Du(e,s,n),Lu(e,s,n),o?Ro(o,s,n):void 0,o&&!s.hideErrorCodeView?Mu(o,s,n):void 0,e instanceof AggregateError?_u(e,s,n):void 0,e.cause===void 0||e.cause===null?void 0:Fu(e,s,n),i.length>0?K1(i,s):void 0].filter(Boolean).join(`
156
+ `)},Hi=(e,t={})=>{if(t.framesMaxLimit!==void 0&&t.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return Vu(e,t,0)},Y1=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],X1=12288,Z1=65510,Q1=[12288,12288,65281,65376,65504,65510],eS=8361,tS=65518,nS=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],sS=32,iS=10630,rS=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],oS=4352,aS=262141,Wu=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],ps=(e,t)=>{let n=0,s=Math.floor(e.length/2)-1;for(;n<=s;){const i=Math.floor((n+s)/2),r=i*2;if(t<e[r])s=i-1;else if(t>e[r+1])n=i+1;else return!0}return!1},Oc=19968,[cS,lS]=dS(Wu);function dS(e){let t=e[0],n=e[1];for(let s=0;s<e.length;s+=2){const i=e[s],r=e[s+1];if(Oc>=i&&Oc<=r)return[i,r];r-i>n-t&&(t=i,n=r)}return[t,n]}const uS=e=>e<161||e>1114109?!1:ps(Y1,e),pS=e=>e<X1||e>Z1?!1:ps(Q1,e),fS=e=>e<eS||e>tS?!1:ps(nS,e),hS=e=>e<sS||e>iS?!1:ps(rS,e),gS=e=>e>=cS&&e<=lS?!0:e<oS||e>aS?!1:ps(Wu,e);function mS(e){return uS(e)?"ambiguous":pS(e)?"fullwidth":fS(e)?"halfwidth":hS(e)?"narrow":gS(e)?"wide":"neutral"}function yS(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Hu(e){return yS(e),mS(e)}const Uu=String.raw,jc=Uu`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,vS=()=>new RegExp(Uu`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${jc}(?:\u200D${jc})*`,"gu"),kn=new Set(["\x1B","›"]),bi="\x07",Gu="[",Oo="m",rs="]8;;",bS=39,wS=/[\u200B\uFEFF\u2060-\u2064]/g,kS=new RegExp(`(?:\\${Gu}(?<code>\\d+)m|\\${rs}(?<uri>.*)${bi})`),SS=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),zu=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,Cs=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,xS=vS(),Tc=new Map,$S=e=>[e.ambiguousIsNarrow?1:0,e.control,e.fullWidth,e.regular,e.wide].join("|"),ES=e=>{const t=$S(e.width);let n=Tc.get(t);return n||(n=new Map,Tc.set(t,n)),n},Rs=new RegExp(zu.source,"y"),Ui=new RegExp(xS.source,"uy"),Os=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Ju=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",CS=(e,t)=>{const n=ES(t),s=Math.floor(e/65536),i=e%65536;let r=n.get(s);if(r||(r=new Map,n.set(s,r)),r.has(i))return r.get(i);let o;switch(Ju(e)){case"control":{o=t.width.control;break}case"latin":{o=t.width.regular;break}case"wide":{o=t.width.wide;break}case"zero":{o=0;break}default:switch(Hu(e)){case"ambiguous":{o=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{o=t.width.fullWidth;break}case"wide":{o=t.width.wide;break}default:o=t.width.regular}}return r.set(i,o),o},RS=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,Nr=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?Nr(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},s=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:i}=e,r=i>1e4;let o=0,a=0,c=i,l=!1;const d=e.includes("\x1B")||e.includes("›");for(;o<i;){if(d&&(e[o]==="\x1B"||e[o]==="›")){if(e.startsWith("\x1B]8;;",o)){const y="\x1B]8;;\x07",x=y.length,b=e.indexOf("\x07",o+5);if(b!==-1){const S=e.indexOf(y,b+1);if(S!==-1){const C=S+x,N=e.slice(b+1,S).replace(zu,""),T=Nr(N,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,s-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),D=T.width;if(T.truncated)l=!0,c=Math.min(c,o);else if(a+D>s&&(c=Math.min(c,o),l=!0,a+D>n.truncation.limit))break;if(a+=D,o=C,l&&a>=n.truncation.limit)break;continue}}}if(Rs.lastIndex=o,Rs.test(e)){const y=Rs.lastIndex-o,x=n.truncation.countAnsiEscapeCodes?y:n.width.ansi;if(a+x>s&&(c=Math.min(c,o),a+x>n.truncation.limit)){l=!0;break}a+=x,o=Rs.lastIndex;continue}}const f=e.codePointAt(o);if(f===8203||f===65279||f>=8288&&f<=8292){o+=1;continue}if(f===9){if(a+n.width.tab>s&&(c=Math.min(c,o),a+n.width.tab>n.truncation.limit)){l=!0;break}a+=n.width.tab,o+=1;continue}if(Os.lastIndex=o,Os.test(e)){const y=(Os.lastIndex-o)*n.width.regular;if(a+y>s){const x=n.width.regular>0?Math.floor((s-a)/n.width.regular):0;if(c=Math.min(c,o+x),a+y>n.truncation.limit){l=!0;break}}a+=y,o=Os.lastIndex;continue}if((f<=31||f>=127&&f<=159)&&(Cs.lastIndex=o,Cs.test(e))){const y=(Cs.lastIndex-o)*n.width.control;if(a+y>s){const x=n.width.control>0?Math.floor((s-a)/n.width.control):0;if(c=Math.min(c,o+x),a+y>n.truncation.limit){l=!0;break}}a+=y,o=Cs.lastIndex;continue}if(Ui.lastIndex=o,Ui.test(e)){if(a+n.width.emoji>s&&(c=Math.min(c,o),a+n.width.emoji>n.truncation.limit)){l=!0;break}a+=n.width.emoji,o=Ui.lastIndex;continue}const h=e.codePointAt(o)??0;if(RS(h)){o+=h>65535?2:1;continue}let g;if(r)g=CS(h,n);else switch(Ju(h)){case"control":{g=n.width.control;break}case"latin":{g=n.width.regular;break}case"wide":{g=n.width.wide;break}case"zero":{g=0;break}default:switch(Hu(h)){case"ambiguous":{g=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{g=n.width.fullWidth;break}case"wide":{g=n.width.wide;break}default:g=n.width.regular}}if(a+g>s&&(c=Math.min(c,o),a+g>n.truncation.limit)){l=!0;break}a+=g,o+=h>65535?2:1}let u=a,p=!1;return l&&n.truncation.limit>=n.truncation.ellipsisWidth&&(u=n.truncation.limit,p=!0),{ellipsed:p,index:l?c:i,truncated:l,width:u}},Ie=(e,t={})=>Nr(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,OS=/\x1B\[(\d+)m/;let qu=class{activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(t){const n=OS.exec(t);if(!n)return;const s=Number.parseInt(n[1],10);switch(s){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(s>=30&&s<=37||s>=90&&s<=97)this.activeForeground=t;else if(s>=40&&s<=47||s>=100&&s<=107)this.activeBackground=t;else if([1,2,3,4,7,8,9].includes(s))this.activeFormatting.push(t);else if([22,23,24,27,28,29].includes(s)){const i={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[s];i&&(this.activeFormatting=this.activeFormatting.filter(r=>!r.includes(i)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const t=[];if(this.activeFormatting.length>0){const n={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(s=>{const i=n[s];i&&t.push(i)})}return this.activeForeground&&t.push("\x1B[39m"),this.activeBackground&&t.push("\x1B[49m"),t.join("")}};const jS=(e,t)=>{if(!kn.has(e[t]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const n=!0,s=e.slice(t+1,t+1+rs.length).join("")===rs;return{isInsideEscape:n,isInsideLinkEscape:s}},TS=(e,t={})=>{const n=new qu;let s="",i=!1,r="",o="",a=!1;const c=[...e];for(let l=0;l<c.length;l++){const d=c[l];if(d&&kn.has(d)){if(s){const g=t.getWidth?.(s)??0,y={isEscapeSequence:!1,isGrapheme:!0,text:s,width:g};if(a&&(y.isHyperlink=!0,y.hyperlinkUrl=o),t.onSegment?.(y,n)===!1)return;s=""}i=!0,r=d;const f=jS(c,l),{isInsideLinkEscape:h}=f;if(h){let g=l+1;for(o="";g<c.length;){const x=c[g];if(x===bi)break;o+=x,g+=1}o=o.slice(4);const y={hyperlinkUrl:o,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(t.onSegment?.(y,n)===!1)return;l=g,a=!0,i=!1,r="";continue}if(l+1<c.length&&c[l+1]==="\\"&&a){const g={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(t.onSegment?.(g,n)===!1)return;a=!1,o="",l+=1,i=!1,r="";continue}}if(i){if(r!==d&&(r+=d),d===Oo){i=!1,n.processEscape(r);const f={isEscapeSequence:!0,isGrapheme:!1,text:r,width:0};if(t.onSegment?.(f,n)===!1)return;r=""}continue}s+=d;const u=t.getWidth?.(s)??0,p={isEscapeSequence:!1,isGrapheme:!0,text:s,width:u};if(a&&(p.isHyperlink=!0,p.hyperlinkUrl=o),t.onSegment?.(p,n)===!1)return;s=""}if(s){const l=t.getWidth?.(s)??0,d={isEscapeSequence:!1,isGrapheme:!0,text:s,width:l};a&&(d.isHyperlink=!0,d.hyperlinkUrl=o),t.onSegment?.(d,n)}if(r){const l={isEscapeSequence:!0,isGrapheme:!1,text:r,width:0};t.onSegment?.(l,n)}},Ic=e=>`${kn.values().next().value}${Gu}${String(e)}${Oo}`,Ac=e=>`${kn.values().next().value}${rs}${e}${bi}`,IS=e=>{if(e.length===0)return"";if(e.length===1)return e[0];let t="",n,s;const i=e.join(`
157
+ `),r=[...i];let o=0;for(const[a,c]of r.entries()){if(t+=c,kn.has(c)){const d=kS.exec(i.slice(o))?.groups??{};if(d.code!==void 0){const u=Number.parseFloat(d.code);n=u===bS?void 0:u}else d.uri!==void 0&&(s=d.uri.length===0?void 0:d.uri)}const l=SS.get(Number(n));r[a+1]===`
158
+ `?(s&&(t+=Ac("")),n&&l&&(t+=Ic(l))):c===`
159
+ `&&(n&&l&&(t+=Ic(n)),s&&(t+=Ac(s))),o+=c.length}return t},Ku=/(?=\s)|(?<=\s)/,Yu=/^\s+$/,Bc=new Map,AS=e=>{const t=Bc.get(e);if(t!==void 0)return t;const n=Ie(e);return Bc.set(e,n),n},Gi=e=>{if(!e.includes("\x1B"))return e;let t=e;return e.includes("\x1B[30m")&&(t+="\x1B[39m"),e.includes("\x1B[42m")&&(t+="\x1B[49m"),t},It=e=>{const t=e.split(" ");let n=t.length;for(;n>0&&Ie(t[n-1])===0;)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},Xu=(e,t,n)=>{if(e.length===0)return[""];if(t<=0)return[e];const s=[],i=new qu;let r="",o=0,a=!1,c=!1,l="",d=0;for(;d<e.length;){const u=e.codePointAt(d),p=String.fromCodePoint(u),f=p.length;if(kn.has(p)){a=!0,l=p,r+=p,c=e.startsWith(rs,d+1),d+=1;continue}if(a){l+=p,r+=p,c?p===bi&&(a=c=!1):p===Oo&&(a=!1,i.processEscape(l)),d+=1;continue}const h=AS(p),g=p===" ";if(h===0){r+=p,d+=f;continue}if(o+h>t&&(r&&s.push(r+i.getEndEscapesForAllActiveAttributes()),r=i.getStartEscapesForAllActiveAttributes(),o=Ie(r),g&&n)){for(;d<e.length&&e[d]===" ";)d+=1;continue}if(r+=p,o+=h,o===t&&d+f<e.length&&(s.push(r+i.getEndEscapesForAllActiveAttributes()),r=i.getStartEscapesForAllActiveAttributes(),o=Ie(r),d+f<e.length&&e[d+f]===" "&&n)){for(d+=f;d<e.length&&e[d]===" ";)d+=1;continue}d+=f}return r&&s.push(r+i.getEndEscapesForAllActiveAttributes()),n?s.map(u=>It(u)):s},BS=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const i=[];let r="",o=0;return TS(s,{getWidth:Ie,onSegment:(a,c)=>{const l=a.text??"";if(a.isEscapeSequence)r+=l;else{const d=l===" ";if(a.width===0)return r+=l,!0;if(o+a.width>t&&(r&&i.push(r),r=c.getStartEscapesForAllActiveAttributes(),o=0,d))return n||i.push(c.getStartEscapesForAllActiveAttributes()+l),!0;r+=l,o+=a.width}return!0}}),r&&i.push(r),n?i.map(a=>It(a)):i},PS=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const i=s.split(Ku),r=[];let o="",a=0,c=0;for(;c<i.length;){const l=i[c],d=Yu.test(l),u=Ie(l);if(l.length===0){c+=1;continue}if(n&&d&&a===0){c+=1;continue}if(a+u>t&&a>0){n?r.push(It(o)):r.push(o),o="",a=0;continue}o+=l,a+=u,c+=1}return o&&(n?r.push(It(o)):r.push(o)),r},NS=(e,t,n)=>{if(e.length===0)return[];const s=n?e.trim():e;if(s.length===0)return[];const i=s.split(Ku),r=[];let o="",a=0,c=0;for(;c<i.length;){const l=i[c],d=Yu.test(l),u=Ie(l);if(l.length===0){c+=1;continue}if(n&&d&&a===0){c+=1;continue}if(u>t){o&&r.push(Gi(n?It(o):o));const p=Xu(l,t,n);if(p.length>0){for(let f=0;f<p.length-1;f+=1)r.push(p[f]);o=p.at(-1),a=Ie(o)}else o="",a=0;c+=1;continue}if(a+u>t&&a>0&&(r.push(Gi(n?It(o):o)),o="",a=0,n&&d)){c+=1;continue}o+=l,a+=u,c+=1}return o&&r.push(Gi(n?It(o):o)),r},_n={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},DS=(e,t={})=>{const{removeZeroWidthCharacters:n=!0,trim:s=!0,width:i=80,wrapMode:r=_n.PRESERVE_WORDS}=t;if(s&&e.trim()==="")return"";let o=e.normalize("NFC").replaceAll(`\r
160
160
  `,`
161
- `);return n&&(o=o.replaceAll(mS,"")),o.split(`
162
- `).map(a=>{if(s&&a.trim()==="")return"";let c;switch(r){case _n.BREAK_AT_CHARACTERS:{c=jS(a,i,s);break}case _n.BREAK_WORDS:{c=IS(a,i,s);break}case _n.STRICT_WIDTH:{c=qu(a,i,s);break}default:c=TS(a,i,s)}return RS(c)}).join(`
163
- `)},Ku=80,Yu=24,Nr=(e,t,{shell:n,env:s}={})=>vk(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:s}).trim(),Ls=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),Xu=(e,t)=>{const{columns:n,rows:s}=Ls(e,t);if(!(Number.isNaN(n)||Number.isNaN(s))&&!(n===Ku&&s===Yu))return{columns:n,rows:s}},PS=()=>{if(at.platform!=="linux")return!0;try{const e=Mn.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const n=e.slice(t+2).trim().split(/\s+/),s=Number.parseInt(n[2],10),i=Number.parseInt(n[5],10);return Number.isNaN(s)||Number.isNaN(i)||i<=0?!1:s===i}catch{return!1}};function BS(){const{env:e,stdout:t,stderr:n}=at;if(t?.columns&&t?.rows)return Ls(t.columns,t.rows);if(n?.columns&&n?.rows)return Ls(n.columns,n.rows);if(e.COLUMNS&&e.LINES)return Ls(e.COLUMNS,e.LINES);const s={columns:Ku,rows:Yu};return at.platform==="win32"?Gi()??s:at.platform==="darwin"?Ac()??Gi()??s:Ac()??Gi()??NS()??s}const Ac=()=>{try{const e=at.platform==="darwin"?Mn.constants.O_EVTONLY|Mn.constants.O_NONBLOCK:Mn.constants.O_NONBLOCK,{columns:t,rows:n}=bk.WriteStream(Mn.openSync("/dev/tty",e));return{columns:t,rows:n}}catch{}},Gi=()=>{try{const e=Nr("tput",["cols"],{env:{TERM:"dumb",...at.env}}),t=Nr("tput",["lines"],{env:{TERM:"dumb",...at.env}});if(e&&t)return Xu(e,t)}catch{}},NS=()=>{try{if(!PS())return;const e=Nr("resize",["-u"]).match(/\d+/g);if(e.length===2)return Xu(e[0],e[1])}catch{}},DS=e=>{const t=Object.keys(e).map(n=>e[n].badge??"");return t.length===0?"":t.reduce((n,s)=>n.length>s.length?n:s,"")},{bold:LS,cyan:MS,green:Pc,grey:_S,magenta:FS,red:VS,yellow:zi}=si,WS={indent:2,quoteStyle:"single",stylize:(e,t)=>{const n={bigint:zi,boolean:zi,date:FS,null:LS,number:zi,regexp:VS,special:MS,string:Pc,symbol:Pc,undefined:_S};return Object.hasOwn(n,t)?n[t](e):e}},{bold:HS,underline:US}=si,GS=(e,t)=>{let n=t.uppercase.label?e.toUpperCase():e;return n=t.underline.label?US(n):n,t.bold.label&&(n=HS(n)),n},zS=e=>[e.getHours(),e.getMinutes(),e.getSeconds()].map(t=>String(t).padStart(2,"0")).join(":");class JS{styles;loggerTypes;constructor(t){this.styles={bold:{label:!1},dateFormatter:zS,underline:{label:!1,message:!1,prefix:!1,suffix:!1},uppercase:{label:!1},...t},this.loggerTypes=bu}setLoggerTypes(t){this.loggerTypes=t}}const qS=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:Oo,stderr:jo,env:Un}=qS,KS="\x1B",Dt="\x1B[",YS=";",Zu=typeof globalThis<"u"&&typeof globalThis.window=="object"&&globalThis.window.document!==void 0,XS=/^(?:msys|cygwin)$/,Qu=process,Dr=Qu?.env??{};!Zu&&Dr.TERM_PROGRAM;const ZS=!Zu&&(Qu?.platform==="win32"||Dr.OSTYPE!==void 0&&XS.test(Dr.OSTYPE)),QS=(e,t)=>`${Dt}${String(t+1)}${YS}${String(e+1)}H`;var e2=(e=>(e[e.Default=0]="Default",e[e.BlinkingBlock=1]="BlinkingBlock",e[e.SteadyBlock=2]="SteadyBlock",e[e.BlinkingUnderline=3]="BlinkingUnderline",e[e.SteadyUnderline=4]="SteadyUnderline",e[e.BlinkingBar=5]="BlinkingBar",e[e.SteadyBar=6]="SteadyBar",e))(e2||{}),cn=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(cn||{});const Gn=e=>{const t=e>=0&&e<=3?e:0;return`${Dt}${t===0?"":String(t)}J`};var ep=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(ep||{});const t2=e=>{const t=e>=0&&e<=2?e:0;return`${Dt}${t===0?"":String(t)}K`};QS(0,0)+Gn(cn.ToEnd);`${t2(ep.EntireLine)}${Dt}`;`${Dt}${Gn(cn.EntireScreen)}`;const Bc=ZS?`${Gn(cn.EntireScreen)}${Dt}0f`:`${Gn(cn.EntireScreen)}${Gn(cn.EntireScreenAndScrollback)}${Dt}H${KS}c`;var Ji={exports:{}},Nc;function n2(){return Nc||(Nc=1,(function(e,t){const{hasOwnProperty:n}=Object.prototype,s=x();s.configure=x,s.stringify=s,s.default=s,t.stringify=s,t.configure=x,e.exports=s;const i=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function r(b){return b.length<5e3&&!i.test(b)?`"${b}"`:JSON.stringify(b)}function o(b,S){if(b.length>200||S)return b.sort(S);for(let C=1;C<b.length;C++){const N=b[C];let T=C;for(;T!==0&&b[T-1]>N;)b[T]=b[T-1],T--;b[T]=N}return b}const a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(b){return a.call(b)!==void 0&&b.length!==0}function l(b,S,C){b.length<C&&(C=b.length);const N=S===","?"":" ";let T=`"0":${N}${b[0]}`;for(let D=1;D<C;D++)T+=`${S}"${D}":${N}${b[D]}`;return T}function d(b){if(n.call(b,"circularValue")){const S=b.circularValue;if(typeof S=="string")return`"${S}"`;if(S==null)return S;if(S===Error||S===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function u(b){let S;if(n.call(b,"deterministic")&&(S=b.deterministic,typeof S!="boolean"&&typeof S!="function"))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return S===void 0?!0:S}function p(b,S){let C;if(n.call(b,S)&&(C=b[S],typeof C!="boolean"))throw new TypeError(`The "${S}" argument must be of type boolean`);return C===void 0?!0:C}function f(b,S){let C;if(n.call(b,S)){if(C=b[S],typeof C!="number")throw new TypeError(`The "${S}" argument must be of type number`);if(!Number.isInteger(C))throw new TypeError(`The "${S}" argument must be an integer`);if(C<1)throw new RangeError(`The "${S}" argument must be >= 1`)}return C===void 0?1/0:C}function h(b){return b===1?"1 item":`${b} items`}function g(b){const S=new Set;for(const C of b)(typeof C=="string"||typeof C=="number")&&S.add(String(C));return S}function y(b){if(n.call(b,"strict")){const S=b.strict;if(typeof S!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(S)return C=>{let N=`Object can not safely be stringified. Received type ${typeof C}`;throw typeof C!="function"&&(N+=` (${C.toString()})`),new Error(N)}}}function x(b){b={...b};const S=y(b);S&&(b.bigint===void 0&&(b.bigint=!1),"circularValue"in b||(b.circularValue=Error));const C=d(b),N=p(b,"bigint"),T=u(b),D=typeof T=="function"?T:void 0,F=f(b,"maximumDepth"),V=f(b,"maximumBreadth");function Z(M,w,A,U,I,P){let j=w[M];switch(typeof j=="object"&&j!==null&&typeof j.toJSON=="function"&&(j=j.toJSON(M)),j=U.call(w,M,j),typeof j){case"string":return r(j);case"object":{if(j===null)return"null";if(A.indexOf(j)!==-1)return C;let _="",H=",";const z=P;if(Array.isArray(j)){if(j.length===0)return"[]";if(F<A.length+1)return'"[Array]"';A.push(j),I!==""&&(P+=I,_+=`
164
- ${P}`,H=`,
165
- ${P}`);const ge=Math.min(j.length,V);let ke=0;for(;ke<ge-1;ke++){const wt=Z(String(ke),j,A,U,I,P);_+=wt!==void 0?wt:"null",_+=H}const Se=Z(String(ke),j,A,U,I,P);if(_+=Se!==void 0?Se:"null",j.length-1>V){const wt=j.length-V-1;_+=`${H}"... ${h(wt)} not stringified"`}return I!==""&&(_+=`
166
- ${z}`),A.pop(),`[${_}]`}let Y=Object.keys(j);const B=Y.length;if(B===0)return"{}";if(F<A.length+1)return'"[Object]"';let K="",ae="";I!==""&&(P+=I,H=`,
167
- ${P}`,K=" ");const le=Math.min(B,V);T&&!c(j)&&(Y=o(Y,D)),A.push(j);for(let ge=0;ge<le;ge++){const ke=Y[ge],Se=Z(ke,j,A,U,I,P);Se!==void 0&&(_+=`${ae}${r(ke)}:${K}${Se}`,ae=H)}if(B>V){const ge=B-V;_+=`${ae}"...":${K}"${h(ge)} not stringified"`,ae=H}return I!==""&&ae.length>1&&(_=`
168
- ${P}${_}
169
- ${z}`),A.pop(),`{${_}}`}case"number":return isFinite(j)?String(j):S?S(j):"null";case"boolean":return j===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(j);default:return S?S(j):void 0}}function re(M,w,A,U,I,P){switch(typeof w=="object"&&w!==null&&typeof w.toJSON=="function"&&(w=w.toJSON(M)),typeof w){case"string":return r(w);case"object":{if(w===null)return"null";if(A.indexOf(w)!==-1)return C;const j=P;let _="",H=",";if(Array.isArray(w)){if(w.length===0)return"[]";if(F<A.length+1)return'"[Array]"';A.push(w),I!==""&&(P+=I,_+=`
170
- ${P}`,H=`,
171
- ${P}`);const B=Math.min(w.length,V);let K=0;for(;K<B-1;K++){const le=re(String(K),w[K],A,U,I,P);_+=le!==void 0?le:"null",_+=H}const ae=re(String(K),w[K],A,U,I,P);if(_+=ae!==void 0?ae:"null",w.length-1>V){const le=w.length-V-1;_+=`${H}"... ${h(le)} not stringified"`}return I!==""&&(_+=`
172
- ${j}`),A.pop(),`[${_}]`}A.push(w);let z="";I!==""&&(P+=I,H=`,
173
- ${P}`,z=" ");let Y="";for(const B of U){const K=re(B,w[B],A,U,I,P);K!==void 0&&(_+=`${Y}${r(B)}:${z}${K}`,Y=H)}return I!==""&&Y.length>1&&(_=`
174
- ${P}${_}
175
- ${j}`),A.pop(),`{${_}}`}case"number":return isFinite(w)?String(w):S?S(w):"null";case"boolean":return w===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(w);default:return S?S(w):void 0}}function te(M,w,A,U,I){switch(typeof w){case"string":return r(w);case"object":{if(w===null)return"null";if(typeof w.toJSON=="function"){if(w=w.toJSON(M),typeof w!="object")return te(M,w,A,U,I);if(w===null)return"null"}if(A.indexOf(w)!==-1)return C;const P=I;if(Array.isArray(w)){if(w.length===0)return"[]";if(F<A.length+1)return'"[Array]"';A.push(w),I+=U;let K=`
161
+ `);return n&&(o=o.replaceAll(wS,"")),o.split(`
162
+ `).map(a=>{if(s&&a.trim()==="")return"";let c;switch(r){case _n.BREAK_AT_CHARACTERS:{c=BS(a,i,s);break}case _n.BREAK_WORDS:{c=NS(a,i,s);break}case _n.STRICT_WIDTH:{c=Xu(a,i,s);break}default:c=PS(a,i,s)}return IS(c)}).join(`
163
+ `)},Zu=80,Qu=24,Dr=(e,t,{shell:n,env:s}={})=>Sk(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:s}).trim(),Ms=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),ep=(e,t)=>{const{columns:n,rows:s}=Ms(e,t);if(!(Number.isNaN(n)||Number.isNaN(s))&&!(n===Zu&&s===Qu))return{columns:n,rows:s}},LS=()=>{if(ct.platform!=="linux")return!0;try{const e=Mn.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const n=e.slice(t+2).trim().split(/\s+/),s=Number.parseInt(n[2],10),i=Number.parseInt(n[5],10);return Number.isNaN(s)||Number.isNaN(i)||i<=0?!1:s===i}catch{return!1}};function MS(){const{env:e,stdout:t,stderr:n}=ct;if(t?.columns&&t?.rows)return Ms(t.columns,t.rows);if(n?.columns&&n?.rows)return Ms(n.columns,n.rows);if(e.COLUMNS&&e.LINES)return Ms(e.COLUMNS,e.LINES);const s={columns:Zu,rows:Qu};return ct.platform==="win32"?zi()??s:ct.platform==="darwin"?Pc()??zi()??s:Pc()??zi()??_S()??s}const Pc=()=>{try{const e=ct.platform==="darwin"?Mn.constants.O_EVTONLY|Mn.constants.O_NONBLOCK:Mn.constants.O_NONBLOCK,{columns:t,rows:n}=xk.WriteStream(Mn.openSync("/dev/tty",e));return{columns:t,rows:n}}catch{}},zi=()=>{try{const e=Dr("tput",["cols"],{env:{TERM:"dumb",...ct.env}}),t=Dr("tput",["lines"],{env:{TERM:"dumb",...ct.env}});if(e&&t)return ep(e,t)}catch{}},_S=()=>{try{if(!LS())return;const e=Dr("resize",["-u"]).match(/\d+/g);if(e.length===2)return ep(e[0],e[1])}catch{}},FS=e=>{const t=Object.keys(e).map(n=>e[n].badge??"");return t.length===0?"":t.reduce((n,s)=>n.length>s.length?n:s,"")},{bold:VS,cyan:WS,green:Nc,grey:HS,magenta:US,red:GS,yellow:Ji}=ii,zS={indent:2,quoteStyle:"single",stylize:(e,t)=>{const n={bigint:Ji,boolean:Ji,date:US,null:VS,number:Ji,regexp:GS,special:WS,string:Nc,symbol:Nc,undefined:HS};return Object.hasOwn(n,t)?n[t](e):e}},{bold:JS,underline:qS}=ii,KS=(e,t)=>{let n=t.uppercase.label?e.toUpperCase():e;return n=t.underline.label?qS(n):n,t.bold.label&&(n=JS(n)),n},YS=e=>[e.getHours(),e.getMinutes(),e.getSeconds()].map(t=>String(t).padStart(2,"0")).join(":");class XS{styles;loggerTypes;constructor(t){this.styles={bold:{label:!1},dateFormatter:YS,underline:{label:!1,message:!1,prefix:!1,suffix:!1},uppercase:{label:!1},...t},this.loggerTypes=Su}setLoggerTypes(t){this.loggerTypes=t}}const ZS=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:jo,stderr:To,env:Gn}=ZS,QS="\x1B",Lt="\x1B[",e2=";",tp=typeof globalThis<"u"&&typeof globalThis.window=="object"&&globalThis.window.document!==void 0,t2=/^(?:msys|cygwin)$/,np=process,Lr=np?.env??{};!tp&&Lr.TERM_PROGRAM;const n2=!tp&&(np?.platform==="win32"||Lr.OSTYPE!==void 0&&t2.test(Lr.OSTYPE)),s2=(e,t)=>`${Lt}${String(t+1)}${e2}${String(e+1)}H`;var i2=(e=>(e[e.Default=0]="Default",e[e.BlinkingBlock=1]="BlinkingBlock",e[e.SteadyBlock=2]="SteadyBlock",e[e.BlinkingUnderline=3]="BlinkingUnderline",e[e.SteadyUnderline=4]="SteadyUnderline",e[e.BlinkingBar=5]="BlinkingBar",e[e.SteadyBar=6]="SteadyBar",e))(i2||{}),ln=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(ln||{});const zn=e=>{const t=e>=0&&e<=3?e:0;return`${Lt}${t===0?"":String(t)}J`};var sp=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(sp||{});const r2=e=>{const t=e>=0&&e<=2?e:0;return`${Lt}${t===0?"":String(t)}K`};s2(0,0)+zn(ln.ToEnd);`${r2(sp.EntireLine)}${Lt}`;`${Lt}${zn(ln.EntireScreen)}`;const Dc=n2?`${zn(ln.EntireScreen)}${Lt}0f`:`${zn(ln.EntireScreen)}${zn(ln.EntireScreenAndScrollback)}${Lt}H${QS}c`;var qi={exports:{}},Lc;function o2(){return Lc||(Lc=1,(function(e,t){const{hasOwnProperty:n}=Object.prototype,s=x();s.configure=x,s.stringify=s,s.default=s,t.stringify=s,t.configure=x,e.exports=s;const i=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function r(b){return b.length<5e3&&!i.test(b)?`"${b}"`:JSON.stringify(b)}function o(b,S){if(b.length>200||S)return b.sort(S);for(let C=1;C<b.length;C++){const N=b[C];let T=C;for(;T!==0&&b[T-1]>N;)b[T]=b[T-1],T--;b[T]=N}return b}const a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(b){return a.call(b)!==void 0&&b.length!==0}function l(b,S,C){b.length<C&&(C=b.length);const N=S===","?"":" ";let T=`"0":${N}${b[0]}`;for(let D=1;D<C;D++)T+=`${S}"${D}":${N}${b[D]}`;return T}function d(b){if(n.call(b,"circularValue")){const S=b.circularValue;if(typeof S=="string")return`"${S}"`;if(S==null)return S;if(S===Error||S===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function u(b){let S;if(n.call(b,"deterministic")&&(S=b.deterministic,typeof S!="boolean"&&typeof S!="function"))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return S===void 0?!0:S}function p(b,S){let C;if(n.call(b,S)&&(C=b[S],typeof C!="boolean"))throw new TypeError(`The "${S}" argument must be of type boolean`);return C===void 0?!0:C}function f(b,S){let C;if(n.call(b,S)){if(C=b[S],typeof C!="number")throw new TypeError(`The "${S}" argument must be of type number`);if(!Number.isInteger(C))throw new TypeError(`The "${S}" argument must be an integer`);if(C<1)throw new RangeError(`The "${S}" argument must be >= 1`)}return C===void 0?1/0:C}function h(b){return b===1?"1 item":`${b} items`}function g(b){const S=new Set;for(const C of b)(typeof C=="string"||typeof C=="number")&&S.add(String(C));return S}function y(b){if(n.call(b,"strict")){const S=b.strict;if(typeof S!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(S)return C=>{let N=`Object can not safely be stringified. Received type ${typeof C}`;throw typeof C!="function"&&(N+=` (${C.toString()})`),new Error(N)}}}function x(b){b={...b};const S=y(b);S&&(b.bigint===void 0&&(b.bigint=!1),"circularValue"in b||(b.circularValue=Error));const C=d(b),N=p(b,"bigint"),T=u(b),D=typeof T=="function"?T:void 0,F=f(b,"maximumDepth"),V=f(b,"maximumBreadth");function Z(M,w,A,U,I,B){let j=w[M];switch(typeof j=="object"&&j!==null&&typeof j.toJSON=="function"&&(j=j.toJSON(M)),j=U.call(w,M,j),typeof j){case"string":return r(j);case"object":{if(j===null)return"null";if(A.indexOf(j)!==-1)return C;let _="",H=",";const z=B;if(Array.isArray(j)){if(j.length===0)return"[]";if(F<A.length+1)return'"[Array]"';A.push(j),I!==""&&(B+=I,_+=`
164
+ ${B}`,H=`,
165
+ ${B}`);const ge=Math.min(j.length,V);let Se=0;for(;Se<ge-1;Se++){const kt=Z(String(Se),j,A,U,I,B);_+=kt!==void 0?kt:"null",_+=H}const xe=Z(String(Se),j,A,U,I,B);if(_+=xe!==void 0?xe:"null",j.length-1>V){const kt=j.length-V-1;_+=`${H}"... ${h(kt)} not stringified"`}return I!==""&&(_+=`
166
+ ${z}`),A.pop(),`[${_}]`}let Y=Object.keys(j);const P=Y.length;if(P===0)return"{}";if(F<A.length+1)return'"[Object]"';let K="",ae="";I!==""&&(B+=I,H=`,
167
+ ${B}`,K=" ");const le=Math.min(P,V);T&&!c(j)&&(Y=o(Y,D)),A.push(j);for(let ge=0;ge<le;ge++){const Se=Y[ge],xe=Z(Se,j,A,U,I,B);xe!==void 0&&(_+=`${ae}${r(Se)}:${K}${xe}`,ae=H)}if(P>V){const ge=P-V;_+=`${ae}"...":${K}"${h(ge)} not stringified"`,ae=H}return I!==""&&ae.length>1&&(_=`
168
+ ${B}${_}
169
+ ${z}`),A.pop(),`{${_}}`}case"number":return isFinite(j)?String(j):S?S(j):"null";case"boolean":return j===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(j);default:return S?S(j):void 0}}function re(M,w,A,U,I,B){switch(typeof w=="object"&&w!==null&&typeof w.toJSON=="function"&&(w=w.toJSON(M)),typeof w){case"string":return r(w);case"object":{if(w===null)return"null";if(A.indexOf(w)!==-1)return C;const j=B;let _="",H=",";if(Array.isArray(w)){if(w.length===0)return"[]";if(F<A.length+1)return'"[Array]"';A.push(w),I!==""&&(B+=I,_+=`
170
+ ${B}`,H=`,
171
+ ${B}`);const P=Math.min(w.length,V);let K=0;for(;K<P-1;K++){const le=re(String(K),w[K],A,U,I,B);_+=le!==void 0?le:"null",_+=H}const ae=re(String(K),w[K],A,U,I,B);if(_+=ae!==void 0?ae:"null",w.length-1>V){const le=w.length-V-1;_+=`${H}"... ${h(le)} not stringified"`}return I!==""&&(_+=`
172
+ ${j}`),A.pop(),`[${_}]`}A.push(w);let z="";I!==""&&(B+=I,H=`,
173
+ ${B}`,z=" ");let Y="";for(const P of U){const K=re(P,w[P],A,U,I,B);K!==void 0&&(_+=`${Y}${r(P)}:${z}${K}`,Y=H)}return I!==""&&Y.length>1&&(_=`
174
+ ${B}${_}
175
+ ${j}`),A.pop(),`{${_}}`}case"number":return isFinite(w)?String(w):S?S(w):"null";case"boolean":return w===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(w);default:return S?S(w):void 0}}function te(M,w,A,U,I){switch(typeof w){case"string":return r(w);case"object":{if(w===null)return"null";if(typeof w.toJSON=="function"){if(w=w.toJSON(M),typeof w!="object")return te(M,w,A,U,I);if(w===null)return"null"}if(A.indexOf(w)!==-1)return C;const B=I;if(Array.isArray(w)){if(w.length===0)return"[]";if(F<A.length+1)return'"[Array]"';A.push(w),I+=U;let K=`
176
176
  ${I}`;const ae=`,
177
- ${I}`,le=Math.min(w.length,V);let ge=0;for(;ge<le-1;ge++){const Se=te(String(ge),w[ge],A,U,I);K+=Se!==void 0?Se:"null",K+=ae}const ke=te(String(ge),w[ge],A,U,I);if(K+=ke!==void 0?ke:"null",w.length-1>V){const Se=w.length-V-1;K+=`${ae}"... ${h(Se)} not stringified"`}return K+=`
178
- ${P}`,A.pop(),`[${K}]`}let j=Object.keys(w);const _=j.length;if(_===0)return"{}";if(F<A.length+1)return'"[Object]"';I+=U;const H=`,
179
- ${I}`;let z="",Y="",B=Math.min(_,V);c(w)&&(z+=l(w,H,V),j=j.slice(w.length),B-=w.length,Y=H),T&&(j=o(j,D)),A.push(w);for(let K=0;K<B;K++){const ae=j[K],le=te(ae,w[ae],A,U,I);le!==void 0&&(z+=`${Y}${r(ae)}: ${le}`,Y=H)}if(_>V){const K=_-V;z+=`${Y}"...": "${h(K)} not stringified"`,Y=H}return Y!==""&&(z=`
177
+ ${I}`,le=Math.min(w.length,V);let ge=0;for(;ge<le-1;ge++){const xe=te(String(ge),w[ge],A,U,I);K+=xe!==void 0?xe:"null",K+=ae}const Se=te(String(ge),w[ge],A,U,I);if(K+=Se!==void 0?Se:"null",w.length-1>V){const xe=w.length-V-1;K+=`${ae}"... ${h(xe)} not stringified"`}return K+=`
178
+ ${B}`,A.pop(),`[${K}]`}let j=Object.keys(w);const _=j.length;if(_===0)return"{}";if(F<A.length+1)return'"[Object]"';I+=U;const H=`,
179
+ ${I}`;let z="",Y="",P=Math.min(_,V);c(w)&&(z+=l(w,H,V),j=j.slice(w.length),P-=w.length,Y=H),T&&(j=o(j,D)),A.push(w);for(let K=0;K<P;K++){const ae=j[K],le=te(ae,w[ae],A,U,I);le!==void 0&&(z+=`${Y}${r(ae)}: ${le}`,Y=H)}if(_>V){const K=_-V;z+=`${Y}"...": "${h(K)} not stringified"`,Y=H}return Y!==""&&(z=`
180
180
  ${I}${z}
181
- ${P}`),A.pop(),`{${z}}`}case"number":return isFinite(w)?String(w):S?S(w):"null";case"boolean":return w===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(w);default:return S?S(w):void 0}}function ne(M,w,A){switch(typeof w){case"string":return r(w);case"object":{if(w===null)return"null";if(typeof w.toJSON=="function"){if(w=w.toJSON(M),typeof w!="object")return ne(M,w,A);if(w===null)return"null"}if(A.indexOf(w)!==-1)return C;let U="";const I=w.length!==void 0;if(I&&Array.isArray(w)){if(w.length===0)return"[]";if(F<A.length+1)return'"[Array]"';A.push(w);const z=Math.min(w.length,V);let Y=0;for(;Y<z-1;Y++){const K=ne(String(Y),w[Y],A);U+=K!==void 0?K:"null",U+=","}const B=ne(String(Y),w[Y],A);if(U+=B!==void 0?B:"null",w.length-1>V){const K=w.length-V-1;U+=`,"... ${h(K)} not stringified"`}return A.pop(),`[${U}]`}let P=Object.keys(w);const j=P.length;if(j===0)return"{}";if(F<A.length+1)return'"[Object]"';let _="",H=Math.min(j,V);I&&c(w)&&(U+=l(w,",",V),P=P.slice(w.length),H-=w.length,_=","),T&&(P=o(P,D)),A.push(w);for(let z=0;z<H;z++){const Y=P[z],B=ne(Y,w[Y],A);B!==void 0&&(U+=`${_}${r(Y)}:${B}`,_=",")}if(j>V){const z=j-V;U+=`${_}"...":"${h(z)} not stringified"`}return A.pop(),`{${U}}`}case"number":return isFinite(w)?String(w):S?S(w):"null";case"boolean":return w===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(w);default:return S?S(w):void 0}}function ie(M,w,A){if(arguments.length>1){let U="";if(typeof A=="number"?U=" ".repeat(Math.min(A,10)):typeof A=="string"&&(U=A.slice(0,10)),w!=null){if(typeof w=="function")return Z("",{"":M},[],w,U,"");if(Array.isArray(w))return re("",M,[],g(w),U,"")}if(U.length!==0)return te("",M,[],U,"")}return ne("",M,[])}return ie}})(Ji,Ji.exports)),Ji.exports}var s2=n2();class i2{#e=new Map;#t;constructor(t){this.#t=t}count(t="default"){const n=this.#e.get(t)??0;this.#e.set(t,n+1),this.#t("log",!1,!1,{message:`${t}: ${String(n+1)}`,prefix:t})}countReset(t="default"){this.#e.has(t)?this.#e.delete(t):this.#t("warn",!1,!1,{message:`Count for ${t} does not exist`,prefix:t})}}const r2=new Set(["alert","critical","emergency","error"]),o2=e=>{const t=console;return r2.has(e)?t.__error??console.error:e==="warning"?t.__warn??console.warn:e==="trace"?t.__trace??console.trace:t.__log??console.log};let a2=class{log(e){const{context:t=[],message:n,type:s}=e;o2(s.level)(n,...t)}};class c2{#e=new Map;#t=new Set;#n;#r;#s;constructor(t,n,s){this.#s=t,this.#n=n,this.#r=s}time(t="default"){this.#t.has(t)?this.#s("warn",!1,!1,{message:`Timer '${t}' already exists`,prefix:t}):(this.#t.add(t),this.#e.set(t,Date.now()),this.#s("start",!1,!1,{message:this.#n,prefix:t}))}timeLog(t,...n){if(!t&&this.#t.size>0&&(t=[...this.#t].pop()),t&&this.#e.has(t)){const s=Date.now()-this.#e.get(t);this.#s("info",!1,!1,{context:n,message:s<1e3?`${String(s)} ms`:`${(s/1e3).toFixed(2)} s`,prefix:t})}else this.#s("warn",!1,!1,{context:n,message:"Timer not found",prefix:t})}timeEnd(t){if(!t&&this.#t.size>0&&(t=[...this.#t].pop()),t&&this.#e.has(t)){const n=Date.now()-this.#e.get(t);this.#e.delete(t),this.#t.delete(t),this.#s("stop",!1,!1,{message:`${this.#r} ${n<1e3?`${String(n)} ms`:`${(n/1e3).toFixed(2)} s`}`,prefix:t})}else this.#s("warn",!1,!1,{message:"Timer not found",prefix:t})}}const Dc=e=>e===void 0?[]:Array.isArray(e)?e:[e],Lc=(e,t)=>{const n={...e};return Object.keys(t).forEach(s=>{n[s]={...n[s],...t[s]}}),n},l2=e=>{let t=!1;return function(...n){if(!t){t=!0;try{const s=e.apply(this,n);return t=!1,s}catch(s){throw t=!1,s}}}};class To{timerManager;counterManager;lastLog;logLevels;disabled;paused;messageQueue;scopeName;types;longestLabel;processors;generalLogLevel;reporters;throttle;throttleMin;stringify;groups;startTimerMessage;endTimerMessage;rawReporter;force={};#e=new Set;#t;#n;constructor(t){this.throttle=t.throttle??1e3,this.throttleMin=t.throttleMin??5;const n=t.parentLongestLabel,s=t.parentTypes,i=t.parentStringify,r=t.parentLogLevels;this.stringify=i??s2.configure({strict:!0}),this.startTimerMessage=t.messages?.timerStart??"Initialized timer...",this.endTimerMessage=t.messages?.timerEnd??"Timer run for:",s&&n?(this.types=s,this.longestLabel=n):(this.types=Lc(bu,t.types??{}),this.longestLabel=Ar(this.types)),this.logLevels=r&&!t.logLevels?r:{...wk,...t.logLevels},this.generalLogLevel=this.#i(t.logLevel),this.reporters=new Set,this.processors=new Set,this.disabled=t.disabled??!1,this.paused=!1,this.messageQueue=[],this.scopeName=Dc(t.scope).filter(Boolean),this.timerManager=new c2((o,a,c,...l)=>{this.logger(o,a,c,...l)},this.startTimerMessage,this.endTimerMessage),this.counterManager=new i2((o,a,c,...l)=>{this.logger(o,a,c,...l)}),this.groups=[],this.lastLog={},this.logger=l2(this.logger.bind(this)),this.#r(),Array.isArray(t.reporters)&&this.registerReporters(t.reporters),this.rawReporter=this.extendReporter(t.rawReporter??new a2),Array.isArray(t.processors)&&this.registerProcessors(t.processors)}#r(){for(const t in this.types)this[t]=this.logger.bind(this,t,!1,!1);for(const t in this.types)this.force[t]=this.logger.bind(this,t,!1,!0);this.raw=this.raw.bind(this)}wrapConsole(){for(const t in this.types)Object.hasOwn(console,`__${t}`)||(console[`__${t}`]=console[t]),console[t]=this[t]}restoreConsole(){for(const t in this.types)if(Object.hasOwn(console,`__${t}`)){const n=console[`__${t}`];n===void 0?delete console[t]:console[t]=n,delete console[`__${t}`]}}wrapException(){this.#t||this.#n||(this.#t=t=>{this.error(t)},this.#n=t=>{this.error(t)},process.on("uncaughtException",this.#t),process.on("unhandledRejection",this.#n))}restoreException(){this.#t&&(process.off("uncaughtException",this.#t),this.#t=void 0),this.#n&&(process.off("unhandledRejection",this.#n),this.#n=void 0)}disable(){this.disabled=!0}enable(){this.disabled=!1}isEnabled(){return!this.disabled}pause(){this.paused=!0}resume(){this.paused=!1;const t=this.messageQueue.splice(0);for(let n=0;n<t.length;n+=1){const{messageObject:s,raw:i,type:r}=t[n];this.logger(r,i,!1,...s)}}scope(...t){if(t.length===0)throw new Error("No scope name was defined.");return this.child({scope:t})}unscope(){this.scopeName=[]}child(t){return new To(this.buildChildOptions(t))}time(t="default"){this.timerManager.time(t)}timeLog(t,...n){this.timerManager.timeLog(t,...n)}timeEnd(t){this.timerManager.timeEnd(t)}group(t="console.group"){globalThis.window===void 0?this.groups.push(t):console.group(t)}groupEnd(){globalThis.window===void 0?this.groups.pop():console.groupEnd()}count(t="default"){this.counterManager.count(t)}countReset(t="default"){this.counterManager.countReset(t)}clear(){console.clear()}raw(t,...n){this.disabled||this.logger("log",!0,!1,{context:n,message:t})}buildChildOptions(t){const n=t?.types!==void 0,s=n?Lc(this.types,t.types):this.types,i=t?.reporters??[],r=i.length>0?[...this.reporters,...i]:[...this.reporters],o=t?.processors??[],a=o.length>0?[...this.processors,...o]:[...this.processors],c=t?.logLevels?{...this.logLevels,...t.logLevels}:this.logLevels;let l;if(t?.scope){const p=Dc(t.scope).filter(Boolean);l=this.scopeName.length>0?[...this.scopeName,...p]:p}else l=this.scopeName.length>0?this.scopeName:[];const d=t?.messages?{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage,...t.messages}:{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage},u={disabled:t?.disabled??this.disabled,logLevel:t?.logLevel??this.generalLogLevel,logLevels:c,messages:d,processors:a,rawReporter:t?.rawReporter??this.rawReporter,reporters:r,scope:l,throttle:t?.throttle??this.throttle,throttleMin:t?.throttleMin??this.throttleMin};return n?(u.parentTypes=s,u.parentLongestLabel=Ar(s)):(u.parentTypes=this.types,u.parentLongestLabel=this.longestLabel),t?.logLevels||(u.parentLogLevels=this.logLevels),t?.messages||(u.parentMessages={timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage}),u.parentStringify=this.stringify,u}extendReporter(t){return typeof t.setLoggerTypes=="function"&&t.setLoggerTypes(this.types),typeof t.setStringify=="function"&&t.setStringify(this.stringify),t}registerReporters(t){for(let n=0;n<t.length;n+=1)this.reporters.add(this.extendReporter(t[n]))}registerProcessors(t){for(let n=0;n<t.length;n+=1){const s=t[n];typeof s.setStringify=="function"&&s.setStringify(this.stringify),this.processors.add(s)}}#s(t,n){if(n)this.rawReporter.log(Object.freeze(t));else for(const s of this.reporters)s.log(Object.freeze(t))}#i(t){let n="debug";return t!==void 0&&Object.hasOwn(this.logLevels,t)?n=t:t!==void 0&&!this.#e.has(t)&&(this.#e.add(t),console.warn(`[pail] Unknown log level "${String(t)}". Valid levels: ${Object.keys(this.logLevels).join(", ")}. Falling back to "debug".`)),n}#o(t,n,...s){const i={badge:void 0,context:void 0,error:void 0,label:void 0,message:$o,prefix:void 0,repeated:void 0,scope:void 0,suffix:void 0};if(i.type={level:n.logLevel,name:t},i.groups=this.groups,i.scope=this.scopeName,i.date=new Date,s.length>0&&s[0]instanceof Error)i.error=s[0],s.length>1&&(i.context=s.slice(1));else if(s.length>0&&typeof s[0]=="object"&&s[0]!==null&&"message"in s[0]){const{context:r,message:o,prefix:a,suffix:c}=s[0];if(r&&(i.context=r),a&&(i.prefix=a),c&&(i.suffix=c),i.message=o,s.length>1){const l=s.slice(1);i.context?i.context=Array.isArray(i.context)?[...i.context,...l]:[i.context,...l]:i.context=l}}else s.length>1?(i.message=s[0],i.context=s.slice(1)):s.length===1?i.message=s[0]:i.message=void 0;return n.logLevel==="trace"&&(i.traceError=new Error("Trace")),n.badge&&(i.badge=n.badge),n.label&&(i.label=n.label),i}logger(t,n,s,...i){if(this.disabled)return;if(this.paused){this.messageQueue.push({messageObject:i,raw:n,type:t});return}const r=this.types[t],o=this.#i(r.logLevel);if(s||this.logLevels[o]>=this.logLevels[this.generalLogLevel]){let a=this.#o(t,r,...i),c;try{c=JSON.stringify([a.label,a.scope,a.type,a.message,a.prefix,a.suffix,a.context])}catch{c=void 0}const l=this.processors.size>0,d=(f=!1)=>{const h=(this.lastLog.count??0)-this.throttleMin;if(this.lastLog.object&&h>0){const g={...this.lastLog.object};h>1&&(g.repeated=h),this.#s(g,n),this.lastLog.count=1}if(f){for(const g of this.processors)a=g.process(a);if(a.dropped===!0)return;if(this.lastLog.object=a,l)try{this.lastLog.signature=JSON.stringify([a.label,a.scope,a.type,a.message,a.prefix,a.suffix,a.context])}catch{this.lastLog.signature=void 0}else this.lastLog.signature=c;this.#s(a,n)}};clearTimeout(this.lastLog.timeout);const u=a.date instanceof Date?a.date:new Date(a.date),p=this.lastLog.time?u.getTime()-this.lastLog.time.getTime():0;if(this.lastLog.time=u,p<this.throttle)try{const f=c;if(this.lastLog.object&&f!==void 0&&f===this.lastLog.signature&&(this.lastLog.count=(this.lastLog.count??0)+1,this.lastLog.count>this.throttleMin)){this.lastLog.timeout=setTimeout(d,this.throttle);return}}catch{}d(!0)}}}class d2{#e;#t;#n;#r=!1;#s;constructor(t={}){this.#e=Oo,this.#t=jo,this.#s=t}setStdout(t){this.#e=t}setStderr(t){this.#t=t}setInteractiveManager(t){this.#n=t}setIsInteractive(t){this.#r=t}log(t){const{context:n,groups:s,message:i,type:r}=t,o=[];if(i!==$o){const d=typeof i=="string"?i:qs(i,this.#s);o.push(d)}n&&o.push(...n.map(d=>typeof d=="object"?` ${qs(d,this.#s)}`:` ${String(d)}`));const a=Cu(r.level)?"stderr":"stdout",c=a==="stderr"?this.#t:this.#e,l=s.map(()=>" ").join("");this.#r&&this.#n!==void 0&&c.isTTY?this.#n.update(a,(l+o.join("")).split(`
182
- `),0):Ru(l+o.join(""),c)}}class Io extends To{constructor(t){const n=t.parentStderr,s=t.parentStdout,{interactive:i,processors:r,rawReporter:o,reporters:a,stderr:c,stdout:l}=t,d=n??c,u=s??l,p=t.parentLongestLabel,f=t.parentTypes,{parentLogLevels:h,parentMessages:g,parentStringify:y}=t,x={disabled:t.disabled,logLevel:t.logLevel,logLevels:t.logLevels,messages:t.messages,processors:[],rawReporter:t.rawReporter,reporters:[],scope:t.scope,throttle:t.throttle,throttleMin:t.throttleMin},b="types"in t;f&&p&&!b?(x.parentTypes=f,x.parentLongestLabel=p):b&&t.types!==void 0&&(x.types=t.types),y&&(x.parentStringify=y),h&&!t.logLevels&&(x.parentLogLevels=h),g&&!t.messages&&(x.parentMessages=g),super(x),this.options=t,this.interactive=i??!1,this.stdout=u,this.stderr=d,this.interactive&&this.stdout&&this.stderr&&(this.interactiveManager=new Qw(new Js(this.stdout),new Js(this.stderr))),Array.isArray(a)&&this.registerReporters(a),this.rawReporter=this.extendReporter(o??new d2),Array.isArray(r)&&this.registerProcessors(r)}options;stdout;stderr;interactiveManager;interactive;scope(...t){if(t.length===0)throw new Error("No scope name was defined.");return this.child({scope:t})}child(t){const n=this.buildChildOptions(t);return n.interactive=t?.interactive??this.interactive,n.stderr=t?.stderr??this.stderr,n.stdout=t?.stdout??this.stdout,t?.stdout||(n.parentStdout=this.stdout),t?.stderr||(n.parentStderr=this.stderr),new Io(n)}getInteractiveManager(){return this.interactiveManager}wrapStd(){this.#e(this.stdout,"log"),this.#e(this.stderr,"error")}restoreStd(){this.#t(this.stdout),this.#t(this.stderr)}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}clear(){this.stdout?.write(Bc),this.stderr?.write(Bc)}extendReporter(t){return typeof t.setStdout=="function"&&t.setStdout(this.stdout),typeof t.setStderr=="function"&&t.setStderr(this.stderr),typeof t.setLoggerTypes=="function"&&t.setLoggerTypes(this.types),typeof t.setStringify=="function"&&t.setStringify(this.stringify),typeof t.setIsInteractive=="function"&&t.setIsInteractive(this.interactive),this.interactive&&typeof t.setInteractiveManager=="function"&&t.setInteractiveManager(this.interactiveManager),t}#e(t,n){t&&(t.__write||(t.__write=t.write),t.write=s=>{this[n](String(s).trim())})}#t(t){t&&t.__write&&(t.write=t.__write,delete t.__write)}}const u2=Io;let qi;const p2=()=>(qi!==void 0||(qi=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["gold","#ffd700"],["goldenrod","#daa520"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavender","#e6e6fa"],["lavenderblush","#fff0f5"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]])),qi),f2=/^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i,h2=/^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i,g2=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,m2=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,Lr=()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),Mc=/\s+/,Ks=e=>{const t=p2();t.has(e)&&(e=t.get(e));const n=f2.exec(e);if(n)return[Number.parseInt(n[1],16),Number.parseInt(n[2],16),Number.parseInt(n[3],16)];const s=h2.exec(e);if(s)return[Number.parseInt(`${s[1]}${s[1]}`,16),Number.parseInt(`${s[2]}${s[2]}`,16),Number.parseInt(`${s[3]}${s[3]}`,16)];const i=g2.exec(e);if(i)return[Math.round(Math.max(0,Math.min(255,Number(i[1])))),Math.round(Math.max(0,Math.min(255,Number(i[2])))),Math.round(Math.max(0,Math.min(255,Number(i[3]))))];const r=m2.exec(e);if(r){let o=Number(r[1])%360;o<0&&(o+=360);const a=Math.max(0,Math.min(100,Number(r[2])))/100,c=Math.max(0,Math.min(100,Number(r[3])))/100,l=(1-Math.abs(2*c-1))*a,d=l*(1-Math.abs(o/60%2-1)),u=c-l/2;let p,f,h;return o<60?{0:p,1:f,2:h}=[l,d,0]:o<120?{0:p,1:f,2:h}=[d,l,0]:o<180?{0:p,1:f,2:h}=[0,l,d]:o<240?{0:p,1:f,2:h}=[0,d,l]:o<300?{0:p,1:f,2:h}=[d,0,l]:{0:p,1:f,2:h}=[l,0,d],[Math.round((p+u)*255),Math.round((f+u)*255),Math.round((h+u)*255)]}return null},Ki=(e,t)=>typeof e=="string"||typeof t=="string"?e===t:e?.[0]===t?.[0]&&e?.[1]===t?.[1]&&e?.[2]===t?.[2],y2=e=>{if(typeof e!="string")return Lr();const t=Lr(),n=[];let s=!1,i=null,r=0,o="";for(const a of e){if(a==="(")r+=1;else if(r>0)a===")"&&(r-=1);else if(s){if(a===";"){const c=o.trim();c!==""&&n.push([i,c]),i=null,o="",s=!1;continue}}else if(a===":"){i=o.trim(),o="",s=!0;continue}o+=a}if(s&&r===0){const a=o.trim();a!==""&&n.push([i,a]),i=null,o=""}for(const{0:a,1:c}of n)switch(a){case"background-color":{c!=null&&(t.backgroundColor=c);break}case"color":{c!=null&&(t.color=c);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(c)&&(t.fontStyle="italic");break}case"font-weight":{c==="bold"&&(t.fontWeight=c);break}case"text-decoration":{t.textDecorationColor=null,t.textDecorationLine=[];const l=c.split(Mc);for(const d of l){const u=Ks(d);u!=null?t.textDecorationColor=u:["line-through","overline","underline"].includes(d)&&t.textDecorationLine.push(d)}break}case"text-decoration-color":{const l=Ks(c);l!=null&&(t.textDecorationColor=l);break}case"text-decoration-line":{t.textDecorationLine=[];const l=c.split(Mc);for(const d of l)["line-through","overline","underline"].includes(d)&&t.textDecorationLine.push(d);break}}return t},v2=(e,t)=>{t=t??Lr();let n="";if(!Ki(e.backgroundColor,t.backgroundColor))if(e.backgroundColor==null)n+="\x1B[49m";else switch(e.backgroundColor){case"black":{n+="\x1B[40m";break}case"blue":{n+="\x1B[44m";break}case"cyan":{n+="\x1B[46m";break}case"green":{n+="\x1B[42m";break}case"magenta":{n+="\x1B[45m";break}case"red":{n+="\x1B[41m";break}case"white":{n+="\x1B[47m";break}case"yellow":{n+="\x1B[43m";break}default:if(Array.isArray(e.backgroundColor)){const{0:s,1:i,2:r}=e.backgroundColor;n+=`\x1B[48;2;${String(s)};${String(i)};${String(r)}m`}else{const s=Ks(e.backgroundColor);if(s===null)n+="\x1B[49m";else{const{0:i,1:r,2:o}=s;n+=`\x1B[48;2;${String(i)};${String(r)};${String(o)}m`}}}if(!Ki(e.color,t.color))if(e.color==null)n+="\x1B[39m";else switch(e.color){case"black":{n+="\x1B[30m";break}case"blue":{n+="\x1B[34m";break}case"cyan":{n+="\x1B[36m";break}case"green":{n+="\x1B[32m";break}case"magenta":{n+="\x1B[35m";break}case"red":{n+="\x1B[31m";break}case"white":{n+="\x1B[37m";break}case"yellow":{n+="\x1B[33m";break}default:if(Array.isArray(e.color)){const{0:s,1:i,2:r}=e.color;n+=`\x1B[38;2;${String(s)};${String(i)};${String(r)}m`}else{const s=Ks(e.color);if(s===null)n+="\x1B[39m";else{const{0:i,1:r,2:o}=s;n+=`\x1B[38;2;${String(i)};${String(r)};${String(o)}m`}}}if(e.fontWeight!==t.fontWeight&&(n+=e.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),e.fontStyle!==t.fontStyle&&(n+=e.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!Ki(e.textDecorationColor,t.textDecorationColor))if(e.textDecorationColor==null)n+="\x1B[59m";else{const{0:s,1:i,2:r}=e.textDecorationColor;n+=`\x1B[58;2;${String(s)};${String(i)};${String(r)}m`}return e.textDecorationLine.includes("line-through")!==t.textDecorationLine.includes("line-through")&&(n+=e.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),e.textDecorationLine.includes("overline")!==t.textDecorationLine.includes("overline")&&(n+=e.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),e.textDecorationLine.includes("underline")!==t.textDecorationLine.includes("underline")&&(n+=e.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),n},b2=e=>{try{return JSON.stringify(e)}catch{return'"[Circular]"'}},_c="%".codePointAt(0),w2="s".codePointAt(0),k2="d".codePointAt(0),S2="f".codePointAt(0),x2="i".codePointAt(0),$2="O".codePointAt(0),E2="o".codePointAt(0),C2="j".codePointAt(0),R2="c".codePointAt(0),Fc=(e,t=[],n={})=>{if(typeof e!="string"&&typeof e!="object"||e===null)throw new TypeError(`fmt must be a string or object, got ${e===null?"null":typeof e}`);const s=n.stringify??b2,i=1;if(typeof e=="object"){const u=t.length+i;if(u===1)return"{}";const p=Array.from({length:u});p[0]=s(e);for(let f=1;f<u;f+=1)p[f]=s(t[f-i]);return p.join(" ")}if(t.length===0)return e;let r="",o=1-i,a=-1,c=!1,l;const d=n.colors??globalThis.window===void 0;for(let u=0;u<e.length;){if(e.codePointAt(u)===_c&&u+1<e.length){a=a>-1?a:0;const p=e.codePointAt(u+1);switch(p){case R2:{if(a<u&&(r+=e.slice(a,u)),d){const f=y2(t[o]),h=v2(f,l);r+=h,h!==""&&(c=!0,l=f)}a=u+2,u+=1;break}case k2:case S2:{const f=t[o];if(o>=t.length||f==null)break;a<u&&(r+=e.slice(a,u)),r+=(typeof f=="symbol"?Number.NaN:Number(f)).toString(),a=u+2,u+=1;break}case x2:{const f=t[o];if(o>=t.length||f==null)break;a<u&&(r+=e.slice(a,u)),r+=Math.floor(typeof f=="symbol"?Number.NaN:Number(f)).toString(),a=u+2,u+=1;break}case C2:case $2:case E2:{if(o>=t.length||t[o]===void 0)break;a<u&&(r+=e.slice(a,u));const f=t[o],h=typeof f;if(h==="string"){r+=`'${f}'`,a=u+2,u+=1;break}if(h==="function"){r+=f.name?`[Function: ${f.name}]`:"[Function: <anonymous>]",a=u+2,u+=1;break}r+=s(f),a=u+2,u+=1;break}case _c:{a<u&&(r+=e.slice(a,u)),r+="%",a=u+2,u+=1,o-=1;break}case w2:{if(o>=t.length)break;a<u&&(r+=e.slice(a,u));const f=t[o];r+=typeof f=="object"&&f!==null?s(f):String(f),a=u+2,u+=1;break}default:typeof n.formatters?.[p]=="function"?(a<u&&(r+=e.slice(a,u)),r+=n.formatters[p](t[o]),a=u+2,u+=1):o-=1}o+=1}u+=1}if(a===-1&&!(n.appendExtraArguments&&o<t.length))return e;if(a===-1?r=e:a<e.length&&(r+=e.slice(a)),a!==-1&&c&&(r+="\x1B[0m"),n.appendExtraArguments&&o<t.length)for(let u=Math.max(o,0);u<t.length;u+=1){const p=t[u];r+=` ${typeof p=="object"&&p!==null?s(p):String(p)}`}return r},O2=(e={})=>{const t={};typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([i,r])=>{if(i.length===0)throw new Error(`Formatter %${i} has no characters`);if(i.length>1)throw new Error(`Formatter %${i} has more than one character`);if(typeof r!="function")throw new TypeError(`Formatter for %${i} is not a function`);const o=i.codePointAt(0);if(o===void 0)throw new Error(`${i}.codePointAt(0) failed to return a value, please report this issue`);t[o]=r});const n={...e};delete n.formatters;const s=Object.freeze({...n,formatters:t});return(i,r=[],o)=>o===void 0?Fc(i,r,s):Fc(i,r,{...n,...o,formatters:t})},j2='"[Circular]"';class T2{#e;#t;#n;constructor(t={}){this.#t=t.formatters}setStringify(t){this.#e=t}process(t){this.#n===void 0&&(this.#n=O2({formatters:this.#t,stringify:s=>this.#r(s)}));const n=this.#n;return t.message!==void 0&&(t.message=this.#s(n,t.message,t.context??[])),t}#r(t){if(this.#e===void 0)try{return JSON.stringify(t)}catch{return j2}try{return this.#e(t)}catch(n){return JSON.stringify(`[unserializable: ${n instanceof Error?n.message:String(n)}]`)}}#s(t,n,s=[]){if(typeof n=="string")return t(n,s);if(typeof n=="object"&&n!==null){const i=n,r=Object.keys(i);for(let o=0;o<r.length;o+=1){const a=r[o],c=i[a];(typeof c=="string"||Array.isArray(c)||typeof c=="object")&&(i[a]=this.#s(t,c,s))}}return n}}const{bgGrey:I2,cyan:A2,green:P2,greenBright:B2,grey:Pe,red:Yi,underline:Vc,white:N2}=si,D2=/[\\/]pail[\\/]dist/,Xi=e=>!D2.test(e);class L2 extends JS{#e;#t;#n;#r=!1;#s;#i;#o;#a=!1;#c="";#l="";constructor(t={}){const{error:n,inspect:s,...i}=t;super({uppercase:{label:!0,...i.uppercase},...i}),this.#s={...WS,...s},this.#i={...n,color:{fileLine:P2,hint:A2,marker:Yi,message:Yi,method:B2,title:Yi}},this.#e=Oo,this.#t=jo,this.#d()}setLoggerTypes(t){super.setLoggerTypes(t),this.#d()}setStdout(t){this.#e=t,this.#o=void 0,this.#a=!1}setStderr(t){this.#t=t}setInteractiveManager(t){this.#n=t}setIsInteractive(t){this.#r=t}log(t){this._log(this._formatMessage(t),t.type.level)}#d(){this.#c=DS(this.loggerTypes),this.#l=Ar(this.loggerTypes)}#p(){return!this.#a&&typeof this.#e.on=="function"&&(this.#a=!0,this.#e.on("resize",()=>{this.#o=void 0})),this.#o===void 0&&(this.#o=BS().columns),this.#o}_formatMessage(t){let n=this.#p();typeof this.styles.messageLength=="number"&&(n=this.styles.messageLength);const{badge:s,context:i,date:r,error:o,file:a,groups:c,label:l,message:d,prefix:u,repeated:p,scope:f,suffix:h,traceError:g,type:y}=t,{color:x}=this.loggerTypes[y.name],b=x?si[x]:N2,S=c.map(()=>" ").join(""),C=[];if(c.length>0&&C.push(`${S+Pe(`[${c.at(-1)??""}]`)} `),r&&C.push(`${Pe(this.styles.dateFormatter(typeof r=="string"?new Date(r):r))} `),s)C.push(b(s));else{const D=this.#c;D.length>0&&C.push(`${Pe(".".repeat(D.length))} `)}const N=this.#l;if(l){const D=Ie(N),F=Ie(l);C.push(`${b(GS(l,this.styles))} `,Pe(".".repeat(Math.max(0,D-F))))}else C.push(Pe(".".repeat(N.length+2)));p&&C.push(`${I2.white(`[${String(p)}x]`)} `),Array.isArray(f)&&f.length>0&&C.push(` ${Pe(`[${f.join(" > ")}]`)} `),u&&C.push(`${Pe(`${Array.isArray(f)&&f.length>0?". ":" "}[${this.styles.underline.prefix?Vc(u):u}]`)} `);const T=Ie(C.join(" "));if(a){const D=(a.name??"")+(a.line?`:${String(a.line)}`:""),F=Ie(D);if(F+T+2>n)C.push(Pe(` ${D}`));else{const V=Math.max(0,n-T-F-2);C.push(Pe(`${".".repeat(V)} ${D}`))}}else C.push(Pe(".".repeat(Math.max(0,n-T-1))));if(C.length>0&&C.push(`
181
+ ${B}`),A.pop(),`{${z}}`}case"number":return isFinite(w)?String(w):S?S(w):"null";case"boolean":return w===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(w);default:return S?S(w):void 0}}function ne(M,w,A){switch(typeof w){case"string":return r(w);case"object":{if(w===null)return"null";if(typeof w.toJSON=="function"){if(w=w.toJSON(M),typeof w!="object")return ne(M,w,A);if(w===null)return"null"}if(A.indexOf(w)!==-1)return C;let U="";const I=w.length!==void 0;if(I&&Array.isArray(w)){if(w.length===0)return"[]";if(F<A.length+1)return'"[Array]"';A.push(w);const z=Math.min(w.length,V);let Y=0;for(;Y<z-1;Y++){const K=ne(String(Y),w[Y],A);U+=K!==void 0?K:"null",U+=","}const P=ne(String(Y),w[Y],A);if(U+=P!==void 0?P:"null",w.length-1>V){const K=w.length-V-1;U+=`,"... ${h(K)} not stringified"`}return A.pop(),`[${U}]`}let B=Object.keys(w);const j=B.length;if(j===0)return"{}";if(F<A.length+1)return'"[Object]"';let _="",H=Math.min(j,V);I&&c(w)&&(U+=l(w,",",V),B=B.slice(w.length),H-=w.length,_=","),T&&(B=o(B,D)),A.push(w);for(let z=0;z<H;z++){const Y=B[z],P=ne(Y,w[Y],A);P!==void 0&&(U+=`${_}${r(Y)}:${P}`,_=",")}if(j>V){const z=j-V;U+=`${_}"...":"${h(z)} not stringified"`}return A.pop(),`{${U}}`}case"number":return isFinite(w)?String(w):S?S(w):"null";case"boolean":return w===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(w);default:return S?S(w):void 0}}function ie(M,w,A){if(arguments.length>1){let U="";if(typeof A=="number"?U=" ".repeat(Math.min(A,10)):typeof A=="string"&&(U=A.slice(0,10)),w!=null){if(typeof w=="function")return Z("",{"":M},[],w,U,"");if(Array.isArray(w))return re("",M,[],g(w),U,"")}if(U.length!==0)return te("",M,[],U,"")}return ne("",M,[])}return ie}})(qi,qi.exports)),qi.exports}var a2=o2();class c2{#e=new Map;#t;constructor(t){this.#t=t}count(t="default"){const n=this.#e.get(t)??0;this.#e.set(t,n+1),this.#t("log",!1,!1,{message:`${t}: ${String(n+1)}`,prefix:t})}countReset(t="default"){this.#e.has(t)?this.#e.delete(t):this.#t("warn",!1,!1,{message:`Count for ${t} does not exist`,prefix:t})}}const l2=new Set(["alert","critical","emergency","error"]),d2=e=>{const t=console;return l2.has(e)?t.__error??console.error:e==="warning"?t.__warn??console.warn:e==="trace"?t.__trace??console.trace:t.__log??console.log};let u2=class{log(e){const{context:t=[],message:n,type:s}=e;d2(s.level)(n,...t)}};class p2{#e=new Map;#t=new Set;#n;#r;#s;constructor(t,n,s){this.#s=t,this.#n=n,this.#r=s}time(t="default"){this.#t.has(t)?this.#s("warn",!1,!1,{message:`Timer '${t}' already exists`,prefix:t}):(this.#t.add(t),this.#e.set(t,Date.now()),this.#s("start",!1,!1,{message:this.#n,prefix:t}))}timeLog(t,...n){if(!t&&this.#t.size>0&&(t=[...this.#t].pop()),t&&this.#e.has(t)){const s=Date.now()-this.#e.get(t);this.#s("info",!1,!1,{context:n,message:s<1e3?`${String(s)} ms`:`${(s/1e3).toFixed(2)} s`,prefix:t})}else this.#s("warn",!1,!1,{context:n,message:"Timer not found",prefix:t})}timeEnd(t){if(!t&&this.#t.size>0&&(t=[...this.#t].pop()),t&&this.#e.has(t)){const n=Date.now()-this.#e.get(t);this.#e.delete(t),this.#t.delete(t),this.#s("stop",!1,!1,{message:`${this.#r} ${n<1e3?`${String(n)} ms`:`${(n/1e3).toFixed(2)} s`}`,prefix:t})}else this.#s("warn",!1,!1,{message:"Timer not found",prefix:t})}}const Mc=e=>e===void 0?[]:Array.isArray(e)?e:[e],_c=(e,t)=>{const n={...e};return Object.keys(t).forEach(s=>{n[s]={...n[s],...t[s]}}),n},f2=e=>{let t=!1;return function(...n){if(!t){t=!0;try{const s=e.apply(this,n);return t=!1,s}catch(s){throw t=!1,s}}}};class Io{timerManager;counterManager;lastLog;logLevels;disabled;paused;messageQueue;scopeName;types;longestLabel;processors;generalLogLevel;reporters;throttle;throttleMin;stringify;groups;startTimerMessage;endTimerMessage;rawReporter;force={};#e=new Set;#t;#n;constructor(t){this.throttle=t.throttle??1e3,this.throttleMin=t.throttleMin??5;const n=t.parentLongestLabel,s=t.parentTypes,i=t.parentStringify,r=t.parentLogLevels;this.stringify=i??a2.configure({strict:!0}),this.startTimerMessage=t.messages?.timerStart??"Initialized timer...",this.endTimerMessage=t.messages?.timerEnd??"Timer run for:",s&&n?(this.types=s,this.longestLabel=n):(this.types=_c(Su,t.types??{}),this.longestLabel=Br(this.types)),this.logLevels=r&&!t.logLevels?r:{...$k,...t.logLevels},this.generalLogLevel=this.#i(t.logLevel),this.reporters=new Set,this.processors=new Set,this.disabled=t.disabled??!1,this.paused=!1,this.messageQueue=[],this.scopeName=Mc(t.scope).filter(Boolean),this.timerManager=new p2((o,a,c,...l)=>{this.logger(o,a,c,...l)},this.startTimerMessage,this.endTimerMessage),this.counterManager=new c2((o,a,c,...l)=>{this.logger(o,a,c,...l)}),this.groups=[],this.lastLog={},this.logger=f2(this.logger.bind(this)),this.#r(),Array.isArray(t.reporters)&&this.registerReporters(t.reporters),this.rawReporter=this.extendReporter(t.rawReporter??new u2),Array.isArray(t.processors)&&this.registerProcessors(t.processors)}#r(){for(const t in this.types)this[t]=this.logger.bind(this,t,!1,!1);for(const t in this.types)this.force[t]=this.logger.bind(this,t,!1,!0);this.raw=this.raw.bind(this)}wrapConsole(){for(const t in this.types)Object.hasOwn(console,`__${t}`)||(console[`__${t}`]=console[t]),console[t]=this[t]}restoreConsole(){for(const t in this.types)if(Object.hasOwn(console,`__${t}`)){const n=console[`__${t}`];n===void 0?delete console[t]:console[t]=n,delete console[`__${t}`]}}wrapException(){this.#t||this.#n||(this.#t=t=>{this.error(t)},this.#n=t=>{this.error(t)},process.on("uncaughtException",this.#t),process.on("unhandledRejection",this.#n))}restoreException(){this.#t&&(process.off("uncaughtException",this.#t),this.#t=void 0),this.#n&&(process.off("unhandledRejection",this.#n),this.#n=void 0)}disable(){this.disabled=!0}enable(){this.disabled=!1}isEnabled(){return!this.disabled}pause(){this.paused=!0}resume(){this.paused=!1;const t=this.messageQueue.splice(0);for(let n=0;n<t.length;n+=1){const{messageObject:s,raw:i,type:r}=t[n];this.logger(r,i,!1,...s)}}scope(...t){if(t.length===0)throw new Error("No scope name was defined.");return this.child({scope:t})}unscope(){this.scopeName=[]}child(t){return new Io(this.buildChildOptions(t))}time(t="default"){this.timerManager.time(t)}timeLog(t,...n){this.timerManager.timeLog(t,...n)}timeEnd(t){this.timerManager.timeEnd(t)}group(t="console.group"){globalThis.window===void 0?this.groups.push(t):console.group(t)}groupEnd(){globalThis.window===void 0?this.groups.pop():console.groupEnd()}count(t="default"){this.counterManager.count(t)}countReset(t="default"){this.counterManager.countReset(t)}clear(){console.clear()}raw(t,...n){this.disabled||this.logger("log",!0,!1,{context:n,message:t})}buildChildOptions(t){const n=t?.types!==void 0,s=n?_c(this.types,t.types):this.types,i=t?.reporters??[],r=i.length>0?[...this.reporters,...i]:[...this.reporters],o=t?.processors??[],a=o.length>0?[...this.processors,...o]:[...this.processors],c=t?.logLevels?{...this.logLevels,...t.logLevels}:this.logLevels;let l;if(t?.scope){const p=Mc(t.scope).filter(Boolean);l=this.scopeName.length>0?[...this.scopeName,...p]:p}else l=this.scopeName.length>0?this.scopeName:[];const d=t?.messages?{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage,...t.messages}:{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage},u={disabled:t?.disabled??this.disabled,logLevel:t?.logLevel??this.generalLogLevel,logLevels:c,messages:d,processors:a,rawReporter:t?.rawReporter??this.rawReporter,reporters:r,scope:l,throttle:t?.throttle??this.throttle,throttleMin:t?.throttleMin??this.throttleMin};return n?(u.parentTypes=s,u.parentLongestLabel=Br(s)):(u.parentTypes=this.types,u.parentLongestLabel=this.longestLabel),t?.logLevels||(u.parentLogLevels=this.logLevels),t?.messages||(u.parentMessages={timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage}),u.parentStringify=this.stringify,u}extendReporter(t){return typeof t.setLoggerTypes=="function"&&t.setLoggerTypes(this.types),typeof t.setStringify=="function"&&t.setStringify(this.stringify),t}registerReporters(t){for(let n=0;n<t.length;n+=1)this.reporters.add(this.extendReporter(t[n]))}registerProcessors(t){for(let n=0;n<t.length;n+=1){const s=t[n];typeof s.setStringify=="function"&&s.setStringify(this.stringify),this.processors.add(s)}}#s(t,n){if(n)this.rawReporter.log(Object.freeze(t));else for(const s of this.reporters)s.log(Object.freeze(t))}#i(t){let n="debug";return t!==void 0&&Object.hasOwn(this.logLevels,t)?n=t:t!==void 0&&!this.#e.has(t)&&(this.#e.add(t),console.warn(`[pail] Unknown log level "${String(t)}". Valid levels: ${Object.keys(this.logLevels).join(", ")}. Falling back to "debug".`)),n}#o(t,n,...s){const i={badge:void 0,context:void 0,error:void 0,label:void 0,message:Eo,prefix:void 0,repeated:void 0,scope:void 0,suffix:void 0};if(i.type={level:n.logLevel,name:t},i.groups=this.groups,i.scope=this.scopeName,i.date=new Date,s.length>0&&s[0]instanceof Error)i.error=s[0],s.length>1&&(i.context=s.slice(1));else if(s.length>0&&typeof s[0]=="object"&&s[0]!==null&&"message"in s[0]){const{context:r,message:o,prefix:a,suffix:c}=s[0];if(r&&(i.context=r),a&&(i.prefix=a),c&&(i.suffix=c),i.message=o,s.length>1){const l=s.slice(1);i.context?i.context=Array.isArray(i.context)?[...i.context,...l]:[i.context,...l]:i.context=l}}else s.length>1?(i.message=s[0],i.context=s.slice(1)):s.length===1?i.message=s[0]:i.message=void 0;return n.logLevel==="trace"&&(i.traceError=new Error("Trace")),n.badge&&(i.badge=n.badge),n.label&&(i.label=n.label),i}logger(t,n,s,...i){if(this.disabled)return;if(this.paused){this.messageQueue.push({messageObject:i,raw:n,type:t});return}const r=this.types[t],o=this.#i(r.logLevel);if(s||this.logLevels[o]>=this.logLevels[this.generalLogLevel]){let a=this.#o(t,r,...i),c;try{c=JSON.stringify([a.label,a.scope,a.type,a.message,a.prefix,a.suffix,a.context])}catch{c=void 0}const l=this.processors.size>0,d=(f=!1)=>{const h=(this.lastLog.count??0)-this.throttleMin;if(this.lastLog.object&&h>0){const g={...this.lastLog.object};h>1&&(g.repeated=h),this.#s(g,n),this.lastLog.count=1}if(f){for(const g of this.processors)a=g.process(a);if(a.dropped===!0)return;if(this.lastLog.object=a,l)try{this.lastLog.signature=JSON.stringify([a.label,a.scope,a.type,a.message,a.prefix,a.suffix,a.context])}catch{this.lastLog.signature=void 0}else this.lastLog.signature=c;this.#s(a,n)}};clearTimeout(this.lastLog.timeout);const u=a.date instanceof Date?a.date:new Date(a.date),p=this.lastLog.time?u.getTime()-this.lastLog.time.getTime():0;if(this.lastLog.time=u,p<this.throttle)try{const f=c;if(this.lastLog.object&&f!==void 0&&f===this.lastLog.signature&&(this.lastLog.count=(this.lastLog.count??0)+1,this.lastLog.count>this.throttleMin)){this.lastLog.timeout=setTimeout(d,this.throttle);return}}catch{}d(!0)}}}class h2{#e;#t;#n;#r=!1;#s;constructor(t={}){this.#e=jo,this.#t=To,this.#s=t}setStdout(t){this.#e=t}setStderr(t){this.#t=t}setInteractiveManager(t){this.#n=t}setIsInteractive(t){this.#r=t}log(t){const{context:n,groups:s,message:i,type:r}=t,o=[];if(i!==Eo){const d=typeof i=="string"?i:Ks(i,this.#s);o.push(d)}n&&o.push(...n.map(d=>typeof d=="object"?` ${Ks(d,this.#s)}`:` ${String(d)}`));const a=ju(r.level)?"stderr":"stdout",c=a==="stderr"?this.#t:this.#e,l=s.map(()=>" ").join("");this.#r&&this.#n!==void 0&&c.isTTY?this.#n.update(a,(l+o.join("")).split(`
182
+ `),0):Tu(l+o.join(""),c)}}class Ao extends Io{constructor(t){const n=t.parentStderr,s=t.parentStdout,{interactive:i,processors:r,rawReporter:o,reporters:a,stderr:c,stdout:l}=t,d=n??c,u=s??l,p=t.parentLongestLabel,f=t.parentTypes,{parentLogLevels:h,parentMessages:g,parentStringify:y}=t,x={disabled:t.disabled,logLevel:t.logLevel,logLevels:t.logLevels,messages:t.messages,processors:[],rawReporter:t.rawReporter,reporters:[],scope:t.scope,throttle:t.throttle,throttleMin:t.throttleMin},b="types"in t;f&&p&&!b?(x.parentTypes=f,x.parentLongestLabel=p):b&&t.types!==void 0&&(x.types=t.types),y&&(x.parentStringify=y),h&&!t.logLevels&&(x.parentLogLevels=h),g&&!t.messages&&(x.parentMessages=g),super(x),this.options=t,this.interactive=i??!1,this.stdout=u,this.stderr=d,this.interactive&&this.stdout&&this.stderr&&(this.interactiveManager=new sk(new qs(this.stdout),new qs(this.stderr))),Array.isArray(a)&&this.registerReporters(a),this.rawReporter=this.extendReporter(o??new h2),Array.isArray(r)&&this.registerProcessors(r)}options;stdout;stderr;interactiveManager;interactive;scope(...t){if(t.length===0)throw new Error("No scope name was defined.");return this.child({scope:t})}child(t){const n=this.buildChildOptions(t);return n.interactive=t?.interactive??this.interactive,n.stderr=t?.stderr??this.stderr,n.stdout=t?.stdout??this.stdout,t?.stdout||(n.parentStdout=this.stdout),t?.stderr||(n.parentStderr=this.stderr),new Ao(n)}getInteractiveManager(){return this.interactiveManager}wrapStd(){this.#e(this.stdout,"log"),this.#e(this.stderr,"error")}restoreStd(){this.#t(this.stdout),this.#t(this.stderr)}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}clear(){this.stdout?.write(Dc),this.stderr?.write(Dc)}extendReporter(t){return typeof t.setStdout=="function"&&t.setStdout(this.stdout),typeof t.setStderr=="function"&&t.setStderr(this.stderr),typeof t.setLoggerTypes=="function"&&t.setLoggerTypes(this.types),typeof t.setStringify=="function"&&t.setStringify(this.stringify),typeof t.setIsInteractive=="function"&&t.setIsInteractive(this.interactive),this.interactive&&typeof t.setInteractiveManager=="function"&&t.setInteractiveManager(this.interactiveManager),t}#e(t,n){t&&(t.__write||(t.__write=t.write),t.write=s=>{this[n](String(s).trim())})}#t(t){t&&t.__write&&(t.write=t.__write,delete t.__write)}}const g2=Ao;let Ki;const m2=()=>(Ki!==void 0||(Ki=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["gold","#ffd700"],["goldenrod","#daa520"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavender","#e6e6fa"],["lavenderblush","#fff0f5"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]])),Ki),y2=/^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i,v2=/^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i,b2=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,w2=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,Mr=()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),Fc=/\s+/,Ys=e=>{const t=m2();t.has(e)&&(e=t.get(e));const n=y2.exec(e);if(n)return[Number.parseInt(n[1],16),Number.parseInt(n[2],16),Number.parseInt(n[3],16)];const s=v2.exec(e);if(s)return[Number.parseInt(`${s[1]}${s[1]}`,16),Number.parseInt(`${s[2]}${s[2]}`,16),Number.parseInt(`${s[3]}${s[3]}`,16)];const i=b2.exec(e);if(i)return[Math.round(Math.max(0,Math.min(255,Number(i[1])))),Math.round(Math.max(0,Math.min(255,Number(i[2])))),Math.round(Math.max(0,Math.min(255,Number(i[3]))))];const r=w2.exec(e);if(r){let o=Number(r[1])%360;o<0&&(o+=360);const a=Math.max(0,Math.min(100,Number(r[2])))/100,c=Math.max(0,Math.min(100,Number(r[3])))/100,l=(1-Math.abs(2*c-1))*a,d=l*(1-Math.abs(o/60%2-1)),u=c-l/2;let p,f,h;return o<60?{0:p,1:f,2:h}=[l,d,0]:o<120?{0:p,1:f,2:h}=[d,l,0]:o<180?{0:p,1:f,2:h}=[0,l,d]:o<240?{0:p,1:f,2:h}=[0,d,l]:o<300?{0:p,1:f,2:h}=[d,0,l]:{0:p,1:f,2:h}=[l,0,d],[Math.round((p+u)*255),Math.round((f+u)*255),Math.round((h+u)*255)]}return null},Yi=(e,t)=>typeof e=="string"||typeof t=="string"?e===t:e?.[0]===t?.[0]&&e?.[1]===t?.[1]&&e?.[2]===t?.[2],k2=e=>{if(typeof e!="string")return Mr();const t=Mr(),n=[];let s=!1,i=null,r=0,o="";for(const a of e){if(a==="(")r+=1;else if(r>0)a===")"&&(r-=1);else if(s){if(a===";"){const c=o.trim();c!==""&&n.push([i,c]),i=null,o="",s=!1;continue}}else if(a===":"){i=o.trim(),o="",s=!0;continue}o+=a}if(s&&r===0){const a=o.trim();a!==""&&n.push([i,a]),i=null,o=""}for(const{0:a,1:c}of n)switch(a){case"background-color":{c!=null&&(t.backgroundColor=c);break}case"color":{c!=null&&(t.color=c);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(c)&&(t.fontStyle="italic");break}case"font-weight":{c==="bold"&&(t.fontWeight=c);break}case"text-decoration":{t.textDecorationColor=null,t.textDecorationLine=[];const l=c.split(Fc);for(const d of l){const u=Ys(d);u!=null?t.textDecorationColor=u:["line-through","overline","underline"].includes(d)&&t.textDecorationLine.push(d)}break}case"text-decoration-color":{const l=Ys(c);l!=null&&(t.textDecorationColor=l);break}case"text-decoration-line":{t.textDecorationLine=[];const l=c.split(Fc);for(const d of l)["line-through","overline","underline"].includes(d)&&t.textDecorationLine.push(d);break}}return t},S2=(e,t)=>{t=t??Mr();let n="";if(!Yi(e.backgroundColor,t.backgroundColor))if(e.backgroundColor==null)n+="\x1B[49m";else switch(e.backgroundColor){case"black":{n+="\x1B[40m";break}case"blue":{n+="\x1B[44m";break}case"cyan":{n+="\x1B[46m";break}case"green":{n+="\x1B[42m";break}case"magenta":{n+="\x1B[45m";break}case"red":{n+="\x1B[41m";break}case"white":{n+="\x1B[47m";break}case"yellow":{n+="\x1B[43m";break}default:if(Array.isArray(e.backgroundColor)){const{0:s,1:i,2:r}=e.backgroundColor;n+=`\x1B[48;2;${String(s)};${String(i)};${String(r)}m`}else{const s=Ys(e.backgroundColor);if(s===null)n+="\x1B[49m";else{const{0:i,1:r,2:o}=s;n+=`\x1B[48;2;${String(i)};${String(r)};${String(o)}m`}}}if(!Yi(e.color,t.color))if(e.color==null)n+="\x1B[39m";else switch(e.color){case"black":{n+="\x1B[30m";break}case"blue":{n+="\x1B[34m";break}case"cyan":{n+="\x1B[36m";break}case"green":{n+="\x1B[32m";break}case"magenta":{n+="\x1B[35m";break}case"red":{n+="\x1B[31m";break}case"white":{n+="\x1B[37m";break}case"yellow":{n+="\x1B[33m";break}default:if(Array.isArray(e.color)){const{0:s,1:i,2:r}=e.color;n+=`\x1B[38;2;${String(s)};${String(i)};${String(r)}m`}else{const s=Ys(e.color);if(s===null)n+="\x1B[39m";else{const{0:i,1:r,2:o}=s;n+=`\x1B[38;2;${String(i)};${String(r)};${String(o)}m`}}}if(e.fontWeight!==t.fontWeight&&(n+=e.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),e.fontStyle!==t.fontStyle&&(n+=e.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!Yi(e.textDecorationColor,t.textDecorationColor))if(e.textDecorationColor==null)n+="\x1B[59m";else{const{0:s,1:i,2:r}=e.textDecorationColor;n+=`\x1B[58;2;${String(s)};${String(i)};${String(r)}m`}return e.textDecorationLine.includes("line-through")!==t.textDecorationLine.includes("line-through")&&(n+=e.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),e.textDecorationLine.includes("overline")!==t.textDecorationLine.includes("overline")&&(n+=e.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),e.textDecorationLine.includes("underline")!==t.textDecorationLine.includes("underline")&&(n+=e.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),n},x2=e=>{try{return JSON.stringify(e)}catch{return'"[Circular]"'}},Vc="%".codePointAt(0),$2="s".codePointAt(0),E2="d".codePointAt(0),C2="f".codePointAt(0),R2="i".codePointAt(0),O2="O".codePointAt(0),j2="o".codePointAt(0),T2="j".codePointAt(0),I2="c".codePointAt(0),Wc=(e,t=[],n={})=>{if(typeof e!="string"&&typeof e!="object"||e===null)throw new TypeError(`fmt must be a string or object, got ${e===null?"null":typeof e}`);const s=n.stringify??x2,i=1;if(typeof e=="object"){const u=t.length+i;if(u===1)return"{}";const p=Array.from({length:u});p[0]=s(e);for(let f=1;f<u;f+=1)p[f]=s(t[f-i]);return p.join(" ")}if(t.length===0)return e;let r="",o=1-i,a=-1,c=!1,l;const d=n.colors??globalThis.window===void 0;for(let u=0;u<e.length;){if(e.codePointAt(u)===Vc&&u+1<e.length){a=a>-1?a:0;const p=e.codePointAt(u+1);switch(p){case I2:{if(a<u&&(r+=e.slice(a,u)),d){const f=k2(t[o]),h=S2(f,l);r+=h,h!==""&&(c=!0,l=f)}a=u+2,u+=1;break}case E2:case C2:{const f=t[o];if(o>=t.length||f==null)break;a<u&&(r+=e.slice(a,u)),r+=(typeof f=="symbol"?Number.NaN:Number(f)).toString(),a=u+2,u+=1;break}case R2:{const f=t[o];if(o>=t.length||f==null)break;a<u&&(r+=e.slice(a,u)),r+=Math.floor(typeof f=="symbol"?Number.NaN:Number(f)).toString(),a=u+2,u+=1;break}case T2:case O2:case j2:{if(o>=t.length||t[o]===void 0)break;a<u&&(r+=e.slice(a,u));const f=t[o],h=typeof f;if(h==="string"){r+=`'${f}'`,a=u+2,u+=1;break}if(h==="function"){r+=f.name?`[Function: ${f.name}]`:"[Function: <anonymous>]",a=u+2,u+=1;break}r+=s(f),a=u+2,u+=1;break}case Vc:{a<u&&(r+=e.slice(a,u)),r+="%",a=u+2,u+=1,o-=1;break}case $2:{if(o>=t.length)break;a<u&&(r+=e.slice(a,u));const f=t[o];r+=typeof f=="object"&&f!==null?s(f):String(f),a=u+2,u+=1;break}default:typeof n.formatters?.[p]=="function"?(a<u&&(r+=e.slice(a,u)),r+=n.formatters[p](t[o]),a=u+2,u+=1):o-=1}o+=1}u+=1}if(a===-1&&!(n.appendExtraArguments&&o<t.length))return e;if(a===-1?r=e:a<e.length&&(r+=e.slice(a)),a!==-1&&c&&(r+="\x1B[0m"),n.appendExtraArguments&&o<t.length)for(let u=Math.max(o,0);u<t.length;u+=1){const p=t[u];r+=` ${typeof p=="object"&&p!==null?s(p):String(p)}`}return r},A2=(e={})=>{const t={};typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([i,r])=>{if(i.length===0)throw new Error(`Formatter %${i} has no characters`);if(i.length>1)throw new Error(`Formatter %${i} has more than one character`);if(typeof r!="function")throw new TypeError(`Formatter for %${i} is not a function`);const o=i.codePointAt(0);if(o===void 0)throw new Error(`${i}.codePointAt(0) failed to return a value, please report this issue`);t[o]=r});const n={...e};delete n.formatters;const s=Object.freeze({...n,formatters:t});return(i,r=[],o)=>o===void 0?Wc(i,r,s):Wc(i,r,{...n,...o,formatters:t})},B2='"[Circular]"';class P2{#e;#t;#n;constructor(t={}){this.#t=t.formatters}setStringify(t){this.#e=t}process(t){this.#n===void 0&&(this.#n=A2({formatters:this.#t,stringify:s=>this.#r(s)}));const n=this.#n;return t.message!==void 0&&(t.message=this.#s(n,t.message,t.context??[])),t}#r(t){if(this.#e===void 0)try{return JSON.stringify(t)}catch{return B2}try{return this.#e(t)}catch(n){return JSON.stringify(`[unserializable: ${n instanceof Error?n.message:String(n)}]`)}}#s(t,n,s=[]){if(typeof n=="string")return t(n,s);if(typeof n=="object"&&n!==null){const i=n,r=Object.keys(i);for(let o=0;o<r.length;o+=1){const a=r[o],c=i[a];(typeof c=="string"||Array.isArray(c)||typeof c=="object")&&(i[a]=this.#s(t,c,s))}}return n}}const{bgGrey:N2,cyan:D2,green:L2,greenBright:M2,grey:Be,red:Xi,underline:Hc,white:_2}=ii,F2=/[\\/]pail[\\/]dist/,Zi=e=>!F2.test(e);class V2 extends XS{#e;#t;#n;#r=!1;#s;#i;#o;#a=!1;#c="";#l="";constructor(t={}){const{error:n,inspect:s,...i}=t;super({uppercase:{label:!0,...i.uppercase},...i}),this.#s={...zS,...s},this.#i={...n,color:{fileLine:L2,hint:D2,marker:Xi,message:Xi,method:M2,title:Xi}},this.#e=jo,this.#t=To,this.#d()}setLoggerTypes(t){super.setLoggerTypes(t),this.#d()}setStdout(t){this.#e=t,this.#o=void 0,this.#a=!1}setStderr(t){this.#t=t}setInteractiveManager(t){this.#n=t}setIsInteractive(t){this.#r=t}log(t){this._log(this._formatMessage(t),t.type.level)}#d(){this.#c=FS(this.loggerTypes),this.#l=Br(this.loggerTypes)}#p(){return!this.#a&&typeof this.#e.on=="function"&&(this.#a=!0,this.#e.on("resize",()=>{this.#o=void 0})),this.#o===void 0&&(this.#o=MS().columns),this.#o}_formatMessage(t){let n=this.#p();typeof this.styles.messageLength=="number"&&(n=this.styles.messageLength);const{badge:s,context:i,date:r,error:o,file:a,groups:c,label:l,message:d,prefix:u,repeated:p,scope:f,suffix:h,traceError:g,type:y}=t,{color:x}=this.loggerTypes[y.name],b=x?ii[x]:_2,S=c.map(()=>" ").join(""),C=[];if(c.length>0&&C.push(`${S+Be(`[${c.at(-1)??""}]`)} `),r&&C.push(`${Be(this.styles.dateFormatter(typeof r=="string"?new Date(r):r))} `),s)C.push(b(s));else{const D=this.#c;D.length>0&&C.push(`${Be(".".repeat(D.length))} `)}const N=this.#l;if(l){const D=Ie(N),F=Ie(l);C.push(`${b(KS(l,this.styles))} `,Be(".".repeat(Math.max(0,D-F))))}else C.push(Be(".".repeat(N.length+2)));p&&C.push(`${N2.white(`[${String(p)}x]`)} `),Array.isArray(f)&&f.length>0&&C.push(` ${Be(`[${f.join(" > ")}]`)} `),u&&C.push(`${Be(`${Array.isArray(f)&&f.length>0?". ":" "}[${this.styles.underline.prefix?Hc(u):u}]`)} `);const T=Ie(C.join(" "));if(a){const D=(a.name??"")+(a.line?`:${String(a.line)}`:""),F=Ie(D);if(F+T+2>n)C.push(Be(` ${D}`));else{const V=Math.max(0,n-T-F-2);C.push(Be(`${".".repeat(V)} ${D}`))}}else C.push(Be(".".repeat(Math.max(0,n-T-1))));if(C.length>0&&C.push(`
183
183
 
184
- `),d!==$o){const D=typeof d=="string"?d:qs(d,this.#s);C.push(S+AS(D,{trim:!1,width:n-3,wrapMode:_n.STRICT_WIDTH}))}if(i){let D=!1;C.push(...i.map(F=>{if(F instanceof Error)return D=!0,`
184
+ `),d!==Eo){const D=typeof d=="string"?d:Ks(d,this.#s);C.push(S+DS(D,{trim:!1,width:n-3,wrapMode:_n.PRESERVE_WORDS}))}if(i){let D=!1;C.push(...i.map(F=>{if(F instanceof Error)return D=!0,`
185
185
 
186
- ${Wi(F,{...this.#i,filterStacktrace:Xi,prefix:S})}`;if(typeof F=="object")return` ${qs(F,this.#s)}`;const V=(D?`
186
+ ${Hi(F,{...this.#i,filterStacktrace:Zi,prefix:S})}`;if(typeof F=="object")return` ${Ks(F,this.#s)}`;const V=(D?`
187
187
 
188
- `:" ")+String(F);return D=!1,V}))}return o&&C.push(Wi(o,{...this.#i,filterStacktrace:Xi,prefix:S})),g&&C.push(`
188
+ `:" ")+String(F);return D=!1,V}))}return o&&C.push(Hi(o,{...this.#i,filterStacktrace:Zi,prefix:S})),g&&C.push(`
189
189
 
190
- ${Wi(g,{...this.#i,filterStacktrace:Xi,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:S})}`),h&&C.push(`
191
- `,S+Pe(this.styles.underline.suffix?Vc(h):h)),C.join("")}_log(t,n){const s=Cu(n)?"stderr":"stdout",i=s==="stderr"?this.#t:this.#e;this.#r&&this.#n!==void 0&&i.isTTY?this.#n.update(s,t.split(`
192
- `),0):Ru(`${t}
193
- `,i)}}const M2=()=>Un.NODE_ENV==="debug"||Un.DEBUG!==void 0?"debug":Un.NODE_ENV==="test"?"warning":"informational",tp=e=>{let t=M2();return Un.PAIL_LOG_LEVEL!==void 0&&(t=Un.PAIL_LOG_LEVEL),new u2({logLevel:t,processors:[new T2],reporters:[new L2],stderr:jo,stdout:Oo,...e})};tp();const E=tp(),_2=e=>`MARSHALL_DISABLE_${e.replaceAll(/([A-Z])/g,"_$1").toUpperCase()}`,Zi=(e,t=process.env)=>ea(t.MARSHALL_DISABLE_ALL)?!0:ea(t[_2(e)]),np=(e,t)=>{const n={errors:[],warnings:[]},{security:s}=e;if(!s)return n.warnings.push("No security settings configured. Use defineConfig() from '@visulima/vis/config' to get secure defaults automatically."),n;const i=s.policies??{},{installScripts:r}=i,o=r?.allow,a=o&&Object.keys(o).length>0;if(a||n.warnings.push(t==="pnpm"?"security.policies.installScripts.allow is not configured. pnpm blocks build scripts by default since v10. Run 'vis approve-builds' to review.":"security.policies.installScripts.allow is not configured. Consider listing which packages are allowed to run install/postinstall scripts."),i.firstSeen?.minutes===0&&n.warnings.push("security.policies.firstSeen.minutes is explicitly set to 0. New packages can be installed immediately after publishing."),i.publisherChange?.mode==="off"&&n.warnings.push("security.policies.publisherChange.mode is explicitly 'off'. Packages whose trust level has decreased will not be blocked."),s.blockExoticSubdeps===!1&&n.warnings.push("security.blockExoticSubdeps is explicitly disabled. Transitive dependencies can pull code from git repos or tarball URLs."),r?.strict===!1&&n.warnings.push("security.policies.installScripts.strict is explicitly disabled. Unapproved build scripts will only produce warnings, not errors."),r?.strict&&!a&&n.errors.push("security.policies.installScripts.strict is enabled but `.allow` is empty. All dependencies with build scripts will be blocked. Run 'vis approve-builds' to review and add packages."),s.acceptedRisks){const l=Date.now();for(const[d,u]of Object.entries(s.acceptedRisks)){const p=new Date(u.acceptedAt).getTime();l-p>7776e6&&n.warnings.push(`Accepted risk for "${d}" is over 90 days old (accepted ${u.acceptedAt}). Consider re-evaluating with 'vis audit'.`)}}return n},F2=(e,t,n=!1)=>{if(dt&&!process.env.VIS_SECURITY_WARNINGS)return;const s=np(e,t);for(const r of s.errors)E.error(r);const i=n?s.warnings.filter(r=>!r.startsWith("security.policies.installScripts.allow is not configured")):s.warnings;i.length>0&&E.warn(`${i.length} security recommendation${i.length===1?"":"s"} found. Run 'vis check --security-config' for details.`)},k4=(e,t)=>{const n=np(e,t),{security:s}=e;if(s){const i=s.policies??{},{firstSeen:r}=i,{publisherChange:o}=i,{installScripts:a}=i,{score:c}=i;if(E.info("Active security settings:"),E.info(` policies.firstSeen.minutes: ${r?.minutes??"not set"} minutes`),E.info(` policies.publisherChange.mode: ${o?.mode??"not set"}`),E.info(` policies.publisherChange.ignoreAfter: ${o?.ignoreAfter??"not set"} minutes`),E.info(` blockExoticSubdeps: ${s.blockExoticSubdeps??!1}`),E.info(` policies.installScripts.strict: ${a?.strict??!1}`),E.info(` policies.installScripts.allow: ${a?.allow?`${Object.keys(a.allow).length} entries`:"not configured"}`),E.info(""),E.info("Socket.dev integration:"),E.info(` socket.enabled: ${s.socket?.enabled??!1}`),E.info(` socket.apiToken: ${s.socket?.apiToken||process.env.VIS_SOCKET_TOKEN?"configured":"using public token"}`),E.info(` policies.score.minimum: ${c?.minimum??"default (0.4)"}`),E.info(` socket.cacheTtlMs: ${s.socket?.cacheTtlMs??"default (1 hour)"}`),E.info(` socket.timeoutMs: ${s.socket?.timeoutMs??"default (15s)"}`),s.acceptedRisks){const l=Object.entries(s.acceptedRisks);E.info(` acceptedRisks: ${String(l.length)} entr${l.length===1?"y":"ies"}`);for(const[d,u]of l)E.info(` ${d}: ${u.reason} (accepted ${u.acceptedAt.slice(0,10)})`)}else E.info(" acceptedRisks: none");E.info("")}if(n.errors.length===0&&n.warnings.length===0){E.info("All recommended security settings are configured.");return}for(const i of n.errors)E.error(i);for(const i of n.warnings)E.warn(i);E.notice(""),E.notice("Secure defaults are applied by defineConfig(). You only need to add install-script allowances:"),E.notice(""),E.notice(" import { defineConfig } from '@visulima/vis/config';"),E.notice(""),E.notice(" export default defineConfig({"),E.notice(" security: {"),E.notice(" policies: {"),E.notice(" installScripts: {"),E.notice(" allow: {"),E.notice(" esbuild: true,"),E.notice(" '@prisma/client': true,"),E.notice(" },"),E.notice(" },"),E.notice(" },"),E.notice(" },"),E.notice(" });")},S4=e=>{const{security:t}=e;if(!t)return[];const n=t.policies??{},{firstSeen:s}=n,{publisherChange:i}=n,{installScripts:r}=n,o=[];return s?.minutes!==void 0&&o.push(`minimumReleaseAge: ${s.minutes}`),i?.mode&&i.mode!=="off"&&o.push(`trustPolicy: ${i.mode}`),t.blockExoticSubdeps&&o.push("blockExoticSubdeps: true"),r?.allow&&o.push(`allowBuilds: ${Object.keys(r.allow).length} entries`),r?.strict&&o.push("strictDepBuilds: true"),i?.ignoreAfter!==void 0&&o.push(`trustPolicyIgnoreAfter: ${i.ignoreAfter}`),o},sp=e=>{const t=e.trim();if(t==="")return;const n=/^(\d+(?:\.\d+)?)\s*([mhdw]?)$/i.exec(t);if(!n)return;const s=Number.parseFloat(n[1]);if(!(!Number.isFinite(s)||s<0))switch(n[2]?.toLowerCase()){case"":case"m":case void 0:return Math.round(s);case"d":return Math.round(s*1440);case"h":return Math.round(s*60);case"w":return Math.round(s*10080);default:return}},V2=e=>e.startsWith("@")||e.includes("/")||/[:#\s]/.test(e),x4=e=>V2(e)?`'${e.replaceAll("'","''")}'`:e,W2=e=>{const t=e.trim();return/^\d+$/.test(t)?Number.parseInt(t,10)*1440:sp(t)},H2=(e,t)=>{const n={};try{switch(e){case"bun":{const s=m(t,"package.json");if($(s)){const r=de(s);Array.isArray(r.trustedDependencies)&&(n.allowBuilds=new Set(r.trustedDependencies))}const i=m(t,"bunfig.toml");if($(i)){const r=mh(i),o=r?.install?.minimumReleaseAge;typeof o=="number"&&(n.minReleaseAgeMinutes=Math.round(o/60)),Array.isArray(r?.install?.minimumReleaseAgeExcludes)&&(n.minReleaseAgeExcludes=new Set(r.install.minimumReleaseAgeExcludes))}break}case"npm":{const s=m(t,".npmrc");if($(s)){const i=J(s),r=/^\s*min-release-age\s*=\s*([^\s#;]+)/m.exec(i);r&&(n.minReleaseAgeMinutes=W2(r[1]))}break}case"pnpm":{const s=m(t,"pnpm-workspace.yaml");if($(s)){const i=It(s);i?.allowBuilds&&typeof i.allowBuilds=="object"?n.allowBuilds=new Set(Object.entries(i.allowBuilds).filter(([,r])=>r).map(([r])=>r)):Array.isArray(i?.onlyBuiltDependencies)&&(n.allowBuilds=new Set(i.onlyBuiltDependencies)),typeof i?.minimumReleaseAge=="number"&&(n.minReleaseAgeMinutes=i.minimumReleaseAge),Array.isArray(i?.minimumReleaseAgeExclude)&&(n.minReleaseAgeExcludes=new Set(i.minimumReleaseAgeExclude))}break}case"yarn":{const s=m(t,".yarnrc.yml");if($(s)){const i=It(s),r=i?.npmMinimalAgeGate;typeof r=="string"?n.minReleaseAgeMinutes=sp(r):typeof r=="number"&&(n.minReleaseAgeMinutes=r),Array.isArray(i?.npmPreapprovedPackages)&&(n.minReleaseAgeExcludes=new Set(i.npmPreapprovedPackages))}break}default:break}}catch{}return n},U2=(e,t,n)=>{const s=H2(t,n),i={hasDrift:!1,packageManager:t},o=(e.security??{}).policies??{},{installScripts:a}=o,{firstSeen:c}=o;if(a?.allow&&(t==="pnpm"||t==="bun")){const l=new Set(Object.entries(a.allow).filter(([,f])=>f).map(([f])=>f)),d=s.allowBuilds??new Set,u=[...l].filter(f=>!d.has(f)),p=[...d].filter(f=>!l.has(f));(u.length>0||p.length>0)&&(i.allowBuilds={onlyInPm:p,onlyInVis:u},i.hasDrift=!0)}if(c?.minutes!==void 0&&!(t==="yarn"&&s.minReleaseAgeMinutes===void 0&&!$(m(n,".yarnrc.yml")))&&s.minReleaseAgeMinutes!==c.minutes&&(i.minReleaseAge={pm:s.minReleaseAgeMinutes,vis:c.minutes},i.hasDrift=!0),c?.exclude&&(t==="pnpm"||t==="bun"||t==="yarn")){const l=new Set(c.exclude),d=s.minReleaseAgeExcludes??new Set,u=[...l].filter(f=>!d.has(f)),p=[...d].filter(f=>!l.has(f));(u.length>0||p.length>0)&&(i.minReleaseAgeExcludes={onlyInPm:p,onlyInVis:u},i.hasDrift=!0)}return i},G2=e=>{if(!e.hasDrift)return[];const t=[`vis.config and ${e.packageManager}-native config disagree on security settings:`];if(e.allowBuilds&&(e.allowBuilds.onlyInVis.length>0&&t.push(` security.policies.installScripts.allow — only in vis.config: ${e.allowBuilds.onlyInVis.join(", ")}`),e.allowBuilds.onlyInPm.length>0&&t.push(` security.policies.installScripts.allow — only in ${e.packageManager} config: ${e.allowBuilds.onlyInPm.join(", ")}`)),e.minReleaseAge){const n=e.minReleaseAge.vis===void 0?"unset":`${String(e.minReleaseAge.vis)} min`,s=e.minReleaseAge.pm===void 0?"unset":`${String(e.minReleaseAge.pm)} min`;t.push(` security.policies.firstSeen.minutes — vis.config: ${n}, ${e.packageManager}: ${s}`)}return e.minReleaseAgeExcludes&&(e.minReleaseAgeExcludes.onlyInVis.length>0&&t.push(` security.policies.firstSeen.exclude — only in vis.config: ${e.minReleaseAgeExcludes.onlyInVis.join(", ")}`),e.minReleaseAgeExcludes.onlyInPm.length>0&&t.push(` security.policies.firstSeen.exclude — only in ${e.packageManager} config: ${e.minReleaseAgeExcludes.onlyInPm.join(", ")}`)),t.push(" Run 'vis security sync' to push vis.config values to the native config."),t},z2=e=>$(m(e,".yarnrc.yml")),J2=(e,t,n)=>{const s={extraArgs:[],postInstallPackages:[],scriptsBlockedByDefault:!1,warnings:[]},i=n.security?.policies?.installScripts?.allow??{},r=Object.keys(i).length>0;switch(e){case"bun":{if(s.scriptsBlockedByDefault=!0,r){const o=m(t,"package.json");try{($(o)?de(o):{}).trustedDependencies?.length||s.warnings.push("vis security.policies.installScripts.allow is configured but trustedDependencies is empty. Run 'vis approve-builds --sync-native'.")}catch{}}break}case"npm":{s.scriptsBlockedByDefault=!1;const o=m(t,".npmrc"),a=$(o)&&/^\s*ignore-scripts\s*=\s*true\s*$/m.test(J(o));if(!a&&r?(s.warnings.push("npm does not block lifecycle scripts. vis will add --ignore-scripts automatically."),s.extraArgs.push("--ignore-scripts")):!a&&!r&&s.warnings.push("npm does not block lifecycle scripts. Add 'ignore-scripts=true' to .npmrc and configure security.policies.installScripts.allow."),r)for(const[c,l]of Object.entries(i))l&&s.postInstallPackages.push(c);break}case"pnpm":{s.scriptsBlockedByDefault=!0,r||s.warnings.push("pnpm blocks build scripts by default. Run 'vis approve-builds' to review packages that need scripts.");break}case"yarn":{if(s.scriptsBlockedByDefault=!1,z2(t)){const o=J(m(t,".yarnrc.yml"));/^\s*enableScripts\s*:\s*false\s*$/m.test(o)?s.scriptsBlockedByDefault=!0:s.warnings.push("yarn berry supports enableScripts. Add 'enableScripts: false' to .yarnrc.yml.")}else if(s.warnings.push("yarn classic does not support blocking lifecycle scripts. Consider upgrading to yarn berry."),r){s.extraArgs.push("--ignore-scripts");for(const[o,a]of Object.entries(i))a&&s.postInstallPackages.push(o)}break}}return s},ip=(...e)=>{const t={...process.env},n=t.PATH??t.Path??"",s=e.filter(i=>i.length>0).join(Zo);return t.PATH=s.length>0?n?`${s}${Zo}${n}`:s:n,t},q2=e=>{if(e.endsWith("*"))return e.endsWith("@*")?e.slice(0,-2):e;const t=e.startsWith("@"),n=e.indexOf("@",t?1:0);return n===-1?e:e.slice(0,n)},K2=(e,t)=>{const n=m(e,"node_modules"),s=[];for(const i of t){if(!i.endsWith("*")){s.push(q2(i));continue}const r=i.slice(0,-1);try{if(r.startsWith("@")&&r.endsWith("/")){const o=m(n,r.slice(0,-1));for(const a of Ee(o))!a.startsWith(".")&&At(m(o,a)).isDirectory()&&s.push(`${r.slice(0,-1)}/${a}`)}else for(const o of Ee(n))o.startsWith(r)&&At(m(n,o)).isDirectory()&&s.push(o)}catch{}}return s},Y2=(e,t)=>{if(t.length===0)return;const n=K2(e,t);if(n.length===0)return;const s=m(e,"node_modules"),i=m(s,".bin");let r=!1;for(const o of n){if(o.includes("..")||o.startsWith("/")||o.startsWith("\\")){E.warn(`Skipping invalid package name: ${o}`);continue}const a=(o.match(/\//g)??[]).length;if(a>1||a===1&&!o.startsWith("@")){E.warn(`Skipping invalid package name: ${o}`);continue}const c=m(s,o),l=m(c,"package.json");if($(l))try{const d=de(l).scripts??{},u=m(c,"node_modules",".bin"),p=ip(u,i);for(const f of["preinstall","install","postinstall"])if(d[f]){E.info(`Running ${f} for ${o}...`);try{const h=d[f];gl(h,{cwd:c,env:p,stdio:"inherit"})}catch{E.error(`${f} script failed for ${o}`),r=!0}}}catch{}}r&&(process.exitCode=1)},$4=(e,t=["prepublish","prepare"])=>{const n=m(e,"package.json");if(!$(n))return;let s;try{s=de(n).scripts??{}}catch{return}let i=!1;const r=ip(m(e,"node_modules",".bin"));for(const o of t){const a=s[o];if(a){E.info(`Running root ${o}...`);try{gl(a,{cwd:e,env:r,stdio:"inherit"})}catch{E.error(`Root ${o} script failed.`),i=!0}}}i&&(process.exitCode=1)},Qi=new Set(["add","install","update"]),X2=new Set(["add","dedupe","install","remove","update"]),Z2=/(\d+\.\d+\.\d+)/,Q2=e=>{const t=m(e,"package.json");if(!$(t))return[];const n=[];try{const s=de(t),i={...s.dependencies,...s.devDependencies};for(const[r,o]of Object.entries(i)){const a=m(e,"node_modules",r,"package.json");if($(a))try{const l=de(a);if(l.version){n.push({name:r,version:l.version});continue}}catch{}const c=Z2.exec(o);c?.[1]&&n.push({name:r,version:c[1]})}}catch{}return n},ex={afterCommand:async e=>{if(process.exitCode&&process.exitCode!==0)return;const t=e.scriptEnforcement;t?.postInstallPackages.length&&e.workspaceRoot&&Y2(e.workspaceRoot,t.postInstallPackages);const n=process.argv[2]??"",s=Qi.has(n)&&e.workspaceRoot?ta(e.workspaceRoot):void 0;if(s&&e.visConfig&&e.workspaceRoot&&new Set(["bun","npm","pnpm","yarn"]).has(s.name)){const r=U2(e.visConfig,s.name,e.workspaceRoot);if(r.hasDrift){E.info("");for(const o of G2(r))E.warn(o)}}if(Qi.has(n)&&e.workspaceRoot){const i=new Set;Zi("socket")&&i.add("socket"),Zi("depsDev")&&i.add("deps-dev");const r=e.visConfig?.security?.policies?.score?.minimum,o=qf(e.visConfig?.security,{disabled:i,minimumScore:r});if(o.length>0)try{const a=Q2(e.workspaceRoot);if(a.length>0){const c=await Kf(o,a);if(c.size>0){const l=fh(c,r);if(l){E.info(""),E.info(l);let d=0;for(const u of c.values())for(const p of u.alerts)(p.severity==="critical"||p.severity==="high")&&d++;d>0&&E.warn(`${String(d)} critical/high severity alert${d===1?"":"s"} detected. Run 'vis check --security' for details.`)}}}}catch{}}},beforeCommand:async e=>{const t=process.argv[2]??"";if(X2.has(t)&&e.visConfig&&e.workspaceRoot){const n=ta(e.workspaceRoot),s=Qi.has(t);if(F2(e.visConfig,n.name,s),s&&!Zi("installScripts")){const i=J2(n.name,e.workspaceRoot,e.visConfig);for(const r of i.warnings)e.logger.warn(`security: ${r}`);e.scriptEnforcement=i}}},name:"security-enforcement"};class Ao extends Ef{troubleshooting;constructor(t,n,s=[]){super(t,n,{troubleshooting:s}),this.name="CompletionError",this.troubleshooting=s,s.length>0&&(this.hint=s.join(`
194
- `))}}const Mr=["bash","zsh","fish","powershell"],_r=["node","bun","deno"],tx=e=>"Deno"in e,nx=e=>"Bun"in e,Wc=()=>tx(globalThis)?"deno":nx(globalThis)?"bun":"node",Hc=e=>{const t=e?.starshipShell??e?.shell;if(t){const i=t.toLowerCase();if(i.includes("zsh"))return"zsh";if(i.includes("bash"))return"bash";if(i.includes("fish"))return"fish"}const n=e?.psModulePath,s=e?.prompt;if(n||s?.includes("PS"))return"powershell";if(e?.comSpec?.toLowerCase().includes("cmd.exe"))return"bash"},sx=async()=>(await import("./index4.js")).default,ix=(e,t)=>{for(const n of t)n.hidden||(n.name&&e.option(n.name,n.description??""),n.alias&&e.option(n.alias,n.description??""))},rx=(e,t)=>{for(const[n,s]of t){if(s.name!==n||s.hidden)continue;const i=e.command(s.name,s.description??"");s.options&&ix(i,s.options)}},ox=e=>{if(!Mr.includes(e))throw new Ao(`Invalid shell type: ${e}`,"INVALID_SHELL",[`Valid shells are: ${Mr.join(", ")}`,"Shell will be auto-detected if not specified"])},ax=e=>{if(e&&!_r.includes(e))throw new Ao(`Invalid runtime: ${e}`,"INVALID_RUNTIME",[`Valid runtimes are: ${_r.join(", ")}`,"Runtime will be auto-detected if not specified"])},cx=(e,t)=>{e.error("Could not detect current shell");const n=[`Usage: ${t} completion --shell=<bash|zsh|fish|powershell> [--runtime=<node|bun|deno>]`,"","Examples:"," # Install completions for zsh:",` ${t} completion --shell=zsh > ~/.${t}-completion.zsh`,` echo 'source ~/.${t}-completion.zsh' >> ~/.zshrc`,""," # Install completions for bash with custom runtime:",` ${t} completion --shell=bash --runtime=bun > ~/.${t}-completion.bash`,` echo 'source ~/.${t}-completion.bash' >> ~/.bashrc`,""," # Install completions for fish:",` ${t} completion --shell=fish > ~/.config/fish/completions/${t}.fish`].join(`
195
- `);e.info(n)},lx={description:"Generate shell completion scripts",env:[{description:"Shell path (Unix-like systems). Used for shell detection.",name:"SHELL",type:String},{description:"Starship shell configuration. Takes precedence over SHELL for detection.",name:"STARSHIP_SHELL",type:String},{description:"PowerShell module path (Windows). Used for PowerShell detection.",name:"PSModulePath",type:String},{description:"Command prompt variable (Windows). Used for PowerShell detection.",name:"PROMPT",type:String},{description:"Command processor (Windows). Used for Windows Command Prompt detection.",name:"ComSpec",type:String}],execute:async({env:e,logger:t,options:n,runtime:s})=>{const i=s.getCliName(),r=n.shell??Hc(e);if(!r){cx(t,i);return}try{ox(r),ax(n.runtime);const o=await sx();rx(o,s.getCommands());const a=`${n.runtime??Wc()} ${i}`;o.setup(i,a,r)}catch(o){if(o instanceof Ao){const a=[`Failed to generate completion script: ${o.message}`,`Error code: ${o.code}`];throw o.troubleshooting.length>0&&a.push("","Troubleshooting:",...o.troubleshooting.map(c=>` • ${c}`)),t.error(a.join(`
196
- `)),o}else{const a=["Failed to generate completion script",`Error: ${o instanceof Error?o.message:String(o)}`,"","Troubleshooting:"," • Ensure @bomb.sh/tab is installed: pnpm add @bomb.sh/tab",` • Verify shell is supported: ${Mr.join(", ")}`,` • Verify runtime is supported: ${_r.join(", ")}`," • Check that your CLI name is correct"];t.error(a.join(`
197
- `))}}},name:"completion",options:[{defaultOption:!0,defaultValue:Hc(),description:"Shell type (bash, zsh, fish, powershell). Defaults to current shell if detected.",name:"shell",type:String,typeLabel:"{underline shell}"},{defaultValue:Wc(),description:"JavaScript runtime (node, bun, deno). Defaults to current runtime if detected.",name:"runtime",type:String,typeLabel:"{underline runtime}"}]},dx={alias:["v","V"],description:"Output the version number",execute:({logger:e,runtime:t})=>{const n=t.getPackageVersion();n===void 0?(e.warn("Unknown version"),e.debug("The version number was not provided by the cli constructor.")):e.info(n)},name:"version",options:[],usage:[]},ux={json:{defaultValue:!1,description:"Emit JSON instead of ASCII",type:Boolean},projects:{alias:"p",description:"Comma-separated list of projects to plan (same semantics as `vis run --projects`)",type:String},query:{description:"Filter matched projects by a query",type:String},tag:{description:'Only plan projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…".',multiple:!0,type:String}},px=R({argument:{description:"Target selector (same syntax as `vis run`): `build`, `:build`, `~:test`, `#tag:lint`, …",name:"selector",type:String},description:"Show the execution plan for a target without running it",examples:[["vis action-graph build","Print the task plan for `build` on every project"],["vis action-graph :test","Moon-style selector"],["vis action-graph build --json","Emit a JSON description of the plan"],['vis action-graph lint --query "tag=frontend"',"Filter projects by query"],["vis action-graph build --projects=@org/web","Plan only the named projects (same flag as `vis run`)"]],group:"Workspace",loader:()=>import("./handler2.js"),name:"action-graph",options:ux}),fx={"auto-install-peers":{defaultValue:!1,description:"After adding, recursively install non-optional peer dependencies that aren't already in the workspace (matches nypm's installPeerDependencies)",type:Boolean},exact:{alias:"E",defaultValue:!1,description:"Save exact version",type:Boolean},filter:{alias:"F",description:"Filter by workspace package name",multiple:!0,type:String},global:{alias:"g",defaultValue:!1,description:"Install globally (uses npm)",type:Boolean},"no-marshall-check":{defaultValue:!1,description:"Skip the offline marshall pipeline (author, provenance, metadata, downloads, expired-domains, new-bin, signatures, archived-repo)",type:Boolean},"no-socket-check":{defaultValue:!1,description:"Skip Socket.dev security check before adding",type:Boolean},"no-typosquat-check":{defaultValue:!1,description:"Skip typosquat name check before adding",type:Boolean},"run-scripts":{defaultValue:!1,description:"Run lifecycle scripts during add (opts out of vis's default block-by-default policy; allowlisted packages run via security.policies.installScripts.allow)",type:Boolean},"save-dev":{alias:"D",defaultValue:!1,description:"Add as dev dependency",type:Boolean},"save-optional":{alias:"O",defaultValue:!1,description:"Add as optional dependency",type:Boolean},"save-peer":{alias:"P",defaultValue:!1,description:"Add as peer dependency",type:Boolean},to:{description:"Target a single workspace package and auto-conform the version to existing catalogs / sibling deps (syncpack#285)",type:String},workspace:{defaultValue:!1,description:"Use workspace protocol (pnpm)",type:Boolean},"workspace-root":{alias:"w",defaultValue:!1,description:"Add to workspace root",type:Boolean}},hx=R({argument:{description:"Packages to add (e.g., react react-dom)",name:"packages",type:String},description:"Add packages using the detected package manager",examples:[["vis add react react-dom","Add packages"],["vis add -D typescript @types/react","Add as dev dependencies"],["vis add react --filter app","Add to specific workspace package"],["vis add react --to web","Add to one package, auto-conforming the version to existing catalogs / sibling deps"],["vis add -g typescript","Add globally (uses npm)"],["vis add lodash -w","Add to workspace root"],["vis add lodash --no-socket-check","Add without Socket.dev check"],["vis add lodash --no-typosquat-check","Skip typosquat name check"],["vis add lodash --no-marshall-check","Skip the offline marshall pipeline (author, downloads, etc.)"],["vis add lodash --run-scripts","Run lifecycle scripts (opts out of vis's default block-by-default policy)"]],group:"Dependencies",loader:()=>import("./handler15.js"),name:"add",options:fx}),Po={description:"Override the cache DB path (defaults to <cache>/vis/advisories/db.sqlite via @visulima/find-cache-dir).",name:"db",type:String},us={description:"Output format: table (default) or json.",name:"format",type:String},gx={commandPath:["advisories"],description:"Download and ingest one or more OSV ecosystem dumps into the local cache",examples:[["vis advisories sync","Sync the npm ecosystem (default)"],["vis advisories sync --ecosystem npm","Sync a single explicit ecosystem"],["vis advisories sync --ecosystem npm,PyPI","Sync several ecosystems in one pass"],["vis advisories sync --force","Re-download even when the ETag matches"],["vis advisories sync --source https://mirror.example.com","Use a corporate OSV mirror (must be in allowedHosts)"]],group:"Security & Health",loader:G(()=>import("./sync.js"),"advisoriesSyncExecute"),name:"sync",options:[{description:"Comma-separated list of ecosystems to sync (default: npm).",name:"ecosystem",type:String},{defaultValue:!1,description:"Re-download and re-ingest even if the upstream ETag is unchanged.",name:"force",type:Boolean},{description:"Override the advisory source URL. Must be https and resolve to an allowed host.",name:"source",type:String},Po,us]},mx={commandPath:["advisories"],description:"Print the local advisory DB summary: path, schema version, ecosystems, row counts, last sync, ETag",examples:[["vis advisories status","Human-readable summary"],["vis advisories status --format json","Machine-readable for CI freshness checks"]],group:"Security & Health",loader:G(()=>import("./status.js"),"advisoriesStatusExecute"),name:"status",options:[Po,us]},yx={commandPath:["advisories"],description:"Delete the local advisory DB. The next `vis audit --offline` will fail until you re-sync",examples:[["vis advisories prune","Confirm and delete the local DB"],["vis advisories prune --force","Delete without confirmation"]],group:"Security & Health",loader:G(()=>import("./prune.js"),"advisoriesPruneExecute"),name:"prune",options:[Po,{defaultValue:!1,description:"Skip the confirmation prompt.",name:"force",type:Boolean},us]},rp={description:"Override the bloom cache directory (defaults to <cache>/vis/osv-bloom/).",name:"cache-dir",type:String},vx={commandPath:["advisories","bloom"],description:"Fetch and verify the endevco/osv-bloom MAL-* prefilter into the local cache",examples:[["vis advisories bloom sync","Fetch the bloom filter from the default upstream"],["vis advisories bloom sync --force","Re-download even when the set digest matches"],["vis advisories bloom sync --source https://bloom.example.com","Use an internal mirror (must be in allowedHosts)"]],group:"Security & Health",loader:G(()=>import("./bloom-sync.js"),"advisoriesBloomSyncExecute"),name:"sync",options:[{defaultValue:!1,description:"Re-download and re-verify even when the upstream set digest is unchanged.",name:"force",type:Boolean},{description:"Override the bloom source URL. Must be https and resolve to an allowed host.",name:"source",type:String},rp,us]},bx={commandPath:["advisories","bloom"],description:"Print the local osv-bloom cache freshness: built-at, filter size, m/k parameters, set digest",examples:[["vis advisories bloom status","Human-readable summary"],["vis advisories bloom status --format json","Machine-readable for CI freshness checks"]],group:"Security & Health",loader:G(()=>import("./bloom-status.js"),"advisoriesBloomStatusExecute"),name:"status",options:[rp,us]},wx=[gx,mx,yx,vx,bx],fe=e=>{const{name:t,...n}=e;return{[`no-${t}`]:{description:`Disable --${t}.`,hidden:!0,type:Boolean},[t]:n}},kx={base:{description:"Git base ref for comparison. When omitted, vis auto-resolves it from the active CI provider (GitHub/GitLab/Buildkite/CircleCI) or falls back to `git merge-base HEAD origin/<defaultBase>` locally. Default base branch comes from `vis.config.ts#defaultBase` (or `main`).",type:String},head:{description:"Git head ref for comparison. When omitted, auto-resolves from CI env (e.g. `$GITHUB_SHA`) or defaults to `HEAD`.",type:String},...fe({description:"Include uncommitted working-tree changes (tracked edits and untracked files) in the changed-file set. Defaults to on for local runs and off in CI; use --no-uncommitted to force off.",name:"uncommitted",type:Boolean}),downstream:{defaultValue:"deep",description:'Downstream scope: "none", "direct", or "deep" — controls how far to include dependents of changed projects',type:String},parallel:{defaultValue:3,description:"Maximum number of parallel tasks",type:Number},upstream:{defaultValue:"none",description:'Upstream scope: "none", "direct", or "deep" — controls how far to include dependencies of changed projects',type:String},...fe({defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean}),"dry-run":{defaultValue:!1,description:"Show what would run without executing",type:Boolean},partition:{description:'Partition tasks for distributed CI (e.g., "1/4" for first of four runners). Falls back to VIS_PARTITION env var.',type:String},query:{description:"Filter affected projects by a query (e.g. 'language=typescript && tag=lib')",type:String},reverse:{defaultValue:!1,description:"Run the dependency graph in reverse (leaves first, then their dependents). Useful for teardown targets like `destroy`/`undeploy` where dependents must run before the things they depend on.",type:Boolean},"runner-tags":{description:"Comma-separated tags this runner advertises (e.g. 'gpu,slow'). Forwarded verbatim to the downstream `vis run` so capability-gated tasks resolve identically. Falls back to VIS_RUNNER_TAGS env var.",type:String},"sparse-checkout":{defaultValue:!1,description:"Instead of running, print the affected project roots as a git sparse-checkout cone set (one path per line) and exit. Pipe into `git sparse-checkout set --stdin` to shrink huge-monorepo CI checkouts.",type:Boolean},tag:{description:'Only run affected projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…"; combines with --query as AND.',multiple:!0,type:String}},Sx=R({argument:{description:"The target to run (e.g., build, test, lint)",name:"target",type:String},description:"Run a target only on projects affected by recent changes",examples:[["vis affected build","Run build on affected projects"],["vis affected test --base=main","Run tests on projects changed since main"],["vis affected destroy --reverse","Tear down affected projects leaves-first"],["vis affected build --sparse-checkout","Print a git sparse-checkout cone set for the affected projects and exit"]],group:"Run & Execute",loader:()=>import("./handler3.js"),name:"affected",options:kx}),op={description:"Output format: table or json (default: table)",name:"format",type:String},xx={commandPath:["ai"],description:"List detected AI providers and show which one is selected",examples:[["vis ai providers","List all AI providers and their status"],["vis ai providers --format json","Output as JSON"]],group:"System",loader:G(()=>import("./handler50.js"),"aiProvidersExecute"),name:"providers",options:[op]},$x={},Ex=R({commandPath:["ai"],description:"Test the best available AI provider with a quick prompt",examples:[["vis ai test","Test the selected provider"]],group:"System",loader:G(()=>import("./handler50.js"),"aiTestExecute"),name:"test",options:$x}),Cx={argument:{description:"Task ID to propose a fix for (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["ai"],description:"Read a failed task's logs and propose a structured patch (Phase 1: local-only, no git)",examples:[["vis ai fix @myorg/app:build","Print proposed patch for the failed task"],["vis ai fix @myorg/app:build --apply","Apply the patch to disk after confirming"],["vis ai fix @myorg/app:build --format json","Machine-readable patch output"],["vis ai fix @myorg/app:build --run 2026-04-28T...","Inspect a specific historical run"]],group:"System",loader:G(()=>import("./handler50.js"),"aiFixExecute"),name:"fix",options:[op,{description:"Use a specific run ID from .vis/runs/ instead of the latest run",name:"run",type:String},{defaultValue:!1,description:"Apply the proposed patch to disk after printing it",name:"apply",type:Boolean},{defaultValue:!1,description:"Bypass the AI response cache",name:"no-cache",type:Boolean},{defaultValue:!1,description:"Skip the confirmation prompt before applying",name:"yes",type:Boolean}]},Rx={},Ox=R({description:"AI-assisted commands: provider detection and failure-fix proposals (cache management lives under `vis cache`)",examples:[["vis ai","List all AI subcommands"],["vis ai discover-help","Machine-readable subcommand catalogue (for AI agents)"]],group:"System",loader:G(()=>import("./handler50.js"),"aiRootExecute"),name:"ai",options:Rx}),jx={},Tx=R({commandPath:["ai"],description:"Print the machine-readable AI subcommand catalogue (JSON to stdout, designed for AI agents)",examples:[["vis ai discover-help","Emit the discovery payload as JSON"],["vis ai discover-help | jq '.subcommands[].path'","List all available paths"]],group:"System",loader:G(()=>import("./handler50.js"),"aiDiscoverHelpExecute"),name:"discover-help",options:jx}),Ix={"dry-run":{defaultValue:!1,description:"Show the proposal and exit without applying or posting it",type:Boolean},"no-cache":{defaultValue:!1,description:"Bypass the AI response cache",type:Boolean},run:{description:"Use a specific run ID from .vis/runs/ instead of the latest run",type:String},"validation-timeout":{description:"Per-task validation timeout in seconds (default: 1800)",type:Number}},Ax=R({commandPath:["ai"],description:"Diagnose the most recent failed task and post a structured patch as a PR/MR comment (or Buildkite annotation)",examples:[["vis ai heal","Heal the most recent failure"],["vis ai heal --dry-run","Propose a patch but skip apply / validate / post"],["vis ai heal --run 2026-04-28T...","Heal a specific historical run"]],group:"System",loader:G(()=>import("./heal.js").then(e=>e.h),"aiHeal"),name:"heal",options:Ix}),Px={run:{description:"Use a specific run ID from .vis/runs/ instead of the latest run",type:String},"validation-timeout":{description:"Per-task validation timeout in seconds (default: 1800)",type:Number}},Bx=R({commandPath:["ai","heal"],description:"Re-run the proposed fix and commit it to the PR/MR branch when validation passes",examples:[["vis ai heal accept","Triggered automatically by a `/vis heal accept` PR comment (GitHub/GitLab) or a Buildkite block-step unblock"]],group:"System",loader:G(()=>import("./heal-accept.js"),"aiHealAccept"),name:"accept",options:Px}),ap=[Ox,Tx,xx,Ex,Cx,Ax,Bx],E4=Object.defineProperty({__proto__:null,default:ap},Symbol.toStringTag,{value:"Module"}),Nx={"ai-type":{description:"AI analysis type: impact, security, compatibility, or recommend (default: impact)",type:String},format:{description:"Output format: table or json (default: table)",type:String},security:{defaultValue:!1,description:"Check for known security vulnerabilities",type:Boolean}},Dx=R({argument:{description:"Package name to analyze (e.g., react)",name:"package",required:!0,type:String},description:"Analyze a single package update with AI",examples:[["vis analyze react","Analyze updating react to latest"],["vis analyze react 19.0.0","Analyze updating react to specific version"],["vis analyze react --ai-type security","Run security-focused analysis"],["vis analyze react --format json","Output as JSON"]],group:"System",loader:()=>import("./handler4.js"),name:"analyze",options:Nx}),Lx={all:{defaultValue:!1,description:"Approve all pending builds without prompting (pnpm only)",type:Boolean},scan:{defaultValue:!1,description:"Force vis scanning even for pnpm (instead of delegating)",type:Boolean},"sync-native":{defaultValue:!1,description:"Sync allowBuilds to native PM config (bun: trustedDependencies, npm: .npmrc, yarn: .yarnrc.yml)",type:Boolean},write:{defaultValue:!1,description:"Write unapproved entries directly into vis.config.ts security.policies.installScripts.allow (LavaMoat 'auto' parity)",type:Boolean}},Mx=R({description:"Review and approve dependencies with build scripts",examples:[["vis approve-builds","Scan and list unapproved build scripts"],["vis approve-builds --all","Approve all pending builds (pnpm)"],["vis approve-builds --write","Write unapproved entries into vis.config.ts security.policies.installScripts.allow"],["vis approve-builds --sync-native","Sync allowBuilds to native PM config"]],group:"Security & Health",loader:()=>import("./handler51.js"),name:"approve-builds",options:Lx}),cp={description:"Output format: table, json, or ndjson (default: table). json/ndjson go to stdout, logs to stderr.",name:"format",type:String},_x={commandPath:["attest"],description:"Verify inbound provenance + registry signatures across the locked dependency graph and gate on regressions",examples:[["vis attest verify","Check every locked dep for provenance regressions and signature problems"],["vis attest verify --prod-only","Skip devDependencies"],["vis attest verify --format json","Machine-readable findings for CI (Axis A)"],["vis attest verify --fail-on error","Exit non-zero only on error-severity findings (default: any finding)"]],group:"Security & Health",loader:G(()=>import("./handler5.js"),"attestVerifyExecute"),name:"verify",options:[cp,{defaultValue:!1,description:"Skip devDependencies — verify the production graph only.",name:"prod-only",type:Boolean},{description:"Severity that triggers a non-zero exit: 'warning' (any finding, default) or 'error'.",name:"fail-on",type:String},{description:"Comma-separated package names to exclude from both marshalls.",name:"allowlist",type:String}]},Fx={argument:{description:"Path to the built artifact to attest (e.g. dist/app.tgz). Its sha256 becomes the in-toto subject digest.",name:"subject",type:String},description:"Build an in-toto SLSA v1 provenance statement for an artifact and keyless-sign it via Sigstore",examples:[["vis attest dist/app.tgz","Emit dist/app.tgz.sigstore (keyless-signed in CI)"],["vis attest dist/app.tgz --output attest.sigstore","Write the bundle to a specific path"],["vis attest dist/app.tgz --predicate slsaProvenance","Predicate type (default: slsaProvenance)"],["vis attest dist/app.tgz --require-signing","Fail instead of skip-with-warn when no ambient OIDC (outside CI)"],["vis attest dist/app.tgz --format json","Print the signed bundle summary as JSON (Axis A)"]],group:"Security & Health",loader:G(()=>import("./handler5.js"),"attestEmitExecute"),name:"attest",options:[cp,{description:"Write the serialized Sigstore bundle here (default: <subject>.sigstore).",name:"output",type:String},{description:"Predicate type: 'slsaProvenance' (default, https://slsa.dev/provenance/v1).",name:"predicate",type:String},{defaultValue:!1,description:"Error instead of skip-with-warn when no ambient OIDC token is available (i.e. outside CI).",name:"require-signing",type:Boolean}]},Vx=[Fx,_x],Wx={"allow-major":{defaultValue:!1,description:"Allow --fix to bump a direct dep across a major version when the lowest fix is outside the existing range",type:Boolean},backend:{description:"Audit backend: 'auto' (default, delegates to 'aube audit' when aube is the installer), 'aube' (force delegate), or 'vis' (always use vis's OSV/Socket scanner).",type:String},db:{description:"Override the offline advisory DB path (default: <cache>/vis/advisories/db.sqlite).",type:String},ecosystem:{description:"Comma-separated list of OSV ecosystems to scan (default: npm). Supported: npm, pypi, crates.io (or 'cargo'), maven, go, rubygems. Non-npm ecosystems require --offline (online OSV path is npm-only).",type:String},"exit-code":{defaultValue:!1,description:"Exit with code 1 if any issues found (for CI)",type:Boolean},explain:{description:"Add a plain-English AI explanation to findings. Bare flag explains all findings at/above --severity; pass a finding index (e.g. 2) or a CVE/GHSA id to explain just one. Auto-detects an installed AI CLI; mutually exclusive with --offline.",type:String},"fail-on":{description:"Exit non-zero when any finding is at this severity or higher. One of: low, medium, high, critical.",type:String},fix:{defaultValue:!1,description:"Apply direct-dep fixes for vulnerable packages by running the active PM update command, then rescan",type:Boolean},"fix-transitive":{defaultValue:!1,description:"Apply transitive fixes by writing PM-specific overrides (pnpm-workspace.yaml / package.json overrides / resolutions)",type:Boolean},format:{description:"Output format: table, json, sarif, csaf, cyclonedx-vex, gitlab, or junit (default: table)",type:String},offline:{defaultValue:!1,description:"Query the local OSV advisory cache only — no network calls. Errors if the cache is missing.",type:Boolean},policies:{description:"Comma-separated list of supply-chain policies to evaluate (default: every configured policy). Use 'none' to skip the engine entirely, 'all' to force the full set. Known: malware, firstSeen, unexpectedDeps, publisherChange, installScripts, score, vulnerability, license.",type:String},"prod-only":{defaultValue:!1,description:"Skip devDependencies — scan production graph only.",type:Boolean},report:{description:"Write a self-contained HTML report to this path. Auto-opens in a TTY when not in CI.",type:String},severity:{description:"Minimum severity to report: low, medium, high, critical (default: low)",type:String},"show-accepted":{defaultValue:!1,description:"Include acknowledged (accepted risk) issues in output",type:Boolean},"show-fixes":{defaultValue:!1,description:"Print fix-suggestion lines for each finding (no apply, no rescan)",type:Boolean},sync:{defaultValue:!1,description:"Sync vis accepted risks to native PM config (pnpm-workspace.yaml / .yarnrc.yml)",type:Boolean},...fe({description:"Only report vulnerabilities in statically-imported packages (reachability filter).",name:"usage",type:Boolean}),yes:{defaultValue:!1,description:"Skip confirmation prompt for --fix / --fix-transitive (required in CI)",type:Boolean}},Hx=R({description:"Audit installed packages for vulnerabilities and supply chain risks",examples:[["vis audit","Full audit of all installed packages"],["vis audit --severity high","Show only high/critical issues"],["vis audit --format json","Output as JSON for CI integration"],["vis audit --format sarif","Output SARIF 2.1.0 for code-scanning uploads"],["vis audit --format csaf","Output CSAF 2.0 csaf_vex for enterprise vuln pipelines"],["vis audit --format cyclonedx-vex","Output a CycloneDX 1.7 BOM with vulnerabilities[] (SBOM + VEX)"],["vis audit --format gitlab","Output a GitLab dependency-scanning report (gl-dependency-scanning.json)"],["vis audit --format junit","Output a Surefire-compatible JUnit XML report"],["vis audit --report report.html","Write a self-contained HTML report to ./report.html"],["vis audit --usage","Only report vulnerabilities in statically-imported packages"],["vis audit --offline","Query the local OSV cache only (no network)"],["vis audit --offline --db ./vendor.sqlite","Use a specific advisory DB"],["vis audit --ecosystem npm,pypi","Scan multiple OSV ecosystems (npm, pypi, crates.io, maven, go, rubygems)"],["vis audit --prod-only","Skip devDependencies"],["vis audit --fail-on high","Exit non-zero on any high or critical finding"],["vis audit --show-fixes","Print fix-suggestion lines (no apply, no rescan)"],["vis audit --fix","Apply direct-dep upgrades for vulnerable packages, then rescan (dry-run preview by default)"],["vis audit --fix --yes","Skip the confirmation prompt and run the upgrades immediately"],["vis audit --fix --allow-major","Permit major-version bumps when the lowest fix is outside the existing range"],["vis audit --fix-transitive","Write PM-specific overrides for vulnerable transitives (dry-run preview by default)"],["vis audit --exit-code","Exit with code 1 if issues found (for CI)"],["vis audit --show-accepted","Include acknowledged risks in output"],["vis audit --sync","Sync accepted risks to native PM config (pnpm-workspace.yaml / .yarnrc.yml)"],["vis audit --policies license,vulnerability","Run only the named policies (default: every configured policy)"],["vis audit --policies none","Skip the policy engine entirely"],["vis audit --explain","Add a plain-English AI explanation under every finding (auto-detects an installed AI CLI)"],["vis audit --explain CVE-2021-23337","Explain only the finding with this CVE/GHSA id"],["vis audit --explain 2","Explain only the 2nd finding"]],group:"Security & Health",loader:()=>import("./handler72.js"),name:"audit",options:Wx}),ps={description:"Cache directory (overrides config and default). Relative paths are resolved against the workspace root.",name:"cache-dir",type:String},bi={description:"Cache scope: 'shared' (default — main worktree's cache), 'worktree' (this checkout's local cache), or 'all' (both)",name:"scope",type:String},lp={description:"Cache type: 'task' (workspace task cache), 'ai' (AI response cache), 'socket' (Socket.dev reports), 'deps-dev' (Google deps.dev reports), or 'all' (default)",name:"type",type:String},Ux={commandPath:["cache"],description:"List all cache entries",examples:[["vis cache list","List all cache entries"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Ft),"cacheListExecute"),name:"list",options:[ps,bi,{description:"Output format: table or json (default: table)",name:"format",type:String}]},Gx={commandPath:["cache"],description:"Remove cache entries (defaults to all stores: workspace task cache, AI responses, Socket.dev reports)",examples:[["vis cache clean","Remove all cache entries from every store"],["vis cache clean --type=ai","Clear only the AI response cache"],["vis cache clean --type=task","Clear only the workspace task cache"],["vis cache clean --dry-run","Preview what clean would remove"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Ft),"cacheCleanExecute"),name:"clean",options:[ps,lp,{defaultValue:!1,description:"Preview without deleting",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Skip the confirmation prompt for out-of-workspace cache directories",name:"force",type:Boolean}]},zx={commandPath:["cache"],description:"Remove old and oversized cache entries",examples:[["vis cache prune","Remove old and oversized entries"],["vis cache prune --max-age-days=3 --max-size=500MB","Prune with custom limits"],["vis cache prune --keep-last=30","Keep only the 30 most recent entries"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Ft),"cachePruneExecute"),name:"prune",options:[ps,bi,{description:"Remove entries older than N days",name:"max-age-days",type:Number},{description:"Evict oldest entries until cache is under this size (e.g. 500MB)",name:"max-size",type:String},{description:"Keep only the N most recent entries (sorted newest-first by mtime)",name:"keep-last",type:Number}]},Jx={commandPath:["cache"],description:"Print on-disk footprint and stats for one or more cache stores (task / ai / socket)",examples:[["vis cache size","Show stats for every cache store"],["vis cache size --type=ai","Show only the AI response cache (entries, size, oldest, newest)"],["vis cache size --type=task --format=json","Machine-readable task cache size"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Ft),"cacheSizeExecute"),name:"size",options:[ps,bi,lp,{description:"Output format: table or json (default: table)",name:"format",type:String}]},Bo={description:"Output format: table or json (default: table)",name:"format",type:String},dp={description:"Use a specific run ID from .vis/runs/ instead of the latest run",name:"run",type:String},qx={argument:{description:"Task ID to explain (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["cache"],description:"Explain why a task missed the cache by diffing hash inputs against the previous run",examples:[["vis cache why @myorg/app:build","Show which inputs changed since the last run"],["vis cache why @myorg/app:build --json","Machine-readable output for CI"],["vis cache why @myorg/app:build --run 2026-04-28T...","Inspect a specific historical run"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Ft),"cacheWhyExecute"),name:"why",options:[Bo,dp]},Kx={argument:{description:"Task ID to print the hash for (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["cache"],description:"Print the recorded hash and per-input hash details for a task",examples:[["vis cache hash @myorg/app:build","Show the resolved hash + contributing inputs"],["vis cache hash @myorg/app:build --json","Machine-readable output"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Ft),"cacheHashExecute"),name:"hash",options:[Bo,dp]},Yx={argument:{description:"Task ID to verify (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["cache"],description:"Verify cache restore fidelity: extract the cached entry into a tmp directory and diff each file's content, mode, and mtime against the live workspace. Exits 1 on any drift (changed content, mode, mtime) or if a cached output is missing from the workspace. With --scope=all, the first cache directory containing the task is used.",examples:[["vis cache verify @myorg/app:build","Diff cached outputs vs live workspace files"],["vis cache verify @myorg/app:build --format=json","Machine-readable diff (status: ok | drift)"],["vis cache verify @myorg/app:build --cache-dir=.alt-cache","Verify against a non-default cache directory"],["vis cache verify @myorg/app:build --scope=all","Search shared and worktree caches for the task"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Ft),"cacheVerifyExecute"),name:"verify",options:[ps,bi,Bo]},Xx={backend:{description:"Override backend selector: 'http' or 'reapi'",type:String},format:{description:"Output format: table or json (default: table)",type:String},timeout:{defaultValue:5e3,description:"Probe timeout in milliseconds (default: 5000)",type:Number},url:{description:"Override remote cache URL (otherwise read from vis.config.ts remoteCache.url, or TURBO_API env var)",type:String}},Zx=R({commandPath:["cache"],description:"Probe the configured remote cache (HTTP HEAD or REAPI Capabilities) and report reachability, latency, and negotiated capabilities",examples:[["vis cache doctor","Probe the remoteCache configured in vis.config.ts"],["vis cache doctor --url=grpcs://cache.example.com:443 --backend=reapi","Override URL/backend ad-hoc"],["vis cache doctor --json","Machine-readable output"]],group:"Workspace",loader:G(()=>import("./doctor-probe.js"),"cacheDoctorExecute"),name:"doctor",options:Xx}),Qx=[Ux,Gx,zx,Jx,qx,Kx,Yx,Zx],e$={ai:{defaultValue:!1,description:"Run AI analysis on outdated packages",type:Boolean},"ai-type":{description:"AI analysis type: impact, security, compatibility, or recommend",type:String},dev:{alias:"D",conflicts:"prod",description:"Check only devDependencies (npm/yarn mode)",type:Boolean},exclude:{description:"Glob pattern to exclude packages (repeatable)",lazyMultiple:!0,type:String},"exit-code":{defaultValue:!1,description:"Exit with code 1 if outdated dependencies found (for CI)",type:Boolean},format:{description:"Output format: table, json, or minimal (default: table)",type:String},include:{description:"Glob pattern to include packages (repeatable)",lazyMultiple:!0,type:String},"include-internal":{defaultValue:!1,description:"Also check workspace-owned package names against the registry",type:Boolean},"no-security":{defaultValue:!1,description:"Skip security vulnerability scanning",type:Boolean},peer:{defaultValue:!1,description:"Include peerDependencies in outdated checks",type:Boolean},prerelease:{defaultValue:!1,description:"Include prerelease versions",type:Boolean},prod:{alias:"P",conflicts:"dev",description:"Check only dependencies (npm/yarn mode)",type:Boolean},"security-config":{defaultValue:!1,description:"Audit supply chain security settings",type:Boolean},sync:{defaultValue:!1,description:"Sync security settings to pnpm-workspace.yaml (pnpm only, requires --security-config)",type:Boolean},target:{alias:"t",description:"Update target: latest, minor, or patch (default: latest)",type:String}},t$=R({alias:["c","outdated"],argument:{description:"Specific packages to check (checks all if omitted)",name:"packages",type:String},description:"Check for outdated dependencies, security vulnerabilities, and supply chain settings",examples:[["vis check","Check all catalog dependencies"],["vis check react","Check specific packages"],["vis check --target minor","Only show minor/patch updates"],["vis check --exclude '@types/*'","Exclude packages by pattern"],["vis check --no-security","Skip vulnerability scanning"],["vis check --security-config","Audit supply chain security settings"],["vis check --security-config --sync","Sync security config to pnpm-workspace.yaml"]],group:"Security & Health",loader:()=>import("./handler6.js"),name:"check",options:e$}),n$={...fe({defaultValue:!0,description:"Install dependencies before running targets (use --no-install to skip)",name:"install",type:Boolean}),base:{description:"Git base ref for affected detection (default: auto-detected from CI env)",type:String},downstream:{defaultValue:"deep",description:"Downstream scope: none | direct | deep",type:String},head:{description:"Git head ref for affected detection (default: HEAD)",type:String},parallel:{defaultValue:4,description:"Maximum number of parallel tasks per target",type:Number},partition:{description:'Partition tasks for distributed CI (e.g., "1/4")',type:String},query:{description:"Filter affected projects by a query (e.g. 'language=typescript && tag=lib')",type:String},"skip-toolchain":{defaultValue:!1,description:"Skip the toolchain pre-flight (no auto-install for any pinned tool: node / pnpm / yarn / npm / bun / deno / go / python / ruby / rust)",type:Boolean},upstream:{defaultValue:"none",description:"Upstream scope: none | direct | deep",type:String}},s$=R({argument:{description:"Comma-separated list of targets to run (e.g., lint,test,build)",name:"targets",type:String},description:"Run affected targets in a CI-optimized pipeline",examples:[["vis ci lint,test,build","Run lint, test, and build on affected projects"],["vis ci test --base=origin/main","Override the base ref"],["vis ci build --no-install","Skip the install step (assume deps already present)"],["vis ci build --parallel=6","Increase concurrency"]],group:"Run & Execute",loader:()=>import("./handler7.js"),name:"ci",options:n$}),i$={base:{description:"Git base ref for comparison. Defaults to CI provider env vars, then HEAD~1.",type:String},downstream:{defaultValue:"deep",description:'Downstream scope: "none", "direct", or "deep"',type:String},"exit-zero-on-build":{defaultValue:!1,description:"Exit 0 on build (normal semantics) instead of 1 (inverted Vercel/Netlify semantics)",type:Boolean},head:{defaultValue:"HEAD",description:"Git head ref for comparison",type:String},json:{defaultValue:!1,description:"Emit the decision as JSON on stdout instead of human text",type:Boolean},upstream:{defaultValue:"none",description:'Upstream scope: "none", "direct", or "deep"',type:String},verbose:{defaultValue:!1,description:"Enable verbose debug output",type:Boolean}},r$=R({argument:{description:"Project name to check (required)",name:"project",type:String},commandPath:["ci"],description:'Exit with inverted codes for CI "Ignored Build Step" gating (Vercel/Netlify)',examples:[["vis ci ignore my-app","Check if my-app is affected and decide whether to build"],["vis ci ignore my-app --base $VERCEL_GIT_PREVIOUS_SHA","Explicit base ref"],["vis ci ignore my-app --json","Emit the decision as JSON instead of text"],["vis ci ignore my-app --verbose","Print debug info about the decision path"],["vis ci ignore my-app --exit-zero-on-build","Normal exit semantics (0=build, 0=skip)"]],group:"Run & Execute",loader:()=>import("./handler52.js"),name:"ignore",options:i$}),o$={"dry-run":{defaultValue:!1,description:"Preview what would be removed without deleting",type:Boolean},"empty-packages":{alias:"e",defaultValue:!1,description:"Also remove stale workspace directories that match a workspace pattern but have no package.json",type:Boolean},lockfile:{alias:"l",defaultValue:!1,description:"Also remove lockfiles (pnpm-lock.yaml, package-lock.json, etc.)",type:Boolean}},a$=R({description:"Remove node_modules from all workspace projects",examples:[["vis clean","Remove all node_modules directories"],["vis clean --lockfile","Also remove lockfiles"],["vis clean --empty-packages","Also remove workspace directories that have no package.json"],["vis clean --dry-run","Preview what would be removed"]],group:"Workspace",loader:()=>import("./handler8.js"),name:"clean",options:o$}),c$={editor:{description:"Generate editor configs (vscode)",type:String},"git-init":{defaultValue:!1,description:"Initialize a git repository",type:Boolean},list:{defaultValue:!1,description:"Show available templates",type:Boolean},"no-interactive":{defaultValue:!1,description:"Skip interactive prompts",type:Boolean}},l$=R({argument:{description:"Template to use (e.g., vis:app, create-vite, user/repo) — omit for interactive mode",name:"template",type:String},description:"Create a new project from a template",examples:[["vis create","Interactive project scaffolding"],["vis create vis:monorepo my-workspace","Create a monorepo workspace"],["vis create vis:app my-app","Scaffold a Vite application"],["vis create vis:library my-lib","Create a TypeScript library"],["vis create vite my-app -- --template react-ts","Use create-vite with React TypeScript"],["vis create user/repo my-project","Clone a GitHub template"],["vis create --list","Show available templates"]],group:"Scaffold & Config",loader:()=>import("./handler68.js"),name:"create",options:c$}),up=(e,t,n)=>{const s=r=>Qr(r)?r:dn(e,r);if(t&&t.length>0)return s(t);if(n&&n.length>0)return s(n);const i=process.env.VIS_CACHE_DIRECTORY;return i&&i.length>0?s(i):dn(e,wl)},d$=(e,t)=>t===!1?e:yh(e)??e,Uc=(e,t,n,s)=>{const i=t??n??process.env.VIS_CACHE_DIRECTORY;if(i&&i.length>0)return up(e,t,n);const r=d$(e,s);return dn(r,wl)},u$=/[^\w.-]+/g,p$=/^-+|-+$/g,f$=e=>e.trim().replaceAll(u$,"-").replaceAll(p$,"").slice(0,64),h$=e=>{try{const t=Qf("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return!t||t==="HEAD"?void 0:t}catch{return}},C4=(e,t,n)=>{if(n!==!0)return e;const s=h$(t);if(!s)return e;const i=f$(s);return i.length===0?e:dn(e,"branches",i)},g$=(e,t)=>{const n=rs(t,e);return n.length===0?!1:n!==".."&&!n.startsWith("../")&&!Qr(n)},m$="x-hono-already-sent";var Me=class extends Error{constructor(e,t){super(e,t),this.name="RequestError"}};const y$=/^\/[!#$&-;=?-\[\]_a-z~]*$/,v$=/\/\.\.?(?:[/?#]|$)/,b$=/^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/,w$=(e,t,n)=>{const s=`${e}://${t}${n}`;if(b$.test(t)){if(n.length===0)return s+"/";if(n.charCodeAt(0)!==47)throw new Me("Invalid URL");return!y$.test(n)||v$.test(n)?new URL(s).href:s}else{const i=new URL(s);if(i.hostname.length!==t.length&&i.hostname!==(t.includes(":")?t.replace(/:\d+$/,""):t).toLowerCase())throw new Me("Invalid host header");return i.href}},k$=e=>e instanceof Me?e:new Me(e.message,{cause:e}),S$=global.Request;var fn=class extends S${constructor(e,t){if(typeof e=="object"&&lt in e){const n=t!==void 0&&"body"in t&&t.body!=null;if(e[qe]&&!n)throw new TypeError("Cannot construct a Request with a Request object that has already been used.");e=e[lt]()}typeof t?.body?.getReader<"u"&&(t.duplex??="half"),super(e,t)}};const pp=e=>{const t=[],n=e.rawHeaders;for(let s=0,i=n.length;s<i;s+=2){const r=n[s];r.charCodeAt(0)!==58&&t.push([r,n[s+1]])}return new Headers(t)},fp=Symbol("wrapBodyStream"),x$=new Set(["latin1","binary","hex","base64","base64url"]),$$=e=>e===null||x$.has(e),er=Symbol("bodyBufferedBeforeDisconnect"),Fr=Symbol("bodyBufferedLengthBeforeDisconnect"),hp=(e,t)=>Buffer.isBuffer(e)?e:Buffer.from(e,t??"utf8"),No=e=>!(e instanceof rn)&&!!e.complete&&!!e.readableAborted&&typeof e.read=="function"&&$$(e.readableEncoding),Gc=e=>{if(e.readableDidRead||!No(e))return;const t=e;t[Fr]??=e.readableLength},Ys=(e,t)=>{if(e.readableDidRead&&!t||!No(e))return;const n=e;if(n[er]!==void 0)return n[er];let s;const i=e.errored;if(i&&i.code!=="ECONNRESET")s=i;else if(n[Fr]!==void 0&&e.readableLength!==n[Fr])s=Xs();else{const r=t??[],o=e.read();o!==null&&r.push(hp(o,e.readableEncoding));const a=r.length===1?r[0]:Buffer.concat(r);s=a;const c=e.headers["content-length"];if(typeof c=="string"&&/^\d+$/.test(c)){const l=Number(c);Number.isSafeInteger(l)&&a.length!==l&&(s=Xs())}}return n[er]=s,s},zc=(e,t)=>{if(t instanceof Error){e.error(t);return}t.length>0&&e.enqueue(t),e.close()},E$=(e,t,n,s,i)=>{const r={method:e,headers:n,signal:i.signal};if(e==="TRACE"){r.method="GET";const o=new fn(t,r);return Object.defineProperty(o,"method",{get(){return"TRACE"}}),o}if(!(e==="GET"||e==="HEAD"))if("rawBody"in s&&s.rawBody instanceof Buffer)r.body=new ReadableStream({start(o){o.enqueue(s.rawBody),o.close()}});else if(s[fp]){let o;r.body=new ReadableStream({async pull(a){try{if(!o){const d=Ys(s);if(d!==void 0){zc(a,d);return}}o||=sa.toWeb(s).getReader();const{done:c,value:l}=await o.read();c?a.close():a.enqueue(l)}catch(c){a.error(c)}}})}else{const o=Ys(s);o!==void 0?r.body=new ReadableStream({start(a){zc(a,o)}}):r.body=sa.toWeb(s)}return new fn(t,r)},lt=Symbol("getRequestCache"),Ge=Symbol("requestCache"),hn=Symbol("incomingKey"),zn=Symbol("urlKey"),gp=Symbol("methodKey"),mp=Symbol("headersKey"),jn=Symbol("abortControllerKey"),Vr=Symbol("getAbortController"),Wr=Symbol("abortRequest"),it=Symbol("bodyBuffer"),Rs=Symbol("bodyReadPromise"),qe=Symbol("bodyConsumedDirectly"),Jc=Symbol("bodyLockReader"),Fn=Symbol("abortReason"),Xs=()=>new TypeError("Body is unusable"),fs=()=>Promise.reject(Xs()),C$=new TextDecoder,R$=e=>{if(e[qe])return fs();e[qe]=!0},O$=e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),j$=e=>(e[mp]||=pp(e[hn])).get("content-type")||"",T$=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,I$=e=>{if(typeof e!="string"||e.length===0)return"GET";switch(e){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"PATCH":case"POST":case"PUT":case"QUERY":return e}const t=e.toUpperCase();switch(t){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"POST":case"PUT":return t;default:return e}},A$=e=>{if(!T$.test(e))return new TypeError(`'${e}' is not a valid HTTP method.`);const t=e.toUpperCase();if(t==="CONNECT"||t==="TRACK"||t==="TRACE"&&e!=="TRACE")return new TypeError(`'${e}' HTTP method is unsupported.`)},Do=(e,t,n)=>{if(e[qe])return fs();const s=e.method;if(s==="GET"||s==="HEAD")return e[lt]()[t]();const i=A$(s);if(i)return Promise.reject(i);if(e[Ge]&&s!=="TRACE")return e[Ge][t]();const r=R$(e);if(r)return r;const o=P$(e);if(o){const a=Promise.resolve(n(o,e));return e[it]=void 0,a}return B$(e).then(a=>{const c=n(a,e);return e[it]=void 0,c})},P$=e=>{const t=e[hn];if("rawBody"in t&&t.rawBody instanceof Buffer)return t.rawBody},qc=(e,t)=>{if(t.errored)return t.errored;const n=e[Fn];return n!==void 0?n instanceof Error?n:new Error(String(n)):new Error("Client connection prematurely closed.")},B$=e=>{if(e[it])return Promise.resolve(e[it]);if(e[Rs])return e[Rs];const t=e[hn];if(t.readableDidRead)return fs();const n=Ys(t);if(n!==void 0)return n instanceof Error?Promise.reject(n):(e[it]=n,Promise.resolve(n));const s=new Promise((i,r)=>{const o=[];let a=!1;const c=g=>{a||(a=!0,h(),g())},l=g=>{const y=t.errored??g;return!No(t)||y&&y.code!=="ECONNRESET"?!1:(c(()=>{const x=Ys(t,o);x instanceof Error?r(x):x===void 0?r(g??qc(e,t)):(e[it]=x,i(x))}),!0)},d=g=>{o.push(hp(g,t.readableEncoding))},u=()=>{c(()=>{const g=o.length===1?o[0]:Buffer.concat(o);e[it]=g,i(g)})},p=g=>{l(g)||c(()=>{r(g)})},f=()=>{if(t.readableEnded){u();return}l()||c(()=>{r(qc(e,t))})},h=()=>{t.off("data",d),t.off("end",u),t.off("error",p),t.off("close",f),e[Rs]=void 0};t.on("data",d),t.on("end",u),t.on("error",p),t.on("close",f),queueMicrotask(()=>{a||(t.readableEnded?u():t.errored?p(t.errored):t.destroyed&&f())})});return e[Rs]=s,s},Ve={get method(){return this[gp]},get url(){return this[zn]},get headers(){return this[mp]||=pp(this[hn])},[Wr](e){this[Fn]===void 0&&(this[Fn]=e);const t=this[jn];t&&!t.signal.aborted&&t.abort(e)},[Vr](){return this[jn]||=new AbortController,this[Fn]!==void 0&&!this[jn].signal.aborted&&this[jn].abort(this[Fn]),this[jn]},[lt](){const e=this[Vr]();if(this[Ge])return this[Ge];const t=this.method;if(this[qe]&&!(t==="GET"||t==="HEAD")){this[it]=void 0;const n={method:t==="TRACE"?"GET":t,headers:this.headers,signal:e.signal};t!=="TRACE"&&(n.body=new ReadableStream({start(i){i.close()}}),n.duplex="half");const s=new fn(this[zn],n);return t==="TRACE"&&Object.defineProperty(s,"method",{get(){return"TRACE"}}),this[Ge]=s}return this[Ge]=E$(this.method,this[zn],this.headers,this[hn],e)},get body(){if(!this[qe])return this[lt]().body;const e=this[lt]();return!this[Jc]&&e.body&&(this[Jc]=e.body.getReader()),e.body},get bodyUsed(){return this[qe]?!0:this[Ge]?this[Ge].bodyUsed:!1}};Object.defineProperty(Ve,"signal",{get(){return this[Vr]().signal}});["cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","keepalive"].forEach(e=>{Object.defineProperty(Ve,e,{get(){return this[lt]()[e]}})});["clone","formData"].forEach(e=>{Object.defineProperty(Ve,e,{value:function(){if(this[qe]){if(e==="clone")throw Xs();return fs()}return this[lt]()[e]()}})});Object.defineProperty(Ve,"text",{value:function(){return Do(this,"text",e=>C$.decode(e))}});Object.defineProperty(Ve,"arrayBuffer",{value:function(){return Do(this,"arrayBuffer",e=>O$(e))}});Object.defineProperty(Ve,"blob",{value:function(){return Do(this,"blob",(e,t)=>{const n=j$(t),s=n?{headers:{"content-type":n}}:void 0;return new Response(e,s).blob()})}});Object.defineProperty(Ve,"json",{value:function(){return this[qe]?fs():this.text().then(JSON.parse)}});Object.defineProperty(Ve,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,n){return`Request (lightweight) ${n({method:this.method,url:this.url,headers:this.headers,nativeRequest:this[Ge]},{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(Ve,fn.prototype);const N$=(e,t)=>{const n=Object.create(Ve);n[hn]=e,n[gp]=I$(e.method);const s=e.url||"";if(s[0]!=="/"&&(s.startsWith("http://")||s.startsWith("https://"))){if(e instanceof rn)throw new Me("Absolute URL for :path is not allowed in HTTP/2");try{n[zn]=new URL(s).href}catch(o){throw new Me("Invalid absolute URL",{cause:o})}return n}const i=(e instanceof rn?e.authority:e.headers.host)||t;if(!i)throw new Me("Missing host header");let r;if(e instanceof rn){if(r=e.scheme,!(r==="http"||r==="https"))throw new Me("Unsupported scheme")}else r=e.socket&&e.socket.encrypted?"https":"http";try{n[zn]=w$(r,i,s)}catch(o){throw o instanceof Me?o:new Me("Invalid URL",{cause:o})}return n},nt="text/plain; charset=UTF-8",Hr=Symbol("responseCache"),tn=Symbol("getResponseCache"),Je=Symbol("cache"),Zs=global.Response;var Fe=class yp{#e;#t;[tn](){const t=this[Je],n=t&&t[2]instanceof Headers?t[2]:void 0;return delete this[Je],this[Hr]||=new Zs(this.#e,n?{status:this.#t?.status,statusText:this.#t?.statusText,headers:n}:this.#t)}constructor(t,n){let s;if(this.#e=t,n instanceof Zs){const i=n[Hr];if(i){this.#t=i,this[tn]();return}this.#t=n instanceof yp?n.#t:n,s=new Headers(n.headers)}else this.#t=n;(t==null||typeof t=="string"||typeof t?.getReader<"u"||t instanceof Blob||t instanceof Uint8Array)&&(this[Je]=[n?.status||200,t??null,s||n?.headers])}get headers(){const t=this[Je];return t?(t[2]instanceof Headers||(t[2]=new Headers(t[2]||(t[1]===null?void 0:{"content-type":nt}))),t[2]):this[tn]().headers}get status(){return this[Je]?.[0]??this[tn]().status}get ok(){const t=this.status;return t>=200&&t<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(Fe.prototype,e,{get(){return this[tn]()[e]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(Fe.prototype,e,{value:function(){return this[tn]()[e]()}})});Object.defineProperty(Fe.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,n){return`Response (lightweight) ${n({status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[Hr]},{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(Fe,Zs);Object.setPrototypeOf(Fe.prototype,Zs.prototype);const D$=/^https?:\/\/[!#-;=?-[\]_a-z~A-Z]+$/,L$=e=>e instanceof URL?e.href:D$.test(e)?e:new URL(e).href,M$=new Set([301,302,303,307,308]);Object.defineProperty(Fe,"redirect",{value:function(t,n=302){if(!M$.has(n))throw new RangeError("Invalid status code");return new Fe(null,{status:n,headers:{location:L$(t)}})},writable:!0,configurable:!0});Object.defineProperty(Fe,"json",{value:function(t,n){const s=JSON.stringify(t);if(s===void 0)throw new TypeError("The data is not JSON serializable");const i=n?.headers;let r;return i?(r=new Headers(i),r.has("content-type")||r.set("content-type","application/json")):r={"content-type":"application/json"},new Fe(s,{status:n?.status??200,statusText:n?.statusText,headers:r})},writable:!0,configurable:!0});async function _$(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function vp(e,t,n){const s=a=>{e.cancel(a).catch(()=>{})};return t.on("close",s),t.on("error",s),(n??e.read()).then(o,i),e.closed.finally(()=>{t.off("close",s),t.off("error",s)});function i(a){a&&t.destroy(a)}function r(){e.read().then(o,i)}function o({done:a,value:c}){try{if(a)t.end();else if(!t.write(c))t.once("drain",r);else return e.read().then(o,i)}catch(l){i(l)}}}function Kc(e,t){if(e.locked)throw new TypeError("ReadableStream is locked.");return t.destroyed?void 0:vp(e.getReader(),t)}const Ur=(e,t)=>{const n={};if(e instanceof Headers||(e=new Headers(e??void 0)),e.has("set-cookie")){const s=[];for(const[i,r]of e)i==="set-cookie"?s.push(r):n[i]=r;s.length>0&&(n["set-cookie"]=s)}else for(const[s,i]of e)n[s]=i;return t&&(n["content-type"]??=t),n},Qs=Symbol("outgoingEnded"),Yc=Symbol("incomingDraining"),F$=500,V$=64*1024*1024,bp=e=>{const t=e;if(e.destroyed||t[Yc])return;if(t[Yc]=!0,e instanceof rn){try{e.stream?.close?.($h.NGHTTP2_NO_ERROR)}catch{}return}let n=0;const s=()=>{clearTimeout(r),e.off("data",o),e.off("end",s),e.off("error",s)},i=()=>{s();const a=e.socket;a&&!a.destroyed&&(typeof a.destroySoon=="function"?a.destroySoon():typeof a.destroy=="function"&&a.destroy())},r=setTimeout(i,F$);r.unref?.();const o=a=>{n+=a.length,n>V$&&i()};e.on("data",o),e.on("end",s),e.on("error",s),e.resume()},W$=(e,t,n,s)=>()=>{t.errored?(Gc(t),e[Wr](t.errored.toString())):n.writableFinished||(Gc(t),e[Wr]("Client connection prematurely closed.")),s&&!t.readableEnded&&setTimeout(()=>{t.readableEnded||setTimeout(()=>{bp(t)})})},H$=e=>{if(!(Je in e))return!1;const t=e[Je][1];return t===null||typeof t=="string"||t instanceof Uint8Array},U$=()=>new Response(null,{status:400}),wp=e=>new Response(null,{status:e instanceof Error&&(e.name==="TimeoutError"||e.constructor.name==="TimeoutError")?504:500}),ei=(e,t)=>{const n=e instanceof Error?e:new Error("unknown error",{cause:e});n.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(e),t.headersSent||t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`Error: ${n.message}`),t.destroy(n))},Gr=e=>{"flushHeaders"in e&&e.writable&&e.flushHeaders()},kp=async(e,t)=>{let[n,s,i]=e[Je];if(!i){s===null?(t.writeHead(n),t.end()):typeof s=="string"?(t.writeHead(n,{"Content-Type":nt,"Content-Length":Buffer.byteLength(s)}),t.end(s)):s instanceof Uint8Array?(t.writeHead(n,{"Content-Type":nt,"Content-Length":s.byteLength}),t.end(s)):s instanceof Blob?(t.writeHead(n,{"Content-Type":nt,"Content-Length":s.size}),t.end(new Uint8Array(await s.arrayBuffer()))):(t.writeHead(n,{"Content-Type":nt}),Gr(t),await Kc(s,t)?.catch(o=>ei(o,t))),t[Qs]?.();return}let r=!1;if(i instanceof Headers)r=i.has("content-length"),i=Ur(i,s===null?void 0:nt);else if(Array.isArray(i)){const o=new Headers(i);r=o.has("content-length"),i=Ur(o,s===null?void 0:nt)}else for(const o in i)if(o.length===14&&o.toLowerCase()==="content-length"){r=!0;break}r||(typeof s=="string"?i["Content-Length"]=Buffer.byteLength(s):s instanceof Uint8Array?i["Content-Length"]=s.byteLength:s instanceof Blob&&(i["Content-Length"]=s.size)),t.writeHead(n,i),s==null?t.end():typeof s=="string"||s instanceof Uint8Array?t.end(s):s instanceof Blob?t.end(new Uint8Array(await s.arrayBuffer())):(Gr(t),await Kc(s,t)?.catch(o=>ei(o,t))),t[Qs]?.()},Sp=e=>typeof e.then=="function",G$=async(e,t,n={})=>{if(Sp(e))if(n.errorHandler)try{e=await e}catch(i){const r=await n.errorHandler(i);if(!r)return;e=r}else e=await e.catch(wp);if(Je in e)return kp(e,t);const s=Ur(e.headers,e.body===null?void 0:nt);if(e.body){const i=e.body.getReader(),r=[];let o=!1,a;if(s["transfer-encoding"]!=="chunked"){let c=2;for(let l=0;l<c;l++){a||=i.read();const d=await _$(a).catch(u=>{console.error(u),o=!0});if(!d){if(l===1){await new Promise(u=>setTimeout(u)),c=3;continue}break}if(a=void 0,d.value&&r.push(d.value),d.done){o=!0;break}}o&&!("content-length"in s)&&(s["content-length"]=r.reduce((l,d)=>l+d.length,0))}t.writeHead(e.status,s),r.forEach(c=>{t.write(c)}),o?t.end():(r.length===0&&Gr(t),await vp(i,t,a))}else s[m$]||(t.writeHead(e.status,s),t.end());t[Qs]?.()},z$=(e,t={})=>{const n=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==fn&&(Object.defineProperty(global,"Request",{value:fn}),Object.defineProperty(global,"Response",{value:Fe})),async(s,i)=>{let r,o,a=!1,c=!1;const l=()=>{!o||c||(c=!0,i.on("close",W$(o,s,i,a)))};try{if(o=N$(s,t.hostname),a=n&&!(s.method==="GET"||s.method==="HEAD"),a&&(s[fp]=!0,s instanceof rn&&(i[Qs]=()=>{s.readableEnded||setTimeout(()=>{s.readableEnded||setTimeout(()=>{s.destroy(),i.destroy()})})})),r=e(o,{incoming:s,outgoing:i}),!Sp(r)&&H$(r))return a&&!s.readableEnded&&i.once("finish",()=>{s.readableEnded||bp(s)}),kp(r,i);l()}catch(d){if(r)return ei(d,i);if(t.errorHandler){if(l(),r=await t.errorHandler(o?d:k$(d)),!r)return}else o?r=wp(d):r=U$()}try{return await G$(r,i,t)}catch(d){return ei(d,i)}}},J$=Symbol("CONNECTION_SYMBOL_KEY"),q$=Symbol("WAIT_FOR_WEBSOCKET_SYMBOL"),K$=new Set(["connection","content-length","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade","sec-websocket-accept","sec-websocket-extensions","sec-websocket-protocol"]),xp=(e,t)=>{t&&t.forEach((n,s)=>{K$.has(s.toLowerCase())||e.push(`${s}: ${n}`)})},Xc=(e,t,n)=>{const s=["Connection: close","Content-Length: 0"];xp(s,n),e.end(`HTTP/1.1 ${t.toString()} ${xh[t]??""}\r
190
+ ${Hi(g,{...this.#i,filterStacktrace:Zi,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:S})}`),h&&C.push(`
191
+ `,S+Be(this.styles.underline.suffix?Hc(h):h)),C.join("")}_log(t,n){const s=ju(n)?"stderr":"stdout",i=s==="stderr"?this.#t:this.#e;this.#r&&this.#n!==void 0&&i.isTTY?this.#n.update(s,t.split(`
192
+ `),0):Tu(`${t}
193
+ `,i)}}const W2=()=>Gn.NODE_ENV==="debug"||Gn.DEBUG!==void 0?"debug":Gn.NODE_ENV==="test"?"warning":"informational",ip=e=>{let t=W2();return Gn.PAIL_LOG_LEVEL!==void 0&&(t=Gn.PAIL_LOG_LEVEL),new g2({logLevel:t,processors:[new P2],reporters:[new V2],stderr:To,stdout:jo,...e})};ip();const E=ip(),H2=e=>`MARSHALL_DISABLE_${e.replaceAll(/([A-Z])/g,"_$1").toUpperCase()}`,Qi=(e,t=process.env)=>na(t.MARSHALL_DISABLE_ALL)?!0:na(t[H2(e)]),rp=(e,t)=>{const n={errors:[],warnings:[]},{security:s}=e;if(!s)return n.warnings.push("No security settings configured. Use defineConfig() from '@visulima/vis/config' to get secure defaults automatically."),n;const i=s.policies??{},{installScripts:r}=i,o=r?.allow,a=o&&Object.keys(o).length>0;if(a||n.warnings.push(t==="pnpm"?"security.policies.installScripts.allow is not configured. pnpm blocks build scripts by default since v10. Run 'vis approve-builds' to review.":"security.policies.installScripts.allow is not configured. Consider listing which packages are allowed to run install/postinstall scripts."),i.firstSeen?.minutes===0&&n.warnings.push("security.policies.firstSeen.minutes is explicitly set to 0. New packages can be installed immediately after publishing."),i.publisherChange?.mode==="off"&&n.warnings.push("security.policies.publisherChange.mode is explicitly 'off'. Packages whose trust level has decreased will not be blocked."),s.blockExoticSubdeps===!1&&n.warnings.push("security.blockExoticSubdeps is explicitly disabled. Transitive dependencies can pull code from git repos or tarball URLs."),r?.strict===!1&&n.warnings.push("security.policies.installScripts.strict is explicitly disabled. Unapproved build scripts will only produce warnings, not errors."),r?.strict&&!a&&n.errors.push("security.policies.installScripts.strict is enabled but `.allow` is empty. All dependencies with build scripts will be blocked. Run 'vis approve-builds' to review and add packages."),s.acceptedRisks){const l=Date.now();for(const[d,u]of Object.entries(s.acceptedRisks)){const p=new Date(u.acceptedAt).getTime();l-p>7776e6&&n.warnings.push(`Accepted risk for "${d}" is over 90 days old (accepted ${u.acceptedAt}). Consider re-evaluating with 'vis audit'.`)}}return n},U2=(e,t,n=!1)=>{if(ut&&!process.env.VIS_SECURITY_WARNINGS)return;const s=rp(e,t);for(const r of s.errors)E.error(r);const i=n?s.warnings.filter(r=>!r.startsWith("security.policies.installScripts.allow is not configured")):s.warnings;i.length>0&&E.warn(`${i.length} security recommendation${i.length===1?"":"s"} found. Run 'vis check --security-config' for details.`)},C4=(e,t)=>{const n=rp(e,t),{security:s}=e;if(s){const i=s.policies??{},{firstSeen:r}=i,{publisherChange:o}=i,{installScripts:a}=i,{score:c}=i;if(E.info("Active security settings:"),E.info(` policies.firstSeen.minutes: ${r?.minutes??"not set"} minutes`),E.info(` policies.publisherChange.mode: ${o?.mode??"not set"}`),E.info(` policies.publisherChange.ignoreAfter: ${o?.ignoreAfter??"not set"} minutes`),E.info(` blockExoticSubdeps: ${s.blockExoticSubdeps??!1}`),E.info(` policies.installScripts.strict: ${a?.strict??!1}`),E.info(` policies.installScripts.allow: ${a?.allow?`${Object.keys(a.allow).length} entries`:"not configured"}`),E.info(""),E.info("Socket.dev integration:"),E.info(` socket.enabled: ${s.socket?.enabled??!1}`),E.info(` socket.apiToken: ${s.socket?.apiToken||process.env.VIS_SOCKET_TOKEN?"configured":"using public token"}`),E.info(` policies.score.minimum: ${c?.minimum??"default (0.4)"}`),E.info(` socket.cacheTtlMs: ${s.socket?.cacheTtlMs??"default (1 hour)"}`),E.info(` socket.timeoutMs: ${s.socket?.timeoutMs??"default (15s)"}`),s.acceptedRisks){const l=Object.entries(s.acceptedRisks);E.info(` acceptedRisks: ${String(l.length)} entr${l.length===1?"y":"ies"}`);for(const[d,u]of l)E.info(` ${d}: ${u.reason} (accepted ${u.acceptedAt.slice(0,10)})`)}else E.info(" acceptedRisks: none");E.info("")}if(n.errors.length===0&&n.warnings.length===0){E.info("All recommended security settings are configured.");return}for(const i of n.errors)E.error(i);for(const i of n.warnings)E.warn(i);E.notice(""),E.notice("Secure defaults are applied by defineConfig(). You only need to add install-script allowances:"),E.notice(""),E.notice(" import { defineConfig } from '@visulima/vis/config';"),E.notice(""),E.notice(" export default defineConfig({"),E.notice(" security: {"),E.notice(" policies: {"),E.notice(" installScripts: {"),E.notice(" allow: {"),E.notice(" esbuild: true,"),E.notice(" '@prisma/client': true,"),E.notice(" },"),E.notice(" },"),E.notice(" },"),E.notice(" },"),E.notice(" });")},R4=e=>{const{security:t}=e;if(!t)return[];const n=t.policies??{},{firstSeen:s}=n,{publisherChange:i}=n,{installScripts:r}=n,o=[];return s?.minutes!==void 0&&o.push(`minimumReleaseAge: ${s.minutes}`),i?.mode&&i.mode!=="off"&&o.push(`trustPolicy: ${i.mode}`),t.blockExoticSubdeps&&o.push("blockExoticSubdeps: true"),r?.allow&&o.push(`allowBuilds: ${Object.keys(r.allow).length} entries`),r?.strict&&o.push("strictDepBuilds: true"),i?.ignoreAfter!==void 0&&o.push(`trustPolicyIgnoreAfter: ${i.ignoreAfter}`),o},op=e=>{const t=e.trim();if(t==="")return;const n=/^(\d+(?:\.\d+)?)\s*([mhdw]?)$/i.exec(t);if(!n)return;const s=Number.parseFloat(n[1]);if(!(!Number.isFinite(s)||s<0))switch(n[2]?.toLowerCase()){case"":case"m":case void 0:return Math.round(s);case"d":return Math.round(s*1440);case"h":return Math.round(s*60);case"w":return Math.round(s*10080);default:return}},G2=e=>e.startsWith("@")||e.includes("/")||/[:#\s]/.test(e),O4=e=>G2(e)?`'${e.replaceAll("'","''")}'`:e,z2=e=>{const t=e.trim();return/^\d+$/.test(t)?Number.parseInt(t,10)*1440:op(t)},J2=(e,t)=>{const n={};try{switch(e){case"bun":{const s=m(t,"package.json");if($(s)){const r=de(s);Array.isArray(r.trustedDependencies)&&(n.allowBuilds=new Set(r.trustedDependencies))}const i=m(t,"bunfig.toml");if($(i)){const r=wh(i),o=r?.install?.minimumReleaseAge;typeof o=="number"&&(n.minReleaseAgeMinutes=Math.round(o/60)),Array.isArray(r?.install?.minimumReleaseAgeExcludes)&&(n.minReleaseAgeExcludes=new Set(r.install.minimumReleaseAgeExcludes))}break}case"npm":{const s=m(t,".npmrc");if($(s)){const i=J(s),r=/^\s*min-release-age\s*=\s*([^\s#;]+)/m.exec(i);r&&(n.minReleaseAgeMinutes=z2(r[1]))}break}case"pnpm":{const s=m(t,"pnpm-workspace.yaml");if($(s)){const i=At(s);i?.allowBuilds&&typeof i.allowBuilds=="object"?n.allowBuilds=new Set(Object.entries(i.allowBuilds).filter(([,r])=>r).map(([r])=>r)):Array.isArray(i?.onlyBuiltDependencies)&&(n.allowBuilds=new Set(i.onlyBuiltDependencies)),typeof i?.minimumReleaseAge=="number"&&(n.minReleaseAgeMinutes=i.minimumReleaseAge),Array.isArray(i?.minimumReleaseAgeExclude)&&(n.minReleaseAgeExcludes=new Set(i.minimumReleaseAgeExclude))}break}case"yarn":{const s=m(t,".yarnrc.yml");if($(s)){const i=At(s),r=i?.npmMinimalAgeGate;typeof r=="string"?n.minReleaseAgeMinutes=op(r):typeof r=="number"&&(n.minReleaseAgeMinutes=r),Array.isArray(i?.npmPreapprovedPackages)&&(n.minReleaseAgeExcludes=new Set(i.npmPreapprovedPackages))}break}default:break}}catch{}return n},q2=(e,t,n)=>{const s=J2(t,n),i={hasDrift:!1,packageManager:t},o=(e.security??{}).policies??{},{installScripts:a}=o,{firstSeen:c}=o;if(a?.allow&&(t==="pnpm"||t==="bun")){const l=new Set(Object.entries(a.allow).filter(([,f])=>f).map(([f])=>f)),d=s.allowBuilds??new Set,u=[...l].filter(f=>!d.has(f)),p=[...d].filter(f=>!l.has(f));(u.length>0||p.length>0)&&(i.allowBuilds={onlyInPm:p,onlyInVis:u},i.hasDrift=!0)}if(c?.minutes!==void 0&&!(t==="yarn"&&s.minReleaseAgeMinutes===void 0&&!$(m(n,".yarnrc.yml")))&&s.minReleaseAgeMinutes!==c.minutes&&(i.minReleaseAge={pm:s.minReleaseAgeMinutes,vis:c.minutes},i.hasDrift=!0),c?.exclude&&(t==="pnpm"||t==="bun"||t==="yarn")){const l=new Set(c.exclude),d=s.minReleaseAgeExcludes??new Set,u=[...l].filter(f=>!d.has(f)),p=[...d].filter(f=>!l.has(f));(u.length>0||p.length>0)&&(i.minReleaseAgeExcludes={onlyInPm:p,onlyInVis:u},i.hasDrift=!0)}return i},K2=e=>{if(!e.hasDrift)return[];const t=[`vis.config and ${e.packageManager}-native config disagree on security settings:`];if(e.allowBuilds&&(e.allowBuilds.onlyInVis.length>0&&t.push(` security.policies.installScripts.allow — only in vis.config: ${e.allowBuilds.onlyInVis.join(", ")}`),e.allowBuilds.onlyInPm.length>0&&t.push(` security.policies.installScripts.allow — only in ${e.packageManager} config: ${e.allowBuilds.onlyInPm.join(", ")}`)),e.minReleaseAge){const n=e.minReleaseAge.vis===void 0?"unset":`${String(e.minReleaseAge.vis)} min`,s=e.minReleaseAge.pm===void 0?"unset":`${String(e.minReleaseAge.pm)} min`;t.push(` security.policies.firstSeen.minutes — vis.config: ${n}, ${e.packageManager}: ${s}`)}return e.minReleaseAgeExcludes&&(e.minReleaseAgeExcludes.onlyInVis.length>0&&t.push(` security.policies.firstSeen.exclude — only in vis.config: ${e.minReleaseAgeExcludes.onlyInVis.join(", ")}`),e.minReleaseAgeExcludes.onlyInPm.length>0&&t.push(` security.policies.firstSeen.exclude — only in ${e.packageManager} config: ${e.minReleaseAgeExcludes.onlyInPm.join(", ")}`)),t.push(" Run 'vis security sync' to push vis.config values to the native config."),t},Y2=e=>$(m(e,".yarnrc.yml")),X2=(e,t,n)=>{const s={extraArgs:[],postInstallPackages:[],scriptsBlockedByDefault:!1,warnings:[]},i=n.security?.policies?.installScripts?.allow??{},r=Object.keys(i).length>0;switch(e){case"bun":{if(s.scriptsBlockedByDefault=!0,r){const o=m(t,"package.json");try{($(o)?de(o):{}).trustedDependencies?.length||s.warnings.push("vis security.policies.installScripts.allow is configured but trustedDependencies is empty. Run 'vis approve-builds --sync-native'.")}catch{}}break}case"npm":{s.scriptsBlockedByDefault=!1;const o=m(t,".npmrc"),a=$(o)&&/^\s*ignore-scripts\s*=\s*true\s*$/m.test(J(o));if(!a&&r?(s.warnings.push("npm does not block lifecycle scripts. vis will add --ignore-scripts automatically."),s.extraArgs.push("--ignore-scripts")):!a&&!r&&s.warnings.push("npm does not block lifecycle scripts. Add 'ignore-scripts=true' to .npmrc and configure security.policies.installScripts.allow."),r)for(const[c,l]of Object.entries(i))l&&s.postInstallPackages.push(c);break}case"pnpm":{s.scriptsBlockedByDefault=!0,r||s.warnings.push("pnpm blocks build scripts by default. Run 'vis approve-builds' to review packages that need scripts.");break}case"yarn":{if(s.scriptsBlockedByDefault=!1,Y2(t)){const o=J(m(t,".yarnrc.yml"));/^\s*enableScripts\s*:\s*false\s*$/m.test(o)?s.scriptsBlockedByDefault=!0:s.warnings.push("yarn berry supports enableScripts. Add 'enableScripts: false' to .yarnrc.yml.")}else if(s.warnings.push("yarn classic does not support blocking lifecycle scripts. Consider upgrading to yarn berry."),r){s.extraArgs.push("--ignore-scripts");for(const[o,a]of Object.entries(i))a&&s.postInstallPackages.push(o)}break}}return s},ap=(...e)=>{const t={...process.env},n=t.PATH??t.Path??"",s=e.filter(i=>i.length>0).join(ea);return t.PATH=s.length>0?n?`${s}${ea}${n}`:s:n,t},Z2=e=>{if(e.endsWith("*"))return e.endsWith("@*")?e.slice(0,-2):e;const t=e.startsWith("@"),n=e.indexOf("@",t?1:0);return n===-1?e:e.slice(0,n)},Q2=(e,t)=>{const n=m(e,"node_modules"),s=[];for(const i of t){if(!i.endsWith("*")){s.push(Z2(i));continue}const r=i.slice(0,-1);try{if(r.startsWith("@")&&r.endsWith("/")){const o=m(n,r.slice(0,-1));for(const a of we(o))!a.startsWith(".")&&Bt(m(o,a)).isDirectory()&&s.push(`${r.slice(0,-1)}/${a}`)}else for(const o of we(n))o.startsWith(r)&&Bt(m(n,o)).isDirectory()&&s.push(o)}catch{}}return s},ex=(e,t)=>{if(t.length===0)return;const n=Q2(e,t);if(n.length===0)return;const s=m(e,"node_modules"),i=m(s,".bin");let r=!1;for(const o of n){if(o.includes("..")||o.startsWith("/")||o.startsWith("\\")){E.warn(`Skipping invalid package name: ${o}`);continue}const a=(o.match(/\//g)??[]).length;if(a>1||a===1&&!o.startsWith("@")){E.warn(`Skipping invalid package name: ${o}`);continue}const c=m(s,o),l=m(c,"package.json");if($(l))try{const d=de(l).scripts??{},u=m(c,"node_modules",".bin"),p=ap(u,i);for(const f of["preinstall","install","postinstall"])if(d[f]){E.info(`Running ${f} for ${o}...`);try{const h=d[f];vl(h,{cwd:c,env:p,stdio:"inherit"})}catch{E.error(`${f} script failed for ${o}`),r=!0}}}catch{}}r&&(process.exitCode=1)},j4=(e,t=["prepublish","prepare"])=>{const n=m(e,"package.json");if(!$(n))return;let s;try{s=de(n).scripts??{}}catch{return}let i=!1;const r=ap(m(e,"node_modules",".bin"));for(const o of t){const a=s[o];if(a){E.info(`Running root ${o}...`);try{vl(a,{cwd:e,env:r,stdio:"inherit"})}catch{E.error(`Root ${o} script failed.`),i=!0}}}i&&(process.exitCode=1)},er=new Set(["add","install","update"]),tx=new Set(["add","dedupe","install","remove","update"]),nx=/(\d+\.\d+\.\d+)/,sx=e=>{const t=m(e,"package.json");if(!$(t))return[];const n=[];try{const s=de(t),i={...s.dependencies,...s.devDependencies};for(const[r,o]of Object.entries(i)){const a=m(e,"node_modules",r,"package.json");if($(a))try{const l=de(a);if(l.version){n.push({name:r,version:l.version});continue}}catch{}const c=nx.exec(o);c?.[1]&&n.push({name:r,version:c[1]})}}catch{}return n},ix={afterCommand:async e=>{if(process.exitCode&&process.exitCode!==0)return;const t=e.scriptEnforcement;t?.postInstallPackages.length&&e.workspaceRoot&&ex(e.workspaceRoot,t.postInstallPackages);const n=process.argv[2]??"",s=er.has(n)&&e.workspaceRoot?sa(e.workspaceRoot):void 0;if(s&&e.visConfig&&e.workspaceRoot&&new Set(["bun","npm","pnpm","yarn"]).has(s.name)){const r=q2(e.visConfig,s.name,e.workspaceRoot);if(r.hasDrift){E.info("");for(const o of K2(r))E.warn(o)}}if(er.has(n)&&e.workspaceRoot){const i=new Set;Qi("socket")&&i.add("socket"),Qi("depsDev")&&i.add("deps-dev");const r=e.visConfig?.security?.policies?.score?.minimum,o=Zf(e.visConfig?.security,{disabled:i,minimumScore:r});if(o.length>0)try{const a=sx(e.workspaceRoot);if(a.length>0){const c=await Qf(o,a);if(c.size>0){const l=yh(c,r);if(l){E.info(""),E.info(l);let d=0;for(const u of c.values())for(const p of u.alerts)(p.severity==="critical"||p.severity==="high")&&d++;d>0&&E.warn(`${String(d)} critical/high severity alert${d===1?"":"s"} detected. Run 'vis check --security' for details.`)}}}}catch{}}},beforeCommand:async e=>{const t=process.argv[2]??"";if(tx.has(t)&&e.visConfig&&e.workspaceRoot){const n=sa(e.workspaceRoot),s=er.has(t);if(U2(e.visConfig,n.name,s),s&&!Qi("installScripts")){const i=X2(n.name,e.workspaceRoot,e.visConfig);for(const r of i.warnings)e.logger.warn(`security: ${r}`);e.scriptEnforcement=i}}},name:"security-enforcement"};class Bo extends jf{troubleshooting;constructor(t,n,s=[]){super(t,n,{troubleshooting:s}),this.name="CompletionError",this.troubleshooting=s,s.length>0&&(this.hint=s.join(`
194
+ `))}}const _r=["bash","zsh","fish","powershell"],Fr=["node","bun","deno"],rx=e=>"Deno"in e,ox=e=>"Bun"in e,Uc=()=>rx(globalThis)?"deno":ox(globalThis)?"bun":"node",Gc=e=>{const t=e?.starshipShell??e?.shell;if(t){const i=t.toLowerCase();if(i.includes("zsh"))return"zsh";if(i.includes("bash"))return"bash";if(i.includes("fish"))return"fish"}const n=e?.psModulePath,s=e?.prompt;if(n||s?.includes("PS"))return"powershell";if(e?.comSpec?.toLowerCase().includes("cmd.exe"))return"bash"},ax=async()=>(await import("./index4.js")).default,cx=(e,t)=>{for(const n of t)n.hidden||(n.name&&e.option(n.name,n.description??""),n.alias&&e.option(n.alias,n.description??""))},lx=(e,t)=>{for(const[n,s]of t){if(s.name!==n||s.hidden)continue;const i=e.command(s.name,s.description??"");s.options&&cx(i,s.options)}},dx=e=>{if(!_r.includes(e))throw new Bo(`Invalid shell type: ${e}`,"INVALID_SHELL",[`Valid shells are: ${_r.join(", ")}`,"Shell will be auto-detected if not specified"])},ux=e=>{if(e&&!Fr.includes(e))throw new Bo(`Invalid runtime: ${e}`,"INVALID_RUNTIME",[`Valid runtimes are: ${Fr.join(", ")}`,"Runtime will be auto-detected if not specified"])},px=(e,t)=>{e.error("Could not detect current shell");const n=[`Usage: ${t} completion --shell=<bash|zsh|fish|powershell> [--runtime=<node|bun|deno>]`,"","Examples:"," # Install completions for zsh:",` ${t} completion --shell=zsh > ~/.${t}-completion.zsh`,` echo 'source ~/.${t}-completion.zsh' >> ~/.zshrc`,""," # Install completions for bash with custom runtime:",` ${t} completion --shell=bash --runtime=bun > ~/.${t}-completion.bash`,` echo 'source ~/.${t}-completion.bash' >> ~/.bashrc`,""," # Install completions for fish:",` ${t} completion --shell=fish > ~/.config/fish/completions/${t}.fish`].join(`
195
+ `);e.info(n)},fx={description:"Generate shell completion scripts",env:[{description:"Shell path (Unix-like systems). Used for shell detection.",name:"SHELL",type:String},{description:"Starship shell configuration. Takes precedence over SHELL for detection.",name:"STARSHIP_SHELL",type:String},{description:"PowerShell module path (Windows). Used for PowerShell detection.",name:"PSModulePath",type:String},{description:"Command prompt variable (Windows). Used for PowerShell detection.",name:"PROMPT",type:String},{description:"Command processor (Windows). Used for Windows Command Prompt detection.",name:"ComSpec",type:String}],execute:async({env:e,logger:t,options:n,runtime:s})=>{const i=s.getCliName(),r=n.shell??Gc(e);if(!r){px(t,i);return}try{dx(r),ux(n.runtime);const o=await ax();lx(o,s.getCommands());const a=`${n.runtime??Uc()} ${i}`;o.setup(i,a,r)}catch(o){if(o instanceof Bo){const a=[`Failed to generate completion script: ${o.message}`,`Error code: ${o.code}`];throw o.troubleshooting.length>0&&a.push("","Troubleshooting:",...o.troubleshooting.map(c=>` • ${c}`)),t.error(a.join(`
196
+ `)),o}else{const a=["Failed to generate completion script",`Error: ${o instanceof Error?o.message:String(o)}`,"","Troubleshooting:"," • Ensure @bomb.sh/tab is installed: pnpm add @bomb.sh/tab",` • Verify shell is supported: ${_r.join(", ")}`,` • Verify runtime is supported: ${Fr.join(", ")}`," • Check that your CLI name is correct"];t.error(a.join(`
197
+ `))}}},name:"completion",options:[{defaultOption:!0,defaultValue:Gc(),description:"Shell type (bash, zsh, fish, powershell). Defaults to current shell if detected.",name:"shell",type:String,typeLabel:"{underline shell}"},{defaultValue:Uc(),description:"JavaScript runtime (node, bun, deno). Defaults to current runtime if detected.",name:"runtime",type:String,typeLabel:"{underline runtime}"}]},hx={alias:["v","V"],description:"Output the version number",execute:({logger:e,runtime:t})=>{const n=t.getPackageVersion();n===void 0?(e.warn("Unknown version"),e.debug("The version number was not provided by the cli constructor.")):e.info(n)},name:"version",options:[],usage:[]},gx={json:{defaultValue:!1,description:"Emit JSON instead of ASCII",type:Boolean},projects:{alias:"p",description:"Comma-separated list of projects to plan (same semantics as `vis run --projects`)",type:String},query:{description:"Filter matched projects by a query",type:String},tag:{description:'Only plan projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…".',multiple:!0,type:String}},mx=R({argument:{description:"Target selector (same syntax as `vis run`): `build`, `:build`, `~:test`, `#tag:lint`, …",name:"selector",type:String},description:"Show the execution plan for a target without running it",examples:[["vis action-graph build","Print the task plan for `build` on every project"],["vis action-graph :test","Moon-style selector"],["vis action-graph build --json","Emit a JSON description of the plan"],['vis action-graph lint --query "tag=frontend"',"Filter projects by query"],["vis action-graph build --projects=@org/web","Plan only the named projects (same flag as `vis run`)"]],group:"Workspace",loader:()=>import("./handler2.js"),name:"action-graph",options:gx}),yx={"auto-install-peers":{defaultValue:!1,description:"After adding, recursively install non-optional peer dependencies that aren't already in the workspace (matches nypm's installPeerDependencies)",type:Boolean},exact:{alias:"E",defaultValue:!1,description:"Save exact version",type:Boolean},filter:{alias:"F",description:"Filter by workspace package name",multiple:!0,type:String},global:{alias:"g",defaultValue:!1,description:"Install globally (uses npm)",type:Boolean},"no-marshall-check":{defaultValue:!1,description:"Skip the offline marshall pipeline (author, provenance, metadata, downloads, expired-domains, new-bin, signatures, archived-repo)",type:Boolean},"no-socket-check":{defaultValue:!1,description:"Skip Socket.dev security check before adding",type:Boolean},"no-typosquat-check":{defaultValue:!1,description:"Skip typosquat name check before adding",type:Boolean},"run-scripts":{defaultValue:!1,description:"Run lifecycle scripts during add (opts out of vis's default block-by-default policy; allowlisted packages run via security.policies.installScripts.allow)",type:Boolean},"save-dev":{alias:"D",defaultValue:!1,description:"Add as dev dependency",type:Boolean},"save-optional":{alias:"O",defaultValue:!1,description:"Add as optional dependency",type:Boolean},"save-peer":{alias:"P",defaultValue:!1,description:"Add as peer dependency",type:Boolean},to:{description:"Target a single workspace package and auto-conform the version to existing catalogs / sibling deps (syncpack#285)",type:String},workspace:{defaultValue:!1,description:"Use workspace protocol (pnpm)",type:Boolean},"workspace-root":{alias:"w",defaultValue:!1,description:"Add to workspace root",type:Boolean}},vx=R({argument:{description:"Packages to add (e.g., react react-dom)",name:"packages",type:String},description:"Add packages using the detected package manager",examples:[["vis add react react-dom","Add packages"],["vis add -D typescript @types/react","Add as dev dependencies"],["vis add react --filter app","Add to specific workspace package"],["vis add react --to web","Add to one package, auto-conforming the version to existing catalogs / sibling deps"],["vis add -g typescript","Add globally (uses npm)"],["vis add lodash -w","Add to workspace root"],["vis add lodash --no-socket-check","Add without Socket.dev check"],["vis add lodash --no-typosquat-check","Skip typosquat name check"],["vis add lodash --no-marshall-check","Skip the offline marshall pipeline (author, downloads, etc.)"],["vis add lodash --run-scripts","Run lifecycle scripts (opts out of vis's default block-by-default policy)"]],group:"Dependencies",loader:()=>import("./handler15.js"),name:"add",options:yx}),Po={description:"Override the cache DB path (defaults to <cache>/vis/advisories/db.sqlite via @visulima/find-cache-dir).",name:"db",type:String},fs={description:"Output format: table (default) or json.",name:"format",type:String},bx={commandPath:["advisories"],description:"Download and ingest one or more OSV ecosystem dumps into the local cache",examples:[["vis advisories sync","Sync the npm ecosystem (default)"],["vis advisories sync --ecosystem npm","Sync a single explicit ecosystem"],["vis advisories sync --ecosystem npm,PyPI","Sync several ecosystems in one pass"],["vis advisories sync --force","Re-download even when the ETag matches"],["vis advisories sync --source https://mirror.example.com","Use a corporate OSV mirror (must be in allowedHosts)"]],group:"Security & Health",loader:G(()=>import("./sync.js"),"advisoriesSyncExecute"),name:"sync",options:[{description:"Comma-separated list of ecosystems to sync (default: npm).",name:"ecosystem",type:String},{defaultValue:!1,description:"Re-download and re-ingest even if the upstream ETag is unchanged.",name:"force",type:Boolean},{description:"Override the advisory source URL. Must be https and resolve to an allowed host.",name:"source",type:String},Po,fs]},wx={commandPath:["advisories"],description:"Print the local advisory DB summary: path, schema version, ecosystems, row counts, last sync, ETag",examples:[["vis advisories status","Human-readable summary"],["vis advisories status --format json","Machine-readable for CI freshness checks"]],group:"Security & Health",loader:G(()=>import("./status.js"),"advisoriesStatusExecute"),name:"status",options:[Po,fs]},kx={commandPath:["advisories"],description:"Delete the local advisory DB. The next `vis audit --offline` will fail until you re-sync",examples:[["vis advisories prune","Confirm and delete the local DB"],["vis advisories prune --force","Delete without confirmation"]],group:"Security & Health",loader:G(()=>import("./prune.js"),"advisoriesPruneExecute"),name:"prune",options:[Po,{defaultValue:!1,description:"Skip the confirmation prompt.",name:"force",type:Boolean},fs]},cp={description:"Override the bloom cache directory (defaults to <cache>/vis/osv-bloom/).",name:"cache-dir",type:String},Sx={commandPath:["advisories","bloom"],description:"Fetch and verify the endevco/osv-bloom MAL-* prefilter into the local cache",examples:[["vis advisories bloom sync","Fetch the bloom filter from the default upstream"],["vis advisories bloom sync --force","Re-download even when the set digest matches"],["vis advisories bloom sync --source https://bloom.example.com","Use an internal mirror (must be in allowedHosts)"]],group:"Security & Health",loader:G(()=>import("./bloom-sync.js"),"advisoriesBloomSyncExecute"),name:"sync",options:[{defaultValue:!1,description:"Re-download and re-verify even when the upstream set digest is unchanged.",name:"force",type:Boolean},{description:"Override the bloom source URL. Must be https and resolve to an allowed host.",name:"source",type:String},cp,fs]},xx={commandPath:["advisories","bloom"],description:"Print the local osv-bloom cache freshness: built-at, filter size, m/k parameters, set digest",examples:[["vis advisories bloom status","Human-readable summary"],["vis advisories bloom status --format json","Machine-readable for CI freshness checks"]],group:"Security & Health",loader:G(()=>import("./bloom-status.js"),"advisoriesBloomStatusExecute"),name:"status",options:[cp,fs]},$x=[bx,wx,kx,Sx,xx],fe=e=>{const{name:t,...n}=e;return{[`no-${t}`]:{description:`Disable --${t}.`,hidden:!0,type:Boolean},[t]:n}},Ex={base:{description:"Git base ref for comparison. When omitted, vis auto-resolves it from the active CI provider (GitHub/GitLab/Buildkite/CircleCI) or falls back to `git merge-base HEAD origin/<defaultBase>` locally. Default base branch comes from `vis.config.ts#defaultBase` (or `main`).",type:String},head:{description:"Git head ref for comparison. When omitted, auto-resolves from CI env (e.g. `$GITHUB_SHA`) or defaults to `HEAD`.",type:String},...fe({description:"Include uncommitted working-tree changes (tracked edits and untracked files) in the changed-file set. Defaults to on for local runs and off in CI; use --no-uncommitted to force off.",name:"uncommitted",type:Boolean}),downstream:{defaultValue:"deep",description:'Downstream scope: "none", "direct", or "deep" — controls how far to include dependents of changed projects',type:String},parallel:{defaultValue:3,description:"Maximum number of parallel tasks",type:Number},upstream:{defaultValue:"none",description:'Upstream scope: "none", "direct", or "deep" — controls how far to include dependencies of changed projects',type:String},...fe({defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean}),"dry-run":{defaultValue:!1,description:"Show what would run without executing",type:Boolean},partition:{description:'Partition tasks for distributed CI (e.g., "1/4" for first of four runners). Falls back to VIS_PARTITION env var.',type:String},query:{description:"Filter affected projects by a query (e.g. 'language=typescript && tag=lib')",type:String},reverse:{defaultValue:!1,description:"Run the dependency graph in reverse (leaves first, then their dependents). Useful for teardown targets like `destroy`/`undeploy` where dependents must run before the things they depend on.",type:Boolean},"runner-tags":{description:"Comma-separated tags this runner advertises (e.g. 'gpu,slow'). Forwarded verbatim to the downstream `vis run` so capability-gated tasks resolve identically. Falls back to VIS_RUNNER_TAGS env var.",type:String},"sparse-checkout":{defaultValue:!1,description:"Instead of running, print the affected project roots as a git sparse-checkout cone set (one path per line) and exit. Pipe into `git sparse-checkout set --stdin` to shrink huge-monorepo CI checkouts.",type:Boolean},tag:{description:'Only run affected projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…"; combines with --query as AND.',multiple:!0,type:String}},Cx=R({argument:{description:"The target to run (e.g., build, test, lint)",name:"target",type:String},description:"Run a target only on projects affected by recent changes",examples:[["vis affected build","Run build on affected projects"],["vis affected test --base=main","Run tests on projects changed since main"],["vis affected destroy --reverse","Tear down affected projects leaves-first"],["vis affected build --sparse-checkout","Print a git sparse-checkout cone set for the affected projects and exit"]],group:"Run & Execute",loader:()=>import("./handler3.js"),name:"affected",options:Ex}),lp={description:"Output format: table or json (default: table)",name:"format",type:String},Rx={commandPath:["ai"],description:"List detected AI providers and show which one is selected",examples:[["vis ai providers","List all AI providers and their status"],["vis ai providers --format json","Output as JSON"]],group:"System",loader:G(()=>import("./handler50.js"),"aiProvidersExecute"),name:"providers",options:[lp]},Ox={},jx=R({commandPath:["ai"],description:"Test the best available AI provider with a quick prompt",examples:[["vis ai test","Test the selected provider"]],group:"System",loader:G(()=>import("./handler50.js"),"aiTestExecute"),name:"test",options:Ox}),Tx={argument:{description:"Task ID to propose a fix for (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["ai"],description:"Read a failed task's logs and propose a structured patch (Phase 1: local-only, no git)",examples:[["vis ai fix @myorg/app:build","Print proposed patch for the failed task"],["vis ai fix @myorg/app:build --apply","Apply the patch to disk after confirming"],["vis ai fix @myorg/app:build --format json","Machine-readable patch output"],["vis ai fix @myorg/app:build --run 2026-04-28T...","Inspect a specific historical run"]],group:"System",loader:G(()=>import("./handler50.js"),"aiFixExecute"),name:"fix",options:[lp,{description:"Use a specific run ID from .vis/runs/ instead of the latest run",name:"run",type:String},{defaultValue:!1,description:"Apply the proposed patch to disk after printing it",name:"apply",type:Boolean},{defaultValue:!1,description:"Bypass the AI response cache",name:"no-cache",type:Boolean},{defaultValue:!1,description:"Skip the confirmation prompt before applying",name:"yes",type:Boolean}]},Ix={},Ax=R({description:"AI-assisted commands: provider detection and failure-fix proposals (cache management lives under `vis cache`)",examples:[["vis ai","List all AI subcommands"],["vis ai discover-help","Machine-readable subcommand catalogue (for AI agents)"]],group:"System",loader:G(()=>import("./handler50.js"),"aiRootExecute"),name:"ai",options:Ix}),Bx={},Px=R({commandPath:["ai"],description:"Print the machine-readable AI subcommand catalogue (JSON to stdout, designed for AI agents)",examples:[["vis ai discover-help","Emit the discovery payload as JSON"],["vis ai discover-help | jq '.subcommands[].path'","List all available paths"]],group:"System",loader:G(()=>import("./handler50.js"),"aiDiscoverHelpExecute"),name:"discover-help",options:Bx}),Nx={"dry-run":{defaultValue:!1,description:"Show the proposal and exit without applying or posting it",type:Boolean},"no-cache":{defaultValue:!1,description:"Bypass the AI response cache",type:Boolean},run:{description:"Use a specific run ID from .vis/runs/ instead of the latest run",type:String},"validation-timeout":{description:"Per-task validation timeout in seconds (default: 1800)",type:Number}},Dx=R({commandPath:["ai"],description:"Diagnose the most recent failed task and post a structured patch as a PR/MR comment (or Buildkite annotation)",examples:[["vis ai heal","Heal the most recent failure"],["vis ai heal --dry-run","Propose a patch but skip apply / validate / post"],["vis ai heal --run 2026-04-28T...","Heal a specific historical run"]],group:"System",loader:G(()=>import("./heal.js").then(e=>e.h),"aiHeal"),name:"heal",options:Nx}),Lx={run:{description:"Use a specific run ID from .vis/runs/ instead of the latest run",type:String},"validation-timeout":{description:"Per-task validation timeout in seconds (default: 1800)",type:Number}},Mx=R({commandPath:["ai","heal"],description:"Re-run the proposed fix and commit it to the PR/MR branch when validation passes",examples:[["vis ai heal accept","Triggered automatically by a `/vis heal accept` PR comment (GitHub/GitLab) or a Buildkite block-step unblock"]],group:"System",loader:G(()=>import("./heal-accept.js"),"aiHealAccept"),name:"accept",options:Lx}),dp=[Ax,Px,Rx,jx,Tx,Dx,Mx],T4=Object.defineProperty({__proto__:null,default:dp},Symbol.toStringTag,{value:"Module"}),_x={"ai-type":{description:"AI analysis type: impact, security, compatibility, or recommend (default: impact)",type:String},format:{description:"Output format: table or json (default: table)",type:String},security:{defaultValue:!1,description:"Check for known security vulnerabilities",type:Boolean}},Fx=R({argument:{description:"Package name to analyze (e.g., react)",name:"package",required:!0,type:String},description:"Analyze a single package update with AI",examples:[["vis analyze react","Analyze updating react to latest"],["vis analyze react 19.0.0","Analyze updating react to specific version"],["vis analyze react --ai-type security","Run security-focused analysis"],["vis analyze react --format json","Output as JSON"]],group:"System",loader:()=>import("./handler4.js"),name:"analyze",options:_x}),Vx={all:{defaultValue:!1,description:"Approve all pending builds without prompting (pnpm only)",type:Boolean},scan:{defaultValue:!1,description:"Force vis scanning even for pnpm (instead of delegating)",type:Boolean},"sync-native":{defaultValue:!1,description:"Sync allowBuilds to native PM config (bun: trustedDependencies, npm: .npmrc, yarn: .yarnrc.yml)",type:Boolean},write:{defaultValue:!1,description:"Write unapproved entries directly into vis.config.ts security.policies.installScripts.allow (LavaMoat 'auto' parity)",type:Boolean}},Wx=R({description:"Review and approve dependencies with build scripts",examples:[["vis approve-builds","Scan and list unapproved build scripts"],["vis approve-builds --all","Approve all pending builds (pnpm)"],["vis approve-builds --write","Write unapproved entries into vis.config.ts security.policies.installScripts.allow"],["vis approve-builds --sync-native","Sync allowBuilds to native PM config"]],group:"Security & Health",loader:()=>import("./handler51.js"),name:"approve-builds",options:Vx}),up={description:"Output format: table, json, or ndjson (default: table). json/ndjson go to stdout, logs to stderr.",name:"format",type:String},Hx={commandPath:["attest"],description:"Verify inbound provenance + registry signatures across the locked dependency graph and gate on regressions",examples:[["vis attest verify","Check every locked dep for provenance regressions and signature problems"],["vis attest verify --prod-only","Skip devDependencies"],["vis attest verify --format json","Machine-readable findings for CI (Axis A)"],["vis attest verify --fail-on error","Exit non-zero only on error-severity findings (default: any finding)"]],group:"Security & Health",loader:G(()=>import("./handler5.js"),"attestVerifyExecute"),name:"verify",options:[up,{defaultValue:!1,description:"Skip devDependencies — verify the production graph only.",name:"prod-only",type:Boolean},{description:"Severity that triggers a non-zero exit: 'warning' (any finding, default) or 'error'.",name:"fail-on",type:String},{description:"Comma-separated package names to exclude from both marshalls.",name:"allowlist",type:String}]},Ux={argument:{description:"Path to the built artifact to attest (e.g. dist/app.tgz). Its sha256 becomes the in-toto subject digest.",name:"subject",type:String},description:"Build an in-toto SLSA v1 provenance statement for an artifact and keyless-sign it via Sigstore",examples:[["vis attest dist/app.tgz","Emit dist/app.tgz.sigstore (keyless-signed in CI)"],["vis attest dist/app.tgz --output attest.sigstore","Write the bundle to a specific path"],["vis attest dist/app.tgz --predicate slsaProvenance","Predicate type (default: slsaProvenance)"],["vis attest dist/app.tgz --require-signing","Fail instead of skip-with-warn when no ambient OIDC (outside CI)"],["vis attest dist/app.tgz --format json","Print the signed bundle summary as JSON (Axis A)"]],group:"Security & Health",loader:G(()=>import("./handler5.js"),"attestEmitExecute"),name:"attest",options:[up,{description:"Write the serialized Sigstore bundle here (default: <subject>.sigstore).",name:"output",type:String},{description:"Predicate type: 'slsaProvenance' (default, https://slsa.dev/provenance/v1).",name:"predicate",type:String},{defaultValue:!1,description:"Error instead of skip-with-warn when no ambient OIDC token is available (i.e. outside CI).",name:"require-signing",type:Boolean}]},Gx=[Ux,Hx],zx={"allow-major":{defaultValue:!1,description:"Allow --fix to bump a direct dep across a major version when the lowest fix is outside the existing range",type:Boolean},backend:{description:"Audit backend: 'auto' (default, delegates to 'aube audit' when aube is the installer), 'aube' (force delegate), or 'vis' (always use vis's OSV/Socket scanner).",type:String},db:{description:"Override the offline advisory DB path (default: <cache>/vis/advisories/db.sqlite).",type:String},ecosystem:{description:"Comma-separated list of OSV ecosystems to scan (default: npm). Supported: npm, pypi, crates.io (or 'cargo'), maven, go, rubygems. Non-npm ecosystems require --offline (online OSV path is npm-only).",type:String},"exit-code":{defaultValue:!1,description:"Exit with code 1 if any issues found (for CI)",type:Boolean},explain:{description:"Add a plain-English AI explanation to findings. Bare flag explains all findings at/above --severity; pass a finding index (e.g. 2) or a CVE/GHSA id to explain just one. Auto-detects an installed AI CLI; mutually exclusive with --offline.",type:String},"fail-on":{description:"Exit non-zero when any finding is at this severity or higher. One of: low, medium, high, critical.",type:String},fix:{defaultValue:!1,description:"Apply direct-dep fixes for vulnerable packages by running the active PM update command, then rescan",type:Boolean},"fix-transitive":{defaultValue:!1,description:"Apply transitive fixes by writing PM-specific overrides (pnpm-workspace.yaml / package.json overrides / resolutions)",type:Boolean},format:{description:"Output format: table, json, sarif, csaf, cyclonedx-vex, gitlab, or junit (default: table)",type:String},offline:{defaultValue:!1,description:"Query the local OSV advisory cache only — no network calls. Errors if the cache is missing.",type:Boolean},policies:{description:"Comma-separated list of supply-chain policies to evaluate (default: every configured policy). Use 'none' to skip the engine entirely, 'all' to force the full set. Known: malware, firstSeen, unexpectedDeps, publisherChange, installScripts, score, vulnerability, license.",type:String},"prod-only":{defaultValue:!1,description:"Skip devDependencies — scan production graph only.",type:Boolean},report:{description:"Write a self-contained HTML report to this path. Auto-opens in a TTY when not in CI.",type:String},severity:{description:"Minimum severity to report: low, medium, high, critical (default: low)",type:String},"show-accepted":{defaultValue:!1,description:"Include acknowledged (accepted risk) issues in output",type:Boolean},"show-fixes":{defaultValue:!1,description:"Print fix-suggestion lines for each finding (no apply, no rescan)",type:Boolean},sync:{defaultValue:!1,description:"Sync vis accepted risks to native PM config (pnpm-workspace.yaml / .yarnrc.yml)",type:Boolean},...fe({description:"Only report vulnerabilities in statically-imported packages (reachability filter).",name:"usage",type:Boolean}),yes:{defaultValue:!1,description:"Skip confirmation prompt for --fix / --fix-transitive (required in CI)",type:Boolean}},Jx=R({description:"Audit installed packages for vulnerabilities and supply chain risks",examples:[["vis audit","Full audit of all installed packages"],["vis audit --severity high","Show only high/critical issues"],["vis audit --format json","Output as JSON for CI integration"],["vis audit --format sarif","Output SARIF 2.1.0 for code-scanning uploads"],["vis audit --format csaf","Output CSAF 2.0 csaf_vex for enterprise vuln pipelines"],["vis audit --format cyclonedx-vex","Output a CycloneDX 1.7 BOM with vulnerabilities[] (SBOM + VEX)"],["vis audit --format gitlab","Output a GitLab dependency-scanning report (gl-dependency-scanning.json)"],["vis audit --format junit","Output a Surefire-compatible JUnit XML report"],["vis audit --report report.html","Write a self-contained HTML report to ./report.html"],["vis audit --usage","Only report vulnerabilities in statically-imported packages"],["vis audit --offline","Query the local OSV cache only (no network)"],["vis audit --offline --db ./vendor.sqlite","Use a specific advisory DB"],["vis audit --ecosystem npm,pypi","Scan multiple OSV ecosystems (npm, pypi, crates.io, maven, go, rubygems)"],["vis audit --prod-only","Skip devDependencies"],["vis audit --fail-on high","Exit non-zero on any high or critical finding"],["vis audit --show-fixes","Print fix-suggestion lines (no apply, no rescan)"],["vis audit --fix","Apply direct-dep upgrades for vulnerable packages, then rescan (dry-run preview by default)"],["vis audit --fix --yes","Skip the confirmation prompt and run the upgrades immediately"],["vis audit --fix --allow-major","Permit major-version bumps when the lowest fix is outside the existing range"],["vis audit --fix-transitive","Write PM-specific overrides for vulnerable transitives (dry-run preview by default)"],["vis audit --exit-code","Exit with code 1 if issues found (for CI)"],["vis audit --show-accepted","Include acknowledged risks in output"],["vis audit --sync","Sync accepted risks to native PM config (pnpm-workspace.yaml / .yarnrc.yml)"],["vis audit --policies license,vulnerability","Run only the named policies (default: every configured policy)"],["vis audit --policies none","Skip the policy engine entirely"],["vis audit --explain","Add a plain-English AI explanation under every finding (auto-detects an installed AI CLI)"],["vis audit --explain CVE-2021-23337","Explain only the finding with this CVE/GHSA id"],["vis audit --explain 2","Explain only the 2nd finding"]],group:"Security & Health",loader:()=>import("./handler73.js"),name:"audit",options:zx}),hs={description:"Cache directory (overrides config and default). Relative paths are resolved against the workspace root.",name:"cache-dir",type:String},wi={description:"Cache scope: 'shared' (default — main worktree's cache), 'worktree' (this checkout's local cache), or 'all' (both)",name:"scope",type:String},pp={description:"Cache type: 'task' (workspace task cache), 'ai' (AI response cache), 'socket' (Socket.dev reports), 'deps-dev' (Google deps.dev reports), or 'all' (default)",name:"type",type:String},qx={commandPath:["cache"],description:"List all cache entries",examples:[["vis cache list","List all cache entries"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Vt),"cacheListExecute"),name:"list",options:[hs,wi,{description:"Output format: table or json (default: table)",name:"format",type:String}]},Kx={commandPath:["cache"],description:"Remove cache entries (defaults to all stores: workspace task cache, AI responses, Socket.dev reports)",examples:[["vis cache clean","Remove all cache entries from every store"],["vis cache clean --type=ai","Clear only the AI response cache"],["vis cache clean --type=task","Clear only the workspace task cache"],["vis cache clean --dry-run","Preview what clean would remove"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Vt),"cacheCleanExecute"),name:"clean",options:[hs,pp,{defaultValue:!1,description:"Preview without deleting",name:"dry-run",type:Boolean},{defaultValue:!1,description:"Skip the confirmation prompt for out-of-workspace cache directories",name:"force",type:Boolean}]},Yx={commandPath:["cache"],description:"Remove old and oversized cache entries",examples:[["vis cache prune","Remove old and oversized entries"],["vis cache prune --max-age-days=3 --max-size=500MB","Prune with custom limits"],["vis cache prune --keep-last=30","Keep only the 30 most recent entries"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Vt),"cachePruneExecute"),name:"prune",options:[hs,wi,{description:"Remove entries older than N days",name:"max-age-days",type:Number},{description:"Evict oldest entries until cache is under this size (e.g. 500MB)",name:"max-size",type:String},{description:"Keep only the N most recent entries (sorted newest-first by mtime)",name:"keep-last",type:Number}]},Xx={commandPath:["cache"],description:"Print on-disk footprint and stats for one or more cache stores (task / ai / socket)",examples:[["vis cache size","Show stats for every cache store"],["vis cache size --type=ai","Show only the AI response cache (entries, size, oldest, newest)"],["vis cache size --type=task --format=json","Machine-readable task cache size"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Vt),"cacheSizeExecute"),name:"size",options:[hs,wi,pp,{description:"Output format: table or json (default: table)",name:"format",type:String}]},No={description:"Output format: table or json (default: table)",name:"format",type:String},fp={description:"Use a specific run ID from .vis/runs/ instead of the latest run",name:"run",type:String},Zx={argument:{description:"Task ID to explain (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["cache"],description:"Explain why a task missed the cache by diffing hash inputs against the previous run",examples:[["vis cache why @myorg/app:build","Show which inputs changed since the last run"],["vis cache why @myorg/app:build --json","Machine-readable output for CI"],["vis cache why @myorg/app:build --run 2026-04-28T...","Inspect a specific historical run"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Vt),"cacheWhyExecute"),name:"why",options:[No,fp]},Qx={argument:{description:"Task ID to print the hash for (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["cache"],description:"Print the recorded hash and per-input hash details for a task",examples:[["vis cache hash @myorg/app:build","Show the resolved hash + contributing inputs"],["vis cache hash @myorg/app:build --json","Machine-readable output"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Vt),"cacheHashExecute"),name:"hash",options:[No,fp]},e$={argument:{description:"Task ID to verify (e.g. @my/app:build)",name:"taskId",type:String},commandPath:["cache"],description:"Verify cache restore fidelity: extract the cached entry into a tmp directory and diff each file's content, mode, and mtime against the live workspace. Exits 1 on any drift (changed content, mode, mtime) or if a cached output is missing from the workspace. With --scope=all, the first cache directory containing the task is used.",examples:[["vis cache verify @myorg/app:build","Diff cached outputs vs live workspace files"],["vis cache verify @myorg/app:build --format=json","Machine-readable diff (status: ok | drift)"],["vis cache verify @myorg/app:build --cache-dir=.alt-cache","Verify against a non-default cache directory"],["vis cache verify @myorg/app:build --scope=all","Search shared and worktree caches for the task"]],group:"Workspace",loader:G(()=>Promise.resolve().then(()=>Vt),"cacheVerifyExecute"),name:"verify",options:[hs,wi,No]},t$={backend:{description:"Override backend selector: 'http' or 'reapi'",type:String},format:{description:"Output format: table or json (default: table)",type:String},timeout:{defaultValue:5e3,description:"Probe timeout in milliseconds (default: 5000)",type:Number},url:{description:"Override remote cache URL (otherwise read from vis.config.ts remoteCache.url, or TURBO_API env var)",type:String}},n$=R({commandPath:["cache"],description:"Probe the configured remote cache (HTTP HEAD or REAPI Capabilities) and report reachability, latency, and negotiated capabilities",examples:[["vis cache doctor","Probe the remoteCache configured in vis.config.ts"],["vis cache doctor --url=grpcs://cache.example.com:443 --backend=reapi","Override URL/backend ad-hoc"],["vis cache doctor --json","Machine-readable output"]],group:"Workspace",loader:G(()=>import("./doctor-probe.js"),"cacheDoctorExecute"),name:"doctor",options:t$}),s$=[qx,Kx,Yx,Xx,Zx,Qx,e$,n$],i$={ai:{defaultValue:!1,description:"Run AI analysis on outdated packages",type:Boolean},"ai-type":{description:"AI analysis type: impact, security, compatibility, or recommend",type:String},dev:{alias:"D",conflicts:"prod",description:"Check only devDependencies (npm/yarn mode)",type:Boolean},exclude:{description:"Glob pattern to exclude packages (repeatable)",lazyMultiple:!0,type:String},"exit-code":{defaultValue:!1,description:"Exit with code 1 if outdated dependencies found (for CI)",type:Boolean},format:{description:"Output format: table, json, or minimal (default: table)",type:String},include:{description:"Glob pattern to include packages (repeatable)",lazyMultiple:!0,type:String},"include-internal":{defaultValue:!1,description:"Also check workspace-owned package names against the registry",type:Boolean},"no-security":{defaultValue:!1,description:"Skip security vulnerability scanning",type:Boolean},peer:{defaultValue:!1,description:"Include peerDependencies in outdated checks",type:Boolean},prerelease:{defaultValue:!1,description:"Include prerelease versions",type:Boolean},prod:{alias:"P",conflicts:"dev",description:"Check only dependencies (npm/yarn mode)",type:Boolean},"security-config":{defaultValue:!1,description:"Audit supply chain security settings",type:Boolean},sync:{defaultValue:!1,description:"Sync security settings to pnpm-workspace.yaml (pnpm only, requires --security-config)",type:Boolean},target:{alias:"t",description:"Update target: latest, minor, or patch (default: latest)",type:String}},r$=R({alias:["c","outdated"],argument:{description:"Specific packages to check (checks all if omitted)",name:"packages",type:String},description:"Check for outdated dependencies, security vulnerabilities, and supply chain settings",examples:[["vis check","Check all catalog dependencies"],["vis check react","Check specific packages"],["vis check --target minor","Only show minor/patch updates"],["vis check --exclude '@types/*'","Exclude packages by pattern"],["vis check --no-security","Skip vulnerability scanning"],["vis check --security-config","Audit supply chain security settings"],["vis check --security-config --sync","Sync security config to pnpm-workspace.yaml"]],group:"Security & Health",loader:()=>import("./handler6.js"),name:"check",options:i$}),o$={...fe({defaultValue:!0,description:"Install dependencies before running targets (use --no-install to skip)",name:"install",type:Boolean}),base:{description:"Git base ref for affected detection (default: auto-detected from CI env)",type:String},downstream:{defaultValue:"deep",description:"Downstream scope: none | direct | deep",type:String},head:{description:"Git head ref for affected detection (default: HEAD)",type:String},parallel:{defaultValue:4,description:"Maximum number of parallel tasks per target",type:Number},partition:{description:'Partition tasks for distributed CI (e.g., "1/4")',type:String},query:{description:"Filter affected projects by a query (e.g. 'language=typescript && tag=lib')",type:String},"skip-toolchain":{defaultValue:!1,description:"Skip the toolchain pre-flight (no auto-install for any pinned tool: node / pnpm / yarn / npm / bun / deno / go / python / ruby / rust)",type:Boolean},upstream:{defaultValue:"none",description:"Upstream scope: none | direct | deep",type:String}},a$=R({argument:{description:"Comma-separated list of targets to run (e.g., lint,test,build)",name:"targets",type:String},description:"Run affected targets in a CI-optimized pipeline",examples:[["vis ci lint,test,build","Run lint, test, and build on affected projects"],["vis ci test --base=origin/main","Override the base ref"],["vis ci build --no-install","Skip the install step (assume deps already present)"],["vis ci build --parallel=6","Increase concurrency"]],group:"Run & Execute",loader:()=>import("./handler7.js"),name:"ci",options:o$}),c$={base:{description:"Git base ref for comparison. Defaults to CI provider env vars, then HEAD~1.",type:String},downstream:{defaultValue:"deep",description:'Downstream scope: "none", "direct", or "deep"',type:String},"exit-zero-on-build":{defaultValue:!1,description:"Exit 0 on build (normal semantics) instead of 1 (inverted Vercel/Netlify semantics)",type:Boolean},head:{defaultValue:"HEAD",description:"Git head ref for comparison",type:String},json:{defaultValue:!1,description:"Emit the decision as JSON on stdout instead of human text",type:Boolean},upstream:{defaultValue:"none",description:'Upstream scope: "none", "direct", or "deep"',type:String},verbose:{defaultValue:!1,description:"Enable verbose debug output",type:Boolean}},l$=R({argument:{description:"Project name to check (required)",name:"project",type:String},commandPath:["ci"],description:'Exit with inverted codes for CI "Ignored Build Step" gating (Vercel/Netlify)',examples:[["vis ci ignore my-app","Check if my-app is affected and decide whether to build"],["vis ci ignore my-app --base $VERCEL_GIT_PREVIOUS_SHA","Explicit base ref"],["vis ci ignore my-app --json","Emit the decision as JSON instead of text"],["vis ci ignore my-app --verbose","Print debug info about the decision path"],["vis ci ignore my-app --exit-zero-on-build","Normal exit semantics (0=build, 0=skip)"]],group:"Run & Execute",loader:()=>import("./handler52.js"),name:"ignore",options:c$}),d$={"dry-run":{defaultValue:!1,description:"Preview what would be removed without deleting",type:Boolean},"empty-packages":{alias:"e",defaultValue:!1,description:"Also remove stale workspace directories that match a workspace pattern but have no package.json",type:Boolean},lockfile:{alias:"l",defaultValue:!1,description:"Also remove lockfiles (pnpm-lock.yaml, package-lock.json, etc.)",type:Boolean}},u$=R({description:"Remove node_modules from all workspace projects",examples:[["vis clean","Remove all node_modules directories"],["vis clean --lockfile","Also remove lockfiles"],["vis clean --empty-packages","Also remove workspace directories that have no package.json"],["vis clean --dry-run","Preview what would be removed"]],group:"Workspace",loader:()=>import("./handler8.js"),name:"clean",options:d$}),p$={editor:{description:"Generate editor configs (vscode)",type:String},"git-init":{defaultValue:!1,description:"Initialize a git repository",type:Boolean},list:{defaultValue:!1,description:"Show available templates",type:Boolean},"no-interactive":{defaultValue:!1,description:"Skip interactive prompts",type:Boolean}},f$=R({argument:{description:"Template to use (e.g., vis:app, create-vite, user/repo) — omit for interactive mode",name:"template",type:String},description:"Create a new project from a template",examples:[["vis create","Interactive project scaffolding"],["vis create vis:monorepo my-workspace","Create a monorepo workspace"],["vis create vis:app my-app","Scaffold a Vite application"],["vis create vis:library my-lib","Create a TypeScript library"],["vis create vite my-app -- --template react-ts","Use create-vite with React TypeScript"],["vis create user/repo my-project","Clone a GitHub template"],["vis create --list","Show available templates"]],group:"Scaffold & Config",loader:()=>import("./handler69.js"),name:"create",options:p$}),hp=(e,t,n)=>{const s=r=>eo(r)?r:un(e,r);if(t&&t.length>0)return s(t);if(n&&n.length>0)return s(n);const i=process.env.VIS_CACHE_DIRECTORY;return i&&i.length>0?s(i):un(e,xl)},h$=(e,t)=>t===!1?e:kh(e)??e,zc=(e,t,n,s)=>{const i=t??n??process.env.VIS_CACHE_DIRECTORY;if(i&&i.length>0)return hp(e,t,n);const r=h$(e,s);return un(r,xl)},g$=/[^\w.-]+/g,m$=/^-+|-+$/g,y$=e=>e.trim().replaceAll(g$,"-").replaceAll(m$,"").slice(0,64),v$=e=>{try{const t=sh("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return!t||t==="HEAD"?void 0:t}catch{return}},Jc=(e,t,n)=>{if(n!==!0)return e;const s=v$(t);if(!s)return e;const i=y$(s);return i.length===0?e:un(e,"branches",i)},b$=(e,t)=>{const n=as(t,e);return n.length===0?!1:n!==".."&&!n.startsWith("../")&&!eo(n)},w$="x-hono-already-sent";var Me=class extends Error{constructor(e,t){super(e,t),this.name="RequestError"}};const k$=/^\/[!#$&-;=?-\[\]_a-z~]*$/,S$=/\/\.\.?(?:[/?#]|$)/,x$=/^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/,$$=(e,t,n)=>{const s=`${e}://${t}${n}`;if(x$.test(t)){if(n.length===0)return s+"/";if(n.charCodeAt(0)!==47)throw new Me("Invalid URL");return!k$.test(n)||S$.test(n)?new URL(s).href:s}else{const i=new URL(s);if(i.hostname.length!==t.length&&i.hostname!==(t.includes(":")?t.replace(/:\d+$/,""):t).toLowerCase())throw new Me("Invalid host header");return i.href}},E$=e=>e instanceof Me?e:new Me(e.message,{cause:e}),C$=global.Request;var fn=class extends C${constructor(e,t){if(typeof e=="object"&&dt in e){const n=t!==void 0&&"body"in t&&t.body!=null;if(e[qe]&&!n)throw new TypeError("Cannot construct a Request with a Request object that has already been used.");e=e[dt]()}typeof t?.body?.getReader<"u"&&(t.duplex??="half"),super(e,t)}};const gp=e=>{const t=[],n=e.rawHeaders;for(let s=0,i=n.length;s<i;s+=2){const r=n[s];r.charCodeAt(0)!==58&&t.push([r,n[s+1]])}return new Headers(t)},mp=Symbol("wrapBodyStream"),R$=new Set(["latin1","binary","hex","base64","base64url"]),O$=e=>e===null||R$.has(e),tr=Symbol("bodyBufferedBeforeDisconnect"),Vr=Symbol("bodyBufferedLengthBeforeDisconnect"),yp=(e,t)=>Buffer.isBuffer(e)?e:Buffer.from(e,t??"utf8"),Do=e=>!(e instanceof on)&&!!e.complete&&!!e.readableAborted&&typeof e.read=="function"&&O$(e.readableEncoding),qc=e=>{if(e.readableDidRead||!Do(e))return;const t=e;t[Vr]??=e.readableLength},Xs=(e,t)=>{if(e.readableDidRead&&!t||!Do(e))return;const n=e;if(n[tr]!==void 0)return n[tr];let s;const i=e.errored;if(i&&i.code!=="ECONNRESET")s=i;else if(n[Vr]!==void 0&&e.readableLength!==n[Vr])s=Zs();else{const r=t??[],o=e.read();o!==null&&r.push(yp(o,e.readableEncoding));const a=r.length===1?r[0]:Buffer.concat(r);s=a;const c=e.headers["content-length"];if(typeof c=="string"&&/^\d+$/.test(c)){const l=Number(c);Number.isSafeInteger(l)&&a.length!==l&&(s=Zs())}}return n[tr]=s,s},Kc=(e,t)=>{if(t instanceof Error){e.error(t);return}t.length>0&&e.enqueue(t),e.close()},j$=(e,t,n,s,i)=>{const r={method:e,headers:n,signal:i.signal};if(e==="TRACE"){r.method="GET";const o=new fn(t,r);return Object.defineProperty(o,"method",{get(){return"TRACE"}}),o}if(!(e==="GET"||e==="HEAD"))if("rawBody"in s&&s.rawBody instanceof Buffer)r.body=new ReadableStream({start(o){o.enqueue(s.rawBody),o.close()}});else if(s[mp]){let o;r.body=new ReadableStream({async pull(a){try{if(!o){const d=Xs(s);if(d!==void 0){Kc(a,d);return}}o||=ra.toWeb(s).getReader();const{done:c,value:l}=await o.read();c?a.close():a.enqueue(l)}catch(c){a.error(c)}}})}else{const o=Xs(s);o!==void 0?r.body=new ReadableStream({start(a){Kc(a,o)}}):r.body=ra.toWeb(s)}return new fn(t,r)},dt=Symbol("getRequestCache"),Ge=Symbol("requestCache"),hn=Symbol("incomingKey"),Jn=Symbol("urlKey"),vp=Symbol("methodKey"),bp=Symbol("headersKey"),jn=Symbol("abortControllerKey"),Wr=Symbol("getAbortController"),Hr=Symbol("abortRequest"),rt=Symbol("bodyBuffer"),js=Symbol("bodyReadPromise"),qe=Symbol("bodyConsumedDirectly"),Yc=Symbol("bodyLockReader"),Fn=Symbol("abortReason"),Zs=()=>new TypeError("Body is unusable"),gs=()=>Promise.reject(Zs()),T$=new TextDecoder,I$=e=>{if(e[qe])return gs();e[qe]=!0},A$=e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),B$=e=>(e[bp]||=gp(e[hn])).get("content-type")||"",P$=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,N$=e=>{if(typeof e!="string"||e.length===0)return"GET";switch(e){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"PATCH":case"POST":case"PUT":case"QUERY":return e}const t=e.toUpperCase();switch(t){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"POST":case"PUT":return t;default:return e}},D$=e=>{if(!P$.test(e))return new TypeError(`'${e}' is not a valid HTTP method.`);const t=e.toUpperCase();if(t==="CONNECT"||t==="TRACK"||t==="TRACE"&&e!=="TRACE")return new TypeError(`'${e}' HTTP method is unsupported.`)},Lo=(e,t,n)=>{if(e[qe])return gs();const s=e.method;if(s==="GET"||s==="HEAD")return e[dt]()[t]();const i=D$(s);if(i)return Promise.reject(i);if(e[Ge]&&s!=="TRACE")return e[Ge][t]();const r=I$(e);if(r)return r;const o=L$(e);if(o){const a=Promise.resolve(n(o,e));return e[rt]=void 0,a}return M$(e).then(a=>{const c=n(a,e);return e[rt]=void 0,c})},L$=e=>{const t=e[hn];if("rawBody"in t&&t.rawBody instanceof Buffer)return t.rawBody},Xc=(e,t)=>{if(t.errored)return t.errored;const n=e[Fn];return n!==void 0?n instanceof Error?n:new Error(String(n)):new Error("Client connection prematurely closed.")},M$=e=>{if(e[rt])return Promise.resolve(e[rt]);if(e[js])return e[js];const t=e[hn];if(t.readableDidRead)return gs();const n=Xs(t);if(n!==void 0)return n instanceof Error?Promise.reject(n):(e[rt]=n,Promise.resolve(n));const s=new Promise((i,r)=>{const o=[];let a=!1;const c=g=>{a||(a=!0,h(),g())},l=g=>{const y=t.errored??g;return!Do(t)||y&&y.code!=="ECONNRESET"?!1:(c(()=>{const x=Xs(t,o);x instanceof Error?r(x):x===void 0?r(g??Xc(e,t)):(e[rt]=x,i(x))}),!0)},d=g=>{o.push(yp(g,t.readableEncoding))},u=()=>{c(()=>{const g=o.length===1?o[0]:Buffer.concat(o);e[rt]=g,i(g)})},p=g=>{l(g)||c(()=>{r(g)})},f=()=>{if(t.readableEnded){u();return}l()||c(()=>{r(Xc(e,t))})},h=()=>{t.off("data",d),t.off("end",u),t.off("error",p),t.off("close",f),e[js]=void 0};t.on("data",d),t.on("end",u),t.on("error",p),t.on("close",f),queueMicrotask(()=>{a||(t.readableEnded?u():t.errored?p(t.errored):t.destroyed&&f())})});return e[js]=s,s},Ve={get method(){return this[vp]},get url(){return this[Jn]},get headers(){return this[bp]||=gp(this[hn])},[Hr](e){this[Fn]===void 0&&(this[Fn]=e);const t=this[jn];t&&!t.signal.aborted&&t.abort(e)},[Wr](){return this[jn]||=new AbortController,this[Fn]!==void 0&&!this[jn].signal.aborted&&this[jn].abort(this[Fn]),this[jn]},[dt](){const e=this[Wr]();if(this[Ge])return this[Ge];const t=this.method;if(this[qe]&&!(t==="GET"||t==="HEAD")){this[rt]=void 0;const n={method:t==="TRACE"?"GET":t,headers:this.headers,signal:e.signal};t!=="TRACE"&&(n.body=new ReadableStream({start(i){i.close()}}),n.duplex="half");const s=new fn(this[Jn],n);return t==="TRACE"&&Object.defineProperty(s,"method",{get(){return"TRACE"}}),this[Ge]=s}return this[Ge]=j$(this.method,this[Jn],this.headers,this[hn],e)},get body(){if(!this[qe])return this[dt]().body;const e=this[dt]();return!this[Yc]&&e.body&&(this[Yc]=e.body.getReader()),e.body},get bodyUsed(){return this[qe]?!0:this[Ge]?this[Ge].bodyUsed:!1}};Object.defineProperty(Ve,"signal",{get(){return this[Wr]().signal}});["cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","keepalive"].forEach(e=>{Object.defineProperty(Ve,e,{get(){return this[dt]()[e]}})});["clone","formData"].forEach(e=>{Object.defineProperty(Ve,e,{value:function(){if(this[qe]){if(e==="clone")throw Zs();return gs()}return this[dt]()[e]()}})});Object.defineProperty(Ve,"text",{value:function(){return Lo(this,"text",e=>T$.decode(e))}});Object.defineProperty(Ve,"arrayBuffer",{value:function(){return Lo(this,"arrayBuffer",e=>A$(e))}});Object.defineProperty(Ve,"blob",{value:function(){return Lo(this,"blob",(e,t)=>{const n=B$(t),s=n?{headers:{"content-type":n}}:void 0;return new Response(e,s).blob()})}});Object.defineProperty(Ve,"json",{value:function(){return this[qe]?gs():this.text().then(JSON.parse)}});Object.defineProperty(Ve,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,n){return`Request (lightweight) ${n({method:this.method,url:this.url,headers:this.headers,nativeRequest:this[Ge]},{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(Ve,fn.prototype);const _$=(e,t)=>{const n=Object.create(Ve);n[hn]=e,n[vp]=N$(e.method);const s=e.url||"";if(s[0]!=="/"&&(s.startsWith("http://")||s.startsWith("https://"))){if(e instanceof on)throw new Me("Absolute URL for :path is not allowed in HTTP/2");try{n[Jn]=new URL(s).href}catch(o){throw new Me("Invalid absolute URL",{cause:o})}return n}const i=(e instanceof on?e.authority:e.headers.host)||t;if(!i)throw new Me("Missing host header");let r;if(e instanceof on){if(r=e.scheme,!(r==="http"||r==="https"))throw new Me("Unsupported scheme")}else r=e.socket&&e.socket.encrypted?"https":"http";try{n[Jn]=$$(r,i,s)}catch(o){throw o instanceof Me?o:new Me("Invalid URL",{cause:o})}return n},nt="text/plain; charset=UTF-8",Ur=Symbol("responseCache"),nn=Symbol("getResponseCache"),Je=Symbol("cache"),Qs=global.Response;var Fe=class wp{#e;#t;[nn](){const t=this[Je],n=t&&t[2]instanceof Headers?t[2]:void 0;return delete this[Je],this[Ur]||=new Qs(this.#e,n?{status:this.#t?.status,statusText:this.#t?.statusText,headers:n}:this.#t)}constructor(t,n){let s;if(this.#e=t,n instanceof Qs){const i=n[Ur];if(i){this.#t=i,this[nn]();return}this.#t=n instanceof wp?n.#t:n,s=new Headers(n.headers)}else this.#t=n;(t==null||typeof t=="string"||typeof t?.getReader<"u"||t instanceof Blob||t instanceof Uint8Array)&&(this[Je]=[n?.status||200,t??null,s||n?.headers])}get headers(){const t=this[Je];return t?(t[2]instanceof Headers||(t[2]=new Headers(t[2]||(t[1]===null?void 0:{"content-type":nt}))),t[2]):this[nn]().headers}get status(){return this[Je]?.[0]??this[nn]().status}get ok(){const t=this.status;return t>=200&&t<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(Fe.prototype,e,{get(){return this[nn]()[e]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(Fe.prototype,e,{value:function(){return this[nn]()[e]()}})});Object.defineProperty(Fe.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,n){return`Response (lightweight) ${n({status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[Ur]},{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(Fe,Qs);Object.setPrototypeOf(Fe.prototype,Qs.prototype);const F$=/^https?:\/\/[!#-;=?-[\]_a-z~A-Z]+$/,V$=e=>e instanceof URL?e.href:F$.test(e)?e:new URL(e).href,W$=new Set([301,302,303,307,308]);Object.defineProperty(Fe,"redirect",{value:function(t,n=302){if(!W$.has(n))throw new RangeError("Invalid status code");return new Fe(null,{status:n,headers:{location:V$(t)}})},writable:!0,configurable:!0});Object.defineProperty(Fe,"json",{value:function(t,n){const s=JSON.stringify(t);if(s===void 0)throw new TypeError("The data is not JSON serializable");const i=n?.headers;let r;return i?(r=new Headers(i),r.has("content-type")||r.set("content-type","application/json")):r={"content-type":"application/json"},new Fe(s,{status:n?.status??200,statusText:n?.statusText,headers:r})},writable:!0,configurable:!0});async function H$(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function kp(e,t,n){const s=a=>{e.cancel(a).catch(()=>{})};return t.on("close",s),t.on("error",s),(n??e.read()).then(o,i),e.closed.finally(()=>{t.off("close",s),t.off("error",s)});function i(a){a&&t.destroy(a)}function r(){e.read().then(o,i)}function o({done:a,value:c}){try{if(a)t.end();else if(!t.write(c))t.once("drain",r);else return e.read().then(o,i)}catch(l){i(l)}}}function Zc(e,t){if(e.locked)throw new TypeError("ReadableStream is locked.");return t.destroyed?void 0:kp(e.getReader(),t)}const Gr=(e,t)=>{const n={};if(e instanceof Headers||(e=new Headers(e??void 0)),e.has("set-cookie")){const s=[];for(const[i,r]of e)i==="set-cookie"?s.push(r):n[i]=r;s.length>0&&(n["set-cookie"]=s)}else for(const[s,i]of e)n[s]=i;return t&&(n["content-type"]??=t),n},ei=Symbol("outgoingEnded"),Qc=Symbol("incomingDraining"),U$=500,G$=64*1024*1024,Sp=e=>{const t=e;if(e.destroyed||t[Qc])return;if(t[Qc]=!0,e instanceof on){try{e.stream?.close?.(Oh.NGHTTP2_NO_ERROR)}catch{}return}let n=0;const s=()=>{clearTimeout(r),e.off("data",o),e.off("end",s),e.off("error",s)},i=()=>{s();const a=e.socket;a&&!a.destroyed&&(typeof a.destroySoon=="function"?a.destroySoon():typeof a.destroy=="function"&&a.destroy())},r=setTimeout(i,U$);r.unref?.();const o=a=>{n+=a.length,n>G$&&i()};e.on("data",o),e.on("end",s),e.on("error",s),e.resume()},z$=(e,t,n,s)=>()=>{t.errored?(qc(t),e[Hr](t.errored.toString())):n.writableFinished||(qc(t),e[Hr]("Client connection prematurely closed.")),s&&!t.readableEnded&&setTimeout(()=>{t.readableEnded||setTimeout(()=>{Sp(t)})})},J$=e=>{if(!(Je in e))return!1;const t=e[Je][1];return t===null||typeof t=="string"||t instanceof Uint8Array},q$=()=>new Response(null,{status:400}),xp=e=>new Response(null,{status:e instanceof Error&&(e.name==="TimeoutError"||e.constructor.name==="TimeoutError")?504:500}),ti=(e,t)=>{const n=e instanceof Error?e:new Error("unknown error",{cause:e});n.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(e),t.headersSent||t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`Error: ${n.message}`),t.destroy(n))},zr=e=>{"flushHeaders"in e&&e.writable&&e.flushHeaders()},$p=async(e,t)=>{let[n,s,i]=e[Je];if(!i){s===null?(t.writeHead(n),t.end()):typeof s=="string"?(t.writeHead(n,{"Content-Type":nt,"Content-Length":Buffer.byteLength(s)}),t.end(s)):s instanceof Uint8Array?(t.writeHead(n,{"Content-Type":nt,"Content-Length":s.byteLength}),t.end(s)):s instanceof Blob?(t.writeHead(n,{"Content-Type":nt,"Content-Length":s.size}),t.end(new Uint8Array(await s.arrayBuffer()))):(t.writeHead(n,{"Content-Type":nt}),zr(t),await Zc(s,t)?.catch(o=>ti(o,t))),t[ei]?.();return}let r=!1;if(i instanceof Headers)r=i.has("content-length"),i=Gr(i,s===null?void 0:nt);else if(Array.isArray(i)){const o=new Headers(i);r=o.has("content-length"),i=Gr(o,s===null?void 0:nt)}else for(const o in i)if(o.length===14&&o.toLowerCase()==="content-length"){r=!0;break}r||(typeof s=="string"?i["Content-Length"]=Buffer.byteLength(s):s instanceof Uint8Array?i["Content-Length"]=s.byteLength:s instanceof Blob&&(i["Content-Length"]=s.size)),t.writeHead(n,i),s==null?t.end():typeof s=="string"||s instanceof Uint8Array?t.end(s):s instanceof Blob?t.end(new Uint8Array(await s.arrayBuffer())):(zr(t),await Zc(s,t)?.catch(o=>ti(o,t))),t[ei]?.()},Ep=e=>typeof e.then=="function",K$=async(e,t,n={})=>{if(Ep(e))if(n.errorHandler)try{e=await e}catch(i){const r=await n.errorHandler(i);if(!r)return;e=r}else e=await e.catch(xp);if(Je in e)return $p(e,t);const s=Gr(e.headers,e.body===null?void 0:nt);if(e.body){const i=e.body.getReader(),r=[];let o=!1,a;if(s["transfer-encoding"]!=="chunked"){let c=2;for(let l=0;l<c;l++){a||=i.read();const d=await H$(a).catch(u=>{console.error(u),o=!0});if(!d){if(l===1){await new Promise(u=>setTimeout(u)),c=3;continue}break}if(a=void 0,d.value&&r.push(d.value),d.done){o=!0;break}}o&&!("content-length"in s)&&(s["content-length"]=r.reduce((l,d)=>l+d.length,0))}t.writeHead(e.status,s),r.forEach(c=>{t.write(c)}),o?t.end():(r.length===0&&zr(t),await kp(i,t,a))}else s[w$]||(t.writeHead(e.status,s),t.end());t[ei]?.()},Y$=(e,t={})=>{const n=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==fn&&(Object.defineProperty(global,"Request",{value:fn}),Object.defineProperty(global,"Response",{value:Fe})),async(s,i)=>{let r,o,a=!1,c=!1;const l=()=>{!o||c||(c=!0,i.on("close",z$(o,s,i,a)))};try{if(o=_$(s,t.hostname),a=n&&!(s.method==="GET"||s.method==="HEAD"),a&&(s[mp]=!0,s instanceof on&&(i[ei]=()=>{s.readableEnded||setTimeout(()=>{s.readableEnded||setTimeout(()=>{s.destroy(),i.destroy()})})})),r=e(o,{incoming:s,outgoing:i}),!Ep(r)&&J$(r))return a&&!s.readableEnded&&i.once("finish",()=>{s.readableEnded||Sp(s)}),$p(r,i);l()}catch(d){if(r)return ti(d,i);if(t.errorHandler){if(l(),r=await t.errorHandler(o?d:E$(d)),!r)return}else o?r=xp(d):r=q$()}try{return await K$(r,i,t)}catch(d){return ti(d,i)}}},X$=Symbol("CONNECTION_SYMBOL_KEY"),Z$=Symbol("WAIT_FOR_WEBSOCKET_SYMBOL"),Q$=new Set(["connection","content-length","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade","sec-websocket-accept","sec-websocket-extensions","sec-websocket-protocol"]),Cp=(e,t)=>{t&&t.forEach((n,s)=>{Q$.has(s.toLowerCase())||e.push(`${s}: ${n}`)})},el=(e,t,n)=>{const s=["Connection: close","Content-Length: 0"];Cp(s,n),e.end(`HTTP/1.1 ${t.toString()} ${Rh[t]??""}\r
198
198
  ${s.join(`\r
199
199
  `)}\r
200
200
  \r
201
- `)},Y$=e=>{const t=e.socket.encrypted?"https":"http",n=new URL(e.url??"/",`${t}://${e.headers.host??"localhost"}`),s=new Headers;for(const i in e.headers){const r=e.headers[i];r&&s.append(i,Array.isArray(r)?r[0]:r)}return new Request(n,{headers:s})},X$=e=>{const{server:t,fetchCallback:n,wss:s}=e,i=new Map;s.on("connection",(a,c)=>{const l=i.get(c);l&&(l.resolve(a),i.delete(c))});const r=a=>{const c=i.get(a);c&&(i.delete(a),c.reject(new Error("WebSocket handshake aborted")))},o=(a,c)=>new Promise((l,d)=>{i.set(a,{resolve:l,reject:d,connectionSymbol:c})});t.on("upgrade",async(a,c,l)=>{if(a.headers.upgrade?.toLowerCase()!=="websocket")return;const d={incoming:a,outgoing:void 0,wss:s,[q$]:o};let u=400,p;try{const y=await n(Y$(a),d);y instanceof Response&&(u=y.status,p=y.headers)}catch{t.listenerCount("upgrade")===1&&Xc(c,500);return}const f=i.get(a);if(!f||f.connectionSymbol!==d[J$]){r(a),t.listenerCount("upgrade")===1&&Xc(c,u,p);return}const h=y=>{xp(y,p)},g=()=>r(a);c.once("close",g),s.on("headers",h);try{s.handleUpgrade(a,c,l,y=>{c.off("close",g),s.emit("connection",y,a)})}finally{s.off("headers",h)}}),t.on("close",()=>{s.close()})},Z$=e=>{const t=e.fetch,n=z$(t,{hostname:e.hostname,overrideGlobalObjects:e.overrideGlobalObjects,autoCleanupIncoming:e.autoCleanupIncoming}),s=(e.createServer||Sh)(e.serverOptions||{},n);if(e.websocket&&e.websocket.server){if(e.websocket.server.options.noServer!==!0)throw new Error("WebSocket server must be created with { noServer: true } option");X$({server:s,fetchCallback:t,wss:e.websocket.server})}return s},Q$=(e,t)=>{const n=Z$(e);return n.listen(e?.port??3e3,e.hostname,()=>{n.address()}),n};var Zc=(e,t,n)=>(s,i)=>{let r=-1;return o(0);async function o(a){if(a<=r)throw new Error("next() called multiple times");r=a;let c,l=!1,d;if(e[a]?(d=e[a][0][0],s.req.routeIndex=a):d=a===e.length&&i||void 0,d)try{c=await d(s,()=>o(a+1))}catch(u){if(u instanceof Error&&t)s.error=u,c=await t(u,s),l=!0;else throw u}else s.finalized===!1&&n&&(c=await n(s));return c&&(s.finalized===!1||l)&&(s.res=c),s}},eE=Symbol(),tE=(e,t)=>new Response(e,{headers:{"Content-Type":t.replace(/^[^;]+/,s=>s.toLowerCase())}}).formData(),Ms=e=>"headers"in e,nE=async(e,t=Object.create(null))=>{const{all:n=!1,dot:s=!1}=t,o=(Ms(e)?e.headers:e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();return o==="multipart/form-data"||o==="application/x-www-form-urlencoded"?sE(e,{all:n,dot:s}):{}};async function sE(e,t){if(!Ms(e)&&e.bodyCache.formData)return Qc(await e.bodyCache.formData,t);const n=Ms(e)?e.headers:e.raw.headers,s=await e.arrayBuffer(),i=tE(s,n.get("Content-Type")||"");Ms(e)||(e.bodyCache.formData=i);const r=await i;return r?Qc(r,t):{}}function Qc(e,t){const n=Object.create(null);return e.forEach((s,i)=>{t.all||i.endsWith("[]")?iE(n,i,s):n[i]=s}),t.dot&&Object.entries(n).forEach(([s,i])=>{s.includes(".")&&(rE(n,s,i),delete n[s])}),n}var iE=(e,t,n)=>{e[t]!==void 0?Array.isArray(e[t])?e[t].push(n):e[t]=[e[t],n]:t.endsWith("[]")?e[t]=[n]:e[t]=n},rE=(e,t,n)=>{if(/(?:^|\.)__proto__\./.test(t))return;let s=e;const i=t.split(".");i.forEach((r,o)=>{o===i.length-1?s[r]=n:((!s[r]||typeof s[r]!="object"||Array.isArray(s[r])||s[r]instanceof File)&&(s[r]=Object.create(null)),s=s[r])})},$p=e=>{const t=e.split("/");return t[0]===""&&t.shift(),t},oE=e=>{const{groups:t,path:n}=aE(e),s=$p(n);return cE(s,t)},aE=e=>{const t=[];return e=e.replace(/\{[^}]+\}/g,(n,s)=>{const i=`@${s}`;return t.push([i,n]),i}),{groups:t,path:e}},cE=(e,t)=>{for(let n=t.length-1;n>=0;n--){const[s]=t[n];for(let i=e.length-1;i>=0;i--)if(e[i].includes(s)){e[i]=e[i].replace(s,t[n][1]);break}}return e},Os={},lE=(e,t)=>{if(e==="*")return"*";const n=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){const s=`${e}#${t}`;return Os[s]||(n[2]?Os[s]=t&&t[0]!==":"&&t[0]!=="*"?[s,n[1],new RegExp(`^${n[2]}(?=/${t})`)]:[e,n[1],new RegExp(`^${n[2]}$`)]:Os[s]=[e,n[1],!0]),Os[s]}return null},Ep=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,n=>{try{return t(n)}catch{return n}})}},dE=e=>Ep(e,decodeURI),Cp=e=>{const t=e.url,n=t.indexOf("/",t.indexOf(":")+4);let s=n;for(;s<t.length;s++){const i=t.charCodeAt(s);if(i===37){const r=t.indexOf("?",s),o=t.indexOf("#",s),a=r===-1?o===-1?void 0:o:o===-1?r:Math.min(r,o),c=t.slice(n,a);return dE(c.includes("%25")?c.replace(/%25/g,"%2525"):c)}else if(i===63||i===35)break}return t.slice(n,s)},uE=e=>{const t=Cp(e);return t.length>1&&t.at(-1)==="/"?t.slice(0,-1):t},$t=(e,t,...n)=>(n.length&&(t=$t(t,...n)),`${e?.[0]==="/"?"":"/"}${e}${t==="/"?"":`${e?.at(-1)==="/"?"":"/"}${t?.[0]==="/"?t.slice(1):t}`}`),Rp=e=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(":"))return null;const t=e.split("/"),n=[];let s="";return t.forEach(i=>{if(i!==""&&!/\:/.test(i))s+="/"+i;else if(/\:/.test(i))if(/\?/.test(i)){n.length===0&&s===""?n.push("/"):n.push(s);const r=i.replace("?","");s+="/"+r,n.push(s)}else s+="/"+i}),n.filter((i,r,o)=>o.indexOf(i)===r)},zr=e=>e.indexOf("%")!==-1?Ep(e,hE):e,tr=e=>(e.indexOf("+")!==-1&&(e=e.replace(/\+/g," ")),zr(e)),Op=(e,t,n)=>{let s;if(!n&&t&&t.indexOf("%")===-1&&t.indexOf("+")===-1){let o=e.indexOf("?",8);if(o===-1)return;for(e.startsWith(t,o+1)||(o=e.indexOf(`&${t}`,o+1));o!==-1;){const a=e.charCodeAt(o+t.length+1);if(a===61){const c=o+t.length+2,l=e.indexOf("&",c);return tr(e.slice(c,l===-1?void 0:l))}else if(a==38||isNaN(a))return"";o=e.indexOf(`&${t}`,o+1)}if(s=/[%+]/.test(e),!s)return}const i=Object.create(null);s??=/[%+]/.test(e);let r=e.indexOf("?",8);for(;r!==-1;){const o=e.indexOf("&",r+1);let a=e.indexOf("=",r);a>o&&o!==-1&&(a=-1);let c=e.slice(r+1,a===-1?o===-1?void 0:o:a);if(s&&(c=tr(c)),r=o,c==="")continue;let l;a===-1?l="":(l=e.slice(a+1,o===-1?void 0:o),s&&(l=tr(l))),n?(i[c]&&Array.isArray(i[c])||(i[c]=[]),i[c].push(l)):i[c]??=l}return t?i[t]:i},pE=Op,fE=(e,t)=>Op(e,t,!0),hE=decodeURIComponent,gE=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t="/",n=[[]]){this.raw=e,this.path=t,this.#t=n}param(e){return e?this.#n(e):this.#r()}#n(e){const t=this.#t[0][this.routeIndex][1][e],n=this.#s(t);return n&&zr(n)}#r(){const e={},t=Object.keys(this.#t[0][this.routeIndex][1]);for(const n of t){const s=this.#s(this.#t[0][this.routeIndex][1][n]);s!==void 0&&(e[n]=zr(s))}return e}#s(e){return this.#t[1]?this.#t[1][e]:e}query(e){return pE(this.url,e)}queries(e){return fE(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;const t=Object.create(null);return this.raw.headers.forEach((n,s)=>{t[s]=n}),t}async parseBody(e){return nE(this,e)}#i=e=>{const{bodyCache:t,raw:n}=this,s=t[e];if(s)return s;for(const i in t)return t[i].then(r=>(i==="json"&&(r=JSON.stringify(r)),new Response(r)[e]()));return t[e]=n[e]()};json(){return this.#i("text").then(e=>JSON.parse(e))}text(){return this.#i("text")}arrayBuffer(){return this.#i("arrayBuffer")}bytes(){return this.#i("arrayBuffer").then(e=>new Uint8Array(e))}blob(){return this.#i("blob")}formData(){return this.#i("formData")}addValidatedData(e,t){(this.#e??={})[e]=t}valid(e){return this.#e?.[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[eE](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}},jp={Stringify:1},Lo=async(e,t,n,s,i)=>{typeof e=="object"&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));const r=e.callbacks;return r?.length?(i?i[0]+=e:i=[e],Promise.all(r.map(a=>a({phase:t,buffer:i,context:s}))).then(a=>Promise.all(a.filter(Boolean).map(c=>Lo(c,t,!1,s,i))).then(()=>i[0]))):Promise.resolve(e)},mE="text/plain; charset=UTF-8",nr=(e,t)=>({"Content-Type":e,...t}),Tn=(e,t)=>new Response(e,t),yE=class{#e;#t;env={};#n;finalized=!1;error;#r;#s;#i;#o;#a;#c;#l;#d;#p;constructor(e,t){this.#e=e,t&&(this.#s=t.executionCtx,this.env=t.env,this.#c=t.notFoundHandler,this.#p=t.path,this.#d=t.matchResult)}get req(){return this.#t??=new gE(this.#e,this.#p,this.#d),this.#t}get event(){if(this.#s&&"respondWith"in this.#s)return this.#s;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#s)return this.#s;throw Error("This context has no ExecutionContext")}get res(){return this.#i||=Tn(null,{headers:this.#l??=new Headers})}set res(e){if(this.#i&&e){e=Tn(e.body,e);for(const[t,n]of this.#i.headers.entries())if(t!=="content-type")if(t==="set-cookie"){const s=this.#i.headers.getSetCookie();e.headers.delete("set-cookie");for(const i of s)e.headers.append("set-cookie",i)}else e.headers.set(t,n)}this.#i=e,this.finalized=!0}render=(...e)=>(this.#a??=t=>this.html(t),this.#a(...e));setLayout=e=>this.#o=e;getLayout=()=>this.#o;setRenderer=e=>{this.#a=e};header=(e,t,n)=>{this.finalized&&(this.#i=Tn(this.#i.body,this.#i));const s=this.#i?this.#i.headers:this.#l??=new Headers;t===void 0?s.delete(e):n?.append?s.append(e,t):s.set(e,t)};status=e=>{this.#r=e};set=(e,t)=>{this.#n??=new Map,this.#n.set(e,t)};get=e=>this.#n?this.#n.get(e):void 0;get var(){return this.#n?Object.fromEntries(this.#n):{}}#u(e,t,n){let s=this.#i?new Headers(this.#i.headers):this.#l;if(typeof t=="object"&&t.headers){s??=new Headers;for(const[r,o]of new Headers(t.headers))r==="set-cookie"?s.append(r,o):s.set(r,o)}if(n){if(!s){let r=0;for(const o in n)if(++r>1||typeof n[o]!="string"){s=new Headers;break}}if(s)for(const r in n){const o=n[r];if(typeof o=="string")s.set(r,o);else{s.delete(r);for(const a of o)s.append(r,a)}}}const i=typeof t=="number"?t:t?.status??this.#r;return Tn(e,{status:i,headers:s??n})}newResponse=(...e)=>this.#u(...e);body=(e,t,n)=>this.#u(e,t,n);text=(e,t,n)=>!this.#l&&!this.#r&&!t&&!n&&!this.finalized?new Response(e):this.#u(e,t,nr(mE,n));json=(e,t,n)=>this.#u(JSON.stringify(e),t,nr("application/json",n));html=(e,t,n)=>{const s=i=>this.#u(i,t,nr("text/html; charset=UTF-8",n));return typeof e=="object"?Lo(e,jp.Stringify,!1,{}).then(s):s(e)};redirect=(e,t)=>{const n=String(e);return this.header("Location",/[^\x00-\xFF]/.test(n)?encodeURI(n):n),this.newResponse(null,t??302)};notFound=()=>(this.#c??=()=>Tn(),this.#c(this))},ve="ALL",vE="all",bE=["get","post","put","delete","options","patch","query"],Tp="Can not add a route since the matcher is already built.",Ip=class extends Error{},wE="__COMPOSED_HANDLER",kE=e=>e.text("404 Not Found",404),el=(e,t)=>{if("getResponse"in e){const n=e.getResponse();return t.newResponse(n.body,n)}return console.error(e),t.text("Internal Server Error",500)},SE=class Ap{get;post;put;delete;options;patch;query;all;on;use;router;getPath;_basePath="/";#e="/";routes=[];constructor(t={}){[...bE,vE].forEach(r=>{this[r]=(o,...a)=>(typeof o=="string"?this.#e=o:this.#r(r,this.#e,o),a.forEach(c=>{this.#r(r,this.#e,c)}),this)}),this.on=(r,o,...a)=>{for(const c of[o].flat()){this.#e=c;for(const l of[r].flat())a.map(d=>{this.#r(l.toUpperCase(),this.#e,d)})}return this},this.use=(r,...o)=>(typeof r=="string"?this.#e=r:(this.#e="*",o.unshift(r)),o.forEach(a=>{this.#r(ve,this.#e,a)}),this);const{strict:s,...i}=t;Object.assign(this,i),this.getPath=s??!0?t.getPath??Cp:uE}#t(){const t=new Ap({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#n=this.#n,t.routes=this.routes,t}#n=kE;errorHandler=el;route(t,n){const s=this.basePath(t);return n.routes.map(i=>{let r;n.errorHandler===el?r=i.handler:(r=async(o,a)=>(await Zc([],n.errorHandler)(o,()=>i.handler(o,a))).res,r[wE]=i.handler),s.#r(i.method,i.path,r,i.basePath)}),this}basePath(t){const n=this.#t();return n._basePath=$t(this._basePath,t),n}onError=t=>(this.errorHandler=t,this);notFound=t=>(this.#n=t,this);mount(t,n,s){let i,r;s&&(typeof s=="function"?r=s:(r=s.optionHandler,s.replaceRequest===!1?i=c=>c:i=s.replaceRequest));const o=r?c=>{const l=r(c);return Array.isArray(l)?l:[l]}:c=>{let l;try{l=c.executionCtx}catch{}return[c.env,l]};i||=(()=>{const c=$t(this._basePath,t),l=c==="/"?0:c.length;return d=>{const u=new URL(d.url);return u.pathname=this.getPath(d).slice(l)||"/",new Request(u,d)}})();const a=async(c,l)=>{const d=await n(i(c.req.raw),...o(c));if(d)return d;await l()};return this.#r(ve,$t(t,"*"),a),this}#r(t,n,s,i){t=t.toUpperCase(),n=$t(this._basePath,n);const r={basePath:i!==void 0?$t(this._basePath,i):this._basePath,path:n,method:t,handler:s};this.router.add(t,n,[s,r]),this.routes.push(r)}#s(t,n){if(t instanceof Error)return this.errorHandler(t,n);throw t}#i(t,n,s,i){if(i==="HEAD")return(async()=>new Response(null,await this.#i(t,n,s,"GET")))();const r=this.getPath(t,{env:s}),o=this.router.match(i,r),a=new yE(t,{path:r,matchResult:o,env:s,executionCtx:n,notFoundHandler:this.#n});if(o[0].length===1){let l;try{l=o[0][0][0][0](a,async()=>{a.res=await this.#n(a)})}catch(d){return this.#s(d,a)}return l instanceof Promise?l.then(d=>d||(a.finalized?a.res:this.#n(a))).catch(d=>this.#s(d,a)):l??this.#n(a)}const c=Zc(o[0],this.errorHandler,this.#n);return(async()=>{try{const l=await c(a);if(!l.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#s(l,a)}})()}fetch=(t,...n)=>this.#i(t,n[1],n[0],t.method);request=(t,n,s,i)=>t instanceof Request?this.fetch(n?new Request(t,n):t,s,i):(t=t.toString(),this.fetch(new Request(/^https?:\/\//.test(t)?t:`http://localhost${$t("/",t)}`,n),s,i));fire=()=>{addEventListener("fetch",t=>{t.respondWith(this.#i(t.request,t,void 0,t.request.method))})}},Pp=[];function xE(e,t){const n=this.buildAllMatchers(),s=((i,r)=>{const o=n[i]||n[ve],a=o[2][r];if(a)return a;const c=r.match(o[0]);if(!c)return[[],Pp];const l=c.indexOf("",1);return[o[1][l],c]});return this.match=s,s(e,t)}var ti="[^/]+",nn=".*",Rt="(?:|/.*)",Et=Symbol(),tl=new Set(".\\+*[^]$()");function $E(e,t){return e.length===1?t.length===1?e<t?-1:1:-1:t.length===1?1:e===nn||e===Rt?t===Rt?-1:1:t===nn||t===Rt?-1:e===ti?1:t===ti?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var EE=class Jr{#e;#t;#n=Object.create(null);insert(t,n,s,i,r){let o=this;for(let a=0,c=t.length;a<c;a++){const l=t[a],d=l.length===1?l==="*"?a===c-1?["","",nn]:["","",ti]:null:l==="/*"?["","",Rt]:l.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(d){const p=d[1];let f=d[2]||ti;if(p&&d[2]&&(f===".*"||(f=f.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(f))||f.length===1&&tl.has(f)))throw Et;if(u=o.#n[f],!u){if(f!==nn&&f!==Rt){for(const h in o.#n)if((f.length>1||h.length>1)&&h!==nn&&h!==Rt)throw Et}u=o.#n[f]=new Jr}p!==""&&(u.#t??=i.varIndex++,s.push([p,u.#t]))}else if(u=o.#n[l],!u){for(const p in o.#n)if(p.length>1&&p!==nn&&p!==Rt)throw Et;u=o.#n[l]=new Jr}o=u}if(o.#e!==void 0)throw Et;o.#e=r?-1:n}buildRegExpStr(){const n=Object.keys(this.#n).sort($E).map(s=>{const i=this.#n[s],r=i.buildRegExpStr();return r===""?"":(typeof i.#t=="number"?`(${s})@${i.#t}`:tl.has(s)?`\\${s}`:s)+r}).filter(Boolean);return typeof this.#e=="number"&&this.#e!==-1&&n.unshift(`#${this.#e}`),n.length===0?"":n.length===1?n[0]:"(?:"+n.join("|")+")"}},nl=class{#e={varIndex:0};#t=new EE;#n=0;paths=Object.create(null);insert(e,t){if(t){this.#t.insert(e.split(""),0,[],this.#e,!0);return}const n=[],s=[];let i=e;for(let o=0;;){let a=!1;if(i=i.replace(/\{[^}]+\}/g,c=>{const l=`@\\${o}`;return s[o]=[l,c],o++,a=!0,l}),!a)break}const r=i.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let o=s.length-1;o>=0;o--){const[a]=s[o];for(let c=r.length-1;c>=0;c--)if(r[c].indexOf(a)!==-1){r[c]=r[c].replace(a,s[o][1]);break}}this.#t.insert(r,this.#n,n,this.#e,!1),this.paths[e]=[this.#n++,n]}buildRegExp(){let e=this.#t.buildRegExpStr();if(e==="")return[/^$/,[],[]];let t=0;const n=[],s=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,r,o)=>r!==void 0?(n[++t]=Number(r),"$()"):(o!==void 0&&(s[Number(o)]=++t),"")),[new RegExp(`^${e}`),n,s]}},Bp=Object.create(null);function Np(e){return Bp[e]??=new RegExp(e==="*"?"":`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(t,n)=>n?`\\${n}`:"(?:|/.*)")}$`)}function CE(){Bp=Object.create(null)}function js(e,t){if(e){for(const n of Object.keys(e).sort((s,i)=>i.length-s.length))if(Np(n).test(t))return[...e[n]]}}var RE=class{name="RegExpRouter";#e;#t;#n;constructor(){this.#e={[ve]:Object.create(null)},this.#t={[ve]:Object.create(null)},this.#n={[ve]:new nl}}#r(e,t){try{this.#n[e].insert(t,!/\*|\/:/.test(t))}catch(n){throw n===Et?new Ip(t):n}}add(e,t,n){const s=this.#e,i=this.#t;if(!s||!i)throw new Error(Tp);s[e]||(this.#n[e]=new nl,[s,i].forEach(a=>{a[e]=Object.create(null),Object.keys(a[ve]).forEach(c=>{a[e][c]=[...a[ve][c]],this.#r(e,c)})})),t==="/*"&&(t="*");const r=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){const a=Np(t);Object.keys(s).forEach(c=>{(e===ve||e===c)&&!s[c][t]&&(this.#r(c,t),s[c][t]=js(s[c],t)||js(s[ve],t)||[])}),Object.keys(s).forEach(c=>{(e===ve||e===c)&&Object.keys(s[c]).forEach(l=>{a.test(l)&&s[c][l].push([n,r])})}),Object.keys(i).forEach(c=>{(e===ve||e===c)&&Object.keys(i[c]).forEach(l=>a.test(l)&&i[c][l].push([n,r]))});return}const o=Rp(t)||[t];for(let a=0,c=o.length;a<c;a++){const l=o[a];Object.keys(i).forEach(d=>{(e===ve||e===d)&&(i[d][l]||(this.#r(d,l),i[d][l]=[...js(s[d],l)||js(s[ve],l)||[]]),i[d][l].push([n,r-c+a+1]))})}}match=xE;buildAllMatchers(){const e=Object.create(null);return Object.keys(this.#t).concat(Object.keys(this.#e)).forEach(t=>{e[t]||=this.#s(t)}),this.#e=this.#t=this.#n=void 0,CE(),e}#s(e){const t=this.#e[e],n=this.#t[e],s=this.#n[e],i=Object.create(null),r=[];[t,n].forEach(d=>{for(const u in d){const p=d[u],f=s.paths[u];if(!f){i[u]=[p.map(([g])=>[g,Object.create(null)]),Pp];continue}const h=f[1];r[f[0]]=p.map(([g,y])=>{const x=Object.create(null);for(y-=1;y>=0;y--){const[b,S]=h[y];x[b]=S}return[g,x]})}});const[o,a,c]=s.buildRegExp();for(let d=0,u=r.length;d<u;d++)for(let p=0,f=r[d].length;p<f;p++){const h=r[d][p]?.[1];if(!h)continue;const g=Object.keys(h);for(let y=0,x=g.length;y<x;y++)h[g[y]]=c[h[g[y]]]}const l=[];for(const d in a)l[d]=r[a[d]];return[o,l,i]}},OE=class{name="SmartRouter";#e=[];#t=[];constructor(e){this.#e=e.routers}add(e,t,n){if(!this.#t)throw new Error(Tp);this.#t.push([e,t,n])}match(e,t){if(!this.#t)throw new Error("Fatal error");const n=this.#e,s=this.#t,i=n.length;let r=0,o;for(;r<i;r++){const a=n[r];try{for(let c=0,l=s.length;c<l;c++)a.add(...s[c]);o=a.match(e,t)}catch(c){if(c instanceof Ip)continue;throw c}this.match=a.match.bind(a),this.#e=[a],this.#t=void 0;break}if(r===i)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,o}get activeRouter(){if(this.#t||this.#e.length!==1)throw new Error("No active router has been determined yet.");return this.#e[0]}},In=Object.create(null),jE=e=>{for(const t in e)return!0;return!1},TE=class Dp{#e;#t;#n;#r=0;#s=In;constructor(t,n,s){if(this.#t=s||Object.create(null),this.#e=[],t&&n){const i=Object.create(null);i[t]={handler:n,possibleKeys:[],score:0},this.#e=[i]}this.#n=[]}insert(t,n,s){this.#r=++this.#r;let i=this;const r=oE(n),o=[];for(let a=0,c=r.length;a<c;a++){const l=r[a],d=r[a+1],u=lE(l,d),p=Array.isArray(u)?u[0]:l;if(p in i.#t){i=i.#t[p],u&&o.push(u[1]);continue}i.#t[p]=new Dp,u&&(i.#n.push(u),o.push(u[1])),i=i.#t[p]}return i.#e.push({[t]:{handler:s,possibleKeys:o.filter((a,c,l)=>l.indexOf(a)===c),score:this.#r}}),i}#i(t,n,s,i,r){for(let o=0,a=n.#e.length;o<a;o++){const c=n.#e[o],l=c[s]||c[ve],d={};if(l!==void 0&&(l.params=Object.create(null),t.push(l),i!==In||r&&r!==In))for(let u=0,p=l.possibleKeys.length;u<p;u++){const f=l.possibleKeys[u],h=d[l.score];l.params[f]=r?.[f]&&!h?r[f]:i[f]??r?.[f],d[l.score]=!0}}}search(t,n){const s=[];this.#s=In;let r=[this];const o=$p(n),a=[],c=o.length;let l=null;for(let d=0;d<c;d++){const u=o[d],p=d===c-1,f=[];for(let g=0,y=r.length;g<y;g++){const x=r[g],b=x.#t[u];b&&(b.#s=x.#s,p?(b.#t["*"]&&this.#i(s,b.#t["*"],t,x.#s),this.#i(s,b,t,x.#s)):f.push(b));for(let S=0,C=x.#n.length;S<C;S++){const N=x.#n[S],T=x.#s===In?{}:{...x.#s};if(N==="*"){const re=x.#t["*"];re&&(this.#i(s,re,t,x.#s),re.#s=T,f.push(re));continue}const[D,F,V]=N;if(!u&&!(V instanceof RegExp))continue;const Z=x.#t[D];if(V instanceof RegExp){if(l===null){l=new Array(c);let ne=n[0]==="/"?1:0;for(let ie=0;ie<c;ie++)l[ie]=ne,ne+=o[ie].length+1}const re=n.substring(l[d]),te=V.exec(re);if(te){if(T[F]=te[0],this.#i(s,Z,t,x.#s,T),te[0].length===re.length&&Z.#t["*"]&&this.#i(s,Z.#t["*"],t,x.#s,T),jE(Z.#t)){Z.#s=T;const ne=te[0].match(/\//g)?.length??0;(a[ne]||=[]).push(Z)}continue}}(V===!0||V.test(u))&&(T[F]=u,p?(this.#i(s,Z,t,T,x.#s),Z.#t["*"]&&this.#i(s,Z.#t["*"],t,T,x.#s)):(Z.#s=T,f.push(Z)))}}const h=a.shift();r=h?f.concat(h):f}return s.length>1&&s.sort((d,u)=>d.score-u.score),[s.map(({handler:d,params:u})=>[d,u])]}},IE=class{name="TrieRouter";#e;constructor(){this.#e=new TE}add(e,t,n){const s=Rp(t);if(s){for(let i=0,r=s.length;i<r;i++)this.#e.insert(e,s[i],n);return}this.#e.insert(e,t,n)}match(e,t){return this.#e.search(e,t)}},AE=class extends SE{constructor(e={}){super(e),this.router=e.router??new OE({routers:[new RE,new IE]})}},PE=class{writer;encoder;writable;abortSubscribers=[];responseReadable;aborted=!1;closed=!1;constructor(e,t){this.writable=e,this.writer=e.getWriter(),this.encoder=new TextEncoder;const n=t.getReader();this.abortSubscribers.push(async()=>{await n.cancel()}),this.responseReadable=new ReadableStream({async pull(s){const{done:i,value:r}=await n.read();i?s.close():s.enqueue(r)},cancel:()=>{this.closed||this.abort()}})}async write(e){try{typeof e=="string"&&(e=this.encoder.encode(e)),await this.writer.write(e)}catch{}return this}async writeln(e){return await this.write(e+`
202
- `),this}sleep(e){return new Promise(t=>setTimeout(t,e))}async close(){this.closed=!0;try{await this.writer.close()}catch{}}async pipe(e){this.writer.releaseLock();try{await e.pipeTo(this.writable,{preventClose:!0,preventAbort:!0})}finally{this.writer=this.writable.getWriter()}}onAbort(e){this.abortSubscribers.push(e)}abort(){this.aborted||(this.aborted=!0,this.abortSubscribers.forEach(e=>e()))}},Lp=()=>{const e=typeof Bun<"u"?Bun.version:void 0;if(e===void 0)return!1;const t=e.startsWith("1.1")||e.startsWith("1.0")||e.startsWith("0.");return Lp=()=>t,t},BE=class extends PE{constructor(e,t){super(e,t)}async writeSSE(e){const n=(await Lo(e.data,jp.Stringify,!1,{})).split(/\r\n|\r|\n/).map(i=>`data: ${i}`).join(`
201
+ `)},eE=e=>{const t=e.socket.encrypted?"https":"http",n=new URL(e.url??"/",`${t}://${e.headers.host??"localhost"}`),s=new Headers;for(const i in e.headers){const r=e.headers[i];r&&s.append(i,Array.isArray(r)?r[0]:r)}return new Request(n,{headers:s})},tE=e=>{const{server:t,fetchCallback:n,wss:s}=e,i=new Map;s.on("connection",(a,c)=>{const l=i.get(c);l&&(l.resolve(a),i.delete(c))});const r=a=>{const c=i.get(a);c&&(i.delete(a),c.reject(new Error("WebSocket handshake aborted")))},o=(a,c)=>new Promise((l,d)=>{i.set(a,{resolve:l,reject:d,connectionSymbol:c})});t.on("upgrade",async(a,c,l)=>{if(a.headers.upgrade?.toLowerCase()!=="websocket")return;const d={incoming:a,outgoing:void 0,wss:s,[Z$]:o};let u=400,p;try{const y=await n(eE(a),d);y instanceof Response&&(u=y.status,p=y.headers)}catch{t.listenerCount("upgrade")===1&&el(c,500);return}const f=i.get(a);if(!f||f.connectionSymbol!==d[X$]){r(a),t.listenerCount("upgrade")===1&&el(c,u,p);return}const h=y=>{Cp(y,p)},g=()=>r(a);c.once("close",g),s.on("headers",h);try{s.handleUpgrade(a,c,l,y=>{c.off("close",g),s.emit("connection",y,a)})}finally{s.off("headers",h)}}),t.on("close",()=>{s.close()})},nE=e=>{const t=e.fetch,n=Y$(t,{hostname:e.hostname,overrideGlobalObjects:e.overrideGlobalObjects,autoCleanupIncoming:e.autoCleanupIncoming}),s=(e.createServer||Ch)(e.serverOptions||{},n);if(e.websocket&&e.websocket.server){if(e.websocket.server.options.noServer!==!0)throw new Error("WebSocket server must be created with { noServer: true } option");tE({server:s,fetchCallback:t,wss:e.websocket.server})}return s},sE=(e,t)=>{const n=nE(e);return n.listen(e?.port??3e3,e.hostname,()=>{n.address()}),n};var tl=(e,t,n)=>(s,i)=>{let r=-1;return o(0);async function o(a){if(a<=r)throw new Error("next() called multiple times");r=a;let c,l=!1,d;if(e[a]?(d=e[a][0][0],s.req.routeIndex=a):d=a===e.length&&i||void 0,d)try{c=await d(s,()=>o(a+1))}catch(u){if(u instanceof Error&&t)s.error=u,c=await t(u,s),l=!0;else throw u}else s.finalized===!1&&n&&(c=await n(s));return c&&(s.finalized===!1||l)&&(s.res=c),s}},iE=Symbol(),rE=(e,t)=>new Response(e,{headers:{"Content-Type":t.replace(/^[^;]+/,s=>s.toLowerCase())}}).formData(),_s=e=>"headers"in e,oE=async(e,t=Object.create(null))=>{const{all:n=!1,dot:s=!1}=t,o=(_s(e)?e.headers:e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();return o==="multipart/form-data"||o==="application/x-www-form-urlencoded"?aE(e,{all:n,dot:s}):{}};async function aE(e,t){if(!_s(e)&&e.bodyCache.formData)return nl(await e.bodyCache.formData,t);const n=_s(e)?e.headers:e.raw.headers,s=await e.arrayBuffer(),i=rE(s,n.get("Content-Type")||"");_s(e)||(e.bodyCache.formData=i);const r=await i;return r?nl(r,t):{}}function nl(e,t){const n=Object.create(null);return e.forEach((s,i)=>{t.all||i.endsWith("[]")?cE(n,i,s):n[i]=s}),t.dot&&Object.entries(n).forEach(([s,i])=>{s.includes(".")&&(lE(n,s,i),delete n[s])}),n}var cE=(e,t,n)=>{e[t]!==void 0?Array.isArray(e[t])?e[t].push(n):e[t]=[e[t],n]:t.endsWith("[]")?e[t]=[n]:e[t]=n},lE=(e,t,n)=>{if(/(?:^|\.)__proto__\./.test(t))return;let s=e;const i=t.split(".");i.forEach((r,o)=>{o===i.length-1?s[r]=n:((!s[r]||typeof s[r]!="object"||Array.isArray(s[r])||s[r]instanceof File)&&(s[r]=Object.create(null)),s=s[r])})},Rp=e=>{const t=e.split("/");return t[0]===""&&t.shift(),t},dE=e=>{const{groups:t,path:n}=uE(e),s=Rp(n);return pE(s,t)},uE=e=>{const t=[];return e=e.replace(/\{[^}]+\}/g,(n,s)=>{const i=`@${s}`;return t.push([i,n]),i}),{groups:t,path:e}},pE=(e,t)=>{for(let n=t.length-1;n>=0;n--){const[s]=t[n];for(let i=e.length-1;i>=0;i--)if(e[i].includes(s)){e[i]=e[i].replace(s,t[n][1]);break}}return e},Ts={},fE=(e,t)=>{if(e==="*")return"*";const n=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){const s=`${e}#${t}`;return Ts[s]||(n[2]?Ts[s]=t&&t[0]!==":"&&t[0]!=="*"?[s,n[1],new RegExp(`^${n[2]}(?=/${t})`)]:[e,n[1],new RegExp(`^${n[2]}$`)]:Ts[s]=[e,n[1],!0]),Ts[s]}return null},Op=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,n=>{try{return t(n)}catch{return n}})}},hE=e=>Op(e,decodeURI),jp=e=>{const t=e.url,n=t.indexOf("/",t.indexOf(":")+4);let s=n;for(;s<t.length;s++){const i=t.charCodeAt(s);if(i===37){const r=t.indexOf("?",s),o=t.indexOf("#",s),a=r===-1?o===-1?void 0:o:o===-1?r:Math.min(r,o),c=t.slice(n,a);return hE(c.includes("%25")?c.replace(/%25/g,"%2525"):c)}else if(i===63||i===35)break}return t.slice(n,s)},gE=e=>{const t=jp(e);return t.length>1&&t.at(-1)==="/"?t.slice(0,-1):t},Et=(e,t,...n)=>(n.length&&(t=Et(t,...n)),`${e?.[0]==="/"?"":"/"}${e}${t==="/"?"":`${e?.at(-1)==="/"?"":"/"}${t?.[0]==="/"?t.slice(1):t}`}`),Tp=e=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(":"))return null;const t=e.split("/"),n=[];let s="";return t.forEach(i=>{if(i!==""&&!/\:/.test(i))s+="/"+i;else if(/\:/.test(i))if(/\?/.test(i)){n.length===0&&s===""?n.push("/"):n.push(s);const r=i.replace("?","");s+="/"+r,n.push(s)}else s+="/"+i}),n.filter((i,r,o)=>o.indexOf(i)===r)},Jr=e=>e.indexOf("%")!==-1?Op(e,vE):e,nr=e=>(e.indexOf("+")!==-1&&(e=e.replace(/\+/g," ")),Jr(e)),Ip=(e,t,n)=>{let s;if(!n&&t&&t.indexOf("%")===-1&&t.indexOf("+")===-1){let o=e.indexOf("?",8);if(o===-1)return;for(e.startsWith(t,o+1)||(o=e.indexOf(`&${t}`,o+1));o!==-1;){const a=e.charCodeAt(o+t.length+1);if(a===61){const c=o+t.length+2,l=e.indexOf("&",c);return nr(e.slice(c,l===-1?void 0:l))}else if(a==38||isNaN(a))return"";o=e.indexOf(`&${t}`,o+1)}if(s=/[%+]/.test(e),!s)return}const i=Object.create(null);s??=/[%+]/.test(e);let r=e.indexOf("?",8);for(;r!==-1;){const o=e.indexOf("&",r+1);let a=e.indexOf("=",r);a>o&&o!==-1&&(a=-1);let c=e.slice(r+1,a===-1?o===-1?void 0:o:a);if(s&&(c=nr(c)),r=o,c==="")continue;let l;a===-1?l="":(l=e.slice(a+1,o===-1?void 0:o),s&&(l=nr(l))),n?(i[c]&&Array.isArray(i[c])||(i[c]=[]),i[c].push(l)):i[c]??=l}return t?i[t]:i},mE=Ip,yE=(e,t)=>Ip(e,t,!0),vE=decodeURIComponent,bE=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,t="/",n=[[]]){this.raw=e,this.path=t,this.#t=n}param(e){return e?this.#n(e):this.#r()}#n(e){const t=this.#t[0][this.routeIndex][1][e],n=this.#s(t);return n&&Jr(n)}#r(){const e={},t=Object.keys(this.#t[0][this.routeIndex][1]);for(const n of t){const s=this.#s(this.#t[0][this.routeIndex][1][n]);s!==void 0&&(e[n]=Jr(s))}return e}#s(e){return this.#t[1]?this.#t[1][e]:e}query(e){return mE(this.url,e)}queries(e){return yE(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;const t=Object.create(null);return this.raw.headers.forEach((n,s)=>{t[s]=n}),t}async parseBody(e){return oE(this,e)}#i=e=>{const{bodyCache:t,raw:n}=this,s=t[e];if(s)return s;for(const i in t)return t[i].then(r=>(i==="json"&&(r=JSON.stringify(r)),new Response(r)[e]()));return t[e]=n[e]()};json(){return this.#i("text").then(e=>JSON.parse(e))}text(){return this.#i("text")}arrayBuffer(){return this.#i("arrayBuffer")}bytes(){return this.#i("arrayBuffer").then(e=>new Uint8Array(e))}blob(){return this.#i("blob")}formData(){return this.#i("formData")}addValidatedData(e,t){(this.#e??={})[e]=t}valid(e){return this.#e?.[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[iE](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}},Ap={Stringify:1},Mo=async(e,t,n,s,i)=>{typeof e=="object"&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));const r=e.callbacks;return r?.length?(i?i[0]+=e:i=[e],Promise.all(r.map(a=>a({phase:t,buffer:i,context:s}))).then(a=>Promise.all(a.filter(Boolean).map(c=>Mo(c,t,!1,s,i))).then(()=>i[0]))):Promise.resolve(e)},wE="text/plain; charset=UTF-8",sr=(e,t)=>({"Content-Type":e,...t}),Tn=(e,t)=>new Response(e,t),kE=class{#e;#t;env={};#n;finalized=!1;error;#r;#s;#i;#o;#a;#c;#l;#d;#p;constructor(e,t){this.#e=e,t&&(this.#s=t.executionCtx,this.env=t.env,this.#c=t.notFoundHandler,this.#p=t.path,this.#d=t.matchResult)}get req(){return this.#t??=new bE(this.#e,this.#p,this.#d),this.#t}get event(){if(this.#s&&"respondWith"in this.#s)return this.#s;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#s)return this.#s;throw Error("This context has no ExecutionContext")}get res(){return this.#i||=Tn(null,{headers:this.#l??=new Headers})}set res(e){if(this.#i&&e){e=Tn(e.body,e);for(const[t,n]of this.#i.headers.entries())if(t!=="content-type")if(t==="set-cookie"){const s=this.#i.headers.getSetCookie();e.headers.delete("set-cookie");for(const i of s)e.headers.append("set-cookie",i)}else e.headers.set(t,n)}this.#i=e,this.finalized=!0}render=(...e)=>(this.#a??=t=>this.html(t),this.#a(...e));setLayout=e=>this.#o=e;getLayout=()=>this.#o;setRenderer=e=>{this.#a=e};header=(e,t,n)=>{this.finalized&&(this.#i=Tn(this.#i.body,this.#i));const s=this.#i?this.#i.headers:this.#l??=new Headers;t===void 0?s.delete(e):n?.append?s.append(e,t):s.set(e,t)};status=e=>{this.#r=e};set=(e,t)=>{this.#n??=new Map,this.#n.set(e,t)};get=e=>this.#n?this.#n.get(e):void 0;get var(){return this.#n?Object.fromEntries(this.#n):{}}#u(e,t,n){let s=this.#i?new Headers(this.#i.headers):this.#l;if(typeof t=="object"&&t.headers){s??=new Headers;for(const[r,o]of new Headers(t.headers))r==="set-cookie"?s.append(r,o):s.set(r,o)}if(n){if(!s){let r=0;for(const o in n)if(++r>1||typeof n[o]!="string"){s=new Headers;break}}if(s)for(const r in n){const o=n[r];if(typeof o=="string")s.set(r,o);else{s.delete(r);for(const a of o)s.append(r,a)}}}const i=typeof t=="number"?t:t?.status??this.#r;return Tn(e,{status:i,headers:s??n})}newResponse=(...e)=>this.#u(...e);body=(e,t,n)=>this.#u(e,t,n);text=(e,t,n)=>!this.#l&&!this.#r&&!t&&!n&&!this.finalized?new Response(e):this.#u(e,t,sr(wE,n));json=(e,t,n)=>this.#u(JSON.stringify(e),t,sr("application/json",n));html=(e,t,n)=>{const s=i=>this.#u(i,t,sr("text/html; charset=UTF-8",n));return typeof e=="object"?Mo(e,Ap.Stringify,!1,{}).then(s):s(e)};redirect=(e,t)=>{const n=String(e);return this.header("Location",/[^\x00-\xFF]/.test(n)?encodeURI(n):n),this.newResponse(null,t??302)};notFound=()=>(this.#c??=()=>Tn(),this.#c(this))},ve="ALL",SE="all",xE=["get","post","put","delete","options","patch","query"],Bp="Can not add a route since the matcher is already built.",Pp=class extends Error{},$E="__COMPOSED_HANDLER",EE=e=>e.text("404 Not Found",404),sl=(e,t)=>{if("getResponse"in e){const n=e.getResponse();return t.newResponse(n.body,n)}return console.error(e),t.text("Internal Server Error",500)},CE=class Np{get;post;put;delete;options;patch;query;all;on;use;router;getPath;_basePath="/";#e="/";routes=[];constructor(t={}){[...xE,SE].forEach(r=>{this[r]=(o,...a)=>(typeof o=="string"?this.#e=o:this.#r(r,this.#e,o),a.forEach(c=>{this.#r(r,this.#e,c)}),this)}),this.on=(r,o,...a)=>{for(const c of[o].flat()){this.#e=c;for(const l of[r].flat())a.map(d=>{this.#r(l.toUpperCase(),this.#e,d)})}return this},this.use=(r,...o)=>(typeof r=="string"?this.#e=r:(this.#e="*",o.unshift(r)),o.forEach(a=>{this.#r(ve,this.#e,a)}),this);const{strict:s,...i}=t;Object.assign(this,i),this.getPath=s??!0?t.getPath??jp:gE}#t(){const t=new Np({router:this.router,getPath:this.getPath});return t.errorHandler=this.errorHandler,t.#n=this.#n,t.routes=this.routes,t}#n=EE;errorHandler=sl;route(t,n){const s=this.basePath(t);return n.routes.map(i=>{let r;n.errorHandler===sl?r=i.handler:(r=async(o,a)=>(await tl([],n.errorHandler)(o,()=>i.handler(o,a))).res,r[$E]=i.handler),s.#r(i.method,i.path,r,i.basePath)}),this}basePath(t){const n=this.#t();return n._basePath=Et(this._basePath,t),n}onError=t=>(this.errorHandler=t,this);notFound=t=>(this.#n=t,this);mount(t,n,s){let i,r;s&&(typeof s=="function"?r=s:(r=s.optionHandler,s.replaceRequest===!1?i=c=>c:i=s.replaceRequest));const o=r?c=>{const l=r(c);return Array.isArray(l)?l:[l]}:c=>{let l;try{l=c.executionCtx}catch{}return[c.env,l]};i||=(()=>{const c=Et(this._basePath,t),l=c==="/"?0:c.length;return d=>{const u=new URL(d.url);return u.pathname=this.getPath(d).slice(l)||"/",new Request(u,d)}})();const a=async(c,l)=>{const d=await n(i(c.req.raw),...o(c));if(d)return d;await l()};return this.#r(ve,Et(t,"*"),a),this}#r(t,n,s,i){t=t.toUpperCase(),n=Et(this._basePath,n);const r={basePath:i!==void 0?Et(this._basePath,i):this._basePath,path:n,method:t,handler:s};this.router.add(t,n,[s,r]),this.routes.push(r)}#s(t,n){if(t instanceof Error)return this.errorHandler(t,n);throw t}#i(t,n,s,i){if(i==="HEAD")return(async()=>new Response(null,await this.#i(t,n,s,"GET")))();const r=this.getPath(t,{env:s}),o=this.router.match(i,r),a=new kE(t,{path:r,matchResult:o,env:s,executionCtx:n,notFoundHandler:this.#n});if(o[0].length===1){let l;try{l=o[0][0][0][0](a,async()=>{a.res=await this.#n(a)})}catch(d){return this.#s(d,a)}return l instanceof Promise?l.then(d=>d||(a.finalized?a.res:this.#n(a))).catch(d=>this.#s(d,a)):l??this.#n(a)}const c=tl(o[0],this.errorHandler,this.#n);return(async()=>{try{const l=await c(a);if(!l.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#s(l,a)}})()}fetch=(t,...n)=>this.#i(t,n[1],n[0],t.method);request=(t,n,s,i)=>t instanceof Request?this.fetch(n?new Request(t,n):t,s,i):(t=t.toString(),this.fetch(new Request(/^https?:\/\//.test(t)?t:`http://localhost${Et("/",t)}`,n),s,i));fire=()=>{addEventListener("fetch",t=>{t.respondWith(this.#i(t.request,t,void 0,t.request.method))})}},Dp=[];function RE(e,t){const n=this.buildAllMatchers(),s=((i,r)=>{const o=n[i]||n[ve],a=o[2][r];if(a)return a;const c=r.match(o[0]);if(!c)return[[],Dp];const l=c.indexOf("",1);return[o[1][l],c]});return this.match=s,s(e,t)}var ni="[^/]+",sn=".*",Ot="(?:|/.*)",Ct=Symbol(),il=new Set(".\\+*[^]$()");function OE(e,t){return e.length===1?t.length===1?e<t?-1:1:-1:t.length===1?1:e===sn||e===Ot?t===Ot?-1:1:t===sn||t===Ot?-1:e===ni?1:t===ni?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var jE=class qr{#e;#t;#n=Object.create(null);insert(t,n,s,i,r){let o=this;for(let a=0,c=t.length;a<c;a++){const l=t[a],d=l.length===1?l==="*"?a===c-1?["","",sn]:["","",ni]:null:l==="/*"?["","",Ot]:l.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);let u;if(d){const p=d[1];let f=d[2]||ni;if(p&&d[2]&&(f===".*"||(f=f.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(f))||f.length===1&&il.has(f)))throw Ct;if(u=o.#n[f],!u){if(f!==sn&&f!==Ot){for(const h in o.#n)if((f.length>1||h.length>1)&&h!==sn&&h!==Ot)throw Ct}u=o.#n[f]=new qr}p!==""&&(u.#t??=i.varIndex++,s.push([p,u.#t]))}else if(u=o.#n[l],!u){for(const p in o.#n)if(p.length>1&&p!==sn&&p!==Ot)throw Ct;u=o.#n[l]=new qr}o=u}if(o.#e!==void 0)throw Ct;o.#e=r?-1:n}buildRegExpStr(){const n=Object.keys(this.#n).sort(OE).map(s=>{const i=this.#n[s],r=i.buildRegExpStr();return r===""?"":(typeof i.#t=="number"?`(${s})@${i.#t}`:il.has(s)?`\\${s}`:s)+r}).filter(Boolean);return typeof this.#e=="number"&&this.#e!==-1&&n.unshift(`#${this.#e}`),n.length===0?"":n.length===1?n[0]:"(?:"+n.join("|")+")"}},rl=class{#e={varIndex:0};#t=new jE;#n=0;paths=Object.create(null);insert(e,t){if(t){this.#t.insert(e.split(""),0,[],this.#e,!0);return}const n=[],s=[];let i=e;for(let o=0;;){let a=!1;if(i=i.replace(/\{[^}]+\}/g,c=>{const l=`@\\${o}`;return s[o]=[l,c],o++,a=!0,l}),!a)break}const r=i.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let o=s.length-1;o>=0;o--){const[a]=s[o];for(let c=r.length-1;c>=0;c--)if(r[c].indexOf(a)!==-1){r[c]=r[c].replace(a,s[o][1]);break}}this.#t.insert(r,this.#n,n,this.#e,!1),this.paths[e]=[this.#n++,n]}buildRegExp(){let e=this.#t.buildRegExpStr();if(e==="")return[/^$/,[],[]];let t=0;const n=[],s=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,r,o)=>r!==void 0?(n[++t]=Number(r),"$()"):(o!==void 0&&(s[Number(o)]=++t),"")),[new RegExp(`^${e}`),n,s]}},Lp=Object.create(null);function Mp(e){return Lp[e]??=new RegExp(e==="*"?"":`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(t,n)=>n?`\\${n}`:"(?:|/.*)")}$`)}function TE(){Lp=Object.create(null)}function Is(e,t){if(e){for(const n of Object.keys(e).sort((s,i)=>i.length-s.length))if(Mp(n).test(t))return[...e[n]]}}var IE=class{name="RegExpRouter";#e;#t;#n;constructor(){this.#e={[ve]:Object.create(null)},this.#t={[ve]:Object.create(null)},this.#n={[ve]:new rl}}#r(e,t){try{this.#n[e].insert(t,!/\*|\/:/.test(t))}catch(n){throw n===Ct?new Pp(t):n}}add(e,t,n){const s=this.#e,i=this.#t;if(!s||!i)throw new Error(Bp);s[e]||(this.#n[e]=new rl,[s,i].forEach(a=>{a[e]=Object.create(null),Object.keys(a[ve]).forEach(c=>{a[e][c]=[...a[ve][c]],this.#r(e,c)})})),t==="/*"&&(t="*");const r=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){const a=Mp(t);Object.keys(s).forEach(c=>{(e===ve||e===c)&&!s[c][t]&&(this.#r(c,t),s[c][t]=Is(s[c],t)||Is(s[ve],t)||[])}),Object.keys(s).forEach(c=>{(e===ve||e===c)&&Object.keys(s[c]).forEach(l=>{a.test(l)&&s[c][l].push([n,r])})}),Object.keys(i).forEach(c=>{(e===ve||e===c)&&Object.keys(i[c]).forEach(l=>a.test(l)&&i[c][l].push([n,r]))});return}const o=Tp(t)||[t];for(let a=0,c=o.length;a<c;a++){const l=o[a];Object.keys(i).forEach(d=>{(e===ve||e===d)&&(i[d][l]||(this.#r(d,l),i[d][l]=[...Is(s[d],l)||Is(s[ve],l)||[]]),i[d][l].push([n,r-c+a+1]))})}}match=RE;buildAllMatchers(){const e=Object.create(null);return Object.keys(this.#t).concat(Object.keys(this.#e)).forEach(t=>{e[t]||=this.#s(t)}),this.#e=this.#t=this.#n=void 0,TE(),e}#s(e){const t=this.#e[e],n=this.#t[e],s=this.#n[e],i=Object.create(null),r=[];[t,n].forEach(d=>{for(const u in d){const p=d[u],f=s.paths[u];if(!f){i[u]=[p.map(([g])=>[g,Object.create(null)]),Dp];continue}const h=f[1];r[f[0]]=p.map(([g,y])=>{const x=Object.create(null);for(y-=1;y>=0;y--){const[b,S]=h[y];x[b]=S}return[g,x]})}});const[o,a,c]=s.buildRegExp();for(let d=0,u=r.length;d<u;d++)for(let p=0,f=r[d].length;p<f;p++){const h=r[d][p]?.[1];if(!h)continue;const g=Object.keys(h);for(let y=0,x=g.length;y<x;y++)h[g[y]]=c[h[g[y]]]}const l=[];for(const d in a)l[d]=r[a[d]];return[o,l,i]}},AE=class{name="SmartRouter";#e=[];#t=[];constructor(e){this.#e=e.routers}add(e,t,n){if(!this.#t)throw new Error(Bp);this.#t.push([e,t,n])}match(e,t){if(!this.#t)throw new Error("Fatal error");const n=this.#e,s=this.#t,i=n.length;let r=0,o;for(;r<i;r++){const a=n[r];try{for(let c=0,l=s.length;c<l;c++)a.add(...s[c]);o=a.match(e,t)}catch(c){if(c instanceof Pp)continue;throw c}this.match=a.match.bind(a),this.#e=[a],this.#t=void 0;break}if(r===i)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,o}get activeRouter(){if(this.#t||this.#e.length!==1)throw new Error("No active router has been determined yet.");return this.#e[0]}},In=Object.create(null),BE=e=>{for(const t in e)return!0;return!1},PE=class _p{#e;#t;#n;#r=0;#s=In;constructor(t,n,s){if(this.#t=s||Object.create(null),this.#e=[],t&&n){const i=Object.create(null);i[t]={handler:n,possibleKeys:[],score:0},this.#e=[i]}this.#n=[]}insert(t,n,s){this.#r=++this.#r;let i=this;const r=dE(n),o=[];for(let a=0,c=r.length;a<c;a++){const l=r[a],d=r[a+1],u=fE(l,d),p=Array.isArray(u)?u[0]:l;if(p in i.#t){i=i.#t[p],u&&o.push(u[1]);continue}i.#t[p]=new _p,u&&(i.#n.push(u),o.push(u[1])),i=i.#t[p]}return i.#e.push({[t]:{handler:s,possibleKeys:o.filter((a,c,l)=>l.indexOf(a)===c),score:this.#r}}),i}#i(t,n,s,i,r){for(let o=0,a=n.#e.length;o<a;o++){const c=n.#e[o],l=c[s]||c[ve],d={};if(l!==void 0&&(l.params=Object.create(null),t.push(l),i!==In||r&&r!==In))for(let u=0,p=l.possibleKeys.length;u<p;u++){const f=l.possibleKeys[u],h=d[l.score];l.params[f]=r?.[f]&&!h?r[f]:i[f]??r?.[f],d[l.score]=!0}}}search(t,n){const s=[];this.#s=In;let r=[this];const o=Rp(n),a=[],c=o.length;let l=null;for(let d=0;d<c;d++){const u=o[d],p=d===c-1,f=[];for(let g=0,y=r.length;g<y;g++){const x=r[g],b=x.#t[u];b&&(b.#s=x.#s,p?(b.#t["*"]&&this.#i(s,b.#t["*"],t,x.#s),this.#i(s,b,t,x.#s)):f.push(b));for(let S=0,C=x.#n.length;S<C;S++){const N=x.#n[S],T=x.#s===In?{}:{...x.#s};if(N==="*"){const re=x.#t["*"];re&&(this.#i(s,re,t,x.#s),re.#s=T,f.push(re));continue}const[D,F,V]=N;if(!u&&!(V instanceof RegExp))continue;const Z=x.#t[D];if(V instanceof RegExp){if(l===null){l=new Array(c);let ne=n[0]==="/"?1:0;for(let ie=0;ie<c;ie++)l[ie]=ne,ne+=o[ie].length+1}const re=n.substring(l[d]),te=V.exec(re);if(te){if(T[F]=te[0],this.#i(s,Z,t,x.#s,T),te[0].length===re.length&&Z.#t["*"]&&this.#i(s,Z.#t["*"],t,x.#s,T),BE(Z.#t)){Z.#s=T;const ne=te[0].match(/\//g)?.length??0;(a[ne]||=[]).push(Z)}continue}}(V===!0||V.test(u))&&(T[F]=u,p?(this.#i(s,Z,t,T,x.#s),Z.#t["*"]&&this.#i(s,Z.#t["*"],t,T,x.#s)):(Z.#s=T,f.push(Z)))}}const h=a.shift();r=h?f.concat(h):f}return s.length>1&&s.sort((d,u)=>d.score-u.score),[s.map(({handler:d,params:u})=>[d,u])]}},NE=class{name="TrieRouter";#e;constructor(){this.#e=new PE}add(e,t,n){const s=Tp(t);if(s){for(let i=0,r=s.length;i<r;i++)this.#e.insert(e,s[i],n);return}this.#e.insert(e,t,n)}match(e,t){return this.#e.search(e,t)}},DE=class extends CE{constructor(e={}){super(e),this.router=e.router??new AE({routers:[new IE,new NE]})}},LE=class{writer;encoder;writable;abortSubscribers=[];responseReadable;aborted=!1;closed=!1;constructor(e,t){this.writable=e,this.writer=e.getWriter(),this.encoder=new TextEncoder;const n=t.getReader();this.abortSubscribers.push(async()=>{await n.cancel()}),this.responseReadable=new ReadableStream({async pull(s){const{done:i,value:r}=await n.read();i?s.close():s.enqueue(r)},cancel:()=>{this.closed||this.abort()}})}async write(e){try{typeof e=="string"&&(e=this.encoder.encode(e)),await this.writer.write(e)}catch{}return this}async writeln(e){return await this.write(e+`
202
+ `),this}sleep(e){return new Promise(t=>setTimeout(t,e))}async close(){this.closed=!0;try{await this.writer.close()}catch{}}async pipe(e){this.writer.releaseLock();try{await e.pipeTo(this.writable,{preventClose:!0,preventAbort:!0})}finally{this.writer=this.writable.getWriter()}}onAbort(e){this.abortSubscribers.push(e)}abort(){this.aborted||(this.aborted=!0,this.abortSubscribers.forEach(e=>e()))}},Fp=()=>{const e=typeof Bun<"u"?Bun.version:void 0;if(e===void 0)return!1;const t=e.startsWith("1.1")||e.startsWith("1.0")||e.startsWith("0.");return Fp=()=>t,t},ME=class extends LE{constructor(e,t){super(e,t)}async writeSSE(e){const n=(await Mo(e.data,Ap.Stringify,!1,{})).split(/\r\n|\r|\n/).map(i=>`data: ${i}`).join(`
203
203
  `);for(const i of["event","id"]){const r=e[i];if(r&&/[\r\n]/.test(r))throw new Error(`${i} must not contain "\\r" or "\\n"`)}const s=[e.event&&`event: ${e.event}`,n,e.id!==void 0&&`id: ${e.id}`,e.retry!==void 0&&`retry: ${e.retry}`].filter(Boolean).join(`
204
204
  `)+`
205
205
 
206
- `;await this.write(s)}},NE=async(e,t,n)=>{try{await t(e)}catch(s){console.error(s)}finally{e.close()}},DE=new WeakMap,LE=(e,t,n)=>{const{readable:s,writable:i}=new TransformStream,r=new BE(i,s);return Lp()&&e.req.raw.signal.addEventListener("abort",()=>{r.closed||r.abort()}),DE.set(r.responseReadable,e),e.header("Transfer-Encoding","chunked"),e.header("Content-Type","text/event-stream"),e.header("Cache-Control","no-cache"),e.header("Connection","keep-alive"),NE(r,t),e.newResponse(r.responseReadable)};const ln=(1n<<128n)-1n,q=(1n<<64n)-1n,is=(1n<<32n)-1n,Mp=0x9E3779B1n,_p=0x85EBCA77n,ME=0xC2B2AE3Dn,pt=0x9E3779B185EBCA87n,Lt=0xC2B2AE3D27D4EB4Fn,Fp=0x165667B19E3779F9n,Mo=0x85EBCA77C2B2AE63n,_E=0x27D4EB2F165667C5n,FE=0x165667919E3779F9n,VE=0x9FB21C651E98DF25n,ze=64,Vp=ze/8,WE=8,je=Buffer.from("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e","hex"),HE=e=>{let t=e&q;return t=(t&0x00000000FFFFFFFFn)<<32n|(t&0xFFFFFFFF00000000n)>>32n,t=(t&0x0000FFFF0000FFFFn)<<16n|(t&0xFFFF0000FFFF0000n)>>16n,t=(t&0x00FF00FF00FF00FFn)<<8n|(t&0xFF00FF00FF00FF00n)>>8n,t&q},Wp=e=>{let t=e;return t=(t&0x0000FFFFn)<<16n|(t&0xFFFF0000n)>>16n,t=(t&0x00FF00FFn)<<8n|(t&0xFF00FF00n)>>8n,t},UE=(e,t)=>(e&is)*(t&is)&q,GE=(e,t)=>(e<<t|e>>32n-t)&is,qr=(e,t)=>e^e>>t,Kr=e=>~e+1n&q,Hp=(e,t)=>{const n=e*t&ln;return n&q^n>>64n},_e=e=>{let t=e;return t^=t>>37n,t=t*FE&q,t^=t>>32n,t},ni=e=>{let t=e;return t^=t>>33n,t=t*Lt&q,t^=t>>29n,t=t*Fp&q,t^=t>>32n,t},Up=(e,t,n,s=0,i=0)=>{for(let r=0;r<Vp;r++){const o=t.readBigUInt64LE(s+r*8),a=o^n.readBigUInt64LE(i+r*8);e[r^1]+=o,e[r]+=UE(a,a>>32n)}return e},sl=(e,t,n,s,i=0)=>{for(let r=0;r<s;r++)Up(e,t,n,i+r*ze,r*8);return e},zE=(e,t,n=0)=>{for(let s=0;s<Vp;s++){const i=t.readBigUInt64LE(n+s*8);let r=e[s];r=qr(r,47n),r^=i,r*=Mp,e[s]=r&q}return e},Ts=(e,t,n,s)=>Hp(e[t]^n.readBigUInt64LE(s),e[t+1]^n.readBigUInt64LE(s+WE)),il=(e,t,n,s)=>{let i=s;return i+=Ts(e,0,t,n+0),i+=Ts(e,2,t,n+16),i+=Ts(e,4,t,n+32),i+=Ts(e,6,t,n+48),_e(i&q)},JE=(e,t,n)=>{const s=Math.floor((n.byteLength-ze)/8),i=ze*s,r=Math.floor((t.byteLength-1)/i);for(let a=0;a<r;a++)sl(e,t,n,s,a*i),zE(e,n,n.byteLength-ze);const o=Math.floor((t.byteLength-1-i*r)/ze);return sl(e,t,n,o,r*i),Up(e,t,n,t.byteLength-ze,n.byteLength-ze-7),e},qE=e=>{const t=Buffer.from(je),n=je.byteLength>>4;for(let s=0;s<n;s++){const i=t.readBigUInt64LE(s*16)+e&q,r=t.readBigUInt64LE(s*16+8)-e&q;t.writeBigUInt64LE(i,s*16),t.writeBigUInt64LE(r,s*16+8)}return t},KE=(e,t)=>{const n=new BigUint64Array([ME,pt,Lt,Fp,Mo,_p,_E,Mp]);JE(n,e,t);const s=il(n,t,11,BigInt(e.byteLength)*pt&q);return il(n,t,t.byteLength-ze-11,~(BigInt(e.byteLength)*Lt)&q)<<64n|s},rl=(e,t,n,s,i)=>Hp((e.readBigUInt64LE(t)^n.readBigUInt64LE(s)+i)&q,(e.readBigUInt64LE(t+8)^n.readBigUInt64LE(s+8)-i)&q),_s=(e,t,n,s,i,r,o)=>{let a=e&q,c=e>>64n&q;return a+=rl(t,n,i,r,o),a^=t.readBigUInt64LE(s)+t.readBigUInt64LE(s+8),a&=q,c+=rl(t,s,i,r+16,o),c^=t.readBigUInt64LE(n)+t.readBigUInt64LE(n+8),c&=q,c<<64n|a},YE=(e,t,n)=>{const s=e.byteLength,i=BigInt(e.readUInt8(s-1))|BigInt(s)<<8n|BigInt(e.readUInt8(0))<<16n|BigInt(e.readUInt8(s>>1))<<24n,r=(BigInt(t.readUInt32LE(0))^BigInt(t.readUInt32LE(4)))+n,o=(i^r)&q,a=(BigInt(t.readUInt32LE(8))^BigInt(t.readUInt32LE(12)))-n,c=(GE(Wp(i),13n)^a)&q;return(ni(c)&q)<<64n|ni(o)},XE=(e,t,n)=>{const s=e.byteLength;n=(n^Wp(n&is)<<32n)&q;const i=e.readUInt32LE(0),r=e.readUInt32LE(s-4),o=BigInt(i)|BigInt(r)<<32n,a=(t.readBigUInt64LE(16)^t.readBigUInt64LE(24))+n&q;let l=(o^a)*(pt+(BigInt(s)<<2n))&ln;return l+=(l&q)<<65n,l&=ln,l^=l>>67n,qr(qr(l&q,35n)*VE&q,28n)|_e(l>>64n)<<64n},ZE=(e,t,n)=>{const s=e.byteLength,i=(t.readBigUInt64LE(32)^t.readBigUInt64LE(40))-n&q,r=(t.readBigUInt64LE(48)^t.readBigUInt64LE(56))+n&q,o=e.readBigUInt64LE();let a=e.readBigUInt64LE(s-8),c=(o^a^i)*pt;const l=(c&q)+(BigInt(s-1)<<54n);c=c&(ln^q)|l,a^=r,c+=a+(a&is)*(_p-1n)<<64n,c&=ln,c^=HE(c>>64n);let d=(c&q)*Lt;return d+=(c>>64n)*Lt<<64n,d&=ln,_e(d&q)|_e(d>>64n)<<64n},QE=(e,t)=>{const n=e.byteLength;return n>8?ZE(e,je,t):n>=4?XE(e,je,t):n>0?YE(e,je,t):ni(t^je.readBigUInt64LE(64)^je.readBigUInt64LE(72))|ni(t^je.readBigUInt64LE(80)^je.readBigUInt64LE(88))<<64n},eC=(e,t,n)=>{let s=BigInt(e.byteLength)*pt&q,i=BigInt(e.byteLength-1)/32n;for(;i>=0n;){const a=Number(i);s=_s(s,e,16*a,e.byteLength-16*(a+1),t,32*a,n),i--}let r=s+(s>>64n)&q;r=_e(r);let o=(s&q)*pt+(s>>64n)*Mo+(BigInt(e.byteLength)-n&q)*Lt;return o&=q,o=Kr(_e(o)),r|o<<64n},tC=(e,t,n)=>{let s=BigInt(e.byteLength)*pt&q;for(let o=32;o<160;o+=32)s=_s(s,e,o-32,o-16,t,o-32,n);s=_e(s&q)|_e(s>>64n)<<64n;for(let o=160;o<=e.byteLength;o+=32)s=_s(s,e,o-32,o-16,t,3+o-160,n);s=_s(s,e,e.byteLength-16,e.byteLength-32,t,103,Kr(n));let i=s+(s>>64n)&q;i=_e(i);let r=(s&q)*pt+(s>>64n)*Mo+(BigInt(e.byteLength)-n&q)*Lt;return r&=q,r=Kr(_e(r)),i|r<<64n},nC=(e,t=0n)=>{const n=e.byteLength;return n<=16?QE(e,t):n<=128?eC(e,je,t):n<=240?tC(e,je,t):KE(e,t===0n?je:qE(t))},sC=e=>{const t=e>>64n&q,n=e&q;return t.toString(16).padStart(16,"0")+n.toString(16).padStart(16,"0")},Gp=(e,t=0n)=>sC(nC(typeof e=="string"?Buffer.from(e):e,BigInt.asUintN(64,t))),_t=()=>m(hh(),"ai"),iC=3600*1e3,rC=1800*1e3,zp=()=>{gt(_t())},Jp=(e,t)=>{const n=`${e}.${String(process.pid)}.${Eh()}.tmp`;try{ce(n,t,"utf8"),ml(n,e)}catch(s){try{ht(n)}catch{}throw s}},R4=(e,t,n)=>{const s=n.map(r=>({currentRange:r.currentRange,name:r.packageName,targetVersion:r.targetVersion})).toSorted((r,o)=>r.name.localeCompare(o.name)),i=JSON.stringify({analysisType:t,packages:s,provider:e});return Gp(Buffer.from(i))},O4=e=>{const t=m(_t(),`${e}.json`);if($(t))try{const n=de(t);if(Date.now()-n.createdAt>n.ttlMs){un(t,{force:!0});return}return n.result}catch{un(t,{force:!0});return}},j4=(e,t,n)=>{zp();const s=_t(),i={createdAt:Date.now(),result:t,ttlMs:n};Jp(m(s,`${e}.json`),JSON.stringify(i,void 0,2))},T4=(e,t)=>t!==void 0&&t>0?t:e==="security"?rC:iC,Yr=()=>{const e=_t();if(!$(e))return{entries:0,newestEntry:void 0,oldestEntry:void 0,totalSizeBytes:0};const t=Ee(e).filter(r=>r.endsWith(".json"));let n=0,s,i;for(const r of t){const o=m(e,r),a=At(o);n+=a.size;const{mtimeMs:c}=a;(s===void 0||c<s)&&(s=c),(i===void 0||c>i)&&(i=c)}return{entries:t.length,newestEntry:i,oldestEntry:s,totalSizeBytes:n}},I4=e=>Gp(Buffer.from(JSON.stringify(e))),A4=e=>{const t=m(_t(),`${e}.json`);if($(t))try{const n=de(t);if(Date.now()-n.createdAt>n.ttlMs){un(t,{force:!0});return}return n.result}catch{un(t,{force:!0});return}},P4=(e,t,n)=>{zp();const s=_t(),i={createdAt:Date.now(),result:t,ttlMs:n};Jp(m(s,`${e}.json`),JSON.stringify(i,void 0,2))},oC=()=>{const e=_t();if(!$(e))return 0;const t=Ee(e).filter(n=>n.endsWith(".json"));for(const n of t)un(m(e,n),{force:!0});return t.length},Xr=(e,t)=>e.tasks.find(n=>n.taskId===t),sr=(e,t)=>{const n=e??{},s=t??{},i=[],r=[],o=[];for(const a of Object.keys(n))a in s?n[a]!==s[a]&&o.push(a):i.push(a);for(const a of Object.keys(s))a in n||r.push(a);return i.sort(),r.sort(),o.sort(),{added:i,changed:o,removed:r}},aC=(e,t)=>({commandChanged:(e?.command??"")!==(t?.command??""),implicitDeps:sr(e?.implicitDeps,t?.implicitDeps),nodes:sr(e?.nodes,t?.nodes),runtime:sr(e?.runtime,t?.runtime)}),qp=async(e,t)=>{const n=m(yt(e),`${t}.json`);try{const s=await $l(n,"utf8");return JSON.parse(s)}catch{return}},cC=async(e,t)=>{const n=yt(e);let s;try{s=await os(n)}catch{return}const i=[];for(const r of s){if(!r.endsWith(".json")||t!==void 0&&r===`${t}.json`)continue;const o=m(n,r);try{const a=await mn(o);a.isFile()&&i.push({mtimeMs:a.mtimeMs,path:o})}catch{}}if(i.length!==0){i.sort((r,o)=>o.mtimeMs-r.mtimeMs);try{const r=await $l(i[0].path,"utf8");return JSON.parse(r)}catch{return}}},B4=async e=>{const t=yt(e);let n;try{n=await os(t)}catch{return[]}const s=[];for(const i of n){if(!i.endsWith(".json"))continue;const r=m(t,i);try{const o=await mn(r);o.isFile()&&s.push({id:i.slice(0,-5),mtimeMs:o.mtimeMs,path:r})}catch{}}return s.sort((i,r)=>r.mtimeMs-i.mtimeMs),s},Kp=async e=>{let t=0;try{const n=await os(e,{withFileTypes:!0});for(const s of n){const i=m(e,s.name);if(s.isDirectory())t+=await Kp(i);else if(s.isFile()){const r=await mn(i);t+=r.size}}}catch{}return t},ft=async e=>{const t=[];let n;try{n=await os(e)}catch{return[]}for(const s of n){if(s.startsWith("."))continue;const i=m(e,s);try{const r=await mn(i);if(!r.isDirectory())continue;const o=await Kp(i);t.push({hash:s,mtimeMs:r.mtimeMs,path:i,sizeBytes:o})}catch{}}return t.sort((s,i)=>i.mtimeMs-s.mtimeMs),t},Yp=(e,t=Date.now())=>{const n=Math.max(0,Math.floor((t-e)/1e3));return n<60?`${String(n)}s`:n<3600?`${String(Math.floor(n/60))}m`:n<86400?`${String(Math.floor(n/3600))}h`:`${String(Math.floor(n/86400))}d`},lC=e=>new Promise(t=>{const n=bl({input:process.stdin,output:process.stderr});n.question(`${e} (y/N) `,s=>{n.close();const i=s.trim().toLowerCase();t(i==="y"||i==="yes")})}),Xp=async(e,t,n)=>{if(!$(e)){if(t==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
207
- `);return}E.info(`No cache directory found at ${e}`);return}const s=await ft(e);if(s.length===0){if(t==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
206
+ `;await this.write(s)}},_E=async(e,t,n)=>{try{await t(e)}catch(s){console.error(s)}finally{e.close()}},FE=new WeakMap,VE=(e,t,n)=>{const{readable:s,writable:i}=new TransformStream,r=new ME(i,s);return Fp()&&e.req.raw.signal.addEventListener("abort",()=>{r.closed||r.abort()}),FE.set(r.responseReadable,e),e.header("Transfer-Encoding","chunked"),e.header("Content-Type","text/event-stream"),e.header("Cache-Control","no-cache"),e.header("Connection","keep-alive"),_E(r,t),e.newResponse(r.responseReadable)};const dn=(1n<<128n)-1n,q=(1n<<64n)-1n,os=(1n<<32n)-1n,Vp=0x9E3779B1n,Wp=0x85EBCA77n,WE=0xC2B2AE3Dn,ft=0x9E3779B185EBCA87n,Mt=0xC2B2AE3D27D4EB4Fn,Hp=0x165667B19E3779F9n,_o=0x85EBCA77C2B2AE63n,HE=0x27D4EB2F165667C5n,UE=0x165667919E3779F9n,GE=0x9FB21C651E98DF25n,ze=64,Up=ze/8,zE=8,je=Buffer.from("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e","hex"),JE=e=>{let t=e&q;return t=(t&0x00000000FFFFFFFFn)<<32n|(t&0xFFFFFFFF00000000n)>>32n,t=(t&0x0000FFFF0000FFFFn)<<16n|(t&0xFFFF0000FFFF0000n)>>16n,t=(t&0x00FF00FF00FF00FFn)<<8n|(t&0xFF00FF00FF00FF00n)>>8n,t&q},Gp=e=>{let t=e;return t=(t&0x0000FFFFn)<<16n|(t&0xFFFF0000n)>>16n,t=(t&0x00FF00FFn)<<8n|(t&0xFF00FF00n)>>8n,t},qE=(e,t)=>(e&os)*(t&os)&q,KE=(e,t)=>(e<<t|e>>32n-t)&os,Kr=(e,t)=>e^e>>t,Yr=e=>~e+1n&q,zp=(e,t)=>{const n=e*t&dn;return n&q^n>>64n},_e=e=>{let t=e;return t^=t>>37n,t=t*UE&q,t^=t>>32n,t},si=e=>{let t=e;return t^=t>>33n,t=t*Mt&q,t^=t>>29n,t=t*Hp&q,t^=t>>32n,t},Jp=(e,t,n,s=0,i=0)=>{for(let r=0;r<Up;r++){const o=t.readBigUInt64LE(s+r*8),a=o^n.readBigUInt64LE(i+r*8);e[r^1]+=o,e[r]+=qE(a,a>>32n)}return e},ol=(e,t,n,s,i=0)=>{for(let r=0;r<s;r++)Jp(e,t,n,i+r*ze,r*8);return e},YE=(e,t,n=0)=>{for(let s=0;s<Up;s++){const i=t.readBigUInt64LE(n+s*8);let r=e[s];r=Kr(r,47n),r^=i,r*=Vp,e[s]=r&q}return e},As=(e,t,n,s)=>zp(e[t]^n.readBigUInt64LE(s),e[t+1]^n.readBigUInt64LE(s+zE)),al=(e,t,n,s)=>{let i=s;return i+=As(e,0,t,n+0),i+=As(e,2,t,n+16),i+=As(e,4,t,n+32),i+=As(e,6,t,n+48),_e(i&q)},XE=(e,t,n)=>{const s=Math.floor((n.byteLength-ze)/8),i=ze*s,r=Math.floor((t.byteLength-1)/i);for(let a=0;a<r;a++)ol(e,t,n,s,a*i),YE(e,n,n.byteLength-ze);const o=Math.floor((t.byteLength-1-i*r)/ze);return ol(e,t,n,o,r*i),Jp(e,t,n,t.byteLength-ze,n.byteLength-ze-7),e},ZE=e=>{const t=Buffer.from(je),n=je.byteLength>>4;for(let s=0;s<n;s++){const i=t.readBigUInt64LE(s*16)+e&q,r=t.readBigUInt64LE(s*16+8)-e&q;t.writeBigUInt64LE(i,s*16),t.writeBigUInt64LE(r,s*16+8)}return t},QE=(e,t)=>{const n=new BigUint64Array([WE,ft,Mt,Hp,_o,Wp,HE,Vp]);XE(n,e,t);const s=al(n,t,11,BigInt(e.byteLength)*ft&q);return al(n,t,t.byteLength-ze-11,~(BigInt(e.byteLength)*Mt)&q)<<64n|s},cl=(e,t,n,s,i)=>zp((e.readBigUInt64LE(t)^n.readBigUInt64LE(s)+i)&q,(e.readBigUInt64LE(t+8)^n.readBigUInt64LE(s+8)-i)&q),Fs=(e,t,n,s,i,r,o)=>{let a=e&q,c=e>>64n&q;return a+=cl(t,n,i,r,o),a^=t.readBigUInt64LE(s)+t.readBigUInt64LE(s+8),a&=q,c+=cl(t,s,i,r+16,o),c^=t.readBigUInt64LE(n)+t.readBigUInt64LE(n+8),c&=q,c<<64n|a},eC=(e,t,n)=>{const s=e.byteLength,i=BigInt(e.readUInt8(s-1))|BigInt(s)<<8n|BigInt(e.readUInt8(0))<<16n|BigInt(e.readUInt8(s>>1))<<24n,r=(BigInt(t.readUInt32LE(0))^BigInt(t.readUInt32LE(4)))+n,o=(i^r)&q,a=(BigInt(t.readUInt32LE(8))^BigInt(t.readUInt32LE(12)))-n,c=(KE(Gp(i),13n)^a)&q;return(si(c)&q)<<64n|si(o)},tC=(e,t,n)=>{const s=e.byteLength;n=(n^Gp(n&os)<<32n)&q;const i=e.readUInt32LE(0),r=e.readUInt32LE(s-4),o=BigInt(i)|BigInt(r)<<32n,a=(t.readBigUInt64LE(16)^t.readBigUInt64LE(24))+n&q;let l=(o^a)*(ft+(BigInt(s)<<2n))&dn;return l+=(l&q)<<65n,l&=dn,l^=l>>67n,Kr(Kr(l&q,35n)*GE&q,28n)|_e(l>>64n)<<64n},nC=(e,t,n)=>{const s=e.byteLength,i=(t.readBigUInt64LE(32)^t.readBigUInt64LE(40))-n&q,r=(t.readBigUInt64LE(48)^t.readBigUInt64LE(56))+n&q,o=e.readBigUInt64LE();let a=e.readBigUInt64LE(s-8),c=(o^a^i)*ft;const l=(c&q)+(BigInt(s-1)<<54n);c=c&(dn^q)|l,a^=r,c+=a+(a&os)*(Wp-1n)<<64n,c&=dn,c^=JE(c>>64n);let d=(c&q)*Mt;return d+=(c>>64n)*Mt<<64n,d&=dn,_e(d&q)|_e(d>>64n)<<64n},sC=(e,t)=>{const n=e.byteLength;return n>8?nC(e,je,t):n>=4?tC(e,je,t):n>0?eC(e,je,t):si(t^je.readBigUInt64LE(64)^je.readBigUInt64LE(72))|si(t^je.readBigUInt64LE(80)^je.readBigUInt64LE(88))<<64n},iC=(e,t,n)=>{let s=BigInt(e.byteLength)*ft&q,i=BigInt(e.byteLength-1)/32n;for(;i>=0n;){const a=Number(i);s=Fs(s,e,16*a,e.byteLength-16*(a+1),t,32*a,n),i--}let r=s+(s>>64n)&q;r=_e(r);let o=(s&q)*ft+(s>>64n)*_o+(BigInt(e.byteLength)-n&q)*Mt;return o&=q,o=Yr(_e(o)),r|o<<64n},rC=(e,t,n)=>{let s=BigInt(e.byteLength)*ft&q;for(let o=32;o<160;o+=32)s=Fs(s,e,o-32,o-16,t,o-32,n);s=_e(s&q)|_e(s>>64n)<<64n;for(let o=160;o<=e.byteLength;o+=32)s=Fs(s,e,o-32,o-16,t,3+o-160,n);s=Fs(s,e,e.byteLength-16,e.byteLength-32,t,103,Yr(n));let i=s+(s>>64n)&q;i=_e(i);let r=(s&q)*ft+(s>>64n)*_o+(BigInt(e.byteLength)-n&q)*Mt;return r&=q,r=Yr(_e(r)),i|r<<64n},oC=(e,t=0n)=>{const n=e.byteLength;return n<=16?sC(e,t):n<=128?iC(e,je,t):n<=240?rC(e,je,t):QE(e,t===0n?je:ZE(t))},aC=e=>{const t=e>>64n&q,n=e&q;return t.toString(16).padStart(16,"0")+n.toString(16).padStart(16,"0")},qp=(e,t=0n)=>aC(oC(typeof e=="string"?Buffer.from(e):e,BigInt.asUintN(64,t))),Ft=()=>m(vh(),"ai"),cC=3600*1e3,lC=1800*1e3,Kp=()=>{mt(Ft())},Yp=(e,t)=>{const n=`${e}.${String(process.pid)}.${jh()}.tmp`;try{ce(n,t,"utf8"),bl(n,e)}catch(s){try{gt(n)}catch{}throw s}},I4=(e,t,n)=>{const s=n.map(r=>({currentRange:r.currentRange,name:r.packageName,targetVersion:r.targetVersion})).toSorted((r,o)=>r.name.localeCompare(o.name)),i=JSON.stringify({analysisType:t,packages:s,provider:e});return qp(Buffer.from(i))},A4=e=>{const t=m(Ft(),`${e}.json`);if($(t))try{const n=de(t);if(Date.now()-n.createdAt>n.ttlMs){pn(t,{force:!0});return}return n.result}catch{pn(t,{force:!0});return}},B4=(e,t,n)=>{Kp();const s=Ft(),i={createdAt:Date.now(),result:t,ttlMs:n};Yp(m(s,`${e}.json`),JSON.stringify(i,void 0,2))},P4=(e,t)=>t!==void 0&&t>0?t:e==="security"?lC:cC,Xr=()=>{const e=Ft();if(!$(e))return{entries:0,newestEntry:void 0,oldestEntry:void 0,totalSizeBytes:0};const t=we(e).filter(r=>r.endsWith(".json"));let n=0,s,i;for(const r of t){const o=m(e,r),a=Bt(o);n+=a.size;const{mtimeMs:c}=a;(s===void 0||c<s)&&(s=c),(i===void 0||c>i)&&(i=c)}return{entries:t.length,newestEntry:i,oldestEntry:s,totalSizeBytes:n}},N4=e=>qp(Buffer.from(JSON.stringify(e))),D4=e=>{const t=m(Ft(),`${e}.json`);if($(t))try{const n=de(t);if(Date.now()-n.createdAt>n.ttlMs){pn(t,{force:!0});return}return n.result}catch{pn(t,{force:!0});return}},L4=(e,t,n)=>{Kp();const s=Ft(),i={createdAt:Date.now(),result:t,ttlMs:n};Yp(m(s,`${e}.json`),JSON.stringify(i,void 0,2))},dC=()=>{const e=Ft();if(!$(e))return 0;const t=we(e).filter(n=>n.endsWith(".json"));for(const n of t)pn(m(e,n),{force:!0});return t.length},Zr=(e,t)=>e.tasks.find(n=>n.taskId===t),ir=(e,t)=>{const n=e??{},s=t??{},i=[],r=[],o=[];for(const a of Object.keys(n))a in s?n[a]!==s[a]&&o.push(a):i.push(a);for(const a of Object.keys(s))a in n||r.push(a);return i.sort(),r.sort(),o.sort(),{added:i,changed:o,removed:r}},uC=(e,t)=>({commandChanged:(e?.command??"")!==(t?.command??""),implicitDeps:ir(e?.implicitDeps,t?.implicitDeps),nodes:ir(e?.nodes,t?.nodes),runtime:ir(e?.runtime,t?.runtime)}),Xp=async(e,t)=>{const n=m(vt(e),`${t}.json`);try{const s=await Rl(n,"utf8");return JSON.parse(s)}catch{return}},pC=async(e,t)=>{const n=vt(e);let s;try{s=await cs(n)}catch{return}const i=[];for(const r of s){if(!r.endsWith(".json")||t!==void 0&&r===`${t}.json`)continue;const o=m(n,r);try{const a=await mn(o);a.isFile()&&i.push({mtimeMs:a.mtimeMs,path:o})}catch{}}if(i.length!==0){i.sort((r,o)=>o.mtimeMs-r.mtimeMs);try{const r=await Rl(i[0].path,"utf8");return JSON.parse(r)}catch{return}}},M4=async e=>{const t=vt(e);let n;try{n=await cs(t)}catch{return[]}const s=[];for(const i of n){if(!i.endsWith(".json"))continue;const r=m(t,i);try{const o=await mn(r);o.isFile()&&s.push({id:i.slice(0,-5),mtimeMs:o.mtimeMs,path:r})}catch{}}return s.sort((i,r)=>r.mtimeMs-i.mtimeMs),s},Fo="branches",Zp=async e=>{let t=0;try{const n=await cs(e,{withFileTypes:!0});for(const s of n){const i=m(e,s.name);if(s.isDirectory())t+=await Zp(i);else if(s.isFile()){const r=await mn(i);t+=r.size}}}catch{}return t},ht=async e=>{const t=[];let n;try{n=await cs(e)}catch{return[]}for(const s of n){if(s.startsWith(".")||s===Fo)continue;const i=m(e,s);try{const r=await mn(i);if(!r.isDirectory())continue;const o=await Zp(i);t.push({hash:s,mtimeMs:r.mtimeMs,path:i,sizeBytes:o})}catch{}}return t.sort((s,i)=>i.mtimeMs-s.mtimeMs),t},Qp=(e,t=Date.now())=>{const n=Math.max(0,Math.floor((t-e)/1e3));return n<60?`${String(n)}s`:n<3600?`${String(Math.floor(n/60))}m`:n<86400?`${String(Math.floor(n/3600))}h`:`${String(Math.floor(n/86400))}d`},De=e=>e===void 0?null:new Date(e).toISOString(),st=e=>{process.stdout.write(`${e}
207
+ `)},Vn=(e,t)=>{st(`${e}:`),t.directory!==void 0&&st(` Directory: ${t.directory}`),st(` Entries: ${String(t.entries)}`),st(` Total size: ${Kn(t.totalSizeBytes,{decimals:1,space:!1})}`),st(` Oldest: ${t.oldestEntry?new Date(t.oldestEntry).toISOString():"N/A"}`),st(` Newest: ${t.newestEntry?new Date(t.newestEntry).toISOString():"N/A"}`)},ef=(e,t)=>{if(!t)return[e];const n=m(e,Fo);if(!$(n))return[e];try{const s=we(n,{withFileTypes:!0}).filter(i=>i.isDirectory()).map(i=>m(n,i.name));return[e,...s]}catch{return[e]}},fC=e=>{if(!$(e))return!1;try{return we(e,{withFileTypes:!0}).some(t=>t.isDirectory()&&!t.name.startsWith(".")&&t.name!==Fo)}catch{return!1}},hC=e=>new Promise(t=>{const n=Sl({input:process.stdin,output:process.stderr});n.question(`${e} (y/N) `,s=>{n.close();const i=s.trim().toLowerCase();t(i==="y"||i==="yes")})}),tf=async(e,t,n)=>{if(!$(e)){if(t==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
208
+ `);return}E.info(`No cache directory found at ${e}`);return}const s=await ht(e);if(s.length===0){if(t==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
208
209
  `);return}E.info(`Cache directory is empty: ${e}`);return}const i=s.reduce((d,u)=>d+u.sizeBytes,0);if(t==="json"){const d=Date.now();process.stdout.write(`${JSON.stringify({directory:e,entries:s.map(u=>({ageMs:d-u.mtimeMs,hash:u.hash,mtimeIso:new Date(u.mtimeMs).toISOString(),sizeBytes:u.sizeBytes})),totalBytes:i,totalCount:s.length},void 0,2)}
209
- `);return}E.info(`Cache directory: ${e}`),E.info(`Entries: ${String(s.length)} (${pn(i,{decimals:1,space:!1})})`),n.info("");const r=Date.now(),o=s.map(d=>({age:Yp(d.mtimeMs,r),hash:d.hash.slice(0,12),size:pn(d.sizeBytes,{decimals:1,space:!1})})),a=Math.max(4,...o.map(d=>d.hash.length)),c=Math.max(4,...o.map(d=>d.size.length)),l=Math.max(3,...o.map(d=>d.age.length));n.info(` ${"hash".padEnd(a)} ${"size".padEnd(c)} ${"age".padEnd(l)}`),n.info(` ${"-".repeat(a)} ${"-".repeat(c)} ${"-".repeat(l)}`);for(const d of o)n.info(` ${d.hash.padEnd(a)} ${d.size.padEnd(c)} ${d.age.padEnd(l)}`)},Zp=()=>{try{const e=oC();e>0&&E.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){E.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},Qp=()=>{try{const e=gh();e>0&&E.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){E.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},ef=()=>{try{const e=Yf();e>0&&E.info(`Cleared ${String(e)} cached deps.dev record${e===1?"":"s"}.`)}catch(e){E.warn(`Failed to clear deps.dev cache: ${e instanceof Error?e.message:String(e)}`)}},tf=()=>{try{const e=Xf();e>0&&E.info(`Cleared ${String(e)} cached Snyk record${e===1?"":"s"}.`)}catch(e){E.warn(`Failed to clear Snyk cache: ${e instanceof Error?e.message:String(e)}`)}},nf=async(e,t,n)=>{if(!$(e)){E.info(`No cache directory to clean at ${e}`);return}if(n.dryRun){const i=await ft(e),r=i.reduce((o,a)=>o+a.sizeBytes,0);E.info(`Would remove ${String(i.length)} cache entr${i.length===1?"y":"ies"} (${pn(r,{decimals:1,space:!1})}) from ${e}`);return}const s=g$(e,t);try{const i=await na(e),r=await na(t);if(i===r){E.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!s&&!n.force){if(E.warn(`Cache directory is outside the workspace root: ${e}`),E.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){E.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await lC(" Continue?")){E.info("Aborted.");return}}s?await new Ws({cacheDirectory:e,workspaceRoot:t}).clear():await eo(e,{force:!0,recursive:!0}),E.success(`Cleared cache: ${e}`)},sf=async(e,t,n)=>{if(!$(e)){E.info(`No cache directory to prune at ${e}`);return}if(n.maxCacheAgeDays!==void 0&&(!Number.isFinite(n.maxCacheAgeDays)||n.maxCacheAgeDays<0)){E.error(`Invalid --max-age-days value: expected a finite number >= 0, got ${String(n.maxCacheAgeDays)}`),process.exitCode=1;return}if(n.keepLast!==void 0&&(!Number.isFinite(n.keepLast)||n.keepLast<0||!Number.isInteger(n.keepLast))){E.error(`Invalid --keep-last value: expected a non-negative integer, got ${String(n.keepLast)}`),process.exitCode=1;return}if(n.maxCacheSize!==void 0){let u;try{u=vh(n.maxCacheSize)}catch(p){E.error(`Invalid --max-size value: ${p instanceof Error?p.message:String(p)}`),process.exitCode=1;return}if(!Number.isFinite(u)||u<=0){E.error(`Invalid --max-size value: expected a positive size, got "${n.maxCacheSize}" (${String(u)} bytes)`),process.exitCode=1;return}}const s=n.maxCacheAgeDays===void 0?void 0:n.maxCacheAgeDays*24*60*60*1e3,i=await ft(e),r=i.reduce((u,p)=>u+p.sizeBytes,0);if(n.keepLast!==void 0&&i.length>n.keepLast){const u=i.slice(n.keepLast);await Promise.all(u.map(p=>eo(p.path,{force:!0,recursive:!0})))}await new Ws({cacheDirectory:e,maxCacheAge:s,maxCacheSize:n.maxCacheSize,workspaceRoot:t}).removeOldEntries();const a=await ft(e),c=a.reduce((u,p)=>u+p.sizeBytes,0),l=i.length-a.length,d=r-c;if(l<=0){E.info("Nothing to prune — all entries are within the configured limits.");return}E.success(`Pruned ${String(l)} entr${l===1?"y":"ies"}, freed ${pn(d,{decimals:1,space:!1})}.`)},ol=16,rf=e=>e.length>ol?`${e.slice(0,ol)}…`:e,ir=(e,t,n)=>{const s=Object.entries(t??{});if(s.length!==0){n.info(` ${e}:`),s.sort(([i],[r])=>i.localeCompare(r));for(const[i,r]of s)n.info(` ${i.padEnd(40)} ${rf(r)}`)}},of=async(e,t,n)=>{const{format:s,runId:i,workspaceRoot:r}=t,o=i===void 0?await Sl(r,{dataDirectory:Vn(r)}):await qp(r,i);if(!o){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:i??null,taskId:e},void 0,2)}
210
- `),process.exitCode=1;return}i===void 0?E.error(`No previous run summary found. Run a task first to populate \`${fr(r,{dataDirectory:Vn(r)})}\`.`):E.error(`Run summary "${i}" not found in ${yt(r)}/.`),process.exitCode=1;return}const a=Xr(o,e);if(!a){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:o.id,taskId:e},void 0,2)}
211
- `),process.exitCode=1;return}E.error(`Task "${e}" was not part of run ${o.id}.`),E.info(`Tasks in this run: ${o.tasks.map(p=>p.taskId).join(", ")||"(none)"}`),process.exitCode=1;return}const c=await cC(r,o.id),l=c?Xr(c,e):void 0,d=aC(a.hashDetails,l?.hashDetails);if(s==="json"){process.stdout.write(`${JSON.stringify({diff:d,previousRunId:c?.id??null,previousTask:l?{cacheStatus:l.cacheStatus,hash:l.hash??null,hashDetails:l.hashDetails??null}:null,runId:o.id,task:{cacheStatus:a.cacheStatus,hash:a.hash??null,hashDetails:a.hashDetails??null,taskId:a.taskId}},void 0,2)}
212
- `);return}if(E.info(`Why ${e}? (run ${o.id})`),n.info(""),n.info(` status: ${a.cacheStatus}`),n.info(` hash: ${a.hash??"(none)"}`),l?n.info(` prev: ${l.hash??"(none)"} [run ${c?.id??"?"}]`):n.info(" prev: (no prior run found)"),n.info(""),!l){E.info("No previous run to diff against — first time this task was recorded.");return}if(!d.commandChanged&&d.nodes.added.length===0&&d.nodes.changed.length===0&&d.nodes.removed.length===0&&d.runtime.added.length===0&&d.runtime.changed.length===0&&d.runtime.removed.length===0&&d.implicitDeps.added.length===0&&d.implicitDeps.changed.length===0&&d.implicitDeps.removed.length===0){E.success("No hash inputs changed since the previous run.");return}n.info("Hash inputs that changed since the previous run:"),n.info(""),d.commandChanged&&n.info(" command: changed");for(const p of["nodes","runtime","implicitDeps"]){const f=d[p];if(!(f.added.length===0&&f.changed.length===0&&f.removed.length===0)){n.info(` ${p}:`);for(const h of f.added)n.info(` + ${h}`);for(const h of f.changed)n.info(` ~ ${h}`);for(const h of f.removed)n.info(` - ${h}`)}}n.info(""),E.info(`Last summary file: ${fr(r,{dataDirectory:Vn(r)})}`)},af=async(e,t,n)=>{const{format:s,runId:i,workspaceRoot:r}=t,o=i===void 0?await Sl(r,{dataDirectory:Vn(r)}):await qp(r,i);if(!o){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:i??null,taskId:e},void 0,2)}
213
- `),process.exitCode=1;return}i===void 0?E.error(`No previous run summary found. Run a task first to populate \`${fr(r,{dataDirectory:Vn(r)})}\`.`):E.error(`Run summary "${i}" not found in ${yt(r)}/.`),process.exitCode=1;return}const a=Xr(o,e);if(!a){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:o.id,taskId:e},void 0,2)}
210
+ `);return}st(`Cache directory: ${e}`),st(`Entries: ${String(s.length)} (${Kn(i,{decimals:1,space:!1})})`),n.info("");const r=Date.now(),o=s.map(d=>({age:Qp(d.mtimeMs,r),hash:d.hash.slice(0,12),size:Kn(d.sizeBytes,{decimals:1,space:!1})})),a=Math.max(4,...o.map(d=>d.hash.length)),c=Math.max(4,...o.map(d=>d.size.length)),l=Math.max(3,...o.map(d=>d.age.length));n.info(` ${"hash".padEnd(a)} ${"size".padEnd(c)} ${"age".padEnd(l)}`),n.info(` ${"-".repeat(a)} ${"-".repeat(c)} ${"-".repeat(l)}`);for(const d of o)n.info(` ${d.hash.padEnd(a)} ${d.size.padEnd(c)} ${d.age.padEnd(l)}`)},nf=()=>{try{const e=dC();e>0&&E.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){E.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},sf=()=>{try{const e=bh();e>0&&E.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){E.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},rf=()=>{try{const e=eh();e>0&&E.info(`Cleared ${String(e)} cached deps.dev record${e===1?"":"s"}.`)}catch(e){E.warn(`Failed to clear deps.dev cache: ${e instanceof Error?e.message:String(e)}`)}},of=()=>{try{const e=th();e>0&&E.info(`Cleared ${String(e)} cached Snyk record${e===1?"":"s"}.`)}catch(e){E.warn(`Failed to clear Snyk cache: ${e instanceof Error?e.message:String(e)}`)}},af=async(e,t,n)=>{if(!$(e)){E.info(`No cache directory to clean at ${e}`);return}if(n.dryRun){const r=(await Promise.all(ef(e,!0).map(async a=>ht(a)))).flat(),o=r.reduce((a,c)=>a+c.sizeBytes,0);E.info(`Would remove ${String(r.length)} cache entr${r.length===1?"y":"ies"} (${Kn(o,{decimals:1,space:!1})}) from ${e}`);return}const s=b$(e,t);try{const i=await ia(e),r=await ia(t);if(i===r){E.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!s&&!n.force){if(E.warn(`Cache directory is outside the workspace root: ${e}`),E.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){E.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await hC(" Continue?")){E.info("Aborted.");return}}s?await new Hs({cacheDirectory:e,workspaceRoot:t}).clear():await to(e,{force:!0,recursive:!0}),E.success(`Cleared cache: ${e}`)},cf=async(e,t,n)=>{if(!$(e)){E.info(`No cache directory to prune at ${e}`);return}if(n.maxCacheAgeDays!==void 0&&(!Number.isFinite(n.maxCacheAgeDays)||n.maxCacheAgeDays<0)){E.error(`Invalid --max-age-days value: expected a finite number >= 0, got ${String(n.maxCacheAgeDays)}`),process.exitCode=1;return}if(n.keepLast!==void 0&&(!Number.isFinite(n.keepLast)||n.keepLast<0||!Number.isInteger(n.keepLast))){E.error(`Invalid --keep-last value: expected a non-negative integer, got ${String(n.keepLast)}`),process.exitCode=1;return}if(n.maxCacheSize!==void 0){let u;try{u=Sh(n.maxCacheSize)}catch(p){E.error(`Invalid --max-size value: ${p instanceof Error?p.message:String(p)}`),process.exitCode=1;return}if(!Number.isFinite(u)||u<=0){E.error(`Invalid --max-size value: expected a positive size, got "${n.maxCacheSize}" (${String(u)} bytes)`),process.exitCode=1;return}}const s=n.maxCacheAgeDays===void 0?void 0:n.maxCacheAgeDays*24*60*60*1e3,i=await ht(e),r=i.reduce((u,p)=>u+p.sizeBytes,0);if(n.keepLast!==void 0&&i.length>n.keepLast){const u=i.slice(n.keepLast);await Promise.all(u.map(p=>to(p.path,{force:!0,recursive:!0})))}await new Hs({cacheDirectory:e,maxCacheAge:s,maxCacheSize:n.maxCacheSize,workspaceRoot:t}).removeOldEntries();const a=await ht(e),c=a.reduce((u,p)=>u+p.sizeBytes,0),l=i.length-a.length,d=r-c;if(l<=0){E.info("Nothing to prune — all entries are within the configured limits.");return}E.success(`Pruned ${String(l)} entr${l===1?"y":"ies"}, freed ${Kn(d,{decimals:1,space:!1})}.`)},ll=16,lf=e=>e.length>ll?`${e.slice(0,ll)}…`:e,rr=(e,t,n)=>{const s=Object.entries(t??{});if(s.length!==0){n.info(` ${e}:`),s.sort(([i],[r])=>i.localeCompare(r));for(const[i,r]of s)n.info(` ${i.padEnd(40)} ${lf(r)}`)}},df=async(e,t,n)=>{const{format:s,runId:i,workspaceRoot:r}=t,o=i===void 0?await El(r,{dataDirectory:Wn(r)}):await Xp(r,i);if(!o){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:i??null,taskId:e},void 0,2)}
211
+ `),process.exitCode=1;return}i===void 0?E.error(`No previous run summary found. Run a task first to populate \`${hr(r,{dataDirectory:Wn(r)})}\`.`):E.error(`Run summary "${i}" not found in ${vt(r)}/.`),process.exitCode=1;return}const a=Zr(o,e);if(!a){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:o.id,taskId:e},void 0,2)}
212
+ `),process.exitCode=1;return}E.error(`Task "${e}" was not part of run ${o.id}.`),E.info(`Tasks in this run: ${o.tasks.map(p=>p.taskId).join(", ")||"(none)"}`),process.exitCode=1;return}const c=await pC(r,o.id),l=c?Zr(c,e):void 0,d=uC(a.hashDetails,l?.hashDetails);if(s==="json"){process.stdout.write(`${JSON.stringify({diff:d,previousRunId:c?.id??null,previousTask:l?{cacheStatus:l.cacheStatus,hash:l.hash??null,hashDetails:l.hashDetails??null}:null,runId:o.id,task:{cacheStatus:a.cacheStatus,hash:a.hash??null,hashDetails:a.hashDetails??null,taskId:a.taskId}},void 0,2)}
213
+ `);return}if(E.info(`Why ${e}? (run ${o.id})`),n.info(""),n.info(` status: ${a.cacheStatus}`),n.info(` hash: ${a.hash??"(none)"}`),l?n.info(` prev: ${l.hash??"(none)"} [run ${c?.id??"?"}]`):n.info(" prev: (no prior run found)"),n.info(""),!l){E.info("No previous run to diff against — first time this task was recorded.");return}if(!d.commandChanged&&d.nodes.added.length===0&&d.nodes.changed.length===0&&d.nodes.removed.length===0&&d.runtime.added.length===0&&d.runtime.changed.length===0&&d.runtime.removed.length===0&&d.implicitDeps.added.length===0&&d.implicitDeps.changed.length===0&&d.implicitDeps.removed.length===0){E.success("No hash inputs changed since the previous run.");return}n.info("Hash inputs that changed since the previous run:"),n.info(""),d.commandChanged&&n.info(" command: changed");for(const p of["nodes","runtime","implicitDeps"]){const f=d[p];if(!(f.added.length===0&&f.changed.length===0&&f.removed.length===0)){n.info(` ${p}:`);for(const h of f.added)n.info(` + ${h}`);for(const h of f.changed)n.info(` ~ ${h}`);for(const h of f.removed)n.info(` - ${h}`)}}n.info(""),E.info(`Last summary file: ${hr(r,{dataDirectory:Wn(r)})}`)},uf=async(e,t,n)=>{const{format:s,runId:i,workspaceRoot:r}=t,o=i===void 0?await El(r,{dataDirectory:Wn(r)}):await Xp(r,i);if(!o){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:i??null,taskId:e},void 0,2)}
214
+ `),process.exitCode=1;return}i===void 0?E.error(`No previous run summary found. Run a task first to populate \`${hr(r,{dataDirectory:Wn(r)})}\`.`):E.error(`Run summary "${i}" not found in ${vt(r)}/.`),process.exitCode=1;return}const a=Zr(o,e);if(!a){if(s==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:o.id,taskId:e},void 0,2)}
214
215
  `),process.exitCode=1;return}E.error(`Task "${e}" was not part of run ${o.id}.`),process.exitCode=1;return}if(s==="json"){process.stdout.write(`${JSON.stringify({cacheStatus:a.cacheStatus,hash:a.hash??null,hashDetails:a.hashDetails??null,runId:o.id,taskId:a.taskId},void 0,2)}
215
- `);return}E.info(`Hash for ${e} (run ${o.id})`),n.info(""),n.info(` status: ${a.cacheStatus}`),n.info(` hash: ${a.hash??"(none)"}`),a.hashDetails?(n.info(""),n.info(` command: ${rf(a.hashDetails.command)}`),ir("nodes",a.hashDetails.nodes,n),ir("runtime",a.hashDetails.runtime,n),ir("implicitDeps",a.hashDetails.implicitDeps,n)):(n.info(""),E.info("No hash details recorded for this task."))},cf=async(e,t)=>{if(!$(e)){if(t==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
216
- `);return}E.info(`No cache directory at ${e}`);return}const n=await ft(e),s=n.reduce((i,r)=>i+r.sizeBytes,0);if(t==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!0,totalBytes:s,totalCount:n.length})}
217
- `);return}E.info(`Cache directory: ${e}`),E.info(`Entries: ${String(n.length)}`),E.info(`Total size: ${pn(s,{decimals:1,space:!1})}`)},dC=async e=>{const t=[],n=async s=>{const r=(await os(s,{withFileTypes:!0})).toSorted((o,a)=>o.name.localeCompare(a.name));for(const o of r){const a=m(s,o.name);if(o.isDirectory()){await n(a);continue}if(!o.isFile())continue;const[c,l]=await Promise.all([mn(a),xl(a)]);t.push({hash:l?.hash??"",mode:c.mode&4095,mtimeMs:c.mtimeMs,relativePath:rs(e,a).replaceAll("\\","/"),sizeBytes:c.size})}};return await n(e),t},uC=(e,t)=>Math.floor(e/1e3)===Math.floor(t/1e3),al=16,pC=async(e,t)=>{const n=m(t,e.relativePath),s=await mn(n).catch(()=>{});if(!s)return{expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:["missing"],relativePath:e.relativePath};const i=await xl(n),r=[];(i?.hash??"")!==e.hash&&r.push("content");const o=s.mode&4095;if(process.platform!=="win32"&&o!==e.mode&&r.push("mode"),uC(s.mtimeMs,e.mtimeMs)||r.push("mtime"),r.length!==0)return{actual:{hash:i?.hash,mode:o,mtimeMs:s.mtimeMs},expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:r,relativePath:e.relativePath}},lf=async(e,t,n)=>{const{cacheDirectories:s,format:i,workspaceRoot:r}=t;if(s.length===0){i==="json"?process.stdout.write(`${JSON.stringify({error:"no-cache-directory",taskId:e},void 0,2)}
218
- `):E.error("No cache directory resolved — pass --cache-dir or run inside a workspace."),process.exitCode=1;return}let o,a;for(const l of s){const d=await new Ws({cacheDirectory:l,workspaceRoot:r}).getByTaskId(e);if(d){o=l,a=d;break}}if(!a||!o){i==="json"?process.stdout.write(`${JSON.stringify({error:"no-cached-entry",searchedCaches:s,taskId:e},void 0,2)}
219
- `):E.error(`No cached entry found for task "${e}". Run it once before verifying.`),process.exitCode=1;return}const c=await bh(m(ph(),"vis-cache-verify-"));try{if(!await new Ws({cacheDirectory:o,workspaceRoot:c}).restoreOutputs(a.hash)){i==="json"?process.stdout.write(`${JSON.stringify({error:"restore-failed",hash:a.hash,taskId:e},void 0,2)}
220
- `):E.error(`Cache restore failed for ${e} (hash ${a.hash}).`),process.exitCode=1;return}const u=await dC(c);if(u.length===0){i==="json"?process.stdout.write(`${JSON.stringify({diffs:[],hash:a.hash,status:"no-outputs",taskId:e},void 0,2)}
221
- `):E.info(`Cached entry for ${e} has no recorded outputs — nothing to verify.`);return}const p=Array.from({length:u.length});for(let h=0;h<u.length;h+=al){const g=u.slice(h,h+al),y=await Promise.all(g.map(async x=>pC(x,r)));for(const[x,b]of y.entries())p[h+x]=b}const f=p.filter(h=>h!==void 0);if(i==="json"){process.stdout.write(`${JSON.stringify({cachedFileCount:u.length,cacheDirectory:o,diffs:f,hash:a.hash,status:f.length===0?"ok":"drift",taskId:e},void 0,2)}
222
- `),f.length>0&&(process.exitCode=1);return}if(E.info(`Verify ${e} (hash ${a.hash})`),n.info(""),n.info(` cache: ${o}`),n.info(` files: ${String(u.length)}`),f.length===0){n.info(""),E.success("Cache restore is faithful — all files match content, mode, and mtime.");return}n.info(` drift: ${String(f.length)} file(s)`),n.info("");for(const h of f){const g=h.issues.includes("missing")?"MISSING":h.issues.join(",").toUpperCase();n.info(` [${g}] ${h.relativePath}`),!h.issues.includes("missing")&&h.expected&&h.actual&&(h.issues.includes("content")&&(n.info(` expected hash: ${h.expected.hash||"(none)"}`),n.info(` actual hash: ${h.actual.hash??"(unreadable)"}`)),h.issues.includes("mode")&&(n.info(` expected mode: ${h.expected.mode.toString(8)}`),n.info(` actual mode: ${(h.actual.mode??0).toString(8)}`)),h.issues.includes("mtime")&&(n.info(` expected mtime: ${new Date(h.expected.mtimeMs).toISOString()}`),n.info(` actual mtime: ${h.actual.mtimeMs===void 0?"(unreadable)":new Date(h.actual.mtimeMs).toISOString()}`)))}process.exitCode=1}finally{await eo(c,{force:!0,recursive:!0}).catch(()=>{})}},df=e=>e==="task"||e==="ai"||e==="socket"||e==="deps-dev"||e==="snyk"||e==="all"?e:(e&&e.length>0&&E.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),be=(e,t)=>e==="all"||e===t,De=e=>e===void 0?null:new Date(e).toISOString(),Is=(e,t)=>{E.info(`${e}:`),E.info(` Entries: ${String(t.entries)}`),E.info(` Total size: ${pn(t.totalSizeBytes,{decimals:1,space:!1})}`),E.info(` Oldest: ${t.oldestEntry?new Date(t.oldestEntry).toISOString():"N/A"}`),E.info(` Newest: ${t.newestEntry?new Date(t.newestEntry).toISOString():"N/A"}`)},fC=e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&E.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),gn=(e,t,n)=>{const s=e??process.cwd(),i=n??{},r=i.taskRunner??{},o=fC(t.scope),a=t.cacheDir,c=Uc(s,a,r.cacheDirectory,!1),l=Uc(s,a,r.cacheDirectory,i.sharedWorktreeCache);let d,u;switch(o){case"all":{d=l,u=l===c?[l]:[l,c];break}case"worktree":{d=c,u=[c];break}default:d=l,u=[l]}return{cacheDirectories:u,cacheDirectory:d,scope:o,sharedWorktreeCache:i.sharedWorktreeCache,workspaceRoot:s}},hC=async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{const{cacheDirectories:i}=gn(s,t,n),r=t.format??"table";for(const o of i)i.length>1&&E.info(`# ${o}`),await Xp(o,r,e)},gC=async({options:e,visConfig:t,workspaceRoot:n})=>{const s=df(e.type),i=!!e.dryRun;if(be(s,"task")){const{cacheDirectory:r,workspaceRoot:o}=gn(n,e,t);await nf(r,o,{dryRun:i,force:!!e.force})}if(be(s,"ai"))if(i){const r=Yr();E.info(`Would clear ${String(r.entries)} cached AI response${r.entries===1?"":"s"}.`)}else Zp();if(be(s,"socket"))if(i){const r=pr();E.info(`Would clear ${String(r.entries)} cached Socket.dev report${r.entries===1?"":"s"}.`)}else Qp();if(be(s,"deps-dev"))if(i){const r=cr();E.info(`Would clear ${String(r.entries)} cached deps.dev record${r.entries===1?"":"s"}.`)}else ef();if(be(s,"snyk"))if(i){const r=lr();E.info(`Would clear ${String(r.entries)} cached Snyk record${r.entries===1?"":"s"}.`)}else tf()},mC=async({options:e,visConfig:t,workspaceRoot:n})=>{const{cacheDirectories:s,workspaceRoot:i}=gn(n,e,t);for(const r of s)s.length>1&&E.info(`# ${r}`),await sf(r,i,{keepLast:typeof e.keepLast=="number"?e.keepLast:void 0,maxCacheAgeDays:typeof e.maxAgeDays=="number"?e.maxAgeDays:void 0,maxCacheSize:e.maxSize})},uf=e=>e??process.cwd(),yC=async({argument:e,logger:t,options:n,workspaceRoot:s})=>{const i=e[0];if(!i){E.error("No task ID specified. Usage: vis cache why <project>:<target>"),process.exitCode=1;return}await of(i,{format:n.format??"table",runId:n.run,workspaceRoot:uf(s)},t)},vC=async({argument:e,logger:t,options:n,workspaceRoot:s})=>{const i=e[0];if(!i){E.error("No task ID specified. Usage: vis cache hash <project>:<target>"),process.exitCode=1;return}await af(i,{format:n.format??"table",runId:n.run,workspaceRoot:uf(s)},t)},bC=async({options:e,visConfig:t,workspaceRoot:n})=>{const s=df(e.type);if((e.format??"table")==="json"){const r={};if(be(s,"task")){const{cacheDirectories:o}=gn(n,e,t);r.task=await Promise.all(o.map(async a=>{const c=$(a),l=c?await ft(a):[],d=l.reduce((u,p)=>u+p.sizeBytes,0);return{directory:a,entries:l.length,exists:c,newestEntry:De(l[0]?.mtimeMs),oldestEntry:De(l.at(-1)?.mtimeMs),totalBytes:d}}))}if(be(s,"ai")){const o=Yr();r.ai={entries:o.entries,newestEntry:De(o.newestEntry),oldestEntry:De(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(be(s,"socket")){const o=pr();r.socket={entries:o.entries,newestEntry:De(o.newestEntry),oldestEntry:De(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(be(s,"deps-dev")){const o=cr();r["deps-dev"]={entries:o.entries,newestEntry:De(o.newestEntry),oldestEntry:De(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(be(s,"snyk")){const o=lr();r.snyk={entries:o.entries,newestEntry:De(o.newestEntry),oldestEntry:De(o.oldestEntry),totalBytes:o.totalSizeBytes}}process.stdout.write(`${JSON.stringify(r,void 0,2)}
223
- `);return}if(be(s,"task")){const{cacheDirectories:r}=gn(n,e,t);for(const o of r)r.length>1&&E.info(`# ${o}`),await cf(o,"table")}be(s,"ai")&&Is("AI response cache",Yr()),be(s,"socket")&&Is("Socket.dev report cache",pr()),be(s,"deps-dev")&&Is("deps.dev cache",cr()),be(s,"snyk")&&Is("Snyk issue cache",lr())},wC=async({argument:e,logger:t,options:n,visConfig:s,workspaceRoot:i})=>{const r=e[0];if(!r){E.error("No task ID specified. Usage: vis cache verify <project>:<target>"),process.exitCode=1;return}const{cacheDirectories:o,workspaceRoot:a}=gn(i,n,s);await lf(r,{cacheDirectories:o,format:n.format??"table",workspaceRoot:a},t)},Ft=Object.defineProperty({__proto__:null,cacheCleanExecute:gC,cacheHashExecute:vC,cacheListExecute:hC,cachePruneExecute:mC,cacheSizeExecute:bC,cacheVerifyExecute:wC,cacheWhyExecute:yC,clearAiCacheSafe:Zp,clearDepsDevCacheSafe:ef,clearSnykCacheSafe:tf,clearSocketCacheSafe:Qp,collectCacheEntries:ft,formatAge:Yp,runClean:nf,runHash:af,runList:Xp,runPrune:sf,runSize:cf,runVerify:lf,runWhy:of},Symbol.toStringTag,{value:"Module"}),N4=(e,t)=>{let n=0,s=0,i=0;for(const[,a]of e)switch(a.status){case"failure":{i+=1;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{s+=1;break}case"success":{n+=1;break}}const r=[];n>0&&r.push(`${String(n)} succeeded`),s>0&&r.push(`${String(s)} cached`),i>0&&r.push(`${String(i)} failed`);const o=(t/1e3).toFixed(1);return r.push(`${o}s`),r.join(" · ")},Jn=e=>{const t=yt(e);if($(t)){const s=Ee(t).filter(r=>r.endsWith(".json")),i=[];for(const r of s)try{i.push(de(m(t,r)))}catch{}if(i.length>0)return i}const n=kl(e);if($(n))try{return[de(n)]}catch{}return[]},D4=(e,t,n)=>{const s=n??Jn(e);if(s.length<2)return;let i=0,r=0;for(const l of s)typeof l.duration=="number"&&l.duration>0&&(i+=l.duration,r+=1);if(r<2)return;const a=i/r-t,c=Math.abs(a/1e3).toFixed(1);return Math.abs(a)<500?"(about average)":a>0?`(${c}s faster than avg)`:`(${c}s slower than avg)`},kC=(e,t={},n)=>{const s=n??Jn(e);if(s.length===0)return[];const i=new Map;for(const a of s)if(!(t.since&&(a.startTime===void 0||a.startTime<t.since))&&Array.isArray(a.tasks))for(const c of a.tasks){if(c.cacheStatus==="HIT"||c.cacheStatus==="REMOTE_HIT"||c.cacheStatus==="SKIPPED")continue;const l=i.get(c.taskId)??{failures:0,project:c.target.project,retriedSuccesses:0,successes:0,target:c.target.target,totalRuns:0};l.totalRuns+=1,c.exitCode!==void 0&&c.exitCode!==0?(l.failures+=1,l.lastFailure=c.startTime??a.startTime):(c.retryAttempts&&c.retryAttempts>0&&(l.retriedSuccesses+=1,l.lastRetry=c.startTime??a.startTime),l.successes+=1),i.set(c.taskId,l)}const r=t.minRuns??2,o=[];for(const[a,c]of i){if(c.totalRuns<r||c.failures===0&&c.retriedSuccesses===0)continue;const l=(c.failures+.5*c.retriedSuccesses)/c.totalRuns;o.push({failures:c.failures,flakinessRate:l,lastFailure:c.lastFailure,lastRetry:c.lastRetry,project:c.project,retriedSuccesses:c.retriedSuccesses,successes:c.successes,target:c.target,taskId:a,totalRuns:c.totalRuns})}return o.sort((a,c)=>c.flakinessRate-a.flakinessRate),o},L4=e=>{if(e.length===0)return["No flaky tasks detected."];const t=["Task","Runs","Failures","Retried","Rate","Last Failure"],n=e.map(a=>[a.taskId,String(a.totalRuns),String(a.failures),String(a.retriedSuccesses),`${(a.flakinessRate*100).toFixed(1)}%`,a.lastFailure??a.lastRetry??"—"]),s=t.map((a,c)=>{let l=0;for(const d of n)l=Math.max(l,(d[c]??"").length);return Math.max(a.length,l)}),i=(a,c)=>a.padEnd(c),r=s.map(a=>"─".repeat(a)).join("──"),o=[t.map((a,c)=>i(a,s[c])).join(" "),r];for(const a of n)o.push(a.map((c,l)=>i(c,s[l])).join(" "));return o},rr=(e,t,n)=>{const s=[],i=t??{},r=n??{},o=new Set([...Object.keys(i),...Object.keys(r)]);for(const a of o){const c=i[a],l=r[a];c!==l&&(c===void 0?s.push({change:"added",current:l,key:a,kind:e,previous:void 0}):l===void 0?s.push({change:"removed",current:void 0,key:a,kind:e,previous:c}):s.push({change:"modified",current:l,key:a,kind:e,previous:c}))}return s.sort((a,c)=>a.key.localeCompare(c.key)),s},SC=e=>{if(e.length===0)return"No input changes detected. The cache may have been evicted or was never stored.";if(e.some(r=>r.kind==="command"))return"The resolved command changed.";const n=new Map;for(const r of e)n.set(r.kind,(n.get(r.kind)??0)+1);const[s]=[...n.entries()].sort((r,o)=>o[1]-r[1])[0]??["nodes",0],i={command:"command",implicitDeps:"lockfile or dependency",nodes:"input file",runtime:"runtime value"};return`${String(e.length)} ${i[s]??s} change(s) detected.`},xC=(e,t,n)=>{const s=e.find(o=>o.id===n)?.startTime,r=[...e].sort((o,a)=>(a.startTime??"").localeCompare(o.startTime??"")).filter(o=>!(o.id!==void 0&&o.id===n||s!==void 0&&o.startTime!==void 0&&o.startTime>s));for(const o of r){const a=o.tasks?.find(c=>c.taskId===t);if(a&&(a.cacheStatus==="HIT"||a.cacheStatus==="REMOTE_HIT"))return{run:o,task:a}}for(const o of r){const a=o.tasks?.find(c=>c.taskId===t);if(a?.hashDetails)return{run:o,task:a}}},$C=(e,t,n)=>{const s=e,i=n.taskId??"",r=xC(s,i,t);if(!r)return{currentHash:n.hash,entries:[],previousHash:void 0,previousRunId:void 0,previousRunStartTime:void 0,reason:"No previous run recorded this task — first observation.",taskId:i};const o=[],a=r.task.hashDetails?.command,c=n.hashDetails?.command;return a!==c&&o.push({change:a===void 0?"added":c===void 0?"removed":"modified",current:c,key:"command",kind:"command",previous:a}),o.push(...rr("nodes",r.task.hashDetails?.nodes,n.hashDetails?.nodes)),o.push(...rr("implicitDeps",r.task.hashDetails?.implicitDeps,n.hashDetails?.implicitDeps)),o.push(...rr("runtime",r.task.hashDetails?.runtime,n.hashDetails?.runtime)),{currentHash:n.hash,entries:o,previousHash:r.task.hash,previousRunId:r.run.id,previousRunStartTime:r.run.startTime,reason:SC(o),taskId:i}},cl=vl(Ch(import.meta.url)),EC=[Fs(cl,"..","..","dashboard","dist","index.html"),Fs(cl,"..","dashboard","dist","index.html")],ll=`<!DOCTYPE html>
216
+ `);return}E.info(`Hash for ${e} (run ${o.id})`),n.info(""),n.info(` status: ${a.cacheStatus}`),n.info(` hash: ${a.hash??"(none)"}`),a.hashDetails?(n.info(""),n.info(` command: ${lf(a.hashDetails.command)}`),rr("nodes",a.hashDetails.nodes,n),rr("runtime",a.hashDetails.runtime,n),rr("implicitDeps",a.hashDetails.implicitDeps,n)):(n.info(""),E.info("No hash details recorded for this task."))},pf=async(e,t)=>{if(!$(e)){if(t==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
217
+ `);return}E.info(`No cache directory at ${e}`);return}const n=await ht(e),s=n.reduce((i,r)=>i+r.sizeBytes,0);if(t==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!0,totalBytes:s,totalCount:n.length})}
218
+ `);return}Vn("Task cache",{directory:e,entries:n.length,newestEntry:n[0]?.mtimeMs,oldestEntry:n.at(-1)?.mtimeMs,totalSizeBytes:s})},gC=async e=>{const t=[],n=async s=>{const r=(await cs(s,{withFileTypes:!0})).toSorted((o,a)=>o.name.localeCompare(a.name));for(const o of r){const a=m(s,o.name);if(o.isDirectory()){await n(a);continue}if(!o.isFile())continue;const[c,l]=await Promise.all([mn(a),Cl(a)]);t.push({hash:l?.hash??"",mode:c.mode&4095,mtimeMs:c.mtimeMs,relativePath:as(e,a).replaceAll("\\","/"),sizeBytes:c.size})}};return await n(e),t},mC=(e,t)=>Math.floor(e/1e3)===Math.floor(t/1e3),dl=16,yC=async(e,t)=>{const n=m(t,e.relativePath),s=await mn(n).catch(()=>{});if(!s)return{expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:["missing"],relativePath:e.relativePath};const i=await Cl(n),r=[];(i?.hash??"")!==e.hash&&r.push("content");const o=s.mode&4095;if(process.platform!=="win32"&&o!==e.mode&&r.push("mode"),mC(s.mtimeMs,e.mtimeMs)||r.push("mtime"),r.length!==0)return{actual:{hash:i?.hash,mode:o,mtimeMs:s.mtimeMs},expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:r,relativePath:e.relativePath}},ff=async(e,t,n)=>{const{cacheDirectories:s,format:i,workspaceRoot:r}=t;if(s.length===0){i==="json"?process.stdout.write(`${JSON.stringify({error:"no-cache-directory",taskId:e},void 0,2)}
219
+ `):E.error("No cache directory resolved — pass --cache-dir or run inside a workspace."),process.exitCode=1;return}let o,a;for(const l of s){const d=await new Hs({cacheDirectory:l,workspaceRoot:r}).getByTaskId(e);if(d){o=l,a=d;break}}if(!a||!o){i==="json"?process.stdout.write(`${JSON.stringify({error:"no-cached-entry",searchedCaches:s,taskId:e},void 0,2)}
220
+ `):E.error(`No cached entry found for task "${e}". Run it once before verifying.`),process.exitCode=1;return}const c=await xh(m(mh(),"vis-cache-verify-"));try{if(!await new Hs({cacheDirectory:o,workspaceRoot:c}).restoreOutputs(a.hash)){i==="json"?process.stdout.write(`${JSON.stringify({error:"restore-failed",hash:a.hash,taskId:e},void 0,2)}
221
+ `):E.error(`Cache restore failed for ${e} (hash ${a.hash}).`),process.exitCode=1;return}const u=await gC(c);if(u.length===0){i==="json"?process.stdout.write(`${JSON.stringify({diffs:[],hash:a.hash,status:"no-outputs",taskId:e},void 0,2)}
222
+ `):E.info(`Cached entry for ${e} has no recorded outputs — nothing to verify.`);return}const p=Array.from({length:u.length});for(let h=0;h<u.length;h+=dl){const g=u.slice(h,h+dl),y=await Promise.all(g.map(async x=>yC(x,r)));for(const[x,b]of y.entries())p[h+x]=b}const f=p.filter(h=>h!==void 0);if(i==="json"){process.stdout.write(`${JSON.stringify({cachedFileCount:u.length,cacheDirectory:o,diffs:f,hash:a.hash,status:f.length===0?"ok":"drift",taskId:e},void 0,2)}
223
+ `),f.length>0&&(process.exitCode=1);return}if(E.info(`Verify ${e} (hash ${a.hash})`),n.info(""),n.info(` cache: ${o}`),n.info(` files: ${String(u.length)}`),f.length===0){n.info(""),E.success("Cache restore is faithful — all files match content, mode, and mtime.");return}n.info(` drift: ${String(f.length)} file(s)`),n.info("");for(const h of f){const g=h.issues.includes("missing")?"MISSING":h.issues.join(",").toUpperCase();n.info(` [${g}] ${h.relativePath}`),!h.issues.includes("missing")&&h.expected&&h.actual&&(h.issues.includes("content")&&(n.info(` expected hash: ${h.expected.hash||"(none)"}`),n.info(` actual hash: ${h.actual.hash??"(unreadable)"}`)),h.issues.includes("mode")&&(n.info(` expected mode: ${h.expected.mode.toString(8)}`),n.info(` actual mode: ${(h.actual.mode??0).toString(8)}`)),h.issues.includes("mtime")&&(n.info(` expected mtime: ${new Date(h.expected.mtimeMs).toISOString()}`),n.info(` actual mtime: ${h.actual.mtimeMs===void 0?"(unreadable)":new Date(h.actual.mtimeMs).toISOString()}`)))}process.exitCode=1}finally{await to(c,{force:!0,recursive:!0}).catch(()=>{})}},hf=e=>e==="task"||e==="ai"||e==="socket"||e==="deps-dev"||e==="snyk"||e==="all"?e:(e&&e.length>0&&E.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),be=(e,t)=>e==="all"||e===t,vC=e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&E.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),gn=(e,t,n)=>{const s=e??process.cwd(),i=n??{},r=i.taskRunner??{},o=vC(t.scope),a=t.cacheDir,c=zc(s,a,r.cacheDirectory,!1),l=zc(s,a,r.cacheDirectory,i.sharedWorktreeCache),d=Jc(c,s,i.branchScopedCache),u=Jc(l,s,i.branchScopedCache);let p;switch(o){case"all":{p=u===d?[{base:l,scoped:u}]:[{base:l,scoped:u},{base:c,scoped:d}];break}case"worktree":{p=[{base:c,scoped:d}];break}default:p=[{base:l,scoped:u}]}const f=i.branchScopedCache===!0;return{directoriesFor:h=>h==="read"?[...new Set(p.flatMap(g=>g.scoped!==g.base&&fC(g.base)?[g.scoped,g.base]:[g.scoped]))]:h==="wipe"?[...new Set(p.map(g=>g.base))]:[...new Set(p.flatMap(g=>ef(g.base,f)))],scope:o,sharedWorktreeCache:i.sharedWorktreeCache,workspaceRoot:s}},bC=async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{const{directoriesFor:i}=gn(s,t,n),r=i("read"),o=t.format??"table";for(const a of r)r.length>1&&E.info(`# ${a}`),await tf(a,o,e)},wC=async({options:e,visConfig:t,workspaceRoot:n})=>{const s=hf(e.type),i=!!e.dryRun;if(be(s,"task")){const{directoriesFor:r,workspaceRoot:o}=gn(n,e,t);for(const a of r("wipe"))await af(a,o,{dryRun:i,force:!!e.force})}if(be(s,"ai"))if(i){const r=Xr();E.info(`Would clear ${String(r.entries)} cached AI response${r.entries===1?"":"s"}.`)}else nf();if(be(s,"socket"))if(i){const r=fr();E.info(`Would clear ${String(r.entries)} cached Socket.dev report${r.entries===1?"":"s"}.`)}else sf();if(be(s,"deps-dev"))if(i){const r=lr();E.info(`Would clear ${String(r.entries)} cached deps.dev record${r.entries===1?"":"s"}.`)}else rf();if(be(s,"snyk"))if(i){const r=dr();E.info(`Would clear ${String(r.entries)} cached Snyk record${r.entries===1?"":"s"}.`)}else of()},kC=async({options:e,visConfig:t,workspaceRoot:n})=>{const{directoriesFor:s,workspaceRoot:i}=gn(n,e,t),r=s("evict");for(const o of r)r.length>1&&E.info(`# ${o}`),await cf(o,i,{keepLast:typeof e.keepLast=="number"?e.keepLast:void 0,maxCacheAgeDays:typeof e.maxAgeDays=="number"?e.maxAgeDays:void 0,maxCacheSize:e.maxSize})},gf=e=>e??process.cwd(),SC=async({argument:e,logger:t,options:n,workspaceRoot:s})=>{const i=e[0];if(!i){E.error("No task ID specified. Usage: vis cache why <project>:<target>"),process.exitCode=1;return}await df(i,{format:n.format??"table",runId:n.run,workspaceRoot:gf(s)},t)},xC=async({argument:e,logger:t,options:n,workspaceRoot:s})=>{const i=e[0];if(!i){E.error("No task ID specified. Usage: vis cache hash <project>:<target>"),process.exitCode=1;return}await uf(i,{format:n.format??"table",runId:n.run,workspaceRoot:gf(s)},t)},$C=async({options:e,visConfig:t,workspaceRoot:n})=>{const s=hf(e.type);if((e.format??"table")==="json"){const r={};if(be(s,"task")){const{directoriesFor:o}=gn(n,e,t),a=o("read");r.task=await Promise.all(a.map(async c=>{const l=$(c),d=l?await ht(c):[],u=d.reduce((p,f)=>p+f.sizeBytes,0);return{directory:c,entries:d.length,exists:l,newestEntry:De(d[0]?.mtimeMs),oldestEntry:De(d.at(-1)?.mtimeMs),totalBytes:u}}))}if(be(s,"ai")){const o=Xr();r.ai={entries:o.entries,newestEntry:De(o.newestEntry),oldestEntry:De(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(be(s,"socket")){const o=fr();r.socket={entries:o.entries,newestEntry:De(o.newestEntry),oldestEntry:De(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(be(s,"deps-dev")){const o=lr();r["deps-dev"]={entries:o.entries,newestEntry:De(o.newestEntry),oldestEntry:De(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(be(s,"snyk")){const o=dr();r.snyk={entries:o.entries,newestEntry:De(o.newestEntry),oldestEntry:De(o.oldestEntry),totalBytes:o.totalSizeBytes}}process.stdout.write(`${JSON.stringify(r,void 0,2)}
224
+ `);return}if(be(s,"task")){const{directoriesFor:r}=gn(n,e,t),o=r("read");for(const a of o)o.length>1&&E.info(`# ${a}`),await pf(a,"table")}be(s,"ai")&&Vn("AI response cache",Xr()),be(s,"socket")&&Vn("Socket.dev report cache",fr()),be(s,"deps-dev")&&Vn("deps.dev cache",lr()),be(s,"snyk")&&Vn("Snyk issue cache",dr())},EC=async({argument:e,logger:t,options:n,visConfig:s,workspaceRoot:i})=>{const r=e[0];if(!r){E.error("No task ID specified. Usage: vis cache verify <project>:<target>"),process.exitCode=1;return}const{directoriesFor:o,workspaceRoot:a}=gn(i,n,s),c=o("read");await ff(r,{cacheDirectories:c,format:n.format??"table",workspaceRoot:a},t)},Vt=Object.defineProperty({__proto__:null,cacheCleanExecute:wC,cacheHashExecute:xC,cacheListExecute:bC,cachePruneExecute:kC,cacheSizeExecute:$C,cacheVerifyExecute:EC,cacheWhyExecute:SC,clearAiCacheSafe:nf,clearDepsDevCacheSafe:rf,clearSnykCacheSafe:of,clearSocketCacheSafe:sf,collectCacheEntries:ht,formatAge:Qp,runClean:af,runHash:uf,runList:tf,runPrune:cf,runSize:pf,runVerify:ff,runWhy:df},Symbol.toStringTag,{value:"Module"}),_4=(e,t)=>{let n=0,s=0,i=0;for(const[,a]of e)switch(a.status){case"failure":{i+=1;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{s+=1;break}case"success":{n+=1;break}}const r=[];n>0&&r.push(`${String(n)} succeeded`),s>0&&r.push(`${String(s)} cached`),i>0&&r.push(`${String(i)} failed`);const o=(t/1e3).toFixed(1);return r.push(`${o}s`),r.join(" · ")},qn=e=>{const t=vt(e);if($(t)){const s=we(t).filter(r=>r.endsWith(".json")),i=[];for(const r of s)try{i.push(de(m(t,r)))}catch{}if(i.length>0)return i}const n=$l(e);if($(n))try{return[de(n)]}catch{}return[]},F4=(e,t,n)=>{const s=n??qn(e);if(s.length<2)return;let i=0,r=0;for(const l of s)typeof l.duration=="number"&&l.duration>0&&(i+=l.duration,r+=1);if(r<2)return;const a=i/r-t,c=Math.abs(a/1e3).toFixed(1);return Math.abs(a)<500?"(about average)":a>0?`(${c}s faster than avg)`:`(${c}s slower than avg)`},CC=(e,t={},n)=>{const s=n??qn(e);if(s.length===0)return[];const i=new Map;for(const a of s)if(!(t.since&&(a.startTime===void 0||a.startTime<t.since))&&Array.isArray(a.tasks))for(const c of a.tasks){if(c.cacheStatus==="HIT"||c.cacheStatus==="REMOTE_HIT"||c.cacheStatus==="SKIPPED")continue;const l=i.get(c.taskId)??{failures:0,project:c.target.project,retriedSuccesses:0,successes:0,target:c.target.target,totalRuns:0};l.totalRuns+=1,c.exitCode!==void 0&&c.exitCode!==0?(l.failures+=1,l.lastFailure=c.startTime??a.startTime):(c.retryAttempts&&c.retryAttempts>0&&(l.retriedSuccesses+=1,l.lastRetry=c.startTime??a.startTime),l.successes+=1),i.set(c.taskId,l)}const r=t.minRuns??2,o=[];for(const[a,c]of i){if(c.totalRuns<r||c.failures===0&&c.retriedSuccesses===0)continue;const l=(c.failures+.5*c.retriedSuccesses)/c.totalRuns;o.push({failures:c.failures,flakinessRate:l,lastFailure:c.lastFailure,lastRetry:c.lastRetry,project:c.project,retriedSuccesses:c.retriedSuccesses,successes:c.successes,target:c.target,taskId:a,totalRuns:c.totalRuns})}return o.sort((a,c)=>c.flakinessRate-a.flakinessRate),o},V4=e=>{if(e.length===0)return["No flaky tasks detected."];const t=["Task","Runs","Failures","Retried","Rate","Last Failure"],n=e.map(a=>[a.taskId,String(a.totalRuns),String(a.failures),String(a.retriedSuccesses),`${(a.flakinessRate*100).toFixed(1)}%`,a.lastFailure??a.lastRetry??"—"]),s=t.map((a,c)=>{let l=0;for(const d of n)l=Math.max(l,(d[c]??"").length);return Math.max(a.length,l)}),i=(a,c)=>a.padEnd(c),r=s.map(a=>"─".repeat(a)).join("──"),o=[t.map((a,c)=>i(a,s[c])).join(" "),r];for(const a of n)o.push(a.map((c,l)=>i(c,s[l])).join(" "));return o},or=(e,t,n)=>{const s=[],i=t??{},r=n??{},o=new Set([...Object.keys(i),...Object.keys(r)]);for(const a of o){const c=i[a],l=r[a];c!==l&&(c===void 0?s.push({change:"added",current:l,key:a,kind:e,previous:void 0}):l===void 0?s.push({change:"removed",current:void 0,key:a,kind:e,previous:c}):s.push({change:"modified",current:l,key:a,kind:e,previous:c}))}return s.sort((a,c)=>a.key.localeCompare(c.key)),s},RC=e=>{if(e.length===0)return"No input changes detected. The cache may have been evicted or was never stored.";if(e.some(r=>r.kind==="command"))return"The resolved command changed.";const n=new Map;for(const r of e)n.set(r.kind,(n.get(r.kind)??0)+1);const[s]=[...n.entries()].sort((r,o)=>o[1]-r[1])[0]??["nodes",0],i={command:"command",implicitDeps:"lockfile or dependency",nodes:"input file",runtime:"runtime value"};return`${String(e.length)} ${i[s]??s} change(s) detected.`},OC=(e,t,n)=>{const s=e.find(o=>o.id===n)?.startTime,r=[...e].sort((o,a)=>(a.startTime??"").localeCompare(o.startTime??"")).filter(o=>!(o.id!==void 0&&o.id===n||s!==void 0&&o.startTime!==void 0&&o.startTime>s));for(const o of r){const a=o.tasks?.find(c=>c.taskId===t);if(a&&(a.cacheStatus==="HIT"||a.cacheStatus==="REMOTE_HIT"))return{run:o,task:a}}for(const o of r){const a=o.tasks?.find(c=>c.taskId===t);if(a?.hashDetails)return{run:o,task:a}}},jC=(e,t,n)=>{const s=e,i=n.taskId??"",r=OC(s,i,t);if(!r)return{currentHash:n.hash,entries:[],previousHash:void 0,previousRunId:void 0,previousRunStartTime:void 0,reason:"No previous run recorded this task — first observation.",taskId:i};const o=[],a=r.task.hashDetails?.command,c=n.hashDetails?.command;return a!==c&&o.push({change:a===void 0?"added":c===void 0?"removed":"modified",current:c,key:"command",kind:"command",previous:a}),o.push(...or("nodes",r.task.hashDetails?.nodes,n.hashDetails?.nodes)),o.push(...or("implicitDeps",r.task.hashDetails?.implicitDeps,n.hashDetails?.implicitDeps)),o.push(...or("runtime",r.task.hashDetails?.runtime,n.hashDetails?.runtime)),{currentHash:n.hash,entries:o,previousHash:r.task.hash,previousRunId:r.run.id,previousRunStartTime:r.run.startTime,reason:RC(o),taskId:i}},ul=kl(Th(import.meta.url)),TC=[Vs(ul,"..","..","dashboard","dist","index.html"),Vs(ul,"..","dashboard","dist","index.html")],pl=`<!DOCTYPE html>
224
225
  <html lang="en">
225
226
  <head>
226
227
  <meta charset="UTF-8" />
@@ -238,9 +239,9 @@ ${s.join(`\r
238
239
  <p>Or run the full vis build:</p>
239
240
  <pre><code>pnpm --filter @visulima/vis run build</code></pre>
240
241
  </body>
241
- </html>`;let kt;const CC=()=>{for(const e of EC)try{if(At(e).isFile())return e}catch{}},RC=()=>{if(kt!==void 0&&!process.env.VIS_DASHBOARD_NO_CACHE)return kt;const e=CC();if(!e)return kt=ll,kt;try{const t=yl(e,"utf8");return kt=t,t}catch{return kt=ll,kt}},OC=e=>{if(e.length===0)return;const t=[...e].sort((s,i)=>s-i),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]},jC=e=>{const t=new Map;for(const s of e)if(Array.isArray(s.tasks))for(const i of s.tasks){if(!i.taskId)continue;const r=t.get(i.taskId)??{durations:[],failures:0,hits:0,misses:0,project:i.target?.project??"",runs:0,target:i.target?.target??"",taskId:i.taskId};i.cacheStatus==="HIT"||i.cacheStatus==="REMOTE_HIT"?(r.runs+=1,r.hits+=1):i.cacheStatus==="MISS"&&(r.runs+=1,r.misses+=1,typeof i.duration=="number"&&i.duration>0&&r.durations.push(i.duration),i.exitCode!==void 0&&i.exitCode!==0&&(r.failures+=1)),t.set(i.taskId,r)}const n=new Map;for(const[s,i]of t){const r=i.durations.length===0?0:i.durations.reduce((o,a)=>o+a,0)/i.durations.length;n.set(s,{averageDurationMs:r,failures:i.failures,hitRate:i.runs===0?0:i.hits/i.runs,hits:i.hits,misses:i.misses,project:i.project,runs:i.runs,target:i.target,taskId:s,timeSavedMs:r*i.hits})}return n},TC=e=>{const t=e,n=[...t].sort((b,S)=>(b.startTime??"").localeCompare(S.startTime??""));let s=0,i=0,r=0,o=0,a=0,c=0;const l=[],d=[],u=[];for(const b of n){const S=b.stats??{};s+=S.total??0,i+=S.succeeded??0,r+=S.failed??0,o+=S.cached??0,a+=S.skipped??0,typeof b.duration=="number"&&b.duration>0&&(c+=b.duration,l.push(b.duration),b.startTime&&u.push({timestamp:b.startTime,value:b.duration})),(S.total??0)>0&&b.startTime&&d.push({timestamp:b.startTime,value:(S.cached??0)/(S.total??1)})}const f=[...jC(n).values()],h=f.filter(b=>b.averageDurationMs>0).sort((b,S)=>S.averageDurationMs-b.averageDurationMs).slice(0,10),g=f.filter(b=>b.runs>=2).sort((b,S)=>S.timeSavedMs-b.timeSavedMs||S.hitRate-b.hitRate).slice(0,10),y=f.filter(b=>b.runs>=3&&b.hits>0&&b.misses>0).sort((b,S)=>S.misses/S.runs-b.misses/b.runs).slice(0,10),x=f.reduce((b,S)=>b+S.timeSavedMs,0);return{averageRunDurationMs:l.length===0?null:l.reduce((b,S)=>b+S,0)/l.length,cacheHitRate:o+i+r===0?null:o/(o+i+r),durationOverTime:u,hitRateOverTime:d,medianRunDurationMs:OC(l)??null,mostCachedTasks:g,mostInvalidatedTasks:y,slowestTasks:h,totals:{cached:o,estimatedTimeSavedMs:x,failed:r,runs:t.length,skipped:a,succeeded:i,tasks:s,totalDurationMs:c}}},IC=(e,t)=>{if(e===void 0||e==="")return!1;let n=e;if(n.startsWith("[")){const s=n.indexOf("]");n=s===-1?n.slice(1):n.slice(1,s)}else if(!n.includes("::")){const s=n.indexOf(":");n=s===-1?n:n.slice(0,s)}return n=n.toLowerCase(),n==="localhost"||n===t.toLowerCase()?!0:kh(n)!==0},dl=(e,t)=>{const n=t.replaceAll(/[^\w.\-:]/g,"");if(n.length===0||n!==t)return;const s=m(yt(e),`${n}.json`);if($(s))try{return de(s)}catch{return}const i=kl(e);if($(i))try{const r=de(i);return r.id===n?r:void 0}catch{return}},AC=async e=>{const t=new Set,n=yt(e);try{await wh(n,{recursive:!0})}catch{}let s,i;const r=a=>{i=a,s&&clearTimeout(s),s=setTimeout(()=>{if(s=void 0,!i)return;const c=i;i=void 0;for(const l of t)try{l(c)}catch{}},200)};let o;try{o=ih(n,(a,c)=>{if(!c||typeof c!="string"||!c.endsWith(".json"))return;const l=c.slice(0,-5);r({id:l,type:"run-changed"})})}catch{o=void 0}return{close:()=>{s&&clearTimeout(s),o?.close(),t.clear()},subscribe:a=>(t.add(a),()=>{t.delete(a)})}},PC=(e,t)=>{const n=new AE;return n.use("*",async(s,i)=>IC(s.req.header("host"),e.host)?i():s.json({error:"Forbidden"},403)),n.get("/",s=>s.html(RC())),n.get("/api/overview",s=>{const i=Jn(e.workspaceRoot),r=TC(i),o=kC(e.workspaceRoot,{minRuns:2},i);return s.json({flaky:o,metrics:r})}),n.get("/api/runs",s=>{const r=Jn(e.workspaceRoot).filter(o=>typeof o.id=="string"&&typeof o.startTime=="string"&&typeof o.endTime=="string"&&typeof o.duration=="number").map(o=>{const a=o.stats,c=a?{cached:typeof a.cached=="number"?a.cached:void 0,failed:typeof a.failed=="number"?a.failed:void 0,skipped:typeof a.skipped=="number"?a.skipped:void 0,succeeded:typeof a.succeeded=="number"?a.succeeded:void 0,total:typeof a.total=="number"?a.total:void 0}:void 0;return{duration:o.duration,endTime:o.endTime,id:o.id,startTime:o.startTime,stats:c}}).sort((o,a)=>a.startTime.localeCompare(o.startTime));return s.json({runs:r})}),n.get("/api/runs/:id",s=>{const i=dl(e.workspaceRoot,s.req.param("id"));return i?s.json(i):s.json({error:"Not found"},404)}),n.get("/api/runs/:runId/tasks/:taskId/diff",s=>{const i=dl(e.workspaceRoot,s.req.param("runId"));if(!i)return s.json({error:"Run not found"},404);const r=s.req.param("taskId"),o=i.tasks?.find(l=>l.taskId===r);if(!o)return s.json({error:"Task not found"},404);const a=Jn(e.workspaceRoot),c=$C(a,i.id,o);return s.json(c)}),n.get("/api/cache",async s=>{if(!$(e.cacheDirectory))return s.json({directory:e.cacheDirectory,entries:[],exists:!1,totalBytes:0});const i=await ft(e.cacheDirectory),r=i.reduce((a,c)=>a+c.sizeBytes,0),o=Date.now();return s.json({directory:e.cacheDirectory,entries:i.map(a=>({ageMs:o-a.mtimeMs,hash:a.hash,mtimeIso:new Date(a.mtimeMs).toISOString(),sizeBytes:a.sizeBytes})),exists:!0,totalBytes:r})}),n.get("/api/environment",s=>s.json({arch:process.arch,cacheDirectory:e.cacheDirectory,node:process.version,platform:process.platform,workspaceRoot:e.workspaceRoot})),n.get("/api/events",s=>LE(s,async i=>{const r=[];let o;const a=t(l=>{if(r.push(l),o){const d=o;o=void 0,d()}});i.onAbort(()=>{if(a(),o){const l=o;o=void 0,l()}}),await i.writeSSE({data:JSON.stringify({ok:!0}),event:"ready"});const c=15e3;for(;!i.aborted;){if(r.length===0){const d=i.sleep(c),u=new Promise(p=>{o=p});if(await Promise.race([d,u]),i.aborted)break;if(r.length===0){await i.writeSSE({data:"",event:"heartbeat"});continue}}const l=r.shift();await i.writeSSE({data:JSON.stringify(l),event:"change"})}})),n},BC=async e=>{const t=await AC(e.workspaceRoot),n=PC(e,t.subscribe),s=Q$({fetch:n.fetch,hostname:e.host,port:e.port});await new Promise((l,d)=>{s.once("listening",()=>{l()}),s.once("error",u=>{d(u)})});const i=s.address(),r=typeof i=="object"&&i?i.port:e.port,c=`http://${e.host==="0.0.0.0"||e.host==="::"||e.host==="::0"?"localhost":e.host}:${String(r)}`;return{close:()=>new Promise((l,d)=>{t.close(),s.close(u=>{u?d(u):l()})}),port:r,url:c}},NC=e=>{const{platform:t}=process,[n,s]=t==="darwin"?["open",[e]]:t==="win32"?["cmd",["/c","start","",e]]:["xdg-open",[e]];eh(n,s,i=>{})},DC={description:"Open a browser dashboard with cache, run history, and cache-miss diffs",examples:[["vis dashboard","Start the dashboard on a random port (server only — does not open a browser)"],["vis dashboard --open","Start the dashboard and open it in the default browser"],["vis dashboard --port=7788","Pin the server to a specific port"],["vis dashboard --host=0.0.0.0 --port=7788","Expose the dashboard on all interfaces"]],execute:async({options:e,process:t,visConfig:n,workspaceRoot:s})=>{const i=s??t.cwd,r=up(i,e.cacheDir,n?.taskRunner?.cacheDirectory),o=typeof e.port=="number"&&Number.isFinite(e.port)?e.port:0,a=typeof e.host=="string"&&e.host.length>0?e.host:"127.0.0.1",c=await BC({cacheDirectory:r,host:a,port:o,workspaceRoot:i});E.success(`Dashboard listening on ${c.url}`),E.info(`Workspace: ${i}`),E.info(`Cache: ${r}`),E.info("Press Ctrl+C to stop."),e.open===!0&&NC(c.url),await new Promise(l=>{let d=!1;const u=()=>{d||(d=!0,process.off("SIGINT",u),process.off("SIGTERM",u),(async()=>{try{await c.close()}catch{}finally{l()}})())};process.once("SIGINT",u),process.once("SIGTERM",u)})},group:"Workspace",name:"dashboard",options:[{defaultValue:0,description:"Port to bind the dashboard server to (0 = auto-assign)",name:"port",type:Number},{defaultValue:"127.0.0.1",description:"Host interface to bind to. Default binds to localhost only.",name:"host",type:String},{defaultValue:!1,description:"Open the dashboard in the default browser after starting",name:"open",type:Boolean},{description:"Cache directory to inspect (overrides config and default). Relative paths resolve against the workspace root.",name:"cache-dir",type:String}]},LC={check:{defaultValue:!1,description:"Preview changes without modifying files (dry-run)",type:Boolean}},MC=R({description:"Deduplicate dependencies using the detected package manager",examples:[["vis dedupe","Run deduplication"],["vis dedupe --check","Preview changes without modifying (CI-friendly)"]],group:"Dependencies",loader:()=>import("./handler9.js"),name:"dedupe",options:LC}),_C={ban:{description:"Ban a dep name or glob for this run (repeatable). Auto-enables --banned-deps.",multiple:!0,type:String},"banned-deps":{defaultValue:!1,description:"Lint deps against policy.bannedDeps in vis config",type:Boolean},"custom-types":{defaultValue:!1,description:"Lint engines.{node,pnpm}, packageManager, volta.*, devEngines.* for drift across packages",type:Boolean},"dead-workspace-patterns":{defaultValue:!1,description:"Flag workspace patterns (in `pnpm-workspace.yaml` / `package.json#workspaces`) that match zero packages",type:Boolean},dep:{description:"Restrict --workspace-versions to a single dep",type:String},"empty-deps":{defaultValue:!1,description:"Flag empty dependency blocks (`dependencies: {}`, `devDependencies: {}`, …) across the workspace",type:Boolean},fix:{defaultValue:!1,description:"Auto-fix violations in place (writes package.json files)",type:Boolean},"fix-specifier":{description:"Specifier used by --fix for workspace-protocol (default: workspace:*)",type:String},format:{description:"Output format: human, json, or minimal (default: human)",type:String},"missing-package-json":{defaultValue:!1,description:"Flag workspace directories that lack a package.json",type:Boolean},pin:{description:"Pin a dep to an exact specifier for this run, e.g. react@^18.2.0 (repeatable). Auto-enables --workspace-versions.",multiple:!0,type:String},"propose-min":{description:"Propose catalog entries for deps ≥N packages already agree on. Activates with --resolve catalog.",type:Number},quiet:{defaultValue:!1,description:"Suppress all output except errors",type:Boolean},"redefine-root":{defaultValue:!1,description:"Lint that no child re-declares a dep already pinned in the workspace root",type:Boolean},resolve:{description:"Conflict resolution for --workspace-versions: highest, lowest, or catalog (default: highest)",type:String},"root-deps":{defaultValue:!1,description:"Flag runtime dependencies on the private workspace root (move them to devDependencies)",type:Boolean},"root-package-manager":{defaultValue:!1,description:"Ensure the workspace root package.json declares a `packageManager` field",type:Boolean},"root-private":{defaultValue:!1,description:'Ensure the workspace root package.json sets `"private": true`',type:Boolean},"similar-deps":{defaultValue:!1,description:"Flag version drift across related dep families (react+react-dom, @babel/*, @storybook/*, …)",type:Boolean},"types-in-deps":{defaultValue:!1,description:"Flag `@types/*` declared in `dependencies` on a private package (should be in devDependencies)",type:Boolean},"workspace-protocol":{defaultValue:!1,description:"Lint that internal deps use the workspace: protocol",type:Boolean},"workspace-versions":{defaultValue:!1,description:"Lint that all packages declare external deps at the same version",type:Boolean}},FC=R({description:"Lint workspace dependency policies (workspace-protocol, banned-deps, redefine-root, workspace-versions, custom-types, empty-deps, root-private, root-package-manager, root-deps, missing-package-json, dead-workspace-patterns, types-in-deps, similar-deps)",examples:[["vis deps","Run every enabled lint and exit non-zero on failures"],["vis deps --workspace-protocol","Only check that internal deps use workspace:*"],["vis deps --workspace-protocol --fix","Auto-rewrite internal deps to use workspace:*"],["vis deps --redefine-root","Flag deps duplicated between root and child packages"],["vis deps --banned-deps","Flag deps matching policy.bannedDeps in vis config"],["vis deps --workspace-versions","Flag external deps declared at different versions across packages"],["vis deps --workspace-versions --fix","Rewrite drifting deps to the highest sibling version"],["vis deps --workspace-versions --dep react","Limit version-drift check to a single dep"],["vis deps --workspace-versions --resolve catalog --fix","Rewrite drifting deps to catalog: when a catalog already pins them"],["vis deps --workspace-versions --resolve catalog --propose-min 3","Suggest new catalog entries for deps ≥3 packages already agree on"],["vis deps --custom-types","Flag drift in engines.{node,pnpm}, packageManager, volta.{node,pnpm,yarn}, devEngines"],["vis deps --custom-types --fix","Align all engines/packageManager/volta versions to the highest sibling"],["vis deps --empty-deps --fix","Drop empty `dependencies` / `devDependencies` / etc. blocks across the workspace"],["vis deps --root-private --fix",'Ensure the workspace root package.json has "private": true'],["vis deps --root-package-manager","Ensure the root package.json declares a `packageManager` field"],["vis deps --root-deps --fix","Move runtime deps off the private workspace root into devDependencies"],["vis deps --missing-package-json","Flag workspace dirs that don't contain a package.json"],["vis deps --dead-workspace-patterns --fix","Drop workspace patterns that match zero packages"],["vis deps --types-in-deps --fix","Move @types/* out of dependencies on private packages"],["vis deps --similar-deps","Flag drift across related dep families (react+react-dom, @babel/*, …)"],["vis deps --ban left-pad --ban request","One-off ban: flag any package declaring left-pad or request"],["vis deps --pin react@18.2.0","One-off pin: flag any package declaring react at a different version"],["vis deps --format json","Emit findings as JSON for CI / editor integrations"]],group:"Security & Health",loader:()=>import("./handler67.js"),name:"deps",options:_C}),VC={output:{alias:"o",description:"Output path (default: .devcontainer/devcontainer.json)",type:String},template:{alias:"t",description:"Start from a template: node, node-pnpm, node-postgres, node-dind, fullstack, python, go, rust, java, devops, minimal, custom",type:String}},WC=R({alias:"dc",description:"Create or update .devcontainer/devcontainer.json interactively",examples:[["vis devcontainer","Launch interactive devcontainer config editor"],["vis dc","Alias for devcontainer"],["vis devcontainer --template node-pnpm","Start from Node.js + pnpm template"]],group:"Scaffold & Config",loader:()=>import("./handler76.js"),name:"devcontainer",options:VC}),wi="Workspace",HC={focus:{description:"Project name(s) to focus on — comma-separated for multiple",type:String},"include-sources":{defaultValue:!1,description:"Also copy focus project source trees to <out>/sources",type:Boolean},out:{description:"Output directory for the scaffold (default: .vis/docker)",type:String},...fe({defaultValue:!0,description:"Rewrite the workspace lockfile to drop unfocused projects (use --no-prune-lockfile to copy verbatim)",name:"prune-lockfile",type:Boolean})},UC=R({commandPath:["docker"],description:"Build a minimal, cache-friendly Docker context for a focus project + its deps",examples:[["vis docker scaffold --focus=my-app","Generate .vis/docker/workspace for my-app + its deps"],["vis docker scaffold --focus=my-app --include-sources","Also copy focus source trees"],["vis docker scaffold --focus=my-app,other --out=.vis/docker","Focus multiple projects"]],group:wi,loader:G(()=>import("./handler59.js"),"scaffoldExecute"),name:"scaffold",options:HC}),GC={context:{description:"Scaffold root for prune (default: .vis/docker)",type:String}},zC=R({commandPath:["docker"],description:"Strip unfocused workspace projects from a scaffolded context (run inside a build stage)",examples:[["vis docker prune --context=.vis/docker","Strip unfocused projects inside a build stage"]],group:wi,loader:G(()=>import("./handler59.js"),"pruneExecute"),name:"prune",options:GC}),JC={"dry-run":{defaultValue:!1,description:"Print the Dockerfile to stdout instead of writing it",type:Boolean},focus:{description:"Focus project name for the build filter",type:String},force:{defaultValue:!1,description:"Overwrite an existing Dockerfile without prompting",type:Boolean},node:{description:"Node.js version tag for the base image (default: 22)",type:String}},qC=R({argument:{description:"Output path for the Dockerfile (default: ./Dockerfile)",name:"path",type:String},commandPath:["docker"],description:"Generate a multi-stage Dockerfile wired to the scaffold/prune flow (create-only)",examples:[["vis docker init","Generate ./Dockerfile for the detected package manager"],["vis docker init --focus=my-app","Target a specific project's build"],["vis docker init --node=24 --force","Use Node 24 and overwrite without prompting"],["vis docker init --dry-run","Print the Dockerfile instead of writing it"]],group:wi,loader:G(()=>import("./handler59.js"),"initExecute"),name:"init",options:JC}),KC={config:{description:"Path to a hadolint config (.hadolint.yaml)",type:String},fix:{defaultValue:!1,description:"Apply safe autofixes, then re-lint and report what remains",type:Boolean},install:{defaultValue:!1,description:"Download hadolint without prompting if it is missing",type:Boolean},json:{defaultValue:!1,description:"Emit findings as JSON",type:Boolean}},YC=R({argument:{description:"Dockerfile path(s) to lint (default: ./Dockerfile)",name:"file",type:String},commandPath:["docker"],description:"Lint a Dockerfile with hadolint (downloaded on demand); --fix applies safe autofixes",examples:[["vis docker lint","Lint ./Dockerfile (prompts to download hadolint on first use)"],["vis docker lint apps/web/Dockerfile","Lint a specific Dockerfile"],["vis docker lint --fix","Apply safe autofixes, then report what remains"],["vis docker lint --install --json","Auto-download hadolint and emit JSON"]],group:wi,loader:G(()=>import("./handler59.js"),"lintExecute"),name:"lint",options:KC}),XC=[UC,zC,qC,YC],ZC={"exit-code":{defaultValue:!1,description:"Exit with code 1 if issues found",type:Boolean},filter:{description:"Comma-separated package name patterns to scope findings (supports * globs, e.g. '@types/*,react')",type:String},fix:{defaultValue:!1,description:"Auto-apply safe fixes (security overrides + codemods, SIGTERM orphans)",type:Boolean},"fix-force":{defaultValue:!1,description:"With --fix: escalate orphan cleanup to SIGKILL / taskkill /F (use when SIGTERM is ignored)",type:Boolean},format:{description:"Output format: table or json (default: table). Alias: --json",type:String},json:{defaultValue:!1,description:"Shorthand for --format json",type:Boolean},"no-cache":{defaultValue:!1,description:"Bypass the doctor result cache (~/.vis/cache/doctor)",type:Boolean},"no-progress":{defaultValue:!1,description:"Disable live progress UI (forces sequential logs)",type:Boolean},only:{description:"Comma-separated sections to run: dependencies,security,optimization,runtime",type:String},quiet:{defaultValue:!1,description:"Suppress per-section detail; print summary only",type:Boolean},skip:{description:"Comma-separated sections to skip",type:String},strict:{defaultValue:!1,description:"With --exit-code: also fail on outdated and duplicate deps",type:Boolean}},QC=R({description:"Run a full project health check (outdated, security, duplicates, optimizations)",examples:[["vis doctor","Full project health check"],["vis doctor --fix","Check and auto-apply safe fixes"],["vis doctor --format json","Machine-readable output for CI"],["vis doctor --only security","Only run the security scans"],["vis doctor --skip optimization,runtime","Skip the listed sections"],["vis doctor --quiet","Summary only, no per-section breakdown"],["vis doctor --no-progress","Disable live progress UI (sequential logs)"],["vis doctor --exit-code","Exit with code 1 if security issues found"],["vis doctor --exit-code --strict","Fail on any issue (outdated, duplicates, security)"]],group:"Security & Health",loader:()=>import("./handler69.js"),name:"doctor",options:ZC}),e8={check:{defaultValue:!1,description:"Report files that would change without writing",type:Boolean},format:{defaultValue:"human",description:"Output format: human, json, minimal, sarif, junit, or github",type:String},output:{description:"Write formatted output to a file path instead of stdout (also accepts `-`/`stdout`/`stderr`)",type:String},quiet:{defaultValue:!1,description:"Suppress per-file logs",type:Boolean},since:{description:"Only format files changed vs the given git ref (branch, tag, sha)",type:String},staged:{defaultValue:!1,description:"Only format files currently staged in the git index",type:Boolean},watch:{defaultValue:!1,description:"Re-run formatters whenever watched files change",type:Boolean}},t8=R({description:"Orchestrate detected formatters (prettier, …) across the workspace",examples:[["vis fmt","Apply formatting in place using every detected formatter"],["vis fmt --check","Report files that would change without writing"],["vis fmt --check --format json","Emit findings as JSON for CI / editor integrations"],["vis fmt --check --format sarif","Emit a SARIF 2.1.0 document for code-scanning uploads"],["vis fmt --check --format junit","Emit a JUnit XML report for CI dashboards"],["vis fmt --check --format github","Emit GitHub Actions workflow commands for inline PR annotations"],["vis fmt src/foo.ts src/bar.ts","Format a specific file list"],["vis fmt --quiet","Suppress per-file logs"],["vis fmt --since main","Only format files changed vs the main branch"],["vis fmt --staged","Only format files currently staged in the git index"],["vis fmt --watch","Re-run formatters when watched files change (cache makes incremental --check near-free)"],["vis fmt --check --format sarif --output fmt.sarif","Write the SARIF report to fmt.sarif instead of stdout"]],group:"Lint & Format",loader:()=>import("./handler60.js"),name:"fmt",options:e8}),n8={defaults:{defaultValue:!1,description:"Skip prompts; use template defaults",type:Boolean},describe:{defaultValue:!1,description:"Print template metadata (about, destination, variables) without running produce",type:Boolean},"dry-run":{defaultValue:!1,description:"Print planned writes without touching disk",type:Boolean},force:{defaultValue:!1,description:"Overwrite existing files without prompting",type:Boolean},json:{defaultValue:!1,description:"Emit JSON output (with --list or --describe)",type:Boolean},list:{defaultValue:!1,description:"List discovered templates",type:Boolean},"no-interactive":{defaultValue:!1,description:"Skip interactive prompts (errors on missing required values)",type:Boolean},"prefer-offline":{defaultValue:!1,description:"Prefer locally cached remote templates over re-downloading",type:Boolean},"skip-scripts":{defaultValue:!1,description:"Skip running post-generation scripts",type:Boolean},to:{description:"Destination directory",type:String}},s8=R({argument:{description:"Template name (or remote source like git://… or npm://…) — omit for interactive picker",name:"template",type:String},description:"Scaffold files from an in-repo template",examples:[["vis generate","Pick a template interactively"],["vis generate package","Run the 'package' template"],["vis generate component -- --name=Button --style=primary","Pre-fill option values"],["vis generate package --to=./packages/new --force","Custom destination + overwrite"],["vis generate package --dry-run","Print planned writes without touching disk"],["vis generate git://github.com/org/template#main","Fetch and run a remote template"],["vis generate --list","Show discovered templates"],["vis generate --list --json","Machine-readable template list"],["vis generate package --describe --json","Print template metadata (variables, destination) as JSON"]],group:"Scaffold & Config",loader:()=>import("./handler61.js"),name:"generate",options:n8}),i8={depth:{alias:"d",description:"Maximum dependency tree depth for ASCII output (default: unlimited)",type:Number},format:{alias:"f",defaultValue:void 0,description:"Output format: tui, ascii, dot, json, html (default: tui in TTY, ascii otherwise)",type:String},output:{alias:"o",description:"Write output to file instead of stdout",type:String}},r8=R({description:"Visualize the project dependency graph",examples:[["vis graph","Show colored dependency graph (TUI in TTY, ASCII otherwise)"],["vis graph --format=ascii","Force ASCII tree output"],["vis graph --format=dot","Output in Graphviz DOT format"],["vis graph --format=html --output=graph.html","Generate interactive HTML graph"],["vis graph --format=json --output=graph.json","Save JSON graph to file"]],group:"Workspace",loader:()=>import("./handler73.js"),name:"graph",options:i8}),Vt={defaultValue:co,description:"Custom hooks directory",name:"hooks-dir",type:String},Wt=[{defaultValue:void 0,description:"Set to 0 to disable git hooks, 1 to force-enable them under CI (override skipInCI), 2 for debug output",name:"VIS_GIT_HOOKS",type:String}],o8={commandPath:["hook"],description:"Install git hooks for the workspace (migrates husky / prek on prompt)",env:[...Wt],examples:[["vis hook install","Install git hooks in .vis/hooks/"],["vis hook install --hooks-dir=.githooks","Install hooks in a custom directory"],["vis hook install --force","Take over core.hooksPath even when another tool set it"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookInstallExecute})),name:"install",options:[Vt,{defaultValue:!1,description:"Overwrite core.hooksPath even when it points somewhere unexpected",name:"force",type:Boolean}]},a8={commandPath:["hook"],description:"Remove git hooks and reset core.hooksPath",env:[...Wt],examples:[["vis hook uninstall","Remove git hooks and reset core.hooksPath"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookUninstallExecute})),name:"uninstall",options:[Vt]},c8={commandPath:["hook"],description:"Migrate from husky or prek to vis hooks (auto-detected)",env:[...Wt],examples:[["vis hook migrate","Migrate from husky or prek to vis hooks (auto-detected)"],["vis hook migrate --dry-run","Preview what a migration would write without touching disk"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookMigrateExecute})),name:"migrate",options:[Vt,{defaultValue:!1,description:"Preview migrate without writing files",name:"dry-run",type:Boolean}]},l8={commandPath:["hook"],description:"Show configured hooks grouped by stage",env:[...Wt],examples:[["vis hook list","Show configured hooks grouped by stage"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookListExecute})),name:"list",options:[Vt]},d8={commandPath:["hook"],description:"Sanity-check installed hooks and the bundled runner",env:[...Wt],examples:[["vis hook validate","Sanity-check installed hooks and the bundled runner"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookValidateExecute})),name:"validate",options:[Vt]},u8={argument:{description:"Hook stage to run (e.g. pre-commit, commit-msg). Defaults to pre-commit.",name:"stage",type:String},commandPath:["hook"],description:"Run a specific hook stage against tracked files",env:[...Wt],examples:[["vis hook run pre-commit --all-files","Run the pre-commit hooks against every tracked file"],["vis hook run pre-commit --from-ref=main --to-ref=HEAD","Run pre-commit hooks on files changed between two refs"],["vis hook run pre-commit --last-commit","Shortcut for --from-ref HEAD~1 --to-ref HEAD"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookRunExecute})),name:"run",options:[Vt,{defaultValue:!1,description:"Run against every tracked file",name:"all-files",type:Boolean},{defaultValue:void 0,description:"Include files changed since this ref",name:"from-ref",type:String},{defaultValue:void 0,description:"Include files changed up to this ref",name:"to-ref",type:String},{defaultValue:!1,description:"Shortcut for --from-ref HEAD~1 --to-ref HEAD",name:"last-commit",type:Boolean}]},p8={argument:{description:"Target to add (currently: `secrets`)",name:"target",type:String},commandPath:["hook"],description:"Add a managed hook snippet (e.g. `vis secrets --staged`)",env:[...Wt],examples:[["vis hook add secrets","Add a pre-commit hook that runs `vis secrets --staged`"]],group:"Git Hooks",loader:()=>import("./handler71.js").then(e=>({default:e.hookAddExecute})),name:"add",options:[Vt]},f8=[o8,a8,c8,l8,d8,u8,p8],h8={json:{defaultValue:!1,description:"Emit the result as JSON",type:Boolean},target:{description:"Ignore-file target: docker | vercel | npm | slug (default: docker)",type:String},write:{defaultValue:!1,description:"Write the result to disk instead of printing to stdout",type:Boolean}},g8=R({description:"Generate or merge an ignore file (.dockerignore/.vercelignore/.npmignore/.slugignore) without duplicate entries",examples:[["vis ignore","Print a .dockerignore (deduped against an existing one)"],["vis ignore --write","Write/merge the .dockerignore in place"],["vis ignore --target=vercel --write","Write a deduped .vercelignore"],["vis ignore --target=npm --json","Emit the npm-target result as JSON"]],group:"Scaffold & Config",loader:()=>import("./handler53.js"),name:"ignore",options:h8}),m8={yes:{alias:"y",defaultValue:!1,description:"Skip confirmation prompt",type:Boolean}},y8=R({description:"Remove vis from the system (self-uninstall)",examples:[["vis implode","Interactive uninstall"],["vis implode --yes","Non-interactive uninstall (CI)"]],group:"System",loader:()=>import("./handler10.js"),name:"implode",options:m8}),v8={"dry-run":{defaultValue:!1,description:"Print the git plan instead of executing it",type:Boolean},message:{alias:"m",description:"Commit message for the subtree merge",type:String},"no-register":{defaultValue:!1,description:"Do not register the package into the workspace config",type:Boolean},prefix:{alias:"p",description:"Target directory in the monorepo (e.g. packages/tooling/foo)",type:String},ref:{alias:"r",description:"Branch, tag, or commit to import (default: HEAD)",type:String},squash:{defaultValue:!1,description:"Collapse the incoming history into a single merge commit",type:Boolean}},b8=R({argument:{description:"Source git repository URL or local path to import",name:"source",type:String},description:"Import an external repo into the monorepo under a prefix, preserving history",examples:[["vis import git@github.com:me/foo.git --prefix packages/tooling/foo","Import a repo under packages/tooling/foo"],["vis import ../foo --prefix packages/foo --ref v1.2.0","Import a specific tag/branch/commit"],["vis import ../foo --prefix packages/foo --squash","Collapse the incoming history into one commit"],["vis import ../foo --prefix packages/foo --dry-run","Print the git plan without making changes"]],group:"Workspace",loader:()=>import("./handler54.js"),name:"import",options:v8}),w8={json:{defaultValue:!1,description:"Output as JSON",type:Boolean}},k8=R({alias:"view",argument:{description:"Package name followed by optional metadata fields (e.g. 'react version dependencies')",name:"args",type:String},description:"Show npm registry metadata for a package (alias of `npm view` / `pnpm view` / `yarn info` / `bun pm view`)",examples:[["vis info react","Full registry metadata for react"],["vis info react version","Latest version only"],["vis info react versions","All published versions"],["vis info react@18 dependencies","Dependencies of react@18"],["vis info react --json","Emit JSON"],["vis view react","Alias matching npm/pnpm"]],group:"Dependencies",loader:()=>import("./handler11.js"),name:"info",options:w8}),S8={force:{defaultValue:!1,description:"Overwrite existing config file",type:Boolean},"no-interactive":{defaultValue:!1,description:"Skip interactive prompts",type:Boolean},schema:{defaultValue:!1,description:"Print workspace-relative $schema paths for project.json and vis.config.ts, then exit",type:Boolean},"sync-native":{defaultValue:!1,description:"Sync settings to native PM config files",type:Boolean}},x8=R({description:"Initialize vis.config.ts with best-practice security defaults",examples:[["vis init","Interactive setup wizard"],["vis init --no-interactive","Create minimal config without prompts"],["vis init --force","Overwrite existing config"],["vis init --sync-native","Also sync to native PM config files"],["vis init --schema","Print the workspace-relative `$schema` refs to paste into project.json and vis.config.ts"]],group:"Scaffold & Config",loader:()=>import("./handler12.js"),name:"init",options:S8}),$8={json:{defaultValue:!1,description:"Emit findings as a JSON document instead of the human-readable table.",type:Boolean},only:{description:"Comma-separated subset of marshalls to run. Known: author, archivedRepo, downloads, expiredDomains, metadata, newBin, provenance, signatures. Signatures only runs when explicitly requested here.",type:String},strict:{defaultValue:!1,description:"Exit non-zero on any finding (warnings included). Default exits non-zero only on errors.",type:Boolean}},E8=R({argument:{description:"Package to inspect, optionally pinned: `<name>` or `<name>@<spec>`. `<spec>` may be a version, range, or dist-tag.",name:"package"},description:"Run all marshalls against a package without installing it",examples:[["vis inspect express","Run every marshall against express@latest"],["vis inspect lodash@4.17.21","Pin to an exact version"],["vis inspect react@^18","Resolve a semver range, then inspect the best match"],["vis inspect express --json","Emit findings as JSON for CI integration"],["vis inspect express --strict","Exit non-zero on any warning, not just errors"],["vis inspect express --only author,downloads","Run a subset of marshalls"],["vis inspect express --only signatures","Signatures are off by default; opt in with --only"]],group:"Security & Health",loader:()=>import("./handler13.js"),name:"inspect",options:$8}),C8={ci:{defaultValue:!1,description:"Clean install: wipe node_modules then install with frozen lockfile",type:Boolean},dev:{alias:"D",conflicts:"prod",description:"Install devDependencies only (no positional args) / add as dev (with positional args, npm-style)",type:Boolean},exact:{alias:"E",defaultValue:!1,description:"Save exact version (only with positional args; mirrors `npm install -E`)",type:Boolean},filter:{alias:"F",description:"Filter by workspace package name",multiple:!0,type:String},force:{alias:"f",defaultValue:!1,description:"Force reinstall all dependencies",type:Boolean},"frozen-lockfile":{description:"Use frozen lockfile (CI mode, maps to npm ci)",type:Boolean},installer:{description:"Pick the installer explicitly. One of: auto, aube, pnpm, npm, yarn, bun. Overrides VIS_INSTALLER and install.backend in vis.config.",type:String},"lockfile-only":{defaultValue:!1,description:"Update lockfile without installing",type:Boolean},"no-aube":{defaultValue:!1,description:"Skip aube and use the lockfile-detected PM. Wins over --installer / VIS_INSTALLER / install.backend.",type:Boolean},"no-frozen-lockfile":{defaultValue:!1,description:"Opt out of vis's default frozen-lockfile behavior and allow lockfile updates",type:Boolean},"no-marshall-check":{defaultValue:!1,description:"Skip the offline marshall pipeline (only with positional args; mirrors `vis add --no-marshall-check`)",type:Boolean},"no-optional":{defaultValue:!1,description:"Skip optional dependencies",type:Boolean},"no-socket-check":{defaultValue:!1,description:"Skip Socket.dev security check (only with positional args; mirrors `vis add --no-socket-check`)",type:Boolean},"no-typosquat-check":{defaultValue:!1,description:"Skip typosquat name check",type:Boolean},offline:{defaultValue:!1,description:"Use only cached packages",type:Boolean},"prefer-offline":{defaultValue:!1,description:"Prefer cached packages, fall back to network when missing",type:Boolean},prod:{alias:"P",conflicts:"dev",description:"Skip devDependencies (no positional args) / add as peer (with positional args, npm-style)",type:Boolean},recursive:{alias:"r",defaultValue:!1,description:"Install in all workspace packages",type:Boolean},"run-scripts":{defaultValue:!1,description:"Run lifecycle scripts (opts out of vis's default block-by-default policy; allowlisted packages run via security.policies.installScripts.allow)",type:Boolean},"save-optional":{defaultValue:!1,description:"Add as optional dependency (only with positional args; mirrors `npm install -O`)",type:Boolean},silent:{alias:"s",defaultValue:!1,description:"Suppress output",type:Boolean},"workspace-root":{alias:"w",defaultValue:!1,description:"Target workspace root",type:Boolean}},R8=R({alias:"i",argument:{description:"Optional package names. When provided, delegates to `vis add` (enables npm-style `alias npm='vis install'` wrappers).",name:"packages",type:String},description:"Install dependencies using the detected package manager",examples:[["vis install","Install all dependencies (frozen-lockfile by default when a lockfile is present)"],["vis install react react-dom","Delegates to `vis add` — enables shell aliases like `alias npm='vis install'`"],["vis i --no-frozen-lockfile","Allow lockfile updates (escape hatch for the default)"],["vis install --ci","Clean install: wipe node_modules + frozen lockfile (mirrors npm ci / pnpm ci)"],["vis install --prefer-offline","Use cached packages when available, fall back to network"],["vis install --prod","Install production dependencies only"],["vis install --filter app","Install for specific workspace package"],["vis install --run-scripts","Run lifecycle scripts (opts out of vis's default block-by-default policy; allowlisted packages run via security.policies.installScripts.allow)"],["vis install --no-typosquat-check","Skip typosquat name check"],["vis install --installer aube","Force aube as the installer (errors if not on PATH)"],["vis install --no-aube","Bypass aube; use the lockfile-detected PM"]],group:"Dependencies",loader:()=>import("./handler14.js"),name:"install",options:C8}),O8={alias:"ln",argument:{description:"Package name or directory path to link (omit to register current package)",name:"target",type:String},description:"Link a local package for development",examples:[["vis link ./packages/utils","Link local directory package (works on all PMs)"],["vis link","Register current package globally (pnpm <=10, yarn, npm, bun)"],["vis link react","Link global package into current project (pnpm <=10, yarn, npm, bun)"]],group:"Dependencies",loader:()=>import("./handler16.js"),name:"link"},j8={fix:{defaultValue:!1,description:"Apply auto-fixes in place",type:Boolean},format:{defaultValue:"human",description:"Output format: human, json, minimal, sarif, junit, or github",type:String},"max-warnings":{description:"Fail the run if more than N warnings are reported",type:Number},output:{description:"Write formatted output to a file path instead of stdout (also accepts `-`/`stdout`/`stderr`)",type:String},quiet:{defaultValue:!1,description:"Suppress warnings — report errors only",type:Boolean},since:{description:"Only lint files changed vs the given git ref (branch, tag, sha)",type:String},staged:{defaultValue:!1,description:"Only lint files currently staged in the git index",type:Boolean},watch:{defaultValue:!1,description:"Re-run linters whenever watched files change",type:Boolean}},T8=R({description:"Orchestrate detected source-code linters (eslint, …) across the workspace",examples:[["vis lint","Run every detected linter against the workspace"],["vis lint --fix","Apply auto-fixes where the tool supports them"],["vis lint --format json","Emit findings as JSON for CI / editor integrations"],["vis lint --format sarif","Emit a SARIF 2.1.0 document for code-scanning uploads"],["vis lint --format junit","Emit a JUnit XML report for CI dashboards"],["vis lint --format github","Emit GitHub Actions workflow commands for inline PR annotations"],["vis lint src/foo.ts src/bar.ts","Lint a specific file list"],["vis lint --quiet","Suppress warnings — only errors are reported"],["vis lint --max-warnings 0","Treat any warning as a failure"],["vis lint --since main","Only lint files changed vs the main branch"],["vis lint --staged","Only lint files currently staged in the git index"],["vis lint --watch","Re-run linters when watched files change (cache makes incremental near-free)"],["vis lint --format sarif --output lint.sarif","Write the SARIF report to lint.sarif instead of stdout"]],group:"Lint & Format",loader:()=>import("./handler63.js"),name:"lint",options:j8}),I8={"dep-type":{description:"Restrict --deps to specific dep blocks (repeatable)",multiple:!0,type:String},deps:{defaultValue:!1,description:"Render a dep-instance view (table by default; use --format=ndjson|json for jq-friendly streams)",type:Boolean},exclude:{description:"With --deps: glob of declaring package names to drop (repeatable)",multiple:!0,type:String},"external-only":{defaultValue:!1,description:"With --deps: only show external/registry deps",type:Boolean},format:{description:"Output format: table (default), json (single document), or ndjson (one record per line; --deps only)",type:String},include:{description:"With --deps: glob of declaring package names to keep (repeatable)",multiple:!0,type:String},inferred:{defaultValue:!1,description:"Filter target rows to only inferred targets (implies --targets)",type:Boolean},"internal-only":{defaultValue:!1,description:"With --deps: only show internal/workspace deps",type:Boolean},pretty:{defaultValue:!1,description:"Pretty-print with 2-space indent (only meaningful with --format=json)",type:Boolean},query:{description:"Filter projects by query",type:String},tag:{description:'Only list projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…".',multiple:!0,type:String},targets:{defaultValue:!1,description:"Show per-target rows (type, cache, description)",type:Boolean}},A8=R({description:"List all workspace projects with metadata",examples:[["vis list","Show all projects"],["vis list --targets","Per-target rows with type, cache status and description"],["vis list --targets --inferred","Only show targets synthesized by Project Crystal-style inference"],["vis list --deps","Human-readable table of every dep-instance across the workspace"],["vis list --deps --internal-only","Only workspace deps in human form"],["vis list --deps --format=ndjson","Stream every dep-instance as NDJSON for jq pipelines"],["vis list --deps --format=json --pretty","Single pretty-printed JSON array of dep-instances"],["vis list --format=json","Machine-readable project listing"],['vis list --query "tag=frontend"',"Filter by query"],["vis list --tag=type:package","Filter by tag (shorthand for the query above)"]],group:"Workspace",loader:()=>import("./handler55.js"),name:"list",options:I8}),Re={"dry-run":{defaultValue:!1,description:"Preview changes without applying",type:Boolean},yes:{alias:"y",defaultValue:!1,description:"Skip the confirmation prompt",type:Boolean}},P8={...Re},B8=R({commandPath:["migrate"],description:"Migrate dependencies and scripts to vis",group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateDepsExecute"),name:"deps",options:P8}),N8={...Re},D8=R({commandPath:["migrate"],description:"Inline lint-staged configuration into vis",group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateLintStagedExecute"),name:"lint-staged",options:N8}),L8={...Re},M8=R({commandPath:["migrate"],description:"Inline nano-staged configuration into vis",group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateNanoStagedExecute"),name:"nano-staged",options:L8}),_8={...Re},F8=R({commandPath:["migrate"],description:"Migrate turborepo tasks/config to vis",group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateTurborepoExecute"),name:"turborepo",options:_8}),V8={...Re,aggressive:{defaultValue:!1,description:"Auto-apply the safe cleanup items the migrator would otherwise leave on the checklist: delete nx.json + ignore-files-for-nx-affected.yml, strip nx/@nx/*/@nrwl/* devDependencies, rewrite mechanical `nx run-many|run|affected` scripts. Implies --force.",type:Boolean},force:{defaultValue:!1,description:"Overwrite an existing vis.config.ts (a .bak is taken first)",type:Boolean},"rewrite-sync-generators":{defaultValue:!1,description:"For each project.json `syncGenerators`, add a `pre<target>` script to sibling package.json (with a TODO for the user to wire up)",type:Boolean}},W8=R({commandPath:["migrate"],description:"Migrate nx targets/config to vis",group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateNxExecute"),name:"nx",options:V8}),H8={...Re,"copy-templates":{defaultValue:!1,description:"Copy .moon/templates/* into .vis/templates/* so `vis generate` works without .moon/",type:Boolean}},U8=R({commandPath:["migrate"],description:"Migrate moon tasks/templates to vis",group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateMoonExecute"),name:"moon",options:H8}),G8={...Re},z8=R({commandPath:["migrate"],description:"Migrate gitleaks config/baseline/hooks to `vis secrets`",examples:[["vis migrate gitleaks","Migrate gitleaks config/baseline/hooks to `vis secrets`"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateGitleaksExecute"),name:"gitleaks",options:G8}),J8={...Re},q8=R({commandPath:["migrate"],description:"Migrate Kingfisher baseline/hooks/scripts to `vis secrets`",examples:[["vis migrate kingfisher","Migrate Kingfisher baseline/hooks/scripts to `vis secrets`"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateKingfisherExecute"),name:"kingfisher",options:J8}),K8={...Re},Y8=R({commandPath:["migrate"],description:"Replace secretlint with `vis secrets`",examples:[["vis migrate secretlint","Replace secretlint with `vis secrets`"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateSecretlintExecute"),name:"secretlint",options:K8}),X8={...Re},Z8=R({commandPath:["migrate"],description:"Translate syncpack customTypes into vis policy and strip the syncpack dep/scripts",examples:[["vis migrate syncpack","Translate syncpack customTypes into vis policy and strip the syncpack dep/scripts"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateSyncpackExecute"),name:"syncpack",options:X8}),Q8={...Re},eR=R({commandPath:["migrate"],description:"Strip sherif config/dep/scripts and surface ignore-rules as a positive `vis lint --<rule>` command",examples:[["vis migrate sherif","Strip sherif config/dep/scripts and surface ignore-rules as a positive `vis lint --<rule>` command"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateSherifExecute"),name:"sherif",options:Q8}),tR={...Re},nR=R({commandPath:["migrate"],description:"Auto-rewrite vis.config.ts to use renamed fields (targetDefaults → tasks, taskDefaults → scopedTasks, taskRunnerOptions → taskRunner)",examples:[["vis migrate self","Rewrite vis.config.ts in-place (a .bak is taken first)"],["vis migrate self --dry-run","Preview the rewrite without writing"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateSelfExecute"),name:"self",options:tR}),sR={},iR=R({commandPath:["migrate"],description:"Audit the workspace for stray gitleaks/secretlint/sherif/syncpack references (exit 1 on issues)",examples:[["vis migrate verify","Audit the workspace for stray gitleaks/secretlint/sherif/syncpack references (exit 1 on issues)"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateVerifyExecute"),name:"verify",options:sR}),rR={"fail-on":{description:"Exit non-zero on: error (default) | warning",type:String},format:{description:"Output format: table | json | ndjson (default: table)",type:String},from:{description:"Source tool to compare against (turbo|nx|moon). Auto-detected when omitted.",type:String}},oR=R({commandPath:["migrate"],description:"Prove a turbo/nx/moon → vis migration preserved the task graph + cache-key surface (exit 1 on divergence)",examples:[["vis migrate verify-graph","Auto-detect the source tool and diff its task graph against the migrated vis.config.ts"],["vis migrate verify-graph --from turbo --format json","Machine-readable equivalence report on stdout (Axis A)"],["vis migrate verify-graph --fail-on warning","Also gate CI on additive/extra-target warnings"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateVerifyGraphExecute"),name:"verify-graph",options:rR}),aR={...Re},cR=R({commandPath:["migrate"],description:"Run every applicable migration non-interactively (autodetected)",examples:[["vis migrate all --yes","Run every detected migration without prompting (CI-friendly)"],["vis migrate all --dry-run","Preview every detected migration without writing files"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateAllExecute"),name:"all",options:aR}),lR=[cR,B8,D8,M8,F8,W8,U8,nR,z8,q8,Y8,Z8,eR,iR,oR],dR={"dry-run":{alias:"d",defaultValue:!1,description:"Preview available optimizations without applying",type:Boolean},format:{description:"Output format: table or json (default: table)",type:String},"no-install":{defaultValue:!1,description:"Skip running install after applying overrides",type:Boolean},pin:{defaultValue:!1,description:"Pin Socket.dev overrides to exact versions",type:Boolean},prod:{defaultValue:!1,description:"Only optimize production dependencies",type:Boolean}},uR=R({description:"Analyze and optimize dependencies using e18e replacements and @socketregistry overrides",examples:[["vis optimize","Interactive TUI to select and apply optimizations"],["vis optimize --dry-run","Preview available optimizations"],["vis optimize --pin","Pin Socket.dev overrides to exact versions"],["vis optimize --prod","Only optimize production dependencies"]],group:"Workspace",loader:()=>import("./handler70.js").then(e=>e.h),name:"optimize",options:dR}),pR={argument:{description:"Subcommand and arguments (e.g., cache dir, publish --dry-run, list --depth 0)",name:"args",type:String},description:"Package manager utilities (cache, publish, audit, list, config, etc.)",examples:[["vis pm cache dir","Show cache directory"],["vis pm cache clean","Clean cache"],["vis pm publish --dry-run","Preview publishing"],["vis pm list --depth 0","List direct dependencies"],["vis pm audit","Run security audit"],["vis pm whoami","Show logged-in user"]],group:"System",loader:()=>import("./handler17.js"),name:"pm"},fR={empty:{description:"Author an empty change file (no bumps; satisfies non-strict `check`)",type:Boolean},"from-bot-pr":{description:"Inspect the current PR (via `gh pr view`) and author a change file from its Dependabot / Renovate title (changesets #647)",type:Boolean},message:{description:"Changelog body for the change file",type:String},name:{description:"Slug for the filename (default: random animal name)",type:String},none:{description:"Author a `none` change file (acknowledged but no direct bump)",type:Boolean},packages:{description:"Comma-separated package:level pairs (e.g. '@scope/a:minor,@scope/b:patch')",type:String}},hR=R({commandPath:["release"],description:"Author a new change file (interactive, or non-interactive via --packages)",examples:[["vis release add","Interactive prompt"],["vis release add --packages '@scope/cerebro:minor,@scope/string:patch' --message 'Add tab completion'","Non-interactive"],["vis release add --empty","Author an empty change file (acknowledges PR but releases nothing)"],["vis release add --name fix-tab-completion","Use a fixed slug instead of a random animal name"],["vis release add --from-bot-pr","Generate a change file from the current Dependabot / Renovate PR (changesets #647)"]],group:"Release",loader:()=>import("./handler31.js"),name:"add",options:fR}),gR={channel:{description:"Override channel (defaults to current branch lookup)",type:String},filter:{description:"Limit to packages matching this glob (CSV)",type:String},json:{description:"Emit machine-readable JSON",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},mR=R({commandPath:["release"],description:"Render the would-be changelog entries without writing to disk",examples:[["vis release changelog","Print rendered entries for the pending plan"],["vis release changelog --json","Emit ChangelogResult (with projectChangelogs[]) as JSON"]],group:"Release",loader:()=>import("./handler32.js"),name:"changelog",options:gR}),yR={hook:{description:"Hook context (pre-commit, pre-push) — affects which file states are counted",type:String},"no-fail":{description:"Always exit 0; warnings still print to stderr",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String},strict:{description:"Require every changed package to have its own non-empty change file",type:Boolean}},vR=R({commandPath:["release"],description:"Verify pending change files cover changed packages — CI / husky gate",examples:[["vis release check","Pass if at least one change file exists"],["vis release check --strict","Fail if any changed package isn't covered by a change file"],["vis release check --hook pre-commit","Run as a husky pre-commit hook"],["vis release check --no-fail","Print warnings but always exit 0"]],group:"Release",loader:()=>import("./handler33.js"),name:"check",options:yR}),bR={"no-fail":{description:"Always exit 0 (warnings still print)",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String},strict:{description:"Require every changed package to be covered by a change file",type:Boolean}},wR=R({commandPath:["release","ci"],description:"CI: post or update a sticky PR comment with the pending release plan",examples:[["vis release ci check","Resolve PR from GITHUB_REF, post/update the release plan comment"],["vis release ci check --strict","Fail if any changed package isn't covered"]],group:"Release",loader:()=>import("./handler34.js"),name:"check",options:bR}),kR={"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},SR=R({commandPath:["release","ci"],description:"CI: emit JSON plan + write to $GITHUB_OUTPUT for workflow gating",examples:[["vis release ci plan","Emit { mode, packages, json } and set $GITHUB_OUTPUT"]],group:"Release",loader:()=>import("./handler35.js"),name:"plan",options:kR}),xR={base:{description:"Override the base branch (default: release.baseBranch)",type:String},branch:{description:"Override the version-PR branch (default: vis-release/version-packages)",type:String}},$R=R({commandPath:["release","ci"],description:"CI: rebase the open version-PR onto the base branch and force-push",examples:[["vis release ci rebase-pr","Rebase the version-PR branch onto base + force-push"],["vis release ci rebase-pr --branch=release/version","Override the version-PR branch"]],group:"Release",loader:()=>import("./handler36.js"),name:"rebase-pr",options:xR}),ER={"auto-publish":{description:"Skip version-PR; version + publish inline",type:Boolean},branch:{description:"Override version-PR branch (default: vis-release/version-packages)",type:String},channel:{description:"Override channel (defaults to current branch lookup)",type:String},"first-release":{description:"Bootstrap mode for greenfield monorepos: force currentVersionResolver=disk and skip remote tag-collision checks. Use on the very first release before any git tags exist.",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},CR=R({commandPath:["release","ci"],description:"CI: maintain a rolling version-PR (default) or version+publish inline (--auto-publish)",examples:[["vis release ci release","On push to main: open/update Versioned release PR; on PR merge: publish"],["vis release ci release --auto-publish","Skip version-PR; version + publish inline (alpha/beta workflow)"]],group:"Release",loader:()=>import("./handler56.js"),name:"release",options:ER}),RR={},OR=R({commandPath:["release","ci"],description:"CI: print setup checklist for tokens (VIS_GH_TOKEN, NPM_TOKEN, OIDC) and workflow permissions",examples:[["vis release ci setup","Walk through the recommended secrets + workflow setup"]],group:"Release",loader:()=>import("./handler37.js"),name:"setup",options:RR}),jR={"on-close":{description:"PR-close cleanup mode — enumerate the closed PR's commit SHAs and remove their snapshot tags from the registry (when supported by the backend)",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String},tag:{description:"Override dist-tag (default: pr-<PR_NUMBER>)",type:String}},TR=R({commandPath:["release","ci"],description:"CI: publish snapshot of affected packages + post sticky PR comment with install instructions",examples:[["vis release ci snapshot --tag pr-1234","Publish PR snapshot + post install snippet"]],group:"Release",loader:()=>import("./handler38.js"),name:"snapshot",options:jR}),IR={"first-release":{description:"Bootstrap mode for greenfield monorepos: doctor asserts the workspace has no release tags and no package has been published yet. Pair with `vis release version --first-release`.",type:Boolean},json:{description:"Emit machine-readable JSON instead of a table",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},AR=R({commandPath:["release"],description:"Preflight diagnostics for the release subsystem (workspace, PM, OIDC, NAPI, guards)",examples:[["vis release doctor","Run all checks; exit non-zero if any error"],["vis release doctor --json","Emit machine-readable report"]],group:"Release",loader:()=>import("./handler39.js"),name:"doctor",options:IR}),PR={"dry-run":{description:"Print would-be content without writing",type:Boolean},from:{description:"Git ref to compare against (default: merge-base with baseBranch)",type:String},name:{description:"Slug for the generated filename (default: random animal name)",type:String},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},BR=R({commandPath:["release"],description:"Auto-derive a change file from branch commits (conventional-commits + path heuristics)",examples:[["vis release generate","Walk commits since the merge-base with baseBranch"],["vis release generate --from origin/main","Walk commits since the given ref"],["vis release generate --dry-run","Print the would-be content without writing"]],group:"Release",loader:()=>import("./handler65.js"),name:"generate",options:PR}),NR={agent:{description:"Append a 'Releasing with vis' section to AGENTS.md so AI agents know how to drive the release flow",type:Boolean},apply:{description:"Actually perform the migration writes (not dry-run)",type:Boolean},"dry-run":{description:"Print what would happen without writing files",type:Boolean},fresh:{description:"Skip migration; start clean",type:Boolean},"from-bumpy":{description:"Force migration from bumpy",type:Boolean},"from-changesets":{description:"Force migration from changesets",type:Boolean},"from-semantic-release":{description:"Force migration from semantic-release / multi-semantic-release",type:Boolean},"package-manager":{description:"Override package manager when generating workflows (npm | pnpm | yarn | bun). Default: auto-detect",type:String},workflows:{description:"Generate CI workflow files. GitHub → `.github/workflows/vis-release{,-check,-snapshot}.yml`. GitLab → `.gitlab-ci.yml`.",type:Boolean},yes:{alias:"y",description:"Auto-confirm prompts (CI-safe)",type:Boolean}},DR=R({commandPath:["release"],description:"Scaffold .vis/release; migrate from changesets / bumpy / semantic-release",examples:[["vis release init","Auto-detect source tool and scaffold"],["vis release init --from-semantic-release","Force semantic-release migration"],["vis release init --from-changesets","Force changesets migration"],["vis release init --fresh","Skip migration; start clean"],["vis release init --dry-run","Print what would happen without writing files"],["vis release init --from-semantic-release --apply","Actually perform the semantic-release migration writes"]],group:"Release",loader:()=>import("./handler40.js"),name:"init",options:NR}),LR={channel:{description:"Override channel (defaults to current branch lookup)",type:String},"first-release":{description:"Bootstrap mode for greenfield monorepos: preview the plan without registry / tag lookups (matches `vis release version --first-release`).",type:Boolean},json:{description:"Emit a JSON `{ name: { from, to } }` map instead of pretty lines",type:Boolean},package:{description:"Limit output to a single package",type:String},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},MR=R({commandPath:["release"],description:"Print the next computed version for each package in the release plan. Read-only; no mutations.",examples:[["vis release next-version","Print `<pkg> <old> -> <new>` for every package in the plan"],["vis release next-version --package=@scope/a","Single-package mode"],["vis release next-version --json","Emit a `{ name: { from, to } }` JSON map"]],group:"Release",loader:()=>import("./handler41.js"),name:"next-version",options:LR}),_R={action:{defaultOption:!0,defaultValue:"test",description:"Subcommand: test",type:String},channel:{description:"Restrict dispatch to a single channel kind (`slack`, `discord`, `webhook`) or an id'd channel (`slack:eng`)",type:String},"custom-context":{description:"Path to a JSON file containing a NotificationContext to use instead of the synthetic default",type:String},json:{description:"Emit machine-readable JSON instead of a per-channel report",type:Boolean}},FR=R({commandPath:["release"],description:"Dry-run the configured notification channels (slack / discord / webhook / plugins) with a synthetic release",examples:[["vis release notifications test","Dispatch a fake release to every configured channel"],["vis release notifications test --channel=slack","Dispatch to every Slack channel only"],["vis release notifications test --channel=slack:eng","Dispatch to the slack channel with id=eng only"],["vis release notifications test --custom-context=./fake.json","Use operator-supplied JSON instead of the built-in synthetic release"],["vis release notifications test --json","Emit machine-readable results"]],group:"Release",loader:()=>import("./handler42.js"),name:"notifications",options:_R}),VR={channel:{description:"Override channel (defaults to current branch lookup)",type:String},filter:{description:"Filter packages by name glob",type:String},interactive:{alias:"i",description:"Walk through pending releases interactively and accept / override each bump level",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String},write:{description:"When used with --interactive, write the chosen overrides to a new change file (.vis/release/<id>.md)",type:Boolean}},WR=R({commandPath:["release"],description:"Inspect the release plan; with --interactive, walk through and override bump levels",examples:[["vis release plan","Emit pending plan as JSON"],["vis release plan --interactive","Walk through pending releases, accept or override each bump"],["vis release plan -i --write","Walk through interactively and write the chosen overrides to a change file"]],group:"Release",loader:()=>import("./handler43.js"),name:"plan",options:VR}),HR={action:{defaultOption:!0,defaultValue:"status",description:"Subcommand: enter | exit | status",type:String},...fe({defaultValue:!0,description:"Commit pre.json after writing. Default: commit",name:"commit",type:Boolean}),...fe({defaultValue:!0,description:"Push the commit. Default: push",name:"push",type:Boolean}),tag:{description:"Prerelease tag (e.g. alpha, beta, rc). Required for `enter`",multiple:!0,type:String}},UR=R({commandPath:["release"],description:"Enter / exit pre-release mode (changesets-compatible — every `version` produces a prerelease until exit)",examples:[["vis release pre enter alpha","Enter pre-mode with the `alpha` tag"],["vis release pre enter rc --no-commit","Enter pre-mode locally without committing pre.json"],["vis release pre exit","Flag the next `version` to consolidate + exit pre-mode"],["vis release pre status","Print whether pre-mode is active, exit-pending, or off"]],group:"Release",loader:()=>import("./handler45.js"),name:"pre",options:HR}),GR={access:{description:"Publish access: public | restricted (default: public)",type:String},"allow-stage-publish":{description:"Trust claim: also grant the staged-publish permission (--allow-stage-publish)",type:Boolean},"dry-run":{description:"Print what would publish without uploading",type:Boolean},env:{description:"Trust claim: restrict to a deployment environment (npm trust --env)",type:String},filter:{description:"Glob filter (CSV) — limit to specific packages",type:String},force:{description:"Publish a placeholder even if the package already exists on the registry",type:Boolean},"no-trust":{description:"Skip the `npm trust` step (only publish placeholders)",type:Boolean},"print-config":{description:"Print the resolved release config and exit",type:String},provider:{description:"Trust claim: forge provider (github | gitlab). Default: auto-detect from the git remote",type:String},registry:{description:"Override registry URL",type:String},repo:{description:"Trust claim: owner/repo (github) or group/project (gitlab). Default: detect from git remote",type:String},tag:{description:"dist-tag for the placeholder (default: placeholder — keeps `latest` unset)",type:String},version:{description:"Placeholder version (default: 0.0.0)",type:String},workflow:{description:"Trust claim: workflow/pipeline filename (npm trust --file). Default: auto-detect the release workflow",type:String}},zR=R({commandPath:["release"],description:"Publish non-functional placeholder packages so npm Trusted Publishing (OIDC) can be configured before the first release",examples:[["vis release pretrust","Publish a placeholder for every managed package missing from the registry"],["vis release pretrust --filter '@scope/*'","Limit to a glob"],["vis release pretrust --dry-run","Print what would be published without uploading"]],group:"Release",loader:()=>import("./handler57.js"),name:"pretrust",options:GR}),JR={channel:{description:"Override channel (defaults to current branch lookup)",type:String},"check-only":{description:"Run preflight checks (config + workspace + plan + auth) and exit. No mutations.",type:Boolean},"dry-run":{description:"Skip uploads — print what would happen",type:Boolean},filter:{description:"Limit to packages matching this glob (CSV)",type:String},"first-release":{description:"Bootstrap mode for greenfield monorepos: force currentVersionResolver=disk and skip remote tag-collision checks. Use on the very first release before any git tags exist.",type:Boolean},"no-push":{description:"Skip `git push --tags` after publish (lands in M5)",type:Boolean},otp:{description:"2FA OTP token",type:String},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String},resume:{description:"Resume from a previous run's state file (skips already-published packages)",type:Boolean},tag:{description:"Override npm dist-tag",type:String}},qR=R({commandPath:["release"],description:"Pack-then-publish unpublished packages, push tags, create GH releases",examples:[["vis release publish","Publish all pending packages"],["vis release publish --dry-run","Print what would publish without uploading"],["vis release publish --tag alpha","Override dist-tag"],["vis release publish --filter '@scope/*'","Limit to packages matching the glob"]],group:"Release",loader:()=>import("./handler46.js"),name:"publish",options:JR}),KR={"dry-run":{description:"Print what would publish without uploading",type:Boolean},filter:{description:"Glob filter (CSV) — limit snapshots to specific packages",type:String},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String},registry:{description:"Override registry URL (defaults to pkg-pr-new backend or `release.snapshot.registry`)",type:String},tag:{description:"Required: dist-tag for the snapshot release",type:String}},YR=R({commandPath:["release"],description:"Publish 0.0.0-<tag>-<sha> snapshot versions of affected packages",examples:[["vis release snapshot --tag pr-1234","Publish snapshots tagged with the PR number"],["vis release snapshot --tag canary --filter '@scope/*'","Limit to a glob"],["vis release snapshot --tag pr-1234 --dry-run","Preview without uploading"]],group:"Release",loader:()=>import("./handler47.js"),name:"snapshot",options:KR}),XR={action:{defaultOption:!0,defaultValue:"list",description:"Subcommand: list | approve | reject",type:String},all:{description:"Approve every pending stage tracked in .vis/release/staged.json",type:Boolean},...fe({defaultValue:!0,description:"Update .vis/release/staged.json but skip the auto-commit. Default: commit",name:"commit",type:Boolean}),filter:{description:"Package name filter for `list`",type:String},json:{description:"Emit machine-readable JSON",type:Boolean},...fe({defaultValue:!0,description:"Skip pushing the registry commit to the remote. Default: push",name:"push",type:Boolean}),"stage-ids":{description:"Stage IDs (positional args after the action)",multiple:!0,type:String}},ZR=R({commandPath:["release"],description:"List, approve, or reject npm staged-publish records (RFC §13.6 — approve/reject need 2FA)",examples:[["vis release stage list","List every staged version (both npm + the local .vis/release/staged.json registry)"],["vis release stage list @scope/pkg","List staged versions for a single package"],["vis release stage list --json","Emit a machine-readable view of both sources"],["vis release stage approve <stage-id>","Promote a staged version, drain it from staged.json, commit + push the registry"],["vis release stage approve --all","Approve every pending stage tracked in .vis/release/staged.json"],["vis release stage reject <stage-id>","Reject a staged version (permanent — cannot be re-approved unless re-staged)"],["vis release stage approve <stage-id> --no-push","Approve, update the registry, commit locally (skip the push)"],["vis release stage approve <stage-id> --no-commit","Approve and update the registry only — no git commit"]],group:"Release",loader:()=>import("./handler48.js"),name:"stage",options:XR}),QR={bump:{description:"Filter by bump level (CSV: major,minor,patch)",type:String},channel:{description:"Override channel (defaults to current branch lookup)",type:String},filter:{description:"Filter packages by name glob",type:String},json:{description:"Emit machine-readable JSON instead of a table",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},e3=R({commandPath:["release"],description:"Print pending release plan (which packages will bump and to what version)",examples:[["vis release status","Print pending plan in human-readable format"],["vis release status --json","Emit the plan as JSON for scripting / CI"],["vis release status --bump major,minor","Filter to packages getting major or minor bumps"],["vis release status --filter '@scope/*'","Show only packages matching the glob"]],group:"Release",loader:()=>import("./handler44.js"),name:"status",options:QR}),t3={channel:{description:"Override channel (defaults to current branch lookup)",type:String},"check-only":{description:"Run preflight checks (config + workspace + plan) and exit. No mutations.",type:Boolean},commit:{description:"Auto-commit after applying",type:Boolean},"dry-run":{description:"Skip writes — print the diff and exit",type:Boolean},filter:{description:"Limit to packages matching this glob (CSV)",type:String},"first-release":{description:"Bootstrap mode for greenfield monorepos: force currentVersionResolver=disk and skip remote tag-collision checks. Use on the very first release before any git tags exist.",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},n3=R({commandPath:["release"],description:"Apply pending change files to disk: bump versions + write CHANGELOG entries",examples:[["vis release version","Apply the plan to disk"],["vis release version --dry-run","Print what would change without touching disk"],["vis release version --channel alpha","Force a specific channel (overrides branch detection)"]],group:"Release",loader:()=>import("./handler49.js"),name:"version",options:t3}),s3=[hR,BR,e3,WR,mR,vR,AR,MR,n3,qR,YR,ZR,UR,zR,DR,FR,wR,SR,CR,$R,TR,OR],i3={filter:{alias:"F",description:"Filter by workspace package name",multiple:!0,type:String},global:{alias:"g",defaultValue:!1,description:"Remove global package",type:Boolean},recursive:{alias:"r",defaultValue:!1,description:"Remove from all workspace packages",type:Boolean},"save-dev":{alias:"D",defaultValue:!1,description:"Remove from devDependencies",type:Boolean},"workspace-root":{alias:"w",defaultValue:!1,description:"Remove from workspace root",type:Boolean}},r3=R({alias:["rm","un","uninstall"],argument:{description:"Packages to remove",name:"packages",type:String},description:"Remove packages using the detected package manager",examples:[["vis remove lodash","Remove a package"],["vis rm old-package","Remove using alias"],["vis remove --filter app react","Remove from specific workspace"],["vis remove -g typescript","Remove global package"]],group:"Dependencies",loader:()=>import("./handler18.js"),name:"remove",options:i3}),o3={failed:{defaultValue:!1,description:"Filter the replay to failed tasks only",type:Boolean},format:{description:"Output format: table or json (default: table)",type:String},list:{defaultValue:!1,description:"List every available run instead of replaying one",type:Boolean},run:{description:"Run id to replay (defaults to the most recent run)",type:String},task:{description:"Filter the replay to a single task id (e.g. @my/app:build)",type:String}},a3=R({description:"Replay a previous task run from .vis/runs/ — show task results without re-executing",examples:[["vis replay","Show the most recent run summary"],["vis replay --run 2026-04-28T12-34-56_ab12","Inspect a specific historical run"],["vis replay --list","List every recorded run, newest first"],["vis replay --task @myorg/app:build","Focus on one task within the loaded run"],["vis replay --failed","Filter to only failed tasks"],["vis replay --format=json","Machine-readable output for CI"]],group:"Workspace",loader:G(()=>import("./handler19.js"),"replayExecute"),name:"replay",options:o3}),c3={filter:{alias:"F",description:"pnpm-style package selector (repeatable). Supports name globs (@org/*), graph modifiers (...pkg dependents, pkg... dependencies, ...^pkg / pkg^... exclude self), changed-since ([main], ...[origin/main]), and path globs (./packages/*, {glob}).",multiple:!0,type:String},projects:{alias:"p",description:"Comma-separated list of projects to run",type:String},"skip-toolchain":{defaultValue:!1,description:"Skip the toolchain pre-flight (no auto-install for any pinned tool: node / pnpm / yarn / npm / bun / deno / go / python / ruby / rust)",type:Boolean},...fe({description:"Detect lockfile/node_modules drift before running (warns in TTY, fails in CI). Use --no-preflight to disable.",name:"preflight",type:Boolean}),parallel:{defaultValue:3,description:"Maximum number of parallel tasks (falls back to VIS_RUN_CONCURRENCY_LIMIT env var, then 3)",type:Number},...fe({defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean}),affected:{defaultValue:!1,description:"Only run on projects affected by git changes. Honors --base/--head/--downstream/--upstream, same as `vis affected`.",type:Boolean},base:{description:"Git base ref for --affected. When omitted, vis auto-resolves it from the active CI provider (GitHub/GitLab/Buildkite/CircleCI) or falls back to `git merge-base HEAD origin/<defaultBase>` locally. Default base branch comes from `vis.config.ts#defaultBase` (or `main`). Requires --affected.",type:String},"cache-backend":{description:"Remote cache wire backend: http (Turborepo-compatible) or reapi (Bazel Remote Execution API gRPC)",type:String},"cache-dir":{description:"Custom cache directory",type:String},"cache-mode":{description:"Remote cache mode: read | write | readwrite (defaults to readwrite when remoteCache is configured)",type:String},downstream:{description:'Downstream scope for --affected: "none", "direct", or "deep" — controls how far to include dependents of changed projects (default "deep"). Requires --affected.',type:String},"dry-run":{defaultValue:!1,description:"Show what would run without executing",type:Boolean},"hash-mode":{description:"Override how the requested target is hashed for this run: declared (hash listed inputs) or trace (hash the files the task actually reads). Overrides per-target hashMode config for the directly-run target.",type:String},head:{description:"Git head ref for --affected. When omitted, auto-resolves from CI env (e.g. `$GITHUB_SHA`) or defaults to `HEAD`. Requires --affected.",type:String},partition:{description:'Partition tasks for distributed CI (e.g., "1/4" for first of four runners). Falls back to VIS_PARTITION env var.',type:String},query:{description:"Filter matched projects by a query (e.g. 'language=typescript && tag=lib')",type:String},"skip-cache":{description:"Comma-separated selectors of tasks to bypass cache for (e.g. 'app:test', ':e2e', '#flaky:lint'). Other tasks in the run still cache normally. --no-cache wins when both are set.",type:String},"skip-constraints":{defaultValue:!1,description:"Skip project constraint validation",type:Boolean},summarize:{defaultValue:!1,description:"Generate a run summary after execution",type:Boolean},tag:{description:'Only run projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…"; combines with --query as AND.',multiple:!0,type:String},upstream:{description:'Upstream scope for --affected: "none", "direct", or "deep" — controls how far to include dependencies of changed projects (default "none"). Requires --affected.',type:String},...fe({description:"Include uncommitted working-tree changes when computing --affected. Defaults to on for local runs and off in CI; use --no-uncommitted to force off.",name:"uncommitted",type:Boolean}),"fail-fast":{defaultValue:!1,description:"Stop all tasks on first failure",type:Boolean},"last-details":{defaultValue:!1,description:"Render the most-recent run's saved summary (from .vis/last-summary.json) and exit without executing any tasks",type:Boolean},log:{description:"Output mode: interleaved (pass-through), labeled (prefix each line with [pkg#task]), or grouped (vite-task-style block)",type:String},"output-style":{description:"Output style: normal (print every task) or quiet (skip output for successful/cached tasks; failed tasks still print in CI mode, and remain in TUI scrollback in interactive mode). Defaults to normal; set run.quietOnSuccess in config to make quiet the default. Per-target options.outputStyle overrides this.",type:String},profile:{description:"Write a Chrome Tracing JSON profile of the run to this path (open in chrome://tracing or Perfetto)",type:String},pty:{defaultValue:!1,description:"Run every task through a pseudo-terminal so color-aware tools render as if attached to a TTY (disables caching)",type:Boolean},"retry-budget":{description:"Global retry budget: cap on total task retries across the run (per-target retryCount is still honored up to the budget)",type:Number},reverse:{defaultValue:!1,description:"Run the dependency graph in reverse (leaves first, then their dependents). Useful for teardown targets like `destroy`/`undeploy` where dependents must run before the things they depend on.",type:Boolean},watch:{defaultValue:!1,description:"Rerun affected tasks on file change. Ctrl+C to exit.",type:Boolean},...fe({defaultValue:!0,description:"Show flaky task report on failure (use --no-flaky to suppress)",name:"flaky",type:Boolean}),"fail-on-retry":{defaultValue:!1,description:"Treat any task that needed at least one retry as a run failure (exit non-zero), even when retries eventually succeeded. Use in CI to surface flakes that retries would otherwise mask.",type:Boolean},...fe({description:"Fail a task if its command references an env var that is unset (no silent empty-string substitution). Use --no-strict-env to disable when set in config.",name:"strict-env",type:Boolean}),"runner-tags":{description:"Comma-separated tags this runner advertises (e.g. 'gpu,slow'). Tasks declaring `options.runnerTags` only run when at least one tag overlaps. Untagged tasks always run. Falls back to VIS_RUNNER_TAGS env var.",type:String},services:{description:"Auto-start service deps. One of: auto | ephemeral | persistent | off. Defaults to `auto` in TTY, `off` in CI.",type:String},"stop-services":{defaultValue:!1,description:"Stop services this run auto-started in registry mode when the run exits (clean, q, or Ctrl+C). Ephemeral services already die with the run.",type:Boolean}},l3=R({argument:{description:"The target to run (e.g., build, test, lint)",name:"target",type:String},description:"Run a target across workspace projects",examples:[["vis run","List all available targets"],["vis run build","Run build on all projects"],["vis run :build","Run build on all projects (moon-style)"],["vis run ~:test","Run test on the project closest to the current directory"],['vis run "#frontend:build"',"Run build on projects tagged 'frontend'"],['vis run :build --query "language=typescript"',"Filter by project metadata"],['vis run build --filter "@org/web"',"Run build on a single package (pnpm filter)"],['vis run build --filter "...@org/web"',"Run build on @org/web and everything that depends on it"],['vis run build -F "@org/web..."',"Run build on @org/web and its dependencies"],['vis run build -F "...[origin/main]"',"Run build on packages changed since origin/main + their dependents"],['vis run build -F "./packages/*"',"Run build on packages matched by a path glob"],["vis run test --affected","Run test only on git-changed projects"],["vis run build --fail-fast","Stop on first failure"],["vis run build --dry-run","Show execution plan without running"],["vis run destroy --reverse","Run leaves-first (teardown order, e.g. CDK/Pulumi destroy)"]],group:"Run & Execute",loader:()=>import("./handler77.js"),name:"run",options:c3}),d3={focus:{description:"Project name(s) to focus on — comma-separated for multiple",type:String},format:{defaultValue:"json",description:"Output format: json (default) or xml",type:String},"include-dev":{defaultValue:!1,description:"Include devDependencies (default: production only)",type:Boolean},output:{description:"Output path (use '-' for stdout; default: sbom.cdx.json)",type:String}},u3=R({description:"Generate a CycloneDX 1.7 Software Bill of Materials for the workspace",examples:[["vis sbom","Write the full-workspace SBOM to sbom.cdx.json"],["vis sbom --focus=my-app","Scope the SBOM to my-app's transitive closure"],["vis sbom --focus=my-app,other","Focus multiple projects"],["vis sbom --format=xml --output=sbom.cdx.xml","Emit XML instead of JSON"],["vis sbom --include-dev","Include devDependencies (default: production only)"],["vis sbom --output=-","Write to stdout"]],group:"Security & Health",loader:()=>import("./handler20.js"),name:"sbom",options:d3}),p3={affected:{defaultValue:!1,description:"Scan only projects affected by the current branch",type:Boolean},baseline:{description:"Path to a baseline JSON of previously-triaged findings",type:String},concurrency:{description:"Rayon worker threads (0 / omit = auto)",type:Number},config:{description:"Path to a JSON config (gitleaks-compatible shape). Defaults to the bundled ruleset.",type:String},"dry-run":{defaultValue:!1,description:"With --init, preview the baseline without writing files",type:Boolean},"enable-rule":{description:"Enable an opt-in rule or tag without restricting output — additive (e.g. tag:preset:weak-passwords, tag:preset:password-manager). Repeatable.",multiple:!0,type:String},exclude:{description:"Gitignore-syntax pattern to exclude from the walk (repeatable)",multiple:!0,type:String},"exclude-from":{description:"Path to a gitignore-shaped file the walker should honor (repeatable)",multiple:!0,type:String},"exclude-rule":{description:"Rule id or tag:<name> selector — drop matching findings. Repeatable.",multiple:!0,type:String},format:{defaultValue:"text",description:"Output format: text (default), json, sarif",type:String},history:{defaultValue:!1,description:"Scan the entire git history (every added/modified blob across commits) instead of the working tree. Surfaces secrets that were committed and later removed. Cannot be combined with --staged/--since/--affected.",type:Boolean},"history-range":{description:"With --history, limit the walk to a rev-list range (e.g. main..HEAD, HEAD~50..HEAD, or a single ref). Defaults to all reachable history of HEAD.",type:String},"include-hidden":{defaultValue:!1,description:"Scan dotfiles",type:Boolean},"include-rule":{description:"Rule id or tag:<name> selector — whitelist, only matching findings are emitted. Implies enablement. Repeatable.",multiple:!0,type:String},init:{defaultValue:!1,description:"Scaffold a baseline from current findings",type:Boolean},"list-rules":{defaultValue:!1,description:"Print all bundled detection rules and exit",type:Boolean},"list-validators":{defaultValue:!1,description:"Print non-HTTP validator types referenced by the current ruleset, with install hints for their optional peer dependencies.",type:Boolean},"max-commits":{description:"With --history, cap the number of commits walked (most-recent first)",type:Number},"max-size":{description:"Skip files larger than this (bytes). Default: 10 MiB",type:Number},"min-confidence":{description:"Drop rules below this author-declared confidence: low (default), medium, high. Rules without a declared confidence (every gitleaks rule) are treated as low, so --min-confidence medium or higher drops them along with explicit low-confidence rules.",type:String},"no-extend-bundled":{defaultValue:!1,description:"With --config, do not merge on top of the bundled ruleset — replace it.",type:Boolean},"no-gitignore":{defaultValue:!1,description:"Do not respect .gitignore",type:Boolean},"only-verified":{defaultValue:!1,description:"With --validate, drop every finding whose validation is not 'verified'. Useful for CI gating.",type:Boolean},quiet:{defaultValue:!1,description:"Suppress all progress output (only emit findings)",type:Boolean},redact:{defaultValue:!1,description:"Mask secret values in output",type:Boolean},"replace-baseline":{defaultValue:!1,description:"With --update-baseline, replace rather than merge",type:Boolean},since:{description:"Scan only files changed since <ref> (e.g. main, origin/HEAD)",type:String},staged:{defaultValue:!1,description:"Scan only files staged for commit",type:Boolean},"update-baseline":{defaultValue:!1,description:"Merge current findings into the baseline and exit 0",type:Boolean},validate:{defaultValue:!1,description:"Live-verify each finding against its provider (one HTTP call per finding, max 8 concurrent). Only supports Kingfisher-style HTTP validators with StatusMatch / WordMatch response matchers; other types (gRPC, multi-step, checksum) mark the finding as validation=skipped. WARNING: sends candidate secrets to the provider — some providers alert their security team on failed auth attempts.",type:Boolean},verbose:{defaultValue:!1,description:"Print diagnostic info (skipped rules, etc.)",type:Boolean}},f3=R({argument:{description:"One or more paths to scan (defaults to workspace root)",name:"paths",type:String},description:"Scan a repository for hardcoded secrets and credentials",examples:[["vis secrets","Scan the workspace with grouped, colourised output"],["vis secrets --staged","Scan only files staged for the current commit (pre-commit hooks)"],["vis secrets --since main","Scan only files changed since the `main` branch"],["vis secrets --affected","Scan only projects affected by the current branch"],["vis secrets --history","Scan the full git history for secrets that were committed then removed"],["vis secrets --history --history-range main..HEAD","Scan only commits on the current branch since main"],["vis secrets --history --max-commits 100 --redact","Scan the last 100 commits, masking any secret values"],["vis secrets --init","Write an initial baseline from current findings"],["vis secrets --list-rules","Print all bundled detection rules"],["vis secrets --list-validators","Print non-HTTP validator types in the ruleset + install hints for each"],["vis secrets --exclude-rule generic-api-key --exclude-rule aws-access-token","Drop noisy rules"],["vis secrets --include-rule stripe-access-token","Check a single rule"],["vis secrets --enable-rule tag:preset:weak-passwords","Enable an opt-in rule group additively (defaults still fire)"],["vis secrets --include-rule tag:preset:password-manager","Restrict output to one opt-in group only"],["vis secrets --min-confidence high","Drop rules without a high confidence label (CI-friendly precision filter)"],["vis secrets --validate --only-verified","Live-verify each finding against its provider (one HTTP call per finding)"],["vis secrets --exclude 'dist/**' --exclude-from .secretsignore","Extra gitignore-syntax exclusions for the walker"],["vis secrets --config ./leaks.json --no-extend-bundled","Use only the supplied config, skip the bundled ruleset"],["vis secrets --concurrency 4","Cap the rayon thread pool (0 / omit = auto)"],["vis secrets --baseline .secrets-baseline.json","Suppress known findings; print diff vs. baseline"],["vis secrets --update-baseline","Merge current findings into the baseline (use --replace-baseline to overwrite)"],["vis secrets --format sarif > report.sarif","SARIF output for GitHub code-scanning"]],group:"Security",loader:()=>import("./handler78.js"),name:"secrets",options:p3}),h3={json:{defaultValue:!1,description:"Emit the report as JSON instead of human-readable text",type:Boolean}},g3=R({commandPath:["security"],description:"List build-script status — allowed, unapproved, and stale allowlist entries",examples:[["vis security list","Show the full build-script triage report"],["vis security list --json","Emit the report as JSON for tooling"]],group:"Security & Health",loader:()=>import("./list.js"),name:"list",options:h3}),m3={"skip-allow-builds":{defaultValue:!1,description:"Skip syncing allowBuilds (trustedDependencies, onlyBuiltDependencies)",type:Boolean},"skip-min-release-age":{defaultValue:!1,description:"Skip syncing minimumReleaseAge and its excludes",type:Boolean}},y3=R({commandPath:["security"],description:"Push vis.config security settings to the package manager's native config",examples:[["vis security sync","Sync allowBuilds + minimumReleaseAge to the PM-native config files"],["vis security sync --skip-allow-builds","Sync only the minimumReleaseAge knobs"],["vis security sync --skip-min-release-age","Sync only allowBuilds (trustedDependencies / onlyBuiltDependencies)"]],group:"Security & Health",loader:()=>import("./sync2.js"),name:"sync",options:m3}),v3={"root-only":{defaultValue:!1,description:"Skip dependency scripts and only run the workspace root's prepublish + prepare hooks",type:Boolean},"with-root":{defaultValue:!1,description:"Also run the workspace root's prepublish + prepare hooks after dependencies",type:Boolean}},b3=R({commandPath:["security"],description:"Run lifecycle scripts for packages in security.policies.installScripts.allow (LavaMoat 'run' parity)",examples:[["vis security run","Run preinstall/install/postinstall for every approved package"],["vis security run --with-root","Also run the workspace root's prepublish + prepare hooks"],["vis security run --root-only","Run only the workspace root's prepublish + prepare hooks"]],group:"Security & Health",loader:()=>import("./run.js"),name:"run",options:v3}),w3={remove:{defaultValue:!1,description:"Remove @lavamoat/preinstall-always-fail from package.json",type:Boolean},status:{defaultValue:!1,description:"Report whether @lavamoat/preinstall-always-fail is installed",type:Boolean}},k3=R({commandPath:["security"],description:"Install @lavamoat/preinstall-always-fail as a devDep so a missing ignore-scripts setting fails loudly",examples:[["vis security tripwire","Install the tripwire devDependency"],["vis security tripwire --status","Report whether the tripwire is installed"],["vis security tripwire --remove","Remove the tripwire from package.json"]],group:"Security & Health",loader:()=>import("./tripwire.js"),name:"tripwire",options:w3}),S3={clear:{defaultValue:!1,description:"Only clear the cache, do not refetch",type:Boolean},json:{defaultValue:!1,description:"Emit the result as JSON instead of human-readable text",type:Boolean}},x3=R({commandPath:["security"],description:"Force-refresh the cached npm signing keys used by the signatures marshall",examples:[["vis security keys-refresh","Drop the disk cache and fetch a fresh key set from registry.npmjs.org"],["vis security keys-refresh --clear","Only drop the cache, do not refetch"],["vis security keys-refresh --json","Emit the refresh result as JSON for tooling"]],group:"Security & Health",loader:()=>import("./keys-refresh.js"),name:"keys-refresh",options:S3}),$3={json:{defaultValue:!1,description:"Emit the result as JSON instead of human-readable text",type:Boolean},offline:{defaultValue:!1,description:"Skip network-bound policies (firstSeen, publisherChange)",type:Boolean}},E3=R({commandPath:["security"],description:"Verify the entire lockfile closure against supply-chain policies (firstSeen, publisherChange, blockExoticSubdeps)",examples:[["vis security verify-lockfile","Re-validate every locked entry; exit non-zero on a policy violation"],["vis security verify-lockfile --offline","Verify without network (skips firstSeen / publisherChange)"],["vis security verify-lockfile --json","Emit the verification result as JSON for CI"]],group:"Security & Health",loader:()=>import("./verify-lockfile.js"),name:"verify-lockfile",options:$3}),C3=[g3,y3,b3,k3,x3,E3],ki={description:"Target id, e.g. @my/api:db",name:"targetId",type:String},R3={description:"Output format: table or json (default: table)",name:"format",type:String},O3={"no-readiness":{defaultValue:!1,description:"Skip the readiness probe",type:Boolean},timeout:{description:"Readiness probe timeout in milliseconds",type:Number}},j3=R({argument:ki,commandPath:["service"],description:"Start a service target detached so it survives across `vis run` invocations",examples:[["vis service start @my/api:db","Boot the db target as a long-lived service"],["vis service start @my/api:db --timeout=60000","Override readiness timeout"],["vis service start @my/api:db --no-readiness","Skip the readiness probe"]],group:"Workspace",loader:G(()=>import("./handler21.js"),"serviceStartExecute"),name:"start",options:O3}),T3={all:{defaultValue:!1,description:"Stop every service registered for this workspace",type:Boolean},"grace-ms":{description:"Override the SIGTERM→SIGKILL grace period in milliseconds",type:Number}},I3=R({argument:{description:"Target id to stop, or omit when using --all",name:"targetId",required:!1,type:String},commandPath:["service"],description:"Stop a running service",examples:[["vis service stop @my/api:db","Stop the db service"],["vis service stop --all","Stop every running service in this workspace"]],group:"Workspace",loader:G(()=>import("./handler21.js"),"serviceStopExecute"),name:"stop",options:T3}),A3={commandPath:["service"],description:"List services registered for this workspace",examples:[["vis service list","Print running services"],["vis service list --format=json","Machine-readable list"]],group:"Workspace",loader:G(()=>import("./handler21.js"),"serviceListExecute"),name:"list",options:[R3]},P3={timeout:{description:"Probe timeout in milliseconds",type:Number}},B3=R({argument:ki,commandPath:["service"],description:"Re-run the readiness probe and report a service's health",examples:[["vis service status @my/api:db","Check whether the db service is reachable"]],group:"Workspace",loader:G(()=>import("./handler21.js"),"serviceStatusExecute"),name:"status",options:P3}),N3={"grace-ms":{description:"Override the SIGTERM→SIGKILL grace period in milliseconds",type:Number},"no-readiness":{defaultValue:!1,description:"Skip the readiness probe after restart",type:Boolean},timeout:{description:"Readiness probe timeout in milliseconds",type:Number}},D3=R({argument:ki,commandPath:["service"],description:"Stop and re-start a running service",examples:[["vis service restart @my/api:db","Recycle the db service"],["vis service restart @my/api:db --no-readiness","Recycle and skip the readiness probe"]],group:"Workspace",loader:G(()=>import("./handler21.js"),"serviceRestartExecute"),name:"restart",options:N3}),L3={follow:{alias:"f",defaultValue:!1,description:"Follow the log file (like `tail -f`)",type:Boolean}},M3=R({argument:ki,commandPath:["service"],description:"Print or tail a service's captured stdout/stderr",examples:[["vis service logs @my/api:db","Print the captured log"],["vis service logs @my/api:db -f","Tail the log (Ctrl-C to exit)"]],group:"Workspace",loader:G(()=>import("./handler21.js"),"serviceLogsExecute"),name:"logs",options:L3}),_3=[j3,I3,A3,B3,D3,M3],F3={commandPath:["shim"],description:"Install project-local PM shims (.vis/shims) that enforce the project's package manager",examples:[["vis shim install","Write npm/pnpm/yarn/… wrapper scripts in .vis/shims"]],group:"Runtime",loader:()=>import("./handler22.js").then(e=>({default:e.shimInstallExecute})),name:"install"},V3={commandPath:["shim"],description:"Remove the project-local PM shim dir (.vis/shims)",examples:[["vis shim uninstall","Delete .vis/shims"]],group:"Runtime",loader:()=>import("./handler22.js").then(e=>({default:e.shimUninstallExecute})),name:"uninstall"},W3={commandPath:["shim"],description:"Report whether the PM shims are installed and active on PATH",examples:[["vis shim status","Show shim install + PATH state"]],group:"Runtime",loader:()=>import("./handler22.js").then(e=>({default:e.shimStatusExecute})),name:"status"},H3=[F3,V3,W3],U3={check:{alias:"c",defaultValue:!1,description:"Check if package.json files are sorted without writing (exits 1 if unsorted)",type:Boolean},ignore:{description:"Glob pattern of files to skip (basename match, or path-relative when the pattern contains `/`). Repeatable.",multiple:!0,type:String},indent:{description:"Indent override: a number of spaces, the literal `tab`, or a literal whitespace string. When unset, the original file's indent is preserved.",type:String},"line-ending":{defaultValue:"auto",description:"Line ending to write: auto (per-file detection, default), lf, or crlf.",type:String},"no-editorconfig":{description:"Disable .editorconfig discovery for indent / line-ending defaults (default: enabled).",type:Boolean},"no-final-newline":{defaultValue:!1,description:"Do not append a trailing newline to the output (default: append one).",type:Boolean},"no-format-bugs":{description:"Disable collapsing `bugs: { url }` to the bare string form (default: enabled).",type:Boolean},"no-format-repository":{description:"Disable collapsing `repository: { type, url }` to the GitHub `owner/repo` shorthand (default: enabled).",type:Boolean},"no-sort-exports":{description:"Disable canonical sorting of `exports` condition keys (default: enabled).",type:Boolean},"sort-order":{description:"Comma-separated list of top-level keys to place first, before the default field order. Repeatable.",multiple:!0,type:String},"sort-scripts":{defaultValue:!1,description:"Also sort the scripts field alphabetically",type:Boolean},unsorted:{description:"Comma-separated list of top-level sections whose key order should be preserved (e.g. dependencies,devDependencies). Repeatable.",multiple:!0,type:String}},G3=R({description:"Sort package.json files across the workspace using the sort-package-json Rust crate",examples:[["vis sort-package-json","Sort all package.json files in the workspace"],["vis sort-package-json --check","Check if files are already sorted (exit 1 if not)"],["vis sort-package-json --sort-scripts","Also sort the scripts field alphabetically"],["vis sort-package-json --indent 4","Force 4-space indentation (overrides per-file detection)"],["vis sort-package-json --indent tab","Force tab indentation"],["vis sort-package-json --ignore '**/fixtures/**'","Skip files matching one or more glob patterns"],["vis sort-package-json --sort-order name,version,license","Pin a custom prefix order before the default field order"],["vis sort-package-json --unsorted dependencies,devDependencies","Preserve original key order for the listed top-level sections"],["vis sort-package-json --no-final-newline","Do not append a trailing newline"],["vis sort-package-json --line-ending crlf","Force CRLF line endings (default: auto-detect per file)"]],group:"Workspace",loader:()=>import("./handler64.js"),name:"sort-package-json",options:U3}),z3={annotate:{defaultValue:!1,description:"Prefix the rewritten commit messages with the package name",type:Boolean},branch:{alias:"b",description:'Default branch name in the new repo (default: vis.config defaultBase or "main")',type:String},"dry-run":{defaultValue:!1,description:"Print the git plan instead of executing it",type:Boolean},force:{defaultValue:!1,description:"Use a non-empty --output directory anyway",type:Boolean},output:{alias:"o",description:"Destination directory for the new repo (required unless --dry-run)",type:String},push:{defaultValue:!1,description:"Push the new repo to origin (requires --remote)",type:Boolean},remote:{description:"Git remote URL to set as origin on the new repo",type:String},remove:{defaultValue:!1,description:"Delete the package from the monorepo after extracting and commit the removal",type:Boolean}},J3=R({argument:{description:"Project name or workspace-relative path of the package to extract",name:"package",type:String},description:"Extract a package into a standalone git repo, preserving its history",examples:[["vis split @scope/pkg --output ../pkg-repo","Extract a package into a new repo at ../pkg-repo"],["vis split packages/tooling/foo -o ../foo --remote git@github.com:me/foo.git --push","Extract, set origin, and push"],["vis split @scope/pkg -o ../pkg --remove","Extract, then delete the package from the monorepo (committed)"],["vis split @scope/pkg --dry-run","Print the git plan without making changes"]],group:"Workspace",loader:()=>import("./handler23.js"),name:"split",options:z3}),q3={"allow-empty":{defaultValue:!1,description:"Allow empty commits when tasks revert all staged changes",type:Boolean},"auto-stage":{defaultValue:!1,description:"Automatically stage new files that tasks create during the run",type:Boolean},concurrent:{description:"Number of concurrent tasks or false for serial",type:String},"continue-on-error":{defaultValue:!1,description:"Run all tasks to completion even if one fails",type:Boolean},cwd:{description:"Working directory to run all tasks in",type:String},debug:{defaultValue:!1,description:"Enable debug output",type:Boolean},diff:{description:"Override the default --staged flag of git diff",type:String},"diff-filter":{description:"Override the default diff-filter",type:String},"fail-on-changes":{defaultValue:!1,description:"Fail with exit code 1 when tasks modify tracked files",type:Boolean},"force-kill":{defaultValue:!1,description:"Kill in-flight tasks with SIGKILL on fast-fail instead of the default SIGTERM",type:Boolean},"hide-partially-staged":{defaultValue:!1,description:"Hide unstaged changes from partially staged files",type:Boolean},"hide-unstaged":{defaultValue:!1,description:"Hide all unstaged changes before running tasks",type:Boolean},quiet:{defaultValue:!1,description:"Suppress console output",type:Boolean},relative:{defaultValue:!1,description:"Pass filepaths relative to cwd to tasks",type:Boolean},revert:{defaultValue:!1,description:"Revert to original state in case of errors",type:Boolean},...fe({defaultValue:!0,description:"Enable backup stash",name:"stash",type:Boolean}),verbose:{defaultValue:!1,description:"Show task output even when tasks succeed",type:Boolean}},K3=R({description:"Run linters on staged files using config from vis.config.ts",examples:[["vis staged","Run staged linters"],["vis staged --verbose","Run with verbose output"],["vis staged --no-stash","Run without backup stash"],["vis staged --diff HEAD~1","Run against a specific diff"]],group:"Run & Execute",loader:()=>import("./handler75.js"),name:"staged",options:q3}),Y3={json:{defaultValue:!1,description:"Emit JSON output",type:Boolean}},X3=R({description:"Show a workspace health dashboard at a glance",examples:[["vis status","Full status overview"],["vis status --json","Machine-readable output"]],group:"Workspace",loader:()=>import("./handler24.js"),name:"status",options:Y3}),Z3={check:{defaultValue:!1,description:"Verify state without writing (exit non-zero if drift is found)",type:Boolean},fields:{description:"Comma-separated list of fields to mirror from root → workspace packages (package-json-fields kind only). Repeatable.",multiple:!0,type:String},format:{defaultValue:"human",description:"Output format for package-json-fields: human | json",type:String},from:{description:"Input sources for codeowners. Comma-separated or repeated. Values: project-json | nested-codeowners | package-json-maintainers. Defaults to project-json.",multiple:!0,type:String},"ignore-package-name":{description:"Glob pattern of package names to skip (package-json-fields kind only). Repeatable.",multiple:!0,type:String},"nested-includes":{description:"Glob (repeatable) used to discover nested CODEOWNERS files. Defaults to `**/CODEOWNERS`.",multiple:!0,type:String},out:{description:"Output path for the generated file (default: <workspace>/CODEOWNERS) — codeowners kind only",type:String},"preserve-block":{defaultValue:!1,description:"Splice the generated block between markers in the existing file instead of overwriting it. Codeowners kind only.",type:Boolean},quiet:{defaultValue:!1,description:"Suppress per-package log lines; print only the summary (package-json-fields kind only)",type:Boolean},"regeneration-command":{description:"Header instruction shown to reviewers (replaces the default 'update project.json' note). Codeowners kind only.",type:String},"write-guard":{defaultValue:!1,description:"Also emit a .github/workflows/write-guard.yml scoped to projects with `restricted: true` in project.json. Codeowners kind only.",type:Boolean}},Q3=R({argument:{description:"What to sync: codeowners | package-json-fields",name:"kind",type:String},description:"Synchronise derived workspace artefacts (codeowners, package.json fields, tsconfig refs, …)",examples:[["vis sync codeowners","Generate CODEOWNERS at the repository root"],["vis sync codeowners --out=.github/CODEOWNERS","Write to .github/CODEOWNERS instead"],["vis sync codeowners --check","Fail if the existing file is stale"],["vis sync codeowners --from=project-json,nested-codeowners","Also aggregate nested CODEOWNERS files in the tree"],["vis sync codeowners --regeneration-command='pnpm codeowners'","Set a custom header instruction"],["vis sync codeowners --preserve-block","Splice the generated block between markers in an existing CODEOWNERS"],["vis sync codeowners --write-guard","Also emit GitHub + GitLab Write Guard CI for restricted projects"],["vis sync package-json-fields","Mirror license/author/repository/bugs/homepage/engines from root to every workspace package"],["vis sync package-json-fields --check","Fail if any workspace package.json is out of sync"],["vis sync package-json-fields --fields license,engines","Override the default field list for this run"]],group:"Workspace",loader:()=>import("./handler62.js"),name:"sync",options:Z3}),eO={argument:{description:"Task ID to explain (e.g. @my/app:build)",name:"taskId",type:String},description:"Explain why a task is included in the graph by walking its dependency chain to a root",examples:[["vis task-why @myorg/app:build","Show what pulls build in"],["vis task-why lib-a:test","Check the test task's triggers"]],group:"Workspace",loader:()=>import("./handler25.js"),name:"task-why"},hs="Workspace",tO={"exit-code":{defaultValue:!1,description:"Exit 1 if any tool mismatches",type:Boolean},json:{defaultValue:!1,description:"Emit JSON",type:Boolean}},nO=R({commandPath:["toolchain"],description:"Show every detected manager + expected vs actual tool versions",examples:[["vis toolchain status","Show every detected manager + expected vs actual tool versions"],["vis toolchain status --json","Emit the status as JSON"],["vis toolchain status --exit-code","Exit 1 if any tool mismatches (for CI)"]],group:hs,loader:G(()=>import("./handler26.js"),"statusExecute"),name:"status",options:tO}),sO={commandPath:["toolchain"],description:"Print the primary manager's name (for scripts)",examples:[["vis toolchain detect","Print the primary manager's name"]],group:hs,loader:G(()=>import("./handler26.js"),"detectExecute"),name:"detect"},iO={"dry-run":{defaultValue:!1,description:"Print the command that would run, but don't execute",type:Boolean}},rO=R({commandPath:["toolchain"],description:"Install pinned versions — per-tool delegation to the right manager",examples:[["vis toolchain install","Install pinned versions"],["vis toolchain install --dry-run","Print the commands that would run, but don't execute"]],group:hs,loader:G(()=>import("./handler26.js"),"installExecute"),name:"install",options:iO}),oO={"dry-run":{defaultValue:!1,description:"Print the command that would run, but don't execute",type:Boolean},...fe({defaultValue:!0,description:"Also mirror the version into engines.<tool> when that field already exists. --no-engines to skip.",name:"engines",type:Boolean})},aO=R({argument:{description:"Tool and version to pin, e.g. node@22.13.0 or pnpm@10.32.1",name:"spec",type:String},commandPath:["toolchain"],description:"Pin a version via the best manager for that tool",examples:[["vis toolchain use node@22.13.0","Pin node 22.13.0 via the best runtime manager"],["vis toolchain use pnpm@10.32.1","Update the packageManager field; pnpm self-activates"],["vis toolchain use node@22.13.0 --dry-run","Print the command without running it"]],group:hs,loader:G(()=>import("./handler26.js"),"useExecute"),name:"use",options:oO}),cO={argument:{description:"Tool to resolve, e.g. node",name:"tool",type:String},commandPath:["toolchain"],description:"Print the resolved binary path a manager would launch for a tool",examples:[["vis toolchain which node","Resolve the node binary the manager would launch"]],group:hs,loader:G(()=>import("./handler26.js"),"whichExecute"),name:"which"},lO=[nO,sO,rO,aO,cO],dO={recursive:{alias:"r",defaultValue:!1,description:"Unlink in all workspace packages",type:Boolean}},uO=R({argument:{description:"Packages to unlink (omit for current package)",name:"packages",type:String},description:"Unlink a previously linked package",examples:[["vis unlink","Unlink current package"],["vis unlink react","Unlink specific package"],["vis unlink -r","Unlink in all workspace packages"]],group:"Dependencies",loader:()=>import("./handler27.js"),name:"unlink",options:dO}),pO={"actions-token":{description:"GitHub token for actions resolution (overrides GITHUB_TOKEN / GH_TOKEN env)",type:String},ai:{defaultValue:!1,description:"Run AI analysis on outdated packages before updating (catalog mode)",type:Boolean},"ai-type":{description:"AI analysis type: impact, security, compatibility, or recommend (default: impact)",type:String},changelog:{defaultValue:!1,description:"Show changelog URLs for updated packages",type:Boolean},dev:{alias:"D",conflicts:"prod",description:"Update only devDependencies",type:Boolean},"dry-run":{alias:"d",defaultValue:!1,description:"Preview changes without applying",type:Boolean},exclude:{description:"Glob pattern to exclude packages (repeatable, catalog mode)",lazyMultiple:!0,type:String},filter:{description:"Filter packages in monorepo (pm-wrapper mode; catalog mode uses --include/--exclude)",type:String},format:{description:"Output format: table, json, or minimal (default: table)",type:String},"gitlab-token":{description:"GitLab token for include-ref resolution (overrides GITLAB_TOKEN / CI_JOB_TOKEN env)",type:String},global:{alias:"g",defaultValue:!1,description:"Update global packages",type:Boolean},"ignore-release-age":{defaultValue:!1,description:"Ignore the minimumReleaseAge gate and select the truly latest version even if freshly published. The selected packages are added to the package manager's native age-gate exclude list (pnpm minimumReleaseAgeExclude, bun minimumReleaseAgeExcludes, yarn npmPreapprovedPackages) so the follow-up install isn't blocked; npm has no per-package exclude. Combine with --latest to also cross the semver range.",type:Boolean},include:{description:"Glob pattern to include packages (repeatable, catalog mode)",lazyMultiple:!0,type:String},"include-branches":{defaultValue:!1,description:"Include branch references (e.g. actions/checkout@main) when scanning workflows",type:Boolean},"include-internal":{defaultValue:!1,description:"Also check workspace-owned package names against the registry (catalog mode)",type:Boolean},"include-locked":{alias:"l",defaultValue:!1,description:"Include packages with pinned/exact versions (no ^ or ~ prefix; catalog mode)",type:Boolean},...fe({description:"Run install after catalog update, --no-install to skip (default: true)",name:"install",type:Boolean}),interactive:{alias:"i",defaultValue:!1,description:"Interactive mode",type:Boolean},latest:{alias:"L",conflicts:"target",description:"Update to latest version (ignore semver range; equivalent to --target latest)",type:Boolean},"max-concurrent-requests":{description:"Cap concurrent registry requests during outdated checks (default: 8)",type:Number},"no-actions":{defaultValue:!1,description:"Skip the GitHub Actions ecosystem scan (workflows + composite action.yml files)",type:Boolean},"no-catalog":{defaultValue:!1,description:"Skip catalog mode, use package manager directly",type:Boolean},"no-docker":{defaultValue:!1,description:"Skip the Docker ecosystem scan (Dockerfile + docker-compose images)",type:Boolean},"no-gitlab":{defaultValue:!1,description:"Skip the GitLab CI ecosystem scan (.gitlab-ci.yml + .gitlab/ci/**)",type:Boolean},"no-marshall-check":{defaultValue:!1,description:"Skip the offline marshall pipeline (author, provenance, metadata, downloads, expired-domains, new-bin, signatures, archived-repo) when explicit package arguments are supplied",type:Boolean},"no-optional":{defaultValue:!1,description:"Don't update optionalDependencies",type:Boolean},"no-save":{defaultValue:!1,description:"Update lockfile only",type:Boolean},"no-typosquat-check":{defaultValue:!1,description:"Skip typosquat name check for package arguments",type:Boolean},peer:{defaultValue:!1,description:"Include peerDependencies in update checks",type:Boolean},prerelease:{defaultValue:!1,description:"Include prerelease versions (catalog mode)",type:Boolean},prod:{alias:"P",conflicts:"dev",description:"Update only dependencies",type:Boolean},recursive:{alias:"r",defaultValue:!1,description:"Update recursively in all workspace packages",type:Boolean},"release-channel":{description:"Release channel filter: stable (default), same (match current's prerelease channel), or any",type:String},rollback:{defaultValue:!1,description:"Restore catalog file from the last backup",type:Boolean},...fe({description:"Check for known security vulnerabilities via OSV.dev (default: true; --no-security to skip)",name:"security",type:Boolean}),style:{description:"Reference style for GitHub Actions updates: sha (default, pin to commit SHA + version comment) or preserve",type:String},target:{alias:"t",conflicts:"latest",description:"Update target: latest, minor, or patch (default: latest, catalog mode)",type:String},"workspace-root":{alias:"w",defaultValue:!1,description:"Include workspace root",type:Boolean},yes:{alias:"y",defaultValue:!1,description:"Skip the confirmation prompt for blanket --latest updates. Required in non-TTY contexts (CI) when running `vis update --latest` without explicit package arguments.",type:Boolean}},fO=R({alias:"up",argument:{description:"Packages to update (updates all if omitted)",name:"packages",type:String},description:"Update packages to their latest versions",examples:[["vis update react","Update react within semver range"],["vis up react -L","Update react to latest"],["vis update -i","Interactive mode"],["vis update --filter app","Update in specific workspace"],["vis update -r","Update in all workspaces"],["vis update --target minor","Only apply minor/patch updates (catalog mode)"],["vis update --dry-run","Preview changes without applying"],["vis update --exclude '@types/*'","Exclude packages by pattern"],["vis update --changelog","Show changelog links after updating"],["vis update --rollback","Restore catalog from last backup"],["vis update --ai","Run AI analysis before applying updates"]],group:"Dependencies",loader:()=>import("./handler74.js"),name:"update",options:pO}),hO={check:{defaultValue:!1,description:"Check for updates without installing",type:Boolean},force:{defaultValue:!1,description:"Reinstall even if already current",type:Boolean},silent:{defaultValue:!1,description:"Suppress output (CI mode)",type:Boolean}},gO=R({argument:{description:"Target version (defaults to latest)",name:"version",type:String},description:"Update vis itself to the latest version",examples:[["vis self-update","Update to latest"],["vis self-update 2.0.0","Install specific version"],["vis self-update --check","Check for updates without installing"]],group:"System",loader:()=>import("./handler28.js"),name:"self-update",options:hO}),mO={depth:{description:"Limit dependency tree depth",type:Number},dev:{alias:"D",conflicts:"prod",description:"Filter to dev dependencies (pnpm)",type:Boolean},filter:{alias:"F",description:"Filter by workspace package name",multiple:!0,type:String},global:{alias:"g",defaultValue:!1,description:"Check globally installed packages (pnpm)",type:Boolean},json:{defaultValue:!1,description:"Output as JSON",type:Boolean},long:{defaultValue:!1,description:"Show extended information (pnpm)",type:Boolean},"no-optional":{defaultValue:!1,description:"Exclude optional dependencies (pnpm)",type:Boolean},parseable:{defaultValue:!1,description:"Machine-readable output (pnpm)",type:Boolean},prod:{alias:"P",conflicts:"dev",description:"Filter to production dependencies (pnpm)",type:Boolean},recursive:{alias:"r",defaultValue:!1,description:"Check across all workspaces",type:Boolean}},yO=R({alias:"explain",argument:{description:"Package(s) to explain",name:"packages",type:String},description:"Show why a package is installed (dependency chain)",examples:[["vis why react","Show why react is installed"],["vis why react --json","Output as JSON"],["vis why react -r","Check across all workspaces"],["vis explain react","Alias matching npm's command"]],group:"Dependencies",loader:()=>import("./handler29.js"),name:"why",options:mO}),vO={},bO=R({argument:{description:"File to run, with any args to forward to it",name:"file",type:String},description:"Run a TypeScript/JavaScript file directly under the selected runtime (node | bun)",examples:[["vis x script.ts","Run a TypeScript file (full TS surface: enums, decorators)"],["vis x --runtime bun server.ts","Run under Bun"],["vis x build.ts foo bar","Forward positional args to the file"],["vis x task.ts -- --watch","Forward flags after -- to the file"]],group:"Run & Execute",loader:()=>import("./handler30.js"),name:"x",options:vO}),wO=e=>{e.addCommand(l3),e.addCommand(s$),e.addCommand(r8),e.addCommand(px),e.addCommand(Sx),e.addCommand(eO),e.addCommand(a3),e.addCommand(g8),e.addCommand(fO),e.addCommand(t$),e.addCommand(FC),e.addCommand(Dx),e.addCommand(G3),e.addCommand(K3),e.addCommand(X3),e.addCommand(DC),e.addCommand(Q3),e.addCommand(A8),e.addCommand(lx),e.addCommand(dx),e.addCommand(T8),e.addCommand(t8),e.addCommand(R8),e.addCommand(hx),e.addCommand(r3),e.addCommand(MC),e.addCommand(yO),e.addCommand(k8),e.addCommand(O8),e.addCommand(uO),e.addCommand(Cf),e.addCommand(Rh),e.addCommand(bO),e.addCommand(pR),e.addCommand(x8),e.addCommand(a$),e.addCommand(l$),e.addCommand(s8),e.addCommand(WC),e.addCommand(gO),e.addCommand(y8),e.addCommand(J3),e.addCommand(b8),e.addCommand(Mx),e.addCommand(Hx),e.addCommand(E8),e.addCommand(QC),e.addCommand(uR),e.addCommand(u3),e.addCommand(f3);for(const t of f8)e.addCommand(t);for(const t of lR)e.addCommand(t);for(const t of Qx)e.addCommand(t);for(const t of wx)e.addCommand(t);for(const t of ap)e.addCommand(t);for(const t of _3)e.addCommand(t);for(const t of C3)e.addCommand(t);for(const t of Vx)e.addCommand(t);for(const t of XC)e.addCommand(t);for(const t of lO)e.addCommand(t);for(const t of H3)e.addCommand(t);e.addCommand(r$);for(const t of s3)e.addCommand(t)},kO=e=>{for(let t=0;t<e.length;t+=1){const n=e[t];if(n==="--ca-cert"){const s=e[t+1];return s===void 0||s.startsWith("-")?void 0:Fs(s)}if(n.startsWith("--ca-cert=")){const s=n.slice(10);return s===""?void 0:Fs(s)}}},SO=()=>process.platform==="win32"?!!process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color":process.env.TERM!=="linux",An=SO(),xO={arrow:An?"→":"->",dash:An?"—":"-",failure:An?"✗":"x",success:An?"✓":"v",warning:An?"⚠":"!"},Zr=m(mt(),"upgrade-check.json"),$O=1440*60*1e3,EO=1440*60*1e3,CO=500,RO=new Set(["--help","--version","-h","-V","help","implode","upgrade"]),OO=()=>{try{if($(Zr))return de(Zr)}catch{}},pf=e=>{try{gt(mt()),ye(Zr,JSON.stringify(e))}catch{}},jO=async e=>{try{const t=new AbortController,n=setTimeout(()=>{t.abort()},CO),s=await fetch(`https://registry.npmjs.org/${e}/latest`,{headers:{accept:"application/json"},signal:t.signal});return clearTimeout(n),s.ok?(await s.json()).version:void 0}catch{return}},ul=(e,t)=>{let n;try{n=ur.gt(t.latestVersion,e,{loose:!0})}catch{return}if(!n)return;const s=Date.now();s-t.lastNoticeAt<EO||(process.stderr.write(`
242
- ${sn("vis update available:")} ${Pn(e)} ${sn(xO.arrow)} ${lh(Le(t.latestVersion))}${sn(", run")} ${et("vis upgrade")}
243
- `),t.lastNoticeAt=s,pf(t))},TO=e=>{if(dt||process.env.VIS_CLI_TEST||process.env.VIS_NO_UPDATE_CHECK==="1"||!process.stderr.isTTY||RO.has(e))return!1;const t=new Set(process.argv.slice(2));return!(t.has("--silent")||t.has("-s")||t.has("--json"))},IO=(e,t)=>{if(!TO(t))return;const n=OO(),s=Date.now();if(n&&s-n.lastQueryAt<$O)return()=>{ul(e,n)};let i=n;return jO("@visulima/vis").then(r=>{r&&(i={lastNoticeAt:n?.lastNoticeAt??0,lastQueryAt:s,latestVersion:r},pf(i))}).catch(()=>{}),()=>{i&&ul(e,i)}},AO=async()=>{const e=kO(process.argv);e!==void 0&&!process.env.NODE_EXTRA_CA_CERTS&&(process.env.NODE_EXTRA_CA_CERTS=e);try{const i=Rl(process.cwd()).path;process.env.VIS_MONOREPO_ROOT=i;const r=de(m(i,"package.json"));r.name&&ah(r.name)}catch{}const t=IO(Vs(),process.argv[2]??""),n=Rf("vis",{packageName:"vis",packageVersion:Vs()}),s=process.argv.includes("--debug")||!!process.env.DEBUG;if(n.addPlugin(Of({concise:Tf,detailed:s,exitOnError:!1})),n.addGlobalOption({description:"Override workspace root directory",name:"cwd",type:String}),n.addGlobalOption({description:"Target JS runtime: node (default) or bun. Overrides VIS_RUNTIME and config; falls back to lockfile detection.",name:"runtime",type:String}),n.addGlobalOption({description:"Path to a vis config file (overrides discovery)",name:"config",type:String}),n.addGlobalOption({description:"Path to a CA bundle (PEM) to trust for HTTPS — for corporate proxies. Equivalent to NODE_EXTRA_CA_CERTS.",name:"ca-cert",type:String}),n.addPlugin(N0),n.addPlugin(ex),wO(n),n.addPlugin(rw(t)),Uh(process.argv.slice(2))){const{loadVisConfig:i}=await import("./CONFIG_FILES.js"),r=process.env.VIS_MONOREPO_ROOT||process.cwd();let o;try{o=await i(r)}catch{o=void 0}try{await B0({logger:{info:a=>{process.stdout.write(`${a}
242
+ </html>`;let St;const IC=()=>{for(const e of TC)try{if(Bt(e).isFile())return e}catch{}},AC=()=>{if(St!==void 0&&!process.env.VIS_DASHBOARD_NO_CACHE)return St;const e=IC();if(!e)return St=pl,St;try{const t=wl(e,"utf8");return St=t,t}catch{return St=pl,St}},BC=e=>{if(e.length===0)return;const t=[...e].sort((s,i)=>s-i),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]},PC=e=>{const t=new Map;for(const s of e)if(Array.isArray(s.tasks))for(const i of s.tasks){if(!i.taskId)continue;const r=t.get(i.taskId)??{durations:[],failures:0,hits:0,misses:0,project:i.target?.project??"",runs:0,target:i.target?.target??"",taskId:i.taskId};i.cacheStatus==="HIT"||i.cacheStatus==="REMOTE_HIT"?(r.runs+=1,r.hits+=1):i.cacheStatus==="MISS"&&(r.runs+=1,r.misses+=1,typeof i.duration=="number"&&i.duration>0&&r.durations.push(i.duration),i.exitCode!==void 0&&i.exitCode!==0&&(r.failures+=1)),t.set(i.taskId,r)}const n=new Map;for(const[s,i]of t){const r=i.durations.length===0?0:i.durations.reduce((o,a)=>o+a,0)/i.durations.length;n.set(s,{averageDurationMs:r,failures:i.failures,hitRate:i.runs===0?0:i.hits/i.runs,hits:i.hits,misses:i.misses,project:i.project,runs:i.runs,target:i.target,taskId:s,timeSavedMs:r*i.hits})}return n},NC=e=>{const t=e,n=[...t].sort((b,S)=>(b.startTime??"").localeCompare(S.startTime??""));let s=0,i=0,r=0,o=0,a=0,c=0;const l=[],d=[],u=[];for(const b of n){const S=b.stats??{};s+=S.total??0,i+=S.succeeded??0,r+=S.failed??0,o+=S.cached??0,a+=S.skipped??0,typeof b.duration=="number"&&b.duration>0&&(c+=b.duration,l.push(b.duration),b.startTime&&u.push({timestamp:b.startTime,value:b.duration})),(S.total??0)>0&&b.startTime&&d.push({timestamp:b.startTime,value:(S.cached??0)/(S.total??1)})}const f=[...PC(n).values()],h=f.filter(b=>b.averageDurationMs>0).sort((b,S)=>S.averageDurationMs-b.averageDurationMs).slice(0,10),g=f.filter(b=>b.runs>=2).sort((b,S)=>S.timeSavedMs-b.timeSavedMs||S.hitRate-b.hitRate).slice(0,10),y=f.filter(b=>b.runs>=3&&b.hits>0&&b.misses>0).sort((b,S)=>S.misses/S.runs-b.misses/b.runs).slice(0,10),x=f.reduce((b,S)=>b+S.timeSavedMs,0);return{averageRunDurationMs:l.length===0?null:l.reduce((b,S)=>b+S,0)/l.length,cacheHitRate:o+i+r===0?null:o/(o+i+r),durationOverTime:u,hitRateOverTime:d,medianRunDurationMs:BC(l)??null,mostCachedTasks:g,mostInvalidatedTasks:y,slowestTasks:h,totals:{cached:o,estimatedTimeSavedMs:x,failed:r,runs:t.length,skipped:a,succeeded:i,tasks:s,totalDurationMs:c}}},DC=(e,t)=>{if(e===void 0||e==="")return!1;let n=e;if(n.startsWith("[")){const s=n.indexOf("]");n=s===-1?n.slice(1):n.slice(1,s)}else if(!n.includes("::")){const s=n.indexOf(":");n=s===-1?n:n.slice(0,s)}return n=n.toLowerCase(),n==="localhost"||n===t.toLowerCase()?!0:Eh(n)!==0},fl=(e,t)=>{const n=t.replaceAll(/[^\w.\-:]/g,"");if(n.length===0||n!==t)return;const s=m(vt(e),`${n}.json`);if($(s))try{return de(s)}catch{return}const i=$l(e);if($(i))try{const r=de(i);return r.id===n?r:void 0}catch{return}},LC=async e=>{const t=new Set,n=vt(e);try{await $h(n,{recursive:!0})}catch{}let s,i;const r=a=>{i=a,s&&clearTimeout(s),s=setTimeout(()=>{if(s=void 0,!i)return;const c=i;i=void 0;for(const l of t)try{l(c)}catch{}},200)};let o;try{o=ch(n,(a,c)=>{if(!c||typeof c!="string"||!c.endsWith(".json"))return;const l=c.slice(0,-5);r({id:l,type:"run-changed"})})}catch{o=void 0}return{close:()=>{s&&clearTimeout(s),o?.close(),t.clear()},subscribe:a=>(t.add(a),()=>{t.delete(a)})}},MC=(e,t)=>{const n=new DE;return n.use("*",async(s,i)=>DC(s.req.header("host"),e.host)?i():s.json({error:"Forbidden"},403)),n.get("/",s=>s.html(AC())),n.get("/api/overview",s=>{const i=qn(e.workspaceRoot),r=NC(i),o=CC(e.workspaceRoot,{minRuns:2},i);return s.json({flaky:o,metrics:r})}),n.get("/api/runs",s=>{const r=qn(e.workspaceRoot).filter(o=>typeof o.id=="string"&&typeof o.startTime=="string"&&typeof o.endTime=="string"&&typeof o.duration=="number").map(o=>{const a=o.stats,c=a?{cached:typeof a.cached=="number"?a.cached:void 0,failed:typeof a.failed=="number"?a.failed:void 0,skipped:typeof a.skipped=="number"?a.skipped:void 0,succeeded:typeof a.succeeded=="number"?a.succeeded:void 0,total:typeof a.total=="number"?a.total:void 0}:void 0;return{duration:o.duration,endTime:o.endTime,id:o.id,startTime:o.startTime,stats:c}}).sort((o,a)=>a.startTime.localeCompare(o.startTime));return s.json({runs:r})}),n.get("/api/runs/:id",s=>{const i=fl(e.workspaceRoot,s.req.param("id"));return i?s.json(i):s.json({error:"Not found"},404)}),n.get("/api/runs/:runId/tasks/:taskId/diff",s=>{const i=fl(e.workspaceRoot,s.req.param("runId"));if(!i)return s.json({error:"Run not found"},404);const r=s.req.param("taskId"),o=i.tasks?.find(l=>l.taskId===r);if(!o)return s.json({error:"Task not found"},404);const a=qn(e.workspaceRoot),c=jC(a,i.id,o);return s.json(c)}),n.get("/api/cache",async s=>{if(!$(e.cacheDirectory))return s.json({directory:e.cacheDirectory,entries:[],exists:!1,totalBytes:0});const i=await ht(e.cacheDirectory),r=i.reduce((a,c)=>a+c.sizeBytes,0),o=Date.now();return s.json({directory:e.cacheDirectory,entries:i.map(a=>({ageMs:o-a.mtimeMs,hash:a.hash,mtimeIso:new Date(a.mtimeMs).toISOString(),sizeBytes:a.sizeBytes})),exists:!0,totalBytes:r})}),n.get("/api/environment",s=>s.json({arch:process.arch,cacheDirectory:e.cacheDirectory,node:process.version,platform:process.platform,workspaceRoot:e.workspaceRoot})),n.get("/api/events",s=>VE(s,async i=>{const r=[];let o;const a=t(l=>{if(r.push(l),o){const d=o;o=void 0,d()}});i.onAbort(()=>{if(a(),o){const l=o;o=void 0,l()}}),await i.writeSSE({data:JSON.stringify({ok:!0}),event:"ready"});const c=15e3;for(;!i.aborted;){if(r.length===0){const d=i.sleep(c),u=new Promise(p=>{o=p});if(await Promise.race([d,u]),i.aborted)break;if(r.length===0){await i.writeSSE({data:"",event:"heartbeat"});continue}}const l=r.shift();await i.writeSSE({data:JSON.stringify(l),event:"change"})}})),n},_C=async e=>{const t=await LC(e.workspaceRoot),n=MC(e,t.subscribe),s=sE({fetch:n.fetch,hostname:e.host,port:e.port});await new Promise((l,d)=>{s.once("listening",()=>{l()}),s.once("error",u=>{d(u)})});const i=s.address(),r=typeof i=="object"&&i?i.port:e.port,c=`http://${e.host==="0.0.0.0"||e.host==="::"||e.host==="::0"?"localhost":e.host}:${String(r)}`;return{close:()=>new Promise((l,d)=>{t.close(),s.close(u=>{u?d(u):l()})}),port:r,url:c}},FC=e=>{const{platform:t}=process,[n,s]=t==="darwin"?["open",[e]]:t==="win32"?["cmd",["/c","start","",e]]:["xdg-open",[e]];ih(n,s,i=>{})},VC={description:"Open a browser dashboard with cache, run history, and cache-miss diffs",examples:[["vis dashboard","Start the dashboard on a random port (server only — does not open a browser)"],["vis dashboard --open","Start the dashboard and open it in the default browser"],["vis dashboard --port=7788","Pin the server to a specific port"],["vis dashboard --host=0.0.0.0 --port=7788","Expose the dashboard on all interfaces"]],execute:async({options:e,process:t,visConfig:n,workspaceRoot:s})=>{const i=s??t.cwd,r=hp(i,e.cacheDir,n?.taskRunner?.cacheDirectory),o=typeof e.port=="number"&&Number.isFinite(e.port)?e.port:0,a=typeof e.host=="string"&&e.host.length>0?e.host:"127.0.0.1",c=await _C({cacheDirectory:r,host:a,port:o,workspaceRoot:i});E.success(`Dashboard listening on ${c.url}`),E.info(`Workspace: ${i}`),E.info(`Cache: ${r}`),E.info("Press Ctrl+C to stop."),e.open===!0&&FC(c.url),await new Promise(l=>{let d=!1;const u=()=>{d||(d=!0,process.off("SIGINT",u),process.off("SIGTERM",u),(async()=>{try{await c.close()}catch{}finally{l()}})())};process.once("SIGINT",u),process.once("SIGTERM",u)})},group:"Workspace",name:"dashboard",options:[{defaultValue:0,description:"Port to bind the dashboard server to (0 = auto-assign)",name:"port",type:Number},{defaultValue:"127.0.0.1",description:"Host interface to bind to. Default binds to localhost only.",name:"host",type:String},{defaultValue:!1,description:"Open the dashboard in the default browser after starting",name:"open",type:Boolean},{description:"Cache directory to inspect (overrides config and default). Relative paths resolve against the workspace root.",name:"cache-dir",type:String}]},WC={check:{defaultValue:!1,description:"Preview changes without modifying files (dry-run)",type:Boolean}},HC=R({description:"Deduplicate dependencies using the detected package manager",examples:[["vis dedupe","Run deduplication"],["vis dedupe --check","Preview changes without modifying (CI-friendly)"]],group:"Dependencies",loader:()=>import("./handler9.js"),name:"dedupe",options:WC}),UC={ban:{description:"Ban a dep name or glob for this run (repeatable). Auto-enables --banned-deps.",multiple:!0,type:String},"banned-deps":{defaultValue:!1,description:"Lint deps against policy.bannedDeps in vis config",type:Boolean},"custom-types":{defaultValue:!1,description:"Lint engines.{node,pnpm}, packageManager, volta.*, devEngines.* for drift across packages",type:Boolean},"dead-workspace-patterns":{defaultValue:!1,description:"Flag workspace patterns (in `pnpm-workspace.yaml` / `package.json#workspaces`) that match zero packages",type:Boolean},dep:{description:"Restrict --workspace-versions to a single dep",type:String},"empty-deps":{defaultValue:!1,description:"Flag empty dependency blocks (`dependencies: {}`, `devDependencies: {}`, …) across the workspace",type:Boolean},fix:{defaultValue:!1,description:"Auto-fix violations in place (writes package.json files)",type:Boolean},"fix-specifier":{description:"Specifier used by --fix for workspace-protocol (default: workspace:*)",type:String},format:{description:"Output format: human, json, or minimal (default: human)",type:String},"missing-package-json":{defaultValue:!1,description:"Flag workspace directories that lack a package.json",type:Boolean},pin:{description:"Pin a dep to an exact specifier for this run, e.g. react@^18.2.0 (repeatable). Auto-enables --workspace-versions.",multiple:!0,type:String},"propose-min":{description:"Propose catalog entries for deps ≥N packages already agree on. Activates with --resolve catalog.",type:Number},quiet:{defaultValue:!1,description:"Suppress all output except errors",type:Boolean},"redefine-root":{defaultValue:!1,description:"Lint that no child re-declares a dep already pinned in the workspace root",type:Boolean},resolve:{description:"Conflict resolution for --workspace-versions: highest, lowest, or catalog (default: highest)",type:String},"root-deps":{defaultValue:!1,description:"Flag runtime dependencies on the private workspace root (move them to devDependencies)",type:Boolean},"root-package-manager":{defaultValue:!1,description:"Ensure the workspace root package.json declares a `packageManager` field",type:Boolean},"root-private":{defaultValue:!1,description:'Ensure the workspace root package.json sets `"private": true`',type:Boolean},"similar-deps":{defaultValue:!1,description:"Flag version drift across related dep families (react+react-dom, @babel/*, @storybook/*, …)",type:Boolean},"types-in-deps":{defaultValue:!1,description:"Flag `@types/*` declared in `dependencies` on a private package (should be in devDependencies)",type:Boolean},"workspace-protocol":{defaultValue:!1,description:"Lint that internal deps use the workspace: protocol",type:Boolean},"workspace-versions":{defaultValue:!1,description:"Lint that all packages declare external deps at the same version",type:Boolean}},GC=R({description:"Lint workspace dependency policies (workspace-protocol, banned-deps, redefine-root, workspace-versions, custom-types, empty-deps, root-private, root-package-manager, root-deps, missing-package-json, dead-workspace-patterns, types-in-deps, similar-deps)",examples:[["vis deps","Run every enabled lint and exit non-zero on failures"],["vis deps --workspace-protocol","Only check that internal deps use workspace:*"],["vis deps --workspace-protocol --fix","Auto-rewrite internal deps to use workspace:*"],["vis deps --redefine-root","Flag deps duplicated between root and child packages"],["vis deps --banned-deps","Flag deps matching policy.bannedDeps in vis config"],["vis deps --workspace-versions","Flag external deps declared at different versions across packages"],["vis deps --workspace-versions --fix","Rewrite drifting deps to the highest sibling version"],["vis deps --workspace-versions --dep react","Limit version-drift check to a single dep"],["vis deps --workspace-versions --resolve catalog --fix","Rewrite drifting deps to catalog: when a catalog already pins them"],["vis deps --workspace-versions --resolve catalog --propose-min 3","Suggest new catalog entries for deps ≥3 packages already agree on"],["vis deps --custom-types","Flag drift in engines.{node,pnpm}, packageManager, volta.{node,pnpm,yarn}, devEngines"],["vis deps --custom-types --fix","Align all engines/packageManager/volta versions to the highest sibling"],["vis deps --empty-deps --fix","Drop empty `dependencies` / `devDependencies` / etc. blocks across the workspace"],["vis deps --root-private --fix",'Ensure the workspace root package.json has "private": true'],["vis deps --root-package-manager","Ensure the root package.json declares a `packageManager` field"],["vis deps --root-deps --fix","Move runtime deps off the private workspace root into devDependencies"],["vis deps --missing-package-json","Flag workspace dirs that don't contain a package.json"],["vis deps --dead-workspace-patterns --fix","Drop workspace patterns that match zero packages"],["vis deps --types-in-deps --fix","Move @types/* out of dependencies on private packages"],["vis deps --similar-deps","Flag drift across related dep families (react+react-dom, @babel/*, …)"],["vis deps --ban left-pad --ban request","One-off ban: flag any package declaring left-pad or request"],["vis deps --pin react@18.2.0","One-off pin: flag any package declaring react at a different version"],["vis deps --format json","Emit findings as JSON for CI / editor integrations"]],group:"Security & Health",loader:()=>import("./handler68.js"),name:"deps",options:UC}),zC={output:{alias:"o",description:"Output path (default: .devcontainer/devcontainer.json)",type:String},template:{alias:"t",description:"Start from a template: node, node-pnpm, node-postgres, node-dind, fullstack, python, go, rust, java, devops, minimal, custom",type:String}},JC=R({alias:"dc",description:"Create or update .devcontainer/devcontainer.json interactively",examples:[["vis devcontainer","Launch interactive devcontainer config editor"],["vis dc","Alias for devcontainer"],["vis devcontainer --template node-pnpm","Start from Node.js + pnpm template"]],group:"Scaffold & Config",loader:()=>import("./handler77.js"),name:"devcontainer",options:zC}),ki="Workspace",qC={focus:{description:"Project name(s) to focus on — comma-separated for multiple",type:String},"include-sources":{defaultValue:!1,description:"Also copy focus project source trees to <out>/sources",type:Boolean},out:{description:"Output directory for the scaffold (default: .vis/docker)",type:String},...fe({defaultValue:!0,description:"Rewrite the workspace lockfile to drop unfocused projects (use --no-prune-lockfile to copy verbatim)",name:"prune-lockfile",type:Boolean})},KC=R({commandPath:["docker"],description:"Build a minimal, cache-friendly Docker context for a focus project + its deps",examples:[["vis docker scaffold --focus=my-app","Generate .vis/docker/workspace for my-app + its deps"],["vis docker scaffold --focus=my-app --include-sources","Also copy focus source trees"],["vis docker scaffold --focus=my-app,other --out=.vis/docker","Focus multiple projects"]],group:ki,loader:G(()=>import("./handler59.js"),"scaffoldExecute"),name:"scaffold",options:qC}),YC={context:{description:"Scaffold root for prune (default: .vis/docker)",type:String}},XC=R({commandPath:["docker"],description:"Strip unfocused workspace projects from a scaffolded context (run inside a build stage)",examples:[["vis docker prune --context=.vis/docker","Strip unfocused projects inside a build stage"]],group:ki,loader:G(()=>import("./handler59.js"),"pruneExecute"),name:"prune",options:YC}),ZC={"dry-run":{defaultValue:!1,description:"Print the Dockerfile to stdout instead of writing it",type:Boolean},focus:{description:"Focus project name for the build filter",type:String},force:{defaultValue:!1,description:"Overwrite an existing Dockerfile without prompting",type:Boolean},node:{description:"Node.js version tag for the base image (default: 22)",type:String}},QC=R({argument:{description:"Output path for the Dockerfile (default: ./Dockerfile)",name:"path",type:String},commandPath:["docker"],description:"Generate a multi-stage Dockerfile wired to the scaffold/prune flow (create-only)",examples:[["vis docker init","Generate ./Dockerfile for the detected package manager"],["vis docker init --focus=my-app","Target a specific project's build"],["vis docker init --node=24 --force","Use Node 24 and overwrite without prompting"],["vis docker init --dry-run","Print the Dockerfile instead of writing it"]],group:ki,loader:G(()=>import("./handler59.js"),"initExecute"),name:"init",options:ZC}),e8={config:{description:"Path to a hadolint config (.hadolint.yaml)",type:String},fix:{defaultValue:!1,description:"Apply safe autofixes, then re-lint and report what remains",type:Boolean},install:{defaultValue:!1,description:"Download hadolint without prompting if it is missing",type:Boolean},json:{defaultValue:!1,description:"Emit findings as JSON",type:Boolean}},t8=R({argument:{description:"Dockerfile path(s) to lint (default: ./Dockerfile)",name:"file",type:String},commandPath:["docker"],description:"Lint a Dockerfile with hadolint (downloaded on demand); --fix applies safe autofixes",examples:[["vis docker lint","Lint ./Dockerfile (prompts to download hadolint on first use)"],["vis docker lint apps/web/Dockerfile","Lint a specific Dockerfile"],["vis docker lint --fix","Apply safe autofixes, then report what remains"],["vis docker lint --install --json","Auto-download hadolint and emit JSON"]],group:ki,loader:G(()=>import("./handler59.js"),"lintExecute"),name:"lint",options:e8}),n8=[KC,XC,QC,t8],s8={"exit-code":{defaultValue:!1,description:"Exit with code 1 if issues found",type:Boolean},filter:{description:"Comma-separated package name patterns to scope findings (supports * globs, e.g. '@types/*,react')",type:String},fix:{defaultValue:!1,description:"Auto-apply safe fixes (security overrides + codemods, SIGTERM orphans)",type:Boolean},"fix-force":{defaultValue:!1,description:"With --fix: escalate orphan cleanup to SIGKILL / taskkill /F (use when SIGTERM is ignored)",type:Boolean},format:{description:"Output format: table or json (default: table). Alias: --json",type:String},json:{defaultValue:!1,description:"Shorthand for --format json",type:Boolean},"no-cache":{defaultValue:!1,description:"Bypass the doctor result cache (~/.vis/cache/doctor)",type:Boolean},"no-progress":{defaultValue:!1,description:"Disable live progress UI (forces sequential logs)",type:Boolean},only:{description:"Comma-separated sections to run: dependencies,security,optimization,runtime",type:String},quiet:{defaultValue:!1,description:"Suppress per-section detail; print summary only",type:Boolean},skip:{description:"Comma-separated sections to skip",type:String},strict:{defaultValue:!1,description:"With --exit-code: also fail on outdated and duplicate deps",type:Boolean}},i8=R({description:"Run a full project health check (outdated, security, duplicates, optimizations)",examples:[["vis doctor","Full project health check"],["vis doctor --fix","Check and auto-apply safe fixes"],["vis doctor --format json","Machine-readable output for CI"],["vis doctor --only security","Only run the security scans"],["vis doctor --skip optimization,runtime","Skip the listed sections"],["vis doctor --quiet","Summary only, no per-section breakdown"],["vis doctor --no-progress","Disable live progress UI (sequential logs)"],["vis doctor --exit-code","Exit with code 1 if security issues found"],["vis doctor --exit-code --strict","Fail on any issue (outdated, duplicates, security)"]],group:"Security & Health",loader:()=>import("./handler70.js"),name:"doctor",options:s8}),r8={check:{defaultValue:!1,description:"Report files that would change without writing",type:Boolean},format:{defaultValue:"human",description:"Output format: human, json, minimal, sarif, junit, or github",type:String},output:{description:"Write formatted output to a file path instead of stdout (also accepts `-`/`stdout`/`stderr`)",type:String},quiet:{defaultValue:!1,description:"Suppress per-file logs",type:Boolean},since:{description:"Only format files changed vs the given git ref (branch, tag, sha)",type:String},staged:{defaultValue:!1,description:"Only format files currently staged in the git index",type:Boolean},watch:{defaultValue:!1,description:"Re-run formatters whenever watched files change",type:Boolean}},o8=R({description:"Orchestrate detected formatters (prettier, …) across the workspace",examples:[["vis fmt","Apply formatting in place using every detected formatter"],["vis fmt --check","Report files that would change without writing"],["vis fmt --check --format json","Emit findings as JSON for CI / editor integrations"],["vis fmt --check --format sarif","Emit a SARIF 2.1.0 document for code-scanning uploads"],["vis fmt --check --format junit","Emit a JUnit XML report for CI dashboards"],["vis fmt --check --format github","Emit GitHub Actions workflow commands for inline PR annotations"],["vis fmt src/foo.ts src/bar.ts","Format a specific file list"],["vis fmt --quiet","Suppress per-file logs"],["vis fmt --since main","Only format files changed vs the main branch"],["vis fmt --staged","Only format files currently staged in the git index"],["vis fmt --watch","Re-run formatters when watched files change (cache makes incremental --check near-free)"],["vis fmt --check --format sarif --output fmt.sarif","Write the SARIF report to fmt.sarif instead of stdout"]],group:"Lint & Format",loader:()=>import("./handler60.js"),name:"fmt",options:r8}),a8={defaults:{defaultValue:!1,description:"Skip prompts; use template defaults",type:Boolean},describe:{defaultValue:!1,description:"Print template metadata (about, destination, variables) without running produce",type:Boolean},"dry-run":{defaultValue:!1,description:"Print planned writes without touching disk",type:Boolean},force:{defaultValue:!1,description:"Overwrite existing files without prompting",type:Boolean},json:{defaultValue:!1,description:"Emit JSON output (with --list or --describe)",type:Boolean},list:{defaultValue:!1,description:"List discovered templates",type:Boolean},"no-interactive":{defaultValue:!1,description:"Skip interactive prompts (errors on missing required values)",type:Boolean},"prefer-offline":{defaultValue:!1,description:"Prefer locally cached remote templates over re-downloading",type:Boolean},"skip-scripts":{defaultValue:!1,description:"Skip running post-generation scripts",type:Boolean},to:{description:"Destination directory",type:String}},c8=R({argument:{description:"Template name (or remote source like git://… or npm://…) — omit for interactive picker",name:"template",type:String},description:"Scaffold files from an in-repo template",examples:[["vis generate","Pick a template interactively"],["vis generate package","Run the 'package' template"],["vis generate component -- --name=Button --style=primary","Pre-fill option values"],["vis generate package --to=./packages/new --force","Custom destination + overwrite"],["vis generate package --dry-run","Print planned writes without touching disk"],["vis generate git://github.com/org/template#main","Fetch and run a remote template"],["vis generate --list","Show discovered templates"],["vis generate --list --json","Machine-readable template list"],["vis generate package --describe --json","Print template metadata (variables, destination) as JSON"]],group:"Scaffold & Config",loader:()=>import("./handler61.js"),name:"generate",options:a8}),l8={depth:{alias:"d",description:"Maximum dependency tree depth for ASCII output (default: unlimited)",type:Number},format:{alias:"f",defaultValue:void 0,description:"Output format: tui, ascii, dot, json, html (default: tui in TTY, ascii otherwise)",type:String},output:{alias:"o",description:"Write output to file instead of stdout",type:String}},d8=R({description:"Visualize the project dependency graph",examples:[["vis graph","Show colored dependency graph (TUI in TTY, ASCII otherwise)"],["vis graph --format=ascii","Force ASCII tree output"],["vis graph --format=dot","Output in Graphviz DOT format"],["vis graph --format=html --output=graph.html","Generate interactive HTML graph"],["vis graph --format=json --output=graph.json","Save JSON graph to file"]],group:"Workspace",loader:()=>import("./handler74.js"),name:"graph",options:l8}),Wt={defaultValue:lo,description:"Custom hooks directory",name:"hooks-dir",type:String},Ht=[{defaultValue:void 0,description:"Set to 0 to disable git hooks, 1 to force-enable them under CI (override skipInCI), 2 for debug output",name:"VIS_GIT_HOOKS",type:String}],u8={commandPath:["hook"],description:"Install git hooks for the workspace (migrates husky / prek on prompt)",env:[...Ht],examples:[["vis hook install","Install git hooks in .vis/hooks/"],["vis hook install --hooks-dir=.githooks","Install hooks in a custom directory"],["vis hook install --force","Take over core.hooksPath even when another tool set it"]],group:"Git Hooks",loader:()=>import("./handler72.js").then(e=>({default:e.hookInstallExecute})),name:"install",options:[Wt,{defaultValue:!1,description:"Overwrite core.hooksPath even when it points somewhere unexpected",name:"force",type:Boolean}]},p8={commandPath:["hook"],description:"Remove git hooks and reset core.hooksPath",env:[...Ht],examples:[["vis hook uninstall","Remove git hooks and reset core.hooksPath"]],group:"Git Hooks",loader:()=>import("./handler72.js").then(e=>({default:e.hookUninstallExecute})),name:"uninstall",options:[Wt]},f8={commandPath:["hook"],description:"Migrate from husky or prek to vis hooks (auto-detected)",env:[...Ht],examples:[["vis hook migrate","Migrate from husky or prek to vis hooks (auto-detected)"],["vis hook migrate --dry-run","Preview what a migration would write without touching disk"]],group:"Git Hooks",loader:()=>import("./handler72.js").then(e=>({default:e.hookMigrateExecute})),name:"migrate",options:[Wt,{defaultValue:!1,description:"Preview migrate without writing files",name:"dry-run",type:Boolean}]},h8={commandPath:["hook"],description:"Show configured hooks grouped by stage",env:[...Ht],examples:[["vis hook list","Show configured hooks grouped by stage"]],group:"Git Hooks",loader:()=>import("./handler72.js").then(e=>({default:e.hookListExecute})),name:"list",options:[Wt]},g8={commandPath:["hook"],description:"Sanity-check installed hooks and the bundled runner",env:[...Ht],examples:[["vis hook validate","Sanity-check installed hooks and the bundled runner"]],group:"Git Hooks",loader:()=>import("./handler72.js").then(e=>({default:e.hookValidateExecute})),name:"validate",options:[Wt]},m8={argument:{description:"Hook stage to run (e.g. pre-commit, commit-msg). Defaults to pre-commit.",name:"stage",type:String},commandPath:["hook"],description:"Run a specific hook stage against tracked files",env:[...Ht],examples:[["vis hook run pre-commit --all-files","Run the pre-commit hooks against every tracked file"],["vis hook run pre-commit --from-ref=main --to-ref=HEAD","Run pre-commit hooks on files changed between two refs"],["vis hook run pre-commit --last-commit","Shortcut for --from-ref HEAD~1 --to-ref HEAD"]],group:"Git Hooks",loader:()=>import("./handler72.js").then(e=>({default:e.hookRunExecute})),name:"run",options:[Wt,{defaultValue:!1,description:"Run against every tracked file",name:"all-files",type:Boolean},{defaultValue:void 0,description:"Include files changed since this ref",name:"from-ref",type:String},{defaultValue:void 0,description:"Include files changed up to this ref",name:"to-ref",type:String},{defaultValue:!1,description:"Shortcut for --from-ref HEAD~1 --to-ref HEAD",name:"last-commit",type:Boolean}]},y8={argument:{description:"Target to add (currently: `secrets`)",name:"target",type:String},commandPath:["hook"],description:"Add a managed hook snippet (e.g. `vis secrets --staged`)",env:[...Ht],examples:[["vis hook add secrets","Add a pre-commit hook that runs `vis secrets --staged`"]],group:"Git Hooks",loader:()=>import("./handler72.js").then(e=>({default:e.hookAddExecute})),name:"add",options:[Wt]},v8=[u8,p8,f8,h8,g8,m8,y8],b8={json:{defaultValue:!1,description:"Emit the result as JSON",type:Boolean},target:{description:"Ignore-file target: docker | vercel | npm | slug (default: docker)",type:String},write:{defaultValue:!1,description:"Write the result to disk instead of printing to stdout",type:Boolean}},w8=R({description:"Generate or merge an ignore file (.dockerignore/.vercelignore/.npmignore/.slugignore) without duplicate entries",examples:[["vis ignore","Print a .dockerignore (deduped against an existing one)"],["vis ignore --write","Write/merge the .dockerignore in place"],["vis ignore --target=vercel --write","Write a deduped .vercelignore"],["vis ignore --target=npm --json","Emit the npm-target result as JSON"]],group:"Scaffold & Config",loader:()=>import("./handler53.js"),name:"ignore",options:b8}),k8={yes:{alias:"y",defaultValue:!1,description:"Skip confirmation prompt",type:Boolean}},S8=R({description:"Remove vis from the system (self-uninstall)",examples:[["vis implode","Interactive uninstall"],["vis implode --yes","Non-interactive uninstall (CI)"]],group:"System",loader:()=>import("./handler10.js"),name:"implode",options:k8}),x8={"dry-run":{defaultValue:!1,description:"Print the git plan instead of executing it",type:Boolean},message:{alias:"m",description:"Commit message for the subtree merge",type:String},"no-register":{defaultValue:!1,description:"Do not register the package into the workspace config",type:Boolean},prefix:{alias:"p",description:"Target directory in the monorepo (e.g. packages/tooling/foo)",type:String},ref:{alias:"r",description:"Branch, tag, or commit to import (default: HEAD)",type:String},squash:{defaultValue:!1,description:"Collapse the incoming history into a single merge commit",type:Boolean}},$8=R({argument:{description:"Source git repository URL or local path to import",name:"source",type:String},description:"Import an external repo into the monorepo under a prefix, preserving history",examples:[["vis import git@github.com:me/foo.git --prefix packages/tooling/foo","Import a repo under packages/tooling/foo"],["vis import ../foo --prefix packages/foo --ref v1.2.0","Import a specific tag/branch/commit"],["vis import ../foo --prefix packages/foo --squash","Collapse the incoming history into one commit"],["vis import ../foo --prefix packages/foo --dry-run","Print the git plan without making changes"]],group:"Workspace",loader:()=>import("./handler54.js"),name:"import",options:x8}),E8={json:{defaultValue:!1,description:"Output as JSON",type:Boolean}},C8=R({alias:"view",argument:{description:"Package name followed by optional metadata fields (e.g. 'react version dependencies')",name:"args",type:String},description:"Show npm registry metadata for a package (alias of `npm view` / `pnpm view` / `yarn info` / `bun pm view`)",examples:[["vis info react","Full registry metadata for react"],["vis info react version","Latest version only"],["vis info react versions","All published versions"],["vis info react@18 dependencies","Dependencies of react@18"],["vis info react --json","Emit JSON"],["vis view react","Alias matching npm/pnpm"]],group:"Dependencies",loader:()=>import("./handler11.js"),name:"info",options:E8}),R8={force:{defaultValue:!1,description:"Overwrite existing config file",type:Boolean},"no-interactive":{defaultValue:!1,description:"Skip interactive prompts",type:Boolean},schema:{defaultValue:!1,description:"Print workspace-relative $schema paths for project.json and vis.config.ts, then exit",type:Boolean},"sync-native":{defaultValue:!1,description:"Sync settings to native PM config files",type:Boolean}},O8=R({description:"Initialize vis.config.ts with best-practice security defaults",examples:[["vis init","Interactive setup wizard"],["vis init --no-interactive","Create minimal config without prompts"],["vis init --force","Overwrite existing config"],["vis init --sync-native","Also sync to native PM config files"],["vis init --schema","Print the workspace-relative `$schema` refs to paste into project.json and vis.config.ts"]],group:"Scaffold & Config",loader:()=>import("./handler12.js"),name:"init",options:R8}),j8={json:{defaultValue:!1,description:"Emit findings as a JSON document instead of the human-readable table.",type:Boolean},only:{description:"Comma-separated subset of marshalls to run. Known: author, archivedRepo, downloads, expiredDomains, metadata, newBin, provenance, signatures. Signatures only runs when explicitly requested here.",type:String},strict:{defaultValue:!1,description:"Exit non-zero on any finding (warnings included). Default exits non-zero only on errors.",type:Boolean}},T8=R({argument:{description:"Package to inspect, optionally pinned: `<name>` or `<name>@<spec>`. `<spec>` may be a version, range, or dist-tag.",name:"package"},description:"Run all marshalls against a package without installing it",examples:[["vis inspect express","Run every marshall against express@latest"],["vis inspect lodash@4.17.21","Pin to an exact version"],["vis inspect react@^18","Resolve a semver range, then inspect the best match"],["vis inspect express --json","Emit findings as JSON for CI integration"],["vis inspect express --strict","Exit non-zero on any warning, not just errors"],["vis inspect express --only author,downloads","Run a subset of marshalls"],["vis inspect express --only signatures","Signatures are off by default; opt in with --only"]],group:"Security & Health",loader:()=>import("./handler13.js"),name:"inspect",options:j8}),I8={ci:{defaultValue:!1,description:"Clean install: wipe node_modules then install with frozen lockfile",type:Boolean},dev:{alias:"D",conflicts:"prod",description:"Install devDependencies only (no positional args) / add as dev (with positional args, npm-style)",type:Boolean},exact:{alias:"E",defaultValue:!1,description:"Save exact version (only with positional args; mirrors `npm install -E`)",type:Boolean},filter:{alias:"F",description:"Filter by workspace package name",multiple:!0,type:String},force:{alias:"f",defaultValue:!1,description:"Force reinstall all dependencies",type:Boolean},"frozen-lockfile":{description:"Use frozen lockfile (CI mode, maps to npm ci)",type:Boolean},installer:{description:"Pick the installer explicitly. One of: auto, aube, pnpm, npm, yarn, bun. Overrides VIS_INSTALLER and install.backend in vis.config.",type:String},"lockfile-only":{defaultValue:!1,description:"Update lockfile without installing",type:Boolean},"no-aube":{defaultValue:!1,description:"Skip aube and use the lockfile-detected PM. Wins over --installer / VIS_INSTALLER / install.backend.",type:Boolean},"no-frozen-lockfile":{defaultValue:!1,description:"Opt out of vis's default frozen-lockfile behavior and allow lockfile updates",type:Boolean},"no-marshall-check":{defaultValue:!1,description:"Skip the offline marshall pipeline (only with positional args; mirrors `vis add --no-marshall-check`)",type:Boolean},"no-optional":{defaultValue:!1,description:"Skip optional dependencies",type:Boolean},"no-socket-check":{defaultValue:!1,description:"Skip Socket.dev security check (only with positional args; mirrors `vis add --no-socket-check`)",type:Boolean},"no-typosquat-check":{defaultValue:!1,description:"Skip typosquat name check",type:Boolean},offline:{defaultValue:!1,description:"Use only cached packages",type:Boolean},"prefer-offline":{defaultValue:!1,description:"Prefer cached packages, fall back to network when missing",type:Boolean},prod:{alias:"P",conflicts:"dev",description:"Skip devDependencies (no positional args) / add as peer (with positional args, npm-style)",type:Boolean},recursive:{alias:"r",defaultValue:!1,description:"Install in all workspace packages",type:Boolean},"run-scripts":{defaultValue:!1,description:"Run lifecycle scripts (opts out of vis's default block-by-default policy; allowlisted packages run via security.policies.installScripts.allow)",type:Boolean},"save-optional":{defaultValue:!1,description:"Add as optional dependency (only with positional args; mirrors `npm install -O`)",type:Boolean},silent:{alias:"s",defaultValue:!1,description:"Suppress output",type:Boolean},"workspace-root":{alias:"w",defaultValue:!1,description:"Target workspace root",type:Boolean}},A8=R({alias:"i",argument:{description:"Optional package names. When provided, delegates to `vis add` (enables npm-style `alias npm='vis install'` wrappers).",name:"packages",type:String},description:"Install dependencies using the detected package manager",examples:[["vis install","Install all dependencies (frozen-lockfile by default when a lockfile is present)"],["vis install react react-dom","Delegates to `vis add` — enables shell aliases like `alias npm='vis install'`"],["vis i --no-frozen-lockfile","Allow lockfile updates (escape hatch for the default)"],["vis install --ci","Clean install: wipe node_modules + frozen lockfile (mirrors npm ci / pnpm ci)"],["vis install --prefer-offline","Use cached packages when available, fall back to network"],["vis install --prod","Install production dependencies only"],["vis install --filter app","Install for specific workspace package"],["vis install --run-scripts","Run lifecycle scripts (opts out of vis's default block-by-default policy; allowlisted packages run via security.policies.installScripts.allow)"],["vis install --no-typosquat-check","Skip typosquat name check"],["vis install --installer aube","Force aube as the installer (errors if not on PATH)"],["vis install --no-aube","Bypass aube; use the lockfile-detected PM"]],group:"Dependencies",loader:()=>import("./handler14.js"),name:"install",options:I8}),B8={alias:"ln",argument:{description:"Package name or directory path to link (omit to register current package)",name:"target",type:String},description:"Link a local package for development",examples:[["vis link ./packages/utils","Link local directory package (works on all PMs)"],["vis link","Register current package globally (pnpm <=10, yarn, npm, bun)"],["vis link react","Link global package into current project (pnpm <=10, yarn, npm, bun)"]],group:"Dependencies",loader:()=>import("./handler16.js"),name:"link"},P8={fix:{defaultValue:!1,description:"Apply auto-fixes in place",type:Boolean},format:{defaultValue:"human",description:"Output format: human, json, minimal, sarif, junit, or github",type:String},"max-warnings":{description:"Fail the run if more than N warnings are reported",type:Number},output:{description:"Write formatted output to a file path instead of stdout (also accepts `-`/`stdout`/`stderr`)",type:String},quiet:{defaultValue:!1,description:"Suppress warnings — report errors only",type:Boolean},since:{description:"Only lint files changed vs the given git ref (branch, tag, sha)",type:String},staged:{defaultValue:!1,description:"Only lint files currently staged in the git index",type:Boolean},watch:{defaultValue:!1,description:"Re-run linters whenever watched files change",type:Boolean}},N8=R({description:"Orchestrate detected source-code linters (eslint, …) across the workspace",examples:[["vis lint","Run every detected linter against the workspace"],["vis lint --fix","Apply auto-fixes where the tool supports them"],["vis lint --format json","Emit findings as JSON for CI / editor integrations"],["vis lint --format sarif","Emit a SARIF 2.1.0 document for code-scanning uploads"],["vis lint --format junit","Emit a JUnit XML report for CI dashboards"],["vis lint --format github","Emit GitHub Actions workflow commands for inline PR annotations"],["vis lint src/foo.ts src/bar.ts","Lint a specific file list"],["vis lint --quiet","Suppress warnings — only errors are reported"],["vis lint --max-warnings 0","Treat any warning as a failure"],["vis lint --since main","Only lint files changed vs the main branch"],["vis lint --staged","Only lint files currently staged in the git index"],["vis lint --watch","Re-run linters when watched files change (cache makes incremental near-free)"],["vis lint --format sarif --output lint.sarif","Write the SARIF report to lint.sarif instead of stdout"]],group:"Lint & Format",loader:()=>import("./handler63.js"),name:"lint",options:P8}),D8={"dep-type":{description:"Restrict --deps to specific dep blocks (repeatable)",multiple:!0,type:String},deps:{defaultValue:!1,description:"Render a dep-instance view (table by default; use --format=ndjson|json for jq-friendly streams)",type:Boolean},exclude:{description:"With --deps: glob of declaring package names to drop (repeatable)",multiple:!0,type:String},"external-only":{defaultValue:!1,description:"With --deps: only show external/registry deps",type:Boolean},format:{description:"Output format: table (default), json (single document), or ndjson (one record per line; --deps only)",type:String},include:{description:"With --deps: glob of declaring package names to keep (repeatable)",multiple:!0,type:String},inferred:{defaultValue:!1,description:"Filter target rows to only inferred targets (implies --targets)",type:Boolean},"internal-only":{defaultValue:!1,description:"With --deps: only show internal/workspace deps",type:Boolean},json:{defaultValue:!1,description:"Shorthand for --format=json",type:Boolean},pretty:{defaultValue:!1,description:"Pretty-print with 2-space indent (only meaningful with --format=json)",type:Boolean},query:{description:"Filter projects by query",type:String},tag:{description:'Only list projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…".',multiple:!0,type:String},targets:{defaultValue:!1,description:"Show per-target rows (type, cache, description)",type:Boolean}},L8=R({description:"List all workspace projects with metadata",examples:[["vis list","Show all projects"],["vis list --targets","Per-target rows with type, cache status and description"],["vis list --targets --inferred","Only show targets synthesized by Project Crystal-style inference"],["vis list --deps","Human-readable table of every dep-instance across the workspace"],["vis list --deps --internal-only","Only workspace deps in human form"],["vis list --deps --format=ndjson","Stream every dep-instance as NDJSON for jq pipelines"],["vis list --deps --format=json --pretty","Single pretty-printed JSON array of dep-instances"],["vis list --format=json","Machine-readable project listing"],["vis list --json","Same, shorthand"],['vis list --query "tag=frontend"',"Filter by query"],["vis list --tag=type:package","Filter by tag (shorthand for the query above)"]],group:"Workspace",loader:()=>import("./handler55.js"),name:"list",options:D8}),Re={"dry-run":{defaultValue:!1,description:"Preview changes without applying",type:Boolean},yes:{alias:"y",defaultValue:!1,description:"Skip the confirmation prompt",type:Boolean}},M8={...Re},_8=R({commandPath:["migrate"],description:"Migrate dependencies and scripts to vis",group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateDepsExecute"),name:"deps",options:M8}),F8={...Re},V8=R({commandPath:["migrate"],description:"Inline lint-staged configuration into vis",group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateLintStagedExecute"),name:"lint-staged",options:F8}),W8={...Re},H8=R({commandPath:["migrate"],description:"Inline nano-staged configuration into vis",group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateNanoStagedExecute"),name:"nano-staged",options:W8}),U8={...Re},G8=R({commandPath:["migrate"],description:"Migrate turborepo tasks/config to vis",group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateTurborepoExecute"),name:"turborepo",options:U8}),z8={...Re,aggressive:{defaultValue:!1,description:"Auto-apply the safe cleanup items the migrator would otherwise leave on the checklist: delete nx.json + ignore-files-for-nx-affected.yml, strip nx/@nx/*/@nrwl/* devDependencies, rewrite mechanical `nx run-many|run|affected` scripts. Implies --force.",type:Boolean},force:{defaultValue:!1,description:"Overwrite an existing vis.config.ts (a .bak is taken first)",type:Boolean},"rewrite-sync-generators":{defaultValue:!1,description:"For each project.json `syncGenerators`, add a `pre<target>` script to sibling package.json (with a TODO for the user to wire up)",type:Boolean}},J8=R({commandPath:["migrate"],description:"Migrate nx targets/config to vis",group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateNxExecute"),name:"nx",options:z8}),q8={...Re,"copy-templates":{defaultValue:!1,description:"Copy .moon/templates/* into .vis/templates/* so `vis generate` works without .moon/",type:Boolean}},K8=R({commandPath:["migrate"],description:"Migrate moon tasks/templates to vis",group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateMoonExecute"),name:"moon",options:q8}),Y8={...Re},X8=R({commandPath:["migrate"],description:"Migrate gitleaks config/baseline/hooks to `vis secrets`",examples:[["vis migrate gitleaks","Migrate gitleaks config/baseline/hooks to `vis secrets`"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateGitleaksExecute"),name:"gitleaks",options:Y8}),Z8={...Re},Q8=R({commandPath:["migrate"],description:"Migrate Kingfisher baseline/hooks/scripts to `vis secrets`",examples:[["vis migrate kingfisher","Migrate Kingfisher baseline/hooks/scripts to `vis secrets`"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateKingfisherExecute"),name:"kingfisher",options:Z8}),eR={...Re},tR=R({commandPath:["migrate"],description:"Replace secretlint with `vis secrets`",examples:[["vis migrate secretlint","Replace secretlint with `vis secrets`"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateSecretlintExecute"),name:"secretlint",options:eR}),nR={...Re},sR=R({commandPath:["migrate"],description:"Translate syncpack customTypes into vis policy and strip the syncpack dep/scripts",examples:[["vis migrate syncpack","Translate syncpack customTypes into vis policy and strip the syncpack dep/scripts"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateSyncpackExecute"),name:"syncpack",options:nR}),iR={...Re},rR=R({commandPath:["migrate"],description:"Strip sherif config/dep/scripts and surface ignore-rules as a positive `vis lint --<rule>` command",examples:[["vis migrate sherif","Strip sherif config/dep/scripts and surface ignore-rules as a positive `vis lint --<rule>` command"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateSherifExecute"),name:"sherif",options:iR}),oR={...Re},aR=R({commandPath:["migrate"],description:"Auto-rewrite vis.config.ts to use renamed fields (targetDefaults → tasks, taskDefaults → scopedTasks, taskRunnerOptions → taskRunner)",examples:[["vis migrate self","Rewrite vis.config.ts in-place (a .bak is taken first)"],["vis migrate self --dry-run","Preview the rewrite without writing"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateSelfExecute"),name:"self",options:oR}),cR={},lR=R({commandPath:["migrate"],description:"Audit the workspace for stray gitleaks/secretlint/sherif/syncpack references (exit 1 on issues)",examples:[["vis migrate verify","Audit the workspace for stray gitleaks/secretlint/sherif/syncpack references (exit 1 on issues)"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateVerifyExecute"),name:"verify",options:cR}),dR={"fail-on":{description:"Exit non-zero on: error (default) | warning",type:String},format:{description:"Output format: table | json | ndjson (default: table)",type:String},from:{description:"Source tool to compare against (turbo|nx|moon). Auto-detected when omitted.",type:String}},uR=R({commandPath:["migrate"],description:"Prove a turbo/nx/moon → vis migration preserved the task graph + cache-key surface (exit 1 on divergence)",examples:[["vis migrate verify-graph","Auto-detect the source tool and diff its task graph against the migrated vis.config.ts"],["vis migrate verify-graph --from turbo --format json","Machine-readable equivalence report on stdout (Axis A)"],["vis migrate verify-graph --fail-on warning","Also gate CI on additive/extra-target warnings"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateVerifyGraphExecute"),name:"verify-graph",options:dR}),pR={...Re},fR=R({commandPath:["migrate"],description:"Run every applicable migration non-interactively (autodetected)",examples:[["vis migrate all --yes","Run every detected migration without prompting (CI-friendly)"],["vis migrate all --dry-run","Preview every detected migration without writing files"]],group:"Migrate",loader:G(()=>import("./handler58.js"),"migrateAllExecute"),name:"all",options:pR}),hR=[fR,_8,V8,H8,G8,J8,K8,aR,X8,Q8,tR,sR,rR,lR,uR],gR={"dry-run":{alias:"d",defaultValue:!1,description:"Preview available optimizations without applying",type:Boolean},format:{description:"Output format: table or json (default: table)",type:String},"no-install":{defaultValue:!1,description:"Skip running install after applying overrides",type:Boolean},pin:{defaultValue:!1,description:"Pin Socket.dev overrides to exact versions",type:Boolean},prod:{defaultValue:!1,description:"Only optimize production dependencies",type:Boolean}},mR=R({description:"Analyze and optimize dependencies using e18e replacements and @socketregistry overrides",examples:[["vis optimize","Interactive TUI to select and apply optimizations"],["vis optimize --dry-run","Preview available optimizations"],["vis optimize --pin","Pin Socket.dev overrides to exact versions"],["vis optimize --prod","Only optimize production dependencies"]],group:"Workspace",loader:()=>import("./handler71.js").then(e=>e.h),name:"optimize",options:gR}),yR={argument:{description:"Subcommand and arguments (e.g., cache dir, publish --dry-run, list --depth 0)",name:"args",type:String},description:"Package manager utilities (cache, publish, audit, list, config, etc.)",examples:[["vis pm cache dir","Show cache directory"],["vis pm cache clean","Clean cache"],["vis pm publish --dry-run","Preview publishing"],["vis pm list --depth 0","List direct dependencies"],["vis pm audit","Run security audit"],["vis pm whoami","Show logged-in user"]],group:"System",loader:()=>import("./handler17.js"),name:"pm"},vR={empty:{description:"Author an empty change file (no bumps; satisfies non-strict `check`)",type:Boolean},"from-bot-pr":{description:"Inspect the current PR (via `gh pr view`) and author a change file from its Dependabot / Renovate title (changesets #647)",type:Boolean},message:{description:"Changelog body for the change file",type:String},name:{description:"Slug for the filename (default: random animal name)",type:String},none:{description:"Author a `none` change file (acknowledged but no direct bump)",type:Boolean},packages:{description:"Comma-separated package:level pairs (e.g. '@scope/a:minor,@scope/b:patch')",type:String}},bR=R({commandPath:["release"],description:"Author a new change file (interactive, or non-interactive via --packages)",examples:[["vis release add","Interactive prompt"],["vis release add --packages '@scope/cerebro:minor,@scope/string:patch' --message 'Add tab completion'","Non-interactive"],["vis release add --empty","Author an empty change file (acknowledges PR but releases nothing)"],["vis release add --name fix-tab-completion","Use a fixed slug instead of a random animal name"],["vis release add --from-bot-pr","Generate a change file from the current Dependabot / Renovate PR (changesets #647)"]],group:"Release",loader:()=>import("./handler31.js"),name:"add",options:vR}),wR={channel:{description:"Override channel (defaults to current branch lookup)",type:String},filter:{description:"Limit to packages matching this glob (CSV)",type:String},json:{description:"Emit machine-readable JSON",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},kR=R({commandPath:["release"],description:"Render the would-be changelog entries without writing to disk",examples:[["vis release changelog","Print rendered entries for the pending plan"],["vis release changelog --json","Emit ChangelogResult (with projectChangelogs[]) as JSON"]],group:"Release",loader:()=>import("./handler32.js"),name:"changelog",options:wR}),SR={hook:{description:"Hook context (pre-commit, pre-push) — affects which file states are counted",type:String},"no-fail":{description:"Always exit 0; warnings still print to stderr",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String},strict:{description:"Require every changed package to have its own non-empty change file",type:Boolean}},xR=R({commandPath:["release"],description:"Verify pending change files cover changed packages — CI / husky gate",examples:[["vis release check","Pass if at least one change file exists"],["vis release check --strict","Fail if any changed package isn't covered by a change file"],["vis release check --hook pre-commit","Run as a husky pre-commit hook"],["vis release check --no-fail","Print warnings but always exit 0"]],group:"Release",loader:()=>import("./handler33.js"),name:"check",options:SR}),$R={"no-fail":{description:"Always exit 0 (warnings still print)",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String},strict:{description:"Require every changed package to be covered by a change file",type:Boolean}},ER=R({commandPath:["release","ci"],description:"CI: post or update a sticky PR comment with the pending release plan",examples:[["vis release ci check","Resolve PR from GITHUB_REF, post/update the release plan comment"],["vis release ci check --strict","Fail if any changed package isn't covered"]],group:"Release",loader:()=>import("./handler34.js"),name:"check",options:$R}),CR={"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},RR=R({commandPath:["release","ci"],description:"CI: emit JSON plan + write to $GITHUB_OUTPUT for workflow gating",examples:[["vis release ci plan","Emit { mode, packages, json } and set $GITHUB_OUTPUT"]],group:"Release",loader:()=>import("./handler35.js"),name:"plan",options:CR}),OR={base:{description:"Override the base branch (default: release.baseBranch)",type:String},branch:{description:"Override the version-PR branch (default: vis-release/version-packages)",type:String}},jR=R({commandPath:["release","ci"],description:"CI: rebase the open version-PR onto the base branch and force-push",examples:[["vis release ci rebase-pr","Rebase the version-PR branch onto base + force-push"],["vis release ci rebase-pr --branch=release/version","Override the version-PR branch"]],group:"Release",loader:()=>import("./handler36.js"),name:"rebase-pr",options:OR}),TR={"auto-publish":{description:"Skip version-PR; version + publish inline",type:Boolean},branch:{description:"Override version-PR branch (default: vis-release/version-packages)",type:String},channel:{description:"Override channel (defaults to current branch lookup)",type:String},"first-release":{description:"Bootstrap mode for greenfield monorepos: force currentVersionResolver=disk and skip remote tag-collision checks. Use on the very first release before any git tags exist.",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},IR=R({commandPath:["release","ci"],description:"CI: maintain a rolling version-PR (default) or version+publish inline (--auto-publish)",examples:[["vis release ci release","On push to main: open/update Versioned release PR; on PR merge: publish"],["vis release ci release --auto-publish","Skip version-PR; version + publish inline (alpha/beta workflow)"]],group:"Release",loader:()=>import("./handler56.js"),name:"release",options:TR}),AR={},BR=R({commandPath:["release","ci"],description:"CI: print setup checklist for tokens (VIS_GH_TOKEN, NPM_TOKEN, OIDC) and workflow permissions",examples:[["vis release ci setup","Walk through the recommended secrets + workflow setup"]],group:"Release",loader:()=>import("./handler37.js"),name:"setup",options:AR}),PR={"on-close":{description:"PR-close cleanup mode — enumerate the closed PR's commit SHAs and remove their snapshot tags from the registry (when supported by the backend)",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String},tag:{description:"Override dist-tag (default: pr-<PR_NUMBER>)",type:String}},NR=R({commandPath:["release","ci"],description:"CI: publish snapshot of affected packages + post sticky PR comment with install instructions",examples:[["vis release ci snapshot --tag pr-1234","Publish PR snapshot + post install snippet"]],group:"Release",loader:()=>import("./handler38.js"),name:"snapshot",options:PR}),DR={"first-release":{description:"Bootstrap mode for greenfield monorepos: doctor asserts the workspace has no release tags and no package has been published yet. Pair with `vis release version --first-release`.",type:Boolean},json:{description:"Emit machine-readable JSON instead of a table",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},LR=R({commandPath:["release"],description:"Preflight diagnostics for the release subsystem (workspace, PM, OIDC, NAPI, guards)",examples:[["vis release doctor","Run all checks; exit non-zero if any error"],["vis release doctor --json","Emit machine-readable report"]],group:"Release",loader:()=>import("./handler39.js"),name:"doctor",options:DR}),MR={"dry-run":{description:"Print would-be content without writing",type:Boolean},from:{description:"Git ref to compare against (default: merge-base with baseBranch)",type:String},name:{description:"Slug for the generated filename (default: random animal name)",type:String},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},_R=R({commandPath:["release"],description:"Auto-derive a change file from branch commits (conventional-commits + path heuristics)",examples:[["vis release generate","Walk commits since the merge-base with baseBranch"],["vis release generate --from origin/main","Walk commits since the given ref"],["vis release generate --dry-run","Print the would-be content without writing"]],group:"Release",loader:()=>import("./handler65.js"),name:"generate",options:MR}),FR={agent:{description:"Append a 'Releasing with vis' section to AGENTS.md so AI agents know how to drive the release flow",type:Boolean},apply:{description:"Actually perform the migration writes (not dry-run)",type:Boolean},"dry-run":{description:"Print what would happen without writing files",type:Boolean},fresh:{description:"Skip migration; start clean",type:Boolean},"from-bumpy":{description:"Force migration from bumpy",type:Boolean},"from-changesets":{description:"Force migration from changesets",type:Boolean},"from-semantic-release":{description:"Force migration from semantic-release / multi-semantic-release",type:Boolean},"package-manager":{description:"Override package manager when generating workflows (npm | pnpm | yarn | bun). Default: auto-detect",type:String},workflows:{description:"Generate CI workflow files. GitHub → `.github/workflows/vis-release{,-check,-snapshot}.yml`. GitLab → `.gitlab-ci.yml`.",type:Boolean},yes:{alias:"y",description:"Auto-confirm prompts (CI-safe)",type:Boolean}},VR=R({commandPath:["release"],description:"Scaffold .vis/release; migrate from changesets / bumpy / semantic-release",examples:[["vis release init","Auto-detect source tool and scaffold"],["vis release init --from-semantic-release","Force semantic-release migration"],["vis release init --from-changesets","Force changesets migration"],["vis release init --fresh","Skip migration; start clean"],["vis release init --dry-run","Print what would happen without writing files"],["vis release init --from-semantic-release --apply","Actually perform the semantic-release migration writes"]],group:"Release",loader:()=>import("./handler40.js"),name:"init",options:FR}),WR={channel:{description:"Override channel (defaults to current branch lookup)",type:String},"first-release":{description:"Bootstrap mode for greenfield monorepos: preview the plan without registry / tag lookups (matches `vis release version --first-release`).",type:Boolean},json:{description:"Emit a JSON `{ name: { from, to } }` map instead of pretty lines",type:Boolean},package:{description:"Limit output to a single package",type:String},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},HR=R({commandPath:["release"],description:"Print the next computed version for each package in the release plan. Read-only; no mutations.",examples:[["vis release next-version","Print `<pkg> <old> -> <new>` for every package in the plan"],["vis release next-version --package=@scope/a","Single-package mode"],["vis release next-version --json","Emit a `{ name: { from, to } }` JSON map"]],group:"Release",loader:()=>import("./handler41.js"),name:"next-version",options:WR}),UR={action:{defaultOption:!0,defaultValue:"test",description:"Subcommand: test",type:String},channel:{description:"Restrict dispatch to a single channel kind (`slack`, `discord`, `webhook`) or an id'd channel (`slack:eng`)",type:String},"custom-context":{description:"Path to a JSON file containing a NotificationContext to use instead of the synthetic default",type:String},json:{description:"Emit machine-readable JSON instead of a per-channel report",type:Boolean}},GR=R({commandPath:["release"],description:"Dry-run the configured notification channels (slack / discord / webhook / plugins) with a synthetic release",examples:[["vis release notifications test","Dispatch a fake release to every configured channel"],["vis release notifications test --channel=slack","Dispatch to every Slack channel only"],["vis release notifications test --channel=slack:eng","Dispatch to the slack channel with id=eng only"],["vis release notifications test --custom-context=./fake.json","Use operator-supplied JSON instead of the built-in synthetic release"],["vis release notifications test --json","Emit machine-readable results"]],group:"Release",loader:()=>import("./handler42.js"),name:"notifications",options:UR}),zR={channel:{description:"Override channel (defaults to current branch lookup)",type:String},filter:{description:"Filter packages by name glob",type:String},interactive:{alias:"i",description:"Walk through pending releases interactively and accept / override each bump level",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String},write:{description:"When used with --interactive, write the chosen overrides to a new change file (.vis/release/<id>.md)",type:Boolean}},JR=R({commandPath:["release"],description:"Inspect the release plan; with --interactive, walk through and override bump levels",examples:[["vis release plan","Emit pending plan as JSON"],["vis release plan --interactive","Walk through pending releases, accept or override each bump"],["vis release plan -i --write","Walk through interactively and write the chosen overrides to a change file"]],group:"Release",loader:()=>import("./handler43.js"),name:"plan",options:zR}),qR={action:{defaultOption:!0,defaultValue:"status",description:"Subcommand: enter | exit | status",type:String},...fe({defaultValue:!0,description:"Commit pre.json after writing. Default: commit",name:"commit",type:Boolean}),...fe({defaultValue:!0,description:"Push the commit. Default: push",name:"push",type:Boolean}),tag:{description:"Prerelease tag (e.g. alpha, beta, rc). Required for `enter`",multiple:!0,type:String}},KR=R({commandPath:["release"],description:"Enter / exit pre-release mode (changesets-compatible — every `version` produces a prerelease until exit)",examples:[["vis release pre enter alpha","Enter pre-mode with the `alpha` tag"],["vis release pre enter rc --no-commit","Enter pre-mode locally without committing pre.json"],["vis release pre exit","Flag the next `version` to consolidate + exit pre-mode"],["vis release pre status","Print whether pre-mode is active, exit-pending, or off"]],group:"Release",loader:()=>import("./handler45.js"),name:"pre",options:qR}),YR={access:{description:"Publish access: public | restricted (default: public)",type:String},"allow-stage-publish":{description:"Trust claim: also grant the staged-publish permission (--allow-stage-publish)",type:Boolean},"dry-run":{description:"Print what would publish without uploading",type:Boolean},env:{description:"Trust claim: restrict to a deployment environment (npm trust --env)",type:String},filter:{description:"Glob filter (CSV) — limit to specific packages",type:String},force:{description:"Publish a placeholder even if the package already exists on the registry",type:Boolean},"no-trust":{description:"Skip the `npm trust` step (only publish placeholders)",type:Boolean},"print-config":{description:"Print the resolved release config and exit",type:String},provider:{description:"Trust claim: forge provider (github | gitlab). Default: auto-detect from the git remote",type:String},registry:{description:"Override registry URL",type:String},repo:{description:"Trust claim: owner/repo (github) or group/project (gitlab). Default: detect from git remote",type:String},tag:{description:"dist-tag for the placeholder (default: placeholder — keeps `latest` unset)",type:String},version:{description:"Placeholder version (default: 0.0.0)",type:String},workflow:{description:"Trust claim: workflow/pipeline filename (npm trust --file). Default: auto-detect the release workflow",type:String}},XR=R({commandPath:["release"],description:"Publish non-functional placeholder packages so npm Trusted Publishing (OIDC) can be configured before the first release",examples:[["vis release pretrust","Publish a placeholder for every managed package missing from the registry"],["vis release pretrust --filter '@scope/*'","Limit to a glob"],["vis release pretrust --dry-run","Print what would be published without uploading"]],group:"Release",loader:()=>import("./handler57.js"),name:"pretrust",options:YR}),ZR={channel:{description:"Override channel (defaults to current branch lookup)",type:String},"check-only":{description:"Run preflight checks (config + workspace + plan + auth) and exit. No mutations.",type:Boolean},"dry-run":{description:"Skip uploads — print what would happen",type:Boolean},filter:{description:"Limit to packages matching this glob (CSV)",type:String},"first-release":{description:"Bootstrap mode for greenfield monorepos: force currentVersionResolver=disk and skip remote tag-collision checks. Use on the very first release before any git tags exist.",type:Boolean},"no-push":{description:"Skip `git push --tags` after publish (lands in M5)",type:Boolean},otp:{description:"2FA OTP token",type:String},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String},resume:{description:"Resume from a previous run's state file (skips already-published packages)",type:Boolean},tag:{description:"Override npm dist-tag",type:String}},QR=R({commandPath:["release"],description:"Pack-then-publish unpublished packages, push tags, create GH releases",examples:[["vis release publish","Publish all pending packages"],["vis release publish --dry-run","Print what would publish without uploading"],["vis release publish --tag alpha","Override dist-tag"],["vis release publish --filter '@scope/*'","Limit to packages matching the glob"]],group:"Release",loader:()=>import("./handler46.js"),name:"publish",options:ZR}),e3={"dry-run":{description:"Print what would publish without uploading",type:Boolean},filter:{description:"Glob filter (CSV) — limit snapshots to specific packages",type:String},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String},registry:{description:"Override registry URL (defaults to pkg-pr-new backend or `release.snapshot.registry`)",type:String},tag:{description:"Required: dist-tag for the snapshot release",type:String}},t3=R({commandPath:["release"],description:"Publish 0.0.0-<tag>-<sha> snapshot versions of affected packages",examples:[["vis release snapshot --tag pr-1234","Publish snapshots tagged with the PR number"],["vis release snapshot --tag canary --filter '@scope/*'","Limit to a glob"],["vis release snapshot --tag pr-1234 --dry-run","Preview without uploading"]],group:"Release",loader:()=>import("./handler47.js"),name:"snapshot",options:e3}),n3={action:{defaultOption:!0,defaultValue:"list",description:"Subcommand: list | approve | reject",type:String},all:{description:"Approve every pending stage tracked in .vis/release/staged.json",type:Boolean},...fe({defaultValue:!0,description:"Update .vis/release/staged.json but skip the auto-commit. Default: commit",name:"commit",type:Boolean}),filter:{description:"Package name filter for `list`",type:String},json:{description:"Emit machine-readable JSON",type:Boolean},...fe({defaultValue:!0,description:"Skip pushing the registry commit to the remote. Default: push",name:"push",type:Boolean}),"stage-ids":{description:"Stage IDs (positional args after the action)",multiple:!0,type:String}},s3=R({commandPath:["release"],description:"List, approve, or reject npm staged-publish records (RFC §13.6 — approve/reject need 2FA)",examples:[["vis release stage list","List every staged version (both npm + the local .vis/release/staged.json registry)"],["vis release stage list @scope/pkg","List staged versions for a single package"],["vis release stage list --json","Emit a machine-readable view of both sources"],["vis release stage approve <stage-id>","Promote a staged version, drain it from staged.json, commit + push the registry"],["vis release stage approve --all","Approve every pending stage tracked in .vis/release/staged.json"],["vis release stage reject <stage-id>","Reject a staged version (permanent — cannot be re-approved unless re-staged)"],["vis release stage approve <stage-id> --no-push","Approve, update the registry, commit locally (skip the push)"],["vis release stage approve <stage-id> --no-commit","Approve and update the registry only — no git commit"]],group:"Release",loader:()=>import("./handler48.js"),name:"stage",options:n3}),i3={bump:{description:"Filter by bump level (CSV: major,minor,patch)",type:String},channel:{description:"Override channel (defaults to current branch lookup)",type:String},filter:{description:"Filter packages by name glob",type:String},json:{description:"Emit machine-readable JSON instead of a table",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},r3=R({commandPath:["release"],description:"Print pending release plan (which packages will bump and to what version)",examples:[["vis release status","Print pending plan in human-readable format"],["vis release status --json","Emit the plan as JSON for scripting / CI"],["vis release status --bump major,minor","Filter to packages getting major or minor bumps"],["vis release status --filter '@scope/*'","Show only packages matching the glob"]],group:"Release",loader:()=>import("./handler44.js"),name:"status",options:i3}),o3={channel:{description:"Override channel (defaults to current branch lookup)",type:String},"check-only":{description:"Run preflight checks (config + workspace + plan) and exit. No mutations.",type:Boolean},commit:{description:"Auto-commit after applying",type:Boolean},"dry-run":{description:"Skip writes — print the diff and exit",type:Boolean},filter:{description:"Limit to packages matching this glob (CSV)",type:String},"first-release":{description:"Bootstrap mode for greenfield monorepos: force currentVersionResolver=disk and skip remote tag-collision checks. Use on the very first release before any git tags exist.",type:Boolean},"print-config":{description:"Print the resolved release config and exit (--print-config=debug for runtime-resolved fields)",type:String}},a3=R({commandPath:["release"],description:"Apply pending change files to disk: bump versions + write CHANGELOG entries",examples:[["vis release version","Apply the plan to disk"],["vis release version --dry-run","Print what would change without touching disk"],["vis release version --channel alpha","Force a specific channel (overrides branch detection)"]],group:"Release",loader:()=>import("./handler49.js"),name:"version",options:o3}),c3=[bR,_R,r3,JR,kR,xR,LR,HR,a3,QR,t3,s3,KR,XR,VR,GR,ER,RR,IR,jR,NR,BR],l3={filter:{alias:"F",description:"Filter by workspace package name",multiple:!0,type:String},global:{alias:"g",defaultValue:!1,description:"Remove global package",type:Boolean},recursive:{alias:"r",defaultValue:!1,description:"Remove from all workspace packages",type:Boolean},"save-dev":{alias:"D",defaultValue:!1,description:"Remove from devDependencies",type:Boolean},"workspace-root":{alias:"w",defaultValue:!1,description:"Remove from workspace root",type:Boolean}},d3=R({alias:["rm","un","uninstall"],argument:{description:"Packages to remove",name:"packages",type:String},description:"Remove packages using the detected package manager",examples:[["vis remove lodash","Remove a package"],["vis rm old-package","Remove using alias"],["vis remove --filter app react","Remove from specific workspace"],["vis remove -g typescript","Remove global package"]],group:"Dependencies",loader:()=>import("./handler18.js"),name:"remove",options:l3}),u3={failed:{defaultValue:!1,description:"Filter the replay to failed tasks only",type:Boolean},format:{description:"Output format: table or json (default: table)",type:String},list:{defaultValue:!1,description:"List every available run instead of replaying one",type:Boolean},run:{description:"Run id to replay (defaults to the most recent run)",type:String},task:{description:"Filter the replay to a single task id (e.g. @my/app:build)",type:String}},p3=R({description:"Replay a previous task run from .vis/runs/ — show task results without re-executing",examples:[["vis replay","Show the most recent run summary"],["vis replay --run 2026-04-28T12-34-56_ab12","Inspect a specific historical run"],["vis replay --list","List every recorded run, newest first"],["vis replay --task @myorg/app:build","Focus on one task within the loaded run"],["vis replay --failed","Filter to only failed tasks"],["vis replay --format=json","Machine-readable output for CI"]],group:"Workspace",loader:G(()=>import("./handler19.js"),"replayExecute"),name:"replay",options:u3}),f3={filter:{alias:"F",description:"pnpm-style package selector (repeatable). Supports name globs (@org/*), graph modifiers (...pkg dependents, pkg... dependencies, ...^pkg / pkg^... exclude self), changed-since ([main], ...[origin/main]), and path globs (./packages/*, {glob}).",multiple:!0,type:String},projects:{alias:"p",description:"Comma-separated list of projects to run",type:String},"skip-toolchain":{defaultValue:!1,description:"Skip the toolchain pre-flight (no auto-install for any pinned tool: node / pnpm / yarn / npm / bun / deno / go / python / ruby / rust)",type:Boolean},...fe({description:"Detect lockfile/node_modules drift before running (warns in TTY, fails in CI). Use --no-preflight to disable.",name:"preflight",type:Boolean}),parallel:{defaultValue:3,description:"Maximum number of parallel tasks (falls back to VIS_RUN_CONCURRENCY_LIMIT env var, then 3)",type:Number},...fe({defaultValue:!0,description:"Enable caching (use --no-cache to disable)",name:"cache",type:Boolean}),affected:{defaultValue:!1,description:"Only run on projects affected by git changes. Honors --base/--head/--downstream/--upstream, same as `vis affected`.",type:Boolean},base:{description:"Git base ref for --affected. When omitted, vis auto-resolves it from the active CI provider (GitHub/GitLab/Buildkite/CircleCI) or falls back to `git merge-base HEAD origin/<defaultBase>` locally. Default base branch comes from `vis.config.ts#defaultBase` (or `main`). Requires --affected.",type:String},"cache-backend":{description:"Remote cache wire backend: http (Turborepo-compatible) or reapi (Bazel Remote Execution API gRPC)",type:String},"cache-dir":{description:"Custom cache directory",type:String},"cache-mode":{description:"Remote cache mode: read | write | readwrite (defaults to readwrite when remoteCache is configured)",type:String},downstream:{description:'Downstream scope for --affected: "none", "direct", or "deep" — controls how far to include dependents of changed projects (default "deep"). Requires --affected.',type:String},"dry-run":{defaultValue:!1,description:"Show what would run without executing",type:Boolean},"hash-mode":{description:"Override how the requested target is hashed for this run: declared (hash listed inputs) or trace (hash the files the task actually reads). Overrides per-target hashMode config for the directly-run target.",type:String},head:{description:"Git head ref for --affected. When omitted, auto-resolves from CI env (e.g. `$GITHUB_SHA`) or defaults to `HEAD`. Requires --affected.",type:String},partition:{description:'Partition tasks for distributed CI (e.g., "1/4" for first of four runners). Falls back to VIS_PARTITION env var.',type:String},query:{description:"Filter matched projects by a query (e.g. 'language=typescript && tag=lib')",type:String},"skip-cache":{description:"Comma-separated selectors of tasks to bypass cache for (e.g. 'app:test', ':e2e', '#flaky:lint'). Other tasks in the run still cache normally. --no-cache wins when both are set.",type:String},"skip-constraints":{defaultValue:!1,description:"Skip project constraint validation",type:Boolean},summarize:{defaultValue:!1,description:"Generate a run summary after execution",type:Boolean},tag:{description:'Only run projects carrying one of these tags (repeatable, or comma-separated). Shorthand for --query="tag=…"; combines with --query as AND.',multiple:!0,type:String},upstream:{description:'Upstream scope for --affected: "none", "direct", or "deep" — controls how far to include dependencies of changed projects (default "none"). Requires --affected.',type:String},...fe({description:"Include uncommitted working-tree changes when computing --affected. Defaults to on for local runs and off in CI; use --no-uncommitted to force off.",name:"uncommitted",type:Boolean}),"fail-fast":{defaultValue:!1,description:"Stop all tasks on first failure",type:Boolean},"last-details":{defaultValue:!1,description:"Render the most-recent run's saved summary (from .vis/last-summary.json) and exit without executing any tasks",type:Boolean},log:{description:"Output mode: interleaved (pass-through), labeled (prefix each line with [pkg#task]), or grouped (vite-task-style block)",type:String},"output-style":{description:"Output style: normal (print every task) or quiet (skip output for successful/cached tasks; failed tasks still print in CI mode, and remain in TUI scrollback in interactive mode). Defaults to normal; set run.quietOnSuccess in config to make quiet the default. Per-target options.outputStyle overrides this.",type:String},profile:{description:"Write a Chrome Tracing JSON profile of the run to this path (open in chrome://tracing or Perfetto)",type:String},pty:{defaultValue:!1,description:"Run every task through a pseudo-terminal so color-aware tools render as if attached to a TTY (disables caching)",type:Boolean},"retry-budget":{description:"Global retry budget: cap on total task retries across the run (per-target retryCount is still honored up to the budget)",type:Number},reverse:{defaultValue:!1,description:"Run the dependency graph in reverse (leaves first, then their dependents). Useful for teardown targets like `destroy`/`undeploy` where dependents must run before the things they depend on.",type:Boolean},watch:{defaultValue:!1,description:"Rerun affected tasks on file change. Ctrl+C to exit.",type:Boolean},...fe({defaultValue:!0,description:"Show flaky task report on failure (use --no-flaky to suppress)",name:"flaky",type:Boolean}),"fail-on-retry":{defaultValue:!1,description:"Treat any task that needed at least one retry as a run failure (exit non-zero), even when retries eventually succeeded. Use in CI to surface flakes that retries would otherwise mask.",type:Boolean},...fe({description:"Fail a task if its command references an env var that is unset (no silent empty-string substitution). Use --no-strict-env to disable when set in config.",name:"strict-env",type:Boolean}),"runner-tags":{description:"Comma-separated tags this runner advertises (e.g. 'gpu,slow'). Tasks declaring `options.runnerTags` only run when at least one tag overlaps. Untagged tasks always run. Falls back to VIS_RUNNER_TAGS env var.",type:String},services:{description:"Auto-start service deps. One of: auto | ephemeral | persistent | off. Defaults to `auto` in TTY, `off` in CI.",type:String},"stop-services":{defaultValue:!1,description:"Stop services this run auto-started in registry mode when the run exits (clean, q, or Ctrl+C). Ephemeral services already die with the run.",type:Boolean}},h3=R({argument:{description:"The target to run (e.g., build, test, lint)",name:"target",type:String},description:"Run a target across workspace projects",examples:[["vis run","List all available targets"],["vis run build","Run build on all projects"],["vis run :build","Run build on all projects (moon-style)"],["vis run ~:test","Run test on the project closest to the current directory"],['vis run "#frontend:build"',"Run build on projects tagged 'frontend'"],['vis run :build --query "language=typescript"',"Filter by project metadata"],['vis run build --filter "@org/web"',"Run build on a single package (pnpm filter)"],['vis run build --filter "...@org/web"',"Run build on @org/web and everything that depends on it"],['vis run build -F "@org/web..."',"Run build on @org/web and its dependencies"],['vis run build -F "...[origin/main]"',"Run build on packages changed since origin/main + their dependents"],['vis run build -F "./packages/*"',"Run build on packages matched by a path glob"],["vis run test --affected","Run test only on git-changed projects"],["vis run build --fail-fast","Stop on first failure"],["vis run build --dry-run","Show execution plan without running"],["vis run destroy --reverse","Run leaves-first (teardown order, e.g. CDK/Pulumi destroy)"]],group:"Run & Execute",loader:()=>import("./handler78.js"),name:"run",options:f3}),g3={focus:{description:"Project name(s) to focus on — comma-separated for multiple",type:String},format:{defaultValue:"json",description:"Output format: json (default) or xml",type:String},"include-dev":{defaultValue:!1,description:"Include devDependencies (default: production only)",type:Boolean},output:{description:"Output path (use '-' for stdout; default: sbom.cdx.json)",type:String}},m3=R({description:"Generate a CycloneDX 1.7 Software Bill of Materials for the workspace",examples:[["vis sbom","Write the full-workspace SBOM to sbom.cdx.json"],["vis sbom --focus=my-app","Scope the SBOM to my-app's transitive closure"],["vis sbom --focus=my-app,other","Focus multiple projects"],["vis sbom --format=xml --output=sbom.cdx.xml","Emit XML instead of JSON"],["vis sbom --include-dev","Include devDependencies (default: production only)"],["vis sbom --output=-","Write to stdout"]],group:"Security & Health",loader:()=>import("./handler20.js"),name:"sbom",options:g3}),y3={affected:{defaultValue:!1,description:"Scan only projects affected by the current branch",type:Boolean},baseline:{description:"Path to a baseline JSON of previously-triaged findings",type:String},concurrency:{description:"Rayon worker threads (0 / omit = auto)",type:Number},config:{description:"Path to a JSON config (gitleaks-compatible shape). Defaults to the bundled ruleset.",type:String},"dry-run":{defaultValue:!1,description:"With --init, preview the baseline without writing files",type:Boolean},"enable-rule":{description:"Enable an opt-in rule or tag without restricting output — additive (e.g. tag:preset:weak-passwords, tag:preset:password-manager). Repeatable.",multiple:!0,type:String},exclude:{description:"Gitignore-syntax pattern to exclude from the walk (repeatable)",multiple:!0,type:String},"exclude-from":{description:"Path to a gitignore-shaped file the walker should honor (repeatable)",multiple:!0,type:String},"exclude-rule":{description:"Rule id or tag:<name> selector — drop matching findings. Repeatable.",multiple:!0,type:String},format:{defaultValue:"text",description:"Output format: text (default), json, sarif",type:String},history:{defaultValue:!1,description:"Scan the entire git history (every added/modified blob across commits) instead of the working tree. Surfaces secrets that were committed and later removed. Cannot be combined with --staged/--since/--affected.",type:Boolean},"history-range":{description:"With --history, limit the walk to a rev-list range (e.g. main..HEAD, HEAD~50..HEAD, or a single ref). Defaults to all reachable history of HEAD.",type:String},"include-hidden":{defaultValue:!1,description:"Scan dotfiles",type:Boolean},"include-rule":{description:"Rule id or tag:<name> selector — whitelist, only matching findings are emitted. Implies enablement. Repeatable.",multiple:!0,type:String},init:{defaultValue:!1,description:"Scaffold a baseline from current findings",type:Boolean},"list-rules":{defaultValue:!1,description:"Print all bundled detection rules and exit",type:Boolean},"list-validators":{defaultValue:!1,description:"Print non-HTTP validator types referenced by the current ruleset, with install hints for their optional peer dependencies.",type:Boolean},"max-commits":{description:"With --history, cap the number of commits walked (most-recent first)",type:Number},"max-size":{description:"Skip files larger than this (bytes). Default: 10 MiB",type:Number},"min-confidence":{description:"Drop rules below this author-declared confidence: low (default), medium, high. Rules without a declared confidence (every gitleaks rule) are treated as low, so --min-confidence medium or higher drops them along with explicit low-confidence rules.",type:String},"no-extend-bundled":{defaultValue:!1,description:"With --config, do not merge on top of the bundled ruleset — replace it.",type:Boolean},"no-gitignore":{defaultValue:!1,description:"Do not respect .gitignore",type:Boolean},"only-verified":{defaultValue:!1,description:"With --validate, drop every finding whose validation is not 'verified'. Useful for CI gating.",type:Boolean},quiet:{defaultValue:!1,description:"Suppress all progress output (only emit findings)",type:Boolean},redact:{defaultValue:!1,description:"Mask secret values in output",type:Boolean},"replace-baseline":{defaultValue:!1,description:"With --update-baseline, replace rather than merge",type:Boolean},since:{description:"Scan only files changed since <ref> (e.g. main, origin/HEAD)",type:String},staged:{defaultValue:!1,description:"Scan only files staged for commit",type:Boolean},"update-baseline":{defaultValue:!1,description:"Merge current findings into the baseline and exit 0",type:Boolean},validate:{defaultValue:!1,description:"Live-verify each finding against its provider (one HTTP call per finding, max 8 concurrent). Only supports Kingfisher-style HTTP validators with StatusMatch / WordMatch response matchers; other types (gRPC, multi-step, checksum) mark the finding as validation=skipped. WARNING: sends candidate secrets to the provider — some providers alert their security team on failed auth attempts.",type:Boolean},verbose:{defaultValue:!1,description:"Print diagnostic info (skipped rules, etc.)",type:Boolean}},v3=R({argument:{description:"One or more paths to scan (defaults to workspace root)",name:"paths",type:String},description:"Scan a repository for hardcoded secrets and credentials",examples:[["vis secrets","Scan the workspace with grouped, colourised output"],["vis secrets --staged","Scan only files staged for the current commit (pre-commit hooks)"],["vis secrets --since main","Scan only files changed since the `main` branch"],["vis secrets --affected","Scan only projects affected by the current branch"],["vis secrets --history","Scan the full git history for secrets that were committed then removed"],["vis secrets --history --history-range main..HEAD","Scan only commits on the current branch since main"],["vis secrets --history --max-commits 100 --redact","Scan the last 100 commits, masking any secret values"],["vis secrets --init","Write an initial baseline from current findings"],["vis secrets --list-rules","Print all bundled detection rules"],["vis secrets --list-validators","Print non-HTTP validator types in the ruleset + install hints for each"],["vis secrets --exclude-rule generic-api-key --exclude-rule aws-access-token","Drop noisy rules"],["vis secrets --include-rule stripe-access-token","Check a single rule"],["vis secrets --enable-rule tag:preset:weak-passwords","Enable an opt-in rule group additively (defaults still fire)"],["vis secrets --include-rule tag:preset:password-manager","Restrict output to one opt-in group only"],["vis secrets --min-confidence high","Drop rules without a high confidence label (CI-friendly precision filter)"],["vis secrets --validate --only-verified","Live-verify each finding against its provider (one HTTP call per finding)"],["vis secrets --exclude 'dist/**' --exclude-from .secretsignore","Extra gitignore-syntax exclusions for the walker"],["vis secrets --config ./leaks.json --no-extend-bundled","Use only the supplied config, skip the bundled ruleset"],["vis secrets --concurrency 4","Cap the rayon thread pool (0 / omit = auto)"],["vis secrets --baseline .secrets-baseline.json","Suppress known findings; print diff vs. baseline"],["vis secrets --update-baseline","Merge current findings into the baseline (use --replace-baseline to overwrite)"],["vis secrets --format sarif > report.sarif","SARIF output for GitHub code-scanning"]],group:"Security",loader:()=>import("./handler67.js"),name:"secrets",options:y3}),b3={json:{defaultValue:!1,description:"Emit the report as JSON instead of human-readable text",type:Boolean}},w3=R({commandPath:["security"],description:"List build-script status — allowed, unapproved, and stale allowlist entries",examples:[["vis security list","Show the full build-script triage report"],["vis security list --json","Emit the report as JSON for tooling"]],group:"Security & Health",loader:()=>import("./list.js"),name:"list",options:b3}),k3={"skip-allow-builds":{defaultValue:!1,description:"Skip syncing allowBuilds (trustedDependencies, onlyBuiltDependencies)",type:Boolean},"skip-min-release-age":{defaultValue:!1,description:"Skip syncing minimumReleaseAge and its excludes",type:Boolean}},S3=R({commandPath:["security"],description:"Push vis.config security settings to the package manager's native config",examples:[["vis security sync","Sync allowBuilds + minimumReleaseAge to the PM-native config files"],["vis security sync --skip-allow-builds","Sync only the minimumReleaseAge knobs"],["vis security sync --skip-min-release-age","Sync only allowBuilds (trustedDependencies / onlyBuiltDependencies)"]],group:"Security & Health",loader:()=>import("./sync2.js"),name:"sync",options:k3}),x3={"root-only":{defaultValue:!1,description:"Skip dependency scripts and only run the workspace root's prepublish + prepare hooks",type:Boolean},"with-root":{defaultValue:!1,description:"Also run the workspace root's prepublish + prepare hooks after dependencies",type:Boolean}},$3=R({commandPath:["security"],description:"Run lifecycle scripts for packages in security.policies.installScripts.allow (LavaMoat 'run' parity)",examples:[["vis security run","Run preinstall/install/postinstall for every approved package"],["vis security run --with-root","Also run the workspace root's prepublish + prepare hooks"],["vis security run --root-only","Run only the workspace root's prepublish + prepare hooks"]],group:"Security & Health",loader:()=>import("./run.js"),name:"run",options:x3}),E3={remove:{defaultValue:!1,description:"Remove @lavamoat/preinstall-always-fail from package.json",type:Boolean},status:{defaultValue:!1,description:"Report whether @lavamoat/preinstall-always-fail is installed",type:Boolean}},C3=R({commandPath:["security"],description:"Install @lavamoat/preinstall-always-fail as a devDep so a missing ignore-scripts setting fails loudly",examples:[["vis security tripwire","Install the tripwire devDependency"],["vis security tripwire --status","Report whether the tripwire is installed"],["vis security tripwire --remove","Remove the tripwire from package.json"]],group:"Security & Health",loader:()=>import("./tripwire.js"),name:"tripwire",options:E3}),R3={clear:{defaultValue:!1,description:"Only clear the cache, do not refetch",type:Boolean},json:{defaultValue:!1,description:"Emit the result as JSON instead of human-readable text",type:Boolean}},O3=R({commandPath:["security"],description:"Force-refresh the cached npm signing keys used by the signatures marshall",examples:[["vis security keys-refresh","Drop the disk cache and fetch a fresh key set from registry.npmjs.org"],["vis security keys-refresh --clear","Only drop the cache, do not refetch"],["vis security keys-refresh --json","Emit the refresh result as JSON for tooling"]],group:"Security & Health",loader:()=>import("./keys-refresh.js"),name:"keys-refresh",options:R3}),j3={json:{defaultValue:!1,description:"Emit the result as JSON instead of human-readable text",type:Boolean},offline:{defaultValue:!1,description:"Skip network-bound policies (firstSeen, publisherChange)",type:Boolean}},T3=R({commandPath:["security"],description:"Verify the entire lockfile closure against supply-chain policies (firstSeen, publisherChange, blockExoticSubdeps)",examples:[["vis security verify-lockfile","Re-validate every locked entry; exit non-zero on a policy violation"],["vis security verify-lockfile --offline","Verify without network (skips firstSeen / publisherChange)"],["vis security verify-lockfile --json","Emit the verification result as JSON for CI"]],group:"Security & Health",loader:()=>import("./verify-lockfile.js"),name:"verify-lockfile",options:j3}),I3=[w3,S3,$3,C3,O3,T3],Si={description:"Target id, e.g. @my/api:db",name:"targetId",type:String},A3={description:"Output format: table or json (default: table)",name:"format",type:String},B3={"no-readiness":{defaultValue:!1,description:"Skip the readiness probe",type:Boolean},timeout:{description:"Readiness probe timeout in milliseconds",type:Number}},P3=R({argument:Si,commandPath:["service"],description:"Start a service target detached so it survives across `vis run` invocations",examples:[["vis service start @my/api:db","Boot the db target as a long-lived service"],["vis service start @my/api:db --timeout=60000","Override readiness timeout"],["vis service start @my/api:db --no-readiness","Skip the readiness probe"]],group:"Workspace",loader:G(()=>import("./handler21.js"),"serviceStartExecute"),name:"start",options:B3}),N3={all:{defaultValue:!1,description:"Stop every service registered for this workspace",type:Boolean},"grace-ms":{description:"Override the SIGTERM→SIGKILL grace period in milliseconds",type:Number}},D3=R({argument:{description:"Target id to stop, or omit when using --all",name:"targetId",required:!1,type:String},commandPath:["service"],description:"Stop a running service",examples:[["vis service stop @my/api:db","Stop the db service"],["vis service stop --all","Stop every running service in this workspace"]],group:"Workspace",loader:G(()=>import("./handler21.js"),"serviceStopExecute"),name:"stop",options:N3}),L3={commandPath:["service"],description:"List services registered for this workspace",examples:[["vis service list","Print running services"],["vis service list --format=json","Machine-readable list"]],group:"Workspace",loader:G(()=>import("./handler21.js"),"serviceListExecute"),name:"list",options:[A3]},M3={timeout:{description:"Probe timeout in milliseconds",type:Number}},_3=R({argument:Si,commandPath:["service"],description:"Re-run the readiness probe and report a service's health",examples:[["vis service status @my/api:db","Check whether the db service is reachable"]],group:"Workspace",loader:G(()=>import("./handler21.js"),"serviceStatusExecute"),name:"status",options:M3}),F3={"grace-ms":{description:"Override the SIGTERM→SIGKILL grace period in milliseconds",type:Number},"no-readiness":{defaultValue:!1,description:"Skip the readiness probe after restart",type:Boolean},timeout:{description:"Readiness probe timeout in milliseconds",type:Number}},V3=R({argument:Si,commandPath:["service"],description:"Stop and re-start a running service",examples:[["vis service restart @my/api:db","Recycle the db service"],["vis service restart @my/api:db --no-readiness","Recycle and skip the readiness probe"]],group:"Workspace",loader:G(()=>import("./handler21.js"),"serviceRestartExecute"),name:"restart",options:F3}),W3={follow:{alias:"f",defaultValue:!1,description:"Follow the log file (like `tail -f`)",type:Boolean}},H3=R({argument:Si,commandPath:["service"],description:"Print or tail a service's captured stdout/stderr",examples:[["vis service logs @my/api:db","Print the captured log"],["vis service logs @my/api:db -f","Tail the log (Ctrl-C to exit)"]],group:"Workspace",loader:G(()=>import("./handler21.js"),"serviceLogsExecute"),name:"logs",options:W3}),U3=[P3,D3,L3,_3,V3,H3],G3={commandPath:["shim"],description:"Install project-local PM shims (.vis/shims) that enforce the project's package manager",examples:[["vis shim install","Write npm/pnpm/yarn/… wrapper scripts in .vis/shims"]],group:"Runtime",loader:()=>import("./handler22.js").then(e=>({default:e.shimInstallExecute})),name:"install"},z3={commandPath:["shim"],description:"Remove the project-local PM shim dir (.vis/shims)",examples:[["vis shim uninstall","Delete .vis/shims"]],group:"Runtime",loader:()=>import("./handler22.js").then(e=>({default:e.shimUninstallExecute})),name:"uninstall"},J3={commandPath:["shim"],description:"Report whether the PM shims are installed and active on PATH",examples:[["vis shim status","Show shim install + PATH state"]],group:"Runtime",loader:()=>import("./handler22.js").then(e=>({default:e.shimStatusExecute})),name:"status"},q3=[G3,z3,J3],K3={check:{alias:"c",defaultValue:!1,description:"Check if package.json files are sorted without writing (exits 1 if unsorted)",type:Boolean},ignore:{description:"Glob pattern of files to skip (basename match, or path-relative when the pattern contains `/`). Repeatable.",multiple:!0,type:String},indent:{description:"Indent override: a number of spaces, the literal `tab`, or a literal whitespace string. When unset, the original file's indent is preserved.",type:String},"line-ending":{defaultValue:"auto",description:"Line ending to write: auto (per-file detection, default), lf, or crlf.",type:String},"no-editorconfig":{description:"Disable .editorconfig discovery for indent / line-ending defaults (default: enabled).",type:Boolean},"no-final-newline":{defaultValue:!1,description:"Do not append a trailing newline to the output (default: append one).",type:Boolean},"no-format-bugs":{description:"Disable collapsing `bugs: { url }` to the bare string form (default: enabled).",type:Boolean},"no-format-repository":{description:"Disable collapsing `repository: { type, url }` to the GitHub `owner/repo` shorthand (default: enabled).",type:Boolean},"no-sort-exports":{description:"Disable canonical sorting of `exports` condition keys (default: enabled).",type:Boolean},"sort-order":{description:"Comma-separated list of top-level keys to place first, before the default field order. Repeatable.",multiple:!0,type:String},"sort-scripts":{defaultValue:!1,description:"Also sort the scripts field alphabetically",type:Boolean},unsorted:{description:"Comma-separated list of top-level sections whose key order should be preserved (e.g. dependencies,devDependencies). Repeatable.",multiple:!0,type:String}},Y3=R({description:"Sort package.json files across the workspace using the sort-package-json Rust crate",examples:[["vis sort-package-json","Sort all package.json files in the workspace"],["vis sort-package-json --check","Check if files are already sorted (exit 1 if not)"],["vis sort-package-json --sort-scripts","Also sort the scripts field alphabetically"],["vis sort-package-json --indent 4","Force 4-space indentation (overrides per-file detection)"],["vis sort-package-json --indent tab","Force tab indentation"],["vis sort-package-json --ignore '**/fixtures/**'","Skip files matching one or more glob patterns"],["vis sort-package-json --sort-order name,version,license","Pin a custom prefix order before the default field order"],["vis sort-package-json --unsorted dependencies,devDependencies","Preserve original key order for the listed top-level sections"],["vis sort-package-json --no-final-newline","Do not append a trailing newline"],["vis sort-package-json --line-ending crlf","Force CRLF line endings (default: auto-detect per file)"]],group:"Workspace",loader:()=>import("./handler64.js"),name:"sort-package-json",options:K3}),X3={annotate:{defaultValue:!1,description:"Prefix the rewritten commit messages with the package name",type:Boolean},branch:{alias:"b",description:'Default branch name in the new repo (default: vis.config defaultBase or "main")',type:String},"dry-run":{defaultValue:!1,description:"Print the git plan instead of executing it",type:Boolean},force:{defaultValue:!1,description:"Use a non-empty --output directory anyway",type:Boolean},output:{alias:"o",description:"Destination directory for the new repo (required unless --dry-run)",type:String},push:{defaultValue:!1,description:"Push the new repo to origin (requires --remote)",type:Boolean},remote:{description:"Git remote URL to set as origin on the new repo",type:String},remove:{defaultValue:!1,description:"Delete the package from the monorepo after extracting and commit the removal",type:Boolean}},Z3=R({argument:{description:"Project name or workspace-relative path of the package to extract",name:"package",type:String},description:"Extract a package into a standalone git repo, preserving its history",examples:[["vis split @scope/pkg --output ../pkg-repo","Extract a package into a new repo at ../pkg-repo"],["vis split packages/tooling/foo -o ../foo --remote git@github.com:me/foo.git --push","Extract, set origin, and push"],["vis split @scope/pkg -o ../pkg --remove","Extract, then delete the package from the monorepo (committed)"],["vis split @scope/pkg --dry-run","Print the git plan without making changes"]],group:"Workspace",loader:()=>import("./handler23.js"),name:"split",options:X3}),Q3={"allow-empty":{defaultValue:!1,description:"Allow empty commits when tasks revert all staged changes",type:Boolean},"auto-stage":{defaultValue:!1,description:"Automatically stage new files that tasks create during the run",type:Boolean},concurrent:{description:"Number of concurrent tasks or false for serial",type:String},"continue-on-error":{defaultValue:!1,description:"Run all tasks to completion even if one fails",type:Boolean},cwd:{description:"Working directory to run all tasks in",type:String},debug:{defaultValue:!1,description:"Enable debug output",type:Boolean},diff:{description:"Override the default --staged flag of git diff",type:String},"diff-filter":{description:"Override the default diff-filter",type:String},"fail-on-changes":{defaultValue:!1,description:"Fail with exit code 1 when tasks modify tracked files",type:Boolean},"force-kill":{defaultValue:!1,description:"Kill in-flight tasks with SIGKILL on fast-fail instead of the default SIGTERM",type:Boolean},"hide-partially-staged":{defaultValue:!1,description:"Hide unstaged changes from partially staged files",type:Boolean},"hide-unstaged":{defaultValue:!1,description:"Hide all unstaged changes before running tasks",type:Boolean},quiet:{defaultValue:!1,description:"Suppress console output",type:Boolean},relative:{defaultValue:!1,description:"Pass filepaths relative to cwd to tasks",type:Boolean},revert:{defaultValue:!1,description:"Revert to original state in case of errors",type:Boolean},...fe({defaultValue:!0,description:"Enable backup stash",name:"stash",type:Boolean}),verbose:{defaultValue:!1,description:"Show task output even when tasks succeed",type:Boolean}},eO=R({description:"Run linters on staged files using config from vis.config.ts",examples:[["vis staged","Run staged linters"],["vis staged --verbose","Run with verbose output"],["vis staged --no-stash","Run without backup stash"],["vis staged --diff HEAD~1","Run against a specific diff"]],group:"Run & Execute",loader:()=>import("./handler76.js"),name:"staged",options:Q3}),tO={json:{defaultValue:!1,description:"Emit JSON output",type:Boolean}},nO=R({description:"Show a workspace health dashboard at a glance",examples:[["vis status","Full status overview"],["vis status --json","Machine-readable output"]],group:"Workspace",loader:()=>import("./handler24.js"),name:"status",options:tO}),sO={check:{defaultValue:!1,description:"Verify state without writing (exit non-zero if drift is found)",type:Boolean},fields:{description:"Comma-separated list of fields to mirror from root → workspace packages (package-json-fields kind only). Repeatable.",multiple:!0,type:String},format:{defaultValue:"human",description:"Output format for package-json-fields: human | json",type:String},from:{description:"Input sources for codeowners. Comma-separated or repeated. Values: project-json | nested-codeowners | package-json-maintainers. Defaults to project-json.",multiple:!0,type:String},"ignore-package-name":{description:"Glob pattern of package names to skip (package-json-fields kind only). Repeatable.",multiple:!0,type:String},"nested-includes":{description:"Glob (repeatable) used to discover nested CODEOWNERS files. Defaults to `**/CODEOWNERS`.",multiple:!0,type:String},out:{description:"Output path for the generated file (default: <workspace>/CODEOWNERS) — codeowners kind only",type:String},"preserve-block":{defaultValue:!1,description:"Splice the generated block between markers in the existing file instead of overwriting it. Codeowners kind only.",type:Boolean},quiet:{defaultValue:!1,description:"Suppress per-package log lines; print only the summary (package-json-fields kind only)",type:Boolean},"regeneration-command":{description:"Header instruction shown to reviewers (replaces the default 'update project.json' note). Codeowners kind only.",type:String},"write-guard":{defaultValue:!1,description:"Also emit a .github/workflows/write-guard.yml scoped to projects with `restricted: true` in project.json. Codeowners kind only.",type:Boolean}},iO=R({argument:{description:"What to sync: codeowners | package-json-fields",name:"kind",type:String},description:"Synchronise derived workspace artefacts (codeowners, package.json fields, tsconfig refs, …)",examples:[["vis sync codeowners","Generate CODEOWNERS at the repository root"],["vis sync codeowners --out=.github/CODEOWNERS","Write to .github/CODEOWNERS instead"],["vis sync codeowners --check","Fail if the existing file is stale"],["vis sync codeowners --from=project-json,nested-codeowners","Also aggregate nested CODEOWNERS files in the tree"],["vis sync codeowners --regeneration-command='pnpm codeowners'","Set a custom header instruction"],["vis sync codeowners --preserve-block","Splice the generated block between markers in an existing CODEOWNERS"],["vis sync codeowners --write-guard","Also emit GitHub + GitLab Write Guard CI for restricted projects"],["vis sync package-json-fields","Mirror license/author/repository/bugs/homepage/engines from root to every workspace package"],["vis sync package-json-fields --check","Fail if any workspace package.json is out of sync"],["vis sync package-json-fields --fields license,engines","Override the default field list for this run"]],group:"Workspace",loader:()=>import("./handler62.js"),name:"sync",options:sO}),rO={argument:{description:"Task ID to explain (e.g. @my/app:build)",name:"taskId",type:String},description:"Explain why a task is included in the graph by walking its dependency chain to a root",examples:[["vis task-why @myorg/app:build","Show what pulls build in"],["vis task-why lib-a:test","Check the test task's triggers"]],group:"Workspace",loader:()=>import("./handler25.js"),name:"task-why"},ms="Workspace",oO={"exit-code":{defaultValue:!1,description:"Exit 1 if any tool mismatches",type:Boolean},json:{defaultValue:!1,description:"Emit JSON",type:Boolean}},aO=R({commandPath:["toolchain"],description:"Show every detected manager + expected vs actual tool versions",examples:[["vis toolchain status","Show every detected manager + expected vs actual tool versions"],["vis toolchain status --json","Emit the status as JSON"],["vis toolchain status --exit-code","Exit 1 if any tool mismatches (for CI)"]],group:ms,loader:G(()=>import("./handler26.js"),"statusExecute"),name:"status",options:oO}),cO={commandPath:["toolchain"],description:"Print the primary manager's name (for scripts)",examples:[["vis toolchain detect","Print the primary manager's name"]],group:ms,loader:G(()=>import("./handler26.js"),"detectExecute"),name:"detect"},lO={"dry-run":{defaultValue:!1,description:"Print the command that would run, but don't execute",type:Boolean}},dO=R({commandPath:["toolchain"],description:"Install pinned versions — per-tool delegation to the right manager",examples:[["vis toolchain install","Install pinned versions"],["vis toolchain install --dry-run","Print the commands that would run, but don't execute"]],group:ms,loader:G(()=>import("./handler26.js"),"installExecute"),name:"install",options:lO}),uO={"dry-run":{defaultValue:!1,description:"Print the command that would run, but don't execute",type:Boolean},...fe({defaultValue:!0,description:"Also mirror the version into engines.<tool> when that field already exists. --no-engines to skip.",name:"engines",type:Boolean})},pO=R({argument:{description:"Tool and version to pin, e.g. node@22.13.0 or pnpm@10.32.1",name:"spec",type:String},commandPath:["toolchain"],description:"Pin a version via the best manager for that tool",examples:[["vis toolchain use node@22.13.0","Pin node 22.13.0 via the best runtime manager"],["vis toolchain use pnpm@10.32.1","Update the packageManager field; pnpm self-activates"],["vis toolchain use node@22.13.0 --dry-run","Print the command without running it"]],group:ms,loader:G(()=>import("./handler26.js"),"useExecute"),name:"use",options:uO}),fO={argument:{description:"Tool to resolve, e.g. node",name:"tool",type:String},commandPath:["toolchain"],description:"Print the resolved binary path a manager would launch for a tool",examples:[["vis toolchain which node","Resolve the node binary the manager would launch"]],group:ms,loader:G(()=>import("./handler26.js"),"whichExecute"),name:"which"},hO=[aO,cO,dO,pO,fO],gO={recursive:{alias:"r",defaultValue:!1,description:"Unlink in all workspace packages",type:Boolean}},mO=R({argument:{description:"Packages to unlink (omit for current package)",name:"packages",type:String},description:"Unlink a previously linked package",examples:[["vis unlink","Unlink current package"],["vis unlink react","Unlink specific package"],["vis unlink -r","Unlink in all workspace packages"]],group:"Dependencies",loader:()=>import("./handler27.js"),name:"unlink",options:gO}),yO={"actions-token":{description:"GitHub token for actions resolution (overrides GITHUB_TOKEN / GH_TOKEN env)",type:String},ai:{defaultValue:!1,description:"Run AI analysis on outdated packages before updating (catalog mode)",type:Boolean},"ai-type":{description:"AI analysis type: impact, security, compatibility, or recommend (default: impact)",type:String},changelog:{defaultValue:!1,description:"Show changelog URLs for updated packages",type:Boolean},dev:{alias:"D",conflicts:"prod",description:"Update only devDependencies",type:Boolean},"dry-run":{alias:"d",defaultValue:!1,description:"Preview changes without applying",type:Boolean},exclude:{description:"Glob pattern to exclude packages (repeatable, catalog mode)",lazyMultiple:!0,type:String},filter:{description:"Filter packages in monorepo (pm-wrapper mode; catalog mode uses --include/--exclude)",type:String},format:{description:"Output format: table, json, or minimal (default: table)",type:String},"gitlab-token":{description:"GitLab token for include-ref resolution (overrides GITLAB_TOKEN / CI_JOB_TOKEN env)",type:String},global:{alias:"g",defaultValue:!1,description:"Update global packages",type:Boolean},"ignore-release-age":{defaultValue:!1,description:"Ignore the minimumReleaseAge gate and select the truly latest version even if freshly published. The selected packages are added to the package manager's native age-gate exclude list (pnpm minimumReleaseAgeExclude, bun minimumReleaseAgeExcludes, yarn npmPreapprovedPackages) so the follow-up install isn't blocked; npm has no per-package exclude. Combine with --latest to also cross the semver range.",type:Boolean},include:{description:"Glob pattern to include packages (repeatable, catalog mode)",lazyMultiple:!0,type:String},"include-branches":{defaultValue:!1,description:"Include branch references (e.g. actions/checkout@main) when scanning workflows",type:Boolean},"include-internal":{defaultValue:!1,description:"Also check workspace-owned package names against the registry (catalog mode)",type:Boolean},"include-locked":{alias:"l",defaultValue:!1,description:"Include packages with pinned/exact versions (no ^ or ~ prefix; catalog mode)",type:Boolean},...fe({description:"Run install after catalog update, --no-install to skip (default: true)",name:"install",type:Boolean}),interactive:{alias:"i",defaultValue:!1,description:"Interactive mode",type:Boolean},latest:{alias:"L",conflicts:"target",description:"Update to latest version (ignore semver range; equivalent to --target latest)",type:Boolean},"max-concurrent-requests":{description:"Cap concurrent registry requests during outdated checks (default: 8)",type:Number},"no-actions":{defaultValue:!1,description:"Skip the GitHub Actions ecosystem scan (workflows + composite action.yml files)",type:Boolean},"no-catalog":{defaultValue:!1,description:"Skip catalog mode, use package manager directly",type:Boolean},"no-docker":{defaultValue:!1,description:"Skip the Docker ecosystem scan (Dockerfile + docker-compose images)",type:Boolean},"no-gitlab":{defaultValue:!1,description:"Skip the GitLab CI ecosystem scan (.gitlab-ci.yml + .gitlab/ci/**)",type:Boolean},"no-marshall-check":{defaultValue:!1,description:"Skip the offline marshall pipeline (author, provenance, metadata, downloads, expired-domains, new-bin, signatures, archived-repo) when explicit package arguments are supplied",type:Boolean},"no-optional":{defaultValue:!1,description:"Don't update optionalDependencies",type:Boolean},"no-save":{defaultValue:!1,description:"Update lockfile only",type:Boolean},"no-typosquat-check":{defaultValue:!1,description:"Skip typosquat name check for package arguments",type:Boolean},peer:{defaultValue:!1,description:"Include peerDependencies in update checks",type:Boolean},prerelease:{defaultValue:!1,description:"Include prerelease versions (catalog mode)",type:Boolean},prod:{alias:"P",conflicts:"dev",description:"Update only dependencies",type:Boolean},recursive:{alias:"r",defaultValue:!1,description:"Update recursively in all workspace packages",type:Boolean},"release-channel":{description:"Release channel filter: stable (default), same (match current's prerelease channel), or any",type:String},rollback:{defaultValue:!1,description:"Restore catalog file from the last backup",type:Boolean},...fe({description:"Check for known security vulnerabilities via OSV.dev (default: true; --no-security to skip)",name:"security",type:Boolean}),style:{description:"Reference style for GitHub Actions updates: sha (default, pin to commit SHA + version comment) or preserve",type:String},target:{alias:"t",conflicts:"latest",description:"Update target: latest, minor, or patch (default: latest, catalog mode)",type:String},"workspace-root":{alias:"w",defaultValue:!1,description:"Include workspace root",type:Boolean},yes:{alias:"y",defaultValue:!1,description:"Skip the confirmation prompt for blanket --latest updates. Required in non-TTY contexts (CI) when running `vis update --latest` without explicit package arguments.",type:Boolean}},vO=R({alias:"up",argument:{description:"Packages to update (updates all if omitted)",name:"packages",type:String},description:"Update packages to their latest versions",examples:[["vis update react","Update react within semver range"],["vis up react -L","Update react to latest"],["vis update -i","Interactive mode"],["vis update --filter app","Update in specific workspace"],["vis update -r","Update in all workspaces"],["vis update --target minor","Only apply minor/patch updates (catalog mode)"],["vis update --dry-run","Preview changes without applying"],["vis update --exclude '@types/*'","Exclude packages by pattern"],["vis update --changelog","Show changelog links after updating"],["vis update --rollback","Restore catalog from last backup"],["vis update --ai","Run AI analysis before applying updates"]],group:"Dependencies",loader:()=>import("./handler75.js"),name:"update",options:yO}),bO={check:{defaultValue:!1,description:"Check for updates without installing",type:Boolean},force:{defaultValue:!1,description:"Reinstall even if already current",type:Boolean},silent:{defaultValue:!1,description:"Suppress output (CI mode)",type:Boolean}},wO=R({argument:{description:"Target version (defaults to latest)",name:"version",type:String},description:"Update vis itself to the latest version",examples:[["vis self-update","Update to latest"],["vis self-update 2.0.0","Install specific version"],["vis self-update --check","Check for updates without installing"]],group:"System",loader:()=>import("./handler28.js"),name:"self-update",options:bO}),kO={depth:{description:"Limit dependency tree depth",type:Number},dev:{alias:"D",conflicts:"prod",description:"Filter to dev dependencies (pnpm)",type:Boolean},filter:{alias:"F",description:"Filter by workspace package name",multiple:!0,type:String},global:{alias:"g",defaultValue:!1,description:"Check globally installed packages (pnpm)",type:Boolean},json:{defaultValue:!1,description:"Output as JSON",type:Boolean},long:{defaultValue:!1,description:"Show extended information (pnpm)",type:Boolean},"no-optional":{defaultValue:!1,description:"Exclude optional dependencies (pnpm)",type:Boolean},parseable:{defaultValue:!1,description:"Machine-readable output (pnpm)",type:Boolean},prod:{alias:"P",conflicts:"dev",description:"Filter to production dependencies (pnpm)",type:Boolean},recursive:{alias:"r",defaultValue:!1,description:"Check across all workspaces",type:Boolean}},SO=R({alias:"explain",argument:{description:"Package(s) to explain",name:"packages",type:String},description:"Show why a package is installed (dependency chain)",examples:[["vis why react","Show why react is installed"],["vis why react --json","Output as JSON"],["vis why react -r","Check across all workspaces"],["vis explain react","Alias matching npm's command"]],group:"Dependencies",loader:()=>import("./handler29.js"),name:"why",options:kO}),xO={},$O=R({argument:{description:"File to run, with any args to forward to it",name:"file",type:String},description:"Run a TypeScript/JavaScript file directly under the selected runtime (node | bun)",examples:[["vis x script.ts","Run a TypeScript file (full TS surface: enums, decorators)"],["vis x --runtime bun server.ts","Run under Bun"],["vis x build.ts foo bar","Forward positional args to the file"],["vis x task.ts -- --watch","Forward flags after -- to the file"]],group:"Run & Execute",loader:()=>import("./handler30.js"),name:"x",options:xO}),EO=e=>{e.addCommand(h3),e.addCommand(a$),e.addCommand(d8),e.addCommand(mx),e.addCommand(Cx),e.addCommand(rO),e.addCommand(p3),e.addCommand(w8),e.addCommand(vO),e.addCommand(r$),e.addCommand(GC),e.addCommand(Fx),e.addCommand(Y3),e.addCommand(eO),e.addCommand(nO),e.addCommand(VC),e.addCommand(iO),e.addCommand(L8),e.addCommand(fx),e.addCommand(hx),e.addCommand(N8),e.addCommand(o8),e.addCommand(A8),e.addCommand(vx),e.addCommand(d3),e.addCommand(HC),e.addCommand(SO),e.addCommand(C8),e.addCommand(B8),e.addCommand(mO),e.addCommand(Tf),e.addCommand(Ih),e.addCommand($O),e.addCommand(yR),e.addCommand(O8),e.addCommand(u$),e.addCommand(f$),e.addCommand(c8),e.addCommand(JC),e.addCommand(wO),e.addCommand(S8),e.addCommand(Z3),e.addCommand($8),e.addCommand(Wx),e.addCommand(Jx),e.addCommand(T8),e.addCommand(i8),e.addCommand(mR),e.addCommand(m3),e.addCommand(v3);for(const t of v8)e.addCommand(t);for(const t of hR)e.addCommand(t);for(const t of s$)e.addCommand(t);for(const t of $x)e.addCommand(t);for(const t of dp)e.addCommand(t);for(const t of U3)e.addCommand(t);for(const t of I3)e.addCommand(t);for(const t of Gx)e.addCommand(t);for(const t of n8)e.addCommand(t);for(const t of hO)e.addCommand(t);for(const t of q3)e.addCommand(t);e.addCommand(l$);for(const t of c3)e.addCommand(t)},CO=e=>{for(let t=0;t<e.length;t+=1){const n=e[t];if(n==="--ca-cert"){const s=e[t+1];return s===void 0||s.startsWith("-")?void 0:Vs(s)}if(n.startsWith("--ca-cert=")){const s=n.slice(10);return s===""?void 0:Vs(s)}}},RO=()=>process.platform==="win32"?!!process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM==="xterm-256color":process.env.TERM!=="linux",An=RO(),OO={arrow:An?"→":"->",dash:An?"—":"-",failure:An?"✗":"x",success:An?"✓":"v",warning:An?"⚠":"!"},Qr=m(yt(),"upgrade-check.json"),jO=1440*60*1e3,TO=1440*60*1e3,IO=500,AO=new Set(["--help","--version","-h","-V","help","implode","upgrade"]),BO=()=>{try{if($(Qr))return de(Qr)}catch{}},mf=e=>{try{mt(yt()),ye(Qr,JSON.stringify(e))}catch{}},PO=async e=>{try{const t=new AbortController,n=setTimeout(()=>{t.abort()},IO),s=await fetch(`https://registry.npmjs.org/${e}/latest`,{headers:{accept:"application/json"},signal:t.signal});return clearTimeout(n),s.ok?(await s.json()).version:void 0}catch{return}},hl=(e,t)=>{let n;try{n=pr.gt(t.latestVersion,e,{loose:!0})}catch{return}if(!n)return;const s=Date.now();s-t.lastNoticeAt<TO||(process.stderr.write(`
243
+ ${rn("vis update available:")} ${Bn(e)} ${rn(OO.arrow)} ${fh(Le(t.latestVersion))}${rn(", run")} ${et("vis upgrade")}
244
+ `),t.lastNoticeAt=s,mf(t))},NO=e=>{if(ut||process.env.VIS_CLI_TEST||process.env.VIS_NO_UPDATE_CHECK==="1"||!process.stderr.isTTY||AO.has(e))return!1;const t=new Set(process.argv.slice(2));return!(t.has("--silent")||t.has("-s")||t.has("--json"))},DO=(e,t)=>{if(!NO(t))return;const n=BO(),s=Date.now();if(n&&s-n.lastQueryAt<jO)return()=>{hl(e,n)};let i=n;return PO("@visulima/vis").then(r=>{r&&(i={lastNoticeAt:n?.lastNoticeAt??0,lastQueryAt:s,latestVersion:r},mf(i))}).catch(()=>{}),()=>{i&&hl(e,i)}},LO=async()=>{const e=CO(process.argv);e!==void 0&&!process.env.NODE_EXTRA_CA_CERTS&&(process.env.NODE_EXTRA_CA_CERTS=e);try{const i=Tl(process.cwd()).path;process.env.VIS_MONOREPO_ROOT=i;const r=de(m(i,"package.json"));r.name&&uh(r.name)}catch{}const t=DO(Ws(),process.argv[2]??""),n=If("vis",{packageName:"vis",packageVersion:Ws()}),s=process.argv.includes("--debug")||!!process.env.DEBUG;if(n.addPlugin(Af({concise:Pf,detailed:s,exitOnError:!1})),n.addGlobalOption({description:"Override workspace root directory",name:"cwd",type:String}),n.addGlobalOption({description:"Target JS runtime: node (default) or bun. Overrides VIS_RUNTIME and config; falls back to lockfile detection.",name:"runtime",type:String}),n.addGlobalOption({description:"Path to a vis config file (overrides discovery)",name:"config",type:String}),n.addGlobalOption({description:"Path to a CA bundle (PEM) to trust for HTTPS — for corporate proxies. Equivalent to NODE_EXTRA_CA_CERTS.",name:"ca-cert",type:String}),n.addPlugin(_0),n.addPlugin(ix),EO(n),n.addPlugin(lw(t)),qh(process.argv.slice(2))){const{loadVisConfig:i}=await import("./CONFIG_FILES.js"),r=process.env.VIS_MONOREPO_ROOT||process.cwd();let o;try{o=await i(r)}catch{o=void 0}try{await M0({logger:{info:a=>{process.stdout.write(`${a}
244
245
  `)},warn:a=>{process.stderr.write(`${a}
245
246
  `)}},visConfig:o,workspaceRoot:r})}catch(a){const c=s?a.stack??a.message:a.message;process.stderr.write(`${c}
246
- `),process.exitCode=1}return}await jf(n)},M4=Object.defineProperty({__proto__:null,runCli:AO},Symbol.toStringTag,{value:"Module"});export{mo as $,I0 as A,T0 as B,A0 as C,Da as D,La as E,_a as F,Wa as G,Ha as H,ob as I,za as J,Ja as K,qa as L,Ka as M,Qa as N,Dh as O,ec as P,Oe as Q,Cd as R,xO as S,rd as T,hd as U,fd as V,ad as W,br as X,Aa as Y,Uc as Z,fi as _,k4 as a,R4 as a0,O4 as a1,j4 as a2,T4 as a3,h4 as a4,g4 as a5,m4 as a6,y4 as a7,Gp as a8,xd as a9,o4 as aa,Zy as ab,Dy as ac,u4 as ad,d4 as ae,c4 as af,Ai as ag,l4 as ah,a4 as ai,Wy as aj,co as ak,qy as al,tv as am,p4 as an,e4 as ao,C4 as ap,N4 as aq,Jn as ar,D4 as as,L4 as at,Qw as au,Js as av,E4 as aw,M4 as ax,S4 as b,Zi as c,Mm as d,rb as e,qp as f,Y2 as g,$4 as h,z2 as i,Yp as j,kC as k,B4 as l,Ll as m,Xr as n,cC as o,E as p,aC as q,x4 as r,A4 as s,P4 as t,I4 as u,ao as v,f4 as w,U2 as x,G2 as y,oe as z};
247
+ `),process.exitCode=1}return}await Bf(n)},W4=Object.defineProperty({__proto__:null,runCli:LO},Symbol.toStringTag,{value:"Module"});export{yo as $,N0 as A,P0 as B,D0 as C,Ma as D,_a as E,Va as F,Ua as G,Ga as H,db as I,qa as J,Ka as K,Ya as L,Xa as M,tc as N,Fh as O,nc as P,Oe as Q,jd as R,OO as S,cd as T,yd as U,md as V,dd as W,wr as X,Pa as Y,zc as Z,hi as _,C4 as a,I4 as a0,A4 as a1,B4 as a2,P4 as a3,sk as a4,qs as a5,b4 as a6,w4 as a7,k4 as a8,S4 as a9,qp as aa,Cd as ab,u4 as ac,nv as ad,Fy as ae,m4 as af,g4 as ag,f4 as ah,Bi as ai,h4 as aj,p4 as ak,zy as al,lo as am,Zy as an,rv as ao,y4 as ap,r4 as aq,Jc as ar,_4 as as,qn as at,F4 as au,V4 as av,T4 as aw,W4 as ax,R4 as b,Qi as c,Wm as d,lb as e,Xp as f,ex as g,j4 as h,Y2 as i,Qp as j,CC as k,M4 as l,Fl as m,Zr as n,pC as o,E as p,uC as q,O4 as r,D4 as s,L4 as t,N4 as u,co as v,v4 as w,q2 as x,K2 as y,oe as z};