UNPKG

@pixelfactory/privatebin

Version:
2 lines 617 kB
#!/usr/bin/env node "use strict";var e=require("node:events"),t=require("node:child_process"),n=require("node:path"),i=require("node:fs"),s=require("node:process"),r=require("fs"),a=require("path"),o=require("buffer"),c=require("crypto"),l=require("process"),u=require("node:readline"),p=require("node:async_hooks"),h=require("stream"),d=require("tty"),m=require("node:tty"),f=require("util"),g=require("http"),y=require("https"),b=require("url"),v=require("assert"),x=require("zlib"),w=require("events");function D(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var k=D(l),E=D(u);function A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _,C,S={},B={},O={};function N(){if(_)return O;_=1;class e extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}}return O.CommanderError=e,O.InvalidArgumentError=class extends e{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},O}function F(){if(C)return B;C=1;const{InvalidArgumentError:e}=N();return B.Argument=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.length>3&&"..."===this._name.slice(-3)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},B.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"},B}var T,U={},L={};function R(){if(T)return L;T=1;const{humanReadableArgName:e}=F();return L.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){const t=e.commands.filter((e=>!e._hidden)),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort(((e,t)=>e.name().localeCompare(t.name()))),t}compareOptions(e,t){const n=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){const t=e.options.filter((e=>!e.hidden)),n=e._getHelpOption();if(n&&!n.hidden){const i=n.short&&e._findOption(n.short),s=n.long&&e._findOption(n.long);i||s?n.long&&!s?t.push(e.createOption(n.long,n.description)):n.short&&!i&&t.push(e.createOption(n.short,n.description)):t.push(n)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];const t=[];for(let n=e.parent;n;n=n.parent){const e=n.options.filter((e=>!e.hidden));t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach((t=>{t.description=t.description||e._argsDescription[t.name()]||""})),e.registeredArguments.find((e=>e.description))?e.registeredArguments:[]}subcommandTerm(t){const n=t.registeredArguments.map((t=>e(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(n?" "+n:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce(((e,n)=>Math.max(e,t.subcommandTerm(n).length)),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce(((e,n)=>Math.max(e,t.optionTerm(n).length)),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce(((e,n)=>Math.max(e,t.optionTerm(n).length)),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce(((e,n)=>Math.max(e,t.argumentTerm(n).length)),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let t=e.parent;t;t=t.parent)n=t.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map((e=>JSON.stringify(e))).join(", ")}`),void 0!==e.defaultValue){(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}return void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map((e=>JSON.stringify(e))).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){const n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatHelp(e,t){const n=t.padWidth(e,t),i=t.helpWidth||80;function s(e,s){if(s){const r=`${e.padEnd(n+2)}${s}`;return t.wrap(r,i-2,n+2)}return e}function r(e){return e.join("\n").replace(/^/gm," ".repeat(2))}let a=[`Usage: ${t.commandUsage(e)}`,""];const o=t.commandDescription(e);o.length>0&&(a=a.concat([t.wrap(o,i,0),""]));const c=t.visibleArguments(e).map((e=>s(t.argumentTerm(e),t.argumentDescription(e))));c.length>0&&(a=a.concat(["Arguments:",r(c),""]));const l=t.visibleOptions(e).map((e=>s(t.optionTerm(e),t.optionDescription(e))));if(l.length>0&&(a=a.concat(["Options:",r(l),""])),this.showGlobalOptions){const n=t.visibleGlobalOptions(e).map((e=>s(t.optionTerm(e),t.optionDescription(e))));n.length>0&&(a=a.concat(["Global Options:",r(n),""]))}const u=t.visibleCommands(e).map((e=>s(t.subcommandTerm(e),t.subcommandDescription(e))));return u.length>0&&(a=a.concat(["Commands:",r(u),""])),a.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,n,i=40){const s=new RegExp("[\\n][ \\f\\t\\v   -    \ufeff]+");if(e.match(s))return e;const r=t-n;if(r<i)return e;const a=e.slice(0,n),o=e.slice(n).replace("\r\n","\n"),c=" ".repeat(n),l="\\s​",u=new RegExp(`\n|.{1,${r-1}}([${l}]|$)|[^${l}]+?([${l}]|$)`,"g");return a+(o.match(u)||[]).map(((e,t)=>"\n"===e?"":(t>0?c:"")+e.trimEnd())).join("\n")}},L}var K,j={};function I(){if(K)return j;K=1;const{InvalidArgumentError:e}=N();return j.Option=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;const n=function(e){let t,n;const i=e.split(/[ |,]+/);i.length>1&&!/^[[<]/.test(i[1])&&(t=i.shift());n=i.shift(),!t&&/^-[^-]$/.test(n)&&(t=n,n=void 0);return{shortFlag:t,longFlag:n}}(e);this.short=n.shortFlag,this.long=n.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(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return"string"==typeof e&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.name().replace(/^no-/,"").split("-").reduce(((e,t)=>e+t[0].toUpperCase()+t.slice(1)))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},j.DualOptions=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach((e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)})),this.negativeOptions.forEach(((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)}))}valueFromOption(e,t){const n=t.attributeName();if(!this.dualOptions.has(n))return!0;const i=this.negativeOptions.get(n).presetArg,s=void 0!==i&&i;return t.negate===(s===e)}},j}var P,$,z,M={};function H(){if(P)return M;P=1;return M.suggestSimilar=function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));const n=e.startsWith("--");n&&(e=e.slice(2),t=t.map((e=>e.slice(2))));let i=[],s=3;return t.forEach((t=>{if(t.length<=1)return;const n=function(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);const n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let i=1;i<=t.length;i++)for(let s=1;s<=e.length;s++){let r=1;r=e[s-1]===t[i-1]?0:1,n[s][i]=Math.min(n[s-1][i]+1,n[s][i-1]+1,n[s-1][i-1]+r),s>1&&i>1&&e[s-1]===t[i-2]&&e[s-2]===t[i-1]&&(n[s][i]=Math.min(n[s][i],n[s-2][i-2]+1))}return n[e.length][t.length]}(e,t),r=Math.max(e.length,t.length);(r-n)/r>.4&&(n<s?(s=n,i=[t]):n===s&&i.push(t))})),i.sort(((e,t)=>e.localeCompare(t))),n&&(i=i.map((e=>`--${e}`))),i.length>1?`\n(Did you mean one of ${i.join(", ")}?)`:1===i.length?`\n(Did you mean ${i[0]}?)`:""},M}var q=function(){if(z)return S;z=1;const{Argument:r}=F(),{Command:a}=function(){if($)return U;$=1;const r=e.EventEmitter,a=t,o=n,c=i,l=s,{Argument:u,humanReadableArgName:p}=F(),{CommanderError:h}=N(),{Help:d}=R(),{Option:m,DualOptions:f}=I(),{suggestSimilar:g}=H();class y extends r{constructor(e){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=e||"",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:e=>l.stdout.write(e),writeErr:e=>l.stderr.write(e),getOutHelpWidth:()=>l.stdout.isTTY?l.stdout.columns:void 0,getErrHelpWidth:()=>l.stderr.isTTY?l.stderr.columns:void 0,outputError:(e,t)=>t(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){const e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let i=t,s=n;"object"==typeof i&&null!==i&&(s=i,i=null),s=s||{};const[,r,a]=e.match(/([^ ]+) *(.*)/),o=this.createCommand(r);return i&&(o.description(i),o._executableHandler=!0),s.isDefault&&(this._defaultCommandName=o._name),o._hidden=!(!s.noHelp&&!s.hidden),o._executableFile=s.executableFile||null,a&&o.arguments(a),this._registerCommand(o),o.parent=this,o.copyInheritedSettings(this),i?this:o}createCommand(e){return new y(e)}createHelp(){return Object.assign(new d,this.configureHelp())}configureHelp(e){return void 0===e?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return void 0===e?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return"string"!=typeof e&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(t=t||{}).isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new u(e,t)}argument(e,t,n,i){const s=this.createArgument(e,t);return"function"==typeof n?s.default(i).argParser(n):s.default(n),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach((e=>{this.argument(e)})),this}addArgument(e){const t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&void 0!==e.defaultValue&&void 0===e.parseArg)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if("boolean"==typeof e)return this._addImplicitHelpCommand=e,this;e=e??"help [command]";const[,n,i]=e.match(/([^ ]+) *(.*)/),s=t??"display help for command",r=this.createCommand(n);return r.helpOption(!1),i&&r.arguments(i),s&&r.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=r,this}addHelpCommand(e,t){return"object"!=typeof e?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(void 0===this._helpCommand&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){const n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return this._exitCallback=e||(e=>{if("commander.executeSubCommandAsync"!==e.code)throw e}),this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new h(e,t,n)),l.exit(e)}action(e){return this._actionHandler=t=>{const n=this.registeredArguments.length,i=t.slice(0,n);return this._storeOptionsAsProperties?i[n]=this:i[n]=this.opts(),i.push(this),e.apply(this,i)},this}createOption(e,t){return new m(e,t)}_callParseArg(e,t,n,i){try{return e.parseArg(t,n)}catch(e){if("commander.invalidArgument"===e.code){const t=`${i} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}_registerOption(e){const t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){const n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'\n- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){const t=e=>[e.name()].concat(e.aliases()),n=t(e).find((e=>this._findCommand(e)));if(n){const i=t(this._findCommand(n)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${i}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);const t=e.name(),n=e.attributeName();if(e.negate){const t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(n,void 0===e.defaultValue||e.defaultValue,"default")}else void 0!==e.defaultValue&&this.setOptionValueWithSource(n,e.defaultValue,"default");const i=(t,i,s)=>{null==t&&void 0!==e.presetArg&&(t=e.presetArg);const r=this.getOptionValue(n);null!==t&&e.parseArg?t=this._callParseArg(e,t,r,i):null!==t&&e.variadic&&(t=e._concatValue(t,r)),null==t&&(t=!e.negate&&(!(!e.isBoolean()&&!e.optional)||"")),this.setOptionValueWithSource(n,t,s)};return this.on("option:"+t,(t=>{const n=`error: option '${e.flags}' argument '${t}' is invalid.`;i(t,n,"cli")})),e.envVar&&this.on("optionEnv:"+t,(t=>{const n=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;i(t,n,"env")})),this}_optionEx(e,t,n,i,s){if("object"==typeof t&&t instanceof m)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const r=this.createOption(t,n);if(r.makeOptionMandatory(!!e.mandatory),"function"==typeof i)r.default(s).argParser(i);else if(i instanceof RegExp){const e=i;i=(t,n)=>{const i=e.exec(t);return i?i[0]:n},r.default(s).argParser(i)}else r.default(i);return this.addOption(r)}option(e,t,n,i){return this._optionEx({},e,t,n,i)}requiredOption(e,t,n,i){return this._optionEx({mandatory:!0},e,t,n,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,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(e=!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=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach((n=>{void 0!==n.getOptionValueSource(e)&&(t=n.getOptionValueSource(e))})),t}_prepareUserArgs(e,t){if(void 0!==e&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},void 0===e&&void 0===t.from){l.versions?.electron&&(t.from="electron");const e=l.execArgv??[];(e.includes("-e")||e.includes("--eval")||e.includes("-p")||e.includes("--print"))&&(t.from="eval")}let n;switch(void 0===e&&(e=l.argv),this.rawArgs=e.slice(),t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":l.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){const n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){const n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_executeSubCommand(e,t){t=t.slice();let n=!1;const i=[".js",".ts",".tsx",".mjs",".cjs"];function s(e,t){const n=o.resolve(e,t);if(c.existsSync(n))return n;if(i.includes(o.extname(t)))return;const s=i.find((e=>c.existsSync(`${n}${e}`)));return s?`${n}${s}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r,u=e._executableFile||`${this._name}-${e._name}`,p=this._executableDir||"";if(this._scriptPath){let e;try{e=c.realpathSync(this._scriptPath)}catch(t){e=this._scriptPath}p=o.resolve(o.dirname(e),p)}if(p){let t=s(p,u);if(!t&&!e._executableFile&&this._scriptPath){const n=o.basename(this._scriptPath,o.extname(this._scriptPath));n!==this._name&&(t=s(p,`${n}-${e._name}`))}u=t||u}n=i.includes(o.extname(u)),"win32"!==l.platform?n?(t.unshift(u),t=b(l.execArgv).concat(t),r=a.spawn(l.argv[0],t,{stdio:"inherit"})):r=a.spawn(u,t,{stdio:"inherit"}):(t.unshift(u),t=b(l.execArgv).concat(t),r=a.spawn(l.execPath,t,{stdio:"inherit"})),r.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((e=>{l.on(e,(()=>{!1===r.killed&&null===r.exitCode&&r.kill(e)}))}));const d=this._exitCallback;r.on("close",(e=>{e=e??1,d?d(new h(e,"commander.executeSubCommandAsync","(close)")):l.exit(e)})),r.on("error",(t=>{if("ENOENT"===t.code){const t=p?`searched for local subcommand relative to directory '${p}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",n=`'${u}' does not exist\n - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${t}`;throw new Error(n)}if("EACCES"===t.code)throw new Error(`'${u}' not executable`);if(d){const e=new h(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,d(e)}else l.exit(1)})),this.runningCommand=r}_dispatchSubcommand(e,t,n){const i=this._findCommand(e);let s;return i||this.help({error:!0}),s=this._chainOrCallSubCommandHook(s,i,"preSubcommand"),s=this._chainOrCall(s,(()=>{if(!i._executableHandler)return i._parseCommand(t,n);this._executeSubCommand(i,t.concat(n))})),s}_dispatchHelpCommand(e){e||this.help();const t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach(((e,t)=>{e.required&&null==this.args[t]&&this.missingArgument(e.name())})),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const e=(e,t,n)=>{let i=t;if(null!==t&&e.parseArg){const s=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;i=this._callParseArg(e,t,n,s)}return i};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach(((n,i)=>{let s=n.defaultValue;n.variadic?i<this.args.length?(s=this.args.slice(i),n.parseArg&&(s=s.reduce(((t,i)=>e(n,i,t)),n.defaultValue))):void 0===s&&(s=[]):i<this.args.length&&(s=this.args[i],n.parseArg&&(s=e(n,s,n.defaultValue))),t[i]=s})),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&"function"==typeof e.then?e.then((()=>t())):t()}_chainOrCallHooks(e,t){let n=e;const i=[];return this._getCommandAndAncestors().reverse().filter((e=>void 0!==e._lifeCycleHooks[t])).forEach((e=>{e._lifeCycleHooks[t].forEach((t=>{i.push({hookedCommand:e,callback:t})}))})),"postAction"===t&&i.reverse(),i.forEach((e=>{n=this._chainOrCall(n,(()=>e.callback(e.hookedCommand,this)))})),n}_chainOrCallSubCommandHook(e,t,n){let i=e;return void 0!==this._lifeCycleHooks[n]&&this._lifeCycleHooks[n].forEach((e=>{i=this._chainOrCall(i,(()=>e(this,t)))})),i}_parseCommand(e,t){const n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const i=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){let n;return i(),this._processArguments(),n=this._chainOrCallHooks(n,"preAction"),n=this._chainOrCall(n,(()=>this._actionHandler(this.processedArgs))),this.parent&&(n=this._chainOrCall(n,(()=>{this.parent.emit(s,e,t)}))),n=this._chainOrCallHooks(n,"postAction"),n}if(this.parent&&this.parent.listenerCount(s))i(),this._processArguments(),this.parent.emit(s,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find((t=>t._name===e||t._aliases.includes(e)))}_findOption(e){return this.options.find((t=>t.is(e)))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((e=>{e.options.forEach((t=>{t.mandatory&&void 0===e.getOptionValue(t.attributeName())&&e.missingMandatoryOptionValue(t)}))}))}_checkForConflictingLocalOptions(){const e=this.options.filter((e=>{const t=e.attributeName();return void 0!==this.getOptionValue(t)&&"default"!==this.getOptionValueSource(t)})),t=e.filter((e=>e.conflictsWith.length>0));t.forEach((t=>{const n=e.find((e=>t.conflictsWith.includes(e.attributeName())));n&&this._conflictingOption(t,n)}))}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((e=>{e._checkForConflictingLocalOptions()}))}parseOptions(e){const t=[],n=[];let i=t;const s=e.slice();function r(e){return e.length>1&&"-"===e[0]}let a=null;for(;s.length;){const e=s.shift();if("--"===e){i===n&&i.push(e),i.push(...s);break}if(!a||r(e)){if(a=null,r(e)){const t=this._findOption(e);if(t){if(t.required){const e=s.shift();void 0===e&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,e)}else if(t.optional){let e=null;s.length>0&&!r(s[0])&&(e=s.shift()),this.emit(`option:${t.name()}`,e)}else this.emit(`option:${t.name()}`);a=t.variadic?t:null;continue}}if(e.length>2&&"-"===e[0]&&"-"!==e[1]){const t=this._findOption(`-${e[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,e.slice(2)):(this.emit(`option:${t.name()}`),s.unshift(`-${e.slice(2)}`));continue}}if(/^--[^=]+=/.test(e)){const t=e.indexOf("="),n=this._findOption(e.slice(0,t));if(n&&(n.required||n.optional)){this.emit(`option:${n.name()}`,e.slice(t+1));continue}}if(r(e)&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&0===t.length&&0===n.length){if(this._findCommand(e)){t.push(e),s.length>0&&n.push(...s);break}if(this._getHelpCommand()&&e===this._getHelpCommand().name()){t.push(e),s.length>0&&t.push(...s);break}if(this._defaultCommandName){n.push(e),s.length>0&&n.push(...s);break}}if(this._passThroughOptions){i.push(e),s.length>0&&i.push(...s);break}i.push(e)}else this.emit(`option:${a.name()}`,e)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){const e={},t=this.options.length;for(let n=0;n<t;n++){const t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(((e,t)=>Object.assign(e,t.opts())),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0}));const n=t||{},i=n.exitCode||1,s=n.code||"commander.error";this._exit(i,s,e)}_parseOptionsEnv(){this.options.forEach((e=>{if(e.envVar&&e.envVar in l.env){const t=e.attributeName();(void 0===this.getOptionValue(t)||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,l.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}}))}_parseOptionsImplied(){const e=new f(this.options),t=e=>void 0!==this.getOptionValue(e)&&!["default","implied"].includes(this.getOptionValueSource(e));this.options.filter((n=>void 0!==n.implied&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n))).forEach((e=>{Object.keys(e.implied).filter((e=>!t(e))).forEach((t=>{this.setOptionValueWithSource(t,e.implied[t],"implied")}))}))}missingArgument(e){const t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){const t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){const t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){const n=e=>{const t=e.attributeName(),n=this.getOptionValue(t),i=this.options.find((e=>e.negate&&t===e.attributeName())),s=this.options.find((e=>!e.negate&&t===e.attributeName()));return i&&(void 0===i.presetArg&&!1===n||void 0!==i.presetArg&&n===i.presetArg)?i:s||e},i=e=>{const t=n(e),i=t.attributeName();return"env"===this.getOptionValueSource(i)?`environment variable '${t.envVar}'`:`option '${t.flags}'`},s=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],i=this;do{const e=i.createHelp().visibleOptions(i).filter((e=>e.long)).map((e=>e.long));n=n.concat(e),i=i.parent}while(i&&!i._enablePositionalOptions);t=g(e,n)}const n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;const t=this.registeredArguments.length,n=1===t?"":"s",i=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${n} but got ${e.length}.`;this.error(i,{code:"commander.excessArguments"})}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const n=[];this.createHelp().visibleCommands(this).forEach((e=>{n.push(e.name()),e.alias()&&n.push(e.alias())})),t=g(e,n)}const n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(void 0===e)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";const i=this.createOption(t,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),(()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,"commander.version",e)})),this}description(e,t){return void 0===e&&void 0===t?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return void 0===e?this._summary:(this._summary=e,this)}alias(e){if(void 0===e)return this._aliases[0];let t=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");const n=this.parent?._findCommand(e);if(n){const t=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return void 0===e?this._aliases:(e.forEach((e=>this.alias(e))),this)}usage(e){if(void 0===e){if(this._usage)return this._usage;const e=this.registeredArguments.map((e=>p(e)));return[].concat(this.options.length||null!==this._helpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=e,this}name(e){return void 0===e?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=o.basename(e,o.extname(e)),this}executableDir(e){return void 0===e?this._executableDir:(this._executableDir=e,this)}helpInformation(e){const t=this.createHelp();return void 0===t.helpWidth&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){const t={error:!!(e=e||{}).error};let n;return n=t.error?e=>this._outputConfiguration.writeErr(e):e=>this._outputConfiguration.writeOut(e),t.write=e.write||n,t.command=this,t}outputHelp(e){let t;"function"==typeof e&&(t=e,e=void 0);const n=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach((e=>e.emit("beforeAllHelp",n))),this.emit("beforeHelp",n);let i=this.helpInformation(n);if(t&&(i=t(i),"string"!=typeof i&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach((e=>e.emit("afterAllHelp",n)))}helpOption(e,t){return"boolean"==typeof e?(this._helpOption=e?this._helpOption??void 0:null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return void 0===this._helpOption&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=l.exitCode||0;0===t&&e&&"function"!=typeof e&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${n.join("', '")}'`);const i=`${e}Help`;return this.on(i,(e=>{let n;n="function"==typeof t?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)})),this}_outputHelpIfRequested(e){const t=this._getHelpOption();t&&e.find((e=>t.is(e)))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}}function b(e){return e.map((e=>{if(!e.startsWith("--inspect"))return e;let t,n,i="127.0.0.1",s="9229";return null!==(n=e.match(/^(--inspect(-brk)?)$/))?t=n[1]:null!==(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=n[1],/^\d+$/.test(n[3])?s=n[3]:i=n[3]):null!==(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=n[1],i=n[3],s=n[4]),t&&"0"!==s?`${t}=${i}:${parseInt(s)+1}`:e}))}return U.Command=y,U}(),{CommanderError:o,InvalidArgumentError:c}=N(),{Help:l}=R(),{Option:u}=I();return S.program=new a,S.createCommand=e=>new a(e),S.createOption=(e,t)=>new u(e,t),S.createArgument=(e,t)=>new r(e,t),S.Command=a,S.Option=u,S.Argument=r,S.Help=l,S.CommanderError=o,S.InvalidArgumentError=c,S.InvalidOptionArgumentError=c,S}(),V=A(q);const{program:J,createCommand:G,createArgument:W,createOption:Y,CommanderError:Z,InvalidArgumentError:X,InvalidOptionArgumentError:Q,Command:ee,Argument:te,Option:ne,Help:ie}=V,se=(e=0)=>t=>`[${t+e}m`,re=(e=0)=>t=>`[${38+e};5;${t}m`,ae=(e=0)=>(t,n,i)=>`[${38+e};2;${t};${n};${i}m`,oe={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(oe.modifier);Object.keys(oe.color),Object.keys(oe.bgColor);const ce=function(){const e=new Map;for(const[t,n]of Object.entries(oe)){for(const[t,i]of Object.entries(n))oe[t]={open:`[${i[0]}m`,close:`[${i[1]}m`},n[t]=oe[t],e.set(i[0],i[1]);Object.defineProperty(oe,t,{value:n,enumerable:!1})}return Object.defineProperty(oe,"codes",{value:e,enumerable:!1}),oe.color.close="",oe.bgColor.close="",oe.color.ansi=se(),oe.color.ansi256=re(),oe.color.ansi16m=ae(),oe.bgColor.ansi=se(10),oe.bgColor.ansi256=re(10),oe.bgColor.ansi16m=ae(10),Object.defineProperties(oe,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value(e){const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;3===n.length&&(n=[...n].map((e=>e+e)).join(""));const i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,255&i]},enumerable:!1},hexToAnsi256:{value:e=>oe.rgbToAnsi256(...oe.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return e-8+90;let t,n,i;if(e>=232)t=(10*(e-232)+8)/255,n=t,i=t;else{const s=(e-=16)%36;t=Math.floor(e/36)/5,n=Math.floor(s/6)/5,i=s%6/5}const s=2*Math.max(t,n,i);if(0===s)return 30;let r=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(t));return 2===s&&(r+=60),r},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>oe.ansi256ToAnsi(oe.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>oe.ansi256ToAnsi(oe.hexToAnsi256(e)),enumerable:!1}}),oe}(),le=(()=>{if(navigator.userAgentData){const e=navigator.userAgentData.brands.find((({brand:e})=>"Chromium"===e));if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(navigator.userAgent)?1:0})(),ue=0!==le&&{level:le,hasBasic:!0,has256:le>=2,has16m:le>=3},pe={stdout:ue,stderr:ue};function he(e,t,n){let i=e.indexOf(t);if(-1===i)return e;const s=t.length;let r=0,a="";do{a+=e.slice(r,i)+t+n,r=i+s,i=e.indexOf(t,r)}while(-1!==i);return a+=e.slice(r),a}const{stdout:de,stderr:me}=pe,fe=Symbol("GENERATOR"),ge=Symbol("STYLER"),ye=Symbol("IS_EMPTY"),be=["ansi","ansi","ansi256","ansi16m"],ve=Object.create(null),xe=e=>{const t=(...e)=>e.join(" ");return((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const n=de?de.level:0;e.level=void 0===t.level?n:t.level})(t,e),Object.setPrototypeOf(t,we.prototype),t};function we(e){return xe(e)}Object.setPrototypeOf(we.prototype,Function.prototype);for(const[e,t]of Object.entries(ce))ve[e]={get(){const n=_e(this,Ae(t.open,t.close,this[ge]),this[ye]);return Object.defineProperty(this,e,{value:n}),n}};ve.visible={get(){const e=_e(this,this[ge],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const De=(e,t,n,...i)=>"rgb"===e?"ansi16m"===t?ce[n].ansi16m(...i):"ansi256"===t?ce[n].ansi256(ce.rgbToAnsi256(...i)):ce[n].ansi(ce.rgbToAnsi(...i)):"hex"===e?De("rgb",t,n,...ce.hexToRgb(...i)):ce[n][e](...i),ke=["rgb","hex","ansi256"];for(const e of ke){ve[e]={get(){const{level:t}=this;return function(...n){const i=Ae(De(e,be[t],"color",...n),ce.color.close,this[ge]);return _e(this,i,this[ye])}}};ve["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:t}=this;return function(...n){const i=Ae(De(e,be[t],"bgColor",...n),ce.bgColor.close,this[ge]);return _e(this,i,this[ye])}}}}const Ee=Object.defineProperties((()=>{}),{...ve,level:{enumerable:!0,get(){return this[fe].level},set(e){this[fe].level=e}}}),Ae=(e,t,n)=>{let i,s;return void 0===n?(i=e,s=t):(i=n.openAll+e,s=t+n.closeAll),{open:e,close:t,openAll:i,closeAll:s,parent:n}},_e=(e,t,n)=>{const i=(...e)=>Ce(i,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(i,Ee),i[fe]=e,i[ge]=t,i[ye]=n,i},Ce=(e,t)=>{if(e.level<=0||!t)return e[ye]?"":t;let n=e[ge];if(void 0===n)return t;const{openAll:i,closeAll:s}=n;if(t.includes(""))for(;void 0!==n;)t=he(t,n.close,n.open),n=n.parent;const r=t.indexOf("\n");return-1!==r&&(t=function(e,t,n,i){let s=0,r="";do{const a="\r"===e[i-1];r+=e.slice(s,a?i-1:i)+t+(a?"\r\n":"\n")+n,s=i+1,i=e.indexOf("\n",s)}while(-1!==i);return r+=e.slice(s),r}(t,s,i,r)),i+t+s};Object.defineProperties(we.prototype,ve);const Se=we();var Be,Oe;we({level:me?me.level:0});var Ne=function(){if(Oe)return Be;Oe=1;var e=r,t=a.resolve(__dirname,"..",".."),n=e.readFileSync(t+"/package.json"),i={};return n&&(i=JSON.parse(n)),Be=i}(),Fe=A(Ne);const Te=Symbol.for("yaml.alias"),Ue=Symbol.for("yaml.document"),Le=Symbol.for("yaml.map"),Re=Symbol.for("yaml.pair"),Ke=Symbol.for("yaml.scalar"),je=Symbol.for("yaml.seq"),Ie=Symbol.for("yaml.node.type"),Pe=e=>!!e&&"object"==typeof e&&e[Ie]===Te,$e=e=>!!e&&"object"==typeof e&&e[Ie]===Ue,ze=e=>!!e&&"object"==typeof e&&e[Ie]===Le,Me=e=>!!e&&"object"==typeof e&&e[Ie]===Re,He=e=>!!e&&"object"==typeof e&&e[Ie]===Ke,qe=e=>!!e&&"object"==typeof e&&e[Ie]===je;function Ve(e){if(e&&"object"==typeof e)switch(e[Ie]){case Le:case je:return!0}return!1}function Je(e){if(e&&"object"==typeof e)switch(e[Ie]){case Te:case Le:case Ke:case je:return!0}return!1}const Ge=Symbol("break visit"),We=Symbol("skip children"),Ye=Symbol("remove node");function Ze(e,t){const n=tt(t);if($e(e)){Xe(null,e.contents,n,Object.freeze([e]))===Ye&&(e.contents=null)}else Xe(null,e,n,Object.freeze([]))}function Xe(e,t,n,i){const s=nt(e,t,n,i);if(Je(s)||Me(s))return it(e,i,s),Xe(e,s,n,i);if("symbol"!=typeof s)if(Ve(t)){i=Object.freeze(i.concat(t));for(let e=0;e<t.items.length;++e){const s=Xe(e,t.items[e],n,i);if("number"==typeof s)e=s-1;else{if(s===Ge)return Ge;s===Ye&&(t.items.splice(e,1),e-=1)}}}else if(Me(t)){i=Object.freeze(i.concat(t));const e=Xe("key",t.key,n,i);if(e===Ge)return Ge;e===Ye&&(t.key=null);const s=Xe("value",t.value,n,i);if(s===Ge)return Ge;s===Ye&&(t.value=null)}return s}async function Qe(e,t){const n=tt(t);if($e(e)){await et(null,e.contents,n,Object.freeze([e]))===Ye&&(e.contents=null)}else await et(null,e,n,Object.freeze([]))}async function et(e,t,n,i){const s=await nt(e,t,n,i);if(Je(s)||Me(s))return it(e,i,s),et(e,s,n,i);if("symbol"!=typeof s)if(Ve(t)){i=Object.freeze(i.concat(t));for(let e=0;e<t.items.length;++e){const s=await et(e,t.items[e],n,i);if("number"==typeof s)e=s-1;else{if(s===Ge)return Ge;s===Ye&&(t.items.splice(e,1),e-=1)}}}else if(Me(t)){i=Object.freeze(i.concat(t));const e=await et("key",t.key,n,i);if(e===Ge)return Ge;e===Ye&&(t.key=null);const s=await et("value",t.value,n,i);if(s===Ge)return Ge;s===Ye&&(t.value=null)}return s}function tt(e){return"object"==typeof e&&(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 nt(e,t,n,i){return"function"==typeof n?n(e,t,i):ze(t)?n.Map?.(e,t,i):qe(t)?n.Seq?.(e,t,i):Me(t)?n.Pair?.(e,t,i):He(t)?n.Scalar?.(e,t,i):Pe(t)?n.Alias?.(e,t,i):void 0}function it(e,t,n){const i=t[t.length-1];if(Ve(i))i.items[e]=n;else if(Me(i))"key"===e?i.key=n:i.value=n;else{if(!$e(i)){const e=Pe(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${e} parent`)}i.contents=n}}Ze.BREAK=Ge,Ze.SKIP=We,Ze.REMOVE=Ye,Qe.BREAK=Ge,Qe.SKIP=We,Qe.REMOVE=Ye;const st={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"};class rt{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},rt.defaultYaml,e),this.tags=Object.assign({},rt.defaultTags,t)}clone(){const e=new rt(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){const e=new rt(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:rt.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},rt.defaultTags)}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:rt.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},rt.defaultTags),this.atNextDocument=!1);const n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(2!==n.length&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;const[e,i]=n;return this.tags[e]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,1!==n.length)return t(0,"%YAML directive should contain exactly one part"),!1;const[e]=n;if("1.1"===e||"1.2"===e)return this.yaml.version=e,!0;return t(6,`Unsupported YAML version ${e}`,/^\d+\.\d+$/.test(e)),!1}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if("!"===e)return"!";if("!"!==e[0])return t(`Not a valid tag: ${e}`),null;if("<"===e[1]){const n=e.slice(2,-1);return"!"===n||"!!"===n?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(">"!==e[e.length-1]&&t("Verbatim tags must end with a >"),n)}const[,n,i]=e.match(/^(.*!)([^!]*)$/s);i||t(`The ${e} tag has no suffix`);const s=this.tags[n];if(s)try{return s+decodeURIComponent(i)}catch(e){return t(String(e)),null}return"!"===n?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(const[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+e.substring(n.length).replace(/[!,[\]{}]/g,(e=>st[e]));return"!"===e[0]?e:`!<${e}>`}toString(e){const t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags);let i;if(e&&n.length>0&&Je(e.contents)){const t={};Ze(e.contents,((e,n)=>{Je(n)&&n.tag&&(t[n.tag]=!0)})),i=Object.keys(t)}else i=[];for(const[s,r]of n)"!!"===s&&"tag:yaml.org,2002:"===r||e&&!i.some((e=>e.startsWith(r)))||t.push(`%TAG ${s} ${r}`);return t.join("\n")}}function at(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const t=JSON.stringify(e);throw new Error(`Anchor must not contain whitespace or control characters: ${t}`)}return!0}function ot(e){const t=new Set;return Ze(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function ct(e,t){for(let n=1;;++n){const i=`${e}${n}`;if(!t.has(i))return i}}function lt(e,t,n,i){if(i&&"object"==typeof i)if(Array.isArray(i))for(let t=0,n=i.length;t<n;++t){const n=i[t],s=lt(e,i,String(t),n);void 0===s?delete i[t]:s!==n&&(i[t]=s)}else if(i instanceof Map)for(const t of Array.from(i.keys())){const n=i.get(t),s=lt(e,i,t,n);void 0===s?i.delete(t):s!==n&&i.set(t,s)}else if(i instanceof Set)for(const t of Array.from(i)){const n=lt(e,i,t,t);void 0===n?i.delete(t):n!==t&&(i.delete(t),i.add(n))}else for(const[t,n]of Object.entries(i)){const s=lt(e,i,t,n);void 0===s?delete i[t]:s!==n&&(i[t]=s)}return e.call(t,n,i)}function ut(e,t,n){if(Array.isArray(e))return e.map(((e,t)=>ut(e,String(t),n)));if(e&&"function"==typeof e.toJSON){if(!n||!(e=>(He(e)||Ve(e))&&!!e.anchor)(e))return e.toJSON(t,n);const i={aliasCount:0,count:1,res:void 0};n.anchors.set(e,i),n.onCreate=e=>{i.res=e,delete n.onCreate};const s=e.toJSON(t,n);return n.onCreate&&n.onCreate(s),s}return"bigint"!=typeof e||n?.keep?e:Number(e)}rt.defaultYaml={explicit:!1,version:"1.2"},rt.defaultTags={"!!":"tag:yaml.org,2002:"};class pt{constructor(e){Object.defineProperty(this,Ie,{value:e})}clone(){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:i,reviver:s}={}){if(!$e(e))throw new TypeError("A document argument is required");const r={anchors:new Map,doc:e,keep:!0,mapAsMap:!0===t,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},a=ut(this,"",r);if("function"==typeof i)for(const{count:e,res:t}of r.anchors.values())i(t,e);return"function"==typeof s?lt(s,{"":a},"",a):a}}class ht extends pt{constructor(e){super(Te),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e){let t;return Ze(e,{Node:(e,n)=>{if(n===this)return Ze.BREAK;n.anchor===this.source&&(t=n)}}),t}toJSON(e,t){if(!t)return{source:this.source};const{anchors:n,doc:i,maxAliasCount:s}=t,r=this.resolve(i);if(!r){const e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(e)}let a=n.get(r);if(a||(ut(r,null,t),a=n.get(r)),!a||void 0===a.res){throw new ReferenceError("This should not happen: Alias anchor was not resolved?")}if(s>=0&&(a.count+=1,0===a.aliasCount&&(a.aliasCount=dt(i,r,n)),a.count*a.aliasCount>s)){throw new ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return a.res}toString(e,t,n){const i=`*${this.source}`;if(e){if(at(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){const e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(e)}if(e.implicitKey)return`${i} `}return i}}function dt(e,t,n){if(Pe(t)){const i=t.resolve(e),s=n&&i&&n.get(i);return s?s.count*s.aliasCount:0}if(Ve(t)){let i=0;for(const s of t.items){const t=dt(e,s,n);t>i&&(i=t)}return i}if(Me(t)){const i=dt(e,t.key,n),s=dt(e,t.value,n);return Math.max(i,s)}return 1}const mt=e=>!e||"function"!=typeof e&&"object"!=typeof e;class ft extends pt{constructor(e){super(Ke),this.value=e}toJSON(e,t){return t?.keep?this.value:ut(this.value,e,t)}toString(){return String(this.value)}}ft.BLOCK_FOLDED="BLOCK_FOLDED",ft.BLOCK_LITERAL="BLOCK_LITERAL",ft.PLAIN="PLAIN",ft.QUOTE_DOUBLE="QUOTE_DOUBLE",ft.QUOTE_SINGLE="QUOTE_SINGLE";function gt(e,t,n){if($e(e)&&(e=e.contents),Je(e))return e;if(Me(e)){const t=n.schema[Le].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||"undefined"!=typeof BigInt&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:i,onAnchor:s,onTagObj:r,schema:a,sourceObjects:o}=n;let c;if(i&&e&&"object"==typeof e){if(c=o.get(e),c)return c.anchor||(c.anchor=s(e)),new h