UNPKG

tinyimg-scripts

Version:
16 lines (14 loc) 58.3 kB
#!/usr/bin/env node import t from"events";import e from"child_process";import n from"path";import r from"fs";import i from"os";import o from"tty";import s from"https";import a from"url"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function l(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{l(r.next(t))}catch(t){o(t)}}function a(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((r=r.apply(t,e||[])).next())}))}function h(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}var c={exports:{}},u={},p={};class m extends Error{constructor(t,e,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}}p.CommanderError=m,p.InvalidArgumentError=class extends m{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:d}=p;u.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,n)=>{if(!t.includes(e))throw new d(`Allowed choices are ${t.join(", ")}.`);return this.variadic?this._concatValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},u.humanReadableArgName=function(t){const e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"};var g={},f={};const{humanReadableArgName:b}=u;f.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[,n,r]=t._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),i=t.createCommand(n).helpOption(!1);i.description(t._helpCommandDescription),r&&i.arguments(r),e.push(i)}return this.sortSubcommands&&e.sort(((t,e)=>t.name().localeCompare(e.name()))),e}visibleOptions(t){const e=t.options.filter((t=>!t.hidden)),n=t._hasHelpOption&&t._helpShortFlag&&!t._findOption(t._helpShortFlag),r=t._hasHelpOption&&!t._findOption(t._helpLongFlag);if(n||r){let i;i=n?r?t.createOption(t._helpFlags,t._helpDescription):t.createOption(t._helpShortFlag,t._helpDescription):t.createOption(t._helpLongFlag,t._helpDescription),e.push(i)}if(this.sortOptions){const t=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");e.sort(((e,n)=>t(e).localeCompare(t(n))))}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,n)=>Math.max(t,e.subcommandTerm(n).length)),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce(((t,n)=>Math.max(t,e.optionTerm(n).length)),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce(((t,n)=>Math.max(t,e.argumentTerm(n).length)),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let n="";for(let e=t.parent;e;e=e.parent)n=e.name()+" "+n;return n+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 n=`(${e.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}formatHelp(t,e){const n=e.padWidth(t,e),r=e.helpWidth||80;function i(t,i){if(i){const o=`${t.padEnd(n+2)}${i}`;return e.wrap(o,r-2,n+2)}return t}function o(t){return t.join("\n").replace(/^/gm," ".repeat(2))}let s=[`Usage: ${e.commandUsage(t)}`,""];const a=e.commandDescription(t);a.length>0&&(s=s.concat([a,""]));const l=e.visibleArguments(t).map((t=>i(e.argumentTerm(t),e.argumentDescription(t))));l.length>0&&(s=s.concat(["Arguments:",o(l),""]));const h=e.visibleOptions(t).map((t=>i(e.optionTerm(t),e.optionDescription(t))));h.length>0&&(s=s.concat(["Options:",o(h),""]));const c=e.visibleCommands(t).map((t=>i(e.subcommandTerm(t),e.subcommandDescription(t))));return c.length>0&&(s=s.concat(["Commands:",o(c),""])),s.join("\n")}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}wrap(t,e,n,r=40){if(t.match(/[\n]\s+/))return t;const i=e-n;if(i<r)return t;const o=t.substr(0,n),s=t.substr(n),a=" ".repeat(n),l=new RegExp(".{1,"+(i-1)+"}([\\s​]|$)|[^\\s​]+?([\\s​]|$)","g");return o+(s.match(l)||[]).map(((t,e)=>("\n"===t.slice(-1)&&(t=t.slice(0,t.length-1)),(e>0?a:"")+t.trimRight()))).join("\n")}};var _={};const{InvalidArgumentError:v}=p;function y(t){let e,n;const r=t.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),n=r.shift(),!e&&/^-[^-]$/.test(n)&&(e=n,n=void 0),{shortFlag:e,longFlag:n}}_.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 n=y(t);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.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,n)=>{if(!t.includes(e))throw new v(`Allowed choices are ${t.join(", ")}.`);return this.variadic?this._concatValue(e,n):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=y;var w={};w.suggestSimilar=function(t,e){if(!e||0===e.length)return"";e=Array.from(new Set(e));const n=t.startsWith("--");n&&(t=t.slice(2),e=e.map((t=>t.slice(2))));let r=[],i=3;return e.forEach((e=>{if(e.length<=1)return;const n=function(t,e){if(Math.abs(t.length-e.length)>3)return Math.max(t.length,e.length);const n=[];for(let e=0;e<=t.length;e++)n[e]=[e];for(let t=0;t<=e.length;t++)n[0][t]=t;for(let r=1;r<=e.length;r++)for(let i=1;i<=t.length;i++){let o=1;o=t[i-1]===e[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+o),i>1&&r>1&&t[i-1]===e[r-2]&&t[i-2]===e[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[t.length][e.length]}(t,e),o=Math.max(t.length,e.length);(o-n)/o>.4&&(n<i?(i=n,r=[e]):n===i&&r.push(e))})),r.sort(((t,e)=>t.localeCompare(e))),n&&(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 O=t.EventEmitter,C=e,A=n,E=r,{Argument:x,humanReadableArgName:k}=u,{CommanderError:M}=p,{Help:$}=f,{Option:S,splitOptionFlags:H}=_,{suggestSimilar:P}=w;class j extends O{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,n){let r=e,i=n;"object"==typeof r&&null!==r&&(i=r,r=null),i=i||{};const[,o,s]=t.match(/([^ ]+) *(.*)/),a=this.createCommand(o);return r&&(a.description(r),a._executableHandler=!0),i.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!i.noHelp&&!i.hidden),a._executableFile=i.executableFile||null,s&&a.arguments(s),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),r?this:a}createCommand(t){return new j(t)}createHelp(){return Object.assign(new $,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 x(t,e)}argument(t,e,n,r){const i=this.createArgument(t,e);return"function"==typeof n?i.default(r).argParser(n):i.default(n),this.addArgument(i),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 n=["preAction","postAction"];if(!n.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${n.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,n){this._exitCallback&&this._exitCallback(new M(t,e,n)),process.exit(t)}action(t){return this._actionHandler=e=>{const n=this._args.length,r=e.slice(0,n);return this._storeOptionsAsProperties?r[n]=this:r[n]=this.opts(),r.push(this),t.apply(this,r)},this}createOption(t,e){return new S(t,e)}addOption(t){const e=t.name(),n=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(n)}void 0!==r&&this._setOptionValueWithSource(n,r,"default")}this.options.push(t);const i=(e,i,o)=>{const s=this.getOptionValue(n);if(null!==e&&t.parseArg)try{e=t.parseArg(e,void 0===s?r:s)}catch(t){if("commander.invalidArgument"===t.code){const e=`${i} ${t.message}`;this._displayError(t.exitCode,t.code,e)}throw t}else null!==e&&t.variadic&&(e=t._concatValue(e,s));"boolean"==typeof s||void 0===s?null==e?this._setOptionValueWithSource(n,!t.negate&&(r||!0),o):this._setOptionValueWithSource(n,e,o):null!==e&&this._setOptionValueWithSource(n,!t.negate&&e,o)};return this.on("option:"+e,(e=>{const n=`error: option '${t.flags}' argument '${e}' is invalid.`;i(e,n,"cli")})),t.envVar&&this.on("optionEnv:"+e,(e=>{const n=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;i(e,n,"env")})),this}_optionEx(t,e,n,r,i){const o=this.createOption(e,n);if(o.makeOptionMandatory(!!t.mandatory),"function"==typeof r)o.default(i).argParser(r);else if(r instanceof RegExp){const t=r;r=(e,n)=>{const r=t.exec(e);return r?r[0]:n},o.default(i).argParser(r)}else o.default(r);return this.addOption(o)}option(t,e,n,r){return this._optionEx({},t,e,n,r)}requiredOption(t,e,n,r){return this._optionEx({mandatory:!0},t,e,n,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,n){this.setOptionValue(t,e),this._optionValueSources[t]=n}_prepareUserArgs(t,e){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");let n;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],n=t.slice(2);break;case"electron":process.defaultApp?(this._scriptPath=t[1],n=t.slice(2)):n=t.slice(1);break;case"user":n=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&&A.basename(this._scriptPath,A.extname(this._scriptPath)),n}parse(t,e){const n=this._prepareUserArgs(t,e);return this._parseCommand([],n),this}async parseAsync(t,e){const n=this._prepareUserArgs(t,e);return await this._parseCommand([],n),this}_executeSubCommand(t,e){e=e.slice();let n=!1;const r=[".js",".ts",".tsx",".mjs",".cjs"];this._checkForMissingMandatoryOptions();let i,o=this._scriptPath;!o&&require.main&&(o=require.main.filename);try{const t=E.realpathSync(o);i=A.dirname(t)}catch(t){i="."}let s=A.basename(o,A.extname(o))+"-"+t._name;t._executableFile&&(s=t._executableFile);const a=A.join(i,s);let l;E.existsSync(a)?s=a:r.forEach((t=>{E.existsSync(`${a}${t}`)&&(s=`${a}${t}`)})),n=r.includes(A.extname(s)),"win32"!==process.platform?n?(e.unshift(s),e=F(process.execArgv).concat(e),l=C.spawn(process.argv[0],e,{stdio:"inherit"})):l=C.spawn(s,e,{stdio:"inherit"}):(e.unshift(s),e=F(process.execArgv).concat(e),l=C.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 h=this._exitCallback;h?l.on("close",(()=>{h(new M(process.exitCode||0,"commander.executeSubCommandAsync","(close)"))})):l.on("close",process.exit.bind(process)),l.on("error",(e=>{if("ENOENT"===e.code){const e=`'${s}' 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`;throw new Error(e)}if("EACCES"===e.code)throw new Error(`'${s}' not executable`);if(h){const t=new M(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,h(t)}else process.exit(1)})),this.runningCommand=l}_dispatchSubcommand(t,e,n){const r=this._findCommand(t);if(r||this.help({error:!0}),!r._executableHandler)return r._parseCommand(e,n);this._executeSubCommand(r,e.concat(n))}_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,n)=>{let r=e;if(null!==e&&t.parseArg)try{r=t.parseArg(e,n)}catch(n){if("commander.invalidArgument"===n.code){const r=`error: command-argument value '${e}' is invalid for argument '${t.name()}'. ${n.message}`;this._displayError(n.exitCode,n.code,r)}throw n}return r};this._checkNumberOfArguments();const e=[];this._args.forEach(((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce(((e,r)=>t(n,r,e)),n.defaultValue))):void 0===i&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=t(n,i,n.defaultValue))),e[r]=i})),this.processedArgs=e}_chainOrCall(t,e){return t&&t.then&&"function"==typeof t.then?t.then((()=>e())):e()}_chainOrCallHooks(t,e){let n=t;const r=[];return I(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=>{n=this._chainOrCall(n,(()=>t.callback(t.hookedCommand,this)))})),n}_parseCommand(t,e){const n=this.parseOptions(e);if(this._parseOptionsEnv(),t=t.concat(n.operands),e=n.unknown,this.args=t.concat(e),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 V(this,e),this._dispatchSubcommand(this._defaultCommandName,t,e);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),V(this,n.unknown),this._checkForMissingMandatoryOptions();const r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){let n;return r(),this._processArguments(),n=this._chainOrCallHooks(n,"preAction"),n=this._chainOrCall(n,(()=>this._actionHandler(this.processedArgs))),this.parent&&this.parent.emit(i,t,e),n=this._chainOrCallHooks(n,"postAction"),n}if(this.parent&&this.parent.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,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=[],n=[];let r=e;const i=t.slice();function o(t){return t.length>1&&"-"===t[0]}let s=null;for(;i.length;){const t=i.shift();if("--"===t){r===n&&r.push(t),r.push(...i);break}if(!s||o(t)){if(s=null,o(t)){const e=this._findOption(t);if(e){if(e.required){const t=i.shift();void 0===t&&this.optionMissingArgument(e),this.emit(`option:${e.name()}`,t)}else if(e.optional){let t=null;i.length>0&&!o(i[0])&&(t=i.shift()),this.emit(`option:${e.name()}`,t)}else this.emit(`option:${e.name()}`);s=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()}`),i.unshift(`-${t.slice(2)}`));continue}}if(/^--[^=]+=/.test(t)){const e=t.indexOf("="),n=this._findOption(t.slice(0,e));if(n&&(n.required||n.optional)){this.emit(`option:${n.name()}`,t.slice(e+1));continue}}if(o(t)&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&0===e.length&&0===n.length){if(this._findCommand(t)){e.push(t),i.length>0&&n.push(...i);break}if(t===this._helpCommandName&&this._hasImplicitHelpCommand()){e.push(t),i.length>0&&e.push(...i);break}if(this._defaultCommandName){n.push(t),i.length>0&&n.push(...i);break}}if(this._passThroughOptions){r.push(t),i.length>0&&r.push(...i);break}r.push(t)}else this.emit(`option:${s.name()}`,t)}return{operands:e,unknown:n}}opts(){if(this._storeOptionsAsProperties){const t={},e=this.options.length;for(let n=0;n<e;n++){const e=this.options[n].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}_displayError(t,e,n){this._outputConfiguration.outputError(`${n}\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,n)}_parseOptionsEnv(){this.options.forEach((t=>{if(t.envVar&&t.envVar in process.env){const e=t.attributeName();void 0!==this.getOptionValue(e)&&"default"!==this._optionValueSources[e]||(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,process.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}}))}missingArgument(t){const e=`error: missing required argument '${t}'`;this._displayError(1,"commander.missingArgument",e)}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this._displayError(1,"commander.optionMissingArgument",e)}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this._displayError(1,"commander.missingMandatoryOptionValue",e)}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let n=[],r=this;do{const t=r.createHelp().visibleOptions(r).filter((t=>t.long)).map((t=>t.long));n=n.concat(t),r=r.parent}while(r&&!r._enablePositionalOptions);e=P(t,n)}const n=`error: unknown option '${t}'${e}`;this._displayError(1,"commander.unknownOption",n)}_excessArguments(t){if(this._allowExcessArguments)return;const e=this._args.length,n=1===e?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${n} but got ${t.length}.`;this._displayError(1,"commander.excessArguments",r)}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const n=[];this.createHelp().visibleCommands(this).forEach((t=>{n.push(t.name()),t.alias()&&n.push(t.alias())})),e=P(t,n)}const n=`error: unknown command '${t}'${e}`;this._displayError(1,"commander.unknownCommand",n)}version(t,e,n){if(void 0===t)return this._version;this._version=t,e=e||"-V, --version",n=n||"output the version number";const r=this.createOption(e,n);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=>k(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 n;return n=e.error?t=>this._outputConfiguration.writeErr(t):t=>this._outputConfiguration.writeOut(t),e.write=t.write||n,e.command=this,e}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const n=this._getHelpContext(t);I(this).reverse().forEach((t=>t.emit("beforeAllHelp",n))),this.emit("beforeHelp",n);let r=this.helpInformation(n);if(e&&(r=e(r),"string"!=typeof r&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(r),this.emit(this._helpLongFlag),this.emit("afterHelp",n),I(this).forEach((t=>t.emit("afterAllHelp",n)))}helpOption(t,e){if("boolean"==typeof t)return this._hasHelpOption=t,this;this._helpFlags=t||this._helpFlags,this._helpDescription=e||this._helpDescription;const n=H(this._helpFlags);return this._helpShortFlag=n.shortFlag,this._helpLongFlag=n.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 n=["beforeAll","before","after","afterAll"];if(!n.includes(t))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${n.join("', '")}'`);const r=`${t}Help`;return this.on(r,(t=>{let n;n="function"==typeof e?e({error:t.error,command:t.command}):e,n&&t.write(`${n}\n`)})),this}}function V(t,e){t._hasHelpOption&&e.find((e=>e===t._helpLongFlag||e===t._helpShortFlag))&&(t.outputHelp(),t._exit(0,"commander.helpDisplayed","(outputHelp)"))}function F(t){return t.map((t=>{if(!t.startsWith("--inspect"))return t;let e,n,r="127.0.0.1",i="9229";return null!==(n=t.match(/^(--inspect(-brk)?)$/))?e=n[1]:null!==(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(e=n[1],/^\d+$/.test(n[3])?i=n[3]:r=n[3]):null!==(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(e=n[1],r=n[3],i=n[4]),e&&"0"!==i?`${e}=${r}:${parseInt(i)+1}`:t}))}function I(t){const e=[];for(let n=t;n;n=n.parent)e.push(n);return e}g.Command=j,function(t,e){const{Argument:n}=u,{Command:r}=g,{CommanderError:i,InvalidArgumentError:o}=p,{Help:s}=f,{Option:a}=_;(e=t.exports=new r).program=e,e.Argument=n,e.Command=r,e.CommanderError=i,e.Help=s,e.InvalidArgumentError=o,e.InvalidOptionArgumentError=o,e.Option=a}(c,c.exports);var R={exports:{}};const T={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},B={};for(const t of Object.keys(T))B[T[t]]=t;const D={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};var N=D;for(const t of Object.keys(D)){if(!("channels"in D[t]))throw new Error("missing channels property: "+t);if(!("labels"in D[t]))throw new Error("missing channel labels property: "+t);if(D[t].labels.length!==D[t].channels)throw new Error("channel and label counts mismatch: "+t);const{channels:e,labels:n}=D[t];delete D[t].channels,delete D[t].labels,Object.defineProperty(D[t],"channels",{value:e}),Object.defineProperty(D[t],"labels",{value:n})}D.rgb.hsl=function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.min(e,n,r),o=Math.max(e,n,r),s=o-i;let a,l;o===i?a=0:e===o?a=(n-r)/s:n===o?a=2+(r-e)/s:r===o&&(a=4+(e-n)/s),a=Math.min(60*a,360),a<0&&(a+=360);const h=(i+o)/2;return l=o===i?0:h<=.5?s/(o+i):s/(2-o-i),[a,100*l,100*h]},D.rgb.hsv=function(t){let e,n,r,i,o;const s=t[0]/255,a=t[1]/255,l=t[2]/255,h=Math.max(s,a,l),c=h-Math.min(s,a,l),u=function(t){return(h-t)/6/c+.5};return 0===c?(i=0,o=0):(o=c/h,e=u(s),n=u(a),r=u(l),s===h?i=r-n:a===h?i=1/3+e-r:l===h&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*o,100*h]},D.rgb.hwb=function(t){const e=t[0],n=t[1];let r=t[2];const i=D.rgb.hsl(t)[0],o=1/255*Math.min(e,Math.min(n,r));return r=1-1/255*Math.max(e,Math.max(n,r)),[i,100*o,100*r]},D.rgb.cmyk=function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.min(1-e,1-n,1-r);return[100*((1-e-i)/(1-i)||0),100*((1-n-i)/(1-i)||0),100*((1-r-i)/(1-i)||0),100*i]},D.rgb.keyword=function(t){const e=B[t];if(e)return e;let n,r=1/0;for(const e of Object.keys(T)){const s=(o=T[e],((i=t)[0]-o[0])**2+(i[1]-o[1])**2+(i[2]-o[2])**2);s<r&&(r=s,n=e)}var i,o;return n},D.keyword.rgb=function(t){return T[t]},D.rgb.xyz=function(t){let e=t[0]/255,n=t[1]/255,r=t[2]/255;e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;return[100*(.4124*e+.3576*n+.1805*r),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},D.rgb.lab=function(t){const e=D.rgb.xyz(t);let n=e[0],r=e[1],i=e[2];n/=95.047,r/=100,i/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,i=i>.008856?i**(1/3):7.787*i+16/116;return[116*r-16,500*(n-r),200*(r-i)]},D.hsl.rgb=function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100;let i,o,s;if(0===n)return s=255*r,[s,s,s];i=r<.5?r*(1+n):r+n-r*n;const a=2*r-i,l=[0,0,0];for(let t=0;t<3;t++)o=e+1/3*-(t-1),o<0&&o++,o>1&&o--,s=6*o<1?a+6*(i-a)*o:2*o<1?i:3*o<2?a+(i-a)*(2/3-o)*6:a,l[t]=255*s;return l},D.hsl.hsv=function(t){const e=t[0];let n=t[1]/100,r=t[2]/100,i=n;const o=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,i*=o<=1?o:2-o;return[e,100*(0===r?2*i/(o+i):2*n/(r+n)),100*((r+n)/2)]},D.hsv.rgb=function(t){const e=t[0]/60,n=t[1]/100;let r=t[2]/100;const i=Math.floor(e)%6,o=e-Math.floor(e),s=255*r*(1-n),a=255*r*(1-n*o),l=255*r*(1-n*(1-o));switch(r*=255,i){case 0:return[r,l,s];case 1:return[a,r,s];case 2:return[s,r,l];case 3:return[s,a,r];case 4:return[l,s,r];case 5:return[r,s,a]}},D.hsv.hsl=function(t){const e=t[0],n=t[1]/100,r=t[2]/100,i=Math.max(r,.01);let o,s;s=(2-n)*r;const a=(2-n)*i;return o=n*i,o/=a<=1?a:2-a,o=o||0,s/=2,[e,100*o,100*s]},D.hwb.rgb=function(t){const e=t[0]/360;let n=t[1]/100,r=t[2]/100;const i=n+r;let o;i>1&&(n/=i,r/=i);const s=Math.floor(6*e),a=1-r;o=6*e-s,0!=(1&s)&&(o=1-o);const l=n+o*(a-n);let h,c,u;switch(s){default:h=a,c=l,u=n;break;case 1:h=l,c=a,u=n;break;case 2:h=n,c=a,u=l;break;case 3:h=n,c=l,u=a;break;case 4:h=l,c=n,u=a;break;case 5:h=a,c=n,u=l}return[255*h,255*c,255*u]},D.cmyk.rgb=function(t){const e=t[0]/100,n=t[1]/100,r=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},D.xyz.rgb=function(t){const e=t[0]/100,n=t[1]/100,r=t[2]/100;let i,o,s;return i=3.2406*e+-1.5372*n+-.4986*r,o=-.9689*e+1.8758*n+.0415*r,s=.0557*e+-.204*n+1.057*r,i=i>.0031308?1.055*i**(1/2.4)-.055:12.92*i,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),s=Math.min(Math.max(0,s),1),[255*i,255*o,255*s]},D.xyz.lab=function(t){let e=t[0],n=t[1],r=t[2];e/=95.047,n/=100,r/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;return[116*n-16,500*(e-n),200*(n-r)]},D.lab.xyz=function(t){let e,n,r;n=(t[0]+16)/116,e=t[1]/500+n,r=n-t[2]/200;const i=n**3,o=e**3,s=r**3;return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=s>.008856?s:(r-16/116)/7.787,e*=95.047,n*=100,r*=108.883,[e,n,r]},D.lab.lch=function(t){const e=t[0],n=t[1],r=t[2];let i;i=360*Math.atan2(r,n)/2/Math.PI,i<0&&(i+=360);return[e,Math.sqrt(n*n+r*r),i]},D.lch.lab=function(t){const e=t[0],n=t[1],r=t[2]/360*2*Math.PI;return[e,n*Math.cos(r),n*Math.sin(r)]},D.rgb.ansi16=function(t,e=null){const[n,r,i]=t;let o=null===e?D.rgb.hsv(t)[2]:e;if(o=Math.round(o/50),0===o)return 30;let s=30+(Math.round(i/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return 2===o&&(s+=60),s},D.hsv.ansi16=function(t){return D.rgb.ansi16(D.hsv.rgb(t),t[2])},D.rgb.ansi256=function(t){const e=t[0],n=t[1],r=t[2];if(e===n&&n===r)return e<8?16:e>248?231:Math.round((e-8)/247*24)+232;return 16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},D.ansi16.rgb=function(t){let e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];const n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},D.ansi256.rgb=function(t){if(t>=232){const e=10*(t-232)+8;return[e,e,e]}let e;t-=16;return[Math.floor(t/36)/5*255,Math.floor((e=t%36)/6)/5*255,e%6/5*255]},D.rgb.hex=function(t){const e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},D.hex.rgb=function(t){const e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];let n=e[0];3===e[0].length&&(n=n.split("").map((t=>t+t)).join(""));const r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},D.rgb.hcg=function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.max(Math.max(e,n),r),o=Math.min(Math.min(e,n),r),s=i-o;let a,l;return a=s<1?o/(1-s):0,l=s<=0?0:i===e?(n-r)/s%6:i===n?2+(r-e)/s:4+(e-n)/s,l/=6,l%=1,[360*l,100*s,100*a]},D.hsl.hcg=function(t){const e=t[1]/100,n=t[2]/100,r=n<.5?2*e*n:2*e*(1-n);let i=0;return r<1&&(i=(n-.5*r)/(1-r)),[t[0],100*r,100*i]},D.hsv.hcg=function(t){const e=t[1]/100,n=t[2]/100,r=e*n;let i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},D.hcg.rgb=function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];const i=[0,0,0],o=e%1*6,s=o%1,a=1-s;let l=0;switch(Math.floor(o)){case 0:i[0]=1,i[1]=s,i[2]=0;break;case 1:i[0]=a,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=s;break;case 3:i[0]=0,i[1]=a,i[2]=1;break;case 4:i[0]=s,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=a}return l=(1-n)*r,[255*(n*i[0]+l),255*(n*i[1]+l),255*(n*i[2]+l)]},D.hcg.hsv=function(t){const e=t[1]/100,n=e+t[2]/100*(1-e);let r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},D.hcg.hsl=function(t){const e=t[1]/100,n=t[2]/100*(1-e)+.5*e;let r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},D.hcg.hwb=function(t){const e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},D.hwb.hcg=function(t){const e=t[1]/100,n=1-t[2]/100,r=n-e;let i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},D.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},D.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},D.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},D.gray.hsl=function(t){return[0,0,t[0]]},D.gray.hsv=D.gray.hsl,D.gray.hwb=function(t){return[0,100,t[0]]},D.gray.cmyk=function(t){return[0,0,0,t[0]]},D.gray.lab=function(t){return[t[0],0,0]},D.gray.hex=function(t){const e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},D.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};const L=N;function q(t){const e=function(){const t={},e=Object.keys(L);for(let n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;){const t=n.pop(),r=Object.keys(L[t]);for(let i=r.length,o=0;o<i;o++){const i=r[o],s=e[i];-1===s.distance&&(s.distance=e[t].distance+1,s.parent=t,n.unshift(i))}}return e}function U(t,e){return function(n){return e(t(n))}}function W(t,e){const n=[e[t].parent,t];let r=L[e[t].parent][t],i=e[t].parent;for(;e[i].parent;)n.unshift(e[i].parent),r=U(L[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}const G=N,z=function(t){const e=q(t),n={},r=Object.keys(e);for(let t=r.length,i=0;i<t;i++){const t=r[i];null!==e[t].parent&&(n[t]=W(t,e))}return n},Y={};Object.keys(G).forEach((t=>{Y[t]={},Object.defineProperty(Y[t],"channels",{value:G[t].channels}),Object.defineProperty(Y[t],"labels",{value:G[t].labels});const e=z(t);Object.keys(e).forEach((n=>{const r=e[n];Y[t][n]=function(t){const e=function(...e){const n=e[0];if(null==n)return n;n.length>1&&(e=n);const r=t(e);if("object"==typeof r)for(let t=r.length,e=0;e<t;e++)r[e]=Math.round(r[e]);return r};return"conversion"in t&&(e.conversion=t.conversion),e}(r),Y[t][n].raw=function(t){const e=function(...e){const n=e[0];return null==n?n:(n.length>1&&(e=n),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var J=Y;!function(t){const e=(t,e)=>(...n)=>`[${t(...n)+e}m`,n=(t,e)=>(...n)=>{const r=t(...n);return`[${38+e};5;${r}m`},r=(t,e)=>(...n)=>{const r=t(...n);return`[${38+e};2;${r[0]};${r[1]};${r[2]}m`},i=t=>t,o=(t,e,n)=>[t,e,n],s=(t,e,n)=>{Object.defineProperty(t,e,{get:()=>{const r=n();return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0}),r},enumerable:!0,configurable:!0})};let a;const l=(t,e,n,r)=>{void 0===a&&(a=J);const i=r?10:0,o={};for(const[r,s]of Object.entries(a)){const a="ansi16"===r?"ansi":r;r===e?o[a]=t(n,i):"object"==typeof s&&(o[a]=t(s[e],i))}return o};Object.defineProperty(t,"exports",{enumerable:!0,get:function(){const t=new Map,a={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};a.color.gray=a.color.blackBright,a.bgColor.bgGray=a.bgColor.bgBlackBright,a.color.grey=a.color.blackBright,a.bgColor.bgGrey=a.bgColor.bgBlackBright;for(const[e,n]of Object.entries(a)){for(const[e,r]of Object.entries(n))a[e]={open:`[${r[0]}m`,close:`[${r[1]}m`},n[e]=a[e],t.set(r[0],r[1]);Object.defineProperty(a,e,{value:n,enumerable:!1})}return Object.defineProperty(a,"codes",{value:t,enumerable:!1}),a.color.close="",a.bgColor.close="",s(a.color,"ansi",(()=>l(e,"ansi16",i,!1))),s(a.color,"ansi256",(()=>l(n,"ansi256",i,!1))),s(a.color,"ansi16m",(()=>l(r,"rgb",o,!1))),s(a.bgColor,"ansi",(()=>l(e,"ansi16",i,!0))),s(a.bgColor,"ansi256",(()=>l(n,"ansi256",i,!0))),s(a.bgColor,"ansi16m",(()=>l(r,"rgb",o,!0))),a}})}(R);const K=i,X=o,Z=(t,e=process.argv)=>{const n=t.startsWith("-")?"":1===t.length?"-":"--",r=e.indexOf(n+t),i=e.indexOf("--");return-1!==r&&(-1===i||r<i)},{env:Q}=process;let tt;function et(t){return 0!==t&&{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function nt(t,e){if(0===tt)return 0;if(Z("color=16m")||Z("color=full")||Z("color=truecolor"))return 3;if(Z("color=256"))return 2;if(t&&!e&&void 0===tt)return 0;const n=tt||0;if("dumb"===Q.TERM)return n;if("win32"===process.platform){const t=K.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in Q)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((t=>t in Q))||"codeship"===Q.CI_NAME?1:n;if("TEAMCITY_VERSION"in Q)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Q.TEAMCITY_VERSION)?1:0;if("truecolor"===Q.COLORTERM)return 3;if("TERM_PROGRAM"in Q){const t=parseInt((Q.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Q.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Q.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Q.TERM)||"COLORTERM"in Q?1:n}Z("no-color")||Z("no-colors")||Z("color=false")||Z("color=never")?tt=0:(Z("color")||Z("colors")||Z("color=true")||Z("color=always"))&&(tt=1),"FORCE_COLOR"in Q&&(tt="true"===Q.FORCE_COLOR?1:"false"===Q.FORCE_COLOR?0:0===Q.FORCE_COLOR.length?1:Math.min(parseInt(Q.FORCE_COLOR,10),3));var rt={supportsColor:function(t){return et(nt(t,t&&t.isTTY))},stdout:et(nt(!0,X.isatty(1))),stderr:et(nt(!0,X.isatty(2)))};var it={stringReplaceAll:(t,e,n)=>{let r=t.indexOf(e);if(-1===r)return t;const i=e.length;let o=0,s="";do{s+=t.substr(o,r-o)+e+n,o=r+i,r=t.indexOf(e,o)}while(-1!==r);return s+=t.substr(o),s},stringEncaseCRLFWithFirstIndex:(t,e,n,r)=>{let i=0,o="";do{const s="\r"===t[r-1];o+=t.substr(i,(s?r-1:r)-i)+e+(s?"\r\n":"\n")+n,i=r+1,r=t.indexOf("\n",i)}while(-1!==r);return o+=t.substr(i),o}};const ot=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,st=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,at=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,lt=/\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,ht=new Map([["n","\n"],["r","\r"],["t","\t"],["b","\b"],["f","\f"],["v","\v"],["0","\0"],["\\","\\"],["e",""],["a",""]]);function ct(t){const e="u"===t[0],n="{"===t[1];return e&&!n&&5===t.length||"x"===t[0]&&3===t.length?String.fromCharCode(parseInt(t.slice(1),16)):e&&n?String.fromCodePoint(parseInt(t.slice(2,-1),16)):ht.get(t)||t}function ut(t,e){const n=[],r=e.trim().split(/\s*,\s*/g);let i;for(const e of r){const r=Number(e);if(Number.isNaN(r)){if(!(i=e.match(at)))throw new Error(`Invalid Chalk template style argument: ${e} (in style '${t}')`);n.push(i[2].replace(lt,((t,e,n)=>e?ct(e):n)))}else n.push(r)}return n}function pt(t){st.lastIndex=0;const e=[];let n;for(;null!==(n=st.exec(t));){const t=n[1];if(n[2]){const r=ut(t,n[2]);e.push([t].concat(r))}else e.push([t])}return e}function mt(t,e){const n={};for(const t of e)for(const e of t.styles)n[e[0]]=t.inverse?null:e.slice(1);let r=t;for(const[t,e]of Object.entries(n))if(Array.isArray(e)){if(!(t in r))throw new Error(`Unknown Chalk style: ${t}`);r=e.length>0?r[t](...e):r[t]}return r}var dt=(t,e)=>{const n=[],r=[];let i=[];if(e.replace(ot,((e,o,s,a,l,h)=>{if(o)i.push(ct(o));else if(a){const e=i.join("");i=[],r.push(0===n.length?e:mt(t,n)(e)),n.push({inverse:s,styles:pt(a)})}else if(l){if(0===n.length)throw new Error("Found extraneous } in Chalk template literal");r.push(mt(t,n)(i.join(""))),i=[],n.pop()}else i.push(h)})),r.push(i.join("")),n.length>0){const t=`Chalk template literal is missing ${n.length} closing bracket${1===n.length?"":"s"} (\`}\`)`;throw new Error(t)}return r.join("")};const gt=R.exports,{stdout:ft,stderr:bt}=rt,{stringReplaceAll:_t,stringEncaseCRLFWithFirstIndex:vt}=it,{isArray:yt}=Arr