UNPKG

agent-contracts

Version:

Declarative YAML DSL toolkit for defining, validating, and rendering multi-agent development workflows

30 lines 3.98 MB
#!/usr/bin/env node import { createRequire as __banner_createRequire } from 'module'; const require = __banner_createRequire(import.meta.url); var Rze=Object.create;var Sw=Object.defineProperty;var Lze=Object.getOwnPropertyDescriptor;var Bze=Object.getOwnPropertyNames;var Fze=Object.getPrototypeOf,Mze=Object.prototype.hasOwnProperty;var bi=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var it=(e,t)=>()=>(e&&(t=e(e=0)),t);var K=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Rn=(e,t)=>{for(var r in t)Sw(e,r,{get:t[r],enumerable:!0})},Xie=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Bze(t))!Mze.call(e,n)&&n!==r&&Sw(e,n,{get:()=>t[n],enumerable:!(i=Lze(t,n))||i.enumerable});return e};var _n=(e,t,r)=>(r=e!=null?Rze(Fze(e)):{},Xie(t||!e||!e.__esModule?Sw(r,"default",{value:e,enumerable:!0}):r,e)),Qt=e=>Xie(Sw({},"__esModule",{value:!0}),e);var s3=K(NR=>{var Ew=class extends Error{constructor(t,r,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=t,this.nestedError=void 0}},TR=class extends Ew{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};NR.CommanderError=Ew;NR.InvalidArgumentError=TR});var xw=K(LR=>{var{InvalidArgumentError:qze}=s3(),RR=class{constructor(t,r){switch(this.description=r||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}default(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,i)=>{if(!this.argChoices.includes(r))throw new qze(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,i):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function zze(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}LR.Argument=RR;LR.humanReadableArgName=zze});var MR=K(FR=>{var{humanReadableArgName:Uze}=xw(),BR=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let r=t.commands.filter(n=>!n._hidden),i=t._getHelpCommand();return i&&!i._hidden&&r.push(i),this.sortSubcommands&&r.sort((n,a)=>n.name().localeCompare(a.name())),r}compareOptions(t,r){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(t).localeCompare(i(r))}visibleOptions(t){let r=t.options.filter(n=>!n.hidden),i=t._getHelpOption();if(i&&!i.hidden){let n=i.short&&t._findOption(i.short),a=i.long&&t._findOption(i.long);!n&&!a?r.push(i):i.long&&!a?r.push(t.createOption(i.long,i.description)):i.short&&!n&&r.push(t.createOption(i.short,i.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let r=[];for(let i=t.parent;i;i=i.parent){let n=i.options.filter(a=>!a.hidden);r.push(...n)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(r=>{r.description=r.description||t._argsDescription[r.name()]||""}),t.registeredArguments.find(r=>r.description)?t.registeredArguments:[]}subcommandTerm(t){let r=t.registeredArguments.map(i=>Uze(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(n)))),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleOptionTerm(r.optionTerm(n)))),0)}longestGlobalOptionTermLength(t,r){return r.visibleGlobalOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleOptionTerm(r.optionTerm(n)))),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce((i,n)=>Math.max(i,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(n)))),0)}commandUsage(t){let r=t._name;t._aliases[0]&&(r=r+"|"+t._aliases[0]);let i="";for(let n=t.parent;n;n=n.parent)i=n.name()+" "+i;return i+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&r.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&r.push(`env: ${t.envVar}`),r.length>0){let i=`(${r.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}argumentDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),r.length>0){let i=`(${r.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatItemList(t,r,i){return r.length===0?[]:[i.styleTitle(t),...r,""]}groupItems(t,r,i){let n=new Map;return t.forEach(a=>{let o=i(a);n.has(o)||n.set(o,[])}),r.forEach(a=>{let o=i(a);n.has(o)||n.set(o,[]),n.get(o).push(a)}),n}formatHelp(t,r){let i=r.padWidth(t,r),n=r.helpWidth??80;function a(d,p){return r.formatItem(d,i,p,r)}let o=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(t))}`,""],s=r.commandDescription(t);s.length>0&&(o=o.concat([r.boxWrap(r.styleCommandDescription(s),n),""]));let u=r.visibleArguments(t).map(d=>a(r.styleArgumentTerm(r.argumentTerm(d)),r.styleArgumentDescription(r.argumentDescription(d))));if(o=o.concat(this.formatItemList("Arguments:",u,r)),this.groupItems(t.options,r.visibleOptions(t),d=>d.helpGroupHeading??"Options:").forEach((d,p)=>{let f=d.map(m=>a(r.styleOptionTerm(r.optionTerm(m)),r.styleOptionDescription(r.optionDescription(m))));o=o.concat(this.formatItemList(p,f,r))}),r.showGlobalOptions){let d=r.visibleGlobalOptions(t).map(p=>a(r.styleOptionTerm(r.optionTerm(p)),r.styleOptionDescription(r.optionDescription(p))));o=o.concat(this.formatItemList("Global Options:",d,r))}return this.groupItems(t.commands,r.visibleCommands(t),d=>d.helpGroup()||"Commands:").forEach((d,p)=>{let f=d.map(m=>a(r.styleSubcommandTerm(r.subcommandTerm(m)),r.styleSubcommandDescription(r.subcommandDescription(m))));o=o.concat(this.formatItemList(p,f,r))}),o.join(` `)}displayWidth(t){return eae(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r==="[command]"?this.styleSubcommandText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleCommandText(r)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleSubcommandText(r)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,r){return Math.max(r.longestOptionTermLength(t,r),r.longestGlobalOptionTermLength(t,r),r.longestSubcommandTermLength(t,r),r.longestArgumentTermLength(t,r))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,r,i,n){let o=" ".repeat(2);if(!i)return o+t;let s=t.padEnd(r+t.length-n.displayWidth(t)),u=2,c=(this.helpWidth??80)-r-u-2,d;return c<this.minWidthToWrap||n.preformatted(i)?d=i:d=n.boxWrap(i,c).replace(/\n/g,` `+" ".repeat(r+u)),o+s+" ".repeat(u)+d.replace(/\n/g,` ${o}`)}boxWrap(t,r){if(r<this.minWidthToWrap)return t;let i=t.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,a=[];return i.forEach(o=>{let s=o.match(n);if(s===null){a.push("");return}let u=[s.shift()],l=this.displayWidth(u[0]);s.forEach(c=>{let d=this.displayWidth(c);if(l+d<=r){u.push(c),l+=d;return}a.push(u.join(""));let p=c.trimStart();u=[p],l=this.displayWidth(p)}),a.push(u.join(""))}),a.join(` `)}};function eae(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}FR.Help=BR;FR.stripColor=eae});var VR=K(UR=>{var{InvalidArgumentError:Vze}=s3(),qR=class{constructor(t,r){this.flags=t,this.description=r||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let i=Gze(t);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let r=t;return typeof t=="string"&&(r={[t]:!0}),this.implied=Object.assign(this.implied||{},r),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,i)=>{if(!this.argChoices.includes(r))throw new Vze(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,i):r},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?tae(this.name().replace(/^no-/,"")):tae(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},zR=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(r=>{r.negate?this.negativeOptions.set(r.attributeName(),r):this.positiveOptions.set(r.attributeName(),r)}),this.negativeOptions.forEach((r,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(t,r){let i=r.attributeName();if(!this.dualOptions.has(i))return!0;let n=this.negativeOptions.get(i).presetArg,a=n!==void 0?n:!1;return r.negate===(a===t)}};function tae(e){return e.split("-").reduce((t,r)=>t+r[0].toUpperCase()+r.slice(1))}function Gze(e){let t,r,i=/^-[^-]$/,n=/^--[^-]/,a=e.split(/[ |,]+/).concat("guard");if(i.test(a[0])&&(t=a.shift()),n.test(a[0])&&(r=a.shift()),!t&&i.test(a[0])&&(t=a.shift()),!t&&n.test(a[0])&&(t=r,r=a.shift()),a[0].startsWith("-")){let o=a[0],s=`option creation failed due to '${o}' in option flags '${e}'`;throw/^-[^-][^-]/.test(o)?new Error(`${s} - a short flag is a single dash and a single character - either use a single dash and a single character (for a short flag) - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):i.test(o)?new Error(`${s} - too many short flags`):n.test(o)?new Error(`${s} - too many long flags`):new Error(`${s} - unrecognised flag format`)}if(t===void 0&&r===void 0)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:r}}UR.Option=qR;UR.DualOptions=zR});var nae=K(rae=>{function Zze(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let r=[];for(let i=0;i<=e.length;i++)r[i]=[i];for(let i=0;i<=t.length;i++)r[0][i]=i;for(let i=1;i<=t.length;i++)for(let n=1;n<=e.length;n++){let a=1;e[n-1]===t[i-1]?a=0:a=1,r[n][i]=Math.min(r[n-1][i]+1,r[n][i-1]+1,r[n-1][i-1]+a),n>1&&i>1&&e[n-1]===t[i-2]&&e[n-2]===t[i-1]&&(r[n][i]=Math.min(r[n][i],r[n-2][i-2]+1))}return r[e.length][t.length]}function Wze(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let r=e.startsWith("--");r&&(e=e.slice(2),t=t.map(o=>o.slice(2)));let i=[],n=3,a=.4;return t.forEach(o=>{if(o.length<=1)return;let s=Zze(e,o),u=Math.max(e.length,o.length);(u-s)/u>a&&(s<n?(n=s,i=[o]):s===n&&i.push(o))}),i.sort((o,s)=>o.localeCompare(s)),r&&(i=i.map(o=>`--${o}`)),i.length>1?` (Did you mean one of ${i.join(", ")}?)`:i.length===1?` (Did you mean ${i[0]}?)`:""}rae.suggestSimilar=Wze});var sae=K(HR=>{var Kze=bi("node:events").EventEmitter,GR=bi("node:child_process"),ep=bi("node:path"),$w=bi("node:fs"),bn=bi("node:process"),{Argument:Hze,humanReadableArgName:Jze}=xw(),{CommanderError:ZR}=s3(),{Help:Yze,stripColor:Qze}=MR(),{Option:iae,DualOptions:Xze}=VR(),{suggestSimilar:aae}=nae(),WR=class e extends Kze{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:r=>bn.stdout.write(r),writeErr:r=>bn.stderr.write(r),outputError:(r,i)=>i(r),getOutHelpWidth:()=>bn.stdout.isTTY?bn.stdout.columns:void 0,getErrHelpWidth:()=>bn.stderr.isTTY?bn.stderr.columns:void 0,getOutHasColors:()=>KR()??(bn.stdout.isTTY&&bn.stdout.hasColors?.()),getErrHasColors:()=>KR()??(bn.stderr.isTTY&&bn.stderr.hasColors?.()),stripColor:r=>Qze(r)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let r=this;r;r=r.parent)t.push(r);return t}command(t,r,i){let n=r,a=i;typeof n=="object"&&n!==null&&(a=n,n=null),a=a||{};let[,o,s]=t.match(/([^ ]+) *(.*)/),u=this.createCommand(o);return n&&(u.description(n),u._executableHandler=!0),a.isDefault&&(this._defaultCommandName=u._name),u._hidden=!!(a.noHelp||a.hidden),u._executableFile=a.executableFile||null,s&&u.arguments(s),this._registerCommand(u),u.parent=this,u.copyInheritedSettings(this),n?this:u}createCommand(t){return new e(t)}createHelp(){return Object.assign(new Yze,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...t},this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,r){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name - specify the name in Command constructor or using .name()`);return r=r||{},r.isDefault&&(this._defaultCommandName=t._name),(r.noHelp||r.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,r){return new Hze(t,r)}argument(t,r,i,n){let a=this.createArgument(t,r);return typeof i=="function"?a.default(n).argParser(i):a.default(i),this.addArgument(a),this}arguments(t){return t.trim().split(/ +/).forEach(r=>{this.argument(r)}),this}addArgument(t){let r=this.registeredArguments.slice(-1)[0];if(r?.variadic)throw new Error(`only the last argument can be variadic '${r.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,r){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let i=t??"help [command]",[,n,a]=i.match(/([^ ]+) *(.*)/),o=r??"display help for command",s=this.createCommand(n);return s.helpOption(!1),a&&s.arguments(a),o&&s.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=s,(t||r)&&this._initCommandGroup(s),this}addHelpCommand(t,r){return typeof t!="object"?(this.helpCommand(t,r),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,r){let i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'. Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(r):this._lifeCycleHooks[t]=[r],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=r=>{if(r.code!=="commander.executeSubCommandAsync")throw r},this}_exit(t,r,i){this._exitCallback&&this._exitCallback(new ZR(t,r,i)),bn.exit(t)}action(t){let r=i=>{let n=this.registeredArguments.length,a=i.slice(0,n);return this._storeOptionsAsProperties?a[n]=this:a[n]=this.opts(),a.push(this),t.apply(this,a)};return this._actionHandler=r,this}createOption(t,r){return new iae(t,r)}_callParseArg(t,r,i,n){try{return t.parseArg(r,i)}catch(a){if(a.code==="commander.invalidArgument"){let o=`${n} ${a.message}`;this.error(o,{exitCode:a.exitCode,code:a.code})}throw a}}_registerOption(t){let r=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(r){let i=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}' - already used by option '${r.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let r=n=>[n.name()].concat(n.aliases()),i=r(t).find(n=>this._findCommand(n));if(i){let n=r(this._findCommand(i)).join("|"),a=r(t).join("|");throw new Error(`cannot add command '${a}' as already have command '${n}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);let r=t.name(),i=t.attributeName();if(t.negate){let a=t.long.replace(/^--no-/,"--");this._findOption(a)||this.setOptionValueWithSource(i,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(i,t.defaultValue,"default");let n=(a,o,s)=>{a==null&&t.presetArg!==void 0&&(a=t.presetArg);let u=this.getOptionValue(i);a!==null&&t.parseArg?a=this._callParseArg(t,a,u,o):a!==null&&t.variadic&&(a=t._collectValue(a,u)),a==null&&(t.negate?a=!1:t.isBoolean()||t.optional?a=!0:a=""),this.setOptionValueWithSource(i,a,s)};return this.on("option:"+r,a=>{let o=`error: option '${t.flags}' argument '${a}' is invalid.`;n(a,o,"cli")}),t.envVar&&this.on("optionEnv:"+r,a=>{let o=`error: option '${t.flags}' value '${a}' from env '${t.envVar}' is invalid.`;n(a,o,"env")}),this}_optionEx(t,r,i,n,a){if(typeof r=="object"&&r instanceof iae)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(r,i);if(o.makeOptionMandatory(!!t.mandatory),typeof n=="function")o.default(a).argParser(n);else if(n instanceof RegExp){let s=n;n=(u,l)=>{let c=s.exec(u);return c?c[0]:l},o.default(a).argParser(n)}else o.default(n);return this.addOption(o)}option(t,r,i,n){return this._optionEx({},t,r,i,n)}requiredOption(t,r,i,n){return this._optionEx({mandatory:!0},t,r,i,n)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,r){return this.setOptionValueWithSource(t,r,void 0)}setOptionValueWithSource(t,r,i){return this._storeOptionsAsProperties?this[t]=r:this._optionValues[t]=r,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let r;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(t)!==void 0&&(r=i.getOptionValueSource(t))}),r}_prepareUserArgs(t,r){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(r=r||{},t===void 0&&r.from===void 0){bn.versions?.electron&&(r.from="electron");let n=bn.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(r.from="eval")}t===void 0&&(t=bn.argv),this.rawArgs=t.slice();let i;switch(r.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":bn.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${r.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,r){this._prepareForParse();let i=this._prepareUserArgs(t,r);return this._parseCommand([],i),this}async parseAsync(t,r){this._prepareForParse();let i=this._prepareUserArgs(t,r);return await this._parseCommand([],i),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true. - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,r,i){if($w.existsSync(t))return;let n=r?`searched for local subcommand relative to directory '${r}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",a=`'${t}' does not exist - if '${i}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead - if the default executable name is not suitable, use the executableFile option to supply a custom name or path - ${n}`;throw new Error(a)}_executeSubCommand(t,r){r=r.slice();let i=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function a(c,d){let p=ep.resolve(c,d);if($w.existsSync(p))return p;if(n.includes(ep.extname(d)))return;let f=n.find(m=>$w.existsSync(`${p}${m}`));if(f)return`${p}${f}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=t._executableFile||`${this._name}-${t._name}`,s=this._executableDir||"";if(this._scriptPath){let c;try{c=$w.realpathSync(this._scriptPath)}catch{c=this._scriptPath}s=ep.resolve(ep.dirname(c),s)}if(s){let c=a(s,o);if(!c&&!t._executableFile&&this._scriptPath){let d=ep.basename(this._scriptPath,ep.extname(this._scriptPath));d!==this._name&&(c=a(s,`${d}-${t._name}`))}o=c||o}i=n.includes(ep.extname(o));let u;bn.platform!=="win32"?i?(r.unshift(o),r=oae(bn.execArgv).concat(r),u=GR.spawn(bn.argv[0],r,{stdio:"inherit"})):u=GR.spawn(o,r,{stdio:"inherit"}):(this._checkForMissingExecutable(o,s,t._name),r.unshift(o),r=oae(bn.execArgv).concat(r),u=GR.spawn(bn.execPath,r,{stdio:"inherit"})),u.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(d=>{bn.on(d,()=>{u.killed===!1&&u.exitCode===null&&u.kill(d)})});let l=this._exitCallback;u.on("close",c=>{c=c??1,l?l(new ZR(c,"commander.executeSubCommandAsync","(close)")):bn.exit(c)}),u.on("error",c=>{if(c.code==="ENOENT")this._checkForMissingExecutable(o,s,t._name);else if(c.code==="EACCES")throw new Error(`'${o}' not executable`);if(!l)bn.exit(1);else{let d=new ZR(1,"commander.executeSubCommandAsync","(error)");d.nestedError=c,l(d)}}),this.runningCommand=u}_dispatchSubcommand(t,r,i){let n=this._findCommand(t);n||this.help({error:!0}),n._prepareForParse();let a;return a=this._chainOrCallSubCommandHook(a,n,"preSubcommand"),a=this._chainOrCall(a,()=>{if(n._executableHandler)this._executeSubCommand(n,r.concat(i));else return n._parseCommand(r,i)}),a}_dispatchHelpCommand(t){t||this.help();let r=this._findCommand(t);return r&&!r._executableHandler&&r.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,r)=>{t.required&&this.args[r]==null&&this.missingArgument(t.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=(i,n,a)=>{let o=n;if(n!==null&&i.parseArg){let s=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;o=this._callParseArg(i,n,a,s)}return o};this._checkNumberOfArguments();let r=[];this.registeredArguments.forEach((i,n)=>{let a=i.defaultValue;i.variadic?n<this.args.length?(a=this.args.slice(n),i.parseArg&&(a=a.reduce((o,s)=>t(i,s,o),i.defaultValue))):a===void 0&&(a=[]):n<this.args.length&&(a=this.args[n],i.parseArg&&(a=t(i,a,i.defaultValue))),r[n]=a}),this.processedArgs=r}_chainOrCall(t,r){return t?.then&&typeof t.then=="function"?t.then(()=>r()):r()}_chainOrCallHooks(t,r){let i=t,n=[];return this._getCommandAndAncestors().reverse().filter(a=>a._lifeCycleHooks[r]!==void 0).forEach(a=>{a._lifeCycleHooks[r].forEach(o=>{n.push({hookedCommand:a,callback:o})})}),r==="postAction"&&n.reverse(),n.forEach(a=>{i=this._chainOrCall(i,()=>a.callback(a.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,r,i){let n=t;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(a=>{n=this._chainOrCall(n,()=>a(this,r))}),n}_parseCommand(t,r){let i=this.parseOptions(r);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),r=i.unknown,this.args=t.concat(r),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),r);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(r),this._dispatchSubcommand(this._defaultCommandName,t,r);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},a=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(a,t,r)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent?.listenerCount(a))n(),this._processArguments(),this.parent.emit(a,t,r);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,r);this.listenerCount("command:*")?this.emit("command:*",t,r):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(r=>r._name===t||r._aliases.includes(t))}_findOption(t){return this.options.find(r=>r.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(r=>{r.mandatory&&t.getOptionValue(r.attributeName())===void 0&&t.missingMandatoryOptionValue(r)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});t.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=t.find(a=>i.conflictsWith.includes(a.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let r=[],i=[],n=r;function a(c){return c.length>1&&c[0]==="-"}let o=c=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(c)?!this._getCommandAndAncestors().some(d=>d.options.map(p=>p.short).some(p=>/^-\d$/.test(p))):!1,s=null,u=null,l=0;for(;l<t.length||u;){let c=u??t[l++];if(u=null,c==="--"){n===i&&n.push(c),n.push(...t.slice(l));break}if(s&&(!a(c)||o(c))){this.emit(`option:${s.name()}`,c);continue}if(s=null,a(c)){let d=this._findOption(c);if(d){if(d.required){let p=t[l++];p===void 0&&this.optionMissingArgument(d),this.emit(`option:${d.name()}`,p)}else if(d.optional){let p=null;l<t.length&&(!a(t[l])||o(t[l]))&&(p=t[l++]),this.emit(`option:${d.name()}`,p)}else this.emit(`option:${d.name()}`);s=d.variadic?d:null;continue}}if(c.length>2&&c[0]==="-"&&c[1]!=="-"){let d=this._findOption(`-${c[1]}`);if(d){d.required||d.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${d.name()}`,c.slice(2)):(this.emit(`option:${d.name()}`),u=`-${c.slice(2)}`);continue}}if(/^--[^=]+=/.test(c)){let d=c.indexOf("="),p=this._findOption(c.slice(0,d));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,c.slice(d+1));continue}}if(n===r&&a(c)&&!(this.commands.length===0&&o(c))&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&r.length===0&&i.length===0){if(this._findCommand(c)){r.push(c),i.push(...t.slice(l));break}else if(this._getHelpCommand()&&c===this._getHelpCommand().name()){r.push(c,...t.slice(l));break}else if(this._defaultCommandName){i.push(c,...t.slice(l));break}}if(this._passThroughOptions){n.push(c,...t.slice(l));break}n.push(c)}return{operands:r,unknown:i}}opts(){if(this._storeOptionsAsProperties){let t={},r=this.options.length;for(let i=0;i<r;i++){let n=this.options[i].attributeName();t[n]=n===this._versionOptionName?this._version:this[n]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,r)=>Object.assign(t,r.opts()),{})}error(t,r){this._outputConfiguration.outputError(`${t} `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError} `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(` `),this.outputHelp({error:!0}));let i=r||{},n=i.exitCode||1,a=i.code||"commander.error";this._exit(n,a,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in bn.env){let r=t.attributeName();(this.getOptionValue(r)===void 0||["default","config","env"].includes(this.getOptionValueSource(r)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,bn.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new Xze(this.options),r=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&r(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!r(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(t){let r=`error: missing required argument '${t}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(t){let r=`error: option '${t.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let r=`error: required option '${t.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,r){let i=o=>{let s=o.attributeName(),u=this.getOptionValue(s),l=this.options.find(d=>d.negate&&s===d.attributeName()),c=this.options.find(d=>!d.negate&&s===d.attributeName());return l&&(l.presetArg===void 0&&u===!1||l.presetArg!==void 0&&u===l.presetArg)?l:c||o},n=o=>{let s=i(o),u=s.attributeName();return this.getOptionValueSource(u)==="env"?`environment variable '${s.envVar}'`:`option '${s.flags}'`},a=`error: ${n(t)} cannot be used with ${n(r)}`;this.error(a,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let r="";if(t.startsWith("--")&&this._showSuggestionAfterError){let n=[],a=this;do{let o=a.createHelp().visibleOptions(a).filter(s=>s.long).map(s=>s.long);n=n.concat(o),a=a.parent}while(a&&!a._enablePositionalOptions);r=aae(t,n)}let i=`error: unknown option '${t}'${r}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let r=this.registeredArguments.length,i=r===1?"":"s",a=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${r} argument${i} but got ${t.length}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],r="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(a=>{n.push(a.name()),a.alias()&&n.push(a.alias())}),r=aae(t,n)}let i=`error: unknown command '${t}'${r}`;this.error(i,{code:"commander.unknownCommand"})}version(t,r,i){if(t===void 0)return this._version;this._version=t,r=r||"-V, --version",i=i||"output the version number";let n=this.createOption(r,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t} `),this._exit(0,"commander.version",t)}),this}description(t,r){return t===void 0&&r===void 0?this._description:(this._description=t,r&&(this._argsDescription=r),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(r=this.commands[this.commands.length-1]),t===r._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${n}'`)}return r._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(r=>this.alias(r)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let r=this.registeredArguments.map(i=>Jze(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?r:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=ep.basename(t,ep.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let r=this.createHelp(),i=this._getOutputContext(t);r.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let n=r.formatHelp(this,r);return i.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(t){t=t||{};let r=!!t.error,i,n,a;return r?(i=s=>this._outputConfiguration.writeErr(s),n=this._outputConfiguration.getErrHasColors(),a=this._outputConfiguration.getErrHelpWidth()):(i=s=>this._outputConfiguration.writeOut(s),n=this._outputConfiguration.getOutHasColors(),a=this._outputConfiguration.getOutHelpWidth()),{error:r,write:s=>(n||(s=this._outputConfiguration.stripColor(s)),i(s)),hasColors:n,helpWidth:a}}outputHelp(t){let r;typeof t=="function"&&(r=t,t=void 0);let i=this._getOutputContext(t),n={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let a=this.helpInformation({error:i.error});if(r&&(a=r(a),typeof a!="string"&&!Buffer.isBuffer(a)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(a),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",n))}helpOption(t,r){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",r??"display help for command"),(t||r)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let r=Number(bn.exitCode??0);r===0&&t&&typeof t!="function"&&t.error&&(r=1),this._exit(r,"commander.help","(outputHelp)")}addHelpText(t,r){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText. Expecting one of '${i.join("', '")}'`);let n=`${t}Help`;return this.on(n,a=>{let o;typeof r=="function"?o=r({error:a.error,command:a.command}):o=r,o&&a.write(`${o} `)}),this}_outputHelpIfRequested(t){let r=this._getHelpOption();r&&t.find(n=>r.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function oae(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let r,i="127.0.0.1",n="9229",a;return(a=t.match(/^(--inspect(-brk)?)$/))!==null?r=a[1]:(a=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(r=a[1],/^\d+$/.test(a[3])?n=a[3]:i=a[3]):(a=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(r=a[1],i=a[3],n=a[4]),r&&n!=="0"?`${r}=${i}:${parseInt(n)+1}`:t})}function KR(){if(bn.env.NO_COLOR||bn.env.FORCE_COLOR==="0"||bn.env.FORCE_COLOR==="false")return!1;if(bn.env.FORCE_COLOR||bn.env.CLICOLOR_FORCE!==void 0)return!0}HR.Command=WR;HR.useColor=KR});var dae=K(Ju=>{var{Argument:uae}=xw(),{Command:JR}=sae(),{CommanderError:eUe,InvalidArgumentError:lae}=s3(),{Help:tUe}=MR(),{Option:cae}=VR();Ju.program=new JR;Ju.createCommand=e=>new JR(e);Ju.createOption=(e,t)=>new cae(e,t);Ju.createArgument=(e,t)=>new uae(e,t);Ju.Command=JR;Ju.Option=cae;Ju.Argument=uae;Ju.Help=tUe;Ju.CommanderError=eUe;Ju.InvalidArgumentError=lae;Ju.InvalidOptionArgumentError=lae});var sn=K(ao=>{"use strict";var QR=Symbol.for("yaml.alias"),_ae=Symbol.for("yaml.document"),kw=Symbol.for("yaml.map"),bae=Symbol.for("yaml.pair"),XR=Symbol.for("yaml.scalar"),Aw=Symbol.for("yaml.seq"),tp=Symbol.for("yaml.node.type"),iUe=e=>!!e&&typeof e=="object"&&e[tp]===QR,aUe=e=>!!e&&typeof e=="object"&&e[tp]===_ae,oUe=e=>!!e&&typeof e=="object"&&e[tp]===kw,sUe=e=>!!e&&typeof e=="object"&&e[tp]===bae,wae=e=>!!e&&typeof e=="object"&&e[tp]===XR,uUe=e=>!!e&&typeof e=="object"&&e[tp]===Aw;function Sae(e){if(e&&typeof e=="object")switch(e[tp]){case kw:case Aw:return!0}return!1}function lUe(e){if(e&&typeof e=="object")switch(e[tp]){case QR:case kw:case XR:case Aw:return!0}return!1}var cUe=e=>(wae(e)||Sae(e))&&!!e.anchor;ao.ALIAS=QR;ao.DOC=_ae;ao.MAP=kw;ao.NODE_TYPE=tp;ao.PAIR=bae;ao.SCALAR=XR;ao.SEQ=Aw;ao.hasAnchor=cUe;ao.isAlias=iUe;ao.isCollection=Sae;ao.isDocument=aUe;ao.isMap=oUe;ao.isNode=lUe;ao.isPair=sUe;ao.isScalar=wae;ao.isSeq=uUe});var u3=K(eL=>{"use strict";var _a=sn(),$s=Symbol("break visit"),Eae=Symbol("skip children"),Zc=Symbol("remove node");function Dw(e,t){let r=xae(t);_a.isDocument(e)?a4(null,e.contents,r,Object.freeze([e]))===Zc&&(e.contents=null):a4(null,e,r,Object.freeze([]))}Dw.BREAK=$s;Dw.SKIP=Eae;Dw.REMOVE=Zc;function a4(e,t,r,i){let n=$ae(e,t,r,i);if(_a.isNode(n)||_a.isPair(n))return kae(e,i,n),a4(e,n,r,i);if(typeof n!="symbol"){if(_a.isCollection(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){let o=a4(a,t.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===$s)return $s;o===Zc&&(t.items.splice(a,1),a-=1)}}}else if(_a.isPair(t)){i=Object.freeze(i.concat(t));let a=a4("key",t.key,r,i);if(a===$s)return $s;a===Zc&&(t.key=null);let o=a4("value",t.value,r,i);if(o===$s)return $s;o===Zc&&(t.value=null)}}return n}async function Ow(e,t){let r=xae(t);_a.isDocument(e)?await o4(null,e.contents,r,Object.freeze([e]))===Zc&&(e.contents=null):await o4(null,e,r,Object.freeze([]))}Ow.BREAK=$s;Ow.SKIP=Eae;Ow.REMOVE=Zc;async function o4(e,t,r,i){let n=await $ae(e,t,r,i);if(_a.isNode(n)||_a.isPair(n))return kae(e,i,n),o4(e,n,r,i);if(typeof n!="symbol"){if(_a.isCollection(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){let o=await o4(a,t.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===$s)return $s;o===Zc&&(t.items.splice(a,1),a-=1)}}}else if(_a.isPair(t)){i=Object.freeze(i.concat(t));let a=await o4("key",t.key,r,i);if(a===$s)return $s;a===Zc&&(t.key=null);let o=await o4("value",t.value,r,i);if(o===$s)return $s;o===Zc&&(t.value=null)}}return n}function xae(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function $ae(e,t,r,i){if(typeof r=="function")return r(e,t,i);if(_a.isMap(t))return r.Map?.(e,t,i);if(_a.isSeq(t))return r.Seq?.(e,t,i);if(_a.isPair(t))return r.Pair?.(e,t,i);if(_a.isScalar(t))return r.Scalar?.(e,t,i);if(_a.isAlias(t))return r.Alias?.(e,t,i)}function kae(e,t,r){let i=t[t.length-1];if(_a.isCollection(i))i.items[e]=r;else if(_a.isPair(i))e==="key"?i.key=r:i.value=r;else if(_a.isDocument(i))i.contents=r;else{let n=_a.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}eL.visit=Dw;eL.visitAsync=Ow});var tL=K(Dae=>{"use strict";var Aae=sn(),dUe=u3(),pUe={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},fUe=e=>e.replace(/[!,[\]{}]/g,t=>pUe[t]),l3=class e{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,r)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let i=t.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[a,o]=i;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[a]=i;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return r(6,`Unsupported YAML version ${a}`,o),!1}}default:return r(0,`Unknown directive ${n}`,!0),!1}}tagName(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,i,n]=t.match(/^(.*!)([^!]*)$/s);n||r(`The ${t} tag has no suffix`);let a=this.tags[i];if(a)try{return a+decodeURIComponent(n)}catch(o){return r(String(o)),null}return i==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,i]of Object.entries(this.tags))if(t.startsWith(i))return r+fUe(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(t&&i.length>0&&Aae.isNode(t.contents)){let a={};dUe.visit(t.contents,(o,s)=>{Aae.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of i)a==="!!"&&o==="tag:yaml.org,2002:"||(!t||n.some(s=>s.startsWith(o)))&&r.push(`%TAG ${a} ${o}`);return r.join(` `)}};l3.defaultYaml={explicit:!1,version:"1.2"};l3.defaultTags={"!!":"tag:yaml.org,2002:"};Dae.Directives=l3});var Pw=K(c3=>{"use strict";var Oae=sn(),mUe=u3();function hUe(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(r)}return!0}function Pae(e){let t=new Set;return mUe.visit(e,{Value(r,i){i.anchor&&t.add(i.anchor)}}),t}function Cae(e,t){for(let r=1;;++r){let i=`${e}${r}`;if(!t.has(i))return i}}function gUe(e,t){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Pae(e));let o=Cae(t,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(Oae.isScalar(o.node)||Oae.isCollection(o.node)))o.node.anchor=o.anchor;else{let s=new Error("Failed to resolve repeated object (this should not happen)");throw s.source=a,s}}},sourceObjects:i}}c3.anchorIsValid=hUe;c3.anchorNames=Pae;c3.createNodeAnchors=gUe;c3.findNewAnchor=Cae});var rL=K(Iae=>{"use strict";function d3(e,t,r,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,a=i.length;n<a;++n){let o=i[n],s=d3(e,i,String(n),o);s===void 0?delete i[n]:s!==o&&(i[n]=s)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let a=i.get(n),o=d3(e,i,n,a);o===void 0?i.delete(n):o!==a&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let a=d3(e,i,n,n);a===void 0?i.delete(n):a!==n&&(i.delete(n),i.add(a))}else for(let[n,a]of Object.entries(i)){let o=d3(e,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return e.call(t,r,i)}Iae.applyReviver=d3});var wf=K(Tae=>{"use strict";var vUe=sn();function jae(e,t,r){if(Array.isArray(e))return e.map((i,n)=>jae(i,String(n),r));if(e&&typeof e.toJSON=="function"){if(!r||!vUe.hasAnchor(e))return e.toJSON(t,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(e,i),r.onCreate=a=>{i.res=a,delete r.onCreate};let n=e.toJSON(t,r);return r.onCreate&&r.onCreate(n),n}return typeof e=="bigint"&&!r?.keep?Number(e):e}Tae.toJS=jae});var Cw=K(Rae=>{"use strict";var yUe=rL(),Nae=sn(),_Ue=wf(),nL=class{constructor(t){Object.defineProperty(this,Nae.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:r,maxAliasCount:i,onAnchor:n,reviver:a}={}){if(!Nae.isDocument(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},s=_Ue.toJS(this,"",o);if(typeof n=="function")for(let{count:u,res:l}of o.anchors.values())n(l,u);return typeof a=="function"?yUe.applyReviver(a,{"":s},"",s):s}};Rae.NodeBase=nL});var p3=K(Lae=>{"use strict";var bUe=Pw(),wUe=u3(),s4=sn(),SUe=Cw(),EUe=wf(),iL=class extends SUe.NodeBase{constructor(t){super(s4.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;r?.aliasResolveCache?i=r.aliasResolveCache:(i=[],wUe.visit(t,{Node:(a,o)=>{(s4.isAlias(o)||s4.hasAnchor(o))&&i.push(o)}}),r&&(r.aliasResolveCache=i));let n;for(let a of i){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(t,r){if(!r)return{source:this.source};let{anchors:i,doc:n,