@bundlekit/cli 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -78,7 +78,7 @@ my-app/
78
78
 
79
79
  ## 文档
80
80
 
81
- 完整文档请访问 [https://bundlekit.dev](https://bundlekit.dev)
81
+ 完整文档请访问 [https://bundlekit.harhao.workers.dev](https://bundlekit.harhao.workers.dev)
82
82
 
83
83
  ## License
84
84
 
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import t,{useMemo as e,useState as i,useEffect as s,useCallback as r}from"react";import n from"node:events";import o from"node:child_process";import a from"node:path";import l from"node:fs";import c from"node:process";import h from"assert";import u from"events";import p from"readline";import{Box as d,Text as m,useInput as f,useApp as g,render as y}from"ink";import{FileManager as w,Logger as b,BUNDLER_PACKAGE_MAP as v,resolveBundlerName as _,PackageManager as S,Spinner as x}from"@bundlekit/shared-utils";import O from"path";import C from"fs";import{spawnSync as k}from"child_process";import{createRequire as E}from"module";import{fileURLToPath as A}from"url";import $ from"constants";import P from"stream";import D from"util";import{createRequire as T}from"node:module";import{fileURLToPath as j}from"node:url";import{jsxs as N,jsx as F}from"react/jsx-runtime";import I from"ink-gradient";import L from"ink-big-text";import R from"ink-text-input";import V from"ink-spinner";var M="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function H(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var W={},B={},q={};let U=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}};q.CommanderError=U,q.InvalidArgumentError=class extends U{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:z}=q;B.Argument=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t}this._name.length>3&&"..."===this._name.slice(-3)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new z(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},B.humanReadableArgName=function(t){const e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"};var J={},G={};const{humanReadableArgName:K}=B;function Y(t){return t.replace(/\x1b\[\d*(;\d*)*m/g,"")}G.Help=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){const e=t.commands.filter(t=>!t._hidden),i=t._getHelpCommand();return i&&!i._hidden&&e.push(i),this.sortSubcommands&&e.sort((t,e)=>t.name().localeCompare(e.name())),e}compareOptions(t,e){const i=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){const e=t.options.filter(t=>!t.hidden),i=t._getHelpOption();if(i&&!i.hidden){const s=i.short&&t._findOption(i.short),r=i.long&&t._findOption(i.long);s||r?i.long&&!r?e.push(t.createOption(i.long,i.description)):i.short&&!s&&e.push(t.createOption(i.short,i.description)):e.push(i)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const e=[];for(let i=t.parent;i;i=i.parent){const t=i.options.filter(t=>!t.hidden);e.push(...t)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(t=>t.description)?t.registeredArguments:[]}subcommandTerm(t){const e=t.registeredArguments.map(t=>K(t)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((t,i)=>Math.max(t,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(i)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((t,i)=>Math.max(t,this.displayWidth(e.styleOptionTerm(e.optionTerm(i)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((t,i)=>Math.max(t,this.displayWidth(e.styleOptionTerm(e.optionTerm(i)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((t,i)=>Math.max(t,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(i)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let e=t.parent;e;e=e.parent)i=e.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue){(t.required||t.optional||t.isBoolean()&&"boolean"==typeof t.defaultValue)&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}return void 0!==t.presetArg&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),void 0!==t.envVar&&e.push(`env: ${t.envVar}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}argumentDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){const i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,e){const i=e.padWidth(t,e),s=e.helpWidth??80;function r(t,s){return e.formatItem(t,i,s,e)}let n=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""];const o=e.commandDescription(t);o.length>0&&(n=n.concat([e.boxWrap(e.styleCommandDescription(o),s),""]));const a=e.visibleArguments(t).map(t=>r(e.styleArgumentTerm(e.argumentTerm(t)),e.styleArgumentDescription(e.argumentDescription(t))));a.length>0&&(n=n.concat([e.styleTitle("Arguments:"),...a,""]));const l=e.visibleOptions(t).map(t=>r(e.styleOptionTerm(e.optionTerm(t)),e.styleOptionDescription(e.optionDescription(t))));if(l.length>0&&(n=n.concat([e.styleTitle("Options:"),...l,""])),e.showGlobalOptions){const i=e.visibleGlobalOptions(t).map(t=>r(e.styleOptionTerm(e.optionTerm(t)),e.styleOptionDescription(e.optionDescription(t))));i.length>0&&(n=n.concat([e.styleTitle("Global Options:"),...i,""]))}const c=e.visibleCommands(t).map(t=>r(e.styleSubcommandTerm(e.subcommandTerm(t)),e.styleSubcommandDescription(e.subcommandDescription(t))));return c.length>0&&(n=n.concat([e.styleTitle("Commands:"),...c,""])),n.join("\n")}displayWidth(t){return Y(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(t=>"[options]"===t?this.styleOptionText(t):"[command]"===t?this.styleSubcommandText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(t=>"[options]"===t?this.styleOptionText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,e,i,s){const r=" ".repeat(2);if(!i)return r+t;const n=t.padEnd(e+t.length-s.displayWidth(t)),o=(this.helpWidth??80)-e-2-2;let a;if(o<this.minWidthToWrap||s.preformatted(i))a=i;else{a=s.boxWrap(i,o).replace(/\n/g,"\n"+" ".repeat(e+2))}return r+n+" ".repeat(2)+a.replace(/\n/g,`\n${r}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;const i=t.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,r=[];return i.forEach(t=>{const i=t.match(s);if(null===i)return void r.push("");let n=[i.shift()],o=this.displayWidth(n[0]);i.forEach(t=>{const i=this.displayWidth(t);if(o+i<=e)return n.push(t),void(o+=i);r.push(n.join(""));const s=t.trimStart();n=[s],o=this.displayWidth(s)}),r.push(n.join(""))}),r.join("\n")}},G.stripColor=Y;var Z={};const{InvalidArgumentError:X}=q;function Q(t){return t.split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}Z.Option=class{constructor(t,e){this.flags=t,this.description=e||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;const i=function(t){let e,i;const s=/^-[^-]$/,r=/^--[^-]/,n=t.split(/[ |,]+/).concat("guard");s.test(n[0])&&(e=n.shift());r.test(n[0])&&(i=n.shift());!e&&s.test(n[0])&&(e=n.shift());!e&&r.test(n[0])&&(e=i,i=n.shift());if(n[0].startsWith("-")){const e=n[0],i=`option creation failed due to '${e}' in option flags '${t}'`;if(/^-[^-][^-]/.test(e))throw new Error(`${i}\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(s.test(e))throw new Error(`${i}\n- too many short flags`);if(r.test(e))throw new Error(`${i}\n- too many long flags`);throw new Error(`${i}\n- unrecognised flag format`)}if(void 0===e&&void 0===i)throw new Error(`option creation failed due to no flags found in '${t}'.`);return{shortFlag:e,longFlag:i}}(t);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let e=t;return"string"==typeof t&&(e={[t]:!0}),this.implied=Object.assign(this.implied||{},e),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new X(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?Q(this.name().replace(/^no-/,"")):Q(this.name())}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Z.DualOptions=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,e)=>{this.positiveOptions.has(e)&&this.dualOptions.add(e)})}valueFromOption(t,e){const i=e.attributeName();if(!this.dualOptions.has(i))return!0;const s=this.negativeOptions.get(i).presetArg,r=void 0!==s&&s;return e.negate===(r===t)}};var tt={};tt.suggestSimilar=function(t,e){if(!e||0===e.length)return"";e=Array.from(new Set(e));const i=t.startsWith("--");i&&(t=t.slice(2),e=e.map(t=>t.slice(2)));let s=[],r=3;return e.forEach(e=>{if(e.length<=1)return;const i=function(t,e){if(Math.abs(t.length-e.length)>3)return Math.max(t.length,e.length);const i=[];for(let e=0;e<=t.length;e++)i[e]=[e];for(let t=0;t<=e.length;t++)i[0][t]=t;for(let s=1;s<=e.length;s++)for(let r=1;r<=t.length;r++){let n=1;n=t[r-1]===e[s-1]?0:1,i[r][s]=Math.min(i[r-1][s]+1,i[r][s-1]+1,i[r-1][s-1]+n),r>1&&s>1&&t[r-1]===e[s-2]&&t[r-2]===e[s-1]&&(i[r][s]=Math.min(i[r][s],i[r-2][s-2]+1))}return i[t.length][e.length]}(t,e),n=Math.max(t.length,e.length);(n-i)/n>.4&&(i<r?(r=i,s=[e]):i===r&&s.push(e))}),s.sort((t,e)=>t.localeCompare(e)),i&&(s=s.map(t=>`--${t}`)),s.length>1?`\n(Did you mean one of ${s.join(", ")}?)`:1===s.length?`\n(Did you mean ${s[0]}?)`:""};const et=n.EventEmitter,it=o,st=a,rt=l,nt=c,{Argument:ot,humanReadableArgName:at}=B,{CommanderError:lt}=q,{Help:ct,stripColor:ht}=G,{Option:ut,DualOptions:pt}=Z,{suggestSimilar:dt}=tt;function mt(t){return t.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i,s="127.0.0.1",r="9229";return null!==(i=t.match(/^(--inspect(-brk)?)$/))?e=i[1]:null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(e=i[1],/^\d+$/.test(i[3])?r=i[3]:s=i[3]):null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(e=i[1],s=i[3],r=i[4]),e&&"0"!==r?`${e}=${s}:${parseInt(r)+1}`:t})}function ft(){return!nt.env.NO_COLOR&&"0"!==nt.env.FORCE_COLOR&&"false"!==nt.env.FORCE_COLOR&&(!(!nt.env.FORCE_COLOR&&void 0===nt.env.CLICOLOR_FORCE)||void 0)}J.Command=class t extends et{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>nt.stdout.write(t),writeErr:t=>nt.stderr.write(t),outputError:(t,e)=>e(t),getOutHelpWidth:()=>nt.stdout.isTTY?nt.stdout.columns:void 0,getErrHelpWidth:()=>nt.stderr.isTTY?nt.stderr.columns:void 0,getOutHasColors:()=>ft()??(nt.stdout.isTTY&&nt.stdout.hasColors?.()),getErrHasColors:()=>ft()??(nt.stderr.isTTY&&nt.stderr.hasColors?.()),stripColor:t=>ht(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){const t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,i){let s=e,r=i;"object"==typeof s&&null!==s&&(r=s,s=null),r=r||{};const[,n,o]=t.match(/([^ ]+) *(.*)/),a=this.createCommand(n);return s&&(a.description(s),a._executableHandler=!0),r.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!r.noHelp&&!r.hidden),a._executableFile=r.executableFile||null,o&&a.arguments(o),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),s?this:a}createCommand(e){return new t(e)}createHelp(){return Object.assign(new ct,this.configureHelp())}configureHelp(t){return void 0===t?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return void 0===t?this._outputConfiguration:(Object.assign(this._outputConfiguration,t),this)}showHelpAfterError(t=!0){return"string"!=typeof t&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(e=e||{}).isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new ot(t,e)}argument(t,e,i,s){const r=this.createArgument(t,e);return"function"==typeof i?r.default(s).argParser(i):r.default(i),this.addArgument(r),this}arguments(t){return t.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(t){const e=this.registeredArguments.slice(-1)[0];if(e&&e.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&void 0!==t.defaultValue&&void 0===t.parseArg)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,e){if("boolean"==typeof t)return this._addImplicitHelpCommand=t,this;t=t??"help [command]";const[,i,s]=t.match(/([^ ]+) *(.*)/),r=e??"display help for command",n=this.createCommand(i);return n.helpOption(!1),s&&n.arguments(s),r&&n.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=n,this}addHelpCommand(t,e){return"object"!=typeof t?(this.helpCommand(t,e),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,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(t,e){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return this._exitCallback=t||(t=>{if("commander.executeSubCommandAsync"!==t.code)throw t}),this}_exit(t,e,i){this._exitCallback&&this._exitCallback(new lt(t,e,i)),nt.exit(t)}action(t){return this._actionHandler=e=>{const i=this.registeredArguments.length,s=e.slice(0,i);return this._storeOptionsAsProperties?s[i]=this:s[i]=this.opts(),s.push(this),t.apply(this,s)},this}createOption(t,e){return new ut(t,e)}_callParseArg(t,e,i,s){try{return t.parseArg(e,i)}catch(t){if("commander.invalidArgument"===t.code){const e=`${s} ${t.message}`;this.error(e,{exitCode:t.exitCode,code:t.code})}throw t}}_registerOption(t){const e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){const i=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'\n- already used by option '${e.flags}'`)}this.options.push(t)}_registerCommand(t){const e=t=>[t.name()].concat(t.aliases()),i=e(t).find(t=>this._findCommand(t));if(i){const s=e(this._findCommand(i)).join("|"),r=e(t).join("|");throw new Error(`cannot add command '${r}' as already have command '${s}'`)}this.commands.push(t)}addOption(t){this._registerOption(t);const e=t.name(),i=t.attributeName();if(t.negate){const e=t.long.replace(/^--no-/,"--");this._findOption(e)||this.setOptionValueWithSource(i,void 0===t.defaultValue||t.defaultValue,"default")}else void 0!==t.defaultValue&&this.setOptionValueWithSource(i,t.defaultValue,"default");const s=(e,s,r)=>{null==e&&void 0!==t.presetArg&&(e=t.presetArg);const n=this.getOptionValue(i);null!==e&&t.parseArg?e=this._callParseArg(t,e,n,s):null!==e&&t.variadic&&(e=t._concatValue(e,n)),null==e&&(e=!t.negate&&(!(!t.isBoolean()&&!t.optional)||"")),this.setOptionValueWithSource(i,e,r)};return this.on("option:"+e,e=>{const i=`error: option '${t.flags}' argument '${e}' is invalid.`;s(e,i,"cli")}),t.envVar&&this.on("optionEnv:"+e,e=>{const i=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;s(e,i,"env")}),this}_optionEx(t,e,i,s,r){if("object"==typeof e&&e instanceof ut)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const n=this.createOption(e,i);if(n.makeOptionMandatory(!!t.mandatory),"function"==typeof s)n.default(r).argParser(s);else if(s instanceof RegExp){const t=s;s=(e,i)=>{const s=t.exec(e);return s?s[0]:i},n.default(r).argParser(s)}else n.default(s);return this.addOption(n)}option(t,e,i,s){return this._optionEx({},t,e,i,s)}requiredOption(t,e,i,s){return this._optionEx({mandatory:!0},t,e,i,s)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,i){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(i=>{void 0!==i.getOptionValueSource(t)&&(e=i.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(e=e||{},void 0===t&&void 0===e.from){nt.versions?.electron&&(e.from="electron");const t=nt.execArgv??[];(t.includes("-e")||t.includes("--eval")||t.includes("-p")||t.includes("--print"))&&(e.from="eval")}let i;switch(void 0===t&&(t=nt.argv),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":nt.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,e){this._prepareForParse();const i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){this._prepareForParse();const i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),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(t,e,i){if(rt.existsSync(t))return;throw new Error(`'${t}' does not exist\n - if '${i}' 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 - ${e?`searched for local subcommand relative to directory '${e}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory"}`)}_executeSubCommand(t,e){e=e.slice();let i=!1;const s=[".js",".ts",".tsx",".mjs",".cjs"];function r(t,e){const i=st.resolve(t,e);if(rt.existsSync(i))return i;if(s.includes(st.extname(e)))return;const r=s.find(t=>rt.existsSync(`${i}${t}`));return r?`${i}${r}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n,o=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let t;try{t=rt.realpathSync(this._scriptPath)}catch{t=this._scriptPath}a=st.resolve(st.dirname(t),a)}if(a){let e=r(a,o);if(!e&&!t._executableFile&&this._scriptPath){const i=st.basename(this._scriptPath,st.extname(this._scriptPath));i!==this._name&&(e=r(a,`${i}-${t._name}`))}o=e||o}if(i=s.includes(st.extname(o)),"win32"!==nt.platform?i?(e.unshift(o),e=mt(nt.execArgv).concat(e),n=it.spawn(nt.argv[0],e,{stdio:"inherit"})):n=it.spawn(o,e,{stdio:"inherit"}):(this._checkForMissingExecutable(o,a,t._name),e.unshift(o),e=mt(nt.execArgv).concat(e),n=it.spawn(nt.execPath,e,{stdio:"inherit"})),!n.killed){["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(t=>{nt.on(t,()=>{!1===n.killed&&null===n.exitCode&&n.kill(t)})})}const l=this._exitCallback;n.on("close",t=>{t=t??1,l?l(new lt(t,"commander.executeSubCommandAsync","(close)")):nt.exit(t)}),n.on("error",e=>{if("ENOENT"===e.code)this._checkForMissingExecutable(o,a,t._name);else if("EACCES"===e.code)throw new Error(`'${o}' not executable`);if(l){const t=new lt(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,l(t)}else nt.exit(1)}),this.runningCommand=n}_dispatchSubcommand(t,e,i){const s=this._findCommand(t);let r;return s||this.help({error:!0}),s._prepareForParse(),r=this._chainOrCallSubCommandHook(r,s,"preSubcommand"),r=this._chainOrCall(r,()=>{if(!s._executableHandler)return s._parseCommand(e,i);this._executeSubCommand(s,e.concat(i))}),r}_dispatchHelpCommand(t){t||this.help();const e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&null==this.args[e]&&this.missingArgument(t.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const t=(t,e,i)=>{let s=e;if(null!==e&&t.parseArg){const r=`error: command-argument value '${e}' is invalid for argument '${t.name()}'.`;s=this._callParseArg(t,e,i,r)}return s};this._checkNumberOfArguments();const e=[];this.registeredArguments.forEach((i,s)=>{let r=i.defaultValue;i.variadic?s<this.args.length?(r=this.args.slice(s),i.parseArg&&(r=r.reduce((e,s)=>t(i,s,e),i.defaultValue))):void 0===r&&(r=[]):s<this.args.length&&(r=this.args[s],i.parseArg&&(r=t(i,r,i.defaultValue))),e[s]=r}),this.processedArgs=e}_chainOrCall(t,e){return t&&t.then&&"function"==typeof t.then?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let i=t;const s=[];return this._getCommandAndAncestors().reverse().filter(t=>void 0!==t._lifeCycleHooks[e]).forEach(t=>{t._lifeCycleHooks[e].forEach(e=>{s.push({hookedCommand:t,callback:e})})}),"postAction"===e&&s.reverse(),s.forEach(t=>{i=this._chainOrCall(i,()=>t.callback(t.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,e,i){let s=t;return void 0!==this._lifeCycleHooks[i]&&this._lifeCycleHooks[i].forEach(t=>{s=this._chainOrCall(s,()=>t(this,e))}),s}_parseCommand(t,e){const i=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),e=i.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(e),this._dispatchSubcommand(this._defaultCommandName,t,e);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const s=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){let i;return s(),this._processArguments(),i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,()=>this._actionHandler(this.processedArgs)),this.parent&&(i=this._chainOrCall(i,()=>{this.parent.emit(r,t,e)})),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(r))s(),this._processArguments(),this.parent.emit(r,t,e);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,e);this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():(s(),this._processArguments())}else this.commands.length?(s(),this.help({error:!0})):(s(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&void 0===t.getOptionValue(e.attributeName())&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){const t=this.options.filter(t=>{const e=t.attributeName();return void 0!==this.getOptionValue(e)&&"default"!==this.getOptionValueSource(e)}),e=t.filter(t=>t.conflictsWith.length>0);e.forEach(e=>{const i=t.find(t=>e.conflictsWith.includes(t.attributeName()));i&&this._conflictingOption(e,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){const e=[],i=[];let s=e;const r=t.slice();function n(t){return t.length>1&&"-"===t[0]}let o=null;for(;r.length;){const t=r.shift();if("--"===t){s===i&&s.push(t),s.push(...r);break}if(!o||n(t)){if(o=null,n(t)){const e=this._findOption(t);if(e){if(e.required){const t=r.shift();void 0===t&&this.optionMissingArgument(e),this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;r.length>0&&!n(r[0])&&(t=r.shift()),this.emit(`option:${e.name()}`,t)}else this.emit(`option:${e.name()}`);o=e.variadic?e:null;continue}}if(t.length>2&&"-"===t[0]&&"-"!==t[1]){const e=this._findOption(`-${t[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,t.slice(2)):(this.emit(`option:${e.name()}`),r.unshift(`-${t.slice(2)}`));continue}}if(/^--[^=]+=/.test(t)){const e=t.indexOf("="),i=this._findOption(t.slice(0,e));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(e+1));continue}}if(n(t)&&(s=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===e.length&&0===i.length){if(this._findCommand(t)){e.push(t),r.length>0&&i.push(...r);break}if(this._getHelpCommand()&&t===this._getHelpCommand().name()){e.push(t),r.length>0&&e.push(...r);break}if(this._defaultCommandName){i.push(t),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){s.push(t),r.length>0&&s.push(...r);break}s.push(t)}else this.emit(`option:${o.name()}`,t)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={},e=this.options.length;for(let i=0;i<e;i++){const e=this.options[i].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){this._outputConfiguration.outputError(`${t}\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 i=e||{},s=i.exitCode||1,r=i.code||"commander.error";this._exit(s,r,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in nt.env){const e=t.attributeName();(void 0===this.getOptionValue(e)||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,nt.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){const t=new pt(this.options),e=t=>void 0!==this.getOptionValue(t)&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter(i=>void 0!==i.implied&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(t=>{Object.keys(t.implied).filter(t=>!e(t)).forEach(e=>{this.setOptionValueWithSource(e,t.implied[e],"implied")})})}missingArgument(t){const e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){const i=t=>{const e=t.attributeName(),i=this.getOptionValue(e),s=this.options.find(t=>t.negate&&e===t.attributeName()),r=this.options.find(t=>!t.negate&&e===t.attributeName());return s&&(void 0===s.presetArg&&!1===i||void 0!==s.presetArg&&i===s.presetArg)?s:r||t},s=t=>{const e=i(t),s=e.attributeName();return"env"===this.getOptionValueSource(s)?`environment variable '${e.envVar}'`:`option '${e.flags}'`},r=`error: ${s(t)} cannot be used with ${s(e)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[],s=this;do{const t=s.createHelp().visibleOptions(s).filter(t=>t.long).map(t=>t.long);i=i.concat(t),s=s.parent}while(s&&!s._enablePositionalOptions);e=dt(t,i)}const i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const e=this.registeredArguments.length,i=1===e?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${i} but got ${t.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach(t=>{i.push(t.name()),t.alias()&&i.push(t.alias())}),e=dt(t,i)}const i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(void 0===t)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";const s=this.createOption(e,i);return this._versionOptionName=s.attributeName(),this._registerOption(s),this.on("option:"+s.name(),()=>{this._outputConfiguration.writeOut(`${t}\n`),this._exit(0,"commander.version",t)}),this}description(t,e){return void 0===t&&void 0===e?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return void 0===t?this._summary:(this._summary=t,this)}alias(t){if(void 0===t)return this._aliases[0];let e=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");const i=this.parent?._findCommand(t);if(i){const e=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${e}'`)}return e._aliases.push(t),this}aliases(t){return void 0===t?this._aliases:(t.forEach(t=>this.alias(t)),this)}usage(t){if(void 0===t){if(this._usage)return this._usage;const t=this.registeredArguments.map(t=>at(t));return[].concat(this.options.length||null!==this._helpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=t,this}name(t){return void 0===t?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=st.basename(t,st.extname(t)),this}executableDir(t){return void 0===t?this._executableDir:(this._executableDir=t,this)}helpInformation(t){const e=this.createHelp(),i=this._getOutputContext(t);e.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});const s=e.formatHelp(this,e);return i.hasColors?s:this._outputConfiguration.stripColor(s)}_getOutputContext(t){const e=!!(t=t||{}).error;let i,s,r;e?(i=t=>this._outputConfiguration.writeErr(t),s=this._outputConfiguration.getErrHasColors(),r=this._outputConfiguration.getErrHelpWidth()):(i=t=>this._outputConfiguration.writeOut(t),s=this._outputConfiguration.getOutHasColors(),r=this._outputConfiguration.getOutHelpWidth());return{error:e,write:t=>(s||(t=this._outputConfiguration.stripColor(t)),i(t)),hasColors:s,helpWidth:r}}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const i=this._getOutputContext(t),s={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(t=>t.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let r=this.helpInformation({error:i.error});if(e&&(r=e(r),"string"!=typeof r&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",s),this._getCommandAndAncestors().forEach(t=>t.emit("afterAllHelp",s))}helpOption(t,e){return"boolean"==typeof t?(this._helpOption=t?this._helpOption??void 0:null,this):(t=t??"-h, --help",e=e??"display help for command",this._helpOption=this.createOption(t,e),this)}_getHelpOption(){return void 0===this._helpOption&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this}help(t){this.outputHelp(t);let e=Number(nt.exitCode??0);0===e&&t&&"function"!=typeof t&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);const s=`${t}Help`;return this.on(s,t=>{let i;i="function"==typeof e?e({error:t.error,command:t.command}):e,i&&t.write(`${i}\n`)}),this}_outputHelpIfRequested(t){const e=this._getHelpOption();e&&t.find(t=>e.is(t))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}},J.useColor=ft;const{Argument:gt}=B,{Command:yt}=J,{CommanderError:wt,InvalidArgumentError:bt}=q,{Help:vt}=G,{Option:_t}=Z;W.program=new yt,W.createCommand=t=>new yt(t),W.createOption=(t,e)=>new _t(t,e),W.createArgument=(t,e)=>new gt(t,e),W.Command=yt,W.Option=_t,W.Argument=gt,W.Help=vt,W.CommanderError=wt,W.InvalidArgumentError=bt,W.InvalidOptionArgumentError=bt;const{Command:St}=W;var xt,Ot={},Ct={exports:{}},kt={exports:{}};const Et=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,At=()=>{const t={enabled:"undefined"!=typeof process&&"0"!==process.env.FORCE_COLOR,visible:!0,styles:{},keys:{}},e=(t,e,i)=>"function"==typeof t?t(e):t.wrap(e,i),i=(i,s)=>{if(""===i||null==i)return"";if(!1===t.enabled)return i;if(!1===t.visible)return"";let r=""+i,n=r.includes("\n"),o=s.length;for(o>0&&s.includes("unstyle")&&(s=[...new Set(["unstyle",...s])].reverse());o-- >0;)r=e(t.styles[s[o]],r,n);return r},s=(e,s,r)=>{t.styles[e]=(t=>{let e=t.open=`[${t.codes[0]}m`,i=t.close=`[${t.codes[1]}m`,s=t.regex=new RegExp(`\\u001b\\[${t.codes[1]}m`,"g");return t.wrap=(t,r)=>{t.includes(i)&&(t=t.replace(s,i+e));let n=e+t+i;return r?n.replace(/\r*\n/g,`${i}$&${e}`):n},t})({name:e,codes:s}),(t.keys[r]||(t.keys[r]=[])).push(e),Reflect.defineProperty(t,e,{configurable:!0,enumerable:!0,set(i){t.alias(e,i)},get(){let s=t=>i(t,s.stack);return Reflect.setPrototypeOf(s,t),s.stack=this.stack?this.stack.concat(e):[e],s}})};return s("reset",[0,0],"modifier"),s("bold",[1,22],"modifier"),s("dim",[2,22],"modifier"),s("italic",[3,23],"modifier"),s("underline",[4,24],"modifier"),s("inverse",[7,27],"modifier"),s("hidden",[8,28],"modifier"),s("strikethrough",[9,29],"modifier"),s("black",[30,39],"color"),s("red",[31,39],"color"),s("green",[32,39],"color"),s("yellow",[33,39],"color"),s("blue",[34,39],"color"),s("magenta",[35,39],"color"),s("cyan",[36,39],"color"),s("white",[37,39],"color"),s("gray",[90,39],"color"),s("grey",[90,39],"color"),s("bgBlack",[40,49],"bg"),s("bgRed",[41,49],"bg"),s("bgGreen",[42,49],"bg"),s("bgYellow",[43,49],"bg"),s("bgBlue",[44,49],"bg"),s("bgMagenta",[45,49],"bg"),s("bgCyan",[46,49],"bg"),s("bgWhite",[47,49],"bg"),s("blackBright",[90,39],"bright"),s("redBright",[91,39],"bright"),s("greenBright",[92,39],"bright"),s("yellowBright",[93,39],"bright"),s("blueBright",[94,39],"bright"),s("magentaBright",[95,39],"bright"),s("cyanBright",[96,39],"bright"),s("whiteBright",[97,39],"bright"),s("bgBlackBright",[100,49],"bgBright"),s("bgRedBright",[101,49],"bgBright"),s("bgGreenBright",[102,49],"bgBright"),s("bgYellowBright",[103,49],"bgBright"),s("bgBlueBright",[104,49],"bgBright"),s("bgMagentaBright",[105,49],"bgBright"),s("bgCyanBright",[106,49],"bgBright"),s("bgWhiteBright",[107,49],"bgBright"),t.ansiRegex=Et,t.hasColor=t.hasAnsi=e=>(t.ansiRegex.lastIndex=0,"string"==typeof e&&""!==e&&t.ansiRegex.test(e)),t.alias=(e,s)=>{let r="string"==typeof s?t[s]:s;if("function"!=typeof r)throw new TypeError("Expected alias to be the name of an existing color (string) or a function");r.stack||(Reflect.defineProperty(r,"name",{value:e}),t.styles[e]=r,r.stack=[e]),Reflect.defineProperty(t,e,{configurable:!0,enumerable:!0,set(i){t.alias(e,i)},get(){let e=t=>i(t,e.stack);return Reflect.setPrototypeOf(e,t),e.stack=this.stack?this.stack.concat(r.stack):r.stack,e}})},t.theme=e=>{if(null===(i=e)||"object"!=typeof i||Array.isArray(i))throw new TypeError("Expected theme to be an object");var i;for(let i of Object.keys(e))t.alias(i,e[i]);return t},t.alias("unstyle",e=>"string"==typeof e&&""!==e?(t.ansiRegex.lastIndex=0,e.replace(t.ansiRegex,"")):""),t.alias("noop",t=>t),t.none=t.clear=t.noop,t.stripColor=t.unstyle,t.symbols=(xt||(xt=1,function(t){const e="undefined"!=typeof process&&"Hyper"===process.env.TERM_PROGRAM,i="undefined"!=typeof process&&"win32"===process.platform,s="undefined"!=typeof process&&"linux"===process.platform,r={ballotDisabled:"☒",ballotOff:"☐",ballotOn:"☑",bullet:"•",bulletWhite:"◦",fullBlock:"█",heart:"❤",identicalTo:"≡",line:"─",mark:"※",middot:"·",minus:"-",multiplication:"×",obelus:"÷",pencilDownRight:"✎",pencilRight:"✏",pencilUpRight:"✐",percent:"%",pilcrow2:"❡",pilcrow:"¶",plusMinus:"±",question:"?",section:"§",starsOff:"☆",starsOn:"★",upDownArrow:"↕"},n=Object.assign({},r,{check:"√",cross:"×",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"»",radioOff:"( )",radioOn:"(*)",warning:"‼"}),o=Object.assign({},r,{ballotCross:"✘",check:"✔",cross:"✖",ellipsisLarge:"⋯",ellipsis:"…",info:"ℹ",questionFull:"?",questionSmall:"﹖",pointer:s?"▸":"❯",pointerSmall:s?"‣":"›",radioOff:"◯",radioOn:"◉",warning:"⚠"});t.exports=i&&!e?n:o,Reflect.defineProperty(t.exports,"common",{enumerable:!1,value:r}),Reflect.defineProperty(t.exports,"windows",{enumerable:!1,value:n}),Reflect.defineProperty(t.exports,"other",{enumerable:!1,value:o})}(kt)),kt.exports),t.define=s,t};Ct.exports=At(),Ct.exports.create=At;var $t,Pt,Dt,Tt,jt=Ct.exports;function Nt(){return Pt?$t:(Pt=1,$t=({onlyFirst:t=!1}={})=>{const e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,t?void 0:"g")})}function Ft(){if(Tt)return Dt;Tt=1;const t=Nt();return Dt=e=>"string"==typeof e?e.replace(t(),""):e,Dt}!function(t){const e=Object.prototype.toString,i=jt;let s=!1,r=new Set;const n={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};t.longest=(t,e)=>t.reduce((t,i)=>Math.max(t,e?i[e].length:i.length),0),t.hasColor=t=>!!t&&i.hasColor(t);const o=t.isObject=t=>null!==t&&"object"==typeof t&&!Array.isArray(t);t.nativeType=t=>e.call(t).slice(8,-1).toLowerCase().replace(/\s/g,""),t.isAsyncFn=e=>"asyncfunction"===t.nativeType(e),t.isPrimitive=t=>null!=t&&"object"!=typeof t&&"function"!=typeof t,t.resolve=(t,e,...i)=>"function"==typeof e?e.call(t,...i):e,t.scrollDown=(t=[])=>[...t.slice(1),t[0]],t.scrollUp=(t=[])=>[t.pop(),...t],t.reorder=(t=[])=>{let e=t.slice();return e.sort((t,e)=>t.index>e.index?1:t.index<e.index?-1:0),e},t.swap=(t,e,i)=>{let s=t.length,r=i===s?0:i<0?s-1:i,n=t[e];t[e]=t[r],t[r]=n},t.width=(t,e=80)=>{let i=t&&t.columns?t.columns:e;return t&&"function"==typeof t.getWindowSize&&(i=t.getWindowSize()[0]),"win32"===process.platform?i-1:i},t.height=(t,e=20)=>{let i=t&&t.rows?t.rows:e;return t&&"function"==typeof t.getWindowSize&&(i=t.getWindowSize()[1]),i},t.wordWrap=(t,e={})=>{if(!t)return t;"number"==typeof e&&(e={width:e});let{indent:i="",newline:s="\n"+i,width:r=80}=e,n=(s+i).match(/[^\S\n]/g)||[];r-=n.length;let o=`.{1,${r}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,a=t.trim(),l=new RegExp(o,"g"),c=a.match(l)||[];return c=c.map(t=>t.replace(/\n$/,"")),e.padEnd&&(c=c.map(t=>t.padEnd(r," "))),e.padStart&&(c=c.map(t=>t.padStart(r," "))),i+c.join(s)},t.unmute=t=>{let e=t.stack.find(t=>i.keys.color.includes(t));return e?i[e]:t.stack.find(t=>"bg"===t.slice(2))?i[e.slice(2)]:t=>t},t.pascal=t=>t?t[0].toUpperCase()+t.slice(1):"",t.inverse=e=>{if(!e||!e.stack)return e;let s=e.stack.find(t=>i.keys.color.includes(t));if(s){let r=i["bg"+t.pascal(s)];return r?r.black:e}let r=e.stack.find(t=>"bg"===t.slice(0,2));return r?i[r.slice(2).toLowerCase()]||e:i.none},t.complement=e=>{if(!e||!e.stack)return e;let s=e.stack.find(t=>i.keys.color.includes(t)),r=e.stack.find(t=>"bg"===t.slice(0,2));if(s&&!r)return i[n[s]||s];if(r){let s=r.slice(2).toLowerCase(),o=n[s];return o&&i["bg"+t.pascal(o)]||e}return i.none},t.meridiem=t=>{let e=t.getHours(),i=t.getMinutes(),s=e>=12?"pm":"am";return e%=12,(0===e?12:e)+":"+(i<10?"0"+i:i)+" "+s},t.set=(e={},i="",s)=>i.split(".").reduce((e,i,r,n)=>{let o=n.length-1>r?e[i]||{}:s;return!t.isObject(o)&&r<n.length-1&&(o={}),e[i]=o},e),t.get=(t={},e="",i)=>{let s=null==t[e]?e.split(".").reduce((t,e)=>t&&t[e],t):t[e];return null==s?i:s},t.mixin=(e,i)=>{if(!o(e))return i;if(!o(i))return e;for(let s of Object.keys(i)){let r=Object.getOwnPropertyDescriptor(i,s);if(hasOwnProperty.call(r,"value"))if(hasOwnProperty.call(e,s)&&o(r.value)){let n=Object.getOwnPropertyDescriptor(e,s);o(n.value)&&n.value!==r.value?e[s]=t.merge({},e[s],i[s]):Reflect.defineProperty(e,s,r)}else Reflect.defineProperty(e,s,r);else Reflect.defineProperty(e,s,r)}return e},t.merge=(...e)=>{let i={};for(let s of e)t.mixin(i,s);return i},t.mixinEmitter=(e,i)=>{let s=i.constructor.prototype;for(let r of Object.keys(s)){let n=s[r];"function"==typeof n?t.define(e,r,n.bind(i)):t.define(e,r,n)}};const a=(t,e)=>{s||(s=!0,r.forEach(t=>t()),!0===t&&process.exit(128+e))},l=a.bind(null,!0,15),c=a.bind(null,!0,2);t.onExit=t=>(0===r.size&&(process.once("SIGTERM",l),process.once("SIGINT",c),process.once("exit",a)),r.add(t),()=>{r.delete(t),0===r.size&&(process.off("SIGTERM",l),process.off("SIGINT",c),process.off("exit",a))}),t.define=(t,e,i)=>{Reflect.defineProperty(t,e,{value:i})},t.defineExport=(t,e,i)=>{let s;Reflect.defineProperty(t,e,{enumerable:!0,configurable:!0,set(t){s=t},get:()=>s?s():i()})}}(Ot);var It,Lt,Rt,Vt,Mt,Ht,Wt,Bt,qt,Ut,zt,Jt,Gt,Kt,Yt,Zt={};function Xt(){return It||(It=1,Zt.ctrl={a:"first",b:"backward",c:"cancel",d:"deleteForward",e:"last",f:"forward",g:"reset",i:"tab",k:"cutForward",l:"reset",n:"newItem",m:"cancel",j:"submit",p:"search",r:"remove",s:"save",u:"undo",w:"cutLeft",x:"toggleCursor",v:"paste"},Zt.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"},Zt.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"},Zt.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"},Zt.keys={pageup:"pageUp",pagedown:"pageDown",home:"home",end:"end",cancel:"cancel",delete:"deleteForward",backspace:"delete",down:"down",enter:"submit",escape:"cancel",left:"left",space:"space",number:"number",return:"submit",right:"right",tab:"next",up:"up"}),Zt}function Qt(){if(Mt)return Vt;Mt=1;const t=p,e=Xt(),i=Rt?Lt:(Rt=1,Lt=class{_queue=[];_executing=!1;_jobRunner=null;constructor(t){this._jobRunner=t}enqueue=(...t)=>{this._queue.push(t),this._dequeue()};destroy(){this._queue.length=0,this._jobRunner=null}_dequeue(){!this._executing&&this._queue.length&&(this._executing=!0,this._jobRunner(...this._queue.shift()),setTimeout(()=>{this._executing=!1,this._dequeue()}))}}),s=/^(?:\x1b)([a-zA-Z0-9])$/,r=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,n={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"};const o=(t="",e={})=>{let i,o={name:e.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:t,raw:t,...e};if(Buffer.isBuffer(t)?t[0]>127&&void 0===t[1]?(t[0]-=128,t=""+String(t)):t=String(t):void 0!==t&&"string"!=typeof t?t=String(t):t||(t=o.sequence||""),o.sequence=o.sequence||t||o.name,"\r"===t)o.raw=void 0,o.name="return";else if("\n"===t)o.name="enter";else if("\t"===t)o.name="tab";else if("\b"===t||""===t||""===t||"\b"===t)o.name="backspace",o.meta=""===t.charAt(0);else if(""===t||""===t)o.name="escape",o.meta=2===t.length;else if(" "===t||" "===t)o.name="space",o.meta=2===t.length;else if(t<="")o.name=String.fromCharCode(t.charCodeAt(0)+"a".charCodeAt(0)-1),o.ctrl=!0;else if(1===t.length&&t>="0"&&t<="9")o.name="number";else if(1===t.length&&t>="a"&&t<="z")o.name=t;else if(1===t.length&&t>="A"&&t<="Z")o.name=t.toLowerCase(),o.shift=!0;else if(i=s.exec(t))o.meta=!0,o.shift=/^[A-Z]$/.test(i[1]);else if(i=r.exec(t)){let e=[...t];""===e[0]&&""===e[1]&&(o.option=!0);let s=[i[1],i[2],i[4],i[6]].filter(Boolean).join(""),r=(i[3]||i[5]||1)-1;o.ctrl=!!(4&r),o.meta=!!(10&r),o.shift=!!(1&r),o.code=s,o.name=n[s],o.shift=function(t){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(t)}(s)||o.shift,o.ctrl=function(t){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(t)}(s)||o.ctrl}return o};return o.listen=(e={},s)=>{let{stdin:r}=e;if(!r||r!==process.stdin&&!r.isTTY)throw new Error("Invalid stream passed");let n=t.createInterface({terminal:!0,input:r});t.emitKeypressEvents(r,n);const a=new i((t,e)=>s(t,o(t,e),n));let l=r.isRaw;r.isTTY&&r.setRawMode(!0),r.on("keypress",a.enqueue),n.resume();return()=>{r.isTTY&&r.setRawMode(l),r.removeListener("keypress",a.enqueue),a.destroy(),n.pause(),n.close()}},o.action=(t,i,s)=>{let r={...e,...s};return i.ctrl?(i.action=r.ctrl[i.name],i):i.option&&r.option?(i.action=r.option[i.name],i):i.shift?(i.action=r.shift[i.name],i):(i.action=r.keys[i.name],i)},Vt=o}function te(){if(Wt)return Ht;function t(t,e,i={}){let s=t.timers[e]={name:e,start:Date.now(),ms:0,tick:0},r=i.interval||120;s.frames=i.frames||[],s.loading=!0;let n=setInterval(()=>{s.ms=Date.now()-s.start,s.tick++,t.render()},r);return s.stop=()=>{s.loading=!1,clearInterval(n)},Reflect.defineProperty(s,"interval",{value:n}),t.once("close",()=>s.stop()),s.stop}return Wt=1,Ht=e=>{e.timers=e.timers||{};let i=e.options.timers;if(i)for(let s of Object.keys(i)){let r=i[s];"number"==typeof r&&(r={interval:r}),t(e,s,r)}},Ht}function ee(){if(Yt)return Kt;Yt=1;const t=function(){if(zt)return Ut;zt=1;const t=Ot,e=jt,i={default:e.noop,noop:e.noop,set inverse(t){this._inverse=t},get inverse(){return this._inverse||t.inverse(this.primary)},set complement(t){this._complement=t},get complement(){return this._complement||t.complement(this.primary)},primary:e.cyan,success:e.green,danger:e.magenta,strong:e.bold,warning:e.yellow,muted:e.dim,disabled:e.gray,dark:e.dim.gray,underline:e.underline,set info(t){this._info=t},get info(){return this._info||this.primary},set em(t){this._em=t},get em(){return this._em||this.primary.underline},set heading(t){this._heading=t},get heading(){return this._heading||this.muted.underline},set pending(t){this._pending=t},get pending(){return this._pending||this.primary},set submitted(t){this._submitted=t},get submitted(){return this._submitted||this.success},set cancelled(t){this._cancelled=t},get cancelled(){return this._cancelled||this.danger},set typing(t){this._typing=t},get typing(){return this._typing||this.dim},set placeholder(t){this._placeholder=t},get placeholder(){return this._placeholder||this.primary.dim},set highlight(t){this._highlight=t},get highlight(){return this._highlight||this.inverse},merge:(s={})=>{s.styles&&"boolean"==typeof s.styles.enabled&&(e.enabled=s.styles.enabled),s.styles&&"boolean"==typeof s.styles.visible&&(e.visible=s.styles.visible);let r=t.merge({},i,s.styles);delete r.merge;for(let t of Object.keys(e))hasOwnProperty.call(r,t)||Reflect.defineProperty(r,t,{get:()=>e[t]});for(let t of Object.keys(e.styles))hasOwnProperty.call(r,t)||Reflect.defineProperty(r,t,{get:()=>e[t]});return r}};return Ut=i}(),e=function(){if(Gt)return Jt;Gt=1;const t="win32"===process.platform,e=jt,i=Ot,s={...e.symbols,upDownDoubleArrow:"⇕",upDownDoubleArrow2:"⬍",upDownArrow:"↕",asterisk:"*",asterism:"⁂",bulletWhite:"◦",electricArrow:"⌁",ellipsisLarge:"⋯",ellipsisSmall:"…",fullBlock:"█",identicalTo:"≡",indicator:e.symbols.check,leftAngle:"‹",mark:"※",minus:"−",multiplication:"×",obelus:"÷",percent:"%",pilcrow:"¶",pilcrow2:"❡",pencilUpRight:"✐",pencilDownRight:"✎",pencilRight:"✏",plus:"+",plusMinus:"±",pointRight:"☞",rightAngle:"›",section:"§",hexagon:{off:"⬡",on:"⬢",disabled:"⬢"},ballot:{on:"☑",off:"☐",disabled:"☒"},stars:{on:"★",off:"☆",disabled:"☆"},folder:{on:"▼",off:"▶",disabled:"▶"},prefix:{pending:e.symbols.question,submitted:e.symbols.check,cancelled:e.symbols.cross},separator:{pending:e.symbols.pointerSmall,submitted:e.symbols.middot,cancelled:e.symbols.middot},radio:{off:t?"( )":"◯",on:t?"(*)":"◉",disabled:t?"(|)":"Ⓘ"},numbers:["⓪","①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩","⑪","⑫","⑬","⑭","⑮","⑯","⑰","⑱","⑲","⑳","㉑","㉒","㉓","㉔","㉕","㉖","㉗","㉘","㉙","㉚","㉛","㉜","㉝","㉞","㉟","㊱","㊲","㊳","㊴","㊵","㊶","㊷","㊸","㊹","㊺","㊻","㊼","㊽","㊾","㊿"]};return s.merge=t=>{let r=i.merge({},e.symbols,s,t.symbols);return delete r.merge,r},Jt=s}(),i=Ot;return Kt=s=>{s.options=i.merge({},s.options.theme,s.options),s.symbols=e.merge(s.options),s.styles=t.merge(s.options)},Kt}var ie,se,re,ne={exports:{}};function oe(){return ie||(ie=1,function(t,e){const i="Apple_Terminal"===process.env.TERM_PROGRAM,s=Ft(),r=Ot,n=t.exports=e,o="[";let a=!1;const l=n.code={bell:"",beep:"",beginning:`${o}G`,down:`${o}J`,esc:o,getPosition:`${o}6n`,hide:`${o}?25l`,line:`${o}2K`,lineEnd:`${o}K`,lineStart:`${o}1K`,restorePosition:o+(i?"8":"u"),savePosition:o+(i?"7":"s"),screen:`${o}2J`,show:`${o}?25h`,up:`${o}1J`},c=n.cursor={get hidden(){return a},hide:()=>(a=!0,l.hide),show:()=>(a=!1,l.show),forward:(t=1)=>`${o}${t}C`,backward:(t=1)=>`${o}${t}D`,nextLine:(t=1)=>`${o}E`.repeat(t),prevLine:(t=1)=>`${o}F`.repeat(t),up:(t=1)=>t?`${o}${t}A`:"",down:(t=1)=>t?`${o}${t}B`:"",right:(t=1)=>t?`${o}${t}C`:"",left:(t=1)=>t?`${o}${t}D`:"",to:(t,e)=>e?`${o}${e+1};${t+1}H`:`${o}${t+1}G`,move(t=0,e=0){let i="";return i+=t<0?c.left(-t):t>0?c.right(t):"",i+=e<0?c.up(-e):e>0?c.down(e):"",i},strLen(t){for(var e=0,i=t.length,s=-1,r=0;r<i;r++)e+=(s=t.charCodeAt(r))>=0&&s<=128?1:2;return e},restore(t={}){let{after:e,cursor:i,initial:s,input:o,prompt:a,size:l,value:c}=t;if(s=r.isPrimitive(s)?String(s):"",o=r.isPrimitive(o)?String(o):"",c=r.isPrimitive(c)?String(c):"",l){let t=n.cursor.up(l)+n.cursor.to(this.strLen(a)),e=o.length-i;return e>0&&(t+=n.cursor.left(e)),t}if(c||e){let t=!o&&s?-this.strLen(s):-this.strLen(o)+i;return e&&(t-=this.strLen(e)),""===o&&s&&!a.includes(s)&&(t+=this.strLen(s)),n.cursor.move(t)}}},h=n.erase={screen:l.screen,up:l.up,down:l.down,line:l.line,lineEnd:l.lineEnd,lineStart:l.lineStart,lines(t){let e="";for(let i=0;i<t;i++)e+=n.erase.line+(i<t-1?n.cursor.up(1):"");return t&&(e+=n.code.beginning),e}};n.clear=(t="",e=process.stdout.columns)=>{if(!e)return h.line+c.to(0);let i=t=>[...s(t)].length,r=t.split(/\r?\n/),n=0;for(let t of r)n+=1+Math.floor(Math.max(i(t)-1,0)/e);return(h.line+c.prevLine()).repeat(n-1)+h.line+c.to(0)}}(ne,ne.exports)),ne.exports}function ae(){if(re)return se;re=1;const t=u,e=Ft(),i=Qt(),s=te(),r=function(){if(qt)return Bt;qt=1;const{define:t,width:e}=Ot;return Bt=class{constructor(i){let s=i.options;t(this,"_prompt",i),this.type=i.type,this.name=i.name,this.message="",this.header="",this.footer="",this.error="",this.hint="",this.input="",this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt="",this.buffer="",this.width=e(s.stdout||process.stdout),Object.assign(this,s),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=i.symbols,this.styles=i.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let t={...this};return t.status=this.status,t.buffer=Buffer.from(t.buffer),delete t.clone,t}set color(t){this._color=t}get color(){let t=this.prompt.styles;if(this.cancelled)return t.cancelled;if(this.submitted)return t.submitted;let e=this._color||t[this.status];return"function"==typeof e?e:t.pending}set loading(t){this._loading=t}get loading(){return"boolean"==typeof this._loading?this._loading:!!this.loadingChoices&&"choices"}get status(){return this.cancelled?"cancelled":this.submitted?"submitted":"pending"}},Bt}(),n=ee(),o=Ot,a=oe();class l extends t{constructor(t={}){super(),this.name=t.name,this.type=t.type,this.options=t,n(this),s(this),this.state=new r(this),this.initial=[t.initial,t.default].find(t=>null!=t),this.stdout=t.stdout||process.stdout,this.stdin=t.stdin||process.stdin,this.scale=t.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=function(t){"number"==typeof t&&(t=[t,t,t,t]);let e=[].concat(t||[]),i=t=>t%2==0?"\n":" ",s=[];for(let t=0;t<4;t++){let r=i(t);e[t]?s.push(r.repeat(e[t])):s.push("")}return s}(this.options.margin),this.setMaxListeners(0),function(t){let e=e=>void 0===t[e]||"function"==typeof t[e],i=["actions","choices","initial","margin","roles","styles","symbols","theme","timers","value"],s=["body","footer","error","header","hint","indicator","message","prefix","separator","skip"];for(let r of Object.keys(t.options)){if(i.includes(r))continue;if(/^on[A-Z]/.test(r))continue;let n=t.options[r];"function"==typeof n&&e(r)?s.includes(r)||(t[r]=n.bind(t)):"function"!=typeof t[r]&&(t[r]=n)}}(this)}async keypress(t,e={}){this.keypressed=!0;let s=i.action(t,i(t,e),this.options.actions);this.state.keypress=s,this.emit("keypress",t,s),this.emit("state",this.state.clone());const r=this.options[s.action]||this[s.action]||this.dispatch;if("function"==typeof r)return await r.call(this,t,s);this.alert()}alert(){delete this.state.alert,!1===this.options.show?this.emit("alert"):this.stdout.write(a.code.beep)}cursorHide(){this.stdout.write(a.cursor.hide());const t=o.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),t()})}cursorShow(){this.stdout.write(a.cursor.show())}write(t){t&&(this.stdout&&!1!==this.state.show&&this.stdout.write(t),this.state.buffer+=t)}clear(t=0){let e=this.state.buffer;this.state.buffer="",(e||t)&&!1!==this.options.show&&this.stdout.write(a.cursor.down(t)+a.clear(e,this.width))}restore(){if(this.state.closed||!1===this.options.show)return;let{prompt:t,after:e,rest:i}=this.sections(),{cursor:s,initial:r="",input:n="",value:o=""}=this,l={after:e,cursor:s,initial:r,input:n,prompt:t,size:this.state.size=i.length,value:o},c=a.cursor.restore(l);c&&this.stdout.write(c)}sections(){let{buffer:t,input:i,prompt:s}=this.state;s=e(s);let r=e(t),n=r.indexOf(s),o=r.slice(0,n),a=r.slice(n).split("\n"),l=a[0],c=a[a.length-1],h=(s+(i?" "+i:"")).length,u=h<l.length?l.slice(h+1):"";return{header:o,prompt:l,after:u,rest:a.slice(1),last:c}}async submit(){this.state.submitted=!0,this.state.validating=!0,this.options.onSubmit&&await this.options.onSubmit.call(this,this.name,this.value,this);let t=this.state.error||await this.validate(this.value,this.state);if(!0!==t){let e="\n"+this.symbols.pointer+" ";return e+="string"==typeof t?t.trim():"Invalid input",this.state.error="\n"+this.styles.danger(e),this.state.submitted=!1,await this.render(),await this.alert(),this.state.validating=!1,void(this.state.error=void 0)}this.state.validating=!1,await this.render(),await this.close(),this.value=await this.result(this.value),this.emit("submit",this.value)}async cancel(t){this.state.cancelled=this.state.submitted=!0,await this.render(),await this.close(),"function"==typeof this.options.onCancel&&await this.options.onCancel.call(this,this.name,this.value,this),this.emit("cancel",await this.error(t))}async close(){this.state.closed=!0;try{let t=this.sections(),e=Math.ceil(t.prompt.length/this.width);t.rest&&this.write(a.cursor.down(t.rest.length)),this.write("\n".repeat(e))}catch(t){}this.emit("close")}start(){this.stop||!1===this.options.show||(this.stop=i.listen(this,this.keypress.bind(this)),this.once("close",this.stop),this.emit("start",this))}async skip(){return this.skipped=!0===this.options.skip,"function"==typeof this.options.skip&&(this.skipped=await this.options.skip.call(this,this.name,this.value)),this.skipped}async initialize(){let{format:t,options:e,result:i}=this;if(this.format=()=>t.call(this,this.value),this.result=()=>i.call(this,this.value),"function"==typeof e.initial&&(this.initial=await e.initial.call(this,this)),"function"==typeof e.onRun&&await e.onRun.call(this,this),"function"==typeof e.onSubmit){let t=e.onSubmit.bind(this),i=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>(await t(this.name,this.value,this),i())}await this.start(),await this.render()}render(){throw new Error("expected prompt to have a custom render method")}run(){return new Promise(async(t,e)=>{if(this.once("submit",t),this.once("cancel",e),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit("run")})}async element(t,e,i){let{options:s,state:r,symbols:n,timers:o}=this,a=o&&o[t];r.timer=a;let l=s[t]||r[t]||n[t],c=e&&null!=e[t]?e[t]:await l;if(""===c)return c;let h=await this.resolve(c,r,e,i);return!h&&e&&e[t]?this.resolve(l,r,e,i):h}async prefix(){let t=await this.element("prefix")||this.symbols,e=this.timers&&this.timers.prefix,i=this.state;if(i.timer=e,o.isObject(t)&&(t=t[i.status]||t.pending),!o.hasColor(t)){return(this.styles[i.status]||this.styles.pending)(t)}return t}async message(){let t=await this.element("message");return o.hasColor(t)?t:this.styles.strong(t)}async separator(){let t=await this.element("separator")||this.symbols,e=this.timers&&this.timers.separator,i=this.state;i.timer=e;let s=t[i.status]||t.pending||i.separator,r=await this.resolve(s,i);return o.isObject(r)&&(r=r[i.status]||r.pending),o.hasColor(r)?r:this.styles.muted(r)}async pointer(t,e){let i=await this.element("pointer",t,e);if("string"==typeof i&&o.hasColor(i))return i;if(i){let t=this.styles,s=this.index===e,r=s?t.primary:t=>t,n=await this.resolve(i[s?"on":"off"]||i,this.state),a=o.hasColor(n)?n:r(n);return s?a:" ".repeat(n.length)}}async indicator(t,e){let i=await this.element("indicator",t,e);if("string"==typeof i&&o.hasColor(i))return i;if(i){let e=this.styles,s=!0===t.enabled,r=s?e.success:e.dark,n=i[s?"on":"off"]||i;return o.hasColor(n)?n:r(n)}return""}body(){return null}footer(){if("pending"===this.state.status)return this.element("footer")}header(){if("pending"===this.state.status)return this.element("header")}async hint(){if("pending"===this.state.status&&!this.isValue(this.state.input)){let t=await this.element("hint");return o.hasColor(t)?t:this.styles.muted(t)}}error(t){return this.state.submitted?"":t||this.state.error}format(t){return t}result(t){return t}validate(t){return!0!==this.options.required||this.isValue(t)}isValue(t){return null!=t&&""!==t}resolve(t,...e){return o.resolve(this,t,...e)}get base(){return l.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||o.height(this.stdout,25)}get width(){return this.options.columns||o.width(this.stdout,80)}get size(){return{width:this.width,height:this.height}}set cursor(t){this.state.cursor=t}get cursor(){return this.state.cursor}set input(t){this.state.input=t}get input(){return this.state.input}set value(t){this.state.value=t}get value(){let{input:t,value:e}=this.state,i=[e,t].find(this.isValue.bind(this));return this.isValue(i)?i:this.initial}static get prompt(){return t=>new this(t).run()}}return se=l}var le,ce,he,ue,pe,de,me,fe,ge,ye,we,be,ve,_e,Se,xe,Oe,Ce,ke,Ee,Ae,$e,Pe,De,Te,je,Ne,Fe,Ie,Le,Re,Ve,Me,He,We,Be,qe,Ue,ze,Je,Ge,Ke,Ye,Ze,Xe,Qe,ti,ei,ii,si,ri,ni,oi,ai,li,ci,hi,ui,pi,di={};function mi(){if(ue)return he;ue=1;const t=Ft(),e=ae(),i=function(){if(ce)return le;ce=1;const t=Ot,e={default:(t,e)=>e,checkbox(t,e){throw new Error("checkbox role is not implemented yet")},editable(t,e){throw new Error("editable role is not implemented yet")},expandable(t,e){throw new Error("expandable role is not implemented yet")},heading:(t,e)=>(e.disabled="",e.indicator=[e.indicator," "].find(t=>null!=t),e.message=e.message||"",e),input(t,e){throw new Error("input role is not implemented yet")},option:(t,i)=>e.default(t,i),radio(t,e){throw new Error("radio role is not implemented yet")},separator:(t,e)=>(e.disabled="",e.indicator=[e.indicator," "].find(t=>null!=t),e.message=e.message||t.symbols.line.repeat(5),e),spacer:(t,e)=>e};return le=(i,s={})=>{let r=t.merge({},e,s.roles);return r[i]||r.default}}(),s=Ot,{reorder:r,scrollUp:n,scrollDown:o,isObject:a,swap:l}=s;function c(t,e){if(e instanceof Promise)return e;if("function"==typeof e){if(s.isAsyncFn(e))return e;e=e.call(t,t)}for(let i of e){if(Array.isArray(i.choices)){let e=i.choices.filter(e=>!t.isDisabled(e));i.enabled=e.every(t=>!0===t.enabled)}!0===t.isDisabled(i)&&delete i.enabled}return e}return he=class extends e{constructor(t){super(t),this.cursorHide(),this.maxSelected=t.maxSelected||1/0,this.multiple=t.multiple||!1,this.initial=t.initial||0,this.delay=t.delay||0,this.longest=0,this.num=""}async initialize(){"function"==typeof this.options.initial&&(this.initial=await this.options.initial.call(this)),await this.reset(!0),await super.initialize()}async reset(){let{choices:t,initial:e,autofocus:i,suggest:s}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(t)),this.choices.forEach(t=>t.enabled=!1),"function"!=typeof s&&0===this.selectable.length)throw new Error("At least one choice must be selectable");a(e)&&(e=Object.keys(e)),Array.isArray(e)?(null!=i&&(this.index=this.findIndex(i)),e.forEach(t=>this.enable(this.find(t))),await this.render()):(null!=i&&(e=i),"string"==typeof e&&(e=this.findIndex(e)),"number"==typeof e&&e>-1&&(this.index=Math.max(0,Math.min(e,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(t,e){this.state.loadingChoices=!0;let i=[],s=0,r=async(t,e)=>{"function"==typeof t&&(t=await t.call(this)),t instanceof Promise&&(t=await t);for(let n=0;n<t.length;n++){let o=t[n]=await this.toChoice(t[n],s++,e);i.push(o),o.choices&&await r(o.choices,o)}return i};return r(t,e).then(t=>(this.state.loadingChoices=!1,t))}async toChoice(e,r,n){if("function"==typeof e&&(e=await e.call(this,this)),e instanceof Promise&&(e=await e),"string"==typeof e&&(e={name:e}),e.normalized)return e;e.normalized=!0;let o=e.value,a=i(e.role,this.options);if("string"!=typeof(e=a(this,e)).disabled||e.hint||(e.hint=e.disabled,e.disabled=!0),!0===e.disabled&&null==e.hint&&(e.hint="(disabled)"),null!=e.index)return e;e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||"",e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input="",e.index=r,e.cursor=0,s.define(e,"parent",n),e.level=n?n.level+1:1,null==e.indent&&(e.indent=n?n.indent+" ":e.indent||""),e.path=n?n.path+"."+e.name:e.name,e.enabled=!(!this.multiple||this.isDisabled(e)||!e.enabled&&!this.isSelected(e)),this.isDisabled(e)||(this.longest=Math.max(this.longest,t(e.message).length));let l={...e};return e.reset=(t=l.input,i=l.value)=>{for(let t of Object.keys(l))e[t]=l[t];e.input=t,e.value=i},null==o&&"function"==typeof e.initial&&(e.input=await e.initial.call(this,this.state,e,r)),e}async onChoice(t,e){this.emit("choice",t,e,this),"function"==typeof t.onChoice&&await t.onChoice.call(this,this.state,t,e)}async addChoice(t,e,i){let s=await this.toChoice(t,e,i);return this.choices.push(s),this.index=this.choices.length-1,this.limit=this.choices.length,s}async newItem(t,e,i){let s={name:"New choice name?",editable:!0,newChoice:!0,...t},r=await this.addChoice(s,e,i);return r.updateChoice=()=>{delete r.newChoice,r.name=r.message=r.input,r.input="",r.cursor=0},this.render()}indent(t){return null==t.indent?t.level>1?" ".repeat(t.level-1):"":t.indent}dispatch(t,e){if(this.multiple&&this[e.name])return this[e.name]();this.alert()}focus(t,e){return"boolean"!=typeof e&&(e=t.enabled),e&&!t.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=t.index,t.enabled=e&&!this.isDisabled(t),t)}space(){return this.multiple?this.focused?(this.toggle(this.focused),this.render()):void 0:this.alert()}a(){if(this.maxSelected<this.choices.length)return this.alert();let t=this.selectable.every(t=>t.enabled);return this.choices.forEach(e=>e.enabled=!t),this.render()}i(){return this.choices.length-this.selected.length>this.maxSelected?this.alert():(this.choices.forEach(t=>t.enabled=!t.enabled),this.render())}g(){if(!this.choices.some(t=>!!t.parent))return this.a();const t=this.focused;return this.toggle(t.parent&&!t.choices?t.parent:t),this.render()}toggle(t,e){if(!t.enabled&&this.selected.length>=this.maxSelected)return this.alert();"boolean"!=typeof e&&(e=!t.enabled),t.enabled=e,t.choices&&t.choices.forEach(t=>this.toggle(t,e));let i=t.parent;for(;i;){let t=i.choices.filter(t=>this.isDisabled(t));i.enabled=t.every(t=>!0===t.enabled),i=i.parent}return c(this,this.choices),this.emit("toggle",t,this),t}enable(t){return this.selected.length>=this.maxSelected?this.alert():(t.enabled=!this.isDisabled(t),t.choices&&t.choices.forEach(this.enable.bind(this)),t)}disable(t){return t.enabled=!1,t.choices&&t.choices.forEach(this.disable.bind(this)),t}number(t){this.num+=t;let e=t=>{let e=Number(t);if(e>this.choices.length-1)return this.alert();let i=this.focused,s=this.choices.find(t=>e===t.index);if(!s.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(-1===this.visible.indexOf(s)){let t=r(this.choices),e=t.indexOf(s);if(i.index>e){let i=t.slice(e,e+this.limit),s=t.filter(t=>!i.includes(t));this.choices=i.concat(s)}else{let i=e-this.limit+1;this.choices=t.slice(i).concat(t.slice(0,i))}}return this.index=this.choices.indexOf(s),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(t=>{let i=this.choices.length,s=this.num,r=(i=!1,r)=>{clearTimeout(this.numberTimeout),i&&(r=e(s)),this.num="",t(r)};return"0"===s||1===s.length&&Number(s+"0")>i?r(!0):Number(s)>i?r(!1,this.alert()):void(this.numberTimeout=setTimeout(()=>r(!0),this.delay))})}home(){return this.choices=r(this.choices),this.index=0,this.render()}end(){let t=this.choices.length-this.limit,e=r(this.choices);return this.choices=e.slice(t).concat(e.slice(0,t)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){return this.visible.length<=1?this.alert():this.up()}next(){return this.visible.length<=1?this.alert():this.down()}right(){return this.cursor>=this.input.length?this.alert():(this.cursor++,this.render())}left(){return this.cursor<=0?this.alert():(this.cursor--,this.render())}up(){let t=this.choices.length,e=this.visible.length,i=this.index;return!1===this.options.scroll&&0===i?this.alert():t>e&&0===i?this.scrollUp():(this.index=(i-1%t+t)%t,this.isDisabled()&&!this.allChoicesAreDisabled()?this.up():this.render())}down(){let t=this.choices.length,e=this.visible.length,i=this.index;return!1===this.options.scroll&&i===e-1?this.alert():t>e&&i===e-1?this.scrollDown():(this.index=(i+1)%t,this.isDisabled()&&!this.allChoicesAreDisabled()?this.down():this.render())}scrollUp(t=0){return this.choices=n(this.choices),this.index=t,this.isDisabled()?this.up():this.render()}scrollDown(t=this.visible.length-1){return this.choices=o(this.choices),this.index=t,this.isDisabled()?this.down():this.render()}async shiftUp(){return!0===this.options.sort?(this.sorting=!0,this.swap(this.index-1),await this.up(),void(this.sorting=!1)):this.scrollUp(this.index)}async shiftDown(){return!0===this.options.sort?(this.sorting=!0,this.swap(this.index+1),await this.down(),void(this.sorting=!1)):this.scrollDown(this.index)}pageUp(){return this.visible.length<=1?this.alert():(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled()?this.up():this.render())}pageDown(){return this.visible.length>=this.choices.length?this.alert():(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled()?this.down():this.render())}swap(t){l(this.choices,this.index,t)}allChoicesAreDisabled(t=this.choices){return t.every(t=>this.isDisabled(t))}isDisabled(t=this.focused){return!(!t||!["disabled","collapsed","hidden","completing","readonly"].some(e=>!0===t[e]))||t&&"heading"===t.role}isEnabled(t=this.focused){if(Array.isArray(t))return t.every(t=>this.isEnabled(t));if(t.choices){let e=t.choices.filter(t=>!this.isDisabled(t));return t.enabled&&e.every(t=>this.isEnabled(t))}return t.enabled&&!this.isDisabled(t)}isChoice(t,e){return t.name===e||t.index===Number(e)}isSelected(t){return Array.isArray(this.initial)?this.initial.some(e=>this.isChoice(t,e)):this.isChoice(t,this.initial)}map(t=[],e="value"){return[].concat(t||[]).reduce((t,i)=>(t[i]=this.find(i,e),t),{})}filter(t,e){let i="function"==typeof t?t:(e,i)=>[e.name,i].includes(t),s=(this.options.multiple?this.state._choices:this.choices).filter(i);return e?s.map(t=>t[e]):s}find(t,e){if(a(t))return e?t[e]:t;let i="function"==typeof t?t:(e,i)=>[e.name,i].includes(t),s=this.choices.find(i);return s?e?s[e]:s:void 0}findIndex(t){return this.choices.indexOf(this.find(t))}async submit(){let t=this.focused;if(!t)return this.alert();if(t.newChoice)return t.input?(t.updateChoice(),this.render()):this.alert();if(this.choices.some(t=>t.newChoice))return this.alert();let{reorder:e,sort:i}=this.options,r=!0===this.multiple,n=this.selected;return void 0===n?this.alert():(Array.isArray(n)&&!1!==e&&!0!==i&&(n=s.reorder(n)),this.value=r?n.map(t=>t.name):n.name,super.submit())}set choices(t=[]){this.state._choices=this.state._choices||[],this.state.choices=t;for(let e of t)this.state._choices.some(t=>t.name===e.name)||this.state._choices.push(e);if(!this._initial&&this.options.initial){this._initial=!0;let t=this.initial;if("string"==typeof t||"number"==typeof t){let e=this.find(t);e&&(this.initial=e.index,this.focus(e,!0))}}}get choices(){return c(this,this.state.choices||[])}set visible(t){this.state.visible=t}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(t){this.state.limit=t}get limit(){let{state:t,options:e,choices:i}=this,s=t.limit||this._limit||e.limit||i.length;return Math.min(s,this.height)}set value(t){super.value=t}get value(){return"string"!=typeof super.value&&super.value===this.initial?this.input:super.value}set index(t){this.state.index=t}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let t=this.choices[this.index];return t&&this.state.submitted&&!0!==this.multiple&&(t.enabled=!0),t}get selectable(){return this.choices.filter(t=>!this.isDisabled(t))}get selected(){return this.multiple?this.enabled:this.focused}},he}function fi(){if(de)return pe;de=1;const t=mi(),e=Ot;return pe=class extends t{constructor(t){super(t),this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(t,e){if(this.multiple)return this[e.name]?await this[e.name](t,e):await super.dispatch(t,e);this.alert()}separator(){if(this.options.separator)return super.separator();let t=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():t}pointer(t,e){return!this.multiple||this.options.pointer?super.pointer(t,e):""}indicator(t,e){return this.multiple?super.indicator(t,e):""}choiceMessage(t,i){let s=this.resolve(t.message,this.state,t,i);return"heading"!==t.role||e.hasColor(s)||(s=this.styles.strong(s)),this.resolve(s,this.state,t,i)}choiceSeparator(){return":"}async renderChoice(t,i){await this.onChoice(t,i);let s=this.index===i,r=await this.pointer(t,i),n=await this.indicator(t,i)+(t.pad||""),o=await this.resolve(t.hint,this.state,t,i);o&&!e.hasColor(o)&&(o=this.styles.muted(o));let a=this.indent(t),l=await this.choiceMessage(t,i),c=()=>[this.margin[3],a+r+n,l,this.margin[1],o].filter(Boolean).join(" ");return"heading"===t.role?c():t.disabled?(e.hasColor(l)||(l=this.styles.disabled(l)),c()):(s&&(l=this.styles.em(l)),c())}async renderChoices(){if("choices"===this.state.loading)return this.styles.warning("Loading choices");if(this.state.submitted)return"";let t=this.visible.map(async(t,e)=>await this.renderChoice(t,e)),e=await Promise.all(t);e.length||e.push(this.styles.danger("No matching choices"));let i,s=this.margin[0]+e.join("\n");return this.options.choicesHeader&&(i=await this.resolve(this.options.choicesHeader,this.state)),[i,s].filter(Boolean).join("\n")}format(){return!this.state.submitted||this.state.cancelled?"":Array.isArray(this.selected)?this.selected.map(t=>this.styles.primary(t.name)).join(", "):this.styles.primary(this.selected.name)}async render(){let{submitted:t,size:e}=this.state,i="",s=await this.header(),r=await this.prefix(),n=await this.separator(),o=await this.message();!1!==this.options.promptLine&&(i=[r,o,n,""].join(" "),this.state.prompt=i);let a=await this.format(),l=await this.error()||await this.hint(),c=await this.renderChoices(),h=await this.footer();a&&(i+=a),l&&!i.includes(l)&&(i+=" "+l),t&&!a&&!c.trim()&&this.multiple&&null!=this.emptyError&&(i+=this.styles.danger(this.emptyError)),this.clear(e),this.write([s,i,c,h].filter(Boolean).join("\n")),this.write(this.margin[2]),this.restore()}},pe}function gi(){if(fe)return me;fe=1;const t=fi();return me=class extends t{constructor(t){super(t),this.cursorShow()}moveCursor(t){this.state.cursor+=t}dispatch(t){return this.append(t)}space(t){return this.options.multiple?super.space(t):this.append(t)}append(t){let{cursor:e,input:i}=this.state;return this.input=i.slice(0,e)+t+i.slice(e),this.moveCursor(1),this.complete()}delete(){let{cursor:t,input:e}=this.state;return e?(this.input=e.slice(0,t-1)+e.slice(t),this.moveCursor(-1),this.complete()):this.alert()}deleteForward(){let{cursor:t,input:e}=this.state;return void 0===e[t]?this.alert():(this.input=`${e}`.slice(0,t)+`${e}`.slice(t+1),this.complete())}number(t){return this.append(t)}async complete(){this.completing=!0,this.choices=await this.suggest(this.input,this.state._choices),this.state.limit=void 0,this.index=Math.min(Math.max(this.visible.length-1,0),this.index),await this.render(),this.completing=!1}suggest(t=this.input,e=this.state._choices){if("function"==typeof this.options.suggest)return this.options.suggest.call(this,t,e);let i=t.toLowerCase();return e.filter(t=>t.message.toLowerCase().includes(i))}pointer(){return""}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map(t=>this.styles.primary(t.message)).join(", ");if(this.state.submitted){let t=this.value=this.input=this.focused.value;return this.styles.primary(t)}return this.input}async render(){if("pending"!==this.state.status)return super.render();const t=this.options.highlight||this.styles.complement,e=((t,e)=>{const i=t?new RegExp(t,"ig"):/$^/;return s=>t?s.replace(i,t=>e(t)):s})(this.input,(e,i)=>e?t.stack?t(e):t.call(this,e):e),i=this.choices;this.choices=i.map(t=>({...t,message:e(t.message)})),await super.render(),this.choices=i}submit(){return this.options.multiple&&(this.value=this.selected.map(t=>t.name)),super.submit()}},me}function yi(){if(ye)return ge;ye=1;const t=Ot;return ge=(e,i={})=>{e.cursorHide();let{input:s="",initial:r="",pos:n,showCursor:o=!0,color:a}=i,l=a||e.styles.placeholder,c=t.inverse(e.styles.primary),h=t=>c(e.styles.black(t)),u=s,p=h(" ");if(e.blink&&!0===e.blink.off&&(h=t=>t,p=""),o&&0===n&&""===r&&""===s)return h(" ");if(o&&0===n&&(s===r||""===s))return h(r[0])+l(r.slice(1));r=t.isPrimitive(r)?`${r}`:"",s=t.isPrimitive(s)?`${s}`:"";let d=r&&r.startsWith(s)&&r!==s,m=d?h(r[s.length]):p;if(n!==s.length&&!0===o&&(u=s.slice(0,n)+h(s[n])+s.slice(n+1),m=""),!1===o&&(m=""),d){let t=e.styles.unstyle(u+m);return u+m+l(r.slice(t.length))}return u+m},ge}function wi(){if(be)return we;be=1;const t=Ft(),e=fi(),i=yi();return we=class extends e{constructor(t){super({...t,multiple:!0}),this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find(t=>null!=t),this.emptyError="",this.values={}}async reset(t){return await super.reset(),!0===t&&(this._index=this.index),this.index=this._index,this.values={},this.choices.forEach(t=>t.reset&&t.reset()),this.render()}dispatch(t){return!!t&&this.append(t)}append(t){let e=this.focused;if(!e)return this.alert();let{cursor:i,input:s}=e;return e.value=e.input=s.slice(0,i)+t+s.slice(i),e.cursor++,this.render()}delete(){let t=this.focused;if(!t||t.cursor<=0)return this.alert();let{cursor:e,input:i}=t;return t.value=t.input=i.slice(0,e-1)+i.slice(e),t.cursor--,this.render()}deleteForward(){let t=this.focused;if(!t)return this.alert();let{cursor:e,input:i}=t;if(void 0===i[e])return this.alert();let s=`${i}`.slice(0,e)+`${i}`.slice(e+1);return t.value=t.input=s,this.render()}right(){let t=this.focused;return t?t.cursor>=t.input.length?this.alert():(t.cursor++,this.render()):this.alert()}left(){let t=this.focused;return t?t.cursor<=0?this.alert():(t.cursor--,this.render()):this.alert()}space(t,e){return this.dispatch(t,e)}number(t,e){return this.dispatch(t,e)}next(){let t=this.focused;if(!t)return this.alert();let{initial:e,input:i}=t;return e&&e.startsWith(i)&&i!==e?(t.value=t.input=e,t.cursor=t.value.length,this.render()):super.next()}prev(){let t=this.focused;return t?0===t.cursor?super.prev():(t.value=t.input="",t.cursor=0,this.render()):this.alert()}separator(){return""}format(t){return this.state.submitted?"":super.format(t)}pointer(){return""}indicator(t){return t.input?"⦿":"⊙"}async choiceSeparator(t,e){let i=await this.resolve(t.separator,this.state,t,e)||":";return i?" "+this.styles.disabled(i):""}async renderChoice(e,s){await this.onChoice(e,s);let{state:r,styles:n}=this,{cursor:o,initial:a="",name:l,input:c=""}=e,{muted:h,submitted:u,primary:p,danger:d}=n,m=this.index===s,f=e.validate||(()=>!0),g=await this.choiceSeparator(e,s),y=e.message;"right"===this.align&&(y=y.padStart(this.longest+1," ")),"left"===this.align&&(y=y.padEnd(this.longest+1," "));let w=this.values[l]=c||a,b=c?"success":"dark";!0!==await f.call(e,w,this.state)&&(b="danger");let v=(0,n[b])(await this.indicator(e,s))+(e.pad||""),_=this.indent(e),S=()=>[_,v,y+g,c].filter(Boolean).join(" ");if(r.submitted)return y=t(y),c=u(c),S();if(e.format)c=await e.format.call(this,c,e,s);else{let t=this.styles.muted;c=i(this,{input:c,initial:a,pos:o,showCursor:m,color:t})}return this.isValue(c)||(c=this.styles.muted(this.symbols.ellipsis)),e.result&&(this.values[l]=await e.result.call(this,w,e,s)),m&&(y=p(y)),e.error?c+=(c?" ":"")+d(e.error.trim()):e.hint&&(c+=(c?" ":"")+h(e.hint.trim())),S()}async submit(){return this.value=this.values,super.base.submit.call(this)}},we}function bi(){if(_e)return ve;_e=1;const t=wi(),e=()=>{throw new Error("expected prompt to have a custom authenticate method")},i=(s=e)=>class extends t{constructor(t){super(t)}async submit(){this.value=await s.call(this,this.values,this.state),super.base.submit.call(this)}static create(t){return i(t)}};return ve=i()}function vi(){if(Ce)return Oe;Ce=1;const t=ae(),{isPrimitive:e,hasColor:i}=Ot;return Oe=class extends t{constructor(t){super(t),this.cursorHide()}async initialize(){let t=await this.resolve(this.initial,this.state);this.input=await this.cast(t),await super.initialize()}dispatch(t){return this.isValue(t)?(this.input=t,this.submit()):this.alert()}format(t){let{styles:e,state:i}=this;return i.submitted?e.success(t):e.primary(t)}cast(t){return this.isTrue(t)}isTrue(t){return/^[ty1]/i.test(t)}isFalse(t){return/^[fn0]/i.test(t)}isValue(t){return e(t)&&(this.isTrue(t)||this.isFalse(t))}async hint(){if("pending"===this.state.status){let t=await this.element("hint");return i(t)?t:this.styles.muted(t)}}async render(){let{input:t,size:e}=this.state,i=await this.prefix(),s=await this.separator(),r=[i,await this.message(),this.styles.muted(this.default),s].filter(Boolean).join(" ");this.state.prompt=r;let n=await this.header(),o=this.value=this.cast(t),a=await this.format(o),l=await this.error()||await this.hint(),c=await this.footer();l&&!r.includes(l)&&(a+=" "+l),r+=" "+a,this.clear(e),this.write([n,r,c].filter(Boolean).join("\n")),this.restore()}set value(t){super.value=t}get value(){return this.cast(super.value)}},Oe}function _i(){if(De)return Pe;De=1;const t=ae(),e=Qt(),i=yi(),{isPrimitive:s}=Ot;return Pe=class extends t{constructor(t){super(t),this.initial=s(this.initial)?String(this.initial):"",this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[],this.keypressTimeout=void 0!==this.options.keypressTimeout?this.options.keypressTimeout:null}async keypress(t,i=(t?e(t,{}):{})){const s=Date.now(),r=s-this.lastKeypress;this.lastKeypress=s;const n="return"===i.name||"enter"===i.name;let o,a=this.state.prevKeypress;if(this.state.prevKeypress=i,null!=this.keypressTimeout&&n){if(r<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||"",this.state.multilineBuffer+=t,o=!0,a=null}return!(o||this.options.multiline&&n)||a&&"return"===a.name?super.keypress(t,i):this.append("\n",i)}moveCursor(t){this.cursor+=t}reset(){return this.input=this.value="",this.cursor=0,this.render()}dispatch(t,e){if(!t||e.ctrl||e.code)return this.alert();this.append(t)}append(t){let{cursor:e,input:i}=this.state;this.input=`${i}`.slice(0,e)+t+`${i}`.slice(e),this.moveCursor(String(t).length),this.render()}insert(t){this.append(t)}delete(){let{cursor:t,input:e}=this.state;if(t<=0)return this.alert();this.input=`${e}`.slice(0,t-1)+`${e}`.slice(t),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:t,input:e}=this.state;if(void 0===e[t])return this.alert();this.input=`${e}`.slice(0,t)+`${e}`.slice(t+1),this.render()}cutForward(){let t=this.cursor;if(this.input.length<=t)return this.alert();this.state.clipboard.push(this.input.slice(t)),this.input=this.input.slice(0,t),this.render()}cutLeft(){let t=this.cursor;if(0===t)return this.alert();let e=this.input.slice(0,t),i=this.input.slice(t),s=e.split(" ");this.state.clipboard.push(s.pop()),this.input=s.join(" "),this.cursor=this.input.length,this.input+=i,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){this.state.prevCursor?(this.cursor=this.state.prevCursor,this.state.prevCursor=0):(this.state.prevCursor=this.cursor,this.cursor=0),this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let t=null!=this.initial?String(this.initial):"";if(!t||!t.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){return this.cursor>=this.input.length?this.alert():(this.moveCursor(1),this.render())}left(){return this.cursor<=0?this.alert():(this.moveCursor(-1),this.render())}isValue(t){return!!t}async format(t=this.value){let e=await this.resolve(this.initial,this.state);return this.state.submitted?this.styles.submitted(t||e):i(this,{input:t,initial:e,pos:this.cursor})}async render(){let t=this.state.size,e=await this.prefix(),i=await this.separator(),s=[e,await this.message(),i].filter(Boolean).join(" ");this.state.prompt=s;let r=await this.header(),n=await this.format(),o=await this.error()||await this.hint(),a=await this.footer();o&&!n.includes(o)&&(n+=" "+o),s+=" "+n,this.clear(t),this.write([r,s,a].filter(Boolean).join("\n")),this.restore()}},Pe}function Si(){if(je)return Te;je=1;const t=t=>(t=>t.filter((e,i)=>t.lastIndexOf(e)===i))(t).filter(Boolean);return Te=(e,i={},s="")=>{let r,n,{past:o=[],present:a=""}=i;switch(e){case"prev":case"undo":return r=o.slice(0,o.length-1),n=o[o.length-1]||"",{past:t([s,...r]),present:n};case"next":case"redo":return r=o.slice(1),n=o[0]||"",{past:t([...r,s]),present:n};case"save":return{past:t([...o,s]),present:""};case"remove":return n=t(o.filter(t=>t!==s)),a="",n.length&&(a=n.pop()),{past:n,present:a};default:throw new Error(`Invalid action: "${e}"`)}}}function xi(){if(Fe)return Ne;Fe=1;const t=_i(),e=Si();return Ne=class extends t{constructor(t){super(t);let e=this.options.history;if(e&&e.store){let t=e.values||this.initial;this.autosave=!!e.autosave,this.store=e.store,this.data=this.store.get("values")||{past:[],present:t},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(t){return this.store?(this.data=e(t,this.data,this.input),this.data.present?(this.input=this.data.present,this.cursor=this.input.length,this.render()):this.alert()):this.alert()}altUp(){return this.completion("prev")}altDown(){return this.completion("next")}prev(){return this.save(),super.prev()}save(){this.store&&(this.data=e("save",this.data,this.input),this.store.set("values",this.data))}submit(){return this.store&&!0===this.autosave&&this.save(),super.submit()}}}function Oi(){if(Be)return We;Be=1;const t=_i();return We=class extends t{constructor(t={}){super({style:"number",...t}),this.min=this.isValue(t.min)?this.toNumber(t.min):-1/0,this.max=this.isValue(t.max)?this.toNumber(t.max):1/0,this.delay=null!=t.delay?t.delay:1e3,this.float=!1!==t.float,this.round=!0===t.round||!1===t.float,this.major=t.major||10,this.minor=t.minor||1,this.initial=null!=t.initial?t.initial:"",this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(t){return!/[-+.]/.test(t)||"."===t&&this.input.includes(".")?this.alert("invalid number"):super.append(t)}number(t){return super.append(t)}next(){return this.input&&this.input!==this.initial?this.alert():this.isValue(this.initial)?(this.input=this.initial,this.cursor=String(this.initial).length,this.render()):this.alert()}up(t){let e=t||this.minor,i=this.toNumber(this.input);return i>this.max+e?this.alert():(this.input=`${i+e}`,this.render())}down(t){let e=t||this.minor,i=this.toNumber(this.input);return i<this.min-e?this.alert():(this.input=""+(i-e),this.render())}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(t=this.input){return"function"==typeof this.options.format?this.options.format.call(this,t):this.styles.info(t)}toNumber(t=""){return this.float?+t:Math.round(+t)}isValue(t){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(t)}submit(){let t=[this.input,this.initial].find(t=>this.isValue(t));return this.value=this.toNumber(t||0),super.submit()}},We}function Ci(){if(Ze)return Ye;Ze=1;const t=Ft();class e{constructor(t){this.name=t.key,this.field=t.field||{},this.value=((t="")=>"string"==typeof t?t.replace(/^['"]|['"]$/g,""):"")(t.initial||this.field.initial||""),this.message=t.message||this.name,this.cursor=0,this.input="",this.lines=[]}}function i(t,e,i,s){return(i,r,n,o)=>"function"==typeof n.field[t]?n.field[t].call(e,i,r,n,o):[s,i].find(t=>e.isValue(t))}return Ye=async s=>{let r=s.options,n=new Set(!0===r.required?[]:r.required||[]),o={...r.values,...r.initial},{tabstops:a,items:l,keys:c}=await(async(t={},i={},s=t=>t)=>{let r=new Set,n=t.fields||[],o=t.template,a=[],l=[],c=[],h=1;"function"==typeof o&&(o=await o());let u=-1,p=()=>o[++u],d=()=>o[u+1],m=t=>{t.line=h,a.push(t)};for(m({type:"bos",value:""});u<o.length-1;){let t=p();if(/^[^\S\n ]$/.test(t)){m({type:"text",value:t});continue}if("\n"===t){m({type:"newline",value:t}),h++;continue}if("\\"===t){t+=p(),m({type:"text",value:t});continue}if(("$"===t||"#"===t||"{"===t)&&"{"===d()){t+=p();let o,a={type:"template",open:t,inner:"",close:"",value:t};for(;o=p();){if("}"===o){"}"===d()&&(o+=p()),a.value+=o,a.close=o;break}":"===o?(a.initial="",a.key=a.inner):void 0!==a.initial&&(a.initial+=o),a.value+=o,a.inner+=o}a.template=a.open+(a.initial||a.inner)+a.close,a.key=a.key||a.inner,hasOwnProperty.call(i,a.key)&&(a.initial=i[a.key]),a=s(a),m(a),c.push(a.key),r.add(a.key);let h=l.find(t=>t.name===a.key);a.field=n.find(t=>t.name===a.key),h||(h=new e(a),l.push(h)),h.lines.push(a.line-1);continue}let o=a[a.length-1];"text"===o.type&&o.line===h?o.value+=t:m({type:"text",value:t})}return m({type:"eos",value:""}),{input:o,tabstops:a,unique:r,keys:c,items:l}})(r,o),h=i("result",s),u=i("format",s),p=i("validate",s,r,!0),d=s.isValue.bind(s);return async(e={},i=!1)=>{let o=0;e.required=n,e.items=l,e.keys=c,e.output="";let m=async(t,e,i,s)=>{let r=await p(t,e,i,s);return!1===r?"Invalid field "+i.name:r};for(let n of a){let a=n.value,c=n.key;if("template"===n.type){if("template"===n.type){let p=l.find(t=>t.name===c);!0===r.required&&e.required.add(p.name);let f=[p.input,e.values[p.value],p.value,a].find(d),g=(p.field||{}).message||n.inner;if(i){let i=await m(e.values[c],e,p,o);if(i&&"string"==typeof i||!1===i){e.invalid.set(c,i);continue}e.invalid.delete(c);let s=await h(e.values[c],e,p,o);e.output+=t(s);continue}p.placeholder=!1;let y=a;a=await u(a,e,p,o),f!==a?(e.values[c]=f,a=s.styles.typing(f),e.missing.delete(g)):(e.values[c]=void 0,f=`<${g}>`,a=s.styles.primary(f),p.placeholder=!0,e.required.has(c)&&e.missing.add(g)),e.missing.has(g)&&e.validating&&(a=s.styles.warning(f)),e.invalid.has(c)&&e.validating&&(a=s.styles.danger(f)),o===e.index&&(a=y!==a?s.styles.underline(a):s.styles.heading(t(a))),o++}a&&(e.output+=a)}else a&&(e.output+=a)}let f=e.output.split("\n").map(t=>" "+t),g=l.length,y=0;for(let t of l)e.invalid.has(t.name)&&t.lines.forEach(t=>{" "===f[t][0]&&(f[t]=e.styles.danger(e.symbols.bullet)+f[t].slice(1))}),s.isValue(e.values[t.name])&&y++;return e.completed=(y/g*100).toFixed(0),e.output=f.join("\n"),e.output}},Ye}function ki(){if(si)return ii;si=1;const t=mi();function e(t,e={}){if(Array.isArray(e.scale))return e.scale.map(t=>({...t}));let i=[];for(let e=1;e<t+1;e++)i.push({i:e,selected:!1});return i}return ii=class extends t{constructor(t={}){if(super(t),this.emptyError=t.emptyError||"No items were selected",this.term=process.env.TERM_PROGRAM,!this.options.header){let t=["","4 - Strongly Agree","3 - Agree","2 - Neutral","1 - Disagree","0 - Strongly Disagree",""];t=t.map(t=>this.styles.muted(t)),this.state.header=t.join("\n ")}}async toChoices(...t){if(this.createdScales)return!1;this.createdScales=!0;let i=await super.toChoices(...t);for(let t of i)t.scale=e(5,this.options),t.scaleIdx=2;return i}dispatch(){this.alert()}space(){let t=this.focused,e=t.scale[t.scaleIdx],i=e.selected;return t.scale.forEach(t=>t.selected=!1),e.selected=!i,this.render()}indicator(){return""}pointer(){return""}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let t=this.focused;return t.scaleIdx>=t.scale.length-1?this.alert():(t.scaleIdx++,this.render())}left(){let t=this.focused;return t.scaleIdx<=0?this.alert():(t.scaleIdx--,this.render())}indent(){return" "}async renderChoice(t,e){await this.onChoice(t,e);let i=this.index===e,s="Hyper"===this.term,r=s?9:8,n=s?"":" ",o=this.symbols.line.repeat(r),a=" ".repeat(r+(s?0:1)),l=t=>(t?this.styles.success("◉"):"◯")+n,c=e+1+".",h=i?this.styles.heading:this.styles.noop,u=await this.resolve(t.message,this.state,t,e),p=this.indent(t),d=p+t.scale.map((e,i)=>l(i===t.scaleIdx)).join(o),m=p+t.scale.map((e,i)=>(e=>e===t.scaleIdx?h(e):e)(i)).join(a);return i&&(d=this.styles.cyan(d),m=this.styles.cyan(m)),[[c,u].filter(Boolean).join(" "),d,m," "].filter(Boolean).join("\n")}async renderChoices(){if(this.state.submitted)return"";let t=this.visible.map(async(t,e)=>await this.renderChoice(t,e)),e=await Promise.all(t);return e.length||e.push(this.styles.danger("No matching choices")),e.join("\n")}format(){if(this.state.submitted){return this.choices.map(t=>this.styles.info(t.scaleIdx)).join(", ")}return""}async render(){let{submitted:t,size:e}=this.state,i=await this.prefix(),s=await this.separator(),r=[i,await this.message(),s].filter(Boolean).join(" ");this.state.prompt=r;let n=await this.header(),o=await this.format(),a=await this.error()||await this.hint(),l=await this.renderChoices(),c=await this.footer();!o&&a||(r+=" "+o),a&&!r.includes(a)&&(r+=" "+a),t&&!o&&!l&&this.multiple&&"form"!==this.type&&(r+=this.styles.danger(this.emptyError)),this.clear(e),this.write([r,n,l,c].filter(Boolean).join("\n")),this.restore()}submit(){this.value={};for(let t of this.choices)this.value[t.name]=t.scaleIdx;return this.base.submit.call(this)}},ii}function Ei(){return hi||(hi=1,function(t){const e=Ot,i=(i,s)=>{e.defineExport(t,i,s),e.defineExport(t,i.toLowerCase(),s)};i("AutoComplete",()=>gi()),i("BasicAuth",()=>function(){if(xe)return Se;xe=1;const t=bi();function e(t,e){return t.username===this.options.username&&t.password===this.options.password}const i=(s=e)=>{const r=[{name:"username",message:"username"},{name:"password",message:"password",format(t){return this.options.showPassword?t:(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(t.length))}}];class n extends(t.create(s)){constructor(t){super({...t,choices:r})}static create(t){return i(t)}}return n};return Se=i()}()),i("Confirm",()=>function(){if(Ee)return ke;Ee=1;const t=vi();return ke=class extends t{constructor(t){super(t),this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}}}()),i("Editable",()=>function(){if($e)return Ae;$e=1;const t=fi(),e=wi().prototype;return Ae=class extends t{constructor(t){super({...t,multiple:!0}),this.align=[this.options.align,"left"].find(t=>null!=t),this.emptyError="",this.values={}}dispatch(t,i){let s=this.focused,r=s.parent||{};return s.editable||r.editable||"a"!==t&&"i"!==t?e.dispatch.call(this,t,i):super[t]()}append(t,i){return e.append.call(this,t,i)}delete(t,i){return e.delete.call(this,t,i)}space(t){return this.focused.editable?this.append(t):super.space()}number(t){return this.focused.editable?this.append(t):super.number(t)}next(){return this.focused.editable?e.next.call(this):super.next()}prev(){return this.focused.editable?e.prev.call(this):super.prev()}async indicator(t,e){let i=t.indicator||"",s=t.editable?i:super.indicator(t,e);return await this.resolve(s,this.state,t,e)||""}indent(t){return"heading"===t.role?"":t.editable?" ":" "}async renderChoice(t,i){return t.indent="",t.editable?e.renderChoice.call(this,t,i):super.renderChoice(t,i)}error(){return""}footer(){return this.state.error}async validate(){let t=!0;for(let e of this.choices){if("function"!=typeof e.validate)continue;if("heading"===e.role)continue;let i=e.parent?this.value[e.parent.name]:this.value;if(e.editable?i=e.value===e.name?e.initial||"":e.value:this.isDisabled(e)||(i=!0===e.enabled),t=await e.validate(i,this.state),!0!==t)break}return!0!==t&&(this.state.error="string"==typeof t?t:"Invalid Input"),t}submit(){if(!0===this.focused.newChoice)return super.submit();if(this.choices.some(t=>t.newChoice))return this.alert();this.value={};for(let t of this.choices){let e=t.parent?this.value[t.parent.name]:this.value;"heading"!==t.role?t.editable?e[t.name]=t.value===t.name?t.initial||"":t.value:this.isDisabled(t)||(e[t.name]=!0===t.enabled):this.value[t.name]={}}return this.base.submit.call(this)}}}()),i("Form",()=>wi()),i("Input",()=>xi()),i("Invisible",()=>function(){if(Le)return Ie;Le=1;const t=_i();return Ie=class extends t{format(){return""}}}()),i("List",()=>function(){if(Ve)return Re;Ve=1;const t=_i();return Re=class extends t{constructor(t={}){super(t),this.sep=this.options.separator||/, */,this.initial=t.initial||""}split(t=this.value){return t?String(t).split(this.sep):[]}format(){let t=this.state.submitted?this.styles.primary:t=>t;return this.list.map(t).join(", ")}async submit(t){let e=this.state.error||await this.validate(this.list,this.state);return!0!==e?(this.state.error=e,super.submit()):(this.value=this.list,super.submit())}get list(){return this.split()}},Re}()),i("MultiSelect",()=>function(){if(He)return Me;He=1;const t=fi();return Me=class extends t{constructor(t){super({...t,multiple:!0})}}}()),i("Numeral",()=>Ue?qe:(Ue=1,qe=Oi())),i("Password",()=>function(){if(Je)return ze;Je=1;const t=_i();return ze=class extends t{constructor(t){super(t),this.cursorShow()}format(t=this.input){return this.keypressed?(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(t.length)):""}},ze}()),i("Scale",()=>function(){if(Ke)return Ge;Ke=1;const t=Ft(),e=mi(),i=Ot;return Ge=class extends e{constructor(t={}){super(t),this.widths=[].concat(t.messageWidth||50),this.align=[].concat(t.align||"left"),this.linebreak=t.linebreak||!1,this.edgeLength=t.edgeLength||3,this.newline=t.newline||"\n ";let e=t.startNumber||1;"number"==typeof this.scale&&(this.scaleKey=!1,this.scale=Array(this.scale).fill(0).map((t,i)=>({name:i+e})))}async reset(){return this.tableized=!1,await super.reset(),this.render()}tableize(){if(!0===this.tableized)return;this.tableized=!0;let t=0;for(let e of this.choices){t=Math.max(t,e.message.length),e.scaleIndex=e.initial||2,e.scale=[];for(let t=0;t<this.scale.length;t++)e.scale.push({index:t})}this.widths[0]=Math.min(this.widths[0],t+3)}async dispatch(t,e){if(this.multiple)return this[e.name]?await this[e.name](t,e):await super.dispatch(t,e);this.alert()}heading(t,e,i){return this.styles.strong(t)}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let t=this.focused;return t.scaleIndex>=this.scale.length-1?this.alert():(t.scaleIndex++,this.render())}left(){let t=this.focused;return t.scaleIndex<=0?this.alert():(t.scaleIndex--,this.render())}indent(){return""}format(){return this.state.submitted?this.choices.map(t=>this.styles.info(t.index)).join(", "):""}pointer(){return""}renderScaleKey(){return!1===this.scaleKey||this.state.submitted?"":["",...this.scale.map(t=>` ${t.name} - ${t.message}`)].map(t=>this.styles.muted(t)).join("\n")}renderScaleHeading(t){let e=this.scale.map(t=>t.name);"function"==typeof this.options.renderScaleHeading&&(e=this.options.renderScaleHeading.call(this,t));let i=this.scaleLength-e.join("").length,s=Math.round(i/(e.length-1)),r=e.map(t=>this.styles.strong(t)).join(" ".repeat(s)),n=" ".repeat(this.widths[0]);return this.margin[3]+n+this.margin[1]+r}scaleIndicator(t,e,i){if("function"==typeof this.options.scaleIndicator)return this.options.scaleIndicator.call(this,t,e,i);let s=t.scaleIndex===e.index;return e.disabled?this.styles.hint(this.symbols.radio.disabled):s?this.styles.success(this.symbols.radio.on):this.symbols.radio.off}renderScale(t,e){let i=t.scale.map(i=>this.scaleIndicator(t,i,e)),s="Hyper"===this.term?"":" ";return i.join(s+this.symbols.line.repeat(this.edgeLength))}async renderChoice(e,s){await this.onChoice(e,s);let r=this.index===s,n=await this.pointer(e,s),o=await e.hint;o&&!i.hasColor(o)&&(o=this.styles.muted(o));let a=t=>this.margin[3]+t.replace(/\s+$/,"").padEnd(this.widths[0]," "),l=this.newline,c=this.indent(e),h=await this.resolve(e.message,this.state,e,s),u=await this.renderScale(e,s),p=this.margin[1]+this.margin[3];this.scaleLength=t(u).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-p.length);let d=i.wordWrap(h,{width:this.widths[0],newline:l}).split("\n").map(t=>a(t)+this.margin[1]);return r&&(u=this.styles.info(u),d=d.map(t=>this.styles.info(t))),d[0]+=u,this.linebreak&&d.push(""),[c+n,d.join("\n")].filter(Boolean)}async renderChoices(){if(this.state.submitted)return"";this.tableize();let t=this.visible.map(async(t,e)=>await this.renderChoice(t,e)),e=await Promise.all(t),i=await this.renderScaleHeading();return this.margin[0]+[i,...e.map(t=>t.join(" "))].join("\n")}async render(){let{submitted:t,size:e}=this.state,i=await this.prefix(),s=await this.separator(),r=await this.message(),n="";!1!==this.options.promptLine&&(n=[i,r,s,""].join(" "),this.state.prompt=n);let o=await this.header(),a=await this.format(),l=await this.renderScaleKey(),c=await this.error()||await this.hint(),h=await this.renderChoices(),u=await this.footer(),p=this.emptyError;a&&(n+=a),c&&!n.includes(c)&&(n+=" "+c),t&&!a&&!h.trim()&&this.multiple&&null!=p&&(n+=this.styles.danger(p)),this.clear(e),this.write([o,n,l,h,u].filter(Boolean).join("\n")),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let t of this.choices)this.value[t.name]=t.scaleIndex;return this.base.submit.call(this)}},Ge}()),i("Select",()=>fi()),i("Snippet",()=>function(){if(Qe)return Xe;Qe=1;const t=Ft(),e=Ci(),i=ae();return Xe=class extends i{constructor(t){super(t),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await e(this),await super.initialize()}async reset(t){this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},!0!==t&&(await this.initialize(),await this.render())}moveCursor(t){let e=this.getItem();this.cursor+=t,e.cursor+=t}dispatch(t,e){e.code||e.ctrl||null==t||!this.getItem()?this.alert():this.append(t,e)}append(t,e){let i=this.getItem(),s=i.input.slice(0,this.cursor),r=i.input.slice(this.cursor);this.input=i.input=`${s}${t}${r}`,this.moveCursor(1),this.render()}delete(){let t=this.getItem();if(this.cursor<=0||!t.input)return this.alert();let e=t.input.slice(this.cursor),i=t.input.slice(0,this.cursor-1);this.input=t.input=`${i}${e}`,this.moveCursor(-1),this.render()}increment(t){return t>=this.state.keys.length-1?0:t+1}decrement(t){return t<=0?this.state.keys.length-1:t-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(t){let e=this.state.completed<100?this.styles.warning:this.styles.success;return!0===this.state.submitted&&100!==this.state.completed&&(e=this.styles.danger),e(`${this.state.completed}% completed`)}async render(){let{index:t,keys:e=[],submitted:i,size:s}=this.state,r=[this.options.newline,"\n"].find(t=>null!=t),n=await this.prefix(),o=await this.separator(),a=[n,await this.message(),o].filter(Boolean).join(" ");this.state.prompt=a;let l=await this.header(),c=await this.error()||"",h=await this.hint()||"",u=i?"":await this.interpolate(this.state),p=this.state.key=e[t]||"",d=await this.format(p),m=await this.footer();d&&(a+=" "+d),h&&!d&&0===this.state.completed&&(a+=" "+h),this.clear(s);let f=[l,a,u,m,c.trim()];this.write(f.filter(Boolean).join(r)),this.restore()}getItem(t){let{items:e,keys:i,index:s}=this.state,r=e.find(t=>t.name===i[s]);return r&&null!=r.input&&(this.input=r.input,this.cursor=r.cursor),r}async submit(){"function"!=typeof this.interpolate&&await this.initialize(),await this.interpolate(this.state,!0);let{invalid:e,missing:i,output:s,values:r}=this.state;if(e.size){let t="";for(let[i,s]of e)t+=`Invalid ${i}: ${s}\n`;return this.state.error=t,super.submit()}if(i.size)return this.state.error="Required: "+[...i.keys()].join(", "),super.submit();let n=t(s).split("\n").map(t=>t.slice(1)).join("\n");return this.value={values:r,result:n},super.submit()}},Xe}()),i("Sort",()=>function(){if(ei)return ti;ei=1;const t="(Use <shift>+<up/down> to sort)",e=fi();return ti=class extends e{constructor(e){super({...e,reorder:!1,sort:!0,multiple:!0}),this.state.hint=[this.options.hint,t].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(t,e){let i=await super.renderChoice(t,e),s=this.symbols.identicalTo+" ",r=this.index===e&&this.sorting?this.styles.muted(s):" ";return!1===this.options.drag&&(r=""),!0===this.options.numbered?r+`${e+1} - `+i:r+i}get selected(){return this.choices}submit(){return this.value=this.choices.map(t=>t.value),super.submit()}}}()),i("Survey",()=>ki()),i("Text",()=>ni?ri:(ni=1,ri=xi())),i("Toggle",()=>function(){if(ai)return oi;ai=1;const t=vi();return oi=class extends t{async initialize(){await super.initialize(),this.value=this.initial=this.resolve(this.options.initial),this.disabled=this.options.disabled||"no",this.enabled=this.options.enabled||"yes",await this.render()}reset(){this.value=this.initial,this.render()}delete(){this.alert()}toggle(){this.value=!this.value,this.render()}enable(){if(!0===this.value)return this.alert();this.value=!0,this.render()}disable(){if(!1===this.value)return this.alert();this.value=!1,this.render()}up(){this.toggle()}down(){this.toggle()}right(){this.toggle()}left(){this.toggle()}next(){this.toggle()}prev(){this.toggle()}dispatch(t="",e){switch(t.toLowerCase()){case" ":return this.toggle();case"1":case"y":case"t":return this.enable();case"0":case"n":case"f":return this.disable();default:return this.alert()}}format(){let t=t=>this.styles.primary.underline(t);return[this.value?this.disabled:t(this.disabled),this.value?t(this.enabled):this.enabled].join(this.styles.muted(" / "))}async render(){let{size:t}=this.state,e=await this.header(),i=await this.prefix(),s=await this.separator(),r=await this.message(),n=await this.format(),o=await this.error()||await this.hint(),a=await this.footer(),l=[i,r,s,n].join(" ");this.state.prompt=l,o&&!l.includes(o)&&(l+=" "+o),this.clear(t),this.write([e,l,a].filter(Boolean).join("\n")),this.write(this.margin[2]),this.restore()}},oi}()),i("Quiz",()=>function(){if(ci)return li;ci=1;const t=fi();return li=class extends t{constructor(t){if(super(t),"number"!=typeof this.options.correctChoice||this.options.correctChoice<0)throw new Error("Please specify the index of the correct answer from the list of choices")}async toChoices(t,e){let i=await super.toChoices(t,e);if(i.length<2)throw new Error("Please give at least two choices to the user");if(this.options.correctChoice>i.length)throw new Error("Please specify the index of the correct answer from the list of choices");return i}check(t){return t.index===this.options.correctChoice}async result(t){return{selectedAnswer:t,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}},li}())}(di)),di}const Ai=h,$i=u,Pi=Ot;class Di extends $i{constructor(t,e){super(),this.options=Pi.merge({},t),this.answers={...e}}register(t,e){if(Pi.isObject(t)){for(let e of Object.keys(t))this.register(e,t[e]);return this}Ai.equal(typeof e,"function","expected a function");const i=t.toLowerCase();return e.prototype instanceof this.Prompt?this.prompts[i]=e:this.prompts[i]=e(this.Prompt,this),this}async prompt(t=[]){for(let e of[].concat(t))try{"function"==typeof e&&(e=await e.call(this)),await this.ask(Pi.merge({},this.options,e))}catch(t){return Promise.reject(t)}return this.answers}async ask(t){"function"==typeof t&&(t=await t.call(this));let e=Pi.merge({},this.options,t),{type:i,name:s}=t,{set:r,get:n}=Pi;if("function"==typeof i&&(i=await i.call(this,t,this.answers)),!i)return this.answers[s];"number"===i&&(i="numeral"),Ai(this.prompts[i],`Prompt "${i}" is not registered`);let o=new this.prompts[i](e),a=n(this.answers,s);o.state.answers=this.answers,o.enquirer=this,s&&o.on("submit",t=>{this.emit("answer",s,t,o),r(this.answers,s,t)});let l=o.emit.bind(o);return o.emit=(...t)=>(this.emit.call(this,...t),l(...t)),this.emit("prompt",o,this),e.autofill&&null!=a?(o.value=o.input=a,"show"===e.autofill&&await o.submit()):a=o.value=await o.run(),a}use(t){return t.call(this,this),this}set Prompt(t){this._Prompt=t}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(t){this._Prompt=t}static get Prompt(){return this._Prompt||ae()}static get prompts(){return Ei()}static get types(){return pi?ui:(pi=1,ui={ArrayPrompt:mi(),AuthPrompt:bi(),BooleanPrompt:vi(),NumberPrompt:Oi(),StringPrompt:_i()})}static get prompt(){const t=(e,...i)=>{let s=new this(...i),r=s.emit.bind(s);return s.emit=(...e)=>(t.emit(...e),r(...e)),s.prompt(e)};return Pi.mixinEmitter(t,new $i),t}}Pi.mixinEmitter(Di,new $i);const Ti=Di.prompts;for(let t of Object.keys(Ti)){let e=t.toLowerCase(),i=e=>new Ti[t](e).run();Di.prompt[e]=i,Di[e]=i,Di[t]||Reflect.defineProperty(Di,t,{get:()=>Ti[t]})}const ji=t=>{Pi.defineExport(Di,t,()=>Di.types[t])};ji("ArrayPrompt"),ji("AuthPrompt"),ji("BooleanPrompt"),ji("NumberPrompt"),ji("StringPrompt");var Ni=H(Di),Fi={},Ii={fromCallback:function(t){return Object.defineProperty(function(...e){if("function"!=typeof e[e.length-1])return new Promise((i,s)=>{e.push((t,e)=>null!=t?s(t):i(e)),t.apply(this,e)});t.apply(this,e)},"name",{value:t.name})},fromPromise:function(t){return Object.defineProperty(function(...e){const i=e[e.length-1];if("function"!=typeof i)return t.apply(this,e);e.pop(),t.apply(this,e).then(t=>i(null,t),i)},"name",{value:t.name})}},Li=$,Ri=process.cwd,Vi=null,Mi=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Vi||(Vi=Ri.call(process)),Vi};try{process.cwd()}catch(t){}if("function"==typeof process.chdir){var Hi=process.chdir;process.chdir=function(t){Vi=null,Hi.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Hi)}var Wi=function(t){Li.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(t){t.lchmod=function(e,i,s){t.open(e,Li.O_WRONLY|Li.O_SYMLINK,i,function(e,r){e?s&&s(e):t.fchmod(r,i,function(e){t.close(r,function(t){s&&s(e||t)})})})},t.lchmodSync=function(e,i){var s,r=t.openSync(e,Li.O_WRONLY|Li.O_SYMLINK,i),n=!0;try{s=t.fchmodSync(r,i),n=!1}finally{if(n)try{t.closeSync(r)}catch(t){}else t.closeSync(r)}return s}}(t);t.lutimes||function(t){Li.hasOwnProperty("O_SYMLINK")&&t.futimes?(t.lutimes=function(e,i,s,r){t.open(e,Li.O_SYMLINK,function(e,n){e?r&&r(e):t.futimes(n,i,s,function(e){t.close(n,function(t){r&&r(e||t)})})})},t.lutimesSync=function(e,i,s){var r,n=t.openSync(e,Li.O_SYMLINK),o=!0;try{r=t.futimesSync(n,i,s),o=!1}finally{if(o)try{t.closeSync(n)}catch(t){}else t.closeSync(n)}return r}):t.futimes&&(t.lutimes=function(t,e,i,s){s&&process.nextTick(s)},t.lutimesSync=function(){})}(t);t.chown=s(t.chown),t.fchown=s(t.fchown),t.lchown=s(t.lchown),t.chmod=e(t.chmod),t.fchmod=e(t.fchmod),t.lchmod=e(t.lchmod),t.chownSync=r(t.chownSync),t.fchownSync=r(t.fchownSync),t.lchownSync=r(t.lchownSync),t.chmodSync=i(t.chmodSync),t.fchmodSync=i(t.fchmodSync),t.lchmodSync=i(t.lchmodSync),t.stat=n(t.stat),t.fstat=n(t.fstat),t.lstat=n(t.lstat),t.statSync=o(t.statSync),t.fstatSync=o(t.fstatSync),t.lstatSync=o(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(t,e,i){i&&process.nextTick(i)},t.lchmodSync=function(){});t.chown&&!t.lchown&&(t.lchown=function(t,e,i,s){s&&process.nextTick(s)},t.lchownSync=function(){});"win32"===Mi&&(t.rename="function"!=typeof t.rename?t.rename:function(e){function i(i,s,r){var n=Date.now(),o=0;e(i,s,function a(l){if(l&&("EACCES"===l.code||"EPERM"===l.code||"EBUSY"===l.code)&&Date.now()-n<6e4)return setTimeout(function(){t.stat(s,function(t,n){t&&"ENOENT"===t.code?e(i,s,a):r(l)})},o),void(o<100&&(o+=10));r&&r(l)})}return Object.setPrototypeOf&&Object.setPrototypeOf(i,e),i}(t.rename));function e(e){return e?function(i,s,r){return e.call(t,i,s,function(t){a(t)&&(t=null),r&&r.apply(this,arguments)})}:e}function i(e){return e?function(i,s){try{return e.call(t,i,s)}catch(t){if(!a(t))throw t}}:e}function s(e){return e?function(i,s,r,n){return e.call(t,i,s,r,function(t){a(t)&&(t=null),n&&n.apply(this,arguments)})}:e}function r(e){return e?function(i,s,r){try{return e.call(t,i,s,r)}catch(t){if(!a(t))throw t}}:e}function n(e){return e?function(i,s,r){function n(t,e){e&&(e.uid<0&&(e.uid+=4294967296),e.gid<0&&(e.gid+=4294967296)),r&&r.apply(this,arguments)}return"function"==typeof s&&(r=s,s=null),s?e.call(t,i,s,n):e.call(t,i,n)}:e}function o(e){return e?function(i,s){var r=s?e.call(t,i,s):e.call(t,i);return r&&(r.uid<0&&(r.uid+=4294967296),r.gid<0&&(r.gid+=4294967296)),r}:e}function a(t){return!t||("ENOSYS"===t.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==t.code&&"EPERM"!==t.code))}t.read="function"!=typeof t.read?t.read:function(e){function i(i,s,r,n,o,a){var l;if(a&&"function"==typeof a){var c=0;l=function(h,u,p){if(h&&"EAGAIN"===h.code&&c<10)return c++,e.call(t,i,s,r,n,o,l);a.apply(this,arguments)}}return e.call(t,i,s,r,n,o,l)}return Object.setPrototypeOf&&Object.setPrototypeOf(i,e),i}(t.read),t.readSync="function"!=typeof t.readSync?t.readSync:(l=t.readSync,function(e,i,s,r,n){for(var o=0;;)try{return l.call(t,e,i,s,r,n)}catch(t){if("EAGAIN"===t.code&&o<10){o++;continue}throw t}});var l};var Bi=P.Stream,qi=function(t){return{ReadStream:function e(i,s){if(!(this instanceof e))return new e(i,s);Bi.call(this);var r=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,s=s||{};for(var n=Object.keys(s),o=0,a=n.length;o<a;o++){var l=n[o];this[l]=s[l]}this.encoding&&this.setEncoding(this.encoding);if(void 0!==this.start){if("number"!=typeof this.start)throw TypeError("start must be a Number");if(void 0===this.end)this.end=1/0;else if("number"!=typeof this.end)throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(null!==this.fd)return void process.nextTick(function(){r._read()});t.open(this.path,this.flags,this.mode,function(t,e){if(t)return r.emit("error",t),void(r.readable=!1);r.fd=e,r.emit("open",e),r._read()})},WriteStream:function e(i,s){if(!(this instanceof e))return new e(i,s);Bi.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,s=s||{};for(var r=Object.keys(s),n=0,o=r.length;n<o;n++){var a=r[n];this[a]=s[a]}if(void 0!==this.start){if("number"!=typeof this.start)throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],null===this.fd&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}};var Ui=function(t){if(null===t||"object"!=typeof t)return t;if(t instanceof Object)var e={__proto__:zi(t)};else e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e},zi=Object.getPrototypeOf||function(t){return t.__proto__};var Ji,Gi,Ki=C,Yi=Wi,Zi=qi,Xi=Ui,Qi=D;function ts(t,e){Object.defineProperty(t,Ji,{get:function(){return e}})}"function"==typeof Symbol&&"function"==typeof Symbol.for?(Ji=Symbol.for("graceful-fs.queue"),Gi=Symbol.for("graceful-fs.previous")):(Ji="___graceful-fs.queue",Gi="___graceful-fs.previous");var es=function(){};if(Qi.debuglog?es=Qi.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(es=function(){var t=Qi.format.apply(Qi,arguments);t="GFS4: "+t.split(/\n/).join("\nGFS4: "),console.error(t)}),!Ki[Ji]){var is=M[Ji]||[];ts(Ki,is),Ki.close=function(t){function e(e,i){return t.call(Ki,e,function(t){t||as(),"function"==typeof i&&i.apply(this,arguments)})}return Object.defineProperty(e,Gi,{value:t}),e}(Ki.close),Ki.closeSync=function(t){function e(e){t.apply(Ki,arguments),as()}return Object.defineProperty(e,Gi,{value:t}),e}(Ki.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){es(Ki[Ji]),h.equal(Ki[Ji].length,0)})}M[Ji]||ts(M,Ki[Ji]);var ss,rs=ns(Xi(Ki));function ns(t){Yi(t),t.gracefulify=ns,t.createReadStream=function(e,i){return new t.ReadStream(e,i)},t.createWriteStream=function(e,i){return new t.WriteStream(e,i)};var e=t.readFile;t.readFile=function(t,i,s){"function"==typeof i&&(s=i,i=null);return function t(i,s,r,n){return e(i,s,function(e){!e||"EMFILE"!==e.code&&"ENFILE"!==e.code?"function"==typeof r&&r.apply(this,arguments):os([t,[i,s,r],e,n||Date.now(),Date.now()])})}(t,i,s)};var i=t.writeFile;t.writeFile=function(t,e,s,r){"function"==typeof s&&(r=s,s=null);return function t(e,s,r,n,o){return i(e,s,r,function(i){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?"function"==typeof n&&n.apply(this,arguments):os([t,[e,s,r,n],i,o||Date.now(),Date.now()])})}(t,e,s,r)};var s=t.appendFile;s&&(t.appendFile=function(t,e,i,r){"function"==typeof i&&(r=i,i=null);return function t(e,i,r,n,o){return s(e,i,r,function(s){!s||"EMFILE"!==s.code&&"ENFILE"!==s.code?"function"==typeof n&&n.apply(this,arguments):os([t,[e,i,r,n],s,o||Date.now(),Date.now()])})}(t,e,i,r)});var r=t.copyFile;r&&(t.copyFile=function(t,e,i,s){"function"==typeof i&&(s=i,i=0);return function t(e,i,s,n,o){return r(e,i,s,function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?"function"==typeof n&&n.apply(this,arguments):os([t,[e,i,s,n],r,o||Date.now(),Date.now()])})}(t,e,i,s)});var n=t.readdir;t.readdir=function(t,e,i){"function"==typeof e&&(i=e,e=null);var s=o.test(process.version)?function(t,e,i,s){return n(t,r(t,e,i,s))}:function(t,e,i,s){return n(t,e,r(t,e,i,s))};return s(t,e,i);function r(t,e,i,r){return function(n,o){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?(o&&o.sort&&o.sort(),"function"==typeof i&&i.call(this,n,o)):os([s,[t,e,i],n,r||Date.now(),Date.now()])}}};var o=/^v[0-5]\./;if("v0.8"===process.version.substr(0,4)){var a=Zi(t);p=a.ReadStream,d=a.WriteStream}var l=t.ReadStream;l&&(p.prototype=Object.create(l.prototype),p.prototype.open=function(){var t=this;f(t.path,t.flags,t.mode,function(e,i){e?(t.autoClose&&t.destroy(),t.emit("error",e)):(t.fd=i,t.emit("open",i),t.read())})});var c=t.WriteStream;c&&(d.prototype=Object.create(c.prototype),d.prototype.open=function(){var t=this;f(t.path,t.flags,t.mode,function(e,i){e?(t.destroy(),t.emit("error",e)):(t.fd=i,t.emit("open",i))})}),Object.defineProperty(t,"ReadStream",{get:function(){return p},set:function(t){p=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return d},set:function(t){d=t},enumerable:!0,configurable:!0});var h=p;Object.defineProperty(t,"FileReadStream",{get:function(){return h},set:function(t){h=t},enumerable:!0,configurable:!0});var u=d;function p(t,e){return this instanceof p?(l.apply(this,arguments),this):p.apply(Object.create(p.prototype),arguments)}function d(t,e){return this instanceof d?(c.apply(this,arguments),this):d.apply(Object.create(d.prototype),arguments)}Object.defineProperty(t,"FileWriteStream",{get:function(){return u},set:function(t){u=t},enumerable:!0,configurable:!0});var m=t.open;function f(t,e,i,s){return"function"==typeof i&&(s=i,i=null),function t(e,i,s,r,n){return m(e,i,s,function(o,a){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?"function"==typeof r&&r.apply(this,arguments):os([t,[e,i,s,r],o,n||Date.now(),Date.now()])})}(t,e,i,s)}return t.open=f,t}function os(t){es("ENQUEUE",t[0].name,t[1]),Ki[Ji].push(t),ls()}function as(){for(var t=Date.now(),e=0;e<Ki[Ji].length;++e)Ki[Ji][e].length>2&&(Ki[Ji][e][3]=t,Ki[Ji][e][4]=t);ls()}function ls(){if(clearTimeout(ss),ss=void 0,0!==Ki[Ji].length){var t=Ki[Ji].shift(),e=t[0],i=t[1],s=t[2],r=t[3],n=t[4];if(void 0===r)es("RETRY",e.name,i),e.apply(null,i);else if(Date.now()-r>=6e4){es("TIMEOUT",e.name,i);var o=i.pop();"function"==typeof o&&o.call(null,s)}else{var a=Date.now()-n,l=Math.max(n-r,1);a>=Math.min(1.2*l,100)?(es("RETRY",e.name,i),e.apply(null,i.concat([r]))):Ki[Ji].push(t)}void 0===ss&&(ss=setTimeout(ls,0))}}process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Ki.__patched&&(rs=ns(Ki),Ki.__patched=!0),function(t){const e=Ii.fromCallback,i=rs,s=["access","appendFile","chmod","chown","close","copyFile","cp","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","glob","lchmod","lchown","lutimes","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","statfs","symlink","truncate","unlink","utimes","writeFile"].filter(t=>"function"==typeof i[t]);Object.assign(t,i),s.forEach(s=>{t[s]=e(i[s])}),t.exists=function(t,e){return"function"==typeof e?i.exists(t,e):new Promise(e=>i.exists(t,e))},t.read=function(t,e,s,r,n,o){return"function"==typeof o?i.read(t,e,s,r,n,o):new Promise((o,a)=>{i.read(t,e,s,r,n,(t,e,i)=>{if(t)return a(t);o({bytesRead:e,buffer:i})})})},t.write=function(t,e,...s){return"function"==typeof s[s.length-1]?i.write(t,e,...s):new Promise((r,n)=>{i.write(t,e,...s,(t,e,i)=>{if(t)return n(t);r({bytesWritten:e,buffer:i})})})},t.readv=function(t,e,...s){return"function"==typeof s[s.length-1]?i.readv(t,e,...s):new Promise((r,n)=>{i.readv(t,e,...s,(t,e,i)=>{if(t)return n(t);r({bytesRead:e,buffers:i})})})},t.writev=function(t,e,...s){return"function"==typeof s[s.length-1]?i.writev(t,e,...s):new Promise((r,n)=>{i.writev(t,e,...s,(t,e,i)=>{if(t)return n(t);r({bytesWritten:e,buffers:i})})})},"function"==typeof i.realpath.native?t.realpath.native=e(i.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")}(Fi);var cs={},hs={};const us=O;hs.checkPath=function(t){if("win32"===process.platform){if(/[<>:"|?*]/.test(t.replace(us.parse(t).root,""))){const e=new Error(`Path contains invalid characters: ${t}`);throw e.code="EINVAL",e}}};const ps=Fi,{checkPath:ds}=hs,ms=t=>"number"==typeof t?t:{mode:511,...t}.mode;cs.makeDir=async(t,e)=>(ds(t),ps.mkdir(t,{mode:ms(e),recursive:!0})),cs.makeDirSync=(t,e)=>(ds(t),ps.mkdirSync(t,{mode:ms(e),recursive:!0}));const fs=Ii.fromPromise,{makeDir:gs,makeDirSync:ys}=cs,ws=fs(gs);var bs={mkdirs:ws,mkdirsSync:ys,mkdirp:ws,mkdirpSync:ys,ensureDir:ws,ensureDirSync:ys};const vs=Ii.fromPromise,_s=Fi;var Ss={pathExists:vs(function(t){return _s.access(t).then(()=>!0).catch(()=>!1)}),pathExistsSync:_s.existsSync};const xs=Fi;var Os={utimesMillis:(0,Ii.fromPromise)(async function(t,e,i){const s=await xs.open(t,"r+");let r=null;try{await xs.futimes(s,e,i)}catch(t){r=t}finally{try{await xs.close(s)}catch(t){r||(r=t)}}if(r)throw r}),utimesMillisSync:function(t,e,i){const s=xs.openSync(t,"r+");let r=null;try{xs.futimesSync(s,e,i)}catch(t){r=t}finally{try{xs.closeSync(s)}catch(t){r||(r=t)}}if(r)throw r}};const Cs=Fi,ks=O,Es=Ii.fromPromise;function As(t,e){return void 0!==e.ino&&void 0!==e.dev&&e.ino===t.ino&&e.dev===t.dev}function $s(t,e){const i=ks.resolve(t).split(ks.sep).filter(t=>t),s=ks.resolve(e).split(ks.sep).filter(t=>t);return i.every((t,e)=>s[e]===t)}function Ps(t,e,i){return`Cannot ${i} '${t}' to a subdirectory of itself, '${e}'.`}var Ds={checkPaths:Es(async function(t,e,i,s){const{srcStat:r,destStat:n}=await function(t,e,i){const s=i.dereference?t=>Cs.stat(t,{bigint:!0}):t=>Cs.lstat(t,{bigint:!0});return Promise.all([s(t),s(e).catch(t=>{if("ENOENT"===t.code)return null;throw t})]).then(([t,e])=>({srcStat:t,destStat:e}))}(t,e,s);if(n){if(As(r,n)){const s=ks.basename(t),o=ks.basename(e);if("move"===i&&s!==o&&s.toLowerCase()===o.toLowerCase())return{srcStat:r,destStat:n,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(r.isDirectory()&&!n.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'.`);if(!r.isDirectory()&&n.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${t}'.`)}if(r.isDirectory()&&$s(t,e))throw new Error(Ps(t,e,i));return{srcStat:r,destStat:n}}),checkPathsSync:function(t,e,i,s){const{srcStat:r,destStat:n}=function(t,e,i){let s;const r=i.dereference?t=>Cs.statSync(t,{bigint:!0}):t=>Cs.lstatSync(t,{bigint:!0}),n=r(t);try{s=r(e)}catch(t){if("ENOENT"===t.code)return{srcStat:n,destStat:null};throw t}return{srcStat:n,destStat:s}}(t,e,s);if(n){if(As(r,n)){const s=ks.basename(t),o=ks.basename(e);if("move"===i&&s!==o&&s.toLowerCase()===o.toLowerCase())return{srcStat:r,destStat:n,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(r.isDirectory()&&!n.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'.`);if(!r.isDirectory()&&n.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${t}'.`)}if(r.isDirectory()&&$s(t,e))throw new Error(Ps(t,e,i));return{srcStat:r,destStat:n}},checkParentPaths:Es(async function t(e,i,s,r){const n=ks.resolve(ks.dirname(e)),o=ks.resolve(ks.dirname(s));if(o===n||o===ks.parse(o).root)return;let a;try{a=await Cs.stat(o,{bigint:!0})}catch(t){if("ENOENT"===t.code)return;throw t}if(As(i,a))throw new Error(Ps(e,s,r));return t(e,i,o,r)}),checkParentPathsSync:function t(e,i,s,r){const n=ks.resolve(ks.dirname(e)),o=ks.resolve(ks.dirname(s));if(o===n||o===ks.parse(o).root)return;let a;try{a=Cs.statSync(o,{bigint:!0})}catch(t){if("ENOENT"===t.code)return;throw t}if(As(i,a))throw new Error(Ps(e,s,r));return t(e,i,o,r)},isSrcSubdir:$s,areIdentical:As};var Ts={asyncIteratorConcurrentProcess:async function(t,e){const i=[];for await(const s of t)i.push(e(s).then(()=>null,t=>t??new Error("unknown error")));await Promise.all(i.map(t=>t.then(t=>{if(null!==t)throw t})))}};const js=Fi,Ns=O,{mkdirs:Fs}=bs,{pathExists:Is}=Ss,{utimesMillis:Ls}=Os,Rs=Ds,{asyncIteratorConcurrentProcess:Vs}=Ts;async function Ms(t,e,i){return!i.filter||i.filter(t,e)}async function Hs(t,e,i,s){const r=s.dereference?js.stat:js.lstat,n=await r(e);if(n.isDirectory())return async function(t,e,i,s,r){e||await js.mkdir(s);await Vs(await js.opendir(i),async t=>{const e=Ns.join(i,t.name),n=Ns.join(s,t.name);if(await Ms(e,n,r)){const{destStat:t}=await Rs.checkPaths(e,n,"copy",r);await Hs(t,e,n,r)}}),e||await js.chmod(s,t.mode)}(n,t,e,i,s);if(n.isFile()||n.isCharacterDevice()||n.isBlockDevice())return async function(t,e,i,s,r){if(!e)return Ws(t,i,s,r);if(r.overwrite)return await js.unlink(s),Ws(t,i,s,r);if(r.errorOnExist)throw new Error(`'${s}' already exists`)}(n,t,e,i,s);if(n.isSymbolicLink())return async function(t,e,i,s){let r=await js.readlink(e);s.dereference&&(r=Ns.resolve(process.cwd(),r));if(!t)return js.symlink(r,i);let n=null;try{n=await js.readlink(i)}catch(t){if("EINVAL"===t.code||"UNKNOWN"===t.code)return js.symlink(r,i);throw t}s.dereference&&(n=Ns.resolve(process.cwd(),n));if(r!==n){if(Rs.isSrcSubdir(r,n))throw new Error(`Cannot copy '${r}' to a subdirectory of itself, '${n}'.`);if(Rs.isSrcSubdir(n,r))throw new Error(`Cannot overwrite '${n}' with '${r}'.`)}return await js.unlink(i),js.symlink(r,i)}(t,e,i,s);if(n.isSocket())throw new Error(`Cannot copy a socket file: ${e}`);if(n.isFIFO())throw new Error(`Cannot copy a FIFO pipe: ${e}`);throw new Error(`Unknown file: ${e}`)}async function Ws(t,e,i,s){if(await js.copyFile(e,i),s.preserveTimestamps){128&t.mode||await function(t,e){return js.chmod(t,128|e)}(i,t.mode);const s=await js.stat(e);await Ls(i,s.atime,s.mtime)}return js.chmod(i,t.mode)}var Bs=async function(t,e,i={}){"function"==typeof i&&(i={filter:i}),i.clobber=!("clobber"in i)||!!i.clobber,i.overwrite="overwrite"in i?!!i.overwrite:i.clobber,i.preserveTimestamps&&"ia32"===process.arch&&process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended;\n\n\tsee https://github.com/jprichardson/node-fs-extra/issues/269","Warning","fs-extra-WARN0001");const{srcStat:s,destStat:r}=await Rs.checkPaths(t,e,"copy",i);if(await Rs.checkParentPaths(t,s,e,"copy"),!await Ms(t,e,i))return;const n=Ns.dirname(e);await Is(n)||await Fs(n),await Hs(r,t,e,i)};const qs=rs,Us=O,zs=bs.mkdirsSync,Js=Os.utimesMillisSync,Gs=Ds;function Ks(t,e,i,s){const r=(s.dereference?qs.statSync:qs.lstatSync)(e);if(r.isDirectory())return function(t,e,i,s,r){return e?Xs(i,s,r):function(t,e,i,s){return qs.mkdirSync(i),Xs(e,i,s),Zs(i,t)}(t.mode,i,s,r)}(r,t,e,i,s);if(r.isFile()||r.isCharacterDevice()||r.isBlockDevice())return function(t,e,i,s,r){return e?function(t,e,i,s){if(s.overwrite)return qs.unlinkSync(i),Ys(t,e,i,s);if(s.errorOnExist)throw new Error(`'${i}' already exists`)}(t,i,s,r):Ys(t,i,s,r)}(r,t,e,i,s);if(r.isSymbolicLink())return function(t,e,i,s){let r=qs.readlinkSync(e);s.dereference&&(r=Us.resolve(process.cwd(),r));if(t){let t;try{t=qs.readlinkSync(i)}catch(t){if("EINVAL"===t.code||"UNKNOWN"===t.code)return qs.symlinkSync(r,i);throw t}if(s.dereference&&(t=Us.resolve(process.cwd(),t)),r!==t){if(Gs.isSrcSubdir(r,t))throw new Error(`Cannot copy '${r}' to a subdirectory of itself, '${t}'.`);if(Gs.isSrcSubdir(t,r))throw new Error(`Cannot overwrite '${t}' with '${r}'.`)}return function(t,e){return qs.unlinkSync(e),qs.symlinkSync(t,e)}(r,i)}return qs.symlinkSync(r,i)}(t,e,i,s);if(r.isSocket())throw new Error(`Cannot copy a socket file: ${e}`);if(r.isFIFO())throw new Error(`Cannot copy a FIFO pipe: ${e}`);throw new Error(`Unknown file: ${e}`)}function Ys(t,e,i,s){return qs.copyFileSync(e,i),s.preserveTimestamps&&function(t,e,i){(function(t){return!(128&t)})(t)&&function(t,e){Zs(t,128|e)}(i,t);(function(t,e){const i=qs.statSync(t);Js(e,i.atime,i.mtime)})(e,i)}(t.mode,e,i),Zs(i,t.mode)}function Zs(t,e){return qs.chmodSync(t,e)}function Xs(t,e,i){const s=qs.opendirSync(t);try{let r;for(;null!==(r=s.readSync());)Qs(r.name,t,e,i)}finally{s.closeSync()}}function Qs(t,e,i,s){const r=Us.join(e,t),n=Us.join(i,t);if(s.filter&&!s.filter(r,n))return;const{destStat:o}=Gs.checkPathsSync(r,n,"copy",s);return Ks(o,r,n,s)}var tr=function(t,e,i){"function"==typeof i&&(i={filter:i}),(i=i||{}).clobber=!("clobber"in i)||!!i.clobber,i.overwrite="overwrite"in i?!!i.overwrite:i.clobber,i.preserveTimestamps&&"ia32"===process.arch&&process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended;\n\n\tsee https://github.com/jprichardson/node-fs-extra/issues/269","Warning","fs-extra-WARN0002");const{srcStat:s,destStat:r}=Gs.checkPathsSync(t,e,"copy",i);if(Gs.checkParentPathsSync(t,s,e,"copy"),i.filter&&!i.filter(t,e))return;const n=Us.dirname(e);return qs.existsSync(n)||zs(n),Ks(r,t,e,i)};var er={copy:(0,Ii.fromPromise)(Bs),copySync:tr};const ir=rs;var sr={remove:(0,Ii.fromCallback)(function(t,e){ir.rm(t,{recursive:!0,force:!0},e)}),removeSync:function(t){ir.rmSync(t,{recursive:!0,force:!0})}};const rr=Ii.fromPromise,nr=Fi,or=O,ar=bs,lr=sr,cr=rr(async function(t){let e;try{e=await nr.readdir(t)}catch{return ar.mkdirs(t)}return Promise.all(e.map(e=>lr.remove(or.join(t,e))))});function hr(t){let e;try{e=nr.readdirSync(t)}catch{return ar.mkdirsSync(t)}e.forEach(e=>{e=or.join(t,e),lr.removeSync(e)})}var ur={emptyDirSync:hr,emptydirSync:hr,emptyDir:cr,emptydir:cr};const pr=Ii.fromPromise,dr=O,mr=Fi,fr=bs;var gr={createFile:pr(async function(t){let e;try{e=await mr.stat(t)}catch{}if(e&&e.isFile())return;const i=dr.dirname(t);let s=null;try{s=await mr.stat(i)}catch(e){if("ENOENT"===e.code)return await fr.mkdirs(i),void await mr.writeFile(t,"");throw e}s.isDirectory()?await mr.writeFile(t,""):await mr.readdir(i)}),createFileSync:function(t){let e;try{e=mr.statSync(t)}catch{}if(e&&e.isFile())return;const i=dr.dirname(t);try{mr.statSync(i).isDirectory()||mr.readdirSync(i)}catch(t){if(!t||"ENOENT"!==t.code)throw t;fr.mkdirsSync(i)}mr.writeFileSync(t,"")}};const yr=Ii.fromPromise,wr=O,br=Fi,vr=bs,{pathExists:_r}=Ss,{areIdentical:Sr}=Ds;var xr={createLink:yr(async function(t,e){let i,s;try{i=await br.lstat(e,{bigint:!0})}catch{}try{s=await br.lstat(t,{bigint:!0})}catch(t){throw t.message=t.message.replace("lstat","ensureLink"),t}if(i&&Sr(s,i))return;const r=wr.dirname(e);await _r(r)||await vr.mkdirs(r),await br.link(t,e)}),createLinkSync:function(t,e){let i;try{i=br.lstatSync(e,{bigint:!0})}catch{}try{const e=br.lstatSync(t,{bigint:!0});if(i&&Sr(e,i))return}catch(t){throw t.message=t.message.replace("lstat","ensureLink"),t}const s=wr.dirname(e);return br.existsSync(s)||vr.mkdirsSync(s),br.linkSync(t,e)}};const Or=O,Cr=Fi,{pathExists:kr}=Ss;var Er={symlinkPaths:(0,Ii.fromPromise)(async function(t,e){if(Or.isAbsolute(t)){try{await Cr.lstat(t)}catch(t){throw t.message=t.message.replace("lstat","ensureSymlink"),t}return{toCwd:t,toDst:t}}const i=Or.dirname(e),s=Or.join(i,t);if(await kr(s))return{toCwd:s,toDst:t};try{await Cr.lstat(t)}catch(t){throw t.message=t.message.replace("lstat","ensureSymlink"),t}return{toCwd:t,toDst:Or.relative(i,t)}}),symlinkPathsSync:function(t,e){if(Or.isAbsolute(t)){if(!Cr.existsSync(t))throw new Error("absolute srcpath does not exist");return{toCwd:t,toDst:t}}const i=Or.dirname(e),s=Or.join(i,t);if(Cr.existsSync(s))return{toCwd:s,toDst:t};if(!Cr.existsSync(t))throw new Error("relative srcpath does not exist");return{toCwd:t,toDst:Or.relative(i,t)}}};const Ar=Fi;var $r={symlinkType:(0,Ii.fromPromise)(async function(t,e){if(e)return e;let i;try{i=await Ar.lstat(t)}catch{return"file"}return i&&i.isDirectory()?"dir":"file"}),symlinkTypeSync:function(t,e){if(e)return e;let i;try{i=Ar.lstatSync(t)}catch{return"file"}return i&&i.isDirectory()?"dir":"file"}};const Pr=Ii.fromPromise,Dr=O,Tr=Fi,{mkdirs:jr,mkdirsSync:Nr}=bs,{symlinkPaths:Fr,symlinkPathsSync:Ir}=Er,{symlinkType:Lr,symlinkTypeSync:Rr}=$r,{pathExists:Vr}=Ss,{areIdentical:Mr}=Ds;var Hr={createSymlink:Pr(async function(t,e,i){let s;try{s=await Tr.lstat(e)}catch{}if(s&&s.isSymbolicLink()){let i;if(Dr.isAbsolute(t))i=await Tr.stat(t,{bigint:!0});else{const s=Dr.dirname(e),r=Dr.join(s,t);try{i=await Tr.stat(r,{bigint:!0})}catch{i=await Tr.stat(t,{bigint:!0})}}const s=await Tr.stat(e,{bigint:!0});if(Mr(i,s))return}const r=await Fr(t,e);t=r.toDst;const n=await Lr(r.toCwd,i),o=Dr.dirname(e);return await Vr(o)||await jr(o),Tr.symlink(t,e,n)}),createSymlinkSync:function(t,e,i){let s;try{s=Tr.lstatSync(e)}catch{}if(s&&s.isSymbolicLink()){let i;if(Dr.isAbsolute(t))i=Tr.statSync(t,{bigint:!0});else{const s=Dr.dirname(e),r=Dr.join(s,t);try{i=Tr.statSync(r,{bigint:!0})}catch{i=Tr.statSync(t,{bigint:!0})}}const s=Tr.statSync(e,{bigint:!0});if(Mr(i,s))return}const r=Ir(t,e);t=r.toDst,i=Rr(r.toCwd,i);const n=Dr.dirname(e);return Tr.existsSync(n)||Nr(n),Tr.symlinkSync(t,e,i)}};const{createFile:Wr,createFileSync:Br}=gr,{createLink:qr,createLinkSync:Ur}=xr,{createSymlink:zr,createSymlinkSync:Jr}=Hr;var Gr={createFile:Wr,createFileSync:Br,ensureFile:Wr,ensureFileSync:Br,createLink:qr,createLinkSync:Ur,ensureLink:qr,ensureLinkSync:Ur,createSymlink:zr,createSymlinkSync:Jr,ensureSymlink:zr,ensureSymlinkSync:Jr};var Kr={stringify:function(t,{EOL:e="\n",finalEOL:i=!0,replacer:s=null,spaces:r}={}){const n=i?e:"",o=JSON.stringify(t,s,r);if(void 0===o)throw new TypeError(`Converting ${typeof t} value to JSON is not supported`);return o.replace(/\n/g,e)+n},stripBom:function(t){return Buffer.isBuffer(t)&&(t=t.toString("utf8")),t.replace(/^\uFEFF/,"")}};let Yr;try{Yr=rs}catch(t){Yr=C}const Zr=Ii,{stringify:Xr,stripBom:Qr}=Kr;const tn=Zr.fromPromise(async function(t,e={}){"string"==typeof e&&(e={encoding:e});const i=e.fs||Yr,s=!("throws"in e)||e.throws;let r,n=await Zr.fromCallback(i.readFile)(t,e);n=Qr(n);try{r=JSON.parse(n,e?e.reviver:null)}catch(e){if(s)throw e.message=`${t}: ${e.message}`,e;return null}return r});const en=Zr.fromPromise(async function(t,e,i={}){const s=i.fs||Yr,r=Xr(e,i);await Zr.fromCallback(s.writeFile)(t,r,i)});var sn={readFile:tn,readFileSync:function(t,e={}){"string"==typeof e&&(e={encoding:e});const i=e.fs||Yr,s=!("throws"in e)||e.throws;try{let s=i.readFileSync(t,e);return s=Qr(s),JSON.parse(s,e.reviver)}catch(e){if(s)throw e.message=`${t}: ${e.message}`,e;return null}},writeFile:en,writeFileSync:function(t,e,i={}){const s=i.fs||Yr,r=Xr(e,i);return s.writeFileSync(t,r,i)}};var rn={readJson:sn.readFile,readJsonSync:sn.readFileSync,writeJson:sn.writeFile,writeJsonSync:sn.writeFileSync};const nn=Ii.fromPromise,on=Fi,an=O,ln=bs,cn=Ss.pathExists;var hn={outputFile:nn(async function(t,e,i="utf-8"){const s=an.dirname(t);return await cn(s)||await ln.mkdirs(s),on.writeFile(t,e,i)}),outputFileSync:function(t,...e){const i=an.dirname(t);on.existsSync(i)||ln.mkdirsSync(i),on.writeFileSync(t,...e)}};const{stringify:un}=Kr,{outputFile:pn}=hn;var dn=async function(t,e,i={}){const s=un(e,i);await pn(t,s,i)};const{stringify:mn}=Kr,{outputFileSync:fn}=hn;var gn=function(t,e,i){const s=mn(e,i);fn(t,s,i)};const yn=Ii.fromPromise,wn=rn;wn.outputJson=yn(dn),wn.outputJsonSync=gn,wn.outputJSON=wn.outputJson,wn.outputJSONSync=wn.outputJsonSync,wn.writeJSON=wn.writeJson,wn.writeJSONSync=wn.writeJsonSync,wn.readJSON=wn.readJson,wn.readJSONSync=wn.readJsonSync;var bn=wn;const vn=Fi,_n=O,{copy:Sn}=er,{remove:xn}=sr,{mkdirp:On}=bs,{pathExists:Cn}=Ss,kn=Ds;var En=async function(t,e,i={}){const s=i.overwrite||i.clobber||!1,{srcStat:r,isChangingCase:n=!1}=await kn.checkPaths(t,e,"move",i);await kn.checkParentPaths(t,r,e,"move");const o=_n.dirname(e);return _n.parse(o).root!==o&&await On(o),async function(t,e,i,s){if(!s)if(i)await xn(e);else if(await Cn(e))throw new Error("dest already exists.");try{await vn.rename(t,e)}catch(s){if("EXDEV"!==s.code)throw s;await async function(t,e,i){const s={overwrite:i,errorOnExist:!0,preserveTimestamps:!0};return await Sn(t,e,s),xn(t)}(t,e,i)}}(t,e,s,n)};const An=rs,$n=O,Pn=er.copySync,Dn=sr.removeSync,Tn=bs.mkdirpSync,jn=Ds;function Nn(t,e,i){try{An.renameSync(t,e)}catch(s){if("EXDEV"!==s.code)throw s;return function(t,e,i){const s={overwrite:i,errorOnExist:!0,preserveTimestamps:!0};return Pn(t,e,s),Dn(t)}(t,e,i)}}var Fn=function(t,e,i){const s=(i=i||{}).overwrite||i.clobber||!1,{srcStat:r,isChangingCase:n=!1}=jn.checkPathsSync(t,e,"move",i);return jn.checkParentPathsSync(t,r,e,"move"),function(t){const e=$n.dirname(t);return $n.parse(e).root===e}(e)||Tn($n.dirname(e)),function(t,e,i,s){if(s)return Nn(t,e,i);if(i)return Dn(e),Nn(t,e,i);if(An.existsSync(e))throw new Error("dest already exists.");return Nn(t,e,i)}(t,e,s,n)};var In={move:(0,Ii.fromPromise)(En),moveSync:Fn},Ln=H({...Fi,...er,...ur,...Gr,...bn,...bs,...In,...hn,...Ss,...sr}),Rn={},Vn={};!function(t){var e=/[|\\{}()[\]^$+*?.]/g,i=Object.prototype.hasOwnProperty,s=function(t,e){return i.apply(t,[e])};t.escapeRegExpChars=function(t){return t?String(t).replace(e,"\\$&"):""};var r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&#34;","'":"&#39;"},n=/[&<>'"]/g;function o(t){return r[t]||t}function a(){return Function.prototype.toString.call(this)+';\nvar _ENCODE_HTML_RULES = {\n "&": "&amp;"\n , "<": "&lt;"\n , ">": "&gt;"\n , \'"\': "&#34;"\n , "\'": "&#39;"\n }\n , _MATCH_HTML = /[&<>\'"]/g;\nfunction encode_char(c) {\n return _ENCODE_HTML_RULES[c] || c;\n};\n'}t.escapeXML=function(t){return null==t?"":String(t).replace(n,o)};try{"function"==typeof Object.defineProperty?Object.defineProperty(t.escapeXML,"toString",{value:a}):t.escapeXML.toString=a}catch(t){console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)")}t.shallowCopy=function(t,e){if(e=e||{},null!=t)for(var i in e)s(e,i)&&"__proto__"!==i&&"constructor"!==i&&(t[i]=e[i]);return t},t.shallowCopyFromList=function(t,e,i){if(i=i||[],e=e||{},null!=t)for(var r=0;r<i.length;r++){var n=i[r];if(void 0!==e[n]){if(!s(e,n))continue;if("__proto__"===n||"constructor"===n)continue;t[n]=e[n]}}return t},t.cache={_data:{},set:function(t,e){this._data[t]=e},get:function(t){return this._data[t]},remove:function(t){delete this._data[t]},reset:function(){this._data={}}},t.hyphenToCamel=function(t){return t.replace(/-[a-z]/g,function(t){return t[1].toUpperCase()})},t.createNullProtoObjWherePossible="function"==typeof Object.create?function(){return Object.create(null)}:{__proto__:null}instanceof Object?function(){return{}}:function(){return{__proto__:null}},t.hasOwnOnlyObject=function(e){var i=t.createNullProtoObjWherePossible();for(var r in e)s(e,r)&&(i[r]=e[r]);return i}}(Vn);var Mn="3.1.10";!function(t){
2
+ import t,{useMemo as e,useState as i,useEffect as s,useCallback as r}from"react";import n from"node:events";import o from"node:child_process";import a from"node:path";import l from"node:fs";import c from"node:process";import h from"assert";import u from"events";import p from"readline";import{Box as d,Text as m,useInput as f,useApp as g,render as y}from"ink";import{createRequire as w}from"module";import{FileManager as b,Logger as v,BUNDLER_PACKAGE_MAP as _,resolveBundlerName as S,PackageManager as x,Spinner as O}from"@bundlekit/shared-utils";import C from"path";import k from"fs";import{spawnSync as E}from"child_process";import{fileURLToPath as A}from"url";import $ from"constants";import P from"stream";import D from"util";import{createRequire as T}from"node:module";import{fileURLToPath as j}from"node:url";import{jsxs as N,jsx as F}from"react/jsx-runtime";import I from"ink-gradient";import R from"ink-big-text";import L from"ink-text-input";import V from"ink-spinner";var M="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function H(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var W={},B={},q={};let U=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}};q.CommanderError=U,q.InvalidArgumentError=class extends U{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:z}=q;B.Argument=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t}this._name.length>3&&"..."===this._name.slice(-3)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new z(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},B.humanReadableArgName=function(t){const e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"};var J={},G={};const{humanReadableArgName:K}=B;function Y(t){return t.replace(/\x1b\[\d*(;\d*)*m/g,"")}G.Help=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){const e=t.commands.filter(t=>!t._hidden),i=t._getHelpCommand();return i&&!i._hidden&&e.push(i),this.sortSubcommands&&e.sort((t,e)=>t.name().localeCompare(e.name())),e}compareOptions(t,e){const i=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){const e=t.options.filter(t=>!t.hidden),i=t._getHelpOption();if(i&&!i.hidden){const s=i.short&&t._findOption(i.short),r=i.long&&t._findOption(i.long);s||r?i.long&&!r?e.push(t.createOption(i.long,i.description)):i.short&&!s&&e.push(t.createOption(i.short,i.description)):e.push(i)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const e=[];for(let i=t.parent;i;i=i.parent){const t=i.options.filter(t=>!t.hidden);e.push(...t)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(t=>t.description)?t.registeredArguments:[]}subcommandTerm(t){const e=t.registeredArguments.map(t=>K(t)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((t,i)=>Math.max(t,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(i)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((t,i)=>Math.max(t,this.displayWidth(e.styleOptionTerm(e.optionTerm(i)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((t,i)=>Math.max(t,this.displayWidth(e.styleOptionTerm(e.optionTerm(i)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((t,i)=>Math.max(t,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(i)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let e=t.parent;e;e=e.parent)i=e.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue){(t.required||t.optional||t.isBoolean()&&"boolean"==typeof t.defaultValue)&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`)}return void 0!==t.presetArg&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),void 0!==t.envVar&&e.push(`env: ${t.envVar}`),e.length>0?`${t.description} (${e.join(", ")})`:t.description}argumentDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){const i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatHelp(t,e){const i=e.padWidth(t,e),s=e.helpWidth??80;function r(t,s){return e.formatItem(t,i,s,e)}let n=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""];const o=e.commandDescription(t);o.length>0&&(n=n.concat([e.boxWrap(e.styleCommandDescription(o),s),""]));const a=e.visibleArguments(t).map(t=>r(e.styleArgumentTerm(e.argumentTerm(t)),e.styleArgumentDescription(e.argumentDescription(t))));a.length>0&&(n=n.concat([e.styleTitle("Arguments:"),...a,""]));const l=e.visibleOptions(t).map(t=>r(e.styleOptionTerm(e.optionTerm(t)),e.styleOptionDescription(e.optionDescription(t))));if(l.length>0&&(n=n.concat([e.styleTitle("Options:"),...l,""])),e.showGlobalOptions){const i=e.visibleGlobalOptions(t).map(t=>r(e.styleOptionTerm(e.optionTerm(t)),e.styleOptionDescription(e.optionDescription(t))));i.length>0&&(n=n.concat([e.styleTitle("Global Options:"),...i,""]))}const c=e.visibleCommands(t).map(t=>r(e.styleSubcommandTerm(e.subcommandTerm(t)),e.styleSubcommandDescription(e.subcommandDescription(t))));return c.length>0&&(n=n.concat([e.styleTitle("Commands:"),...c,""])),n.join("\n")}displayWidth(t){return Y(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(t=>"[options]"===t?this.styleOptionText(t):"[command]"===t?this.styleSubcommandText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(t=>"[options]"===t?this.styleOptionText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,e,i,s){const r=" ".repeat(2);if(!i)return r+t;const n=t.padEnd(e+t.length-s.displayWidth(t)),o=(this.helpWidth??80)-e-2-2;let a;if(o<this.minWidthToWrap||s.preformatted(i))a=i;else{a=s.boxWrap(i,o).replace(/\n/g,"\n"+" ".repeat(e+2))}return r+n+" ".repeat(2)+a.replace(/\n/g,`\n${r}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;const i=t.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,r=[];return i.forEach(t=>{const i=t.match(s);if(null===i)return void r.push("");let n=[i.shift()],o=this.displayWidth(n[0]);i.forEach(t=>{const i=this.displayWidth(t);if(o+i<=e)return n.push(t),void(o+=i);r.push(n.join(""));const s=t.trimStart();n=[s],o=this.displayWidth(s)}),r.push(n.join(""))}),r.join("\n")}},G.stripColor=Y;var Z={};const{InvalidArgumentError:X}=q;function Q(t){return t.split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}Z.Option=class{constructor(t,e){this.flags=t,this.description=e||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;const i=function(t){let e,i;const s=/^-[^-]$/,r=/^--[^-]/,n=t.split(/[ |,]+/).concat("guard");s.test(n[0])&&(e=n.shift());r.test(n[0])&&(i=n.shift());!e&&s.test(n[0])&&(e=n.shift());!e&&r.test(n[0])&&(e=i,i=n.shift());if(n[0].startsWith("-")){const e=n[0],i=`option creation failed due to '${e}' in option flags '${t}'`;if(/^-[^-][^-]/.test(e))throw new Error(`${i}\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(s.test(e))throw new Error(`${i}\n- too many short flags`);if(r.test(e))throw new Error(`${i}\n- too many long flags`);throw new Error(`${i}\n- unrecognised flag format`)}if(void 0===e&&void 0===i)throw new Error(`option creation failed due to no flags found in '${t}'.`);return{shortFlag:e,longFlag:i}}(t);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let e=t;return"string"==typeof t&&(e={[t]:!0}),this.implied=Object.assign(this.implied||{},e),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?e.concat(t):[t]}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,e)=>{if(!this.argChoices.includes(t))throw new X(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,e):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?Q(this.name().replace(/^no-/,"")):Q(this.name())}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Z.DualOptions=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,e)=>{this.positiveOptions.has(e)&&this.dualOptions.add(e)})}valueFromOption(t,e){const i=e.attributeName();if(!this.dualOptions.has(i))return!0;const s=this.negativeOptions.get(i).presetArg,r=void 0!==s&&s;return e.negate===(r===t)}};var tt={};tt.suggestSimilar=function(t,e){if(!e||0===e.length)return"";e=Array.from(new Set(e));const i=t.startsWith("--");i&&(t=t.slice(2),e=e.map(t=>t.slice(2)));let s=[],r=3;return e.forEach(e=>{if(e.length<=1)return;const i=function(t,e){if(Math.abs(t.length-e.length)>3)return Math.max(t.length,e.length);const i=[];for(let e=0;e<=t.length;e++)i[e]=[e];for(let t=0;t<=e.length;t++)i[0][t]=t;for(let s=1;s<=e.length;s++)for(let r=1;r<=t.length;r++){let n=1;n=t[r-1]===e[s-1]?0:1,i[r][s]=Math.min(i[r-1][s]+1,i[r][s-1]+1,i[r-1][s-1]+n),r>1&&s>1&&t[r-1]===e[s-2]&&t[r-2]===e[s-1]&&(i[r][s]=Math.min(i[r][s],i[r-2][s-2]+1))}return i[t.length][e.length]}(t,e),n=Math.max(t.length,e.length);(n-i)/n>.4&&(i<r?(r=i,s=[e]):i===r&&s.push(e))}),s.sort((t,e)=>t.localeCompare(e)),i&&(s=s.map(t=>`--${t}`)),s.length>1?`\n(Did you mean one of ${s.join(", ")}?)`:1===s.length?`\n(Did you mean ${s[0]}?)`:""};const et=n.EventEmitter,it=o,st=a,rt=l,nt=c,{Argument:ot,humanReadableArgName:at}=B,{CommanderError:lt}=q,{Help:ct,stripColor:ht}=G,{Option:ut,DualOptions:pt}=Z,{suggestSimilar:dt}=tt;function mt(t){return t.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i,s="127.0.0.1",r="9229";return null!==(i=t.match(/^(--inspect(-brk)?)$/))?e=i[1]:null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(e=i[1],/^\d+$/.test(i[3])?r=i[3]:s=i[3]):null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(e=i[1],s=i[3],r=i[4]),e&&"0"!==r?`${e}=${s}:${parseInt(r)+1}`:t})}function ft(){return!nt.env.NO_COLOR&&"0"!==nt.env.FORCE_COLOR&&"false"!==nt.env.FORCE_COLOR&&(!(!nt.env.FORCE_COLOR&&void 0===nt.env.CLICOLOR_FORCE)||void 0)}J.Command=class t extends et{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>nt.stdout.write(t),writeErr:t=>nt.stderr.write(t),outputError:(t,e)=>e(t),getOutHelpWidth:()=>nt.stdout.isTTY?nt.stdout.columns:void 0,getErrHelpWidth:()=>nt.stderr.isTTY?nt.stderr.columns:void 0,getOutHasColors:()=>ft()??(nt.stdout.isTTY&&nt.stdout.hasColors?.()),getErrHasColors:()=>ft()??(nt.stderr.isTTY&&nt.stderr.hasColors?.()),stripColor:t=>ht(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){const t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,i){let s=e,r=i;"object"==typeof s&&null!==s&&(r=s,s=null),r=r||{};const[,n,o]=t.match(/([^ ]+) *(.*)/),a=this.createCommand(n);return s&&(a.description(s),a._executableHandler=!0),r.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!r.noHelp&&!r.hidden),a._executableFile=r.executableFile||null,o&&a.arguments(o),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),s?this:a}createCommand(e){return new t(e)}createHelp(){return Object.assign(new ct,this.configureHelp())}configureHelp(t){return void 0===t?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return void 0===t?this._outputConfiguration:(Object.assign(this._outputConfiguration,t),this)}showHelpAfterError(t=!0){return"string"!=typeof t&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(e=e||{}).isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new ot(t,e)}argument(t,e,i,s){const r=this.createArgument(t,e);return"function"==typeof i?r.default(s).argParser(i):r.default(i),this.addArgument(r),this}arguments(t){return t.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(t){const e=this.registeredArguments.slice(-1)[0];if(e&&e.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&void 0!==t.defaultValue&&void 0===t.parseArg)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,e){if("boolean"==typeof t)return this._addImplicitHelpCommand=t,this;t=t??"help [command]";const[,i,s]=t.match(/([^ ]+) *(.*)/),r=e??"display help for command",n=this.createCommand(i);return n.helpOption(!1),s&&n.arguments(s),r&&n.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=n,this}addHelpCommand(t,e){return"object"!=typeof t?(this.helpCommand(t,e),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,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(t,e){const i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return this._exitCallback=t||(t=>{if("commander.executeSubCommandAsync"!==t.code)throw t}),this}_exit(t,e,i){this._exitCallback&&this._exitCallback(new lt(t,e,i)),nt.exit(t)}action(t){return this._actionHandler=e=>{const i=this.registeredArguments.length,s=e.slice(0,i);return this._storeOptionsAsProperties?s[i]=this:s[i]=this.opts(),s.push(this),t.apply(this,s)},this}createOption(t,e){return new ut(t,e)}_callParseArg(t,e,i,s){try{return t.parseArg(e,i)}catch(t){if("commander.invalidArgument"===t.code){const e=`${s} ${t.message}`;this.error(e,{exitCode:t.exitCode,code:t.code})}throw t}}_registerOption(t){const e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){const i=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'\n- already used by option '${e.flags}'`)}this.options.push(t)}_registerCommand(t){const e=t=>[t.name()].concat(t.aliases()),i=e(t).find(t=>this._findCommand(t));if(i){const s=e(this._findCommand(i)).join("|"),r=e(t).join("|");throw new Error(`cannot add command '${r}' as already have command '${s}'`)}this.commands.push(t)}addOption(t){this._registerOption(t);const e=t.name(),i=t.attributeName();if(t.negate){const e=t.long.replace(/^--no-/,"--");this._findOption(e)||this.setOptionValueWithSource(i,void 0===t.defaultValue||t.defaultValue,"default")}else void 0!==t.defaultValue&&this.setOptionValueWithSource(i,t.defaultValue,"default");const s=(e,s,r)=>{null==e&&void 0!==t.presetArg&&(e=t.presetArg);const n=this.getOptionValue(i);null!==e&&t.parseArg?e=this._callParseArg(t,e,n,s):null!==e&&t.variadic&&(e=t._concatValue(e,n)),null==e&&(e=!t.negate&&(!(!t.isBoolean()&&!t.optional)||"")),this.setOptionValueWithSource(i,e,r)};return this.on("option:"+e,e=>{const i=`error: option '${t.flags}' argument '${e}' is invalid.`;s(e,i,"cli")}),t.envVar&&this.on("optionEnv:"+e,e=>{const i=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;s(e,i,"env")}),this}_optionEx(t,e,i,s,r){if("object"==typeof e&&e instanceof ut)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const n=this.createOption(e,i);if(n.makeOptionMandatory(!!t.mandatory),"function"==typeof s)n.default(r).argParser(s);else if(s instanceof RegExp){const t=s;s=(e,i)=>{const s=t.exec(e);return s?s[0]:i},n.default(r).argParser(s)}else n.default(s);return this.addOption(n)}option(t,e,i,s){return this._optionEx({},t,e,i,s)}requiredOption(t,e,i,s){return this._optionEx({mandatory:!0},t,e,i,s)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,i){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(i=>{void 0!==i.getOptionValueSource(t)&&(e=i.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(e=e||{},void 0===t&&void 0===e.from){nt.versions?.electron&&(e.from="electron");const t=nt.execArgv??[];(t.includes("-e")||t.includes("--eval")||t.includes("-p")||t.includes("--print"))&&(e.from="eval")}let i;switch(void 0===t&&(t=nt.argv),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":nt.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,e){this._prepareForParse();const i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){this._prepareForParse();const i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),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(t,e,i){if(rt.existsSync(t))return;throw new Error(`'${t}' does not exist\n - if '${i}' 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 - ${e?`searched for local subcommand relative to directory '${e}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory"}`)}_executeSubCommand(t,e){e=e.slice();let i=!1;const s=[".js",".ts",".tsx",".mjs",".cjs"];function r(t,e){const i=st.resolve(t,e);if(rt.existsSync(i))return i;if(s.includes(st.extname(e)))return;const r=s.find(t=>rt.existsSync(`${i}${t}`));return r?`${i}${r}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n,o=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let t;try{t=rt.realpathSync(this._scriptPath)}catch{t=this._scriptPath}a=st.resolve(st.dirname(t),a)}if(a){let e=r(a,o);if(!e&&!t._executableFile&&this._scriptPath){const i=st.basename(this._scriptPath,st.extname(this._scriptPath));i!==this._name&&(e=r(a,`${i}-${t._name}`))}o=e||o}if(i=s.includes(st.extname(o)),"win32"!==nt.platform?i?(e.unshift(o),e=mt(nt.execArgv).concat(e),n=it.spawn(nt.argv[0],e,{stdio:"inherit"})):n=it.spawn(o,e,{stdio:"inherit"}):(this._checkForMissingExecutable(o,a,t._name),e.unshift(o),e=mt(nt.execArgv).concat(e),n=it.spawn(nt.execPath,e,{stdio:"inherit"})),!n.killed){["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(t=>{nt.on(t,()=>{!1===n.killed&&null===n.exitCode&&n.kill(t)})})}const l=this._exitCallback;n.on("close",t=>{t=t??1,l?l(new lt(t,"commander.executeSubCommandAsync","(close)")):nt.exit(t)}),n.on("error",e=>{if("ENOENT"===e.code)this._checkForMissingExecutable(o,a,t._name);else if("EACCES"===e.code)throw new Error(`'${o}' not executable`);if(l){const t=new lt(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,l(t)}else nt.exit(1)}),this.runningCommand=n}_dispatchSubcommand(t,e,i){const s=this._findCommand(t);let r;return s||this.help({error:!0}),s._prepareForParse(),r=this._chainOrCallSubCommandHook(r,s,"preSubcommand"),r=this._chainOrCall(r,()=>{if(!s._executableHandler)return s._parseCommand(e,i);this._executeSubCommand(s,e.concat(i))}),r}_dispatchHelpCommand(t){t||this.help();const e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&null==this.args[e]&&this.missingArgument(t.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const t=(t,e,i)=>{let s=e;if(null!==e&&t.parseArg){const r=`error: command-argument value '${e}' is invalid for argument '${t.name()}'.`;s=this._callParseArg(t,e,i,r)}return s};this._checkNumberOfArguments();const e=[];this.registeredArguments.forEach((i,s)=>{let r=i.defaultValue;i.variadic?s<this.args.length?(r=this.args.slice(s),i.parseArg&&(r=r.reduce((e,s)=>t(i,s,e),i.defaultValue))):void 0===r&&(r=[]):s<this.args.length&&(r=this.args[s],i.parseArg&&(r=t(i,r,i.defaultValue))),e[s]=r}),this.processedArgs=e}_chainOrCall(t,e){return t&&t.then&&"function"==typeof t.then?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let i=t;const s=[];return this._getCommandAndAncestors().reverse().filter(t=>void 0!==t._lifeCycleHooks[e]).forEach(t=>{t._lifeCycleHooks[e].forEach(e=>{s.push({hookedCommand:t,callback:e})})}),"postAction"===e&&s.reverse(),s.forEach(t=>{i=this._chainOrCall(i,()=>t.callback(t.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,e,i){let s=t;return void 0!==this._lifeCycleHooks[i]&&this._lifeCycleHooks[i].forEach(t=>{s=this._chainOrCall(s,()=>t(this,e))}),s}_parseCommand(t,e){const i=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),e=i.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(e),this._dispatchSubcommand(this._defaultCommandName,t,e);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const s=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){let i;return s(),this._processArguments(),i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,()=>this._actionHandler(this.processedArgs)),this.parent&&(i=this._chainOrCall(i,()=>{this.parent.emit(r,t,e)})),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(r))s(),this._processArguments(),this.parent.emit(r,t,e);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,e);this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():(s(),this._processArguments())}else this.commands.length?(s(),this.help({error:!0})):(s(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&void 0===t.getOptionValue(e.attributeName())&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){const t=this.options.filter(t=>{const e=t.attributeName();return void 0!==this.getOptionValue(e)&&"default"!==this.getOptionValueSource(e)}),e=t.filter(t=>t.conflictsWith.length>0);e.forEach(e=>{const i=t.find(t=>e.conflictsWith.includes(t.attributeName()));i&&this._conflictingOption(e,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){const e=[],i=[];let s=e;const r=t.slice();function n(t){return t.length>1&&"-"===t[0]}let o=null;for(;r.length;){const t=r.shift();if("--"===t){s===i&&s.push(t),s.push(...r);break}if(!o||n(t)){if(o=null,n(t)){const e=this._findOption(t);if(e){if(e.required){const t=r.shift();void 0===t&&this.optionMissingArgument(e),this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;r.length>0&&!n(r[0])&&(t=r.shift()),this.emit(`option:${e.name()}`,t)}else this.emit(`option:${e.name()}`);o=e.variadic?e:null;continue}}if(t.length>2&&"-"===t[0]&&"-"!==t[1]){const e=this._findOption(`-${t[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,t.slice(2)):(this.emit(`option:${e.name()}`),r.unshift(`-${t.slice(2)}`));continue}}if(/^--[^=]+=/.test(t)){const e=t.indexOf("="),i=this._findOption(t.slice(0,e));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,t.slice(e+1));continue}}if(n(t)&&(s=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===e.length&&0===i.length){if(this._findCommand(t)){e.push(t),r.length>0&&i.push(...r);break}if(this._getHelpCommand()&&t===this._getHelpCommand().name()){e.push(t),r.length>0&&e.push(...r);break}if(this._defaultCommandName){i.push(t),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){s.push(t),r.length>0&&s.push(...r);break}s.push(t)}else this.emit(`option:${o.name()}`,t)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){const t={},e=this.options.length;for(let i=0;i<e;i++){const e=this.options[i].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){this._outputConfiguration.outputError(`${t}\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 i=e||{},s=i.exitCode||1,r=i.code||"commander.error";this._exit(s,r,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in nt.env){const e=t.attributeName();(void 0===this.getOptionValue(e)||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,nt.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){const t=new pt(this.options),e=t=>void 0!==this.getOptionValue(t)&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter(i=>void 0!==i.implied&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(t=>{Object.keys(t.implied).filter(t=>!e(t)).forEach(e=>{this.setOptionValueWithSource(e,t.implied[e],"implied")})})}missingArgument(t){const e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){const i=t=>{const e=t.attributeName(),i=this.getOptionValue(e),s=this.options.find(t=>t.negate&&e===t.attributeName()),r=this.options.find(t=>!t.negate&&e===t.attributeName());return s&&(void 0===s.presetArg&&!1===i||void 0!==s.presetArg&&i===s.presetArg)?s:r||t},s=t=>{const e=i(t),s=e.attributeName();return"env"===this.getOptionValueSource(s)?`environment variable '${e.envVar}'`:`option '${e.flags}'`},r=`error: ${s(t)} cannot be used with ${s(e)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[],s=this;do{const t=s.createHelp().visibleOptions(s).filter(t=>t.long).map(t=>t.long);i=i.concat(t),s=s.parent}while(s&&!s._enablePositionalOptions);e=dt(t,i)}const i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const e=this.registeredArguments.length,i=1===e?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${i} but got ${t.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach(t=>{i.push(t.name()),t.alias()&&i.push(t.alias())}),e=dt(t,i)}const i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(void 0===t)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";const s=this.createOption(e,i);return this._versionOptionName=s.attributeName(),this._registerOption(s),this.on("option:"+s.name(),()=>{this._outputConfiguration.writeOut(`${t}\n`),this._exit(0,"commander.version",t)}),this}description(t,e){return void 0===t&&void 0===e?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return void 0===t?this._summary:(this._summary=t,this)}alias(t){if(void 0===t)return this._aliases[0];let e=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");const i=this.parent?._findCommand(t);if(i){const e=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${e}'`)}return e._aliases.push(t),this}aliases(t){return void 0===t?this._aliases:(t.forEach(t=>this.alias(t)),this)}usage(t){if(void 0===t){if(this._usage)return this._usage;const t=this.registeredArguments.map(t=>at(t));return[].concat(this.options.length||null!==this._helpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=t,this}name(t){return void 0===t?this._name:(this._name=t,this)}nameFromFilename(t){return this._name=st.basename(t,st.extname(t)),this}executableDir(t){return void 0===t?this._executableDir:(this._executableDir=t,this)}helpInformation(t){const e=this.createHelp(),i=this._getOutputContext(t);e.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});const s=e.formatHelp(this,e);return i.hasColors?s:this._outputConfiguration.stripColor(s)}_getOutputContext(t){const e=!!(t=t||{}).error;let i,s,r;e?(i=t=>this._outputConfiguration.writeErr(t),s=this._outputConfiguration.getErrHasColors(),r=this._outputConfiguration.getErrHelpWidth()):(i=t=>this._outputConfiguration.writeOut(t),s=this._outputConfiguration.getOutHasColors(),r=this._outputConfiguration.getOutHelpWidth());return{error:e,write:t=>(s||(t=this._outputConfiguration.stripColor(t)),i(t)),hasColors:s,helpWidth:r}}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const i=this._getOutputContext(t),s={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(t=>t.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let r=this.helpInformation({error:i.error});if(e&&(r=e(r),"string"!=typeof r&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",s),this._getCommandAndAncestors().forEach(t=>t.emit("afterAllHelp",s))}helpOption(t,e){return"boolean"==typeof t?(this._helpOption=t?this._helpOption??void 0:null,this):(t=t??"-h, --help",e=e??"display help for command",this._helpOption=this.createOption(t,e),this)}_getHelpOption(){return void 0===this._helpOption&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this}help(t){this.outputHelp(t);let e=Number(nt.exitCode??0);0===e&&t&&"function"!=typeof t&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);const s=`${t}Help`;return this.on(s,t=>{let i;i="function"==typeof e?e({error:t.error,command:t.command}):e,i&&t.write(`${i}\n`)}),this}_outputHelpIfRequested(t){const e=this._getHelpOption();e&&t.find(t=>e.is(t))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}},J.useColor=ft;const{Argument:gt}=B,{Command:yt}=J,{CommanderError:wt,InvalidArgumentError:bt}=q,{Help:vt}=G,{Option:_t}=Z;W.program=new yt,W.createCommand=t=>new yt(t),W.createOption=(t,e)=>new _t(t,e),W.createArgument=(t,e)=>new gt(t,e),W.Command=yt,W.Option=_t,W.Argument=gt,W.Help=vt,W.CommanderError=wt,W.InvalidArgumentError=bt,W.InvalidOptionArgumentError=bt;const{Command:St}=W;var xt,Ot={},Ct={exports:{}},kt={exports:{}};const Et=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,At=()=>{const t={enabled:"undefined"!=typeof process&&"0"!==process.env.FORCE_COLOR,visible:!0,styles:{},keys:{}},e=(t,e,i)=>"function"==typeof t?t(e):t.wrap(e,i),i=(i,s)=>{if(""===i||null==i)return"";if(!1===t.enabled)return i;if(!1===t.visible)return"";let r=""+i,n=r.includes("\n"),o=s.length;for(o>0&&s.includes("unstyle")&&(s=[...new Set(["unstyle",...s])].reverse());o-- >0;)r=e(t.styles[s[o]],r,n);return r},s=(e,s,r)=>{t.styles[e]=(t=>{let e=t.open=`[${t.codes[0]}m`,i=t.close=`[${t.codes[1]}m`,s=t.regex=new RegExp(`\\u001b\\[${t.codes[1]}m`,"g");return t.wrap=(t,r)=>{t.includes(i)&&(t=t.replace(s,i+e));let n=e+t+i;return r?n.replace(/\r*\n/g,`${i}$&${e}`):n},t})({name:e,codes:s}),(t.keys[r]||(t.keys[r]=[])).push(e),Reflect.defineProperty(t,e,{configurable:!0,enumerable:!0,set(i){t.alias(e,i)},get(){let s=t=>i(t,s.stack);return Reflect.setPrototypeOf(s,t),s.stack=this.stack?this.stack.concat(e):[e],s}})};return s("reset",[0,0],"modifier"),s("bold",[1,22],"modifier"),s("dim",[2,22],"modifier"),s("italic",[3,23],"modifier"),s("underline",[4,24],"modifier"),s("inverse",[7,27],"modifier"),s("hidden",[8,28],"modifier"),s("strikethrough",[9,29],"modifier"),s("black",[30,39],"color"),s("red",[31,39],"color"),s("green",[32,39],"color"),s("yellow",[33,39],"color"),s("blue",[34,39],"color"),s("magenta",[35,39],"color"),s("cyan",[36,39],"color"),s("white",[37,39],"color"),s("gray",[90,39],"color"),s("grey",[90,39],"color"),s("bgBlack",[40,49],"bg"),s("bgRed",[41,49],"bg"),s("bgGreen",[42,49],"bg"),s("bgYellow",[43,49],"bg"),s("bgBlue",[44,49],"bg"),s("bgMagenta",[45,49],"bg"),s("bgCyan",[46,49],"bg"),s("bgWhite",[47,49],"bg"),s("blackBright",[90,39],"bright"),s("redBright",[91,39],"bright"),s("greenBright",[92,39],"bright"),s("yellowBright",[93,39],"bright"),s("blueBright",[94,39],"bright"),s("magentaBright",[95,39],"bright"),s("cyanBright",[96,39],"bright"),s("whiteBright",[97,39],"bright"),s("bgBlackBright",[100,49],"bgBright"),s("bgRedBright",[101,49],"bgBright"),s("bgGreenBright",[102,49],"bgBright"),s("bgYellowBright",[103,49],"bgBright"),s("bgBlueBright",[104,49],"bgBright"),s("bgMagentaBright",[105,49],"bgBright"),s("bgCyanBright",[106,49],"bgBright"),s("bgWhiteBright",[107,49],"bgBright"),t.ansiRegex=Et,t.hasColor=t.hasAnsi=e=>(t.ansiRegex.lastIndex=0,"string"==typeof e&&""!==e&&t.ansiRegex.test(e)),t.alias=(e,s)=>{let r="string"==typeof s?t[s]:s;if("function"!=typeof r)throw new TypeError("Expected alias to be the name of an existing color (string) or a function");r.stack||(Reflect.defineProperty(r,"name",{value:e}),t.styles[e]=r,r.stack=[e]),Reflect.defineProperty(t,e,{configurable:!0,enumerable:!0,set(i){t.alias(e,i)},get(){let e=t=>i(t,e.stack);return Reflect.setPrototypeOf(e,t),e.stack=this.stack?this.stack.concat(r.stack):r.stack,e}})},t.theme=e=>{if(null===(i=e)||"object"!=typeof i||Array.isArray(i))throw new TypeError("Expected theme to be an object");var i;for(let i of Object.keys(e))t.alias(i,e[i]);return t},t.alias("unstyle",e=>"string"==typeof e&&""!==e?(t.ansiRegex.lastIndex=0,e.replace(t.ansiRegex,"")):""),t.alias("noop",t=>t),t.none=t.clear=t.noop,t.stripColor=t.unstyle,t.symbols=(xt||(xt=1,function(t){const e="undefined"!=typeof process&&"Hyper"===process.env.TERM_PROGRAM,i="undefined"!=typeof process&&"win32"===process.platform,s="undefined"!=typeof process&&"linux"===process.platform,r={ballotDisabled:"☒",ballotOff:"☐",ballotOn:"☑",bullet:"•",bulletWhite:"◦",fullBlock:"█",heart:"❤",identicalTo:"≡",line:"─",mark:"※",middot:"·",minus:"-",multiplication:"×",obelus:"÷",pencilDownRight:"✎",pencilRight:"✏",pencilUpRight:"✐",percent:"%",pilcrow2:"❡",pilcrow:"¶",plusMinus:"±",question:"?",section:"§",starsOff:"☆",starsOn:"★",upDownArrow:"↕"},n=Object.assign({},r,{check:"√",cross:"×",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"»",radioOff:"( )",radioOn:"(*)",warning:"‼"}),o=Object.assign({},r,{ballotCross:"✘",check:"✔",cross:"✖",ellipsisLarge:"⋯",ellipsis:"…",info:"ℹ",questionFull:"?",questionSmall:"﹖",pointer:s?"▸":"❯",pointerSmall:s?"‣":"›",radioOff:"◯",radioOn:"◉",warning:"⚠"});t.exports=i&&!e?n:o,Reflect.defineProperty(t.exports,"common",{enumerable:!1,value:r}),Reflect.defineProperty(t.exports,"windows",{enumerable:!1,value:n}),Reflect.defineProperty(t.exports,"other",{enumerable:!1,value:o})}(kt)),kt.exports),t.define=s,t};Ct.exports=At(),Ct.exports.create=At;var $t,Pt,Dt,Tt,jt=Ct.exports;function Nt(){return Pt?$t:(Pt=1,$t=({onlyFirst:t=!1}={})=>{const e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,t?void 0:"g")})}function Ft(){if(Tt)return Dt;Tt=1;const t=Nt();return Dt=e=>"string"==typeof e?e.replace(t(),""):e,Dt}!function(t){const e=Object.prototype.toString,i=jt;let s=!1,r=new Set;const n={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};t.longest=(t,e)=>t.reduce((t,i)=>Math.max(t,e?i[e].length:i.length),0),t.hasColor=t=>!!t&&i.hasColor(t);const o=t.isObject=t=>null!==t&&"object"==typeof t&&!Array.isArray(t);t.nativeType=t=>e.call(t).slice(8,-1).toLowerCase().replace(/\s/g,""),t.isAsyncFn=e=>"asyncfunction"===t.nativeType(e),t.isPrimitive=t=>null!=t&&"object"!=typeof t&&"function"!=typeof t,t.resolve=(t,e,...i)=>"function"==typeof e?e.call(t,...i):e,t.scrollDown=(t=[])=>[...t.slice(1),t[0]],t.scrollUp=(t=[])=>[t.pop(),...t],t.reorder=(t=[])=>{let e=t.slice();return e.sort((t,e)=>t.index>e.index?1:t.index<e.index?-1:0),e},t.swap=(t,e,i)=>{let s=t.length,r=i===s?0:i<0?s-1:i,n=t[e];t[e]=t[r],t[r]=n},t.width=(t,e=80)=>{let i=t&&t.columns?t.columns:e;return t&&"function"==typeof t.getWindowSize&&(i=t.getWindowSize()[0]),"win32"===process.platform?i-1:i},t.height=(t,e=20)=>{let i=t&&t.rows?t.rows:e;return t&&"function"==typeof t.getWindowSize&&(i=t.getWindowSize()[1]),i},t.wordWrap=(t,e={})=>{if(!t)return t;"number"==typeof e&&(e={width:e});let{indent:i="",newline:s="\n"+i,width:r=80}=e,n=(s+i).match(/[^\S\n]/g)||[];r-=n.length;let o=`.{1,${r}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,a=t.trim(),l=new RegExp(o,"g"),c=a.match(l)||[];return c=c.map(t=>t.replace(/\n$/,"")),e.padEnd&&(c=c.map(t=>t.padEnd(r," "))),e.padStart&&(c=c.map(t=>t.padStart(r," "))),i+c.join(s)},t.unmute=t=>{let e=t.stack.find(t=>i.keys.color.includes(t));return e?i[e]:t.stack.find(t=>"bg"===t.slice(2))?i[e.slice(2)]:t=>t},t.pascal=t=>t?t[0].toUpperCase()+t.slice(1):"",t.inverse=e=>{if(!e||!e.stack)return e;let s=e.stack.find(t=>i.keys.color.includes(t));if(s){let r=i["bg"+t.pascal(s)];return r?r.black:e}let r=e.stack.find(t=>"bg"===t.slice(0,2));return r?i[r.slice(2).toLowerCase()]||e:i.none},t.complement=e=>{if(!e||!e.stack)return e;let s=e.stack.find(t=>i.keys.color.includes(t)),r=e.stack.find(t=>"bg"===t.slice(0,2));if(s&&!r)return i[n[s]||s];if(r){let s=r.slice(2).toLowerCase(),o=n[s];return o&&i["bg"+t.pascal(o)]||e}return i.none},t.meridiem=t=>{let e=t.getHours(),i=t.getMinutes(),s=e>=12?"pm":"am";return e%=12,(0===e?12:e)+":"+(i<10?"0"+i:i)+" "+s},t.set=(e={},i="",s)=>i.split(".").reduce((e,i,r,n)=>{let o=n.length-1>r?e[i]||{}:s;return!t.isObject(o)&&r<n.length-1&&(o={}),e[i]=o},e),t.get=(t={},e="",i)=>{let s=null==t[e]?e.split(".").reduce((t,e)=>t&&t[e],t):t[e];return null==s?i:s},t.mixin=(e,i)=>{if(!o(e))return i;if(!o(i))return e;for(let s of Object.keys(i)){let r=Object.getOwnPropertyDescriptor(i,s);if(hasOwnProperty.call(r,"value"))if(hasOwnProperty.call(e,s)&&o(r.value)){let n=Object.getOwnPropertyDescriptor(e,s);o(n.value)&&n.value!==r.value?e[s]=t.merge({},e[s],i[s]):Reflect.defineProperty(e,s,r)}else Reflect.defineProperty(e,s,r);else Reflect.defineProperty(e,s,r)}return e},t.merge=(...e)=>{let i={};for(let s of e)t.mixin(i,s);return i},t.mixinEmitter=(e,i)=>{let s=i.constructor.prototype;for(let r of Object.keys(s)){let n=s[r];"function"==typeof n?t.define(e,r,n.bind(i)):t.define(e,r,n)}};const a=(t,e)=>{s||(s=!0,r.forEach(t=>t()),!0===t&&process.exit(128+e))},l=a.bind(null,!0,15),c=a.bind(null,!0,2);t.onExit=t=>(0===r.size&&(process.once("SIGTERM",l),process.once("SIGINT",c),process.once("exit",a)),r.add(t),()=>{r.delete(t),0===r.size&&(process.off("SIGTERM",l),process.off("SIGINT",c),process.off("exit",a))}),t.define=(t,e,i)=>{Reflect.defineProperty(t,e,{value:i})},t.defineExport=(t,e,i)=>{let s;Reflect.defineProperty(t,e,{enumerable:!0,configurable:!0,set(t){s=t},get:()=>s?s():i()})}}(Ot);var It,Rt,Lt,Vt,Mt,Ht,Wt,Bt,qt,Ut,zt,Jt,Gt,Kt,Yt,Zt={};function Xt(){return It||(It=1,Zt.ctrl={a:"first",b:"backward",c:"cancel",d:"deleteForward",e:"last",f:"forward",g:"reset",i:"tab",k:"cutForward",l:"reset",n:"newItem",m:"cancel",j:"submit",p:"search",r:"remove",s:"save",u:"undo",w:"cutLeft",x:"toggleCursor",v:"paste"},Zt.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"},Zt.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"},Zt.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"},Zt.keys={pageup:"pageUp",pagedown:"pageDown",home:"home",end:"end",cancel:"cancel",delete:"deleteForward",backspace:"delete",down:"down",enter:"submit",escape:"cancel",left:"left",space:"space",number:"number",return:"submit",right:"right",tab:"next",up:"up"}),Zt}function Qt(){if(Mt)return Vt;Mt=1;const t=p,e=Xt(),i=Lt?Rt:(Lt=1,Rt=class{_queue=[];_executing=!1;_jobRunner=null;constructor(t){this._jobRunner=t}enqueue=(...t)=>{this._queue.push(t),this._dequeue()};destroy(){this._queue.length=0,this._jobRunner=null}_dequeue(){!this._executing&&this._queue.length&&(this._executing=!0,this._jobRunner(...this._queue.shift()),setTimeout(()=>{this._executing=!1,this._dequeue()}))}}),s=/^(?:\x1b)([a-zA-Z0-9])$/,r=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,n={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"};const o=(t="",e={})=>{let i,o={name:e.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:t,raw:t,...e};if(Buffer.isBuffer(t)?t[0]>127&&void 0===t[1]?(t[0]-=128,t=""+String(t)):t=String(t):void 0!==t&&"string"!=typeof t?t=String(t):t||(t=o.sequence||""),o.sequence=o.sequence||t||o.name,"\r"===t)o.raw=void 0,o.name="return";else if("\n"===t)o.name="enter";else if("\t"===t)o.name="tab";else if("\b"===t||""===t||""===t||"\b"===t)o.name="backspace",o.meta=""===t.charAt(0);else if(""===t||""===t)o.name="escape",o.meta=2===t.length;else if(" "===t||" "===t)o.name="space",o.meta=2===t.length;else if(t<="")o.name=String.fromCharCode(t.charCodeAt(0)+"a".charCodeAt(0)-1),o.ctrl=!0;else if(1===t.length&&t>="0"&&t<="9")o.name="number";else if(1===t.length&&t>="a"&&t<="z")o.name=t;else if(1===t.length&&t>="A"&&t<="Z")o.name=t.toLowerCase(),o.shift=!0;else if(i=s.exec(t))o.meta=!0,o.shift=/^[A-Z]$/.test(i[1]);else if(i=r.exec(t)){let e=[...t];""===e[0]&&""===e[1]&&(o.option=!0);let s=[i[1],i[2],i[4],i[6]].filter(Boolean).join(""),r=(i[3]||i[5]||1)-1;o.ctrl=!!(4&r),o.meta=!!(10&r),o.shift=!!(1&r),o.code=s,o.name=n[s],o.shift=function(t){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(t)}(s)||o.shift,o.ctrl=function(t){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(t)}(s)||o.ctrl}return o};return o.listen=(e={},s)=>{let{stdin:r}=e;if(!r||r!==process.stdin&&!r.isTTY)throw new Error("Invalid stream passed");let n=t.createInterface({terminal:!0,input:r});t.emitKeypressEvents(r,n);const a=new i((t,e)=>s(t,o(t,e),n));let l=r.isRaw;r.isTTY&&r.setRawMode(!0),r.on("keypress",a.enqueue),n.resume();return()=>{r.isTTY&&r.setRawMode(l),r.removeListener("keypress",a.enqueue),a.destroy(),n.pause(),n.close()}},o.action=(t,i,s)=>{let r={...e,...s};return i.ctrl?(i.action=r.ctrl[i.name],i):i.option&&r.option?(i.action=r.option[i.name],i):i.shift?(i.action=r.shift[i.name],i):(i.action=r.keys[i.name],i)},Vt=o}function te(){if(Wt)return Ht;function t(t,e,i={}){let s=t.timers[e]={name:e,start:Date.now(),ms:0,tick:0},r=i.interval||120;s.frames=i.frames||[],s.loading=!0;let n=setInterval(()=>{s.ms=Date.now()-s.start,s.tick++,t.render()},r);return s.stop=()=>{s.loading=!1,clearInterval(n)},Reflect.defineProperty(s,"interval",{value:n}),t.once("close",()=>s.stop()),s.stop}return Wt=1,Ht=e=>{e.timers=e.timers||{};let i=e.options.timers;if(i)for(let s of Object.keys(i)){let r=i[s];"number"==typeof r&&(r={interval:r}),t(e,s,r)}},Ht}function ee(){if(Yt)return Kt;Yt=1;const t=function(){if(zt)return Ut;zt=1;const t=Ot,e=jt,i={default:e.noop,noop:e.noop,set inverse(t){this._inverse=t},get inverse(){return this._inverse||t.inverse(this.primary)},set complement(t){this._complement=t},get complement(){return this._complement||t.complement(this.primary)},primary:e.cyan,success:e.green,danger:e.magenta,strong:e.bold,warning:e.yellow,muted:e.dim,disabled:e.gray,dark:e.dim.gray,underline:e.underline,set info(t){this._info=t},get info(){return this._info||this.primary},set em(t){this._em=t},get em(){return this._em||this.primary.underline},set heading(t){this._heading=t},get heading(){return this._heading||this.muted.underline},set pending(t){this._pending=t},get pending(){return this._pending||this.primary},set submitted(t){this._submitted=t},get submitted(){return this._submitted||this.success},set cancelled(t){this._cancelled=t},get cancelled(){return this._cancelled||this.danger},set typing(t){this._typing=t},get typing(){return this._typing||this.dim},set placeholder(t){this._placeholder=t},get placeholder(){return this._placeholder||this.primary.dim},set highlight(t){this._highlight=t},get highlight(){return this._highlight||this.inverse},merge:(s={})=>{s.styles&&"boolean"==typeof s.styles.enabled&&(e.enabled=s.styles.enabled),s.styles&&"boolean"==typeof s.styles.visible&&(e.visible=s.styles.visible);let r=t.merge({},i,s.styles);delete r.merge;for(let t of Object.keys(e))hasOwnProperty.call(r,t)||Reflect.defineProperty(r,t,{get:()=>e[t]});for(let t of Object.keys(e.styles))hasOwnProperty.call(r,t)||Reflect.defineProperty(r,t,{get:()=>e[t]});return r}};return Ut=i}(),e=function(){if(Gt)return Jt;Gt=1;const t="win32"===process.platform,e=jt,i=Ot,s={...e.symbols,upDownDoubleArrow:"⇕",upDownDoubleArrow2:"⬍",upDownArrow:"↕",asterisk:"*",asterism:"⁂",bulletWhite:"◦",electricArrow:"⌁",ellipsisLarge:"⋯",ellipsisSmall:"…",fullBlock:"█",identicalTo:"≡",indicator:e.symbols.check,leftAngle:"‹",mark:"※",minus:"−",multiplication:"×",obelus:"÷",percent:"%",pilcrow:"¶",pilcrow2:"❡",pencilUpRight:"✐",pencilDownRight:"✎",pencilRight:"✏",plus:"+",plusMinus:"±",pointRight:"☞",rightAngle:"›",section:"§",hexagon:{off:"⬡",on:"⬢",disabled:"⬢"},ballot:{on:"☑",off:"☐",disabled:"☒"},stars:{on:"★",off:"☆",disabled:"☆"},folder:{on:"▼",off:"▶",disabled:"▶"},prefix:{pending:e.symbols.question,submitted:e.symbols.check,cancelled:e.symbols.cross},separator:{pending:e.symbols.pointerSmall,submitted:e.symbols.middot,cancelled:e.symbols.middot},radio:{off:t?"( )":"◯",on:t?"(*)":"◉",disabled:t?"(|)":"Ⓘ"},numbers:["⓪","①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩","⑪","⑫","⑬","⑭","⑮","⑯","⑰","⑱","⑲","⑳","㉑","㉒","㉓","㉔","㉕","㉖","㉗","㉘","㉙","㉚","㉛","㉜","㉝","㉞","㉟","㊱","㊲","㊳","㊴","㊵","㊶","㊷","㊸","㊹","㊺","㊻","㊼","㊽","㊾","㊿"]};return s.merge=t=>{let r=i.merge({},e.symbols,s,t.symbols);return delete r.merge,r},Jt=s}(),i=Ot;return Kt=s=>{s.options=i.merge({},s.options.theme,s.options),s.symbols=e.merge(s.options),s.styles=t.merge(s.options)},Kt}var ie,se,re,ne={exports:{}};function oe(){return ie||(ie=1,function(t,e){const i="Apple_Terminal"===process.env.TERM_PROGRAM,s=Ft(),r=Ot,n=t.exports=e,o="[";let a=!1;const l=n.code={bell:"",beep:"",beginning:`${o}G`,down:`${o}J`,esc:o,getPosition:`${o}6n`,hide:`${o}?25l`,line:`${o}2K`,lineEnd:`${o}K`,lineStart:`${o}1K`,restorePosition:o+(i?"8":"u"),savePosition:o+(i?"7":"s"),screen:`${o}2J`,show:`${o}?25h`,up:`${o}1J`},c=n.cursor={get hidden(){return a},hide:()=>(a=!0,l.hide),show:()=>(a=!1,l.show),forward:(t=1)=>`${o}${t}C`,backward:(t=1)=>`${o}${t}D`,nextLine:(t=1)=>`${o}E`.repeat(t),prevLine:(t=1)=>`${o}F`.repeat(t),up:(t=1)=>t?`${o}${t}A`:"",down:(t=1)=>t?`${o}${t}B`:"",right:(t=1)=>t?`${o}${t}C`:"",left:(t=1)=>t?`${o}${t}D`:"",to:(t,e)=>e?`${o}${e+1};${t+1}H`:`${o}${t+1}G`,move(t=0,e=0){let i="";return i+=t<0?c.left(-t):t>0?c.right(t):"",i+=e<0?c.up(-e):e>0?c.down(e):"",i},strLen(t){for(var e=0,i=t.length,s=-1,r=0;r<i;r++)e+=(s=t.charCodeAt(r))>=0&&s<=128?1:2;return e},restore(t={}){let{after:e,cursor:i,initial:s,input:o,prompt:a,size:l,value:c}=t;if(s=r.isPrimitive(s)?String(s):"",o=r.isPrimitive(o)?String(o):"",c=r.isPrimitive(c)?String(c):"",l){let t=n.cursor.up(l)+n.cursor.to(this.strLen(a)),e=o.length-i;return e>0&&(t+=n.cursor.left(e)),t}if(c||e){let t=!o&&s?-this.strLen(s):-this.strLen(o)+i;return e&&(t-=this.strLen(e)),""===o&&s&&!a.includes(s)&&(t+=this.strLen(s)),n.cursor.move(t)}}},h=n.erase={screen:l.screen,up:l.up,down:l.down,line:l.line,lineEnd:l.lineEnd,lineStart:l.lineStart,lines(t){let e="";for(let i=0;i<t;i++)e+=n.erase.line+(i<t-1?n.cursor.up(1):"");return t&&(e+=n.code.beginning),e}};n.clear=(t="",e=process.stdout.columns)=>{if(!e)return h.line+c.to(0);let i=t=>[...s(t)].length,r=t.split(/\r?\n/),n=0;for(let t of r)n+=1+Math.floor(Math.max(i(t)-1,0)/e);return(h.line+c.prevLine()).repeat(n-1)+h.line+c.to(0)}}(ne,ne.exports)),ne.exports}function ae(){if(re)return se;re=1;const t=u,e=Ft(),i=Qt(),s=te(),r=function(){if(qt)return Bt;qt=1;const{define:t,width:e}=Ot;return Bt=class{constructor(i){let s=i.options;t(this,"_prompt",i),this.type=i.type,this.name=i.name,this.message="",this.header="",this.footer="",this.error="",this.hint="",this.input="",this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt="",this.buffer="",this.width=e(s.stdout||process.stdout),Object.assign(this,s),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=i.symbols,this.styles=i.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let t={...this};return t.status=this.status,t.buffer=Buffer.from(t.buffer),delete t.clone,t}set color(t){this._color=t}get color(){let t=this.prompt.styles;if(this.cancelled)return t.cancelled;if(this.submitted)return t.submitted;let e=this._color||t[this.status];return"function"==typeof e?e:t.pending}set loading(t){this._loading=t}get loading(){return"boolean"==typeof this._loading?this._loading:!!this.loadingChoices&&"choices"}get status(){return this.cancelled?"cancelled":this.submitted?"submitted":"pending"}},Bt}(),n=ee(),o=Ot,a=oe();class l extends t{constructor(t={}){super(),this.name=t.name,this.type=t.type,this.options=t,n(this),s(this),this.state=new r(this),this.initial=[t.initial,t.default].find(t=>null!=t),this.stdout=t.stdout||process.stdout,this.stdin=t.stdin||process.stdin,this.scale=t.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=function(t){"number"==typeof t&&(t=[t,t,t,t]);let e=[].concat(t||[]),i=t=>t%2==0?"\n":" ",s=[];for(let t=0;t<4;t++){let r=i(t);e[t]?s.push(r.repeat(e[t])):s.push("")}return s}(this.options.margin),this.setMaxListeners(0),function(t){let e=e=>void 0===t[e]||"function"==typeof t[e],i=["actions","choices","initial","margin","roles","styles","symbols","theme","timers","value"],s=["body","footer","error","header","hint","indicator","message","prefix","separator","skip"];for(let r of Object.keys(t.options)){if(i.includes(r))continue;if(/^on[A-Z]/.test(r))continue;let n=t.options[r];"function"==typeof n&&e(r)?s.includes(r)||(t[r]=n.bind(t)):"function"!=typeof t[r]&&(t[r]=n)}}(this)}async keypress(t,e={}){this.keypressed=!0;let s=i.action(t,i(t,e),this.options.actions);this.state.keypress=s,this.emit("keypress",t,s),this.emit("state",this.state.clone());const r=this.options[s.action]||this[s.action]||this.dispatch;if("function"==typeof r)return await r.call(this,t,s);this.alert()}alert(){delete this.state.alert,!1===this.options.show?this.emit("alert"):this.stdout.write(a.code.beep)}cursorHide(){this.stdout.write(a.cursor.hide());const t=o.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),t()})}cursorShow(){this.stdout.write(a.cursor.show())}write(t){t&&(this.stdout&&!1!==this.state.show&&this.stdout.write(t),this.state.buffer+=t)}clear(t=0){let e=this.state.buffer;this.state.buffer="",(e||t)&&!1!==this.options.show&&this.stdout.write(a.cursor.down(t)+a.clear(e,this.width))}restore(){if(this.state.closed||!1===this.options.show)return;let{prompt:t,after:e,rest:i}=this.sections(),{cursor:s,initial:r="",input:n="",value:o=""}=this,l={after:e,cursor:s,initial:r,input:n,prompt:t,size:this.state.size=i.length,value:o},c=a.cursor.restore(l);c&&this.stdout.write(c)}sections(){let{buffer:t,input:i,prompt:s}=this.state;s=e(s);let r=e(t),n=r.indexOf(s),o=r.slice(0,n),a=r.slice(n).split("\n"),l=a[0],c=a[a.length-1],h=(s+(i?" "+i:"")).length,u=h<l.length?l.slice(h+1):"";return{header:o,prompt:l,after:u,rest:a.slice(1),last:c}}async submit(){this.state.submitted=!0,this.state.validating=!0,this.options.onSubmit&&await this.options.onSubmit.call(this,this.name,this.value,this);let t=this.state.error||await this.validate(this.value,this.state);if(!0!==t){let e="\n"+this.symbols.pointer+" ";return e+="string"==typeof t?t.trim():"Invalid input",this.state.error="\n"+this.styles.danger(e),this.state.submitted=!1,await this.render(),await this.alert(),this.state.validating=!1,void(this.state.error=void 0)}this.state.validating=!1,await this.render(),await this.close(),this.value=await this.result(this.value),this.emit("submit",this.value)}async cancel(t){this.state.cancelled=this.state.submitted=!0,await this.render(),await this.close(),"function"==typeof this.options.onCancel&&await this.options.onCancel.call(this,this.name,this.value,this),this.emit("cancel",await this.error(t))}async close(){this.state.closed=!0;try{let t=this.sections(),e=Math.ceil(t.prompt.length/this.width);t.rest&&this.write(a.cursor.down(t.rest.length)),this.write("\n".repeat(e))}catch(t){}this.emit("close")}start(){this.stop||!1===this.options.show||(this.stop=i.listen(this,this.keypress.bind(this)),this.once("close",this.stop),this.emit("start",this))}async skip(){return this.skipped=!0===this.options.skip,"function"==typeof this.options.skip&&(this.skipped=await this.options.skip.call(this,this.name,this.value)),this.skipped}async initialize(){let{format:t,options:e,result:i}=this;if(this.format=()=>t.call(this,this.value),this.result=()=>i.call(this,this.value),"function"==typeof e.initial&&(this.initial=await e.initial.call(this,this)),"function"==typeof e.onRun&&await e.onRun.call(this,this),"function"==typeof e.onSubmit){let t=e.onSubmit.bind(this),i=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>(await t(this.name,this.value,this),i())}await this.start(),await this.render()}render(){throw new Error("expected prompt to have a custom render method")}run(){return new Promise(async(t,e)=>{if(this.once("submit",t),this.once("cancel",e),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit("run")})}async element(t,e,i){let{options:s,state:r,symbols:n,timers:o}=this,a=o&&o[t];r.timer=a;let l=s[t]||r[t]||n[t],c=e&&null!=e[t]?e[t]:await l;if(""===c)return c;let h=await this.resolve(c,r,e,i);return!h&&e&&e[t]?this.resolve(l,r,e,i):h}async prefix(){let t=await this.element("prefix")||this.symbols,e=this.timers&&this.timers.prefix,i=this.state;if(i.timer=e,o.isObject(t)&&(t=t[i.status]||t.pending),!o.hasColor(t)){return(this.styles[i.status]||this.styles.pending)(t)}return t}async message(){let t=await this.element("message");return o.hasColor(t)?t:this.styles.strong(t)}async separator(){let t=await this.element("separator")||this.symbols,e=this.timers&&this.timers.separator,i=this.state;i.timer=e;let s=t[i.status]||t.pending||i.separator,r=await this.resolve(s,i);return o.isObject(r)&&(r=r[i.status]||r.pending),o.hasColor(r)?r:this.styles.muted(r)}async pointer(t,e){let i=await this.element("pointer",t,e);if("string"==typeof i&&o.hasColor(i))return i;if(i){let t=this.styles,s=this.index===e,r=s?t.primary:t=>t,n=await this.resolve(i[s?"on":"off"]||i,this.state),a=o.hasColor(n)?n:r(n);return s?a:" ".repeat(n.length)}}async indicator(t,e){let i=await this.element("indicator",t,e);if("string"==typeof i&&o.hasColor(i))return i;if(i){let e=this.styles,s=!0===t.enabled,r=s?e.success:e.dark,n=i[s?"on":"off"]||i;return o.hasColor(n)?n:r(n)}return""}body(){return null}footer(){if("pending"===this.state.status)return this.element("footer")}header(){if("pending"===this.state.status)return this.element("header")}async hint(){if("pending"===this.state.status&&!this.isValue(this.state.input)){let t=await this.element("hint");return o.hasColor(t)?t:this.styles.muted(t)}}error(t){return this.state.submitted?"":t||this.state.error}format(t){return t}result(t){return t}validate(t){return!0!==this.options.required||this.isValue(t)}isValue(t){return null!=t&&""!==t}resolve(t,...e){return o.resolve(this,t,...e)}get base(){return l.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||o.height(this.stdout,25)}get width(){return this.options.columns||o.width(this.stdout,80)}get size(){return{width:this.width,height:this.height}}set cursor(t){this.state.cursor=t}get cursor(){return this.state.cursor}set input(t){this.state.input=t}get input(){return this.state.input}set value(t){this.state.value=t}get value(){let{input:t,value:e}=this.state,i=[e,t].find(this.isValue.bind(this));return this.isValue(i)?i:this.initial}static get prompt(){return t=>new this(t).run()}}return se=l}var le,ce,he,ue,pe,de,me,fe,ge,ye,we,be,ve,_e,Se,xe,Oe,Ce,ke,Ee,Ae,$e,Pe,De,Te,je,Ne,Fe,Ie,Re,Le,Ve,Me,He,We,Be,qe,Ue,ze,Je,Ge,Ke,Ye,Ze,Xe,Qe,ti,ei,ii,si,ri,ni,oi,ai,li,ci,hi,ui,pi,di={};function mi(){if(ue)return he;ue=1;const t=Ft(),e=ae(),i=function(){if(ce)return le;ce=1;const t=Ot,e={default:(t,e)=>e,checkbox(t,e){throw new Error("checkbox role is not implemented yet")},editable(t,e){throw new Error("editable role is not implemented yet")},expandable(t,e){throw new Error("expandable role is not implemented yet")},heading:(t,e)=>(e.disabled="",e.indicator=[e.indicator," "].find(t=>null!=t),e.message=e.message||"",e),input(t,e){throw new Error("input role is not implemented yet")},option:(t,i)=>e.default(t,i),radio(t,e){throw new Error("radio role is not implemented yet")},separator:(t,e)=>(e.disabled="",e.indicator=[e.indicator," "].find(t=>null!=t),e.message=e.message||t.symbols.line.repeat(5),e),spacer:(t,e)=>e};return le=(i,s={})=>{let r=t.merge({},e,s.roles);return r[i]||r.default}}(),s=Ot,{reorder:r,scrollUp:n,scrollDown:o,isObject:a,swap:l}=s;function c(t,e){if(e instanceof Promise)return e;if("function"==typeof e){if(s.isAsyncFn(e))return e;e=e.call(t,t)}for(let i of e){if(Array.isArray(i.choices)){let e=i.choices.filter(e=>!t.isDisabled(e));i.enabled=e.every(t=>!0===t.enabled)}!0===t.isDisabled(i)&&delete i.enabled}return e}return he=class extends e{constructor(t){super(t),this.cursorHide(),this.maxSelected=t.maxSelected||1/0,this.multiple=t.multiple||!1,this.initial=t.initial||0,this.delay=t.delay||0,this.longest=0,this.num=""}async initialize(){"function"==typeof this.options.initial&&(this.initial=await this.options.initial.call(this)),await this.reset(!0),await super.initialize()}async reset(){let{choices:t,initial:e,autofocus:i,suggest:s}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(t)),this.choices.forEach(t=>t.enabled=!1),"function"!=typeof s&&0===this.selectable.length)throw new Error("At least one choice must be selectable");a(e)&&(e=Object.keys(e)),Array.isArray(e)?(null!=i&&(this.index=this.findIndex(i)),e.forEach(t=>this.enable(this.find(t))),await this.render()):(null!=i&&(e=i),"string"==typeof e&&(e=this.findIndex(e)),"number"==typeof e&&e>-1&&(this.index=Math.max(0,Math.min(e,this.choices.length)),this.enable(this.find(this.index)))),this.isDisabled(this.focused)&&await this.down()}async toChoices(t,e){this.state.loadingChoices=!0;let i=[],s=0,r=async(t,e)=>{"function"==typeof t&&(t=await t.call(this)),t instanceof Promise&&(t=await t);for(let n=0;n<t.length;n++){let o=t[n]=await this.toChoice(t[n],s++,e);i.push(o),o.choices&&await r(o.choices,o)}return i};return r(t,e).then(t=>(this.state.loadingChoices=!1,t))}async toChoice(e,r,n){if("function"==typeof e&&(e=await e.call(this,this)),e instanceof Promise&&(e=await e),"string"==typeof e&&(e={name:e}),e.normalized)return e;e.normalized=!0;let o=e.value,a=i(e.role,this.options);if("string"!=typeof(e=a(this,e)).disabled||e.hint||(e.hint=e.disabled,e.disabled=!0),!0===e.disabled&&null==e.hint&&(e.hint="(disabled)"),null!=e.index)return e;e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||"",e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input="",e.index=r,e.cursor=0,s.define(e,"parent",n),e.level=n?n.level+1:1,null==e.indent&&(e.indent=n?n.indent+" ":e.indent||""),e.path=n?n.path+"."+e.name:e.name,e.enabled=!(!this.multiple||this.isDisabled(e)||!e.enabled&&!this.isSelected(e)),this.isDisabled(e)||(this.longest=Math.max(this.longest,t(e.message).length));let l={...e};return e.reset=(t=l.input,i=l.value)=>{for(let t of Object.keys(l))e[t]=l[t];e.input=t,e.value=i},null==o&&"function"==typeof e.initial&&(e.input=await e.initial.call(this,this.state,e,r)),e}async onChoice(t,e){this.emit("choice",t,e,this),"function"==typeof t.onChoice&&await t.onChoice.call(this,this.state,t,e)}async addChoice(t,e,i){let s=await this.toChoice(t,e,i);return this.choices.push(s),this.index=this.choices.length-1,this.limit=this.choices.length,s}async newItem(t,e,i){let s={name:"New choice name?",editable:!0,newChoice:!0,...t},r=await this.addChoice(s,e,i);return r.updateChoice=()=>{delete r.newChoice,r.name=r.message=r.input,r.input="",r.cursor=0},this.render()}indent(t){return null==t.indent?t.level>1?" ".repeat(t.level-1):"":t.indent}dispatch(t,e){if(this.multiple&&this[e.name])return this[e.name]();this.alert()}focus(t,e){return"boolean"!=typeof e&&(e=t.enabled),e&&!t.enabled&&this.selected.length>=this.maxSelected?this.alert():(this.index=t.index,t.enabled=e&&!this.isDisabled(t),t)}space(){return this.multiple?this.focused?(this.toggle(this.focused),this.render()):void 0:this.alert()}a(){if(this.maxSelected<this.choices.length)return this.alert();let t=this.selectable.every(t=>t.enabled);return this.choices.forEach(e=>e.enabled=!t),this.render()}i(){return this.choices.length-this.selected.length>this.maxSelected?this.alert():(this.choices.forEach(t=>t.enabled=!t.enabled),this.render())}g(){if(!this.choices.some(t=>!!t.parent))return this.a();const t=this.focused;return this.toggle(t.parent&&!t.choices?t.parent:t),this.render()}toggle(t,e){if(!t.enabled&&this.selected.length>=this.maxSelected)return this.alert();"boolean"!=typeof e&&(e=!t.enabled),t.enabled=e,t.choices&&t.choices.forEach(t=>this.toggle(t,e));let i=t.parent;for(;i;){let t=i.choices.filter(t=>this.isDisabled(t));i.enabled=t.every(t=>!0===t.enabled),i=i.parent}return c(this,this.choices),this.emit("toggle",t,this),t}enable(t){return this.selected.length>=this.maxSelected?this.alert():(t.enabled=!this.isDisabled(t),t.choices&&t.choices.forEach(this.enable.bind(this)),t)}disable(t){return t.enabled=!1,t.choices&&t.choices.forEach(this.disable.bind(this)),t}number(t){this.num+=t;let e=t=>{let e=Number(t);if(e>this.choices.length-1)return this.alert();let i=this.focused,s=this.choices.find(t=>e===t.index);if(!s.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(-1===this.visible.indexOf(s)){let t=r(this.choices),e=t.indexOf(s);if(i.index>e){let i=t.slice(e,e+this.limit),s=t.filter(t=>!i.includes(t));this.choices=i.concat(s)}else{let i=e-this.limit+1;this.choices=t.slice(i).concat(t.slice(0,i))}}return this.index=this.choices.indexOf(s),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(t=>{let i=this.choices.length,s=this.num,r=(i=!1,r)=>{clearTimeout(this.numberTimeout),i&&(r=e(s)),this.num="",t(r)};return"0"===s||1===s.length&&Number(s+"0")>i?r(!0):Number(s)>i?r(!1,this.alert()):void(this.numberTimeout=setTimeout(()=>r(!0),this.delay))})}home(){return this.choices=r(this.choices),this.index=0,this.render()}end(){let t=this.choices.length-this.limit,e=r(this.choices);return this.choices=e.slice(t).concat(e.slice(0,t)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){return this.visible.length<=1?this.alert():this.up()}next(){return this.visible.length<=1?this.alert():this.down()}right(){return this.cursor>=this.input.length?this.alert():(this.cursor++,this.render())}left(){return this.cursor<=0?this.alert():(this.cursor--,this.render())}up(){let t=this.choices.length,e=this.visible.length,i=this.index;return!1===this.options.scroll&&0===i?this.alert():t>e&&0===i?this.scrollUp():(this.index=(i-1%t+t)%t,this.isDisabled()&&!this.allChoicesAreDisabled()?this.up():this.render())}down(){let t=this.choices.length,e=this.visible.length,i=this.index;return!1===this.options.scroll&&i===e-1?this.alert():t>e&&i===e-1?this.scrollDown():(this.index=(i+1)%t,this.isDisabled()&&!this.allChoicesAreDisabled()?this.down():this.render())}scrollUp(t=0){return this.choices=n(this.choices),this.index=t,this.isDisabled()?this.up():this.render()}scrollDown(t=this.visible.length-1){return this.choices=o(this.choices),this.index=t,this.isDisabled()?this.down():this.render()}async shiftUp(){return!0===this.options.sort?(this.sorting=!0,this.swap(this.index-1),await this.up(),void(this.sorting=!1)):this.scrollUp(this.index)}async shiftDown(){return!0===this.options.sort?(this.sorting=!0,this.swap(this.index+1),await this.down(),void(this.sorting=!1)):this.scrollDown(this.index)}pageUp(){return this.visible.length<=1?this.alert():(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled()?this.up():this.render())}pageDown(){return this.visible.length>=this.choices.length?this.alert():(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled()?this.down():this.render())}swap(t){l(this.choices,this.index,t)}allChoicesAreDisabled(t=this.choices){return t.every(t=>this.isDisabled(t))}isDisabled(t=this.focused){return!(!t||!["disabled","collapsed","hidden","completing","readonly"].some(e=>!0===t[e]))||t&&"heading"===t.role}isEnabled(t=this.focused){if(Array.isArray(t))return t.every(t=>this.isEnabled(t));if(t.choices){let e=t.choices.filter(t=>!this.isDisabled(t));return t.enabled&&e.every(t=>this.isEnabled(t))}return t.enabled&&!this.isDisabled(t)}isChoice(t,e){return t.name===e||t.index===Number(e)}isSelected(t){return Array.isArray(this.initial)?this.initial.some(e=>this.isChoice(t,e)):this.isChoice(t,this.initial)}map(t=[],e="value"){return[].concat(t||[]).reduce((t,i)=>(t[i]=this.find(i,e),t),{})}filter(t,e){let i="function"==typeof t?t:(e,i)=>[e.name,i].includes(t),s=(this.options.multiple?this.state._choices:this.choices).filter(i);return e?s.map(t=>t[e]):s}find(t,e){if(a(t))return e?t[e]:t;let i="function"==typeof t?t:(e,i)=>[e.name,i].includes(t),s=this.choices.find(i);return s?e?s[e]:s:void 0}findIndex(t){return this.choices.indexOf(this.find(t))}async submit(){let t=this.focused;if(!t)return this.alert();if(t.newChoice)return t.input?(t.updateChoice(),this.render()):this.alert();if(this.choices.some(t=>t.newChoice))return this.alert();let{reorder:e,sort:i}=this.options,r=!0===this.multiple,n=this.selected;return void 0===n?this.alert():(Array.isArray(n)&&!1!==e&&!0!==i&&(n=s.reorder(n)),this.value=r?n.map(t=>t.name):n.name,super.submit())}set choices(t=[]){this.state._choices=this.state._choices||[],this.state.choices=t;for(let e of t)this.state._choices.some(t=>t.name===e.name)||this.state._choices.push(e);if(!this._initial&&this.options.initial){this._initial=!0;let t=this.initial;if("string"==typeof t||"number"==typeof t){let e=this.find(t);e&&(this.initial=e.index,this.focus(e,!0))}}}get choices(){return c(this,this.state.choices||[])}set visible(t){this.state.visible=t}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(t){this.state.limit=t}get limit(){let{state:t,options:e,choices:i}=this,s=t.limit||this._limit||e.limit||i.length;return Math.min(s,this.height)}set value(t){super.value=t}get value(){return"string"!=typeof super.value&&super.value===this.initial?this.input:super.value}set index(t){this.state.index=t}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let t=this.choices[this.index];return t&&this.state.submitted&&!0!==this.multiple&&(t.enabled=!0),t}get selectable(){return this.choices.filter(t=>!this.isDisabled(t))}get selected(){return this.multiple?this.enabled:this.focused}},he}function fi(){if(de)return pe;de=1;const t=mi(),e=Ot;return pe=class extends t{constructor(t){super(t),this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(t,e){if(this.multiple)return this[e.name]?await this[e.name](t,e):await super.dispatch(t,e);this.alert()}separator(){if(this.options.separator)return super.separator();let t=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():t}pointer(t,e){return!this.multiple||this.options.pointer?super.pointer(t,e):""}indicator(t,e){return this.multiple?super.indicator(t,e):""}choiceMessage(t,i){let s=this.resolve(t.message,this.state,t,i);return"heading"!==t.role||e.hasColor(s)||(s=this.styles.strong(s)),this.resolve(s,this.state,t,i)}choiceSeparator(){return":"}async renderChoice(t,i){await this.onChoice(t,i);let s=this.index===i,r=await this.pointer(t,i),n=await this.indicator(t,i)+(t.pad||""),o=await this.resolve(t.hint,this.state,t,i);o&&!e.hasColor(o)&&(o=this.styles.muted(o));let a=this.indent(t),l=await this.choiceMessage(t,i),c=()=>[this.margin[3],a+r+n,l,this.margin[1],o].filter(Boolean).join(" ");return"heading"===t.role?c():t.disabled?(e.hasColor(l)||(l=this.styles.disabled(l)),c()):(s&&(l=this.styles.em(l)),c())}async renderChoices(){if("choices"===this.state.loading)return this.styles.warning("Loading choices");if(this.state.submitted)return"";let t=this.visible.map(async(t,e)=>await this.renderChoice(t,e)),e=await Promise.all(t);e.length||e.push(this.styles.danger("No matching choices"));let i,s=this.margin[0]+e.join("\n");return this.options.choicesHeader&&(i=await this.resolve(this.options.choicesHeader,this.state)),[i,s].filter(Boolean).join("\n")}format(){return!this.state.submitted||this.state.cancelled?"":Array.isArray(this.selected)?this.selected.map(t=>this.styles.primary(t.name)).join(", "):this.styles.primary(this.selected.name)}async render(){let{submitted:t,size:e}=this.state,i="",s=await this.header(),r=await this.prefix(),n=await this.separator(),o=await this.message();!1!==this.options.promptLine&&(i=[r,o,n,""].join(" "),this.state.prompt=i);let a=await this.format(),l=await this.error()||await this.hint(),c=await this.renderChoices(),h=await this.footer();a&&(i+=a),l&&!i.includes(l)&&(i+=" "+l),t&&!a&&!c.trim()&&this.multiple&&null!=this.emptyError&&(i+=this.styles.danger(this.emptyError)),this.clear(e),this.write([s,i,c,h].filter(Boolean).join("\n")),this.write(this.margin[2]),this.restore()}},pe}function gi(){if(fe)return me;fe=1;const t=fi();return me=class extends t{constructor(t){super(t),this.cursorShow()}moveCursor(t){this.state.cursor+=t}dispatch(t){return this.append(t)}space(t){return this.options.multiple?super.space(t):this.append(t)}append(t){let{cursor:e,input:i}=this.state;return this.input=i.slice(0,e)+t+i.slice(e),this.moveCursor(1),this.complete()}delete(){let{cursor:t,input:e}=this.state;return e?(this.input=e.slice(0,t-1)+e.slice(t),this.moveCursor(-1),this.complete()):this.alert()}deleteForward(){let{cursor:t,input:e}=this.state;return void 0===e[t]?this.alert():(this.input=`${e}`.slice(0,t)+`${e}`.slice(t+1),this.complete())}number(t){return this.append(t)}async complete(){this.completing=!0,this.choices=await this.suggest(this.input,this.state._choices),this.state.limit=void 0,this.index=Math.min(Math.max(this.visible.length-1,0),this.index),await this.render(),this.completing=!1}suggest(t=this.input,e=this.state._choices){if("function"==typeof this.options.suggest)return this.options.suggest.call(this,t,e);let i=t.toLowerCase();return e.filter(t=>t.message.toLowerCase().includes(i))}pointer(){return""}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map(t=>this.styles.primary(t.message)).join(", ");if(this.state.submitted){let t=this.value=this.input=this.focused.value;return this.styles.primary(t)}return this.input}async render(){if("pending"!==this.state.status)return super.render();const t=this.options.highlight||this.styles.complement,e=((t,e)=>{const i=t?new RegExp(t,"ig"):/$^/;return s=>t?s.replace(i,t=>e(t)):s})(this.input,(e,i)=>e?t.stack?t(e):t.call(this,e):e),i=this.choices;this.choices=i.map(t=>({...t,message:e(t.message)})),await super.render(),this.choices=i}submit(){return this.options.multiple&&(this.value=this.selected.map(t=>t.name)),super.submit()}},me}function yi(){if(ye)return ge;ye=1;const t=Ot;return ge=(e,i={})=>{e.cursorHide();let{input:s="",initial:r="",pos:n,showCursor:o=!0,color:a}=i,l=a||e.styles.placeholder,c=t.inverse(e.styles.primary),h=t=>c(e.styles.black(t)),u=s,p=h(" ");if(e.blink&&!0===e.blink.off&&(h=t=>t,p=""),o&&0===n&&""===r&&""===s)return h(" ");if(o&&0===n&&(s===r||""===s))return h(r[0])+l(r.slice(1));r=t.isPrimitive(r)?`${r}`:"",s=t.isPrimitive(s)?`${s}`:"";let d=r&&r.startsWith(s)&&r!==s,m=d?h(r[s.length]):p;if(n!==s.length&&!0===o&&(u=s.slice(0,n)+h(s[n])+s.slice(n+1),m=""),!1===o&&(m=""),d){let t=e.styles.unstyle(u+m);return u+m+l(r.slice(t.length))}return u+m},ge}function wi(){if(be)return we;be=1;const t=Ft(),e=fi(),i=yi();return we=class extends e{constructor(t){super({...t,multiple:!0}),this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find(t=>null!=t),this.emptyError="",this.values={}}async reset(t){return await super.reset(),!0===t&&(this._index=this.index),this.index=this._index,this.values={},this.choices.forEach(t=>t.reset&&t.reset()),this.render()}dispatch(t){return!!t&&this.append(t)}append(t){let e=this.focused;if(!e)return this.alert();let{cursor:i,input:s}=e;return e.value=e.input=s.slice(0,i)+t+s.slice(i),e.cursor++,this.render()}delete(){let t=this.focused;if(!t||t.cursor<=0)return this.alert();let{cursor:e,input:i}=t;return t.value=t.input=i.slice(0,e-1)+i.slice(e),t.cursor--,this.render()}deleteForward(){let t=this.focused;if(!t)return this.alert();let{cursor:e,input:i}=t;if(void 0===i[e])return this.alert();let s=`${i}`.slice(0,e)+`${i}`.slice(e+1);return t.value=t.input=s,this.render()}right(){let t=this.focused;return t?t.cursor>=t.input.length?this.alert():(t.cursor++,this.render()):this.alert()}left(){let t=this.focused;return t?t.cursor<=0?this.alert():(t.cursor--,this.render()):this.alert()}space(t,e){return this.dispatch(t,e)}number(t,e){return this.dispatch(t,e)}next(){let t=this.focused;if(!t)return this.alert();let{initial:e,input:i}=t;return e&&e.startsWith(i)&&i!==e?(t.value=t.input=e,t.cursor=t.value.length,this.render()):super.next()}prev(){let t=this.focused;return t?0===t.cursor?super.prev():(t.value=t.input="",t.cursor=0,this.render()):this.alert()}separator(){return""}format(t){return this.state.submitted?"":super.format(t)}pointer(){return""}indicator(t){return t.input?"⦿":"⊙"}async choiceSeparator(t,e){let i=await this.resolve(t.separator,this.state,t,e)||":";return i?" "+this.styles.disabled(i):""}async renderChoice(e,s){await this.onChoice(e,s);let{state:r,styles:n}=this,{cursor:o,initial:a="",name:l,input:c=""}=e,{muted:h,submitted:u,primary:p,danger:d}=n,m=this.index===s,f=e.validate||(()=>!0),g=await this.choiceSeparator(e,s),y=e.message;"right"===this.align&&(y=y.padStart(this.longest+1," ")),"left"===this.align&&(y=y.padEnd(this.longest+1," "));let w=this.values[l]=c||a,b=c?"success":"dark";!0!==await f.call(e,w,this.state)&&(b="danger");let v=(0,n[b])(await this.indicator(e,s))+(e.pad||""),_=this.indent(e),S=()=>[_,v,y+g,c].filter(Boolean).join(" ");if(r.submitted)return y=t(y),c=u(c),S();if(e.format)c=await e.format.call(this,c,e,s);else{let t=this.styles.muted;c=i(this,{input:c,initial:a,pos:o,showCursor:m,color:t})}return this.isValue(c)||(c=this.styles.muted(this.symbols.ellipsis)),e.result&&(this.values[l]=await e.result.call(this,w,e,s)),m&&(y=p(y)),e.error?c+=(c?" ":"")+d(e.error.trim()):e.hint&&(c+=(c?" ":"")+h(e.hint.trim())),S()}async submit(){return this.value=this.values,super.base.submit.call(this)}},we}function bi(){if(_e)return ve;_e=1;const t=wi(),e=()=>{throw new Error("expected prompt to have a custom authenticate method")},i=(s=e)=>class extends t{constructor(t){super(t)}async submit(){this.value=await s.call(this,this.values,this.state),super.base.submit.call(this)}static create(t){return i(t)}};return ve=i()}function vi(){if(Ce)return Oe;Ce=1;const t=ae(),{isPrimitive:e,hasColor:i}=Ot;return Oe=class extends t{constructor(t){super(t),this.cursorHide()}async initialize(){let t=await this.resolve(this.initial,this.state);this.input=await this.cast(t),await super.initialize()}dispatch(t){return this.isValue(t)?(this.input=t,this.submit()):this.alert()}format(t){let{styles:e,state:i}=this;return i.submitted?e.success(t):e.primary(t)}cast(t){return this.isTrue(t)}isTrue(t){return/^[ty1]/i.test(t)}isFalse(t){return/^[fn0]/i.test(t)}isValue(t){return e(t)&&(this.isTrue(t)||this.isFalse(t))}async hint(){if("pending"===this.state.status){let t=await this.element("hint");return i(t)?t:this.styles.muted(t)}}async render(){let{input:t,size:e}=this.state,i=await this.prefix(),s=await this.separator(),r=[i,await this.message(),this.styles.muted(this.default),s].filter(Boolean).join(" ");this.state.prompt=r;let n=await this.header(),o=this.value=this.cast(t),a=await this.format(o),l=await this.error()||await this.hint(),c=await this.footer();l&&!r.includes(l)&&(a+=" "+l),r+=" "+a,this.clear(e),this.write([n,r,c].filter(Boolean).join("\n")),this.restore()}set value(t){super.value=t}get value(){return this.cast(super.value)}},Oe}function _i(){if(De)return Pe;De=1;const t=ae(),e=Qt(),i=yi(),{isPrimitive:s}=Ot;return Pe=class extends t{constructor(t){super(t),this.initial=s(this.initial)?String(this.initial):"",this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[],this.keypressTimeout=void 0!==this.options.keypressTimeout?this.options.keypressTimeout:null}async keypress(t,i=(t?e(t,{}):{})){const s=Date.now(),r=s-this.lastKeypress;this.lastKeypress=s;const n="return"===i.name||"enter"===i.name;let o,a=this.state.prevKeypress;if(this.state.prevKeypress=i,null!=this.keypressTimeout&&n){if(r<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||"",this.state.multilineBuffer+=t,o=!0,a=null}return!(o||this.options.multiline&&n)||a&&"return"===a.name?super.keypress(t,i):this.append("\n",i)}moveCursor(t){this.cursor+=t}reset(){return this.input=this.value="",this.cursor=0,this.render()}dispatch(t,e){if(!t||e.ctrl||e.code)return this.alert();this.append(t)}append(t){let{cursor:e,input:i}=this.state;this.input=`${i}`.slice(0,e)+t+`${i}`.slice(e),this.moveCursor(String(t).length),this.render()}insert(t){this.append(t)}delete(){let{cursor:t,input:e}=this.state;if(t<=0)return this.alert();this.input=`${e}`.slice(0,t-1)+`${e}`.slice(t),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:t,input:e}=this.state;if(void 0===e[t])return this.alert();this.input=`${e}`.slice(0,t)+`${e}`.slice(t+1),this.render()}cutForward(){let t=this.cursor;if(this.input.length<=t)return this.alert();this.state.clipboard.push(this.input.slice(t)),this.input=this.input.slice(0,t),this.render()}cutLeft(){let t=this.cursor;if(0===t)return this.alert();let e=this.input.slice(0,t),i=this.input.slice(t),s=e.split(" ");this.state.clipboard.push(s.pop()),this.input=s.join(" "),this.cursor=this.input.length,this.input+=i,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){this.state.prevCursor?(this.cursor=this.state.prevCursor,this.state.prevCursor=0):(this.state.prevCursor=this.cursor,this.cursor=0),this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let t=null!=this.initial?String(this.initial):"";if(!t||!t.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){return this.cursor>=this.input.length?this.alert():(this.moveCursor(1),this.render())}left(){return this.cursor<=0?this.alert():(this.moveCursor(-1),this.render())}isValue(t){return!!t}async format(t=this.value){let e=await this.resolve(this.initial,this.state);return this.state.submitted?this.styles.submitted(t||e):i(this,{input:t,initial:e,pos:this.cursor})}async render(){let t=this.state.size,e=await this.prefix(),i=await this.separator(),s=[e,await this.message(),i].filter(Boolean).join(" ");this.state.prompt=s;let r=await this.header(),n=await this.format(),o=await this.error()||await this.hint(),a=await this.footer();o&&!n.includes(o)&&(n+=" "+o),s+=" "+n,this.clear(t),this.write([r,s,a].filter(Boolean).join("\n")),this.restore()}},Pe}function Si(){if(je)return Te;je=1;const t=t=>(t=>t.filter((e,i)=>t.lastIndexOf(e)===i))(t).filter(Boolean);return Te=(e,i={},s="")=>{let r,n,{past:o=[],present:a=""}=i;switch(e){case"prev":case"undo":return r=o.slice(0,o.length-1),n=o[o.length-1]||"",{past:t([s,...r]),present:n};case"next":case"redo":return r=o.slice(1),n=o[0]||"",{past:t([...r,s]),present:n};case"save":return{past:t([...o,s]),present:""};case"remove":return n=t(o.filter(t=>t!==s)),a="",n.length&&(a=n.pop()),{past:n,present:a};default:throw new Error(`Invalid action: "${e}"`)}}}function xi(){if(Fe)return Ne;Fe=1;const t=_i(),e=Si();return Ne=class extends t{constructor(t){super(t);let e=this.options.history;if(e&&e.store){let t=e.values||this.initial;this.autosave=!!e.autosave,this.store=e.store,this.data=this.store.get("values")||{past:[],present:t},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(t){return this.store?(this.data=e(t,this.data,this.input),this.data.present?(this.input=this.data.present,this.cursor=this.input.length,this.render()):this.alert()):this.alert()}altUp(){return this.completion("prev")}altDown(){return this.completion("next")}prev(){return this.save(),super.prev()}save(){this.store&&(this.data=e("save",this.data,this.input),this.store.set("values",this.data))}submit(){return this.store&&!0===this.autosave&&this.save(),super.submit()}}}function Oi(){if(Be)return We;Be=1;const t=_i();return We=class extends t{constructor(t={}){super({style:"number",...t}),this.min=this.isValue(t.min)?this.toNumber(t.min):-1/0,this.max=this.isValue(t.max)?this.toNumber(t.max):1/0,this.delay=null!=t.delay?t.delay:1e3,this.float=!1!==t.float,this.round=!0===t.round||!1===t.float,this.major=t.major||10,this.minor=t.minor||1,this.initial=null!=t.initial?t.initial:"",this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(t){return!/[-+.]/.test(t)||"."===t&&this.input.includes(".")?this.alert("invalid number"):super.append(t)}number(t){return super.append(t)}next(){return this.input&&this.input!==this.initial?this.alert():this.isValue(this.initial)?(this.input=this.initial,this.cursor=String(this.initial).length,this.render()):this.alert()}up(t){let e=t||this.minor,i=this.toNumber(this.input);return i>this.max+e?this.alert():(this.input=`${i+e}`,this.render())}down(t){let e=t||this.minor,i=this.toNumber(this.input);return i<this.min-e?this.alert():(this.input=""+(i-e),this.render())}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(t=this.input){return"function"==typeof this.options.format?this.options.format.call(this,t):this.styles.info(t)}toNumber(t=""){return this.float?+t:Math.round(+t)}isValue(t){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(t)}submit(){let t=[this.input,this.initial].find(t=>this.isValue(t));return this.value=this.toNumber(t||0),super.submit()}},We}function Ci(){if(Ze)return Ye;Ze=1;const t=Ft();class e{constructor(t){this.name=t.key,this.field=t.field||{},this.value=((t="")=>"string"==typeof t?t.replace(/^['"]|['"]$/g,""):"")(t.initial||this.field.initial||""),this.message=t.message||this.name,this.cursor=0,this.input="",this.lines=[]}}function i(t,e,i,s){return(i,r,n,o)=>"function"==typeof n.field[t]?n.field[t].call(e,i,r,n,o):[s,i].find(t=>e.isValue(t))}return Ye=async s=>{let r=s.options,n=new Set(!0===r.required?[]:r.required||[]),o={...r.values,...r.initial},{tabstops:a,items:l,keys:c}=await(async(t={},i={},s=t=>t)=>{let r=new Set,n=t.fields||[],o=t.template,a=[],l=[],c=[],h=1;"function"==typeof o&&(o=await o());let u=-1,p=()=>o[++u],d=()=>o[u+1],m=t=>{t.line=h,a.push(t)};for(m({type:"bos",value:""});u<o.length-1;){let t=p();if(/^[^\S\n ]$/.test(t)){m({type:"text",value:t});continue}if("\n"===t){m({type:"newline",value:t}),h++;continue}if("\\"===t){t+=p(),m({type:"text",value:t});continue}if(("$"===t||"#"===t||"{"===t)&&"{"===d()){t+=p();let o,a={type:"template",open:t,inner:"",close:"",value:t};for(;o=p();){if("}"===o){"}"===d()&&(o+=p()),a.value+=o,a.close=o;break}":"===o?(a.initial="",a.key=a.inner):void 0!==a.initial&&(a.initial+=o),a.value+=o,a.inner+=o}a.template=a.open+(a.initial||a.inner)+a.close,a.key=a.key||a.inner,hasOwnProperty.call(i,a.key)&&(a.initial=i[a.key]),a=s(a),m(a),c.push(a.key),r.add(a.key);let h=l.find(t=>t.name===a.key);a.field=n.find(t=>t.name===a.key),h||(h=new e(a),l.push(h)),h.lines.push(a.line-1);continue}let o=a[a.length-1];"text"===o.type&&o.line===h?o.value+=t:m({type:"text",value:t})}return m({type:"eos",value:""}),{input:o,tabstops:a,unique:r,keys:c,items:l}})(r,o),h=i("result",s),u=i("format",s),p=i("validate",s,r,!0),d=s.isValue.bind(s);return async(e={},i=!1)=>{let o=0;e.required=n,e.items=l,e.keys=c,e.output="";let m=async(t,e,i,s)=>{let r=await p(t,e,i,s);return!1===r?"Invalid field "+i.name:r};for(let n of a){let a=n.value,c=n.key;if("template"===n.type){if("template"===n.type){let p=l.find(t=>t.name===c);!0===r.required&&e.required.add(p.name);let f=[p.input,e.values[p.value],p.value,a].find(d),g=(p.field||{}).message||n.inner;if(i){let i=await m(e.values[c],e,p,o);if(i&&"string"==typeof i||!1===i){e.invalid.set(c,i);continue}e.invalid.delete(c);let s=await h(e.values[c],e,p,o);e.output+=t(s);continue}p.placeholder=!1;let y=a;a=await u(a,e,p,o),f!==a?(e.values[c]=f,a=s.styles.typing(f),e.missing.delete(g)):(e.values[c]=void 0,f=`<${g}>`,a=s.styles.primary(f),p.placeholder=!0,e.required.has(c)&&e.missing.add(g)),e.missing.has(g)&&e.validating&&(a=s.styles.warning(f)),e.invalid.has(c)&&e.validating&&(a=s.styles.danger(f)),o===e.index&&(a=y!==a?s.styles.underline(a):s.styles.heading(t(a))),o++}a&&(e.output+=a)}else a&&(e.output+=a)}let f=e.output.split("\n").map(t=>" "+t),g=l.length,y=0;for(let t of l)e.invalid.has(t.name)&&t.lines.forEach(t=>{" "===f[t][0]&&(f[t]=e.styles.danger(e.symbols.bullet)+f[t].slice(1))}),s.isValue(e.values[t.name])&&y++;return e.completed=(y/g*100).toFixed(0),e.output=f.join("\n"),e.output}},Ye}function ki(){if(si)return ii;si=1;const t=mi();function e(t,e={}){if(Array.isArray(e.scale))return e.scale.map(t=>({...t}));let i=[];for(let e=1;e<t+1;e++)i.push({i:e,selected:!1});return i}return ii=class extends t{constructor(t={}){if(super(t),this.emptyError=t.emptyError||"No items were selected",this.term=process.env.TERM_PROGRAM,!this.options.header){let t=["","4 - Strongly Agree","3 - Agree","2 - Neutral","1 - Disagree","0 - Strongly Disagree",""];t=t.map(t=>this.styles.muted(t)),this.state.header=t.join("\n ")}}async toChoices(...t){if(this.createdScales)return!1;this.createdScales=!0;let i=await super.toChoices(...t);for(let t of i)t.scale=e(5,this.options),t.scaleIdx=2;return i}dispatch(){this.alert()}space(){let t=this.focused,e=t.scale[t.scaleIdx],i=e.selected;return t.scale.forEach(t=>t.selected=!1),e.selected=!i,this.render()}indicator(){return""}pointer(){return""}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let t=this.focused;return t.scaleIdx>=t.scale.length-1?this.alert():(t.scaleIdx++,this.render())}left(){let t=this.focused;return t.scaleIdx<=0?this.alert():(t.scaleIdx--,this.render())}indent(){return" "}async renderChoice(t,e){await this.onChoice(t,e);let i=this.index===e,s="Hyper"===this.term,r=s?9:8,n=s?"":" ",o=this.symbols.line.repeat(r),a=" ".repeat(r+(s?0:1)),l=t=>(t?this.styles.success("◉"):"◯")+n,c=e+1+".",h=i?this.styles.heading:this.styles.noop,u=await this.resolve(t.message,this.state,t,e),p=this.indent(t),d=p+t.scale.map((e,i)=>l(i===t.scaleIdx)).join(o),m=p+t.scale.map((e,i)=>(e=>e===t.scaleIdx?h(e):e)(i)).join(a);return i&&(d=this.styles.cyan(d),m=this.styles.cyan(m)),[[c,u].filter(Boolean).join(" "),d,m," "].filter(Boolean).join("\n")}async renderChoices(){if(this.state.submitted)return"";let t=this.visible.map(async(t,e)=>await this.renderChoice(t,e)),e=await Promise.all(t);return e.length||e.push(this.styles.danger("No matching choices")),e.join("\n")}format(){if(this.state.submitted){return this.choices.map(t=>this.styles.info(t.scaleIdx)).join(", ")}return""}async render(){let{submitted:t,size:e}=this.state,i=await this.prefix(),s=await this.separator(),r=[i,await this.message(),s].filter(Boolean).join(" ");this.state.prompt=r;let n=await this.header(),o=await this.format(),a=await this.error()||await this.hint(),l=await this.renderChoices(),c=await this.footer();!o&&a||(r+=" "+o),a&&!r.includes(a)&&(r+=" "+a),t&&!o&&!l&&this.multiple&&"form"!==this.type&&(r+=this.styles.danger(this.emptyError)),this.clear(e),this.write([r,n,l,c].filter(Boolean).join("\n")),this.restore()}submit(){this.value={};for(let t of this.choices)this.value[t.name]=t.scaleIdx;return this.base.submit.call(this)}},ii}function Ei(){return hi||(hi=1,function(t){const e=Ot,i=(i,s)=>{e.defineExport(t,i,s),e.defineExport(t,i.toLowerCase(),s)};i("AutoComplete",()=>gi()),i("BasicAuth",()=>function(){if(xe)return Se;xe=1;const t=bi();function e(t,e){return t.username===this.options.username&&t.password===this.options.password}const i=(s=e)=>{const r=[{name:"username",message:"username"},{name:"password",message:"password",format(t){return this.options.showPassword?t:(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(t.length))}}];class n extends(t.create(s)){constructor(t){super({...t,choices:r})}static create(t){return i(t)}}return n};return Se=i()}()),i("Confirm",()=>function(){if(Ee)return ke;Ee=1;const t=vi();return ke=class extends t{constructor(t){super(t),this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}}}()),i("Editable",()=>function(){if($e)return Ae;$e=1;const t=fi(),e=wi().prototype;return Ae=class extends t{constructor(t){super({...t,multiple:!0}),this.align=[this.options.align,"left"].find(t=>null!=t),this.emptyError="",this.values={}}dispatch(t,i){let s=this.focused,r=s.parent||{};return s.editable||r.editable||"a"!==t&&"i"!==t?e.dispatch.call(this,t,i):super[t]()}append(t,i){return e.append.call(this,t,i)}delete(t,i){return e.delete.call(this,t,i)}space(t){return this.focused.editable?this.append(t):super.space()}number(t){return this.focused.editable?this.append(t):super.number(t)}next(){return this.focused.editable?e.next.call(this):super.next()}prev(){return this.focused.editable?e.prev.call(this):super.prev()}async indicator(t,e){let i=t.indicator||"",s=t.editable?i:super.indicator(t,e);return await this.resolve(s,this.state,t,e)||""}indent(t){return"heading"===t.role?"":t.editable?" ":" "}async renderChoice(t,i){return t.indent="",t.editable?e.renderChoice.call(this,t,i):super.renderChoice(t,i)}error(){return""}footer(){return this.state.error}async validate(){let t=!0;for(let e of this.choices){if("function"!=typeof e.validate)continue;if("heading"===e.role)continue;let i=e.parent?this.value[e.parent.name]:this.value;if(e.editable?i=e.value===e.name?e.initial||"":e.value:this.isDisabled(e)||(i=!0===e.enabled),t=await e.validate(i,this.state),!0!==t)break}return!0!==t&&(this.state.error="string"==typeof t?t:"Invalid Input"),t}submit(){if(!0===this.focused.newChoice)return super.submit();if(this.choices.some(t=>t.newChoice))return this.alert();this.value={};for(let t of this.choices){let e=t.parent?this.value[t.parent.name]:this.value;"heading"!==t.role?t.editable?e[t.name]=t.value===t.name?t.initial||"":t.value:this.isDisabled(t)||(e[t.name]=!0===t.enabled):this.value[t.name]={}}return this.base.submit.call(this)}}}()),i("Form",()=>wi()),i("Input",()=>xi()),i("Invisible",()=>function(){if(Re)return Ie;Re=1;const t=_i();return Ie=class extends t{format(){return""}}}()),i("List",()=>function(){if(Ve)return Le;Ve=1;const t=_i();return Le=class extends t{constructor(t={}){super(t),this.sep=this.options.separator||/, */,this.initial=t.initial||""}split(t=this.value){return t?String(t).split(this.sep):[]}format(){let t=this.state.submitted?this.styles.primary:t=>t;return this.list.map(t).join(", ")}async submit(t){let e=this.state.error||await this.validate(this.list,this.state);return!0!==e?(this.state.error=e,super.submit()):(this.value=this.list,super.submit())}get list(){return this.split()}},Le}()),i("MultiSelect",()=>function(){if(He)return Me;He=1;const t=fi();return Me=class extends t{constructor(t){super({...t,multiple:!0})}}}()),i("Numeral",()=>Ue?qe:(Ue=1,qe=Oi())),i("Password",()=>function(){if(Je)return ze;Je=1;const t=_i();return ze=class extends t{constructor(t){super(t),this.cursorShow()}format(t=this.input){return this.keypressed?(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(t.length)):""}},ze}()),i("Scale",()=>function(){if(Ke)return Ge;Ke=1;const t=Ft(),e=mi(),i=Ot;return Ge=class extends e{constructor(t={}){super(t),this.widths=[].concat(t.messageWidth||50),this.align=[].concat(t.align||"left"),this.linebreak=t.linebreak||!1,this.edgeLength=t.edgeLength||3,this.newline=t.newline||"\n ";let e=t.startNumber||1;"number"==typeof this.scale&&(this.scaleKey=!1,this.scale=Array(this.scale).fill(0).map((t,i)=>({name:i+e})))}async reset(){return this.tableized=!1,await super.reset(),this.render()}tableize(){if(!0===this.tableized)return;this.tableized=!0;let t=0;for(let e of this.choices){t=Math.max(t,e.message.length),e.scaleIndex=e.initial||2,e.scale=[];for(let t=0;t<this.scale.length;t++)e.scale.push({index:t})}this.widths[0]=Math.min(this.widths[0],t+3)}async dispatch(t,e){if(this.multiple)return this[e.name]?await this[e.name](t,e):await super.dispatch(t,e);this.alert()}heading(t,e,i){return this.styles.strong(t)}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let t=this.focused;return t.scaleIndex>=this.scale.length-1?this.alert():(t.scaleIndex++,this.render())}left(){let t=this.focused;return t.scaleIndex<=0?this.alert():(t.scaleIndex--,this.render())}indent(){return""}format(){return this.state.submitted?this.choices.map(t=>this.styles.info(t.index)).join(", "):""}pointer(){return""}renderScaleKey(){return!1===this.scaleKey||this.state.submitted?"":["",...this.scale.map(t=>` ${t.name} - ${t.message}`)].map(t=>this.styles.muted(t)).join("\n")}renderScaleHeading(t){let e=this.scale.map(t=>t.name);"function"==typeof this.options.renderScaleHeading&&(e=this.options.renderScaleHeading.call(this,t));let i=this.scaleLength-e.join("").length,s=Math.round(i/(e.length-1)),r=e.map(t=>this.styles.strong(t)).join(" ".repeat(s)),n=" ".repeat(this.widths[0]);return this.margin[3]+n+this.margin[1]+r}scaleIndicator(t,e,i){if("function"==typeof this.options.scaleIndicator)return this.options.scaleIndicator.call(this,t,e,i);let s=t.scaleIndex===e.index;return e.disabled?this.styles.hint(this.symbols.radio.disabled):s?this.styles.success(this.symbols.radio.on):this.symbols.radio.off}renderScale(t,e){let i=t.scale.map(i=>this.scaleIndicator(t,i,e)),s="Hyper"===this.term?"":" ";return i.join(s+this.symbols.line.repeat(this.edgeLength))}async renderChoice(e,s){await this.onChoice(e,s);let r=this.index===s,n=await this.pointer(e,s),o=await e.hint;o&&!i.hasColor(o)&&(o=this.styles.muted(o));let a=t=>this.margin[3]+t.replace(/\s+$/,"").padEnd(this.widths[0]," "),l=this.newline,c=this.indent(e),h=await this.resolve(e.message,this.state,e,s),u=await this.renderScale(e,s),p=this.margin[1]+this.margin[3];this.scaleLength=t(u).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-p.length);let d=i.wordWrap(h,{width:this.widths[0],newline:l}).split("\n").map(t=>a(t)+this.margin[1]);return r&&(u=this.styles.info(u),d=d.map(t=>this.styles.info(t))),d[0]+=u,this.linebreak&&d.push(""),[c+n,d.join("\n")].filter(Boolean)}async renderChoices(){if(this.state.submitted)return"";this.tableize();let t=this.visible.map(async(t,e)=>await this.renderChoice(t,e)),e=await Promise.all(t),i=await this.renderScaleHeading();return this.margin[0]+[i,...e.map(t=>t.join(" "))].join("\n")}async render(){let{submitted:t,size:e}=this.state,i=await this.prefix(),s=await this.separator(),r=await this.message(),n="";!1!==this.options.promptLine&&(n=[i,r,s,""].join(" "),this.state.prompt=n);let o=await this.header(),a=await this.format(),l=await this.renderScaleKey(),c=await this.error()||await this.hint(),h=await this.renderChoices(),u=await this.footer(),p=this.emptyError;a&&(n+=a),c&&!n.includes(c)&&(n+=" "+c),t&&!a&&!h.trim()&&this.multiple&&null!=p&&(n+=this.styles.danger(p)),this.clear(e),this.write([o,n,l,h,u].filter(Boolean).join("\n")),this.state.submitted||this.write(this.margin[2]),this.restore()}submit(){this.value={};for(let t of this.choices)this.value[t.name]=t.scaleIndex;return this.base.submit.call(this)}},Ge}()),i("Select",()=>fi()),i("Snippet",()=>function(){if(Qe)return Xe;Qe=1;const t=Ft(),e=Ci(),i=ae();return Xe=class extends i{constructor(t){super(t),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await e(this),await super.initialize()}async reset(t){this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},!0!==t&&(await this.initialize(),await this.render())}moveCursor(t){let e=this.getItem();this.cursor+=t,e.cursor+=t}dispatch(t,e){e.code||e.ctrl||null==t||!this.getItem()?this.alert():this.append(t,e)}append(t,e){let i=this.getItem(),s=i.input.slice(0,this.cursor),r=i.input.slice(this.cursor);this.input=i.input=`${s}${t}${r}`,this.moveCursor(1),this.render()}delete(){let t=this.getItem();if(this.cursor<=0||!t.input)return this.alert();let e=t.input.slice(this.cursor),i=t.input.slice(0,this.cursor-1);this.input=t.input=`${i}${e}`,this.moveCursor(-1),this.render()}increment(t){return t>=this.state.keys.length-1?0:t+1}decrement(t){return t<=0?this.state.keys.length-1:t-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(t){let e=this.state.completed<100?this.styles.warning:this.styles.success;return!0===this.state.submitted&&100!==this.state.completed&&(e=this.styles.danger),e(`${this.state.completed}% completed`)}async render(){let{index:t,keys:e=[],submitted:i,size:s}=this.state,r=[this.options.newline,"\n"].find(t=>null!=t),n=await this.prefix(),o=await this.separator(),a=[n,await this.message(),o].filter(Boolean).join(" ");this.state.prompt=a;let l=await this.header(),c=await this.error()||"",h=await this.hint()||"",u=i?"":await this.interpolate(this.state),p=this.state.key=e[t]||"",d=await this.format(p),m=await this.footer();d&&(a+=" "+d),h&&!d&&0===this.state.completed&&(a+=" "+h),this.clear(s);let f=[l,a,u,m,c.trim()];this.write(f.filter(Boolean).join(r)),this.restore()}getItem(t){let{items:e,keys:i,index:s}=this.state,r=e.find(t=>t.name===i[s]);return r&&null!=r.input&&(this.input=r.input,this.cursor=r.cursor),r}async submit(){"function"!=typeof this.interpolate&&await this.initialize(),await this.interpolate(this.state,!0);let{invalid:e,missing:i,output:s,values:r}=this.state;if(e.size){let t="";for(let[i,s]of e)t+=`Invalid ${i}: ${s}\n`;return this.state.error=t,super.submit()}if(i.size)return this.state.error="Required: "+[...i.keys()].join(", "),super.submit();let n=t(s).split("\n").map(t=>t.slice(1)).join("\n");return this.value={values:r,result:n},super.submit()}},Xe}()),i("Sort",()=>function(){if(ei)return ti;ei=1;const t="(Use <shift>+<up/down> to sort)",e=fi();return ti=class extends e{constructor(e){super({...e,reorder:!1,sort:!0,multiple:!0}),this.state.hint=[this.options.hint,t].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(t,e){let i=await super.renderChoice(t,e),s=this.symbols.identicalTo+" ",r=this.index===e&&this.sorting?this.styles.muted(s):" ";return!1===this.options.drag&&(r=""),!0===this.options.numbered?r+`${e+1} - `+i:r+i}get selected(){return this.choices}submit(){return this.value=this.choices.map(t=>t.value),super.submit()}}}()),i("Survey",()=>ki()),i("Text",()=>ni?ri:(ni=1,ri=xi())),i("Toggle",()=>function(){if(ai)return oi;ai=1;const t=vi();return oi=class extends t{async initialize(){await super.initialize(),this.value=this.initial=this.resolve(this.options.initial),this.disabled=this.options.disabled||"no",this.enabled=this.options.enabled||"yes",await this.render()}reset(){this.value=this.initial,this.render()}delete(){this.alert()}toggle(){this.value=!this.value,this.render()}enable(){if(!0===this.value)return this.alert();this.value=!0,this.render()}disable(){if(!1===this.value)return this.alert();this.value=!1,this.render()}up(){this.toggle()}down(){this.toggle()}right(){this.toggle()}left(){this.toggle()}next(){this.toggle()}prev(){this.toggle()}dispatch(t="",e){switch(t.toLowerCase()){case" ":return this.toggle();case"1":case"y":case"t":return this.enable();case"0":case"n":case"f":return this.disable();default:return this.alert()}}format(){let t=t=>this.styles.primary.underline(t);return[this.value?this.disabled:t(this.disabled),this.value?t(this.enabled):this.enabled].join(this.styles.muted(" / "))}async render(){let{size:t}=this.state,e=await this.header(),i=await this.prefix(),s=await this.separator(),r=await this.message(),n=await this.format(),o=await this.error()||await this.hint(),a=await this.footer(),l=[i,r,s,n].join(" ");this.state.prompt=l,o&&!l.includes(o)&&(l+=" "+o),this.clear(t),this.write([e,l,a].filter(Boolean).join("\n")),this.write(this.margin[2]),this.restore()}},oi}()),i("Quiz",()=>function(){if(ci)return li;ci=1;const t=fi();return li=class extends t{constructor(t){if(super(t),"number"!=typeof this.options.correctChoice||this.options.correctChoice<0)throw new Error("Please specify the index of the correct answer from the list of choices")}async toChoices(t,e){let i=await super.toChoices(t,e);if(i.length<2)throw new Error("Please give at least two choices to the user");if(this.options.correctChoice>i.length)throw new Error("Please specify the index of the correct answer from the list of choices");return i}check(t){return t.index===this.options.correctChoice}async result(t){return{selectedAnswer:t,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}},li}())}(di)),di}const Ai=h,$i=u,Pi=Ot;class Di extends $i{constructor(t,e){super(),this.options=Pi.merge({},t),this.answers={...e}}register(t,e){if(Pi.isObject(t)){for(let e of Object.keys(t))this.register(e,t[e]);return this}Ai.equal(typeof e,"function","expected a function");const i=t.toLowerCase();return e.prototype instanceof this.Prompt?this.prompts[i]=e:this.prompts[i]=e(this.Prompt,this),this}async prompt(t=[]){for(let e of[].concat(t))try{"function"==typeof e&&(e=await e.call(this)),await this.ask(Pi.merge({},this.options,e))}catch(t){return Promise.reject(t)}return this.answers}async ask(t){"function"==typeof t&&(t=await t.call(this));let e=Pi.merge({},this.options,t),{type:i,name:s}=t,{set:r,get:n}=Pi;if("function"==typeof i&&(i=await i.call(this,t,this.answers)),!i)return this.answers[s];"number"===i&&(i="numeral"),Ai(this.prompts[i],`Prompt "${i}" is not registered`);let o=new this.prompts[i](e),a=n(this.answers,s);o.state.answers=this.answers,o.enquirer=this,s&&o.on("submit",t=>{this.emit("answer",s,t,o),r(this.answers,s,t)});let l=o.emit.bind(o);return o.emit=(...t)=>(this.emit.call(this,...t),l(...t)),this.emit("prompt",o,this),e.autofill&&null!=a?(o.value=o.input=a,"show"===e.autofill&&await o.submit()):a=o.value=await o.run(),a}use(t){return t.call(this,this),this}set Prompt(t){this._Prompt=t}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(t){this._Prompt=t}static get Prompt(){return this._Prompt||ae()}static get prompts(){return Ei()}static get types(){return pi?ui:(pi=1,ui={ArrayPrompt:mi(),AuthPrompt:bi(),BooleanPrompt:vi(),NumberPrompt:Oi(),StringPrompt:_i()})}static get prompt(){const t=(e,...i)=>{let s=new this(...i),r=s.emit.bind(s);return s.emit=(...e)=>(t.emit(...e),r(...e)),s.prompt(e)};return Pi.mixinEmitter(t,new $i),t}}Pi.mixinEmitter(Di,new $i);const Ti=Di.prompts;for(let t of Object.keys(Ti)){let e=t.toLowerCase(),i=e=>new Ti[t](e).run();Di.prompt[e]=i,Di[e]=i,Di[t]||Reflect.defineProperty(Di,t,{get:()=>Ti[t]})}const ji=t=>{Pi.defineExport(Di,t,()=>Di.types[t])};ji("ArrayPrompt"),ji("AuthPrompt"),ji("BooleanPrompt"),ji("NumberPrompt"),ji("StringPrompt");var Ni=H(Di),Fi={},Ii={fromCallback:function(t){return Object.defineProperty(function(...e){if("function"!=typeof e[e.length-1])return new Promise((i,s)=>{e.push((t,e)=>null!=t?s(t):i(e)),t.apply(this,e)});t.apply(this,e)},"name",{value:t.name})},fromPromise:function(t){return Object.defineProperty(function(...e){const i=e[e.length-1];if("function"!=typeof i)return t.apply(this,e);e.pop(),t.apply(this,e).then(t=>i(null,t),i)},"name",{value:t.name})}},Ri=$,Li=process.cwd,Vi=null,Mi=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Vi||(Vi=Li.call(process)),Vi};try{process.cwd()}catch(t){}if("function"==typeof process.chdir){var Hi=process.chdir;process.chdir=function(t){Vi=null,Hi.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Hi)}var Wi=function(t){Ri.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(t){t.lchmod=function(e,i,s){t.open(e,Ri.O_WRONLY|Ri.O_SYMLINK,i,function(e,r){e?s&&s(e):t.fchmod(r,i,function(e){t.close(r,function(t){s&&s(e||t)})})})},t.lchmodSync=function(e,i){var s,r=t.openSync(e,Ri.O_WRONLY|Ri.O_SYMLINK,i),n=!0;try{s=t.fchmodSync(r,i),n=!1}finally{if(n)try{t.closeSync(r)}catch(t){}else t.closeSync(r)}return s}}(t);t.lutimes||function(t){Ri.hasOwnProperty("O_SYMLINK")&&t.futimes?(t.lutimes=function(e,i,s,r){t.open(e,Ri.O_SYMLINK,function(e,n){e?r&&r(e):t.futimes(n,i,s,function(e){t.close(n,function(t){r&&r(e||t)})})})},t.lutimesSync=function(e,i,s){var r,n=t.openSync(e,Ri.O_SYMLINK),o=!0;try{r=t.futimesSync(n,i,s),o=!1}finally{if(o)try{t.closeSync(n)}catch(t){}else t.closeSync(n)}return r}):t.futimes&&(t.lutimes=function(t,e,i,s){s&&process.nextTick(s)},t.lutimesSync=function(){})}(t);t.chown=s(t.chown),t.fchown=s(t.fchown),t.lchown=s(t.lchown),t.chmod=e(t.chmod),t.fchmod=e(t.fchmod),t.lchmod=e(t.lchmod),t.chownSync=r(t.chownSync),t.fchownSync=r(t.fchownSync),t.lchownSync=r(t.lchownSync),t.chmodSync=i(t.chmodSync),t.fchmodSync=i(t.fchmodSync),t.lchmodSync=i(t.lchmodSync),t.stat=n(t.stat),t.fstat=n(t.fstat),t.lstat=n(t.lstat),t.statSync=o(t.statSync),t.fstatSync=o(t.fstatSync),t.lstatSync=o(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(t,e,i){i&&process.nextTick(i)},t.lchmodSync=function(){});t.chown&&!t.lchown&&(t.lchown=function(t,e,i,s){s&&process.nextTick(s)},t.lchownSync=function(){});"win32"===Mi&&(t.rename="function"!=typeof t.rename?t.rename:function(e){function i(i,s,r){var n=Date.now(),o=0;e(i,s,function a(l){if(l&&("EACCES"===l.code||"EPERM"===l.code||"EBUSY"===l.code)&&Date.now()-n<6e4)return setTimeout(function(){t.stat(s,function(t,n){t&&"ENOENT"===t.code?e(i,s,a):r(l)})},o),void(o<100&&(o+=10));r&&r(l)})}return Object.setPrototypeOf&&Object.setPrototypeOf(i,e),i}(t.rename));function e(e){return e?function(i,s,r){return e.call(t,i,s,function(t){a(t)&&(t=null),r&&r.apply(this,arguments)})}:e}function i(e){return e?function(i,s){try{return e.call(t,i,s)}catch(t){if(!a(t))throw t}}:e}function s(e){return e?function(i,s,r,n){return e.call(t,i,s,r,function(t){a(t)&&(t=null),n&&n.apply(this,arguments)})}:e}function r(e){return e?function(i,s,r){try{return e.call(t,i,s,r)}catch(t){if(!a(t))throw t}}:e}function n(e){return e?function(i,s,r){function n(t,e){e&&(e.uid<0&&(e.uid+=4294967296),e.gid<0&&(e.gid+=4294967296)),r&&r.apply(this,arguments)}return"function"==typeof s&&(r=s,s=null),s?e.call(t,i,s,n):e.call(t,i,n)}:e}function o(e){return e?function(i,s){var r=s?e.call(t,i,s):e.call(t,i);return r&&(r.uid<0&&(r.uid+=4294967296),r.gid<0&&(r.gid+=4294967296)),r}:e}function a(t){return!t||("ENOSYS"===t.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==t.code&&"EPERM"!==t.code))}t.read="function"!=typeof t.read?t.read:function(e){function i(i,s,r,n,o,a){var l;if(a&&"function"==typeof a){var c=0;l=function(h,u,p){if(h&&"EAGAIN"===h.code&&c<10)return c++,e.call(t,i,s,r,n,o,l);a.apply(this,arguments)}}return e.call(t,i,s,r,n,o,l)}return Object.setPrototypeOf&&Object.setPrototypeOf(i,e),i}(t.read),t.readSync="function"!=typeof t.readSync?t.readSync:(l=t.readSync,function(e,i,s,r,n){for(var o=0;;)try{return l.call(t,e,i,s,r,n)}catch(t){if("EAGAIN"===t.code&&o<10){o++;continue}throw t}});var l};var Bi=P.Stream,qi=function(t){return{ReadStream:function e(i,s){if(!(this instanceof e))return new e(i,s);Bi.call(this);var r=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,s=s||{};for(var n=Object.keys(s),o=0,a=n.length;o<a;o++){var l=n[o];this[l]=s[l]}this.encoding&&this.setEncoding(this.encoding);if(void 0!==this.start){if("number"!=typeof this.start)throw TypeError("start must be a Number");if(void 0===this.end)this.end=1/0;else if("number"!=typeof this.end)throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(null!==this.fd)return void process.nextTick(function(){r._read()});t.open(this.path,this.flags,this.mode,function(t,e){if(t)return r.emit("error",t),void(r.readable=!1);r.fd=e,r.emit("open",e),r._read()})},WriteStream:function e(i,s){if(!(this instanceof e))return new e(i,s);Bi.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,s=s||{};for(var r=Object.keys(s),n=0,o=r.length;n<o;n++){var a=r[n];this[a]=s[a]}if(void 0!==this.start){if("number"!=typeof this.start)throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],null===this.fd&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}};var Ui=function(t){if(null===t||"object"!=typeof t)return t;if(t instanceof Object)var e={__proto__:zi(t)};else e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e},zi=Object.getPrototypeOf||function(t){return t.__proto__};var Ji,Gi,Ki=k,Yi=Wi,Zi=qi,Xi=Ui,Qi=D;function ts(t,e){Object.defineProperty(t,Ji,{get:function(){return e}})}"function"==typeof Symbol&&"function"==typeof Symbol.for?(Ji=Symbol.for("graceful-fs.queue"),Gi=Symbol.for("graceful-fs.previous")):(Ji="___graceful-fs.queue",Gi="___graceful-fs.previous");var es=function(){};if(Qi.debuglog?es=Qi.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(es=function(){var t=Qi.format.apply(Qi,arguments);t="GFS4: "+t.split(/\n/).join("\nGFS4: "),console.error(t)}),!Ki[Ji]){var is=M[Ji]||[];ts(Ki,is),Ki.close=function(t){function e(e,i){return t.call(Ki,e,function(t){t||as(),"function"==typeof i&&i.apply(this,arguments)})}return Object.defineProperty(e,Gi,{value:t}),e}(Ki.close),Ki.closeSync=function(t){function e(e){t.apply(Ki,arguments),as()}return Object.defineProperty(e,Gi,{value:t}),e}(Ki.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){es(Ki[Ji]),h.equal(Ki[Ji].length,0)})}M[Ji]||ts(M,Ki[Ji]);var ss,rs=ns(Xi(Ki));function ns(t){Yi(t),t.gracefulify=ns,t.createReadStream=function(e,i){return new t.ReadStream(e,i)},t.createWriteStream=function(e,i){return new t.WriteStream(e,i)};var e=t.readFile;t.readFile=function(t,i,s){"function"==typeof i&&(s=i,i=null);return function t(i,s,r,n){return e(i,s,function(e){!e||"EMFILE"!==e.code&&"ENFILE"!==e.code?"function"==typeof r&&r.apply(this,arguments):os([t,[i,s,r],e,n||Date.now(),Date.now()])})}(t,i,s)};var i=t.writeFile;t.writeFile=function(t,e,s,r){"function"==typeof s&&(r=s,s=null);return function t(e,s,r,n,o){return i(e,s,r,function(i){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?"function"==typeof n&&n.apply(this,arguments):os([t,[e,s,r,n],i,o||Date.now(),Date.now()])})}(t,e,s,r)};var s=t.appendFile;s&&(t.appendFile=function(t,e,i,r){"function"==typeof i&&(r=i,i=null);return function t(e,i,r,n,o){return s(e,i,r,function(s){!s||"EMFILE"!==s.code&&"ENFILE"!==s.code?"function"==typeof n&&n.apply(this,arguments):os([t,[e,i,r,n],s,o||Date.now(),Date.now()])})}(t,e,i,r)});var r=t.copyFile;r&&(t.copyFile=function(t,e,i,s){"function"==typeof i&&(s=i,i=0);return function t(e,i,s,n,o){return r(e,i,s,function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?"function"==typeof n&&n.apply(this,arguments):os([t,[e,i,s,n],r,o||Date.now(),Date.now()])})}(t,e,i,s)});var n=t.readdir;t.readdir=function(t,e,i){"function"==typeof e&&(i=e,e=null);var s=o.test(process.version)?function(t,e,i,s){return n(t,r(t,e,i,s))}:function(t,e,i,s){return n(t,e,r(t,e,i,s))};return s(t,e,i);function r(t,e,i,r){return function(n,o){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?(o&&o.sort&&o.sort(),"function"==typeof i&&i.call(this,n,o)):os([s,[t,e,i],n,r||Date.now(),Date.now()])}}};var o=/^v[0-5]\./;if("v0.8"===process.version.substr(0,4)){var a=Zi(t);p=a.ReadStream,d=a.WriteStream}var l=t.ReadStream;l&&(p.prototype=Object.create(l.prototype),p.prototype.open=function(){var t=this;f(t.path,t.flags,t.mode,function(e,i){e?(t.autoClose&&t.destroy(),t.emit("error",e)):(t.fd=i,t.emit("open",i),t.read())})});var c=t.WriteStream;c&&(d.prototype=Object.create(c.prototype),d.prototype.open=function(){var t=this;f(t.path,t.flags,t.mode,function(e,i){e?(t.destroy(),t.emit("error",e)):(t.fd=i,t.emit("open",i))})}),Object.defineProperty(t,"ReadStream",{get:function(){return p},set:function(t){p=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return d},set:function(t){d=t},enumerable:!0,configurable:!0});var h=p;Object.defineProperty(t,"FileReadStream",{get:function(){return h},set:function(t){h=t},enumerable:!0,configurable:!0});var u=d;function p(t,e){return this instanceof p?(l.apply(this,arguments),this):p.apply(Object.create(p.prototype),arguments)}function d(t,e){return this instanceof d?(c.apply(this,arguments),this):d.apply(Object.create(d.prototype),arguments)}Object.defineProperty(t,"FileWriteStream",{get:function(){return u},set:function(t){u=t},enumerable:!0,configurable:!0});var m=t.open;function f(t,e,i,s){return"function"==typeof i&&(s=i,i=null),function t(e,i,s,r,n){return m(e,i,s,function(o,a){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?"function"==typeof r&&r.apply(this,arguments):os([t,[e,i,s,r],o,n||Date.now(),Date.now()])})}(t,e,i,s)}return t.open=f,t}function os(t){es("ENQUEUE",t[0].name,t[1]),Ki[Ji].push(t),ls()}function as(){for(var t=Date.now(),e=0;e<Ki[Ji].length;++e)Ki[Ji][e].length>2&&(Ki[Ji][e][3]=t,Ki[Ji][e][4]=t);ls()}function ls(){if(clearTimeout(ss),ss=void 0,0!==Ki[Ji].length){var t=Ki[Ji].shift(),e=t[0],i=t[1],s=t[2],r=t[3],n=t[4];if(void 0===r)es("RETRY",e.name,i),e.apply(null,i);else if(Date.now()-r>=6e4){es("TIMEOUT",e.name,i);var o=i.pop();"function"==typeof o&&o.call(null,s)}else{var a=Date.now()-n,l=Math.max(n-r,1);a>=Math.min(1.2*l,100)?(es("RETRY",e.name,i),e.apply(null,i.concat([r]))):Ki[Ji].push(t)}void 0===ss&&(ss=setTimeout(ls,0))}}process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Ki.__patched&&(rs=ns(Ki),Ki.__patched=!0),function(t){const e=Ii.fromCallback,i=rs,s=["access","appendFile","chmod","chown","close","copyFile","cp","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","glob","lchmod","lchown","lutimes","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","statfs","symlink","truncate","unlink","utimes","writeFile"].filter(t=>"function"==typeof i[t]);Object.assign(t,i),s.forEach(s=>{t[s]=e(i[s])}),t.exists=function(t,e){return"function"==typeof e?i.exists(t,e):new Promise(e=>i.exists(t,e))},t.read=function(t,e,s,r,n,o){return"function"==typeof o?i.read(t,e,s,r,n,o):new Promise((o,a)=>{i.read(t,e,s,r,n,(t,e,i)=>{if(t)return a(t);o({bytesRead:e,buffer:i})})})},t.write=function(t,e,...s){return"function"==typeof s[s.length-1]?i.write(t,e,...s):new Promise((r,n)=>{i.write(t,e,...s,(t,e,i)=>{if(t)return n(t);r({bytesWritten:e,buffer:i})})})},t.readv=function(t,e,...s){return"function"==typeof s[s.length-1]?i.readv(t,e,...s):new Promise((r,n)=>{i.readv(t,e,...s,(t,e,i)=>{if(t)return n(t);r({bytesRead:e,buffers:i})})})},t.writev=function(t,e,...s){return"function"==typeof s[s.length-1]?i.writev(t,e,...s):new Promise((r,n)=>{i.writev(t,e,...s,(t,e,i)=>{if(t)return n(t);r({bytesWritten:e,buffers:i})})})},"function"==typeof i.realpath.native?t.realpath.native=e(i.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")}(Fi);var cs={},hs={};const us=C;hs.checkPath=function(t){if("win32"===process.platform){if(/[<>:"|?*]/.test(t.replace(us.parse(t).root,""))){const e=new Error(`Path contains invalid characters: ${t}`);throw e.code="EINVAL",e}}};const ps=Fi,{checkPath:ds}=hs,ms=t=>"number"==typeof t?t:{mode:511,...t}.mode;cs.makeDir=async(t,e)=>(ds(t),ps.mkdir(t,{mode:ms(e),recursive:!0})),cs.makeDirSync=(t,e)=>(ds(t),ps.mkdirSync(t,{mode:ms(e),recursive:!0}));const fs=Ii.fromPromise,{makeDir:gs,makeDirSync:ys}=cs,ws=fs(gs);var bs={mkdirs:ws,mkdirsSync:ys,mkdirp:ws,mkdirpSync:ys,ensureDir:ws,ensureDirSync:ys};const vs=Ii.fromPromise,_s=Fi;var Ss={pathExists:vs(function(t){return _s.access(t).then(()=>!0).catch(()=>!1)}),pathExistsSync:_s.existsSync};const xs=Fi;var Os={utimesMillis:(0,Ii.fromPromise)(async function(t,e,i){const s=await xs.open(t,"r+");let r=null;try{await xs.futimes(s,e,i)}catch(t){r=t}finally{try{await xs.close(s)}catch(t){r||(r=t)}}if(r)throw r}),utimesMillisSync:function(t,e,i){const s=xs.openSync(t,"r+");let r=null;try{xs.futimesSync(s,e,i)}catch(t){r=t}finally{try{xs.closeSync(s)}catch(t){r||(r=t)}}if(r)throw r}};const Cs=Fi,ks=C,Es=Ii.fromPromise;function As(t,e){return void 0!==e.ino&&void 0!==e.dev&&e.ino===t.ino&&e.dev===t.dev}function $s(t,e){const i=ks.resolve(t).split(ks.sep).filter(t=>t),s=ks.resolve(e).split(ks.sep).filter(t=>t);return i.every((t,e)=>s[e]===t)}function Ps(t,e,i){return`Cannot ${i} '${t}' to a subdirectory of itself, '${e}'.`}var Ds={checkPaths:Es(async function(t,e,i,s){const{srcStat:r,destStat:n}=await function(t,e,i){const s=i.dereference?t=>Cs.stat(t,{bigint:!0}):t=>Cs.lstat(t,{bigint:!0});return Promise.all([s(t),s(e).catch(t=>{if("ENOENT"===t.code)return null;throw t})]).then(([t,e])=>({srcStat:t,destStat:e}))}(t,e,s);if(n){if(As(r,n)){const s=ks.basename(t),o=ks.basename(e);if("move"===i&&s!==o&&s.toLowerCase()===o.toLowerCase())return{srcStat:r,destStat:n,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(r.isDirectory()&&!n.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'.`);if(!r.isDirectory()&&n.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${t}'.`)}if(r.isDirectory()&&$s(t,e))throw new Error(Ps(t,e,i));return{srcStat:r,destStat:n}}),checkPathsSync:function(t,e,i,s){const{srcStat:r,destStat:n}=function(t,e,i){let s;const r=i.dereference?t=>Cs.statSync(t,{bigint:!0}):t=>Cs.lstatSync(t,{bigint:!0}),n=r(t);try{s=r(e)}catch(t){if("ENOENT"===t.code)return{srcStat:n,destStat:null};throw t}return{srcStat:n,destStat:s}}(t,e,s);if(n){if(As(r,n)){const s=ks.basename(t),o=ks.basename(e);if("move"===i&&s!==o&&s.toLowerCase()===o.toLowerCase())return{srcStat:r,destStat:n,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(r.isDirectory()&&!n.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'.`);if(!r.isDirectory()&&n.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${t}'.`)}if(r.isDirectory()&&$s(t,e))throw new Error(Ps(t,e,i));return{srcStat:r,destStat:n}},checkParentPaths:Es(async function t(e,i,s,r){const n=ks.resolve(ks.dirname(e)),o=ks.resolve(ks.dirname(s));if(o===n||o===ks.parse(o).root)return;let a;try{a=await Cs.stat(o,{bigint:!0})}catch(t){if("ENOENT"===t.code)return;throw t}if(As(i,a))throw new Error(Ps(e,s,r));return t(e,i,o,r)}),checkParentPathsSync:function t(e,i,s,r){const n=ks.resolve(ks.dirname(e)),o=ks.resolve(ks.dirname(s));if(o===n||o===ks.parse(o).root)return;let a;try{a=Cs.statSync(o,{bigint:!0})}catch(t){if("ENOENT"===t.code)return;throw t}if(As(i,a))throw new Error(Ps(e,s,r));return t(e,i,o,r)},isSrcSubdir:$s,areIdentical:As};var Ts={asyncIteratorConcurrentProcess:async function(t,e){const i=[];for await(const s of t)i.push(e(s).then(()=>null,t=>t??new Error("unknown error")));await Promise.all(i.map(t=>t.then(t=>{if(null!==t)throw t})))}};const js=Fi,Ns=C,{mkdirs:Fs}=bs,{pathExists:Is}=Ss,{utimesMillis:Rs}=Os,Ls=Ds,{asyncIteratorConcurrentProcess:Vs}=Ts;async function Ms(t,e,i){return!i.filter||i.filter(t,e)}async function Hs(t,e,i,s){const r=s.dereference?js.stat:js.lstat,n=await r(e);if(n.isDirectory())return async function(t,e,i,s,r){e||await js.mkdir(s);await Vs(await js.opendir(i),async t=>{const e=Ns.join(i,t.name),n=Ns.join(s,t.name);if(await Ms(e,n,r)){const{destStat:t}=await Ls.checkPaths(e,n,"copy",r);await Hs(t,e,n,r)}}),e||await js.chmod(s,t.mode)}(n,t,e,i,s);if(n.isFile()||n.isCharacterDevice()||n.isBlockDevice())return async function(t,e,i,s,r){if(!e)return Ws(t,i,s,r);if(r.overwrite)return await js.unlink(s),Ws(t,i,s,r);if(r.errorOnExist)throw new Error(`'${s}' already exists`)}(n,t,e,i,s);if(n.isSymbolicLink())return async function(t,e,i,s){let r=await js.readlink(e);s.dereference&&(r=Ns.resolve(process.cwd(),r));if(!t)return js.symlink(r,i);let n=null;try{n=await js.readlink(i)}catch(t){if("EINVAL"===t.code||"UNKNOWN"===t.code)return js.symlink(r,i);throw t}s.dereference&&(n=Ns.resolve(process.cwd(),n));if(r!==n){if(Ls.isSrcSubdir(r,n))throw new Error(`Cannot copy '${r}' to a subdirectory of itself, '${n}'.`);if(Ls.isSrcSubdir(n,r))throw new Error(`Cannot overwrite '${n}' with '${r}'.`)}return await js.unlink(i),js.symlink(r,i)}(t,e,i,s);if(n.isSocket())throw new Error(`Cannot copy a socket file: ${e}`);if(n.isFIFO())throw new Error(`Cannot copy a FIFO pipe: ${e}`);throw new Error(`Unknown file: ${e}`)}async function Ws(t,e,i,s){if(await js.copyFile(e,i),s.preserveTimestamps){128&t.mode||await function(t,e){return js.chmod(t,128|e)}(i,t.mode);const s=await js.stat(e);await Rs(i,s.atime,s.mtime)}return js.chmod(i,t.mode)}var Bs=async function(t,e,i={}){"function"==typeof i&&(i={filter:i}),i.clobber=!("clobber"in i)||!!i.clobber,i.overwrite="overwrite"in i?!!i.overwrite:i.clobber,i.preserveTimestamps&&"ia32"===process.arch&&process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended;\n\n\tsee https://github.com/jprichardson/node-fs-extra/issues/269","Warning","fs-extra-WARN0001");const{srcStat:s,destStat:r}=await Ls.checkPaths(t,e,"copy",i);if(await Ls.checkParentPaths(t,s,e,"copy"),!await Ms(t,e,i))return;const n=Ns.dirname(e);await Is(n)||await Fs(n),await Hs(r,t,e,i)};const qs=rs,Us=C,zs=bs.mkdirsSync,Js=Os.utimesMillisSync,Gs=Ds;function Ks(t,e,i,s){const r=(s.dereference?qs.statSync:qs.lstatSync)(e);if(r.isDirectory())return function(t,e,i,s,r){return e?Xs(i,s,r):function(t,e,i,s){return qs.mkdirSync(i),Xs(e,i,s),Zs(i,t)}(t.mode,i,s,r)}(r,t,e,i,s);if(r.isFile()||r.isCharacterDevice()||r.isBlockDevice())return function(t,e,i,s,r){return e?function(t,e,i,s){if(s.overwrite)return qs.unlinkSync(i),Ys(t,e,i,s);if(s.errorOnExist)throw new Error(`'${i}' already exists`)}(t,i,s,r):Ys(t,i,s,r)}(r,t,e,i,s);if(r.isSymbolicLink())return function(t,e,i,s){let r=qs.readlinkSync(e);s.dereference&&(r=Us.resolve(process.cwd(),r));if(t){let t;try{t=qs.readlinkSync(i)}catch(t){if("EINVAL"===t.code||"UNKNOWN"===t.code)return qs.symlinkSync(r,i);throw t}if(s.dereference&&(t=Us.resolve(process.cwd(),t)),r!==t){if(Gs.isSrcSubdir(r,t))throw new Error(`Cannot copy '${r}' to a subdirectory of itself, '${t}'.`);if(Gs.isSrcSubdir(t,r))throw new Error(`Cannot overwrite '${t}' with '${r}'.`)}return function(t,e){return qs.unlinkSync(e),qs.symlinkSync(t,e)}(r,i)}return qs.symlinkSync(r,i)}(t,e,i,s);if(r.isSocket())throw new Error(`Cannot copy a socket file: ${e}`);if(r.isFIFO())throw new Error(`Cannot copy a FIFO pipe: ${e}`);throw new Error(`Unknown file: ${e}`)}function Ys(t,e,i,s){return qs.copyFileSync(e,i),s.preserveTimestamps&&function(t,e,i){(function(t){return!(128&t)})(t)&&function(t,e){Zs(t,128|e)}(i,t);(function(t,e){const i=qs.statSync(t);Js(e,i.atime,i.mtime)})(e,i)}(t.mode,e,i),Zs(i,t.mode)}function Zs(t,e){return qs.chmodSync(t,e)}function Xs(t,e,i){const s=qs.opendirSync(t);try{let r;for(;null!==(r=s.readSync());)Qs(r.name,t,e,i)}finally{s.closeSync()}}function Qs(t,e,i,s){const r=Us.join(e,t),n=Us.join(i,t);if(s.filter&&!s.filter(r,n))return;const{destStat:o}=Gs.checkPathsSync(r,n,"copy",s);return Ks(o,r,n,s)}var tr=function(t,e,i){"function"==typeof i&&(i={filter:i}),(i=i||{}).clobber=!("clobber"in i)||!!i.clobber,i.overwrite="overwrite"in i?!!i.overwrite:i.clobber,i.preserveTimestamps&&"ia32"===process.arch&&process.emitWarning("Using the preserveTimestamps option in 32-bit node is not recommended;\n\n\tsee https://github.com/jprichardson/node-fs-extra/issues/269","Warning","fs-extra-WARN0002");const{srcStat:s,destStat:r}=Gs.checkPathsSync(t,e,"copy",i);if(Gs.checkParentPathsSync(t,s,e,"copy"),i.filter&&!i.filter(t,e))return;const n=Us.dirname(e);return qs.existsSync(n)||zs(n),Ks(r,t,e,i)};var er={copy:(0,Ii.fromPromise)(Bs),copySync:tr};const ir=rs;var sr={remove:(0,Ii.fromCallback)(function(t,e){ir.rm(t,{recursive:!0,force:!0},e)}),removeSync:function(t){ir.rmSync(t,{recursive:!0,force:!0})}};const rr=Ii.fromPromise,nr=Fi,or=C,ar=bs,lr=sr,cr=rr(async function(t){let e;try{e=await nr.readdir(t)}catch{return ar.mkdirs(t)}return Promise.all(e.map(e=>lr.remove(or.join(t,e))))});function hr(t){let e;try{e=nr.readdirSync(t)}catch{return ar.mkdirsSync(t)}e.forEach(e=>{e=or.join(t,e),lr.removeSync(e)})}var ur={emptyDirSync:hr,emptydirSync:hr,emptyDir:cr,emptydir:cr};const pr=Ii.fromPromise,dr=C,mr=Fi,fr=bs;var gr={createFile:pr(async function(t){let e;try{e=await mr.stat(t)}catch{}if(e&&e.isFile())return;const i=dr.dirname(t);let s=null;try{s=await mr.stat(i)}catch(e){if("ENOENT"===e.code)return await fr.mkdirs(i),void await mr.writeFile(t,"");throw e}s.isDirectory()?await mr.writeFile(t,""):await mr.readdir(i)}),createFileSync:function(t){let e;try{e=mr.statSync(t)}catch{}if(e&&e.isFile())return;const i=dr.dirname(t);try{mr.statSync(i).isDirectory()||mr.readdirSync(i)}catch(t){if(!t||"ENOENT"!==t.code)throw t;fr.mkdirsSync(i)}mr.writeFileSync(t,"")}};const yr=Ii.fromPromise,wr=C,br=Fi,vr=bs,{pathExists:_r}=Ss,{areIdentical:Sr}=Ds;var xr={createLink:yr(async function(t,e){let i,s;try{i=await br.lstat(e,{bigint:!0})}catch{}try{s=await br.lstat(t,{bigint:!0})}catch(t){throw t.message=t.message.replace("lstat","ensureLink"),t}if(i&&Sr(s,i))return;const r=wr.dirname(e);await _r(r)||await vr.mkdirs(r),await br.link(t,e)}),createLinkSync:function(t,e){let i;try{i=br.lstatSync(e,{bigint:!0})}catch{}try{const e=br.lstatSync(t,{bigint:!0});if(i&&Sr(e,i))return}catch(t){throw t.message=t.message.replace("lstat","ensureLink"),t}const s=wr.dirname(e);return br.existsSync(s)||vr.mkdirsSync(s),br.linkSync(t,e)}};const Or=C,Cr=Fi,{pathExists:kr}=Ss;var Er={symlinkPaths:(0,Ii.fromPromise)(async function(t,e){if(Or.isAbsolute(t)){try{await Cr.lstat(t)}catch(t){throw t.message=t.message.replace("lstat","ensureSymlink"),t}return{toCwd:t,toDst:t}}const i=Or.dirname(e),s=Or.join(i,t);if(await kr(s))return{toCwd:s,toDst:t};try{await Cr.lstat(t)}catch(t){throw t.message=t.message.replace("lstat","ensureSymlink"),t}return{toCwd:t,toDst:Or.relative(i,t)}}),symlinkPathsSync:function(t,e){if(Or.isAbsolute(t)){if(!Cr.existsSync(t))throw new Error("absolute srcpath does not exist");return{toCwd:t,toDst:t}}const i=Or.dirname(e),s=Or.join(i,t);if(Cr.existsSync(s))return{toCwd:s,toDst:t};if(!Cr.existsSync(t))throw new Error("relative srcpath does not exist");return{toCwd:t,toDst:Or.relative(i,t)}}};const Ar=Fi;var $r={symlinkType:(0,Ii.fromPromise)(async function(t,e){if(e)return e;let i;try{i=await Ar.lstat(t)}catch{return"file"}return i&&i.isDirectory()?"dir":"file"}),symlinkTypeSync:function(t,e){if(e)return e;let i;try{i=Ar.lstatSync(t)}catch{return"file"}return i&&i.isDirectory()?"dir":"file"}};const Pr=Ii.fromPromise,Dr=C,Tr=Fi,{mkdirs:jr,mkdirsSync:Nr}=bs,{symlinkPaths:Fr,symlinkPathsSync:Ir}=Er,{symlinkType:Rr,symlinkTypeSync:Lr}=$r,{pathExists:Vr}=Ss,{areIdentical:Mr}=Ds;var Hr={createSymlink:Pr(async function(t,e,i){let s;try{s=await Tr.lstat(e)}catch{}if(s&&s.isSymbolicLink()){let i;if(Dr.isAbsolute(t))i=await Tr.stat(t,{bigint:!0});else{const s=Dr.dirname(e),r=Dr.join(s,t);try{i=await Tr.stat(r,{bigint:!0})}catch{i=await Tr.stat(t,{bigint:!0})}}const s=await Tr.stat(e,{bigint:!0});if(Mr(i,s))return}const r=await Fr(t,e);t=r.toDst;const n=await Rr(r.toCwd,i),o=Dr.dirname(e);return await Vr(o)||await jr(o),Tr.symlink(t,e,n)}),createSymlinkSync:function(t,e,i){let s;try{s=Tr.lstatSync(e)}catch{}if(s&&s.isSymbolicLink()){let i;if(Dr.isAbsolute(t))i=Tr.statSync(t,{bigint:!0});else{const s=Dr.dirname(e),r=Dr.join(s,t);try{i=Tr.statSync(r,{bigint:!0})}catch{i=Tr.statSync(t,{bigint:!0})}}const s=Tr.statSync(e,{bigint:!0});if(Mr(i,s))return}const r=Ir(t,e);t=r.toDst,i=Lr(r.toCwd,i);const n=Dr.dirname(e);return Tr.existsSync(n)||Nr(n),Tr.symlinkSync(t,e,i)}};const{createFile:Wr,createFileSync:Br}=gr,{createLink:qr,createLinkSync:Ur}=xr,{createSymlink:zr,createSymlinkSync:Jr}=Hr;var Gr={createFile:Wr,createFileSync:Br,ensureFile:Wr,ensureFileSync:Br,createLink:qr,createLinkSync:Ur,ensureLink:qr,ensureLinkSync:Ur,createSymlink:zr,createSymlinkSync:Jr,ensureSymlink:zr,ensureSymlinkSync:Jr};var Kr={stringify:function(t,{EOL:e="\n",finalEOL:i=!0,replacer:s=null,spaces:r}={}){const n=i?e:"",o=JSON.stringify(t,s,r);if(void 0===o)throw new TypeError(`Converting ${typeof t} value to JSON is not supported`);return o.replace(/\n/g,e)+n},stripBom:function(t){return Buffer.isBuffer(t)&&(t=t.toString("utf8")),t.replace(/^\uFEFF/,"")}};let Yr;try{Yr=rs}catch(t){Yr=k}const Zr=Ii,{stringify:Xr,stripBom:Qr}=Kr;const tn=Zr.fromPromise(async function(t,e={}){"string"==typeof e&&(e={encoding:e});const i=e.fs||Yr,s=!("throws"in e)||e.throws;let r,n=await Zr.fromCallback(i.readFile)(t,e);n=Qr(n);try{r=JSON.parse(n,e?e.reviver:null)}catch(e){if(s)throw e.message=`${t}: ${e.message}`,e;return null}return r});const en=Zr.fromPromise(async function(t,e,i={}){const s=i.fs||Yr,r=Xr(e,i);await Zr.fromCallback(s.writeFile)(t,r,i)});var sn={readFile:tn,readFileSync:function(t,e={}){"string"==typeof e&&(e={encoding:e});const i=e.fs||Yr,s=!("throws"in e)||e.throws;try{let s=i.readFileSync(t,e);return s=Qr(s),JSON.parse(s,e.reviver)}catch(e){if(s)throw e.message=`${t}: ${e.message}`,e;return null}},writeFile:en,writeFileSync:function(t,e,i={}){const s=i.fs||Yr,r=Xr(e,i);return s.writeFileSync(t,r,i)}};var rn={readJson:sn.readFile,readJsonSync:sn.readFileSync,writeJson:sn.writeFile,writeJsonSync:sn.writeFileSync};const nn=Ii.fromPromise,on=Fi,an=C,ln=bs,cn=Ss.pathExists;var hn={outputFile:nn(async function(t,e,i="utf-8"){const s=an.dirname(t);return await cn(s)||await ln.mkdirs(s),on.writeFile(t,e,i)}),outputFileSync:function(t,...e){const i=an.dirname(t);on.existsSync(i)||ln.mkdirsSync(i),on.writeFileSync(t,...e)}};const{stringify:un}=Kr,{outputFile:pn}=hn;var dn=async function(t,e,i={}){const s=un(e,i);await pn(t,s,i)};const{stringify:mn}=Kr,{outputFileSync:fn}=hn;var gn=function(t,e,i){const s=mn(e,i);fn(t,s,i)};const yn=Ii.fromPromise,wn=rn;wn.outputJson=yn(dn),wn.outputJsonSync=gn,wn.outputJSON=wn.outputJson,wn.outputJSONSync=wn.outputJsonSync,wn.writeJSON=wn.writeJson,wn.writeJSONSync=wn.writeJsonSync,wn.readJSON=wn.readJson,wn.readJSONSync=wn.readJsonSync;var bn=wn;const vn=Fi,_n=C,{copy:Sn}=er,{remove:xn}=sr,{mkdirp:On}=bs,{pathExists:Cn}=Ss,kn=Ds;var En=async function(t,e,i={}){const s=i.overwrite||i.clobber||!1,{srcStat:r,isChangingCase:n=!1}=await kn.checkPaths(t,e,"move",i);await kn.checkParentPaths(t,r,e,"move");const o=_n.dirname(e);return _n.parse(o).root!==o&&await On(o),async function(t,e,i,s){if(!s)if(i)await xn(e);else if(await Cn(e))throw new Error("dest already exists.");try{await vn.rename(t,e)}catch(s){if("EXDEV"!==s.code)throw s;await async function(t,e,i){const s={overwrite:i,errorOnExist:!0,preserveTimestamps:!0};return await Sn(t,e,s),xn(t)}(t,e,i)}}(t,e,s,n)};const An=rs,$n=C,Pn=er.copySync,Dn=sr.removeSync,Tn=bs.mkdirpSync,jn=Ds;function Nn(t,e,i){try{An.renameSync(t,e)}catch(s){if("EXDEV"!==s.code)throw s;return function(t,e,i){const s={overwrite:i,errorOnExist:!0,preserveTimestamps:!0};return Pn(t,e,s),Dn(t)}(t,e,i)}}var Fn=function(t,e,i){const s=(i=i||{}).overwrite||i.clobber||!1,{srcStat:r,isChangingCase:n=!1}=jn.checkPathsSync(t,e,"move",i);return jn.checkParentPathsSync(t,r,e,"move"),function(t){const e=$n.dirname(t);return $n.parse(e).root===e}(e)||Tn($n.dirname(e)),function(t,e,i,s){if(s)return Nn(t,e,i);if(i)return Dn(e),Nn(t,e,i);if(An.existsSync(e))throw new Error("dest already exists.");return Nn(t,e,i)}(t,e,s,n)};var In={move:(0,Ii.fromPromise)(En),moveSync:Fn},Rn=H({...Fi,...er,...ur,...Gr,...bn,...bs,...In,...hn,...Ss,...sr}),Ln={},Vn={};!function(t){var e=/[|\\{}()[\]^$+*?.]/g,i=Object.prototype.hasOwnProperty,s=function(t,e){return i.apply(t,[e])};t.escapeRegExpChars=function(t){return t?String(t).replace(e,"\\$&"):""};var r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&#34;","'":"&#39;"},n=/[&<>'"]/g;function o(t){return r[t]||t}function a(){return Function.prototype.toString.call(this)+';\nvar _ENCODE_HTML_RULES = {\n "&": "&amp;"\n , "<": "&lt;"\n , ">": "&gt;"\n , \'"\': "&#34;"\n , "\'": "&#39;"\n }\n , _MATCH_HTML = /[&<>\'"]/g;\nfunction encode_char(c) {\n return _ENCODE_HTML_RULES[c] || c;\n};\n'}t.escapeXML=function(t){return null==t?"":String(t).replace(n,o)};try{"function"==typeof Object.defineProperty?Object.defineProperty(t.escapeXML,"toString",{value:a}):t.escapeXML.toString=a}catch(t){console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)")}t.shallowCopy=function(t,e){if(e=e||{},null!=t)for(var i in e)s(e,i)&&"__proto__"!==i&&"constructor"!==i&&(t[i]=e[i]);return t},t.shallowCopyFromList=function(t,e,i){if(i=i||[],e=e||{},null!=t)for(var r=0;r<i.length;r++){var n=i[r];if(void 0!==e[n]){if(!s(e,n))continue;if("__proto__"===n||"constructor"===n)continue;t[n]=e[n]}}return t},t.cache={_data:{},set:function(t,e){this._data[t]=e},get:function(t){return this._data[t]},remove:function(t){delete this._data[t]},reset:function(){this._data={}}},t.hyphenToCamel=function(t){return t.replace(/-[a-z]/g,function(t){return t[1].toUpperCase()})},t.createNullProtoObjWherePossible="function"==typeof Object.create?function(){return Object.create(null)}:{__proto__:null}instanceof Object?function(){return{}}:function(){return{__proto__:null}},t.hasOwnOnlyObject=function(e){var i=t.createNullProtoObjWherePossible();for(var r in e)s(e,r)&&(i[r]=e[r]);return i}}(Vn);var Mn="3.1.10";!function(t){
3
3
  /**
4
4
  * @file Embedded JavaScript templating engine. {@link http://ejs.co}
5
5
  * @author Matthew Eernisse <mde@fleegix.org>
@@ -7,4 +7,4 @@ import t,{useMemo as e,useState as i,useEffect as s,useCallback as r}from"react"
7
7
  * @project EJS
8
8
  * @license {@link http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0}
9
9
  */
10
- var e=C,i=O,s=Vn,r=!1,n=Mn,o="locals",a=["delimiter","scope","context","debug","compileDebug","client","_with","rmWhitespace","strict","filename","async"],l=a.concat("cache"),c=/^\uFEFF/,h=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/;function u(i,s){var r;if(s.some(function(s){return r=t.resolveInclude(i,s,!0),e.existsSync(r)}))return r}function p(e,i){var s,r=e.filename,n=arguments.length>1;if(e.cache){if(!r)throw new Error("cache option requires a filename");if(s=t.cache.get(r))return s;n||(i=d(r).toString().replace(c,""))}else if(!n){if(!r)throw new Error("Internal EJS error: no file name or template provided");i=d(r).toString().replace(c,"")}return s=t.compile(i,e),e.cache&&t.cache.set(r,s),s}function d(e){return t.fileLoader(e)}function m(i,r){var n=s.shallowCopy(s.createNullProtoObjWherePossible(),r);if(n.filename=function(i,s){var r,n,o=s.views,a=/^[A-Za-z]+:\\|^\//.exec(i);if(a&&a.length)i=i.replace(/^\/*/,""),r=Array.isArray(s.root)?u(i,s.root):t.resolveInclude(i,s.root||"/",!0);else if(s.filename&&(n=t.resolveInclude(i,s.filename),e.existsSync(n)&&(r=n)),!r&&Array.isArray(o)&&(r=u(i,o)),!r&&"function"!=typeof s.includer)throw new Error('Could not find the include file "'+s.escapeFunction(i)+'"');return r}(i,n),"function"==typeof r.includer){var o=r.includer(i,n.filename);if(o&&(o.filename&&(n.filename=o.filename),o.template))return p(n,o.template)}return p(n)}function f(t,e,i,s,r){var n=e.split("\n"),o=Math.max(s-3,0),a=Math.min(n.length,s+3),l=r(i),c=n.slice(o,a).map(function(t,e){var i=e+o+1;return(i==s?" >> ":" ")+i+"| "+t}).join("\n");throw t.path=l,t.message=(l||"ejs")+":"+s+"\n"+c+"\n\n"+t.message,t}function g(t){return t.replace(/;(\s*$)/,"$1")}function y(e,i){var r=s.hasOwnOnlyObject(i),n=s.createNullProtoObjWherePossible();this.templateText=e,this.mode=null,this.truncate=!1,this.currentLine=1,this.source="",n.client=r.client||!1,n.escapeFunction=r.escape||r.escapeFunction||s.escapeXML,n.compileDebug=!1!==r.compileDebug,n.debug=!!r.debug,n.filename=r.filename,n.openDelimiter=r.openDelimiter||t.openDelimiter||"<",n.closeDelimiter=r.closeDelimiter||t.closeDelimiter||">",n.delimiter=r.delimiter||t.delimiter||"%",n.strict=r.strict||!1,n.context=r.context,n.cache=r.cache||!1,n.rmWhitespace=r.rmWhitespace,n.root=r.root,n.includer=r.includer,n.outputFunctionName=r.outputFunctionName,n.localsName=r.localsName||t.localsName||o,n.views=r.views,n.async=r.async,n.destructuredLocals=r.destructuredLocals,n.legacyInclude=void 0===r.legacyInclude||!!r.legacyInclude,n.strict?n._with=!1:n._with=void 0===r._with||r._with,this.opts=n,this.regex=this.createRegex()}t.cache=s.cache,t.fileLoader=e.readFileSync,t.localsName=o,t.promiseImpl=new Function("return this;")().Promise,t.resolveInclude=function(t,e,s){var r=i.dirname,n=i.extname,o=(0,i.resolve)(s?e:r(e),t);return n(t)||(o+=".ejs"),o},t.compile=function(t,e){return e&&e.scope&&(r||(console.warn("`scope` option is deprecated and will be removed in EJS 3"),r=!0),e.context||(e.context=e.scope),delete e.scope),new y(t,e).compile()},t.render=function(t,e,i){var r=e||s.createNullProtoObjWherePossible(),n=i||s.createNullProtoObjWherePossible();return 2==arguments.length&&s.shallowCopyFromList(n,r,a),p(n,t)(r)},t.renderFile=function(){var e,i,r,n=Array.prototype.slice.call(arguments),o=n.shift(),a={filename:o};return"function"==typeof arguments[arguments.length-1]&&(e=n.pop()),n.length?(i=n.shift(),n.length?s.shallowCopy(a,n.pop()):(i.settings&&(i.settings.views&&(a.views=i.settings.views),i.settings["view cache"]&&(a.cache=!0),(r=i.settings["view options"])&&s.shallowCopy(a,r)),s.shallowCopyFromList(a,i,l)),a.filename=o):i=s.createNullProtoObjWherePossible(),function(e,i,s){var r;if(!s){if("function"==typeof t.promiseImpl)return new t.promiseImpl(function(t,s){try{t(r=p(e)(i))}catch(t){s(t)}});throw new Error("Please provide a callback function")}try{r=p(e)(i)}catch(t){return s(t)}s(null,r)}(a,i,e)},t.Template=y,t.clearCache=function(){t.cache.reset()},y.modes={EVAL:"eval",ESCAPED:"escaped",RAW:"raw",COMMENT:"comment",LITERAL:"literal"},y.prototype={createRegex:function(){var t="(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)",e=s.escapeRegExpChars(this.opts.delimiter),i=s.escapeRegExpChars(this.opts.openDelimiter),r=s.escapeRegExpChars(this.opts.closeDelimiter);return t=t.replace(/%/g,e).replace(/</g,i).replace(/>/g,r),new RegExp(t)},compile:function(){var t,e,r,n=this.opts,o="",a="",l=n.escapeFunction,c=n.filename?JSON.stringify(n.filename):"undefined";if(!this.source){if(this.generateSource(),o+=' var __output = "";\n function __append(s) { if (s !== undefined && s !== null) __output += s }\n',n.outputFunctionName){if(!h.test(n.outputFunctionName))throw new Error("outputFunctionName is not a valid JS identifier.");o+=" var "+n.outputFunctionName+" = __append;\n"}if(n.localsName&&!h.test(n.localsName))throw new Error("localsName is not a valid JS identifier.");if(n.destructuredLocals&&n.destructuredLocals.length){for(var u=" var __locals = ("+n.localsName+" || {}),\n",p=0;p<n.destructuredLocals.length;p++){var d=n.destructuredLocals[p];if(!h.test(d))throw new Error("destructuredLocals["+p+"] is not a valid JS identifier.");p>0&&(u+=",\n "),u+=d+" = __locals."+d}o+=u+";\n"}!1!==n._with&&(o+=" with ("+n.localsName+" || {}) {\n",a+=" }\n"),a+=" return __output;\n",this.source=o+this.source+a}t=n.compileDebug?"var __line = 1\n , __lines = "+JSON.stringify(this.templateText)+"\n , __filename = "+c+";\ntry {\n"+this.source+"} catch (e) {\n rethrow(e, __lines, __filename, __line, escapeFn);\n}\n":this.source,n.client&&(t="escapeFn = escapeFn || "+l.toString()+";\n"+t,n.compileDebug&&(t="rethrow = rethrow || "+f.toString()+";\n"+t)),n.strict&&(t='"use strict";\n'+t),n.debug&&console.log(t),n.compileDebug&&n.filename&&(t=t+"\n//# sourceURL="+c+"\n");try{if(n.async)try{r=new Function("return (async function(){}).constructor;")()}catch(t){throw t instanceof SyntaxError?new Error("This environment does not support async/await"):t}else r=Function;e=new r(n.localsName+", escapeFn, include, rethrow",t)}catch(t){throw t instanceof SyntaxError&&(n.filename&&(t.message+=" in "+n.filename),t.message+=" while compiling ejs\n\n",t.message+="If the above error is not helpful, you may want to try EJS-Lint:\n",t.message+="https://github.com/RyanZim/EJS-Lint",n.async||(t.message+="\n",t.message+="Or, if you meant to create an async function, pass `async: true` as an option.")),t}var g=n.client?e:function(t){return e.apply(n.context,[t||s.createNullProtoObjWherePossible(),l,function(e,i){var r=s.shallowCopy(s.createNullProtoObjWherePossible(),t);return i&&(r=s.shallowCopy(r,i)),m(e,n)(r)},f])};if(n.filename&&"function"==typeof Object.defineProperty){var y=n.filename,w=i.basename(y,i.extname(y));try{Object.defineProperty(g,"name",{value:w,writable:!1,enumerable:!1,configurable:!0})}catch(t){}}return g},generateSource:function(){this.opts.rmWhitespace&&(this.templateText=this.templateText.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),this.templateText=this.templateText.replace(/[ \t]*<%_/gm,"<%_").replace(/_%>[ \t]*/gm,"_%>");var t=this,e=this.parseTemplateText(),i=this.opts.delimiter,s=this.opts.openDelimiter,r=this.opts.closeDelimiter;e&&e.length&&e.forEach(function(n,o){var a;if(0===n.indexOf(s+i)&&0!==n.indexOf(s+i+i)&&(a=e[o+2])!=i+r&&a!="-"+i+r&&a!="_"+i+r)throw new Error('Could not find matching close tag for "'+n+'".');t.scanLine(n)})},parseTemplateText:function(){for(var t,e=this.templateText,i=this.regex,s=i.exec(e),r=[];s;)0!==(t=s.index)&&(r.push(e.substring(0,t)),e=e.slice(t)),r.push(s[0]),e=e.slice(s[0].length),s=i.exec(e);return e&&r.push(e),r},_addOutput:function(t){if(this.truncate&&(t=t.replace(/^(?:\r\n|\r|\n)/,""),this.truncate=!1),!t)return t;t=(t=(t=(t=t.replace(/\\/g,"\\\\")).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/"/g,'\\"'),this.source+=' ; __append("'+t+'")\n'},scanLine:function(t){var e,i=this.opts.delimiter,s=this.opts.openDelimiter,r=this.opts.closeDelimiter;switch(e=t.split("\n").length-1,t){case s+i:case s+i+"_":this.mode=y.modes.EVAL;break;case s+i+"=":this.mode=y.modes.ESCAPED;break;case s+i+"-":this.mode=y.modes.RAW;break;case s+i+"#":this.mode=y.modes.COMMENT;break;case s+i+i:this.mode=y.modes.LITERAL,this.source+=' ; __append("'+t.replace(s+i+i,s+i)+'")\n';break;case i+i+r:this.mode=y.modes.LITERAL,this.source+=' ; __append("'+t.replace(i+i+r,i+r)+'")\n';break;case i+r:case"-"+i+r:case"_"+i+r:this.mode==y.modes.LITERAL&&this._addOutput(t),this.mode=null,this.truncate=0===t.indexOf("-")||0===t.indexOf("_");break;default:if(this.mode){switch(this.mode){case y.modes.EVAL:case y.modes.ESCAPED:case y.modes.RAW:t.lastIndexOf("//")>t.lastIndexOf("\n")&&(t+="\n")}switch(this.mode){case y.modes.EVAL:this.source+=" ; "+t+"\n";break;case y.modes.ESCAPED:this.source+=" ; __append(escapeFn("+g(t)+"))\n";break;case y.modes.RAW:this.source+=" ; __append("+g(t)+")\n";break;case y.modes.COMMENT:break;case y.modes.LITERAL:this._addOutput(t)}}else this._addOutput(t)}this.opts.compileDebug&&e&&(this.currentLine+=e,this.source+=" ; __line = "+this.currentLine+"\n")}},t.escapeXML=s.escapeXML,t.__express=t.renderFile,t.VERSION=n,t.name="ejs","undefined"!=typeof window&&(window.ejs=t)}(Rn);var Hn=H(Rn);class Wn{constructor(t){this.templateDir=t.templateDir,this.targetDir=t.targetDir,this.context=t.context,this.fileManager=new w(t.targetDir),this.logger=new b}async generate(){await this.processDir(this.templateDir,this.targetDir),this.logger.info(`模板渲染完成: ${this.targetDir}`)}async processDir(t,e){const i=await Ln.readdir(t,{withFileTypes:!0});for(const s of i){if(!this.context.ssr&&s.name.includes("entry-server"))continue;const i=O.join(t,s.name),r=s.name.replace(/\.ejs$/,""),n=O.join(e,r);if(s.isDirectory())await Ln.ensureDir(n),await this.processDir(i,n);else if(s.name.endsWith(".ejs")){const t=await Ln.readFile(i,"utf-8"),e=Hn.render(t,this.context);await Ln.outputFile(n,e)}else await Ln.copyFile(i,n)}}}function Bn(t,e){const i=new Ni,s=[],r={prompt:t=>i.prompt(t),log:t=>e.done(t),addDependency(t,e="latest",i=!1){s.push({pkgName:t,version:e,dev:i})}};return r.__pendingDeps=s,r}async function qn(t,e,i,s){const r=`${t}/generator`;try{const n=E(import.meta.url).resolve(r,{paths:[e]}),o=await import(n),a=o.default??o;if("function"!=typeof a)return s.warn(`${t} 的 generator 不是函数,跳过`),!1;await a(e,i);const l=i.__pendingDeps??[];return function(t,e){if(!e.length)return;const i=O.join(t,"package.json");if(!C.existsSync(i))return;const s=JSON.parse(C.readFileSync(i,"utf-8"));for(const{pkgName:t,version:i,dev:r}of e){const e=r?"devDependencies":"dependencies";s[e]=s[e]||{},s[e][t]=i}C.writeFileSync(i,JSON.stringify(s,null,2)+"\n","utf-8")}(e,l),l.length>0}catch(e){return"MODULE_NOT_FOUND"===e?.code?s.warn(`${t} 未提供 generator,跳过`):s.error(`generator 执行失败: ${e?.message??e}`),!1}}function Un(t,e){return{kind:"npm",cliVersion:function(){try{const t=T(import.meta.url),e=t.resolve("@bundlekit/cli/package.json",{paths:[process.cwd()]}),i=t(e);if(i?.version)return i.version}catch{}try{const t=a.dirname(j(import.meta.url)),e=[a.resolve(t,"../package.json"),a.resolve(t,"../../package.json")];for(const t of e)try{const e=T(import.meta.url)(t);if("@bundlekit/cli"===e?.name&&e?.version)return e.version}catch{}}catch{}return"*"}()}}function zn(t,e){return`^${e.cliVersion}`}function Jn(t){const e=/^@bundlekit\/(.+)$/.exec(t.trim());return e?e[1]:null}function Gn(t,e){if(!/^[a-z0-9@.\-_]+$/.test(t))throw new Error(`项目名称 "${t}" 不合法,只能包含小写字母、数字、@、.、-、_`);const i=O.resolve(e,t);if(new w(e).isFilePathExist(i))throw new Error(`目录 ${i} 已存在,请选择其他项目名称`);return{targetDir:i}}function Kn(t){return Yn(t).startsWith("vue")?"@bundlekit/plugin-vue":"@bundlekit/plugin-react"}function Yn(t){return{react:"react-ts",vue:"vue3-ts",vue3:"vue3-ts","react-ts":"react-ts","react-js":"react-js","vue3-ts":"vue3-ts","vue3-js":"vue3-js"}[t]??t}function Zn(t){const e=Yn(t),i=Kn(t);try{const t=E(import.meta.url).resolve(`${i}/package.json`),s=O.join(O.dirname(t),"templates",`template-${e}`);if(C.existsSync(s))return s}catch{}const s=O.dirname(A(import.meta.url)),r=i.replace("@bundlekit/","bundlekit-"),n=O.resolve(s,"../..",r,"templates",`template-${e}`);if(C.existsSync(n))return n;throw new Error(`模板 "${t}" 未找到,可用模板:react-ts / react-js / vue3-ts / vue3-js`)}async function Xn(t){const e=new Wn({templateDir:t.templateDir,targetDir:t.targetDir,context:{projectName:t.projectName,description:t.description||"",bundler:t.bundler,ssr:!!t.ssr}});await e.generate()}function Qn(t,e,i){const s=_(e);return s?function(t,e,i){const s=v[e],r=zn(0,i),n=a.join(t,"package.json"),o=JSON.parse(l.readFileSync(n,"utf-8"));return o.devDependencies=o.devDependencies||{},o.devDependencies[s]=r,o.devDependencies=Object.fromEntries(Object.entries(o.devDependencies).sort(([t],[e])=>t.localeCompare(e))),l.writeFileSync(n,JSON.stringify(o,null,2)+"\n"),[s,r]}(t,s,i):null}function to(t,e){!function(t,e){const i=a.join(t,"package.json"),s=l.readFileSync(i,"utf-8"),r=JSON.parse(s),n=[],o=["dependencies","devDependencies","peerDependencies","optionalDependencies"];for(const t of o){const i=r[t];if(i&&"object"==typeof i)for(const t of Object.keys(i)){const s=i[t];if("string"!=typeof s)continue;if(!s.startsWith("workspace:"))continue;if(!Jn(t)){i[t]=s.replace(/^workspace:/,"");continue}const r=zn(0,e);n.push([t,s,r]),i[t]=r}}l.writeFileSync(i,JSON.stringify(r,null,2)+"\n")}(t,e)}async function eo(t,e){const i=e?.pm?e.pm:void 0,s=new S({context:t,forcePackageManager:i});await s.install()}function io(){const t=t=>{try{return 0===k(t,["--version"],{stdio:"ignore",shell:"win32"===process.platform}).status}catch{return!1}};return{pnpm:t("pnpm"),yarn:t("yarn"),npm:t("npm")}}async function so(t,e,i){return qn(t,e,Bn(0,i),i)}class ro{constructor(){this.logger=new b}async create(t,e={}){const i=new x,s=e.cwd||process.cwd(),r=e.template||"react-ts",n=e.bundler||"webpack",o=e.pm||void 0,a=Un();let l;try{({targetDir:l}=Gn(t,s))}catch(t){this.logger.error(t.message),process.exit(1)}i.logWithSpinner("📦",`正在创建项目 ${t}...`);const c=Zn(r);await Xn({targetDir:l,templateDir:c,projectName:t,description:e.description,bundler:n,ssr:!!e.ssr}),to(l,a),this.logger.info(`依赖模式:npm 模式(^${a.cliVersion})`);const h=Qn(l,n,a);if(h){const[t,e]=h;this.logger.info(`已写入 ${t}@${e} 到 devDependencies`)}else this.logger.warn(`bundler "${n}" 不在内置列表中,跳过 devDeps 写入`);const u="1"===process.env.DEVKIT_SKIP_INSTALL;u||(i.logWithSpinner("📦","正在安装依赖..."),await eo(l,{pm:o}),i.stopSpinner(!1)),this.logger.done(`项目 ${t} 创建成功!`);const p=process.env.DEVKIT_NO_PROMPT;process.env.DEVKIT_NO_PROMPT="1";let d=!1;try{const t=Kn(r);d=await so(t,l,this.logger)}finally{void 0===p?delete process.env.DEVKIT_NO_PROMPT:process.env.DEVKIT_NO_PROMPT=p}d&&(to(l,a),u||(this.logger.info("正在安装追加的依赖..."),await eo(l,{pm:o})));const m="npm"===o?"npm run dev":`${o||"pnpm"} dev`;this.logger.log(`\n cd ${t}`),this.logger.log(` ${m}\n`)}}const no={mock:"@bundlekit/plugin-mock",react:"@bundlekit/plugin-react",vue:"@bundlekit/plugin-vue",request:"@bundlekit/request"};class oo{constructor(t){this.context=t||process.cwd(),this.logger=new b}async add(t){const e=function(t){const e=(()=>{const e=_(t);return e?v[e]:null})();if(e)return e;const[i]=t.split("@").filter(Boolean);return no[i]??t}(t),i=function(t){return/\/plugin-|^plugin-/.test(t)}(e),s=function(t){return/^@bundlekit\/bundler-/.test(t)}(e),r=i||s;this.logger.info(`解析插件: ${t} → ${e}`),this.logger.info("类型: "+(s?"构建工具适配器(devDependency)":i?"构建插件(devDependency)":"运行时库(dependency)"));const n=new S({context:this.context});if(await n.add(e,{dev:r})){if(this.logger.done(`已安装 ${e}`),i&&!s){const t=Bn(this.context,this.logger);if(await qn(e,this.context,t,this.logger)){this.logger.info("正在安装追加的依赖...");const t=new S({context:this.context});await t.install()}}}else this.logger.error(`安装 ${e} 失败`)}}const ao=({version:t=""})=>N(d,{flexDirection:"column",marginBottom:1,children:[F(I,{name:"atlas",children:F(L,{text:"DEVKIT-CLI",font:"block"})}),F(d,{marginLeft:1,children:F(m,{dimColor:!0,children:`bundlekit${t?` v${t}`:""} · 多打包器构建工具`})})]}),lo=({title:t,step:e,total:i,children:s})=>N(d,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,marginBottom:1,children:[F(d,{marginBottom:1,children:F(m,{bold:!0,color:"cyan",children:e&&i?`Step ${e}/${i} · ${t}`:t})}),s]});function co(t,e,i){if(0===t.length)return-1;const s=t.length;let r=e;for(let e=0;e<s;e++)if(r=(r+i+s)%s,!t[r].disabled)return r;return-1}function ho(t){const{items:r,initialValue:n,onSelect:o,onBack:a}=t,l=e(()=>{if(n){const t=r.findIndex(t=>t.value===n&&!t.disabled);if(t>=0)return t}const t=r.findIndex(t=>!t.disabled);return t>=0?t:0},[r,n]),[c,h]=i(l);return s(()=>{if(c>=r.length||r[c]?.disabled){const t=r.findIndex(t=>!t.disabled);h(t>=0?t:0)}},[r]),f((t,e)=>{if(e.upArrow||"k"===t){const t=co(r,c,-1);return void(t>=0&&h(t))}if(e.downArrow||"j"===t){const t=co(r,c,1);return void(t>=0&&h(t))}if(e.return){const t=r[c];return void(t&&!t.disabled&&o(t.value))}(e.escape||e.backspace||e.delete)&&a&&a()}),F(d,{flexDirection:"column",children:r.map((t,e)=>{const i=e===c,s=!!t.disabled,r=i?"▶ ":" ",n=s?void 0:i?"cyan":void 0,o=s||!i,a=s&&t.disabledReason?` ${t.disabledReason}`:"";return N(d,{children:[F(m,{color:i&&!s?"cyan":void 0,children:r}),N(m,{color:n,dimColor:o,children:[t.label,a]})]},String(t.value))})})}const uo=({value:t,placeholder:e,onChange:i,onSubmit:s})=>F(R,{value:t,placeholder:e,onChange:i,onSubmit:s}),po={pending:"○",running:"",done:"✔",error:"✘"},mo={pending:"gray",running:"cyan",done:"green",error:"red"},fo=({tasks:t})=>F(d,{flexDirection:"column",children:t.map(t=>N(d,{children:[F(d,{width:3,children:"running"===t.status?F(m,{color:"cyan",children:F(V,{type:"dots"})}):F(m,{color:mo[t.status],children:po[t.status]})}),F(m,{color:"pending"===t.status?"gray":void 0,children:t.label}),t.detail?N(m,{dimColor:!0,children:[" (",t.detail,")"]}):null]},t.id))});function go(t,e){return"npm"===t?`npm run ${e}`:`${t} ${e}`}const yo=({name:t,bundler:e,template:i,pm:s="pnpm"})=>{const r=go(s,"dev"),n=go(s,"build");return N(d,{flexDirection:"column",marginTop:1,children:[N(d,{children:[F(m,{color:"green",bold:!0,children:" ✔ 项目 "}),F(m,{color:"cyan",bold:!0,children:t}),F(m,{color:"green",bold:!0,children:" 创建成功"})]}),N(d,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:"green",paddingX:1,children:[i&&N(d,{children:[F(m,{dimColor:!0,children:"模板 "}),F(m,{color:"cyan",children:i})]}),N(d,{children:[F(m,{dimColor:!0,children:"打包器 "}),F(m,{color:"cyan",children:e})]}),N(d,{children:[F(m,{dimColor:!0,children:"包管理器 "}),F(m,{color:"cyan",children:s})]}),N(d,{children:[F(m,{dimColor:!0,children:"位置 "}),F(m,{color:"cyan",children:`./${t}`})]})]}),N(d,{flexDirection:"column",marginTop:1,children:[F(m,{dimColor:!0,children:"下一步:"}),N(d,{marginLeft:2,marginTop:1,flexDirection:"column",children:[N(d,{children:[F(m,{color:"gray",children:"$ "}),F(m,{color:"cyan",children:`cd ${t}`})]}),N(d,{children:[F(m,{color:"gray",children:"$ "}),F(m,{color:"cyan",children:r}),F(m,{dimColor:!0,children:` 使用 ${e} 启动开发服务`})]}),N(d,{children:[F(m,{color:"gray",children:"$ "}),F(m,{color:"cyan",children:n}),F(m,{dimColor:!0,children:" 生产构建"})]})]})]}),N(d,{marginTop:1,children:[F(m,{dimColor:!0,children:"提示:"}),N(m,{dimColor:!0,children:["使用 ",N(m,{color:"cyan",children:["dc add bundler-","<name>"]})," 切换打包器,使用 ",N(m,{color:"cyan",children:["dc add ","<plugin>"]})," 追加插件"]})]})]})},wo=({step:t,message:e,stack:i})=>N(d,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:"red",paddingX:1,children:[F(d,{children:N(m,{color:"red",bold:!0,children:["✘ ",t," 失败"]})}),F(d,{marginTop:1,children:F(m,{color:"redBright",children:e})}),i?F(d,{marginTop:1,children:F(m,{dimColor:!0,children:i})}):null]}),bo=[{label:"React + TypeScript",value:"react-ts"},{label:"React + JavaScript",value:"react-js"},{label:"Vue 3 + TypeScript",value:"vue3-ts"},{label:"Vue 3 + JavaScript",value:"vue3-js"}],vo=[{label:"Vite —— 开发体感最佳",value:"vite"},{label:"Webpack —— 生态最完整",value:"webpack"},{label:"Rspack —— Rust 实现,极速",value:"rspack"},{label:"更多打包器 →",value:"__more__"}],_o=[{label:"Rollup —— 适合库构建",value:"rollup"},{label:"Rolldown —— 实验性",value:"rolldown"},{label:"← 返回",value:"__back__"}],So=["pnpm","yarn","npm"],xo={pnpm:"pnpm —— 推荐,磁盘占用最小",yarn:"yarn —— 兼容性好",npm:"npm —— Node 内置"};const Oo=({params:t})=>{const{exit:n}=g(),[o,a]=i(t.template),[l,c]=i(t.bundler),[h,u]=i("primary"),p=e(()=>io(),[]),f=e(()=>function(){const t=process.env.DEVKIT_PM;if("pnpm"===t||"yarn"===t||"npm"===t)return t}(),[]),[y,w]=i(function(t,e,i){return t&&i[t]?t:e&&i[e]?e:void 0}(t.pm,f,p));e(()=>Un(t.cwd||process.cwd()),[t.cwd]);const[v,_]=i(t.description||""),[S,x]=i(void 0!==t.description),[O,C]=i([]),[k,E]=i(null);let A;A=k?"error":O.length>0&&O.every(t=>"done"===t.status)?"done":O.length>0?"tasks":o?l?y?S?"tasks":"description":"pm":"bundler":"template";const $=r((t,e)=>{C(i=>i.map(i=>i.id===t?{...i,...e}:i))},[]);s(()=>{if("tasks"!==A)return;if(O.length>0)return;C([{id:"render",label:"渲染模板",status:"pending"},{id:"normalize",label:"规范化依赖版本",status:"pending"},{id:"deps",label:"写入 bundler 到 devDependencies",status:"pending"},{id:"install",label:"安装依赖",status:"pending"},{id:"generator",label:"调用框架插件 generator",status:"pending"}]),(async()=>{const e=t.cwd||process.cwd();let i;try{({targetDir:i}=Gn(t.name,e))}catch(t){return void E({step:"校验项目",message:t.message})}const s=new b,r=Un();try{$("render",{status:"running"});const e=Zn(o);await Xn({targetDir:i,templateDir:e,projectName:t.name,description:v,bundler:l,ssr:!!t.ssr}),$("render",{status:"done"})}catch(t){const e=t;return $("render",{status:"error"}),void E({step:"渲染模板",message:e.message,stack:e.stack})}try{$("normalize",{status:"running"}),to(i,r);const t=`npm 模式 → ^${r.cliVersion}`;$("normalize",{status:"done",detail:t})}catch(t){const e=t;return $("normalize",{status:"error"}),void E({step:"规范化依赖版本",message:e.message,stack:e.stack})}try{$("deps",{status:"running"});const t=Qn(i,l,r);if(t){const[e,i]=t;$("deps",{status:"done",detail:`${e}@${i}`})}else $("deps",{status:"done",detail:"未识别的 bundler,跳过"})}catch(t){const e=t;return $("deps",{status:"error"}),void E({step:"写入 devDependencies",message:e.message,stack:e.stack})}try{$("install",{status:"running"}),await eo(i,{pm:y}),$("install",{status:"done"})}catch(t){const e=t;return $("install",{status:"error"}),void E({step:"安装依赖",message:e.message,stack:e.stack})}try{$("generator",{status:"running"});const t=Kn(o),e=process.env.DEVKIT_NO_PROMPT;process.env.DEVKIT_NO_PROMPT="1";let n=!1;try{n=await so(t,i,s)}finally{void 0===e?delete process.env.DEVKIT_NO_PROMPT:process.env.DEVKIT_NO_PROMPT=e}n&&(to(i,r),await eo(i,{pm:y})),$("generator",{status:"done"})}catch(t){const e=t;return $("generator",{status:"error"}),void E({step:"调用 generator",message:e.message,stack:e.stack})}})()},[A,O.length,o,l,y,v,t,$]),s(()=>{if("done"===A){const t=setTimeout(()=>n(),100);return()=>clearTimeout(t)}if("error"===A){const t=setTimeout(()=>{n(),process.exit(1)},100);return()=>clearTimeout(t)}},[A,n]);const P=e(()=>So.map(t=>({label:xo[t],value:t,disabled:!p[t],disabledReason:p[t]?void 0:"(未安装)"})),[p]);return N(d,{flexDirection:"column",children:[F(ao,{}),"template"===A&&F(lo,{title:"模板",step:1,total:4,children:F(ho,{items:bo,initialValue:o,onSelect:t=>a(t)})}),"bundler"===A&&N(lo,{title:"打包器",step:2,total:4,children:[N(d,{marginBottom:1,children:[F(m,{dimColor:!0,children:"已选模板:"}),N(m,{color:"cyan",children:[" ",o]})]}),F(ho,"primary"===h?{items:vo,initialValue:l,onSelect:t=>{"__more__"===t?u("secondary"):c(t)}}:{items:_o,onSelect:t=>{"__back__"===t?u("primary"):c(t)},onBack:()=>u("primary")})]}),"pm"===A&&N(lo,{title:"包管理器",step:3,total:4,children:[F(d,{marginBottom:1,children:F(m,{dimColor:!0,children:"用于安装项目依赖:"})}),F(ho,{items:P,onSelect:t=>w(t)})]}),"description"===A&&F(lo,{title:"项目描述(可选,按回车跳过)",step:4,total:4,children:F(uo,{value:v,placeholder:"A demo app",onChange:_,onSubmit:t=>{_(t||" "),x(!0)}})}),("tasks"===A||"done"===A)&&N(d,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,marginBottom:1,children:[N(d,{marginBottom:1,children:[F(m,{bold:!0,color:"cyan",children:"创建项目 "}),F(m,{bold:!0,children:t.name}),F(m,{dimColor:!0,children:` ${o} · ${l} · ${y}`})]}),F(fo,{tasks:O})]}),"done"===A&&F(yo,{name:t.name,bundler:l,template:o,pm:y}),"error"===A&&k&&F(wo,{step:k.step,message:k.message,stack:k.stack})]})},Co=({params:t})=>{const{exit:e}=g(),[r,n]=i([{id:"resolve",label:`解析 ${t.plugin}`,status:"pending"},{id:"install",label:"安装依赖",status:"pending"},{id:"generator",label:"调用 generator (如有)",status:"pending"}]),[o,a]=i(null);return s(()=>{const i=(t,e)=>{n(i=>i.map(i=>i.id===t?{...i,...e}:i))};(async()=>{try{i("resolve",{status:"running"});const e=t.cwd||process.cwd(),s=new oo(e);i("resolve",{status:"done"}),i("install",{status:"running"}),await s.add(t.plugin),i("install",{status:"done"}),i("generator",{status:"done"})}catch(t){const e=t;a({step:"add",message:e.message,stack:e.stack})}finally{setTimeout(()=>e(),100)}})()},[t,e]),N(d,{flexDirection:"column",children:[F(ao,{}),N(d,{marginBottom:1,children:[F(m,{children:"追加:"}),N(m,{color:"cyan",bold:!0,children:[" ",t.plugin]})]}),F(fo,{tasks:r}),o&&F(wo,{step:o.step,message:o.message,stack:o.stack})]})},ko=t=>"create"===t.command?F(Oo,{params:t.params}):"add"===t.command?F(Co,{params:t.params}):null,Eo=new St,Ao=[{name:"react-ts",message:"React + TypeScript"},{name:"react-js",message:"React + JavaScript"},{name:"vue3-ts",message:"Vue 3 + TypeScript"},{name:"vue3-js",message:"Vue 3 + JavaScript"}],$o=[{name:"vite",message:"Vite"},{name:"webpack",message:"Webpack"},{name:"rspack",message:"Rspack"},{name:"rollup",message:"Rollup"},{name:"rolldown",message:"Rolldown"}];function Po(){return"1"!==process.env.DEVKIT_NO_INK&&(!!process.stdout.isTTY&&!!process.stdin.isTTY)}function Do(t){return"pnpm"===t||"yarn"===t||"npm"===t}async function To(t,e){const i=new Ni;if(!e.template){const t=await i.prompt({type:"select",name:"template",message:"请选择项目模板:",choices:Ao});e.template=t.template}if(!e.bundler){const t=await i.prompt({type:"select",name:"bundler",message:"请选择默认构建工具:",choices:$o});e.bundler=t.bundler}let s=Do(e.pm)?e.pm:void 0;if(s||(s=function(){const t=process.env.DEVKIT_PM;if("pnpm"===t||"yarn"===t||"npm"===t)return t}()),!s){const t=io(),e=["pnpm","yarn","npm"].filter(e=>t[e]).map(t=>({name:t,message:t}));if(0===e.length)s="npm";else if(1===e.length)s=e[0].name;else{s=(await i.prompt({type:"select",name:"pm",message:"请选择包管理器:",choices:e})).pm}}e.pm=s;const r=new ro;await r.create(t,e)}Eo.command("create <name>").description("create a new project powered by bundlekit-service").option("-t, --template <template>","模板类型 (react-ts, react-js, vue3-ts, vue3-js)").option("-b, --bundler <bundler>","默认构建工具 (vite, webpack, rspack, rollup, rolldown)").option("-d, --description <desc>","项目描述").option("--pm <pm>","包管理器 (pnpm, yarn, npm)").option("--ssr","启用 SSR:模板生成 entry-client/entry-server + .bundlekitrc.ts 加 ssr 配置块",!1).action(async(e,i)=>{if(!Po())return void await To(e,i);process.env.DEVKIT_QUIET="1";const s=Do(i.pm)?i.pm:void 0,{waitUntilExit:r}=y(t.createElement(ko,{command:"create",params:{name:e,template:i.template,bundler:i.bundler,pm:s,description:i.description,ssr:!!i.ssr}}));await r()}),Eo.command("add <plugin>").description("向已有项目添加插件 / bundler 适配器").action(async e=>{if(!Po()){const t=new oo(process.cwd());return void await t.add(e)}process.env.DEVKIT_QUIET="1";const{waitUntilExit:i}=y(t.createElement(ko,{command:"add",params:{plugin:e}}));await i()}),Eo.command("help").alias("h").description("处理帮助信息 -h").action(()=>{Eo.outputHelp()}),Eo.command("version").alias("v").description("bundlekit-cli版本 -v").action(()=>{const t=require("../package.json");console.log(`bundlekit-cli v${t.version}`)}),Eo.parse(process.argv);
10
+ var e=k,i=C,s=Vn,r=!1,n=Mn,o="locals",a=["delimiter","scope","context","debug","compileDebug","client","_with","rmWhitespace","strict","filename","async"],l=a.concat("cache"),c=/^\uFEFF/,h=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/;function u(i,s){var r;if(s.some(function(s){return r=t.resolveInclude(i,s,!0),e.existsSync(r)}))return r}function p(e,i){var s,r=e.filename,n=arguments.length>1;if(e.cache){if(!r)throw new Error("cache option requires a filename");if(s=t.cache.get(r))return s;n||(i=d(r).toString().replace(c,""))}else if(!n){if(!r)throw new Error("Internal EJS error: no file name or template provided");i=d(r).toString().replace(c,"")}return s=t.compile(i,e),e.cache&&t.cache.set(r,s),s}function d(e){return t.fileLoader(e)}function m(i,r){var n=s.shallowCopy(s.createNullProtoObjWherePossible(),r);if(n.filename=function(i,s){var r,n,o=s.views,a=/^[A-Za-z]+:\\|^\//.exec(i);if(a&&a.length)i=i.replace(/^\/*/,""),r=Array.isArray(s.root)?u(i,s.root):t.resolveInclude(i,s.root||"/",!0);else if(s.filename&&(n=t.resolveInclude(i,s.filename),e.existsSync(n)&&(r=n)),!r&&Array.isArray(o)&&(r=u(i,o)),!r&&"function"!=typeof s.includer)throw new Error('Could not find the include file "'+s.escapeFunction(i)+'"');return r}(i,n),"function"==typeof r.includer){var o=r.includer(i,n.filename);if(o&&(o.filename&&(n.filename=o.filename),o.template))return p(n,o.template)}return p(n)}function f(t,e,i,s,r){var n=e.split("\n"),o=Math.max(s-3,0),a=Math.min(n.length,s+3),l=r(i),c=n.slice(o,a).map(function(t,e){var i=e+o+1;return(i==s?" >> ":" ")+i+"| "+t}).join("\n");throw t.path=l,t.message=(l||"ejs")+":"+s+"\n"+c+"\n\n"+t.message,t}function g(t){return t.replace(/;(\s*$)/,"$1")}function y(e,i){var r=s.hasOwnOnlyObject(i),n=s.createNullProtoObjWherePossible();this.templateText=e,this.mode=null,this.truncate=!1,this.currentLine=1,this.source="",n.client=r.client||!1,n.escapeFunction=r.escape||r.escapeFunction||s.escapeXML,n.compileDebug=!1!==r.compileDebug,n.debug=!!r.debug,n.filename=r.filename,n.openDelimiter=r.openDelimiter||t.openDelimiter||"<",n.closeDelimiter=r.closeDelimiter||t.closeDelimiter||">",n.delimiter=r.delimiter||t.delimiter||"%",n.strict=r.strict||!1,n.context=r.context,n.cache=r.cache||!1,n.rmWhitespace=r.rmWhitespace,n.root=r.root,n.includer=r.includer,n.outputFunctionName=r.outputFunctionName,n.localsName=r.localsName||t.localsName||o,n.views=r.views,n.async=r.async,n.destructuredLocals=r.destructuredLocals,n.legacyInclude=void 0===r.legacyInclude||!!r.legacyInclude,n.strict?n._with=!1:n._with=void 0===r._with||r._with,this.opts=n,this.regex=this.createRegex()}t.cache=s.cache,t.fileLoader=e.readFileSync,t.localsName=o,t.promiseImpl=new Function("return this;")().Promise,t.resolveInclude=function(t,e,s){var r=i.dirname,n=i.extname,o=(0,i.resolve)(s?e:r(e),t);return n(t)||(o+=".ejs"),o},t.compile=function(t,e){return e&&e.scope&&(r||(console.warn("`scope` option is deprecated and will be removed in EJS 3"),r=!0),e.context||(e.context=e.scope),delete e.scope),new y(t,e).compile()},t.render=function(t,e,i){var r=e||s.createNullProtoObjWherePossible(),n=i||s.createNullProtoObjWherePossible();return 2==arguments.length&&s.shallowCopyFromList(n,r,a),p(n,t)(r)},t.renderFile=function(){var e,i,r,n=Array.prototype.slice.call(arguments),o=n.shift(),a={filename:o};return"function"==typeof arguments[arguments.length-1]&&(e=n.pop()),n.length?(i=n.shift(),n.length?s.shallowCopy(a,n.pop()):(i.settings&&(i.settings.views&&(a.views=i.settings.views),i.settings["view cache"]&&(a.cache=!0),(r=i.settings["view options"])&&s.shallowCopy(a,r)),s.shallowCopyFromList(a,i,l)),a.filename=o):i=s.createNullProtoObjWherePossible(),function(e,i,s){var r;if(!s){if("function"==typeof t.promiseImpl)return new t.promiseImpl(function(t,s){try{t(r=p(e)(i))}catch(t){s(t)}});throw new Error("Please provide a callback function")}try{r=p(e)(i)}catch(t){return s(t)}s(null,r)}(a,i,e)},t.Template=y,t.clearCache=function(){t.cache.reset()},y.modes={EVAL:"eval",ESCAPED:"escaped",RAW:"raw",COMMENT:"comment",LITERAL:"literal"},y.prototype={createRegex:function(){var t="(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)",e=s.escapeRegExpChars(this.opts.delimiter),i=s.escapeRegExpChars(this.opts.openDelimiter),r=s.escapeRegExpChars(this.opts.closeDelimiter);return t=t.replace(/%/g,e).replace(/</g,i).replace(/>/g,r),new RegExp(t)},compile:function(){var t,e,r,n=this.opts,o="",a="",l=n.escapeFunction,c=n.filename?JSON.stringify(n.filename):"undefined";if(!this.source){if(this.generateSource(),o+=' var __output = "";\n function __append(s) { if (s !== undefined && s !== null) __output += s }\n',n.outputFunctionName){if(!h.test(n.outputFunctionName))throw new Error("outputFunctionName is not a valid JS identifier.");o+=" var "+n.outputFunctionName+" = __append;\n"}if(n.localsName&&!h.test(n.localsName))throw new Error("localsName is not a valid JS identifier.");if(n.destructuredLocals&&n.destructuredLocals.length){for(var u=" var __locals = ("+n.localsName+" || {}),\n",p=0;p<n.destructuredLocals.length;p++){var d=n.destructuredLocals[p];if(!h.test(d))throw new Error("destructuredLocals["+p+"] is not a valid JS identifier.");p>0&&(u+=",\n "),u+=d+" = __locals."+d}o+=u+";\n"}!1!==n._with&&(o+=" with ("+n.localsName+" || {}) {\n",a+=" }\n"),a+=" return __output;\n",this.source=o+this.source+a}t=n.compileDebug?"var __line = 1\n , __lines = "+JSON.stringify(this.templateText)+"\n , __filename = "+c+";\ntry {\n"+this.source+"} catch (e) {\n rethrow(e, __lines, __filename, __line, escapeFn);\n}\n":this.source,n.client&&(t="escapeFn = escapeFn || "+l.toString()+";\n"+t,n.compileDebug&&(t="rethrow = rethrow || "+f.toString()+";\n"+t)),n.strict&&(t='"use strict";\n'+t),n.debug&&console.log(t),n.compileDebug&&n.filename&&(t=t+"\n//# sourceURL="+c+"\n");try{if(n.async)try{r=new Function("return (async function(){}).constructor;")()}catch(t){throw t instanceof SyntaxError?new Error("This environment does not support async/await"):t}else r=Function;e=new r(n.localsName+", escapeFn, include, rethrow",t)}catch(t){throw t instanceof SyntaxError&&(n.filename&&(t.message+=" in "+n.filename),t.message+=" while compiling ejs\n\n",t.message+="If the above error is not helpful, you may want to try EJS-Lint:\n",t.message+="https://github.com/RyanZim/EJS-Lint",n.async||(t.message+="\n",t.message+="Or, if you meant to create an async function, pass `async: true` as an option.")),t}var g=n.client?e:function(t){return e.apply(n.context,[t||s.createNullProtoObjWherePossible(),l,function(e,i){var r=s.shallowCopy(s.createNullProtoObjWherePossible(),t);return i&&(r=s.shallowCopy(r,i)),m(e,n)(r)},f])};if(n.filename&&"function"==typeof Object.defineProperty){var y=n.filename,w=i.basename(y,i.extname(y));try{Object.defineProperty(g,"name",{value:w,writable:!1,enumerable:!1,configurable:!0})}catch(t){}}return g},generateSource:function(){this.opts.rmWhitespace&&(this.templateText=this.templateText.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),this.templateText=this.templateText.replace(/[ \t]*<%_/gm,"<%_").replace(/_%>[ \t]*/gm,"_%>");var t=this,e=this.parseTemplateText(),i=this.opts.delimiter,s=this.opts.openDelimiter,r=this.opts.closeDelimiter;e&&e.length&&e.forEach(function(n,o){var a;if(0===n.indexOf(s+i)&&0!==n.indexOf(s+i+i)&&(a=e[o+2])!=i+r&&a!="-"+i+r&&a!="_"+i+r)throw new Error('Could not find matching close tag for "'+n+'".');t.scanLine(n)})},parseTemplateText:function(){for(var t,e=this.templateText,i=this.regex,s=i.exec(e),r=[];s;)0!==(t=s.index)&&(r.push(e.substring(0,t)),e=e.slice(t)),r.push(s[0]),e=e.slice(s[0].length),s=i.exec(e);return e&&r.push(e),r},_addOutput:function(t){if(this.truncate&&(t=t.replace(/^(?:\r\n|\r|\n)/,""),this.truncate=!1),!t)return t;t=(t=(t=(t=t.replace(/\\/g,"\\\\")).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/"/g,'\\"'),this.source+=' ; __append("'+t+'")\n'},scanLine:function(t){var e,i=this.opts.delimiter,s=this.opts.openDelimiter,r=this.opts.closeDelimiter;switch(e=t.split("\n").length-1,t){case s+i:case s+i+"_":this.mode=y.modes.EVAL;break;case s+i+"=":this.mode=y.modes.ESCAPED;break;case s+i+"-":this.mode=y.modes.RAW;break;case s+i+"#":this.mode=y.modes.COMMENT;break;case s+i+i:this.mode=y.modes.LITERAL,this.source+=' ; __append("'+t.replace(s+i+i,s+i)+'")\n';break;case i+i+r:this.mode=y.modes.LITERAL,this.source+=' ; __append("'+t.replace(i+i+r,i+r)+'")\n';break;case i+r:case"-"+i+r:case"_"+i+r:this.mode==y.modes.LITERAL&&this._addOutput(t),this.mode=null,this.truncate=0===t.indexOf("-")||0===t.indexOf("_");break;default:if(this.mode){switch(this.mode){case y.modes.EVAL:case y.modes.ESCAPED:case y.modes.RAW:t.lastIndexOf("//")>t.lastIndexOf("\n")&&(t+="\n")}switch(this.mode){case y.modes.EVAL:this.source+=" ; "+t+"\n";break;case y.modes.ESCAPED:this.source+=" ; __append(escapeFn("+g(t)+"))\n";break;case y.modes.RAW:this.source+=" ; __append("+g(t)+")\n";break;case y.modes.COMMENT:break;case y.modes.LITERAL:this._addOutput(t)}}else this._addOutput(t)}this.opts.compileDebug&&e&&(this.currentLine+=e,this.source+=" ; __line = "+this.currentLine+"\n")}},t.escapeXML=s.escapeXML,t.__express=t.renderFile,t.VERSION=n,t.name="ejs","undefined"!=typeof window&&(window.ejs=t)}(Ln);var Hn=H(Ln);class Wn{constructor(t){this.templateDir=t.templateDir,this.targetDir=t.targetDir,this.context=t.context,this.fileManager=new b(t.targetDir),this.logger=new v}async generate(){await this.processDir(this.templateDir,this.targetDir),this.logger.info(`模板渲染完成: ${this.targetDir}`)}async processDir(t,e){const i=await Rn.readdir(t,{withFileTypes:!0});for(const s of i){if(!this.context.ssr&&(s.name.includes("entry-server")||s.name.includes("entry-client")))continue;if(this.context.ssr&&("index.tsx"===s.name||"index.jsx"===s.name||"main.ts"===s.name||"main.js"===s.name||"index.tsx.ejs"===s.name||"index.jsx.ejs"===s.name||"main.ts.ejs"===s.name||"main.js.ejs"===s.name))continue;const i=C.join(t,s.name),r=s.name.replace(/\.ejs$/,""),n=C.join(e,r);if(s.isDirectory())await Rn.ensureDir(n),await this.processDir(i,n);else if(s.name.endsWith(".ejs")){const t=await Rn.readFile(i,"utf-8"),e=Hn.render(t,this.context);await Rn.outputFile(n,e)}else await Rn.copyFile(i,n)}}}function Bn(t,e){const i=new Ni,s=[],r={prompt:t=>i.prompt(t),log:t=>e.done(t),addDependency(t,e="latest",i=!1){s.push({pkgName:t,version:e,dev:i})}};return r.__pendingDeps=s,r}async function qn(t,e,i,s){const r=`${t}/generator`;try{const n=w(import.meta.url).resolve(r,{paths:[e]}),o=await import(n),a=o.default??o;if("function"!=typeof a)return s.warn(`${t} 的 generator 不是函数,跳过`),!1;await a(e,i);const l=i.__pendingDeps??[];return function(t,e){if(!e.length)return;const i=C.join(t,"package.json");if(!k.existsSync(i))return;const s=JSON.parse(k.readFileSync(i,"utf-8"));for(const{pkgName:t,version:i,dev:r}of e){const e=r?"devDependencies":"dependencies";s[e]=s[e]||{},s[e][t]=i}k.writeFileSync(i,JSON.stringify(s,null,2)+"\n","utf-8")}(e,l),l.length>0}catch(e){return"MODULE_NOT_FOUND"===e?.code?s.warn(`${t} 未提供 generator,跳过`):s.error(`generator 执行失败: ${e?.message??e}`),!1}}function Un(t,e){return{kind:"npm",cliVersion:function(){try{const t=T(import.meta.url),e=t.resolve("@bundlekit/cli/package.json",{paths:[process.cwd()]}),i=t(e);if(i?.version)return i.version}catch{}try{const t=a.dirname(j(import.meta.url)),e=[a.resolve(t,"../package.json"),a.resolve(t,"../../package.json")];for(const t of e)try{const e=T(import.meta.url)(t);if("@bundlekit/cli"===e?.name&&e?.version)return e.version}catch{}}catch{}return"*"}()}}function zn(t,e){return`^${e.cliVersion}`}function Jn(t){const e=/^@bundlekit\/(.+)$/.exec(t.trim());return e?e[1]:null}function Gn(t,e){if(!/^[a-z0-9@.\-_]+$/.test(t))throw new Error(`项目名称 "${t}" 不合法,只能包含小写字母、数字、@、.、-、_`);const i=C.resolve(e,t);if(new b(e).isFilePathExist(i))throw new Error(`目录 ${i} 已存在,请选择其他项目名称`);return{targetDir:i}}function Kn(t){return Yn(t).startsWith("vue")?"@bundlekit/plugin-vue":"@bundlekit/plugin-react"}function Yn(t){return{react:"react-ts",vue:"vue3-ts",vue3:"vue3-ts","react-ts":"react-ts","react-js":"react-js","vue3-ts":"vue3-ts","vue3-js":"vue3-js"}[t]??t}function Zn(t){const e=Yn(t),i=Kn(t);try{const t=w(import.meta.url).resolve(`${i}/package.json`),s=C.join(C.dirname(t),"templates",`template-${e}`);if(k.existsSync(s))return s}catch{}const s=C.dirname(A(import.meta.url)),r=i.replace("@bundlekit/","bundlekit-"),n=C.resolve(s,"../..",r,"templates",`template-${e}`);if(k.existsSync(n))return n;throw new Error(`模板 "${t}" 未找到,可用模板:react-ts / react-js / vue3-ts / vue3-js`)}async function Xn(t){const e=new Wn({templateDir:t.templateDir,targetDir:t.targetDir,context:{projectName:t.projectName,description:t.description||"",bundler:t.bundler,ssr:!!t.ssr}});await e.generate()}function Qn(t,e,i){const s=S(e);return s?function(t,e,i){const s=_[e],r=zn(0,i),n=a.join(t,"package.json"),o=JSON.parse(l.readFileSync(n,"utf-8"));return o.devDependencies=o.devDependencies||{},o.devDependencies[s]=r,o.devDependencies=Object.fromEntries(Object.entries(o.devDependencies).sort(([t],[e])=>t.localeCompare(e))),l.writeFileSync(n,JSON.stringify(o,null,2)+"\n"),[s,r]}(t,s,i):null}function to(t,e){!function(t,e){const i=a.join(t,"package.json"),s=l.readFileSync(i,"utf-8"),r=JSON.parse(s),n=[],o=["dependencies","devDependencies","peerDependencies","optionalDependencies"];for(const t of o){const i=r[t];if(i&&"object"==typeof i)for(const t of Object.keys(i)){const s=i[t];if("string"!=typeof s)continue;if(!s.startsWith("workspace:"))continue;if(!Jn(t)){i[t]=s.replace(/^workspace:/,"");continue}const r=zn(0,e);n.push([t,s,r]),i[t]=r}}l.writeFileSync(i,JSON.stringify(r,null,2)+"\n")}(t,e)}async function eo(t,e){const i=e?.pm?e.pm:void 0,s=new x({context:t,forcePackageManager:i});await s.install()}function io(){const t=t=>{try{return 0===E(t,["--version"],{stdio:"ignore",shell:"win32"===process.platform}).status}catch{return!1}};return{pnpm:t("pnpm"),yarn:t("yarn"),npm:t("npm")}}async function so(t,e,i){return qn(t,e,Bn(0,i),i)}class ro{constructor(){this.logger=new v}async create(t,e={}){const i=new O,s=e.cwd||process.cwd(),r=e.template||"react-ts",n=e.bundler||"webpack",o=e.pm||void 0,a=Un();let l;try{({targetDir:l}=Gn(t,s))}catch(t){this.logger.error(t.message),process.exit(1)}i.logWithSpinner("📦",`正在创建项目 ${t}...`);const c=Zn(r);await Xn({targetDir:l,templateDir:c,projectName:t,description:e.description,bundler:n,ssr:!!e.ssr}),to(l,a),this.logger.info(`依赖模式:npm 模式(^${a.cliVersion})`);const h=Qn(l,n,a);if(h){const[t,e]=h;this.logger.info(`已写入 ${t}@${e} 到 devDependencies`)}else this.logger.warn(`bundler "${n}" 不在内置列表中,跳过 devDeps 写入`);const u="1"===process.env.DEVKIT_SKIP_INSTALL;u||(i.logWithSpinner("📦","正在安装依赖..."),await eo(l,{pm:o}),i.stopSpinner(!1)),this.logger.done(`项目 ${t} 创建成功!`);const p=process.env.DEVKIT_NO_PROMPT;process.env.DEVKIT_NO_PROMPT="1";let d=!1;try{const t=Kn(r);d=await so(t,l,this.logger)}finally{void 0===p?delete process.env.DEVKIT_NO_PROMPT:process.env.DEVKIT_NO_PROMPT=p}d&&(to(l,a),u||(this.logger.info("正在安装追加的依赖..."),await eo(l,{pm:o})));const m="npm"===o?"npm run dev":`${o||"pnpm"} dev`;this.logger.log(`\n cd ${t}`),this.logger.log(` ${m}\n`)}}const no={mock:"@bundlekit/plugin-mock",react:"@bundlekit/plugin-react",vue:"@bundlekit/plugin-vue",request:"@bundlekit/request"};class oo{constructor(t){this.context=t||process.cwd(),this.logger=new v}async add(t){const e=function(t){const e=(()=>{const e=S(t);return e?_[e]:null})();if(e)return e;const[i]=t.split("@").filter(Boolean);return no[i]??t}(t),i=function(t){return/\/plugin-|^plugin-/.test(t)}(e),s=function(t){return/^@bundlekit\/bundler-/.test(t)}(e),r=i||s;this.logger.info(`解析插件: ${t} → ${e}`),this.logger.info("类型: "+(s?"构建工具适配器(devDependency)":i?"构建插件(devDependency)":"运行时库(dependency)"));const n=new x({context:this.context});if(await n.add(e,{dev:r})){if(this.logger.done(`已安装 ${e}`),i&&!s){const t=Bn(this.context,this.logger);if(await qn(e,this.context,t,this.logger)){this.logger.info("正在安装追加的依赖...");const t=new x({context:this.context});await t.install()}}}else this.logger.error(`安装 ${e} 失败`)}}const ao=({version:t=""})=>N(d,{flexDirection:"column",marginBottom:1,children:[F(I,{name:"atlas",children:F(R,{text:"BUNDLEKIT-CLI",font:"block"})}),F(d,{marginLeft:1,children:F(m,{dimColor:!0,children:`bundlekit${t?` v${t}`:""} · 多打包器构建工具`})})]}),lo=({title:t,step:e,total:i,children:s})=>N(d,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,marginBottom:1,children:[F(d,{marginBottom:1,children:F(m,{bold:!0,color:"cyan",children:e&&i?`Step ${e}/${i} · ${t}`:t})}),s]});function co(t,e,i){if(0===t.length)return-1;const s=t.length;let r=e;for(let e=0;e<s;e++)if(r=(r+i+s)%s,!t[r].disabled)return r;return-1}function ho(t){const{items:r,initialValue:n,onSelect:o,onBack:a}=t,l=e(()=>{if(n){const t=r.findIndex(t=>t.value===n&&!t.disabled);if(t>=0)return t}const t=r.findIndex(t=>!t.disabled);return t>=0?t:0},[r,n]),[c,h]=i(l);return s(()=>{if(c>=r.length||r[c]?.disabled){const t=r.findIndex(t=>!t.disabled);h(t>=0?t:0)}},[r]),f((t,e)=>{if(e.upArrow||"k"===t){const t=co(r,c,-1);return void(t>=0&&h(t))}if(e.downArrow||"j"===t){const t=co(r,c,1);return void(t>=0&&h(t))}if(e.return){const t=r[c];return void(t&&!t.disabled&&o(t.value))}(e.escape||e.backspace||e.delete)&&a&&a()}),F(d,{flexDirection:"column",children:r.map((t,e)=>{const i=e===c,s=!!t.disabled,r=i?"▶ ":" ",n=s?void 0:i?"cyan":void 0,o=s||!i,a=s&&t.disabledReason?` ${t.disabledReason}`:"";return N(d,{children:[F(m,{color:i&&!s?"cyan":void 0,children:r}),N(m,{color:n,dimColor:o,children:[t.label,a]})]},String(t.value))})})}const uo=({value:t,placeholder:e,onChange:i,onSubmit:s})=>F(L,{value:t,placeholder:e,onChange:i,onSubmit:s}),po={pending:"○",running:"",done:"✔",error:"✘"},mo={pending:"gray",running:"cyan",done:"green",error:"red"},fo=({tasks:t})=>F(d,{flexDirection:"column",children:t.map(t=>N(d,{children:[F(d,{width:3,children:"running"===t.status?F(m,{color:"cyan",children:F(V,{type:"dots"})}):F(m,{color:mo[t.status],children:po[t.status]})}),F(m,{color:"pending"===t.status?"gray":void 0,children:t.label}),t.detail?N(m,{dimColor:!0,children:[" (",t.detail,")"]}):null]},t.id))});function go(t,e){return"npm"===t?`npm run ${e}`:`${t} ${e}`}const yo=({name:t,bundler:e,template:i,pm:s="pnpm"})=>{const r=go(s,"dev"),n=go(s,"build");return N(d,{flexDirection:"column",marginTop:1,children:[N(d,{children:[F(m,{color:"green",bold:!0,children:" ✔ 项目 "}),F(m,{color:"cyan",bold:!0,children:t}),F(m,{color:"green",bold:!0,children:" 创建成功"})]}),N(d,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:"green",paddingX:1,children:[i&&N(d,{children:[F(m,{dimColor:!0,children:"模板 "}),F(m,{color:"cyan",children:i})]}),N(d,{children:[F(m,{dimColor:!0,children:"打包器 "}),F(m,{color:"cyan",children:e})]}),N(d,{children:[F(m,{dimColor:!0,children:"包管理器 "}),F(m,{color:"cyan",children:s})]}),N(d,{children:[F(m,{dimColor:!0,children:"位置 "}),F(m,{color:"cyan",children:`./${t}`})]})]}),N(d,{flexDirection:"column",marginTop:1,children:[F(m,{dimColor:!0,children:"下一步:"}),N(d,{marginLeft:2,marginTop:1,flexDirection:"column",children:[N(d,{children:[F(m,{color:"gray",children:"$ "}),F(m,{color:"cyan",children:`cd ${t}`})]}),N(d,{children:[F(m,{color:"gray",children:"$ "}),F(m,{color:"cyan",children:r}),F(m,{dimColor:!0,children:` 使用 ${e} 启动开发服务`})]}),N(d,{children:[F(m,{color:"gray",children:"$ "}),F(m,{color:"cyan",children:n}),F(m,{dimColor:!0,children:" 生产构建"})]})]})]}),N(d,{marginTop:1,children:[F(m,{dimColor:!0,children:"提示:"}),N(m,{dimColor:!0,children:["使用 ",N(m,{color:"cyan",children:["dc add bundler-","<name>"]})," 切换打包器,使用 ",N(m,{color:"cyan",children:["dc add ","<plugin>"]})," 追加插件"]})]})]})},wo=({step:t,message:e,stack:i})=>N(d,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:"red",paddingX:1,children:[F(d,{children:N(m,{color:"red",bold:!0,children:["✘ ",t," 失败"]})}),F(d,{marginTop:1,children:F(m,{color:"redBright",children:e})}),i?F(d,{marginTop:1,children:F(m,{dimColor:!0,children:i})}):null]}),bo=[{label:"React + TypeScript",value:"react-ts"},{label:"React + JavaScript",value:"react-js"},{label:"Vue 3 + TypeScript",value:"vue3-ts"},{label:"Vue 3 + JavaScript",value:"vue3-js"}],vo=[{label:"Vite —— 开发体感最佳",value:"vite"},{label:"Webpack —— 生态最完整",value:"webpack"},{label:"Rspack —— Rust 实现,极速",value:"rspack"},{label:"更多打包器 →",value:"__more__"}],_o=[{label:"Rollup —— 适合库构建",value:"rollup"},{label:"Rolldown —— 实验性",value:"rolldown"},{label:"← 返回",value:"__back__"}],So=["pnpm","yarn","npm"],xo={pnpm:"pnpm —— 推荐,磁盘占用最小",yarn:"yarn —— 兼容性好",npm:"npm —— Node 内置"};const Oo=({params:t})=>{const{exit:n}=g(),[o,a]=i(t.template),[l,c]=i(t.bundler),[h,u]=i("primary"),[p,f]=i(void 0!==t.ssr?t.ssr:void 0),y=e(()=>io(),[]),w=e(()=>function(){const t=process.env.DEVKIT_PM;if("pnpm"===t||"yarn"===t||"npm"===t)return t}(),[]),[b,_]=i(function(t,e,i){return t&&i[t]?t:e&&i[e]?e:void 0}(t.pm,w,y));e(()=>Un(t.cwd||process.cwd()),[t.cwd]);const[S,x]=i(t.description||""),[O,C]=i(void 0!==t.description),[k,E]=i([]),[A,$]=i(null);let P;P=A?"error":k.length>0&&k.every(t=>"done"===t.status)?"done":k.length>0?"tasks":o?l?void 0===p?"ssr":b?O?"tasks":"description":"pm":"bundler":"template";const D=r((t,e)=>{E(i=>i.map(i=>i.id===t?{...i,...e}:i))},[]);s(()=>{if("tasks"!==P)return;if(k.length>0)return;E([{id:"render",label:"渲染模板",status:"pending"},{id:"normalize",label:"规范化依赖版本",status:"pending"},{id:"deps",label:"写入 bundler 到 devDependencies",status:"pending"},{id:"install",label:"安装依赖",status:"pending"},{id:"generator",label:"调用框架插件 generator",status:"pending"}]),(async()=>{const e=t.cwd||process.cwd();let i;try{({targetDir:i}=Gn(t.name,e))}catch(t){return void $({step:"校验项目",message:t.message})}const s=new v,r=Un();try{D("render",{status:"running"});const e=Zn(o);await Xn({targetDir:i,templateDir:e,projectName:t.name,description:S,bundler:l,ssr:p}),D("render",{status:"done"})}catch(t){const e=t;return D("render",{status:"error"}),void $({step:"渲染模板",message:e.message,stack:e.stack})}try{D("normalize",{status:"running"}),to(i,r);const t=`npm 模式 → ^${r.cliVersion}`;D("normalize",{status:"done",detail:t})}catch(t){const e=t;return D("normalize",{status:"error"}),void $({step:"规范化依赖版本",message:e.message,stack:e.stack})}try{D("deps",{status:"running"});const t=Qn(i,l,r);if(t){const[e,i]=t;D("deps",{status:"done",detail:`${e}@${i}`})}else D("deps",{status:"done",detail:"未识别的 bundler,跳过"})}catch(t){const e=t;return D("deps",{status:"error"}),void $({step:"写入 devDependencies",message:e.message,stack:e.stack})}try{D("install",{status:"running"}),await eo(i,{pm:b}),D("install",{status:"done"})}catch(t){const e=t;return D("install",{status:"error"}),void $({step:"安装依赖",message:e.message,stack:e.stack})}try{D("generator",{status:"running"});const t=Kn(o),e=process.env.DEVKIT_NO_PROMPT;process.env.DEVKIT_NO_PROMPT="1";let n=!1;try{n=await so(t,i,s)}finally{void 0===e?delete process.env.DEVKIT_NO_PROMPT:process.env.DEVKIT_NO_PROMPT=e}n&&(to(i,r),await eo(i,{pm:b})),D("generator",{status:"done"})}catch(t){const e=t;return D("generator",{status:"error"}),void $({step:"调用 generator",message:e.message,stack:e.stack})}})()},[P,k.length,o,l,b,p,S,t,D]),s(()=>{if("done"===P){const t=setTimeout(()=>n(),100);return()=>clearTimeout(t)}if("error"===P){const t=setTimeout(()=>{n(),process.exit(1)},100);return()=>clearTimeout(t)}},[P,n]);const T=e(()=>So.map(t=>({label:xo[t],value:t,disabled:!y[t],disabledReason:y[t]?void 0:"(未安装)"})),[y]);return N(d,{flexDirection:"column",children:[F(ao,{}),"template"===P&&F(lo,{title:"模板",step:1,total:5,children:F(ho,{items:bo,initialValue:o,onSelect:t=>a(t)})}),"bundler"===P&&N(lo,{title:"打包器",step:2,total:5,children:[N(d,{marginBottom:1,children:[F(m,{dimColor:!0,children:"已选模板:"}),N(m,{color:"cyan",children:[" ",o]})]}),F(ho,"primary"===h?{items:vo,initialValue:l,onSelect:t=>{"__more__"===t?u("secondary"):c(t)}}:{items:_o,onSelect:t=>{"__back__"===t?u("primary"):c(t)},onBack:()=>u("primary")})]}),"ssr"===P&&N(lo,{title:"SSR",step:3,total:5,children:[N(d,{marginBottom:1,children:[F(m,{dimColor:!0,children:"已选打包器:"}),N(m,{color:"cyan",children:[" ",l]})]}),F(ho,{items:[{label:"否 — 纯客户端渲染(推荐)",value:"no"},{label:"是 — 启用 SSR(需要服务端渲染)",value:"yes"}],onSelect:t=>f("yes"===t)})]}),"pm"===P&&N(lo,{title:"包管理器",step:4,total:5,children:[F(d,{marginBottom:1,children:F(m,{dimColor:!0,children:"用于安装项目依赖:"})}),F(ho,{items:T,onSelect:t=>_(t)})]}),"description"===P&&F(lo,{title:"项目描述(可选,按回车跳过)",step:5,total:5,children:F(uo,{value:S,placeholder:"A demo app",onChange:x,onSubmit:t=>{x(t||" "),C(!0)}})}),("tasks"===P||"done"===P)&&N(d,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,marginBottom:1,children:[N(d,{marginBottom:1,children:[F(m,{bold:!0,color:"cyan",children:"创建项目 "}),F(m,{bold:!0,children:t.name}),F(m,{dimColor:!0,children:` ${o} · ${l} · ${p?"SSR":"CSR"} · ${b}`})]}),F(fo,{tasks:k})]}),"done"===P&&F(yo,{name:t.name,bundler:l,template:o,pm:b}),"error"===P&&A&&F(wo,{step:A.step,message:A.message,stack:A.stack})]})},Co=({params:t})=>{const{exit:e}=g(),[r,n]=i([{id:"resolve",label:`解析 ${t.plugin}`,status:"pending"},{id:"install",label:"安装依赖",status:"pending"},{id:"generator",label:"调用 generator (如有)",status:"pending"}]),[o,a]=i(null);return s(()=>{const i=(t,e)=>{n(i=>i.map(i=>i.id===t?{...i,...e}:i))};(async()=>{try{i("resolve",{status:"running"});const e=t.cwd||process.cwd(),s=new oo(e);i("resolve",{status:"done"}),i("install",{status:"running"}),await s.add(t.plugin),i("install",{status:"done"}),i("generator",{status:"done"})}catch(t){const e=t;a({step:"add",message:e.message,stack:e.stack})}finally{setTimeout(()=>e(),100)}})()},[t,e]),N(d,{flexDirection:"column",children:[F(ao,{}),N(d,{marginBottom:1,children:[F(m,{children:"追加:"}),N(m,{color:"cyan",bold:!0,children:[" ",t.plugin]})]}),F(fo,{tasks:r}),o&&F(wo,{step:o.step,message:o.message,stack:o.stack})]})},ko=t=>"create"===t.command?F(Oo,{params:t.params}):"add"===t.command?F(Co,{params:t.params}):null,Eo=w(import.meta.url),Ao=new St,$o=[{name:"react-ts",message:"React + TypeScript"},{name:"react-js",message:"React + JavaScript"},{name:"vue3-ts",message:"Vue 3 + TypeScript"},{name:"vue3-js",message:"Vue 3 + JavaScript"}],Po=[{name:"vite",message:"Vite"},{name:"webpack",message:"Webpack"},{name:"rspack",message:"Rspack"},{name:"rollup",message:"Rollup"},{name:"rolldown",message:"Rolldown"}],Do=[{name:"no",message:"否 — 纯客户端渲染(推荐)"},{name:"yes",message:"是 — 启用 SSR(需要服务端渲染)"}];function To(){return"1"!==process.env.DEVKIT_NO_INK&&(!!process.stdout.isTTY&&!!process.stdin.isTTY)}function jo(t){return"pnpm"===t||"yarn"===t||"npm"===t}async function No(t,e){const i=new Ni;if(!e.template){const t=await i.prompt({type:"select",name:"template",message:"请选择项目模板:",choices:$o});e.template=t.template}if(!e.bundler){const t=await i.prompt({type:"select",name:"bundler",message:"请选择默认构建工具:",choices:Po});e.bundler=t.bundler}if(void 0===e.ssr){const t=await i.prompt({type:"select",name:"ssr",message:"是否启用 SSR:",choices:Do});e.ssr="yes"===t.ssr}let s=jo(e.pm)?e.pm:void 0;if(s||(s=function(){const t=process.env.DEVKIT_PM;if("pnpm"===t||"yarn"===t||"npm"===t)return t}()),!s){const t=io(),e=["pnpm","yarn","npm"].filter(e=>t[e]).map(t=>({name:t,message:t}));if(0===e.length)s="npm";else if(1===e.length)s=e[0].name;else{s=(await i.prompt({type:"select",name:"pm",message:"请选择包管理器:",choices:e})).pm}}e.pm=s;const r=new ro;await r.create(t,e)}Ao.command("create <name>").description("create a new project powered by bundlekit-service").option("-t, --template <template>","模板类型 (react-ts, react-js, vue3-ts, vue3-js)").option("-b, --bundler <bundler>","默认构建工具 (vite, webpack, rspack, rollup, rolldown)").option("-d, --description <desc>","项目描述").option("--pm <pm>","包管理器 (pnpm, yarn, npm)").option("--ssr","启用 SSR:模板生成 entry-client/entry-server + .bundlekitrc.ts 加 ssr 配置块",!1).action(async(e,i)=>{if(!To())return void await No(e,i);process.env.DEVKIT_QUIET="1";const s=jo(i.pm)?i.pm:void 0,{waitUntilExit:r}=y(t.createElement(ko,{command:"create",params:{name:e,template:i.template,bundler:i.bundler,pm:s,description:i.description,ssr:!!i.ssr}}));await r()}),Ao.command("add <plugin>").description("向已有项目添加插件 / bundler 适配器").action(async e=>{if(!To()){const t=new oo(process.cwd());return void await t.add(e)}process.env.DEVKIT_QUIET="1";const{waitUntilExit:i}=y(t.createElement(ko,{command:"add",params:{plugin:e}}));await i()}),Ao.command("help").alias("h").description("处理帮助信息 -h").action(()=>{Ao.outputHelp()}),Ao.command("version").alias("v").description("bundlekit-cli版本 -v").action(()=>{const t=Eo("../package.json");console.log(`bundlekit-cli v${t.version}`)}),Ao.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bundlekit/cli",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "a cli tool serve for generate frontend project",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -24,7 +24,13 @@
24
24
  "@bundlekit/cli"
25
25
  ],
26
26
  "author": "harhao@163.com",
27
- "license": "ISC",
27
+ "license": "MIT",
28
+ "website": "https://bundlekit.harhao.workers.dev",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/Harhao/bundlekit.git",
32
+ "directory": "packages/bundlekit-cli"
33
+ },
28
34
  "publishConfig": {
29
35
  "registry": "https://registry.npmjs.org/",
30
36
  "access": "public"
@@ -41,9 +47,9 @@
41
47
  "ink-spinner": "^5.0.0",
42
48
  "ink-text-input": "^6.0.0",
43
49
  "react": "^18.3.0",
44
- "@bundlekit/plugin-react": "0.0.2",
45
- "@bundlekit/plugin-vue": "0.0.2",
46
- "@bundlekit/shared-utils": "0.0.2"
50
+ "@bundlekit/plugin-react": "0.0.3",
51
+ "@bundlekit/shared-utils": "0.0.3",
52
+ "@bundlekit/plugin-vue": "0.0.3"
47
53
  },
48
54
  "devDependencies": {
49
55
  "@rollup/plugin-commonjs": "^25.0.7",