UNPKG

create-hest-app

Version:

Create HestJS-powered applications with one command

27 lines 832 kB
#!/usr/bin/env node import{createRequire as Bk}from"node:module";var Hk=Object.create;var{getPrototypeOf:Wk,defineProperty:WJ,getOwnPropertyNames:Kk}=Object;var zk=Object.prototype.hasOwnProperty;var e=(D,$,Z)=>{Z=D!=null?Hk(Wk(D)):{};let F=$||!D||!D.__esModule?WJ(Z,"default",{value:D,enumerable:!0}):Z;for(let Y of Kk(D))if(!zk.call(F,Y))WJ(F,Y,{get:()=>D[Y],enumerable:!0});return F};var W=(D,$)=>()=>($||D(($={exports:{}}).exports,$),$.exports);var S=Bk(import.meta.url);var q6=W((Vk)=>{class o3 extends Error{constructor(D,$,Z){super(Z);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=$,this.exitCode=D,this.nestedError=void 0}}class KJ extends o3{constructor(D){super(1,"commander.invalidArgument",D);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}Vk.CommanderError=o3;Vk.InvalidArgumentError=KJ});var _9=W((Ik)=>{var{InvalidArgumentError:Nk}=q6();class zJ{constructor(D,$){switch(this.description=$||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,D[0]){case"<":this.required=!0,this._name=D.slice(1,-1);break;case"[":this.required=!1,this._name=D.slice(1,-1);break;default:this.required=!0,this._name=D;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue(D,$){if($===this.defaultValue||!Array.isArray($))return[D];return $.concat(D)}default(D,$){return this.defaultValue=D,this.defaultValueDescription=$,this}argParser(D){return this.parseArg=D,this}choices(D){return this.argChoices=D.slice(),this.parseArg=($,Z)=>{if(!this.argChoices.includes($))throw new Nk(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue($,Z);return $},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function Ek(D){let $=D.name()+(D.variadic===!0?"...":"");return D.required?"<"+$+">":"["+$+"]"}Ik.Argument=zJ;Ik.humanReadableArgName=Ek});var t3=W((Rk)=>{var{humanReadableArgName:Tk}=_9();class BJ{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(D){this.helpWidth=this.helpWidth??D.helpWidth??80}visibleCommands(D){let $=D.commands.filter((F)=>!F._hidden),Z=D._getHelpCommand();if(Z&&!Z._hidden)$.push(Z);if(this.sortSubcommands)$.sort((F,Y)=>{return F.name().localeCompare(Y.name())});return $}compareOptions(D,$){let Z=(F)=>{return F.short?F.short.replace(/^-/,""):F.long.replace(/^--/,"")};return Z(D).localeCompare(Z($))}visibleOptions(D){let $=D.options.filter((F)=>!F.hidden),Z=D._getHelpOption();if(Z&&!Z.hidden){let F=Z.short&&D._findOption(Z.short),Y=Z.long&&D._findOption(Z.long);if(!F&&!Y)$.push(Z);else if(Z.long&&!Y)$.push(D.createOption(Z.long,Z.description));else if(Z.short&&!F)$.push(D.createOption(Z.short,Z.description))}if(this.sortOptions)$.sort(this.compareOptions);return $}visibleGlobalOptions(D){if(!this.showGlobalOptions)return[];let $=[];for(let Z=D.parent;Z;Z=Z.parent){let F=Z.options.filter((Y)=>!Y.hidden);$.push(...F)}if(this.sortOptions)$.sort(this.compareOptions);return $}visibleArguments(D){if(D._argsDescription)D.registeredArguments.forEach(($)=>{$.description=$.description||D._argsDescription[$.name()]||""});if(D.registeredArguments.find(($)=>$.description))return D.registeredArguments;return[]}subcommandTerm(D){let $=D.registeredArguments.map((Z)=>Tk(Z)).join(" ");return D._name+(D._aliases[0]?"|"+D._aliases[0]:"")+(D.options.length?" [options]":"")+($?" "+$:"")}optionTerm(D){return D.flags}argumentTerm(D){return D.name()}longestSubcommandTermLength(D,$){return $.visibleCommands(D).reduce((Z,F)=>{return Math.max(Z,this.displayWidth($.styleSubcommandTerm($.subcommandTerm(F))))},0)}longestOptionTermLength(D,$){return $.visibleOptions(D).reduce((Z,F)=>{return Math.max(Z,this.displayWidth($.styleOptionTerm($.optionTerm(F))))},0)}longestGlobalOptionTermLength(D,$){return $.visibleGlobalOptions(D).reduce((Z,F)=>{return Math.max(Z,this.displayWidth($.styleOptionTerm($.optionTerm(F))))},0)}longestArgumentTermLength(D,$){return $.visibleArguments(D).reduce((Z,F)=>{return Math.max(Z,this.displayWidth($.styleArgumentTerm($.argumentTerm(F))))},0)}commandUsage(D){let $=D._name;if(D._aliases[0])$=$+"|"+D._aliases[0];let Z="";for(let F=D.parent;F;F=F.parent)Z=F.name()+" "+Z;return Z+$+" "+D.usage()}commandDescription(D){return D.description()}subcommandDescription(D){return D.summary()||D.description()}optionDescription(D){let $=[];if(D.argChoices)$.push(`choices: ${D.argChoices.map((Z)=>JSON.stringify(Z)).join(", ")}`);if(D.defaultValue!==void 0){if(D.required||D.optional||D.isBoolean()&&typeof D.defaultValue==="boolean")$.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`)}if(D.presetArg!==void 0&&D.optional)$.push(`preset: ${JSON.stringify(D.presetArg)}`);if(D.envVar!==void 0)$.push(`env: ${D.envVar}`);if($.length>0){let Z=`(${$.join(", ")})`;if(D.description)return`${D.description} ${Z}`;return Z}return D.description}argumentDescription(D){let $=[];if(D.argChoices)$.push(`choices: ${D.argChoices.map((Z)=>JSON.stringify(Z)).join(", ")}`);if(D.defaultValue!==void 0)$.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`);if($.length>0){let Z=`(${$.join(", ")})`;if(D.description)return`${D.description} ${Z}`;return Z}return D.description}formatItemList(D,$,Z){if($.length===0)return[];return[Z.styleTitle(D),...$,""]}groupItems(D,$,Z){let F=new Map;return D.forEach((Y)=>{let J=Z(Y);if(!F.has(J))F.set(J,[])}),$.forEach((Y)=>{let J=Z(Y);if(!F.has(J))F.set(J,[]);F.get(J).push(Y)}),F}formatHelp(D,$){let Z=$.padWidth(D,$),F=$.helpWidth??80;function Y(H,K){return $.formatItem(H,Z,K,$)}let J=[`${$.styleTitle("Usage:")} ${$.styleUsage($.commandUsage(D))}`,""],X=$.commandDescription(D);if(X.length>0)J=J.concat([$.boxWrap($.styleCommandDescription(X),F),""]);let Q=$.visibleArguments(D).map((H)=>{return Y($.styleArgumentTerm($.argumentTerm(H)),$.styleArgumentDescription($.argumentDescription(H)))});if(J=J.concat(this.formatItemList("Arguments:",Q,$)),this.groupItems(D.options,$.visibleOptions(D),(H)=>H.helpGroupHeading??"Options:").forEach((H,K)=>{let B=H.map((z)=>{return Y($.styleOptionTerm($.optionTerm(z)),$.styleOptionDescription($.optionDescription(z)))});J=J.concat(this.formatItemList(K,B,$))}),$.showGlobalOptions){let H=$.visibleGlobalOptions(D).map((K)=>{return Y($.styleOptionTerm($.optionTerm(K)),$.styleOptionDescription($.optionDescription(K)))});J=J.concat(this.formatItemList("Global Options:",H,$))}return this.groupItems(D.commands,$.visibleCommands(D),(H)=>H.helpGroup()||"Commands:").forEach((H,K)=>{let B=H.map((z)=>{return Y($.styleSubcommandTerm($.subcommandTerm(z)),$.styleSubcommandDescription($.subcommandDescription(z)))});J=J.concat(this.formatItemList(K,B,$))}),J.join(` `)}displayWidth(D){return VJ(D).length}styleTitle(D){return D}styleUsage(D){return D.split(" ").map(($)=>{if($==="[options]")return this.styleOptionText($);if($==="[command]")return this.styleSubcommandText($);if($[0]==="["||$[0]==="<")return this.styleArgumentText($);return this.styleCommandText($)}).join(" ")}styleCommandDescription(D){return this.styleDescriptionText(D)}styleOptionDescription(D){return this.styleDescriptionText(D)}styleSubcommandDescription(D){return this.styleDescriptionText(D)}styleArgumentDescription(D){return this.styleDescriptionText(D)}styleDescriptionText(D){return D}styleOptionTerm(D){return this.styleOptionText(D)}styleSubcommandTerm(D){return D.split(" ").map(($)=>{if($==="[options]")return this.styleOptionText($);if($[0]==="["||$[0]==="<")return this.styleArgumentText($);return this.styleSubcommandText($)}).join(" ")}styleArgumentTerm(D){return this.styleArgumentText(D)}styleOptionText(D){return D}styleArgumentText(D){return D}styleSubcommandText(D){return D}styleCommandText(D){return D}padWidth(D,$){return Math.max($.longestOptionTermLength(D,$),$.longestGlobalOptionTermLength(D,$),$.longestSubcommandTermLength(D,$),$.longestArgumentTermLength(D,$))}preformatted(D){return/\n[^\S\r\n]/.test(D)}formatItem(D,$,Z,F){let J=" ".repeat(2);if(!Z)return J+D;let X=D.padEnd($+D.length-F.displayWidth(D)),Q=2,G=(this.helpWidth??80)-$-Q-2,H;if(G<this.minWidthToWrap||F.preformatted(Z))H=Z;else H=F.boxWrap(Z,G).replace(/\n/g,` `+" ".repeat($+Q));return J+X+" ".repeat(Q)+H.replace(/\n/g,` ${J}`)}boxWrap(D,$){if($<this.minWidthToWrap)return D;let Z=D.split(/\r\n|\n/),F=/[\s]*[^\s]+/g,Y=[];return Z.forEach((J)=>{let X=J.match(F);if(X===null){Y.push("");return}let Q=[X.shift()],q=this.displayWidth(Q[0]);X.forEach((G)=>{let H=this.displayWidth(G);if(q+H<=$){Q.push(G),q+=H;return}Y.push(Q.join(""));let K=G.trimStart();Q=[K],q=this.displayWidth(K)}),Y.push(Q.join(""))}),Y.join(` `)}}function VJ(D){let $=/\x1b\[\d*(;\d*)*m/g;return D.replace($,"")}Rk.Help=BJ;Rk.stripColor=VJ});var s3=W((wk)=>{var{InvalidArgumentError:Ok}=q6();class LJ{constructor(D,$){this.flags=D,this.description=$||"",this.required=D.includes("<"),this.optional=D.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(D),this.mandatory=!1;let Z=jk(D);if(this.short=Z.shortFlag,this.long=Z.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(D,$){return this.defaultValue=D,this.defaultValueDescription=$,this}preset(D){return this.presetArg=D,this}conflicts(D){return this.conflictsWith=this.conflictsWith.concat(D),this}implies(D){let $=D;if(typeof D==="string")$={[D]:!0};return this.implied=Object.assign(this.implied||{},$),this}env(D){return this.envVar=D,this}argParser(D){return this.parseArg=D,this}makeOptionMandatory(D=!0){return this.mandatory=!!D,this}hideHelp(D=!0){return this.hidden=!!D,this}_concatValue(D,$){if($===this.defaultValue||!Array.isArray($))return[D];return $.concat(D)}choices(D){return this.argChoices=D.slice(),this.parseArg=($,Z)=>{if(!this.argChoices.includes($))throw new Ok(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue($,Z);return $},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return UJ(this.name().replace(/^no-/,""));return UJ(this.name())}helpGroup(D){return this.helpGroupHeading=D,this}is(D){return this.short===D||this.long===D}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class NJ{constructor(D){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,D.forEach(($)=>{if($.negate)this.negativeOptions.set($.attributeName(),$);else this.positiveOptions.set($.attributeName(),$)}),this.negativeOptions.forEach(($,Z)=>{if(this.positiveOptions.has(Z))this.dualOptions.add(Z)})}valueFromOption(D,$){let Z=$.attributeName();if(!this.dualOptions.has(Z))return!0;let F=this.negativeOptions.get(Z).presetArg,Y=F!==void 0?F:!1;return $.negate===(Y===D)}}function UJ(D){return D.split("-").reduce(($,Z)=>{return $+Z[0].toUpperCase()+Z.slice(1)})}function jk(D){let $,Z,F=/^-[^-]$/,Y=/^--[^-]/,J=D.split(/[ |,]+/).concat("guard");if(F.test(J[0]))$=J.shift();if(Y.test(J[0]))Z=J.shift();if(!$&&F.test(J[0]))$=J.shift();if(!$&&Y.test(J[0]))$=Z,Z=J.shift();if(J[0].startsWith("-")){let X=J[0],Q=`option creation failed due to '${X}' in option flags '${D}'`;if(/^-[^-][^-]/.test(X))throw new Error(`${Q} - a short flag is a single dash and a single character - either use a single dash and a single character (for a short flag) - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(F.test(X))throw new Error(`${Q} - too many short flags`);if(Y.test(X))throw new Error(`${Q} - too many long flags`);throw new Error(`${Q} - unrecognised flag format`)}if($===void 0&&Z===void 0)throw new Error(`option creation failed due to no flags found in '${D}'.`);return{shortFlag:$,longFlag:Z}}wk.Option=LJ;wk.DualOptions=NJ});var EJ=W((vk)=>{function yk(D,$){if(Math.abs(D.length-$.length)>3)return Math.max(D.length,$.length);let Z=[];for(let F=0;F<=D.length;F++)Z[F]=[F];for(let F=0;F<=$.length;F++)Z[0][F]=F;for(let F=1;F<=$.length;F++)for(let Y=1;Y<=D.length;Y++){let J=1;if(D[Y-1]===$[F-1])J=0;else J=1;if(Z[Y][F]=Math.min(Z[Y-1][F]+1,Z[Y][F-1]+1,Z[Y-1][F-1]+J),Y>1&&F>1&&D[Y-1]===$[F-2]&&D[Y-2]===$[F-1])Z[Y][F]=Math.min(Z[Y][F],Z[Y-2][F-2]+1)}return Z[D.length][$.length]}function xk(D,$){if(!$||$.length===0)return"";$=Array.from(new Set($));let Z=D.startsWith("--");if(Z)D=D.slice(2),$=$.map((X)=>X.slice(2));let F=[],Y=3,J=0.4;if($.forEach((X)=>{if(X.length<=1)return;let Q=yk(D,X),q=Math.max(D.length,X.length);if((q-Q)/q>J){if(Q<Y)Y=Q,F=[X];else if(Q===Y)F.push(X)}}),F.sort((X,Q)=>X.localeCompare(Q)),Z)F=F.map((X)=>`--${X}`);if(F.length>1)return` (Did you mean one of ${F.join(", ")}?)`;if(F.length===1)return` (Did you mean ${F[0]}?)`;return""}vk.suggestSimilar=xk});var TJ=W((lk)=>{var _k=S("node:events").EventEmitter,r3=S("node:child_process"),F0=S("node:path"),h9=S("node:fs"),F1=S("node:process"),{Argument:hk,humanReadableArgName:gk}=_9(),{CommanderError:e3}=q6(),{Help:bk,stripColor:uk}=t3(),{Option:IJ,DualOptions:mk}=s3(),{suggestSimilar:AJ}=EJ();class $7 extends _k{constructor(D){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=D||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:($)=>F1.stdout.write($),writeErr:($)=>F1.stderr.write($),outputError:($,Z)=>Z($),getOutHelpWidth:()=>F1.stdout.isTTY?F1.stdout.columns:void 0,getErrHelpWidth:()=>F1.stderr.isTTY?F1.stderr.columns:void 0,getOutHasColors:()=>D7()??(F1.stdout.isTTY&&F1.stdout.hasColors?.()),getErrHasColors:()=>D7()??(F1.stderr.isTTY&&F1.stderr.hasColors?.()),stripColor:($)=>uk($)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(D){return this._outputConfiguration=D._outputConfiguration,this._helpOption=D._helpOption,this._helpCommand=D._helpCommand,this._helpConfiguration=D._helpConfiguration,this._exitCallback=D._exitCallback,this._storeOptionsAsProperties=D._storeOptionsAsProperties,this._combineFlagAndOptionalValue=D._combineFlagAndOptionalValue,this._allowExcessArguments=D._allowExcessArguments,this._enablePositionalOptions=D._enablePositionalOptions,this._showHelpAfterError=D._showHelpAfterError,this._showSuggestionAfterError=D._showSuggestionAfterError,this}_getCommandAndAncestors(){let D=[];for(let $=this;$;$=$.parent)D.push($);return D}command(D,$,Z){let F=$,Y=Z;if(typeof F==="object"&&F!==null)Y=F,F=null;Y=Y||{};let[,J,X]=D.match(/([^ ]+) *(.*)/),Q=this.createCommand(J);if(F)Q.description(F),Q._executableHandler=!0;if(Y.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(Y.noHelp||Y.hidden),Q._executableFile=Y.executableFile||null,X)Q.arguments(X);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),F)return this;return Q}createCommand(D){return new $7(D)}createHelp(){return Object.assign(new bk,this.configureHelp())}configureHelp(D){if(D===void 0)return this._helpConfiguration;return this._helpConfiguration=D,this}configureOutput(D){if(D===void 0)return this._outputConfiguration;return this._outputConfiguration=Object.assign({},this._outputConfiguration,D),this}showHelpAfterError(D=!0){if(typeof D!=="string")D=!!D;return this._showHelpAfterError=D,this}showSuggestionAfterError(D=!0){return this._showSuggestionAfterError=!!D,this}addCommand(D,$){if(!D._name)throw new Error(`Command passed to .addCommand() must have a name - specify the name in Command constructor or using .name()`);if($=$||{},$.isDefault)this._defaultCommandName=D._name;if($.noHelp||$.hidden)D._hidden=!0;return this._registerCommand(D),D.parent=this,D._checkForBrokenPassThrough(),this}createArgument(D,$){return new hk(D,$)}argument(D,$,Z,F){let Y=this.createArgument(D,$);if(typeof Z==="function")Y.default(F).argParser(Z);else Y.default(Z);return this.addArgument(Y),this}arguments(D){return D.trim().split(/ +/).forEach(($)=>{this.argument($)}),this}addArgument(D){let $=this.registeredArguments.slice(-1)[0];if($&&$.variadic)throw new Error(`only the last argument can be variadic '${$.name()}'`);if(D.required&&D.defaultValue!==void 0&&D.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${D.name()}'`);return this.registeredArguments.push(D),this}helpCommand(D,$){if(typeof D==="boolean"){if(this._addImplicitHelpCommand=D,D&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let Z=D??"help [command]",[,F,Y]=Z.match(/([^ ]+) *(.*)/),J=$??"display help for command",X=this.createCommand(F);if(X.helpOption(!1),Y)X.arguments(Y);if(J)X.description(J);if(this._addImplicitHelpCommand=!0,this._helpCommand=X,D||$)this._initCommandGroup(X);return this}addHelpCommand(D,$){if(typeof D!=="object")return this.helpCommand(D,$),this;return this._addImplicitHelpCommand=!0,this._helpCommand=D,this._initCommandGroup(D),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(D,$){let Z=["preSubcommand","preAction","postAction"];if(!Z.includes(D))throw new Error(`Unexpected value for event passed to hook : '${D}'. Expecting one of '${Z.join("', '")}'`);if(this._lifeCycleHooks[D])this._lifeCycleHooks[D].push($);else this._lifeCycleHooks[D]=[$];return this}exitOverride(D){if(D)this._exitCallback=D;else this._exitCallback=($)=>{if($.code!=="commander.executeSubCommandAsync")throw $};return this}_exit(D,$,Z){if(this._exitCallback)this._exitCallback(new e3(D,$,Z));F1.exit(D)}action(D){let $=(Z)=>{let F=this.registeredArguments.length,Y=Z.slice(0,F);if(this._storeOptionsAsProperties)Y[F]=this;else Y[F]=this.opts();return Y.push(this),D.apply(this,Y)};return this._actionHandler=$,this}createOption(D,$){return new IJ(D,$)}_callParseArg(D,$,Z,F){try{return D.parseArg($,Z)}catch(Y){if(Y.code==="commander.invalidArgument"){let J=`${F} ${Y.message}`;this.error(J,{exitCode:Y.exitCode,code:Y.code})}throw Y}}_registerOption(D){let $=D.short&&this._findOption(D.short)||D.long&&this._findOption(D.long);if($){let Z=D.long&&this._findOption(D.long)?D.long:D.short;throw new Error(`Cannot add option '${D.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${Z}' - already used by option '${$.flags}'`)}this._initOptionGroup(D),this.options.push(D)}_registerCommand(D){let $=(F)=>{return[F.name()].concat(F.aliases())},Z=$(D).find((F)=>this._findCommand(F));if(Z){let F=$(this._findCommand(Z)).join("|"),Y=$(D).join("|");throw new Error(`cannot add command '${Y}' as already have command '${F}'`)}this._initCommandGroup(D),this.commands.push(D)}addOption(D){this._registerOption(D);let $=D.name(),Z=D.attributeName();if(D.negate){let Y=D.long.replace(/^--no-/,"--");if(!this._findOption(Y))this.setOptionValueWithSource(Z,D.defaultValue===void 0?!0:D.defaultValue,"default")}else if(D.defaultValue!==void 0)this.setOptionValueWithSource(Z,D.defaultValue,"default");let F=(Y,J,X)=>{if(Y==null&&D.presetArg!==void 0)Y=D.presetArg;let Q=this.getOptionValue(Z);if(Y!==null&&D.parseArg)Y=this._callParseArg(D,Y,Q,J);else if(Y!==null&&D.variadic)Y=D._concatValue(Y,Q);if(Y==null)if(D.negate)Y=!1;else if(D.isBoolean()||D.optional)Y=!0;else Y="";this.setOptionValueWithSource(Z,Y,X)};if(this.on("option:"+$,(Y)=>{let J=`error: option '${D.flags}' argument '${Y}' is invalid.`;F(Y,J,"cli")}),D.envVar)this.on("optionEnv:"+$,(Y)=>{let J=`error: option '${D.flags}' value '${Y}' from env '${D.envVar}' is invalid.`;F(Y,J,"env")});return this}_optionEx(D,$,Z,F,Y){if(typeof $==="object"&&$ instanceof IJ)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let J=this.createOption($,Z);if(J.makeOptionMandatory(!!D.mandatory),typeof F==="function")J.default(Y).argParser(F);else if(F instanceof RegExp){let X=F;F=(Q,q)=>{let G=X.exec(Q);return G?G[0]:q},J.default(Y).argParser(F)}else J.default(F);return this.addOption(J)}option(D,$,Z,F){return this._optionEx({},D,$,Z,F)}requiredOption(D,$,Z,F){return this._optionEx({mandatory:!0},D,$,Z,F)}combineFlagAndOptionalValue(D=!0){return this._combineFlagAndOptionalValue=!!D,this}allowUnknownOption(D=!0){return this._allowUnknownOption=!!D,this}allowExcessArguments(D=!0){return this._allowExcessArguments=!!D,this}enablePositionalOptions(D=!0){return this._enablePositionalOptions=!!D,this}passThroughOptions(D=!0){return this._passThroughOptions=!!D,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(D=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!D,this}getOptionValue(D){if(this._storeOptionsAsProperties)return this[D];return this._optionValues[D]}setOptionValue(D,$){return this.setOptionValueWithSource(D,$,void 0)}setOptionValueWithSource(D,$,Z){if(this._storeOptionsAsProperties)this[D]=$;else this._optionValues[D]=$;return this._optionValueSources[D]=Z,this}getOptionValueSource(D){return this._optionValueSources[D]}getOptionValueSourceWithGlobals(D){let $;return this._getCommandAndAncestors().forEach((Z)=>{if(Z.getOptionValueSource(D)!==void 0)$=Z.getOptionValueSource(D)}),$}_prepareUserArgs(D,$){if(D!==void 0&&!Array.isArray(D))throw new Error("first parameter to parse must be array or undefined");if($=$||{},D===void 0&&$.from===void 0){if(F1.versions?.electron)$.from="electron";let F=F1.execArgv??[];if(F.includes("-e")||F.includes("--eval")||F.includes("-p")||F.includes("--print"))$.from="eval"}if(D===void 0)D=F1.argv;this.rawArgs=D.slice();let Z;switch($.from){case void 0:case"node":this._scriptPath=D[1],Z=D.slice(2);break;case"electron":if(F1.defaultApp)this._scriptPath=D[1],Z=D.slice(2);else Z=D.slice(1);break;case"user":Z=D.slice(0);break;case"eval":Z=D.slice(1);break;default:throw new Error(`unexpected parse option { from: '${$.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",Z}parse(D,$){this._prepareForParse();let Z=this._prepareUserArgs(D,$);return this._parseCommand([],Z),this}async parseAsync(D,$){this._prepareForParse();let Z=this._prepareUserArgs(D,$);return await this._parseCommand([],Z),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true. - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(D,$,Z){if(h9.existsSync(D))return;let F=$?`searched for local subcommand relative to directory '${$}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",Y=`'${D}' does not exist - if '${Z}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead - if the default executable name is not suitable, use the executableFile option to supply a custom name or path - ${F}`;throw new Error(Y)}_executeSubCommand(D,$){$=$.slice();let Z=!1,F=[".js",".ts",".tsx",".mjs",".cjs"];function Y(G,H){let K=F0.resolve(G,H);if(h9.existsSync(K))return K;if(F.includes(F0.extname(H)))return;let B=F.find((z)=>h9.existsSync(`${K}${z}`));if(B)return`${K}${B}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let J=D._executableFile||`${this._name}-${D._name}`,X=this._executableDir||"";if(this._scriptPath){let G;try{G=h9.realpathSync(this._scriptPath)}catch{G=this._scriptPath}X=F0.resolve(F0.dirname(G),X)}if(X){let G=Y(X,J);if(!G&&!D._executableFile&&this._scriptPath){let H=F0.basename(this._scriptPath,F0.extname(this._scriptPath));if(H!==this._name)G=Y(X,`${H}-${D._name}`)}J=G||J}Z=F.includes(F0.extname(J));let Q;if(F1.platform!=="win32")if(Z)$.unshift(J),$=MJ(F1.execArgv).concat($),Q=r3.spawn(F1.argv[0],$,{stdio:"inherit"});else Q=r3.spawn(J,$,{stdio:"inherit"});else this._checkForMissingExecutable(J,X,D._name),$.unshift(J),$=MJ(F1.execArgv).concat($),Q=r3.spawn(F1.execPath,$,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((H)=>{F1.on(H,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(H)})});let q=this._exitCallback;Q.on("close",(G)=>{if(G=G??1,!q)F1.exit(G);else q(new e3(G,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(G)=>{if(G.code==="ENOENT")this._checkForMissingExecutable(J,X,D._name);else if(G.code==="EACCES")throw new Error(`'${J}' not executable`);if(!q)F1.exit(1);else{let H=new e3(1,"commander.executeSubCommandAsync","(error)");H.nestedError=G,q(H)}}),this.runningCommand=Q}_dispatchSubcommand(D,$,Z){let F=this._findCommand(D);if(!F)this.help({error:!0});F._prepareForParse();let Y;return Y=this._chainOrCallSubCommandHook(Y,F,"preSubcommand"),Y=this._chainOrCall(Y,()=>{if(F._executableHandler)this._executeSubCommand(F,$.concat(Z));else return F._parseCommand($,Z)}),Y}_dispatchHelpCommand(D){if(!D)this.help();let $=this._findCommand(D);if($&&!$._executableHandler)$.help();return this._dispatchSubcommand(D,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((D,$)=>{if(D.required&&this.args[$]==null)this.missingArgument(D.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let D=(Z,F,Y)=>{let J=F;if(F!==null&&Z.parseArg){let X=`error: command-argument value '${F}' is invalid for argument '${Z.name()}'.`;J=this._callParseArg(Z,F,Y,X)}return J};this._checkNumberOfArguments();let $=[];this.registeredArguments.forEach((Z,F)=>{let Y=Z.defaultValue;if(Z.variadic){if(F<this.args.length){if(Y=this.args.slice(F),Z.parseArg)Y=Y.reduce((J,X)=>{return D(Z,X,J)},Z.defaultValue)}else if(Y===void 0)Y=[]}else if(F<this.args.length){if(Y=this.args[F],Z.parseArg)Y=D(Z,Y,Z.defaultValue)}$[F]=Y}),this.processedArgs=$}_chainOrCall(D,$){if(D&&D.then&&typeof D.then==="function")return D.then(()=>$());return $()}_chainOrCallHooks(D,$){let Z=D,F=[];if(this._getCommandAndAncestors().reverse().filter((Y)=>Y._lifeCycleHooks[$]!==void 0).forEach((Y)=>{Y._lifeCycleHooks[$].forEach((J)=>{F.push({hookedCommand:Y,callback:J})})}),$==="postAction")F.reverse();return F.forEach((Y)=>{Z=this._chainOrCall(Z,()=>{return Y.callback(Y.hookedCommand,this)})}),Z}_chainOrCallSubCommandHook(D,$,Z){let F=D;if(this._lifeCycleHooks[Z]!==void 0)this._lifeCycleHooks[Z].forEach((Y)=>{F=this._chainOrCall(F,()=>{return Y(this,$)})});return F}_parseCommand(D,$){let Z=this.parseOptions($);if(this._parseOptionsEnv(),this._parseOptionsImplied(),D=D.concat(Z.operands),$=Z.unknown,this.args=D.concat($),D&&this._findCommand(D[0]))return this._dispatchSubcommand(D[0],D.slice(1),$);if(this._getHelpCommand()&&D[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(D[1]);if(this._defaultCommandName)return this._outputHelpIfRequested($),this._dispatchSubcommand(this._defaultCommandName,D,$);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(Z.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let F=()=>{if(Z.unknown.length>0)this.unknownOption(Z.unknown[0])},Y=`command:${this.name()}`;if(this._actionHandler){F(),this._processArguments();let J;if(J=this._chainOrCallHooks(J,"preAction"),J=this._chainOrCall(J,()=>this._actionHandler(this.processedArgs)),this.parent)J=this._chainOrCall(J,()=>{this.parent.emit(Y,D,$)});return J=this._chainOrCallHooks(J,"postAction"),J}if(this.parent&&this.parent.listenerCount(Y))F(),this._processArguments(),this.parent.emit(Y,D,$);else if(D.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",D,$);if(this.listenerCount("command:*"))this.emit("command:*",D,$);else if(this.commands.length)this.unknownCommand();else F(),this._processArguments()}else if(this.commands.length)F(),this.help({error:!0});else F(),this._processArguments()}_findCommand(D){if(!D)return;return this.commands.find(($)=>$._name===D||$._aliases.includes(D))}_findOption(D){return this.options.find(($)=>$.is(D))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((D)=>{D.options.forEach(($)=>{if($.mandatory&&D.getOptionValue($.attributeName())===void 0)D.missingMandatoryOptionValue($)})})}_checkForConflictingLocalOptions(){let D=this.options.filter((Z)=>{let F=Z.attributeName();if(this.getOptionValue(F)===void 0)return!1;return this.getOptionValueSource(F)!=="default"});D.filter((Z)=>Z.conflictsWith.length>0).forEach((Z)=>{let F=D.find((Y)=>Z.conflictsWith.includes(Y.attributeName()));if(F)this._conflictingOption(Z,F)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((D)=>{D._checkForConflictingLocalOptions()})}parseOptions(D){let $=[],Z=[],F=$,Y=D.slice();function J(q){return q.length>1&&q[0]==="-"}let X=(q)=>{if(!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(q))return!1;return!this._getCommandAndAncestors().some((G)=>G.options.map((H)=>H.short).some((H)=>/^-\d$/.test(H)))},Q=null;while(Y.length){let q=Y.shift();if(q==="--"){if(F===Z)F.push(q);F.push(...Y);break}if(Q&&(!J(q)||X(q))){this.emit(`option:${Q.name()}`,q);continue}if(Q=null,J(q)){let G=this._findOption(q);if(G){if(G.required){let H=Y.shift();if(H===void 0)this.optionMissingArgument(G);this.emit(`option:${G.name()}`,H)}else if(G.optional){let H=null;if(Y.length>0&&(!J(Y[0])||X(Y[0])))H=Y.shift();this.emit(`option:${G.name()}`,H)}else this.emit(`option:${G.name()}`);Q=G.variadic?G:null;continue}}if(q.length>2&&q[0]==="-"&&q[1]!=="-"){let G=this._findOption(`-${q[1]}`);if(G){if(G.required||G.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${G.name()}`,q.slice(2));else this.emit(`option:${G.name()}`),Y.unshift(`-${q.slice(2)}`);continue}}if(/^--[^=]+=/.test(q)){let G=q.indexOf("="),H=this._findOption(q.slice(0,G));if(H&&(H.required||H.optional)){this.emit(`option:${H.name()}`,q.slice(G+1));continue}}if(F===$&&J(q)&&!(this.commands.length===0&&X(q)))F=Z;if((this._enablePositionalOptions||this._passThroughOptions)&&$.length===0&&Z.length===0){if(this._findCommand(q)){if($.push(q),Y.length>0)Z.push(...Y);break}else if(this._getHelpCommand()&&q===this._getHelpCommand().name()){if($.push(q),Y.length>0)$.push(...Y);break}else if(this._defaultCommandName){if(Z.push(q),Y.length>0)Z.push(...Y);break}}if(this._passThroughOptions){if(F.push(q),Y.length>0)F.push(...Y);break}F.push(q)}return{operands:$,unknown:Z}}opts(){if(this._storeOptionsAsProperties){let D={},$=this.options.length;for(let Z=0;Z<$;Z++){let F=this.options[Z].attributeName();D[F]=F===this._versionOptionName?this._version:this[F]}return D}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((D,$)=>Object.assign(D,$.opts()),{})}error(D,$){if(this._outputConfiguration.outputError(`${D} `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError} `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(` `),this.outputHelp({error:!0});let Z=$||{},F=Z.exitCode||1,Y=Z.code||"commander.error";this._exit(F,Y,D)}_parseOptionsEnv(){this.options.forEach((D)=>{if(D.envVar&&D.envVar in F1.env){let $=D.attributeName();if(this.getOptionValue($)===void 0||["default","config","env"].includes(this.getOptionValueSource($)))if(D.required||D.optional)this.emit(`optionEnv:${D.name()}`,F1.env[D.envVar]);else this.emit(`optionEnv:${D.name()}`)}})}_parseOptionsImplied(){let D=new mk(this.options),$=(Z)=>{return this.getOptionValue(Z)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(Z))};this.options.filter((Z)=>Z.implied!==void 0&&$(Z.attributeName())&&D.valueFromOption(this.getOptionValue(Z.attributeName()),Z)).forEach((Z)=>{Object.keys(Z.implied).filter((F)=>!$(F)).forEach((F)=>{this.setOptionValueWithSource(F,Z.implied[F],"implied")})})}missingArgument(D){let $=`error: missing required argument '${D}'`;this.error($,{code:"commander.missingArgument"})}optionMissingArgument(D){let $=`error: option '${D.flags}' argument missing`;this.error($,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(D){let $=`error: required option '${D.flags}' not specified`;this.error($,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(D,$){let Z=(J)=>{let X=J.attributeName(),Q=this.getOptionValue(X),q=this.options.find((H)=>H.negate&&X===H.attributeName()),G=this.options.find((H)=>!H.negate&&X===H.attributeName());if(q&&(q.presetArg===void 0&&Q===!1||q.presetArg!==void 0&&Q===q.presetArg))return q;return G||J},F=(J)=>{let X=Z(J),Q=X.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${X.envVar}'`;return`option '${X.flags}'`},Y=`error: ${F(D)} cannot be used with ${F($)}`;this.error(Y,{code:"commander.conflictingOption"})}unknownOption(D){if(this._allowUnknownOption)return;let $="";if(D.startsWith("--")&&this._showSuggestionAfterError){let F=[],Y=this;do{let J=Y.createHelp().visibleOptions(Y).filter((X)=>X.long).map((X)=>X.long);F=F.concat(J),Y=Y.parent}while(Y&&!Y._enablePositionalOptions);$=AJ(D,F)}let Z=`error: unknown option '${D}'${$}`;this.error(Z,{code:"commander.unknownOption"})}_excessArguments(D){if(this._allowExcessArguments)return;let $=this.registeredArguments.length,Z=$===1?"":"s",Y=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${$} argument${Z} but got ${D.length}.`;this.error(Y,{code:"commander.excessArguments"})}unknownCommand(){let D=this.args[0],$="";if(this._showSuggestionAfterError){let F=[];this.createHelp().visibleCommands(this).forEach((Y)=>{if(F.push(Y.name()),Y.alias())F.push(Y.alias())}),$=AJ(D,F)}let Z=`error: unknown command '${D}'${$}`;this.error(Z,{code:"commander.unknownCommand"})}version(D,$,Z){if(D===void 0)return this._version;this._version=D,$=$||"-V, --version",Z=Z||"output the version number";let F=this.createOption($,Z);return this._versionOptionName=F.attributeName(),this._registerOption(F),this.on("option:"+F.name(),()=>{this._outputConfiguration.writeOut(`${D} `),this._exit(0,"commander.version",D)}),this}description(D,$){if(D===void 0&&$===void 0)return this._description;if(this._description=D,$)this._argsDescription=$;return this}summary(D){if(D===void 0)return this._summary;return this._summary=D,this}alias(D){if(D===void 0)return this._aliases[0];let $=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)$=this.commands[this.commands.length-1];if(D===$._name)throw new Error("Command alias can't be the same as its name");let Z=this.parent?._findCommand(D);if(Z){let F=[Z.name()].concat(Z.aliases()).join("|");throw new Error(`cannot add alias '${D}' to command '${this.name()}' as already have command '${F}'`)}return $._aliases.push(D),this}aliases(D){if(D===void 0)return this._aliases;return D.forEach(($)=>this.alias($)),this}usage(D){if(D===void 0){if(this._usage)return this._usage;let $=this.registeredArguments.map((Z)=>{return gk(Z)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?$:[]).join(" ")}return this._usage=D,this}name(D){if(D===void 0)return this._name;return this._name=D,this}helpGroup(D){if(D===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=D,this}commandsGroup(D){if(D===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=D,this}optionsGroup(D){if(D===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=D,this}_initOptionGroup(D){if(this._defaultOptionGroup&&!D.helpGroupHeading)D.helpGroup(this._defaultOptionGroup)}_initCommandGroup(D){if(this._defaultCommandGroup&&!D.helpGroup())D.helpGroup(this._defaultCommandGroup)}nameFromFilename(D){return this._name=F0.basename(D,F0.extname(D)),this}executableDir(D){if(D===void 0)return this._executableDir;return this._executableDir=D,this}helpInformation(D){let $=this.createHelp(),Z=this._getOutputContext(D);$.prepareContext({error:Z.error,helpWidth:Z.helpWidth,outputHasColors:Z.hasColors});let F=$.formatHelp(this,$);if(Z.hasColors)return F;return this._outputConfiguration.stripColor(F)}_getOutputContext(D){D=D||{};let $=!!D.error,Z,F,Y;if($)Z=(X)=>this._outputConfiguration.writeErr(X),F=this._outputConfiguration.getErrHasColors(),Y=this._outputConfiguration.getErrHelpWidth();else Z=(X)=>this._outputConfiguration.writeOut(X),F=this._outputConfiguration.getOutHasColors(),Y=this._outputConfiguration.getOutHelpWidth();return{error:$,write:(X)=>{if(!F)X=this._outputConfiguration.stripColor(X);return Z(X)},hasColors:F,helpWidth:Y}}outputHelp(D){let $;if(typeof D==="function")$=D,D=void 0;let Z=this._getOutputContext(D),F={error:Z.error,write:Z.write,command:this};this._getCommandAndAncestors().reverse().forEach((J)=>J.emit("beforeAllHelp",F)),this.emit("beforeHelp",F);let Y=this.helpInformation({error:Z.error});if($){if(Y=$(Y),typeof Y!=="string"&&!Buffer.isBuffer(Y))throw new Error("outputHelp callback must return a string or a Buffer")}if(Z.write(Y),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",F),this._getCommandAndAncestors().forEach((J)=>J.emit("afterAllHelp",F))}helpOption(D,$){if(typeof D==="boolean"){if(D){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(D??"-h, --help",$??"display help for command"),D||$)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(D){return this._helpOption=D,this._initOptionGroup(D),this}help(D){this.outputHelp(D);let $=Number(F1.exitCode??0);if($===0&&D&&typeof D!=="function"&&D.error)$=1;this._exit($,"commander.help","(outputHelp)")}addHelpText(D,$){let Z=["beforeAll","before","after","afterAll"];if(!Z.includes(D))throw new Error(`Unexpected value for position to addHelpText. Expecting one of '${Z.join("', '")}'`);let F=`${D}Help`;return this.on(F,(Y)=>{let J;if(typeof $==="function")J=$({error:Y.error,command:Y.command});else J=$;if(J)Y.write(`${J} `)}),this}_outputHelpIfRequested(D){let $=this._getHelpOption();if($&&D.find((F)=>$.is(F)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function MJ(D){return D.map(($)=>{if(!$.startsWith("--inspect"))return $;let Z,F="127.0.0.1",Y="9229",J;if((J=$.match(/^(--inspect(-brk)?)$/))!==null)Z=J[1];else if((J=$.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(Z=J[1],/^\d+$/.test(J[3]))Y=J[3];else F=J[3];else if((J=$.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)Z=J[1],F=J[3],Y=J[4];if(Z&&Y!=="0")return`${Z}=${F}:${parseInt(Y)+1}`;return $})}function D7(){if(F1.env.NO_COLOR||F1.env.FORCE_COLOR==="0"||F1.env.FORCE_COLOR==="false")return!1;if(F1.env.FORCE_COLOR||F1.env.CLICOLOR_FORCE!==void 0)return!0;return}lk.Command=$7;lk.useColor=D7});var OJ=W((ik)=>{var{Argument:RJ}=_9(),{Command:Z7}=TJ(),{CommanderError:ck,InvalidArgumentError:PJ}=q6(),{Help:nk}=t3(),{Option:CJ}=s3();ik.program=new Z7;ik.createCommand=(D)=>new Z7(D);ik.createOption=(D,$)=>new CJ(D,$);ik.createArgument=(D,$)=>new RJ(D,$);ik.Command=Z7;ik.Option=CJ;ik.Argument=RJ;ik.Help=nk;ik.CommanderError=ck;ik.InvalidArgumentError=PJ;ik.InvalidOptionArgumentError=PJ});var K6=W((FX)=>{Object.defineProperty(FX,"__esModule",{value:!0});FX.regexpCode=FX.getEsmExportName=FX.getProperty=FX.safeStringify=FX.stringify=FX.strConcat=FX.addCodeArg=FX.str=FX._=FX.nil=FX._Code=FX.Name=FX.IDENTIFIER=FX._CodeOrName=void 0;class m9{}FX._CodeOrName=m9;FX.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class m8 extends m9{constructor(D){super();if(!FX.IDENTIFIER.test(D))throw new Error("CodeGen: name must be a valid identifier");this.str=D}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}FX.Name=m8;class CD extends m9{constructor(D){super();this._items=typeof D==="string"?[D]:D}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let D=this._items[0];return D===""||D==='""'}get str(){var D;return(D=this._str)!==null&&D!==void 0?D:this._str=this._items.reduce(($,Z)=>`${$}${Z}`,"")}get names(){var D;return(D=this._names)!==null&&D!==void 0?D:this._names=this._items.reduce(($,Z)=>{if(Z instanceof m8)$[Z.str]=($[Z.str]||0)+1;return $},{})}}FX._Code=CD;FX.nil=new CD("");function $X(D,...$){let Z=[D[0]],F=0;while(F<$.length)U7(Z,$[F]),Z.push(D[++F]);return new CD(Z)}FX._=$X;var V7=new CD("+");function ZX(D,...$){let Z=[W6(D[0])],F=0;while(F<$.length)Z.push(V7),U7(Z,$[F]),Z.push(V7,W6(D[++F]));return zS(Z),new CD(Z)}FX.str=ZX;function U7(D,$){if($ instanceof CD)D.push(...$._items);else if($ instanceof m8)D.push($);else D.push(US($))}FX.addCodeArg=U7;function zS(D){let $=1;while($<D.length-1){if(D[$]===V7){let Z=BS(D[$-1],D[$+1]);if(Z!==void 0){D.splice($-1,3,Z);continue}D[$++]="+"}$++}}function BS(D,$){if($==='""')return D;if(D==='""')return $;if(typeof D=="string"){if($ instanceof m8||D[D.length-1]!=='"')return;if(typeof $!="string")return`${D.slice(0,-1)}${$}"`;if($[0]==='"')return D.slice(0,-1)+$.slice(1);return}if(typeof $=="string"&&$[0]==='"'&&!(D instanceof m8))return`"${D}${$.slice(1)}`;return}function VS(D,$){return $.emptyStr()?D:D.emptyStr()?$:ZX`${D}${$}`}FX.strConcat=VS;function US(D){return typeof D=="number"||typeof D=="boolean"||D===null?D:W6(Array.isArray(D)?D.join(","):D)}function LS(D){return new CD(W6(D))}FX.stringify=LS;function W6(D){return JSON.stringify(D).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}FX.safeStringify=W6;function NS(D){return typeof D=="string"&&FX.IDENTIFIER.test(D)?new CD(`.${D}`):$X`[${D}]`}FX.getProperty=NS;function ES(D){if(typeof D=="string"&&FX.IDENTIFIER.test(D))return new CD(`${D}`);throw new Error(`CodeGen: invalid export name: ${D}, use explicit $id name mapping`)}FX.getEsmExportName=ES;function IS(D){return new CD(D.toString())}FX.regexpCode=IS});var I7=W((QX)=>{Object.defineProperty(QX,"__esModule",{value:!0});QX.ValueScope=QX.ValueScopeName=QX.Scope=QX.varKinds=QX.UsedValueState=void 0;var s1=K6();class JX extends Error{constructor(D){super(`CodeGen: "code" for ${D} not defined`);this.value=D.value}}var d9;(function(D){D[D.Started=0]="Started",D[D.Completed=1]="Completed"})(d9||(QX.UsedValueState=d9={}));QX.varKinds={const:new s1.Name("const"),let:new s1.Name("let"),var:new s1.Name("var")};class N7{constructor({prefixes:D,parent:$}={}){this._names={},this._prefixes=D,this._parent=$}toName(D){return D instanceof s1.Name?D:this.name(D)}name(D){return new s1.Name(this._newName(D))}_newName(D){let $=this._names[D]||this._nameGroup(D);return`${D}${$.index++}`}_nameGroup(D){var $,Z;if(((Z=($=this._parent)===null||$===void 0?void 0:$._prefixes)===null||Z===void 0?void 0:Z.has(D))||this._prefixes&&!this._prefixes.has(D))throw new Error(`CodeGen: prefix "${D}" is not allowed in this scope`);return this._names[D]={prefix:D,index:0}}}QX.Scope=N7;class E7 extends s1.Name{constructor(D,$){super($);this.prefix=D}setValue(D,{property:$,itemIndex:Z}){this.value=D,this.scopePath=s1._`.${new s1.Name($)}[${Z}]`}}QX.ValueScopeName=E7;var xS=s1._`\n`;class XX extends N7{constructor(D){super(D);this._values={},this._scope=D.scope,this.opts={...D,_n:D.lines?xS:s1.nil}}get(){return this._scope}name(D){return new E7(D,this._newName(D))}value(D,$){var Z;if($.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let F=this.toName(D),{prefix:Y}=F,J=(Z=$.key)!==null&&Z!==void 0?Z:$.ref,X=this._values[Y];if(X){let G=X.get(J);if(G)return G}else X=this._values[Y]=new Map;X.set(J,F);let Q=this._scope[Y]||(this._scope[Y]=[]),q=Q.length;return Q[q]=$.ref,F.setValue($,{property:Y,itemIndex:q}),F}getValue(D,$){let Z=this._values[D];if(!Z)return;return Z.get($)}scopeRefs(D,$=this._values){return this._reduceValues($,(Z)=>{if(Z.scopePath===void 0)throw new Error(`CodeGen: name "${Z}" has no value`);return s1._`${D}${Z.scopePath}`})}scopeCode(D=this._values,$,Z){return this._reduceValues(D,(F)=>{if(F.value===void 0)throw new Error(`CodeGen: name "${F}" has no value`);return F.value.code},$,Z)}_reduceValues(D,$,Z={},F){let Y=s1.nil;for(let J in D){let X=D[J];if(!X)continue;let Q=Z[J]=Z[J]||new Map;X.forEach((q)=>{if(Q.has(q))return;Q.set(q,d9.Started);let G=$(q);if(G){let H=this.opts.es5?QX.varKinds.var:QX.varKinds.const;Y=s1._`${Y}${H} ${q} = ${G};${this.opts._n}`}else if(G=F===null||F===void 0?void 0:F(q))Y=s1._`${Y}${G}${this.opts._n}`;else throw new JX(q);Q.set(q,d9.Completed)})}return Y}}QX.ValueScope=XX});var b=W((r1)=>{Object.defineProperty(r1,"__esModule",{value:!0});r1.or=r1.and=r1.not=r1.CodeGen=r1.operators=r1.varKinds=r1.ValueScopeName=r1.ValueScope=r1.Scope=r1.Name=r1.regexpCode=r1.stringify=r1.getProperty=r1.nil=r1.strConcat=r1.str=r1._=void 0;var o=K6(),OD=I7(),M0=K6();Object.defineProperty(r1,"_",{enumerable:!0,get:function(){return M0._}});Object.defineProperty(r1,"str",{enumerable:!0,get:function(){return M0.str}});Object.defineProperty(r1,"strConcat",{enumerable:!0,get:function(){return M0.strConcat}});Object.defineProperty(r1,"nil",{enumerable:!0,get:function(){return M0.nil}});Object.defineProperty(r1,"getProperty",{enumerable:!0,get:function(){return M0.getProperty}});Object.defineProperty(r1,"stringify",{enumerable:!0,get:function(){return M0.stringify}});Object.defineProperty(r1,"regexpCode",{enumerable:!0,get:function(){return M0.regexpCode}});Object.defineProperty(r1,"Name",{enumerable:!0,get:function(){return M0.Name}});var o9=I7();Object.defineProperty(r1,"Scope",{enumerable:!0,get:function(){return o9.Scope}});Object.defineProperty(r1,"ValueScope",{enumerable:!0,get:function(){return o9.ValueScope}});Object.defineProperty(r1,"ValueScopeName",{enumerable:!0,get:function(){return o9.ValueScopeName}});Object.defineProperty(r1,"varKinds",{enumerable:!0,get:function(){return o9.varKinds}});r1.operators={GT:new o._Code(">"),GTE:new o._Code(">="),LT:new o._Code("<"),LTE:new o._Code("<="),EQ:new o._Code("==="),NEQ:new o._Code("!=="),NOT:new o._Code("!"),OR:new o._Code("||"),AND:new o._Code("&&"),ADD:new o._Code("+")};class T0{optimizeNodes(){return this}optimizeNames(D,$){return this}}class GX extends T0{constructor(D,$,Z){super();this.varKind=D,this.name=$,this.rhs=Z}render({es5:D,_n:$}){let Z=D?OD.varKinds.var:this.varKind,F=this.rhs===void 0?"":` = ${this.rhs}`;return`${Z} ${this.name}${F};`+$}optimizeNames(D,$){if(!D[this.name.str])return;if(this.rhs)this.rhs=d8(this.rhs,D,$);return this}get names(){return this.rhs instanceof o._CodeOrName?this.rhs.names:{}}}class T7 extends T0{constructor(D,$,Z){super();this.lhs=D,this.rhs=$,this.sideEffects=Z}render({_n:D}){return`${this.lhs} = ${this.rhs};`+D}optimizeNames(D,$){if(this.lhs instanceof o.Name&&!D[this.lhs.str]&&!this.sideEffects)return;return this.rhs=d8(this.rhs,D,$),this}get names(){let D=this.lhs instanceof o.Name?{}:{...this.lhs.names};return a9(D,this.rhs)}}class HX extends T7{constructor(D,$,Z,F){super(D,Z,F);this.op=$}render({_n:D}){return`${this.lhs} ${this.op}= ${this.rhs};`+D}}class WX extends T0{constructor(D){super();this.label=D,this.names={}}render({_n:D}){return`${this.label}:`+D}}class KX extends T0{constructor(D){super();this.label=D,this.names={}}render({_n:D}){return`break${this.label?` ${this.label}`:""};`+D}}class zX extends T0{constructor(D){super();this.error=D}render({_n:D}){return`throw ${this.error};`+D}get names(){return this.error.names}}class BX extends T0{constructor(D){super();this.code=D}render({_n:D}){return`${this.code};`+D}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(D,$){return this.code=d8(this.code,D,$),this}get names(){return this.code instanceof o._CodeOrName?this.code.names:{}}}class t9 extends T0{constructor(D=[]){super();this.nodes=D}render(D){return this.nodes.redu