@macpaw/cctk 1.0.0-beta.1 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"chalk";import t,{once as n,addAbortListener as r,EventEmitter as i,on as o,setMaxListeners as s}from"node:events";import a,{ChildProcess as l,spawnSync as c,spawn as d}from"node:child_process";import u from"node:path";import p,{statSync as m,readFileSync as h,appendFileSync as f,writeFileSync as g,createWriteStream as b,createReadStream as w,existsSync as y}from"node:fs";import v,{platform as $,hrtime as S,execPath as E,execArgv as x,stdin as O,stdout as C}from"node:process";import _,{spawnSync as T}from"child_process";import{fileURLToPath as A}from"node:url";import{StringDecoder as I}from"node:string_decoder";import{debuglog as D,stripVTControlCharacters as k,inspect as M,promisify as j,callbackify as N,aborted as P,styleText as R}from"node:util";import L,{ReadStream as B}from"node:tty";import F from"path";import U from"fs";import{toPath as H,traversePathUp as W}from"unicorn-magic";import{setTimeout as G,scheduler as V,setImmediate as q}from"node:timers/promises";import{constants as K}from"node:os";import{serialize as z}from"node:v8";import{Transform as Y,getDefaultHighWaterMark as J,Duplex as X,Writable as Q,Readable as Z,PassThrough as ee}from"node:stream";import{Buffer as te}from"node:buffer";import{finished as ne}from"node:stream/promises";import*as re from"node:readline";import ie from"node:readline";import oe,{copyFile as se}from"node:fs/promises";var ae="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function le(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ce={},de={},ue={};let pe=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}};ue.CommanderError=pe,ue.InvalidArgumentError=class extends pe{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:me}=ue;de.Argument=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.length>3&&"..."===this._name.slice(-3)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new me(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,t):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},de.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"};var he={},fe={};const{humanReadableArgName:ge}=de;function be(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,"")}fe.Help=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){const t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){const n=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){const t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){const r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);r||i?n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description)):t.push(n)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];const t=[];for(let n=e.parent;n;n=n.parent){const e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){const t=e.registeredArguments.map(e=>ge(e)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let t=e.parent;t;t=t.parent)n=t.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){const t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){const n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatHelp(e,t){const n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""];const s=t.commandDescription(e);s.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(s),r),""]));const a=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));a.length>0&&(o=o.concat([t.styleTitle("Arguments:"),...a,""]));const l=t.visibleOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));if(l.length>0&&(o=o.concat([t.styleTitle("Options:"),...l,""])),t.showGlobalOptions){const n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));n.length>0&&(o=o.concat([t.styleTitle("Global Options:"),...n,""]))}const c=t.visibleCommands(e).map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));return c.length>0&&(o=o.concat([t.styleTitle("Commands:"),...c,""])),o.join("\n")}displayWidth(e){return be(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(e=>"[options]"===e?this.styleOptionText(e):"[command]"===e?this.styleSubcommandText(e):"["===e[0]||"<"===e[0]?this.styleArgumentText(e):this.styleCommandText(e)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(e=>"[options]"===e?this.styleOptionText(e):"["===e[0]||"<"===e[0]?this.styleArgumentText(e):this.styleSubcommandText(e)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){const i=" ".repeat(2);if(!n)return i+e;const o=e.padEnd(t+e.length-r.displayWidth(e)),s=(this.helpWidth??80)-t-2-2;let a;return a=s<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,s).replace(/\n/g,"\n"+" ".repeat(t+2)),i+o+" ".repeat(2)+a.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;const n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{const n=e.match(r);if(null===n)return void i.push("");let o=[n.shift()],s=this.displayWidth(o[0]);n.forEach(e=>{const n=this.displayWidth(e);if(s+n<=t)return o.push(e),void(s+=n);i.push(o.join(""));const r=e.trimStart();o=[r],s=this.displayWidth(r)}),i.push(o.join(""))}),i.join("\n")}},fe.stripColor=be;var we={};const{InvalidArgumentError:ye}=ue;function ve(e){return e.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}we.Option=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;const n=function(e){let t,n;const r=/^-[^-]$/,i=/^--[^-]/,o=e.split(/[ |,]+/).concat("guard");if(r.test(o[0])&&(t=o.shift()),i.test(o[0])&&(n=o.shift()),!t&&r.test(o[0])&&(t=o.shift()),!t&&i.test(o[0])&&(t=n,n=o.shift()),o[0].startsWith("-")){const t=o[0],n=`option creation failed due to '${t}' in option flags '${e}'`;if(/^-[^-][^-]/.test(t))throw new Error(`${n}\n- a short flag is a single dash and a single character\n - either use a single dash and a single character (for a short flag)\n - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(r.test(t))throw new Error(`${n}\n- too many short flags`);if(i.test(t))throw new Error(`${n}\n- too many long flags`);throw new Error(`${n}\n- unrecognised flag format`)}if(void 0===t&&void 0===n)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}(e);this.short=n.shortFlag,this.long=n.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(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return"string"==typeof e&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new ye(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,t):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?ve(this.name().replace(/^no-/,"")):ve(this.name())}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},we.DualOptions=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){const n=t.attributeName();if(!this.dualOptions.has(n))return!0;const r=this.negativeOptions.get(n).presetArg,i=void 0!==r&&r;return t.negate===(i===e)}};var $e={suggestSimilar:function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));const n=e.startsWith("--");n&&(e=e.slice(2),t=t.map(e=>e.slice(2)));let r=[],i=3;return t.forEach(t=>{if(t.length<=1)return;const n=function(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);const n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let o=1;o=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+o),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}(e,t),o=Math.max(e.length,t.length);(o-n)/o>.4&&(n<i?(i=n,r=[t]):n===i&&r.push(t))}),r.sort((e,t)=>e.localeCompare(t)),n&&(r=r.map(e=>`--${e}`)),r.length>1?`\n(Did you mean one of ${r.join(", ")}?)`:1===r.length?`\n(Did you mean ${r[0]}?)`:""}};const Se=t.EventEmitter,Ee=a,xe=u,Oe=p,Ce=v,{Argument:_e,humanReadableArgName:Te}=de,{CommanderError:Ae}=ue,{Help:Ie,stripColor:De}=fe,{Option:ke,DualOptions:Me}=we,{suggestSimilar:je}=$e;function Ne(e){return e.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n,r="127.0.0.1",i="9229";return null!==(n=e.match(/^(--inspect(-brk)?)$/))?t=n[1]:null!==(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=n[1],/^\d+$/.test(n[3])?i=n[3]:r=n[3]):null!==(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=n[1],r=n[3],i=n[4]),t&&"0"!==i?`${t}=${r}:${parseInt(i)+1}`:e})}function Pe(){return!Ce.env.NO_COLOR&&"0"!==Ce.env.FORCE_COLOR&&"false"!==Ce.env.FORCE_COLOR&&(!(!Ce.env.FORCE_COLOR&&void 0===Ce.env.CLICOLOR_FORCE)||void 0)}he.Command=class e extends Se{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>Ce.stdout.write(e),writeErr:e=>Ce.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>Ce.stdout.isTTY?Ce.stdout.columns:void 0,getErrHelpWidth:()=>Ce.stderr.isTTY?Ce.stderr.columns:void 0,getOutHasColors:()=>Pe()??(Ce.stdout.isTTY&&Ce.stdout.hasColors?.()),getErrHasColors:()=>Pe()??(Ce.stderr.isTTY&&Ce.stderr.hasColors?.()),stripColor:e=>De(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){const e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let r=t,i=n;"object"==typeof r&&null!==r&&(i=r,r=null),i=i||{};const[,o,s]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(o);return r&&(a.description(r),a._executableHandler=!0),i.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!i.noHelp&&!i.hidden),a._executableFile=i.executableFile||null,s&&a.arguments(s),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),r?this:a}createCommand(t){return new e(t)}createHelp(){return Object.assign(new Ie,this.configureHelp())}configureHelp(e){return void 0===e?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return void 0===e?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return"string"!=typeof e&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(t=t||{}).isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new _e(e,t)}argument(e,t,n,r){const i=this.createArgument(e,t);return"function"==typeof n?i.default(r).argParser(n):i.default(n),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(e){const t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&void 0!==e.defaultValue&&void 0===e.parseArg)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if("boolean"==typeof e)return this._addImplicitHelpCommand=e,this;e=e??"help [command]";const[,n,r]=e.match(/([^ ]+) *(.*)/),i=t??"display help for command",o=this.createCommand(n);return o.helpOption(!1),r&&o.arguments(r),i&&o.description(i),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(e,t){return"object"!=typeof e?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(void 0===this._helpCommand&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){const n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return this._exitCallback=e||(e=>{if("commander.executeSubCommandAsync"!==e.code)throw e}),this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new Ae(e,t,n)),Ce.exit(e)}action(e){return this._actionHandler=t=>{const n=this.registeredArguments.length,r=t.slice(0,n);return this._storeOptionsAsProperties?r[n]=this:r[n]=this.opts(),r.push(this),e.apply(this,r)},this}createOption(e,t){return new ke(e,t)}_callParseArg(e,t,n,r){try{return e.parseArg(t,n)}catch(e){if("commander.invalidArgument"===e.code){const t=`${r} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}_registerOption(e){const t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){const n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'\n- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){const t=e=>[e.name()].concat(e.aliases()),n=t(e).find(e=>this._findCommand(e));if(n){const r=t(this._findCommand(n)).join("|"),i=t(e).join("|");throw new Error(`cannot add command '${i}' as already have command '${r}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);const t=e.name(),n=e.attributeName();if(e.negate){const t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(n,void 0===e.defaultValue||e.defaultValue,"default")}else void 0!==e.defaultValue&&this.setOptionValueWithSource(n,e.defaultValue,"default");const r=(t,r,i)=>{null==t&&void 0!==e.presetArg&&(t=e.presetArg);const o=this.getOptionValue(n);null!==t&&e.parseArg?t=this._callParseArg(e,t,o,r):null!==t&&e.variadic&&(t=e._concatValue(t,o)),null==t&&(t=!e.negate&&(!(!e.isBoolean()&&!e.optional)||"")),this.setOptionValueWithSource(n,t,i)};return this.on("option:"+t,t=>{const n=`error: option '${e.flags}' argument '${t}' is invalid.`;r(t,n,"cli")}),e.envVar&&this.on("optionEnv:"+t,t=>{const n=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;r(t,n,"env")}),this}_optionEx(e,t,n,r,i){if("object"==typeof t&&t instanceof ke)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const o=this.createOption(t,n);if(o.makeOptionMandatory(!!e.mandatory),"function"==typeof r)o.default(i).argParser(r);else if(r instanceof RegExp){const e=r;r=(t,n)=>{const r=e.exec(t);return r?r[0]:n},o.default(i).argParser(r)}else o.default(r);return this.addOption(o)}option(e,t,n,r){return this._optionEx({},e,t,n,r)}requiredOption(e,t,n,r){return this._optionEx({mandatory:!0},e,t,n,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{void 0!==n.getOptionValueSource(e)&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(void 0!==e&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},void 0===e&&void 0===t.from){Ce.versions?.electron&&(t.from="electron");const e=Ce.execArgv??[];(e.includes("-e")||e.includes("--eval")||e.includes("-p")||e.includes("--print"))&&(t.from="eval")}let n;switch(void 0===e&&(e=Ce.argv),this.rawArgs=e.slice(),t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":Ce.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){this._prepareForParse();const n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();const n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){null===this._savedState?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error("Can not call parse again when storeOptionsAsProperties is true.\n- either make a new Command for each call to parse, or stop storing options as properties");this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(!Oe.existsSync(e))throw new Error(`'${e}' does not exist\n - if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory"}`)}_executeSubCommand(e,t){t=t.slice();let n=!1;const r=[".js",".ts",".tsx",".mjs",".cjs"];function i(e,t){const n=xe.resolve(e,t);if(Oe.existsSync(n))return n;if(r.includes(xe.extname(t)))return;const i=r.find(e=>Oe.existsSync(`${n}${e}`));return i?`${n}${i}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o,s=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let e;try{e=Oe.realpathSync(this._scriptPath)}catch{e=this._scriptPath}a=xe.resolve(xe.dirname(e),a)}if(a){let t=i(a,s);if(!t&&!e._executableFile&&this._scriptPath){const n=xe.basename(this._scriptPath,xe.extname(this._scriptPath));n!==this._name&&(t=i(a,`${n}-${e._name}`))}s=t||s}n=r.includes(xe.extname(s)),"win32"!==Ce.platform?n?(t.unshift(s),t=Ne(Ce.execArgv).concat(t),o=Ee.spawn(Ce.argv[0],t,{stdio:"inherit"})):o=Ee.spawn(s,t,{stdio:"inherit"}):(this._checkForMissingExecutable(s,a,e._name),t.unshift(s),t=Ne(Ce.execArgv).concat(t),o=Ee.spawn(Ce.execPath,t,{stdio:"inherit"})),o.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(e=>{Ce.on(e,()=>{!1===o.killed&&null===o.exitCode&&o.kill(e)})});const l=this._exitCallback;o.on("close",e=>{e=e??1,l?l(new Ae(e,"commander.executeSubCommandAsync","(close)")):Ce.exit(e)}),o.on("error",t=>{if("ENOENT"===t.code)this._checkForMissingExecutable(s,a,e._name);else if("EACCES"===t.code)throw new Error(`'${s}' not executable`);if(l){const e=new Ae(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,l(e)}else Ce.exit(1)}),this.runningCommand=o}_dispatchSubcommand(e,t,n){const r=this._findCommand(e);let i;return r||this.help({error:!0}),r._prepareForParse(),i=this._chainOrCallSubCommandHook(i,r,"preSubcommand"),i=this._chainOrCall(i,()=>{if(!r._executableHandler)return r._parseCommand(t,n);this._executeSubCommand(r,t.concat(n))}),i}_dispatchHelpCommand(e){e||this.help();const t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&null==this.args[t]&&this.missingArgument(e.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const e=(e,t,n)=>{let r=t;if(null!==t&&e.parseArg){const i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):void 0===i&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&"function"==typeof e.then?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e;const r=[];return this._getCommandAndAncestors().reverse().filter(e=>void 0!==e._lifeCycleHooks[t]).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),"postAction"===t&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return void 0!==this._lifeCycleHooks[n]&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){const n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){let n;return r(),this._processArguments(),n=this._chainOrCallHooks(n,"preAction"),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,"postAction"),n}if(this.parent&&this.parent.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&void 0===e.getOptionValue(t.attributeName())&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){const e=this.options.filter(e=>{const t=e.attributeName();return void 0!==this.getOptionValue(t)&&"default"!==this.getOptionValueSource(t)}),t=e.filter(e=>e.conflictsWith.length>0);t.forEach(t=>{const n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){const t=[],n=[];let r=t;const i=e.slice();function o(e){return e.length>1&&"-"===e[0]}let s=null;for(;i.length;){const e=i.shift();if("--"===e){r===n&&r.push(e),r.push(...i);break}if(!s||o(e)){if(s=null,o(e)){const t=this._findOption(e);if(t){if(t.required){const e=i.shift();void 0===e&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,e)}else if(t.optional){let e=null;i.length>0&&!o(i[0])&&(e=i.shift()),this.emit(`option:${t.name()}`,e)}else this.emit(`option:${t.name()}`);s=t.variadic?t:null;continue}}if(e.length>2&&"-"===e[0]&&"-"!==e[1]){const t=this._findOption(`-${e[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,e.slice(2)):(this.emit(`option:${t.name()}`),i.unshift(`-${e.slice(2)}`));continue}}if(/^--[^=]+=/.test(e)){const t=e.indexOf("="),n=this._findOption(e.slice(0,t));if(n&&(n.required||n.optional)){this.emit(`option:${n.name()}`,e.slice(t+1));continue}}if(o(e)&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&0===t.length&&0===n.length){if(this._findCommand(e)){t.push(e),i.length>0&&n.push(...i);break}if(this._getHelpCommand()&&e===this._getHelpCommand().name()){t.push(e),i.length>0&&t.push(...i);break}if(this._defaultCommandName){n.push(e),i.length>0&&n.push(...i);break}}if(this._passThroughOptions){r.push(e),i.length>0&&r.push(...i);break}r.push(e)}else this.emit(`option:${s.name()}`,e)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){const e={},t=this.options.length;for(let n=0;n<t;n++){const t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0}));const n=t||{},r=n.exitCode||1,i=n.code||"commander.error";this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in Ce.env){const t=e.attributeName();(void 0===this.getOptionValue(t)||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,Ce.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){const e=new Me(this.options),t=e=>void 0!==this.getOptionValue(e)&&!["default","implied"].includes(this.getOptionValueSource(e));this.options.filter(n=>void 0!==n.implied&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],"implied")})})}missingArgument(e){const t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){const t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){const t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){const n=e=>{const t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(void 0===r.presetArg&&!1===n||void 0!==r.presetArg&&n===r.presetArg)?r:i||e},r=e=>{const t=n(e),r=t.attributeName();return"env"===this.getOptionValueSource(r)?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],r=this;do{const e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=je(e,n)}const n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;const t=this.registeredArguments.length,n=1===t?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=je(e,n)}const n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(void 0===e)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";const r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,"commander.version",e)}),this}description(e,t){return void 0===e&&void 0===t?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return void 0===e?this._summary:(this._summary=e,this)}alias(e){if(void 0===e)return this._aliases[0];let t=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");const n=this.parent?._findCommand(e);if(n){const t=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return void 0===e?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(void 0===e){if(this._usage)return this._usage;const e=this.registeredArguments.map(e=>Te(e));return[].concat(this.options.length||null!==this._helpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=e,this}name(e){return void 0===e?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=xe.basename(e,xe.extname(e)),this}executableDir(e){return void 0===e?this._executableDir:(this._executableDir=e,this)}helpInformation(e){const t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});const r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){const t=!!(e=e||{}).error;let n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;"function"==typeof e&&(t=e,e=void 0);const n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),"string"!=typeof i&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(e=>e.emit("afterAllHelp",r))}helpOption(e,t){return"boolean"==typeof e?(this._helpOption=e?this._helpOption??void 0:null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return void 0===this._helpOption&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=Number(Ce.exitCode??0);0===t&&e&&"function"!=typeof e&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${n.join("', '")}'`);const r=`${e}Help`;return this.on(r,e=>{let n;n="function"==typeof t?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){const t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}},he.useColor=Pe;const{Argument:Re}=de,{Command:Le}=he,{CommanderError:Be,InvalidArgumentError:Fe}=ue,{Help:Ue}=fe,{Option:He}=we;ce.program=new Le,ce.createCommand=e=>new Le(e),ce.createOption=(e,t)=>new He(e,t),ce.createArgument=(e,t)=>new Re(e,t),ce.Command=Le,ce.Option=He,ce.Argument=Re,ce.Help=Ue,ce.CommanderError=Be,ce.InvalidArgumentError=Fe,ce.InvalidOptionArgumentError=Fe;const{Command:We}=ce;function Ge(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}const Ve=(e,t)=>{const n=ze(qe(e));if("string"!=typeof n)throw new TypeError(`${t} must be a string or a file URL: ${n}.`);return n},qe=e=>Ke(e)?e.toString():e,Ke=e=>"string"!=typeof e&&e&&Object.getPrototypeOf(e)===String.prototype,ze=e=>e instanceof URL?A(e):e,Ye=(e,t=[],n={})=>{const r=Ve(e,"First argument"),[i,o]=Ge(t)?[[],t]:[t,n];if(!Array.isArray(i))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${i}`);if(i.some(e=>"object"==typeof e&&null!==e))throw new TypeError(`Second argument must be an array of strings: ${i}`);const s=i.map(String),a=s.find(e=>e.includes("\0"));if(void 0!==a)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${a}`);if(!Ge(o))throw new TypeError(`Last argument must be an options object: ${o}`);return[r,s,o]},{toString:Je}=Object.prototype,Xe=e=>"[object Uint8Array]"===Je.call(e),Qe=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Ze=new TextEncoder,et=e=>Ze.encode(e),tt=new TextDecoder,nt=e=>tt.decode(e),rt=e=>1===e.length&&Xe(e[0])?e[0]:ot(it(e)),it=e=>e.map(e=>"string"==typeof e?et(e):e),ot=e=>{const t=new Uint8Array(st(e));let n=0;for(const r of e)t.set(r,n),n+=r.length;return t},st=e=>{let t=0;for(const n of e)t+=n.length;return t},at=({templates:e,expressions:t,tokens:n,index:r,template:i})=>{if(void 0===i)throw new TypeError(`Invalid backslash sequence: ${e.raw[r]}`);const{nextTokens:o,leadingWhitespaces:s,trailingWhitespaces:a}=lt(i,e.raw[r]),l=ut(n,o,s);if(r===t.length)return l;const c=t[r],d=Array.isArray(c)?c.map(e=>pt(e)):[pt(c)];return ut(l,d,a)},lt=(e,t)=>{if(0===t.length)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};const n=[];let r=0;const i=ct.has(t[0]);for(let i=0,o=0;i<e.length;i+=1,o+=1){const s=t[o];if(ct.has(s))r!==i&&n.push(e.slice(r,i)),r=i+1;else if("\\"===s){const e=t[o+1];"\n"===e?(i-=1,o+=1):"u"===e&&"{"===t[o+2]?o=t.indexOf("}",o+3):o+=dt[e]??1}}const o=r===e.length;return o||n.push(e.slice(r)),{nextTokens:n,leadingWhitespaces:i,trailingWhitespaces:o}},ct=new Set([" ","\t","\r","\n"]),dt={x:3,u:5},ut=(e,t,n)=>n||0===e.length||0===t.length?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],pt=e=>{const t=typeof e;if("string"===t)return e;if("number"===t)return String(e);if(Ge(e)&&("stdout"in e||"isMaxBuffer"in e))return mt(e);if(e instanceof l||"[object Promise]"===Object.prototype.toString.call(e))throw new TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}.");throw new TypeError(`Unexpected "${t}" in template expression`)},mt=({stdout:e})=>{if("string"==typeof e)return e;if(Xe(e))return nt(e);if(void 0===e)throw new TypeError('Missing result.stdout in template expression. This is probably due to the previous subprocess\' "stdout" option.');throw new TypeError(`Unexpected "${typeof e}" stdout in template expression`)},ht=e=>ft.includes(e),ft=[v.stdin,v.stdout,v.stderr],gt=["stdin","stdout","stderr"],bt=e=>gt[e]??`stdio[${e}]`,wt=(e,t)=>{const n=Array.from({length:yt(e)+1}),r=vt(e[t],n,t);return _t(r,t)},yt=({stdio:e})=>Array.isArray(e)?Math.max(e.length,gt.length):gt.length,vt=(e,t,n)=>Ge(e)?$t(e,t,n):t.fill(e),$t=(e,t,n)=>{for(const r of Object.keys(e).sort(St))for(const i of xt(r,n,t))t[i]=e[r];return t},St=(e,t)=>Et(e)<Et(t)?1:-1,Et=e=>"stdout"===e||"stderr"===e?0:"all"===e?2:1,xt=(e,t,n)=>{if("ipc"===e)return[n.length-1];const r=Ot(e);if(void 0===r||0===r)throw new TypeError(`"${t}.${e}" is invalid.\nIt must be "${t}.stdout", "${t}.stderr", "${t}.all", "${t}.ipc", or "${t}.fd3", "${t}.fd4" (and so on).`);if(r>=n.length)throw new TypeError(`"${t}.${e}" is invalid: that file descriptor does not exist.\nPlease set the "stdio" option to ensure that file descriptor exists.`);return"all"===r?[1,2]:[r]},Ot=e=>{if("all"===e)return e;if(gt.includes(e))return gt.indexOf(e);const t=Ct.exec(e);return null!==t?Number(t[1]):void 0},Ct=/^fd(\d+)$/,_t=(e,t)=>e.map(e=>void 0===e?Tt[t]:e),Tt={lines:!1,buffer:!0,maxBuffer:1e8,verbose:D("execa").enabled?"full":"none",stripFinalNewline:!0},At=["lines","buffer","maxBuffer","verbose","stripFinalNewline"],It=(e,t)=>"ipc"===t?e.at(-1):e[t],Dt=({verbose:e},t)=>"none"!==Mt(e,t),kt=({verbose:e},t)=>!["none","short"].includes(Mt(e,t)),Mt=(e,t)=>void 0===t?jt(e):It(e,t),jt=e=>e.find(e=>Nt(e))??Pt.findLast(t=>e.includes(t)),Nt=e=>"function"==typeof e,Pt=["none","short","full"],Rt=e=>k(e).split("\n").map(e=>Lt(e)).join("\n"),Lt=e=>e.replaceAll(Ft,e=>Bt(e)),Bt=e=>{const t=Ut[e];if(void 0!==t)return t;const n=e.codePointAt(0),r=n.toString(16);return n<=Ht?`\\u${r.padStart(4,"0")}`:`\\U${r}`},Ft=(()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}})(),Ut={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},Ht=65535,Wt=/^[\w./-]+$/,Gt={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"█",squareDarkShade:"▓",squareMediumShade:"▒",squareLightShade:"░",squareTop:"▀",squareBottom:"▄",squareLeft:"▌",squareRight:"▐",squareCenter:"■",bullet:"●",dot:"․",ellipsis:"…",pointerSmall:"›",triangleUp:"▲",triangleUpSmall:"▴",triangleDown:"▼",triangleDownSmall:"▾",triangleLeftSmall:"◂",triangleRightSmall:"▸",home:"⌂",heart:"♥",musicNote:"♪",musicNoteBeamed:"♫",arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",arrowLeftRight:"↔",arrowUpDown:"↕",almostEqual:"≈",notEqual:"≠",lessOrEqual:"≤",greaterOrEqual:"≥",identical:"≡",infinity:"∞",subscriptZero:"₀",subscriptOne:"₁",subscriptTwo:"₂",subscriptThree:"₃",subscriptFour:"₄",subscriptFive:"₅",subscriptSix:"₆",subscriptSeven:"₇",subscriptEight:"₈",subscriptNine:"₉",oneHalf:"½",oneThird:"⅓",oneQuarter:"¼",oneFifth:"⅕",oneSixth:"⅙",oneEighth:"⅛",twoThirds:"⅔",twoFifths:"⅖",threeQuarters:"¾",threeFifths:"⅗",threeEighths:"⅜",fourFifths:"⅘",fiveSixths:"⅚",fiveEighths:"⅝",sevenEighths:"⅞",line:"─",lineBold:"━",lineDouble:"═",lineDashed0:"┄",lineDashed1:"┅",lineDashed2:"┈",lineDashed3:"┉",lineDashed4:"╌",lineDashed5:"╍",lineDashed6:"╴",lineDashed7:"╶",lineDashed8:"╸",lineDashed9:"╺",lineDashed10:"╼",lineDashed11:"╾",lineDashed12:"−",lineDashed13:"–",lineDashed14:"‐",lineDashed15:"⁃",lineVertical:"│",lineVerticalBold:"┃",lineVerticalDouble:"║",lineVerticalDashed0:"┆",lineVerticalDashed1:"┇",lineVerticalDashed2:"┊",lineVerticalDashed3:"┋",lineVerticalDashed4:"╎",lineVerticalDashed5:"╏",lineVerticalDashed6:"╵",lineVerticalDashed7:"╷",lineVerticalDashed8:"╹",lineVerticalDashed9:"╻",lineVerticalDashed10:"╽",lineVerticalDashed11:"╿",lineDownLeft:"┐",lineDownLeftArc:"╮",lineDownBoldLeftBold:"┓",lineDownBoldLeft:"┒",lineDownLeftBold:"┑",lineDownDoubleLeftDouble:"╗",lineDownDoubleLeft:"╖",lineDownLeftDouble:"╕",lineDownRight:"┌",lineDownRightArc:"╭",lineDownBoldRightBold:"┏",lineDownBoldRight:"┎",lineDownRightBold:"┍",lineDownDoubleRightDouble:"╔",lineDownDoubleRight:"╓",lineDownRightDouble:"╒",lineUpLeft:"┘",lineUpLeftArc:"╯",lineUpBoldLeftBold:"┛",lineUpBoldLeft:"┚",lineUpLeftBold:"┙",lineUpDoubleLeftDouble:"╝",lineUpDoubleLeft:"╜",lineUpLeftDouble:"╛",lineUpRight:"└",lineUpRightArc:"╰",lineUpBoldRightBold:"┗",lineUpBoldRight:"┖",lineUpRightBold:"┕",lineUpDoubleRightDouble:"╚",lineUpDoubleRight:"╙",lineUpRightDouble:"╘",lineUpDownLeft:"┤",lineUpBoldDownBoldLeftBold:"┫",lineUpBoldDownBoldLeft:"┨",lineUpDownLeftBold:"┥",lineUpBoldDownLeftBold:"┩",lineUpDownBoldLeftBold:"┪",lineUpDownBoldLeft:"┧",lineUpBoldDownLeft:"┦",lineUpDoubleDownDoubleLeftDouble:"╣",lineUpDoubleDownDoubleLeft:"╢",lineUpDownLeftDouble:"╡",lineUpDownRight:"├",lineUpBoldDownBoldRightBold:"┣",lineUpBoldDownBoldRight:"┠",lineUpDownRightBold:"┝",lineUpBoldDownRightBold:"┡",lineUpDownBoldRightBold:"┢",lineUpDownBoldRight:"┟",lineUpBoldDownRight:"┞",lineUpDoubleDownDoubleRightDouble:"╠",lineUpDoubleDownDoubleRight:"╟",lineUpDownRightDouble:"╞",lineDownLeftRight:"┬",lineDownBoldLeftBoldRightBold:"┳",lineDownLeftBoldRightBold:"┯",lineDownBoldLeftRight:"┰",lineDownBoldLeftBoldRight:"┱",lineDownBoldLeftRightBold:"┲",lineDownLeftRightBold:"┮",lineDownLeftBoldRight:"┭",lineDownDoubleLeftDoubleRightDouble:"╦",lineDownDoubleLeftRight:"╥",lineDownLeftDoubleRightDouble:"╤",lineUpLeftRight:"┴",lineUpBoldLeftBoldRightBold:"┻",lineUpLeftBoldRightBold:"┷",lineUpBoldLeftRight:"┸",lineUpBoldLeftBoldRight:"┹",lineUpBoldLeftRightBold:"┺",lineUpLeftRightBold:"┶",lineUpLeftBoldRight:"┵",lineUpDoubleLeftDoubleRightDouble:"╩",lineUpDoubleLeftRight:"╨",lineUpLeftDoubleRightDouble:"╧",lineUpDownLeftRight:"┼",lineUpBoldDownBoldLeftBoldRightBold:"╋",lineUpDownBoldLeftBoldRightBold:"╈",lineUpBoldDownLeftBoldRightBold:"╇",lineUpBoldDownBoldLeftRightBold:"╊",lineUpBoldDownBoldLeftBoldRight:"╉",lineUpBoldDownLeftRight:"╀",lineUpDownBoldLeftRight:"╁",lineUpDownLeftBoldRight:"┽",lineUpDownLeftRightBold:"┾",lineUpBoldDownBoldLeftRight:"╂",lineUpDownLeftBoldRightBold:"┿",lineUpBoldDownLeftBoldRight:"╃",lineUpBoldDownLeftRightBold:"╄",lineUpDownBoldLeftBoldRight:"╅",lineUpDownBoldLeftRightBold:"╆",lineUpDoubleDownDoubleLeftDoubleRightDouble:"╬",lineUpDoubleDownDoubleLeftRight:"╫",lineUpDownLeftDoubleRightDouble:"╪",lineCross:"╳",lineBackslash:"╲",lineSlash:"╱"},Vt={...Gt,tick:"✔",info:"ℹ",warning:"⚠",cross:"✘",squareSmall:"◻",squareSmallFilled:"◼",circle:"◯",circleFilled:"◉",circleDotted:"◌",circleDouble:"◎",circleCircle:"ⓞ",circleCross:"ⓧ",circlePipe:"Ⓘ",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",checkboxCircleOn:"ⓧ",checkboxCircleOff:"Ⓘ",pointer:"❯",triangleUpOutline:"△",triangleLeft:"◀",triangleRight:"▶",lozenge:"◆",lozengeOutline:"◇",hamburger:"☰",smiley:"㋡",mustache:"෴",star:"★",play:"▶",nodejs:"⬢",oneSeventh:"⅐",oneNinth:"⅑",oneTenth:"⅒"},qt={...Gt,tick:"√",info:"i",warning:"‼",cross:"×",squareSmall:"□",squareSmallFilled:"■",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(○)",circleCross:"(×)",circlePipe:"(│)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[×]",checkboxOff:"[ ]",checkboxCircleOn:"(×)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"∆",triangleLeft:"◄",triangleRight:"►",lozenge:"♦",lozengeOutline:"◊",hamburger:"≡",smiley:"☺",mustache:"┌─┐",star:"✶",play:"►",nodejs:"♦",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},Kt=function(){const{env:e}=v,{TERM:t,TERM_PROGRAM:n}=e;return"win32"!==v.platform?"linux"!==t:Boolean(e.WT_SESSION)||Boolean(e.TERMINUS_SUBLIME)||"{cmd::Cmder}"===e.ConEmuTask||"Terminus-Sublime"===n||"vscode"===n||"xterm-256color"===t||"alacritty"===t||"rxvt-unicode"===t||"rxvt-unicode-256color"===t||"JetBrains-JediTerm"===e.TERMINAL_EMULATOR}()?Vt:qt,zt=L?.WriteStream?.prototype?.hasColors?.()??!1,Yt=(e,t)=>{if(!zt)return e=>e;const n=`[${e}m`,r=`[${t}m`;return e=>{const i=e+"";let o=i.indexOf(r);if(-1===o)return n+i+r;let s=n,a=0;const l=(22===t?r:"")+n;for(;-1!==o;)s+=i.slice(a,o)+l,a=o+r.length,o=i.indexOf(r,a);return s+=i.slice(a)+r,s}},Jt=Yt(1,22),Xt=Yt(90,39),Qt=Yt(91,39),Zt=Yt(93,39),en=(e,t)=>String(e).padStart(t,"0"),tn=({failed:e,reject:t})=>e?t?Kt.cross:Kt.warning:Kt.tick,nn={command:({piped:e})=>e?"|":"$",output:()=>" ",ipc:()=>"*",error:tn,duration:tn},rn=e=>e,on={command:()=>Jt,output:()=>rn,ipc:()=>rn,error:({reject:e})=>e?Qt:Zt,duration:()=>Xt},sn=(e,t,n)=>{if(void 0===n)return e;const r=n(e,t);return"string"==typeof r?r:void 0},an=e=>e.endsWith("\n")?e:`${e}\n`,ln=({type:e,verboseMessage:t,fdNumber:n,verboseInfo:r,result:i})=>{const o=cn({type:e,result:i,verboseInfo:r}),s=((e,t,n)=>{const r=(({verbose:e},t)=>{const n=Mt(e,t);return Nt(n)?n:void 0})(t,n);return e.map(({verboseLine:e,verboseObject:t})=>sn(e,t,r)).filter(e=>void 0!==e).map(e=>an(e)).join("")})(dn(t,o),r,n);""!==s&&console.warn(s.slice(0,-1))},cn=({type:e,result:t,verboseInfo:{escapedCommand:n,commandId:r,rawOptions:{piped:i=!1,...o}}})=>({type:e,escapedCommand:n,commandId:`${r}`,timestamp:new Date,piped:i,result:t,options:o}),dn=(e,t)=>e.split("\n").map(e=>un({...t,message:e})),un=e=>({verboseLine:(({type:e,message:t,timestamp:n,piped:r,commandId:i,result:{failed:o=!1}={},options:{reject:s=!0}})=>{const a=(e=>`${en(e.getHours(),2)}:${en(e.getMinutes(),2)}:${en(e.getSeconds(),2)}.${en(e.getMilliseconds(),3)}`)(n),l=nn[e]({failed:o,reject:s,piped:r}),c=on[e]({reject:s});return`${Xt(`[${a}]`)} ${Xt(`[${i}]`)} ${c(l)} ${c(t)}`})(e),verboseObject:e}),pn=e=>{const t="string"==typeof e?e:M(e);return Rt(t).replaceAll("\t"," ".repeat(mn))},mn=2,hn=e=>Dt({verbose:e})?fn++:void 0;let fn=0n;const gn=()=>S.bigint(),bn=e=>Number(S.bigint()-e)/1e6,wn=(e,t,n)=>{const r=gn(),{command:i,escapedCommand:o}=((e,t)=>{const n=[e,...t];return{command:n.join(" "),escapedCommand:n.map(e=>{return t=Lt(e),Wt.test(t)?t:"win32"===$?`"${t.replaceAll('"','""')}"`:`'${t.replaceAll("'","'\\''")}'`;var t}).join(" ")}})(e,t),s=((e,t,n)=>((e=>{for(const t of e){if(!1===t)throw new TypeError('The "verbose: false" option was renamed to "verbose: \'none\'".');if(!0===t)throw new TypeError('The "verbose: true" option was renamed to "verbose: \'short\'".');if(!Pt.includes(t)&&!Nt(t)){const e=Pt.map(e=>`'${e}'`).join(", ");throw new TypeError(`The "verbose" option must not be ${t}. Allowed values are: ${e} or a function.`)}}})(e),{verbose:e,escapedCommand:t,commandId:hn(e),rawOptions:n}))(wt(n,"verbose"),o,{...n});return((e,t)=>{Dt(t)&&ln({type:"command",verboseMessage:e,verboseInfo:t})})(o,s),{command:i,escapedCommand:o,startTime:r,verboseInfo:s}};var yn,vn,$n,Sn,En,xn={exports:{}};En="win32"===process.platform||ae.TESTING_WINDOWS?function(){if(vn)return yn;vn=1,yn=n,n.sync=function(n,r){return t(e.statSync(n),n,r)};var e=U;function t(e,t,n){return!(!e.isSymbolicLink()&&!e.isFile())&&function(e,t){var n=void 0!==t.pathExt?t.pathExt:process.env.PATHEXT;if(!n)return!0;if(-1!==(n=n.split(";")).indexOf(""))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}(t,n)}function n(n,r,i){e.stat(n,function(e,o){i(e,!e&&t(o,n,r))})}return yn}():function(){if(Sn)return $n;Sn=1,$n=t,t.sync=function(t,r){return n(e.statSync(t),r)};var e=U;function t(t,r,i){e.stat(t,function(e,t){i(e,!e&&n(t,r))})}function n(e,t){return e.isFile()&&function(e,t){var n=e.mode,r=e.uid,i=e.gid,o=void 0!==t.uid?t.uid:process.getuid&&process.getuid(),s=void 0!==t.gid?t.gid:process.getgid&&process.getgid(),a=parseInt("100",8),l=parseInt("010",8);return n&parseInt("001",8)||n&l&&i===s||n&a&&r===o||n&(a|l)&&0===o}(e,t)}return $n}();var On=Cn;function Cn(e,t,n){if("function"==typeof t&&(n=t,t={}),!n){if("function"!=typeof Promise)throw new TypeError("callback not provided");return new Promise(function(n,r){Cn(e,t||{},function(e,t){e?r(e):n(t)})})}En(e,t||{},function(e,r){e&&("EACCES"===e.code||t&&t.ignoreErrors)&&(e=null,r=!1),n(e,r)})}Cn.sync=function(e,t){try{return En.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||"EACCES"===e.code)return!1;throw e}};const _n="win32"===process.platform||"cygwin"===process.env.OSTYPE||"msys"===process.env.OSTYPE,Tn=F,An=_n?";":":",In=On,Dn=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),kn=(e,t)=>{const n=t.colon||An,r=e.match(/\//)||_n&&e.match(/\\/)?[""]:[..._n?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(n)],i=_n?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=_n?i.split(n):[""];return _n&&-1!==e.indexOf(".")&&""!==o[0]&&o.unshift(""),{pathEnv:r,pathExt:o,pathExtExe:i}},Mn=(e,t,n)=>{"function"==typeof t&&(n=t,t={}),t||(t={});const{pathEnv:r,pathExt:i,pathExtExe:o}=kn(e,t),s=[],a=n=>new Promise((i,o)=>{if(n===r.length)return t.all&&s.length?i(s):o(Dn(e));const a=r[n],c=/^".*"$/.test(a)?a.slice(1,-1):a,d=Tn.join(c,e),u=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;i(l(u,n,0))}),l=(e,n,r)=>new Promise((c,d)=>{if(r===i.length)return c(a(n+1));const u=i[r];In(e+u,{pathExt:o},(i,o)=>{if(!i&&o){if(!t.all)return c(e+u);s.push(e+u)}return c(l(e,n,r+1))})});return n?a(0).then(e=>n(null,e),n):a(0)};var jn=Mn;Mn.sync=(e,t)=>{t=t||{};const{pathEnv:n,pathExt:r,pathExtExe:i}=kn(e,t),o=[];for(let s=0;s<n.length;s++){const a=n[s],l=/^".*"$/.test(a)?a.slice(1,-1):a,c=Tn.join(l,e),d=!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+c:c;for(let e=0;e<r.length;e++){const n=d+r[e];try{if(In.sync(n,{pathExt:i})){if(!t.all)return n;o.push(n)}}catch(e){}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw Dn(e)};var Nn={exports:{}};const Pn=(e={})=>{const t=e.env||process.env;return"win32"!==(e.platform||process.platform)?"PATH":Object.keys(t).reverse().find(e=>"PATH"===e.toUpperCase())||"Path"};Nn.exports=Pn,Nn.exports.default=Pn;var Rn=Nn.exports;const Ln=F,Bn=jn,Fn=Rn;function Un(e,t){const n=e.options.env||process.env,r=process.cwd(),i=null!=e.options.cwd,o=i&&void 0!==process.chdir&&!process.chdir.disabled;if(o)try{process.chdir(e.options.cwd)}catch(e){}let s;try{s=Bn.sync(e.command,{path:n[Fn({env:n})],pathExt:t?Ln.delimiter:void 0})}catch(e){}finally{o&&process.chdir(r)}return s&&(s=Ln.resolve(i?e.options.cwd:"",s)),s}var Hn={};const Wn=/([()\][%!^"`<>&|;, *?])/g;Hn.command=function(e){return e.replace(Wn,"^$1")},Hn.argument=function(e,t){return e=(e=`"${e=(e=(e=`${e}`).replace(/(?=(\\+?)?)\1"/g,'$1$1\\"')).replace(/(?=(\\+?)?)\1$/,"$1$1")}"`).replace(Wn,"^$1"),t&&(e=e.replace(Wn,"^$1")),e};const Gn=/^#!(.*)/,Vn=U;const qn=F,Kn=function(e){return Un(e)||Un(e,!0)},zn=Hn,Yn=function(e){const t=Buffer.alloc(150);let n;try{n=Vn.openSync(e,"r"),Vn.readSync(n,t,0,150,0),Vn.closeSync(n)}catch(e){}return((e="")=>{const t=e.match(Gn);if(!t)return null;const[n,r]=t[0].replace(/#! ?/,"").split(" "),i=n.split("/").pop();return"env"===i?r:r?`${i} ${r}`:i})(t.toString())},Jn="win32"===process.platform,Xn=/\.(?:com|exe)$/i,Qn=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;const Zn="win32"===process.platform;function er(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function tr(e,t){return Zn&&1===e&&!t.file?er(t.original,"spawn"):null}var nr={hookChildProcess:function(e,t){if(!Zn)return;const n=e.emit;e.emit=function(r,i){if("exit"===r){const r=tr(i,t);if(r)return n.call(e,"error",r)}return n.apply(e,arguments)}},verifyENOENT:tr,verifyENOENTSync:function(e,t){return Zn&&1===e&&!t.file?er(t.original,"spawnSync"):null},notFoundError:er};const rr=_,ir=function(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null);const r={command:e,args:t=t?t.slice(0):[],options:n=Object.assign({},n),file:void 0,original:{command:e,args:t}};return n.shell?r:function(e){if(!Jn)return e;const t=function(e){e.file=Kn(e);const t=e.file&&Yn(e.file);return t?(e.args.unshift(e.file),e.command=t,Kn(e)):e.file}(e),n=!Xn.test(t);if(e.options.forceShell||n){const n=Qn.test(t);e.command=qn.normalize(e.command),e.command=zn.command(e.command),e.args=e.args.map(e=>zn.argument(e,n));const r=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${r}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}(r)},or=nr;function sr(e,t,n){const r=ir(e,t,n),i=rr.spawn(r.command,r.args,r.options);return or.hookChildProcess(i,r),i}xn.exports=sr,xn.exports.spawn=sr,xn.exports.sync=function(e,t,n){const r=ir(e,t,n),i=rr.spawnSync(r.command,r.args,r.options);return i.error=i.error||or.verifyENOENTSync(i.status,r),i},xn.exports._parse=ir,xn.exports._enoent=or;const ar=le(xn.exports);function lr(e={}){const{env:t=process.env,platform:n=process.platform}=e;return"win32"!==n?"PATH":Object.keys(t).reverse().find(e=>"PATH"===e.toUpperCase())||"Path"}const cr=({env:e=v.env,...t}={})=>{const n=lr({env:e={...e}});return t.path=e[n],e[n]=(({cwd:e=v.cwd(),path:t=v.env[lr()],preferLocal:n=!0,execPath:r=v.execPath,addExecPath:i=!0}={})=>{const o=u.resolve(H(e)),s=[],a=t.split(u.delimiter);return n&&((e,t,n)=>{for(const r of W(n)){const n=u.join(r,"node_modules/.bin");t.includes(n)||e.push(n)}})(s,a,o),i&&((e,t,n,r)=>{const i=u.resolve(r,H(n),"..");t.includes(i)||e.push(i)})(s,a,r,o),""===t||t===u.delimiter?`${s.join(u.delimiter)}${t}`:[...s,t].join(u.delimiter)})(t),e};class dr extends Error{}const ur=(e,t)=>{Object.defineProperty(e.prototype,"name",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,pr,{value:!0,writable:!1,enumerable:!1,configurable:!1})},pr=Symbol("isExecaError"),mr=e=>"[object Error]"===Object.prototype.toString.call(e);class hr extends Error{}ur(hr,hr.name);class fr extends Error{}ur(fr,fr.name);const gr=(e,t)=>({name:`SIGRT${t+1}`,number:br+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),br=34,wr=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}],yr=()=>{const e=(()=>{const e=64-br+1;return Array.from({length:e},gr)})();return[...wr,...e].map(vr)},vr=({name:e,number:t,description:n,action:r,forced:i=!1,standard:o})=>{const{signals:{[e]:s}}=K,a=void 0!==s;return{name:e,number:a?s:t,description:n,supported:a,action:r,forced:i,standard:o}},$r=({name:e,number:t,description:n,supported:r,action:i,forced:o,standard:s})=>[e,{name:e,number:t,description:n,supported:r,action:i,forced:o,standard:s}],Sr=(()=>{const e=yr();return Object.fromEntries(e.map($r))})(),Er=(e,t)=>{const n=t.find(({name:t})=>K.signals[t]===e);return void 0!==n?n:t.find(t=>t.number===e)};(()=>{const e=yr(),t=Array.from({length:65},(t,n)=>((e,t)=>{const n=Er(e,t);if(void 0===n)return{};const{name:r,description:i,supported:o,action:s,forced:a,standard:l}=n;return{[e]:{name:r,number:e,description:i,supported:o,action:s,forced:a,standard:l}}})(n,e));Object.assign({},...t)})();const xr=e=>0===e?e:Or(e,"`subprocess.kill()`'s argument"),Or=(e,t)=>{if(Number.isInteger(e))return Cr(e,t);if("string"==typeof e)return Tr(e,t);throw new TypeError(`Invalid ${t} ${String(e)}: it must be a string or an integer.\n${Ar()}`)},Cr=(e,t)=>{if(_r.has(e))return _r.get(e);throw new TypeError(`Invalid ${t} ${e}: this signal integer does not exist.\n${Ar()}`)},_r=new Map(Object.entries(K.signals).reverse().map(([e,t])=>[t,e])),Tr=(e,t)=>{if(e in K.signals)return e;if(e.toUpperCase()in K.signals)throw new TypeError(`Invalid ${t} '${e}': please rename it to '${e.toUpperCase()}'.`);throw new TypeError(`Invalid ${t} '${e}': this signal name does not exist.\n${Ar()}`)},Ar=()=>`Available signal names: ${Ir()}.\nAvailable signal numbers: ${Dr()}.`,Ir=()=>Object.keys(K.signals).sort().map(e=>`'${e}'`).join(", "),Dr=()=>[...new Set(Object.values(K.signals).sort((e,t)=>e-t))].join(", "),kr=e=>Sr[e].description,Mr=({kill:e,options:{forceKillAfterDelay:t,killSignal:n},onInternalError:r,context:i,controller:o},s,a)=>{const{signal:l,error:c}=jr(s,a,n);Nr(c,r);const d=e(l);return Pr({kill:e,signal:l,forceKillAfterDelay:t,killSignal:n,killResult:d,context:i,controller:o}),d},jr=(e,t,n)=>{const[r=n,i]=mr(e)?[void 0,e]:[e,t];if("string"!=typeof r&&!Number.isInteger(r))throw new TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(r)}`);if(void 0!==i&&!mr(i))throw new TypeError(`The second argument is optional. If specified, it must be an error instance: ${i}`);return{signal:xr(r),error:i}},Nr=(e,t)=>{void 0!==e&&t.reject(e)},Pr=async({kill:e,signal:t,forceKillAfterDelay:n,killSignal:r,killResult:i,context:o,controller:s})=>{t===r&&i&&Rr({kill:e,forceKillAfterDelay:n,context:o,controllerSignal:s.signal})},Rr=async({kill:e,forceKillAfterDelay:t,context:n,controllerSignal:r})=>{if(!1!==t)try{await G(t,void 0,{signal:r}),e("SIGKILL")&&(n.isForcefullyTerminated??=!0)}catch{}},Lr=async(e,t)=>{e.aborted||await n(e,"abort",{signal:t})},Br=({subprocess:e,cancelSignal:t,gracefulCancel:n,context:r,controller:i})=>void 0===t||n?[]:[Fr(e,t,r,i)],Fr=async(e,t,n,{signal:r})=>{throw await Lr(t,r),n.terminationReason??="cancel",e.kill(),t.reason},Ur=({methodName:e,isSubprocess:t,ipc:n,isConnected:r})=>{Hr(e,t,n),Wr(e,t,r)},Hr=(e,t,n)=>{if(!n)throw new Error(`${Kr(e,t)} can only be used if the \`ipc\` option is \`true\`.`)},Wr=(e,t,n)=>{if(!n)throw new Error(`${Kr(e,t)} cannot be used: the ${Yr(t)} has already exited or disconnected.`)},Gr=(e,t)=>new Error(`${Kr("sendMessage",t)} failed when sending an acknowledgment response to the ${Yr(t)}.`,{cause:e}),Vr=new Set(["ERR_MISSING_ARGS","ERR_INVALID_ARG_TYPE"]),qr=["could not be cloned","circular structure","call stack size exceeded"],Kr=(e,t,n="")=>"cancelSignal"===e?"`cancelSignal`'s `controller.abort()`":`${zr(t)}${e}(${n})`,zr=e=>e?"":"subprocess.",Yr=e=>e?"parent process":"subprocess",Jr=e=>{e.connected&&e.disconnect()},Xr=()=>{const e={},t=new Promise((t,n)=>{Object.assign(e,{resolve:t,reject:n})});return Object.assign(t,e)},Qr=(e,t="stdin")=>{const n=!0,{options:r,fileDescriptors:i}=ei.get(e),o=ti(i,t,n),s=e.stdio[o];if(null===s)throw new TypeError(ii(o,t,r,n));return s},Zr=(e,t="stdout")=>{const n=!1,{options:r,fileDescriptors:i}=ei.get(e),o=ti(i,t,n),s="all"===o?e.all:e.stdio[o];if(null==s)throw new TypeError(ii(o,t,r,n));return s},ei=new WeakMap,ti=(e,t,n)=>{const r=ni(t,n);return ri(r,t,n,e),r},ni=(e,t)=>{const n=Ot(e);if(void 0!==n)return n;const{validOptions:r,defaultValue:i}=t?{validOptions:'"stdin"',defaultValue:"stdin"}:{validOptions:'"stdout", "stderr", "all"',defaultValue:"stdout"};throw new TypeError(`"${ai(t)}" must not be "${e}".\nIt must be ${r} or "fd3", "fd4" (and so on).\nIt is optional and defaults to "${i}".`)},ri=(e,t,n,r)=>{const i=r[si(e)];if(void 0===i)throw new TypeError(`"${ai(n)}" must not be ${t}. That file descriptor does not exist.\nPlease set the "stdio" option to ensure that file descriptor exists.`);if("input"===i.direction&&!n)throw new TypeError(`"${ai(n)}" must not be ${t}. It must be a readable stream, not writable.`);if("input"!==i.direction&&n)throw new TypeError(`"${ai(n)}" must not be ${t}. It must be a writable stream, not readable.`)},ii=(e,t,n,r)=>{if("all"===e&&!n.all)return'The "all" option must be true to use "from: \'all\'".';const{optionName:i,optionValue:o}=oi(e,n);return`The "${i}: ${li(o)}" option is incompatible with using "${ai(r)}: ${li(t)}".\nPlease set this option with "pipe" instead.`},oi=(e,{stdin:t,stdout:n,stderr:r,stdio:i})=>{const o=si(e);return 0===o&&void 0!==t?{optionName:"stdin",optionValue:t}:1===o&&void 0!==n?{optionName:"stdout",optionValue:n}:2===o&&void 0!==r?{optionName:"stderr",optionValue:r}:{optionName:`stdio[${o}]`,optionValue:i[o]}},si=e=>"all"===e?1:e,ai=e=>e?"to":"from",li=e=>"string"==typeof e?`'${e}'`:"number"==typeof e?`${e}`:"Stream",ci=(e,t,n)=>{const i=e.getMaxListeners();0!==i&&i!==Number.POSITIVE_INFINITY&&(e.setMaxListeners(i+t),r(n,()=>{e.setMaxListeners(e.getMaxListeners()-t)}))},di=(e,t)=>{t&&ui(e)},ui=e=>{e.refCounted()},pi=(e,t)=>{t&&mi(e)},mi=e=>{e.unrefCounted()},hi=async({anyProcess:e,channel:t,isSubprocess:n,ipcEmitter:r},i)=>{if(xi(i)||Hi(i))return;gi.has(e)||gi.set(e,[]);const o=gi.get(e);if(o.push(i),!(o.length>1))for(;o.length>0;){await Ii(e,r,i),await V.yield();const s=await Ei({wrappedMessage:o[0],anyProcess:e,channel:t,isSubprocess:n,ipcEmitter:r});o.shift(),r.emit("message",s),r.emit("message:done")}},fi=async({anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i,boundOnMessage:o})=>{Gi();const s=gi.get(e);for(;s?.length>0;)await n(i,"message:done");e.removeListener("message",o),((e,t)=>{t&&(ui(e),ui(e))})(t,r),i.connected=!1,i.emit("disconnect")},gi=new WeakMap,bi=(e,t,n)=>{if(wi.has(e))return wi.get(e);const r=new i;return r.connected=!0,wi.set(e,r),yi({ipcEmitter:r,anyProcess:e,channel:t,isSubprocess:n}),r},wi=new WeakMap,yi=({ipcEmitter:e,anyProcess:t,channel:n,isSubprocess:r})=>{const i=hi.bind(void 0,{anyProcess:t,channel:n,isSubprocess:r,ipcEmitter:e});t.on("message",i),t.once("disconnect",fi.bind(void 0,{anyProcess:t,channel:n,isSubprocess:r,ipcEmitter:e,boundOnMessage:i})),((e,t)=>{t&&(mi(e),mi(e))})(n,r)},vi=e=>{const t=wi.get(e);return void 0===t?null!==e.channel:t.connected};let $i=0n;const Si=(e,t)=>{if(t?.type===Ti&&!t.hasListeners)for(const{id:t}of e)void 0!==t&&Ci[t].resolve({isDeadlock:!0,hasListeners:!1})},Ei=async({wrappedMessage:e,anyProcess:t,channel:n,isSubprocess:r,ipcEmitter:i})=>{if(e?.type!==Ti||!t.connected)return e;const{id:o,message:s}=e,a={id:o,type:Ai,message:ki(t,i)};try{await ji({anyProcess:t,channel:n,isSubprocess:r,ipc:!0},a)}catch(e){i.emit("strict:error",e)}return s},xi=e=>{if(e?.type!==Ai)return!1;const{id:t,message:n}=e;return Ci[t]?.resolve({isDeadlock:!1,hasListeners:n}),!0},Oi=async(e,t,n)=>{if(e?.type!==Ti)return;const r=Xr();Ci[e.id]=r;const i=new AbortController;try{const{isDeadlock:e,hasListeners:o}=await Promise.race([r,_i(t,n,i)]);e&&(e=>{throw new Error(`${Kr("sendMessage",e)} failed: the ${Yr(e)} is sending a message too, instead of listening to incoming messages.\nThis can be fixed by both sending a message and listening to incoming messages at the same time:\n\nconst [receivedMessage] = await Promise.all([\n\t${Kr("getOneMessage",e)},\n\t${Kr("sendMessage",e,"message, {strict: true}")},\n]);`)})(n),o||(e=>{throw new Error(`${Kr("sendMessage",e)} failed: the ${Yr(e)} is not listening to incoming messages.`)})(n)}finally{i.abort(),delete Ci[e.id]}},Ci={},_i=async(e,t,{signal:r})=>{ci(e,1,r),await n(e,"disconnect",{signal:r}),(e=>{throw new Error(`${Kr("sendMessage",e)} failed: the ${Yr(e)} exited without listening to incoming messages.`)})(t)},Ti="execa:ipc:request",Ai="execa:ipc:response",Ii=async(e,t,n)=>{for(;!ki(e,t)&&Di.get(e)?.size>0;){const t=[...Di.get(e)];Si(t,n),await Promise.all(t.map(({onMessageSent:e})=>e))}},Di=new WeakMap,ki=(e,t)=>t.listenerCount("message")>Mi(e),Mi=e=>ei.has(e)&&!It(ei.get(e).options.buffer,"ipc")?1:0,ji=({anyProcess:e,channel:t,isSubprocess:n,ipc:r},i,{strict:o=!1}={})=>{const s="sendMessage";return Ur({methodName:s,isSubprocess:n,ipc:r,isConnected:e.connected}),Ni({anyProcess:e,channel:t,methodName:s,isSubprocess:n,message:i,strict:o})},Ni=async({anyProcess:e,channel:t,methodName:n,isSubprocess:r,message:i,strict:o})=>{const s=(({anyProcess:e,channel:t,isSubprocess:n,message:r,strict:i})=>{if(!i)return r;const o=bi(e,t,n),s=ki(e,o);return{id:$i++,type:Ti,message:r,hasListeners:s}})({anyProcess:e,channel:t,isSubprocess:r,message:i,strict:o}),a=((e,t,n)=>{Di.has(e)||Di.set(e,new Set);const r=Di.get(e),i={onMessageSent:Xr(),id:n?t.id:void 0};return r.add(i),{outgoingMessages:r,outgoingMessage:i}})(e,s,o);try{await Pi({anyProcess:e,methodName:n,isSubprocess:r,wrappedMessage:s,message:i})}catch(t){throw Jr(e),t}finally{(({outgoingMessages:e,outgoingMessage:t})=>{e.delete(t),t.onMessageSent.resolve()})(a)}},Pi=async({anyProcess:e,methodName:t,isSubprocess:n,wrappedMessage:r,message:i})=>{const o=Ri(e);try{await Promise.all([Oi(r,e,n),o(r)])}catch(e){throw(({error:e,methodName:t,isSubprocess:n})=>{if("EPIPE"===e.code)throw new Error(`${Kr(t,n)} cannot be used: the ${Yr(n)} is disconnecting.`,{cause:e})})({error:e,methodName:t,isSubprocess:n}),(({error:e,methodName:t,isSubprocess:n,message:r})=>{if((({code:e,message:t})=>Vr.has(e)||qr.some(e=>t.includes(e)))(e))throw new Error(`${Kr(t,n)}'s argument type is invalid: the message cannot be serialized: ${String(r)}.`,{cause:e})})({error:e,methodName:t,isSubprocess:n,message:i}),e}},Ri=e=>{if(Li.has(e))return Li.get(e);const t=j(e.send.bind(e));return Li.set(e,t),t},Li=new WeakMap,Bi=async({anyProcess:e,channel:t,isSubprocess:n,ipc:r})=>(await Fi({anyProcess:e,channel:t,isSubprocess:n,ipc:r}),Vi.signal),Fi=async({anyProcess:e,channel:t,isSubprocess:n,ipc:r})=>{Ui||(Ui=!0,r?null!==t?(bi(e,t,n),await V.yield()):Gi():(()=>{throw new Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")})())};let Ui=!1;const Hi=e=>e?.type===Wi&&(Vi.abort(e.message),!0),Wi="execa:ipc:cancel",Gi=()=>{Vi.abort(new Error(`\`cancelSignal\` aborted: the ${Yr(!0)} disconnected.`))},Vi=new AbortController,qi=({subprocess:e,cancelSignal:t,gracefulCancel:n,forceKillAfterDelay:r,context:i,controller:o})=>n?[Ki({subprocess:e,cancelSignal:t,forceKillAfterDelay:r,context:i,controller:o})]:[],Ki=async({subprocess:e,cancelSignal:t,forceKillAfterDelay:n,context:r,controller:{signal:i}})=>{await Lr(t,i);const o=zi(t);throw await((e,t)=>{const n="cancelSignal";return Wr(n,!1,e.connected),Pi({anyProcess:e,methodName:n,isSubprocess:!1,wrappedMessage:{type:Wi,message:t},message:t})})(e,o),Rr({kill:e.kill,forceKillAfterDelay:n,context:r,controllerSignal:i}),r.terminationReason??="gracefulCancel",t.reason},zi=({reason:e})=>{if(!(e instanceof DOMException))return e;const t=new Error(e.message);return Object.defineProperty(t,"stack",{value:e.stack,enumerable:!1,configurable:!0,writable:!0}),t},Yi=(e,t,n,r)=>0===t||void 0===t?[]:[Ji(e,t,n,r)],Ji=async(e,t,n,{signal:r})=>{throw await G(t,void 0,{signal:r}),n.terminationReason??="timeout",e.kill(),new dr},Xi={advanced:e=>{try{z(e)}catch(e){throw new Error("The `ipcInput` option is not serializable with a structured clone.",{cause:e})}},json:e=>{try{JSON.stringify(e)}catch(e){throw new Error("The `ipcInput` option is not serializable with JSON.",{cause:e})}}},Qi=async(e,t)=>{void 0!==t&&await e.sendMessage(t)},Zi=new Set(["utf8","utf16le"]),eo=new Set(["buffer","hex","base64","base64url","latin1","ascii"]),to=new Set([...Zi,...eo]),no={"utf-8":"utf8","utf-16le":"utf16le","ucs-2":"utf16le",ucs2:"utf16le",binary:"latin1"},ro=e=>"string"==typeof e?`"${e}"`:String(e),io=()=>{try{return v.cwd()}catch(e){throw e.message=`The current directory does not exist.\n${e.message}`,e}},oo=(e,t,n)=>{n.cwd=((e=io())=>{const t=Ve(e,'The "cwd" option');return u.resolve(t)})(n.cwd);const[r,i,o]=((e,t,{node:n=!1,nodePath:r=E,nodeOptions:i=x.filter(e=>!e.startsWith("--inspect")),cwd:o,execPath:s,...a})=>{if(void 0!==s)throw new TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');const l=Ve(r,'The "nodePath" option'),c=u.resolve(o,l),d={...a,nodePath:c,node:n,cwd:o};if(!n)return[e,t,d];if("node"===u.basename(e,".exe"))throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');return[c,[...i,e,...t],{ipc:!0,...d,shell:!1}]})(e,t,n),{command:s,args:a,options:l}=ar._parse(r,i,o),c=(e=>{const t={...e};for(const n of At)t[n]=wt(e,n);return t})(l),d=so(c);return(({timeout:e})=>{if(void 0!==e&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)})(d),(({encoding:e})=>{if(to.has(e))return;const t=(e=>{if(null===e)return"buffer";if("string"!=typeof e)return;const t=e.toLowerCase();return t in no?no[t]:to.has(t)?t:void 0})(e);if(void 0!==t)throw new TypeError(`Invalid option \`encoding: ${ro(e)}\`.\nPlease rename it to ${ro(t)}.`);const n=[...to].map(e=>ro(e)).join(", ");throw new TypeError(`Invalid option \`encoding: ${ro(e)}\`.\nPlease rename it to one of: ${n}.`)})(d),(({ipcInput:e,ipc:t,serialization:n})=>{if(void 0!==e){if(!t)throw new Error("The `ipcInput` option cannot be set unless the `ipc` option is `true`.");Xi[n](e)}})(d),(({cancelSignal:e})=>{if(void 0!==e&&"[object AbortSignal]"!==Object.prototype.toString.call(e))throw new Error(`The \`cancelSignal\` option must be an AbortSignal: ${String(e)}`)})(d),(({gracefulCancel:e,cancelSignal:t,ipc:n,serialization:r})=>{if(e){if(void 0===t)throw new Error("The `cancelSignal` option must be defined when setting the `gracefulCancel` option.");if(!n)throw new Error("The `ipc` option cannot be false when setting the `gracefulCancel` option.");if("json"===r)throw new Error("The `serialization` option cannot be 'json' when setting the `gracefulCancel` option.")}})(d),d.shell=ze(d.shell),d.env=ao(d),d.killSignal=(e=>{const t="option `killSignal`";if(0===e)throw new TypeError(`Invalid ${t}: 0 cannot be used.`);return Or(e,t)})(d.killSignal),d.forceKillAfterDelay=(e=>{if(!1===e)return e;if(!0===e)return 5e3;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e})(d.forceKillAfterDelay),d.lines=d.lines.map((e,t)=>e&&!eo.has(d.encoding)&&d.buffer[t]),"win32"===v.platform&&"cmd"===u.basename(s,".exe")&&a.unshift("/q"),{file:s,commandArguments:a,options:d}},so=({extendEnv:e=!0,preferLocal:t=!1,cwd:n,localDir:r=n,encoding:i="utf8",reject:o=!0,cleanup:s=!0,all:a=!1,windowsHide:l=!0,killSignal:c="SIGTERM",forceKillAfterDelay:d=!0,gracefulCancel:u=!1,ipcInput:p,ipc:m=void 0!==p||u,serialization:h="advanced",...f})=>({...f,extendEnv:e,preferLocal:t,cwd:n,localDirectory:r,encoding:i,reject:o,cleanup:s,all:a,windowsHide:l,killSignal:c,forceKillAfterDelay:d,gracefulCancel:u,ipcInput:p,ipc:m,serialization:h}),ao=({env:e,extendEnv:t,preferLocal:n,node:r,localDirectory:i,nodePath:o})=>{const s=t?{...v.env,...e}:e;return n||r?cr({env:s,cwd:i,execPath:o,preferLocal:n,addExecPath:r}):s},lo=(e,t,n)=>n.shell&&t.length>0?[[e,...t].join(" "),[],n]:[e,t,n];function co(e){if("string"==typeof e)return uo(e);if(!ArrayBuffer.isView(e)||1!==e.BYTES_PER_ELEMENT)throw new Error("Input must be a string or a Uint8Array");return po(e)}const uo=e=>e.at(-1)===mo?e.slice(0,e.at(-2)===fo?-2:-1):e,po=e=>e.at(-1)===ho?e.subarray(0,e.at(-2)===go?-2:-1):e,mo="\n",ho=mo.codePointAt(0),fo="\r",go=fo.codePointAt(0);function bo(e,{checkOpen:t=!0}={}){return null!==e&&"object"==typeof e&&(e.writable||e.readable||!t||void 0===e.writable&&void 0===e.readable)&&"function"==typeof e.pipe}function wo(e,{checkOpen:t=!0}={}){return bo(e,{checkOpen:t})&&(e.writable||!t)&&"function"==typeof e.write&&"function"==typeof e.end&&"boolean"==typeof e.writable&&"boolean"==typeof e.writableObjectMode&&"function"==typeof e.destroy&&"boolean"==typeof e.destroyed}function yo(e,{checkOpen:t=!0}={}){return bo(e,{checkOpen:t})&&(e.readable||!t)&&"function"==typeof e.read&&"boolean"==typeof e.readable&&"boolean"==typeof e.readableObjectMode&&"function"==typeof e.destroy&&"boolean"==typeof e.destroyed}function vo(e,t){return wo(e,t)&&yo(e,t)}const $o=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype);class So{#e;#t;#n=!1;#r=void 0;constructor(e,t){this.#e=e,this.#t=t}next(){const e=()=>this.#i();return this.#r=this.#r?this.#r.then(e,e):e(),this.#r}return(e){const t=()=>this.#o(e);return this.#r?this.#r.then(t,t):t()}async#i(){if(this.#n)return{done:!0,value:void 0};let e;try{e=await this.#e.read()}catch(e){throw this.#r=void 0,this.#n=!0,this.#e.releaseLock(),e}return e.done&&(this.#r=void 0,this.#n=!0,this.#e.releaseLock()),e}async#o(e){if(this.#n)return{done:!0,value:e};if(this.#n=!0,!this.#t){const t=this.#e.cancel(e);return this.#e.releaseLock(),await t,{done:!0,value:e}}return this.#e.releaseLock(),{done:!0,value:e}}}const Eo=Symbol();function xo(){return this[Eo].next()}function Oo(e){return this[Eo].return(e)}Object.defineProperty(xo,"name",{value:"next"}),Object.defineProperty(Oo,"name",{value:"return"});const Co=Object.create($o,{next:{enumerable:!0,configurable:!0,writable:!0,value:xo},return:{enumerable:!0,configurable:!0,writable:!0,value:Oo}});function _o({preventCancel:e=!1}={}){const t=this.getReader(),n=new So(t,e),r=Object.create(Co);return r[Eo]=n,r}const To=e=>{if(yo(e,{checkOpen:!1})&&void 0!==ko.on)return Io(e);if("function"==typeof e?.[Symbol.asyncIterator])return e;if("[object ReadableStream]"===Ao.call(e))return _o.call(e);throw new TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.")},{toString:Ao}=Object.prototype,Io=async function*(e){const t=new AbortController,n={};Do(e,t,n);try{for await(const[n]of ko.on(e,"data",{signal:t.signal}))yield n}catch(e){if(void 0!==n.error)throw n.error;if(!t.signal.aborted)throw e}finally{e.destroy()}},Do=async(e,t,n)=>{try{await ko.finished(e,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(e){n.error=e}finally{t.abort()}},ko={},Mo=async(e,{init:t,convertChunk:n,getSize:r,truncateChunk:i,addChunk:o,getFinalChunk:s,finalize:a},{maxBuffer:l=Number.POSITIVE_INFINITY}={})=>{const c=To(e),d=t();d.length=0;try{for await(const e of c){const t=n[Ro(e)](e,d);No({convertedChunk:t,state:d,getSize:r,truncateChunk:i,addChunk:o,maxBuffer:l})}return jo({state:d,convertChunk:n,getSize:r,truncateChunk:i,addChunk:o,getFinalChunk:s,maxBuffer:l}),a(d)}catch(e){const t="object"==typeof e&&null!==e?e:new Error(e);throw t.bufferedData=a(d),t}},jo=({state:e,getSize:t,truncateChunk:n,addChunk:r,getFinalChunk:i,maxBuffer:o})=>{const s=i(e);void 0!==s&&No({convertedChunk:s,state:e,getSize:t,truncateChunk:n,addChunk:r,maxBuffer:o})},No=({convertedChunk:e,state:t,getSize:n,truncateChunk:r,addChunk:i,maxBuffer:o})=>{const s=n(e),a=t.length+s;if(a<=o)return void Po(e,t,i,a);const l=r(e,o-t.length);throw void 0!==l&&Po(l,t,i,o),new Bo},Po=(e,t,n,r)=>{t.contents=n(e,t,r),t.length=r},Ro=e=>{const t=typeof e;if("string"===t)return"string";if("object"!==t||null===e)return"others";if(globalThis.Buffer?.isBuffer(e))return"buffer";const n=Lo.call(e);return"[object ArrayBuffer]"===n?"arrayBuffer":"[object DataView]"===n?"dataView":Number.isInteger(e.byteLength)&&Number.isInteger(e.byteOffset)&&"[object ArrayBuffer]"===Lo.call(e.buffer)?"typedArray":"others"},{toString:Lo}=Object.prototype;class Bo extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}}const Fo=e=>e,Uo=()=>{},Ho=({contents:e})=>e,Wo=e=>{throw new Error(`Streams in object mode are not supported: ${String(e)}`)},Go=e=>e.length,Vo={init:()=>({contents:[]}),convertChunk:{string:Fo,buffer:Fo,arrayBuffer:Fo,dataView:Fo,typedArray:Fo,others:Fo},getSize:()=>1,truncateChunk:Uo,addChunk:(e,{contents:t})=>(t.push(e),t),getFinalChunk:Uo,finalize:Ho},qo=new TextEncoder,Ko=e=>new Uint8Array(e),zo=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Yo=e=>Jo**Math.ceil(Math.log(e)/Math.log(Jo)),Jo=2,Xo=()=>"resize"in ArrayBuffer.prototype,Qo={init:()=>({contents:new ArrayBuffer(0)}),convertChunk:{string:e=>qo.encode(e),buffer:Ko,arrayBuffer:Ko,dataView:zo,typedArray:zo,others:Wo},getSize:Go,truncateChunk:(e,t)=>e.slice(0,t),addChunk:(e,{contents:t,length:n},r)=>{const i=Xo()?((e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;const n=new ArrayBuffer(t,{maxByteLength:Yo(t)});return new Uint8Array(n).set(new Uint8Array(e),0),n})(t,r):((e,t)=>{if(t<=e.byteLength)return e;const n=new ArrayBuffer(Yo(t));return new Uint8Array(n).set(new Uint8Array(e),0),n})(t,r);return new Uint8Array(i).set(e,n),i},getFinalChunk:Uo,finalize:({contents:e,length:t})=>Xo()?e:e.slice(0,t)},Zo=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),es={init:()=>({contents:"",textDecoder:new TextDecoder}),convertChunk:{string:Fo,buffer:Zo,arrayBuffer:Zo,dataView:Zo,typedArray:Zo,others:Wo},getSize:Go,truncateChunk:(e,t)=>e.slice(0,t),addChunk:(e,{contents:t})=>t+e,getFinalChunk:({textDecoder:e})=>{const t=e.decode();return""===t?void 0:t},finalize:Ho},ts=(e,t,n)=>{if(t.length!==n)return;const r=new Bo;throw r.maxBufferInfo={fdNumber:"ipc"},r},ns=([,e])=>e,rs=({originalError:e,timedOut:t,timeout:n,isMaxBuffer:r,maxBuffer:i,errorCode:o,signal:s,signalDescription:a,exitCode:l,isCanceled:c,isGracefullyCanceled:d,isForcefullyTerminated:u,forceKillAfterDelay:p,killSignal:m})=>{const h=is(u,p);return t?`Command timed out after ${n} milliseconds${h}`:d?void 0===s?`Command was gracefully canceled with exit code ${l}`:u?`Command was gracefully canceled${h}`:`Command was gracefully canceled with ${s} (${a})`:c?`Command was canceled${h}`:r?`${((e,t)=>{const{streamName:n,threshold:r,unit:i}=((e,t)=>{if(void 0===e?.maxBufferInfo)return{streamName:"output",threshold:t[1],unit:"bytes"};const{maxBufferInfo:{fdNumber:n,unit:r}}=e;delete e.maxBufferInfo;const i=It(t,n);return"ipc"===n?{streamName:"IPC output",threshold:i,unit:"messages"}:{streamName:bt(n),threshold:i,unit:r}})(e,t);return`Command's ${n} was larger than ${r} ${i}`})(e,i)}${h}`:void 0!==o?`Command failed with ${o}${h}`:u?`Command was killed with ${m} (${kr(m)})${h}`:void 0!==s?`Command was killed with ${s} (${a})`:void 0!==l?`Command failed with exit code ${l}`:"Command failed"},is=(e,t)=>e?` and was forcefully terminated after ${t} milliseconds`:"",os=e=>"string"==typeof e?e:Xe(e)?nt(e):"",ss=({command:e,escapedCommand:t,stdio:n,all:r,ipcOutput:i,options:{cwd:o},startTime:s})=>ds({command:e,escapedCommand:t,cwd:o,durationMs:bn(s),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:n[1],stderr:n[2],all:r,stdio:n,ipcOutput:i,pipedFrom:[]}),as=({error:e,command:t,escapedCommand:n,fileDescriptors:r,options:i,startTime:o,isSync:s})=>ls({error:e,command:t,escapedCommand:n,startTime:o,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:r.length}),ipcOutput:[],options:i,isSync:s}),ls=({error:e,command:t,escapedCommand:n,startTime:r,timedOut:i,isCanceled:o,isGracefullyCanceled:s,isMaxBuffer:a,isForcefullyTerminated:l,exitCode:c,signal:d,stdio:u,all:p,ipcOutput:h,options:{timeoutDuration:f,timeout:g=f,forceKillAfterDelay:b,killSignal:w,cwd:y,maxBuffer:v},isSync:$})=>{const{exitCode:S,signal:E,signalDescription:x}=us(c,d),{originalMessage:O,shortMessage:C,message:_}=(({stdio:e,all:t,ipcOutput:n,originalError:r,signal:i,signalDescription:o,exitCode:s,escapedCommand:a,timedOut:l,isCanceled:c,isGracefullyCanceled:d,isMaxBuffer:u,isForcefullyTerminated:p,forceKillAfterDelay:h,killSignal:f,maxBuffer:g,timeout:b,cwd:w})=>{const y=r?.code,v=rs({originalError:r,timedOut:l,timeout:b,isMaxBuffer:u,maxBuffer:g,errorCode:y,signal:i,signalDescription:o,exitCode:s,isCanceled:c,isGracefullyCanceled:d,isForcefullyTerminated:p,forceKillAfterDelay:h,killSignal:f}),$=((e,t)=>{if(e instanceof dr)return;const n=(e=>mr(e)&&pr in e)(e)?e.originalMessage:String(e?.message??e),r=Rt(((e,t)=>{if(t===io())return e;let n;try{n=m(t)}catch(n){return`The "cwd" option is invalid: ${t}.\n${n.message}\n${e}`}return n.isDirectory()?e:`The "cwd" option is not a directory: ${t}.\n${e}`})(n,t));return""===r?void 0:r})(r,w),S=`${v}: ${a}${void 0===$?"":`\n${$}`}`,E=[S,...void 0===t?[e[2],e[1]]:[t],...e.slice(3),n.map(e=>(e=>"string"==typeof e?e:M(e))(e)).join("\n")].map(e=>Rt(co((e=>Array.isArray(e)?e.map(e=>co(os(e))).filter(Boolean).join("\n"):os(e))(e)))).filter(Boolean).join("\n\n");return{originalMessage:$,shortMessage:S,message:E}})({stdio:u,all:p,ipcOutput:h,originalError:e,signal:E,signalDescription:x,exitCode:S,escapedCommand:n,timedOut:i,isCanceled:o,isGracefullyCanceled:s,isMaxBuffer:a,isForcefullyTerminated:l,forceKillAfterDelay:b,killSignal:w,maxBuffer:v,timeout:g,cwd:y}),T=((e,t,n)=>new(n?fr:hr)(t,e instanceof dr?{}:{cause:e}))(e,_,$);return Object.assign(T,cs({error:T,command:t,escapedCommand:n,startTime:r,timedOut:i,isCanceled:o,isGracefullyCanceled:s,isMaxBuffer:a,isForcefullyTerminated:l,exitCode:S,signal:E,signalDescription:x,stdio:u,all:p,ipcOutput:h,cwd:y,originalMessage:O,shortMessage:C})),T},cs=({error:e,command:t,escapedCommand:n,startTime:r,timedOut:i,isCanceled:o,isGracefullyCanceled:s,isMaxBuffer:a,isForcefullyTerminated:l,exitCode:c,signal:d,signalDescription:u,stdio:p,all:m,ipcOutput:h,cwd:f,originalMessage:g,shortMessage:b})=>ds({shortMessage:b,originalMessage:g,command:t,escapedCommand:n,cwd:f,durationMs:bn(r),failed:!0,timedOut:i,isCanceled:o,isGracefullyCanceled:s,isTerminated:void 0!==d,isMaxBuffer:a,isForcefullyTerminated:l,exitCode:c,signal:d,signalDescription:u,code:e.cause?.code,stdout:p[1],stderr:p[2],all:m,stdio:p,ipcOutput:h,pipedFrom:[]}),ds=e=>Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e)),us=(e,t)=>{const n=null===t?void 0:t;return{exitCode:null===e?void 0:e,signal:n,signalDescription:void 0===n?void 0:kr(t)}},ps=e=>Number.isFinite(e)?e:0;function ms(e,t){const n="bigint"==typeof e;if(!n&&!Number.isFinite(e))throw new TypeError("Expected a finite number or bigint");const r=e<0?"-":"";e=e<0?-e:e,(t={...t}).colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let i=[];const o=(e,n,r,o)=>{if(0!==i.length&&t.colonNotation||!(e=>0===e||0n===e)(e)||t.colonNotation&&"m"===r){if(o??=String(e),t.colonNotation){const e=o.includes(".")?o.split(".")[0].length:o.length,t=i.length>0?2:1;o="0".repeat(Math.max(0,t-e))+o}else o+=t.verbose?" "+((e,t)=>1===t||1n===t?e:`${e}s`)(n,e):r;i.push(o)}},s=function(e){switch(typeof e){case"number":if(Number.isFinite(e))return function(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(ps(1e3*e)%1e3),nanoseconds:Math.trunc(ps(1e6*e)%1e3)}}(e);break;case"bigint":return function(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}(e)}throw new TypeError("Expected a finite number or bigint")}(e),a=BigInt(s.days);if(t.hideYearAndDays?o(24n*BigInt(a)+BigInt(s.hours),"hour","h"):(t.hideYear?o(a,"day","d"):(o(a/365n,"year","y"),o(a%365n,"day","d")),o(Number(s.hours),"hour","h")),o(Number(s.minutes),"minute","m"),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3&&!t.subSecondsAsDecimals){const e=Number(s.seconds),n=Number(s.milliseconds),r=Number(s.microseconds),i=Number(s.nanoseconds);if(o(e,"second","s"),t.formatSubMilliseconds)o(n,"millisecond","ms"),o(r,"microsecond","µs"),o(i,"nanosecond","ns");else{const e=n+r/1e3+i/1e6,s="number"==typeof t.millisecondsDecimalDigits?t.millisecondsDecimalDigits:0,a=e>=1?Math.round(e):Math.ceil(e),l=s?e.toFixed(s):a;o(Number.parseFloat(l),"millisecond","ms",l)}}else{const r=((e,t)=>{const n=Math.floor(e*10**t+1e-7);return(Math.round(n)/10**t).toFixed(t)})((n?Number(e%86400000n):e)/1e3%60,"number"==typeof t.secondsDecimalDigits?t.secondsDecimalDigits:1),i=t.keepDecimalsOnWholeSeconds?r:r.replace(/\.0+$/,"");o(Number.parseFloat(i),"second","s",i)}if(0===i.length)return r+"0"+(t.verbose?" milliseconds":"ms");const l=t.colonNotation?":":" ";return"number"==typeof t.unitCount&&(i=i.slice(0,Math.max(t.unitCount,1))),r+i.join(l)}const hs=(e,t)=>{const n=`(done in ${ms(e.durationMs)})`;ln({type:"duration",verboseMessage:n,verboseInfo:t,result:e})},fs=(e,t,{reject:n})=>{if(((e,t)=>{Dt(t)&&(((e,t)=>{e.failed&&ln({type:"error",verboseMessage:e.shortMessage,verboseInfo:t,result:e})})(e,t),hs(e,t))})(e,t),e.failed&&n)throw e;return e},gs=(e,t)=>Os(e)?"asyncGenerator":Cs(e)?"generator":Ts(e)?"fileUrl":As(e)?"filePath":Ns(e)?"webStream":bo(e,{checkOpen:!1})?"native":Xe(e)?"uint8Array":Rs(e)?"asyncIterable":Ls(e)?"iterable":Ps(e)?ys({},t):_s(e)?bs(e,t):"native",bs=(e,t)=>vo(e.transform,{checkOpen:!1})?ws(e,t):Ps(e.transform)?ys(e,t):Ss(e,t),ws=(e,t)=>(vs(e,t,"Duplex stream"),"duplex"),ys=(e,t)=>(vs(e,t,"web TransformStream"),"webTransform"),vs=({final:e,binary:t,objectMode:n},r,i)=>{$s(e,`${r}.final`,i),$s(t,`${r}.binary`,i),Es(n,`${r}.objectMode`)},$s=(e,t,n)=>{if(void 0!==e)throw new TypeError(`The \`${t}\` option can only be defined when using a generator, not a ${n}.`)},Ss=({transform:e,final:t,binary:n,objectMode:r},i)=>{if(void 0!==e&&!xs(e))throw new TypeError(`The \`${i}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(vo(t,{checkOpen:!1}))throw new TypeError(`The \`${i}.final\` option must not be a Duplex stream.`);if(Ps(t))throw new TypeError(`The \`${i}.final\` option must not be a web TransformStream.`);if(void 0!==t&&!xs(t))throw new TypeError(`The \`${i}.final\` option must be a generator.`);return Es(n,`${i}.binary`),Es(r,`${i}.objectMode`),Os(e)||Os(t)?"asyncGenerator":"generator"},Es=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw new TypeError(`The \`${t}\` option must use a boolean.`)},xs=e=>Os(e)||Cs(e),Os=e=>"[object AsyncGeneratorFunction]"===Object.prototype.toString.call(e),Cs=e=>"[object GeneratorFunction]"===Object.prototype.toString.call(e),_s=e=>Ge(e)&&(void 0!==e.transform||void 0!==e.final),Ts=e=>"[object URL]"===Object.prototype.toString.call(e),As=e=>Ge(e)&&Object.keys(e).length>0&&Object.keys(e).every(e=>Is.has(e))&&Ds(e.file),Is=new Set(["file","append"]),Ds=e=>"string"==typeof e,ks=new Set(["ipc","ignore","inherit","overlapped","pipe"]),Ms=e=>"[object ReadableStream]"===Object.prototype.toString.call(e),js=e=>"[object WritableStream]"===Object.prototype.toString.call(e),Ns=e=>Ms(e)||js(e),Ps=e=>Ms(e?.readable)&&js(e?.writable),Rs=e=>Bs(e)&&"function"==typeof e[Symbol.asyncIterator],Ls=e=>Bs(e)&&"function"==typeof e[Symbol.iterator],Bs=e=>"object"==typeof e&&null!==e,Fs=new Set(["generator","asyncGenerator","duplex","webTransform"]),Us=new Set(["fileUrl","filePath","fileNumber"]),Hs=new Set(["fileUrl","filePath"]),Ws=new Set([...Hs,"webStream","nodeStream"]),Gs=new Set(["webTransform","duplex"]),Vs={generator:"a generator",asyncGenerator:"an async generator",fileUrl:"a file URL",filePath:"a file path string",fileNumber:"a file descriptor number",webStream:"a web stream",nodeStream:"a Node.js stream",webTransform:"a web TransformStream",duplex:"a Duplex stream",native:"any value",iterable:"an iterable",asyncIterable:"an async iterable",string:"a string",uint8Array:"a Uint8Array"},qs=(e,t,n,r)=>"output"===r?Ks(e,t,n):zs(e,t,n),Ks=(e,t,n)=>{const r=0!==t&&n[t-1].value.readableObjectMode;return{writableObjectMode:r,readableObjectMode:e??r}},zs=(e,t,n)=>{const r=0===t?!0===e:n[t-1].value.readableObjectMode;return{writableObjectMode:r,readableObjectMode:t!==n.length-1&&(e??r)}},Ys=(e,t,n,{encoding:r})=>{const i=e.filter(({type:e})=>Fs.has(e)),o=Array.from({length:i.length});for(const[e,s]of Object.entries(i))o[e]=Js({stdioItem:s,index:Number(e),newTransforms:o,optionName:t,direction:n,encoding:r});return ea(o,n)},Js=({stdioItem:e,stdioItem:{type:t},index:n,newTransforms:r,optionName:i,direction:o,encoding:s})=>"duplex"===t?Xs({stdioItem:e,optionName:i}):"webTransform"===t?Qs({stdioItem:e,index:n,newTransforms:r,direction:o}):Zs({stdioItem:e,index:n,newTransforms:r,direction:o,encoding:s}),Xs=({stdioItem:e,stdioItem:{value:{transform:t,transform:{writableObjectMode:n,readableObjectMode:r},objectMode:i=r}},optionName:o})=>{if(i&&!r)throw new TypeError(`The \`${o}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!i&&r)throw new TypeError(`The \`${o}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...e,value:{transform:t,writableObjectMode:n,readableObjectMode:r}}},Qs=({stdioItem:e,stdioItem:{value:t},index:n,newTransforms:r,direction:i})=>{const{transform:o,objectMode:s}=Ge(t)?t:{transform:t},{writableObjectMode:a,readableObjectMode:l}=qs(s,n,r,i);return{...e,value:{transform:o,writableObjectMode:a,readableObjectMode:l}}},Zs=({stdioItem:e,stdioItem:{value:t},index:n,newTransforms:r,direction:i,encoding:o})=>{const{transform:s,final:a,binary:l=!1,preserveNewlines:c=!1,objectMode:d}=Ge(t)?t:{transform:t},u=l||eo.has(o),{writableObjectMode:p,readableObjectMode:m}=qs(d,n,r,i);return{...e,value:{transform:s,final:a,binary:u,preserveNewlines:c,writableObjectMode:p,readableObjectMode:m}}},ea=(e,t)=>"input"===t?e.reverse():e,ta=["input","output","output"],na=()=>{},ra=()=>"input",ia={generator:na,asyncGenerator:na,fileUrl:na,filePath:na,iterable:ra,asyncIterable:ra,uint8Array:ra,webStream:e=>js(e)?"output":"input",nodeStream:e=>yo(e,{checkOpen:!1})?wo(e,{checkOpen:!1})?void 0:"input":"output",webTransform:na,duplex:na,native(e){const t=oa(e);return void 0!==t?t:bo(e,{checkOpen:!1})?ia.nodeStream(e):void 0}},oa=e=>[0,v.stdin].includes(e)?"input":[1,2,v.stdout,v.stderr].includes(e)?"output":void 0,sa=e=>gt.some(t=>void 0!==e[t]),aa=(e,t)=>Array.isArray(e)?e.map(e=>aa(e,t)):null==e?t>=gt.length?"ignore":"pipe":e,la=e=>"pipe"===e||Array.isArray(e)&&e.every(e=>"pipe"===e),ca=({value:e,optionName:t,fdNumber:n,direction:r})=>{const i=da(e,n);if(void 0!==i){if("output"===r)return{type:"fileNumber",value:i,optionName:t};if(L.isatty(i))throw new TypeError(`The \`${t}: ${li(e)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:Qe(h(i)),optionName:t}}},da=(e,t)=>{if("inherit"===e)return t;if("number"==typeof e)return e;const n=ft.indexOf(e);return-1!==n?n:void 0},ua=(e,t,n)=>{const r=ft[e];if(void 0===r)throw new TypeError(`The \`${n}: ${t}\` option is invalid: no such standard stream.`);return r},pa=({input:e,inputFile:t},n)=>0===n?[...ma(e),...fa(t)]:[],ma=e=>void 0===e?[]:[{type:ha(e),value:e,optionName:"input"}],ha=e=>{if(yo(e,{checkOpen:!1}))return"nodeStream";if("string"==typeof e)return"string";if(Xe(e))return"uint8Array";throw new Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},fa=e=>void 0===e?[]:[{...ga(e),optionName:"inputFile"}],ga=e=>{if(Ts(e))return{type:"fileUrl",value:e};if(Ds(e))return{type:"filePath",value:{file:e}};throw new Error("The `inputFile` option must be a file path string or a file URL.")},ba=({otherStdioItems:e,type:t,value:n,optionName:r,direction:i})=>{const o=e.filter(e=>wa(e,n));if(0===o.length)return;const s=o.find(e=>e.direction!==i);return ya(s,r,t),"output"===i?o[0].stream:void 0},wa=({type:e,value:t},n)=>"filePath"===e?t.file===n.file:"fileUrl"===e?t.href===n.href:t===n,ya=(e,t,n)=>{if(void 0!==e)throw new TypeError(`The \`${e.optionName}\` and \`${t}\` options must not target ${Vs[n]} that is the same.`)},va=(e,t,n,r)=>{const i=(({stdio:e,ipc:t,buffer:n,...r},i,o)=>{const s=((e,t)=>{if(void 0===e)return gt.map(e=>t[e]);if(sa(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${gt.map(e=>`\`${e}\``).join(", ")}`);if("string"==typeof e)return[e,e,e];if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);const n=Math.max(e.length,gt.length);return Array.from({length:n},(t,n)=>e[n])})(e,r).map((e,t)=>aa(e,t));return o?((e,t,n)=>e.map((e,r)=>t[r]||0===r||kt(n,r)||!la(e)?e:"ignore"))(s,n,i):((e,t)=>t&&!e.includes("ipc")?[...e,"ipc"]:e)(s,t)})(t,n,r),o=i.map((e,n)=>$a({stdioOption:e,fdNumber:n,options:t,isSync:r})),s=Aa({initialFileDescriptors:o,addProperties:e,options:t,isSync:r});return t.stdio=s.map(({stdioItems:e})=>Ma(e)),s},$a=({stdioOption:e,fdNumber:t,options:n,isSync:r})=>{const i=bt(t),{stdioItems:o,isStdioArray:s}=Sa({stdioOption:e,fdNumber:t,options:n,optionName:i}),a=((e,t,n)=>{const r=e.map(e=>(({type:e,value:t},n)=>ta[n]??ia[e](t))(e,t));if(r.includes("input")&&r.includes("output"))throw new TypeError(`The \`${n}\` option must not be an array of both readable and writable values.`);return r.find(Boolean)??"output"})(o,t,i),l=o.map(e=>(({stdioItem:e,stdioItem:{type:t},isStdioArray:n,fdNumber:r,direction:i,isSync:o})=>n&&"native"===t?o?(({stdioItem:e,stdioItem:{value:t,optionName:n},fdNumber:r,direction:i})=>{const o=ca({value:t,optionName:n,fdNumber:r,direction:i});if(void 0!==o)return o;if(bo(t,{checkOpen:!1}))throw new TypeError(`The \`${n}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return e})({stdioItem:e,fdNumber:r,direction:i}):(({stdioItem:e,stdioItem:{value:t,optionName:n},fdNumber:r})=>"inherit"===t?{type:"nodeStream",value:ua(r,t,n),optionName:n}:"number"==typeof t?{type:"nodeStream",value:ua(t,t,n),optionName:n}:bo(t,{checkOpen:!1})?{type:"nodeStream",value:t,optionName:n}:e)({stdioItem:e,fdNumber:r}):e)({stdioItem:e,isStdioArray:s,fdNumber:t,direction:a,isSync:r})),c=((e,t,n,r)=>[...e.filter(({type:e})=>!Fs.has(e)),...Ys(e,t,n,r)])(l,i,a,n),d=((e,t)=>{const n=e.findLast(({type:e})=>Fs.has(e));return void 0!==n&&("input"===t?n.value.writableObjectMode:n.value.readableObjectMode)})(c,a);return Ta(c,d),{direction:a,objectMode:d,stdioItems:c}},Sa=({stdioOption:e,fdNumber:t,options:n,optionName:r})=>{const i=(e=>e.filter((t,n)=>e.every((e,r)=>t.value!==e.value||n>=r||"generator"===t.type||"asyncGenerator"===t.type)))([...(Array.isArray(e)?e:[e]).map(e=>Ea(e,r)),...pa(n,t)]),o=i.length>1;return xa(i,o,r),Ca(i),{stdioItems:i,isStdioArray:o}},Ea=(e,t)=>({type:gs(e,t),value:e,optionName:t}),xa=(e,t,n)=>{if(0===e.length)throw new TypeError(`The \`${n}\` option must not be an empty array.`);if(t)for(const{value:t,optionName:n}of e)if(Oa.has(t))throw new Error(`The \`${n}\` option must not include \`${t}\`.`)},Oa=new Set(["ignore","ipc"]),Ca=e=>{for(const t of e)_a(t)},_a=({type:e,value:t,optionName:n})=>{if((e=>Ts(e)&&"file:"!==e.protocol)(t))throw new TypeError(`The \`${n}: URL\` option must use the \`file:\` scheme.\nFor example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(((e,t)=>"native"===e&&"string"==typeof t&&!ks.has(t))(e,t))throw new TypeError(`The \`${n}: { file: '...' }\` option must be used instead of \`${n}: '...'\`.`)},Ta=(e,t)=>{if(!t)return;const n=e.find(({type:e})=>Us.has(e));if(void 0!==n)throw new TypeError(`The \`${n.optionName}\` option cannot use both files and transforms in objectMode.`)},Aa=({initialFileDescriptors:e,addProperties:t,options:n,isSync:r})=>{const i=[];try{for(const o of e)i.push(Ia({fileDescriptor:o,fileDescriptors:i,addProperties:t,options:n,isSync:r}));return i}catch(e){throw ka(i),e}},Ia=({fileDescriptor:{direction:e,objectMode:t,stdioItems:n},fileDescriptors:r,addProperties:i,options:o,isSync:s})=>{const a=n.map(t=>Da({stdioItem:t,addProperties:i,direction:e,options:o,fileDescriptors:r,isSync:s}));return{direction:e,objectMode:t,stdioItems:a}},Da=({stdioItem:e,addProperties:t,direction:n,options:r,fileDescriptors:i,isSync:o})=>{const s=(({stdioItem:{type:e,value:t,optionName:n},direction:r,fileDescriptors:i,isSync:o})=>{const s=((e,t)=>e.flatMap(({direction:e,stdioItems:n})=>n.filter(e=>e.type===t).map(t=>({...t,direction:e}))))(i,e);if(0!==s.length){if(!o)return Ws.has(e)?ba({otherStdioItems:s,type:e,value:t,optionName:n,direction:r}):void(Gs.has(e)&&(({otherStdioItems:e,type:t,value:n,optionName:r})=>{const i=e.find(({value:{transform:e}})=>e===n.transform);ya(i,r,t)})({otherStdioItems:s,type:e,value:t,optionName:n}));(({otherStdioItems:e,type:t,value:n,optionName:r,direction:i})=>{Hs.has(t)&&ba({otherStdioItems:e,type:t,value:n,optionName:r,direction:i})})({otherStdioItems:s,type:e,value:t,optionName:n,direction:r})}})({stdioItem:e,direction:n,fileDescriptors:i,isSync:o});return void 0!==s?{...e,stream:s}:{...e,...t[n][e.type](e,r)}},ka=e=>{for(const{stdioItems:t}of e)for(const{stream:e}of t)void 0===e||ht(e)||e.destroy()},Ma=e=>{if(e.length>1)return e.some(({value:e})=>"overlapped"===e)?"overlapped":"pipe";const[{type:t,value:n}]=e;return"native"===t?n:"pipe"},ja=({type:e,optionName:t})=>{Na(t,Vs[e])},Na=(e,t)=>{throw new TypeError(`The \`${e}\` option cannot be ${t} with synchronous methods.`)},Pa={generator(){},asyncGenerator:ja,webStream:ja,nodeStream:ja,webTransform:ja,duplex:ja,asyncIterable:ja,native:({optionName:e,value:t})=>("ipc"!==t&&"overlapped"!==t||Na(e,`"${t}"`),{})},Ra={input:{...Pa,fileUrl:({value:e})=>({contents:[Qe(h(e))]}),filePath:({value:{file:e}})=>({contents:[Qe(h(e))]}),fileNumber:ja,iterable:({value:e})=>({contents:[...e]}),string:({value:e})=>({contents:[e]}),uint8Array:({value:e})=>({contents:[e]})},output:{...Pa,fileUrl:({value:e})=>({path:e}),filePath:({value:{file:e,append:t}})=>({path:e,append:t}),fileNumber:({value:e})=>({path:e}),iterable:ja,string:ja,uint8Array:ja}},La=(e,{stripFinalNewline:t},n)=>Ba(t,n)&&void 0!==e&&!Array.isArray(e)?co(e):e,Ba=(e,t)=>"all"===t?e[1]||e[2]:e[t],Fa=(e,t,n,r)=>e||n?void 0:Wa(t,r),Ua=(e,t,n)=>n?e.flatMap(e=>Ha(e,t)):Ha(e,t),Ha=(e,t)=>{const{transform:n,final:r}=Wa(t,{});return[...n(e),...r()]},Wa=(e,t)=>(t.previousChunks="",{transform:Ga.bind(void 0,t,e),final:qa.bind(void 0,t)}),Ga=function*(e,t,n){if("string"!=typeof n)return void(yield n);let{previousChunks:r}=e,i=-1;for(let o=0;o<n.length;o+=1)if("\n"===n[o]){const s=Va(n,o,t,e);let a=n.slice(i+1,o+1-s);r.length>0&&(a=Ya(r,a),r=""),yield a,i=o}i!==n.length-1&&(r=Ya(r,n.slice(i+1))),e.previousChunks=r},Va=(e,t,n,r)=>n?0:(r.isWindowsNewline=0!==t&&"\r"===e[t-1],r.isWindowsNewline?2:1),qa=function*({previousChunks:e}){e.length>0&&(yield e)},Ka=({binary:e,preserveNewlines:t,readableObjectMode:n,state:r})=>e||t||n?void 0:{transform:za.bind(void 0,r)},za=function*({isWindowsNewline:e=!1},t){const{unixNewline:n,windowsNewline:r,LF:i,concatBytes:o}="string"==typeof t?Ja:Xa;if(t.at(-1)===i)return void(yield t);const s=e?r:n;yield o(t,s)},Ya=(e,t)=>`${e}${t}`,Ja={windowsNewline:"\r\n",unixNewline:"\n",LF:"\n",concatBytes:Ya},Xa={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:(e,t)=>{const n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}},Qa=(e,t)=>e?void 0:Za.bind(void 0,t),Za=function*(e,t){if("string"!=typeof t&&!Xe(t)&&!te.isBuffer(t))throw new TypeError(`The \`${e}\` option's transform must use "objectMode: true" to receive as input: ${typeof t}.`);yield t},el=(e,t)=>e?tl.bind(void 0,t):nl.bind(void 0,t),tl=function*(e,t){rl(e,t),yield t},nl=function*(e,t){if(rl(e,t),"string"!=typeof t&&!Xe(t))throw new TypeError(`The \`${e}\` option's function must yield a string or an Uint8Array, not ${typeof t}.`);yield t},rl=(e,t)=>{if(null==t)throw new TypeError(`The \`${e}\` option's function must not call \`yield ${t}\`.\nInstead, \`yield\` should either be called with a value, or not be called at all. For example:\n if (condition) { yield value; }`)},il=(e,t,n)=>{if(n)return;if(e)return{transform:ol.bind(void 0,new TextEncoder)};const r=new I(t);return{transform:sl.bind(void 0,r),final:al.bind(void 0,r)}},ol=function*(e,t){te.isBuffer(t)?yield Qe(t):"string"==typeof t?yield e.encode(t):yield t},sl=function*(e,t){yield Xe(t)?e.write(t):t},al=function*(e){const t=e.end();""!==t&&(yield t)},ll=N(async(e,t,n,r)=>{t.currentIterable=e(...n);try{for await(const e of t.currentIterable)r.push(e)}finally{delete t.currentIterable}}),cl=async function*(e,t,n){if(n===t.length)return void(yield e);const{transform:r=ml}=t[n];for await(const i of r(e))yield*cl(i,t,n+1)},dl=async function*(e){for(const[t,{final:n}]of Object.entries(e))yield*ul(n,Number(t),e)},ul=async function*(e,t,n){if(void 0!==e)for await(const r of e())yield*cl(r,n,t+1)},pl=N(async({currentIterable:e},t)=>{if(void 0===e){if(t)throw t}else await(t?e.throw(t):e.return())}),ml=function*(e){yield e},hl=(e,t,n,r)=>{try{for(const r of e(...t))n.push(r);r()}catch(e){r(e)}},fl=(e,t)=>[...t.flatMap(t=>[...gl(t,e,0)]),...bl(e)],gl=function*(e,t,n){if(n===t.length)return void(yield e);const{transform:r=yl}=t[n];for(const i of r(e))yield*gl(i,t,n+1)},bl=function*(e){for(const[t,{final:n}]of Object.entries(e))yield*wl(n,Number(t),e)},wl=function*(e,t,n){if(void 0!==e)for(const r of e())yield*gl(r,n,t+1)},yl=function*(e){yield e},vl=({value:e,value:{transform:t,final:n,writableObjectMode:r,readableObjectMode:i},optionName:o},{encoding:s})=>{const a={},l=Sl(e,s,o),c=Os(t),d=Os(n),u=c?ll.bind(void 0,cl,a):hl.bind(void 0,gl),p=c||d?ll.bind(void 0,dl,a):hl.bind(void 0,bl),m=c||d?pl.bind(void 0,a):void 0;return{stream:new Y({writableObjectMode:r,writableHighWaterMark:J(r),readableObjectMode:i,readableHighWaterMark:J(i),transform(e,t,n){u([e,l,0],this,n)},flush(e){p([l],this,e)},destroy:m})}},$l=(e,t,n,r)=>{const i=t.filter(({type:e})=>"generator"===e),o=r?i.reverse():i;for(const{value:t,optionName:r}of o){const i=Sl(t,n,r);e=fl(i,e)}return e},Sl=({transform:e,final:t,binary:n,writableObjectMode:r,readableObjectMode:i,preserveNewlines:o},s,a)=>{const l={};return[{transform:Qa(r,a)},il(n,s,r),Fa(n,o,r,l),{transform:e,final:t},{transform:el(i,a)},Ka({binary:n,preserveNewlines:o,readableObjectMode:i,state:l})].filter(Boolean)},El=(e,t,n)=>{const{stdioItems:r}=e[t],i=r.filter(({contents:e})=>void 0!==e);if(0===i.length)return;if(0!==t){const[{type:e,optionName:t}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${t}\`, can be ${Vs[e]} with synchronous methods.`)}const o=i.map(({contents:e})=>e).map(e=>xl(e,r));n.input=rt(o)},xl=(e,t)=>{const n=$l(e,t,"utf8",!0);return Ol(n),rt(n)},Ol=e=>{const t=e.find(e=>"string"!=typeof e&&!Xe(e));if(void 0!==t)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${t}.`)},Cl=({stdioItems:e,encoding:t,verboseInfo:n,fdNumber:r})=>"all"!==r&&kt(n,r)&&!eo.has(t)&&_l(r)&&(e.some(({type:e,value:t})=>"native"===e&&Tl.has(t))||e.every(({type:e})=>Fs.has(e))),_l=e=>1===e||2===e,Tl=new Set(["pipe","overlapped"]),Al=e=>e._readableState.pipes.length>0,Il=(e,t,n)=>{const r=pn(e);ln({type:"output",verboseMessage:r,fdNumber:t,verboseInfo:n})},Dl=(e,t,n,r)=>{try{return $l(e,t,n,!1)}catch(t){return r.error=t,e}},kl=({chunks:e,objectMode:t,encoding:n,lines:r,stripFinalNewline:i,fdNumber:o})=>{if(t)return{serializedResult:e};if("buffer"===n)return{serializedResult:rt(e)};const s=((e,t)=>((e,t)=>{if("utf8"===t&&e.every(e=>"string"==typeof e))return e;const n=new I(t),r=e.map(e=>"string"==typeof e?et(e):e).map(e=>n.write(e)),i=n.end();return""===i?r:[...r,i]})(e,t).join(""))(e,n);return r[o]?{serializedResult:s,finalResult:Ua(s,!i[o],t)}:{serializedResult:s}},Ml=({serializedResult:e,fdNumber:t,state:n,verboseInfo:r,encoding:i,stdioItems:o,objectMode:s})=>{if(!Cl({stdioItems:o,encoding:i,verboseInfo:r,fdNumber:t}))return;const a=Ua(e,!1,s);try{((e,t,n)=>{for(const r of e)Il(r,t,n)})(a,t,r)}catch(e){n.error??=e}},jl=(e,t,n)=>{for(const{path:r,append:i}of t.filter(({type:e})=>Us.has(e))){const t="string"==typeof r?r:r.toString();i||n.has(t)?f(r,e):(n.add(t),g(r,e))}},Nl=async e=>{try{return await n(e,"exit")}catch{return Nl(e)}},Pl=async e=>{const[t,n]=await e;if(!Rl(t,n)&&Ll(t,n))throw new dr;return[t,n]},Rl=(e,t)=>void 0===e&&void 0===t,Ll=(e,t)=>0!==e||null!==t,Bl=(e,t,n)=>void 0!==e?e:Ll(t,n)?new dr:void 0,Fl=e=>e.node&&!e.ipc?{...e,ipc:!1}:e,Ul=({ipc:e,ipcInput:t,detached:n,cancelSignal:r})=>{t&&Hl("ipcInput"),e&&Hl("ipc: true"),n&&Hl("detached: true"),r&&Hl("cancelSignal")},Hl=e=>{throw new TypeError(`The "${e}" option cannot be used with synchronous methods.`)},Wl=({file:e,commandArguments:t,options:n,command:r,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{const l=Gl({file:e,commandArguments:t,options:n,command:r,escapedCommand:i,fileDescriptors:s,startTime:a});if(l.failed)return l;const{resultError:c,exitCode:d,signal:u,timedOut:p,isMaxBuffer:m}=(({error:e,status:t,signal:n,output:r},{maxBuffer:i})=>{const o=Bl(e,t,n),s="ETIMEDOUT"===o?.code,a=((e,t,n)=>"ENOBUFS"===e?.code&&null!==t&&t.some(e=>null!==e&&e.length>ns(n)))(o,r,i);return{resultError:o,exitCode:t,signal:n,timedOut:s,isMaxBuffer:a}})(l,n),{output:h,error:f=c}=(({fileDescriptors:e,syncResult:{output:t},options:n,isMaxBuffer:r,verboseInfo:i})=>{if(null===t)return{output:Array.from({length:3})};const o={},s=new Set([]);return{output:t.map((t,a)=>(({result:e,fileDescriptors:t,fdNumber:n,state:r,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:l,lines:c,stripFinalNewline:d,maxBuffer:u})=>{if(null===e)return;const p=((e,t,n)=>{if(!t)return e;const r=ns(n);return e.length>r?e.slice(0,r):e})(e,o,u),m=Qe(p),{stdioItems:h,objectMode:f}=t[n],g=Dl([m],h,l,r),{serializedResult:b,finalResult:w=b}=kl({chunks:g,objectMode:f,encoding:l,lines:c,stripFinalNewline:d,fdNumber:n});Ml({serializedResult:b,fdNumber:n,state:r,verboseInfo:s,encoding:l,stdioItems:h,objectMode:f});const y=a[n]?w:void 0;try{return void 0===r.error&&jl(b,h,i),y}catch(e){return r.error=e,y}})({result:t,fileDescriptors:e,fdNumber:a,state:o,outputFiles:s,isMaxBuffer:r,verboseInfo:i},n)),...o}})({fileDescriptors:s,syncResult:l,options:n,isMaxBuffer:m,verboseInfo:o}),g=h.map((e,t)=>La(e,n,t)),b=La((([,e,t],n)=>{if(n.all)return void 0===e?t:void 0===t?e:Array.isArray(e)?Array.isArray(t)?[...e,...t]:[...e,La(t,n,"all")]:Array.isArray(t)?[La(e,n,"all"),...t]:Xe(e)&&Xe(t)?ot([e,t]):`${e}${t}`})(h,n),n,"all");return ql({error:f,exitCode:d,signal:u,timedOut:p,isMaxBuffer:m,stdio:g,all:b,options:n,command:r,escapedCommand:i,startTime:a})},Gl=({file:e,commandArguments:t,options:n,command:r,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{((e,t)=>{for(const n of(e=>new Set(Object.entries(e).filter(([,{direction:e}])=>"input"===e).map(([e])=>Number(e))))(e))El(e,n,t)})(o,n);const r=Vl(n);return c(...lo(e,t,r))}catch(e){return as({error:e,command:r,escapedCommand:i,fileDescriptors:o,options:n,startTime:s,isSync:!0})}},Vl=({encoding:e,maxBuffer:t,...n})=>({...n,encoding:"buffer",maxBuffer:ns(t)}),ql=({error:e,exitCode:t,signal:n,timedOut:r,isMaxBuffer:i,stdio:o,all:s,options:a,command:l,escapedCommand:c,startTime:d})=>void 0===e?ss({command:l,escapedCommand:c,stdio:o,all:s,ipcOutput:[],options:a,startTime:d}):ls({error:e,command:l,escapedCommand:c,timedOut:r,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:t,signal:n,stdio:o,all:s,ipcOutput:[],options:a,startTime:d,isSync:!0}),Kl=({anyProcess:e,channel:t,isSubprocess:n,ipc:r},{reference:i=!0,filter:o}={})=>(Ur({methodName:"getOneMessage",isSubprocess:n,ipc:r,isConnected:vi(e)}),zl({anyProcess:e,channel:t,isSubprocess:n,filter:o,reference:i})),zl=async({anyProcess:e,channel:t,isSubprocess:n,filter:r,reference:i})=>{di(t,i);const o=bi(e,t,n),s=new AbortController;try{return await Promise.race([Yl(o,r,s),Jl(o,n,s),Xl(o,n,s)])}catch(t){throw Jr(e),t}finally{s.abort(),pi(t,i)}},Yl=async(e,t,{signal:r})=>{if(void 0===t){const[t]=await n(e,"message",{signal:r});return t}for await(const[n]of o(e,"message",{signal:r}))if(t(n))return n},Jl=async(e,t,{signal:r})=>{await n(e,"disconnect",{signal:r}),(e=>{throw new Error(`${Kr("getOneMessage",e)} could not complete: the ${Yr(e)} exited or disconnected.`)})(t)},Xl=async(e,t,{signal:r})=>{const[i]=await n(e,"strict:error",{signal:r});throw Gr(i,t)},Ql=({anyProcess:e,channel:t,isSubprocess:n,ipc:r},{reference:i=!0}={})=>Zl({anyProcess:e,channel:t,isSubprocess:n,ipc:r,shouldAwait:!n,reference:i}),Zl=({anyProcess:e,channel:t,isSubprocess:n,ipc:r,shouldAwait:i,reference:o})=>{Ur({methodName:"getEachMessage",isSubprocess:n,ipc:r,isConnected:vi(e)}),di(t,o);const s=bi(e,t,n),a=new AbortController,l={};return ec(e,s,a),tc({ipcEmitter:s,isSubprocess:n,controller:a,state:l}),nc({anyProcess:e,channel:t,ipcEmitter:s,isSubprocess:n,shouldAwait:i,controller:a,state:l,reference:o})},ec=async(e,t,r)=>{try{await n(t,"disconnect",{signal:r.signal}),r.abort()}catch{}},tc=async({ipcEmitter:e,isSubprocess:t,controller:r,state:i})=>{try{const[o]=await n(e,"strict:error",{signal:r.signal});i.error=Gr(o,t),r.abort()}catch{}},nc=async function*({anyProcess:e,channel:t,ipcEmitter:n,isSubprocess:r,shouldAwait:i,controller:s,state:a,reference:l}){try{for await(const[e]of o(n,"message",{signal:s.signal}))rc(a),yield e}catch{rc(a)}finally{s.abort(),pi(t,l),r||Jr(e),i&&await e}},rc=({error:e})=>{if(e)throw e},ic=(e,t,n)=>({sendMessage:ji.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n}),getOneMessage:Kl.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n}),getEachMessage:Ql.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n})}),oc=()=>{const e=new ee;return e.end(),e},sc=()=>new Z({read(){}}),ac=()=>new Q({write(){}}),lc=()=>new X({read(){},write(){}}),cc=async(e,t,n)=>fs(e,t,n),dc=({type:e,optionName:t})=>{throw new TypeError(`The \`${t}\` option cannot be ${Vs[e]}.`)},uc={fileNumber:dc,generator:vl,asyncGenerator:vl,nodeStream:({value:e})=>({stream:e}),webTransform({value:{transform:e,writableObjectMode:t,readableObjectMode:n}}){const r=t||n;return{stream:X.fromWeb(e,{objectMode:r})}},duplex:({value:{transform:e}})=>({stream:e}),native(){}},pc={input:{...uc,fileUrl:({value:e})=>({stream:w(e)}),filePath:({value:{file:e}})=>({stream:w(e)}),webStream:({value:e})=>({stream:Z.fromWeb(e)}),iterable:({value:e})=>({stream:Z.from(e)}),asyncIterable:({value:e})=>({stream:Z.from(e)}),string:({value:e})=>({stream:Z.from(e)}),uint8Array:({value:e})=>({stream:Z.from(te.from(e))})},output:{...uc,fileUrl:({value:e})=>({stream:b(e)}),filePath:({value:{file:e,append:t}})=>({stream:b(e,t?{flags:"a"}:{})}),webStream:({value:e})=>({stream:Q.fromWeb(e)}),iterable:dc,asyncIterable:dc,string:dc,uint8Array:dc}};function mc(e){if(!Array.isArray(e))throw new TypeError(`Expected an array, got \`${typeof e}\`.`);for(const t of e)yc(t);const t=e.some(({readableObjectMode:e})=>e),n=hc(e,t),r=new fc({objectMode:t,writableHighWaterMark:n,readableHighWaterMark:n});for(const t of e)r.add(t);return r}const hc=(e,t)=>{if(0===e.length)return J(t);const n=e.filter(({readableObjectMode:e})=>e===t).map(({readableHighWaterMark:e})=>e);return Math.max(...n)};class fc extends ee{#s=new Set([]);#a=new Set([]);#l=new Set([]);#c;#d=Symbol("unpipe");#u=new WeakMap;add(e){if(yc(e),this.#s.has(e))return;this.#s.add(e),this.#c??=gc(this,this.#s,this.#d);const t=vc({passThroughStream:this,stream:e,streams:this.#s,ended:this.#a,aborted:this.#l,onFinished:this.#c,unpipeEvent:this.#d});this.#u.set(e,t),e.pipe(this,{end:!1})}async remove(e){if(yc(e),!this.#s.has(e))return!1;const t=this.#u.get(e);return void 0!==t&&(this.#u.delete(e),e.unpipe(this),await t,!0)}}const gc=async(e,t,n)=>{Ic(e,Dc);const r=new AbortController;try{await Promise.race([bc(e,r),wc(e,t,n,r)])}finally{r.abort(),Ic(e,-Dc)}},bc=async(e,{signal:t})=>{try{await ne(e,{signal:t,cleanup:!0})}catch(t){throw Oc(e,t),t}},wc=async(e,t,n,{signal:r})=>{for await(const[i]of o(e,"unpipe",{signal:r}))t.has(i)&&i.emit(n)},yc=e=>{if("function"!=typeof e?.pipe)throw new TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)},vc=async({passThroughStream:e,stream:t,streams:n,ended:r,aborted:i,onFinished:o,unpipeEvent:s})=>{Ic(e,kc);const a=new AbortController;try{await Promise.race([$c(o,t,a),Sc({passThroughStream:e,stream:t,streams:n,ended:r,aborted:i,controller:a}),Ec({stream:t,streams:n,ended:r,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Ic(e,-kc)}n.size>0&&n.size===r.size+i.size&&(0===r.size&&i.size>0?_c(e):xc(e))},$c=async(e,t,{signal:n})=>{try{await e,n.aborted||_c(t)}catch(e){n.aborted||Oc(t,e)}},Sc=async({passThroughStream:e,stream:t,streams:n,ended:r,aborted:i,controller:{signal:o}})=>{try{await ne(t,{signal:o,cleanup:!0,readable:!0,writable:!1}),n.has(t)&&r.add(t)}catch(r){if(o.aborted||!n.has(t))return;Cc(r)?i.add(t):Tc(e,r)}},Ec=async({stream:e,streams:t,ended:r,aborted:i,unpipeEvent:o,controller:{signal:s}})=>{if(await n(e,o,{signal:s}),!e.readable)return n(s,"abort",{signal:s});t.delete(e),r.delete(e),i.delete(e)},xc=e=>{e.writable&&e.end()},Oc=(e,t)=>{Cc(t)?_c(e):Tc(e,t)},Cc=e=>"ERR_STREAM_PREMATURE_CLOSE"===e?.code,_c=e=>{(e.readable||e.writable)&&e.destroy()},Tc=(e,t)=>{e.destroyed||(e.once("error",Ac),e.destroy(t))},Ac=()=>{},Ic=(e,t)=>{const n=e.getMaxListeners();0!==n&&n!==Number.POSITIVE_INFINITY&&e.setMaxListeners(n+t)},Dc=2,kc=1,Mc=(e,t)=>{e.pipe(t),jc(e,t),Pc(e,t)},jc=async(e,t)=>{if(!ht(e)&&!ht(t)){try{await ne(e,{cleanup:!0,readable:!0,writable:!1})}catch{}Nc(t)}},Nc=e=>{e.writable&&e.end()},Pc=async(e,t)=>{if(!ht(e)&&!ht(t)){try{await ne(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Rc(e)}},Rc=e=>{e.readable&&e.destroy()},Lc=(e,t,n,r)=>{"output"===n?Mc(e.stdio[r],t):Mc(t,e.stdio[r]);const i=Bc[r];void 0!==i&&(e[i]=t),e.stdio[r]=t},Bc=["stdin","stdout","stderr"],Fc=({subprocess:e,stream:t,direction:n,fdNumber:r,pipeGroups:i,controller:o})=>{if(void 0===t)return;Uc(t,o);const[s,a]="output"===n?[t,e.stdio[r]]:[e.stdio[r],t],l=i.get(s)??[];i.set(s,[...l,a])},Uc=(e,{signal:t})=>{ht(e)&&ci(e,Hc,t)},Hc=2,Wc=[];Wc.push("SIGHUP","SIGINT","SIGTERM"),"win32"!==process.platform&&Wc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),"linux"===process.platform&&Wc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const Gc=e=>!!e&&"object"==typeof e&&"function"==typeof e.removeListener&&"function"==typeof e.emit&&"function"==typeof e.reallyExit&&"function"==typeof e.listeners&&"function"==typeof e.kill&&"number"==typeof e.pid&&"function"==typeof e.on,Vc=Symbol.for("signal-exit emitter"),qc=globalThis,Kc=Object.defineProperty.bind(Object);class zc{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(qc[Vc])return qc[Vc];Kc(qc,Vc,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){const n=this.listeners[e],r=n.indexOf(t);-1!==r&&(0===r&&1===n.length?n.length=0:n.splice(r,1))}emit(e,t,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(const i of this.listeners[e])r=!0===i(t,n)||r;return"exit"===e&&(r=this.emit("afterExit",t,n)||r),r}}class Yc{}const Jc=globalThis.process,{onExit:Xc}=(Qc=Gc(Jc)?new class extends Yc{#p="win32"===Jc.platform?"SIGINT":"SIGHUP";#m=new zc;#h;#f;#g;#b={};#w=!1;constructor(e){super(),this.#h=e,this.#b={};for(const t of Wc)this.#b[t]=()=>{const n=this.#h.listeners(t);let{count:r}=this.#m;const i=e;if("object"==typeof i.__signal_exit_emitter__&&"number"==typeof i.__signal_exit_emitter__.count&&(r+=i.__signal_exit_emitter__.count),n.length===r){this.unload();const n=this.#m.emit("exit",null,t),r="SIGHUP"===t?this.#p:t;n||e.kill(e.pid,r)}};this.#g=e.reallyExit,this.#f=e.emit}onExit(e,t){if(!Gc(this.#h))return()=>{};!1===this.#w&&this.load();const n=t?.alwaysLast?"afterExit":"exit";return this.#m.on(n,e),()=>{this.#m.removeListener(n,e),0===this.#m.listeners.exit.length&&0===this.#m.listeners.afterExit.length&&this.unload()}}load(){if(!this.#w){this.#w=!0,this.#m.count+=1;for(const e of Wc)try{const t=this.#b[e];t&&this.#h.on(e,t)}catch(e){}this.#h.emit=(e,...t)=>this.#y(e,...t),this.#h.reallyExit=e=>this.#v(e)}}unload(){this.#w&&(this.#w=!1,Wc.forEach(e=>{const t=this.#b[e];if(!t)throw new Error("Listener not defined for signal: "+e);try{this.#h.removeListener(e,t)}catch(e){}}),this.#h.emit=this.#f,this.#h.reallyExit=this.#g,this.#m.count-=1)}#v(e){return Gc(this.#h)?(this.#h.exitCode=e||0,this.#m.emit("exit",this.#h.exitCode,null),this.#g.call(this.#h,this.#h.exitCode)):0}#y(e,...t){const n=this.#f;if("exit"===e&&Gc(this.#h)){"number"==typeof t[0]&&(this.#h.exitCode=t[0]);const r=n.call(this.#h,e,...t);return this.#m.emit("exit",this.#h.exitCode,null),r}return n.call(this.#h,e,...t)}}(Jc):new class extends Yc{onExit(){return()=>{}}load(){}unload(){}},{onExit:(e,t)=>Qc.onExit(e,t),load:()=>Qc.load(),unload:()=>Qc.unload()});var Qc;const Zc=(e,t,n,...r)=>{if(Array.isArray(n))return{destination:t(ed,e)(n,...r),pipeOptions:e};if("string"==typeof n||n instanceof URL||Ke(n)){if(Object.keys(e).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');const[i,o,s]=Ye(n,...r);return{destination:t(ed)(i,o,s),pipeOptions:s}}if(ei.has(n)){if(Object.keys(e).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:n,pipeOptions:r[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${n}`)},ed=({options:e})=>({options:{...e,stdin:"pipe",piped:!0}}),td=({error:e,fileDescriptors:t,sourceOptions:n,startTime:r})=>as({error:e,command:nd,escapedCommand:nd,fileDescriptors:t,options:n,startTime:r,isSync:!1}),nd="source.pipe(destination)",rd=async e=>{const[{status:t,reason:n,value:r=n},{status:i,reason:o,value:s=o}]=await e;if(s.pipedFrom.includes(r)||s.pipedFrom.push(r),"rejected"===i)throw s;if("rejected"===t)throw r;return s},id=new WeakMap,od=(e,t)=>void 0===e?[]:[sd(e,t)],sd=async(e,{sourceStream:t,mergedStream:n,fileDescriptors:r,sourceOptions:i,startTime:o})=>{await P(e,t),await n.remove(t);const s=new Error("Pipe canceled by `unpipeSignal` option.");throw td({error:s,fileDescriptors:r,sourceOptions:i,startTime:o})},ad=(e,...t)=>{if(Ge(t[0]))return ad.bind(void 0,{...e,boundOptions:{...e.boundOptions,...t[0]}});const{destination:n,...r}=(({source:e,sourcePromise:t,boundOptions:n,createNested:r},...i)=>{const o=gn(),{destination:s,destinationStream:a,destinationError:l,from:c,unpipeSignal:d}=((e,t,n)=>{try{const{destination:r,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Zc(e,t,...n);return{destination:r,destinationStream:Qr(r,o),from:i,unpipeSignal:s}}catch(e){return{destinationError:e}}})(n,r,i),{sourceStream:u,sourceError:p}=((e,t)=>{try{return{sourceStream:Zr(e,t)}}catch(e){return{sourceError:e}}})(e,c),{options:m,fileDescriptors:h}=ei.get(e);return{sourcePromise:t,sourceStream:u,sourceOptions:m,sourceError:p,destination:s,destinationStream:a,destinationError:l,unpipeSignal:d,fileDescriptors:h,startTime:o}})(e,...t),i=ld({...r,destination:n});return i.pipe=ad.bind(void 0,{...e,source:n,sourcePromise:i,boundOptions:{}}),i},ld=async({sourcePromise:e,sourceStream:t,sourceOptions:n,sourceError:r,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:l,startTime:c})=>{const d=cd(e,i);(({sourceStream:e,sourceError:t,destinationStream:n,destinationError:r,fileDescriptors:i,sourceOptions:o,startTime:s})=>{const a=(({sourceStream:e,sourceError:t,destinationStream:n,destinationError:r})=>void 0!==t&&void 0!==r?r:void 0!==r?(Rc(e),r):void 0!==t?(Nc(n),t):void 0)({sourceStream:e,sourceError:t,destinationStream:n,destinationError:r});if(void 0!==a)throw td({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})})({sourceStream:t,sourceError:r,destinationStream:o,destinationError:s,fileDescriptors:l,sourceOptions:n,startTime:c});const u=new AbortController;try{const e=((e,t,n)=>{const r=id.has(t)?((e,t)=>{const n=id.get(t);return n.add(e),n})(e,t):((e,t)=>{const n=mc([e]);return Mc(n,t),id.set(t,n),n})(e,t);return ci(e,2,n.signal),ci(t,1,n.signal),(async e=>{try{await ne(e,{cleanup:!0,readable:!1,writable:!0})}catch{}id.delete(e)})(t),r})(t,o,u);return await Promise.race([rd(d),...od(a,{sourceStream:t,mergedStream:e,sourceOptions:n,fileDescriptors:l,startTime:c})])}finally{u.abort()}},cd=(e,t)=>Promise.allSettled([e,t]),dd=({subprocessStdout:e,subprocess:t,binary:n,shouldEncode:r,encoding:i,preserveNewlines:o})=>{const s=new AbortController;return ud(t,s),hd({stream:e,controller:s,binary:n,shouldEncode:!e.readableObjectMode&&r,encoding:i,shouldSplit:!e.readableObjectMode,preserveNewlines:o})},ud=async(e,t)=>{try{await e}catch{}finally{t.abort()}},pd=({stream:e,onStreamEnd:t,lines:n,encoding:r,stripFinalNewline:i,allMixed:o})=>{const s=new AbortController;md(t,s,e);const a=e.readableObjectMode&&!o;return hd({stream:e,controller:s,binary:"buffer"===r,shouldEncode:!a,encoding:r,shouldSplit:!a&&n,preserveNewlines:!i})},md=async(e,t,n)=>{try{await e}catch{n.destroy()}finally{t.abort()}},hd=({stream:e,controller:t,binary:n,shouldEncode:r,encoding:i,shouldSplit:s,preserveNewlines:a})=>{const l=o(e,"data",{signal:t.signal,highWaterMark:gd,highWatermark:gd});return bd({onStdoutChunk:l,controller:t,binary:n,shouldEncode:r,encoding:i,shouldSplit:s,preserveNewlines:a})},fd=J(!0),gd=fd,bd=async function*({onStdoutChunk:e,controller:t,binary:n,shouldEncode:r,encoding:i,shouldSplit:o,preserveNewlines:s}){const a=wd({binary:n,shouldEncode:r,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(const[t]of e)yield*gl(t,a,0)}catch(e){if(!t.signal.aborted)throw e}finally{yield*bl(a)}},wd=({binary:e,shouldEncode:t,encoding:n,shouldSplit:r,preserveNewlines:i})=>[il(e,n,!t),Fa(e,i,!r,{})].filter(Boolean),yd=async({stream:e,onStreamEnd:t,fdNumber:n,encoding:r,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:l,verboseInfo:c,streamInfo:d})=>{const u=vd({stream:e,onStreamEnd:t,fdNumber:n,encoding:r,allMixed:a,verboseInfo:c,streamInfo:d});if(!i)return void await Promise.all([$d(e),u]);const p=Ba(l,n),m=pd({stream:e,onStreamEnd:t,lines:s,encoding:r,stripFinalNewline:p,allMixed:a}),[h]=await Promise.all([Sd({stream:e,iterable:m,fdNumber:n,encoding:r,maxBuffer:o,lines:s}),u]);return h},vd=async({stream:e,onStreamEnd:t,fdNumber:n,encoding:r,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Cl({stdioItems:s[n]?.stdioItems,encoding:r,verboseInfo:o,fdNumber:n}))return;const a=pd({stream:e,onStreamEnd:t,lines:!0,encoding:r,stripFinalNewline:!0,allMixed:i});await(async(e,t,n,r)=>{for await(const i of e)Al(t)||Il(i,n,r)})(a,e,n,o)},$d=async e=>{await q(),null===e.readableFlowing&&e.resume()},Sd=async({stream:e,stream:{readableObjectMode:t},iterable:n,fdNumber:r,encoding:i,maxBuffer:o,lines:s})=>{try{return t||s?await async function(e,t){return Mo(e,Vo,t)}(n,{maxBuffer:o}):"buffer"===i?new Uint8Array(await async function(e,t){return Mo(e,Qo,t)}(n,{maxBuffer:o})):await async function(e,t){return Mo(e,es,t)}(n,{maxBuffer:o})}catch(n){return xd((({error:e,stream:t,readableObjectMode:n,lines:r,encoding:i,fdNumber:o})=>{if(!(e instanceof Bo))throw e;if("all"===o)return e;const s=((e,t,n)=>e?"objects":t?"lines":"buffer"===n?"bytes":"characters")(n,r,i);throw e.maxBufferInfo={fdNumber:o,unit:s},t.destroy(),e})({error:n,stream:e,readableObjectMode:t,lines:s,encoding:i,fdNumber:r}))}},Ed=async e=>{try{return await e}catch(e){return xd(e)}},xd=({bufferedData:e})=>{return t=e,"[object ArrayBuffer]"===Je.call(t)?new Uint8Array(e):e;var t},Od=async(e,t,n,{isSameDirection:r,stopOnExit:i=!1}={})=>{const o=Cd(e,n),s=new AbortController;try{await Promise.race([...i?[n.exitPromise]:[],ne(e,{cleanup:!0,signal:s.signal})])}catch(e){o.stdinCleanedUp||Ad(e,t,n,r)}finally{s.abort()}},Cd=(e,{originalStreams:[t],subprocess:n})=>{const r={stdinCleanedUp:!1};return e===t&&_d(e,n,r),r},_d=(e,t,n)=>{const{_destroy:r}=e;e._destroy=(...i)=>{Td(t,n),r.call(e,...i)}},Td=({exitCode:e,signalCode:t},n)=>{null===e&&null===t||(n.stdinCleanedUp=!0)},Ad=(e,t,n,r)=>{if(!Id(e,t,n,r))throw e},Id=(e,t,n,r=!0)=>n.propagating?Md(e)||kd(e):(n.propagating=!0,Dd(n,t)===r?Md(e):kd(e)),Dd=({fileDescriptors:e},t)=>"all"!==t&&"input"===e[t].direction,kd=e=>"ERR_STREAM_PREMATURE_CLOSE"===e?.code,Md=e=>"EPIPE"===e?.code,jd=async({stream:e,fdNumber:t,encoding:n,buffer:r,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:l,streamInfo:c})=>{if(!e)return;const d=Od(e,t,c);if(Dd(c,t))return void await d;const[u]=await Promise.all([yd({stream:e,onStreamEnd:d,fdNumber:t,encoding:n,buffer:r,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:l,streamInfo:c}),d]);return u},Nd=({stdout:e,stderr:t,all:n},[,r,i])=>{const o=r||i;return o?r?i?{stream:n,buffer:o}:{stream:e,buffer:o}:{stream:t,buffer:o}:{stream:n,buffer:o}},Pd=({all:e,stdout:t,stderr:n})=>e&&t&&n&&t.readableObjectMode!==n.readableObjectMode,Rd=(e,t)=>{const n=pn(e);ln({type:"ipc",verboseMessage:n,fdNumber:"ipc",verboseInfo:t})},Ld=async(e,t)=>(await Promise.allSettled([e]),t),Bd=async({subprocess:e,options:{encoding:t,buffer:r,maxBuffer:i,lines:o,timeoutDuration:s,cancelSignal:a,gracefulCancel:l,forceKillAfterDelay:c,stripFinalNewline:d,ipc:u,ipcInput:p},context:m,verboseInfo:h,fileDescriptors:f,originalStreams:g,onInternalError:b,controller:w})=>{const y=(async(e,t)=>{const[r,i]=await(async e=>{const[t,r]=await Promise.allSettled([n(e,"spawn"),n(e,"exit")]);return"rejected"===t.status?[]:"rejected"===r.status?Nl(e):r.value})(e);return t.isForcefullyTerminated??=!1,[r,i]})(e,m),v={originalStreams:g,fileDescriptors:f,subprocess:e,exitPromise:y,propagating:!1},$=(({subprocess:e,encoding:t,buffer:n,maxBuffer:r,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>e.stdio.map((e,l)=>jd({stream:e,fdNumber:l,encoding:t,buffer:n[l],maxBuffer:r[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})))({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:o,stripFinalNewline:d,verboseInfo:h,streamInfo:v}),S=(({subprocess:e,encoding:t,buffer:n,maxBuffer:r,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>jd({...Nd(e,n),fdNumber:"all",encoding:t,maxBuffer:r[1]+r[2],lines:i[1]||i[2],allMixed:Pd(e),stripFinalNewline:o,verboseInfo:s,streamInfo:a}))({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:o,stripFinalNewline:d,verboseInfo:h,streamInfo:v}),E=[],x=(async({subprocess:e,buffer:t,maxBuffer:n,ipc:r,ipcOutput:i,verboseInfo:o})=>{if(!r)return i;const s=(e=>kt(e,"ipc"))(o),a=It(t,"ipc"),l=It(n,"ipc");for await(const t of Zl({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:r,shouldAwait:!1,reference:!0}))a&&(ts(0,i,l),i.push(t)),s&&Rd(t,o);return i})({subprocess:e,buffer:r,maxBuffer:i,ipc:u,ipcOutput:E,verboseInfo:h}),O=Fd(g,e,v),C=Ud(f,v);try{return await Promise.race([Promise.all([{},Pl(y),Promise.all($),S,x,Qi(e,p),...O,...C]),b,Hd(e,w),...Yi(e,s,m,w),...Br({subprocess:e,cancelSignal:a,gracefulCancel:l,context:m,controller:w}),...qi({subprocess:e,cancelSignal:a,gracefulCancel:l,forceKillAfterDelay:c,context:m,controller:w})])}catch(e){return m.terminationReason??="other",Promise.all([{error:e},y,Promise.all($.map(e=>Ed(e))),Ed(S),Ld(x,E),Promise.allSettled(O),Promise.allSettled(C)])}},Fd=(e,t,n)=>e.map((e,r)=>e===t.stdio[r]?void 0:Od(e,r,n)),Ud=(e,t)=>e.flatMap(({stdioItems:e},n)=>e.filter(({value:e,stream:t=e})=>bo(t,{checkOpen:!1})&&!ht(t)).map(({type:e,value:r,stream:i=r})=>Od(i,n,t,{isSameDirection:Fs.has(e),stopOnExit:"native"===e}))),Hd=async(e,{signal:t})=>{const[r]=await n(e,"error",{signal:t});throw r},Wd=(e,t,n)=>{const r=e[n];r.has(t)||r.set(t,[]);const i=r.get(t),o=Xr();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Gd=async({resolve:e,promises:t},n)=>{e();const[r]=await Promise.race([Promise.allSettled([!0,n]),Promise.all([!1,...t])]);return!r},Vd=async e=>{if(void 0!==e)try{await qd(e)}catch{}},qd=async e=>{await ne(e,{cleanup:!0,readable:!1,writable:!0})},Kd=async e=>{await ne(e,{cleanup:!0,readable:!0,writable:!1})},zd=async(e,t)=>{if(await e,t)throw t},Yd=(e,t,n)=>{n&&!kd(n)?e.destroy(n):t&&e.destroy()},Jd=({subprocess:e,concurrentStreams:t,encoding:n},{from:r,binary:i=!0,preserveNewlines:o=!0}={})=>{const s=i||eo.has(n),{subprocessStdout:a,waitReadableDestroy:l}=Xd(e,r,t),{readableEncoding:c,readableObjectMode:d,readableHighWaterMark:u}=Qd(a,s),{read:p,onStdoutDataDone:m}=Zd({subprocessStdout:a,subprocess:e,binary:s,encoding:n,preserveNewlines:o}),h=new Z({read:p,destroy:N(nu.bind(void 0,{subprocessStdout:a,subprocess:e,waitReadableDestroy:l})),highWaterMark:u,objectMode:d,encoding:c});return tu({subprocessStdout:a,onStdoutDataDone:m,readable:h,subprocess:e}),h},Xd=(e,t,n)=>{const r=Zr(e,t);return{subprocessStdout:r,waitReadableDestroy:Wd(n,r,"readableDestroy")}},Qd=({readableEncoding:e,readableObjectMode:t,readableHighWaterMark:n},r)=>r?{readableEncoding:e,readableObjectMode:t,readableHighWaterMark:n}:{readableEncoding:e,readableObjectMode:!0,readableHighWaterMark:fd},Zd=({subprocessStdout:e,subprocess:t,binary:n,encoding:r,preserveNewlines:i})=>{const o=Xr(),s=dd({subprocessStdout:e,subprocess:t,binary:n,shouldEncode:!n,encoding:r,preserveNewlines:i});return{read(){eu(this,s,o)},onStdoutDataDone:o}},eu=async(e,t,n)=>{try{const{value:r,done:i}=await t.next();i?n.resolve():e.push(r)}catch{}},tu=async({subprocessStdout:e,onStdoutDataDone:t,readable:n,subprocess:r,subprocessStdin:i})=>{try{await Kd(e),await r,await Vd(i),await t,n.readable&&n.push(null)}catch(e){await Vd(i),ru(n,e)}},nu=async({subprocessStdout:e,subprocess:t,waitReadableDestroy:n},r)=>{await Gd(n,t)&&(ru(e,r),await zd(t,r))},ru=(e,t)=>{Yd(e,e.readable,t)},iu=({subprocess:e,concurrentStreams:t},{to:n}={})=>{const{subprocessStdin:r,waitWritableFinal:i,waitWritableDestroy:o}=ou(e,n,t),s=new Q({...su(r,e,i),destroy:N(du.bind(void 0,{subprocessStdin:r,subprocess:e,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:r.writableHighWaterMark,objectMode:r.writableObjectMode});return cu(r,s),s},ou=(e,t,n)=>{const r=Qr(e,t);return{subprocessStdin:r,waitWritableFinal:Wd(n,r,"writableFinal"),waitWritableDestroy:Wd(n,r,"writableDestroy")}},su=(e,t,n)=>({write:au.bind(void 0,e),final:N(lu.bind(void 0,e,t,n))}),au=(e,t,n,r)=>{e.write(t,n)?r():e.once("drain",r)},lu=async(e,t,n)=>{await Gd(n,t)&&(e.writable&&e.end(),await t)},cu=async(e,t,n)=>{try{await qd(e),t.writable&&t.end()}catch(e){await(async e=>{if(void 0!==e)try{await Kd(e)}catch{}})(n),uu(t,e)}},du=async({subprocessStdin:e,subprocess:t,waitWritableFinal:n,waitWritableDestroy:r},i)=>{await Gd(n,t),await Gd(r,t)&&(uu(e,i),await zd(t,i))},uu=(e,t)=>{Yd(e,e.writable,t)},pu=({subprocess:e,concurrentStreams:t,encoding:n},{from:r,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{const a=o||eo.has(n),{subprocessStdout:l,waitReadableDestroy:c}=Xd(e,r,t),{subprocessStdin:d,waitWritableFinal:u,waitWritableDestroy:p}=ou(e,i,t),{readableEncoding:m,readableObjectMode:h,readableHighWaterMark:f}=Qd(l,a),{read:g,onStdoutDataDone:b}=Zd({subprocessStdout:l,subprocess:e,binary:a,encoding:n,preserveNewlines:s}),w=new X({read:g,...su(d,e,u),destroy:N(mu.bind(void 0,{subprocessStdout:l,subprocessStdin:d,subprocess:e,waitReadableDestroy:c,waitWritableFinal:u,waitWritableDestroy:p})),readableHighWaterMark:f,writableHighWaterMark:d.writableHighWaterMark,readableObjectMode:h,writableObjectMode:d.writableObjectMode,encoding:m});return tu({subprocessStdout:l,onStdoutDataDone:b,readable:w,subprocess:e,subprocessStdin:d}),cu(d,w,l),w},mu=async({subprocessStdout:e,subprocessStdin:t,subprocess:n,waitReadableDestroy:r,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([nu({subprocessStdout:e,subprocess:n,waitReadableDestroy:r},s),du({subprocessStdin:t,subprocess:n,waitWritableFinal:i,waitWritableDestroy:o},s)])},hu=(e,t,{from:n,binary:r=!1,preserveNewlines:i=!1}={})=>{const o=r||eo.has(t),s=Zr(e,n),a=dd({subprocessStdout:s,subprocess:e,binary:o,shouldEncode:!0,encoding:t,preserveNewlines:i});return fu(a,s,e)},fu=async function*(e,t,n){try{yield*e}finally{t.readable&&t.destroy(),await n}},gu=(e,{encoding:t})=>{const n={readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap};e.readable=Jd.bind(void 0,{subprocess:e,concurrentStreams:n,encoding:t}),e.writable=iu.bind(void 0,{subprocess:e,concurrentStreams:n}),e.duplex=pu.bind(void 0,{subprocess:e,concurrentStreams:n,encoding:t}),e.iterable=hu.bind(void 0,e,t),e[Symbol.asyncIterator]=hu.bind(void 0,e,t,{})},bu=(async()=>{})().constructor.prototype,wu=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(bu,e)]),yu=(e,t,n)=>{const{command:r,escapedCommand:i,startTime:o,verboseInfo:s}=wn(e,t,n),{file:a,commandArguments:l,options:c}=oo(e,t,n),d=vu(c),u=((e,t)=>va(pc,e,t,!1))(d,s);return{file:a,commandArguments:l,command:r,escapedCommand:i,startTime:o,verboseInfo:s,options:d,fileDescriptors:u}},vu=({timeout:e,signal:t,...n})=>{if(void 0!==t)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...n,timeoutDuration:e}},$u=({file:e,commandArguments:t,options:n,startTime:i,verboseInfo:o,command:a,escapedCommand:c,fileDescriptors:u})=>{let p;try{p=d(...lo(e,t,n))}catch(e){return(({error:e,command:t,escapedCommand:n,fileDescriptors:r,options:i,startTime:o,verboseInfo:s})=>{ka(r);const a=new l;((e,t)=>{const n=oc(),r=oc(),i=oc(),o=Array.from({length:t.length-3},oc),s=oc(),a=[n,r,i,...o];Object.assign(e,{stdin:n,stdout:r,stderr:i,all:s,stdio:a})})(a,r),Object.assign(a,{readable:sc,writable:ac,duplex:lc});const c=as({error:e,command:t,escapedCommand:n,fileDescriptors:r,options:i,startTime:o,isSync:!1});return{subprocess:a,promise:cc(c,s,i)}})({error:e,command:a,escapedCommand:c,fileDescriptors:u,options:n,startTime:i,verboseInfo:o})}const m=new AbortController;s(Number.POSITIVE_INFINITY,m.signal);const h=[...p.stdio];((e,t,n)=>{const r=new Map;for(const[i,{stdioItems:o,direction:s}]of Object.entries(t)){for(const{stream:t}of o.filter(({type:e})=>Fs.has(e)))Lc(e,t,s,i);for(const{stream:t}of o.filter(({type:e})=>!Fs.has(e)))Fc({subprocess:e,stream:t,direction:s,fdNumber:i,pipeGroups:r,controller:n})}for(const[e,t]of r.entries()){const n=1===t.length?t[0]:mc(t);Mc(n,e)}})(p,u,m),((e,{cleanup:t,detached:n},{signal:i})=>{if(!t||n)return;const o=Xc(()=>{e.kill()});r(i,()=>{o()})})(p,n,m);const f={},g=Xr();return p.kill=Mr.bind(void 0,{kill:p.kill.bind(p),options:n,onInternalError:g,context:f,controller:m}),p.all=(({stdout:e,stderr:t},{all:n})=>n&&(e||t)?mc([e,t].filter(Boolean)):void 0)(p,n),gu(p,n),((e,{ipc:t})=>{Object.assign(e,ic(e,!1,t))})(p,n),{subprocess:p,promise:Su({subprocess:p,options:n,startTime:i,verboseInfo:o,fileDescriptors:u,originalStreams:h,command:a,escapedCommand:c,context:f,onInternalError:g,controller:m})}},Su=async({subprocess:e,options:t,startTime:n,verboseInfo:r,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:l,onInternalError:c,controller:d})=>{const[u,[p,m],h,f,g]=await Bd({subprocess:e,options:t,context:l,verboseInfo:r,fileDescriptors:i,originalStreams:o,onInternalError:c,controller:d});d.abort(),c.resolve();const b=h.map((e,n)=>La(e,t,n)),w=La(f,t,"all"),y=Eu({errorInfo:u,exitCode:p,signal:m,stdio:b,all:w,ipcOutput:g,context:l,options:t,command:s,escapedCommand:a,startTime:n});return fs(y,r,t)},Eu=({errorInfo:e,exitCode:t,signal:n,stdio:r,all:i,ipcOutput:o,context:s,options:a,command:l,escapedCommand:c,startTime:d})=>"error"in e?ls({error:e.error,command:l,escapedCommand:c,timedOut:"timeout"===s.terminationReason,isCanceled:"cancel"===s.terminationReason||"gracefulCancel"===s.terminationReason,isGracefullyCanceled:"gracefulCancel"===s.terminationReason,isMaxBuffer:e.error instanceof Bo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:t,signal:n,stdio:r,all:i,ipcOutput:o,options:a,startTime:d,isSync:!1}):ss({command:l,escapedCommand:c,stdio:r,all:i,ipcOutput:o,options:a,startTime:d}),xu=(e,t)=>{const n=Object.fromEntries(Object.entries(t).map(([t,n])=>[t,Ou(t,e[t],n)]));return{...e,...n}},Ou=(e,t,n)=>Cu.has(e)&&Ge(t)&&Ge(n)?{...t,...n}:n,Cu=new Set(["env",...At]),_u=(e,t,n,r)=>{const i=(e,t,r)=>_u(e,t,n,r),o=(...o)=>Tu({mapArguments:e,deepOptions:n,boundOptions:t,setBoundExeca:r,createNested:i},...o);return void 0!==r&&r(o,i,t),o},Tu=({mapArguments:e,deepOptions:t={},boundOptions:n={},setBoundExeca:r,createNested:i},o,...s)=>{if(Ge(o))return i(e,xu(n,o),r);const{file:a,commandArguments:l,options:c,isSync:d}=Au({mapArguments:e,firstArgument:o,nextArguments:s,deepOptions:t,boundOptions:n});return d?((e,t,n)=>{const{file:r,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:l,options:c,fileDescriptors:d}=((e,t,n)=>{const{command:r,escapedCommand:i,startTime:o,verboseInfo:s}=wn(e,t,n),a=Fl(n),{file:l,commandArguments:c,options:d}=oo(e,t,a);Ul(d);const u=((e,t)=>va(Ra,e,t,!0))(d,s);return{file:l,commandArguments:c,command:r,escapedCommand:i,startTime:o,verboseInfo:s,options:d,fileDescriptors:u}})(e,t,n),u=Wl({file:r,commandArguments:i,options:c,command:o,escapedCommand:s,verboseInfo:l,fileDescriptors:d,startTime:a});return fs(u,l,c)})(a,l,c):((e,t,n,r)=>{const{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:l,verboseInfo:c,options:d,fileDescriptors:u}=yu(e,t,n),{subprocess:p,promise:m}=$u({file:i,commandArguments:o,options:d,startTime:l,verboseInfo:c,command:s,escapedCommand:a,fileDescriptors:u});return p.pipe=ad.bind(void 0,{source:p,sourcePromise:m,boundOptions:{},createNested:r}),((e,t)=>{for(const[n,r]of wu){const i=r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:i})}})(p,m),ei.set(p,{options:d,fileDescriptors:u}),p})(a,l,c,i)},Au=({mapArguments:e,firstArgument:t,nextArguments:n,deepOptions:r,boundOptions:i})=>{const o=(s=t,Array.isArray(s)&&Array.isArray(s.raw)?((e,t)=>{let n=[];for(const[r,i]of e.entries())n=at({templates:e,expressions:t,tokens:n,index:r,template:i});if(0===n.length)throw new TypeError("Template script must not be empty");const[r,...i]=n;return[r,i,{}]})(t,n):[t,...n]);var s;const[a,l,c]=Ye(...o),d=xu(xu(r,i),c),{file:u=a,commandArguments:p=l,options:m=d,isSync:h=!1}=e({file:a,commandArguments:l,options:d});return{file:u,commandArguments:p,options:m,isSync:h}},Iu=(e,t)=>{if(t.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${e} ${t}.`);const[n,...r]=Du(e);return{file:n,commandArguments:r}},Du=e=>{if("string"!=typeof e)throw new TypeError(`The command must be a string: ${String(e)}.`);const t=e.trim();if(""===t)return[];const n=[];for(const e of t.split(ku)){const t=n.at(-1);t&&t.endsWith("\\")?n[n.length-1]=`${t.slice(0,-1)} ${e}`:n.push(e)}return n},ku=/ +/g,Mu=({options:e})=>({...ju(e),isSync:!0}),ju=e=>({options:{...Nu(e),...e}}),Nu=({input:e,inputFile:t,stdio:n})=>void 0===e&&void 0===t&&void 0===n?{stdin:"inherit"}:{};_u(()=>({})),_u(()=>({isSync:!0})),_u(({file:e,commandArguments:t})=>Iu(e,t)),_u(({file:e,commandArguments:t})=>({...Iu(e,t),isSync:!0})),_u(({options:e})=>{if(!1===e.node)throw new TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...e,node:!0}}});const Pu=_u(({options:e})=>ju(e),{},{preferLocal:!0},(e,t,n)=>{e.sync=t(Mu,n),e.s=e.sync});(()=>{const e=v,t=!0,n=void 0!==v.channel;ic(e,t,n),Bi.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n})})();const Ru=(()=>{const e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),Lu=e=>12288===e||e>=65281&&e<=65376||e>=65504&&e<=65510,Bu=e=>8987===e||9001===e||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Fu=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Uu=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Hu=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Wu=/\t{1,1000}/y,Gu=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Vu=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,qu=/\p{M}+/gu,Ku={limit:1/0,ellipsis:""},zu=(e,t={},n={})=>{const r=t.limit??1/0,i=t.ellipsis??"",o=t?.ellipsisWidth??(i?zu(i,Ku,n).width:0),s=n.controlWidth??0,a=n.tabWidth??8,l=n.emojiWidth??2,c=n.regularWidth??1,d=n.wideWidth??2,u=[[Vu,c],[Fu,0],[Uu,s],[Wu,a],[Gu,l],[Hu,d]];let p=0,m=0,h=e.length,f=0,g=!1,b=h,w=Math.max(0,r-o),y=0,v=0,$=0,S=0;e:for(;;){if(v>y||m>=h&&m>p){const t=e.slice(y,v)||e.slice(p,m);f=0;for(const e of t.replaceAll(qu,"")){const t=e.codePointAt(0)||0;if(S=Lu(t)?2:Bu(t)?d:c,$+S>w&&(b=Math.min(b,Math.max(y,p)+f)),$+S>r){g=!0;break e}f+=e.length,$+=S}y=v=0}if(m>=h)break e;for(let t=0,n=u.length;t<n;t++){const[n,i]=u[t];if(n.lastIndex=m,n.test(e)){if(f=n===Hu?Ru(e.slice(m,n.lastIndex)):n===Gu?1:n.lastIndex-m,S=f*i,$+S>w&&(b=Math.min(b,m+Math.floor((w-$)/i))),$+S>r){g=!0;break e}$+=S,y=p,v=m,m=p=n.lastIndex;continue e}}m+=1}return{width:g?w:$,index:g?b:h,truncated:g,ellipsed:g&&r>=o}},Yu={limit:1/0,ellipsis:"",ellipsisWidth:0},Ju=(e,t={})=>zu(e,Yu,t).width,Xu="",Qu="]8;;",Zu=new RegExp(`(?:\\[(?<code>\\d+)m|\\${Qu}(?<uri>.*))`,"y"),ep=e=>e>=30&&e<=37||e>=90&&e<=97?39:e>=40&&e<=47||e>=100&&e<=107?49:1===e||2===e?22:3===e?23:4===e?24:7===e?27:8===e?28:9===e?29:0===e?0:void 0,tp=e=>`${Xu}[${e}m`,np=e=>`${Xu}${Qu}${e}`,rp=(e,t,n)=>{const r=t[Symbol.iterator]();let i=!1,o=!1,s=e.at(-1),a=void 0===s?0:Ju(s),l=r.next(),c=r.next(),d=0;for(;!l.done;){const s=l.value,u=Ju(s);a+u<=n?e[e.length-1]+=s:(e.push(s),a=0),s!==Xu&&""!==s||(i=!0,o=t.startsWith(Qu,d+1)),i?o?""===s&&(i=!1,o=!1):"m"===s&&(i=!1):(a+=u,a!==n||c.done||(e.push(""),a=0)),l=c,c=r.next(),d+=s.length}s=e.at(-1),!a&&void 0!==s&&s.length&&e.length>1&&(e[e.length-2]+=e.pop())},ip=/\r?\n/;function op(e,t,n){return String(e).normalize().split(ip).map(e=>((e,t,n={})=>{if(!1!==n.trim&&""===e.trim())return"";let r,i,o="";const s=e.split(" ");let a=[""],l=0;for(let e=0;e<s.length;e++){const r=s[e];if(!1!==n.trim){const e=a.at(-1)??"",t=e.trimStart();e.length!==t.length&&(a[a.length-1]=t,l=Ju(t))}0!==e&&(l>=t&&(!1===n.wordWrap||!1===n.trim)&&(a.push(""),l=0),(l||!1===n.trim)&&(a[a.length-1]+=" ",l++));const i=Ju(r);if(n.hard&&i>t){const e=t-l,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&a.push(""),rp(a,r,t),l=Ju(a.at(-1)??"");continue}if(l+i>t&&l&&i){if(!1===n.wordWrap&&l<t){rp(a,r,t),l=Ju(a.at(-1)??"");continue}a.push(""),l=0}l+i>t&&!1===n.wordWrap?(rp(a,r,t),l=Ju(a.at(-1)??"")):(a[a.length-1]+=r,l+=i)}!1!==n.trim&&(a=a.map(e=>(e=>{const t=e.split(" ");let n=t.length;for(;n&&!Ju(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")})(e)));const c=a.join("\n");let d=!1;for(let e=0;e<c.length;e++){const t=c[e];if(o+=t,d)d=!1;else if(d=t>="\ud800"&&t<="\udbff",d)continue;if(t===Xu||""===t){Zu.lastIndex=e+1;const t=Zu.exec(c),n=t?.groups;if(void 0!==n?.code){const e=Number.parseFloat(n.code);r=39===e?void 0:e}else void 0!==n?.uri&&(i=0===n.uri.length?void 0:n.uri)}if("\n"===c[e+1]){i&&(o+=np(""));const e=r?ep(r):void 0;r&&e&&(o+=tp(e))}else"\n"===t&&(r&&ep(r)&&(o+=tp(r)),i&&(o+=np(i)))}return o})(e,t,n)).join("\n")}const sp="[",ap={to:(e,t)=>t?`${sp}${t+1};${e+1}H`:`${sp}${e+1}G`,move(e,t){let n="";return e<0?n+=`${sp}${-e}D`:e>0&&(n+=`${sp}${e}C`),t<0?n+=`${sp}${-t}A`:t>0&&(n+=`${sp}${t}B`),n},up:(e=1)=>`${sp}${e}A`,down:(e=1)=>`${sp}${e}B`,forward:(e=1)=>`${sp}${e}C`,backward:(e=1)=>`${sp}${e}D`,nextLine:(e=1)=>`${sp}E`.repeat(e),prevLine:(e=1)=>`${sp}F`.repeat(e),left:`${sp}G`,hide:`${sp}?25l`,show:`${sp}?25h`,save:"7",restore:"8"},lp={screen:`${sp}2J`,up:(e=1)=>`${sp}1J`.repeat(e),down:(e=1)=>`${sp}J`.repeat(e),line:`${sp}2K`,lineEnd:`${sp}K`,lineStart:`${sp}1K`,lines(e){let t="";for(let n=0;n<e;n++)t+=this.line+(n<e-1?ap.up():"");return e&&(t+=ap.left),t}};var cp={cursor:ap,erase:lp};function dp(e,t,n){if(!n.some(e=>!e.disabled))return e;const r=e+t,i=Math.max(n.length-1,0),o=r<0?i:r>i?0:r;return n[o].disabled?dp(o,t<0?-1:1,n):o}const up={actions:new Set(["up","down","left","right","space","enter","cancel"]),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};function pp(e,t){if("string"==typeof e)return up.aliases.get(e)===t;for(const n of e)if(void 0!==n&&pp(n,t))return!0;return!1}const mp=globalThis.process.platform.startsWith("win"),hp=Symbol("clack:cancel");function fp(e,t){const n=e;n.isTTY&&n.setRawMode(t)}function gp({input:e=O,output:t=C,overwrite:n=!0,hideCursor:r=!0}={}){const i=re.createInterface({input:e,output:t,prompt:"",tabSize:1});re.emitKeypressEvents(e,i),e instanceof B&&e.isTTY&&e.setRawMode(!0);const o=(i,{name:s,sequence:a})=>{if(pp([String(i),s,a],"cancel"))return r&&t.write(cp.cursor.show),void process.exit(0);if(!n)return;const l="return"===s?0:-1,c="return"===s?-1:0;re.moveCursor(t,l,c,()=>{re.clearLine(t,1,()=>{e.once("keypress",o)})})};return r&&t.write(cp.cursor.hide),e.once("keypress",o),()=>{e.off("keypress",o),r&&t.write(cp.cursor.show),e instanceof B&&e.isTTY&&!mp&&e.setRawMode(!1),i.terminal=!1,i.close()}}const bp=e=>"columns"in e&&"number"==typeof e.columns?e.columns:80,wp=e=>"rows"in e&&"number"==typeof e.rows?e.rows:20;function yp(e,t,n,r=n,i=n,o){return op(t,bp(e??C)-n.length,{hard:!0,trim:!1}).split("\n").map((e,t,o)=>{const s=e;return 0===t?`${r}${s}`:t===o.length-1?`${i}${s}`:`${n}${s}`}).join("\n")}let vp=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,t=!0){const{input:n=O,output:r=C,render:i,signal:o,...s}=e;this.opts=s,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=o,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){const n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){const n=this._subscribers.get(e)??[],r=[];for(const e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(const e of r)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(hp);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=ie.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),void 0!==this.opts.initialUserInput&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),fp(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(cp.cursor.show),this.output.off("resize",this.render),fp(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(cp.cursor.show),this.output.off("resize",this.render),fp(this.input,!1),e(hp)})})}_isActionKey(e,t){return"\t"===e}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,t){if(this._track&&"return"!==t.name&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),"error"===this.state&&(this.state="active"),t?.name&&(!this._track&&up.aliases.has(t.name)&&this.emit("cursor",up.aliases.get(t.name)),up.actions.has(t.name)&&this.emit("cursor",t.name)),e&&("y"===e.toLowerCase()||"n"===e.toLowerCase())&&this.emit("confirm","y"===e.toLowerCase()),this.emit("key",e?.toLowerCase(),t),"return"===t?.name&&this._shouldSubmit(e,t)){if(this.opts.validate){const e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state="error",this.rl?.write(this.userInput))}"error"!==this.state&&(this.state="submit")}pp([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),("submit"===this.state||"cancel"===this.state)&&this.emit("finalize"),this.render(),("submit"===this.state||"cancel"===this.state)&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write("\n"),fp(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const e=op(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split("\n").length-1;this.output.write(cp.cursor.move(-999,-1*e))}render(){const e=op(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if("initial"===this.state)this.output.write(cp.cursor.hide);else{const t=function(e,t){if(e===t)return;const n=e.split("\n"),r=t.split("\n"),i=Math.max(n.length,r.length),o=[];for(let e=0;e<i;e++)n[e]!==r[e]&&o.push(e);return{lines:o,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}(this._prevFrame,e),n=wp(this.output);if(this.restoreCursor(),t){const r=Math.max(0,t.numLinesAfter-n),i=Math.max(0,t.numLinesBefore-n);let o=t.lines.find(e=>e>=r);if(void 0===o)return void(this._prevFrame=e);if(1===t.lines.length){this.output.write(cp.cursor.move(0,o-i)),this.output.write(cp.erase.lines(1));const t=e.split("\n");return this.output.write(t[o]),this._prevFrame=e,void this.output.write(cp.cursor.move(0,t.length-o-1))}if(t.lines.length>1){if(r<i)o=r;else{const e=o-i;e>0&&this.output.write(cp.cursor.move(0,e))}this.output.write(cp.erase.down());const t=e.split("\n").slice(o);return this.output.write(t.join("\n")),void(this._prevFrame=e)}}this.output.write(cp.erase.down())}this.output.write(e),"initial"===this.state&&(this.state="active"),this._prevFrame=e}}};class $p extends vp{get cursor(){return this.value?0:1}get _value(){return 0===this.cursor}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",e=>{this.output.write(cp.cursor.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}let Sp=class extends vp{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(e=>!0!==e.disabled)}toggleAll(){const e=this._enabledOptions,t=void 0!==this.value&&this.value.length===e.length;this.value=t?[]:e.map(e=>e.value)}toggleInvert(){const e=this.value;if(!e)return;const t=this._enabledOptions.filter(t=>!e.includes(t.value));this.value=t.map(e=>e.value)}toggleValue(){void 0===this.value&&(this.value=[]);const e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}constructor(e){super(e,!1),this.options=e.options,this.value=[...e.initialValues??[]];const t=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0);this.cursor=this.options[t].disabled?dp(t,1,this.options):t,this.on("key",e=>{"a"===e&&this.toggleAll(),"i"===e&&this.toggleInvert()}),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=dp(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=dp(this.cursor,1,this.options);break;case"space":this.toggleValue()}})}},Ep=class extends vp{_mask="•";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if("submit"===this.state||"cancel"===this.state)return this.masked;const e=this.userInput;if(this.cursor>=e.length)return`${this.masked}${R(["inverse","hidden"],"_")}`;const t=this.masked,n=t.slice(0,this.cursor),r=t.slice(this.cursor);return`${n}${R("inverse",r[0])}${r.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:e,...t}){super(t),this._mask=e??"•",this.on("userInput",e=>{this._setValue(e)})}},xp=class extends vp{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(e){super(e,!1),this.options=e.options;const t=this.options.findIndex(({value:t})=>t===e.initialValue),n=-1===t?0:t;this.cursor=this.options[n].disabled?dp(n,1,this.options):n,this.changeValue(),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=dp(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=dp(this.cursor,1,this.options)}this.changeValue()})}};const Op="win32"!==v.platform?"linux"!==v.env.TERM:!!v.env.CI||!!v.env.WT_SESSION||!!v.env.TERMINUS_SUBLIME||"{cmd::Cmder}"===v.env.ConEmuTask||"Terminus-Sublime"===v.env.TERM_PROGRAM||"vscode"===v.env.TERM_PROGRAM||"xterm-256color"===v.env.TERM||"alacritty"===v.env.TERM||"JetBrains-JediTerm"===v.env.TERMINAL_EMULATOR,Cp=(e,t)=>Op?e:t,_p=Cp("◆","*"),Tp=Cp("■","x"),Ap=Cp("▲","x"),Ip=Cp("◇","o"),Dp=Cp("┌","T"),kp=Cp("│","|"),Mp=Cp("└","—"),jp=Cp("┐","T"),Np=Cp("┘","—"),Pp=Cp("●",">"),Rp=Cp("○"," "),Lp=Cp("◻","[•]"),Bp=Cp("◼","[+]"),Fp=Cp("◻","[ ]"),Up=Cp("▪","•"),Hp=Cp("─","-"),Wp=Cp("╮","+"),Gp=Cp("╯","+"),Vp=Cp("╰","+"),qp=Cp("╭","+"),Kp=Cp("●","•"),zp=Cp("◆","*"),Yp=Cp("▲","!"),Jp=Cp("■","x"),Xp=e=>{switch(e){case"initial":case"active":return R("cyan",_p);case"cancel":return R("red",Tp);case"error":return R("yellow",Ap);case"submit":return R("green",Ip)}},Qp=e=>{switch(e){case"initial":case"active":return R("cyan",kp);case"cancel":return R("red",kp);case"error":return R("yellow",kp);case"submit":return R("green",kp)}},Zp=(e,t,n,r,i,o=!1)=>{let s=t,a=0;if(o)for(let t=r-1;t>=n&&(s-=e[t].length,a++,!(s<=i));t--);else for(let t=n;t<r&&(s-=e[t].length,a++,!(s<=i));t++);return{lineCount:s,removals:a}},em=({cursor:e,options:t,style:n,output:r=process.stdout,maxItems:i=Number.POSITIVE_INFINITY,columnPadding:o=0,rowPadding:s=4})=>{const a=bp(r)-o,l=wp(r),c=R("dim","..."),d=Math.max(l-s,0),u=Math.max(Math.min(i,d),5);let p=0;e>=u-3&&(p=Math.max(Math.min(e-u+3,t.length-u),0));let m=u<t.length&&p>0,h=u<t.length&&p+u<t.length;const f=Math.min(p+u,t.length),g=[];let b=0;m&&b++,h&&b++;const w=p+(m?1:0),y=f-(h?1:0);for(let r=w;r<y;r++){const i=op(n(t[r],r===e),a,{hard:!0,trim:!1}).split("\n");g.push(i),b+=i.length}if(b>d){let t=0,n=0,r=b;const i=e-w;let o=d;const s=()=>Zp(g,r,0,i,o),a=()=>Zp(g,r,i+1,g.length,o,!0);m?(({lineCount:r,removals:t}=s()),r>o&&(h||(o-=1),({lineCount:r,removals:n}=a()))):(h||(o-=1),({lineCount:r,removals:n}=a()),r>o&&(o-=1,({lineCount:r,removals:t}=s()))),t>0&&(m=!0,g.splice(0,t)),n>0&&(h=!0,g.splice(g.length-n,n))}const v=[];m&&v.push(c);for(const e of g)for(const t of e)v.push(t);return h&&v.push(c),v},tm=[qp,Wp,Vp,Gp],nm=[Dp,jp,Mp,Np];function rm(e,t,n,r){let i=n,o=n;return"center"===r?i=Math.floor((t-e)/2):"right"===r&&(i=t-e-n),o=t-i-e,[i,o]}const im=e=>e,om=e=>{const t=e.active??"Yes",n=e.inactive??"No";return new $p({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){const r=e.withGuide??up.withGuide,i=`${Xp(this.state)} `,o=r?`${R("gray",kp)} `:"",s=yp(e.output,e.message,o,i),a=`${r?`${R("gray",kp)}\n`:""}${s}\n`,l=this.value?t:n;switch(this.state){case"submit":return`${a}${r?`${R("gray",kp)} `:""}${R("dim",l)}`;case"cancel":return`${a}${r?`${R("gray",kp)} `:""}${R(["strikethrough","dim"],l)}${r?`\n${R("gray",kp)}`:""}`;default:{const i=r?`${R("cyan",kp)} `:"",o=r?R("cyan",Mp):"";return`${a}${i}${this.value?`${R("green",Pp)} ${t}`:`${R("dim",Rp)} ${R("dim",t)}`}${e.vertical?r?`\n${R("cyan",kp)} `:"\n":` ${R("dim","/")} `}${this.value?`${R("dim",Rp)} ${R("dim",n)}`:`${R("green",Pp)} ${n}`}\n${o}\n`}}}}).prompt()},sm={message:(e=[],{symbol:t=R("gray",kp),secondarySymbol:n=R("gray",kp),output:r=process.stdout,spacing:i=1,withGuide:o}={})=>{const s=[],a=o??up.withGuide,l=a?n:"",c=a?`${t} `:"",d=a?`${n} `:"";for(let e=0;e<i;e++)s.push(l);const u=Array.isArray(e)?e:e.split("\n");if(u.length>0){const[e,...r]=u;e.length>0?s.push(`${c}${e}`):s.push(a?t:"");for(const e of r)e.length>0?s.push(`${d}${e}`):s.push(a?n:"")}r.write(`${s.join("\n")}\n`)},info:(e,t)=>{sm.message(e,{...t,symbol:R("blue",Kp)})},success:(e,t)=>{sm.message(e,{...t,symbol:R("green",zp)})},step:(e,t)=>{sm.message(e,{...t,symbol:R("green",Ip)})},warn:(e,t)=>{sm.message(e,{...t,symbol:R("yellow",Yp)})},warning:(e,t)=>{sm.warn(e,t)},error:(e,t)=>{sm.message(e,{...t,symbol:R("red",Jp)})}},am=(e,t)=>e.split("\n").map(e=>t(e)).join("\n"),lm=e=>{const t=(e,t)=>{const n=e.label??String(e.value);return"disabled"===t?`${R("gray",Fp)} ${am(n,e=>R(["strikethrough","gray"],e))}${e.hint?` ${R("dim",`(${e.hint??"disabled"})`)}`:""}`:"active"===t?`${R("cyan",Lp)} ${n}${e.hint?` ${R("dim",`(${e.hint})`)}`:""}`:"selected"===t?`${R("green",Bp)} ${am(n,e=>R("dim",e))}${e.hint?` ${R("dim",`(${e.hint})`)}`:""}`:"cancelled"===t?`${am(n,e=>R(["strikethrough","dim"],e))}`:"active-selected"===t?`${R("green",Bp)} ${n}${e.hint?` ${R("dim",`(${e.hint})`)}`:""}`:"submitted"===t?`${am(n,e=>R("dim",e))}`:`${R("dim",Fp)} ${am(n,e=>R("dim",e))}`},n=e.required??!0;return new Sp({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:n,cursorAt:e.cursorAt,validate(e){if(n&&(void 0===e||0===e.length))return`Please select at least one option.\n${R("reset",R("dim",`Press ${R(["gray","bgWhite","inverse"]," space ")} to select, ${R("gray",R("bgWhite",R("inverse"," enter ")))} to submit`))}`},render(){const n=e.withGuide??up.withGuide,r=yp(e.output,e.message,n?`${Qp(this.state)} `:"",`${Xp(this.state)} `),i=`${n?`${R("gray",kp)}\n`:""}${r}\n`,o=this.value??[],s=(e,n)=>{if(e.disabled)return t(e,"disabled");const r=o.includes(e.value);return t(e,n&&r?"active-selected":r?"selected":n?"active":"inactive")};switch(this.state){case"submit":{const r=this.options.filter(({value:e})=>o.includes(e)).map(e=>t(e,"submitted")).join(R("dim",", "))||R("dim","none");return`${i}${yp(e.output,r,n?`${R("gray",kp)} `:"")}`}case"cancel":{const r=this.options.filter(({value:e})=>o.includes(e)).map(e=>t(e,"cancelled")).join(R("dim",", "));return""===r.trim()?`${i}${R("gray",kp)}`:`${i}${yp(e.output,r,n?`${R("gray",kp)} `:"")}${n?`\n${R("gray",kp)}`:""}`}case"error":{const t=n?`${R("yellow",kp)} `:"",r=this.error.split("\n").map((e,t)=>0===t?`${n?`${R("yellow",Mp)} `:""}${R("yellow",e)}`:` ${e}`).join("\n"),o=i.split("\n").length,a=r.split("\n").length+1;return`${i}${t}${em({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:t.length,rowPadding:o+a,style:s}).join(`\n${t}`)}\n${r}\n`}default:{const t=n?`${R("cyan",kp)} `:"",r=i.split("\n").length,o=n?2:1;return`${i}${t}${em({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:t.length,rowPadding:r+o,style:s}).join(`\n${t}`)}\n${n?R("cyan",Mp):""}\n`}}}}).prompt()},cm=e=>new Ep({validate:e.validate,mask:e.mask??Up,signal:e.signal,input:e.input,output:e.output,render(){const t=e.withGuide??up.withGuide,n=`${t?`${R("gray",kp)}\n`:""}${Xp(this.state)} ${e.message}\n`,r=this.userInputWithCursor,i=this.masked;switch(this.state){case"error":{const r=t?`${R("yellow",kp)} `:"",o=t?`${R("yellow",Mp)} `:"",s=i??"";return e.clearOnError&&this.clear(),`${n.trim()}\n${r}${s}\n${o}${R("yellow",this.error)}\n`}case"submit":return`${n}${t?`${R("gray",kp)} `:""}${i?R("dim",i):""}`;case"cancel":return`${n}${t?`${R("gray",kp)} `:""}${i?R(["strikethrough","dim"],i):""}${i&&t?`\n${R("gray",kp)}`:""}`;default:return`${n}${t?`${R("cyan",kp)} `:""}${r}\n${t?R("cyan",Mp):""}\n`}}}).prompt(),dm=e=>R("magenta",e),um=(e,t)=>e.includes("\n")?e.split("\n").map(e=>t(e)).join("\n"):t(e),pm=e=>{const t=(e,t)=>{const n=e.label??String(e.value);switch(t){case"disabled":return`${R("gray",Rp)} ${um(n,e=>R("gray",e))}${e.hint?` ${R("dim",`(${e.hint??"disabled"})`)}`:""}`;case"selected":return`${um(n,e=>R("dim",e))}`;case"active":return`${R("green",Pp)} ${n}${e.hint?` ${R("dim",`(${e.hint})`)}`:""}`;case"cancelled":return`${um(n,e=>R(["strikethrough","dim"],e))}`;default:return`${R("dim",Rp)} ${um(n,e=>R("dim",e))}`}};return new xp({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){const n=e.withGuide??up.withGuide,r=`${Xp(this.state)} `,i=`${Qp(this.state)} `,o=yp(e.output,e.message,i,r),s=`${n?`${R("gray",kp)}\n`:""}${o}\n`;switch(this.state){case"submit":{const r=n?`${R("gray",kp)} `:"";return`${s}${yp(e.output,t(this.options[this.cursor],"selected"),r)}`}case"cancel":{const r=n?`${R("gray",kp)} `:"";return`${s}${yp(e.output,t(this.options[this.cursor],"cancelled"),r)}${n?`\n${R("gray",kp)}`:""}`}default:{const r=n?`${R("cyan",kp)} `:"",i=n?R("cyan",Mp):"",o=s.split("\n").length,a=n?2:1;return`${s}${r}${em({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:r.length,rowPadding:o+a,style:(e,n)=>t(e,e.disabled?"disabled":n?"active":"inactive")}).join(`\n${r}`)}\n${i}\n`}}}}).prompt()};R("gray",kp);var mm=e=>{const t=(({indicator:e="dots",onCancel:t,output:n=process.stdout,cancelMessage:r,errorMessage:i,frames:o=(Op?["◒","◐","◓","◑"]:["•","o","O","0"]),delay:s=(Op?80:120),signal:a,...l}={})=>{const c="true"===process.env.CI;let d,u,p,m=!1,h=!1,f="",g=performance.now();const b=bp(n),w=l?.styleFrame??dm,y=e=>{const n=e>1?i??up.messages.error:r??up.messages.cancel;h=1===e,m&&(C(n,e),h&&"function"==typeof t&&t())},v=()=>y(2),$=()=>y(1),S=()=>{if(void 0===p)return;c&&n.write("\n");const e=op(p,b,{hard:!0,trim:!1}).split("\n");e.length>1&&n.write(cp.cursor.up(e.length-1)),n.write(cp.cursor.to(0)),n.write(cp.erase.down())},E=e=>e.replace(/\.+$/,""),x=e=>{const t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},O=l.withGuide??up.withGuide,C=(t="",r=0,i=!1)=>{if(!m)return;m=!1,clearInterval(u),S();const o=0===r?R("green",Ip):R("red",1===r?Tp:Ap);f=t??f,i||("timer"===e?n.write(`${o} ${f} ${x(g)}\n`):n.write(`${o} ${f}\n`)),process.removeListener("uncaughtExceptionMonitor",v),process.removeListener("unhandledRejection",v),process.removeListener("SIGINT",$),process.removeListener("SIGTERM",$),process.removeListener("exit",y),a&&a.removeEventListener("abort",$),d()};return{start:(t="")=>{m=!0,d=gp({output:n}),f=E(t),g=performance.now(),O&&n.write(`${R("gray",kp)}\n`);let r=0,i=0;process.on("uncaughtExceptionMonitor",v),process.on("unhandledRejection",v),process.on("SIGINT",$),process.on("SIGTERM",$),process.on("exit",y),a&&a.addEventListener("abort",$),u=setInterval(()=>{if(c&&f===p)return;S(),p=f;const t=w(o[r]);let s;if(c)s=`${t} ${f}...`;else if("timer"===e)s=`${t} ${f} ${x(g)}`;else{const e=".".repeat(Math.floor(i)).slice(0,3);s=`${t} ${f}${e}`}const a=op(s,b,{hard:!0,trim:!1});n.write(a),r=r+1<o.length?r+1:0,i=i<4?i+.125:0},s)},stop:(e="")=>C(e,0),message:(e="")=>{f=E(e??f)},cancel:(e="")=>C(e,1),error:(e="")=>C(e,2),clear:()=>C("",0,!0),get isCancelled(){return h}}})();let n=e;return t.start(e),{get text(){return n},set text(e){n=e,t.message(e)},message:e=>{n=e,t.message(e)},succeed:e=>{t.stop(e??`${n.replace(/\n+$/,"")} - done.`)},fail:e=>{t.stop(e??`${n.replace(/\n+$/,"")} - error.`)},stop:e=>{t.stop(e)},info:e=>{t.stop(e??n.replace(/\n+$/,""))}}},hm=async(e,t,n,r={})=>{const{exitOnError:i=!0,showError:o=!0,stdio:s,killSignal:a,type:l="spawn",cwd:c,env:d,spinner:u=!0}=r,p=u?mm(`${n}\n\n`):null;if("exec"===l){p?.stop();const t=Pu({stdio:"inherit",shell:!0,cwd:c})`${e}`;return a&&process.on(a,()=>{t.kill()}),await t,{stdout:"",stderr:"",exitCode:0}}try{const r=T(e,t,{stdio:s,killSignal:a,cwd:c,env:d});if(0===r.status)return p?.succeed(`${n} - done.`),{stdout:r.stdout?.toString()??"",stderr:r.stderr?.toString()??"",exitCode:0};const l=r.stderr?.toString()??"",u=r.stdout?.toString()??"",m=`[${n}] Command failed: ${e} ${t.join(" ")}\n\nSTD ERROR:\n${l}\n\nSTD OUTPUT:\n${u}`;throw o&&p?.fail(m),i&&process.exit(r.status??1),new Error(m)}catch(e){throw o?p?.fail(`${n} - error.`):p?.stop(),e}},fm=t=>e.yellowBright(`(${t})`),gm=e=>e.map(e=>(e=>{if("string"==typeof e)return{value:e,label:e};const t={value:e.name,label:e.message??e.name,disabled:Boolean(e.disabled)};return e.hint&&(t.hint=e.hint),t})(e)),bm=e=>{if(e)return t=>{const n=e(t);if("string"==typeof n)return n}},wm={info:"cyan",success:"green",error:"red",warning:"yellow",step:"blue"},ym=((t={})=>{const{prefix:n="",colors:r={}}=t,i={...wm,...r},o=(t,r)=>{const o=i[t],s=e[o];return n?`${s(n)} ${r}`:r};return{intro:e=>{((e="",t)=>{const n=t?.output??process.stdout,r=`${R("gray",Dp)} `;n.write(`${r}${e}\n`)})(o("info",e),{})},outro:e=>{((e="")=>{const t=process.stdout,n=`${R("gray",kp)}\n${R("gray",Mp)} `;t.write(`${n}${e}\n\n`)})(o("info",e))},box:(e,t,n)=>{((e="",t="",n)=>{const r=n?.output??process.stdout,i=bp(r),o=n?.titlePadding??1,s=n?.contentPadding??2,a=void 0===n?.width||"auto"===n.width?1:Math.min(1,n.width),l=n?.withGuide??up.withGuide?`${kp} `:"",c=n?.formatBorder??im,d=(n?.rounded?tm:nm).map(c),u=c(Hp),p=c(kp),m=Ju(l),h=Ju(t),f=i-m;let g=Math.floor(i*a)-m;if("auto"===n?.width){const t=e.split("\n");let n=h+2*o;for(const e of t){const t=Ju(e)+2*s;t>n&&(n=t)}const r=n+2;r<g&&(g=r)}g%2!=0&&(g<f?g++:g--);const b=g-2,w=b-2*o,y=h>w?`${t.slice(0,w-3)}...`:t,[v,$]=rm(Ju(y),b,o,n?.titleAlign),S=op(e,b-2*s,{hard:!0,trim:!1});r.write(`${l}${d[0]}${u.repeat(v)}${y}${u.repeat($)}${d[1]}\n`);const E=S.split("\n");for(const e of E){const[t,i]=rm(Ju(e),b,s,n?.contentAlign);r.write(`${l}${p}${" ".repeat(t)}${e}${" ".repeat(i)}${p}\n`)}r.write(`${l}${d[2]}${u.repeat(b)}${d[3]}\n`)})(o("info",t),e,n)},info:e=>{sm.info(o("info",e))},success:e=>{sm.success(o("success",e))},error:e=>{sm.error(o("error",e))},warning:e=>{sm.warn(o("warning",e))},message:e=>{sm.message(e)},step:(t,n,r)=>{const i=e.blue(`[${t}/${n}]`);sm.step(`${i} ${r}`)}}})(),vm=ym.info,$m=ym.success,Sm=ym.error,Em=ym.warning,xm=ym.step,Om=ym.intro,Cm=ym.outro,_m=ym.box,Tm=ym.message,Am=e=>(e===hp&&(((e="")=>{const t=process.stdout,n=`${R("gray",Mp)} `;t.write(`${n}${R("red",e)}\n\n`)})("Operation cancelled."),process.exit(0)),e),Im=async e=>{const{message:t,choices:n,initial:r}=e,i=fm("Use arrows to navigate, enter to confirm"),o=gm(n),s=await pm({message:`${t}\n${i}`,options:o,initialValue:r});return Am(s)},Dm=async e=>{const{message:t,choices:n,maxChoices:r,minChoices:i,required:o=!1}=e,s=fm("Press space to select, enter to confirm"),a=gm(n),l=await lm({message:`${t}\n${s}`,options:a,required:o||"number"==typeof i&&i>0}),c=Am(l);return i&&c.length<i?(Sm(`Please select at least ${i} options`),Dm(e)):r&&c.length>r?(Sm(`Please select at most ${r} options`),Dm(e)):c},km=async e=>{const{message:t,initial:n=!1}=e,r=await om({message:t,initialValue:n});return Am(r)},Mm=async e=>{const{message:t,validate:n}=e,r=await cm({message:t,validate:bm(n)});return Am(r)};const jm="1.0.0-beta.1",Nm="A comprehensive CLI toolkit for boosting Claude Code to the insane level.",Pm=["agents","commands","skills","hooks","scripts","workflows"],Rm="init",Lm="install",Bm="add-skill",Fm="add-agent",Um="add-command",Hm="exit",Wm={[Lm]:"Install full claude code toolkit",[Rm]:"Initialize base Claude Code infrastructure (hooks, scripts, settings)",[Bm]:"Add a new skill to the existing Сlaude code",[Fm]:"Add a new agent to the existing Сlaude code",[Um]:"Add a new command to the existing Сlaude code",[Hm]:"Exit the claude code toolkit"},Gm={[Lm]:"Install",[Rm]:"Initialize",[Bm]:"Add skill",[Fm]:"Add agent",[Um]:"Add command",[Hm]:"Exit"},Vm=[],qm=()=>{const e=A(import.meta.url);return u.resolve(u.dirname(e),"..")},Km={get PACKAGE_ROOT(){return qm()},get TEMPLATES_ROOT(){return u.join(qm(),"templates")},get CLAUDE_TEMPLATES(){return u.join(qm(),"templates","claude")},get PLANS_TEMPLATES(){return u.join(qm(),"templates","plans")},get CONFIG_TEMPLATES(){return u.join(qm(),"templates","config")},get COMMON_TEMPLATES(){return u.join(qm(),"templates","common")},get OUTPUT_STYLES(){return u.join(qm(),"templates","claude","output-styles")},DEST_DIR:".claude",PLANS_DIR:"plans/templates"},zm="#DE7356",Ym="#FFBC05",Jm="#3E85F8",Xm="#79FF4A",Qm=`\n ${e.hex(zm)(" ▐▛███▜▌")} ${e.bold.white("Claude Code Toolkit")}\n ${e.hex(zm)("▝▜█████▛▘")} ${e.dim("Version:")} ${e.bold.white(`v${jm}`)}\n ${e.hex(zm)(" ▘▘ ▝▝ ")} ${e.dim(Nm)}\n`,Zm=()=>{_m(e.bgHex(zm).bold(" ⚡️ Welcome ⚡️ "),Qm,{formatBorder:t=>e.hex(zm).bold(t),titleAlign:"center",rounded:!0})},eh=()=>0===c("command",["-v","claude"],{stdio:"ignore",shell:!0}).status,th=async()=>{eh()?$m("Claude Code is installed"):(Em("Claude Code is not installed"),await km({message:"Claude Code is required. Install it now?",initial:!0})||(Sm("Claude Code is required to use this toolkit. Please install it manually:"),Sm(" curl -fsSL https://claude.ai/install.sh | bash"),process.exit(1)),await hm("bash",["-c","curl -fsSL https://claude.ai/install.sh | bash"],"Installing Claude Code...",{exitOnError:!1,showError:!0}),eh()||(Sm("Claude Code installation failed. Please install manually:"),Sm(" curl -fsSL https://claude.ai/install.sh | bash"),process.exit(1)),$m("Claude Code installed successfully"))},nh=()=>{Number(process.version.split(".")[0]?.replace("v",""))<18&&Em(`Node.js ${process.version} detected. Recommended: v18+`)},rh=async e=>{await oe.mkdir(e,{recursive:!0})},ih=async e=>{try{return await oe.access(e),!0}catch{return!1}},oh=async e=>{try{const t=await oe.readFile(e,"utf8");return JSON.parse(t)}catch(t){const n=t instanceof Error?t.message:String(t);throw new Error(`Failed to read JSON from ${e}: ${n}`)}},sh=async(e,t)=>{await rh(u.dirname(e)),await oe.writeFile(e,`${JSON.stringify(t,null,2)}\n`,"utf8")},ah=async(e,t)=>{await rh(u.dirname(t)),await oe.copyFile(e,t)},lh=async(e,t,n)=>{await rh(t);const r=await oe.readdir(e,{withFileTypes:!0});for(const i of r){if(n?.(i.name))continue;const r=u.join(e,i.name),o=u.join(t,i.name);await(i.isDirectory()?lh(r,o,n):ah(r,o))}},ch=new Set(["node_modules",".git",".DS_Store","tests","__tests__","__pycache__"]),dh=e=>e.endsWith(".example")||ch.has(e),uh=async(e,t)=>{await(async n=>{const r=mm(n);try{const i=await(async()=>{for(const{item:n}of e)for(const e of n.files){const n=u.join(Km.CLAUDE_TEMPLATES,e),r=u.join(t,Km.DEST_DIR,e);await(e.endsWith("/")?lh(n,r,dh):ah(n,r))}})();return r.succeed(`${n} - done.`),i}catch(e){throw r.fail(`${n} - error.`),e}})("Copying component files...")},ph=async e=>{const t=Km.CONFIG_TEMPLATES,n=e,r=await oe.readdir(t,{withFileTypes:!0}),i=await oe.readdir(n,{withFileTypes:!0}),o=r.filter(e=>i.some(t=>t.name===e.name));if(o.length>0)for(const e of o){const r=u.join(n,`${e.name}.backup`);await oe.copyFile(u.join(t,e.name),r),await oe.unlink(u.join(n,e.name))}await rh(n)},mh=async e=>{const t=Km.OUTPUT_STYLES,n=u.join(e,Km.DEST_DIR,"output-styles");await rh(n),await lh(t,n,dh)},hh=async e=>{const t=u.join(e,Km.DEST_DIR,"metadata.json"),n=await oh(t),r=n.download??{lastDownloadedAt:null,downloadedBy:null,installCount:0};n.version=jm,n.download={...r,lastDownloadedAt:(new Date).toISOString(),downloadedBy:process.env.USER??process.env.USERNAME??"unknown",installCount:r.installCount+1},await sh(t,n)},fh=async e=>{await(async e=>{const t=u.join(e.projectRoot,Km.DEST_DIR,".env.example"),n=u.join(e.projectRoot,Km.DEST_DIR,".env");let r=await oe.readFile(t,"utf8");e.context7.enabled&&e.context7.apiKey&&(r=r.replace(/^CONTEXT7_API_KEY=$/m,`CONTEXT7_API_KEY=${e.context7.apiKey}`)),e.gemini.enabled&&e.gemini.apiKey&&(r=r.replace(/^GEMINI_API_KEY=$/m,`GEMINI_API_KEY=${e.gemini.apiKey}`)),await rh(u.dirname(n)),await oe.writeFile(n,r,{encoding:"utf8",mode:384})})(e),await(async e=>{const t=u.join(e.projectRoot,Km.DEST_DIR,".mcp.json.example"),n=u.join(e.projectRoot,Km.DEST_DIR,".mcp.json"),r=await oh(t);if(e.context7.enabled&&e.context7.apiKey){const{apiKey:t}=e.context7,i=r.mcpServers.context7;i?.args&&(i.args=i.args.map(e=>"YOUR_API_KEY"===e?t:e)),await sh(n,r),await oe.chmod(n,384)}else delete r.mcpServers.context7,await sh(n,r)})(e),await(async e=>{const t=u.join(e.projectRoot,Km.DEST_DIR,".cctk.json"),n=await oh(t);n.codingLevel=e.codingLevel,n.locale={...n.locale,responseLanguage:e.language},await sh(t,n)})(e),await hh(e.projectRoot)},gh="# Claude Code Toolkit",bh="# /Claude Code Toolkit",wh=async e=>{const t=u.join(e.projectRoot,".gitignore"),n=(e=>{const t=["plans/",".claude/.mcp.json",".claude/.env","tmp/","!**/templates/plans/**"];return"private"===e&&t.unshift(".claude/"),t})(e.mode),r=(e=>[gh,...e,bh].join("\n"))(n);if(!await ih(t))return void await oe.writeFile(t,`${r}\n`,"utf8");const i=await oe.readFile(t,"utf8"),o=i.indexOf(gh),s=i.indexOf(bh);if(-1!==o&&-1!==s){const e=i.slice(0,o),n=i.slice(s+22);return void await oe.writeFile(t,`${e}${r}${n}`,"utf8")}const a=i.endsWith("\n")?"\n":"\n\n";await oe.writeFile(t,`${i}${a}${r}\n`,"utf8")},yh=async e=>{const t=u.join(e,Km.DEST_DIR);return!!await ih(t)&&(await oe.readdir(t)).length>0},vh=async e=>{const t=u.join(e,"CLAUDE.md");return await ih(t)},$h=(t,n,r)=>{const i=[` ${e.yellow("⚠")} Existing Claude Code configuration detected:`,"",...(n??[]).map(e=>` ${e}`),...r&&r.length>0?["",...r]:[],"",` ${e.yellow("⚠")} ${t}`];_m(e.bgHex(Ym).bold(" Warning "),i.join("\n"),{titleAlign:"center",rounded:!0,formatBorder:t=>e.hex(Ym)(t)})},Sh=async t=>{const n=await yh(t),r=await vh(t);if(!n&&!r)return"fresh";const i=[];n&&i.push(`${e.yellow("•")} ${e.bold(".claude/")} directory found`),r&&i.push(`${e.yellow("•")} ${e.bold("CLAUDE.md")} file found`);const o=n?await(async e=>{const t=u.join(e,Km.DEST_DIR,"metadata.json");try{return(await oh(t)).version??null}catch{return null}})(t):null,s=(t=>{if(!t)return[];const n=jm,r=[` ${e.dim("Installed:")} v${t} ${e.dim("Current:")} v${n}`],i=((e,t)=>{const n=e.split(".").map(Number),r=t.split(".").map(Number),i=Math.max(n.length,r.length);for(let e=0;e<i;e++){const t=n[e]??0,i=r[e]??0;if(t!==i)return t<i?-1:1}return 0})(t,n);return 0===i?r.push(` ${e.green("✓")} Versions match`):i<0?r.push(` ${e.yellow("↑")} Update available`):r.push(` ${e.yellow("⚠")} Installed version is newer than current toolkit`),r})(o);$h("Proceeding may overwrite your current settings.",i,s);const a=await Im({message:"How would you like to proceed?",choices:[{name:"update",message:"Update templates",hint:"Keep your configs (.env, .cctk.json, .claude/.mcp.json)"},{name:"fresh",message:"Fresh install",hint:"Overwrite everything"},{name:"backup",message:"Fresh install with backup",hint:"Backup .claude/ to tmp/ first"},{name:"cancel",message:"Cancel",hint:"Exit without changes"}]});if("cancel"===a&&(Em("Installation cancelled by user."),process.exit(0)),"backup"===a&&n){const e=u.join(t,Km.DEST_DIR),n=u.join(t,"tmp",Km.DEST_DIR);await lh(e,n),$m(`Backup created at tmp/${Km.DEST_DIR}`)}return"backup"===a?"fresh":a},Eh=async e=>{const t=await Im({message:"How would you like to use the toolkit?",choices:[{name:"public",message:"Public — shared with team (AI config committed)",hint:"Recommended for teams"},{name:"private",message:"Private — local only (added to .gitignore)",hint:"Personal use"}]});return"private"!==t||(await ih(u.join(e,"CLAUDE.md"))&&(Em("Existing CLAUDE.md detected. Private mode will add .claude/ to .gitignore."),Em("Other team members using Claude Code may be confused by missing config.")),await km({message:"This will add .claude/ and plans/ to .gitignore. Continue?",initial:!0}))?t:Eh(e)},xh=async t=>({mode:await Eh(t),codingLevel:await(async()=>{const e=await Im({message:"What power level do you want?",choices:[{name:String(-1),message:"Auto (default)",hint:"System determines based on context"},{name:String(1),message:"Senior Engineer Mode",hint:"Trade-offs, business context, architecture (5-8 yrs)"},{name:String(2),message:"Tech Lead Mode",hint:"Strategic thinking, risk assessment (8-15 yrs)"},{name:String(3),message:"God Mode",hint:"Max velocity, zero hand-holding (15+ yrs)"}],initial:String(-1)});return Number(e)})(),language:await(async()=>Im({message:"What language should Claude respond in?",choices:[{name:"en",message:"English",hint:"Default"},{name:"uk",message:"Українська",hint:"Ukrainian"}]}))(),context7:await(async()=>await km({message:"Enable Context7 MCP? (provides documentation context)",initial:!1})?{enabled:!0,apiKey:(await Mm({message:"Enter your CONTEXT7_API_KEY (from https://context7.com/dashboard/api-keys):",validate:e=>e.trim().length>0||"API key is required when Context7 is enabled"})).trim()}:{enabled:!1})(),gemini:await(async()=>{if(!await km({message:"Provide Gemini API key? (enhances research quality & reduces token costs)",initial:!1})){const t=[` ${e.hex(Ym)("⚠")} ${e.bold("Some toolkit features will be limited without Gemini API:")}`,"",` ${e.dim("•")} Research capabilities will use fallback methods`,` ${e.dim("•")} Documentation search may be slower`,` ${e.dim("•")} Token costs may be higher due to less efficient workflows`,"",` ${e.dim("You can add GEMINI_API_KEY to .claude/.env later.")}`];return _m(e.bgHex(Ym).bold(" Notice "),t.join("\n"),{titleAlign:"center",rounded:!0,formatBorder:t=>e.hex(Ym)(t)}),{enabled:!1}}return{enabled:!0,apiKey:(await Mm({message:"Enter your GEMINI_API_KEY (from https://aistudio.google.com/apikey):",validate:e=>e.trim().length>0||"API key is required when Gemini is enabled"})).trim()}})(),projectRoot:t}),Oh=async(e,t,n)=>{const r=u.join(t,Km.DEST_DIR,e),i=await(async e=>{try{return(await oe.readdir(e)).filter(e=>!e.startsWith("."))}catch{return[]}})(r);if(0===i.length)return[];const o=n[e],s=new Set(i);return o.items.filter(e=>e.files.some(e=>{const t=e.replace(/\/$/,""),n=u.basename(t);return s.has(n)})).map(e=>e.name)},Ch=async e=>{const t=u.join(Km.CLAUDE_TEMPLATES,e,"registry.json");try{await oe.access(t)}catch{throw new Error(`Registry file not found: ${t}`)}const n=await oe.readFile(t,"utf8"),r=JSON.parse(n);if(r.name!==e)throw new Error(`Registry name mismatch: expected "${e}", got "${r.name}"`);return r},_h=async()=>{const e=await Promise.all(Pm.map(async e=>[e,await Ch(e)]));return Object.fromEntries(e)},Th=e=>Pm.includes(e),Ah=(e,t)=>{for(const n of e.item.meta?.externalDeps??[])t.has(n.command)||t.set(n.command,n)},Ih=e=>{const t=new Map;for(const n of e)Ah(n,t);return[...t.values()]},Dh=(e,t)=>{const{dependencies:n}=e.item,r=[];for(const[i,o]of Object.entries(n)){if(!Th(i))continue;const n=i,s=t[n];for(const i of o){const o=s.items.find(e=>e.name===i);if(!o){Em(`Dependency "${i}" not found in ${n} registry (referenced by ${e.item.name})`);continue}const a={type:n,item:o,registry:s},l=Dh(a,t);r.push(a,...l)}}return r},kh=e=>e.reduce((e,t)=>({...e,[t.type]:[...e[t.type]??[],t]}),{}),Mh=e=>e.command.includes(" ")?0===c(e.command,{stdio:"ignore",shell:!0}).status:0===c("command",["-v",e.command],{stdio:"ignore",shell:!0}).status,jh=e=>{const t=[],n=[];for(const r of e)Mh(r)?t.push(r):n.push(r);return{installed:t,missing:n}},Nh=async(e,t,n)=>{try{if(await(async e=>{await hm(e.install,[],`Installing ${e.name}...`,{exitOnError:!1,stdio:"inherit",type:"exec"})})(e),Mh(e))return $m(`${e.name} installed successfully`),void t.push(e);if("brew"===e.type&&(e=>{const t=e.install.split(/\s+/),n=t.indexOf("install");if(-1===n||!t[n+1])return!1;const r=t[n+1],i=[`/opt/homebrew/opt/${r}/bin`,`/usr/local/opt/${r}/bin`];for(const t of i)if(y(`${t}/${e.command}`))return process.env.PATH=`${t}:${process.env.PATH}`,vm(`Added ${t} to PATH (keg-only formula)`),Em(`To make "${e.command}" permanently available, add to ~/.zshrc:`),Em(` export PATH="${t}:$PATH"`),!0;const o=c("brew",["--prefix",r],{encoding:"utf8",stdio:"pipe"});if(0===o.status&&o.stdout.trim()){const t=`${o.stdout.trim()}/bin`;if(y(`${t}/${e.command}`))return process.env.PATH=`${t}:${process.env.PATH}`,vm(`Added ${t} to PATH (keg-only formula)`),Em(`To make "${e.command}" permanently available, add to ~/.zshrc:`),Em(` export PATH="${t}:$PATH"`),!0}return!1})(e)&&Mh(e))return $m(`${e.name} installed successfully (keg-only, PATH updated)`),void t.push(e);n.push({dep:e,error:"Installation completed but command not found"}),Em(`${e.name} installation did not register the command "${e.command}"`)}catch(t){const r=t instanceof Error?t.message:String(t);n.push({dep:e,error:r}),Em(`Failed to install ${e.name}: ${r}`)}},Ph=t=>{const n=[];for(const r of t.installed){const t=e.dim("installed");n.push(` ${e.green("✓")} ${r.name.padEnd(20)} ${t}`)}for(const r of t.missing){const t=e.yellow(r.install),i=r.optional?e.dim(" (optional)"):"";n.push(` ${e.red("✗")} ${r.name.padEnd(20)} ${t}${i}`)}const r=t.missing.filter(e=>!e.optional),i=t.missing.filter(e=>e.optional);if((r.length>0||i.length>0)&&n.push(""),r.length>0){const t=`${r.length} required dependencies need installation`;n.push(` ${e.red(t)}`)}if(i.length>0){const t=`${i.length} optional dependencies not installed`;n.push(` ${e.dim(t)}`)}0===t.missing.length&&n.push("",` ${e.green("All dependencies are installed!")}`),_m(e.bgHex(Jm).bold(" External Dependencies "),n.join("\n"),{titleAlign:"center",rounded:!0,formatBorder:t=>e.hex(Jm)(t)})},Rh=async t=>{const n=t.missing.filter(e=>!e.optional),r=t.missing.filter(e=>e.optional);if(0===n.length&&r.length>0)return await Im({message:`${r.length} optional dependencies available. What would you like to install?`,choices:[{name:"skip",message:"Skip installation",hint:"Continue without optional deps"},{name:"all",message:"Install optional dependencies",hint:"Full feature set"}]});const i=await Im({message:"What would you like to install?",choices:[{name:"all",message:`All dependencies (${n.length} required + ${r.length} optional)`,hint:"Recommended"},{name:"required",message:`Required only (${n.length})`,hint:"Skip optional packages"},{name:"skip",message:"Skip installation",hint:"Install nothing"}]});if("skip"===i){const r=[` ${e.hex(Ym)("⚠")} Some toolkit features may be limited or unavailable`,` ${e.hex(Ym)("⚠")} without the required external dependencies.`,"",` ${e.dim("Missing required:")} ${n.map(e=>e.name).join(", ")}`];if(_m(e.bgHex(Ym).bold(" Warning "),r.join("\n"),{titleAlign:"center",rounded:!0,formatBorder:t=>e.hex(Ym)(t)}),!await km({message:"Continue without installing dependencies?",initial:!1}))return Rh(t)}return i},Lh=async e=>{const t=u.join(e,Km.DEST_DIR),n=Km.COMMON_TEMPLATES,r=await(async e=>{const t=Km.COMMON_TEMPLATES,n=u.join(e,Km.DEST_DIR);await rh(n);const r=await oe.readdir(t,{withFileTypes:!0}),i=await oe.readdir(n,{withFileTypes:!0}),o=r.filter(e=>!i.some(t=>t.name===e.name));return 0===o.length?[]:o.map(e=>e.name)})(e);await rh(t);const i=r.map(e=>{const r=u.join(n,e),i=u.join(t,e);return se(r,i)});await Promise.all(i)},Bh=(t,n,r)=>{const i=null===t,o=i?" Update Complete ":" Installation Complete ",s=[` ${e.green("Components installed:")} ${n}`,...r>0?[` ${e.green("External deps installed:")} ${r}`]:[],...i?[` ${e.dim("Mode: update (configs preserved)")}`]:[],"",` ${e.dim("Next: Run")} ${e.bold("claude")} ${e.dim("to start using the toolkit")}`];_m(e.bgHex(Xm).bold(o),s.join("\n"),{titleAlign:"center",rounded:!0,formatBorder:t=>e.hex(Xm)(t)})},Fh=new Set(["npm install","yarn install","pnpm install"]),Uh=async e=>{const t=u.join(e,"package.json");if(await ih(t))return e;const n=u.join(e,"scripts","package.json");return await ih(n)?u.join(e,"scripts"):null},Hh=(e,t)=>{const n=e.item.files[0];if(!n)return null;const r=n.endsWith("/")?n.slice(0,-1):u.dirname(n);return u.join(t,".claude",r)},Wh=async(e,t,n)=>{try{return await hm(t,[],`Running postInstall for ${e}...`,{exitOnError:!1,type:"exec",cwd:n,spinner:!1}),{ok:!0}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},Gh=async(e,t,n)=>{const r=n??process.cwd(),i=e.filter(e=>e.type===t);if(0===i.length)return{installed:0,failedPostInstall:0};await uh(i,r);const o=await(async(e,t)=>{const n=e.filter(e=>e.item.meta?.postInstall);if(0===n.length)return{success:[],failed:[]};const r=[],i=[];for(const e of n){const{name:n,meta:o}=e.item,s=o?.postInstall;if(!s)continue;if(!Fh.has(s)){Em(`Skipping untrusted postInstall command for ${n}: "${s}"`);continue}const a=Hh(e,t);if(!a){Em(`Skipping postInstall for ${n}: no files defined`);continue}const l=await Uh(a);if(!l){Em(`Skipping postInstall for ${n}: no package.json found in ${a}`);continue}vm(`Running "${s}" for ${n} in ${u.relative(t,l)}`);const c=await Wh(n,s,l);c.ok?($m(`postInstall completed for ${n}`),r.push(n)):(Em(`postInstall failed for ${n}: ${c.error}`),i.push({name:n,error:c.error??"Unknown error"}))}return{success:r,failed:i}})(i,r);return o.failed.length>0&&Em(`${o.failed.length} postInstall command(s) failed for ${t}`),{installed:i.length,failedPostInstall:o.failed.length}},Vh=async e=>{if(0===e.missing.length)return $m("All external dependencies are already installed"),0;const t=await Rh(e);if("skip"===t)return Em("Skipping dependency installation. Some features may be limited."),0;const n="all"===t?e.missing:e.missing.filter(e=>!e.optional),r=await(async e=>{const t=[],n=[];for(let r=0;r<e.length;r++){const i=e[r],o=`[${r+1}/${e.length}]`;vm(`${o} Installing ${i.name} via: ${i.install}`),await Nh(i,t,n)}return{success:t,failed:n}})(n);return(e=>{if(e.failed.length>0){const t=e.failed.filter(e=>!e.dep.optional);for(const t of e.failed)Em(`Failed to install ${t.dep.name}: ${t.error}`);t.length>0&&Sm(`${t.length} required dependencies failed to install. Some features may not work.`)}return e.success.length})(r)},qh=e=>{const t=e.split(/\s+/).at(-1);return t&&"install"!==t?t:null},Kh={PREREQUISITES:1,CONFIGURE:2,COMMONS:3,SCRIPTS:4,HOOKS:5,WORKFLOWS:6,ANALYZE:7,INSTALL:8,DEPENDENCIES:9},zh=Object.values(Kh).length,Yh=new Set(["catalog-generators"]),Jh={PREREQUISITES:1,CONFIGURE:2,COMMONS:3,ANALYZE:4,DEPLOY:5,PYTHON:6,DEPS:7,GENERATE:8,DONE:9},Xh=Object.values(Jh).length,Qh=async()=>{try{xm(Jh.PREREQUISITES,Xh,"Checking prerequisites..."),nh(),await th();const e=process.cwd(),t="update"===await Sh(e);t&&vm("Update mode: templates will be refreshed, your configs preserved."),xm(Jh.CONFIGURE,Xh,"Configuring installation...");const n=t?null:await xh(e);xm(Jh.COMMONS,Xh,"Copying base infrastructure..."),n&&await ph(e),await Lh(e),await mh(e),xm(Jh.ANALYZE,Xh,"Analyzing components...");const r=(e=>{const t=[];for(const[n,r]of Object.entries(e))for(const e of r.items)t.push({type:n,item:e,registry:r});return t})(await _h());xm(Jh.DEPLOY,Xh,"Deploying components...");for(const t of Pm)await Gh(r,t,e);xm(Jh.PYTHON,Xh,"Setting up Python environment..."),await(async(e,t)=>{const n=e.some(e=>"python"===e.item.meta?.runtime);if(!n)return{venvCreated:!1,packagesInstalled:[],errors:[]};const r=(e=>{const t=new Set;for(const n of e)if("python"===n.item.meta?.runtime)for(const e of n.item.meta.externalDeps??[])if("pip"===e.type){const n=qh(e.install);n&&t.add(n)}return[...t]})(e);if(0===r.length)return{venvCreated:!1,packagesInstalled:[],errors:[]};const i=u.join(t,".claude/skills/.venv"),o=await(async e=>{const t=u.join(e,"bin","activate"),n=u.join(e,"bin","python3");if(!await ih(e))return"missing";const r=await ih(t),i=await ih(n);return r&&i?"valid":"corrupted"})(i);"corrupted"===o&&(Em("Existing venv is corrupted, recreating..."),await oe.rm(i,{recursive:!0,force:!0}));let s=!1;if("valid"!==o)try{await(async e=>{try{return void await hm(`python3 -m venv ${e}`,[],"Creating Python venv...",{exitOnError:!1,type:"exec",spinner:!1})}catch{}vm("Falling back to venv without pip..."),await hm(`python3 -m venv --without-pip ${e}`,[],"Creating Python venv (no pip)...",{exitOnError:!1,type:"exec",spinner:!1}),Em("Bootstrapping pip from bootstrap.pypa.io (remote script)"),await hm(`curl -sS https://bootstrap.pypa.io/get-pip.py | ${e}/bin/python3`,[],"Bootstrapping pip...",{exitOnError:!1,type:"exec",spinner:!1})})(i),s=!0,$m("Python venv created")}catch(e){const t=e instanceof Error?e.message:String(e);return Em(`Failed to create Python venv: ${t}`),{venvCreated:!1,packagesInstalled:[],errors:[t]}}if(s)try{const e=u.join(i,"bin","pip3");await hm(`${e} install --upgrade pip`,[],"Upgrading pip...",{exitOnError:!1,type:"exec",spinner:!1})}catch{}const{installed:a,errors:l}=await(async(e,t)=>{const n=[],r=[],i=u.join(e,"bin","pip3");for(const e of t)try{await hm(`${i} install ${e}`,[],`Installing ${e}...`,{exitOnError:!1,type:"exec",spinner:!1}),n.push(e)}catch(t){const n=t instanceof Error?t.message:String(t);r.push(`${e}: ${n}`),Em(`Failed to install ${e}: ${n}`)}return{installed:n,errors:r}})(i,r);return a.length>0&&$m(`Installed ${a.length} pip package(s) in venv`),{venvCreated:s,packagesInstalled:a,errors:l}})(r,e),xm(Jh.DEPS,Xh,"Installing external dependencies...");const i=Ih(r),o=jh(i);Ph(o);const s=await Vh(o);xm(Jh.GENERATE,Xh,"Generating configuration files..."),n?(await fh(n),await wh(n)):await hh(e),xm(Jh.DONE,Xh,"Done!"),Bh(n,r.length,s)}catch(e){const t=e instanceof Error?e.message:String(e);throw Sm(`Installation failed: ${t}`),e}},Zh={LOAD:1,SCAN:2,SELECT:3,RESOLVE:4,COPY:5},ef=Object.values(Zh).length,tf=async t=>{try{const n=process.cwd();xm(Zh.LOAD,ef,"Loading registries...");const r=await _h();xm(Zh.SCAN,ef,"Scanning existing installation...");const i=await(async(e,t)=>{const n=u.join(e,Km.DEST_DIR,"settings.json"),r=u.join(e,Km.DEST_DIR,"hooks"),[i,o]=await Promise.all([ih(n),ih(r)]),s=await Promise.all(Pm.map(async n=>[n,await Oh(n,e,t)]));return{hasSettings:i,hasHooks:o,installedComponents:new Map(s)}})(n,r);xm(Zh.SELECT,ef,`Select ${t} to add...`);const o=r[t],s=await(async(t,n,r)=>{const i=n.items.map(n=>{const i=((e,t,n)=>{const r=n.installedComponents.get(e);return r?.includes(t)??!1})(t,n.name,r),o=i?e.hex(Xm)("installed"):(s=n.description).length<=80?s:`${s.slice(0,80)}…`;var s;return{name:n.name,message:n.title,hint:o,disabled:i}}),o=i.filter(e=>!e.disabled);return 0===o.length?[]:await Dm({message:`Select ${t} to add:`,choices:i,required:!0})})(t,o,i);if(0===s.length)return void Em(`No ${t} selected. Exiting.`);const a=s.flatMap(e=>{const n=o.items.find(t=>t.name===e);return n?[{type:t,item:n,registry:o}]:[]});xm(Zh.RESOLVE,ef,"Resolving dependencies..."),await Gh(a,t),$m(`${t} added successfully`)}catch(e){const n=e instanceof Error?e.message:String(e);throw Sm(`Add-${t} failed: ${n}`),e}},nf=async(e,t={})=>{switch(e){case Rm:await(async()=>{try{xm(Kh.PREREQUISITES,zh,"Checking prerequisites..."),nh(),await th();const e=process.cwd(),t=await yh(e),n=await vh(e);t&&($h("Initialization unavailable due to existing configuration."),process.exit(0)),n&&(Em("CLAUDE.md already exists — by continuing, we'll backup your current configuration and install fresh."),await km({message:"Are you sure you want to continue?",initial:!0})||process.exit(0)),await ph(e),xm(Kh.COMMONS,zh,"Copying common configs..."),await Lh(e),await mh(e),xm(Kh.CONFIGURE,zh,"Configuring installation...");const r=await xh(e);await fh(r),await wh(r),xm(Kh.SCRIPTS,zh,"Loading scripts...");const i=await Ch("scripts"),o={...i,items:i.items.filter(e=>Yh.has(e.name))};xm(Kh.HOOKS,zh,"Loading hooks...");const s=await Ch("hooks");xm(Kh.WORKFLOWS,zh,"Loading workflows...");const a=new Set(s.items.flatMap(e=>e.dependencies.workflows)),l=await Ch("workflows"),c={...l,items:l.items.filter(e=>a.has(e.name))};xm(Kh.ANALYZE,zh,"Analyzing dependencies...");const d=await(async e=>{const t={agents:[],commands:[],skills:[],hooks:[],scripts:[],workflows:[]};if(0===Object.keys(e).length)return t;const n=await _h(),r=Object.entries(e).filter(([e])=>Th(e)).flatMap(([e,t])=>{const r=e,i=t.items.map(e=>({type:r,item:e,registry:t})),o=i.flatMap(e=>Dh(e,n));return[...i,...o]});return{...t,...kh((i=r,i.filter((e,t,n)=>t===n.findIndex(t=>t.item.name===e.item.name))))};var i})({workflows:c,scripts:o,hooks:s}),u=Object.values(d).flat(),p=Ih(u);xm(Kh.INSTALL,zh,"Installing components...");for(const[e,t]of Object.entries(d))await Gh(t,e);xm(Kh.DEPENDENCIES,zh,"Checking dependencies...");const m=jh(p);Ph(m);const h=await Vh(m);Bh(r,u.length,h)}catch(e){const t=e instanceof Error?e.message:String(e);throw Sm(`Init failed: ${t}`),e}})();break;case Lm:await Qh();break;case Bm:await(async()=>tf("skills"))();break;case Fm:await(async()=>tf("agents"))();break;case Um:await(async()=>tf("commands"))();break;case Hm:Cm("Exiting the claude code toolkit"),process.exit(0);break;default:throw new Error(`Unknown command: ${e}`)}},rf=e=>{e instanceof Error?Sm(e.message):Sm(`Unknown error: ${String(e)}`),process.exit(1)},of=(sf={name:"cc",version:jm,description:Nm,banner:Zm},new class{program;config;constructor(e){this.config=e,this.program=(new We).name(e.name).version(e.version).description(e.description??"")}command(e){const t=this.program.command(e.name).description(e.description);if(e.arguments)for(const n of e.arguments){const e=!1===n.required?`[${n.name}]`:`<${n.name}>`;t.argument(e,n.description)}if(e.options)for(const n of e.options)n.required?t.requiredOption(n.flags,n.description,n.default):t.option(n.flags,n.description,n.default);return t.action(async(...t)=>{const n=t.at(-2),r=t.slice(0,-2);this.config.banner&&this.config.banner(),await e.action(n,...r)}),this}async parse(e=process.argv){await this.program.parseAsync(e)}getProgram(){return this.program}}(sf)).command({name:Rm,description:Wm[Rm],action:e=>{nf(Rm,e).catch(rf)}}).command({name:Lm,description:Wm[Lm],action:e=>{nf(Lm,e).catch(rf)}}).command({name:Bm,description:Wm[Bm],action:e=>{nf(Bm,e).catch(rf)}}).command({name:Fm,description:Wm[Fm],action:e=>{nf(Fm,e).catch(rf)}}).command({name:Um,description:Wm[Um],action:e=>{nf(Um,e).catch(rf)}}).getProgram().action(()=>{Om(e.hex("#DE7356").bold("Launching Claude Code Toolkit...")),Tm(""),Zm(),(async()=>{try{vm("Preparing next steps...");const t=16,n=Object.entries(Wm).map(([n,r])=>{const i=((e,t)=>{const n=Math.max(0,t-e.length);return" ".repeat(n)})(n,t),o=Gm[n],s=Vm.includes(n);return{name:`${n}${i}}`,hint:s?"Coming soon...":e.bold.magenta(r),message:o,disabled:s}}),r=await Im({message:"Pick operation you would like to perform?",choices:n}),i=Object.keys(Wm).find(e=>r.startsWith(e));i||(Sm("Invalid operation"),process.exit(1)),$m(`Chosen operation: ${e.greenBright(i)}`),await nf(i),process.exit(0)}catch{process.exit(1)}})().catch(rf)});var sf;const af=()=>{process.on("unhandledRejection",e=>{console.error("Unhandled Rejection at:",{error:e}),process.exit(1)}),process.on("uncaughtException",e=>{console.error("Uncaught Exception thrown:",{error:e}),process.exit(1)}),process.on("SIGINT",()=>{console.log("Received SIGINT"),process.exit(0)}),process.on("SIGTERM",()=>{console.log("Received SIGTERM"),process.exit(0)}),of.parse()};export{af as claudeCodeToolkit};
|
|
1
|
+
import e from"chalk";import t,{once as n,addAbortListener as r,EventEmitter as i,on as o,setMaxListeners as s}from"node:events";import a,{ChildProcess as l,spawnSync as c,spawn as d}from"node:child_process";import u from"node:path";import p,{statSync as m,readFileSync as h,appendFileSync as f,writeFileSync as g,createWriteStream as b,createReadStream as w,existsSync as y}from"node:fs";import v,{platform as $,hrtime as S,execPath as E,execArgv as x,stdin as O,stdout as C}from"node:process";import _,{spawnSync as T}from"child_process";import{fileURLToPath as A}from"node:url";import{StringDecoder as I}from"node:string_decoder";import{debuglog as D,stripVTControlCharacters as k,inspect as M,promisify as j,callbackify as N,aborted as P,styleText as R}from"node:util";import L,{ReadStream as B}from"node:tty";import F from"path";import U from"fs";import{toPath as H,traversePathUp as W}from"unicorn-magic";import{setTimeout as G,scheduler as V,setImmediate as q}from"node:timers/promises";import{constants as K}from"node:os";import{serialize as z}from"node:v8";import{Transform as Y,getDefaultHighWaterMark as J,Duplex as X,Writable as Q,Readable as Z,PassThrough as ee}from"node:stream";import{Buffer as te}from"node:buffer";import{finished as ne}from"node:stream/promises";import*as re from"node:readline";import ie from"node:readline";import oe,{copyFile as se}from"node:fs/promises";var ae="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function le(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ce={},de={},ue={};let pe=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}};ue.CommanderError=pe,ue.InvalidArgumentError=class extends pe{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:me}=ue;de.Argument=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.length>3&&"..."===this._name.slice(-3)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new me(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,t):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},de.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"};var he={},fe={};const{humanReadableArgName:ge}=de;function be(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,"")}fe.Help=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){const t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){const n=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){const t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){const r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);r||i?n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description)):t.push(n)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];const t=[];for(let n=e.parent;n;n=n.parent){const e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){const t=e.registeredArguments.map(e=>ge(e)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let t=e.parent;t;t=t.parent)n=t.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){const t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){const n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatHelp(e,t){const n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""];const s=t.commandDescription(e);s.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(s),r),""]));const a=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));a.length>0&&(o=o.concat([t.styleTitle("Arguments:"),...a,""]));const l=t.visibleOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));if(l.length>0&&(o=o.concat([t.styleTitle("Options:"),...l,""])),t.showGlobalOptions){const n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));n.length>0&&(o=o.concat([t.styleTitle("Global Options:"),...n,""]))}const c=t.visibleCommands(e).map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));return c.length>0&&(o=o.concat([t.styleTitle("Commands:"),...c,""])),o.join("\n")}displayWidth(e){return be(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(e=>"[options]"===e?this.styleOptionText(e):"[command]"===e?this.styleSubcommandText(e):"["===e[0]||"<"===e[0]?this.styleArgumentText(e):this.styleCommandText(e)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(e=>"[options]"===e?this.styleOptionText(e):"["===e[0]||"<"===e[0]?this.styleArgumentText(e):this.styleSubcommandText(e)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){const i=" ".repeat(2);if(!n)return i+e;const o=e.padEnd(t+e.length-r.displayWidth(e)),s=(this.helpWidth??80)-t-2-2;let a;return a=s<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,s).replace(/\n/g,"\n"+" ".repeat(t+2)),i+o+" ".repeat(2)+a.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;const n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{const n=e.match(r);if(null===n)return void i.push("");let o=[n.shift()],s=this.displayWidth(o[0]);n.forEach(e=>{const n=this.displayWidth(e);if(s+n<=t)return o.push(e),void(s+=n);i.push(o.join(""));const r=e.trimStart();o=[r],s=this.displayWidth(r)}),i.push(o.join(""))}),i.join("\n")}},fe.stripColor=be;var we={};const{InvalidArgumentError:ye}=ue;function ve(e){return e.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}we.Option=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;const n=function(e){let t,n;const r=/^-[^-]$/,i=/^--[^-]/,o=e.split(/[ |,]+/).concat("guard");if(r.test(o[0])&&(t=o.shift()),i.test(o[0])&&(n=o.shift()),!t&&r.test(o[0])&&(t=o.shift()),!t&&i.test(o[0])&&(t=n,n=o.shift()),o[0].startsWith("-")){const t=o[0],n=`option creation failed due to '${t}' in option flags '${e}'`;if(/^-[^-][^-]/.test(t))throw new Error(`${n}\n- a short flag is a single dash and a single character\n - either use a single dash and a single character (for a short flag)\n - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(r.test(t))throw new Error(`${n}\n- too many short flags`);if(i.test(t))throw new Error(`${n}\n- too many long flags`);throw new Error(`${n}\n- unrecognised flag format`)}if(void 0===t&&void 0===n)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}(e);this.short=n.shortFlag,this.long=n.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(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return"string"==typeof e&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new ye(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,t):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?ve(this.name().replace(/^no-/,"")):ve(this.name())}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},we.DualOptions=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){const n=t.attributeName();if(!this.dualOptions.has(n))return!0;const r=this.negativeOptions.get(n).presetArg,i=void 0!==r&&r;return t.negate===(i===e)}};var $e={suggestSimilar:function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));const n=e.startsWith("--");n&&(e=e.slice(2),t=t.map(e=>e.slice(2)));let r=[],i=3;return t.forEach(t=>{if(t.length<=1)return;const n=function(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);const n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let o=1;o=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+o),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}(e,t),o=Math.max(e.length,t.length);(o-n)/o>.4&&(n<i?(i=n,r=[t]):n===i&&r.push(t))}),r.sort((e,t)=>e.localeCompare(t)),n&&(r=r.map(e=>`--${e}`)),r.length>1?`\n(Did you mean one of ${r.join(", ")}?)`:1===r.length?`\n(Did you mean ${r[0]}?)`:""}};const Se=t.EventEmitter,Ee=a,xe=u,Oe=p,Ce=v,{Argument:_e,humanReadableArgName:Te}=de,{CommanderError:Ae}=ue,{Help:Ie,stripColor:De}=fe,{Option:ke,DualOptions:Me}=we,{suggestSimilar:je}=$e;function Ne(e){return e.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n,r="127.0.0.1",i="9229";return null!==(n=e.match(/^(--inspect(-brk)?)$/))?t=n[1]:null!==(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=n[1],/^\d+$/.test(n[3])?i=n[3]:r=n[3]):null!==(n=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=n[1],r=n[3],i=n[4]),t&&"0"!==i?`${t}=${r}:${parseInt(i)+1}`:e})}function Pe(){return!Ce.env.NO_COLOR&&"0"!==Ce.env.FORCE_COLOR&&"false"!==Ce.env.FORCE_COLOR&&(!(!Ce.env.FORCE_COLOR&&void 0===Ce.env.CLICOLOR_FORCE)||void 0)}he.Command=class e extends Se{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>Ce.stdout.write(e),writeErr:e=>Ce.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>Ce.stdout.isTTY?Ce.stdout.columns:void 0,getErrHelpWidth:()=>Ce.stderr.isTTY?Ce.stderr.columns:void 0,getOutHasColors:()=>Pe()??(Ce.stdout.isTTY&&Ce.stdout.hasColors?.()),getErrHasColors:()=>Pe()??(Ce.stderr.isTTY&&Ce.stderr.hasColors?.()),stripColor:e=>De(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){const e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let r=t,i=n;"object"==typeof r&&null!==r&&(i=r,r=null),i=i||{};const[,o,s]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(o);return r&&(a.description(r),a._executableHandler=!0),i.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!i.noHelp&&!i.hidden),a._executableFile=i.executableFile||null,s&&a.arguments(s),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),r?this:a}createCommand(t){return new e(t)}createHelp(){return Object.assign(new Ie,this.configureHelp())}configureHelp(e){return void 0===e?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return void 0===e?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return"string"!=typeof e&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(t=t||{}).isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new _e(e,t)}argument(e,t,n,r){const i=this.createArgument(e,t);return"function"==typeof n?i.default(r).argParser(n):i.default(n),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(e){const t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&void 0!==e.defaultValue&&void 0===e.parseArg)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if("boolean"==typeof e)return this._addImplicitHelpCommand=e,this;e=e??"help [command]";const[,n,r]=e.match(/([^ ]+) *(.*)/),i=t??"display help for command",o=this.createCommand(n);return o.helpOption(!1),r&&o.arguments(r),i&&o.description(i),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(e,t){return"object"!=typeof e?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(void 0===this._helpCommand&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){const n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return this._exitCallback=e||(e=>{if("commander.executeSubCommandAsync"!==e.code)throw e}),this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new Ae(e,t,n)),Ce.exit(e)}action(e){return this._actionHandler=t=>{const n=this.registeredArguments.length,r=t.slice(0,n);return this._storeOptionsAsProperties?r[n]=this:r[n]=this.opts(),r.push(this),e.apply(this,r)},this}createOption(e,t){return new ke(e,t)}_callParseArg(e,t,n,r){try{return e.parseArg(t,n)}catch(e){if("commander.invalidArgument"===e.code){const t=`${r} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}_registerOption(e){const t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){const n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'\n- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){const t=e=>[e.name()].concat(e.aliases()),n=t(e).find(e=>this._findCommand(e));if(n){const r=t(this._findCommand(n)).join("|"),i=t(e).join("|");throw new Error(`cannot add command '${i}' as already have command '${r}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);const t=e.name(),n=e.attributeName();if(e.negate){const t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(n,void 0===e.defaultValue||e.defaultValue,"default")}else void 0!==e.defaultValue&&this.setOptionValueWithSource(n,e.defaultValue,"default");const r=(t,r,i)=>{null==t&&void 0!==e.presetArg&&(t=e.presetArg);const o=this.getOptionValue(n);null!==t&&e.parseArg?t=this._callParseArg(e,t,o,r):null!==t&&e.variadic&&(t=e._concatValue(t,o)),null==t&&(t=!e.negate&&(!(!e.isBoolean()&&!e.optional)||"")),this.setOptionValueWithSource(n,t,i)};return this.on("option:"+t,t=>{const n=`error: option '${e.flags}' argument '${t}' is invalid.`;r(t,n,"cli")}),e.envVar&&this.on("optionEnv:"+t,t=>{const n=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;r(t,n,"env")}),this}_optionEx(e,t,n,r,i){if("object"==typeof t&&t instanceof ke)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const o=this.createOption(t,n);if(o.makeOptionMandatory(!!e.mandatory),"function"==typeof r)o.default(i).argParser(r);else if(r instanceof RegExp){const e=r;r=(t,n)=>{const r=e.exec(t);return r?r[0]:n},o.default(i).argParser(r)}else o.default(r);return this.addOption(o)}option(e,t,n,r){return this._optionEx({},e,t,n,r)}requiredOption(e,t,n,r){return this._optionEx({mandatory:!0},e,t,n,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{void 0!==n.getOptionValueSource(e)&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(void 0!==e&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},void 0===e&&void 0===t.from){Ce.versions?.electron&&(t.from="electron");const e=Ce.execArgv??[];(e.includes("-e")||e.includes("--eval")||e.includes("-p")||e.includes("--print"))&&(t.from="eval")}let n;switch(void 0===e&&(e=Ce.argv),this.rawArgs=e.slice(),t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":Ce.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){this._prepareForParse();const n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();const n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){null===this._savedState?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error("Can not call parse again when storeOptionsAsProperties is true.\n- either make a new Command for each call to parse, or stop storing options as properties");this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(!Oe.existsSync(e))throw new Error(`'${e}' does not exist\n - if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory"}`)}_executeSubCommand(e,t){t=t.slice();let n=!1;const r=[".js",".ts",".tsx",".mjs",".cjs"];function i(e,t){const n=xe.resolve(e,t);if(Oe.existsSync(n))return n;if(r.includes(xe.extname(t)))return;const i=r.find(e=>Oe.existsSync(`${n}${e}`));return i?`${n}${i}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o,s=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let e;try{e=Oe.realpathSync(this._scriptPath)}catch{e=this._scriptPath}a=xe.resolve(xe.dirname(e),a)}if(a){let t=i(a,s);if(!t&&!e._executableFile&&this._scriptPath){const n=xe.basename(this._scriptPath,xe.extname(this._scriptPath));n!==this._name&&(t=i(a,`${n}-${e._name}`))}s=t||s}n=r.includes(xe.extname(s)),"win32"!==Ce.platform?n?(t.unshift(s),t=Ne(Ce.execArgv).concat(t),o=Ee.spawn(Ce.argv[0],t,{stdio:"inherit"})):o=Ee.spawn(s,t,{stdio:"inherit"}):(this._checkForMissingExecutable(s,a,e._name),t.unshift(s),t=Ne(Ce.execArgv).concat(t),o=Ee.spawn(Ce.execPath,t,{stdio:"inherit"})),o.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(e=>{Ce.on(e,()=>{!1===o.killed&&null===o.exitCode&&o.kill(e)})});const l=this._exitCallback;o.on("close",e=>{e=e??1,l?l(new Ae(e,"commander.executeSubCommandAsync","(close)")):Ce.exit(e)}),o.on("error",t=>{if("ENOENT"===t.code)this._checkForMissingExecutable(s,a,e._name);else if("EACCES"===t.code)throw new Error(`'${s}' not executable`);if(l){const e=new Ae(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,l(e)}else Ce.exit(1)}),this.runningCommand=o}_dispatchSubcommand(e,t,n){const r=this._findCommand(e);let i;return r||this.help({error:!0}),r._prepareForParse(),i=this._chainOrCallSubCommandHook(i,r,"preSubcommand"),i=this._chainOrCall(i,()=>{if(!r._executableHandler)return r._parseCommand(t,n);this._executeSubCommand(r,t.concat(n))}),i}_dispatchHelpCommand(e){e||this.help();const t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&null==this.args[t]&&this.missingArgument(e.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const e=(e,t,n)=>{let r=t;if(null!==t&&e.parseArg){const i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):void 0===i&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&"function"==typeof e.then?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e;const r=[];return this._getCommandAndAncestors().reverse().filter(e=>void 0!==e._lifeCycleHooks[t]).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),"postAction"===t&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return void 0!==this._lifeCycleHooks[n]&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){const n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){let n;return r(),this._processArguments(),n=this._chainOrCallHooks(n,"preAction"),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,"postAction"),n}if(this.parent&&this.parent.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&void 0===e.getOptionValue(t.attributeName())&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){const e=this.options.filter(e=>{const t=e.attributeName();return void 0!==this.getOptionValue(t)&&"default"!==this.getOptionValueSource(t)}),t=e.filter(e=>e.conflictsWith.length>0);t.forEach(t=>{const n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){const t=[],n=[];let r=t;const i=e.slice();function o(e){return e.length>1&&"-"===e[0]}let s=null;for(;i.length;){const e=i.shift();if("--"===e){r===n&&r.push(e),r.push(...i);break}if(!s||o(e)){if(s=null,o(e)){const t=this._findOption(e);if(t){if(t.required){const e=i.shift();void 0===e&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,e)}else if(t.optional){let e=null;i.length>0&&!o(i[0])&&(e=i.shift()),this.emit(`option:${t.name()}`,e)}else this.emit(`option:${t.name()}`);s=t.variadic?t:null;continue}}if(e.length>2&&"-"===e[0]&&"-"!==e[1]){const t=this._findOption(`-${e[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,e.slice(2)):(this.emit(`option:${t.name()}`),i.unshift(`-${e.slice(2)}`));continue}}if(/^--[^=]+=/.test(e)){const t=e.indexOf("="),n=this._findOption(e.slice(0,t));if(n&&(n.required||n.optional)){this.emit(`option:${n.name()}`,e.slice(t+1));continue}}if(o(e)&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&0===t.length&&0===n.length){if(this._findCommand(e)){t.push(e),i.length>0&&n.push(...i);break}if(this._getHelpCommand()&&e===this._getHelpCommand().name()){t.push(e),i.length>0&&t.push(...i);break}if(this._defaultCommandName){n.push(e),i.length>0&&n.push(...i);break}}if(this._passThroughOptions){r.push(e),i.length>0&&r.push(...i);break}r.push(e)}else this.emit(`option:${s.name()}`,e)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){const e={},t=this.options.length;for(let n=0;n<t;n++){const t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0}));const n=t||{},r=n.exitCode||1,i=n.code||"commander.error";this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in Ce.env){const t=e.attributeName();(void 0===this.getOptionValue(t)||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,Ce.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){const e=new Me(this.options),t=e=>void 0!==this.getOptionValue(e)&&!["default","implied"].includes(this.getOptionValueSource(e));this.options.filter(n=>void 0!==n.implied&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],"implied")})})}missingArgument(e){const t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){const t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){const t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){const n=e=>{const t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(void 0===r.presetArg&&!1===n||void 0!==r.presetArg&&n===r.presetArg)?r:i||e},r=e=>{const t=n(e),r=t.attributeName();return"env"===this.getOptionValueSource(r)?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],r=this;do{const e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=je(e,n)}const n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;const t=this.registeredArguments.length,n=1===t?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=je(e,n)}const n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(void 0===e)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";const r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,"commander.version",e)}),this}description(e,t){return void 0===e&&void 0===t?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return void 0===e?this._summary:(this._summary=e,this)}alias(e){if(void 0===e)return this._aliases[0];let t=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");const n=this.parent?._findCommand(e);if(n){const t=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return void 0===e?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(void 0===e){if(this._usage)return this._usage;const e=this.registeredArguments.map(e=>Te(e));return[].concat(this.options.length||null!==this._helpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=e,this}name(e){return void 0===e?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=xe.basename(e,xe.extname(e)),this}executableDir(e){return void 0===e?this._executableDir:(this._executableDir=e,this)}helpInformation(e){const t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});const r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){const t=!!(e=e||{}).error;let n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;"function"==typeof e&&(t=e,e=void 0);const n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),"string"!=typeof i&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(e=>e.emit("afterAllHelp",r))}helpOption(e,t){return"boolean"==typeof e?(this._helpOption=e?this._helpOption??void 0:null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return void 0===this._helpOption&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=Number(Ce.exitCode??0);0===t&&e&&"function"!=typeof e&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${n.join("', '")}'`);const r=`${e}Help`;return this.on(r,e=>{let n;n="function"==typeof t?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){const t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}},he.useColor=Pe;const{Argument:Re}=de,{Command:Le}=he,{CommanderError:Be,InvalidArgumentError:Fe}=ue,{Help:Ue}=fe,{Option:He}=we;ce.program=new Le,ce.createCommand=e=>new Le(e),ce.createOption=(e,t)=>new He(e,t),ce.createArgument=(e,t)=>new Re(e,t),ce.Command=Le,ce.Option=He,ce.Argument=Re,ce.Help=Ue,ce.CommanderError=Be,ce.InvalidArgumentError=Fe,ce.InvalidOptionArgumentError=Fe;const{Command:We}=ce;function Ge(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}const Ve=(e,t)=>{const n=ze(qe(e));if("string"!=typeof n)throw new TypeError(`${t} must be a string or a file URL: ${n}.`);return n},qe=e=>Ke(e)?e.toString():e,Ke=e=>"string"!=typeof e&&e&&Object.getPrototypeOf(e)===String.prototype,ze=e=>e instanceof URL?A(e):e,Ye=(e,t=[],n={})=>{const r=Ve(e,"First argument"),[i,o]=Ge(t)?[[],t]:[t,n];if(!Array.isArray(i))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${i}`);if(i.some(e=>"object"==typeof e&&null!==e))throw new TypeError(`Second argument must be an array of strings: ${i}`);const s=i.map(String),a=s.find(e=>e.includes("\0"));if(void 0!==a)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${a}`);if(!Ge(o))throw new TypeError(`Last argument must be an options object: ${o}`);return[r,s,o]},{toString:Je}=Object.prototype,Xe=e=>"[object Uint8Array]"===Je.call(e),Qe=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Ze=new TextEncoder,et=e=>Ze.encode(e),tt=new TextDecoder,nt=e=>tt.decode(e),rt=e=>1===e.length&&Xe(e[0])?e[0]:ot(it(e)),it=e=>e.map(e=>"string"==typeof e?et(e):e),ot=e=>{const t=new Uint8Array(st(e));let n=0;for(const r of e)t.set(r,n),n+=r.length;return t},st=e=>{let t=0;for(const n of e)t+=n.length;return t},at=({templates:e,expressions:t,tokens:n,index:r,template:i})=>{if(void 0===i)throw new TypeError(`Invalid backslash sequence: ${e.raw[r]}`);const{nextTokens:o,leadingWhitespaces:s,trailingWhitespaces:a}=lt(i,e.raw[r]),l=ut(n,o,s);if(r===t.length)return l;const c=t[r],d=Array.isArray(c)?c.map(e=>pt(e)):[pt(c)];return ut(l,d,a)},lt=(e,t)=>{if(0===t.length)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};const n=[];let r=0;const i=ct.has(t[0]);for(let i=0,o=0;i<e.length;i+=1,o+=1){const s=t[o];if(ct.has(s))r!==i&&n.push(e.slice(r,i)),r=i+1;else if("\\"===s){const e=t[o+1];"\n"===e?(i-=1,o+=1):"u"===e&&"{"===t[o+2]?o=t.indexOf("}",o+3):o+=dt[e]??1}}const o=r===e.length;return o||n.push(e.slice(r)),{nextTokens:n,leadingWhitespaces:i,trailingWhitespaces:o}},ct=new Set([" ","\t","\r","\n"]),dt={x:3,u:5},ut=(e,t,n)=>n||0===e.length||0===t.length?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],pt=e=>{const t=typeof e;if("string"===t)return e;if("number"===t)return String(e);if(Ge(e)&&("stdout"in e||"isMaxBuffer"in e))return mt(e);if(e instanceof l||"[object Promise]"===Object.prototype.toString.call(e))throw new TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}.");throw new TypeError(`Unexpected "${t}" in template expression`)},mt=({stdout:e})=>{if("string"==typeof e)return e;if(Xe(e))return nt(e);if(void 0===e)throw new TypeError('Missing result.stdout in template expression. This is probably due to the previous subprocess\' "stdout" option.');throw new TypeError(`Unexpected "${typeof e}" stdout in template expression`)},ht=e=>ft.includes(e),ft=[v.stdin,v.stdout,v.stderr],gt=["stdin","stdout","stderr"],bt=e=>gt[e]??`stdio[${e}]`,wt=(e,t)=>{const n=Array.from({length:yt(e)+1}),r=vt(e[t],n,t);return _t(r,t)},yt=({stdio:e})=>Array.isArray(e)?Math.max(e.length,gt.length):gt.length,vt=(e,t,n)=>Ge(e)?$t(e,t,n):t.fill(e),$t=(e,t,n)=>{for(const r of Object.keys(e).sort(St))for(const i of xt(r,n,t))t[i]=e[r];return t},St=(e,t)=>Et(e)<Et(t)?1:-1,Et=e=>"stdout"===e||"stderr"===e?0:"all"===e?2:1,xt=(e,t,n)=>{if("ipc"===e)return[n.length-1];const r=Ot(e);if(void 0===r||0===r)throw new TypeError(`"${t}.${e}" is invalid.\nIt must be "${t}.stdout", "${t}.stderr", "${t}.all", "${t}.ipc", or "${t}.fd3", "${t}.fd4" (and so on).`);if(r>=n.length)throw new TypeError(`"${t}.${e}" is invalid: that file descriptor does not exist.\nPlease set the "stdio" option to ensure that file descriptor exists.`);return"all"===r?[1,2]:[r]},Ot=e=>{if("all"===e)return e;if(gt.includes(e))return gt.indexOf(e);const t=Ct.exec(e);return null!==t?Number(t[1]):void 0},Ct=/^fd(\d+)$/,_t=(e,t)=>e.map(e=>void 0===e?Tt[t]:e),Tt={lines:!1,buffer:!0,maxBuffer:1e8,verbose:D("execa").enabled?"full":"none",stripFinalNewline:!0},At=["lines","buffer","maxBuffer","verbose","stripFinalNewline"],It=(e,t)=>"ipc"===t?e.at(-1):e[t],Dt=({verbose:e},t)=>"none"!==Mt(e,t),kt=({verbose:e},t)=>!["none","short"].includes(Mt(e,t)),Mt=(e,t)=>void 0===t?jt(e):It(e,t),jt=e=>e.find(e=>Nt(e))??Pt.findLast(t=>e.includes(t)),Nt=e=>"function"==typeof e,Pt=["none","short","full"],Rt=e=>k(e).split("\n").map(e=>Lt(e)).join("\n"),Lt=e=>e.replaceAll(Ft,e=>Bt(e)),Bt=e=>{const t=Ut[e];if(void 0!==t)return t;const n=e.codePointAt(0),r=n.toString(16);return n<=Ht?`\\u${r.padStart(4,"0")}`:`\\U${r}`},Ft=(()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}})(),Ut={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},Ht=65535,Wt=/^[\w./-]+$/,Gt={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"█",squareDarkShade:"▓",squareMediumShade:"▒",squareLightShade:"░",squareTop:"▀",squareBottom:"▄",squareLeft:"▌",squareRight:"▐",squareCenter:"■",bullet:"●",dot:"․",ellipsis:"…",pointerSmall:"›",triangleUp:"▲",triangleUpSmall:"▴",triangleDown:"▼",triangleDownSmall:"▾",triangleLeftSmall:"◂",triangleRightSmall:"▸",home:"⌂",heart:"♥",musicNote:"♪",musicNoteBeamed:"♫",arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",arrowLeftRight:"↔",arrowUpDown:"↕",almostEqual:"≈",notEqual:"≠",lessOrEqual:"≤",greaterOrEqual:"≥",identical:"≡",infinity:"∞",subscriptZero:"₀",subscriptOne:"₁",subscriptTwo:"₂",subscriptThree:"₃",subscriptFour:"₄",subscriptFive:"₅",subscriptSix:"₆",subscriptSeven:"₇",subscriptEight:"₈",subscriptNine:"₉",oneHalf:"½",oneThird:"⅓",oneQuarter:"¼",oneFifth:"⅕",oneSixth:"⅙",oneEighth:"⅛",twoThirds:"⅔",twoFifths:"⅖",threeQuarters:"¾",threeFifths:"⅗",threeEighths:"⅜",fourFifths:"⅘",fiveSixths:"⅚",fiveEighths:"⅝",sevenEighths:"⅞",line:"─",lineBold:"━",lineDouble:"═",lineDashed0:"┄",lineDashed1:"┅",lineDashed2:"┈",lineDashed3:"┉",lineDashed4:"╌",lineDashed5:"╍",lineDashed6:"╴",lineDashed7:"╶",lineDashed8:"╸",lineDashed9:"╺",lineDashed10:"╼",lineDashed11:"╾",lineDashed12:"−",lineDashed13:"–",lineDashed14:"‐",lineDashed15:"⁃",lineVertical:"│",lineVerticalBold:"┃",lineVerticalDouble:"║",lineVerticalDashed0:"┆",lineVerticalDashed1:"┇",lineVerticalDashed2:"┊",lineVerticalDashed3:"┋",lineVerticalDashed4:"╎",lineVerticalDashed5:"╏",lineVerticalDashed6:"╵",lineVerticalDashed7:"╷",lineVerticalDashed8:"╹",lineVerticalDashed9:"╻",lineVerticalDashed10:"╽",lineVerticalDashed11:"╿",lineDownLeft:"┐",lineDownLeftArc:"╮",lineDownBoldLeftBold:"┓",lineDownBoldLeft:"┒",lineDownLeftBold:"┑",lineDownDoubleLeftDouble:"╗",lineDownDoubleLeft:"╖",lineDownLeftDouble:"╕",lineDownRight:"┌",lineDownRightArc:"╭",lineDownBoldRightBold:"┏",lineDownBoldRight:"┎",lineDownRightBold:"┍",lineDownDoubleRightDouble:"╔",lineDownDoubleRight:"╓",lineDownRightDouble:"╒",lineUpLeft:"┘",lineUpLeftArc:"╯",lineUpBoldLeftBold:"┛",lineUpBoldLeft:"┚",lineUpLeftBold:"┙",lineUpDoubleLeftDouble:"╝",lineUpDoubleLeft:"╜",lineUpLeftDouble:"╛",lineUpRight:"└",lineUpRightArc:"╰",lineUpBoldRightBold:"┗",lineUpBoldRight:"┖",lineUpRightBold:"┕",lineUpDoubleRightDouble:"╚",lineUpDoubleRight:"╙",lineUpRightDouble:"╘",lineUpDownLeft:"┤",lineUpBoldDownBoldLeftBold:"┫",lineUpBoldDownBoldLeft:"┨",lineUpDownLeftBold:"┥",lineUpBoldDownLeftBold:"┩",lineUpDownBoldLeftBold:"┪",lineUpDownBoldLeft:"┧",lineUpBoldDownLeft:"┦",lineUpDoubleDownDoubleLeftDouble:"╣",lineUpDoubleDownDoubleLeft:"╢",lineUpDownLeftDouble:"╡",lineUpDownRight:"├",lineUpBoldDownBoldRightBold:"┣",lineUpBoldDownBoldRight:"┠",lineUpDownRightBold:"┝",lineUpBoldDownRightBold:"┡",lineUpDownBoldRightBold:"┢",lineUpDownBoldRight:"┟",lineUpBoldDownRight:"┞",lineUpDoubleDownDoubleRightDouble:"╠",lineUpDoubleDownDoubleRight:"╟",lineUpDownRightDouble:"╞",lineDownLeftRight:"┬",lineDownBoldLeftBoldRightBold:"┳",lineDownLeftBoldRightBold:"┯",lineDownBoldLeftRight:"┰",lineDownBoldLeftBoldRight:"┱",lineDownBoldLeftRightBold:"┲",lineDownLeftRightBold:"┮",lineDownLeftBoldRight:"┭",lineDownDoubleLeftDoubleRightDouble:"╦",lineDownDoubleLeftRight:"╥",lineDownLeftDoubleRightDouble:"╤",lineUpLeftRight:"┴",lineUpBoldLeftBoldRightBold:"┻",lineUpLeftBoldRightBold:"┷",lineUpBoldLeftRight:"┸",lineUpBoldLeftBoldRight:"┹",lineUpBoldLeftRightBold:"┺",lineUpLeftRightBold:"┶",lineUpLeftBoldRight:"┵",lineUpDoubleLeftDoubleRightDouble:"╩",lineUpDoubleLeftRight:"╨",lineUpLeftDoubleRightDouble:"╧",lineUpDownLeftRight:"┼",lineUpBoldDownBoldLeftBoldRightBold:"╋",lineUpDownBoldLeftBoldRightBold:"╈",lineUpBoldDownLeftBoldRightBold:"╇",lineUpBoldDownBoldLeftRightBold:"╊",lineUpBoldDownBoldLeftBoldRight:"╉",lineUpBoldDownLeftRight:"╀",lineUpDownBoldLeftRight:"╁",lineUpDownLeftBoldRight:"┽",lineUpDownLeftRightBold:"┾",lineUpBoldDownBoldLeftRight:"╂",lineUpDownLeftBoldRightBold:"┿",lineUpBoldDownLeftBoldRight:"╃",lineUpBoldDownLeftRightBold:"╄",lineUpDownBoldLeftBoldRight:"╅",lineUpDownBoldLeftRightBold:"╆",lineUpDoubleDownDoubleLeftDoubleRightDouble:"╬",lineUpDoubleDownDoubleLeftRight:"╫",lineUpDownLeftDoubleRightDouble:"╪",lineCross:"╳",lineBackslash:"╲",lineSlash:"╱"},Vt={...Gt,tick:"✔",info:"ℹ",warning:"⚠",cross:"✘",squareSmall:"◻",squareSmallFilled:"◼",circle:"◯",circleFilled:"◉",circleDotted:"◌",circleDouble:"◎",circleCircle:"ⓞ",circleCross:"ⓧ",circlePipe:"Ⓘ",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",checkboxCircleOn:"ⓧ",checkboxCircleOff:"Ⓘ",pointer:"❯",triangleUpOutline:"△",triangleLeft:"◀",triangleRight:"▶",lozenge:"◆",lozengeOutline:"◇",hamburger:"☰",smiley:"㋡",mustache:"෴",star:"★",play:"▶",nodejs:"⬢",oneSeventh:"⅐",oneNinth:"⅑",oneTenth:"⅒"},qt={...Gt,tick:"√",info:"i",warning:"‼",cross:"×",squareSmall:"□",squareSmallFilled:"■",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(○)",circleCross:"(×)",circlePipe:"(│)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[×]",checkboxOff:"[ ]",checkboxCircleOn:"(×)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"∆",triangleLeft:"◄",triangleRight:"►",lozenge:"♦",lozengeOutline:"◊",hamburger:"≡",smiley:"☺",mustache:"┌─┐",star:"✶",play:"►",nodejs:"♦",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},Kt=function(){const{env:e}=v,{TERM:t,TERM_PROGRAM:n}=e;return"win32"!==v.platform?"linux"!==t:Boolean(e.WT_SESSION)||Boolean(e.TERMINUS_SUBLIME)||"{cmd::Cmder}"===e.ConEmuTask||"Terminus-Sublime"===n||"vscode"===n||"xterm-256color"===t||"alacritty"===t||"rxvt-unicode"===t||"rxvt-unicode-256color"===t||"JetBrains-JediTerm"===e.TERMINAL_EMULATOR}()?Vt:qt,zt=L?.WriteStream?.prototype?.hasColors?.()??!1,Yt=(e,t)=>{if(!zt)return e=>e;const n=`[${e}m`,r=`[${t}m`;return e=>{const i=e+"";let o=i.indexOf(r);if(-1===o)return n+i+r;let s=n,a=0;const l=(22===t?r:"")+n;for(;-1!==o;)s+=i.slice(a,o)+l,a=o+r.length,o=i.indexOf(r,a);return s+=i.slice(a)+r,s}},Jt=Yt(1,22),Xt=Yt(90,39),Qt=Yt(91,39),Zt=Yt(93,39),en=(e,t)=>String(e).padStart(t,"0"),tn=({failed:e,reject:t})=>e?t?Kt.cross:Kt.warning:Kt.tick,nn={command:({piped:e})=>e?"|":"$",output:()=>" ",ipc:()=>"*",error:tn,duration:tn},rn=e=>e,on={command:()=>Jt,output:()=>rn,ipc:()=>rn,error:({reject:e})=>e?Qt:Zt,duration:()=>Xt},sn=(e,t,n)=>{if(void 0===n)return e;const r=n(e,t);return"string"==typeof r?r:void 0},an=e=>e.endsWith("\n")?e:`${e}\n`,ln=({type:e,verboseMessage:t,fdNumber:n,verboseInfo:r,result:i})=>{const o=cn({type:e,result:i,verboseInfo:r}),s=((e,t,n)=>{const r=(({verbose:e},t)=>{const n=Mt(e,t);return Nt(n)?n:void 0})(t,n);return e.map(({verboseLine:e,verboseObject:t})=>sn(e,t,r)).filter(e=>void 0!==e).map(e=>an(e)).join("")})(dn(t,o),r,n);""!==s&&console.warn(s.slice(0,-1))},cn=({type:e,result:t,verboseInfo:{escapedCommand:n,commandId:r,rawOptions:{piped:i=!1,...o}}})=>({type:e,escapedCommand:n,commandId:`${r}`,timestamp:new Date,piped:i,result:t,options:o}),dn=(e,t)=>e.split("\n").map(e=>un({...t,message:e})),un=e=>({verboseLine:(({type:e,message:t,timestamp:n,piped:r,commandId:i,result:{failed:o=!1}={},options:{reject:s=!0}})=>{const a=(e=>`${en(e.getHours(),2)}:${en(e.getMinutes(),2)}:${en(e.getSeconds(),2)}.${en(e.getMilliseconds(),3)}`)(n),l=nn[e]({failed:o,reject:s,piped:r}),c=on[e]({reject:s});return`${Xt(`[${a}]`)} ${Xt(`[${i}]`)} ${c(l)} ${c(t)}`})(e),verboseObject:e}),pn=e=>{const t="string"==typeof e?e:M(e);return Rt(t).replaceAll("\t"," ".repeat(mn))},mn=2,hn=e=>Dt({verbose:e})?fn++:void 0;let fn=0n;const gn=()=>S.bigint(),bn=e=>Number(S.bigint()-e)/1e6,wn=(e,t,n)=>{const r=gn(),{command:i,escapedCommand:o}=((e,t)=>{const n=[e,...t];return{command:n.join(" "),escapedCommand:n.map(e=>{return t=Lt(e),Wt.test(t)?t:"win32"===$?`"${t.replaceAll('"','""')}"`:`'${t.replaceAll("'","'\\''")}'`;var t}).join(" ")}})(e,t),s=((e,t,n)=>((e=>{for(const t of e){if(!1===t)throw new TypeError('The "verbose: false" option was renamed to "verbose: \'none\'".');if(!0===t)throw new TypeError('The "verbose: true" option was renamed to "verbose: \'short\'".');if(!Pt.includes(t)&&!Nt(t)){const e=Pt.map(e=>`'${e}'`).join(", ");throw new TypeError(`The "verbose" option must not be ${t}. Allowed values are: ${e} or a function.`)}}})(e),{verbose:e,escapedCommand:t,commandId:hn(e),rawOptions:n}))(wt(n,"verbose"),o,{...n});return((e,t)=>{Dt(t)&&ln({type:"command",verboseMessage:e,verboseInfo:t})})(o,s),{command:i,escapedCommand:o,startTime:r,verboseInfo:s}};var yn,vn,$n,Sn,En,xn={exports:{}};En="win32"===process.platform||ae.TESTING_WINDOWS?function(){if(vn)return yn;vn=1,yn=n,n.sync=function(n,r){return t(e.statSync(n),n,r)};var e=U;function t(e,t,n){return!(!e.isSymbolicLink()&&!e.isFile())&&function(e,t){var n=void 0!==t.pathExt?t.pathExt:process.env.PATHEXT;if(!n)return!0;if(-1!==(n=n.split(";")).indexOf(""))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}(t,n)}function n(n,r,i){e.stat(n,function(e,o){i(e,!e&&t(o,n,r))})}return yn}():function(){if(Sn)return $n;Sn=1,$n=t,t.sync=function(t,r){return n(e.statSync(t),r)};var e=U;function t(t,r,i){e.stat(t,function(e,t){i(e,!e&&n(t,r))})}function n(e,t){return e.isFile()&&function(e,t){var n=e.mode,r=e.uid,i=e.gid,o=void 0!==t.uid?t.uid:process.getuid&&process.getuid(),s=void 0!==t.gid?t.gid:process.getgid&&process.getgid(),a=parseInt("100",8),l=parseInt("010",8);return n&parseInt("001",8)||n&l&&i===s||n&a&&r===o||n&(a|l)&&0===o}(e,t)}return $n}();var On=Cn;function Cn(e,t,n){if("function"==typeof t&&(n=t,t={}),!n){if("function"!=typeof Promise)throw new TypeError("callback not provided");return new Promise(function(n,r){Cn(e,t||{},function(e,t){e?r(e):n(t)})})}En(e,t||{},function(e,r){e&&("EACCES"===e.code||t&&t.ignoreErrors)&&(e=null,r=!1),n(e,r)})}Cn.sync=function(e,t){try{return En.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||"EACCES"===e.code)return!1;throw e}};const _n="win32"===process.platform||"cygwin"===process.env.OSTYPE||"msys"===process.env.OSTYPE,Tn=F,An=_n?";":":",In=On,Dn=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),kn=(e,t)=>{const n=t.colon||An,r=e.match(/\//)||_n&&e.match(/\\/)?[""]:[..._n?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(n)],i=_n?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=_n?i.split(n):[""];return _n&&-1!==e.indexOf(".")&&""!==o[0]&&o.unshift(""),{pathEnv:r,pathExt:o,pathExtExe:i}},Mn=(e,t,n)=>{"function"==typeof t&&(n=t,t={}),t||(t={});const{pathEnv:r,pathExt:i,pathExtExe:o}=kn(e,t),s=[],a=n=>new Promise((i,o)=>{if(n===r.length)return t.all&&s.length?i(s):o(Dn(e));const a=r[n],c=/^".*"$/.test(a)?a.slice(1,-1):a,d=Tn.join(c,e),u=!c&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;i(l(u,n,0))}),l=(e,n,r)=>new Promise((c,d)=>{if(r===i.length)return c(a(n+1));const u=i[r];In(e+u,{pathExt:o},(i,o)=>{if(!i&&o){if(!t.all)return c(e+u);s.push(e+u)}return c(l(e,n,r+1))})});return n?a(0).then(e=>n(null,e),n):a(0)};var jn=Mn;Mn.sync=(e,t)=>{t=t||{};const{pathEnv:n,pathExt:r,pathExtExe:i}=kn(e,t),o=[];for(let s=0;s<n.length;s++){const a=n[s],l=/^".*"$/.test(a)?a.slice(1,-1):a,c=Tn.join(l,e),d=!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+c:c;for(let e=0;e<r.length;e++){const n=d+r[e];try{if(In.sync(n,{pathExt:i})){if(!t.all)return n;o.push(n)}}catch(e){}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw Dn(e)};var Nn={exports:{}};const Pn=(e={})=>{const t=e.env||process.env;return"win32"!==(e.platform||process.platform)?"PATH":Object.keys(t).reverse().find(e=>"PATH"===e.toUpperCase())||"Path"};Nn.exports=Pn,Nn.exports.default=Pn;var Rn=Nn.exports;const Ln=F,Bn=jn,Fn=Rn;function Un(e,t){const n=e.options.env||process.env,r=process.cwd(),i=null!=e.options.cwd,o=i&&void 0!==process.chdir&&!process.chdir.disabled;if(o)try{process.chdir(e.options.cwd)}catch(e){}let s;try{s=Bn.sync(e.command,{path:n[Fn({env:n})],pathExt:t?Ln.delimiter:void 0})}catch(e){}finally{o&&process.chdir(r)}return s&&(s=Ln.resolve(i?e.options.cwd:"",s)),s}var Hn={};const Wn=/([()\][%!^"`<>&|;, *?])/g;Hn.command=function(e){return e.replace(Wn,"^$1")},Hn.argument=function(e,t){return e=(e=`"${e=(e=(e=`${e}`).replace(/(?=(\\+?)?)\1"/g,'$1$1\\"')).replace(/(?=(\\+?)?)\1$/,"$1$1")}"`).replace(Wn,"^$1"),t&&(e=e.replace(Wn,"^$1")),e};const Gn=/^#!(.*)/,Vn=U;const qn=F,Kn=function(e){return Un(e)||Un(e,!0)},zn=Hn,Yn=function(e){const t=Buffer.alloc(150);let n;try{n=Vn.openSync(e,"r"),Vn.readSync(n,t,0,150,0),Vn.closeSync(n)}catch(e){}return((e="")=>{const t=e.match(Gn);if(!t)return null;const[n,r]=t[0].replace(/#! ?/,"").split(" "),i=n.split("/").pop();return"env"===i?r:r?`${i} ${r}`:i})(t.toString())},Jn="win32"===process.platform,Xn=/\.(?:com|exe)$/i,Qn=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;const Zn="win32"===process.platform;function er(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function tr(e,t){return Zn&&1===e&&!t.file?er(t.original,"spawn"):null}var nr={hookChildProcess:function(e,t){if(!Zn)return;const n=e.emit;e.emit=function(r,i){if("exit"===r){const r=tr(i,t);if(r)return n.call(e,"error",r)}return n.apply(e,arguments)}},verifyENOENT:tr,verifyENOENTSync:function(e,t){return Zn&&1===e&&!t.file?er(t.original,"spawnSync"):null},notFoundError:er};const rr=_,ir=function(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null);const r={command:e,args:t=t?t.slice(0):[],options:n=Object.assign({},n),file:void 0,original:{command:e,args:t}};return n.shell?r:function(e){if(!Jn)return e;const t=function(e){e.file=Kn(e);const t=e.file&&Yn(e.file);return t?(e.args.unshift(e.file),e.command=t,Kn(e)):e.file}(e),n=!Xn.test(t);if(e.options.forceShell||n){const n=Qn.test(t);e.command=qn.normalize(e.command),e.command=zn.command(e.command),e.args=e.args.map(e=>zn.argument(e,n));const r=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${r}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}(r)},or=nr;function sr(e,t,n){const r=ir(e,t,n),i=rr.spawn(r.command,r.args,r.options);return or.hookChildProcess(i,r),i}xn.exports=sr,xn.exports.spawn=sr,xn.exports.sync=function(e,t,n){const r=ir(e,t,n),i=rr.spawnSync(r.command,r.args,r.options);return i.error=i.error||or.verifyENOENTSync(i.status,r),i},xn.exports._parse=ir,xn.exports._enoent=or;const ar=le(xn.exports);function lr(e={}){const{env:t=process.env,platform:n=process.platform}=e;return"win32"!==n?"PATH":Object.keys(t).reverse().find(e=>"PATH"===e.toUpperCase())||"Path"}const cr=({env:e=v.env,...t}={})=>{const n=lr({env:e={...e}});return t.path=e[n],e[n]=(({cwd:e=v.cwd(),path:t=v.env[lr()],preferLocal:n=!0,execPath:r=v.execPath,addExecPath:i=!0}={})=>{const o=u.resolve(H(e)),s=[],a=t.split(u.delimiter);return n&&((e,t,n)=>{for(const r of W(n)){const n=u.join(r,"node_modules/.bin");t.includes(n)||e.push(n)}})(s,a,o),i&&((e,t,n,r)=>{const i=u.resolve(r,H(n),"..");t.includes(i)||e.push(i)})(s,a,r,o),""===t||t===u.delimiter?`${s.join(u.delimiter)}${t}`:[...s,t].join(u.delimiter)})(t),e};class dr extends Error{}const ur=(e,t)=>{Object.defineProperty(e.prototype,"name",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,pr,{value:!0,writable:!1,enumerable:!1,configurable:!1})},pr=Symbol("isExecaError"),mr=e=>"[object Error]"===Object.prototype.toString.call(e);class hr extends Error{}ur(hr,hr.name);class fr extends Error{}ur(fr,fr.name);const gr=(e,t)=>({name:`SIGRT${t+1}`,number:br+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),br=34,wr=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}],yr=()=>{const e=(()=>{const e=64-br+1;return Array.from({length:e},gr)})();return[...wr,...e].map(vr)},vr=({name:e,number:t,description:n,action:r,forced:i=!1,standard:o})=>{const{signals:{[e]:s}}=K,a=void 0!==s;return{name:e,number:a?s:t,description:n,supported:a,action:r,forced:i,standard:o}},$r=({name:e,number:t,description:n,supported:r,action:i,forced:o,standard:s})=>[e,{name:e,number:t,description:n,supported:r,action:i,forced:o,standard:s}],Sr=(()=>{const e=yr();return Object.fromEntries(e.map($r))})(),Er=(e,t)=>{const n=t.find(({name:t})=>K.signals[t]===e);return void 0!==n?n:t.find(t=>t.number===e)};(()=>{const e=yr(),t=Array.from({length:65},(t,n)=>((e,t)=>{const n=Er(e,t);if(void 0===n)return{};const{name:r,description:i,supported:o,action:s,forced:a,standard:l}=n;return{[e]:{name:r,number:e,description:i,supported:o,action:s,forced:a,standard:l}}})(n,e));Object.assign({},...t)})();const xr=e=>0===e?e:Or(e,"`subprocess.kill()`'s argument"),Or=(e,t)=>{if(Number.isInteger(e))return Cr(e,t);if("string"==typeof e)return Tr(e,t);throw new TypeError(`Invalid ${t} ${String(e)}: it must be a string or an integer.\n${Ar()}`)},Cr=(e,t)=>{if(_r.has(e))return _r.get(e);throw new TypeError(`Invalid ${t} ${e}: this signal integer does not exist.\n${Ar()}`)},_r=new Map(Object.entries(K.signals).reverse().map(([e,t])=>[t,e])),Tr=(e,t)=>{if(e in K.signals)return e;if(e.toUpperCase()in K.signals)throw new TypeError(`Invalid ${t} '${e}': please rename it to '${e.toUpperCase()}'.`);throw new TypeError(`Invalid ${t} '${e}': this signal name does not exist.\n${Ar()}`)},Ar=()=>`Available signal names: ${Ir()}.\nAvailable signal numbers: ${Dr()}.`,Ir=()=>Object.keys(K.signals).sort().map(e=>`'${e}'`).join(", "),Dr=()=>[...new Set(Object.values(K.signals).sort((e,t)=>e-t))].join(", "),kr=e=>Sr[e].description,Mr=({kill:e,options:{forceKillAfterDelay:t,killSignal:n},onInternalError:r,context:i,controller:o},s,a)=>{const{signal:l,error:c}=jr(s,a,n);Nr(c,r);const d=e(l);return Pr({kill:e,signal:l,forceKillAfterDelay:t,killSignal:n,killResult:d,context:i,controller:o}),d},jr=(e,t,n)=>{const[r=n,i]=mr(e)?[void 0,e]:[e,t];if("string"!=typeof r&&!Number.isInteger(r))throw new TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(r)}`);if(void 0!==i&&!mr(i))throw new TypeError(`The second argument is optional. If specified, it must be an error instance: ${i}`);return{signal:xr(r),error:i}},Nr=(e,t)=>{void 0!==e&&t.reject(e)},Pr=async({kill:e,signal:t,forceKillAfterDelay:n,killSignal:r,killResult:i,context:o,controller:s})=>{t===r&&i&&Rr({kill:e,forceKillAfterDelay:n,context:o,controllerSignal:s.signal})},Rr=async({kill:e,forceKillAfterDelay:t,context:n,controllerSignal:r})=>{if(!1!==t)try{await G(t,void 0,{signal:r}),e("SIGKILL")&&(n.isForcefullyTerminated??=!0)}catch{}},Lr=async(e,t)=>{e.aborted||await n(e,"abort",{signal:t})},Br=({subprocess:e,cancelSignal:t,gracefulCancel:n,context:r,controller:i})=>void 0===t||n?[]:[Fr(e,t,r,i)],Fr=async(e,t,n,{signal:r})=>{throw await Lr(t,r),n.terminationReason??="cancel",e.kill(),t.reason},Ur=({methodName:e,isSubprocess:t,ipc:n,isConnected:r})=>{Hr(e,t,n),Wr(e,t,r)},Hr=(e,t,n)=>{if(!n)throw new Error(`${Kr(e,t)} can only be used if the \`ipc\` option is \`true\`.`)},Wr=(e,t,n)=>{if(!n)throw new Error(`${Kr(e,t)} cannot be used: the ${Yr(t)} has already exited or disconnected.`)},Gr=(e,t)=>new Error(`${Kr("sendMessage",t)} failed when sending an acknowledgment response to the ${Yr(t)}.`,{cause:e}),Vr=new Set(["ERR_MISSING_ARGS","ERR_INVALID_ARG_TYPE"]),qr=["could not be cloned","circular structure","call stack size exceeded"],Kr=(e,t,n="")=>"cancelSignal"===e?"`cancelSignal`'s `controller.abort()`":`${zr(t)}${e}(${n})`,zr=e=>e?"":"subprocess.",Yr=e=>e?"parent process":"subprocess",Jr=e=>{e.connected&&e.disconnect()},Xr=()=>{const e={},t=new Promise((t,n)=>{Object.assign(e,{resolve:t,reject:n})});return Object.assign(t,e)},Qr=(e,t="stdin")=>{const n=!0,{options:r,fileDescriptors:i}=ei.get(e),o=ti(i,t,n),s=e.stdio[o];if(null===s)throw new TypeError(ii(o,t,r,n));return s},Zr=(e,t="stdout")=>{const n=!1,{options:r,fileDescriptors:i}=ei.get(e),o=ti(i,t,n),s="all"===o?e.all:e.stdio[o];if(null==s)throw new TypeError(ii(o,t,r,n));return s},ei=new WeakMap,ti=(e,t,n)=>{const r=ni(t,n);return ri(r,t,n,e),r},ni=(e,t)=>{const n=Ot(e);if(void 0!==n)return n;const{validOptions:r,defaultValue:i}=t?{validOptions:'"stdin"',defaultValue:"stdin"}:{validOptions:'"stdout", "stderr", "all"',defaultValue:"stdout"};throw new TypeError(`"${ai(t)}" must not be "${e}".\nIt must be ${r} or "fd3", "fd4" (and so on).\nIt is optional and defaults to "${i}".`)},ri=(e,t,n,r)=>{const i=r[si(e)];if(void 0===i)throw new TypeError(`"${ai(n)}" must not be ${t}. That file descriptor does not exist.\nPlease set the "stdio" option to ensure that file descriptor exists.`);if("input"===i.direction&&!n)throw new TypeError(`"${ai(n)}" must not be ${t}. It must be a readable stream, not writable.`);if("input"!==i.direction&&n)throw new TypeError(`"${ai(n)}" must not be ${t}. It must be a writable stream, not readable.`)},ii=(e,t,n,r)=>{if("all"===e&&!n.all)return'The "all" option must be true to use "from: \'all\'".';const{optionName:i,optionValue:o}=oi(e,n);return`The "${i}: ${li(o)}" option is incompatible with using "${ai(r)}: ${li(t)}".\nPlease set this option with "pipe" instead.`},oi=(e,{stdin:t,stdout:n,stderr:r,stdio:i})=>{const o=si(e);return 0===o&&void 0!==t?{optionName:"stdin",optionValue:t}:1===o&&void 0!==n?{optionName:"stdout",optionValue:n}:2===o&&void 0!==r?{optionName:"stderr",optionValue:r}:{optionName:`stdio[${o}]`,optionValue:i[o]}},si=e=>"all"===e?1:e,ai=e=>e?"to":"from",li=e=>"string"==typeof e?`'${e}'`:"number"==typeof e?`${e}`:"Stream",ci=(e,t,n)=>{const i=e.getMaxListeners();0!==i&&i!==Number.POSITIVE_INFINITY&&(e.setMaxListeners(i+t),r(n,()=>{e.setMaxListeners(e.getMaxListeners()-t)}))},di=(e,t)=>{t&&ui(e)},ui=e=>{e.refCounted()},pi=(e,t)=>{t&&mi(e)},mi=e=>{e.unrefCounted()},hi=async({anyProcess:e,channel:t,isSubprocess:n,ipcEmitter:r},i)=>{if(xi(i)||Hi(i))return;gi.has(e)||gi.set(e,[]);const o=gi.get(e);if(o.push(i),!(o.length>1))for(;o.length>0;){await Ii(e,r,i),await V.yield();const s=await Ei({wrappedMessage:o[0],anyProcess:e,channel:t,isSubprocess:n,ipcEmitter:r});o.shift(),r.emit("message",s),r.emit("message:done")}},fi=async({anyProcess:e,channel:t,isSubprocess:r,ipcEmitter:i,boundOnMessage:o})=>{Gi();const s=gi.get(e);for(;s?.length>0;)await n(i,"message:done");e.removeListener("message",o),((e,t)=>{t&&(ui(e),ui(e))})(t,r),i.connected=!1,i.emit("disconnect")},gi=new WeakMap,bi=(e,t,n)=>{if(wi.has(e))return wi.get(e);const r=new i;return r.connected=!0,wi.set(e,r),yi({ipcEmitter:r,anyProcess:e,channel:t,isSubprocess:n}),r},wi=new WeakMap,yi=({ipcEmitter:e,anyProcess:t,channel:n,isSubprocess:r})=>{const i=hi.bind(void 0,{anyProcess:t,channel:n,isSubprocess:r,ipcEmitter:e});t.on("message",i),t.once("disconnect",fi.bind(void 0,{anyProcess:t,channel:n,isSubprocess:r,ipcEmitter:e,boundOnMessage:i})),((e,t)=>{t&&(mi(e),mi(e))})(n,r)},vi=e=>{const t=wi.get(e);return void 0===t?null!==e.channel:t.connected};let $i=0n;const Si=(e,t)=>{if(t?.type===Ti&&!t.hasListeners)for(const{id:t}of e)void 0!==t&&Ci[t].resolve({isDeadlock:!0,hasListeners:!1})},Ei=async({wrappedMessage:e,anyProcess:t,channel:n,isSubprocess:r,ipcEmitter:i})=>{if(e?.type!==Ti||!t.connected)return e;const{id:o,message:s}=e,a={id:o,type:Ai,message:ki(t,i)};try{await ji({anyProcess:t,channel:n,isSubprocess:r,ipc:!0},a)}catch(e){i.emit("strict:error",e)}return s},xi=e=>{if(e?.type!==Ai)return!1;const{id:t,message:n}=e;return Ci[t]?.resolve({isDeadlock:!1,hasListeners:n}),!0},Oi=async(e,t,n)=>{if(e?.type!==Ti)return;const r=Xr();Ci[e.id]=r;const i=new AbortController;try{const{isDeadlock:e,hasListeners:o}=await Promise.race([r,_i(t,n,i)]);e&&(e=>{throw new Error(`${Kr("sendMessage",e)} failed: the ${Yr(e)} is sending a message too, instead of listening to incoming messages.\nThis can be fixed by both sending a message and listening to incoming messages at the same time:\n\nconst [receivedMessage] = await Promise.all([\n\t${Kr("getOneMessage",e)},\n\t${Kr("sendMessage",e,"message, {strict: true}")},\n]);`)})(n),o||(e=>{throw new Error(`${Kr("sendMessage",e)} failed: the ${Yr(e)} is not listening to incoming messages.`)})(n)}finally{i.abort(),delete Ci[e.id]}},Ci={},_i=async(e,t,{signal:r})=>{ci(e,1,r),await n(e,"disconnect",{signal:r}),(e=>{throw new Error(`${Kr("sendMessage",e)} failed: the ${Yr(e)} exited without listening to incoming messages.`)})(t)},Ti="execa:ipc:request",Ai="execa:ipc:response",Ii=async(e,t,n)=>{for(;!ki(e,t)&&Di.get(e)?.size>0;){const t=[...Di.get(e)];Si(t,n),await Promise.all(t.map(({onMessageSent:e})=>e))}},Di=new WeakMap,ki=(e,t)=>t.listenerCount("message")>Mi(e),Mi=e=>ei.has(e)&&!It(ei.get(e).options.buffer,"ipc")?1:0,ji=({anyProcess:e,channel:t,isSubprocess:n,ipc:r},i,{strict:o=!1}={})=>{const s="sendMessage";return Ur({methodName:s,isSubprocess:n,ipc:r,isConnected:e.connected}),Ni({anyProcess:e,channel:t,methodName:s,isSubprocess:n,message:i,strict:o})},Ni=async({anyProcess:e,channel:t,methodName:n,isSubprocess:r,message:i,strict:o})=>{const s=(({anyProcess:e,channel:t,isSubprocess:n,message:r,strict:i})=>{if(!i)return r;const o=bi(e,t,n),s=ki(e,o);return{id:$i++,type:Ti,message:r,hasListeners:s}})({anyProcess:e,channel:t,isSubprocess:r,message:i,strict:o}),a=((e,t,n)=>{Di.has(e)||Di.set(e,new Set);const r=Di.get(e),i={onMessageSent:Xr(),id:n?t.id:void 0};return r.add(i),{outgoingMessages:r,outgoingMessage:i}})(e,s,o);try{await Pi({anyProcess:e,methodName:n,isSubprocess:r,wrappedMessage:s,message:i})}catch(t){throw Jr(e),t}finally{(({outgoingMessages:e,outgoingMessage:t})=>{e.delete(t),t.onMessageSent.resolve()})(a)}},Pi=async({anyProcess:e,methodName:t,isSubprocess:n,wrappedMessage:r,message:i})=>{const o=Ri(e);try{await Promise.all([Oi(r,e,n),o(r)])}catch(e){throw(({error:e,methodName:t,isSubprocess:n})=>{if("EPIPE"===e.code)throw new Error(`${Kr(t,n)} cannot be used: the ${Yr(n)} is disconnecting.`,{cause:e})})({error:e,methodName:t,isSubprocess:n}),(({error:e,methodName:t,isSubprocess:n,message:r})=>{if((({code:e,message:t})=>Vr.has(e)||qr.some(e=>t.includes(e)))(e))throw new Error(`${Kr(t,n)}'s argument type is invalid: the message cannot be serialized: ${String(r)}.`,{cause:e})})({error:e,methodName:t,isSubprocess:n,message:i}),e}},Ri=e=>{if(Li.has(e))return Li.get(e);const t=j(e.send.bind(e));return Li.set(e,t),t},Li=new WeakMap,Bi=async({anyProcess:e,channel:t,isSubprocess:n,ipc:r})=>(await Fi({anyProcess:e,channel:t,isSubprocess:n,ipc:r}),Vi.signal),Fi=async({anyProcess:e,channel:t,isSubprocess:n,ipc:r})=>{Ui||(Ui=!0,r?null!==t?(bi(e,t,n),await V.yield()):Gi():(()=>{throw new Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")})())};let Ui=!1;const Hi=e=>e?.type===Wi&&(Vi.abort(e.message),!0),Wi="execa:ipc:cancel",Gi=()=>{Vi.abort(new Error(`\`cancelSignal\` aborted: the ${Yr(!0)} disconnected.`))},Vi=new AbortController,qi=({subprocess:e,cancelSignal:t,gracefulCancel:n,forceKillAfterDelay:r,context:i,controller:o})=>n?[Ki({subprocess:e,cancelSignal:t,forceKillAfterDelay:r,context:i,controller:o})]:[],Ki=async({subprocess:e,cancelSignal:t,forceKillAfterDelay:n,context:r,controller:{signal:i}})=>{await Lr(t,i);const o=zi(t);throw await((e,t)=>{const n="cancelSignal";return Wr(n,!1,e.connected),Pi({anyProcess:e,methodName:n,isSubprocess:!1,wrappedMessage:{type:Wi,message:t},message:t})})(e,o),Rr({kill:e.kill,forceKillAfterDelay:n,context:r,controllerSignal:i}),r.terminationReason??="gracefulCancel",t.reason},zi=({reason:e})=>{if(!(e instanceof DOMException))return e;const t=new Error(e.message);return Object.defineProperty(t,"stack",{value:e.stack,enumerable:!1,configurable:!0,writable:!0}),t},Yi=(e,t,n,r)=>0===t||void 0===t?[]:[Ji(e,t,n,r)],Ji=async(e,t,n,{signal:r})=>{throw await G(t,void 0,{signal:r}),n.terminationReason??="timeout",e.kill(),new dr},Xi={advanced:e=>{try{z(e)}catch(e){throw new Error("The `ipcInput` option is not serializable with a structured clone.",{cause:e})}},json:e=>{try{JSON.stringify(e)}catch(e){throw new Error("The `ipcInput` option is not serializable with JSON.",{cause:e})}}},Qi=async(e,t)=>{void 0!==t&&await e.sendMessage(t)},Zi=new Set(["utf8","utf16le"]),eo=new Set(["buffer","hex","base64","base64url","latin1","ascii"]),to=new Set([...Zi,...eo]),no={"utf-8":"utf8","utf-16le":"utf16le","ucs-2":"utf16le",ucs2:"utf16le",binary:"latin1"},ro=e=>"string"==typeof e?`"${e}"`:String(e),io=()=>{try{return v.cwd()}catch(e){throw e.message=`The current directory does not exist.\n${e.message}`,e}},oo=(e,t,n)=>{n.cwd=((e=io())=>{const t=Ve(e,'The "cwd" option');return u.resolve(t)})(n.cwd);const[r,i,o]=((e,t,{node:n=!1,nodePath:r=E,nodeOptions:i=x.filter(e=>!e.startsWith("--inspect")),cwd:o,execPath:s,...a})=>{if(void 0!==s)throw new TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');const l=Ve(r,'The "nodePath" option'),c=u.resolve(o,l),d={...a,nodePath:c,node:n,cwd:o};if(!n)return[e,t,d];if("node"===u.basename(e,".exe"))throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');return[c,[...i,e,...t],{ipc:!0,...d,shell:!1}]})(e,t,n),{command:s,args:a,options:l}=ar._parse(r,i,o),c=(e=>{const t={...e};for(const n of At)t[n]=wt(e,n);return t})(l),d=so(c);return(({timeout:e})=>{if(void 0!==e&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)})(d),(({encoding:e})=>{if(to.has(e))return;const t=(e=>{if(null===e)return"buffer";if("string"!=typeof e)return;const t=e.toLowerCase();return t in no?no[t]:to.has(t)?t:void 0})(e);if(void 0!==t)throw new TypeError(`Invalid option \`encoding: ${ro(e)}\`.\nPlease rename it to ${ro(t)}.`);const n=[...to].map(e=>ro(e)).join(", ");throw new TypeError(`Invalid option \`encoding: ${ro(e)}\`.\nPlease rename it to one of: ${n}.`)})(d),(({ipcInput:e,ipc:t,serialization:n})=>{if(void 0!==e){if(!t)throw new Error("The `ipcInput` option cannot be set unless the `ipc` option is `true`.");Xi[n](e)}})(d),(({cancelSignal:e})=>{if(void 0!==e&&"[object AbortSignal]"!==Object.prototype.toString.call(e))throw new Error(`The \`cancelSignal\` option must be an AbortSignal: ${String(e)}`)})(d),(({gracefulCancel:e,cancelSignal:t,ipc:n,serialization:r})=>{if(e){if(void 0===t)throw new Error("The `cancelSignal` option must be defined when setting the `gracefulCancel` option.");if(!n)throw new Error("The `ipc` option cannot be false when setting the `gracefulCancel` option.");if("json"===r)throw new Error("The `serialization` option cannot be 'json' when setting the `gracefulCancel` option.")}})(d),d.shell=ze(d.shell),d.env=ao(d),d.killSignal=(e=>{const t="option `killSignal`";if(0===e)throw new TypeError(`Invalid ${t}: 0 cannot be used.`);return Or(e,t)})(d.killSignal),d.forceKillAfterDelay=(e=>{if(!1===e)return e;if(!0===e)return 5e3;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e})(d.forceKillAfterDelay),d.lines=d.lines.map((e,t)=>e&&!eo.has(d.encoding)&&d.buffer[t]),"win32"===v.platform&&"cmd"===u.basename(s,".exe")&&a.unshift("/q"),{file:s,commandArguments:a,options:d}},so=({extendEnv:e=!0,preferLocal:t=!1,cwd:n,localDir:r=n,encoding:i="utf8",reject:o=!0,cleanup:s=!0,all:a=!1,windowsHide:l=!0,killSignal:c="SIGTERM",forceKillAfterDelay:d=!0,gracefulCancel:u=!1,ipcInput:p,ipc:m=void 0!==p||u,serialization:h="advanced",...f})=>({...f,extendEnv:e,preferLocal:t,cwd:n,localDirectory:r,encoding:i,reject:o,cleanup:s,all:a,windowsHide:l,killSignal:c,forceKillAfterDelay:d,gracefulCancel:u,ipcInput:p,ipc:m,serialization:h}),ao=({env:e,extendEnv:t,preferLocal:n,node:r,localDirectory:i,nodePath:o})=>{const s=t?{...v.env,...e}:e;return n||r?cr({env:s,cwd:i,execPath:o,preferLocal:n,addExecPath:r}):s},lo=(e,t,n)=>n.shell&&t.length>0?[[e,...t].join(" "),[],n]:[e,t,n];function co(e){if("string"==typeof e)return uo(e);if(!ArrayBuffer.isView(e)||1!==e.BYTES_PER_ELEMENT)throw new Error("Input must be a string or a Uint8Array");return po(e)}const uo=e=>e.at(-1)===mo?e.slice(0,e.at(-2)===fo?-2:-1):e,po=e=>e.at(-1)===ho?e.subarray(0,e.at(-2)===go?-2:-1):e,mo="\n",ho=mo.codePointAt(0),fo="\r",go=fo.codePointAt(0);function bo(e,{checkOpen:t=!0}={}){return null!==e&&"object"==typeof e&&(e.writable||e.readable||!t||void 0===e.writable&&void 0===e.readable)&&"function"==typeof e.pipe}function wo(e,{checkOpen:t=!0}={}){return bo(e,{checkOpen:t})&&(e.writable||!t)&&"function"==typeof e.write&&"function"==typeof e.end&&"boolean"==typeof e.writable&&"boolean"==typeof e.writableObjectMode&&"function"==typeof e.destroy&&"boolean"==typeof e.destroyed}function yo(e,{checkOpen:t=!0}={}){return bo(e,{checkOpen:t})&&(e.readable||!t)&&"function"==typeof e.read&&"boolean"==typeof e.readable&&"boolean"==typeof e.readableObjectMode&&"function"==typeof e.destroy&&"boolean"==typeof e.destroyed}function vo(e,t){return wo(e,t)&&yo(e,t)}const $o=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype);class So{#e;#t;#n=!1;#r=void 0;constructor(e,t){this.#e=e,this.#t=t}next(){const e=()=>this.#i();return this.#r=this.#r?this.#r.then(e,e):e(),this.#r}return(e){const t=()=>this.#o(e);return this.#r?this.#r.then(t,t):t()}async#i(){if(this.#n)return{done:!0,value:void 0};let e;try{e=await this.#e.read()}catch(e){throw this.#r=void 0,this.#n=!0,this.#e.releaseLock(),e}return e.done&&(this.#r=void 0,this.#n=!0,this.#e.releaseLock()),e}async#o(e){if(this.#n)return{done:!0,value:e};if(this.#n=!0,!this.#t){const t=this.#e.cancel(e);return this.#e.releaseLock(),await t,{done:!0,value:e}}return this.#e.releaseLock(),{done:!0,value:e}}}const Eo=Symbol();function xo(){return this[Eo].next()}function Oo(e){return this[Eo].return(e)}Object.defineProperty(xo,"name",{value:"next"}),Object.defineProperty(Oo,"name",{value:"return"});const Co=Object.create($o,{next:{enumerable:!0,configurable:!0,writable:!0,value:xo},return:{enumerable:!0,configurable:!0,writable:!0,value:Oo}});function _o({preventCancel:e=!1}={}){const t=this.getReader(),n=new So(t,e),r=Object.create(Co);return r[Eo]=n,r}const To=e=>{if(yo(e,{checkOpen:!1})&&void 0!==ko.on)return Io(e);if("function"==typeof e?.[Symbol.asyncIterator])return e;if("[object ReadableStream]"===Ao.call(e))return _o.call(e);throw new TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.")},{toString:Ao}=Object.prototype,Io=async function*(e){const t=new AbortController,n={};Do(e,t,n);try{for await(const[n]of ko.on(e,"data",{signal:t.signal}))yield n}catch(e){if(void 0!==n.error)throw n.error;if(!t.signal.aborted)throw e}finally{e.destroy()}},Do=async(e,t,n)=>{try{await ko.finished(e,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(e){n.error=e}finally{t.abort()}},ko={},Mo=async(e,{init:t,convertChunk:n,getSize:r,truncateChunk:i,addChunk:o,getFinalChunk:s,finalize:a},{maxBuffer:l=Number.POSITIVE_INFINITY}={})=>{const c=To(e),d=t();d.length=0;try{for await(const e of c){const t=n[Ro(e)](e,d);No({convertedChunk:t,state:d,getSize:r,truncateChunk:i,addChunk:o,maxBuffer:l})}return jo({state:d,convertChunk:n,getSize:r,truncateChunk:i,addChunk:o,getFinalChunk:s,maxBuffer:l}),a(d)}catch(e){const t="object"==typeof e&&null!==e?e:new Error(e);throw t.bufferedData=a(d),t}},jo=({state:e,getSize:t,truncateChunk:n,addChunk:r,getFinalChunk:i,maxBuffer:o})=>{const s=i(e);void 0!==s&&No({convertedChunk:s,state:e,getSize:t,truncateChunk:n,addChunk:r,maxBuffer:o})},No=({convertedChunk:e,state:t,getSize:n,truncateChunk:r,addChunk:i,maxBuffer:o})=>{const s=n(e),a=t.length+s;if(a<=o)return void Po(e,t,i,a);const l=r(e,o-t.length);throw void 0!==l&&Po(l,t,i,o),new Bo},Po=(e,t,n,r)=>{t.contents=n(e,t,r),t.length=r},Ro=e=>{const t=typeof e;if("string"===t)return"string";if("object"!==t||null===e)return"others";if(globalThis.Buffer?.isBuffer(e))return"buffer";const n=Lo.call(e);return"[object ArrayBuffer]"===n?"arrayBuffer":"[object DataView]"===n?"dataView":Number.isInteger(e.byteLength)&&Number.isInteger(e.byteOffset)&&"[object ArrayBuffer]"===Lo.call(e.buffer)?"typedArray":"others"},{toString:Lo}=Object.prototype;class Bo extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}}const Fo=e=>e,Uo=()=>{},Ho=({contents:e})=>e,Wo=e=>{throw new Error(`Streams in object mode are not supported: ${String(e)}`)},Go=e=>e.length,Vo={init:()=>({contents:[]}),convertChunk:{string:Fo,buffer:Fo,arrayBuffer:Fo,dataView:Fo,typedArray:Fo,others:Fo},getSize:()=>1,truncateChunk:Uo,addChunk:(e,{contents:t})=>(t.push(e),t),getFinalChunk:Uo,finalize:Ho},qo=new TextEncoder,Ko=e=>new Uint8Array(e),zo=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Yo=e=>Jo**Math.ceil(Math.log(e)/Math.log(Jo)),Jo=2,Xo=()=>"resize"in ArrayBuffer.prototype,Qo={init:()=>({contents:new ArrayBuffer(0)}),convertChunk:{string:e=>qo.encode(e),buffer:Ko,arrayBuffer:Ko,dataView:zo,typedArray:zo,others:Wo},getSize:Go,truncateChunk:(e,t)=>e.slice(0,t),addChunk:(e,{contents:t,length:n},r)=>{const i=Xo()?((e,t)=>{if(t<=e.maxByteLength)return e.resize(t),e;const n=new ArrayBuffer(t,{maxByteLength:Yo(t)});return new Uint8Array(n).set(new Uint8Array(e),0),n})(t,r):((e,t)=>{if(t<=e.byteLength)return e;const n=new ArrayBuffer(Yo(t));return new Uint8Array(n).set(new Uint8Array(e),0),n})(t,r);return new Uint8Array(i).set(e,n),i},getFinalChunk:Uo,finalize:({contents:e,length:t})=>Xo()?e:e.slice(0,t)},Zo=(e,{textDecoder:t})=>t.decode(e,{stream:!0}),es={init:()=>({contents:"",textDecoder:new TextDecoder}),convertChunk:{string:Fo,buffer:Zo,arrayBuffer:Zo,dataView:Zo,typedArray:Zo,others:Wo},getSize:Go,truncateChunk:(e,t)=>e.slice(0,t),addChunk:(e,{contents:t})=>t+e,getFinalChunk:({textDecoder:e})=>{const t=e.decode();return""===t?void 0:t},finalize:Ho},ts=(e,t,n)=>{if(t.length!==n)return;const r=new Bo;throw r.maxBufferInfo={fdNumber:"ipc"},r},ns=([,e])=>e,rs=({originalError:e,timedOut:t,timeout:n,isMaxBuffer:r,maxBuffer:i,errorCode:o,signal:s,signalDescription:a,exitCode:l,isCanceled:c,isGracefullyCanceled:d,isForcefullyTerminated:u,forceKillAfterDelay:p,killSignal:m})=>{const h=is(u,p);return t?`Command timed out after ${n} milliseconds${h}`:d?void 0===s?`Command was gracefully canceled with exit code ${l}`:u?`Command was gracefully canceled${h}`:`Command was gracefully canceled with ${s} (${a})`:c?`Command was canceled${h}`:r?`${((e,t)=>{const{streamName:n,threshold:r,unit:i}=((e,t)=>{if(void 0===e?.maxBufferInfo)return{streamName:"output",threshold:t[1],unit:"bytes"};const{maxBufferInfo:{fdNumber:n,unit:r}}=e;delete e.maxBufferInfo;const i=It(t,n);return"ipc"===n?{streamName:"IPC output",threshold:i,unit:"messages"}:{streamName:bt(n),threshold:i,unit:r}})(e,t);return`Command's ${n} was larger than ${r} ${i}`})(e,i)}${h}`:void 0!==o?`Command failed with ${o}${h}`:u?`Command was killed with ${m} (${kr(m)})${h}`:void 0!==s?`Command was killed with ${s} (${a})`:void 0!==l?`Command failed with exit code ${l}`:"Command failed"},is=(e,t)=>e?` and was forcefully terminated after ${t} milliseconds`:"",os=e=>"string"==typeof e?e:Xe(e)?nt(e):"",ss=({command:e,escapedCommand:t,stdio:n,all:r,ipcOutput:i,options:{cwd:o},startTime:s})=>ds({command:e,escapedCommand:t,cwd:o,durationMs:bn(s),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:n[1],stderr:n[2],all:r,stdio:n,ipcOutput:i,pipedFrom:[]}),as=({error:e,command:t,escapedCommand:n,fileDescriptors:r,options:i,startTime:o,isSync:s})=>ls({error:e,command:t,escapedCommand:n,startTime:o,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:r.length}),ipcOutput:[],options:i,isSync:s}),ls=({error:e,command:t,escapedCommand:n,startTime:r,timedOut:i,isCanceled:o,isGracefullyCanceled:s,isMaxBuffer:a,isForcefullyTerminated:l,exitCode:c,signal:d,stdio:u,all:p,ipcOutput:h,options:{timeoutDuration:f,timeout:g=f,forceKillAfterDelay:b,killSignal:w,cwd:y,maxBuffer:v},isSync:$})=>{const{exitCode:S,signal:E,signalDescription:x}=us(c,d),{originalMessage:O,shortMessage:C,message:_}=(({stdio:e,all:t,ipcOutput:n,originalError:r,signal:i,signalDescription:o,exitCode:s,escapedCommand:a,timedOut:l,isCanceled:c,isGracefullyCanceled:d,isMaxBuffer:u,isForcefullyTerminated:p,forceKillAfterDelay:h,killSignal:f,maxBuffer:g,timeout:b,cwd:w})=>{const y=r?.code,v=rs({originalError:r,timedOut:l,timeout:b,isMaxBuffer:u,maxBuffer:g,errorCode:y,signal:i,signalDescription:o,exitCode:s,isCanceled:c,isGracefullyCanceled:d,isForcefullyTerminated:p,forceKillAfterDelay:h,killSignal:f}),$=((e,t)=>{if(e instanceof dr)return;const n=(e=>mr(e)&&pr in e)(e)?e.originalMessage:String(e?.message??e),r=Rt(((e,t)=>{if(t===io())return e;let n;try{n=m(t)}catch(n){return`The "cwd" option is invalid: ${t}.\n${n.message}\n${e}`}return n.isDirectory()?e:`The "cwd" option is not a directory: ${t}.\n${e}`})(n,t));return""===r?void 0:r})(r,w),S=`${v}: ${a}${void 0===$?"":`\n${$}`}`,E=[S,...void 0===t?[e[2],e[1]]:[t],...e.slice(3),n.map(e=>(e=>"string"==typeof e?e:M(e))(e)).join("\n")].map(e=>Rt(co((e=>Array.isArray(e)?e.map(e=>co(os(e))).filter(Boolean).join("\n"):os(e))(e)))).filter(Boolean).join("\n\n");return{originalMessage:$,shortMessage:S,message:E}})({stdio:u,all:p,ipcOutput:h,originalError:e,signal:E,signalDescription:x,exitCode:S,escapedCommand:n,timedOut:i,isCanceled:o,isGracefullyCanceled:s,isMaxBuffer:a,isForcefullyTerminated:l,forceKillAfterDelay:b,killSignal:w,maxBuffer:v,timeout:g,cwd:y}),T=((e,t,n)=>new(n?fr:hr)(t,e instanceof dr?{}:{cause:e}))(e,_,$);return Object.assign(T,cs({error:T,command:t,escapedCommand:n,startTime:r,timedOut:i,isCanceled:o,isGracefullyCanceled:s,isMaxBuffer:a,isForcefullyTerminated:l,exitCode:S,signal:E,signalDescription:x,stdio:u,all:p,ipcOutput:h,cwd:y,originalMessage:O,shortMessage:C})),T},cs=({error:e,command:t,escapedCommand:n,startTime:r,timedOut:i,isCanceled:o,isGracefullyCanceled:s,isMaxBuffer:a,isForcefullyTerminated:l,exitCode:c,signal:d,signalDescription:u,stdio:p,all:m,ipcOutput:h,cwd:f,originalMessage:g,shortMessage:b})=>ds({shortMessage:b,originalMessage:g,command:t,escapedCommand:n,cwd:f,durationMs:bn(r),failed:!0,timedOut:i,isCanceled:o,isGracefullyCanceled:s,isTerminated:void 0!==d,isMaxBuffer:a,isForcefullyTerminated:l,exitCode:c,signal:d,signalDescription:u,code:e.cause?.code,stdout:p[1],stderr:p[2],all:m,stdio:p,ipcOutput:h,pipedFrom:[]}),ds=e=>Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e)),us=(e,t)=>{const n=null===t?void 0:t;return{exitCode:null===e?void 0:e,signal:n,signalDescription:void 0===n?void 0:kr(t)}},ps=e=>Number.isFinite(e)?e:0;function ms(e,t){const n="bigint"==typeof e;if(!n&&!Number.isFinite(e))throw new TypeError("Expected a finite number or bigint");const r=e<0?"-":"";e=e<0?-e:e,(t={...t}).colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let i=[];const o=(e,n,r,o)=>{if(0!==i.length&&t.colonNotation||!(e=>0===e||0n===e)(e)||t.colonNotation&&"m"===r){if(o??=String(e),t.colonNotation){const e=o.includes(".")?o.split(".")[0].length:o.length,t=i.length>0?2:1;o="0".repeat(Math.max(0,t-e))+o}else o+=t.verbose?" "+((e,t)=>1===t||1n===t?e:`${e}s`)(n,e):r;i.push(o)}},s=function(e){switch(typeof e){case"number":if(Number.isFinite(e))return function(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(ps(1e3*e)%1e3),nanoseconds:Math.trunc(ps(1e6*e)%1e3)}}(e);break;case"bigint":return function(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}(e)}throw new TypeError("Expected a finite number or bigint")}(e),a=BigInt(s.days);if(t.hideYearAndDays?o(24n*BigInt(a)+BigInt(s.hours),"hour","h"):(t.hideYear?o(a,"day","d"):(o(a/365n,"year","y"),o(a%365n,"day","d")),o(Number(s.hours),"hour","h")),o(Number(s.minutes),"minute","m"),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3&&!t.subSecondsAsDecimals){const e=Number(s.seconds),n=Number(s.milliseconds),r=Number(s.microseconds),i=Number(s.nanoseconds);if(o(e,"second","s"),t.formatSubMilliseconds)o(n,"millisecond","ms"),o(r,"microsecond","µs"),o(i,"nanosecond","ns");else{const e=n+r/1e3+i/1e6,s="number"==typeof t.millisecondsDecimalDigits?t.millisecondsDecimalDigits:0,a=e>=1?Math.round(e):Math.ceil(e),l=s?e.toFixed(s):a;o(Number.parseFloat(l),"millisecond","ms",l)}}else{const r=((e,t)=>{const n=Math.floor(e*10**t+1e-7);return(Math.round(n)/10**t).toFixed(t)})((n?Number(e%86400000n):e)/1e3%60,"number"==typeof t.secondsDecimalDigits?t.secondsDecimalDigits:1),i=t.keepDecimalsOnWholeSeconds?r:r.replace(/\.0+$/,"");o(Number.parseFloat(i),"second","s",i)}if(0===i.length)return r+"0"+(t.verbose?" milliseconds":"ms");const l=t.colonNotation?":":" ";return"number"==typeof t.unitCount&&(i=i.slice(0,Math.max(t.unitCount,1))),r+i.join(l)}const hs=(e,t)=>{const n=`(done in ${ms(e.durationMs)})`;ln({type:"duration",verboseMessage:n,verboseInfo:t,result:e})},fs=(e,t,{reject:n})=>{if(((e,t)=>{Dt(t)&&(((e,t)=>{e.failed&&ln({type:"error",verboseMessage:e.shortMessage,verboseInfo:t,result:e})})(e,t),hs(e,t))})(e,t),e.failed&&n)throw e;return e},gs=(e,t)=>Os(e)?"asyncGenerator":Cs(e)?"generator":Ts(e)?"fileUrl":As(e)?"filePath":Ns(e)?"webStream":bo(e,{checkOpen:!1})?"native":Xe(e)?"uint8Array":Rs(e)?"asyncIterable":Ls(e)?"iterable":Ps(e)?ys({},t):_s(e)?bs(e,t):"native",bs=(e,t)=>vo(e.transform,{checkOpen:!1})?ws(e,t):Ps(e.transform)?ys(e,t):Ss(e,t),ws=(e,t)=>(vs(e,t,"Duplex stream"),"duplex"),ys=(e,t)=>(vs(e,t,"web TransformStream"),"webTransform"),vs=({final:e,binary:t,objectMode:n},r,i)=>{$s(e,`${r}.final`,i),$s(t,`${r}.binary`,i),Es(n,`${r}.objectMode`)},$s=(e,t,n)=>{if(void 0!==e)throw new TypeError(`The \`${t}\` option can only be defined when using a generator, not a ${n}.`)},Ss=({transform:e,final:t,binary:n,objectMode:r},i)=>{if(void 0!==e&&!xs(e))throw new TypeError(`The \`${i}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(vo(t,{checkOpen:!1}))throw new TypeError(`The \`${i}.final\` option must not be a Duplex stream.`);if(Ps(t))throw new TypeError(`The \`${i}.final\` option must not be a web TransformStream.`);if(void 0!==t&&!xs(t))throw new TypeError(`The \`${i}.final\` option must be a generator.`);return Es(n,`${i}.binary`),Es(r,`${i}.objectMode`),Os(e)||Os(t)?"asyncGenerator":"generator"},Es=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw new TypeError(`The \`${t}\` option must use a boolean.`)},xs=e=>Os(e)||Cs(e),Os=e=>"[object AsyncGeneratorFunction]"===Object.prototype.toString.call(e),Cs=e=>"[object GeneratorFunction]"===Object.prototype.toString.call(e),_s=e=>Ge(e)&&(void 0!==e.transform||void 0!==e.final),Ts=e=>"[object URL]"===Object.prototype.toString.call(e),As=e=>Ge(e)&&Object.keys(e).length>0&&Object.keys(e).every(e=>Is.has(e))&&Ds(e.file),Is=new Set(["file","append"]),Ds=e=>"string"==typeof e,ks=new Set(["ipc","ignore","inherit","overlapped","pipe"]),Ms=e=>"[object ReadableStream]"===Object.prototype.toString.call(e),js=e=>"[object WritableStream]"===Object.prototype.toString.call(e),Ns=e=>Ms(e)||js(e),Ps=e=>Ms(e?.readable)&&js(e?.writable),Rs=e=>Bs(e)&&"function"==typeof e[Symbol.asyncIterator],Ls=e=>Bs(e)&&"function"==typeof e[Symbol.iterator],Bs=e=>"object"==typeof e&&null!==e,Fs=new Set(["generator","asyncGenerator","duplex","webTransform"]),Us=new Set(["fileUrl","filePath","fileNumber"]),Hs=new Set(["fileUrl","filePath"]),Ws=new Set([...Hs,"webStream","nodeStream"]),Gs=new Set(["webTransform","duplex"]),Vs={generator:"a generator",asyncGenerator:"an async generator",fileUrl:"a file URL",filePath:"a file path string",fileNumber:"a file descriptor number",webStream:"a web stream",nodeStream:"a Node.js stream",webTransform:"a web TransformStream",duplex:"a Duplex stream",native:"any value",iterable:"an iterable",asyncIterable:"an async iterable",string:"a string",uint8Array:"a Uint8Array"},qs=(e,t,n,r)=>"output"===r?Ks(e,t,n):zs(e,t,n),Ks=(e,t,n)=>{const r=0!==t&&n[t-1].value.readableObjectMode;return{writableObjectMode:r,readableObjectMode:e??r}},zs=(e,t,n)=>{const r=0===t?!0===e:n[t-1].value.readableObjectMode;return{writableObjectMode:r,readableObjectMode:t!==n.length-1&&(e??r)}},Ys=(e,t,n,{encoding:r})=>{const i=e.filter(({type:e})=>Fs.has(e)),o=Array.from({length:i.length});for(const[e,s]of Object.entries(i))o[e]=Js({stdioItem:s,index:Number(e),newTransforms:o,optionName:t,direction:n,encoding:r});return ea(o,n)},Js=({stdioItem:e,stdioItem:{type:t},index:n,newTransforms:r,optionName:i,direction:o,encoding:s})=>"duplex"===t?Xs({stdioItem:e,optionName:i}):"webTransform"===t?Qs({stdioItem:e,index:n,newTransforms:r,direction:o}):Zs({stdioItem:e,index:n,newTransforms:r,direction:o,encoding:s}),Xs=({stdioItem:e,stdioItem:{value:{transform:t,transform:{writableObjectMode:n,readableObjectMode:r},objectMode:i=r}},optionName:o})=>{if(i&&!r)throw new TypeError(`The \`${o}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!i&&r)throw new TypeError(`The \`${o}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...e,value:{transform:t,writableObjectMode:n,readableObjectMode:r}}},Qs=({stdioItem:e,stdioItem:{value:t},index:n,newTransforms:r,direction:i})=>{const{transform:o,objectMode:s}=Ge(t)?t:{transform:t},{writableObjectMode:a,readableObjectMode:l}=qs(s,n,r,i);return{...e,value:{transform:o,writableObjectMode:a,readableObjectMode:l}}},Zs=({stdioItem:e,stdioItem:{value:t},index:n,newTransforms:r,direction:i,encoding:o})=>{const{transform:s,final:a,binary:l=!1,preserveNewlines:c=!1,objectMode:d}=Ge(t)?t:{transform:t},u=l||eo.has(o),{writableObjectMode:p,readableObjectMode:m}=qs(d,n,r,i);return{...e,value:{transform:s,final:a,binary:u,preserveNewlines:c,writableObjectMode:p,readableObjectMode:m}}},ea=(e,t)=>"input"===t?e.reverse():e,ta=["input","output","output"],na=()=>{},ra=()=>"input",ia={generator:na,asyncGenerator:na,fileUrl:na,filePath:na,iterable:ra,asyncIterable:ra,uint8Array:ra,webStream:e=>js(e)?"output":"input",nodeStream:e=>yo(e,{checkOpen:!1})?wo(e,{checkOpen:!1})?void 0:"input":"output",webTransform:na,duplex:na,native(e){const t=oa(e);return void 0!==t?t:bo(e,{checkOpen:!1})?ia.nodeStream(e):void 0}},oa=e=>[0,v.stdin].includes(e)?"input":[1,2,v.stdout,v.stderr].includes(e)?"output":void 0,sa=e=>gt.some(t=>void 0!==e[t]),aa=(e,t)=>Array.isArray(e)?e.map(e=>aa(e,t)):null==e?t>=gt.length?"ignore":"pipe":e,la=e=>"pipe"===e||Array.isArray(e)&&e.every(e=>"pipe"===e),ca=({value:e,optionName:t,fdNumber:n,direction:r})=>{const i=da(e,n);if(void 0!==i){if("output"===r)return{type:"fileNumber",value:i,optionName:t};if(L.isatty(i))throw new TypeError(`The \`${t}: ${li(e)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:Qe(h(i)),optionName:t}}},da=(e,t)=>{if("inherit"===e)return t;if("number"==typeof e)return e;const n=ft.indexOf(e);return-1!==n?n:void 0},ua=(e,t,n)=>{const r=ft[e];if(void 0===r)throw new TypeError(`The \`${n}: ${t}\` option is invalid: no such standard stream.`);return r},pa=({input:e,inputFile:t},n)=>0===n?[...ma(e),...fa(t)]:[],ma=e=>void 0===e?[]:[{type:ha(e),value:e,optionName:"input"}],ha=e=>{if(yo(e,{checkOpen:!1}))return"nodeStream";if("string"==typeof e)return"string";if(Xe(e))return"uint8Array";throw new Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},fa=e=>void 0===e?[]:[{...ga(e),optionName:"inputFile"}],ga=e=>{if(Ts(e))return{type:"fileUrl",value:e};if(Ds(e))return{type:"filePath",value:{file:e}};throw new Error("The `inputFile` option must be a file path string or a file URL.")},ba=({otherStdioItems:e,type:t,value:n,optionName:r,direction:i})=>{const o=e.filter(e=>wa(e,n));if(0===o.length)return;const s=o.find(e=>e.direction!==i);return ya(s,r,t),"output"===i?o[0].stream:void 0},wa=({type:e,value:t},n)=>"filePath"===e?t.file===n.file:"fileUrl"===e?t.href===n.href:t===n,ya=(e,t,n)=>{if(void 0!==e)throw new TypeError(`The \`${e.optionName}\` and \`${t}\` options must not target ${Vs[n]} that is the same.`)},va=(e,t,n,r)=>{const i=(({stdio:e,ipc:t,buffer:n,...r},i,o)=>{const s=((e,t)=>{if(void 0===e)return gt.map(e=>t[e]);if(sa(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${gt.map(e=>`\`${e}\``).join(", ")}`);if("string"==typeof e)return[e,e,e];if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);const n=Math.max(e.length,gt.length);return Array.from({length:n},(t,n)=>e[n])})(e,r).map((e,t)=>aa(e,t));return o?((e,t,n)=>e.map((e,r)=>t[r]||0===r||kt(n,r)||!la(e)?e:"ignore"))(s,n,i):((e,t)=>t&&!e.includes("ipc")?[...e,"ipc"]:e)(s,t)})(t,n,r),o=i.map((e,n)=>$a({stdioOption:e,fdNumber:n,options:t,isSync:r})),s=Aa({initialFileDescriptors:o,addProperties:e,options:t,isSync:r});return t.stdio=s.map(({stdioItems:e})=>Ma(e)),s},$a=({stdioOption:e,fdNumber:t,options:n,isSync:r})=>{const i=bt(t),{stdioItems:o,isStdioArray:s}=Sa({stdioOption:e,fdNumber:t,options:n,optionName:i}),a=((e,t,n)=>{const r=e.map(e=>(({type:e,value:t},n)=>ta[n]??ia[e](t))(e,t));if(r.includes("input")&&r.includes("output"))throw new TypeError(`The \`${n}\` option must not be an array of both readable and writable values.`);return r.find(Boolean)??"output"})(o,t,i),l=o.map(e=>(({stdioItem:e,stdioItem:{type:t},isStdioArray:n,fdNumber:r,direction:i,isSync:o})=>n&&"native"===t?o?(({stdioItem:e,stdioItem:{value:t,optionName:n},fdNumber:r,direction:i})=>{const o=ca({value:t,optionName:n,fdNumber:r,direction:i});if(void 0!==o)return o;if(bo(t,{checkOpen:!1}))throw new TypeError(`The \`${n}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return e})({stdioItem:e,fdNumber:r,direction:i}):(({stdioItem:e,stdioItem:{value:t,optionName:n},fdNumber:r})=>"inherit"===t?{type:"nodeStream",value:ua(r,t,n),optionName:n}:"number"==typeof t?{type:"nodeStream",value:ua(t,t,n),optionName:n}:bo(t,{checkOpen:!1})?{type:"nodeStream",value:t,optionName:n}:e)({stdioItem:e,fdNumber:r}):e)({stdioItem:e,isStdioArray:s,fdNumber:t,direction:a,isSync:r})),c=((e,t,n,r)=>[...e.filter(({type:e})=>!Fs.has(e)),...Ys(e,t,n,r)])(l,i,a,n),d=((e,t)=>{const n=e.findLast(({type:e})=>Fs.has(e));return void 0!==n&&("input"===t?n.value.writableObjectMode:n.value.readableObjectMode)})(c,a);return Ta(c,d),{direction:a,objectMode:d,stdioItems:c}},Sa=({stdioOption:e,fdNumber:t,options:n,optionName:r})=>{const i=(e=>e.filter((t,n)=>e.every((e,r)=>t.value!==e.value||n>=r||"generator"===t.type||"asyncGenerator"===t.type)))([...(Array.isArray(e)?e:[e]).map(e=>Ea(e,r)),...pa(n,t)]),o=i.length>1;return xa(i,o,r),Ca(i),{stdioItems:i,isStdioArray:o}},Ea=(e,t)=>({type:gs(e,t),value:e,optionName:t}),xa=(e,t,n)=>{if(0===e.length)throw new TypeError(`The \`${n}\` option must not be an empty array.`);if(t)for(const{value:t,optionName:n}of e)if(Oa.has(t))throw new Error(`The \`${n}\` option must not include \`${t}\`.`)},Oa=new Set(["ignore","ipc"]),Ca=e=>{for(const t of e)_a(t)},_a=({type:e,value:t,optionName:n})=>{if((e=>Ts(e)&&"file:"!==e.protocol)(t))throw new TypeError(`The \`${n}: URL\` option must use the \`file:\` scheme.\nFor example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(((e,t)=>"native"===e&&"string"==typeof t&&!ks.has(t))(e,t))throw new TypeError(`The \`${n}: { file: '...' }\` option must be used instead of \`${n}: '...'\`.`)},Ta=(e,t)=>{if(!t)return;const n=e.find(({type:e})=>Us.has(e));if(void 0!==n)throw new TypeError(`The \`${n.optionName}\` option cannot use both files and transforms in objectMode.`)},Aa=({initialFileDescriptors:e,addProperties:t,options:n,isSync:r})=>{const i=[];try{for(const o of e)i.push(Ia({fileDescriptor:o,fileDescriptors:i,addProperties:t,options:n,isSync:r}));return i}catch(e){throw ka(i),e}},Ia=({fileDescriptor:{direction:e,objectMode:t,stdioItems:n},fileDescriptors:r,addProperties:i,options:o,isSync:s})=>{const a=n.map(t=>Da({stdioItem:t,addProperties:i,direction:e,options:o,fileDescriptors:r,isSync:s}));return{direction:e,objectMode:t,stdioItems:a}},Da=({stdioItem:e,addProperties:t,direction:n,options:r,fileDescriptors:i,isSync:o})=>{const s=(({stdioItem:{type:e,value:t,optionName:n},direction:r,fileDescriptors:i,isSync:o})=>{const s=((e,t)=>e.flatMap(({direction:e,stdioItems:n})=>n.filter(e=>e.type===t).map(t=>({...t,direction:e}))))(i,e);if(0!==s.length){if(!o)return Ws.has(e)?ba({otherStdioItems:s,type:e,value:t,optionName:n,direction:r}):void(Gs.has(e)&&(({otherStdioItems:e,type:t,value:n,optionName:r})=>{const i=e.find(({value:{transform:e}})=>e===n.transform);ya(i,r,t)})({otherStdioItems:s,type:e,value:t,optionName:n}));(({otherStdioItems:e,type:t,value:n,optionName:r,direction:i})=>{Hs.has(t)&&ba({otherStdioItems:e,type:t,value:n,optionName:r,direction:i})})({otherStdioItems:s,type:e,value:t,optionName:n,direction:r})}})({stdioItem:e,direction:n,fileDescriptors:i,isSync:o});return void 0!==s?{...e,stream:s}:{...e,...t[n][e.type](e,r)}},ka=e=>{for(const{stdioItems:t}of e)for(const{stream:e}of t)void 0===e||ht(e)||e.destroy()},Ma=e=>{if(e.length>1)return e.some(({value:e})=>"overlapped"===e)?"overlapped":"pipe";const[{type:t,value:n}]=e;return"native"===t?n:"pipe"},ja=({type:e,optionName:t})=>{Na(t,Vs[e])},Na=(e,t)=>{throw new TypeError(`The \`${e}\` option cannot be ${t} with synchronous methods.`)},Pa={generator(){},asyncGenerator:ja,webStream:ja,nodeStream:ja,webTransform:ja,duplex:ja,asyncIterable:ja,native:({optionName:e,value:t})=>("ipc"!==t&&"overlapped"!==t||Na(e,`"${t}"`),{})},Ra={input:{...Pa,fileUrl:({value:e})=>({contents:[Qe(h(e))]}),filePath:({value:{file:e}})=>({contents:[Qe(h(e))]}),fileNumber:ja,iterable:({value:e})=>({contents:[...e]}),string:({value:e})=>({contents:[e]}),uint8Array:({value:e})=>({contents:[e]})},output:{...Pa,fileUrl:({value:e})=>({path:e}),filePath:({value:{file:e,append:t}})=>({path:e,append:t}),fileNumber:({value:e})=>({path:e}),iterable:ja,string:ja,uint8Array:ja}},La=(e,{stripFinalNewline:t},n)=>Ba(t,n)&&void 0!==e&&!Array.isArray(e)?co(e):e,Ba=(e,t)=>"all"===t?e[1]||e[2]:e[t],Fa=(e,t,n,r)=>e||n?void 0:Wa(t,r),Ua=(e,t,n)=>n?e.flatMap(e=>Ha(e,t)):Ha(e,t),Ha=(e,t)=>{const{transform:n,final:r}=Wa(t,{});return[...n(e),...r()]},Wa=(e,t)=>(t.previousChunks="",{transform:Ga.bind(void 0,t,e),final:qa.bind(void 0,t)}),Ga=function*(e,t,n){if("string"!=typeof n)return void(yield n);let{previousChunks:r}=e,i=-1;for(let o=0;o<n.length;o+=1)if("\n"===n[o]){const s=Va(n,o,t,e);let a=n.slice(i+1,o+1-s);r.length>0&&(a=Ya(r,a),r=""),yield a,i=o}i!==n.length-1&&(r=Ya(r,n.slice(i+1))),e.previousChunks=r},Va=(e,t,n,r)=>n?0:(r.isWindowsNewline=0!==t&&"\r"===e[t-1],r.isWindowsNewline?2:1),qa=function*({previousChunks:e}){e.length>0&&(yield e)},Ka=({binary:e,preserveNewlines:t,readableObjectMode:n,state:r})=>e||t||n?void 0:{transform:za.bind(void 0,r)},za=function*({isWindowsNewline:e=!1},t){const{unixNewline:n,windowsNewline:r,LF:i,concatBytes:o}="string"==typeof t?Ja:Xa;if(t.at(-1)===i)return void(yield t);const s=e?r:n;yield o(t,s)},Ya=(e,t)=>`${e}${t}`,Ja={windowsNewline:"\r\n",unixNewline:"\n",LF:"\n",concatBytes:Ya},Xa={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:(e,t)=>{const n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}},Qa=(e,t)=>e?void 0:Za.bind(void 0,t),Za=function*(e,t){if("string"!=typeof t&&!Xe(t)&&!te.isBuffer(t))throw new TypeError(`The \`${e}\` option's transform must use "objectMode: true" to receive as input: ${typeof t}.`);yield t},el=(e,t)=>e?tl.bind(void 0,t):nl.bind(void 0,t),tl=function*(e,t){rl(e,t),yield t},nl=function*(e,t){if(rl(e,t),"string"!=typeof t&&!Xe(t))throw new TypeError(`The \`${e}\` option's function must yield a string or an Uint8Array, not ${typeof t}.`);yield t},rl=(e,t)=>{if(null==t)throw new TypeError(`The \`${e}\` option's function must not call \`yield ${t}\`.\nInstead, \`yield\` should either be called with a value, or not be called at all. For example:\n if (condition) { yield value; }`)},il=(e,t,n)=>{if(n)return;if(e)return{transform:ol.bind(void 0,new TextEncoder)};const r=new I(t);return{transform:sl.bind(void 0,r),final:al.bind(void 0,r)}},ol=function*(e,t){te.isBuffer(t)?yield Qe(t):"string"==typeof t?yield e.encode(t):yield t},sl=function*(e,t){yield Xe(t)?e.write(t):t},al=function*(e){const t=e.end();""!==t&&(yield t)},ll=N(async(e,t,n,r)=>{t.currentIterable=e(...n);try{for await(const e of t.currentIterable)r.push(e)}finally{delete t.currentIterable}}),cl=async function*(e,t,n){if(n===t.length)return void(yield e);const{transform:r=ml}=t[n];for await(const i of r(e))yield*cl(i,t,n+1)},dl=async function*(e){for(const[t,{final:n}]of Object.entries(e))yield*ul(n,Number(t),e)},ul=async function*(e,t,n){if(void 0!==e)for await(const r of e())yield*cl(r,n,t+1)},pl=N(async({currentIterable:e},t)=>{if(void 0===e){if(t)throw t}else await(t?e.throw(t):e.return())}),ml=function*(e){yield e},hl=(e,t,n,r)=>{try{for(const r of e(...t))n.push(r);r()}catch(e){r(e)}},fl=(e,t)=>[...t.flatMap(t=>[...gl(t,e,0)]),...bl(e)],gl=function*(e,t,n){if(n===t.length)return void(yield e);const{transform:r=yl}=t[n];for(const i of r(e))yield*gl(i,t,n+1)},bl=function*(e){for(const[t,{final:n}]of Object.entries(e))yield*wl(n,Number(t),e)},wl=function*(e,t,n){if(void 0!==e)for(const r of e())yield*gl(r,n,t+1)},yl=function*(e){yield e},vl=({value:e,value:{transform:t,final:n,writableObjectMode:r,readableObjectMode:i},optionName:o},{encoding:s})=>{const a={},l=Sl(e,s,o),c=Os(t),d=Os(n),u=c?ll.bind(void 0,cl,a):hl.bind(void 0,gl),p=c||d?ll.bind(void 0,dl,a):hl.bind(void 0,bl),m=c||d?pl.bind(void 0,a):void 0;return{stream:new Y({writableObjectMode:r,writableHighWaterMark:J(r),readableObjectMode:i,readableHighWaterMark:J(i),transform(e,t,n){u([e,l,0],this,n)},flush(e){p([l],this,e)},destroy:m})}},$l=(e,t,n,r)=>{const i=t.filter(({type:e})=>"generator"===e),o=r?i.reverse():i;for(const{value:t,optionName:r}of o){const i=Sl(t,n,r);e=fl(i,e)}return e},Sl=({transform:e,final:t,binary:n,writableObjectMode:r,readableObjectMode:i,preserveNewlines:o},s,a)=>{const l={};return[{transform:Qa(r,a)},il(n,s,r),Fa(n,o,r,l),{transform:e,final:t},{transform:el(i,a)},Ka({binary:n,preserveNewlines:o,readableObjectMode:i,state:l})].filter(Boolean)},El=(e,t,n)=>{const{stdioItems:r}=e[t],i=r.filter(({contents:e})=>void 0!==e);if(0===i.length)return;if(0!==t){const[{type:e,optionName:t}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${t}\`, can be ${Vs[e]} with synchronous methods.`)}const o=i.map(({contents:e})=>e).map(e=>xl(e,r));n.input=rt(o)},xl=(e,t)=>{const n=$l(e,t,"utf8",!0);return Ol(n),rt(n)},Ol=e=>{const t=e.find(e=>"string"!=typeof e&&!Xe(e));if(void 0!==t)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${t}.`)},Cl=({stdioItems:e,encoding:t,verboseInfo:n,fdNumber:r})=>"all"!==r&&kt(n,r)&&!eo.has(t)&&_l(r)&&(e.some(({type:e,value:t})=>"native"===e&&Tl.has(t))||e.every(({type:e})=>Fs.has(e))),_l=e=>1===e||2===e,Tl=new Set(["pipe","overlapped"]),Al=e=>e._readableState.pipes.length>0,Il=(e,t,n)=>{const r=pn(e);ln({type:"output",verboseMessage:r,fdNumber:t,verboseInfo:n})},Dl=(e,t,n,r)=>{try{return $l(e,t,n,!1)}catch(t){return r.error=t,e}},kl=({chunks:e,objectMode:t,encoding:n,lines:r,stripFinalNewline:i,fdNumber:o})=>{if(t)return{serializedResult:e};if("buffer"===n)return{serializedResult:rt(e)};const s=((e,t)=>((e,t)=>{if("utf8"===t&&e.every(e=>"string"==typeof e))return e;const n=new I(t),r=e.map(e=>"string"==typeof e?et(e):e).map(e=>n.write(e)),i=n.end();return""===i?r:[...r,i]})(e,t).join(""))(e,n);return r[o]?{serializedResult:s,finalResult:Ua(s,!i[o],t)}:{serializedResult:s}},Ml=({serializedResult:e,fdNumber:t,state:n,verboseInfo:r,encoding:i,stdioItems:o,objectMode:s})=>{if(!Cl({stdioItems:o,encoding:i,verboseInfo:r,fdNumber:t}))return;const a=Ua(e,!1,s);try{((e,t,n)=>{for(const r of e)Il(r,t,n)})(a,t,r)}catch(e){n.error??=e}},jl=(e,t,n)=>{for(const{path:r,append:i}of t.filter(({type:e})=>Us.has(e))){const t="string"==typeof r?r:r.toString();i||n.has(t)?f(r,e):(n.add(t),g(r,e))}},Nl=async e=>{try{return await n(e,"exit")}catch{return Nl(e)}},Pl=async e=>{const[t,n]=await e;if(!Rl(t,n)&&Ll(t,n))throw new dr;return[t,n]},Rl=(e,t)=>void 0===e&&void 0===t,Ll=(e,t)=>0!==e||null!==t,Bl=(e,t,n)=>void 0!==e?e:Ll(t,n)?new dr:void 0,Fl=e=>e.node&&!e.ipc?{...e,ipc:!1}:e,Ul=({ipc:e,ipcInput:t,detached:n,cancelSignal:r})=>{t&&Hl("ipcInput"),e&&Hl("ipc: true"),n&&Hl("detached: true"),r&&Hl("cancelSignal")},Hl=e=>{throw new TypeError(`The "${e}" option cannot be used with synchronous methods.`)},Wl=({file:e,commandArguments:t,options:n,command:r,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{const l=Gl({file:e,commandArguments:t,options:n,command:r,escapedCommand:i,fileDescriptors:s,startTime:a});if(l.failed)return l;const{resultError:c,exitCode:d,signal:u,timedOut:p,isMaxBuffer:m}=(({error:e,status:t,signal:n,output:r},{maxBuffer:i})=>{const o=Bl(e,t,n),s="ETIMEDOUT"===o?.code,a=((e,t,n)=>"ENOBUFS"===e?.code&&null!==t&&t.some(e=>null!==e&&e.length>ns(n)))(o,r,i);return{resultError:o,exitCode:t,signal:n,timedOut:s,isMaxBuffer:a}})(l,n),{output:h,error:f=c}=(({fileDescriptors:e,syncResult:{output:t},options:n,isMaxBuffer:r,verboseInfo:i})=>{if(null===t)return{output:Array.from({length:3})};const o={},s=new Set([]);return{output:t.map((t,a)=>(({result:e,fileDescriptors:t,fdNumber:n,state:r,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:l,lines:c,stripFinalNewline:d,maxBuffer:u})=>{if(null===e)return;const p=((e,t,n)=>{if(!t)return e;const r=ns(n);return e.length>r?e.slice(0,r):e})(e,o,u),m=Qe(p),{stdioItems:h,objectMode:f}=t[n],g=Dl([m],h,l,r),{serializedResult:b,finalResult:w=b}=kl({chunks:g,objectMode:f,encoding:l,lines:c,stripFinalNewline:d,fdNumber:n});Ml({serializedResult:b,fdNumber:n,state:r,verboseInfo:s,encoding:l,stdioItems:h,objectMode:f});const y=a[n]?w:void 0;try{return void 0===r.error&&jl(b,h,i),y}catch(e){return r.error=e,y}})({result:t,fileDescriptors:e,fdNumber:a,state:o,outputFiles:s,isMaxBuffer:r,verboseInfo:i},n)),...o}})({fileDescriptors:s,syncResult:l,options:n,isMaxBuffer:m,verboseInfo:o}),g=h.map((e,t)=>La(e,n,t)),b=La((([,e,t],n)=>{if(n.all)return void 0===e?t:void 0===t?e:Array.isArray(e)?Array.isArray(t)?[...e,...t]:[...e,La(t,n,"all")]:Array.isArray(t)?[La(e,n,"all"),...t]:Xe(e)&&Xe(t)?ot([e,t]):`${e}${t}`})(h,n),n,"all");return ql({error:f,exitCode:d,signal:u,timedOut:p,isMaxBuffer:m,stdio:g,all:b,options:n,command:r,escapedCommand:i,startTime:a})},Gl=({file:e,commandArguments:t,options:n,command:r,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{((e,t)=>{for(const n of(e=>new Set(Object.entries(e).filter(([,{direction:e}])=>"input"===e).map(([e])=>Number(e))))(e))El(e,n,t)})(o,n);const r=Vl(n);return c(...lo(e,t,r))}catch(e){return as({error:e,command:r,escapedCommand:i,fileDescriptors:o,options:n,startTime:s,isSync:!0})}},Vl=({encoding:e,maxBuffer:t,...n})=>({...n,encoding:"buffer",maxBuffer:ns(t)}),ql=({error:e,exitCode:t,signal:n,timedOut:r,isMaxBuffer:i,stdio:o,all:s,options:a,command:l,escapedCommand:c,startTime:d})=>void 0===e?ss({command:l,escapedCommand:c,stdio:o,all:s,ipcOutput:[],options:a,startTime:d}):ls({error:e,command:l,escapedCommand:c,timedOut:r,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:t,signal:n,stdio:o,all:s,ipcOutput:[],options:a,startTime:d,isSync:!0}),Kl=({anyProcess:e,channel:t,isSubprocess:n,ipc:r},{reference:i=!0,filter:o}={})=>(Ur({methodName:"getOneMessage",isSubprocess:n,ipc:r,isConnected:vi(e)}),zl({anyProcess:e,channel:t,isSubprocess:n,filter:o,reference:i})),zl=async({anyProcess:e,channel:t,isSubprocess:n,filter:r,reference:i})=>{di(t,i);const o=bi(e,t,n),s=new AbortController;try{return await Promise.race([Yl(o,r,s),Jl(o,n,s),Xl(o,n,s)])}catch(t){throw Jr(e),t}finally{s.abort(),pi(t,i)}},Yl=async(e,t,{signal:r})=>{if(void 0===t){const[t]=await n(e,"message",{signal:r});return t}for await(const[n]of o(e,"message",{signal:r}))if(t(n))return n},Jl=async(e,t,{signal:r})=>{await n(e,"disconnect",{signal:r}),(e=>{throw new Error(`${Kr("getOneMessage",e)} could not complete: the ${Yr(e)} exited or disconnected.`)})(t)},Xl=async(e,t,{signal:r})=>{const[i]=await n(e,"strict:error",{signal:r});throw Gr(i,t)},Ql=({anyProcess:e,channel:t,isSubprocess:n,ipc:r},{reference:i=!0}={})=>Zl({anyProcess:e,channel:t,isSubprocess:n,ipc:r,shouldAwait:!n,reference:i}),Zl=({anyProcess:e,channel:t,isSubprocess:n,ipc:r,shouldAwait:i,reference:o})=>{Ur({methodName:"getEachMessage",isSubprocess:n,ipc:r,isConnected:vi(e)}),di(t,o);const s=bi(e,t,n),a=new AbortController,l={};return ec(e,s,a),tc({ipcEmitter:s,isSubprocess:n,controller:a,state:l}),nc({anyProcess:e,channel:t,ipcEmitter:s,isSubprocess:n,shouldAwait:i,controller:a,state:l,reference:o})},ec=async(e,t,r)=>{try{await n(t,"disconnect",{signal:r.signal}),r.abort()}catch{}},tc=async({ipcEmitter:e,isSubprocess:t,controller:r,state:i})=>{try{const[o]=await n(e,"strict:error",{signal:r.signal});i.error=Gr(o,t),r.abort()}catch{}},nc=async function*({anyProcess:e,channel:t,ipcEmitter:n,isSubprocess:r,shouldAwait:i,controller:s,state:a,reference:l}){try{for await(const[e]of o(n,"message",{signal:s.signal}))rc(a),yield e}catch{rc(a)}finally{s.abort(),pi(t,l),r||Jr(e),i&&await e}},rc=({error:e})=>{if(e)throw e},ic=(e,t,n)=>({sendMessage:ji.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n}),getOneMessage:Kl.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n}),getEachMessage:Ql.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n})}),oc=()=>{const e=new ee;return e.end(),e},sc=()=>new Z({read(){}}),ac=()=>new Q({write(){}}),lc=()=>new X({read(){},write(){}}),cc=async(e,t,n)=>fs(e,t,n),dc=({type:e,optionName:t})=>{throw new TypeError(`The \`${t}\` option cannot be ${Vs[e]}.`)},uc={fileNumber:dc,generator:vl,asyncGenerator:vl,nodeStream:({value:e})=>({stream:e}),webTransform({value:{transform:e,writableObjectMode:t,readableObjectMode:n}}){const r=t||n;return{stream:X.fromWeb(e,{objectMode:r})}},duplex:({value:{transform:e}})=>({stream:e}),native(){}},pc={input:{...uc,fileUrl:({value:e})=>({stream:w(e)}),filePath:({value:{file:e}})=>({stream:w(e)}),webStream:({value:e})=>({stream:Z.fromWeb(e)}),iterable:({value:e})=>({stream:Z.from(e)}),asyncIterable:({value:e})=>({stream:Z.from(e)}),string:({value:e})=>({stream:Z.from(e)}),uint8Array:({value:e})=>({stream:Z.from(te.from(e))})},output:{...uc,fileUrl:({value:e})=>({stream:b(e)}),filePath:({value:{file:e,append:t}})=>({stream:b(e,t?{flags:"a"}:{})}),webStream:({value:e})=>({stream:Q.fromWeb(e)}),iterable:dc,asyncIterable:dc,string:dc,uint8Array:dc}};function mc(e){if(!Array.isArray(e))throw new TypeError(`Expected an array, got \`${typeof e}\`.`);for(const t of e)yc(t);const t=e.some(({readableObjectMode:e})=>e),n=hc(e,t),r=new fc({objectMode:t,writableHighWaterMark:n,readableHighWaterMark:n});for(const t of e)r.add(t);return r}const hc=(e,t)=>{if(0===e.length)return J(t);const n=e.filter(({readableObjectMode:e})=>e===t).map(({readableHighWaterMark:e})=>e);return Math.max(...n)};class fc extends ee{#s=new Set([]);#a=new Set([]);#l=new Set([]);#c;#d=Symbol("unpipe");#u=new WeakMap;add(e){if(yc(e),this.#s.has(e))return;this.#s.add(e),this.#c??=gc(this,this.#s,this.#d);const t=vc({passThroughStream:this,stream:e,streams:this.#s,ended:this.#a,aborted:this.#l,onFinished:this.#c,unpipeEvent:this.#d});this.#u.set(e,t),e.pipe(this,{end:!1})}async remove(e){if(yc(e),!this.#s.has(e))return!1;const t=this.#u.get(e);return void 0!==t&&(this.#u.delete(e),e.unpipe(this),await t,!0)}}const gc=async(e,t,n)=>{Ic(e,Dc);const r=new AbortController;try{await Promise.race([bc(e,r),wc(e,t,n,r)])}finally{r.abort(),Ic(e,-Dc)}},bc=async(e,{signal:t})=>{try{await ne(e,{signal:t,cleanup:!0})}catch(t){throw Oc(e,t),t}},wc=async(e,t,n,{signal:r})=>{for await(const[i]of o(e,"unpipe",{signal:r}))t.has(i)&&i.emit(n)},yc=e=>{if("function"!=typeof e?.pipe)throw new TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)},vc=async({passThroughStream:e,stream:t,streams:n,ended:r,aborted:i,onFinished:o,unpipeEvent:s})=>{Ic(e,kc);const a=new AbortController;try{await Promise.race([$c(o,t,a),Sc({passThroughStream:e,stream:t,streams:n,ended:r,aborted:i,controller:a}),Ec({stream:t,streams:n,ended:r,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Ic(e,-kc)}n.size>0&&n.size===r.size+i.size&&(0===r.size&&i.size>0?_c(e):xc(e))},$c=async(e,t,{signal:n})=>{try{await e,n.aborted||_c(t)}catch(e){n.aborted||Oc(t,e)}},Sc=async({passThroughStream:e,stream:t,streams:n,ended:r,aborted:i,controller:{signal:o}})=>{try{await ne(t,{signal:o,cleanup:!0,readable:!0,writable:!1}),n.has(t)&&r.add(t)}catch(r){if(o.aborted||!n.has(t))return;Cc(r)?i.add(t):Tc(e,r)}},Ec=async({stream:e,streams:t,ended:r,aborted:i,unpipeEvent:o,controller:{signal:s}})=>{if(await n(e,o,{signal:s}),!e.readable)return n(s,"abort",{signal:s});t.delete(e),r.delete(e),i.delete(e)},xc=e=>{e.writable&&e.end()},Oc=(e,t)=>{Cc(t)?_c(e):Tc(e,t)},Cc=e=>"ERR_STREAM_PREMATURE_CLOSE"===e?.code,_c=e=>{(e.readable||e.writable)&&e.destroy()},Tc=(e,t)=>{e.destroyed||(e.once("error",Ac),e.destroy(t))},Ac=()=>{},Ic=(e,t)=>{const n=e.getMaxListeners();0!==n&&n!==Number.POSITIVE_INFINITY&&e.setMaxListeners(n+t)},Dc=2,kc=1,Mc=(e,t)=>{e.pipe(t),jc(e,t),Pc(e,t)},jc=async(e,t)=>{if(!ht(e)&&!ht(t)){try{await ne(e,{cleanup:!0,readable:!0,writable:!1})}catch{}Nc(t)}},Nc=e=>{e.writable&&e.end()},Pc=async(e,t)=>{if(!ht(e)&&!ht(t)){try{await ne(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Rc(e)}},Rc=e=>{e.readable&&e.destroy()},Lc=(e,t,n,r)=>{"output"===n?Mc(e.stdio[r],t):Mc(t,e.stdio[r]);const i=Bc[r];void 0!==i&&(e[i]=t),e.stdio[r]=t},Bc=["stdin","stdout","stderr"],Fc=({subprocess:e,stream:t,direction:n,fdNumber:r,pipeGroups:i,controller:o})=>{if(void 0===t)return;Uc(t,o);const[s,a]="output"===n?[t,e.stdio[r]]:[e.stdio[r],t],l=i.get(s)??[];i.set(s,[...l,a])},Uc=(e,{signal:t})=>{ht(e)&&ci(e,Hc,t)},Hc=2,Wc=[];Wc.push("SIGHUP","SIGINT","SIGTERM"),"win32"!==process.platform&&Wc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),"linux"===process.platform&&Wc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const Gc=e=>!!e&&"object"==typeof e&&"function"==typeof e.removeListener&&"function"==typeof e.emit&&"function"==typeof e.reallyExit&&"function"==typeof e.listeners&&"function"==typeof e.kill&&"number"==typeof e.pid&&"function"==typeof e.on,Vc=Symbol.for("signal-exit emitter"),qc=globalThis,Kc=Object.defineProperty.bind(Object);class zc{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(qc[Vc])return qc[Vc];Kc(qc,Vc,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){const n=this.listeners[e],r=n.indexOf(t);-1!==r&&(0===r&&1===n.length?n.length=0:n.splice(r,1))}emit(e,t,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(const i of this.listeners[e])r=!0===i(t,n)||r;return"exit"===e&&(r=this.emit("afterExit",t,n)||r),r}}class Yc{}const Jc=globalThis.process,{onExit:Xc}=(Qc=Gc(Jc)?new class extends Yc{#p="win32"===Jc.platform?"SIGINT":"SIGHUP";#m=new zc;#h;#f;#g;#b={};#w=!1;constructor(e){super(),this.#h=e,this.#b={};for(const t of Wc)this.#b[t]=()=>{const n=this.#h.listeners(t);let{count:r}=this.#m;const i=e;if("object"==typeof i.__signal_exit_emitter__&&"number"==typeof i.__signal_exit_emitter__.count&&(r+=i.__signal_exit_emitter__.count),n.length===r){this.unload();const n=this.#m.emit("exit",null,t),r="SIGHUP"===t?this.#p:t;n||e.kill(e.pid,r)}};this.#g=e.reallyExit,this.#f=e.emit}onExit(e,t){if(!Gc(this.#h))return()=>{};!1===this.#w&&this.load();const n=t?.alwaysLast?"afterExit":"exit";return this.#m.on(n,e),()=>{this.#m.removeListener(n,e),0===this.#m.listeners.exit.length&&0===this.#m.listeners.afterExit.length&&this.unload()}}load(){if(!this.#w){this.#w=!0,this.#m.count+=1;for(const e of Wc)try{const t=this.#b[e];t&&this.#h.on(e,t)}catch(e){}this.#h.emit=(e,...t)=>this.#y(e,...t),this.#h.reallyExit=e=>this.#v(e)}}unload(){this.#w&&(this.#w=!1,Wc.forEach(e=>{const t=this.#b[e];if(!t)throw new Error("Listener not defined for signal: "+e);try{this.#h.removeListener(e,t)}catch(e){}}),this.#h.emit=this.#f,this.#h.reallyExit=this.#g,this.#m.count-=1)}#v(e){return Gc(this.#h)?(this.#h.exitCode=e||0,this.#m.emit("exit",this.#h.exitCode,null),this.#g.call(this.#h,this.#h.exitCode)):0}#y(e,...t){const n=this.#f;if("exit"===e&&Gc(this.#h)){"number"==typeof t[0]&&(this.#h.exitCode=t[0]);const r=n.call(this.#h,e,...t);return this.#m.emit("exit",this.#h.exitCode,null),r}return n.call(this.#h,e,...t)}}(Jc):new class extends Yc{onExit(){return()=>{}}load(){}unload(){}},{onExit:(e,t)=>Qc.onExit(e,t),load:()=>Qc.load(),unload:()=>Qc.unload()});var Qc;const Zc=(e,t,n,...r)=>{if(Array.isArray(n))return{destination:t(ed,e)(n,...r),pipeOptions:e};if("string"==typeof n||n instanceof URL||Ke(n)){if(Object.keys(e).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');const[i,o,s]=Ye(n,...r);return{destination:t(ed)(i,o,s),pipeOptions:s}}if(ei.has(n)){if(Object.keys(e).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:n,pipeOptions:r[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${n}`)},ed=({options:e})=>({options:{...e,stdin:"pipe",piped:!0}}),td=({error:e,fileDescriptors:t,sourceOptions:n,startTime:r})=>as({error:e,command:nd,escapedCommand:nd,fileDescriptors:t,options:n,startTime:r,isSync:!1}),nd="source.pipe(destination)",rd=async e=>{const[{status:t,reason:n,value:r=n},{status:i,reason:o,value:s=o}]=await e;if(s.pipedFrom.includes(r)||s.pipedFrom.push(r),"rejected"===i)throw s;if("rejected"===t)throw r;return s},id=new WeakMap,od=(e,t)=>void 0===e?[]:[sd(e,t)],sd=async(e,{sourceStream:t,mergedStream:n,fileDescriptors:r,sourceOptions:i,startTime:o})=>{await P(e,t),await n.remove(t);const s=new Error("Pipe canceled by `unpipeSignal` option.");throw td({error:s,fileDescriptors:r,sourceOptions:i,startTime:o})},ad=(e,...t)=>{if(Ge(t[0]))return ad.bind(void 0,{...e,boundOptions:{...e.boundOptions,...t[0]}});const{destination:n,...r}=(({source:e,sourcePromise:t,boundOptions:n,createNested:r},...i)=>{const o=gn(),{destination:s,destinationStream:a,destinationError:l,from:c,unpipeSignal:d}=((e,t,n)=>{try{const{destination:r,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Zc(e,t,...n);return{destination:r,destinationStream:Qr(r,o),from:i,unpipeSignal:s}}catch(e){return{destinationError:e}}})(n,r,i),{sourceStream:u,sourceError:p}=((e,t)=>{try{return{sourceStream:Zr(e,t)}}catch(e){return{sourceError:e}}})(e,c),{options:m,fileDescriptors:h}=ei.get(e);return{sourcePromise:t,sourceStream:u,sourceOptions:m,sourceError:p,destination:s,destinationStream:a,destinationError:l,unpipeSignal:d,fileDescriptors:h,startTime:o}})(e,...t),i=ld({...r,destination:n});return i.pipe=ad.bind(void 0,{...e,source:n,sourcePromise:i,boundOptions:{}}),i},ld=async({sourcePromise:e,sourceStream:t,sourceOptions:n,sourceError:r,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:l,startTime:c})=>{const d=cd(e,i);(({sourceStream:e,sourceError:t,destinationStream:n,destinationError:r,fileDescriptors:i,sourceOptions:o,startTime:s})=>{const a=(({sourceStream:e,sourceError:t,destinationStream:n,destinationError:r})=>void 0!==t&&void 0!==r?r:void 0!==r?(Rc(e),r):void 0!==t?(Nc(n),t):void 0)({sourceStream:e,sourceError:t,destinationStream:n,destinationError:r});if(void 0!==a)throw td({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})})({sourceStream:t,sourceError:r,destinationStream:o,destinationError:s,fileDescriptors:l,sourceOptions:n,startTime:c});const u=new AbortController;try{const e=((e,t,n)=>{const r=id.has(t)?((e,t)=>{const n=id.get(t);return n.add(e),n})(e,t):((e,t)=>{const n=mc([e]);return Mc(n,t),id.set(t,n),n})(e,t);return ci(e,2,n.signal),ci(t,1,n.signal),(async e=>{try{await ne(e,{cleanup:!0,readable:!1,writable:!0})}catch{}id.delete(e)})(t),r})(t,o,u);return await Promise.race([rd(d),...od(a,{sourceStream:t,mergedStream:e,sourceOptions:n,fileDescriptors:l,startTime:c})])}finally{u.abort()}},cd=(e,t)=>Promise.allSettled([e,t]),dd=({subprocessStdout:e,subprocess:t,binary:n,shouldEncode:r,encoding:i,preserveNewlines:o})=>{const s=new AbortController;return ud(t,s),hd({stream:e,controller:s,binary:n,shouldEncode:!e.readableObjectMode&&r,encoding:i,shouldSplit:!e.readableObjectMode,preserveNewlines:o})},ud=async(e,t)=>{try{await e}catch{}finally{t.abort()}},pd=({stream:e,onStreamEnd:t,lines:n,encoding:r,stripFinalNewline:i,allMixed:o})=>{const s=new AbortController;md(t,s,e);const a=e.readableObjectMode&&!o;return hd({stream:e,controller:s,binary:"buffer"===r,shouldEncode:!a,encoding:r,shouldSplit:!a&&n,preserveNewlines:!i})},md=async(e,t,n)=>{try{await e}catch{n.destroy()}finally{t.abort()}},hd=({stream:e,controller:t,binary:n,shouldEncode:r,encoding:i,shouldSplit:s,preserveNewlines:a})=>{const l=o(e,"data",{signal:t.signal,highWaterMark:gd,highWatermark:gd});return bd({onStdoutChunk:l,controller:t,binary:n,shouldEncode:r,encoding:i,shouldSplit:s,preserveNewlines:a})},fd=J(!0),gd=fd,bd=async function*({onStdoutChunk:e,controller:t,binary:n,shouldEncode:r,encoding:i,shouldSplit:o,preserveNewlines:s}){const a=wd({binary:n,shouldEncode:r,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(const[t]of e)yield*gl(t,a,0)}catch(e){if(!t.signal.aborted)throw e}finally{yield*bl(a)}},wd=({binary:e,shouldEncode:t,encoding:n,shouldSplit:r,preserveNewlines:i})=>[il(e,n,!t),Fa(e,i,!r,{})].filter(Boolean),yd=async({stream:e,onStreamEnd:t,fdNumber:n,encoding:r,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:l,verboseInfo:c,streamInfo:d})=>{const u=vd({stream:e,onStreamEnd:t,fdNumber:n,encoding:r,allMixed:a,verboseInfo:c,streamInfo:d});if(!i)return void await Promise.all([$d(e),u]);const p=Ba(l,n),m=pd({stream:e,onStreamEnd:t,lines:s,encoding:r,stripFinalNewline:p,allMixed:a}),[h]=await Promise.all([Sd({stream:e,iterable:m,fdNumber:n,encoding:r,maxBuffer:o,lines:s}),u]);return h},vd=async({stream:e,onStreamEnd:t,fdNumber:n,encoding:r,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Cl({stdioItems:s[n]?.stdioItems,encoding:r,verboseInfo:o,fdNumber:n}))return;const a=pd({stream:e,onStreamEnd:t,lines:!0,encoding:r,stripFinalNewline:!0,allMixed:i});await(async(e,t,n,r)=>{for await(const i of e)Al(t)||Il(i,n,r)})(a,e,n,o)},$d=async e=>{await q(),null===e.readableFlowing&&e.resume()},Sd=async({stream:e,stream:{readableObjectMode:t},iterable:n,fdNumber:r,encoding:i,maxBuffer:o,lines:s})=>{try{return t||s?await async function(e,t){return Mo(e,Vo,t)}(n,{maxBuffer:o}):"buffer"===i?new Uint8Array(await async function(e,t){return Mo(e,Qo,t)}(n,{maxBuffer:o})):await async function(e,t){return Mo(e,es,t)}(n,{maxBuffer:o})}catch(n){return xd((({error:e,stream:t,readableObjectMode:n,lines:r,encoding:i,fdNumber:o})=>{if(!(e instanceof Bo))throw e;if("all"===o)return e;const s=((e,t,n)=>e?"objects":t?"lines":"buffer"===n?"bytes":"characters")(n,r,i);throw e.maxBufferInfo={fdNumber:o,unit:s},t.destroy(),e})({error:n,stream:e,readableObjectMode:t,lines:s,encoding:i,fdNumber:r}))}},Ed=async e=>{try{return await e}catch(e){return xd(e)}},xd=({bufferedData:e})=>{return t=e,"[object ArrayBuffer]"===Je.call(t)?new Uint8Array(e):e;var t},Od=async(e,t,n,{isSameDirection:r,stopOnExit:i=!1}={})=>{const o=Cd(e,n),s=new AbortController;try{await Promise.race([...i?[n.exitPromise]:[],ne(e,{cleanup:!0,signal:s.signal})])}catch(e){o.stdinCleanedUp||Ad(e,t,n,r)}finally{s.abort()}},Cd=(e,{originalStreams:[t],subprocess:n})=>{const r={stdinCleanedUp:!1};return e===t&&_d(e,n,r),r},_d=(e,t,n)=>{const{_destroy:r}=e;e._destroy=(...i)=>{Td(t,n),r.call(e,...i)}},Td=({exitCode:e,signalCode:t},n)=>{null===e&&null===t||(n.stdinCleanedUp=!0)},Ad=(e,t,n,r)=>{if(!Id(e,t,n,r))throw e},Id=(e,t,n,r=!0)=>n.propagating?Md(e)||kd(e):(n.propagating=!0,Dd(n,t)===r?Md(e):kd(e)),Dd=({fileDescriptors:e},t)=>"all"!==t&&"input"===e[t].direction,kd=e=>"ERR_STREAM_PREMATURE_CLOSE"===e?.code,Md=e=>"EPIPE"===e?.code,jd=async({stream:e,fdNumber:t,encoding:n,buffer:r,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:l,streamInfo:c})=>{if(!e)return;const d=Od(e,t,c);if(Dd(c,t))return void await d;const[u]=await Promise.all([yd({stream:e,onStreamEnd:d,fdNumber:t,encoding:n,buffer:r,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:l,streamInfo:c}),d]);return u},Nd=({stdout:e,stderr:t,all:n},[,r,i])=>{const o=r||i;return o?r?i?{stream:n,buffer:o}:{stream:e,buffer:o}:{stream:t,buffer:o}:{stream:n,buffer:o}},Pd=({all:e,stdout:t,stderr:n})=>e&&t&&n&&t.readableObjectMode!==n.readableObjectMode,Rd=(e,t)=>{const n=pn(e);ln({type:"ipc",verboseMessage:n,fdNumber:"ipc",verboseInfo:t})},Ld=async(e,t)=>(await Promise.allSettled([e]),t),Bd=async({subprocess:e,options:{encoding:t,buffer:r,maxBuffer:i,lines:o,timeoutDuration:s,cancelSignal:a,gracefulCancel:l,forceKillAfterDelay:c,stripFinalNewline:d,ipc:u,ipcInput:p},context:m,verboseInfo:h,fileDescriptors:f,originalStreams:g,onInternalError:b,controller:w})=>{const y=(async(e,t)=>{const[r,i]=await(async e=>{const[t,r]=await Promise.allSettled([n(e,"spawn"),n(e,"exit")]);return"rejected"===t.status?[]:"rejected"===r.status?Nl(e):r.value})(e);return t.isForcefullyTerminated??=!1,[r,i]})(e,m),v={originalStreams:g,fileDescriptors:f,subprocess:e,exitPromise:y,propagating:!1},$=(({subprocess:e,encoding:t,buffer:n,maxBuffer:r,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>e.stdio.map((e,l)=>jd({stream:e,fdNumber:l,encoding:t,buffer:n[l],maxBuffer:r[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})))({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:o,stripFinalNewline:d,verboseInfo:h,streamInfo:v}),S=(({subprocess:e,encoding:t,buffer:n,maxBuffer:r,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>jd({...Nd(e,n),fdNumber:"all",encoding:t,maxBuffer:r[1]+r[2],lines:i[1]||i[2],allMixed:Pd(e),stripFinalNewline:o,verboseInfo:s,streamInfo:a}))({subprocess:e,encoding:t,buffer:r,maxBuffer:i,lines:o,stripFinalNewline:d,verboseInfo:h,streamInfo:v}),E=[],x=(async({subprocess:e,buffer:t,maxBuffer:n,ipc:r,ipcOutput:i,verboseInfo:o})=>{if(!r)return i;const s=(e=>kt(e,"ipc"))(o),a=It(t,"ipc"),l=It(n,"ipc");for await(const t of Zl({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:r,shouldAwait:!1,reference:!0}))a&&(ts(0,i,l),i.push(t)),s&&Rd(t,o);return i})({subprocess:e,buffer:r,maxBuffer:i,ipc:u,ipcOutput:E,verboseInfo:h}),O=Fd(g,e,v),C=Ud(f,v);try{return await Promise.race([Promise.all([{},Pl(y),Promise.all($),S,x,Qi(e,p),...O,...C]),b,Hd(e,w),...Yi(e,s,m,w),...Br({subprocess:e,cancelSignal:a,gracefulCancel:l,context:m,controller:w}),...qi({subprocess:e,cancelSignal:a,gracefulCancel:l,forceKillAfterDelay:c,context:m,controller:w})])}catch(e){return m.terminationReason??="other",Promise.all([{error:e},y,Promise.all($.map(e=>Ed(e))),Ed(S),Ld(x,E),Promise.allSettled(O),Promise.allSettled(C)])}},Fd=(e,t,n)=>e.map((e,r)=>e===t.stdio[r]?void 0:Od(e,r,n)),Ud=(e,t)=>e.flatMap(({stdioItems:e},n)=>e.filter(({value:e,stream:t=e})=>bo(t,{checkOpen:!1})&&!ht(t)).map(({type:e,value:r,stream:i=r})=>Od(i,n,t,{isSameDirection:Fs.has(e),stopOnExit:"native"===e}))),Hd=async(e,{signal:t})=>{const[r]=await n(e,"error",{signal:t});throw r},Wd=(e,t,n)=>{const r=e[n];r.has(t)||r.set(t,[]);const i=r.get(t),o=Xr();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Gd=async({resolve:e,promises:t},n)=>{e();const[r]=await Promise.race([Promise.allSettled([!0,n]),Promise.all([!1,...t])]);return!r},Vd=async e=>{if(void 0!==e)try{await qd(e)}catch{}},qd=async e=>{await ne(e,{cleanup:!0,readable:!1,writable:!0})},Kd=async e=>{await ne(e,{cleanup:!0,readable:!0,writable:!1})},zd=async(e,t)=>{if(await e,t)throw t},Yd=(e,t,n)=>{n&&!kd(n)?e.destroy(n):t&&e.destroy()},Jd=({subprocess:e,concurrentStreams:t,encoding:n},{from:r,binary:i=!0,preserveNewlines:o=!0}={})=>{const s=i||eo.has(n),{subprocessStdout:a,waitReadableDestroy:l}=Xd(e,r,t),{readableEncoding:c,readableObjectMode:d,readableHighWaterMark:u}=Qd(a,s),{read:p,onStdoutDataDone:m}=Zd({subprocessStdout:a,subprocess:e,binary:s,encoding:n,preserveNewlines:o}),h=new Z({read:p,destroy:N(nu.bind(void 0,{subprocessStdout:a,subprocess:e,waitReadableDestroy:l})),highWaterMark:u,objectMode:d,encoding:c});return tu({subprocessStdout:a,onStdoutDataDone:m,readable:h,subprocess:e}),h},Xd=(e,t,n)=>{const r=Zr(e,t);return{subprocessStdout:r,waitReadableDestroy:Wd(n,r,"readableDestroy")}},Qd=({readableEncoding:e,readableObjectMode:t,readableHighWaterMark:n},r)=>r?{readableEncoding:e,readableObjectMode:t,readableHighWaterMark:n}:{readableEncoding:e,readableObjectMode:!0,readableHighWaterMark:fd},Zd=({subprocessStdout:e,subprocess:t,binary:n,encoding:r,preserveNewlines:i})=>{const o=Xr(),s=dd({subprocessStdout:e,subprocess:t,binary:n,shouldEncode:!n,encoding:r,preserveNewlines:i});return{read(){eu(this,s,o)},onStdoutDataDone:o}},eu=async(e,t,n)=>{try{const{value:r,done:i}=await t.next();i?n.resolve():e.push(r)}catch{}},tu=async({subprocessStdout:e,onStdoutDataDone:t,readable:n,subprocess:r,subprocessStdin:i})=>{try{await Kd(e),await r,await Vd(i),await t,n.readable&&n.push(null)}catch(e){await Vd(i),ru(n,e)}},nu=async({subprocessStdout:e,subprocess:t,waitReadableDestroy:n},r)=>{await Gd(n,t)&&(ru(e,r),await zd(t,r))},ru=(e,t)=>{Yd(e,e.readable,t)},iu=({subprocess:e,concurrentStreams:t},{to:n}={})=>{const{subprocessStdin:r,waitWritableFinal:i,waitWritableDestroy:o}=ou(e,n,t),s=new Q({...su(r,e,i),destroy:N(du.bind(void 0,{subprocessStdin:r,subprocess:e,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:r.writableHighWaterMark,objectMode:r.writableObjectMode});return cu(r,s),s},ou=(e,t,n)=>{const r=Qr(e,t);return{subprocessStdin:r,waitWritableFinal:Wd(n,r,"writableFinal"),waitWritableDestroy:Wd(n,r,"writableDestroy")}},su=(e,t,n)=>({write:au.bind(void 0,e),final:N(lu.bind(void 0,e,t,n))}),au=(e,t,n,r)=>{e.write(t,n)?r():e.once("drain",r)},lu=async(e,t,n)=>{await Gd(n,t)&&(e.writable&&e.end(),await t)},cu=async(e,t,n)=>{try{await qd(e),t.writable&&t.end()}catch(e){await(async e=>{if(void 0!==e)try{await Kd(e)}catch{}})(n),uu(t,e)}},du=async({subprocessStdin:e,subprocess:t,waitWritableFinal:n,waitWritableDestroy:r},i)=>{await Gd(n,t),await Gd(r,t)&&(uu(e,i),await zd(t,i))},uu=(e,t)=>{Yd(e,e.writable,t)},pu=({subprocess:e,concurrentStreams:t,encoding:n},{from:r,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{const a=o||eo.has(n),{subprocessStdout:l,waitReadableDestroy:c}=Xd(e,r,t),{subprocessStdin:d,waitWritableFinal:u,waitWritableDestroy:p}=ou(e,i,t),{readableEncoding:m,readableObjectMode:h,readableHighWaterMark:f}=Qd(l,a),{read:g,onStdoutDataDone:b}=Zd({subprocessStdout:l,subprocess:e,binary:a,encoding:n,preserveNewlines:s}),w=new X({read:g,...su(d,e,u),destroy:N(mu.bind(void 0,{subprocessStdout:l,subprocessStdin:d,subprocess:e,waitReadableDestroy:c,waitWritableFinal:u,waitWritableDestroy:p})),readableHighWaterMark:f,writableHighWaterMark:d.writableHighWaterMark,readableObjectMode:h,writableObjectMode:d.writableObjectMode,encoding:m});return tu({subprocessStdout:l,onStdoutDataDone:b,readable:w,subprocess:e,subprocessStdin:d}),cu(d,w,l),w},mu=async({subprocessStdout:e,subprocessStdin:t,subprocess:n,waitReadableDestroy:r,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([nu({subprocessStdout:e,subprocess:n,waitReadableDestroy:r},s),du({subprocessStdin:t,subprocess:n,waitWritableFinal:i,waitWritableDestroy:o},s)])},hu=(e,t,{from:n,binary:r=!1,preserveNewlines:i=!1}={})=>{const o=r||eo.has(t),s=Zr(e,n),a=dd({subprocessStdout:s,subprocess:e,binary:o,shouldEncode:!0,encoding:t,preserveNewlines:i});return fu(a,s,e)},fu=async function*(e,t,n){try{yield*e}finally{t.readable&&t.destroy(),await n}},gu=(e,{encoding:t})=>{const n={readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap};e.readable=Jd.bind(void 0,{subprocess:e,concurrentStreams:n,encoding:t}),e.writable=iu.bind(void 0,{subprocess:e,concurrentStreams:n}),e.duplex=pu.bind(void 0,{subprocess:e,concurrentStreams:n,encoding:t}),e.iterable=hu.bind(void 0,e,t),e[Symbol.asyncIterator]=hu.bind(void 0,e,t,{})},bu=(async()=>{})().constructor.prototype,wu=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(bu,e)]),yu=(e,t,n)=>{const{command:r,escapedCommand:i,startTime:o,verboseInfo:s}=wn(e,t,n),{file:a,commandArguments:l,options:c}=oo(e,t,n),d=vu(c),u=((e,t)=>va(pc,e,t,!1))(d,s);return{file:a,commandArguments:l,command:r,escapedCommand:i,startTime:o,verboseInfo:s,options:d,fileDescriptors:u}},vu=({timeout:e,signal:t,...n})=>{if(void 0!==t)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...n,timeoutDuration:e}},$u=({file:e,commandArguments:t,options:n,startTime:i,verboseInfo:o,command:a,escapedCommand:c,fileDescriptors:u})=>{let p;try{p=d(...lo(e,t,n))}catch(e){return(({error:e,command:t,escapedCommand:n,fileDescriptors:r,options:i,startTime:o,verboseInfo:s})=>{ka(r);const a=new l;((e,t)=>{const n=oc(),r=oc(),i=oc(),o=Array.from({length:t.length-3},oc),s=oc(),a=[n,r,i,...o];Object.assign(e,{stdin:n,stdout:r,stderr:i,all:s,stdio:a})})(a,r),Object.assign(a,{readable:sc,writable:ac,duplex:lc});const c=as({error:e,command:t,escapedCommand:n,fileDescriptors:r,options:i,startTime:o,isSync:!1});return{subprocess:a,promise:cc(c,s,i)}})({error:e,command:a,escapedCommand:c,fileDescriptors:u,options:n,startTime:i,verboseInfo:o})}const m=new AbortController;s(Number.POSITIVE_INFINITY,m.signal);const h=[...p.stdio];((e,t,n)=>{const r=new Map;for(const[i,{stdioItems:o,direction:s}]of Object.entries(t)){for(const{stream:t}of o.filter(({type:e})=>Fs.has(e)))Lc(e,t,s,i);for(const{stream:t}of o.filter(({type:e})=>!Fs.has(e)))Fc({subprocess:e,stream:t,direction:s,fdNumber:i,pipeGroups:r,controller:n})}for(const[e,t]of r.entries()){const n=1===t.length?t[0]:mc(t);Mc(n,e)}})(p,u,m),((e,{cleanup:t,detached:n},{signal:i})=>{if(!t||n)return;const o=Xc(()=>{e.kill()});r(i,()=>{o()})})(p,n,m);const f={},g=Xr();return p.kill=Mr.bind(void 0,{kill:p.kill.bind(p),options:n,onInternalError:g,context:f,controller:m}),p.all=(({stdout:e,stderr:t},{all:n})=>n&&(e||t)?mc([e,t].filter(Boolean)):void 0)(p,n),gu(p,n),((e,{ipc:t})=>{Object.assign(e,ic(e,!1,t))})(p,n),{subprocess:p,promise:Su({subprocess:p,options:n,startTime:i,verboseInfo:o,fileDescriptors:u,originalStreams:h,command:a,escapedCommand:c,context:f,onInternalError:g,controller:m})}},Su=async({subprocess:e,options:t,startTime:n,verboseInfo:r,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:l,onInternalError:c,controller:d})=>{const[u,[p,m],h,f,g]=await Bd({subprocess:e,options:t,context:l,verboseInfo:r,fileDescriptors:i,originalStreams:o,onInternalError:c,controller:d});d.abort(),c.resolve();const b=h.map((e,n)=>La(e,t,n)),w=La(f,t,"all"),y=Eu({errorInfo:u,exitCode:p,signal:m,stdio:b,all:w,ipcOutput:g,context:l,options:t,command:s,escapedCommand:a,startTime:n});return fs(y,r,t)},Eu=({errorInfo:e,exitCode:t,signal:n,stdio:r,all:i,ipcOutput:o,context:s,options:a,command:l,escapedCommand:c,startTime:d})=>"error"in e?ls({error:e.error,command:l,escapedCommand:c,timedOut:"timeout"===s.terminationReason,isCanceled:"cancel"===s.terminationReason||"gracefulCancel"===s.terminationReason,isGracefullyCanceled:"gracefulCancel"===s.terminationReason,isMaxBuffer:e.error instanceof Bo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:t,signal:n,stdio:r,all:i,ipcOutput:o,options:a,startTime:d,isSync:!1}):ss({command:l,escapedCommand:c,stdio:r,all:i,ipcOutput:o,options:a,startTime:d}),xu=(e,t)=>{const n=Object.fromEntries(Object.entries(t).map(([t,n])=>[t,Ou(t,e[t],n)]));return{...e,...n}},Ou=(e,t,n)=>Cu.has(e)&&Ge(t)&&Ge(n)?{...t,...n}:n,Cu=new Set(["env",...At]),_u=(e,t,n,r)=>{const i=(e,t,r)=>_u(e,t,n,r),o=(...o)=>Tu({mapArguments:e,deepOptions:n,boundOptions:t,setBoundExeca:r,createNested:i},...o);return void 0!==r&&r(o,i,t),o},Tu=({mapArguments:e,deepOptions:t={},boundOptions:n={},setBoundExeca:r,createNested:i},o,...s)=>{if(Ge(o))return i(e,xu(n,o),r);const{file:a,commandArguments:l,options:c,isSync:d}=Au({mapArguments:e,firstArgument:o,nextArguments:s,deepOptions:t,boundOptions:n});return d?((e,t,n)=>{const{file:r,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:l,options:c,fileDescriptors:d}=((e,t,n)=>{const{command:r,escapedCommand:i,startTime:o,verboseInfo:s}=wn(e,t,n),a=Fl(n),{file:l,commandArguments:c,options:d}=oo(e,t,a);Ul(d);const u=((e,t)=>va(Ra,e,t,!0))(d,s);return{file:l,commandArguments:c,command:r,escapedCommand:i,startTime:o,verboseInfo:s,options:d,fileDescriptors:u}})(e,t,n),u=Wl({file:r,commandArguments:i,options:c,command:o,escapedCommand:s,verboseInfo:l,fileDescriptors:d,startTime:a});return fs(u,l,c)})(a,l,c):((e,t,n,r)=>{const{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:l,verboseInfo:c,options:d,fileDescriptors:u}=yu(e,t,n),{subprocess:p,promise:m}=$u({file:i,commandArguments:o,options:d,startTime:l,verboseInfo:c,command:s,escapedCommand:a,fileDescriptors:u});return p.pipe=ad.bind(void 0,{source:p,sourcePromise:m,boundOptions:{},createNested:r}),((e,t)=>{for(const[n,r]of wu){const i=r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:i})}})(p,m),ei.set(p,{options:d,fileDescriptors:u}),p})(a,l,c,i)},Au=({mapArguments:e,firstArgument:t,nextArguments:n,deepOptions:r,boundOptions:i})=>{const o=(s=t,Array.isArray(s)&&Array.isArray(s.raw)?((e,t)=>{let n=[];for(const[r,i]of e.entries())n=at({templates:e,expressions:t,tokens:n,index:r,template:i});if(0===n.length)throw new TypeError("Template script must not be empty");const[r,...i]=n;return[r,i,{}]})(t,n):[t,...n]);var s;const[a,l,c]=Ye(...o),d=xu(xu(r,i),c),{file:u=a,commandArguments:p=l,options:m=d,isSync:h=!1}=e({file:a,commandArguments:l,options:d});return{file:u,commandArguments:p,options:m,isSync:h}},Iu=(e,t)=>{if(t.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${e} ${t}.`);const[n,...r]=Du(e);return{file:n,commandArguments:r}},Du=e=>{if("string"!=typeof e)throw new TypeError(`The command must be a string: ${String(e)}.`);const t=e.trim();if(""===t)return[];const n=[];for(const e of t.split(ku)){const t=n.at(-1);t&&t.endsWith("\\")?n[n.length-1]=`${t.slice(0,-1)} ${e}`:n.push(e)}return n},ku=/ +/g,Mu=({options:e})=>({...ju(e),isSync:!0}),ju=e=>({options:{...Nu(e),...e}}),Nu=({input:e,inputFile:t,stdio:n})=>void 0===e&&void 0===t&&void 0===n?{stdin:"inherit"}:{};_u(()=>({})),_u(()=>({isSync:!0})),_u(({file:e,commandArguments:t})=>Iu(e,t)),_u(({file:e,commandArguments:t})=>({...Iu(e,t),isSync:!0})),_u(({options:e})=>{if(!1===e.node)throw new TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...e,node:!0}}});const Pu=_u(({options:e})=>ju(e),{},{preferLocal:!0},(e,t,n)=>{e.sync=t(Mu,n),e.s=e.sync});(()=>{const e=v,t=!0,n=void 0!==v.channel;ic(e,t,n),Bi.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n})})();const Ru=(()=>{const e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),Lu=e=>12288===e||e>=65281&&e<=65376||e>=65504&&e<=65510,Bu=e=>8987===e||9001===e||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Fu=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Uu=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Hu=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Wu=/\t{1,1000}/y,Gu=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Vu=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,qu=/\p{M}+/gu,Ku={limit:1/0,ellipsis:""},zu=(e,t={},n={})=>{const r=t.limit??1/0,i=t.ellipsis??"",o=t?.ellipsisWidth??(i?zu(i,Ku,n).width:0),s=n.controlWidth??0,a=n.tabWidth??8,l=n.emojiWidth??2,c=n.regularWidth??1,d=n.wideWidth??2,u=[[Vu,c],[Fu,0],[Uu,s],[Wu,a],[Gu,l],[Hu,d]];let p=0,m=0,h=e.length,f=0,g=!1,b=h,w=Math.max(0,r-o),y=0,v=0,$=0,S=0;e:for(;;){if(v>y||m>=h&&m>p){const t=e.slice(y,v)||e.slice(p,m);f=0;for(const e of t.replaceAll(qu,"")){const t=e.codePointAt(0)||0;if(S=Lu(t)?2:Bu(t)?d:c,$+S>w&&(b=Math.min(b,Math.max(y,p)+f)),$+S>r){g=!0;break e}f+=e.length,$+=S}y=v=0}if(m>=h)break e;for(let t=0,n=u.length;t<n;t++){const[n,i]=u[t];if(n.lastIndex=m,n.test(e)){if(f=n===Hu?Ru(e.slice(m,n.lastIndex)):n===Gu?1:n.lastIndex-m,S=f*i,$+S>w&&(b=Math.min(b,m+Math.floor((w-$)/i))),$+S>r){g=!0;break e}$+=S,y=p,v=m,m=p=n.lastIndex;continue e}}m+=1}return{width:g?w:$,index:g?b:h,truncated:g,ellipsed:g&&r>=o}},Yu={limit:1/0,ellipsis:"",ellipsisWidth:0},Ju=(e,t={})=>zu(e,Yu,t).width,Xu="",Qu="]8;;",Zu=new RegExp(`(?:\\[(?<code>\\d+)m|\\${Qu}(?<uri>.*))`,"y"),ep=e=>e>=30&&e<=37||e>=90&&e<=97?39:e>=40&&e<=47||e>=100&&e<=107?49:1===e||2===e?22:3===e?23:4===e?24:7===e?27:8===e?28:9===e?29:0===e?0:void 0,tp=e=>`${Xu}[${e}m`,np=e=>`${Xu}${Qu}${e}`,rp=(e,t,n)=>{const r=t[Symbol.iterator]();let i=!1,o=!1,s=e.at(-1),a=void 0===s?0:Ju(s),l=r.next(),c=r.next(),d=0;for(;!l.done;){const s=l.value,u=Ju(s);a+u<=n?e[e.length-1]+=s:(e.push(s),a=0),s!==Xu&&""!==s||(i=!0,o=t.startsWith(Qu,d+1)),i?o?""===s&&(i=!1,o=!1):"m"===s&&(i=!1):(a+=u,a!==n||c.done||(e.push(""),a=0)),l=c,c=r.next(),d+=s.length}s=e.at(-1),!a&&void 0!==s&&s.length&&e.length>1&&(e[e.length-2]+=e.pop())},ip=/\r?\n/;function op(e,t,n){return String(e).normalize().split(ip).map(e=>((e,t,n={})=>{if(!1!==n.trim&&""===e.trim())return"";let r,i,o="";const s=e.split(" ");let a=[""],l=0;for(let e=0;e<s.length;e++){const r=s[e];if(!1!==n.trim){const e=a.at(-1)??"",t=e.trimStart();e.length!==t.length&&(a[a.length-1]=t,l=Ju(t))}0!==e&&(l>=t&&(!1===n.wordWrap||!1===n.trim)&&(a.push(""),l=0),(l||!1===n.trim)&&(a[a.length-1]+=" ",l++));const i=Ju(r);if(n.hard&&i>t){const e=t-l,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&a.push(""),rp(a,r,t),l=Ju(a.at(-1)??"");continue}if(l+i>t&&l&&i){if(!1===n.wordWrap&&l<t){rp(a,r,t),l=Ju(a.at(-1)??"");continue}a.push(""),l=0}l+i>t&&!1===n.wordWrap?(rp(a,r,t),l=Ju(a.at(-1)??"")):(a[a.length-1]+=r,l+=i)}!1!==n.trim&&(a=a.map(e=>(e=>{const t=e.split(" ");let n=t.length;for(;n&&!Ju(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")})(e)));const c=a.join("\n");let d=!1;for(let e=0;e<c.length;e++){const t=c[e];if(o+=t,d)d=!1;else if(d=t>="\ud800"&&t<="\udbff",d)continue;if(t===Xu||""===t){Zu.lastIndex=e+1;const t=Zu.exec(c),n=t?.groups;if(void 0!==n?.code){const e=Number.parseFloat(n.code);r=39===e?void 0:e}else void 0!==n?.uri&&(i=0===n.uri.length?void 0:n.uri)}if("\n"===c[e+1]){i&&(o+=np(""));const e=r?ep(r):void 0;r&&e&&(o+=tp(e))}else"\n"===t&&(r&&ep(r)&&(o+=tp(r)),i&&(o+=np(i)))}return o})(e,t,n)).join("\n")}const sp="[",ap={to:(e,t)=>t?`${sp}${t+1};${e+1}H`:`${sp}${e+1}G`,move(e,t){let n="";return e<0?n+=`${sp}${-e}D`:e>0&&(n+=`${sp}${e}C`),t<0?n+=`${sp}${-t}A`:t>0&&(n+=`${sp}${t}B`),n},up:(e=1)=>`${sp}${e}A`,down:(e=1)=>`${sp}${e}B`,forward:(e=1)=>`${sp}${e}C`,backward:(e=1)=>`${sp}${e}D`,nextLine:(e=1)=>`${sp}E`.repeat(e),prevLine:(e=1)=>`${sp}F`.repeat(e),left:`${sp}G`,hide:`${sp}?25l`,show:`${sp}?25h`,save:"7",restore:"8"},lp={screen:`${sp}2J`,up:(e=1)=>`${sp}1J`.repeat(e),down:(e=1)=>`${sp}J`.repeat(e),line:`${sp}2K`,lineEnd:`${sp}K`,lineStart:`${sp}1K`,lines(e){let t="";for(let n=0;n<e;n++)t+=this.line+(n<e-1?ap.up():"");return e&&(t+=ap.left),t}};var cp={cursor:ap,erase:lp};function dp(e,t,n){if(!n.some(e=>!e.disabled))return e;const r=e+t,i=Math.max(n.length-1,0),o=r<0?i:r>i?0:r;return n[o].disabled?dp(o,t<0?-1:1,n):o}const up={actions:new Set(["up","down","left","right","space","enter","cancel"]),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};function pp(e,t){if("string"==typeof e)return up.aliases.get(e)===t;for(const n of e)if(void 0!==n&&pp(n,t))return!0;return!1}const mp=globalThis.process.platform.startsWith("win"),hp=Symbol("clack:cancel");function fp(e,t){const n=e;n.isTTY&&n.setRawMode(t)}function gp({input:e=O,output:t=C,overwrite:n=!0,hideCursor:r=!0}={}){const i=re.createInterface({input:e,output:t,prompt:"",tabSize:1});re.emitKeypressEvents(e,i),e instanceof B&&e.isTTY&&e.setRawMode(!0);const o=(i,{name:s,sequence:a})=>{if(pp([String(i),s,a],"cancel"))return r&&t.write(cp.cursor.show),void process.exit(0);if(!n)return;const l="return"===s?0:-1,c="return"===s?-1:0;re.moveCursor(t,l,c,()=>{re.clearLine(t,1,()=>{e.once("keypress",o)})})};return r&&t.write(cp.cursor.hide),e.once("keypress",o),()=>{e.off("keypress",o),r&&t.write(cp.cursor.show),e instanceof B&&e.isTTY&&!mp&&e.setRawMode(!1),i.terminal=!1,i.close()}}const bp=e=>"columns"in e&&"number"==typeof e.columns?e.columns:80,wp=e=>"rows"in e&&"number"==typeof e.rows?e.rows:20;function yp(e,t,n,r=n,i=n,o){return op(t,bp(e??C)-n.length,{hard:!0,trim:!1}).split("\n").map((e,t,o)=>{const s=e;return 0===t?`${r}${s}`:t===o.length-1?`${i}${s}`:`${n}${s}`}).join("\n")}let vp=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,t=!0){const{input:n=O,output:r=C,render:i,signal:o,...s}=e;this.opts=s,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=o,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){const n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){const n=this._subscribers.get(e)??[],r=[];for(const e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(const e of r)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(hp);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=ie.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),void 0!==this.opts.initialUserInput&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),fp(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(cp.cursor.show),this.output.off("resize",this.render),fp(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(cp.cursor.show),this.output.off("resize",this.render),fp(this.input,!1),e(hp)})})}_isActionKey(e,t){return"\t"===e}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,t){if(this._track&&"return"!==t.name&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),"error"===this.state&&(this.state="active"),t?.name&&(!this._track&&up.aliases.has(t.name)&&this.emit("cursor",up.aliases.get(t.name)),up.actions.has(t.name)&&this.emit("cursor",t.name)),e&&("y"===e.toLowerCase()||"n"===e.toLowerCase())&&this.emit("confirm","y"===e.toLowerCase()),this.emit("key",e?.toLowerCase(),t),"return"===t?.name&&this._shouldSubmit(e,t)){if(this.opts.validate){const e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state="error",this.rl?.write(this.userInput))}"error"!==this.state&&(this.state="submit")}pp([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),("submit"===this.state||"cancel"===this.state)&&this.emit("finalize"),this.render(),("submit"===this.state||"cancel"===this.state)&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write("\n"),fp(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const e=op(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split("\n").length-1;this.output.write(cp.cursor.move(-999,-1*e))}render(){const e=op(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if("initial"===this.state)this.output.write(cp.cursor.hide);else{const t=function(e,t){if(e===t)return;const n=e.split("\n"),r=t.split("\n"),i=Math.max(n.length,r.length),o=[];for(let e=0;e<i;e++)n[e]!==r[e]&&o.push(e);return{lines:o,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}(this._prevFrame,e),n=wp(this.output);if(this.restoreCursor(),t){const r=Math.max(0,t.numLinesAfter-n),i=Math.max(0,t.numLinesBefore-n);let o=t.lines.find(e=>e>=r);if(void 0===o)return void(this._prevFrame=e);if(1===t.lines.length){this.output.write(cp.cursor.move(0,o-i)),this.output.write(cp.erase.lines(1));const t=e.split("\n");return this.output.write(t[o]),this._prevFrame=e,void this.output.write(cp.cursor.move(0,t.length-o-1))}if(t.lines.length>1){if(r<i)o=r;else{const e=o-i;e>0&&this.output.write(cp.cursor.move(0,e))}this.output.write(cp.erase.down());const t=e.split("\n").slice(o);return this.output.write(t.join("\n")),void(this._prevFrame=e)}}this.output.write(cp.erase.down())}this.output.write(e),"initial"===this.state&&(this.state="active"),this._prevFrame=e}}};class $p extends vp{get cursor(){return this.value?0:1}get _value(){return 0===this.cursor}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",e=>{this.output.write(cp.cursor.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}let Sp=class extends vp{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(e=>!0!==e.disabled)}toggleAll(){const e=this._enabledOptions,t=void 0!==this.value&&this.value.length===e.length;this.value=t?[]:e.map(e=>e.value)}toggleInvert(){const e=this.value;if(!e)return;const t=this._enabledOptions.filter(t=>!e.includes(t.value));this.value=t.map(e=>e.value)}toggleValue(){void 0===this.value&&(this.value=[]);const e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}constructor(e){super(e,!1),this.options=e.options,this.value=[...e.initialValues??[]];const t=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0);this.cursor=this.options[t].disabled?dp(t,1,this.options):t,this.on("key",e=>{"a"===e&&this.toggleAll(),"i"===e&&this.toggleInvert()}),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=dp(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=dp(this.cursor,1,this.options);break;case"space":this.toggleValue()}})}},Ep=class extends vp{_mask="•";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if("submit"===this.state||"cancel"===this.state)return this.masked;const e=this.userInput;if(this.cursor>=e.length)return`${this.masked}${R(["inverse","hidden"],"_")}`;const t=this.masked,n=t.slice(0,this.cursor),r=t.slice(this.cursor);return`${n}${R("inverse",r[0])}${r.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:e,...t}){super(t),this._mask=e??"•",this.on("userInput",e=>{this._setValue(e)})}},xp=class extends vp{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(e){super(e,!1),this.options=e.options;const t=this.options.findIndex(({value:t})=>t===e.initialValue),n=-1===t?0:t;this.cursor=this.options[n].disabled?dp(n,1,this.options):n,this.changeValue(),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=dp(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=dp(this.cursor,1,this.options)}this.changeValue()})}};const Op="win32"!==v.platform?"linux"!==v.env.TERM:!!v.env.CI||!!v.env.WT_SESSION||!!v.env.TERMINUS_SUBLIME||"{cmd::Cmder}"===v.env.ConEmuTask||"Terminus-Sublime"===v.env.TERM_PROGRAM||"vscode"===v.env.TERM_PROGRAM||"xterm-256color"===v.env.TERM||"alacritty"===v.env.TERM||"JetBrains-JediTerm"===v.env.TERMINAL_EMULATOR,Cp=(e,t)=>Op?e:t,_p=Cp("◆","*"),Tp=Cp("■","x"),Ap=Cp("▲","x"),Ip=Cp("◇","o"),Dp=Cp("┌","T"),kp=Cp("│","|"),Mp=Cp("└","—"),jp=Cp("┐","T"),Np=Cp("┘","—"),Pp=Cp("●",">"),Rp=Cp("○"," "),Lp=Cp("◻","[•]"),Bp=Cp("◼","[+]"),Fp=Cp("◻","[ ]"),Up=Cp("▪","•"),Hp=Cp("─","-"),Wp=Cp("╮","+"),Gp=Cp("╯","+"),Vp=Cp("╰","+"),qp=Cp("╭","+"),Kp=Cp("●","•"),zp=Cp("◆","*"),Yp=Cp("▲","!"),Jp=Cp("■","x"),Xp=e=>{switch(e){case"initial":case"active":return R("cyan",_p);case"cancel":return R("red",Tp);case"error":return R("yellow",Ap);case"submit":return R("green",Ip)}},Qp=e=>{switch(e){case"initial":case"active":return R("cyan",kp);case"cancel":return R("red",kp);case"error":return R("yellow",kp);case"submit":return R("green",kp)}},Zp=(e,t,n,r,i,o=!1)=>{let s=t,a=0;if(o)for(let t=r-1;t>=n&&(s-=e[t].length,a++,!(s<=i));t--);else for(let t=n;t<r&&(s-=e[t].length,a++,!(s<=i));t++);return{lineCount:s,removals:a}},em=({cursor:e,options:t,style:n,output:r=process.stdout,maxItems:i=Number.POSITIVE_INFINITY,columnPadding:o=0,rowPadding:s=4})=>{const a=bp(r)-o,l=wp(r),c=R("dim","..."),d=Math.max(l-s,0),u=Math.max(Math.min(i,d),5);let p=0;e>=u-3&&(p=Math.max(Math.min(e-u+3,t.length-u),0));let m=u<t.length&&p>0,h=u<t.length&&p+u<t.length;const f=Math.min(p+u,t.length),g=[];let b=0;m&&b++,h&&b++;const w=p+(m?1:0),y=f-(h?1:0);for(let r=w;r<y;r++){const i=op(n(t[r],r===e),a,{hard:!0,trim:!1}).split("\n");g.push(i),b+=i.length}if(b>d){let t=0,n=0,r=b;const i=e-w;let o=d;const s=()=>Zp(g,r,0,i,o),a=()=>Zp(g,r,i+1,g.length,o,!0);m?(({lineCount:r,removals:t}=s()),r>o&&(h||(o-=1),({lineCount:r,removals:n}=a()))):(h||(o-=1),({lineCount:r,removals:n}=a()),r>o&&(o-=1,({lineCount:r,removals:t}=s()))),t>0&&(m=!0,g.splice(0,t)),n>0&&(h=!0,g.splice(g.length-n,n))}const v=[];m&&v.push(c);for(const e of g)for(const t of e)v.push(t);return h&&v.push(c),v},tm=[qp,Wp,Vp,Gp],nm=[Dp,jp,Mp,Np];function rm(e,t,n,r){let i=n,o=n;return"center"===r?i=Math.floor((t-e)/2):"right"===r&&(i=t-e-n),o=t-i-e,[i,o]}const im=e=>e,om=e=>{const t=e.active??"Yes",n=e.inactive??"No";return new $p({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){const r=e.withGuide??up.withGuide,i=`${Xp(this.state)} `,o=r?`${R("gray",kp)} `:"",s=yp(e.output,e.message,o,i),a=`${r?`${R("gray",kp)}\n`:""}${s}\n`,l=this.value?t:n;switch(this.state){case"submit":return`${a}${r?`${R("gray",kp)} `:""}${R("dim",l)}`;case"cancel":return`${a}${r?`${R("gray",kp)} `:""}${R(["strikethrough","dim"],l)}${r?`\n${R("gray",kp)}`:""}`;default:{const i=r?`${R("cyan",kp)} `:"",o=r?R("cyan",Mp):"";return`${a}${i}${this.value?`${R("green",Pp)} ${t}`:`${R("dim",Rp)} ${R("dim",t)}`}${e.vertical?r?`\n${R("cyan",kp)} `:"\n":` ${R("dim","/")} `}${this.value?`${R("dim",Rp)} ${R("dim",n)}`:`${R("green",Pp)} ${n}`}\n${o}\n`}}}}).prompt()},sm={message:(e=[],{symbol:t=R("gray",kp),secondarySymbol:n=R("gray",kp),output:r=process.stdout,spacing:i=1,withGuide:o}={})=>{const s=[],a=o??up.withGuide,l=a?n:"",c=a?`${t} `:"",d=a?`${n} `:"";for(let e=0;e<i;e++)s.push(l);const u=Array.isArray(e)?e:e.split("\n");if(u.length>0){const[e,...r]=u;e.length>0?s.push(`${c}${e}`):s.push(a?t:"");for(const e of r)e.length>0?s.push(`${d}${e}`):s.push(a?n:"")}r.write(`${s.join("\n")}\n`)},info:(e,t)=>{sm.message(e,{...t,symbol:R("blue",Kp)})},success:(e,t)=>{sm.message(e,{...t,symbol:R("green",zp)})},step:(e,t)=>{sm.message(e,{...t,symbol:R("green",Ip)})},warn:(e,t)=>{sm.message(e,{...t,symbol:R("yellow",Yp)})},warning:(e,t)=>{sm.warn(e,t)},error:(e,t)=>{sm.message(e,{...t,symbol:R("red",Jp)})}},am=(e,t)=>e.split("\n").map(e=>t(e)).join("\n"),lm=e=>{const t=(e,t)=>{const n=e.label??String(e.value);return"disabled"===t?`${R("gray",Fp)} ${am(n,e=>R(["strikethrough","gray"],e))}${e.hint?` ${R("dim",`(${e.hint??"disabled"})`)}`:""}`:"active"===t?`${R("cyan",Lp)} ${n}${e.hint?` ${R("dim",`(${e.hint})`)}`:""}`:"selected"===t?`${R("green",Bp)} ${am(n,e=>R("dim",e))}${e.hint?` ${R("dim",`(${e.hint})`)}`:""}`:"cancelled"===t?`${am(n,e=>R(["strikethrough","dim"],e))}`:"active-selected"===t?`${R("green",Bp)} ${n}${e.hint?` ${R("dim",`(${e.hint})`)}`:""}`:"submitted"===t?`${am(n,e=>R("dim",e))}`:`${R("dim",Fp)} ${am(n,e=>R("dim",e))}`},n=e.required??!0;return new Sp({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:n,cursorAt:e.cursorAt,validate(e){if(n&&(void 0===e||0===e.length))return`Please select at least one option.\n${R("reset",R("dim",`Press ${R(["gray","bgWhite","inverse"]," space ")} to select, ${R("gray",R("bgWhite",R("inverse"," enter ")))} to submit`))}`},render(){const n=e.withGuide??up.withGuide,r=yp(e.output,e.message,n?`${Qp(this.state)} `:"",`${Xp(this.state)} `),i=`${n?`${R("gray",kp)}\n`:""}${r}\n`,o=this.value??[],s=(e,n)=>{if(e.disabled)return t(e,"disabled");const r=o.includes(e.value);return t(e,n&&r?"active-selected":r?"selected":n?"active":"inactive")};switch(this.state){case"submit":{const r=this.options.filter(({value:e})=>o.includes(e)).map(e=>t(e,"submitted")).join(R("dim",", "))||R("dim","none");return`${i}${yp(e.output,r,n?`${R("gray",kp)} `:"")}`}case"cancel":{const r=this.options.filter(({value:e})=>o.includes(e)).map(e=>t(e,"cancelled")).join(R("dim",", "));return""===r.trim()?`${i}${R("gray",kp)}`:`${i}${yp(e.output,r,n?`${R("gray",kp)} `:"")}${n?`\n${R("gray",kp)}`:""}`}case"error":{const t=n?`${R("yellow",kp)} `:"",r=this.error.split("\n").map((e,t)=>0===t?`${n?`${R("yellow",Mp)} `:""}${R("yellow",e)}`:` ${e}`).join("\n"),o=i.split("\n").length,a=r.split("\n").length+1;return`${i}${t}${em({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:t.length,rowPadding:o+a,style:s}).join(`\n${t}`)}\n${r}\n`}default:{const t=n?`${R("cyan",kp)} `:"",r=i.split("\n").length,o=n?2:1;return`${i}${t}${em({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:t.length,rowPadding:r+o,style:s}).join(`\n${t}`)}\n${n?R("cyan",Mp):""}\n`}}}}).prompt()},cm=e=>new Ep({validate:e.validate,mask:e.mask??Up,signal:e.signal,input:e.input,output:e.output,render(){const t=e.withGuide??up.withGuide,n=`${t?`${R("gray",kp)}\n`:""}${Xp(this.state)} ${e.message}\n`,r=this.userInputWithCursor,i=this.masked;switch(this.state){case"error":{const r=t?`${R("yellow",kp)} `:"",o=t?`${R("yellow",Mp)} `:"",s=i??"";return e.clearOnError&&this.clear(),`${n.trim()}\n${r}${s}\n${o}${R("yellow",this.error)}\n`}case"submit":return`${n}${t?`${R("gray",kp)} `:""}${i?R("dim",i):""}`;case"cancel":return`${n}${t?`${R("gray",kp)} `:""}${i?R(["strikethrough","dim"],i):""}${i&&t?`\n${R("gray",kp)}`:""}`;default:return`${n}${t?`${R("cyan",kp)} `:""}${r}\n${t?R("cyan",Mp):""}\n`}}}).prompt(),dm=e=>R("magenta",e),um=(e,t)=>e.includes("\n")?e.split("\n").map(e=>t(e)).join("\n"):t(e),pm=e=>{const t=(e,t)=>{const n=e.label??String(e.value);switch(t){case"disabled":return`${R("gray",Rp)} ${um(n,e=>R("gray",e))}${e.hint?` ${R("dim",`(${e.hint??"disabled"})`)}`:""}`;case"selected":return`${um(n,e=>R("dim",e))}`;case"active":return`${R("green",Pp)} ${n}${e.hint?` ${R("dim",`(${e.hint})`)}`:""}`;case"cancelled":return`${um(n,e=>R(["strikethrough","dim"],e))}`;default:return`${R("dim",Rp)} ${um(n,e=>R("dim",e))}`}};return new xp({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){const n=e.withGuide??up.withGuide,r=`${Xp(this.state)} `,i=`${Qp(this.state)} `,o=yp(e.output,e.message,i,r),s=`${n?`${R("gray",kp)}\n`:""}${o}\n`;switch(this.state){case"submit":{const r=n?`${R("gray",kp)} `:"";return`${s}${yp(e.output,t(this.options[this.cursor],"selected"),r)}`}case"cancel":{const r=n?`${R("gray",kp)} `:"";return`${s}${yp(e.output,t(this.options[this.cursor],"cancelled"),r)}${n?`\n${R("gray",kp)}`:""}`}default:{const r=n?`${R("cyan",kp)} `:"",i=n?R("cyan",Mp):"",o=s.split("\n").length,a=n?2:1;return`${s}${r}${em({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:r.length,rowPadding:o+a,style:(e,n)=>t(e,e.disabled?"disabled":n?"active":"inactive")}).join(`\n${r}`)}\n${i}\n`}}}}).prompt()};R("gray",kp);var mm=e=>{const t=(({indicator:e="dots",onCancel:t,output:n=process.stdout,cancelMessage:r,errorMessage:i,frames:o=(Op?["◒","◐","◓","◑"]:["•","o","O","0"]),delay:s=(Op?80:120),signal:a,...l}={})=>{const c="true"===process.env.CI;let d,u,p,m=!1,h=!1,f="",g=performance.now();const b=bp(n),w=l?.styleFrame??dm,y=e=>{const n=e>1?i??up.messages.error:r??up.messages.cancel;h=1===e,m&&(C(n,e),h&&"function"==typeof t&&t())},v=()=>y(2),$=()=>y(1),S=()=>{if(void 0===p)return;c&&n.write("\n");const e=op(p,b,{hard:!0,trim:!1}).split("\n");e.length>1&&n.write(cp.cursor.up(e.length-1)),n.write(cp.cursor.to(0)),n.write(cp.erase.down())},E=e=>e.replace(/\.+$/,""),x=e=>{const t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},O=l.withGuide??up.withGuide,C=(t="",r=0,i=!1)=>{if(!m)return;m=!1,clearInterval(u),S();const o=0===r?R("green",Ip):R("red",1===r?Tp:Ap);f=t??f,i||("timer"===e?n.write(`${o} ${f} ${x(g)}\n`):n.write(`${o} ${f}\n`)),process.removeListener("uncaughtExceptionMonitor",v),process.removeListener("unhandledRejection",v),process.removeListener("SIGINT",$),process.removeListener("SIGTERM",$),process.removeListener("exit",y),a&&a.removeEventListener("abort",$),d()};return{start:(t="")=>{m=!0,d=gp({output:n}),f=E(t),g=performance.now(),O&&n.write(`${R("gray",kp)}\n`);let r=0,i=0;process.on("uncaughtExceptionMonitor",v),process.on("unhandledRejection",v),process.on("SIGINT",$),process.on("SIGTERM",$),process.on("exit",y),a&&a.addEventListener("abort",$),u=setInterval(()=>{if(c&&f===p)return;S(),p=f;const t=w(o[r]);let s;if(c)s=`${t} ${f}...`;else if("timer"===e)s=`${t} ${f} ${x(g)}`;else{const e=".".repeat(Math.floor(i)).slice(0,3);s=`${t} ${f}${e}`}const a=op(s,b,{hard:!0,trim:!1});n.write(a),r=r+1<o.length?r+1:0,i=i<4?i+.125:0},s)},stop:(e="")=>C(e,0),message:(e="")=>{f=E(e??f)},cancel:(e="")=>C(e,1),error:(e="")=>C(e,2),clear:()=>C("",0,!0),get isCancelled(){return h}}})();let n=e;return t.start(e),{get text(){return n},set text(e){n=e,t.message(e)},message:e=>{n=e,t.message(e)},succeed:e=>{t.stop(e??`${n.replace(/\n+$/,"")} - done.`)},fail:e=>{t.stop(e??`${n.replace(/\n+$/,"")} - error.`)},stop:e=>{t.stop(e)},info:e=>{t.stop(e??n.replace(/\n+$/,""))}}},hm=async(e,t,n,r={})=>{const{exitOnError:i=!0,showError:o=!0,stdio:s,killSignal:a,type:l="spawn",cwd:c,env:d,spinner:u=!0}=r,p=u?mm(`${n}\n\n`):null;if("exec"===l){p?.stop();const t=Pu({stdio:"inherit",shell:!0,cwd:c})`${e}`;return a&&process.on(a,()=>{t.kill()}),await t,{stdout:"",stderr:"",exitCode:0}}try{const r=T(e,t,{stdio:s,killSignal:a,cwd:c,env:d});if(0===r.status)return p?.succeed(`${n} - done.`),{stdout:r.stdout?.toString()??"",stderr:r.stderr?.toString()??"",exitCode:0};const l=r.stderr?.toString()??"",u=r.stdout?.toString()??"",m=`[${n}] Command failed: ${e} ${t.join(" ")}\n\nSTD ERROR:\n${l}\n\nSTD OUTPUT:\n${u}`;throw o&&p?.fail(m),i&&process.exit(r.status??1),new Error(m)}catch(e){throw o?p?.fail(`${n} - error.`):p?.stop(),e}},fm=t=>e.yellowBright(`(${t})`),gm=e=>e.map(e=>(e=>{if("string"==typeof e)return{value:e,label:e};const t={value:e.name,label:e.message??e.name,disabled:Boolean(e.disabled)};return e.hint&&(t.hint=e.hint),t})(e)),bm=e=>{if(e)return t=>{const n=e(t);if("string"==typeof n)return n}},wm={info:"cyan",success:"green",error:"red",warning:"yellow",step:"blue"},ym=((t={})=>{const{prefix:n="",colors:r={}}=t,i={...wm,...r},o=(t,r)=>{const o=i[t],s=e[o];return n?`${s(n)} ${r}`:r};return{intro:e=>{((e="",t)=>{const n=t?.output??process.stdout,r=`${R("gray",Dp)} `;n.write(`${r}${e}\n`)})(o("info",e),{})},outro:e=>{((e="")=>{const t=process.stdout,n=`${R("gray",kp)}\n${R("gray",Mp)} `;t.write(`${n}${e}\n\n`)})(o("info",e))},box:(e,t,n)=>{((e="",t="",n)=>{const r=n?.output??process.stdout,i=bp(r),o=n?.titlePadding??1,s=n?.contentPadding??2,a=void 0===n?.width||"auto"===n.width?1:Math.min(1,n.width),l=n?.withGuide??up.withGuide?`${kp} `:"",c=n?.formatBorder??im,d=(n?.rounded?tm:nm).map(c),u=c(Hp),p=c(kp),m=Ju(l),h=Ju(t),f=i-m;let g=Math.floor(i*a)-m;if("auto"===n?.width){const t=e.split("\n");let n=h+2*o;for(const e of t){const t=Ju(e)+2*s;t>n&&(n=t)}const r=n+2;r<g&&(g=r)}g%2!=0&&(g<f?g++:g--);const b=g-2,w=b-2*o,y=h>w?`${t.slice(0,w-3)}...`:t,[v,$]=rm(Ju(y),b,o,n?.titleAlign),S=op(e,b-2*s,{hard:!0,trim:!1});r.write(`${l}${d[0]}${u.repeat(v)}${y}${u.repeat($)}${d[1]}\n`);const E=S.split("\n");for(const e of E){const[t,i]=rm(Ju(e),b,s,n?.contentAlign);r.write(`${l}${p}${" ".repeat(t)}${e}${" ".repeat(i)}${p}\n`)}r.write(`${l}${d[2]}${u.repeat(b)}${d[3]}\n`)})(o("info",t),e,n)},info:e=>{sm.info(o("info",e))},success:e=>{sm.success(o("success",e))},error:e=>{sm.error(o("error",e))},warning:e=>{sm.warn(o("warning",e))},message:e=>{sm.message(e)},step:(t,n,r)=>{const i=e.blue(`[${t}/${n}]`);sm.step(`${i} ${r}`)}}})(),vm=ym.info,$m=ym.success,Sm=ym.error,Em=ym.warning,xm=ym.step,Om=ym.intro,Cm=ym.outro,_m=ym.box,Tm=ym.message,Am=e=>(e===hp&&(((e="")=>{const t=process.stdout,n=`${R("gray",Mp)} `;t.write(`${n}${R("red",e)}\n\n`)})("Operation cancelled."),process.exit(0)),e),Im=async e=>{const{message:t,choices:n,initial:r}=e,i=fm("Use arrows to navigate, enter to confirm"),o=gm(n),s=await pm({message:`${t}\n${i}`,options:o,initialValue:r});return Am(s)},Dm=async e=>{const{message:t,choices:n,maxChoices:r,minChoices:i,required:o=!1}=e,s=fm("Press space to select, enter to confirm"),a=gm(n),l=await lm({message:`${t}\n${s}`,options:a,required:o||"number"==typeof i&&i>0}),c=Am(l);return i&&c.length<i?(Sm(`Please select at least ${i} options`),Dm(e)):r&&c.length>r?(Sm(`Please select at most ${r} options`),Dm(e)):c},km=async e=>{const{message:t,initial:n=!1}=e,r=await om({message:t,initialValue:n});return Am(r)},Mm=async e=>{const{message:t,validate:n}=e,r=await cm({message:t,validate:bm(n)});return Am(r)};const jm="1.0.0-beta.2",Nm="A comprehensive CLI toolkit for boosting Claude Code to the insane level.",Pm=["agents","commands","skills","hooks","scripts","workflows"],Rm="init",Lm="install",Bm="add-skill",Fm="add-agent",Um="add-command",Hm="exit",Wm={[Lm]:"Install full claude code toolkit",[Rm]:"Initialize base Claude Code infrastructure (hooks, scripts, settings)",[Bm]:"Add a new skill to the existing Сlaude code",[Fm]:"Add a new agent to the existing Сlaude code",[Um]:"Add a new command to the existing Сlaude code",[Hm]:"Exit the claude code toolkit"},Gm={[Lm]:"Install",[Rm]:"Initialize",[Bm]:"Add skill",[Fm]:"Add agent",[Um]:"Add command",[Hm]:"Exit"},Vm=[],qm=()=>{const e=A(import.meta.url);return u.resolve(u.dirname(e),"..")},Km={get PACKAGE_ROOT(){return qm()},get TEMPLATES_ROOT(){return u.join(qm(),"templates")},get CLAUDE_TEMPLATES(){return u.join(qm(),"templates","claude")},get PLANS_TEMPLATES(){return u.join(qm(),"templates","plans")},get CONFIG_TEMPLATES(){return u.join(qm(),"templates","config")},get COMMON_TEMPLATES(){return u.join(qm(),"templates","common")},get OUTPUT_STYLES(){return u.join(qm(),"templates","claude","output-styles")},DEST_DIR:".claude",PLANS_DIR:"plans/templates"},zm="#DE7356",Ym="#FFBC05",Jm="#3E85F8",Xm="#79FF4A",Qm=`\n ${e.hex(zm)(" ▐▛███▜▌")} ${e.bold.white("Claude Code Toolkit")}\n ${e.hex(zm)("▝▜█████▛▘")} ${e.dim("Version:")} ${e.bold.white(`v${jm}`)}\n ${e.hex(zm)(" ▘▘ ▝▝ ")} ${e.dim(Nm)}\n`,Zm=()=>{_m(e.bgHex(zm).bold(" ⚡️ Welcome ⚡️ "),Qm,{formatBorder:t=>e.hex(zm).bold(t),titleAlign:"center",rounded:!0})},eh=()=>0===c("command",["-v","claude"],{stdio:"ignore",shell:!0}).status,th=async()=>{eh()?$m("Claude Code is installed"):(Em("Claude Code is not installed"),await km({message:"Claude Code is required. Install it now?",initial:!0})||(Sm("Claude Code is required to use this toolkit. Please install it manually:"),Sm(" curl -fsSL https://claude.ai/install.sh | bash"),process.exit(1)),await hm("bash",["-c","curl -fsSL https://claude.ai/install.sh | bash"],"Installing Claude Code...",{exitOnError:!1,showError:!0}),eh()||(Sm("Claude Code installation failed. Please install manually:"),Sm(" curl -fsSL https://claude.ai/install.sh | bash"),process.exit(1)),$m("Claude Code installed successfully"))},nh=()=>{Number(process.version.split(".")[0]?.replace("v",""))<18&&Em(`Node.js ${process.version} detected. Recommended: v18+`)},rh=async e=>{await oe.mkdir(e,{recursive:!0})},ih=async e=>{try{return await oe.access(e),!0}catch{return!1}},oh=async e=>{try{const t=await oe.readFile(e,"utf8");return JSON.parse(t)}catch(t){const n=t instanceof Error?t.message:String(t);throw new Error(`Failed to read JSON from ${e}: ${n}`)}},sh=async(e,t)=>{await rh(u.dirname(e)),await oe.writeFile(e,`${JSON.stringify(t,null,2)}\n`,"utf8")},ah=async(e,t)=>{await rh(u.dirname(t)),await oe.copyFile(e,t)},lh=async(e,t,n)=>{await rh(t);const r=await oe.readdir(e,{withFileTypes:!0});for(const i of r){if(n?.(i.name))continue;const r=u.join(e,i.name),o=u.join(t,i.name);await(i.isDirectory()?lh(r,o,n):ah(r,o))}},ch=new Set(["node_modules",".git",".DS_Store","tests","__tests__","__pycache__"]),dh=e=>e.endsWith(".example")||ch.has(e),uh=async(e,t)=>{await(async n=>{const r=mm(n);try{const i=await(async()=>{for(const{item:n}of e)for(const e of n.files){const n=u.join(Km.CLAUDE_TEMPLATES,e),r=u.join(t,Km.DEST_DIR,e);await(e.endsWith("/")?lh(n,r,dh):ah(n,r))}})();return r.succeed(`${n} - done.`),i}catch(e){throw r.fail(`${n} - error.`),e}})("Copying component files...")},ph=async e=>{const t=Km.CONFIG_TEMPLATES,n=e,r=await oe.readdir(t,{withFileTypes:!0}),i=await oe.readdir(n,{withFileTypes:!0}),o=r.filter(e=>i.some(t=>t.name===e.name));if(o.length>0)for(const e of o){const r=u.join(n,`${e.name}.backup`);await oe.copyFile(u.join(t,e.name),r),await oe.unlink(u.join(n,e.name))}await rh(n)},mh=async e=>{const t=Km.OUTPUT_STYLES,n=u.join(e,Km.DEST_DIR,"output-styles");await rh(n),await lh(t,n,dh)},hh=async e=>{const t=u.join(e,Km.DEST_DIR,"metadata.json"),n=await oh(t),r=n.download??{lastDownloadedAt:null,downloadedBy:null,installCount:0};n.version=jm,n.download={...r,lastDownloadedAt:(new Date).toISOString(),downloadedBy:process.env.USER??process.env.USERNAME??"unknown",installCount:r.installCount+1},await sh(t,n)},fh=async e=>{await(async e=>{const t=u.join(e.projectRoot,Km.DEST_DIR,".env.example"),n=u.join(e.projectRoot,Km.DEST_DIR,".env");let r=await oe.readFile(t,"utf8");e.context7.enabled&&e.context7.apiKey&&(r=r.replace(/^CONTEXT7_API_KEY=$/m,`CONTEXT7_API_KEY=${e.context7.apiKey}`)),e.gemini.enabled&&e.gemini.apiKey&&(r=r.replace(/^GEMINI_API_KEY=$/m,`GEMINI_API_KEY=${e.gemini.apiKey}`)),await rh(u.dirname(n)),await oe.writeFile(n,r,{encoding:"utf8",mode:384})})(e),await(async e=>{const t=u.join(e.projectRoot,Km.DEST_DIR,".mcp.json.example"),n=u.join(e.projectRoot,Km.DEST_DIR,".mcp.json"),r=await oh(t);if(e.context7.enabled&&e.context7.apiKey){const{apiKey:t}=e.context7,i=r.mcpServers.context7;i?.args&&(i.args=i.args.map(e=>"YOUR_API_KEY"===e?t:e)),await sh(n,r),await oe.chmod(n,384)}else delete r.mcpServers.context7,await sh(n,r)})(e),await(async e=>{const t=u.join(e.projectRoot,Km.DEST_DIR,".cctk.json"),n=await oh(t);n.codingLevel=e.codingLevel,n.locale={...n.locale,responseLanguage:e.language},await sh(t,n)})(e),await hh(e.projectRoot)},gh="# Claude Code Toolkit",bh="# /Claude Code Toolkit",wh=async e=>{const t=u.join(e.projectRoot,".gitignore"),n=(e=>{const t=["plans/",".claude/.mcp.json",".claude/.env","tmp/","!**/templates/plans/**"];return"private"===e&&t.unshift(".claude/"),t})(e.mode),r=(e=>[gh,...e,bh].join("\n"))(n);if(!await ih(t))return void await oe.writeFile(t,`${r}\n`,"utf8");const i=await oe.readFile(t,"utf8"),o=i.indexOf(gh),s=i.indexOf(bh);if(-1!==o&&-1!==s){const e=i.slice(0,o),n=i.slice(s+22);return void await oe.writeFile(t,`${e}${r}${n}`,"utf8")}const a=i.endsWith("\n")?"\n":"\n\n";await oe.writeFile(t,`${i}${a}${r}\n`,"utf8")},yh=async e=>{const t=u.join(e,Km.DEST_DIR);return!!await ih(t)&&(await oe.readdir(t)).length>0},vh=async e=>{const t=u.join(e,"CLAUDE.md");return await ih(t)},$h=(t,n,r)=>{const i=[` ${e.yellow("⚠")} Existing Claude Code configuration detected:`,"",...(n??[]).map(e=>` ${e}`),...r&&r.length>0?["",...r]:[],"",` ${e.yellow("⚠")} ${t}`];_m(e.bgHex(Ym).bold(" Warning "),i.join("\n"),{titleAlign:"center",rounded:!0,formatBorder:t=>e.hex(Ym)(t)})},Sh=async t=>{const n=await yh(t),r=await vh(t);if(!n&&!r)return"fresh";const i=[];n&&i.push(`${e.yellow("•")} ${e.bold(".claude/")} directory found`),r&&i.push(`${e.yellow("•")} ${e.bold("CLAUDE.md")} file found`);const o=n?await(async e=>{const t=u.join(e,Km.DEST_DIR,"metadata.json");try{return(await oh(t)).version??null}catch{return null}})(t):null,s=(t=>{if(!t)return[];const n=jm,r=[` ${e.dim("Installed:")} v${t} ${e.dim("Current:")} v${n}`],i=((e,t)=>{const n=e.split(".").map(Number),r=t.split(".").map(Number),i=Math.max(n.length,r.length);for(let e=0;e<i;e++){const t=n[e]??0,i=r[e]??0;if(t!==i)return t<i?-1:1}return 0})(t,n);return 0===i?r.push(` ${e.green("✓")} Versions match`):i<0?r.push(` ${e.yellow("↑")} Update available`):r.push(` ${e.yellow("⚠")} Installed version is newer than current toolkit`),r})(o);$h("Proceeding may overwrite your current settings.",i,s);const a=await Im({message:"How would you like to proceed?",choices:[{name:"update",message:"Update templates",hint:"Keep your configs (.env, .cctk.json, .claude/.mcp.json)"},{name:"fresh",message:"Fresh install",hint:"Overwrite everything"},{name:"backup",message:"Fresh install with backup",hint:"Backup .claude/ to tmp/ first"},{name:"cancel",message:"Cancel",hint:"Exit without changes"}]});if("cancel"===a&&(Em("Installation cancelled by user."),process.exit(0)),"backup"===a&&n){const e=u.join(t,Km.DEST_DIR),n=u.join(t,"tmp",Km.DEST_DIR);await lh(e,n),$m(`Backup created at tmp/${Km.DEST_DIR}`)}return"backup"===a?"fresh":a},Eh=async e=>{const t=await Im({message:"How would you like to use the toolkit?",choices:[{name:"public",message:"Public — shared with team (AI config committed)",hint:"Recommended for teams"},{name:"private",message:"Private — local only (added to .gitignore)",hint:"Personal use"}]});return"private"!==t||(await ih(u.join(e,"CLAUDE.md"))&&(Em("Existing CLAUDE.md detected. Private mode will add .claude/ to .gitignore."),Em("Other team members using Claude Code may be confused by missing config.")),await km({message:"This will add .claude/ and plans/ to .gitignore. Continue?",initial:!0}))?t:Eh(e)},xh=async t=>({mode:await Eh(t),codingLevel:await(async()=>{const e=await Im({message:"What power level do you want?",choices:[{name:String(-1),message:"Auto (default)",hint:"System determines based on context"},{name:String(1),message:"Senior Engineer Mode",hint:"Trade-offs, business context, architecture (5-8 yrs)"},{name:String(2),message:"Tech Lead Mode",hint:"Strategic thinking, risk assessment (8-15 yrs)"},{name:String(3),message:"God Mode",hint:"Max velocity, zero hand-holding (15+ yrs)"}],initial:String(-1)});return Number(e)})(),language:await(async()=>Im({message:"What language should Claude respond in?",choices:[{name:"en",message:"English",hint:"Default"},{name:"uk",message:"Українська",hint:"Ukrainian"}]}))(),context7:await(async()=>await km({message:"Enable Context7 MCP? (provides documentation context)",initial:!1})?{enabled:!0,apiKey:(await Mm({message:"Enter your CONTEXT7_API_KEY (from https://context7.com/dashboard/api-keys):",validate:e=>e.trim().length>0||"API key is required when Context7 is enabled"})).trim()}:{enabled:!1})(),gemini:await(async()=>{if(!await km({message:"Provide Gemini API key? (enhances research quality & reduces token costs)",initial:!1})){const t=[` ${e.hex(Ym)("⚠")} ${e.bold("Some toolkit features will be limited without Gemini API:")}`,"",` ${e.dim("•")} Research capabilities will use fallback methods`,` ${e.dim("•")} Documentation search may be slower`,` ${e.dim("•")} Token costs may be higher due to less efficient workflows`,"",` ${e.dim("You can add GEMINI_API_KEY to .claude/.env later.")}`];return _m(e.bgHex(Ym).bold(" Notice "),t.join("\n"),{titleAlign:"center",rounded:!0,formatBorder:t=>e.hex(Ym)(t)}),{enabled:!1}}return{enabled:!0,apiKey:(await Mm({message:"Enter your GEMINI_API_KEY (from https://aistudio.google.com/apikey):",validate:e=>e.trim().length>0||"API key is required when Gemini is enabled"})).trim()}})(),projectRoot:t}),Oh=async(e,t,n)=>{const r=u.join(t,Km.DEST_DIR,e),i=await(async e=>{try{return(await oe.readdir(e)).filter(e=>!e.startsWith("."))}catch{return[]}})(r);if(0===i.length)return[];const o=n[e],s=new Set(i);return o.items.filter(e=>e.files.some(e=>{const t=e.replace(/\/$/,""),n=u.basename(t);return s.has(n)})).map(e=>e.name)},Ch=async e=>{const t=u.join(Km.CLAUDE_TEMPLATES,e,"registry.json");try{await oe.access(t)}catch{throw new Error(`Registry file not found: ${t}`)}const n=await oe.readFile(t,"utf8"),r=JSON.parse(n);if(r.name!==e)throw new Error(`Registry name mismatch: expected "${e}", got "${r.name}"`);return r},_h=async()=>{const e=await Promise.all(Pm.map(async e=>[e,await Ch(e)]));return Object.fromEntries(e)},Th=e=>Pm.includes(e),Ah=(e,t)=>{for(const n of e.item.meta?.externalDeps??[])t.has(n.command)||t.set(n.command,n)},Ih=e=>{const t=new Map;for(const n of e)Ah(n,t);return[...t.values()]},Dh=(e,t)=>{const{dependencies:n}=e.item,r=[];for(const[i,o]of Object.entries(n)){if(!Th(i))continue;const n=i,s=t[n];for(const i of o){const o=s.items.find(e=>e.name===i);if(!o){Em(`Dependency "${i}" not found in ${n} registry (referenced by ${e.item.name})`);continue}const a={type:n,item:o,registry:s},l=Dh(a,t);r.push(a,...l)}}return r},kh=e=>e.reduce((e,t)=>({...e,[t.type]:[...e[t.type]??[],t]}),{}),Mh=e=>e.command.includes(" ")?0===c(e.command,{stdio:"ignore",shell:!0}).status:0===c("command",["-v",e.command],{stdio:"ignore",shell:!0}).status,jh=e=>{const t=[],n=[];for(const r of e)Mh(r)?t.push(r):n.push(r);return{installed:t,missing:n}},Nh=async(e,t,n)=>{try{if(await(async e=>{await hm(e.install,[],`Installing ${e.name}...`,{exitOnError:!1,stdio:"inherit",type:"exec"})})(e),Mh(e))return $m(`${e.name} installed successfully`),void t.push(e);if("brew"===e.type&&(e=>{const t=e.install.split(/\s+/),n=t.indexOf("install");if(-1===n||!t[n+1])return!1;const r=t[n+1],i=[`/opt/homebrew/opt/${r}/bin`,`/usr/local/opt/${r}/bin`];for(const t of i)if(y(`${t}/${e.command}`))return process.env.PATH=`${t}:${process.env.PATH}`,vm(`Added ${t} to PATH (keg-only formula)`),Em(`To make "${e.command}" permanently available, add to ~/.zshrc:`),Em(` export PATH="${t}:$PATH"`),!0;const o=c("brew",["--prefix",r],{encoding:"utf8",stdio:"pipe"});if(0===o.status&&o.stdout.trim()){const t=`${o.stdout.trim()}/bin`;if(y(`${t}/${e.command}`))return process.env.PATH=`${t}:${process.env.PATH}`,vm(`Added ${t} to PATH (keg-only formula)`),Em(`To make "${e.command}" permanently available, add to ~/.zshrc:`),Em(` export PATH="${t}:$PATH"`),!0}return!1})(e)&&Mh(e))return $m(`${e.name} installed successfully (keg-only, PATH updated)`),void t.push(e);n.push({dep:e,error:"Installation completed but command not found"}),Em(`${e.name} installation did not register the command "${e.command}"`)}catch(t){const r=t instanceof Error?t.message:String(t);n.push({dep:e,error:r}),Em(`Failed to install ${e.name}: ${r}`)}},Ph=t=>{const n=[];for(const r of t.installed){const t=e.dim("installed");n.push(` ${e.green("✓")} ${r.name.padEnd(20)} ${t}`)}for(const r of t.missing){const t=e.yellow(r.install),i=r.optional?e.dim(" (optional)"):"";n.push(` ${e.red("✗")} ${r.name.padEnd(20)} ${t}${i}`)}const r=t.missing.filter(e=>!e.optional),i=t.missing.filter(e=>e.optional);if((r.length>0||i.length>0)&&n.push(""),r.length>0){const t=`${r.length} required dependencies need installation`;n.push(` ${e.red(t)}`)}if(i.length>0){const t=`${i.length} optional dependencies not installed`;n.push(` ${e.dim(t)}`)}0===t.missing.length&&n.push("",` ${e.green("All dependencies are installed!")}`),_m(e.bgHex(Jm).bold(" External Dependencies "),n.join("\n"),{titleAlign:"center",rounded:!0,formatBorder:t=>e.hex(Jm)(t)})},Rh=async t=>{const n=t.missing.filter(e=>!e.optional),r=t.missing.filter(e=>e.optional);if(0===n.length&&r.length>0)return await Im({message:`${r.length} optional dependencies available. What would you like to install?`,choices:[{name:"skip",message:"Skip installation",hint:"Continue without optional deps"},{name:"all",message:"Install optional dependencies",hint:"Full feature set"}]});const i=await Im({message:"What would you like to install?",choices:[{name:"all",message:`All dependencies (${n.length} required + ${r.length} optional)`,hint:"Recommended"},{name:"required",message:`Required only (${n.length})`,hint:"Skip optional packages"},{name:"skip",message:"Skip installation",hint:"Install nothing"}]});if("skip"===i){const r=[` ${e.hex(Ym)("⚠")} Some toolkit features may be limited or unavailable`,` ${e.hex(Ym)("⚠")} without the required external dependencies.`,"",` ${e.dim("Missing required:")} ${n.map(e=>e.name).join(", ")}`];if(_m(e.bgHex(Ym).bold(" Warning "),r.join("\n"),{titleAlign:"center",rounded:!0,formatBorder:t=>e.hex(Ym)(t)}),!await km({message:"Continue without installing dependencies?",initial:!1}))return Rh(t)}return i},Lh=async e=>{const t=u.join(e,Km.DEST_DIR),n=Km.COMMON_TEMPLATES,r=await(async e=>{const t=Km.COMMON_TEMPLATES,n=u.join(e,Km.DEST_DIR);await rh(n);const r=await oe.readdir(t,{withFileTypes:!0}),i=await oe.readdir(n,{withFileTypes:!0}),o=r.filter(e=>!i.some(t=>t.name===e.name));return 0===o.length?[]:o.map(e=>e.name)})(e);await rh(t);const i=r.map(e=>{const r=u.join(n,e),i=u.join(t,e);return se(r,i)});await Promise.all(i)},Bh=(t,n,r)=>{const i=null===t,o=i?" Update Complete ":" Installation Complete ",s=[` ${e.green("Components installed:")} ${n}`,...r>0?[` ${e.green("External deps installed:")} ${r}`]:[],...i?[` ${e.dim("Mode: update (configs preserved)")}`]:[],"",` ${e.dim("Next: Run")} ${e.bold("claude")} ${e.dim("to start using the toolkit")}`];_m(e.bgHex(Xm).bold(o),s.join("\n"),{titleAlign:"center",rounded:!0,formatBorder:t=>e.hex(Xm)(t)})},Fh=new Set(["npm install","yarn install","pnpm install"]),Uh=async e=>{const t=u.join(e,"package.json");if(await ih(t))return e;const n=u.join(e,"scripts","package.json");return await ih(n)?u.join(e,"scripts"):null},Hh=(e,t)=>{const n=e.item.files[0];if(!n)return null;const r=n.endsWith("/")?n.slice(0,-1):u.dirname(n);return u.join(t,".claude",r)},Wh=async(e,t,n)=>{try{return await hm(t,[],`Running postInstall for ${e}...`,{exitOnError:!1,type:"exec",cwd:n,spinner:!1}),{ok:!0}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},Gh=async(e,t,n)=>{const r=n??process.cwd(),i=e.filter(e=>e.type===t);if(0===i.length)return{installed:0,failedPostInstall:0};await uh(i,r);const o=await(async(e,t)=>{const n=e.filter(e=>e.item.meta?.postInstall);if(0===n.length)return{success:[],failed:[]};const r=[],i=[];for(const e of n){const{name:n,meta:o}=e.item,s=o?.postInstall;if(!s)continue;if(!Fh.has(s)){Em(`Skipping untrusted postInstall command for ${n}: "${s}"`);continue}const a=Hh(e,t);if(!a){Em(`Skipping postInstall for ${n}: no files defined`);continue}const l=await Uh(a);if(!l){Em(`Skipping postInstall for ${n}: no package.json found in ${a}`);continue}vm(`Running "${s}" for ${n} in ${u.relative(t,l)}`);const c=await Wh(n,s,l);c.ok?($m(`postInstall completed for ${n}`),r.push(n)):(Em(`postInstall failed for ${n}: ${c.error}`),i.push({name:n,error:c.error??"Unknown error"}))}return{success:r,failed:i}})(i,r);return o.failed.length>0&&Em(`${o.failed.length} postInstall command(s) failed for ${t}`),{installed:i.length,failedPostInstall:o.failed.length}},Vh=async e=>{if(0===e.missing.length)return $m("All external dependencies are already installed"),0;const t=await Rh(e);if("skip"===t)return Em("Skipping dependency installation. Some features may be limited."),0;const n="all"===t?e.missing:e.missing.filter(e=>!e.optional),r=await(async e=>{const t=[],n=[];for(let r=0;r<e.length;r++){const i=e[r],o=`[${r+1}/${e.length}]`;vm(`${o} Installing ${i.name} via: ${i.install}`),await Nh(i,t,n)}return{success:t,failed:n}})(n);return(e=>{if(e.failed.length>0){const t=e.failed.filter(e=>!e.dep.optional);for(const t of e.failed)Em(`Failed to install ${t.dep.name}: ${t.error}`);t.length>0&&Sm(`${t.length} required dependencies failed to install. Some features may not work.`)}return e.success.length})(r)},qh=e=>{const t=e.split(/\s+/).at(-1);return t&&"install"!==t?t:null},Kh={PREREQUISITES:1,CONFIGURE:2,COMMONS:3,SCRIPTS:4,HOOKS:5,WORKFLOWS:6,ANALYZE:7,INSTALL:8,DEPENDENCIES:9},zh=Object.values(Kh).length,Yh=new Set(["catalog-generators"]),Jh={PREREQUISITES:1,CONFIGURE:2,COMMONS:3,ANALYZE:4,DEPLOY:5,PYTHON:6,DEPS:7,GENERATE:8,DONE:9},Xh=Object.values(Jh).length,Qh=async()=>{try{xm(Jh.PREREQUISITES,Xh,"Checking prerequisites..."),nh(),await th();const e=process.cwd(),t="update"===await Sh(e);t&&vm("Update mode: templates will be refreshed, your configs preserved."),xm(Jh.CONFIGURE,Xh,"Configuring installation...");const n=t?null:await xh(e);xm(Jh.COMMONS,Xh,"Copying base infrastructure..."),n&&await ph(e),await Lh(e),await mh(e),xm(Jh.ANALYZE,Xh,"Analyzing components...");const r=(e=>{const t=[];for(const[n,r]of Object.entries(e))for(const e of r.items)t.push({type:n,item:e,registry:r});return t})(await _h());xm(Jh.DEPLOY,Xh,"Deploying components...");for(const t of Pm)await Gh(r,t,e);xm(Jh.PYTHON,Xh,"Setting up Python environment..."),await(async(e,t)=>{const n=e.some(e=>"python"===e.item.meta?.runtime);if(!n)return{venvCreated:!1,packagesInstalled:[],errors:[]};const r=(e=>{const t=new Set;for(const n of e)if("python"===n.item.meta?.runtime)for(const e of n.item.meta.externalDeps??[])if("pip"===e.type){const n=qh(e.install);n&&t.add(n)}return[...t]})(e);if(0===r.length)return{venvCreated:!1,packagesInstalled:[],errors:[]};const i=u.join(t,".claude/skills/.venv"),o=await(async e=>{const t=u.join(e,"bin","activate"),n=u.join(e,"bin","python3");if(!await ih(e))return"missing";const r=await ih(t),i=await ih(n);return r&&i?"valid":"corrupted"})(i);"corrupted"===o&&(Em("Existing venv is corrupted, recreating..."),await oe.rm(i,{recursive:!0,force:!0}));let s=!1;if("valid"!==o)try{await(async e=>{try{return void await hm(`python3 -m venv ${e}`,[],"Creating Python venv...",{exitOnError:!1,type:"exec",spinner:!1})}catch{}vm("Falling back to venv without pip..."),await hm(`python3 -m venv --without-pip ${e}`,[],"Creating Python venv (no pip)...",{exitOnError:!1,type:"exec",spinner:!1}),Em("Bootstrapping pip from bootstrap.pypa.io (remote script)"),await hm(`curl -sS https://bootstrap.pypa.io/get-pip.py | ${e}/bin/python3`,[],"Bootstrapping pip...",{exitOnError:!1,type:"exec",spinner:!1})})(i),s=!0,$m("Python venv created")}catch(e){const t=e instanceof Error?e.message:String(e);return Em(`Failed to create Python venv: ${t}`),{venvCreated:!1,packagesInstalled:[],errors:[t]}}if(s)try{const e=u.join(i,"bin","pip3");await hm(`${e} install --upgrade pip`,[],"Upgrading pip...",{exitOnError:!1,type:"exec",spinner:!1})}catch{}const{installed:a,errors:l}=await(async(e,t)=>{const n=[],r=[],i=u.join(e,"bin","pip3");for(const e of t)try{await hm(`${i} install ${e}`,[],`Installing ${e}...`,{exitOnError:!1,type:"exec",spinner:!1}),n.push(e)}catch(t){const n=t instanceof Error?t.message:String(t);r.push(`${e}: ${n}`),Em(`Failed to install ${e}: ${n}`)}return{installed:n,errors:r}})(i,r);return a.length>0&&$m(`Installed ${a.length} pip package(s) in venv`),{venvCreated:s,packagesInstalled:a,errors:l}})(r,e),xm(Jh.DEPS,Xh,"Installing external dependencies...");const i=Ih(r),o=jh(i);Ph(o);const s=await Vh(o);xm(Jh.GENERATE,Xh,"Generating configuration files..."),n?(await fh(n),await wh(n)):await hh(e),xm(Jh.DONE,Xh,"Done!"),Bh(n,r.length,s)}catch(e){const t=e instanceof Error?e.message:String(e);throw Sm(`Installation failed: ${t}`),e}},Zh={LOAD:1,SCAN:2,SELECT:3,RESOLVE:4,COPY:5},ef=Object.values(Zh).length,tf=async t=>{try{const n=process.cwd();xm(Zh.LOAD,ef,"Loading registries...");const r=await _h();xm(Zh.SCAN,ef,"Scanning existing installation...");const i=await(async(e,t)=>{const n=u.join(e,Km.DEST_DIR,"settings.json"),r=u.join(e,Km.DEST_DIR,"hooks"),[i,o]=await Promise.all([ih(n),ih(r)]),s=await Promise.all(Pm.map(async n=>[n,await Oh(n,e,t)]));return{hasSettings:i,hasHooks:o,installedComponents:new Map(s)}})(n,r);xm(Zh.SELECT,ef,`Select ${t} to add...`);const o=r[t],s=await(async(t,n,r)=>{const i=n.items.map(n=>{const i=((e,t,n)=>{const r=n.installedComponents.get(e);return r?.includes(t)??!1})(t,n.name,r),o=i?e.hex(Xm)("installed"):(s=n.description).length<=80?s:`${s.slice(0,80)}…`;var s;return{name:n.name,message:n.title,hint:o,disabled:i}}),o=i.filter(e=>!e.disabled);return 0===o.length?[]:await Dm({message:`Select ${t} to add:`,choices:i,required:!0})})(t,o,i);if(0===s.length)return void Em(`No ${t} selected. Exiting.`);const a=s.flatMap(e=>{const n=o.items.find(t=>t.name===e);return n?[{type:t,item:n,registry:o}]:[]});xm(Zh.RESOLVE,ef,"Resolving dependencies..."),await Gh(a,t),$m(`${t} added successfully`)}catch(e){const n=e instanceof Error?e.message:String(e);throw Sm(`Add-${t} failed: ${n}`),e}},nf=async(e,t={})=>{switch(e){case Rm:await(async()=>{try{xm(Kh.PREREQUISITES,zh,"Checking prerequisites..."),nh(),await th();const e=process.cwd(),t=await yh(e),n=await vh(e);t&&($h("Initialization unavailable due to existing configuration."),process.exit(0)),n&&(Em("CLAUDE.md already exists — by continuing, we'll backup your current configuration and install fresh."),await km({message:"Are you sure you want to continue?",initial:!0})||process.exit(0)),await ph(e),xm(Kh.COMMONS,zh,"Copying common configs..."),await Lh(e),await mh(e),xm(Kh.CONFIGURE,zh,"Configuring installation...");const r=await xh(e);await fh(r),await wh(r),xm(Kh.SCRIPTS,zh,"Loading scripts...");const i=await Ch("scripts"),o={...i,items:i.items.filter(e=>Yh.has(e.name))};xm(Kh.HOOKS,zh,"Loading hooks...");const s=await Ch("hooks");xm(Kh.WORKFLOWS,zh,"Loading workflows...");const a=new Set(s.items.flatMap(e=>e.dependencies.workflows)),l=await Ch("workflows"),c={...l,items:l.items.filter(e=>a.has(e.name))};xm(Kh.ANALYZE,zh,"Analyzing dependencies...");const d=await(async e=>{const t={agents:[],commands:[],skills:[],hooks:[],scripts:[],workflows:[]};if(0===Object.keys(e).length)return t;const n=await _h(),r=Object.entries(e).filter(([e])=>Th(e)).flatMap(([e,t])=>{const r=e,i=t.items.map(e=>({type:r,item:e,registry:t})),o=i.flatMap(e=>Dh(e,n));return[...i,...o]});return{...t,...kh((i=r,i.filter((e,t,n)=>t===n.findIndex(t=>t.item.name===e.item.name))))};var i})({workflows:c,scripts:o,hooks:s}),u=Object.values(d).flat(),p=Ih(u);xm(Kh.INSTALL,zh,"Installing components...");for(const[e,t]of Object.entries(d))await Gh(t,e);xm(Kh.DEPENDENCIES,zh,"Checking dependencies...");const m=jh(p);Ph(m);const h=await Vh(m);Bh(r,u.length,h)}catch(e){const t=e instanceof Error?e.message:String(e);throw Sm(`Init failed: ${t}`),e}})();break;case Lm:await Qh();break;case Bm:await(async()=>tf("skills"))();break;case Fm:await(async()=>tf("agents"))();break;case Um:await(async()=>tf("commands"))();break;case Hm:Cm("Exiting the claude code toolkit"),process.exit(0);break;default:throw new Error(`Unknown command: ${e}`)}},rf=e=>{e instanceof Error?Sm(e.message):Sm(`Unknown error: ${String(e)}`),process.exit(1)},of=(sf={name:"cc",version:jm,description:Nm,banner:Zm},new class{program;config;constructor(e){this.config=e,this.program=(new We).name(e.name).version(e.version).description(e.description??"")}command(e){const t=this.program.command(e.name).description(e.description);if(e.arguments)for(const n of e.arguments){const e=!1===n.required?`[${n.name}]`:`<${n.name}>`;t.argument(e,n.description)}if(e.options)for(const n of e.options)n.required?t.requiredOption(n.flags,n.description,n.default):t.option(n.flags,n.description,n.default);return t.action(async(...t)=>{const n=t.at(-2),r=t.slice(0,-2);this.config.banner&&this.config.banner(),await e.action(n,...r)}),this}async parse(e=process.argv){await this.program.parseAsync(e)}getProgram(){return this.program}}(sf)).command({name:Rm,description:Wm[Rm],action:e=>{nf(Rm,e).catch(rf)}}).command({name:Lm,description:Wm[Lm],action:e=>{nf(Lm,e).catch(rf)}}).command({name:Bm,description:Wm[Bm],action:e=>{nf(Bm,e).catch(rf)}}).command({name:Fm,description:Wm[Fm],action:e=>{nf(Fm,e).catch(rf)}}).command({name:Um,description:Wm[Um],action:e=>{nf(Um,e).catch(rf)}}).getProgram().action(()=>{Om(e.hex("#DE7356").bold("Launching Claude Code Toolkit...")),Tm(""),Zm(),(async()=>{try{vm("Preparing next steps...");const t=16,n=Object.entries(Wm).map(([n,r])=>{const i=((e,t)=>{const n=Math.max(0,t-e.length);return" ".repeat(n)})(n,t),o=Gm[n],s=Vm.includes(n);return{name:`${n}${i}}`,hint:s?"Coming soon...":e.bold.magenta(r),message:o,disabled:s}}),r=await Im({message:"Pick operation you would like to perform?",choices:n}),i=Object.keys(Wm).find(e=>r.startsWith(e));i||(Sm("Invalid operation"),process.exit(1)),$m(`Chosen operation: ${e.greenBright(i)}`),await nf(i),process.exit(0)}catch{process.exit(1)}})().catch(rf)});var sf;const af=()=>{process.on("unhandledRejection",e=>{console.error("Unhandled Rejection at:",{error:e}),process.exit(1)}),process.on("uncaughtException",e=>{console.error("Uncaught Exception thrown:",{error:e}),process.exit(1)}),process.on("SIGINT",()=>{console.log("Received SIGINT"),process.exit(0)}),process.on("SIGTERM",()=>{console.log("Received SIGTERM"),process.exit(0)}),of.parse()};export{af as claudeCodeToolkit};
|
package/package.json
CHANGED
|
File without changes
|