@task-handoff/server 0.0.9-alpha.5 → 0.0.10-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server-cli.js +1 -1
- package/package.json +4 -4
package/dist/server-cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("node:events"),e=require("node:child_process"),r=require("node:path"),n=require("node:fs"),i=require("node:process"),s=require("node:http");function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var a,l,h={},c={},u={};function p(){if(a)return u;a=1;class t extends Error{constructor(t,e,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}}return u.CommanderError=t,u.InvalidArgumentError=class extends t{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},u}function m(){if(l)return c;l=1;const{InvalidArgumentError:t}=p();return c.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.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?(e.push(t),e):[t]}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,r)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(e,r):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},c.humanReadableArgName=function(t){const e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"},c}var d,f={},g={};function E(){if(d)return g;d=1;const{humanReadableArgName:t}=m();function e(t){return t.replace(/\x1b\[\d*(;\d*)*m/g,"")}return g.Help=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){const e=t.commands.filter(t=>!t._hidden),r=t._getHelpCommand();return r&&!r._hidden&&e.push(r),this.sortSubcommands&&e.sort((t,e)=>t.name().localeCompare(e.name())),e}compareOptions(t,e){const r=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return r(t).localeCompare(r(e))}visibleOptions(t){const e=t.options.filter(t=>!t.hidden),r=t._getHelpOption();if(r&&!r.hidden){const n=r.short&&t._findOption(r.short),i=r.long&&t._findOption(r.long);n||i?r.long&&!i?e.push(t.createOption(r.long,r.description)):r.short&&!n&&e.push(t.createOption(r.short,r.description)):e.push(r)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const e=[];for(let r=t.parent;r;r=r.parent){const t=r.options.filter(t=>!t.hidden);e.push(...t)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(t=>t.description)?t.registeredArguments:[]}subcommandTerm(e){const r=e.registeredArguments.map(e=>t(e)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((t,r)=>Math.max(t,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(r)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((t,r)=>Math.max(t,this.displayWidth(e.styleOptionTerm(e.optionTerm(r)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((t,r)=>Math.max(t,this.displayWidth(e.styleOptionTerm(e.optionTerm(r)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((t,r)=>Math.max(t,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(r)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let r="";for(let e=t.parent;e;e=e.parent)r=e.name()+" "+r;return r+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue&&(t.required||t.optional||t.isBoolean()&&"boolean"==typeof t.defaultValue)&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),void 0!==t.presetArg&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),void 0!==t.envVar&&e.push(`env: ${t.envVar}`),e.length>0){const r=`(${e.join(", ")})`;return t.description?`${t.description} ${r}`:r}return 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 r=`(${e.join(", ")})`;return t.description?`${t.description} ${r}`:r}return t.description}formatItemList(t,e,r){return 0===e.length?[]:[r.styleTitle(t),...e,""]}groupItems(t,e,r){const n=new Map;return t.forEach(t=>{const e=r(t);n.has(e)||n.set(e,[])}),e.forEach(t=>{const e=r(t);n.has(e)||n.set(e,[]),n.get(e).push(t)}),n}formatHelp(t,e){const r=e.padWidth(t,e),n=e.helpWidth??80;function i(t,n){return e.formatItem(t,r,n,e)}let s=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""];const o=e.commandDescription(t);o.length>0&&(s=s.concat([e.boxWrap(e.styleCommandDescription(o),n),""]));const a=e.visibleArguments(t).map(t=>i(e.styleArgumentTerm(e.argumentTerm(t)),e.styleArgumentDescription(e.argumentDescription(t))));s=s.concat(this.formatItemList("Arguments:",a,e));const l=this.groupItems(t.options,e.visibleOptions(t),t=>t.helpGroupHeading??"Options:");if(l.forEach((t,r)=>{const n=t.map(t=>i(e.styleOptionTerm(e.optionTerm(t)),e.styleOptionDescription(e.optionDescription(t))));s=s.concat(this.formatItemList(r,n,e))}),e.showGlobalOptions){const r=e.visibleGlobalOptions(t).map(t=>i(e.styleOptionTerm(e.optionTerm(t)),e.styleOptionDescription(e.optionDescription(t))));s=s.concat(this.formatItemList("Global Options:",r,e))}return this.groupItems(t.commands,e.visibleCommands(t),t=>t.helpGroup()||"Commands:").forEach((t,r)=>{const n=t.map(t=>i(e.styleSubcommandTerm(e.subcommandTerm(t)),e.styleSubcommandDescription(e.subcommandDescription(t))));s=s.concat(this.formatItemList(r,n,e))}),s.join("\n")}displayWidth(t){return e(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(t=>"[options]"===t?this.styleOptionText(t):"[command]"===t?this.styleSubcommandText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(t=>"[options]"===t?this.styleOptionText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,e,r,n){const i=" ".repeat(2);if(!r)return i+t;const s=t.padEnd(e+t.length-n.displayWidth(t)),o=(this.helpWidth??80)-e-2-2;let a;return a=o<this.minWidthToWrap||n.preformatted(r)?r:n.boxWrap(r,o).replace(/\n/g,"\n"+" ".repeat(e+2)),i+s+" ".repeat(2)+a.replace(/\n/g,`\n${i}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;const r=t.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,i=[];return r.forEach(t=>{const r=t.match(n);if(null===r)return void i.push("");let s=[r.shift()],o=this.displayWidth(s[0]);r.forEach(t=>{const r=this.displayWidth(t);if(o+r<=e)return s.push(t),void(o+=r);i.push(s.join(""));const n=t.trimStart();s=[n],o=this.displayWidth(n)}),i.push(s.join(""))}),i.join("\n")}},g.stripColor=e,g}var _,v={};function O(){if(_)return v;_=1;const{InvalidArgumentError:t}=p();function e(t){return t.split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}return v.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 r=function(t){let e,r;const n=/^-[^-]$/,i=/^--[^-]/,s=t.split(/[ |,]+/).concat("guard");if(n.test(s[0])&&(e=s.shift()),i.test(s[0])&&(r=s.shift()),!e&&n.test(s[0])&&(e=s.shift()),!e&&i.test(s[0])&&(e=r,r=s.shift()),s[0].startsWith("-")){const e=s[0],r=`option creation failed due to '${e}' in option flags '${t}'`;if(/^-[^-][^-]/.test(e))throw new Error(`${r}\n- a short flag is a single dash and a single character\n - either use a single dash and a single character (for a short flag)\n - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(n.test(e))throw new Error(`${r}\n- too many short flags`);if(i.test(e))throw new Error(`${r}\n- too many long flags`);throw new Error(`${r}\n- unrecognised flag format`)}if(void 0===e&&void 0===r)throw new Error(`option creation failed due to no flags found in '${t}'.`);return{shortFlag:e,longFlag:r}}(t);this.short=r.shortFlag,this.long=r.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let e=t;return"string"==typeof t&&(e={[t]:!0}),this.implied=Object.assign(this.implied||{},e),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_collectValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?(e.push(t),e):[t]}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,r)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(e,r):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?e(this.name().replace(/^no-/,"")):e(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},v.DualOptions=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,e)=>{this.positiveOptions.has(e)&&this.dualOptions.add(e)})}valueFromOption(t,e){const r=e.attributeName();if(!this.dualOptions.has(r))return!0;const n=this.negativeOptions.get(r).presetArg,i=void 0!==n&&n;return e.negate===(i===t)}},v}var A,$,C,w={};function b(){return A||(A=1,w.suggestSimilar=function(t,e){if(!e||0===e.length)return"";e=Array.from(new Set(e));const r=t.startsWith("--");r&&(t=t.slice(2),e=e.map(t=>t.slice(2)));let n=[],i=3;return e.forEach(e=>{if(e.length<=1)return;const r=function(t,e){if(Math.abs(t.length-e.length)>3)return Math.max(t.length,e.length);const r=[];for(let e=0;e<=t.length;e++)r[e]=[e];for(let t=0;t<=e.length;t++)r[0][t]=t;for(let n=1;n<=e.length;n++)for(let i=1;i<=t.length;i++){let s=1;s=t[i-1]===e[n-1]?0:1,r[i][n]=Math.min(r[i-1][n]+1,r[i][n-1]+1,r[i-1][n-1]+s),i>1&&n>1&&t[i-1]===e[n-2]&&t[i-2]===e[n-1]&&(r[i][n]=Math.min(r[i][n],r[i-2][n-2]+1))}return r[t.length][e.length]}(t,e),s=Math.max(t.length,e.length);(s-r)/s>.4&&(r<i?(i=r,n=[e]):r===i&&n.push(e))}),n.sort((t,e)=>t.localeCompare(e)),r&&(n=n.map(t=>`--${t}`)),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""}),w}var I=function(){if(C)return h;C=1;const{Argument:s}=m(),{Command:o}=function(){if($)return f;$=1;const s=t.EventEmitter,o=e,a=r,l=n,h=i,{Argument:c,humanReadableArgName:u}=m(),{CommanderError:d}=p(),{Help:g,stripColor:_}=E(),{Option:v,DualOptions:A}=O(),{suggestSimilar:C}=b();class w extends s{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>h.stdout.write(t),writeErr:t=>h.stderr.write(t),outputError:(t,e)=>e(t),getOutHelpWidth:()=>h.stdout.isTTY?h.stdout.columns:void 0,getErrHelpWidth:()=>h.stderr.isTTY?h.stderr.columns:void 0,getOutHasColors:()=>y()??(h.stdout.isTTY&&h.stdout.hasColors?.()),getErrHasColors:()=>y()??(h.stderr.isTTY&&h.stderr.hasColors?.()),stripColor:t=>_(t)},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(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){const t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,r){let n=e,i=r;"object"==typeof n&&null!==n&&(i=n,n=null),i=i||{};const[,s,o]=t.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return n&&(a.description(n),a._executableHandler=!0),i.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!i.noHelp&&!i.hidden),a._executableFile=i.executableFile||null,o&&a.arguments(o),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(t){return new w(t)}createHelp(){return Object.assign(new g,this.configureHelp())}configureHelp(t){return void 0===t?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return void 0===t?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...t},this)}showHelpAfterError(t=!0){return"string"!=typeof t&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(e=e||{}).isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new c(t,e)}argument(t,e,r,n){const i=this.createArgument(t,e);return"function"==typeof r?i.default(n).argParser(r):i.default(r),this.addArgument(i),this}arguments(t){return t.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(t){const e=this.registeredArguments.slice(-1)[0];if(e?.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&void 0!==t.defaultValue&&void 0===t.parseArg)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,e){if("boolean"==typeof t)return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;const r=t??"help [command]",[,n,i]=r.match(/([^ ]+) *(.*)/),s=e??"display help for command",o=this.createCommand(n);return o.helpOption(!1),i&&o.arguments(i),s&&o.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=o,(t||e)&&this._initCommandGroup(o),this}addHelpCommand(t,e){return"object"!=typeof t?(this.helpCommand(t,e),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(void 0===this._helpCommand&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,e){const r=["preSubcommand","preAction","postAction"];if(!r.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${r.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,r){this._exitCallback&&this._exitCallback(new d(t,e,r)),h.exit(t)}action(t){return this._actionHandler=e=>{const r=this.registeredArguments.length,n=e.slice(0,r);return this._storeOptionsAsProperties?n[r]=this:n[r]=this.opts(),n.push(this),t.apply(this,n)},this}createOption(t,e){return new v(t,e)}_callParseArg(t,e,r,n){try{return t.parseArg(e,r)}catch(t){if("commander.invalidArgument"===t.code){const e=`${n} ${t.message}`;this.error(e,{exitCode:t.exitCode,code:t.code})}throw t}}_registerOption(t){const e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){const r=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'\n- already used by option '${e.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){const e=t=>[t.name()].concat(t.aliases()),r=e(t).find(t=>this._findCommand(t));if(r){const n=e(this._findCommand(r)).join("|"),i=e(t).join("|");throw new Error(`cannot add command '${i}' as already have command '${n}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);const e=t.name(),r=t.attributeName();if(t.negate){const e=t.long.replace(/^--no-/,"--");this._findOption(e)||this.setOptionValueWithSource(r,void 0===t.defaultValue||t.defaultValue,"default")}else void 0!==t.defaultValue&&this.setOptionValueWithSource(r,t.defaultValue,"default");const n=(e,n,i)=>{null==e&&void 0!==t.presetArg&&(e=t.presetArg);const s=this.getOptionValue(r);null!==e&&t.parseArg?e=this._callParseArg(t,e,s,n):null!==e&&t.variadic&&(e=t._collectValue(e,s)),null==e&&(e=!t.negate&&(!(!t.isBoolean()&&!t.optional)||"")),this.setOptionValueWithSource(r,e,i)};return this.on("option:"+e,e=>{const r=`error: option '${t.flags}' argument '${e}' is invalid.`;n(e,r,"cli")}),t.envVar&&this.on("optionEnv:"+e,e=>{const r=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;n(e,r,"env")}),this}_optionEx(t,e,r,n,i){if("object"==typeof e&&e instanceof v)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const s=this.createOption(e,r);if(s.makeOptionMandatory(!!t.mandatory),"function"==typeof n)s.default(i).argParser(n);else if(n instanceof RegExp){const t=n;n=(e,r)=>{const n=t.exec(e);return n?n[0]:r},s.default(i).argParser(n)}else s.default(n);return this.addOption(s)}option(t,e,r,n){return this._optionEx({},t,e,r,n)}requiredOption(t,e,r,n){return this._optionEx({mandatory:!0},t,e,r,n)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,r){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=r,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(r=>{void 0!==r.getOptionValueSource(t)&&(e=r.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(e=e||{},void 0===t&&void 0===e.from){h.versions?.electron&&(e.from="electron");const t=h.execArgv??[];(t.includes("-e")||t.includes("--eval")||t.includes("-p")||t.includes("--print"))&&(e.from="eval")}let r;switch(void 0===t&&(t=h.argv),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],r=t.slice(2);break;case"electron":h.defaultApp?(this._scriptPath=t[1],r=t.slice(2)):r=t.slice(1);break;case"user":r=t.slice(0);break;case"eval":r=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(t,e){this._prepareForParse();const r=this._prepareUserArgs(t,e);return this._parseCommand([],r),this}async parseAsync(t,e){this._prepareForParse();const r=this._prepareUserArgs(t,e);return await this._parseCommand([],r),this}_prepareForParse(){null===this._savedState?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error("Can not call parse again when storeOptionsAsProperties is true.\n- either make a new Command for each call to parse, or stop storing options as properties");this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,e,r){if(!l.existsSync(t))throw new Error(`'${t}' does not exist\n - if '${r}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${e?`searched for local subcommand relative to directory '${e}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory"}`)}_executeSubCommand(t,e){e=e.slice();let r=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function i(t,e){const r=a.resolve(t,e);if(l.existsSync(r))return r;if(n.includes(a.extname(e)))return;const i=n.find(t=>l.existsSync(`${r}${t}`));return i?`${r}${i}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s,c=t._executableFile||`${this._name}-${t._name}`,u=this._executableDir||"";if(this._scriptPath){let t;try{t=l.realpathSync(this._scriptPath)}catch{t=this._scriptPath}u=a.resolve(a.dirname(t),u)}if(u){let e=i(u,c);if(!e&&!t._executableFile&&this._scriptPath){const r=a.basename(this._scriptPath,a.extname(this._scriptPath));r!==this._name&&(e=i(u,`${r}-${t._name}`))}c=e||c}r=n.includes(a.extname(c)),"win32"!==h.platform?r?(e.unshift(c),e=I(h.execArgv).concat(e),s=o.spawn(h.argv[0],e,{stdio:"inherit"})):s=o.spawn(c,e,{stdio:"inherit"}):(this._checkForMissingExecutable(c,u,t._name),e.unshift(c),e=I(h.execArgv).concat(e),s=o.spawn(h.execPath,e,{stdio:"inherit"})),s.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(t=>{h.on(t,()=>{!1===s.killed&&null===s.exitCode&&s.kill(t)})});const p=this._exitCallback;s.on("close",t=>{t=t??1,p?p(new d(t,"commander.executeSubCommandAsync","(close)")):h.exit(t)}),s.on("error",e=>{if("ENOENT"===e.code)this._checkForMissingExecutable(c,u,t._name);else if("EACCES"===e.code)throw new Error(`'${c}' not executable`);if(p){const t=new d(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,p(t)}else h.exit(1)}),this.runningCommand=s}_dispatchSubcommand(t,e,r){const n=this._findCommand(t);let i;return n||this.help({error:!0}),n._prepareForParse(),i=this._chainOrCallSubCommandHook(i,n,"preSubcommand"),i=this._chainOrCall(i,()=>{if(!n._executableHandler)return n._parseCommand(e,r);this._executeSubCommand(n,e.concat(r))}),i}_dispatchHelpCommand(t){t||this.help();const e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&null==this.args[e]&&this.missingArgument(t.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const t=(t,e,r)=>{let n=e;if(null!==e&&t.parseArg){const i=`error: command-argument value '${e}' is invalid for argument '${t.name()}'.`;n=this._callParseArg(t,e,r,i)}return n};this._checkNumberOfArguments();const e=[];this.registeredArguments.forEach((r,n)=>{let i=r.defaultValue;r.variadic?n<this.args.length?(i=this.args.slice(n),r.parseArg&&(i=i.reduce((e,n)=>t(r,n,e),r.defaultValue))):void 0===i&&(i=[]):n<this.args.length&&(i=this.args[n],r.parseArg&&(i=t(r,i,r.defaultValue))),e[n]=i}),this.processedArgs=e}_chainOrCall(t,e){return t?.then&&"function"==typeof t.then?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let r=t;const n=[];return this._getCommandAndAncestors().reverse().filter(t=>void 0!==t._lifeCycleHooks[e]).forEach(t=>{t._lifeCycleHooks[e].forEach(e=>{n.push({hookedCommand:t,callback:e})})}),"postAction"===e&&n.reverse(),n.forEach(t=>{r=this._chainOrCall(r,()=>t.callback(t.hookedCommand,this))}),r}_chainOrCallSubCommandHook(t,e,r){let n=t;return void 0!==this._lifeCycleHooks[r]&&this._lifeCycleHooks[r].forEach(t=>{n=this._chainOrCall(n,()=>t(this,e))}),n}_parseCommand(t,e){const r=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(r.operands),e=r.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(e),this._dispatchSubcommand(this._defaultCommandName,t,e);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),this._outputHelpIfRequested(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const n=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){let r;return n(),this._processArguments(),r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,()=>this._actionHandler(this.processedArgs)),this.parent&&(r=this._chainOrCall(r,()=>{this.parent.emit(i,t,e)})),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent?.listenerCount(i))n(),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():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&void 0===t.getOptionValue(e.attributeName())&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){const t=this.options.filter(t=>{const e=t.attributeName();return void 0!==this.getOptionValue(e)&&"default"!==this.getOptionValueSource(e)}),e=t.filter(t=>t.conflictsWith.length>0);e.forEach(e=>{const r=t.find(t=>e.conflictsWith.includes(t.attributeName()));r&&this._conflictingOption(e,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){const e=[],r=[];let n=e;function i(t){return t.length>1&&"-"===t[0]}const s=t=>!!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(t)&&!this._getCommandAndAncestors().some(t=>t.options.map(t=>t.short).some(t=>/^-\d$/.test(t)));let o=null,a=null,l=0;for(;l<t.length||a;){const h=a??t[l++];if(a=null,"--"===h){n===r&&n.push(h),n.push(...t.slice(l));break}if(!o||i(h)&&!s(h)){if(o=null,i(h)){const e=this._findOption(h);if(e){if(e.required){const r=t[l++];void 0===r&&this.optionMissingArgument(e),this.emit(`option:${e.name()}`,r)}else if(e.optional){let r=null;l<t.length&&(!i(t[l])||s(t[l]))&&(r=t[l++]),this.emit(`option:${e.name()}`,r)}else this.emit(`option:${e.name()}`);o=e.variadic?e:null;continue}}if(h.length>2&&"-"===h[0]&&"-"!==h[1]){const t=this._findOption(`-${h[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,h.slice(2)):(this.emit(`option:${t.name()}`),a=`-${h.slice(2)}`);continue}}if(/^--[^=]+=/.test(h)){const t=h.indexOf("="),e=this._findOption(h.slice(0,t));if(e&&(e.required||e.optional)){this.emit(`option:${e.name()}`,h.slice(t+1));continue}}if(n!==e||!i(h)||0===this.commands.length&&s(h)||(n=r),(this._enablePositionalOptions||this._passThroughOptions)&&0===e.length&&0===r.length){if(this._findCommand(h)){e.push(h),r.push(...t.slice(l));break}if(this._getHelpCommand()&&h===this._getHelpCommand().name()){e.push(h,...t.slice(l));break}if(this._defaultCommandName){r.push(h,...t.slice(l));break}}if(this._passThroughOptions){n.push(h,...t.slice(l));break}n.push(h)}else this.emit(`option:${o.name()}`,h)}return{operands:e,unknown:r}}opts(){if(this._storeOptionsAsProperties){const t={},e=this.options.length;for(let r=0;r<e;r++){const e=this.options[r].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){this._outputConfiguration.outputError(`${t}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0}));const r=e||{},n=r.exitCode||1,i=r.code||"commander.error";this._exit(n,i,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in h.env){const e=t.attributeName();(void 0===this.getOptionValue(e)||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,h.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){const t=new A(this.options),e=t=>void 0!==this.getOptionValue(t)&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter(r=>void 0!==r.implied&&e(r.attributeName())&&t.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(t=>{Object.keys(t.implied).filter(t=>!e(t)).forEach(e=>{this.setOptionValueWithSource(e,t.implied[e],"implied")})})}missingArgument(t){const e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){const r=t=>{const e=t.attributeName(),r=this.getOptionValue(e),n=this.options.find(t=>t.negate&&e===t.attributeName()),i=this.options.find(t=>!t.negate&&e===t.attributeName());return n&&(void 0===n.presetArg&&!1===r||void 0!==n.presetArg&&r===n.presetArg)?n:i||t},n=t=>{const e=r(t),n=e.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${e.envVar}'`:`option '${e.flags}'`},i=`error: ${n(t)} cannot be used with ${n(e)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let r=[],n=this;do{const t=n.createHelp().visibleOptions(n).filter(t=>t.long).map(t=>t.long);r=r.concat(t),n=n.parent}while(n&&!n._enablePositionalOptions);e=C(t,r)}const r=`error: unknown option '${t}'${e}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const e=this.registeredArguments.length,r=1===e?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${r} but got ${t.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const r=[];this.createHelp().visibleCommands(this).forEach(t=>{r.push(t.name()),t.alias()&&r.push(t.alias())}),e=C(t,r)}const r=`error: unknown command '${t}'${e}`;this.error(r,{code:"commander.unknownCommand"})}version(t,e,r){if(void 0===t)return this._version;this._version=t,e=e||"-V, --version",r=r||"output the version number";const n=this.createOption(e,r);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}\n`),this._exit(0,"commander.version",t)}),this}description(t,e){return void 0===t&&void 0===e?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return void 0===t?this._summary:(this._summary=t,this)}alias(t){if(void 0===t)return this._aliases[0];let e=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");const r=this.parent?._findCommand(t);if(r){const e=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${e}'`)}return e._aliases.push(t),this}aliases(t){return void 0===t?this._aliases:(t.forEach(t=>this.alias(t)),this)}usage(t){if(void 0===t){if(this._usage)return this._usage;const t=this.registeredArguments.map(t=>u(t));return[].concat(this.options.length||null!==this._helpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=t,this}name(t){return void 0===t?this._name:(this._name=t,this)}helpGroup(t){return void 0===t?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return void 0===t?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return void 0===t?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=a.basename(t,a.extname(t)),this}executableDir(t){return void 0===t?this._executableDir:(this._executableDir=t,this)}helpInformation(t){const e=this.createHelp(),r=this._getOutputContext(t);e.prepareContext({error:r.error,helpWidth:r.helpWidth,outputHasColors:r.hasColors});const n=e.formatHelp(this,e);return r.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(t){const e=!!(t=t||{}).error;let r,n,i;return e?(r=t=>this._outputConfiguration.writeErr(t),n=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(r=t=>this._outputConfiguration.writeOut(t),n=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:e,write:t=>(n||(t=this._outputConfiguration.stripColor(t)),r(t)),hasColors:n,helpWidth:i}}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const r=this._getOutputContext(t),n={error:r.error,write:r.write,command:this};this._getCommandAndAncestors().reverse().forEach(t=>t.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let i=this.helpInformation({error:r.error});if(e&&(i=e(i),"string"!=typeof i&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(t=>t.emit("afterAllHelp",n))}helpOption(t,e){return"boolean"==typeof t?(t?(null===this._helpOption&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",e??"display help for command"),(t||e)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return void 0===this._helpOption&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let e=Number(h.exitCode??0);0===e&&t&&"function"!=typeof t&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const r=["beforeAll","before","after","afterAll"];if(!r.includes(t))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${r.join("', '")}'`);const n=`${t}Help`;return this.on(n,t=>{let r;r="function"==typeof e?e({error:t.error,command:t.command}):e,r&&t.write(`${r}\n`)}),this}_outputHelpIfRequested(t){const e=this._getHelpOption();e&&t.find(t=>e.is(t))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}}function I(t){return t.map(t=>{if(!t.startsWith("--inspect"))return t;let e,r,n="127.0.0.1",i="9229";return null!==(r=t.match(/^(--inspect(-brk)?)$/))?e=r[1]:null!==(r=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(e=r[1],/^\d+$/.test(r[3])?i=r[3]:n=r[3]):null!==(r=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(e=r[1],n=r[3],i=r[4]),e&&"0"!==i?`${e}=${n}:${parseInt(i)+1}`:t})}function y(){return!h.env.NO_COLOR&&"0"!==h.env.FORCE_COLOR&&"false"!==h.env.FORCE_COLOR&&(!(!h.env.FORCE_COLOR&&void 0===h.env.CLICOLOR_FORCE)||void 0)}return f.Command=w,f.useColor=y,f}(),{CommanderError:a,InvalidArgumentError:l}=p(),{Help:c}=E(),{Option:u}=O();return h.program=new o,h.createCommand=t=>new o(t),h.createOption=(t,e)=>new u(t,e),h.createArgument=(t,e)=>new s(t,e),h.Command=o,h.Option=u,h.Argument=s,h.Help=c,h.CommanderError=a,h.InvalidArgumentError=l,h.InvalidOptionArgumentError=l,h}(),y=o(I);const{program:S,createCommand:R,createArgument:T,createOption:N,CommanderError:L,InvalidArgumentError:x,InvalidOptionArgumentError:P,Command:k,Argument:H,Option:D,Help:F}=y;var G,V,M,j,U,W,X,q,B,Y,K,z,J,Z,Q,tt,et,rt,nt,it,st,ot,at,lt,ht,ct,ut,pt,mt,dt,ft,gt,Et,_t,vt,Ot,At,$t,Ct,wt,bt,It,yt,St,Rt,Tt,Nt,Lt,xt,Pt,kt,Ht,Dt,Ft,Gt,Vt,Mt,jt,Ut,Wt,Xt,qt,Bt,Yt,Kt,zt,Jt,Zt,Qt,te,ee,re,ne,ie,se,oe,ae,le,he,ce,ue,pe,me,de,fe,ge,Ee,_e,ve,Oe,Ae,$e={exports:{}};function Ce(){if(V)return G;V=1;const t=Number.MAX_SAFE_INTEGER||9007199254740991;return G={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}function we(){if(j)return M;j=1;const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};return M=t}function be(){return U||(U=1,function(t,e){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=Ce(),s=we(),o=(e=t.exports={}).re=[],a=e.safeRe=[],l=e.src=[],h=e.safeSrc=[],c=e.t={};let u=0;const p="[a-zA-Z0-9-]",m=[["\\s",1],["\\d",i],[p,n]],d=(t,e,r)=>{const n=(t=>{for(const[e,r]of m)t=t.split(`${e}*`).join(`${e}{0,${r}}`).split(`${e}+`).join(`${e}{1,${r}}`);return t})(e),i=u++;s(t,i,e),c[t]=i,l[i]=e,h[i]=n,o[i]=new RegExp(e,r?"g":void 0),a[i]=new RegExp(n,r?"g":void 0)};d("NUMERICIDENTIFIER","0|[1-9]\\d*"),d("NUMERICIDENTIFIERLOOSE","\\d+"),d("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${p}*`),d("MAINVERSION",`(${l[c.NUMERICIDENTIFIER]})\\.(${l[c.NUMERICIDENTIFIER]})\\.(${l[c.NUMERICIDENTIFIER]})`),d("MAINVERSIONLOOSE",`(${l[c.NUMERICIDENTIFIERLOOSE]})\\.(${l[c.NUMERICIDENTIFIERLOOSE]})\\.(${l[c.NUMERICIDENTIFIERLOOSE]})`),d("PRERELEASEIDENTIFIER",`(?:${l[c.NONNUMERICIDENTIFIER]}|${l[c.NUMERICIDENTIFIER]})`),d("PRERELEASEIDENTIFIERLOOSE",`(?:${l[c.NONNUMERICIDENTIFIER]}|${l[c.NUMERICIDENTIFIERLOOSE]})`),d("PRERELEASE",`(?:-(${l[c.PRERELEASEIDENTIFIER]}(?:\\.${l[c.PRERELEASEIDENTIFIER]})*))`),d("PRERELEASELOOSE",`(?:-?(${l[c.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[c.PRERELEASEIDENTIFIERLOOSE]})*))`),d("BUILDIDENTIFIER",`${p}+`),d("BUILD",`(?:\\+(${l[c.BUILDIDENTIFIER]}(?:\\.${l[c.BUILDIDENTIFIER]})*))`),d("FULLPLAIN",`v?${l[c.MAINVERSION]}${l[c.PRERELEASE]}?${l[c.BUILD]}?`),d("FULL",`^${l[c.FULLPLAIN]}$`),d("LOOSEPLAIN",`[v=\\s]*${l[c.MAINVERSIONLOOSE]}${l[c.PRERELEASELOOSE]}?${l[c.BUILD]}?`),d("LOOSE",`^${l[c.LOOSEPLAIN]}$`),d("GTLT","((?:<|>)?=?)"),d("XRANGEIDENTIFIERLOOSE",`${l[c.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),d("XRANGEIDENTIFIER",`${l[c.NUMERICIDENTIFIER]}|x|X|\\*`),d("XRANGEPLAIN",`[v=\\s]*(${l[c.XRANGEIDENTIFIER]})(?:\\.(${l[c.XRANGEIDENTIFIER]})(?:\\.(${l[c.XRANGEIDENTIFIER]})(?:${l[c.PRERELEASE]})?${l[c.BUILD]}?)?)?`),d("XRANGEPLAINLOOSE",`[v=\\s]*(${l[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[c.XRANGEIDENTIFIERLOOSE]})(?:${l[c.PRERELEASELOOSE]})?${l[c.BUILD]}?)?)?`),d("XRANGE",`^${l[c.GTLT]}\\s*${l[c.XRANGEPLAIN]}$`),d("XRANGELOOSE",`^${l[c.GTLT]}\\s*${l[c.XRANGEPLAINLOOSE]}$`),d("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),d("COERCE",`${l[c.COERCEPLAIN]}(?:$|[^\\d])`),d("COERCEFULL",l[c.COERCEPLAIN]+`(?:${l[c.PRERELEASE]})?`+`(?:${l[c.BUILD]})?(?:$|[^\\d])`),d("COERCERTL",l[c.COERCE],!0),d("COERCERTLFULL",l[c.COERCEFULL],!0),d("LONETILDE","(?:~>?)"),d("TILDETRIM",`(\\s*)${l[c.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",d("TILDE",`^${l[c.LONETILDE]}${l[c.XRANGEPLAIN]}$`),d("TILDELOOSE",`^${l[c.LONETILDE]}${l[c.XRANGEPLAINLOOSE]}$`),d("LONECARET","(?:\\^)"),d("CARETTRIM",`(\\s*)${l[c.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",d("CARET",`^${l[c.LONECARET]}${l[c.XRANGEPLAIN]}$`),d("CARETLOOSE",`^${l[c.LONECARET]}${l[c.XRANGEPLAINLOOSE]}$`),d("COMPARATORLOOSE",`^${l[c.GTLT]}\\s*(${l[c.LOOSEPLAIN]})$|^$`),d("COMPARATOR",`^${l[c.GTLT]}\\s*(${l[c.FULLPLAIN]})$|^$`),d("COMPARATORTRIM",`(\\s*)${l[c.GTLT]}\\s*(${l[c.LOOSEPLAIN]}|${l[c.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",d("HYPHENRANGE",`^\\s*(${l[c.XRANGEPLAIN]})\\s+-\\s+(${l[c.XRANGEPLAIN]})\\s*$`),d("HYPHENRANGELOOSE",`^\\s*(${l[c.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[c.XRANGEPLAINLOOSE]})\\s*$`),d("STAR","(<|>)?=?\\s*\\*"),d("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),d("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}($e,$e.exports)),$e.exports}function Ie(){if(X)return W;X=1;const t=Object.freeze({loose:!0}),e=Object.freeze({});return W=r=>r?"object"!=typeof r?t:r:e}function ye(){if(B)return q;B=1;const t=/^[0-9]+$/,e=(e,r)=>{if("number"==typeof e&&"number"==typeof r)return e===r?0:e<r?-1:1;const n=t.test(e),i=t.test(r);return n&&i&&(e=+e,r=+r),e===r?0:n&&!i?-1:i&&!n?1:e<r?-1:1};return q={compareIdentifiers:e,rcompareIdentifiers:(t,r)=>e(r,t)}}function Se(){if(K)return Y;K=1;const t=we(),{MAX_LENGTH:e,MAX_SAFE_INTEGER:r}=Ce(),{safeRe:n,t:i}=be(),s=Ie(),{compareIdentifiers:o}=ye();class a{constructor(o,l){if(l=s(l),o instanceof a){if(o.loose===!!l.loose&&o.includePrerelease===!!l.includePrerelease)return o;o=o.version}else if("string"!=typeof o)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof o}".`);if(o.length>e)throw new TypeError(`version is longer than ${e} characters`);t("SemVer",o,l),this.options=l,this.loose=!!l.loose,this.includePrerelease=!!l.includePrerelease;const h=o.trim().match(l.loose?n[i.LOOSE]:n[i.FULL]);if(!h)throw new TypeError(`Invalid Version: ${o}`);if(this.raw=o,this.major=+h[1],this.minor=+h[2],this.patch=+h[3],this.major>r||this.major<0)throw new TypeError("Invalid major version");if(this.minor>r||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>r||this.patch<0)throw new TypeError("Invalid patch version");h[4]?this.prerelease=h[4].split(".").map(t=>{if(/^[0-9]+$/.test(t)){const e=+t;if(e>=0&&e<r)return e}return t}):this.prerelease=[],this.build=h[5]?h[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(t("SemVer.compare",this.version,this.options,e),!(e instanceof a)){if("string"==typeof e&&e===this.version)return 0;e=new a(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(t){return t instanceof a||(t=new a(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:this.patch>t.patch?1:0}comparePre(e){if(e instanceof a||(e=new a(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let r=0;do{const n=this.prerelease[r],i=e.prerelease[r];if(t("prerelease compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return o(n,i)}while(++r)}compareBuild(e){e instanceof a||(e=new a(e,this.options));let r=0;do{const n=this.build[r],i=e.build[r];if(t("build compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return o(n,i)}while(++r)}inc(t,e,r){if(t.startsWith("pre")){if(!e&&!1===r)throw new Error("invalid increment argument: identifier is empty");if(e){const t=`-${e}`.match(this.options.loose?n[i.PRERELEASELOOSE]:n[i.PRERELEASE]);if(!t||t[1]!==e)throw new Error(`invalid identifier: ${e}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",e,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",e,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",e,r),this.inc("pre",e,r);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",e,r),this.inc("pre",e,r);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const t=Number(r)?1:0;if(0===this.prerelease.length)this.prerelease=[t];else{let n=this.prerelease.length;for(;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(e===this.prerelease.join(".")&&!1===r)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(t)}}if(e){let n=[e,t];if(!1===r&&(n=[e]),((t,e)=>{const r=e.split(".");if(r.length>t.length)return!1;for(let e=0;e<r.length;e++)if(0!==o(t[e],r[e]))return!1;return!0})(this.prerelease,e)){const t=this.prerelease[e.split(".").length];isNaN(t)&&(this.prerelease=n)}else this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return Y=a}function Re(){if(J)return z;J=1;const t=Se();return z=(e,r,n=!1)=>{if(e instanceof t)return e;try{return new t(e,r)}catch(t){if(!n)return null;throw t}}}function Te(){if(ft)return dt;ft=1;const t=Se();return dt=(e,r,n)=>new t(e,n).compare(new t(r,n))}function Ne(){if(At)return Ot;At=1;const t=Se();return Ot=(e,r,n)=>{const i=new t(e,n),s=new t(r,n);return i.compare(s)||i.compareBuild(s)}}function Le(){if(yt)return It;yt=1;const t=Te();return It=(e,r,n)=>t(e,r,n)>0}function xe(){if(Rt)return St;Rt=1;const t=Te();return St=(e,r,n)=>t(e,r,n)<0}function Pe(){if(Nt)return Tt;Nt=1;const t=Te();return Tt=(e,r,n)=>0===t(e,r,n)}function ke(){if(xt)return Lt;xt=1;const t=Te();return Lt=(e,r,n)=>0!==t(e,r,n)}function He(){if(kt)return Pt;kt=1;const t=Te();return Pt=(e,r,n)=>t(e,r,n)>=0}function De(){if(Dt)return Ht;Dt=1;const t=Te();return Ht=(e,r,n)=>t(e,r,n)<=0}function Fe(){if(Gt)return Ft;Gt=1;const t=Pe(),e=ke(),r=Le(),n=He(),i=xe(),s=De();return Ft=(o,a,l,h)=>{switch(a){case"===":return"object"==typeof o&&(o=o.version),"object"==typeof l&&(l=l.version),o===l;case"!==":return"object"==typeof o&&(o=o.version),"object"==typeof l&&(l=l.version),o!==l;case"":case"=":case"==":return t(o,l,h);case"!=":return e(o,l,h);case">":return r(o,l,h);case">=":return n(o,l,h);case"<":return i(o,l,h);case"<=":return s(o,l,h);default:throw new TypeError(`Invalid operator: ${a}`)}}}function Ge(){if(Bt)return qt;Bt=1;const t=/\s+/g;class e{constructor(r,s){if(s=n(s),r instanceof e)return r.loose===!!s.loose&&r.includePrerelease===!!s.includePrerelease?r:new e(r.raw,s);if(r instanceof i)return this.raw=r.value,this.set=[[r]],this.formatted=void 0,this;if(this.options=s,this.loose=!!s.loose,this.includePrerelease=!!s.includePrerelease,this.raw=r.trim().replace(t," "),this.set=this.raw.split("||").map(t=>this.parseRange(t.trim())).filter(t=>t.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const t=this.set[0];if(this.set=this.set.filter(t=>!g(t[0])),0===this.set.length)this.set=[t];else if(this.set.length>1)for(const t of this.set)if(1===t.length&&E(t[0])){this.set=[t];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let t=0;t<this.set.length;t++){t>0&&(this.formatted+="||");const e=this.set[t];for(let t=0;t<e.length;t++)t>0&&(this.formatted+=" "),this.formatted+=e[t].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(t){t=t.replace(f,"");const e=((this.options.includePrerelease&&m)|(this.options.loose&&d))+":"+t,n=r.get(e);if(n)return n;const o=this.options.loose,l=o?a[h.HYPHENRANGELOOSE]:a[h.HYPHENRANGE];t=t.replace(l,R(this.options.includePrerelease)),s("hyphen replace",t),t=t.replace(a[h.COMPARATORTRIM],c),s("comparator trim",t),t=t.replace(a[h.TILDETRIM],u),s("tilde trim",t),t=t.replace(a[h.CARETTRIM],p),s("caret trim",t);let E=t.split(" ").map(t=>v(t,this.options)).join(" ").split(/\s+/).map(t=>S(t,this.options));o&&(E=E.filter(t=>(s("loose invalid filter",t,this.options),!!t.match(a[h.COMPARATORLOOSE])))),s("range list",E);const _=new Map,O=E.map(t=>new i(t,this.options));for(const t of O){if(g(t))return[t];_.set(t.value,t)}_.size>1&&_.has("")&&_.delete("");const A=[..._.values()];return r.set(e,A),A}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Range is required");return this.set.some(e=>_(e,r)&&t.set.some(t=>_(t,r)&&e.every(e=>t.every(t=>e.intersects(t,r)))))}test(t){if(!t)return!1;if("string"==typeof t)try{t=new o(t,this.options)}catch(t){return!1}for(let e=0;e<this.set.length;e++)if(T(this.set[e],t,this.options))return!0;return!1}}qt=e;const r=new(Xt?Wt:(Xt=1,Wt=class{constructor(){this.max=1e3,this.map=new Map}get(t){const e=this.map.get(t);return void 0===e?void 0:(this.map.delete(t),this.map.set(t,e),e)}delete(t){return this.map.delete(t)}set(t,e){if(!this.delete(t)&&void 0!==e){if(this.map.size>=this.max){const t=this.map.keys().next().value;this.delete(t)}this.map.set(t,e)}return this}})),n=Ie(),i=Ve(),s=we(),o=Se(),{safeRe:a,src:l,t:h,comparatorTrimReplace:c,tildeTrimReplace:u,caretTrimReplace:p}=be(),{FLAG_INCLUDE_PRERELEASE:m,FLAG_LOOSE:d}=Ce(),f=new RegExp(l[h.BUILD],"g"),g=t=>"<0.0.0-0"===t.value,E=t=>""===t.value,_=(t,e)=>{let r=!0;const n=t.slice();let i=n.pop();for(;r&&n.length;)r=n.every(t=>i.intersects(t,e)),i=n.pop();return r},v=(t,e)=>(t=t.replace(a[h.BUILD],""),s("comp",t,e),t=C(t,e),s("caret",t),t=A(t,e),s("tildes",t),t=b(t,e),s("xrange",t),t=y(t,e),s("stars",t),t),O=t=>!t||"x"===t.toLowerCase()||"*"===t,A=(t,e)=>t.trim().split(/\s+/).map(t=>$(t,e)).join(" "),$=(t,e)=>{const r=e.loose?a[h.TILDELOOSE]:a[h.TILDE],n=e.includePrerelease?"-0":"";return t.replace(r,(e,r,i,o,a)=>{let l;return s("tilde",t,e,r,i,o,a),O(r)?l="":O(i)?l=`>=${r}.0.0${n} <${+r+1}.0.0-0`:O(o)?l=`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:a?(s("replaceTilde pr",a),l=`>=${r}.${i}.${o}-${a} <${r}.${+i+1}.0-0`):l=`>=${r}.${i}.${o} <${r}.${+i+1}.0-0`,s("tilde return",l),l})},C=(t,e)=>t.trim().split(/\s+/).map(t=>w(t,e)).join(" "),w=(t,e)=>{s("caret",t,e);const r=e.loose?a[h.CARETLOOSE]:a[h.CARET],n=e.includePrerelease?"-0":"";return t.replace(r,(e,r,i,o,a)=>{let l;return s("caret",t,e,r,i,o,a),O(r)?l="":O(i)?l=`>=${r}.0.0${n} <${+r+1}.0.0-0`:O(o)?l="0"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:a?(s("replaceCaret pr",a),l="0"===r?"0"===i?`>=${r}.${i}.${o}-${a} <${r}.${i}.${+o+1}-0`:`>=${r}.${i}.${o}-${a} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${o}-${a} <${+r+1}.0.0-0`):(s("no pr"),l="0"===r?"0"===i?`>=${r}.${i}.${o} <${r}.${i}.${+o+1}-0`:`>=${r}.${i}.${o} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${o} <${+r+1}.0.0-0`),s("caret return",l),l})},b=(t,e)=>(s("replaceXRanges",t,e),t.split(/\s+/).map(t=>I(t,e)).join(" ")),I=(t,e)=>{t=t.trim();const r=e.loose?a[h.XRANGELOOSE]:a[h.XRANGE];return t.replace(r,(r,n,i,o,a,l)=>{if(s("xRange",t,r,n,i,o,a,l),((t,e,r)=>O(t)&&!O(e)||O(e)&&r&&!O(r))(i,o,a))return t;const h=O(i),c=h||O(o),u=c||O(a),p=u;return"="===n&&p&&(n=""),l=e.includePrerelease?"-0":"",h?r=">"===n||"<"===n?"<0.0.0-0":"*":n&&p?(c&&(o=0),a=0,">"===n?(n=">=",c?(i=+i+1,o=0,a=0):(o=+o+1,a=0)):"<="===n&&(n="<",c?i=+i+1:o=+o+1),"<"===n&&(l="-0"),r=`${n+i}.${o}.${a}${l}`):c?r=`>=${i}.0.0${l} <${+i+1}.0.0-0`:u&&(r=`>=${i}.${o}.0${l} <${i}.${+o+1}.0-0`),s("xRange return",r),r})},y=(t,e)=>(s("replaceStars",t,e),t.trim().replace(a[h.STAR],"")),S=(t,e)=>(s("replaceGTE0",t,e),t.trim().replace(a[e.includePrerelease?h.GTE0PRE:h.GTE0],"")),R=t=>(e,r,n,i,s,o,a,l,h,c,u,p)=>`${r=O(n)?"":O(i)?`>=${n}.0.0${t?"-0":""}`:O(s)?`>=${n}.${i}.0${t?"-0":""}`:o?`>=${r}`:`>=${r}${t?"-0":""}`} ${l=O(h)?"":O(c)?`<${+h+1}.0.0-0`:O(u)?`<${h}.${+c+1}.0-0`:p?`<=${h}.${c}.${u}-${p}`:t?`<${h}.${c}.${+u+1}-0`:`<=${l}`}`.trim(),T=(t,e,r)=>{for(let r=0;r<t.length;r++)if(!t[r].test(e))return!1;if(e.prerelease.length&&!r.includePrerelease){for(let r=0;r<t.length;r++)if(s(t[r].semver),t[r].semver!==i.ANY&&t[r].semver.prerelease.length>0){const n=t[r].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0};return qt}function Ve(){if(Kt)return Yt;Kt=1;const t=Symbol("SemVer ANY");class e{static get ANY(){return t}constructor(n,i){if(i=r(i),n instanceof e){if(n.loose===!!i.loose)return n;n=n.value}n=n.trim().split(/\s+/).join(" "),o("comparator",n,i),this.options=i,this.loose=!!i.loose,this.parse(n),this.semver===t?this.value="":this.value=this.operator+this.semver.version,o("comp",this)}parse(e){const r=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],s=e.match(r);if(!s)throw new TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==s[1]?s[1]:"","="===this.operator&&(this.operator=""),s[2]?this.semver=new a(s[2],this.options.loose):this.semver=t}toString(){return this.value}test(e){if(o("Comparator.test",e,this.options.loose),this.semver===t||e===t)return!0;if("string"==typeof e)try{e=new a(e,this.options)}catch(t){return!1}return s(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new l(t.value,n).test(this.value):""===t.operator?""===t.value||new l(this.value,n).test(t.semver):!((n=r(n)).includePrerelease&&("<0.0.0-0"===this.value||"<0.0.0-0"===t.value)||!n.includePrerelease&&(this.value.startsWith("<0.0.0")||t.value.startsWith("<0.0.0"))||(!this.operator.startsWith(">")||!t.operator.startsWith(">"))&&(!this.operator.startsWith("<")||!t.operator.startsWith("<"))&&(this.semver.version!==t.semver.version||!this.operator.includes("=")||!t.operator.includes("="))&&!(s(this.semver,"<",t.semver,n)&&this.operator.startsWith(">")&&t.operator.startsWith("<"))&&!(s(this.semver,">",t.semver,n)&&this.operator.startsWith("<")&&t.operator.startsWith(">")))}}Yt=e;const r=Ie(),{safeRe:n,t:i}=be(),s=Fe(),o=we(),a=Se(),l=Ge();return Yt}function Me(){if(Jt)return zt;Jt=1;const t=Ge();return zt=(e,r,n)=>{try{r=new t(r,n)}catch(t){return!1}return r.test(e)},zt}function je(){if(ae)return oe;ae=1;const t=Ge();return oe=(e,r)=>{try{return new t(e,r).range||"*"}catch(t){return null}},oe}function Ue(){if(he)return le;he=1;const t=Se(),e=Ve(),{ANY:r}=e,n=Ge(),i=Me(),s=Le(),o=xe(),a=De(),l=He();return le=(h,c,u,p)=>{let m,d,f,g,E;switch(h=new t(h,p),c=new n(c,p),u){case">":m=s,d=a,f=o,g=">",E=">=";break;case"<":m=o,d=l,f=s,g="<",E="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(i(h,c,p))return!1;for(let t=0;t<c.set.length;++t){const n=c.set[t];let i=null,s=null;if(n.forEach(t=>{t.semver===r&&(t=new e(">=0.0.0")),i=i||t,s=s||t,m(t.semver,i.semver,p)?i=t:f(t.semver,s.semver,p)&&(s=t)}),i.operator===g||i.operator===E)return!1;if((!s.operator||s.operator===g)&&d(h,s.semver))return!1;if(s.operator===E&&f(h,s.semver))return!1}return!0},le}var We=function(){if(Ae)return Oe;Ae=1;const t=be(),e=Ce(),r=Se(),n=ye(),i=Re(),s=function(){if(Q)return Z;Q=1;const t=Re();return Z=(e,r)=>{const n=t(e,r);return n?n.version:null}}(),o=function(){if(et)return tt;et=1;const t=Re();return tt=(e,r)=>{const n=t(e.trim().replace(/^[=v]+/,""),r);return n?n.version:null}}(),a=function(){if(nt)return rt;nt=1;const t=Se();return rt=(e,r,n,i,s)=>{"string"==typeof n&&(s=i,i=n,n=void 0);try{return new t(e instanceof t?e.version:e,n).inc(r,i,s).version}catch(t){return null}}}(),l=function(){if(st)return it;st=1;const t=Re();return it=(e,r)=>{const n=t(e,null,!0),i=t(r,null,!0),s=n.compare(i);if(0===s)return null;const o=s>0,a=o?n:i,l=o?i:n,h=!!a.prerelease.length;if(l.prerelease.length&&!h){if(!l.patch&&!l.minor)return"major";if(0===l.compareMain(a))return l.minor&&!l.patch?"minor":"patch"}const c=h?"pre":"";return n.major!==i.major?c+"major":n.minor!==i.minor?c+"minor":n.patch!==i.patch?c+"patch":"prerelease"}}(),h=function(){if(at)return ot;at=1;const t=Se();return ot=(e,r)=>new t(e,r).major}(),c=function(){if(ht)return lt;ht=1;const t=Se();return lt=(e,r)=>new t(e,r).minor}(),u=function(){if(ut)return ct;ut=1;const t=Se();return ct=(e,r)=>new t(e,r).patch}(),p=function(){if(mt)return pt;mt=1;const t=Re();return pt=(e,r)=>{const n=t(e,r);return n&&n.prerelease.length?n.prerelease:null}}(),m=Te(),d=function(){if(Et)return gt;Et=1;const t=Te();return gt=(e,r,n)=>t(r,e,n)}(),f=function(){if(vt)return _t;vt=1;const t=Te();return _t=(e,r)=>t(e,r,!0)}(),g=Ne(),E=function(){if(Ct)return $t;Ct=1;const t=Ne();return $t=(e,r)=>e.sort((e,n)=>t(e,n,r))}(),_=function(){if(bt)return wt;bt=1;const t=Ne();return wt=(e,r)=>e.sort((e,n)=>t(n,e,r))}(),v=Le(),O=xe(),A=Pe(),$=ke(),C=He(),w=De(),b=Fe(),I=function(){if(Mt)return Vt;Mt=1;const t=Se(),e=Re(),{safeRe:r,t:n}=be();return Vt=(i,s)=>{if(i instanceof t)return i;if("number"==typeof i&&(i=String(i)),"string"!=typeof i)return null;let o=null;if((s=s||{}).rtl){const t=s.includePrerelease?r[n.COERCERTLFULL]:r[n.COERCERTL];let e;for(;(e=t.exec(i))&&(!o||o.index+o[0].length!==i.length);)o&&e.index+e[0].length===o.index+o[0].length||(o=e),t.lastIndex=e.index+e[1].length+e[2].length;t.lastIndex=-1}else o=i.match(s.includePrerelease?r[n.COERCEFULL]:r[n.COERCE]);if(null===o)return null;const a=o[2],l=o[3]||"0",h=o[4]||"0",c=s.includePrerelease&&o[5]?`-${o[5]}`:"",u=s.includePrerelease&&o[6]?`+${o[6]}`:"";return e(`${a}.${l}.${h}${c}${u}`,s)}}(),y=function(){if(Ut)return jt;Ut=1;const t=Re(),e=Ce(),r=Se(),n=t=>t.startsWith("pre");return jt=(i,s,o)=>{if(!e.RELEASE_TYPES.includes(s))return null;const a=((e,n)=>{const i=e instanceof r?e.version:e;return t(i,n)})(i,o);return a&&((t,e)=>{if(n(e))return t.version;switch(t.prerelease=[],e){case"major":t.minor=0,t.patch=0;break;case"minor":t.patch=0}return t.format()})(a,s)}}(),S=Ve(),R=Ge(),T=Me(),N=function(){if(Qt)return Zt;Qt=1;const t=Ge();return Zt=(e,r)=>new t(e,r).set.map(t=>t.map(t=>t.value).join(" ").trim().split(" ")),Zt}(),L=function(){if(ee)return te;ee=1;const t=Se(),e=Ge();return te=(r,n,i)=>{let s=null,o=null,a=null;try{a=new e(n,i)}catch(t){return null}return r.forEach(e=>{a.test(e)&&(s&&-1!==o.compare(e)||(s=e,o=new t(s,i)))}),s},te}(),x=function(){if(ne)return re;ne=1;const t=Se(),e=Ge();return re=(r,n,i)=>{let s=null,o=null,a=null;try{a=new e(n,i)}catch(t){return null}return r.forEach(e=>{a.test(e)&&(s&&1!==o.compare(e)||(s=e,o=new t(s,i)))}),s},re}(),P=function(){if(se)return ie;se=1;const t=Se(),e=Ge(),r=Le();return ie=(n,i)=>{n=new e(n,i);let s=new t("0.0.0");if(n.test(s))return s;if(s=new t("0.0.0-0"),n.test(s))return s;s=null;for(let e=0;e<n.set.length;++e){const i=n.set[e];let o=null;i.forEach(e=>{const n=new t(e.semver.version);switch(e.operator){case">":0===n.prerelease.length?n.patch++:n.prerelease.push(0),n.raw=n.format();case"":case">=":o&&!r(n,o)||(o=n);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}}),!o||s&&!r(s,o)||(s=o)}return s&&n.test(s)?s:null},ie}(),k=je(),H=Ue(),D=function(){if(ue)return ce;ue=1;const t=Ue();return ce=(e,r,n)=>t(e,r,">",n),ce}(),F=function(){if(me)return pe;me=1;const t=Ue();return pe=(e,r,n)=>t(e,r,"<",n),pe}(),G=function(){if(fe)return de;fe=1;const t=Ge();return de=(e,r,n)=>(e=new t(e,n),r=new t(r,n),e.intersects(r,n))}(),V=function(){if(Ee)return ge;Ee=1;const t=Me(),e=Te();return ge=(r,n,i)=>{const s=[];let o=null,a=null;const l=r.sort((t,r)=>e(t,r,i));for(const e of l)t(e,n,i)?(a=e,o||(o=e)):(a&&s.push([o,a]),a=null,o=null);o&&s.push([o,null]);const h=[];for(const[t,e]of s)t===e?h.push(t):e||t!==l[0]?e?t===l[0]?h.push(`<=${e}`):h.push(`${t} - ${e}`):h.push(`>=${t}`):h.push("*");const c=h.join(" || "),u="string"==typeof n.raw?n.raw:String(n);return c.length<u.length?c:n},ge}(),M=function(){if(ve)return _e;ve=1;const t=Ge(),e=Ve(),{ANY:r}=e,n=Me(),i=Te(),s=[new e(">=0.0.0-0")],o=[new e(">=0.0.0")],a=(t,e,a)=>{if(t===e)return!0;if(1===t.length&&t[0].semver===r){if(1===e.length&&e[0].semver===r)return!0;t=a.includePrerelease?s:o}if(1===e.length&&e[0].semver===r){if(a.includePrerelease)return!0;e=o}const c=new Set;let u,p,m,d,f,g,E;for(const e of t)">"===e.operator||">="===e.operator?u=l(u,e,a):"<"===e.operator||"<="===e.operator?p=h(p,e,a):c.add(e.semver);if(c.size>1)return null;if(u&&p){if(m=i(u.semver,p.semver,a),m>0)return null;if(0===m&&(">="!==u.operator||"<="!==p.operator))return null}for(const t of c){if(u&&!n(t,String(u),a))return null;if(p&&!n(t,String(p),a))return null;for(const r of e)if(!n(t,String(r),a))return!1;return!0}let _=!(!p||a.includePrerelease||!p.semver.prerelease.length)&&p.semver,v=!(!u||a.includePrerelease||!u.semver.prerelease.length)&&u.semver;_&&1===_.prerelease.length&&"<"===p.operator&&0===_.prerelease[0]&&(_=!1);for(const t of e){if(E=E||">"===t.operator||">="===t.operator,g=g||"<"===t.operator||"<="===t.operator,u)if(v&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===v.major&&t.semver.minor===v.minor&&t.semver.patch===v.patch&&(v=!1),">"===t.operator||">="===t.operator){if(d=l(u,t,a),d===t&&d!==u)return!1}else if(">="===u.operator&&!t.test(u.semver))return!1;if(p)if(_&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===_.major&&t.semver.minor===_.minor&&t.semver.patch===_.patch&&(_=!1),"<"===t.operator||"<="===t.operator){if(f=h(p,t,a),f===t&&f!==p)return!1}else if("<="===p.operator&&!t.test(p.semver))return!1;if(!t.operator&&(p||u)&&0!==m)return!1}return!(u&&g&&!p&&0!==m||p&&E&&!u&&0!==m||v||_)},l=(t,e,r)=>{if(!t)return e;const n=i(t.semver,e.semver,r);return n>0?t:n<0||">"===e.operator&&">="===t.operator?e:t},h=(t,e,r)=>{if(!t)return e;const n=i(t.semver,e.semver,r);return n<0?t:n>0||"<"===e.operator&&"<="===t.operator?e:t};return _e=(e,r,n={})=>{if(e===r)return!0;e=new t(e,n),r=new t(r,n);let i=!1;t:for(const t of e.set){for(const e of r.set){const r=a(t,e,n);if(i=i||null!==r,r)continue t}if(i)return!1}return!0}}();return Oe={parse:i,valid:s,clean:o,inc:a,diff:l,major:h,minor:c,patch:u,prerelease:p,compare:m,rcompare:d,compareLoose:f,compareBuild:g,sort:E,rsort:_,gt:v,lt:O,eq:A,neq:$,gte:C,lte:w,cmp:b,coerce:I,truncate:y,Comparator:S,Range:R,satisfies:T,toComparators:N,maxSatisfying:L,minSatisfying:x,minVersion:P,validRange:k,outside:H,gtr:D,ltr:F,intersects:G,simplifyRange:V,subset:M,SemVer:r,re:t.re,src:t.src,tokens:t.t,SEMVER_SPEC_VERSION:e.SEMVER_SPEC_VERSION,RELEASE_TYPES:e.RELEASE_TYPES,compareIdentifiers:n.compareIdentifiers,rcompareIdentifiers:n.rcompareIdentifiers}}(),Xe=o(We);const qe=r.resolve(__dirname,".."),Be=JSON.parse(n.readFileSync(r.join(qe,"package.json"),"utf8")),Ye=process.env.TASK_HANDOFF_NPM_COMMAND||"npm",Ke=function(t){const e=Xe.prerelease(t)?.[0];return"alpha"===e||"beta"===e?e:"stable"}(Be.version);function ze(t,r,n={}){const i=e.spawnSync(t,r,{encoding:"utf8",...n});if(0!==i.status){const e=[i.stdout,i.stderr].filter(Boolean).join("\n").trim();throw new Error(`${t} ${r.join(" ")} failed${e?`:\n${e}`:""}`)}return String(i.stdout||"").trim()}function Je(t){const e={};if(!n.existsSync(t))return e;for(const r of n.readFileSync(t,"utf8").split(/\r?\n/)){if(!r||r.startsWith("#"))continue;const t=r.indexOf("=");t>0&&(e[r.slice(0,t)]=r.slice(t+1))}return e}function Ze(){const t="/etc/systemd/system/task-handoff-node-agent.service";return n.existsSync(t)&&n.readFileSync(t,"utf8").match(/^User=(.+)$/m)?.[1]||"root"}function Qe(){const t=Je("/etc/task-handoff/control-plane.env"),e=Je("/etc/task-handoff/node-agent.env");return["--service-user",Ze(),"--control-plane-data-dir",t.TASK_HANDOFF_CONTROL_PLANE_DATA_DIR||"/var/lib/task-handoff/control-plane","--node-agent-data-dir",e.TASK_HANDOFF_NODE_AGENT_DATA_DIR||"/var/lib/task-handoff/node-agent","--control-plane-host",t.TASK_HANDOFF_CONTROL_PLANE_HOST||"0.0.0.0","--control-plane-port",t.TASK_HANDOFF_CONTROL_PLANE_PORT||"8081","--node-agent-host",e.TASK_HANDOFF_NODE_AGENT_HOST||"127.0.0.1","--node-agent-port",e.TASK_HANDOFF_NODE_AGENT_PORT||"8091","--node-agent-ipc-path",e.TASK_HANDOFF_NODE_AGENT_IPC_PATH||"/run/task-handoff/node-agent.sock","--auth-mode",t.TASK_HANDOFF_CONTROL_PLANE_AUTH_MODE||"password"]}function tr(t){const r=e.spawnSync("systemctl",["is-active",t],{encoding:"utf8"});return String(r.stdout||"unknown").trim()||"unknown"}async function er(t){or();const e=Qe(),r=e[e.indexOf("--node-agent-ipc-path")+1],n=Number(e[e.indexOf("--control-plane-port")+1]);if("stop"===t)return ze("systemctl",["stop","task-handoff-control-plane.service"],{stdio:"inherit"}),ze("systemctl",["stop","task-handoff-node-agent.service"],{stdio:"inherit"}),void console.log("Stopped TaskHandoff server services.");ze("systemctl",[t,"task-handoff-node-agent.service"],{stdio:"inherit"}),ar(r),ze("systemctl",[t,"task-handoff-control-plane.service"],{stdio:"inherit"}),await lr(n),console.log(("start"===t?"Started":"Restarted")+" TaskHandoff server services.")}function rr(t,e){return e||("stable"===t?"latest":t)}function nr(t){if((e=t).trim()!==e||/^[v=]/.test(e)||null===Xe.valid(e))throw new x("must be an exact semantic version");var e;return t}function ir(){return new D("--channel <channel>","stable, beta, or alpha").choices(["stable","beta","alpha"]).default(Ke).conflicts("to")}function sr(t,e){const r=["view",`@task-handoff/server@${t}`,"version","--json"];e&&r.push("--registry",e);const n=JSON.parse(ze(Ye,r));if("string"!=typeof n)throw new Error(`npm target ${t} did not resolve to one version.`);return n}function or(){if("function"==typeof process.getuid&&0!==process.getuid())throw new Error("Run this command as root so system packages and services can be changed.")}function ar(t,e=3e4){const r=Date.now()+e;for(;Date.now()<r;){try{if(n.statSync(t).isSocket())return}catch{}Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,250)}throw new Error(`Node agent socket was not ready after ${e}ms: ${t}`)}function lr(t,e=3e4){return new Promise((r,n)=>{const i=Date.now()+e,o=()=>{const e=s.get({host:"127.0.0.1",port:t,path:"/api/health",timeout:1e3},t=>{if(t.resume(),200===t.statusCode)return r();a()});e.on("timeout",()=>e.destroy()),e.on("error",a)},a=()=>Date.now()>=i?n(new Error(`Control plane was not healthy on port ${t} after ${e}ms.`)):setTimeout(o,250);o()})}function hr(t){return[["--service-user",t.serviceUser],["--control-plane-data-dir",t.controlPlaneDataDir],["--node-agent-data-dir",t.nodeAgentDataDir],["--control-plane-host",t.controlPlaneHost],["--control-plane-port",t.controlPlanePort],["--node-agent-host",t.nodeAgentHost],["--node-agent-port",t.nodeAgentPort],["--node-agent-ipc-path",t.nodeAgentIpcPath],["--auth-mode",t.authMode],["--static-dir",t.staticDir]].flatMap(([t,e])=>void 0===e?[]:[t,e])}(async function(){const t=(new k).name("task-handoff").description("Manage a TaskHandoff server and run its installed runtimes.").version(Be.version).showSuggestionAfterError();t.command("control-plane","Run the installed control-plane runtime.",{executableFile:"task-handoff-control-plane"}),t.command("node-agent","Run the installed node-agent runtime.",{executableFile:"task-handoff-node-agent"}),t.command("controlled-instance","Run the installed controlled-instance runtime.",{executableFile:"task-handoff-controlled-instance"}),t.command("install").description("Install or regenerate the server systemd services.").option("--service-user <user>").option("--control-plane-data-dir <path>").option("--node-agent-data-dir <path>").option("--control-plane-host <host>").option("--control-plane-port <port>").option("--node-agent-host <host>").option("--node-agent-port <port>").option("--node-agent-ipc-path <path>").option("--auth-mode <mode>").option("--static-dir <path>").action(t=>{or(),ze(process.execPath,[r.join(qe,"bin","task-handoff-install-server"),...hr(t)],{stdio:"inherit"})}),t.command("status").description("Show the installed version and service state.").action(()=>{console.log(`Package: @task-handoff/server ${Be.version}`),console.log(`Node agent: ${tr("task-handoff-node-agent.service")}`),console.log(`Control plane: ${tr("task-handoff-control-plane.service")}`)}),t.command("start").description("Start the node agent and control plane services.").action(()=>er("start")),t.command("stop").description("Stop the control plane and node agent services.").action(()=>er("stop")),t.command("restart").description("Restart the node agent and control plane services safely.").action(()=>er("restart")),t.command("check").description("Check npm for an available server version.").addOption(ir()).option("--registry <url>").action(t=>{const e=rr(t.channel),r=sr(e,t.registry);console.log(`Installed: ${Be.version}`),console.log(`Available (${t.channel} channel, npm ${e}): ${r}`),console.log(r===Be.version?"Up to date.":`Update available: task-handoff update --to ${r}`)}),t.command("update").description("Update the server package set and restart services safely.").addOption(ir()).option("--to <version>","exact semantic version",nr).option("--registry <url>").option("--force").action(async t=>{or();const e=rr(t.channel,t.to),i=e===Be.version?Be.version:sr(e,t.registry);if(i===Be.version&&!t.force)return void console.log(`@task-handoff/server ${Be.version} is already installed.`);const s=function(){const t="/run/task-handoff-server-update.lock";try{n.mkdirSync(t)}catch(t){if("EEXIST"===t?.code)throw new Error("Another TaskHandoff server update is already running.");throw t}return()=>n.rmSync(t,{recursive:!0,force:!0})}();try{const e=function(){let t=qe;for(;t!==r.dirname(t);){if("node_modules"===r.basename(t)&&"lib"===r.basename(r.dirname(t)))return r.dirname(r.dirname(t));t=r.dirname(t)}throw new Error(`Cannot determine the npm global prefix from ${qe}.`)}(),n=Qe(),s=n[n.indexOf("--node-agent-ipc-path")+1],o=Number(n[n.indexOf("--control-plane-port")+1]),a=["install","--global","--prefix",e,`@task-handoff/server@${i}`];t.registry&&a.push("--registry",t.registry),console.log(`Updating @task-handoff/server ${Be.version} -> ${i}`),ze(Ye,a,{stdio:"inherit"}),ze(r.join(e,"bin","task-handoff"),["install",...n],{stdio:"inherit"}),ze("systemctl",["restart","task-handoff-node-agent.service"]),ar(s),ze("systemctl",["restart","task-handoff-control-plane.service"]),await lr(o),console.log(`Updated TaskHandoff server to ${i}.`)}catch(t){throw console.error(`Update failed. To reinstall the previous version, run: npm install -g @task-handoff/server@${Be.version}`),t}finally{s()}}),await t.parseAsync(process.argv)})().catch(t=>{console.error(`Error: ${t instanceof Error?t.message:String(t)}`),process.exitCode=1});
|
|
1
|
+
"use strict";var t=require("node:events"),e=require("node:child_process"),r=require("node:path"),n=require("node:fs"),i=require("node:process"),s=require("node:http"),o=require("node:os"),a=require("node:crypto");function l(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var c,h,u={},p={},d={};function m(){if(c)return d;c=1;class t extends Error{constructor(t,e,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}}return d.CommanderError=t,d.InvalidArgumentError=class extends t{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},d}function f(){if(h)return p;h=1;const{InvalidArgumentError:t}=m();return p.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.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?(e.push(t),e):[t]}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,r)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(e,r):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},p.humanReadableArgName=function(t){const e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"},p}var g,E={},_={};function v(){if(g)return _;g=1;const{humanReadableArgName:t}=f();function e(t){return t.replace(/\x1b\[\d*(;\d*)*m/g,"")}return _.Help=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){const e=t.commands.filter(t=>!t._hidden),r=t._getHelpCommand();return r&&!r._hidden&&e.push(r),this.sortSubcommands&&e.sort((t,e)=>t.name().localeCompare(e.name())),e}compareOptions(t,e){const r=t=>t.short?t.short.replace(/^-/,""):t.long.replace(/^--/,"");return r(t).localeCompare(r(e))}visibleOptions(t){const e=t.options.filter(t=>!t.hidden),r=t._getHelpOption();if(r&&!r.hidden){const n=r.short&&t._findOption(r.short),i=r.long&&t._findOption(r.long);n||i?r.long&&!i?e.push(t.createOption(r.long,r.description)):r.short&&!n&&e.push(t.createOption(r.short,r.description)):e.push(r)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const e=[];for(let r=t.parent;r;r=r.parent){const t=r.options.filter(t=>!t.hidden);e.push(...t)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(t=>t.description)?t.registeredArguments:[]}subcommandTerm(e){const r=e.registeredArguments.map(e=>t(e)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((t,r)=>Math.max(t,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(r)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((t,r)=>Math.max(t,this.displayWidth(e.styleOptionTerm(e.optionTerm(r)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((t,r)=>Math.max(t,this.displayWidth(e.styleOptionTerm(e.optionTerm(r)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((t,r)=>Math.max(t,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(r)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let r="";for(let e=t.parent;e;e=e.parent)r=e.name()+" "+r;return r+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(t=>JSON.stringify(t)).join(", ")}`),void 0!==t.defaultValue&&(t.required||t.optional||t.isBoolean()&&"boolean"==typeof t.defaultValue)&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),void 0!==t.presetArg&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),void 0!==t.envVar&&e.push(`env: ${t.envVar}`),e.length>0){const r=`(${e.join(", ")})`;return t.description?`${t.description} ${r}`:r}return 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 r=`(${e.join(", ")})`;return t.description?`${t.description} ${r}`:r}return t.description}formatItemList(t,e,r){return 0===e.length?[]:[r.styleTitle(t),...e,""]}groupItems(t,e,r){const n=new Map;return t.forEach(t=>{const e=r(t);n.has(e)||n.set(e,[])}),e.forEach(t=>{const e=r(t);n.has(e)||n.set(e,[]),n.get(e).push(t)}),n}formatHelp(t,e){const r=e.padWidth(t,e),n=e.helpWidth??80;function i(t,n){return e.formatItem(t,r,n,e)}let s=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""];const o=e.commandDescription(t);o.length>0&&(s=s.concat([e.boxWrap(e.styleCommandDescription(o),n),""]));const a=e.visibleArguments(t).map(t=>i(e.styleArgumentTerm(e.argumentTerm(t)),e.styleArgumentDescription(e.argumentDescription(t))));s=s.concat(this.formatItemList("Arguments:",a,e));const l=this.groupItems(t.options,e.visibleOptions(t),t=>t.helpGroupHeading??"Options:");if(l.forEach((t,r)=>{const n=t.map(t=>i(e.styleOptionTerm(e.optionTerm(t)),e.styleOptionDescription(e.optionDescription(t))));s=s.concat(this.formatItemList(r,n,e))}),e.showGlobalOptions){const r=e.visibleGlobalOptions(t).map(t=>i(e.styleOptionTerm(e.optionTerm(t)),e.styleOptionDescription(e.optionDescription(t))));s=s.concat(this.formatItemList("Global Options:",r,e))}return this.groupItems(t.commands,e.visibleCommands(t),t=>t.helpGroup()||"Commands:").forEach((t,r)=>{const n=t.map(t=>i(e.styleSubcommandTerm(e.subcommandTerm(t)),e.styleSubcommandDescription(e.subcommandDescription(t))));s=s.concat(this.formatItemList(r,n,e))}),s.join("\n")}displayWidth(t){return e(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(t=>"[options]"===t?this.styleOptionText(t):"[command]"===t?this.styleSubcommandText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(t=>"[options]"===t?this.styleOptionText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,e,r,n){const i=" ".repeat(2);if(!r)return i+t;const s=t.padEnd(e+t.length-n.displayWidth(t)),o=(this.helpWidth??80)-e-2-2;let a;return a=o<this.minWidthToWrap||n.preformatted(r)?r:n.boxWrap(r,o).replace(/\n/g,"\n"+" ".repeat(e+2)),i+s+" ".repeat(2)+a.replace(/\n/g,`\n${i}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;const r=t.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,i=[];return r.forEach(t=>{const r=t.match(n);if(null===r)return void i.push("");let s=[r.shift()],o=this.displayWidth(s[0]);r.forEach(t=>{const r=this.displayWidth(t);if(o+r<=e)return s.push(t),void(o+=r);i.push(s.join(""));const n=t.trimStart();s=[n],o=this.displayWidth(n)}),i.push(s.join(""))}),i.join("\n")}},_.stripColor=e,_}var O,A={};function $(){if(O)return A;O=1;const{InvalidArgumentError:t}=m();function e(t){return t.split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}return A.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 r=function(t){let e,r;const n=/^-[^-]$/,i=/^--[^-]/,s=t.split(/[ |,]+/).concat("guard");if(n.test(s[0])&&(e=s.shift()),i.test(s[0])&&(r=s.shift()),!e&&n.test(s[0])&&(e=s.shift()),!e&&i.test(s[0])&&(e=r,r=s.shift()),s[0].startsWith("-")){const e=s[0],r=`option creation failed due to '${e}' in option flags '${t}'`;if(/^-[^-][^-]/.test(e))throw new Error(`${r}\n- a short flag is a single dash and a single character\n - either use a single dash and a single character (for a short flag)\n - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(n.test(e))throw new Error(`${r}\n- too many short flags`);if(i.test(e))throw new Error(`${r}\n- too many long flags`);throw new Error(`${r}\n- unrecognised flag format`)}if(void 0===e&&void 0===r)throw new Error(`option creation failed due to no flags found in '${t}'.`);return{shortFlag:e,longFlag:r}}(t);this.short=r.shortFlag,this.long=r.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let e=t;return"string"==typeof t&&(e={[t]:!0}),this.implied=Object.assign(this.implied||{},e),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_collectValue(t,e){return e!==this.defaultValue&&Array.isArray(e)?(e.push(t),e):[t]}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,r)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(e,r):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?e(this.name().replace(/^no-/,"")):e(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},A.DualOptions=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,e)=>{this.positiveOptions.has(e)&&this.dualOptions.add(e)})}valueFromOption(t,e){const r=e.attributeName();if(!this.dualOptions.has(r))return!0;const n=this.negativeOptions.get(r).presetArg,i=void 0!==n&&n;return e.negate===(i===t)}},A}var w,C,y,S={};function I(){return w||(w=1,S.suggestSimilar=function(t,e){if(!e||0===e.length)return"";e=Array.from(new Set(e));const r=t.startsWith("--");r&&(t=t.slice(2),e=e.map(t=>t.slice(2)));let n=[],i=3;return e.forEach(e=>{if(e.length<=1)return;const r=function(t,e){if(Math.abs(t.length-e.length)>3)return Math.max(t.length,e.length);const r=[];for(let e=0;e<=t.length;e++)r[e]=[e];for(let t=0;t<=e.length;t++)r[0][t]=t;for(let n=1;n<=e.length;n++)for(let i=1;i<=t.length;i++){let s=1;s=t[i-1]===e[n-1]?0:1,r[i][n]=Math.min(r[i-1][n]+1,r[i][n-1]+1,r[i-1][n-1]+s),i>1&&n>1&&t[i-1]===e[n-2]&&t[i-2]===e[n-1]&&(r[i][n]=Math.min(r[i][n],r[i-2][n-2]+1))}return r[t.length][e.length]}(t,e),s=Math.max(t.length,e.length);(s-r)/s>.4&&(r<i?(i=r,n=[e]):r===i&&n.push(e))}),n.sort((t,e)=>t.localeCompare(e)),r&&(n=n.map(t=>`--${t}`)),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""}),S}var b=function(){if(y)return u;y=1;const{Argument:s}=f(),{Command:o}=function(){if(C)return E;C=1;const s=t.EventEmitter,o=e,a=r,l=n,c=i,{Argument:h,humanReadableArgName:u}=f(),{CommanderError:p}=m(),{Help:d,stripColor:g}=v(),{Option:_,DualOptions:O}=$(),{suggestSimilar:A}=I();class w extends s{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>c.stdout.write(t),writeErr:t=>c.stderr.write(t),outputError:(t,e)=>e(t),getOutHelpWidth:()=>c.stdout.isTTY?c.stdout.columns:void 0,getErrHelpWidth:()=>c.stderr.isTTY?c.stderr.columns:void 0,getOutHasColors:()=>S()??(c.stdout.isTTY&&c.stdout.hasColors?.()),getErrHasColors:()=>S()??(c.stderr.isTTY&&c.stderr.hasColors?.()),stripColor:t=>g(t)},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(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){const t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,r){let n=e,i=r;"object"==typeof n&&null!==n&&(i=n,n=null),i=i||{};const[,s,o]=t.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return n&&(a.description(n),a._executableHandler=!0),i.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!i.noHelp&&!i.hidden),a._executableFile=i.executableFile||null,o&&a.arguments(o),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(t){return new w(t)}createHelp(){return Object.assign(new d,this.configureHelp())}configureHelp(t){return void 0===t?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return void 0===t?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...t},this)}showHelpAfterError(t=!0){return"string"!=typeof t&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(e=e||{}).isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new h(t,e)}argument(t,e,r,n){const i=this.createArgument(t,e);return"function"==typeof r?i.default(n).argParser(r):i.default(r),this.addArgument(i),this}arguments(t){return t.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(t){const e=this.registeredArguments.slice(-1)[0];if(e?.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&void 0!==t.defaultValue&&void 0===t.parseArg)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,e){if("boolean"==typeof t)return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;const r=t??"help [command]",[,n,i]=r.match(/([^ ]+) *(.*)/),s=e??"display help for command",o=this.createCommand(n);return o.helpOption(!1),i&&o.arguments(i),s&&o.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=o,(t||e)&&this._initCommandGroup(o),this}addHelpCommand(t,e){return"object"!=typeof t?(this.helpCommand(t,e),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(void 0===this._helpCommand&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,e){const r=["preSubcommand","preAction","postAction"];if(!r.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.\nExpecting one of '${r.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,r){this._exitCallback&&this._exitCallback(new p(t,e,r)),c.exit(t)}action(t){return this._actionHandler=e=>{const r=this.registeredArguments.length,n=e.slice(0,r);return this._storeOptionsAsProperties?n[r]=this:n[r]=this.opts(),n.push(this),t.apply(this,n)},this}createOption(t,e){return new _(t,e)}_callParseArg(t,e,r,n){try{return t.parseArg(e,r)}catch(t){if("commander.invalidArgument"===t.code){const e=`${n} ${t.message}`;this.error(e,{exitCode:t.exitCode,code:t.code})}throw t}}_registerOption(t){const e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){const r=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'\n- already used by option '${e.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){const e=t=>[t.name()].concat(t.aliases()),r=e(t).find(t=>this._findCommand(t));if(r){const n=e(this._findCommand(r)).join("|"),i=e(t).join("|");throw new Error(`cannot add command '${i}' as already have command '${n}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);const e=t.name(),r=t.attributeName();if(t.negate){const e=t.long.replace(/^--no-/,"--");this._findOption(e)||this.setOptionValueWithSource(r,void 0===t.defaultValue||t.defaultValue,"default")}else void 0!==t.defaultValue&&this.setOptionValueWithSource(r,t.defaultValue,"default");const n=(e,n,i)=>{null==e&&void 0!==t.presetArg&&(e=t.presetArg);const s=this.getOptionValue(r);null!==e&&t.parseArg?e=this._callParseArg(t,e,s,n):null!==e&&t.variadic&&(e=t._collectValue(e,s)),null==e&&(e=!t.negate&&(!(!t.isBoolean()&&!t.optional)||"")),this.setOptionValueWithSource(r,e,i)};return this.on("option:"+e,e=>{const r=`error: option '${t.flags}' argument '${e}' is invalid.`;n(e,r,"cli")}),t.envVar&&this.on("optionEnv:"+e,e=>{const r=`error: option '${t.flags}' value '${e}' from env '${t.envVar}' is invalid.`;n(e,r,"env")}),this}_optionEx(t,e,r,n,i){if("object"==typeof e&&e instanceof _)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const s=this.createOption(e,r);if(s.makeOptionMandatory(!!t.mandatory),"function"==typeof n)s.default(i).argParser(n);else if(n instanceof RegExp){const t=n;n=(e,r)=>{const n=t.exec(e);return n?n[0]:r},s.default(i).argParser(n)}else s.default(n);return this.addOption(s)}option(t,e,r,n){return this._optionEx({},t,e,r,n)}requiredOption(t,e,r,n){return this._optionEx({mandatory:!0},t,e,r,n)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,r){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=r,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(r=>{void 0!==r.getOptionValueSource(t)&&(e=r.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){if(void 0!==t&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(e=e||{},void 0===t&&void 0===e.from){c.versions?.electron&&(e.from="electron");const t=c.execArgv??[];(t.includes("-e")||t.includes("--eval")||t.includes("-p")||t.includes("--print"))&&(e.from="eval")}let r;switch(void 0===t&&(t=c.argv),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],r=t.slice(2);break;case"electron":c.defaultApp?(this._scriptPath=t[1],r=t.slice(2)):r=t.slice(1);break;case"user":r=t.slice(0);break;case"eval":r=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(t,e){this._prepareForParse();const r=this._prepareUserArgs(t,e);return this._parseCommand([],r),this}async parseAsync(t,e){this._prepareForParse();const r=this._prepareUserArgs(t,e);return await this._parseCommand([],r),this}_prepareForParse(){null===this._savedState?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error("Can not call parse again when storeOptionsAsProperties is true.\n- either make a new Command for each call to parse, or stop storing options as properties");this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,e,r){if(!l.existsSync(t))throw new Error(`'${t}' does not exist\n - if '${r}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${e?`searched for local subcommand relative to directory '${e}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory"}`)}_executeSubCommand(t,e){e=e.slice();let r=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function i(t,e){const r=a.resolve(t,e);if(l.existsSync(r))return r;if(n.includes(a.extname(e)))return;const i=n.find(t=>l.existsSync(`${r}${t}`));return i?`${r}${i}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s,h=t._executableFile||`${this._name}-${t._name}`,u=this._executableDir||"";if(this._scriptPath){let t;try{t=l.realpathSync(this._scriptPath)}catch{t=this._scriptPath}u=a.resolve(a.dirname(t),u)}if(u){let e=i(u,h);if(!e&&!t._executableFile&&this._scriptPath){const r=a.basename(this._scriptPath,a.extname(this._scriptPath));r!==this._name&&(e=i(u,`${r}-${t._name}`))}h=e||h}r=n.includes(a.extname(h)),"win32"!==c.platform?r?(e.unshift(h),e=y(c.execArgv).concat(e),s=o.spawn(c.argv[0],e,{stdio:"inherit"})):s=o.spawn(h,e,{stdio:"inherit"}):(this._checkForMissingExecutable(h,u,t._name),e.unshift(h),e=y(c.execArgv).concat(e),s=o.spawn(c.execPath,e,{stdio:"inherit"})),s.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(t=>{c.on(t,()=>{!1===s.killed&&null===s.exitCode&&s.kill(t)})});const d=this._exitCallback;s.on("close",t=>{t=t??1,d?d(new p(t,"commander.executeSubCommandAsync","(close)")):c.exit(t)}),s.on("error",e=>{if("ENOENT"===e.code)this._checkForMissingExecutable(h,u,t._name);else if("EACCES"===e.code)throw new Error(`'${h}' not executable`);if(d){const t=new p(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,d(t)}else c.exit(1)}),this.runningCommand=s}_dispatchSubcommand(t,e,r){const n=this._findCommand(t);let i;return n||this.help({error:!0}),n._prepareForParse(),i=this._chainOrCallSubCommandHook(i,n,"preSubcommand"),i=this._chainOrCall(i,()=>{if(!n._executableHandler)return n._parseCommand(e,r);this._executeSubCommand(n,e.concat(r))}),i}_dispatchHelpCommand(t){t||this.help();const e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&null==this.args[e]&&this.missingArgument(t.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const t=(t,e,r)=>{let n=e;if(null!==e&&t.parseArg){const i=`error: command-argument value '${e}' is invalid for argument '${t.name()}'.`;n=this._callParseArg(t,e,r,i)}return n};this._checkNumberOfArguments();const e=[];this.registeredArguments.forEach((r,n)=>{let i=r.defaultValue;r.variadic?n<this.args.length?(i=this.args.slice(n),r.parseArg&&(i=i.reduce((e,n)=>t(r,n,e),r.defaultValue))):void 0===i&&(i=[]):n<this.args.length&&(i=this.args[n],r.parseArg&&(i=t(r,i,r.defaultValue))),e[n]=i}),this.processedArgs=e}_chainOrCall(t,e){return t?.then&&"function"==typeof t.then?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let r=t;const n=[];return this._getCommandAndAncestors().reverse().filter(t=>void 0!==t._lifeCycleHooks[e]).forEach(t=>{t._lifeCycleHooks[e].forEach(e=>{n.push({hookedCommand:t,callback:e})})}),"postAction"===e&&n.reverse(),n.forEach(t=>{r=this._chainOrCall(r,()=>t.callback(t.hookedCommand,this))}),r}_chainOrCallSubCommandHook(t,e,r){let n=t;return void 0!==this._lifeCycleHooks[r]&&this._lifeCycleHooks[r].forEach(t=>{n=this._chainOrCall(n,()=>t(this,e))}),n}_parseCommand(t,e){const r=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(r.operands),e=r.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(e),this._dispatchSubcommand(this._defaultCommandName,t,e);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),this._outputHelpIfRequested(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const n=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){let r;return n(),this._processArguments(),r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,()=>this._actionHandler(this.processedArgs)),this.parent&&(r=this._chainOrCall(r,()=>{this.parent.emit(i,t,e)})),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent?.listenerCount(i))n(),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():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&void 0===t.getOptionValue(e.attributeName())&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){const t=this.options.filter(t=>{const e=t.attributeName();return void 0!==this.getOptionValue(e)&&"default"!==this.getOptionValueSource(e)}),e=t.filter(t=>t.conflictsWith.length>0);e.forEach(e=>{const r=t.find(t=>e.conflictsWith.includes(t.attributeName()));r&&this._conflictingOption(e,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){const e=[],r=[];let n=e;function i(t){return t.length>1&&"-"===t[0]}const s=t=>!!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(t)&&!this._getCommandAndAncestors().some(t=>t.options.map(t=>t.short).some(t=>/^-\d$/.test(t)));let o=null,a=null,l=0;for(;l<t.length||a;){const c=a??t[l++];if(a=null,"--"===c){n===r&&n.push(c),n.push(...t.slice(l));break}if(!o||i(c)&&!s(c)){if(o=null,i(c)){const e=this._findOption(c);if(e){if(e.required){const r=t[l++];void 0===r&&this.optionMissingArgument(e),this.emit(`option:${e.name()}`,r)}else if(e.optional){let r=null;l<t.length&&(!i(t[l])||s(t[l]))&&(r=t[l++]),this.emit(`option:${e.name()}`,r)}else this.emit(`option:${e.name()}`);o=e.variadic?e:null;continue}}if(c.length>2&&"-"===c[0]&&"-"!==c[1]){const t=this._findOption(`-${c[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,c.slice(2)):(this.emit(`option:${t.name()}`),a=`-${c.slice(2)}`);continue}}if(/^--[^=]+=/.test(c)){const t=c.indexOf("="),e=this._findOption(c.slice(0,t));if(e&&(e.required||e.optional)){this.emit(`option:${e.name()}`,c.slice(t+1));continue}}if(n!==e||!i(c)||0===this.commands.length&&s(c)||(n=r),(this._enablePositionalOptions||this._passThroughOptions)&&0===e.length&&0===r.length){if(this._findCommand(c)){e.push(c),r.push(...t.slice(l));break}if(this._getHelpCommand()&&c===this._getHelpCommand().name()){e.push(c,...t.slice(l));break}if(this._defaultCommandName){r.push(c,...t.slice(l));break}}if(this._passThroughOptions){n.push(c,...t.slice(l));break}n.push(c)}else this.emit(`option:${o.name()}`,c)}return{operands:e,unknown:r}}opts(){if(this._storeOptionsAsProperties){const t={},e=this.options.length;for(let r=0;r<e;r++){const e=this.options[r].attributeName();t[e]=e===this._versionOptionName?this._version:this[e]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){this._outputConfiguration.outputError(`${t}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0}));const r=e||{},n=r.exitCode||1,i=r.code||"commander.error";this._exit(n,i,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in c.env){const e=t.attributeName();(void 0===this.getOptionValue(e)||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,c.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){const t=new O(this.options),e=t=>void 0!==this.getOptionValue(t)&&!["default","implied"].includes(this.getOptionValueSource(t));this.options.filter(r=>void 0!==r.implied&&e(r.attributeName())&&t.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(t=>{Object.keys(t.implied).filter(t=>!e(t)).forEach(e=>{this.setOptionValueWithSource(e,t.implied[e],"implied")})})}missingArgument(t){const e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){const r=t=>{const e=t.attributeName(),r=this.getOptionValue(e),n=this.options.find(t=>t.negate&&e===t.attributeName()),i=this.options.find(t=>!t.negate&&e===t.attributeName());return n&&(void 0===n.presetArg&&!1===r||void 0!==n.presetArg&&r===n.presetArg)?n:i||t},n=t=>{const e=r(t),n=e.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${e.envVar}'`:`option '${e.flags}'`},i=`error: ${n(t)} cannot be used with ${n(e)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let r=[],n=this;do{const t=n.createHelp().visibleOptions(n).filter(t=>t.long).map(t=>t.long);r=r.concat(t),n=n.parent}while(n&&!n._enablePositionalOptions);e=A(t,r)}const r=`error: unknown option '${t}'${e}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const e=this.registeredArguments.length,r=1===e?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${r} but got ${t.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const r=[];this.createHelp().visibleCommands(this).forEach(t=>{r.push(t.name()),t.alias()&&r.push(t.alias())}),e=A(t,r)}const r=`error: unknown command '${t}'${e}`;this.error(r,{code:"commander.unknownCommand"})}version(t,e,r){if(void 0===t)return this._version;this._version=t,e=e||"-V, --version",r=r||"output the version number";const n=this.createOption(e,r);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}\n`),this._exit(0,"commander.version",t)}),this}description(t,e){return void 0===t&&void 0===e?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return void 0===t?this._summary:(this._summary=t,this)}alias(t){if(void 0===t)return this._aliases[0];let e=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");const r=this.parent?._findCommand(t);if(r){const e=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${e}'`)}return e._aliases.push(t),this}aliases(t){return void 0===t?this._aliases:(t.forEach(t=>this.alias(t)),this)}usage(t){if(void 0===t){if(this._usage)return this._usage;const t=this.registeredArguments.map(t=>u(t));return[].concat(this.options.length||null!==this._helpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=t,this}name(t){return void 0===t?this._name:(this._name=t,this)}helpGroup(t){return void 0===t?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return void 0===t?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return void 0===t?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=a.basename(t,a.extname(t)),this}executableDir(t){return void 0===t?this._executableDir:(this._executableDir=t,this)}helpInformation(t){const e=this.createHelp(),r=this._getOutputContext(t);e.prepareContext({error:r.error,helpWidth:r.helpWidth,outputHasColors:r.hasColors});const n=e.formatHelp(this,e);return r.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(t){const e=!!(t=t||{}).error;let r,n,i;return e?(r=t=>this._outputConfiguration.writeErr(t),n=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(r=t=>this._outputConfiguration.writeOut(t),n=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:e,write:t=>(n||(t=this._outputConfiguration.stripColor(t)),r(t)),hasColors:n,helpWidth:i}}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const r=this._getOutputContext(t),n={error:r.error,write:r.write,command:this};this._getCommandAndAncestors().reverse().forEach(t=>t.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let i=this.helpInformation({error:r.error});if(e&&(i=e(i),"string"!=typeof i&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(t=>t.emit("afterAllHelp",n))}helpOption(t,e){return"boolean"==typeof t?(t?(null===this._helpOption&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",e??"display help for command"),(t||e)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return void 0===this._helpOption&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let e=Number(c.exitCode??0);0===e&&t&&"function"!=typeof t&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const r=["beforeAll","before","after","afterAll"];if(!r.includes(t))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${r.join("', '")}'`);const n=`${t}Help`;return this.on(n,t=>{let r;r="function"==typeof e?e({error:t.error,command:t.command}):e,r&&t.write(`${r}\n`)}),this}_outputHelpIfRequested(t){const e=this._getHelpOption();e&&t.find(t=>e.is(t))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}}function y(t){return t.map(t=>{if(!t.startsWith("--inspect"))return t;let e,r,n="127.0.0.1",i="9229";return null!==(r=t.match(/^(--inspect(-brk)?)$/))?e=r[1]:null!==(r=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(e=r[1],/^\d+$/.test(r[3])?i=r[3]:n=r[3]):null!==(r=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(e=r[1],n=r[3],i=r[4]),e&&"0"!==i?`${e}=${n}:${parseInt(i)+1}`:t})}function S(){return!c.env.NO_COLOR&&"0"!==c.env.FORCE_COLOR&&"false"!==c.env.FORCE_COLOR&&(!(!c.env.FORCE_COLOR&&void 0===c.env.CLICOLOR_FORCE)||void 0)}return E.Command=w,E.useColor=S,E}(),{CommanderError:a,InvalidArgumentError:l}=m(),{Help:c}=v(),{Option:h}=$();return u.program=new o,u.createCommand=t=>new o(t),u.createOption=(t,e)=>new h(t,e),u.createArgument=(t,e)=>new s(t,e),u.Command=o,u.Option=h,u.Argument=s,u.Help=c,u.CommanderError=a,u.InvalidArgumentError=l,u.InvalidOptionArgumentError=l,u}(),N=l(b);const{program:T,createCommand:R,createArgument:L,createOption:k,CommanderError:x,InvalidArgumentError:P,InvalidOptionArgumentError:D,Command:H,Argument:F,Option:G,Help:V}=N;var M,j,U,W,X,q,B,Y,J,z,K,Z,Q,tt,et,rt,nt,it,st,ot,at,lt,ct,ht,ut,pt,dt,mt,ft,gt,Et,_t,vt,Ot,At,$t,wt,Ct,yt,St,It,bt,Nt,Tt,Rt,Lt,kt,xt,Pt,Dt,Ht,Ft,Gt,Vt,Mt,jt,Ut,Wt,Xt,qt,Bt,Yt,Jt,zt,Kt,Zt,Qt,te,ee,re,ne,ie,se,oe,ae,le,ce,he,ue,pe,de,me,fe,ge,Ee,_e,ve,Oe,Ae,$e,we,Ce={exports:{}};function ye(){if(j)return M;j=1;const t=Number.MAX_SAFE_INTEGER||9007199254740991;return M={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}function Se(){if(W)return U;W=1;const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{};return U=t}function Ie(){return X||(X=1,function(t,e){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=ye(),s=Se(),o=(e=t.exports={}).re=[],a=e.safeRe=[],l=e.src=[],c=e.safeSrc=[],h=e.t={};let u=0;const p="[a-zA-Z0-9-]",d=[["\\s",1],["\\d",i],[p,n]],m=(t,e,r)=>{const n=(t=>{for(const[e,r]of d)t=t.split(`${e}*`).join(`${e}{0,${r}}`).split(`${e}+`).join(`${e}{1,${r}}`);return t})(e),i=u++;s(t,i,e),h[t]=i,l[i]=e,c[i]=n,o[i]=new RegExp(e,r?"g":void 0),a[i]=new RegExp(n,r?"g":void 0)};m("NUMERICIDENTIFIER","0|[1-9]\\d*"),m("NUMERICIDENTIFIERLOOSE","\\d+"),m("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${p}*`),m("MAINVERSION",`(${l[h.NUMERICIDENTIFIER]})\\.(${l[h.NUMERICIDENTIFIER]})\\.(${l[h.NUMERICIDENTIFIER]})`),m("MAINVERSIONLOOSE",`(${l[h.NUMERICIDENTIFIERLOOSE]})\\.(${l[h.NUMERICIDENTIFIERLOOSE]})\\.(${l[h.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASEIDENTIFIER",`(?:${l[h.NONNUMERICIDENTIFIER]}|${l[h.NUMERICIDENTIFIER]})`),m("PRERELEASEIDENTIFIERLOOSE",`(?:${l[h.NONNUMERICIDENTIFIER]}|${l[h.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASE",`(?:-(${l[h.PRERELEASEIDENTIFIER]}(?:\\.${l[h.PRERELEASEIDENTIFIER]})*))`),m("PRERELEASELOOSE",`(?:-?(${l[h.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[h.PRERELEASEIDENTIFIERLOOSE]})*))`),m("BUILDIDENTIFIER",`${p}+`),m("BUILD",`(?:\\+(${l[h.BUILDIDENTIFIER]}(?:\\.${l[h.BUILDIDENTIFIER]})*))`),m("FULLPLAIN",`v?${l[h.MAINVERSION]}${l[h.PRERELEASE]}?${l[h.BUILD]}?`),m("FULL",`^${l[h.FULLPLAIN]}$`),m("LOOSEPLAIN",`[v=\\s]*${l[h.MAINVERSIONLOOSE]}${l[h.PRERELEASELOOSE]}?${l[h.BUILD]}?`),m("LOOSE",`^${l[h.LOOSEPLAIN]}$`),m("GTLT","((?:<|>)?=?)"),m("XRANGEIDENTIFIERLOOSE",`${l[h.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),m("XRANGEIDENTIFIER",`${l[h.NUMERICIDENTIFIER]}|x|X|\\*`),m("XRANGEPLAIN",`[v=\\s]*(${l[h.XRANGEIDENTIFIER]})(?:\\.(${l[h.XRANGEIDENTIFIER]})(?:\\.(${l[h.XRANGEIDENTIFIER]})(?:${l[h.PRERELEASE]})?${l[h.BUILD]}?)?)?`),m("XRANGEPLAINLOOSE",`[v=\\s]*(${l[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[h.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[h.XRANGEIDENTIFIERLOOSE]})(?:${l[h.PRERELEASELOOSE]})?${l[h.BUILD]}?)?)?`),m("XRANGE",`^${l[h.GTLT]}\\s*${l[h.XRANGEPLAIN]}$`),m("XRANGELOOSE",`^${l[h.GTLT]}\\s*${l[h.XRANGEPLAINLOOSE]}$`),m("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),m("COERCE",`${l[h.COERCEPLAIN]}(?:$|[^\\d])`),m("COERCEFULL",l[h.COERCEPLAIN]+`(?:${l[h.PRERELEASE]})?`+`(?:${l[h.BUILD]})?(?:$|[^\\d])`),m("COERCERTL",l[h.COERCE],!0),m("COERCERTLFULL",l[h.COERCEFULL],!0),m("LONETILDE","(?:~>?)"),m("TILDETRIM",`(\\s*)${l[h.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",m("TILDE",`^${l[h.LONETILDE]}${l[h.XRANGEPLAIN]}$`),m("TILDELOOSE",`^${l[h.LONETILDE]}${l[h.XRANGEPLAINLOOSE]}$`),m("LONECARET","(?:\\^)"),m("CARETTRIM",`(\\s*)${l[h.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",m("CARET",`^${l[h.LONECARET]}${l[h.XRANGEPLAIN]}$`),m("CARETLOOSE",`^${l[h.LONECARET]}${l[h.XRANGEPLAINLOOSE]}$`),m("COMPARATORLOOSE",`^${l[h.GTLT]}\\s*(${l[h.LOOSEPLAIN]})$|^$`),m("COMPARATOR",`^${l[h.GTLT]}\\s*(${l[h.FULLPLAIN]})$|^$`),m("COMPARATORTRIM",`(\\s*)${l[h.GTLT]}\\s*(${l[h.LOOSEPLAIN]}|${l[h.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",m("HYPHENRANGE",`^\\s*(${l[h.XRANGEPLAIN]})\\s+-\\s+(${l[h.XRANGEPLAIN]})\\s*$`),m("HYPHENRANGELOOSE",`^\\s*(${l[h.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[h.XRANGEPLAINLOOSE]})\\s*$`),m("STAR","(<|>)?=?\\s*\\*"),m("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),m("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(Ce,Ce.exports)),Ce.exports}function be(){if(B)return q;B=1;const t=Object.freeze({loose:!0}),e=Object.freeze({});return q=r=>r?"object"!=typeof r?t:r:e}function Ne(){if(J)return Y;J=1;const t=/^[0-9]+$/,e=(e,r)=>{if("number"==typeof e&&"number"==typeof r)return e===r?0:e<r?-1:1;const n=t.test(e),i=t.test(r);return n&&i&&(e=+e,r=+r),e===r?0:n&&!i?-1:i&&!n?1:e<r?-1:1};return Y={compareIdentifiers:e,rcompareIdentifiers:(t,r)=>e(r,t)}}function Te(){if(K)return z;K=1;const t=Se(),{MAX_LENGTH:e,MAX_SAFE_INTEGER:r}=ye(),{safeRe:n,t:i}=Ie(),s=be(),{compareIdentifiers:o}=Ne();class a{constructor(o,l){if(l=s(l),o instanceof a){if(o.loose===!!l.loose&&o.includePrerelease===!!l.includePrerelease)return o;o=o.version}else if("string"!=typeof o)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof o}".`);if(o.length>e)throw new TypeError(`version is longer than ${e} characters`);t("SemVer",o,l),this.options=l,this.loose=!!l.loose,this.includePrerelease=!!l.includePrerelease;const c=o.trim().match(l.loose?n[i.LOOSE]:n[i.FULL]);if(!c)throw new TypeError(`Invalid Version: ${o}`);if(this.raw=o,this.major=+c[1],this.minor=+c[2],this.patch=+c[3],this.major>r||this.major<0)throw new TypeError("Invalid major version");if(this.minor>r||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>r||this.patch<0)throw new TypeError("Invalid patch version");c[4]?this.prerelease=c[4].split(".").map(t=>{if(/^[0-9]+$/.test(t)){const e=+t;if(e>=0&&e<r)return e}return t}):this.prerelease=[],this.build=c[5]?c[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(t("SemVer.compare",this.version,this.options,e),!(e instanceof a)){if("string"==typeof e&&e===this.version)return 0;e=new a(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(t){return t instanceof a||(t=new a(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:this.patch>t.patch?1:0}comparePre(e){if(e instanceof a||(e=new a(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let r=0;do{const n=this.prerelease[r],i=e.prerelease[r];if(t("prerelease compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return o(n,i)}while(++r)}compareBuild(e){e instanceof a||(e=new a(e,this.options));let r=0;do{const n=this.build[r],i=e.build[r];if(t("build compare",r,n,i),void 0===n&&void 0===i)return 0;if(void 0===i)return 1;if(void 0===n)return-1;if(n!==i)return o(n,i)}while(++r)}inc(t,e,r){if(t.startsWith("pre")){if(!e&&!1===r)throw new Error("invalid increment argument: identifier is empty");if(e){const t=`-${e}`.match(this.options.loose?n[i.PRERELEASELOOSE]:n[i.PRERELEASE]);if(!t||t[1]!==e)throw new Error(`invalid identifier: ${e}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",e,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",e,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",e,r),this.inc("pre",e,r);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",e,r),this.inc("pre",e,r);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const t=Number(r)?1:0;if(0===this.prerelease.length)this.prerelease=[t];else{let n=this.prerelease.length;for(;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(e===this.prerelease.join(".")&&!1===r)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(t)}}if(e){let n=[e,t];if(!1===r&&(n=[e]),((t,e)=>{const r=e.split(".");if(r.length>t.length)return!1;for(let e=0;e<r.length;e++)if(0!==o(t[e],r[e]))return!1;return!0})(this.prerelease,e)){const t=this.prerelease[e.split(".").length];isNaN(t)&&(this.prerelease=n)}else this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return z=a}function Re(){if(Q)return Z;Q=1;const t=Te();return Z=(e,r,n=!1)=>{if(e instanceof t)return e;try{return new t(e,r)}catch(t){if(!n)return null;throw t}}}function Le(){if(Et)return gt;Et=1;const t=Te();return gt=(e,r,n)=>new t(e,n).compare(new t(r,n))}function ke(){if(wt)return $t;wt=1;const t=Te();return $t=(e,r,n)=>{const i=new t(e,n),s=new t(r,n);return i.compare(s)||i.compareBuild(s)}}function xe(){if(Nt)return bt;Nt=1;const t=Le();return bt=(e,r,n)=>t(e,r,n)>0}function Pe(){if(Rt)return Tt;Rt=1;const t=Le();return Tt=(e,r,n)=>t(e,r,n)<0}function De(){if(kt)return Lt;kt=1;const t=Le();return Lt=(e,r,n)=>0===t(e,r,n)}function He(){if(Pt)return xt;Pt=1;const t=Le();return xt=(e,r,n)=>0!==t(e,r,n)}function Fe(){if(Ht)return Dt;Ht=1;const t=Le();return Dt=(e,r,n)=>t(e,r,n)>=0}function Ge(){if(Gt)return Ft;Gt=1;const t=Le();return Ft=(e,r,n)=>t(e,r,n)<=0}function Ve(){if(Mt)return Vt;Mt=1;const t=De(),e=He(),r=xe(),n=Fe(),i=Pe(),s=Ge();return Vt=(o,a,l,c)=>{switch(a){case"===":return"object"==typeof o&&(o=o.version),"object"==typeof l&&(l=l.version),o===l;case"!==":return"object"==typeof o&&(o=o.version),"object"==typeof l&&(l=l.version),o!==l;case"":case"=":case"==":return t(o,l,c);case"!=":return e(o,l,c);case">":return r(o,l,c);case">=":return n(o,l,c);case"<":return i(o,l,c);case"<=":return s(o,l,c);default:throw new TypeError(`Invalid operator: ${a}`)}}}function Me(){if(Jt)return Yt;Jt=1;const t=/\s+/g;class e{constructor(r,s){if(s=n(s),r instanceof e)return r.loose===!!s.loose&&r.includePrerelease===!!s.includePrerelease?r:new e(r.raw,s);if(r instanceof i)return this.raw=r.value,this.set=[[r]],this.formatted=void 0,this;if(this.options=s,this.loose=!!s.loose,this.includePrerelease=!!s.includePrerelease,this.raw=r.trim().replace(t," "),this.set=this.raw.split("||").map(t=>this.parseRange(t.trim())).filter(t=>t.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const t=this.set[0];if(this.set=this.set.filter(t=>!g(t[0])),0===this.set.length)this.set=[t];else if(this.set.length>1)for(const t of this.set)if(1===t.length&&E(t[0])){this.set=[t];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let t=0;t<this.set.length;t++){t>0&&(this.formatted+="||");const e=this.set[t];for(let t=0;t<e.length;t++)t>0&&(this.formatted+=" "),this.formatted+=e[t].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(t){t=t.replace(f,"");const e=((this.options.includePrerelease&&d)|(this.options.loose&&m))+":"+t,n=r.get(e);if(n)return n;const o=this.options.loose,l=o?a[c.HYPHENRANGELOOSE]:a[c.HYPHENRANGE];t=t.replace(l,N(this.options.includePrerelease)),s("hyphen replace",t),t=t.replace(a[c.COMPARATORTRIM],h),s("comparator trim",t),t=t.replace(a[c.TILDETRIM],u),s("tilde trim",t),t=t.replace(a[c.CARETTRIM],p),s("caret trim",t);let E=t.split(" ").map(t=>v(t,this.options)).join(" ").split(/\s+/).map(t=>b(t,this.options));o&&(E=E.filter(t=>(s("loose invalid filter",t,this.options),!!t.match(a[c.COMPARATORLOOSE])))),s("range list",E);const _=new Map,O=E.map(t=>new i(t,this.options));for(const t of O){if(g(t))return[t];_.set(t.value,t)}_.size>1&&_.has("")&&_.delete("");const A=[..._.values()];return r.set(e,A),A}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Range is required");return this.set.some(e=>_(e,r)&&t.set.some(t=>_(t,r)&&e.every(e=>t.every(t=>e.intersects(t,r)))))}test(t){if(!t)return!1;if("string"==typeof t)try{t=new o(t,this.options)}catch(t){return!1}for(let e=0;e<this.set.length;e++)if(T(this.set[e],t,this.options))return!0;return!1}}Yt=e;const r=new(Bt?qt:(Bt=1,qt=class{constructor(){this.max=1e3,this.map=new Map}get(t){const e=this.map.get(t);return void 0===e?void 0:(this.map.delete(t),this.map.set(t,e),e)}delete(t){return this.map.delete(t)}set(t,e){if(!this.delete(t)&&void 0!==e){if(this.map.size>=this.max){const t=this.map.keys().next().value;this.delete(t)}this.map.set(t,e)}return this}})),n=be(),i=je(),s=Se(),o=Te(),{safeRe:a,src:l,t:c,comparatorTrimReplace:h,tildeTrimReplace:u,caretTrimReplace:p}=Ie(),{FLAG_INCLUDE_PRERELEASE:d,FLAG_LOOSE:m}=ye(),f=new RegExp(l[c.BUILD],"g"),g=t=>"<0.0.0-0"===t.value,E=t=>""===t.value,_=(t,e)=>{let r=!0;const n=t.slice();let i=n.pop();for(;r&&n.length;)r=n.every(t=>i.intersects(t,e)),i=n.pop();return r},v=(t,e)=>(t=t.replace(a[c.BUILD],""),s("comp",t,e),t=w(t,e),s("caret",t),t=A(t,e),s("tildes",t),t=y(t,e),s("xrange",t),t=I(t,e),s("stars",t),t),O=t=>!t||"x"===t.toLowerCase()||"*"===t,A=(t,e)=>t.trim().split(/\s+/).map(t=>$(t,e)).join(" "),$=(t,e)=>{const r=e.loose?a[c.TILDELOOSE]:a[c.TILDE],n=e.includePrerelease?"-0":"";return t.replace(r,(e,r,i,o,a)=>{let l;return s("tilde",t,e,r,i,o,a),O(r)?l="":O(i)?l=`>=${r}.0.0${n} <${+r+1}.0.0-0`:O(o)?l=`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:a?(s("replaceTilde pr",a),l=`>=${r}.${i}.${o}-${a} <${r}.${+i+1}.0-0`):l=`>=${r}.${i}.${o} <${r}.${+i+1}.0-0`,s("tilde return",l),l})},w=(t,e)=>t.trim().split(/\s+/).map(t=>C(t,e)).join(" "),C=(t,e)=>{s("caret",t,e);const r=e.loose?a[c.CARETLOOSE]:a[c.CARET],n=e.includePrerelease?"-0":"";return t.replace(r,(e,r,i,o,a)=>{let l;return s("caret",t,e,r,i,o,a),O(r)?l="":O(i)?l=`>=${r}.0.0${n} <${+r+1}.0.0-0`:O(o)?l="0"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:a?(s("replaceCaret pr",a),l="0"===r?"0"===i?`>=${r}.${i}.${o}-${a} <${r}.${i}.${+o+1}-0`:`>=${r}.${i}.${o}-${a} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${o}-${a} <${+r+1}.0.0-0`):(s("no pr"),l="0"===r?"0"===i?`>=${r}.${i}.${o} <${r}.${i}.${+o+1}-0`:`>=${r}.${i}.${o} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${o} <${+r+1}.0.0-0`),s("caret return",l),l})},y=(t,e)=>(s("replaceXRanges",t,e),t.split(/\s+/).map(t=>S(t,e)).join(" ")),S=(t,e)=>{t=t.trim();const r=e.loose?a[c.XRANGELOOSE]:a[c.XRANGE];return t.replace(r,(r,n,i,o,a,l)=>{if(s("xRange",t,r,n,i,o,a,l),((t,e,r)=>O(t)&&!O(e)||O(e)&&r&&!O(r))(i,o,a))return t;const c=O(i),h=c||O(o),u=h||O(a),p=u;return"="===n&&p&&(n=""),l=e.includePrerelease?"-0":"",c?r=">"===n||"<"===n?"<0.0.0-0":"*":n&&p?(h&&(o=0),a=0,">"===n?(n=">=",h?(i=+i+1,o=0,a=0):(o=+o+1,a=0)):"<="===n&&(n="<",h?i=+i+1:o=+o+1),"<"===n&&(l="-0"),r=`${n+i}.${o}.${a}${l}`):h?r=`>=${i}.0.0${l} <${+i+1}.0.0-0`:u&&(r=`>=${i}.${o}.0${l} <${i}.${+o+1}.0-0`),s("xRange return",r),r})},I=(t,e)=>(s("replaceStars",t,e),t.trim().replace(a[c.STAR],"")),b=(t,e)=>(s("replaceGTE0",t,e),t.trim().replace(a[e.includePrerelease?c.GTE0PRE:c.GTE0],"")),N=t=>(e,r,n,i,s,o,a,l,c,h,u,p)=>`${r=O(n)?"":O(i)?`>=${n}.0.0${t?"-0":""}`:O(s)?`>=${n}.${i}.0${t?"-0":""}`:o?`>=${r}`:`>=${r}${t?"-0":""}`} ${l=O(c)?"":O(h)?`<${+c+1}.0.0-0`:O(u)?`<${c}.${+h+1}.0-0`:p?`<=${c}.${h}.${u}-${p}`:t?`<${c}.${h}.${+u+1}-0`:`<=${l}`}`.trim(),T=(t,e,r)=>{for(let r=0;r<t.length;r++)if(!t[r].test(e))return!1;if(e.prerelease.length&&!r.includePrerelease){for(let r=0;r<t.length;r++)if(s(t[r].semver),t[r].semver!==i.ANY&&t[r].semver.prerelease.length>0){const n=t[r].semver;if(n.major===e.major&&n.minor===e.minor&&n.patch===e.patch)return!0}return!1}return!0};return Yt}function je(){if(Kt)return zt;Kt=1;const t=Symbol("SemVer ANY");class e{static get ANY(){return t}constructor(n,i){if(i=r(i),n instanceof e){if(n.loose===!!i.loose)return n;n=n.value}n=n.trim().split(/\s+/).join(" "),o("comparator",n,i),this.options=i,this.loose=!!i.loose,this.parse(n),this.semver===t?this.value="":this.value=this.operator+this.semver.version,o("comp",this)}parse(e){const r=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],s=e.match(r);if(!s)throw new TypeError(`Invalid comparator: ${e}`);this.operator=void 0!==s[1]?s[1]:"","="===this.operator&&(this.operator=""),s[2]?this.semver=new a(s[2],this.options.loose):this.semver=t}toString(){return this.value}test(e){if(o("Comparator.test",e,this.options.loose),this.semver===t||e===t)return!0;if("string"==typeof e)try{e=new a(e,this.options)}catch(t){return!1}return s(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new l(t.value,n).test(this.value):""===t.operator?""===t.value||new l(this.value,n).test(t.semver):!((n=r(n)).includePrerelease&&("<0.0.0-0"===this.value||"<0.0.0-0"===t.value)||!n.includePrerelease&&(this.value.startsWith("<0.0.0")||t.value.startsWith("<0.0.0"))||(!this.operator.startsWith(">")||!t.operator.startsWith(">"))&&(!this.operator.startsWith("<")||!t.operator.startsWith("<"))&&(this.semver.version!==t.semver.version||!this.operator.includes("=")||!t.operator.includes("="))&&!(s(this.semver,"<",t.semver,n)&&this.operator.startsWith(">")&&t.operator.startsWith("<"))&&!(s(this.semver,">",t.semver,n)&&this.operator.startsWith("<")&&t.operator.startsWith(">")))}}zt=e;const r=be(),{safeRe:n,t:i}=Ie(),s=Ve(),o=Se(),a=Te(),l=Me();return zt}function Ue(){if(Qt)return Zt;Qt=1;const t=Me();return Zt=(e,r,n)=>{try{r=new t(r,n)}catch(t){return!1}return r.test(e)},Zt}function We(){if(ce)return le;ce=1;const t=Me();return le=(e,r)=>{try{return new t(e,r).range||"*"}catch(t){return null}},le}function Xe(){if(ue)return he;ue=1;const t=Te(),e=je(),{ANY:r}=e,n=Me(),i=Ue(),s=xe(),o=Pe(),a=Ge(),l=Fe();return he=(c,h,u,p)=>{let d,m,f,g,E;switch(c=new t(c,p),h=new n(h,p),u){case">":d=s,m=a,f=o,g=">",E=">=";break;case"<":d=o,m=l,f=s,g="<",E="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(i(c,h,p))return!1;for(let t=0;t<h.set.length;++t){const n=h.set[t];let i=null,s=null;if(n.forEach(t=>{t.semver===r&&(t=new e(">=0.0.0")),i=i||t,s=s||t,d(t.semver,i.semver,p)?i=t:f(t.semver,s.semver,p)&&(s=t)}),i.operator===g||i.operator===E)return!1;if((!s.operator||s.operator===g)&&m(c,s.semver))return!1;if(s.operator===E&&f(c,s.semver))return!1}return!0},he}var qe=function(){if(we)return $e;we=1;const t=Ie(),e=ye(),r=Te(),n=Ne(),i=Re(),s=function(){if(et)return tt;et=1;const t=Re();return tt=(e,r)=>{const n=t(e,r);return n?n.version:null}}(),o=function(){if(nt)return rt;nt=1;const t=Re();return rt=(e,r)=>{const n=t(e.trim().replace(/^[=v]+/,""),r);return n?n.version:null}}(),a=function(){if(st)return it;st=1;const t=Te();return it=(e,r,n,i,s)=>{"string"==typeof n&&(s=i,i=n,n=void 0);try{return new t(e instanceof t?e.version:e,n).inc(r,i,s).version}catch(t){return null}}}(),l=function(){if(at)return ot;at=1;const t=Re();return ot=(e,r)=>{const n=t(e,null,!0),i=t(r,null,!0),s=n.compare(i);if(0===s)return null;const o=s>0,a=o?n:i,l=o?i:n,c=!!a.prerelease.length;if(l.prerelease.length&&!c){if(!l.patch&&!l.minor)return"major";if(0===l.compareMain(a))return l.minor&&!l.patch?"minor":"patch"}const h=c?"pre":"";return n.major!==i.major?h+"major":n.minor!==i.minor?h+"minor":n.patch!==i.patch?h+"patch":"prerelease"}}(),c=function(){if(ct)return lt;ct=1;const t=Te();return lt=(e,r)=>new t(e,r).major}(),h=function(){if(ut)return ht;ut=1;const t=Te();return ht=(e,r)=>new t(e,r).minor}(),u=function(){if(dt)return pt;dt=1;const t=Te();return pt=(e,r)=>new t(e,r).patch}(),p=function(){if(ft)return mt;ft=1;const t=Re();return mt=(e,r)=>{const n=t(e,r);return n&&n.prerelease.length?n.prerelease:null}}(),d=Le(),m=function(){if(vt)return _t;vt=1;const t=Le();return _t=(e,r,n)=>t(r,e,n)}(),f=function(){if(At)return Ot;At=1;const t=Le();return Ot=(e,r)=>t(e,r,!0)}(),g=ke(),E=function(){if(yt)return Ct;yt=1;const t=ke();return Ct=(e,r)=>e.sort((e,n)=>t(e,n,r))}(),_=function(){if(It)return St;It=1;const t=ke();return St=(e,r)=>e.sort((e,n)=>t(n,e,r))}(),v=xe(),O=Pe(),A=De(),$=He(),w=Fe(),C=Ge(),y=Ve(),S=function(){if(Ut)return jt;Ut=1;const t=Te(),e=Re(),{safeRe:r,t:n}=Ie();return jt=(i,s)=>{if(i instanceof t)return i;if("number"==typeof i&&(i=String(i)),"string"!=typeof i)return null;let o=null;if((s=s||{}).rtl){const t=s.includePrerelease?r[n.COERCERTLFULL]:r[n.COERCERTL];let e;for(;(e=t.exec(i))&&(!o||o.index+o[0].length!==i.length);)o&&e.index+e[0].length===o.index+o[0].length||(o=e),t.lastIndex=e.index+e[1].length+e[2].length;t.lastIndex=-1}else o=i.match(s.includePrerelease?r[n.COERCEFULL]:r[n.COERCE]);if(null===o)return null;const a=o[2],l=o[3]||"0",c=o[4]||"0",h=s.includePrerelease&&o[5]?`-${o[5]}`:"",u=s.includePrerelease&&o[6]?`+${o[6]}`:"";return e(`${a}.${l}.${c}${h}${u}`,s)}}(),I=function(){if(Xt)return Wt;Xt=1;const t=Re(),e=ye(),r=Te(),n=t=>t.startsWith("pre");return Wt=(i,s,o)=>{if(!e.RELEASE_TYPES.includes(s))return null;const a=((e,n)=>{const i=e instanceof r?e.version:e;return t(i,n)})(i,o);return a&&((t,e)=>{if(n(e))return t.version;switch(t.prerelease=[],e){case"major":t.minor=0,t.patch=0;break;case"minor":t.patch=0}return t.format()})(a,s)}}(),b=je(),N=Me(),T=Ue(),R=function(){if(ee)return te;ee=1;const t=Me();return te=(e,r)=>new t(e,r).set.map(t=>t.map(t=>t.value).join(" ").trim().split(" ")),te}(),L=function(){if(ne)return re;ne=1;const t=Te(),e=Me();return re=(r,n,i)=>{let s=null,o=null,a=null;try{a=new e(n,i)}catch(t){return null}return r.forEach(e=>{a.test(e)&&(s&&-1!==o.compare(e)||(s=e,o=new t(s,i)))}),s},re}(),k=function(){if(se)return ie;se=1;const t=Te(),e=Me();return ie=(r,n,i)=>{let s=null,o=null,a=null;try{a=new e(n,i)}catch(t){return null}return r.forEach(e=>{a.test(e)&&(s&&1!==o.compare(e)||(s=e,o=new t(s,i)))}),s},ie}(),x=function(){if(ae)return oe;ae=1;const t=Te(),e=Me(),r=xe();return oe=(n,i)=>{n=new e(n,i);let s=new t("0.0.0");if(n.test(s))return s;if(s=new t("0.0.0-0"),n.test(s))return s;s=null;for(let e=0;e<n.set.length;++e){const i=n.set[e];let o=null;i.forEach(e=>{const n=new t(e.semver.version);switch(e.operator){case">":0===n.prerelease.length?n.patch++:n.prerelease.push(0),n.raw=n.format();case"":case">=":o&&!r(n,o)||(o=n);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}}),!o||s&&!r(s,o)||(s=o)}return s&&n.test(s)?s:null},oe}(),P=We(),D=Xe(),H=function(){if(de)return pe;de=1;const t=Xe();return pe=(e,r,n)=>t(e,r,">",n),pe}(),F=function(){if(fe)return me;fe=1;const t=Xe();return me=(e,r,n)=>t(e,r,"<",n),me}(),G=function(){if(Ee)return ge;Ee=1;const t=Me();return ge=(e,r,n)=>(e=new t(e,n),r=new t(r,n),e.intersects(r,n))}(),V=function(){if(ve)return _e;ve=1;const t=Ue(),e=Le();return _e=(r,n,i)=>{const s=[];let o=null,a=null;const l=r.sort((t,r)=>e(t,r,i));for(const e of l)t(e,n,i)?(a=e,o||(o=e)):(a&&s.push([o,a]),a=null,o=null);o&&s.push([o,null]);const c=[];for(const[t,e]of s)t===e?c.push(t):e||t!==l[0]?e?t===l[0]?c.push(`<=${e}`):c.push(`${t} - ${e}`):c.push(`>=${t}`):c.push("*");const h=c.join(" || "),u="string"==typeof n.raw?n.raw:String(n);return h.length<u.length?h:n},_e}(),M=function(){if(Ae)return Oe;Ae=1;const t=Me(),e=je(),{ANY:r}=e,n=Ue(),i=Le(),s=[new e(">=0.0.0-0")],o=[new e(">=0.0.0")],a=(t,e,a)=>{if(t===e)return!0;if(1===t.length&&t[0].semver===r){if(1===e.length&&e[0].semver===r)return!0;t=a.includePrerelease?s:o}if(1===e.length&&e[0].semver===r){if(a.includePrerelease)return!0;e=o}const h=new Set;let u,p,d,m,f,g,E;for(const e of t)">"===e.operator||">="===e.operator?u=l(u,e,a):"<"===e.operator||"<="===e.operator?p=c(p,e,a):h.add(e.semver);if(h.size>1)return null;if(u&&p){if(d=i(u.semver,p.semver,a),d>0)return null;if(0===d&&(">="!==u.operator||"<="!==p.operator))return null}for(const t of h){if(u&&!n(t,String(u),a))return null;if(p&&!n(t,String(p),a))return null;for(const r of e)if(!n(t,String(r),a))return!1;return!0}let _=!(!p||a.includePrerelease||!p.semver.prerelease.length)&&p.semver,v=!(!u||a.includePrerelease||!u.semver.prerelease.length)&&u.semver;_&&1===_.prerelease.length&&"<"===p.operator&&0===_.prerelease[0]&&(_=!1);for(const t of e){if(E=E||">"===t.operator||">="===t.operator,g=g||"<"===t.operator||"<="===t.operator,u)if(v&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===v.major&&t.semver.minor===v.minor&&t.semver.patch===v.patch&&(v=!1),">"===t.operator||">="===t.operator){if(m=l(u,t,a),m===t&&m!==u)return!1}else if(">="===u.operator&&!t.test(u.semver))return!1;if(p)if(_&&t.semver.prerelease&&t.semver.prerelease.length&&t.semver.major===_.major&&t.semver.minor===_.minor&&t.semver.patch===_.patch&&(_=!1),"<"===t.operator||"<="===t.operator){if(f=c(p,t,a),f===t&&f!==p)return!1}else if("<="===p.operator&&!t.test(p.semver))return!1;if(!t.operator&&(p||u)&&0!==d)return!1}return!(u&&g&&!p&&0!==d||p&&E&&!u&&0!==d||v||_)},l=(t,e,r)=>{if(!t)return e;const n=i(t.semver,e.semver,r);return n>0?t:n<0||">"===e.operator&&">="===t.operator?e:t},c=(t,e,r)=>{if(!t)return e;const n=i(t.semver,e.semver,r);return n<0?t:n>0||"<"===e.operator&&"<="===t.operator?e:t};return Oe=(e,r,n={})=>{if(e===r)return!0;e=new t(e,n),r=new t(r,n);let i=!1;t:for(const t of e.set){for(const e of r.set){const r=a(t,e,n);if(i=i||null!==r,r)continue t}if(i)return!1}return!0}}();return $e={parse:i,valid:s,clean:o,inc:a,diff:l,major:c,minor:h,patch:u,prerelease:p,compare:d,rcompare:m,compareLoose:f,compareBuild:g,sort:E,rsort:_,gt:v,lt:O,eq:A,neq:$,gte:w,lte:C,cmp:y,coerce:S,truncate:I,Comparator:b,Range:N,satisfies:T,toComparators:R,maxSatisfying:L,minSatisfying:k,minVersion:x,validRange:P,outside:D,gtr:H,ltr:F,intersects:G,simplifyRange:V,subset:M,SemVer:r,re:t.re,src:t.src,tokens:t.t,SEMVER_SPEC_VERSION:e.SEMVER_SPEC_VERSION,RELEASE_TYPES:e.RELEASE_TYPES,compareIdentifiers:n.compareIdentifiers,rcompareIdentifiers:n.rcompareIdentifiers}}(),Be=l(qe);class Ye extends Error{code;lockPath;owner;constructor(t,e,r={}){const n=e?.pid?` pid ${e.pid}`:"";super(`${r.label||"Process"} is already running${n}. Lock: ${t}`),this.name="ProcessSingletonError",this.code=r.code||"PROCESS_ALREADY_RUNNING",this.lockPath=t,this.owner=e}}function Je(t){return r.join(t,"owner.json")}function ze(t){return r.join(t,"initializing.json")}function Ke(t){return r.join(t,"recovering.json")}function Ze(t){return Number.isInteger(t)&&Number(t)>0}function Qe(t,r=process.platform){if(Ze(t)){if("linux"===r)try{const e=n.readFileSync(`/proc/${t}/stat`,"utf8"),r=e.lastIndexOf(")");if(r<0)return;const i=e.slice(r+2).trim().split(/\s+/)[19];return i?`linux:${i}`:void 0}catch{return}if(["darwin","freebsd","openbsd","aix","sunos"].includes(r)){const n=e.spawnSync("ps",["-o","lstart=","-p",String(t)],{encoding:"utf8",timeout:1e3}),i=0===n.status?n.stdout.trim().replace(/\s+/g," "):"";return i?`${r}:${i}`:void 0}if("win32"===r){const r=`(Get-Process -Id ${t} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`,n=e.spawnSync("powershell.exe",["-NoProfile","-NonInteractive","-Command",r],{encoding:"utf8",timeout:2e3}),i=0===n.status?n.stdout.trim():"";return/^\d+$/.test(i)?`win32:${i}`:void 0}}}const tr=function(t){try{const e=JSON.parse(n.readFileSync(Je(t),"utf8"));if(Ze(e.pid)&&"string"==typeof e.startTime){const t=e;return{pid:t.pid,hostname:"string"==typeof t.hostname&&t.hostname?t.hostname:o.hostname(),component:t.component||"server-update",command:"string"==typeof t.command?t.command:"",acquiredAt:"string"==typeof t.createdAt&&Number.isFinite(Date.parse(t.createdAt))?t.createdAt:new Date(0).toISOString(),token:"string"==typeof t.token&&t.token?t.token:`legacy:${t.pid}:${t.startTime}`,startIdentity:t.startTime.startsWith("linux:")?t.startTime:`linux:${t.startTime}`}}if(!(Ze(e.pid)&&"string"==typeof e.hostname&&e.hostname&&"string"==typeof e.command&&"string"==typeof e.acquiredAt&&Number.isFinite(Date.parse(e.acquiredAt))&&"string"==typeof e.token&&e.token))return;return e}catch{return}};function er(t){if(!Ze(t))return!1;try{return process.kill(Number(t),0),!0}catch(t){return"EPERM"===t.code}}function rr(t){if(!t||!er(t.pid))return!1;if(!t.startIdentity)return!0;const e=Qe(t.pid);return void 0===e||e===t.startIdentity}function nr(t,e){const i=r.join(t,`.owner-${e.token}.tmp`);n.writeFileSync(i,`${JSON.stringify(e,null,2)}\n`,{encoding:"utf8",mode:384,flag:"wx"});const s=ir(t);if(s?.token!==e.token)throw or(i),new Error(`Process lock initialization was superseded: ${t}`);n.renameSync(i,Je(t)),or(ze(t))}function ir(t){try{return JSON.parse(n.readFileSync(ze(t),"utf8"))}catch{return}}function sr(t){const e=ir(t);return Ze(e?.pid)&&rr({pid:e.pid,startIdentity:e.startIdentity})}function or(t){try{n.unlinkSync(t)}catch(t){if("ENOENT"!==t.code)throw t}}function ar(){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,20)}function lr(t){try{const e=ir(t),r=Date.parse(e?.startedAt||"");return Number.isFinite(r)?Math.max(0,Date.now()-r):Math.max(0,Date.now()-n.statSync(t).mtimeMs)}catch{return 0}}function cr(t,e){try{return n.writeFileSync(Ke(t),`${JSON.stringify({token:e,pid:process.pid,startedAt:(new Date).toISOString()})}\n`,{encoding:"utf8",mode:384,flag:"wx"}),!0}catch(i){if("EEXIST"===i.code)return!!function(t){const e=Ke(t),i=hr(e),s=Date.parse(i?.startedAt||"");if(er(i?.pid)||Number.isFinite(s)&&Date.now()-s<2e3)return!1;const o=r.join(t,`.recovering-${a.randomUUID()}.stale`);try{n.renameSync(e,o)}catch(t){if(["ENOENT","EEXIST"].includes(t.code||""))return!1;throw t}const l=hr(o);if(l?.token===i?.token)return or(o),!0;try{n.linkSync(o,e)}catch(t){if("EEXIST"!==t.code)throw t}finally{or(o)}return!1}(t)&&cr(t,e);if("ENOENT"===i.code)return!1;throw i}}function hr(t){try{return JSON.parse(n.readFileSync(t,"utf8"))}catch{return}}function ur(t,e){return hr(Ke(t))?.token===e}const pr=r.resolve(__dirname,".."),dr=JSON.parse(n.readFileSync(r.join(pr,"package.json"),"utf8")),mr=process.env.TASK_HANDOFF_NPM_COMMAND||"npm",fr=function(t){const e=Be.prerelease(t)?.[0];return"alpha"===e||"beta"===e?e:"stable"}(dr.version);function gr(t,r,n={}){const i=e.spawnSync(t,r,{encoding:"utf8",...n});if(0!==i.status){const e=[i.stdout,i.stderr].filter(Boolean).join("\n").trim();throw new Error(`${t} ${r.join(" ")} failed${e?`:\n${e}`:""}`)}return String(i.stdout||"").trim()}function Er(t){const e={};if(!n.existsSync(t))return e;for(const r of n.readFileSync(t,"utf8").split(/\r?\n/)){if(!r||r.startsWith("#"))continue;const t=r.indexOf("=");t>0&&(e[r.slice(0,t)]=r.slice(t+1))}return e}function _r(){const t="/etc/systemd/system/task-handoff-node-agent.service";return n.existsSync(t)&&n.readFileSync(t,"utf8").match(/^User=(.+)$/m)?.[1]||"root"}function vr(){const t=Er("/etc/task-handoff/control-plane.env"),e=Er("/etc/task-handoff/node-agent.env");return["--service-user",_r(),"--control-plane-data-dir",t.TASK_HANDOFF_CONTROL_PLANE_DATA_DIR||"/var/lib/task-handoff/control-plane","--node-agent-data-dir",e.TASK_HANDOFF_NODE_AGENT_DATA_DIR||"/var/lib/task-handoff/node-agent","--control-plane-host",t.TASK_HANDOFF_CONTROL_PLANE_HOST||"0.0.0.0","--control-plane-port",t.TASK_HANDOFF_CONTROL_PLANE_PORT||"8081","--node-agent-host",e.TASK_HANDOFF_NODE_AGENT_HOST||"127.0.0.1","--node-agent-port",e.TASK_HANDOFF_NODE_AGENT_PORT||"8091","--node-agent-ipc-path",e.TASK_HANDOFF_NODE_AGENT_IPC_PATH||"/run/task-handoff/node-agent.sock","--auth-mode",t.TASK_HANDOFF_CONTROL_PLANE_AUTH_MODE||"password"]}function Or(t){const r=e.spawnSync("systemctl",["is-active",t],{encoding:"utf8"});return String(r.stdout||"unknown").trim()||"unknown"}async function Ar(t){Sr();const e=vr(),r=e[e.indexOf("--node-agent-ipc-path")+1],n=Number(e[e.indexOf("--control-plane-port")+1]);if("stop"===t)return gr("systemctl",["stop","task-handoff-control-plane.service"],{stdio:"inherit"}),gr("systemctl",["stop","task-handoff-node-agent.service"],{stdio:"inherit"}),void console.log("Stopped TaskHandoff server services.");gr("systemctl",[t,"task-handoff-node-agent.service"],{stdio:"inherit"}),Ir(r),gr("systemctl",[t,"task-handoff-control-plane.service"],{stdio:"inherit"}),await br(n),console.log(("start"===t?"Started":"Restarted")+" TaskHandoff server services.")}function $r(t,e){return e||("stable"===t?"latest":t)}function wr(t){if((e=t).trim()!==e||/^[v=]/.test(e)||null===Be.valid(e))throw new P("must be an exact semantic version");var e;return t}function Cr(){return new G("--channel <channel>","stable, beta, or alpha").choices(["stable","beta","alpha"]).default(fr).conflicts("to")}function yr(t,e){const r=["view",`@task-handoff/server@${t}`,"version","--json"];e&&r.push("--registry",e);const n=JSON.parse(gr(mr,r));if("string"!=typeof n)throw new Error(`npm target ${t} did not resolve to one version.`);return n}function Sr(){if("function"==typeof process.getuid&&0!==process.getuid())throw new Error("Run this command as root so system packages and services can be changed.")}function Ir(t,e=3e4){const r=Date.now()+e;for(;Date.now()<r;){try{if(n.statSync(t).isSocket())return}catch{}Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,250)}throw new Error(`Node agent socket was not ready after ${e}ms: ${t}`)}function br(t,e=3e4){return new Promise((r,n)=>{const i=Date.now()+e,o=()=>{const e=s.get({host:"127.0.0.1",port:t,path:"/api/health",timeout:1e3},t=>{if(t.resume(),200===t.statusCode)return r();a()});e.on("timeout",()=>e.destroy()),e.on("error",a)},a=()=>Date.now()>=i?n(new Error(`Control plane was not healthy on port ${t} after ${e}ms.`)):setTimeout(o,250);o()})}function Nr(t){return[["--service-user",t.serviceUser],["--control-plane-data-dir",t.controlPlaneDataDir],["--node-agent-data-dir",t.nodeAgentDataDir],["--control-plane-host",t.controlPlaneHost],["--control-plane-port",t.controlPlanePort],["--node-agent-host",t.nodeAgentHost],["--node-agent-port",t.nodeAgentPort],["--node-agent-ipc-path",t.nodeAgentIpcPath],["--auth-mode",t.authMode],["--static-dir",t.staticDir]].flatMap(([t,e])=>void 0===e?[]:[t,e])}(async function(){const t=(new H).name("task-handoff").description("Manage a TaskHandoff server and run its installed runtimes.").version(dr.version).showSuggestionAfterError();t.command("control-plane","Run the installed control-plane runtime.",{executableFile:"task-handoff-control-plane"}),t.command("node-agent","Run the installed node-agent runtime.",{executableFile:"task-handoff-node-agent"}),t.command("controlled-instance","Run the installed controlled-instance runtime.",{executableFile:"task-handoff-controlled-instance"}),t.command("install").description("Install or regenerate the server systemd services.").option("--service-user <user>").option("--control-plane-data-dir <path>").option("--node-agent-data-dir <path>").option("--control-plane-host <host>").option("--control-plane-port <port>").option("--node-agent-host <host>").option("--node-agent-port <port>").option("--node-agent-ipc-path <path>").option("--auth-mode <mode>").option("--static-dir <path>").action(t=>{Sr(),gr(process.execPath,[r.join(pr,"bin","task-handoff-install-server"),...Nr(t)],{stdio:"inherit"})}),t.command("status").description("Show the installed version and service state.").action(()=>{console.log(`Package: @task-handoff/server ${dr.version}`),console.log(`Node agent: ${Or("task-handoff-node-agent.service")}`),console.log(`Control plane: ${Or("task-handoff-control-plane.service")}`)}),t.command("start").description("Start the node agent and control plane services.").action(()=>Ar("start")),t.command("stop").description("Stop the control plane and node agent services.").action(()=>Ar("stop")),t.command("restart").description("Restart the node agent and control plane services safely.").action(()=>Ar("restart")),t.command("check").description("Check npm for an available server version.").addOption(Cr()).option("--registry <url>").action(t=>{const e=$r(t.channel),r=yr(e,t.registry);console.log(`Installed: ${dr.version}`),console.log(`Available (${t.channel} channel, npm ${e}): ${r}`),console.log(r===dr.version?"Up to date.":`Update available: task-handoff update --to ${r}`)}),t.command("update").description("Update the server package set and restart services safely.").addOption(Cr()).option("--to <version>","exact semantic version",wr).option("--registry <url>").option("--force").action(async t=>{Sr();const e=$r(t.channel,t.to),i=e===dr.version?dr.version:yr(e,t.registry);if(i===dr.version&&!t.force)return void console.log(`@task-handoff/server ${dr.version} is already installed.`);const s=function(t="/run/task-handoff-server-update.lock",e={}){const i=function(t,e={}){n.mkdirSync(r.dirname(t),{recursive:!0});const i={pid:process.pid,hostname:o.hostname(),component:e.component,command:process.argv.join(" "),acquiredAt:(new Date).toISOString(),token:a.randomUUID(),startIdentity:Qe(process.pid),dataDir:e.dataDir,host:e.host,port:e.port,instanceId:e.instanceId};for(let r=0;r<5;r+=1)try{return n.mkdirSync(t),n.writeFileSync(ze(t),`${JSON.stringify({token:i.token,pid:i.pid,startIdentity:i.startIdentity,startedAt:(new Date).toISOString()})}\n`,{encoding:"utf8",mode:384,flag:"wx"}),nr(t,i),{lockPath:t,owner:i,release(){const e=tr(t);e?.token===i.token&&n.rmSync(t,{recursive:!0,force:!0})}}}catch(i){if("EEXIST"!==i.code)throw i;const s=tr(t);if(rr(s))throw new Ye(t,s,e.error);if(!s&&(sr(t)||lr(t)<(e.incompleteLockStaleMs??2e3))){if(r+1<5){ar();continue}throw new Ye(t,void 0,e.error)}const o=a.randomUUID();if(!cr(t,o)){if(r+1<5){ar();continue}throw new Ye(t,tr(t),e.error)}const l=tr(t);if(rr(l))throw or(Ke(t)),new Ye(t,l,e.error);if(s?.token&&l?.token!==s.token){or(Ke(t));continue}if(!ur(t,o))continue;n.rmSync(t,{recursive:!0,force:!0})}const s=tr(t);throw new Ye(t,s,e.error)}(t,{component:"server-update",incompleteLockStaleMs:e.legacyGraceMs??3e4,error:{label:"TaskHandoff server update",code:"SERVER_UPDATE_ALREADY_RUNNING"}});return i.release}(),l=function(t){const e=new Map;for(const r of["SIGINT","SIGTERM","SIGHUP"]){const n=()=>{t(),process.removeListener(r,n),process.kill(process.pid,r)};e.set(r,n),process.on(r,n)}return()=>{for(const[t,r]of e)process.removeListener(t,r)}}(s);try{const e=function(){let t=pr;for(;t!==r.dirname(t);){if("node_modules"===r.basename(t)&&"lib"===r.basename(r.dirname(t)))return r.dirname(r.dirname(t));t=r.dirname(t)}throw new Error(`Cannot determine the npm global prefix from ${pr}.`)}(),n=vr(),s=n[n.indexOf("--node-agent-ipc-path")+1],o=Number(n[n.indexOf("--control-plane-port")+1]),a=["install","--global","--prefix",e,`@task-handoff/server@${i}`];t.registry&&a.push("--registry",t.registry),console.log(`Updating @task-handoff/server ${dr.version} -> ${i}`),gr(mr,a,{stdio:"inherit"}),gr(r.join(e,"bin","task-handoff"),["install",...n],{stdio:"inherit"}),gr("systemctl",["restart","task-handoff-node-agent.service"]),Ir(s),gr("systemctl",["restart","task-handoff-control-plane.service"]),await br(o),console.log(`Updated TaskHandoff server to ${i}.`)}catch(t){throw console.error(`Update failed. To reinstall the previous version, run: npm install -g @task-handoff/server@${dr.version}`),t}finally{l(),s()}}),await t.parseAsync(process.argv)})().catch(t=>{console.error(`Error: ${t instanceof Error?t.message:String(t)}`),process.exitCode=1});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@task-handoff/server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10-alpha.1",
|
|
4
4
|
"description": "Complete TaskHandoff server package.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"node": ">=24.15.0 <25"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@task-handoff/control-plane": "0.0.
|
|
22
|
-
"@task-handoff/node-agent": "0.0.
|
|
23
|
-
"@task-handoff/controlled-instance": "0.0.
|
|
21
|
+
"@task-handoff/control-plane": "0.0.10-alpha.1",
|
|
22
|
+
"@task-handoff/node-agent": "0.0.10-alpha.1",
|
|
23
|
+
"@task-handoff/controlled-instance": "0.0.10-alpha.1"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|