create-medusa-app 0.0.7-dev.113 → 0.0.7-next.98

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/dist/index.js CHANGED
@@ -1 +1 @@
1
- var t=require("path"),e=require("events"),i=require("child_process"),r=require("fs"),n=require("assert"),s=require("readline"),o=require("os"),a=require("buffer"),l=require("stream"),c=require("util"),u=require("constants"),h=require("url"),d=require("crypto"),p=require("http"),f=require("https"),m=require("zlib");function g(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var y=g(t),b=g(e),w=g(i),v=g(r),S=g(n),E=g(s),x=g(o),_=g(a),O=g(l),C=g(c),k=g(u),$=g(h),j=g(d),A=g(p),P=g(f),T=g(m),I="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function N(t){var e={exports:{}};return t(e,e.exports),e.exports}class F 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}}var R={CommanderError:F,InvalidArgumentError:class extends F{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}};const{InvalidArgumentError:L}=R;var D={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,this.parseArg=(e,i)=>{if(!t.includes(e))throw new L(`Allowed choices are ${t.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},humanReadableArgName:function(t){const e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"}};const{humanReadableArgName:B}=D;var M={Help:class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1}visibleCommands(t){const e=t.commands.filter(t=>!t._hidden);if(t._hasImplicitHelpCommand()){const[,i,r]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),n=t.createCommand(i).helpOption(!1);n.description(t._helpCommandDescription),r&&n.arguments(r),e.push(n)}return this.sortSubcommands&&e.sort((t,e)=>t.name().localeCompare(e.name())),e}visibleOptions(t){const e=t.options.filter(t=>!t.hidden),i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag),r=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||r){let n;n=t.createOption(i?r?t._helpFlags:t._helpShortFlag:t._helpLongFlag,t._helpDescription),e.push(n)}if(this.sortOptions){const t=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");e.sort((e,i)=>t(e).localeCompare(t(i)))}return e}visibleArguments(t){return t._argsDescription&&t._args.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t._args.find(t=>t.description)?t._args:[]}subcommandTerm(t){const e=t._args.map(t=>B(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,e.subcommandTerm(i).length),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((t,i)=>Math.max(t,e.optionTerm(i).length),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((t,i)=>Math.max(t,e.argumentTerm(i).length),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.description()}optionDescription(t){const e=[];return t.argChoices&&!t.negate&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0===t.defaultValue||t.negate||e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),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),r=e.helpWidth||80;function n(t,n){if(n){const s=`${t.padEnd(i+2)}${n}`;return e.wrap(s,r-2,i+2)}return t}function s(t){return t.join("\n").replace(/^/gm," ".repeat(2))}let o=[`Usage: ${e.commandUsage(t)}`,""];const a=e.commandDescription(t);a.length>0&&(o=o.concat([a,""]));const l=e.visibleArguments(t).map(t=>n(e.argumentTerm(t),e.argumentDescription(t)));l.length>0&&(o=o.concat(["Arguments:",s(l),""]));const c=e.visibleOptions(t).map(t=>n(e.optionTerm(t),e.optionDescription(t)));c.length>0&&(o=o.concat(["Options:",s(c),""]));const u=e.visibleCommands(t).map(t=>n(e.subcommandTerm(t),e.subcommandDescription(t)));return u.length>0&&(o=o.concat(["Commands:",s(u),""])),o.join("\n")}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,i,r=40){if(t.match(/[\n]\s+/))return t;const n=e-i;if(n<r)return t;const s=t.substr(0,i),o=t.substr(i),a=" ".repeat(i),l=new RegExp(".{1,"+(n-1)+"}([\\s​]|$)|[^\\s​]+?([\\s​]|$)","g");return s+(o.match(l)||[]).map((t,e)=>("\n"===t.slice(-1)&&(t=t.slice(0,t.length-1)),(e>0?a:"")+t.trimRight())).join("\n")}}};const{InvalidArgumentError:G}=R;function H(t){let e,i;const r=t.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),i=r.shift(),!e&&/^-[^-]$/.test(i)&&(e=i,i=void 0),{shortFlag:e,longFlag:i}}var U={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=H(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.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=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,this.parseArg=(e,i)=>{if(!t.includes(e))throw new G(`Allowed choices are ${t.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.name().replace(/^no-/,"").split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}is(t){return this.short===t||this.long===t}},splitOptionFlags:H},q={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 r=[],n=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 r=1;r<=e.length;r++)for(let n=1;n<=t.length;n++){let s=1;s=t[n-1]===e[r-1]?0:1,i[n][r]=Math.min(i[n-1][r]+1,i[n][r-1]+1,i[n-1][r-1]+s),n>1&&r>1&&t[n-1]===e[r-2]&&t[n-2]===e[r-1]&&(i[n][r]=Math.min(i[n][r],i[n-2][r-2]+1))}return i[t.length][e.length]}(t,e),s=Math.max(t.length,e.length);(s-i)/s>.4&&(i<n?(n=i,r=[e]):i===n&&r.push(e))}),r.sort((t,e)=>t.localeCompare(e)),i&&(r=r.map(t=>`--${t}`)),r.length>1?`\n(Did you mean one of ${r.join(", ")}?)`:1===r.length?`\n(Did you mean ${r[0]}?)`:""}};const V=b.default.EventEmitter,{Argument:W,humanReadableArgName:z}=D,{CommanderError:Y}=R,{Help:K}=M,{Option:J,splitOptionFlags:X}=U,{suggestSimilar:Z}=q;class Q extends V{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this._args=[],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._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!1,this._outputConfiguration={writeOut:t=>process.stdout.write(t),writeErr:t=>process.stderr.write(t),getOutHelpWidth:()=>process.stdout.isTTY?process.stdout.columns:void 0,getErrHelpWidth:()=>process.stderr.isTTY?process.stderr.columns:void 0,outputError:(t,e)=>e(t)},this._hidden=!1,this._hasHelpOption=!0,this._helpFlags="-h, --help",this._helpDescription="display help for command",this._helpShortFlag="-h",this._helpLongFlag="--help",this._addImplicitHelpCommand=void 0,this._helpCommandName="help",this._helpCommandnameAndArgs="help [command]",this._helpCommandDescription="display help for command",this._helpConfiguration={}}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._hasHelpOption=t._hasHelpOption,this._helpFlags=t._helpFlags,this._helpDescription=t._helpDescription,this._helpShortFlag=t._helpShortFlag,this._helpLongFlag=t._helpLongFlag,this._helpCommandName=t._helpCommandName,this._helpCommandnameAndArgs=t._helpCommandnameAndArgs,this._helpCommandDescription=t._helpCommandDescription,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}command(t,e,i){let r=e,n=i;"object"==typeof r&&null!==r&&(n=r,r=null),n=n||{};const[,s,o]=t.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return r&&(a.description(r),a._executableHandler=!0),n.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!n.noHelp&&!n.hidden),a._executableFile=n.executableFile||null,o&&a.arguments(o),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),r?this:a}createCommand(t){return new Q(t)}createHelp(){return Object.assign(new K,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");return function t(e){e.forEach(e=>{if(e._executableHandler&&!e._executableFile)throw new Error(`Must specify executableFile for deeply nested executable: ${e.name()}`);t(e.commands)})}(t.commands),(e=e||{}).isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this.commands.push(t),t.parent=this,this}createArgument(t,e){return new W(t,e)}argument(t,e,i,r){const n=this.createArgument(t,e);return"function"==typeof i?n.default(r).argParser(i):n.default(i),this.addArgument(n),this}arguments(t){return t.split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(t){const e=this._args.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._args.push(t),this}addHelpCommand(t,e){return!1===t?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,"string"==typeof t&&(this._helpCommandName=t.split(" ")[0],this._helpCommandnameAndArgs=t),this._helpCommandDescription=e||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return void 0===this._addImplicitHelpCommand?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(t,e){const i=["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 Y(t,e,i)),process.exit(t)}action(t){return this._actionHandler=e=>{const i=this._args.length,r=e.slice(0,i);return r[i]=this._storeOptionsAsProperties?this:this.opts(),r.push(this),t.apply(this,r)},this}createOption(t,e){return new J(t,e)}addOption(t){const e=t.name(),i=t.attributeName();let r=t.defaultValue;if(t.negate||t.optional||t.required||"boolean"==typeof r){if(t.negate){const e=t.long.replace(/^--no-/,"--");r=!this._findOption(e)||this.getOptionValue(i)}void 0!==r&&this.setOptionValueWithSource(i,r,"default")}this.options.push(t);const n=(e,n,s)=>{const o=this.getOptionValue(i);if(null!==e&&t.parseArg)try{e=t.parseArg(e,void 0===o?r:o)}catch(t){throw"commander.invalidArgument"===t.code&&this._displayError(t.exitCode,t.code,`${n} ${t.message}`),t}else null!==e&&t.variadic&&(e=t._concatValue(e,o));"boolean"==typeof o||void 0===o?this.setOptionValueWithSource(i,null==e?!t.negate&&(r||!0):e,s):null!==e&&this.setOptionValueWithSource(i,!t.negate&&e,s)};return this.on("option:"+e,e=>{n(e,`error: option '${t.flags}' argument '${e}' is invalid.`,"cli")}),t.envVar&&this.on("optionEnv:"+e,e=>{n(e,`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`,"env")}),this}_optionEx(t,e,i,r,n){const s=this.createOption(e,i);if(s.makeOptionMandatory(!!t.mandatory),"function"==typeof r)s.default(n).argParser(r);else if(r instanceof RegExp){const t=r;r=(e,i)=>{const r=t.exec(e);return r?r[0]:i},s.default(n).argParser(r)}else s.default(r);return this.addOption(s)}option(t,e,i,r){return this._optionEx({},t,e,i,r)}requiredOption(t,e,i,r){return this._optionEx({mandatory:!0},t,e,i,r)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){if(this._passThroughOptions=!!t,this.parent&&t&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(t=!0){if(this._storeOptionsAsProperties=!!t,this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this}setOptionValueWithSource(t,e,i){return this.setOptionValue(t,e),this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}_prepareUserArgs(t,e){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");let i;switch(e=e||{},void 0===t&&(t=process.argv,process.versions&&process.versions.electron&&(e.from="electron")),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":process.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._scriptPath&&require.main&&(this._scriptPath=require.main.filename),this._name=this._name||this._scriptPath&&y.default.basename(this._scriptPath,y.default.extname(this._scriptPath)),i}parse(t,e){const i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){const i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),this}_executeSubCommand(t,e){e=e.slice();let i=!1;const r=[".js",".ts",".tsx",".mjs",".cjs"];this._checkForMissingMandatoryOptions();let n,s=this._scriptPath;!s&&require.main&&(s=require.main.filename);try{const t=v.default.realpathSync(s);n=y.default.dirname(t)}catch(t){n="."}let o=y.default.basename(s,y.default.extname(s))+"-"+t._name;t._executableFile&&(o=t._executableFile);const a=y.default.join(n,o);let l;v.default.existsSync(a)?o=a:r.forEach(t=>{v.default.existsSync(`${a}${t}`)&&(o=`${a}${t}`)}),i=r.includes(y.default.extname(o)),"win32"!==process.platform?i?(e.unshift(o),e=et(process.execArgv).concat(e),l=w.default.spawn(process.argv[0],e,{stdio:"inherit"})):l=w.default.spawn(o,e,{stdio:"inherit"}):(e.unshift(o),e=et(process.execArgv).concat(e),l=w.default.spawn(process.execPath,e,{stdio:"inherit"})),["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(t=>{process.on(t,()=>{!1===l.killed&&null===l.exitCode&&l.kill(t)})});const c=this._exitCallback;l.on("close",c?()=>{c(new Y(process.exitCode||0,"commander.executeSubCommandAsync","(close)"))}:process.exit.bind(process)),l.on("error",e=>{if("ENOENT"===e.code)throw new Error(`'${o}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name`);if("EACCES"===e.code)throw new Error(`'${o}' not executable`);if(c){const t=new Y(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,c(t)}else process.exit(1)}),this.runningCommand=l}_dispatchSubcommand(t,e,i){const r=this._findCommand(t);if(r||this.help({error:!0}),!r._executableHandler)return r._parseCommand(e,i);this._executeSubCommand(r,e.concat(i))}_checkNumberOfArguments(){this._args.forEach((t,e)=>{t.required&&null==this.args[e]&&this.missingArgument(t.name())}),this._args.length>0&&this._args[this._args.length-1].variadic||this.args.length>this._args.length&&this._excessArguments(this.args)}_processArguments(){const t=(t,e,i)=>{let r=e;if(null!==e&&t.parseArg)try{r=t.parseArg(e,i)}catch(i){if("commander.invalidArgument"===i.code){const r=`error: command-argument value '${e}' is invalid for argument '${t.name()}'. ${i.message}`;this._displayError(i.exitCode,i.code,r)}throw i}return r};this._checkNumberOfArguments();const e=[];this._args.forEach((i,r)=>{let n=i.defaultValue;i.variadic?r<this.args.length?(n=this.args.slice(r),i.parseArg&&(n=n.reduce((e,r)=>t(i,r,e),i.defaultValue))):void 0===n&&(n=[]):r<this.args.length&&(n=this.args[r],i.parseArg&&(n=t(i,n,i.defaultValue))),e[r]=n}),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 r=[];return it(this).reverse().filter(t=>void 0!==t._lifeCycleHooks[e]).forEach(t=>{t._lifeCycleHooks[e].forEach(e=>{r.push({hookedCommand:t,callback:e})})}),"postAction"===e&&r.reverse(),r.forEach(t=>{i=this._chainOrCall(i,()=>t.callback(t.hookedCommand,this))}),i}_parseCommand(t,e){const i=this.parseOptions(e);if(this._parseOptionsEnv(),t=t.concat(i.operands),this.args=t.concat(e=i.unknown),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._hasImplicitHelpCommand()&&t[0]===this._helpCommandName)return 1===t.length&&this.help(),this._dispatchSubcommand(t[1],[],[this._helpLongFlag]);if(this._defaultCommandName)return tt(this,e),this._dispatchSubcommand(this._defaultCommandName,t,e);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),tt(this,i.unknown),this._checkForMissingMandatoryOptions();const r=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},n=`command:${this.name()}`;if(this._actionHandler){let i;return r(),this._processArguments(),i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,()=>this._actionHandler(this.processedArgs)),this.parent&&this.parent.emit(n,t,e),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(n))r(),this._processArguments(),this.parent.emit(n,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():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),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(){for(let t=this;t;t=t.parent)t.options.forEach(e=>{e.mandatory&&void 0===t.getOptionValue(e.attributeName())&&t.missingMandatoryOptionValue(e)})}parseOptions(t){const e=[],i=[];let r=e;const n=t.slice();function s(t){return t.length>1&&"-"===t[0]}let o=null;for(;n.length;){const t=n.shift();if("--"===t){r===i&&r.push(t),r.push(...n);break}if(!o||s(t)){if(o=null,s(t)){const e=this._findOption(t);if(e){if(e.required){const t=n.shift();void 0===t&&this.optionMissingArgument(e),this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;n.length>0&&!s(n[0])&&(t=n.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()}`),n.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(s(t)&&(r=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===e.length&&0===i.length){if(this._findCommand(t)){e.push(t),n.length>0&&i.push(...n);break}if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){e.push(t),n.length>0&&e.push(...n);break}if(this._defaultCommandName){i.push(t),n.length>0&&i.push(...n);break}}if(this._passThroughOptions){r.push(t),n.length>0&&r.push(...n);break}r.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}_displayError(t,e,i){this._outputConfiguration.outputError(`${i}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0})),this._exit(t,e,i)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in process.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()}`,process.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}missingArgument(t){this._displayError(1,"commander.missingArgument",`error: missing required argument '${t}'`)}optionMissingArgument(t){this._displayError(1,"commander.optionMissingArgument",`error: option '${t.flags}' argument missing`)}missingMandatoryOptionValue(t){this._displayError(1,"commander.missingMandatoryOptionValue",`error: required option '${t.flags}' not specified`)}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[],r=this;do{const t=r.createHelp().visibleOptions(r).filter(t=>t.long).map(t=>t.long);i=i.concat(t),r=r.parent}while(r&&!r._enablePositionalOptions);e=Z(t,i)}this._displayError(1,"commander.unknownOption",`error: unknown option '${t}'${e}`)}_excessArguments(t){if(this._allowExcessArguments)return;const e=this._args.length,i=1===e?"":"s",r=this.parent?` for '${this.name()}'`:"";this._displayError(1,"commander.excessArguments",`error: too many arguments${r}. Expected ${e} argument${i} but got ${t.length}.`)}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=Z(t,i)}this._displayError(1,"commander.unknownCommand",`error: unknown command '${t}'${e}`)}version(t,e,i){if(void 0===t)return this._version;this._version=t;const r=this.createOption(e=e||"-V, --version",i=i||"output the version number");return this._versionOptionName=r.attributeName(),this.options.push(r),this.on("option:"+r.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)}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");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._args.map(t=>z(t));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?t:[]).join(" ")}return this._usage=t,this}name(t){return void 0===t?this._name:(this._name=t,this)}helpInformation(t){const e=this.createHelp();return void 0===e.helpWidth&&(e.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),e.formatHelp(this,e)}_getHelpContext(t){const e={error:!!(t=t||{}).error};let i;return i=e.error?t=>this._outputConfiguration.writeErr(t):t=>this._outputConfiguration.writeOut(t),e.write=t.write||i,e.command=this,e}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const i=this._getHelpContext(t);it(this).reverse().forEach(t=>t.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let r=this.helpInformation(i);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.emit(this._helpLongFlag),this.emit("afterHelp",i),it(this).forEach(t=>t.emit("afterAllHelp",i))}helpOption(t,e){if("boolean"==typeof t)return this._hasHelpOption=t,this;this._helpFlags=t||this._helpFlags,this._helpDescription=e||this._helpDescription;const i=X(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(t){this.outputHelp(t);let e=process.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("', '")}'`);return this.on(`${t}Help`,t=>{let i;i="function"==typeof e?e({error:t.error,command:t.command}):e,i&&t.write(`${i}\n`)}),this}}function tt(t,e){t._hasHelpOption&&e.find(e=>e===t._helpLongFlag||e===t._helpShortFlag)&&(t.outputHelp(),t._exit(0,"commander.helpDisplayed","(outputHelp)"))}function et(t){return t.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i,r="127.0.0.1",n="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])?n=i[3]:r=i[3]):null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(e=i[1],r=i[3],n=i[4]),e&&"0"!==n?`${e}=${r}:${parseInt(n)+1}`:t})}function it(t){const e=[];for(let i=t;i;i=i.parent)e.push(i);return e}var rt={Command:Q},nt=N(function(t,e){const{Argument:i}=D,{Command:r}=rt,{CommanderError:n,InvalidArgumentError:s}=R,{Help:o}=M,{Option:a}=U;(e=t.exports=new r).program=e,e.Argument=i,e.Command=r,e.CommanderError=n,e.Help=o,e.InvalidArgumentError=s,e.InvalidOptionArgumentError=s,e.Option=a});function st(){return(st=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}var ot=N(function(t){const e="Hyper"===process.env.TERM_PROGRAM,i="win32"===process.platform,r="linux"===process.platform,n={ballotDisabled:"☒",ballotOff:"☐",ballotOn:"☑",bullet:"•",bulletWhite:"◦",fullBlock:"█",heart:"❤",identicalTo:"≡",line:"─",mark:"※",middot:"·",minus:"-",multiplication:"×",obelus:"÷",pencilDownRight:"✎",pencilRight:"✏",pencilUpRight:"✐",percent:"%",pilcrow2:"❡",pilcrow:"¶",plusMinus:"±",section:"§",starsOff:"☆",starsOn:"★",upDownArrow:"↕"},s=Object.assign({},n,{check:"√",cross:"×",ellipsisLarge:"...",ellipsis:"...",info:"i",question:"?",questionSmall:"?",pointer:">",pointerSmall:"»",radioOff:"( )",radioOn:"(*)",warning:"‼"}),o=Object.assign({},n,{ballotCross:"✘",check:"✔",cross:"✖",ellipsisLarge:"⋯",ellipsis:"…",info:"ℹ",question:"?",questionFull:"?",questionSmall:"﹖",pointer:r?"▸":"❯",pointerSmall:r?"‣":"›",radioOff:"◯",radioOn:"◉",warning:"⚠"});t.exports=i&&!e?s:o,Reflect.defineProperty(t.exports,"common",{enumerable:!1,value:n}),Reflect.defineProperty(t.exports,"windows",{enumerable:!1,value:s}),Reflect.defineProperty(t.exports,"other",{enumerable:!1,value:o})});const at=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,lt=()=>{const t={enabled:!0,visible:!0,styles:{},keys:{}};"FORCE_COLOR"in process.env&&(t.enabled="0"!==process.env.FORCE_COLOR);const e=(t,e,i)=>"function"==typeof t?t(e):t.wrap(e,i),i=(i,r)=>{if(""===i||null==i)return"";if(!1===t.enabled)return i;if(!1===t.visible)return"";let n=""+i,s=n.includes("\n"),o=r.length;for(o>0&&r.includes("unstyle")&&(r=[...new Set(["unstyle",...r])].reverse());o-- >0;)n=e(t.styles[r[o]],n,s);return n},r=(e,r,n)=>{t.styles[e]=(t=>{let e=t.open=`[${t.codes[0]}m`,i=t.close=`[${t.codes[1]}m`,r=t.regex=new RegExp(`\\u001b\\[${t.codes[1]}m`,"g");return t.wrap=(t,n)=>{t.includes(i)&&(t=t.replace(r,i+e));let s=e+t+i;return n?s.replace(/\r*\n/g,`${i}$&${e}`):s},t})({name:e,codes:r}),(t.keys[n]||(t.keys[n]=[])).push(e),Reflect.defineProperty(t,e,{configurable:!0,enumerable:!0,set(i){t.alias(e,i)},get(){let r=t=>i(t,r.stack);return Reflect.setPrototypeOf(r,t),r.stack=this.stack?this.stack.concat(e):[e],r}})};return r("reset",[0,0],"modifier"),r("bold",[1,22],"modifier"),r("dim",[2,22],"modifier"),r("italic",[3,23],"modifier"),r("underline",[4,24],"modifier"),r("inverse",[7,27],"modifier"),r("hidden",[8,28],"modifier"),r("strikethrough",[9,29],"modifier"),r("black",[30,39],"color"),r("red",[31,39],"color"),r("green",[32,39],"color"),r("yellow",[33,39],"color"),r("blue",[34,39],"color"),r("magenta",[35,39],"color"),r("cyan",[36,39],"color"),r("white",[37,39],"color"),r("gray",[90,39],"color"),r("grey",[90,39],"color"),r("bgBlack",[40,49],"bg"),r("bgRed",[41,49],"bg"),r("bgGreen",[42,49],"bg"),r("bgYellow",[43,49],"bg"),r("bgBlue",[44,49],"bg"),r("bgMagenta",[45,49],"bg"),r("bgCyan",[46,49],"bg"),r("bgWhite",[47,49],"bg"),r("blackBright",[90,39],"bright"),r("redBright",[91,39],"bright"),r("greenBright",[92,39],"bright"),r("yellowBright",[93,39],"bright"),r("blueBright",[94,39],"bright"),r("magentaBright",[95,39],"bright"),r("cyanBright",[96,39],"bright"),r("whiteBright",[97,39],"bright"),r("bgBlackBright",[100,49],"bgBright"),r("bgRedBright",[101,49],"bgBright"),r("bgGreenBright",[102,49],"bgBright"),r("bgYellowBright",[103,49],"bgBright"),r("bgBlueBright",[104,49],"bgBright"),r("bgMagentaBright",[105,49],"bgBright"),r("bgCyanBright",[106,49],"bgBright"),r("bgWhiteBright",[107,49],"bgBright"),t.ansiRegex=at,t.hasColor=t.hasAnsi=e=>(t.ansiRegex.lastIndex=0,"string"==typeof e&&""!==e&&t.ansiRegex.test(e)),t.alias=(e,r)=>{let n="string"==typeof r?t[r]:r;if("function"!=typeof n)throw new TypeError("Expected alias to be the name of an existing color (string) or a function");n.stack||(Reflect.defineProperty(n,"name",{value:e}),t.styles[e]=n,n.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(n.stack):n.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=ot,t.define=r,t};var ct=lt();ct.create=lt;var ut=N(function(t,e){const i=Object.prototype.toString;let r=!1,n=[];const s={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};e.longest=(t,e)=>t.reduce((t,i)=>Math.max(t,e?i[e].length:i.length),0),e.hasColor=t=>!!t&&ct.hasColor(t);const o=e.isObject=t=>null!==t&&"object"==typeof t&&!Array.isArray(t);e.nativeType=t=>i.call(t).slice(8,-1).toLowerCase().replace(/\s/g,""),e.isAsyncFn=t=>"asyncfunction"===e.nativeType(t),e.isPrimitive=t=>null!=t&&"object"!=typeof t&&"function"!=typeof t,e.resolve=(t,e,...i)=>"function"==typeof e?e.call(t,...i):e,e.scrollDown=(t=[])=>[...t.slice(1),t[0]],e.scrollUp=(t=[])=>[t.pop(),...t],e.reorder=(t=[])=>{let e=t.slice();return e.sort((t,e)=>t.index>e.index?1:t.index<e.index?-1:0),e},e.swap=(t,e,i)=>{let r=t.length,n=i===r?0:i<0?r-1:i,s=t[e];t[e]=t[n],t[n]=s},e.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},e.height=(t,e=20)=>{let i=t&&t.rows?t.rows:e;return t&&"function"==typeof t.getWindowSize&&(i=t.getWindowSize()[1]),i},e.wordWrap=(t,e={})=>{if(!t)return t;"number"==typeof e&&(e={width:e});let{indent:i="",newline:r="\n"+i,width:n=80}=e,s=(r+i).match(/[^\S\n]/g)||[];n-=s.length;let o=`.{1,${n}}([\\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(n," "))),e.padStart&&(c=c.map(t=>t.padStart(n," "))),i+c.join(r)},e.unmute=t=>{let e=t.stack.find(t=>ct.keys.color.includes(t));return e?ct[e]:t.stack.find(t=>"bg"===t.slice(2))?ct[e.slice(2)]:t=>t},e.pascal=t=>t?t[0].toUpperCase()+t.slice(1):"",e.inverse=t=>{if(!t||!t.stack)return t;let i=t.stack.find(t=>ct.keys.color.includes(t));if(i){let r=ct["bg"+e.pascal(i)];return r?r.black:t}let r=t.stack.find(t=>"bg"===t.slice(0,2));return r?ct[r.slice(2).toLowerCase()]||t:ct.none},e.complement=t=>{if(!t||!t.stack)return t;let i=t.stack.find(t=>ct.keys.color.includes(t)),r=t.stack.find(t=>"bg"===t.slice(0,2));if(i&&!r)return ct[s[i]||i];if(r){let i=r.slice(2).toLowerCase(),n=s[i];return n&&ct["bg"+e.pascal(n)]||t}return ct.none},e.meridiem=t=>{let e=t.getHours(),i=t.getMinutes(),r=e>=12?"pm":"am";return e%=12,(0===e?12:e)+":"+(i<10?"0"+i:i)+" "+r},e.set=(t={},i="",r)=>i.split(".").reduce((t,i,n,s)=>{let o=s.length-1>n?t[i]||{}:r;return!e.isObject(o)&&n<s.length-1&&(o={}),t[i]=o},t),e.get=(t={},e="",i)=>{let r=null==t[e]?e.split(".").reduce((t,e)=>t&&t[e],t):t[e];return null==r?i:r},e.mixin=(t,i)=>{if(!o(t))return i;if(!o(i))return t;for(let r of Object.keys(i)){let n=Object.getOwnPropertyDescriptor(i,r);if(n.hasOwnProperty("value"))if(t.hasOwnProperty(r)&&o(n.value)){let s=Object.getOwnPropertyDescriptor(t,r);o(s.value)?t[r]=e.merge({},t[r],i[r]):Reflect.defineProperty(t,r,n)}else Reflect.defineProperty(t,r,n);else Reflect.defineProperty(t,r,n)}return t},e.merge=(...t)=>{let i={};for(let r of t)e.mixin(i,r);return i},e.mixinEmitter=(t,i)=>{let r=i.constructor.prototype;for(let n of Object.keys(r)){let s=r[n];e.define(t,n,"function"==typeof s?s.bind(i):s)}},e.onExit=t=>{const e=(t,e)=>{r||(r=!0,n.forEach(t=>t()),!0===t&&process.exit(128+e))};0===n.length&&(process.once("SIGTERM",e.bind(null,!0,15)),process.once("SIGINT",e.bind(null,!0,2)),process.once("exit",e)),n.push(t)},e.define=(t,e,i)=>{Reflect.defineProperty(t,e,{value:i})},e.defineExport=(t,e,i)=>{let r;Reflect.defineProperty(t,e,{enumerable:!0,configurable:!0,set(t){r=t},get:()=>r?r():i()})}}),ht={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"},shift:{up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"},fn:{up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"},option:{b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"},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"}};const dt=/^(?:\x1b)([a-zA-Z0-9])$/,pt=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,ft={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"},mt=(t="",e={})=>{let i,r=st({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=r.sequence||""),r.sequence=r.sequence||t||r.name,"\r"===t)r.raw=void 0,r.name="return";else if("\n"===t)r.name="enter";else if("\t"===t)r.name="tab";else if("\b"===t||""===t||""===t||"\b"===t)r.name="backspace",r.meta=""===t.charAt(0);else if(""===t||""===t)r.name="escape",r.meta=2===t.length;else if(" "===t||" "===t)r.name="space",r.meta=2===t.length;else if(t<="")r.name=String.fromCharCode(t.charCodeAt(0)+"a".charCodeAt(0)-1),r.ctrl=!0;else if(1===t.length&&t>="0"&&t<="9")r.name="number";else if(1===t.length&&t>="a"&&t<="z")r.name=t;else if(1===t.length&&t>="A"&&t<="Z")r.name=t.toLowerCase(),r.shift=!0;else if(i=dt.exec(t))r.meta=!0,r.shift=/^[A-Z]$/.test(i[1]);else if(i=pt.exec(t)){let e=[...t];""===e[0]&&""===e[1]&&(r.option=!0);let n=[i[1],i[2],i[4],i[6]].filter(Boolean).join(""),s=(i[3]||i[5]||1)-1;r.ctrl=!!(4&s),r.meta=!!(10&s),r.shift=!!(1&s),r.code=n,r.name=ft[n],r.shift=function(t){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(t)}(n)||r.shift,r.ctrl=function(t){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(t)}(n)||r.ctrl}return r};mt.listen=(t={},e)=>{let{stdin:i}=t;if(!i||i!==process.stdin&&!i.isTTY)throw new Error("Invalid stream passed");let r=E.default.createInterface({terminal:!0,input:i});E.default.emitKeypressEvents(i,r);let n=(t,i)=>e(t,mt(t,i),r),s=i.isRaw;return i.isTTY&&i.setRawMode(!0),i.on("keypress",n),r.resume(),()=>{i.isTTY&&i.setRawMode(s),i.removeListener("keypress",n),r.pause(),r.close()}},mt.action=(t,e,i)=>{let r=st({},ht,i);return e.ctrl?(e.action=r.ctrl[e.name],e):e.option&&r.option?(e.action=r.option[e.name],e):e.shift?(e.action=r.shift[e.name],e):(e.action=r.keys[e.name],e)};var gt=mt;function yt(t,e,i={}){let r=t.timers[e]={name:e,start:Date.now(),ms:0,tick:0},n=i.interval||120;r.frames=i.frames||[],r.loading=!0;let s=setInterval(()=>{r.ms=Date.now()-r.start,r.tick++,t.render()},n);return r.stop=()=>{r.loading=!1,clearInterval(s)},Reflect.defineProperty(r,"interval",{value:s}),t.once("close",()=>r.stop()),r.stop}const{define:bt,width:wt}=ut,vt={default:ct.noop,noop:ct.noop,set inverse(t){this._inverse=t},get inverse(){return this._inverse||ut.inverse(this.primary)},set complement(t){this._complement=t},get complement(){return this._complement||ut.complement(this.primary)},primary:ct.cyan,success:ct.green,danger:ct.magenta,strong:ct.bold,warning:ct.yellow,muted:ct.dim,disabled:ct.gray,dark:ct.dim.gray,underline:ct.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:(t={})=>{t.styles&&"boolean"==typeof t.styles.enabled&&(ct.enabled=t.styles.enabled),t.styles&&"boolean"==typeof t.styles.visible&&(ct.visible=t.styles.visible);let e=ut.merge({},vt,t.styles);delete e.merge;for(let t of Object.keys(ct))e.hasOwnProperty(t)||Reflect.defineProperty(e,t,{get:()=>ct[t]});for(let t of Object.keys(ct.styles))e.hasOwnProperty(t)||Reflect.defineProperty(e,t,{get:()=>ct[t]});return e}};var St=vt;const Et="win32"===process.platform,xt=st({},ct.symbols,{upDownDoubleArrow:"⇕",upDownDoubleArrow2:"⬍",upDownArrow:"↕",asterisk:"*",asterism:"⁂",bulletWhite:"◦",electricArrow:"⌁",ellipsisLarge:"⋯",ellipsisSmall:"…",fullBlock:"█",identicalTo:"≡",indicator:ct.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:ct.symbols.question,submitted:ct.symbols.check,cancelled:ct.symbols.cross},separator:{pending:ct.symbols.pointerSmall,submitted:ct.symbols.middot,cancelled:ct.symbols.middot},radio:{off:Et?"( )":"◯",on:Et?"(*)":"◉",disabled:Et?"(|)":"Ⓘ"},numbers:["⓪","①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩","⑪","⑫","⑬","⑭","⑮","⑯","⑰","⑱","⑲","⑳","㉑","㉒","㉓","㉔","㉕","㉖","㉗","㉘","㉙","㉚","㉛","㉜","㉝","㉞","㉟","㊱","㊲","㊳","㊴","㊵","㊶","㊷","㊸","㊹","㊺","㊻","㊼","㊽","㊾","㊿"]});xt.merge=t=>{let e=ut.merge({},ct.symbols,xt,t.symbols);return delete e.merge,e};var _t=xt,Ot=N(function(t,e){const i="Apple_Terminal"===process.env.TERM_PROGRAM,r=t.exports=e,n="[";let s=!1;const o=r.code={bell:"",beep:"",beginning:"",down:"",esc:n,getPosition:"",hide:"[?25l",line:"",lineEnd:"",lineStart:"",restorePosition:n+(i?"8":"u"),savePosition:n+(i?"7":"s"),screen:"",show:"[?25h",up:""},a=r.cursor={get hidden(){return s},hide:()=>(s=!0,o.hide),show:()=>(s=!1,o.show),forward:(t=1)=>`[${t}C`,backward:(t=1)=>`[${t}D`,nextLine:(t=1)=>"".repeat(t),prevLine:(t=1)=>"".repeat(t),up:(t=1)=>t?`[${t}A`:"",down:(t=1)=>t?`[${t}B`:"",right:(t=1)=>t?`[${t}C`:"",left:(t=1)=>t?`[${t}D`:"",to:(t,e)=>e?`[${e+1};${t+1}H`:`[${t+1}G`,move(t=0,e=0){let i="";return i+=t<0?a.left(-t):t>0?a.right(t):"",i+=e<0?a.up(-e):e>0?a.down(e):"",i},restore(t={}){let{after:e,cursor:i,initial:n,input:s,prompt:o,size:a,value:l}=t;if(n=ut.isPrimitive(n)?String(n):"",s=ut.isPrimitive(s)?String(s):"",l=ut.isPrimitive(l)?String(l):"",a){let t=r.cursor.up(a)+r.cursor.to(o.length),e=s.length-i;return e>0&&(t+=r.cursor.left(e)),t}if(l||e){let t=!s&&n?-n.length:-s.length+i;return e&&(t-=e.length),""===s&&n&&!o.includes(n)&&(t+=n.length),r.cursor.move(t)}}},l=r.erase={screen:o.screen,up:o.up,down:o.down,line:o.line,lineEnd:o.lineEnd,lineStart:o.lineStart,lines(t){let e="";for(let i=0;i<t;i++)e+=r.erase.line+(i<t-1?r.cursor.up(1):"");return t&&(e+=r.code.beginning),e}};r.clear=(t="",e=process.stdout.columns)=>{if(!e)return l.line+a.to(0);let i=t.split(/\r?\n/),r=0;for(let t of i)r+=1+Math.floor(Math.max([...ct.unstyle(t)].length-1,0)/e);return(l.line+a.prevLine()).repeat(r-1)+l.line+a.to(0)}});class Ct extends b.default{constructor(t={}){super(),this.name=t.name,this.type=t.type,this.options=t,(t=>{t.options=ut.merge({},t.options.theme,t.options),t.symbols=_t.merge(t.options),t.styles=St.merge(t.options)})(this),(t=>{t.timers=t.timers||{};let e=t.options.timers;if(e)for(let i of Object.keys(e)){let r=e[i];"number"==typeof r&&(r={interval:r}),yt(t,i,r)}})(this),this.state=new class{constructor(t){let e=t.options;bt(this,"_prompt",t),this.type=t.type,this.name=t.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=wt(e.stdout||process.stdout),Object.assign(this,e),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=t.symbols,this.styles=t.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let t=st({},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"}}(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":" ",r=[];for(let t=0;t<4;t++){let n=i(t);r.push(e[t]?n.repeat(e[t]):"")}return r}(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"],r=["body","footer","error","header","hint","indicator","message","prefix","separator","skip"];for(let n of Object.keys(t.options)){if(i.includes(n))continue;if(/^on[A-Z]/.test(n))continue;let s=t.options[n];"function"==typeof s&&e(n)?r.includes(n)||(t[n]=s.bind(t)):"function"!=typeof t[n]&&(t[n]=s)}}(this)}async keypress(t,e={}){this.keypressed=!0;let i=gt.action(t,gt(t,e),this.options.actions);this.state.keypress=i,this.emit("keypress",t,i),this.emit("state",this.state.clone());let r=this.options[i.action]||this[i.action]||this.dispatch;if("function"==typeof r)return await r.call(this,t,i);this.alert()}alert(){delete this.state.alert,!1===this.options.show?this.emit("alert"):this.stdout.write(Ot.code.beep)}cursorHide(){this.stdout.write(Ot.cursor.hide()),ut.onExit(()=>this.cursorShow())}cursorShow(){this.stdout.write(Ot.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(Ot.cursor.down(t)+Ot.clear(e,this.width))}restore(){if(this.state.closed||!1===this.options.show)return;let{prompt:t,after:e,rest:i}=this.sections(),{cursor:r,initial:n="",input:s="",value:o=""}=this,a=this.state.size=i.length,l=Ot.cursor.restore({after:e,cursor:r,initial:n,input:s,prompt:t,size:a,value:o});l&&this.stdout.write(l)}sections(){let{buffer:t,input:e,prompt:i}=this.state;i=ct.unstyle(i);let r=ct.unstyle(t),n=r.indexOf(i),s=r.slice(0,n),o=r.slice(n).split("\n"),a=o[0],l=o[o.length-1],c=(i+(e?" "+e:"")).length,u=c<a.length?a.slice(c+1):"";return{header:s,prompt:a,after:u,rest:o.slice(1),last:l}}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(Ot.cursor.down(t.rest.length)),this.write("\n".repeat(e))}catch(t){}this.emit("close")}start(){this.stop||!1===this.options.show||(this.stop=gt.listen(this,this.keypress.bind(this)),this.once("close",this.stop))}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:r,state:n,symbols:s,timers:o}=this;n.timer=o&&o[t];let a=r[t]||n[t]||s[t],l=e&&null!=e[t]?e[t]:await a;if(""===l)return l;let c=await this.resolve(l,n,e,i);return!c&&e&&e[t]?this.resolve(a,n,e,i):c}async prefix(){let t=await this.element("prefix")||this.symbols,e=this.state;return e.timer=this.timers&&this.timers.prefix,ut.isObject(t)&&(t=t[e.status]||t.pending),ut.hasColor(t)?t:(this.styles[e.status]||this.styles.pending)(t)}async message(){let t=await this.element("message");return ut.hasColor(t)?t:this.styles.strong(t)}async separator(){let t=await this.element("separator")||this.symbols,e=this.state;e.timer=this.timers&&this.timers.separator;let i=t[e.status]||t.pending||e.separator,r=await this.resolve(i,e);return ut.isObject(r)&&(r=r[e.status]||r.pending),ut.hasColor(r)?r:this.styles.muted(r)}async pointer(t,e){let i=await this.element("pointer",t,e);if("string"==typeof i&&ut.hasColor(i))return i;if(i){let t=this.styles,r=this.index===e,n=r?t.primary:t=>t,s=await this.resolve(i[r?"on":"off"]||i,this.state),o=ut.hasColor(s)?s:n(s);return r?o:" ".repeat(s.length)}}async indicator(t,e){let i=await this.element("indicator",t,e);if("string"==typeof i&&ut.hasColor(i))return i;if(i){let e=this.styles,r=!0===t.enabled,n=r?e.success:e.dark,s=i[r?"on":"off"]||i;return ut.hasColor(s)?s:n(s)}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 ut.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 ut.resolve(this,t,...e)}get base(){return Ct.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||ut.height(this.stdout,25)}get width(){return this.options.columns||ut.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()}}var kt=Ct;const $t={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,e)=>$t.default(t,e),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},{reorder:jt,scrollUp:At,scrollDown:Pt,isObject:Tt,swap:It}=ut;function Nt(t,e){if(e instanceof Promise)return e;if("function"==typeof e){if(ut.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}var Ft=class extends kt{constructor(t){super(t),this.cursorHide(),this.maxSelected=t.maxSelected||Infinity,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:r}=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 r&&0===this.selectable.length)throw new Error("At least one choice must be selectable");Tt(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=[],r=0,n=async(t,e)=>{"function"==typeof t&&(t=await t.call(this)),t instanceof Promise&&(t=await t);for(let s=0;s<t.length;s++){let o=t[s]=await this.toChoice(t[s],r++,e);i.push(o),o.choices&&await n(o.choices,o)}return i};return n(t,e).then(t=>(this.state.loadingChoices=!1,t))}async toChoice(t,e,i){if("function"==typeof t&&(t=await t.call(this,this)),t instanceof Promise&&(t=await t),"string"==typeof t&&(t={name:t}),t.normalized)return t;t.normalized=!0;let r=t.value,n=((t,e={})=>{let i=ut.merge({},$t,e.roles);return i[t]||i.default})(t.role,this.options);if("string"!=typeof(t=n(this,t)).disabled||t.hint||(t.hint=t.disabled,t.disabled=!0),!0===t.disabled&&null==t.hint&&(t.hint="(disabled)"),null!=t.index)return t;t.name=t.name||t.key||t.title||t.value||t.message,t.message=t.message||t.name||"",t.value=[t.value,t.name].find(this.isValue.bind(this)),t.input="",t.index=e,t.cursor=0,ut.define(t,"parent",i),t.level=i?i.level+1:1,null==t.indent&&(t.indent=i?i.indent+" ":t.indent||""),t.path=i?i.path+"."+t.name:t.name,t.enabled=!(!this.multiple||this.isDisabled(t)||!t.enabled&&!this.isSelected(t)),this.isDisabled(t)||(this.longest=Math.max(this.longest,ct.unstyle(t.message).length));let s=st({},t);return t.reset=(e=s.input,i=s.value)=>{for(let e of Object.keys(s))t[e]=s[e];t.input=e,t.value=i},null==r&&"function"==typeof t.initial&&(t.input=await t.initial.call(this,this.state,t,e)),t}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 r=await this.toChoice(t,e,i);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(t,e,i){let r=st({name:"New choice name?",editable:!0,newChoice:!0},t),n=await this.addChoice(r,e,i);return n.updateChoice=()=>{delete n.newChoice,n.name=n.message=n.input,n.input="",n.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.toggle(this.focused),this.render()):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(t=this.focused){return this.choices.some(t=>!!t.parent)?(this.toggle(t.parent&&!t.choices?t.parent:t),this.render()):this.a()}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 Nt(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,r=this.choices.find(t=>e===t.index);if(!r.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(-1===this.visible.indexOf(r)){let t=jt(this.choices),e=t.indexOf(r);if(i.index>e){let i=t.slice(e,e+this.limit),r=t.filter(t=>!i.includes(t));this.choices=i.concat(r)}else{let i=e-this.limit+1;this.choices=t.slice(i).concat(t.slice(0,i))}}return this.index=this.choices.indexOf(r),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(t=>{let i=this.choices.length,r=this.num,n=(i=!1,n)=>{clearTimeout(this.numberTimeout),i&&(n=e(r)),this.num="",t(n)};return"0"===r||1===r.length&&Number(r+"0")>i?n(!0):Number(r)>i?n(!1,this.alert()):void(this.numberTimeout=setTimeout(()=>n(!0),this.delay))})}home(){return this.choices=jt(this.choices),this.index=0,this.render()}end(){let t=this.choices.length-this.limit,e=jt(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.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.down():this.render())}scrollUp(t=0){return this.choices=At(this.choices),this.index=t,this.isDisabled()?this.up():this.render()}scrollDown(t=this.visible.length-1){return this.choices=Pt(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){It(this.choices,this.index,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=(this.options.multiple?this.state._choices:this.choices).filter("function"==typeof t?t:(e,i)=>[e.name,i].includes(t));return e?i.map(t=>t[e]):i}find(t,e){if(Tt(t))return e?t[e]:t;let i=this.choices.find("function"==typeof t?t:(e,i)=>[e.name,i].includes(t));return i?e?i[e]:i: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=ut.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 Nt(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;return Math.min(t.limit||this._limit||e.limit||i.length,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}},Rt=class extends Ft{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,e){let i=this.resolve(t.message,this.state,t,e);return"heading"!==t.role||ut.hasColor(i)||(i=this.styles.strong(i)),this.resolve(i,this.state,t,e)}choiceSeparator(){return":"}async renderChoice(t,e){await this.onChoice(t,e);let i=this.index===e,r=await this.pointer(t,e),n=await this.indicator(t,e)+(t.pad||""),s=await this.resolve(t.hint,this.state,t,e);s&&!ut.hasColor(s)&&(s=this.styles.muted(s));let o=this.indent(t),a=await this.choiceMessage(t,e),l=()=>[this.margin[3],o+r+n,a,this.margin[1],s].filter(Boolean).join(" ");return"heading"===t.role?l():t.disabled?(ut.hasColor(a)||(a=this.styles.disabled(a)),l()):(i&&(a=this.styles.em(a)),l())}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,r=this.margin[0]+e.join("\n");return this.options.choicesHeader&&(i=await this.resolve(this.options.choicesHeader,this.state)),[i,r].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="",r=await this.header(),n=await this.prefix(),s=await this.separator(),o=await this.message();!1!==this.options.promptLine&&(i=[n,o,s,""].join(" "),this.state.prompt=i);let a=await this.format(),l=await this.error()||await this.hint(),c=await this.renderChoices(),u=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([r,i,c,u].filter(Boolean).join("\n")),this.write(this.margin[2]),this.restore()}},Lt=class extends Rt{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();let t=((t,e)=>{let i=this.input.toLowerCase();return t=>{let r=t.toLowerCase().indexOf(i),n=e(t.slice(r,r+i.length));return r>=0?t.slice(0,r)+n+t.slice(r+i.length):t}})(0,this.options.highlight?this.options.highlight.bind(this):this.styles.placeholder),e=this.choices;this.choices=e.map(e=>st({},e,{message:t(e.message)})),await super.render(),this.choices=e}submit(){return this.options.multiple&&(this.value=this.selected.map(t=>t.name)),super.submit()}},Dt=(t,e={})=>{t.cursorHide();let{input:i="",initial:r="",pos:n,showCursor:s=!0,color:o}=e,a=o||t.styles.placeholder,l=ut.inverse(t.styles.primary),c=e=>l(t.styles.black(e)),u=i,h=c(" ");if(t.blink&&!0===t.blink.off&&(c=t=>t,h=""),s&&0===n&&""===r&&""===i)return c(" ");if(s&&0===n&&(i===r||""===i))return c(r[0])+a(r.slice(1));r=ut.isPrimitive(r)?`${r}`:"",i=ut.isPrimitive(i)?`${i}`:"";let d=r&&r.startsWith(i)&&r!==i,p=d?c(r[i.length]):h;if(n!==i.length&&!0===s&&(u=i.slice(0,n)+c(i[n])+i.slice(n+1),p=""),!1===s&&(p=""),d){let e=t.styles.unstyle(u+p);return u+p+a(r.slice(e.length))}return u+p},Bt=class extends Rt{constructor(t){super(st({},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:r}=e;return e.value=e.input=r.slice(0,i)+t+r.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 r=`${i}`.slice(0,e)+`${i}`.slice(e+1);return t.value=t.input=r,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(t,e){await this.onChoice(t,e);let{state:i,styles:r}=this,{cursor:n,initial:s="",name:o,hint:a,input:l=""}=t,{muted:c,submitted:u,primary:h,danger:d}=r,p=a,f=this.index===e,m=t.validate||(()=>!0),g=await this.choiceSeparator(t,e),y=t.message;"right"===this.align&&(y=y.padStart(this.longest+1," ")),"left"===this.align&&(y=y.padEnd(this.longest+1," "));let b=this.values[o]=l||s,w=l?"success":"dark";!0!==await m.call(t,b,this.state)&&(w="danger");let v=(0,r[w])(await this.indicator(t,e))+(t.pad||""),S=this.indent(t),E=()=>[S,v,y+g,l,p].filter(Boolean).join(" ");return i.submitted?(y=ct.unstyle(y),l=u(l),p="",E()):(l=t.format?await t.format.call(this,l,t,e):Dt(this,{input:l,initial:s,pos:n,showCursor:f,color:this.styles.muted}),this.isValue(l)||(l=this.styles.muted(this.symbols.ellipsis)),t.result&&(this.values[o]=await t.result.call(this,b,t,e)),f&&(y=h(y)),t.error?l+=(l?" ":"")+d(t.error.trim()):t.hint&&(l+=(l?" ":"")+c(t.hint.trim())),E())}async submit(){return this.value=this.values,super.base.submit.call(this)}};const Mt=()=>{throw new Error("expected prompt to have a custom authenticate method")},Gt=(t=Mt)=>class extends Bt{constructor(t){super(t)}async submit(){this.value=await t.call(this,this.values,this.state),super.base.submit.call(this)}static create(t){return Gt(t)}};var Ht=Gt();function Ut(t,e){return t.username===this.options.username&&t.password===this.options.password}const qt=(t=Ut)=>{const e=[{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 i extends(Ht.create(t)){constructor(t){super(st({},t,{choices:e}))}static create(t){return qt(t)}}return i};var Vt=qt();const{isPrimitive:Wt,hasColor:zt}=ut;var Yt=class extends kt{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 Wt(t)&&(this.isTrue(t)||this.isFalse(t))}async hint(){if("pending"===this.state.status){let t=await this.element("hint");return zt(t)?t:this.styles.muted(t)}}async render(){let{input:t,size:e}=this.state,i=await this.prefix(),r=await this.separator(),n=[i,await this.message(),this.styles.muted(this.default),r].filter(Boolean).join(" ");this.state.prompt=n;let s=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&&!n.includes(l)&&(a+=" "+l),n+=" "+a,this.clear(e),this.write([s,n,c].filter(Boolean).join("\n")),this.restore()}set value(t){super.value=t}get value(){return this.cast(super.value)}},Kt=class extends Yt{constructor(t){super(t),this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}};const Jt=Bt.prototype;var Xt=class extends Rt{constructor(t){super(st({},t,{multiple:!0})),this.align=[this.options.align,"left"].find(t=>null!=t),this.emptyError="",this.values={}}dispatch(t,e){let i=this.focused;return i.editable||(i.parent||{}).editable||"a"!==t&&"i"!==t?Jt.dispatch.call(this,t,e):super[t]()}append(t,e){return Jt.append.call(this,t,e)}delete(t,e){return Jt.delete.call(this,t,e)}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?Jt.next.call(this):super.next()}prev(){return this.focused.editable?Jt.prev.call(this):super.prev()}async indicator(t,e){let i=t.editable?t.indicator||"":super.indicator(t,e);return await this.resolve(i,this.state,t,e)||""}indent(t){return"heading"===t.role?"":t.editable?" ":" "}async renderChoice(t,e){return t.indent="",t.editable?Jt.renderChoice.call(this,t,e):super.renderChoice(t,e)}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)}};const{isPrimitive:Zt}=ut;var Qt=class extends kt{constructor(t){super(t),this.initial=Zt(this.initial)?String(this.initial):"",this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[]}async keypress(t,e={}){let i=this.state.prevKeypress;return this.state.prevKeypress=e,!0!==this.options.multiline||"return"!==e.name||i&&"return"===i.name?super.keypress(t,e):this.append("\n",e)}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),r=e.split(" ");this.state.clipboard.push(r.pop()),this.input=r.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):Dt(this,{input:t,initial:e,pos:this.cursor})}async render(){let t=this.state.size,e=await this.prefix(),i=await this.separator(),r=[e,await this.message(),i].filter(Boolean).join(" ");this.state.prompt=r;let n=await this.header(),s=await this.format(),o=await this.error()||await this.hint(),a=await this.footer();o&&!s.includes(o)&&(s+=" "+o),r+=" "+s,this.clear(t),this.write([n,r,a].filter(Boolean).join("\n")),this.restore()}};const te=t=>(t=>t.filter((e,i)=>t.lastIndexOf(e)===i))(t).filter(Boolean);var ee=(t,e={},i="")=>{let r,n,{past:s=[],present:o=""}=e;switch(t){case"prev":case"undo":return r=s.slice(0,s.length-1),n=s[s.length-1]||"",{past:te([i,...r]),present:n};case"next":case"redo":return r=s.slice(1),n=s[0]||"",{past:te([...r,i]),present:n};case"save":return{past:te([...s,i]),present:""};case"remove":return n=te(s.filter(t=>t!==i)),o="",n.length&&(o=n.pop()),{past:n,present:o};default:throw new Error(`Invalid action: "${t}"`)}},ie=class extends Qt{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=ee(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=ee("save",this.data,this.input),this.store.set("values",this.data))}submit(){return this.store&&!0===this.autosave&&this.save(),super.submit()}},re=class extends Qt{format(){return""}},ne=class extends Qt{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(){return this.list.map(this.state.submitted?this.styles.primary:t=>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()}},se=class extends Rt{constructor(t){super(st({},t,{multiple:!0}))}},oe=class extends Qt{constructor(t={}){super(st({style:"number"},t)),this.min=this.isValue(t.min)?this.toNumber(t.min):-Infinity,this.max=this.isValue(t.max)?this.toNumber(t.max):Infinity,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()}},ae=oe,le=class extends Qt{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)):""}},ce=class extends Ft{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,r=Math.round(i/(e.length-1)),n=e.map(t=>this.styles.strong(t)).join(" ".repeat(r)),s=" ".repeat(this.widths[0]);return this.margin[3]+s+this.margin[1]+n}scaleIndicator(t,e,i){if("function"==typeof this.options.scaleIndicator)return this.options.scaleIndicator.call(this,t,e,i);let r=t.scaleIndex===e.index;return e.disabled?this.styles.hint(this.symbols.radio.disabled):r?this.styles.success(this.symbols.radio.on):this.symbols.radio.off}renderScale(t,e){return t.scale.map(i=>this.scaleIndicator(t,i,e)).join(("Hyper"===this.term?"":" ")+this.symbols.line.repeat(this.edgeLength))}async renderChoice(t,e){await this.onChoice(t,e);let i=this.index===e,r=await this.pointer(t,e),n=await t.hint;n&&!ut.hasColor(n)&&(n=this.styles.muted(n));let s=t=>this.margin[3]+t.replace(/\s+$/,"").padEnd(this.widths[0]," "),o=this.newline,a=this.indent(t),l=await this.resolve(t.message,this.state,t,e),c=await this.renderScale(t,e),u=this.margin[1]+this.margin[3];this.scaleLength=ct.unstyle(c).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-u.length);let h=ut.wordWrap(l,{width:this.widths[0],newline:o}).split("\n").map(t=>s(t)+this.margin[1]);return i&&(c=this.styles.info(c),h=h.map(t=>this.styles.info(t))),h[0]+=c,this.linebreak&&h.push(""),[a+r,h.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(),r=await this.separator(),n=await this.message(),s="";!1!==this.options.promptLine&&(s=[i,n,r,""].join(" "),this.state.prompt=s);let o=await this.header(),a=await this.format(),l=await this.renderScaleKey(),c=await this.error()||await this.hint(),u=await this.renderChoices(),h=await this.footer(),d=this.emptyError;a&&(s+=a),c&&!s.includes(c)&&(s+=" "+c),t&&!a&&!u.trim()&&this.multiple&&null!=d&&(s+=this.styles.danger(d)),this.clear(e),this.write([o,s,l,u,h].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)}};class ue{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 he(t,e,i,r){return(i,n,s,o)=>"function"==typeof s.field[t]?s.field[t].call(e,i,n,s,o):[r,i].find(t=>e.isValue(t))}var de=class extends kt{constructor(t){super(t),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await(async t=>{let e=t.options,i=new Set(!0===e.required?[]:e.required||[]),r=st({},e.values,e.initial),{tabstops:n,items:s,keys:o}=await(async(t={},e={},i=(t=>t))=>{let r=new Set,n=t.fields||[],s=t.template,o=[],a=[],l=[],c=1;"function"==typeof s&&(s=await s());let u=-1,h=()=>s[++u],d=()=>s[u+1],p=t=>{t.line=c,o.push(t)};for(p({type:"bos",value:""});u<s.length-1;){let t=h();if(/^[^\S\n ]$/.test(t)){p({type:"text",value:t});continue}if("\n"===t){p({type:"newline",value:t}),c++;continue}if("\\"===t){t+=h(),p({type:"text",value:t});continue}if(("$"===t||"#"===t||"{"===t)&&"{"===d()){t+=h();let s,o={type:"template",open:t,inner:"",close:"",value:t};for(;s=h();){if("}"===s){"}"===d()&&(s+=h()),o.value+=s,o.close=s;break}":"===s?(o.initial="",o.key=o.inner):void 0!==o.initial&&(o.initial+=s),o.value+=s,o.inner+=s}o.template=o.open+(o.initial||o.inner)+o.close,o.key=o.key||o.inner,e.hasOwnProperty(o.key)&&(o.initial=e[o.key]),o=i(o),p(o),l.push(o.key),r.add(o.key);let c=a.find(t=>t.name===o.key);o.field=n.find(t=>t.name===o.key),c||(c=new ue(o),a.push(c)),c.lines.push(o.line-1);continue}let s=o[o.length-1];"text"===s.type&&s.line===c?s.value+=t:p({type:"text",value:t})}return p({type:"eos",value:""}),{input:s,tabstops:o,unique:r,keys:l,items:a}})(e,r),a=he("result",t),l=he("format",t),c=he("validate",t,0,!0),u=t.isValue.bind(t);return async(r={},h=!1)=>{let d=0;r.required=i,r.items=s,r.keys=o,r.output="";let p=async(t,e,i,r)=>{let n=await c(t,e,i,r);return!1===n?"Invalid field "+i.name:n};for(let i of n){let n=i.value,o=i.key;if("template"===i.type){if("template"===i.type){let c=s.find(t=>t.name===o);!0===e.required&&r.required.add(c.name);let f=[c.input,r.values[c.value],c.value,n].find(u),m=(c.field||{}).message||i.inner;if(h){let t=await p(r.values[o],r,c,d);if(t&&"string"==typeof t||!1===t){r.invalid.set(o,t);continue}r.invalid.delete(o);let e=await a(r.values[o],r,c,d);r.output+=ct.unstyle(e);continue}c.placeholder=!1;let g=n;n=await l(n,r,c,d),f!==n?(r.values[o]=f,n=t.styles.typing(f),r.missing.delete(m)):(r.values[o]=void 0,f=`<${m}>`,n=t.styles.primary(f),c.placeholder=!0,r.required.has(o)&&r.missing.add(m)),r.missing.has(m)&&r.validating&&(n=t.styles.warning(f)),r.invalid.has(o)&&r.validating&&(n=t.styles.danger(f)),d===r.index&&(n=g!==n?t.styles.underline(n):t.styles.heading(ct.unstyle(n))),d++}n&&(r.output+=n)}else n&&(r.output+=n)}let f=r.output.split("\n").map(t=>" "+t),m=s.length,g=0;for(let e of s)r.invalid.has(e.name)&&e.lines.forEach(t=>{" "===f[t][0]&&(f[t]=r.styles.danger(r.symbols.bullet)+f[t].slice(1))}),t.isValue(r.values[e.name])&&g++;return r.completed=(g/m*100).toFixed(0),r.output=f.join("\n"),r.output}})(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(),r=i.input.slice(0,this.cursor),n=i.input.slice(this.cursor);this.input=i.input=`${r}${t}${n}`,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:r}=this.state,n=[this.options.newline,"\n"].find(t=>null!=t),s=await this.prefix(),o=await this.separator(),a=[s,await this.message(),o].filter(Boolean).join(" ");this.state.prompt=a;let l=await this.header(),c=await this.error()||"",u=await this.hint()||"",h=i?"":await this.interpolate(this.state),d=this.state.key=e[t]||"",p=await this.format(d),f=await this.footer();p&&(a+=" "+p),u&&!p&&0===this.state.completed&&(a+=" "+u),this.clear(r);let m=[l,a,h,f,c.trim()];this.write(m.filter(Boolean).join(n)),this.restore()}getItem(t){let{items:e,keys:i,index:r}=this.state,n=e.find(t=>t.name===i[r]);return n&&null!=n.input&&(this.input=n.input,this.cursor=n.cursor),n}async submit(){"function"!=typeof this.interpolate&&await this.initialize(),await this.interpolate(this.state,!0);let{invalid:t,missing:e,output:i,values:r}=this.state;if(t.size){let e="";for(let[i,r]of t)e+=`Invalid ${i}: ${r}\n`;return this.state.error=e,super.submit()}if(e.size)return this.state.error="Required: "+[...e.keys()].join(", "),super.submit();let n=ct.unstyle(i).split("\n").map(t=>t.slice(1)).join("\n");return this.value={values:r,result:n},super.submit()}};const pe="(Use <shift>+<up/down> to sort)";var fe=class extends Rt{constructor(t){super(st({},t,{reorder:!1,sort:!0,multiple:!0})),this.state.hint=[this.options.hint,pe].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(t,e){let i=await super.renderChoice(t,e),r=this.index===e&&this.sorting?this.styles.muted(this.symbols.identicalTo+" "):" ";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()}};function me(t,e={}){if(Array.isArray(e.scale))return e.scale.map(t=>st({},t));let i=[];for(let e=1;e<t+1;e++)i.push({i:e,selected:!1});return i}var ge=class extends Ft{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 e=await super.toChoices(...t);for(let t of e)t.scale=me(5,this.options),t.scaleIdx=2;return e}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,r="Hyper"===this.term,n=r?9:8,s=r?"":" ",o=this.symbols.line.repeat(n),a=" ".repeat(n+(r?0:1)),l=t=>(t?this.styles.success("◉"):"◯")+s,c=e+1+".",u=i?this.styles.heading:this.styles.noop,h=await this.resolve(t.message,this.state,t,e),d=this.indent(t),p=d+t.scale.map((e,i)=>l(i===t.scaleIdx)).join(o),f=d+t.scale.map((e,i)=>(e=>e===t.scaleIdx?u(e):e)(i)).join(a);return i&&(p=this.styles.cyan(p),f=this.styles.cyan(f)),[[c,h].filter(Boolean).join(" "),p,f," "].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(){return this.state.submitted?this.choices.map(t=>this.styles.info(t.scaleIdx)).join(", "):""}async render(){let{submitted:t,size:e}=this.state,i=await this.prefix(),r=await this.separator(),n=[i,await this.message(),r].filter(Boolean).join(" ");this.state.prompt=n;let s=await this.header(),o=await this.format(),a=await this.error()||await this.hint(),l=await this.renderChoices(),c=await this.footer();!o&&a||(n+=" "+o),a&&!n.includes(a)&&(n+=" "+a),t&&!o&&!l&&this.multiple&&"form"!==this.type&&(n+=this.styles.danger(this.emptyError)),this.clear(e),this.write([n,s,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)}},ye=ie,be=class extends Yt{async initialize(){await super.initialize(),this.value=this.initial=!!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(),r=await this.separator(),n=await this.message(),s=await this.format(),o=await this.error()||await this.hint(),a=await this.footer(),l=[i,n,r,s].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()}},we=class extends Rt{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)}}},ve=N(function(t,e){const i=(t,i)=>{ut.defineExport(e,t,i),ut.defineExport(e,t.toLowerCase(),i)};i("AutoComplete",()=>Lt),i("BasicAuth",()=>Vt),i("Confirm",()=>Kt),i("Editable",()=>Xt),i("Form",()=>Bt),i("Input",()=>ie),i("Invisible",()=>re),i("List",()=>ne),i("MultiSelect",()=>se),i("Numeral",()=>ae),i("Password",()=>le),i("Scale",()=>ce),i("Select",()=>Rt),i("Snippet",()=>de),i("Sort",()=>fe),i("Survey",()=>ge),i("Text",()=>ye),i("Toggle",()=>be),i("Quiz",()=>we)}),Se={ArrayPrompt:Ft,AuthPrompt:Ht,BooleanPrompt:Yt,NumberPrompt:oe,StringPrompt:Qt};class Ee extends b.default{constructor(t,e){super(),this.options=ut.merge({},t),this.answers=st({},e)}register(t,e){if(ut.isObject(t)){for(let e of Object.keys(t))this.register(e,t[e]);return this}S.default.equal(typeof e,"function","expected a function");let i=t.toLowerCase();return this.prompts[i]=e.prototype instanceof this.Prompt?e: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(ut.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=ut.merge({},this.options,t),{type:i,name:r}=t,{set:n,get:s}=ut;if("function"==typeof i&&(i=await i.call(this,t,this.answers)),!i)return this.answers[r];S.default(this.prompts[i],`Prompt "${i}" is not registered`);let o=new this.prompts[i](e),a=s(this.answers,r);o.state.answers=this.answers,o.enquirer=this,r&&o.on("submit",t=>{this.emit("answer",r,t,o),n(this.answers,r,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||kt}static get prompts(){return ve}static get types(){return Se}static get prompt(){const t=(e,...i)=>{let r=new this(...i),n=r.emit.bind(r);return r.emit=(...e)=>(t.emit(...e),n(...e)),r.prompt(e)};return ut.mixinEmitter(t,new b.default),t}}ut.mixinEmitter(Ee,new b.default);const xe=Ee.prompts;for(let t of Object.keys(xe)){let e=t.toLowerCase(),i=e=>new xe[t](e).run();Ee.prompt[e]=i,Ee[e]=i,Ee[t]||Reflect.defineProperty(Ee,t,{get:()=>xe[t]})}const _e=t=>{ut.defineExport(Ee,t,()=>Ee.types[t])};_e("ArrayPrompt"),_e("AuthPrompt"),_e("BooleanPrompt"),_e("NumberPrompt"),_e("StringPrompt");var Oe=Ee,Ce=$e;function ke(t,e,i){return!(!t.isSymbolicLink()&&!t.isFile())&&function(t,e){var i=void 0!==e.pathExt?e.pathExt:process.env.PATHEXT;if(!i)return!0;if(-1!==(i=i.split(";")).indexOf(""))return!0;for(var r=0;r<i.length;r++){var n=i[r].toLowerCase();if(n&&t.substr(-n.length).toLowerCase()===n)return!0}return!1}(e,i)}function $e(t,e,i){v.default.stat(t,function(r,n){i(r,!r&&ke(n,t,e))})}$e.sync=function(t,e){return ke(v.default.statSync(t),t,e)};var je,Ae=Pe;function Pe(t,e,i){v.default.stat(t,function(t,r){i(t,!t&&Te(r,e))})}function Te(t,e){return t.isFile()&&function(t,e){var i=t.mode,r=t.uid,n=t.gid,s=void 0!==e.uid?e.uid:process.getuid&&process.getuid(),o=void 0!==e.gid?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),l=parseInt("010",8);return i&parseInt("001",8)||i&l&&n===o||i&a&&r===s||i&(a|l)&&0===s}(t,e)}Pe.sync=function(t,e){return Te(v.default.statSync(t),e)},je="win32"===process.platform||I.TESTING_WINDOWS?Ce:Ae;var Ie=Ne;function Ne(t,e,i){if("function"==typeof e&&(i=e,e={}),!i){if("function"!=typeof Promise)throw new TypeError("callback not provided");return new Promise(function(i,r){Ne(t,e||{},function(t,e){t?r(t):i(e)})})}je(t,e||{},function(t,r){t&&("EACCES"===t.code||e&&e.ignoreErrors)&&(t=null,r=!1),i(t,r)})}Ne.sync=function(t,e){try{return je.sync(t,e||{})}catch(t){if(e&&e.ignoreErrors||"EACCES"===t.code)return!1;throw t}};const Fe="win32"===process.platform||"cygwin"===process.env.OSTYPE||"msys"===process.env.OSTYPE,Re=Fe?";":":",Le=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),De=(t,e)=>{const i=e.colon||Re,r=t.match(/\//)||Fe&&t.match(/\\/)?[""]:[...Fe?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(i)],n=Fe?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=Fe?n.split(i):[""];return Fe&&-1!==t.indexOf(".")&&""!==s[0]&&s.unshift(""),{pathEnv:r,pathExt:s,pathExtExe:n}},Be=(t,e,i)=>{"function"==typeof e&&(i=e,e={}),e||(e={});const{pathEnv:r,pathExt:n,pathExtExe:s}=De(t,e),o=[],a=i=>new Promise((n,s)=>{if(i===r.length)return e.all&&o.length?n(o):s(Le(t));const a=r[i],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=y.default.join(c,t),h=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;n(l(h,i,0))}),l=(t,i,r)=>new Promise((c,u)=>{if(r===n.length)return c(a(i+1));const h=n[r];Ie(t+h,{pathExt:s},(n,s)=>{if(!n&&s){if(!e.all)return c(t+h);o.push(t+h)}return c(l(t,i,r+1))})});return i?a(0).then(t=>i(null,t),i):a(0)};var Me=Be;Be.sync=(t,e)=>{e=e||{};const{pathEnv:i,pathExt:r,pathExtExe:n}=De(t,e),s=[];for(let o=0;o<i.length;o++){const a=i[o],l=/^".*"$/.test(a)?a.slice(1,-1):a,c=y.default.join(l,t),u=!l&&/^\.[\\\/]/.test(t)?t.slice(0,2)+c:c;for(let t=0;t<r.length;t++){const i=u+r[t];try{if(Ie.sync(i,{pathExt:n})){if(!e.all)return i;s.push(i)}}catch(t){}}}if(e.all&&s.length)return s;if(e.nothrow)return null;throw Le(t)};const Ge=(t={})=>{const e=t.env||process.env;return"win32"!==(t.platform||process.platform)?"PATH":Object.keys(e).reverse().find(t=>"PATH"===t.toUpperCase())||"Path"};var He=Ge;function Ue(t,e){const i=t.options.env||process.env,r=process.cwd(),n=null!=t.options.cwd,s=n&&void 0!==process.chdir&&!process.chdir.disabled;if(s)try{process.chdir(t.options.cwd)}catch(t){}let o;try{o=Me.sync(t.command,{path:i[He({env:i})],pathExt:e?y.default.delimiter:void 0})}catch(t){}finally{s&&process.chdir(r)}return o&&(o=y.default.resolve(n?t.options.cwd:"",o)),o}He.default=Ge;var qe=function(t){return Ue(t)||Ue(t,!0)};const Ve=/([()\][%!^"`<>&|;, *?])/g;var We=/^#!(.*)/;const ze="win32"===process.platform,Ye=/\.(?:com|exe)$/i,Ke=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;var Je=function(t,e,i){e&&!Array.isArray(e)&&(i=e,e=null);const r={command:t,args:e=e?e.slice(0):[],options:i=Object.assign({},i),file:void 0,original:{command:t,args:e}};return i.shell?r:function(t){if(!ze)return t;const e=function(t){t.file=qe(t);const e=t.file&&function(t){const e=Buffer.alloc(150);let i;try{i=v.default.openSync(t,"r"),v.default.readSync(i,e,0,150,0),v.default.closeSync(i)}catch(t){}return((t="")=>{const e=t.match(We);if(!e)return null;const[i,r]=e[0].replace(/#! ?/,"").split(" "),n=i.split("/").pop();return"env"===n?r:r?`${n} ${r}`:n})(e.toString())}(t.file);return e?(t.args.unshift(t.file),t.command=e,qe(t)):t.file}(t),i=!Ye.test(e);if(t.options.forceShell||i){const i=Ke.test(e);t.command=y.default.normalize(t.command),t.command=t.command.replace(Ve,"^$1"),t.args=t.args.map(t=>function(t,e){return t=(t=`"${t=(t=(t=`${t}`).replace(/(\\*)"/g,'$1$1\\"')).replace(/(\\*)$/,"$1$1")}"`).replace(Ve,"^$1"),e&&(t=t.replace(Ve,"^$1")),t}(t,i));const r=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${r}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}(r)};const Xe="win32"===process.platform;function Ze(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function Qe(t,e){return Xe&&1===t&&!e.file?Ze(e.original,"spawn"):null}var ti={hookChildProcess:function(t,e){if(!Xe)return;const i=t.emit;t.emit=function(r,n){if("exit"===r){const r=Qe(n,e);if(r)return i.call(t,"error",r)}return i.apply(t,arguments)}},verifyENOENT:Qe,verifyENOENTSync:function(t,e){return Xe&&1===t&&!e.file?Ze(e.original,"spawnSync"):null},notFoundError:Ze};function ei(t,e,i){const r=Je(t,e,i),n=w.default.spawn(r.command,r.args,r.options);return ti.hookChildProcess(n,r),n}var ii=ei,ri=Je,ni=ti;ii.spawn=ei,ii.sync=function(t,e,i){const r=Je(t,e,i),n=w.default.spawnSync(r.command,r.args,r.options);return n.error=n.error||ti.verifyENOENTSync(n.status,r),n},ii._parse=ri,ii._enoent=ni;const si=(t={})=>{const e=t.env||process.env;return"win32"!==(t.platform||process.platform)?"PATH":Object.keys(e).reverse().find(t=>"PATH"===t.toUpperCase())||"Path"};var oi=si;oi.default=si;var ai=N(function(t){const e=t=>{let e;t=st({cwd:process.cwd(),path:process.env[oi()],execPath:process.execPath},t);let i=y.default.resolve(t.cwd);const r=[];for(;e!==i;)r.push(y.default.join(i,"node_modules/.bin")),e=i,i=y.default.resolve(i,"..");const n=y.default.resolve(t.cwd,t.execPath,"..");return r.push(n),r.concat(t.path).join(y.default.delimiter)};t.exports=e,t.exports.default=e,t.exports.env=e=>{e=st({env:process.env},e);const i=st({},e.env),r=oi({env:i});return e.path=i[r],i[r]=t.exports(e),i}});const li=(t,e)=>{for(const i of Reflect.ownKeys(e))Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(e,i));return t};var ci=li;ci.default=li;const ui=new WeakMap,hi=(t,e={})=>{if("function"!=typeof t)throw new TypeError("Expected a function");let i,r=0;const n=t.displayName||t.name||"<anonymous>",s=function(...o){if(ui.set(s,++r),1===r)i=t.apply(this,o),t=null;else if(!0===e.throw)throw new Error(`Function \`${n}\` can only be called once`);return i};return ci(s,t),ui.set(s,r),s};var di=hi;di.default=hi,di.callCount=t=>{if(!ui.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return ui.get(t)};var pi=N(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.SIGNALS=void 0,e.SIGNALS=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}]}),fi=N(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.SIGRTMAX=e.getRealtimeSignals=void 0,e.getRealtimeSignals=function(){return Array.from({length:n-r+1},i)};const i=function(t,e){return{name:`SIGRT${e+1}`,number:r+e,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},r=34,n=64;e.SIGRTMAX=n}),mi=N(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.getSignals=void 0,e.getSignals=function(){const t=(0,fi.getRealtimeSignals)();return[...pi.SIGNALS,...t].map(i)};const i=function({name:t,number:e,description:i,action:r,forced:n=!1,standard:s}){const{signals:{[t]:o}}=x.default.constants,a=void 0!==o;return{name:t,number:a?o:e,description:i,supported:a,action:r,forced:n,standard:s}}}),gi=N(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.signalsByNumber=e.signalsByName=void 0;const i=(0,mi.getSignals)().reduce(function(t,{name:e,number:i,description:r,supported:n,action:s,forced:o,standard:a}){return st({},t,{[e]:{name:e,number:i,description:r,supported:n,action:s,forced:o,standard:a}})},{});e.signalsByName=i;const r=function(){const t=(0,mi.getSignals)(),e=Array.from({length:fi.SIGRTMAX+1},(e,i)=>function(t,e){const i=function(t,e){const i=e.find(({name:e})=>x.default.constants.signals[e]===t);return void 0!==i?i:e.find(e=>e.number===t)}(t,e);if(void 0===i)return{};const{name:r,description:n,supported:s,action:o,forced:a,standard:l}=i;return{[t]:{name:r,number:t,description:n,supported:s,action:o,forced:a,standard:l}}}(i,t));return Object.assign({},...e)}();e.signalsByNumber=r});const{signalsByName:yi}=gi;var bi=({stdout:t,stderr:e,all:i,error:r,signal:n,exitCode:s,command:o,escapedCommand:a,timedOut:l,isCanceled:c,killed:u,parsed:{options:{timeout:h}}})=>{const d=void 0===(n=null===n?void 0:n)?void 0:yi[n].description,p=`Command ${(({timedOut:t,timeout:e,errorCode:i,signal:r,signalDescription:n,exitCode:s,isCanceled:o})=>t?`timed out after ${e} milliseconds`:o?"was canceled":void 0!==i?`failed with ${i}`:void 0!==r?`was killed with ${r} (${n})`:void 0!==s?`failed with exit code ${s}`:"failed")({timedOut:l,timeout:h,errorCode:r&&r.code,signal:n,signalDescription:d,exitCode:s=null===s?void 0:s,isCanceled:c})}: ${o}`,f="[object Error]"===Object.prototype.toString.call(r),m=f?`${p}\n${r.message}`:p,g=[m,e,t].filter(Boolean).join("\n");return f?(r.originalMessage=r.message,r.message=g):r=new Error(g),r.shortMessage=m,r.command=o,r.escapedCommand=a,r.exitCode=s,r.signal=n,r.signalDescription=d,r.stdout=t,r.stderr=e,void 0!==i&&(r.all=i),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=Boolean(l),r.isCanceled=c,r.killed=u&&!l,r};const wi=["stdin","stdout","stderr"],vi=t=>{if(!t)return;const{stdio:e}=t;if(void 0===e)return wi.map(e=>t[e]);if((t=>wi.some(e=>void 0!==t[e]))(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${wi.map(t=>`\`${t}\``).join(", ")}`);if("string"==typeof e)return e;if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);const i=Math.max(e.length,wi.length);return Array.from({length:i},(t,i)=>e[i])};var Si=vi;Si.node=t=>{const e=vi(t);return"ipc"===e?"ipc":void 0===e||"string"==typeof e?[e,e,e,"ipc"]:e.includes("ipc")?e:[...e,"ipc"]};var Ei,xi=N(function(t){t.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],"win32"!==process.platform&&t.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),"linux"===process.platform&&t.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")}),_i=/^win/i.test(process.platform),Oi=b.default;"function"!=typeof Oi&&(Oi=Oi.EventEmitter),process.__signal_exit_emitter__?Ei=process.__signal_exit_emitter__:((Ei=process.__signal_exit_emitter__=new Oi).count=0,Ei.emitted={}),Ei.infinite||(Ei.setMaxListeners(Infinity),Ei.infinite=!0);var Ci=function(t,e){S.default.equal(typeof t,"function","a callback must be provided for exit handler"),!1===Ti&&Ii();var i="exit";return e&&e.alwaysLast&&(i="afterexit"),Ei.on(i,t),function(){Ei.removeListener(i,t),0===Ei.listeners("exit").length&&0===Ei.listeners("afterexit").length&&$i()}},ki=$i;function $i(){Ti&&(Ti=!1,xi.forEach(function(t){try{process.removeListener(t,Ai[t])}catch(t){}}),process.emit=Ri,process.reallyExit=Ni,Ei.count-=1)}function ji(t,e,i){Ei.emitted[t]||(Ei.emitted[t]=!0,Ei.emit(t,e,i))}var Ai={};xi.forEach(function(t){Ai[t]=function(){process.listeners(t).length===Ei.count&&($i(),ji("exit",null,t),ji("afterexit",null,t),_i&&"SIGHUP"===t&&(t="SIGINT"),process.kill(process.pid,t))}});var Pi=Ii,Ti=!1;function Ii(){Ti||(Ti=!0,Ei.count+=1,xi=xi.filter(function(t){try{return process.on(t,Ai[t]),!0}catch(t){return!1}}),process.emit=Li,process.reallyExit=Fi)}var Ni=process.reallyExit;function Fi(t){process.exitCode=t||0,ji("exit",process.exitCode,null),ji("afterexit",process.exitCode,null),Ni.call(process,process.exitCode)}var Ri=process.emit;function Li(t,e){if("exit"===t){void 0!==e&&(process.exitCode=e);var i=Ri.apply(this,arguments);return ji("exit",process.exitCode,null),ji("afterexit",process.exitCode,null),i}return Ri.apply(this,arguments)}Ci.unload=ki,Ci.signals=function(){return xi},Ci.load=Pi;var Di={spawnedKill:(t,e="SIGTERM",i={})=>{const r=t(e);return((t,e,i,r)=>{if(!((t,{forceKillAfterTimeout:e},i)=>(t=>t===x.default.constants.signals.SIGTERM||"string"==typeof t&&"SIGTERM"===t.toUpperCase())(t)&&!1!==e&&i)(e,i,r))return;const n=(({forceKillAfterTimeout:t=!0})=>{if(!0===t)return 5e3;if(!Number.isFinite(t)||t<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`);return t})(i),s=setTimeout(()=>{t("SIGKILL")},n);s.unref&&s.unref()})(t,e,i,r),r},spawnedCancel:(t,e)=>{t.kill()&&(e.isCanceled=!0)},setupTimeout:(t,{timeout:e,killSignal:i="SIGTERM"},r)=>{if(0===e||void 0===e)return r;let n;const s=new Promise((r,s)=>{n=setTimeout(()=>{((t,e,i)=>{t.kill(e),i(Object.assign(new Error("Timed out"),{timedOut:!0,signal:e}))})(t,i,s)},e)}),o=r.finally(()=>{clearTimeout(n)});return Promise.race([s,o])},validateTimeout:({timeout:t})=>{if(void 0!==t&&(!Number.isFinite(t)||t<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`)},setExitHandler:async(t,{cleanup:e,detached:i},r)=>{if(!e||i)return r;const n=Ci(()=>{t.kill()});return r.finally(()=>{n()})}};const Bi=t=>null!==t&&"object"==typeof t&&"function"==typeof t.pipe;Bi.writable=t=>Bi(t)&&!1!==t.writable&&"function"==typeof t._write&&"object"==typeof t._writableState,Bi.readable=t=>Bi(t)&&!1!==t.readable&&"function"==typeof t._read&&"object"==typeof t._readableState,Bi.duplex=t=>Bi.writable(t)&&Bi.readable(t),Bi.transform=t=>Bi.duplex(t)&&"function"==typeof t._transform;var Mi=Bi;const{PassThrough:Gi}=O.default,{constants:Hi}=_.default,{promisify:Ui}=C.default,qi=Ui(O.default.pipeline);class Vi extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function Wi(t,e){if(!t)throw new Error("Expected a stream");e=st({maxBuffer:Infinity},e);const{maxBuffer:i}=e,r=(t=>{t=st({},t);const{array:e}=t;let{encoding:i}=t;const r="buffer"===i;let n=!1;e?n=!(i||r):i=i||"utf8",r&&(i=null);const s=new Gi({objectMode:n});i&&s.setEncoding(i);let o=0;const a=[];return s.on("data",t=>{a.push(t),n?o=a.length:o+=t.length}),s.getBufferedValue=()=>e?a:r?Buffer.concat(a,o):a.join(""),s.getBufferedLength=()=>o,s})(e);return await new Promise((e,n)=>{const s=t=>{t&&r.getBufferedLength()<=Hi.MAX_LENGTH&&(t.bufferedData=r.getBufferedValue()),n(t)};(async()=>{try{await qi(t,r),e()}catch(t){s(t)}})(),r.on("data",()=>{r.getBufferedLength()>i&&s(new Vi)})}),r.getBufferedValue()}var zi=Wi,Yi=Vi;zi.buffer=(t,e)=>Wi(t,st({},e,{encoding:"buffer"})),zi.array=(t,e)=>Wi(t,st({},e,{array:!0})),zi.MaxBufferError=Yi;const{PassThrough:Ki}=O.default,Ji=async(t,e)=>{if(t){t.destroy();try{return await e}catch(t){return t.bufferedData}}},Xi=(t,{encoding:e,buffer:i,maxBuffer:r})=>{if(t&&i)return e?zi(t,{encoding:e,maxBuffer:r}):zi.buffer(t,{maxBuffer:r})};var Zi={handleInput:(t,e)=>{void 0!==e&&void 0!==t.stdin&&(Mi(e)?e.pipe(t.stdin):t.stdin.end(e))},makeAllStream:(t,{all:e})=>{if(!e||!t.stdout&&!t.stderr)return;const i=function(){var t=[],e=new Ki({objectMode:!0});return e.setMaxListeners(0),e.add=i,e.isEmpty=r,e.on("unpipe",n),Array.prototype.slice.call(arguments).forEach(i),e;function i(r){return Array.isArray(r)?(r.forEach(i),this):(t.push(r),r.once("end",n.bind(null,r)),r.once("error",e.emit.bind(e,"error")),r.pipe(e,{end:!1}),this)}function r(){return 0==t.length}function n(i){!(t=t.filter(function(t){return t!==i})).length&&e.readable&&e.end()}}();return t.stdout&&i.add(t.stdout),t.stderr&&i.add(t.stderr),i},getSpawnedResult:async({stdout:t,stderr:e,all:i},{encoding:r,buffer:n,maxBuffer:s},o)=>{const a=Xi(t,{encoding:r,buffer:n,maxBuffer:s}),l=Xi(e,{encoding:r,buffer:n,maxBuffer:s}),c=Xi(i,{encoding:r,buffer:n,maxBuffer:2*s});try{return await Promise.all([o,a,l,c])}catch(r){return Promise.all([{error:r,signal:r.signal,timedOut:r.timedOut},Ji(t,a),Ji(e,l),Ji(i,c)])}},validateInputSync:({input:t})=>{if(Mi(t))throw new TypeError("The `input` option cannot be a stream in sync mode")}};const Qi=(async()=>{})().constructor.prototype,tr=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Qi,t)]);var er={mergePromise:(t,e)=>{for(const[i,r]of tr){const n="function"==typeof e?(...t)=>Reflect.apply(r.value,e(),t):r.value.bind(e);Reflect.defineProperty(t,i,st({},r,{value:n}))}return t},getSpawnedPromise:t=>new Promise((e,i)=>{t.on("exit",(t,i)=>{e({exitCode:t,signal:i})}),t.on("error",t=>{i(t)}),t.stdin&&t.stdin.on("error",t=>{i(t)})})};const ir=(t,e=[])=>Array.isArray(e)?[t,...e]:[t],rr=/^[\w.-]+$/,nr=/"/g,sr=/ +/g;var or={joinCommand:(t,e)=>ir(t,e).join(" "),getEscapedCommand:(t,e)=>ir(t,e).map(t=>(t=>"string"!=typeof t||rr.test(t)?t:`"${t.replace(nr,'\\"')}"`)(t)).join(" "),parseCommand:t=>{const e=[];for(const i of t.trim().split(sr)){const t=e[e.length-1];t&&t.endsWith("\\")?e[e.length-1]=`${t.slice(0,-1)} ${i}`:e.push(i)}return e}};const{spawnedKill:ar,spawnedCancel:lr,setupTimeout:cr,validateTimeout:ur,setExitHandler:hr}=Di,{handleInput:dr,getSpawnedResult:pr,makeAllStream:fr,validateInputSync:mr}=Zi,{mergePromise:gr,getSpawnedPromise:yr}=er,{joinCommand:br,parseCommand:wr,getEscapedCommand:vr}=or,Sr=(t,e,i={})=>{const r=ii._parse(t,e,i);return t=r.command,e=r.args,(i=st({maxBuffer:1e8,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:(i=r.options).cwd||process.cwd(),execPath:process.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0},i)).env=(({env:t,extendEnv:e,preferLocal:i,localDir:r,execPath:n})=>{const s=e?st({},process.env,t):t;return i?ai.env({env:s,cwd:r,execPath:n}):s})(i),i.stdio=Si(i),"win32"===process.platform&&"cmd"===y.default.basename(t,".exe")&&e.unshift("/q"),{file:t,args:e,options:i,parsed:r}},Er=(t,e,i)=>"string"==typeof e||Buffer.isBuffer(e)?t.stripFinalNewline?(t=>{const e="string"==typeof t?"\n":"\n".charCodeAt(),i="string"==typeof t?"\r":"\r".charCodeAt();return t[t.length-1]===e&&(t=t.slice(0,t.length-1)),t[t.length-1]===i&&(t=t.slice(0,t.length-1)),t})(e):e:void 0===i?void 0:"",xr=(t,e,i)=>{const r=Sr(t,e,i),n=br(t,e),s=vr(t,e);let o;ur(r.options);try{o=w.default.spawn(r.file,r.args,r.options)}catch(t){const e=new w.default.ChildProcess,i=Promise.reject(bi({error:t,stdout:"",stderr:"",all:"",command:n,escapedCommand:s,parsed:r,timedOut:!1,isCanceled:!1,killed:!1}));return gr(e,i)}const a=yr(o),l=cr(o,r.options,a),c=hr(o,r.options,l),u={isCanceled:!1};o.kill=ar.bind(null,o.kill.bind(o)),o.cancel=lr.bind(null,o,u);const h=di(async()=>{const[{error:t,exitCode:e,signal:i,timedOut:a},l,h,d]=await pr(o,r.options,c),p=Er(r.options,l),f=Er(r.options,h),m=Er(r.options,d);if(t||0!==e||null!==i){const l=bi({error:t,exitCode:e,signal:i,stdout:p,stderr:f,all:m,command:n,escapedCommand:s,parsed:r,timedOut:a,isCanceled:u.isCanceled,killed:o.killed});if(!r.options.reject)return l;throw l}return{command:n,escapedCommand:s,exitCode:0,stdout:p,stderr:f,all:m,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return dr(o,r.options.input),o.all=fr(o,r.options),gr(o,h)};var _r=xr;_r.sync=(t,e,i)=>{const r=Sr(t,e,i),n=br(t,e),s=vr(t,e);let o;mr(r.options);try{o=w.default.spawnSync(r.file,r.args,r.options)}catch(t){throw bi({error:t,stdout:"",stderr:"",all:"",command:n,escapedCommand:s,parsed:r,timedOut:!1,isCanceled:!1,killed:!1})}const a=Er(r.options,o.stdout,o.error),l=Er(r.options,o.stderr,o.error);if(o.error||0!==o.status||null!==o.signal){const t=bi({stdout:a,stderr:l,error:o.error,signal:o.signal,exitCode:o.status,command:n,escapedCommand:s,parsed:r,timedOut:o.error&&"ETIMEDOUT"===o.error.code,isCanceled:!1,killed:null!==o.signal});if(!r.options.reject)return t;throw t}return{command:n,escapedCommand:s,exitCode:0,stdout:a,stderr:l,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},_r.command=(t,e)=>{const[i,...r]=wr(t);return xr(i,r,e)},_r.commandSync=(t,e)=>{const[i,...r]=wr(t);return xr.sync(i,r,e)},_r.node=(t,e,i={})=>{e&&!Array.isArray(e)&&"object"==typeof e&&(i=e,e=[]);const r=Si.node(i),n=process.execArgv.filter(t=>!t.startsWith("--inspect")),{nodePath:s=process.execPath,nodeOptions:o=n}=i;return xr(s,[...o,t,...Array.isArray(e)?e:[]],st({},i,{stdin:void 0,stdout:void 0,stderr:void 0,stdio:r,shell:!1}))};const Or="win32"===process.platform?["-","\\","|","/"]:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],Cr=process.stderr;var kr=function(t="",e=Or,i=80){let r=0;Cr.write("[?25l");const n=setInterval(()=>{Cr.write(`${e[r]} ${t}`),r=(r+1)%e.length,Cr.cursorTo(0)},i);return function(){clearInterval(n),Cr.cursorTo(0),Cr.write("[?25h")}},$r=Ar;Ar.sync=function(t){if(t in jr)return jr[t];try{v.default.lstatSync(t),jr[t]=!0}catch(e){jr[t]=!1}return jr[t]};var jr=Object.create(null);function Ar(t,e){if(t in jr)return process.nextTick(e.bind(null,jr[t]));v.default.lstat(t,function(i){e(jr[t]=!i)})}var Pr=function(t){return Object.defineProperty(function(...e){if("function"!=typeof e[e.length-1])return new Promise((i,r)=>{t.call(this,...e,(t,e)=>null!=t?r(t):i(e))});t.apply(this,e)},"name",{value:t.name})},Tr=function(t){return Object.defineProperty(function(...e){const i=e[e.length-1];if("function"!=typeof i)return t.apply(this,e);t.apply(this,e.slice(0,-1)).then(t=>i(null,t),i)},"name",{value:t.name})},Ir=process.cwd,Nr=null,Fr=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Nr||(Nr=Ir.call(process)),Nr};try{process.cwd()}catch(t){}var Rr=process.chdir;process.chdir=function(t){Nr=null,Rr.call(process,t)};var Lr=O.default.Stream,Dr=N(function(t){var e,i;"function"==typeof Symbol&&"function"==typeof Symbol.for?(e=Symbol.for("graceful-fs.queue"),i=Symbol.for("graceful-fs.previous")):(e="___graceful-fs.queue",i="___graceful-fs.previous");var r=function(){};if(C.default.debuglog?r=C.default.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(r=function(){var t=C.default.format.apply(C.default,arguments);t="GFS4: "+t.split(/\n/).join("\nGFS4: "),console.error(t)}),!I[e]){var n=[];Object.defineProperty(I,e,{get:function(){return n}}),v.default.close=function(t){function e(e,i){return t.call(v.default,e,function(t){t||a(),"function"==typeof i&&i.apply(this,arguments)})}return Object.defineProperty(e,i,{value:t}),e}(v.default.close),v.default.closeSync=function(t){function e(e){t.apply(v.default,arguments),a()}return Object.defineProperty(e,i,{value:t}),e}(v.default.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){r(I[e]),S.default.equal(I[e].length,0)})}function s(t){(function(t){var e,i;function r(e){return e?function(i,r,n){return e.call(t,i,r,function(t){c(t)&&(t=null),n&&n.apply(this,arguments)})}:e}function n(e){return e?function(i,r){try{return e.call(t,i,r)}catch(t){if(!c(t))throw t}}:e}function s(e){return e?function(i,r,n,s){return e.call(t,i,r,n,function(t){c(t)&&(t=null),s&&s.apply(this,arguments)})}:e}function o(e){return e?function(i,r,n){try{return e.call(t,i,r,n)}catch(t){if(!c(t))throw t}}:e}function a(e){return e?function(i,r,n){function s(t,e){e&&(e.uid<0&&(e.uid+=4294967296),e.gid<0&&(e.gid+=4294967296)),n&&n.apply(this,arguments)}return"function"==typeof r&&(n=r,r=null),r?e.call(t,i,r,s):e.call(t,i,s)}:e}function l(e){return e?function(i,r){var n=r?e.call(t,i,r):e.call(t,i);return n.uid<0&&(n.uid+=4294967296),n.gid<0&&(n.gid+=4294967296),n}:e}function c(t){return!t||"ENOSYS"===t.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==t.code&&"EPERM"!==t.code)}k.default.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(t){t.lchmod=function(e,i,r){t.open(e,k.default.O_WRONLY|k.default.O_SYMLINK,i,function(e,n){e?r&&r(e):t.fchmod(n,i,function(e){t.close(n,function(t){r&&r(e||t)})})})},t.lchmodSync=function(e,i){var r,n=t.openSync(e,k.default.O_WRONLY|k.default.O_SYMLINK,i),s=!0;try{r=t.fchmodSync(n,i),s=!1}finally{if(s)try{t.closeSync(n)}catch(t){}else t.closeSync(n)}return r}}(t),t.lutimes||function(t){k.default.hasOwnProperty("O_SYMLINK")?(t.lutimes=function(e,i,r,n){t.open(e,k.default.O_SYMLINK,function(e,s){e?n&&n(e):t.futimes(s,i,r,function(e){t.close(s,function(t){n&&n(e||t)})})})},t.lutimesSync=function(e,i,r){var n,s=t.openSync(e,k.default.O_SYMLINK),o=!0;try{n=t.futimesSync(s,i,r),o=!1}finally{if(o)try{t.closeSync(s)}catch(t){}else t.closeSync(s)}return n}):(t.lutimes=function(t,e,i,r){r&&process.nextTick(r)},t.lutimesSync=function(){})}(t),t.chown=s(t.chown),t.fchown=s(t.fchown),t.lchown=s(t.lchown),t.chmod=r(t.chmod),t.fchmod=r(t.fchmod),t.lchmod=r(t.lchmod),t.chownSync=o(t.chownSync),t.fchownSync=o(t.fchownSync),t.lchownSync=o(t.lchownSync),t.chmodSync=n(t.chmodSync),t.fchmodSync=n(t.fchmodSync),t.lchmodSync=n(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=l(t.statSync),t.fstatSync=l(t.fstatSync),t.lstatSync=l(t.lstatSync),t.lchmod||(t.lchmod=function(t,e,i){i&&process.nextTick(i)},t.lchmodSync=function(){}),t.lchown||(t.lchown=function(t,e,i,r){r&&process.nextTick(r)},t.lchownSync=function(){}),"win32"===Fr&&(t.rename=(e=t.rename,function(i,r,n){var s=Date.now(),o=0;e(i,r,function a(l){if(l&&("EACCES"===l.code||"EPERM"===l.code)&&Date.now()-s<6e4)return setTimeout(function(){t.stat(r,function(t,s){t&&"ENOENT"===t.code?e(i,r,a):n(l)})},o),void(o<100&&(o+=10));n&&n(l)})})),t.read=function(e){function i(i,r,n,s,o,a){var l;if(a&&"function"==typeof a){var c=0;l=function(u,h,d){if(u&&"EAGAIN"===u.code&&c<10)return c++,e.call(t,i,r,n,s,o,l);a.apply(this,arguments)}}return e.call(t,i,r,n,s,o,l)}return i.__proto__=e,i}(t.read),t.readSync=(i=t.readSync,function(e,r,n,s,o){for(var a=0;;)try{return i.call(t,e,r,n,s,o)}catch(t){if("EAGAIN"===t.code&&a<10){a++;continue}throw t}})})(t),t.gracefulify=s,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,r){return"function"==typeof i&&(r=i,i=null),function t(i,r,n){return e(i,r,function(e){!e||"EMFILE"!==e.code&&"ENFILE"!==e.code?("function"==typeof n&&n.apply(this,arguments),a()):o([t,[i,r,n]])})}(t,i,r)};var i=t.writeFile;t.writeFile=function(t,e,r,n){return"function"==typeof r&&(n=r,r=null),function t(e,r,n,s){return i(e,r,n,function(i){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?("function"==typeof s&&s.apply(this,arguments),a()):o([t,[e,r,n,s]])})}(t,e,r,n)};var r=t.appendFile;r&&(t.appendFile=function(t,e,i,n){return"function"==typeof i&&(n=i,i=null),function t(e,i,n,s){return r(e,i,n,function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?("function"==typeof s&&s.apply(this,arguments),a()):o([t,[e,i,n,s]])})}(t,e,i,n)});var n=t.readdir;function l(e){return n.apply(t,e)}if(t.readdir=function(t,e,i){var r=[t];return"function"!=typeof e?r.push(e):i=e,r.push(function(t,e){e&&e.sort&&e.sort(),!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?("function"==typeof i&&i.apply(this,arguments),a()):o([l,[r]])}),l(r)},"v0.8"===process.version.substr(0,4)){var c=function(t){return{ReadStream:function e(i,r){if(!(this instanceof e))return new e(i,r);Lr.call(this);var n=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,r=r||{};for(var s=Object.keys(r),o=0,a=s.length;o<a;o++){var l=s[o];this[l]=r[l]}if(this.encoding&&this.setEncoding(this.encoding),void 0!==this.start){if("number"!=typeof this.start)throw TypeError("start must be a Number");if(void 0===this.end)this.end=Infinity;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}null===this.fd?t.open(this.path,this.flags,this.mode,function(t,e){if(t)return n.emit("error",t),void(n.readable=!1);n.fd=e,n.emit("open",e),n._read()}):process.nextTick(function(){n._read()})},WriteStream:function e(i,r){if(!(this instanceof e))return new e(i,r);Lr.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var n=Object.keys(r),s=0,o=n.length;s<o;s++){var a=n[s];this[a]=r[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())}}}(t);f=c.ReadStream,m=c.WriteStream}var u=t.ReadStream;u&&(f.prototype=Object.create(u.prototype),f.prototype.open=function(){var t=this;y(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 h=t.WriteStream;h&&(m.prototype=Object.create(h.prototype),m.prototype.open=function(){var t=this;y(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 f},set:function(t){f=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return m},set:function(t){m=t},enumerable:!0,configurable:!0});var d=f;Object.defineProperty(t,"FileReadStream",{get:function(){return d},set:function(t){d=t},enumerable:!0,configurable:!0});var p=m;function f(t,e){return this instanceof f?(u.apply(this,arguments),this):f.apply(Object.create(f.prototype),arguments)}function m(t,e){return this instanceof m?(h.apply(this,arguments),this):m.apply(Object.create(m.prototype),arguments)}Object.defineProperty(t,"FileWriteStream",{get:function(){return p},set:function(t){p=t},enumerable:!0,configurable:!0});var g=t.open;function y(t,e,i,r){return"function"==typeof i&&(r=i,i=null),function t(e,i,r,n){return g(e,i,r,function(s,l){!s||"EMFILE"!==s.code&&"ENFILE"!==s.code?("function"==typeof n&&n.apply(this,arguments),a()):o([t,[e,i,r,n]])})}(t,e,i,r)}return t.open=y,t}function o(t){r("ENQUEUE",t[0].name,t[1]),I[e].push(t)}function a(){var t=I[e].shift();t&&(r("RETRY",t[0].name,t[1]),t[0].apply(null,t[1]))}t.exports=s(function(t){if(null===t||"object"!=typeof t)return t;if(t instanceof Object)var e={__proto__:t.__proto__};else e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}(v.default)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!v.default.__patched&&(t.exports=s(v.default),v.default.__patched=!0)}),Br=N(function(t,e){const i=Pr,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(t=>"function"==typeof Dr[t]);Object.assign(e,Dr),r.forEach(t=>{e[t]=i(Dr[t])}),e.realpath.native=i(Dr.realpath.native),e.exists=function(t,e){return"function"==typeof e?Dr.exists(t,e):new Promise(e=>Dr.exists(t,e))},e.read=function(t,e,i,r,n,s){return"function"==typeof s?Dr.read(t,e,i,r,n,s):new Promise((s,o)=>{Dr.read(t,e,i,r,n,(t,e,i)=>{if(t)return o(t);s({bytesRead:e,buffer:i})})})},e.write=function(t,e,...i){return"function"==typeof i[i.length-1]?Dr.write(t,e,...i):new Promise((r,n)=>{Dr.write(t,e,...i,(t,e,i)=>{if(t)return n(t);r({bytesWritten:e,buffer:i})})})},"function"==typeof Dr.writev&&(e.writev=function(t,e,...i){return"function"==typeof i[i.length-1]?Dr.writev(t,e,...i):new Promise((r,n)=>{Dr.writev(t,e,...i,(t,e,i)=>{if(t)return n(t);r({bytesWritten:e,buffers:i})})})})}),Mr={checkPath:function(t){if("win32"===process.platform&&/[<>:"|?*]/.test(t.replace(y.default.parse(t).root,""))){const e=new Error(`Path contains invalid characters: ${t}`);throw e.code="EINVAL",e}}};const{checkPath:Gr}=Mr,Hr=t=>"number"==typeof t?t:{mode:511,...t}.mode;var Ur={makeDir:async(t,e)=>(Gr(t),Br.mkdir(t,{mode:Hr(e),recursive:!0})),makeDirSync:(t,e)=>(Gr(t),Br.mkdirSync(t,{mode:Hr(e),recursive:!0}))};const qr=Tr,{makeDir:Vr,makeDirSync:Wr}=Ur,zr=qr(Vr);var Yr={mkdirs:zr,mkdirsSync:Wr,mkdirp:zr,mkdirpSync:Wr,ensureDir:zr,ensureDirSync:Wr};function Kr(t,e,i){const r=i.dereference?t=>Br.stat(t,{bigint:!0}):t=>Br.lstat(t,{bigint:!0});return Promise.all([r(t),r(e).catch(t=>{if("ENOENT"===t.code)return null;throw t})]).then(([t,e])=>({srcStat:t,destStat:e}))}function Jr(t,e){return e.ino&&e.dev&&e.ino===t.ino&&e.dev===t.dev}function Xr(t,e){const i=y.default.resolve(t).split(y.default.sep).filter(t=>t),r=y.default.resolve(e).split(y.default.sep).filter(t=>t);return i.reduce((t,e,i)=>t&&r[i]===e,!0)}function Zr(t,e,i){return`Cannot ${i} '${t}' to a subdirectory of itself, '${e}'.`}var Qr={checkPaths:function(t,e,i,r,n){C.default.callbackify(Kr)(t,e,r,(r,s)=>{if(r)return n(r);const{srcStat:o,destStat:a}=s;if(a){if(Jr(o,a)){const r=y.default.basename(t),s=y.default.basename(e);return"move"===i&&r!==s&&r.toLowerCase()===s.toLowerCase()?n(null,{srcStat:o,destStat:a,isChangingCase:!0}):n(new Error("Source and destination must not be the same."))}if(o.isDirectory()&&!a.isDirectory())return n(new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'.`));if(!o.isDirectory()&&a.isDirectory())return n(new Error(`Cannot overwrite directory '${e}' with non-directory '${t}'.`))}return o.isDirectory()&&Xr(t,e)?n(new Error(Zr(t,e,i))):n(null,{srcStat:o,destStat:a})})},checkPathsSync:function(t,e,i,r){const{srcStat:n,destStat:s}=function(t,e,i){let r;const n=i.dereference?t=>Br.statSync(t,{bigint:!0}):t=>Br.lstatSync(t,{bigint:!0}),s=n(t);try{r=n(e)}catch(t){if("ENOENT"===t.code)return{srcStat:s,destStat:null};throw t}return{srcStat:s,destStat:r}}(t,e,r);if(s){if(Jr(n,s)){const r=y.default.basename(t),o=y.default.basename(e);if("move"===i&&r!==o&&r.toLowerCase()===o.toLowerCase())return{srcStat:n,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(n.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'.`);if(!n.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${t}'.`)}if(n.isDirectory()&&Xr(t,e))throw new Error(Zr(t,e,i));return{srcStat:n,destStat:s}},checkParentPaths:function t(e,i,r,n,s){const o=y.default.resolve(y.default.dirname(e)),a=y.default.resolve(y.default.dirname(r));if(a===o||a===y.default.parse(a).root)return s();Br.stat(a,{bigint:!0},(o,l)=>o?"ENOENT"===o.code?s():s(o):Jr(i,l)?s(new Error(Zr(e,r,n))):t(e,i,a,n,s))},checkParentPathsSync:function t(e,i,r,n){const s=y.default.resolve(y.default.dirname(e)),o=y.default.resolve(y.default.dirname(r));if(o===s||o===y.default.parse(o).root)return;let a;try{a=Br.statSync(o,{bigint:!0})}catch(t){if("ENOENT"===t.code)return;throw t}if(Jr(i,a))throw new Error(Zr(e,r,n));return t(e,i,o,n)},isSrcSubdir:Xr,areIdentical:Jr};const tn=Yr.mkdirsSync;function en(t,e,i,r){const n=(r.dereference?Dr.statSync:Dr.lstatSync)(e);if(n.isDirectory())return function(t,e,i,r,n){return e?sn(i,r,n):function(t,e,i,r){return Dr.mkdirSync(i),sn(e,i,r),nn(i,t)}(t.mode,i,r,n)}(n,t,e,i,r);if(n.isFile()||n.isCharacterDevice()||n.isBlockDevice())return function(t,e,i,r,n){return e?function(t,e,i,r){if(r.overwrite)return Dr.unlinkSync(i),rn(t,e,i,r);if(r.errorOnExist)throw new Error(`'${i}' already exists`)}(t,i,r,n):rn(t,i,r,n)}(n,t,e,i,r);if(n.isSymbolicLink())return function(t,e,i,r){let n=Dr.readlinkSync(e);if(r.dereference&&(n=y.default.resolve(process.cwd(),n)),t){let t;try{t=Dr.readlinkSync(i)}catch(t){if("EINVAL"===t.code||"UNKNOWN"===t.code)return Dr.symlinkSync(n,i);throw t}if(r.dereference&&(t=y.default.resolve(process.cwd(),t)),Qr.isSrcSubdir(n,t))throw new Error(`Cannot copy '${n}' to a subdirectory of itself, '${t}'.`);if(Dr.statSync(i).isDirectory()&&Qr.isSrcSubdir(t,n))throw new Error(`Cannot overwrite '${t}' with '${n}'.`);return function(t,e){return Dr.unlinkSync(e),Dr.symlinkSync(t,e)}(n,i)}return Dr.symlinkSync(n,i)}(t,e,i,r);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}`)}function rn(t,e,i,r){return Dr.copyFileSync(e,i),r.preserveTimestamps&&function(t,e,i){(function(t){return 0==(128&t)})(t)&&function(t,e){nn(t,128|e)}(i,t),function(t,e){const i=Dr.statSync(t);!function(t,e,i){const r=Dr.openSync(t,"r+");Dr.futimesSync(r,e,i),Dr.closeSync(r)}(e,i.atime,i.mtime)}(e,i)}(t.mode,e,i),nn(i,t.mode)}function nn(t,e){return Dr.chmodSync(t,e)}function sn(t,e,i){Dr.readdirSync(t).forEach(r=>function(t,e,i,r){const n=y.default.join(e,t),s=y.default.join(i,t),{destStat:o}=Qr.checkPathsSync(n,s,"copy",r);return function(t,e,i,r){if(!r.filter||r.filter(e,i))return en(t,e,i,r)}(o,n,s,r)}(r,t,e,i))}var on={copySync: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&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");const{srcStat:r,destStat:n}=Qr.checkPathsSync(t,e,"copy",i);return Qr.checkParentPathsSync(t,r,e,"copy"),function(t,e,i,r){if(r.filter&&!r.filter(e,i))return;const n=y.default.dirname(i);return Dr.existsSync(n)||tn(n),en(t,e,i,r)}(n,t,e,i)}},an={pathExists:Tr(function(t){return Br.access(t).then(()=>!0).catch(()=>!1)}),pathExistsSync:Br.existsSync};const ln=Yr.mkdirs,cn=an.pathExists;function un(t,e,i,r,n){const s=y.default.dirname(i);cn(s,(o,a)=>o?n(o):a?dn(t,e,i,r,n):void ln(s,s=>s?n(s):dn(t,e,i,r,n)))}function hn(t,e,i,r,n,s){Promise.resolve(n.filter(i,r)).then(o=>o?t(e,i,r,n,s):s(),t=>s(t))}function dn(t,e,i,r,n){(r.dereference?Dr.stat:Dr.lstat)(e,(s,o)=>s?n(s):o.isDirectory()?function(t,e,i,r,n,s){return e?gn(i,r,n,s):function(t,e,i,r,n){Dr.mkdir(i,s=>{if(s)return n(s);gn(e,i,r,e=>e?n(e):mn(i,t,n))})}(t.mode,i,r,n,s)}(o,t,e,i,r,n):o.isFile()||o.isCharacterDevice()||o.isBlockDevice()?function(t,e,i,r,n,s){return e?function(t,e,i,r,n){if(!r.overwrite)return r.errorOnExist?n(new Error(`'${i}' already exists`)):n();Dr.unlink(i,s=>s?n(s):pn(t,e,i,r,n))}(t,i,r,n,s):pn(t,i,r,n,s)}(o,t,e,i,r,n):o.isSymbolicLink()?function(t,e,i,r,n){Dr.readlink(e,(e,s)=>e?n(e):(r.dereference&&(s=y.default.resolve(process.cwd(),s)),t?void Dr.readlink(i,(e,o)=>e?"EINVAL"===e.code||"UNKNOWN"===e.code?Dr.symlink(s,i,n):n(e):(r.dereference&&(o=y.default.resolve(process.cwd(),o)),Qr.isSrcSubdir(s,o)?n(new Error(`Cannot copy '${s}' to a subdirectory of itself, '${o}'.`)):t.isDirectory()&&Qr.isSrcSubdir(o,s)?n(new Error(`Cannot overwrite '${o}' with '${s}'.`)):function(t,e,i){Dr.unlink(e,r=>r?i(r):Dr.symlink(t,e,i))}(s,i,n))):Dr.symlink(s,i,n)))}(t,e,i,r,n):o.isSocket()?n(new Error(`Cannot copy a socket file: ${e}`)):o.isFIFO()?n(new Error(`Cannot copy a FIFO pipe: ${e}`)):n(new Error(`Unknown file: ${e}`)))}function pn(t,e,i,r,n){Dr.copyFile(e,i,s=>s?n(s):r.preserveTimestamps?function(t,e,i,r){return function(t){return 0==(128&t)}(t)?function(t,e,i){return mn(t,128|e,i)}(i,t,n=>n?r(n):fn(t,e,i,r)):fn(t,e,i,r)}(t.mode,e,i,n):mn(i,t.mode,n))}function fn(t,e,i,r){!function(t,e,i){Dr.stat(t,(t,r)=>t?i(t):function(t,e,i,r){Dr.open(t,"r+",(t,n)=>{if(t)return r(t);Dr.futimes(n,e,i,t=>{Dr.close(n,e=>{r&&r(t||e)})})})}(e,r.atime,r.mtime,i))}(e,i,e=>e?r(e):mn(i,t,r))}function mn(t,e,i){return Dr.chmod(t,e,i)}function gn(t,e,i,r){Dr.readdir(t,(n,s)=>n?r(n):yn(s,t,e,i,r))}function yn(t,e,i,r,n){const s=t.pop();return s?function(t,e,i,r,n,s){const o=y.default.join(i,e),a=y.default.join(r,e);Qr.checkPaths(o,a,"copy",n,(e,l)=>{if(e)return s(e);const{destStat:c}=l;!function(t,e,i,r,n){r.filter?hn(dn,t,e,i,r,n):dn(t,e,i,r,n)}(c,o,a,n,e=>e?s(e):yn(t,i,r,n,s))})}(t,s,e,i,r,n):n()}var bn={copy:Pr(function(t,e,i,r){"function"!=typeof i||r?"function"==typeof i&&(i={filter:i}):(r=i,i={}),r=r||function(){},(i=i||{}).clobber=!("clobber"in i)||!!i.clobber,i.overwrite="overwrite"in i?!!i.overwrite:i.clobber,i.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269"),Qr.checkPaths(t,e,"copy",i,(n,s)=>{if(n)return r(n);const{srcStat:o,destStat:a}=s;Qr.checkParentPaths(t,o,e,"copy",n=>n?r(n):i.filter?hn(un,a,t,e,i,r):un(a,t,e,i,r))})})};const wn="win32"===process.platform;function vn(t){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(e=>{t[e]=t[e]||Dr[e],t[e+="Sync"]=t[e]||Dr[e]}),t.maxBusyTries=t.maxBusyTries||3}function Sn(t,e,i){let r=0;"function"==typeof e&&(i=e,e={}),S.default(t,"rimraf: missing path"),S.default.strictEqual(typeof t,"string","rimraf: path should be a string"),S.default.strictEqual(typeof i,"function","rimraf: callback function required"),S.default(e,"rimraf: invalid options argument provided"),S.default.strictEqual(typeof e,"object","rimraf: options should be object"),vn(e),En(t,e,function n(s){if(s){if(("EBUSY"===s.code||"ENOTEMPTY"===s.code||"EPERM"===s.code)&&r<e.maxBusyTries)return r++,setTimeout(()=>En(t,e,n),100*r);"ENOENT"===s.code&&(s=null)}i(s)})}function En(t,e,i){S.default(t),S.default(e),S.default("function"==typeof i),e.lstat(t,(r,n)=>r&&"ENOENT"===r.code?i(null):r&&"EPERM"===r.code&&wn?xn(t,e,r,i):n&&n.isDirectory()?On(t,e,r,i):void e.unlink(t,r=>{if(r){if("ENOENT"===r.code)return i(null);if("EPERM"===r.code)return wn?xn(t,e,r,i):On(t,e,r,i);if("EISDIR"===r.code)return On(t,e,r,i)}return i(r)}))}function xn(t,e,i,r){S.default(t),S.default(e),S.default("function"==typeof r),e.chmod(t,438,n=>{n?r("ENOENT"===n.code?null:i):e.stat(t,(n,s)=>{n?r("ENOENT"===n.code?null:i):s.isDirectory()?On(t,e,i,r):e.unlink(t,r)})})}function _n(t,e,i){let r;S.default(t),S.default(e);try{e.chmodSync(t,438)}catch(t){if("ENOENT"===t.code)return;throw i}try{r=e.statSync(t)}catch(t){if("ENOENT"===t.code)return;throw i}r.isDirectory()?kn(t,e,i):e.unlinkSync(t)}function On(t,e,i,r){S.default(t),S.default(e),S.default("function"==typeof r),e.rmdir(t,n=>{!n||"ENOTEMPTY"!==n.code&&"EEXIST"!==n.code&&"EPERM"!==n.code?r(n&&"ENOTDIR"===n.code?i:n):function(t,e,i){S.default(t),S.default(e),S.default("function"==typeof i),e.readdir(t,(r,n)=>{if(r)return i(r);let s,o=n.length;if(0===o)return e.rmdir(t,i);n.forEach(r=>{Sn(y.default.join(t,r),e,r=>{if(!s)return r?i(s=r):void(0==--o&&e.rmdir(t,i))})})})}(t,e,r)})}function Cn(t,e){let i;vn(e=e||{}),S.default(t,"rimraf: missing path"),S.default.strictEqual(typeof t,"string","rimraf: path should be a string"),S.default(e,"rimraf: missing options"),S.default.strictEqual(typeof e,"object","rimraf: options should be object");try{i=e.lstatSync(t)}catch(i){if("ENOENT"===i.code)return;"EPERM"===i.code&&wn&&_n(t,e,i)}try{i&&i.isDirectory()?kn(t,e,null):e.unlinkSync(t)}catch(i){if("ENOENT"===i.code)return;if("EPERM"===i.code)return wn?_n(t,e,i):kn(t,e,i);if("EISDIR"!==i.code)throw i;kn(t,e,i)}}function kn(t,e,i){S.default(t),S.default(e);try{e.rmdirSync(t)}catch(r){if("ENOTDIR"===r.code)throw i;if("ENOTEMPTY"===r.code||"EEXIST"===r.code||"EPERM"===r.code)!function(t,e){if(S.default(t),S.default(e),e.readdirSync(t).forEach(i=>Cn(y.default.join(t,i),e)),!wn)return e.rmdirSync(t,e);{const i=Date.now();do{try{return e.rmdirSync(t,e)}catch{}}while(Date.now()-i<500)}}(t,e);else if("ENOENT"!==r.code)throw r}}var $n=Sn;Sn.sync=Cn;var jn={remove:Pr(function(t,e){if(Dr.rm)return Dr.rm(t,{recursive:!0,force:!0},e);$n(t,e)}),removeSync:function(t){if(Dr.rmSync)return Dr.rmSync(t,{recursive:!0,force:!0});$n.sync(t)}};const An=Tr(async function(t){let e;try{e=await Br.readdir(t)}catch{return Yr.mkdirs(t)}return Promise.all(e.map(e=>jn.remove(y.default.join(t,e))))});function Pn(t){let e;try{e=Br.readdirSync(t)}catch{return Yr.mkdirsSync(t)}e.forEach(e=>{e=y.default.join(t,e),jn.removeSync(e)})}var Tn={emptyDirSync:Pn,emptydirSync:Pn,emptyDir:An,emptydir:An},In={createFile:Pr(function(t,e){function i(){Dr.writeFile(t,"",t=>{if(t)return e(t);e()})}Dr.stat(t,(r,n)=>{if(!r&&n.isFile())return e();const s=y.default.dirname(t);Dr.stat(s,(t,r)=>{if(t)return"ENOENT"===t.code?Yr.mkdirs(s,t=>{if(t)return e(t);i()}):e(t);r.isDirectory()?i():Dr.readdir(s,t=>{if(t)return e(t)})})})}),createFileSync:function(t){let e;try{e=Dr.statSync(t)}catch{}if(e&&e.isFile())return;const i=y.default.dirname(t);try{Dr.statSync(i).isDirectory()||Dr.readdirSync(i)}catch(t){if(!t||"ENOENT"!==t.code)throw t;Yr.mkdirsSync(i)}Dr.writeFileSync(t,"")}};const Nn=Pr,Fn=an.pathExists,{areIdentical:Rn}=Qr;var Ln={createLink:Nn(function(t,e,i){function r(t,e){Dr.link(t,e,t=>{if(t)return i(t);i(null)})}Dr.lstat(e,(n,s)=>{Dr.lstat(t,(n,o)=>{if(n)return n.message=n.message.replace("lstat","ensureLink"),i(n);if(s&&Rn(o,s))return i(null);const a=y.default.dirname(e);Fn(a,(n,s)=>n?i(n):s?r(t,e):void Yr.mkdirs(a,n=>{if(n)return i(n);r(t,e)}))})})}),createLinkSync:function(t,e){let i;try{i=Dr.lstatSync(e)}catch{}try{const e=Dr.lstatSync(t);if(i&&Rn(e,i))return}catch(t){throw t.message=t.message.replace("lstat","ensureLink"),t}const r=y.default.dirname(e);return Dr.existsSync(r)||Yr.mkdirsSync(r),Dr.linkSync(t,e)}};const Dn=an.pathExists,Bn=Pr,Mn=Yr.mkdirs,Gn=Yr.mkdirsSync,Hn=an.pathExists,{areIdentical:Un}=Qr;function qn(t,e,i,r){!function(t,e,i){if(y.default.isAbsolute(t))return Dr.lstat(t,e=>e?(e.message=e.message.replace("lstat","ensureSymlink"),i(e)):i(null,{toCwd:t,toDst:t}));{const r=y.default.dirname(e),n=y.default.join(r,t);Dn(n,(e,s)=>e?i(e):s?i(null,{toCwd:n,toDst:t}):Dr.lstat(t,e=>e?(e.message=e.message.replace("lstat","ensureSymlink"),i(e)):i(null,{toCwd:t,toDst:y.default.relative(r,t)})))}}(t,e,(n,s)=>{if(n)return r(n);t=s.toDst,function(t,e,i){if(i="function"==typeof e?e:i,e="function"!=typeof e&&e)return i(null,e);Dr.lstat(t,(t,r)=>{if(t)return i(null,"file");e=r&&r.isDirectory()?"dir":"file",i(null,e)})}(s.toCwd,i,(i,n)=>{if(i)return r(i);const s=y.default.dirname(e);Hn(s,(i,o)=>i?r(i):o?Br.symlink(t,e,n,r):void Mn(s,i=>{if(i)return r(i);Br.symlink(t,e,n,r)}))})})}var Vn={createSymlink:Bn(function(t,e,i,r){r="function"==typeof i?i:r,i="function"!=typeof i&&i,Br.lstat(e,(n,s)=>{!n&&s.isSymbolicLink()?Promise.all([Br.stat(t),Br.stat(e)]).then(([n,s])=>{if(Un(n,s))return r(null);qn(t,e,i,r)}):qn(t,e,i,r)})}),createSymlinkSync:function(t,e,i){let r;try{r=Br.lstatSync(e)}catch{}if(r&&r.isSymbolicLink()){const i=Br.statSync(t),r=Br.statSync(e);if(Un(i,r))return}const n=function(t,e){let i;if(y.default.isAbsolute(t)){if(i=Dr.existsSync(t),!i)throw new Error("absolute srcpath does not exist");return{toCwd:t,toDst:t}}{const r=y.default.dirname(e),n=y.default.join(r,t);if(i=Dr.existsSync(n),i)return{toCwd:n,toDst:t};if(i=Dr.existsSync(t),!i)throw new Error("relative srcpath does not exist");return{toCwd:t,toDst:y.default.relative(r,t)}}}(t,e);t=n.toDst,i=function(t,e){let i;if(e)return e;try{i=Dr.lstatSync(t)}catch{return"file"}return i&&i.isDirectory()?"dir":"file"}(n.toCwd,i);const s=y.default.dirname(e);return Br.existsSync(s)||Gn(s),Br.symlinkSync(t,e,i)}},Wn={createFile:In.createFile,createFileSync:In.createFileSync,ensureFile:In.createFile,ensureFileSync:In.createFileSync,createLink:Ln.createLink,createLinkSync:Ln.createLinkSync,ensureLink:Ln.createLink,ensureLinkSync:Ln.createLinkSync,createSymlink:Vn.createSymlink,createSymlinkSync:Vn.createSymlinkSync,ensureSymlink:Vn.createSymlink,ensureSymlinkSync:Vn.createSymlinkSync},zn=process.cwd,Yn=null,Kn=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Yn||(Yn=zn.call(process)),Yn};try{process.cwd()}catch(t){}var Jn=process.chdir;process.chdir=function(t){Yn=null,Jn.call(process,t)};var Xn=O.default.Stream,Zn=N(function(t){var e,i;"function"==typeof Symbol&&"function"==typeof Symbol.for?(e=Symbol.for("graceful-fs.queue"),i=Symbol.for("graceful-fs.previous")):(e="___graceful-fs.queue",i="___graceful-fs.previous");var r=function(){};if(C.default.debuglog?r=C.default.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(r=function(){var t=C.default.format.apply(C.default,arguments);t="GFS4: "+t.split(/\n/).join("\nGFS4: "),console.error(t)}),!I[e]){var n=[];Object.defineProperty(I,e,{get:function(){return n}}),v.default.close=function(t){function e(e,i){return t.call(v.default,e,function(t){t||a(),"function"==typeof i&&i.apply(this,arguments)})}return Object.defineProperty(e,i,{value:t}),e}(v.default.close),v.default.closeSync=function(t){function e(e){t.apply(v.default,arguments),a()}return Object.defineProperty(e,i,{value:t}),e}(v.default.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){r(I[e]),S.default.equal(I[e].length,0)})}function s(t){(function(t){var e,i;function r(e){return e?function(i,r,n){return e.call(t,i,r,function(t){c(t)&&(t=null),n&&n.apply(this,arguments)})}:e}function n(e){return e?function(i,r){try{return e.call(t,i,r)}catch(t){if(!c(t))throw t}}:e}function s(e){return e?function(i,r,n,s){return e.call(t,i,r,n,function(t){c(t)&&(t=null),s&&s.apply(this,arguments)})}:e}function o(e){return e?function(i,r,n){try{return e.call(t,i,r,n)}catch(t){if(!c(t))throw t}}:e}function a(e){return e?function(i,r,n){function s(t,e){e&&(e.uid<0&&(e.uid+=4294967296),e.gid<0&&(e.gid+=4294967296)),n&&n.apply(this,arguments)}return"function"==typeof r&&(n=r,r=null),r?e.call(t,i,r,s):e.call(t,i,s)}:e}function l(e){return e?function(i,r){var n=r?e.call(t,i,r):e.call(t,i);return n.uid<0&&(n.uid+=4294967296),n.gid<0&&(n.gid+=4294967296),n}:e}function c(t){return!t||"ENOSYS"===t.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==t.code&&"EPERM"!==t.code)}k.default.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(t){t.lchmod=function(e,i,r){t.open(e,k.default.O_WRONLY|k.default.O_SYMLINK,i,function(e,n){e?r&&r(e):t.fchmod(n,i,function(e){t.close(n,function(t){r&&r(e||t)})})})},t.lchmodSync=function(e,i){var r,n=t.openSync(e,k.default.O_WRONLY|k.default.O_SYMLINK,i),s=!0;try{r=t.fchmodSync(n,i),s=!1}finally{if(s)try{t.closeSync(n)}catch(t){}else t.closeSync(n)}return r}}(t),t.lutimes||function(t){k.default.hasOwnProperty("O_SYMLINK")?(t.lutimes=function(e,i,r,n){t.open(e,k.default.O_SYMLINK,function(e,s){e?n&&n(e):t.futimes(s,i,r,function(e){t.close(s,function(t){n&&n(e||t)})})})},t.lutimesSync=function(e,i,r){var n,s=t.openSync(e,k.default.O_SYMLINK),o=!0;try{n=t.futimesSync(s,i,r),o=!1}finally{if(o)try{t.closeSync(s)}catch(t){}else t.closeSync(s)}return n}):(t.lutimes=function(t,e,i,r){r&&process.nextTick(r)},t.lutimesSync=function(){})}(t),t.chown=s(t.chown),t.fchown=s(t.fchown),t.lchown=s(t.lchown),t.chmod=r(t.chmod),t.fchmod=r(t.fchmod),t.lchmod=r(t.lchmod),t.chownSync=o(t.chownSync),t.fchownSync=o(t.fchownSync),t.lchownSync=o(t.lchownSync),t.chmodSync=n(t.chmodSync),t.fchmodSync=n(t.fchmodSync),t.lchmodSync=n(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=l(t.statSync),t.fstatSync=l(t.fstatSync),t.lstatSync=l(t.lstatSync),t.lchmod||(t.lchmod=function(t,e,i){i&&process.nextTick(i)},t.lchmodSync=function(){}),t.lchown||(t.lchown=function(t,e,i,r){r&&process.nextTick(r)},t.lchownSync=function(){}),"win32"===Kn&&(t.rename=(e=t.rename,function(i,r,n){var s=Date.now(),o=0;e(i,r,function a(l){if(l&&("EACCES"===l.code||"EPERM"===l.code)&&Date.now()-s<6e4)return setTimeout(function(){t.stat(r,function(t,s){t&&"ENOENT"===t.code?e(i,r,a):n(l)})},o),void(o<100&&(o+=10));n&&n(l)})})),t.read=function(e){function i(i,r,n,s,o,a){var l;if(a&&"function"==typeof a){var c=0;l=function(u,h,d){if(u&&"EAGAIN"===u.code&&c<10)return c++,e.call(t,i,r,n,s,o,l);a.apply(this,arguments)}}return e.call(t,i,r,n,s,o,l)}return i.__proto__=e,i}(t.read),t.readSync=(i=t.readSync,function(e,r,n,s,o){for(var a=0;;)try{return i.call(t,e,r,n,s,o)}catch(t){if("EAGAIN"===t.code&&a<10){a++;continue}throw t}})})(t),t.gracefulify=s,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,r){return"function"==typeof i&&(r=i,i=null),function t(i,r,n){return e(i,r,function(e){!e||"EMFILE"!==e.code&&"ENFILE"!==e.code?("function"==typeof n&&n.apply(this,arguments),a()):o([t,[i,r,n]])})}(t,i,r)};var i=t.writeFile;t.writeFile=function(t,e,r,n){return"function"==typeof r&&(n=r,r=null),function t(e,r,n,s){return i(e,r,n,function(i){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?("function"==typeof s&&s.apply(this,arguments),a()):o([t,[e,r,n,s]])})}(t,e,r,n)};var r=t.appendFile;r&&(t.appendFile=function(t,e,i,n){return"function"==typeof i&&(n=i,i=null),function t(e,i,n,s){return r(e,i,n,function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?("function"==typeof s&&s.apply(this,arguments),a()):o([t,[e,i,n,s]])})}(t,e,i,n)});var n=t.readdir;function l(e){return n.apply(t,e)}if(t.readdir=function(t,e,i){var r=[t];return"function"!=typeof e?r.push(e):i=e,r.push(function(t,e){e&&e.sort&&e.sort(),!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?("function"==typeof i&&i.apply(this,arguments),a()):o([l,[r]])}),l(r)},"v0.8"===process.version.substr(0,4)){var c=function(t){return{ReadStream:function e(i,r){if(!(this instanceof e))return new e(i,r);Xn.call(this);var n=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,r=r||{};for(var s=Object.keys(r),o=0,a=s.length;o<a;o++){var l=s[o];this[l]=r[l]}if(this.encoding&&this.setEncoding(this.encoding),void 0!==this.start){if("number"!=typeof this.start)throw TypeError("start must be a Number");if(void 0===this.end)this.end=Infinity;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}null===this.fd?t.open(this.path,this.flags,this.mode,function(t,e){if(t)return n.emit("error",t),void(n.readable=!1);n.fd=e,n.emit("open",e),n._read()}):process.nextTick(function(){n._read()})},WriteStream:function e(i,r){if(!(this instanceof e))return new e(i,r);Xn.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var n=Object.keys(r),s=0,o=n.length;s<o;s++){var a=n[s];this[a]=r[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())}}}(t);f=c.ReadStream,m=c.WriteStream}var u=t.ReadStream;u&&(f.prototype=Object.create(u.prototype),f.prototype.open=function(){var t=this;y(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 h=t.WriteStream;h&&(m.prototype=Object.create(h.prototype),m.prototype.open=function(){var t=this;y(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 f},set:function(t){f=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return m},set:function(t){m=t},enumerable:!0,configurable:!0});var d=f;Object.defineProperty(t,"FileReadStream",{get:function(){return d},set:function(t){d=t},enumerable:!0,configurable:!0});var p=m;function f(t,e){return this instanceof f?(u.apply(this,arguments),this):f.apply(Object.create(f.prototype),arguments)}function m(t,e){return this instanceof m?(h.apply(this,arguments),this):m.apply(Object.create(m.prototype),arguments)}Object.defineProperty(t,"FileWriteStream",{get:function(){return p},set:function(t){p=t},enumerable:!0,configurable:!0});var g=t.open;function y(t,e,i,r){return"function"==typeof i&&(r=i,i=null),function t(e,i,r,n){return g(e,i,r,function(s,l){!s||"EMFILE"!==s.code&&"ENFILE"!==s.code?("function"==typeof n&&n.apply(this,arguments),a()):o([t,[e,i,r,n]])})}(t,e,i,r)}return t.open=y,t}function o(t){r("ENQUEUE",t[0].name,t[1]),I[e].push(t)}function a(){var t=I[e].shift();t&&(r("RETRY",t[0].name,t[1]),t[0].apply(null,t[1]))}t.exports=s(function(t){if(null===t||"object"!=typeof t)return t;if(t instanceof Object)var e={__proto__:t.__proto__};else e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}(v.default)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!v.default.__patched&&(t.exports=s(v.default),v.default.__patched=!0)}),Qn={stringify:function(t,{EOL:e="\n",finalEOL:i=!0,replacer:r=null,spaces:n}={}){const s=i?e:"";return JSON.stringify(t,r,n).replace(/\n/g,e)+s},stripBom:function(t){return Buffer.isBuffer(t)&&(t=t.toString("utf8")),t.replace(/^\uFEFF/,"")}};let ts;try{ts=Zn}catch(t){ts=v.default}const{stringify:es,stripBom:is}=Qn,rs={readFile:Tr(async function(t,e={}){"string"==typeof e&&(e={encoding:e});const i=e.fs||ts,r=!("throws"in e)||e.throws;let n,s=await Pr(i.readFile)(t,e);s=is(s);try{n=JSON.parse(s,e?e.reviver:null)}catch(e){if(r)throw e.message=`${t}: ${e.message}`,e;return null}return n}),readFileSync:function(t,e={}){"string"==typeof e&&(e={encoding:e});const i=e.fs||ts,r=!("throws"in e)||e.throws;try{let r=i.readFileSync(t,e);return r=is(r),JSON.parse(r,e.reviver)}catch(e){if(r)throw e.message=`${t}: ${e.message}`,e;return null}},writeFile:Tr(async function(t,e,i={}){const r=i.fs||ts,n=es(e,i);await Pr(r.writeFile)(t,n,i)}),writeFileSync:function(t,e,i={}){const r=i.fs||ts,n=es(e,i);return r.writeFileSync(t,n,i)}};var ns={readJson:rs.readFile,readJsonSync:rs.readFileSync,writeJson:rs.writeFile,writeJsonSync:rs.writeFileSync};const ss=an.pathExists;var os={outputFile:Pr(function(t,e,i,r){"function"==typeof i&&(r=i,i="utf8");const n=y.default.dirname(t);ss(n,(s,o)=>s?r(s):o?Dr.writeFile(t,e,i,r):void Yr.mkdirs(n,n=>{if(n)return r(n);Dr.writeFile(t,e,i,r)}))}),outputFileSync:function(t,...e){const i=y.default.dirname(t);if(Dr.existsSync(i))return Dr.writeFileSync(t,...e);Yr.mkdirsSync(i),Dr.writeFileSync(t,...e)}};const{stringify:as}=Qn,{outputFile:ls}=os,{stringify:cs}=Qn,{outputFileSync:us}=os;ns.outputJson=Tr(async function(t,e,i={}){const r=as(e,i);await ls(t,r,i)}),ns.outputJsonSync=function(t,e,i){const r=cs(e,i);us(t,r,i)},ns.outputJSON=ns.outputJson,ns.outputJSONSync=ns.outputJsonSync,ns.writeJSON=ns.writeJson,ns.writeJSONSync=ns.writeJsonSync,ns.readJSON=ns.readJson,ns.readJSONSync=ns.readJsonSync;var hs=ns;const ds=on.copySync,ps=jn.removeSync,fs=Yr.mkdirpSync;function ms(t,e,i){try{Dr.renameSync(t,e)}catch(r){if("EXDEV"!==r.code)throw r;return function(t,e,i){return ds(t,e,{overwrite:i,errorOnExist:!0}),ps(t)}(t,e,i)}}var gs={moveSync:function(t,e,i){const r=(i=i||{}).overwrite||i.clobber||!1,{srcStat:n,isChangingCase:s=!1}=Qr.checkPathsSync(t,e,"move",i);return Qr.checkParentPathsSync(t,n,e,"move"),function(t){const e=y.default.dirname(t);return y.default.parse(e).root===e}(e)||fs(y.default.dirname(e)),function(t,e,i,r){if(r)return ms(t,e,i);if(i)return ps(e),ms(t,e,i);if(Dr.existsSync(e))throw new Error("dest already exists.");return ms(t,e,i)}(t,e,r,s)}};const ys=bn.copy,bs=jn.remove,ws=Yr.mkdirp,vs=an.pathExists;function Ss(t,e,i,r,n){return r?Es(t,e,i,n):i?bs(e,r=>r?n(r):Es(t,e,i,n)):void vs(e,(r,s)=>r?n(r):s?n(new Error("dest already exists.")):Es(t,e,i,n))}function Es(t,e,i,r){Dr.rename(t,e,n=>n?"EXDEV"!==n.code?r(n):function(t,e,i,r){ys(t,e,{overwrite:i,errorOnExist:!0},e=>e?r(e):bs(t,r))}(t,e,i,r):r())}var xs={move:Pr(function(t,e,i,r){"function"==typeof i&&(r=i,i={});const n=i.overwrite||i.clobber||!1;Qr.checkPaths(t,e,"move",i,(i,s)=>{if(i)return r(i);const{srcStat:o,isChangingCase:a=!1}=s;Qr.checkParentPaths(t,o,e,"move",i=>i?r(i):function(t){const e=y.default.dirname(t);return y.default.parse(e).root===e}(e)?Ss(t,e,n,a,r):void ws(y.default.dirname(e),i=>i?r(i):Ss(t,e,n,a,r)))})})},_s={...Br,...on,...bn,...Tn,...Wn,...hs,...Yr,...gs,...xs,...os,...an,...jn};const Os=(...t)=>t.every(t=>t)?t.join(""):"",Cs=t=>t?encodeURIComponent(t):"",ks={sshtemplate:({domain:t,user:e,project:i,committish:r})=>`git@${t}:${e}/${i}.git${Os("#",r)}`,sshurltemplate:({domain:t,user:e,project:i,committish:r})=>`git+ssh://git@${t}/${e}/${i}.git${Os("#",r)}`,browsetemplate:({domain:t,user:e,project:i,committish:r,treepath:n})=>`https://${t}/${e}/${i}${Os("/",n,"/",Cs(r))}`,browsefiletemplate:({domain:t,user:e,project:i,committish:r,treepath:n,path:s,fragment:o,hashformat:a})=>`https://${t}/${e}/${i}/${n}/${Cs(r||"master")}/${s}${Os("#",a(o||""))}`,docstemplate:({domain:t,user:e,project:i,treepath:r,committish:n})=>`https://${t}/${e}/${i}${Os("/",r,"/",Cs(n))}#readme`,httpstemplate:({auth:t,domain:e,user:i,project:r,committish:n})=>`git+https://${Os(t,"@")}${e}/${i}/${r}.git${Os("#",n)}`,filetemplate:({domain:t,user:e,project:i,committish:r,path:n})=>`https://${t}/${e}/${i}/raw/${Cs(r)||"master"}/${n}`,shortcuttemplate:({type:t,user:e,project:i,committish:r})=>`${t}:${e}/${i}${Os("#",r)}`,pathtemplate:({user:t,project:e,committish:i})=>`${t}/${e}${Os("#",i)}`,bugstemplate:({domain:t,user:e,project:i})=>`https://${t}/${e}/${i}/issues`,hashformat:As},$s={};$s.github=Object.assign({},ks,{protocols:["git:","http:","git+ssh:","git+https:","ssh:","https:"],domain:"github.com",treepath:"tree",filetemplate:({auth:t,user:e,project:i,committish:r,path:n})=>`https://${Os(t,"@")}raw.githubusercontent.com/${e}/${i}/${Cs(r)||"master"}/${n}`,gittemplate:({auth:t,domain:e,user:i,project:r,committish:n})=>`git://${Os(t,"@")}${e}/${i}/${r}.git${Os("#",n)}`,tarballtemplate:({domain:t,user:e,project:i,committish:r})=>`https://codeload.${t}/${e}/${i}/tar.gz/${Cs(r)||"master"}`,extract:t=>{let[,e,i,r,n]=t.pathname.split("/",5);if((!r||"tree"===r)&&(r||(n=t.hash.slice(1)),i&&i.endsWith(".git")&&(i=i.slice(0,-4)),e&&i))return{user:e,project:i,committish:n}}}),$s.bitbucket=Object.assign({},ks,{protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"bitbucket.org",treepath:"src",tarballtemplate:({domain:t,user:e,project:i,committish:r})=>`https://${t}/${e}/${i}/get/${Cs(r)||"master"}.tar.gz`,extract:t=>{let[,e,i,r]=t.pathname.split("/",4);if(!["get"].includes(r)&&(i&&i.endsWith(".git")&&(i=i.slice(0,-4)),e&&i))return{user:e,project:i,committish:t.hash.slice(1)}}}),$s.gitlab=Object.assign({},ks,{protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"gitlab.com",treepath:"tree",httpstemplate:({auth:t,domain:e,user:i,project:r,committish:n})=>`git+https://${Os(t,"@")}${e}/${i}/${r}.git${Os("#",n)}`,tarballtemplate:({domain:t,user:e,project:i,committish:r})=>`https://${t}/${e}/${i}/repository/archive.tar.gz?ref=${Cs(r)||"master"}`,extract:t=>{const e=t.pathname.slice(1);if(e.includes("/-/")||e.includes("/archive.tar.gz"))return;const i=e.split("/");let r=i.pop();r.endsWith(".git")&&(r=r.slice(0,-4));const n=i.join("/");return n&&r?{user:n,project:r,committish:t.hash.slice(1)}:void 0}}),$s.gist=Object.assign({},ks,{protocols:["git:","git+ssh:","git+https:","ssh:","https:"],domain:"gist.github.com",sshtemplate:({domain:t,project:e,committish:i})=>`git@${t}:${e}.git${Os("#",i)}`,sshurltemplate:({domain:t,project:e,committish:i})=>`git+ssh://git@${t}/${e}.git${Os("#",i)}`,browsetemplate:({domain:t,project:e,committish:i})=>`https://${t}/${e}${Os("/",Cs(i))}`,browsefiletemplate:({domain:t,project:e,committish:i,path:r,hashformat:n})=>`https://${t}/${e}${Os("/",Cs(i))}${Os("#",n(r))}`,docstemplate:({domain:t,project:e,committish:i})=>`https://${t}/${e}${Os("/",Cs(i))}`,httpstemplate:({domain:t,project:e,committish:i})=>`git+https://${t}/${e}.git${Os("#",i)}`,filetemplate:({user:t,project:e,committish:i,path:r})=>`https://gist.githubusercontent.com/${t}/${e}/raw${Os("/",Cs(i))}/${r}`,shortcuttemplate:({type:t,project:e,committish:i})=>`${t}:${e}${Os("#",i)}`,pathtemplate:({project:t,committish:e})=>`${t}${Os("#",e)}`,bugstemplate:({domain:t,project:e})=>`https://${t}/${e}`,gittemplate:({domain:t,project:e,committish:i})=>`git://${t}/${e}.git${Os("#",i)}`,tarballtemplate:({project:t,committish:e})=>`https://codeload.github.com/gist/${t}/tar.gz/${Cs(e)||"master"}`,extract:t=>{let[,e,i,r]=t.pathname.split("/",4);if("raw"!==r){if(!i){if(!e)return;i=e,e=null}return i.endsWith(".git")&&(i=i.slice(0,-4)),{user:e,project:i,committish:t.hash.slice(1)}}},hashformat:function(t){return t&&"file-"+As(t)}}),$s.sourcehut=Object.assign({},ks,{protocols:["git+ssh:","https:"],domain:"git.sr.ht",treepath:"tree",browsefiletemplate:({domain:t,user:e,project:i,committish:r,treepath:n,path:s,fragment:o,hashformat:a})=>`https://${t}/${e}/${i}/${n}/${Cs(r||"main")}/${s}${Os("#",a(o||""))}`,filetemplate:({domain:t,user:e,project:i,committish:r,path:n})=>`https://${t}/${e}/${i}/blob/${Cs(r)||"main"}/${n}`,httpstemplate:({domain:t,user:e,project:i,committish:r})=>`https://${t}/${e}/${i}.git${Os("#",r)}`,tarballtemplate:({domain:t,user:e,project:i,committish:r})=>`https://${t}/${e}/${i}/archive/${Cs(r)||"main"}.tar.gz`,bugstemplate:({user:t,project:e})=>`https://todo.sr.ht/${t}/${e}`,docstemplate:({domain:t,user:e,project:i,treepath:r,committish:n})=>`https://${t}/${e}/${i}${Os("/",r,"/",Cs(n))}#readme`,extract:t=>{let[,e,i,r]=t.pathname.split("/",4);if(!["archive"].includes(r)&&(i&&i.endsWith(".git")&&(i=i.slice(0,-4)),e&&i))return{user:e,project:i,committish:t.hash.slice(1)}}});const js=Object.keys($s);$s.byShortcut={},$s.byDomain={};for(const t of js)$s.byShortcut[`${t}:`]=t,$s.byDomain[$s[t].domain]=t;function As(t){return t.toLowerCase().replace(/^\W+|\/|\W+$/g,"").replace(/\W+/g,"-")}var Ps=$s,Ts=Is;function Is(t){var e=this;if(e instanceof Is||(e=new Is),e.tail=null,e.head=null,e.length=0,t&&"function"==typeof t.forEach)t.forEach(function(t){e.push(t)});else if(arguments.length>0)for(var i=0,r=arguments.length;i<r;i++)e.push(arguments[i]);return e}function Ns(t,e,i){var r=e===t.head?new Ls(i,null,e,t):new Ls(i,e,e.next,t);return null===r.next&&(t.tail=r),null===r.prev&&(t.head=r),t.length++,r}function Fs(t,e){t.tail=new Ls(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function Rs(t,e){t.head=new Ls(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++}function Ls(t,e,i,r){if(!(this instanceof Ls))return new Ls(t,e,i,r);this.list=r,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,i?(i.prev=this,this.next=i):this.next=null}Is.Node=Ls,Is.create=Is,Is.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,i=t.prev;return e&&(e.prev=i),i&&(i.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=i),t.list.length--,t.next=null,t.prev=null,t.list=null,e},Is.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}},Is.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}},Is.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)Fs(this,arguments[t]);return this.length},Is.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)Rs(this,arguments[t]);return this.length},Is.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}},Is.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}},Is.prototype.forEach=function(t,e){e=e||this;for(var i=this.head,r=0;null!==i;r++)t.call(e,i.value,r,this),i=i.next},Is.prototype.forEachReverse=function(t,e){e=e||this;for(var i=this.tail,r=this.length-1;null!==i;r--)t.call(e,i.value,r,this),i=i.prev},Is.prototype.get=function(t){for(var e=0,i=this.head;null!==i&&e<t;e++)i=i.next;if(e===t&&null!==i)return i.value},Is.prototype.getReverse=function(t){for(var e=0,i=this.tail;null!==i&&e<t;e++)i=i.prev;if(e===t&&null!==i)return i.value},Is.prototype.map=function(t,e){e=e||this;for(var i=new Is,r=this.head;null!==r;)i.push(t.call(e,r.value,this)),r=r.next;return i},Is.prototype.mapReverse=function(t,e){e=e||this;for(var i=new Is,r=this.tail;null!==r;)i.push(t.call(e,r.value,this)),r=r.prev;return i},Is.prototype.reduce=function(t,e){var i,r=this.head;if(arguments.length>1)i=e;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");r=this.head.next,i=this.head.value}for(var n=0;null!==r;n++)i=t(i,r.value,n),r=r.next;return i},Is.prototype.reduceReverse=function(t,e){var i,r=this.tail;if(arguments.length>1)i=e;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");r=this.tail.prev,i=this.tail.value}for(var n=this.length-1;null!==r;n--)i=t(i,r.value,n),r=r.prev;return i},Is.prototype.toArray=function(){for(var t=new Array(this.length),e=0,i=this.head;null!==i;e++)t[e]=i.value,i=i.next;return t},Is.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,i=this.tail;null!==i;e++)t[e]=i.value,i=i.prev;return t},Is.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var i=new Is;if(e<t||e<0)return i;t<0&&(t=0),e>this.length&&(e=this.length);for(var r=0,n=this.head;null!==n&&r<t;r++)n=n.next;for(;null!==n&&r<e;r++,n=n.next)i.push(n.value);return i},Is.prototype.sliceReverse=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var i=new Is;if(e<t||e<0)return i;t<0&&(t=0),e>this.length&&(e=this.length);for(var r=this.length,n=this.tail;null!==n&&r>e;r--)n=n.prev;for(;null!==n&&r>t;r--,n=n.prev)i.push(n.value);return i},Is.prototype.splice=function(t,e,...i){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var r=0,n=this.head;null!==n&&r<t;r++)n=n.next;var s=[];for(r=0;n&&r<e;r++)s.push(n.value),n=this.removeNode(n);for(null===n&&(n=this.tail),n!==this.head&&n!==this.tail&&(n=n.prev),r=0;r<i.length;r++)n=Ns(this,n,i[r]);return s},Is.prototype.reverse=function(){for(var t=this.head,e=this.tail,i=t;null!==i;i=i.prev){var r=i.prev;i.prev=i.next,i.next=r}return this.head=e,this.tail=t,this};try{!function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}(Is)}catch(t){}const Ds=Symbol("max"),Bs=Symbol("length"),Ms=Symbol("lengthCalculator"),Gs=Symbol("allowStale"),Hs=Symbol("maxAge"),Us=Symbol("dispose"),qs=Symbol("noDisposeOnSet"),Vs=Symbol("lruList"),Ws=Symbol("cache"),zs=Symbol("updateAgeOnGet"),Ys=()=>1,Ks=(t,e,i)=>{const r=t[Ws].get(e);if(r){const e=r.value;if(Js(t,e)){if(Zs(t,r),!t[Gs])return}else i&&(t[zs]&&(r.value.now=Date.now()),t[Vs].unshiftNode(r));return e.value}},Js=(t,e)=>{if(!e||!e.maxAge&&!t[Hs])return!1;const i=Date.now()-e.now;return e.maxAge?i>e.maxAge:t[Hs]&&i>t[Hs]},Xs=t=>{if(t[Bs]>t[Ds])for(let e=t[Vs].tail;t[Bs]>t[Ds]&&null!==e;){const i=e.prev;Zs(t,e),e=i}},Zs=(t,e)=>{if(e){const i=e.value;t[Us]&&t[Us](i.key,i.value),t[Bs]-=i.length,t[Ws].delete(i.key),t[Vs].removeNode(e)}};class Qs{constructor(t,e,i,r,n){this.key=t,this.value=e,this.length=i,this.now=r,this.maxAge=n||0}}const to=(t,e,i,r)=>{let n=i.value;Js(t,n)&&(Zs(t,i),t[Gs]||(n=void 0)),n&&e.call(r,n.value,n.key,t)};var eo=N(function(t){const e=t.exports=class{constructor(t,e,i,r,n,s,o={}){Object.assign(this,Ps[t]),this.type=t,this.user=e,this.auth=i,this.project=r,this.committish=n,this.default=s,this.opts=o}hash(){return this.committish?`#${this.committish}`:""}ssh(t){return this._fill(this.sshtemplate,t)}_fill(t,e){if("function"==typeof t){const i={...this,...this.opts,...e};i.path||(i.path=""),i.path.startsWith("/")&&(i.path=i.path.slice(1)),i.noCommittish&&(i.committish=null);const r=t(i);return i.noGitPlus&&r.startsWith("git+")?r.slice(4):r}return null}sshurl(t){return this._fill(this.sshurltemplate,t)}browse(t,e,i){return"string"!=typeof t?this._fill(this.browsetemplate,t):("string"!=typeof e&&(i=e,e=null),this._fill(this.browsefiletemplate,{...i,fragment:e,path:t}))}docs(t){return this._fill(this.docstemplate,t)}bugs(t){return this._fill(this.bugstemplate,t)}https(t){return this._fill(this.httpstemplate,t)}git(t){return this._fill(this.gittemplate,t)}shortcut(t){return this._fill(this.shortcuttemplate,t)}path(t){return this._fill(this.pathtemplate,t)}tarball(t){return this._fill(this.tarballtemplate,{...t,noCommittish:!1})}file(t,e){return this._fill(this.filetemplate,{...e,path:t})}getDefaultRepresentation(){return this.default}toString(t){return this.default&&"function"==typeof this[this.default]?this[this.default](t):this.sshurl(t)}},i=new class{constructor(t){if("number"==typeof t&&(t={max:t}),t||(t={}),t.max&&("number"!=typeof t.max||t.max<0))throw new TypeError("max must be a non-negative number");this[Ds]=t.max||Infinity;const e=t.length||Ys;if(this[Ms]="function"!=typeof e?Ys:e,this[Gs]=t.stale||!1,t.maxAge&&"number"!=typeof t.maxAge)throw new TypeError("maxAge must be a number");this[Hs]=t.maxAge||0,this[Us]=t.dispose,this[qs]=t.noDisposeOnSet||!1,this[zs]=t.updateAgeOnGet||!1,this.reset()}set max(t){if("number"!=typeof t||t<0)throw new TypeError("max must be a non-negative number");this[Ds]=t||Infinity,Xs(this)}get max(){return this[Ds]}set allowStale(t){this[Gs]=!!t}get allowStale(){return this[Gs]}set maxAge(t){if("number"!=typeof t)throw new TypeError("maxAge must be a non-negative number");this[Hs]=t,Xs(this)}get maxAge(){return this[Hs]}set lengthCalculator(t){"function"!=typeof t&&(t=Ys),t!==this[Ms]&&(this[Ms]=t,this[Bs]=0,this[Vs].forEach(t=>{t.length=this[Ms](t.value,t.key),this[Bs]+=t.length})),Xs(this)}get lengthCalculator(){return this[Ms]}get length(){return this[Bs]}get itemCount(){return this[Vs].length}rforEach(t,e){e=e||this;for(let i=this[Vs].tail;null!==i;){const r=i.prev;to(this,t,i,e),i=r}}forEach(t,e){e=e||this;for(let i=this[Vs].head;null!==i;){const r=i.next;to(this,t,i,e),i=r}}keys(){return this[Vs].toArray().map(t=>t.key)}values(){return this[Vs].toArray().map(t=>t.value)}reset(){this[Us]&&this[Vs]&&this[Vs].length&&this[Vs].forEach(t=>this[Us](t.key,t.value)),this[Ws]=new Map,this[Vs]=new Ts,this[Bs]=0}dump(){return this[Vs].map(t=>!Js(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)}).toArray().filter(t=>t)}dumpLru(){return this[Vs]}set(t,e,i){if((i=i||this[Hs])&&"number"!=typeof i)throw new TypeError("maxAge must be a number");const r=i?Date.now():0,n=this[Ms](e,t);if(this[Ws].has(t)){if(n>this[Ds])return Zs(this,this[Ws].get(t)),!1;const s=this[Ws].get(t).value;return this[Us]&&(this[qs]||this[Us](t,s.value)),s.now=r,s.maxAge=i,s.value=e,this[Bs]+=n-s.length,s.length=n,this.get(t),Xs(this),!0}const s=new Qs(t,e,n,r,i);return s.length>this[Ds]?(this[Us]&&this[Us](t,e),!1):(this[Bs]+=s.length,this[Vs].unshift(s),this[Ws].set(t,this[Vs].head),Xs(this),!0)}has(t){if(!this[Ws].has(t))return!1;const e=this[Ws].get(t).value;return!Js(this,e)}get(t){return Ks(this,t,!0)}peek(t){return Ks(this,t,!1)}pop(){const t=this[Vs].tail;return t?(Zs(this,t),t.value):null}del(t){Zs(this,this[Ws].get(t))}load(t){this.reset();const e=Date.now();for(let i=t.length-1;i>=0;i--){const r=t[i],n=r.e||0;if(0===n)this.set(r.k,r.v);else{const t=n-e;t>0&&this.set(r.k,r.v,t)}}}prune(){this[Ws].forEach((t,e)=>Ks(this,e,!1))}}({max:1e3}),r={"git+ssh:":"sshurl","git+https:":"https","ssh:":"sshurl","git:":"git"},n={"git:":!0,"https:":!0,"git+https:":!0,"http:":!0,"git+http:":!0},s=Object.keys(Ps.byShortcut).concat(["http:","https:","git:","git+ssh:","git+https:","ssh:"]);t.exports.fromUrl=function(t,s){if("string"!=typeof t)return;const c=t+JSON.stringify(s||{});return i.has(c)||i.set(c,function(t,i){if(!t)return;const s=a(t)?"github:"+t:o(t),c=l(s);if(!c)return c;const u=Ps.byShortcut[c.protocol],h=Ps.byDomain[c.hostname.startsWith("www.")?c.hostname.slice(4):c.hostname],d=u||h;if(!d)return;const p=Ps[u||h];let f=null;n[c.protocol]&&(c.username||c.password)&&(f=`${c.username}${c.password?":"+c.password:""}`);let m=null,g=null,y=null,b=null;try{if(u){let t=c.pathname.startsWith("/")?c.pathname.slice(1):c.pathname;const e=t.indexOf("@");e>-1&&(t=t.slice(e+1));const i=t.lastIndexOf("/");i>-1?(g=decodeURIComponent(t.slice(0,i)),g||(g=null),y=decodeURIComponent(t.slice(i+1))):y=decodeURIComponent(t),y.endsWith(".git")&&(y=y.slice(0,-4)),c.hash&&(m=decodeURIComponent(c.hash.slice(1))),b="shortcut"}else{if(!p.protocols.includes(c.protocol))return;const t=p.extract(c);if(!t)return;g=t.user&&decodeURIComponent(t.user),y=decodeURIComponent(t.project),m=decodeURIComponent(t.committish),b=r[w=c.protocol]||w.slice(0,-1)}}catch(t){if(t instanceof URIError)return;throw t}var w;return new e(d,g,f,y,m,b,i)}(t,s)),i.get(c)};const o=t=>{const e=t.indexOf(":"),i=t.slice(0,e+1);if(s.includes(i))return t;const r=t.indexOf("@");return r>-1?r>e?`git+ssh://${t}`:t:t.indexOf("//")===e+1?t:t.slice(0,e+1)+"//"+t.slice(e+1)},a=t=>{const e=t.indexOf("#"),i=t.indexOf("/"),r=t.indexOf("/",i+1),n=t.indexOf(":"),s=/\s/.exec(t),o=t.indexOf("@"),a=!s||e>-1&&s.index>e,l=-1===o||e>-1&&o>e,c=-1===n||e>-1&&n>e,u=-1===r||e>-1&&r>e,h=i>0,d=e>-1?"/"!==t[e-1]:!t.endsWith("/"),p=!t.startsWith(".");return a&&h&&d&&p&&l&&c&&u},l=t=>{let e;try{e=new $.default.URL(t)}catch(t){}if(e)return e;const i=(t=>{const e=t.indexOf("@"),i=t.lastIndexOf("#");let r,n=t.indexOf(":"),s=t.lastIndexOf(":",i>-1?i:Infinity);return s>e&&(r=t.slice(0,s)+"/"+t.slice(s+1),n=r.indexOf(":"),s=r.lastIndexOf(":")),-1===n&&-1===t.indexOf("//")&&(r=`git+ssh://${r}`),r})(t);try{e=new $.default.URL(i)}catch(t){}return e}}),io=/[‘“!#$%&+^<=>`]/,ro=N(function(t){const e="win32"===process.platform,i="linux"===process.platform,r={bullet:"•",check:"√",cross:"×",ellipsis:"...",heart:"❤",info:"i",line:"─",middot:"·",minus:"-",plus:"+",question:"?",questionSmall:"﹖",pointer:">",pointerSmall:"»",warning:"‼"},n={ballotCross:"✘",bullet:"•",check:"✔",cross:"✖",ellipsis:"…",heart:"❤",info:"ℹ",line:"─",middot:"·",minus:"-",plus:"+",question:"?",questionFull:"?",questionSmall:"﹖",pointer:i?"▸":"❯",pointerSmall:i?"‣":"›",warning:"⚠"};t.exports=e?r:n,Reflect.defineProperty(t.exports,"windows",{enumerable:!1,value:r}),Reflect.defineProperty(t.exports,"other",{enumerable:!1,value:n})});const no={enabled:!0,visible:!0,styles:{},keys:{}};"FORCE_COLOR"in process.env&&(no.enabled="0"!==process.env.FORCE_COLOR);const so=(t,e,i)=>{let{open:r,close:n,regex:s}=t;return e=r+(e.includes(n)?e.replace(s,n+r):e)+n,i?e.replace(/\r?\n/g,`${n}$&${r}`):e},oo=(t,e,i)=>{var r;no.styles[t]=((r={name:t,codes:e}).open=`[${r.codes[0]}m`,r.close=`[${r.codes[1]}m`,r.regex=new RegExp(`\\u001b\\[${r.codes[1]}m`,"g"),r),(no.keys[i]||(no.keys[i]=[])).push(t),Reflect.defineProperty(no,t,{get(){let e=t=>((t,e)=>{if(""===t||null==t)return"";if(!1===no.enabled)return t;if(!1===no.visible)return"";let i=""+t,r=i.includes("\n"),n=e.length;for(;n-- >0;)i=so(no.styles[e[n]],i,r);return i})(t,e.stack);return Reflect.setPrototypeOf(e,no),e.stack=this.stack?this.stack.concat(t):[t],e}})};oo("reset",[0,0],"modifier"),oo("bold",[1,22],"modifier"),oo("dim",[2,22],"modifier"),oo("italic",[3,23],"modifier"),oo("underline",[4,24],"modifier"),oo("inverse",[7,27],"modifier"),oo("hidden",[8,28],"modifier"),oo("strikethrough",[9,29],"modifier"),oo("black",[30,39],"color"),oo("red",[31,39],"color"),oo("green",[32,39],"color"),oo("yellow",[33,39],"color"),oo("blue",[34,39],"color"),oo("magenta",[35,39],"color"),oo("cyan",[36,39],"color"),oo("white",[37,39],"color"),oo("gray",[90,39],"color"),oo("grey",[90,39],"color"),oo("bgBlack",[40,49],"bg"),oo("bgRed",[41,49],"bg"),oo("bgGreen",[42,49],"bg"),oo("bgYellow",[43,49],"bg"),oo("bgBlue",[44,49],"bg"),oo("bgMagenta",[45,49],"bg"),oo("bgCyan",[46,49],"bg"),oo("bgWhite",[47,49],"bg"),oo("blackBright",[90,39],"bright"),oo("redBright",[91,39],"bright"),oo("greenBright",[92,39],"bright"),oo("yellowBright",[93,39],"bright"),oo("blueBright",[94,39],"bright"),oo("magentaBright",[95,39],"bright"),oo("cyanBright",[96,39],"bright"),oo("whiteBright",[97,39],"bright"),oo("bgBlackBright",[100,49],"bgBright"),oo("bgRedBright",[101,49],"bgBright"),oo("bgGreenBright",[102,49],"bgBright"),oo("bgYellowBright",[103,49],"bgBright"),oo("bgBlueBright",[104,49],"bgBright"),oo("bgMagentaBright",[105,49],"bgBright"),oo("bgCyanBright",[106,49],"bgBright"),oo("bgWhiteBright",[107,49],"bgBright");const ao=no.ansiRegex=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g;no.hasColor=no.hasAnsi=t=>(ao.lastIndex=0,!!t&&"string"==typeof t&&ao.test(t)),no.unstyle=t=>(ao.lastIndex=0,"string"==typeof t?t.replace(ao,""):t),no.none=no.clear=no.noop=t=>t,no.stripColor=no.unstyle,no.symbols=ro,no.define=oo;var lo=no;const co=t=>console.log(t),uo=t=>console.log(lo.green(lo.symbols.check+" ")+t),ho=t=>console.error(lo.red(lo.symbols.cross+" ")+t),po=t=>{const{message:e}=((t={})=>{const{id:e,context:i}=t;switch(e){case"10000":case"10001":return{message:`Looks like you provided a URL as your project name. Try "medusa new my-medusa-store ${i.rootPath}" instead.`};case"10002":return{message:`Could not create project because ${i.path} is not a valid path.`};case"10003":return{message:`Directory ${i.rootPath} is already a Node project.`};default:return{message:"Unknown error"}}})(t);console.error(e),process.exit(1)};var fo=process.cwd,mo=null,go=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return mo||(mo=fo.call(process)),mo};try{process.cwd()}catch(t){}if("function"==typeof process.chdir){var yo=process.chdir;process.chdir=function(t){mo=null,yo.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,yo)}var bo=O.default.Stream,wo=Object.getPrototypeOf||function(t){return t.__proto__},vo=N(function(t){var e,i;function r(t,i){Object.defineProperty(t,e,{get:function(){return i}})}"function"==typeof Symbol&&"function"==typeof Symbol.for?(e=Symbol.for("graceful-fs.queue"),i=Symbol.for("graceful-fs.previous")):(e="___graceful-fs.queue",i="___graceful-fs.previous");var n,s=function(){};function o(t){(function(t){var e,i;function r(e){return e?function(i,r,n){return e.call(t,i,r,function(t){c(t)&&(t=null),n&&n.apply(this,arguments)})}:e}function n(e){return e?function(i,r){try{return e.call(t,i,r)}catch(t){if(!c(t))throw t}}:e}function s(e){return e?function(i,r,n,s){return e.call(t,i,r,n,function(t){c(t)&&(t=null),s&&s.apply(this,arguments)})}:e}function o(e){return e?function(i,r,n){try{return e.call(t,i,r,n)}catch(t){if(!c(t))throw t}}:e}function a(e){return e?function(i,r,n){function s(t,e){e&&(e.uid<0&&(e.uid+=4294967296),e.gid<0&&(e.gid+=4294967296)),n&&n.apply(this,arguments)}return"function"==typeof r&&(n=r,r=null),r?e.call(t,i,r,s):e.call(t,i,s)}:e}function l(e){return e?function(i,r){var n=r?e.call(t,i,r):e.call(t,i);return n&&(n.uid<0&&(n.uid+=4294967296),n.gid<0&&(n.gid+=4294967296)),n}:e}function c(t){return!t||"ENOSYS"===t.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==t.code&&"EPERM"!==t.code)}k.default.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(t){t.lchmod=function(e,i,r){t.open(e,k.default.O_WRONLY|k.default.O_SYMLINK,i,function(e,n){e?r&&r(e):t.fchmod(n,i,function(e){t.close(n,function(t){r&&r(e||t)})})})},t.lchmodSync=function(e,i){var r,n=t.openSync(e,k.default.O_WRONLY|k.default.O_SYMLINK,i),s=!0;try{r=t.fchmodSync(n,i),s=!1}finally{if(s)try{t.closeSync(n)}catch(t){}else t.closeSync(n)}return r}}(t),t.lutimes||function(t){k.default.hasOwnProperty("O_SYMLINK")?(t.lutimes=function(e,i,r,n){t.open(e,k.default.O_SYMLINK,function(e,s){e?n&&n(e):t.futimes(s,i,r,function(e){t.close(s,function(t){n&&n(e||t)})})})},t.lutimesSync=function(e,i,r){var n,s=t.openSync(e,k.default.O_SYMLINK),o=!0;try{n=t.futimesSync(s,i,r),o=!1}finally{if(o)try{t.closeSync(s)}catch(t){}else t.closeSync(s)}return n}):(t.lutimes=function(t,e,i,r){r&&process.nextTick(r)},t.lutimesSync=function(){})}(t),t.chown=s(t.chown),t.fchown=s(t.fchown),t.lchown=s(t.lchown),t.chmod=r(t.chmod),t.fchmod=r(t.fchmod),t.lchmod=r(t.lchmod),t.chownSync=o(t.chownSync),t.fchownSync=o(t.fchownSync),t.lchownSync=o(t.lchownSync),t.chmodSync=n(t.chmodSync),t.fchmodSync=n(t.fchmodSync),t.lchmodSync=n(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=l(t.statSync),t.fstatSync=l(t.fstatSync),t.lstatSync=l(t.lstatSync),t.lchmod||(t.lchmod=function(t,e,i){i&&process.nextTick(i)},t.lchmodSync=function(){}),t.lchown||(t.lchown=function(t,e,i,r){r&&process.nextTick(r)},t.lchownSync=function(){}),"win32"===go&&(t.rename=(e=t.rename,function(i,r,n){var s=Date.now(),o=0;e(i,r,function a(l){if(l&&("EACCES"===l.code||"EPERM"===l.code)&&Date.now()-s<6e4)return setTimeout(function(){t.stat(r,function(t,s){t&&"ENOENT"===t.code?e(i,r,a):n(l)})},o),void(o<100&&(o+=10));n&&n(l)})})),t.read=function(e){function i(i,r,n,s,o,a){var l;if(a&&"function"==typeof a){var c=0;l=function(u,h,d){if(u&&"EAGAIN"===u.code&&c<10)return c++,e.call(t,i,r,n,s,o,l);a.apply(this,arguments)}}return e.call(t,i,r,n,s,o,l)}return Object.setPrototypeOf&&Object.setPrototypeOf(i,e),i}(t.read),t.readSync=(i=t.readSync,function(e,r,n,s,o){for(var a=0;;)try{return i.call(t,e,r,n,s,o)}catch(t){if("EAGAIN"===t.code&&a<10){a++;continue}throw t}})})(t),t.gracefulify=o,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,r){return"function"==typeof i&&(r=i,i=null),function t(i,r,n,s){return e(i,r,function(e){!e||"EMFILE"!==e.code&&"ENFILE"!==e.code?"function"==typeof n&&n.apply(this,arguments):a([t,[i,r,n],e,s||Date.now(),Date.now()])})}(t,i,r)};var i=t.writeFile;t.writeFile=function(t,e,r,n){return"function"==typeof r&&(n=r,r=null),function t(e,r,n,s,o){return i(e,r,n,function(i){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?"function"==typeof s&&s.apply(this,arguments):a([t,[e,r,n,s],i,o||Date.now(),Date.now()])})}(t,e,r,n)};var r=t.appendFile;r&&(t.appendFile=function(t,e,i,n){return"function"==typeof i&&(n=i,i=null),function t(e,i,n,s,o){return r(e,i,n,function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?"function"==typeof s&&s.apply(this,arguments):a([t,[e,i,n,s],r,o||Date.now(),Date.now()])})}(t,e,i,n)});var n=t.copyFile;n&&(t.copyFile=function(t,e,i,r){return"function"==typeof i&&(r=i,i=0),function t(e,i,r,s,o){return n(e,i,r,function(n){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?"function"==typeof s&&s.apply(this,arguments):a([t,[e,i,r,s],n,o||Date.now(),Date.now()])})}(t,e,i,r)});var s=t.readdir;if(t.readdir=function(t,e,i){return"function"==typeof e&&(i=e,e=null),function t(e,i,r,n){return s(e,i,function(s,o){!s||"EMFILE"!==s.code&&"ENFILE"!==s.code?(o&&o.sort&&o.sort(),"function"==typeof r&&r.call(this,s,o)):a([t,[e,i,r],s,n||Date.now(),Date.now()])})}(t,e,i)},"v0.8"===process.version.substr(0,4)){var l=function(t){return{ReadStream:function e(i,r){if(!(this instanceof e))return new e(i,r);bo.call(this);var n=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,r=r||{};for(var s=Object.keys(r),o=0,a=s.length;o<a;o++){var l=s[o];this[l]=r[l]}if(this.encoding&&this.setEncoding(this.encoding),void 0!==this.start){if("number"!=typeof this.start)throw TypeError("start must be a Number");if(void 0===this.end)this.end=Infinity;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}null===this.fd?t.open(this.path,this.flags,this.mode,function(t,e){if(t)return n.emit("error",t),void(n.readable=!1);n.fd=e,n.emit("open",e),n._read()}):process.nextTick(function(){n._read()})},WriteStream:function e(i,r){if(!(this instanceof e))return new e(i,r);bo.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var n=Object.keys(r),s=0,o=n.length;s<o;s++){var a=n[s];this[a]=r[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())}}}(t);p=l.ReadStream,f=l.WriteStream}var c=t.ReadStream;c&&(p.prototype=Object.create(c.prototype),p.prototype.open=function(){var t=this;g(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 u=t.WriteStream;u&&(f.prototype=Object.create(u.prototype),f.prototype.open=function(){var t=this;g(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 f},set:function(t){f=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 d=f;function p(t,e){return this instanceof p?(c.apply(this,arguments),this):p.apply(Object.create(p.prototype),arguments)}function f(t,e){return this instanceof f?(u.apply(this,arguments),this):f.apply(Object.create(f.prototype),arguments)}Object.defineProperty(t,"FileWriteStream",{get:function(){return d},set:function(t){d=t},enumerable:!0,configurable:!0});var m=t.open;function g(t,e,i,r){return"function"==typeof i&&(r=i,i=null),function t(e,i,r,n,s){return m(e,i,r,function(o,l){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?"function"==typeof n&&n.apply(this,arguments):a([t,[e,i,r,n],o,s||Date.now(),Date.now()])})}(t,e,i,r)}return t.open=g,t}function a(t){s("ENQUEUE",t[0].name,t[1]),v.default[e].push(t),c()}function l(){for(var t=Date.now(),i=0;i<v.default[e].length;++i)v.default[e][i].length>2&&(v.default[e][i][3]=t,v.default[e][i][4]=t);c()}function c(){if(clearTimeout(n),n=void 0,0!==v.default[e].length){var t=v.default[e].shift(),i=t[0],r=t[1],o=t[2],a=t[3],l=t[4];if(void 0===a)s("RETRY",i.name,r),i.apply(null,r);else if(Date.now()-a>=6e4){s("TIMEOUT",i.name,r);var u=r.pop();"function"==typeof u&&u.call(null,o)}else{var h=Date.now()-l,d=Math.max(l-a,1);h>=Math.min(1.2*d,100)?(s("RETRY",i.name,r),i.apply(null,r.concat([a]))):v.default[e].push(t)}void 0===n&&(n=setTimeout(c,0))}}C.default.debuglog?s=C.default.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(s=function(){var t=C.default.format.apply(C.default,arguments);t="GFS4: "+t.split(/\n/).join("\nGFS4: "),console.error(t)}),v.default[e]||(r(v.default,I[e]||[]),v.default.close=function(t){function e(e,i){return t.call(v.default,e,function(t){t||l(),"function"==typeof i&&i.apply(this,arguments)})}return Object.defineProperty(e,i,{value:t}),e}(v.default.close),v.default.closeSync=function(t){function e(e){t.apply(v.default,arguments),l()}return Object.defineProperty(e,i,{value:t}),e}(v.default.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){s(v.default[e]),S.default.equal(v.default[e].length,0)})),I[e]||r(I,v.default[e]),t.exports=o(function(t){if(null===t||"object"!=typeof t)return t;if(t instanceof Object)var e={__proto__:wo(t)};else e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}(v.default)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!v.default.__patched&&(t.exports=o(v.default),v.default.__patched=!0)});const So=x.default.homedir(),{env:Eo}=process,xo=Eo.XDG_DATA_HOME||(So?y.default.join(So,".local","share"):void 0),_o=Eo.XDG_CONFIG_HOME||(So?y.default.join(So,".config"):void 0);Eo.XDG_STATE_HOME||So&&y.default.join(So,".local","state"),Eo.XDG_CACHE_HOME||So&&y.default.join(So,".cache");const Oo=(Eo.XDG_DATA_DIRS||"/usr/local/share/:/usr/share/").split(":");xo&&Oo.unshift(xo);const Co=(Eo.XDG_CONFIG_DIRS||"/etc/xdg").split(":");_o&&Co.unshift(_o);var ko=N(function(t){!function(){var e;function i(t,r){var n=this instanceof i?this:e;if(n.reset(r),"string"==typeof t&&t.length>0&&n.hash(t),n!==this)return n}i.prototype.hash=function(t){var e,i,r,n,s;switch(this.len+=s=t.length,i=this.k1,r=0,this.rem){case 0:i^=s>r?65535&t.charCodeAt(r++):0;case 1:i^=s>r?(65535&t.charCodeAt(r++))<<8:0;case 2:i^=s>r?(65535&t.charCodeAt(r++))<<16:0;case 3:i^=s>r?(255&t.charCodeAt(r))<<24:0,i^=s>r?(65280&t.charCodeAt(r++))>>8:0}if(this.rem=s+this.rem&3,(s-=this.rem)>0){for(e=this.h1;e=5*(e=(e^=i=13715*(i=(i=11601*i+3432906752*(65535&i)&4294967295)<<15|i>>>17)+461832192*(65535&i)&4294967295)<<13|e>>>19)+3864292196&4294967295,!(r>=s);)i=65535&t.charCodeAt(r++)^(65535&t.charCodeAt(r++))<<8^(65535&t.charCodeAt(r++))<<16,i^=(255&(n=t.charCodeAt(r++)))<<24^(65280&n)>>8;switch(i=0,this.rem){case 3:i^=(65535&t.charCodeAt(r+2))<<16;case 2:i^=(65535&t.charCodeAt(r+1))<<8;case 1:i^=65535&t.charCodeAt(r)}this.h1=e}return this.k1=i,this},i.prototype.result=function(){var t,e;return e=this.h1,(t=this.k1)>0&&(e^=t=13715*(t=(t=11601*t+3432906752*(65535&t)&4294967295)<<15|t>>>17)+461832192*(65535&t)&4294967295),e^=this.len,e=51819*(e^=e>>>16)+2246770688*(65535&e)&4294967295,e=44597*(e^=e>>>13)+3266445312*(65535&e)&4294967295,(e^=e>>>16)>>>0},i.prototype.reset=function(t){return this.h1="number"==typeof t?t:0,this.rem=this.k1=this.len=0,this},e=new i,t.exports=i}()}),$o=Po;Po.strict=To,Po.loose=Io;var jo=Object.prototype.toString,Ao={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function Po(t){return To(t)||Io(t)}function To(t){return t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array}function Io(t){return Ao[jo.call(t)]}var No=$o.strict,Fo=function(t){if(No(t)){var e=Buffer.from(t.buffer);return t.byteLength!==t.buffer.byteLength&&(e=e.slice(t.byteOffset,t.byteOffset+t.byteLength)),e}return Buffer.from(t)},Ro=function(t,e,i,r){i instanceof Function&&(r=i,i={});const n=async function(t,e,i={}){let r,n;"string"==typeof i&&(i={encoding:i});const s=Ci(qo(()=>n)),o=y.default.resolve(t);try{await function(t){return new Promise(e=>{Mo[t]||(Mo[t]=[]),Mo[t].push(e),1===Mo[t].length&&e()})}(o);const a=await Bo(v.default.realpath)(t).catch(()=>t);if(n=Uo(a),!i.mode||!i.chown){const t=await Bo(v.default.stat)(a).catch(()=>{});t&&(null==i.mode&&(i.mode=t.mode),null==i.chown&&process.getuid&&(i.chown={uid:t.uid,gid:t.gid}))}r=await Bo(v.default.open)(n,"w",i.mode),i.tmpfileCreated&&await i.tmpfileCreated(n),$o(e)&&(e=Fo(e)),Buffer.isBuffer(e)?await Bo(v.default.write)(r,e,0,e.length,0):null!=e&&await Bo(v.default.write)(r,String(e),0,String(i.encoding||"utf8")),!1!==i.fsync&&await Bo(v.default.fsync)(r),await Bo(v.default.close)(r),r=null,i.chown&&await Bo(v.default.chown)(n,i.chown.uid,i.chown.gid).catch(t=>{if(!Vo(t))throw t}),i.mode&&await Bo(v.default.chmod)(n,i.mode).catch(t=>{if(!Vo(t))throw t}),await Bo(v.default.rename)(n,a)}finally{r&&await Bo(v.default.close)(r).catch(()=>{}),s(),await Bo(v.default.unlink)(n).catch(()=>{}),Mo[o].shift(),Mo[o].length>0?Mo[o][0]():delete Mo[o]}}(t,e,i);return r&&n.then(r,r),n},Lo=Uo,Do=qo;const{promisify:Bo}=C.default,Mo={},Go=function(){try{return 0}catch(t){return 0}}();let Ho=0;function Uo(t){return t+"."+ko(__filename).hash(String(process.pid)).hash(String(Go)).hash(String(++Ho)).result()}function qo(t){return()=>{try{v.default.unlinkSync("function"==typeof t?t():t)}catch(t){}}}function Vo(t){return"ENOSYS"===t.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==t.code&&"EPERM"!==t.code)}Ro.sync=function(t,e,i){"string"==typeof i?i={encoding:i}:i||(i={});try{t=v.default.realpathSync(t)}catch(t){}const r=Uo(t);if(!i.mode||!i.chown)try{const e=v.default.statSync(t);(i=Object.assign({},i)).mode||(i.mode=e.mode),!i.chown&&process.getuid&&(i.chown={uid:e.uid,gid:e.gid})}catch(t){}let n;const s=qo(r),o=Ci(s);let a=!0;try{if(n=v.default.openSync(r,"w",i.mode||438),i.tmpfileCreated&&i.tmpfileCreated(r),$o(e)&&(e=Fo(e)),Buffer.isBuffer(e)?v.default.writeSync(n,e,0,e.length,0):null!=e&&v.default.writeSync(n,String(e),0,String(i.encoding||"utf8")),!1!==i.fsync&&v.default.fsyncSync(n),v.default.closeSync(n),n=null,i.chown)try{v.default.chownSync(r,i.chown.uid,i.chown.gid)}catch(t){if(!Vo(t))throw t}if(i.mode)try{v.default.chmodSync(r,i.mode)}catch(t){if(!Vo(t))throw t}v.default.renameSync(r,t),a=!1}finally{if(n)try{v.default.closeSync(n)}catch(t){}o(),a&&s()}},Ro._getTmpname=Lo,Ro._cleanupOnExit=Do;var Wo=t=>{const e=typeof t;return null!==t&&("object"===e||"function"===e)};const zo=new Set(["__proto__","prototype","constructor"]);function Yo(t){const e=t.split("."),i=[];for(let t=0;t<e.length;t++){let r=e[t];for(;"\\"===r[r.length-1]&&void 0!==e[t+1];)r=r.slice(0,-1)+".",r+=e[++t];i.push(r)}return i.some(t=>zo.has(t))?[]:i}var Ko={get(t,e,i){if(!Wo(t)||"string"!=typeof e)return void 0===i?t:i;const r=Yo(e);if(0!==r.length){for(let e=0;e<r.length;e++)if(null==(t=t[r[e]])){if(e!==r.length-1)return i;break}return void 0===t?i:t}},set(t,e,i){if(!Wo(t)||"string"!=typeof e)return t;const r=t,n=Yo(e);for(let e=0;e<n.length;e++){const r=n[e];Wo(t[r])||(t[r]={}),e===n.length-1&&(t[r]=i),t=t[r]}return r},delete(t,e){if(!Wo(t)||"string"!=typeof e)return!1;const i=Yo(e);for(let e=0;e<i.length;e++){const r=i[e];if(e===i.length-1)return delete t[r],!0;if(!Wo(t=t[r]))return!1}},has(t,e){if(!Wo(t)||"string"!=typeof e)return!1;const i=Yo(e);if(0===i.length)return!1;for(let e=0;e<i.length;e++){if(!Wo(t))return!1;if(!(i[e]in t))return!1;t=t[i[e]]}return!0}};const Jo=c.promisify(j.default.randomBytes),Xo="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~".split(""),Zo="0123456789".split(""),Qo="CDEHKMPRTUWXY012458".split(""),ta="!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~".split(""),ea="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),ia=new Set([void 0,"hex","base64","url-safe","numeric","distinguishable","ascii-printable","alphanumeric"]),ra=(t,e)=>({length:i,type:r,characters:n})=>{if(!(i>=0&&Number.isFinite(i)))throw new TypeError("Expected a `length` to be a non-negative finite number");if(void 0!==r&&void 0!==n)throw new TypeError("Expected either `type` or `characters`");if(void 0!==n&&"string"!=typeof n)throw new TypeError("Expected `characters` to be string");if(!ia.has(r))throw new TypeError(`Unknown type: ${r}`);if(void 0===r&&void 0===n&&(r="hex"),"hex"===r||void 0===r&&void 0===n)return e(Math.ceil(.5*i),"hex",i);if("base64"===r)return e(Math.ceil(.75*i),"base64",i);if("url-safe"===r)return t(i,Xo);if("numeric"===r)return t(i,Zo);if("distinguishable"===r)return t(i,Qo);if("ascii-printable"===r)return t(i,ta);if("alphanumeric"===r)return t(i,ea);if(0===n.length)throw new TypeError("Expected `characters` string length to be greater than or equal to 1");if(n.length>65536)throw new TypeError("Expected `characters` string length to be less or equal to 65536");return t(i,n.split(""))},na=ra((t,e)=>{const i=e.length,r=Math.floor(65536/i)*i-1,n=2*Math.ceil(1.1*t);let s="",o=0;for(;o<t;){const a=j.default.randomBytes(n);let l=0;for(;l<n&&o<t;){const t=a.readUInt16LE(l);l+=2,t>r||(s+=e[t%i],o++)}}return s},(t,e,i)=>j.default.randomBytes(t).toString(e).slice(0,i));na.async=ra(async(t,e)=>{const i=e.length,r=Math.floor(65536/i)*i-1,n=2*Math.ceil(1.1*t);let s="",o=0;for(;o<t;){const a=await Jo(n);let l=0;for(;l<n&&o<t;){const t=a.readUInt16LE(l);l+=2,t>r||(s+=e[t%i],o++)}}return s},async(t,e,i)=>(await Jo(t)).toString(e).slice(0,i));const sa=_o||y.default.join(x.default.tmpdir(),na({length:32})),oa={mode:448,recursive:!0},aa={mode:384};class la{constructor(t,e,i={}){const r=i.globalConfigPath?y.default.join(t,"config.json"):y.default.join("configstore",`${t}.json`);this._path=i.configPath||y.default.join(sa,r),e&&(this.all={...e,...this.all})}get all(){try{return JSON.parse(vo.readFileSync(this._path,"utf8"))}catch(t){if("ENOENT"===t.code)return{};if("EACCES"===t.code&&(t.message=`${t.message}\nYou don't have access to this file.\n`),"SyntaxError"===t.name)return Ro.sync(this._path,"",aa),{};throw t}}set all(t){try{vo.mkdirSync(y.default.dirname(this._path),oa),Ro.sync(this._path,JSON.stringify(t,void 0,"\t"),aa)}catch(t){throw"EACCES"===t.code&&(t.message=`${t.message}\nYou don't have access to this file.\n`),t}}get size(){return Object.keys(this.all||{}).length}get(t){return Ko.get(this.all,t)}set(t,e){const i=this.all;if(1===arguments.length)for(const e of Object.keys(t))Ko.set(i,e,t[e]);else Ko.set(i,t,e);this.all=i}has(t){return Ko.has(this.all,t)}delete(t){const e=this.all;Ko.delete(e,t),this.all=e}clear(){this.all={}}get path(){return this._path}}let ca;const ua=()=>(ca||(ca=new la("medusa",{},{globalConfigPath:!0})),ca),ha=t=>{const e=ua();return e.get("cli.packageManager")||(null!=t&&t.includes("yarn")?(e.set("cli.packageManager","yarn"),"yarn"):(e.set("cli.packageManager","npm"),"npm"))},da=(t,e)=>{const[i,...r]=t.split(/\s+/);return((t,e,i)=>_r(t,e,st({stdio:"ignore",preferLocal:!1},i)))(i,r,e)},pa=async(t,e)=>{const r=process.cwd(),n=kr("Installing packages...");console.log(),process.chdir(t),process;try{"yarn"===ha()&&(()=>{try{return i.execSync("yarnpkg --version",{stdio:"ignore"}),!0}catch(t){return!1}})()?(await _s.remove("package-lock.json"),await da("yarnpkg",{stdio:e?"inherit":"ignore"})):(await _s.remove("yarn.lock"),await da("npm install",{stdio:e?"inherit":"ignore"}))}finally{n(),console.log(),uo("Packages installed"),process.chdir(r)}},fa=t=>!/^\.(git|hg)$/.test(y.default.basename(t)),ma=async t=>{const{starter:e,root:r,verbose:n,seed:s,keepGit:o}=t,{starterPath:a,rootPath:l}=await(async(t,e)=>({starterPath:t=t||"medusajs/medusa-starter-default",rootPath:e=e||process.cwd(),selectedOtherStarter:!1}))(e,r),c=$.default.parse(l);if(c.protocol&&c.host){const t=e&&!$.default.parse(e).hostname&&!$.default.parse(e).protocol;return/medusa-starter/gi.test(l)&&t?void po({id:"10000",context:{starter:e,rootPath:l}}):void po({id:"10001",context:{rootPath:l}})}if(!1!==("string"!=typeof(u=l)||function(t){return"string"==typeof t&&(/[*!?{}(|)[\]]/.test(t)||function(t){return"string"==typeof t&&/[@?!+*]\(/.test(t)}(t))}(u)||io.test(u)))return void po({id:"10002",context:{path:y.default.resolve(l)}});var u;if($r.sync(y.default.join(l,"package.json")))return void po({id:"10003",context:{rootPath:l}});const h=eo.fromUrl(a);h?await(async(t,e,r,n=!1)=>{let s;s="sshurl"===t.getDefaultRepresentation()?t.ssh({noCommittish:!0}):t.https({noCommittish:!0,noGitPlus:!0});const o=t.committish?["-b",t.committish]:[],a=kr(`Creating new project from git: ${s}`),l=["clone",...o,s,e,"--recursive","--depth=1"].filter(t=>Boolean(t));await _r("git",l,{}).then(()=>{a(),console.log(),uo("Created starter directory layout")}).catch(t=>{throw a(),console.log(),ho("Failed to clone repository"),t}),r||await _s.remove(y.default.join(e,".git")),await pa(e,n);const c=await(async()=>{try{return await da("git rev-parse --is-inside-work-tree",{stdio:"pipe"}).then(t=>"true"===t.stdout)}catch(t){return!1}})();c||await(async t=>(co(`Initialising git in ${t}`),await da("git init",{cwd:t})))(e),await(async t=>{$r.sync(y.default.join(t,".gitignore"))||(co(`Creating minimal .gitignore in ${t}`),await _s.writeFile(y.default.join(t,".gitignore"),".cache\nnode_modules\npublic\n"),uo(`Created .gitignore in ${t}`))})(e),c||await(async(t,e)=>{co(`Create initial git commit in ${t}`),await da("git add -A",{cwd:t});try{i.execSync(`git commit -m "Initial commit from medusa: (${e})"`,{cwd:t})}catch(e){console.warn("Initial git commit failed - removing git support\n"),_s.removeSync(y.default.join(t,".git"))}})(e,s)})(h,l,o,n):await(async(t,e)=>{if(await _s.ensureDir(e,{mode:493}),!$r.sync(t))throw new Error(`starter ${t} doesn't exist`);if("."===t)throw new Error("You can't create a starter from the existing directory. If you want to\n create a new project in the current directory, the trailing dot isn't\n necessary. If you want to create a project from a local starter, run\n something like \"medusa new my-medusa-store ../local-medusa-starter\"");const i=kr(`Creating new site from local starter: ${t}`);return co(`Copying local starter to ${e} ...`),await _s.copy(t,e,{filter:fa}),i(),console.log(),uo("Created starter directory layout"),console.log(),await pa(e),!0})(a,l);const d=(t=>{try{const e=y.default.join(t,"medusa-config.js");if($r.sync(e)){const t=y.default.resolve(e);return require(t)}throw Error()}catch(t){return null}return{}})(l);if(d){let t=!1;d.projectConfig&&(t="postgres"===d.projectConfig.database_type),!t&&s&&await(async t=>{const e=kr("Seeding database"),i=y.default.resolve(t,"package.json");if($r.sync(i)){const r=require(i);if(r.scripts&&r.scripts.seed){await(async t=>{const e=y.default.join(t,".env.template"),i=y.default.join(t,".env");$r.sync(e)&&_s.renameSync(e,i)})(t);const i=_r(ha(),["run","seed"],{cwd:t});i.stdout.pipe(process.stdout),await i.then(()=>{e(),console.log(),uo("Seed completed")}).catch(t=>{e(),console.log(),ho("Failed to complete seed; skipping"),console.error(t)})}else e(),console.log(),ho("Starter doesn't provide a seed command; skipping.")}else e(),console.log(),ho("Could not find package.json")})(l)}},ga=O.default.Readable,ya=Symbol("buffer"),ba=Symbol("type");class wa{constructor(){this[ba]="";const t=arguments[0],e=arguments[1],i=[];if(t){const e=t,r=Number(e.length);for(let t=0;t<r;t++){const r=e[t];let n;n=r instanceof Buffer?r:ArrayBuffer.isView(r)?Buffer.from(r.buffer,r.byteOffset,r.byteLength):r instanceof ArrayBuffer?Buffer.from(r):r instanceof wa?r[ya]:Buffer.from("string"==typeof r?r:String(r)),i.push(n)}}this[ya]=Buffer.concat(i);let r=e&&void 0!==e.type&&String(e.type).toLowerCase();r&&!/[^\u0020-\u007E]/.test(r)&&(this[ba]=r)}get size(){return this[ya].length}get type(){return this[ba]}text(){return Promise.resolve(this[ya].toString())}arrayBuffer(){const t=this[ya],e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return Promise.resolve(e)}stream(){const t=new ga;return t._read=function(){},t.push(this[ya]),t.push(null),t}toString(){return"[object Blob]"}slice(){const t=this.size,e=arguments[0],i=arguments[1];let r,n;r=void 0===e?0:e<0?Math.max(t+e,0):Math.min(e,t),n=void 0===i?t:i<0?Math.max(t+i,0):Math.min(i,t);const s=Math.max(n-r,0),o=this[ya].slice(r,r+s),a=new wa([],{type:arguments[2]});return a[ya]=o,a}}function va(t,e,i){Error.call(this,t),this.message=t,this.type=e,i&&(this.code=this.errno=i.code),Error.captureStackTrace(this,this.constructor)}let Sa;Object.defineProperties(wa.prototype,{size:{enumerable:!0},type:{enumerable:!0},slice:{enumerable:!0}}),Object.defineProperty(wa.prototype,Symbol.toStringTag,{value:"Blob",writable:!1,enumerable:!1,configurable:!0}),(va.prototype=Object.create(Error.prototype)).constructor=va,va.prototype.name="FetchError";try{Sa=require("encoding").convert}catch(t){}const Ea=Symbol("Body internals"),xa=O.default.PassThrough;function _a(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i.size;let n=void 0===r?0:r;var s=i.timeout;let o=void 0===s?0:s;null==t?t=null:Ca(t)?t=Buffer.from(t.toString()):ka(t)||Buffer.isBuffer(t)||("[object ArrayBuffer]"===Object.prototype.toString.call(t)?t=Buffer.from(t):ArrayBuffer.isView(t)?t=Buffer.from(t.buffer,t.byteOffset,t.byteLength):t instanceof O.default||(t=Buffer.from(String(t)))),this[Ea]={body:t,disturbed:!1,error:null},this.size=n,this.timeout=o,t instanceof O.default&&t.on("error",function(t){const i="AbortError"===t.name?t:new va(`Invalid response body while trying to fetch ${e.url}: ${t.message}`,"system",t);e[Ea].error=i})}function Oa(){var t=this;if(this[Ea].disturbed)return _a.Promise.reject(new TypeError(`body used already for: ${this.url}`));if(this[Ea].disturbed=!0,this[Ea].error)return _a.Promise.reject(this[Ea].error);let e=this.body;if(null===e)return _a.Promise.resolve(Buffer.alloc(0));if(ka(e)&&(e=e.stream()),Buffer.isBuffer(e))return _a.Promise.resolve(e);if(!(e instanceof O.default))return _a.Promise.resolve(Buffer.alloc(0));let i=[],r=0,n=!1;return new _a.Promise(function(s,o){let a;t.timeout&&(a=setTimeout(function(){n=!0,o(new va(`Response timeout while trying to fetch ${t.url} (over ${t.timeout}ms)`,"body-timeout"))},t.timeout)),e.on("error",function(e){"AbortError"===e.name?(n=!0,o(e)):o(new va(`Invalid response body while trying to fetch ${t.url}: ${e.message}`,"system",e))}),e.on("data",function(e){if(!n&&null!==e){if(t.size&&r+e.length>t.size)return n=!0,void o(new va(`content size at ${t.url} over limit: ${t.size}`,"max-size"));r+=e.length,i.push(e)}}),e.on("end",function(){if(!n){clearTimeout(a);try{s(Buffer.concat(i,r))}catch(e){o(new va(`Could not create Buffer from response body for ${t.url}: ${e.message}`,"system",e))}}})})}function Ca(t){return"object"==typeof t&&"function"==typeof t.append&&"function"==typeof t.delete&&"function"==typeof t.get&&"function"==typeof t.getAll&&"function"==typeof t.has&&"function"==typeof t.set&&("URLSearchParams"===t.constructor.name||"[object URLSearchParams]"===Object.prototype.toString.call(t)||"function"==typeof t.sort)}function ka(t){return"object"==typeof t&&"function"==typeof t.arrayBuffer&&"string"==typeof t.type&&"function"==typeof t.stream&&"function"==typeof t.constructor&&"string"==typeof t.constructor.name&&/^(Blob|File)$/.test(t.constructor.name)&&/^(Blob|File)$/.test(t[Symbol.toStringTag])}function $a(t){let e,i,r=t.body;if(t.bodyUsed)throw new Error("cannot clone body after it is used");return r instanceof O.default&&"function"!=typeof r.getBoundary&&(e=new xa,i=new xa,r.pipe(e),r.pipe(i),t[Ea].body=e,r=i),r}function ja(t){return null===t?null:"string"==typeof t?"text/plain;charset=UTF-8":Ca(t)?"application/x-www-form-urlencoded;charset=UTF-8":ka(t)?t.type||null:Buffer.isBuffer(t)||"[object ArrayBuffer]"===Object.prototype.toString.call(t)||ArrayBuffer.isView(t)?null:"function"==typeof t.getBoundary?`multipart/form-data;boundary=${t.getBoundary()}`:t instanceof O.default?null:"text/plain;charset=UTF-8"}function Aa(t){const e=t.body;return null===e?0:ka(e)?e.size:Buffer.isBuffer(e)?e.length:e&&"function"==typeof e.getLengthSync&&(e._lengthRetrievers&&0==e._lengthRetrievers.length||e.hasKnownLength&&e.hasKnownLength())?e.getLengthSync():null}_a.prototype={get body(){return this[Ea].body},get bodyUsed(){return this[Ea].disturbed},arrayBuffer(){return Oa.call(this).then(function(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)})},blob(){let t=this.headers&&this.headers.get("content-type")||"";return Oa.call(this).then(function(e){return Object.assign(new wa([],{type:t.toLowerCase()}),{[ya]:e})})},json(){var t=this;return Oa.call(this).then(function(e){try{return JSON.parse(e.toString())}catch(e){return _a.Promise.reject(new va(`invalid json response body at ${t.url} reason: ${e.message}`,"invalid-json"))}})},text(){return Oa.call(this).then(function(t){return t.toString()})},buffer(){return Oa.call(this)},textConverted(){var t=this;return Oa.call(this).then(function(e){return function(t,e){if("function"!=typeof Sa)throw new Error("The package `encoding` must be installed to use the textConverted() function");const i=e.get("content-type");let r,n,s="utf-8";return i&&(r=/charset=([^;]*)/i.exec(i)),n=t.slice(0,1024).toString(),!r&&n&&(r=/<meta.+?charset=(['"])(.+?)\1/i.exec(n)),!r&&n&&(r=/<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(n),r||(r=/<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(n),r&&r.pop()),r&&(r=/charset=(.*)/i.exec(r.pop()))),!r&&n&&(r=/<\?xml.+?encoding=(['"])(.+?)\1/i.exec(n)),r&&(s=r.pop(),"gb2312"!==s&&"gbk"!==s||(s="gb18030")),Sa(t,"UTF-8",s).toString()}(e,t.headers)})}},Object.defineProperties(_a.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}}),_a.mixIn=function(t){for(const e of Object.getOwnPropertyNames(_a.prototype))if(!(e in t)){const i=Object.getOwnPropertyDescriptor(_a.prototype,e);Object.defineProperty(t,e,i)}},_a.Promise=global.Promise;const Pa=/[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/,Ta=/[^\t\x20-\x7e\x80-\xff]/;function Ia(t){if(Pa.test(t=`${t}`)||""===t)throw new TypeError(`${t} is not a legal HTTP header name`)}function Na(t){if(Ta.test(t=`${t}`))throw new TypeError(`${t} is not a legal HTTP header value`)}function Fa(t,e){e=e.toLowerCase();for(const i in t)if(i.toLowerCase()===e)return i}const Ra=Symbol("map");class La{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;if(this[Ra]=Object.create(null),t instanceof La){const e=t.raw(),i=Object.keys(e);for(const t of i)for(const i of e[t])this.append(t,i)}else if(null==t);else{if("object"!=typeof t)throw new TypeError("Provided initializer must be an object");{const e=t[Symbol.iterator];if(null!=e){if("function"!=typeof e)throw new TypeError("Header pairs must be iterable");const i=[];for(const e of t){if("object"!=typeof e||"function"!=typeof e[Symbol.iterator])throw new TypeError("Each header pair must be iterable");i.push(Array.from(e))}for(const t of i){if(2!==t.length)throw new TypeError("Each header pair must be a name/value tuple");this.append(t[0],t[1])}}else for(const e of Object.keys(t))this.append(e,t[e])}}}get(t){Ia(t=`${t}`);const e=Fa(this[Ra],t);return void 0===e?null:this[Ra][e].join(", ")}forEach(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=Da(this),r=0;for(;r<i.length;){var n=i[r];t.call(e,n[1],n[0],this),i=Da(this),r++}}set(t,e){e=`${e}`,Ia(t=`${t}`),Na(e);const i=Fa(this[Ra],t);this[Ra][void 0!==i?i:t]=[e]}append(t,e){e=`${e}`,Ia(t=`${t}`),Na(e);const i=Fa(this[Ra],t);void 0!==i?this[Ra][i].push(e):this[Ra][t]=[e]}has(t){return Ia(t=`${t}`),void 0!==Fa(this[Ra],t)}delete(t){Ia(t=`${t}`);const e=Fa(this[Ra],t);void 0!==e&&delete this[Ra][e]}raw(){return this[Ra]}keys(){return Ma(this,"key")}values(){return Ma(this,"value")}[Symbol.iterator](){return Ma(this,"key+value")}}function Da(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"key+value";const i=Object.keys(t[Ra]).sort();return i.map("key"===e?function(t){return t.toLowerCase()}:"value"===e?function(e){return t[Ra][e].join(", ")}:function(e){return[e.toLowerCase(),t[Ra][e].join(", ")]})}La.prototype.entries=La.prototype[Symbol.iterator],Object.defineProperty(La.prototype,Symbol.toStringTag,{value:"Headers",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(La.prototype,{get:{enumerable:!0},forEach:{enumerable:!0},set:{enumerable:!0},append:{enumerable:!0},has:{enumerable:!0},delete:{enumerable:!0},keys:{enumerable:!0},values:{enumerable:!0},entries:{enumerable:!0}});const Ba=Symbol("internal");function Ma(t,e){const i=Object.create(Ga);return i[Ba]={target:t,kind:e,index:0},i}const Ga=Object.setPrototypeOf({next(){if(!this||Object.getPrototypeOf(this)!==Ga)throw new TypeError("Value of `this` is not a HeadersIterator");var t=this[Ba];const e=t.index,i=Da(t.target,t.kind);return e>=i.length?{value:void 0,done:!0}:(this[Ba].index=e+1,{value:i[e],done:!1})}},Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));function Ha(t){const e=Object.assign({__proto__:null},t[Ra]),i=Fa(t[Ra],"Host");return void 0!==i&&(e[i]=e[i][0]),e}Object.defineProperty(Ga,Symbol.toStringTag,{value:"HeadersIterator",writable:!1,enumerable:!1,configurable:!0});const Ua=Symbol("Response internals"),qa=A.default.STATUS_CODES;class Va{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_a.call(this,t,e);const i=e.status||200,r=new La(e.headers);if(null!=t&&!r.has("Content-Type")){const e=ja(t);e&&r.append("Content-Type",e)}this[Ua]={url:e.url,status:i,statusText:e.statusText||qa[i],headers:r,counter:e.counter}}get url(){return this[Ua].url||""}get status(){return this[Ua].status}get ok(){return this[Ua].status>=200&&this[Ua].status<300}get redirected(){return this[Ua].counter>0}get statusText(){return this[Ua].statusText}get headers(){return this[Ua].headers}clone(){return new Va($a(this),{url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected})}}_a.mixIn(Va.prototype),Object.defineProperties(Va.prototype,{url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}}),Object.defineProperty(Va.prototype,Symbol.toStringTag,{value:"Response",writable:!1,enumerable:!1,configurable:!0});const Wa=Symbol("Request internals"),za=$.default.parse,Ya=$.default.format,Ka="destroy"in O.default.Readable.prototype;function Ja(t){return"object"==typeof t&&"object"==typeof t[Wa]}class Xa{constructor(t){let e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Ja(t)?e=za(t.url):(e=za(t&&t.href?t.href:`${t}`),t={});let r=i.method||t.method||"GET";if(r=r.toUpperCase(),(null!=i.body||Ja(t)&&null!==t.body)&&("GET"===r||"HEAD"===r))throw new TypeError("Request with GET/HEAD method cannot have body");let n=null!=i.body?i.body:Ja(t)&&null!==t.body?$a(t):null;_a.call(this,n,{timeout:i.timeout||t.timeout||0,size:i.size||t.size||0});const s=new La(i.headers||t.headers||{});if(null!=n&&!s.has("Content-Type")){const t=ja(n);t&&s.append("Content-Type",t)}let o=Ja(t)?t.signal:null;if("signal"in i&&(o=i.signal),null!=o&&!function(t){const e=t&&"object"==typeof t&&Object.getPrototypeOf(t);return!(!e||"AbortSignal"!==e.constructor.name)}(o))throw new TypeError("Expected signal to be an instanceof AbortSignal");this[Wa]={method:r,redirect:i.redirect||t.redirect||"follow",headers:s,parsedURL:e,signal:o},this.follow=void 0!==i.follow?i.follow:void 0!==t.follow?t.follow:20,this.compress=void 0!==i.compress?i.compress:void 0===t.compress||t.compress,this.counter=i.counter||t.counter||0,this.agent=i.agent||t.agent}get method(){return this[Wa].method}get url(){return Ya(this[Wa].parsedURL)}get headers(){return this[Wa].headers}get redirect(){return this[Wa].redirect}get signal(){return this[Wa].signal}clone(){return new Xa(this)}}function Za(t){Error.call(this,t),this.type="aborted",this.message=t,Error.captureStackTrace(this,this.constructor)}_a.mixIn(Xa.prototype),Object.defineProperty(Xa.prototype,Symbol.toStringTag,{value:"Request",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(Xa.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0}}),(Za.prototype=Object.create(Error.prototype)).constructor=Za,Za.prototype.name="AbortError";const Qa=O.default.PassThrough,tl=$.default.resolve;function el(t,e){if(!el.Promise)throw new Error("native promise missing, set fetch.Promise to your favorite alternative");return _a.Promise=el.Promise,new el.Promise(function(i,r){const n=new Xa(t,e),s=function(t){const e=t[Wa].parsedURL,i=new La(t[Wa].headers);if(i.has("Accept")||i.set("Accept","*/*"),!e.protocol||!e.hostname)throw new TypeError("Only absolute URLs are supported");if(!/^https?:$/.test(e.protocol))throw new TypeError("Only HTTP(S) protocols are supported");if(t.signal&&t.body instanceof O.default.Readable&&!Ka)throw new Error("Cancellation of streamed requests with AbortSignal is not supported in node < 8");let r=null;if(null==t.body&&/^(POST|PUT)$/i.test(t.method)&&(r="0"),null!=t.body){const e=Aa(t);"number"==typeof e&&(r=String(e))}r&&i.set("Content-Length",r),i.has("User-Agent")||i.set("User-Agent","node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"),t.compress&&!i.has("Accept-Encoding")&&i.set("Accept-Encoding","gzip,deflate");let n=t.agent;return"function"==typeof n&&(n=n(e)),i.has("Connection")||n||i.set("Connection","close"),Object.assign({},e,{method:t.method,headers:Ha(i),agent:n})}(n),o=("https:"===s.protocol?P.default:A.default).request,a=n.signal;let l=null;const c=function(){let t=new Za("The user aborted a request.");r(t),n.body&&n.body instanceof O.default.Readable&&n.body.destroy(t),l&&l.body&&l.body.emit("error",t)};if(a&&a.aborted)return void c();const u=function(){c(),p()},h=o(s);let d;function p(){h.abort(),a&&a.removeEventListener("abort",u),clearTimeout(d)}a&&a.addEventListener("abort",u),n.timeout&&h.once("socket",function(t){d=setTimeout(function(){r(new va(`network timeout at: ${n.url}`,"request-timeout")),p()},n.timeout)}),h.on("error",function(t){r(new va(`request to ${n.url} failed, reason: ${t.message}`,"system",t)),p()}),h.on("response",function(t){clearTimeout(d);const e=function(t){const e=new La;for(const i of Object.keys(t))if(!Pa.test(i))if(Array.isArray(t[i]))for(const r of t[i])Ta.test(r)||(void 0===e[Ra][i]?e[Ra][i]=[r]:e[Ra][i].push(r));else Ta.test(t[i])||(e[Ra][i]=[t[i]]);return e}(t.headers);if(el.isRedirect(t.statusCode)){const s=e.get("Location"),o=null===s?null:tl(n.url,s);switch(n.redirect){case"error":return r(new va(`uri requested responds with a redirect, redirect mode is set to error: ${n.url}`,"no-redirect")),void p();case"manual":if(null!==o)try{e.set("Location",o)}catch(t){r(t)}break;case"follow":if(null===o)break;if(n.counter>=n.follow)return r(new va(`maximum redirect reached at: ${n.url}`,"max-redirect")),void p();const s={headers:new La(n.headers),follow:n.follow,counter:n.counter+1,agent:n.agent,compress:n.compress,method:n.method,body:n.body,signal:n.signal,timeout:n.timeout,size:n.size};return 303!==t.statusCode&&n.body&&null===Aa(n)?(r(new va("Cannot follow redirect with body being a readable stream","unsupported-redirect")),void p()):(303!==t.statusCode&&(301!==t.statusCode&&302!==t.statusCode||"POST"!==n.method)||(s.method="GET",s.body=void 0,s.headers.delete("content-length")),i(el(new Xa(o,s))),void p())}}t.once("end",function(){a&&a.removeEventListener("abort",u)});let s=t.pipe(new Qa);const o={url:n.url,status:t.statusCode,statusText:t.statusMessage,headers:e,size:n.size,timeout:n.timeout,counter:n.counter},c=e.get("Content-Encoding");if(!n.compress||"HEAD"===n.method||null===c||204===t.statusCode||304===t.statusCode)return l=new Va(s,o),void i(l);if("gzip"==c||"x-gzip"==c)return s=s.pipe(T.default.createGunzip({flush:T.default.Z_SYNC_FLUSH,finishFlush:T.default.Z_SYNC_FLUSH})),l=new Va(s,o),void i(l);if("deflate"!=c&&"x-deflate"!=c){if("br"==c&&"function"==typeof T.default.createBrotliDecompress)return s=s.pipe(T.default.createBrotliDecompress()),l=new Va(s,o),void i(l);l=new Va(s,o),i(l)}else t.pipe(new Qa).once("data",function(t){s=s.pipe(8==(15&t[0])?T.default.createInflate():T.default.createInflateRaw()),l=new Va(s,o),i(l)})}),function(t,e){const i=e.body;null===i?t.end():ka(i)?i.stream().pipe(t):Buffer.isBuffer(i)?(t.write(i),t.end()):i.pipe(t)}(h,n)})}el.isRedirect=function(t){return 301===t||302===t||303===t||307===t||308===t},el.Promise=global.Promise;for(var il=function(){return j.default.randomBytes(16)},rl=[],nl=0;nl<256;++nl)rl[nl]=(nl+256).toString(16).substr(1);var sl=function(t,e,i){var r=e&&i||0;"string"==typeof t&&(e="binary"===t?new Array(16):null,t=null);var n=(t=t||{}).random||(t.rng||il)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e)for(var s=0;s<16;++s)e[r+s]=n[s];return e||function(t,e){var i=0;return[rl[t[i++]],rl[t[i++]],rl[t[i++]],rl[t[i++]],"-",rl[t[i++]],rl[t[i++]],"-",rl[t[i++]],rl[t[i++]],"-",rl[t[i++]],rl[t[i++]],"-",rl[t[i++]],rl[t[i++]],rl[t[i++]],rl[t[i++]],rl[t[i++]],rl[t[i++]]].join("")}(n)};const ol=ua(),al=require("../package.json").version,ll=process.env.MEDUSA_TELEMETRY_API||"https://telemetry.medusa-commerce.com/batch",cl=()=>{let t=ol.get("telemetry.machine_id");return"string"!=typeof t&&(t=sl(),ol.set("telemetry.machine_id",t)),t},ul=sl(),hl=(t,e)=>{el(ll,{method:"POST",headers:{"content-type":"application/json","user-agent":`create-medusa-app:${al}`},body:JSON.stringify({timestamp:new Date,batch:[{type:t,timestamp:new Date,sessionId:ul,machine_id:cl(),component_id:"create-medusa-app",cli_version:al,properties:e}]})}).catch(()=>{})};let dl="";const pl={type:"input",name:"projectRoot",message:"Where should your project be installed?",initial:"my-medusa-store"},fl={type:"select",name:"starter",message:"Which Medusa starter would you like to install?",choices:["medusa-starter-default","medusa-starter-contentful","Other"]},ml={type:"input",name:"starterUrl",message:"Where is the starter located? (URL or path)"},gl={type:"select",name:"storefront",message:"Which storefront starter would you like to install?",choices:["Gatsby Starter","Next.js Starter","medusa.express (Next.js)","medusa.express (Gatsby)","Gatsby Starter (Simple)","None"]},yl=new nt.Command("create-medusa-app").version("0.0.7-dev.113+8e7de6dd").action(t=>dl=t).option("-r --root","The directory to install your Medusa app").option("-s --starter-url","A GitHub URL to a repository that contains a Medusa starter project to bootstrap from").option("--no-seed","If run with the no-seed flag the script will skip seeding the database upon setup").option("-v --verbose","Show all installation output").parse(process.argv);exports.run=async()=>{hl("CREATE_CLI"),"string"==typeof dl&&(dl=dl.trim());const{projectRoot:t}=await Oe.prompt(pl);let{starter:e}=await Oe.prompt(fl);if("Other"===e){const{starterUrl:t}=await Oe.prompt(ml);e=t}else e=`medusajs/${e}`;hl("STARTER_SELECTED",{starter:e});const i=yl.opts(),r=i.noSeed;hl("SEED_SELECTED",{seed:!r});const{storefront:n}=await Oe.prompt(gl);hl("STOREFRONT_SELECTED",{storefront:n}),await ma({starter:e,root:y.default.join(t,"backend"),seed:!r,verbose:i.verbose});const s="none"!==n.toLowerCase();if(s){const e=(t=>{switch(t.toLowerCase()){case"gatsby starter":return"https://github.com/medusajs/gatsby-starter-medusa";case"next.js starter":return"https://github.com/medusajs/nextjs-starter-medusa";case"medusa.express (next.js)":return"https://github.com/medusajs/medusa-express-nextjs";case"medusa.express (gatsby)":return"https://github.com/medusajs/medusa-express-gatsby";case"gatsby starter (simple)":return"https://github.com/medusajs/gatsby-starter-medusa-simple";default:return""}})(n);await ma({starter:e,root:y.default.join(t,"storefront"),verbose:i.verbose})}await ma({starter:"https://github.com/medusajs/admin",root:y.default.join(t,"admin"),keepGit:!0,verbose:i.verbose}),console.log(`\n Your project is ready 🚀. The available commands are:\n \n Medusa API\n cd ${t}/backend\n yarn start\n\n Admin\n cd ${t}/admin\n yarn start\n `),s&&console.log(`\n Storefront\n cd ${t}/storefront\n yarn start\n `)};
1
+ var t=require("path"),e=require("events"),i=require("child_process"),r=require("fs"),n=require("assert"),s=require("readline"),o=require("os"),a=require("buffer"),l=require("stream"),c=require("util"),u=require("constants"),h=require("url"),d=require("crypto"),p=require("http"),f=require("https"),m=require("zlib");function g(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var y=g(t),b=g(e),w=g(i),v=g(r),S=g(n),E=g(s),x=g(o),_=g(a),O=g(l),C=g(c),k=g(u),$=g(h),j=g(d),A=g(p),P=g(f),T=g(m),I="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function N(t){var e={exports:{}};return t(e,e.exports),e.exports}class F 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}}var R={CommanderError:F,InvalidArgumentError:class extends F{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}};const{InvalidArgumentError:L}=R;var D={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,this.parseArg=(e,i)=>{if(!t.includes(e))throw new L(`Allowed choices are ${t.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},humanReadableArgName:function(t){const e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"}};const{humanReadableArgName:B}=D;var M={Help:class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1}visibleCommands(t){const e=t.commands.filter(t=>!t._hidden);if(t._hasImplicitHelpCommand()){const[,i,r]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),n=t.createCommand(i).helpOption(!1);n.description(t._helpCommandDescription),r&&n.arguments(r),e.push(n)}return this.sortSubcommands&&e.sort((t,e)=>t.name().localeCompare(e.name())),e}visibleOptions(t){const e=t.options.filter(t=>!t.hidden),i=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag),r=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(i||r){let n;n=t.createOption(i?r?t._helpFlags:t._helpShortFlag:t._helpLongFlag,t._helpDescription),e.push(n)}if(this.sortOptions){const t=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");e.sort((e,i)=>t(e).localeCompare(t(i)))}return e}visibleArguments(t){return t._argsDescription&&t._args.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t._args.find(t=>t.description)?t._args:[]}subcommandTerm(t){const e=t._args.map(t=>B(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,e.subcommandTerm(i).length),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((t,i)=>Math.max(t,e.optionTerm(i).length),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((t,i)=>Math.max(t,e.argumentTerm(i).length),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.description()}optionDescription(t){const e=[];return t.argChoices&&!t.negate&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0===t.defaultValue||t.negate||e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),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),r=e.helpWidth||80;function n(t,n){if(n){const s=`${t.padEnd(i+2)}${n}`;return e.wrap(s,r-2,i+2)}return t}function s(t){return t.join("\n").replace(/^/gm," ".repeat(2))}let o=[`Usage: ${e.commandUsage(t)}`,""];const a=e.commandDescription(t);a.length>0&&(o=o.concat([a,""]));const l=e.visibleArguments(t).map(t=>n(e.argumentTerm(t),e.argumentDescription(t)));l.length>0&&(o=o.concat(["Arguments:",s(l),""]));const c=e.visibleOptions(t).map(t=>n(e.optionTerm(t),e.optionDescription(t)));c.length>0&&(o=o.concat(["Options:",s(c),""]));const u=e.visibleCommands(t).map(t=>n(e.subcommandTerm(t),e.subcommandDescription(t)));return u.length>0&&(o=o.concat(["Commands:",s(u),""])),o.join("\n")}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,i,r=40){if(t.match(/[\n]\s+/))return t;const n=e-i;if(n<r)return t;const s=t.substr(0,i),o=t.substr(i),a=" ".repeat(i),l=new RegExp(".{1,"+(n-1)+"}([\\s​]|$)|[^\\s​]+?([\\s​]|$)","g");return s+(o.match(l)||[]).map((t,e)=>("\n"===t.slice(-1)&&(t=t.slice(0,t.length-1)),(e>0?a:"")+t.trimRight())).join("\n")}}};const{InvalidArgumentError:G}=R;function H(t){let e,i;const r=t.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),i=r.shift(),!e&&/^-[^-]$/.test(i)&&(e=i,i=void 0),{shortFlag:e,longFlag:i}}var U={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=H(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.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=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,this.parseArg=(e,i)=>{if(!t.includes(e))throw new G(`Allowed choices are ${t.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.name().replace(/^no-/,"").split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}is(t){return this.short===t||this.long===t}},splitOptionFlags:H},q={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 r=[],n=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 r=1;r<=e.length;r++)for(let n=1;n<=t.length;n++){let s=1;s=t[n-1]===e[r-1]?0:1,i[n][r]=Math.min(i[n-1][r]+1,i[n][r-1]+1,i[n-1][r-1]+s),n>1&&r>1&&t[n-1]===e[r-2]&&t[n-2]===e[r-1]&&(i[n][r]=Math.min(i[n][r],i[n-2][r-2]+1))}return i[t.length][e.length]}(t,e),s=Math.max(t.length,e.length);(s-i)/s>.4&&(i<n?(n=i,r=[e]):i===n&&r.push(e))}),r.sort((t,e)=>t.localeCompare(e)),i&&(r=r.map(t=>`--${t}`)),r.length>1?`\n(Did you mean one of ${r.join(", ")}?)`:1===r.length?`\n(Did you mean ${r[0]}?)`:""}};const V=b.default.EventEmitter,{Argument:W,humanReadableArgName:z}=D,{CommanderError:Y}=R,{Help:K}=M,{Option:J,splitOptionFlags:X}=U,{suggestSimilar:Z}=q;class Q extends V{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this._args=[],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._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!1,this._outputConfiguration={writeOut:t=>process.stdout.write(t),writeErr:t=>process.stderr.write(t),getOutHelpWidth:()=>process.stdout.isTTY?process.stdout.columns:void 0,getErrHelpWidth:()=>process.stderr.isTTY?process.stderr.columns:void 0,outputError:(t,e)=>e(t)},this._hidden=!1,this._hasHelpOption=!0,this._helpFlags="-h, --help",this._helpDescription="display help for command",this._helpShortFlag="-h",this._helpLongFlag="--help",this._addImplicitHelpCommand=void 0,this._helpCommandName="help",this._helpCommandnameAndArgs="help [command]",this._helpCommandDescription="display help for command",this._helpConfiguration={}}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._hasHelpOption=t._hasHelpOption,this._helpFlags=t._helpFlags,this._helpDescription=t._helpDescription,this._helpShortFlag=t._helpShortFlag,this._helpLongFlag=t._helpLongFlag,this._helpCommandName=t._helpCommandName,this._helpCommandnameAndArgs=t._helpCommandnameAndArgs,this._helpCommandDescription=t._helpCommandDescription,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}command(t,e,i){let r=e,n=i;"object"==typeof r&&null!==r&&(n=r,r=null),n=n||{};const[,s,o]=t.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return r&&(a.description(r),a._executableHandler=!0),n.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!n.noHelp&&!n.hidden),a._executableFile=n.executableFile||null,o&&a.arguments(o),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),r?this:a}createCommand(t){return new Q(t)}createHelp(){return Object.assign(new K,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");return function t(e){e.forEach(e=>{if(e._executableHandler&&!e._executableFile)throw new Error(`Must specify executableFile for deeply nested executable: ${e.name()}`);t(e.commands)})}(t.commands),(e=e||{}).isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this.commands.push(t),t.parent=this,this}createArgument(t,e){return new W(t,e)}argument(t,e,i,r){const n=this.createArgument(t,e);return"function"==typeof i?n.default(r).argParser(i):n.default(i),this.addArgument(n),this}arguments(t){return t.split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(t){const e=this._args.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._args.push(t),this}addHelpCommand(t,e){return!1===t?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,"string"==typeof t&&(this._helpCommandName=t.split(" ")[0],this._helpCommandnameAndArgs=t),this._helpCommandDescription=e||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return void 0===this._addImplicitHelpCommand?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(t,e){const i=["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 Y(t,e,i)),process.exit(t)}action(t){return this._actionHandler=e=>{const i=this._args.length,r=e.slice(0,i);return r[i]=this._storeOptionsAsProperties?this:this.opts(),r.push(this),t.apply(this,r)},this}createOption(t,e){return new J(t,e)}addOption(t){const e=t.name(),i=t.attributeName();let r=t.defaultValue;if(t.negate||t.optional||t.required||"boolean"==typeof r){if(t.negate){const e=t.long.replace(/^--no-/,"--");r=!this._findOption(e)||this.getOptionValue(i)}void 0!==r&&this.setOptionValueWithSource(i,r,"default")}this.options.push(t);const n=(e,n,s)=>{const o=this.getOptionValue(i);if(null!==e&&t.parseArg)try{e=t.parseArg(e,void 0===o?r:o)}catch(t){throw"commander.invalidArgument"===t.code&&this._displayError(t.exitCode,t.code,`${n} ${t.message}`),t}else null!==e&&t.variadic&&(e=t._concatValue(e,o));"boolean"==typeof o||void 0===o?this.setOptionValueWithSource(i,null==e?!t.negate&&(r||!0):e,s):null!==e&&this.setOptionValueWithSource(i,!t.negate&&e,s)};return this.on("option:"+e,e=>{n(e,`error: option '${t.flags}' argument '${e}' is invalid.`,"cli")}),t.envVar&&this.on("optionEnv:"+e,e=>{n(e,`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`,"env")}),this}_optionEx(t,e,i,r,n){const s=this.createOption(e,i);if(s.makeOptionMandatory(!!t.mandatory),"function"==typeof r)s.default(n).argParser(r);else if(r instanceof RegExp){const t=r;r=(e,i)=>{const r=t.exec(e);return r?r[0]:i},s.default(n).argParser(r)}else s.default(r);return this.addOption(s)}option(t,e,i,r){return this._optionEx({},t,e,i,r)}requiredOption(t,e,i,r){return this._optionEx({mandatory:!0},t,e,i,r)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){if(this._passThroughOptions=!!t,this.parent&&t&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(t=!0){if(this._storeOptionsAsProperties=!!t,this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this}setOptionValueWithSource(t,e,i){return this.setOptionValue(t,e),this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}_prepareUserArgs(t,e){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");let i;switch(e=e||{},void 0===t&&(t=process.argv,process.versions&&process.versions.electron&&(e.from="electron")),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":process.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._scriptPath&&require.main&&(this._scriptPath=require.main.filename),this._name=this._name||this._scriptPath&&y.default.basename(this._scriptPath,y.default.extname(this._scriptPath)),i}parse(t,e){const i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){const i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),this}_executeSubCommand(t,e){e=e.slice();let i=!1;const r=[".js",".ts",".tsx",".mjs",".cjs"];this._checkForMissingMandatoryOptions();let n,s=this._scriptPath;!s&&require.main&&(s=require.main.filename);try{const t=v.default.realpathSync(s);n=y.default.dirname(t)}catch(t){n="."}let o=y.default.basename(s,y.default.extname(s))+"-"+t._name;t._executableFile&&(o=t._executableFile);const a=y.default.join(n,o);let l;v.default.existsSync(a)?o=a:r.forEach(t=>{v.default.existsSync(`${a}${t}`)&&(o=`${a}${t}`)}),i=r.includes(y.default.extname(o)),"win32"!==process.platform?i?(e.unshift(o),e=et(process.execArgv).concat(e),l=w.default.spawn(process.argv[0],e,{stdio:"inherit"})):l=w.default.spawn(o,e,{stdio:"inherit"}):(e.unshift(o),e=et(process.execArgv).concat(e),l=w.default.spawn(process.execPath,e,{stdio:"inherit"})),["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(t=>{process.on(t,()=>{!1===l.killed&&null===l.exitCode&&l.kill(t)})});const c=this._exitCallback;l.on("close",c?()=>{c(new Y(process.exitCode||0,"commander.executeSubCommandAsync","(close)"))}:process.exit.bind(process)),l.on("error",e=>{if("ENOENT"===e.code)throw new Error(`'${o}' does not exist\n - if '${t._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name`);if("EACCES"===e.code)throw new Error(`'${o}' not executable`);if(c){const t=new Y(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,c(t)}else process.exit(1)}),this.runningCommand=l}_dispatchSubcommand(t,e,i){const r=this._findCommand(t);if(r||this.help({error:!0}),!r._executableHandler)return r._parseCommand(e,i);this._executeSubCommand(r,e.concat(i))}_checkNumberOfArguments(){this._args.forEach((t,e)=>{t.required&&null==this.args[e]&&this.missingArgument(t.name())}),this._args.length>0&&this._args[this._args.length-1].variadic||this.args.length>this._args.length&&this._excessArguments(this.args)}_processArguments(){const t=(t,e,i)=>{let r=e;if(null!==e&&t.parseArg)try{r=t.parseArg(e,i)}catch(i){if("commander.invalidArgument"===i.code){const r=`error: command-argument value '${e}' is invalid for argument '${t.name()}'. ${i.message}`;this._displayError(i.exitCode,i.code,r)}throw i}return r};this._checkNumberOfArguments();const e=[];this._args.forEach((i,r)=>{let n=i.defaultValue;i.variadic?r<this.args.length?(n=this.args.slice(r),i.parseArg&&(n=n.reduce((e,r)=>t(i,r,e),i.defaultValue))):void 0===n&&(n=[]):r<this.args.length&&(n=this.args[r],i.parseArg&&(n=t(i,n,i.defaultValue))),e[r]=n}),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 r=[];return it(this).reverse().filter(t=>void 0!==t._lifeCycleHooks[e]).forEach(t=>{t._lifeCycleHooks[e].forEach(e=>{r.push({hookedCommand:t,callback:e})})}),"postAction"===e&&r.reverse(),r.forEach(t=>{i=this._chainOrCall(i,()=>t.callback(t.hookedCommand,this))}),i}_parseCommand(t,e){const i=this.parseOptions(e);if(this._parseOptionsEnv(),t=t.concat(i.operands),this.args=t.concat(e=i.unknown),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._hasImplicitHelpCommand()&&t[0]===this._helpCommandName)return 1===t.length&&this.help(),this._dispatchSubcommand(t[1],[],[this._helpLongFlag]);if(this._defaultCommandName)return tt(this,e),this._dispatchSubcommand(this._defaultCommandName,t,e);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),tt(this,i.unknown),this._checkForMissingMandatoryOptions();const r=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},n=`command:${this.name()}`;if(this._actionHandler){let i;return r(),this._processArguments(),i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,()=>this._actionHandler(this.processedArgs)),this.parent&&this.parent.emit(n,t,e),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(n))r(),this._processArguments(),this.parent.emit(n,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():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),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(){for(let t=this;t;t=t.parent)t.options.forEach(e=>{e.mandatory&&void 0===t.getOptionValue(e.attributeName())&&t.missingMandatoryOptionValue(e)})}parseOptions(t){const e=[],i=[];let r=e;const n=t.slice();function s(t){return t.length>1&&"-"===t[0]}let o=null;for(;n.length;){const t=n.shift();if("--"===t){r===i&&r.push(t),r.push(...n);break}if(!o||s(t)){if(o=null,s(t)){const e=this._findOption(t);if(e){if(e.required){const t=n.shift();void 0===t&&this.optionMissingArgument(e),this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;n.length>0&&!s(n[0])&&(t=n.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()}`),n.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(s(t)&&(r=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===e.length&&0===i.length){if(this._findCommand(t)){e.push(t),n.length>0&&i.push(...n);break}if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){e.push(t),n.length>0&&e.push(...n);break}if(this._defaultCommandName){i.push(t),n.length>0&&i.push(...n);break}}if(this._passThroughOptions){r.push(t),n.length>0&&r.push(...n);break}r.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}_displayError(t,e,i){this._outputConfiguration.outputError(`${i}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0})),this._exit(t,e,i)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in process.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()}`,process.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}missingArgument(t){this._displayError(1,"commander.missingArgument",`error: missing required argument '${t}'`)}optionMissingArgument(t){this._displayError(1,"commander.optionMissingArgument",`error: option '${t.flags}' argument missing`)}missingMandatoryOptionValue(t){this._displayError(1,"commander.missingMandatoryOptionValue",`error: required option '${t.flags}' not specified`)}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[],r=this;do{const t=r.createHelp().visibleOptions(r).filter(t=>t.long).map(t=>t.long);i=i.concat(t),r=r.parent}while(r&&!r._enablePositionalOptions);e=Z(t,i)}this._displayError(1,"commander.unknownOption",`error: unknown option '${t}'${e}`)}_excessArguments(t){if(this._allowExcessArguments)return;const e=this._args.length,i=1===e?"":"s",r=this.parent?` for '${this.name()}'`:"";this._displayError(1,"commander.excessArguments",`error: too many arguments${r}. Expected ${e} argument${i} but got ${t.length}.`)}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=Z(t,i)}this._displayError(1,"commander.unknownCommand",`error: unknown command '${t}'${e}`)}version(t,e,i){if(void 0===t)return this._version;this._version=t;const r=this.createOption(e=e||"-V, --version",i=i||"output the version number");return this._versionOptionName=r.attributeName(),this.options.push(r),this.on("option:"+r.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)}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");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._args.map(t=>z(t));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?t:[]).join(" ")}return this._usage=t,this}name(t){return void 0===t?this._name:(this._name=t,this)}helpInformation(t){const e=this.createHelp();return void 0===e.helpWidth&&(e.helpWidth=t&&t.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),e.formatHelp(this,e)}_getHelpContext(t){const e={error:!!(t=t||{}).error};let i;return i=e.error?t=>this._outputConfiguration.writeErr(t):t=>this._outputConfiguration.writeOut(t),e.write=t.write||i,e.command=this,e}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const i=this._getHelpContext(t);it(this).reverse().forEach(t=>t.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let r=this.helpInformation(i);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.emit(this._helpLongFlag),this.emit("afterHelp",i),it(this).forEach(t=>t.emit("afterAllHelp",i))}helpOption(t,e){if("boolean"==typeof t)return this._hasHelpOption=t,this;this._helpFlags=t||this._helpFlags,this._helpDescription=e||this._helpDescription;const i=X(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(t){this.outputHelp(t);let e=process.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("', '")}'`);return this.on(`${t}Help`,t=>{let i;i="function"==typeof e?e({error:t.error,command:t.command}):e,i&&t.write(`${i}\n`)}),this}}function tt(t,e){t._hasHelpOption&&e.find(e=>e===t._helpLongFlag||e===t._helpShortFlag)&&(t.outputHelp(),t._exit(0,"commander.helpDisplayed","(outputHelp)"))}function et(t){return t.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i,r="127.0.0.1",n="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])?n=i[3]:r=i[3]):null!==(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(e=i[1],r=i[3],n=i[4]),e&&"0"!==n?`${e}=${r}:${parseInt(n)+1}`:t})}function it(t){const e=[];for(let i=t;i;i=i.parent)e.push(i);return e}var rt={Command:Q},nt=N(function(t,e){const{Argument:i}=D,{Command:r}=rt,{CommanderError:n,InvalidArgumentError:s}=R,{Help:o}=M,{Option:a}=U;(e=t.exports=new r).program=e,e.Argument=i,e.Command=r,e.CommanderError=n,e.Help=o,e.InvalidArgumentError=s,e.InvalidOptionArgumentError=s,e.Option=a});function st(){return(st=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t}).apply(this,arguments)}var ot=N(function(t){const e="Hyper"===process.env.TERM_PROGRAM,i="win32"===process.platform,r="linux"===process.platform,n={ballotDisabled:"☒",ballotOff:"☐",ballotOn:"☑",bullet:"•",bulletWhite:"◦",fullBlock:"█",heart:"❤",identicalTo:"≡",line:"─",mark:"※",middot:"·",minus:"-",multiplication:"×",obelus:"÷",pencilDownRight:"✎",pencilRight:"✏",pencilUpRight:"✐",percent:"%",pilcrow2:"❡",pilcrow:"¶",plusMinus:"±",section:"§",starsOff:"☆",starsOn:"★",upDownArrow:"↕"},s=Object.assign({},n,{check:"√",cross:"×",ellipsisLarge:"...",ellipsis:"...",info:"i",question:"?",questionSmall:"?",pointer:">",pointerSmall:"»",radioOff:"( )",radioOn:"(*)",warning:"‼"}),o=Object.assign({},n,{ballotCross:"✘",check:"✔",cross:"✖",ellipsisLarge:"⋯",ellipsis:"…",info:"ℹ",question:"?",questionFull:"?",questionSmall:"﹖",pointer:r?"▸":"❯",pointerSmall:r?"‣":"›",radioOff:"◯",radioOn:"◉",warning:"⚠"});t.exports=i&&!e?s:o,Reflect.defineProperty(t.exports,"common",{enumerable:!1,value:n}),Reflect.defineProperty(t.exports,"windows",{enumerable:!1,value:s}),Reflect.defineProperty(t.exports,"other",{enumerable:!1,value:o})});const at=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,lt=()=>{const t={enabled:!0,visible:!0,styles:{},keys:{}};"FORCE_COLOR"in process.env&&(t.enabled="0"!==process.env.FORCE_COLOR);const e=(t,e,i)=>"function"==typeof t?t(e):t.wrap(e,i),i=(i,r)=>{if(""===i||null==i)return"";if(!1===t.enabled)return i;if(!1===t.visible)return"";let n=""+i,s=n.includes("\n"),o=r.length;for(o>0&&r.includes("unstyle")&&(r=[...new Set(["unstyle",...r])].reverse());o-- >0;)n=e(t.styles[r[o]],n,s);return n},r=(e,r,n)=>{t.styles[e]=(t=>{let e=t.open=`[${t.codes[0]}m`,i=t.close=`[${t.codes[1]}m`,r=t.regex=new RegExp(`\\u001b\\[${t.codes[1]}m`,"g");return t.wrap=(t,n)=>{t.includes(i)&&(t=t.replace(r,i+e));let s=e+t+i;return n?s.replace(/\r*\n/g,`${i}$&${e}`):s},t})({name:e,codes:r}),(t.keys[n]||(t.keys[n]=[])).push(e),Reflect.defineProperty(t,e,{configurable:!0,enumerable:!0,set(i){t.alias(e,i)},get(){let r=t=>i(t,r.stack);return Reflect.setPrototypeOf(r,t),r.stack=this.stack?this.stack.concat(e):[e],r}})};return r("reset",[0,0],"modifier"),r("bold",[1,22],"modifier"),r("dim",[2,22],"modifier"),r("italic",[3,23],"modifier"),r("underline",[4,24],"modifier"),r("inverse",[7,27],"modifier"),r("hidden",[8,28],"modifier"),r("strikethrough",[9,29],"modifier"),r("black",[30,39],"color"),r("red",[31,39],"color"),r("green",[32,39],"color"),r("yellow",[33,39],"color"),r("blue",[34,39],"color"),r("magenta",[35,39],"color"),r("cyan",[36,39],"color"),r("white",[37,39],"color"),r("gray",[90,39],"color"),r("grey",[90,39],"color"),r("bgBlack",[40,49],"bg"),r("bgRed",[41,49],"bg"),r("bgGreen",[42,49],"bg"),r("bgYellow",[43,49],"bg"),r("bgBlue",[44,49],"bg"),r("bgMagenta",[45,49],"bg"),r("bgCyan",[46,49],"bg"),r("bgWhite",[47,49],"bg"),r("blackBright",[90,39],"bright"),r("redBright",[91,39],"bright"),r("greenBright",[92,39],"bright"),r("yellowBright",[93,39],"bright"),r("blueBright",[94,39],"bright"),r("magentaBright",[95,39],"bright"),r("cyanBright",[96,39],"bright"),r("whiteBright",[97,39],"bright"),r("bgBlackBright",[100,49],"bgBright"),r("bgRedBright",[101,49],"bgBright"),r("bgGreenBright",[102,49],"bgBright"),r("bgYellowBright",[103,49],"bgBright"),r("bgBlueBright",[104,49],"bgBright"),r("bgMagentaBright",[105,49],"bgBright"),r("bgCyanBright",[106,49],"bgBright"),r("bgWhiteBright",[107,49],"bgBright"),t.ansiRegex=at,t.hasColor=t.hasAnsi=e=>(t.ansiRegex.lastIndex=0,"string"==typeof e&&""!==e&&t.ansiRegex.test(e)),t.alias=(e,r)=>{let n="string"==typeof r?t[r]:r;if("function"!=typeof n)throw new TypeError("Expected alias to be the name of an existing color (string) or a function");n.stack||(Reflect.defineProperty(n,"name",{value:e}),t.styles[e]=n,n.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(n.stack):n.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=ot,t.define=r,t};var ct=lt();ct.create=lt;var ut=N(function(t,e){const i=Object.prototype.toString;let r=!1,n=[];const s={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};e.longest=(t,e)=>t.reduce((t,i)=>Math.max(t,e?i[e].length:i.length),0),e.hasColor=t=>!!t&&ct.hasColor(t);const o=e.isObject=t=>null!==t&&"object"==typeof t&&!Array.isArray(t);e.nativeType=t=>i.call(t).slice(8,-1).toLowerCase().replace(/\s/g,""),e.isAsyncFn=t=>"asyncfunction"===e.nativeType(t),e.isPrimitive=t=>null!=t&&"object"!=typeof t&&"function"!=typeof t,e.resolve=(t,e,...i)=>"function"==typeof e?e.call(t,...i):e,e.scrollDown=(t=[])=>[...t.slice(1),t[0]],e.scrollUp=(t=[])=>[t.pop(),...t],e.reorder=(t=[])=>{let e=t.slice();return e.sort((t,e)=>t.index>e.index?1:t.index<e.index?-1:0),e},e.swap=(t,e,i)=>{let r=t.length,n=i===r?0:i<0?r-1:i,s=t[e];t[e]=t[n],t[n]=s},e.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},e.height=(t,e=20)=>{let i=t&&t.rows?t.rows:e;return t&&"function"==typeof t.getWindowSize&&(i=t.getWindowSize()[1]),i},e.wordWrap=(t,e={})=>{if(!t)return t;"number"==typeof e&&(e={width:e});let{indent:i="",newline:r="\n"+i,width:n=80}=e,s=(r+i).match(/[^\S\n]/g)||[];n-=s.length;let o=`.{1,${n}}([\\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(n," "))),e.padStart&&(c=c.map(t=>t.padStart(n," "))),i+c.join(r)},e.unmute=t=>{let e=t.stack.find(t=>ct.keys.color.includes(t));return e?ct[e]:t.stack.find(t=>"bg"===t.slice(2))?ct[e.slice(2)]:t=>t},e.pascal=t=>t?t[0].toUpperCase()+t.slice(1):"",e.inverse=t=>{if(!t||!t.stack)return t;let i=t.stack.find(t=>ct.keys.color.includes(t));if(i){let r=ct["bg"+e.pascal(i)];return r?r.black:t}let r=t.stack.find(t=>"bg"===t.slice(0,2));return r?ct[r.slice(2).toLowerCase()]||t:ct.none},e.complement=t=>{if(!t||!t.stack)return t;let i=t.stack.find(t=>ct.keys.color.includes(t)),r=t.stack.find(t=>"bg"===t.slice(0,2));if(i&&!r)return ct[s[i]||i];if(r){let i=r.slice(2).toLowerCase(),n=s[i];return n&&ct["bg"+e.pascal(n)]||t}return ct.none},e.meridiem=t=>{let e=t.getHours(),i=t.getMinutes(),r=e>=12?"pm":"am";return e%=12,(0===e?12:e)+":"+(i<10?"0"+i:i)+" "+r},e.set=(t={},i="",r)=>i.split(".").reduce((t,i,n,s)=>{let o=s.length-1>n?t[i]||{}:r;return!e.isObject(o)&&n<s.length-1&&(o={}),t[i]=o},t),e.get=(t={},e="",i)=>{let r=null==t[e]?e.split(".").reduce((t,e)=>t&&t[e],t):t[e];return null==r?i:r},e.mixin=(t,i)=>{if(!o(t))return i;if(!o(i))return t;for(let r of Object.keys(i)){let n=Object.getOwnPropertyDescriptor(i,r);if(n.hasOwnProperty("value"))if(t.hasOwnProperty(r)&&o(n.value)){let s=Object.getOwnPropertyDescriptor(t,r);o(s.value)?t[r]=e.merge({},t[r],i[r]):Reflect.defineProperty(t,r,n)}else Reflect.defineProperty(t,r,n);else Reflect.defineProperty(t,r,n)}return t},e.merge=(...t)=>{let i={};for(let r of t)e.mixin(i,r);return i},e.mixinEmitter=(t,i)=>{let r=i.constructor.prototype;for(let n of Object.keys(r)){let s=r[n];e.define(t,n,"function"==typeof s?s.bind(i):s)}},e.onExit=t=>{const e=(t,e)=>{r||(r=!0,n.forEach(t=>t()),!0===t&&process.exit(128+e))};0===n.length&&(process.once("SIGTERM",e.bind(null,!0,15)),process.once("SIGINT",e.bind(null,!0,2)),process.once("exit",e)),n.push(t)},e.define=(t,e,i)=>{Reflect.defineProperty(t,e,{value:i})},e.defineExport=(t,e,i)=>{let r;Reflect.defineProperty(t,e,{enumerable:!0,configurable:!0,set(t){r=t},get:()=>r?r():i()})}}),ht={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"},shift:{up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"},fn:{up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"},option:{b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"},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"}};const dt=/^(?:\x1b)([a-zA-Z0-9])$/,pt=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,ft={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"},mt=(t="",e={})=>{let i,r=st({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=r.sequence||""),r.sequence=r.sequence||t||r.name,"\r"===t)r.raw=void 0,r.name="return";else if("\n"===t)r.name="enter";else if("\t"===t)r.name="tab";else if("\b"===t||""===t||""===t||"\b"===t)r.name="backspace",r.meta=""===t.charAt(0);else if(""===t||""===t)r.name="escape",r.meta=2===t.length;else if(" "===t||" "===t)r.name="space",r.meta=2===t.length;else if(t<="")r.name=String.fromCharCode(t.charCodeAt(0)+"a".charCodeAt(0)-1),r.ctrl=!0;else if(1===t.length&&t>="0"&&t<="9")r.name="number";else if(1===t.length&&t>="a"&&t<="z")r.name=t;else if(1===t.length&&t>="A"&&t<="Z")r.name=t.toLowerCase(),r.shift=!0;else if(i=dt.exec(t))r.meta=!0,r.shift=/^[A-Z]$/.test(i[1]);else if(i=pt.exec(t)){let e=[...t];""===e[0]&&""===e[1]&&(r.option=!0);let n=[i[1],i[2],i[4],i[6]].filter(Boolean).join(""),s=(i[3]||i[5]||1)-1;r.ctrl=!!(4&s),r.meta=!!(10&s),r.shift=!!(1&s),r.code=n,r.name=ft[n],r.shift=function(t){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(t)}(n)||r.shift,r.ctrl=function(t){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(t)}(n)||r.ctrl}return r};mt.listen=(t={},e)=>{let{stdin:i}=t;if(!i||i!==process.stdin&&!i.isTTY)throw new Error("Invalid stream passed");let r=E.default.createInterface({terminal:!0,input:i});E.default.emitKeypressEvents(i,r);let n=(t,i)=>e(t,mt(t,i),r),s=i.isRaw;return i.isTTY&&i.setRawMode(!0),i.on("keypress",n),r.resume(),()=>{i.isTTY&&i.setRawMode(s),i.removeListener("keypress",n),r.pause(),r.close()}},mt.action=(t,e,i)=>{let r=st({},ht,i);return e.ctrl?(e.action=r.ctrl[e.name],e):e.option&&r.option?(e.action=r.option[e.name],e):e.shift?(e.action=r.shift[e.name],e):(e.action=r.keys[e.name],e)};var gt=mt;function yt(t,e,i={}){let r=t.timers[e]={name:e,start:Date.now(),ms:0,tick:0},n=i.interval||120;r.frames=i.frames||[],r.loading=!0;let s=setInterval(()=>{r.ms=Date.now()-r.start,r.tick++,t.render()},n);return r.stop=()=>{r.loading=!1,clearInterval(s)},Reflect.defineProperty(r,"interval",{value:s}),t.once("close",()=>r.stop()),r.stop}const{define:bt,width:wt}=ut,vt={default:ct.noop,noop:ct.noop,set inverse(t){this._inverse=t},get inverse(){return this._inverse||ut.inverse(this.primary)},set complement(t){this._complement=t},get complement(){return this._complement||ut.complement(this.primary)},primary:ct.cyan,success:ct.green,danger:ct.magenta,strong:ct.bold,warning:ct.yellow,muted:ct.dim,disabled:ct.gray,dark:ct.dim.gray,underline:ct.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:(t={})=>{t.styles&&"boolean"==typeof t.styles.enabled&&(ct.enabled=t.styles.enabled),t.styles&&"boolean"==typeof t.styles.visible&&(ct.visible=t.styles.visible);let e=ut.merge({},vt,t.styles);delete e.merge;for(let t of Object.keys(ct))e.hasOwnProperty(t)||Reflect.defineProperty(e,t,{get:()=>ct[t]});for(let t of Object.keys(ct.styles))e.hasOwnProperty(t)||Reflect.defineProperty(e,t,{get:()=>ct[t]});return e}};var St=vt;const Et="win32"===process.platform,xt=st({},ct.symbols,{upDownDoubleArrow:"⇕",upDownDoubleArrow2:"⬍",upDownArrow:"↕",asterisk:"*",asterism:"⁂",bulletWhite:"◦",electricArrow:"⌁",ellipsisLarge:"⋯",ellipsisSmall:"…",fullBlock:"█",identicalTo:"≡",indicator:ct.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:ct.symbols.question,submitted:ct.symbols.check,cancelled:ct.symbols.cross},separator:{pending:ct.symbols.pointerSmall,submitted:ct.symbols.middot,cancelled:ct.symbols.middot},radio:{off:Et?"( )":"◯",on:Et?"(*)":"◉",disabled:Et?"(|)":"Ⓘ"},numbers:["⓪","①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩","⑪","⑫","⑬","⑭","⑮","⑯","⑰","⑱","⑲","⑳","㉑","㉒","㉓","㉔","㉕","㉖","㉗","㉘","㉙","㉚","㉛","㉜","㉝","㉞","㉟","㊱","㊲","㊳","㊴","㊵","㊶","㊷","㊸","㊹","㊺","㊻","㊼","㊽","㊾","㊿"]});xt.merge=t=>{let e=ut.merge({},ct.symbols,xt,t.symbols);return delete e.merge,e};var _t=xt,Ot=N(function(t,e){const i="Apple_Terminal"===process.env.TERM_PROGRAM,r=t.exports=e,n="[";let s=!1;const o=r.code={bell:"",beep:"",beginning:"",down:"",esc:n,getPosition:"",hide:"[?25l",line:"",lineEnd:"",lineStart:"",restorePosition:n+(i?"8":"u"),savePosition:n+(i?"7":"s"),screen:"",show:"[?25h",up:""},a=r.cursor={get hidden(){return s},hide:()=>(s=!0,o.hide),show:()=>(s=!1,o.show),forward:(t=1)=>`[${t}C`,backward:(t=1)=>`[${t}D`,nextLine:(t=1)=>"".repeat(t),prevLine:(t=1)=>"".repeat(t),up:(t=1)=>t?`[${t}A`:"",down:(t=1)=>t?`[${t}B`:"",right:(t=1)=>t?`[${t}C`:"",left:(t=1)=>t?`[${t}D`:"",to:(t,e)=>e?`[${e+1};${t+1}H`:`[${t+1}G`,move(t=0,e=0){let i="";return i+=t<0?a.left(-t):t>0?a.right(t):"",i+=e<0?a.up(-e):e>0?a.down(e):"",i},restore(t={}){let{after:e,cursor:i,initial:n,input:s,prompt:o,size:a,value:l}=t;if(n=ut.isPrimitive(n)?String(n):"",s=ut.isPrimitive(s)?String(s):"",l=ut.isPrimitive(l)?String(l):"",a){let t=r.cursor.up(a)+r.cursor.to(o.length),e=s.length-i;return e>0&&(t+=r.cursor.left(e)),t}if(l||e){let t=!s&&n?-n.length:-s.length+i;return e&&(t-=e.length),""===s&&n&&!o.includes(n)&&(t+=n.length),r.cursor.move(t)}}},l=r.erase={screen:o.screen,up:o.up,down:o.down,line:o.line,lineEnd:o.lineEnd,lineStart:o.lineStart,lines(t){let e="";for(let i=0;i<t;i++)e+=r.erase.line+(i<t-1?r.cursor.up(1):"");return t&&(e+=r.code.beginning),e}};r.clear=(t="",e=process.stdout.columns)=>{if(!e)return l.line+a.to(0);let i=t.split(/\r?\n/),r=0;for(let t of i)r+=1+Math.floor(Math.max([...ct.unstyle(t)].length-1,0)/e);return(l.line+a.prevLine()).repeat(r-1)+l.line+a.to(0)}});class Ct extends b.default{constructor(t={}){super(),this.name=t.name,this.type=t.type,this.options=t,(t=>{t.options=ut.merge({},t.options.theme,t.options),t.symbols=_t.merge(t.options),t.styles=St.merge(t.options)})(this),(t=>{t.timers=t.timers||{};let e=t.options.timers;if(e)for(let i of Object.keys(e)){let r=e[i];"number"==typeof r&&(r={interval:r}),yt(t,i,r)}})(this),this.state=new class{constructor(t){let e=t.options;bt(this,"_prompt",t),this.type=t.type,this.name=t.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=wt(e.stdout||process.stdout),Object.assign(this,e),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=t.symbols,this.styles=t.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let t=st({},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"}}(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":" ",r=[];for(let t=0;t<4;t++){let n=i(t);r.push(e[t]?n.repeat(e[t]):"")}return r}(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"],r=["body","footer","error","header","hint","indicator","message","prefix","separator","skip"];for(let n of Object.keys(t.options)){if(i.includes(n))continue;if(/^on[A-Z]/.test(n))continue;let s=t.options[n];"function"==typeof s&&e(n)?r.includes(n)||(t[n]=s.bind(t)):"function"!=typeof t[n]&&(t[n]=s)}}(this)}async keypress(t,e={}){this.keypressed=!0;let i=gt.action(t,gt(t,e),this.options.actions);this.state.keypress=i,this.emit("keypress",t,i),this.emit("state",this.state.clone());let r=this.options[i.action]||this[i.action]||this.dispatch;if("function"==typeof r)return await r.call(this,t,i);this.alert()}alert(){delete this.state.alert,!1===this.options.show?this.emit("alert"):this.stdout.write(Ot.code.beep)}cursorHide(){this.stdout.write(Ot.cursor.hide()),ut.onExit(()=>this.cursorShow())}cursorShow(){this.stdout.write(Ot.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(Ot.cursor.down(t)+Ot.clear(e,this.width))}restore(){if(this.state.closed||!1===this.options.show)return;let{prompt:t,after:e,rest:i}=this.sections(),{cursor:r,initial:n="",input:s="",value:o=""}=this,a=this.state.size=i.length,l=Ot.cursor.restore({after:e,cursor:r,initial:n,input:s,prompt:t,size:a,value:o});l&&this.stdout.write(l)}sections(){let{buffer:t,input:e,prompt:i}=this.state;i=ct.unstyle(i);let r=ct.unstyle(t),n=r.indexOf(i),s=r.slice(0,n),o=r.slice(n).split("\n"),a=o[0],l=o[o.length-1],c=(i+(e?" "+e:"")).length,u=c<a.length?a.slice(c+1):"";return{header:s,prompt:a,after:u,rest:o.slice(1),last:l}}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(Ot.cursor.down(t.rest.length)),this.write("\n".repeat(e))}catch(t){}this.emit("close")}start(){this.stop||!1===this.options.show||(this.stop=gt.listen(this,this.keypress.bind(this)),this.once("close",this.stop))}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:r,state:n,symbols:s,timers:o}=this;n.timer=o&&o[t];let a=r[t]||n[t]||s[t],l=e&&null!=e[t]?e[t]:await a;if(""===l)return l;let c=await this.resolve(l,n,e,i);return!c&&e&&e[t]?this.resolve(a,n,e,i):c}async prefix(){let t=await this.element("prefix")||this.symbols,e=this.state;return e.timer=this.timers&&this.timers.prefix,ut.isObject(t)&&(t=t[e.status]||t.pending),ut.hasColor(t)?t:(this.styles[e.status]||this.styles.pending)(t)}async message(){let t=await this.element("message");return ut.hasColor(t)?t:this.styles.strong(t)}async separator(){let t=await this.element("separator")||this.symbols,e=this.state;e.timer=this.timers&&this.timers.separator;let i=t[e.status]||t.pending||e.separator,r=await this.resolve(i,e);return ut.isObject(r)&&(r=r[e.status]||r.pending),ut.hasColor(r)?r:this.styles.muted(r)}async pointer(t,e){let i=await this.element("pointer",t,e);if("string"==typeof i&&ut.hasColor(i))return i;if(i){let t=this.styles,r=this.index===e,n=r?t.primary:t=>t,s=await this.resolve(i[r?"on":"off"]||i,this.state),o=ut.hasColor(s)?s:n(s);return r?o:" ".repeat(s.length)}}async indicator(t,e){let i=await this.element("indicator",t,e);if("string"==typeof i&&ut.hasColor(i))return i;if(i){let e=this.styles,r=!0===t.enabled,n=r?e.success:e.dark,s=i[r?"on":"off"]||i;return ut.hasColor(s)?s:n(s)}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 ut.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 ut.resolve(this,t,...e)}get base(){return Ct.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||ut.height(this.stdout,25)}get width(){return this.options.columns||ut.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()}}var kt=Ct;const $t={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,e)=>$t.default(t,e),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},{reorder:jt,scrollUp:At,scrollDown:Pt,isObject:Tt,swap:It}=ut;function Nt(t,e){if(e instanceof Promise)return e;if("function"==typeof e){if(ut.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}var Ft=class extends kt{constructor(t){super(t),this.cursorHide(),this.maxSelected=t.maxSelected||Infinity,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:r}=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 r&&0===this.selectable.length)throw new Error("At least one choice must be selectable");Tt(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=[],r=0,n=async(t,e)=>{"function"==typeof t&&(t=await t.call(this)),t instanceof Promise&&(t=await t);for(let s=0;s<t.length;s++){let o=t[s]=await this.toChoice(t[s],r++,e);i.push(o),o.choices&&await n(o.choices,o)}return i};return n(t,e).then(t=>(this.state.loadingChoices=!1,t))}async toChoice(t,e,i){if("function"==typeof t&&(t=await t.call(this,this)),t instanceof Promise&&(t=await t),"string"==typeof t&&(t={name:t}),t.normalized)return t;t.normalized=!0;let r=t.value,n=((t,e={})=>{let i=ut.merge({},$t,e.roles);return i[t]||i.default})(t.role,this.options);if("string"!=typeof(t=n(this,t)).disabled||t.hint||(t.hint=t.disabled,t.disabled=!0),!0===t.disabled&&null==t.hint&&(t.hint="(disabled)"),null!=t.index)return t;t.name=t.name||t.key||t.title||t.value||t.message,t.message=t.message||t.name||"",t.value=[t.value,t.name].find(this.isValue.bind(this)),t.input="",t.index=e,t.cursor=0,ut.define(t,"parent",i),t.level=i?i.level+1:1,null==t.indent&&(t.indent=i?i.indent+" ":t.indent||""),t.path=i?i.path+"."+t.name:t.name,t.enabled=!(!this.multiple||this.isDisabled(t)||!t.enabled&&!this.isSelected(t)),this.isDisabled(t)||(this.longest=Math.max(this.longest,ct.unstyle(t.message).length));let s=st({},t);return t.reset=(e=s.input,i=s.value)=>{for(let e of Object.keys(s))t[e]=s[e];t.input=e,t.value=i},null==r&&"function"==typeof t.initial&&(t.input=await t.initial.call(this,this.state,t,e)),t}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 r=await this.toChoice(t,e,i);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(t,e,i){let r=st({name:"New choice name?",editable:!0,newChoice:!0},t),n=await this.addChoice(r,e,i);return n.updateChoice=()=>{delete n.newChoice,n.name=n.message=n.input,n.input="",n.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.toggle(this.focused),this.render()):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(t=this.focused){return this.choices.some(t=>!!t.parent)?(this.toggle(t.parent&&!t.choices?t.parent:t),this.render()):this.a()}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 Nt(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,r=this.choices.find(t=>e===t.index);if(!r.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(-1===this.visible.indexOf(r)){let t=jt(this.choices),e=t.indexOf(r);if(i.index>e){let i=t.slice(e,e+this.limit),r=t.filter(t=>!i.includes(t));this.choices=i.concat(r)}else{let i=e-this.limit+1;this.choices=t.slice(i).concat(t.slice(0,i))}}return this.index=this.choices.indexOf(r),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise(t=>{let i=this.choices.length,r=this.num,n=(i=!1,n)=>{clearTimeout(this.numberTimeout),i&&(n=e(r)),this.num="",t(n)};return"0"===r||1===r.length&&Number(r+"0")>i?n(!0):Number(r)>i?n(!1,this.alert()):void(this.numberTimeout=setTimeout(()=>n(!0),this.delay))})}home(){return this.choices=jt(this.choices),this.index=0,this.render()}end(){let t=this.choices.length-this.limit,e=jt(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.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.down():this.render())}scrollUp(t=0){return this.choices=At(this.choices),this.index=t,this.isDisabled()?this.up():this.render()}scrollDown(t=this.visible.length-1){return this.choices=Pt(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){It(this.choices,this.index,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=(this.options.multiple?this.state._choices:this.choices).filter("function"==typeof t?t:(e,i)=>[e.name,i].includes(t));return e?i.map(t=>t[e]):i}find(t,e){if(Tt(t))return e?t[e]:t;let i=this.choices.find("function"==typeof t?t:(e,i)=>[e.name,i].includes(t));return i?e?i[e]:i: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=ut.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 Nt(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;return Math.min(t.limit||this._limit||e.limit||i.length,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}},Rt=class extends Ft{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,e){let i=this.resolve(t.message,this.state,t,e);return"heading"!==t.role||ut.hasColor(i)||(i=this.styles.strong(i)),this.resolve(i,this.state,t,e)}choiceSeparator(){return":"}async renderChoice(t,e){await this.onChoice(t,e);let i=this.index===e,r=await this.pointer(t,e),n=await this.indicator(t,e)+(t.pad||""),s=await this.resolve(t.hint,this.state,t,e);s&&!ut.hasColor(s)&&(s=this.styles.muted(s));let o=this.indent(t),a=await this.choiceMessage(t,e),l=()=>[this.margin[3],o+r+n,a,this.margin[1],s].filter(Boolean).join(" ");return"heading"===t.role?l():t.disabled?(ut.hasColor(a)||(a=this.styles.disabled(a)),l()):(i&&(a=this.styles.em(a)),l())}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,r=this.margin[0]+e.join("\n");return this.options.choicesHeader&&(i=await this.resolve(this.options.choicesHeader,this.state)),[i,r].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="",r=await this.header(),n=await this.prefix(),s=await this.separator(),o=await this.message();!1!==this.options.promptLine&&(i=[n,o,s,""].join(" "),this.state.prompt=i);let a=await this.format(),l=await this.error()||await this.hint(),c=await this.renderChoices(),u=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([r,i,c,u].filter(Boolean).join("\n")),this.write(this.margin[2]),this.restore()}},Lt=class extends Rt{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();let t=((t,e)=>{let i=this.input.toLowerCase();return t=>{let r=t.toLowerCase().indexOf(i),n=e(t.slice(r,r+i.length));return r>=0?t.slice(0,r)+n+t.slice(r+i.length):t}})(0,this.options.highlight?this.options.highlight.bind(this):this.styles.placeholder),e=this.choices;this.choices=e.map(e=>st({},e,{message:t(e.message)})),await super.render(),this.choices=e}submit(){return this.options.multiple&&(this.value=this.selected.map(t=>t.name)),super.submit()}},Dt=(t,e={})=>{t.cursorHide();let{input:i="",initial:r="",pos:n,showCursor:s=!0,color:o}=e,a=o||t.styles.placeholder,l=ut.inverse(t.styles.primary),c=e=>l(t.styles.black(e)),u=i,h=c(" ");if(t.blink&&!0===t.blink.off&&(c=t=>t,h=""),s&&0===n&&""===r&&""===i)return c(" ");if(s&&0===n&&(i===r||""===i))return c(r[0])+a(r.slice(1));r=ut.isPrimitive(r)?`${r}`:"",i=ut.isPrimitive(i)?`${i}`:"";let d=r&&r.startsWith(i)&&r!==i,p=d?c(r[i.length]):h;if(n!==i.length&&!0===s&&(u=i.slice(0,n)+c(i[n])+i.slice(n+1),p=""),!1===s&&(p=""),d){let e=t.styles.unstyle(u+p);return u+p+a(r.slice(e.length))}return u+p},Bt=class extends Rt{constructor(t){super(st({},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:r}=e;return e.value=e.input=r.slice(0,i)+t+r.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 r=`${i}`.slice(0,e)+`${i}`.slice(e+1);return t.value=t.input=r,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(t,e){await this.onChoice(t,e);let{state:i,styles:r}=this,{cursor:n,initial:s="",name:o,hint:a,input:l=""}=t,{muted:c,submitted:u,primary:h,danger:d}=r,p=a,f=this.index===e,m=t.validate||(()=>!0),g=await this.choiceSeparator(t,e),y=t.message;"right"===this.align&&(y=y.padStart(this.longest+1," ")),"left"===this.align&&(y=y.padEnd(this.longest+1," "));let b=this.values[o]=l||s,w=l?"success":"dark";!0!==await m.call(t,b,this.state)&&(w="danger");let v=(0,r[w])(await this.indicator(t,e))+(t.pad||""),S=this.indent(t),E=()=>[S,v,y+g,l,p].filter(Boolean).join(" ");return i.submitted?(y=ct.unstyle(y),l=u(l),p="",E()):(l=t.format?await t.format.call(this,l,t,e):Dt(this,{input:l,initial:s,pos:n,showCursor:f,color:this.styles.muted}),this.isValue(l)||(l=this.styles.muted(this.symbols.ellipsis)),t.result&&(this.values[o]=await t.result.call(this,b,t,e)),f&&(y=h(y)),t.error?l+=(l?" ":"")+d(t.error.trim()):t.hint&&(l+=(l?" ":"")+c(t.hint.trim())),E())}async submit(){return this.value=this.values,super.base.submit.call(this)}};const Mt=()=>{throw new Error("expected prompt to have a custom authenticate method")},Gt=(t=Mt)=>class extends Bt{constructor(t){super(t)}async submit(){this.value=await t.call(this,this.values,this.state),super.base.submit.call(this)}static create(t){return Gt(t)}};var Ht=Gt();function Ut(t,e){return t.username===this.options.username&&t.password===this.options.password}const qt=(t=Ut)=>{const e=[{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 i extends(Ht.create(t)){constructor(t){super(st({},t,{choices:e}))}static create(t){return qt(t)}}return i};var Vt=qt();const{isPrimitive:Wt,hasColor:zt}=ut;var Yt=class extends kt{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 Wt(t)&&(this.isTrue(t)||this.isFalse(t))}async hint(){if("pending"===this.state.status){let t=await this.element("hint");return zt(t)?t:this.styles.muted(t)}}async render(){let{input:t,size:e}=this.state,i=await this.prefix(),r=await this.separator(),n=[i,await this.message(),this.styles.muted(this.default),r].filter(Boolean).join(" ");this.state.prompt=n;let s=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&&!n.includes(l)&&(a+=" "+l),n+=" "+a,this.clear(e),this.write([s,n,c].filter(Boolean).join("\n")),this.restore()}set value(t){super.value=t}get value(){return this.cast(super.value)}},Kt=class extends Yt{constructor(t){super(t),this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}};const Jt=Bt.prototype;var Xt=class extends Rt{constructor(t){super(st({},t,{multiple:!0})),this.align=[this.options.align,"left"].find(t=>null!=t),this.emptyError="",this.values={}}dispatch(t,e){let i=this.focused;return i.editable||(i.parent||{}).editable||"a"!==t&&"i"!==t?Jt.dispatch.call(this,t,e):super[t]()}append(t,e){return Jt.append.call(this,t,e)}delete(t,e){return Jt.delete.call(this,t,e)}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?Jt.next.call(this):super.next()}prev(){return this.focused.editable?Jt.prev.call(this):super.prev()}async indicator(t,e){let i=t.editable?t.indicator||"":super.indicator(t,e);return await this.resolve(i,this.state,t,e)||""}indent(t){return"heading"===t.role?"":t.editable?" ":" "}async renderChoice(t,e){return t.indent="",t.editable?Jt.renderChoice.call(this,t,e):super.renderChoice(t,e)}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)}};const{isPrimitive:Zt}=ut;var Qt=class extends kt{constructor(t){super(t),this.initial=Zt(this.initial)?String(this.initial):"",this.initial&&this.cursorHide(),this.state.prevCursor=0,this.state.clipboard=[]}async keypress(t,e={}){let i=this.state.prevKeypress;return this.state.prevKeypress=e,!0!==this.options.multiline||"return"!==e.name||i&&"return"===i.name?super.keypress(t,e):this.append("\n",e)}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),r=e.split(" ");this.state.clipboard.push(r.pop()),this.input=r.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):Dt(this,{input:t,initial:e,pos:this.cursor})}async render(){let t=this.state.size,e=await this.prefix(),i=await this.separator(),r=[e,await this.message(),i].filter(Boolean).join(" ");this.state.prompt=r;let n=await this.header(),s=await this.format(),o=await this.error()||await this.hint(),a=await this.footer();o&&!s.includes(o)&&(s+=" "+o),r+=" "+s,this.clear(t),this.write([n,r,a].filter(Boolean).join("\n")),this.restore()}};const te=t=>(t=>t.filter((e,i)=>t.lastIndexOf(e)===i))(t).filter(Boolean);var ee=(t,e={},i="")=>{let r,n,{past:s=[],present:o=""}=e;switch(t){case"prev":case"undo":return r=s.slice(0,s.length-1),n=s[s.length-1]||"",{past:te([i,...r]),present:n};case"next":case"redo":return r=s.slice(1),n=s[0]||"",{past:te([...r,i]),present:n};case"save":return{past:te([...s,i]),present:""};case"remove":return n=te(s.filter(t=>t!==i)),o="",n.length&&(o=n.pop()),{past:n,present:o};default:throw new Error(`Invalid action: "${t}"`)}},ie=class extends Qt{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=ee(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=ee("save",this.data,this.input),this.store.set("values",this.data))}submit(){return this.store&&!0===this.autosave&&this.save(),super.submit()}},re=class extends Qt{format(){return""}},ne=class extends Qt{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(){return this.list.map(this.state.submitted?this.styles.primary:t=>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()}},se=class extends Rt{constructor(t){super(st({},t,{multiple:!0}))}},oe=class extends Qt{constructor(t={}){super(st({style:"number"},t)),this.min=this.isValue(t.min)?this.toNumber(t.min):-Infinity,this.max=this.isValue(t.max)?this.toNumber(t.max):Infinity,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()}},ae=oe,le=class extends Qt{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)):""}},ce=class extends Ft{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,r=Math.round(i/(e.length-1)),n=e.map(t=>this.styles.strong(t)).join(" ".repeat(r)),s=" ".repeat(this.widths[0]);return this.margin[3]+s+this.margin[1]+n}scaleIndicator(t,e,i){if("function"==typeof this.options.scaleIndicator)return this.options.scaleIndicator.call(this,t,e,i);let r=t.scaleIndex===e.index;return e.disabled?this.styles.hint(this.symbols.radio.disabled):r?this.styles.success(this.symbols.radio.on):this.symbols.radio.off}renderScale(t,e){return t.scale.map(i=>this.scaleIndicator(t,i,e)).join(("Hyper"===this.term?"":" ")+this.symbols.line.repeat(this.edgeLength))}async renderChoice(t,e){await this.onChoice(t,e);let i=this.index===e,r=await this.pointer(t,e),n=await t.hint;n&&!ut.hasColor(n)&&(n=this.styles.muted(n));let s=t=>this.margin[3]+t.replace(/\s+$/,"").padEnd(this.widths[0]," "),o=this.newline,a=this.indent(t),l=await this.resolve(t.message,this.state,t,e),c=await this.renderScale(t,e),u=this.margin[1]+this.margin[3];this.scaleLength=ct.unstyle(c).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-u.length);let h=ut.wordWrap(l,{width:this.widths[0],newline:o}).split("\n").map(t=>s(t)+this.margin[1]);return i&&(c=this.styles.info(c),h=h.map(t=>this.styles.info(t))),h[0]+=c,this.linebreak&&h.push(""),[a+r,h.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(),r=await this.separator(),n=await this.message(),s="";!1!==this.options.promptLine&&(s=[i,n,r,""].join(" "),this.state.prompt=s);let o=await this.header(),a=await this.format(),l=await this.renderScaleKey(),c=await this.error()||await this.hint(),u=await this.renderChoices(),h=await this.footer(),d=this.emptyError;a&&(s+=a),c&&!s.includes(c)&&(s+=" "+c),t&&!a&&!u.trim()&&this.multiple&&null!=d&&(s+=this.styles.danger(d)),this.clear(e),this.write([o,s,l,u,h].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)}};class ue{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 he(t,e,i,r){return(i,n,s,o)=>"function"==typeof s.field[t]?s.field[t].call(e,i,n,s,o):[r,i].find(t=>e.isValue(t))}var de=class extends kt{constructor(t){super(t),this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await(async t=>{let e=t.options,i=new Set(!0===e.required?[]:e.required||[]),r=st({},e.values,e.initial),{tabstops:n,items:s,keys:o}=await(async(t={},e={},i=(t=>t))=>{let r=new Set,n=t.fields||[],s=t.template,o=[],a=[],l=[],c=1;"function"==typeof s&&(s=await s());let u=-1,h=()=>s[++u],d=()=>s[u+1],p=t=>{t.line=c,o.push(t)};for(p({type:"bos",value:""});u<s.length-1;){let t=h();if(/^[^\S\n ]$/.test(t)){p({type:"text",value:t});continue}if("\n"===t){p({type:"newline",value:t}),c++;continue}if("\\"===t){t+=h(),p({type:"text",value:t});continue}if(("$"===t||"#"===t||"{"===t)&&"{"===d()){t+=h();let s,o={type:"template",open:t,inner:"",close:"",value:t};for(;s=h();){if("}"===s){"}"===d()&&(s+=h()),o.value+=s,o.close=s;break}":"===s?(o.initial="",o.key=o.inner):void 0!==o.initial&&(o.initial+=s),o.value+=s,o.inner+=s}o.template=o.open+(o.initial||o.inner)+o.close,o.key=o.key||o.inner,e.hasOwnProperty(o.key)&&(o.initial=e[o.key]),o=i(o),p(o),l.push(o.key),r.add(o.key);let c=a.find(t=>t.name===o.key);o.field=n.find(t=>t.name===o.key),c||(c=new ue(o),a.push(c)),c.lines.push(o.line-1);continue}let s=o[o.length-1];"text"===s.type&&s.line===c?s.value+=t:p({type:"text",value:t})}return p({type:"eos",value:""}),{input:s,tabstops:o,unique:r,keys:l,items:a}})(e,r),a=he("result",t),l=he("format",t),c=he("validate",t,0,!0),u=t.isValue.bind(t);return async(r={},h=!1)=>{let d=0;r.required=i,r.items=s,r.keys=o,r.output="";let p=async(t,e,i,r)=>{let n=await c(t,e,i,r);return!1===n?"Invalid field "+i.name:n};for(let i of n){let n=i.value,o=i.key;if("template"===i.type){if("template"===i.type){let c=s.find(t=>t.name===o);!0===e.required&&r.required.add(c.name);let f=[c.input,r.values[c.value],c.value,n].find(u),m=(c.field||{}).message||i.inner;if(h){let t=await p(r.values[o],r,c,d);if(t&&"string"==typeof t||!1===t){r.invalid.set(o,t);continue}r.invalid.delete(o);let e=await a(r.values[o],r,c,d);r.output+=ct.unstyle(e);continue}c.placeholder=!1;let g=n;n=await l(n,r,c,d),f!==n?(r.values[o]=f,n=t.styles.typing(f),r.missing.delete(m)):(r.values[o]=void 0,f=`<${m}>`,n=t.styles.primary(f),c.placeholder=!0,r.required.has(o)&&r.missing.add(m)),r.missing.has(m)&&r.validating&&(n=t.styles.warning(f)),r.invalid.has(o)&&r.validating&&(n=t.styles.danger(f)),d===r.index&&(n=g!==n?t.styles.underline(n):t.styles.heading(ct.unstyle(n))),d++}n&&(r.output+=n)}else n&&(r.output+=n)}let f=r.output.split("\n").map(t=>" "+t),m=s.length,g=0;for(let e of s)r.invalid.has(e.name)&&e.lines.forEach(t=>{" "===f[t][0]&&(f[t]=r.styles.danger(r.symbols.bullet)+f[t].slice(1))}),t.isValue(r.values[e.name])&&g++;return r.completed=(g/m*100).toFixed(0),r.output=f.join("\n"),r.output}})(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(),r=i.input.slice(0,this.cursor),n=i.input.slice(this.cursor);this.input=i.input=`${r}${t}${n}`,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:r}=this.state,n=[this.options.newline,"\n"].find(t=>null!=t),s=await this.prefix(),o=await this.separator(),a=[s,await this.message(),o].filter(Boolean).join(" ");this.state.prompt=a;let l=await this.header(),c=await this.error()||"",u=await this.hint()||"",h=i?"":await this.interpolate(this.state),d=this.state.key=e[t]||"",p=await this.format(d),f=await this.footer();p&&(a+=" "+p),u&&!p&&0===this.state.completed&&(a+=" "+u),this.clear(r);let m=[l,a,h,f,c.trim()];this.write(m.filter(Boolean).join(n)),this.restore()}getItem(t){let{items:e,keys:i,index:r}=this.state,n=e.find(t=>t.name===i[r]);return n&&null!=n.input&&(this.input=n.input,this.cursor=n.cursor),n}async submit(){"function"!=typeof this.interpolate&&await this.initialize(),await this.interpolate(this.state,!0);let{invalid:t,missing:e,output:i,values:r}=this.state;if(t.size){let e="";for(let[i,r]of t)e+=`Invalid ${i}: ${r}\n`;return this.state.error=e,super.submit()}if(e.size)return this.state.error="Required: "+[...e.keys()].join(", "),super.submit();let n=ct.unstyle(i).split("\n").map(t=>t.slice(1)).join("\n");return this.value={values:r,result:n},super.submit()}};const pe="(Use <shift>+<up/down> to sort)";var fe=class extends Rt{constructor(t){super(st({},t,{reorder:!1,sort:!0,multiple:!0})),this.state.hint=[this.options.hint,pe].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(t,e){let i=await super.renderChoice(t,e),r=this.index===e&&this.sorting?this.styles.muted(this.symbols.identicalTo+" "):" ";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()}};function me(t,e={}){if(Array.isArray(e.scale))return e.scale.map(t=>st({},t));let i=[];for(let e=1;e<t+1;e++)i.push({i:e,selected:!1});return i}var ge=class extends Ft{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 e=await super.toChoices(...t);for(let t of e)t.scale=me(5,this.options),t.scaleIdx=2;return e}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,r="Hyper"===this.term,n=r?9:8,s=r?"":" ",o=this.symbols.line.repeat(n),a=" ".repeat(n+(r?0:1)),l=t=>(t?this.styles.success("◉"):"◯")+s,c=e+1+".",u=i?this.styles.heading:this.styles.noop,h=await this.resolve(t.message,this.state,t,e),d=this.indent(t),p=d+t.scale.map((e,i)=>l(i===t.scaleIdx)).join(o),f=d+t.scale.map((e,i)=>(e=>e===t.scaleIdx?u(e):e)(i)).join(a);return i&&(p=this.styles.cyan(p),f=this.styles.cyan(f)),[[c,h].filter(Boolean).join(" "),p,f," "].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(){return this.state.submitted?this.choices.map(t=>this.styles.info(t.scaleIdx)).join(", "):""}async render(){let{submitted:t,size:e}=this.state,i=await this.prefix(),r=await this.separator(),n=[i,await this.message(),r].filter(Boolean).join(" ");this.state.prompt=n;let s=await this.header(),o=await this.format(),a=await this.error()||await this.hint(),l=await this.renderChoices(),c=await this.footer();!o&&a||(n+=" "+o),a&&!n.includes(a)&&(n+=" "+a),t&&!o&&!l&&this.multiple&&"form"!==this.type&&(n+=this.styles.danger(this.emptyError)),this.clear(e),this.write([n,s,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)}},ye=ie,be=class extends Yt{async initialize(){await super.initialize(),this.value=this.initial=!!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(),r=await this.separator(),n=await this.message(),s=await this.format(),o=await this.error()||await this.hint(),a=await this.footer(),l=[i,n,r,s].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()}},we=class extends Rt{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)}}},ve=N(function(t,e){const i=(t,i)=>{ut.defineExport(e,t,i),ut.defineExport(e,t.toLowerCase(),i)};i("AutoComplete",()=>Lt),i("BasicAuth",()=>Vt),i("Confirm",()=>Kt),i("Editable",()=>Xt),i("Form",()=>Bt),i("Input",()=>ie),i("Invisible",()=>re),i("List",()=>ne),i("MultiSelect",()=>se),i("Numeral",()=>ae),i("Password",()=>le),i("Scale",()=>ce),i("Select",()=>Rt),i("Snippet",()=>de),i("Sort",()=>fe),i("Survey",()=>ge),i("Text",()=>ye),i("Toggle",()=>be),i("Quiz",()=>we)}),Se={ArrayPrompt:Ft,AuthPrompt:Ht,BooleanPrompt:Yt,NumberPrompt:oe,StringPrompt:Qt};class Ee extends b.default{constructor(t,e){super(),this.options=ut.merge({},t),this.answers=st({},e)}register(t,e){if(ut.isObject(t)){for(let e of Object.keys(t))this.register(e,t[e]);return this}S.default.equal(typeof e,"function","expected a function");let i=t.toLowerCase();return this.prompts[i]=e.prototype instanceof this.Prompt?e: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(ut.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=ut.merge({},this.options,t),{type:i,name:r}=t,{set:n,get:s}=ut;if("function"==typeof i&&(i=await i.call(this,t,this.answers)),!i)return this.answers[r];S.default(this.prompts[i],`Prompt "${i}" is not registered`);let o=new this.prompts[i](e),a=s(this.answers,r);o.state.answers=this.answers,o.enquirer=this,r&&o.on("submit",t=>{this.emit("answer",r,t,o),n(this.answers,r,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||kt}static get prompts(){return ve}static get types(){return Se}static get prompt(){const t=(e,...i)=>{let r=new this(...i),n=r.emit.bind(r);return r.emit=(...e)=>(t.emit(...e),n(...e)),r.prompt(e)};return ut.mixinEmitter(t,new b.default),t}}ut.mixinEmitter(Ee,new b.default);const xe=Ee.prompts;for(let t of Object.keys(xe)){let e=t.toLowerCase(),i=e=>new xe[t](e).run();Ee.prompt[e]=i,Ee[e]=i,Ee[t]||Reflect.defineProperty(Ee,t,{get:()=>xe[t]})}const _e=t=>{ut.defineExport(Ee,t,()=>Ee.types[t])};_e("ArrayPrompt"),_e("AuthPrompt"),_e("BooleanPrompt"),_e("NumberPrompt"),_e("StringPrompt");var Oe=Ee,Ce=$e;function ke(t,e,i){return!(!t.isSymbolicLink()&&!t.isFile())&&function(t,e){var i=void 0!==e.pathExt?e.pathExt:process.env.PATHEXT;if(!i)return!0;if(-1!==(i=i.split(";")).indexOf(""))return!0;for(var r=0;r<i.length;r++){var n=i[r].toLowerCase();if(n&&t.substr(-n.length).toLowerCase()===n)return!0}return!1}(e,i)}function $e(t,e,i){v.default.stat(t,function(r,n){i(r,!r&&ke(n,t,e))})}$e.sync=function(t,e){return ke(v.default.statSync(t),t,e)};var je,Ae=Pe;function Pe(t,e,i){v.default.stat(t,function(t,r){i(t,!t&&Te(r,e))})}function Te(t,e){return t.isFile()&&function(t,e){var i=t.mode,r=t.uid,n=t.gid,s=void 0!==e.uid?e.uid:process.getuid&&process.getuid(),o=void 0!==e.gid?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),l=parseInt("010",8);return i&parseInt("001",8)||i&l&&n===o||i&a&&r===s||i&(a|l)&&0===s}(t,e)}Pe.sync=function(t,e){return Te(v.default.statSync(t),e)},je="win32"===process.platform||I.TESTING_WINDOWS?Ce:Ae;var Ie=Ne;function Ne(t,e,i){if("function"==typeof e&&(i=e,e={}),!i){if("function"!=typeof Promise)throw new TypeError("callback not provided");return new Promise(function(i,r){Ne(t,e||{},function(t,e){t?r(t):i(e)})})}je(t,e||{},function(t,r){t&&("EACCES"===t.code||e&&e.ignoreErrors)&&(t=null,r=!1),i(t,r)})}Ne.sync=function(t,e){try{return je.sync(t,e||{})}catch(t){if(e&&e.ignoreErrors||"EACCES"===t.code)return!1;throw t}};const Fe="win32"===process.platform||"cygwin"===process.env.OSTYPE||"msys"===process.env.OSTYPE,Re=Fe?";":":",Le=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),De=(t,e)=>{const i=e.colon||Re,r=t.match(/\//)||Fe&&t.match(/\\/)?[""]:[...Fe?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(i)],n=Fe?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=Fe?n.split(i):[""];return Fe&&-1!==t.indexOf(".")&&""!==s[0]&&s.unshift(""),{pathEnv:r,pathExt:s,pathExtExe:n}},Be=(t,e,i)=>{"function"==typeof e&&(i=e,e={}),e||(e={});const{pathEnv:r,pathExt:n,pathExtExe:s}=De(t,e),o=[],a=i=>new Promise((n,s)=>{if(i===r.length)return e.all&&o.length?n(o):s(Le(t));const a=r[i],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=y.default.join(c,t),h=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;n(l(h,i,0))}),l=(t,i,r)=>new Promise((c,u)=>{if(r===n.length)return c(a(i+1));const h=n[r];Ie(t+h,{pathExt:s},(n,s)=>{if(!n&&s){if(!e.all)return c(t+h);o.push(t+h)}return c(l(t,i,r+1))})});return i?a(0).then(t=>i(null,t),i):a(0)};var Me=Be;Be.sync=(t,e)=>{e=e||{};const{pathEnv:i,pathExt:r,pathExtExe:n}=De(t,e),s=[];for(let o=0;o<i.length;o++){const a=i[o],l=/^".*"$/.test(a)?a.slice(1,-1):a,c=y.default.join(l,t),u=!l&&/^\.[\\\/]/.test(t)?t.slice(0,2)+c:c;for(let t=0;t<r.length;t++){const i=u+r[t];try{if(Ie.sync(i,{pathExt:n})){if(!e.all)return i;s.push(i)}}catch(t){}}}if(e.all&&s.length)return s;if(e.nothrow)return null;throw Le(t)};const Ge=(t={})=>{const e=t.env||process.env;return"win32"!==(t.platform||process.platform)?"PATH":Object.keys(e).reverse().find(t=>"PATH"===t.toUpperCase())||"Path"};var He=Ge;function Ue(t,e){const i=t.options.env||process.env,r=process.cwd(),n=null!=t.options.cwd,s=n&&void 0!==process.chdir&&!process.chdir.disabled;if(s)try{process.chdir(t.options.cwd)}catch(t){}let o;try{o=Me.sync(t.command,{path:i[He({env:i})],pathExt:e?y.default.delimiter:void 0})}catch(t){}finally{s&&process.chdir(r)}return o&&(o=y.default.resolve(n?t.options.cwd:"",o)),o}He.default=Ge;var qe=function(t){return Ue(t)||Ue(t,!0)};const Ve=/([()\][%!^"`<>&|;, *?])/g;var We=/^#!(.*)/;const ze="win32"===process.platform,Ye=/\.(?:com|exe)$/i,Ke=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;var Je=function(t,e,i){e&&!Array.isArray(e)&&(i=e,e=null);const r={command:t,args:e=e?e.slice(0):[],options:i=Object.assign({},i),file:void 0,original:{command:t,args:e}};return i.shell?r:function(t){if(!ze)return t;const e=function(t){t.file=qe(t);const e=t.file&&function(t){const e=Buffer.alloc(150);let i;try{i=v.default.openSync(t,"r"),v.default.readSync(i,e,0,150,0),v.default.closeSync(i)}catch(t){}return((t="")=>{const e=t.match(We);if(!e)return null;const[i,r]=e[0].replace(/#! ?/,"").split(" "),n=i.split("/").pop();return"env"===n?r:r?`${n} ${r}`:n})(e.toString())}(t.file);return e?(t.args.unshift(t.file),t.command=e,qe(t)):t.file}(t),i=!Ye.test(e);if(t.options.forceShell||i){const i=Ke.test(e);t.command=y.default.normalize(t.command),t.command=t.command.replace(Ve,"^$1"),t.args=t.args.map(t=>function(t,e){return t=(t=`"${t=(t=(t=`${t}`).replace(/(\\*)"/g,'$1$1\\"')).replace(/(\\*)$/,"$1$1")}"`).replace(Ve,"^$1"),e&&(t=t.replace(Ve,"^$1")),t}(t,i));const r=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${r}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}(r)};const Xe="win32"===process.platform;function Ze(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function Qe(t,e){return Xe&&1===t&&!e.file?Ze(e.original,"spawn"):null}var ti={hookChildProcess:function(t,e){if(!Xe)return;const i=t.emit;t.emit=function(r,n){if("exit"===r){const r=Qe(n,e);if(r)return i.call(t,"error",r)}return i.apply(t,arguments)}},verifyENOENT:Qe,verifyENOENTSync:function(t,e){return Xe&&1===t&&!e.file?Ze(e.original,"spawnSync"):null},notFoundError:Ze};function ei(t,e,i){const r=Je(t,e,i),n=w.default.spawn(r.command,r.args,r.options);return ti.hookChildProcess(n,r),n}var ii=ei,ri=Je,ni=ti;ii.spawn=ei,ii.sync=function(t,e,i){const r=Je(t,e,i),n=w.default.spawnSync(r.command,r.args,r.options);return n.error=n.error||ti.verifyENOENTSync(n.status,r),n},ii._parse=ri,ii._enoent=ni;const si=(t={})=>{const e=t.env||process.env;return"win32"!==(t.platform||process.platform)?"PATH":Object.keys(e).reverse().find(t=>"PATH"===t.toUpperCase())||"Path"};var oi=si;oi.default=si;var ai=N(function(t){const e=t=>{let e;t=st({cwd:process.cwd(),path:process.env[oi()],execPath:process.execPath},t);let i=y.default.resolve(t.cwd);const r=[];for(;e!==i;)r.push(y.default.join(i,"node_modules/.bin")),e=i,i=y.default.resolve(i,"..");const n=y.default.resolve(t.cwd,t.execPath,"..");return r.push(n),r.concat(t.path).join(y.default.delimiter)};t.exports=e,t.exports.default=e,t.exports.env=e=>{e=st({env:process.env},e);const i=st({},e.env),r=oi({env:i});return e.path=i[r],i[r]=t.exports(e),i}});const li=(t,e)=>{for(const i of Reflect.ownKeys(e))Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(e,i));return t};var ci=li;ci.default=li;const ui=new WeakMap,hi=(t,e={})=>{if("function"!=typeof t)throw new TypeError("Expected a function");let i,r=0;const n=t.displayName||t.name||"<anonymous>",s=function(...o){if(ui.set(s,++r),1===r)i=t.apply(this,o),t=null;else if(!0===e.throw)throw new Error(`Function \`${n}\` can only be called once`);return i};return ci(s,t),ui.set(s,r),s};var di=hi;di.default=hi,di.callCount=t=>{if(!ui.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return ui.get(t)};var pi=N(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.SIGNALS=void 0,e.SIGNALS=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}]}),fi=N(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.SIGRTMAX=e.getRealtimeSignals=void 0,e.getRealtimeSignals=function(){return Array.from({length:n-r+1},i)};const i=function(t,e){return{name:`SIGRT${e+1}`,number:r+e,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},r=34,n=64;e.SIGRTMAX=n}),mi=N(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.getSignals=void 0,e.getSignals=function(){const t=(0,fi.getRealtimeSignals)();return[...pi.SIGNALS,...t].map(i)};const i=function({name:t,number:e,description:i,action:r,forced:n=!1,standard:s}){const{signals:{[t]:o}}=x.default.constants,a=void 0!==o;return{name:t,number:a?o:e,description:i,supported:a,action:r,forced:n,standard:s}}}),gi=N(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.signalsByNumber=e.signalsByName=void 0;const i=(0,mi.getSignals)().reduce(function(t,{name:e,number:i,description:r,supported:n,action:s,forced:o,standard:a}){return st({},t,{[e]:{name:e,number:i,description:r,supported:n,action:s,forced:o,standard:a}})},{});e.signalsByName=i;const r=function(){const t=(0,mi.getSignals)(),e=Array.from({length:fi.SIGRTMAX+1},(e,i)=>function(t,e){const i=function(t,e){const i=e.find(({name:e})=>x.default.constants.signals[e]===t);return void 0!==i?i:e.find(e=>e.number===t)}(t,e);if(void 0===i)return{};const{name:r,description:n,supported:s,action:o,forced:a,standard:l}=i;return{[t]:{name:r,number:t,description:n,supported:s,action:o,forced:a,standard:l}}}(i,t));return Object.assign({},...e)}();e.signalsByNumber=r});const{signalsByName:yi}=gi;var bi=({stdout:t,stderr:e,all:i,error:r,signal:n,exitCode:s,command:o,escapedCommand:a,timedOut:l,isCanceled:c,killed:u,parsed:{options:{timeout:h}}})=>{const d=void 0===(n=null===n?void 0:n)?void 0:yi[n].description,p=`Command ${(({timedOut:t,timeout:e,errorCode:i,signal:r,signalDescription:n,exitCode:s,isCanceled:o})=>t?`timed out after ${e} milliseconds`:o?"was canceled":void 0!==i?`failed with ${i}`:void 0!==r?`was killed with ${r} (${n})`:void 0!==s?`failed with exit code ${s}`:"failed")({timedOut:l,timeout:h,errorCode:r&&r.code,signal:n,signalDescription:d,exitCode:s=null===s?void 0:s,isCanceled:c})}: ${o}`,f="[object Error]"===Object.prototype.toString.call(r),m=f?`${p}\n${r.message}`:p,g=[m,e,t].filter(Boolean).join("\n");return f?(r.originalMessage=r.message,r.message=g):r=new Error(g),r.shortMessage=m,r.command=o,r.escapedCommand=a,r.exitCode=s,r.signal=n,r.signalDescription=d,r.stdout=t,r.stderr=e,void 0!==i&&(r.all=i),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=Boolean(l),r.isCanceled=c,r.killed=u&&!l,r};const wi=["stdin","stdout","stderr"],vi=t=>{if(!t)return;const{stdio:e}=t;if(void 0===e)return wi.map(e=>t[e]);if((t=>wi.some(e=>void 0!==t[e]))(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${wi.map(t=>`\`${t}\``).join(", ")}`);if("string"==typeof e)return e;if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);const i=Math.max(e.length,wi.length);return Array.from({length:i},(t,i)=>e[i])};var Si=vi;Si.node=t=>{const e=vi(t);return"ipc"===e?"ipc":void 0===e||"string"==typeof e?[e,e,e,"ipc"]:e.includes("ipc")?e:[...e,"ipc"]};var Ei,xi=N(function(t){t.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],"win32"!==process.platform&&t.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),"linux"===process.platform&&t.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")}),_i=/^win/i.test(process.platform),Oi=b.default;"function"!=typeof Oi&&(Oi=Oi.EventEmitter),process.__signal_exit_emitter__?Ei=process.__signal_exit_emitter__:((Ei=process.__signal_exit_emitter__=new Oi).count=0,Ei.emitted={}),Ei.infinite||(Ei.setMaxListeners(Infinity),Ei.infinite=!0);var Ci=function(t,e){S.default.equal(typeof t,"function","a callback must be provided for exit handler"),!1===Ti&&Ii();var i="exit";return e&&e.alwaysLast&&(i="afterexit"),Ei.on(i,t),function(){Ei.removeListener(i,t),0===Ei.listeners("exit").length&&0===Ei.listeners("afterexit").length&&$i()}},ki=$i;function $i(){Ti&&(Ti=!1,xi.forEach(function(t){try{process.removeListener(t,Ai[t])}catch(t){}}),process.emit=Ri,process.reallyExit=Ni,Ei.count-=1)}function ji(t,e,i){Ei.emitted[t]||(Ei.emitted[t]=!0,Ei.emit(t,e,i))}var Ai={};xi.forEach(function(t){Ai[t]=function(){process.listeners(t).length===Ei.count&&($i(),ji("exit",null,t),ji("afterexit",null,t),_i&&"SIGHUP"===t&&(t="SIGINT"),process.kill(process.pid,t))}});var Pi=Ii,Ti=!1;function Ii(){Ti||(Ti=!0,Ei.count+=1,xi=xi.filter(function(t){try{return process.on(t,Ai[t]),!0}catch(t){return!1}}),process.emit=Li,process.reallyExit=Fi)}var Ni=process.reallyExit;function Fi(t){process.exitCode=t||0,ji("exit",process.exitCode,null),ji("afterexit",process.exitCode,null),Ni.call(process,process.exitCode)}var Ri=process.emit;function Li(t,e){if("exit"===t){void 0!==e&&(process.exitCode=e);var i=Ri.apply(this,arguments);return ji("exit",process.exitCode,null),ji("afterexit",process.exitCode,null),i}return Ri.apply(this,arguments)}Ci.unload=ki,Ci.signals=function(){return xi},Ci.load=Pi;var Di={spawnedKill:(t,e="SIGTERM",i={})=>{const r=t(e);return((t,e,i,r)=>{if(!((t,{forceKillAfterTimeout:e},i)=>(t=>t===x.default.constants.signals.SIGTERM||"string"==typeof t&&"SIGTERM"===t.toUpperCase())(t)&&!1!==e&&i)(e,i,r))return;const n=(({forceKillAfterTimeout:t=!0})=>{if(!0===t)return 5e3;if(!Number.isFinite(t)||t<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`);return t})(i),s=setTimeout(()=>{t("SIGKILL")},n);s.unref&&s.unref()})(t,e,i,r),r},spawnedCancel:(t,e)=>{t.kill()&&(e.isCanceled=!0)},setupTimeout:(t,{timeout:e,killSignal:i="SIGTERM"},r)=>{if(0===e||void 0===e)return r;let n;const s=new Promise((r,s)=>{n=setTimeout(()=>{((t,e,i)=>{t.kill(e),i(Object.assign(new Error("Timed out"),{timedOut:!0,signal:e}))})(t,i,s)},e)}),o=r.finally(()=>{clearTimeout(n)});return Promise.race([s,o])},validateTimeout:({timeout:t})=>{if(void 0!==t&&(!Number.isFinite(t)||t<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`)},setExitHandler:async(t,{cleanup:e,detached:i},r)=>{if(!e||i)return r;const n=Ci(()=>{t.kill()});return r.finally(()=>{n()})}};const Bi=t=>null!==t&&"object"==typeof t&&"function"==typeof t.pipe;Bi.writable=t=>Bi(t)&&!1!==t.writable&&"function"==typeof t._write&&"object"==typeof t._writableState,Bi.readable=t=>Bi(t)&&!1!==t.readable&&"function"==typeof t._read&&"object"==typeof t._readableState,Bi.duplex=t=>Bi.writable(t)&&Bi.readable(t),Bi.transform=t=>Bi.duplex(t)&&"function"==typeof t._transform;var Mi=Bi;const{PassThrough:Gi}=O.default,{constants:Hi}=_.default,{promisify:Ui}=C.default,qi=Ui(O.default.pipeline);class Vi extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function Wi(t,e){if(!t)throw new Error("Expected a stream");e=st({maxBuffer:Infinity},e);const{maxBuffer:i}=e,r=(t=>{t=st({},t);const{array:e}=t;let{encoding:i}=t;const r="buffer"===i;let n=!1;e?n=!(i||r):i=i||"utf8",r&&(i=null);const s=new Gi({objectMode:n});i&&s.setEncoding(i);let o=0;const a=[];return s.on("data",t=>{a.push(t),n?o=a.length:o+=t.length}),s.getBufferedValue=()=>e?a:r?Buffer.concat(a,o):a.join(""),s.getBufferedLength=()=>o,s})(e);return await new Promise((e,n)=>{const s=t=>{t&&r.getBufferedLength()<=Hi.MAX_LENGTH&&(t.bufferedData=r.getBufferedValue()),n(t)};(async()=>{try{await qi(t,r),e()}catch(t){s(t)}})(),r.on("data",()=>{r.getBufferedLength()>i&&s(new Vi)})}),r.getBufferedValue()}var zi=Wi,Yi=Vi;zi.buffer=(t,e)=>Wi(t,st({},e,{encoding:"buffer"})),zi.array=(t,e)=>Wi(t,st({},e,{array:!0})),zi.MaxBufferError=Yi;const{PassThrough:Ki}=O.default,Ji=async(t,e)=>{if(t){t.destroy();try{return await e}catch(t){return t.bufferedData}}},Xi=(t,{encoding:e,buffer:i,maxBuffer:r})=>{if(t&&i)return e?zi(t,{encoding:e,maxBuffer:r}):zi.buffer(t,{maxBuffer:r})};var Zi={handleInput:(t,e)=>{void 0!==e&&void 0!==t.stdin&&(Mi(e)?e.pipe(t.stdin):t.stdin.end(e))},makeAllStream:(t,{all:e})=>{if(!e||!t.stdout&&!t.stderr)return;const i=function(){var t=[],e=new Ki({objectMode:!0});return e.setMaxListeners(0),e.add=i,e.isEmpty=r,e.on("unpipe",n),Array.prototype.slice.call(arguments).forEach(i),e;function i(r){return Array.isArray(r)?(r.forEach(i),this):(t.push(r),r.once("end",n.bind(null,r)),r.once("error",e.emit.bind(e,"error")),r.pipe(e,{end:!1}),this)}function r(){return 0==t.length}function n(i){!(t=t.filter(function(t){return t!==i})).length&&e.readable&&e.end()}}();return t.stdout&&i.add(t.stdout),t.stderr&&i.add(t.stderr),i},getSpawnedResult:async({stdout:t,stderr:e,all:i},{encoding:r,buffer:n,maxBuffer:s},o)=>{const a=Xi(t,{encoding:r,buffer:n,maxBuffer:s}),l=Xi(e,{encoding:r,buffer:n,maxBuffer:s}),c=Xi(i,{encoding:r,buffer:n,maxBuffer:2*s});try{return await Promise.all([o,a,l,c])}catch(r){return Promise.all([{error:r,signal:r.signal,timedOut:r.timedOut},Ji(t,a),Ji(e,l),Ji(i,c)])}},validateInputSync:({input:t})=>{if(Mi(t))throw new TypeError("The `input` option cannot be a stream in sync mode")}};const Qi=(async()=>{})().constructor.prototype,tr=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Qi,t)]);var er={mergePromise:(t,e)=>{for(const[i,r]of tr){const n="function"==typeof e?(...t)=>Reflect.apply(r.value,e(),t):r.value.bind(e);Reflect.defineProperty(t,i,st({},r,{value:n}))}return t},getSpawnedPromise:t=>new Promise((e,i)=>{t.on("exit",(t,i)=>{e({exitCode:t,signal:i})}),t.on("error",t=>{i(t)}),t.stdin&&t.stdin.on("error",t=>{i(t)})})};const ir=(t,e=[])=>Array.isArray(e)?[t,...e]:[t],rr=/^[\w.-]+$/,nr=/"/g,sr=/ +/g;var or={joinCommand:(t,e)=>ir(t,e).join(" "),getEscapedCommand:(t,e)=>ir(t,e).map(t=>(t=>"string"!=typeof t||rr.test(t)?t:`"${t.replace(nr,'\\"')}"`)(t)).join(" "),parseCommand:t=>{const e=[];for(const i of t.trim().split(sr)){const t=e[e.length-1];t&&t.endsWith("\\")?e[e.length-1]=`${t.slice(0,-1)} ${i}`:e.push(i)}return e}};const{spawnedKill:ar,spawnedCancel:lr,setupTimeout:cr,validateTimeout:ur,setExitHandler:hr}=Di,{handleInput:dr,getSpawnedResult:pr,makeAllStream:fr,validateInputSync:mr}=Zi,{mergePromise:gr,getSpawnedPromise:yr}=er,{joinCommand:br,parseCommand:wr,getEscapedCommand:vr}=or,Sr=(t,e,i={})=>{const r=ii._parse(t,e,i);return t=r.command,e=r.args,(i=st({maxBuffer:1e8,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:(i=r.options).cwd||process.cwd(),execPath:process.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0},i)).env=(({env:t,extendEnv:e,preferLocal:i,localDir:r,execPath:n})=>{const s=e?st({},process.env,t):t;return i?ai.env({env:s,cwd:r,execPath:n}):s})(i),i.stdio=Si(i),"win32"===process.platform&&"cmd"===y.default.basename(t,".exe")&&e.unshift("/q"),{file:t,args:e,options:i,parsed:r}},Er=(t,e,i)=>"string"==typeof e||Buffer.isBuffer(e)?t.stripFinalNewline?(t=>{const e="string"==typeof t?"\n":"\n".charCodeAt(),i="string"==typeof t?"\r":"\r".charCodeAt();return t[t.length-1]===e&&(t=t.slice(0,t.length-1)),t[t.length-1]===i&&(t=t.slice(0,t.length-1)),t})(e):e:void 0===i?void 0:"",xr=(t,e,i)=>{const r=Sr(t,e,i),n=br(t,e),s=vr(t,e);let o;ur(r.options);try{o=w.default.spawn(r.file,r.args,r.options)}catch(t){const e=new w.default.ChildProcess,i=Promise.reject(bi({error:t,stdout:"",stderr:"",all:"",command:n,escapedCommand:s,parsed:r,timedOut:!1,isCanceled:!1,killed:!1}));return gr(e,i)}const a=yr(o),l=cr(o,r.options,a),c=hr(o,r.options,l),u={isCanceled:!1};o.kill=ar.bind(null,o.kill.bind(o)),o.cancel=lr.bind(null,o,u);const h=di(async()=>{const[{error:t,exitCode:e,signal:i,timedOut:a},l,h,d]=await pr(o,r.options,c),p=Er(r.options,l),f=Er(r.options,h),m=Er(r.options,d);if(t||0!==e||null!==i){const l=bi({error:t,exitCode:e,signal:i,stdout:p,stderr:f,all:m,command:n,escapedCommand:s,parsed:r,timedOut:a,isCanceled:u.isCanceled,killed:o.killed});if(!r.options.reject)return l;throw l}return{command:n,escapedCommand:s,exitCode:0,stdout:p,stderr:f,all:m,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return dr(o,r.options.input),o.all=fr(o,r.options),gr(o,h)};var _r=xr;_r.sync=(t,e,i)=>{const r=Sr(t,e,i),n=br(t,e),s=vr(t,e);let o;mr(r.options);try{o=w.default.spawnSync(r.file,r.args,r.options)}catch(t){throw bi({error:t,stdout:"",stderr:"",all:"",command:n,escapedCommand:s,parsed:r,timedOut:!1,isCanceled:!1,killed:!1})}const a=Er(r.options,o.stdout,o.error),l=Er(r.options,o.stderr,o.error);if(o.error||0!==o.status||null!==o.signal){const t=bi({stdout:a,stderr:l,error:o.error,signal:o.signal,exitCode:o.status,command:n,escapedCommand:s,parsed:r,timedOut:o.error&&"ETIMEDOUT"===o.error.code,isCanceled:!1,killed:null!==o.signal});if(!r.options.reject)return t;throw t}return{command:n,escapedCommand:s,exitCode:0,stdout:a,stderr:l,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},_r.command=(t,e)=>{const[i,...r]=wr(t);return xr(i,r,e)},_r.commandSync=(t,e)=>{const[i,...r]=wr(t);return xr.sync(i,r,e)},_r.node=(t,e,i={})=>{e&&!Array.isArray(e)&&"object"==typeof e&&(i=e,e=[]);const r=Si.node(i),n=process.execArgv.filter(t=>!t.startsWith("--inspect")),{nodePath:s=process.execPath,nodeOptions:o=n}=i;return xr(s,[...o,t,...Array.isArray(e)?e:[]],st({},i,{stdin:void 0,stdout:void 0,stderr:void 0,stdio:r,shell:!1}))};const Or="win32"===process.platform?["-","\\","|","/"]:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],Cr=process.stderr;var kr=function(t="",e=Or,i=80){let r=0;Cr.write("[?25l");const n=setInterval(()=>{Cr.write(`${e[r]} ${t}`),r=(r+1)%e.length,Cr.cursorTo(0)},i);return function(){clearInterval(n),Cr.cursorTo(0),Cr.write("[?25h")}},$r=Ar;Ar.sync=function(t){if(t in jr)return jr[t];try{v.default.lstatSync(t),jr[t]=!0}catch(e){jr[t]=!1}return jr[t]};var jr=Object.create(null);function Ar(t,e){if(t in jr)return process.nextTick(e.bind(null,jr[t]));v.default.lstat(t,function(i){e(jr[t]=!i)})}var Pr=function(t){return Object.defineProperty(function(...e){if("function"!=typeof e[e.length-1])return new Promise((i,r)=>{t.call(this,...e,(t,e)=>null!=t?r(t):i(e))});t.apply(this,e)},"name",{value:t.name})},Tr=function(t){return Object.defineProperty(function(...e){const i=e[e.length-1];if("function"!=typeof i)return t.apply(this,e);t.apply(this,e.slice(0,-1)).then(t=>i(null,t),i)},"name",{value:t.name})},Ir=process.cwd,Nr=null,Fr=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Nr||(Nr=Ir.call(process)),Nr};try{process.cwd()}catch(t){}var Rr=process.chdir;process.chdir=function(t){Nr=null,Rr.call(process,t)};var Lr=O.default.Stream,Dr=N(function(t){var e,i;"function"==typeof Symbol&&"function"==typeof Symbol.for?(e=Symbol.for("graceful-fs.queue"),i=Symbol.for("graceful-fs.previous")):(e="___graceful-fs.queue",i="___graceful-fs.previous");var r=function(){};if(C.default.debuglog?r=C.default.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(r=function(){var t=C.default.format.apply(C.default,arguments);t="GFS4: "+t.split(/\n/).join("\nGFS4: "),console.error(t)}),!I[e]){var n=[];Object.defineProperty(I,e,{get:function(){return n}}),v.default.close=function(t){function e(e,i){return t.call(v.default,e,function(t){t||a(),"function"==typeof i&&i.apply(this,arguments)})}return Object.defineProperty(e,i,{value:t}),e}(v.default.close),v.default.closeSync=function(t){function e(e){t.apply(v.default,arguments),a()}return Object.defineProperty(e,i,{value:t}),e}(v.default.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){r(I[e]),S.default.equal(I[e].length,0)})}function s(t){(function(t){var e,i;function r(e){return e?function(i,r,n){return e.call(t,i,r,function(t){c(t)&&(t=null),n&&n.apply(this,arguments)})}:e}function n(e){return e?function(i,r){try{return e.call(t,i,r)}catch(t){if(!c(t))throw t}}:e}function s(e){return e?function(i,r,n,s){return e.call(t,i,r,n,function(t){c(t)&&(t=null),s&&s.apply(this,arguments)})}:e}function o(e){return e?function(i,r,n){try{return e.call(t,i,r,n)}catch(t){if(!c(t))throw t}}:e}function a(e){return e?function(i,r,n){function s(t,e){e&&(e.uid<0&&(e.uid+=4294967296),e.gid<0&&(e.gid+=4294967296)),n&&n.apply(this,arguments)}return"function"==typeof r&&(n=r,r=null),r?e.call(t,i,r,s):e.call(t,i,s)}:e}function l(e){return e?function(i,r){var n=r?e.call(t,i,r):e.call(t,i);return n.uid<0&&(n.uid+=4294967296),n.gid<0&&(n.gid+=4294967296),n}:e}function c(t){return!t||"ENOSYS"===t.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==t.code&&"EPERM"!==t.code)}k.default.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(t){t.lchmod=function(e,i,r){t.open(e,k.default.O_WRONLY|k.default.O_SYMLINK,i,function(e,n){e?r&&r(e):t.fchmod(n,i,function(e){t.close(n,function(t){r&&r(e||t)})})})},t.lchmodSync=function(e,i){var r,n=t.openSync(e,k.default.O_WRONLY|k.default.O_SYMLINK,i),s=!0;try{r=t.fchmodSync(n,i),s=!1}finally{if(s)try{t.closeSync(n)}catch(t){}else t.closeSync(n)}return r}}(t),t.lutimes||function(t){k.default.hasOwnProperty("O_SYMLINK")?(t.lutimes=function(e,i,r,n){t.open(e,k.default.O_SYMLINK,function(e,s){e?n&&n(e):t.futimes(s,i,r,function(e){t.close(s,function(t){n&&n(e||t)})})})},t.lutimesSync=function(e,i,r){var n,s=t.openSync(e,k.default.O_SYMLINK),o=!0;try{n=t.futimesSync(s,i,r),o=!1}finally{if(o)try{t.closeSync(s)}catch(t){}else t.closeSync(s)}return n}):(t.lutimes=function(t,e,i,r){r&&process.nextTick(r)},t.lutimesSync=function(){})}(t),t.chown=s(t.chown),t.fchown=s(t.fchown),t.lchown=s(t.lchown),t.chmod=r(t.chmod),t.fchmod=r(t.fchmod),t.lchmod=r(t.lchmod),t.chownSync=o(t.chownSync),t.fchownSync=o(t.fchownSync),t.lchownSync=o(t.lchownSync),t.chmodSync=n(t.chmodSync),t.fchmodSync=n(t.fchmodSync),t.lchmodSync=n(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=l(t.statSync),t.fstatSync=l(t.fstatSync),t.lstatSync=l(t.lstatSync),t.lchmod||(t.lchmod=function(t,e,i){i&&process.nextTick(i)},t.lchmodSync=function(){}),t.lchown||(t.lchown=function(t,e,i,r){r&&process.nextTick(r)},t.lchownSync=function(){}),"win32"===Fr&&(t.rename=(e=t.rename,function(i,r,n){var s=Date.now(),o=0;e(i,r,function a(l){if(l&&("EACCES"===l.code||"EPERM"===l.code)&&Date.now()-s<6e4)return setTimeout(function(){t.stat(r,function(t,s){t&&"ENOENT"===t.code?e(i,r,a):n(l)})},o),void(o<100&&(o+=10));n&&n(l)})})),t.read=function(e){function i(i,r,n,s,o,a){var l;if(a&&"function"==typeof a){var c=0;l=function(u,h,d){if(u&&"EAGAIN"===u.code&&c<10)return c++,e.call(t,i,r,n,s,o,l);a.apply(this,arguments)}}return e.call(t,i,r,n,s,o,l)}return i.__proto__=e,i}(t.read),t.readSync=(i=t.readSync,function(e,r,n,s,o){for(var a=0;;)try{return i.call(t,e,r,n,s,o)}catch(t){if("EAGAIN"===t.code&&a<10){a++;continue}throw t}})})(t),t.gracefulify=s,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,r){return"function"==typeof i&&(r=i,i=null),function t(i,r,n){return e(i,r,function(e){!e||"EMFILE"!==e.code&&"ENFILE"!==e.code?("function"==typeof n&&n.apply(this,arguments),a()):o([t,[i,r,n]])})}(t,i,r)};var i=t.writeFile;t.writeFile=function(t,e,r,n){return"function"==typeof r&&(n=r,r=null),function t(e,r,n,s){return i(e,r,n,function(i){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?("function"==typeof s&&s.apply(this,arguments),a()):o([t,[e,r,n,s]])})}(t,e,r,n)};var r=t.appendFile;r&&(t.appendFile=function(t,e,i,n){return"function"==typeof i&&(n=i,i=null),function t(e,i,n,s){return r(e,i,n,function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?("function"==typeof s&&s.apply(this,arguments),a()):o([t,[e,i,n,s]])})}(t,e,i,n)});var n=t.readdir;function l(e){return n.apply(t,e)}if(t.readdir=function(t,e,i){var r=[t];return"function"!=typeof e?r.push(e):i=e,r.push(function(t,e){e&&e.sort&&e.sort(),!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?("function"==typeof i&&i.apply(this,arguments),a()):o([l,[r]])}),l(r)},"v0.8"===process.version.substr(0,4)){var c=function(t){return{ReadStream:function e(i,r){if(!(this instanceof e))return new e(i,r);Lr.call(this);var n=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,r=r||{};for(var s=Object.keys(r),o=0,a=s.length;o<a;o++){var l=s[o];this[l]=r[l]}if(this.encoding&&this.setEncoding(this.encoding),void 0!==this.start){if("number"!=typeof this.start)throw TypeError("start must be a Number");if(void 0===this.end)this.end=Infinity;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}null===this.fd?t.open(this.path,this.flags,this.mode,function(t,e){if(t)return n.emit("error",t),void(n.readable=!1);n.fd=e,n.emit("open",e),n._read()}):process.nextTick(function(){n._read()})},WriteStream:function e(i,r){if(!(this instanceof e))return new e(i,r);Lr.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var n=Object.keys(r),s=0,o=n.length;s<o;s++){var a=n[s];this[a]=r[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())}}}(t);f=c.ReadStream,m=c.WriteStream}var u=t.ReadStream;u&&(f.prototype=Object.create(u.prototype),f.prototype.open=function(){var t=this;y(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 h=t.WriteStream;h&&(m.prototype=Object.create(h.prototype),m.prototype.open=function(){var t=this;y(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 f},set:function(t){f=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return m},set:function(t){m=t},enumerable:!0,configurable:!0});var d=f;Object.defineProperty(t,"FileReadStream",{get:function(){return d},set:function(t){d=t},enumerable:!0,configurable:!0});var p=m;function f(t,e){return this instanceof f?(u.apply(this,arguments),this):f.apply(Object.create(f.prototype),arguments)}function m(t,e){return this instanceof m?(h.apply(this,arguments),this):m.apply(Object.create(m.prototype),arguments)}Object.defineProperty(t,"FileWriteStream",{get:function(){return p},set:function(t){p=t},enumerable:!0,configurable:!0});var g=t.open;function y(t,e,i,r){return"function"==typeof i&&(r=i,i=null),function t(e,i,r,n){return g(e,i,r,function(s,l){!s||"EMFILE"!==s.code&&"ENFILE"!==s.code?("function"==typeof n&&n.apply(this,arguments),a()):o([t,[e,i,r,n]])})}(t,e,i,r)}return t.open=y,t}function o(t){r("ENQUEUE",t[0].name,t[1]),I[e].push(t)}function a(){var t=I[e].shift();t&&(r("RETRY",t[0].name,t[1]),t[0].apply(null,t[1]))}t.exports=s(function(t){if(null===t||"object"!=typeof t)return t;if(t instanceof Object)var e={__proto__:t.__proto__};else e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}(v.default)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!v.default.__patched&&(t.exports=s(v.default),v.default.__patched=!0)}),Br=N(function(t,e){const i=Pr,r=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(t=>"function"==typeof Dr[t]);Object.assign(e,Dr),r.forEach(t=>{e[t]=i(Dr[t])}),e.realpath.native=i(Dr.realpath.native),e.exists=function(t,e){return"function"==typeof e?Dr.exists(t,e):new Promise(e=>Dr.exists(t,e))},e.read=function(t,e,i,r,n,s){return"function"==typeof s?Dr.read(t,e,i,r,n,s):new Promise((s,o)=>{Dr.read(t,e,i,r,n,(t,e,i)=>{if(t)return o(t);s({bytesRead:e,buffer:i})})})},e.write=function(t,e,...i){return"function"==typeof i[i.length-1]?Dr.write(t,e,...i):new Promise((r,n)=>{Dr.write(t,e,...i,(t,e,i)=>{if(t)return n(t);r({bytesWritten:e,buffer:i})})})},"function"==typeof Dr.writev&&(e.writev=function(t,e,...i){return"function"==typeof i[i.length-1]?Dr.writev(t,e,...i):new Promise((r,n)=>{Dr.writev(t,e,...i,(t,e,i)=>{if(t)return n(t);r({bytesWritten:e,buffers:i})})})})}),Mr={checkPath:function(t){if("win32"===process.platform&&/[<>:"|?*]/.test(t.replace(y.default.parse(t).root,""))){const e=new Error(`Path contains invalid characters: ${t}`);throw e.code="EINVAL",e}}};const{checkPath:Gr}=Mr,Hr=t=>"number"==typeof t?t:{mode:511,...t}.mode;var Ur={makeDir:async(t,e)=>(Gr(t),Br.mkdir(t,{mode:Hr(e),recursive:!0})),makeDirSync:(t,e)=>(Gr(t),Br.mkdirSync(t,{mode:Hr(e),recursive:!0}))};const qr=Tr,{makeDir:Vr,makeDirSync:Wr}=Ur,zr=qr(Vr);var Yr={mkdirs:zr,mkdirsSync:Wr,mkdirp:zr,mkdirpSync:Wr,ensureDir:zr,ensureDirSync:Wr};function Kr(t,e,i){const r=i.dereference?t=>Br.stat(t,{bigint:!0}):t=>Br.lstat(t,{bigint:!0});return Promise.all([r(t),r(e).catch(t=>{if("ENOENT"===t.code)return null;throw t})]).then(([t,e])=>({srcStat:t,destStat:e}))}function Jr(t,e){return e.ino&&e.dev&&e.ino===t.ino&&e.dev===t.dev}function Xr(t,e){const i=y.default.resolve(t).split(y.default.sep).filter(t=>t),r=y.default.resolve(e).split(y.default.sep).filter(t=>t);return i.reduce((t,e,i)=>t&&r[i]===e,!0)}function Zr(t,e,i){return`Cannot ${i} '${t}' to a subdirectory of itself, '${e}'.`}var Qr={checkPaths:function(t,e,i,r,n){C.default.callbackify(Kr)(t,e,r,(r,s)=>{if(r)return n(r);const{srcStat:o,destStat:a}=s;if(a){if(Jr(o,a)){const r=y.default.basename(t),s=y.default.basename(e);return"move"===i&&r!==s&&r.toLowerCase()===s.toLowerCase()?n(null,{srcStat:o,destStat:a,isChangingCase:!0}):n(new Error("Source and destination must not be the same."))}if(o.isDirectory()&&!a.isDirectory())return n(new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'.`));if(!o.isDirectory()&&a.isDirectory())return n(new Error(`Cannot overwrite directory '${e}' with non-directory '${t}'.`))}return o.isDirectory()&&Xr(t,e)?n(new Error(Zr(t,e,i))):n(null,{srcStat:o,destStat:a})})},checkPathsSync:function(t,e,i,r){const{srcStat:n,destStat:s}=function(t,e,i){let r;const n=i.dereference?t=>Br.statSync(t,{bigint:!0}):t=>Br.lstatSync(t,{bigint:!0}),s=n(t);try{r=n(e)}catch(t){if("ENOENT"===t.code)return{srcStat:s,destStat:null};throw t}return{srcStat:s,destStat:r}}(t,e,r);if(s){if(Jr(n,s)){const r=y.default.basename(t),o=y.default.basename(e);if("move"===i&&r!==o&&r.toLowerCase()===o.toLowerCase())return{srcStat:n,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(n.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'.`);if(!n.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${t}'.`)}if(n.isDirectory()&&Xr(t,e))throw new Error(Zr(t,e,i));return{srcStat:n,destStat:s}},checkParentPaths:function t(e,i,r,n,s){const o=y.default.resolve(y.default.dirname(e)),a=y.default.resolve(y.default.dirname(r));if(a===o||a===y.default.parse(a).root)return s();Br.stat(a,{bigint:!0},(o,l)=>o?"ENOENT"===o.code?s():s(o):Jr(i,l)?s(new Error(Zr(e,r,n))):t(e,i,a,n,s))},checkParentPathsSync:function t(e,i,r,n){const s=y.default.resolve(y.default.dirname(e)),o=y.default.resolve(y.default.dirname(r));if(o===s||o===y.default.parse(o).root)return;let a;try{a=Br.statSync(o,{bigint:!0})}catch(t){if("ENOENT"===t.code)return;throw t}if(Jr(i,a))throw new Error(Zr(e,r,n));return t(e,i,o,n)},isSrcSubdir:Xr,areIdentical:Jr};const tn=Yr.mkdirsSync;function en(t,e,i,r){const n=(r.dereference?Dr.statSync:Dr.lstatSync)(e);if(n.isDirectory())return function(t,e,i,r,n){return e?sn(i,r,n):function(t,e,i,r){return Dr.mkdirSync(i),sn(e,i,r),nn(i,t)}(t.mode,i,r,n)}(n,t,e,i,r);if(n.isFile()||n.isCharacterDevice()||n.isBlockDevice())return function(t,e,i,r,n){return e?function(t,e,i,r){if(r.overwrite)return Dr.unlinkSync(i),rn(t,e,i,r);if(r.errorOnExist)throw new Error(`'${i}' already exists`)}(t,i,r,n):rn(t,i,r,n)}(n,t,e,i,r);if(n.isSymbolicLink())return function(t,e,i,r){let n=Dr.readlinkSync(e);if(r.dereference&&(n=y.default.resolve(process.cwd(),n)),t){let t;try{t=Dr.readlinkSync(i)}catch(t){if("EINVAL"===t.code||"UNKNOWN"===t.code)return Dr.symlinkSync(n,i);throw t}if(r.dereference&&(t=y.default.resolve(process.cwd(),t)),Qr.isSrcSubdir(n,t))throw new Error(`Cannot copy '${n}' to a subdirectory of itself, '${t}'.`);if(Dr.statSync(i).isDirectory()&&Qr.isSrcSubdir(t,n))throw new Error(`Cannot overwrite '${t}' with '${n}'.`);return function(t,e){return Dr.unlinkSync(e),Dr.symlinkSync(t,e)}(n,i)}return Dr.symlinkSync(n,i)}(t,e,i,r);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}`)}function rn(t,e,i,r){return Dr.copyFileSync(e,i),r.preserveTimestamps&&function(t,e,i){(function(t){return 0==(128&t)})(t)&&function(t,e){nn(t,128|e)}(i,t),function(t,e){const i=Dr.statSync(t);!function(t,e,i){const r=Dr.openSync(t,"r+");Dr.futimesSync(r,e,i),Dr.closeSync(r)}(e,i.atime,i.mtime)}(e,i)}(t.mode,e,i),nn(i,t.mode)}function nn(t,e){return Dr.chmodSync(t,e)}function sn(t,e,i){Dr.readdirSync(t).forEach(r=>function(t,e,i,r){const n=y.default.join(e,t),s=y.default.join(i,t),{destStat:o}=Qr.checkPathsSync(n,s,"copy",r);return function(t,e,i,r){if(!r.filter||r.filter(e,i))return en(t,e,i,r)}(o,n,s,r)}(r,t,e,i))}var on={copySync: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&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");const{srcStat:r,destStat:n}=Qr.checkPathsSync(t,e,"copy",i);return Qr.checkParentPathsSync(t,r,e,"copy"),function(t,e,i,r){if(r.filter&&!r.filter(e,i))return;const n=y.default.dirname(i);return Dr.existsSync(n)||tn(n),en(t,e,i,r)}(n,t,e,i)}},an={pathExists:Tr(function(t){return Br.access(t).then(()=>!0).catch(()=>!1)}),pathExistsSync:Br.existsSync};const ln=Yr.mkdirs,cn=an.pathExists;function un(t,e,i,r,n){const s=y.default.dirname(i);cn(s,(o,a)=>o?n(o):a?dn(t,e,i,r,n):void ln(s,s=>s?n(s):dn(t,e,i,r,n)))}function hn(t,e,i,r,n,s){Promise.resolve(n.filter(i,r)).then(o=>o?t(e,i,r,n,s):s(),t=>s(t))}function dn(t,e,i,r,n){(r.dereference?Dr.stat:Dr.lstat)(e,(s,o)=>s?n(s):o.isDirectory()?function(t,e,i,r,n,s){return e?gn(i,r,n,s):function(t,e,i,r,n){Dr.mkdir(i,s=>{if(s)return n(s);gn(e,i,r,e=>e?n(e):mn(i,t,n))})}(t.mode,i,r,n,s)}(o,t,e,i,r,n):o.isFile()||o.isCharacterDevice()||o.isBlockDevice()?function(t,e,i,r,n,s){return e?function(t,e,i,r,n){if(!r.overwrite)return r.errorOnExist?n(new Error(`'${i}' already exists`)):n();Dr.unlink(i,s=>s?n(s):pn(t,e,i,r,n))}(t,i,r,n,s):pn(t,i,r,n,s)}(o,t,e,i,r,n):o.isSymbolicLink()?function(t,e,i,r,n){Dr.readlink(e,(e,s)=>e?n(e):(r.dereference&&(s=y.default.resolve(process.cwd(),s)),t?void Dr.readlink(i,(e,o)=>e?"EINVAL"===e.code||"UNKNOWN"===e.code?Dr.symlink(s,i,n):n(e):(r.dereference&&(o=y.default.resolve(process.cwd(),o)),Qr.isSrcSubdir(s,o)?n(new Error(`Cannot copy '${s}' to a subdirectory of itself, '${o}'.`)):t.isDirectory()&&Qr.isSrcSubdir(o,s)?n(new Error(`Cannot overwrite '${o}' with '${s}'.`)):function(t,e,i){Dr.unlink(e,r=>r?i(r):Dr.symlink(t,e,i))}(s,i,n))):Dr.symlink(s,i,n)))}(t,e,i,r,n):o.isSocket()?n(new Error(`Cannot copy a socket file: ${e}`)):o.isFIFO()?n(new Error(`Cannot copy a FIFO pipe: ${e}`)):n(new Error(`Unknown file: ${e}`)))}function pn(t,e,i,r,n){Dr.copyFile(e,i,s=>s?n(s):r.preserveTimestamps?function(t,e,i,r){return function(t){return 0==(128&t)}(t)?function(t,e,i){return mn(t,128|e,i)}(i,t,n=>n?r(n):fn(t,e,i,r)):fn(t,e,i,r)}(t.mode,e,i,n):mn(i,t.mode,n))}function fn(t,e,i,r){!function(t,e,i){Dr.stat(t,(t,r)=>t?i(t):function(t,e,i,r){Dr.open(t,"r+",(t,n)=>{if(t)return r(t);Dr.futimes(n,e,i,t=>{Dr.close(n,e=>{r&&r(t||e)})})})}(e,r.atime,r.mtime,i))}(e,i,e=>e?r(e):mn(i,t,r))}function mn(t,e,i){return Dr.chmod(t,e,i)}function gn(t,e,i,r){Dr.readdir(t,(n,s)=>n?r(n):yn(s,t,e,i,r))}function yn(t,e,i,r,n){const s=t.pop();return s?function(t,e,i,r,n,s){const o=y.default.join(i,e),a=y.default.join(r,e);Qr.checkPaths(o,a,"copy",n,(e,l)=>{if(e)return s(e);const{destStat:c}=l;!function(t,e,i,r,n){r.filter?hn(dn,t,e,i,r,n):dn(t,e,i,r,n)}(c,o,a,n,e=>e?s(e):yn(t,i,r,n,s))})}(t,s,e,i,r,n):n()}var bn={copy:Pr(function(t,e,i,r){"function"!=typeof i||r?"function"==typeof i&&(i={filter:i}):(r=i,i={}),r=r||function(){},(i=i||{}).clobber=!("clobber"in i)||!!i.clobber,i.overwrite="overwrite"in i?!!i.overwrite:i.clobber,i.preserveTimestamps&&"ia32"===process.arch&&console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269"),Qr.checkPaths(t,e,"copy",i,(n,s)=>{if(n)return r(n);const{srcStat:o,destStat:a}=s;Qr.checkParentPaths(t,o,e,"copy",n=>n?r(n):i.filter?hn(un,a,t,e,i,r):un(a,t,e,i,r))})})};const wn="win32"===process.platform;function vn(t){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(e=>{t[e]=t[e]||Dr[e],t[e+="Sync"]=t[e]||Dr[e]}),t.maxBusyTries=t.maxBusyTries||3}function Sn(t,e,i){let r=0;"function"==typeof e&&(i=e,e={}),S.default(t,"rimraf: missing path"),S.default.strictEqual(typeof t,"string","rimraf: path should be a string"),S.default.strictEqual(typeof i,"function","rimraf: callback function required"),S.default(e,"rimraf: invalid options argument provided"),S.default.strictEqual(typeof e,"object","rimraf: options should be object"),vn(e),En(t,e,function n(s){if(s){if(("EBUSY"===s.code||"ENOTEMPTY"===s.code||"EPERM"===s.code)&&r<e.maxBusyTries)return r++,setTimeout(()=>En(t,e,n),100*r);"ENOENT"===s.code&&(s=null)}i(s)})}function En(t,e,i){S.default(t),S.default(e),S.default("function"==typeof i),e.lstat(t,(r,n)=>r&&"ENOENT"===r.code?i(null):r&&"EPERM"===r.code&&wn?xn(t,e,r,i):n&&n.isDirectory()?On(t,e,r,i):void e.unlink(t,r=>{if(r){if("ENOENT"===r.code)return i(null);if("EPERM"===r.code)return wn?xn(t,e,r,i):On(t,e,r,i);if("EISDIR"===r.code)return On(t,e,r,i)}return i(r)}))}function xn(t,e,i,r){S.default(t),S.default(e),S.default("function"==typeof r),e.chmod(t,438,n=>{n?r("ENOENT"===n.code?null:i):e.stat(t,(n,s)=>{n?r("ENOENT"===n.code?null:i):s.isDirectory()?On(t,e,i,r):e.unlink(t,r)})})}function _n(t,e,i){let r;S.default(t),S.default(e);try{e.chmodSync(t,438)}catch(t){if("ENOENT"===t.code)return;throw i}try{r=e.statSync(t)}catch(t){if("ENOENT"===t.code)return;throw i}r.isDirectory()?kn(t,e,i):e.unlinkSync(t)}function On(t,e,i,r){S.default(t),S.default(e),S.default("function"==typeof r),e.rmdir(t,n=>{!n||"ENOTEMPTY"!==n.code&&"EEXIST"!==n.code&&"EPERM"!==n.code?r(n&&"ENOTDIR"===n.code?i:n):function(t,e,i){S.default(t),S.default(e),S.default("function"==typeof i),e.readdir(t,(r,n)=>{if(r)return i(r);let s,o=n.length;if(0===o)return e.rmdir(t,i);n.forEach(r=>{Sn(y.default.join(t,r),e,r=>{if(!s)return r?i(s=r):void(0==--o&&e.rmdir(t,i))})})})}(t,e,r)})}function Cn(t,e){let i;vn(e=e||{}),S.default(t,"rimraf: missing path"),S.default.strictEqual(typeof t,"string","rimraf: path should be a string"),S.default(e,"rimraf: missing options"),S.default.strictEqual(typeof e,"object","rimraf: options should be object");try{i=e.lstatSync(t)}catch(i){if("ENOENT"===i.code)return;"EPERM"===i.code&&wn&&_n(t,e,i)}try{i&&i.isDirectory()?kn(t,e,null):e.unlinkSync(t)}catch(i){if("ENOENT"===i.code)return;if("EPERM"===i.code)return wn?_n(t,e,i):kn(t,e,i);if("EISDIR"!==i.code)throw i;kn(t,e,i)}}function kn(t,e,i){S.default(t),S.default(e);try{e.rmdirSync(t)}catch(r){if("ENOTDIR"===r.code)throw i;if("ENOTEMPTY"===r.code||"EEXIST"===r.code||"EPERM"===r.code)!function(t,e){if(S.default(t),S.default(e),e.readdirSync(t).forEach(i=>Cn(y.default.join(t,i),e)),!wn)return e.rmdirSync(t,e);{const i=Date.now();do{try{return e.rmdirSync(t,e)}catch{}}while(Date.now()-i<500)}}(t,e);else if("ENOENT"!==r.code)throw r}}var $n=Sn;Sn.sync=Cn;var jn={remove:Pr(function(t,e){if(Dr.rm)return Dr.rm(t,{recursive:!0,force:!0},e);$n(t,e)}),removeSync:function(t){if(Dr.rmSync)return Dr.rmSync(t,{recursive:!0,force:!0});$n.sync(t)}};const An=Tr(async function(t){let e;try{e=await Br.readdir(t)}catch{return Yr.mkdirs(t)}return Promise.all(e.map(e=>jn.remove(y.default.join(t,e))))});function Pn(t){let e;try{e=Br.readdirSync(t)}catch{return Yr.mkdirsSync(t)}e.forEach(e=>{e=y.default.join(t,e),jn.removeSync(e)})}var Tn={emptyDirSync:Pn,emptydirSync:Pn,emptyDir:An,emptydir:An},In={createFile:Pr(function(t,e){function i(){Dr.writeFile(t,"",t=>{if(t)return e(t);e()})}Dr.stat(t,(r,n)=>{if(!r&&n.isFile())return e();const s=y.default.dirname(t);Dr.stat(s,(t,r)=>{if(t)return"ENOENT"===t.code?Yr.mkdirs(s,t=>{if(t)return e(t);i()}):e(t);r.isDirectory()?i():Dr.readdir(s,t=>{if(t)return e(t)})})})}),createFileSync:function(t){let e;try{e=Dr.statSync(t)}catch{}if(e&&e.isFile())return;const i=y.default.dirname(t);try{Dr.statSync(i).isDirectory()||Dr.readdirSync(i)}catch(t){if(!t||"ENOENT"!==t.code)throw t;Yr.mkdirsSync(i)}Dr.writeFileSync(t,"")}};const Nn=Pr,Fn=an.pathExists,{areIdentical:Rn}=Qr;var Ln={createLink:Nn(function(t,e,i){function r(t,e){Dr.link(t,e,t=>{if(t)return i(t);i(null)})}Dr.lstat(e,(n,s)=>{Dr.lstat(t,(n,o)=>{if(n)return n.message=n.message.replace("lstat","ensureLink"),i(n);if(s&&Rn(o,s))return i(null);const a=y.default.dirname(e);Fn(a,(n,s)=>n?i(n):s?r(t,e):void Yr.mkdirs(a,n=>{if(n)return i(n);r(t,e)}))})})}),createLinkSync:function(t,e){let i;try{i=Dr.lstatSync(e)}catch{}try{const e=Dr.lstatSync(t);if(i&&Rn(e,i))return}catch(t){throw t.message=t.message.replace("lstat","ensureLink"),t}const r=y.default.dirname(e);return Dr.existsSync(r)||Yr.mkdirsSync(r),Dr.linkSync(t,e)}};const Dn=an.pathExists,Bn=Pr,Mn=Yr.mkdirs,Gn=Yr.mkdirsSync,Hn=an.pathExists,{areIdentical:Un}=Qr;function qn(t,e,i,r){!function(t,e,i){if(y.default.isAbsolute(t))return Dr.lstat(t,e=>e?(e.message=e.message.replace("lstat","ensureSymlink"),i(e)):i(null,{toCwd:t,toDst:t}));{const r=y.default.dirname(e),n=y.default.join(r,t);Dn(n,(e,s)=>e?i(e):s?i(null,{toCwd:n,toDst:t}):Dr.lstat(t,e=>e?(e.message=e.message.replace("lstat","ensureSymlink"),i(e)):i(null,{toCwd:t,toDst:y.default.relative(r,t)})))}}(t,e,(n,s)=>{if(n)return r(n);t=s.toDst,function(t,e,i){if(i="function"==typeof e?e:i,e="function"!=typeof e&&e)return i(null,e);Dr.lstat(t,(t,r)=>{if(t)return i(null,"file");e=r&&r.isDirectory()?"dir":"file",i(null,e)})}(s.toCwd,i,(i,n)=>{if(i)return r(i);const s=y.default.dirname(e);Hn(s,(i,o)=>i?r(i):o?Br.symlink(t,e,n,r):void Mn(s,i=>{if(i)return r(i);Br.symlink(t,e,n,r)}))})})}var Vn={createSymlink:Bn(function(t,e,i,r){r="function"==typeof i?i:r,i="function"!=typeof i&&i,Br.lstat(e,(n,s)=>{!n&&s.isSymbolicLink()?Promise.all([Br.stat(t),Br.stat(e)]).then(([n,s])=>{if(Un(n,s))return r(null);qn(t,e,i,r)}):qn(t,e,i,r)})}),createSymlinkSync:function(t,e,i){let r;try{r=Br.lstatSync(e)}catch{}if(r&&r.isSymbolicLink()){const i=Br.statSync(t),r=Br.statSync(e);if(Un(i,r))return}const n=function(t,e){let i;if(y.default.isAbsolute(t)){if(i=Dr.existsSync(t),!i)throw new Error("absolute srcpath does not exist");return{toCwd:t,toDst:t}}{const r=y.default.dirname(e),n=y.default.join(r,t);if(i=Dr.existsSync(n),i)return{toCwd:n,toDst:t};if(i=Dr.existsSync(t),!i)throw new Error("relative srcpath does not exist");return{toCwd:t,toDst:y.default.relative(r,t)}}}(t,e);t=n.toDst,i=function(t,e){let i;if(e)return e;try{i=Dr.lstatSync(t)}catch{return"file"}return i&&i.isDirectory()?"dir":"file"}(n.toCwd,i);const s=y.default.dirname(e);return Br.existsSync(s)||Gn(s),Br.symlinkSync(t,e,i)}},Wn={createFile:In.createFile,createFileSync:In.createFileSync,ensureFile:In.createFile,ensureFileSync:In.createFileSync,createLink:Ln.createLink,createLinkSync:Ln.createLinkSync,ensureLink:Ln.createLink,ensureLinkSync:Ln.createLinkSync,createSymlink:Vn.createSymlink,createSymlinkSync:Vn.createSymlinkSync,ensureSymlink:Vn.createSymlink,ensureSymlinkSync:Vn.createSymlinkSync},zn=process.cwd,Yn=null,Kn=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Yn||(Yn=zn.call(process)),Yn};try{process.cwd()}catch(t){}var Jn=process.chdir;process.chdir=function(t){Yn=null,Jn.call(process,t)};var Xn=O.default.Stream,Zn=N(function(t){var e,i;"function"==typeof Symbol&&"function"==typeof Symbol.for?(e=Symbol.for("graceful-fs.queue"),i=Symbol.for("graceful-fs.previous")):(e="___graceful-fs.queue",i="___graceful-fs.previous");var r=function(){};if(C.default.debuglog?r=C.default.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(r=function(){var t=C.default.format.apply(C.default,arguments);t="GFS4: "+t.split(/\n/).join("\nGFS4: "),console.error(t)}),!I[e]){var n=[];Object.defineProperty(I,e,{get:function(){return n}}),v.default.close=function(t){function e(e,i){return t.call(v.default,e,function(t){t||a(),"function"==typeof i&&i.apply(this,arguments)})}return Object.defineProperty(e,i,{value:t}),e}(v.default.close),v.default.closeSync=function(t){function e(e){t.apply(v.default,arguments),a()}return Object.defineProperty(e,i,{value:t}),e}(v.default.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){r(I[e]),S.default.equal(I[e].length,0)})}function s(t){(function(t){var e,i;function r(e){return e?function(i,r,n){return e.call(t,i,r,function(t){c(t)&&(t=null),n&&n.apply(this,arguments)})}:e}function n(e){return e?function(i,r){try{return e.call(t,i,r)}catch(t){if(!c(t))throw t}}:e}function s(e){return e?function(i,r,n,s){return e.call(t,i,r,n,function(t){c(t)&&(t=null),s&&s.apply(this,arguments)})}:e}function o(e){return e?function(i,r,n){try{return e.call(t,i,r,n)}catch(t){if(!c(t))throw t}}:e}function a(e){return e?function(i,r,n){function s(t,e){e&&(e.uid<0&&(e.uid+=4294967296),e.gid<0&&(e.gid+=4294967296)),n&&n.apply(this,arguments)}return"function"==typeof r&&(n=r,r=null),r?e.call(t,i,r,s):e.call(t,i,s)}:e}function l(e){return e?function(i,r){var n=r?e.call(t,i,r):e.call(t,i);return n.uid<0&&(n.uid+=4294967296),n.gid<0&&(n.gid+=4294967296),n}:e}function c(t){return!t||"ENOSYS"===t.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==t.code&&"EPERM"!==t.code)}k.default.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(t){t.lchmod=function(e,i,r){t.open(e,k.default.O_WRONLY|k.default.O_SYMLINK,i,function(e,n){e?r&&r(e):t.fchmod(n,i,function(e){t.close(n,function(t){r&&r(e||t)})})})},t.lchmodSync=function(e,i){var r,n=t.openSync(e,k.default.O_WRONLY|k.default.O_SYMLINK,i),s=!0;try{r=t.fchmodSync(n,i),s=!1}finally{if(s)try{t.closeSync(n)}catch(t){}else t.closeSync(n)}return r}}(t),t.lutimes||function(t){k.default.hasOwnProperty("O_SYMLINK")?(t.lutimes=function(e,i,r,n){t.open(e,k.default.O_SYMLINK,function(e,s){e?n&&n(e):t.futimes(s,i,r,function(e){t.close(s,function(t){n&&n(e||t)})})})},t.lutimesSync=function(e,i,r){var n,s=t.openSync(e,k.default.O_SYMLINK),o=!0;try{n=t.futimesSync(s,i,r),o=!1}finally{if(o)try{t.closeSync(s)}catch(t){}else t.closeSync(s)}return n}):(t.lutimes=function(t,e,i,r){r&&process.nextTick(r)},t.lutimesSync=function(){})}(t),t.chown=s(t.chown),t.fchown=s(t.fchown),t.lchown=s(t.lchown),t.chmod=r(t.chmod),t.fchmod=r(t.fchmod),t.lchmod=r(t.lchmod),t.chownSync=o(t.chownSync),t.fchownSync=o(t.fchownSync),t.lchownSync=o(t.lchownSync),t.chmodSync=n(t.chmodSync),t.fchmodSync=n(t.fchmodSync),t.lchmodSync=n(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=l(t.statSync),t.fstatSync=l(t.fstatSync),t.lstatSync=l(t.lstatSync),t.lchmod||(t.lchmod=function(t,e,i){i&&process.nextTick(i)},t.lchmodSync=function(){}),t.lchown||(t.lchown=function(t,e,i,r){r&&process.nextTick(r)},t.lchownSync=function(){}),"win32"===Kn&&(t.rename=(e=t.rename,function(i,r,n){var s=Date.now(),o=0;e(i,r,function a(l){if(l&&("EACCES"===l.code||"EPERM"===l.code)&&Date.now()-s<6e4)return setTimeout(function(){t.stat(r,function(t,s){t&&"ENOENT"===t.code?e(i,r,a):n(l)})},o),void(o<100&&(o+=10));n&&n(l)})})),t.read=function(e){function i(i,r,n,s,o,a){var l;if(a&&"function"==typeof a){var c=0;l=function(u,h,d){if(u&&"EAGAIN"===u.code&&c<10)return c++,e.call(t,i,r,n,s,o,l);a.apply(this,arguments)}}return e.call(t,i,r,n,s,o,l)}return i.__proto__=e,i}(t.read),t.readSync=(i=t.readSync,function(e,r,n,s,o){for(var a=0;;)try{return i.call(t,e,r,n,s,o)}catch(t){if("EAGAIN"===t.code&&a<10){a++;continue}throw t}})})(t),t.gracefulify=s,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,r){return"function"==typeof i&&(r=i,i=null),function t(i,r,n){return e(i,r,function(e){!e||"EMFILE"!==e.code&&"ENFILE"!==e.code?("function"==typeof n&&n.apply(this,arguments),a()):o([t,[i,r,n]])})}(t,i,r)};var i=t.writeFile;t.writeFile=function(t,e,r,n){return"function"==typeof r&&(n=r,r=null),function t(e,r,n,s){return i(e,r,n,function(i){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?("function"==typeof s&&s.apply(this,arguments),a()):o([t,[e,r,n,s]])})}(t,e,r,n)};var r=t.appendFile;r&&(t.appendFile=function(t,e,i,n){return"function"==typeof i&&(n=i,i=null),function t(e,i,n,s){return r(e,i,n,function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?("function"==typeof s&&s.apply(this,arguments),a()):o([t,[e,i,n,s]])})}(t,e,i,n)});var n=t.readdir;function l(e){return n.apply(t,e)}if(t.readdir=function(t,e,i){var r=[t];return"function"!=typeof e?r.push(e):i=e,r.push(function(t,e){e&&e.sort&&e.sort(),!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?("function"==typeof i&&i.apply(this,arguments),a()):o([l,[r]])}),l(r)},"v0.8"===process.version.substr(0,4)){var c=function(t){return{ReadStream:function e(i,r){if(!(this instanceof e))return new e(i,r);Xn.call(this);var n=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,r=r||{};for(var s=Object.keys(r),o=0,a=s.length;o<a;o++){var l=s[o];this[l]=r[l]}if(this.encoding&&this.setEncoding(this.encoding),void 0!==this.start){if("number"!=typeof this.start)throw TypeError("start must be a Number");if(void 0===this.end)this.end=Infinity;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}null===this.fd?t.open(this.path,this.flags,this.mode,function(t,e){if(t)return n.emit("error",t),void(n.readable=!1);n.fd=e,n.emit("open",e),n._read()}):process.nextTick(function(){n._read()})},WriteStream:function e(i,r){if(!(this instanceof e))return new e(i,r);Xn.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var n=Object.keys(r),s=0,o=n.length;s<o;s++){var a=n[s];this[a]=r[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())}}}(t);f=c.ReadStream,m=c.WriteStream}var u=t.ReadStream;u&&(f.prototype=Object.create(u.prototype),f.prototype.open=function(){var t=this;y(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 h=t.WriteStream;h&&(m.prototype=Object.create(h.prototype),m.prototype.open=function(){var t=this;y(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 f},set:function(t){f=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return m},set:function(t){m=t},enumerable:!0,configurable:!0});var d=f;Object.defineProperty(t,"FileReadStream",{get:function(){return d},set:function(t){d=t},enumerable:!0,configurable:!0});var p=m;function f(t,e){return this instanceof f?(u.apply(this,arguments),this):f.apply(Object.create(f.prototype),arguments)}function m(t,e){return this instanceof m?(h.apply(this,arguments),this):m.apply(Object.create(m.prototype),arguments)}Object.defineProperty(t,"FileWriteStream",{get:function(){return p},set:function(t){p=t},enumerable:!0,configurable:!0});var g=t.open;function y(t,e,i,r){return"function"==typeof i&&(r=i,i=null),function t(e,i,r,n){return g(e,i,r,function(s,l){!s||"EMFILE"!==s.code&&"ENFILE"!==s.code?("function"==typeof n&&n.apply(this,arguments),a()):o([t,[e,i,r,n]])})}(t,e,i,r)}return t.open=y,t}function o(t){r("ENQUEUE",t[0].name,t[1]),I[e].push(t)}function a(){var t=I[e].shift();t&&(r("RETRY",t[0].name,t[1]),t[0].apply(null,t[1]))}t.exports=s(function(t){if(null===t||"object"!=typeof t)return t;if(t instanceof Object)var e={__proto__:t.__proto__};else e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}(v.default)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!v.default.__patched&&(t.exports=s(v.default),v.default.__patched=!0)}),Qn={stringify:function(t,{EOL:e="\n",finalEOL:i=!0,replacer:r=null,spaces:n}={}){const s=i?e:"";return JSON.stringify(t,r,n).replace(/\n/g,e)+s},stripBom:function(t){return Buffer.isBuffer(t)&&(t=t.toString("utf8")),t.replace(/^\uFEFF/,"")}};let ts;try{ts=Zn}catch(t){ts=v.default}const{stringify:es,stripBom:is}=Qn,rs={readFile:Tr(async function(t,e={}){"string"==typeof e&&(e={encoding:e});const i=e.fs||ts,r=!("throws"in e)||e.throws;let n,s=await Pr(i.readFile)(t,e);s=is(s);try{n=JSON.parse(s,e?e.reviver:null)}catch(e){if(r)throw e.message=`${t}: ${e.message}`,e;return null}return n}),readFileSync:function(t,e={}){"string"==typeof e&&(e={encoding:e});const i=e.fs||ts,r=!("throws"in e)||e.throws;try{let r=i.readFileSync(t,e);return r=is(r),JSON.parse(r,e.reviver)}catch(e){if(r)throw e.message=`${t}: ${e.message}`,e;return null}},writeFile:Tr(async function(t,e,i={}){const r=i.fs||ts,n=es(e,i);await Pr(r.writeFile)(t,n,i)}),writeFileSync:function(t,e,i={}){const r=i.fs||ts,n=es(e,i);return r.writeFileSync(t,n,i)}};var ns={readJson:rs.readFile,readJsonSync:rs.readFileSync,writeJson:rs.writeFile,writeJsonSync:rs.writeFileSync};const ss=an.pathExists;var os={outputFile:Pr(function(t,e,i,r){"function"==typeof i&&(r=i,i="utf8");const n=y.default.dirname(t);ss(n,(s,o)=>s?r(s):o?Dr.writeFile(t,e,i,r):void Yr.mkdirs(n,n=>{if(n)return r(n);Dr.writeFile(t,e,i,r)}))}),outputFileSync:function(t,...e){const i=y.default.dirname(t);if(Dr.existsSync(i))return Dr.writeFileSync(t,...e);Yr.mkdirsSync(i),Dr.writeFileSync(t,...e)}};const{stringify:as}=Qn,{outputFile:ls}=os,{stringify:cs}=Qn,{outputFileSync:us}=os;ns.outputJson=Tr(async function(t,e,i={}){const r=as(e,i);await ls(t,r,i)}),ns.outputJsonSync=function(t,e,i){const r=cs(e,i);us(t,r,i)},ns.outputJSON=ns.outputJson,ns.outputJSONSync=ns.outputJsonSync,ns.writeJSON=ns.writeJson,ns.writeJSONSync=ns.writeJsonSync,ns.readJSON=ns.readJson,ns.readJSONSync=ns.readJsonSync;var hs=ns;const ds=on.copySync,ps=jn.removeSync,fs=Yr.mkdirpSync;function ms(t,e,i){try{Dr.renameSync(t,e)}catch(r){if("EXDEV"!==r.code)throw r;return function(t,e,i){return ds(t,e,{overwrite:i,errorOnExist:!0}),ps(t)}(t,e,i)}}var gs={moveSync:function(t,e,i){const r=(i=i||{}).overwrite||i.clobber||!1,{srcStat:n,isChangingCase:s=!1}=Qr.checkPathsSync(t,e,"move",i);return Qr.checkParentPathsSync(t,n,e,"move"),function(t){const e=y.default.dirname(t);return y.default.parse(e).root===e}(e)||fs(y.default.dirname(e)),function(t,e,i,r){if(r)return ms(t,e,i);if(i)return ps(e),ms(t,e,i);if(Dr.existsSync(e))throw new Error("dest already exists.");return ms(t,e,i)}(t,e,r,s)}};const ys=bn.copy,bs=jn.remove,ws=Yr.mkdirp,vs=an.pathExists;function Ss(t,e,i,r,n){return r?Es(t,e,i,n):i?bs(e,r=>r?n(r):Es(t,e,i,n)):void vs(e,(r,s)=>r?n(r):s?n(new Error("dest already exists.")):Es(t,e,i,n))}function Es(t,e,i,r){Dr.rename(t,e,n=>n?"EXDEV"!==n.code?r(n):function(t,e,i,r){ys(t,e,{overwrite:i,errorOnExist:!0},e=>e?r(e):bs(t,r))}(t,e,i,r):r())}var xs={move:Pr(function(t,e,i,r){"function"==typeof i&&(r=i,i={});const n=i.overwrite||i.clobber||!1;Qr.checkPaths(t,e,"move",i,(i,s)=>{if(i)return r(i);const{srcStat:o,isChangingCase:a=!1}=s;Qr.checkParentPaths(t,o,e,"move",i=>i?r(i):function(t){const e=y.default.dirname(t);return y.default.parse(e).root===e}(e)?Ss(t,e,n,a,r):void ws(y.default.dirname(e),i=>i?r(i):Ss(t,e,n,a,r)))})})},_s={...Br,...on,...bn,...Tn,...Wn,...hs,...Yr,...gs,...xs,...os,...an,...jn};const Os=(...t)=>t.every(t=>t)?t.join(""):"",Cs=t=>t?encodeURIComponent(t):"",ks={sshtemplate:({domain:t,user:e,project:i,committish:r})=>`git@${t}:${e}/${i}.git${Os("#",r)}`,sshurltemplate:({domain:t,user:e,project:i,committish:r})=>`git+ssh://git@${t}/${e}/${i}.git${Os("#",r)}`,browsetemplate:({domain:t,user:e,project:i,committish:r,treepath:n})=>`https://${t}/${e}/${i}${Os("/",n,"/",Cs(r))}`,browsefiletemplate:({domain:t,user:e,project:i,committish:r,treepath:n,path:s,fragment:o,hashformat:a})=>`https://${t}/${e}/${i}/${n}/${Cs(r||"master")}/${s}${Os("#",a(o||""))}`,docstemplate:({domain:t,user:e,project:i,treepath:r,committish:n})=>`https://${t}/${e}/${i}${Os("/",r,"/",Cs(n))}#readme`,httpstemplate:({auth:t,domain:e,user:i,project:r,committish:n})=>`git+https://${Os(t,"@")}${e}/${i}/${r}.git${Os("#",n)}`,filetemplate:({domain:t,user:e,project:i,committish:r,path:n})=>`https://${t}/${e}/${i}/raw/${Cs(r)||"master"}/${n}`,shortcuttemplate:({type:t,user:e,project:i,committish:r})=>`${t}:${e}/${i}${Os("#",r)}`,pathtemplate:({user:t,project:e,committish:i})=>`${t}/${e}${Os("#",i)}`,bugstemplate:({domain:t,user:e,project:i})=>`https://${t}/${e}/${i}/issues`,hashformat:As},$s={};$s.github=Object.assign({},ks,{protocols:["git:","http:","git+ssh:","git+https:","ssh:","https:"],domain:"github.com",treepath:"tree",filetemplate:({auth:t,user:e,project:i,committish:r,path:n})=>`https://${Os(t,"@")}raw.githubusercontent.com/${e}/${i}/${Cs(r)||"master"}/${n}`,gittemplate:({auth:t,domain:e,user:i,project:r,committish:n})=>`git://${Os(t,"@")}${e}/${i}/${r}.git${Os("#",n)}`,tarballtemplate:({domain:t,user:e,project:i,committish:r})=>`https://codeload.${t}/${e}/${i}/tar.gz/${Cs(r)||"master"}`,extract:t=>{let[,e,i,r,n]=t.pathname.split("/",5);if((!r||"tree"===r)&&(r||(n=t.hash.slice(1)),i&&i.endsWith(".git")&&(i=i.slice(0,-4)),e&&i))return{user:e,project:i,committish:n}}}),$s.bitbucket=Object.assign({},ks,{protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"bitbucket.org",treepath:"src",tarballtemplate:({domain:t,user:e,project:i,committish:r})=>`https://${t}/${e}/${i}/get/${Cs(r)||"master"}.tar.gz`,extract:t=>{let[,e,i,r]=t.pathname.split("/",4);if(!["get"].includes(r)&&(i&&i.endsWith(".git")&&(i=i.slice(0,-4)),e&&i))return{user:e,project:i,committish:t.hash.slice(1)}}}),$s.gitlab=Object.assign({},ks,{protocols:["git+ssh:","git+https:","ssh:","https:"],domain:"gitlab.com",treepath:"tree",httpstemplate:({auth:t,domain:e,user:i,project:r,committish:n})=>`git+https://${Os(t,"@")}${e}/${i}/${r}.git${Os("#",n)}`,tarballtemplate:({domain:t,user:e,project:i,committish:r})=>`https://${t}/${e}/${i}/repository/archive.tar.gz?ref=${Cs(r)||"master"}`,extract:t=>{const e=t.pathname.slice(1);if(e.includes("/-/")||e.includes("/archive.tar.gz"))return;const i=e.split("/");let r=i.pop();r.endsWith(".git")&&(r=r.slice(0,-4));const n=i.join("/");return n&&r?{user:n,project:r,committish:t.hash.slice(1)}:void 0}}),$s.gist=Object.assign({},ks,{protocols:["git:","git+ssh:","git+https:","ssh:","https:"],domain:"gist.github.com",sshtemplate:({domain:t,project:e,committish:i})=>`git@${t}:${e}.git${Os("#",i)}`,sshurltemplate:({domain:t,project:e,committish:i})=>`git+ssh://git@${t}/${e}.git${Os("#",i)}`,browsetemplate:({domain:t,project:e,committish:i})=>`https://${t}/${e}${Os("/",Cs(i))}`,browsefiletemplate:({domain:t,project:e,committish:i,path:r,hashformat:n})=>`https://${t}/${e}${Os("/",Cs(i))}${Os("#",n(r))}`,docstemplate:({domain:t,project:e,committish:i})=>`https://${t}/${e}${Os("/",Cs(i))}`,httpstemplate:({domain:t,project:e,committish:i})=>`git+https://${t}/${e}.git${Os("#",i)}`,filetemplate:({user:t,project:e,committish:i,path:r})=>`https://gist.githubusercontent.com/${t}/${e}/raw${Os("/",Cs(i))}/${r}`,shortcuttemplate:({type:t,project:e,committish:i})=>`${t}:${e}${Os("#",i)}`,pathtemplate:({project:t,committish:e})=>`${t}${Os("#",e)}`,bugstemplate:({domain:t,project:e})=>`https://${t}/${e}`,gittemplate:({domain:t,project:e,committish:i})=>`git://${t}/${e}.git${Os("#",i)}`,tarballtemplate:({project:t,committish:e})=>`https://codeload.github.com/gist/${t}/tar.gz/${Cs(e)||"master"}`,extract:t=>{let[,e,i,r]=t.pathname.split("/",4);if("raw"!==r){if(!i){if(!e)return;i=e,e=null}return i.endsWith(".git")&&(i=i.slice(0,-4)),{user:e,project:i,committish:t.hash.slice(1)}}},hashformat:function(t){return t&&"file-"+As(t)}}),$s.sourcehut=Object.assign({},ks,{protocols:["git+ssh:","https:"],domain:"git.sr.ht",treepath:"tree",browsefiletemplate:({domain:t,user:e,project:i,committish:r,treepath:n,path:s,fragment:o,hashformat:a})=>`https://${t}/${e}/${i}/${n}/${Cs(r||"main")}/${s}${Os("#",a(o||""))}`,filetemplate:({domain:t,user:e,project:i,committish:r,path:n})=>`https://${t}/${e}/${i}/blob/${Cs(r)||"main"}/${n}`,httpstemplate:({domain:t,user:e,project:i,committish:r})=>`https://${t}/${e}/${i}.git${Os("#",r)}`,tarballtemplate:({domain:t,user:e,project:i,committish:r})=>`https://${t}/${e}/${i}/archive/${Cs(r)||"main"}.tar.gz`,bugstemplate:({user:t,project:e})=>`https://todo.sr.ht/${t}/${e}`,docstemplate:({domain:t,user:e,project:i,treepath:r,committish:n})=>`https://${t}/${e}/${i}${Os("/",r,"/",Cs(n))}#readme`,extract:t=>{let[,e,i,r]=t.pathname.split("/",4);if(!["archive"].includes(r)&&(i&&i.endsWith(".git")&&(i=i.slice(0,-4)),e&&i))return{user:e,project:i,committish:t.hash.slice(1)}}});const js=Object.keys($s);$s.byShortcut={},$s.byDomain={};for(const t of js)$s.byShortcut[`${t}:`]=t,$s.byDomain[$s[t].domain]=t;function As(t){return t.toLowerCase().replace(/^\W+|\/|\W+$/g,"").replace(/\W+/g,"-")}var Ps=$s,Ts=Is;function Is(t){var e=this;if(e instanceof Is||(e=new Is),e.tail=null,e.head=null,e.length=0,t&&"function"==typeof t.forEach)t.forEach(function(t){e.push(t)});else if(arguments.length>0)for(var i=0,r=arguments.length;i<r;i++)e.push(arguments[i]);return e}function Ns(t,e,i){var r=e===t.head?new Ls(i,null,e,t):new Ls(i,e,e.next,t);return null===r.next&&(t.tail=r),null===r.prev&&(t.head=r),t.length++,r}function Fs(t,e){t.tail=new Ls(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function Rs(t,e){t.head=new Ls(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++}function Ls(t,e,i,r){if(!(this instanceof Ls))return new Ls(t,e,i,r);this.list=r,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,i?(i.prev=this,this.next=i):this.next=null}Is.Node=Ls,Is.create=Is,Is.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,i=t.prev;return e&&(e.prev=i),i&&(i.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=i),t.list.length--,t.next=null,t.prev=null,t.list=null,e},Is.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}},Is.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}},Is.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)Fs(this,arguments[t]);return this.length},Is.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)Rs(this,arguments[t]);return this.length},Is.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}},Is.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}},Is.prototype.forEach=function(t,e){e=e||this;for(var i=this.head,r=0;null!==i;r++)t.call(e,i.value,r,this),i=i.next},Is.prototype.forEachReverse=function(t,e){e=e||this;for(var i=this.tail,r=this.length-1;null!==i;r--)t.call(e,i.value,r,this),i=i.prev},Is.prototype.get=function(t){for(var e=0,i=this.head;null!==i&&e<t;e++)i=i.next;if(e===t&&null!==i)return i.value},Is.prototype.getReverse=function(t){for(var e=0,i=this.tail;null!==i&&e<t;e++)i=i.prev;if(e===t&&null!==i)return i.value},Is.prototype.map=function(t,e){e=e||this;for(var i=new Is,r=this.head;null!==r;)i.push(t.call(e,r.value,this)),r=r.next;return i},Is.prototype.mapReverse=function(t,e){e=e||this;for(var i=new Is,r=this.tail;null!==r;)i.push(t.call(e,r.value,this)),r=r.prev;return i},Is.prototype.reduce=function(t,e){var i,r=this.head;if(arguments.length>1)i=e;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");r=this.head.next,i=this.head.value}for(var n=0;null!==r;n++)i=t(i,r.value,n),r=r.next;return i},Is.prototype.reduceReverse=function(t,e){var i,r=this.tail;if(arguments.length>1)i=e;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");r=this.tail.prev,i=this.tail.value}for(var n=this.length-1;null!==r;n--)i=t(i,r.value,n),r=r.prev;return i},Is.prototype.toArray=function(){for(var t=new Array(this.length),e=0,i=this.head;null!==i;e++)t[e]=i.value,i=i.next;return t},Is.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,i=this.tail;null!==i;e++)t[e]=i.value,i=i.prev;return t},Is.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var i=new Is;if(e<t||e<0)return i;t<0&&(t=0),e>this.length&&(e=this.length);for(var r=0,n=this.head;null!==n&&r<t;r++)n=n.next;for(;null!==n&&r<e;r++,n=n.next)i.push(n.value);return i},Is.prototype.sliceReverse=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var i=new Is;if(e<t||e<0)return i;t<0&&(t=0),e>this.length&&(e=this.length);for(var r=this.length,n=this.tail;null!==n&&r>e;r--)n=n.prev;for(;null!==n&&r>t;r--,n=n.prev)i.push(n.value);return i},Is.prototype.splice=function(t,e,...i){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var r=0,n=this.head;null!==n&&r<t;r++)n=n.next;var s=[];for(r=0;n&&r<e;r++)s.push(n.value),n=this.removeNode(n);for(null===n&&(n=this.tail),n!==this.head&&n!==this.tail&&(n=n.prev),r=0;r<i.length;r++)n=Ns(this,n,i[r]);return s},Is.prototype.reverse=function(){for(var t=this.head,e=this.tail,i=t;null!==i;i=i.prev){var r=i.prev;i.prev=i.next,i.next=r}return this.head=e,this.tail=t,this};try{!function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}(Is)}catch(t){}const Ds=Symbol("max"),Bs=Symbol("length"),Ms=Symbol("lengthCalculator"),Gs=Symbol("allowStale"),Hs=Symbol("maxAge"),Us=Symbol("dispose"),qs=Symbol("noDisposeOnSet"),Vs=Symbol("lruList"),Ws=Symbol("cache"),zs=Symbol("updateAgeOnGet"),Ys=()=>1,Ks=(t,e,i)=>{const r=t[Ws].get(e);if(r){const e=r.value;if(Js(t,e)){if(Zs(t,r),!t[Gs])return}else i&&(t[zs]&&(r.value.now=Date.now()),t[Vs].unshiftNode(r));return e.value}},Js=(t,e)=>{if(!e||!e.maxAge&&!t[Hs])return!1;const i=Date.now()-e.now;return e.maxAge?i>e.maxAge:t[Hs]&&i>t[Hs]},Xs=t=>{if(t[Bs]>t[Ds])for(let e=t[Vs].tail;t[Bs]>t[Ds]&&null!==e;){const i=e.prev;Zs(t,e),e=i}},Zs=(t,e)=>{if(e){const i=e.value;t[Us]&&t[Us](i.key,i.value),t[Bs]-=i.length,t[Ws].delete(i.key),t[Vs].removeNode(e)}};class Qs{constructor(t,e,i,r,n){this.key=t,this.value=e,this.length=i,this.now=r,this.maxAge=n||0}}const to=(t,e,i,r)=>{let n=i.value;Js(t,n)&&(Zs(t,i),t[Gs]||(n=void 0)),n&&e.call(r,n.value,n.key,t)};var eo=N(function(t){const e=t.exports=class{constructor(t,e,i,r,n,s,o={}){Object.assign(this,Ps[t]),this.type=t,this.user=e,this.auth=i,this.project=r,this.committish=n,this.default=s,this.opts=o}hash(){return this.committish?`#${this.committish}`:""}ssh(t){return this._fill(this.sshtemplate,t)}_fill(t,e){if("function"==typeof t){const i={...this,...this.opts,...e};i.path||(i.path=""),i.path.startsWith("/")&&(i.path=i.path.slice(1)),i.noCommittish&&(i.committish=null);const r=t(i);return i.noGitPlus&&r.startsWith("git+")?r.slice(4):r}return null}sshurl(t){return this._fill(this.sshurltemplate,t)}browse(t,e,i){return"string"!=typeof t?this._fill(this.browsetemplate,t):("string"!=typeof e&&(i=e,e=null),this._fill(this.browsefiletemplate,{...i,fragment:e,path:t}))}docs(t){return this._fill(this.docstemplate,t)}bugs(t){return this._fill(this.bugstemplate,t)}https(t){return this._fill(this.httpstemplate,t)}git(t){return this._fill(this.gittemplate,t)}shortcut(t){return this._fill(this.shortcuttemplate,t)}path(t){return this._fill(this.pathtemplate,t)}tarball(t){return this._fill(this.tarballtemplate,{...t,noCommittish:!1})}file(t,e){return this._fill(this.filetemplate,{...e,path:t})}getDefaultRepresentation(){return this.default}toString(t){return this.default&&"function"==typeof this[this.default]?this[this.default](t):this.sshurl(t)}},i=new class{constructor(t){if("number"==typeof t&&(t={max:t}),t||(t={}),t.max&&("number"!=typeof t.max||t.max<0))throw new TypeError("max must be a non-negative number");this[Ds]=t.max||Infinity;const e=t.length||Ys;if(this[Ms]="function"!=typeof e?Ys:e,this[Gs]=t.stale||!1,t.maxAge&&"number"!=typeof t.maxAge)throw new TypeError("maxAge must be a number");this[Hs]=t.maxAge||0,this[Us]=t.dispose,this[qs]=t.noDisposeOnSet||!1,this[zs]=t.updateAgeOnGet||!1,this.reset()}set max(t){if("number"!=typeof t||t<0)throw new TypeError("max must be a non-negative number");this[Ds]=t||Infinity,Xs(this)}get max(){return this[Ds]}set allowStale(t){this[Gs]=!!t}get allowStale(){return this[Gs]}set maxAge(t){if("number"!=typeof t)throw new TypeError("maxAge must be a non-negative number");this[Hs]=t,Xs(this)}get maxAge(){return this[Hs]}set lengthCalculator(t){"function"!=typeof t&&(t=Ys),t!==this[Ms]&&(this[Ms]=t,this[Bs]=0,this[Vs].forEach(t=>{t.length=this[Ms](t.value,t.key),this[Bs]+=t.length})),Xs(this)}get lengthCalculator(){return this[Ms]}get length(){return this[Bs]}get itemCount(){return this[Vs].length}rforEach(t,e){e=e||this;for(let i=this[Vs].tail;null!==i;){const r=i.prev;to(this,t,i,e),i=r}}forEach(t,e){e=e||this;for(let i=this[Vs].head;null!==i;){const r=i.next;to(this,t,i,e),i=r}}keys(){return this[Vs].toArray().map(t=>t.key)}values(){return this[Vs].toArray().map(t=>t.value)}reset(){this[Us]&&this[Vs]&&this[Vs].length&&this[Vs].forEach(t=>this[Us](t.key,t.value)),this[Ws]=new Map,this[Vs]=new Ts,this[Bs]=0}dump(){return this[Vs].map(t=>!Js(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)}).toArray().filter(t=>t)}dumpLru(){return this[Vs]}set(t,e,i){if((i=i||this[Hs])&&"number"!=typeof i)throw new TypeError("maxAge must be a number");const r=i?Date.now():0,n=this[Ms](e,t);if(this[Ws].has(t)){if(n>this[Ds])return Zs(this,this[Ws].get(t)),!1;const s=this[Ws].get(t).value;return this[Us]&&(this[qs]||this[Us](t,s.value)),s.now=r,s.maxAge=i,s.value=e,this[Bs]+=n-s.length,s.length=n,this.get(t),Xs(this),!0}const s=new Qs(t,e,n,r,i);return s.length>this[Ds]?(this[Us]&&this[Us](t,e),!1):(this[Bs]+=s.length,this[Vs].unshift(s),this[Ws].set(t,this[Vs].head),Xs(this),!0)}has(t){if(!this[Ws].has(t))return!1;const e=this[Ws].get(t).value;return!Js(this,e)}get(t){return Ks(this,t,!0)}peek(t){return Ks(this,t,!1)}pop(){const t=this[Vs].tail;return t?(Zs(this,t),t.value):null}del(t){Zs(this,this[Ws].get(t))}load(t){this.reset();const e=Date.now();for(let i=t.length-1;i>=0;i--){const r=t[i],n=r.e||0;if(0===n)this.set(r.k,r.v);else{const t=n-e;t>0&&this.set(r.k,r.v,t)}}}prune(){this[Ws].forEach((t,e)=>Ks(this,e,!1))}}({max:1e3}),r={"git+ssh:":"sshurl","git+https:":"https","ssh:":"sshurl","git:":"git"},n={"git:":!0,"https:":!0,"git+https:":!0,"http:":!0,"git+http:":!0},s=Object.keys(Ps.byShortcut).concat(["http:","https:","git:","git+ssh:","git+https:","ssh:"]);t.exports.fromUrl=function(t,s){if("string"!=typeof t)return;const c=t+JSON.stringify(s||{});return i.has(c)||i.set(c,function(t,i){if(!t)return;const s=a(t)?"github:"+t:o(t),c=l(s);if(!c)return c;const u=Ps.byShortcut[c.protocol],h=Ps.byDomain[c.hostname.startsWith("www.")?c.hostname.slice(4):c.hostname],d=u||h;if(!d)return;const p=Ps[u||h];let f=null;n[c.protocol]&&(c.username||c.password)&&(f=`${c.username}${c.password?":"+c.password:""}`);let m=null,g=null,y=null,b=null;try{if(u){let t=c.pathname.startsWith("/")?c.pathname.slice(1):c.pathname;const e=t.indexOf("@");e>-1&&(t=t.slice(e+1));const i=t.lastIndexOf("/");i>-1?(g=decodeURIComponent(t.slice(0,i)),g||(g=null),y=decodeURIComponent(t.slice(i+1))):y=decodeURIComponent(t),y.endsWith(".git")&&(y=y.slice(0,-4)),c.hash&&(m=decodeURIComponent(c.hash.slice(1))),b="shortcut"}else{if(!p.protocols.includes(c.protocol))return;const t=p.extract(c);if(!t)return;g=t.user&&decodeURIComponent(t.user),y=decodeURIComponent(t.project),m=decodeURIComponent(t.committish),b=r[w=c.protocol]||w.slice(0,-1)}}catch(t){if(t instanceof URIError)return;throw t}var w;return new e(d,g,f,y,m,b,i)}(t,s)),i.get(c)};const o=t=>{const e=t.indexOf(":"),i=t.slice(0,e+1);if(s.includes(i))return t;const r=t.indexOf("@");return r>-1?r>e?`git+ssh://${t}`:t:t.indexOf("//")===e+1?t:t.slice(0,e+1)+"//"+t.slice(e+1)},a=t=>{const e=t.indexOf("#"),i=t.indexOf("/"),r=t.indexOf("/",i+1),n=t.indexOf(":"),s=/\s/.exec(t),o=t.indexOf("@"),a=!s||e>-1&&s.index>e,l=-1===o||e>-1&&o>e,c=-1===n||e>-1&&n>e,u=-1===r||e>-1&&r>e,h=i>0,d=e>-1?"/"!==t[e-1]:!t.endsWith("/"),p=!t.startsWith(".");return a&&h&&d&&p&&l&&c&&u},l=t=>{let e;try{e=new $.default.URL(t)}catch(t){}if(e)return e;const i=(t=>{const e=t.indexOf("@"),i=t.lastIndexOf("#");let r,n=t.indexOf(":"),s=t.lastIndexOf(":",i>-1?i:Infinity);return s>e&&(r=t.slice(0,s)+"/"+t.slice(s+1),n=r.indexOf(":"),s=r.lastIndexOf(":")),-1===n&&-1===t.indexOf("//")&&(r=`git+ssh://${r}`),r})(t);try{e=new $.default.URL(i)}catch(t){}return e}}),io=/[‘“!#$%&+^<=>`]/,ro=N(function(t){const e="win32"===process.platform,i="linux"===process.platform,r={bullet:"•",check:"√",cross:"×",ellipsis:"...",heart:"❤",info:"i",line:"─",middot:"·",minus:"-",plus:"+",question:"?",questionSmall:"﹖",pointer:">",pointerSmall:"»",warning:"‼"},n={ballotCross:"✘",bullet:"•",check:"✔",cross:"✖",ellipsis:"…",heart:"❤",info:"ℹ",line:"─",middot:"·",minus:"-",plus:"+",question:"?",questionFull:"?",questionSmall:"﹖",pointer:i?"▸":"❯",pointerSmall:i?"‣":"›",warning:"⚠"};t.exports=e?r:n,Reflect.defineProperty(t.exports,"windows",{enumerable:!1,value:r}),Reflect.defineProperty(t.exports,"other",{enumerable:!1,value:n})});const no={enabled:!0,visible:!0,styles:{},keys:{}};"FORCE_COLOR"in process.env&&(no.enabled="0"!==process.env.FORCE_COLOR);const so=(t,e,i)=>{let{open:r,close:n,regex:s}=t;return e=r+(e.includes(n)?e.replace(s,n+r):e)+n,i?e.replace(/\r?\n/g,`${n}$&${r}`):e},oo=(t,e,i)=>{var r;no.styles[t]=((r={name:t,codes:e}).open=`[${r.codes[0]}m`,r.close=`[${r.codes[1]}m`,r.regex=new RegExp(`\\u001b\\[${r.codes[1]}m`,"g"),r),(no.keys[i]||(no.keys[i]=[])).push(t),Reflect.defineProperty(no,t,{get(){let e=t=>((t,e)=>{if(""===t||null==t)return"";if(!1===no.enabled)return t;if(!1===no.visible)return"";let i=""+t,r=i.includes("\n"),n=e.length;for(;n-- >0;)i=so(no.styles[e[n]],i,r);return i})(t,e.stack);return Reflect.setPrototypeOf(e,no),e.stack=this.stack?this.stack.concat(t):[t],e}})};oo("reset",[0,0],"modifier"),oo("bold",[1,22],"modifier"),oo("dim",[2,22],"modifier"),oo("italic",[3,23],"modifier"),oo("underline",[4,24],"modifier"),oo("inverse",[7,27],"modifier"),oo("hidden",[8,28],"modifier"),oo("strikethrough",[9,29],"modifier"),oo("black",[30,39],"color"),oo("red",[31,39],"color"),oo("green",[32,39],"color"),oo("yellow",[33,39],"color"),oo("blue",[34,39],"color"),oo("magenta",[35,39],"color"),oo("cyan",[36,39],"color"),oo("white",[37,39],"color"),oo("gray",[90,39],"color"),oo("grey",[90,39],"color"),oo("bgBlack",[40,49],"bg"),oo("bgRed",[41,49],"bg"),oo("bgGreen",[42,49],"bg"),oo("bgYellow",[43,49],"bg"),oo("bgBlue",[44,49],"bg"),oo("bgMagenta",[45,49],"bg"),oo("bgCyan",[46,49],"bg"),oo("bgWhite",[47,49],"bg"),oo("blackBright",[90,39],"bright"),oo("redBright",[91,39],"bright"),oo("greenBright",[92,39],"bright"),oo("yellowBright",[93,39],"bright"),oo("blueBright",[94,39],"bright"),oo("magentaBright",[95,39],"bright"),oo("cyanBright",[96,39],"bright"),oo("whiteBright",[97,39],"bright"),oo("bgBlackBright",[100,49],"bgBright"),oo("bgRedBright",[101,49],"bgBright"),oo("bgGreenBright",[102,49],"bgBright"),oo("bgYellowBright",[103,49],"bgBright"),oo("bgBlueBright",[104,49],"bgBright"),oo("bgMagentaBright",[105,49],"bgBright"),oo("bgCyanBright",[106,49],"bgBright"),oo("bgWhiteBright",[107,49],"bgBright");const ao=no.ansiRegex=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g;no.hasColor=no.hasAnsi=t=>(ao.lastIndex=0,!!t&&"string"==typeof t&&ao.test(t)),no.unstyle=t=>(ao.lastIndex=0,"string"==typeof t?t.replace(ao,""):t),no.none=no.clear=no.noop=t=>t,no.stripColor=no.unstyle,no.symbols=ro,no.define=oo;var lo=no;const co=t=>console.log(t),uo=t=>console.log(lo.green(lo.symbols.check+" ")+t),ho=t=>console.error(lo.red(lo.symbols.cross+" ")+t),po=t=>{const{message:e}=((t={})=>{const{id:e,context:i}=t;switch(e){case"10000":case"10001":return{message:`Looks like you provided a URL as your project name. Try "medusa new my-medusa-store ${i.rootPath}" instead.`};case"10002":return{message:`Could not create project because ${i.path} is not a valid path.`};case"10003":return{message:`Directory ${i.rootPath} is already a Node project.`};default:return{message:"Unknown error"}}})(t);console.error(e),process.exit(1)};var fo=process.cwd,mo=null,go=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return mo||(mo=fo.call(process)),mo};try{process.cwd()}catch(t){}if("function"==typeof process.chdir){var yo=process.chdir;process.chdir=function(t){mo=null,yo.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,yo)}var bo=O.default.Stream,wo=Object.getPrototypeOf||function(t){return t.__proto__},vo=N(function(t){var e,i;function r(t,i){Object.defineProperty(t,e,{get:function(){return i}})}"function"==typeof Symbol&&"function"==typeof Symbol.for?(e=Symbol.for("graceful-fs.queue"),i=Symbol.for("graceful-fs.previous")):(e="___graceful-fs.queue",i="___graceful-fs.previous");var n,s=function(){};function o(t){(function(t){var e,i;function r(e){return e?function(i,r,n){return e.call(t,i,r,function(t){c(t)&&(t=null),n&&n.apply(this,arguments)})}:e}function n(e){return e?function(i,r){try{return e.call(t,i,r)}catch(t){if(!c(t))throw t}}:e}function s(e){return e?function(i,r,n,s){return e.call(t,i,r,n,function(t){c(t)&&(t=null),s&&s.apply(this,arguments)})}:e}function o(e){return e?function(i,r,n){try{return e.call(t,i,r,n)}catch(t){if(!c(t))throw t}}:e}function a(e){return e?function(i,r,n){function s(t,e){e&&(e.uid<0&&(e.uid+=4294967296),e.gid<0&&(e.gid+=4294967296)),n&&n.apply(this,arguments)}return"function"==typeof r&&(n=r,r=null),r?e.call(t,i,r,s):e.call(t,i,s)}:e}function l(e){return e?function(i,r){var n=r?e.call(t,i,r):e.call(t,i);return n&&(n.uid<0&&(n.uid+=4294967296),n.gid<0&&(n.gid+=4294967296)),n}:e}function c(t){return!t||"ENOSYS"===t.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==t.code&&"EPERM"!==t.code)}k.default.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(t){t.lchmod=function(e,i,r){t.open(e,k.default.O_WRONLY|k.default.O_SYMLINK,i,function(e,n){e?r&&r(e):t.fchmod(n,i,function(e){t.close(n,function(t){r&&r(e||t)})})})},t.lchmodSync=function(e,i){var r,n=t.openSync(e,k.default.O_WRONLY|k.default.O_SYMLINK,i),s=!0;try{r=t.fchmodSync(n,i),s=!1}finally{if(s)try{t.closeSync(n)}catch(t){}else t.closeSync(n)}return r}}(t),t.lutimes||function(t){k.default.hasOwnProperty("O_SYMLINK")?(t.lutimes=function(e,i,r,n){t.open(e,k.default.O_SYMLINK,function(e,s){e?n&&n(e):t.futimes(s,i,r,function(e){t.close(s,function(t){n&&n(e||t)})})})},t.lutimesSync=function(e,i,r){var n,s=t.openSync(e,k.default.O_SYMLINK),o=!0;try{n=t.futimesSync(s,i,r),o=!1}finally{if(o)try{t.closeSync(s)}catch(t){}else t.closeSync(s)}return n}):(t.lutimes=function(t,e,i,r){r&&process.nextTick(r)},t.lutimesSync=function(){})}(t),t.chown=s(t.chown),t.fchown=s(t.fchown),t.lchown=s(t.lchown),t.chmod=r(t.chmod),t.fchmod=r(t.fchmod),t.lchmod=r(t.lchmod),t.chownSync=o(t.chownSync),t.fchownSync=o(t.fchownSync),t.lchownSync=o(t.lchownSync),t.chmodSync=n(t.chmodSync),t.fchmodSync=n(t.fchmodSync),t.lchmodSync=n(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=l(t.statSync),t.fstatSync=l(t.fstatSync),t.lstatSync=l(t.lstatSync),t.lchmod||(t.lchmod=function(t,e,i){i&&process.nextTick(i)},t.lchmodSync=function(){}),t.lchown||(t.lchown=function(t,e,i,r){r&&process.nextTick(r)},t.lchownSync=function(){}),"win32"===go&&(t.rename=(e=t.rename,function(i,r,n){var s=Date.now(),o=0;e(i,r,function a(l){if(l&&("EACCES"===l.code||"EPERM"===l.code)&&Date.now()-s<6e4)return setTimeout(function(){t.stat(r,function(t,s){t&&"ENOENT"===t.code?e(i,r,a):n(l)})},o),void(o<100&&(o+=10));n&&n(l)})})),t.read=function(e){function i(i,r,n,s,o,a){var l;if(a&&"function"==typeof a){var c=0;l=function(u,h,d){if(u&&"EAGAIN"===u.code&&c<10)return c++,e.call(t,i,r,n,s,o,l);a.apply(this,arguments)}}return e.call(t,i,r,n,s,o,l)}return Object.setPrototypeOf&&Object.setPrototypeOf(i,e),i}(t.read),t.readSync=(i=t.readSync,function(e,r,n,s,o){for(var a=0;;)try{return i.call(t,e,r,n,s,o)}catch(t){if("EAGAIN"===t.code&&a<10){a++;continue}throw t}})})(t),t.gracefulify=o,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,r){return"function"==typeof i&&(r=i,i=null),function t(i,r,n,s){return e(i,r,function(e){!e||"EMFILE"!==e.code&&"ENFILE"!==e.code?"function"==typeof n&&n.apply(this,arguments):a([t,[i,r,n],e,s||Date.now(),Date.now()])})}(t,i,r)};var i=t.writeFile;t.writeFile=function(t,e,r,n){return"function"==typeof r&&(n=r,r=null),function t(e,r,n,s,o){return i(e,r,n,function(i){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?"function"==typeof s&&s.apply(this,arguments):a([t,[e,r,n,s],i,o||Date.now(),Date.now()])})}(t,e,r,n)};var r=t.appendFile;r&&(t.appendFile=function(t,e,i,n){return"function"==typeof i&&(n=i,i=null),function t(e,i,n,s,o){return r(e,i,n,function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?"function"==typeof s&&s.apply(this,arguments):a([t,[e,i,n,s],r,o||Date.now(),Date.now()])})}(t,e,i,n)});var n=t.copyFile;n&&(t.copyFile=function(t,e,i,r){return"function"==typeof i&&(r=i,i=0),function t(e,i,r,s,o){return n(e,i,r,function(n){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?"function"==typeof s&&s.apply(this,arguments):a([t,[e,i,r,s],n,o||Date.now(),Date.now()])})}(t,e,i,r)});var s=t.readdir;if(t.readdir=function(t,e,i){return"function"==typeof e&&(i=e,e=null),function t(e,i,r,n){return s(e,i,function(s,o){!s||"EMFILE"!==s.code&&"ENFILE"!==s.code?(o&&o.sort&&o.sort(),"function"==typeof r&&r.call(this,s,o)):a([t,[e,i,r],s,n||Date.now(),Date.now()])})}(t,e,i)},"v0.8"===process.version.substr(0,4)){var l=function(t){return{ReadStream:function e(i,r){if(!(this instanceof e))return new e(i,r);bo.call(this);var n=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,r=r||{};for(var s=Object.keys(r),o=0,a=s.length;o<a;o++){var l=s[o];this[l]=r[l]}if(this.encoding&&this.setEncoding(this.encoding),void 0!==this.start){if("number"!=typeof this.start)throw TypeError("start must be a Number");if(void 0===this.end)this.end=Infinity;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}null===this.fd?t.open(this.path,this.flags,this.mode,function(t,e){if(t)return n.emit("error",t),void(n.readable=!1);n.fd=e,n.emit("open",e),n._read()}):process.nextTick(function(){n._read()})},WriteStream:function e(i,r){if(!(this instanceof e))return new e(i,r);bo.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var n=Object.keys(r),s=0,o=n.length;s<o;s++){var a=n[s];this[a]=r[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())}}}(t);p=l.ReadStream,f=l.WriteStream}var c=t.ReadStream;c&&(p.prototype=Object.create(c.prototype),p.prototype.open=function(){var t=this;g(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 u=t.WriteStream;u&&(f.prototype=Object.create(u.prototype),f.prototype.open=function(){var t=this;g(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 f},set:function(t){f=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 d=f;function p(t,e){return this instanceof p?(c.apply(this,arguments),this):p.apply(Object.create(p.prototype),arguments)}function f(t,e){return this instanceof f?(u.apply(this,arguments),this):f.apply(Object.create(f.prototype),arguments)}Object.defineProperty(t,"FileWriteStream",{get:function(){return d},set:function(t){d=t},enumerable:!0,configurable:!0});var m=t.open;function g(t,e,i,r){return"function"==typeof i&&(r=i,i=null),function t(e,i,r,n,s){return m(e,i,r,function(o,l){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?"function"==typeof n&&n.apply(this,arguments):a([t,[e,i,r,n],o,s||Date.now(),Date.now()])})}(t,e,i,r)}return t.open=g,t}function a(t){s("ENQUEUE",t[0].name,t[1]),v.default[e].push(t),c()}function l(){for(var t=Date.now(),i=0;i<v.default[e].length;++i)v.default[e][i].length>2&&(v.default[e][i][3]=t,v.default[e][i][4]=t);c()}function c(){if(clearTimeout(n),n=void 0,0!==v.default[e].length){var t=v.default[e].shift(),i=t[0],r=t[1],o=t[2],a=t[3],l=t[4];if(void 0===a)s("RETRY",i.name,r),i.apply(null,r);else if(Date.now()-a>=6e4){s("TIMEOUT",i.name,r);var u=r.pop();"function"==typeof u&&u.call(null,o)}else{var h=Date.now()-l,d=Math.max(l-a,1);h>=Math.min(1.2*d,100)?(s("RETRY",i.name,r),i.apply(null,r.concat([a]))):v.default[e].push(t)}void 0===n&&(n=setTimeout(c,0))}}C.default.debuglog?s=C.default.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(s=function(){var t=C.default.format.apply(C.default,arguments);t="GFS4: "+t.split(/\n/).join("\nGFS4: "),console.error(t)}),v.default[e]||(r(v.default,I[e]||[]),v.default.close=function(t){function e(e,i){return t.call(v.default,e,function(t){t||l(),"function"==typeof i&&i.apply(this,arguments)})}return Object.defineProperty(e,i,{value:t}),e}(v.default.close),v.default.closeSync=function(t){function e(e){t.apply(v.default,arguments),l()}return Object.defineProperty(e,i,{value:t}),e}(v.default.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){s(v.default[e]),S.default.equal(v.default[e].length,0)})),I[e]||r(I,v.default[e]),t.exports=o(function(t){if(null===t||"object"!=typeof t)return t;if(t instanceof Object)var e={__proto__:wo(t)};else e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(t,i))}),e}(v.default)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!v.default.__patched&&(t.exports=o(v.default),v.default.__patched=!0)});const So=x.default.homedir(),{env:Eo}=process,xo=Eo.XDG_DATA_HOME||(So?y.default.join(So,".local","share"):void 0),_o=Eo.XDG_CONFIG_HOME||(So?y.default.join(So,".config"):void 0);Eo.XDG_STATE_HOME||So&&y.default.join(So,".local","state"),Eo.XDG_CACHE_HOME||So&&y.default.join(So,".cache");const Oo=(Eo.XDG_DATA_DIRS||"/usr/local/share/:/usr/share/").split(":");xo&&Oo.unshift(xo);const Co=(Eo.XDG_CONFIG_DIRS||"/etc/xdg").split(":");_o&&Co.unshift(_o);var ko=N(function(t){!function(){var e;function i(t,r){var n=this instanceof i?this:e;if(n.reset(r),"string"==typeof t&&t.length>0&&n.hash(t),n!==this)return n}i.prototype.hash=function(t){var e,i,r,n,s;switch(this.len+=s=t.length,i=this.k1,r=0,this.rem){case 0:i^=s>r?65535&t.charCodeAt(r++):0;case 1:i^=s>r?(65535&t.charCodeAt(r++))<<8:0;case 2:i^=s>r?(65535&t.charCodeAt(r++))<<16:0;case 3:i^=s>r?(255&t.charCodeAt(r))<<24:0,i^=s>r?(65280&t.charCodeAt(r++))>>8:0}if(this.rem=s+this.rem&3,(s-=this.rem)>0){for(e=this.h1;e=5*(e=(e^=i=13715*(i=(i=11601*i+3432906752*(65535&i)&4294967295)<<15|i>>>17)+461832192*(65535&i)&4294967295)<<13|e>>>19)+3864292196&4294967295,!(r>=s);)i=65535&t.charCodeAt(r++)^(65535&t.charCodeAt(r++))<<8^(65535&t.charCodeAt(r++))<<16,i^=(255&(n=t.charCodeAt(r++)))<<24^(65280&n)>>8;switch(i=0,this.rem){case 3:i^=(65535&t.charCodeAt(r+2))<<16;case 2:i^=(65535&t.charCodeAt(r+1))<<8;case 1:i^=65535&t.charCodeAt(r)}this.h1=e}return this.k1=i,this},i.prototype.result=function(){var t,e;return e=this.h1,(t=this.k1)>0&&(e^=t=13715*(t=(t=11601*t+3432906752*(65535&t)&4294967295)<<15|t>>>17)+461832192*(65535&t)&4294967295),e^=this.len,e=51819*(e^=e>>>16)+2246770688*(65535&e)&4294967295,e=44597*(e^=e>>>13)+3266445312*(65535&e)&4294967295,(e^=e>>>16)>>>0},i.prototype.reset=function(t){return this.h1="number"==typeof t?t:0,this.rem=this.k1=this.len=0,this},e=new i,t.exports=i}()}),$o=Po;Po.strict=To,Po.loose=Io;var jo=Object.prototype.toString,Ao={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function Po(t){return To(t)||Io(t)}function To(t){return t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array}function Io(t){return Ao[jo.call(t)]}var No=$o.strict,Fo=function(t){if(No(t)){var e=Buffer.from(t.buffer);return t.byteLength!==t.buffer.byteLength&&(e=e.slice(t.byteOffset,t.byteOffset+t.byteLength)),e}return Buffer.from(t)},Ro=function(t,e,i,r){i instanceof Function&&(r=i,i={});const n=async function(t,e,i={}){let r,n;"string"==typeof i&&(i={encoding:i});const s=Ci(qo(()=>n)),o=y.default.resolve(t);try{await function(t){return new Promise(e=>{Mo[t]||(Mo[t]=[]),Mo[t].push(e),1===Mo[t].length&&e()})}(o);const a=await Bo(v.default.realpath)(t).catch(()=>t);if(n=Uo(a),!i.mode||!i.chown){const t=await Bo(v.default.stat)(a).catch(()=>{});t&&(null==i.mode&&(i.mode=t.mode),null==i.chown&&process.getuid&&(i.chown={uid:t.uid,gid:t.gid}))}r=await Bo(v.default.open)(n,"w",i.mode),i.tmpfileCreated&&await i.tmpfileCreated(n),$o(e)&&(e=Fo(e)),Buffer.isBuffer(e)?await Bo(v.default.write)(r,e,0,e.length,0):null!=e&&await Bo(v.default.write)(r,String(e),0,String(i.encoding||"utf8")),!1!==i.fsync&&await Bo(v.default.fsync)(r),await Bo(v.default.close)(r),r=null,i.chown&&await Bo(v.default.chown)(n,i.chown.uid,i.chown.gid).catch(t=>{if(!Vo(t))throw t}),i.mode&&await Bo(v.default.chmod)(n,i.mode).catch(t=>{if(!Vo(t))throw t}),await Bo(v.default.rename)(n,a)}finally{r&&await Bo(v.default.close)(r).catch(()=>{}),s(),await Bo(v.default.unlink)(n).catch(()=>{}),Mo[o].shift(),Mo[o].length>0?Mo[o][0]():delete Mo[o]}}(t,e,i);return r&&n.then(r,r),n},Lo=Uo,Do=qo;const{promisify:Bo}=C.default,Mo={},Go=function(){try{return 0}catch(t){return 0}}();let Ho=0;function Uo(t){return t+"."+ko(__filename).hash(String(process.pid)).hash(String(Go)).hash(String(++Ho)).result()}function qo(t){return()=>{try{v.default.unlinkSync("function"==typeof t?t():t)}catch(t){}}}function Vo(t){return"ENOSYS"===t.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==t.code&&"EPERM"!==t.code)}Ro.sync=function(t,e,i){"string"==typeof i?i={encoding:i}:i||(i={});try{t=v.default.realpathSync(t)}catch(t){}const r=Uo(t);if(!i.mode||!i.chown)try{const e=v.default.statSync(t);(i=Object.assign({},i)).mode||(i.mode=e.mode),!i.chown&&process.getuid&&(i.chown={uid:e.uid,gid:e.gid})}catch(t){}let n;const s=qo(r),o=Ci(s);let a=!0;try{if(n=v.default.openSync(r,"w",i.mode||438),i.tmpfileCreated&&i.tmpfileCreated(r),$o(e)&&(e=Fo(e)),Buffer.isBuffer(e)?v.default.writeSync(n,e,0,e.length,0):null!=e&&v.default.writeSync(n,String(e),0,String(i.encoding||"utf8")),!1!==i.fsync&&v.default.fsyncSync(n),v.default.closeSync(n),n=null,i.chown)try{v.default.chownSync(r,i.chown.uid,i.chown.gid)}catch(t){if(!Vo(t))throw t}if(i.mode)try{v.default.chmodSync(r,i.mode)}catch(t){if(!Vo(t))throw t}v.default.renameSync(r,t),a=!1}finally{if(n)try{v.default.closeSync(n)}catch(t){}o(),a&&s()}},Ro._getTmpname=Lo,Ro._cleanupOnExit=Do;var Wo=t=>{const e=typeof t;return null!==t&&("object"===e||"function"===e)};const zo=new Set(["__proto__","prototype","constructor"]);function Yo(t){const e=t.split("."),i=[];for(let t=0;t<e.length;t++){let r=e[t];for(;"\\"===r[r.length-1]&&void 0!==e[t+1];)r=r.slice(0,-1)+".",r+=e[++t];i.push(r)}return i.some(t=>zo.has(t))?[]:i}var Ko={get(t,e,i){if(!Wo(t)||"string"!=typeof e)return void 0===i?t:i;const r=Yo(e);if(0!==r.length){for(let e=0;e<r.length;e++)if(null==(t=t[r[e]])){if(e!==r.length-1)return i;break}return void 0===t?i:t}},set(t,e,i){if(!Wo(t)||"string"!=typeof e)return t;const r=t,n=Yo(e);for(let e=0;e<n.length;e++){const r=n[e];Wo(t[r])||(t[r]={}),e===n.length-1&&(t[r]=i),t=t[r]}return r},delete(t,e){if(!Wo(t)||"string"!=typeof e)return!1;const i=Yo(e);for(let e=0;e<i.length;e++){const r=i[e];if(e===i.length-1)return delete t[r],!0;if(!Wo(t=t[r]))return!1}},has(t,e){if(!Wo(t)||"string"!=typeof e)return!1;const i=Yo(e);if(0===i.length)return!1;for(let e=0;e<i.length;e++){if(!Wo(t))return!1;if(!(i[e]in t))return!1;t=t[i[e]]}return!0}};const Jo=c.promisify(j.default.randomBytes),Xo="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~".split(""),Zo="0123456789".split(""),Qo="CDEHKMPRTUWXY012458".split(""),ta="!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~".split(""),ea="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),ia=new Set([void 0,"hex","base64","url-safe","numeric","distinguishable","ascii-printable","alphanumeric"]),ra=(t,e)=>({length:i,type:r,characters:n})=>{if(!(i>=0&&Number.isFinite(i)))throw new TypeError("Expected a `length` to be a non-negative finite number");if(void 0!==r&&void 0!==n)throw new TypeError("Expected either `type` or `characters`");if(void 0!==n&&"string"!=typeof n)throw new TypeError("Expected `characters` to be string");if(!ia.has(r))throw new TypeError(`Unknown type: ${r}`);if(void 0===r&&void 0===n&&(r="hex"),"hex"===r||void 0===r&&void 0===n)return e(Math.ceil(.5*i),"hex",i);if("base64"===r)return e(Math.ceil(.75*i),"base64",i);if("url-safe"===r)return t(i,Xo);if("numeric"===r)return t(i,Zo);if("distinguishable"===r)return t(i,Qo);if("ascii-printable"===r)return t(i,ta);if("alphanumeric"===r)return t(i,ea);if(0===n.length)throw new TypeError("Expected `characters` string length to be greater than or equal to 1");if(n.length>65536)throw new TypeError("Expected `characters` string length to be less or equal to 65536");return t(i,n.split(""))},na=ra((t,e)=>{const i=e.length,r=Math.floor(65536/i)*i-1,n=2*Math.ceil(1.1*t);let s="",o=0;for(;o<t;){const a=j.default.randomBytes(n);let l=0;for(;l<n&&o<t;){const t=a.readUInt16LE(l);l+=2,t>r||(s+=e[t%i],o++)}}return s},(t,e,i)=>j.default.randomBytes(t).toString(e).slice(0,i));na.async=ra(async(t,e)=>{const i=e.length,r=Math.floor(65536/i)*i-1,n=2*Math.ceil(1.1*t);let s="",o=0;for(;o<t;){const a=await Jo(n);let l=0;for(;l<n&&o<t;){const t=a.readUInt16LE(l);l+=2,t>r||(s+=e[t%i],o++)}}return s},async(t,e,i)=>(await Jo(t)).toString(e).slice(0,i));const sa=_o||y.default.join(x.default.tmpdir(),na({length:32})),oa={mode:448,recursive:!0},aa={mode:384};class la{constructor(t,e,i={}){const r=i.globalConfigPath?y.default.join(t,"config.json"):y.default.join("configstore",`${t}.json`);this._path=i.configPath||y.default.join(sa,r),e&&(this.all={...e,...this.all})}get all(){try{return JSON.parse(vo.readFileSync(this._path,"utf8"))}catch(t){if("ENOENT"===t.code)return{};if("EACCES"===t.code&&(t.message=`${t.message}\nYou don't have access to this file.\n`),"SyntaxError"===t.name)return Ro.sync(this._path,"",aa),{};throw t}}set all(t){try{vo.mkdirSync(y.default.dirname(this._path),oa),Ro.sync(this._path,JSON.stringify(t,void 0,"\t"),aa)}catch(t){throw"EACCES"===t.code&&(t.message=`${t.message}\nYou don't have access to this file.\n`),t}}get size(){return Object.keys(this.all||{}).length}get(t){return Ko.get(this.all,t)}set(t,e){const i=this.all;if(1===arguments.length)for(const e of Object.keys(t))Ko.set(i,e,t[e]);else Ko.set(i,t,e);this.all=i}has(t){return Ko.has(this.all,t)}delete(t){const e=this.all;Ko.delete(e,t),this.all=e}clear(){this.all={}}get path(){return this._path}}let ca;const ua=()=>(ca||(ca=new la("medusa",{},{globalConfigPath:!0})),ca),ha=t=>{const e=ua();return e.get("cli.packageManager")||(null!=t&&t.includes("yarn")?(e.set("cli.packageManager","yarn"),"yarn"):(e.set("cli.packageManager","npm"),"npm"))},da=(t,e)=>{const[i,...r]=t.split(/\s+/);return((t,e,i)=>_r(t,e,st({stdio:"ignore",preferLocal:!1},i)))(i,r,e)},pa=async(t,e)=>{const r=process.cwd(),n=kr("Installing packages...");console.log(),process.chdir(t),process;try{"yarn"===ha()&&(()=>{try{return i.execSync("yarnpkg --version",{stdio:"ignore"}),!0}catch(t){return!1}})()?(await _s.remove("package-lock.json"),await da("yarnpkg",{stdio:e?"inherit":"ignore"})):(await _s.remove("yarn.lock"),await da("npm install",{stdio:e?"inherit":"ignore"}))}finally{n(),console.log(),uo("Packages installed"),process.chdir(r)}},fa=t=>!/^\.(git|hg)$/.test(y.default.basename(t)),ma=async t=>{const{starter:e,root:r,verbose:n,seed:s,keepGit:o}=t,{starterPath:a,rootPath:l}=await(async(t,e)=>({starterPath:t=t||"medusajs/medusa-starter-default",rootPath:e=e||process.cwd(),selectedOtherStarter:!1}))(e,r),c=$.default.parse(l);if(c.protocol&&c.host){const t=e&&!$.default.parse(e).hostname&&!$.default.parse(e).protocol;return/medusa-starter/gi.test(l)&&t?void po({id:"10000",context:{starter:e,rootPath:l}}):void po({id:"10001",context:{rootPath:l}})}if(!1!==("string"!=typeof(u=l)||function(t){return"string"==typeof t&&(/[*!?{}(|)[\]]/.test(t)||function(t){return"string"==typeof t&&/[@?!+*]\(/.test(t)}(t))}(u)||io.test(u)))return void po({id:"10002",context:{path:y.default.resolve(l)}});var u;if($r.sync(y.default.join(l,"package.json")))return void po({id:"10003",context:{rootPath:l}});const h=eo.fromUrl(a);h?await(async(t,e,r,n=!1)=>{let s;s="sshurl"===t.getDefaultRepresentation()?t.ssh({noCommittish:!0}):t.https({noCommittish:!0,noGitPlus:!0});const o=t.committish?["-b",t.committish]:[],a=kr(`Creating new project from git: ${s}`),l=["clone",...o,s,e,"--recursive","--depth=1"].filter(t=>Boolean(t));await _r("git",l,{}).then(()=>{a(),console.log(),uo("Created starter directory layout")}).catch(t=>{throw a(),console.log(),ho("Failed to clone repository"),t}),r||await _s.remove(y.default.join(e,".git")),await pa(e,n);const c=await(async()=>{try{return await da("git rev-parse --is-inside-work-tree",{stdio:"pipe"}).then(t=>"true"===t.stdout)}catch(t){return!1}})();c||await(async t=>(co(`Initialising git in ${t}`),await da("git init",{cwd:t})))(e),await(async t=>{$r.sync(y.default.join(t,".gitignore"))||(co(`Creating minimal .gitignore in ${t}`),await _s.writeFile(y.default.join(t,".gitignore"),".cache\nnode_modules\npublic\n"),uo(`Created .gitignore in ${t}`))})(e),c||await(async(t,e)=>{co(`Create initial git commit in ${t}`),await da("git add -A",{cwd:t});try{i.execSync(`git commit -m "Initial commit from medusa: (${e})"`,{cwd:t})}catch(e){console.warn("Initial git commit failed - removing git support\n"),_s.removeSync(y.default.join(t,".git"))}})(e,s)})(h,l,o,n):await(async(t,e)=>{if(await _s.ensureDir(e,{mode:493}),!$r.sync(t))throw new Error(`starter ${t} doesn't exist`);if("."===t)throw new Error("You can't create a starter from the existing directory. If you want to\n create a new project in the current directory, the trailing dot isn't\n necessary. If you want to create a project from a local starter, run\n something like \"medusa new my-medusa-store ../local-medusa-starter\"");const i=kr(`Creating new site from local starter: ${t}`);return co(`Copying local starter to ${e} ...`),await _s.copy(t,e,{filter:fa}),i(),console.log(),uo("Created starter directory layout"),console.log(),await pa(e),!0})(a,l);const d=(t=>{try{const e=y.default.join(t,"medusa-config.js");if($r.sync(e)){const t=y.default.resolve(e);return require(t)}throw Error()}catch(t){return null}return{}})(l);if(d){let t=!1;d.projectConfig&&(t="postgres"===d.projectConfig.database_type),!t&&s&&await(async t=>{const e=kr("Seeding database"),i=y.default.resolve(t,"package.json");if($r.sync(i)){const r=require(i);if(r.scripts&&r.scripts.seed){await(async t=>{const e=y.default.join(t,".env.template"),i=y.default.join(t,".env");$r.sync(e)&&_s.renameSync(e,i)})(t);const i=_r(ha(),["run","seed"],{cwd:t});i.stdout.pipe(process.stdout),await i.then(()=>{e(),console.log(),uo("Seed completed")}).catch(t=>{e(),console.log(),ho("Failed to complete seed; skipping"),console.error(t)})}else e(),console.log(),ho("Starter doesn't provide a seed command; skipping.")}else e(),console.log(),ho("Could not find package.json")})(l)}},ga=O.default.Readable,ya=Symbol("buffer"),ba=Symbol("type");class wa{constructor(){this[ba]="";const t=arguments[0],e=arguments[1],i=[];if(t){const e=t,r=Number(e.length);for(let t=0;t<r;t++){const r=e[t];let n;n=r instanceof Buffer?r:ArrayBuffer.isView(r)?Buffer.from(r.buffer,r.byteOffset,r.byteLength):r instanceof ArrayBuffer?Buffer.from(r):r instanceof wa?r[ya]:Buffer.from("string"==typeof r?r:String(r)),i.push(n)}}this[ya]=Buffer.concat(i);let r=e&&void 0!==e.type&&String(e.type).toLowerCase();r&&!/[^\u0020-\u007E]/.test(r)&&(this[ba]=r)}get size(){return this[ya].length}get type(){return this[ba]}text(){return Promise.resolve(this[ya].toString())}arrayBuffer(){const t=this[ya],e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return Promise.resolve(e)}stream(){const t=new ga;return t._read=function(){},t.push(this[ya]),t.push(null),t}toString(){return"[object Blob]"}slice(){const t=this.size,e=arguments[0],i=arguments[1];let r,n;r=void 0===e?0:e<0?Math.max(t+e,0):Math.min(e,t),n=void 0===i?t:i<0?Math.max(t+i,0):Math.min(i,t);const s=Math.max(n-r,0),o=this[ya].slice(r,r+s),a=new wa([],{type:arguments[2]});return a[ya]=o,a}}function va(t,e,i){Error.call(this,t),this.message=t,this.type=e,i&&(this.code=this.errno=i.code),Error.captureStackTrace(this,this.constructor)}let Sa;Object.defineProperties(wa.prototype,{size:{enumerable:!0},type:{enumerable:!0},slice:{enumerable:!0}}),Object.defineProperty(wa.prototype,Symbol.toStringTag,{value:"Blob",writable:!1,enumerable:!1,configurable:!0}),(va.prototype=Object.create(Error.prototype)).constructor=va,va.prototype.name="FetchError";try{Sa=require("encoding").convert}catch(t){}const Ea=Symbol("Body internals"),xa=O.default.PassThrough;function _a(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i.size;let n=void 0===r?0:r;var s=i.timeout;let o=void 0===s?0:s;null==t?t=null:Ca(t)?t=Buffer.from(t.toString()):ka(t)||Buffer.isBuffer(t)||("[object ArrayBuffer]"===Object.prototype.toString.call(t)?t=Buffer.from(t):ArrayBuffer.isView(t)?t=Buffer.from(t.buffer,t.byteOffset,t.byteLength):t instanceof O.default||(t=Buffer.from(String(t)))),this[Ea]={body:t,disturbed:!1,error:null},this.size=n,this.timeout=o,t instanceof O.default&&t.on("error",function(t){const i="AbortError"===t.name?t:new va(`Invalid response body while trying to fetch ${e.url}: ${t.message}`,"system",t);e[Ea].error=i})}function Oa(){var t=this;if(this[Ea].disturbed)return _a.Promise.reject(new TypeError(`body used already for: ${this.url}`));if(this[Ea].disturbed=!0,this[Ea].error)return _a.Promise.reject(this[Ea].error);let e=this.body;if(null===e)return _a.Promise.resolve(Buffer.alloc(0));if(ka(e)&&(e=e.stream()),Buffer.isBuffer(e))return _a.Promise.resolve(e);if(!(e instanceof O.default))return _a.Promise.resolve(Buffer.alloc(0));let i=[],r=0,n=!1;return new _a.Promise(function(s,o){let a;t.timeout&&(a=setTimeout(function(){n=!0,o(new va(`Response timeout while trying to fetch ${t.url} (over ${t.timeout}ms)`,"body-timeout"))},t.timeout)),e.on("error",function(e){"AbortError"===e.name?(n=!0,o(e)):o(new va(`Invalid response body while trying to fetch ${t.url}: ${e.message}`,"system",e))}),e.on("data",function(e){if(!n&&null!==e){if(t.size&&r+e.length>t.size)return n=!0,void o(new va(`content size at ${t.url} over limit: ${t.size}`,"max-size"));r+=e.length,i.push(e)}}),e.on("end",function(){if(!n){clearTimeout(a);try{s(Buffer.concat(i,r))}catch(e){o(new va(`Could not create Buffer from response body for ${t.url}: ${e.message}`,"system",e))}}})})}function Ca(t){return"object"==typeof t&&"function"==typeof t.append&&"function"==typeof t.delete&&"function"==typeof t.get&&"function"==typeof t.getAll&&"function"==typeof t.has&&"function"==typeof t.set&&("URLSearchParams"===t.constructor.name||"[object URLSearchParams]"===Object.prototype.toString.call(t)||"function"==typeof t.sort)}function ka(t){return"object"==typeof t&&"function"==typeof t.arrayBuffer&&"string"==typeof t.type&&"function"==typeof t.stream&&"function"==typeof t.constructor&&"string"==typeof t.constructor.name&&/^(Blob|File)$/.test(t.constructor.name)&&/^(Blob|File)$/.test(t[Symbol.toStringTag])}function $a(t){let e,i,r=t.body;if(t.bodyUsed)throw new Error("cannot clone body after it is used");return r instanceof O.default&&"function"!=typeof r.getBoundary&&(e=new xa,i=new xa,r.pipe(e),r.pipe(i),t[Ea].body=e,r=i),r}function ja(t){return null===t?null:"string"==typeof t?"text/plain;charset=UTF-8":Ca(t)?"application/x-www-form-urlencoded;charset=UTF-8":ka(t)?t.type||null:Buffer.isBuffer(t)||"[object ArrayBuffer]"===Object.prototype.toString.call(t)||ArrayBuffer.isView(t)?null:"function"==typeof t.getBoundary?`multipart/form-data;boundary=${t.getBoundary()}`:t instanceof O.default?null:"text/plain;charset=UTF-8"}function Aa(t){const e=t.body;return null===e?0:ka(e)?e.size:Buffer.isBuffer(e)?e.length:e&&"function"==typeof e.getLengthSync&&(e._lengthRetrievers&&0==e._lengthRetrievers.length||e.hasKnownLength&&e.hasKnownLength())?e.getLengthSync():null}_a.prototype={get body(){return this[Ea].body},get bodyUsed(){return this[Ea].disturbed},arrayBuffer(){return Oa.call(this).then(function(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)})},blob(){let t=this.headers&&this.headers.get("content-type")||"";return Oa.call(this).then(function(e){return Object.assign(new wa([],{type:t.toLowerCase()}),{[ya]:e})})},json(){var t=this;return Oa.call(this).then(function(e){try{return JSON.parse(e.toString())}catch(e){return _a.Promise.reject(new va(`invalid json response body at ${t.url} reason: ${e.message}`,"invalid-json"))}})},text(){return Oa.call(this).then(function(t){return t.toString()})},buffer(){return Oa.call(this)},textConverted(){var t=this;return Oa.call(this).then(function(e){return function(t,e){if("function"!=typeof Sa)throw new Error("The package `encoding` must be installed to use the textConverted() function");const i=e.get("content-type");let r,n,s="utf-8";return i&&(r=/charset=([^;]*)/i.exec(i)),n=t.slice(0,1024).toString(),!r&&n&&(r=/<meta.+?charset=(['"])(.+?)\1/i.exec(n)),!r&&n&&(r=/<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(n),r||(r=/<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(n),r&&r.pop()),r&&(r=/charset=(.*)/i.exec(r.pop()))),!r&&n&&(r=/<\?xml.+?encoding=(['"])(.+?)\1/i.exec(n)),r&&(s=r.pop(),"gb2312"!==s&&"gbk"!==s||(s="gb18030")),Sa(t,"UTF-8",s).toString()}(e,t.headers)})}},Object.defineProperties(_a.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}}),_a.mixIn=function(t){for(const e of Object.getOwnPropertyNames(_a.prototype))if(!(e in t)){const i=Object.getOwnPropertyDescriptor(_a.prototype,e);Object.defineProperty(t,e,i)}},_a.Promise=global.Promise;const Pa=/[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/,Ta=/[^\t\x20-\x7e\x80-\xff]/;function Ia(t){if(Pa.test(t=`${t}`)||""===t)throw new TypeError(`${t} is not a legal HTTP header name`)}function Na(t){if(Ta.test(t=`${t}`))throw new TypeError(`${t} is not a legal HTTP header value`)}function Fa(t,e){e=e.toLowerCase();for(const i in t)if(i.toLowerCase()===e)return i}const Ra=Symbol("map");class La{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;if(this[Ra]=Object.create(null),t instanceof La){const e=t.raw(),i=Object.keys(e);for(const t of i)for(const i of e[t])this.append(t,i)}else if(null==t);else{if("object"!=typeof t)throw new TypeError("Provided initializer must be an object");{const e=t[Symbol.iterator];if(null!=e){if("function"!=typeof e)throw new TypeError("Header pairs must be iterable");const i=[];for(const e of t){if("object"!=typeof e||"function"!=typeof e[Symbol.iterator])throw new TypeError("Each header pair must be iterable");i.push(Array.from(e))}for(const t of i){if(2!==t.length)throw new TypeError("Each header pair must be a name/value tuple");this.append(t[0],t[1])}}else for(const e of Object.keys(t))this.append(e,t[e])}}}get(t){Ia(t=`${t}`);const e=Fa(this[Ra],t);return void 0===e?null:this[Ra][e].join(", ")}forEach(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=Da(this),r=0;for(;r<i.length;){var n=i[r];t.call(e,n[1],n[0],this),i=Da(this),r++}}set(t,e){e=`${e}`,Ia(t=`${t}`),Na(e);const i=Fa(this[Ra],t);this[Ra][void 0!==i?i:t]=[e]}append(t,e){e=`${e}`,Ia(t=`${t}`),Na(e);const i=Fa(this[Ra],t);void 0!==i?this[Ra][i].push(e):this[Ra][t]=[e]}has(t){return Ia(t=`${t}`),void 0!==Fa(this[Ra],t)}delete(t){Ia(t=`${t}`);const e=Fa(this[Ra],t);void 0!==e&&delete this[Ra][e]}raw(){return this[Ra]}keys(){return Ma(this,"key")}values(){return Ma(this,"value")}[Symbol.iterator](){return Ma(this,"key+value")}}function Da(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"key+value";const i=Object.keys(t[Ra]).sort();return i.map("key"===e?function(t){return t.toLowerCase()}:"value"===e?function(e){return t[Ra][e].join(", ")}:function(e){return[e.toLowerCase(),t[Ra][e].join(", ")]})}La.prototype.entries=La.prototype[Symbol.iterator],Object.defineProperty(La.prototype,Symbol.toStringTag,{value:"Headers",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(La.prototype,{get:{enumerable:!0},forEach:{enumerable:!0},set:{enumerable:!0},append:{enumerable:!0},has:{enumerable:!0},delete:{enumerable:!0},keys:{enumerable:!0},values:{enumerable:!0},entries:{enumerable:!0}});const Ba=Symbol("internal");function Ma(t,e){const i=Object.create(Ga);return i[Ba]={target:t,kind:e,index:0},i}const Ga=Object.setPrototypeOf({next(){if(!this||Object.getPrototypeOf(this)!==Ga)throw new TypeError("Value of `this` is not a HeadersIterator");var t=this[Ba];const e=t.index,i=Da(t.target,t.kind);return e>=i.length?{value:void 0,done:!0}:(this[Ba].index=e+1,{value:i[e],done:!1})}},Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));function Ha(t){const e=Object.assign({__proto__:null},t[Ra]),i=Fa(t[Ra],"Host");return void 0!==i&&(e[i]=e[i][0]),e}Object.defineProperty(Ga,Symbol.toStringTag,{value:"HeadersIterator",writable:!1,enumerable:!1,configurable:!0});const Ua=Symbol("Response internals"),qa=A.default.STATUS_CODES;class Va{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_a.call(this,t,e);const i=e.status||200,r=new La(e.headers);if(null!=t&&!r.has("Content-Type")){const e=ja(t);e&&r.append("Content-Type",e)}this[Ua]={url:e.url,status:i,statusText:e.statusText||qa[i],headers:r,counter:e.counter}}get url(){return this[Ua].url||""}get status(){return this[Ua].status}get ok(){return this[Ua].status>=200&&this[Ua].status<300}get redirected(){return this[Ua].counter>0}get statusText(){return this[Ua].statusText}get headers(){return this[Ua].headers}clone(){return new Va($a(this),{url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected})}}_a.mixIn(Va.prototype),Object.defineProperties(Va.prototype,{url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}}),Object.defineProperty(Va.prototype,Symbol.toStringTag,{value:"Response",writable:!1,enumerable:!1,configurable:!0});const Wa=Symbol("Request internals"),za=$.default.parse,Ya=$.default.format,Ka="destroy"in O.default.Readable.prototype;function Ja(t){return"object"==typeof t&&"object"==typeof t[Wa]}class Xa{constructor(t){let e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Ja(t)?e=za(t.url):(e=za(t&&t.href?t.href:`${t}`),t={});let r=i.method||t.method||"GET";if(r=r.toUpperCase(),(null!=i.body||Ja(t)&&null!==t.body)&&("GET"===r||"HEAD"===r))throw new TypeError("Request with GET/HEAD method cannot have body");let n=null!=i.body?i.body:Ja(t)&&null!==t.body?$a(t):null;_a.call(this,n,{timeout:i.timeout||t.timeout||0,size:i.size||t.size||0});const s=new La(i.headers||t.headers||{});if(null!=n&&!s.has("Content-Type")){const t=ja(n);t&&s.append("Content-Type",t)}let o=Ja(t)?t.signal:null;if("signal"in i&&(o=i.signal),null!=o&&!function(t){const e=t&&"object"==typeof t&&Object.getPrototypeOf(t);return!(!e||"AbortSignal"!==e.constructor.name)}(o))throw new TypeError("Expected signal to be an instanceof AbortSignal");this[Wa]={method:r,redirect:i.redirect||t.redirect||"follow",headers:s,parsedURL:e,signal:o},this.follow=void 0!==i.follow?i.follow:void 0!==t.follow?t.follow:20,this.compress=void 0!==i.compress?i.compress:void 0===t.compress||t.compress,this.counter=i.counter||t.counter||0,this.agent=i.agent||t.agent}get method(){return this[Wa].method}get url(){return Ya(this[Wa].parsedURL)}get headers(){return this[Wa].headers}get redirect(){return this[Wa].redirect}get signal(){return this[Wa].signal}clone(){return new Xa(this)}}function Za(t){Error.call(this,t),this.type="aborted",this.message=t,Error.captureStackTrace(this,this.constructor)}_a.mixIn(Xa.prototype),Object.defineProperty(Xa.prototype,Symbol.toStringTag,{value:"Request",writable:!1,enumerable:!1,configurable:!0}),Object.defineProperties(Xa.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0}}),(Za.prototype=Object.create(Error.prototype)).constructor=Za,Za.prototype.name="AbortError";const Qa=O.default.PassThrough,tl=$.default.resolve;function el(t,e){if(!el.Promise)throw new Error("native promise missing, set fetch.Promise to your favorite alternative");return _a.Promise=el.Promise,new el.Promise(function(i,r){const n=new Xa(t,e),s=function(t){const e=t[Wa].parsedURL,i=new La(t[Wa].headers);if(i.has("Accept")||i.set("Accept","*/*"),!e.protocol||!e.hostname)throw new TypeError("Only absolute URLs are supported");if(!/^https?:$/.test(e.protocol))throw new TypeError("Only HTTP(S) protocols are supported");if(t.signal&&t.body instanceof O.default.Readable&&!Ka)throw new Error("Cancellation of streamed requests with AbortSignal is not supported in node < 8");let r=null;if(null==t.body&&/^(POST|PUT)$/i.test(t.method)&&(r="0"),null!=t.body){const e=Aa(t);"number"==typeof e&&(r=String(e))}r&&i.set("Content-Length",r),i.has("User-Agent")||i.set("User-Agent","node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"),t.compress&&!i.has("Accept-Encoding")&&i.set("Accept-Encoding","gzip,deflate");let n=t.agent;return"function"==typeof n&&(n=n(e)),i.has("Connection")||n||i.set("Connection","close"),Object.assign({},e,{method:t.method,headers:Ha(i),agent:n})}(n),o=("https:"===s.protocol?P.default:A.default).request,a=n.signal;let l=null;const c=function(){let t=new Za("The user aborted a request.");r(t),n.body&&n.body instanceof O.default.Readable&&n.body.destroy(t),l&&l.body&&l.body.emit("error",t)};if(a&&a.aborted)return void c();const u=function(){c(),p()},h=o(s);let d;function p(){h.abort(),a&&a.removeEventListener("abort",u),clearTimeout(d)}a&&a.addEventListener("abort",u),n.timeout&&h.once("socket",function(t){d=setTimeout(function(){r(new va(`network timeout at: ${n.url}`,"request-timeout")),p()},n.timeout)}),h.on("error",function(t){r(new va(`request to ${n.url} failed, reason: ${t.message}`,"system",t)),p()}),h.on("response",function(t){clearTimeout(d);const e=function(t){const e=new La;for(const i of Object.keys(t))if(!Pa.test(i))if(Array.isArray(t[i]))for(const r of t[i])Ta.test(r)||(void 0===e[Ra][i]?e[Ra][i]=[r]:e[Ra][i].push(r));else Ta.test(t[i])||(e[Ra][i]=[t[i]]);return e}(t.headers);if(el.isRedirect(t.statusCode)){const s=e.get("Location"),o=null===s?null:tl(n.url,s);switch(n.redirect){case"error":return r(new va(`uri requested responds with a redirect, redirect mode is set to error: ${n.url}`,"no-redirect")),void p();case"manual":if(null!==o)try{e.set("Location",o)}catch(t){r(t)}break;case"follow":if(null===o)break;if(n.counter>=n.follow)return r(new va(`maximum redirect reached at: ${n.url}`,"max-redirect")),void p();const s={headers:new La(n.headers),follow:n.follow,counter:n.counter+1,agent:n.agent,compress:n.compress,method:n.method,body:n.body,signal:n.signal,timeout:n.timeout,size:n.size};return 303!==t.statusCode&&n.body&&null===Aa(n)?(r(new va("Cannot follow redirect with body being a readable stream","unsupported-redirect")),void p()):(303!==t.statusCode&&(301!==t.statusCode&&302!==t.statusCode||"POST"!==n.method)||(s.method="GET",s.body=void 0,s.headers.delete("content-length")),i(el(new Xa(o,s))),void p())}}t.once("end",function(){a&&a.removeEventListener("abort",u)});let s=t.pipe(new Qa);const o={url:n.url,status:t.statusCode,statusText:t.statusMessage,headers:e,size:n.size,timeout:n.timeout,counter:n.counter},c=e.get("Content-Encoding");if(!n.compress||"HEAD"===n.method||null===c||204===t.statusCode||304===t.statusCode)return l=new Va(s,o),void i(l);if("gzip"==c||"x-gzip"==c)return s=s.pipe(T.default.createGunzip({flush:T.default.Z_SYNC_FLUSH,finishFlush:T.default.Z_SYNC_FLUSH})),l=new Va(s,o),void i(l);if("deflate"!=c&&"x-deflate"!=c){if("br"==c&&"function"==typeof T.default.createBrotliDecompress)return s=s.pipe(T.default.createBrotliDecompress()),l=new Va(s,o),void i(l);l=new Va(s,o),i(l)}else t.pipe(new Qa).once("data",function(t){s=s.pipe(8==(15&t[0])?T.default.createInflate():T.default.createInflateRaw()),l=new Va(s,o),i(l)})}),function(t,e){const i=e.body;null===i?t.end():ka(i)?i.stream().pipe(t):Buffer.isBuffer(i)?(t.write(i),t.end()):i.pipe(t)}(h,n)})}el.isRedirect=function(t){return 301===t||302===t||303===t||307===t||308===t},el.Promise=global.Promise;for(var il=function(){return j.default.randomBytes(16)},rl=[],nl=0;nl<256;++nl)rl[nl]=(nl+256).toString(16).substr(1);var sl=function(t,e,i){var r=e&&i||0;"string"==typeof t&&(e="binary"===t?new Array(16):null,t=null);var n=(t=t||{}).random||(t.rng||il)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e)for(var s=0;s<16;++s)e[r+s]=n[s];return e||function(t,e){var i=0;return[rl[t[i++]],rl[t[i++]],rl[t[i++]],rl[t[i++]],"-",rl[t[i++]],rl[t[i++]],"-",rl[t[i++]],rl[t[i++]],"-",rl[t[i++]],rl[t[i++]],"-",rl[t[i++]],rl[t[i++]],rl[t[i++]],rl[t[i++]],rl[t[i++]],rl[t[i++]]].join("")}(n)};const ol=ua(),al=require("../package.json").version,ll=process.env.MEDUSA_TELEMETRY_API||"https://telemetry.medusa-commerce.com/batch",cl=()=>{let t=ol.get("telemetry.machine_id");return"string"!=typeof t&&(t=sl(),ol.set("telemetry.machine_id",t)),t},ul=sl(),hl=(t,e)=>{el(ll,{method:"POST",headers:{"content-type":"application/json","user-agent":`create-medusa-app:${al}`},body:JSON.stringify({timestamp:new Date,batch:[{type:t,timestamp:new Date,sessionId:ul,machine_id:cl(),component_id:"create-medusa-app",cli_version:al,properties:e}]})}).catch(()=>{})};let dl="";const pl={type:"input",name:"projectRoot",message:"Where should your project be installed?",initial:"my-medusa-store"},fl={type:"select",name:"starter",message:"Which Medusa starter would you like to install?",choices:["medusa-starter-default","medusa-starter-contentful","Other"]},ml={type:"input",name:"starterUrl",message:"Where is the starter located? (URL or path)"},gl={type:"select",name:"storefront",message:"Which storefront starter would you like to install?",choices:["Gatsby Starter","Next.js Starter","medusa.express (Next.js)","medusa.express (Gatsby)","Gatsby Starter (Simple)","None"]},yl=new nt.Command("create-medusa-app").version("0.0.7-next.98+d7971ba6").action(t=>dl=t).option("-r --root","The directory to install your Medusa app").option("-s --starter-url","A GitHub URL to a repository that contains a Medusa starter project to bootstrap from").option("--no-seed","If run with the no-seed flag the script will skip seeding the database upon setup").option("-v --verbose","Show all installation output").parse(process.argv);exports.run=async()=>{hl("CREATE_CLI"),"string"==typeof dl&&(dl=dl.trim());const{projectRoot:t}=await Oe.prompt(pl);let{starter:e}=await Oe.prompt(fl);if("Other"===e){const{starterUrl:t}=await Oe.prompt(ml);e=t}else e=`medusajs/${e}`;hl("STARTER_SELECTED",{starter:e});const i=yl.opts(),r=i.noSeed;hl("SEED_SELECTED",{seed:!r});const{storefront:n}=await Oe.prompt(gl);hl("STOREFRONT_SELECTED",{storefront:n}),await ma({starter:e,root:y.default.join(t,"backend"),seed:!r,verbose:i.verbose});const s="none"!==n.toLowerCase();if(s){const e=(t=>{switch(t.toLowerCase()){case"gatsby starter":return"https://github.com/medusajs/gatsby-starter-medusa";case"next.js starter":return"https://github.com/medusajs/nextjs-starter-medusa";case"medusa.express (next.js)":return"https://github.com/medusajs/medusa-express-nextjs";case"medusa.express (gatsby)":return"https://github.com/medusajs/medusa-express-gatsby";case"gatsby starter (simple)":return"https://github.com/medusajs/gatsby-starter-medusa-simple";default:return""}})(n);await ma({starter:e,root:y.default.join(t,"storefront"),verbose:i.verbose})}await ma({starter:"https://github.com/medusajs/admin",root:y.default.join(t,"admin"),keepGit:!0,verbose:i.verbose}),console.log(`\n Your project is ready 🚀. The available commands are:\n \n Medusa API\n cd ${t}/backend\n yarn start\n\n Admin\n cd ${t}/admin\n yarn start\n `),s&&console.log(`\n Storefront\n cd ${t}/storefront\n yarn start\n `)};