oh-my-ag 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +89 -90
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as r9}from"node:module";var
|
|
3
|
-
`).replace(/^/gm," ".repeat(2))}let Y=[`Usage: ${G.commandUsage($)}`,""],K=G.commandDescription($);if(K.length>0)Y=Y.concat([G.wrap(K,Z,0),""]);let I=G.visibleArguments($).map((
|
|
2
|
+
import{createRequire as r9}from"node:module";var n9=Object.create;var{getPrototypeOf:i9,defineProperty:M4,getOwnPropertyNames:s9}=Object;var o9=Object.prototype.hasOwnProperty;var s=($,G,J)=>{J=$!=null?n9(i9($)):{};let Z=G||!$||!$.__esModule?M4(J,"default",{value:$,enumerable:!0}):J;for(let X of s9($))if(!o9.call(Z,X))M4(Z,X,{get:()=>$[X],enumerable:!0});return Z};var f=($,G)=>()=>(G||$((G={exports:{}}).exports,G),G.exports);var S=r9(import.meta.url);var i1=f((a9)=>{class J2 extends Error{constructor($,G,J){super(J);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=G,this.exitCode=$,this.nestedError=void 0}}class V4 extends J2{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}a9.CommanderError=J2;a9.InvalidArgumentError=V4});var _0=f((J$)=>{var{InvalidArgumentError:$$}=i1();class T4{constructor($,G){switch(this.description=G||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue($,G){if(G===this.defaultValue||!Array.isArray(G))return[$];return G.concat($)}default($,G){return this.defaultValue=$,this.defaultValueDescription=G,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(G,J)=>{if(!this.argChoices.includes(G))throw new $$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(G,J);return G},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function G$($){let G=$.name()+($.variadic===!0?"...":"");return $.required?"<"+G+">":"["+G+"]"}J$.Argument=T4;J$.humanReadableArgName=G$});var Z2=f((Q$)=>{var{humanReadableArgName:z$}=_0();class x4{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands($){let G=$.commands.filter((Z)=>!Z._hidden),J=$._getHelpCommand();if(J&&!J._hidden)G.push(J);if(this.sortSubcommands)G.sort((Z,X)=>{return Z.name().localeCompare(X.name())});return G}compareOptions($,G){let J=(Z)=>{return Z.short?Z.short.replace(/^-/,""):Z.long.replace(/^--/,"")};return J($).localeCompare(J(G))}visibleOptions($){let G=$.options.filter((Z)=>!Z.hidden),J=$._getHelpOption();if(J&&!J.hidden){let Z=J.short&&$._findOption(J.short),X=J.long&&$._findOption(J.long);if(!Z&&!X)G.push(J);else if(J.long&&!X)G.push($.createOption(J.long,J.description));else if(J.short&&!Z)G.push($.createOption(J.short,J.description))}if(this.sortOptions)G.sort(this.compareOptions);return G}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let G=[];for(let J=$.parent;J;J=J.parent){let Z=J.options.filter((X)=>!X.hidden);G.push(...Z)}if(this.sortOptions)G.sort(this.compareOptions);return G}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((G)=>{G.description=G.description||$._argsDescription[G.name()]||""});if($.registeredArguments.find((G)=>G.description))return $.registeredArguments;return[]}subcommandTerm($){let G=$.registeredArguments.map((J)=>z$(J)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(G?" "+G:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,G){return G.visibleCommands($).reduce((J,Z)=>{return Math.max(J,G.subcommandTerm(Z).length)},0)}longestOptionTermLength($,G){return G.visibleOptions($).reduce((J,Z)=>{return Math.max(J,G.optionTerm(Z).length)},0)}longestGlobalOptionTermLength($,G){return G.visibleGlobalOptions($).reduce((J,Z)=>{return Math.max(J,G.optionTerm(Z).length)},0)}longestArgumentTermLength($,G){return G.visibleArguments($).reduce((J,Z)=>{return Math.max(J,G.argumentTerm(Z).length)},0)}commandUsage($){let G=$._name;if($._aliases[0])G=G+"|"+$._aliases[0];let J="";for(let Z=$.parent;Z;Z=Z.parent)J=Z.name()+" "+J;return J+G+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let G=[];if($.argChoices)G.push(`choices: ${$.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")G.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)G.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)G.push(`env: ${$.envVar}`);if(G.length>0)return`${$.description} (${G.join(", ")})`;return $.description}argumentDescription($){let G=[];if($.argChoices)G.push(`choices: ${$.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if($.defaultValue!==void 0)G.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(G.length>0){let J=`(${G.join(", ")})`;if($.description)return`${$.description} ${J}`;return J}return $.description}formatHelp($,G){let J=G.padWidth($,G),Z=G.helpWidth||80,X=2,z=2;function N(j,U){if(U){let q=`${j.padEnd(J+2)}${U}`;return G.wrap(q,Z-2,J+2)}return j}function Q(j){return j.join(`
|
|
3
|
+
`).replace(/^/gm," ".repeat(2))}let Y=[`Usage: ${G.commandUsage($)}`,""],K=G.commandDescription($);if(K.length>0)Y=Y.concat([G.wrap(K,Z,0),""]);let I=G.visibleArguments($).map((j)=>{return N(G.argumentTerm(j),G.argumentDescription(j))});if(I.length>0)Y=Y.concat(["Arguments:",Q(I),""]);let H=G.visibleOptions($).map((j)=>{return N(G.optionTerm(j),G.optionDescription(j))});if(H.length>0)Y=Y.concat(["Options:",Q(H),""]);if(this.showGlobalOptions){let j=G.visibleGlobalOptions($).map((U)=>{return N(G.optionTerm(U),G.optionDescription(U))});if(j.length>0)Y=Y.concat(["Global Options:",Q(j),""])}let B=G.visibleCommands($).map((j)=>{return N(G.subcommandTerm(j),G.subcommandDescription(j))});if(B.length>0)Y=Y.concat(["Commands:",Q(B),""]);return Y.join(`
|
|
4
4
|
`)}padWidth($,G){return Math.max(G.longestOptionTermLength($,G),G.longestGlobalOptionTermLength($,G),G.longestSubcommandTermLength($,G),G.longestArgumentTermLength($,G))}wrap($,G,J,Z=40){let z=new RegExp(`[\\n][${" \\f\\t\\v - \uFEFF"}]+`);if($.match(z))return $;let N=G-J;if(N<Z)return $;let Q=$.slice(0,J),Y=$.slice(J).replace(`\r
|
|
5
5
|
`,`
|
|
6
|
-
`),K=" ".repeat(J),H=`\\s${""}`,
|
|
7
|
-
|.{1,${N-1}}([${H}]|$)|[^${H}]+?([${H}]|$)`,"g"),
|
|
8
|
-
`)return"";return(
|
|
9
|
-
`)}}Q$.Help=x4});var X2=
|
|
6
|
+
`),K=" ".repeat(J),H=`\\s${""}`,B=new RegExp(`
|
|
7
|
+
|.{1,${N-1}}([${H}]|$)|[^${H}]+?([${H}]|$)`,"g"),j=Y.match(B)||[];return Q+j.map((U,q)=>{if(U===`
|
|
8
|
+
`)return"";return(q>0?K:"")+U.trimEnd()}).join(`
|
|
9
|
+
`)}}Q$.Help=x4});var X2=f((I$)=>{var{InvalidArgumentError:Y$}=i1();class W4{constructor($,G){this.flags=$,this.description=G||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let J=H$($);if(this.short=J.shortFlag,this.long=J.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}default($,G){return this.defaultValue=$,this.defaultValueDescription=G,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let G=$;if(typeof $==="string")G={[$]:!0};return this.implied=Object.assign(this.implied||{},G),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_concatValue($,G){if(G===this.defaultValue||!Array.isArray(G))return[$];return G.concat($)}choices($){return this.argChoices=$.slice(),this.parseArg=(G,J)=>{if(!this.argChoices.includes(G))throw new Y$(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(G,J);return G},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return K$(this.name().replace(/^no-/,""))}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class L4{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((G)=>{if(G.negate)this.negativeOptions.set(G.attributeName(),G);else this.positiveOptions.set(G.attributeName(),G)}),this.negativeOptions.forEach((G,J)=>{if(this.positiveOptions.has(J))this.dualOptions.add(J)})}valueFromOption($,G){let J=G.attributeName();if(!this.dualOptions.has(J))return!0;let Z=this.negativeOptions.get(J).presetArg,X=Z!==void 0?Z:!1;return G.negate===(X===$)}}function K$($){return $.split("-").reduce((G,J)=>{return G+J[0].toUpperCase()+J.slice(1)})}function H$($){let G,J,Z=$.split(/[ |,]+/);if(Z.length>1&&!/^[[<]/.test(Z[1]))G=Z.shift();if(J=Z.shift(),!G&&/^-[^-]$/.test(J))G=J,J=void 0;return{shortFlag:G,longFlag:J}}I$.Option=W4;I$.DualOptions=L4});var A4=f((j$)=>{function U$($,G){if(Math.abs($.length-G.length)>3)return Math.max($.length,G.length);let J=[];for(let Z=0;Z<=$.length;Z++)J[Z]=[Z];for(let Z=0;Z<=G.length;Z++)J[0][Z]=Z;for(let Z=1;Z<=G.length;Z++)for(let X=1;X<=$.length;X++){let z=1;if($[X-1]===G[Z-1])z=0;else z=1;if(J[X][Z]=Math.min(J[X-1][Z]+1,J[X][Z-1]+1,J[X-1][Z-1]+z),X>1&&Z>1&&$[X-1]===G[Z-2]&&$[X-2]===G[Z-1])J[X][Z]=Math.min(J[X][Z],J[X-2][Z-2]+1)}return J[$.length][G.length]}function _$($,G){if(!G||G.length===0)return"";G=Array.from(new Set(G));let J=$.startsWith("--");if(J)$=$.slice(2),G=G.map((N)=>N.slice(2));let Z=[],X=3,z=0.4;if(G.forEach((N)=>{if(N.length<=1)return;let Q=U$($,N),Y=Math.max($.length,N.length);if((Y-Q)/Y>z){if(Q<X)X=Q,Z=[N];else if(Q===X)Z.push(N)}}),Z.sort((N,Q)=>N.localeCompare(Q)),J)Z=Z.map((N)=>`--${N}`);if(Z.length>1)return`
|
|
10
10
|
(Did you mean one of ${Z.join(", ")}?)`;if(Z.length===1)return`
|
|
11
|
-
(Did you mean ${Z[0]}?)`;return""}j$.suggestSimilar=_$});var F4=
|
|
12
|
-
- specify the name in Command constructor or using .name()`);if(G=G||{},G.isDefault)this._defaultCommandName=$._name;if(G.noHelp||G.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,G){return new
|
|
13
|
-
Expecting one of '${J.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(G);else this._lifeCycleHooks[$]=[G];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(G)=>{if(G.code!=="commander.executeSubCommandAsync")throw G};return this}_exit($,G,J){if(this._exitCallback)this._exitCallback(new N2($,G,J));
|
|
14
|
-
- already used by option '${G.flags}'`)}this.options.push($)}_registerCommand($){let G=(Z)=>{return[Z.name()].concat(Z.aliases())},J=G($).find((Z)=>this._findCommand(Z));if(J){let Z=G(this._findCommand(J)).join("|"),X=G($).join("|");throw Error(`cannot add command '${X}' as already have command '${Z}'`)}this.commands.push($)}addOption($){this._registerOption($);let G=$.name(),J=$.attributeName();if($.negate){let X=$.long.replace(/^--no-/,"--");if(!this._findOption(X))this.setOptionValueWithSource(J,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(J,$.defaultValue,"default");let Z=(X,z,N)=>{if(X==null&&$.presetArg!==void 0)X=$.presetArg;let Q=this.getOptionValue(J);if(X!==null&&$.parseArg)X=this._callParseArg($,X,Q,z);else if(X!==null&&$.variadic)X=$._concatValue(X,Q);if(X==null)if($.negate)X=!1;else if($.isBoolean()||$.optional)X=!0;else X="";this.setOptionValueWithSource(J,X,N)};if(this.on("option:"+G,(X)=>{let z=`error: option '${$.flags}' argument '${X}' is invalid.`;Z(X,z,"cli")}),$.envVar)this.on("optionEnv:"+G,(X)=>{let z=`error: option '${$.flags}' value '${X}' from env '${$.envVar}' is invalid.`;Z(X,z,"env")});return this}_optionEx($,G,J,Z,X){if(typeof G==="object"&&G instanceof D4)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let z=this.createOption(G,J);if(z.makeOptionMandatory(!!$.mandatory),typeof Z==="function")z.default(X).argParser(Z);else if(Z instanceof RegExp){let N=Z;Z=(Q,Y)=>{let K=N.exec(Q);return K?K[0]:Y},z.default(X).argParser(Z)}else z.default(Z);return this.addOption(z)}option($,G,J,Z){return this._optionEx({},$,G,J,Z)}requiredOption($,G,J,Z){return this._optionEx({mandatory:!0},$,G,J,Z)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,G){return this.setOptionValueWithSource($,G,void 0)}setOptionValueWithSource($,G,J){if(this._storeOptionsAsProperties)this[$]=G;else this._optionValues[$]=G;return this._optionValueSources[$]=J,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let G;return this._getCommandAndAncestors().forEach((J)=>{if(J.getOptionValueSource($)!==void 0)G=J.getOptionValueSource($)}),G}_prepareUserArgs($,G){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(G=G||{},$===void 0&&G.from===void 0){if(
|
|
11
|
+
(Did you mean ${Z[0]}?)`;return""}j$.suggestSimilar=_$});var F4=f((L$)=>{var M$=S("node:events").EventEmitter,z2=S("node:child_process"),q1=S("node:path"),Q2=S("node:fs"),b=S("node:process"),{Argument:V$,humanReadableArgName:T$}=_0(),{CommanderError:N2}=i1(),{Help:x$}=Z2(),{Option:D4,DualOptions:W$}=X2(),{suggestSimilar:C4}=A4();class Y2 extends M${constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",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._outputConfiguration={writeOut:(G)=>b.stdout.write(G),writeErr:(G)=>b.stderr.write(G),getOutHelpWidth:()=>b.stdout.isTTY?b.stdout.columns:void 0,getErrHelpWidth:()=>b.stderr.isTTY?b.stderr.columns:void 0,outputError:(G,J)=>J(G)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let G=this;G;G=G.parent)$.push(G);return $}command($,G,J){let Z=G,X=J;if(typeof Z==="object"&&Z!==null)X=Z,Z=null;X=X||{};let[,z,N]=$.match(/([^ ]+) *(.*)/),Q=this.createCommand(z);if(Z)Q.description(Z),Q._executableHandler=!0;if(X.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(X.noHelp||X.hidden),Q._executableFile=X.executableFile||null,N)Q.arguments(N);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),Z)return this;return Q}createCommand($){return new Y2($)}createHelp(){return Object.assign(new x$,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,$),this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,G){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
|
|
12
|
+
- specify the name in Command constructor or using .name()`);if(G=G||{},G.isDefault)this._defaultCommandName=$._name;if(G.noHelp||G.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,G){return new V$($,G)}argument($,G,J,Z){let X=this.createArgument($,G);if(typeof J==="function")X.default(Z).argParser(J);else X.default(J);return this.addArgument(X),this}arguments($){return $.trim().split(/ +/).forEach((G)=>{this.argument(G)}),this}addArgument($){let G=this.registeredArguments.slice(-1)[0];if(G&&G.variadic)throw Error(`only the last argument can be variadic '${G.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,G){if(typeof $==="boolean")return this._addImplicitHelpCommand=$,this;$=$??"help [command]";let[,J,Z]=$.match(/([^ ]+) *(.*)/),X=G??"display help for command",z=this.createCommand(J);if(z.helpOption(!1),Z)z.arguments(Z);if(X)z.description(X);return this._addImplicitHelpCommand=!0,this._helpCommand=z,this}addHelpCommand($,G){if(typeof $!=="object")return this.helpCommand($,G),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,G){let J=["preSubcommand","preAction","postAction"];if(!J.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
|
|
13
|
+
Expecting one of '${J.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(G);else this._lifeCycleHooks[$]=[G];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(G)=>{if(G.code!=="commander.executeSubCommandAsync")throw G};return this}_exit($,G,J){if(this._exitCallback)this._exitCallback(new N2($,G,J));b.exit($)}action($){let G=(J)=>{let Z=this.registeredArguments.length,X=J.slice(0,Z);if(this._storeOptionsAsProperties)X[Z]=this;else X[Z]=this.opts();return X.push(this),$.apply(this,X)};return this._actionHandler=G,this}createOption($,G){return new D4($,G)}_callParseArg($,G,J,Z){try{return $.parseArg(G,J)}catch(X){if(X.code==="commander.invalidArgument"){let z=`${Z} ${X.message}`;this.error(z,{exitCode:X.exitCode,code:X.code})}throw X}}_registerOption($){let G=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(G){let J=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${J}'
|
|
14
|
+
- already used by option '${G.flags}'`)}this.options.push($)}_registerCommand($){let G=(Z)=>{return[Z.name()].concat(Z.aliases())},J=G($).find((Z)=>this._findCommand(Z));if(J){let Z=G(this._findCommand(J)).join("|"),X=G($).join("|");throw Error(`cannot add command '${X}' as already have command '${Z}'`)}this.commands.push($)}addOption($){this._registerOption($);let G=$.name(),J=$.attributeName();if($.negate){let X=$.long.replace(/^--no-/,"--");if(!this._findOption(X))this.setOptionValueWithSource(J,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(J,$.defaultValue,"default");let Z=(X,z,N)=>{if(X==null&&$.presetArg!==void 0)X=$.presetArg;let Q=this.getOptionValue(J);if(X!==null&&$.parseArg)X=this._callParseArg($,X,Q,z);else if(X!==null&&$.variadic)X=$._concatValue(X,Q);if(X==null)if($.negate)X=!1;else if($.isBoolean()||$.optional)X=!0;else X="";this.setOptionValueWithSource(J,X,N)};if(this.on("option:"+G,(X)=>{let z=`error: option '${$.flags}' argument '${X}' is invalid.`;Z(X,z,"cli")}),$.envVar)this.on("optionEnv:"+G,(X)=>{let z=`error: option '${$.flags}' value '${X}' from env '${$.envVar}' is invalid.`;Z(X,z,"env")});return this}_optionEx($,G,J,Z,X){if(typeof G==="object"&&G instanceof D4)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let z=this.createOption(G,J);if(z.makeOptionMandatory(!!$.mandatory),typeof Z==="function")z.default(X).argParser(Z);else if(Z instanceof RegExp){let N=Z;Z=(Q,Y)=>{let K=N.exec(Q);return K?K[0]:Y},z.default(X).argParser(Z)}else z.default(Z);return this.addOption(z)}option($,G,J,Z){return this._optionEx({},$,G,J,Z)}requiredOption($,G,J,Z){return this._optionEx({mandatory:!0},$,G,J,Z)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,G){return this.setOptionValueWithSource($,G,void 0)}setOptionValueWithSource($,G,J){if(this._storeOptionsAsProperties)this[$]=G;else this._optionValues[$]=G;return this._optionValueSources[$]=J,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let G;return this._getCommandAndAncestors().forEach((J)=>{if(J.getOptionValueSource($)!==void 0)G=J.getOptionValueSource($)}),G}_prepareUserArgs($,G){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(G=G||{},$===void 0&&G.from===void 0){if(b.versions?.electron)G.from="electron";let Z=b.execArgv??[];if(Z.includes("-e")||Z.includes("--eval")||Z.includes("-p")||Z.includes("--print"))G.from="eval"}if($===void 0)$=b.argv;this.rawArgs=$.slice();let J;switch(G.from){case void 0:case"node":this._scriptPath=$[1],J=$.slice(2);break;case"electron":if(b.defaultApp)this._scriptPath=$[1],J=$.slice(2);else J=$.slice(1);break;case"user":J=$.slice(0);break;case"eval":J=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${G.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",J}parse($,G){let J=this._prepareUserArgs($,G);return this._parseCommand([],J),this}async parseAsync($,G){let J=this._prepareUserArgs($,G);return await this._parseCommand([],J),this}_executeSubCommand($,G){G=G.slice();let J=!1,Z=[".js",".ts",".tsx",".mjs",".cjs"];function X(K,I){let H=q1.resolve(K,I);if(Q2.existsSync(H))return H;if(Z.includes(q1.extname(I)))return;let B=Z.find((j)=>Q2.existsSync(`${H}${j}`));if(B)return`${H}${B}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let z=$._executableFile||`${this._name}-${$._name}`,N=this._executableDir||"";if(this._scriptPath){let K;try{K=Q2.realpathSync(this._scriptPath)}catch(I){K=this._scriptPath}N=q1.resolve(q1.dirname(K),N)}if(N){let K=X(N,z);if(!K&&!$._executableFile&&this._scriptPath){let I=q1.basename(this._scriptPath,q1.extname(this._scriptPath));if(I!==this._name)K=X(N,`${I}-${$._name}`)}z=K||z}J=Z.includes(q1.extname(z));let Q;if(b.platform!=="win32")if(J)G.unshift(z),G=O4(b.execArgv).concat(G),Q=z2.spawn(b.argv[0],G,{stdio:"inherit"});else Q=z2.spawn(z,G,{stdio:"inherit"});else G.unshift(z),G=O4(b.execArgv).concat(G),Q=z2.spawn(b.execPath,G,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((I)=>{b.on(I,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(I)})});let Y=this._exitCallback;Q.on("close",(K)=>{if(K=K??1,!Y)b.exit(K);else Y(new N2(K,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(K)=>{if(K.code==="ENOENT"){let I=N?`searched for local subcommand relative to directory '${N}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",H=`'${z}' does not exist
|
|
15
15
|
- if '${$._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
16
16
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
17
|
-
- ${I}`;throw Error(H)}else if(K.code==="EACCES")throw Error(`'${z}' not executable`);if(!Y)
|
|
17
|
+
- ${I}`;throw Error(H)}else if(K.code==="EACCES")throw Error(`'${z}' not executable`);if(!Y)b.exit(1);else{let I=new N2(1,"commander.executeSubCommandAsync","(error)");I.nestedError=K,Y(I)}}),this.runningCommand=Q}_dispatchSubcommand($,G,J){let Z=this._findCommand($);if(!Z)this.help({error:!0});let X;return X=this._chainOrCallSubCommandHook(X,Z,"preSubcommand"),X=this._chainOrCall(X,()=>{if(Z._executableHandler)this._executeSubCommand(Z,G.concat(J));else return Z._parseCommand(G,J)}),X}_dispatchHelpCommand($){if(!$)this.help();let G=this._findCommand($);if(G&&!G._executableHandler)G.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,G)=>{if($.required&&this.args[G]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(J,Z,X)=>{let z=Z;if(Z!==null&&J.parseArg){let N=`error: command-argument value '${Z}' is invalid for argument '${J.name()}'.`;z=this._callParseArg(J,Z,X,N)}return z};this._checkNumberOfArguments();let G=[];this.registeredArguments.forEach((J,Z)=>{let X=J.defaultValue;if(J.variadic){if(Z<this.args.length){if(X=this.args.slice(Z),J.parseArg)X=X.reduce((z,N)=>{return $(J,N,z)},J.defaultValue)}else if(X===void 0)X=[]}else if(Z<this.args.length){if(X=this.args[Z],J.parseArg)X=$(J,X,J.defaultValue)}G[Z]=X}),this.processedArgs=G}_chainOrCall($,G){if($&&$.then&&typeof $.then==="function")return $.then(()=>G());return G()}_chainOrCallHooks($,G){let J=$,Z=[];if(this._getCommandAndAncestors().reverse().filter((X)=>X._lifeCycleHooks[G]!==void 0).forEach((X)=>{X._lifeCycleHooks[G].forEach((z)=>{Z.push({hookedCommand:X,callback:z})})}),G==="postAction")Z.reverse();return Z.forEach((X)=>{J=this._chainOrCall(J,()=>{return X.callback(X.hookedCommand,this)})}),J}_chainOrCallSubCommandHook($,G,J){let Z=$;if(this._lifeCycleHooks[J]!==void 0)this._lifeCycleHooks[J].forEach((X)=>{Z=this._chainOrCall(Z,()=>{return X(this,G)})});return Z}_parseCommand($,G){let J=this.parseOptions(G);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(J.operands),G=J.unknown,this.args=$.concat(G),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),G);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(G),this._dispatchSubcommand(this._defaultCommandName,$,G);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(J.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Z=()=>{if(J.unknown.length>0)this.unknownOption(J.unknown[0])},X=`command:${this.name()}`;if(this._actionHandler){Z(),this._processArguments();let z;if(z=this._chainOrCallHooks(z,"preAction"),z=this._chainOrCall(z,()=>this._actionHandler(this.processedArgs)),this.parent)z=this._chainOrCall(z,()=>{this.parent.emit(X,$,G)});return z=this._chainOrCallHooks(z,"postAction"),z}if(this.parent&&this.parent.listenerCount(X))Z(),this._processArguments(),this.parent.emit(X,$,G);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,G);if(this.listenerCount("command:*"))this.emit("command:*",$,G);else if(this.commands.length)this.unknownCommand();else Z(),this._processArguments()}else if(this.commands.length)Z(),this.help({error:!0});else Z(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((G)=>G._name===$||G._aliases.includes($))}_findOption($){return this.options.find((G)=>G.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((G)=>{if(G.mandatory&&$.getOptionValue(G.attributeName())===void 0)$.missingMandatoryOptionValue(G)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((J)=>{let Z=J.attributeName();if(this.getOptionValue(Z)===void 0)return!1;return this.getOptionValueSource(Z)!=="default"});$.filter((J)=>J.conflictsWith.length>0).forEach((J)=>{let Z=$.find((X)=>J.conflictsWith.includes(X.attributeName()));if(Z)this._conflictingOption(J,Z)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let G=[],J=[],Z=G,X=$.slice();function z(Q){return Q.length>1&&Q[0]==="-"}let N=null;while(X.length){let Q=X.shift();if(Q==="--"){if(Z===J)Z.push(Q);Z.push(...X);break}if(N&&!z(Q)){this.emit(`option:${N.name()}`,Q);continue}if(N=null,z(Q)){let Y=this._findOption(Q);if(Y){if(Y.required){let K=X.shift();if(K===void 0)this.optionMissingArgument(Y);this.emit(`option:${Y.name()}`,K)}else if(Y.optional){let K=null;if(X.length>0&&!z(X[0]))K=X.shift();this.emit(`option:${Y.name()}`,K)}else this.emit(`option:${Y.name()}`);N=Y.variadic?Y:null;continue}}if(Q.length>2&&Q[0]==="-"&&Q[1]!=="-"){let Y=this._findOption(`-${Q[1]}`);if(Y){if(Y.required||Y.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${Y.name()}`,Q.slice(2));else this.emit(`option:${Y.name()}`),X.unshift(`-${Q.slice(2)}`);continue}}if(/^--[^=]+=/.test(Q)){let Y=Q.indexOf("="),K=this._findOption(Q.slice(0,Y));if(K&&(K.required||K.optional)){this.emit(`option:${K.name()}`,Q.slice(Y+1));continue}}if(z(Q))Z=J;if((this._enablePositionalOptions||this._passThroughOptions)&&G.length===0&&J.length===0){if(this._findCommand(Q)){if(G.push(Q),X.length>0)J.push(...X);break}else if(this._getHelpCommand()&&Q===this._getHelpCommand().name()){if(G.push(Q),X.length>0)G.push(...X);break}else if(this._defaultCommandName){if(J.push(Q),X.length>0)J.push(...X);break}}if(this._passThroughOptions){if(Z.push(Q),X.length>0)Z.push(...X);break}Z.push(Q)}return{operands:G,unknown:J}}opts(){if(this._storeOptionsAsProperties){let $={},G=this.options.length;for(let J=0;J<G;J++){let Z=this.options[J].attributeName();$[Z]=Z===this._versionOptionName?this._version:this[Z]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,G)=>Object.assign($,G.opts()),{})}error($,G){if(this._outputConfiguration.outputError(`${$}
|
|
18
18
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
19
19
|
`);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
|
|
20
|
-
`),this.outputHelp({error:!0});let J=G||{},Z=J.exitCode||1,X=J.code||"commander.error";this._exit(Z,X,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in
|
|
21
|
-
`),this._exit(0,"commander.version",$)}),this}description($,G){if($===void 0&&G===void 0)return this._description;if(this._description=$,G)this._argsDescription=G;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let G=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)G=this.commands[this.commands.length-1];if($===G._name)throw Error("Command alias can't be the same as its name");let J=this.parent?._findCommand($);if(J){let Z=[J.name()].concat(J.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${Z}'`)}return G._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((G)=>this.alias(G)),this}usage($){if($===void 0){if(this._usage)return this._usage;let G=this.registeredArguments.map((J)=>{return T$(J)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?G:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}nameFromFilename($){return this._name=q1.basename($,q1.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let G=this.createHelp();if(G.helpWidth===void 0)G.helpWidth=$&&$.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return G.formatHelp(this,G)}_getHelpContext($){$=$||{};let G={error:!!$.error},J;if(G.error)J=(Z)=>this._outputConfiguration.writeErr(Z);else J=(Z)=>this._outputConfiguration.writeOut(Z);return G.write=$.write||J,G.command=this,G}outputHelp($){let G;if(typeof $==="function")G=$,$=void 0;let J=this._getHelpContext($);this._getCommandAndAncestors().reverse().forEach((X)=>X.emit("beforeAllHelp",J)),this.emit("beforeHelp",J);let Z=this.helpInformation(J);if(G){if(Z=G(Z),typeof Z!=="string"&&!Buffer.isBuffer(Z))throw Error("outputHelp callback must return a string or a Buffer")}if(J.write(Z),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",J),this._getCommandAndAncestors().forEach((X)=>X.emit("afterAllHelp",J))}helpOption($,G){if(typeof $==="boolean"){if($)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return $=$??"-h, --help",G=G??"display help for command",this._helpOption=this.createOption($,G),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this}help($){this.outputHelp($);let G=
|
|
20
|
+
`),this.outputHelp({error:!0});let J=G||{},Z=J.exitCode||1,X=J.code||"commander.error";this._exit(Z,X,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in b.env){let G=$.attributeName();if(this.getOptionValue(G)===void 0||["default","config","env"].includes(this.getOptionValueSource(G)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,b.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new W$(this.options),G=(J)=>{return this.getOptionValue(J)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(J))};this.options.filter((J)=>J.implied!==void 0&&G(J.attributeName())&&$.valueFromOption(this.getOptionValue(J.attributeName()),J)).forEach((J)=>{Object.keys(J.implied).filter((Z)=>!G(Z)).forEach((Z)=>{this.setOptionValueWithSource(Z,J.implied[Z],"implied")})})}missingArgument($){let G=`error: missing required argument '${$}'`;this.error(G,{code:"commander.missingArgument"})}optionMissingArgument($){let G=`error: option '${$.flags}' argument missing`;this.error(G,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let G=`error: required option '${$.flags}' not specified`;this.error(G,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,G){let J=(z)=>{let N=z.attributeName(),Q=this.getOptionValue(N),Y=this.options.find((I)=>I.negate&&N===I.attributeName()),K=this.options.find((I)=>!I.negate&&N===I.attributeName());if(Y&&(Y.presetArg===void 0&&Q===!1||Y.presetArg!==void 0&&Q===Y.presetArg))return Y;return K||z},Z=(z)=>{let N=J(z),Q=N.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${N.envVar}'`;return`option '${N.flags}'`},X=`error: ${Z($)} cannot be used with ${Z(G)}`;this.error(X,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let G="";if($.startsWith("--")&&this._showSuggestionAfterError){let Z=[],X=this;do{let z=X.createHelp().visibleOptions(X).filter((N)=>N.long).map((N)=>N.long);Z=Z.concat(z),X=X.parent}while(X&&!X._enablePositionalOptions);G=C4($,Z)}let J=`error: unknown option '${$}'${G}`;this.error(J,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let G=this.registeredArguments.length,J=G===1?"":"s",X=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${G} argument${J} but got ${$.length}.`;this.error(X,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],G="";if(this._showSuggestionAfterError){let Z=[];this.createHelp().visibleCommands(this).forEach((X)=>{if(Z.push(X.name()),X.alias())Z.push(X.alias())}),G=C4($,Z)}let J=`error: unknown command '${$}'${G}`;this.error(J,{code:"commander.unknownCommand"})}version($,G,J){if($===void 0)return this._version;this._version=$,G=G||"-V, --version",J=J||"output the version number";let Z=this.createOption(G,J);return this._versionOptionName=Z.attributeName(),this._registerOption(Z),this.on("option:"+Z.name(),()=>{this._outputConfiguration.writeOut(`${$}
|
|
21
|
+
`),this._exit(0,"commander.version",$)}),this}description($,G){if($===void 0&&G===void 0)return this._description;if(this._description=$,G)this._argsDescription=G;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let G=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)G=this.commands[this.commands.length-1];if($===G._name)throw Error("Command alias can't be the same as its name");let J=this.parent?._findCommand($);if(J){let Z=[J.name()].concat(J.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${Z}'`)}return G._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((G)=>this.alias(G)),this}usage($){if($===void 0){if(this._usage)return this._usage;let G=this.registeredArguments.map((J)=>{return T$(J)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?G:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}nameFromFilename($){return this._name=q1.basename($,q1.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let G=this.createHelp();if(G.helpWidth===void 0)G.helpWidth=$&&$.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth();return G.formatHelp(this,G)}_getHelpContext($){$=$||{};let G={error:!!$.error},J;if(G.error)J=(Z)=>this._outputConfiguration.writeErr(Z);else J=(Z)=>this._outputConfiguration.writeOut(Z);return G.write=$.write||J,G.command=this,G}outputHelp($){let G;if(typeof $==="function")G=$,$=void 0;let J=this._getHelpContext($);this._getCommandAndAncestors().reverse().forEach((X)=>X.emit("beforeAllHelp",J)),this.emit("beforeHelp",J);let Z=this.helpInformation(J);if(G){if(Z=G(Z),typeof Z!=="string"&&!Buffer.isBuffer(Z))throw Error("outputHelp callback must return a string or a Buffer")}if(J.write(Z),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",J),this._getCommandAndAncestors().forEach((X)=>X.emit("afterAllHelp",J))}helpOption($,G){if(typeof $==="boolean"){if($)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return $=$??"-h, --help",G=G??"display help for command",this._helpOption=this.createOption($,G),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this}help($){this.outputHelp($);let G=b.exitCode||0;if(G===0&&$&&typeof $!=="function"&&$.error)G=1;this._exit(G,"commander.help","(outputHelp)")}addHelpText($,G){let J=["beforeAll","before","after","afterAll"];if(!J.includes($))throw Error(`Unexpected value for position to addHelpText.
|
|
22
22
|
Expecting one of '${J.join("', '")}'`);let Z=`${$}Help`;return this.on(Z,(X)=>{let z;if(typeof G==="function")z=G({error:X.error,command:X.command});else z=G;if(z)X.write(`${z}
|
|
23
|
-
`)}),this}_outputHelpIfRequested($){let G=this._getHelpOption();if(G&&$.find((Z)=>G.is(Z)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function O4($){return $.map((G)=>{if(!G.startsWith("--inspect"))return G;let J,Z="127.0.0.1",X="9229",z;if((z=G.match(/^(--inspect(-brk)?)$/))!==null)J=z[1];else if((z=G.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(J=z[1],/^\d+$/.test(z[3]))X=z[3];else Z=z[3];else if((z=G.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)J=z[1],Z=z[3],X=z[4];if(J&&X!=="0")return`${J}=${Z}:${parseInt(X)+1}`;return G})}L$.Command=Y2});var w4=u((O$)=>{var{Argument:P4}=_0(),{Command:K2}=F4(),{CommanderError:D$,InvalidArgumentError:E4}=n1(),{Help:C$}=Z2(),{Option:S4}=X2();O$.program=new K2;O$.createCommand=($)=>new K2($);O$.createOption=($,G)=>new S4($,G);O$.createArgument=($,G)=>new P4($,G);O$.Command=K2;O$.Option=S4;O$.Argument=P4;O$.Help=C$;O$.CommanderError=D$;O$.InvalidArgumentError=E4;O$.InvalidOptionArgumentError=E4});var f1=u((VG,H2)=>{var R0=process||{},g4=R0.argv||[],j0=R0.env||{},k$=!(!!j0.NO_COLOR||g4.includes("--no-color"))&&(!!j0.FORCE_COLOR||g4.includes("--color")||R0.platform==="win32"||(R0.stdout||{}).isTTY&&j0.TERM!=="dumb"||!!j0.CI),h$=($,G,J=$)=>(Z)=>{let X=""+Z,z=X.indexOf(G,$.length);return~z?$+m$(X,G,J,z)+G:$+X+G},m$=($,G,J,Z)=>{let X="",z=0;do X+=$.substring(z,Z)+J,z=Z+G.length,Z=$.indexOf(G,z);while(~Z);return X+$.substring(z)},f4=($=k$)=>{let G=$?h$:()=>String;return{isColorSupported:$,reset:G("\x1B[0m","\x1B[0m"),bold:G("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:G("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:G("\x1B[3m","\x1B[23m"),underline:G("\x1B[4m","\x1B[24m"),inverse:G("\x1B[7m","\x1B[27m"),hidden:G("\x1B[8m","\x1B[28m"),strikethrough:G("\x1B[9m","\x1B[29m"),black:G("\x1B[30m","\x1B[39m"),red:G("\x1B[31m","\x1B[39m"),green:G("\x1B[32m","\x1B[39m"),yellow:G("\x1B[33m","\x1B[39m"),blue:G("\x1B[34m","\x1B[39m"),magenta:G("\x1B[35m","\x1B[39m"),cyan:G("\x1B[36m","\x1B[39m"),white:G("\x1B[37m","\x1B[39m"),gray:G("\x1B[90m","\x1B[39m"),bgBlack:G("\x1B[40m","\x1B[49m"),bgRed:G("\x1B[41m","\x1B[49m"),bgGreen:G("\x1B[42m","\x1B[49m"),bgYellow:G("\x1B[43m","\x1B[49m"),bgBlue:G("\x1B[44m","\x1B[49m"),bgMagenta:G("\x1B[45m","\x1B[49m"),bgCyan:G("\x1B[46m","\x1B[49m"),bgWhite:G("\x1B[47m","\x1B[49m"),blackBright:G("\x1B[90m","\x1B[39m"),redBright:G("\x1B[91m","\x1B[39m"),greenBright:G("\x1B[92m","\x1B[39m"),yellowBright:G("\x1B[93m","\x1B[39m"),blueBright:G("\x1B[94m","\x1B[39m"),magentaBright:G("\x1B[95m","\x1B[39m"),cyanBright:G("\x1B[96m","\x1B[39m"),whiteBright:G("\x1B[97m","\x1B[39m"),bgBlackBright:G("\x1B[100m","\x1B[49m"),bgRedBright:G("\x1B[101m","\x1B[49m"),bgGreenBright:G("\x1B[102m","\x1B[49m"),bgYellowBright:G("\x1B[103m","\x1B[49m"),bgBlueBright:G("\x1B[104m","\x1B[49m"),bgMagentaBright:G("\x1B[105m","\x1B[49m"),bgCyanBright:G("\x1B[106m","\x1B[49m"),bgWhiteBright:G("\x1B[107m","\x1B[49m")}};H2.exports=f4();H2.exports.createColors=f4});var q2=u((MG,b4)=>{var I2={to($,G){if(!G)return`\x1B[${$+1}G`;return`\x1B[${G+1};${$+1}H`},move($,G){let J="";if($<0)J+=`\x1B[${-$}D`;else if($>0)J+=`\x1B[${$}C`;if(G<0)J+=`\x1B[${-G}A`;else if(G>0)J+=`\x1B[${G}B`;return J},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},l$={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},d$={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let G="";for(let J=0;J<$;J++)G+=this.line+(J<$-1?I2.up():"");if($)G+=I2.left;return G}};b4.exports={cursor:I2,scroll:l$,erase:d$,beep:"\x07"}});var U1=u((aG,b3)=>{var g3=["nodebuffer","arraybuffer","fragments"],f3=typeof Blob<"u";if(f3)g3.push("blob");b3.exports={BINARY_TYPES:g3,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:f3,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var J0=u((tG,m0)=>{var{EMPTY_BUFFER:S6}=U1(),i2=Buffer[Symbol.species];function w6($,G){if($.length===0)return S6;if($.length===1)return $[0];let J=Buffer.allocUnsafe(G),Z=0;for(let X=0;X<$.length;X++){let z=$[X];J.set(z,Z),Z+=z.length}if(Z<G)return new i2(J.buffer,J.byteOffset,Z);return J}function u3($,G,J,Z,X){for(let z=0;z<X;z++)J[Z+z]=$[z]^G[z&3]}function k3($,G){for(let J=0;J<$.length;J++)$[J]^=G[J&3]}function y6($){if($.length===$.buffer.byteLength)return $.buffer;return $.buffer.slice($.byteOffset,$.byteOffset+$.length)}function n2($){if(n2.readOnly=!0,Buffer.isBuffer($))return $;let G;if($ instanceof ArrayBuffer)G=new i2($);else if(ArrayBuffer.isView($))G=new i2($.buffer,$.byteOffset,$.byteLength);else G=Buffer.from($),n2.readOnly=!1;return G}m0.exports={concat:w6,mask:u3,toArrayBuffer:y6,toBuffer:n2,unmask:k3};if(!process.env.WS_NO_BUFFER_UTIL)try{let $=(()=>{throw new Error("Cannot require module "+"bufferutil");})();m0.exports.mask=function(G,J,Z,X,z){if(z<48)u3(G,J,Z,X,z);else $.mask(G,J,Z,X,z)},m0.exports.unmask=function(G,J){if(G.length<32)k3(G,J);else $.unmask(G,J)}}catch($){}});var d3=u((eG,l3)=>{var h3=Symbol("kDone"),s2=Symbol("kRun");class m3{constructor($){this[h3]=()=>{this.pending--,this[s2]()},this.concurrency=$||1/0,this.jobs=[],this.pending=0}add($){this.jobs.push($),this[s2]()}[s2](){if(this.pending===this.concurrency)return;if(this.jobs.length){let $=this.jobs.shift();this.pending++,$(this[h3])}}}l3.exports=m3});var X0=u(($J,s3)=>{var Z0=w("zlib"),c3=J0(),v6=d3(),{kStatusCode:p3}=U1(),g6=Buffer[Symbol.species],f6=Buffer.from([0,0,255,255]),d0=Symbol("permessage-deflate"),_1=Symbol("total-length"),u1=Symbol("callback"),T1=Symbol("buffers"),k1=Symbol("error"),l0;class i3{constructor($,G,J){if(this._maxPayload=J|0,this._options=$||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!G,this._deflate=null,this._inflate=null,this.params=null,!l0){let Z=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;l0=new v6(Z)}}static get extensionName(){return"permessage-deflate"}offer(){let $={};if(this._options.serverNoContextTakeover)$.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)$.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)$.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)$.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)$.client_max_window_bits=!0;return $}accept($){return $=this.normalizeParams($),this.params=this._isServer?this.acceptAsServer($):this.acceptAsClient($),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let $=this._deflate[u1];if(this._deflate.close(),this._deflate=null,$)$(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer($){let G=this._options,J=$.find((Z)=>{if(G.serverNoContextTakeover===!1&&Z.server_no_context_takeover||Z.server_max_window_bits&&(G.serverMaxWindowBits===!1||typeof G.serverMaxWindowBits==="number"&&G.serverMaxWindowBits>Z.server_max_window_bits)||typeof G.clientMaxWindowBits==="number"&&!Z.client_max_window_bits)return!1;return!0});if(!J)throw Error("None of the extension offers can be accepted");if(G.serverNoContextTakeover)J.server_no_context_takeover=!0;if(G.clientNoContextTakeover)J.client_no_context_takeover=!0;if(typeof G.serverMaxWindowBits==="number")J.server_max_window_bits=G.serverMaxWindowBits;if(typeof G.clientMaxWindowBits==="number")J.client_max_window_bits=G.clientMaxWindowBits;else if(J.client_max_window_bits===!0||G.clientMaxWindowBits===!1)delete J.client_max_window_bits;return J}acceptAsClient($){let G=$[0];if(this._options.clientNoContextTakeover===!1&&G.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!G.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")G.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&G.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return G}normalizeParams($){return $.forEach((G)=>{Object.keys(G).forEach((J)=>{let Z=G[J];if(Z.length>1)throw Error(`Parameter "${J}" must have only a single value`);if(Z=Z[0],J==="client_max_window_bits"){if(Z!==!0){let X=+Z;if(!Number.isInteger(X)||X<8||X>15)throw TypeError(`Invalid value for parameter "${J}": ${Z}`);Z=X}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${J}": ${Z}`)}else if(J==="server_max_window_bits"){let X=+Z;if(!Number.isInteger(X)||X<8||X>15)throw TypeError(`Invalid value for parameter "${J}": ${Z}`);Z=X}else if(J==="client_no_context_takeover"||J==="server_no_context_takeover"){if(Z!==!0)throw TypeError(`Invalid value for parameter "${J}": ${Z}`)}else throw Error(`Unknown parameter "${J}"`);G[J]=Z})}),$}decompress($,G,J){l0.add((Z)=>{this._decompress($,G,(X,z)=>{Z(),J(X,z)})})}compress($,G,J){l0.add((Z)=>{this._compress($,G,(X,z)=>{Z(),J(X,z)})})}_decompress($,G,J){let Z=this._isServer?"client":"server";if(!this._inflate){let X=`${Z}_max_window_bits`,z=typeof this.params[X]!=="number"?Z0.Z_DEFAULT_WINDOWBITS:this.params[X];this._inflate=Z0.createInflateRaw({...this._options.zlibInflateOptions,windowBits:z}),this._inflate[d0]=this,this._inflate[_1]=0,this._inflate[T1]=[],this._inflate.on("error",u6),this._inflate.on("data",n3)}if(this._inflate[u1]=J,this._inflate.write($),G)this._inflate.write(f6);this._inflate.flush(()=>{let X=this._inflate[k1];if(X){this._inflate.close(),this._inflate=null,J(X);return}let z=c3.concat(this._inflate[T1],this._inflate[_1]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[_1]=0,this._inflate[T1]=[],G&&this.params[`${Z}_no_context_takeover`])this._inflate.reset();J(null,z)})}_compress($,G,J){let Z=this._isServer?"server":"client";if(!this._deflate){let X=`${Z}_max_window_bits`,z=typeof this.params[X]!=="number"?Z0.Z_DEFAULT_WINDOWBITS:this.params[X];this._deflate=Z0.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:z}),this._deflate[_1]=0,this._deflate[T1]=[],this._deflate.on("data",b6)}this._deflate[u1]=J,this._deflate.write($),this._deflate.flush(Z0.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let X=c3.concat(this._deflate[T1],this._deflate[_1]);if(G)X=new g6(X.buffer,X.byteOffset,X.length-4);if(this._deflate[u1]=null,this._deflate[_1]=0,this._deflate[T1]=[],G&&this.params[`${Z}_no_context_takeover`])this._deflate.reset();J(null,X)})}}s3.exports=i3;function b6($){this[T1].push($),this[_1]+=$.length}function n3($){if(this[_1]+=$.length,this[d0]._maxPayload<1||this[_1]<=this[d0]._maxPayload){this[T1].push($);return}this[k1]=RangeError("Max payload size exceeded"),this[k1].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[k1][p3]=1009,this.removeListener("data",n3),this.reset()}function u6($){if(this[d0]._inflate=null,this[k1]){this[u1](this[k1]);return}$[p3]=1007,this[u1]($)}});var h1=u((GJ,c0)=>{var{isUtf8:o3}=w("buffer"),{hasBlob:k6}=U1(),h6=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function m6($){return $>=1000&&$<=1014&&$!==1004&&$!==1005&&$!==1006||$>=3000&&$<=4999}function o2($){let G=$.length,J=0;while(J<G)if(($[J]&128)===0)J++;else if(($[J]&224)===192){if(J+1===G||($[J+1]&192)!==128||($[J]&254)===192)return!1;J+=2}else if(($[J]&240)===224){if(J+2>=G||($[J+1]&192)!==128||($[J+2]&192)!==128||$[J]===224&&($[J+1]&224)===128||$[J]===237&&($[J+1]&224)===160)return!1;J+=3}else if(($[J]&248)===240){if(J+3>=G||($[J+1]&192)!==128||($[J+2]&192)!==128||($[J+3]&192)!==128||$[J]===240&&($[J+1]&240)===128||$[J]===244&&$[J+1]>143||$[J]>244)return!1;J+=4}else return!1;return!0}function l6($){return k6&&typeof $==="object"&&typeof $.arrayBuffer==="function"&&typeof $.type==="string"&&typeof $.stream==="function"&&($[Symbol.toStringTag]==="Blob"||$[Symbol.toStringTag]==="File")}c0.exports={isBlob:l6,isValidStatusCode:m6,isValidUTF8:o2,tokenChars:h6};if(o3)c0.exports.isValidUTF8=function($){return $.length<24?o2($):o3($)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let $=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();c0.exports.isValidUTF8=function(G){return G.length<32?o2(G):$(G)}}catch($){}});var a2=u((JJ,$9)=>{var{Writable:d6}=w("stream"),r3=X0(),{BINARY_TYPES:c6,EMPTY_BUFFER:a3,kStatusCode:p6,kWebSocket:i6}=U1(),{concat:r2,toArrayBuffer:n6,unmask:s6}=J0(),{isValidStatusCode:o6,isValidUTF8:t3}=h1(),p0=Buffer[Symbol.species];class e3 extends d6{constructor($={}){super();this._allowSynchronousEvents=$.allowSynchronousEvents!==void 0?$.allowSynchronousEvents:!0,this._binaryType=$.binaryType||c6[0],this._extensions=$.extensions||{},this._isServer=!!$.isServer,this._maxPayload=$.maxPayload|0,this._skipUTF8Validation=!!$.skipUTF8Validation,this[i6]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write($,G,J){if(this._opcode===8&&this._state==0)return J();this._bufferedBytes+=$.length,this._buffers.push($),this.startLoop(J)}consume($){if(this._bufferedBytes-=$,$===this._buffers[0].length)return this._buffers.shift();if($<this._buffers[0].length){let J=this._buffers[0];return this._buffers[0]=new p0(J.buffer,J.byteOffset+$,J.length-$),new p0(J.buffer,J.byteOffset,$)}let G=Buffer.allocUnsafe($);do{let J=this._buffers[0],Z=G.length-$;if($>=J.length)G.set(this._buffers.shift(),Z);else G.set(new Uint8Array(J.buffer,J.byteOffset,$),Z),this._buffers[0]=new p0(J.buffer,J.byteOffset+$,J.length-$);$-=J.length}while($>0);return G}startLoop($){this._loop=!0;do switch(this._state){case 0:this.getInfo($);break;case 1:this.getPayloadLength16($);break;case 2:this.getPayloadLength64($);break;case 3:this.getMask();break;case 4:this.getData($);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)$()}getInfo($){if(this._bufferedBytes<2){this._loop=!1;return}let G=this.consume(2);if((G[0]&48)!==0){let Z=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");$(Z);return}let J=(G[0]&64)===64;if(J&&!this._extensions[r3.extensionName]){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(Z);return}if(this._fin=(G[0]&128)===128,this._opcode=G[0]&15,this._payloadLength=G[1]&127,this._opcode===0){if(J){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(Z);return}if(!this._fragmented){let Z=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");$(Z);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let Z=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(Z);return}this._compressed=J}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let Z=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");$(Z);return}if(J){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(Z);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let Z=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");$(Z);return}}else{let Z=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(Z);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(G[1]&128)===128,this._isServer){if(!this._masked){let Z=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");$(Z);return}}else if(this._masked){let Z=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");$(Z);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength($)}getPayloadLength16($){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength($)}getPayloadLength64($){if(this._bufferedBytes<8){this._loop=!1;return}let G=this.consume(8),J=G.readUInt32BE(0);if(J>Math.pow(2,21)-1){let Z=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");$(Z);return}this._payloadLength=J*Math.pow(2,32)+G.readUInt32BE(4),this.haveLength($)}haveLength($){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let G=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(G);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData($){let G=a3;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(G=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)s6(G,this._mask)}if(this._opcode>7){this.controlMessage(G,$);return}if(this._compressed){this._state=5,this.decompress(G,$);return}if(G.length)this._messageLength=this._totalPayloadLength,this._fragments.push(G);this.dataMessage($)}decompress($,G){this._extensions[r3.extensionName].decompress($,this._fin,(Z,X)=>{if(Z)return G(Z);if(X.length){if(this._messageLength+=X.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let z=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");G(z);return}this._fragments.push(X)}if(this.dataMessage(G),this._state===0)this.startLoop(G)})}dataMessage($){if(!this._fin){this._state=0;return}let G=this._messageLength,J=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let Z;if(this._binaryType==="nodebuffer")Z=r2(J,G);else if(this._binaryType==="arraybuffer")Z=n6(r2(J,G));else if(this._binaryType==="blob")Z=new Blob(J);else Z=J;if(this._allowSynchronousEvents)this.emit("message",Z,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Z,!0),this._state=0,this.startLoop($)})}else{let Z=r2(J,G);if(!this._skipUTF8Validation&&!t3(Z)){let X=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(X);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",Z,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Z,!1),this._state=0,this.startLoop($)})}}controlMessage($,G){if(this._opcode===8){if($.length===0)this._loop=!1,this.emit("conclude",1005,a3),this.end();else{let J=$.readUInt16BE(0);if(!o6(J)){let X=this.createError(RangeError,`invalid status code ${J}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");G(X);return}let Z=new p0($.buffer,$.byteOffset+2,$.length-2);if(!this._skipUTF8Validation&&!t3(Z)){let X=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");G(X);return}this._loop=!1,this.emit("conclude",J,Z),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",$),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",$),this._state=0,this.startLoop(G)})}createError($,G,J,Z,X){this._loop=!1,this._errored=!0;let z=new $(J?`Invalid WebSocket frame: ${G}`:G);return Error.captureStackTrace(z,this.createError),z.code=X,z[p6]=Z,z}}$9.exports=e3});var e2=u((XJ,Z9)=>{var{Duplex:ZJ}=w("stream"),{randomFillSync:r6}=w("crypto"),G9=X0(),{EMPTY_BUFFER:a6,kWebSocket:t6,NOOP:e6}=U1(),{isBlob:m1,isValidStatusCode:$8}=h1(),{mask:J9,toBuffer:E1}=J0(),G1=Symbol("kByteLength"),G8=Buffer.alloc(4),S1,l1=8192,z1=0,J8=1,Z8=2;class x1{constructor($,G,J){if(this._extensions=G||{},J)this._generateMask=J,this._maskBuffer=Buffer.alloc(4);this._socket=$,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=z1,this.onerror=e6,this[t6]=void 0}static frame($,G){let J,Z=!1,X=2,z=!1;if(G.mask){if(J=G.maskBuffer||G8,G.generateMask)G.generateMask(J);else{if(l1===8192){if(S1===void 0)S1=Buffer.alloc(8192);r6(S1,0,8192),l1=0}J[0]=S1[l1++],J[1]=S1[l1++],J[2]=S1[l1++],J[3]=S1[l1++]}z=(J[0]|J[1]|J[2]|J[3])===0,X=6}let N;if(typeof $==="string")if((!G.mask||z)&&G[G1]!==void 0)N=G[G1];else $=Buffer.from($),N=$.length;else N=$.length,Z=G.mask&&G.readOnly&&!z;let Q=N;if(N>=65536)X+=8,Q=127;else if(N>125)X+=2,Q=126;let Y=Buffer.allocUnsafe(Z?N+X:X);if(Y[0]=G.fin?G.opcode|128:G.opcode,G.rsv1)Y[0]|=64;if(Y[1]=Q,Q===126)Y.writeUInt16BE(N,2);else if(Q===127)Y[2]=Y[3]=0,Y.writeUIntBE(N,4,6);if(!G.mask)return[Y,$];if(Y[1]|=128,Y[X-4]=J[0],Y[X-3]=J[1],Y[X-2]=J[2],Y[X-1]=J[3],z)return[Y,$];if(Z)return J9($,J,Y,X,N),[Y];return J9($,J,$,0,N),[Y,$]}close($,G,J,Z){let X;if($===void 0)X=a6;else if(typeof $!=="number"||!$8($))throw TypeError("First argument must be a valid error code number");else if(G===void 0||!G.length)X=Buffer.allocUnsafe(2),X.writeUInt16BE($,0);else{let N=Buffer.byteLength(G);if(N>123)throw RangeError("The message must not be greater than 123 bytes");if(X=Buffer.allocUnsafe(2+N),X.writeUInt16BE($,0),typeof G==="string")X.write(G,2);else X.set(G,2)}let z={[G1]:X.length,fin:!0,generateMask:this._generateMask,mask:J,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==z1)this.enqueue([this.dispatch,X,!1,z,Z]);else this.sendFrame(x1.frame(X,z),Z)}ping($,G,J){let Z,X;if(typeof $==="string")Z=Buffer.byteLength($),X=!1;else if(m1($))Z=$.size,X=!1;else $=E1($),Z=$.length,X=E1.readOnly;if(Z>125)throw RangeError("The data size must not be greater than 125 bytes");let z={[G1]:Z,fin:!0,generateMask:this._generateMask,mask:G,maskBuffer:this._maskBuffer,opcode:9,readOnly:X,rsv1:!1};if(m1($))if(this._state!==z1)this.enqueue([this.getBlobData,$,!1,z,J]);else this.getBlobData($,!1,z,J);else if(this._state!==z1)this.enqueue([this.dispatch,$,!1,z,J]);else this.sendFrame(x1.frame($,z),J)}pong($,G,J){let Z,X;if(typeof $==="string")Z=Buffer.byteLength($),X=!1;else if(m1($))Z=$.size,X=!1;else $=E1($),Z=$.length,X=E1.readOnly;if(Z>125)throw RangeError("The data size must not be greater than 125 bytes");let z={[G1]:Z,fin:!0,generateMask:this._generateMask,mask:G,maskBuffer:this._maskBuffer,opcode:10,readOnly:X,rsv1:!1};if(m1($))if(this._state!==z1)this.enqueue([this.getBlobData,$,!1,z,J]);else this.getBlobData($,!1,z,J);else if(this._state!==z1)this.enqueue([this.dispatch,$,!1,z,J]);else this.sendFrame(x1.frame($,z),J)}send($,G,J){let Z=this._extensions[G9.extensionName],X=G.binary?2:1,z=G.compress,N,Q;if(typeof $==="string")N=Buffer.byteLength($),Q=!1;else if(m1($))N=$.size,Q=!1;else $=E1($),N=$.length,Q=E1.readOnly;if(this._firstFragment){if(this._firstFragment=!1,z&&Z&&Z.params[Z._isServer?"server_no_context_takeover":"client_no_context_takeover"])z=N>=Z._threshold;this._compress=z}else z=!1,X=0;if(G.fin)this._firstFragment=!0;let Y={[G1]:N,fin:G.fin,generateMask:this._generateMask,mask:G.mask,maskBuffer:this._maskBuffer,opcode:X,readOnly:Q,rsv1:z};if(m1($))if(this._state!==z1)this.enqueue([this.getBlobData,$,this._compress,Y,J]);else this.getBlobData($,this._compress,Y,J);else if(this._state!==z1)this.enqueue([this.dispatch,$,this._compress,Y,J]);else this.dispatch($,this._compress,Y,J)}getBlobData($,G,J,Z){this._bufferedBytes+=J[G1],this._state=Z8,$.arrayBuffer().then((X)=>{if(this._socket.destroyed){let N=Error("The socket was closed while the blob was being read");process.nextTick(t2,this,N,Z);return}this._bufferedBytes-=J[G1];let z=E1(X);if(!G)this._state=z1,this.sendFrame(x1.frame(z,J),Z),this.dequeue();else this.dispatch(z,G,J,Z)}).catch((X)=>{process.nextTick(X8,this,X,Z)})}dispatch($,G,J,Z){if(!G){this.sendFrame(x1.frame($,J),Z);return}let X=this._extensions[G9.extensionName];this._bufferedBytes+=J[G1],this._state=J8,X.compress($,J.fin,(z,N)=>{if(this._socket.destroyed){let Q=Error("The socket was closed while data was being compressed");t2(this,Q,Z);return}this._bufferedBytes-=J[G1],this._state=z1,J.readOnly=!1,this.sendFrame(x1.frame(N,J),Z),this.dequeue()})}dequeue(){while(this._state===z1&&this._queue.length){let $=this._queue.shift();this._bufferedBytes-=$[3][G1],Reflect.apply($[0],this,$.slice(1))}}enqueue($){this._bufferedBytes+=$[3][G1],this._queue.push($)}sendFrame($,G){if($.length===2)this._socket.cork(),this._socket.write($[0]),this._socket.write($[1],G),this._socket.uncork();else this._socket.write($[0],G)}}Z9.exports=x1;function t2($,G,J){if(typeof J==="function")J(G);for(let Z=0;Z<$._queue.length;Z++){let X=$._queue[Z],z=X[X.length-1];if(typeof z==="function")z(G)}}function X8($,G,J){t2($,G,J),$.onerror(G)}});var q9=u((zJ,I9)=>{var{kForOnEventAttribute:z0,kListener:$4}=U1(),X9=Symbol("kCode"),z9=Symbol("kData"),Q9=Symbol("kError"),N9=Symbol("kMessage"),Y9=Symbol("kReason"),d1=Symbol("kTarget"),K9=Symbol("kType"),H9=Symbol("kWasClean");class W1{constructor($){this[d1]=null,this[K9]=$}get target(){return this[d1]}get type(){return this[K9]}}Object.defineProperty(W1.prototype,"target",{enumerable:!0});Object.defineProperty(W1.prototype,"type",{enumerable:!0});class c1 extends W1{constructor($,G={}){super($);this[X9]=G.code===void 0?0:G.code,this[Y9]=G.reason===void 0?"":G.reason,this[H9]=G.wasClean===void 0?!1:G.wasClean}get code(){return this[X9]}get reason(){return this[Y9]}get wasClean(){return this[H9]}}Object.defineProperty(c1.prototype,"code",{enumerable:!0});Object.defineProperty(c1.prototype,"reason",{enumerable:!0});Object.defineProperty(c1.prototype,"wasClean",{enumerable:!0});class Q0 extends W1{constructor($,G={}){super($);this[Q9]=G.error===void 0?null:G.error,this[N9]=G.message===void 0?"":G.message}get error(){return this[Q9]}get message(){return this[N9]}}Object.defineProperty(Q0.prototype,"error",{enumerable:!0});Object.defineProperty(Q0.prototype,"message",{enumerable:!0});class n0 extends W1{constructor($,G={}){super($);this[z9]=G.data===void 0?null:G.data}get data(){return this[z9]}}Object.defineProperty(n0.prototype,"data",{enumerable:!0});var z8={addEventListener($,G,J={}){for(let X of this.listeners($))if(!J[z0]&&X[$4]===G&&!X[z0])return;let Z;if($==="message")Z=function(z,N){let Q=new n0("message",{data:N?z:z.toString()});Q[d1]=this,i0(G,this,Q)};else if($==="close")Z=function(z,N){let Q=new c1("close",{code:z,reason:N.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});Q[d1]=this,i0(G,this,Q)};else if($==="error")Z=function(z){let N=new Q0("error",{error:z,message:z.message});N[d1]=this,i0(G,this,N)};else if($==="open")Z=function(){let z=new W1("open");z[d1]=this,i0(G,this,z)};else return;if(Z[z0]=!!J[z0],Z[$4]=G,J.once)this.once($,Z);else this.on($,Z)},removeEventListener($,G){for(let J of this.listeners($))if(J[$4]===G&&!J[z0]){this.removeListener($,J);break}}};I9.exports={CloseEvent:c1,ErrorEvent:Q0,Event:W1,EventTarget:z8,MessageEvent:n0};function i0($,G,J){if(typeof $==="object"&&$.handleEvent)$.handleEvent.call($,J);else $.call(G,J)}});var G4=u((QJ,B9)=>{var{tokenChars:N0}=h1();function K1($,G,J){if($[G]===void 0)$[G]=[J];else $[G].push(J)}function Q8($){let G=Object.create(null),J=Object.create(null),Z=!1,X=!1,z=!1,N,Q,Y=-1,K=-1,I=-1,H=0;for(;H<$.length;H++)if(K=$.charCodeAt(H),N===void 0)if(I===-1&&N0[K]===1){if(Y===-1)Y=H}else if(H!==0&&(K===32||K===9)){if(I===-1&&Y!==-1)I=H}else if(K===59||K===44){if(Y===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(I===-1)I=H;let _=$.slice(Y,I);if(K===44)K1(G,_,J),J=Object.create(null);else N=_;Y=I=-1}else throw SyntaxError(`Unexpected character at index ${H}`);else if(Q===void 0)if(I===-1&&N0[K]===1){if(Y===-1)Y=H}else if(K===32||K===9){if(I===-1&&Y!==-1)I=H}else if(K===59||K===44){if(Y===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(I===-1)I=H;if(K1(J,$.slice(Y,I),!0),K===44)K1(G,N,J),J=Object.create(null),N=void 0;Y=I=-1}else if(K===61&&Y!==-1&&I===-1)Q=$.slice(Y,H),Y=I=-1;else throw SyntaxError(`Unexpected character at index ${H}`);else if(X){if(N0[K]!==1)throw SyntaxError(`Unexpected character at index ${H}`);if(Y===-1)Y=H;else if(!Z)Z=!0;X=!1}else if(z)if(N0[K]===1){if(Y===-1)Y=H}else if(K===34&&Y!==-1)z=!1,I=H;else if(K===92)X=!0;else throw SyntaxError(`Unexpected character at index ${H}`);else if(K===34&&$.charCodeAt(H-1)===61)z=!0;else if(I===-1&&N0[K]===1){if(Y===-1)Y=H}else if(Y!==-1&&(K===32||K===9)){if(I===-1)I=H}else if(K===59||K===44){if(Y===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(I===-1)I=H;let _=$.slice(Y,I);if(Z)_=_.replace(/\\/g,""),Z=!1;if(K1(J,Q,_),K===44)K1(G,N,J),J=Object.create(null),N=void 0;Q=void 0,Y=I=-1}else throw SyntaxError(`Unexpected character at index ${H}`);if(Y===-1||z||K===32||K===9)throw SyntaxError("Unexpected end of input");if(I===-1)I=H;let U=$.slice(Y,I);if(N===void 0)K1(G,U,J);else{if(Q===void 0)K1(J,U,!0);else if(Z)K1(J,Q,U.replace(/\\/g,""));else K1(J,Q,U);K1(G,N,J)}return G}function N8($){return Object.keys($).map((G)=>{let J=$[G];if(!Array.isArray(J))J=[J];return J.map((Z)=>{return[G].concat(Object.keys(Z).map((X)=>{let z=Z[X];if(!Array.isArray(z))z=[z];return z.map((N)=>N===!0?X:`${X}=${N}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}B9.exports={format:N8,parse:Q8}});var a0=u((KJ,D9)=>{var Y8=w("events"),K8=w("https"),H8=w("http"),j9=w("net"),I8=w("tls"),{randomBytes:q8,createHash:B8}=w("crypto"),{Duplex:NJ,Readable:YJ}=w("stream"),{URL:J4}=w("url"),L1=X0(),U8=a2(),_8=e2(),{isBlob:j8}=h1(),{BINARY_TYPES:U9,CLOSE_TIMEOUT:R8,EMPTY_BUFFER:s0,GUID:V8,kForOnEventAttribute:Z4,kListener:M8,kStatusCode:T8,kWebSocket:l,NOOP:R9}=U1(),{EventTarget:{addEventListener:x8,removeEventListener:W8}}=q9(),{format:L8,parse:A8}=G4(),{toBuffer:D8}=J0(),V9=Symbol("kAborted"),X4=[8,13],j1=["CONNECTING","OPEN","CLOSING","CLOSED"],C8=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class C extends Y8{constructor($,G,J){super();if(this._binaryType=U9[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=s0,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=C.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,$!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,G===void 0)G=[];else if(!Array.isArray(G))if(typeof G==="object"&&G!==null)J=G,G=[];else G=[G];M9(this,$,G,J)}else this._autoPong=J.autoPong,this._closeTimeout=J.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType($){if(!U9.includes($))return;if(this._binaryType=$,this._receiver)this._receiver._binaryType=$}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket($,G,J){let Z=new U8({allowSynchronousEvents:J.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:J.maxPayload,skipUTF8Validation:J.skipUTF8Validation}),X=new _8($,this._extensions,J.generateMask);if(this._receiver=Z,this._sender=X,this._socket=$,Z[l]=this,X[l]=this,$[l]=this,Z.on("conclude",P8),Z.on("drain",E8),Z.on("error",S8),Z.on("message",w8),Z.on("ping",y8),Z.on("pong",v8),X.onerror=g8,$.setTimeout)$.setTimeout(0);if($.setNoDelay)$.setNoDelay();if(G.length>0)$.unshift(G);$.on("close",W9),$.on("data",r0),$.on("end",L9),$.on("error",A9),this._readyState=C.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=C.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[L1.extensionName])this._extensions[L1.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=C.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close($,G){if(this.readyState===C.CLOSED)return;if(this.readyState===C.CONNECTING){r(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===C.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=C.CLOSING,this._sender.close($,G,!this._isServer,(J)=>{if(J)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),x9(this)}pause(){if(this.readyState===C.CONNECTING||this.readyState===C.CLOSED)return;this._paused=!0,this._socket.pause()}ping($,G,J){if(this.readyState===C.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")J=$,$=G=void 0;else if(typeof G==="function")J=G,G=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==C.OPEN){z4(this,$,J);return}if(G===void 0)G=!this._isServer;this._sender.ping($||s0,G,J)}pong($,G,J){if(this.readyState===C.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")J=$,$=G=void 0;else if(typeof G==="function")J=G,G=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==C.OPEN){z4(this,$,J);return}if(G===void 0)G=!this._isServer;this._sender.pong($||s0,G,J)}resume(){if(this.readyState===C.CONNECTING||this.readyState===C.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send($,G,J){if(this.readyState===C.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof G==="function")J=G,G={};if(typeof $==="number")$=$.toString();if(this.readyState!==C.OPEN){z4(this,$,J);return}let Z={binary:typeof $!=="string",mask:!this._isServer,compress:!0,fin:!0,...G};if(!this._extensions[L1.extensionName])Z.compress=!1;this._sender.send($||s0,Z,J)}terminate(){if(this.readyState===C.CLOSED)return;if(this.readyState===C.CONNECTING){r(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=C.CLOSING,this._socket.destroy()}}Object.defineProperty(C,"CONNECTING",{enumerable:!0,value:j1.indexOf("CONNECTING")});Object.defineProperty(C.prototype,"CONNECTING",{enumerable:!0,value:j1.indexOf("CONNECTING")});Object.defineProperty(C,"OPEN",{enumerable:!0,value:j1.indexOf("OPEN")});Object.defineProperty(C.prototype,"OPEN",{enumerable:!0,value:j1.indexOf("OPEN")});Object.defineProperty(C,"CLOSING",{enumerable:!0,value:j1.indexOf("CLOSING")});Object.defineProperty(C.prototype,"CLOSING",{enumerable:!0,value:j1.indexOf("CLOSING")});Object.defineProperty(C,"CLOSED",{enumerable:!0,value:j1.indexOf("CLOSED")});Object.defineProperty(C.prototype,"CLOSED",{enumerable:!0,value:j1.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(($)=>{Object.defineProperty(C.prototype,$,{enumerable:!0})});["open","error","close","message"].forEach(($)=>{Object.defineProperty(C.prototype,`on${$}`,{enumerable:!0,get(){for(let G of this.listeners($))if(G[Z4])return G[M8];return null},set(G){for(let J of this.listeners($))if(J[Z4]){this.removeListener($,J);break}if(typeof G!=="function")return;this.addEventListener($,G,{[Z4]:!0})}})});C.prototype.addEventListener=x8;C.prototype.removeEventListener=W8;D9.exports=C;function M9($,G,J,Z){let X={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:R8,protocolVersion:X4[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...Z,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if($._autoPong=X.autoPong,$._closeTimeout=X.closeTimeout,!X4.includes(X.protocolVersion))throw RangeError(`Unsupported protocol version: ${X.protocolVersion} (supported versions: ${X4.join(", ")})`);let z;if(G instanceof J4)z=G;else try{z=new J4(G)}catch(B){throw SyntaxError(`Invalid URL: ${G}`)}if(z.protocol==="http:")z.protocol="ws:";else if(z.protocol==="https:")z.protocol="wss:";$._url=z.href;let N=z.protocol==="wss:",Q=z.protocol==="ws+unix:",Y;if(z.protocol!=="ws:"&&!N&&!Q)Y=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(Q&&!z.pathname)Y="The URL's pathname is empty";else if(z.hash)Y="The URL contains a fragment identifier";if(Y){let B=SyntaxError(Y);if($._redirects===0)throw B;else{o0($,B);return}}let K=N?443:80,I=q8(16).toString("base64"),H=N?K8.request:H8.request,U=new Set,_;if(X.createConnection=X.createConnection||(N?F8:O8),X.defaultPort=X.defaultPort||K,X.port=z.port||K,X.host=z.hostname.startsWith("[")?z.hostname.slice(1,-1):z.hostname,X.headers={...X.headers,"Sec-WebSocket-Version":X.protocolVersion,"Sec-WebSocket-Key":I,Connection:"Upgrade",Upgrade:"websocket"},X.path=z.pathname+z.search,X.timeout=X.handshakeTimeout,X.perMessageDeflate)_=new L1(X.perMessageDeflate!==!0?X.perMessageDeflate:{},!1,X.maxPayload),X.headers["Sec-WebSocket-Extensions"]=L8({[L1.extensionName]:_.offer()});if(J.length){for(let B of J){if(typeof B!=="string"||!C8.test(B)||U.has(B))throw SyntaxError("An invalid or duplicated subprotocol was specified");U.add(B)}X.headers["Sec-WebSocket-Protocol"]=J.join(",")}if(X.origin)if(X.protocolVersion<13)X.headers["Sec-WebSocket-Origin"]=X.origin;else X.headers.Origin=X.origin;if(z.username||z.password)X.auth=`${z.username}:${z.password}`;if(Q){let B=X.path.split(":");X.socketPath=B[0],X.path=B[1]}let q;if(X.followRedirects){if($._redirects===0){$._originalIpc=Q,$._originalSecure=N,$._originalHostOrSocketPath=Q?X.socketPath:z.host;let B=Z&&Z.headers;if(Z={...Z,headers:{}},B)for(let[M,V]of Object.entries(B))Z.headers[M.toLowerCase()]=V}else if($.listenerCount("redirect")===0){let B=Q?$._originalIpc?X.socketPath===$._originalHostOrSocketPath:!1:$._originalIpc?!1:z.host===$._originalHostOrSocketPath;if(!B||$._originalSecure&&!N){if(delete X.headers.authorization,delete X.headers.cookie,!B)delete X.headers.host;X.auth=void 0}}if(X.auth&&!Z.headers.authorization)Z.headers.authorization="Basic "+Buffer.from(X.auth).toString("base64");if(q=$._req=H(X),$._redirects)$.emit("redirect",$.url,q)}else q=$._req=H(X);if(X.timeout)q.on("timeout",()=>{r($,q,"Opening handshake has timed out")});if(q.on("error",(B)=>{if(q===null||q[V9])return;q=$._req=null,o0($,B)}),q.on("response",(B)=>{let M=B.headers.location,V=B.statusCode;if(M&&X.followRedirects&&V>=300&&V<400){if(++$._redirects>X.maxRedirects){r($,q,"Maximum redirects exceeded");return}q.abort();let x;try{x=new J4(M,G)}catch(L){let D=SyntaxError(`Invalid URL: ${M}`);o0($,D);return}M9($,x,J,Z)}else if(!$.emit("unexpected-response",q,B))r($,q,`Unexpected server response: ${B.statusCode}`)}),q.on("upgrade",(B,M,V)=>{if($.emit("upgrade",B),$.readyState!==C.CONNECTING)return;q=$._req=null;let x=B.headers.upgrade;if(x===void 0||x.toLowerCase()!=="websocket"){r($,M,"Invalid Upgrade header");return}let L=B8("sha1").update(I+V8).digest("base64");if(B.headers["sec-websocket-accept"]!==L){r($,M,"Invalid Sec-WebSocket-Accept header");return}let D=B.headers["sec-websocket-protocol"],A;if(D!==void 0){if(!U.size)A="Server sent a subprotocol but none was requested";else if(!U.has(D))A="Server sent an invalid subprotocol"}else if(U.size)A="Server sent no subprotocol";if(A){r($,M,A);return}if(D)$._protocol=D;let F=B.headers["sec-websocket-extensions"];if(F!==void 0){if(!_){r($,M,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let T;try{T=A8(F)}catch(b){r($,M,"Invalid Sec-WebSocket-Extensions header");return}let W=Object.keys(T);if(W.length!==1||W[0]!==L1.extensionName){r($,M,"Server indicated an extension that was not requested");return}try{_.accept(T[L1.extensionName])}catch(b){r($,M,"Invalid Sec-WebSocket-Extensions header");return}$._extensions[L1.extensionName]=_}$.setSocket(M,V,{allowSynchronousEvents:X.allowSynchronousEvents,generateMask:X.generateMask,maxPayload:X.maxPayload,skipUTF8Validation:X.skipUTF8Validation})}),X.finishRequest)X.finishRequest(q,$);else q.end()}function o0($,G){$._readyState=C.CLOSING,$._errorEmitted=!0,$.emit("error",G),$.emitClose()}function O8($){return $.path=$.socketPath,j9.connect($)}function F8($){if($.path=void 0,!$.servername&&$.servername!=="")$.servername=j9.isIP($.host)?"":$.host;return I8.connect($)}function r($,G,J){$._readyState=C.CLOSING;let Z=Error(J);if(Error.captureStackTrace(Z,r),G.setHeader){if(G[V9]=!0,G.abort(),G.socket&&!G.socket.destroyed)G.socket.destroy();process.nextTick(o0,$,Z)}else G.destroy(Z),G.once("error",$.emit.bind($,"error")),G.once("close",$.emitClose.bind($))}function z4($,G,J){if(G){let Z=j8(G)?G.size:D8(G).length;if($._socket)$._sender._bufferedBytes+=Z;else $._bufferedAmount+=Z}if(J){let Z=Error(`WebSocket is not open: readyState ${$.readyState} (${j1[$.readyState]})`);process.nextTick(J,Z)}}function P8($,G){let J=this[l];if(J._closeFrameReceived=!0,J._closeMessage=G,J._closeCode=$,J._socket[l]===void 0)return;if(J._socket.removeListener("data",r0),process.nextTick(T9,J._socket),$===1005)J.close();else J.close($,G)}function E8(){let $=this[l];if(!$.isPaused)$._socket.resume()}function S8($){let G=this[l];if(G._socket[l]!==void 0)G._socket.removeListener("data",r0),process.nextTick(T9,G._socket),G.close($[T8]);if(!G._errorEmitted)G._errorEmitted=!0,G.emit("error",$)}function _9(){this[l].emitClose()}function w8($,G){this[l].emit("message",$,G)}function y8($){let G=this[l];if(G._autoPong)G.pong($,!this._isServer,R9);G.emit("ping",$)}function v8($){this[l].emit("pong",$)}function T9($){$.resume()}function g8($){let G=this[l];if(G.readyState===C.CLOSED)return;if(G.readyState===C.OPEN)G._readyState=C.CLOSING,x9(G);if(this._socket.end(),!G._errorEmitted)G._errorEmitted=!0,G.emit("error",$)}function x9($){$._closeTimer=setTimeout($._socket.destroy.bind($._socket),$._closeTimeout)}function W9(){let $=this[l];if(this.removeListener("close",W9),this.removeListener("data",r0),this.removeListener("end",L9),$._readyState=C.CLOSING,!this._readableState.endEmitted&&!$._closeFrameReceived&&!$._receiver._writableState.errorEmitted&&this._readableState.length!==0){let G=this.read(this._readableState.length);$._receiver.write(G)}if($._receiver.end(),this[l]=void 0,clearTimeout($._closeTimer),$._receiver._writableState.finished||$._receiver._writableState.errorEmitted)$.emitClose();else $._receiver.on("error",_9),$._receiver.on("finish",_9)}function r0($){if(!this[l]._receiver.write($))this.pause()}function L9(){let $=this[l];$._readyState=C.CLOSING,$._receiver.end(),this.end()}function A9(){let $=this[l];if(this.removeListener("error",A9),this.on("error",R9),$)$._readyState=C.CLOSING,this.destroy()}});var P9=u((IJ,F9)=>{var HJ=a0(),{Duplex:f8}=w("stream");function C9($){$.emit("close")}function b8(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function O9($){if(this.removeListener("error",O9),this.destroy(),this.listenerCount("error")===0)this.emit("error",$)}function u8($,G){let J=!0,Z=new f8({...G,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return $.on("message",function(z,N){let Q=!N&&Z._readableState.objectMode?z.toString():z;if(!Z.push(Q))$.pause()}),$.once("error",function(z){if(Z.destroyed)return;J=!1,Z.destroy(z)}),$.once("close",function(){if(Z.destroyed)return;Z.push(null)}),Z._destroy=function(X,z){if($.readyState===$.CLOSED){z(X),process.nextTick(C9,Z);return}let N=!1;if($.once("error",function(Y){N=!0,z(Y)}),$.once("close",function(){if(!N)z(X);process.nextTick(C9,Z)}),J)$.terminate()},Z._final=function(X){if($.readyState===$.CONNECTING){$.once("open",function(){Z._final(X)});return}if($._socket===null)return;if($._socket._writableState.finished){if(X(),Z._readableState.endEmitted)Z.destroy()}else $._socket.once("finish",function(){X()}),$.close()},Z._read=function(){if($.isPaused)$.resume()},Z._write=function(X,z,N){if($.readyState===$.CONNECTING){$.once("open",function(){Z._write(X,z,N)});return}$.send(X,N)},Z.on("end",b8),Z.on("error",O9),Z}F9.exports=u8});var S9=u((qJ,E9)=>{var{tokenChars:k8}=h1();function h8($){let G=new Set,J=-1,Z=-1,X=0;for(X;X<$.length;X++){let N=$.charCodeAt(X);if(Z===-1&&k8[N]===1){if(J===-1)J=X}else if(X!==0&&(N===32||N===9)){if(Z===-1&&J!==-1)Z=X}else if(N===44){if(J===-1)throw SyntaxError(`Unexpected character at index ${X}`);if(Z===-1)Z=X;let Q=$.slice(J,Z);if(G.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);G.add(Q),J=Z=-1}else throw SyntaxError(`Unexpected character at index ${X}`)}if(J===-1||Z!==-1)throw SyntaxError("Unexpected end of input");let z=$.slice(J,X);if(G.has(z))throw SyntaxError(`The "${z}" subprotocol is duplicated`);return G.add(z),G}E9.exports={parse:h8}});var f9=u((UJ,g9)=>{var m8=w("events"),t0=w("http"),{Duplex:BJ}=w("stream"),{createHash:l8}=w("crypto"),w9=G4(),w1=X0(),d8=S9(),c8=a0(),{CLOSE_TIMEOUT:p8,GUID:i8,kWebSocket:n8}=U1(),s8=/^[+/0-9A-Za-z]{22}==$/;class v9 extends m8{constructor($,G){super();if($={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:p8,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:c8,...$},$.port==null&&!$.server&&!$.noServer||$.port!=null&&($.server||$.noServer)||$.server&&$.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if($.port!=null)this._server=t0.createServer((J,Z)=>{let X=t0.STATUS_CODES[426];Z.writeHead(426,{"Content-Length":X.length,"Content-Type":"text/plain"}),Z.end(X)}),this._server.listen($.port,$.host,$.backlog,G);else if($.server)this._server=$.server;if(this._server){let J=this.emit.bind(this,"connection");this._removeListeners=o8(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(Z,X,z)=>{this.handleUpgrade(Z,X,z,J)}})}if($.perMessageDeflate===!0)$.perMessageDeflate={};if($.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=$,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close($){if(this._state===2){if($)this.once("close",()=>{$(Error("The server is not running"))});process.nextTick(Y0,this);return}if($)this.once("close",$);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(Y0,this);else this._shouldEmitClose=!0;else process.nextTick(Y0,this)}else{let G=this._server;this._removeListeners(),this._removeListeners=this._server=null,G.close(()=>{Y0(this)})}}shouldHandle($){if(this.options.path){let G=$.url.indexOf("?");if((G!==-1?$.url.slice(0,G):$.url)!==this.options.path)return!1}return!0}handleUpgrade($,G,J,Z){G.on("error",y9);let X=$.headers["sec-websocket-key"],z=$.headers.upgrade,N=+$.headers["sec-websocket-version"];if($.method!=="GET"){y1(this,$,G,405,"Invalid HTTP method");return}if(z===void 0||z.toLowerCase()!=="websocket"){y1(this,$,G,400,"Invalid Upgrade header");return}if(X===void 0||!s8.test(X)){y1(this,$,G,400,"Missing or invalid Sec-WebSocket-Key header");return}if(N!==13&&N!==8){y1(this,$,G,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle($)){K0(G,400);return}let Q=$.headers["sec-websocket-protocol"],Y=new Set;if(Q!==void 0)try{Y=d8.parse(Q)}catch(H){y1(this,$,G,400,"Invalid Sec-WebSocket-Protocol header");return}let K=$.headers["sec-websocket-extensions"],I={};if(this.options.perMessageDeflate&&K!==void 0){let H=new w1(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let U=w9.parse(K);if(U[w1.extensionName])H.accept(U[w1.extensionName]),I[w1.extensionName]=H}catch(U){y1(this,$,G,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let H={origin:$.headers[`${N===8?"sec-websocket-origin":"origin"}`],secure:!!($.socket.authorized||$.socket.encrypted),req:$};if(this.options.verifyClient.length===2){this.options.verifyClient(H,(U,_,q,B)=>{if(!U)return K0(G,_||401,q,B);this.completeUpgrade(I,X,Y,$,G,J,Z)});return}if(!this.options.verifyClient(H))return K0(G,401)}this.completeUpgrade(I,X,Y,$,G,J,Z)}completeUpgrade($,G,J,Z,X,z,N){if(!X.readable||!X.writable)return X.destroy();if(X[n8])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return K0(X,503);let Y=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${l8("sha1").update(G+i8).digest("base64")}`],K=new this.options.WebSocket(null,void 0,this.options);if(J.size){let I=this.options.handleProtocols?this.options.handleProtocols(J,Z):J.values().next().value;if(I)Y.push(`Sec-WebSocket-Protocol: ${I}`),K._protocol=I}if($[w1.extensionName]){let I=$[w1.extensionName].params,H=w9.format({[w1.extensionName]:[I]});Y.push(`Sec-WebSocket-Extensions: ${H}`),K._extensions=$}if(this.emit("headers",Y,Z),X.write(Y.concat(`\r
|
|
23
|
+
`)}),this}_outputHelpIfRequested($){let G=this._getHelpOption();if(G&&$.find((Z)=>G.is(Z)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function O4($){return $.map((G)=>{if(!G.startsWith("--inspect"))return G;let J,Z="127.0.0.1",X="9229",z;if((z=G.match(/^(--inspect(-brk)?)$/))!==null)J=z[1];else if((z=G.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(J=z[1],/^\d+$/.test(z[3]))X=z[3];else Z=z[3];else if((z=G.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)J=z[1],Z=z[3],X=z[4];if(J&&X!=="0")return`${J}=${Z}:${parseInt(X)+1}`;return G})}L$.Command=Y2});var w4=f((O$)=>{var{Argument:P4}=_0(),{Command:K2}=F4(),{CommanderError:D$,InvalidArgumentError:E4}=i1(),{Help:C$}=Z2(),{Option:S4}=X2();O$.program=new K2;O$.createCommand=($)=>new K2($);O$.createOption=($,G)=>new S4($,G);O$.createArgument=($,G)=>new P4($,G);O$.Command=K2;O$.Option=S4;O$.Argument=P4;O$.Help=C$;O$.CommanderError=D$;O$.InvalidArgumentError=E4;O$.InvalidOptionArgumentError=E4});var f1=f((RG,H2)=>{var R0=process||{},g4=R0.argv||[],j0=R0.env||{},k$=!(!!j0.NO_COLOR||g4.includes("--no-color"))&&(!!j0.FORCE_COLOR||g4.includes("--color")||R0.platform==="win32"||(R0.stdout||{}).isTTY&&j0.TERM!=="dumb"||!!j0.CI),h$=($,G,J=$)=>(Z)=>{let X=""+Z,z=X.indexOf(G,$.length);return~z?$+m$(X,G,J,z)+G:$+X+G},m$=($,G,J,Z)=>{let X="",z=0;do X+=$.substring(z,Z)+J,z=Z+G.length,Z=$.indexOf(G,z);while(~Z);return X+$.substring(z)},f4=($=k$)=>{let G=$?h$:()=>String;return{isColorSupported:$,reset:G("\x1B[0m","\x1B[0m"),bold:G("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:G("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:G("\x1B[3m","\x1B[23m"),underline:G("\x1B[4m","\x1B[24m"),inverse:G("\x1B[7m","\x1B[27m"),hidden:G("\x1B[8m","\x1B[28m"),strikethrough:G("\x1B[9m","\x1B[29m"),black:G("\x1B[30m","\x1B[39m"),red:G("\x1B[31m","\x1B[39m"),green:G("\x1B[32m","\x1B[39m"),yellow:G("\x1B[33m","\x1B[39m"),blue:G("\x1B[34m","\x1B[39m"),magenta:G("\x1B[35m","\x1B[39m"),cyan:G("\x1B[36m","\x1B[39m"),white:G("\x1B[37m","\x1B[39m"),gray:G("\x1B[90m","\x1B[39m"),bgBlack:G("\x1B[40m","\x1B[49m"),bgRed:G("\x1B[41m","\x1B[49m"),bgGreen:G("\x1B[42m","\x1B[49m"),bgYellow:G("\x1B[43m","\x1B[49m"),bgBlue:G("\x1B[44m","\x1B[49m"),bgMagenta:G("\x1B[45m","\x1B[49m"),bgCyan:G("\x1B[46m","\x1B[49m"),bgWhite:G("\x1B[47m","\x1B[49m"),blackBright:G("\x1B[90m","\x1B[39m"),redBright:G("\x1B[91m","\x1B[39m"),greenBright:G("\x1B[92m","\x1B[39m"),yellowBright:G("\x1B[93m","\x1B[39m"),blueBright:G("\x1B[94m","\x1B[39m"),magentaBright:G("\x1B[95m","\x1B[39m"),cyanBright:G("\x1B[96m","\x1B[39m"),whiteBright:G("\x1B[97m","\x1B[39m"),bgBlackBright:G("\x1B[100m","\x1B[49m"),bgRedBright:G("\x1B[101m","\x1B[49m"),bgGreenBright:G("\x1B[102m","\x1B[49m"),bgYellowBright:G("\x1B[103m","\x1B[49m"),bgBlueBright:G("\x1B[104m","\x1B[49m"),bgMagentaBright:G("\x1B[105m","\x1B[49m"),bgCyanBright:G("\x1B[106m","\x1B[49m"),bgWhiteBright:G("\x1B[107m","\x1B[49m")}};H2.exports=f4();H2.exports.createColors=f4});var q2=f((MG,b4)=>{var I2={to($,G){if(!G)return`\x1B[${$+1}G`;return`\x1B[${G+1};${$+1}H`},move($,G){let J="";if($<0)J+=`\x1B[${-$}D`;else if($>0)J+=`\x1B[${$}C`;if(G<0)J+=`\x1B[${-G}A`;else if(G>0)J+=`\x1B[${G}B`;return J},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},d$={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},l$={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let G="";for(let J=0;J<$;J++)G+=this.line+(J<$-1?I2.up():"");if($)G+=I2.left;return G}};b4.exports={cursor:I2,scroll:d$,erase:l$,beep:"\x07"}});var U1=f((rG,b3)=>{var g3=["nodebuffer","arraybuffer","fragments"],f3=typeof Blob<"u";if(f3)g3.push("blob");b3.exports={BINARY_TYPES:g3,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:f3,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var J0=f((aG,m0)=>{var{EMPTY_BUFFER:S6}=U1(),n2=Buffer[Symbol.species];function w6($,G){if($.length===0)return S6;if($.length===1)return $[0];let J=Buffer.allocUnsafe(G),Z=0;for(let X=0;X<$.length;X++){let z=$[X];J.set(z,Z),Z+=z.length}if(Z<G)return new n2(J.buffer,J.byteOffset,Z);return J}function u3($,G,J,Z,X){for(let z=0;z<X;z++)J[Z+z]=$[z]^G[z&3]}function k3($,G){for(let J=0;J<$.length;J++)$[J]^=G[J&3]}function y6($){if($.length===$.buffer.byteLength)return $.buffer;return $.buffer.slice($.byteOffset,$.byteOffset+$.length)}function i2($){if(i2.readOnly=!0,Buffer.isBuffer($))return $;let G;if($ instanceof ArrayBuffer)G=new n2($);else if(ArrayBuffer.isView($))G=new n2($.buffer,$.byteOffset,$.byteLength);else G=Buffer.from($),i2.readOnly=!1;return G}m0.exports={concat:w6,mask:u3,toArrayBuffer:y6,toBuffer:i2,unmask:k3};if(!process.env.WS_NO_BUFFER_UTIL)try{let $=(()=>{throw new Error("Cannot require module "+"bufferutil");})();m0.exports.mask=function(G,J,Z,X,z){if(z<48)u3(G,J,Z,X,z);else $.mask(G,J,Z,X,z)},m0.exports.unmask=function(G,J){if(G.length<32)k3(G,J);else $.unmask(G,J)}}catch($){}});var l3=f((tG,d3)=>{var h3=Symbol("kDone"),s2=Symbol("kRun");class m3{constructor($){this[h3]=()=>{this.pending--,this[s2]()},this.concurrency=$||1/0,this.jobs=[],this.pending=0}add($){this.jobs.push($),this[s2]()}[s2](){if(this.pending===this.concurrency)return;if(this.jobs.length){let $=this.jobs.shift();this.pending++,$(this[h3])}}}d3.exports=m3});var X0=f((eG,s3)=>{var Z0=S("zlib"),c3=J0(),v6=l3(),{kStatusCode:p3}=U1(),g6=Buffer[Symbol.species],f6=Buffer.from([0,0,255,255]),l0=Symbol("permessage-deflate"),_1=Symbol("total-length"),u1=Symbol("callback"),T1=Symbol("buffers"),k1=Symbol("error"),d0;class n3{constructor($,G,J){if(this._maxPayload=J|0,this._options=$||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!G,this._deflate=null,this._inflate=null,this.params=null,!d0){let Z=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;d0=new v6(Z)}}static get extensionName(){return"permessage-deflate"}offer(){let $={};if(this._options.serverNoContextTakeover)$.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)$.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)$.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)$.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)$.client_max_window_bits=!0;return $}accept($){return $=this.normalizeParams($),this.params=this._isServer?this.acceptAsServer($):this.acceptAsClient($),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let $=this._deflate[u1];if(this._deflate.close(),this._deflate=null,$)$(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer($){let G=this._options,J=$.find((Z)=>{if(G.serverNoContextTakeover===!1&&Z.server_no_context_takeover||Z.server_max_window_bits&&(G.serverMaxWindowBits===!1||typeof G.serverMaxWindowBits==="number"&&G.serverMaxWindowBits>Z.server_max_window_bits)||typeof G.clientMaxWindowBits==="number"&&!Z.client_max_window_bits)return!1;return!0});if(!J)throw Error("None of the extension offers can be accepted");if(G.serverNoContextTakeover)J.server_no_context_takeover=!0;if(G.clientNoContextTakeover)J.client_no_context_takeover=!0;if(typeof G.serverMaxWindowBits==="number")J.server_max_window_bits=G.serverMaxWindowBits;if(typeof G.clientMaxWindowBits==="number")J.client_max_window_bits=G.clientMaxWindowBits;else if(J.client_max_window_bits===!0||G.clientMaxWindowBits===!1)delete J.client_max_window_bits;return J}acceptAsClient($){let G=$[0];if(this._options.clientNoContextTakeover===!1&&G.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!G.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")G.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&G.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return G}normalizeParams($){return $.forEach((G)=>{Object.keys(G).forEach((J)=>{let Z=G[J];if(Z.length>1)throw Error(`Parameter "${J}" must have only a single value`);if(Z=Z[0],J==="client_max_window_bits"){if(Z!==!0){let X=+Z;if(!Number.isInteger(X)||X<8||X>15)throw TypeError(`Invalid value for parameter "${J}": ${Z}`);Z=X}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${J}": ${Z}`)}else if(J==="server_max_window_bits"){let X=+Z;if(!Number.isInteger(X)||X<8||X>15)throw TypeError(`Invalid value for parameter "${J}": ${Z}`);Z=X}else if(J==="client_no_context_takeover"||J==="server_no_context_takeover"){if(Z!==!0)throw TypeError(`Invalid value for parameter "${J}": ${Z}`)}else throw Error(`Unknown parameter "${J}"`);G[J]=Z})}),$}decompress($,G,J){d0.add((Z)=>{this._decompress($,G,(X,z)=>{Z(),J(X,z)})})}compress($,G,J){d0.add((Z)=>{this._compress($,G,(X,z)=>{Z(),J(X,z)})})}_decompress($,G,J){let Z=this._isServer?"client":"server";if(!this._inflate){let X=`${Z}_max_window_bits`,z=typeof this.params[X]!=="number"?Z0.Z_DEFAULT_WINDOWBITS:this.params[X];this._inflate=Z0.createInflateRaw({...this._options.zlibInflateOptions,windowBits:z}),this._inflate[l0]=this,this._inflate[_1]=0,this._inflate[T1]=[],this._inflate.on("error",u6),this._inflate.on("data",i3)}if(this._inflate[u1]=J,this._inflate.write($),G)this._inflate.write(f6);this._inflate.flush(()=>{let X=this._inflate[k1];if(X){this._inflate.close(),this._inflate=null,J(X);return}let z=c3.concat(this._inflate[T1],this._inflate[_1]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[_1]=0,this._inflate[T1]=[],G&&this.params[`${Z}_no_context_takeover`])this._inflate.reset();J(null,z)})}_compress($,G,J){let Z=this._isServer?"server":"client";if(!this._deflate){let X=`${Z}_max_window_bits`,z=typeof this.params[X]!=="number"?Z0.Z_DEFAULT_WINDOWBITS:this.params[X];this._deflate=Z0.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:z}),this._deflate[_1]=0,this._deflate[T1]=[],this._deflate.on("data",b6)}this._deflate[u1]=J,this._deflate.write($),this._deflate.flush(Z0.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let X=c3.concat(this._deflate[T1],this._deflate[_1]);if(G)X=new g6(X.buffer,X.byteOffset,X.length-4);if(this._deflate[u1]=null,this._deflate[_1]=0,this._deflate[T1]=[],G&&this.params[`${Z}_no_context_takeover`])this._deflate.reset();J(null,X)})}}s3.exports=n3;function b6($){this[T1].push($),this[_1]+=$.length}function i3($){if(this[_1]+=$.length,this[l0]._maxPayload<1||this[_1]<=this[l0]._maxPayload){this[T1].push($);return}this[k1]=RangeError("Max payload size exceeded"),this[k1].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[k1][p3]=1009,this.removeListener("data",i3),this.reset()}function u6($){if(this[l0]._inflate=null,this[k1]){this[u1](this[k1]);return}$[p3]=1007,this[u1]($)}});var h1=f(($J,c0)=>{var{isUtf8:o3}=S("buffer"),{hasBlob:k6}=U1(),h6=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function m6($){return $>=1000&&$<=1014&&$!==1004&&$!==1005&&$!==1006||$>=3000&&$<=4999}function o2($){let G=$.length,J=0;while(J<G)if(($[J]&128)===0)J++;else if(($[J]&224)===192){if(J+1===G||($[J+1]&192)!==128||($[J]&254)===192)return!1;J+=2}else if(($[J]&240)===224){if(J+2>=G||($[J+1]&192)!==128||($[J+2]&192)!==128||$[J]===224&&($[J+1]&224)===128||$[J]===237&&($[J+1]&224)===160)return!1;J+=3}else if(($[J]&248)===240){if(J+3>=G||($[J+1]&192)!==128||($[J+2]&192)!==128||($[J+3]&192)!==128||$[J]===240&&($[J+1]&240)===128||$[J]===244&&$[J+1]>143||$[J]>244)return!1;J+=4}else return!1;return!0}function d6($){return k6&&typeof $==="object"&&typeof $.arrayBuffer==="function"&&typeof $.type==="string"&&typeof $.stream==="function"&&($[Symbol.toStringTag]==="Blob"||$[Symbol.toStringTag]==="File")}c0.exports={isBlob:d6,isValidStatusCode:m6,isValidUTF8:o2,tokenChars:h6};if(o3)c0.exports.isValidUTF8=function($){return $.length<24?o2($):o3($)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let $=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();c0.exports.isValidUTF8=function(G){return G.length<32?o2(G):$(G)}}catch($){}});var a2=f((GJ,$9)=>{var{Writable:l6}=S("stream"),r3=X0(),{BINARY_TYPES:c6,EMPTY_BUFFER:a3,kStatusCode:p6,kWebSocket:n6}=U1(),{concat:r2,toArrayBuffer:i6,unmask:s6}=J0(),{isValidStatusCode:o6,isValidUTF8:t3}=h1(),p0=Buffer[Symbol.species];class e3 extends l6{constructor($={}){super();this._allowSynchronousEvents=$.allowSynchronousEvents!==void 0?$.allowSynchronousEvents:!0,this._binaryType=$.binaryType||c6[0],this._extensions=$.extensions||{},this._isServer=!!$.isServer,this._maxPayload=$.maxPayload|0,this._skipUTF8Validation=!!$.skipUTF8Validation,this[n6]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write($,G,J){if(this._opcode===8&&this._state==0)return J();this._bufferedBytes+=$.length,this._buffers.push($),this.startLoop(J)}consume($){if(this._bufferedBytes-=$,$===this._buffers[0].length)return this._buffers.shift();if($<this._buffers[0].length){let J=this._buffers[0];return this._buffers[0]=new p0(J.buffer,J.byteOffset+$,J.length-$),new p0(J.buffer,J.byteOffset,$)}let G=Buffer.allocUnsafe($);do{let J=this._buffers[0],Z=G.length-$;if($>=J.length)G.set(this._buffers.shift(),Z);else G.set(new Uint8Array(J.buffer,J.byteOffset,$),Z),this._buffers[0]=new p0(J.buffer,J.byteOffset+$,J.length-$);$-=J.length}while($>0);return G}startLoop($){this._loop=!0;do switch(this._state){case 0:this.getInfo($);break;case 1:this.getPayloadLength16($);break;case 2:this.getPayloadLength64($);break;case 3:this.getMask();break;case 4:this.getData($);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)$()}getInfo($){if(this._bufferedBytes<2){this._loop=!1;return}let G=this.consume(2);if((G[0]&48)!==0){let Z=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");$(Z);return}let J=(G[0]&64)===64;if(J&&!this._extensions[r3.extensionName]){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(Z);return}if(this._fin=(G[0]&128)===128,this._opcode=G[0]&15,this._payloadLength=G[1]&127,this._opcode===0){if(J){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(Z);return}if(!this._fragmented){let Z=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");$(Z);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let Z=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(Z);return}this._compressed=J}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let Z=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");$(Z);return}if(J){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");$(Z);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let Z=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");$(Z);return}}else{let Z=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");$(Z);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(G[1]&128)===128,this._isServer){if(!this._masked){let Z=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");$(Z);return}}else if(this._masked){let Z=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");$(Z);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength($)}getPayloadLength16($){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength($)}getPayloadLength64($){if(this._bufferedBytes<8){this._loop=!1;return}let G=this.consume(8),J=G.readUInt32BE(0);if(J>Math.pow(2,21)-1){let Z=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");$(Z);return}this._payloadLength=J*Math.pow(2,32)+G.readUInt32BE(4),this.haveLength($)}haveLength($){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let G=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");$(G);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData($){let G=a3;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(G=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)s6(G,this._mask)}if(this._opcode>7){this.controlMessage(G,$);return}if(this._compressed){this._state=5,this.decompress(G,$);return}if(G.length)this._messageLength=this._totalPayloadLength,this._fragments.push(G);this.dataMessage($)}decompress($,G){this._extensions[r3.extensionName].decompress($,this._fin,(Z,X)=>{if(Z)return G(Z);if(X.length){if(this._messageLength+=X.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let z=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");G(z);return}this._fragments.push(X)}if(this.dataMessage(G),this._state===0)this.startLoop(G)})}dataMessage($){if(!this._fin){this._state=0;return}let G=this._messageLength,J=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let Z;if(this._binaryType==="nodebuffer")Z=r2(J,G);else if(this._binaryType==="arraybuffer")Z=i6(r2(J,G));else if(this._binaryType==="blob")Z=new Blob(J);else Z=J;if(this._allowSynchronousEvents)this.emit("message",Z,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Z,!0),this._state=0,this.startLoop($)})}else{let Z=r2(J,G);if(!this._skipUTF8Validation&&!t3(Z)){let X=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");$(X);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",Z,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Z,!1),this._state=0,this.startLoop($)})}}controlMessage($,G){if(this._opcode===8){if($.length===0)this._loop=!1,this.emit("conclude",1005,a3),this.end();else{let J=$.readUInt16BE(0);if(!o6(J)){let X=this.createError(RangeError,`invalid status code ${J}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");G(X);return}let Z=new p0($.buffer,$.byteOffset+2,$.length-2);if(!this._skipUTF8Validation&&!t3(Z)){let X=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");G(X);return}this._loop=!1,this.emit("conclude",J,Z),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",$),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",$),this._state=0,this.startLoop(G)})}createError($,G,J,Z,X){this._loop=!1,this._errored=!0;let z=new $(J?`Invalid WebSocket frame: ${G}`:G);return Error.captureStackTrace(z,this.createError),z.code=X,z[p6]=Z,z}}$9.exports=e3});var e2=f((ZJ,Z9)=>{var{Duplex:JJ}=S("stream"),{randomFillSync:r6}=S("crypto"),G9=X0(),{EMPTY_BUFFER:a6,kWebSocket:t6,NOOP:e6}=U1(),{isBlob:m1,isValidStatusCode:$8}=h1(),{mask:J9,toBuffer:E1}=J0(),G1=Symbol("kByteLength"),G8=Buffer.alloc(4),S1,d1=8192,z1=0,J8=1,Z8=2;class x1{constructor($,G,J){if(this._extensions=G||{},J)this._generateMask=J,this._maskBuffer=Buffer.alloc(4);this._socket=$,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=z1,this.onerror=e6,this[t6]=void 0}static frame($,G){let J,Z=!1,X=2,z=!1;if(G.mask){if(J=G.maskBuffer||G8,G.generateMask)G.generateMask(J);else{if(d1===8192){if(S1===void 0)S1=Buffer.alloc(8192);r6(S1,0,8192),d1=0}J[0]=S1[d1++],J[1]=S1[d1++],J[2]=S1[d1++],J[3]=S1[d1++]}z=(J[0]|J[1]|J[2]|J[3])===0,X=6}let N;if(typeof $==="string")if((!G.mask||z)&&G[G1]!==void 0)N=G[G1];else $=Buffer.from($),N=$.length;else N=$.length,Z=G.mask&&G.readOnly&&!z;let Q=N;if(N>=65536)X+=8,Q=127;else if(N>125)X+=2,Q=126;let Y=Buffer.allocUnsafe(Z?N+X:X);if(Y[0]=G.fin?G.opcode|128:G.opcode,G.rsv1)Y[0]|=64;if(Y[1]=Q,Q===126)Y.writeUInt16BE(N,2);else if(Q===127)Y[2]=Y[3]=0,Y.writeUIntBE(N,4,6);if(!G.mask)return[Y,$];if(Y[1]|=128,Y[X-4]=J[0],Y[X-3]=J[1],Y[X-2]=J[2],Y[X-1]=J[3],z)return[Y,$];if(Z)return J9($,J,Y,X,N),[Y];return J9($,J,$,0,N),[Y,$]}close($,G,J,Z){let X;if($===void 0)X=a6;else if(typeof $!=="number"||!$8($))throw TypeError("First argument must be a valid error code number");else if(G===void 0||!G.length)X=Buffer.allocUnsafe(2),X.writeUInt16BE($,0);else{let N=Buffer.byteLength(G);if(N>123)throw RangeError("The message must not be greater than 123 bytes");if(X=Buffer.allocUnsafe(2+N),X.writeUInt16BE($,0),typeof G==="string")X.write(G,2);else X.set(G,2)}let z={[G1]:X.length,fin:!0,generateMask:this._generateMask,mask:J,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==z1)this.enqueue([this.dispatch,X,!1,z,Z]);else this.sendFrame(x1.frame(X,z),Z)}ping($,G,J){let Z,X;if(typeof $==="string")Z=Buffer.byteLength($),X=!1;else if(m1($))Z=$.size,X=!1;else $=E1($),Z=$.length,X=E1.readOnly;if(Z>125)throw RangeError("The data size must not be greater than 125 bytes");let z={[G1]:Z,fin:!0,generateMask:this._generateMask,mask:G,maskBuffer:this._maskBuffer,opcode:9,readOnly:X,rsv1:!1};if(m1($))if(this._state!==z1)this.enqueue([this.getBlobData,$,!1,z,J]);else this.getBlobData($,!1,z,J);else if(this._state!==z1)this.enqueue([this.dispatch,$,!1,z,J]);else this.sendFrame(x1.frame($,z),J)}pong($,G,J){let Z,X;if(typeof $==="string")Z=Buffer.byteLength($),X=!1;else if(m1($))Z=$.size,X=!1;else $=E1($),Z=$.length,X=E1.readOnly;if(Z>125)throw RangeError("The data size must not be greater than 125 bytes");let z={[G1]:Z,fin:!0,generateMask:this._generateMask,mask:G,maskBuffer:this._maskBuffer,opcode:10,readOnly:X,rsv1:!1};if(m1($))if(this._state!==z1)this.enqueue([this.getBlobData,$,!1,z,J]);else this.getBlobData($,!1,z,J);else if(this._state!==z1)this.enqueue([this.dispatch,$,!1,z,J]);else this.sendFrame(x1.frame($,z),J)}send($,G,J){let Z=this._extensions[G9.extensionName],X=G.binary?2:1,z=G.compress,N,Q;if(typeof $==="string")N=Buffer.byteLength($),Q=!1;else if(m1($))N=$.size,Q=!1;else $=E1($),N=$.length,Q=E1.readOnly;if(this._firstFragment){if(this._firstFragment=!1,z&&Z&&Z.params[Z._isServer?"server_no_context_takeover":"client_no_context_takeover"])z=N>=Z._threshold;this._compress=z}else z=!1,X=0;if(G.fin)this._firstFragment=!0;let Y={[G1]:N,fin:G.fin,generateMask:this._generateMask,mask:G.mask,maskBuffer:this._maskBuffer,opcode:X,readOnly:Q,rsv1:z};if(m1($))if(this._state!==z1)this.enqueue([this.getBlobData,$,this._compress,Y,J]);else this.getBlobData($,this._compress,Y,J);else if(this._state!==z1)this.enqueue([this.dispatch,$,this._compress,Y,J]);else this.dispatch($,this._compress,Y,J)}getBlobData($,G,J,Z){this._bufferedBytes+=J[G1],this._state=Z8,$.arrayBuffer().then((X)=>{if(this._socket.destroyed){let N=Error("The socket was closed while the blob was being read");process.nextTick(t2,this,N,Z);return}this._bufferedBytes-=J[G1];let z=E1(X);if(!G)this._state=z1,this.sendFrame(x1.frame(z,J),Z),this.dequeue();else this.dispatch(z,G,J,Z)}).catch((X)=>{process.nextTick(X8,this,X,Z)})}dispatch($,G,J,Z){if(!G){this.sendFrame(x1.frame($,J),Z);return}let X=this._extensions[G9.extensionName];this._bufferedBytes+=J[G1],this._state=J8,X.compress($,J.fin,(z,N)=>{if(this._socket.destroyed){let Q=Error("The socket was closed while data was being compressed");t2(this,Q,Z);return}this._bufferedBytes-=J[G1],this._state=z1,J.readOnly=!1,this.sendFrame(x1.frame(N,J),Z),this.dequeue()})}dequeue(){while(this._state===z1&&this._queue.length){let $=this._queue.shift();this._bufferedBytes-=$[3][G1],Reflect.apply($[0],this,$.slice(1))}}enqueue($){this._bufferedBytes+=$[3][G1],this._queue.push($)}sendFrame($,G){if($.length===2)this._socket.cork(),this._socket.write($[0]),this._socket.write($[1],G),this._socket.uncork();else this._socket.write($[0],G)}}Z9.exports=x1;function t2($,G,J){if(typeof J==="function")J(G);for(let Z=0;Z<$._queue.length;Z++){let X=$._queue[Z],z=X[X.length-1];if(typeof z==="function")z(G)}}function X8($,G,J){t2($,G,J),$.onerror(G)}});var q9=f((XJ,I9)=>{var{kForOnEventAttribute:z0,kListener:$4}=U1(),X9=Symbol("kCode"),z9=Symbol("kData"),Q9=Symbol("kError"),N9=Symbol("kMessage"),Y9=Symbol("kReason"),l1=Symbol("kTarget"),K9=Symbol("kType"),H9=Symbol("kWasClean");class W1{constructor($){this[l1]=null,this[K9]=$}get target(){return this[l1]}get type(){return this[K9]}}Object.defineProperty(W1.prototype,"target",{enumerable:!0});Object.defineProperty(W1.prototype,"type",{enumerable:!0});class c1 extends W1{constructor($,G={}){super($);this[X9]=G.code===void 0?0:G.code,this[Y9]=G.reason===void 0?"":G.reason,this[H9]=G.wasClean===void 0?!1:G.wasClean}get code(){return this[X9]}get reason(){return this[Y9]}get wasClean(){return this[H9]}}Object.defineProperty(c1.prototype,"code",{enumerable:!0});Object.defineProperty(c1.prototype,"reason",{enumerable:!0});Object.defineProperty(c1.prototype,"wasClean",{enumerable:!0});class Q0 extends W1{constructor($,G={}){super($);this[Q9]=G.error===void 0?null:G.error,this[N9]=G.message===void 0?"":G.message}get error(){return this[Q9]}get message(){return this[N9]}}Object.defineProperty(Q0.prototype,"error",{enumerable:!0});Object.defineProperty(Q0.prototype,"message",{enumerable:!0});class i0 extends W1{constructor($,G={}){super($);this[z9]=G.data===void 0?null:G.data}get data(){return this[z9]}}Object.defineProperty(i0.prototype,"data",{enumerable:!0});var z8={addEventListener($,G,J={}){for(let X of this.listeners($))if(!J[z0]&&X[$4]===G&&!X[z0])return;let Z;if($==="message")Z=function(z,N){let Q=new i0("message",{data:N?z:z.toString()});Q[l1]=this,n0(G,this,Q)};else if($==="close")Z=function(z,N){let Q=new c1("close",{code:z,reason:N.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});Q[l1]=this,n0(G,this,Q)};else if($==="error")Z=function(z){let N=new Q0("error",{error:z,message:z.message});N[l1]=this,n0(G,this,N)};else if($==="open")Z=function(){let z=new W1("open");z[l1]=this,n0(G,this,z)};else return;if(Z[z0]=!!J[z0],Z[$4]=G,J.once)this.once($,Z);else this.on($,Z)},removeEventListener($,G){for(let J of this.listeners($))if(J[$4]===G&&!J[z0]){this.removeListener($,J);break}}};I9.exports={CloseEvent:c1,ErrorEvent:Q0,Event:W1,EventTarget:z8,MessageEvent:i0};function n0($,G,J){if(typeof $==="object"&&$.handleEvent)$.handleEvent.call($,J);else $.call(G,J)}});var G4=f((zJ,B9)=>{var{tokenChars:N0}=h1();function K1($,G,J){if($[G]===void 0)$[G]=[J];else $[G].push(J)}function Q8($){let G=Object.create(null),J=Object.create(null),Z=!1,X=!1,z=!1,N,Q,Y=-1,K=-1,I=-1,H=0;for(;H<$.length;H++)if(K=$.charCodeAt(H),N===void 0)if(I===-1&&N0[K]===1){if(Y===-1)Y=H}else if(H!==0&&(K===32||K===9)){if(I===-1&&Y!==-1)I=H}else if(K===59||K===44){if(Y===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(I===-1)I=H;let j=$.slice(Y,I);if(K===44)K1(G,j,J),J=Object.create(null);else N=j;Y=I=-1}else throw SyntaxError(`Unexpected character at index ${H}`);else if(Q===void 0)if(I===-1&&N0[K]===1){if(Y===-1)Y=H}else if(K===32||K===9){if(I===-1&&Y!==-1)I=H}else if(K===59||K===44){if(Y===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(I===-1)I=H;if(K1(J,$.slice(Y,I),!0),K===44)K1(G,N,J),J=Object.create(null),N=void 0;Y=I=-1}else if(K===61&&Y!==-1&&I===-1)Q=$.slice(Y,H),Y=I=-1;else throw SyntaxError(`Unexpected character at index ${H}`);else if(X){if(N0[K]!==1)throw SyntaxError(`Unexpected character at index ${H}`);if(Y===-1)Y=H;else if(!Z)Z=!0;X=!1}else if(z)if(N0[K]===1){if(Y===-1)Y=H}else if(K===34&&Y!==-1)z=!1,I=H;else if(K===92)X=!0;else throw SyntaxError(`Unexpected character at index ${H}`);else if(K===34&&$.charCodeAt(H-1)===61)z=!0;else if(I===-1&&N0[K]===1){if(Y===-1)Y=H}else if(Y!==-1&&(K===32||K===9)){if(I===-1)I=H}else if(K===59||K===44){if(Y===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(I===-1)I=H;let j=$.slice(Y,I);if(Z)j=j.replace(/\\/g,""),Z=!1;if(K1(J,Q,j),K===44)K1(G,N,J),J=Object.create(null),N=void 0;Q=void 0,Y=I=-1}else throw SyntaxError(`Unexpected character at index ${H}`);if(Y===-1||z||K===32||K===9)throw SyntaxError("Unexpected end of input");if(I===-1)I=H;let B=$.slice(Y,I);if(N===void 0)K1(G,B,J);else{if(Q===void 0)K1(J,B,!0);else if(Z)K1(J,Q,B.replace(/\\/g,""));else K1(J,Q,B);K1(G,N,J)}return G}function N8($){return Object.keys($).map((G)=>{let J=$[G];if(!Array.isArray(J))J=[J];return J.map((Z)=>{return[G].concat(Object.keys(Z).map((X)=>{let z=Z[X];if(!Array.isArray(z))z=[z];return z.map((N)=>N===!0?X:`${X}=${N}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}B9.exports={format:N8,parse:Q8}});var a0=f((YJ,D9)=>{var Y8=S("events"),K8=S("https"),H8=S("http"),j9=S("net"),I8=S("tls"),{randomBytes:q8,createHash:B8}=S("crypto"),{Duplex:QJ,Readable:NJ}=S("stream"),{URL:J4}=S("url"),L1=X0(),U8=a2(),_8=e2(),{isBlob:j8}=h1(),{BINARY_TYPES:U9,CLOSE_TIMEOUT:R8,EMPTY_BUFFER:s0,GUID:M8,kForOnEventAttribute:Z4,kListener:V8,kStatusCode:T8,kWebSocket:d,NOOP:R9}=U1(),{EventTarget:{addEventListener:x8,removeEventListener:W8}}=q9(),{format:L8,parse:A8}=G4(),{toBuffer:D8}=J0(),M9=Symbol("kAborted"),X4=[8,13],j1=["CONNECTING","OPEN","CLOSING","CLOSED"],C8=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class D extends Y8{constructor($,G,J){super();if(this._binaryType=U9[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=s0,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=D.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,$!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,G===void 0)G=[];else if(!Array.isArray(G))if(typeof G==="object"&&G!==null)J=G,G=[];else G=[G];V9(this,$,G,J)}else this._autoPong=J.autoPong,this._closeTimeout=J.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType($){if(!U9.includes($))return;if(this._binaryType=$,this._receiver)this._receiver._binaryType=$}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket($,G,J){let Z=new U8({allowSynchronousEvents:J.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:J.maxPayload,skipUTF8Validation:J.skipUTF8Validation}),X=new _8($,this._extensions,J.generateMask);if(this._receiver=Z,this._sender=X,this._socket=$,Z[d]=this,X[d]=this,$[d]=this,Z.on("conclude",P8),Z.on("drain",E8),Z.on("error",S8),Z.on("message",w8),Z.on("ping",y8),Z.on("pong",v8),X.onerror=g8,$.setTimeout)$.setTimeout(0);if($.setNoDelay)$.setNoDelay();if(G.length>0)$.unshift(G);$.on("close",W9),$.on("data",r0),$.on("end",L9),$.on("error",A9),this._readyState=D.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=D.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[L1.extensionName])this._extensions[L1.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=D.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close($,G){if(this.readyState===D.CLOSED)return;if(this.readyState===D.CONNECTING){r(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===D.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=D.CLOSING,this._sender.close($,G,!this._isServer,(J)=>{if(J)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),x9(this)}pause(){if(this.readyState===D.CONNECTING||this.readyState===D.CLOSED)return;this._paused=!0,this._socket.pause()}ping($,G,J){if(this.readyState===D.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")J=$,$=G=void 0;else if(typeof G==="function")J=G,G=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==D.OPEN){z4(this,$,J);return}if(G===void 0)G=!this._isServer;this._sender.ping($||s0,G,J)}pong($,G,J){if(this.readyState===D.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof $==="function")J=$,$=G=void 0;else if(typeof G==="function")J=G,G=void 0;if(typeof $==="number")$=$.toString();if(this.readyState!==D.OPEN){z4(this,$,J);return}if(G===void 0)G=!this._isServer;this._sender.pong($||s0,G,J)}resume(){if(this.readyState===D.CONNECTING||this.readyState===D.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send($,G,J){if(this.readyState===D.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof G==="function")J=G,G={};if(typeof $==="number")$=$.toString();if(this.readyState!==D.OPEN){z4(this,$,J);return}let Z={binary:typeof $!=="string",mask:!this._isServer,compress:!0,fin:!0,...G};if(!this._extensions[L1.extensionName])Z.compress=!1;this._sender.send($||s0,Z,J)}terminate(){if(this.readyState===D.CLOSED)return;if(this.readyState===D.CONNECTING){r(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=D.CLOSING,this._socket.destroy()}}Object.defineProperty(D,"CONNECTING",{enumerable:!0,value:j1.indexOf("CONNECTING")});Object.defineProperty(D.prototype,"CONNECTING",{enumerable:!0,value:j1.indexOf("CONNECTING")});Object.defineProperty(D,"OPEN",{enumerable:!0,value:j1.indexOf("OPEN")});Object.defineProperty(D.prototype,"OPEN",{enumerable:!0,value:j1.indexOf("OPEN")});Object.defineProperty(D,"CLOSING",{enumerable:!0,value:j1.indexOf("CLOSING")});Object.defineProperty(D.prototype,"CLOSING",{enumerable:!0,value:j1.indexOf("CLOSING")});Object.defineProperty(D,"CLOSED",{enumerable:!0,value:j1.indexOf("CLOSED")});Object.defineProperty(D.prototype,"CLOSED",{enumerable:!0,value:j1.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(($)=>{Object.defineProperty(D.prototype,$,{enumerable:!0})});["open","error","close","message"].forEach(($)=>{Object.defineProperty(D.prototype,`on${$}`,{enumerable:!0,get(){for(let G of this.listeners($))if(G[Z4])return G[V8];return null},set(G){for(let J of this.listeners($))if(J[Z4]){this.removeListener($,J);break}if(typeof G!=="function")return;this.addEventListener($,G,{[Z4]:!0})}})});D.prototype.addEventListener=x8;D.prototype.removeEventListener=W8;D9.exports=D;function V9($,G,J,Z){let X={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:R8,protocolVersion:X4[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...Z,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if($._autoPong=X.autoPong,$._closeTimeout=X.closeTimeout,!X4.includes(X.protocolVersion))throw RangeError(`Unsupported protocol version: ${X.protocolVersion} (supported versions: ${X4.join(", ")})`);let z;if(G instanceof J4)z=G;else try{z=new J4(G)}catch(q){throw SyntaxError(`Invalid URL: ${G}`)}if(z.protocol==="http:")z.protocol="ws:";else if(z.protocol==="https:")z.protocol="wss:";$._url=z.href;let N=z.protocol==="wss:",Q=z.protocol==="ws+unix:",Y;if(z.protocol!=="ws:"&&!N&&!Q)Y=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(Q&&!z.pathname)Y="The URL's pathname is empty";else if(z.hash)Y="The URL contains a fragment identifier";if(Y){let q=SyntaxError(Y);if($._redirects===0)throw q;else{o0($,q);return}}let K=N?443:80,I=q8(16).toString("base64"),H=N?K8.request:H8.request,B=new Set,j;if(X.createConnection=X.createConnection||(N?F8:O8),X.defaultPort=X.defaultPort||K,X.port=z.port||K,X.host=z.hostname.startsWith("[")?z.hostname.slice(1,-1):z.hostname,X.headers={...X.headers,"Sec-WebSocket-Version":X.protocolVersion,"Sec-WebSocket-Key":I,Connection:"Upgrade",Upgrade:"websocket"},X.path=z.pathname+z.search,X.timeout=X.handshakeTimeout,X.perMessageDeflate)j=new L1(X.perMessageDeflate!==!0?X.perMessageDeflate:{},!1,X.maxPayload),X.headers["Sec-WebSocket-Extensions"]=L8({[L1.extensionName]:j.offer()});if(J.length){for(let q of J){if(typeof q!=="string"||!C8.test(q)||B.has(q))throw SyntaxError("An invalid or duplicated subprotocol was specified");B.add(q)}X.headers["Sec-WebSocket-Protocol"]=J.join(",")}if(X.origin)if(X.protocolVersion<13)X.headers["Sec-WebSocket-Origin"]=X.origin;else X.headers.Origin=X.origin;if(z.username||z.password)X.auth=`${z.username}:${z.password}`;if(Q){let q=X.path.split(":");X.socketPath=q[0],X.path=q[1]}let U;if(X.followRedirects){if($._redirects===0){$._originalIpc=Q,$._originalSecure=N,$._originalHostOrSocketPath=Q?X.socketPath:z.host;let q=Z&&Z.headers;if(Z={...Z,headers:{}},q)for(let[R,x]of Object.entries(q))Z.headers[R.toLowerCase()]=x}else if($.listenerCount("redirect")===0){let q=Q?$._originalIpc?X.socketPath===$._originalHostOrSocketPath:!1:$._originalIpc?!1:z.host===$._originalHostOrSocketPath;if(!q||$._originalSecure&&!N){if(delete X.headers.authorization,delete X.headers.cookie,!q)delete X.headers.host;X.auth=void 0}}if(X.auth&&!Z.headers.authorization)Z.headers.authorization="Basic "+Buffer.from(X.auth).toString("base64");if(U=$._req=H(X),$._redirects)$.emit("redirect",$.url,U)}else U=$._req=H(X);if(X.timeout)U.on("timeout",()=>{r($,U,"Opening handshake has timed out")});if(U.on("error",(q)=>{if(U===null||U[M9])return;U=$._req=null,o0($,q)}),U.on("response",(q)=>{let R=q.headers.location,x=q.statusCode;if(R&&X.followRedirects&&x>=300&&x<400){if(++$._redirects>X.maxRedirects){r($,U,"Maximum redirects exceeded");return}U.abort();let T;try{T=new J4(R,G)}catch(L){let C=SyntaxError(`Invalid URL: ${R}`);o0($,C);return}V9($,T,J,Z)}else if(!$.emit("unexpected-response",U,q))r($,U,`Unexpected server response: ${q.statusCode}`)}),U.on("upgrade",(q,R,x)=>{if($.emit("upgrade",q),$.readyState!==D.CONNECTING)return;U=$._req=null;let T=q.headers.upgrade;if(T===void 0||T.toLowerCase()!=="websocket"){r($,R,"Invalid Upgrade header");return}let L=B8("sha1").update(I+M8).digest("base64");if(q.headers["sec-websocket-accept"]!==L){r($,R,"Invalid Sec-WebSocket-Accept header");return}let C=q.headers["sec-websocket-protocol"],A;if(C!==void 0){if(!B.size)A="Server sent a subprotocol but none was requested";else if(!B.has(C))A="Server sent an invalid subprotocol"}else if(B.size)A="Server sent no subprotocol";if(A){r($,R,A);return}if(C)$._protocol=C;let F=q.headers["sec-websocket-extensions"];if(F!==void 0){if(!j){r($,R,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let V;try{V=A8(F)}catch(k){r($,R,"Invalid Sec-WebSocket-Extensions header");return}let W=Object.keys(V);if(W.length!==1||W[0]!==L1.extensionName){r($,R,"Server indicated an extension that was not requested");return}try{j.accept(V[L1.extensionName])}catch(k){r($,R,"Invalid Sec-WebSocket-Extensions header");return}$._extensions[L1.extensionName]=j}$.setSocket(R,x,{allowSynchronousEvents:X.allowSynchronousEvents,generateMask:X.generateMask,maxPayload:X.maxPayload,skipUTF8Validation:X.skipUTF8Validation})}),X.finishRequest)X.finishRequest(U,$);else U.end()}function o0($,G){$._readyState=D.CLOSING,$._errorEmitted=!0,$.emit("error",G),$.emitClose()}function O8($){return $.path=$.socketPath,j9.connect($)}function F8($){if($.path=void 0,!$.servername&&$.servername!=="")$.servername=j9.isIP($.host)?"":$.host;return I8.connect($)}function r($,G,J){$._readyState=D.CLOSING;let Z=Error(J);if(Error.captureStackTrace(Z,r),G.setHeader){if(G[M9]=!0,G.abort(),G.socket&&!G.socket.destroyed)G.socket.destroy();process.nextTick(o0,$,Z)}else G.destroy(Z),G.once("error",$.emit.bind($,"error")),G.once("close",$.emitClose.bind($))}function z4($,G,J){if(G){let Z=j8(G)?G.size:D8(G).length;if($._socket)$._sender._bufferedBytes+=Z;else $._bufferedAmount+=Z}if(J){let Z=Error(`WebSocket is not open: readyState ${$.readyState} (${j1[$.readyState]})`);process.nextTick(J,Z)}}function P8($,G){let J=this[d];if(J._closeFrameReceived=!0,J._closeMessage=G,J._closeCode=$,J._socket[d]===void 0)return;if(J._socket.removeListener("data",r0),process.nextTick(T9,J._socket),$===1005)J.close();else J.close($,G)}function E8(){let $=this[d];if(!$.isPaused)$._socket.resume()}function S8($){let G=this[d];if(G._socket[d]!==void 0)G._socket.removeListener("data",r0),process.nextTick(T9,G._socket),G.close($[T8]);if(!G._errorEmitted)G._errorEmitted=!0,G.emit("error",$)}function _9(){this[d].emitClose()}function w8($,G){this[d].emit("message",$,G)}function y8($){let G=this[d];if(G._autoPong)G.pong($,!this._isServer,R9);G.emit("ping",$)}function v8($){this[d].emit("pong",$)}function T9($){$.resume()}function g8($){let G=this[d];if(G.readyState===D.CLOSED)return;if(G.readyState===D.OPEN)G._readyState=D.CLOSING,x9(G);if(this._socket.end(),!G._errorEmitted)G._errorEmitted=!0,G.emit("error",$)}function x9($){$._closeTimer=setTimeout($._socket.destroy.bind($._socket),$._closeTimeout)}function W9(){let $=this[d];if(this.removeListener("close",W9),this.removeListener("data",r0),this.removeListener("end",L9),$._readyState=D.CLOSING,!this._readableState.endEmitted&&!$._closeFrameReceived&&!$._receiver._writableState.errorEmitted&&this._readableState.length!==0){let G=this.read(this._readableState.length);$._receiver.write(G)}if($._receiver.end(),this[d]=void 0,clearTimeout($._closeTimer),$._receiver._writableState.finished||$._receiver._writableState.errorEmitted)$.emitClose();else $._receiver.on("error",_9),$._receiver.on("finish",_9)}function r0($){if(!this[d]._receiver.write($))this.pause()}function L9(){let $=this[d];$._readyState=D.CLOSING,$._receiver.end(),this.end()}function A9(){let $=this[d];if(this.removeListener("error",A9),this.on("error",R9),$)$._readyState=D.CLOSING,this.destroy()}});var P9=f((HJ,F9)=>{var KJ=a0(),{Duplex:f8}=S("stream");function C9($){$.emit("close")}function b8(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function O9($){if(this.removeListener("error",O9),this.destroy(),this.listenerCount("error")===0)this.emit("error",$)}function u8($,G){let J=!0,Z=new f8({...G,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return $.on("message",function(z,N){let Q=!N&&Z._readableState.objectMode?z.toString():z;if(!Z.push(Q))$.pause()}),$.once("error",function(z){if(Z.destroyed)return;J=!1,Z.destroy(z)}),$.once("close",function(){if(Z.destroyed)return;Z.push(null)}),Z._destroy=function(X,z){if($.readyState===$.CLOSED){z(X),process.nextTick(C9,Z);return}let N=!1;if($.once("error",function(Y){N=!0,z(Y)}),$.once("close",function(){if(!N)z(X);process.nextTick(C9,Z)}),J)$.terminate()},Z._final=function(X){if($.readyState===$.CONNECTING){$.once("open",function(){Z._final(X)});return}if($._socket===null)return;if($._socket._writableState.finished){if(X(),Z._readableState.endEmitted)Z.destroy()}else $._socket.once("finish",function(){X()}),$.close()},Z._read=function(){if($.isPaused)$.resume()},Z._write=function(X,z,N){if($.readyState===$.CONNECTING){$.once("open",function(){Z._write(X,z,N)});return}$.send(X,N)},Z.on("end",b8),Z.on("error",O9),Z}F9.exports=u8});var S9=f((IJ,E9)=>{var{tokenChars:k8}=h1();function h8($){let G=new Set,J=-1,Z=-1,X=0;for(X;X<$.length;X++){let N=$.charCodeAt(X);if(Z===-1&&k8[N]===1){if(J===-1)J=X}else if(X!==0&&(N===32||N===9)){if(Z===-1&&J!==-1)Z=X}else if(N===44){if(J===-1)throw SyntaxError(`Unexpected character at index ${X}`);if(Z===-1)Z=X;let Q=$.slice(J,Z);if(G.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);G.add(Q),J=Z=-1}else throw SyntaxError(`Unexpected character at index ${X}`)}if(J===-1||Z!==-1)throw SyntaxError("Unexpected end of input");let z=$.slice(J,X);if(G.has(z))throw SyntaxError(`The "${z}" subprotocol is duplicated`);return G.add(z),G}E9.exports={parse:h8}});var f9=f((BJ,g9)=>{var m8=S("events"),t0=S("http"),{Duplex:qJ}=S("stream"),{createHash:d8}=S("crypto"),w9=G4(),w1=X0(),l8=S9(),c8=a0(),{CLOSE_TIMEOUT:p8,GUID:n8,kWebSocket:i8}=U1(),s8=/^[+/0-9A-Za-z]{22}==$/;class v9 extends m8{constructor($,G){super();if($={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:p8,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:c8,...$},$.port==null&&!$.server&&!$.noServer||$.port!=null&&($.server||$.noServer)||$.server&&$.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if($.port!=null)this._server=t0.createServer((J,Z)=>{let X=t0.STATUS_CODES[426];Z.writeHead(426,{"Content-Length":X.length,"Content-Type":"text/plain"}),Z.end(X)}),this._server.listen($.port,$.host,$.backlog,G);else if($.server)this._server=$.server;if(this._server){let J=this.emit.bind(this,"connection");this._removeListeners=o8(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(Z,X,z)=>{this.handleUpgrade(Z,X,z,J)}})}if($.perMessageDeflate===!0)$.perMessageDeflate={};if($.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=$,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close($){if(this._state===2){if($)this.once("close",()=>{$(Error("The server is not running"))});process.nextTick(Y0,this);return}if($)this.once("close",$);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(Y0,this);else this._shouldEmitClose=!0;else process.nextTick(Y0,this)}else{let G=this._server;this._removeListeners(),this._removeListeners=this._server=null,G.close(()=>{Y0(this)})}}shouldHandle($){if(this.options.path){let G=$.url.indexOf("?");if((G!==-1?$.url.slice(0,G):$.url)!==this.options.path)return!1}return!0}handleUpgrade($,G,J,Z){G.on("error",y9);let X=$.headers["sec-websocket-key"],z=$.headers.upgrade,N=+$.headers["sec-websocket-version"];if($.method!=="GET"){y1(this,$,G,405,"Invalid HTTP method");return}if(z===void 0||z.toLowerCase()!=="websocket"){y1(this,$,G,400,"Invalid Upgrade header");return}if(X===void 0||!s8.test(X)){y1(this,$,G,400,"Missing or invalid Sec-WebSocket-Key header");return}if(N!==13&&N!==8){y1(this,$,G,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle($)){K0(G,400);return}let Q=$.headers["sec-websocket-protocol"],Y=new Set;if(Q!==void 0)try{Y=l8.parse(Q)}catch(H){y1(this,$,G,400,"Invalid Sec-WebSocket-Protocol header");return}let K=$.headers["sec-websocket-extensions"],I={};if(this.options.perMessageDeflate&&K!==void 0){let H=new w1(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let B=w9.parse(K);if(B[w1.extensionName])H.accept(B[w1.extensionName]),I[w1.extensionName]=H}catch(B){y1(this,$,G,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let H={origin:$.headers[`${N===8?"sec-websocket-origin":"origin"}`],secure:!!($.socket.authorized||$.socket.encrypted),req:$};if(this.options.verifyClient.length===2){this.options.verifyClient(H,(B,j,U,q)=>{if(!B)return K0(G,j||401,U,q);this.completeUpgrade(I,X,Y,$,G,J,Z)});return}if(!this.options.verifyClient(H))return K0(G,401)}this.completeUpgrade(I,X,Y,$,G,J,Z)}completeUpgrade($,G,J,Z,X,z,N){if(!X.readable||!X.writable)return X.destroy();if(X[i8])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return K0(X,503);let Y=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${d8("sha1").update(G+n8).digest("base64")}`],K=new this.options.WebSocket(null,void 0,this.options);if(J.size){let I=this.options.handleProtocols?this.options.handleProtocols(J,Z):J.values().next().value;if(I)Y.push(`Sec-WebSocket-Protocol: ${I}`),K._protocol=I}if($[w1.extensionName]){let I=$[w1.extensionName].params,H=w9.format({[w1.extensionName]:[I]});Y.push(`Sec-WebSocket-Extensions: ${H}`),K._extensions=$}if(this.emit("headers",Y,Z),X.write(Y.concat(`\r
|
|
24
24
|
`).join(`\r
|
|
25
25
|
`)),X.removeListener("error",y9),K.setSocket(X,z,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(K),K.on("close",()=>{if(this.clients.delete(K),this._shouldEmitClose&&!this.clients.size)process.nextTick(Y0,this)});N(K,Z)}}g9.exports=v9;function o8($,G){for(let J of Object.keys(G))$.on(J,G[J]);return function(){for(let Z of Object.keys(G))$.removeListener(Z,G[Z])}}function Y0($){$._state=2,$.emit("close")}function y9(){this.destroy()}function K0($,G,J,Z){J=J||t0.STATUS_CODES[G],Z={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(J),...Z},$.once("finish",$.destroy),$.end(`HTTP/1.1 ${G} ${t0.STATUS_CODES[G]}\r
|
|
26
26
|
`+Object.keys(Z).map((X)=>`${X}: ${Z[X]}`).join(`\r
|
|
27
27
|
`)+`\r
|
|
28
28
|
\r
|
|
29
|
-
`+J)}function y1($,G,J,Z,X,z){if($.listenerCount("wsClientError")){let N=Error(X);Error.captureStackTrace(N,y1),$.emit("wsClientError",N,J,G)}else K0(J,Z,X,z)}});var y4=s(w4(),1),{program:
|
|
30
|
-
`),I=K[Symbol.iterator](),H=I.next(),
|
|
31
|
-
`?(z&&(Z+=m4("")),X&&
|
|
32
|
-
`&&(X&&
|
|
29
|
+
`+J)}function y1($,G,J,Z,X,z){if($.listenerCount("wsClientError")){let N=Error(X);Error.captureStackTrace(N,y1),$.emit("wsClientError",N,J,G)}else K0(J,Z,X,z)}});var y4=s(w4(),1),{program:QG,createCommand:NG,createArgument:YG,createOption:KG,CommanderError:HG,InvalidArgumentError:IG,InvalidOptionArgumentError:qG,Command:v4,Argument:BG,Option:UG,Help:_G}=y4.default;var s1=s(f1(),1),l=s(q2(),1);import{stdout as M2,stdin as d4}from"node:process";import*as M1 from"node:readline";import c$ from"node:readline";import{ReadStream as u4}from"node:tty";var p$=($)=>$===161||$===164||$===167||$===168||$===170||$===173||$===174||$>=176&&$<=180||$>=182&&$<=186||$>=188&&$<=191||$===198||$===208||$===215||$===216||$>=222&&$<=225||$===230||$>=232&&$<=234||$===236||$===237||$===240||$===242||$===243||$>=247&&$<=250||$===252||$===254||$===257||$===273||$===275||$===283||$===294||$===295||$===299||$>=305&&$<=307||$===312||$>=319&&$<=322||$===324||$>=328&&$<=331||$===333||$===338||$===339||$===358||$===359||$===363||$===462||$===464||$===466||$===468||$===470||$===472||$===474||$===476||$===593||$===609||$===708||$===711||$>=713&&$<=715||$===717||$===720||$>=728&&$<=731||$===733||$===735||$>=768&&$<=879||$>=913&&$<=929||$>=931&&$<=937||$>=945&&$<=961||$>=963&&$<=969||$===1025||$>=1040&&$<=1103||$===1105||$===8208||$>=8211&&$<=8214||$===8216||$===8217||$===8220||$===8221||$>=8224&&$<=8226||$>=8228&&$<=8231||$===8240||$===8242||$===8243||$===8245||$===8251||$===8254||$===8308||$===8319||$>=8321&&$<=8324||$===8364||$===8451||$===8453||$===8457||$===8467||$===8470||$===8481||$===8482||$===8486||$===8491||$===8531||$===8532||$>=8539&&$<=8542||$>=8544&&$<=8555||$>=8560&&$<=8569||$===8585||$>=8592&&$<=8601||$===8632||$===8633||$===8658||$===8660||$===8679||$===8704||$===8706||$===8707||$===8711||$===8712||$===8715||$===8719||$===8721||$===8725||$===8730||$>=8733&&$<=8736||$===8739||$===8741||$>=8743&&$<=8748||$===8750||$>=8756&&$<=8759||$===8764||$===8765||$===8776||$===8780||$===8786||$===8800||$===8801||$>=8804&&$<=8807||$===8810||$===8811||$===8814||$===8815||$===8834||$===8835||$===8838||$===8839||$===8853||$===8857||$===8869||$===8895||$===8978||$>=9312&&$<=9449||$>=9451&&$<=9547||$>=9552&&$<=9587||$>=9600&&$<=9615||$>=9618&&$<=9621||$===9632||$===9633||$>=9635&&$<=9641||$===9650||$===9651||$===9654||$===9655||$===9660||$===9661||$===9664||$===9665||$>=9670&&$<=9672||$===9675||$>=9678&&$<=9681||$>=9698&&$<=9701||$===9711||$===9733||$===9734||$===9737||$===9742||$===9743||$===9756||$===9758||$===9792||$===9794||$===9824||$===9825||$>=9827&&$<=9829||$>=9831&&$<=9834||$===9836||$===9837||$===9839||$===9886||$===9887||$===9919||$>=9926&&$<=9933||$>=9935&&$<=9939||$>=9941&&$<=9953||$===9955||$===9960||$===9961||$>=9963&&$<=9969||$===9972||$>=9974&&$<=9977||$===9979||$===9980||$===9982||$===9983||$===10045||$>=10102&&$<=10111||$>=11094&&$<=11097||$>=12872&&$<=12879||$>=57344&&$<=63743||$>=65024&&$<=65039||$===65533||$>=127232&&$<=127242||$>=127248&&$<=127277||$>=127280&&$<=127337||$>=127344&&$<=127373||$===127375||$===127376||$>=127387&&$<=127404||$>=917760&&$<=917999||$>=983040&&$<=1048573||$>=1048576&&$<=1114109,n$=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,i$=($)=>$>=4352&&$<=4447||$===8986||$===8987||$===9001||$===9002||$>=9193&&$<=9196||$===9200||$===9203||$===9725||$===9726||$===9748||$===9749||$>=9800&&$<=9811||$===9855||$===9875||$===9889||$===9898||$===9899||$===9917||$===9918||$===9924||$===9925||$===9934||$===9940||$===9962||$===9970||$===9971||$===9973||$===9978||$===9981||$===9989||$===9994||$===9995||$===10024||$===10060||$===10062||$>=10067&&$<=10069||$===10071||$>=10133&&$<=10135||$===10160||$===10175||$===11035||$===11036||$===11088||$===11093||$>=11904&&$<=11929||$>=11931&&$<=12019||$>=12032&&$<=12245||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12353&&$<=12438||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=19968&&$<=42124||$>=42128&&$<=42182||$>=43360&&$<=43388||$>=44032&&$<=55203||$>=63744&&$<=64255||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=94176&&$<=94180||$===94192||$===94193||$>=94208&&$<=100343||$>=100352&&$<=101589||$>=101632&&$<=101640||$>=110576&&$<=110579||$>=110581&&$<=110587||$===110589||$===110590||$>=110592&&$<=110882||$===110898||$>=110928&&$<=110930||$===110933||$>=110948&&$<=110951||$>=110960&&$<=111355||$===126980||$===127183||$===127374||$>=127377&&$<=127386||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$===127568||$===127569||$>=127584&&$<=127589||$>=127744&&$<=127776||$>=127789&&$<=127797||$>=127799&&$<=127868||$>=127870&&$<=127891||$>=127904&&$<=127946||$>=127951&&$<=127955||$>=127968&&$<=127984||$===127988||$>=127992&&$<=128062||$===128064||$>=128066&&$<=128252||$>=128255&&$<=128317||$>=128331&&$<=128334||$>=128336&&$<=128359||$===128378||$===128405||$===128406||$===128420||$>=128507&&$<=128591||$>=128640&&$<=128709||$===128716||$>=128720&&$<=128722||$>=128725&&$<=128727||$>=128732&&$<=128735||$===128747||$===128748||$>=128756&&$<=128764||$>=128992&&$<=129003||$===129008||$>=129292&&$<=129338||$>=129340&&$<=129349||$>=129351&&$<=129535||$>=129648&&$<=129660||$>=129664&&$<=129672||$>=129680&&$<=129725||$>=129727&&$<=129733||$>=129742&&$<=129755||$>=129760&&$<=129768||$>=129776&&$<=129784||$>=131072&&$<=196605||$>=196608&&$<=262141,B2=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,M0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,V0=/\t{1,1000}/y,U2=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,T0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,s$=/\p{M}+/gu,o$={limit:1/0,ellipsis:""},l4=($,G={},J={})=>{let Z=G.limit??1/0,X=G.ellipsis??"",z=G?.ellipsisWidth??(X?l4(X,o$,J).width:0),N=J.ansiWidth??0,Q=J.controlWidth??0,Y=J.tabWidth??8,K=J.ambiguousWidth??1,I=J.emojiWidth??2,H=J.fullWidthWidth??2,B=J.regularWidth??1,j=J.wideWidth??2,U=0,q=0,R=$.length,x=0,T=!1,L=R,C=Math.max(0,Z-z),A=0,F=0,V=0,W=0;$:for(;;){if(F>A||q>=R&&q>U){let k=$.slice(A,F)||$.slice(U,q);x=0;for(let p of k.replaceAll(s$,"")){let i=p.codePointAt(0)||0;if(n$(i)?W=H:i$(i)?W=j:K!==B&&p$(i)?W=K:W=B,V+W>C&&(L=Math.min(L,Math.max(A,U)+x)),V+W>Z){T=!0;break $}x+=p.length,V+=W}A=F=0}if(q>=R)break;if(T0.lastIndex=q,T0.test($)){if(x=T0.lastIndex-q,W=x*B,V+W>C&&(L=Math.min(L,q+Math.floor((C-V)/B))),V+W>Z){T=!0;break}V+=W,A=U,F=q,q=U=T0.lastIndex;continue}if(B2.lastIndex=q,B2.test($)){if(V+N>C&&(L=Math.min(L,q)),V+N>Z){T=!0;break}V+=N,A=U,F=q,q=U=B2.lastIndex;continue}if(M0.lastIndex=q,M0.test($)){if(x=M0.lastIndex-q,W=x*Q,V+W>C&&(L=Math.min(L,q+Math.floor((C-V)/Q))),V+W>Z){T=!0;break}V+=W,A=U,F=q,q=U=M0.lastIndex;continue}if(V0.lastIndex=q,V0.test($)){if(x=V0.lastIndex-q,W=x*Y,V+W>C&&(L=Math.min(L,q+Math.floor((C-V)/Y))),V+W>Z){T=!0;break}V+=W,A=U,F=q,q=U=V0.lastIndex;continue}if(U2.lastIndex=q,U2.test($)){if(V+I>C&&(L=Math.min(L,q)),V+I>Z){T=!0;break}V+=I,A=U,F=q,q=U=U2.lastIndex;continue}q+=1}return{width:T?C:V,index:T?L:R,truncated:T,ellipsed:T&&Z>=z}},r$={limit:1/0,ellipsis:"",ellipsisWidth:0},o1=($,G={})=>l4($,r$,G).width,W0="\x1B",c4="",a$=39,V2="\x07",p4="[",t$="]",n4="m",T2=`${t$}8;;`,k4=new RegExp(`(?:\\${p4}(?<code>\\d+)m|\\${T2}(?<uri>.*)${V2})`,"y"),e$=($)=>{if($>=30&&$<=37||$>=90&&$<=97)return 39;if($>=40&&$<=47||$>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0},h4=($)=>`${W0}${p4}${$}${n4}`,m4=($)=>`${W0}${T2}${$}${V2}`,$5=($)=>$.map((G)=>o1(G)),_2=($,G,J)=>{let Z=G[Symbol.iterator](),X=!1,z=!1,N=$.at(-1),Q=N===void 0?0:o1(N),Y=Z.next(),K=Z.next(),I=0;for(;!Y.done;){let H=Y.value,B=o1(H);Q+B<=J?$[$.length-1]+=H:($.push(H),Q=0),(H===W0||H===c4)&&(X=!0,z=G.startsWith(T2,I+1)),X?z?H===V2&&(X=!1,z=!1):H===n4&&(X=!1):(Q+=B,Q===J&&!K.done&&($.push(""),Q=0)),Y=K,K=Z.next(),I+=H.length}N=$.at(-1),!Q&&N!==void 0&&N.length>0&&$.length>1&&($[$.length-2]+=$.pop())},G5=($)=>{let G=$.split(" "),J=G.length;for(;J>0&&!(o1(G[J-1])>0);)J--;return J===G.length?$:G.slice(0,J).join(" ")+G.slice(J).join("")},J5=($,G,J={})=>{if(J.trim!==!1&&$.trim()==="")return"";let Z="",X,z,N=$.split(" "),Q=$5(N),Y=[""];for(let[U,q]of N.entries()){J.trim!==!1&&(Y[Y.length-1]=(Y.at(-1)??"").trimStart());let R=o1(Y.at(-1)??"");if(U!==0&&(R>=G&&(J.wordWrap===!1||J.trim===!1)&&(Y.push(""),R=0),(R>0||J.trim===!1)&&(Y[Y.length-1]+=" ",R++)),J.hard&&Q[U]>G){let x=G-R,T=1+Math.floor((Q[U]-x-1)/G);Math.floor((Q[U]-1)/G)<T&&Y.push(""),_2(Y,q,G);continue}if(R+Q[U]>G&&R>0&&Q[U]>0){if(J.wordWrap===!1&&R<G){_2(Y,q,G);continue}Y.push("")}if(R+Q[U]>G&&J.wordWrap===!1){_2(Y,q,G);continue}Y[Y.length-1]+=q}J.trim!==!1&&(Y=Y.map((U)=>G5(U)));let K=Y.join(`
|
|
30
|
+
`),I=K[Symbol.iterator](),H=I.next(),B=I.next(),j=0;for(;!H.done;){let U=H.value,q=B.value;if(Z+=U,U===W0||U===c4){k4.lastIndex=j+1;let x=k4.exec(K)?.groups;if(x?.code!==void 0){let T=Number.parseFloat(x.code);X=T===a$?void 0:T}else x?.uri!==void 0&&(z=x.uri.length===0?void 0:x.uri)}let R=X?e$(X):void 0;q===`
|
|
31
|
+
`?(z&&(Z+=m4("")),X&&R&&(Z+=h4(R))):U===`
|
|
32
|
+
`&&(X&&R&&(Z+=h4(X)),z&&(Z+=m4(z))),j+=U.length,H=B,B=I.next()}return Z};function j2($,G,J){return String($).normalize().replaceAll(`\r
|
|
33
33
|
`,`
|
|
34
34
|
`).split(`
|
|
35
35
|
`).map((Z)=>J5(Z,G,J)).join(`
|
|
36
36
|
`)}var Z5=["up","down","left","right","space","enter","cancel"],J1={actions:new Set(Z5),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};function x2($,G){if(typeof $=="string")return J1.aliases.get($)===G;for(let J of $)if(J!==void 0&&x2(J,G))return!0;return!1}function X5($,G){if($===G)return;let J=$.split(`
|
|
37
37
|
`),Z=G.split(`
|
|
38
|
-
`),X=Math.max(J.length,Z.length),z=[];for(let N=0;N<X;N++)J[N]!==Z[N]&&z.push(N);return{lines:z,numLinesBefore:J.length,numLinesAfter:Z.length,numLines:X}}var z5=globalThis.process.platform.startsWith("win"),R2=Symbol("clack:cancel");function t($){return $===R2}function x0($,G){let J=$;J.isTTY&&J.setRawMode(G)}function
|
|
38
|
+
`),X=Math.max(J.length,Z.length),z=[];for(let N=0;N<X;N++)J[N]!==Z[N]&&z.push(N);return{lines:z,numLinesBefore:J.length,numLinesAfter:Z.length,numLines:X}}var z5=globalThis.process.platform.startsWith("win"),R2=Symbol("clack:cancel");function t($){return $===R2}function x0($,G){let J=$;J.isTTY&&J.setRawMode(G)}function i4({input:$=d4,output:G=M2,overwrite:J=!0,hideCursor:Z=!0}={}){let X=M1.createInterface({input:$,output:G,prompt:"",tabSize:1});M1.emitKeypressEvents($,X),$ instanceof u4&&$.isTTY&&$.setRawMode(!0);let z=(N,{name:Q,sequence:Y})=>{let K=String(N);if(x2([K,Q,Y],"cancel")){Z&&G.write(l.cursor.show),process.exit(0);return}if(!J)return;M1.moveCursor(G,Q==="return"?0:-1,Q==="return"?-1:0,()=>{M1.clearLine(G,1,()=>{$.once("keypress",z)})})};return Z&&G.write(l.cursor.hide),$.once("keypress",z),()=>{$.off("keypress",z),Z&&G.write(l.cursor.show),$ instanceof u4&&$.isTTY&&!z5&&$.setRawMode(!1),X.terminal=!1,X.close()}}var r1=($)=>("columns"in $)&&typeof $.columns=="number"?$.columns:80,W2=($)=>("rows"in $)&&typeof $.rows=="number"?$.rows:20;function C1($,G,J,Z=J){let X=r1($??M2);return j2(G,X-J.length,{hard:!0,trim:!1}).split(`
|
|
39
39
|
`).map((z,N)=>`${N===0?Z:J}${z}`).join(`
|
|
40
|
-
`)}class O1{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor($,G=!0){let{input:J=
|
|
40
|
+
`)}class O1{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor($,G=!0){let{input:J=d4,output:Z=M2,render:X,signal:z,...N}=$;this.opts=N,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=X.bind(this),this._track=G,this._abortSignal=z,this.input=J,this.output=Z}unsubscribe(){this._subscribers.clear()}setSubscriber($,G){let J=this._subscribers.get($)??[];J.push(G),this._subscribers.set($,J)}on($,G){this.setSubscriber($,{cb:G})}once($,G){this.setSubscriber($,{cb:G,once:!0})}emit($,...G){let J=this._subscribers.get($)??[],Z=[];for(let X of J)X.cb(...G),X.once&&Z.push(()=>J.splice(J.indexOf(X),1));for(let X of Z)X()}prompt(){return new Promise(($)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),$(R2);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=c$.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),x0(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(l.cursor.show),this.output.off("resize",this.render),x0(this.input,!1),$(this.value)}),this.once("cancel",()=>{this.output.write(l.cursor.show),this.output.off("resize",this.render),x0(this.input,!1),$(R2)})})}_isActionKey($,G){return $==="\t"}_setValue($){this.value=$,this.emit("value",this.value)}_setUserInput($,G){this.userInput=$??"",this.emit("userInput",this.userInput),G&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress($,G){if(this._track&&G.name!=="return"&&(G.name&&this._isActionKey($,G)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),G?.name&&(!this._track&&J1.aliases.has(G.name)&&this.emit("cursor",J1.aliases.get(G.name)),J1.actions.has(G.name)&&this.emit("cursor",G.name)),$&&($.toLowerCase()==="y"||$.toLowerCase()==="n")&&this.emit("confirm",$.toLowerCase()==="y"),this.emit("key",$?.toLowerCase(),G),G?.name==="return"){if(this.opts.validate){let J=this.opts.validate(this.value);J&&(this.error=J instanceof Error?J.message:J,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}x2([$,G?.name,G?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
41
41
|
`),x0(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let $=j2(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
42
|
-
`).length-1;this.output.write(
|
|
43
|
-
`);this.output.write(N[z]),this._prevFrame=$,this.output.write(
|
|
42
|
+
`).length-1;this.output.write(l.cursor.move(-999,$*-1))}render(){let $=j2(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if($!==this._prevFrame){if(this.state==="initial")this.output.write(l.cursor.hide);else{let G=X5(this._prevFrame,$),J=W2(this.output);if(this.restoreCursor(),G){let Z=Math.max(0,G.numLinesAfter-J),X=Math.max(0,G.numLinesBefore-J),z=G.lines.find((N)=>N>=Z);if(z===void 0){this._prevFrame=$;return}if(G.lines.length===1){this.output.write(l.cursor.move(0,z-X)),this.output.write(l.erase.lines(1));let N=$.split(`
|
|
43
|
+
`);this.output.write(N[z]),this._prevFrame=$,this.output.write(l.cursor.move(0,N.length-z-1));return}else if(G.lines.length>1){if(Z<X)z=Z;else{let Q=z-X;Q>0&&this.output.write(l.cursor.move(0,Q))}this.output.write(l.erase.down());let N=$.split(`
|
|
44
44
|
`).slice(z);this.output.write(N.join(`
|
|
45
|
-
`)),this._prevFrame=$;return}}this.output.write(d.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}function Q5($,G){if($===void 0||G.length===0)return 0;let J=G.findIndex((Z)=>Z.value===$);return J!==-1?J:0}function N5($,G){return(G.label??String(G.value)).toLowerCase().includes($.toLowerCase())}function Y5($,G){if(G)return $?G:G[0]}class s4 extends O1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#J="";#Z;#G;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return s1.default.inverse(s1.default.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let $=this.userInput.slice(0,this._cursor),[G,...J]=this.userInput.slice(this._cursor);return`${$}${s1.default.inverse(G)}${J.join("")}`}get options(){return typeof this.#G=="function"?this.#G():this.#G}constructor($){super($),this.#G=$.options;let G=this.options;this.filteredOptions=[...G],this.multiple=$.multiple===!0,this.#Z=$.filter??N5;let J;if($.initialValue&&Array.isArray($.initialValue)?this.multiple?J=$.initialValue:J=$.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(J=[this.options[0].value]),J)for(let Z of J){let X=G.findIndex((z)=>z.value===Z);X!==-1&&(this.toggleSelected(Z),this.#$=X)}this.focusedValue=this.options[this.#$]?.value,this.on("key",(Z,X)=>this.#X(Z,X)),this.on("userInput",(Z)=>this.#z(Z))}_isActionKey($,G){return $==="\t"||this.multiple&&this.isNavigating&&G.name==="space"&&$!==void 0&&$!==""}#X($,G){let J=G.name==="up",Z=G.name==="down",X=G.name==="return";J||Z?(this.#$=Math.max(0,Math.min(this.#$+(J?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):X?this.value=Y5(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(G.name==="tab"||this.isNavigating&&G.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected($){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes($)?this.selectedValues=this.selectedValues.filter((G)=>G!==$):this.selectedValues=[...this.selectedValues,$]:this.selectedValues=[$])}#z($){if($!==this.#J){this.#J=$;let G=this.options;$?this.filteredOptions=G.filter((J)=>this.#Z($,J)):this.filteredOptions=[...G],this.#$=Q5(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}}class L2 extends O1{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor($){super($,!1),this.value=!!$.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(G)=>{this.output.write(d.cursor.move(0,-1)),this.value=G,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class o4 extends O1{options;cursor=0;#$;getGroupItems($){return this.options.filter((G)=>G.group===$)}isGroupSelected($){let G=this.getGroupItems($),J=this.value;return J===void 0?!1:G.every((Z)=>J.includes(Z.value))}toggleValue(){let $=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),$.group===!0){let G=$.value,J=this.getGroupItems(G);this.isGroupSelected(G)?this.value=this.value.filter((Z)=>J.findIndex((X)=>X.value===Z)===-1):this.value=[...this.value,...J.map((Z)=>Z.value)],this.value=Array.from(new Set(this.value))}else{let G=this.value.includes($.value);this.value=G?this.value.filter((J)=>J!==$.value):[...this.value,$.value]}}constructor($){super($,!1);let{options:G}=$;this.#$=$.selectableGroups!==!1,this.options=Object.entries(G).flatMap(([J,Z])=>[{value:J,group:!0,label:J},...Z.map((X)=>({...X,group:J}))]),this.value=[...$.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:J})=>J===$.cursorAt),this.#$?0:1),this.on("cursor",(J)=>{switch(J){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Z=this.options[this.cursor]?.group===!0;!this.#$&&Z&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Z=this.options[this.cursor]?.group===!0;!this.#$&&Z&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}}function D1($,G,J){let Z=$+G,X=Math.max(J.length-1,0),z=Z<0?X:Z>X?0:Z;return J[z].disabled?D1(z,G<0?-1:1,J):z}class A2 extends O1{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(($)=>$.disabled!==!0)}toggleAll(){let $=this._enabledOptions,G=this.value!==void 0&&this.value.length===$.length;this.value=G?[]:$.map((J)=>J.value)}toggleInvert(){let $=this.value;if(!$)return;let G=this._enabledOptions.filter((J)=>!$.includes(J.value));this.value=G.map((J)=>J.value)}toggleValue(){this.value===void 0&&(this.value=[]);let $=this.value.includes(this._value);this.value=$?this.value.filter((G)=>G!==this._value):[...this.value,this._value]}constructor($){super($,!1),this.options=$.options,this.value=[...$.initialValues??[]];let G=Math.max(this.options.findIndex(({value:J})=>J===$.cursorAt),0);this.cursor=this.options[G].disabled?D1(G,1,this.options):G,this.on("key",(J)=>{J==="a"&&this.toggleAll(),J==="i"&&this.toggleInvert()}),this.on("cursor",(J)=>{switch(J){case"left":case"up":this.cursor=D1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=D1(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}}class D2 extends O1{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor($){super($,!1),this.options=$.options;let G=this.options.findIndex(({value:Z})=>Z===$.initialValue),J=G===-1?0:G;this.cursor=this.options[J].disabled?D1(J,1,this.options):J,this.changeValue(),this.on("cursor",(Z)=>{switch(Z){case"left":case"up":this.cursor=D1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=D1(this.cursor,1,this.options);break}this.changeValue()})}}class C2 extends O1{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${this.userInput}█`;let G=$.slice(0,this.cursor),[J,...Z]=$.slice(this.cursor);return`${G}${s1.default.inverse(J)}${Z.join("")}`}get cursor(){return this._cursor}constructor($){super({...$,initialUserInput:$.initialUserInput??$.initialValue}),this.on("userInput",(G)=>{this._setValue(G)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}}var j=s(f1(),1);import e from"node:process";var t1=s(q2(),1);function K5(){return e.platform!=="win32"?e.env.TERM!=="linux":!!e.env.CI||!!e.env.WT_SESSION||!!e.env.TERMINUS_SUBLIME||e.env.ConEmuTask==="{cmd::Cmder}"||e.env.TERM_PROGRAM==="Terminus-Sublime"||e.env.TERM_PROGRAM==="vscode"||e.env.TERM==="xterm-256color"||e.env.TERM==="alacritty"||e.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var E2=K5(),H5=()=>process.env.CI==="true";var E=($,G)=>E2?$:G,I5=E("◆","*"),J3=E("■","x"),Z3=E("▲","x"),F0=E("◇","o"),q5=E("┌","T"),P=E("│","|"),M1=E("└","—"),PG=E("┐","T"),EG=E("┘","—"),S2=E("●",">"),O0=E("○"," "),B5=E("◻","[•]"),r4=E("◼","[+]"),a4=E("◻","[ ]"),SG=E("▪","•"),t4=E("─","-"),U5=E("╮","+"),_5=E("├","+"),j5=E("╯","+"),R5=E("╰","+"),wG=E("╭","+"),V5=E("●","•"),M5=E("◆","*"),T5=E("▲","!"),x5=E("■","x"),P0=($)=>{switch($){case"initial":case"active":return j.default.cyan(I5);case"cancel":return j.default.red(J3);case"error":return j.default.yellow(Z3);case"submit":return j.default.green(F0)}},X3=($)=>{switch($){case"initial":case"active":return j.default.cyan(P);case"cancel":return j.default.red(P);case"error":return j.default.yellow(P);case"submit":return j.default.green(P)}},W5=($)=>$===161||$===164||$===167||$===168||$===170||$===173||$===174||$>=176&&$<=180||$>=182&&$<=186||$>=188&&$<=191||$===198||$===208||$===215||$===216||$>=222&&$<=225||$===230||$>=232&&$<=234||$===236||$===237||$===240||$===242||$===243||$>=247&&$<=250||$===252||$===254||$===257||$===273||$===275||$===283||$===294||$===295||$===299||$>=305&&$<=307||$===312||$>=319&&$<=322||$===324||$>=328&&$<=331||$===333||$===338||$===339||$===358||$===359||$===363||$===462||$===464||$===466||$===468||$===470||$===472||$===474||$===476||$===593||$===609||$===708||$===711||$>=713&&$<=715||$===717||$===720||$>=728&&$<=731||$===733||$===735||$>=768&&$<=879||$>=913&&$<=929||$>=931&&$<=937||$>=945&&$<=961||$>=963&&$<=969||$===1025||$>=1040&&$<=1103||$===1105||$===8208||$>=8211&&$<=8214||$===8216||$===8217||$===8220||$===8221||$>=8224&&$<=8226||$>=8228&&$<=8231||$===8240||$===8242||$===8243||$===8245||$===8251||$===8254||$===8308||$===8319||$>=8321&&$<=8324||$===8364||$===8451||$===8453||$===8457||$===8467||$===8470||$===8481||$===8482||$===8486||$===8491||$===8531||$===8532||$>=8539&&$<=8542||$>=8544&&$<=8555||$>=8560&&$<=8569||$===8585||$>=8592&&$<=8601||$===8632||$===8633||$===8658||$===8660||$===8679||$===8704||$===8706||$===8707||$===8711||$===8712||$===8715||$===8719||$===8721||$===8725||$===8730||$>=8733&&$<=8736||$===8739||$===8741||$>=8743&&$<=8748||$===8750||$>=8756&&$<=8759||$===8764||$===8765||$===8776||$===8780||$===8786||$===8800||$===8801||$>=8804&&$<=8807||$===8810||$===8811||$===8814||$===8815||$===8834||$===8835||$===8838||$===8839||$===8853||$===8857||$===8869||$===8895||$===8978||$>=9312&&$<=9449||$>=9451&&$<=9547||$>=9552&&$<=9587||$>=9600&&$<=9615||$>=9618&&$<=9621||$===9632||$===9633||$>=9635&&$<=9641||$===9650||$===9651||$===9654||$===9655||$===9660||$===9661||$===9664||$===9665||$>=9670&&$<=9672||$===9675||$>=9678&&$<=9681||$>=9698&&$<=9701||$===9711||$===9733||$===9734||$===9737||$===9742||$===9743||$===9756||$===9758||$===9792||$===9794||$===9824||$===9825||$>=9827&&$<=9829||$>=9831&&$<=9834||$===9836||$===9837||$===9839||$===9886||$===9887||$===9919||$>=9926&&$<=9933||$>=9935&&$<=9939||$>=9941&&$<=9953||$===9955||$===9960||$===9961||$>=9963&&$<=9969||$===9972||$>=9974&&$<=9977||$===9979||$===9980||$===9982||$===9983||$===10045||$>=10102&&$<=10111||$>=11094&&$<=11097||$>=12872&&$<=12879||$>=57344&&$<=63743||$>=65024&&$<=65039||$===65533||$>=127232&&$<=127242||$>=127248&&$<=127277||$>=127280&&$<=127337||$>=127344&&$<=127373||$===127375||$===127376||$>=127387&&$<=127404||$>=917760&&$<=917999||$>=983040&&$<=1048573||$>=1048576&&$<=1114109,L5=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,A5=($)=>$>=4352&&$<=4447||$===8986||$===8987||$===9001||$===9002||$>=9193&&$<=9196||$===9200||$===9203||$===9725||$===9726||$===9748||$===9749||$>=9800&&$<=9811||$===9855||$===9875||$===9889||$===9898||$===9899||$===9917||$===9918||$===9924||$===9925||$===9934||$===9940||$===9962||$===9970||$===9971||$===9973||$===9978||$===9981||$===9989||$===9994||$===9995||$===10024||$===10060||$===10062||$>=10067&&$<=10069||$===10071||$>=10133&&$<=10135||$===10160||$===10175||$===11035||$===11036||$===11088||$===11093||$>=11904&&$<=11929||$>=11931&&$<=12019||$>=12032&&$<=12245||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12353&&$<=12438||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=19968&&$<=42124||$>=42128&&$<=42182||$>=43360&&$<=43388||$>=44032&&$<=55203||$>=63744&&$<=64255||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=94176&&$<=94180||$===94192||$===94193||$>=94208&&$<=100343||$>=100352&&$<=101589||$>=101632&&$<=101640||$>=110576&&$<=110579||$>=110581&&$<=110587||$===110589||$===110590||$>=110592&&$<=110882||$===110898||$>=110928&&$<=110930||$===110933||$>=110948&&$<=110951||$>=110960&&$<=111355||$===126980||$===127183||$===127374||$>=127377&&$<=127386||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$===127568||$===127569||$>=127584&&$<=127589||$>=127744&&$<=127776||$>=127789&&$<=127797||$>=127799&&$<=127868||$>=127870&&$<=127891||$>=127904&&$<=127946||$>=127951&&$<=127955||$>=127968&&$<=127984||$===127988||$>=127992&&$<=128062||$===128064||$>=128066&&$<=128252||$>=128255&&$<=128317||$>=128331&&$<=128334||$>=128336&&$<=128359||$===128378||$===128405||$===128406||$===128420||$>=128507&&$<=128591||$>=128640&&$<=128709||$===128716||$>=128720&&$<=128722||$>=128725&&$<=128727||$>=128732&&$<=128735||$===128747||$===128748||$>=128756&&$<=128764||$>=128992&&$<=129003||$===129008||$>=129292&&$<=129338||$>=129340&&$<=129349||$>=129351&&$<=129535||$>=129648&&$<=129660||$>=129664&&$<=129672||$>=129680&&$<=129725||$>=129727&&$<=129733||$>=129742&&$<=129755||$>=129760&&$<=129768||$>=129776&&$<=129784||$>=131072&&$<=196605||$>=196608&&$<=262141,O2=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,L0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,A0=/\t{1,1000}/y,F2=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,D0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,D5=/\p{M}+/gu,C5={limit:1/0,ellipsis:""},z3=($,G={},J={})=>{let Z=G.limit??1/0,X=G.ellipsis??"",z=G?.ellipsisWidth??(X?z3(X,C5,J).width:0),N=J.ansiWidth??0,Q=J.controlWidth??0,Y=J.tabWidth??8,K=J.ambiguousWidth??1,I=J.emojiWidth??2,H=J.fullWidthWidth??2,U=J.regularWidth??1,_=J.wideWidth??2,q=0,B=0,M=$.length,V=0,x=!1,L=M,D=Math.max(0,Z-z),A=0,F=0,T=0,W=0;$:for(;;){if(F>A||B>=M&&B>q){let b=$.slice(A,F)||$.slice(q,B);V=0;for(let p of b.replaceAll(D5,"")){let n=p.codePointAt(0)||0;if(L5(n)?W=H:A5(n)?W=_:K!==U&&W5(n)?W=K:W=U,T+W>D&&(L=Math.min(L,Math.max(A,q)+V)),T+W>Z){x=!0;break $}V+=p.length,T+=W}A=F=0}if(B>=M)break;if(D0.lastIndex=B,D0.test($)){if(V=D0.lastIndex-B,W=V*U,T+W>D&&(L=Math.min(L,B+Math.floor((D-T)/U))),T+W>Z){x=!0;break}T+=W,A=q,F=B,B=q=D0.lastIndex;continue}if(O2.lastIndex=B,O2.test($)){if(T+N>D&&(L=Math.min(L,B)),T+N>Z){x=!0;break}T+=N,A=q,F=B,B=q=O2.lastIndex;continue}if(L0.lastIndex=B,L0.test($)){if(V=L0.lastIndex-B,W=V*Q,T+W>D&&(L=Math.min(L,B+Math.floor((D-T)/Q))),T+W>Z){x=!0;break}T+=W,A=q,F=B,B=q=L0.lastIndex;continue}if(A0.lastIndex=B,A0.test($)){if(V=A0.lastIndex-B,W=V*Y,T+W>D&&(L=Math.min(L,B+Math.floor((D-T)/Y))),T+W>Z){x=!0;break}T+=W,A=q,F=B,B=q=A0.lastIndex;continue}if(F2.lastIndex=B,F2.test($)){if(T+I>D&&(L=Math.min(L,B)),T+I>Z){x=!0;break}T+=I,A=q,F=B,B=q=F2.lastIndex;continue}B+=1}return{width:x?D:T,index:x?L:M,truncated:x,ellipsed:x&&Z>=z}},O5={limit:1/0,ellipsis:"",ellipsisWidth:0},Y1=($,G={})=>z3($,O5,G).width,E0="\x1B",Q3="",F5=39,y2="\x07",N3="[",P5="]",Y3="m",v2=`${P5}8;;`,e4=new RegExp(`(?:\\${N3}(?<code>\\d+)m|\\${v2}(?<uri>.*)${y2})`,"y"),E5=($)=>{if($>=30&&$<=37||$>=90&&$<=97)return 39;if($>=40&&$<=47||$>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0},$3=($)=>`${E0}${N3}${$}${Y3}`,G3=($)=>`${E0}${v2}${$}${y2}`,S5=($)=>$.map((G)=>Y1(G)),P2=($,G,J)=>{let Z=G[Symbol.iterator](),X=!1,z=!1,N=$.at(-1),Q=N===void 0?0:Y1(N),Y=Z.next(),K=Z.next(),I=0;for(;!Y.done;){let H=Y.value,U=Y1(H);Q+U<=J?$[$.length-1]+=H:($.push(H),Q=0),(H===E0||H===Q3)&&(X=!0,z=G.startsWith(v2,I+1)),X?z?H===y2&&(X=!1,z=!1):H===Y3&&(X=!1):(Q+=U,Q===J&&!K.done&&($.push(""),Q=0)),Y=K,K=Z.next(),I+=H.length}N=$.at(-1),!Q&&N!==void 0&&N.length>0&&$.length>1&&($[$.length-2]+=$.pop())},w5=($)=>{let G=$.split(" "),J=G.length;for(;J>0&&!(Y1(G[J-1])>0);)J--;return J===G.length?$:G.slice(0,J).join(" ")+G.slice(J).join("")},y5=($,G,J={})=>{if(J.trim!==!1&&$.trim()==="")return"";let Z="",X,z,N=$.split(" "),Q=S5(N),Y=[""];for(let[q,B]of N.entries()){J.trim!==!1&&(Y[Y.length-1]=(Y.at(-1)??"").trimStart());let M=Y1(Y.at(-1)??"");if(q!==0&&(M>=G&&(J.wordWrap===!1||J.trim===!1)&&(Y.push(""),M=0),(M>0||J.trim===!1)&&(Y[Y.length-1]+=" ",M++)),J.hard&&Q[q]>G){let V=G-M,x=1+Math.floor((Q[q]-V-1)/G);Math.floor((Q[q]-1)/G)<x&&Y.push(""),P2(Y,B,G);continue}if(M+Q[q]>G&&M>0&&Q[q]>0){if(J.wordWrap===!1&&M<G){P2(Y,B,G);continue}Y.push("")}if(M+Q[q]>G&&J.wordWrap===!1){P2(Y,B,G);continue}Y[Y.length-1]+=B}J.trim!==!1&&(Y=Y.map((q)=>w5(q)));let K=Y.join(`
|
|
46
|
-
`),I=K[Symbol.iterator](),H=I.next(),
|
|
47
|
-
`?(z&&(Z+=G3("")),X&&
|
|
48
|
-
`&&(X&&
|
|
45
|
+
`)),this._prevFrame=$;return}}this.output.write(l.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}function Q5($,G){if($===void 0||G.length===0)return 0;let J=G.findIndex((Z)=>Z.value===$);return J!==-1?J:0}function N5($,G){return(G.label??String(G.value)).toLowerCase().includes($.toLowerCase())}function Y5($,G){if(G)return $?G:G[0]}class s4 extends O1{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#$=0;#J="";#Z;#G;get cursor(){return this.#$}get userInputWithCursor(){if(!this.userInput)return s1.default.inverse(s1.default.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let $=this.userInput.slice(0,this._cursor),[G,...J]=this.userInput.slice(this._cursor);return`${$}${s1.default.inverse(G)}${J.join("")}`}get options(){return typeof this.#G=="function"?this.#G():this.#G}constructor($){super($),this.#G=$.options;let G=this.options;this.filteredOptions=[...G],this.multiple=$.multiple===!0,this.#Z=$.filter??N5;let J;if($.initialValue&&Array.isArray($.initialValue)?this.multiple?J=$.initialValue:J=$.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(J=[this.options[0].value]),J)for(let Z of J){let X=G.findIndex((z)=>z.value===Z);X!==-1&&(this.toggleSelected(Z),this.#$=X)}this.focusedValue=this.options[this.#$]?.value,this.on("key",(Z,X)=>this.#X(Z,X)),this.on("userInput",(Z)=>this.#z(Z))}_isActionKey($,G){return $==="\t"||this.multiple&&this.isNavigating&&G.name==="space"&&$!==void 0&&$!==""}#X($,G){let J=G.name==="up",Z=G.name==="down",X=G.name==="return";J||Z?(this.#$=Math.max(0,Math.min(this.#$+(J?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):X?this.value=Y5(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(G.name==="tab"||this.isNavigating&&G.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected($){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes($)?this.selectedValues=this.selectedValues.filter((G)=>G!==$):this.selectedValues=[...this.selectedValues,$]:this.selectedValues=[$])}#z($){if($!==this.#J){this.#J=$;let G=this.options;$?this.filteredOptions=G.filter((J)=>this.#Z($,J)):this.filteredOptions=[...G],this.#$=Q5(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#$]?.value,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}}class L2 extends O1{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor($){super($,!1),this.value=!!$.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(G)=>{this.output.write(l.cursor.move(0,-1)),this.value=G,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}class o4 extends O1{options;cursor=0;#$;getGroupItems($){return this.options.filter((G)=>G.group===$)}isGroupSelected($){let G=this.getGroupItems($),J=this.value;return J===void 0?!1:G.every((Z)=>J.includes(Z.value))}toggleValue(){let $=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),$.group===!0){let G=$.value,J=this.getGroupItems(G);this.isGroupSelected(G)?this.value=this.value.filter((Z)=>J.findIndex((X)=>X.value===Z)===-1):this.value=[...this.value,...J.map((Z)=>Z.value)],this.value=Array.from(new Set(this.value))}else{let G=this.value.includes($.value);this.value=G?this.value.filter((J)=>J!==$.value):[...this.value,$.value]}}constructor($){super($,!1);let{options:G}=$;this.#$=$.selectableGroups!==!1,this.options=Object.entries(G).flatMap(([J,Z])=>[{value:J,group:!0,label:J},...Z.map((X)=>({...X,group:J}))]),this.value=[...$.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:J})=>J===$.cursorAt),this.#$?0:1),this.on("cursor",(J)=>{switch(J){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Z=this.options[this.cursor]?.group===!0;!this.#$&&Z&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Z=this.options[this.cursor]?.group===!0;!this.#$&&Z&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}}function D1($,G,J){let Z=$+G,X=Math.max(J.length-1,0),z=Z<0?X:Z>X?0:Z;return J[z].disabled?D1(z,G<0?-1:1,J):z}class A2 extends O1{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(($)=>$.disabled!==!0)}toggleAll(){let $=this._enabledOptions,G=this.value!==void 0&&this.value.length===$.length;this.value=G?[]:$.map((J)=>J.value)}toggleInvert(){let $=this.value;if(!$)return;let G=this._enabledOptions.filter((J)=>!$.includes(J.value));this.value=G.map((J)=>J.value)}toggleValue(){this.value===void 0&&(this.value=[]);let $=this.value.includes(this._value);this.value=$?this.value.filter((G)=>G!==this._value):[...this.value,this._value]}constructor($){super($,!1),this.options=$.options,this.value=[...$.initialValues??[]];let G=Math.max(this.options.findIndex(({value:J})=>J===$.cursorAt),0);this.cursor=this.options[G].disabled?D1(G,1,this.options):G,this.on("key",(J)=>{J==="a"&&this.toggleAll(),J==="i"&&this.toggleInvert()}),this.on("cursor",(J)=>{switch(J){case"left":case"up":this.cursor=D1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=D1(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}}class D2 extends O1{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor($){super($,!1),this.options=$.options;let G=this.options.findIndex(({value:Z})=>Z===$.initialValue),J=G===-1?0:G;this.cursor=this.options[J].disabled?D1(J,1,this.options):J,this.changeValue(),this.on("cursor",(Z)=>{switch(Z){case"left":case"up":this.cursor=D1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=D1(this.cursor,1,this.options);break}this.changeValue()})}}class C2 extends O1{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${this.userInput}█`;let G=$.slice(0,this.cursor),[J,...Z]=$.slice(this.cursor);return`${G}${s1.default.inverse(J)}${Z.join("")}`}get cursor(){return this._cursor}constructor($){super({...$,initialUserInput:$.initialUserInput??$.initialValue}),this.on("userInput",(G)=>{this._setValue(G)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}}var _=s(f1(),1);import e from"node:process";var t1=s(q2(),1);function K5(){return e.platform!=="win32"?e.env.TERM!=="linux":!!e.env.CI||!!e.env.WT_SESSION||!!e.env.TERMINUS_SUBLIME||e.env.ConEmuTask==="{cmd::Cmder}"||e.env.TERM_PROGRAM==="Terminus-Sublime"||e.env.TERM_PROGRAM==="vscode"||e.env.TERM==="xterm-256color"||e.env.TERM==="alacritty"||e.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var E2=K5(),H5=()=>process.env.CI==="true";var E=($,G)=>E2?$:G,I5=E("◆","*"),J3=E("■","x"),Z3=E("▲","x"),F0=E("◇","o"),q5=E("┌","T"),P=E("│","|"),V1=E("└","—"),FG=E("┐","T"),PG=E("┘","—"),S2=E("●",">"),O0=E("○"," "),B5=E("◻","[•]"),r4=E("◼","[+]"),a4=E("◻","[ ]"),EG=E("▪","•"),t4=E("─","-"),U5=E("╮","+"),_5=E("├","+"),j5=E("╯","+"),R5=E("╰","+"),SG=E("╭","+"),M5=E("●","•"),V5=E("◆","*"),T5=E("▲","!"),x5=E("■","x"),P0=($)=>{switch($){case"initial":case"active":return _.default.cyan(I5);case"cancel":return _.default.red(J3);case"error":return _.default.yellow(Z3);case"submit":return _.default.green(F0)}},X3=($)=>{switch($){case"initial":case"active":return _.default.cyan(P);case"cancel":return _.default.red(P);case"error":return _.default.yellow(P);case"submit":return _.default.green(P)}},W5=($)=>$===161||$===164||$===167||$===168||$===170||$===173||$===174||$>=176&&$<=180||$>=182&&$<=186||$>=188&&$<=191||$===198||$===208||$===215||$===216||$>=222&&$<=225||$===230||$>=232&&$<=234||$===236||$===237||$===240||$===242||$===243||$>=247&&$<=250||$===252||$===254||$===257||$===273||$===275||$===283||$===294||$===295||$===299||$>=305&&$<=307||$===312||$>=319&&$<=322||$===324||$>=328&&$<=331||$===333||$===338||$===339||$===358||$===359||$===363||$===462||$===464||$===466||$===468||$===470||$===472||$===474||$===476||$===593||$===609||$===708||$===711||$>=713&&$<=715||$===717||$===720||$>=728&&$<=731||$===733||$===735||$>=768&&$<=879||$>=913&&$<=929||$>=931&&$<=937||$>=945&&$<=961||$>=963&&$<=969||$===1025||$>=1040&&$<=1103||$===1105||$===8208||$>=8211&&$<=8214||$===8216||$===8217||$===8220||$===8221||$>=8224&&$<=8226||$>=8228&&$<=8231||$===8240||$===8242||$===8243||$===8245||$===8251||$===8254||$===8308||$===8319||$>=8321&&$<=8324||$===8364||$===8451||$===8453||$===8457||$===8467||$===8470||$===8481||$===8482||$===8486||$===8491||$===8531||$===8532||$>=8539&&$<=8542||$>=8544&&$<=8555||$>=8560&&$<=8569||$===8585||$>=8592&&$<=8601||$===8632||$===8633||$===8658||$===8660||$===8679||$===8704||$===8706||$===8707||$===8711||$===8712||$===8715||$===8719||$===8721||$===8725||$===8730||$>=8733&&$<=8736||$===8739||$===8741||$>=8743&&$<=8748||$===8750||$>=8756&&$<=8759||$===8764||$===8765||$===8776||$===8780||$===8786||$===8800||$===8801||$>=8804&&$<=8807||$===8810||$===8811||$===8814||$===8815||$===8834||$===8835||$===8838||$===8839||$===8853||$===8857||$===8869||$===8895||$===8978||$>=9312&&$<=9449||$>=9451&&$<=9547||$>=9552&&$<=9587||$>=9600&&$<=9615||$>=9618&&$<=9621||$===9632||$===9633||$>=9635&&$<=9641||$===9650||$===9651||$===9654||$===9655||$===9660||$===9661||$===9664||$===9665||$>=9670&&$<=9672||$===9675||$>=9678&&$<=9681||$>=9698&&$<=9701||$===9711||$===9733||$===9734||$===9737||$===9742||$===9743||$===9756||$===9758||$===9792||$===9794||$===9824||$===9825||$>=9827&&$<=9829||$>=9831&&$<=9834||$===9836||$===9837||$===9839||$===9886||$===9887||$===9919||$>=9926&&$<=9933||$>=9935&&$<=9939||$>=9941&&$<=9953||$===9955||$===9960||$===9961||$>=9963&&$<=9969||$===9972||$>=9974&&$<=9977||$===9979||$===9980||$===9982||$===9983||$===10045||$>=10102&&$<=10111||$>=11094&&$<=11097||$>=12872&&$<=12879||$>=57344&&$<=63743||$>=65024&&$<=65039||$===65533||$>=127232&&$<=127242||$>=127248&&$<=127277||$>=127280&&$<=127337||$>=127344&&$<=127373||$===127375||$===127376||$>=127387&&$<=127404||$>=917760&&$<=917999||$>=983040&&$<=1048573||$>=1048576&&$<=1114109,L5=($)=>$===12288||$>=65281&&$<=65376||$>=65504&&$<=65510,A5=($)=>$>=4352&&$<=4447||$===8986||$===8987||$===9001||$===9002||$>=9193&&$<=9196||$===9200||$===9203||$===9725||$===9726||$===9748||$===9749||$>=9800&&$<=9811||$===9855||$===9875||$===9889||$===9898||$===9899||$===9917||$===9918||$===9924||$===9925||$===9934||$===9940||$===9962||$===9970||$===9971||$===9973||$===9978||$===9981||$===9989||$===9994||$===9995||$===10024||$===10060||$===10062||$>=10067&&$<=10069||$===10071||$>=10133&&$<=10135||$===10160||$===10175||$===11035||$===11036||$===11088||$===11093||$>=11904&&$<=11929||$>=11931&&$<=12019||$>=12032&&$<=12245||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12353&&$<=12438||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=19968&&$<=42124||$>=42128&&$<=42182||$>=43360&&$<=43388||$>=44032&&$<=55203||$>=63744&&$<=64255||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=94176&&$<=94180||$===94192||$===94193||$>=94208&&$<=100343||$>=100352&&$<=101589||$>=101632&&$<=101640||$>=110576&&$<=110579||$>=110581&&$<=110587||$===110589||$===110590||$>=110592&&$<=110882||$===110898||$>=110928&&$<=110930||$===110933||$>=110948&&$<=110951||$>=110960&&$<=111355||$===126980||$===127183||$===127374||$>=127377&&$<=127386||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$===127568||$===127569||$>=127584&&$<=127589||$>=127744&&$<=127776||$>=127789&&$<=127797||$>=127799&&$<=127868||$>=127870&&$<=127891||$>=127904&&$<=127946||$>=127951&&$<=127955||$>=127968&&$<=127984||$===127988||$>=127992&&$<=128062||$===128064||$>=128066&&$<=128252||$>=128255&&$<=128317||$>=128331&&$<=128334||$>=128336&&$<=128359||$===128378||$===128405||$===128406||$===128420||$>=128507&&$<=128591||$>=128640&&$<=128709||$===128716||$>=128720&&$<=128722||$>=128725&&$<=128727||$>=128732&&$<=128735||$===128747||$===128748||$>=128756&&$<=128764||$>=128992&&$<=129003||$===129008||$>=129292&&$<=129338||$>=129340&&$<=129349||$>=129351&&$<=129535||$>=129648&&$<=129660||$>=129664&&$<=129672||$>=129680&&$<=129725||$>=129727&&$<=129733||$>=129742&&$<=129755||$>=129760&&$<=129768||$>=129776&&$<=129784||$>=131072&&$<=196605||$>=196608&&$<=262141,O2=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,L0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,A0=/\t{1,1000}/y,F2=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,D0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,D5=/\p{M}+/gu,C5={limit:1/0,ellipsis:""},z3=($,G={},J={})=>{let Z=G.limit??1/0,X=G.ellipsis??"",z=G?.ellipsisWidth??(X?z3(X,C5,J).width:0),N=J.ansiWidth??0,Q=J.controlWidth??0,Y=J.tabWidth??8,K=J.ambiguousWidth??1,I=J.emojiWidth??2,H=J.fullWidthWidth??2,B=J.regularWidth??1,j=J.wideWidth??2,U=0,q=0,R=$.length,x=0,T=!1,L=R,C=Math.max(0,Z-z),A=0,F=0,V=0,W=0;$:for(;;){if(F>A||q>=R&&q>U){let k=$.slice(A,F)||$.slice(U,q);x=0;for(let p of k.replaceAll(D5,"")){let i=p.codePointAt(0)||0;if(L5(i)?W=H:A5(i)?W=j:K!==B&&W5(i)?W=K:W=B,V+W>C&&(L=Math.min(L,Math.max(A,U)+x)),V+W>Z){T=!0;break $}x+=p.length,V+=W}A=F=0}if(q>=R)break;if(D0.lastIndex=q,D0.test($)){if(x=D0.lastIndex-q,W=x*B,V+W>C&&(L=Math.min(L,q+Math.floor((C-V)/B))),V+W>Z){T=!0;break}V+=W,A=U,F=q,q=U=D0.lastIndex;continue}if(O2.lastIndex=q,O2.test($)){if(V+N>C&&(L=Math.min(L,q)),V+N>Z){T=!0;break}V+=N,A=U,F=q,q=U=O2.lastIndex;continue}if(L0.lastIndex=q,L0.test($)){if(x=L0.lastIndex-q,W=x*Q,V+W>C&&(L=Math.min(L,q+Math.floor((C-V)/Q))),V+W>Z){T=!0;break}V+=W,A=U,F=q,q=U=L0.lastIndex;continue}if(A0.lastIndex=q,A0.test($)){if(x=A0.lastIndex-q,W=x*Y,V+W>C&&(L=Math.min(L,q+Math.floor((C-V)/Y))),V+W>Z){T=!0;break}V+=W,A=U,F=q,q=U=A0.lastIndex;continue}if(F2.lastIndex=q,F2.test($)){if(V+I>C&&(L=Math.min(L,q)),V+I>Z){T=!0;break}V+=I,A=U,F=q,q=U=F2.lastIndex;continue}q+=1}return{width:T?C:V,index:T?L:R,truncated:T,ellipsed:T&&Z>=z}},O5={limit:1/0,ellipsis:"",ellipsisWidth:0},Y1=($,G={})=>z3($,O5,G).width,E0="\x1B",Q3="",F5=39,y2="\x07",N3="[",P5="]",Y3="m",v2=`${P5}8;;`,e4=new RegExp(`(?:\\${N3}(?<code>\\d+)m|\\${v2}(?<uri>.*)${y2})`,"y"),E5=($)=>{if($>=30&&$<=37||$>=90&&$<=97)return 39;if($>=40&&$<=47||$>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0},$3=($)=>`${E0}${N3}${$}${Y3}`,G3=($)=>`${E0}${v2}${$}${y2}`,S5=($)=>$.map((G)=>Y1(G)),P2=($,G,J)=>{let Z=G[Symbol.iterator](),X=!1,z=!1,N=$.at(-1),Q=N===void 0?0:Y1(N),Y=Z.next(),K=Z.next(),I=0;for(;!Y.done;){let H=Y.value,B=Y1(H);Q+B<=J?$[$.length-1]+=H:($.push(H),Q=0),(H===E0||H===Q3)&&(X=!0,z=G.startsWith(v2,I+1)),X?z?H===y2&&(X=!1,z=!1):H===Y3&&(X=!1):(Q+=B,Q===J&&!K.done&&($.push(""),Q=0)),Y=K,K=Z.next(),I+=H.length}N=$.at(-1),!Q&&N!==void 0&&N.length>0&&$.length>1&&($[$.length-2]+=$.pop())},w5=($)=>{let G=$.split(" "),J=G.length;for(;J>0&&!(Y1(G[J-1])>0);)J--;return J===G.length?$:G.slice(0,J).join(" ")+G.slice(J).join("")},y5=($,G,J={})=>{if(J.trim!==!1&&$.trim()==="")return"";let Z="",X,z,N=$.split(" "),Q=S5(N),Y=[""];for(let[U,q]of N.entries()){J.trim!==!1&&(Y[Y.length-1]=(Y.at(-1)??"").trimStart());let R=Y1(Y.at(-1)??"");if(U!==0&&(R>=G&&(J.wordWrap===!1||J.trim===!1)&&(Y.push(""),R=0),(R>0||J.trim===!1)&&(Y[Y.length-1]+=" ",R++)),J.hard&&Q[U]>G){let x=G-R,T=1+Math.floor((Q[U]-x-1)/G);Math.floor((Q[U]-1)/G)<T&&Y.push(""),P2(Y,q,G);continue}if(R+Q[U]>G&&R>0&&Q[U]>0){if(J.wordWrap===!1&&R<G){P2(Y,q,G);continue}Y.push("")}if(R+Q[U]>G&&J.wordWrap===!1){P2(Y,q,G);continue}Y[Y.length-1]+=q}J.trim!==!1&&(Y=Y.map((U)=>w5(U)));let K=Y.join(`
|
|
46
|
+
`),I=K[Symbol.iterator](),H=I.next(),B=I.next(),j=0;for(;!H.done;){let U=H.value,q=B.value;if(Z+=U,U===E0||U===Q3){e4.lastIndex=j+1;let x=e4.exec(K)?.groups;if(x?.code!==void 0){let T=Number.parseFloat(x.code);X=T===F5?void 0:T}else x?.uri!==void 0&&(z=x.uri.length===0?void 0:x.uri)}let R=X?E5(X):void 0;q===`
|
|
47
|
+
`?(z&&(Z+=G3("")),X&&R&&(Z+=$3(R))):U===`
|
|
48
|
+
`&&(X&&R&&(Z+=$3(X)),z&&(Z+=G3(z))),j+=U.length,H=B,B=I.next()}return Z};function e1($,G,J){return String($).normalize().replaceAll(`\r
|
|
49
49
|
`,`
|
|
50
50
|
`).split(`
|
|
51
51
|
`).map((Z)=>y5(Z,G,J)).join(`
|
|
52
|
-
`)}var v5=($,G,J,Z,X)=>{let z=G,N=0;for(let Q=J;Q<Z;Q++){let Y=$[Q];if(z=z-Y.length,N++,z<=X)break}return{lineCount:z,removals:N}},w2=($)=>{let{cursor:G,options:J,style:Z}=$,X=$.output??process.stdout,z=r1(X),N=$.columnPadding??0,Q=$.rowPadding??4,Y=z-N,K=W2(X),I=
|
|
53
|
-
`);
|
|
52
|
+
`)}var v5=($,G,J,Z,X)=>{let z=G,N=0;for(let Q=J;Q<Z;Q++){let Y=$[Q];if(z=z-Y.length,N++,z<=X)break}return{lineCount:z,removals:N}},w2=($)=>{let{cursor:G,options:J,style:Z}=$,X=$.output??process.stdout,z=r1(X),N=$.columnPadding??0,Q=$.rowPadding??4,Y=z-N,K=W2(X),I=_.default.dim("..."),H=$.maxItems??Number.POSITIVE_INFINITY,B=Math.max(K-Q,0),j=Math.max(Math.min(H,B),5),U=0;G>=j-3&&(U=Math.max(Math.min(G-j+3,J.length-j),0));let q=j<J.length&&U>0,R=j<J.length&&U+j<J.length,x=Math.min(U+j,J.length),T=[],L=0;q&&L++,R&&L++;let C=U+(q?1:0),A=x-(R?1:0);for(let V=C;V<A;V++){let W=e1(Z(J[V],V===G),Y,{hard:!0,trim:!1}).split(`
|
|
53
|
+
`);T.push(W),L+=W.length}if(L>B){let V=0,W=0,k=L,p=G-C,i=(A1,y)=>v5(T,k,A1,y,B);q?({lineCount:k,removals:V}=i(0,p),k>B&&({lineCount:k,removals:W}=i(p+1,T.length))):({lineCount:k,removals:W}=i(p+1,T.length),k>B&&({lineCount:k,removals:V}=i(0,p))),V>0&&(q=!0,T.splice(0,V)),W>0&&(R=!0,T.splice(T.length-W,W))}let F=[];q&&F.push(I);for(let V of T)for(let W of V)F.push(W);return R&&F.push(I),F};var K3=($)=>{let G=$.active??"Yes",J=$.inactive??"No";return new L2({active:G,inactive:J,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue??!0,render(){let Z=`${_.default.gray(P)}
|
|
54
54
|
${P0(this.state)} ${$.message}
|
|
55
|
-
`,X=this.value?G:J;switch(this.state){case"submit":return`${Z}${
|
|
56
|
-
${
|
|
57
|
-
${
|
|
58
|
-
`}}}).prompt()};var Z1={message:($=[],{symbol:G=
|
|
59
|
-
`);if(H.length>0){let[
|
|
55
|
+
`,X=this.value?G:J;switch(this.state){case"submit":return`${Z}${_.default.gray(P)} ${_.default.dim(X)}`;case"cancel":return`${Z}${_.default.gray(P)} ${_.default.strikethrough(_.default.dim(X))}
|
|
56
|
+
${_.default.gray(P)}`;default:return`${Z}${_.default.cyan(P)} ${this.value?`${_.default.green(S2)} ${G}`:`${_.default.dim(O0)} ${_.default.dim(G)}`} ${_.default.dim("/")} ${this.value?`${_.default.dim(O0)} ${_.default.dim(J)}`:`${_.default.green(S2)} ${J}`}
|
|
57
|
+
${_.default.cyan(V1)}
|
|
58
|
+
`}}}).prompt()};var Z1={message:($=[],{symbol:G=_.default.gray(P),secondarySymbol:J=_.default.gray(P),output:Z=process.stdout,spacing:X=1,withGuide:z}={})=>{let N=[],Q=(z??J1.withGuide)!==!1,Y=Q?J:"",K=Q?`${G} `:"",I=Q?`${J} `:"";for(let B=0;B<X;B++)N.push(Y);let H=Array.isArray($)?$:$.split(`
|
|
59
|
+
`);if(H.length>0){let[B,...j]=H;B.length>0?N.push(`${K}${B}`):N.push(Q?G:"");for(let U of j)U.length>0?N.push(`${I}${U}`):N.push(Q?J:"")}Z.write(`${N.join(`
|
|
60
60
|
`)}
|
|
61
|
-
`)},info:($,G)=>{Z1.message($,{...G,symbol:
|
|
61
|
+
`)},info:($,G)=>{Z1.message($,{...G,symbol:_.default.blue(M5)})},success:($,G)=>{Z1.message($,{...G,symbol:_.default.green(V5)})},step:($,G)=>{Z1.message($,{...G,symbol:_.default.green(F0)})},warn:($,G)=>{Z1.message($,{...G,symbol:_.default.yellow(T5)})},warning:($,G)=>{Z1.warn($,G)},error:($,G)=>{Z1.message($,{...G,symbol:_.default.red(x5)})}},B1=($="",G)=>{(G?.output??process.stdout).write(`${_.default.gray(V1)} ${_.default.red($)}
|
|
62
62
|
|
|
63
|
-
`)},F1=($="",G)=>{(G?.output??process.stdout).write(`${
|
|
64
|
-
`)},$1=($="",G)=>{(G?.output??process.stdout).write(`${
|
|
65
|
-
${
|
|
63
|
+
`)},F1=($="",G)=>{(G?.output??process.stdout).write(`${_.default.gray(q5)} ${$}
|
|
64
|
+
`)},$1=($="",G)=>{(G?.output??process.stdout).write(`${_.default.gray(P)}
|
|
65
|
+
${_.default.gray(V1)} ${$}
|
|
66
66
|
|
|
67
67
|
`)},a1=($,G)=>$.split(`
|
|
68
68
|
`).map((J)=>G(J)).join(`
|
|
69
|
-
`),g2=($)=>{let G=(Z,X)=>{let z=Z.label??String(Z.value);return X==="disabled"?`${
|
|
70
|
-
${
|
|
69
|
+
`),g2=($)=>{let G=(Z,X)=>{let z=Z.label??String(Z.value);return X==="disabled"?`${_.default.gray(a4)} ${a1(z,(N)=>_.default.strikethrough(_.default.gray(N)))}${Z.hint?` ${_.default.dim(`(${Z.hint??"disabled"})`)}`:""}`:X==="active"?`${_.default.cyan(B5)} ${z}${Z.hint?` ${_.default.dim(`(${Z.hint})`)}`:""}`:X==="selected"?`${_.default.green(r4)} ${a1(z,_.default.dim)}${Z.hint?` ${_.default.dim(`(${Z.hint})`)}`:""}`:X==="cancelled"?`${a1(z,(N)=>_.default.strikethrough(_.default.dim(N)))}`:X==="active-selected"?`${_.default.green(r4)} ${z}${Z.hint?` ${_.default.dim(`(${Z.hint})`)}`:""}`:X==="submitted"?`${a1(z,_.default.dim)}`:`${_.default.dim(a4)} ${a1(z,_.default.dim)}`},J=$.required??!0;return new A2({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValues:$.initialValues,required:J,cursorAt:$.cursorAt,validate(Z){if(J&&(Z===void 0||Z.length===0))return`Please select at least one option.
|
|
70
|
+
${_.default.reset(_.default.dim(`Press ${_.default.gray(_.default.bgWhite(_.default.inverse(" space ")))} to select, ${_.default.gray(_.default.bgWhite(_.default.inverse(" enter ")))} to submit`))}`},render(){let Z=C1($.output,$.message,`${X3(this.state)} `,`${P0(this.state)} `),X=`${_.default.gray(P)}
|
|
71
71
|
${Z}
|
|
72
|
-
`,z=this.value??[],N=(Q,Y)=>{if(Q.disabled)return G(Q,"disabled");let K=z.includes(Q.value);return Y&&K?G(Q,"active-selected"):K?G(Q,"selected"):G(Q,Y?"active":"inactive")};switch(this.state){case"submit":{let Q=this.options.filter(({value:K})=>z.includes(K)).map((K)=>G(K,"submitted")).join(
|
|
73
|
-
${
|
|
74
|
-
`).map((H,
|
|
72
|
+
`,z=this.value??[],N=(Q,Y)=>{if(Q.disabled)return G(Q,"disabled");let K=z.includes(Q.value);return Y&&K?G(Q,"active-selected"):K?G(Q,"selected"):G(Q,Y?"active":"inactive")};switch(this.state){case"submit":{let Q=this.options.filter(({value:K})=>z.includes(K)).map((K)=>G(K,"submitted")).join(_.default.dim(", "))||_.default.dim("none"),Y=C1($.output,Q,`${_.default.gray(P)} `);return`${X}${Y}`}case"cancel":{let Q=this.options.filter(({value:K})=>z.includes(K)).map((K)=>G(K,"cancelled")).join(_.default.dim(", "));if(Q.trim()==="")return`${X}${_.default.gray(P)}`;let Y=C1($.output,Q,`${_.default.gray(P)} `);return`${X}${Y}
|
|
73
|
+
${_.default.gray(P)}`}case"error":{let Q=`${_.default.yellow(P)} `,Y=this.error.split(`
|
|
74
|
+
`).map((H,B)=>B===0?`${_.default.yellow(V1)} ${_.default.yellow(H)}`:` ${H}`).join(`
|
|
75
75
|
`),K=X.split(`
|
|
76
76
|
`).length,I=Y.split(`
|
|
77
77
|
`).length+1;return`${X}${Q}${w2({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:Q.length,rowPadding:K+I,style:N}).join(`
|
|
78
78
|
${Q}`)}
|
|
79
79
|
${Y}
|
|
80
|
-
`}default:{let Q=`${
|
|
80
|
+
`}default:{let Q=`${_.default.cyan(P)} `,Y=X.split(`
|
|
81
81
|
`).length;return`${X}${Q}${w2({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:Q.length,rowPadding:Y+2,style:N}).join(`
|
|
82
82
|
${Q}`)}
|
|
83
|
-
${
|
|
84
|
-
`}}}}).prompt()},g5=($)=>
|
|
83
|
+
${_.default.cyan(V1)}
|
|
84
|
+
`}}}}).prompt()},g5=($)=>_.default.dim($),f5=($,G,J)=>{let Z={hard:!0,trim:!1},X=e1($,G,Z).split(`
|
|
85
85
|
`),z=X.reduce((Y,K)=>Math.max(Y1(K),Y),0),N=X.map(J).reduce((Y,K)=>Math.max(Y1(K),Y),0),Q=G-(N-z);return e1($,Q,Z)},g=($="",G="",J)=>{let Z=J?.output??e.stdout,X=(J?.withGuide??J1.withGuide)!==!1,z=J?.format??g5,N=["",...f5($,r1(Z)-6,z).split(`
|
|
86
|
-
`).map(z),""],Q=Y1(G),Y=Math.max(N.reduce((
|
|
87
|
-
`),I=X?`${
|
|
88
|
-
`:"",H=X?_5:R5;Z.write(`${I}${
|
|
86
|
+
`).map(z),""],Q=Y1(G),Y=Math.max(N.reduce((B,j)=>{let U=Y1(j);return U>B?U:B},0),Q)+2,K=N.map((B)=>`${_.default.gray(P)} ${B}${" ".repeat(Y-Y1(B))}${_.default.gray(P)}`).join(`
|
|
87
|
+
`),I=X?`${_.default.gray(P)}
|
|
88
|
+
`:"",H=X?_5:R5;Z.write(`${I}${_.default.green(F0)} ${_.default.reset(G)} ${_.default.gray(t4.repeat(Math.max(Y-Q-1,1))+U5)}
|
|
89
89
|
${K}
|
|
90
|
-
${
|
|
91
|
-
`)};var b5=
|
|
92
|
-
`);let
|
|
93
|
-
`);
|
|
94
|
-
`);let a=0,H1=0;F(),H=setInterval(()=>{if(K&&q
|
|
95
|
-
`):J.write(`${I1} ${
|
|
96
|
-
`)),
|
|
90
|
+
${_.default.gray(H+t4.repeat(Y+2)+j5)}
|
|
91
|
+
`)};var b5=_.default.magenta,S0=({indicator:$="dots",onCancel:G,output:J=process.stdout,cancelMessage:Z,errorMessage:X,frames:z=E2?["◒","◐","◓","◑"]:["•","o","O","0"],delay:N=E2?80:120,signal:Q,...Y}={})=>{let K=H5(),I,H,B=!1,j=!1,U="",q,R=performance.now(),x=r1(J),T=Y?.styleFrame??b5,L=(y)=>{let a=y>1?X??J1.messages.error:Z??J1.messages.cancel;j=y===1,B&&(A1(a,y),j&&typeof G=="function"&&G())},C=()=>L(2),A=()=>L(1),F=()=>{process.on("uncaughtExceptionMonitor",C),process.on("unhandledRejection",C),process.on("SIGINT",A),process.on("SIGTERM",A),process.on("exit",L),Q&&Q.addEventListener("abort",A)},V=()=>{process.removeListener("uncaughtExceptionMonitor",C),process.removeListener("unhandledRejection",C),process.removeListener("SIGINT",A),process.removeListener("SIGTERM",A),process.removeListener("exit",L),Q&&Q.removeEventListener("abort",A)},W=()=>{if(q===void 0)return;K&&J.write(`
|
|
92
|
+
`);let y=e1(q,x,{hard:!0,trim:!1}).split(`
|
|
93
|
+
`);y.length>1&&J.write(t1.cursor.up(y.length-1)),J.write(t1.cursor.to(0)),J.write(t1.erase.down())},k=(y)=>y.replace(/\.+$/,""),p=(y)=>{let a=(performance.now()-y)/1000,H1=Math.floor(a/60),I1=Math.floor(a%60);return H1>0?`[${H1}m ${I1}s]`:`[${I1}s]`},i=(y="")=>{B=!0,I=i4({output:J}),U=k(y),R=performance.now(),J.write(`${_.default.gray(P)}
|
|
94
|
+
`);let a=0,H1=0;F(),H=setInterval(()=>{if(K&&U===q)return;W(),q=U;let I1=T(z[a]),U0;if(K)U0=`${I1} ${U}...`;else if($==="timer")U0=`${I1} ${U} ${p(R)}`;else{let p9=".".repeat(Math.floor(H1)).slice(0,3);U0=`${I1} ${U}${p9}`}let c9=e1(U0,x,{hard:!0,trim:!1});J.write(c9),a=a+1<z.length?a+1:0,H1=H1<4?H1+0.125:0},N)},A1=(y="",a=0,H1=!1)=>{if(!B)return;B=!1,clearInterval(H),W();let I1=a===0?_.default.green(F0):a===1?_.default.red(J3):_.default.red(Z3);U=y??U,H1||($==="timer"?J.write(`${I1} ${U} ${p(R)}
|
|
95
|
+
`):J.write(`${I1} ${U}
|
|
96
|
+
`)),V(),I()};return{start:i,stop:(y="")=>A1(y,0),message:(y="")=>{U=k(y??U)},cancel:(y="")=>A1(y,1),error:(y="")=>A1(y,2),clear:()=>A1("",0,!0),get isCancelled(){return j}}},wG={light:E("─","-"),heavy:E("━","="),block:E("█","#")};var C0=($,G)=>$.includes(`
|
|
97
97
|
`)?$.split(`
|
|
98
98
|
`).map((J)=>G(J)).join(`
|
|
99
|
-
`):G($),w0=($)=>{let G=(J,Z)=>{let X=J.label??String(J.value);switch(Z){case"disabled":return`${
|
|
99
|
+
`):G($),w0=($)=>{let G=(J,Z)=>{let X=J.label??String(J.value);switch(Z){case"disabled":return`${_.default.gray(O0)} ${C0(X,_.default.gray)}${J.hint?` ${_.default.dim(`(${J.hint??"disabled"})`)}`:""}`;case"selected":return`${C0(X,_.default.dim)}`;case"active":return`${_.default.green(S2)} ${X}${J.hint?` ${_.default.dim(`(${J.hint})`)}`:""}`;case"cancelled":return`${C0(X,(z)=>_.default.strikethrough(_.default.dim(z)))}`;default:return`${_.default.dim(O0)} ${C0(X,_.default.dim)}`}};return new D2({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue,render(){let J=`${P0(this.state)} `,Z=`${X3(this.state)} `,X=C1($.output,$.message,Z,J),z=`${_.default.gray(P)}
|
|
100
100
|
${X}
|
|
101
|
-
`;switch(this.state){case"submit":{let N=`${
|
|
102
|
-
${
|
|
101
|
+
`;switch(this.state){case"submit":{let N=`${_.default.gray(P)} `,Q=C1($.output,G(this.options[this.cursor],"selected"),N);return`${z}${Q}`}case"cancel":{let N=`${_.default.gray(P)} `,Q=C1($.output,G(this.options[this.cursor],"cancelled"),N);return`${z}${Q}
|
|
102
|
+
${_.default.gray(P)}`}default:{let N=`${_.default.cyan(P)} `,Q=z.split(`
|
|
103
103
|
`).length;return`${z}${N}${w2({output:$.output,cursor:this.cursor,options:this.options,maxItems:$.maxItems,columnPadding:N.length,rowPadding:Q+2,style:(Y,K)=>G(Y,Y.disabled?"disabled":K?"active":"inactive")}).join(`
|
|
104
104
|
${N}`)}
|
|
105
|
-
${
|
|
106
|
-
`}}}}).prompt()};var
|
|
105
|
+
${_.default.cyan(V1)}
|
|
106
|
+
`}}}}).prompt()};var yG=`${_.default.gray(P)} `;var y0=($)=>new C2({validate:$.validate,placeholder:$.placeholder,defaultValue:$.defaultValue,initialValue:$.initialValue,output:$.output,signal:$.signal,input:$.input,render(){let G=($?.withGuide??J1.withGuide)!==!1,J=`${`${G?`${_.default.gray(P)}
|
|
107
107
|
`:""}${P0(this.state)} `}${$.message}
|
|
108
|
-
`,Z=$.placeholder?
|
|
108
|
+
`,Z=$.placeholder?_.default.inverse($.placeholder[0])+_.default.dim($.placeholder.slice(1)):_.default.inverse(_.default.hidden("_")),X=this.userInput?this.userInputWithCursor:Z,z=this.value??"";switch(this.state){case"error":{let N=this.error?` ${_.default.yellow(this.error)}`:"",Q=G?`${_.default.yellow(P)} `:"",Y=G?_.default.yellow(V1):"";return`${J.trim()}
|
|
109
109
|
${Q}${X}
|
|
110
110
|
${Y}${N}
|
|
111
|
-
`}case"submit":{let N=z?` ${
|
|
112
|
-
${Q}`:""}`}default:{let N=G?`${
|
|
111
|
+
`}case"submit":{let N=z?` ${_.default.dim(z)}`:"",Q=G?_.default.gray(P):"";return`${J}${Q}${N}`}case"cancel":{let N=z?` ${_.default.strikethrough(_.default.dim(z))}`:"",Q=G?_.default.gray(P):"";return`${J}${Q}${N}${z.trim()?`
|
|
112
|
+
${Q}`:""}`}default:{let N=G?`${_.default.cyan(P)} `:"",Q=G?_.default.cyan(V1):"";return`${J}${N}${X}
|
|
113
113
|
${Q}
|
|
114
|
-
`}}}}).prompt();var R=s(f1(),1);import{existsSync as h,mkdirSync as i1,readFileSync as v1,writeFileSync as g1,readdirSync as p1}from"node:fs";import{execSync as m}from"node:child_process";import{dirname as G2,join as S}from"node:path";import{createHash as C7}from"node:crypto";async function f2($,G,{concurrency:J=Number.POSITIVE_INFINITY,stopOnError:Z=!0,signal:X}={}){return new Promise((z,N)=>{if($[Symbol.iterator]===void 0&&$[Symbol.asyncIterator]===void 0)throw TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof $})`);if(typeof G!=="function")throw TypeError("Mapper function is required");if(!(Number.isSafeInteger(J)&&J>=1||J===Number.POSITIVE_INFINITY))throw TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${J}\` (${typeof J})`);let Q=[],Y=[],K=new Map,I=!1,H=!1,U=!1,_=0,q=0,B=$[Symbol.iterator]===void 0?$[Symbol.asyncIterator]():$[Symbol.iterator](),M=()=>{L(X.reason)},V=()=>{X?.removeEventListener("abort",M)},x=(A)=>{z(A),V()},L=(A)=>{I=!0,H=!0,N(A),V()};if(X){if(X.aborted)L(X.reason);X.addEventListener("abort",M,{once:!0})}let D=async()=>{if(H)return;let A=await B.next(),F=q;if(q++,A.done){if(U=!0,_===0&&!H){if(!Z&&Y.length>0){L(AggregateError(Y));return}if(H=!0,K.size===0){x(Q);return}let T=[];for(let[W,b]of Q.entries()){if(K.get(W)===H3)continue;T.push(b)}x(T)}return}_++,(async()=>{try{let T=await A.value;if(H)return;let W=await G(T,F);if(W===H3)K.set(F,W);Q[F]=W,_--,await D()}catch(T){if(Z)L(T);else{Y.push(T),_--;try{await D()}catch(W){L(W)}}}})()};(async()=>{for(let A=0;A<J;A++){try{await D()}catch(F){L(F);break}if(U||I)break}})()})}var H3=Symbol("skip");import{stat as U6}from"fs";import{stat as _6,readdir as j6}from"fs/promises";import{EventEmitter as R6}from"events";import*as O from"path";import{stat as k5,lstat as I3,readdir as h5,realpath as m5}from"node:fs/promises";import{Readable as l5}from"node:stream";import{resolve as q3,relative as d5,join as c5,sep as p5}from"node:path";var o={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},b2={root:".",fileFilter:($)=>!0,directoryFilter:($)=>!0,type:o.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(b2);var j3="READDIRP_RECURSIVE_ERROR",i5=new Set(["ENOENT","EPERM","EACCES","ELOOP",j3]),B3=[o.DIR_TYPE,o.EVERYTHING_TYPE,o.FILE_DIR_TYPE,o.FILE_TYPE],n5=new Set([o.DIR_TYPE,o.EVERYTHING_TYPE,o.FILE_DIR_TYPE]),s5=new Set([o.EVERYTHING_TYPE,o.FILE_DIR_TYPE,o.FILE_TYPE]),o5=($)=>i5.has($.code),r5=process.platform==="win32",U3=($)=>!0,_3=($)=>{if($===void 0)return U3;if(typeof $==="function")return $;if(typeof $==="string"){let G=$.trim();return(J)=>J.basename===G}if(Array.isArray($)){let G=$.map((J)=>J.trim());return(J)=>G.some((Z)=>J.basename===Z)}return U3};class R3 extends l5{constructor($={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:$.highWaterMark});let G={...b2,...$},{root:J,type:Z}=G;this._fileFilter=_3(G.fileFilter),this._directoryFilter=_3(G.directoryFilter);let X=G.lstat?I3:k5;if(r5)this._stat=(z)=>X(z,{bigint:!0});else this._stat=X;this._maxDepth=G.depth??b2.depth,this._wantsDir=Z?n5.has(Z):!1,this._wantsFile=Z?s5.has(Z):!1,this._wantsEverything=Z===o.EVERYTHING_TYPE,this._root=q3(J),this._isDirent=!G.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(J,1)],this.reading=!1,this.parent=void 0}async _read($){if(this.reading)return;this.reading=!0;try{while(!this.destroyed&&$>0){let G=this.parent,J=G&&G.files;if(J&&J.length>0){let{path:Z,depth:X}=G,z=J.splice(0,$).map((Q)=>this._formatEntry(Q,Z)),N=await Promise.all(z);for(let Q of N){if(!Q)continue;if(this.destroyed)return;let Y=await this._getEntryType(Q);if(Y==="directory"&&this._directoryFilter(Q)){if(X<=this._maxDepth)this.parents.push(this._exploreDir(Q.fullPath,X+1));if(this._wantsDir)this.push(Q),$--}else if((Y==="file"||this._includeAsFile(Q))&&this._fileFilter(Q)){if(this._wantsFile)this.push(Q),$--}}}else{let Z=this.parents.pop();if(!Z){this.push(null);break}if(this.parent=await Z,this.destroyed)return}}}catch(G){this.destroy(G)}finally{this.reading=!1}}async _exploreDir($,G){let J;try{J=await h5($,this._rdOptions)}catch(Z){this._onError(Z)}return{files:J,depth:G,path:$}}async _formatEntry($,G){let J,Z=this._isDirent?$.name:$;try{let X=q3(c5(G,Z));J={path:d5(this._root,X),fullPath:X,basename:Z},J[this._statsProp]=this._isDirent?$:await this._stat(X)}catch(X){this._onError(X);return}return J}_onError($){if(o5($)&&!this.destroyed)this.emit("warn",$);else this.destroy($)}async _getEntryType($){if(!$&&this._statsProp in $)return"";let G=$[this._statsProp];if(G.isFile())return"file";if(G.isDirectory())return"directory";if(G&&G.isSymbolicLink()){let J=$.fullPath;try{let Z=await m5(J),X=await I3(Z);if(X.isFile())return"file";if(X.isDirectory()){let z=Z.length;if(J.startsWith(Z)&&J.substr(z,1)===p5){let N=Error(`Circular symlink detected: "${J}" points to "${Z}"`);return N.code=j3,this._onError(N)}return"directory"}}catch(Z){return this._onError(Z),""}}}_includeAsFile($){let G=$&&$[this._statsProp];return G&&this._wantsEverything&&!G.isDirectory()}}function V3($,G={}){let J=G.entryType||G.type;if(J==="both")J=o.FILE_DIR_TYPE;if(J)G.type=J;if(!$)throw Error("readdirp: root argument is required. Usage: readdirp(root, options)");else if(typeof $!=="string")throw TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");else if(J&&!B3.includes(J))throw Error(`readdirp: Invalid type passed. Use one of ${B3.join(", ")}`);return G.root=$,new R3(G)}import{watchFile as a5,unwatchFile as M3,watch as t5}from"fs";import{open as e5,stat as x3,lstat as $6,realpath as u2}from"fs/promises";import*as f from"path";import{type as G6}from"os";var J6="data",m2="end",W3="close",b0=()=>{};var u0=process.platform,l2=u0==="win32",Z6=u0==="darwin",X6=u0==="linux",z6=u0==="freebsd",L3=G6()==="OS400",y={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},X1=y,Q6="watch",N6={lstat:$6,stat:x3},P1="listeners",v0="errHandlers",b1="rawEmitters",Y6=[P1,v0,b1],K6=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),H6=($)=>K6.has(f.extname($).slice(1).toLowerCase()),h2=($,G)=>{if($ instanceof Set)$.forEach(G);else G($)},$0=($,G,J)=>{let Z=$[G];if(!(Z instanceof Set))$[G]=Z=new Set([Z]);Z.add(J)},I6=($)=>(G)=>{let J=$[G];if(J instanceof Set)J.clear();else delete $[G]},G0=($,G,J)=>{let Z=$[G];if(Z instanceof Set)Z.delete(J);else if(Z===J)delete $[G]},A3=($)=>$ instanceof Set?$.size===0:!$,g0=new Map;function T3($,G,J,Z,X){let z=(N,Q)=>{if(J($),X(N,Q,{watchedPath:$}),Q&&$!==Q)f0(f.resolve($,Q),P1,f.join($,Q))};try{return t5($,{persistent:G.persistent},z)}catch(N){Z(N);return}}var f0=($,G,J,Z,X)=>{let z=g0.get($);if(!z)return;h2(z[G],(N)=>{N(J,Z,X)})},q6=($,G,J,Z)=>{let{listener:X,errHandler:z,rawEmitter:N}=Z,Q=g0.get(G),Y;if(!J.persistent){if(Y=T3($,J,X,z,N),!Y)return;return Y.close.bind(Y)}if(Q)$0(Q,P1,X),$0(Q,v0,z),$0(Q,b1,N);else{if(Y=T3($,J,f0.bind(null,G,P1),z,f0.bind(null,G,b1)),!Y)return;Y.on(X1.ERROR,async(K)=>{let I=f0.bind(null,G,v0);if(Q)Q.watcherUnusable=!0;if(l2&&K.code==="EPERM")try{await(await e5($,"r")).close(),I(K)}catch(H){}else I(K)}),Q={listeners:X,errHandlers:z,rawEmitters:N,watcher:Y},g0.set(G,Q)}return()=>{if(G0(Q,P1,X),G0(Q,v0,z),G0(Q,b1,N),A3(Q.listeners))Q.watcher.close(),g0.delete(G),Y6.forEach(I6(Q)),Q.watcher=void 0,Object.freeze(Q)}},k2=new Map,B6=($,G,J,Z)=>{let{listener:X,rawEmitter:z}=Z,N=k2.get(G),Q=N&&N.options;if(Q&&(Q.persistent<J.persistent||Q.interval>J.interval))M3(G),N=void 0;if(N)$0(N,P1,X),$0(N,b1,z);else N={listeners:X,rawEmitters:z,options:J,watcher:a5(G,J,(Y,K)=>{h2(N.rawEmitters,(H)=>{H(X1.CHANGE,G,{curr:Y,prev:K})});let I=Y.mtimeMs;if(Y.size!==K.size||I>K.mtimeMs||I===0)h2(N.listeners,(H)=>H($,Y))})},k2.set(G,N);return()=>{if(G0(N,P1,X),G0(N,b1,z),A3(N.listeners))k2.delete(G),M3(G),N.options=N.watcher=void 0,Object.freeze(N)}};class d2{constructor($){this.fsw=$,this._boundHandleError=(G)=>$._handleError(G)}_watchWithNodeFs($,G){let J=this.fsw.options,Z=f.dirname($),X=f.basename($);this.fsw._getWatchedDir(Z).add(X);let N=f.resolve($),Q={persistent:J.persistent};if(!G)G=b0;let Y;if(J.usePolling){let K=J.interval!==J.binaryInterval;Q.interval=K&&H6(X)?J.binaryInterval:J.interval,Y=B6($,N,Q,{listener:G,rawEmitter:this.fsw._emitRaw})}else Y=q6($,N,Q,{listener:G,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return Y}_handleFile($,G,J){if(this.fsw.closed)return;let Z=f.dirname($),X=f.basename($),z=this.fsw._getWatchedDir(Z),N=G;if(z.has(X))return;let Q=async(K,I)=>{if(!this.fsw._throttle(Q6,$,5))return;if(!I||I.mtimeMs===0)try{let H=await x3($);if(this.fsw.closed)return;let{atimeMs:U,mtimeMs:_}=H;if(!U||U<=_||_!==N.mtimeMs)this.fsw._emit(X1.CHANGE,$,H);if((Z6||X6||z6)&&N.ino!==H.ino){this.fsw._closeFile(K),N=H;let q=this._watchWithNodeFs($,Q);if(q)this.fsw._addPathCloser(K,q)}else N=H}catch(H){this.fsw._remove(Z,X)}else if(z.has(X)){let{atimeMs:H,mtimeMs:U}=I;if(!H||H<=U||U!==N.mtimeMs)this.fsw._emit(X1.CHANGE,$,I);N=I}},Y=this._watchWithNodeFs($,Q);if(!(J&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored($)){if(!this.fsw._throttle(X1.ADD,$,0))return;this.fsw._emit(X1.ADD,$,G)}return Y}async _handleSymlink($,G,J,Z){if(this.fsw.closed)return;let X=$.fullPath,z=this.fsw._getWatchedDir(G);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let N;try{N=await u2(J)}catch(Q){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;if(z.has(Z)){if(this.fsw._symlinkPaths.get(X)!==N)this.fsw._symlinkPaths.set(X,N),this.fsw._emit(X1.CHANGE,J,$.stats)}else z.add(Z),this.fsw._symlinkPaths.set(X,N),this.fsw._emit(X1.ADD,J,$.stats);return this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(X))return!0;this.fsw._symlinkPaths.set(X,!0)}_handleRead($,G,J,Z,X,z,N){if($=f.join($,""),N=this.fsw._throttle("readdir",$,1000),!N)return;let Q=this.fsw._getWatchedDir(J.path),Y=new Set,K=this.fsw._readdirp($,{fileFilter:(I)=>J.filterPath(I),directoryFilter:(I)=>J.filterDir(I)});if(!K)return;return K.on(J6,async(I)=>{if(this.fsw.closed){K=void 0;return}let H=I.path,U=f.join($,H);if(Y.add(H),I.stats.isSymbolicLink()&&await this._handleSymlink(I,$,U,H))return;if(this.fsw.closed){K=void 0;return}if(H===Z||!Z&&!Q.has(H))this.fsw._incrReadyCount(),U=f.join(X,f.relative(X,U)),this._addToNodeFs(U,G,J,z+1)}).on(X1.ERROR,this._boundHandleError),new Promise((I,H)=>{if(!K)return H();K.once(m2,()=>{if(this.fsw.closed){K=void 0;return}let U=N?N.clear():!1;if(I(void 0),Q.getChildren().filter((_)=>{return _!==$&&!Y.has(_)}).forEach((_)=>{this.fsw._remove($,_)}),K=void 0,U)this._handleRead($,!1,J,Z,X,z,N)})})}async _handleDir($,G,J,Z,X,z,N){let Q=this.fsw._getWatchedDir(f.dirname($)),Y=Q.has(f.basename($));if(!(J&&this.fsw.options.ignoreInitial)&&!X&&!Y)this.fsw._emit(X1.ADD_DIR,$,G);Q.add(f.basename($)),this.fsw._getWatchedDir($);let K,I,H=this.fsw.options.depth;if((H==null||Z<=H)&&!this.fsw._symlinkPaths.has(N)){if(!X){if(await this._handleRead($,J,z,X,$,Z,K),this.fsw.closed)return}I=this._watchWithNodeFs($,(U,_)=>{if(_&&_.mtimeMs===0)return;this._handleRead(U,!1,z,X,$,Z,K)})}return I}async _addToNodeFs($,G,J,Z,X){let z=this.fsw._emitReady;if(this.fsw._isIgnored($)||this.fsw.closed)return z(),!1;let N=this.fsw._getWatchHelpers($);if(J)N.filterPath=(Q)=>J.filterPath(Q),N.filterDir=(Q)=>J.filterDir(Q);try{let Q=await N6[N.statMethod](N.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(N.watchPath,Q))return z(),!1;let Y=this.fsw.options.followSymlinks,K;if(Q.isDirectory()){let I=f.resolve($),H=Y?await u2($):$;if(this.fsw.closed)return;if(K=await this._handleDir(N.watchPath,Q,G,Z,X,N,H),this.fsw.closed)return;if(I!==H&&H!==void 0)this.fsw._symlinkPaths.set(I,H)}else if(Q.isSymbolicLink()){let I=Y?await u2($):$;if(this.fsw.closed)return;let H=f.dirname(N.watchPath);if(this.fsw._getWatchedDir(H).add(N.watchPath),this.fsw._emit(X1.ADD,N.watchPath,Q),K=await this._handleDir(H,Q,G,Z,$,N,I),this.fsw.closed)return;if(I!==void 0)this.fsw._symlinkPaths.set(f.resolve($),I)}else K=this._handleFile(N.watchPath,Q,G);if(z(),K)this.fsw._addPathCloser($,K);return!1}catch(Q){if(this.fsw._handleError(Q))return z(),$}}}/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */var c2="/",V6="//",E3=".",M6="..",T6="string",x6=/\\/g,D3=/\/\//,W6=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,L6=/^\.[/\\]/;function k0($){return Array.isArray($)?$:[$]}var p2=($)=>typeof $==="object"&&$!==null&&!($ instanceof RegExp);function A6($){if(typeof $==="function")return $;if(typeof $==="string")return(G)=>$===G;if($ instanceof RegExp)return(G)=>$.test(G);if(typeof $==="object"&&$!==null)return(G)=>{if($.path===G)return!0;if($.recursive){let J=O.relative($.path,G);if(!J)return!1;return!J.startsWith("..")&&!O.isAbsolute(J)}return!1};return()=>!1}function D6($){if(typeof $!=="string")throw Error("string expected");$=O.normalize($),$=$.replace(/\\/g,"/");let G=!1;if($.startsWith("//"))G=!0;let J=/\/\//;while($.match(J))$=$.replace(J,"/");if(G)$="/"+$;return $}function C3($,G,J){let Z=D6(G);for(let X=0;X<$.length;X++){let z=$[X];if(z(Z,J))return!0}return!1}function C6($,G){if($==null)throw TypeError("anymatch: specify first argument");let Z=k0($).map((X)=>A6(X));if(G==null)return(X,z)=>{return C3(Z,X,z)};return C3(Z,G)}var O3=($)=>{let G=k0($).flat();if(!G.every((J)=>typeof J===T6))throw TypeError(`Non-string provided as watch path: ${G}`);return G.map(S3)},F3=($)=>{let G=$.replace(x6,c2),J=!1;if(G.startsWith(V6))J=!0;while(G.match(D3))G=G.replace(D3,c2);if(J)G=c2+G;return G},S3=($)=>F3(O.normalize(F3($))),P3=($="")=>(G)=>{if(typeof G==="string")return S3(O.isAbsolute(G)?G:O.join($,G));else return G},O6=($,G)=>{if(O.isAbsolute($))return $;return O.join(G,$)},F6=Object.freeze(new Set);class w3{constructor($,G){this.path=$,this._removeWatcher=G,this.items=new Set}add($){let{items:G}=this;if(!G)return;if($!==E3&&$!==M6)G.add($)}async remove($){let{items:G}=this;if(!G)return;if(G.delete($),G.size>0)return;let J=this.path;try{await j6(J)}catch(Z){if(this._removeWatcher)this._removeWatcher(O.dirname(J),O.basename(J))}}has($){let{items:G}=this;if(!G)return;return G.has($)}getChildren(){let{items:$}=this;if(!$)return[];return[...$.values()]}dispose(){this.items.clear(),this.path="",this._removeWatcher=b0,this.items=F6,Object.freeze(this)}}var P6="stat",E6="lstat";class y3{constructor($,G,J){this.fsw=J;let Z=$;this.path=$=$.replace(L6,""),this.watchPath=Z,this.fullWatchPath=O.resolve(Z),this.dirParts=[],this.dirParts.forEach((X)=>{if(X.length>1)X.pop()}),this.followSymlinks=G,this.statMethod=G?P6:E6}entryPath($){return O.join(this.watchPath,O.relative(this.watchPath,$.fullPath))}filterPath($){let{stats:G}=$;if(G&&G.isSymbolicLink())return this.filterDir($);let J=this.entryPath($);return this.fsw._isntIgnored(J,G)&&this.fsw._hasReadPermissions(G)}filterDir($){return this.fsw._isntIgnored(this.entryPath($),$.stats)}}class v3 extends R6{constructor($={}){super();this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let G=$.awaitWriteFinish,J={stabilityThreshold:2000,pollInterval:100},Z={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...$,ignored:$.ignored?k0($.ignored):k0([]),awaitWriteFinish:G===!0?J:typeof G==="object"?{...J,...G}:!1};if(L3)Z.usePolling=!0;if(Z.atomic===void 0)Z.atomic=!Z.usePolling;let X=process.env.CHOKIDAR_USEPOLLING;if(X!==void 0){let Q=X.toLowerCase();if(Q==="false"||Q==="0")Z.usePolling=!1;else if(Q==="true"||Q==="1")Z.usePolling=!0;else Z.usePolling=!!Q}let z=process.env.CHOKIDAR_INTERVAL;if(z)Z.interval=Number.parseInt(z,10);let N=0;this._emitReady=()=>{if(N++,N>=this._readyCount)this._emitReady=b0,this._readyEmitted=!0,process.nextTick(()=>this.emit(y.READY))},this._emitRaw=(...Q)=>this.emit(y.RAW,...Q),this._boundRemove=this._remove.bind(this),this.options=Z,this._nodeFsHandler=new d2(this),Object.freeze(Z)}_addIgnoredPath($){if(p2($)){for(let G of this._ignoredPaths)if(p2(G)&&G.path===$.path&&G.recursive===$.recursive)return}this._ignoredPaths.add($)}_removeIgnoredPath($){if(this._ignoredPaths.delete($),typeof $==="string"){for(let G of this._ignoredPaths)if(p2(G)&&G.path===$)this._ignoredPaths.delete(G)}}add($,G,J){let{cwd:Z}=this.options;this.closed=!1,this._closePromise=void 0;let X=O3($);if(Z)X=X.map((z)=>{return O6(z,Z)});if(X.forEach((z)=>{this._removeIgnoredPath(z)}),this._userIgnored=void 0,!this._readyCount)this._readyCount=0;return this._readyCount+=X.length,Promise.all(X.map(async(z)=>{let N=await this._nodeFsHandler._addToNodeFs(z,!J,void 0,0,G);if(N)this._emitReady();return N})).then((z)=>{if(this.closed)return;z.forEach((N)=>{if(N)this.add(O.dirname(N),O.basename(G||N))})}),this}unwatch($){if(this.closed)return this;let G=O3($),{cwd:J}=this.options;return G.forEach((Z)=>{if(!O.isAbsolute(Z)&&!this._closers.has(Z)){if(J)Z=O.join(J,Z);Z=O.resolve(Z)}if(this._closePath(Z),this._addIgnoredPath(Z),this._watched.has(Z))this._addIgnoredPath({path:Z,recursive:!0});this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let $=[];return this._closers.forEach((G)=>G.forEach((J)=>{let Z=J();if(Z instanceof Promise)$.push(Z)})),this._streams.forEach((G)=>G.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach((G)=>G.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=$.length?Promise.all($).then(()=>{return}):Promise.resolve(),this._closePromise}getWatched(){let $={};return this._watched.forEach((G,J)=>{let X=(this.options.cwd?O.relative(this.options.cwd,J):J)||E3;$[X]=G.getChildren().sort()}),$}emitWithAll($,G){if(this.emit($,...G),$!==y.ERROR)this.emit(y.ALL,$,...G)}async _emit($,G,J){if(this.closed)return;let Z=this.options;if(l2)G=O.normalize(G);if(Z.cwd)G=O.relative(Z.cwd,G);let X=[G];if(J!=null)X.push(J);let z=Z.awaitWriteFinish,N;if(z&&(N=this._pendingWrites.get(G)))return N.lastChange=new Date,this;if(Z.atomic){if($===y.UNLINK)return this._pendingUnlinks.set(G,[$,...X]),setTimeout(()=>{this._pendingUnlinks.forEach((Q,Y)=>{this.emit(...Q),this.emit(y.ALL,...Q),this._pendingUnlinks.delete(Y)})},typeof Z.atomic==="number"?Z.atomic:100),this;if($===y.ADD&&this._pendingUnlinks.has(G))$=y.CHANGE,this._pendingUnlinks.delete(G)}if(z&&($===y.ADD||$===y.CHANGE)&&this._readyEmitted){let Q=(Y,K)=>{if(Y)$=y.ERROR,X[0]=Y,this.emitWithAll($,X);else if(K){if(X.length>1)X[1]=K;else X.push(K);this.emitWithAll($,X)}};return this._awaitWriteFinish(G,z.stabilityThreshold,$,Q),this}if($===y.CHANGE){if(!this._throttle(y.CHANGE,G,50))return this}if(Z.alwaysStat&&J===void 0&&($===y.ADD||$===y.ADD_DIR||$===y.CHANGE)){let Q=Z.cwd?O.join(Z.cwd,G):G,Y;try{Y=await _6(Q)}catch(K){}if(!Y||this.closed)return;X.push(Y)}return this.emitWithAll($,X),this}_handleError($){let G=$&&$.code;if($&&G!=="ENOENT"&&G!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||G!=="EPERM"&&G!=="EACCES"))this.emit(y.ERROR,$);return $||this.closed}_throttle($,G,J){if(!this._throttled.has($))this._throttled.set($,new Map);let Z=this._throttled.get($);if(!Z)throw Error("invalid throttle");let X=Z.get(G);if(X)return X.count++,!1;let z,N=()=>{let Y=Z.get(G),K=Y?Y.count:0;if(Z.delete(G),clearTimeout(z),Y)clearTimeout(Y.timeoutObject);return K};z=setTimeout(N,J);let Q={timeoutObject:z,clear:N,count:0};return Z.set(G,Q),Q}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish($,G,J,Z){let X=this.options.awaitWriteFinish;if(typeof X!=="object")return;let z=X.pollInterval,N,Q=$;if(this.options.cwd&&!O.isAbsolute($))Q=O.join(this.options.cwd,$);let Y=new Date,K=this._pendingWrites;function I(H){U6(Q,(U,_)=>{if(U||!K.has($)){if(U&&U.code!=="ENOENT")Z(U);return}let q=Number(new Date);if(H&&_.size!==H.size)K.get($).lastChange=q;let B=K.get($);if(q-B.lastChange>=G)K.delete($),Z(void 0,_);else N=setTimeout(I,z,_)})}if(!K.has($))K.set($,{lastChange:Y,cancelWait:()=>{return K.delete($),clearTimeout(N),J}}),N=setTimeout(I,z)}_isIgnored($,G){if(this.options.atomic&&W6.test($))return!0;if(!this._userIgnored){let{cwd:J}=this.options,X=(this.options.ignored||[]).map(P3(J)),N=[...[...this._ignoredPaths].map(P3(J)),...X];this._userIgnored=C6(N,void 0)}return this._userIgnored($,G)}_isntIgnored($,G){return!this._isIgnored($,G)}_getWatchHelpers($){return new y3($,this.options.followSymlinks,this)}_getWatchedDir($){let G=O.resolve($);if(!this._watched.has(G))this._watched.set(G,new w3(G,this._boundRemove));return this._watched.get(G)}_hasReadPermissions($){if(this.options.ignorePermissionErrors)return!0;return Boolean(Number($.mode)&256)}_remove($,G,J){let Z=O.join($,G),X=O.resolve(Z);if(J=J!=null?J:this._watched.has(Z)||this._watched.has(X),!this._throttle("remove",Z,100))return;if(!J&&this._watched.size===1)this.add($,G,!0);this._getWatchedDir(Z).getChildren().forEach((H)=>this._remove(Z,H));let Q=this._getWatchedDir($),Y=Q.has(G);if(Q.remove(G),this._symlinkPaths.has(X))this._symlinkPaths.delete(X);let K=Z;if(this.options.cwd)K=O.relative(this.options.cwd,Z);if(this.options.awaitWriteFinish&&this._pendingWrites.has(K)){if(this._pendingWrites.get(K).cancelWait()===y.ADD)return}this._watched.delete(Z),this._watched.delete(X);let I=J?y.UNLINK_DIR:y.UNLINK;if(Y&&!this._isIgnored(Z))this._emit(I,Z);this._closePath(Z)}_closePath($){this._closeFile($);let G=O.dirname($);this._getWatchedDir(G).remove(O.basename($))}_closeFile($){let G=this._closers.get($);if(!G)return;G.forEach((J)=>J()),this._closers.delete($)}_addPathCloser($,G){if(!G)return;let J=this._closers.get($);if(!J)J=[],this._closers.set($,J);J.push(G)}_readdirp($,G){if(this.closed)return;let J={type:y.ALL,alwaysStat:!0,lstat:!0,...G,depth:0},Z=V3($,J);return this._streams.add(Z),Z.once(W3,()=>{Z=void 0}),Z.once(m2,()=>{if(Z)this._streams.delete(Z),Z=void 0}),Z}}function h0($,G={}){let J=new v3(G);return J.add($),J}import{createServer as e8}from"node:http";import{readFileSync as $7,existsSync as G7,readdirSync as H0,statSync as H4,mkdirSync as J7}from"node:fs";import{join as Q1,basename as u9}from"node:path";var r8=s(P9(),1),a8=s(a2(),1),t8=s(e2(),1),Q4=s(a0(),1),N4=s(f9(),1);var e0=s(f1(),1),b9=process.env.DASHBOARD_PORT?parseInt(process.env.DASHBOARD_PORT):9847;function Z7(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return Q1($,".serena","memories");return Q1(process.cwd(),".serena","memories")}function I0($){try{return $7($,"utf-8")}catch{return""}}function X7($){try{let G=H0($);if(G.includes("orchestrator-session.md"))return Q1($,"orchestrator-session.md");let J=G.filter((Z)=>/^session-.*\.md$/.test(Z)).map((Z)=>({name:Z,mtime:H4(Q1($,Z)).mtimeMs})).sort((Z,X)=>X.mtime-Z.mtime);if(J.length>0)return Q1($,J[0].name)}catch{}return null}function z7($){let G=X7($);if(!G)return{id:"N/A",status:"UNKNOWN"};let J=I0(G);if(!J)return{id:"N/A",status:"UNKNOWN"};let Z=(J.match(/session-id:\s*(.+)/i)||[])[1]||(J.match(/# Session:\s*(.+)/i)||[])[1]||J.match(/(session-\d{8}-\d{6})/)?.[1]||u9(G,".md")||"N/A",X="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(J))X="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(J))X="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(J))X="FAILED";else if(/Step \d+:.*\[/i.test(J))X="RUNNING";return{id:Z.trim(),status:X}}function Q7($){let G=I0(Q1($,"task-board.md"));if(!G)return[];let J=[],Z=G.split(`
|
|
114
|
+
`}}}}).prompt();var M=s(f1(),1);import{existsSync as m,mkdirSync as n1,readFileSync as v1,writeFileSync as g1,readdirSync as p1}from"node:fs";import{execSync as h}from"node:child_process";import{dirname as G2,join as u}from"node:path";import{createHash as C7}from"node:crypto";async function f2($,G,{concurrency:J=Number.POSITIVE_INFINITY,stopOnError:Z=!0,signal:X}={}){return new Promise((z,N)=>{if($[Symbol.iterator]===void 0&&$[Symbol.asyncIterator]===void 0)throw TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof $})`);if(typeof G!=="function")throw TypeError("Mapper function is required");if(!(Number.isSafeInteger(J)&&J>=1||J===Number.POSITIVE_INFINITY))throw TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${J}\` (${typeof J})`);let Q=[],Y=[],K=new Map,I=!1,H=!1,B=!1,j=0,U=0,q=$[Symbol.iterator]===void 0?$[Symbol.asyncIterator]():$[Symbol.iterator](),R=()=>{L(X.reason)},x=()=>{X?.removeEventListener("abort",R)},T=(A)=>{z(A),x()},L=(A)=>{I=!0,H=!0,N(A),x()};if(X){if(X.aborted)L(X.reason);X.addEventListener("abort",R,{once:!0})}let C=async()=>{if(H)return;let A=await q.next(),F=U;if(U++,A.done){if(B=!0,j===0&&!H){if(!Z&&Y.length>0){L(AggregateError(Y));return}if(H=!0,K.size===0){T(Q);return}let V=[];for(let[W,k]of Q.entries()){if(K.get(W)===H3)continue;V.push(k)}T(V)}return}j++,(async()=>{try{let V=await A.value;if(H)return;let W=await G(V,F);if(W===H3)K.set(F,W);Q[F]=W,j--,await C()}catch(V){if(Z)L(V);else{Y.push(V),j--;try{await C()}catch(W){L(W)}}}})()};(async()=>{for(let A=0;A<J;A++){try{await C()}catch(F){L(F);break}if(B||I)break}})()})}var H3=Symbol("skip");import{stat as U6}from"fs";import{stat as _6,readdir as j6}from"fs/promises";import{EventEmitter as R6}from"events";import*as O from"path";import{stat as k5,lstat as I3,readdir as h5,realpath as m5}from"node:fs/promises";import{Readable as d5}from"node:stream";import{resolve as q3,relative as l5,join as c5,sep as p5}from"node:path";var o={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},b2={root:".",fileFilter:($)=>!0,directoryFilter:($)=>!0,type:o.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(b2);var j3="READDIRP_RECURSIVE_ERROR",n5=new Set(["ENOENT","EPERM","EACCES","ELOOP",j3]),B3=[o.DIR_TYPE,o.EVERYTHING_TYPE,o.FILE_DIR_TYPE,o.FILE_TYPE],i5=new Set([o.DIR_TYPE,o.EVERYTHING_TYPE,o.FILE_DIR_TYPE]),s5=new Set([o.EVERYTHING_TYPE,o.FILE_DIR_TYPE,o.FILE_TYPE]),o5=($)=>n5.has($.code),r5=process.platform==="win32",U3=($)=>!0,_3=($)=>{if($===void 0)return U3;if(typeof $==="function")return $;if(typeof $==="string"){let G=$.trim();return(J)=>J.basename===G}if(Array.isArray($)){let G=$.map((J)=>J.trim());return(J)=>G.some((Z)=>J.basename===Z)}return U3};class R3 extends d5{constructor($={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:$.highWaterMark});let G={...b2,...$},{root:J,type:Z}=G;this._fileFilter=_3(G.fileFilter),this._directoryFilter=_3(G.directoryFilter);let X=G.lstat?I3:k5;if(r5)this._stat=(z)=>X(z,{bigint:!0});else this._stat=X;this._maxDepth=G.depth??b2.depth,this._wantsDir=Z?i5.has(Z):!1,this._wantsFile=Z?s5.has(Z):!1,this._wantsEverything=Z===o.EVERYTHING_TYPE,this._root=q3(J),this._isDirent=!G.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(J,1)],this.reading=!1,this.parent=void 0}async _read($){if(this.reading)return;this.reading=!0;try{while(!this.destroyed&&$>0){let G=this.parent,J=G&&G.files;if(J&&J.length>0){let{path:Z,depth:X}=G,z=J.splice(0,$).map((Q)=>this._formatEntry(Q,Z)),N=await Promise.all(z);for(let Q of N){if(!Q)continue;if(this.destroyed)return;let Y=await this._getEntryType(Q);if(Y==="directory"&&this._directoryFilter(Q)){if(X<=this._maxDepth)this.parents.push(this._exploreDir(Q.fullPath,X+1));if(this._wantsDir)this.push(Q),$--}else if((Y==="file"||this._includeAsFile(Q))&&this._fileFilter(Q)){if(this._wantsFile)this.push(Q),$--}}}else{let Z=this.parents.pop();if(!Z){this.push(null);break}if(this.parent=await Z,this.destroyed)return}}}catch(G){this.destroy(G)}finally{this.reading=!1}}async _exploreDir($,G){let J;try{J=await h5($,this._rdOptions)}catch(Z){this._onError(Z)}return{files:J,depth:G,path:$}}async _formatEntry($,G){let J,Z=this._isDirent?$.name:$;try{let X=q3(c5(G,Z));J={path:l5(this._root,X),fullPath:X,basename:Z},J[this._statsProp]=this._isDirent?$:await this._stat(X)}catch(X){this._onError(X);return}return J}_onError($){if(o5($)&&!this.destroyed)this.emit("warn",$);else this.destroy($)}async _getEntryType($){if(!$&&this._statsProp in $)return"";let G=$[this._statsProp];if(G.isFile())return"file";if(G.isDirectory())return"directory";if(G&&G.isSymbolicLink()){let J=$.fullPath;try{let Z=await m5(J),X=await I3(Z);if(X.isFile())return"file";if(X.isDirectory()){let z=Z.length;if(J.startsWith(Z)&&J.substr(z,1)===p5){let N=Error(`Circular symlink detected: "${J}" points to "${Z}"`);return N.code=j3,this._onError(N)}return"directory"}}catch(Z){return this._onError(Z),""}}}_includeAsFile($){let G=$&&$[this._statsProp];return G&&this._wantsEverything&&!G.isDirectory()}}function M3($,G={}){let J=G.entryType||G.type;if(J==="both")J=o.FILE_DIR_TYPE;if(J)G.type=J;if(!$)throw Error("readdirp: root argument is required. Usage: readdirp(root, options)");else if(typeof $!=="string")throw TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");else if(J&&!B3.includes(J))throw Error(`readdirp: Invalid type passed. Use one of ${B3.join(", ")}`);return G.root=$,new R3(G)}import{watchFile as a5,unwatchFile as V3,watch as t5}from"fs";import{open as e5,stat as x3,lstat as $6,realpath as u2}from"fs/promises";import*as v from"path";import{type as G6}from"os";var J6="data",m2="end",W3="close",b0=()=>{};var u0=process.platform,d2=u0==="win32",Z6=u0==="darwin",X6=u0==="linux",z6=u0==="freebsd",L3=G6()==="OS400",w={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},X1=w,Q6="watch",N6={lstat:$6,stat:x3},P1="listeners",v0="errHandlers",b1="rawEmitters",Y6=[P1,v0,b1],K6=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),H6=($)=>K6.has(v.extname($).slice(1).toLowerCase()),h2=($,G)=>{if($ instanceof Set)$.forEach(G);else G($)},$0=($,G,J)=>{let Z=$[G];if(!(Z instanceof Set))$[G]=Z=new Set([Z]);Z.add(J)},I6=($)=>(G)=>{let J=$[G];if(J instanceof Set)J.clear();else delete $[G]},G0=($,G,J)=>{let Z=$[G];if(Z instanceof Set)Z.delete(J);else if(Z===J)delete $[G]},A3=($)=>$ instanceof Set?$.size===0:!$,g0=new Map;function T3($,G,J,Z,X){let z=(N,Q)=>{if(J($),X(N,Q,{watchedPath:$}),Q&&$!==Q)f0(v.resolve($,Q),P1,v.join($,Q))};try{return t5($,{persistent:G.persistent},z)}catch(N){Z(N);return}}var f0=($,G,J,Z,X)=>{let z=g0.get($);if(!z)return;h2(z[G],(N)=>{N(J,Z,X)})},q6=($,G,J,Z)=>{let{listener:X,errHandler:z,rawEmitter:N}=Z,Q=g0.get(G),Y;if(!J.persistent){if(Y=T3($,J,X,z,N),!Y)return;return Y.close.bind(Y)}if(Q)$0(Q,P1,X),$0(Q,v0,z),$0(Q,b1,N);else{if(Y=T3($,J,f0.bind(null,G,P1),z,f0.bind(null,G,b1)),!Y)return;Y.on(X1.ERROR,async(K)=>{let I=f0.bind(null,G,v0);if(Q)Q.watcherUnusable=!0;if(d2&&K.code==="EPERM")try{await(await e5($,"r")).close(),I(K)}catch(H){}else I(K)}),Q={listeners:X,errHandlers:z,rawEmitters:N,watcher:Y},g0.set(G,Q)}return()=>{if(G0(Q,P1,X),G0(Q,v0,z),G0(Q,b1,N),A3(Q.listeners))Q.watcher.close(),g0.delete(G),Y6.forEach(I6(Q)),Q.watcher=void 0,Object.freeze(Q)}},k2=new Map,B6=($,G,J,Z)=>{let{listener:X,rawEmitter:z}=Z,N=k2.get(G),Q=N&&N.options;if(Q&&(Q.persistent<J.persistent||Q.interval>J.interval))V3(G),N=void 0;if(N)$0(N,P1,X),$0(N,b1,z);else N={listeners:X,rawEmitters:z,options:J,watcher:a5(G,J,(Y,K)=>{h2(N.rawEmitters,(H)=>{H(X1.CHANGE,G,{curr:Y,prev:K})});let I=Y.mtimeMs;if(Y.size!==K.size||I>K.mtimeMs||I===0)h2(N.listeners,(H)=>H($,Y))})},k2.set(G,N);return()=>{if(G0(N,P1,X),G0(N,b1,z),A3(N.listeners))k2.delete(G),V3(G),N.options=N.watcher=void 0,Object.freeze(N)}};class l2{constructor($){this.fsw=$,this._boundHandleError=(G)=>$._handleError(G)}_watchWithNodeFs($,G){let J=this.fsw.options,Z=v.dirname($),X=v.basename($);this.fsw._getWatchedDir(Z).add(X);let N=v.resolve($),Q={persistent:J.persistent};if(!G)G=b0;let Y;if(J.usePolling){let K=J.interval!==J.binaryInterval;Q.interval=K&&H6(X)?J.binaryInterval:J.interval,Y=B6($,N,Q,{listener:G,rawEmitter:this.fsw._emitRaw})}else Y=q6($,N,Q,{listener:G,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return Y}_handleFile($,G,J){if(this.fsw.closed)return;let Z=v.dirname($),X=v.basename($),z=this.fsw._getWatchedDir(Z),N=G;if(z.has(X))return;let Q=async(K,I)=>{if(!this.fsw._throttle(Q6,$,5))return;if(!I||I.mtimeMs===0)try{let H=await x3($);if(this.fsw.closed)return;let{atimeMs:B,mtimeMs:j}=H;if(!B||B<=j||j!==N.mtimeMs)this.fsw._emit(X1.CHANGE,$,H);if((Z6||X6||z6)&&N.ino!==H.ino){this.fsw._closeFile(K),N=H;let U=this._watchWithNodeFs($,Q);if(U)this.fsw._addPathCloser(K,U)}else N=H}catch(H){this.fsw._remove(Z,X)}else if(z.has(X)){let{atimeMs:H,mtimeMs:B}=I;if(!H||H<=B||B!==N.mtimeMs)this.fsw._emit(X1.CHANGE,$,I);N=I}},Y=this._watchWithNodeFs($,Q);if(!(J&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored($)){if(!this.fsw._throttle(X1.ADD,$,0))return;this.fsw._emit(X1.ADD,$,G)}return Y}async _handleSymlink($,G,J,Z){if(this.fsw.closed)return;let X=$.fullPath,z=this.fsw._getWatchedDir(G);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let N;try{N=await u2(J)}catch(Q){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;if(z.has(Z)){if(this.fsw._symlinkPaths.get(X)!==N)this.fsw._symlinkPaths.set(X,N),this.fsw._emit(X1.CHANGE,J,$.stats)}else z.add(Z),this.fsw._symlinkPaths.set(X,N),this.fsw._emit(X1.ADD,J,$.stats);return this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(X))return!0;this.fsw._symlinkPaths.set(X,!0)}_handleRead($,G,J,Z,X,z,N){if($=v.join($,""),N=this.fsw._throttle("readdir",$,1000),!N)return;let Q=this.fsw._getWatchedDir(J.path),Y=new Set,K=this.fsw._readdirp($,{fileFilter:(I)=>J.filterPath(I),directoryFilter:(I)=>J.filterDir(I)});if(!K)return;return K.on(J6,async(I)=>{if(this.fsw.closed){K=void 0;return}let H=I.path,B=v.join($,H);if(Y.add(H),I.stats.isSymbolicLink()&&await this._handleSymlink(I,$,B,H))return;if(this.fsw.closed){K=void 0;return}if(H===Z||!Z&&!Q.has(H))this.fsw._incrReadyCount(),B=v.join(X,v.relative(X,B)),this._addToNodeFs(B,G,J,z+1)}).on(X1.ERROR,this._boundHandleError),new Promise((I,H)=>{if(!K)return H();K.once(m2,()=>{if(this.fsw.closed){K=void 0;return}let B=N?N.clear():!1;if(I(void 0),Q.getChildren().filter((j)=>{return j!==$&&!Y.has(j)}).forEach((j)=>{this.fsw._remove($,j)}),K=void 0,B)this._handleRead($,!1,J,Z,X,z,N)})})}async _handleDir($,G,J,Z,X,z,N){let Q=this.fsw._getWatchedDir(v.dirname($)),Y=Q.has(v.basename($));if(!(J&&this.fsw.options.ignoreInitial)&&!X&&!Y)this.fsw._emit(X1.ADD_DIR,$,G);Q.add(v.basename($)),this.fsw._getWatchedDir($);let K,I,H=this.fsw.options.depth;if((H==null||Z<=H)&&!this.fsw._symlinkPaths.has(N)){if(!X){if(await this._handleRead($,J,z,X,$,Z,K),this.fsw.closed)return}I=this._watchWithNodeFs($,(B,j)=>{if(j&&j.mtimeMs===0)return;this._handleRead(B,!1,z,X,$,Z,K)})}return I}async _addToNodeFs($,G,J,Z,X){let z=this.fsw._emitReady;if(this.fsw._isIgnored($)||this.fsw.closed)return z(),!1;let N=this.fsw._getWatchHelpers($);if(J)N.filterPath=(Q)=>J.filterPath(Q),N.filterDir=(Q)=>J.filterDir(Q);try{let Q=await N6[N.statMethod](N.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(N.watchPath,Q))return z(),!1;let Y=this.fsw.options.followSymlinks,K;if(Q.isDirectory()){let I=v.resolve($),H=Y?await u2($):$;if(this.fsw.closed)return;if(K=await this._handleDir(N.watchPath,Q,G,Z,X,N,H),this.fsw.closed)return;if(I!==H&&H!==void 0)this.fsw._symlinkPaths.set(I,H)}else if(Q.isSymbolicLink()){let I=Y?await u2($):$;if(this.fsw.closed)return;let H=v.dirname(N.watchPath);if(this.fsw._getWatchedDir(H).add(N.watchPath),this.fsw._emit(X1.ADD,N.watchPath,Q),K=await this._handleDir(H,Q,G,Z,$,N,I),this.fsw.closed)return;if(I!==void 0)this.fsw._symlinkPaths.set(v.resolve($),I)}else K=this._handleFile(N.watchPath,Q,G);if(z(),K)this.fsw._addPathCloser($,K);return!1}catch(Q){if(this.fsw._handleError(Q))return z(),$}}}/*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */var c2="/",M6="//",E3=".",V6="..",T6="string",x6=/\\/g,D3=/\/\//,W6=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,L6=/^\.[/\\]/;function k0($){return Array.isArray($)?$:[$]}var p2=($)=>typeof $==="object"&&$!==null&&!($ instanceof RegExp);function A6($){if(typeof $==="function")return $;if(typeof $==="string")return(G)=>$===G;if($ instanceof RegExp)return(G)=>$.test(G);if(typeof $==="object"&&$!==null)return(G)=>{if($.path===G)return!0;if($.recursive){let J=O.relative($.path,G);if(!J)return!1;return!J.startsWith("..")&&!O.isAbsolute(J)}return!1};return()=>!1}function D6($){if(typeof $!=="string")throw Error("string expected");$=O.normalize($),$=$.replace(/\\/g,"/");let G=!1;if($.startsWith("//"))G=!0;let J=/\/\//;while($.match(J))$=$.replace(J,"/");if(G)$="/"+$;return $}function C3($,G,J){let Z=D6(G);for(let X=0;X<$.length;X++){let z=$[X];if(z(Z,J))return!0}return!1}function C6($,G){if($==null)throw TypeError("anymatch: specify first argument");let Z=k0($).map((X)=>A6(X));if(G==null)return(X,z)=>{return C3(Z,X,z)};return C3(Z,G)}var O3=($)=>{let G=k0($).flat();if(!G.every((J)=>typeof J===T6))throw TypeError(`Non-string provided as watch path: ${G}`);return G.map(S3)},F3=($)=>{let G=$.replace(x6,c2),J=!1;if(G.startsWith(M6))J=!0;while(G.match(D3))G=G.replace(D3,c2);if(J)G=c2+G;return G},S3=($)=>F3(O.normalize(F3($))),P3=($="")=>(G)=>{if(typeof G==="string")return S3(O.isAbsolute(G)?G:O.join($,G));else return G},O6=($,G)=>{if(O.isAbsolute($))return $;return O.join(G,$)},F6=Object.freeze(new Set);class w3{constructor($,G){this.path=$,this._removeWatcher=G,this.items=new Set}add($){let{items:G}=this;if(!G)return;if($!==E3&&$!==V6)G.add($)}async remove($){let{items:G}=this;if(!G)return;if(G.delete($),G.size>0)return;let J=this.path;try{await j6(J)}catch(Z){if(this._removeWatcher)this._removeWatcher(O.dirname(J),O.basename(J))}}has($){let{items:G}=this;if(!G)return;return G.has($)}getChildren(){let{items:$}=this;if(!$)return[];return[...$.values()]}dispose(){this.items.clear(),this.path="",this._removeWatcher=b0,this.items=F6,Object.freeze(this)}}var P6="stat",E6="lstat";class y3{constructor($,G,J){this.fsw=J;let Z=$;this.path=$=$.replace(L6,""),this.watchPath=Z,this.fullWatchPath=O.resolve(Z),this.dirParts=[],this.dirParts.forEach((X)=>{if(X.length>1)X.pop()}),this.followSymlinks=G,this.statMethod=G?P6:E6}entryPath($){return O.join(this.watchPath,O.relative(this.watchPath,$.fullPath))}filterPath($){let{stats:G}=$;if(G&&G.isSymbolicLink())return this.filterDir($);let J=this.entryPath($);return this.fsw._isntIgnored(J,G)&&this.fsw._hasReadPermissions(G)}filterDir($){return this.fsw._isntIgnored(this.entryPath($),$.stats)}}class v3 extends R6{constructor($={}){super();this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let G=$.awaitWriteFinish,J={stabilityThreshold:2000,pollInterval:100},Z={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...$,ignored:$.ignored?k0($.ignored):k0([]),awaitWriteFinish:G===!0?J:typeof G==="object"?{...J,...G}:!1};if(L3)Z.usePolling=!0;if(Z.atomic===void 0)Z.atomic=!Z.usePolling;let X=process.env.CHOKIDAR_USEPOLLING;if(X!==void 0){let Q=X.toLowerCase();if(Q==="false"||Q==="0")Z.usePolling=!1;else if(Q==="true"||Q==="1")Z.usePolling=!0;else Z.usePolling=!!Q}let z=process.env.CHOKIDAR_INTERVAL;if(z)Z.interval=Number.parseInt(z,10);let N=0;this._emitReady=()=>{if(N++,N>=this._readyCount)this._emitReady=b0,this._readyEmitted=!0,process.nextTick(()=>this.emit(w.READY))},this._emitRaw=(...Q)=>this.emit(w.RAW,...Q),this._boundRemove=this._remove.bind(this),this.options=Z,this._nodeFsHandler=new l2(this),Object.freeze(Z)}_addIgnoredPath($){if(p2($)){for(let G of this._ignoredPaths)if(p2(G)&&G.path===$.path&&G.recursive===$.recursive)return}this._ignoredPaths.add($)}_removeIgnoredPath($){if(this._ignoredPaths.delete($),typeof $==="string"){for(let G of this._ignoredPaths)if(p2(G)&&G.path===$)this._ignoredPaths.delete(G)}}add($,G,J){let{cwd:Z}=this.options;this.closed=!1,this._closePromise=void 0;let X=O3($);if(Z)X=X.map((z)=>{return O6(z,Z)});if(X.forEach((z)=>{this._removeIgnoredPath(z)}),this._userIgnored=void 0,!this._readyCount)this._readyCount=0;return this._readyCount+=X.length,Promise.all(X.map(async(z)=>{let N=await this._nodeFsHandler._addToNodeFs(z,!J,void 0,0,G);if(N)this._emitReady();return N})).then((z)=>{if(this.closed)return;z.forEach((N)=>{if(N)this.add(O.dirname(N),O.basename(G||N))})}),this}unwatch($){if(this.closed)return this;let G=O3($),{cwd:J}=this.options;return G.forEach((Z)=>{if(!O.isAbsolute(Z)&&!this._closers.has(Z)){if(J)Z=O.join(J,Z);Z=O.resolve(Z)}if(this._closePath(Z),this._addIgnoredPath(Z),this._watched.has(Z))this._addIgnoredPath({path:Z,recursive:!0});this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let $=[];return this._closers.forEach((G)=>G.forEach((J)=>{let Z=J();if(Z instanceof Promise)$.push(Z)})),this._streams.forEach((G)=>G.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach((G)=>G.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=$.length?Promise.all($).then(()=>{return}):Promise.resolve(),this._closePromise}getWatched(){let $={};return this._watched.forEach((G,J)=>{let X=(this.options.cwd?O.relative(this.options.cwd,J):J)||E3;$[X]=G.getChildren().sort()}),$}emitWithAll($,G){if(this.emit($,...G),$!==w.ERROR)this.emit(w.ALL,$,...G)}async _emit($,G,J){if(this.closed)return;let Z=this.options;if(d2)G=O.normalize(G);if(Z.cwd)G=O.relative(Z.cwd,G);let X=[G];if(J!=null)X.push(J);let z=Z.awaitWriteFinish,N;if(z&&(N=this._pendingWrites.get(G)))return N.lastChange=new Date,this;if(Z.atomic){if($===w.UNLINK)return this._pendingUnlinks.set(G,[$,...X]),setTimeout(()=>{this._pendingUnlinks.forEach((Q,Y)=>{this.emit(...Q),this.emit(w.ALL,...Q),this._pendingUnlinks.delete(Y)})},typeof Z.atomic==="number"?Z.atomic:100),this;if($===w.ADD&&this._pendingUnlinks.has(G))$=w.CHANGE,this._pendingUnlinks.delete(G)}if(z&&($===w.ADD||$===w.CHANGE)&&this._readyEmitted){let Q=(Y,K)=>{if(Y)$=w.ERROR,X[0]=Y,this.emitWithAll($,X);else if(K){if(X.length>1)X[1]=K;else X.push(K);this.emitWithAll($,X)}};return this._awaitWriteFinish(G,z.stabilityThreshold,$,Q),this}if($===w.CHANGE){if(!this._throttle(w.CHANGE,G,50))return this}if(Z.alwaysStat&&J===void 0&&($===w.ADD||$===w.ADD_DIR||$===w.CHANGE)){let Q=Z.cwd?O.join(Z.cwd,G):G,Y;try{Y=await _6(Q)}catch(K){}if(!Y||this.closed)return;X.push(Y)}return this.emitWithAll($,X),this}_handleError($){let G=$&&$.code;if($&&G!=="ENOENT"&&G!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||G!=="EPERM"&&G!=="EACCES"))this.emit(w.ERROR,$);return $||this.closed}_throttle($,G,J){if(!this._throttled.has($))this._throttled.set($,new Map);let Z=this._throttled.get($);if(!Z)throw Error("invalid throttle");let X=Z.get(G);if(X)return X.count++,!1;let z,N=()=>{let Y=Z.get(G),K=Y?Y.count:0;if(Z.delete(G),clearTimeout(z),Y)clearTimeout(Y.timeoutObject);return K};z=setTimeout(N,J);let Q={timeoutObject:z,clear:N,count:0};return Z.set(G,Q),Q}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish($,G,J,Z){let X=this.options.awaitWriteFinish;if(typeof X!=="object")return;let z=X.pollInterval,N,Q=$;if(this.options.cwd&&!O.isAbsolute($))Q=O.join(this.options.cwd,$);let Y=new Date,K=this._pendingWrites;function I(H){U6(Q,(B,j)=>{if(B||!K.has($)){if(B&&B.code!=="ENOENT")Z(B);return}let U=Number(new Date);if(H&&j.size!==H.size)K.get($).lastChange=U;let q=K.get($);if(U-q.lastChange>=G)K.delete($),Z(void 0,j);else N=setTimeout(I,z,j)})}if(!K.has($))K.set($,{lastChange:Y,cancelWait:()=>{return K.delete($),clearTimeout(N),J}}),N=setTimeout(I,z)}_isIgnored($,G){if(this.options.atomic&&W6.test($))return!0;if(!this._userIgnored){let{cwd:J}=this.options,X=(this.options.ignored||[]).map(P3(J)),N=[...[...this._ignoredPaths].map(P3(J)),...X];this._userIgnored=C6(N,void 0)}return this._userIgnored($,G)}_isntIgnored($,G){return!this._isIgnored($,G)}_getWatchHelpers($){return new y3($,this.options.followSymlinks,this)}_getWatchedDir($){let G=O.resolve($);if(!this._watched.has(G))this._watched.set(G,new w3(G,this._boundRemove));return this._watched.get(G)}_hasReadPermissions($){if(this.options.ignorePermissionErrors)return!0;return Boolean(Number($.mode)&256)}_remove($,G,J){let Z=O.join($,G),X=O.resolve(Z);if(J=J!=null?J:this._watched.has(Z)||this._watched.has(X),!this._throttle("remove",Z,100))return;if(!J&&this._watched.size===1)this.add($,G,!0);this._getWatchedDir(Z).getChildren().forEach((H)=>this._remove(Z,H));let Q=this._getWatchedDir($),Y=Q.has(G);if(Q.remove(G),this._symlinkPaths.has(X))this._symlinkPaths.delete(X);let K=Z;if(this.options.cwd)K=O.relative(this.options.cwd,Z);if(this.options.awaitWriteFinish&&this._pendingWrites.has(K)){if(this._pendingWrites.get(K).cancelWait()===w.ADD)return}this._watched.delete(Z),this._watched.delete(X);let I=J?w.UNLINK_DIR:w.UNLINK;if(Y&&!this._isIgnored(Z))this._emit(I,Z);this._closePath(Z)}_closePath($){this._closeFile($);let G=O.dirname($);this._getWatchedDir(G).remove(O.basename($))}_closeFile($){let G=this._closers.get($);if(!G)return;G.forEach((J)=>J()),this._closers.delete($)}_addPathCloser($,G){if(!G)return;let J=this._closers.get($);if(!J)J=[],this._closers.set($,J);J.push(G)}_readdirp($,G){if(this.closed)return;let J={type:w.ALL,alwaysStat:!0,lstat:!0,...G,depth:0},Z=M3($,J);return this._streams.add(Z),Z.once(W3,()=>{Z=void 0}),Z.once(m2,()=>{if(Z)this._streams.delete(Z),Z=void 0}),Z}}function h0($,G={}){let J=new v3(G);return J.add($),J}import{createServer as e8}from"node:http";import{readFileSync as $7,existsSync as G7,readdirSync as H0,statSync as H4,mkdirSync as J7}from"node:fs";import{join as Q1,basename as u9}from"node:path";var r8=s(P9(),1),a8=s(a2(),1),t8=s(e2(),1),Q4=s(a0(),1),N4=s(f9(),1);var e0=s(f1(),1),b9=process.env.DASHBOARD_PORT?parseInt(process.env.DASHBOARD_PORT):9847;function Z7(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return Q1($,".serena","memories");return Q1(process.cwd(),".serena","memories")}function I0($){try{return $7($,"utf-8")}catch{return""}}function X7($){try{let G=H0($);if(G.includes("orchestrator-session.md"))return Q1($,"orchestrator-session.md");let J=G.filter((Z)=>/^session-.*\.md$/.test(Z)).map((Z)=>({name:Z,mtime:H4(Q1($,Z)).mtimeMs})).sort((Z,X)=>X.mtime-Z.mtime);if(J.length>0)return Q1($,J[0].name)}catch{}return null}function z7($){let G=X7($);if(!G)return{id:"N/A",status:"UNKNOWN"};let J=I0(G);if(!J)return{id:"N/A",status:"UNKNOWN"};let Z=(J.match(/session-id:\s*(.+)/i)||[])[1]||(J.match(/# Session:\s*(.+)/i)||[])[1]||J.match(/(session-\d{8}-\d{6})/)?.[1]||u9(G,".md")||"N/A",X="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(J))X="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(J))X="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(J))X="FAILED";else if(/Step \d+:.*\[/i.test(J))X="RUNNING";return{id:Z.trim(),status:X}}function Q7($){let G=I0(Q1($,"task-board.md"));if(!G)return[];let J=[],Z=G.split(`
|
|
115
115
|
`);for(let X of Z){if(!X.startsWith("|")||/^\|\s*-+/.test(X))continue;let z=X.split("|").map((N)=>N.trim()).filter(Boolean);if(z.length<2||/^agent$/i.test(z[0]))continue;J.push({agent:z[0]||"",status:z[1]||"pending",task:z[2]||""})}return J}function K4($,G){try{let J=H0($).filter((z)=>z.startsWith(`progress-${G}`)&&z.endsWith(".md")).sort().reverse();if(J.length===0)return null;let X=I0(Q1($,J[0])).match(/turn[:\s]*(\d+)/i);return X?parseInt(X[1],10):null}catch{return null}}function N7($){try{return H0($).filter((J)=>J.endsWith(".md")&&J!==".gitkeep").map((J)=>({name:J,mtime:H4(Q1($,J)).mtimeMs})).sort((J,Z)=>Z.mtime-J.mtime).slice(0,10).map((J)=>{let Z=J.name.replace(/^(progress|result|session|debug|task)-?/,"").replace(/[-_]agent/,"").replace(/[-_]completion/,"").replace(/\.md$/,"").replace(/[-_]/g," ").trim()||J.name.replace(/\.md$/,""),z=I0(Q1($,J.name)).split(`
|
|
116
116
|
`).map((Q)=>Q.trim()).filter((Q)=>Q&&!Q.startsWith("---")&&Q.length>3),N="";for(let Q=z.length-1;Q>=0;Q--){let Y=z[Q];if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(Y)){if(N=Y.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),N.length>5)break}}if(N.length>80)N=N.substring(0,77)+"...";return{agent:Z,message:N,file:J.name}}).filter((J)=>J.message)}catch{return[]}}function Y7($){let G=[],J=new Set;try{let Z=H0($).filter((X)=>X.endsWith(".md")&&X!==".gitkeep").map((X)=>({name:X,mtime:H4(Q1($,X)).mtimeMs})).sort((X,z)=>z.mtime-X.mtime);for(let X of Z){let z=I0(Q1($,X.name)),N=z.match(/\*\*Agent\*\*:\s*(.+)/i)||z.match(/Agent:\s*(.+)/i)||z.match(/^#+\s*(.+?)\s*Agent/im),Q=null;if(N)Q=N[1].trim();else if(/_agent|agent_|-agent/i.test(X.name))Q=X.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(Q&&!J.has(Q.toLowerCase())){J.add(Q.toLowerCase());let Y="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(z))Y="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(z))Y="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(z))Y="failed";let K=z.match(/## Task\s*\n+(.+)/i)||z.match(/\*\*Task\*\*:\s*(.+)/i),I=K?K[1].trim().substring(0,60):"";G.push({agent:Q,status:Y,task:I,turn:K4($,Q)})}}}catch{}return G}function Y4($){let G=z7($),Z=Q7($).map((X)=>({...X,turn:K4($,X.agent)}));if(Z.length===0)Z=Y7($);if(Z.length===0)try{let X=H0($).filter((z)=>z.startsWith("progress-")&&z.endsWith(".md"));for(let z of X){let N=z.replace(/^progress-/,"").replace(/\.md$/,"");Z.push({agent:N,status:"running",task:"",turn:K4($,N)})}}catch{}return{session:G,agents:Z,activity:N7($),memoriesDir:$,updatedAt:new Date().toISOString()}}var K7=`<!DOCTYPE html>
|
|
117
117
|
<html lang="en">
|
|
@@ -173,33 +173,32 @@ ${Q}
|
|
|
173
173
|
</html>`;function k9(){let $=Z7();if(!G7($))J7($,{recursive:!0});let G=e8((N,Q)=>{if(N.url==="/api/state")Q.writeHead(200,{"Content-Type":"application/json"}),Q.end(JSON.stringify(Y4($)));else Q.writeHead(200,{"Content-Type":"text/html"}),Q.end(K7)}),J=new N4.default({server:G}),Z=null;function X(N,Q){if(Z)clearTimeout(Z);Z=setTimeout(()=>{let Y=JSON.stringify({type:"update",event:N,file:Q,data:Y4($)});J.clients.forEach((K)=>{if(K.readyState===Q4.default.OPEN)K.send(Y)})},100)}let z=h0($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});z.on("all",(N,Q)=>X(N,u9(Q))),J.on("connection",(N)=>{N.send(JSON.stringify({type:"full",data:Y4($)})),N.on("error",()=>N.terminate())}),process.on("SIGINT",()=>{console.log(`
|
|
174
174
|
Shutting down...`),z.close(),J.clients.forEach((N)=>N.terminate()),J.close(()=>G.close(()=>process.exit(0))),setTimeout(()=>process.exit(1),3000).unref()}),process.on("SIGTERM",()=>process.emit("SIGINT")),G.listen(b9,()=>{console.log(e0.default.magenta(`
|
|
175
175
|
\uD83D\uDEF8 Serena Memory Dashboard`)),console.log(e0.default.white(` http://localhost:${b9}`)),console.log(e0.default.dim(` Watching: ${$}
|
|
176
|
-
`))})}var c=s(f1(),1);import{readFileSync as H7,existsSync as I7,readdirSync as q0,statSync as q4,mkdirSync as q7}from"node:fs";import{join as N1,basename as B7}from"node:path";var U7="●",_7="✓",j7="✗",R7="○",
|
|
176
|
+
`))})}var c=s(f1(),1);import{readFileSync as H7,existsSync as I7,readdirSync as q0,statSync as q4,mkdirSync as q7}from"node:fs";import{join as N1,basename as B7}from"node:path";var U7="●",_7="✓",j7="✗",R7="○",M7="◌";function V7(){if(process.env.MEMORIES_DIR)return process.env.MEMORIES_DIR;let $=process.argv[3];if($)return N1($,".serena","memories");return N1(process.cwd(),".serena","memories")}function B0($){try{return H7($,"utf-8")}catch{return""}}function T7($){try{let G=q0($);if(G.includes("orchestrator-session.md"))return N1($,"orchestrator-session.md");let J=G.filter((Z)=>/^session-.*\.md$/.test(Z)).map((Z)=>({name:Z,mtime:q4(N1($,Z)).mtimeMs})).sort((Z,X)=>X.mtime-Z.mtime);if(J.length>0&&J[0])return N1($,J[0].name)}catch{}return null}function x7($){let G=T7($);if(!G)return{id:"N/A",status:"UNKNOWN"};let J=B0(G);if(!J)return{id:"N/A",status:"UNKNOWN"};let Z=(J.match(/session-id:\s*(.+)/i)||[])[1]||(J.match(/# Session:\s*(.+)/i)||[])[1]||J.match(/(session-\d{8}-\d{6})/)?.[1]||B7(G,".md"),X="UNKNOWN";if(/IN PROGRESS|RUNNING|## Active|\[IN PROGRESS\]/i.test(J))X="RUNNING";else if(/COMPLETED|DONE|## Completed|\[COMPLETED\]/i.test(J))X="COMPLETED";else if(/FAILED|ERROR|## Failed|\[FAILED\]/i.test(J))X="FAILED";else if(/Step \d+:.*\[/i.test(J))X="RUNNING";return{id:(Z||"N/A").trim(),status:X}}function W7($){let G=B0(N1($,"task-board.md"));if(!G)return[];let J=[],Z=G.split(`
|
|
177
177
|
`);for(let X of Z){if(!X.startsWith("|")||/^\|\s*-+/.test(X))continue;let z=X.split("|").map((K)=>K.trim()).filter(Boolean),N=z[0];if(z.length<2||!N||/^agent$/i.test(N))continue;let Q=z[1],Y=z[2];J.push({agent:N,status:Q||"pending",task:Y||""})}return J}function I4($,G){try{let J=q0($).filter((z)=>z.startsWith(`progress-${G}`)&&z.endsWith(".md")).sort().reverse();if(J.length===0||!J[0])return null;let X=B0(N1($,J[0])).match(/turn[:\s]*(\d+)/i);return X&&X[1]?parseInt(X[1],10):null}catch{return null}}function L7($){try{let G=q0($).filter((Z)=>Z.endsWith(".md")&&Z!==".gitkeep").map((Z)=>({name:Z,mtime:q4(N1($,Z)).mtimeMs})).sort((Z,X)=>X.mtime-Z.mtime).slice(0,5),J=[];for(let Z of G){let X=Z.name.replace(/^(progress|result|session|debug|task)-?/,"").replace(/[-_]agent/,"").replace(/[-_]completion/,"").replace(/\.md$/,"").replace(/[-_]/g," ").trim()||Z.name.replace(/\.md$/,""),N=B0(N1($,Z.name)).split(`
|
|
178
|
-
`).map((Y)=>Y.trim()).filter((Y)=>Y&&!Y.startsWith("---")&&Y.length>3),Q="";for(let Y=N.length-1;Y>=0;Y--){let K=N[Y];if(!K)continue;if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(K)){if(Q=K.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),Q.length>5)break}}if(Q.length>52)Q=Q.substring(0,49)+"...";if(Q)J.push({agent:X,message:Q})}return J}catch{return[]}}function A7($){let G=[],J=new Set;try{let Z=q0($).filter((X)=>X.endsWith(".md")&&X!==".gitkeep").map((X)=>({name:X,mtime:q4(N1($,X)).mtimeMs})).sort((X,z)=>z.mtime-X.mtime);for(let X of Z){let z=B0(N1($,X.name)),N=z.match(/\*\*Agent\*\*:\s*(.+)/i)||z.match(/Agent:\s*(.+)/i)||z.match(/^#+\s*(.+?)\s*Agent/im),Q=null;if(N&&N[1])Q=N[1].trim();else if(/_agent|agent_|-agent/i.test(X.name))Q=X.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(Q&&!J.has(Q.toLowerCase())){J.add(Q.toLowerCase());let Y="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(z))Y="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(z))Y="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(z))Y="failed";let K=z.match(/## Task\s*\n+(.+)/i)||z.match(/\*\*Task\*\*:\s*(.+)/i),I=K&&K[1]?K[1].trim().substring(0,20):"";G.push({agent:Q,status:Y,task:I,turn:I4($,Q)})}}}catch{}return G}function D7($){let G=$.toLowerCase();if(["running","active","in_progress","in-progress"].includes(G))return`${c.default.green(U7)} running`;else if(["completed","done","finished"].includes(G))return`${c.default.cyan(_7)} completed`;else if(["failed","error"].includes(G))return`${c.default.red(j7)} failed`;else if(["blocked","waiting"].includes(G))return`${c.default.yellow(R7)} blocked`;return`${c.default.dim(
|
|
178
|
+
`).map((Y)=>Y.trim()).filter((Y)=>Y&&!Y.startsWith("---")&&Y.length>3),Q="";for(let Y=N.length-1;Y>=0;Y--){let K=N[Y];if(!K)continue;if(/^\*\*|^#+|^-|^\d+\.|Status|Result|Action|Step/i.test(K)){if(Q=K.replace(/^[#*\-\d.]+\s*/,"").replace(/\*\*/g,"").trim(),Q.length>5)break}}if(Q.length>52)Q=Q.substring(0,49)+"...";if(Q)J.push({agent:X,message:Q})}return J}catch{return[]}}function A7($){let G=[],J=new Set;try{let Z=q0($).filter((X)=>X.endsWith(".md")&&X!==".gitkeep").map((X)=>({name:X,mtime:q4(N1($,X)).mtimeMs})).sort((X,z)=>z.mtime-X.mtime);for(let X of Z){let z=B0(N1($,X.name)),N=z.match(/\*\*Agent\*\*:\s*(.+)/i)||z.match(/Agent:\s*(.+)/i)||z.match(/^#+\s*(.+?)\s*Agent/im),Q=null;if(N&&N[1])Q=N[1].trim();else if(/_agent|agent_|-agent/i.test(X.name))Q=X.name.replace(/\.md$/,"").replace(/[-_]completion|[-_]progress|[-_]result/gi,"").replace(/[-_]/g," ").trim();if(Q&&!J.has(Q.toLowerCase())){J.add(Q.toLowerCase());let Y="unknown";if(/\[COMPLETED\]|## Completed|## Results/i.test(z))Y="completed";else if(/\[IN PROGRESS\]|## Progress|IN PROGRESS/i.test(z))Y="running";else if(/\[FAILED\]|## Failed|ERROR/i.test(z))Y="failed";let K=z.match(/## Task\s*\n+(.+)/i)||z.match(/\*\*Task\*\*:\s*(.+)/i),I=K&&K[1]?K[1].trim().substring(0,20):"";G.push({agent:Q,status:Y,task:I,turn:I4($,Q)})}}}catch{}return G}function D7($){let G=$.toLowerCase();if(["running","active","in_progress","in-progress"].includes(G))return`${c.default.green(U7)} running`;else if(["completed","done","finished"].includes(G))return`${c.default.cyan(_7)} completed`;else if(["failed","error"].includes(G))return`${c.default.red(j7)} failed`;else if(["blocked","waiting"].includes(G))return`${c.default.yellow(R7)} blocked`;return`${c.default.dim(M7)} pending`}function h9($){console.clear();let G=x7($),Z=W7($).map((q)=>({...q,turn:I4($,q.agent)}));if(Z.length===0)Z=A7($);if(Z.length===0)try{let q=q0($).filter((R)=>R.startsWith("progress-")&&R.endsWith(".md"));for(let R of q){let x=R.replace(/^progress-/,"").replace(/\.md$/,"");Z.push({agent:x,status:"running",task:"",turn:I4($,x)})}}catch{}let X=56,z="═".repeat(X),N=(q)=>" ".repeat(Math.max(0,q)),Q=(q)=>c.default.magenta(q),Y=(q)=>c.default.bold(q),K=(q)=>c.default.dim(q),I=c.default.yellow;if(G.status==="RUNNING")I=c.default.green;else if(G.status==="COMPLETED")I=c.default.cyan;else if(G.status==="FAILED")I=c.default.red;console.log(`${Q("╔"+z+"╗")}`),console.log(`${Q("║")} ${Y(Q("Serena Memory Dashboard"))}${N(X-25)}${Q("║")}`);let H=`Session: ${Y(G.id.padEnd(20))} [${I(G.status)}]`;if(console.log(`${Q("║")} ${H}${N(X-4-H.length-9)}${Q("║")}`),console.log(`${Q("╠"+z+"╣")}`),console.log(`${Q("║")} ${Y("Agent".padEnd(12)+" "+"Status".padEnd(12)+" "+"Turn".padEnd(6)+" "+"Task".padEnd(20))} ${Q("║")}`),console.log(`${Q("║")} ${K("──────────".padEnd(12)+" "+"──────────".padEnd(12)+" "+"────".padEnd(6)+" "+"──────────────────".padEnd(20))} ${Q("║")}`),Z.length===0)console.log(`${Q("║")} ${K("No agents detected yet"+N(32))}${Q("║")}`);else for(let q of Z){let R=D7(q.status),x=q.turn!=null?String(q.turn):"-",T=q.task.substring(0,20);console.log(`${Q("║")} ${q.agent.padEnd(12)} ${R.padEnd(22)} ${x.padEnd(6)} ${T.padEnd(20)}${Q("║")}`)}console.log(`${Q("╠"+z+"╣")}`),console.log(`${Q("║")} ${Y("Latest Activity:")}${N(X-18)}${Q("║")}`);let B=L7($);if(B.length===0)console.log(`${Q("║")} ${K("No activity yet"+N(38))}${Q("║")}`);else for(let q of B){let R=`[${q.agent}] ${q.message}`;console.log(`${Q("║")} ${K(R.substring(0,52).padEnd(52))}${Q("║")}`)}console.log(`${Q("╠"+z+"╣")}`);let U=`Updated: ${new Date().toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})} | Ctrl+C to exit`;console.log(`${Q("║")} ${K(U)}${N(X-4-U.length)}${Q("║")}`),console.log(`${Q("╚"+z+"╝")}`)}function m9(){let $=V7();if(!I7($))q7($,{recursive:!0}),console.log(c.default.yellow(`Created ${$} — waiting for memory files...`));console.log(c.default.magenta(`
|
|
179
179
|
\uD83D\uDEF8 Serena Terminal Dashboard`)),console.log(c.default.dim(` Watching: ${$}
|
|
180
180
|
`)),h9($);let G=h0($,{persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});G.on("all",()=>h9($)),process.on("SIGINT",()=>{console.log(`
|
|
181
|
-
`),G.close(),process.exit(0)}),process.on("SIGTERM",()=>process.emit("SIGINT"))}var U4="first-fluke/oh-my-ag",_4=`https://raw.githubusercontent.com/${U4}/main/.agent/skills`,O7="1.1.1",
|
|
182
|
-
`),`${z.length} files failed`);else G.stop(`Updated to version ${
|
|
183
|
-
`);if(g(
|
|
184
|
-
`),"Install missing CLIs");if(Z.length>0){let
|
|
185
|
-
`);g(
|
|
186
|
-
`);g(q,"
|
|
187
|
-
`)
|
|
188
|
-
|
|
189
|
-
${
|
|
190
|
-
|
|
191
|
-
`)
|
|
192
|
-
`);g(
|
|
193
|
-
`)
|
|
194
|
-
`).filter(Boolean)}catch{return[]}}function s7($){
|
|
195
|
-
`)
|
|
196
|
-
`)
|
|
197
|
-
`);g(U,`\uD83D\uDCDA Past Retrospectives (${Z.length})`)}$1(R.default.dim(`Stored in: ${J}`));return}let N=n7(G),Q=s7(G);if(N.length>0)g(N.join(`
|
|
181
|
+
`),G.close(),process.exit(0)}),process.on("SIGTERM",()=>process.emit("SIGINT"))}var U4="first-fluke/oh-my-ag",_4=`https://raw.githubusercontent.com/${U4}/main/.agent/skills`,O7="1.1.1",n={domain:[{name:"frontend-agent",desc:"React/Next.js UI specialist"},{name:"backend-agent",desc:"FastAPI/SQLAlchemy API specialist"},{name:"mobile-agent",desc:"Flutter/Dart mobile specialist"}],coordination:[{name:"pm-agent",desc:"Product manager - task decomposition"},{name:"qa-agent",desc:"QA - OWASP, Lighthouse, WCAG"},{name:"workflow-guide",desc:"Manual multi-agent orchestration"},{name:"orchestrator",desc:"Automated parallel CLI execution"}],utility:[{name:"debug-agent",desc:"Bug fixing specialist"},{name:"commit",desc:"Conventional Commits helper"}]},F7={fullstack:["frontend-agent","backend-agent","pm-agent","qa-agent","debug-agent","commit"],frontend:["frontend-agent","pm-agent","qa-agent","debug-agent","commit"],backend:["backend-agent","pm-agent","qa-agent","debug-agent","commit"],mobile:["mobile-agent","pm-agent","qa-agent","debug-agent","commit"],all:[...n.domain,...n.coordination,...n.utility].map(($)=>$.name)};async function P7($){let G=["SKILL.md"],J=["resources/execution-protocol.md","resources/tech-stack.md","resources/checklist.md","resources/templates.md","resources/error-playbook.md"];for(let Z of J){let X=`${_4}/${$}/${Z}`;if((await fetch(X,{method:"HEAD"})).ok)G.push(Z)}return G}async function d9($,G){let J=u(G,".agent","skills",$),Z=await P7($);for(let X of Z){let z=`${_4}/${$}/${X}`,N=await fetch(z);if(!N.ok)continue;let Q=await N.text(),Y=u(J,X),K=G2(Y);if(!m(K))n1(K,{recursive:!0});g1(Y,Q,"utf-8")}return!0}async function l9($){let G=u($,".agent","skills","_shared"),J=["reasoning-templates.md","clarification-protocol.md","context-loading.md","skill-routing.md"];if(!m(G))n1(G,{recursive:!0});for(let Z of J){let X=`${_4}/_shared/${Z}`,z=await fetch(X);if(!z.ok)continue;let N=await z.text();g1(u(G,Z),N,"utf-8")}}function E7($){return C7("sha256").update($,"utf-8").digest("hex")}async function S7($){let G=u($,".agent","skills","_version.json");if(!m(G))return null;try{let J=v1(G,"utf-8");return JSON.parse(J).version||null}catch{return null}}async function w7($,G){let J=u($,".agent","skills","_version.json"),Z=G2(J);if(!m(Z))n1(Z,{recursive:!0});g1(J,JSON.stringify({version:G},null,2),"utf-8")}async function y7(){let $=`https://raw.githubusercontent.com/${U4}/main/prompt-manifest.json`,G=await fetch($);if(!G.ok)throw Error("Failed to fetch remote manifest");return await G.json()}async function v7($){let G=`https://raw.githubusercontent.com/${U4}/main/${$.path}`,J=await fetch(G);if(!J.ok)return{path:$.path,success:!1,error:`HTTP ${J.status}`};let Z=await J.text();if(E7(Z)!==$.sha256)return{path:$.path,success:!1,error:"SHA256 mismatch"};let z=u(process.cwd(),$.path),N=G2(z);if(!m(N))n1(N,{recursive:!0});return g1(z,Z,"utf-8"),{path:$.path,success:!0}}async function g7(){console.clear(),F1(M.default.bgMagenta(M.default.white(" \uD83D\uDEF8 oh-my-ag update ")));let $=process.cwd(),G=S0();try{G.start("Checking for updates...");let J=await y7(),Z=await S7($);if(Z===J.version){G.stop(M.default.green("Already up to date!")),$1(`Current version: ${M.default.cyan(Z)}`);return}G.message(`Updating from ${Z||"not installed"} to ${M.default.cyan(J.version)}...`);let X=await f2(J.files,async(Q)=>v7(Q),{concurrency:10}),z=X.filter((Q)=>!Q.success);if(z.length>0)G.stop("Update completed with errors"),g(z.map((Q)=>`${M.default.red("✗")} ${Q.path}: ${Q.error}`).join(`
|
|
182
|
+
`),`${z.length} files failed`);else G.stop(`Updated to version ${M.default.cyan(J.version)}!`);await w7($,J.version);let N=X.length-z.length;$1(z.length>0?`${N} files updated, ${z.length} failed`:`${N} files updated successfully`)}catch(J){G.stop("Update failed"),Z1.error(J instanceof Error?J.message:String(J)),process.exit(1)}}async function $2($,G,J){try{let Z=h(`${G} --version`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim();return{name:$,installed:!0,version:Z,installCmd:J}}catch{return{name:$,installed:!1,installCmd:J}}}async function f7($){let G=process.env.HOME||process.env.USERPROFILE||"",Z={gemini:{path:`${G}/.gemini/settings.json`,type:"json"},claude:{path:`${G}/.claude.json`,type:"json"},codex:{path:`${G}/.codex/config.toml`,type:"toml"}}[$];if(!Z)return{configured:!1};if(m(Z.path))try{let X=v1(Z.path,"utf-8");if(Z.type==="json"){let z=JSON.parse(X);return{configured:!!(z.mcpServers||z.mcp),path:Z.path}}return{configured:!0,path:Z.path}}catch{return{configured:!1}}return{configured:!1}}async function b7(){let $=u(process.cwd(),".agent","skills");if(!m($))return[];let G=[...n.domain,...n.coordination,...n.utility],J=[];for(let Z of G){let X=u($,Z.name),z=u(X,"SKILL.md");J.push({name:Z.name,installed:m(X),hasSkillMd:m(z)})}return J}async function u7($=!1){let G=process.cwd(),J=await Promise.all([$2("gemini","gemini","bun install --global @anthropic-ai/gemini-cli"),$2("claude","claude","bun install --global @anthropic-ai/claude-code"),$2("codex","codex","bun install --global @openai/codex"),$2("qwen","qwen","bun install --global @qwen-code/qwen-code")]),Z=await Promise.all(J.filter((B)=>B.installed).map(async(B)=>{let j=await f7(B.name);return{...B,mcp:j}})),X=await b7(),z=u(G,".serena","memories"),N=m(z),Q=0;if(N)try{Q=p1(z).length}catch{}let Y=J.filter((B)=>!B.installed),K=X.length>0?X.filter((B)=>!B.installed||!B.hasSkillMd):[...n.domain,...n.coordination,...n.utility].map((B)=>({name:B.name,installed:!1,hasSkillMd:!1})),I=Y.length+Z.filter((B)=>!B.mcp.configured).length+K.length;if($){let B={ok:I===0,issues:I,clis:J.map((j)=>({name:j.name,installed:j.installed,version:j.version||null})),mcp:Z.map((j)=>({name:j.name,configured:j.mcp.configured,path:j.mcp.path||null})),skills:X.length>0?X.map((j)=>({name:j.name,installed:j.installed,complete:j.hasSkillMd})):[],missingSkills:K.map((j)=>j.name),serena:{exists:N,fileCount:Q}};console.log(JSON.stringify(B,null,2)),process.exit(I===0?0:1)}console.clear(),F1(M.default.bgMagenta(M.default.white(" \uD83E\uDE7A oh-my-ag doctor ")));let H=S0();try{let B=[M.default.bold("\uD83D\uDD0D CLI Installation Status"),"┌─────────┬──────────┬─────────────┐",`│ ${M.default.bold("CLI")} │ ${M.default.bold("Status")} │ ${M.default.bold("Version")} │`,"├─────────┼──────────┼─────────────┤",...J.map((q)=>{let R=q.installed?M.default.green("✅ Installed"):M.default.red("❌ Missing"),x=q.version||"-";return`│ ${q.name.padEnd(7)} │ ${R.padEnd(8)} │ ${x.padEnd(11)} │`}),"└─────────┴──────────┴─────────────┘"].join(`
|
|
183
|
+
`);if(g(B,"CLI Status"),Y.length>0)g(Y.map((q)=>`${M.default.yellow("→")} ${q.name}: ${M.default.dim(q.installCmd)}`).join(`
|
|
184
|
+
`),"Install missing CLIs");if(Z.length>0){let q=[M.default.bold("\uD83D\uDD17 MCP Connection Status"),"┌─────────┬──────────┬─────────────────────┐",`│ ${M.default.bold("CLI")} │ ${M.default.bold("MCP Config")} │ ${M.default.bold("Path")} │`,"├─────────┼──────────┼─────────────────────┤",...Z.map((R)=>{let x=R.mcp.configured?M.default.green("✅ Configured"):M.default.yellow("⚠️ Not configured"),T=R.mcp.path?R.mcp.path.split("/").pop()||"":"-";return`│ ${R.name.padEnd(7)} │ ${x.padEnd(8)} │ ${T.padEnd(19)} │`}),"└─────────┴──────────┴─────────────────────┘"].join(`
|
|
185
|
+
`);g(q,"MCP Status")}let j=X.filter((q)=>q.installed).length,U=X.filter((q)=>q.hasSkillMd).length;if(X.length>0){let q=[M.default.bold(`\uD83D\uDCE6 Skills (${j}/${X.length} installed, ${U} complete)`),"┌────────────────────┬──────────┬─────────────┐",`│ ${M.default.bold("Skill")} │ ${M.default.bold("Installed")} │ ${M.default.bold("SKILL.md")} │`,"├────────────────────┼──────────┼─────────────┤",...X.map((R)=>{let x=R.installed?M.default.green("✅"):M.default.red("❌"),T=R.hasSkillMd?M.default.green("✅"):M.default.red("❌");return`│ ${R.name.padEnd(18)} │ ${x.padEnd(8)} │ ${T.padEnd(11)} │`}),"└────────────────────┴──────────┴─────────────┘"].join(`
|
|
186
|
+
`);g(q,"Skills Status")}else g(M.default.yellow("No skills installed."),"Skills Status");if(K.length>0){let q=await K3({message:`Found ${K.length} missing/incomplete skill(s). Install them?`,initialValue:!0});if(t(q))B1("Cancelled."),process.exit(0);if(q){let R=K.map((L)=>L.name),x=await w0({message:"Which skills to install?",options:[{value:"all",label:`✨ All (${R.length} skills)`,hint:"Recommended"},{value:"select",label:"\uD83D\uDD27 Select individually"}]});if(t(x))B1("Cancelled."),process.exit(0);let T;if(x==="select"){let L=[...n.domain,...n.coordination,...n.utility],C=await g2({message:"Select skills to install:",options:K.map((A)=>{let F=L.find((V)=>V.name===A.name);return{value:A.name,label:A.name,hint:F?.desc||""}}),required:!0});if(t(C))B1("Cancelled."),process.exit(0);T=C}else T=R;H.start("Installing skills...");try{await l9(G);for(let L of T)H.message(`Installing ${M.default.cyan(L)}...`),await d9(L,G);H.stop(`Installed ${T.length} skill(s)!`),g(T.map((L)=>`${M.default.green("✓")} ${L}`).join(`
|
|
187
|
+
`),"Installed Skills")}catch(L){H.stop("Installation failed"),Z1.error(L instanceof Error?L.message:String(L))}}}if(N)g(`${M.default.green("✅")} Serena memory directory exists
|
|
188
|
+
${M.default.dim(`${Q} memory files found`)}`,"Serena Memory");else g(`${M.default.yellow("⚠️")} Serena memory directory not found
|
|
189
|
+
${M.default.dim("Dashboard will show 'No agents detected'")}`,"Serena Memory");if(I===0)$1(M.default.green("✅ All checks passed! Ready to use."));else $1(M.default.yellow(`⚠️ Found ${I} issue(s). See details above.`))}catch(B){if(H)H.stop("Check failed");Z1.error(B instanceof Error?B.message:String(B)),process.exit(1)}}function j4($){return u($,".serena","metrics.json")}function B4(){return{sessions:0,skillsUsed:{},tasksCompleted:0,totalSessionTime:0,filesChanged:0,linesAdded:0,linesRemoved:0,lastUpdated:new Date().toISOString(),startDate:new Date().toISOString()}}function k7($){let G=j4($);if(m(G))try{return JSON.parse(v1(G,"utf-8"))}catch{return B4()}return B4()}function h7($,G){let J=j4($),Z=G2(J);if(!m(Z))n1(Z,{recursive:!0});G.lastUpdated=new Date().toISOString(),g1(J,JSON.stringify(G,null,2),"utf-8")}function m7($){try{let J=h("git diff --stat HEAD~10 2>/dev/null || git diff --stat",{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
190
|
+
`),Z=J[J.length-1]||"",X=Z.match(/(\d+) files? changed/),z=Z.match(/(\d+) insertions?\(\+\)/),N=Z.match(/(\d+) deletions?\(-\)/);return{filesChanged:X?.[1]?parseInt(X[1],10):0,linesAdded:z?.[1]?parseInt(z[1],10):0,linesRemoved:N?.[1]?parseInt(N[1],10):0}}catch{return{filesChanged:0,linesAdded:0,linesRemoved:0}}}function d7($){let G=u($,".serena","memories"),J={};if(!m(G))return J;try{let Z=p1(G);for(let X of Z){let z=X.match(/(?:progress|result)-(\w+)/);if(z?.[1]){let N=z[1];J[N]=(J[N]||0)+1}}}catch{}return J}async function l7($=!1,G=!1){let J=process.cwd(),Z=j4(J);if(G){if(m(Z))g1(Z,JSON.stringify(B4(),null,2),"utf-8");if($)console.log(JSON.stringify({reset:!0}));else console.log(M.default.green("✅ Metrics reset successfully."));return}let X=k7(J),z=m7(J),N=d7(J);for(let[H,B]of Object.entries(N))X.skillsUsed[H]=(X.skillsUsed[H]||0)+B;X.filesChanged+=z.filesChanged,X.linesAdded+=z.linesAdded,X.linesRemoved+=z.linesRemoved,X.sessions+=1,h7(J,X);let Q=Math.max(1,Math.ceil((Date.now()-new Date(X.startDate).getTime())/86400000)),Y=X.sessions>0?Math.round(X.totalSessionTime/X.sessions):0;if($){console.log(JSON.stringify({...X,gitStats:z,daysSinceStart:Q,avgSessionTime:Y},null,2));return}console.clear(),F1(M.default.bgMagenta(M.default.white(" \uD83D\uDCCA oh-my-ag stats ")));let K=[M.default.bold(`\uD83D\uDCC8 Productivity Metrics (${Q} days)`),"┌─────────────────────┬──────────────┐",`│ ${M.default.bold("Metric")} │ ${M.default.bold("Value")} │`,"├─────────────────────┼──────────────┤",`│ Sessions │ ${String(X.sessions).padEnd(12)} │`,`│ Tasks Completed │ ${String(X.tasksCompleted).padEnd(12)} │`,`│ Files Changed │ ${String(X.filesChanged).padEnd(12)} │`,`│ Lines Added │ ${M.default.green("+"+X.linesAdded).padEnd(12)} │`,`│ Lines Removed │ ${M.default.red("-"+X.linesRemoved).padEnd(12)} │`,"└─────────────────────┴──────────────┘"].join(`
|
|
191
|
+
`);g(K,"Overview");let I=Object.entries(X.skillsUsed).sort(([,H],[,B])=>B-H).slice(0,5);if(I.length>0){let H=[M.default.bold("\uD83C\uDFC6 Top Skills Used"),...I.map(([B,j],U)=>` ${U+1}. ${B} (${j})`)].join(`
|
|
192
|
+
`);g(H,"Skills")}$1(M.default.dim(`Data stored in: ${Z}`))}function R4($){return u($,".serena","retrospectives")}function c7($){let G=R4($);if(!m(G))return[];try{return p1(G).filter((Z)=>Z.endsWith(".json")).sort().reverse().slice(0,10).map((Z)=>JSON.parse(v1(u(G,Z),"utf-8")))}catch{return[]}}function p7($,G){let J=R4($);if(!m(J))n1(J,{recursive:!0});let Z=`${G.date.replace(/[:.]/g,"-")}_${G.id}.json`;g1(u(J,Z),JSON.stringify(G,null,2),"utf-8")}function n7($,G=5){try{return h(`git log --oneline -${G} 2>/dev/null`,{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
193
|
+
`).filter(Boolean)}catch{return[]}}function i7($){try{return h("git diff --name-only HEAD~5 2>/dev/null || git diff --name-only",{cwd:$,encoding:"utf-8",stdio:["pipe","pipe","ignore"]}).trim().split(`
|
|
194
|
+
`).filter(Boolean).slice(0,10)}catch{return[]}}async function s7($=!1){let G=process.cwd(),J=R4(G),Z=c7(G);if($){console.log(JSON.stringify({retrospectives:Z},null,2));return}console.clear(),F1(M.default.bgMagenta(M.default.white(" \uD83D\uDD04 oh-my-ag retro ")));let X=Z[0];if(X)g([M.default.bold("\uD83D\uDCC5 Last Retrospective"),`Date: ${X.date}`,"",M.default.bold("Summary:"),X.summary,"",M.default.bold("Key Learnings:"),...X.keyLearnings.map((B)=>` • ${B}`),"",M.default.bold("Next Steps:"),...X.nextSteps.map((B)=>` → ${B}`)].join(`
|
|
195
|
+
`),"Previous Session");let z=await w0({message:"What would you like to do?",options:[{value:"new",label:"\uD83D\uDCDD Create new retrospective"},{value:"list",label:"\uD83D\uDCCB View past retrospectives"},{value:"exit",label:"\uD83D\uDC4B Exit"}]});if(t(z)||z==="exit"){$1(M.default.dim("Goodbye!"));return}if(z==="list"){if(Z.length===0)g(M.default.yellow("No retrospectives found."),"History");else{let B=Z.map((j,U)=>`${U+1}. [${j.date.split("T")[0]}] ${j.summary.slice(0,50)}...`).join(`
|
|
196
|
+
`);g(B,`\uD83D\uDCDA Past Retrospectives (${Z.length})`)}$1(M.default.dim(`Stored in: ${J}`));return}let N=n7(G),Q=i7(G);if(N.length>0)g(N.join(`
|
|
198
197
|
`),"Recent Commits");if(Q.length>0)g(Q.join(`
|
|
199
|
-
`),"Changed Files");let Y=await y0({message:"What did you accomplish in this session?",placeholder:"e.g., Implemented user authentication flow"});if(t(Y)){B1("Cancelled.");return}let K=await y0({message:"Key learnings? (comma-separated)",placeholder:"e.g., JWT needs refresh token, bcrypt is slow"});if(t(K)){B1("Cancelled.");return}let I=await y0({message:"Next steps? (comma-separated)",placeholder:"e.g., Add password reset, Write tests"});if(t(I)){B1("Cancelled.");return}let H={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:Y,keyLearnings:K.split(",").map((
|
|
200
|
-
`),"Saved"),$1(
|
|
201
|
-
`).filter((
|
|
202
|
-
`);g(K,"Details")}let Y=[
|
|
203
|
-
`);if(g(Y,"Results"),$)$1(
|
|
204
|
-
`),"Installed"),$1(
|
|
205
|
-
${
|
|
198
|
+
`),"Changed Files");let Y=await y0({message:"What did you accomplish in this session?",placeholder:"e.g., Implemented user authentication flow"});if(t(Y)){B1("Cancelled.");return}let K=await y0({message:"Key learnings? (comma-separated)",placeholder:"e.g., JWT needs refresh token, bcrypt is slow"});if(t(K)){B1("Cancelled.");return}let I=await y0({message:"Next steps? (comma-separated)",placeholder:"e.g., Add password reset, Write tests"});if(t(I)){B1("Cancelled.");return}let H={id:Math.random().toString(36).slice(2,8),date:new Date().toISOString(),summary:Y,keyLearnings:K.split(",").map((B)=>B.trim()).filter(Boolean),filesChanged:Q,nextSteps:I.split(",").map((B)=>B.trim()).filter(Boolean)};p7(G,H),g([M.default.green("✅ Retrospective saved!"),"",`Summary: ${H.summary}`,`Learnings: ${H.keyLearnings.length} items`,`Next steps: ${H.nextSteps.length} items`].join(`
|
|
199
|
+
`),"Saved"),$1(M.default.dim(`Stored in: ${J}`))}async function o7($=!1,G=!1){let J=process.cwd(),Z=u(J,".agent","results"),X="/tmp",z={cleaned:0,skipped:0,details:[]},N=(K)=>{z.details.push($?`[DRY-RUN] ${K}`:`[CLEAN] ${K}`),z.cleaned++},Q=(K)=>{z.details.push(`[SKIP] ${K}`),z.skipped++};try{let K=p1("/tmp").filter((I)=>I.startsWith("subagent-")&&I.endsWith(".pid"));for(let I of K){let H=u("/tmp",I),B=v1(H,"utf-8").trim();if(!B){if(N(`Removing empty PID file: ${H}`),!$)try{h(`rm -f "${H}"`)}catch{}continue}let j=parseInt(B,10);if(isNaN(j)){if(N(`Removing invalid PID file: ${H}`),!$)try{h(`rm -f "${H}"`)}catch{}continue}try{if(h(`kill -0 ${j} 2>/dev/null`),N(`Killing orphaned process PID=${j} (from ${H})`),!$)try{h(`kill ${j} 2>/dev/null || true`),await new Promise((U)=>setTimeout(U,1000));try{h(`kill -0 ${j} 2>/dev/null`),h(`kill -9 ${j} 2>/dev/null || true`)}catch{}h(`rm -f "${H}"`)}catch{}}catch{if(N(`Removing stale PID file (process gone): ${H}`),!$)try{h(`rm -f "${H}"`)}catch{}}}}catch{}try{let K=p1("/tmp").filter((I)=>I.startsWith("subagent-")&&I.endsWith(".log"));for(let I of K){let H=u("/tmp",I),B=I.replace(".log",".pid"),j=u("/tmp",B);if(m(j))try{let U=v1(j,"utf-8").trim(),q=parseInt(U,10);if(!isNaN(q)){h(`kill -0 ${q} 2>/dev/null`),Q(`Log file has active process: ${H}`);continue}}catch{}if(N(`Removing stale log file: ${H}`),!$)try{h(`rm -f "${H}"`)}catch{}}}catch{}if(m(Z))try{let K=p1(Z).filter((I)=>I.startsWith("parallel-"));for(let I of K){let H=u(Z,I,"pids.txt");if(!m(H))continue;let j=v1(H,"utf-8").split(`
|
|
200
|
+
`).filter((q)=>q.trim()),U=!1;for(let q of j){let[R,x]=q.split(":"),T=parseInt(R?.trim()||"",10);if(isNaN(T))continue;try{if(h(`kill -0 ${T} 2>/dev/null`),U=!0,N(`Killing orphaned parallel agent PID=${T} (${x?.trim()||"unknown"})`),!$)try{h(`kill ${T} 2>/dev/null || true`),h(`rm -f "${H}"`)}catch{}}catch{}}if(!U){if(N(`Removing stale PID list: ${H}`),!$)try{h(`rm -f "${H}"`)}catch{}}else if(!$){await new Promise((q)=>setTimeout(q,1000));try{h(`rm -f "${H}"`)}catch{}}}}catch{}else Q(`No results directory found: ${Z}`);if(G){console.log(JSON.stringify(z,null,2));return}if(console.clear(),F1(M.default.bgMagenta(M.default.white(" \uD83E\uDDF9 oh-my-ag cleanup "))),$)g(M.default.yellow("Dry-run mode — no changes will be made"),"Mode");if(z.details.length>0){let K=[M.default.bold("Cleanup Details"),...z.details.map((I)=>{if(I.startsWith("[DRY-RUN]"))return M.default.yellow(I);if(I.startsWith("[CLEAN]"))return M.default.green(I);return M.default.cyan(I)})].join(`
|
|
201
|
+
`);g(K,"Details")}let Y=[M.default.bold("Summary"),"┌─────────┬────────┐",`│ ${M.default.bold("Action")} │ ${M.default.bold("Count")} │`,"├─────────┼────────┤",`│ Cleaned │ ${String(z.cleaned).padEnd(6)} │`,`│ Skipped │ ${String(z.skipped).padEnd(6)} │`,"└─────────┴────────┘"].join(`
|
|
202
|
+
`);if(g(Y,"Results"),$)$1(M.default.yellow("Run without --dry-run to apply changes"));else $1(M.default.green("Cleanup complete!"))}async function r7(){console.clear(),F1(M.default.bgMagenta(M.default.white(" \uD83D\uDEF8 oh-my-ag ")));let $=await w0({message:"What type of project?",options:[{value:"all",label:"✨ All",hint:"Install everything"},{value:"fullstack",label:"\uD83C\uDF10 Fullstack",hint:"Frontend + Backend + PM + QA"},{value:"frontend",label:"\uD83C\uDFA8 Frontend",hint:"React/Next.js"},{value:"backend",label:"⚙️ Backend",hint:"FastAPI/Python"},{value:"mobile",label:"\uD83D\uDCF1 Mobile",hint:"Flutter/Dart"},{value:"custom",label:"\uD83D\uDD27 Custom",hint:"Choose skills"}]});if(t($))B1("Cancelled."),process.exit(0);let G;if($==="custom"){let X=[...n.domain,...n.coordination,...n.utility],z=await g2({message:"Select skills:",options:X.map((N)=>({value:N.name,label:N.name,hint:N.desc})),required:!0});if(t(z))B1("Cancelled."),process.exit(0);G=z}else G=F7[$]??[];let J=process.cwd(),Z=S0();Z.start("Installing skills...");try{await l9(J);for(let X of G)Z.message(`Installing ${M.default.cyan(X)}...`),await d9(X,J);Z.stop("Skills installed!"),g([...G.map((X)=>`${M.default.green("✓")} ${X}`),"",M.default.dim(`Location: ${u(J,".agent","skills")}`)].join(`
|
|
203
|
+
`),"Installed"),$1(M.default.green("Done! Open your project in your IDE to use the skills.")),g(`${M.default.yellow("❤️")} Enjoying oh-my-ag? Give it a star!
|
|
204
|
+
${M.default.dim("gh api --method PUT /user/starred/first-fluke/oh-my-ag")}`,"Support")}catch(X){Z.stop("Installation failed"),Z1.error(X instanceof Error?X.message:String(X)),process.exit(1)}}var R1=new v4;R1.name("oh-my-ag").description("Multi-Agent Skills for Antigravity IDE").version(O7).action(()=>{r7().catch(console.error)});R1.command("dashboard").description("Start terminal dashboard (real-time agent monitoring)").action(()=>{m9()});R1.command("dashboard:web").description("Start web dashboard on http://localhost:9847").action(()=>{k9()});R1.command("update").description("Update skills to latest version from registry").action(()=>{g7().catch(console.error)});R1.command("doctor").description("Check CLI installations, MCP configs, and skill status").option("--json","Output as JSON for CI/CD").action(($)=>{u7($.json).catch(console.error)});R1.command("stats").description("View productivity metrics").option("--json","Output as JSON").option("--reset","Reset metrics data").action(($)=>{l7($.json,$.reset).catch(console.error)});R1.command("retro").description("Session retrospective (learnings & next steps)").option("--json","Output as JSON").action(($)=>{s7($.json).catch(console.error)});R1.command("cleanup").description("Clean up orphaned subagent processes and temp files").option("--dry-run","Show what would be cleaned without making changes").option("--json","Output as JSON").action(($)=>{o7($.dryRun,$.json).catch(console.error)});R1.parse();
|