jg-h-cli
Version:
jg-h-cli 脚手架
1 lines • 240 kB
JavaScript
"use strict";var e=require("node:events"),t=require("node:child_process"),r=require("node:path"),n=require("node:fs"),s=require("node:process"),i=require("node:tty"),o=require("node:util"),u=require("node:os"),a=require("node:assert"),c=require("node:crypto"),l=require("node:constants"),h=require("node:stream"),f=require("node:readline"),p=require("node:async_hooks");function d(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var m=d(f),D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function g(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var y,b,w={},v={},C={};function _(){if(y)return C;y=1;class e extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}}return C.CommanderError=e,C.InvalidArgumentError=class extends e{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},C}function E(){if(b)return v;b=1;const{InvalidArgumentError:e}=_();return v.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,r)=>{if(!this.argChoices.includes(t))throw new e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},v.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"},v}var F,k={},O={};function S(){if(F)return O;F=1;const{humanReadableArgName:e}=E();function t(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,"")}return O.Help=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){const t=e.commands.filter((e=>!e._hidden)),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort(((e,t)=>e.name().localeCompare(t.name()))),t}compareOptions(e,t){const r=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){const t=e.options.filter((e=>!e.hidden)),r=e._getHelpOption();if(r&&!r.hidden){const n=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);n||s?r.long&&!s?t.push(e.createOption(r.long,r.description)):r.short&&!n&&t.push(e.createOption(r.short,r.description)):t.push(r)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];const t=[];for(let r=e.parent;r;r=r.parent){const e=r.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 r=t.registeredArguments.map((t=>e(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce(((e,r)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(r))))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce(((e,r)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(r))))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce(((e,r)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(r))))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce(((e,r)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(r))))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let t=e.parent;t;t=t.parent)r=t.name()+" "+r;return r+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 r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){const r=t.padWidth(e,t),n=t.helpWidth??80;function s(e,n){return t.formatItem(e,r,n,t)}let i=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""];const o=t.commandDescription(e);o.length>0&&(i=i.concat([t.boxWrap(t.styleCommandDescription(o),n),""]));const u=t.visibleArguments(e).map((e=>s(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e)))));u.length>0&&(i=i.concat([t.styleTitle("Arguments:"),...u,""]));const a=t.visibleOptions(e).map((e=>s(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e)))));if(a.length>0&&(i=i.concat([t.styleTitle("Options:"),...a,""])),t.showGlobalOptions){const r=t.visibleGlobalOptions(e).map((e=>s(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e)))));r.length>0&&(i=i.concat([t.styleTitle("Global Options:"),...r,""]))}const c=t.visibleCommands(e).map((e=>s(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e)))));return c.length>0&&(i=i.concat([t.styleTitle("Commands:"),...c,""])),i.join("\n")}displayWidth(e){return t(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map((e=>"[options]"===e?this.styleOptionText(e):"[command]"===e?this.styleSubcommandText(e):"["===e[0]||"<"===e[0]?this.styleArgumentText(e):this.styleCommandText(e))).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map((e=>"[options]"===e?this.styleOptionText(e):"["===e[0]||"<"===e[0]?this.styleArgumentText(e):this.styleSubcommandText(e))).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,r,n){const s=" ".repeat(2);if(!r)return s+e;const i=e.padEnd(t+e.length-n.displayWidth(e)),o=(this.helpWidth??80)-t-2-2;let u;if(o<this.minWidthToWrap||n.preformatted(r))u=r;else{u=n.boxWrap(r,o).replace(/\n/g,"\n"+" ".repeat(t+2))}return s+i+" ".repeat(2)+u.replace(/\n/g,`\n${s}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;const r=e.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,s=[];return r.forEach((e=>{const r=e.match(n);if(null===r)return void s.push("");let i=[r.shift()],o=this.displayWidth(i[0]);r.forEach((e=>{const r=this.displayWidth(e);if(o+r<=t)return i.push(e),void(o+=r);s.push(i.join(""));const n=e.trimStart();i=[n],o=this.displayWidth(n)})),s.push(i.join(""))})),s.join("\n")}},O.stripColor=t,O}var x,A={};function B(){if(x)return A;x=1;const{InvalidArgumentError:e}=_();function t(e){return e.split("-").reduce(((e,t)=>e+t[0].toUpperCase()+t.slice(1)))}return A.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 r=function(e){let t,r;const n=/^-[^-]$/,s=/^--[^-]/,i=e.split(/[ |,]+/).concat("guard");n.test(i[0])&&(t=i.shift());s.test(i[0])&&(r=i.shift());!t&&n.test(i[0])&&(t=i.shift());!t&&s.test(i[0])&&(t=r,r=i.shift());if(i[0].startsWith("-")){const t=i[0],r=`option creation failed due to '${t}' in option flags '${e}'`;if(/^-[^-][^-]/.test(t))throw new Error(`${r}\n- a short flag is a single dash and a single character\n - either use a single dash and a single character (for a short flag)\n - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(n.test(t))throw new Error(`${r}\n- too many short flags`);if(s.test(t))throw new Error(`${r}\n- too many long flags`);throw new Error(`${r}\n- unrecognised flag format`)}if(void 0===t&&void 0===r)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:r}}(e);this.short=r.shortFlag,this.long=r.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,r)=>{if(!this.argChoices.includes(t))throw new e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?t(this.name().replace(/^no-/,"")):t(this.name())}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},A.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 r=t.attributeName();if(!this.dualOptions.has(r))return!0;const n=this.negativeOptions.get(r).presetArg,s=void 0!==n&&n;return t.negate===(s===e)}},A}var T,M,R,P={};function $(){if(T)return P;T=1;return P.suggestSimilar=function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));const r=e.startsWith("--");r&&(e=e.slice(2),t=t.map((e=>e.slice(2))));let n=[],s=3;return t.forEach((t=>{if(t.length<=1)return;const r=function(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);const r=[];for(let t=0;t<=e.length;t++)r[t]=[t];for(let e=0;e<=t.length;e++)r[0][e]=e;for(let n=1;n<=t.length;n++)for(let s=1;s<=e.length;s++){let i=1;i=e[s-1]===t[n-1]?0:1,r[s][n]=Math.min(r[s-1][n]+1,r[s][n-1]+1,r[s-1][n-1]+i),s>1&&n>1&&e[s-1]===t[n-2]&&e[s-2]===t[n-1]&&(r[s][n]=Math.min(r[s][n],r[s-2][n-2]+1))}return r[e.length][t.length]}(e,t),i=Math.max(e.length,t.length);(i-r)/i>.4&&(r<s?(s=r,n=[t]):r===s&&n.push(t))})),n.sort(((e,t)=>e.localeCompare(t))),r&&(n=n.map((e=>`--${e}`))),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""},P}var L=function(){if(R)return w;R=1;const{Argument:i}=E(),{Command:o}=function(){if(M)return k;M=1;const i=e.EventEmitter,o=t,u=r,a=n,c=s,{Argument:l,humanReadableArgName:h}=E(),{CommanderError:f}=_(),{Help:p,stripColor:d}=S(),{Option:m,DualOptions:D}=B(),{suggestSimilar:g}=$();class y extends i{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=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._savedState=null,this._outputConfiguration={writeOut:e=>c.stdout.write(e),writeErr:e=>c.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>c.stdout.isTTY?c.stdout.columns:void 0,getErrHelpWidth:()=>c.stderr.isTTY?c.stderr.columns:void 0,getOutHasColors:()=>w()??(c.stdout.isTTY&&c.stdout.hasColors?.()),getErrHasColors:()=>w()??(c.stderr.isTTY&&c.stderr.hasColors?.()),stripColor:e=>d(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,r){let n=t,s=r;"object"==typeof n&&null!==n&&(s=n,n=null),s=s||{};const[,i,o]=e.match(/([^ ]+) *(.*)/),u=this.createCommand(i);return n&&(u.description(n),u._executableHandler=!0),s.isDefault&&(this._defaultCommandName=u._name),u._hidden=!(!s.noHelp&&!s.hidden),u._executableFile=s.executableFile||null,o&&u.arguments(o),this._registerCommand(u),u.parent=this,u.copyInheritedSettings(this),n?this:u}createCommand(e){return new y(e)}createHelp(){return Object.assign(new p,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 l(e,t)}argument(e,t,r,n){const s=this.createArgument(e,t);return"function"==typeof r?s.default(n).argParser(r):s.default(r),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[,r,n]=e.match(/([^ ]+) *(.*)/),s=t??"display help for command",i=this.createCommand(r);return i.helpOption(!1),n&&i.arguments(n),s&&i.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=i,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 r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${r.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,r){this._exitCallback&&this._exitCallback(new f(e,t,r)),c.exit(e)}action(e){return this._actionHandler=t=>{const r=this.registeredArguments.length,n=t.slice(0,r);return this._storeOptionsAsProperties?n[r]=this:n[r]=this.opts(),n.push(this),e.apply(this,n)},this}createOption(e,t){return new m(e,t)}_callParseArg(e,t,r,n){try{return e.parseArg(t,r)}catch(e){if("commander.invalidArgument"===e.code){const t=`${n} ${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 r=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 '${r}'\n- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){const t=e=>[e.name()].concat(e.aliases()),r=t(e).find((e=>this._findCommand(e)));if(r){const n=t(this._findCommand(r)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${n}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);const t=e.name(),r=e.attributeName();if(e.negate){const t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(r,void 0===e.defaultValue||e.defaultValue,"default")}else void 0!==e.defaultValue&&this.setOptionValueWithSource(r,e.defaultValue,"default");const n=(t,n,s)=>{null==t&&void 0!==e.presetArg&&(t=e.presetArg);const i=this.getOptionValue(r);null!==t&&e.parseArg?t=this._callParseArg(e,t,i,n):null!==t&&e.variadic&&(t=e._concatValue(t,i)),null==t&&(t=!e.negate&&(!(!e.isBoolean()&&!e.optional)||"")),this.setOptionValueWithSource(r,t,s)};return this.on("option:"+t,(t=>{const r=`error: option '${e.flags}' argument '${t}' is invalid.`;n(t,r,"cli")})),e.envVar&&this.on("optionEnv:"+t,(t=>{const r=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;n(t,r,"env")})),this}_optionEx(e,t,r,n,s){if("object"==typeof t&&t instanceof m)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const i=this.createOption(t,r);if(i.makeOptionMandatory(!!e.mandatory),"function"==typeof n)i.default(s).argParser(n);else if(n instanceof RegExp){const e=n;n=(t,r)=>{const n=e.exec(t);return n?n[0]:r},i.default(s).argParser(n)}else i.default(n);return this.addOption(i)}option(e,t,r,n){return this._optionEx({},e,t,r,n)}requiredOption(e,t,r,n){return this._optionEx({mandatory:!0},e,t,r,n)}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,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach((r=>{void 0!==r.getOptionValueSource(e)&&(t=r.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){c.versions?.electron&&(t.from="electron");const e=c.execArgv??[];(e.includes("-e")||e.includes("--eval")||e.includes("-p")||e.includes("--print"))&&(t.from="eval")}let r;switch(void 0===e&&(e=c.argv),this.rawArgs=e.slice(),t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":c.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=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",r}parse(e,t){this._prepareForParse();const r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){this._prepareForParse();const r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_prepareForParse(){null===this._savedState?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error("Can not call parse again when storeOptionsAsProperties is true.\n- either make a new Command for each call to parse, or stop storing options as properties");this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,r){if(!a.existsSync(e))throw new Error(`'${e}' does not exist\n - if '${r}' 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?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory"}`)}_executeSubCommand(e,t){t=t.slice();let r=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function s(e,t){const r=u.resolve(e,t);if(a.existsSync(r))return r;if(n.includes(u.extname(t)))return;const s=n.find((e=>a.existsSync(`${r}${e}`)));return s?`${r}${s}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i,l=e._executableFile||`${this._name}-${e._name}`,h=this._executableDir||"";if(this._scriptPath){let e;try{e=a.realpathSync(this._scriptPath)}catch{e=this._scriptPath}h=u.resolve(u.dirname(e),h)}if(h){let t=s(h,l);if(!t&&!e._executableFile&&this._scriptPath){const r=u.basename(this._scriptPath,u.extname(this._scriptPath));r!==this._name&&(t=s(h,`${r}-${e._name}`))}l=t||l}r=n.includes(u.extname(l)),"win32"!==c.platform?r?(t.unshift(l),t=b(c.execArgv).concat(t),i=o.spawn(c.argv[0],t,{stdio:"inherit"})):i=o.spawn(l,t,{stdio:"inherit"}):(this._checkForMissingExecutable(l,h,e._name),t.unshift(l),t=b(c.execArgv).concat(t),i=o.spawn(c.execPath,t,{stdio:"inherit"})),i.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((e=>{c.on(e,(()=>{!1===i.killed&&null===i.exitCode&&i.kill(e)}))}));const p=this._exitCallback;i.on("close",(e=>{e=e??1,p?p(new f(e,"commander.executeSubCommandAsync","(close)")):c.exit(e)})),i.on("error",(t=>{if("ENOENT"===t.code)this._checkForMissingExecutable(l,h,e._name);else if("EACCES"===t.code)throw new Error(`'${l}' not executable`);if(p){const e=new f(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,p(e)}else c.exit(1)})),this.runningCommand=i}_dispatchSubcommand(e,t,r){const n=this._findCommand(e);let s;return n||this.help({error:!0}),n._prepareForParse(),s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,(()=>{if(!n._executableHandler)return n._parseCommand(t,r);this._executeSubCommand(n,t.concat(r))})),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,r)=>{let n=t;if(null!==t&&e.parseArg){const s=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;n=this._callParseArg(e,t,r,s)}return n};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach(((r,n)=>{let s=r.defaultValue;r.variadic?n<this.args.length?(s=this.args.slice(n),r.parseArg&&(s=s.reduce(((t,n)=>e(r,n,t)),r.defaultValue))):void 0===s&&(s=[]):n<this.args.length&&(s=this.args[n],r.parseArg&&(s=e(r,s,r.defaultValue))),t[n]=s})),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&"function"==typeof e.then?e.then((()=>t())):t()}_chainOrCallHooks(e,t){let r=e;const n=[];return this._getCommandAndAncestors().reverse().filter((e=>void 0!==e._lifeCycleHooks[t])).forEach((e=>{e._lifeCycleHooks[t].forEach((t=>{n.push({hookedCommand:e,callback:t})}))})),"postAction"===t&&n.reverse(),n.forEach((e=>{r=this._chainOrCall(r,(()=>e.callback(e.hookedCommand,this)))})),r}_chainOrCallSubCommandHook(e,t,r){let n=e;return void 0!==this._lifeCycleHooks[r]&&this._lifeCycleHooks[r].forEach((e=>{n=this._chainOrCall(n,(()=>e(this,t)))})),n}_parseCommand(e,t){const r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.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(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const n=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){let r;return n(),this._processArguments(),r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,(()=>this._actionHandler(this.processedArgs))),this.parent&&(r=this._chainOrCall(r,(()=>{this.parent.emit(s,e,t)}))),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent&&this.parent.listenerCount(s))n(),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():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),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 r=e.find((e=>t.conflictsWith.includes(e.attributeName())));r&&this._conflictingOption(t,r)}))}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((e=>{e._checkForConflictingLocalOptions()}))}parseOptions(e){const t=[],r=[];let n=t;const s=e.slice();function i(e){return e.length>1&&"-"===e[0]}let o=null;for(;s.length;){const e=s.shift();if("--"===e){n===r&&n.push(e),n.push(...s);break}if(!o||i(e)){if(o=null,i(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&&!i(s[0])&&(e=s.shift()),this.emit(`option:${t.name()}`,e)}else this.emit(`option:${t.name()}`);o=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("="),r=this._findOption(e.slice(0,t));if(r&&(r.required||r.optional)){this.emit(`option:${r.name()}`,e.slice(t+1));continue}}if(i(e)&&(n=r),(this._enablePositionalOptions||this._passThroughOptions)&&0===t.length&&0===r.length){if(this._findCommand(e)){t.push(e),s.length>0&&r.push(...s);break}if(this._getHelpCommand()&&e===this._getHelpCommand().name()){t.push(e),s.length>0&&t.push(...s);break}if(this._defaultCommandName){r.push(e),s.length>0&&r.push(...s);break}}if(this._passThroughOptions){n.push(e),s.length>0&&n.push(...s);break}n.push(e)}else this.emit(`option:${o.name()}`,e)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){const e={},t=this.options.length;for(let r=0;r<t;r++){const t=this.options[r].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 r=t||{},n=r.exitCode||1,s=r.code||"commander.error";this._exit(n,s,e)}_parseOptionsEnv(){this.options.forEach((e=>{if(e.envVar&&e.envVar in c.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()}`,c.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}}))}_parseOptionsImplied(){const e=new D(this.options),t=e=>void 0!==this.getOptionValue(e)&&!["default","implied"].includes(this.getOptionValueSource(e));this.options.filter((r=>void 0!==r.implied&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r))).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 r=e=>{const t=e.attributeName(),r=this.getOptionValue(t),n=this.options.find((e=>e.negate&&t===e.attributeName())),s=this.options.find((e=>!e.negate&&t===e.attributeName()));return n&&(void 0===n.presetArg&&!1===r||void 0!==n.presetArg&&r===n.presetArg)?n:s||e},n=e=>{const t=r(e),n=t.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${t.envVar}'`:`option '${t.flags}'`},s=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let r=[],n=this;do{const e=n.createHelp().visibleOptions(n).filter((e=>e.long)).map((e=>e.long));r=r.concat(e),n=n.parent}while(n&&!n._enablePositionalOptions);t=g(e,r)}const r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;const t=this.registeredArguments.length,r=1===t?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const r=[];this.createHelp().visibleCommands(this).forEach((e=>{r.push(e.name()),e.alias()&&r.push(e.alias())})),t=g(e,r)}const r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(void 0===e)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";const n=this.createOption(t,r);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.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 r=this.parent?._findCommand(e);if(r){const t=[r.name()].concat(r.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=>h(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=u.basename(e,u.extname(e)),this}executableDir(e){return void 0===e?this._executableDir:(this._executableDir=e,this)}helpInformation(e){const t=this.createHelp(),r=this._getOutputContext(e);t.prepareContext({error:r.error,helpWidth:r.helpWidth,outputHasColors:r.hasColors});const n=t.formatHelp(this,t);return r.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(e){const t=!!(e=e||{}).error;let r,n,s;return t?(r=e=>this._outputConfiguration.writeErr(e),n=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(r=e=>this._outputConfiguration.writeOut(e),n=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(n||(e=this._outputConfiguration.stripColor(e)),r(e)),hasColors:n,helpWidth:s}}outputHelp(e){let t;"function"==typeof e&&(t=e,e=void 0);const r=this._getOutputContext(e),n={error:r.error,write:r.write,command:this};this._getCommandAndAncestors().reverse().forEach((e=>e.emit("beforeAllHelp",n))),this.emit("beforeHelp",n);let s=this.helpInformation({error:r.error});if(t&&(s=t(s),"string"!=typeof s&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(s),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=Number(c.exitCode??0);0===t&&e&&"function"!=typeof e&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${r.join("', '")}'`);const n=`${e}Help`;return this.on(n,(e=>{let r;r="function"==typeof t?t({error:e.error,command:e.command}):t,r&&e.write(`${r}\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,r,n="127.0.0.1",s="9229";return null!==(r=e.match(/^(--inspect(-brk)?)$/))?t=r[1]:null!==(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=r[1],/^\d+$/.test(r[3])?s=r[3]:n=r[3]):null!==(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=r[1],n=r[3],s=r[4]),t&&"0"!==s?`${t}=${n}:${parseInt(s)+1}`:e}))}function w(){return!c.env.NO_COLOR&&"0"!==c.env.FORCE_COLOR&&"false"!==c.env.FORCE_COLOR&&(!(!c.env.FORCE_COLOR&&void 0===c.env.CLICOLOR_FORCE)||void 0)}return k.Command=y,k.useColor=w,k}(),{CommanderError:u,InvalidArgumentError:a}=_(),{Help:c}=S(),{Option:l}=B();return w.program=new o,w.createCommand=e=>new o(e),w.createOption=(e,t)=>new l(e,t),w.createArgument=(e,t)=>new i(e,t),w.Command=o,w.Option=l,w.Argument=i,w.Help=c,w.CommanderError=u,w.InvalidArgumentError=a,w.InvalidOptionArgumentError=a,w}(),j=g(L);const{program:I,createCommand:N,createArgument:U,createOption:V,CommanderError:H,InvalidArgumentError:G,InvalidOptionArgumentError:q,Command:W,Argument:z,Option:Y,Help:J}=j;function K(e,t,r,n){return new(r||(r=Promise))((function(s,i){function o(e){try{a(n.next(e))}catch(e){i(e)}}function u(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,u)}a((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const Q=e=>"up"===e.name||"k"===e.name||e.ctrl&&"p"===e.name,Z=e=>"down"===e.name||"j"===e.name||e.ctrl&&"n"===e.name,X=e=>"backspace"===e.name,ee=e=>"enter"===e.name||"return"===e.name;class te extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(e){super(),this.cause=e?.cause}}class re extends Error{name="CancelPromptError";message="Prompt was canceled"}class ne extends Error{name="ExitPromptError"}class se extends Error{name="HookError"}class ie extends Error{name="ValidationError"}const oe=new p.AsyncLocalStorage;function ue(){const e=oe.getStore();if(!e)throw new se("[Inquirer] Hook functions can only be called from within a prompt");return e}function ae(){return ue().rl}function ce(e){return p.AsyncResource.bind(((...t)=>{const r=ue();let n=!1;const s=r.handleChange;r.handleChange=()=>{n=!0};const i=e(...t);return n&&s(),r.handleChange=s,i}))}function le(e){const t=ue(),{index:r}=t,n=e({get:()=>t.hooks[r],set(e){t.hooks[r]=e},initialized:r in t.hooks});return t.index++,n}const he={queue(e){const t=ue(),{index:r}=t;t.hooksEffect.push((()=>{t.hooksCleanup[r]?.();const n=e(ae());if(null!=n&&"function"!=typeof n)throw new ie("useEffect return value must be a cleanup function or nothing.");t.hooksCleanup[r]=n}))},run(){const e=ue();ce((()=>{e.hooksEffect.forEach((e=>{e()})),e.hooksEffect.length=0}))()},clearAll(){const e=ue();e.hooksCleanup.forEach((e=>{e?.()})),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function fe(e){return le((t=>{const r=e=>{t.get()!==e&&(t.set(e),ue().handleChange())};if(t.initialized)return[t.get(),r];const n="function"==typeof e?e():e;return t.set(n),[n,r]}))}function pe(e,t){le((r=>{const n=r.get();(!Array.isArray(n)||t.some(((e,t)=>!Object.is(e,n[t]))))&&he.queue(e),r.set(t)}))}var de,me;function De(){if(me)return de;me=1;const e=i,t=e?.WriteStream?.prototype?.hasColors?.()??!1,r=(e,r)=>{if(!t)return e=>e;const n=`[${e}m`,s=`[${r}m`;return e=>{const t=e+"";let r=t.indexOf(s);if(-1===r)return n+t+s;let i=n,o=0;for(;-1!==r;)i+=t.slice(o,r)+n,o=r+s.length,r=t.indexOf(s,o);return i+=t.slice(o)+s,i}},n={};return n.reset=r(0,0),n.bold=r(1,22),n.dim=r(2,22),n.italic=r(3,23),n.underline=r(4,24),n.overline=r(53,55),n.inverse=r(7,27),n.hidden=r(8,28),n.strikethrough=r(9,29),n.black=r(30,39),n.red=r(31,39),n.green=r(32,39),n.yellow=r(33,39),n.blue=r(34,39),n.magenta=r(35,39),n.cyan=r(36,39),n.white=r(37,39),n.gray=r(90,39),n.bgBlack=r(40,49),n.bgRed=r(41,49),n.bgGreen=r(42,49),n.bgYellow=r(43,49),n.bgBlue=r(44,49),n.bgMagenta=r(45,49),n.bgCyan=r(46,49),n.bgWhite=r(47,49),n.bgGray=r(100,49),n.redBright=r(91,39),n.greenBright=r(92,39),n.yellowBright=r(93,39),n.blueBright=r(94,39),n.magentaBright=r(95,39),n.cyanBright=r(96,39),n.whiteBright=r(97,39),n.bgRedBright=r(101,49),n.bgGreenBright=r(102,49),n.bgYellowBright=r(103,49),n.bgBlueBright=r(104,49),n.bgMagentaBright=r(105,49),n.bgCyanBright=r(106,49),n.bgWhiteBright=r(107,49),de=n}var ge=g(De());const ye={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"█",squareDarkShade:"▓",squareMediumShade:"▒",squareLightShade:"░",squareTop:"▀",squareBottom:"▄",squareLeft:"▌",squareRight:"▐",squareCenter:"■",bullet:"●",dot:"․",ellipsis:"…",pointerSmall:"›",triangleUp:"▲",triangleUpSmall:"▴",triangleDown:"▼",triangleDownSmall:"▾",triangleLeftSmall:"◂",triangleRightSmall:"▸",home:"⌂",heart:"♥",musicNote:"♪",musicNoteBeamed:"♫",arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",arrowLeftRight:"↔",arrowUpDown:"↕",almostEqual:"≈",notEqual:"≠",lessOrEqual:"≤",greaterOrEqual:"≥",identical:"≡",infinity:"∞",subscriptZero:"₀",subscriptOne:"₁",subscriptTwo:"₂",subscriptThree:"₃",subscriptFour:"₄",subscriptFive:"₅",subscriptSix:"₆",subscriptSeven:"₇",subscriptEight:"₈",subscriptNine:"₉",oneHalf:"½",oneThird:"⅓",oneQuarter:"¼",oneFifth:"⅕",oneSixth:"⅙",oneEighth:"⅛",twoThirds:"⅔",twoFifths:"⅖",threeQuarters:"¾",threeFifths:"⅗",threeEighths:"⅜",fourFifths:"⅘",fiveSixths:"⅚",fiveEighths:"⅝",sevenEighths:"⅞",line:"─",lineBold:"━",lineDouble:"═",lineDashed0:"┄",lineDashed1:"┅",lineDashed2:"┈",lineDashed3:"┉",lineDashed4:"╌",lineDashed5:"╍",lineDashed6:"╴",lineDashed7:"╶",lineDashed8:"╸",lineDashed9:"╺",lineDashed10:"╼",lineDashed11:"╾",lineDashed12:"−",lineDashed13:"–",lineDashed14:"‐",lineDashed15:"⁃",lineVertical:"│",lineVerticalBold:"┃",lineVerticalDouble:"║",lineVerticalDashed0:"┆",lineVerticalDashed1:"┇",lineVerticalDashed2:"┊",lineVerticalDashed3:"┋",lineVerticalDashed4:"╎",lineVerticalDashed5:"╏",lineVerticalDashed6:"╵",lineVerticalDashed7:"╷",lineVerticalDashed8:"╹",lineVerticalDashed9:"╻",lineVerticalDashed10:"╽",lineVerticalDashed11:"╿",lineDownLeft:"┐",lineDownLeftArc:"╮",lineDownBoldLeftBold:"┓",lineDownBoldLeft:"┒",lineDownLeftBold:"┑",lineDownDoubleLeftDouble:"╗",lineDownDoubleLeft:"╖",lineDownLeftDouble:"╕",lineDownRight:"┌",lineDownRightArc:"╭",lineDownBoldRightBold:"┏",lineDownBoldRight:"┎",lineDownRightBold:"┍",lineDownDoubleRightDouble:"╔",lineDownDoubleRight:"╓",lineDownRightDouble:"╒",lineUpLeft:"┘",lineUpLeftArc:"╯",lineUpBoldLeftBold:"┛",lineUpBoldLeft:"┚",lineUpLeftBold:"┙",lineUpDoubleLeftDouble:"╝",lineUpDoubleLeft:"╜",lineUpLeftDouble:"╛",lineUpRight:"└",lineUpRightArc:"╰",lineUpBoldRightBold:"┗",lineUpBoldRight:"┖",lineUpRightBold:"┕",lineUpDoubleRightDouble:"╚",lineUpDoubleRight:"╙",lineUpRightDouble:"╘",lineUpDownLeft:"┤",lineUpBoldDownBoldLeftBold:"┫",lineUpBoldDownBoldLeft:"┨",lineUpDownLeftBold:"┥",lineUpBoldDownLeftBold:"┩",lineUpDownBoldLeftBold:"┪",lineUpDownBoldLeft:"┧",lineUpBoldDownLeft:"┦",lineUpDoubleDownDoubleLeftDouble:"╣",lineUpDoubleDownDoubleLeft:"╢",lineUpDownLeftDouble:"╡",lineUpDownRight:"├",lineUpBoldDownBoldRightBold:"┣",lineUpBoldDownBoldRight:"┠",lineUpDownRightBold:"┝",lineUpBoldDownRightBold:"┡",lineUpDownBoldRightBold:"┢",lineUpDownBoldRight:"┟",lineUpBoldDownRight:"┞",lineUpDoubleDownDoubleRightDouble:"╠",lineUpDoubleDownDoubleRight:"╟",lineUpDownRightDouble:"╞",lineDownLeftRight:"┬",lineDownBoldLeftBoldRightBold:"┳",lineDownLeftBoldRightBold:"┯",lineDownBoldLeftRight:"┰",lineDownBoldLeftBoldRight:"┱",lineDownBoldLeftRightBold:"┲",lineDownLeftRightBold:"┮",lineDownLeftBoldRight:"┭",lineDownDoubleLeftDoubleRightDouble:"╦",lineDownDoubleLeftRight:"╥",lineDownLeftDoubleRightDouble:"╤",lineUpLeftRight:"┴",lineUpBoldLeftBoldRightBold:"┻",lineUpLeftBoldRightBold:"┷",lineUpBoldLeftRight:"┸",lineUpBoldLeftBoldRight:"┹",lineUpBoldLeftRightBold:"┺",lineUpLeftRightBold:"┶",lineUpLeftBoldRight:"┵",lineUpDoubleLeftDoubleRightDouble:"╩",lineUpDoubleLeftRight:"╨",lineUpLeftDoubleRightDouble:"╧",lineUpDownLeftRight:"┼",lineUpBoldDownBoldLeftBoldRightBold:"╋",lineUpDownBoldLeftBoldRightBold:"╈",lineUpBoldDownLeftBoldRightBold:"╇",lineUpBoldDownBoldLeftRightBold:"╊",lineUpBoldDownBoldLeftBoldRight:"╉",lineUpBoldDownLeftRight:"╀",lineUpDownBoldLeftRight:"╁",lineUpDownLeftBoldRight:"┽",lineUpDownLeftRightBold:"┾",lineUpBoldDownBoldLeftRight:"╂",lineUpDownLeftBoldRightBold:"┿",lineUpBoldDownLeftBoldRight:"╃",lineUpBoldDownLeftRightBold:"╄",lineUpDownBoldLeftBoldRight:"╅",lineUpDownBoldLeftRightBold:"╆",lineUpDoubleDownDoubleLeftDoubleRightDouble:"╬",lineUpDoubleDownDoubleLeftRight:"╫",lineUpDownLeftDoubleRightDouble:"╪",lineCross:"╳",lineBackslash:"╲",lineSlash:"╱"},be={...ye,tick:"✔",info:"ℹ",warning:"⚠",cross:"✘",squareSmall:"◻",squareSmallFilled:"◼",circle:"◯",circleFilled:"◉",circleDotted:"◌",circleDouble:"◎",circleCircle:"ⓞ",circleCross:"ⓧ",circlePipe:"Ⓘ",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",checkboxCircleOn:"ⓧ",checkboxCircleOff:"Ⓘ",pointer:"❯",triangleUpOutline:"△",triangleLeft:"◀",triangleRight:"▶",lozenge:"◆",lozengeOutline:"◇",hamburger:"☰",smiley:"㋡",mustache:"෴",star:"★",play:"▶",nodejs:"⬢",oneSeventh:"⅐",oneNinth:"⅑",oneTenth:"⅒"},we={...ye,tick:"√",info:"i",warning:"‼",cross:"×",squareSmall:"□",squareSmallFilled:"■",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(○)",circleCross:"(×)",circlePipe:"(│)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[×]",checkboxOff:"[ ]",checkboxCircleOn:"(×)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"∆",triangleLeft:"◄",triangleRight:"►",lozenge:"♦",lozengeOutline:"◊",hamburger:"≡",smiley:"☺",mustache:"┌─┐",star:"✶",play:"►",nodejs:"♦",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},ve=("win32"!==s.platform?"linux"!==s.env.TERM:Boolean(s.env.WT_SESSION)||Boolean(s.env.TERMINUS_SUBLIME)||"{cmd::Cmder}"===s.env.ConEmuTask||"Terminus-Sublime"===s.env.TERM_PROGRAM||"vscode"===s.env.TERM_PROGRAM||"xterm-256color"===s.env.TERM||"alacritty"===s.env.TERM||"JetBrains-JediTerm"===s.env.TERMINAL_EMULATOR)?be:we,Ce={prefix:{idle:ge.blue("?"),done:ge.green(ve.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map((e=>ge.yellow(e)))},style:{answer:ge.cyan,message:ge.bold,error:e=>ge.red(`> ${e}`),defaultAnswer:e=>ge.dim(`(${e})`),help:ge.dim,highlight:ge.cyan,key:e=>ge.cyan(ge.bold(`<${e}>`))}};function _e(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Ee(...e){const t={};for(const r of e)for(const[e,n]of Object.entries(r)){const r=t[e];t[e]=_e(r)&&_e(n)?Ee(r,n):n}return t}function Fe(...e){return Ee(...[Ce,...e.filter((e=>null!=e))])}function ke({status:e="idle",theme:t}){const[r,n]=fe(!1),[s,i]=fe(0),{prefix:o,spinner:u}=Fe(t);if(pe((()=>{if("loading"===e){let e,t=-1;const r=setTimeout(p.AsyncResource.bind((()=>{n(!0),e=setInterval(p.AsyncResource.bind((()=>{t+=1,i(t%u.frames.length)})),u.interval)})),300);return()=>{clearTimeout(r),clearInterval(e)}}n(!1)}),[e]),r)return u.frames[s];return"string"==typeof o?o:o["loading"===e?"idle":e]??o.idle}function Oe(e,t){return le((r=>{const n=r.get();if(!n||n.dependencies.length!==t.length||n.dependencies.some(((e,r)=>e!==t[r]))){const n=e();return r.set({value:n,dependencies:t}),n}return n.value}))}function Se(e){retur