@visulima/vis 1.0.0-alpha.38 → 1.0.0-alpha.39

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.
@@ -1,4 +1,4 @@
1
- import{createRequire as nt}from"node:module";import{U as gt,$ as dt,N as Ke,j as tt,r as Oe,O as U,q as oe,I as mi,s as Ie}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{t as st,o as pe,p as We,L as Jo,b as ht,s as lt,i as vt,n as yt,d as ct,r as bt}from"../packem_shared/index-D1_fbGbj.js";const at=nt(import.meta.url),be=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ut=i=>{if(typeof be<"u"&&be.versions&&be.versions.node){const[e,o]=be.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return be.getBuiltinModule(i)}return at(i)},{createRequire:rt}=ut("node:module"),pt=/^#?([a-f\d]{3}|[a-f\d]{6})$/i,Fo=i=>{let[,e]=pt.exec(i)??[];const o=e?e.length:0;if(o===3){const a=e.charAt(0),u=e.charAt(1),g=e.charAt(2);e=a+a+u+u+g+g}else if(o!==6)return globalThis.process?.env?.NODE_ENV!=="production"&&console.warn(`[@visulima/colorize] Invalid hex color "${i}"; expected a 3- or 6-digit hex string (e.g. "#96C" or "#E0115F"). Falling back to black.`),[0,0,0];const n=Number.parseInt(e,16);return[n>>16&255,n>>8&255,n&255]},ku=(i,e,o)=>i===e&&e===o?i<8?16:i>248?231:Math.round((i-8)/247*24)+232:16+36*Math.round(i/51)+6*Math.round(e/51)+Math.round(o/51),Ko=i=>{let e,o,n;if(i<8)return 30+i;if(i<16)return 90+(i-8);if(i>=232)e=o=n=((i-232)*10+8)/255;else{i-=16;const g=i%36;e=Math.floor(i/36)/5,o=Math.floor(g/6)/5,n=g%6/5}const a=Math.max(e,o,n)*2;if(a===0)return 30;const u=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(e));return a===2?u+60:u},na=(i,e,o)=>Ko(ku(i,e,o));function wt({onlyFirst:i=!1}={}){const e="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(e,i?void 0:"g")}const Mi=(i,e,o)=>e>i?e:Math.min(i,o),N=39,W=49,aa=10,ua={close:"",open:""},Lu=i=>{const e=i>0?(h,v)=>({close:`\x1B[${String(v)}m`,open:`\x1B[${String(h)}m`}):()=>ua,o=h=>(v,y,c)=>h(ku(Number(v),Number(y),Number(c))),n=h=>v=>{const[y,c,b]=Fo(v);return h(y,c,b)};let a=h=>e(`38;5;${String(h)}`,N),u=h=>e(`48;5;${String(h)}`,W),g=(h,v,y)=>e(`38;2;${String(h)};${String(v)};${String(y)}`,N),d=(h,v,y)=>e(`48;2;${String(h)};${String(v)};${String(y)}`,W);i===1?(a=h=>e(Ko(Number(h)),N),u=h=>e(Ko(Number(h))+aa,W),g=(h,v,y)=>e(na(Number(h),Number(v),Number(y)),N),d=(h,v,y)=>e(na(Number(h),Number(v),Number(y))+aa,W)):i===2&&(g=o(a),d=o(u));const r={bold:e(1,22),dim:e(2,22),hidden:e(8,28),inverse:e(7,27),italic:e(3,23),overline:e(53,55),reset:e(0,0),strike:e(9,29),strikethrough:e(9,29),underline:e(4,24),visible:ua},s={bgBlack:e(40,W),bgBlackBright:e(100,W),bgBlue:e(44,W),bgBlueBright:e(104,W),bgCyan:e(46,W),bgCyanBright:e(106,W),bgGray:e(100,W),bgGreen:e(42,W),bgGreenBright:e(102,W),bgGrey:e(100,W),bgMagenta:e(45,W),bgMagentaBright:e(105,W),bgRed:e(41,W),bgRedBright:e(101,W),bgWhite:e(47,W),bgWhiteBright:e(107,W),bgYellow:e(43,W),bgYellowBright:e(103,W),black:e(30,N),blackBright:e(90,N),blue:e(34,N),blueBright:e(94,N),cyan:e(36,N),cyanBright:e(96,N),gray:e(90,N),green:e(32,N),greenBright:e(92,N),grey:e(90,N),magenta:e(35,N),magentaBright:e(95,N),red:e(31,N),redBright:e(91,N),white:e(37,N),whiteBright:e(97,N),yellow:e(33,N),yellowBright:e(93,N)},l={bg:h=>u(Mi(h,0,255)),bgHex:n(d),bgRgb:(h,v,y)=>d(Mi(h,0,255),Mi(v,0,255),Mi(y,0,255)),fg:h=>a(Mi(h,0,255)),hex:n(g),rgb:(h,v,y)=>g(Mi(h,0,255),Mi(v,0,255),Mi(y,0,255))};return{baseColors:s,baseStyles:r,styleMethods:l}},Zu=gt();dt();Lu(Zu);const jt=(i,e,o)=>{if(e==="")return i;let n=i.indexOf(e);if(n<0)return i;const a=e.length;let u=0,g="";for(;~n;)g+=i.slice(u,n)+o,u=n+a,n=i.indexOf(e,u);return g+i.slice(u)},mt=(i,e,o)=>{if(!i)return"";let n;if(i.raw===void 0?n=String(i):n=String.raw(i,...e),n.includes("\x1B"))for(let a=o;a;a=a.props)n=jt(n,a.close,a.open);return n.includes(`
1
+ import{createRequire as nt}from"node:module";import{U as gt,$ as dt,N as Ke,j as tt,r as Oe,O as U,q as oe,I as mi,s as Ie}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{t as st,o as pe,p as We,L as Jo,b as ht,s as lt,i as vt,n as yt,d as ct,r as bt}from"../packem_shared/index-B4RYu87L.js";const at=nt(import.meta.url),be=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ut=i=>{if(typeof be<"u"&&be.versions&&be.versions.node){const[e,o]=be.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return be.getBuiltinModule(i)}return at(i)},{createRequire:rt}=ut("node:module"),pt=/^#?([a-f\d]{3}|[a-f\d]{6})$/i,Fo=i=>{let[,e]=pt.exec(i)??[];const o=e?e.length:0;if(o===3){const a=e.charAt(0),u=e.charAt(1),g=e.charAt(2);e=a+a+u+u+g+g}else if(o!==6)return globalThis.process?.env?.NODE_ENV!=="production"&&console.warn(`[@visulima/colorize] Invalid hex color "${i}"; expected a 3- or 6-digit hex string (e.g. "#96C" or "#E0115F"). Falling back to black.`),[0,0,0];const n=Number.parseInt(e,16);return[n>>16&255,n>>8&255,n&255]},ku=(i,e,o)=>i===e&&e===o?i<8?16:i>248?231:Math.round((i-8)/247*24)+232:16+36*Math.round(i/51)+6*Math.round(e/51)+Math.round(o/51),Ko=i=>{let e,o,n;if(i<8)return 30+i;if(i<16)return 90+(i-8);if(i>=232)e=o=n=((i-232)*10+8)/255;else{i-=16;const g=i%36;e=Math.floor(i/36)/5,o=Math.floor(g/6)/5,n=g%6/5}const a=Math.max(e,o,n)*2;if(a===0)return 30;const u=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(e));return a===2?u+60:u},na=(i,e,o)=>Ko(ku(i,e,o));function wt({onlyFirst:i=!1}={}){const e="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(e,i?void 0:"g")}const Mi=(i,e,o)=>e>i?e:Math.min(i,o),N=39,W=49,aa=10,ua={close:"",open:""},Lu=i=>{const e=i>0?(h,v)=>({close:`\x1B[${String(v)}m`,open:`\x1B[${String(h)}m`}):()=>ua,o=h=>(v,y,c)=>h(ku(Number(v),Number(y),Number(c))),n=h=>v=>{const[y,c,b]=Fo(v);return h(y,c,b)};let a=h=>e(`38;5;${String(h)}`,N),u=h=>e(`48;5;${String(h)}`,W),g=(h,v,y)=>e(`38;2;${String(h)};${String(v)};${String(y)}`,N),d=(h,v,y)=>e(`48;2;${String(h)};${String(v)};${String(y)}`,W);i===1?(a=h=>e(Ko(Number(h)),N),u=h=>e(Ko(Number(h))+aa,W),g=(h,v,y)=>e(na(Number(h),Number(v),Number(y)),N),d=(h,v,y)=>e(na(Number(h),Number(v),Number(y))+aa,W)):i===2&&(g=o(a),d=o(u));const r={bold:e(1,22),dim:e(2,22),hidden:e(8,28),inverse:e(7,27),italic:e(3,23),overline:e(53,55),reset:e(0,0),strike:e(9,29),strikethrough:e(9,29),underline:e(4,24),visible:ua},s={bgBlack:e(40,W),bgBlackBright:e(100,W),bgBlue:e(44,W),bgBlueBright:e(104,W),bgCyan:e(46,W),bgCyanBright:e(106,W),bgGray:e(100,W),bgGreen:e(42,W),bgGreenBright:e(102,W),bgGrey:e(100,W),bgMagenta:e(45,W),bgMagentaBright:e(105,W),bgRed:e(41,W),bgRedBright:e(101,W),bgWhite:e(47,W),bgWhiteBright:e(107,W),bgYellow:e(43,W),bgYellowBright:e(103,W),black:e(30,N),blackBright:e(90,N),blue:e(34,N),blueBright:e(94,N),cyan:e(36,N),cyanBright:e(96,N),gray:e(90,N),green:e(32,N),greenBright:e(92,N),grey:e(90,N),magenta:e(35,N),magentaBright:e(95,N),red:e(31,N),redBright:e(91,N),white:e(37,N),whiteBright:e(97,N),yellow:e(33,N),yellowBright:e(93,N)},l={bg:h=>u(Mi(h,0,255)),bgHex:n(d),bgRgb:(h,v,y)=>d(Mi(h,0,255),Mi(v,0,255),Mi(y,0,255)),fg:h=>a(Mi(h,0,255)),hex:n(g),rgb:(h,v,y)=>g(Mi(h,0,255),Mi(v,0,255),Mi(y,0,255))};return{baseColors:s,baseStyles:r,styleMethods:l}},Zu=gt();dt();Lu(Zu);const jt=(i,e,o)=>{if(e==="")return i;let n=i.indexOf(e);if(n<0)return i;const a=e.length;let u=0,g="";for(;~n;)g+=i.slice(u,n)+o,u=n+a,n=i.indexOf(e,u);return g+i.slice(u)},mt=(i,e,o)=>{if(!i)return"";let n;if(i.raw===void 0?n=String(i):n=String.raw(i,...e),n.includes("\x1B"))for(let a=o;a;a=a.props)n=jt(n,a.close,a.open);return n.includes(`
2
2
  `)&&(n=n.replace(/(\r*\n)/g,`${o.closeStack}$1${o.openStack}`)),o.openStack+n+o.closeStack},ft=function(i){const e=i?.level??Zu,{baseColors:o,baseStyles:n,styleMethods:a}=Lu(e),u={};let g=null;const d=({props:s},{close:l,open:h})=>{const v=(s?.openStack??"")+h,y=l+(s?.closeStack??""),c=(b,...p)=>mt(b,p,c.props);return Object.setPrototypeOf(c,g),c.props={close:l,closeStack:y,open:h,openStack:v,props:s},c.open=v,c.close=y,c},r=s=>String(s);r.strip=s=>s.replaceAll(wt(),"");for(const s in o)u[s]={get(){const l=d(this,o[s]);return Object.defineProperty(this,s,{value:l}),l}};for(const s in n)u[s]={get(){const l=d(this,n[s]);return Object.defineProperty(this,s,{value:l}),l}};for(const s in a)u[s]={get(){return(...l)=>d(this,a[s](...l))}};return u.ansi256=u.fg,u.bgAnsi256=u.bg,g=Object.defineProperties({},u),Object.setPrototypeOf(r,g),r},Yt=i=>(e,...o)=>{if(!Array.isArray(e)||!Array.isArray(e.raw))throw new TypeError("A tagged template literal must be provided");const n=[e.raw[0]];for(let a=1;a<e.raw.length;a+=1)n.push(String(o[a-1]).replaceAll(/[{}\\]/g,String.raw`\$&`),String(e.raw[a]));return i(n.join(""))},kt=new Map([["0","\0"],["\\","\\"],["a","\x07"],["b","\b"],["e","\x1B"],["f","\f"],["n",`
3
3
  `],["r","\r"],["t"," "],["v","\v"]]),Su=i=>{const e=i.startsWith("u"),o=i[1]==="{";return e&&!o&&i.length===5||i.startsWith("x")&&i.length===3?String.fromCodePoint(Number.parseInt(i.slice(1),16)):e&&o?String.fromCodePoint(Number.parseInt(i.slice(2,-1),16)):kt.get(i)??i},Lt=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi,ga=/(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi,Zt=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,St=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,Jt=/\s*,\s*/,Ct=(i,e)=>{const o=[],n=e.trim().split(Jt);let a;for(const u of n){const g=Number(u);if(!Number.isNaN(g))o.push(g);else if(a=Zt.exec(u))o.push(a[2].replaceAll(St,(d,r,s)=>r?Su(r):s));else throw new Error(`Invalid template style argument: ${u} (in style '${i}')`)}return o},Xt=i=>{ga.lastIndex=0;const e=[];let o;for(;(o=ga.exec(i))!==null;){const n=o[1];o[2]?e.push([n,...Ct(n,o[2])]):o[3]||o[4]?(o[3]&&e.push(["rgb",...Fo(o[3])]),o[4]&&e.push(["bgRgb",...Fo(o[4])])):e.push([n])}return e},da=(i,e)=>{const o={};for(const a of e)for(const u of a.styles)o[u[0]]=a.inverse?void 0:u.slice(1);let n=i;for(const[a,u]of Object.entries(o))if(Array.isArray(u)){if(!(a in n))throw new Error(`Unknown style: ${a}`);n=u.length>0?n[a](...u):n[a]}return n},Ht=i=>e=>{const o=[],n=[];let a=[];if(e.replaceAll(Lt,(u,g,d,r,s,l)=>{if(g)a.push(Su(g));else if(r){const h=a.join("");a=[],n.push(o.length===0?h:da(i,o)(h)),o.push({inverse:d,styles:Xt(r)})}else if(s){if(o.length===0)throw new Error("Found extraneous } in template literal");n.push(da(i,o)(a.join(""))),a=[],o.pop()}else a.push(l)}),n.push(a.join("")),o.length>0)throw new Error(`template literal is missing ${String(o.length)} closing bracket${o.length===1?"":"s"} (\`}\`)`);return n.join("")},Dt=new ft,Tt=Ht(Dt),Bt=Yt(Tt),Qt=rt(import.meta.url),Vi=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xe=i=>{if(typeof Vi<"u"&&Vi.versions&&Vi.versions.node){const[e,o]=Vi.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return Vi.getBuiltinModule(i)}return Qt(i)},{createRequire:Mt}=Xe("node:module"),Ri=Vi,{execFileSync:Gt}=Xe("node:child_process"),Ye=Xe("node:fs"),Nt=Xe("node:tty"),Wt=Xe("node:os"),xt=[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],Pt=12288,Ft=65510,Kt=[12288,12288,65281,65376,65504,65510],Ot=8361,At=65518,Rt=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],_t=32,zt=10630,Et=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],qt=4352,It=262141,Ju=[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],He=(i,e)=>{let o=0,n=Math.floor(i.length/2)-1;for(;o<=n;){const a=Math.floor((o+n)/2),u=a*2;if(e<i[u])n=a-1;else if(e>i[u+1])o=a+1;else return!0}return!1},ta=19968,[Ut,$t]=Vt(Ju);function Vt(i){let e=i[0],o=i[1];for(let n=0;n<i.length;n+=2){const a=i[n],u=i[n+1];if(ta>=a&&ta<=u)return[a,u];u-a>o-e&&(e=a,o=u)}return[e,o]}const ir=i=>i<161||i>1114109?!1:He(xt,i),er=i=>i<Pt||i>Ft?!1:He(Kt,i),or=i=>i<Ot||i>At?!1:He(Rt,i),nr=i=>i<_t||i>zt?!1:He(Et,i),ar=i=>i>=Ut&&i<=$t?!0:i<qt||i>It?!1:He(Ju,i);function ur(i){return ir(i)?"ambiguous":er(i)?"fullwidth":or(i)?"halfwidth":nr(i)?"narrow":ar(i)?"wide":"neutral"}function gr(i){if(!Number.isSafeInteger(i))throw new TypeError(`Expected a code point, got \`${typeof i}\`.`)}function Cu(i){return gr(i),ur(i)}const ra=new Map,dr=i=>[i.ambiguousIsNarrow?1:0,i.control,i.fullWidth,i.regular,i.wide].join("|"),tr=i=>{const e=dr(i.width);let o=ra.get(e);return o||(o=new Map,ra.set(e,o)),o},xe=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Xu=i=>i>=32&&i<=126?"latin":i===8203||i===8204||i===8205||i===8288?"zero":i<=31||i>=127&&i<=159?"control":i>=160&&i<=255||i>=9472&&i<=9599?"latin":i>=4352&&i<=4607||i>=11904&&i<=40959||i>=44032&&i<=55215||i>=63744&&i<=64255||i>=65280&&i<=65519&&!(i>=65377&&i<=65439)||i>=12352&&i<=12543?"wide":i===8230?"latin":"other",rr=(i,e)=>{const o=tr(e),n=Math.floor(i/65536),a=i%65536;let u=o.get(n);if(u||(u=new Map,o.set(n,u)),u.has(a))return u.get(a);let g;switch(Xu(i)){case"control":{g=e.width.control;break}case"latin":{g=e.width.regular;break}case"wide":{g=e.width.wide;break}case"zero":{g=0;break}default:switch(Cu(i)){case"ambiguous":{g=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{g=e.width.fullWidth;break}case"wide":{g=e.width.wide;break}default:g=e.width.regular}}return u.set(a,g),g},sr=i=>i>=768&&i<=879||i>=6832&&i<=6911||i>=7616&&i<=7679||i>=8400&&i<=8447||i>=65056&&i<=65071||i>=917760&&i<=917999||i>=65024&&i<=65039||i>=3633&&i<=3642||i>=3655&&i<=3662||i>=3761&&i<=3769||i>=3771&&i<=3772||i>=3784&&i<=3789||i>=2304&&i<=2307||i>=2362&&i<=2383||i>=2385&&i<=2391||i>=2402&&i<=2403||i>=2433&&i<=2435||i>=2492&&i<=2500||i>=2509&&i<=2509||i>=2561&&i<=2563||i>=2620&&i<=2637||i>=1611&&i<=1631||i>=1648&&i<=1648||i>=1750&&i<=1773||i>=2276&&i<=2302||i>=1425&&i<=1469||i>=1471&&i<=1471||i>=1473&&i<=1474||i>=1476&&i<=1477||i>=1479&&i<=1479||i>=3893&&i<=3893||i>=3895&&i<=3895||i>=3897&&i<=3897||i>=3953&&i<=3966||i>=3968&&i<=3972||i>=3974&&i<=3975?!0:i>=768&&i<=777||i>=803&&i<=803,Oo=(i,e={})=>{if(!i||i.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const o={truncation:{countAnsiEscapeCodes:e.countAnsiEscapeCodes??!1,ellipsis:e.ellipsis??"",ellipsisWidth:e.ellipsisWidth??(e.ellipsis?Oo(e.ellipsis,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:e.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:e.ambiguousIsNarrow??!1,ansi:e.ansiWidth??0,control:e.controlWidth??0,emoji:e.emojiWidth??2,fullWidth:e.fullWidth??2,halfWidth:e.halfWidth??1,regular:e.regularWidth??1,tab:e.tabWidth??8,wide:e.wideWidth??2}},n=Math.max(0,o.truncation.limit-o.truncation.ellipsisWidth),{length:a}=i,u=a>1e4;let g=0,d=0,r=a,s=!1;const l=i.includes("\x1B")||i.includes("›");for(;g<a;){if(l&&(i[g]==="\x1B"||i[g]==="›")){if(i.startsWith("\x1B]8;;",g)){const p="\x1B]8;;\x07",j=p.length,L=i.indexOf("\x07",g+5);if(L!==-1){const R=i.indexOf(p,L+1);if(R!==-1){const _=R+j,q=i.slice(L+1,R).replace(pe,""),Q=Oo(q,{ambiguousIsNarrow:o.width.ambiguousIsNarrow,ansiWidth:o.width.ansi,controlWidth:o.width.control,countAnsiEscapeCodes:!1,ellipsis:o.truncation.ellipsis,ellipsisWidth:o.truncation.ellipsisWidth,emojiWidth:o.width.emoji,fullWidth:o.width.fullWidth,halfWidth:o.width.halfWidth,limit:Math.max(0,n-d),regularWidth:o.width.regular,tabWidth:o.width.tab,wideWidth:o.width.wide}),I=Q.width;if(Q.truncated)s=!0,r=Math.min(r,g);else if(d+I>n&&(r=Math.min(r,g),s=!0,d+I>o.truncation.limit))break;if(d+=I,g=_,s&&d>=o.truncation.limit)break;continue}}}if(pe.lastIndex=g,pe.test(i)){const p=pe.lastIndex-g,j=o.truncation.countAnsiEscapeCodes?p:o.width.ansi;if(d+j>n&&(r=Math.min(r,g),d+j>o.truncation.limit)){s=!0;break}d+=j,g=pe.lastIndex;continue}}const y=i.codePointAt(g);if(y===8203||y===65279||y>=8288&&y<=8292){g+=1;continue}if(y===9){if(d+o.width.tab>n&&(r=Math.min(r,g),d+o.width.tab>o.truncation.limit)){s=!0;break}d+=o.width.tab,g+=1;continue}if(xe.lastIndex=g,xe.test(i)){const p=(xe.lastIndex-g)*o.width.regular;if(d+p>n){const j=Math.floor((n-d)/o.width.regular);if(r=Math.min(r,g+j),d+p>o.truncation.limit){s=!0;break}}d+=p,g=xe.lastIndex;continue}if((y<=31||y>=127&&y<=159)&&(We.lastIndex=g,We.test(i))){const p=(We.lastIndex-g)*o.width.control;if(d+p>n&&(r=Math.min(r,g+Math.floor((n-d)/o.width.control)),d+p>o.truncation.limit)){s=!0;break}d+=p,g=We.lastIndex;continue}if(Jo.lastIndex=g,Jo.test(i)){if(d+o.width.emoji>n&&(r=Math.min(r,g),d+o.width.emoji>o.truncation.limit)){s=!0;break}d+=o.width.emoji,g=Jo.lastIndex;continue}const c=i.codePointAt(g)??0;if(sr(c)){g+=c>65535?2:1;continue}let b;if(u)b=rr(c,o);else switch(Xu(c)){case"control":{b=o.width.control;break}case"latin":{b=o.width.regular;break}case"wide":{b=o.width.wide;break}case"zero":{b=0;break}default:switch(Cu(c)){case"ambiguous":{b=o.width.ambiguousIsNarrow?o.width.regular:o.width.wide;break}case"fullwidth":{b=o.width.fullWidth;break}case"wide":{b=o.width.wide;break}default:b=o.width.regular}}if(d+b>n&&(r=Math.min(r,g),d+b>o.truncation.limit)){s=!0;break}d+=b,g+=c>65535?2:1}let h=d,v=!1;return s&&o.truncation.limit>=o.truncation.ellipsisWidth&&(h=o.truncation.limit,v=!0),{ellipsed:v,index:s?r:a,truncated:s,width:h}},hr=(i,e={})=>Oo(i,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,lr=Mt(import.meta.url),we=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,vr=i=>{if(typeof we<"u"&&we.versions&&we.versions.node){const[e,o]=we.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return we.getBuiltinModule(i)}return lr(i)};vr("node:util");function yr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Co,sa;function cr(){if(sa)return Co;sa=1,Co=e;function i(n){return n instanceof Buffer?Buffer.from(n):new n.constructor(n.buffer.slice(),n.byteOffset,n.length)}function e(n){if(n=n||{},n.circles)return o(n);const a=new Map;if(a.set(Date,s=>new Date(s)),a.set(Map,(s,l)=>new Map(g(Array.from(s),l))),a.set(Set,(s,l)=>new Set(g(Array.from(s),l))),n.constructorHandlers)for(const s of n.constructorHandlers)a.set(s[0],s[1]);let u=null;return n.proto?r:d;function g(s,l){const h=Object.keys(s),v=new Array(h.length);for(let y=0;y<h.length;y++){const c=h[y],b=s[c];typeof b!="object"||b===null?v[c]=b:b.constructor!==Object&&(u=a.get(b.constructor))?v[c]=u(b,l):ArrayBuffer.isView(b)?v[c]=i(b):v[c]=l(b)}return v}function d(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return g(s,d);if(s.constructor!==Object&&(u=a.get(s.constructor)))return u(s,d);const l={};for(const h in s){if(Object.hasOwnProperty.call(s,h)===!1)continue;const v=s[h];typeof v!="object"||v===null?l[h]=v:v.constructor!==Object&&(u=a.get(v.constructor))?l[h]=u(v,d):ArrayBuffer.isView(v)?l[h]=i(v):l[h]=d(v)}return l}function r(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return g(s,r);if(s.constructor!==Object&&(u=a.get(s.constructor)))return u(s,r);const l={};for(const h in s){const v=s[h];typeof v!="object"||v===null?l[h]=v:v.constructor!==Object&&(u=a.get(v.constructor))?l[h]=u(v,r):ArrayBuffer.isView(v)?l[h]=i(v):l[h]=r(v)}return l}}function o(n){const a=[],u=[],g=new Map;if(g.set(Date,h=>new Date(h)),g.set(Map,(h,v)=>new Map(r(Array.from(h),v))),g.set(Set,(h,v)=>new Set(r(Array.from(h),v))),n.constructorHandlers)for(const h of n.constructorHandlers)g.set(h[0],h[1]);let d=null;return n.proto?l:s;function r(h,v){const y=Object.keys(h),c=new Array(y.length);for(let b=0;b<y.length;b++){const p=y[b],j=h[p];if(typeof j!="object"||j===null)c[p]=j;else if(j.constructor!==Object&&(d=g.get(j.constructor)))c[p]=d(j,v);else if(ArrayBuffer.isView(j))c[p]=i(j);else{const L=a.indexOf(j);L!==-1?c[p]=u[L]:c[p]=v(j)}}return c}function s(h){if(typeof h!="object"||h===null)return h;if(Array.isArray(h))return r(h,s);if(h.constructor!==Object&&(d=g.get(h.constructor)))return d(h,s);const v={};a.push(h),u.push(v);for(const y in h){if(Object.hasOwnProperty.call(h,y)===!1)continue;const c=h[y];if(typeof c!="object"||c===null)v[y]=c;else if(c.constructor!==Object&&(d=g.get(c.constructor)))v[y]=d(c,s);else if(ArrayBuffer.isView(c))v[y]=i(c);else{const b=a.indexOf(c);b!==-1?v[y]=u[b]:v[y]=s(c)}}return a.pop(),u.pop(),v}function l(h){if(typeof h!="object"||h===null)return h;if(Array.isArray(h))return r(h,l);if(h.constructor!==Object&&(d=g.get(h.constructor)))return d(h,l);const v={};a.push(h),u.push(v);for(const y in h){const c=h[y];if(typeof c!="object"||c===null)v[y]=c;else if(c.constructor!==Object&&(d=g.get(c.constructor)))v[y]=d(c,l);else if(ArrayBuffer.isView(c))v[y]=i(c);else{const b=a.indexOf(c);b!==-1?v[y]=u[b]:v[y]=l(c)}}return a.pop(),u.pop(),v}}return Co}var br=cr();const Hu=yr(br);Hu();var Du=typeof global=="object"&&global&&global.Object===Object&&global,pr=typeof self=="object"&&self&&self.Object===Object&&self,O=Du||pr||Function("return this")(),E=O.Symbol,Tu=Object.prototype,wr=Tu.hasOwnProperty,jr=Tu.toString,je=E?E.toStringTag:void 0;function mr(i){var e=wr.call(i,je),o=i[je];try{i[je]=void 0;var n=!0}catch{}var a=jr.call(i);return n&&(e?i[je]=o:delete i[je]),a}var fr=Object.prototype,Yr=fr.toString;function kr(i){return Yr.call(i)}var Lr="[object Null]",Zr="[object Undefined]",ha=E?E.toStringTag:void 0;function V(i){return i==null?i===void 0?Zr:Lr:ha&&ha in Object(i)?mr(i):kr(i)}function x(i){return i!=null&&typeof i=="object"}var Sr="[object Symbol]";function ui(i){return typeof i=="symbol"||x(i)&&V(i)==Sr}var Jr=NaN;function la(i){return typeof i=="number"?i:ui(i)?Jr:+i}function M(i,e){for(var o=-1,n=i==null?0:i.length,a=Array(n);++o<n;)a[o]=e(i[o],o,i);return a}var k=Array.isArray,va=E?E.prototype:void 0,ya=va?va.toString:void 0;function gi(i){if(typeof i=="string")return i;if(k(i))return M(i,gi)+"";if(ui(i))return ya?ya.call(i):"";var e=i+"";return e=="0"&&1/i==-1/0?"-0":e}function eo(i,e){return function(o,n){var a;if(o===void 0&&n===void 0)return e;if(o!==void 0&&(a=o),n!==void 0){if(a===void 0)return n;typeof o=="string"||typeof n=="string"?(o=gi(o),n=gi(n)):(o=la(o),n=la(n)),a=i(o,n)}return a}}var Cr=eo(function(i,e){return i+e},0),Xr=/\s/;function Bu(i){for(var e=i.length;e--&&Xr.test(i.charAt(e)););return e}var Hr=/^\s+/;function Qu(i){return i&&i.slice(0,Bu(i)+1).replace(Hr,"")}function G(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var ca=NaN,Dr=/^[-+]0x[0-9a-f]+$/i,Tr=/^0b[01]+$/i,Br=/^0o[0-7]+$/i,Qr=parseInt;function si(i){if(typeof i=="number")return i;if(ui(i))return ca;if(G(i)){var e=typeof i.valueOf=="function"?i.valueOf():i;i=G(e)?e+"":e}if(typeof i!="string")return i===0?i:+i;i=Qu(i);var o=Tr.test(i);return o||Br.test(i)?Qr(i.slice(2),o?2:8):Dr.test(i)?ca:+i}var ba=1/0,Mr=17976931348623157e292;function Ci(i){if(!i)return i===0?i:0;if(i=si(i),i===ba||i===-ba){var e=i<0?-1:1;return e*Mr}return i===i?i:0}function Z(i){var e=Ci(i),o=e%1;return e===e?o?e-o:e:0}var Gr="Expected a function";function Nr(i,e){if(typeof e!="function")throw new TypeError(Gr);return i=Z(i),function(){if(--i<1)return e.apply(this,arguments)}}function oi(i){return i}var Wr="[object AsyncFunction]",xr="[object Function]",Pr="[object GeneratorFunction]",Fr="[object Proxy]";function Xi(i){if(!G(i))return!1;var e=V(i);return e==xr||e==Pr||e==Wr||e==Fr}var Ae=O["__core-js_shared__"],pa=(function(){var i=/[^.]+$/.exec(Ae&&Ae.keys&&Ae.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function Kr(i){return!!pa&&pa in i}var Or=Function.prototype,Ar=Or.toString;function qi(i){if(i!=null){try{return Ar.call(i)}catch{}try{return i+""}catch{}}return""}var Rr=/[\\^$.*+?()[\]{}|]/g,_r=/^\[object .+?Constructor\]$/,zr=Function.prototype,Er=Object.prototype,qr=zr.toString,Ir=Er.hasOwnProperty,Ur=RegExp("^"+qr.call(Ir).replace(Rr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Mu(i){if(!G(i)||Kr(i))return!1;var e=Xi(i)?Ur:_r;return e.test(qi(i))}function $r(i,e){return i?.[e]}function Ii(i,e){var o=$r(i,e);return Mu(o)?o:void 0}var Le=Ii(O,"WeakMap"),Ue=Le&&new Le,Gu=Ue?function(i,e){return Ue.set(i,e),i}:oi,wa=Object.create,de=(function(){function i(){}return function(e){if(!G(e))return{};if(wa)return wa(e);i.prototype=e;var o=new i;return i.prototype=void 0,o}})();function Ze(i){return function(){var e=arguments;switch(e.length){case 0:return new i;case 1:return new i(e[0]);case 2:return new i(e[0],e[1]);case 3:return new i(e[0],e[1],e[2]);case 4:return new i(e[0],e[1],e[2],e[3]);case 5:return new i(e[0],e[1],e[2],e[3],e[4]);case 6:return new i(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new i(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var o=de(i.prototype),n=i.apply(o,e);return G(n)?n:o}}var Vr=1;function is(i,e,o){var n=e&Vr,a=Ze(i);function u(){var g=this&&this!==O&&this instanceof u?a:i;return g.apply(n?o:this,arguments)}return u}function di(i,e,o){switch(o.length){case 0:return i.call(e);case 1:return i.call(e,o[0]);case 2:return i.call(e,o[0],o[1]);case 3:return i.call(e,o[0],o[1],o[2])}return i.apply(e,o)}var es=Math.max;function Nu(i,e,o,n){for(var a=-1,u=i.length,g=o.length,d=-1,r=e.length,s=es(u-g,0),l=Array(r+s),h=!n;++d<r;)l[d]=e[d];for(;++a<g;)(h||a<u)&&(l[o[a]]=i[a]);for(;s--;)l[d++]=i[a++];return l}var os=Math.max;function Wu(i,e,o,n){for(var a=-1,u=i.length,g=-1,d=o.length,r=-1,s=e.length,l=os(u-d,0),h=Array(l+s),v=!n;++a<l;)h[a]=i[a];for(var y=a;++r<s;)h[y+r]=e[r];for(;++g<d;)(v||a<u)&&(h[y+o[g]]=i[a++]);return h}function ns(i,e){for(var o=i.length,n=0;o--;)i[o]===e&&++n;return n}function oo(){}var as=4294967295;function J(i){this.__wrapped__=i,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=as,this.__views__=[]}J.prototype=de(oo.prototype);J.prototype.constructor=J;function gn(){}var dn=Ue?function(i){return Ue.get(i)}:gn,ne={},us=Object.prototype,gs=us.hasOwnProperty;function Re(i){for(var e=i.name+"",o=ne[e],n=gs.call(ne,e)?o.length:0;n--;){var a=o[n],u=a.func;if(u==null||u==i)return a.name}return e}function li(i,e){this.__wrapped__=i,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=void 0}li.prototype=de(oo.prototype);li.prototype.constructor=li;function ei(i,e){var o=-1,n=i.length;for(e||(e=Array(n));++o<n;)e[o]=i[o];return e}function xu(i){if(i instanceof J)return i.clone();var e=new li(i.__wrapped__,i.__chain__);return e.__actions__=ei(i.__actions__),e.__index__=i.__index__,e.__values__=i.__values__,e}var ds=Object.prototype,ts=ds.hasOwnProperty;function t(i){if(x(i)&&!k(i)&&!(i instanceof J)){if(i instanceof li)return i;if(ts.call(i,"__wrapped__"))return xu(i)}return new li(i)}t.prototype=oo.prototype;t.prototype.constructor=t;function Ao(i){var e=Re(i),o=t[e];if(typeof o!="function"||!(e in J.prototype))return!1;if(i===o)return!0;var n=dn(o);return!!n&&i===n[0]}var rs=800,ss=16,hs=Date.now;function Pu(i){var e=0,o=0;return function(){var n=hs(),a=ss-(n-o);if(o=n,a>0){if(++e>=rs)return arguments[0]}else e=0;return i.apply(void 0,arguments)}}var Fu=Pu(Gu),ls=/\{\n\/\* \[wrapped with (.+)\] \*/,vs=/,? & /;function ys(i){var e=i.match(ls);return e?e[1].split(vs):[]}var cs=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;function bs(i,e){var o=e.length;if(!o)return i;var n=o-1;return e[n]=(o>1?"& ":"")+e[n],e=e.join(o>2?", ":" "),i.replace(cs,`{
4
4
  /* [wrapped with `+e+`] */
@@ -27,4 +27,4 @@ ${s}`},jn=(t,e)=>(t.length>0?`
27
27
  `)},Vn=(t,e={})=>{if(e.framesMaxLimit!==void 0&&e.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return Nt(t,e,0)};class oe extends Error{loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:o,message:s,name:i,stack:c,title:a}){super(s,{cause:e}),this.title=a,this.name=i,this.stack=c??this.stack,this.loc=o,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}}class k extends oe{code;context;constructor(e,n,o){super({message:e,name:"CerebroError"}),this.code=n,this.context=o}}const z=t=>"Deno"in t,W=t=>"Bun"in t,ye=()=>{if(z(globalThis)){const t=globalThis.Deno,e=t.execPath();let n=e;try{const{importMeta:o}=globalThis;o?.url&&(n=o.url)}catch{}return[e,n,...t.args]}return W(globalThis)?globalThis.Bun.process.argv:process.argv},Bn=()=>z(globalThis)?globalThis.Deno.cwd():W(globalThis)?globalThis.Bun.process.cwd():process.cwd(),he=()=>{if(z(globalThis)){const t=globalThis.Deno;return new Proxy(t.env.toObject(),{get:(e,n)=>typeof n=="string"?t.env.get(n):e[n],has:(e,n)=>typeof n=="string"?t.env.has(n):n in e,set:(e,n,o)=>typeof n=="string"?(o===void 0||t.env.set(n,o),!0):!1})}return W(globalThis)?globalThis.Bun.process.env:process.env},At=()=>z(globalThis)?[]:W(globalThis)?globalThis.Bun.process.execArgv:process.execArgv,kt=()=>z(globalThis)?globalThis.Deno.execPath():W(globalThis)?globalThis.Bun.process.execPath:process.execPath,Rn=()=>{if(z(globalThis)){const t=globalThis.Deno.build?.os??"unknown";return t==="windows"?"win32":t}return W(globalThis)?globalThis.Bun.platform??"unknown":process.platform},zn=()=>{if(z(globalThis)){const t=globalThis.Deno.build?.arch??"unknown";return t==="x86_64"?"x64":t==="aarch64"?"arm64":t}return W(globalThis)?globalThis.Bun.process.arch:process.arch},R=(t=0)=>{if(z(globalThis))throw globalThis.Deno.exit(t),new Error("Deno exit failed");if(W(globalThis))throw globalThis.Bun.process.exit(t),new Error("Bun exit failed");process.exit(t)},je=(t,e)=>{if(z(globalThis))return()=>{};if(W(globalThis)){try{const o=globalThis.Bun;if(o.process?.on)return o.process.on(t,e),()=>{o.process?.removeListener&&o.process.removeListener(t,e)}}catch{}return()=>{}}const n=process;return n.on(t,e),()=>{n.removeListener(t,e)}},B=new Uint32Array(65536),Wn=(t,e)=>{const n=t.length,o=e.length,s=1<<n-1;let i=-1,c=0,a=n,u=n;for(;u--;)B[t.charCodeAt(u)]|=1<<u;for(u=0;u<o;u++){let r=B[e.charCodeAt(u)];const l=r|c;r|=(r&i)+i^i,c|=~(r|i),i&=r,c&s&&a++,i&s&&a--,c=c<<1|1,i=i<<1|~(l|c),c&=l}for(u=n;u--;)B[t.charCodeAt(u)]=0;return a},Fn=(t,e)=>{const n=e.length,o=t.length,s=[],i=[],c=Math.ceil(n/32),a=Math.ceil(o/32);for(let p=0;p<c;p++)i[p]=-1,s[p]=0;let u=0;for(;u<a-1;u++){let p=0,g=-1;const $=u*32,w=Math.min(32,o)+$;for(let y=$;y<w;y++)B[t.charCodeAt(y)]|=1<<y;for(let y=0;y<n;y++){const b=B[e.charCodeAt(y)],N=i[y/32|0]>>>y&1,E=s[y/32|0]>>>y&1,I=b|p,O=((b|E)&g)+g^g|b|E;let m=p|~(O|g),v=g&O;m>>>31^N&&(i[y/32|0]^=1<<y),v>>>31^E&&(s[y/32|0]^=1<<y),m=m<<1|N,v=v<<1|E,g=v|~(I|m),p=m&I}for(let y=$;y<w;y++)B[t.charCodeAt(y)]=0}let r=0,l=-1;const d=u*32,h=Math.min(32,o-d)+d;for(let p=d;p<h;p++)B[t.charCodeAt(p)]|=1<<p;let f=o;for(let p=0;p<n;p++){const g=B[e.charCodeAt(p)],$=i[p/32|0]>>>p&1,w=s[p/32|0]>>>p&1,y=g|r,b=((g|w)&l)+l^l|g|w;let N=r|~(b|l),E=l&b;f+=N>>>o-1&1,f-=E>>>o-1&1,N>>>31^$&&(i[p/32|0]^=1<<p),E>>>31^w&&(s[p/32|0]^=1<<p),N=N<<1|$,E=E<<1|w,l=E|~(y|N),r=N&y}for(let p=d;p<h;p++)B[t.charCodeAt(p)]=0;return f},qn=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return e.length===0?t.length:t.length<=32?Wn(t,e):Fn(t,e)},Gn=ve(import.meta.url),ae=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Hn=t=>{if(typeof ae<"u"&&ae.versions&&ae.versions.node){const[e,n]=ae.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ae.getBuiltinModule(t)}return Gn(t)},{createRequire:Jn}=Hn("node:module"),Et=String.raw,Ve=Et`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Kn=()=>new RegExp(Et`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${Ve}(?:\u200D${Ve})*`,"gu");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]]));const gs=/^[ \t]*(?:\r\n|\r|\n)/,ws=/(?:\r\n|\r|\n)[ \t]*$/,ys=/^(?:[\r\n]|$)/,vs=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,$s=/^[ \t]*[\r\n][ \t\r\n]*$/,bs=/\r\n|\n|\r/g,xs=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,Ns=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,G=Kn(),Yn=/[-_./\s]+/g,we=/(\u001B\[[0-9;]*[a-z])/i,Be=new RegExp("\\p{Script=Arabic}","u"),Qn=new RegExp("\\p{Script=Bengali}","u"),X=new RegExp("\\p{Script=Cyrillic}","u"),Zn=new RegExp("\\p{Script=Devanagari}","u"),Xn=new RegExp("\\p{Script=Ethiopic}","u"),xe=new RegExp("\\p{Script=Greek}","u"),Re=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),eo=new RegExp("\\p{Script=Gujarati}","u"),to=new RegExp("\\p{Script=Gurmukhi}","u"),ze=new RegExp("\\p{Script=Hangul}","u"),We=new RegExp("\\p{Script=Hebrew}","u"),no=new RegExp("\\p{Script=Hiragana}","u"),Fe=new RegExp("\\p{Script=Han}","u"),oo=new RegExp("\\p{Script=Kannada}","u"),io=new RegExp("\\p{Script=Katakana}","u"),so=new RegExp("\\p{Script=Khmer}","u"),ro=new RegExp("\\p{Script=Lao}","u"),M=new RegExp("\\p{Script=Latin}","u"),ao=new RegExp("\\p{Script=Malayalam}","u"),lo=new RegExp("\\p{Script=Myanmar}","u"),co=new RegExp("\\p{Script=Oriya}","u"),uo=new RegExp("\\p{Script=Sinhala}","u"),ho=new RegExp("\\p{Script=Tamil}","u"),po=new RegExp("\\p{Script=Telugu}","u"),fo=new RegExp("\\p{Script=Thai}","u"),mo=new RegExp("\\p{Script=Tibetan}","u"),qe=/[\u02BB\u02BC\u0027]/u,go=t=>t.replace(G,"");let wo=class{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const o=this.cache.keys().next().value;o!==void 0&&this.cache.delete(o)}this.cache.set(e,n)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}};const yo=Jn(import.meta.url),le=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,vo=t=>{if(typeof le<"u"&&le.versions&&le.versions.node){const[e,n]=le.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return le.getBuiltinModule(t)}return yo(t)},{stripVTControlCharacters:$o}=vo("node:util"),Ne=new wo(1e3),bo=/[.*+?^${}()|[\]\\]/g,xo=t=>{const e=t.join("");if(Ne.has(e)){const s=Ne.get(e);return s.lastIndex=0,s}const n=t.map(s=>s.replaceAll(bo,String.raw`\$&`)).join("|"),o=new RegExp(n,"g");return Ne.set(e,o),o},No=t=>{const e=[];let n=0,o;for(G.lastIndex=0;(o=G.exec(t))!==null;)o.index>n&&e.push(t.slice(n,o.index)),e.push(o[0]),n=G.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},Ao=/[ČŠŽĐ]/i,Ct=new Uint8Array(128),Ot=new Uint8Array(128),_t=new Uint8Array(128);for(let t=0;t<128;t++)Ct[t]=t>=65&&t<=90?1:0,Ot[t]=t>=97&&t<=122?1:0,_t[t]=t>=48&&t<=57?1:0;const Ae=t=>Ct[t],Ge=t=>Ot[t],ke=t=>_t[t],F=(t,e,n,o,s)=>{if(t.length===0)return[];let i=!1;const c=Object.values(e);for(const f of c)if(f(t[0])){i=!0;break}if(!i&&!n)return[t];const a=[...t],u=[];let r=a[0],l="other";const d=Object.entries(e);for(const f of d){const[p,g]=f;if(g(a[0])){l=p;break}}let h=n&&o?a[0]===a[0].toLocaleUpperCase(o):!1;for(let f=1;f<a.length;f++){const p=a[f];let g="other";for(const y of d){const[b,N]=y;if(N(p)){g=b;break}}const $=n&&o?p===p.toLocaleUpperCase(o):!1;let w=!1;s?w=s(l,g,h,$,p,f,a):(l!==g&&l!=="other"&&g!=="other"&&(w=!0),n&&g!=="other"&&!h&&$&&(w=!0)),w?(u.push(r),r=p):r+=p,l=g,n&&(h=$)}return r&&r.length>0&&u.push(r),u.length>0?u:[t]},ko=(t,e,n,o)=>{if(n.size===0)return e;for(const s of n)if(t.startsWith(s,e))return o.push(s),e+s.length;return e},It=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const o=[],s=t.length;for(let i=1;i<s;i++){const c=ko(t,n,e,o);if(c!==n){n=c,i=n-1;continue}const a=t.codePointAt(i-1),u=t.codePointAt(i),r=a&&a<128&&Ae(a),l=u&&u<128&&Ae(u),d=a&&a<128&&Ge(a),h=a&&a<128&&ke(a),f=u&&u<128&&ke(u);if(d&&l){o.push(t.slice(n,i)),n=i;continue}if(h&&!f||!h&&f){o.push(t.slice(n,i)),n=i;continue}if(f&&!h){let p=!1,g=!1;if(i+1<s){const $=t.codePointAt(i+1);p=$&&$<128&&Ae($),g=$&&$<128&&ke($)}if(!g&&p){o.push(t.slice(n,i),t.slice(i,i+1)),n=i+1;continue}}if(i+1<s){const p=t.codePointAt(i+1),g=p&&p<128&&Ge(p);if(r&&l&&g){const $=t.slice(n,i+1);e.has($)||(o.push(t.slice(n,i)),n=i)}}}return n<s&&o.push(t.slice(n)),o.filter(i=>i!=="")},Lt=(t,e,n)=>{if(t.length===0)return[];const o=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!o&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const r=[...t],l=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e),p=f,g=f?0:-1;for(let $=1;$<l;$++){const w=r[$],y=w===w.toLocaleUpperCase(e);if(y===f)h+=w;else if(y)h&&h.length>0&&(d.push(h),h=w),p=!0,g=$;else{if(p&&$-g>1){const b=r[$-1],N=h.slice(0,-1);N&&N.length>0&&d.push(N),h=b+w}else h+=w;p=!1,g=-1}f=y}return h&&h.length>0&&d.push(h),d}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!X.test(t)&&!M.test(t))return[t];const r=[...t],l=r.length,d=[];let h=r[0];const f=r[0];let p;X.test(f)?p=1:M.test(f)?p=2:p=0;let g=f===f.toLocaleUpperCase(e);for(let w=1;w<l;w++){const y=r[w];let b;X.test(y)?b=1:M.test(y)?b=2:b=0;const N=y===y.toLocaleUpperCase(e);p!==b&&(p===1||p===2)&&(b===1||b===2)||b===p&&!g&&N?(d.push(h),h=y):h+=y,p=b,g=N}h&&h.length>0&&d.push(h);const $=[];for(let w=0;w<d.length;w++)w<d.length-1&&d[w].length===1&&M.test(d[w])&&X.test(d[w+1][0])?($.push(d[w]+d[w+1]),w+=1):$.push(d[w]);return $}if(e.startsWith("el")){if(!xe.test(t)&&!M.test(t))return[t];const r=[];Re.lastIndex=0;let l;for(;(l=Re.exec(t))!==null;)r.push(l[0]);r.length===0&&r.push(t);const d=[];if(r.length===1){const h=r[0];if(!h||!xe.test(h[0])||h.length===1)return[h??t]}for(const h of r){if(!h)continue;if(!xe.test(h[0])||h.length===1){d.push(h);continue}const f=h.length;let p=h[0],g=h[0]===h[0].toLocaleUpperCase(e);for(let $=1;$<f;$++){const w=h[$],y=w===w.toLocaleUpperCase(e);!g&&y?(d.push(p),p=w):p+=w,g=y}p&&d.push(p)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),l=r?{hiragana:h=>no.test(h),kanji:h=>Fe.test(h),katakana:h=>io.test(h),latin:h=>M.test(h)}:{hangul:h=>ze.test(h),latin:h=>M.test(h)},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const h=F(t,l,!1,e,(p,g)=>p==="hiragana"&&g==="katakana"||p==="katakana"&&g==="hiragana"||p==="hiragana"&&g==="latin"||p==="katakana"&&g==="latin"||p==="kanji"&&g==="latin"||p==="latin"&&(g==="hiragana"||g==="katakana"||g==="kanji")),f=[];for(const p of h){const g=p;g.length===1&&d.has(g)&&f.length>0?f[f.length-1]=f.at(-1)+g:f.push(g)}return f.length>0?f:[t]}return F(t,l,!1,e,(h,f)=>h==="hangul"&&f==="latin"||h==="latin"&&f==="hangul")}if(e.startsWith("sl")){const r=[...t],l=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let p=1;p<l;p++){const g=r[p],$=g===g.toLocaleUpperCase(e),w=Ao.test(g),y=p<l-1&&r[p+1]===r[p+1].toLocaleUpperCase(e);!f&&$||w&&y?(d.push(h),h=g,w&&y&&(d.push(h),h="")):h+=g,f=$}return h&&h.length>0&&d.push(h),d}if(e.startsWith("zh"))return F(t,{han:r=>Fe.test(r),latin:r=>M.test(r)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=l=>We.test(l)||Be.test(l);return F(t,{latin:l=>M.test(l),rtl:l=>r(l)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const r=l=>Zn.test(l)||Qn.test(l)||eo.test(l)||to.test(l)||oo.test(l)||ho.test(l)||po.test(l)||ao.test(l)||uo.test(l)||fo.test(l)||ro.test(l)||mo.test(l)||lo.test(l)||Xn.test(l)||so.test(l)||co.test(l);return F(t,{indic:l=>r(l),latin:l=>M.test(l)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return F(t,{cyrillic:r=>X.test(r),latin:r=>M.test(r)},!0,e);if(["ar","fa","he"].includes(e))return F(t,{latin:r=>M.test(r),rtl:r=>We.test(r)||Be.test(r)},!1,e);if(e.startsWith("ko"))return F(t,{hangul:r=>ze.test(r),latin:r=>M.test(r)},!1,e);if(e.startsWith("uz")){if(!X.test(t)&&!M.test(t))return[t];const r=[...t],l=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let p=1;p<l;p++){const g=r[p],$=g===g.toLocaleUpperCase(e);if(qe.test(g)||qe.test(r[p-1])){h+=g;continue}!f&&$?(d.push(h),h=g):h+=g,f=$}return h&&h.length>0&&d.push(h),d}const s=[...t],i=s.length,c=[];let a=s[0],u=s[0]===s[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){c.push(r),a=s[r.length],u=a===a.toLocaleUpperCase(e);break}for(let r=1;r<i;r++){const l=s[r],d=l===l.toLocaleUpperCase(e);let h=0;for(const f of n)if(t.startsWith(f,r)){c.push(a,f),h=f.length,a="";const p=f.at(-1);p&&(u=p===p.toLocaleUpperCase(e));break}if(h>0){r+=h-1;continue}!u&&d?(c.push(a),a=l):a+=l,u=d}return a&&c.push(a),c},Eo=(t,e,n)=>{const o=[],s=we.test(t)?t.split(we).filter(Boolean):[t];for(const i of s){const c=i;if(we.test(c))o.push(c);else{G.lastIndex=0;const a=G.test(c)?No(c).filter(Boolean):[c];for(const u of a)if(G.lastIndex=0,G.test(u))o.push(u);else if(e){const r=e.toLowerCase().split("-")[0];o.push(...Lt(u,r,n))}else o.push(...It(u,n))}}return o},Co=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:o=!1,knownAcronyms:s=[],locale:i,normalize:c=!1,separators:a,stripAnsi:u=!1,stripEmoji:r=!1}=e,l=new Set([...s].toSorted((w,y)=>y.length-w.length));let d=t;u&&(d=$o(d)),r&&(d=go(d));let h;Array.isArray(a)?h=xo(a):a instanceof RegExp?h=a:h=Yn;const f=[];let p=d;const g=h.flags.includes("g")?h:new RegExp(h.source,`${h.flags}g`);for(;p.length>0;){const w=g.exec(p);if(!w){p===".."?f.push(".."):p==="."?f.push("."):p.length>0&&f.push(p);break}const y=w.index,b=w[0],N=b.length,E=p.slice(0,y),I=p.slice(y+N);if(b.startsWith("../"))f.push(".."),p=p.slice(y+3);else if(b.startsWith("./"))f.push("."),p=p.slice(y+2);else if(y===0&&b==="..")f.push(".."),p=p.slice(2);else if(y===0&&b===".")f.push("."),p=p.slice(1);else{E.length>0&&f.push(E);let O=0;for(;(O=b.indexOf("../",O))!==-1;)f.push(".."),O+=3;for(O=0;(O=b.indexOf("./",O))!==-1;)(O===0||b[O-1]!==".")&&f.push("."),O+=2;let m=I;for(;m.startsWith("../");)f.push(".."),m=m.slice(3);for(;m.startsWith("./");)f.push("."),m=m.slice(2);if(m===".."){f.push("..");break}else if(m==="."){f.push(".");break}else p=m}g.lastIndex=0}if(f.length===0){const w=d.split(h).filter(Boolean);f.push(...w)}let $=[];for(const w of f)n||o?$.push(...Eo(w,i,l)):i?$.push(...Lt(w,i,l)):$.push(...It(w,l));return c&&($=$.map(w=>l.has(w)?w:i&&w===w.toLocaleUpperCase(i)?w[0]+w.slice(1).toLocaleLowerCase(i):w.toUpperCase()===w&&!l.has(w)?w.slice(0,1)+w.slice(1).toLowerCase():w)),$},Oo=ve(import.meta.url),ce=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_o=t=>{if(typeof ce<"u"&&ce.versions&&ce.versions.node){const[e,n]=ce.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ce.getBuiltinModule(t)}return Oo(t)},{writeFile:Io,stat:Lo,rm:So,readFile:He,readdir:To,mkdir:Mo,access:Po}=_o("node:fs/promises"),de=[{alias:"v",description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];let H=class extends k{commandName;constructor(t,e=[]){const n=`Command "${t}" not found${e.length>0?`. Did you mean: ${e.join(", ")}?`:""}`;super(n,"COMMAND_NOT_FOUND",{commandName:t,suggestions:e}),this.name="CommandNotFoundError",this.commandName=t,e.length>0&&(this.hint=`Try one of these commands: ${e.join(", ")}`)}},St=class extends k{option1;option2;constructor(t,e){super(`Options "${t}" and "${e}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:t,option2:e}),this.name="ConflictingOptionsError",this.option1=t,this.option2=e,this.hint=`Remove either --${t} or --${e}`}},Do=class extends k{unknownOptions;constructor(t,e){const n=t.join(", "),o=`Found unknown ${t.length===1?"option":"options"}: ${n}`;super(o,"UNKNOWN_OPTION",{suggestions:e,unknownOptions:t}),this.name="UnknownOptionError",this.unknownOptions=t,e&&e.length>0&&(this.hint=`Did you mean: ${e.join(", ")}?`)}},Uo=class extends k{pluginName;constructor(t,e,n){super(`Plugin "${t}" error: ${e}`,"PLUGIN_ERROR",{originalError:n,pluginName:t}),this.name="PluginError",this.pluginName=t,n&&(this.cause=n)}},jo=class{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(t){this.logger=t}hasPlugins(){return this.plugins.size>0}register(t){if(this.initialized)throw new Error(`Cannot register plugin "${t.name}" after initialization`);if(this.plugins.has(t.name))throw new Error(`Plugin "${t.name}" is already registered`);he().CEREBRO_OUTPUT_LEVEL===String(V)&&this.logger.debug(`registering plugin: ${t.name}`),this.plugins.set(t.name,t),this.cachedDependencyOrder=void 0}async init(t){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const e=this.getDependencyOrder();this.logger.debug(`initializing ${String(e.length)} plugin(s)...`);for(const n of e)if(typeof n.init=="function"){this.logger.debug(`initializing plugin: ${n.name}`);try{await n.init(t)}catch(o){const s=new Uo(n.name,`Failed to initialize: ${o instanceof Error?o.message:String(o)}`,o instanceof Error?o:void 0);throw this.logger.error(s.message),s}}this.initialized=!0}async executeLifecycle(t,e,n){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const o=this.getDependencyOrder();for(const s of o){const i=s[t];if(typeof i=="function"){this.logger.debug(`executing ${t} hook for plugin: ${s.name}`);try{await(t==="afterCommand"?i(e,n):i(e))}catch(c){throw this.logger.error(`Error in ${t} hook for plugin "${s.name}":`,c),c}}}}async executeErrorHandlers(t,e){if(!this.initialized||this.plugins.size===0)return;const n=this.getDependencyOrder();for(const o of n)if(typeof o.onError=="function"){this.logger.debug(`executing error handler for plugin: ${o.name}`);try{await o.onError(t,e)}catch(s){this.logger.error(`Error in error handler for plugin "${o.name}":`,s)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const t=[],e=new Set,n=new Set,o=s=>{if(e.has(s))return;if(n.has(s))throw new Error(`Circular dependency detected involving plugin "${s}"`);const i=this.plugins.get(s);if(!i)throw new Error(`Plugin "${s}" not found`);if(n.add(s),i.dependencies)for(const c of i.dependencies)o(c);n.delete(s),e.add(s),t.push(i)};for(const s of this.plugins.keys())o(s);return this.cachedDependencyOrder=t,t}validateDependencies(){for(const t of this.plugins.values())if(t.dependencies){for(const e of t.dependencies)if(!this.plugins.has(e))throw new Error(`Plugin "${t.name}" depends on "${e}" which is not registered`)}}};const pe=t=>t.type?.name==="Boolean",Vo=t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},Je=t=>(pe(t)||(t.typeLabel=t.typeLabel??Vo(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),Bo=new RegExp(/^-([^\d-])$/),Ro=new RegExp(/^--(\S+)/),zo=new RegExp(/^-([^\d-]{2,})$/),Wo=t=>Bo.test(t)||Ro.test(t)||zo.test(t),Fo=(t,e)=>{const n=e[0]&&Wo(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const o=new Error(`Command not recognised: ${String(n)}`);throw o.command=n,o.name="INVALID_COMMAND",o}return{argv:e,command:n}};class Te extends oe{optionName;value;constructor(e,n,o){super({hint:`Pass a valid ${o} value for '${e}'.`,message:`Invalid ${o} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,Te.prototype)}}let qo=class Tt extends oe{optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,Tt.prototype)}},Ke=class Mt extends oe{optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,Mt.prototype)}},Go=class Pt extends oe{value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,Pt.prototype)}};class S extends oe{constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,S.prototype)}}const Ye=(t,e,n)=>{const o=Number(t);if(e&&Number.isNaN(o)&&String(t).trim().toLowerCase()!=="nan")throw new Te(n??"",String(t),"Number");return o},Qe=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",Ze=t=>t===Number||typeof t=="function"&&t.name==="Number",Xe=t=>t===String||typeof t=="function"&&t.name==="String",Ho=(t,e,n={})=>{const{optionName:o,strictTypes:s}=n;return Array.isArray(t)?Qe(e)?t.map(Boolean):Ze(e)?t.map(i=>Ye(i,s,o)):Xe(e)?t.map(String):t.map(i=>e(String(i))):t===null?null:Qe(e)?!!t:Ze(e)?Ye(t,s,o):Xe(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},_=(t,e,n,...o)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...o)},Jo=/-([a-z])/g,Ko=/^\d+$/,fe=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",Yo=t=>t.codePointAt(0)===95,et=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],tt=t=>t==="__proto__"||t==="constructor"||t==="prototype",nt=(t,e,n,o=!1)=>{t[e]===void 0?t[e]=o?[n]:n:o&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},ot=(t,e,n,o,s)=>{let i=e.get(t)??n.get(t);if(!i&&o){const c=t.toLowerCase();i=o.get(c)??s?.get(c)}return i},Qo=(t,e,n,o)=>{const s=n.debug??!1;_(s,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),_(s,"Starting argument resolution","resolver"),_(s,"Tokens:","resolver",t),_(s,"Definitions:","resolver",e),_(s,"Processing tokens...","resolver");const i=new Map,c=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,l=n.camelCase?new Map:void 0;for(const m of e)if(i.set(m.name,m),m.alias&&c.set(m.alias,m),n.caseInsensitive&&a&&(a.set(m.name.toLowerCase(),m),m.alias&&u&&u.set(m.alias.toLowerCase(),m)),n.camelCase&&r&&l){const v=m.name.replaceAll(Jo,(x,L)=>L.toUpperCase());r.set(m.name,v),l.set(v,m.name)}const d=Object.create(null),h=Object.create(null),f=[],p=[],g=new Set;let $=!1;const w=e.find(m=>m.defaultOption),y=e.some(m=>m.group),b=e.find(m=>m.type===Number);for(let m=0;m<t.length;m++){const v=t[m];if(v.kind==="option-terminator"){d._unknown=o.slice(v.index),$=!0;break}if(v.kind==="option"&&v.name){let x=ot(v.name,i,c,a,u);!x&&v.value===void 0&&b&&Ko.test(v.name)&&(x=b,v.value=v.name,v.name=b.name);let L=!1;if(!x&&n.negation&&v.value===void 0&&v.name.startsWith("no-")){const C=v.name.slice(3),P=ot(C,i,c,a,u);P?.type&&fe(P.type)&&(x=P,L=!0)}const A=x?x.name:v.name,T=x?.multiple,D=x?.lazyMultiple;if(Object.hasOwn(h,A)&&h[A]!==void 0&&!T&&!D&&!n.partial)throw new qo(A);if(!x&&n.partial){const C=v.rawName??`--${v.name}${v.value!==void 0&&v.inlineValue?`=${v.value}`:""}`;f.push({index:v.index,value:C});continue}if(!x&&n.stopAtFirstUnknown){d._unknown=o.slice(v.index);break}if(!x&&!n.partial)throw new Ke(v.name);if(v.value===void 0){const C=t[m+1],P=C?.kind==="option"&&!("name"in C)&&C.value!==void 0,U=C&&x&&!(x.type&&fe(x.type))&&(C.kind==="positional"||P),Rt=x&&x.defaultOption&&!x.multiple&&!x.lazyMultiple;if(U&&(!x?.defaultOption||Rt))if(T){let j=m+1;const $e=[];for(;j<t.length&&(t[j].kind==="positional"||t[j].kind==="option"&&!("name"in t[j])&&t[j].value!==void 0);)$e.push(t[j].value),g.add(t[j].index),j++;h[A]=h[A]===void 0?$e:et(h[A],$e),m=j-1}else D?(nt(h,A,C.value,!0),g.add(C.index),m++):(h[A]=C.value,g.add(C.index),m++);else x?.type&&fe(x.type)?nt(h,A,!L,T):h[A]=T?[]:null}else{let{value:C}=v;if(x?.type&&fe(x.type))switch(C){case"":{if(n.partial){h._unknown??=[];const U=`${v.rawName??`--${v.name}`}${v.value?`=${v.value}`:""}`;h._unknown.push(U),p.push({index:v.index,value:U}),C=!0}else throw new Ke(v.name);break}case"false":{C=!1;break}case"true":{C=!0;break}default:C=!0}const P=[C];if(T){let U=m+1;for(;U<t.length&&t[U].kind==="positional";)P.push(t[U].value),g.add(t[U].index),U++;m=U-1}h[A]===void 0?h[A]=T||D?P:C:T||D?h[A]=et(h[A],P):h[A]=C}}else if(v.kind==="positional"&&n.stopAtFirstUnknown&&!g.has(v.index)&&!w){_(s,`Found unconsumed positional token at index ${String(v.index)}, stopping processing`,"resolver"),d._unknown=o.slice(v.index);break}}for(const[m,v]of Object.entries(h)){const x=i.get(m);x&&(x.multiple||x.lazyMultiple)&&!Array.isArray(v)&&(h[m]=[v])}const N=m=>m.kind==="option"&&!i.has(m.name??"")&&!c.has(m.name??"")&&(!n.caseInsensitive||!a?.has(m.name?.toLowerCase()??"")&&!u?.has(m.name?.toLowerCase()??""));let E=-1,I=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!$&&(E=t.findIndex(m=>N(m)),E!==-1&&(I=t[E].index)),w){const m=[],v=[];for(const x of t)x.kind==="positional"&&!g.has(x.index)&&x.index<I&&(m.push(x.value),v.push(x));if(m.length>0){const x=h[w.name],L=w.multiple??w.lazyMultiple;x===void 0?L?(v.forEach(A=>g.add(A.index)),h[w.name]=m):(g.add(v[0].index),h[w.name]=m[0]):L&&(v.forEach(A=>g.add(A.index)),h[w.name]=Array.isArray(x)?[...m,...x]:[...m,x])}}if(!n.partial){for(const m of t)if(m.kind==="positional"&&!g.has(m.index))throw new Go(o[m.index])}if(n.partial&&!n.stopAtFirstUnknown){const m=[...f];if(h._unknown)for(const v of p)m.push({index:v.index,value:v.value});for(const v of t)v.kind==="positional"&&!g.has(v.index)&&m.push({index:v.index,value:o[v.index]});m.length>0&&(m.sort((v,x)=>v.index-x.index),d._unknown=m.map(v=>v.value))}if(n.stopAtFirstUnknown&&!$){const m=t.findIndex(x=>x.kind==="positional"&&!g.has(x.index));let v=-1;if(E!==-1&&m!==-1?v=Math.min(E,m):E!==-1?v=E:m!==-1&&(v=m),v>=0){const x=t[v].index;d._unknown=o.slice(x)}}else f.length>0&&!n.partial&&(d._unknown=f.map(m=>m.value));for(const[m,v]of Object.entries(h)){const x=n.camelCase?r?.get(m)??m:m,L=i.get(m);L?.type?d[x]=Ho(v,L.type,{optionName:L.name,strictTypes:n.strictTypes}):d[x]=v===void 0?null:v}for(const m of e){const v=n.camelCase?r?.get(m.name)??m.name:m.name;!(v in d)&&m.defaultValue!==void 0&&(m.multiple??m.lazyMultiple?d[v]=Array.isArray(m.defaultValue)?[...m.defaultValue]:[m.defaultValue]:d[v]=m.defaultValue)}if(y){const m={},v={},x={};for(const A of e)if(A.group){const T=Array.isArray(A.group)?A.group:[A.group];for(const D of T)tt(D)||(m[D]??={})}for(const A of Object.keys(d))if(!Yo(A)){v[A]=d[A];let T=A;n.camelCase&&(T=l?.get(A)??A);const D=i.get(T);if(D?.group){const C=Array.isArray(D.group)?D.group:[D.group];for(const P of C)tt(P)||m[P]&&(m[P][A]=d[A])}else x[A]=d[A]}const L={_all:v};for(const[A,T]of Object.entries(m))L[A]=T;Object.keys(x).length>0&&(L._none=x),d._unknown&&(L._unknown=d._unknown),Object.keys(d).forEach(A=>delete d[A]),Object.assign(d,L)}const O=Object.defineProperties({},Object.getOwnPropertyDescriptors(d));return _(s,"Final parsed result:","resolver",O),O},ne="-".codePointAt(0),K="=",Zo=K.codePointAt(0),Xo="--",ei="-",ti="--",Dt=t=>t.length>2&&t.startsWith(ti),ni=t=>Dt(t)&&!t.includes(K,3),oi=t=>Dt(t)&&t.includes(K,3),ii=t=>{if(t.length!==2||t.codePointAt(0)!==ne||t.codePointAt(1)===ne)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},si=t=>!(t.length<=2||t.codePointAt(0)!==ne||t.codePointAt(1)===ne),ri=t=>{const e=[];let n=0,o=[],s=0,i=-1,c=0;for(;s<o.length||n<t.length;){let a;if(s<o.length?(a=o[s],s++):(a=t[n],n++),c>0?c--:i++,a===Xo){e.push({index:i,kind:"option-terminator"});const u=[...o.slice(s),...t.slice(n)],r=u.map((l,d)=>({index:i+d+1,kind:"positional",value:l}));e.push(...r),i+=u.length;break}if(ii(a)){const u=a.charAt(1);e.push({index:i,kind:"option",name:u,rawName:a});continue}if(si(a)&&!a.includes(K)){const u=[];let r="",l=!1;for(let d=1;d<a.length;d++){const h=a.charAt(d);l?r+=h:h.codePointAt(0)===Zo?l=!0:u.push(`${ei}${h}`)}if(l)if(u.length>0){const d=u.pop();u.push(`${d}=${r}`)}else u.push(r);o=s<o.length?[...u,...o.slice(s)]:u,s=0,c=u.length;continue}if(ni(a)){const u=a.slice(2);e.push({index:i,kind:"option",name:u,rawName:a});continue}if(oi(a)){const u=a.indexOf(K),r=a.slice(2,u),l=a.slice(u+1);e.push({index:i,inlineValue:!0,kind:"option",name:r,rawName:a,value:l});continue}if(a.length>2&&a.codePointAt(0)===ne&&a.codePointAt(1)!==ne&&a.includes(K)){const u=a.indexOf(K),r=a.charAt(1),l=a.slice(u+1);e.push({index:i,inlineValue:!0,kind:"option",name:r,rawName:a,value:l});continue}e.push({index:i,kind:"positional",value:a})}return e},ai=/\d/,li=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",ci=t=>typeof t=="function",ui=(t,e,n)=>{const o=n?.debug??!1;_(o,"Validating definitions:","validation",t,"caseInsensitive:",e);const s=new Set,i=new Set,c=new Set,a=new Set;let u=0;for(const r of t){if(_(o,"Checking definition:","validation",r),!r.name)throw _(o,"Validation failed: name is required","validation"),new S("Invalid option definition: name is required");if(typeof r.name!="string")throw new S("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new S("Invalid option definition: name cannot be empty");const l=e?r.name.toLowerCase():"";if(s.has(r.name)||e&&c.has(l))throw new S(`Invalid option definition: duplicate name '${r.name}'`);if(i.has(r.name)||e&&a.has(l))throw new S(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(s.add(r.name),e&&c.add(l),r.alias!==void 0){if(typeof r.alias!="string")throw new S("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new S("Invalid option definition: alias must be a single character");if(ai.test(r.alias))throw new S("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new S('Invalid option definition: alias cannot be "-"');const d=e?r.alias.toLowerCase():"";if(i.has(r.alias)||e&&a.has(d))throw new S(`Invalid option definition: duplicate alias '${r.alias}'`);if(s.has(r.alias)||e&&c.has(d))throw new S(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);i.add(r.alias),e&&a.add(d)}if(r.defaultOption&&(u++,r.type!==void 0&&li(r.type)))throw new S("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&ci(r.type)))throw new S("Invalid option definition: invalid type")}if(u>1)throw _(o,"Validation failed: multiple defaultOptions not allowed","validation"),new S("Invalid option definition: multiple defaultOptions not allowed");_(o,"Validation completed successfully","validation")};function hi(t,e={}){const n=e.debug??!1;_(n,"Starting command-line-args parsing","index"),_(n,"Options:","index",e);const o={...e};o.stopAtFirstUnknown&&(o.partial=!0);const s=Array.isArray(t)?t:[t];_(n,"Normalized definitions:","index",s),ui(s,o.caseInsensitive,n?o:void 0);let{argv:i}=o;if(!i&&(i=process.argv.slice(2),process.execArgv.length>0)){const r=new Set(process.execArgv);i=i.filter(l=>!r.has(l))}_(n,"Using argv:","index",i);let c=i;o.caseInsensitive&&(c=i.map(r=>{if(r.startsWith("--")){const l=r.indexOf("="),d=(l===-1?r.slice(2):r.slice(2,l)).toLowerCase();return l===-1?`--${d}`:`--${d}${r.slice(l)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const l=r.slice(1).split("=",2),d=l[0],h=l[1];if(!d)return r;const f=d.toLowerCase();return h===void 0?`-${f}`:`-${f}=${h}`}return r}));const a=ri(c.map(String));_(n,"Tokenized arguments:","index",a);const u=Qo(a,s,o,i);return _(n,"Command-line-args parsing completed","index"),u}class pi{result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let Ee=class extends k{commandName;constructor(t,e,n){super(`Failed to load command "${t}": ${e}`,"COMMAND_LOADER_ERROR",{commandName:t,reason:e}),this.name="CommandLoaderError",this.commandName=t,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",n!==void 0&&(this.cause=n)}};const di=/^-{1,2}(\w+)(=(.+))?$/,Ut=(t,e,n,o)=>{const s=di.exec(t);if(s===null)return{};const i=s[1];if(!i)return{};const c=n&&o?n.get(i)??o.get(i):e.find(a=>a.name===i||a.alias===i);return c!==void 0?{argName:c.name,argValue:s[3],option:c}:{}},it=(t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},fi=new Set(["0","1","false","true"]),mi=(t,e,n,o)=>{if(e.length===0||t.length===0)return{};const s=(i,c)=>{const{argName:a,argValue:u,option:r}=Ut(c,e,n,o),{lastOption:l}=i;return r&&pe(r)&&u&&a?i.partial[a]=it(u,r):i.lastName&&l&&pe(l)&&fi.has(c)&&(i.partial[i.lastName]=it(c,l)),{lastName:a,lastOption:r,partial:i.partial}};return t.reduce(s,{partial:{}}).partial},gi=new Set(["0","1","false","true"]),wi=(t,e,n,o)=>{if(e.length===0||t.length===0)return t;const s=(i,c)=>{const{argValue:a,option:u}=Ut(c,e,n,o),{lastOption:r}=i;if(r&&pe(r)&&gi.has(c)){const{args:l}=i;return{args:l.slice(0,-1)}}return u&&pe(u)&&a?{args:i.args}:{args:[...i.args,c],lastOption:u}};return t.reduce(s,{args:[]}).args},yi=t=>{const e=new Map;for(const n of t){const o=e.get(n.name);o?e.set(n.name,{...o,...n}):e.set(n.name,n)}return[...e.values()]},vi=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},$i=(t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return vi(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const n=Number.parseFloat(e);return Number.isNaN(n)?void 0:n}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)}},bi=/_./g,xi=/^[A-Z]/,Ni=t=>t.toLowerCase().replaceAll(bi,e=>e[1]?.toUpperCase()??e).replace(xi,e=>e.toLowerCase()),Ai=t=>{if(!t||t.length===0)return{};const e={},n=he();for(const o of t){const s=n[o.name],i=$i(o,s),c=i===void 0?o.defaultValue:i,a=Ni(o.name);e[a]=c}return e},ki=t=>{const e=new Map,n=new Map;for(const o of t)if(e.set(o.name,o),o.alias){const s=Array.isArray(o.alias)?o.alias:[o.alias];for(const i of s)n.set(i,o)}return{optionMapByAlias:n,optionMapByName:e}},jt=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new Ee(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(o){throw new Ee(t.name,o instanceof Error?o.message:String(o),o)}const n=e.default;if(typeof n!="function")throw new Ee(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},Ei=(t,e,n,o)=>{const s=new pi(t.name,t),{_all:i,_unknown:c,positionals:a}=e,u=Object.keys(n).length>0?{...i,...n}:i;ge in u&&delete u[ge],s.argument=a?.[ge]??[],s.rawUnknown=[...c??[]];const r=Object.keys(o).length>0;return s.options=r?{...u,...o}:u,s.env=Ai(t.env),s},Ci=(t,e,n)=>{const o=t.options??[],s=o.length>0;let i=yi(s?[...o,...n]:n);if(i.length>0){for(const r of i)if(r.multiple&&r.lazyMultiple)throw new Error(`Argument "${r.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(i=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:ge,type:t.argument.type,typeLabel:t.argument.typeLabel},...i]);let c,a;if(s){const{optionMapByAlias:r,optionMapByName:l}=ki(o);c=wi(e,o,l,r),a=mi(e,o,l,r)}else c=e,a={};const u=hi(i,{argv:c,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:i,booleanValues:a,parsedArgs:u}},ee=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await jt(t))(e);let Oi=class extends k{commandName;missingOptions;constructor(t,e){super(`Command "${t}" is missing required options: ${e.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:t,missingOptions:e}),this.name="CommandValidationError",this.commandName=t,this.missingOptions=e,this.hint=`Provide the following required options: ${e.join(", ")}`}},_i=class extends k{choices;option;value;constructor(t,e,n){super(`Invalid value "${e}" for option "${t}". Allowed values: ${n.join(", ")}`,"INVALID_CHOICE",{choices:n,option:t,value:e}),this.name="InvalidChoiceError",this.option=t,this.value=e,this.choices=n,this.hint=`Use one of: ${n.map(o=>`--${t} ${o}`).join(", ")}`}};const st=(t,e,n=!1)=>{const o=[];for(const s of t)if(!(!n&&!s.required)&&e[s.name]===void 0){if(s.type?.name==="Boolean"){e[s.name]=!1;continue}o.push(s)}return o},Ii=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:qn(t,e)<=t.length/3,q=(t,e)=>{const n=t.toLowerCase();return e.filter(o=>Ii(o.toLowerCase(),n))},Li=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(o=>{const s=o.startsWith("--");let i=`Found unknown ${s?"option":"argument"} "${o}"`;if(s){const c=q(o.replace("--",""),(e.options??[]).map(a=>a.name));if(c.length>0){const[a,...u]=c.map(r=>`--${r}`);i+=u.length>0?`, did you mean ${a??""} or ${u.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(i)}),n.length>0)throw new Error(n.join(`
28
28
  `))},Si=(t,e,n)=>{const o=n.__requiredOptions__,s=o?st(o,e,!0):st(t,e,!1);if(s.length>0)throw new Oi(n.name,s.map(i=>i.name));e._unknown&&e._unknown.length>0&&!n.argument&&Li(e,n)},Ti=(t,e,n)=>{const o=n.__conflictingOptions__??t.filter(s=>s.conflicts!==void 0);if(o.length>0){const s=o.find(i=>Array.isArray(i.conflicts)?i.conflicts.some(c=>e[c]!==void 0)&&e[i.name]!==void 0:e[i.conflicts]!==void 0&&e[i.name]!==void 0);if(s)throw new St(s.name,typeof s.conflicts=="string"?s.conflicts:s.conflicts?.[0]??"unknown")}},Mi=(t,e)=>{const n=e.options;if(n)for(const o of n){if(!o.choices||o.choices.length===0)continue;const s=t[o.name];if(s==null)continue;const i=Array.isArray(s)?s:[s];for(const c of i){const a=String(c);if(!o.choices.includes(a))throw new _i(o.name,a,o.choices)}}},Pi=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const s of t.options){if(s.name){const i=e.get(s.name)??[];i.push(s),e.set(s.name,i)}if(typeof s.alias=="string"&&s.alias.length>0){const i=n.get(s.alias)??[];i.push(s),n.set(s.alias,i)}else if(Array.isArray(s.alias)){for(const i of s.alias)if(i.length>0){const c=n.get(i)??[];c.push(s),n.set(i,c)}}}const o=[];for(const[s,i]of e)i.length>1&&o.push(`Duplicate option name "${s}" in command "${t.name}": ${JSON.stringify(i)}`);for(const[s,i]of n)i.length>1&&o.push(`Duplicate option alias "-${s}" used by options ${i.map(c=>`"${c.name}"`).join(", ")} in command "${t.name}"`);if(o.length>0)throw new Error(o.join(`
29
29
  `))},Di=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let o;for(let s=1;s<=e.length;s+=1){const i=e[s-1];if(i===void 0||i.startsWith("-"))break;n.push(i);const c=n.join(" ");t.has(c)&&(o={commandPath:[...n],depth:s})}return o?{argv:e.slice(o.depth),commandPath:o.commandPath}:{argv:e,commandPath:void 0}},J=t=>t.join(" "),rt=(t,e)=>e&&e.length>0?[...e,t]:[t],Ui=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),ji=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),Vi=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const o=[];let s="",i="";for(let c=0;c<n;c++){const a=t[c];if(we.test(a)){s?(o.push(s+i+a),s="",i=""):(o.length>0&&o.push(e),s=a);continue}s?(i&&(i+=e),i+=a):(o.length>0&&o.push(e),o.push(a))}return o.join("")},Vt=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return Vi(Co(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(o=>{const s=o,i=s.toLowerCase();return n?(n=!1,Ui(i)):ji(i)}),"")},Bi=/^no-/,Ri=t=>{t.options?.forEach(e=>{e.__camelCaseName__=Vt(e.name)})},zi=t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const o of t.options)e.add(o.name);const n=[];for(const o of t.options)if(o.name.startsWith("no-")){const s=o.name.replace(Bi,"");if(!e.has(s)){if(o.type!==Boolean)throw new Error(`Cannot add negated option "${o.name}" to command "${t.name}" because it is not a boolean.`);const i={...o,defaultValue:o.defaultValue===void 0?!0:!o.defaultValue,name:s};n.push(i),e.add(s)}}n.length>0&&t.options.push(...n)},Wi=(t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,o=new Map;for(const i of e.options)if(i.name.startsWith("no-")){const c=Vt(i.name);o.set(c,i)}const s=Object.keys(n).filter(i=>o.has(i));if(s.length!==0)for(const i of s){const c=i.charAt(2);if(!c)continue;const a=c.toLowerCase()+i.slice(3),u=o.get(i);u&&(u.__negated__=!0),n[a]=!n[i],Reflect.deleteProperty(n,i)}},Fi=(t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const s of e.options)s.__camelCaseName__&&s.__negated__===void 0&&s.implies!==void 0&&n.set(s.__camelCaseName__,s);if(n.size===0)return;const{options:o}=t;for(const s of Object.keys(o)){const i=n.get(s);if(i?.implies){const{implies:c}=i;for(const[a,u]of Object.entries(c))o[a]===void 0&&(o[a]=u)}}},qi=()=>!!process.versions.electron,Gi=()=>qi()&&!process.defaultApp,Hi=()=>Gi()?0:1,Ji=t=>t.slice(Hi()+1),Ki=" ",Yi=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,o)=>n===e[o]),Qi=t=>{if(typeof t=="string")return t.split(Ki);const e=ye();return Yi(t,e)?Ji(t):t},Zi=t=>{const e=i=>{t.error(`Uncaught exception: ${i.message||i}`),i.stack&&t.error(i.stack),R(1)},n=(i,c)=>{if(i instanceof Error)t.error(`Promise rejection: ${i.message||i}`),i.stack&&t.error(i.stack);else{let a;if(typeof i=="string")a=i;else try{a=JSON.stringify(i)}catch{a=String(i)}t.error(`Promise rejection: ${a}`)}R(1)},o=je("uncaughtException",e),s=je("unhandledRejection",n);return()=>{o(),s()}},at=100,Xi=/^[a-z][\w-]*$/i,Ie=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new k(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},lt=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new k(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},Ce=(t,e)=>{if(typeof t!="object"||t===null)throw new k(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},me=t=>{const e=Ie(t,"Command name");if(e.length>at)throw new k(`Command name is too long (maximum ${String(at)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new k(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Xi.test(e))throw new k(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},es=new Set([`
30
- `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),ts=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArgumentLength??1e6;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Argument is too long (maximum ${String(o)} characters)`);if(n.checkDangerousChars){for(const s of t)if(es.has(s))throw new Error(`Argument contains dangerous character: ${s}`)}return n.trim?t.trim():t},ct=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArguments??1e5;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Too many arguments (maximum ${String(o)})`);return t.map(s=>ts(s,n))},ns=/^-([^\d-])$/,os=/^--(\S+)/,is=/^-([^\d-]{2,})$/,Oe=t=>ns.test(t)||os.test(t)||is.test(t),ss={access:(t,e)=>Po(t,e),mkdir:(t,e)=>Mo(t,e),readdir:t=>To(t),readFile:(async(t,e)=>e===void 0?He(t):He(t,e)),rm:(t,e)=>So(t,e),stat:t=>Lo(t),writeFile:(t,e,n)=>Io(t,e,n)},rs=(t,e,n)=>{const o=e.indexOf("--"),s=o===-1?new Set:new Set(e.slice(o+1)),i=n.filter(u=>u.startsWith("--")&&u!=="--"&&!s.has(u));if(i.length===0)return;const c=(t.options??[]).map(u=>u.name),a=i.flatMap(u=>q(u.slice(2),c).map(r=>`--${r}`));throw new Do(i,a)};class Me{#t;#e;#u;#h;#f;#m;#A;#k;#E;#$;#C;#b;#O;#_=be;#p;#n;#o;#i;#s;#r;#g=!1;#I;#L=!1;#w;#y;#v;#l=[];#D(){return this.#w===void 0&&(this.#w=[...this.#o.keys()]),this.#w}#S(){return this.#y===void 0&&(this.#y=[...this.#n.keys()]),this.#y}#a(){return this.#v===void 0&&(this.#v=[...this.#D(),...this.#S()]),this.#v}#T(){return this.#l.length===0?de:[...de,...this.#l]}#M(){this.#w=void 0,this.#y=void 0,this.#v=void 0}#x(){if(this.#u===void 0){const e=Qi(this.#e.argv);this.#u=ct(e,{maxArguments:this.#b}),this.#U()}return this.#u}#N(){return this.#$??he()}#d(e){this.#_=e,this.#N().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){const e=this.#N().CEREBRO_OUTPUT_LEVEL,n=e===void 0?Number.NaN:Number(e);return Number.isNaN(n)?this.#_:n}#U(){if(!this.#u)return;let e=!1;for(const n of this.#u){if(n==="--quiet"||n==="-q"){this.#d(qt),e=!0;break}if(n==="--verbose"||n==="-v"){this.#d(Gt),e=!0;break}if(n==="--debug"){this.#d(V),e=!0;break}}e||this.#d(Object.hasOwn(this.#N(),"DEBUG")?V:be)}#j(){this.#L||(this.#I=Zi(this.#t),this.#L=!0)}#V(){return{arch:zn(),argv:this.#x(),cwd:this.#h,env:this.#$??he(),exit:this.#E??(e=>R(e??0)),platform:Rn(),stdin:this.#C}}#P(e,n,o,s){this.#c()===V&&this.#t.debug(`command '${s}' found, parsing command args: ${n.join(", ")}`);const{arguments_:i,booleanValues:c,parsedArgs:a}=Ci(e,n,this.#T()),u=Object.keys(c).length>0;let r=a;u&&(r={...a,_all:{...a._all,...c}}),Si(i,r,e);const l=Ei(e,a,c,o);l.runtime=this,l.argv=this.#x(),l.fs=this.#k??ss,l.process=this.#V(),l.console=this.#t;const d=e.options&&e.options.length>0;if(d&&e.options){const h=e.options.filter(f=>f.name.startsWith("no-"));for(const f of h){const p=f.name.slice(3),g=`--${f.name}`,$=`--${p}`,w=n.includes(g),y=n.includes($);if(w&&y)throw new St(p,f.name)}}return d&&(Wi(l,e),Fi(l,e)),Ti(i,l.options,e),Mi(l.options,e),this.#O&&rs(e,n,l.rawUnknown),this.#c()===V&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(l.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(l.argument,null,2))),{arguments_:i,booleanValues:c,commandArgs:r,parsedArgs:a,toolbox:l}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new k("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const o=n.argv??ye(),s=n.cwd??Bn();if(this.#e={...n,argv:o,cwd:s},this.#e.argv&&!Array.isArray(this.#e.argv))throw new k("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new k("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new k("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new k("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const r=["debug","error","info","log","warn"],l=[],d=this.#e.logger;for(const h of r)typeof d[h]!="function"&&l.push(h);if(l.length>0)throw new k(`Logger object is missing required methods: ${l.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:l});this.#t=this.#e.logger}else this.#t={...console,debug:(...r)=>{this.#c()===V&&console.debug(...r)}};this.#m=this.#e.packageVersion,this.#A=this.#e.packageName,this.#h=this.#e.cwd,this.#s="help",this.#r={};const i=n.fs;if(i!==void 0&&(typeof i!="object"||i===null))throw new k("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const c=n.exit;if(c!==void 0&&typeof c!="function")throw new k("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new k("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const u=n.stdin;if(u!==void 0&&typeof u!="string")throw new k("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#k=n.fs,this.#E=n.exit,this.#$=n.env,this.#C=n.stdin??"",this.#b=n.maxArguments,this.#O=n.strictOptions??!1,this.#d(be),this.#n=new Map,this.#o=new Map,this.#i=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#f}${this.#m?` v${this.#m}`:""}`),this.#r}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){Ce(e,"Command"),me(e.name);const n=typeof e.execute=="function",o=typeof e.loader=="function";if(n&&o)throw new k(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!o)throw new k(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?me(e.alias):lt(e.alias,"Command alias").forEach(r=>me(r))),e.argument&&Ce(e.argument,"Command argument"),e.options&&Ce(e.options,"Command options"),e.commandPath&&(lt(e.commandPath,"Command commandPath"),e.commandPath.forEach(r=>{me(r)}));const s=rt(e.name,e.commandPath),i=J(s);if(this.#o.has(i))throw new k(`Command with path "${i}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const c=Array.isArray(e.commandPath)&&e.commandPath.length>0,a=this.#n.get(e.name),u=a!==void 0&&(a.commandPath===void 0||a.commandPath.length===0);if(!c&&u)throw new k(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)Je(r);if(Pi(e),zi(e),Ri(e),e.options&&(e.__conflictingOptions__=e.options.filter(r=>r.conflicts!==void 0),e.__requiredOptions__=e.options.filter(r=>r.required===!0)),c&&a!==void 0)this.#n.set(i,e);else{if(!c&&a!==void 0&&!u){const r=rt(a.name,a.commandPath);this.#n.set(J(r),a)}this.#n.set(e.name,e)}if(this.#o.set(i,s),this.#i.set(i,e),this.#M(),e.alias!==void 0){const r=typeof e.alias=="string"?[e.alias]:e.alias;for(const l of r){if(this.#c()===V&&this.#t.debug("adding alias",l),this.#n.has(l))throw new k(`Command alias "${l}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:l,commandName:e.name});this.#n.set(l,e)}}return this}addGlobalOption(e){const n=e,o=new Set(de.map(i=>i.name)),s=new Set(de.map(i=>i.alias).filter(Boolean));if(o.has(n.name))throw new k(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&s.has(n.alias))throw new k(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(i=>i.name)).has(n.name))throw new k(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",Je(n),this.#l.push(n),this}getGlobalOptions(){return this.#T()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#p?this.#p:(this.#p=new jo(this.#t),this.#p.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#p)}getCliName(){return this.#f}getPackageVersion(){return this.#m}getPackageName(){return this.#A}getCommands(){return this.#n}getCwd(){return this.#h}dispose(){this.#I?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:o=!0,...s}=e;if(!this.#n.has("help")){const{default:y}=await import("../packem_chunks/help-command.js");this.addCommand(new y(this.#n))}const i=this.#S(),c=this.#o;this.#j();const a=this.#x();let u,r=[...a];this.#c()===V&&(this.#t.debug(`process.execPath: ${kt()}`),this.#t.debug(`process.execArgv: ${At().join(" ")}`),this.#t.debug(`process.argv: ${ye().join(" ")}`));const l=Di(c,[...a]);if(l.commandPath)u=l.commandPath,r=l.argv;else{if(a.length>1&&a[0]&&a[1]&&!Oe(a[0])&&!Oe(a[1])){const b=[];let N=0;for(;N<a.length;){const I=a[N];if(!I||Oe(I))break;b.push(I),N+=1}const E=J(b);if(b[0]&&!i.includes(b[0])){const I=this.#a(),O=q(E,I);throw new H(E,O)}}let y;try{y=Fo([null,...i],[...a])}catch(b){if(b instanceof Error&&b.name==="INVALID_COMMAND"&&"command"in b){const N=b.command,E=this.#a(),I=q(N,E);throw new H(N,I)}throw b}y.command&&(u=[y.command],r=y.argv)}if(!u)if(this.#s)u=[this.#s];else{const y=this.#a();throw new H("",y)}const d=J(u),h=this.#o.get(d);let f;if(h){if(f=this.#i.get(d),!f||J(h)!==d){const y=this.#a(),b=q(d,y);throw new H(d,b)}}else{const y=u.at(-1);if(f=y?this.#n.get(y):void 0,!f){const b=this.#a(),N=q(d,b);throw new H(d,N)}}if(typeof f.execute!="function"&&typeof f.loader!="function")return this.#t.error(`Command "${f.name}" has no function to execute.`),o?R(1):void 0;const p=r;let g,$;try{({commandArgs:g,toolbox:$}=this.#P(f,p,s,d))}catch(y){if(this.#t.error(y),o)return R(1);throw y}const w=this.getPluginManager();try{!this.#g&&w.hasPlugins()&&(await w.init({cli:this,cwd:this.#h,logger:this.#t}),this.#g=!0),await w.executeLifecycle("execute",$),await w.executeLifecycle("beforeCommand",$);let y;const b=g.global;if(b?.help){const N=this.#n.get("help");if(!N)throw new k("Help command not found","COMMAND_NOT_FOUND");y=await ee(N,$)}else if(b?.version??b?.V){const N=this.#n.get("version");if(!N)throw new k("Version command not found","COMMAND_NOT_FOUND");y=await ee(N,$)}else y=await ee(f,$);return await w.executeLifecycle("afterCommand",$,y),o?R(0):void 0}catch(y){throw await w.executeErrorHandlers(y,$),y}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:o=[],...s}=n;Ie(e,"Command name");const i=e.split(" ").filter(Boolean),c=J(i),a=this.#o.get(c)?this.#i.get(c):this.#n.get(e);if(!a){const h=this.#a(),f=q(c||e,h);throw new H(e,f)}if(typeof a.execute!="function"&&typeof a.loader!="function")throw new k(`Command "${a.name}" has no function to execute`,"INVALID_COMMAND",{commandName:a.name});const u=[...ct(o,{maxArguments:this.#b})];this.#c()===V&&this.#t.debug(`running command '${e}' programmatically with args: ${u.join(", ")}`);const{commandArgs:r,toolbox:l}=this.#P(a,u,s,c||e),d=this.getPluginManager();try{!this.#g&&d.hasPlugins()&&(await d.init({cli:this,cwd:this.#h,logger:this.#t}),this.#g=!0),await d.executeLifecycle("execute",l),await d.executeLifecycle("beforeCommand",l);let h;const f=r.global;if(f?.help){const p=this.#n.get("help");if(!p)throw new k("Help command not found","COMMAND_NOT_FOUND");h=await ee(p,l)}else if(f?.version??f?.V){const p=this.#n.get("version");if(!p)throw new k("Version command not found","COMMAND_NOT_FOUND");h=await ee(p,l)}else h=await ee(a,l);return await d.executeLifecycle("afterCommand",l,h),h}catch(h){throw await d.executeErrorHandlers(h,l),h}}clone(e){const n={...this.#e,...e},o=new Me(this.#f,n);for(const[s,i]of this.#n)o.#n.set(s,i);for(const[s,i]of this.#o)o.#o.set(s,[...i]);for(const[s,i]of this.#i)o.#i.set(s,i);for(const s of this.#l)o.#l.push(s);return o.#s=this.#s,o.#r={...this.#r},o.#M(),o}async getAction(e){Ie(e,"Command name");const n=e.split(" ").filter(Boolean),o=J(n),s=this.#o.get(o)?this.#i.get(o):this.#n.get(e);if(!s){const i=this.#a(),c=q(o||e,i);throw new H(e,c)}if(typeof s.execute=="function")return s.execute;if(typeof s.loader=="function")return jt(s);throw new k(`Command "${s.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:s.name})}}const ks=(t,e)=>new Me(t,e),Es=()=>{try{const t=require("node:module");if(typeof t.enableCompileCache=="function"){t.enableCompileCache();return}}catch{}try{require("v8-compile-cache")}catch{}},as=ve(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Bt=t=>{if(typeof ue<"u"&&ue.versions&&ue.versions.node){const[e,n]=ue.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ue.getBuiltinModule(t)}return as(t)},{execFileSync:ls}=Bt("node:child_process"),{totalmem:cs}=Bt("node:os"),us=/--max-old-space-size=(\d+)/,hs=/--max-semi-space-size=(\d+)/,ps=t=>Math.floor(cs()/1024/1024*t),ds=t=>t<=512?4:t<=1024?8:t<=2048?16:t<=4096?32:t<=8192?64:Math.floor(Math.log2(t))*8,ut=(t,e)=>{for(const n of e){const o=t.exec(n);if(o)return Number.parseInt(o[1],10)}},Cs=t=>{const n=[...At()],o=[...ye()],s=ut(us,n),i=ut(hs,n);if(s!==void 0&&i!==void 0)return;const c=s??ps(.75),a=i??ds(c),u=[];if(s===void 0&&u.push(`--max-old-space-size=${String(c)}`),i===void 0&&u.push(`--max-semi-space-size=${String(a)}`),u.length!==0)try{ls(kt(),[...u,...n,...o.slice(1)],{env:he(),stdio:"inherit"}),R(0)}catch(r){const l=r.status;R(typeof l=="number"?l:1)}},Os=(t={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(e,n)=>{const{logger:o,runtime:s}=n,{detailed:i=!1,exitOnError:c=!0,formatter:a,logErrors:u=!0,renderOptions:r={}}=t;if(u)if(a)o.error(a(e));else if(i){const l=s.getCwd(),d=Vn(e,{cwd:l,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...r});o.error(d)}else o.error(e);c&&R(1)},version:"1.0.0"});var fs="1.0.0-alpha.37";const _s={version:fs},Is={argument:{description:"Package to execute (optionally with @version)",name:"package",type:String},description:"Execute a remote package without permanent installation",examples:[["vis dlx create-vite my-app","Scaffold a new project"],["vis dlx typescript@5.5.4 tsc --version","Run specific version"],["vis dlx -p cowsay -p lolcatjs -c 'echo hi | cowsay | lolcatjs'","Multiple packages with shell"],["vis install && vis dlx --offline typescript tsc --version","Hardened: pre-install + offline (no registry fetch on dlx)"]],group:"Run & Execute",loader:()=>import("../packem_chunks/handler9.js"),name:"dlx",options:[{alias:"p",description:"Additional packages to install (repeatable)",multiple:!0,name:"package",type:String},{alias:"c",defaultValue:!1,description:"Execute within shell environment",name:"shell-mode",type:Boolean},{alias:"s",defaultValue:!1,description:"Suppress output except command results",name:"silent",type:Boolean},{defaultValue:!1,description:"Resolve from local store only — fail rather than fetch from the registry. Pair with `vis install` for hardened npx-style workflows.",name:"offline",type:Boolean}]};export{G as L,Cs as P,ks as V,Es as a,gs as b,_s as c,bs as d,Is as e,k as f,Os as h,$s as i,ys as n,xs as o,Ns as p,vs as r,ws as s,he as t};
30
+ `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),ts=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArgumentLength??1e6;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Argument is too long (maximum ${String(o)} characters)`);if(n.checkDangerousChars){for(const s of t)if(es.has(s))throw new Error(`Argument contains dangerous character: ${s}`)}return n.trim?t.trim():t},ct=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArguments??1e5;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Too many arguments (maximum ${String(o)})`);return t.map(s=>ts(s,n))},ns=/^-([^\d-])$/,os=/^--(\S+)/,is=/^-([^\d-]{2,})$/,Oe=t=>ns.test(t)||os.test(t)||is.test(t),ss={access:(t,e)=>Po(t,e),mkdir:(t,e)=>Mo(t,e),readdir:t=>To(t),readFile:(async(t,e)=>e===void 0?He(t):He(t,e)),rm:(t,e)=>So(t,e),stat:t=>Lo(t),writeFile:(t,e,n)=>Io(t,e,n)},rs=(t,e,n)=>{const o=e.indexOf("--"),s=o===-1?new Set:new Set(e.slice(o+1)),i=n.filter(u=>u.startsWith("--")&&u!=="--"&&!s.has(u));if(i.length===0)return;const c=(t.options??[]).map(u=>u.name),a=i.flatMap(u=>q(u.slice(2),c).map(r=>`--${r}`));throw new Do(i,a)};class Me{#t;#e;#u;#h;#f;#m;#A;#k;#E;#$;#C;#b;#O;#_=be;#p;#n;#o;#i;#s;#r;#g=!1;#I;#L=!1;#w;#y;#v;#l=[];#D(){return this.#w===void 0&&(this.#w=[...this.#o.keys()]),this.#w}#S(){return this.#y===void 0&&(this.#y=[...this.#n.keys()]),this.#y}#a(){return this.#v===void 0&&(this.#v=[...this.#D(),...this.#S()]),this.#v}#T(){return this.#l.length===0?de:[...de,...this.#l]}#M(){this.#w=void 0,this.#y=void 0,this.#v=void 0}#x(){if(this.#u===void 0){const e=Qi(this.#e.argv);this.#u=ct(e,{maxArguments:this.#b}),this.#U()}return this.#u}#N(){return this.#$??he()}#d(e){this.#_=e,this.#N().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){const e=this.#N().CEREBRO_OUTPUT_LEVEL,n=e===void 0?Number.NaN:Number(e);return Number.isNaN(n)?this.#_:n}#U(){if(!this.#u)return;let e=!1;for(const n of this.#u){if(n==="--quiet"||n==="-q"){this.#d(qt),e=!0;break}if(n==="--verbose"||n==="-v"){this.#d(Gt),e=!0;break}if(n==="--debug"){this.#d(V),e=!0;break}}e||this.#d(Object.hasOwn(this.#N(),"DEBUG")?V:be)}#j(){this.#L||(this.#I=Zi(this.#t),this.#L=!0)}#V(){return{arch:zn(),argv:this.#x(),cwd:this.#h,env:this.#$??he(),exit:this.#E??(e=>R(e??0)),platform:Rn(),stdin:this.#C}}#P(e,n,o,s){this.#c()===V&&this.#t.debug(`command '${s}' found, parsing command args: ${n.join(", ")}`);const{arguments_:i,booleanValues:c,parsedArgs:a}=Ci(e,n,this.#T()),u=Object.keys(c).length>0;let r=a;u&&(r={...a,_all:{...a._all,...c}}),Si(i,r,e);const l=Ei(e,a,c,o);l.runtime=this,l.argv=this.#x(),l.fs=this.#k??ss,l.process=this.#V(),l.console=this.#t;const d=e.options&&e.options.length>0;if(d&&e.options){const h=e.options.filter(f=>f.name.startsWith("no-"));for(const f of h){const p=f.name.slice(3),g=`--${f.name}`,$=`--${p}`,w=n.includes(g),y=n.includes($);if(w&&y)throw new St(p,f.name)}}return d&&(Wi(l,e),Fi(l,e)),Ti(i,l.options,e),Mi(l.options,e),this.#O&&rs(e,n,l.rawUnknown),this.#c()===V&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(l.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(l.argument,null,2))),{arguments_:i,booleanValues:c,commandArgs:r,parsedArgs:a,toolbox:l}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new k("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const o=n.argv??ye(),s=n.cwd??Bn();if(this.#e={...n,argv:o,cwd:s},this.#e.argv&&!Array.isArray(this.#e.argv))throw new k("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new k("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new k("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new k("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const r=["debug","error","info","log","warn"],l=[],d=this.#e.logger;for(const h of r)typeof d[h]!="function"&&l.push(h);if(l.length>0)throw new k(`Logger object is missing required methods: ${l.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:l});this.#t=this.#e.logger}else this.#t={...console,debug:(...r)=>{this.#c()===V&&console.debug(...r)}};this.#m=this.#e.packageVersion,this.#A=this.#e.packageName,this.#h=this.#e.cwd,this.#s="help",this.#r={};const i=n.fs;if(i!==void 0&&(typeof i!="object"||i===null))throw new k("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const c=n.exit;if(c!==void 0&&typeof c!="function")throw new k("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new k("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const u=n.stdin;if(u!==void 0&&typeof u!="string")throw new k("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#k=n.fs,this.#E=n.exit,this.#$=n.env,this.#C=n.stdin??"",this.#b=n.maxArguments,this.#O=n.strictOptions??!1,this.#d(be),this.#n=new Map,this.#o=new Map,this.#i=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#f}${this.#m?` v${this.#m}`:""}`),this.#r}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){Ce(e,"Command"),me(e.name);const n=typeof e.execute=="function",o=typeof e.loader=="function";if(n&&o)throw new k(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!o)throw new k(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?me(e.alias):lt(e.alias,"Command alias").forEach(r=>me(r))),e.argument&&Ce(e.argument,"Command argument"),e.options&&Ce(e.options,"Command options"),e.commandPath&&(lt(e.commandPath,"Command commandPath"),e.commandPath.forEach(r=>{me(r)}));const s=rt(e.name,e.commandPath),i=J(s);if(this.#o.has(i))throw new k(`Command with path "${i}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const c=Array.isArray(e.commandPath)&&e.commandPath.length>0,a=this.#n.get(e.name),u=a!==void 0&&(a.commandPath===void 0||a.commandPath.length===0);if(!c&&u)throw new k(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)Je(r);if(Pi(e),zi(e),Ri(e),e.options&&(e.__conflictingOptions__=e.options.filter(r=>r.conflicts!==void 0),e.__requiredOptions__=e.options.filter(r=>r.required===!0)),c&&a!==void 0)this.#n.set(i,e);else{if(!c&&a!==void 0&&!u){const r=rt(a.name,a.commandPath);this.#n.set(J(r),a)}this.#n.set(e.name,e)}if(this.#o.set(i,s),this.#i.set(i,e),this.#M(),e.alias!==void 0){const r=typeof e.alias=="string"?[e.alias]:e.alias;for(const l of r){if(this.#c()===V&&this.#t.debug("adding alias",l),this.#n.has(l))throw new k(`Command alias "${l}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:l,commandName:e.name});this.#n.set(l,e)}}return this}addGlobalOption(e){const n=e,o=new Set(de.map(i=>i.name)),s=new Set(de.map(i=>i.alias).filter(Boolean));if(o.has(n.name))throw new k(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&s.has(n.alias))throw new k(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(i=>i.name)).has(n.name))throw new k(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",Je(n),this.#l.push(n),this}getGlobalOptions(){return this.#T()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#p?this.#p:(this.#p=new jo(this.#t),this.#p.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#p)}getCliName(){return this.#f}getPackageVersion(){return this.#m}getPackageName(){return this.#A}getCommands(){return this.#n}getCwd(){return this.#h}dispose(){this.#I?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:o=!0,...s}=e;if(!this.#n.has("help")){const{default:y}=await import("../packem_chunks/help-command.js");this.addCommand(new y(this.#n))}const i=this.#S(),c=this.#o;this.#j();const a=this.#x();let u,r=[...a];this.#c()===V&&(this.#t.debug(`process.execPath: ${kt()}`),this.#t.debug(`process.execArgv: ${At().join(" ")}`),this.#t.debug(`process.argv: ${ye().join(" ")}`));const l=Di(c,[...a]);if(l.commandPath)u=l.commandPath,r=l.argv;else{if(a.length>1&&a[0]&&a[1]&&!Oe(a[0])&&!Oe(a[1])){const b=[];let N=0;for(;N<a.length;){const I=a[N];if(!I||Oe(I))break;b.push(I),N+=1}const E=J(b);if(b[0]&&!i.includes(b[0])){const I=this.#a(),O=q(E,I);throw new H(E,O)}}let y;try{y=Fo([null,...i],[...a])}catch(b){if(b instanceof Error&&b.name==="INVALID_COMMAND"&&"command"in b){const N=b.command,E=this.#a(),I=q(N,E);throw new H(N,I)}throw b}y.command&&(u=[y.command],r=y.argv)}if(!u)if(this.#s)u=[this.#s];else{const y=this.#a();throw new H("",y)}const d=J(u),h=this.#o.get(d);let f;if(h){if(f=this.#i.get(d),!f||J(h)!==d){const y=this.#a(),b=q(d,y);throw new H(d,b)}}else{const y=u.at(-1);if(f=y?this.#n.get(y):void 0,!f){const b=this.#a(),N=q(d,b);throw new H(d,N)}}if(typeof f.execute!="function"&&typeof f.loader!="function")return this.#t.error(`Command "${f.name}" has no function to execute.`),o?R(1):void 0;const p=r;let g,$;try{({commandArgs:g,toolbox:$}=this.#P(f,p,s,d))}catch(y){if(this.#t.error(y),o)return R(1);throw y}const w=this.getPluginManager();try{!this.#g&&w.hasPlugins()&&(await w.init({cli:this,cwd:this.#h,logger:this.#t}),this.#g=!0),await w.executeLifecycle("execute",$),await w.executeLifecycle("beforeCommand",$);let y;const b=g.global;if(b?.help){const N=this.#n.get("help");if(!N)throw new k("Help command not found","COMMAND_NOT_FOUND");y=await ee(N,$)}else if(b?.version??b?.V){const N=this.#n.get("version");if(!N)throw new k("Version command not found","COMMAND_NOT_FOUND");y=await ee(N,$)}else y=await ee(f,$);return await w.executeLifecycle("afterCommand",$,y),o?R(0):void 0}catch(y){throw await w.executeErrorHandlers(y,$),y}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:o=[],...s}=n;Ie(e,"Command name");const i=e.split(" ").filter(Boolean),c=J(i),a=this.#o.get(c)?this.#i.get(c):this.#n.get(e);if(!a){const h=this.#a(),f=q(c||e,h);throw new H(e,f)}if(typeof a.execute!="function"&&typeof a.loader!="function")throw new k(`Command "${a.name}" has no function to execute`,"INVALID_COMMAND",{commandName:a.name});const u=[...ct(o,{maxArguments:this.#b})];this.#c()===V&&this.#t.debug(`running command '${e}' programmatically with args: ${u.join(", ")}`);const{commandArgs:r,toolbox:l}=this.#P(a,u,s,c||e),d=this.getPluginManager();try{!this.#g&&d.hasPlugins()&&(await d.init({cli:this,cwd:this.#h,logger:this.#t}),this.#g=!0),await d.executeLifecycle("execute",l),await d.executeLifecycle("beforeCommand",l);let h;const f=r.global;if(f?.help){const p=this.#n.get("help");if(!p)throw new k("Help command not found","COMMAND_NOT_FOUND");h=await ee(p,l)}else if(f?.version??f?.V){const p=this.#n.get("version");if(!p)throw new k("Version command not found","COMMAND_NOT_FOUND");h=await ee(p,l)}else h=await ee(a,l);return await d.executeLifecycle("afterCommand",l,h),h}catch(h){throw await d.executeErrorHandlers(h,l),h}}clone(e){const n={...this.#e,...e},o=new Me(this.#f,n);for(const[s,i]of this.#n)o.#n.set(s,i);for(const[s,i]of this.#o)o.#o.set(s,[...i]);for(const[s,i]of this.#i)o.#i.set(s,i);for(const s of this.#l)o.#l.push(s);return o.#s=this.#s,o.#r={...this.#r},o.#M(),o}async getAction(e){Ie(e,"Command name");const n=e.split(" ").filter(Boolean),o=J(n),s=this.#o.get(o)?this.#i.get(o):this.#n.get(e);if(!s){const i=this.#a(),c=q(o||e,i);throw new H(e,c)}if(typeof s.execute=="function")return s.execute;if(typeof s.loader=="function")return jt(s);throw new k(`Command "${s.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:s.name})}}const ks=(t,e)=>new Me(t,e),Es=()=>{try{const t=require("node:module");if(typeof t.enableCompileCache=="function"){t.enableCompileCache();return}}catch{}try{require("v8-compile-cache")}catch{}},as=ve(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Bt=t=>{if(typeof ue<"u"&&ue.versions&&ue.versions.node){const[e,n]=ue.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ue.getBuiltinModule(t)}return as(t)},{execFileSync:ls}=Bt("node:child_process"),{totalmem:cs}=Bt("node:os"),us=/--max-old-space-size=(\d+)/,hs=/--max-semi-space-size=(\d+)/,ps=t=>Math.floor(cs()/1024/1024*t),ds=t=>t<=512?4:t<=1024?8:t<=2048?16:t<=4096?32:t<=8192?64:Math.floor(Math.log2(t))*8,ut=(t,e)=>{for(const n of e){const o=t.exec(n);if(o)return Number.parseInt(o[1],10)}},Cs=t=>{const n=[...At()],o=[...ye()],s=ut(us,n),i=ut(hs,n);if(s!==void 0&&i!==void 0)return;const c=s??ps(.75),a=i??ds(c),u=[];if(s===void 0&&u.push(`--max-old-space-size=${String(c)}`),i===void 0&&u.push(`--max-semi-space-size=${String(a)}`),u.length!==0)try{ls(kt(),[...u,...n,...o.slice(1)],{env:he(),stdio:"inherit"}),R(0)}catch(r){const l=r.status;R(typeof l=="number"?l:1)}},Os=(t={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(e,n)=>{const{logger:o,runtime:s}=n,{detailed:i=!1,exitOnError:c=!0,formatter:a,logErrors:u=!0,renderOptions:r={}}=t;if(u)if(a)o.error(a(e));else if(i){const l=s.getCwd(),d=Vn(e,{cwd:l,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...r});o.error(d)}else o.error(e);c&&R(1)},version:"1.0.0"});var fs="1.0.0-alpha.38";const _s={version:fs},Is={argument:{description:"Package to execute (optionally with @version)",name:"package",type:String},description:"Execute a remote package without permanent installation",examples:[["vis dlx create-vite my-app","Scaffold a new project"],["vis dlx typescript@5.5.4 tsc --version","Run specific version"],["vis dlx -p cowsay -p lolcatjs -c 'echo hi | cowsay | lolcatjs'","Multiple packages with shell"],["vis install && vis dlx --offline typescript tsc --version","Hardened: pre-install + offline (no registry fetch on dlx)"]],group:"Run & Execute",loader:()=>import("../packem_chunks/handler9.js"),name:"dlx",options:[{alias:"p",description:"Additional packages to install (repeatable)",multiple:!0,name:"package",type:String},{alias:"c",defaultValue:!1,description:"Execute within shell environment",name:"shell-mode",type:Boolean},{alias:"s",defaultValue:!1,description:"Suppress output except command results",name:"silent",type:Boolean},{defaultValue:!1,description:"Resolve from local store only — fail rather than fetch from the registry. Pair with `vis install` for hardened npx-style workflows.",name:"offline",type:Boolean}]};export{G as L,Cs as P,ks as V,Es as a,gs as b,_s as c,bs as d,Is as e,k as f,Os as h,$s as i,ys as n,xs as o,Ns as p,vs as r,ws as s,he as t};