agent-contracts-runtime
Version:
Runtime bridge for executing agent-contracts workflows on Agent SDKs
29 lines • 2.78 MB
JavaScript
#!/usr/bin/env node
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
var rte=Object.create;var jy=Object.defineProperty;var nte=Object.getOwnPropertyDescriptor;var ite=Object.getOwnPropertyNames;var ate=Object.getPrototypeOf,ote=Object.prototype.hasOwnProperty;var Mn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Ro=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ke=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),zn=(e,t)=>{for(var n in t)jy(e,n,{get:t[n],enumerable:!0})},ste=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ite(t))!ote.call(e,r)&&r!==n&&jy(e,r,{get:()=>t[r],enumerable:!(i=nte(t,r))||i.enumerable});return e};var Ja=(e,t,n)=>(n=e!=null?rte(ate(e)):{},ste(t||!e||!e.__esModule?jy(n,"default",{value:e,enumerable:!0}):n,e));var Lc=Ke(Ny=>{var hm=class extends Error{constructor(t,n,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=n,this.exitCode=t,this.nestedError=void 0}},Ty=class extends hm{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Ny.CommanderError=hm;Ny.InvalidArgumentError=Ty});var gm=Ke(By=>{var{InvalidArgumentError:ute}=Lc(),Ry=class{constructor(t,n){switch(this.description=n||"",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.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,n){return n===this.defaultValue||!Array.isArray(n)?[t]:n.concat(t)}default(t,n){return this.defaultValue=t,this.defaultValueDescription=n,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(n,i)=>{if(!this.argChoices.includes(n))throw new ute(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(n,i):n},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function lte(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}By.Argument=Ry;By.humanReadableArgName=lte});var Fy=Ke(Y$=>{var{humanReadableArgName:cte}=gm(),Ly=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(t){let n=t.commands.filter(r=>!r._hidden),i=t._getHelpCommand();return i&&!i._hidden&&n.push(i),this.sortSubcommands&&n.sort((r,a)=>r.name().localeCompare(a.name())),n}compareOptions(t,n){let i=r=>r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"");return i(t).localeCompare(i(n))}visibleOptions(t){let n=t.options.filter(r=>!r.hidden),i=t._getHelpOption();if(i&&!i.hidden){let r=i.short&&t._findOption(i.short),a=i.long&&t._findOption(i.long);!r&&!a?n.push(i):i.long&&!a?n.push(t.createOption(i.long,i.description)):i.short&&!r&&n.push(t.createOption(i.short,i.description))}return this.sortOptions&&n.sort(this.compareOptions),n}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let n=[];for(let i=t.parent;i;i=i.parent){let r=i.options.filter(a=>!a.hidden);n.push(...r)}return this.sortOptions&&n.sort(this.compareOptions),n}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(n=>{n.description=n.description||t._argsDescription[n.name()]||""}),t.registeredArguments.find(n=>n.description)?t.registeredArguments:[]}subcommandTerm(t){let n=t.registeredArguments.map(i=>cte(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(n?" "+n:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,n){return n.visibleCommands(t).reduce((i,r)=>Math.max(i,n.subcommandTerm(r).length),0)}longestOptionTermLength(t,n){return n.visibleOptions(t).reduce((i,r)=>Math.max(i,n.optionTerm(r).length),0)}longestGlobalOptionTermLength(t,n){return n.visibleGlobalOptions(t).reduce((i,r)=>Math.max(i,n.optionTerm(r).length),0)}longestArgumentTermLength(t,n){return n.visibleArguments(t).reduce((i,r)=>Math.max(i,n.argumentTerm(r).length),0)}commandUsage(t){let n=t._name;t._aliases[0]&&(n=n+"|"+t._aliases[0]);let i="";for(let r=t.parent;r;r=r.parent)i=r.name()+" "+i;return i+n+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let n=[];return t.argChoices&&n.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&n.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&n.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&n.push(`env: ${t.envVar}`),n.length>0?`${t.description} (${n.join(", ")})`:t.description}argumentDescription(t){let n=[];if(t.argChoices&&n.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&n.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),n.length>0){let i=`(${n.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,n){let i=n.padWidth(t,n),r=n.helpWidth||80,a=2,o=2;function s(m,h){if(h){let v=`${m.padEnd(i+o)}${h}`;return n.wrap(v,r-a,i+o)}return m}function l(m){return m.join(`
`).replace(/^/gm," ".repeat(a))}let u=[`Usage: ${n.commandUsage(t)}`,""],c=n.commandDescription(t);c.length>0&&(u=u.concat([n.wrap(c,r,0),""]));let d=n.visibleArguments(t).map(m=>s(n.argumentTerm(m),n.argumentDescription(m)));d.length>0&&(u=u.concat(["Arguments:",l(d),""]));let p=n.visibleOptions(t).map(m=>s(n.optionTerm(m),n.optionDescription(m)));if(p.length>0&&(u=u.concat(["Options:",l(p),""])),this.showGlobalOptions){let m=n.visibleGlobalOptions(t).map(h=>s(n.optionTerm(h),n.optionDescription(h)));m.length>0&&(u=u.concat(["Global Options:",l(m),""]))}let f=n.visibleCommands(t).map(m=>s(n.subcommandTerm(m),n.subcommandDescription(m)));return f.length>0&&(u=u.concat(["Commands:",l(f),""])),u.join(`
`)}padWidth(t,n){return Math.max(n.longestOptionTermLength(t,n),n.longestGlobalOptionTermLength(t,n),n.longestSubcommandTermLength(t,n),n.longestArgumentTermLength(t,n))}wrap(t,n,i,r=40){let a=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",o=new RegExp(`[\\n][${a}]+`);if(t.match(o))return t;let s=n-i;if(s<r)return t;let l=t.slice(0,i),u=t.slice(i).replace(`\r
`,`
`),c=" ".repeat(i),p="\\s\u200B",f=new RegExp(`
|.{1,${s-1}}([${p}]|$)|[^${p}]+?([${p}]|$)`,"g"),m=u.match(f)||[];return l+m.map((h,v)=>h===`
`?"":(v>0?c:"")+h.trimEnd()).join(`
`)}};Y$.Help=Ly});var qy=Ke(Uy=>{var{InvalidArgumentError:dte}=Lc(),My=class{constructor(t,n){this.flags=t,this.description=n||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let i=fte(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}default(t,n){return this.defaultValue=t,this.defaultValueDescription=n,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let n=t;return typeof t=="string"&&(n={[t]:!0}),this.implied=Object.assign(this.implied||{},n),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}_concatValue(t,n){return n===this.defaultValue||!Array.isArray(n)?[t]:n.concat(t)}choices(t){return this.argChoices=t.slice(),this.parseArg=(n,i)=>{if(!this.argChoices.includes(n))throw new dte(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(n,i):n},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return pte(this.name().replace(/^no-/,""))}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},zy=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(n=>{n.negate?this.negativeOptions.set(n.attributeName(),n):this.positiveOptions.set(n.attributeName(),n)}),this.negativeOptions.forEach((n,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(t,n){let i=n.attributeName();if(!this.dualOptions.has(i))return!0;let r=this.negativeOptions.get(i).presetArg,a=r!==void 0?r:!1;return n.negate===(a===t)}};function pte(e){return e.split("-").reduce((t,n)=>t+n[0].toUpperCase()+n.slice(1))}function fte(e){let t,n,i=e.split(/[ |,]+/);return i.length>1&&!/^[[<]/.test(i[1])&&(t=i.shift()),n=i.shift(),!t&&/^-[^-]$/.test(n)&&(t=n,n=void 0),{shortFlag:t,longFlag:n}}Uy.Option=My;Uy.DualOptions=zy});var Q$=Ke(X$=>{function mte(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let i=0;i<=e.length;i++)n[i]=[i];for(let i=0;i<=t.length;i++)n[0][i]=i;for(let i=1;i<=t.length;i++)for(let r=1;r<=e.length;r++){let a=1;e[r-1]===t[i-1]?a=0:a=1,n[r][i]=Math.min(n[r-1][i]+1,n[r][i-1]+1,n[r-1][i-1]+a),r>1&&i>1&&e[r-1]===t[i-2]&&e[r-2]===t[i-1]&&(n[r][i]=Math.min(n[r][i],n[r-2][i-2]+1))}return n[e.length][t.length]}function hte(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let n=e.startsWith("--");n&&(e=e.slice(2),t=t.map(o=>o.slice(2)));let i=[],r=3,a=.4;return t.forEach(o=>{if(o.length<=1)return;let s=mte(e,o),l=Math.max(e.length,o.length);(l-s)/l>a&&(s<r?(r=s,i=[o]):s===r&&i.push(o))}),i.sort((o,s)=>o.localeCompare(s)),n&&(i=i.map(o=>`--${o}`)),i.length>1?`
(Did you mean one of ${i.join(", ")}?)`:i.length===1?`
(Did you mean ${i[0]}?)`:""}X$.suggestSimilar=hte});var ix=Ke(nx=>{var gte=Mn("node:events").EventEmitter,Vy=Mn("node:child_process"),Ya=Mn("node:path"),Zy=Mn("node:fs"),Zr=Mn("node:process"),{Argument:vte,humanReadableArgName:yte}=gm(),{CommanderError:Gy}=Lc(),{Help:_te}=Fy(),{Option:ex,DualOptions:bte}=qy(),{suggestSimilar:tx}=Q$(),Wy=class e extends gte{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,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._outputConfiguration={writeOut:n=>Zr.stdout.write(n),writeErr:n=>Zr.stderr.write(n),getOutHelpWidth:()=>Zr.stdout.isTTY?Zr.stdout.columns:void 0,getErrHelpWidth:()=>Zr.stderr.isTTY?Zr.stderr.columns:void 0,outputError:(n,i)=>i(n)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}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 n=this;n;n=n.parent)t.push(n);return t}command(t,n,i){let r=n,a=i;typeof r=="object"&&r!==null&&(a=r,r=null),a=a||{};let[,o,s]=t.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return r&&(l.description(r),l._executableHandler=!0),a.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(a.noHelp||a.hidden),l._executableFile=a.executableFile||null,s&&l.arguments(s),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),r?this:l}createCommand(t){return new e(t)}createHelp(){return Object.assign(new _te,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(Object.assign(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,n){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
- specify the name in Command constructor or using .name()`);return n=n||{},n.isDefault&&(this._defaultCommandName=t._name),(n.noHelp||n.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,n){return new vte(t,n)}argument(t,n,i,r){let a=this.createArgument(t,n);return typeof i=="function"?a.default(r).argParser(i):a.default(i),this.addArgument(a),this}arguments(t){return t.trim().split(/ +/).forEach(n=>{this.argument(n)}),this}addArgument(t){let n=this.registeredArguments.slice(-1)[0];if(n&&n.variadic)throw new Error(`only the last argument can be variadic '${n.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,n){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,this;t=t??"help [command]";let[,i,r]=t.match(/([^ ]+) *(.*)/),a=n??"display help for command",o=this.createCommand(i);return o.helpOption(!1),r&&o.arguments(r),a&&o.description(a),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(t,n){return typeof t!="object"?(this.helpCommand(t,n),this):(this._addImplicitHelpCommand=!0,this._helpCommand=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,n){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(n):this._lifeCycleHooks[t]=[n],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=n=>{if(n.code!=="commander.executeSubCommandAsync")throw n},this}_exit(t,n,i){this._exitCallback&&this._exitCallback(new Gy(t,n,i)),Zr.exit(t)}action(t){let n=i=>{let r=this.registeredArguments.length,a=i.slice(0,r);return this._storeOptionsAsProperties?a[r]=this:a[r]=this.opts(),a.push(this),t.apply(this,a)};return this._actionHandler=n,this}createOption(t,n){return new ex(t,n)}_callParseArg(t,n,i,r){try{return t.parseArg(n,i)}catch(a){if(a.code==="commander.invalidArgument"){let o=`${r} ${a.message}`;this.error(o,{exitCode:a.exitCode,code:a.code})}throw a}}_registerOption(t){let n=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(n){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 '${n.flags}'`)}this.options.push(t)}_registerCommand(t){let n=r=>[r.name()].concat(r.aliases()),i=n(t).find(r=>this._findCommand(r));if(i){let r=n(this._findCommand(i)).join("|"),a=n(t).join("|");throw new Error(`cannot add command '${a}' as already have command '${r}'`)}this.commands.push(t)}addOption(t){this._registerOption(t);let n=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 r=(a,o,s)=>{a==null&&t.presetArg!==void 0&&(a=t.presetArg);let l=this.getOptionValue(i);a!==null&&t.parseArg?a=this._callParseArg(t,a,l,o):a!==null&&t.variadic&&(a=t._concatValue(a,l)),a==null&&(t.negate?a=!1:t.isBoolean()||t.optional?a=!0:a=""),this.setOptionValueWithSource(i,a,s)};return this.on("option:"+n,a=>{let o=`error: option '${t.flags}' argument '${a}' is invalid.`;r(a,o,"cli")}),t.envVar&&this.on("optionEnv:"+n,a=>{let o=`error: option '${t.flags}' value '${a}' from env '${t.envVar}' is invalid.`;r(a,o,"env")}),this}_optionEx(t,n,i,r,a){if(typeof n=="object"&&n instanceof ex)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(n,i);if(o.makeOptionMandatory(!!t.mandatory),typeof r=="function")o.default(a).argParser(r);else if(r instanceof RegExp){let s=r;r=(l,u)=>{let c=s.exec(l);return c?c[0]:u},o.default(a).argParser(r)}else o.default(r);return this.addOption(o)}option(t,n,i,r){return this._optionEx({},t,n,i,r)}requiredOption(t,n,i,r){return this._optionEx({mandatory:!0},t,n,i,r)}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,n){return this.setOptionValueWithSource(t,n,void 0)}setOptionValueWithSource(t,n,i){return this._storeOptionsAsProperties?this[t]=n:this._optionValues[t]=n,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let n;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(t)!==void 0&&(n=i.getOptionValueSource(t))}),n}_prepareUserArgs(t,n){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(n=n||{},t===void 0&&n.from===void 0){Zr.versions?.electron&&(n.from="electron");let r=Zr.execArgv??[];(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))&&(n.from="eval")}t===void 0&&(t=Zr.argv),this.rawArgs=t.slice();let i;switch(n.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":Zr.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: '${n.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,n){let i=this._prepareUserArgs(t,n);return this._parseCommand([],i),this}async parseAsync(t,n){let i=this._prepareUserArgs(t,n);return await this._parseCommand([],i),this}_executeSubCommand(t,n){n=n.slice();let i=!1,r=[".js",".ts",".tsx",".mjs",".cjs"];function a(c,d){let p=Ya.resolve(c,d);if(Zy.existsSync(p))return p;if(r.includes(Ya.extname(d)))return;let f=r.find(m=>Zy.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=Zy.realpathSync(this._scriptPath)}catch{c=this._scriptPath}s=Ya.resolve(Ya.dirname(c),s)}if(s){let c=a(s,o);if(!c&&!t._executableFile&&this._scriptPath){let d=Ya.basename(this._scriptPath,Ya.extname(this._scriptPath));d!==this._name&&(c=a(s,`${d}-${t._name}`))}o=c||o}i=r.includes(Ya.extname(o));let l;Zr.platform!=="win32"?i?(n.unshift(o),n=rx(Zr.execArgv).concat(n),l=Vy.spawn(Zr.argv[0],n,{stdio:"inherit"})):l=Vy.spawn(o,n,{stdio:"inherit"}):(n.unshift(o),n=rx(Zr.execArgv).concat(n),l=Vy.spawn(Zr.execPath,n,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(d=>{Zr.on(d,()=>{l.killed===!1&&l.exitCode===null&&l.kill(d)})});let u=this._exitCallback;l.on("close",c=>{c=c??1,u?u(new Gy(c,"commander.executeSubCommandAsync","(close)")):Zr.exit(c)}),l.on("error",c=>{if(c.code==="ENOENT"){let d=s?`searched for local subcommand relative to directory '${s}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",p=`'${o}' does not exist
- if '${t._name}' 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
- ${d}`;throw new Error(p)}else if(c.code==="EACCES")throw new Error(`'${o}' not executable`);if(!u)Zr.exit(1);else{let d=new Gy(1,"commander.executeSubCommandAsync","(error)");d.nestedError=c,u(d)}}),this.runningCommand=l}_dispatchSubcommand(t,n,i){let r=this._findCommand(t);r||this.help({error:!0});let a;return a=this._chainOrCallSubCommandHook(a,r,"preSubcommand"),a=this._chainOrCall(a,()=>{if(r._executableHandler)this._executeSubCommand(r,n.concat(i));else return r._parseCommand(n,i)}),a}_dispatchHelpCommand(t){t||this.help();let n=this._findCommand(t);return n&&!n._executableHandler&&n.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,n)=>{t.required&&this.args[n]==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,r,a)=>{let o=r;if(r!==null&&i.parseArg){let s=`error: command-argument value '${r}' is invalid for argument '${i.name()}'.`;o=this._callParseArg(i,r,a,s)}return o};this._checkNumberOfArguments();let n=[];this.registeredArguments.forEach((i,r)=>{let a=i.defaultValue;i.variadic?r<this.args.length?(a=this.args.slice(r),i.parseArg&&(a=a.reduce((o,s)=>t(i,s,o),i.defaultValue))):a===void 0&&(a=[]):r<this.args.length&&(a=this.args[r],i.parseArg&&(a=t(i,a,i.defaultValue))),n[r]=a}),this.processedArgs=n}_chainOrCall(t,n){return t&&t.then&&typeof t.then=="function"?t.then(()=>n()):n()}_chainOrCallHooks(t,n){let i=t,r=[];return this._getCommandAndAncestors().reverse().filter(a=>a._lifeCycleHooks[n]!==void 0).forEach(a=>{a._lifeCycleHooks[n].forEach(o=>{r.push({hookedCommand:a,callback:o})})}),n==="postAction"&&r.reverse(),r.forEach(a=>{i=this._chainOrCall(i,()=>a.callback(a.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,n,i){let r=t;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(a=>{r=this._chainOrCall(r,()=>a(this,n))}),r}_parseCommand(t,n){let i=this.parseOptions(n);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),n=i.unknown,this.args=t.concat(n),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),n);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(n),this._dispatchSubcommand(this._defaultCommandName,t,n);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},a=`command:${this.name()}`;if(this._actionHandler){r(),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,n)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent&&this.parent.listenerCount(a))r(),this._processArguments(),this.parent.emit(a,t,n);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,n);this.listenerCount("command:*")?this.emit("command:*",t,n):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(n=>n._name===t||n._aliases.includes(t))}_findOption(t){return this.options.find(n=>n.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(n=>{n.mandatory&&t.getOptionValue(n.attributeName())===void 0&&t.missingMandatoryOptionValue(n)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(i=>{let r=i.attributeName();return this.getOptionValue(r)===void 0?!1:this.getOptionValueSource(r)!=="default"});t.filter(i=>i.conflictsWith.length>0).forEach(i=>{let r=t.find(a=>i.conflictsWith.includes(a.attributeName()));r&&this._conflictingOption(i,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let n=[],i=[],r=n,a=t.slice();function o(l){return l.length>1&&l[0]==="-"}let s=null;for(;a.length;){let l=a.shift();if(l==="--"){r===i&&r.push(l),r.push(...a);break}if(s&&!o(l)){this.emit(`option:${s.name()}`,l);continue}if(s=null,o(l)){let u=this._findOption(l);if(u){if(u.required){let c=a.shift();c===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,c)}else if(u.optional){let c=null;a.length>0&&!o(a[0])&&(c=a.shift()),this.emit(`option:${u.name()}`,c)}else this.emit(`option:${u.name()}`);s=u.variadic?u:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let u=this._findOption(`-${l[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,l.slice(2)):(this.emit(`option:${u.name()}`),a.unshift(`-${l.slice(2)}`));continue}}if(/^--[^=]+=/.test(l)){let u=l.indexOf("="),c=this._findOption(l.slice(0,u));if(c&&(c.required||c.optional)){this.emit(`option:${c.name()}`,l.slice(u+1));continue}}if(o(l)&&(r=i),(this._enablePositionalOptions||this._passThroughOptions)&&n.length===0&&i.length===0){if(this._findCommand(l)){n.push(l),a.length>0&&i.push(...a);break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){n.push(l),a.length>0&&n.push(...a);break}else if(this._defaultCommandName){i.push(l),a.length>0&&i.push(...a);break}}if(this._passThroughOptions){r.push(l),a.length>0&&r.push(...a);break}r.push(l)}return{operands:n,unknown:i}}opts(){if(this._storeOptionsAsProperties){let t={},n=this.options.length;for(let i=0;i<n;i++){let r=this.options[i].attributeName();t[r]=r===this._versionOptionName?this._version:this[r]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,n)=>Object.assign(t,n.opts()),{})}error(t,n){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=n||{},r=i.exitCode||1,a=i.code||"commander.error";this._exit(r,a,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in Zr.env){let n=t.attributeName();(this.getOptionValue(n)===void 0||["default","config","env"].includes(this.getOptionValueSource(n)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,Zr.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new bte(this.options),n=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&n(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(r=>!n(r)).forEach(r=>{this.setOptionValueWithSource(r,i.implied[r],"implied")})})}missingArgument(t){let n=`error: missing required argument '${t}'`;this.error(n,{code:"commander.missingArgument"})}optionMissingArgument(t){let n=`error: option '${t.flags}' argument missing`;this.error(n,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let n=`error: required option '${t.flags}' not specified`;this.error(n,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,n){let i=o=>{let s=o.attributeName(),l=this.getOptionValue(s),u=this.options.find(d=>d.negate&&s===d.attributeName()),c=this.options.find(d=>!d.negate&&s===d.attributeName());return u&&(u.presetArg===void 0&&l===!1||u.presetArg!==void 0&&l===u.presetArg)?u:c||o},r=o=>{let s=i(o),l=s.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${s.envVar}'`:`option '${s.flags}'`},a=`error: ${r(t)} cannot be used with ${r(n)}`;this.error(a,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let n="";if(t.startsWith("--")&&this._showSuggestionAfterError){let r=[],a=this;do{let o=a.createHelp().visibleOptions(a).filter(s=>s.long).map(s=>s.long);r=r.concat(o),a=a.parent}while(a&&!a._enablePositionalOptions);n=tx(t,r)}let i=`error: unknown option '${t}'${n}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let n=this.registeredArguments.length,i=n===1?"":"s",a=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${n} argument${i} but got ${t.length}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],n="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach(a=>{r.push(a.name()),a.alias()&&r.push(a.alias())}),n=tx(t,r)}let i=`error: unknown command '${t}'${n}`;this.error(i,{code:"commander.unknownCommand"})}version(t,n,i){if(t===void 0)return this._version;this._version=t,n=n||"-V, --version",i=i||"output the version number";let r=this.createOption(n,i);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${t}
`),this._exit(0,"commander.version",t)}),this}description(t,n){return t===void 0&&n===void 0?this._description:(this._description=t,n&&(this._argsDescription=n),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let n=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(n=this.commands[this.commands.length-1]),t===n._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let r=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${r}'`)}return n._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(n=>this.alias(n)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let n=this.registeredArguments.map(i=>yte(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?n:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=Ya.basename(t,Ya.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let n=this.createHelp();return n.helpWidth===void 0&&(n.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),n.formatHelp(this,n)}_getHelpContext(t){t=t||{};let n={error:!!t.error},i;return n.error?i=r=>this._outputConfiguration.writeErr(r):i=r=>this._outputConfiguration.writeOut(r),n.write=t.write||i,n.command=this,n}outputHelp(t){let n;typeof t=="function"&&(n=t,t=void 0);let i=this._getHelpContext(t);this._getCommandAndAncestors().reverse().forEach(a=>a.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let r=this.helpInformation(i);if(n&&(r=n(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(a=>a.emit("afterAllHelp",i))}helpOption(t,n){return typeof t=="boolean"?(t?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(t=t??"-h, --help",n=n??"display help for command",this._helpOption=this.createOption(t,n),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this}help(t){this.outputHelp(t);let n=Zr.exitCode||0;n===0&&t&&typeof t!="function"&&t.error&&(n=1),this._exit(n,"commander.help","(outputHelp)")}addHelpText(t,n){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 r=`${t}Help`;return this.on(r,a=>{let o;typeof n=="function"?o=n({error:a.error,command:a.command}):o=n,o&&a.write(`${o}
`)}),this}_outputHelpIfRequested(t){let n=this._getHelpOption();n&&t.find(r=>n.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function rx(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let n,i="127.0.0.1",r="9229",a;return(a=t.match(/^(--inspect(-brk)?)$/))!==null?n=a[1]:(a=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(n=a[1],/^\d+$/.test(a[3])?r=a[3]:i=a[3]):(a=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(n=a[1],i=a[3],r=a[4]),n&&r!=="0"?`${n}=${i}:${parseInt(r)+1}`:t})}nx.Command=Wy});var ux=Ke(Fi=>{var{Argument:ax}=gm(),{Command:Ky}=ix(),{CommanderError:wte,InvalidArgumentError:ox}=Lc(),{Help:kte}=Fy(),{Option:sx}=qy();Fi.program=new Ky;Fi.createCommand=e=>new Ky(e);Fi.createOption=(e,t)=>new sx(e,t);Fi.createArgument=(e,t)=>new ax(e,t);Fi.Command=Ky;Fi.Option=sx;Fi.Argument=ax;Fi.Help=kte;Fi.CommanderError=wte;Fi.InvalidArgumentError=ox;Fi.InvalidOptionArgumentError=ox});var mr=Ke(kn=>{"use strict";var Hy=Symbol.for("yaml.alias"),mx=Symbol.for("yaml.document"),vm=Symbol.for("yaml.map"),hx=Symbol.for("yaml.pair"),Jy=Symbol.for("yaml.scalar"),ym=Symbol.for("yaml.seq"),Xa=Symbol.for("yaml.node.type"),Ste=e=>!!e&&typeof e=="object"&&e[Xa]===Hy,Ete=e=>!!e&&typeof e=="object"&&e[Xa]===mx,$te=e=>!!e&&typeof e=="object"&&e[Xa]===vm,xte=e=>!!e&&typeof e=="object"&&e[Xa]===hx,gx=e=>!!e&&typeof e=="object"&&e[Xa]===Jy,Ate=e=>!!e&&typeof e=="object"&&e[Xa]===ym;function vx(e){if(e&&typeof e=="object")switch(e[Xa]){case vm:case ym:return!0}return!1}function Dte(e){if(e&&typeof e=="object")switch(e[Xa]){case Hy:case vm:case Jy:case ym:return!0}return!1}var Cte=e=>(gx(e)||vx(e))&&!!e.anchor;kn.ALIAS=Hy;kn.DOC=mx;kn.MAP=vm;kn.NODE_TYPE=Xa;kn.PAIR=hx;kn.SCALAR=Jy;kn.SEQ=ym;kn.hasAnchor=Cte;kn.isAlias=Ste;kn.isCollection=vx;kn.isDocument=Ete;kn.isMap=$te;kn.isNode=Dte;kn.isPair=xte;kn.isScalar=gx;kn.isSeq=Ate});var Fc=Ke(Yy=>{"use strict";var sn=mr(),ti=Symbol("break visit"),yx=Symbol("skip children"),ka=Symbol("remove node");function _m(e,t){let n=_x(t);sn.isDocument(e)?Zu(null,e.contents,n,Object.freeze([e]))===ka&&(e.contents=null):Zu(null,e,n,Object.freeze([]))}_m.BREAK=ti;_m.SKIP=yx;_m.REMOVE=ka;function Zu(e,t,n,i){let r=bx(e,t,n,i);if(sn.isNode(r)||sn.isPair(r))return wx(e,i,r),Zu(e,r,n,i);if(typeof r!="symbol"){if(sn.isCollection(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){let o=Zu(a,t.items[a],n,i);if(typeof o=="number")a=o-1;else{if(o===ti)return ti;o===ka&&(t.items.splice(a,1),a-=1)}}}else if(sn.isPair(t)){i=Object.freeze(i.concat(t));let a=Zu("key",t.key,n,i);if(a===ti)return ti;a===ka&&(t.key=null);let o=Zu("value",t.value,n,i);if(o===ti)return ti;o===ka&&(t.value=null)}}return r}async function bm(e,t){let n=_x(t);sn.isDocument(e)?await Gu(null,e.contents,n,Object.freeze([e]))===ka&&(e.contents=null):await Gu(null,e,n,Object.freeze([]))}bm.BREAK=ti;bm.SKIP=yx;bm.REMOVE=ka;async function Gu(e,t,n,i){let r=await bx(e,t,n,i);if(sn.isNode(r)||sn.isPair(r))return wx(e,i,r),Gu(e,r,n,i);if(typeof r!="symbol"){if(sn.isCollection(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){let o=await Gu(a,t.items[a],n,i);if(typeof o=="number")a=o-1;else{if(o===ti)return ti;o===ka&&(t.items.splice(a,1),a-=1)}}}else if(sn.isPair(t)){i=Object.freeze(i.concat(t));let a=await Gu("key",t.key,n,i);if(a===ti)return ti;a===ka&&(t.key=null);let o=await Gu("value",t.value,n,i);if(o===ti)return ti;o===ka&&(t.value=null)}}return r}function _x(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 bx(e,t,n,i){if(typeof n=="function")return n(e,t,i);if(sn.isMap(t))return n.Map?.(e,t,i);if(sn.isSeq(t))return n.Seq?.(e,t,i);if(sn.isPair(t))return n.Pair?.(e,t,i);if(sn.isScalar(t))return n.Scalar?.(e,t,i);if(sn.isAlias(t))return n.Alias?.(e,t,i)}function wx(e,t,n){let i=t[t.length-1];if(sn.isCollection(i))i.items[e]=n;else if(sn.isPair(i))e==="key"?i.key=n:i.value=n;else if(sn.isDocument(i))i.contents=n;else{let r=sn.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}Yy.visit=_m;Yy.visitAsync=bm});var Xy=Ke(Sx=>{"use strict";var kx=mr(),Pte=Fc(),Ote={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ite=e=>e.replace(/[!,[\]{}]/g,t=>Ote[t]),Mc=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}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,n){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]+/),r=i.shift();switch(r){case"%TAG":{if(i.length!==2&&(n(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 n(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 n(6,`Unsupported YAML version ${a}`,o),!1}}default:return n(0,`Unknown directive ${r}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}let[,i,r]=t.match(/^(.*!)([^!]*)$/s);r||n(`The ${t} tag has no suffix`);let a=this.tags[i];if(a)try{return a+decodeURIComponent(r)}catch(o){return n(String(o)),null}return i==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[n,i]of Object.entries(this.tags))if(t.startsWith(i))return n+Ite(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),r;if(t&&i.length>0&&kx.isNode(t.contents)){let a={};Pte.visit(t.contents,(o,s)=>{kx.isNode(s)&&s.tag&&(a[s.tag]=!0)}),r=Object.keys(a)}else r=[];for(let[a,o]of i)a==="!!"&&o==="tag:yaml.org,2002:"||(!t||r.some(s=>s.startsWith(o)))&&n.push(`%TAG ${a} ${o}`);return n.join(`
`)}};Mc.defaultYaml={explicit:!1,version:"1.2"};Mc.defaultTags={"!!":"tag:yaml.org,2002:"};Sx.Directives=Mc});var wm=Ke(zc=>{"use strict";var Ex=mr(),jte=Fc();function Tte(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}function $x(e){let t=new Set;return jte.visit(e,{Value(n,i){i.anchor&&t.add(i.anchor)}}),t}function xx(e,t){for(let n=1;;++n){let i=`${e}${n}`;if(!t.has(i))return i}}function Nte(e,t){let n=[],i=new Map,r=null;return{onAnchor:a=>{n.push(a),r??(r=$x(e));let o=xx(t,r);return r.add(o),o},setAnchors:()=>{for(let a of n){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(Ex.isScalar(o.node)||Ex.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}}zc.anchorIsValid=Tte;zc.anchorNames=$x;zc.createNodeAnchors=Nte;zc.findNewAnchor=xx});var Qy=Ke(Ax=>{"use strict";function Uc(e,t,n,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let r=0,a=i.length;r<a;++r){let o=i[r],s=Uc(e,i,String(r),o);s===void 0?delete i[r]:s!==o&&(i[r]=s)}else if(i instanceof Map)for(let r of Array.from(i.keys())){let a=i.get(r),o=Uc(e,i,r,a);o===void 0?i.delete(r):o!==a&&i.set(r,o)}else if(i instanceof Set)for(let r of Array.from(i)){let a=Uc(e,i,r,r);a===void 0?i.delete(r):a!==r&&(i.delete(r),i.add(a))}else for(let[r,a]of Object.entries(i)){let o=Uc(e,i,r,a);o===void 0?delete i[r]:o!==a&&(i[r]=o)}return e.call(t,n,i)}Ax.applyReviver=Uc});var Bo=Ke(Cx=>{"use strict";var Rte=mr();function Dx(e,t,n){if(Array.isArray(e))return e.map((i,r)=>Dx(i,String(r),n));if(e&&typeof e.toJSON=="function"){if(!n||!Rte.hasAnchor(e))return e.toJSON(t,n);let i={aliasCount:0,count:1,res:void 0};n.anchors.set(e,i),n.onCreate=a=>{i.res=a,delete n.onCreate};let r=e.toJSON(t,n);return n.onCreate&&n.onCreate(r),r}return typeof e=="bigint"&&!n?.keep?Number(e):e}Cx.toJS=Dx});var km=Ke(Ox=>{"use strict";var Bte=Qy(),Px=mr(),Lte=Bo(),e2=class{constructor(t){Object.defineProperty(this,Px.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:n,maxAliasCount:i,onAnchor:r,reviver:a}={}){if(!Px.isDocument(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},s=Lte.toJS(this,"",o);if(typeof r=="function")for(let{count:l,res:u}of o.anchors.values())r(u,l);return typeof a=="function"?Bte.applyReviver(a,{"":s},"",s):s}};Ox.NodeBase=e2});var qc=Ke(Ix=>{"use strict";var Fte=wm(),Mte=Fc(),Wu=mr(),zte=km(),Ute=Bo(),t2=class extends zte.NodeBase{constructor(t){super(Wu.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;n?.aliasResolveCache?i=n.aliasResolveCache:(i=[],Mte.visit(t,{Node:(a,o)=>{(Wu.isAlias(o)||Wu.hasAnchor(o))&&i.push(o)}}),n&&(n.aliasResolveCache=i));let r;for(let a of i){if(a===this)break;a.anchor===this.source&&(r=a)}return r}toJSON(t,n){if(!n)return{source:this.source};let{anchors:i,doc:r,maxAliasCount:a}=n,o=this.resolve(r,n);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let s=i.get(o);if(s||(Ute.toJS(o,null,n),s=i.get(o)),s?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(a>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=Sm(r,o,i)),s.count*s.aliasCount>a)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return s.res}toString(t,n,i){let r=`*${this.source}`;if(t){if(Fte.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(t.implicitKey)return`${r} `}return r}};function Sm(e,t,n){if(Wu.isAlias(t)){let i=t.resolve(e),r=n&&i&&n.get(i);return r?r.count*r.aliasCount:0}else if(Wu.isCollection(t)){let i=0;for(let r of t.items){let a=Sm(e,r,n);a>i&&(i=a)}return i}else if(Wu.isPair(t)){let i=Sm(e,t.key,n),r=Sm(e,t.value,n);return Math.max(i,r)}return 1}Ix.Alias=t2});var tn=Ke(r2=>{"use strict";var qte=mr(),Vte=km(),Zte=Bo(),Gte=e=>!e||typeof e!="function"&&typeof e!="object",Lo=class extends Vte.NodeBase{constructor(t){super(qte.SCALAR),this.value=t}toJSON(t,n){return n?.keep?this.value:Zte.toJS(this.value,t,n)}toString(){return String(this.value)}};Lo.BLOCK_FOLDED="BLOCK_FOLDED";Lo.BLOCK_LITERAL="BLOCK_LITERAL";Lo.PLAIN="PLAIN";Lo.QUOTE_DOUBLE="QUOTE_DOUBLE";Lo.QUOTE_SINGLE="QUOTE_SINGLE";r2.Scalar=Lo;r2.isScalarValue=Gte});var Vc=Ke(Tx=>{"use strict";var Wte=qc(),Ns=mr(),jx=tn(),Kte="tag:yaml.org,2002:";function Hte(e,t,n){if(t){let i=n.filter(a=>a.tag===t),r=i.find(a=>!a.format)??i[0];if(!r)throw new Error(`Tag ${t} not found`);return r}return n.find(i=>i.identify?.(e)&&!i.format)}function Jte(e,t,n){if(Ns.isDocument(e)&&(e=e.contents),Ns.isNode(e))return e;if(Ns.isPair(e)){let d=n.schema[Ns.MAP].createNode?.(n.schema,null,n);return d.items.push(e),d}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:i,onAnchor:r,onTagObj:a,schema:o,sourceObjects:s}=n,l;if(i&&e&&typeof e=="object"){if(l=s.get(e),l)return l.anchor??(l.anchor=r(e)),new Wte.Alias(l.anchor);l={anchor:null,node:null},s.set(e,l)}t?.startsWith("!!")&&(t=Kte+t.slice(2));let u=Hte(e,t,o.tags);if(!u){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new jx.Scalar(e);return l&&(l.node=d),d}u=e instanceof Map?o[Ns.MAP]:Symbol.iterator in Object(e)?o[Ns.SEQ]:o[Ns.MAP]}a&&(a(u),delete n.onTagObj);let c=u?.createNode?u.createNode(n.schema,e,n):typeof u?.nodeClass?.from=="function"?u.nodeClass.from(n.schema,e,n):new jx.Scalar(e);return t?c.tag=t:u.default||(c.tag=u.tag),l&&(l.node=c),c}Tx.createNode=Jte});var $m=Ke(Em=>{"use strict";var Yte=Vc(),Sa=mr(),Xte=km();function n2(e,t,n){let i=n;for(let r=t.length-1;r>=0;--r){let a=t[r];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){let o=[];o[a]=i,i=o}else i=new Map([[a,i]])}return Yte.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Nx=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,i2=class extends Xte.NodeBase{constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(i=>Sa.isNode(i)||Sa.isPair(i)?i.clone(t):i),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(Nx(t))this.add(n);else{let[i,...r]=t,a=this.get(i,!0);if(Sa.isCollection(a))a.addIn(r,n);else if(a===void 0&&this.schema)this.set(i,n2(this.schema,r,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}deleteIn(t){let[n,...i]=t;if(i.length===0)return this.delete(n);let r=this.get(n,!0);if(Sa.isCollection(r))return r.deleteIn(i);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}getIn(t,n){let[i,...r]=t,a=this.get(i,!0);return r.length===0?!n&&Sa.isScalar(a)?a.value:a:Sa.isCollection(a)?a.getIn(r,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!Sa.isPair(n))return!1;let i=n.value;return i==null||t&&Sa.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(t){let[n,...i]=t;if(i.length===0)return this.has(n);let r=this.get(n,!0);return Sa.isCollection(r)?r.hasIn(i):!1}setIn(t,n){let[i,...r]=t;if(r.length===0)this.set(i,n);else{let a=this.get(i,!0);if(Sa.isCollection(a))a.setIn(r,n);else if(a===void 0&&this.schema)this.set(i,n2(this.schema,r,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}};Em.Collection=i2;Em.collectionFromPath=n2;Em.isEmptyPath=Nx});var Zc=Ke(xm=>{"use strict";var Qte=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function a2(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var ere=(e,t,n)=>e.endsWith(`
`)?a2(n,t):n.includes(`
`)?`
`+a2(n,t):(e.endsWith(" ")?"":" ")+n;xm.indentComment=a2;xm.lineComment=ere;xm.stringifyComment=Qte});var Bx=Ke(Gc=>{"use strict";var tre="flow",o2="block",Am="quoted";function rre(e,t,n="flow",{indentAtStart:i,lineWidth:r=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!r||r<0)return e;r<a&&(a=0);let l=Math.max(1+a,1+r-t.length);if(e.length<=l)return e;let u=[],c={},d=r-t.length;typeof i=="number"&&(i>r-Math.max(2,a)?u.push(0):d=r-i);let p,f,m=!1,h=-1,v=-1,y=-1;n===o2&&(h=Rx(e,h,t.length),h!==-1&&(d=h+l));for(let w;w=e[h+=1];){if(n===Am&&w==="\\"){switch(v=h,e[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}y=h}if(w=