@visulima/cerebro 3.0.0-alpha.6 → 3.0.0-alpha.8

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 +0,0 @@
1
- var _t=Object.defineProperty;var $=(t,e)=>_t(t,"name",{value:e,configurable:!0});import{createRequire as Lt}from"node:module";import{o as Ut,D as Mt}from"./help-command-CIRIXN03.js";import{VERBOSITY_DEBUG as W,POSITIONALS_KEY as te,VERBOSITY_QUIET as Vt,VERBOSITY_VERBOSE as Tt,VERBOSITY_NORMAL as Ne}from"./VERBOSITY_QUIET-XPultrIA.js";import{c as k}from"./cerebro-error-CXXSmFtP.js";import{d as q,f as Ee,e as ie,o as xe,a as Rt,h as Dt,i as Bt}from"./runtime-process-G-n-wOub.js";import{distance as zt}from"fastest-levenshtein";const It=Lt(import.meta.url),Y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,St=$(t=>{if(typeof Y<"u"&&Y.versions&&Y.versions.node){const[e,n]=Y.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return Y.getBuiltinModule(t)}return It(t)},"__cjs_getBuiltinModule"),{createRequire:Wt}=St("node:module");var Ft=Object.defineProperty,qt=$((t,e)=>Ft(t,"name",{value:e,configurable:!0}),"t$9");let D=class extends k{static{$(this,"a")}static{qt(this,"CommandNotFoundError")}commandName;constructor(e,n=[]){const a=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(a,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}};var Gt=Object.defineProperty,Ht=$((t,e)=>Gt(t,"name",{value:e,configurable:!0}),"e$6");let Qe=class extends k{static{$(this,"o")}static{Ht(this,"ConflictingOptionsError")}option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}};var Kt=Object.defineProperty,Yt=$((t,e)=>Kt(t,"name",{value:e,configurable:!0}),"e$5");let Jt=class extends k{static{$(this,"o")}static{Yt(this,"PluginError")}pluginName;constructor(e,n,a){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:a,pluginName:e}),this.name="PluginError",this.pluginName=e,a&&(this.cause=a)}};var Qt=Object.defineProperty,je=$((t,e)=>Qt(t,"name",{value:e,configurable:!0}),"d$6");let Zt=class{static{$(this,"p")}static{je(this,"PluginManager")}logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);q().CEREBRO_OUTPUT_LEVEL===String(W)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){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 n=this.getDependencyOrder();this.logger.debug(`initializing ${n.length} plugin(s)...`);for(const a of n)if(typeof a.init=="function"){this.logger.debug(`initializing plugin: ${a.name}`);try{await a.init(e)}catch(o){const i=new Jt(a.name,`Failed to initialize: ${o instanceof Error?o.message:String(o)}`,o instanceof Error?o:void 0);throw this.logger.error(i.message),i}}this.initialized=!0}async executeLifecycle(e,n,a){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const o=this.getDependencyOrder();for(const i of o){const u=i[e];if(typeof u=="function"){this.logger.debug(`executing ${e} hook for plugin: ${i.name}`);try{await(e==="afterCommand"?u(n,a):u(n))}catch(s){throw this.logger.error(`Error in ${e} hook for plugin "${i.name}":`,s),s}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const a=this.getDependencyOrder();for(const o of a)if(typeof o.onError=="function"){this.logger.debug(`executing error handler for plugin: ${o.name}`);try{await o.onError(e,n)}catch(i){this.logger.error(`Error in error handler for plugin "${o.name}":`,i)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,a=new Set,o=je(i=>{if(n.has(i))return;if(a.has(i))throw new Error(`Circular dependency detected involving plugin "${i}"`);const u=this.plugins.get(i);if(!u)throw new Error(`Plugin "${i}" not found`);if(a.add(i),u.dependencies)for(const s of u.dependencies)o(s);a.delete(i),n.add(i),e.push(u)},"visit");for(const i of this.plugins.keys())o(i);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}};var Xt=Object.defineProperty,en=$((t,e)=>Xt(t,"name",{value:e,configurable:!0}),"n$b");const X=en(t=>t.type?.name==="Boolean","optionIsBoolean");var tn=Object.defineProperty,Ze=$((t,e)=>tn(t,"name",{value:e,configurable:!0}),"p$9");const nn=Ze(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},"getTypeLabel"),an=Ze(t=>(X(t)||(t.typeLabel=t.typeLabel??nn(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var rn=Object.defineProperty,Xe=$((t,e)=>rn(t,"name",{value:e,configurable:!0}),"e$3");const on=new RegExp(/^-([^\d-])$/),sn=new RegExp(/^--(\S+)/),ln=new RegExp(/^-([^\d-]{2,})$/),cn=Xe(t=>on.test(t)||sn.test(t)||ln.test(t),"isOption"),un=Xe((t,e)=>{const n=e[0]&&cn(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const a=new Error(`Command not recognised: ${n}`);throw a.command=n,a.name="INVALID_COMMAND",a}return{argv:e,command:n}},"commandLineCommands");var pn=Object.defineProperty,et=$((t,e)=>pn(t,"name",{value:e,configurable:!0}),"i$a"),fn=Object.defineProperty,tt=et((t,e)=>fn(t,"name",{value:e,configurable:!0}),"i"),hn=Object.defineProperty,nt=tt((t,e)=>hn(t,"name",{value:e,configurable:!0}),"i");nt(t=>t instanceof Error&&t.type==="VisulimaError","isVisulimaError");let re=class extends Error{static{$(this,"p")}static{et(this,"E")}static{tt(this,"m")}static{nt(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:a,message:o,name:i,stack:u,title:s}){super(o,{cause:e}),this.title=s,this.name=i,this.stack=u??this.stack,this.loc=a,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}};var dn=Object.defineProperty,it=$((t,e)=>dn(t,"name",{value:e,configurable:!0}),"o$b"),mn=Object.defineProperty,at=it((t,e)=>mn(t,"name",{value:e,configurable:!0}),"o"),gn=Object.defineProperty,vn=at((t,e)=>gn(t,"name",{value:e,configurable:!0}),"i");let yn=class rt extends re{static{$(this,"a")}static{it(this,"a")}static{at(this,"t")}static{vn(this,"AlreadySetError")}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,rt.prototype)}};var wn=Object.defineProperty,ot=$((t,e)=>wn(t,"name",{value:e,configurable:!0}),"t$7"),bn=Object.defineProperty,st=ot((t,e)=>bn(t,"name",{value:e,configurable:!0}),"e"),$n=Object.defineProperty,On=st((t,e)=>$n(t,"name",{value:e,configurable:!0}),"e");let _e=class lt extends re{static{$(this,"n")}static{ot(this,"n")}static{st(this,"o")}static{On(this,"UnknownOptionError")}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,lt.prototype)}};var En=Object.defineProperty,ct=$((t,e)=>En(t,"name",{value:e,configurable:!0}),"a$6"),An=Object.defineProperty,ut=ct((t,e)=>An(t,"name",{value:e,configurable:!0}),"a"),Pn=Object.defineProperty,Cn=ut((t,e)=>Pn(t,"name",{value:e,configurable:!0}),"o");let kn=class pt extends re{static{$(this,"n")}static{ct(this,"o")}static{ut(this,"e")}static{Cn(this,"UnknownValueError")}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)}};var Nn=Object.defineProperty,ft=$((t,e)=>Nn(t,"name",{value:e,configurable:!0}),"i$7"),xn=Object.defineProperty,ht=ft((t,e)=>xn(t,"name",{value:e,configurable:!0}),"i"),jn=Object.defineProperty,_n=ht((t,e)=>jn(t,"name",{value:e,configurable:!0}),"i");let j=class dt extends re{static{$(this,"a")}static{ft(this,"o")}static{ht(this,"e")}static{_n(this,"InvalidDefinitionsError")}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,dt.prototype)}};var Ln=Object.defineProperty,In=$((t,e)=>Ln(t,"name",{value:e,configurable:!0}),"T$1"),Sn=Object.defineProperty,H=In((t,e)=>Sn(t,"name",{value:e,configurable:!0}),"P"),Un=Object.defineProperty,oe=H((t,e)=>Un(t,"name",{value:e,configurable:!0}),"o");const Le=oe(t=>t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean"),"isBooleanType"),Ie=oe(t=>t===Number||typeof t=="function"&&t.name==="Number","isNumberType"),Se=oe(t=>t===String||typeof t=="function"&&t.name==="String","isStringType"),Mn=oe((t,e)=>Array.isArray(t)?Le(e)?t.map(Boolean):Ie(e)?t.map(Number):Se(e)?t.map(String):t.map(n=>e(String(n))):t===null?null:Le(e)?!!t:Ie(e)?Number(t):Se(e)?String(t):e(String(t)),"convertValue");var Vn=Object.defineProperty,Tn=H((t,e)=>Vn(t,"name",{value:e,configurable:!0}),"e");const x=Tn((t,e,n,...a)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...a)},"debug");var Rn=Object.defineProperty,T=H((t,e)=>Rn(t,"name",{value:e,configurable:!0}),"A");const Dn=/-([a-z])/g,me=T(t=>t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean"),"isBooleanType"),Bn=T(t=>t.codePointAt(0)===95,"isSpecialKey"),Ue=T((t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],"appendToArrayMultiple"),Me=T(t=>t==="__proto__"||t==="constructor"||t==="prototype","isUnsafeKey"),Ve=T((t,e,n,a=!1)=>{t[e]===void 0?t[e]=a?[n]:n:a&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},"createOrAppendArray"),zn=T((t,e,n,a,o)=>{let i=e.get(t)||n.get(t);if(!i&&a){const u=t.toLowerCase();i=a.get(u)||o?.get(u)}return i},"getDefinition"),Wn=T((t,e,n,a)=>{const o=n.debug||!1;x(o,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),x(o,"Starting argument resolution","resolver"),x(o,"Tokens:","resolver",t),x(o,"Definitions:","resolver",e),x(o,"Processing tokens...","resolver");const i=new Map,u=new Map,s=n.caseInsensitive?new Map:void 0,g=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,p=n.camelCase?new Map:void 0;for(const f of e)if(i.set(f.name,f),f.alias&&u.set(f.alias,f),n.caseInsensitive&&s&&(s.set(f.name.toLowerCase(),f),f.alias&&g&&g.set(f.alias.toLowerCase(),f)),n.camelCase&&r&&p){const m=f.name.replaceAll(Dn,(v,y)=>y.toUpperCase());r.set(f.name,m),p.set(m,f.name)}const c={},l={},d=[],h=new Set;let O=!1;const b=e.find(f=>f.defaultOption),w=e.some(f=>f.group),P=e.some(f=>f.type===Number);for(let f=0;f<t.length;f++){const m=t[f];if(m.kind==="option-terminator"){c._unknown=a.slice(m.index),O=!0;break}if(m.kind==="option"&&m.name){let v=zn(m.name,i,u,s,g);if(!v&&m.value===void 0&&P&&/^\d+$/.test(m.name)){const A=e.find(I=>I.type===Number);A&&(v=A,m.value=m.name,m.name=A.name)}const y=v?v.name:m.name,E=v&&v.multiple,N=v&&v.lazyMultiple;if(l[y]!==void 0&&!E&&!N&&!n.partial)throw new yn(y);if(!v&&n.partial){const A=m.rawName||`--${m.name}${m.value!==void 0&&m.inlineValue?`=${m.value}`:""}`;d.push({index:m.index,value:A});continue}if(!v&&n.stopAtFirstUnknown){c._unknown=a.slice(m.index);break}if(!v&&!n.partial)throw new _e(m.name);if(m.value===void 0){const A=t[f+1],I=A&&A.kind==="option"&&!("name"in A)&&A.value!==void 0,L=A&&v&&!(v.type&&me(v.type))&&(A.kind==="positional"||I),jt=v&&v.defaultOption&&!v.multiple&&!v.lazyMultiple;if(L&&(!v?.defaultOption||jt))if(E){let S=f+1;const de=[];for(;S<t.length&&(t[S].kind==="positional"||t[S].kind==="option"&&!("name"in t[S])&&t[S].value!==void 0);)de.push(t[S].value),h.add(t[S].index),S++;l[y]=l[y]===void 0?de:Ue(l[y],de),f=S-1}else N?(Ve(l,y,A.value,!0),h.add(A.index),f++):(l[y]=A.value,h.add(A.index),f++);else v&&v.type&&me(v.type)?Ve(l,y,!0,E):l[y]=E?[]:null}else{let{value:A}=m;if(v&&v.type&&me(v.type))switch(A){case"":{if(n.partial)l._unknown||(l._unknown=[]),l._unknown.push(`${m.rawName||`--${m.name}`}${m.value?`=${m.value}`:""}`),A=!0;else throw new _e(m.name);break}case"false":{A=!1;break}case"true":{A=!0;break}default:A=!0}const I=A===void 0?[]:[A];if(E){let L=f+1;for(;L<t.length&&t[L].kind==="positional";)I.push(t[L].value),h.add(t[L].index),L++;f=L-1}l[y]===void 0?l[y]=E||N?I:A:E||N?l[y]=Ue(l[y],I):l[y]=A}}else if(m.kind==="positional"&&n.stopAtFirstUnknown&&!h.has(m.index)){x(o,`Found unconsumed positional token at index ${m.index}, stopping processing`,"resolver"),c._unknown=a.slice(m.index);break}}for(const[f,m]of Object.entries(l)){const v=i.get(f);v&&(v.multiple||v.lazyMultiple)&&!Array.isArray(m)&&(l[f]=[m])}if(b){const f=[],m=[];for(const v of t)v.kind==="positional"&&!h.has(v.index)&&(f.push(v.value),m.push(v));if(f.length>0){const v=l[b.name],y=b.multiple||b.lazyMultiple;v===void 0?y?(m.forEach(E=>h.add(E.index)),l[b.name]=f):(h.add(m[0].index),l[b.name]=f[0]):y&&(m.forEach(E=>h.add(E.index)),l[b.name]=Array.isArray(v)?[...f,...v]:[...f,v])}}if(!n.partial){for(const f of t)if(f.kind==="positional"&&!h.has(f.index))throw new kn(a[f.index])}if(n.partial&&!n.stopAtFirstUnknown){const f=[...d];if(l._unknown){const m=new Map;for(const[v,y]of a.entries())m.set(y,v);for(const v of l._unknown){const y=m.get(v);y!==void 0&&f.push({index:y,value:v})}}for(const m of t)m.kind==="positional"&&!h.has(m.index)&&f.push({index:m.index,value:a[m.index]});f.length>0&&(f.sort((m,v)=>m.index-v.index),c._unknown=f.map(m=>m.value))}if(n.stopAtFirstUnknown&&!O){const f=t.findIndex(y=>y.kind==="option"&&!i.has(y.name||"")&&!u.has(y.name||"")&&(!n.caseInsensitive||!s?.has(y.name?.toLowerCase()||"")&&!g?.has(y.name?.toLowerCase()||""))),m=t.findIndex(y=>y.kind==="positional"&&!h.has(y.index));let v=-1;if(f!==-1&&m!==-1?v=Math.min(f,m):f!==-1?v=f:m!==-1&&(v=m),v>=0){const y=t[v].index;c._unknown=a.slice(y)}}else d.length>0&&!n.partial&&(c._unknown=d.map(f=>f.value));for(const[f,m]of Object.entries(l)){const v=n.camelCase&&r?.get(f)||f,y=i.get(f);c[v]=y&&y.type?Mn(m,y.type):m===void 0?null:m}for(const f of e){const m=n.camelCase&&r?.get(f.name)||f.name;!(m in c)&&f.defaultValue!==void 0&&(f.multiple||f.lazyMultiple?c[m]=Array.isArray(f.defaultValue)?[...f.defaultValue]:[f.defaultValue]:c[m]=f.defaultValue)}if(w){const f={},m={},v={};for(const E of e)if(E.group){const N=Array.isArray(E.group)?E.group:[E.group];for(const A of N)Me(A)||f[A]||(f[A]={})}for(const E of Object.keys(c))if(!Bn(E)){m[E]=c[E];let N=E;n.camelCase&&(N=p?.get(E)||E);const A=i.get(N);if(A&&A.group){const I=Array.isArray(A.group)?A.group:[A.group];for(const L of I)Me(L)||f[L]&&(f[L][E]=c[E])}else v[E]=c[E]}const y={_all:m};for(const[E,N]of Object.entries(f))y[E]=N;Object.keys(v).length>0&&(y._none=v),c._unknown&&(y._unknown=c._unknown),Object.keys(c).forEach(E=>delete c[E]),Object.assign(c,y)}return x(o,"Final parsed result:","resolver",c),c},"resolveArgs");var Fn=Object.defineProperty,R=H((t,e)=>Fn(t,"name",{value:e,configurable:!0}),"l");const V="-".codePointAt(0),M="=",qn=M.codePointAt(0),Gn="--",Hn="-",Kn="--",mt=R(t=>t.length>2&&t.startsWith(Kn),"hasLongOptionPrefix"),Yn=R(t=>mt(t)&&!t.includes(M,3),"isLongOption"),Jn=R(t=>mt(t)&&t.includes(M,3),"isLongOptionAndValue"),Qn=R(t=>t!==void 0&&t.length>0&&t.codePointAt(0)!==V,"hasOptionValue"),Zn=R(t=>{if(t.length!==2||t.codePointAt(0)!==V||t.codePointAt(1)===V)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},"isShortOption"),Xn=R(t=>!(t.length<=2||t.codePointAt(0)!==V||t.codePointAt(1)===V),"isShortOptionGroup"),ei=R(t=>{const e=[],n=[...t];let a=-1,o=0;for(;n.length>0;){const i=n.shift();if(i===void 0)break;const u=n[0];if(o>0?o--:a++,i===Gn){e.push({index:a,kind:"option-terminator"});const s=n.map((g,r)=>({index:a+r+1,kind:"positional",value:g}));e.push(...s),a+=n.length;break}if(Zn(i)){const s=i.charAt(1);let g,r;o?(e.push({index:a,inlineValue:r,kind:"option",name:s,rawName:i,value:g}),o===1&&Qn(u)&&(g=n.shift(),e.push({index:a,inlineValue:r,kind:"option",value:g}))):e.push({index:a,inlineValue:r,kind:"option",name:s,rawName:i,value:g}),g!==void 0&&++a;continue}if(Xn(i)&&!i.includes(M)){const s=[];let g="",r=!1;for(let p=1;p<i.length;p++){const c=i.charAt(p);r?g+=c:c.codePointAt(0)===qn?r=!0:s.push(`${Hn}${c}`)}if(r)if(s.length>0){const p=s.pop();s.push(`${p}=${g}`)}else s.push(g);n.unshift(...s),o=s.length;continue}if(Yn(i)){const s=i.slice(2);e.push({index:a,kind:"option",name:s,rawName:i});continue}if(Jn(i)){const s=i.indexOf(M),g=i.slice(2,s),r=i.slice(s+1);e.push({index:a,inlineValue:!0,kind:"option",name:g,rawName:i,value:r});continue}if(i.length>2&&i.codePointAt(0)===V&&i.codePointAt(1)!==V&&i.includes(M)){const s=i.indexOf(M),g=i.charAt(1),r=i.slice(s+1);e.push({index:a,inlineValue:!0,kind:"option",name:g,rawName:i,value:r});continue}e.push({index:a,kind:"positional",value:i})}return e},"parseArgsTokens");var ti=Object.defineProperty,Pe=H((t,e)=>ti(t,"name",{value:e,configurable:!0}),"d");const ni=Pe(t=>t&&(t===Boolean||typeof t=="function"&&t.name?.startsWith("Boolean")),"isBooleanType"),ii=Pe(t=>typeof t=="function","isValidCustomTypeFunction"),ai=Pe((t,e,n)=>{const a=n?.debug||!1;x(a,"Validating definitions:","validation",t,"caseInsensitive:",e);const o=new Set,i=new Set,u=new Set,s=new Set;let g=0;for(const r of t){if(x(a,"Checking definition:","validation",r),!r.name)throw x(a,"Validation failed: name is required","validation"),new j("Invalid option definition: name is required");if(typeof r.name!="string")throw new j("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new j("Invalid option definition: name cannot be empty");const p=e?r.name.toLowerCase():"";if(o.has(r.name)||e&&u.has(p))throw new j(`Invalid option definition: duplicate name '${r.name}'`);if(i.has(r.name)||e&&s.has(p))throw new j(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(o.add(r.name),e&&u.add(p),r.alias!==void 0){if(typeof r.alias!="string")throw new j("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new j("Invalid option definition: alias must be a single character");if(/\d/.test(r.alias))throw new j("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new j('Invalid option definition: alias cannot be "-"');const c=e?r.alias.toLowerCase():"";if(i.has(r.alias)||e&&s.has(c))throw new j(`Invalid option definition: duplicate alias '${r.alias}'`);if(o.has(r.alias)||e&&u.has(c))throw new j(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);i.add(r.alias),e&&s.add(c)}if(r.defaultOption&&(g++,r.type!==void 0&&ni(r.type)))throw new j("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"&&ii(r.type)))throw new j("Invalid option definition: invalid type")}if(g>1)throw x(a,"Validation failed: multiple defaultOptions not allowed","validation"),new j("Invalid option definition: multiple defaultOptions not allowed");x(a,"Validation completed successfully","validation")},"validateDefinitions");var ri=Object.defineProperty,oi=H((t,e)=>ri(t,"name",{value:e,configurable:!0}),"O");const si=oi((t,e={})=>{const n=e.debug||!1;x(n,"Starting command-line-args parsing","index"),x(n,"Options:","index",e);const a={...e};a.stopAtFirstUnknown&&(a.partial=!0);const o=Array.isArray(t)?t:[t];x(n,"Normalized definitions:","index",o),ai(o,a.caseInsensitive,n?a:void 0);let{argv:i}=a;if(!i&&(i=process.argv.slice(2),process.execArgv?.length)){const r=new Set(process.execArgv);i=i.filter(p=>!r.has(p))}x(n,"Using argv:","index",i);let u=i;a.caseInsensitive&&i&&(u=i.map(r=>{if(r.startsWith("--")){const p=r.indexOf("="),c=(p===-1?r.slice(2):r.slice(2,p)).toLowerCase();return p===-1?`--${c}`:`--${c}${r.slice(p)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const p=r.slice(1).split("=",2),c=p[0],l=p[1];if(!c)return r;const d=c.toLowerCase();return l===void 0?`-${d}`:`-${d}=${l}`}return r}));const s=ei((u??i??[]).map(String));x(n,"Tokenized arguments:","index",s);const g=Wn(s,o,a,i??[]);return x(n,"Command-line-args parsing completed","index"),g},"commandLineArgs");var li=Object.defineProperty,ci=$((t,e)=>li(t,"name",{value:e,configurable:!0}),"m$6");let ui=class{static{$(this,"a")}static{ci(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;env;logger;runtime;constructor(e,n){this.commandName=e,this.command=n}};var pi=Object.defineProperty,fi=$((t,e)=>pi(t,"name",{value:e,configurable:!0}),"f$4");const hi=/^-{1,2}(\w+)(=(.+))?$/,gt=fi((t,e,n,a)=>{const o=hi.exec(t);if(o==null)return{};const i=o[1];if(!i)return{};const u=n&&a?n.get(i)??a.get(i):e.find(s=>s.name===i||s.alias===i);return u!==void 0?{argName:u.name,argValue:o[3],option:u}:{}},"getParameterOption");var di=Object.defineProperty,Ae=$((t,e)=>di(t,"name",{value:e,configurable:!0}),"e$2");const Te=Ae((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)},"convertType"),mi=new Set(["0","1","false","true"]),gi=Ae((t,e,n,a)=>{if(e.length===0||t.length===0)return{};const o=Ae((i,u)=>{const{argName:s,argValue:g,option:r}=gt(u,e,n,a),{lastOption:p}=i;return r&&X(r)&&g&&s?i.partial[s]=Te(g,r):i.lastName&&p&&X(p)&&mi.has(u)&&(i.partial[i.lastName]=Te(u,p)),{lastName:s,lastOption:r,partial:i.partial}},"getBooleanValue");return t.reduce(o,{partial:{}}).partial},"getBooleanValues");var vi=Object.defineProperty,Re=$((t,e)=>vi(t,"name",{value:e,configurable:!0}),"s$8");const yi=new Set(["0","1","false","true"]),wi=Re((t,e,n,a)=>{if(e.length===0||t.length===0)return t;const o=Re((i,u)=>{const{argValue:s,option:g}=gt(u,e,n,a),{lastOption:r}=i;if(r&&X(r)&&yi.has(u)){const{args:p}=i;return{args:p.slice(0,-1)}}return g&&X(g)&&s?{args:i.args}:{args:[...i.args,u],lastOption:g}},"removeBooleanArguments");return t.reduce(o,{args:[]}).args},"removeBooleanValues");var bi=Object.defineProperty,$i=$((t,e)=>bi(t,"name",{value:e,configurable:!0}),"o$8");const De=$i(t=>{const e=new Map;for(const n of t){const a=e.get(n.name);a?e.set(n.name,{...a,...n}):e.set(n.name,n)}return[...e.values()]},"mergeArguments");var Oi=Object.defineProperty,se=$((t,e)=>Oi(t,"name",{value:e,configurable:!0}),"o$7");const Ei=se(t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},"transformBooleanEnv"),Ai=se((t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return Ei(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)}},"transformEnvValue"),Pi=se(t=>t.toLowerCase().replaceAll(/_./g,e=>e[1]?.toUpperCase()??e).replace(/^[A-Z]/,e=>e.toLowerCase()),"toCamelCase"),Ci=se(t=>{if(!t||t.length===0)return{};const e={},n=q();for(const a of t){const o=n[a.name],i=Ai(a,o),u=i===void 0?a.defaultValue:i,s=Pi(a.name);e[s]=u}return e},"processEnvVariables");var ki=Object.defineProperty,le=$((t,e)=>ki(t,"name",{value:e,configurable:!0}),"l$a");const Ni=le(t=>{const e=new Map,n=new Map;for(const a of t)if(e.set(a.name,a),a.alias){const o=Array.isArray(a.alias)?a.alias:[a.alias];for(const i of o)n.set(i,a)}return{optionMapByAlias:n,optionMapByName:e}},"buildOptionMaps"),xi=le((t,e,n,a)=>{const o=new ui(t.name,t),{_all:i,positionals:u}=e,s=Object.keys(n).length>0?{...i,...n}:i;te in s&&delete s[te],o.argument=u?.[te]??[];const g=Object.keys(a).length>0;return o.options=g?{...s,...a}:s,o.env=Ci(t.env),o},"prepareToolbox"),ji=le((t,e,n)=>{const a=t.options??[],o=a.length>0;let i=De(o?[...a,...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:te,type:t.argument?.type,typeLabel:t.argument?.typeLabel},...i]);let u,s;if(o){const{optionMapByAlias:r,optionMapByName:p}=Ni(a);u=wi(e,a,p,r),s=gi(e,a,p,r)}else u=e,s={};const g=si(i,{argv:u,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:i,booleanValues:s,parsedArgs:g}},"processCommandArgs"),B=le(async(t,e,n)=>await t.execute(e),"executeCommand");var _i=Object.defineProperty,Li=$((t,e)=>_i(t,"name",{value:e,configurable:!0}),"n$6");let Ii=class extends k{static{$(this,"s")}static{Li(this,"CommandValidationError")}commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}};var Si=Object.defineProperty,Ui=$((t,e)=>Si(t,"name",{value:e,configurable:!0}),"t$5");const Be=Ui((t,e,n=!1)=>{const a=[];for(const o of t)if(!(!n&&!o.required)&&e[o.name]===void 0){if(o.type?.name==="Boolean"){e[o.name]=!1;continue}a.push(o)}return a},"listMissingArguments");var Mi=Object.defineProperty,vt=$((t,e)=>Mi(t,"name",{value:e,configurable:!0}),"n$5");const Vi=vt((t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:zt(t,e)<=t.length/3,"isSimilar"),F=vt((t,e)=>{const n=t.toLowerCase();return e.filter(a=>Vi(a.toLowerCase(),n))},"findAlternatives");var Ti=Object.defineProperty,ce=$((t,e)=>Ti(t,"name",{value:e,configurable:!0}),"a$2");const Ri=ce((t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(a=>{const o=a.startsWith("--");let i=`Found unknown ${o?"option":"argument"} "${a}"`;if(o){const u=F(a.replace("--",""),(e.options??[]).map(s=>s.name));if(u.length>0){const[s,...g]=u.map(r=>`--${r}`);i+=g.length>0?`, did you mean ${s} or ${g.join(", ")}?`:`, did you mean ${s}?`}}n.push(i)}),n.length>0)throw new Error(n.join(`
2
- `))},"validateUnknownOptions"),Di=ce((t,e,n)=>{const a=n.__requiredOptions__?Be(n.__requiredOptions__,e,!0):Be(t,e,!1);if(a.length>0)throw new Ii(n.name,a.map(o=>o.name));e._unknown&&e._unknown.length>0&&!n.argument&&Ri(e,n)},"validateRequiredOptions"),Bi=ce((t,e,n)=>{const a=n.__conflictingOptions__??t.filter(o=>o.conflicts!==void 0);if(a.length>0){const o=a.find(i=>Array.isArray(i.conflicts)?i.conflicts.some(u=>e[u]!==void 0)&&e[i.name]!==void 0:e[i.conflicts]!==void 0&&e[i.name]!==void 0);if(o)throw new Qe(o.name,typeof o.conflicts=="string"?o.conflicts:o.conflicts?.[0]??"unknown")}},"validateConflictingOptions"),zi=ce(t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const o of t.options){if(o.name){const i=e.get(o.name)??[];i.push(o),e.set(o.name,i)}if(typeof o.alias=="string"&&o.alias.length>0){const i=n.get(o.alias)??[];i.push(o),n.set(o.alias,i)}else if(Array.isArray(o.alias)){for(const i of o.alias)if(i.length>0){const u=n.get(i)??[];u.push(o),n.set(i,u)}}}const a=[];for(const[o,i]of e)i.length>1&&a.push(`Duplicate option name "${o}" in command "${t.name}": ${JSON.stringify(i)}`);for(const[o,i]of n)i.length>1&&a.push(`Duplicate option alias "-${o}" used by options ${i.map(u=>`"${u.name}"`).join(", ")} in command "${t.name}"`);if(a.length>0)throw new Error(a.join(`
3
- `))},"validateDuplicateOptions");var Wi=Object.defineProperty,Ce=$((t,e)=>Wi(t,"name",{value:e,configurable:!0}),"r$7");const Fi=Ce((t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];for(let a=1;a<=e.length;a+=1){const o=e[a-1];if(o===void 0)break;n.push(o);const i=n.join(" ");if(t.has(i))return{argv:e.slice(a),commandPath:[...n]}}return{argv:e,commandPath:void 0}},"parseNestedCommand"),J=Ce(t=>t.join(" "),"getCommandPathKey"),qi=Ce((t,e)=>e&&e.length>0?[...e,t]:[t],"getFullCommandPath");var Gi=Object.defineProperty,Hi=$((t,e)=>Gi(t,"name",{value:e,configurable:!0}),"p$4"),Ki=Object.defineProperty,yt=Hi((t,e)=>Ki(t,"name",{value:e,configurable:!0}),"e"),Yi=Object.defineProperty,Ji=yt((t,e)=>Yi(t,"name",{value:e,configurable:!0}),"E");const wt=String.raw,ze=wt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Qi=Ji(()=>new RegExp(wt`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${ze}(?:\u200D${ze})*`,"gu"),"default");var Zi=Object.defineProperty,Xi=yt((t,e)=>Zi(t,"name",{value:e,configurable:!0}),"p");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 G=Qi(),ea=/[-_./\s]+/g,Z=/(\u001B\[[0-9;]*[a-z])/i,We=new RegExp("\\p{Script=Arabic}","u"),ta=new RegExp("\\p{Script=Bengali}","u"),z=new RegExp("\\p{Script=Cyrillic}","u"),na=new RegExp("\\p{Script=Devanagari}","u"),ia=new RegExp("\\p{Script=Ethiopic}","u"),ge=new RegExp("\\p{Script=Greek}","u"),aa=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),ra=new RegExp("\\p{Script=Gujarati}","u"),oa=new RegExp("\\p{Script=Gurmukhi}","u"),Fe=new RegExp("\\p{Script=Hangul}","u"),qe=new RegExp("\\p{Script=Hebrew}","u"),sa=new RegExp("\\p{Script=Hiragana}","u"),Ge=new RegExp("\\p{Script=Han}","u"),la=new RegExp("\\p{Script=Kannada}","u"),ca=new RegExp("\\p{Script=Katakana}","u"),ua=new RegExp("\\p{Script=Khmer}","u"),pa=new RegExp("\\p{Script=Lao}","u"),_=new RegExp("\\p{Script=Latin}","u"),fa=new RegExp("\\p{Script=Malayalam}","u"),ha=new RegExp("\\p{Script=Myanmar}","u"),da=new RegExp("\\p{Script=Oriya}","u"),ma=new RegExp("\\p{Script=Sinhala}","u"),ga=new RegExp("\\p{Script=Tamil}","u"),va=new RegExp("\\p{Script=Telugu}","u"),ya=new RegExp("\\p{Script=Thai}","u"),wa=new RegExp("\\p{Script=Tibetan}","u"),He=/[\u02BB\u02BC\u0027]/u,ba=Xi(t=>t.replace(G,""),"stripEmoji");var $a=Object.defineProperty,bt=$((t,e)=>$a(t,"name",{value:e,configurable:!0}),"i$6"),Oa=Object.defineProperty,$t=bt((t,e)=>Oa(t,"name",{value:e,configurable:!0}),"r"),Ea=Object.defineProperty,Aa=$t((t,e)=>Ea(t,"name",{value:e,configurable:!0}),"c");let Ot=class{static{$(this,"l")}static{bt(this,"y")}static{$t(this,"s")}static{Aa(this,"LRUCache")}capacity;cache;keyOrder;constructor(e){this.capacity=e,this.cache=new Map,this.keyOrder=[]}get(e){if(this.cache.has(e))return this.keyOrder=this.keyOrder.filter(n=>n!==e),this.keyOrder.push(e),this.cache.get(e)}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.keyOrder=this.keyOrder.filter(a=>a!==e);else if(this.cache.size>=this.capacity){const a=this.keyOrder.shift();a!==void 0&&this.cache.delete(a)}this.cache.set(e,n),this.keyOrder.push(e)}delete(e){this.cache.delete(e),this.keyOrder=this.keyOrder.filter(n=>n!==e)}clear(){this.cache.clear(),this.keyOrder=[]}size(){return this.cache.size}};var Pa=Object.defineProperty,Ca=$((t,e)=>Pa(t,"name",{value:e,configurable:!0}),"r$5"),ka=Object.defineProperty,Na=Ca((t,e)=>ka(t,"name",{value:e,configurable:!0}),"a"),xa=Object.defineProperty,ja=Na((t,e)=>xa(t,"name",{value:e,configurable:!0}),"s");const _a=ja((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleLowerCase(e.locale):t[0].toLowerCase())+t.slice(1),"lowerFirst");var La=Object.defineProperty,Ia=$((t,e)=>La(t,"name",{value:e,configurable:!0}),"I"),Sa=Object.defineProperty,ue=Ia((t,e)=>Sa(t,"name",{value:e,configurable:!0}),"j");const Ua=Wt(import.meta.url),Q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ma=ue(t=>{if(typeof Q<"u"&&Q.versions&&Q.versions.node){const[e,n]=Q.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return Q.getBuiltinModule(t)}return Ua(t)},"__cjs_getBuiltinModule"),{stripVTControlCharacters:Va}=Ma("node:util");var Ta=Object.defineProperty,Ra=ue((t,e)=>Ta(t,"name",{value:e,configurable:!0}),"g");const ve=new Ot(1e3),Da=Ra(t=>{const e=t.join("");if(ve.has(e))return ve.get(e);const n=t.map(o=>o.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)).join("|"),a=new RegExp(n,"g");return ve.set(e,a),a},"getSeparatorsRegex");var Ba=Object.defineProperty,za=ue((t,e)=>Ba(t,"name",{value:e,configurable:!0}),"t");const Wa=za(t=>{const e=[];let n=0,a;for(G.lastIndex=0;(a=G.exec(t))!==null;)a.index>n&&e.push(t.slice(n,a.index)),e.push(a[0]),n=G.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},"splitByEmoji");var Fa=Object.defineProperty,C=ue((t,e)=>Fa(t,"name",{value:e,configurable:!0}),"u");const Et=new Uint8Array(128),At=new Uint8Array(128),Pt=new Uint8Array(128);for(let t=0;t<128;t++)Et[t]=t>=65&&t<=90?1:0,At[t]=t>=97&&t<=122?1:0,Pt[t]=t>=48&&t<=57?1:0;const ye=C(t=>Et[t],"isUpper"),Ke=C(t=>At[t],"isLower"),we=C(t=>Pt[t],"isDigit"),U=C((t,e,n,a,o)=>{if(t.length===0)return[];let i=!1;for(const c of Object.values(e))if(c(t[0])){i=!0;break}if(!i&&!n)return[t];const u=[...t],s=[];let g=u[0],r="other";for(const[c,l]of Object.entries(e))if(l(u[0])){r=c;break}let p=n&&a?u[0]===u[0].toLocaleUpperCase(a):!1;for(let c=1;c<u.length;c++){const l=u[c];let d="other";for(const[b,w]of Object.entries(e))if(w(l)){d=b;break}const h=n&&a?l===l.toLocaleUpperCase(a):!1;let O=!1;o?O=o(r,d,p,h,l,c,u):(r!==d&&r!=="other"&&d!=="other"&&(O=!0),n&&d!=="other"&&!p&&h&&(O=!0)),O?(s.push(g),g=l):g+=l,r=d,n&&(p=h)}return g&&g.length>0&&s.push(g),s.length>0?s:[t]},"handleScriptTransitions"),qa=C((t,e,n,a)=>{if(n.size===0)return e;for(const o of n)if(t.startsWith(o,e))return a.push(o),e+o.length;return e},"detectAndProcessAcronym"),Ct=C((t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const a=[],o=t.length;for(let i=1;i<o;i++){const u=qa(t,n,e,a);if(u!==n){n=u,i=n-1;continue}const s=t.codePointAt(i-1),g=t.codePointAt(i),r=s&&s<128&&ye(s),p=g&&g<128&&ye(g),c=s&&s<128&&Ke(s),l=s&&s<128&&we(s),d=g&&g<128&&we(g);if(c&&p){a.push(t.slice(n,i)),n=i;continue}if(l&&!d||!l&&d){a.push(t.slice(n,i)),n=i;continue}if(d&&!l){let h=!1,O=!1;if(i+1<o){const b=t.codePointAt(i+1);h=b&&b<128&&ye(b),O=b&&b<128&&we(b)}if(!O&&h){a.push(t.slice(n,i),t.slice(i,i+1)),n=i+1;continue}}if(i+1<o){const h=t.codePointAt(i+1),O=h&&h<128&&Ke(h);if(r&&p&&O){const b=t.slice(n,i+1);e.has(b)||(a.push(t.slice(n,i)),n=i)}}}return n<o&&a.push(t.slice(n)),a.filter(i=>i!=="")},"splitCamelCaseFast"),kt=C((t,e,n)=>{if(t.length===0)return[];const a=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!a&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const r=[...t],p=r.length,c=[];let l=r[0],d=r[0]===r[0].toLocaleUpperCase(e),h=d,O=d?0:-1;for(let b=1;b<p;b++){const w=r[b],P=w===w.toLocaleUpperCase(e);if(P===d)l+=w;else if(P)l&&l.length>0&&(c.push(l),l=w),h=!0,O=b;else{if(h&&b-O>1){const f=r[b-1],m=l.slice(0,-1);m&&m.length>0&&c.push(m),l=f+w}else l+=w;h=!1,O=-1}d=P}return l&&l.length>0&&c.push(l),c}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!z.test(t)&&!_.test(t))return[t];const r=[...t],p=r.length,c=[];let l=r[0];const d=r[0];let h;z.test(d)?h=1:_.test(d)?h=2:h=0;let O=d===d.toLocaleUpperCase(e);for(let w=1;w<p;w++){const P=r[w];let f;z.test(P)?f=1:_.test(P)?f=2:f=0;const m=P===P.toLocaleUpperCase(e);h!==f&&(h===1||h===2)&&(f===1||f===2)||f===h&&!O&&m?(c.push(l),l=P):l+=P,h=f,O=m}l&&l.length>0&&c.push(l);const b=[];for(let w=0;w<c.length;w++)w<c.length-1&&c[w].length===1&&_.test(c[w])&&z.test(c[w+1][0])?(b.push(c[w]+c[w+1]),w+=1):b.push(c[w]);return b}if(e.startsWith("el")){if(!ge.test(t)&&!_.test(t))return[t];const r=t.match(aa)??[t],p=[];if(r.length===1){const c=r[0];if(!c||!ge.test(c[0])||c.length===1)return[c||t]}for(const c of r){if(!c)continue;if(!ge.test(c[0])||c.length===1){p.push(c);continue}const l=c.length;let d=c[0],h=c[0]===c[0].toLocaleUpperCase(e);for(let O=1;O<l;O++){const b=c[O],w=b===b.toLocaleUpperCase(e);!h&&w?(p.push(d),d=b):d+=b,h=w}d&&p.push(d)}return p}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),p=r?{hiragana:C(l=>sa.test(l),"hiragana"),kanji:C(l=>Ge.test(l),"kanji"),katakana:C(l=>ca.test(l),"katakana"),latin:C(l=>_.test(l),"latin")}:{hangul:C(l=>Fe.test(l),"hangul"),latin:C(l=>_.test(l),"latin")},c=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const l=U(t,p,!1,e,(h,O)=>h==="hiragana"&&O==="katakana"||h==="katakana"&&O==="hiragana"||h==="hiragana"&&O==="latin"||h==="katakana"&&O==="latin"||h==="kanji"&&O==="latin"||h==="latin"&&(O==="hiragana"||O==="katakana"||O==="kanji")),d=[];for(const h of l)h.length===1&&c.has(h)&&d.length>0?d[d.length-1]+=h:d.push(h);return d.length>0?d:[t]}return U(t,p,!1,e,(l,d)=>l==="hangul"&&d==="latin"||l==="latin"&&d==="hangul")}if(e.startsWith("sl")){const r=[...t],p=r.length,c=[];let l=r[0],d=r[0]===r[0].toLocaleUpperCase(e);for(let h=1;h<p;h++){const O=r[h],b=O===O.toLocaleUpperCase(e),w=/[ČŠŽĐ]/i.test(O),P=h<p-1&&r[h+1]===r[h+1].toLocaleUpperCase(e);!d&&b||w&&P?(c.push(l),l=O,w&&P&&(c.push(l),l="")):l+=O,d=b}return l&&l.length>0&&c.push(l),c}if(e.startsWith("zh"))return U(t,{han:C(r=>Ge.test(r),"han"),latin:C(r=>_.test(r),"latin")},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=C(p=>qe.test(p)||We.test(p),"isRtlChar");return U(t,{latin:C(p=>_.test(p),"latin"),rtl:C(p=>r(p),"rtl")},!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=C(p=>na.test(p)||ta.test(p)||ra.test(p)||oa.test(p)||la.test(p)||ga.test(p)||va.test(p)||fa.test(p)||ma.test(p)||ya.test(p)||pa.test(p)||wa.test(p)||ha.test(p)||ia.test(p)||ua.test(p)||da.test(p),"isIndicChar");return U(t,{indic:C(p=>r(p),"indic"),latin:C(p=>_.test(p),"latin")},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return U(t,{cyrillic:C(r=>z.test(r),"cyrillic"),latin:C(r=>_.test(r),"latin")},!0,e);if(["ar","fa","he"].includes(e))return U(t,{latin:C(r=>_.test(r),"latin"),rtl:C(r=>qe.test(r)||We.test(r),"rtl")},!1,e);if(e.startsWith("ko"))return U(t,{hangul:C(r=>Fe.test(r),"hangul"),latin:C(r=>_.test(r),"latin")},!1,e);if(e.startsWith("uz")){if(!z.test(t)&&!_.test(t))return[t];const r=[...t],p=r.length,c=[];let l=r[0],d=r[0]===r[0].toLocaleUpperCase(e);for(let h=1;h<p;h++){const O=r[h],b=O===O.toLocaleUpperCase(e);if(He.test(O)||He.test(r[h-1])){l+=O;continue}!d&&b?(c.push(l),l=O):l+=O,d=b}return l&&l.length>0&&c.push(l),c}const o=[...t],i=o.length,u=[];let s=o[0],g=o[0]===o[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){u.push(r),s=o[r.length],g=s===s.toLocaleUpperCase(e);break}for(let r=1;r<i;r++){const p=o[r],c=p===p.toLocaleUpperCase(e);let l=0;for(const d of n)if(t.startsWith(d,r)){u.push(s,d),l=d.length,s="";const h=d[d.length-1];h&&(g=h===h.toLocaleUpperCase(e));break}if(l>0){r+=l-1;continue}!g&&c?(u.push(s),s=p):s+=p,g=c}return s&&u.push(s),u},"splitCamelCaseLocale"),Ga=C((t,e,n)=>{const a=[],o=Z.test(t)?t.split(Z).filter(Boolean):[t];for(const i of o)if(Z.test(i))a.push(i);else{const u=G.test(i)?Wa(i).filter(Boolean):[i];for(const s of u)if(G.test(s))a.push(s);else if(e){const g=e.toLowerCase().split("-")[0];a.push(...kt(s,g,n))}else a.push(...Ct(s,n))}return a},"processTextWithAnsiEmoji"),Ha=C((t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:a=!1,knownAcronyms:o=[],locale:i,normalize:u=!1,separators:s,stripAnsi:g=!1,stripEmoji:r=!1}=e,p=new Set([...o].toSorted((w,P)=>P.length-w.length));let c=t;g&&(c=Va(c)),r&&(c=ba(c));let l;Array.isArray(s)?l=Da(s):s instanceof RegExp?l=s:l=ea;const d=[];let h=c;const O=l.flags.includes("g")?l:new RegExp(l.source,`${l.flags}g`);for(;h.length>0;){const w=O.exec(h);if(!w){h===".."?d.push(".."):h==="."?d.push("."):h.length>0&&d.push(h);break}const P=w.index,f=w[0],m=f.length,v=h.slice(0,P),y=h.slice(P+m);if(f.startsWith("../"))d.push(".."),h=h.slice(P+3);else if(f.startsWith("./"))d.push("."),h=h.slice(P+2);else if(P===0&&f==="..")d.push(".."),h=h.slice(2);else if(P===0&&f===".")d.push("."),h=h.slice(1);else{v.length>0&&d.push(v);let E=0;for(;(E=f.indexOf("../",E))!==-1;)d.push(".."),E+=3;for(E=0;(E=f.indexOf("./",E))!==-1;)(E===0||f[E-1]!==".")&&d.push("."),E+=2;let N=y;for(;N.startsWith("../");)d.push(".."),N=N.slice(3);for(;N.startsWith("./");)d.push("."),N=N.slice(2);if(N===".."){d.push("..");break}else if(N==="."){d.push(".");break}else h=N}O.lastIndex=0}if(d.length===0){const w=c.split(l).filter(Boolean);d.push(...w)}let b=[];for(const w of d)n||a?b.push(...Ga(w,i,p)):i?b.push(...kt(w,i,p)):b.push(...Ct(w,p));return u&&(b=b.map(w=>p.has(w)?w:i&&w===w.toLocaleUpperCase(i)?w[0]+w.slice(1).toLocaleLowerCase(i):w.toUpperCase()===w&&!p.has(w)?w.slice(0,1)+w.slice(1).toLowerCase():w)),b},"splitByCase");var Ka=Object.defineProperty,Ya=$((t,e)=>Ka(t,"name",{value:e,configurable:!0}),"r$4"),Ja=Object.defineProperty,Qa=Ya((t,e)=>Ja(t,"name",{value:e,configurable:!0}),"o"),Za=Object.defineProperty,Xa=Qa((t,e)=>Za(t,"name",{value:e,configurable:!0}),"s");const er=Xa((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleUpperCase(e.locale):t[0].toUpperCase())+t.slice(1),"upperFirst");var tr=Object.defineProperty,nr=$((t,e)=>tr(t,"name",{value:e,configurable:!0}),"r$3"),ir=Object.defineProperty,ar=nr((t,e)=>ir(t,"name",{value:e,configurable:!0}),"r"),rr=Object.defineProperty,or=ar((t,e)=>rr(t,"name",{value:e,configurable:!0}),"n");const sr=or((t,e)=>`${t}::${e?.joiner??""}::${e?.locale??""}::${e?.knownAcronyms?.join(",")??""}::${e?.normalize?"true":"false"}`,"generateCacheKey");var lr=Object.defineProperty,cr=$((t,e)=>lr(t,"name",{value:e,configurable:!0}),"i$4"),ur=Object.defineProperty,pr=cr((t,e)=>ur(t,"name",{value:e,configurable:!0}),"a"),fr=Object.defineProperty,hr=pr((t,e)=>fr(t,"name",{value:e,configurable:!0}),"l");const dr=hr((t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const a=[];let o="",i="";for(let u=0;u<n;u++){const s=t[u];if(Z.test(s)){o?(a.push(o+i+s),o="",i=""):(a.length>0&&a.push(e),o=s);continue}o?(i&&(i+=e),i+=s):(a.length>0&&a.push(e),a.push(s))}return a.join("")},"joinSegments");var mr=Object.defineProperty,gr=$((t,e)=>mr(t,"name",{value:e,configurable:!0}),"r$2"),vr=Object.defineProperty,yr=gr((t,e)=>vr(t,"name",{value:e,configurable:!0}),"a"),wr=Object.defineProperty,br=yr((t,e)=>wr(t,"name",{value:e,configurable:!0}),"t");const $r=br(t=>t.replaceAll(/(?<![a-zß])SS(?![a-z])/g,"ß"),"normalizeGermanEszett");var Or=Object.defineProperty,Er=$((t,e)=>Or(t,"name",{value:e,configurable:!0}),"l$2"),Ar=Object.defineProperty,Pr=Er((t,e)=>Ar(t,"name",{value:e,configurable:!0}),"n"),Cr=Object.defineProperty,kr=Pr((t,e)=>Cr(t,"name",{value:e,configurable:!0}),"l");const Nr=new Ot(1e3),Nt=kr((t,e)=>{if(typeof t!="string"||!t)return"";const n=e?.cache??!1,a=e?.cacheStore??Nr;let o;if(n&&(o=sr(t,e)),n&&o&&a.has(o))return a.get(o);let i=!0;const u=dr(Ha(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(s=>e?.handleAnsi&&Z.test(s)?s:(s=e?.locale?.startsWith("de")?$r(s):s,s=e?.locale?s.toLocaleLowerCase(e.locale):s.toLowerCase(),i?(i=!1,_a(s,e)):er(s,e))),"");return n&&o&&a.set(o,u),u},"camelCase");var xr=Object.defineProperty,pe=$((t,e)=>xr(t,"name",{value:e,configurable:!0}),"a");const jr=pe(t=>{t.options?.forEach(e=>{e.__camelCaseName__=Nt(e.name)})},"processOptionNames"),_r=pe(t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const a of t.options)e.add(a.name);const n=[];for(const a of t.options)if(a.name.startsWith("no-")){const o=a.name.replace("no-","");if(!e.has(o)){if(a.type!==Boolean)throw new Error(`Cannot add negated option "${a.name}" to command "${t.name}" because it is not a boolean.`);const i={...a,defaultValue:a.defaultValue===void 0?!0:!a.defaultValue,name:o};n.push(i),e.add(o)}}n.length>0&&t.options.push(...n)},"addNegatableOptions"),Lr=pe((t,e)=>{if(!e.options||e.options.length===0)return;const n=t.options,a=new Map;for(const i of e.options)if(i.name.startsWith("no-")){const u=Nt(i.name);a.set(u,i)}const o=Object.keys(n).filter(i=>a.has(i));if(o.length!==0)for(const i of o){const u=i.charAt(2);if(!u)continue;const s=u.toLowerCase()+i.slice(3),g=a.get(i);g&&(g.__negated__=!0),n[s]=!n[i],Reflect.deleteProperty(n,i)}},"mapNegatableOptions"),Ir=pe((t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const o of e.options)o.__camelCaseName__&&o.__negated__===void 0&&o.implies!==void 0&&n.set(o.__camelCaseName__,o);if(n.size===0)return;const a=t.options;for(const o of Object.keys(a)){const i=n.get(o);if(i?.implies){const u=i.implies;for(const[s,g]of Object.entries(u))a[s]===void 0&&(a[s]=g)}}},"mapImpliedOptions");var Sr=Object.defineProperty,fe=$((t,e)=>Sr(t,"name",{value:e,configurable:!0}),"e$1");const Ur=fe(()=>!!process.versions.electron,"isElectronApp"),Mr=fe(()=>Ur()&&!process.defaultApp,"isBundledElectronApp"),Vr=fe(()=>Mr()?0:1,"getProcessArgvBinIndex"),Tr=fe(t=>t.slice(Vr()+1),"hideBin");var Rr=Object.defineProperty,xt=$((t,e)=>Rr(t,"name",{value:e,configurable:!0}),"s$2");const Dr=" ",Br=xt((t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,a)=>n===e[a]),"equals"),zr=xt(t=>{if(typeof t=="string")return t.split(Dr);const e=Ee();return Br(t,e)?Tr(t):t},"parseRawCommand");var Wr=Object.defineProperty,be=$((t,e)=>Wr(t,"name",{value:e,configurable:!0}),"r");const Fr=be(t=>{const e=be(i=>{t.error(`Uncaught exception: ${i.message||i}`),i.stack&&t.error(i.stack),ie(1)},"uncaughtExceptionHandler"),n=be((i,u)=>{if(i instanceof Error)t.error(`Promise rejection: ${i.message||i}`),i.stack&&t.error(i.stack);else{let s;if(typeof i=="string")s=i;else try{s=JSON.stringify(i)}catch{s=String(i)}t.error(`Promise rejection: ${s}`)}ie(1)},"unhandledRejectionHandler"),a=xe("uncaughtException",e),o=xe("unhandledRejection",n);return()=>{a(),o()}},"registerExceptionHandler");var qr=Object.defineProperty,K=$((t,e)=>qr(t,"name",{value:e,configurable:!0}),"e");const ae=100,ke=K((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()},"validateNonEmptyString"),Ye=K((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},"validateStringArray");K((t,e)=>{if(typeof t!="function")throw new k(`${e} must be a function`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateFunction");const $e=K((t,e)=>{if(typeof t!="object"||t===null)throw new k(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateObject"),ee=K(t=>{const e=ke(t,"Command name");if(e.length>ae)throw new k(`Command name is too long (maximum ${ae} 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(!/^[a-z][\w-]*$/i.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},"validateCommandName");K(t=>{const e=ke(t,"Plugin name");if(e.length>ae)throw new k(`Plugin name is too long (maximum ${ae} characters)`,"INVALID_PLUGIN_NAME",{length:e.length,pluginName:e});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new k(`Plugin name "${e}" contains invalid characters`,"INVALID_PLUGIN_NAME",{pluginName:e});if(!/^[a-z][\w-]*$/i.test(e))throw new k(`Plugin name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_PLUGIN_NAME",{pluginName:e});return e},"validatePluginName");var Gr=Object.defineProperty,he=$((t,e)=>Gr(t,"name",{value:e,configurable:!0}),"s");const Hr=new Set([`
4
- `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Kr=he(t=>{if(typeof t!="string")throw new TypeError("Argument must be a string");if(t.length>1e4)throw new Error("Argument is too long (maximum 10000 characters)");for(const e of t)if(Hr.has(e))throw new Error(`Argument contains dangerous character: ${e}`);return t.trim()},"sanitizeArgument"),Je=he(t=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");if(t.length>100)throw new Error("Too many arguments (maximum 100)");return t.map(e=>Kr(e))},"sanitizeArguments");he(t=>{if(typeof t!="string")throw new TypeError("Path must be a string");const e=t.trim();if(e.includes("..")||e.includes("../")||e.includes("..\\"))throw new Error("Path contains directory traversal sequences");if(e.startsWith("/")||/^[A-Z]:/i.test(e))throw new Error("Absolute paths are not allowed");if(e.length>1e3)throw new Error("Path is too long");return e},"validateSafePath");class mo{static{$(this,"RateLimiter")}static{he(this,"RateLimiter")}attempts=new Map;maxAttempts;windowMs;constructor(e=5,n=6e4){if(e<=0||n<=0)throw new Error("maxAttempts and windowMs must be positive numbers");this.maxAttempts=e,this.windowMs=n}checkLimit(e){const n=Date.now(),a=this.attempts.get(e);return!a||n>a.resetTime?(this.attempts.set(e,{count:1,resetTime:n+this.windowMs}),this.cleanup(n),!0):a.count>=this.maxAttempts?!1:(a.count+=1,!0)}reset(e){this.attempts.delete(e)}cleanup(e){for(const[n,a]of this.attempts.entries())e>a.resetTime&&this.attempts.delete(n)}}var Yr=Object.defineProperty,ne=$((t,e)=>Yr(t,"name",{value:e,configurable:!0}),"_");const Jr=/^-([^\d-])$/,Qr=/^--(\S+)/,Zr=/^-([^\d-]{2,})$/,Oe=ne(t=>Jr.test(t)||Qr.test(t)||Zr.test(t),"isOption");class go{static{$(this,"Cli")}static{ne(this,"Cli")}#t;#e;#r;#c;#g;#u;#v;#o;#n;#i;#p;#s;#l;#f=!1;#y;#w=!1;#h;#d;#m;#E(){return this.#h===void 0&&(this.#h=[...this.#i.keys()]),this.#h}#b(){return this.#d===void 0&&(this.#d=[...this.#n.keys()]),this.#d}#a(){return this.#m===void 0&&(this.#m=[...this.#E(),...this.#b()]),this.#m}#A(){this.#h=void 0,this.#d=void 0,this.#m=void 0}#$(){if(this.#r===void 0){const e=zr(this.#e.argv);this.#r=Je(e),this.#P()}return this.#r}#P(){if(!this.#r)return;const e=q();let n=!1;for(const a of this.#r){if(a==="--quiet"||a==="-q"){e.CEREBRO_OUTPUT_LEVEL=String(Vt),n=!0;break}if(a==="--verbose"||a==="-v"){e.CEREBRO_OUTPUT_LEVEL=String(Tt),n=!0;break}if(a==="--debug"||a==="-vvv"){e.CEREBRO_OUTPUT_LEVEL=String(W),n=!0;break}}n||(e.CEREBRO_OUTPUT_LEVEL=Object.hasOwn(e,"DEBUG")?String(W):String(Ne))}#C(){this.#w||(this.#y=Fr(this.#t),this.#w=!0)}#O(e,n,a,o){this.#t.debug(`command '${o}' found, parsing command args: ${n.join(", ")}`);const{arguments_:i,booleanValues:u,parsedArgs:s}=ji(e,n,Ut),g=Object.keys(u).length>0?{...s,_all:{...s._all,...u}}:s;Di(i,g,e);const r=xi(e,s,u,a);r.runtime=this,r.argv=this.#$();const p=e.options&&e.options.length>0;if(p&&e.options){const c=e.options.filter(l=>l.name.startsWith("no-"));for(const l of c){const d=l.name.replace("no-",""),h=`--${l.name}`,O=`--${d}`,b=n.includes(h),w=n.includes(O);if(b&&w)throw new Qe(d,l.name)}}return p&&(Lr(r,e),Ir(r,e)),Bi(i,r.options,e),q().CEREBRO_OUTPUT_LEVEL===String(W)&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(r.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(r.argument,null,2))),{arguments_:i,booleanValues:u,commandArgs:g,parsedArgs:s,toolbox:r}}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.#g=e.trim();const a=n.argv??Ee(),o=n.cwd??Rt();if(this.#e={...n,argv:a,cwd:o},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});const i=q();if(i.CEREBRO_OUTPUT_LEVEL=String(Ne),typeof this.#e.logger=="object"){const u=["debug","error","info","log","warn"],s=[],g=this.#e.logger;for(const r of u)typeof g[r]!="function"&&s.push(r);if(s.length>0)throw new k(`Logger object is missing required methods: ${s.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:s});this.#t=this.#e.logger}else this.#t={...console,debug:ne((...u)=>{i.CEREBRO_OUTPUT_LEVEL===String(W)&&console.debug(...u)},"debug")};this.#u=this.#e.packageVersion,this.#v=this.#e.packageName,this.#c=this.#e.cwd,this.#s="help",this.#l={},this.#n=new Map,this.#i=new Map,this.#p=new Map}setCommandSection(e){return this.#l=e,this}getCommandSection(){return this.#l.header||(this.#l.header=`${this.#g}${this.#u?` v${this.#u}`:""}`),this.#l}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){$e(e,"Command"),ee(e.name),e.alias&&(typeof e.alias=="string"?ee(e.alias):Ye(e.alias,"Command alias").forEach(o=>ee(o))),e.argument&&$e(e.argument,"Command argument"),e.options&&$e(e.options,"Command options"),e.commandPath&&(Ye(e.commandPath,"Command commandPath"),e.commandPath.forEach(o=>{ee(o)}));const n=qi(e.name,e.commandPath),a=J(n);if(this.#i.has(a))throw new k(`Command with path "${a}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});if(this.#n.has(e.name)&&!e.commandPath)throw new k(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const o of e.options)an(o);if(zi(e),_r(e),jr(e),e.options&&(e.__conflictingOptions__=e.options.filter(o=>o.conflicts!==void 0),e.__requiredOptions__=e.options.filter(o=>o.required===!0)),this.#n.set(e.name,e),this.#i.set(a,n),this.#p.set(a,e),this.#A(),e.alias!==void 0){const o=typeof e.alias=="string"?[e.alias]:e.alias;for(const i of o){if(q().CEREBRO_OUTPUT_LEVEL===String(W)&&this.#t.debug("adding alias",i),this.#n.has(i))throw new k(`Command alias "${i}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:i,commandName:e.name});this.#n.set(i,e)}}return this}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#o?this.#o:(this.#o=new Zt(this.#t),this.#o.register({description:"Attaches the logger to the toolbox",execute:ne(e=>{e.logger=this.#t},"execute"),name:"logger"}),this.#o)}getCliName(){return this.#g}getPackageVersion(){return this.#u}getPackageName(){return this.#v}getCommands(){return this.#n}getCwd(){return this.#c}dispose(){this.#y?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:a=!0,...o}=e;this.#n.has("help")||this.addCommand(new Mt(this.#n));const i=this.#b(),u=this.#i;this.#C();const s=this.#$();let g,r=[...s];const p=Dt(),c=Bt(),l=Ee();this.#t.debug(`process.execPath: ${p}`),this.#t.debug(`process.execArgv: ${c.join(" ")}`),this.#t.debug(`process.argv: ${l.join(" ")}`);const d=Fi(u,[...s]);if(d.commandPath)g=d.commandPath,r=d.argv;else{if(s.length>1&&s[0]&&s[1]&&!Oe(s[0])&&!Oe(s[1])){const y=[];let E=0;for(;E<s.length;){const A=s[E];if(!A||Oe(A))break;y.push(A),E+=1}const N=J(y);if(y[0]&&!i.includes(y[0])){const A=this.#a(),I=F(N,A);throw new D(N,I)}}let v;try{v=un([null,...i],[...s])}catch(y){if(y instanceof Error&&y.name==="INVALID_COMMAND"&&"command"in y){const E=y.command,N=this.#a(),A=F(E,N);throw new D(E,A)}throw y}v.command&&(g=[v.command],r=v.argv)}if(!g)if(this.#s)g=[this.#s];else{const v=this.#a();throw new D("",v)}const h=J(g),O=this.#i.get(h);let b;if(O){if(b=this.#p.get(h),!b||J(O)!==h){const v=this.#a(),y=F(h,v);throw new D(h,y)}}else{const v=g[g.length-1];if(b=v?this.#n.get(v):void 0,!b){const y=this.#a(),E=F(h,y);throw new D(h,E)}}if(typeof b.execute!="function")return this.#t.error(`Command "${b.name}" has no function to execute.`),a?ie(1):void 0;const w=r,{commandArgs:P,toolbox:f}=this.#O(b,w,o,h),m=this.getPluginManager();try{!this.#f&&m.hasPlugins()&&(await m.init({cli:this,cwd:this.#c,logger:this.#t}),this.#f=!0),await m.executeLifecycle("execute",f),await m.executeLifecycle("beforeCommand",f);let v;if(P.global?.help){const y=this.#n.get("help");if(!y)throw new k("Help command not found","COMMAND_NOT_FOUND");v=await B(y,f,P)}else if(P.global?.version||P.global?.V){const y=this.#n.get("version");if(!y)throw new k("Version command not found","COMMAND_NOT_FOUND");v=await B(y,f,P)}else v=await B(b,f,P);return await m.executeLifecycle("afterCommand",f,v),a?ie(0):void 0}catch(v){throw await m.executeErrorHandlers(v,f),v}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:a=[],...o}=n;ke(e,"Command name");const i=e.split(" ").filter(Boolean),u=J(i),s=this.#i.get(u)?this.#p.get(u):this.#n.get(e);if(!s){const l=this.#a(),d=F(u||e,l);throw new D(e,d)}if(typeof s.execute!="function")throw new k(`Command "${s.name}" has no function to execute`,"INVALID_COMMAND",{commandName:s.name});const g=[...Je(a)];this.#t.debug(`running command '${e}' programmatically with args: ${g.join(", ")}`);const{commandArgs:r,toolbox:p}=this.#O(s,g,o,u||e),c=this.getPluginManager();try{!this.#f&&c.hasPlugins()&&(await c.init({cli:this,cwd:this.#c,logger:this.#t}),this.#f=!0),await c.executeLifecycle("execute",p),await c.executeLifecycle("beforeCommand",p);let l;if(r.global?.help){const d=this.#n.get("help");if(!d)throw new k("Help command not found","COMMAND_NOT_FOUND");l=await B(d,p,r)}else if(r.global?.version||r.global?.V){const d=this.#n.get("version");if(!d)throw new k("Version command not found","COMMAND_NOT_FOUND");l=await B(d,p,r)}else l=await B(s,p,r);return await c.executeLifecycle("afterCommand",p,l),l}catch(l){throw await c.executeErrorHandlers(l,p),l}}}export{go as Cli};
@@ -1 +0,0 @@
1
- const O=1,T=2,E=4,I=16,R=32,U=64,_=128,S="positionals";export{O as OUTPUT_NORMAL,E as OUTPUT_PLAIN,T as OUTPUT_RAW,S as POSITIONALS_KEY,_ as VERBOSITY_DEBUG,R as VERBOSITY_NORMAL,I as VERBOSITY_QUIET,U as VERBOSITY_VERBOSE};
@@ -1 +0,0 @@
1
- var h=Object.defineProperty;var i=(s,t)=>h(s,"name",{value:t,configurable:!0});var m=Object.defineProperty,e=i((s,t)=>m(s,"name",{value:t,configurable:!0}),"i");const E=e(s=>s instanceof Error&&s.type==="VisulimaError","isVisulimaError");class V extends Error{static{i(this,"m")}static{e(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:t,hint:r,location:a,message:o,name:c,stack:n,title:l}){super(o,{cause:t}),this.title=l,this.name=c,this.stack=n??this.stack,this.loc=a,this.hint=r}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}}export{V as VisulimaError,E as isVisulimaError};
@@ -1 +0,0 @@
1
- var a=Object.defineProperty;var t=(e,r)=>a(e,"name",{value:r,configurable:!0});import{VisulimaError as c}from"./VisulimaError-rZ7cJo5A.js";var i=Object.defineProperty,n=t((e,r)=>i(e,"name",{value:r,configurable:!0}),"e");class b extends c{static{t(this,"c")}static{n(this,"CerebroError")}code;context;constructor(r,o,s){super({message:r,name:"CerebroError"}),this.code=o,this.context=s}}export{b as c};
@@ -1 +0,0 @@
1
- var E=Object.defineProperty;var g=(i,r)=>E(i,"name",{value:r,configurable:!0});import{green as d,inverse as s,cyan as c,yellow as f}from"@visulima/colorize";import{f as y,p as $}from"./index-DQ3pvLQH.js";const O=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],C=[{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}];var N=Object.defineProperty,u=g((i,r)=>N(i,"name",{value:r,configurable:!0}),"p");const b="__Other",v=u(i=>i.charAt(0).toUpperCase()+i.slice(1),"upperFirstChar"),A=u((i,r,p,t)=>{i.debug("no command given, printing general help...");let n=[...new Set(p.values())].filter(e=>!e.hidden);t&&(n=n.filter(e=>e.group===t));const a=n.reduce((e,o)=>{const l=o.group??b;return e[l]||(e[l]=[]),e[l].push(o),e},{}),m=u(e=>e.map(o=>{let l="";typeof o.alias=="string"?l=o.alias:Array.isArray(o.alias)&&(l=o.alias.join(", ")),l!==""&&(l=` [${l}]`);let h=o.name;return o.commandPath&&o.commandPath.length>0&&(h=`${o.commandPath.join(" ")} ${o.name}`),[`${d(h)}${l}`,o.description??""]}),"buildCommandList");(i?.raw??i.log)($([{content:`${c(r.getCliName())} ${d("<command>")} [positional arguments] ${f("[options]")}`,header:s.cyan(" Usage ")},...Object.keys(a).map(e=>{const o=t?` ${v(t)}`:"";return{content:m(a[e]),header:e===b||t?s.green(` Available${o} Commands `):` ${s.green(` ${v(e)} `)}`}}),p.has("help")?{header:s.yellow(" Command Options "),optionList:p.get("help").options?.filter(e=>!e.hidden)}:void 0,{header:s.yellow(" Global Options "),optionList:C},{content:O.filter(e=>!e.hidden).map(e=>[e.name,e.description??""]),header:s.magenta(" Environment Variables ")},{content:`Run "${c(r.getCliName())} ${d("help <command>")}" or "${c(r.getCliName())} ${d("<command>")} ${f("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"printGeneralHelp"),B=u((i,r,p,t)=>{let n=p.get(t);if(!n)for(const e of p.values()){const o=e.commandPath?[...e.commandPath,e.name]:[e.name];if(o[o.length-1]===t||o.join(" ")===t){n=e;break}}if(!n){i.error(`Command "${t}" not found`);return}const a=[],m=(n.commandPath?[...n.commandPath,n.name]:[n.name]).join(" ");if(a.push({content:`${c(r.getCliName())} ${d(m)}${n.argument?" [positional arguments]":""}${n.options?" [options]":""}`,header:s.cyan(" Usage ")}),n.description&&a.push({content:n.description,header:s.green(" Description ")}),n.argument&&a.push({header:"Command Positional Arguments",isArgument:!0,optionList:[n.argument]}),Array.isArray(n.options)&&n.options.length>0&&a.push({header:s.yellow(" Command Options "),optionList:n.options.filter(e=>!e.hidden)}),a.push({header:s.yellow(" Global Options "),optionList:C}),Array.isArray(n.env)&&n.env.length>0){const e=n.env.filter(o=>!o.hidden);e.length>0&&a.push({content:e.map(o=>[o.name,o.description??""]),header:s.magenta(" Environment Variables ")})}if(n.alias!==void 0&&n.alias.length>0){let e=n.alias;typeof n.alias=="string"&&(e=[n.alias]),a.splice(1,0,{content:e,header:"Alias(es)"})}Array.isArray(n.examples)&&n.examples.length>0&&a.push({content:n.examples,header:"Examples"}),(i?.raw??i.log)($(a))},"printCommandHelp");class R{static{g(this,"D")}static{u(this,"HelpCommand")}name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(r){this.commands=r}execute(r){const{commandName:p,logger:t,options:n,runtime:a}=r,{footer:m,header:e}=a.getCommandSection();e&&(t?.raw??t.log)(y(e)),p==="help"?A(t,a,this.commands,typeof n?.group=="string"?n.group:void 0):B(t,a,this.commands,p),m&&(t?.raw??t.log)(y(m))}}export{R as D,C as o};
@@ -1,6 +0,0 @@
1
- var m=Object.defineProperty;var s=(r,e)=>m(r,"name",{value:e,configurable:!0});import{createRequire as b}from"node:module";import{createTable as p}from"@visulima/tabular";import{NO_BORDER as u}from"@visulima/tabular/style";import $ from"@visulima/colorize/template";import{d as O}from"./runtime-process-G-n-wOub.js";import{bold as R}from"@visulima/colorize";const v=b(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=s(r=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[e,t]=l.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return l.getBuiltinModule(r)}return v(r)},"__cjs_getBuiltinModule"),A=w("node:os");var j=Object.defineProperty,_=s((r,e)=>j(r,"name",{value:e,configurable:!0}),"s");const c=new Map,E=500,o=_(r=>{if(!r||r==="")return"";const e=c.get(r);if(e!==void 0)return e;const t=$(Object.assign([],{raw:[r]}));if(c.size>=E){const n=c.keys().next().value;n!==void 0&&c.delete(n)}return c.set(r,t),t},"templateFormat");var L=Object.defineProperty,N=s((r,e)=>L(r,"name",{value:e,configurable:!0}),"t$1");const g=N(()=>{const r=O().CEREBRO_TERMINAL_WIDTH;if(r===void 0)return;const e=Number.parseInt(r,10);if(!(Number.isNaN(e)||e<=0))return e},"getTerminalWidth");var S=Object.defineProperty,W=s((r,e)=>S(r,"name",{value:e,configurable:!0}),"t");class h{static{s(this,"n")}static{W(this,"BaseSection")}lines;constructor(){this.lines=[]}add(e){this.lines.push(e)}toString(){return this.lines.join(A.EOL)}header(e){this.add(R(e)),this.lines.push("")}}var T=Object.defineProperty,B=s((r,e)=>T(r,"name",{value:e,configurable:!0}),"f");class P extends h{static{s(this,"l")}static{B(this,"ContentSection")}constructor(e){if(super(),e.header&&this.header(o(e.header)),e.content){if(e.raw)if(Array.isArray(e.content)&&e.content.every(t=>typeof t=="string"))e.content.forEach(t=>{Array.isArray(t)?t.forEach(n=>this.add(o(n))):this.add(o(t))});else if(typeof e.content=="string")this.add(o(e.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(e.content));this.add("")}}getContentLines(e){if(typeof e=="string"){const t=p({showHeader:!1,style:{border:u,paddingLeft:4,paddingRight:1},terminalWidth:g(),truncateOverflow:!1,wordWrap:!0});return t.addRow([o(e)]),t.toString()}if(Array.isArray(e)&&e.every(t=>typeof t=="string"||Array.isArray(t)&&t.every(n=>typeof n=="string"))){const t=p({showHeader:!1,style:{border:u,paddingLeft:4,paddingRight:1},terminalWidth:g(),truncateOverflow:!1,wordWrap:!0});return e.forEach(n=>{Array.isArray(n)?t.addRow(n.map(i=>o(i))):t.addRow([o(n)])}),t.toString()}if(typeof e=="object"){const t=e;if(!t.options||!t.data)throw new Error(`Must have an "options" or "data" property
2
- ${JSON.stringify(e)}`);const n=p({showHeader:!1,style:{border:u,paddingLeft:4,paddingRight:1},terminalWidth:g(),truncateOverflow:!1,wordWrap:!0});return t.data.forEach(i=>{Array.isArray(i)?n.addRow(i.map(d=>o(d))):n.addRow([o(i)])}),n.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
3
-
4
- ${JSON.stringify(e)}`)}}var M=Object.defineProperty,C=s((r,e)=>M(r,"name",{value:e,configurable:!0}),"a");class H extends h{static{s(this,"b")}static{C(this,"OptionListSection")}constructor(e){super();let t=e.optionList??[];const n=Array.isArray(e.hide)?e.hide:[e.hide].filter(Boolean),i=Array.isArray(e.group)?e.group:[e.group].filter(Boolean);n.length>0&&(t=t.filter(a=>!n.includes(a.name))),e.header&&this.header(o(e.header)),i.length>0&&(t=t.filter(a=>{const f=i.includes("_none")&&!a.group,y=this.intersect(Array.isArray(a.group)?a.group:[a.group],i);return f||y?a:void 0}));const d=p({showHeader:!1,style:{border:u,paddingLeft:2,paddingRight:1,...e.tableOptions?.style},terminalWidth:g()??e.tableOptions?.terminalWidth,truncateOverflow:!1,wordWrap:e.tableOptions?.wordWrap??!0,...e.tableOptions});t.forEach(a=>d.addRow([this.getOptionNames(a,e.reverseNameOrder??!1,e.isArgument??!1),o(a.description)])),this.add(d.toString()),this.lines.push("")}getOptionNames(e,t,n){if(!e.name)throw new TypeError("Invalid option definition, name is required.");let i=e.type?e.type.name.toLowerCase():"string";const d=e.multiple||e.lazyMultiple?"[]":"";i=o(e.typeLabel??`{underline ${i}${d}}`);let a;if(e.alias)if(e.name){const f=n?e.name:`{yellow --${e.name}}`;a=o(t?`{bold ${f}}, {bold -${e.alias}} ${i}`:`{bold -${e.alias}}, {bold ${f}} ${i}`)}else t?a=o(`{bold -${e.alias}} ${i}`):a=o(`{bold -${e.alias}} ${i}`);else a=o(`{bold ${n?e.name:`{yellow --${e.name}}`}} ${i}`);return a}intersect(e,t){return e.some(n=>t.includes(n))}}var I=Object.defineProperty,q=s((r,e)=>I(r,"name",{value:e,configurable:!0}),"o");const G=q(r=>(Array.isArray(r)?r:[r]).length===0?"":`
5
- ${r.map(e=>e.optionList?new H(e).toString():new P(e).toString()).join(`
6
- `)}`,"commandLineUsage");export{o as f,G as p};
@@ -1 +0,0 @@
1
- var a=Object.defineProperty;var l=(e,s)=>a(e,"name",{value:s,configurable:!0});var g=Object.defineProperty,r=l((e,s)=>g(e,"name",{value:s,configurable:!0}),"r");const t=r(e=>"Deno"in e,"hasDeno"),i=r(e=>"Bun"in e,"hasBun"),h=r(()=>{if(t(globalThis)){const e=globalThis.Deno,s=e.execPath();let o=s;try{const{importMeta:n}=globalThis;n?.url&&(o=n.url)}catch{}return[s,o,...e.args]}return i(globalThis)?globalThis.Bun.process.argv:process.argv},"getArgv"),b=r(()=>t(globalThis)?globalThis.Deno.cwd():i(globalThis)?globalThis.Bun.process.cwd():process.cwd(),"getCwd"),u=r(()=>{if(t(globalThis)){const e=globalThis.Deno;return new Proxy(e.env.toObject(),{get:r((s,o)=>typeof o=="string"?e.env.get(o):s[o],"get"),has:r((s,o)=>typeof o=="string"?e.env.has(o):o in s,"has"),set:r((s,o,n)=>typeof o=="string"?(n===void 0||e.env.set(o,n),!0):!1,"set")})}return i(globalThis)?globalThis.Bun.process.env:process.env},"getEnv"),T=r(()=>t(globalThis)?[]:i(globalThis)?globalThis.Bun.process.execArgv:process.execArgv,"getExecArgv"),v=r(()=>t(globalThis)?globalThis.Deno.execPath():i(globalThis)?globalThis.Bun.process.execPath:process.execPath,"getExecPath"),p=r(()=>{if(t(globalThis)){const e=globalThis.Deno.build?.os??"unknown";return e==="windows"?"win32":e}return i(globalThis)?globalThis.Bun.platform??"unknown":process.platform},"getPlatform"),f=r(()=>{if(t(globalThis)){const e=globalThis.Deno.build?.arch??"unknown";return e==="x86_64"?"x64":e==="aarch64"?"arm64":e}return i(globalThis)?globalThis.Bun.process.arch:process.arch},"getArch"),x=r(()=>{if(t(globalThis)){const e=globalThis.Deno,s={};return e.version?.deno&&(s.deno=e.version.deno),e.version?.v8&&(s.v8=e.version.v8),e.version?.typescript&&(s.typescript=e.version.typescript),s}if(i(globalThis)){const e=globalThis.Bun,s={...e.process.versions};return e.version&&(s.bun=e.version),s}return process.versions},"getVersions"),d=r((e=0)=>{if(t(globalThis))throw globalThis.Deno.exit(e),new Error("Deno exit failed");if(i(globalThis))throw globalThis.Bun.process.exit(e),new Error("Bun exit failed");process.exit(e)},"exitProcess"),w=r((e,s)=>{if(t(globalThis))return()=>{};if(i(globalThis)){try{const n=globalThis.Bun;if(n.process?.on)return n.process.on(e,s),()=>{n.process?.removeListener&&n.process.removeListener(e,s)}}catch{}return()=>{}}const o=process;return o.on(e,s),()=>{o.removeListener(e,s)}},"onProcessEvent");export{b as a,p as b,f as c,u as d,d as e,h as f,x as g,v as h,T as i,w as o};