@mitsein-ai/cli 0.1.0
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/README.md +142 -0
- package/dist/index.js +143 -0
- package/package.json +49 -0
- package/src/commands/agent.ts +91 -0
- package/src/commands/api-auto.ts +245 -0
- package/src/commands/auth-browser.ts +126 -0
- package/src/commands/auth-device.ts +97 -0
- package/src/commands/auth-internal.ts +49 -0
- package/src/commands/auth.ts +105 -0
- package/src/commands/command-opts.ts +41 -0
- package/src/commands/dev.ts +100 -0
- package/src/commands/messages.ts +61 -0
- package/src/commands/project.ts +77 -0
- package/src/commands/run.ts +134 -0
- package/src/commands/thread.ts +187 -0
- package/src/commands/version.ts +17 -0
- package/src/core/client.ts +201 -0
- package/src/core/config.ts +26 -0
- package/src/core/credentials.ts +173 -0
- package/src/core/errors.ts +76 -0
- package/src/core/openapi.ts +182 -0
- package/src/core/output.ts +59 -0
- package/src/core/sse.ts +135 -0
- package/src/core/waiters-output.ts +95 -0
- package/src/core/waiters.ts +169 -0
- package/src/index.ts +66 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
var Fi=Object.create;var{getPrototypeOf:ei,defineProperty:Mu,getOwnPropertyNames:si}=Object;var Ci=Object.prototype.hasOwnProperty;function fi(u){return this[u]}var Ei,hi,ci=(u,D,t)=>{var r=u!=null&&typeof u==="object";if(r){var n=D?Ei??=new WeakMap:hi??=new WeakMap,F=n.get(u);if(F)return F}t=u!=null?Fi(ei(u)):{};let i=D||!u||!u.__esModule?Mu(t,"default",{value:u,enumerable:!0}):t;for(let e of si(u))if(!Ci.call(i,e))Mu(i,e,{get:fi.bind(u,e),enumerable:!0});if(r)n.set(u,i);return i};var O=(u,D)=>()=>(D||u((D={exports:{}}).exports,D),D.exports);var Bi=(u)=>u;function oi(u,D){this[u]=Bi.bind(null,D)}var li=(u,D)=>{for(var t in D)Mu(u,t,{get:D[t],enumerable:!0,configurable:!0,set:oi.bind(D,t)})};var $i=(u,D)=>()=>(u&&(D=u(u=0)),D);var Fu=import.meta.require;var eu=O((Ai)=>{class gu extends Error{constructor(u,D,t){super(t);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=D,this.exitCode=u,this.nestedError=void 0}}class lD extends gu{constructor(u){super(1,"commander.invalidArgument",u);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}Ai.CommanderError=gu;Ai.InvalidArgumentError=lD});var cu=O((Ri)=>{var{InvalidArgumentError:mi}=eu();class $D{constructor(u,D){switch(this.description=D||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,u[0]){case"<":this.required=!0,this._name=u.slice(1,-1);break;case"[":this.required=!1,this._name=u.slice(1,-1);break;default:this.required=!0,this._name=u;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(u,D){if(D===this.defaultValue||!Array.isArray(D))return[u];return D.concat(u)}default(u,D){return this.defaultValue=u,this.defaultValueDescription=D,this}argParser(u){return this.parseArg=u,this}choices(u){return this.argChoices=u.slice(),this.parseArg=(D,t)=>{if(!this.argChoices.includes(D))throw new mi(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(D,t);return D},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function bi(u){let D=u.name()+(u.variadic===!0?"...":"");return u.required?"<"+D+">":"["+D+"]"}Ri.Argument=$D;Ri.humanReadableArgName=bi});var Lu=O((Ui)=>{var{humanReadableArgName:yi}=cu();class AD{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(u){this.helpWidth=this.helpWidth??u.helpWidth??80}visibleCommands(u){let D=u.commands.filter((r)=>!r._hidden),t=u._getHelpCommand();if(t&&!t._hidden)D.push(t);if(this.sortSubcommands)D.sort((r,n)=>{return r.name().localeCompare(n.name())});return D}compareOptions(u,D){let t=(r)=>{return r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"")};return t(u).localeCompare(t(D))}visibleOptions(u){let D=u.options.filter((r)=>!r.hidden),t=u._getHelpOption();if(t&&!t.hidden){let r=t.short&&u._findOption(t.short),n=t.long&&u._findOption(t.long);if(!r&&!n)D.push(t);else if(t.long&&!n)D.push(u.createOption(t.long,t.description));else if(t.short&&!r)D.push(u.createOption(t.short,t.description))}if(this.sortOptions)D.sort(this.compareOptions);return D}visibleGlobalOptions(u){if(!this.showGlobalOptions)return[];let D=[];for(let t=u.parent;t;t=t.parent){let r=t.options.filter((n)=>!n.hidden);D.push(...r)}if(this.sortOptions)D.sort(this.compareOptions);return D}visibleArguments(u){if(u._argsDescription)u.registeredArguments.forEach((D)=>{D.description=D.description||u._argsDescription[D.name()]||""});if(u.registeredArguments.find((D)=>D.description))return u.registeredArguments;return[]}subcommandTerm(u){let D=u.registeredArguments.map((t)=>yi(t)).join(" ");return u._name+(u._aliases[0]?"|"+u._aliases[0]:"")+(u.options.length?" [options]":"")+(D?" "+D:"")}optionTerm(u){return u.flags}argumentTerm(u){return u.name()}longestSubcommandTermLength(u,D){return D.visibleCommands(u).reduce((t,r)=>{return Math.max(t,this.displayWidth(D.styleSubcommandTerm(D.subcommandTerm(r))))},0)}longestOptionTermLength(u,D){return D.visibleOptions(u).reduce((t,r)=>{return Math.max(t,this.displayWidth(D.styleOptionTerm(D.optionTerm(r))))},0)}longestGlobalOptionTermLength(u,D){return D.visibleGlobalOptions(u).reduce((t,r)=>{return Math.max(t,this.displayWidth(D.styleOptionTerm(D.optionTerm(r))))},0)}longestArgumentTermLength(u,D){return D.visibleArguments(u).reduce((t,r)=>{return Math.max(t,this.displayWidth(D.styleArgumentTerm(D.argumentTerm(r))))},0)}commandUsage(u){let D=u._name;if(u._aliases[0])D=D+"|"+u._aliases[0];let t="";for(let r=u.parent;r;r=r.parent)t=r.name()+" "+t;return t+D+" "+u.usage()}commandDescription(u){return u.description()}subcommandDescription(u){return u.summary()||u.description()}optionDescription(u){let D=[];if(u.argChoices)D.push(`choices: ${u.argChoices.map((t)=>JSON.stringify(t)).join(", ")}`);if(u.defaultValue!==void 0){if(u.required||u.optional||u.isBoolean()&&typeof u.defaultValue==="boolean")D.push(`default: ${u.defaultValueDescription||JSON.stringify(u.defaultValue)}`)}if(u.presetArg!==void 0&&u.optional)D.push(`preset: ${JSON.stringify(u.presetArg)}`);if(u.envVar!==void 0)D.push(`env: ${u.envVar}`);if(D.length>0)return`${u.description} (${D.join(", ")})`;return u.description}argumentDescription(u){let D=[];if(u.argChoices)D.push(`choices: ${u.argChoices.map((t)=>JSON.stringify(t)).join(", ")}`);if(u.defaultValue!==void 0)D.push(`default: ${u.defaultValueDescription||JSON.stringify(u.defaultValue)}`);if(D.length>0){let t=`(${D.join(", ")})`;if(u.description)return`${u.description} ${t}`;return t}return u.description}formatHelp(u,D){let t=D.padWidth(u,D),r=D.helpWidth??80;function n(C,E){return D.formatItem(C,t,E,D)}let F=[`${D.styleTitle("Usage:")} ${D.styleUsage(D.commandUsage(u))}`,""],i=D.commandDescription(u);if(i.length>0)F=F.concat([D.boxWrap(D.styleCommandDescription(i),r),""]);let e=D.visibleArguments(u).map((C)=>{return n(D.styleArgumentTerm(D.argumentTerm(C)),D.styleArgumentDescription(D.argumentDescription(C)))});if(e.length>0)F=F.concat([D.styleTitle("Arguments:"),...e,""]);let s=D.visibleOptions(u).map((C)=>{return n(D.styleOptionTerm(D.optionTerm(C)),D.styleOptionDescription(D.optionDescription(C)))});if(s.length>0)F=F.concat([D.styleTitle("Options:"),...s,""]);if(D.showGlobalOptions){let C=D.visibleGlobalOptions(u).map((E)=>{return n(D.styleOptionTerm(D.optionTerm(E)),D.styleOptionDescription(D.optionDescription(E)))});if(C.length>0)F=F.concat([D.styleTitle("Global Options:"),...C,""])}let f=D.visibleCommands(u).map((C)=>{return n(D.styleSubcommandTerm(D.subcommandTerm(C)),D.styleSubcommandDescription(D.subcommandDescription(C)))});if(f.length>0)F=F.concat([D.styleTitle("Commands:"),...f,""]);return F.join(`
|
|
4
|
+
`)}displayWidth(u){return wD(u).length}styleTitle(u){return u}styleUsage(u){return u.split(" ").map((D)=>{if(D==="[options]")return this.styleOptionText(D);if(D==="[command]")return this.styleSubcommandText(D);if(D[0]==="["||D[0]==="<")return this.styleArgumentText(D);return this.styleCommandText(D)}).join(" ")}styleCommandDescription(u){return this.styleDescriptionText(u)}styleOptionDescription(u){return this.styleDescriptionText(u)}styleSubcommandDescription(u){return this.styleDescriptionText(u)}styleArgumentDescription(u){return this.styleDescriptionText(u)}styleDescriptionText(u){return u}styleOptionTerm(u){return this.styleOptionText(u)}styleSubcommandTerm(u){return u.split(" ").map((D)=>{if(D==="[options]")return this.styleOptionText(D);if(D[0]==="["||D[0]==="<")return this.styleArgumentText(D);return this.styleSubcommandText(D)}).join(" ")}styleArgumentTerm(u){return this.styleArgumentText(u)}styleOptionText(u){return u}styleArgumentText(u){return u}styleSubcommandText(u){return u}styleCommandText(u){return u}padWidth(u,D){return Math.max(D.longestOptionTermLength(u,D),D.longestGlobalOptionTermLength(u,D),D.longestSubcommandTermLength(u,D),D.longestArgumentTermLength(u,D))}preformatted(u){return/\n[^\S\r\n]/.test(u)}formatItem(u,D,t,r){let F=" ".repeat(2);if(!t)return F+u;let i=u.padEnd(D+u.length-r.displayWidth(u)),e=2,f=(this.helpWidth??80)-D-e-2,C;if(f<this.minWidthToWrap||r.preformatted(t))C=t;else C=r.boxWrap(t,f).replace(/\n/g,`
|
|
5
|
+
`+" ".repeat(D+e));return F+i+" ".repeat(e)+C.replace(/\n/g,`
|
|
6
|
+
${F}`)}boxWrap(u,D){if(D<this.minWidthToWrap)return u;let t=u.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,n=[];return t.forEach((F)=>{let i=F.match(r);if(i===null){n.push("");return}let e=[i.shift()],s=this.displayWidth(e[0]);i.forEach((f)=>{let C=this.displayWidth(f);if(s+C<=D){e.push(f),s+=C;return}n.push(e.join(""));let E=f.trimStart();e=[E],s=this.displayWidth(E)}),n.push(e.join(""))}),n.join(`
|
|
7
|
+
`)}}function wD(u){let D=/\x1b\[\d*(;\d*)*m/g;return u.replace(D,"")}Ui.Help=AD;Ui.stripColor=wD});var Pu=O((Mi)=>{var{InvalidArgumentError:Ni}=eu();class mD{constructor(u,D){this.flags=u,this.description=D||"",this.required=u.includes("<"),this.optional=u.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(u),this.mandatory=!1;let t=Ji(u);if(this.short=t.shortFlag,this.long=t.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(u,D){return this.defaultValue=u,this.defaultValueDescription=D,this}preset(u){return this.presetArg=u,this}conflicts(u){return this.conflictsWith=this.conflictsWith.concat(u),this}implies(u){let D=u;if(typeof u==="string")D={[u]:!0};return this.implied=Object.assign(this.implied||{},D),this}env(u){return this.envVar=u,this}argParser(u){return this.parseArg=u,this}makeOptionMandatory(u=!0){return this.mandatory=!!u,this}hideHelp(u=!0){return this.hidden=!!u,this}_concatValue(u,D){if(D===this.defaultValue||!Array.isArray(D))return[u];return D.concat(u)}choices(u){return this.argChoices=u.slice(),this.parseArg=(D,t)=>{if(!this.argChoices.includes(D))throw new Ni(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(D,t);return D},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return _D(this.name().replace(/^no-/,""));return _D(this.name())}is(u){return this.short===u||this.long===u}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class bD{constructor(u){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,u.forEach((D)=>{if(D.negate)this.negativeOptions.set(D.attributeName(),D);else this.positiveOptions.set(D.attributeName(),D)}),this.negativeOptions.forEach((D,t)=>{if(this.positiveOptions.has(t))this.dualOptions.add(t)})}valueFromOption(u,D){let t=D.attributeName();if(!this.dualOptions.has(t))return!0;let r=this.negativeOptions.get(t).presetArg,n=r!==void 0?r:!1;return D.negate===(n===u)}}function _D(u){return u.split("-").reduce((D,t)=>{return D+t[0].toUpperCase()+t.slice(1)})}function Ji(u){let D,t,r=/^-[^-]$/,n=/^--[^-]/,F=u.split(/[ |,]+/).concat("guard");if(r.test(F[0]))D=F.shift();if(n.test(F[0]))t=F.shift();if(!D&&r.test(F[0]))D=F.shift();if(!D&&n.test(F[0]))D=t,t=F.shift();if(F[0].startsWith("-")){let i=F[0],e=`option creation failed due to '${i}' in option flags '${u}'`;if(/^-[^-][^-]/.test(i))throw Error(`${e}
|
|
8
|
+
- a short flag is a single dash and a single character
|
|
9
|
+
- either use a single dash and a single character (for a short flag)
|
|
10
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(r.test(i))throw Error(`${e}
|
|
11
|
+
- too many short flags`);if(n.test(i))throw Error(`${e}
|
|
12
|
+
- too many long flags`);throw Error(`${e}
|
|
13
|
+
- unrecognised flag format`)}if(D===void 0&&t===void 0)throw Error(`option creation failed due to no flags found in '${u}'.`);return{shortFlag:D,longFlag:t}}Mi.Option=mD;Mi.DualOptions=bD});var RD=O((Wi)=>{function Pi(u,D){if(Math.abs(u.length-D.length)>3)return Math.max(u.length,D.length);let t=[];for(let r=0;r<=u.length;r++)t[r]=[r];for(let r=0;r<=D.length;r++)t[0][r]=r;for(let r=1;r<=D.length;r++)for(let n=1;n<=u.length;n++){let F=1;if(u[n-1]===D[r-1])F=0;else F=1;if(t[n][r]=Math.min(t[n-1][r]+1,t[n][r-1]+1,t[n-1][r-1]+F),n>1&&r>1&&u[n-1]===D[r-2]&&u[n-2]===D[r-1])t[n][r]=Math.min(t[n][r],t[n-2][r-2]+1)}return t[u.length][D.length]}function Qi(u,D){if(!D||D.length===0)return"";D=Array.from(new Set(D));let t=u.startsWith("--");if(t)u=u.slice(2),D=D.map((i)=>i.slice(2));let r=[],n=3,F=0.4;if(D.forEach((i)=>{if(i.length<=1)return;let e=Pi(u,i),s=Math.max(u.length,i.length);if((s-e)/s>F){if(e<n)n=e,r=[i];else if(e===n)r.push(i)}}),r.sort((i,e)=>i.localeCompare(e)),t)r=r.map((i)=>`--${i}`);if(r.length>1)return`
|
|
14
|
+
(Did you mean one of ${r.join(", ")}?)`;if(r.length===1)return`
|
|
15
|
+
(Did you mean ${r[0]}?)`;return""}Wi.suggestSimilar=Qi});var UD=O((Vi)=>{var Yi=Fu("events").EventEmitter,Qu=Fu("child_process"),a=Fu("path"),Bu=Fu("fs"),b=Fu("process"),{Argument:qi,humanReadableArgName:Zi}=cu(),{CommanderError:Wu}=eu(),{Help:ai,stripColor:Xi}=Lu(),{Option:SD,DualOptions:Hi}=Pu(),{suggestSimilar:TD}=RD();class Yu extends Yi{constructor(u){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=u||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(D)=>b.stdout.write(D),writeErr:(D)=>b.stderr.write(D),outputError:(D,t)=>t(D),getOutHelpWidth:()=>b.stdout.isTTY?b.stdout.columns:void 0,getErrHelpWidth:()=>b.stderr.isTTY?b.stderr.columns:void 0,getOutHasColors:()=>zu()??(b.stdout.isTTY&&b.stdout.hasColors?.()),getErrHasColors:()=>zu()??(b.stderr.isTTY&&b.stderr.hasColors?.()),stripColor:(D)=>Xi(D)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(u){return this._outputConfiguration=u._outputConfiguration,this._helpOption=u._helpOption,this._helpCommand=u._helpCommand,this._helpConfiguration=u._helpConfiguration,this._exitCallback=u._exitCallback,this._storeOptionsAsProperties=u._storeOptionsAsProperties,this._combineFlagAndOptionalValue=u._combineFlagAndOptionalValue,this._allowExcessArguments=u._allowExcessArguments,this._enablePositionalOptions=u._enablePositionalOptions,this._showHelpAfterError=u._showHelpAfterError,this._showSuggestionAfterError=u._showSuggestionAfterError,this}_getCommandAndAncestors(){let u=[];for(let D=this;D;D=D.parent)u.push(D);return u}command(u,D,t){let r=D,n=t;if(typeof r==="object"&&r!==null)n=r,r=null;n=n||{};let[,F,i]=u.match(/([^ ]+) *(.*)/),e=this.createCommand(F);if(r)e.description(r),e._executableHandler=!0;if(n.isDefault)this._defaultCommandName=e._name;if(e._hidden=!!(n.noHelp||n.hidden),e._executableFile=n.executableFile||null,i)e.arguments(i);if(this._registerCommand(e),e.parent=this,e.copyInheritedSettings(this),r)return this;return e}createCommand(u){return new Yu(u)}createHelp(){return Object.assign(new ai,this.configureHelp())}configureHelp(u){if(u===void 0)return this._helpConfiguration;return this._helpConfiguration=u,this}configureOutput(u){if(u===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,u),this}showHelpAfterError(u=!0){if(typeof u!=="string")u=!!u;return this._showHelpAfterError=u,this}showSuggestionAfterError(u=!0){return this._showSuggestionAfterError=!!u,this}addCommand(u,D){if(!u._name)throw Error(`Command passed to .addCommand() must have a name
|
|
16
|
+
- specify the name in Command constructor or using .name()`);if(D=D||{},D.isDefault)this._defaultCommandName=u._name;if(D.noHelp||D.hidden)u._hidden=!0;return this._registerCommand(u),u.parent=this,u._checkForBrokenPassThrough(),this}createArgument(u,D){return new qi(u,D)}argument(u,D,t,r){let n=this.createArgument(u,D);if(typeof t==="function")n.default(r).argParser(t);else n.default(t);return this.addArgument(n),this}arguments(u){return u.trim().split(/ +/).forEach((D)=>{this.argument(D)}),this}addArgument(u){let D=this.registeredArguments.slice(-1)[0];if(D&&D.variadic)throw Error(`only the last argument can be variadic '${D.name()}'`);if(u.required&&u.defaultValue!==void 0&&u.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${u.name()}'`);return this.registeredArguments.push(u),this}helpCommand(u,D){if(typeof u==="boolean")return this._addImplicitHelpCommand=u,this;u=u??"help [command]";let[,t,r]=u.match(/([^ ]+) *(.*)/),n=D??"display help for command",F=this.createCommand(t);if(F.helpOption(!1),r)F.arguments(r);if(n)F.description(n);return this._addImplicitHelpCommand=!0,this._helpCommand=F,this}addHelpCommand(u,D){if(typeof u!=="object")return this.helpCommand(u,D),this;return this._addImplicitHelpCommand=!0,this._helpCommand=u,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(u,D){let t=["preSubcommand","preAction","postAction"];if(!t.includes(u))throw Error(`Unexpected value for event passed to hook : '${u}'.
|
|
17
|
+
Expecting one of '${t.join("', '")}'`);if(this._lifeCycleHooks[u])this._lifeCycleHooks[u].push(D);else this._lifeCycleHooks[u]=[D];return this}exitOverride(u){if(u)this._exitCallback=u;else this._exitCallback=(D)=>{if(D.code!=="commander.executeSubCommandAsync")throw D};return this}_exit(u,D,t){if(this._exitCallback)this._exitCallback(new Wu(u,D,t));b.exit(u)}action(u){let D=(t)=>{let r=this.registeredArguments.length,n=t.slice(0,r);if(this._storeOptionsAsProperties)n[r]=this;else n[r]=this.opts();return n.push(this),u.apply(this,n)};return this._actionHandler=D,this}createOption(u,D){return new SD(u,D)}_callParseArg(u,D,t,r){try{return u.parseArg(D,t)}catch(n){if(n.code==="commander.invalidArgument"){let F=`${r} ${n.message}`;this.error(F,{exitCode:n.exitCode,code:n.code})}throw n}}_registerOption(u){let D=u.short&&this._findOption(u.short)||u.long&&this._findOption(u.long);if(D){let t=u.long&&this._findOption(u.long)?u.long:u.short;throw Error(`Cannot add option '${u.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${t}'
|
|
18
|
+
- already used by option '${D.flags}'`)}this.options.push(u)}_registerCommand(u){let D=(r)=>{return[r.name()].concat(r.aliases())},t=D(u).find((r)=>this._findCommand(r));if(t){let r=D(this._findCommand(t)).join("|"),n=D(u).join("|");throw Error(`cannot add command '${n}' as already have command '${r}'`)}this.commands.push(u)}addOption(u){this._registerOption(u);let D=u.name(),t=u.attributeName();if(u.negate){let n=u.long.replace(/^--no-/,"--");if(!this._findOption(n))this.setOptionValueWithSource(t,u.defaultValue===void 0?!0:u.defaultValue,"default")}else if(u.defaultValue!==void 0)this.setOptionValueWithSource(t,u.defaultValue,"default");let r=(n,F,i)=>{if(n==null&&u.presetArg!==void 0)n=u.presetArg;let e=this.getOptionValue(t);if(n!==null&&u.parseArg)n=this._callParseArg(u,n,e,F);else if(n!==null&&u.variadic)n=u._concatValue(n,e);if(n==null)if(u.negate)n=!1;else if(u.isBoolean()||u.optional)n=!0;else n="";this.setOptionValueWithSource(t,n,i)};if(this.on("option:"+D,(n)=>{let F=`error: option '${u.flags}' argument '${n}' is invalid.`;r(n,F,"cli")}),u.envVar)this.on("optionEnv:"+D,(n)=>{let F=`error: option '${u.flags}' value '${n}' from env '${u.envVar}' is invalid.`;r(n,F,"env")});return this}_optionEx(u,D,t,r,n){if(typeof D==="object"&&D instanceof SD)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let F=this.createOption(D,t);if(F.makeOptionMandatory(!!u.mandatory),typeof r==="function")F.default(n).argParser(r);else if(r instanceof RegExp){let i=r;r=(e,s)=>{let f=i.exec(e);return f?f[0]:s},F.default(n).argParser(r)}else F.default(r);return this.addOption(F)}option(u,D,t,r){return this._optionEx({},u,D,t,r)}requiredOption(u,D,t,r){return this._optionEx({mandatory:!0},u,D,t,r)}combineFlagAndOptionalValue(u=!0){return this._combineFlagAndOptionalValue=!!u,this}allowUnknownOption(u=!0){return this._allowUnknownOption=!!u,this}allowExcessArguments(u=!0){return this._allowExcessArguments=!!u,this}enablePositionalOptions(u=!0){return this._enablePositionalOptions=!!u,this}passThroughOptions(u=!0){return this._passThroughOptions=!!u,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(u=!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=!!u,this}getOptionValue(u){if(this._storeOptionsAsProperties)return this[u];return this._optionValues[u]}setOptionValue(u,D){return this.setOptionValueWithSource(u,D,void 0)}setOptionValueWithSource(u,D,t){if(this._storeOptionsAsProperties)this[u]=D;else this._optionValues[u]=D;return this._optionValueSources[u]=t,this}getOptionValueSource(u){return this._optionValueSources[u]}getOptionValueSourceWithGlobals(u){let D;return this._getCommandAndAncestors().forEach((t)=>{if(t.getOptionValueSource(u)!==void 0)D=t.getOptionValueSource(u)}),D}_prepareUserArgs(u,D){if(u!==void 0&&!Array.isArray(u))throw Error("first parameter to parse must be array or undefined");if(D=D||{},u===void 0&&D.from===void 0){if(b.versions?.electron)D.from="electron";let r=b.execArgv??[];if(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))D.from="eval"}if(u===void 0)u=b.argv;this.rawArgs=u.slice();let t;switch(D.from){case void 0:case"node":this._scriptPath=u[1],t=u.slice(2);break;case"electron":if(b.defaultApp)this._scriptPath=u[1],t=u.slice(2);else t=u.slice(1);break;case"user":t=u.slice(0);break;case"eval":t=u.slice(1);break;default:throw Error(`unexpected parse option { from: '${D.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",t}parse(u,D){this._prepareForParse();let t=this._prepareUserArgs(u,D);return this._parseCommand([],t),this}async parseAsync(u,D){this._prepareForParse();let t=this._prepareUserArgs(u,D);return await this._parseCommand([],t),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
19
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(u,D,t){if(Bu.existsSync(u))return;let r=D?`searched for local subcommand relative to directory '${D}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",n=`'${u}' does not exist
|
|
20
|
+
- if '${t}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
21
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
22
|
+
- ${r}`;throw Error(n)}_executeSubCommand(u,D){D=D.slice();let t=!1,r=[".js",".ts",".tsx",".mjs",".cjs"];function n(f,C){let E=a.resolve(f,C);if(Bu.existsSync(E))return E;if(r.includes(a.extname(C)))return;let c=r.find((B)=>Bu.existsSync(`${E}${B}`));if(c)return`${E}${c}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let F=u._executableFile||`${this._name}-${u._name}`,i=this._executableDir||"";if(this._scriptPath){let f;try{f=Bu.realpathSync(this._scriptPath)}catch{f=this._scriptPath}i=a.resolve(a.dirname(f),i)}if(i){let f=n(i,F);if(!f&&!u._executableFile&&this._scriptPath){let C=a.basename(this._scriptPath,a.extname(this._scriptPath));if(C!==this._name)f=n(i,`${C}-${u._name}`)}F=f||F}t=r.includes(a.extname(F));let e;if(b.platform!=="win32")if(t)D.unshift(F),D=yD(b.execArgv).concat(D),e=Qu.spawn(b.argv[0],D,{stdio:"inherit"});else e=Qu.spawn(F,D,{stdio:"inherit"});else this._checkForMissingExecutable(F,i,u._name),D.unshift(F),D=yD(b.execArgv).concat(D),e=Qu.spawn(b.execPath,D,{stdio:"inherit"});if(!e.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((C)=>{b.on(C,()=>{if(e.killed===!1&&e.exitCode===null)e.kill(C)})});let s=this._exitCallback;e.on("close",(f)=>{if(f=f??1,!s)b.exit(f);else s(new Wu(f,"commander.executeSubCommandAsync","(close)"))}),e.on("error",(f)=>{if(f.code==="ENOENT")this._checkForMissingExecutable(F,i,u._name);else if(f.code==="EACCES")throw Error(`'${F}' not executable`);if(!s)b.exit(1);else{let C=new Wu(1,"commander.executeSubCommandAsync","(error)");C.nestedError=f,s(C)}}),this.runningCommand=e}_dispatchSubcommand(u,D,t){let r=this._findCommand(u);if(!r)this.help({error:!0});r._prepareForParse();let n;return n=this._chainOrCallSubCommandHook(n,r,"preSubcommand"),n=this._chainOrCall(n,()=>{if(r._executableHandler)this._executeSubCommand(r,D.concat(t));else return r._parseCommand(D,t)}),n}_dispatchHelpCommand(u){if(!u)this.help();let D=this._findCommand(u);if(D&&!D._executableHandler)D.help();return this._dispatchSubcommand(u,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((u,D)=>{if(u.required&&this.args[D]==null)this.missingArgument(u.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 u=(t,r,n)=>{let F=r;if(r!==null&&t.parseArg){let i=`error: command-argument value '${r}' is invalid for argument '${t.name()}'.`;F=this._callParseArg(t,r,n,i)}return F};this._checkNumberOfArguments();let D=[];this.registeredArguments.forEach((t,r)=>{let n=t.defaultValue;if(t.variadic){if(r<this.args.length){if(n=this.args.slice(r),t.parseArg)n=n.reduce((F,i)=>{return u(t,i,F)},t.defaultValue)}else if(n===void 0)n=[]}else if(r<this.args.length){if(n=this.args[r],t.parseArg)n=u(t,n,t.defaultValue)}D[r]=n}),this.processedArgs=D}_chainOrCall(u,D){if(u&&u.then&&typeof u.then==="function")return u.then(()=>D());return D()}_chainOrCallHooks(u,D){let t=u,r=[];if(this._getCommandAndAncestors().reverse().filter((n)=>n._lifeCycleHooks[D]!==void 0).forEach((n)=>{n._lifeCycleHooks[D].forEach((F)=>{r.push({hookedCommand:n,callback:F})})}),D==="postAction")r.reverse();return r.forEach((n)=>{t=this._chainOrCall(t,()=>{return n.callback(n.hookedCommand,this)})}),t}_chainOrCallSubCommandHook(u,D,t){let r=u;if(this._lifeCycleHooks[t]!==void 0)this._lifeCycleHooks[t].forEach((n)=>{r=this._chainOrCall(r,()=>{return n(this,D)})});return r}_parseCommand(u,D){let t=this.parseOptions(D);if(this._parseOptionsEnv(),this._parseOptionsImplied(),u=u.concat(t.operands),D=t.unknown,this.args=u.concat(D),u&&this._findCommand(u[0]))return this._dispatchSubcommand(u[0],u.slice(1),D);if(this._getHelpCommand()&&u[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(u[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(D),this._dispatchSubcommand(this._defaultCommandName,u,D);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(t.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{if(t.unknown.length>0)this.unknownOption(t.unknown[0])},n=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let F;if(F=this._chainOrCallHooks(F,"preAction"),F=this._chainOrCall(F,()=>this._actionHandler(this.processedArgs)),this.parent)F=this._chainOrCall(F,()=>{this.parent.emit(n,u,D)});return F=this._chainOrCallHooks(F,"postAction"),F}if(this.parent&&this.parent.listenerCount(n))r(),this._processArguments(),this.parent.emit(n,u,D);else if(u.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",u,D);if(this.listenerCount("command:*"))this.emit("command:*",u,D);else if(this.commands.length)this.unknownCommand();else r(),this._processArguments()}else if(this.commands.length)r(),this.help({error:!0});else r(),this._processArguments()}_findCommand(u){if(!u)return;return this.commands.find((D)=>D._name===u||D._aliases.includes(u))}_findOption(u){return this.options.find((D)=>D.is(u))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((u)=>{u.options.forEach((D)=>{if(D.mandatory&&u.getOptionValue(D.attributeName())===void 0)u.missingMandatoryOptionValue(D)})})}_checkForConflictingLocalOptions(){let u=this.options.filter((t)=>{let r=t.attributeName();if(this.getOptionValue(r)===void 0)return!1;return this.getOptionValueSource(r)!=="default"});u.filter((t)=>t.conflictsWith.length>0).forEach((t)=>{let r=u.find((n)=>t.conflictsWith.includes(n.attributeName()));if(r)this._conflictingOption(t,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((u)=>{u._checkForConflictingLocalOptions()})}parseOptions(u){let D=[],t=[],r=D,n=u.slice();function F(e){return e.length>1&&e[0]==="-"}let i=null;while(n.length){let e=n.shift();if(e==="--"){if(r===t)r.push(e);r.push(...n);break}if(i&&!F(e)){this.emit(`option:${i.name()}`,e);continue}if(i=null,F(e)){let s=this._findOption(e);if(s){if(s.required){let f=n.shift();if(f===void 0)this.optionMissingArgument(s);this.emit(`option:${s.name()}`,f)}else if(s.optional){let f=null;if(n.length>0&&!F(n[0]))f=n.shift();this.emit(`option:${s.name()}`,f)}else this.emit(`option:${s.name()}`);i=s.variadic?s:null;continue}}if(e.length>2&&e[0]==="-"&&e[1]!=="-"){let s=this._findOption(`-${e[1]}`);if(s){if(s.required||s.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${s.name()}`,e.slice(2));else this.emit(`option:${s.name()}`),n.unshift(`-${e.slice(2)}`);continue}}if(/^--[^=]+=/.test(e)){let s=e.indexOf("="),f=this._findOption(e.slice(0,s));if(f&&(f.required||f.optional)){this.emit(`option:${f.name()}`,e.slice(s+1));continue}}if(F(e))r=t;if((this._enablePositionalOptions||this._passThroughOptions)&&D.length===0&&t.length===0){if(this._findCommand(e)){if(D.push(e),n.length>0)t.push(...n);break}else if(this._getHelpCommand()&&e===this._getHelpCommand().name()){if(D.push(e),n.length>0)D.push(...n);break}else if(this._defaultCommandName){if(t.push(e),n.length>0)t.push(...n);break}}if(this._passThroughOptions){if(r.push(e),n.length>0)r.push(...n);break}r.push(e)}return{operands:D,unknown:t}}opts(){if(this._storeOptionsAsProperties){let u={},D=this.options.length;for(let t=0;t<D;t++){let r=this.options[t].attributeName();u[r]=r===this._versionOptionName?this._version:this[r]}return u}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((u,D)=>Object.assign(u,D.opts()),{})}error(u,D){if(this._outputConfiguration.outputError(`${u}
|
|
23
|
+
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
24
|
+
`);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
|
|
25
|
+
`),this.outputHelp({error:!0});let t=D||{},r=t.exitCode||1,n=t.code||"commander.error";this._exit(r,n,u)}_parseOptionsEnv(){this.options.forEach((u)=>{if(u.envVar&&u.envVar in b.env){let D=u.attributeName();if(this.getOptionValue(D)===void 0||["default","config","env"].includes(this.getOptionValueSource(D)))if(u.required||u.optional)this.emit(`optionEnv:${u.name()}`,b.env[u.envVar]);else this.emit(`optionEnv:${u.name()}`)}})}_parseOptionsImplied(){let u=new Hi(this.options),D=(t)=>{return this.getOptionValue(t)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(t))};this.options.filter((t)=>t.implied!==void 0&&D(t.attributeName())&&u.valueFromOption(this.getOptionValue(t.attributeName()),t)).forEach((t)=>{Object.keys(t.implied).filter((r)=>!D(r)).forEach((r)=>{this.setOptionValueWithSource(r,t.implied[r],"implied")})})}missingArgument(u){let D=`error: missing required argument '${u}'`;this.error(D,{code:"commander.missingArgument"})}optionMissingArgument(u){let D=`error: option '${u.flags}' argument missing`;this.error(D,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(u){let D=`error: required option '${u.flags}' not specified`;this.error(D,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(u,D){let t=(F)=>{let i=F.attributeName(),e=this.getOptionValue(i),s=this.options.find((C)=>C.negate&&i===C.attributeName()),f=this.options.find((C)=>!C.negate&&i===C.attributeName());if(s&&(s.presetArg===void 0&&e===!1||s.presetArg!==void 0&&e===s.presetArg))return s;return f||F},r=(F)=>{let i=t(F),e=i.attributeName();if(this.getOptionValueSource(e)==="env")return`environment variable '${i.envVar}'`;return`option '${i.flags}'`},n=`error: ${r(u)} cannot be used with ${r(D)}`;this.error(n,{code:"commander.conflictingOption"})}unknownOption(u){if(this._allowUnknownOption)return;let D="";if(u.startsWith("--")&&this._showSuggestionAfterError){let r=[],n=this;do{let F=n.createHelp().visibleOptions(n).filter((i)=>i.long).map((i)=>i.long);r=r.concat(F),n=n.parent}while(n&&!n._enablePositionalOptions);D=TD(u,r)}let t=`error: unknown option '${u}'${D}`;this.error(t,{code:"commander.unknownOption"})}_excessArguments(u){if(this._allowExcessArguments)return;let D=this.registeredArguments.length,t=D===1?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${D} argument${t} but got ${u.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){let u=this.args[0],D="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach((n)=>{if(r.push(n.name()),n.alias())r.push(n.alias())}),D=TD(u,r)}let t=`error: unknown command '${u}'${D}`;this.error(t,{code:"commander.unknownCommand"})}version(u,D,t){if(u===void 0)return this._version;this._version=u,D=D||"-V, --version",t=t||"output the version number";let r=this.createOption(D,t);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${u}
|
|
26
|
+
`),this._exit(0,"commander.version",u)}),this}description(u,D){if(u===void 0&&D===void 0)return this._description;if(this._description=u,D)this._argsDescription=D;return this}summary(u){if(u===void 0)return this._summary;return this._summary=u,this}alias(u){if(u===void 0)return this._aliases[0];let D=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)D=this.commands[this.commands.length-1];if(u===D._name)throw Error("Command alias can't be the same as its name");let t=this.parent?._findCommand(u);if(t){let r=[t.name()].concat(t.aliases()).join("|");throw Error(`cannot add alias '${u}' to command '${this.name()}' as already have command '${r}'`)}return D._aliases.push(u),this}aliases(u){if(u===void 0)return this._aliases;return u.forEach((D)=>this.alias(D)),this}usage(u){if(u===void 0){if(this._usage)return this._usage;let D=this.registeredArguments.map((t)=>{return Zi(t)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?D:[]).join(" ")}return this._usage=u,this}name(u){if(u===void 0)return this._name;return this._name=u,this}nameFromFilename(u){return this._name=a.basename(u,a.extname(u)),this}executableDir(u){if(u===void 0)return this._executableDir;return this._executableDir=u,this}helpInformation(u){let D=this.createHelp(),t=this._getOutputContext(u);D.prepareContext({error:t.error,helpWidth:t.helpWidth,outputHasColors:t.hasColors});let r=D.formatHelp(this,D);if(t.hasColors)return r;return this._outputConfiguration.stripColor(r)}_getOutputContext(u){u=u||{};let D=!!u.error,t,r,n;if(D)t=(i)=>this._outputConfiguration.writeErr(i),r=this._outputConfiguration.getErrHasColors(),n=this._outputConfiguration.getErrHelpWidth();else t=(i)=>this._outputConfiguration.writeOut(i),r=this._outputConfiguration.getOutHasColors(),n=this._outputConfiguration.getOutHelpWidth();return{error:D,write:(i)=>{if(!r)i=this._outputConfiguration.stripColor(i);return t(i)},hasColors:r,helpWidth:n}}outputHelp(u){let D;if(typeof u==="function")D=u,u=void 0;let t=this._getOutputContext(u),r={error:t.error,write:t.write,command:this};this._getCommandAndAncestors().reverse().forEach((F)=>F.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let n=this.helpInformation({error:t.error});if(D){if(n=D(n),typeof n!=="string"&&!Buffer.isBuffer(n))throw Error("outputHelp callback must return a string or a Buffer")}if(t.write(n),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",r),this._getCommandAndAncestors().forEach((F)=>F.emit("afterAllHelp",r))}helpOption(u,D){if(typeof u==="boolean"){if(u)this._helpOption=this._helpOption??void 0;else this._helpOption=null;return this}return u=u??"-h, --help",D=D??"display help for command",this._helpOption=this.createOption(u,D),this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(u){return this._helpOption=u,this}help(u){this.outputHelp(u);let D=Number(b.exitCode??0);if(D===0&&u&&typeof u!=="function"&&u.error)D=1;this._exit(D,"commander.help","(outputHelp)")}addHelpText(u,D){let t=["beforeAll","before","after","afterAll"];if(!t.includes(u))throw Error(`Unexpected value for position to addHelpText.
|
|
27
|
+
Expecting one of '${t.join("', '")}'`);let r=`${u}Help`;return this.on(r,(n)=>{let F;if(typeof D==="function")F=D({error:n.error,command:n.command});else F=D;if(F)n.write(`${F}
|
|
28
|
+
`)}),this}_outputHelpIfRequested(u){let D=this._getHelpOption();if(D&&u.find((r)=>D.is(r)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function yD(u){return u.map((D)=>{if(!D.startsWith("--inspect"))return D;let t,r="127.0.0.1",n="9229",F;if((F=D.match(/^(--inspect(-brk)?)$/))!==null)t=F[1];else if((F=D.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(t=F[1],/^\d+$/.test(F[3]))n=F[3];else r=F[3];else if((F=D.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)t=F[1],r=F[3],n=F[4];if(t&&n!=="0")return`${t}=${r}:${parseInt(n)+1}`;return D})}function zu(){if(b.env.NO_COLOR||b.env.FORCE_COLOR==="0"||b.env.FORCE_COLOR==="false")return!1;if(b.env.FORCE_COLOR||b.env.CLICOLOR_FORCE!==void 0)return!0;return}Vi.Command=Yu;Vi.useColor=zu});var JD=O((Oi)=>{var{Argument:ID}=cu(),{Command:qu}=UD(),{CommanderError:vi,InvalidArgumentError:GD}=eu(),{Help:ji}=Lu(),{Option:ND}=Pu();Oi.program=new qu;Oi.createCommand=(u)=>new qu(u);Oi.createOption=(u,D)=>new ND(u,D);Oi.createArgument=(u,D)=>new ID(u,D);Oi.Command=qu;Oi.Option=ND;Oi.Argument=ID;Oi.Help=ji;Oi.CommanderError=vi;Oi.InvalidArgumentError=GD;Oi.InvalidOptionArgumentError=GD});var ct={};li(ct,{prompt:()=>ht,kCancel:()=>Et});import Q,{stdin as U2,stdout as I2}from"process";import XD from"readline";import{WriteStream as G2}from"tty";function N2(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}function J2(){if(HD)return vu;HD=1;let u="\x1B",D=`${u}[`,t="\x07",r={to(i,e){if(!e)return`${D}${i+1}G`;return`${D}${e+1};${i+1}H`},move(i,e){let s="";if(i<0)s+=`${D}${-i}D`;else if(i>0)s+=`${D}${i}C`;if(e<0)s+=`${D}${-e}A`;else if(e>0)s+=`${D}${e}B`;return s},up:(i=1)=>`${D}${i}A`,down:(i=1)=>`${D}${i}B`,forward:(i=1)=>`${D}${i}C`,backward:(i=1)=>`${D}${i}D`,nextLine:(i=1)=>`${D}E`.repeat(i),prevLine:(i=1)=>`${D}F`.repeat(i),left:`${D}G`,hide:`${D}?25l`,show:`${D}?25h`,save:`${u}7`,restore:`${u}8`},n={up:(i=1)=>`${D}S`.repeat(i),down:(i=1)=>`${D}T`.repeat(i)},F={screen:`${D}2J`,up:(i=1)=>`${D}1J`.repeat(i),down:(i=1)=>`${D}J`.repeat(i),line:`${D}2K`,lineEnd:`${D}K`,lineStart:`${D}1K`,lines(i){let e="";for(let s=0;s<i;s++)e+=this.line+(s<i-1?r.up():"");if(i)e+=r.left;return e}};return vu={cursor:r,scroll:n,erase:F,beep:t},vu}function M2(){if(VD)return $u.exports;VD=1;let u=process||{},D=u.argv||[],t=u.env||{},r=!(!!t.NO_COLOR||D.includes("--no-color"))&&(!!t.FORCE_COLOR||D.includes("--color")||u.platform==="win32"||(u.stdout||{}).isTTY&&t.TERM!=="dumb"||!!t.CI),n=(e,s,f=e)=>(C)=>{let E=""+C,c=E.indexOf(s,e.length);return~c?e+F(E,s,f,c)+s:e+E+s},F=(e,s,f,C)=>{let E="",c=0;do E+=e.substring(c,C)+f,c=C+s.length,C=e.indexOf(s,c);while(~C);return E+e.substring(c)},i=(e=r)=>{let s=e?n:()=>String;return{isColorSupported:e,reset:s("\x1B[0m","\x1B[0m"),bold:s("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:s("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:s("\x1B[3m","\x1B[23m"),underline:s("\x1B[4m","\x1B[24m"),inverse:s("\x1B[7m","\x1B[27m"),hidden:s("\x1B[8m","\x1B[28m"),strikethrough:s("\x1B[9m","\x1B[29m"),black:s("\x1B[30m","\x1B[39m"),red:s("\x1B[31m","\x1B[39m"),green:s("\x1B[32m","\x1B[39m"),yellow:s("\x1B[33m","\x1B[39m"),blue:s("\x1B[34m","\x1B[39m"),magenta:s("\x1B[35m","\x1B[39m"),cyan:s("\x1B[36m","\x1B[39m"),white:s("\x1B[37m","\x1B[39m"),gray:s("\x1B[90m","\x1B[39m"),bgBlack:s("\x1B[40m","\x1B[49m"),bgRed:s("\x1B[41m","\x1B[49m"),bgGreen:s("\x1B[42m","\x1B[49m"),bgYellow:s("\x1B[43m","\x1B[49m"),bgBlue:s("\x1B[44m","\x1B[49m"),bgMagenta:s("\x1B[45m","\x1B[49m"),bgCyan:s("\x1B[46m","\x1B[49m"),bgWhite:s("\x1B[47m","\x1B[49m"),blackBright:s("\x1B[90m","\x1B[39m"),redBright:s("\x1B[91m","\x1B[39m"),greenBright:s("\x1B[92m","\x1B[39m"),yellowBright:s("\x1B[93m","\x1B[39m"),blueBright:s("\x1B[94m","\x1B[39m"),magentaBright:s("\x1B[95m","\x1B[39m"),cyanBright:s("\x1B[96m","\x1B[39m"),whiteBright:s("\x1B[97m","\x1B[39m"),bgBlackBright:s("\x1B[100m","\x1B[49m"),bgRedBright:s("\x1B[101m","\x1B[49m"),bgGreenBright:s("\x1B[102m","\x1B[49m"),bgYellowBright:s("\x1B[103m","\x1B[49m"),bgBlueBright:s("\x1B[104m","\x1B[49m"),bgMagentaBright:s("\x1B[105m","\x1B[49m"),bgCyanBright:s("\x1B[106m","\x1B[49m"),bgWhiteBright:s("\x1B[107m","\x1B[49m")}};return $u.exports=i(),$u.exports.createColors=i,$u.exports}function L2({onlyFirst:u=!1}={}){let D=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(D,u?void 0:"g")}function tt(u){if(typeof u!="string")throw TypeError(`Expected a \`string\`, got \`${typeof u}\``);return u.replace(P2,"")}function it(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}function su(u,D={}){if(typeof u!="string"||u.length===0||(D={ambiguousIsNarrow:!0,...D},u=tt(u),u.length===0))return 0;u=u.replace(Y2()," ");let t=D.ambiguousIsNarrow?1:2,r=0;for(let n of u){let F=n.codePointAt(0);if(F<=31||F>=127&&F<=159||F>=768&&F<=879)continue;switch(W2.eastAsianWidth(n)){case"F":case"W":r+=2;break;case"A":r+=t;break;default:r+=1}}return r}function a2(){let u=new Map;for(let[D,t]of Object.entries(U)){for(let[r,n]of Object.entries(t))U[r]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},t[r]=U[r],u.set(n[0],n[1]);Object.defineProperty(U,D,{value:t,enumerable:!1})}return Object.defineProperty(U,"codes",{value:u,enumerable:!1}),U.color.close="\x1B[39m",U.bgColor.close="\x1B[49m",U.color.ansi=kD(),U.color.ansi256=KD(),U.color.ansi16m=vD(),U.bgColor.ansi=kD(ju),U.bgColor.ansi256=KD(ju),U.bgColor.ansi16m=vD(ju),Object.defineProperties(U,{rgbToAnsi256:{value:(D,t,r)=>D===t&&t===r?D<8?16:D>248?231:Math.round((D-8)/247*24)+232:16+36*Math.round(D/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value:(D)=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(D.toString(16));if(!t)return[0,0,0];let[r]=t;r.length===3&&(r=[...r].map((F)=>F+F).join(""));let n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:(D)=>U.rgbToAnsi256(...U.hexToRgb(D)),enumerable:!1},ansi256ToAnsi:{value:(D)=>{if(D<8)return 30+D;if(D<16)return 90+(D-8);let t,r,n;if(D>=232)t=((D-232)*10+8)/255,r=t,n=t;else{D-=16;let e=D%36;t=Math.floor(D/36)/5,r=Math.floor(e/6)/5,n=e%6/5}let F=Math.max(t,r,n)*2;if(F===0)return 30;let i=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return F===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(D,t,r)=>U.ansi256ToAnsi(U.rgbToAnsi256(D,t,r)),enumerable:!1},hexToAnsi:{value:(D)=>U.ansi256ToAnsi(U.hexToAnsi256(D)),enumerable:!1}}),U}function dD(u,D,t){return String(u).normalize().replace(/\r\n/g,`
|
|
29
|
+
`).split(`
|
|
30
|
+
`).map((r)=>v2(r,D,t)).join(`
|
|
31
|
+
`)}function et(u,D){if(typeof u=="string")return wu.aliases.get(u)===D;for(let t of u)if(t!==void 0&&et(t,D))return!0;return!1}function O2(u,D){if(u===D)return;let t=u.split(`
|
|
32
|
+
`),r=D.split(`
|
|
33
|
+
`),n=[];for(let F=0;F<Math.max(t.length,r.length);F++)t[F]!==r[F]&&n.push(F);return n}function Au(u,D){let t=u;t.isTTY&&t.setRawMode(D)}class Cu{constructor(u,D=!0){L(this,"input"),L(this,"output"),L(this,"_abortSignal"),L(this,"rl"),L(this,"opts"),L(this,"_render"),L(this,"_track",!1),L(this,"_prevFrame",""),L(this,"_subscribers",new Map),L(this,"_cursor",0),L(this,"state","initial"),L(this,"error",""),L(this,"value");let{input:t=U2,output:r=I2,render:n,signal:F,...i}=u;this.opts=i,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=n.bind(this),this._track=D,this._abortSignal=F,this.input=t,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(u,D){let t=this._subscribers.get(u)??[];t.push(D),this._subscribers.set(u,t)}on(u,D){this.setSubscriber(u,{cb:D})}once(u,D){this.setSubscriber(u,{cb:D,once:!0})}emit(u,...D){let t=this._subscribers.get(u)??[],r=[];for(let n of t)n.cb(...D),n.once&&r.push(()=>t.splice(t.indexOf(n),1));for(let n of r)n()}prompt(){return new Promise((u,D)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),u(pD);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let t=new G2(0);t._write=(r,n,F)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),F()},this.input.pipe(t),this.rl=XD.createInterface({input:this.input,output:t,tabSize:2,prompt:"",escapeCodeTimeout:50}),XD.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),Au(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(W.cursor.show),this.output.off("resize",this.render),Au(this.input,!1),u(this.value)}),this.once("cancel",()=>{this.output.write(W.cursor.show),this.output.off("resize",this.render),Au(this.input,!1),u(pD)})})}onKeypress(u,D){if(this.state==="error"&&(this.state="active"),D?.name&&(!this._track&&wu.aliases.has(D.name)&&this.emit("cursor",wu.aliases.get(D.name)),wu.actions.has(D.name)&&this.emit("cursor",D.name)),u&&(u.toLowerCase()==="y"||u.toLowerCase()==="n")&&this.emit("confirm",u.toLowerCase()==="y"),u==="\t"&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),u&&this.emit("key",u.toLowerCase()),D?.name==="return"){if(this.opts.validate){let t=this.opts.validate(this.value);t&&(this.error=t instanceof Error?t.message:t,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}et([u,D?.name,D?.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(`
|
|
34
|
+
`),Au(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let u=dD(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
35
|
+
`).length-1;this.output.write(W.cursor.move(-999,u*-1))}render(){let u=dD(this._render(this)??"",process.stdout.columns,{hard:!0});if(u!==this._prevFrame){if(this.state==="initial")this.output.write(W.cursor.hide);else{let D=O2(this._prevFrame,u);if(this.restoreCursor(),D&&D?.length===1){let t=D[0];this.output.write(W.cursor.move(0,t)),this.output.write(W.erase.lines(1));let r=u.split(`
|
|
36
|
+
`);this.output.write(r[t]),this._prevFrame=u,this.output.write(W.cursor.move(0,r.length-t-1));return}if(D&&D?.length>1){let t=D[0];this.output.write(W.cursor.move(0,t)),this.output.write(W.erase.down());let r=u.split(`
|
|
37
|
+
`).slice(t);this.output.write(r.join(`
|
|
38
|
+
`)),this._prevFrame=u;return}this.output.write(W.erase.down())}this.output.write(u),this.state==="initial"&&(this.state="active"),this._prevFrame=u}}}function rr(){return Q.platform!=="win32"?Q.env.TERM!=="linux":!!Q.env.CI||!!Q.env.WT_SESSION||!!Q.env.TERMINUS_SUBLIME||Q.env.ConEmuTask==="{cmd::Cmder}"||Q.env.TERM_PROGRAM==="Terminus-Sublime"||Q.env.TERM_PROGRAM==="vscode"||Q.env.TERM==="xterm-256color"||Q.env.TERM==="alacritty"||Q.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}async function ht(u,D={}){let t=(r)=>{if(typeof r!=="symbol"||r.toString()!=="Symbol(clack:cancel)")return r;switch(D.cancel){case"reject":{let n=Error("Prompt cancelled.");if(n.name="ConsolaPromptCancelledError",Error.captureStackTrace)Error.captureStackTrace(n,ht);throw n}case"undefined":return;case"null":return null;case"symbol":return Et;default:case"default":return D.default??D.initial}};if(!D.type||D.type==="text")return await hr({message:u,defaultValue:D.default,placeholder:D.placeholder,initialValue:D.initial}).then(t);if(D.type==="confirm")return await cr({message:u,initialValue:D.initial}).then(t);if(D.type==="select")return await Br({message:u,options:D.options.map((r)=>typeof r==="string"?{value:r,label:r}:r),initialValue:D.initial}).then(t);if(D.type==="multiselect")return await or({message:u,options:D.options.map((r)=>typeof r==="string"?{value:r,label:r}:r),required:D.required,initialValues:D.initial}).then(t);throw Error(`Unknown prompt type: ${D.type}`)}var vu,HD,W,$u,VD,g2,h,P2,rt,Q2,W2,z2=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},Y2,ju=10,kD=(u=0)=>(D)=>`\x1B[${D+u}m`,KD=(u=0)=>(D)=>`\x1B[${38+u};5;${D}m`,vD=(u=0)=>(D,t,r)=>`\x1B[${38+u};2;${D};${t};${r}m`,U,q2,Z2,X2,_u,H2=39,uD="\x07",nt="[",V2="]",Ft="m",DD,jD=(u)=>`${_u.values().next().value}${nt}${u}${Ft}`,OD=(u)=>`${_u.values().next().value}${DD}${u}${uD}`,k2=(u)=>u.split(" ").map((D)=>su(D)),Ou=(u,D,t)=>{let r=[...D],n=!1,F=!1,i=su(tt(u[u.length-1]));for(let[e,s]of r.entries()){let f=su(s);if(i+f<=t?u[u.length-1]+=s:(u.push(s),i=0),_u.has(s)&&(n=!0,F=r.slice(e+1).join("").startsWith(DD)),n){F?s===uD&&(n=!1,F=!1):s===Ft&&(n=!1);continue}i+=f,i===t&&e<r.length-1&&(u.push(""),i=0)}!i&&u[u.length-1].length>0&&u.length>1&&(u[u.length-2]+=u.pop())},K2=(u)=>{let D=u.split(" "),t=D.length;for(;t>0&&!(su(D[t-1])>0);)t--;return t===D.length?u:D.slice(0,t).join(" ")+D.slice(t).join("")},v2=(u,D,t={})=>{if(t.trim!==!1&&u.trim()==="")return"";let r="",n,F,i=k2(u),e=[""];for(let[f,C]of u.split(" ").entries()){t.trim!==!1&&(e[e.length-1]=e[e.length-1].trimStart());let E=su(e[e.length-1]);if(f!==0&&(E>=D&&(t.wordWrap===!1||t.trim===!1)&&(e.push(""),E=0),(E>0||t.trim===!1)&&(e[e.length-1]+=" ",E++)),t.hard&&i[f]>D){let c=D-E,B=1+Math.floor((i[f]-c-1)/D);Math.floor((i[f]-1)/D)<B&&e.push(""),Ou(e,C,D);continue}if(E+i[f]>D&&E>0&&i[f]>0){if(t.wordWrap===!1&&E<D){Ou(e,C,D);continue}e.push("")}if(E+i[f]>D&&t.wordWrap===!1){Ou(e,C,D);continue}e[e.length-1]+=C}t.trim!==!1&&(e=e.map((f)=>K2(f)));let s=[...e.join(`
|
|
39
|
+
`)];for(let[f,C]of s.entries()){if(r+=C,_u.has(C)){let{groups:c}=new RegExp(`(?:\\${nt}(?<code>\\d+)m|\\${DD}(?<uri>.*)${uD})`).exec(s.slice(f).join(""))||{groups:{}};if(c.code!==void 0){let B=Number.parseFloat(c.code);n=B===H2?void 0:B}else c.uri!==void 0&&(F=c.uri.length===0?void 0:c.uri)}let E=X2.codes.get(Number(n));s[f+1]===`
|
|
40
|
+
`?(F&&(r+=OD("")),n&&E&&(r+=jD(E))):C===`
|
|
41
|
+
`&&(n&&E&&(r+=jD(n)),F&&(r+=OD(F)))}return r},j2,wu,pD,d2,p2=(u,D,t)=>(D in u)?d2(u,D,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[D]=t,L=(u,D,t)=>(p2(u,typeof D!="symbol"?D+"":D,t),t),st,x2,ur=(u,D,t)=>(D in u)?x2(u,D,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[D]=t,xD=(u,D,t)=>(ur(u,typeof D!="symbol"?D+"":D,t),t),Dr,tr,ir=(u,D,t)=>(D in u)?tr(u,D,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[D]=t,ut=(u,D,t)=>(ir(u,typeof D!="symbol"?D+"":D,t),t),Ct,ft,nr,z=(u,D)=>nr?u:D,Fr,er,sr,Cr,T,tu,du,pu,fr,Dt,Er,mu=(u)=>{switch(u){case"initial":case"active":return h.cyan(Fr);case"cancel":return h.red(er);case"error":return h.yellow(sr);case"submit":return h.green(Cr)}},xu=(u)=>{let{cursor:D,options:t,style:r}=u,n=u.maxItems??Number.POSITIVE_INFINITY,F=Math.max(process.stdout.rows-4,0),i=Math.min(F,Math.max(n,5)),e=0;D>=e+i-3?e=Math.max(Math.min(D-i+3,t.length-i),0):D<e+2&&(e=Math.max(D-2,0));let s=i<t.length&&e>0,f=i<t.length&&e+i<t.length;return t.slice(e,e+i).map((C,E,c)=>{let B=E===0&&s,A=E===c.length-1&&f;return B||A?h.dim("..."):r(C,E+e===D)})},hr=(u)=>new ft({validate:u.validate,placeholder:u.placeholder,defaultValue:u.defaultValue,initialValue:u.initialValue,render(){let D=`${h.gray(T)}
|
|
42
|
+
${mu(this.state)} ${u.message}
|
|
43
|
+
`,t=u.placeholder?h.inverse(u.placeholder[0])+h.dim(u.placeholder.slice(1)):h.inverse(h.hidden("_")),r=this.value?this.valueWithCursor:t;switch(this.state){case"error":return`${D.trim()}
|
|
44
|
+
${h.yellow(T)} ${r}
|
|
45
|
+
${h.yellow(tu)} ${h.yellow(this.error)}
|
|
46
|
+
`;case"submit":return`${D}${h.gray(T)} ${h.dim(this.value||u.placeholder)}`;case"cancel":return`${D}${h.gray(T)} ${h.strikethrough(h.dim(this.value??""))}${this.value?.trim()?`
|
|
47
|
+
${h.gray(T)}`:""}`;default:return`${D}${h.cyan(T)} ${r}
|
|
48
|
+
${h.cyan(tu)}
|
|
49
|
+
`}}}).prompt(),cr=(u)=>{let D=u.active??"Yes",t=u.inactive??"No";return new st({active:D,inactive:t,initialValue:u.initialValue??!0,render(){let r=`${h.gray(T)}
|
|
50
|
+
${mu(this.state)} ${u.message}
|
|
51
|
+
`,n=this.value?D:t;switch(this.state){case"submit":return`${r}${h.gray(T)} ${h.dim(n)}`;case"cancel":return`${r}${h.gray(T)} ${h.strikethrough(h.dim(n))}
|
|
52
|
+
${h.gray(T)}`;default:return`${r}${h.cyan(T)} ${this.value?`${h.green(du)} ${D}`:`${h.dim(pu)} ${h.dim(D)}`} ${h.dim("/")} ${this.value?`${h.dim(pu)} ${h.dim(t)}`:`${h.green(du)} ${t}`}
|
|
53
|
+
${h.cyan(tu)}
|
|
54
|
+
`}}}).prompt()},Br=(u)=>{let D=(t,r)=>{let n=t.label??String(t.value);switch(r){case"selected":return`${h.dim(n)}`;case"active":return`${h.green(du)} ${n} ${t.hint?h.dim(`(${t.hint})`):""}`;case"cancelled":return`${h.strikethrough(h.dim(n))}`;default:return`${h.dim(pu)} ${h.dim(n)}`}};return new Ct({options:u.options,initialValue:u.initialValue,render(){let t=`${h.gray(T)}
|
|
55
|
+
${mu(this.state)} ${u.message}
|
|
56
|
+
`;switch(this.state){case"submit":return`${t}${h.gray(T)} ${D(this.options[this.cursor],"selected")}`;case"cancel":return`${t}${h.gray(T)} ${D(this.options[this.cursor],"cancelled")}
|
|
57
|
+
${h.gray(T)}`;default:return`${t}${h.cyan(T)} ${xu({cursor:this.cursor,options:this.options,maxItems:u.maxItems,style:(r,n)=>D(r,n?"active":"inactive")}).join(`
|
|
58
|
+
${h.cyan(T)} `)}
|
|
59
|
+
${h.cyan(tu)}
|
|
60
|
+
`}}}).prompt()},or=(u)=>{let D=(t,r)=>{let n=t.label??String(t.value);return r==="active"?`${h.cyan(fr)} ${n} ${t.hint?h.dim(`(${t.hint})`):""}`:r==="selected"?`${h.green(Dt)} ${h.dim(n)}`:r==="cancelled"?`${h.strikethrough(h.dim(n))}`:r==="active-selected"?`${h.green(Dt)} ${n} ${t.hint?h.dim(`(${t.hint})`):""}`:r==="submitted"?`${h.dim(n)}`:`${h.dim(Er)} ${h.dim(n)}`};return new Dr({options:u.options,initialValues:u.initialValues,required:u.required??!0,cursorAt:u.cursorAt,validate(t){if(this.required&&t.length===0)return`Please select at least one option.
|
|
61
|
+
${h.reset(h.dim(`Press ${h.gray(h.bgWhite(h.inverse(" space ")))} to select, ${h.gray(h.bgWhite(h.inverse(" enter ")))} to submit`))}`},render(){let t=`${h.gray(T)}
|
|
62
|
+
${mu(this.state)} ${u.message}
|
|
63
|
+
`,r=(n,F)=>{let i=this.value.includes(n.value);return F&&i?D(n,"active-selected"):i?D(n,"selected"):D(n,F?"active":"inactive")};switch(this.state){case"submit":return`${t}${h.gray(T)} ${this.options.filter(({value:n})=>this.value.includes(n)).map((n)=>D(n,"submitted")).join(h.dim(", "))||h.dim("none")}`;case"cancel":{let n=this.options.filter(({value:F})=>this.value.includes(F)).map((F)=>D(F,"cancelled")).join(h.dim(", "));return`${t}${h.gray(T)} ${n.trim()?`${n}
|
|
64
|
+
${h.gray(T)}`:""}`}case"error":{let n=this.error.split(`
|
|
65
|
+
`).map((F,i)=>i===0?`${h.yellow(tu)} ${h.yellow(F)}`:` ${F}`).join(`
|
|
66
|
+
`);return`${t+h.yellow(T)} ${xu({options:this.options,cursor:this.cursor,maxItems:u.maxItems,style:r}).join(`
|
|
67
|
+
${h.yellow(T)} `)}
|
|
68
|
+
${n}
|
|
69
|
+
`}default:return`${t}${h.cyan(T)} ${xu({options:this.options,cursor:this.cursor,maxItems:u.maxItems,style:r}).join(`
|
|
70
|
+
${h.cyan(T)} `)}
|
|
71
|
+
${h.cyan(tu)}
|
|
72
|
+
`}}}).prompt()},Et;var Bt=$i(()=>{W=J2(),$u={exports:{}};g2=M2(),h=N2(g2);P2=L2();rt={exports:{}};(function(u){var D={};u.exports=D,D.eastAsianWidth=function(r){var n=r.charCodeAt(0),F=r.length==2?r.charCodeAt(1):0,i=n;return 55296<=n&&n<=56319&&56320<=F&&F<=57343&&(n&=1023,F&=1023,i=n<<10|F,i+=65536),i==12288||65281<=i&&i<=65376||65504<=i&&i<=65510?"F":i==8361||65377<=i&&i<=65470||65474<=i&&i<=65479||65482<=i&&i<=65487||65490<=i&&i<=65495||65498<=i&&i<=65500||65512<=i&&i<=65518?"H":4352<=i&&i<=4447||4515<=i&&i<=4519||4602<=i&&i<=4607||9001<=i&&i<=9002||11904<=i&&i<=11929||11931<=i&&i<=12019||12032<=i&&i<=12245||12272<=i&&i<=12283||12289<=i&&i<=12350||12353<=i&&i<=12438||12441<=i&&i<=12543||12549<=i&&i<=12589||12593<=i&&i<=12686||12688<=i&&i<=12730||12736<=i&&i<=12771||12784<=i&&i<=12830||12832<=i&&i<=12871||12880<=i&&i<=13054||13056<=i&&i<=19903||19968<=i&&i<=42124||42128<=i&&i<=42182||43360<=i&&i<=43388||44032<=i&&i<=55203||55216<=i&&i<=55238||55243<=i&&i<=55291||63744<=i&&i<=64255||65040<=i&&i<=65049||65072<=i&&i<=65106||65108<=i&&i<=65126||65128<=i&&i<=65131||110592<=i&&i<=110593||127488<=i&&i<=127490||127504<=i&&i<=127546||127552<=i&&i<=127560||127568<=i&&i<=127569||131072<=i&&i<=194367||177984<=i&&i<=196605||196608<=i&&i<=262141?"W":32<=i&&i<=126||162<=i&&i<=163||165<=i&&i<=166||i==172||i==175||10214<=i&&i<=10221||10629<=i&&i<=10630?"Na":i==161||i==164||167<=i&&i<=168||i==170||173<=i&&i<=174||176<=i&&i<=180||182<=i&&i<=186||188<=i&&i<=191||i==198||i==208||215<=i&&i<=216||222<=i&&i<=225||i==230||232<=i&&i<=234||236<=i&&i<=237||i==240||242<=i&&i<=243||247<=i&&i<=250||i==252||i==254||i==257||i==273||i==275||i==283||294<=i&&i<=295||i==299||305<=i&&i<=307||i==312||319<=i&&i<=322||i==324||328<=i&&i<=331||i==333||338<=i&&i<=339||358<=i&&i<=359||i==363||i==462||i==464||i==466||i==468||i==470||i==472||i==474||i==476||i==593||i==609||i==708||i==711||713<=i&&i<=715||i==717||i==720||728<=i&&i<=731||i==733||i==735||768<=i&&i<=879||913<=i&&i<=929||931<=i&&i<=937||945<=i&&i<=961||963<=i&&i<=969||i==1025||1040<=i&&i<=1103||i==1105||i==8208||8211<=i&&i<=8214||8216<=i&&i<=8217||8220<=i&&i<=8221||8224<=i&&i<=8226||8228<=i&&i<=8231||i==8240||8242<=i&&i<=8243||i==8245||i==8251||i==8254||i==8308||i==8319||8321<=i&&i<=8324||i==8364||i==8451||i==8453||i==8457||i==8467||i==8470||8481<=i&&i<=8482||i==8486||i==8491||8531<=i&&i<=8532||8539<=i&&i<=8542||8544<=i&&i<=8555||8560<=i&&i<=8569||i==8585||8592<=i&&i<=8601||8632<=i&&i<=8633||i==8658||i==8660||i==8679||i==8704||8706<=i&&i<=8707||8711<=i&&i<=8712||i==8715||i==8719||i==8721||i==8725||i==8730||8733<=i&&i<=8736||i==8739||i==8741||8743<=i&&i<=8748||i==8750||8756<=i&&i<=8759||8764<=i&&i<=8765||i==8776||i==8780||i==8786||8800<=i&&i<=8801||8804<=i&&i<=8807||8810<=i&&i<=8811||8814<=i&&i<=8815||8834<=i&&i<=8835||8838<=i&&i<=8839||i==8853||i==8857||i==8869||i==8895||i==8978||9312<=i&&i<=9449||9451<=i&&i<=9547||9552<=i&&i<=9587||9600<=i&&i<=9615||9618<=i&&i<=9621||9632<=i&&i<=9633||9635<=i&&i<=9641||9650<=i&&i<=9651||9654<=i&&i<=9655||9660<=i&&i<=9661||9664<=i&&i<=9665||9670<=i&&i<=9672||i==9675||9678<=i&&i<=9681||9698<=i&&i<=9701||i==9711||9733<=i&&i<=9734||i==9737||9742<=i&&i<=9743||9748<=i&&i<=9749||i==9756||i==9758||i==9792||i==9794||9824<=i&&i<=9825||9827<=i&&i<=9829||9831<=i&&i<=9834||9836<=i&&i<=9837||i==9839||9886<=i&&i<=9887||9918<=i&&i<=9919||9924<=i&&i<=9933||9935<=i&&i<=9953||i==9955||9960<=i&&i<=9983||i==10045||i==10071||10102<=i&&i<=10111||11093<=i&&i<=11097||12872<=i&&i<=12879||57344<=i&&i<=63743||65024<=i&&i<=65039||i==65533||127232<=i&&i<=127242||127248<=i&&i<=127277||127280<=i&&i<=127337||127344<=i&&i<=127386||917760<=i&&i<=917999||983040<=i&&i<=1048573||1048576<=i&&i<=1114109?"A":"N"},D.characterLength=function(r){var n=this.eastAsianWidth(r);return n=="F"||n=="W"||n=="A"?2:1};function t(r){return r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}D.length=function(r){for(var n=t(r),F=0,i=0;i<n.length;i++)F=F+this.characterLength(n[i]);return F},D.slice=function(r,n,F){textLen=D.length(r),n=n||0,F=F||1,n<0&&(n=textLen+n),F<0&&(F=textLen+F);for(var i="",e=0,s=t(r),f=0;f<s.length;f++){var C=s[f],E=D.length(C);if(e>=n-(E==2?1:0))if(e+E<=F)i+=C;else break;e+=E}return i}})(rt);Q2=rt.exports,W2=it(Q2),Y2=it(z2);U={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(U.modifier);q2=Object.keys(U.color),Z2=Object.keys(U.bgColor);[...q2,...Z2];X2=a2(),_u=new Set(["\x1B","\x9B"]),DD=`${V2}8;;`;j2=["up","down","left","right","space","enter","cancel"],wu={actions:new Set(j2),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]])};globalThis.process.platform.startsWith("win");pD=Symbol("clack:cancel");d2=Object.defineProperty;st=class st extends Cu{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(u){super(u,!1),this.value=!!u.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(D)=>{this.output.write(W.cursor.move(0,-1)),this.value=D,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};x2=Object.defineProperty,Dr=class extends Cu{constructor(u){super(u,!1),xD(this,"options"),xD(this,"cursor",0),this.options=u.options,this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:D})=>D===u.cursorAt),0),this.on("key",(D)=>{D==="a"&&this.toggleAll()}),this.on("cursor",(D)=>{switch(D){case"left":case"up":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;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let u=this.value.length===this.options.length;this.value=u?[]:this.options.map((D)=>D.value)}toggleValue(){let u=this.value.includes(this._value);this.value=u?this.value.filter((D)=>D!==this._value):[...this.value,this._value]}},tr=Object.defineProperty;Ct=class Ct extends Cu{constructor(u){super(u,!1),ut(this,"options"),ut(this,"cursor",0),this.options=u.options,this.cursor=this.options.findIndex(({value:D})=>D===u.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(D)=>{switch(D){case"left":case"up":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;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};ft=class ft extends Cu{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let u=this.value.slice(0,this.cursor),[D,...t]=this.value.slice(this.cursor);return`${u}${h.inverse(D)}${t.join("")}`}get cursor(){return this._cursor}constructor(u){super(u),this.on("finalize",()=>{this.value||(this.value=u.defaultValue)})}};nr=rr(),Fr=z("\u276F",">"),er=z("\u25A0","x"),sr=z("\u25B2","x"),Cr=z("\u2714","\u221A"),T=z(""),tu=z(""),du=z("\u25CF",">"),pu=z("\u25CB"," "),fr=z("\u25FB","[\u2022]"),Dt=z("\u25FC","[+]"),Er=z("\u25FB","[ ]");`${h.gray(T)} `;Et=Symbol.for("cancel")});var MD=ci(JD(),1),{program:z0,createCommand:Y0,createArgument:q0,createOption:Z0,CommanderError:a0,InvalidArgumentError:X0,InvalidOptionArgumentError:H0,Command:gD,Argument:V0,Option:k0,Help:K0}=MD.default;var J={silent:Number.NEGATIVE_INFINITY,fatal:0,error:0,warn:1,log:2,info:3,success:3,fail:3,ready:3,start:3,box:3,debug:4,trace:5,verbose:Number.POSITIVE_INFINITY},Hu={silent:{level:-1},fatal:{level:J.fatal},error:{level:J.error},warn:{level:J.warn},log:{level:J.log},info:{level:J.info},success:{level:J.success},fail:{level:J.fail},ready:{level:J.info},start:{level:J.info},box:{level:J.info},debug:{level:J.debug},trace:{level:J.trace},verbose:{level:J.verbose}};function Zu(u){if(u===null||typeof u!=="object")return!1;let D=Object.getPrototypeOf(u);if(D!==null&&D!==Object.prototype&&Object.getPrototypeOf(D)!==null)return!1;if(Symbol.iterator in u)return!1;if(Symbol.toStringTag in u)return Object.prototype.toString.call(u)==="[object Module]";return!0}function Vu(u,D,t=".",r){if(!Zu(D))return Vu(u,{},t,r);let n=Object.assign({},D);for(let F in u){if(F==="__proto__"||F==="constructor")continue;let i=u[F];if(i===null||i===void 0)continue;if(r&&r(n,F,i,t))continue;if(Array.isArray(i)&&Array.isArray(n[F]))n[F]=[...i,...n[F]];else if(Zu(i)&&Zu(n[F]))n[F]=Vu(i,n[F],(t?`${t}.`:"")+F.toString(),r);else n[F]=i}return n}function s2(u){return(...D)=>D.reduce((t,r)=>Vu(t,r,"",u),{})}var C2=s2();function f2(u){return Object.prototype.toString.call(u)==="[object Object]"}function E2(u){if(!f2(u))return!1;if(!u.message&&!u.args)return!1;if(u.stack)return!1;return!0}var au=!1,LD=[];class N{options;_lastLog;_mockFn;constructor(u={}){let D=u.types||Hu;this.options=C2({...u,defaults:{...u.defaults},level:Xu(u.level,D),reporters:[...u.reporters||[]]},{types:Hu,throttle:1000,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}});for(let t in D){let r={type:t,...this.options.defaults,...D[t]};this[t]=this._wrapLogFn(r),this[t].raw=this._wrapLogFn(r,!0)}if(this.options.mockFn)this.mockTypes();this._lastLog={}}get level(){return this.options.level}set level(u){this.options.level=Xu(u,this.options.types,this.options.level)}prompt(u,D){if(!this.options.prompt)throw Error("prompt is not supported!");return this.options.prompt(u,D)}create(u){let D=new N({...this.options,...u});if(this._mockFn)D.mockTypes(this._mockFn);return D}withDefaults(u){return this.create({...this.options,defaults:{...this.options.defaults,...u}})}withTag(u){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+":"+u:u})}addReporter(u){return this.options.reporters.push(u),this}removeReporter(u){if(u){let D=this.options.reporters.indexOf(u);if(D!==-1)return this.options.reporters.splice(D,1)}else this.options.reporters.splice(0);return this}setReporters(u){return this.options.reporters=Array.isArray(u)?u:[u],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(let u in this.options.types){if(!console["__"+u])console["__"+u]=console[u];console[u]=this[u].raw}}restoreConsole(){for(let u in this.options.types)if(console["__"+u])console[u]=console["__"+u],delete console["__"+u]}wrapStd(){this._wrapStream(this.options.stdout,"log"),this._wrapStream(this.options.stderr,"log")}_wrapStream(u,D){if(!u)return;if(!u.__write)u.__write=u.write;u.write=(t)=>{this[D].raw(String(t).trim())}}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(u){if(!u)return;if(u.__write)u.write=u.__write,delete u.__write}pauseLogs(){au=!0}resumeLogs(){au=!1;let u=LD.splice(0);for(let D of u)D[0]._logFn(D[1],D[2])}mockTypes(u){let D=u||this.options.mockFn;if(this._mockFn=D,typeof D!=="function")return;for(let t in this.options.types)this[t]=D(t,this.options.types[t])||this[t],this[t].raw=this[t]}_wrapLogFn(u,D){return(...t)=>{if(au){LD.push([this,u,t,D]);return}return this._logFn(u,t,D)}}_logFn(u,D,t){if((u.level||0)>this.level)return!1;let r={date:new Date,args:[],...u,level:Xu(u.level,this.options.types)};if(!t&&D.length===1&&E2(D[0]))Object.assign(r,D[0]);else r.args=[...D];if(r.message)r.args.unshift(r.message),delete r.message;if(r.additional){if(!Array.isArray(r.additional))r.additional=r.additional.split(`
|
|
73
|
+
`);r.args.push(`
|
|
74
|
+
`+r.additional.join(`
|
|
75
|
+
`)),delete r.additional}r.type=typeof r.type==="string"?r.type.toLowerCase():"log",r.tag=typeof r.tag==="string"?r.tag:"";let n=(i=!1)=>{let e=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&e>0){let s=[...this._lastLog.object.args];if(e>1)s.push(`(repeated ${e} times)`);this._log({...this._lastLog.object,args:s}),this._lastLog.count=1}if(i)this._lastLog.object=r,this._log(r)};clearTimeout(this._lastLog.timeout);let F=this._lastLog.time&&r.date?r.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=r.date,F<this.options.throttle)try{let i=JSON.stringify([r.type,r.tag,r.args]),e=this._lastLog.serialized===i;if(this._lastLog.serialized=i,e){if(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin){this._lastLog.timeout=setTimeout(n,this.options.throttle);return}}}catch{}n(!0)}_log(u){for(let D of this.options.reporters)D.log(u,{options:this.options})}}function Xu(u,D={},t=3){if(u===void 0)return t;if(typeof u==="number")return u;if(D[u]&&D[u].level!==void 0)return D[u].level;return t}N.prototype.add=N.prototype.addReporter;N.prototype.remove=N.prototype.removeReporter;N.prototype.clear=N.prototype.removeReporter;N.prototype.withScope=N.prototype.withTag;N.prototype.mock=N.prototype.mockTypes;N.prototype.pause=N.prototype.pauseLogs;N.prototype.resume=N.prototype.resumeLogs;function PD(u={}){return new N(u)}import{formatWithOptions as QD}from"util";import{sep as h2}from"path";function Ku(u,D){let t=process.cwd()+h2;return u.split(`
|
|
76
|
+
`).splice(D.split(`
|
|
77
|
+
`).length).map((n)=>n.trim().replace("file://","").replace(t,""))}function c2(u,D){return(D.__write||D.write).call(D,u)}var ku=(u)=>u?`[${u}]`:"";class ou{formatStack(u,D,t){let r=" ".repeat((t?.errorLevel||0)+1);return r+Ku(u,D).join(`
|
|
78
|
+
${r}`)}formatError(u,D){let t=u.message??QD(D,u),r=u.stack?this.formatStack(u.stack,t,D):"",n=D?.errorLevel||0,F=n>0?`${" ".repeat(n)}[cause]: `:"",i=u.cause?`
|
|
79
|
+
|
|
80
|
+
`+this.formatError(u.cause,{...D,errorLevel:n+1}):"";return F+t+`
|
|
81
|
+
`+r+i}formatArgs(u,D){let t=u.map((r)=>{if(r&&typeof r.stack==="string")return this.formatError(r,D);return r});return QD(D,...t)}formatDate(u,D){return D.date?u.toLocaleTimeString():""}filterAndJoin(u){return u.filter(Boolean).join(" ")}formatLogObj(u,D){let t=this.formatArgs(u.args,D);if(u.type==="box")return`
|
|
82
|
+
`+[ku(u.tag),u.title&&u.title,...t.split(`
|
|
83
|
+
`)].filter(Boolean).map((r)=>" > "+r).join(`
|
|
84
|
+
`)+`
|
|
85
|
+
`;return this.filterAndJoin([ku(u.type),ku(u.tag),t])}log(u,D){let t=this.formatLogObj(u,{columns:D.options.stdout.columns||0,...D.options.formatOptions});return c2(t+`
|
|
86
|
+
`,u.level<2?D.options.stderr||process.stderr:D.options.stdout||process.stdout)}}import ot from"process";import*as lu from"tty";var{env:V={},argv:YD=[],platform:B2=""}=typeof process>"u"?{}:process,o2="NO_COLOR"in V||YD.includes("--no-color"),l2="FORCE_COLOR"in V||YD.includes("--color"),$2=B2==="win32",qD=V.TERM==="dumb",A2=lu&&lu.isatty&&lu.isatty(1)&&V.TERM&&!qD,w2="CI"in V&&(("GITHUB_ACTIONS"in V)||("GITLAB_CI"in V)||("CIRCLECI"in V)),_2=!o2&&(l2||$2&&!qD||A2||w2);function ZD(u,D,t,r,n=D.slice(0,Math.max(0,u))+r,F=D.slice(Math.max(0,u+t.length)),i=F.indexOf(t)){return n+(i<0?F:ZD(i,F,t,r))}function m2(u,D,t,r,n){return u<0?t+D+r:t+ZD(u,D,r,n)+r}function b2(u,D,t=u,r=u.length+1){return(n)=>n||!(n===""||n===void 0)?m2((""+n).indexOf(D,r),n,u,D,t):""}function l(u,D,t){return b2(`\x1B[${u}m`,`\x1B[${D}m`,t)}var WD={reset:l(0,0),bold:l(1,22,"\x1B[22m\x1B[1m"),dim:l(2,22,"\x1B[22m\x1B[2m"),italic:l(3,23),underline:l(4,24),inverse:l(7,27),hidden:l(8,28),strikethrough:l(9,29),black:l(30,39),red:l(31,39),green:l(32,39),yellow:l(33,39),blue:l(34,39),magenta:l(35,39),cyan:l(36,39),white:l(37,39),gray:l(90,39),bgBlack:l(40,49),bgRed:l(41,49),bgGreen:l(42,49),bgYellow:l(43,49),bgBlue:l(44,49),bgMagenta:l(45,49),bgCyan:l(46,49),bgWhite:l(47,49),blackBright:l(90,39),redBright:l(91,39),greenBright:l(92,39),yellowBright:l(93,39),blueBright:l(94,39),magentaBright:l(95,39),cyanBright:l(96,39),whiteBright:l(97,39),bgBlackBright:l(100,49),bgRedBright:l(101,49),bgGreenBright:l(102,49),bgYellowBright:l(103,49),bgBlueBright:l(104,49),bgMagentaBright:l(105,49),bgCyanBright:l(106,49),bgWhiteBright:l(107,49)};function R2(u=_2){return u?WD:Object.fromEntries(Object.keys(WD).map((D)=>[D,String]))}var g=R2();function S2(u,D="reset"){return g[u]||g[D]}var T2=[String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");function H(u){return u.replace(new RegExp(T2,"g"),"")}var zD={solid:{tl:"\u250C",tr:"\u2510",bl:"\u2514",br:"\u2518",h:"\u2500",v:"\u2502"},double:{tl:"\u2554",tr:"\u2557",bl:"\u255A",br:"\u255D",h:"\u2550",v:"\u2551"},doubleSingle:{tl:"\u2553",tr:"\u2556",bl:"\u2559",br:"\u255C",h:"\u2500",v:"\u2551"},doubleSingleRounded:{tl:"\u256D",tr:"\u256E",bl:"\u2570",br:"\u256F",h:"\u2500",v:"\u2551"},singleThick:{tl:"\u250F",tr:"\u2513",bl:"\u2517",br:"\u251B",h:"\u2501",v:"\u2503"},singleDouble:{tl:"\u2552",tr:"\u2555",bl:"\u2558",br:"\u255B",h:"\u2550",v:"\u2502"},singleDoubleRounded:{tl:"\u256D",tr:"\u256E",bl:"\u2570",br:"\u256F",h:"\u2550",v:"\u2502"},rounded:{tl:"\u256D",tr:"\u256E",bl:"\u2570",br:"\u256F",h:"\u2500",v:"\u2502"}},y2={borderColor:"white",borderStyle:"rounded",valign:"center",padding:2,marginLeft:1,marginTop:1,marginBottom:1};function aD(u,D={}){let t={...D,style:{...y2,...D.style}},r=u.split(`
|
|
87
|
+
`),n=[],F=S2(t.style.borderColor),i={...typeof t.style.borderStyle==="string"?zD[t.style.borderStyle]||zD.solid:t.style.borderStyle};if(F)for(let B in i)i[B]=F(i[B]);let e=t.style.padding%2===0?t.style.padding:t.style.padding+1,s=r.length+e,f=Math.max(...r.map((B)=>H(B).length),t.title?H(t.title).length:0)+e,C=f+e,E=t.style.marginLeft>0?" ".repeat(t.style.marginLeft):"";if(t.style.marginTop>0)n.push("".repeat(t.style.marginTop));if(t.title){let B=F?F(t.title):t.title,A=i.h.repeat(Math.floor((f-H(t.title).length)/2)),S=i.h.repeat(f-H(t.title).length-H(A).length+e);n.push(`${E}${i.tl}${A}${B}${S}${i.tr}`)}else n.push(`${E}${i.tl}${i.h.repeat(C)}${i.tr}`);let c=t.style.valign==="center"?Math.floor((s-r.length)/2):t.style.valign==="top"?s-r.length-e:s-r.length;for(let B=0;B<s;B++)if(B<c||B>=c+r.length)n.push(`${E}${i.v}${" ".repeat(C)}${i.v}`);else{let A=r[B-c],S=" ".repeat(e),M=" ".repeat(f-H(A).length);n.push(`${E}${i.v}${S}${A}${M}${i.v}`)}if(n.push(`${E}${i.bl}${i.h.repeat(C)}${i.br}`),t.style.marginBottom>0)n.push("".repeat(t.style.marginBottom));return n.join(`
|
|
88
|
+
`)}var Ru=Object.create(null),fu=(u)=>globalThis.process?.env||import.meta.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(u?Ru:globalThis),k=new Proxy(Ru,{get(u,D){return fu()[D]??Ru[D]},has(u,D){let t=fu();return D in t||D in Ru},set(u,D,t){let r=fu(!0);return r[D]=t,!0},deleteProperty(u,D){if(!D)return!1;let t=fu(!0);return delete t[D],!0},ownKeys(){let u=fu(!0);return Object.keys(u)}}),lr=typeof process<"u"&&process.env&&"development"||"",$r=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:!0}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:!0}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:!1}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:!1}],["VERCEL","VERCEL_ENV",{ci:!1}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:!1}],["CODESANDBOX","CODESANDBOX_HOST",{ci:!1}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:!0}],["RAILWAY","RAILWAY_PROJECT_ID"],["RAILWAY","RAILWAY_SERVICE_ID"],["DENO-DEPLOY","DENO_DEPLOYMENT_ID"],["FIREBASE_APP_HOSTING","FIREBASE_APP_HOSTING",{ci:!0}]];function Ar(){if(globalThis.process?.env)for(let u of $r){let D=u[1]||u[0];if(globalThis.process?.env[D])return{name:u[0].toLowerCase(),...u[2]}}return globalThis.process?.env?.SHELL==="/bin/jsh"&&globalThis.process?.versions?.webcontainer?{name:"stackblitz",ci:!1}:{name:"",ci:!1}}var wt=Ar();wt.name;function d(u){return u?u!=="false":!1}var wr=globalThis.process?.platform||"",tD=d(k.CI)||wt.ci!==!1,_t=d(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY),_r=d(k.DEBUG),iD=lr==="test"||d(k.TEST);d(k.MINIMAL);var mr=/^win/i.test(wr);!d(k.NO_COLOR)&&(d(k.FORCE_COLOR)||(_t||mr)&&k.TERM);var br=(globalThis.process?.versions?.node||"").replace(/^v/,"")||null;Number(br?.split(".")[0]);var Rr=globalThis.process||Object.create(null),lt={versions:{}};new Proxy(Rr,{get(u,D){if(D==="env")return k;if(D in u)return u[D];if(D in lt)return lt[D]}});var Sr=globalThis.process?.release?.name==="node",Tr=!!globalThis.Bun||!!globalThis.process?.versions?.bun,yr=!!globalThis.Deno,Ur=!!globalThis.fastly,Ir=!!globalThis.Netlify,Gr=!!globalThis.EdgeRuntime,Nr=globalThis.navigator?.userAgent==="Cloudflare-Workers",Jr=[[Ir,"netlify"],[Gr,"edge-light"],[Nr,"workerd"],[Ur,"fastly"],[yr,"deno"],[Tr,"bun"],[Sr,"node"]];function Mr(){let u=Jr.find((D)=>D[0]);if(u)return{name:u[1]}}var gr=Mr();gr?.name;function Lr({onlyFirst:u=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,u?void 0:"g")}var Pr=Lr();function Qr(u){if(typeof u!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof u}\``);return u.replace(Pr,"")}function Wr(u){return u===161||u===164||u===167||u===168||u===170||u===173||u===174||u>=176&&u<=180||u>=182&&u<=186||u>=188&&u<=191||u===198||u===208||u===215||u===216||u>=222&&u<=225||u===230||u>=232&&u<=234||u===236||u===237||u===240||u===242||u===243||u>=247&&u<=250||u===252||u===254||u===257||u===273||u===275||u===283||u===294||u===295||u===299||u>=305&&u<=307||u===312||u>=319&&u<=322||u===324||u>=328&&u<=331||u===333||u===338||u===339||u===358||u===359||u===363||u===462||u===464||u===466||u===468||u===470||u===472||u===474||u===476||u===593||u===609||u===708||u===711||u>=713&&u<=715||u===717||u===720||u>=728&&u<=731||u===733||u===735||u>=768&&u<=879||u>=913&&u<=929||u>=931&&u<=937||u>=945&&u<=961||u>=963&&u<=969||u===1025||u>=1040&&u<=1103||u===1105||u===8208||u>=8211&&u<=8214||u===8216||u===8217||u===8220||u===8221||u>=8224&&u<=8226||u>=8228&&u<=8231||u===8240||u===8242||u===8243||u===8245||u===8251||u===8254||u===8308||u===8319||u>=8321&&u<=8324||u===8364||u===8451||u===8453||u===8457||u===8467||u===8470||u===8481||u===8482||u===8486||u===8491||u===8531||u===8532||u>=8539&&u<=8542||u>=8544&&u<=8555||u>=8560&&u<=8569||u===8585||u>=8592&&u<=8601||u===8632||u===8633||u===8658||u===8660||u===8679||u===8704||u===8706||u===8707||u===8711||u===8712||u===8715||u===8719||u===8721||u===8725||u===8730||u>=8733&&u<=8736||u===8739||u===8741||u>=8743&&u<=8748||u===8750||u>=8756&&u<=8759||u===8764||u===8765||u===8776||u===8780||u===8786||u===8800||u===8801||u>=8804&&u<=8807||u===8810||u===8811||u===8814||u===8815||u===8834||u===8835||u===8838||u===8839||u===8853||u===8857||u===8869||u===8895||u===8978||u>=9312&&u<=9449||u>=9451&&u<=9547||u>=9552&&u<=9587||u>=9600&&u<=9615||u>=9618&&u<=9621||u===9632||u===9633||u>=9635&&u<=9641||u===9650||u===9651||u===9654||u===9655||u===9660||u===9661||u===9664||u===9665||u>=9670&&u<=9672||u===9675||u>=9678&&u<=9681||u>=9698&&u<=9701||u===9711||u===9733||u===9734||u===9737||u===9742||u===9743||u===9756||u===9758||u===9792||u===9794||u===9824||u===9825||u>=9827&&u<=9829||u>=9831&&u<=9834||u===9836||u===9837||u===9839||u===9886||u===9887||u===9919||u>=9926&&u<=9933||u>=9935&&u<=9939||u>=9941&&u<=9953||u===9955||u===9960||u===9961||u>=9963&&u<=9969||u===9972||u>=9974&&u<=9977||u===9979||u===9980||u===9982||u===9983||u===10045||u>=10102&&u<=10111||u>=11094&&u<=11097||u>=12872&&u<=12879||u>=57344&&u<=63743||u>=65024&&u<=65039||u===65533||u>=127232&&u<=127242||u>=127248&&u<=127277||u>=127280&&u<=127337||u>=127344&&u<=127373||u===127375||u===127376||u>=127387&&u<=127404||u>=917760&&u<=917999||u>=983040&&u<=1048573||u>=1048576&&u<=1114109}function zr(u){return u===12288||u>=65281&&u<=65376||u>=65504&&u<=65510}function Yr(u){return u>=4352&&u<=4447||u===8986||u===8987||u===9001||u===9002||u>=9193&&u<=9196||u===9200||u===9203||u===9725||u===9726||u===9748||u===9749||u>=9776&&u<=9783||u>=9800&&u<=9811||u===9855||u>=9866&&u<=9871||u===9875||u===9889||u===9898||u===9899||u===9917||u===9918||u===9924||u===9925||u===9934||u===9940||u===9962||u===9970||u===9971||u===9973||u===9978||u===9981||u===9989||u===9994||u===9995||u===10024||u===10060||u===10062||u>=10067&&u<=10069||u===10071||u>=10133&&u<=10135||u===10160||u===10175||u===11035||u===11036||u===11088||u===11093||u>=11904&&u<=11929||u>=11931&&u<=12019||u>=12032&&u<=12245||u>=12272&&u<=12287||u>=12289&&u<=12350||u>=12353&&u<=12438||u>=12441&&u<=12543||u>=12549&&u<=12591||u>=12593&&u<=12686||u>=12688&&u<=12773||u>=12783&&u<=12830||u>=12832&&u<=12871||u>=12880&&u<=42124||u>=42128&&u<=42182||u>=43360&&u<=43388||u>=44032&&u<=55203||u>=63744&&u<=64255||u>=65040&&u<=65049||u>=65072&&u<=65106||u>=65108&&u<=65126||u>=65128&&u<=65131||u>=94176&&u<=94180||u===94192||u===94193||u>=94208&&u<=100343||u>=100352&&u<=101589||u>=101631&&u<=101640||u>=110576&&u<=110579||u>=110581&&u<=110587||u===110589||u===110590||u>=110592&&u<=110882||u===110898||u>=110928&&u<=110930||u===110933||u>=110948&&u<=110951||u>=110960&&u<=111355||u>=119552&&u<=119638||u>=119648&&u<=119670||u===126980||u===127183||u===127374||u>=127377&&u<=127386||u>=127488&&u<=127490||u>=127504&&u<=127547||u>=127552&&u<=127560||u===127568||u===127569||u>=127584&&u<=127589||u>=127744&&u<=127776||u>=127789&&u<=127797||u>=127799&&u<=127868||u>=127870&&u<=127891||u>=127904&&u<=127946||u>=127951&&u<=127955||u>=127968&&u<=127984||u===127988||u>=127992&&u<=128062||u===128064||u>=128066&&u<=128252||u>=128255&&u<=128317||u>=128331&&u<=128334||u>=128336&&u<=128359||u===128378||u===128405||u===128406||u===128420||u>=128507&&u<=128591||u>=128640&&u<=128709||u===128716||u>=128720&&u<=128722||u>=128725&&u<=128727||u>=128732&&u<=128735||u===128747||u===128748||u>=128756&&u<=128764||u>=128992&&u<=129003||u===129008||u>=129292&&u<=129338||u>=129340&&u<=129349||u>=129351&&u<=129535||u>=129648&&u<=129660||u>=129664&&u<=129673||u>=129679&&u<=129734||u>=129742&&u<=129756||u>=129759&&u<=129769||u>=129776&&u<=129784||u>=131072&&u<=196605||u>=196608&&u<=262141}function qr(u){if(!Number.isSafeInteger(u))throw TypeError(`Expected a code point, got \`${typeof u}\`.`)}function Zr(u,{ambiguousAsWide:D=!1}={}){if(qr(u),zr(u)||Yr(u)||D&&Wr(u))return 2;return 1}var ar=()=>{return/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g},Xr=globalThis.Intl?.Segmenter?new Intl.Segmenter:{segment:(u)=>u.split("")},Hr=/^\p{Default_Ignorable_Code_Point}$/u;function Vr(u,D={}){if(typeof u!=="string"||u.length===0)return 0;let{ambiguousIsNarrow:t=!0,countAnsiEscapeCodes:r=!1}=D;if(!r)u=Qr(u);if(u.length===0)return 0;let n=0,F={ambiguousAsWide:!t};for(let{segment:i}of Xr.segment(u)){let e=i.codePointAt(0);if(e<=31||e>=127&&e<=159)continue;if(e>=8203&&e<=8207||e===65279)continue;if(e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071)continue;if(e>=55296&&e<=57343)continue;if(e>=65024&&e<=65039)continue;if(Hr.test(i))continue;if(ar().test(i)){n+=2;continue}n+=Zr(e,F)}return n}function kr(){let{env:u}=ot,{TERM:D,TERM_PROGRAM:t}=u;if(ot.platform!=="win32")return D!=="linux";return Boolean(u.WT_SESSION)||Boolean(u.TERMINUS_SUBLIME)||u.ConEmuTask==="{cmd::Cmder}"||t==="Terminus-Sublime"||t==="vscode"||D==="xterm-256color"||D==="alacritty"||D==="rxvt-unicode"||D==="rxvt-unicode-256color"||u.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Kr={info:"cyan",fail:"red",success:"green",ready:"green",start:"magenta"},vr={0:"red",1:"yellow"},jr=kr(),Z=(u,D)=>jr?u:D,$t={error:Z("\u2716","\xD7"),fatal:Z("\u2716","\xD7"),ready:Z("\u2714","\u221A"),warn:Z("\u26A0","\u203C"),info:Z("\u2139","i"),success:Z("\u2714","\u221A"),debug:Z("\u2699","D"),trace:Z("\u2192","\u2192"),fail:Z("\u2716","\xD7"),start:Z("\u25D0","o"),log:""};function At(u){if(typeof Intl!=="object"||!Intl.Segmenter)return H(u).length;return Vr(u)}class mt extends ou{formatStack(u,D,t){let r=" ".repeat((t?.errorLevel||0)+1);return`
|
|
89
|
+
${r}`+Ku(u,D).map((n)=>" "+n.replace(/^at +/,(F)=>g.gray(F)).replace(/\((.+)\)/,(F,i)=>`(${g.cyan(i)})`)).join(`
|
|
90
|
+
${r}`)}formatType(u,D,t){let r=Kr[u.type]||vr[u.level]||"gray";if(D)return dr(r)(g.black(` ${u.type.toUpperCase()} `));let n=typeof $t[u.type]==="string"?$t[u.type]:u.icon||u.type;return n?Or(r)(n):""}formatLogObj(u,D){let[t,...r]=this.formatArgs(u.args,D).split(`
|
|
91
|
+
`);if(u.type==="box")return aD(bu(t+(r.length>0?`
|
|
92
|
+
`+r.join(`
|
|
93
|
+
`):"")),{title:u.title?bu(u.title):void 0,style:u.style});let n=this.formatDate(u.date,D),F=n&&g.gray(n),i=u.badge??u.level<2,e=this.formatType(u,i,D),s=u.tag?g.gray(u.tag):"",f,C=this.filterAndJoin([e,bu(t)]),E=this.filterAndJoin(D.columns?[s,F]:[s]),c=(D.columns||0)-At(C)-At(E)-2;if(f=c>0&&(D.columns||0)>=80?C+" ".repeat(c)+E:(E?`${g.gray(`[${E}]`)} `:"")+C,f+=bu(r.length>0?`
|
|
94
|
+
`+r.join(`
|
|
95
|
+
`):""),u.type==="trace"){let B=Error("Trace: "+u.message);f+=this.formatStack(B.stack||"",B.message)}return i?`
|
|
96
|
+
`+f+`
|
|
97
|
+
`:f}}function bu(u){return u.replace(/`([^`]+)`/gm,(D,t)=>g.cyan(t)).replace(/\s+_([^_]+)_\s+/gm,(D,t)=>` ${g.underline(t)} `)}function Or(u="white"){return g[u]||g.white}function dr(u="bgWhite"){return g[`bg${u[0].toUpperCase()}${u.slice(1)}`]||g.bgWhite}function pr(u={}){let D=xr();if(process.env.CONSOLA_LEVEL)D=Number.parseInt(process.env.CONSOLA_LEVEL)??D;return PD({level:D,defaults:{level:D},stdout:process.stdout,stderr:process.stderr,prompt:(...r)=>Promise.resolve().then(() => (Bt(),ct)).then((n)=>n.prompt(...r)),reporters:u.reporters||[u.fancy??!(tD||iD)?new mt:new ou],...u})}function xr(){if(_r)return J.debug;if(iD)return J.warn;return J.info}var R=pr();var un=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,Dn=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,tn=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function rn(u,D){if(u==="__proto__"||u==="constructor"&&D&&typeof D==="object"&&"prototype"in D){nn(u);return}return D}function nn(u){console.warn(`[destr] Dropping "${u}" key to prevent prototype pollution.`)}function bt(u,D={}){if(typeof u!=="string")return u;if(u[0]==='"'&&u[u.length-1]==='"'&&u.indexOf("\\")===-1)return u.slice(1,-1);let t=u.trim();if(t.length<=9)switch(t.toLowerCase()){case"true":return!0;case"false":return!1;case"undefined":return;case"null":return null;case"nan":return Number.NaN;case"infinity":return Number.POSITIVE_INFINITY;case"-infinity":return Number.NEGATIVE_INFINITY}if(!tn.test(u)){if(D.strict)throw SyntaxError("[destr] Invalid JSON");return u}try{if(un.test(u)||Dn.test(u)){if(D.strict)throw Error("[destr] Possible prototype pollution");return JSON.parse(u,rn)}return JSON.parse(u)}catch(r){if(D.strict)throw r;return u}}var E3=String.fromCharCode;var Fn=/#/g,en=/&/g,sn=/\//g,Cn=/=/g;var eD=/\+/g,fn=/%5e/gi,En=/%60/gi;var hn=/%7c/gi;var cn=/%20/gi;function Bn(u){return encodeURI(""+u).replace(hn,"|")}function nD(u){return Bn(typeof u==="string"?u:JSON.stringify(u)).replace(eD,"%2B").replace(cn,"+").replace(Fn,"%23").replace(en,"%26").replace(En,"`").replace(fn,"^").replace(sn,"%2F")}function rD(u){return nD(u).replace(Cn,"%3D")}function St(u=""){try{return decodeURIComponent(""+u)}catch{return""+u}}function on(u){return St(u.replace(eD," "))}function ln(u){return St(u.replace(eD," "))}function $n(u=""){let D=Object.create(null);if(u[0]==="?")u=u.slice(1);for(let t of u.split("&")){let r=t.match(/([^=]+)=?(.*)/)||[];if(r.length<2)continue;let n=on(r[1]);if(n==="__proto__"||n==="constructor")continue;let F=ln(r[2]||"");if(D[n]===void 0)D[n]=F;else if(Array.isArray(D[n]))D[n].push(F);else D[n]=[D[n],F]}return D}function An(u,D){if(typeof D==="number"||typeof D==="boolean")D=String(D);if(!D)return rD(u);if(Array.isArray(D))return D.map((t)=>`${rD(u)}=${nD(t)}`).join("&");return`${rD(u)}=${nD(D)}`}function wn(u){return Object.keys(u).filter((D)=>u[D]!==void 0).map((D)=>An(D,u[D])).filter(Boolean).join("&")}var _n=/^[\s\w\0+.-]{2,}:([/\\]{1,2})/,mn=/^[\s\w\0+.-]{2,}:([/\\]{2})?/,bn=/^([/\\]\s*){2,}[^/\\]/;var Rn=/\/$|\/\?|\/#/,Sn=/^\.?\//;function Tt(u,D={}){if(typeof D==="boolean")D={acceptRelative:D};if(D.strict)return _n.test(u);return mn.test(u)||(D.acceptRelative?bn.test(u):!1)}function FD(u="",D){if(!D)return u.endsWith("/");return Rn.test(u)}function Tn(u="",D){if(!D)return(FD(u)?u.slice(0,-1):u)||"/";if(!FD(u,!0))return u||"/";let t=u,r="",n=u.indexOf("#");if(n!==-1)t=u.slice(0,n),r=u.slice(n);let[F,...i]=t.split("?");return((F.endsWith("/")?F.slice(0,-1):F)||"/")+(i.length>0?`?${i.join("?")}`:"")+r}function yn(u="",D){if(!D)return u.endsWith("/")?u:u+"/";if(FD(u,!0))return u||"/";let t=u,r="",n=u.indexOf("#");if(n!==-1){if(t=u.slice(0,n),r=u.slice(n),!t)return r}let[F,...i]=t.split("?");return F+"/"+(i.length>0?`?${i.join("?")}`:"")+r}function yt(u,D){if(Un(D)||Tt(u))return u;let t=Tn(D);if(u.startsWith(t)){let r=u[t.length];if(!r||r==="/"||r==="?")return u}return Gn(t,u)}function Ut(u,D){let t=Gt(u),r={...$n(t.search),...D};return t.search=wn(r),Nn(t)}function Un(u){return!u||u==="/"}function In(u){return u&&u!=="/"}function Gn(u,...D){let t=u||"";for(let r of D.filter((n)=>In(n)))if(t){let n=r.replace(Sn,"");t=yn(t)+n}else t=r;return t}var It=Symbol.for("ufo:protocolRelative");function Gt(u="",D){let t=u.match(/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i);if(t){let[,E,c=""]=t;return{protocol:E.toLowerCase(),pathname:c,href:E+c,auth:"",host:"",search:"",hash:""}}if(!Tt(u,{acceptRelative:!0}))return D?Gt(D+u):Rt(u);let[,r="",n,F=""]=u.replace(/\\/g,"/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/)||[],[,i="",e=""]=F.match(/([^#/?]*)(.*)?/)||[];if(r==="file:")e=e.replace(/\/(?=[A-Za-z]:)/,"");let{pathname:s,search:f,hash:C}=Rt(e);return{protocol:r.toLowerCase(),auth:n?n.slice(0,Math.max(0,n.length-1)):"",host:i,pathname:s,search:f,hash:C,[It]:!r}}function Rt(u=""){let[D="",t="",r=""]=(u.match(/([^#?]*)(\?[^#]*)?(#.*)?/)||[]).splice(1);return{pathname:D,search:t,hash:r}}function Nn(u){let D=u.pathname||"",t=u.search?(u.search.startsWith("?")?"":"?")+u.search:"",r=u.hash||"",n=u.auth?u.auth+"@":"",F=u.host||"";return(u.protocol||u[It]?(u.protocol||"")+"//":"")+n+F+D+t+r}class Eu extends Error{constructor(u,D){super(u,D);if(this.name="FetchError",D?.cause&&!this.cause)this.cause=D.cause}}function Jt(u){let D=u.error?.message||u.error?.toString()||"",t=u.request?.method||u.options?.method||"GET",r=u.request?.url||String(u.request)||"/",n=`[${t}] ${JSON.stringify(r)}`,F=u.response?`${u.response.status} ${u.response.statusText}`:"<no response>",i=`${n}: ${F}${D?` ${D}`:""}`,e=new Eu(i,u.error?{cause:u.error}:void 0);for(let s of["request","options","response"])Object.defineProperty(e,s,{get(){return u[s]}});for(let[s,f]of[["data","_data"],["status","status"],["statusCode","status"],["statusText","statusText"],["statusMessage","statusText"]])Object.defineProperty(e,s,{get(){return u.response&&u.response[f]}});return e}var Jn=new Set(Object.freeze(["PATCH","POST","PUT","DELETE"]));function Nt(u="GET"){return Jn.has(u.toUpperCase())}function Mn(u){if(u===void 0)return!1;let D=typeof u;if(D==="string"||D==="number"||D==="boolean"||D===null)return!0;if(D!=="object")return!1;if(Array.isArray(u))return!0;if(u.buffer)return!1;if(u instanceof FormData||u instanceof URLSearchParams)return!1;return u.constructor&&u.constructor.name==="Object"||typeof u.toJSON==="function"}var gn=new Set(["image/svg","application/xml","application/xhtml","application/html"]),Ln=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Pn(u=""){if(!u)return"json";let D=u.split(";").shift()||"";if(Ln.test(D))return"json";if(D==="text/event-stream")return"stream";if(gn.has(D)||D.startsWith("text/"))return"text";return"blob"}function Qn(u,D,t,r){let n=Wn(D?.headers??u?.headers,t?.headers,r),F;if(t?.query||t?.params||D?.params||D?.query)F={...t?.params,...t?.query,...D?.params,...D?.query};return{...t,...D,query:F,params:F,headers:n}}function Wn(u,D,t){if(!D)return new t(u);let r=new t(D);if(u)for(let[n,F]of Symbol.iterator in u||Array.isArray(u)?u:new t(u))r.set(n,F);return r}async function Su(u,D){if(D)if(Array.isArray(D))for(let t of D)await t(u);else await D(u)}var zn=new Set([408,409,425,429,500,502,503,504]),Yn=new Set([101,204,205,304]);function sD(u={}){let{fetch:D=globalThis.fetch,Headers:t=globalThis.Headers,AbortController:r=globalThis.AbortController}=u;async function n(e){let s=e.error&&e.error.name==="AbortError"&&!e.options.timeout||!1;if(e.options.retry!==!1&&!s){let C;if(typeof e.options.retry==="number")C=e.options.retry;else C=Nt(e.options.method)?0:1;let E=e.response&&e.response.status||500;if(C>0&&(Array.isArray(e.options.retryStatusCodes)?e.options.retryStatusCodes.includes(E):zn.has(E))){let c=typeof e.options.retryDelay==="function"?e.options.retryDelay(e):e.options.retryDelay||0;if(c>0)await new Promise((B)=>setTimeout(B,c));return F(e.request,{...e.options,retry:C-1})}}let f=Jt(e);if(Error.captureStackTrace)Error.captureStackTrace(f,F);throw f}let F=async function(s,f={}){let C={request:s,options:Qn(s,f,u.defaults,t),response:void 0,error:void 0};if(C.options.method)C.options.method=C.options.method.toUpperCase();if(C.options.onRequest){if(await Su(C,C.options.onRequest),!(C.options.headers instanceof t))C.options.headers=new t(C.options.headers||{})}if(typeof C.request==="string"){if(C.options.baseURL)C.request=yt(C.request,C.options.baseURL);if(C.options.query)C.request=Ut(C.request,C.options.query),delete C.options.query;if("query"in C.options)delete C.options.query;if("params"in C.options)delete C.options.params}if(C.options.body&&Nt(C.options.method)){if(Mn(C.options.body)){let B=C.options.headers.get("content-type");if(typeof C.options.body!=="string")C.options.body=B==="application/x-www-form-urlencoded"?new URLSearchParams(C.options.body).toString():JSON.stringify(C.options.body);if(!B)C.options.headers.set("content-type","application/json");if(!C.options.headers.has("accept"))C.options.headers.set("accept","application/json")}else if("pipeTo"in C.options.body&&typeof C.options.body.pipeTo==="function"||typeof C.options.body.pipe==="function"){if(!("duplex"in C.options))C.options.duplex="half"}}let E;if(!C.options.signal&&C.options.timeout){let B=new r;E=setTimeout(()=>{let A=Error("[TimeoutError]: The operation was aborted due to timeout");A.name="TimeoutError",A.code=23,B.abort(A)},C.options.timeout),C.options.signal=B.signal}try{C.response=await D(C.request,C.options)}catch(B){if(C.error=B,C.options.onRequestError)await Su(C,C.options.onRequestError);return await n(C)}finally{if(E)clearTimeout(E)}if((C.response.body||C.response._bodyInit)&&!Yn.has(C.response.status)&&C.options.method!=="HEAD"){let B=(C.options.parseResponse?"json":C.options.responseType)||Pn(C.response.headers.get("content-type")||"");switch(B){case"json":{let A=await C.response.text(),S=C.options.parseResponse||bt;C.response._data=S(A);break}case"stream":{C.response._data=C.response.body||C.response._bodyInit;break}default:C.response._data=await C.response[B]()}}if(C.options.onResponse)await Su(C,C.options.onResponse);if(!C.options.ignoreResponseError&&C.response.status>=400&&C.response.status<600){if(C.options.onResponseError)await Su(C,C.options.onResponseError);return await n(C)}return C.response},i=async function(s,f){return(await F(s,f))._data};return i.raw=F,i.native=(...e)=>D(...e),i.create=(e={},s={})=>sD({...u,...s,defaults:{...u.defaults,...s.defaults,...e}}),i}var Tu=function(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw Error("unable to locate global object")}(),qn=Tu.fetch?(...u)=>Tu.fetch(...u):()=>Promise.reject(Error("[ofetch] global.fetch is not supported!")),Zn=Tu.Headers,an=Tu.AbortController,Mt=sD({fetch:qn,Headers:Zn,AbortController:an});import{existsSync as Lt,readFileSync as kn}from"fs";import{join as gt}from"path";import{mkdirSync as Xn}from"fs";import{homedir as Hn}from"os";import{join as CD}from"path";var p="http://localhost:8000",Vn="e2e",yu=CD(Hn(),".mitsein");function Uu(){return Xn(yu,{recursive:!0,mode:448}),yu}function x(u=Vn){return CD(yu,"oauth",`${u}.json`)}function Iu(){return CD(yu,"openapi.json")}class o extends Error{code;detail;constructor(u,D=1,t){super(u);this.name="CliError",this.code=D,this.detail=t}}class fD extends o{constructor(u="No credentials found. Set MITSEIN_TOKEN, pass --token, or run from a dev environment with scripts/dev-token.sh."){super(u,2);this.name="NoCredentialsError"}}class iu extends o{statusCode;constructor(u,D,t){let r=u>=400&&u<500?1:3;super(D,r,t);this.name="HttpError",this.statusCode=u}}function w(u){return async function(...t){try{await Promise.resolve(u.apply(this,t))}catch(r){if(r instanceof o){if(R.error(`Error: ${r.message}`),r.detail!=null&&r.detail!=="")R.error(String(r.detail));process.exit(r.code)}if(r!==null&&typeof r==="object"&&r.name==="AbortError")process.stderr.write(`
|
|
98
|
+
Interrupted.
|
|
99
|
+
`),process.exit(130);throw r}}}function Kn(u){try{return new URL(u).hostname}catch{return""}}function vn(u){let D=Kn(u);return D==="localhost"||D==="127.0.0.1"||D==="::1"||D==="0.0.0.0"}function jn(u){let D=[];if(u)D.push(u);D.push(process.cwd());for(let t of D){let r=t;for(let n=0;n<10;n++){let F=gt(r,"scripts","dev-token.sh");if(Lt(F))return F;let i=gt(r,"..");if(i===r)break;r=i}}return null}function On(u,D){let t=[u,"--raw"];if(D)t.push("--real");let r=Bun.spawnSync(["bash",...t],{timeout:1e4,stdout:"pipe",stderr:"pipe"}),n=r.stdout.toString().trim();return{ok:r.success&&n.length>0,stdout:n}}function dn(u,D){if(u)return{token:u,endpoint:D??p};return null}function pn(){let u=process.env.MITSEIN_TOKEN;if(u)return{token:u,endpoint:process.env.MITSEIN_API_URL??p};return null}function xn(u,D){let t=x(u);if(!Lt(t))return null;try{let r=kn(t,"utf8"),n=JSON.parse(r),F=n.access_token;if(F)return{token:F,endpoint:D??n.endpoint??p}}catch{}return null}function u0(u,D,t,r){let n=u??p;if(!vn(n))return null;let F=jn(t);if(!F)return null;try{let{ok:i,stdout:e}=r(F,D);if(i)return{token:e,endpoint:n}}catch{}return null}function Y(u={}){let D=u.profile??"e2e",t=u.spawnDevToken??On,r=dn(u.token,u.endpoint);if(r)return r;let n=pn();if(n)return n;let F=xn(D,u.endpoint);if(F)return F;let i=u0(u.endpoint,u.real??!1,u.projectRoot,t);if(i)return i;throw new fD}function D0(u){return u.replace(/\/$/,"")}function K(u,D){if(u)process.stderr.write(`[debug] ${D}
|
|
100
|
+
`)}function t0(u){let D="HTTP error",t;if(u!==null&&typeof u==="object"&&!Array.isArray(u)){let r=u;D=typeof r.message==="string"?r.message:D,t=r.detail??r.error}return{message:D,detail:t}}async function hu(u){try{return await u}catch(D){if(D instanceof Eu){let t=D.statusCode??D.status??0,{message:r,detail:n}=t0(D.data);throw new iu(t||599,r,n)}throw D}}class y{timeoutMs;debug;fetchImpl;baseUrl;bearerToken;constructor(u,D={}){this.debug=D.debug??!1,this.timeoutMs=D.timeoutSec===void 0||D.timeoutSec===0?void 0:D.timeoutSec*1000,this.baseUrl=D0(u.endpoint),this.bearerToken=u.token;let t=this.debug;this.fetchImpl=D.fetcher??Mt.create({baseURL:this.baseUrl,timeout:this.timeoutMs,headers:{Authorization:`Bearer ${u.token}`,"Content-Type":"application/json"},retry:0,onRequest({request:r}){K(t,`${r.method} ${r.url}`)},onResponse({response:r}){K(t,`\u2192 ${r.status} (${r.headers.get("content-length")??"?"} bytes)`)}})}static fromOptions(u){let{timeoutSec:D,debug:t,fetcher:r,...n}=u,F=Y(n);return new y(F,{timeoutSec:D,debug:t,fetcher:r})}async get(u,D){let t=u.startsWith("/")?u:`/${u}`;return hu(this.fetchImpl(t,{method:"GET",query:D??void 0}))}async post(u,D){let t=u.startsWith("/")?u:`/${u}`;if(this.debug&&D!==void 0&&D!==null)K(this.debug,`body: ${JSON.stringify(D)}`);return hu(this.fetchImpl(t,{method:"POST",body:D===void 0||D===null?void 0:D}))}async postForm(u,D){let t=u.startsWith("/")?u:`/${u}`,r={};for(let[f,C]of Object.entries(D??{}))if(C!==void 0&&C!==null)r[f]=String(C);if(this.debug)K(this.debug,`POST ${t}`),K(this.debug,`form: ${JSON.stringify(r)}`);let n=`${this.baseUrl}${t}`,F=new URLSearchParams(r),i=new AbortController,e=this.timeoutMs,s=e===void 0?null:setTimeout(()=>i.abort(),e);try{let f=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${this.bearerToken}`,"Content-Type":"application/x-www-form-urlencoded"},body:F,signal:i.signal});if(K(this.debug,`\u2192 ${f.status} (${f.headers.get("content-length")??"?"} bytes)`),f.ok){if((f.headers.get("content-type")??"").includes("application/json"))return f.json();return f.text()}let C=`HTTP ${f.status}`,E;try{let c=await f.json();C=typeof c.message==="string"?c.message:C,E=c.detail??c.error}catch{}throw new iu(f.status,C,E)}catch(f){if(f instanceof iu)throw f;if(f instanceof Error&&f.name==="AbortError")throw new iu(599,"Request aborted or timed out");throw f}finally{if(s)clearTimeout(s)}}async patch(u,D){let t=u.startsWith("/")?u:`/${u}`;if(this.debug&&D!==void 0&&D!==null)K(this.debug,`body: ${JSON.stringify(D)}`);return hu(this.fetchImpl(t,{method:"PATCH",body:D===void 0||D===null?void 0:D}))}async put(u,D){let t=u.startsWith("/")?u:`/${u}`;if(this.debug&&D!==void 0&&D!==null)K(this.debug,`body: ${JSON.stringify(D)}`);return hu(this.fetchImpl(t,{method:"PUT",body:D===void 0||D===null?void 0:D}))}async delete(u){let D=u.startsWith("/")?u:`/${u}`;return hu(this.fetchImpl(D,{method:"DELETE"}))}}var ED=!1;function _(u){ED=u}function Qt(){return ED}function Wt(){return process.stdout.isTTY===!0}function $(u,D){if(ED){process.stdout.write(`${JSON.stringify(u,i0)}
|
|
101
|
+
`);return}if(D){D(u);return}if(u!==null&&typeof u==="object"&&!Array.isArray(u)){Pt(u);return}if(Array.isArray(u)){for(let t of u){if(t!==null&&typeof t==="object"&&!Array.isArray(t))Pt(t);else process.stdout.write(`${String(t)}
|
|
102
|
+
`);process.stdout.write(`
|
|
103
|
+
`)}return}process.stdout.write(`${u===void 0?"":String(u)}
|
|
104
|
+
`)}function i0(u,D){if(typeof D==="bigint")return D.toString();return D}function Pt(u){for(let[D,t]of Object.entries(u))process.stdout.write(`${D}: ${String(t)}
|
|
105
|
+
`)}function r0(u){let D=new Date(u*1000),t=String(D.getHours()).padStart(2,"0"),r=String(D.getMinutes()).padStart(2,"0"),n=String(D.getSeconds()).padStart(2,"0");return`${t}:${r}:${n}`}function zt(u,D){return u.length>D?`${u.slice(0,D)}...`:u}function Yt(u){let D=u.data;if(typeof D!=="object"||D===null){process.stdout.write(`\x1B[2m${String(D)}\x1B[0m
|
|
106
|
+
`);return}let t=u.event_type,r=typeof D.content==="string"?D.content:"",n=r0(u.timestamp);if(t==="assistant"||t==="text"||t==="message")process.stdout.write(`\x1B[2m[${n}]\x1B[0m \x1B[1massistant:\x1B[0m ${r}
|
|
107
|
+
`);else if(t==="tool_call"){let F=(typeof D.name==="string"?D.name:null)??(typeof D.tool_name==="string"?D.tool_name:null)??"?",i=D.arguments??D.args??"";if(typeof i==="string")i=zt(i,80);else i=JSON.stringify(i);process.stdout.write(`\x1B[2m[${n}]\x1B[0m \x1B[33mtool_call:\x1B[0m ${F}(${String(i)})
|
|
108
|
+
`)}else if(t==="tool_result"){let F=D.output??D.result??D.content??"";if(typeof F==="string")F=zt(F,100);else F=JSON.stringify(F);process.stdout.write(`\x1B[2m[${n}]\x1B[0m \x1B[32mtool_result:\x1B[0m ${String(F)}
|
|
109
|
+
`)}else if(t==="status"){let F=typeof D.status==="string"?D.status:"";process.stdout.write(`\x1B[2m[${n}]\x1B[0m \x1B[34mstatus:\x1B[0m ${F}
|
|
110
|
+
`)}else if(t==="error")process.stdout.write(`\x1B[2m[${n}]\x1B[0m \x1B[1m\x1B[31merror:\x1B[0m ${r}
|
|
111
|
+
`);else{let F=JSON.stringify(D).slice(0,120);process.stdout.write(`\x1B[2m[${n}]\x1B[0m \x1B[2m${t}:\x1B[0m ${F}
|
|
112
|
+
`)}}function qt(u){let D=String(u.status??""),t=Number(u.duration_ms??0)/1000,r=u.events_count;if(D==="succeeded")process.stdout.write(`
|
|
113
|
+
\x1B[1m\x1B[32m\u2713\x1B[0m run completed in ${t.toFixed(1)}s (${r} events)
|
|
114
|
+
`);else if(D==="failed"){let n=String(u.error??"");process.stdout.write(`
|
|
115
|
+
\x1B[1m\x1B[31m\u2717\x1B[0m run failed in ${t.toFixed(1)}s: ${n}
|
|
116
|
+
`)}else if(D==="disconnected")process.stdout.write(`
|
|
117
|
+
\x1B[2mdisconnected after ${t.toFixed(1)}s (${r} events)\x1B[0m
|
|
118
|
+
`)}function Zt(u,D){return u&&!D&&Wt()}function n0(u){return u.replace(/\/$/,"")}function F0(u,D=!1){let t=u.trim().split(`
|
|
119
|
+
`),r=[];for(let i of t){if(i.startsWith(":")){if(D)process.stderr.write(`[debug] SSE comment: ${i}
|
|
120
|
+
`);continue}if(i.startsWith("data: "))r.push(i.slice(6));else if(i.startsWith("data:"))r.push(i.slice(5))}if(r.length===0)return null;let n=r.join(`
|
|
121
|
+
`),F=Date.now()/1000;try{let i=JSON.parse(n);return{event_type:typeof i==="object"&&i!==null&&"type"in i&&typeof i.type==="string"?i.type:"message",data:i,raw:n,timestamp:F}}catch{return{event_type:"unknown",data:n,raw:n,timestamp:F}}}async function*at(u){let D=`${n0(u.endpoint)}${u.path.startsWith("/")?u.path:`/${u.path}`}`;if(u.debug)process.stderr.write(`[debug] SSE connecting to ${D}
|
|
122
|
+
`);let t=Date.now(),r=u.timeoutSec===void 0||u.timeoutSec===null||u.timeoutSec===0?null:u.timeoutSec*1000,n=await fetch(D,{headers:{Authorization:`Bearer ${u.token}`,Accept:"text/event-stream"},signal:u.signal});if(!n.ok)throw new o(`SSE connection failed: HTTP ${n.status}`,3);if(u.debug)process.stderr.write(`[debug] SSE connected (${n.status})
|
|
123
|
+
`);let F=n.body;if(!F)throw new o("SSE response has no body",3);let i=F.getReader(),e=new TextDecoder,s="";try{for(;;){let{done:f,value:C}=await i.read();if(f)break;s+=e.decode(C,{stream:!0});let E;while((E=s.indexOf(`
|
|
124
|
+
|
|
125
|
+
`))!==-1){let c=s.slice(0,E);s=s.slice(E+2);let B=F0(c,u.debug??!1);if(B!==null){if(yield B,r!==null&&Date.now()-t>r)throw new o("Stream timeout",124)}}}}finally{i.releaseLock()}}function e0(u,D,t){if(t&&!t.has(u.event_type))return;if(D)if(typeof u.data==="object"&&u.data!==null){let r={ts:u.timestamp,...u.data};process.stdout.write(`${JSON.stringify(r)}
|
|
126
|
+
`)}else process.stdout.write(`${JSON.stringify({ts:u.timestamp,type:u.event_type,raw:u.data})}
|
|
127
|
+
`);else Yt(u)}async function uu(u){let D=Date.now(),t=[],r="unknown",n=null,F=[],i=[],e=u.stream_output??!1,s=u.json_mode??Qt(),f=u.event_filter??null,C=u.debug??!1,E=u.eventStream==null,c=E?new AbortController:null,B=()=>{c?.abort()};if(E)process.once("SIGINT",B);let A=`/api/agent-run/${u.agent_run_id}/stream`,S=u.eventStream??at({endpoint:u.endpoint,path:A,token:u.token,timeoutSec:u.timeout??void 0,debug:C,signal:c?.signal});try{try{for await(let G of S){if(t.push({type:G.event_type,data:G.data}),u.on_event?.(G),e)e0(G,s,f);if(typeof G.data==="object"&&G.data!==null){let{data:P,event_type:j}=G;if(j==="status"){let Du=typeof P.status==="string"?P.status:"";if(Du==="completed"){r="succeeded";break}if(Du==="failed"||Du==="error"){r="failed",n=(typeof P.content==="string"?P.content:null)??(typeof P.error==="string"?P.error:null)??null;break}}else if(j==="error"){r="failed",n=(typeof P.content==="string"?P.content:null)??String(G.data);break}else if(j==="assistant"||j==="text"||j==="message"){let Du=typeof P.content==="string"?P.content:"";if(Du)F.push(Du)}else if(j==="tool_call"||j==="tool_result")i.push(P)}}}catch(G){if(G!==null&&typeof G==="object"&&G.name==="AbortError"){if(!s)process.stderr.write(`
|
|
128
|
+
\x1B[2mDisconnected from stream (run continues in background)\x1B[0m
|
|
129
|
+
`);r="disconnected"}else throw G}}finally{if(E)process.off("SIGINT",B)}let M=Date.now()-D,X={status:r,agent_run_id:u.agent_run_id,duration_ms:M,events_count:t.length};if(F.length>0)X.assistant_message=F.join("");if(i.length>0)X.tool_calls=i;if(n)X.error=n;if(Zt(e,s))qt(X);if(r==="failed")throw new o(`Run failed: ${n??"unknown error"}`,1,X);return X}function m(u){return u.optsWithGlobals()}function ru(u){if(!u)return null;let D=u.split(",").map((t)=>t.trim()).filter((t)=>t.length>0);return D.length>0?new Set(D):null}function I(u){let D=u.timeout??"30",t=Number.parseFloat(D);if(!Number.isFinite(t))return 30;if(t===0)return;return t}function Xt(u){u.command("agent").description("Agent operations").command("invoke <thread_id> <prompt>").description("Send a message, start the agent, optional wait/stream").option("--wait","Block until run completes",!1).option("--stream","Stream run events",!1).option("--cancel-on-interrupt","Cancel run on Ctrl-C (reserved)",!1).option("--filter <types>","Comma-separated SSE event types").option("--model <name>","Model override").option("--timeout <sec>","Wait/stream timeout (0 = no limit)","120").action(w(async function(r,n){let F=m(this),i=this.opts();if(_(Boolean(F.json)),i.wait&&i.stream)throw new o("--wait and --stream are mutually exclusive",2);let e=Y({token:F.token,endpoint:F.endpoint,profile:F.profile??"e2e",real:F.real}),s=new y(e,{debug:F.debug,timeoutSec:I(F)}),f=await s.post("/api/message/add",{thread_id:r,content:n}),C={};if(i.model)C.model_name=i.model;let c=(await s.postForm(`/api/thread/${r}/agent/start`,C)).agent_run_id??"";if(!i.wait&&!i.stream){$({message:f,agent_run_id:c,status:"started"});return}let B=i.timeout??"120",A=Number.parseFloat(B),S=Number.isFinite(A)&&A===0?null:Number.isFinite(A)?A:120,M=await uu({endpoint:e.endpoint,token:e.token,agent_run_id:c,timeout:S??void 0,stream_output:Boolean(i.stream),json_mode:Boolean(F.json),debug:F.debug,event_filter:ru(i.filter)});if(i.wait&&!i.stream)$(M)}))}import{readFileSync as kt}from"fs";import{existsSync as Ht,readFileSync as s0,writeFileSync as C0}from"fs";function hD(u){let D=u.replace(/([a-z0-9])([A-Z])/g,"$1-$2");return D=D.replace(/[_\s/]+/g,"-"),D=D.replace(/-+/g,"-"),D=D.replace(/^-+|-+$/g,""),D.toLowerCase()}class Vt{_spec;_operations=new Map;_byId=new Map;constructor(u){this._spec=u,this.parse()}parse(){let u=this._spec.paths;if(u===null||typeof u!=="object"||Array.isArray(u))return;for(let[D,t]of Object.entries(u)){if(t===null||typeof t!=="object"||Array.isArray(t))continue;let r=t;if("$ref"in r&&Object.keys(r).length===1)continue;for(let n of["get","post","put","patch","delete"]){let F=r[n];if(F===null||typeof F!=="object"||Array.isArray(F))continue;let i=F,e=typeof i.operationId==="string"?i.operationId:"",s=Array.isArray(i.tags)?i.tags:["untagged"],f=typeof s[0]==="string"?s[0]:"untagged",C=hD(f),E=typeof i.summary==="string"?i.summary:"",c=Array.isArray(i.parameters)?i.parameters:[],B=i.requestBody!==null&&typeof i.requestBody==="object"&&!Array.isArray(i.requestBody)?i.requestBody:null,A=e?hD(e):`${n}-${hD(D)}`,S={operation_id:A,tag:C,method:n,path:D,summary:E,parameters:c,request_body:B},M=this._operations.get(C)??[];M.push(S),this._operations.set(C,M),this._byId.set(A,S)}}}get tags(){return[...this._operations.keys()].sort()}operationsForTag(u){return this._operations.get(u)??[]}getOperation(u){return this._byId.get(u)}get allOperations(){return[...this._byId.values()]}}function cD(u){let D=s0(u,"utf8");try{return JSON.parse(D)}catch{let t=D.trim();if(t.startsWith("openapi:")||t.startsWith("swagger:"))throw new o(`File ${u} appears to be YAML; install a YAML parser or use JSON.`,2);throw new o(`Failed to parse ${u} as JSON`,2)}}async function f0(u,D){let t=`${u.replace(/\/$/,"")}/openapi.json`,r;try{r=await fetch(t,{signal:AbortSignal.timeout(1e4)})}catch(F){throw new o(`Failed to fetch OpenAPI spec from ${t}: ${F}`,3)}if(!r.ok)throw new o(`Failed to fetch OpenAPI spec from ${t}: HTTP ${r.status}`,3);let n=await r.json();try{Uu(),C0(D,`${JSON.stringify(n,null,2)}
|
|
130
|
+
`,"utf8")}catch{}return n}async function BD(u={}){let D=process.env.MITSEIN_OPENAPI_PATH;if(D)return cD(D);let t=Iu();if(!u.refresh&&Ht(t))try{return cD(t)}catch{}if(u.endpoint)return f0(u.endpoint,t);if(Ht(t))return cD(t);throw new o("No OpenAPI spec available. Run `mitsein dev openapi --refresh` or set MITSEIN_OPENAPI_PATH.",2)}async function Gu(u={}){let D=await BD(u);return new Vt(D)}function E0(u){let D={},t=0;while(t<u.length){let r=u[t];if(r===void 0)break;if(r.startsWith("--")){let n=r.replace(/^-+/,""),F=u[t+1];if(F!==void 0&&!F.startsWith("--"))D[n]=F,t+=2;else D[n]="true",t+=1}else t+=1}return D}function h0(u,D){if(D){let t=kt(0,"utf8");try{return JSON.parse(t)}catch(r){throw new o(`Invalid JSON from stdin: ${r}`,2)}}if(u===void 0)return;if(u.startsWith("@")){let t=u.slice(1);try{let r=kt(t,"utf8");return JSON.parse(r)}catch(r){if(r.code==="ENOENT")throw new o(`File not found: ${t}`,2);throw new o(`Invalid JSON in ${t}: ${r}`,2)}}try{return JSON.parse(u)}catch(t){throw new o(`Invalid JSON body: ${t}`,2)}}async function c0(u,D,t,r){let{path:n,method:F}=D,i=[...n.matchAll(/\{(\w+)\}/g)].map((s)=>s[1]??""),e={...r};for(let s of i)if(s in e){let f=e[s];delete e[s],n=n.replace(`{${s}}`,f??"")}else throw new o(`Missing required path parameter: --${s}`,2);if(F==="get"){let s=Object.keys(e).length>0?{...e}:void 0;return u.get(n,s)}if(F==="post")return u.post(n,t);if(F==="patch")return u.patch(n,t);if(F==="put")return u.put(n,t);if(F==="delete")return u.delete(n);throw new o(`Unsupported HTTP method: ${F}`,2)}function B0(u){let D=u;R.log(` \x1B[1m${D.tag??""}\x1B[0m (${D.operations??0} operations)`)}function o0(u){let D=u,t=D.method??"",r=t==="GET"?"\x1B[32m":t==="POST"?"\x1B[34m":t==="PATCH"?"\x1B[33m":t==="DELETE"?"\x1B[31m":"\x1B[37m",n=(D.operation??"").padEnd(30);R.log(` ${r}${t.padEnd(6)}\x1B[0m ${n} ${D.summary??""}`)}function Kt(u){let D=u.command("api").description("Auto-generated API commands from OpenAPI spec");D.command("list-tags").description("List all available API tags").option("--endpoint <url>","API base URL").action(w(async function(){let r=m(this),n=this.opts();_(Boolean(r.json));let F=await Gu({endpoint:n.endpoint??r.endpoint});for(let i of F.tags){let e=F.operationsForTag(i);$({tag:i,operations:e.length},B0)}})),D.command("list-ops <tag>").description("List operations for a tag").option("--endpoint <url>","API base URL").action(w(async function(r){let n=m(this),F=this.opts();_(Boolean(n.json));let i=await Gu({endpoint:F.endpoint??n.endpoint}),e=i.operationsForTag(r);if(e.length===0)throw new o(`Unknown tag '${r}'. Available: ${i.tags.join(", ")}`,2);for(let s of e)$({operation:s.operation_id,method:s.method.toUpperCase(),path:s.path,summary:s.summary},o0)})),D.command("api-call <tag> <operation>").description(`Execute an API operation (examples: mitsein api api-call threads list-threads --body '{"limit":20}')`).allowUnknownOption(!0).allowExcessArguments(!0).option("--body <json>","JSON body: inline or @file.json").option("--body-stdin","Read JSON body from stdin",!1).option("--endpoint <url>","API base URL").option("--token <token>","Bearer token").option("--timeout <sec>","HTTP timeout (0 = none)","30").option("--debug","Print HTTP details",!1).action(w(async function(r,n){let F=m(this),i=this.opts();_(Boolean(F.json));let e=await Gu({endpoint:i.endpoint??F.endpoint}),s=e.getOperation(n);if(s===void 0){let M=e.operationsForTag(r);if(M.length===0){let G=e.tags.length>0?e.tags.join(", "):"(none \u2014 run `mitsein dev openapi --refresh`)";throw new o(`Unknown tag '${r}'. Available tags: ${G}`,2)}let X=M.map((G)=>G.operation_id).join(", ");throw new o(`Unknown operation '${n}' in tag '${r}'. Available: ${X}`,2)}if(s.tag!==r)throw new o(`Operation '${n}' belongs to tag '${s.tag}', not '${r}'.`,2);let f=h0(i.body,Boolean(i.bodyStdin)),C=E0(this.args.slice(2)),E=i.timeout??F.timeout??"30",c=Number.parseFloat(E),B=Number.isFinite(c)&&c===0?void 0:Number.isFinite(c)?c:30,A=y.fromOptions({token:i.token??F.token,endpoint:i.endpoint??F.endpoint,profile:F.profile??"e2e",real:F.real,timeoutSec:B,debug:Boolean(i.debug??F.debug)}),S=await c0(A,s,f,C);$(S)}))}import{existsSync as pt,readFileSync as R0,unlinkSync as S0}from"fs";import{createServer as _0}from"http";import{parse as m0}from"querystring";import{execFileSync as oD}from"child_process";import{chmodSync as l0,mkdirSync as $0,writeFileSync as A0}from"fs";import{dirname as w0}from"path";var vt=19284;function Nu(u,D,t){Uu();let r=x(u);$0(w0(r),{recursive:!0,mode:448});let n={access_token:t.access_token??"",user_email:t.user_email??"",user_id:t.user_id??"",endpoint:D,created_at:Date.now()/1000,expires_in:t.expires_in??86400};A0(r,`${JSON.stringify(n,null,2)}
|
|
131
|
+
`,"utf8"),l0(r,384)}function Ju(u){try{if(process.platform==="darwin")oD("open",[u],{stdio:"ignore"});else if(process.platform==="win32")oD("cmd",["/c","start","",u],{stdio:"ignore"});else oD("xdg-open",[u],{stdio:"ignore"})}catch{}}function jt(u){return(u??process.env.MITSEIN_API_URL??p).replace(/\/$/,"")}function nu(u,D){let t=u[D];if(Array.isArray(t))return t[0];return t}async function Ot(u,D,t,r){let n={};if(await new Promise((F,i)=>{let e=!1,s,f=()=>{if(e)return;if(e=!0,s!==void 0)clearTimeout(s);C.close(()=>F())},C=_0((E,c)=>{let B=E.url??"",A="";try{A=new URL(B,"http://127.0.0.1").pathname}catch{A=""}if(A!=="/callback"){c.writeHead(404),c.end(),f();return}let S=B.includes("?")?m0(B.split("?",2)[1]??""):{};if(S.error){c.writeHead(200,{"Content-Type":"text/html"});let M=nu(S,"error_description")??nu(S,"error")??"Unknown error";c.end(`<html><body><h2>Login failed</h2><p>${String(M)}</p></body></html>`),n.error=String(M),f();return}if(S.account)n.account=nu(S,"account")??"";if(S.email)n.email=nu(S,"email")??"";if(S.token)n.token=nu(S,"token")??"";if(S.session_id)n.session_id=nu(S,"session_id")??"";c.writeHead(200,{"Content-Type":"text/html"}),c.end("<html><body><h2>Login successful!</h2><p>You can close this window.</p></body></html>"),n.success=!0,f()});C.once("error",(E)=>{if(!e){if(e=!0,s!==void 0)clearTimeout(s);i(E)}}),s=setTimeout(()=>f(),300000),C.listen(vt,"127.0.0.1",()=>{let E=`${u}/api/auth/cognito/login?provider=${encodeURIComponent(D)}`;if(!r)R.log(`
|
|
132
|
+
Opening browser for login...`),R.log(`If browser does not open, visit: ${E}
|
|
133
|
+
`);if(Ju(E),!r)R.log("Waiting for browser login...")})}),n.error!==void 0)throw new o(`Login failed: ${String(n.error)}`,1);if(n.success===!0){let F={access_token:String(n.token??""),user_email:String(n.email??""),user_id:String(n.account??"")};Nu(t,u,F),$({status:"logged_in",email:F.user_email,profile:t},()=>{R.success(`Logged in as ${F.user_email}`)});return}throw new o("Login timed out. Try again.",124)}async function b0(u){await new Promise((D)=>setTimeout(D,u))}async function dt(u,D,t){let r=await fetch(`${u}/api/auth/cli/device`,{method:"POST",signal:AbortSignal.timeout(1e4)});if(!r.ok)throw new o(`Failed to create device code: HTTP ${r.status}`,3);let n=await r.json(),{device_code:F,user_code:i,verification_url:e,expires_in:s}=n,f=n.interval??5,C=`${e}?user_code=${encodeURIComponent(i)}`;if(!t)R.log(`
|
|
134
|
+
Mitsein CLI Login
|
|
135
|
+
`),R.log("Open this URL in your browser:"),R.log(C),R.log(`Or go to ${e} and enter code:`),R.log(i),R.log(`Waiting for authorization (expires in ${Math.floor(s/60)} min)...`);Ju(C);let E=Date.now()+s*1000;while(Date.now()<E){await b0(f*1000);try{let B=await(await fetch(`${u}/api/auth/cli/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:F,grant_type:"device_code"}),signal:AbortSignal.timeout(1e4)})).json(),A=B.status;if(A==="authorized"){Nu(D,u,B),$({status:"logged_in",email:B.user_email??"",profile:D},()=>{R.success(`
|
|
136
|
+
Logged in as ${B.user_email??""}`)});return}if(A==="expired")throw new o("Device code expired. Run `mitsein auth login` again.",1);if(!t)process.stderr.write(".")}catch(c){if(c instanceof o)throw c;if(!t)R.log(`
|
|
137
|
+
Poll error: ${c}, retrying...`)}}throw new o("Login timed out. Run `mitsein auth login` again.",124)}function xt(u){let D=u.command("auth").description("Authentication management");D.command("login").description("Log in (browser callback on localhost, or --device-code)").option("--device-code","Device code flow",!1).option("--provider <name>","OAuth provider: google or msa","google").option("--endpoint <url>","API base URL").option("--profile <name>","Profile to save credentials","default").action(w(async function(){let r=m(this),n=this.opts();_(Boolean(r.json));let F=jt(n.endpoint??r.endpoint);if(n.deviceCode)await dt(F,n.profile??"default",Boolean(r.json));else await Ot(F,n.provider??"google",n.profile??"default",Boolean(r.json))})),D.command("logout").description("Remove saved credentials for a profile").option("--profile <name>","Profile","default").action(w(async function(){let r=m(this),n=this.opts();_(Boolean(r.json));let F=n.profile??"default",i=x(F);if(pt(i))S0(i),$({status:"logged_out",profile:F},()=>{R.success(`Logged out from profile '${F}'`)});else $({status:"not_logged_in",profile:F},()=>{R.log(`Not logged in (profile '${F}')`)})})),D.command("whoami").description("Show current identity").option("--profile <name>","Profile","default").option("--endpoint <url>","API base URL (display only)").action(w(async function(){let r=m(this),n=this.opts();_(Boolean(r.json)),n.endpoint;let F=n.profile??"default",i=x(F);if(!pt(i))throw new o("Not logged in. Run `mitsein auth login`.",2);let e=JSON.parse(R0(i,"utf8"));$({email:e.user_email??"unknown",user_id:e.user_id??"unknown",profile:F,endpoint:e.endpoint??""},(s)=>{let f=s;R.success(`Logged in as ${f.email}`),R.log(` User ID: ${f.user_id}`),R.log(` Profile: ${f.profile}`),R.log(` Endpoint: ${f.endpoint}`)})}))}function T0(u){let D=typeof u==="object"&&u!==null?u:null;if(Boolean(D&&(D.status==="ok"||D.ok===!0)))process.stdout.write(`\u2713 Backend is healthy
|
|
138
|
+
`);else process.stdout.write(`\u2717 Backend is unhealthy
|
|
139
|
+
`)}function y0(u){let D=u;process.stdout.write(`\u2713 ${D.title??""} v${D.version??""}
|
|
140
|
+
`),process.stdout.write(` ${D.paths??0} paths
|
|
141
|
+
`),process.stdout.write(` Cached at: ${D.cached_at??""}
|
|
142
|
+
`)}function ui(u){let D=u.command("dev").description("Development utilities");D.command("token").description("Print the resolved dev token").action(w(async function(){let r=m(this);if(r.real)process.stderr.write(`\u26A0\uFE0F Using --real: this token accesses real data, not e2e sandbox.
|
|
143
|
+
`);let n=Y({token:r.token,endpoint:r.endpoint,profile:r.profile??"e2e",real:r.real});$(n.token)})),D.command("health").description("Check backend health (GET /health)").action(w(async function(){let r=m(this),F=await y.fromOptions({token:r.token,endpoint:r.endpoint,profile:r.profile??"e2e",real:r.real,timeoutSec:I(r),debug:r.debug}).get("/health");$(F,T0)})),D.command("openapi").description("Fetch and cache OpenAPI spec from backend").option("--refresh","Force re-fetch from backend",!1).action(w(async function(){let r=m(this),n=this.opts();_(Boolean(r.json));let F=await BD({endpoint:r.endpoint,refresh:Boolean(n.refresh)}),i=Iu(),e=F.paths,s=e!==null&&typeof e==="object"&&!Array.isArray(e)?Object.keys(e).length:0,f=F.info??{};$({title:String(f.title??""),version:String(f.version??""),paths:s,cached_at:i},y0)}))}function Di(u){let D=u.command("messages").description("Message list and send (no agent)");D.command("list <thread_id>").description("List messages for a thread").option("--offset <n>","Pagination offset","0").option("--limit <n>","Max results","20").action(w(async function(r){let n=m(this),F=this.opts();_(Boolean(n.json));let i=y.fromOptions({token:n.token,endpoint:n.endpoint,profile:n.profile??"e2e",real:n.real,timeoutSec:I(n),debug:n.debug}),e=Number.parseInt(String(F.offset??"0"),10),s=Number.parseInt(String(F.limit??"20"),10),f=await i.post("/api/message/list",{thread_id:r,limit:Number.isFinite(s)?s:20,offset:Number.isFinite(e)?e:0});$(f)})),D.command("send <thread_id> <content>").description("Add a user message (does not start the agent)").action(w(async function(r,n){let F=m(this);_(Boolean(F.json));let e=await y.fromOptions({token:F.token,endpoint:F.endpoint,profile:F.profile??"e2e",real:F.real,timeoutSec:I(F),debug:F.debug}).post("/api/message/add",{thread_id:r,content:n});$(e)}))}function ti(u){let D=u.command("project").description("Project management");D.command("list").description("List projects").option("--offset <n>","Pagination offset","0").option("--limit <n>","Max results","20").action(w(async function(){let r=m(this),n=this.opts();_(Boolean(r.json));let F=y.fromOptions({token:r.token,endpoint:r.endpoint,profile:r.profile??"e2e",real:r.real,timeoutSec:I(r),debug:r.debug}),i=Number.parseInt(String(n.offset??"0"),10),e=Number.parseInt(String(n.limit??"20"),10),s=await F.post("/api/project/list",{offset:Number.isFinite(i)?i:0,limit:Number.isFinite(e)?e:20});$(s)})),D.command("get <project_id>").description("Get project details").action(w(async function(r){let n=m(this);_(Boolean(n.json));let i=await y.fromOptions({token:n.token,endpoint:n.endpoint,profile:n.profile??"e2e",real:n.real,timeoutSec:I(n),debug:n.debug}).post("/api/project/get",{project_id:r});$(i)})),D.command("delete <project_id>").description("Delete a project").action(w(async function(r){let n=m(this);_(Boolean(n.json));let i=await y.fromOptions({token:n.token,endpoint:n.endpoint,profile:n.profile??"e2e",real:n.real,timeoutSec:I(n),debug:n.debug}).post("/api/project/delete",{project_id:r});$(i)}))}function ii(u){let D=u.command("run").description("Agent run management");D.command("list <thread_id>").description("List agent runs for a thread").action(w(async function(r){let n=m(this);_(Boolean(n.json));let i=await y.fromOptions({token:n.token,endpoint:n.endpoint,profile:n.profile??"e2e",real:n.real,timeoutSec:I(n),debug:n.debug}).post(`/api/thread/${r}/agent-runs`);$(i)})),D.command("get <run_id>").description("Get agent run status").action(w(async function(r){let n=m(this);_(Boolean(n.json));let i=await y.fromOptions({token:n.token,endpoint:n.endpoint,profile:n.profile??"e2e",real:n.real,timeoutSec:I(n),debug:n.debug}).post(`/api/agent-run/${r}`);$(i)})),D.command("tail <run_id>").description("Stream agent run events (tail -f)").option("--filter <types>","Comma-separated event types").option("--timeout <sec>","Timeout (0 = no limit)","120").action(w(async function(r){let n=m(this),F=this.opts();_(Boolean(n.json));let i=Y({token:n.token,endpoint:n.endpoint,profile:n.profile??"e2e",real:n.real}),e=F.timeout??"120",s=Number.parseFloat(e),f=Number.isFinite(s)&&s===0?null:Number.isFinite(s)?s:120;await uu({endpoint:i.endpoint,token:i.token,agent_run_id:r,timeout:f??void 0,stream_output:!0,json_mode:Boolean(n.json),debug:n.debug,event_filter:ru(F.filter)})})),D.command("wait <run_id>").description("Block until agent run completes").option("--timeout <sec>","Timeout (0 = no limit)","120").action(w(async function(r){let n=m(this),F=this.opts();_(Boolean(n.json));let i=Y({token:n.token,endpoint:n.endpoint,profile:n.profile??"e2e",real:n.real}),e=F.timeout??"120",s=Number.parseFloat(e),f=Number.isFinite(s)&&s===0?null:Number.isFinite(s)?s:120,C=await uu({endpoint:i.endpoint,token:i.token,agent_run_id:r,timeout:f??void 0,stream_output:!1,json_mode:Boolean(n.json),debug:n.debug});$(C)})),D.command("cancel <run_id>").description("Cancel a running agent").action(w(async function(r){let n=m(this);_(Boolean(n.json));let i=await y.fromOptions({token:n.token,endpoint:n.endpoint,profile:n.profile??"e2e",real:n.real,timeoutSec:I(n),debug:n.debug}).post(`/api/agent-run/${r}/stop`);$(i)}))}function ri(u){let D=u.command("thread").description("Thread management and messaging");D.command("list").description("List threads").option("--offset <n>","Pagination offset","0").option("--limit <n>","Max results","20").action(w(async function(){let r=m(this);_(Boolean(r.json));let n=y.fromOptions({token:r.token,endpoint:r.endpoint,profile:r.profile??"e2e",real:r.real,timeoutSec:I(r),debug:r.debug}),F=Number.parseInt(String(this.opts().offset??"0"),10),i=Number.parseInt(String(this.opts().limit??"20"),10),e=await n.post("/api/thread/list",{offset:Number.isFinite(F)?F:0,limit:Number.isFinite(i)?i:20});$(e)})),D.command("get <thread_id>").description("Get thread details").action(w(async function(r){let n=m(this);_(Boolean(n.json));let i=await y.fromOptions({token:n.token,endpoint:n.endpoint,profile:n.profile??"e2e",real:n.real,timeoutSec:I(n),debug:n.debug}).post("/api/thread/get",{thread_id:r});$(i)})),D.command("create").description("Create a new thread").option("--title <title>","Thread title","").action(w(async function(){let r=m(this),{title:n}=this.opts();_(Boolean(r.json));let i=await y.fromOptions({token:r.token,endpoint:r.endpoint,profile:r.profile??"e2e",real:r.real,timeoutSec:I(r),debug:r.debug}).post("/api/thread/create",{title:n??""});$(i)})),D.command("history <thread_id>").description("Show message history for a thread").option("--limit <n>","Max messages","50").action(w(async function(r){let n=m(this),{limit:F}=this.opts();_(Boolean(n.json));let i=y.fromOptions({token:n.token,endpoint:n.endpoint,profile:n.profile??"e2e",real:n.real,timeoutSec:I(n),debug:n.debug}),e=Number.parseInt(String(F??"50"),10),s=await i.post("/api/message/list",{thread_id:r,limit:Number.isFinite(e)?e:50});$(s)})),D.command("send <thread_id> <message>").description("Send a message and start an agent run").option("--wait","Block until run completes",!1).option("--stream","Stream run events",!1).option("--cancel-on-interrupt","Cancel run on Ctrl-C (reserved)",!1).option("--filter <types>","Comma-separated SSE event types").option("--agent <name>","Agent name (reserved)","").option("--model <name>","Model override").option("--timeout <sec>","Wait/stream timeout (0 = no limit)","120").action(w(async function(r,n){let F=m(this),i=this.opts();if(_(Boolean(F.json)),i.wait&&i.stream)throw new o("--wait and --stream are mutually exclusive",2);let e=Y({token:F.token,endpoint:F.endpoint,profile:F.profile??"e2e",real:F.real}),s=new y(e,{debug:F.debug,timeoutSec:I(F)}),f=await s.post("/api/message/add",{thread_id:r,content:n}),C={};if(i.model)C.model_name=i.model;let c=(await s.postForm(`/api/thread/${r}/agent/start`,C)).agent_run_id??"";if(!i.wait&&!i.stream){$({message:f,agent_run_id:c,status:"started"});return}let B=i.timeout??"120",A=Number.parseFloat(B),S=Number.isFinite(A)&&A===0?null:Number.isFinite(A)?A:120,M=await uu({endpoint:e.endpoint,token:e.token,agent_run_id:c,timeout:S??void 0,stream_output:Boolean(i.stream),json_mode:Boolean(F.json),debug:F.debug,event_filter:ru(i.filter)});if(i.wait&&!i.stream)$(M)}))}import{readFileSync as U0}from"fs";import{join as I0}from"path";function G0(){let u=I0(import.meta.dir,"..","..","package.json");try{return JSON.parse(U0(u,"utf8")).version??"0.1.0-dev"}catch{return"0.1.0-dev"}}function ni(){$(G0())}var q=new gD;q.name("mitsein").description("Mitsein CLI \u2014 internal dev tool for agent verification and workflow automation.").option("--endpoint <url>","API endpoint URL").option("--token <token>","Bearer token").option("--profile <name>","Profile name","e2e").option("--real","Use real account for dev token",!1).option("--json","Output structured JSON",!1).option("--debug","Print HTTP request/response details",!1).option("--timeout <sec>","HTTP timeout in seconds (0 = no timeout)","30").hook("preAction",(u,D)=>{let r=(D??u).optsWithGlobals();_(Boolean(r.json))});q.command("version").description("Print CLI version").action(()=>{ni()});ui(q);Kt(q);ri(q);ii(q);Di(q);Xt(q);ti(q);xt(q);try{await q.parseAsync(process.argv,{from:"node"})}catch(u){if(u instanceof o){if(R.error(`Error: ${u.message}`),u.detail!=null&&u.detail!=="")R.error(String(u.detail));process.exit(u.code)}R.error(u),process.exit(1)}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bin": {
|
|
3
|
+
"mitsein": "./dist/index.js"
|
|
4
|
+
},
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"commander": "^13.1.0",
|
|
7
|
+
"consola": "^3.4.2",
|
|
8
|
+
"ofetch": "^1.4.1"
|
|
9
|
+
},
|
|
10
|
+
"description": "Mitsein CLI \u2014 dev tooling, API helpers, and workflow automation",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/bun": "latest",
|
|
13
|
+
"typescript": "^5.3.3"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"bun": ">=1.0.0"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"src",
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"mitsein",
|
|
25
|
+
"cli",
|
|
26
|
+
"agent",
|
|
27
|
+
"api"
|
|
28
|
+
],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"main": "./src/index.ts",
|
|
31
|
+
"name": "@mitsein-ai/cli",
|
|
32
|
+
"private": false,
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"directory": "bun-workspace/apps/mitsein-cli",
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://gitee.com/mitsein/mitsein.git"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "bun build ./src/index.ts --outdir=dist --target=bun --minify",
|
|
43
|
+
"prepublishOnly": "bun run typecheck && bun test && bun run build",
|
|
44
|
+
"test": "bun test",
|
|
45
|
+
"typecheck": "tsc --noEmit"
|
|
46
|
+
},
|
|
47
|
+
"type": "module",
|
|
48
|
+
"version": "0.1.0"
|
|
49
|
+
}
|