@task-handoff/server 0.0.24 → 0.0.25-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.
|
@@ -22,6 +22,7 @@ NODE_AGENT_PORT="8091"
|
|
|
22
22
|
NODE_AGENT_IPC_PATH="/run/task-handoff/node-agent.sock"
|
|
23
23
|
AUTH_MODE="password"
|
|
24
24
|
STATIC_DIR=""
|
|
25
|
+
MATERIALIZE_ONLY="0"
|
|
25
26
|
|
|
26
27
|
usage() {
|
|
27
28
|
cat <<'USAGE'
|
|
@@ -47,6 +48,7 @@ Options:
|
|
|
47
48
|
--node-agent-ipc-path <path> Local control socket, default /run/task-handoff/node-agent.sock
|
|
48
49
|
--auth-mode <mode> Control-plane auth mode: password or disabled
|
|
49
50
|
--static-dir <path> Built control-plane UI directory
|
|
51
|
+
--materialize-only Rewrite env and systemd units without starting services
|
|
50
52
|
USAGE
|
|
51
53
|
}
|
|
52
54
|
|
|
@@ -74,6 +76,7 @@ while [ "$#" -gt 0 ]; do
|
|
|
74
76
|
--node-agent-ipc-path) NODE_AGENT_IPC_PATH="${2:-}"; shift 2 ;;
|
|
75
77
|
--auth-mode) AUTH_MODE="${2:-}"; shift 2 ;;
|
|
76
78
|
--static-dir) STATIC_DIR="${2:-}"; shift 2 ;;
|
|
79
|
+
--materialize-only) MATERIALIZE_ONLY="1"; shift ;;
|
|
77
80
|
-h|--help) usage; exit 0 ;;
|
|
78
81
|
*) echo "Unknown option: $1" >&2; usage >&2; exit 1 ;;
|
|
79
82
|
esac
|
|
@@ -181,6 +184,27 @@ assert_service_command_accessible "$NPM_COMMAND" "npm command"
|
|
|
181
184
|
mkdir -p "$ENV_DIR" "$CONTROL_PLANE_DATA_DIR" "$NODE_AGENT_DATA_DIR"
|
|
182
185
|
chown -R "$SERVICE_USER":"$SERVICE_USER" "$CONTROL_PLANE_DATA_DIR" "$NODE_AGENT_DATA_DIR" 2>/dev/null || true
|
|
183
186
|
|
|
187
|
+
ADMIN_USERNAME=""
|
|
188
|
+
ADMIN_PASSWORD=""
|
|
189
|
+
if [ "$AUTH_MODE" = "password" ]; then
|
|
190
|
+
# Compatibility for v0.0.21: an older service may still be running with a
|
|
191
|
+
# publicly bootstrap-able empty account store during an in-place upgrade.
|
|
192
|
+
# The auth store is the sole authority: file existence cannot distinguish a
|
|
193
|
+
# valid administrator from a corrupt record that sanitation will isolate.
|
|
194
|
+
systemctl stop task-handoff-control-plane.service 2>/dev/null || true
|
|
195
|
+
ADMIN_USERNAME="$(node -e 'process.stdout.write(`admin-${require("node:crypto").randomBytes(6).toString("hex")}`)')"
|
|
196
|
+
ADMIN_PASSWORD="$(node -e 'process.stdout.write(require("node:crypto").randomBytes(24).toString("base64url"))')"
|
|
197
|
+
if [ "$SERVICE_USER" = "root" ]; then
|
|
198
|
+
ADMIN_INITIALIZATION_RESULT="$(printf '%s\n' "$ADMIN_PASSWORD" | $CONTROL_PLANE_COMMAND credentials --initialize-if-needed --username "$ADMIN_USERNAME" --password-stdin --data-dir "$CONTROL_PLANE_DATA_DIR")"
|
|
199
|
+
else
|
|
200
|
+
ADMIN_INITIALIZATION_RESULT="$(printf '%s\n' "$ADMIN_PASSWORD" | runuser -u "$SERVICE_USER" -- $CONTROL_PLANE_COMMAND credentials --initialize-if-needed --username "$ADMIN_USERNAME" --password-stdin --data-dir "$CONTROL_PLANE_DATA_DIR")"
|
|
201
|
+
fi
|
|
202
|
+
if [ "$ADMIN_INITIALIZATION_RESULT" != "created" ]; then
|
|
203
|
+
ADMIN_USERNAME=""
|
|
204
|
+
ADMIN_PASSWORD=""
|
|
205
|
+
fi
|
|
206
|
+
fi
|
|
207
|
+
|
|
184
208
|
cat > "$ENV_DIR/node-agent.env" <<EOF
|
|
185
209
|
TASK_HANDOFF_NODE_AGENT_HOST=$NODE_AGENT_HOST
|
|
186
210
|
TASK_HANDOFF_NODE_AGENT_PORT=$NODE_AGENT_PORT
|
|
@@ -250,9 +274,21 @@ WantedBy=multi-user.target
|
|
|
250
274
|
EOF
|
|
251
275
|
|
|
252
276
|
systemctl daemon-reload
|
|
253
|
-
|
|
254
|
-
systemctl enable --now task-handoff-
|
|
277
|
+
if [ "$MATERIALIZE_ONLY" = "0" ]; then
|
|
278
|
+
systemctl enable --now task-handoff-node-agent.service
|
|
279
|
+
systemctl enable --now task-handoff-control-plane.service
|
|
280
|
+
fi
|
|
255
281
|
|
|
256
|
-
|
|
282
|
+
if [ "$MATERIALIZE_ONLY" = "1" ]; then
|
|
283
|
+
echo "TaskHandoff server service configuration is materialized."
|
|
284
|
+
else
|
|
285
|
+
echo "TaskHandoff server services are installed."
|
|
286
|
+
fi
|
|
257
287
|
echo "Control plane: task-handoff-control-plane.service on $CONTROL_PLANE_HOST:$CONTROL_PLANE_PORT"
|
|
258
288
|
echo "Local node-agent: task-handoff-node-agent.service on $NODE_AGENT_HOST:$NODE_AGENT_PORT"
|
|
289
|
+
if [ -n "$ADMIN_USERNAME" ]; then
|
|
290
|
+
echo "Control Plane administrator credentials (shown once):"
|
|
291
|
+
echo " Username: $ADMIN_USERNAME"
|
|
292
|
+
echo " Password: $ADMIN_PASSWORD"
|
|
293
|
+
echo "Store these credentials securely; they are not written to the service environment."
|
|
294
|
+
fi
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("node:fs"),t=require("node:path"),{spawnSync:n}=require("node:child_process"),{Command:o,InvalidArgumentError:r}=require("commander"),a=require("semver"),s=require("write-file-atomic"),{ControlPlaneHealthResponseSchema:i}=require("../packages/protocol/src/control-plane.ts"),{acquireServerUpdateLock:c,cleanUpServerUpdateLockOnSignals:d,globalPrefixFromModulePath:f}=require("../packages/core/src/core/server-update-installation.ts");function l(e){const t=i.safeParse(e);return t.success?t.data.data.build.packageVersion:void 0}function u(e){if(!t.isAbsolute(e))throw new r("must be an absolute path");return t.resolve(e)}const p=(new o).name("task-handoff-node-update-worker").description("Apply a detached TaskHandoff node update.").requiredOption("--job-file <path>","persisted update job file").requiredOption("--target-version <version>","exact semantic version",function(e){if(e.trim()!==e||/^[v=]/.test(e)||null===a.valid(e))throw new r("must be an exact semantic version");return e}).option("--service <name>","systemd service to restart","task-handoff-node-agent.service").option("--npm-command <path>","npm executable",process.env.TASK_HANDOFF_NPM_COMMAND||"npm").option("--control-plane-health-url <url>","local control-plane health endpoint",function(e){let t;try{t=new URL(e)}catch{throw new r("must be a valid loopback HTTP URL")}if(!["http:","https:"].includes(t.protocol)||!["127.0.0.1","localhost","::1"].includes(t.hostname))throw new r("must be a valid loopback HTTP URL");return t.toString()}).option("--install-prefix <path>","authoritative npm global prefix",u).option("--node-agent-ipc-path <path>","node-agent readiness socket",u).option("--registry <url>","npm registry URL").option("--standalone","complete the temporary job after service verification").parse(process.argv).opts(),h=p.jobFile,m=p.targetVersion,g=p.service,w=p.npmCommand,y=p.controlPlaneHealthUrl,v=p.installPrefix,S=p.nodeAgentIpcPath,E=p.registry,k=new Set(["succeeded","degraded","failed"]),_=new Set(["@task-handoff/node-agent","@task-handoff/server"]),A=["/etc/task-handoff/control-plane.env","/etc/task-handoff/node-agent.env","/etc/systemd/system/task-handoff-control-plane.service","/etc/systemd/system/task-handoff-node-agent.service"];function T(n,o){const r=JSON.parse(e.readFileSync(h,"utf8"));process.env.TASK_HANDOFF_UPDATE_WORKER_TEST_CAS_HOOK&&require(t.resolve(process.env.TASK_HANDOFF_UPDATE_WORKER_TEST_CAS_HOOK))({jobFile:h,observed:r});const a=`${h}.worker-lock`;e.mkdirSync(a);try{const t=JSON.parse(e.readFileSync(h,"utf8"));if(k.has(t.status)||!n.includes(t.status))return!1;const r="function"==typeof o?o(t):o,a={...t,...r,updatedAt:(new Date).toISOString()};return s.sync(h,`${JSON.stringify(a,null,2)}\n`,{encoding:"utf8"}),!0}finally{e.rmdirSync(a)}}function O(e,t){const o=n(e,t,{stdio:"inherit"});if(0!==o.status)throw new Error(`${e} exited with status ${o.status??"unknown"}`)}function b(n,o,r){const a=r?t.join(o,...r.split("/"),"node_modules",...n.split("/"),"package.json"):t.join(o,...n.split("/"),"package.json");try{return JSON.parse(e.readFileSync(a,"utf8")).version}catch(e){if("ENOENT"===e?.code)return;throw e}}function $(e,t){const n=b(e,t);if(n!==m)throw new Error(`Updated ${e} verification failed: expected ${m}, found ${n||"unknown"}.`)}function R(e){const t=["view",`${e}@${m}`,"dist.integrity","--json"];E&&t.push("--registry",E);const o=n(w,t,{encoding:"utf8"});if(0!==o.status)throw new Error(`Could not verify the ${e} npm artifact integrity.`);let r;try{r=JSON.parse(o.stdout)}catch{throw new Error(`npm returned invalid ${e} artifact integrity metadata.`)}if("string"!=typeof r||!/^sha(?:256|384|512)-[A-Za-z0-9+/=]+$/.test(r))throw new Error(`npm returned invalid ${e} artifact integrity metadata.`);return r}async function N(t,n=m,o=6e4){const r=Date.now()+o;let a="not reachable";for(;Date.now()<r;){try{if(process.env.TASK_HANDOFF_UPDATE_WORKER_TEST_HEALTH_FILE){const t=l(JSON.parse(e.readFileSync(process.env.TASK_HANDOFF_UPDATE_WORKER_TEST_HEALTH_FILE,"utf8")));if(t===n)return;a=`reported version ${String(t||"unknown")}`,await new Promise(e=>setTimeout(e,10));continue}const o=await fetch(t,{headers:{"cache-control":"no-cache"},signal:AbortSignal.timeout(2e3)}),r=l(await o.json().catch(()=>({})));if(o.ok&&r===n)return;a=o.ok?`reported version ${String(r||"unknown")}`:`returned HTTP ${o.status}`}catch(e){a=e instanceof Error?e.message:String(e)}await new Promise(e=>setTimeout(e,500))}throw new Error(`Control plane did not become healthy at ${t} with version ${n}: ${a}.`)}function D(t,n=3e4){const o=Date.now()+n;for(;Date.now()<o;){try{if(e.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 ${n}ms: ${t}`)}function F(e,t,n){const o=["install","--global","--prefix",e,`${t}@${n}`];E&&o.push("--registry",E),O(w,o)}!async function(){let o,r,a;try{if(!T(["queued"],e=>({status:"updating-node",rollout:{...e.rollout,phase:"updating-node"},startedAt:(new Date).toISOString(),error:void 0})))return;o=c(process.env.TASK_HANDOFF_SERVER_UPDATE_LOCK_PATH||void 0),r=d(o);const i=function(){const t=JSON.parse(e.readFileSync(h,"utf8")),n=`@${m}#`;if("string"!=typeof t.artifactRef||!t.artifactRef.startsWith("npm:")||!t.artifactRef.includes(n))throw new Error(`Update job does not pin npm integrity for version ${m}.`);const o=t.artifactRef.indexOf(n),r=t.artifactRef.slice(4,o),a=t.artifactRef.slice(o+n.length);if(!_.has(r)||!a)throw new Error("Update job does not identify a supported immutable npm artifact.");const s=R(r);if(s!==a)throw new Error(`${r} npm artifact integrity mismatch: expected ${a}, found ${String(s||"unknown")}.`);return{packageName:r,integrity:s}}(),l=i.packageName,u=f(process.argv[1]);if(v&&u&&v!==u)throw Object.assign(new Error(`Update prefix ${v} does not match the running package prefix ${u}.`),{code:"UPDATE_INSTALL_PREFIX_MISMATCH"});const E=u?void 0:n(w,["prefix","--global"],{encoding:"utf8"});if(E&&0!==E.status)throw new Error("Could not determine the npm global prefix.");const k=v||u||E?.stdout.trim();if(!k)throw new Error("Could not determine the npm global prefix.");const P=n(w,["root","--global","--prefix",k],{encoding:"utf8"});if(0!==P.status)throw new Error("Could not determine the npm global module root.");const U=P.stdout.trim(),H=[l];"@task-handoff/server"===l&&void 0!==b("@task-handoff/node-agent",U)&&H.push("@task-handoff/node-agent");const j=new Map(H.map(e=>[e,b(e,U)])),x="@task-handoff/server"===l?function(){const e=process.env.TASK_HANDOFF_UPDATE_WORKER_TEST_CONFIGURATION_ROOT;return e?A.map(n=>t.join(e,n.slice(1))):A}().map(t=>{try{const n=e.statSync(t);return{file:t,contents:e.readFileSync(t),mode:n.mode}}catch(e){if("ENOENT"===e?.code)return{file:t};throw e}}):[];let I=!1;a=async()=>{for(const e of[...H].reverse()){const t=j.get(e);t&&F(k,e,t)}if("@task-handoff/server"===l){I&&(function(n){for(const o of n)o.contents?(e.mkdirSync(t.dirname(o.file),{recursive:!0}),s.sync(o.file,o.contents,{mode:o.mode})):e.rmSync(o.file,{force:!0})}(x),O("systemctl",["daemon-reload"])),O("systemctl",["restart","task-handoff-control-plane.service"]);const n=j.get("@task-handoff/server");y&&n&&await N(y,n)}O("systemctl",["restart",g]),S&&D(S)};const L=new Map([[l,i.integrity]]);for(const e of H.slice(1))L.set(e,R(e));for(const e of H){if(F(k,e,m),R(e)!==L.get(e))throw new Error(`${e} npm artifact integrity changed during installation.`);$(e,U)}if("@task-handoff/server"===l){if(function(e){for(const t of["@task-handoff/control-plane","@task-handoff/node-agent","@task-handoff/controlled-instance"]){const n=b(t,e,"@task-handoff/server")||b(t,e);if(n!==m)throw new Error(`Updated @task-handoff/server does not provide ${t} ${m}; found ${n||"unknown"}.`)}}(U),!y)throw new Error("A control-plane health URL is required for a complete server update.");I=!0,function(e){O(t.join(e,"bin","task-handoff"),["install","--preserve-current","--materialize-only"])}(k),O("systemctl",["restart","task-handoff-control-plane.service"]),await N(y)}if(!T(["updating-node"],e=>({status:"restarting-node",rollout:{...e.rollout,phase:"restarting-node"}})))return;O("systemctl",["restart",g]),S&&D(S),p.standalone&&T(["restarting-node"],e=>({status:"succeeded",rollout:{...e.rollout,phase:"succeeded",nodeVersion:m},completedAt:(new Date).toISOString()}))}catch(e){let t;if(a)try{await a()}catch(e){t=e}const n=[e instanceof Error?e.message:String(e),t?`Rollback failed: ${t instanceof Error?t.message:String(t)}`:void 0].filter(Boolean).join(" ");T(["queued","updating-node","restarting-node"],t=>({status:"failed",rollout:{...t.rollout,phase:"failed"},error:{code:e&&"object"==typeof e&&"code"in e&&"string"==typeof e.code?e.code:"NODE_UPDATE_FAILED",message:n,retryable:e&&"object"==typeof e&&"code"in e&&"SERVER_UPDATE_ALREADY_RUNNING"===e.code},completedAt:(new Date).toISOString()})),console.error(e),process.exitCode=1}finally{r?.(),o?.()}}();
|
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"),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=sr(t);if(s?.token!==e.token)throw ar(i),new Error(`Process lock initialization was superseded: ${t}`);n.renameSync(i,Je(t)),ar(ze(t))}function ir(t,e,i){const s=tr(t);if(s?.token!==e.token)return!1;const o={...e};for(const[t,e]of Object.entries(i))void 0===e?delete o[t]:Object.assign(o,{[t]:e});const l=r.join(t,`.owner-update-${e.token}-${a.randomUUID()}.tmp`);try{if(n.writeFileSync(l,`${JSON.stringify(o,null,2)}\n`,{encoding:"utf8",mode:384,flag:"wx"}),tr(t)?.token!==e.token)return!1;n.renameSync(l,Je(t));for(const t of Object.keys(e))delete e[t];return Object.assign(e,o),!0}catch(t){if("ENOENT"===t.code)return!1;throw t}finally{ar(l)}}function sr(t){try{return JSON.parse(n.readFileSync(ze(t),"utf8"))}catch{return}}function or(t){const e=sr(t);return Ze(e?.pid)&&rr({pid:e.pid,startIdentity:e.startIdentity})}function ar(t){try{n.unlinkSync(t)}catch(t){if("ENOENT"!==t.code)throw t}}function lr(){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,20)}function cr(t){try{const e=sr(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 hr(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=ur(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=ur(o);if(l?.token===i?.token)return ar(o),!0;try{n.linkSync(o,e)}catch(t){if("EEXIST"!==t.code)throw t}finally{ar(o)}return!1}(t)&&hr(t,e);if("ENOENT"===i.code)return!1;throw i}}function ur(t){try{return JSON.parse(n.readFileSync(t,"utf8"))}catch{return}}function pr(t,e){return ur(Ke(t))?.token===e}const dr=r.resolve(__dirname,".."),mr=JSON.parse(n.readFileSync(r.join(dr,"package.json"),"utf8")),fr=process.env.TASK_HANDOFF_NPM_COMMAND||"npm",gr=function(t){const e=Be.prerelease(t)?.[0];return"alpha"===e||"beta"===e?e:"stable"}(mr.version);function Er(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 _r(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 vr(){const t="/etc/systemd/system/task-handoff-node-agent.service";return n.existsSync(t)&&n.readFileSync(t,"utf8").match(/^User=(.+)$/m)?.[1]||"root"}function Or(){const t=_r("/etc/task-handoff/control-plane.env"),e=_r("/etc/task-handoff/node-agent.env");return["--service-user",vr(),"--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 Ar(t){const r=e.spawnSync("systemctl",["is-active",t],{encoding:"utf8"});return String(r.stdout||"unknown").trim()||"unknown"}async function $r(t){Ir();const e=Or(),r=e[e.indexOf("--node-agent-ipc-path")+1],n=Number(e[e.indexOf("--control-plane-port")+1]);if("stop"===t)return Er("systemctl",["stop","task-handoff-control-plane.service"],{stdio:"inherit"}),Er("systemctl",["stop","task-handoff-node-agent.service"],{stdio:"inherit"}),void console.log("Stopped TaskHandoff server services.");Er("systemctl",[t,"task-handoff-node-agent.service"],{stdio:"inherit"}),br(r),Er("systemctl",[t,"task-handoff-control-plane.service"],{stdio:"inherit"}),await Nr(n),console.log(("start"===t?"Started":"Restarted")+" TaskHandoff server services.")}function wr(t,e){return e||("stable"===t?"latest":t)}function Cr(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 yr(){return new G("--channel <channel>","stable, beta, or alpha").choices(["stable","beta","alpha"]).default(gr).conflicts("to")}function Sr(t,e){const r=["view",`@task-handoff/server@${t}`,"version","--json"];e&&r.push("--registry",e);const n=JSON.parse(Er(fr,r));if("string"!=typeof n)throw new Error(`npm target ${t} did not resolve to one version.`);return n}function Ir(){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 br(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 Nr(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 Tr(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(mr.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=>{Ir(),Er(process.execPath,[r.join(dr,"bin","task-handoff-install-server"),...Tr(t)],{stdio:"inherit"})}),t.command("status").description("Show the installed version and service state.").action(()=>{console.log(`Package: @task-handoff/server ${mr.version}`),console.log(`Node agent: ${Ar("task-handoff-node-agent.service")}`),console.log(`Control plane: ${Ar("task-handoff-control-plane.service")}`)}),t.command("start").description("Start the node agent and control plane services.").action(()=>$r("start")),t.command("stop").description("Stop the control plane and node agent services.").action(()=>$r("stop")),t.command("restart").description("Restart the node agent and control plane services safely.").action(()=>$r("restart")),t.command("check").description("Check npm for an available server version.").addOption(yr()).option("--registry <url>").action(t=>{const e=wr(t.channel),r=Sr(e,t.registry);console.log(`Installed: ${mr.version}`),console.log(`Available (${t.channel} channel, npm ${e}): ${r}`),console.log(r===mr.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(yr()).option("--to <version>","exact semantic version",Cr).option("--registry <url>").option("--force").action(async t=>{Ir();const e=wr(t.channel,t.to),i=e===mr.version?mr.version:Sr(e,t.registry);if(i===mr.version&&!t.force)return void console.log(`@task-handoff/server ${mr.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=Qe(process.pid),s={pid:process.pid,hostname:o.hostname(),command:process.argv.join(" "),acquiredAt:(new Date).toISOString(),token:a.randomUUID(),...void 0!==e.component?{component:e.component}:{},...i?{startIdentity:i}:{},...void 0!==e.dataDir?{dataDir:e.dataDir}:{},...void 0!==e.host?{host:e.host}:{},...void 0!==e.port?{port:e.port}:{},...void 0!==e.instanceId?{instanceId:e.instanceId}:{}};for(let r=0;r<5;r+=1)try{return n.mkdirSync(t),n.writeFileSync(ze(t),`${JSON.stringify({token:s.token,pid:s.pid,startIdentity:s.startIdentity,startedAt:(new Date).toISOString()})}\n`,{encoding:"utf8",mode:384,flag:"wx"}),nr(t,s),{lockPath:t,owner:s,updateDetails:e=>ir(t,s,e),release(){const e=tr(t);e?.token===s.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&&(or(t)||cr(t)<(e.incompleteLockStaleMs??2e3))){if(r+1<5){lr();continue}throw new Ye(t,void 0,e.error)}const o=a.randomUUID();if(!hr(t,o)){if(r+1<5){lr();continue}throw new Ye(t,tr(t),e.error)}const l=tr(t);if(rr(l))throw ar(Ke(t)),new Ye(t,l,e.error);if(s?.token&&l?.token!==s.token){ar(Ke(t));continue}if(!pr(t,o))continue;n.rmSync(t,{recursive:!0,force:!0})}const l=tr(t);throw new Ye(t,l,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=dr;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 ${dr}.`)}(),n=Or(),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 ${mr.version} -> ${i}`),Er(fr,a,{stdio:"inherit"}),Er(r.join(e,"bin","task-handoff"),["install",...n],{stdio:"inherit"}),Er("systemctl",["restart","task-handoff-node-agent.service"]),br(s),Er("systemctl",["restart","task-handoff-control-plane.service"]),await Nr(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@${mr.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});
|
|
1
|
+
"use strict";var e=require("node:events"),t=require("node:child_process"),r=require("node:path"),n=require("node:fs"),i=require("node:process"),s=require("node:http"),o=require("node:os");function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}require("node:crypto");var l,h,c={},u={},p={};function d(){if(l)return p;l=1;class e extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}}return p.CommanderError=e,p.InvalidArgumentError=class extends e{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},p}function m(){if(h)return u;h=1;const{InvalidArgumentError:e}=d();return u.Argument=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?(t.push(e),t):[e]}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},u.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"},u}var f,g={},E={};function _(){if(f)return E;f=1;const{humanReadableArgName:e}=m();function t(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,"")}return E.Help=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){const t=e.commands.filter(e=>!e._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){const r=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){const t=e.options.filter(e=>!e.hidden),r=e._getHelpOption();if(r&&!r.hidden){const n=r.short&&e._findOption(r.short),i=r.long&&e._findOption(r.long);n||i?r.long&&!i?t.push(e.createOption(r.long,r.description)):r.short&&!n&&t.push(e.createOption(r.short,r.description)):t.push(r)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];const t=[];for(let r=e.parent;r;r=r.parent){const e=r.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(t){const r=t.registeredArguments.map(t=>e(t)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,r)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(r)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,r)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(r)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,r)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(r)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,r)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(r)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let t=e.parent;t;t=t.parent)r=t.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0){const r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}argumentDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){const r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatItemList(e,t,r){return 0===t.length?[]:[r.styleTitle(e),...t,""]}groupItems(e,t,r){const n=new Map;return e.forEach(e=>{const t=r(e);n.has(t)||n.set(t,[])}),t.forEach(e=>{const t=r(e);n.has(t)||n.set(t,[]),n.get(t).push(e)}),n}formatHelp(e,t){const r=t.padWidth(e,t),n=t.helpWidth??80;function i(e,n){return t.formatItem(e,r,n,t)}let s=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""];const o=t.commandDescription(e);o.length>0&&(s=s.concat([t.boxWrap(t.styleCommandDescription(o),n),""]));const a=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));s=s.concat(this.formatItemList("Arguments:",a,t));const l=this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??"Options:");if(l.forEach((e,r)=>{const n=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));s=s.concat(this.formatItemList(r,n,t))}),t.showGlobalOptions){const r=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));s=s.concat(this.formatItemList("Global Options:",r,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||"Commands:").forEach((e,r)=>{const n=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));s=s.concat(this.formatItemList(r,n,t))}),s.join("\n")}displayWidth(e){return t(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(e=>"[options]"===e?this.styleOptionText(e):"[command]"===e?this.styleSubcommandText(e):"["===e[0]||"<"===e[0]?this.styleArgumentText(e):this.styleCommandText(e)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(e=>"[options]"===e?this.styleOptionText(e):"["===e[0]||"<"===e[0]?this.styleArgumentText(e):this.styleSubcommandText(e)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,r,n){const i=" ".repeat(2);if(!r)return i+e;const s=e.padEnd(t+e.length-n.displayWidth(e)),o=(this.helpWidth??80)-t-2-2;let a;return a=o<this.minWidthToWrap||n.preformatted(r)?r:n.boxWrap(r,o).replace(/\n/g,"\n"+" ".repeat(t+2)),i+s+" ".repeat(2)+a.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;const r=e.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,i=[];return r.forEach(e=>{const r=e.match(n);if(null===r)return void i.push("");let s=[r.shift()],o=this.displayWidth(s[0]);r.forEach(e=>{const r=this.displayWidth(e);if(o+r<=t)return s.push(e),void(o+=r);i.push(s.join(""));const n=e.trimStart();s=[n],o=this.displayWidth(n)}),i.push(s.join(""))}),i.join("\n")}},E.stripColor=t,E}var v,O={};function A(){if(v)return O;v=1;const{InvalidArgumentError:e}=d();function t(e){return e.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}return O.Option=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;const r=function(e){let t,r;const n=/^-[^-]$/,i=/^--[^-]/,s=e.split(/[ |,]+/).concat("guard");if(n.test(s[0])&&(t=s.shift()),i.test(s[0])&&(r=s.shift()),!t&&n.test(s[0])&&(t=s.shift()),!t&&i.test(s[0])&&(t=r,r=s.shift()),s[0].startsWith("-")){const t=s[0],r=`option creation failed due to '${t}' in option flags '${e}'`;if(/^-[^-][^-]/.test(t))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(t))throw new Error(`${r}\n- too many short flags`);if(i.test(t))throw new Error(`${r}\n- too many long flags`);throw new Error(`${r}\n- unrecognised flag format`)}if(void 0===t&&void 0===r)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:r}}(e);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(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return"string"==typeof e&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?(t.push(e),t):[e]}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?t(this.name().replace(/^no-/,"")):t(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},O.DualOptions=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){const r=t.attributeName();if(!this.dualOptions.has(r))return!0;const n=this.negativeOptions.get(r).presetArg,i=void 0!==n&&n;return t.negate===(i===e)}},O}var $,C,w,I={};function y(){return $||($=1,I.suggestSimilar=function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));const r=e.startsWith("--");r&&(e=e.slice(2),t=t.map(e=>e.slice(2)));let n=[],i=3;return t.forEach(t=>{if(t.length<=1)return;const r=function(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);const r=[];for(let t=0;t<=e.length;t++)r[t]=[t];for(let e=0;e<=t.length;e++)r[0][e]=e;for(let n=1;n<=t.length;n++)for(let i=1;i<=e.length;i++){let s=1;s=e[i-1]===t[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&&e[i-1]===t[n-2]&&e[i-2]===t[n-1]&&(r[i][n]=Math.min(r[i][n],r[i-2][n-2]+1))}return r[e.length][t.length]}(e,t),s=Math.max(e.length,t.length);(s-r)/s>.4&&(r<i?(i=r,n=[t]):r===i&&n.push(t))}),n.sort((e,t)=>e.localeCompare(t)),r&&(n=n.map(e=>`--${e}`)),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""}),I}var S=function(){if(w)return c;w=1;const{Argument:s}=m(),{Command:o}=function(){if(C)return g;C=1;const s=e.EventEmitter,o=t,a=r,l=n,h=i,{Argument:c,humanReadableArgName:u}=m(),{CommanderError:p}=d(),{Help:f,stripColor:E}=_(),{Option:v,DualOptions:O}=A(),{suggestSimilar:$}=y();class w extends s{constructor(e){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=e||"",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:e=>h.stdout.write(e),writeErr:e=>h.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>h.stdout.isTTY?h.stdout.columns:void 0,getErrHelpWidth:()=>h.stderr.isTTY?h.stderr.columns:void 0,getOutHasColors:()=>S()??(h.stdout.isTTY&&h.stdout.hasColors?.()),getErrHasColors:()=>S()??(h.stderr.isTTY&&h.stderr.hasColors?.()),stripColor:e=>E(e)},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(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){const e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,r){let n=t,i=r;"object"==typeof n&&null!==n&&(i=n,n=null),i=i||{};const[,s,o]=e.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(e){return new w(e)}createHelp(){return Object.assign(new f,this.configureHelp())}configureHelp(e){return void 0===e?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return void 0===e?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return"string"!=typeof e&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(t=t||{}).isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new c(e,t)}argument(e,t,r,n){const i=this.createArgument(e,t);return"function"==typeof r?i.default(n).argParser(r):i.default(r),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(e){const t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&void 0!==e.defaultValue&&void 0===e.parseArg)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if("boolean"==typeof e)return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;const r=e??"help [command]",[,n,i]=r.match(/([^ ]+) *(.*)/),s=t??"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,(e||t)&&this._initCommandGroup(o),this}addHelpCommand(e,t){return"object"!=typeof e?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),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(e,t){const r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return this._exitCallback=e||(e=>{if("commander.executeSubCommandAsync"!==e.code)throw e}),this}_exit(e,t,r){this._exitCallback&&this._exitCallback(new p(e,t,r)),h.exit(e)}action(e){return this._actionHandler=t=>{const r=this.registeredArguments.length,n=t.slice(0,r);return this._storeOptionsAsProperties?n[r]=this:n[r]=this.opts(),n.push(this),e.apply(this,n)},this}createOption(e,t){return new v(e,t)}_callParseArg(e,t,r,n){try{return e.parseArg(t,r)}catch(e){if("commander.invalidArgument"===e.code){const t=`${n} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}_registerOption(e){const t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){const r=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'\n- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){const t=e=>[e.name()].concat(e.aliases()),r=t(e).find(e=>this._findCommand(e));if(r){const n=t(this._findCommand(r)).join("|"),i=t(e).join("|");throw new Error(`cannot add command '${i}' as already have command '${n}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);const t=e.name(),r=e.attributeName();if(e.negate){const t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(r,void 0===e.defaultValue||e.defaultValue,"default")}else void 0!==e.defaultValue&&this.setOptionValueWithSource(r,e.defaultValue,"default");const n=(t,n,i)=>{null==t&&void 0!==e.presetArg&&(t=e.presetArg);const s=this.getOptionValue(r);null!==t&&e.parseArg?t=this._callParseArg(e,t,s,n):null!==t&&e.variadic&&(t=e._collectValue(t,s)),null==t&&(t=!e.negate&&(!(!e.isBoolean()&&!e.optional)||"")),this.setOptionValueWithSource(r,t,i)};return this.on("option:"+t,t=>{const r=`error: option '${e.flags}' argument '${t}' is invalid.`;n(t,r,"cli")}),e.envVar&&this.on("optionEnv:"+t,t=>{const r=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;n(t,r,"env")}),this}_optionEx(e,t,r,n,i){if("object"==typeof t&&t instanceof v)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const s=this.createOption(t,r);if(s.makeOptionMandatory(!!e.mandatory),"function"==typeof n)s.default(i).argParser(n);else if(n instanceof RegExp){const e=n;n=(t,r)=>{const n=e.exec(t);return n?n[0]:r},s.default(i).argParser(n)}else s.default(n);return this.addOption(s)}option(e,t,r,n){return this._optionEx({},e,t,r,n)}requiredOption(e,t,r,n){return this._optionEx({mandatory:!0},e,t,r,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,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(e=!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=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(r=>{void 0!==r.getOptionValueSource(e)&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(void 0!==e&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},void 0===e&&void 0===t.from){h.versions?.electron&&(t.from="electron");const e=h.execArgv??[];(e.includes("-e")||e.includes("--eval")||e.includes("-p")||e.includes("--print"))&&(t.from="eval")}let r;switch(void 0===e&&(e=h.argv),this.rawArgs=e.slice(),t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":h.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(e,t){this._prepareForParse();const r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){this._prepareForParse();const r=this._prepareUserArgs(e,t);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(e,t,r){if(!l.existsSync(e))throw new Error(`'${e}' 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 - ${t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory"}`)}_executeSubCommand(e,t){t=t.slice();let r=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function i(e,t){const r=a.resolve(e,t);if(l.existsSync(r))return r;if(n.includes(a.extname(t)))return;const i=n.find(e=>l.existsSync(`${r}${e}`));return i?`${r}${i}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s,c=e._executableFile||`${this._name}-${e._name}`,u=this._executableDir||"";if(this._scriptPath){let e;try{e=l.realpathSync(this._scriptPath)}catch{e=this._scriptPath}u=a.resolve(a.dirname(e),u)}if(u){let t=i(u,c);if(!t&&!e._executableFile&&this._scriptPath){const r=a.basename(this._scriptPath,a.extname(this._scriptPath));r!==this._name&&(t=i(u,`${r}-${e._name}`))}c=t||c}r=n.includes(a.extname(c)),"win32"!==h.platform?r?(t.unshift(c),t=I(h.execArgv).concat(t),s=o.spawn(h.argv[0],t,{stdio:"inherit"})):s=o.spawn(c,t,{stdio:"inherit"}):(this._checkForMissingExecutable(c,u,e._name),t.unshift(c),t=I(h.execArgv).concat(t),s=o.spawn(h.execPath,t,{stdio:"inherit"})),s.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(e=>{h.on(e,()=>{!1===s.killed&&null===s.exitCode&&s.kill(e)})});const d=this._exitCallback;s.on("close",e=>{e=e??1,d?d(new p(e,"commander.executeSubCommandAsync","(close)")):h.exit(e)}),s.on("error",t=>{if("ENOENT"===t.code)this._checkForMissingExecutable(c,u,e._name);else if("EACCES"===t.code)throw new Error(`'${c}' not executable`);if(d){const e=new p(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,d(e)}else h.exit(1)}),this.runningCommand=s}_dispatchSubcommand(e,t,r){const n=this._findCommand(e);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(t,r);this._executeSubCommand(n,t.concat(r))}),i}_dispatchHelpCommand(e){e||this.help();const t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&null==this.args[t]&&this.missingArgument(e.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const e=(e,t,r)=>{let n=t;if(null!==t&&e.parseArg){const i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;n=this._callParseArg(e,t,r,i)}return n};this._checkNumberOfArguments();const t=[];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((t,n)=>e(r,n,t),r.defaultValue))):void 0===i&&(i=[]):n<this.args.length&&(i=this.args[n],r.parseArg&&(i=e(r,i,r.defaultValue))),t[n]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&"function"==typeof e.then?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e;const n=[];return this._getCommandAndAncestors().reverse().filter(e=>void 0!==e._lifeCycleHooks[t]).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{n.push({hookedCommand:e,callback:t})})}),"postAction"===t&&n.reverse(),n.forEach(e=>{r=this._chainOrCall(r,()=>e.callback(e.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let n=e;return void 0!==this._lifeCycleHooks[r]&&this._lifeCycleHooks[r].forEach(e=>{n=this._chainOrCall(n,()=>e(this,t))}),n}_parseCommand(e,t){const r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);!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,e,t)})),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent?.listenerCount(i))n(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&void 0===e.getOptionValue(t.attributeName())&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){const e=this.options.filter(e=>{const t=e.attributeName();return void 0!==this.getOptionValue(t)&&"default"!==this.getOptionValueSource(t)}),t=e.filter(e=>e.conflictsWith.length>0);t.forEach(t=>{const r=e.find(e=>t.conflictsWith.includes(e.attributeName()));r&&this._conflictingOption(t,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){const t=[],r=[];let n=t;function i(e){return e.length>1&&"-"===e[0]}const s=e=>!!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)&&!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e)));let o=null,a=null,l=0;for(;l<e.length||a;){const h=a??e[l++];if(a=null,"--"===h){n===r&&n.push(h),n.push(...e.slice(l));break}if(!o||i(h)&&!s(h)){if(o=null,i(h)){const t=this._findOption(h);if(t){if(t.required){const r=e[l++];void 0===r&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,r)}else if(t.optional){let r=null;l<e.length&&(!i(e[l])||s(e[l]))&&(r=e[l++]),this.emit(`option:${t.name()}`,r)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(h.length>2&&"-"===h[0]&&"-"!==h[1]){const e=this._findOption(`-${h[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,h.slice(2)):(this.emit(`option:${e.name()}`),a=`-${h.slice(2)}`);continue}}if(/^--[^=]+=/.test(h)){const e=h.indexOf("="),t=this._findOption(h.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,h.slice(e+1));continue}}if(n!==t||!i(h)||0===this.commands.length&&s(h)||(n=r),(this._enablePositionalOptions||this._passThroughOptions)&&0===t.length&&0===r.length){if(this._findCommand(h)){t.push(h),r.push(...e.slice(l));break}if(this._getHelpCommand()&&h===this._getHelpCommand().name()){t.push(h,...e.slice(l));break}if(this._defaultCommandName){r.push(h,...e.slice(l));break}}if(this._passThroughOptions){n.push(h,...e.slice(l));break}n.push(h)}else this.emit(`option:${o.name()}`,h)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){const e={},t=this.options.length;for(let r=0;r<t;r++){const t=this.options[r].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\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=t||{},n=r.exitCode||1,i=r.code||"commander.error";this._exit(n,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in h.env){const t=e.attributeName();(void 0===this.getOptionValue(t)||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,h.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){const e=new O(this.options),t=e=>void 0!==this.getOptionValue(e)&&!["default","implied"].includes(this.getOptionValueSource(e));this.options.filter(r=>void 0!==r.implied&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],"implied")})})}missingArgument(e){const t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){const t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){const t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){const r=e=>{const t=e.attributeName(),r=this.getOptionValue(t),n=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return n&&(void 0===n.presetArg&&!1===r||void 0!==n.presetArg&&r===n.presetArg)?n:i||e},n=e=>{const t=r(e),n=t.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let r=[],n=this;do{const e=n.createHelp().visibleOptions(n).filter(e=>e.long).map(e=>e.long);r=r.concat(e),n=n.parent}while(n&&!n._enablePositionalOptions);t=$(e,r)}const r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;const t=this.registeredArguments.length,r=1===t?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const r=[];this.createHelp().visibleCommands(this).forEach(e=>{r.push(e.name()),e.alias()&&r.push(e.alias())}),t=$(e,r)}const r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(void 0===e)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";const n=this.createOption(t,r);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,"commander.version",e)}),this}description(e,t){return void 0===e&&void 0===t?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return void 0===e?this._summary:(this._summary=e,this)}alias(e){if(void 0===e)return this._aliases[0];let t=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");const r=this.parent?._findCommand(e);if(r){const t=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return void 0===e?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(void 0===e){if(this._usage)return this._usage;const e=this.registeredArguments.map(e=>u(e));return[].concat(this.options.length||null!==this._helpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=e,this}name(e){return void 0===e?this._name:(this._name=e,this)}helpGroup(e){return void 0===e?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return void 0===e?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return void 0===e?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=a.basename(e,a.extname(e)),this}executableDir(e){return void 0===e?this._executableDir:(this._executableDir=e,this)}helpInformation(e){const t=this.createHelp(),r=this._getOutputContext(e);t.prepareContext({error:r.error,helpWidth:r.helpWidth,outputHasColors:r.hasColors});const n=t.formatHelp(this,t);return r.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(e){const t=!!(e=e||{}).error;let r,n,i;return t?(r=e=>this._outputConfiguration.writeErr(e),n=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(r=e=>this._outputConfiguration.writeOut(e),n=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(n||(e=this._outputConfiguration.stripColor(e)),r(e)),hasColors:n,helpWidth:i}}outputHelp(e){let t;"function"==typeof e&&(t=e,e=void 0);const r=this._getOutputContext(e),n={error:r.error,write:r.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let i=this.helpInformation({error:r.error});if(t&&(i=t(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(e=>e.emit("afterAllHelp",n))}helpOption(e,t){return"boolean"==typeof e?(e?(null===this._helpOption&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return void 0===this._helpOption&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(h.exitCode??0);0===t&&e&&"function"!=typeof e&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${r.join("', '")}'`);const n=`${e}Help`;return this.on(n,e=>{let r;r="function"==typeof t?t({error:e.error,command:e.command}):t,r&&e.write(`${r}\n`)}),this}_outputHelpIfRequested(e){const t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}}function I(e){return e.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r,n="127.0.0.1",i="9229";return null!==(r=e.match(/^(--inspect(-brk)?)$/))?t=r[1]:null!==(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=r[1],/^\d+$/.test(r[3])?i=r[3]:n=r[3]):null!==(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=r[1],n=r[3],i=r[4]),t&&"0"!==i?`${t}=${n}:${parseInt(i)+1}`:e})}function S(){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 g.Command=w,g.useColor=S,g}(),{CommanderError:a,InvalidArgumentError:l}=d(),{Help:h}=_(),{Option:u}=A();return c.program=new o,c.createCommand=e=>new o(e),c.createOption=(e,t)=>new u(e,t),c.createArgument=(e,t)=>new s(e,t),c.Command=o,c.Option=u,c.Argument=s,c.Help=h,c.CommanderError=a,c.InvalidArgumentError=l,c.InvalidOptionArgumentError=l,c}(),b=a(S);const{program:T,createCommand:R,createArgument:N,createOption:L,CommanderError:x,InvalidArgumentError:P,InvalidOptionArgumentError:k,Command:H,Argument:D,Option:F,Help:G}=b;var V,j,M,U,W,q,X,B,Y,z,K,J,Z,Q,ee,te,re,ne,ie,se,oe,ae,le,he,ce,ue,pe,de,me,fe,ge,Ee,_e,ve,Oe,Ae,$e,Ce,we,Ie,ye,Se,be,Te,Re,Ne,Le,xe,Pe,ke,He,De,Fe,Ge,Ve,je,Me,Ue,We,qe,Xe,Be,Ye,ze,Ke,Je,Ze,Qe,et,tt,rt,nt,it,st,ot,at,lt,ht,ct,ut,pt,dt,mt,ft,gt,Et,_t,vt,Ot,At,$t,Ct={exports:{}};function wt(){if(j)return V;j=1;const e=Number.MAX_SAFE_INTEGER||9007199254740991;return V={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}function It(){if(U)return M;U=1;const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};return M=e}function yt(){return W||(W=1,function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=wt(),s=It(),o=(t=e.exports={}).re=[],a=t.safeRe=[],l=t.src=[],h=t.safeSrc=[],c=t.t={};let u=0;const p="[a-zA-Z0-9-]",d=[["\\s",1],["\\d",i],[p,n]],m=(e,t,r)=>{const n=(e=>{for(const[t,r]of d)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e})(t),i=u++;s(e,i,t),c[e]=i,l[i]=t,h[i]=n,o[i]=new RegExp(t,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[c.NUMERICIDENTIFIER]})\\.(${l[c.NUMERICIDENTIFIER]})\\.(${l[c.NUMERICIDENTIFIER]})`),m("MAINVERSIONLOOSE",`(${l[c.NUMERICIDENTIFIERLOOSE]})\\.(${l[c.NUMERICIDENTIFIERLOOSE]})\\.(${l[c.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASEIDENTIFIER",`(?:${l[c.NONNUMERICIDENTIFIER]}|${l[c.NUMERICIDENTIFIER]})`),m("PRERELEASEIDENTIFIERLOOSE",`(?:${l[c.NONNUMERICIDENTIFIER]}|${l[c.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASE",`(?:-(${l[c.PRERELEASEIDENTIFIER]}(?:\\.${l[c.PRERELEASEIDENTIFIER]})*))`),m("PRERELEASELOOSE",`(?:-?(${l[c.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[c.PRERELEASEIDENTIFIERLOOSE]})*))`),m("BUILDIDENTIFIER",`${p}+`),m("BUILD",`(?:\\+(${l[c.BUILDIDENTIFIER]}(?:\\.${l[c.BUILDIDENTIFIER]})*))`),m("FULLPLAIN",`v?${l[c.MAINVERSION]}${l[c.PRERELEASE]}?${l[c.BUILD]}?`),m("FULL",`^${l[c.FULLPLAIN]}$`),m("LOOSEPLAIN",`[v=\\s]*${l[c.MAINVERSIONLOOSE]}${l[c.PRERELEASELOOSE]}?${l[c.BUILD]}?`),m("LOOSE",`^${l[c.LOOSEPLAIN]}$`),m("GTLT","((?:<|>)?=?)"),m("XRANGEIDENTIFIERLOOSE",`${l[c.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),m("XRANGEIDENTIFIER",`${l[c.NUMERICIDENTIFIER]}|x|X|\\*`),m("XRANGEPLAIN",`[v=\\s]*(${l[c.XRANGEIDENTIFIER]})(?:\\.(${l[c.XRANGEIDENTIFIER]})(?:\\.(${l[c.XRANGEIDENTIFIER]})(?:${l[c.PRERELEASE]})?${l[c.BUILD]}?)?)?`),m("XRANGEPLAINLOOSE",`[v=\\s]*(${l[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[c.XRANGEIDENTIFIERLOOSE]})(?:${l[c.PRERELEASELOOSE]})?${l[c.BUILD]}?)?)?`),m("XRANGE",`^${l[c.GTLT]}\\s*${l[c.XRANGEPLAIN]}$`),m("XRANGELOOSE",`^${l[c.GTLT]}\\s*${l[c.XRANGEPLAINLOOSE]}$`),m("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),m("COERCE",`${l[c.COERCEPLAIN]}(?:$|[^\\d])`),m("COERCEFULL",l[c.COERCEPLAIN]+`(?:${l[c.PRERELEASE]})?`+`(?:${l[c.BUILD]})?(?:$|[^\\d])`),m("COERCERTL",l[c.COERCE],!0),m("COERCERTLFULL",l[c.COERCEFULL],!0),m("LONETILDE","(?:~>?)"),m("TILDETRIM",`(\\s*)${l[c.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",m("TILDE",`^${l[c.LONETILDE]}${l[c.XRANGEPLAIN]}$`),m("TILDELOOSE",`^${l[c.LONETILDE]}${l[c.XRANGEPLAINLOOSE]}$`),m("LONECARET","(?:\\^)"),m("CARETTRIM",`(\\s*)${l[c.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",m("CARET",`^${l[c.LONECARET]}${l[c.XRANGEPLAIN]}$`),m("CARETLOOSE",`^${l[c.LONECARET]}${l[c.XRANGEPLAINLOOSE]}$`),m("COMPARATORLOOSE",`^${l[c.GTLT]}\\s*(${l[c.LOOSEPLAIN]})$|^$`),m("COMPARATOR",`^${l[c.GTLT]}\\s*(${l[c.FULLPLAIN]})$|^$`),m("COMPARATORTRIM",`(\\s*)${l[c.GTLT]}\\s*(${l[c.LOOSEPLAIN]}|${l[c.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",m("HYPHENRANGE",`^\\s*(${l[c.XRANGEPLAIN]})\\s+-\\s+(${l[c.XRANGEPLAIN]})\\s*$`),m("HYPHENRANGELOOSE",`^\\s*(${l[c.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[c.XRANGEPLAINLOOSE]})\\s*$`),m("STAR","(<|>)?=?\\s*\\*"),m("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),m("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(Ct,Ct.exports)),Ct.exports}function St(){if(X)return q;X=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return q=r=>r?"object"!=typeof r?e:r:t}function bt(){if(Y)return B;Y=1;const e=/^[0-9]+$/,t=(t,r)=>{if("number"==typeof t&&"number"==typeof r)return t===r?0:t<r?-1:1;const n=e.test(t),i=e.test(r);return n&&i&&(t=+t,r=+r),t===r?0:n&&!i?-1:i&&!n?1:t<r?-1:1};return B={compareIdentifiers:t,rcompareIdentifiers:(e,r)=>t(r,e)}}function Tt(){if(K)return z;K=1;const e=It(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:r}=wt(),{safeRe:n,t:i}=yt(),s=St(),{compareIdentifiers:o}=bt();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>t)throw new TypeError(`version is longer than ${t} characters`);e("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(e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<r)return t}return e}):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(t){if(e("SemVer.compare",this.version,this.options,t),!(t instanceof a)){if("string"==typeof t&&t===this.version)return 0;t=new a(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(e){return e instanceof a||(e=new a(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(t){if(t instanceof a||(t=new a(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{const n=this.prerelease[r],i=t.prerelease[r];if(e("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(t){t instanceof a||(t=new a(t,this.options));let r=0;do{const n=this.build[r],i=t.build[r];if(e("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(e,t,r){if(e.startsWith("pre")){if(!t&&!1===r)throw new Error("invalid increment argument: identifier is empty");if(t){const e=`-${t}`.match(this.options.loose?n[i.PRERELEASELOOSE]:n[i.PRERELEASE]);if(!e||e[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,r),this.inc("pre",t,r);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,r),this.inc("pre",t,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 e=Number(r)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let n=this.prerelease.length;for(;--n>=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(t===this.prerelease.join(".")&&!1===r)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let n=[t,e];if(!1===r&&(n=[t]),((e,t)=>{const r=t.split(".");if(r.length>e.length)return!1;for(let t=0;t<r.length;t++)if(0!==o(e[t],r[t]))return!1;return!0})(this.prerelease,t)){const e=this.prerelease[t.split(".").length];isNaN(e)&&(this.prerelease=n)}else this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return z=a}function Rt(){if(Z)return J;Z=1;const e=Tt();return J=(t,r,n=!1)=>{if(t instanceof e)return t;try{return new e(t,r)}catch(e){if(!n)return null;throw e}}}function Nt(){if(ge)return fe;ge=1;const e=Tt();return fe=(t,r,n)=>new e(t,n).compare(new e(r,n))}function Lt(){if($e)return Ae;$e=1;const e=Tt();return Ae=(t,r,n)=>{const i=new e(t,n),s=new e(r,n);return i.compare(s)||i.compareBuild(s)}}function xt(){if(be)return Se;be=1;const e=Nt();return Se=(t,r,n)=>e(t,r,n)>0}function Pt(){if(Re)return Te;Re=1;const e=Nt();return Te=(t,r,n)=>e(t,r,n)<0}function kt(){if(Le)return Ne;Le=1;const e=Nt();return Ne=(t,r,n)=>0===e(t,r,n)}function Ht(){if(Pe)return xe;Pe=1;const e=Nt();return xe=(t,r,n)=>0!==e(t,r,n)}function Dt(){if(He)return ke;He=1;const e=Nt();return ke=(t,r,n)=>e(t,r,n)>=0}function Ft(){if(Fe)return De;Fe=1;const e=Nt();return De=(t,r,n)=>e(t,r,n)<=0}function Gt(){if(Ve)return Ge;Ve=1;const e=kt(),t=Ht(),r=xt(),n=Dt(),i=Pt(),s=Ft();return Ge=(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 e(o,l,h);case"!=":return t(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 Vt(){if(Ye)return Be;Ye=1;const e=/\s+/g;class t{constructor(r,s){if(s=n(s),r instanceof t)return r.loose===!!s.loose&&r.includePrerelease===!!s.includePrerelease?r:new t(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(e," "),this.set=this.raw.split("||").map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter(e=>!g(e[0])),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&E(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+="||");const t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=" "),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){e=e.replace(f,"");const t=((this.options.includePrerelease&&d)|(this.options.loose&&m))+":"+e,n=r.get(t);if(n)return n;const o=this.options.loose,l=o?a[h.HYPHENRANGELOOSE]:a[h.HYPHENRANGE];e=e.replace(l,T(this.options.includePrerelease)),s("hyphen replace",e),e=e.replace(a[h.COMPARATORTRIM],c),s("comparator trim",e),e=e.replace(a[h.TILDETRIM],u),s("tilde trim",e),e=e.replace(a[h.CARETTRIM],p),s("caret trim",e);let E=e.split(" ").map(e=>v(e,this.options)).join(" ").split(/\s+/).map(e=>b(e,this.options));o&&(E=E.filter(e=>(s("loose invalid filter",e,this.options),!!e.match(a[h.COMPARATORLOOSE])))),s("range list",E);const _=new Map,O=E.map(e=>new i(e,this.options));for(const e of O){if(g(e))return[e];_.set(e.value,e)}_.size>1&&_.has("")&&_.delete("");const A=[..._.values()];return r.set(t,A),A}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some(t=>_(t,r)&&e.set.some(e=>_(e,r)&&t.every(t=>e.every(e=>t.intersects(e,r)))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new o(e,this.options)}catch(e){return!1}for(let t=0;t<this.set.length;t++)if(R(this.set[t],e,this.options))return!0;return!1}}Be=t;const r=new(Xe?qe:(Xe=1,qe=class{constructor(){this.max=1e3,this.map=new Map}get(e){const t=this.map.get(e);return void 0===t?void 0:(this.map.delete(e),this.map.set(e,t),t)}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&void 0!==t){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}})),n=St(),i=jt(),s=It(),o=Tt(),{safeRe:a,src:l,t:h,comparatorTrimReplace:c,tildeTrimReplace:u,caretTrimReplace:p}=yt(),{FLAG_INCLUDE_PRERELEASE:d,FLAG_LOOSE:m}=wt(),f=new RegExp(l[h.BUILD],"g"),g=e=>"<0.0.0-0"===e.value,E=e=>""===e.value,_=(e,t)=>{let r=!0;const n=e.slice();let i=n.pop();for(;r&&n.length;)r=n.every(e=>i.intersects(e,t)),i=n.pop();return r},v=(e,t)=>(e=e.replace(a[h.BUILD],""),s("comp",e,t),e=C(e,t),s("caret",e),e=A(e,t),s("tildes",e),e=I(e,t),s("xrange",e),e=S(e,t),s("stars",e),e),O=e=>!e||"x"===e.toLowerCase()||"*"===e,A=(e,t)=>e.trim().split(/\s+/).map(e=>$(e,t)).join(" "),$=(e,t)=>{const r=t.loose?a[h.TILDELOOSE]:a[h.TILDE],n=t.includePrerelease?"-0":"";return e.replace(r,(t,r,i,o,a)=>{let l;return s("tilde",e,t,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=(e,t)=>e.trim().split(/\s+/).map(e=>w(e,t)).join(" "),w=(e,t)=>{s("caret",e,t);const r=t.loose?a[h.CARETLOOSE]:a[h.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,(t,r,i,o,a)=>{let l;return s("caret",e,t,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})},I=(e,t)=>(s("replaceXRanges",e,t),e.split(/\s+/).map(e=>y(e,t)).join(" ")),y=(e,t)=>{e=e.trim();const r=t.loose?a[h.XRANGELOOSE]:a[h.XRANGE];return e.replace(r,(r,n,i,o,a,l)=>{if(s("xRange",e,r,n,i,o,a,l),((e,t,r)=>O(e)&&!O(t)||O(t)&&r&&!O(r))(i,o,a))return e;const h=O(i),c=h||O(o),u=c||O(a),p=u;return"="===n&&p&&(n=""),l=t.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})},S=(e,t)=>(s("replaceStars",e,t),e.trim().replace(a[h.STAR],"")),b=(e,t)=>(s("replaceGTE0",e,t),e.trim().replace(a[t.includePrerelease?h.GTE0PRE:h.GTE0],"")),T=e=>(t,r,n,i,s,o,a,l,h,c,u,p)=>`${r=O(n)?"":O(i)?`>=${n}.0.0${e?"-0":""}`:O(s)?`>=${n}.${i}.0${e?"-0":""}`:o?`>=${r}`:`>=${r}${e?"-0":""}`} ${l=O(h)?"":O(c)?`<${+h+1}.0.0-0`:O(u)?`<${h}.${+c+1}.0-0`:p?`<=${h}.${c}.${u}-${p}`:e?`<${h}.${c}.${+u+1}-0`:`<=${l}`}`.trim(),R=(e,t,r)=>{for(let r=0;r<e.length;r++)if(!e[r].test(t))return!1;if(t.prerelease.length&&!r.includePrerelease){for(let r=0;r<e.length;r++)if(s(e[r].semver),e[r].semver!==i.ANY&&e[r].semver.prerelease.length>0){const n=e[r].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0};return Be}function jt(){if(Ke)return ze;Ke=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(n,i){if(i=r(i),n instanceof t){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===e?this.value="":this.value=this.operator+this.semver.version,o("comp",this)}parse(t){const r=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],s=t.match(r);if(!s)throw new TypeError(`Invalid comparator: ${t}`);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=e}toString(){return this.value}test(t){if(o("Comparator.test",t,this.options.loose),this.semver===e||t===e)return!0;if("string"==typeof t)try{t=new a(t,this.options)}catch(e){return!1}return s(t,this.operator,this.semver,this.options)}intersects(e,n){if(!(e instanceof t))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new l(e.value,n).test(this.value):""===e.operator?""===e.value||new l(this.value,n).test(e.semver):!((n=r(n)).includePrerelease&&("<0.0.0-0"===this.value||"<0.0.0-0"===e.value)||!n.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0"))||(!this.operator.startsWith(">")||!e.operator.startsWith(">"))&&(!this.operator.startsWith("<")||!e.operator.startsWith("<"))&&(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))&&!(s(this.semver,"<",e.semver,n)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))&&!(s(this.semver,">",e.semver,n)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))}}ze=t;const r=St(),{safeRe:n,t:i}=yt(),s=Gt(),o=It(),a=Tt(),l=Vt();return ze}function Mt(){if(Ze)return Je;Ze=1;const e=Vt();return Je=(t,r,n)=>{try{r=new e(r,n)}catch(e){return!1}return r.test(t)},Je}function Ut(){if(lt)return at;lt=1;const e=Vt();return at=(t,r)=>{try{return new e(t,r).range||"*"}catch(e){return null}},at}function Wt(){if(ct)return ht;ct=1;const e=Tt(),t=jt(),{ANY:r}=t,n=Vt(),i=Mt(),s=xt(),o=Pt(),a=Ft(),l=Dt();return ht=(h,c,u,p)=>{let d,m,f,g,E;switch(h=new e(h,p),c=new n(c,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(h,c,p))return!1;for(let e=0;e<c.set.length;++e){const n=c.set[e];let i=null,s=null;if(n.forEach(e=>{e.semver===r&&(e=new t(">=0.0.0")),i=i||e,s=s||e,d(e.semver,i.semver,p)?i=e:f(e.semver,s.semver,p)&&(s=e)}),i.operator===g||i.operator===E)return!1;if((!s.operator||s.operator===g)&&m(h,s.semver))return!1;if(s.operator===E&&f(h,s.semver))return!1}return!0},ht}var qt,Xt,Bt=function(){if($t)return At;$t=1;const e=yt(),t=wt(),r=Tt(),n=bt(),i=Rt(),s=function(){if(ee)return Q;ee=1;const e=Rt();return Q=(t,r)=>{const n=e(t,r);return n?n.version:null}}(),o=function(){if(re)return te;re=1;const e=Rt();return te=(t,r)=>{const n=e(t.trim().replace(/^[=v]+/,""),r);return n?n.version:null}}(),a=function(){if(ie)return ne;ie=1;const e=Tt();return ne=(t,r,n,i,s)=>{"string"==typeof n&&(s=i,i=n,n=void 0);try{return new e(t instanceof e?t.version:t,n).inc(r,i,s).version}catch(e){return null}}}(),l=function(){if(oe)return se;oe=1;const e=Rt();return se=(t,r)=>{const n=e(t,null,!0),i=e(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(le)return ae;le=1;const e=Tt();return ae=(t,r)=>new e(t,r).major}(),c=function(){if(ce)return he;ce=1;const e=Tt();return he=(t,r)=>new e(t,r).minor}(),u=function(){if(pe)return ue;pe=1;const e=Tt();return ue=(t,r)=>new e(t,r).patch}(),p=function(){if(me)return de;me=1;const e=Rt();return de=(t,r)=>{const n=e(t,r);return n&&n.prerelease.length?n.prerelease:null}}(),d=Nt(),m=function(){if(_e)return Ee;_e=1;const e=Nt();return Ee=(t,r,n)=>e(r,t,n)}(),f=function(){if(Oe)return ve;Oe=1;const e=Nt();return ve=(t,r)=>e(t,r,!0)}(),g=Lt(),E=function(){if(we)return Ce;we=1;const e=Lt();return Ce=(t,r)=>t.sort((t,n)=>e(t,n,r))}(),_=function(){if(ye)return Ie;ye=1;const e=Lt();return Ie=(t,r)=>t.sort((t,n)=>e(n,t,r))}(),v=xt(),O=Pt(),A=kt(),$=Ht(),C=Dt(),w=Ft(),I=Gt(),y=function(){if(Me)return je;Me=1;const e=Tt(),t=Rt(),{safeRe:r,t:n}=yt();return je=(i,s)=>{if(i instanceof e)return i;if("number"==typeof i&&(i=String(i)),"string"!=typeof i)return null;let o=null;if((s=s||{}).rtl){const e=s.includePrerelease?r[n.COERCERTLFULL]:r[n.COERCERTL];let t;for(;(t=e.exec(i))&&(!o||o.index+o[0].length!==i.length);)o&&t.index+t[0].length===o.index+o[0].length||(o=t),e.lastIndex=t.index+t[1].length+t[2].length;e.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 t(`${a}.${l}.${h}${c}${u}`,s)}}(),S=function(){if(We)return Ue;We=1;const e=Rt(),t=wt(),r=Tt(),n=e=>e.startsWith("pre");return Ue=(i,s,o)=>{if(!t.RELEASE_TYPES.includes(s))return null;const a=((t,n)=>{const i=t instanceof r?t.version:t;return e(i,n)})(i,o);return a&&((e,t)=>{if(n(t))return e.version;switch(e.prerelease=[],t){case"major":e.minor=0,e.patch=0;break;case"minor":e.patch=0}return e.format()})(a,s)}}(),b=jt(),T=Vt(),R=Mt(),N=function(){if(et)return Qe;et=1;const e=Vt();return Qe=(t,r)=>new e(t,r).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" ")),Qe}(),L=function(){if(rt)return tt;rt=1;const e=Tt(),t=Vt();return tt=(r,n,i)=>{let s=null,o=null,a=null;try{a=new t(n,i)}catch(e){return null}return r.forEach(t=>{a.test(t)&&(s&&-1!==o.compare(t)||(s=t,o=new e(s,i)))}),s},tt}(),x=function(){if(it)return nt;it=1;const e=Tt(),t=Vt();return nt=(r,n,i)=>{let s=null,o=null,a=null;try{a=new t(n,i)}catch(e){return null}return r.forEach(t=>{a.test(t)&&(s&&1!==o.compare(t)||(s=t,o=new e(s,i)))}),s},nt}(),P=function(){if(ot)return st;ot=1;const e=Tt(),t=Vt(),r=xt();return st=(n,i)=>{n=new t(n,i);let s=new e("0.0.0");if(n.test(s))return s;if(s=new e("0.0.0-0"),n.test(s))return s;s=null;for(let t=0;t<n.set.length;++t){const i=n.set[t];let o=null;i.forEach(t=>{const n=new e(t.semver.version);switch(t.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: ${t.operator}`)}}),!o||s&&!r(s,o)||(s=o)}return s&&n.test(s)?s:null},st}(),k=Ut(),H=Wt(),D=function(){if(pt)return ut;pt=1;const e=Wt();return ut=(t,r,n)=>e(t,r,">",n),ut}(),F=function(){if(mt)return dt;mt=1;const e=Wt();return dt=(t,r,n)=>e(t,r,"<",n),dt}(),G=function(){if(gt)return ft;gt=1;const e=Vt();return ft=(t,r,n)=>(t=new e(t,n),r=new e(r,n),t.intersects(r,n))}(),V=function(){if(_t)return Et;_t=1;const e=Mt(),t=Nt();return Et=(r,n,i)=>{const s=[];let o=null,a=null;const l=r.sort((e,r)=>t(e,r,i));for(const t of l)e(t,n,i)?(a=t,o||(o=t)):(a&&s.push([o,a]),a=null,o=null);o&&s.push([o,null]);const h=[];for(const[e,t]of s)e===t?h.push(e):t||e!==l[0]?t?e===l[0]?h.push(`<=${t}`):h.push(`${e} - ${t}`):h.push(`>=${e}`):h.push("*");const c=h.join(" || "),u="string"==typeof n.raw?n.raw:String(n);return c.length<u.length?c:n},Et}(),j=function(){if(Ot)return vt;Ot=1;const e=Vt(),t=jt(),{ANY:r}=t,n=Mt(),i=Nt(),s=[new t(">=0.0.0-0")],o=[new t(">=0.0.0")],a=(e,t,a)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===r){if(1===t.length&&t[0].semver===r)return!0;e=a.includePrerelease?s:o}if(1===t.length&&t[0].semver===r){if(a.includePrerelease)return!0;t=o}const c=new Set;let u,p,d,m,f,g,E;for(const t of e)">"===t.operator||">="===t.operator?u=l(u,t,a):"<"===t.operator||"<="===t.operator?p=h(p,t,a):c.add(t.semver);if(c.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 e of c){if(u&&!n(e,String(u),a))return null;if(p&&!n(e,String(p),a))return null;for(const r of t)if(!n(e,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 e of t){if(E=E||">"===e.operator||">="===e.operator,g=g||"<"===e.operator||"<="===e.operator,u)if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),">"===e.operator||">="===e.operator){if(m=l(u,e,a),m===e&&m!==u)return!1}else if(">="===u.operator&&!e.test(u.semver))return!1;if(p)if(_&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===_.major&&e.semver.minor===_.minor&&e.semver.patch===_.patch&&(_=!1),"<"===e.operator||"<="===e.operator){if(f=h(p,e,a),f===e&&f!==p)return!1}else if("<="===p.operator&&!e.test(p.semver))return!1;if(!e.operator&&(p||u)&&0!==d)return!1}return!(u&&g&&!p&&0!==d||p&&E&&!u&&0!==d||v||_)},l=(e,t,r)=>{if(!e)return t;const n=i(e.semver,t.semver,r);return n>0?e:n<0||">"===t.operator&&">="===e.operator?t:e},h=(e,t,r)=>{if(!e)return t;const n=i(e.semver,t.semver,r);return n<0?e:n>0||"<"===t.operator&&"<="===e.operator?t:e};return vt=(t,r,n={})=>{if(t===r)return!0;t=new e(t,n),r=new e(r,n);let i=!1;e:for(const e of t.set){for(const t of r.set){const r=a(e,t,n);if(i=i||null!==r,r)continue e}if(i)return!1}return!0}}();return At={parse:i,valid:s,clean:o,inc:a,diff:l,major:h,minor:c,patch:u,prerelease:p,compare:d,rcompare:m,compareLoose:f,compareBuild:g,sort:E,rsort:_,gt:v,lt:O,eq:A,neq:$,gte:C,lte:w,cmp:I,coerce:y,truncate:S,Comparator:b,Range:T,satisfies:R,toComparators:N,maxSatisfying:L,minSatisfying:x,minVersion:P,validRange:k,outside:H,gtr:D,ltr:F,intersects:G,simplifyRange:V,subset:j,SemVer:r,re:e.re,src:e.src,tokens:e.t,SEMVER_SPEC_VERSION:t.SEMVER_SPEC_VERSION,RELEASE_TYPES:t.RELEASE_TYPES,compareIdentifiers:n.compareIdentifiers,rcompareIdentifiers:n.rcompareIdentifiers}}(),Yt=a(Bt);function zt(e){const t=Yt.prerelease(e)?.[0];return"alpha"===t||"beta"===t?t:"stable"}function Kt(e){const t={};if(!n.existsSync(e))return t;for(const r of n.readFileSync(e,"utf8").split(/\r?\n/)){if(!r||r.startsWith("#"))continue;const e=r.indexOf("=");e>0&&(t[r.slice(0,e)]=r.slice(e+1))}return t}!function(){if(Xt)return qt;Xt=1;const e=n,{spawnSync:r}=t;qt={processStartIdentity:function(t,n=process.platform){if(Number.isInteger(t)&&!(t<=0)){if("linux"===n)try{const r=e.readFileSync(`/proc/${t}/stat`,"utf8"),n=r.lastIndexOf(")");if(n<0)return;const i=r.slice(n+2).trim().split(/\s+/)[19];return i?`linux:${i}`:void 0}catch{return}if(["darwin","freebsd","openbsd","aix","sunos"].includes(n)){const e=r("ps",["-o","lstart=","-p",String(t)],{encoding:"utf8",timeout:1e3}),i=0===e.status?e.stdout.trim().replace(/\s+/g," "):"";return i?`${n}:${i}`:void 0}if("win32"===n){const e=r("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${t} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`],{encoding:"utf8",timeout:2e3}),n=0===e.status?e.stdout.trim():"";return/^\d+$/.test(n)?`win32:${n}`:void 0}}}}}();const Jt=r.resolve(__dirname,".."),Zt=JSON.parse(n.readFileSync(r.join(Jt,"package.json"),"utf8")),Qt=process.env.TASK_HANDOFF_NPM_COMMAND||"npm",er=zt(Zt.version);function tr(e,r,n={}){const i=t.spawnSync(e,r,{encoding:"utf8",...n});if(0!==i.status){const t=[i.stdout,i.stderr].filter(Boolean).join("\n").trim();throw new Error(`${e} ${r.join(" ")} failed${t?`:\n${t}`:""}`)}return String(i.stdout||"").trim()}function rr(){return function(e={}){const t=Kt(e.controlPlaneEnvFile||"/etc/task-handoff/control-plane.env"),r=Kt(e.nodeAgentEnvFile||"/etc/task-handoff/node-agent.env");return["--service-user",(i=e.nodeAgentUnitFile||"/etc/systemd/system/task-handoff-node-agent.service",n.existsSync(i)&&n.readFileSync(i,"utf8").match(/^User=(.+)$/m)?.[1]||"root"),"--control-plane-data-dir",t.TASK_HANDOFF_CONTROL_PLANE_DATA_DIR||"/var/lib/task-handoff/control-plane","--node-agent-data-dir",r.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",r.TASK_HANDOFF_NODE_AGENT_HOST||"127.0.0.1","--node-agent-port",r.TASK_HANDOFF_NODE_AGENT_PORT||"8091","--node-agent-ipc-path",r.TASK_HANDOFF_NODE_AGENT_IPC_PATH||"/run/task-handoff/node-agent.sock","--auth-mode",t.TASK_HANDOFF_CONTROL_PLANE_AUTH_MODE||"password",...t.TASK_HANDOFF_CONTROL_PLANE_STATIC_DIR?["--static-dir",t.TASK_HANDOFF_CONTROL_PLANE_STATIC_DIR]:[]];var i}()}function nr(e){const r=t.spawnSync("systemctl",["is-active",e],{encoding:"utf8"});return String(r.stdout||"unknown").trim()||"unknown"}async function ir(e){hr();const t=rr(),r=t[t.indexOf("--node-agent-ipc-path")+1],i=Number(t[t.indexOf("--control-plane-port")+1]);if("stop"===e)return tr("systemctl",["stop","task-handoff-control-plane.service"],{stdio:"inherit"}),tr("systemctl",["stop","task-handoff-node-agent.service"],{stdio:"inherit"}),void console.log("Stopped TaskHandoff server services.");tr("systemctl",[e,"task-handoff-node-agent.service"],{stdio:"inherit"}),function(e,t=3e4){const r=Date.now()+t;for(;Date.now()<r;){try{if(n.statSync(e).isSocket())return}catch{}Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,250)}throw new Error(`Node agent socket was not ready after ${t}ms: ${e}`)}(r),tr("systemctl",[e,"task-handoff-control-plane.service"],{stdio:"inherit"}),await function(e,t=3e4){return new Promise((r,n)=>{const i=Date.now()+t,o=()=>{const t=s.get({host:"127.0.0.1",port:e,path:"/api/health",timeout:1e3},e=>{if(e.resume(),200===e.statusCode)return r();a()});t.on("timeout",()=>t.destroy()),t.on("error",a)},a=()=>Date.now()>=i?n(new Error(`Control plane was not healthy on port ${e} after ${t}ms.`)):setTimeout(o,250);o()})}(i),console.log(("start"===e?"Started":"Restarted")+" TaskHandoff server services.")}function sr(e,t){return t||("stable"===e?"latest":e)}function or(e){if((t=e).trim()!==t||/^[v=]/.test(t)||null===Yt.valid(t))throw new P("must be an exact semantic version");var t;return e}function ar(){return new F("--channel <channel>","stable, beta, or alpha").choices(["stable","beta","alpha"]).default(er).conflicts("to")}function lr(e,t){const r=["view",`@task-handoff/server@${e}`,"version","--json"];t&&r.push("--registry",t);const n=JSON.parse(tr(Qt,r));if("string"!=typeof n)throw new Error(`npm target ${e} did not resolve to one version.`);return n}function hr(){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 cr(e){return[["--service-user",e.serviceUser],["--control-plane-data-dir",e.controlPlaneDataDir],["--node-agent-data-dir",e.nodeAgentDataDir],["--control-plane-host",e.controlPlaneHost],["--control-plane-port",e.controlPlanePort],["--node-agent-host",e.nodeAgentHost],["--node-agent-port",e.nodeAgentPort],["--node-agent-ipc-path",e.nodeAgentIpcPath],["--auth-mode",e.authMode],["--static-dir",e.staticDir]].flatMap(([e,t])=>void 0===t?[]:[e,t])}(async function(){const e=(new H).name("task-handoff").description("Manage a TaskHandoff server and run its installed runtimes.").version(Zt.version).showSuggestionAfterError();e.command("control-plane","Run the installed control-plane runtime.",{executableFile:"task-handoff-control-plane"}),e.command("node-agent","Run the installed node-agent runtime.",{executableFile:"task-handoff-node-agent"}),e.command("controlled-instance","Run the installed controlled-instance runtime.",{executableFile:"task-handoff-controlled-instance"}),e.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>").option("--preserve-current","Reuse the installed service configuration").option("--materialize-only","Rewrite service configuration without starting services").action(e=>{hr(),tr(process.execPath,[r.join(Jt,"bin","task-handoff-install-server"),...e.preserveCurrent?rr():[],...cr(e),...e.materializeOnly?["--materialize-only"]:[]],{stdio:"inherit"})}),e.command("status").description("Show the installed version and service state.").action(()=>{console.log(`Package: @task-handoff/server ${Zt.version}`),console.log(`Node agent: ${nr("task-handoff-node-agent.service")}`),console.log(`Control plane: ${nr("task-handoff-control-plane.service")}`)}),e.command("start").description("Start the node agent and control plane services.").action(()=>ir("start")),e.command("stop").description("Stop the control plane and node agent services.").action(()=>ir("stop")),e.command("restart").description("Restart the node agent and control plane services safely.").action(()=>ir("restart")),e.command("check").description("Check npm for an available server version.").addOption(ar()).option("--registry <url>").action(e=>{const t=sr(e.channel),r=lr(t,e.registry);console.log(`Installed: ${Zt.version}`),console.log(`Available (${e.channel} channel, npm ${t}): ${r}`),console.log(r===Zt.version?"Up to date.":`Update available: task-handoff update --to ${r}`)}),e.command("update").description("Update the server package set and restart services safely.").addOption(ar()).option("--to <version>","exact semantic version",or).option("--registry <url>").option("--force").action(async e=>{hr();const t=sr(e.channel,e.to),i=t===Zt.version?Zt.version:lr(t,e.registry);if(i===Zt.version&&!e.force)return void console.log(`@task-handoff/server ${Zt.version} is already installed.`);const s=function(){const e=function(e){let t=r.resolve(e);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)}}(Jt);if(e)return e;throw new Error(`Cannot determine the npm global prefix from ${Jt}.`)}(),a=rr(),l=a[a.indexOf("--node-agent-ipc-path")+1],h=Number(a[a.indexOf("--control-plane-port")+1]),c=function(e,t){const r=["view",`@task-handoff/server@${e}`,"dist.integrity","--json"];t&&r.push("--registry",t);const n=JSON.parse(tr(Qt,r));if("string"!=typeof n||!/^sha(?:256|384|512)-[A-Za-z0-9+/=]+$/.test(n))throw new Error(`npm did not return immutable integrity metadata for @task-handoff/server@${e}.`);return n}(i,e.registry),u=n.mkdtempSync(r.join(o.tmpdir(),"task-handoff-server-update-")),p=r.join(u,"job.json"),d=(new Date).toISOString();n.writeFileSync(p,`${JSON.stringify({id:`update_cli_${process.pid}_${Date.now()}`,nodeId:"node_cli_server",source:"npm",channel:e.channel||zt(i),fromVersion:Zt.version,toVersion:i,artifactRef:`npm:@task-handoff/server@${i}#${c}`,runtimeArtifacts:[],impact:{runningInstanceCount:0,stoppedInstanceCount:0,activeInstanceCount:0,restartInstanceCount:0,runningInstanceIds:[],stoppedInstanceIds:[],activeInstanceIds:[]},rollout:{phase:"queued",desiredVersion:i,expectedInstanceIds:[],expectedInstanceCount:0,matchedInstanceCount:0,pendingInstanceCount:0,failedInstanceCount:0,deferredInstanceCount:0},status:"queued",createdAt:d,updatedAt:d},null,2)}\n`);try{console.log(`Updating @task-handoff/server ${Zt.version} -> ${i}`),tr(r.join(Jt,"bin","task-handoff-node-update-worker"),["--job-file",p,"--target-version",i,"--npm-command",Qt,"--install-prefix",s,"--node-agent-ipc-path",l,"--control-plane-health-url",`http://127.0.0.1:${h}/api/health`,...e.registry?["--registry",e.registry]:[],"--standalone"],{stdio:"inherit"});const t=JSON.parse(n.readFileSync(p,"utf8"));if("succeeded"!==t.status)throw new Error(t.error?.message||`Update finished with status ${t.status}.`);console.log(`Updated TaskHandoff server to ${i}.`)}catch(e){throw console.error(`Update failed. The updater attempted to restore @task-handoff/server ${Zt.version}.`),e}finally{n.rmSync(u,{recursive:!0,force:!0})}}),await e.parseAsync(process.argv)})().catch(e=>{console.error(`Error: ${e instanceof Error?e.message:String(e)}`),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.25-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.25-alpha.1",
|
|
22
|
+
"@task-handoff/node-agent": "0.0.25-alpha.1",
|
|
23
|
+
"@task-handoff/controlled-instance": "0.0.25-alpha.1"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|