espcli 0.0.2 → 0.0.4
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 +120 -94
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,133 +1,133 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as
|
|
3
|
-
`)}displayWidth($){return
|
|
2
|
+
import{createRequire as BX}from"node:module";var GX=Object.create;var{getPrototypeOf:KX,defineProperty:K3,getOwnPropertyNames:UX}=Object;var zX=Object.prototype.hasOwnProperty;var o=($,q,J)=>{J=$!=null?GX(KX($)):{};let X=q||!$||!$.__esModule?K3(J,"default",{value:$,enumerable:!0}):J;for(let Z of UX($))if(!zX.call(X,Z))K3(X,Z,{get:()=>$[Z],enumerable:!0});return X};var A=($,q)=>()=>(q||$((q={exports:{}}).exports,q),q.exports);var m=BX(import.meta.url);var e1=A((LX)=>{class J2 extends Error{constructor($,q,J){super(J);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=q,this.exitCode=$,this.nestedError=void 0}}class U3 extends J2{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}LX.CommanderError=J2;LX.InvalidArgumentError=U3});var k0=A((TX)=>{var{InvalidArgumentError:_X}=e1();class z3{constructor($,q){switch(this.description=q||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue($,q){if(q===this.defaultValue||!Array.isArray(q))return[$];return q.push($),q}default($,q){return this.defaultValue=$,this.defaultValueDescription=q,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(q,J)=>{if(!this.argChoices.includes(q))throw new _X(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(q,J);return q},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function RX($){let q=$.name()+($.variadic===!0?"...":"");return $.required?"<"+q+">":"["+q+"]"}TX.Argument=z3;TX.humanReadableArgName=RX});var X2=A((xX)=>{var{humanReadableArgName:FX}=k0();class B3{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext($){this.helpWidth=this.helpWidth??$.helpWidth??80}visibleCommands($){let q=$.commands.filter((X)=>!X._hidden),J=$._getHelpCommand();if(J&&!J._hidden)q.push(J);if(this.sortSubcommands)q.sort((X,Z)=>{return X.name().localeCompare(Z.name())});return q}compareOptions($,q){let J=(X)=>{return X.short?X.short.replace(/^-/,""):X.long.replace(/^--/,"")};return J($).localeCompare(J(q))}visibleOptions($){let q=$.options.filter((X)=>!X.hidden),J=$._getHelpOption();if(J&&!J.hidden){let X=J.short&&$._findOption(J.short),Z=J.long&&$._findOption(J.long);if(!X&&!Z)q.push(J);else if(J.long&&!Z)q.push($.createOption(J.long,J.description));else if(J.short&&!X)q.push($.createOption(J.short,J.description))}if(this.sortOptions)q.sort(this.compareOptions);return q}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let q=[];for(let J=$.parent;J;J=J.parent){let X=J.options.filter((Z)=>!Z.hidden);q.push(...X)}if(this.sortOptions)q.sort(this.compareOptions);return q}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((q)=>{q.description=q.description||$._argsDescription[q.name()]||""});if($.registeredArguments.find((q)=>q.description))return $.registeredArguments;return[]}subcommandTerm($){let q=$.registeredArguments.map((J)=>FX(J)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(q?" "+q:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,q){return q.visibleCommands($).reduce((J,X)=>{return Math.max(J,this.displayWidth(q.styleSubcommandTerm(q.subcommandTerm(X))))},0)}longestOptionTermLength($,q){return q.visibleOptions($).reduce((J,X)=>{return Math.max(J,this.displayWidth(q.styleOptionTerm(q.optionTerm(X))))},0)}longestGlobalOptionTermLength($,q){return q.visibleGlobalOptions($).reduce((J,X)=>{return Math.max(J,this.displayWidth(q.styleOptionTerm(q.optionTerm(X))))},0)}longestArgumentTermLength($,q){return q.visibleArguments($).reduce((J,X)=>{return Math.max(J,this.displayWidth(q.styleArgumentTerm(q.argumentTerm(X))))},0)}commandUsage($){let q=$._name;if($._aliases[0])q=q+"|"+$._aliases[0];let J="";for(let X=$.parent;X;X=X.parent)J=X.name()+" "+J;return J+q+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let q=[];if($.argChoices)q.push(`choices: ${$.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")q.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)q.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)q.push(`env: ${$.envVar}`);if(q.length>0){let J=`(${q.join(", ")})`;if($.description)return`${$.description} ${J}`;return J}return $.description}argumentDescription($){let q=[];if($.argChoices)q.push(`choices: ${$.argChoices.map((J)=>JSON.stringify(J)).join(", ")}`);if($.defaultValue!==void 0)q.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(q.length>0){let J=`(${q.join(", ")})`;if($.description)return`${$.description} ${J}`;return J}return $.description}formatItemList($,q,J){if(q.length===0)return[];return[J.styleTitle($),...q,""]}groupItems($,q,J){let X=new Map;return $.forEach((Z)=>{let H=J(Z);if(!X.has(H))X.set(H,[])}),q.forEach((Z)=>{let H=J(Z);if(!X.has(H))X.set(H,[]);X.get(H).push(Z)}),X}formatHelp($,q){let J=q.padWidth($,q),X=q.helpWidth??80;function Z(U,z){return q.formatItem(U,J,z,q)}let H=[`${q.styleTitle("Usage:")} ${q.styleUsage(q.commandUsage($))}`,""],Q=q.commandDescription($);if(Q.length>0)H=H.concat([q.boxWrap(q.styleCommandDescription(Q),X),""]);let Y=q.visibleArguments($).map((U)=>{return Z(q.styleArgumentTerm(q.argumentTerm(U)),q.styleArgumentDescription(q.argumentDescription(U)))});if(H=H.concat(this.formatItemList("Arguments:",Y,q)),this.groupItems($.options,q.visibleOptions($),(U)=>U.helpGroupHeading??"Options:").forEach((U,z)=>{let B=U.map((L)=>{return Z(q.styleOptionTerm(q.optionTerm(L)),q.styleOptionDescription(q.optionDescription(L)))});H=H.concat(this.formatItemList(z,B,q))}),q.showGlobalOptions){let U=q.visibleGlobalOptions($).map((z)=>{return Z(q.styleOptionTerm(q.optionTerm(z)),q.styleOptionDescription(q.optionDescription(z)))});H=H.concat(this.formatItemList("Global Options:",U,q))}return this.groupItems($.commands,q.visibleCommands($),(U)=>U.helpGroup()||"Commands:").forEach((U,z)=>{let B=U.map((L)=>{return Z(q.styleSubcommandTerm(q.subcommandTerm(L)),q.styleSubcommandDescription(q.subcommandDescription(L)))});H=H.concat(this.formatItemList(z,B,q))}),H.join(`
|
|
3
|
+
`)}displayWidth($){return L3($).length}styleTitle($){return $}styleUsage($){return $.split(" ").map((q)=>{if(q==="[options]")return this.styleOptionText(q);if(q==="[command]")return this.styleSubcommandText(q);if(q[0]==="["||q[0]==="<")return this.styleArgumentText(q);return this.styleCommandText(q)}).join(" ")}styleCommandDescription($){return this.styleDescriptionText($)}styleOptionDescription($){return this.styleDescriptionText($)}styleSubcommandDescription($){return this.styleDescriptionText($)}styleArgumentDescription($){return this.styleDescriptionText($)}styleDescriptionText($){return $}styleOptionTerm($){return this.styleOptionText($)}styleSubcommandTerm($){return $.split(" ").map((q)=>{if(q==="[options]")return this.styleOptionText(q);if(q[0]==="["||q[0]==="<")return this.styleArgumentText(q);return this.styleSubcommandText(q)}).join(" ")}styleArgumentTerm($){return this.styleArgumentText($)}styleOptionText($){return $}styleArgumentText($){return $}styleSubcommandText($){return $}styleCommandText($){return $}padWidth($,q){return Math.max(q.longestOptionTermLength($,q),q.longestGlobalOptionTermLength($,q),q.longestSubcommandTermLength($,q),q.longestArgumentTermLength($,q))}preformatted($){return/\n[^\S\r\n]/.test($)}formatItem($,q,J,X){let H=" ".repeat(2);if(!J)return H+$;let Q=$.padEnd(q+$.length-X.displayWidth($)),Y=2,K=(this.helpWidth??80)-q-Y-2,U;if(K<this.minWidthToWrap||X.preformatted(J))U=J;else U=X.boxWrap(J,K).replace(/\n/g,`
|
|
4
4
|
`+" ".repeat(q+Y));return H+Q+" ".repeat(Y)+U.replace(/\n/g,`
|
|
5
5
|
${H}`)}boxWrap($,q){if(q<this.minWidthToWrap)return $;let J=$.split(/\r\n|\n/),X=/[\s]*[^\s]+/g,Z=[];return J.forEach((H)=>{let Q=H.match(X);if(Q===null){Z.push("");return}let Y=[Q.shift()],G=this.displayWidth(Y[0]);Q.forEach((K)=>{let U=this.displayWidth(K);if(G+U<=q){Y.push(K),G+=U;return}Z.push(Y.join(""));let z=K.trimStart();Y=[z],G=this.displayWidth(z)}),Z.push(Y.join(""))}),Z.join(`
|
|
6
|
-
`)}}function
|
|
6
|
+
`)}}function L3($){let q=/\x1b\[\d*(;\d*)*m/g;return $.replace(q,"")}xX.Help=B3;xX.stripColor=L3});var Z2=A((IX)=>{var{InvalidArgumentError:CX}=e1();class W3{constructor($,q){this.flags=$,this.description=q||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let J=wX($);if(this.short=J.shortFlag,this.long=J.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default($,q){return this.defaultValue=$,this.defaultValueDescription=q,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let q=$;if(typeof $==="string")q={[$]:!0};return this.implied=Object.assign(this.implied||{},q),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_collectValue($,q){if(q===this.defaultValue||!Array.isArray(q))return[$];return q.push($),q}choices($){return this.argChoices=$.slice(),this.parseArg=(q,J)=>{if(!this.argChoices.includes(q))throw new CX(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(q,J);return q},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return V3(this.name().replace(/^no-/,""));return V3(this.name())}helpGroup($){return this.helpGroupHeading=$,this}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class _3{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((q)=>{if(q.negate)this.negativeOptions.set(q.attributeName(),q);else this.positiveOptions.set(q.attributeName(),q)}),this.negativeOptions.forEach((q,J)=>{if(this.positiveOptions.has(J))this.dualOptions.add(J)})}valueFromOption($,q){let J=q.attributeName();if(!this.dualOptions.has(J))return!0;let X=this.negativeOptions.get(J).presetArg,Z=X!==void 0?X:!1;return q.negate===(Z===$)}}function V3($){return $.split("-").reduce((q,J)=>{return q+J[0].toUpperCase()+J.slice(1)})}function wX($){let q,J,X=/^-[^-]$/,Z=/^--[^-]/,H=$.split(/[ |,]+/).concat("guard");if(X.test(H[0]))q=H.shift();if(Z.test(H[0]))J=H.shift();if(!q&&X.test(H[0]))q=H.shift();if(!q&&Z.test(H[0]))q=J,J=H.shift();if(H[0].startsWith("-")){let Q=H[0],Y=`option creation failed due to '${Q}' in option flags '${$}'`;if(/^-[^-][^-]/.test(Q))throw Error(`${Y}
|
|
7
7
|
- a short flag is a single dash and a single character
|
|
8
8
|
- either use a single dash and a single character (for a short flag)
|
|
9
9
|
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(X.test(Q))throw Error(`${Y}
|
|
10
10
|
- too many short flags`);if(Z.test(Q))throw Error(`${Y}
|
|
11
11
|
- too many long flags`);throw Error(`${Y}
|
|
12
|
-
- unrecognised flag format`)}if(q===void 0&&J===void 0)throw Error(`option creation failed due to no flags found in '${$}'.`);return{shortFlag:q,longFlag:J}}
|
|
12
|
+
- unrecognised flag format`)}if(q===void 0&&J===void 0)throw Error(`option creation failed due to no flags found in '${$}'.`);return{shortFlag:q,longFlag:J}}IX.Option=W3;IX.DualOptions=_3});var R3=A((NX)=>{function yX($,q){if(Math.abs($.length-q.length)>3)return Math.max($.length,q.length);let J=[];for(let X=0;X<=$.length;X++)J[X]=[X];for(let X=0;X<=q.length;X++)J[0][X]=X;for(let X=1;X<=q.length;X++)for(let Z=1;Z<=$.length;Z++){let H=1;if($[Z-1]===q[X-1])H=0;else H=1;if(J[Z][X]=Math.min(J[Z-1][X]+1,J[Z][X-1]+1,J[Z-1][X-1]+H),Z>1&&X>1&&$[Z-1]===q[X-2]&&$[Z-2]===q[X-1])J[Z][X]=Math.min(J[Z][X],J[Z-2][X-2]+1)}return J[$.length][q.length]}function OX($,q){if(!q||q.length===0)return"";q=Array.from(new Set(q));let J=$.startsWith("--");if(J)$=$.slice(2),q=q.map((Q)=>Q.slice(2));let X=[],Z=3,H=0.4;if(q.forEach((Q)=>{if(Q.length<=1)return;let Y=yX($,Q),G=Math.max($.length,Q.length);if((G-Y)/G>H){if(Y<Z)Z=Y,X=[Q];else if(Y===Z)X.push(Q)}}),X.sort((Q,Y)=>Q.localeCompare(Y)),J)X=X.map((Q)=>`--${Q}`);if(X.length>1)return`
|
|
13
13
|
(Did you mean one of ${X.join(", ")}?)`;if(X.length===1)return`
|
|
14
|
-
(Did you mean ${X[0]}?)`;return""}
|
|
15
|
-
- specify the name in Command constructor or using .name()`);if(q=q||{},q.isDefault)this._defaultCommandName=$._name;if(q.noHelp||q.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,q){return new
|
|
16
|
-
Expecting one of '${J.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(q);else this._lifeCycleHooks[$]=[q];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(q)=>{if(q.code!=="commander.executeSubCommandAsync")throw q};return this}_exit($,q,J){if(this._exitCallback)this._exitCallback(new
|
|
17
|
-
- already used by option '${q.flags}'`)}this._initOptionGroup($),this.options.push($)}_registerCommand($){let q=(X)=>{return[X.name()].concat(X.aliases())},J=q($).find((X)=>this._findCommand(X));if(J){let X=q(this._findCommand(J)).join("|"),Z=q($).join("|");throw Error(`cannot add command '${Z}' as already have command '${X}'`)}this._initCommandGroup($),this.commands.push($)}addOption($){this._registerOption($);let q=$.name(),J=$.attributeName();if($.negate){let Z=$.long.replace(/^--no-/,"--");if(!this._findOption(Z))this.setOptionValueWithSource(J,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(J,$.defaultValue,"default");let X=(Z,H,Q)=>{if(Z==null&&$.presetArg!==void 0)Z=$.presetArg;let Y=this.getOptionValue(J);if(Z!==null&&$.parseArg)Z=this._callParseArg($,Z,Y,H);else if(Z!==null&&$.variadic)Z=$._collectValue(Z,Y);if(Z==null)if($.negate)Z=!1;else if($.isBoolean()||$.optional)Z=!0;else Z="";this.setOptionValueWithSource(J,Z,Q)};if(this.on("option:"+q,(Z)=>{let H=`error: option '${$.flags}' argument '${Z}' is invalid.`;X(Z,H,"cli")}),$.envVar)this.on("optionEnv:"+q,(Z)=>{let H=`error: option '${$.flags}' value '${Z}' from env '${$.envVar}' is invalid.`;X(Z,H,"env")});return this}_optionEx($,q,J,X,Z){if(typeof q==="object"&&q instanceof
|
|
18
|
-
- 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($,q,J){if(
|
|
14
|
+
(Did you mean ${X[0]}?)`;return""}NX.suggestSimilar=OX});var F3=A((cX)=>{var vX=m("node:events").EventEmitter,Q2=m("node:child_process"),Q1=m("node:path"),F0=m("node:fs"),k=m("node:process"),{Argument:hX,humanReadableArgName:fX}=k0(),{CommanderError:H2}=e1(),{Help:SX,stripColor:bX}=X2(),{Option:T3,DualOptions:gX}=Z2(),{suggestSimilar:P3}=R3();class G2 extends vX{constructor($){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=$||"",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:(q)=>k.stdout.write(q),writeErr:(q)=>k.stderr.write(q),outputError:(q,J)=>J(q),getOutHelpWidth:()=>k.stdout.isTTY?k.stdout.columns:void 0,getErrHelpWidth:()=>k.stderr.isTTY?k.stderr.columns:void 0,getOutHasColors:()=>Y2()??(k.stdout.isTTY&&k.stdout.hasColors?.()),getErrHasColors:()=>Y2()??(k.stderr.isTTY&&k.stderr.hasColors?.()),stripColor:(q)=>bX(q)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let q=this;q;q=q.parent)$.push(q);return $}command($,q,J){let X=q,Z=J;if(typeof X==="object"&&X!==null)Z=X,X=null;Z=Z||{};let[,H,Q]=$.match(/([^ ]+) *(.*)/),Y=this.createCommand(H);if(X)Y.description(X),Y._executableHandler=!0;if(Z.isDefault)this._defaultCommandName=Y._name;if(Y._hidden=!!(Z.noHelp||Z.hidden),Y._executableFile=Z.executableFile||null,Q)Y.arguments(Q);if(this._registerCommand(Y),Y.parent=this,Y.copyInheritedSettings(this),X)return this;return Y}createCommand($){return new G2($)}createHelp(){return Object.assign(new SX,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...$},this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,q){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
|
|
15
|
+
- specify the name in Command constructor or using .name()`);if(q=q||{},q.isDefault)this._defaultCommandName=$._name;if(q.noHelp||q.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,q){return new hX($,q)}argument($,q,J,X){let Z=this.createArgument($,q);if(typeof J==="function")Z.default(X).argParser(J);else Z.default(J);return this.addArgument(Z),this}arguments($){return $.trim().split(/ +/).forEach((q)=>{this.argument(q)}),this}addArgument($){let q=this.registeredArguments.slice(-1)[0];if(q?.variadic)throw Error(`only the last argument can be variadic '${q.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,q){if(typeof $==="boolean"){if(this._addImplicitHelpCommand=$,$&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let J=$??"help [command]",[,X,Z]=J.match(/([^ ]+) *(.*)/),H=q??"display help for command",Q=this.createCommand(X);if(Q.helpOption(!1),Z)Q.arguments(Z);if(H)Q.description(H);if(this._addImplicitHelpCommand=!0,this._helpCommand=Q,$||q)this._initCommandGroup(Q);return this}addHelpCommand($,q){if(typeof $!=="object")return this.helpCommand($,q),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this._initCommandGroup($),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,q){let J=["preSubcommand","preAction","postAction"];if(!J.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
|
|
16
|
+
Expecting one of '${J.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(q);else this._lifeCycleHooks[$]=[q];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(q)=>{if(q.code!=="commander.executeSubCommandAsync")throw q};return this}_exit($,q,J){if(this._exitCallback)this._exitCallback(new H2($,q,J));k.exit($)}action($){let q=(J)=>{let X=this.registeredArguments.length,Z=J.slice(0,X);if(this._storeOptionsAsProperties)Z[X]=this;else Z[X]=this.opts();return Z.push(this),$.apply(this,Z)};return this._actionHandler=q,this}createOption($,q){return new T3($,q)}_callParseArg($,q,J,X){try{return $.parseArg(q,J)}catch(Z){if(Z.code==="commander.invalidArgument"){let H=`${X} ${Z.message}`;this.error(H,{exitCode:Z.exitCode,code:Z.code})}throw Z}}_registerOption($){let q=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(q){let J=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${J}'
|
|
17
|
+
- already used by option '${q.flags}'`)}this._initOptionGroup($),this.options.push($)}_registerCommand($){let q=(X)=>{return[X.name()].concat(X.aliases())},J=q($).find((X)=>this._findCommand(X));if(J){let X=q(this._findCommand(J)).join("|"),Z=q($).join("|");throw Error(`cannot add command '${Z}' as already have command '${X}'`)}this._initCommandGroup($),this.commands.push($)}addOption($){this._registerOption($);let q=$.name(),J=$.attributeName();if($.negate){let Z=$.long.replace(/^--no-/,"--");if(!this._findOption(Z))this.setOptionValueWithSource(J,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(J,$.defaultValue,"default");let X=(Z,H,Q)=>{if(Z==null&&$.presetArg!==void 0)Z=$.presetArg;let Y=this.getOptionValue(J);if(Z!==null&&$.parseArg)Z=this._callParseArg($,Z,Y,H);else if(Z!==null&&$.variadic)Z=$._collectValue(Z,Y);if(Z==null)if($.negate)Z=!1;else if($.isBoolean()||$.optional)Z=!0;else Z="";this.setOptionValueWithSource(J,Z,Q)};if(this.on("option:"+q,(Z)=>{let H=`error: option '${$.flags}' argument '${Z}' is invalid.`;X(Z,H,"cli")}),$.envVar)this.on("optionEnv:"+q,(Z)=>{let H=`error: option '${$.flags}' value '${Z}' from env '${$.envVar}' is invalid.`;X(Z,H,"env")});return this}_optionEx($,q,J,X,Z){if(typeof q==="object"&&q instanceof T3)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let H=this.createOption(q,J);if(H.makeOptionMandatory(!!$.mandatory),typeof X==="function")H.default(Z).argParser(X);else if(X instanceof RegExp){let Q=X;X=(Y,G)=>{let K=Q.exec(Y);return K?K[0]:G},H.default(Z).argParser(X)}else H.default(X);return this.addOption(H)}option($,q,J,X){return this._optionEx({},$,q,J,X)}requiredOption($,q,J,X){return this._optionEx({mandatory:!0},$,q,J,X)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,q){return this.setOptionValueWithSource($,q,void 0)}setOptionValueWithSource($,q,J){if(this._storeOptionsAsProperties)this[$]=q;else this._optionValues[$]=q;return this._optionValueSources[$]=J,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let q;return this._getCommandAndAncestors().forEach((J)=>{if(J.getOptionValueSource($)!==void 0)q=J.getOptionValueSource($)}),q}_prepareUserArgs($,q){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(q=q||{},$===void 0&&q.from===void 0){if(k.versions?.electron)q.from="electron";let X=k.execArgv??[];if(X.includes("-e")||X.includes("--eval")||X.includes("-p")||X.includes("--print"))q.from="eval"}if($===void 0)$=k.argv;this.rawArgs=$.slice();let J;switch(q.from){case void 0:case"node":this._scriptPath=$[1],J=$.slice(2);break;case"electron":if(k.defaultApp)this._scriptPath=$[1],J=$.slice(2);else J=$.slice(1);break;case"user":J=$.slice(0);break;case"eval":J=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${q.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",J}parse($,q){this._prepareForParse();let J=this._prepareUserArgs($,q);return this._parseCommand([],J),this}async parseAsync($,q){this._prepareForParse();let J=this._prepareUserArgs($,q);return await this._parseCommand([],J),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
18
|
+
- 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($,q,J){if(F0.existsSync($))return;let X=q?`searched for local subcommand relative to directory '${q}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",Z=`'${$}' does not exist
|
|
19
19
|
- if '${J}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
20
20
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
21
|
-
- ${X}`;throw Error(Z)}_executeSubCommand($,q){q=q.slice();let J=!1,X=[".js",".ts",".tsx",".mjs",".cjs"];function Z(K,U){let z=
|
|
21
|
+
- ${X}`;throw Error(Z)}_executeSubCommand($,q){q=q.slice();let J=!1,X=[".js",".ts",".tsx",".mjs",".cjs"];function Z(K,U){let z=Q1.resolve(K,U);if(F0.existsSync(z))return z;if(X.includes(Q1.extname(U)))return;let B=X.find((L)=>F0.existsSync(`${z}${L}`));if(B)return`${z}${B}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let H=$._executableFile||`${this._name}-${$._name}`,Q=this._executableDir||"";if(this._scriptPath){let K;try{K=F0.realpathSync(this._scriptPath)}catch{K=this._scriptPath}Q=Q1.resolve(Q1.dirname(K),Q)}if(Q){let K=Z(Q,H);if(!K&&!$._executableFile&&this._scriptPath){let U=Q1.basename(this._scriptPath,Q1.extname(this._scriptPath));if(U!==this._name)K=Z(Q,`${U}-${$._name}`)}H=K||H}J=X.includes(Q1.extname(H));let Y;if(k.platform!=="win32")if(J)q.unshift(H),q=k3(k.execArgv).concat(q),Y=Q2.spawn(k.argv[0],q,{stdio:"inherit"});else Y=Q2.spawn(H,q,{stdio:"inherit"});else this._checkForMissingExecutable(H,Q,$._name),q.unshift(H),q=k3(k.execArgv).concat(q),Y=Q2.spawn(k.execPath,q,{stdio:"inherit"});if(!Y.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((U)=>{k.on(U,()=>{if(Y.killed===!1&&Y.exitCode===null)Y.kill(U)})});let G=this._exitCallback;Y.on("close",(K)=>{if(K=K??1,!G)k.exit(K);else G(new H2(K,"commander.executeSubCommandAsync","(close)"))}),Y.on("error",(K)=>{if(K.code==="ENOENT")this._checkForMissingExecutable(H,Q,$._name);else if(K.code==="EACCES")throw Error(`'${H}' not executable`);if(!G)k.exit(1);else{let U=new H2(1,"commander.executeSubCommandAsync","(error)");U.nestedError=K,G(U)}}),this.runningCommand=Y}_dispatchSubcommand($,q,J){let X=this._findCommand($);if(!X)this.help({error:!0});X._prepareForParse();let Z;return Z=this._chainOrCallSubCommandHook(Z,X,"preSubcommand"),Z=this._chainOrCall(Z,()=>{if(X._executableHandler)this._executeSubCommand(X,q.concat(J));else return X._parseCommand(q,J)}),Z}_dispatchHelpCommand($){if(!$)this.help();let q=this._findCommand($);if(q&&!q._executableHandler)q.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,q)=>{if($.required&&this.args[q]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(J,X,Z)=>{let H=X;if(X!==null&&J.parseArg){let Q=`error: command-argument value '${X}' is invalid for argument '${J.name()}'.`;H=this._callParseArg(J,X,Z,Q)}return H};this._checkNumberOfArguments();let q=[];this.registeredArguments.forEach((J,X)=>{let Z=J.defaultValue;if(J.variadic){if(X<this.args.length){if(Z=this.args.slice(X),J.parseArg)Z=Z.reduce((H,Q)=>{return $(J,Q,H)},J.defaultValue)}else if(Z===void 0)Z=[]}else if(X<this.args.length){if(Z=this.args[X],J.parseArg)Z=$(J,Z,J.defaultValue)}q[X]=Z}),this.processedArgs=q}_chainOrCall($,q){if($?.then&&typeof $.then==="function")return $.then(()=>q());return q()}_chainOrCallHooks($,q){let J=$,X=[];if(this._getCommandAndAncestors().reverse().filter((Z)=>Z._lifeCycleHooks[q]!==void 0).forEach((Z)=>{Z._lifeCycleHooks[q].forEach((H)=>{X.push({hookedCommand:Z,callback:H})})}),q==="postAction")X.reverse();return X.forEach((Z)=>{J=this._chainOrCall(J,()=>{return Z.callback(Z.hookedCommand,this)})}),J}_chainOrCallSubCommandHook($,q,J){let X=$;if(this._lifeCycleHooks[J]!==void 0)this._lifeCycleHooks[J].forEach((Z)=>{X=this._chainOrCall(X,()=>{return Z(this,q)})});return X}_parseCommand($,q){let J=this.parseOptions(q);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(J.operands),q=J.unknown,this.args=$.concat(q),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),q);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(q),this._dispatchSubcommand(this._defaultCommandName,$,q);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(J.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let X=()=>{if(J.unknown.length>0)this.unknownOption(J.unknown[0])},Z=`command:${this.name()}`;if(this._actionHandler){X(),this._processArguments();let H;if(H=this._chainOrCallHooks(H,"preAction"),H=this._chainOrCall(H,()=>this._actionHandler(this.processedArgs)),this.parent)H=this._chainOrCall(H,()=>{this.parent.emit(Z,$,q)});return H=this._chainOrCallHooks(H,"postAction"),H}if(this.parent?.listenerCount(Z))X(),this._processArguments(),this.parent.emit(Z,$,q);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,q);if(this.listenerCount("command:*"))this.emit("command:*",$,q);else if(this.commands.length)this.unknownCommand();else X(),this._processArguments()}else if(this.commands.length)X(),this.help({error:!0});else X(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((q)=>q._name===$||q._aliases.includes($))}_findOption($){return this.options.find((q)=>q.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((q)=>{if(q.mandatory&&$.getOptionValue(q.attributeName())===void 0)$.missingMandatoryOptionValue(q)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((J)=>{let X=J.attributeName();if(this.getOptionValue(X)===void 0)return!1;return this.getOptionValueSource(X)!=="default"});$.filter((J)=>J.conflictsWith.length>0).forEach((J)=>{let X=$.find((Z)=>J.conflictsWith.includes(Z.attributeName()));if(X)this._conflictingOption(J,X)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let q=[],J=[],X=q;function Z(K){return K.length>1&&K[0]==="-"}let H=(K)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(K))return!1;return!this._getCommandAndAncestors().some((U)=>U.options.map((z)=>z.short).some((z)=>/^-\d$/.test(z)))},Q=null,Y=null,G=0;while(G<$.length||Y){let K=Y??$[G++];if(Y=null,K==="--"){if(X===J)X.push(K);X.push(...$.slice(G));break}if(Q&&(!Z(K)||H(K))){this.emit(`option:${Q.name()}`,K);continue}if(Q=null,Z(K)){let U=this._findOption(K);if(U){if(U.required){let z=$[G++];if(z===void 0)this.optionMissingArgument(U);this.emit(`option:${U.name()}`,z)}else if(U.optional){let z=null;if(G<$.length&&(!Z($[G])||H($[G])))z=$[G++];this.emit(`option:${U.name()}`,z)}else this.emit(`option:${U.name()}`);Q=U.variadic?U:null;continue}}if(K.length>2&&K[0]==="-"&&K[1]!=="-"){let U=this._findOption(`-${K[1]}`);if(U){if(U.required||U.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${U.name()}`,K.slice(2));else this.emit(`option:${U.name()}`),Y=`-${K.slice(2)}`;continue}}if(/^--[^=]+=/.test(K)){let U=K.indexOf("="),z=this._findOption(K.slice(0,U));if(z&&(z.required||z.optional)){this.emit(`option:${z.name()}`,K.slice(U+1));continue}}if(X===q&&Z(K)&&!(this.commands.length===0&&H(K)))X=J;if((this._enablePositionalOptions||this._passThroughOptions)&&q.length===0&&J.length===0){if(this._findCommand(K)){q.push(K),J.push(...$.slice(G));break}else if(this._getHelpCommand()&&K===this._getHelpCommand().name()){q.push(K,...$.slice(G));break}else if(this._defaultCommandName){J.push(K,...$.slice(G));break}}if(this._passThroughOptions){X.push(K,...$.slice(G));break}X.push(K)}return{operands:q,unknown:J}}opts(){if(this._storeOptionsAsProperties){let $={},q=this.options.length;for(let J=0;J<q;J++){let X=this.options[J].attributeName();$[X]=X===this._versionOptionName?this._version:this[X]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,q)=>Object.assign($,q.opts()),{})}error($,q){if(this._outputConfiguration.outputError(`${$}
|
|
22
22
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
23
23
|
`);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
|
|
24
|
-
`),this.outputHelp({error:!0});let J=q||{},X=J.exitCode||1,Z=J.code||"commander.error";this._exit(X,Z,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in k.env){let q=$.attributeName();if(this.getOptionValue(q)===void 0||["default","config","env"].includes(this.getOptionValueSource(q)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,k.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new
|
|
25
|
-
`),this._exit(0,"commander.version",$)}),this}description($,q){if($===void 0&&q===void 0)return this._description;if(this._description=$,q)this._argsDescription=q;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let q=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)q=this.commands[this.commands.length-1];if($===q._name)throw Error("Command alias can't be the same as its name");let J=this.parent?._findCommand($);if(J){let X=[J.name()].concat(J.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${X}'`)}return q._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((q)=>this.alias(q)),this}usage($){if($===void 0){if(this._usage)return this._usage;let q=this.registeredArguments.map((J)=>{return
|
|
24
|
+
`),this.outputHelp({error:!0});let J=q||{},X=J.exitCode||1,Z=J.code||"commander.error";this._exit(X,Z,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in k.env){let q=$.attributeName();if(this.getOptionValue(q)===void 0||["default","config","env"].includes(this.getOptionValueSource(q)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,k.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new gX(this.options),q=(J)=>{return this.getOptionValue(J)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(J))};this.options.filter((J)=>J.implied!==void 0&&q(J.attributeName())&&$.valueFromOption(this.getOptionValue(J.attributeName()),J)).forEach((J)=>{Object.keys(J.implied).filter((X)=>!q(X)).forEach((X)=>{this.setOptionValueWithSource(X,J.implied[X],"implied")})})}missingArgument($){let q=`error: missing required argument '${$}'`;this.error(q,{code:"commander.missingArgument"})}optionMissingArgument($){let q=`error: option '${$.flags}' argument missing`;this.error(q,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let q=`error: required option '${$.flags}' not specified`;this.error(q,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,q){let J=(H)=>{let Q=H.attributeName(),Y=this.getOptionValue(Q),G=this.options.find((U)=>U.negate&&Q===U.attributeName()),K=this.options.find((U)=>!U.negate&&Q===U.attributeName());if(G&&(G.presetArg===void 0&&Y===!1||G.presetArg!==void 0&&Y===G.presetArg))return G;return K||H},X=(H)=>{let Q=J(H),Y=Q.attributeName();if(this.getOptionValueSource(Y)==="env")return`environment variable '${Q.envVar}'`;return`option '${Q.flags}'`},Z=`error: ${X($)} cannot be used with ${X(q)}`;this.error(Z,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let q="";if($.startsWith("--")&&this._showSuggestionAfterError){let X=[],Z=this;do{let H=Z.createHelp().visibleOptions(Z).filter((Q)=>Q.long).map((Q)=>Q.long);X=X.concat(H),Z=Z.parent}while(Z&&!Z._enablePositionalOptions);q=P3($,X)}let J=`error: unknown option '${$}'${q}`;this.error(J,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let q=this.registeredArguments.length,J=q===1?"":"s",Z=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${q} argument${J} but got ${$.length}.`;this.error(Z,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],q="";if(this._showSuggestionAfterError){let X=[];this.createHelp().visibleCommands(this).forEach((Z)=>{if(X.push(Z.name()),Z.alias())X.push(Z.alias())}),q=P3($,X)}let J=`error: unknown command '${$}'${q}`;this.error(J,{code:"commander.unknownCommand"})}version($,q,J){if($===void 0)return this._version;this._version=$,q=q||"-V, --version",J=J||"output the version number";let X=this.createOption(q,J);return this._versionOptionName=X.attributeName(),this._registerOption(X),this.on("option:"+X.name(),()=>{this._outputConfiguration.writeOut(`${$}
|
|
25
|
+
`),this._exit(0,"commander.version",$)}),this}description($,q){if($===void 0&&q===void 0)return this._description;if(this._description=$,q)this._argsDescription=q;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let q=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)q=this.commands[this.commands.length-1];if($===q._name)throw Error("Command alias can't be the same as its name");let J=this.parent?._findCommand($);if(J){let X=[J.name()].concat(J.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${X}'`)}return q._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((q)=>this.alias(q)),this}usage($){if($===void 0){if(this._usage)return this._usage;let q=this.registeredArguments.map((J)=>{return fX(J)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?q:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}helpGroup($){if($===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=$,this}commandsGroup($){if($===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=$,this}optionsGroup($){if($===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=$,this}_initOptionGroup($){if(this._defaultOptionGroup&&!$.helpGroupHeading)$.helpGroup(this._defaultOptionGroup)}_initCommandGroup($){if(this._defaultCommandGroup&&!$.helpGroup())$.helpGroup(this._defaultCommandGroup)}nameFromFilename($){return this._name=Q1.basename($,Q1.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let q=this.createHelp(),J=this._getOutputContext($);q.prepareContext({error:J.error,helpWidth:J.helpWidth,outputHasColors:J.hasColors});let X=q.formatHelp(this,q);if(J.hasColors)return X;return this._outputConfiguration.stripColor(X)}_getOutputContext($){$=$||{};let q=!!$.error,J,X,Z;if(q)J=(Q)=>this._outputConfiguration.writeErr(Q),X=this._outputConfiguration.getErrHasColors(),Z=this._outputConfiguration.getErrHelpWidth();else J=(Q)=>this._outputConfiguration.writeOut(Q),X=this._outputConfiguration.getOutHasColors(),Z=this._outputConfiguration.getOutHelpWidth();return{error:q,write:(Q)=>{if(!X)Q=this._outputConfiguration.stripColor(Q);return J(Q)},hasColors:X,helpWidth:Z}}outputHelp($){let q;if(typeof $==="function")q=$,$=void 0;let J=this._getOutputContext($),X={error:J.error,write:J.write,command:this};this._getCommandAndAncestors().reverse().forEach((H)=>H.emit("beforeAllHelp",X)),this.emit("beforeHelp",X);let Z=this.helpInformation({error:J.error});if(q){if(Z=q(Z),typeof Z!=="string"&&!Buffer.isBuffer(Z))throw Error("outputHelp callback must return a string or a Buffer")}if(J.write(Z),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",X),this._getCommandAndAncestors().forEach((H)=>H.emit("afterAllHelp",X))}helpOption($,q){if(typeof $==="boolean"){if($){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption($??"-h, --help",q??"display help for command"),$||q)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this._initOptionGroup($),this}help($){this.outputHelp($);let q=Number(k.exitCode??0);if(q===0&&$&&typeof $!=="function"&&$.error)q=1;this._exit(q,"commander.help","(outputHelp)")}addHelpText($,q){let J=["beforeAll","before","after","afterAll"];if(!J.includes($))throw Error(`Unexpected value for position to addHelpText.
|
|
26
26
|
Expecting one of '${J.join("', '")}'`);let X=`${$}Help`;return this.on(X,(Z)=>{let H;if(typeof q==="function")H=q({error:Z.error,command:Z.command});else H=q;if(H)Z.write(`${H}
|
|
27
|
-
`)}),this}_outputHelpIfRequested($){let q=this._getHelpOption();if(q&&$.find((X)=>q.is(X)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function L3($){return $.map((q)=>{if(!q.startsWith("--inspect"))return q;let J,X="127.0.0.1",Z="9229",H;if((H=q.match(/^(--inspect(-brk)?)$/))!==null)J=H[1];else if((H=q.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(J=H[1],/^\d+$/.test(H[3]))Z=H[3];else X=H[3];else if((H=q.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)J=H[1],X=H[3],Z=H[4];if(J&&Z!=="0")return`${J}=${X}:${parseInt(Z)+1}`;return q})}function r$(){if(k.env.NO_COLOR||k.env.FORCE_COLOR==="0"||k.env.FORCE_COLOR==="false")return!1;if(k.env.FORCE_COLOR||k.env.CLICOLOR_FORCE!==void 0)return!0;return}AX.Command=s$;AX.useColor=r$});var T3=A((DX)=>{var{Argument:V3}=_0(),{Command:e$}=_3(),{CommanderError:OX,InvalidArgumentError:R3}=n1(),{Help:NX}=n$(),{Option:W3}=a$();DX.program=new e$;DX.createCommand=($)=>new e$($);DX.createOption=($,q)=>new W3($,q);DX.createArgument=($,q)=>new V3($,q);DX.Command=e$;DX.Option=W3;DX.Argument=V3;DX.Help=NX;DX.CommanderError=OX;DX.InvalidArgumentError=R3;DX.InvalidOptionArgumentError=R3});var Y6=A((aL,H6)=>{H6.exports=Q6;Q6.sync=dZ;var X6=c("fs");function lZ($,q){var J=q.pathExt!==void 0?q.pathExt:process.env.PATHEXT;if(!J)return!0;if(J=J.split(";"),J.indexOf("")!==-1)return!0;for(var X=0;X<J.length;X++){var Z=J[X].toLowerCase();if(Z&&$.substr(-Z.length).toLowerCase()===Z)return!0}return!1}function Z6($,q,J){if(!$.isSymbolicLink()&&!$.isFile())return!1;return lZ(q,J)}function Q6($,q,J){X6.stat($,function(X,Z){J(X,X?!1:Z6(Z,$,q))})}function dZ($,q){return Z6(X6.statSync($),$,q)}});var B6=A((tL,z6)=>{z6.exports=K6;K6.sync=iZ;var G6=c("fs");function K6($,q,J){G6.stat($,function(X,Z){J(X,X?!1:U6(Z,q))})}function iZ($,q){return U6(G6.statSync($),q)}function U6($,q){return $.isFile()&&nZ($,q)}function nZ($,q){var{mode:J,uid:X,gid:Z}=$,H=q.uid!==void 0?q.uid:process.getuid&&process.getuid(),Q=q.gid!==void 0?q.gid:process.getgid&&process.getgid(),Y=parseInt("100",8),G=parseInt("010",8),K=parseInt("001",8),U=Y|G,z=J&K||J&G&&Z===Q||J&Y&&X===H||J&U&&H===0;return z}});var _6=A((rL,L6)=>{var oL=c("fs"),E0;if(process.platform==="win32"||global.TESTING_WINDOWS)E0=Y6();else E0=B6();L6.exports=B2;B2.sync=aZ;function B2($,q,J){if(typeof q==="function")J=q,q={};if(!J){if(typeof Promise!=="function")throw TypeError("callback not provided");return new Promise(function(X,Z){B2($,q||{},function(H,Q){if(H)Z(H);else X(Q)})})}E0($,q||{},function(X,Z){if(X){if(X.code==="EACCES"||q&&q.ignoreErrors)X=null,Z=!1}J(X,Z)})}function aZ($,q){try{return E0.sync($,q||{})}catch(J){if(q&&q.ignoreErrors||J.code==="EACCES")return!1;else throw J}}});var F6=A((sL,k6)=>{var y1=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",V6=c("path"),tZ=y1?";":":",R6=_6(),W6=($)=>Object.assign(Error(`not found: ${$}`),{code:"ENOENT"}),T6=($,q)=>{let J=q.colon||tZ,X=$.match(/\//)||y1&&$.match(/\\/)?[""]:[...y1?[process.cwd()]:[],...(q.path||process.env.PATH||"").split(J)],Z=y1?q.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",H=y1?Z.split(J):[""];if(y1){if($.indexOf(".")!==-1&&H[0]!=="")H.unshift("")}return{pathEnv:X,pathExt:H,pathExtExe:Z}},P6=($,q,J)=>{if(typeof q==="function")J=q,q={};if(!q)q={};let{pathEnv:X,pathExt:Z,pathExtExe:H}=T6($,q),Q=[],Y=(K)=>new Promise((U,z)=>{if(K===X.length)return q.all&&Q.length?U(Q):z(W6($));let B=X[K],L=/^".*"$/.test(B)?B.slice(1,-1):B,W=V6.join(L,$),P=!L&&/^\.[\\\/]/.test($)?$.slice(0,2)+W:W;U(G(P,K,0))}),G=(K,U,z)=>new Promise((B,L)=>{if(z===Z.length)return B(Y(U+1));let W=Z[z];R6(K+W,{pathExt:H},(P,M)=>{if(!P&&M)if(q.all)Q.push(K+W);else return B(K+W);return B(G(K,U,z+1))})});return J?Y(0).then((K)=>J(null,K),J):Y(0)},oZ=($,q)=>{q=q||{};let{pathEnv:J,pathExt:X,pathExtExe:Z}=T6($,q),H=[];for(let Q=0;Q<J.length;Q++){let Y=J[Q],G=/^".*"$/.test(Y)?Y.slice(1,-1):Y,K=V6.join(G,$),U=!G&&/^\.[\\\/]/.test($)?$.slice(0,2)+K:K;for(let z=0;z<X.length;z++){let B=U+X[z];try{if(R6.sync(B,{pathExt:Z}))if(q.all)H.push(B);else return B}catch(L){}}}if(q.all&&H.length)return H;if(q.nothrow)return null;throw W6($)};k6.exports=P6;P6.sync=oZ});var j6=A((eL,L2)=>{var x6=($={})=>{let q=$.env||process.env;if(($.platform||process.platform)!=="win32")return"PATH";return Object.keys(q).reverse().find((X)=>X.toUpperCase()==="PATH")||"Path"};L2.exports=x6;L2.exports.default=x6});var w6=A(($_,I6)=>{var M6=c("path"),rZ=F6(),sZ=j6();function C6($,q){let J=$.options.env||process.env,X=process.cwd(),Z=$.options.cwd!=null,H=Z&&process.chdir!==void 0&&!process.chdir.disabled;if(H)try{process.chdir($.options.cwd)}catch(Y){}let Q;try{Q=rZ.sync($.command,{path:J[sZ({env:J})],pathExt:q?M6.delimiter:void 0})}catch(Y){}finally{if(H)process.chdir(X)}if(Q)Q=M6.resolve(Z?$.options.cwd:"",Q);return Q}function eZ($){return C6($)||C6($,!0)}I6.exports=eZ});var A6=A((JQ,V2)=>{var _2=/([()\][%!^"`<>&|;, *?])/g;function $Q($){return $=$.replace(_2,"^$1"),$}function qQ($,q){if($=`${$}`,$=$.replace(/(?=(\\+?)?)\1"/g,"$1$1\\\""),$=$.replace(/(?=(\\+?)?)\1$/,"$1$1"),$=`"${$}"`,$=$.replace(_2,"^$1"),q)$=$.replace(_2,"^$1");return $}JQ.command=$Q;JQ.argument=qQ});var y6=A((q_,E6)=>{E6.exports=/^#!(.*)/});var N6=A((J_,O6)=>{var QQ=y6();O6.exports=($="")=>{let q=$.match(QQ);if(!q)return null;let[J,X]=q[0].replace(/#! ?/,"").split(" "),Z=J.split("/").pop();if(Z==="env")return X;return X?`${Z} ${X}`:Z}});var v6=A((X_,D6)=>{var R2=c("fs"),HQ=N6();function YQ($){let J=Buffer.alloc(150),X;try{X=R2.openSync($,"r"),R2.readSync(X,J,0,150,0),R2.closeSync(X)}catch(Z){}return HQ(J.toString())}D6.exports=YQ});var b6=A((Z_,S6)=>{var GQ=c("path"),f6=w6(),h6=A6(),KQ=v6(),UQ=process.platform==="win32",zQ=/\.(?:com|exe)$/i,BQ=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function LQ($){$.file=f6($);let q=$.file&&KQ($.file);if(q)return $.args.unshift($.file),$.command=q,f6($);return $.file}function _Q($){if(!UQ)return $;let q=LQ($),J=!zQ.test(q);if($.options.forceShell||J){let X=BQ.test(q);$.command=GQ.normalize($.command),$.command=h6.command($.command),$.args=$.args.map((H)=>h6.argument(H,X));let Z=[$.command].concat($.args).join(" ");$.args=["/d","/s","/c",`"${Z}"`],$.command=process.env.comspec||"cmd.exe",$.options.windowsVerbatimArguments=!0}return $}function VQ($,q,J){if(q&&!Array.isArray(q))J=q,q=null;q=q?q.slice(0):[],J=Object.assign({},J);let X={command:$,args:q,options:J,file:void 0,original:{command:$,args:q}};return J.shell?X:_Q(X)}S6.exports=VQ});var m6=A((Q_,c6)=>{var W2=process.platform==="win32";function T2($,q){return Object.assign(Error(`${q} ${$.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${q} ${$.command}`,path:$.command,spawnargs:$.args})}function RQ($,q){if(!W2)return;let J=$.emit;$.emit=function(X,Z){if(X==="exit"){let H=g6(Z,q);if(H)return J.call($,"error",H)}return J.apply($,arguments)}}function g6($,q){if(W2&&$===1&&!q.file)return T2(q.original,"spawn");return null}function WQ($,q){if(W2&&$===1&&!q.file)return T2(q.original,"spawnSync");return null}c6.exports={hookChildProcess:RQ,verifyENOENT:g6,verifyENOENTSync:WQ,notFoundError:T2}});var l6=A((H_,O1)=>{var u6=c("child_process"),P2=b6(),k2=m6();function p6($,q,J){let X=P2($,q,J),Z=u6.spawn(X.command,X.args,X.options);return k2.hookChildProcess(Z,X),Z}function TQ($,q,J){let X=P2($,q,J),Z=u6.spawnSync(X.command,X.args,X.options);return Z.error=Z.error||k2.verifyENOENTSync(Z.status,X),Z}O1.exports=p6;O1.exports.spawn=p6;O1.exports.sync=TQ;O1.exports._parse=P2;O1.exports._enoent=k2});var f4=A((Sj,nq)=>{var v4={to($,q){if(!q)return`\x1B[${$+1}G`;return`\x1B[${q+1};${$+1}H`},move($,q){let J="";if($<0)J+=`\x1B[${-$}D`;else if($>0)J+=`\x1B[${$}C`;if(q<0)J+=`\x1B[${-q}A`;else if(q>0)J+=`\x1B[${q}B`;return J},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},wU={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},AU={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let q="";for(let J=0;J<$;J++)q+=this.line+(J<$-1?v4.up():"");if($)q+=v4.left;return q}};nq.exports={cursor:v4,scroll:wU,erase:AU,beep:"\x07"}});var C1=A((bj,h4)=>{var y$=process||{},aq=y$.argv||[],E$=y$.env||{},EU=!(!!E$.NO_COLOR||aq.includes("--no-color"))&&(!!E$.FORCE_COLOR||aq.includes("--color")||y$.platform==="win32"||(y$.stdout||{}).isTTY&&E$.TERM!=="dumb"||!!E$.CI),yU=($,q,J=$)=>(X)=>{let Z=""+X,H=Z.indexOf(q,$.length);return~H?$+OU(Z,q,J,H)+q:$+Z+q},OU=($,q,J,X)=>{let Z="",H=0;do Z+=$.substring(H,X)+J,H=X+q.length,X=$.indexOf(q,H);while(~X);return Z+$.substring(H)},tq=($=EU)=>{let q=$?yU:()=>String;return{isColorSupported:$,reset:q("\x1B[0m","\x1B[0m"),bold:q("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:q("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:q("\x1B[3m","\x1B[23m"),underline:q("\x1B[4m","\x1B[24m"),inverse:q("\x1B[7m","\x1B[27m"),hidden:q("\x1B[8m","\x1B[28m"),strikethrough:q("\x1B[9m","\x1B[29m"),black:q("\x1B[30m","\x1B[39m"),red:q("\x1B[31m","\x1B[39m"),green:q("\x1B[32m","\x1B[39m"),yellow:q("\x1B[33m","\x1B[39m"),blue:q("\x1B[34m","\x1B[39m"),magenta:q("\x1B[35m","\x1B[39m"),cyan:q("\x1B[36m","\x1B[39m"),white:q("\x1B[37m","\x1B[39m"),gray:q("\x1B[90m","\x1B[39m"),bgBlack:q("\x1B[40m","\x1B[49m"),bgRed:q("\x1B[41m","\x1B[49m"),bgGreen:q("\x1B[42m","\x1B[49m"),bgYellow:q("\x1B[43m","\x1B[49m"),bgBlue:q("\x1B[44m","\x1B[49m"),bgMagenta:q("\x1B[45m","\x1B[49m"),bgCyan:q("\x1B[46m","\x1B[49m"),bgWhite:q("\x1B[47m","\x1B[49m"),blackBright:q("\x1B[90m","\x1B[39m"),redBright:q("\x1B[91m","\x1B[39m"),greenBright:q("\x1B[92m","\x1B[39m"),yellowBright:q("\x1B[93m","\x1B[39m"),blueBright:q("\x1B[94m","\x1B[39m"),magentaBright:q("\x1B[95m","\x1B[39m"),cyanBright:q("\x1B[96m","\x1B[39m"),whiteBright:q("\x1B[97m","\x1B[39m"),bgBlackBright:q("\x1B[100m","\x1B[49m"),bgRedBright:q("\x1B[101m","\x1B[49m"),bgGreenBright:q("\x1B[102m","\x1B[49m"),bgYellowBright:q("\x1B[103m","\x1B[49m"),bgBlueBright:q("\x1B[104m","\x1B[49m"),bgMagentaBright:q("\x1B[105m","\x1B[49m"),bgCyanBright:q("\x1B[106m","\x1B[49m"),bgWhiteBright:q("\x1B[107m","\x1B[49m")}};h4.exports=tq();h4.exports.createColors=tq});var P3=t(T3(),1),{program:rz,createCommand:sz,createArgument:ez,createOption:$B,CommanderError:qB,InvalidArgumentError:JB,InvalidOptionArgumentError:XB,Command:k3,Argument:ZB,Option:QB,Help:HB}=P3.default;import{homedir as F3}from"os";import{join as x3}from"path";var j3=[{id:"esp32",name:"ESP32",description:"Original dual-core Xtensa",stable:!0},{id:"esp32s2",name:"ESP32-S2",description:"Single-core Xtensa with USB OTG",stable:!0},{id:"esp32s3",name:"ESP32-S3",description:"Dual-core Xtensa with AI acceleration",stable:!0},{id:"esp32s31",name:"ESP32-S3 (rev1)",description:"ESP32-S3 revision 1",stable:!1},{id:"esp32c2",name:"ESP32-C2",description:"Single-core RISC-V (cost-optimized)",stable:!0},{id:"esp32c3",name:"ESP32-C3",description:"Single-core RISC-V",stable:!0},{id:"esp32c5",name:"ESP32-C5",description:"RISC-V with WiFi 6",stable:!1},{id:"esp32c6",name:"ESP32-C6",description:"RISC-V with WiFi 6 & 802.15.4",stable:!0},{id:"esp32c61",name:"ESP32-C61",description:"ESP32-C6 variant",stable:!1},{id:"esp32h2",name:"ESP32-H2",description:"RISC-V with 802.15.4/Zigbee/Thread",stable:!0},{id:"esp32h21",name:"ESP32-H21",description:"ESP32-H2 variant",stable:!1},{id:"esp32h4",name:"ESP32-H4",description:"RISC-V 802.15.4",stable:!1},{id:"esp32p4",name:"ESP32-P4",description:"High-performance dual-core RISC-V",stable:!1}],$2=x3(F3(),"esp","esp-idf"),R0=x3(F3(),"esp"),M3="https://github.com/espressif/esp-idf.git",C3=460800,I3=115200,q2={"10C4":{name:"Silicon Labs",chips:{EA60:"CP210x",EA70:"CP2105"}},"1A86":{name:"QinHeng Electronics",chips:{"7523":"CH340","5523":"CH341","55D3":"CH343","55D4":"CH9102"}},"0403":{name:"FTDI",chips:{"6001":"FT232R","6010":"FT2232","6011":"FT4232","6014":"FT232H"}},"303A":{name:"Espressif",chips:{"1001":"ESP32 (USB-JTAG)","1002":"ESP32 (USB-OTG)"}}},w3={zsh:".zshrc",bash:".bashrc",fish:".config/fish/config.fish"},A3="0.0.1";class E3{handlers=new Map;globalHandlers=new Set;subscribe($,q){if(!this.handlers.has($))this.handlers.set($,new Set);return this.handlers.get($).add(q),()=>{this.handlers.get($)?.delete(q)}}subscribeAll($){return this.globalHandlers.add($),()=>{this.globalHandlers.delete($)}}emit($,q){let J={type:q.type,timestamp:Date.now(),operationId:$,data:q};this.handlers.get($)?.forEach((X)=>X(J)),this.globalHandlers.forEach((X)=>X(J))}cleanup($){this.handlers.delete($)}}var R=new E3;function j(){return`op_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function E($){if(typeof $!=="object"||$===null)return!1;let q=Object.getPrototypeOf($);return(q===null||q===Object.prototype||Object.getPrototypeOf(q)===null)&&!(Symbol.toStringTag in $)&&!(Symbol.iterator in $)}import{fileURLToPath as dX}from"node:url";var w1=($,q)=>{let J=X2(iX($));if(typeof J!=="string")throw TypeError(`${q} must be a string or a file URL: ${J}.`);return J},iX=($)=>J2($)?$.toString():$,J2=($)=>typeof $!=="string"&&$&&Object.getPrototypeOf($)===String.prototype,X2=($)=>$ instanceof URL?dX($):$;var W0=($,q=[],J={})=>{let X=w1($,"First argument"),[Z,H]=E(q)?[[],q]:[q,J];if(!Array.isArray(Z))throw TypeError(`Second argument must be either an array of arguments or an options object: ${Z}`);if(Z.some((G)=>typeof G==="object"&&G!==null))throw TypeError(`Second argument must be an array of strings: ${Z}`);let Q=Z.map(String),Y=Q.find((G)=>G.includes("\x00"));if(Y!==void 0)throw TypeError(`Arguments cannot contain null bytes ("\\0"): ${Y}`);if(!E(H))throw TypeError(`Last argument must be an options object: ${H}`);return[X,Q,H]};import{ChildProcess as eX}from"node:child_process";import{StringDecoder as nX}from"node:string_decoder";var{toString:y3}=Object.prototype,O3=($)=>y3.call($)==="[object ArrayBuffer]",D=($)=>y3.call($)==="[object Uint8Array]",Z1=($)=>new Uint8Array($.buffer,$.byteOffset,$.byteLength),aX=new TextEncoder,N3=($)=>aX.encode($),tX=new TextDecoder,T0=($)=>tX.decode($),D3=($,q)=>{return oX($,q).join("")},oX=($,q)=>{if(q==="utf8"&&$.every((H)=>typeof H==="string"))return $;let J=new nX(q),X=$.map((H)=>typeof H==="string"?N3(H):H).map((H)=>J.write(H)),Z=J.end();return Z===""?X:[...X,Z]},a1=($)=>{if($.length===1&&D($[0]))return $[0];return Z2(rX($))},rX=($)=>$.map((q)=>typeof q==="string"?N3(q):q),Z2=($)=>{let q=new Uint8Array(sX($)),J=0;for(let X of $)q.set(X,J),J+=X.length;return q},sX=($)=>{let q=0;for(let J of $)q+=J.length;return q};var S3=($)=>Array.isArray($)&&Array.isArray($.raw),b3=($,q)=>{let J=[];for(let[H,Q]of $.entries())J=$Z({templates:$,expressions:q,tokens:J,index:H,template:Q});if(J.length===0)throw TypeError("Template script must not be empty");let[X,...Z]=J;return[X,Z,{}]},$Z=({templates:$,expressions:q,tokens:J,index:X,template:Z})=>{if(Z===void 0)throw TypeError(`Invalid backslash sequence: ${$.raw[X]}`);let{nextTokens:H,leadingWhitespaces:Q,trailingWhitespaces:Y}=qZ(Z,$.raw[X]),G=f3(J,H,Q);if(X===q.length)return G;let K=q[X],U=Array.isArray(K)?K.map((z)=>h3(z)):[h3(K)];return f3(G,U,Y)},qZ=($,q)=>{if(q.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let J=[],X=0,Z=v3.has(q[0]);for(let Q=0,Y=0;Q<$.length;Q+=1,Y+=1){let G=q[Y];if(v3.has(G)){if(X!==Q)J.push($.slice(X,Q));X=Q+1}else if(G==="\\"){let K=q[Y+1];if(K===`
|
|
28
|
-
`)Q-=1,Y+=1;else if(K==="u"&&q[Y+2]==="{")Y=q.indexOf("}",Y+3);else Y+=
|
|
29
|
-
`]),
|
|
27
|
+
`)}),this}_outputHelpIfRequested($){let q=this._getHelpOption();if(q&&$.find((X)=>q.is(X)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function k3($){return $.map((q)=>{if(!q.startsWith("--inspect"))return q;let J,X="127.0.0.1",Z="9229",H;if((H=q.match(/^(--inspect(-brk)?)$/))!==null)J=H[1];else if((H=q.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(J=H[1],/^\d+$/.test(H[3]))Z=H[3];else X=H[3];else if((H=q.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)J=H[1],X=H[3],Z=H[4];if(J&&Z!=="0")return`${J}=${X}:${parseInt(Z)+1}`;return q})}function Y2(){if(k.env.NO_COLOR||k.env.FORCE_COLOR==="0"||k.env.FORCE_COLOR==="false")return!1;if(k.env.FORCE_COLOR||k.env.CLICOLOR_FORCE!==void 0)return!0;return}cX.Command=G2;cX.useColor=Y2});var C3=A((dX)=>{var{Argument:x3}=k0(),{Command:K2}=F3(),{CommanderError:pX,InvalidArgumentError:j3}=e1(),{Help:lX}=X2(),{Option:M3}=Z2();dX.program=new K2;dX.createCommand=($)=>new K2($);dX.createOption=($,q)=>new M3($,q);dX.createArgument=($,q)=>new x3($,q);dX.Command=K2;dX.Option=M3;dX.Argument=x3;dX.Help=lX;dX.CommanderError=pX;dX.InvalidArgumentError=j3;dX.InvalidOptionArgumentError=j3});var V6=A((BV,L6)=>{L6.exports=B6;B6.sync=XQ;var U6=m("fs");function JQ($,q){var J=q.pathExt!==void 0?q.pathExt:process.env.PATHEXT;if(!J)return!0;if(J=J.split(";"),J.indexOf("")!==-1)return!0;for(var X=0;X<J.length;X++){var Z=J[X].toLowerCase();if(Z&&$.substr(-Z.length).toLowerCase()===Z)return!0}return!1}function z6($,q,J){if(!$.isSymbolicLink()&&!$.isFile())return!1;return JQ(q,J)}function B6($,q,J){U6.stat($,function(X,Z){J(X,X?!1:z6(Z,$,q))})}function XQ($,q){return z6(U6.statSync($),$,q)}});var P6=A((LV,T6)=>{T6.exports=_6;_6.sync=ZQ;var W6=m("fs");function _6($,q,J){W6.stat($,function(X,Z){J(X,X?!1:R6(Z,q))})}function ZQ($,q){return R6(W6.statSync($),q)}function R6($,q){return $.isFile()&&QQ($,q)}function QQ($,q){var{mode:J,uid:X,gid:Z}=$,H=q.uid!==void 0?q.uid:process.getuid&&process.getuid(),Q=q.gid!==void 0?q.gid:process.getgid&&process.getgid(),Y=parseInt("100",8),G=parseInt("010",8),K=parseInt("001",8),U=Y|G,z=J&K||J&G&&Z===Q||J&Y&&X===H||J&U&&H===0;return z}});var F6=A((WV,k6)=>{var VV=m("fs"),h0;if(process.platform==="win32"||global.TESTING_WINDOWS)h0=V6();else h0=P6();k6.exports=x2;x2.sync=HQ;function x2($,q,J){if(typeof q==="function")J=q,q={};if(!J){if(typeof Promise!=="function")throw TypeError("callback not provided");return new Promise(function(X,Z){x2($,q||{},function(H,Q){if(H)Z(H);else X(Q)})})}h0($,q||{},function(X,Z){if(X){if(X.code==="EACCES"||q&&q.ignoreErrors)X=null,Z=!1}J(X,Z)})}function HQ($,q){try{return h0.sync($,q||{})}catch(J){if(q&&q.ignoreErrors||J.code==="EACCES")return!1;else throw J}}});var A6=A((_V,I6)=>{var f1=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",x6=m("path"),YQ=f1?";":":",j6=F6(),M6=($)=>Object.assign(Error(`not found: ${$}`),{code:"ENOENT"}),C6=($,q)=>{let J=q.colon||YQ,X=$.match(/\//)||f1&&$.match(/\\/)?[""]:[...f1?[process.cwd()]:[],...(q.path||process.env.PATH||"").split(J)],Z=f1?q.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",H=f1?Z.split(J):[""];if(f1){if($.indexOf(".")!==-1&&H[0]!=="")H.unshift("")}return{pathEnv:X,pathExt:H,pathExtExe:Z}},w6=($,q,J)=>{if(typeof q==="function")J=q,q={};if(!q)q={};let{pathEnv:X,pathExt:Z,pathExtExe:H}=C6($,q),Q=[],Y=(K)=>new Promise((U,z)=>{if(K===X.length)return q.all&&Q.length?U(Q):z(M6($));let B=X[K],L=/^".*"$/.test(B)?B.slice(1,-1):B,_=x6.join(L,$),P=!L&&/^\.[\\\/]/.test($)?$.slice(0,2)+_:_;U(G(P,K,0))}),G=(K,U,z)=>new Promise((B,L)=>{if(z===Z.length)return B(Y(U+1));let _=Z[z];j6(K+_,{pathExt:H},(P,M)=>{if(!P&&M)if(q.all)Q.push(K+_);else return B(K+_);return B(G(K,U,z+1))})});return J?Y(0).then((K)=>J(null,K),J):Y(0)},GQ=($,q)=>{q=q||{};let{pathEnv:J,pathExt:X,pathExtExe:Z}=C6($,q),H=[];for(let Q=0;Q<J.length;Q++){let Y=J[Q],G=/^".*"$/.test(Y)?Y.slice(1,-1):Y,K=x6.join(G,$),U=!G&&/^\.[\\\/]/.test($)?$.slice(0,2)+K:K;for(let z=0;z<X.length;z++){let B=U+X[z];try{if(j6.sync(B,{pathExt:Z}))if(q.all)H.push(B);else return B}catch(L){}}}if(q.all&&H.length)return H;if(q.nothrow)return null;throw M6($)};I6.exports=w6;w6.sync=GQ});var y6=A((RV,j2)=>{var E6=($={})=>{let q=$.env||process.env;if(($.platform||process.platform)!=="win32")return"PATH";return Object.keys(q).reverse().find((X)=>X.toUpperCase()==="PATH")||"Path"};j2.exports=E6;j2.exports.default=E6});var v6=A((TV,D6)=>{var O6=m("path"),KQ=A6(),UQ=y6();function N6($,q){let J=$.options.env||process.env,X=process.cwd(),Z=$.options.cwd!=null,H=Z&&process.chdir!==void 0&&!process.chdir.disabled;if(H)try{process.chdir($.options.cwd)}catch(Y){}let Q;try{Q=KQ.sync($.command,{path:J[UQ({env:J})],pathExt:q?O6.delimiter:void 0})}catch(Y){}finally{if(H)process.chdir(X)}if(Q)Q=O6.resolve(Z?$.options.cwd:"",Q);return Q}function zQ($){return N6($)||N6($,!0)}D6.exports=zQ});var h6=A((VQ,C2)=>{var M2=/([()\][%!^"`<>&|;, *?])/g;function BQ($){return $=$.replace(M2,"^$1"),$}function LQ($,q){if($=`${$}`,$=$.replace(/(?=(\\+?)?)\1"/g,"$1$1\\\""),$=$.replace(/(?=(\\+?)?)\1$/,"$1$1"),$=`"${$}"`,$=$.replace(M2,"^$1"),q)$=$.replace(M2,"^$1");return $}VQ.command=BQ;VQ.argument=LQ});var S6=A((PV,f6)=>{f6.exports=/^#!(.*)/});var g6=A((kV,b6)=>{var RQ=S6();b6.exports=($="")=>{let q=$.match(RQ);if(!q)return null;let[J,X]=q[0].replace(/#! ?/,"").split(" "),Z=J.split("/").pop();if(Z==="env")return X;return X?`${Z} ${X}`:Z}});var m6=A((FV,c6)=>{var w2=m("fs"),TQ=g6();function PQ($){let J=Buffer.alloc(150),X;try{X=w2.openSync($,"r"),w2.readSync(X,J,0,150,0),w2.closeSync(X)}catch(Z){}return TQ(J.toString())}c6.exports=PQ});var d6=A((xV,l6)=>{var kQ=m("path"),u6=v6(),p6=h6(),FQ=m6(),xQ=process.platform==="win32",jQ=/\.(?:com|exe)$/i,MQ=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function CQ($){$.file=u6($);let q=$.file&&FQ($.file);if(q)return $.args.unshift($.file),$.command=q,u6($);return $.file}function wQ($){if(!xQ)return $;let q=CQ($),J=!jQ.test(q);if($.options.forceShell||J){let X=MQ.test(q);$.command=kQ.normalize($.command),$.command=p6.command($.command),$.args=$.args.map((H)=>p6.argument(H,X));let Z=[$.command].concat($.args).join(" ");$.args=["/d","/s","/c",`"${Z}"`],$.command=process.env.comspec||"cmd.exe",$.options.windowsVerbatimArguments=!0}return $}function IQ($,q,J){if(q&&!Array.isArray(q))J=q,q=null;q=q?q.slice(0):[],J=Object.assign({},J);let X={command:$,args:q,options:J,file:void 0,original:{command:$,args:q}};return J.shell?X:wQ(X)}l6.exports=IQ});var a6=A((jV,n6)=>{var I2=process.platform==="win32";function A2($,q){return Object.assign(Error(`${q} ${$.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${q} ${$.command}`,path:$.command,spawnargs:$.args})}function AQ($,q){if(!I2)return;let J=$.emit;$.emit=function(X,Z){if(X==="exit"){let H=i6(Z,q);if(H)return J.call($,"error",H)}return J.apply($,arguments)}}function i6($,q){if(I2&&$===1&&!q.file)return A2(q.original,"spawn");return null}function EQ($,q){if(I2&&$===1&&!q.file)return A2(q.original,"spawnSync");return null}n6.exports={hookChildProcess:AQ,verifyENOENT:i6,verifyENOENTSync:EQ,notFoundError:A2}});var r6=A((MV,S1)=>{var t6=m("child_process"),E2=d6(),y2=a6();function o6($,q,J){let X=E2($,q,J),Z=t6.spawn(X.command,X.args,X.options);return y2.hookChildProcess(Z,X),Z}function yQ($,q,J){let X=E2($,q,J),Z=t6.spawnSync(X.command,X.args,X.options);return Z.error=Z.error||y2.verifyENOENTSync(Z.status,X),Z}S1.exports=o6;S1.exports.spawn=o6;S1.exports.sync=yQ;S1.exports._parse=E2;S1.exports._enoent=y2});var l4=A((qM,$J)=>{var p4={to($,q){if(!q)return`\x1B[${$+1}G`;return`\x1B[${q+1};${$+1}H`},move($,q){let J="";if($<0)J+=`\x1B[${-$}D`;else if($>0)J+=`\x1B[${$}C`;if(q<0)J+=`\x1B[${-q}A`;else if(q>0)J+=`\x1B[${q}B`;return J},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},gU={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},cU={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let q="";for(let J=0;J<$;J++)q+=this.line+(J<$-1?p4.up():"");if($)q+=p4.left;return q}};$J.exports={cursor:p4,scroll:gU,erase:cU,beep:"\x07"}});var A1=A((JM,d4)=>{var S$=process||{},qJ=S$.argv||[],f$=S$.env||{},mU=!(!!f$.NO_COLOR||qJ.includes("--no-color"))&&(!!f$.FORCE_COLOR||qJ.includes("--color")||S$.platform==="win32"||(S$.stdout||{}).isTTY&&f$.TERM!=="dumb"||!!f$.CI),uU=($,q,J=$)=>(X)=>{let Z=""+X,H=Z.indexOf(q,$.length);return~H?$+pU(Z,q,J,H)+q:$+Z+q},pU=($,q,J,X)=>{let Z="",H=0;do Z+=$.substring(H,X)+J,H=X+q.length,X=$.indexOf(q,H);while(~X);return Z+$.substring(H)},JJ=($=mU)=>{let q=$?uU:()=>String;return{isColorSupported:$,reset:q("\x1B[0m","\x1B[0m"),bold:q("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:q("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:q("\x1B[3m","\x1B[23m"),underline:q("\x1B[4m","\x1B[24m"),inverse:q("\x1B[7m","\x1B[27m"),hidden:q("\x1B[8m","\x1B[28m"),strikethrough:q("\x1B[9m","\x1B[29m"),black:q("\x1B[30m","\x1B[39m"),red:q("\x1B[31m","\x1B[39m"),green:q("\x1B[32m","\x1B[39m"),yellow:q("\x1B[33m","\x1B[39m"),blue:q("\x1B[34m","\x1B[39m"),magenta:q("\x1B[35m","\x1B[39m"),cyan:q("\x1B[36m","\x1B[39m"),white:q("\x1B[37m","\x1B[39m"),gray:q("\x1B[90m","\x1B[39m"),bgBlack:q("\x1B[40m","\x1B[49m"),bgRed:q("\x1B[41m","\x1B[49m"),bgGreen:q("\x1B[42m","\x1B[49m"),bgYellow:q("\x1B[43m","\x1B[49m"),bgBlue:q("\x1B[44m","\x1B[49m"),bgMagenta:q("\x1B[45m","\x1B[49m"),bgCyan:q("\x1B[46m","\x1B[49m"),bgWhite:q("\x1B[47m","\x1B[49m"),blackBright:q("\x1B[90m","\x1B[39m"),redBright:q("\x1B[91m","\x1B[39m"),greenBright:q("\x1B[92m","\x1B[39m"),yellowBright:q("\x1B[93m","\x1B[39m"),blueBright:q("\x1B[94m","\x1B[39m"),magentaBright:q("\x1B[95m","\x1B[39m"),cyanBright:q("\x1B[96m","\x1B[39m"),whiteBright:q("\x1B[97m","\x1B[39m"),bgBlackBright:q("\x1B[100m","\x1B[49m"),bgRedBright:q("\x1B[101m","\x1B[49m"),bgGreenBright:q("\x1B[102m","\x1B[49m"),bgYellowBright:q("\x1B[103m","\x1B[49m"),bgBlueBright:q("\x1B[104m","\x1B[49m"),bgMagentaBright:q("\x1B[105m","\x1B[49m"),bgCyanBright:q("\x1B[106m","\x1B[49m"),bgWhiteBright:q("\x1B[107m","\x1B[49m")}};d4.exports=JJ();d4.exports.createColors=JJ});var w3=o(C3(),1),{program:WB,createCommand:_B,createArgument:RB,createOption:TB,CommanderError:PB,InvalidArgumentError:kB,InvalidOptionArgumentError:FB,Command:I3,Argument:xB,Option:jB,Help:MB}=w3.default;import{homedir as A3}from"os";import{join as E3}from"path";var y3=[{id:"esp32",name:"ESP32",description:"Original dual-core Xtensa",stable:!0},{id:"esp32s2",name:"ESP32-S2",description:"Single-core Xtensa with USB OTG",stable:!0},{id:"esp32s3",name:"ESP32-S3",description:"Dual-core Xtensa with AI acceleration",stable:!0},{id:"esp32s31",name:"ESP32-S3 (rev1)",description:"ESP32-S3 revision 1",stable:!1},{id:"esp32c2",name:"ESP32-C2",description:"Single-core RISC-V (cost-optimized)",stable:!0},{id:"esp32c3",name:"ESP32-C3",description:"Single-core RISC-V",stable:!0},{id:"esp32c5",name:"ESP32-C5",description:"RISC-V with WiFi 6",stable:!1},{id:"esp32c6",name:"ESP32-C6",description:"RISC-V with WiFi 6 & 802.15.4",stable:!0},{id:"esp32c61",name:"ESP32-C61",description:"ESP32-C6 variant",stable:!1},{id:"esp32h2",name:"ESP32-H2",description:"RISC-V with 802.15.4/Zigbee/Thread",stable:!0},{id:"esp32h21",name:"ESP32-H21",description:"ESP32-H2 variant",stable:!1},{id:"esp32h4",name:"ESP32-H4",description:"RISC-V 802.15.4",stable:!1},{id:"esp32p4",name:"ESP32-P4",description:"High-performance dual-core RISC-V",stable:!1}],U2=E3(A3(),"esp","esp-idf"),x0=E3(A3(),"esp"),O3="https://github.com/espressif/esp-idf.git",O1=460800,N1=115200,N3=[{value:115200,label:"115200",hint:"Slow but reliable"},{value:230400,label:"230400",hint:"Balanced"},{value:460800,label:"460800",hint:"Default - fast and stable"},{value:921600,label:"921600",hint:"Very fast (may be unstable)"},{value:1500000,label:"1500000",hint:"Maximum (native USB only)"}],D3=[{value:74880,label:"74880",hint:"ESP8266 boot messages"},{value:115200,label:"115200",hint:"Default - standard rate"},{value:230400,label:"230400",hint:"High speed logging"},{value:921600,label:"921600",hint:"Very high speed"}],z2={"10C4":{name:"Silicon Labs",chips:{EA60:"CP210x",EA70:"CP2105"}},"1A86":{name:"QinHeng Electronics",chips:{"7523":"CH340","5523":"CH341","55D3":"CH343","55D4":"CH9102"}},"0403":{name:"FTDI",chips:{"6001":"FT232R","6010":"FT2232","6011":"FT4232","6014":"FT232H"}},"303A":{name:"Espressif",chips:{"1001":"ESP32 (USB-JTAG)","1002":"ESP32 (USB-OTG)"}}},v3={zsh:".zshrc",bash:".bashrc",fish:".config/fish/config.fish"},h3="0.0.1";class f3{handlers=new Map;globalHandlers=new Set;subscribe($,q){if(!this.handlers.has($))this.handlers.set($,new Set);return this.handlers.get($).add(q),()=>{this.handlers.get($)?.delete(q)}}subscribeAll($){return this.globalHandlers.add($),()=>{this.globalHandlers.delete($)}}emit($,q){let J={type:q.type,timestamp:Date.now(),operationId:$,data:q};this.handlers.get($)?.forEach((X)=>X(J)),this.globalHandlers.forEach((X)=>X(J))}cleanup($){this.handlers.delete($)}}var R=new f3;function j(){return`op_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function E($){if(typeof $!=="object"||$===null)return!1;let q=Object.getPrototypeOf($);return(q===null||q===Object.prototype||Object.getPrototypeOf(q)===null)&&!(Symbol.toStringTag in $)&&!(Symbol.iterator in $)}import{fileURLToPath as XZ}from"node:url";var D1=($,q)=>{let J=L2(ZZ($));if(typeof J!=="string")throw TypeError(`${q} must be a string or a file URL: ${J}.`);return J},ZZ=($)=>B2($)?$.toString():$,B2=($)=>typeof $!=="string"&&$&&Object.getPrototypeOf($)===String.prototype,L2=($)=>$ instanceof URL?XZ($):$;var j0=($,q=[],J={})=>{let X=D1($,"First argument"),[Z,H]=E(q)?[[],q]:[q,J];if(!Array.isArray(Z))throw TypeError(`Second argument must be either an array of arguments or an options object: ${Z}`);if(Z.some((G)=>typeof G==="object"&&G!==null))throw TypeError(`Second argument must be an array of strings: ${Z}`);let Q=Z.map(String),Y=Q.find((G)=>G.includes("\x00"));if(Y!==void 0)throw TypeError(`Arguments cannot contain null bytes ("\\0"): ${Y}`);if(!E(H))throw TypeError(`Last argument must be an options object: ${H}`);return[X,Q,H]};import{ChildProcess as zZ}from"node:child_process";import{StringDecoder as QZ}from"node:string_decoder";var{toString:S3}=Object.prototype,b3=($)=>S3.call($)==="[object ArrayBuffer]",D=($)=>S3.call($)==="[object Uint8Array]",H1=($)=>new Uint8Array($.buffer,$.byteOffset,$.byteLength),HZ=new TextEncoder,g3=($)=>HZ.encode($),YZ=new TextDecoder,M0=($)=>YZ.decode($),c3=($,q)=>{return GZ($,q).join("")},GZ=($,q)=>{if(q==="utf8"&&$.every((H)=>typeof H==="string"))return $;let J=new QZ(q),X=$.map((H)=>typeof H==="string"?g3(H):H).map((H)=>J.write(H)),Z=J.end();return Z===""?X:[...X,Z]},$0=($)=>{if($.length===1&&D($[0]))return $[0];return V2(KZ($))},KZ=($)=>$.map((q)=>typeof q==="string"?g3(q):q),V2=($)=>{let q=new Uint8Array(UZ($)),J=0;for(let X of $)q.set(X,J),J+=X.length;return q},UZ=($)=>{let q=0;for(let J of $)q+=J.length;return q};var l3=($)=>Array.isArray($)&&Array.isArray($.raw),d3=($,q)=>{let J=[];for(let[H,Q]of $.entries())J=BZ({templates:$,expressions:q,tokens:J,index:H,template:Q});if(J.length===0)throw TypeError("Template script must not be empty");let[X,...Z]=J;return[X,Z,{}]},BZ=({templates:$,expressions:q,tokens:J,index:X,template:Z})=>{if(Z===void 0)throw TypeError(`Invalid backslash sequence: ${$.raw[X]}`);let{nextTokens:H,leadingWhitespaces:Q,trailingWhitespaces:Y}=LZ(Z,$.raw[X]),G=u3(J,H,Q);if(X===q.length)return G;let K=q[X],U=Array.isArray(K)?K.map((z)=>p3(z)):[p3(K)];return u3(G,U,Y)},LZ=($,q)=>{if(q.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let J=[],X=0,Z=m3.has(q[0]);for(let Q=0,Y=0;Q<$.length;Q+=1,Y+=1){let G=q[Y];if(m3.has(G)){if(X!==Q)J.push($.slice(X,Q));X=Q+1}else if(G==="\\"){let K=q[Y+1];if(K===`
|
|
28
|
+
`)Q-=1,Y+=1;else if(K==="u"&&q[Y+2]==="{")Y=q.indexOf("}",Y+3);else Y+=VZ[K]??1}}let H=X===$.length;if(!H)J.push($.slice(X));return{nextTokens:J,leadingWhitespaces:Z,trailingWhitespaces:H}},m3=new Set([" ","\t","\r",`
|
|
29
|
+
`]),VZ={x:3,u:5},u3=($,q,J)=>J||$.length===0||q.length===0?[...$,...q]:[...$.slice(0,-1),`${$.at(-1)}${q[0]}`,...q.slice(1)],p3=($)=>{let q=typeof $;if(q==="string")return $;if(q==="number")return String($);if(E($)&&(("stdout"in $)||("isMaxBuffer"in $)))return WZ($);if($ instanceof zZ||Object.prototype.toString.call($)==="[object Promise]")throw TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}.");throw TypeError(`Unexpected "${q}" in template expression`)},WZ=({stdout:$})=>{if(typeof $==="string")return $;if(D($))return M0($);if($===void 0)throw TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`);throw TypeError(`Unexpected "${typeof $}" stdout in template expression`)};import{spawnSync as xG}from"node:child_process";import{debuglog as _Z}from"node:util";import W2 from"node:process";var i=($)=>C0.includes($),C0=[W2.stdin,W2.stdout,W2.stderr],l=["stdin","stdout","stderr"],w0=($)=>l[$]??`stdio[${$}]`;var n3=($)=>{let q={...$};for(let J of T2)q[J]=_2($,J);return q},_2=($,q)=>{let J=Array.from({length:RZ($)+1}),X=TZ($[q],J,q);return jZ(X,q)},RZ=({stdio:$})=>Array.isArray($)?Math.max($.length,l.length):l.length,TZ=($,q,J)=>E($)?PZ($,q,J):q.fill($),PZ=($,q,J)=>{for(let X of Object.keys($).sort(kZ))for(let Z of FZ(X,J,q))q[Z]=$[X];return q},kZ=($,q)=>i3($)<i3(q)?1:-1,i3=($)=>{if($==="stdout"||$==="stderr")return 0;return $==="all"?2:1},FZ=($,q,J)=>{if($==="ipc")return[J.length-1];let X=R2($);if(X===void 0||X===0)throw TypeError(`"${q}.${$}" is invalid.
|
|
30
30
|
It must be "${q}.stdout", "${q}.stderr", "${q}.all", "${q}.ipc", or "${q}.fd3", "${q}.fd4" (and so on).`);if(X>=J.length)throw TypeError(`"${q}.${$}" is invalid: that file descriptor does not exist.
|
|
31
|
-
Please set the "stdio" option to ensure that file descriptor exists.`);return X==="all"?[1,2]:[X]},
|
|
32
|
-
`).map((q)=>
|
|
33
|
-
`),
|
|
31
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);return X==="all"?[1,2]:[X]},R2=($)=>{if($==="all")return $;if(l.includes($))return l.indexOf($);let q=xZ.exec($);if(q!==null)return Number(q[1])},xZ=/^fd(\d+)$/,jZ=($,q)=>$.map((J)=>J===void 0?CZ[q]:J),MZ=_Z("execa").enabled?"full":"none",CZ={lines:!1,buffer:!0,maxBuffer:1e8,verbose:MZ,stripFinalNewline:!0},T2=["lines","buffer","maxBuffer","verbose","stripFinalNewline"],Y1=($,q)=>q==="ipc"?$.at(-1):$[q];var v1=({verbose:$},q)=>P2($,q)!=="none",h1=({verbose:$},q)=>!["none","short"].includes(P2($,q)),a3=({verbose:$},q)=>{let J=P2($,q);return I0(J)?J:void 0},P2=($,q)=>q===void 0?wZ($):Y1($,q),wZ=($)=>$.find((q)=>I0(q))??A0.findLast((q)=>$.includes(q)),I0=($)=>typeof $==="function",A0=["none","short","full"];import{inspect as aZ}from"node:util";import{platform as IZ}from"node:process";import{stripVTControlCharacters as AZ}from"node:util";var t3=($,q)=>{let J=[$,...q],X=J.join(" "),Z=J.map((H)=>vZ(o3(H))).join(" ");return{command:X,escapedCommand:Z}},q0=($)=>AZ($).split(`
|
|
32
|
+
`).map((q)=>o3(q)).join(`
|
|
33
|
+
`),o3=($)=>$.replaceAll(OZ,(q)=>EZ(q)),EZ=($)=>{let q=NZ[$];if(q!==void 0)return q;let J=$.codePointAt(0),X=J.toString(16);return J<=DZ?`\\u${X.padStart(4,"0")}`:`\\U${X}`},yZ=()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}},OZ=yZ(),NZ={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},DZ=65535,vZ=($)=>{if(hZ.test($))return $;return IZ==="win32"?`"${$.replaceAll('"','""')}"`:`'${$.replaceAll("'","'\\''")}'`},hZ=/^[\w./-]+$/;import r3 from"node:process";function k2(){let{env:$}=r3,{TERM:q,TERM_PROGRAM:J}=$;if(r3.platform!=="win32")return q!=="linux";return Boolean($.WT_SESSION)||Boolean($.TERMINUS_SUBLIME)||$.ConEmuTask==="{cmd::Cmder}"||J==="Terminus-Sublime"||J==="vscode"||q==="xterm-256color"||q==="alacritty"||q==="rxvt-unicode"||q==="rxvt-unicode-256color"||$.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var s3={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:"╱"},e3={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:"⅒"},fZ={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"},SZ={...s3,...e3},bZ={...s3,...fZ},gZ=k2(),cZ=gZ?SZ:bZ,E0=cZ,JL=Object.entries(e3);import mZ from"node:tty";var uZ=mZ?.WriteStream?.prototype?.hasColors?.()??!1,T=($,q)=>{if(!uZ)return(Z)=>Z;let J=`\x1B[${$}m`,X=`\x1B[${q}m`;return(Z)=>{let H=Z+"",Q=H.indexOf(X);if(Q===-1)return J+H+X;let Y=J,G=0,U=(q===22?X:"")+J;while(Q!==-1)Y+=H.slice(G,Q)+U,G=Q+X.length,Q=H.indexOf(X,G);return Y+=H.slice(G)+X,Y}},QL=T(0,0),$6=T(1,22),HL=T(2,22),YL=T(3,23),GL=T(4,24),KL=T(53,55),UL=T(7,27),zL=T(8,28),BL=T(9,29),LL=T(30,39),VL=T(31,39),WL=T(32,39),_L=T(33,39),RL=T(34,39),TL=T(35,39),PL=T(36,39),kL=T(37,39),y0=T(90,39),FL=T(40,49),xL=T(41,49),jL=T(42,49),ML=T(43,49),CL=T(44,49),wL=T(45,49),IL=T(46,49),AL=T(47,49),EL=T(100,49),q6=T(91,39),yL=T(92,39),J6=T(93,39),OL=T(94,39),NL=T(95,39),DL=T(96,39),vL=T(97,39),hL=T(101,49),fL=T(102,49),SL=T(103,49),bL=T(104,49),gL=T(105,49),cL=T(106,49),mL=T(107,49);var Q6=({type:$,message:q,timestamp:J,piped:X,commandId:Z,result:{failed:H=!1}={},options:{reject:Q=!0}})=>{let Y=pZ(J),G=lZ[$]({failed:H,reject:Q,piped:X}),K=dZ[$]({reject:Q});return`${y0(`[${Y}]`)} ${y0(`[${Z}]`)} ${K(G)} ${K(q)}`},pZ=($)=>`${O0($.getHours(),2)}:${O0($.getMinutes(),2)}:${O0($.getSeconds(),2)}.${O0($.getMilliseconds(),3)}`,O0=($,q)=>String($).padStart(q,"0"),X6=({failed:$,reject:q})=>{if(!$)return E0.tick;return q?E0.cross:E0.warning},lZ={command:({piped:$})=>$?"|":"$",output:()=>" ",ipc:()=>"*",error:X6,duration:X6},Z6=($)=>$,dZ={command:()=>$6,output:()=>Z6,ipc:()=>Z6,error:({reject:$})=>$?q6:J6,duration:()=>y0};var H6=($,q,J)=>{let X=a3(q,J);return $.map(({verboseLine:Z,verboseObject:H})=>iZ(Z,H,X)).filter((Z)=>Z!==void 0).map((Z)=>nZ(Z)).join("")},iZ=($,q,J)=>{if(J===void 0)return $;let X=J($,q);if(typeof X==="string")return X},nZ=($)=>$.endsWith(`
|
|
34
34
|
`)?$:`${$}
|
|
35
|
-
`;var
|
|
36
|
-
`).map((J)=>
|
|
37
|
-
${
|
|
38
|
-
${
|
|
39
|
-
${
|
|
40
|
-
Available signal numbers: ${
|
|
35
|
+
`;var r=({type:$,verboseMessage:q,fdNumber:J,verboseInfo:X,result:Z})=>{let H=tZ({type:$,result:Z,verboseInfo:X}),Q=oZ(q,H),Y=H6(Q,X,J);if(Y!=="")console.warn(Y.slice(0,-1))},tZ=({type:$,result:q,verboseInfo:{escapedCommand:J,commandId:X,rawOptions:{piped:Z=!1,...H}}})=>({type:$,escapedCommand:J,commandId:`${X}`,timestamp:new Date,piped:Z,result:q,options:H}),oZ=($,q)=>$.split(`
|
|
36
|
+
`).map((J)=>rZ({...q,message:J})),rZ=($)=>{return{verboseLine:Q6($),verboseObject:$}},N0=($)=>{let q=typeof $==="string"?$:aZ($);return q0(q).replaceAll("\t"," ".repeat(sZ))},sZ=2;var Y6=($,q)=>{if(!v1(q))return;r({type:"command",verboseMessage:$,verboseInfo:q})};var G6=($,q,J)=>{qQ($);let X=eZ($);return{verbose:$,escapedCommand:q,commandId:X,rawOptions:J}},eZ=($)=>v1({verbose:$})?$Q++:void 0,$Q=0n,qQ=($)=>{for(let q of $){if(q===!1)throw TypeError(`The "verbose: false" option was renamed to "verbose: 'none'".`);if(q===!0)throw TypeError(`The "verbose: true" option was renamed to "verbose: 'short'".`);if(!A0.includes(q)&&!I0(q)){let J=A0.map((X)=>`'${X}'`).join(", ");throw TypeError(`The "verbose" option must not be ${q}. Allowed values are: ${J} or a function.`)}}};import{hrtime as K6}from"node:process";var D0=()=>K6.bigint(),F2=($)=>Number(K6.bigint()-$)/1e6;var v0=($,q,J)=>{let X=D0(),{command:Z,escapedCommand:H}=t3($,q),Q=_2(J,"verbose"),Y=G6(Q,H,{...J});return Y6(H,Y),{command:Z,escapedCommand:H,startTime:X,verboseInfo:Y}};var Y7=o(r6(),1);import m9 from"node:path";import H7 from"node:process";import b0 from"node:process";import k1 from"node:path";function f0($={}){let{env:q=process.env,platform:J=process.platform}=$;if(J!=="win32")return"PATH";return Object.keys(q).reverse().find((X)=>X.toUpperCase()==="PATH")||"Path"}import{promisify as OQ}from"node:util";import{execFile as NQ,execFileSync as AV}from"node:child_process";import s6 from"node:path";import{fileURLToPath as DQ}from"node:url";var OV=OQ(NQ);function S0($){return $ instanceof URL?DQ($):$}function e6($){return{*[Symbol.iterator](){let q=s6.resolve(S0($)),J;while(J!==q)yield q,J=q,q=s6.resolve(q,"..")}}}var vQ=({cwd:$=b0.cwd(),path:q=b0.env[f0()],preferLocal:J=!0,execPath:X=b0.execPath,addExecPath:Z=!0}={})=>{let H=k1.resolve(S0($)),Q=[],Y=q.split(k1.delimiter);if(J)hQ(Q,Y,H);if(Z)fQ(Q,Y,X,H);return q===""||q===k1.delimiter?`${Q.join(k1.delimiter)}${q}`:[...Q,q].join(k1.delimiter)},hQ=($,q,J)=>{for(let X of e6(J)){let Z=k1.join(X,"node_modules/.bin");if(!q.includes(Z))$.push(Z)}},fQ=($,q,J,X)=>{let Z=k1.resolve(X,S0(J),"..");if(!q.includes(Z))$.push(Z)},$8=({env:$=b0.env,...q}={})=>{$={...$};let J=f0({env:$});return q.path=$[J],$[J]=vQ(q),$};import{setTimeout as rQ}from"node:timers/promises";var q8=($,q,J)=>{let X=J?c0:g0,Z=$ instanceof s?{}:{cause:$};return new X(q,Z)};class s extends Error{}var J8=($,q)=>{Object.defineProperty($.prototype,"name",{value:q,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,Z8,{value:!0,writable:!1,enumerable:!1,configurable:!1})},X8=($)=>m0($)&&(Z8 in $),Z8=Symbol("isExecaError"),m0=($)=>Object.prototype.toString.call($)==="[object Error]";class g0 extends Error{}J8(g0,g0.name);class c0 extends Error{}J8(c0,c0.name);import{constants as J0}from"node:os";import{constants as cQ}from"node:os";var Q8=()=>{let $=O2-H8+1;return Array.from({length:$},SQ)},SQ=($,q)=>({name:`SIGRT${q+1}`,number:H8+q,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),H8=34,O2=64;import{constants as bQ}from"node:os";var Y8=[{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"}];var N2=()=>{let $=Q8();return[...Y8,...$].map(gQ)},gQ=({name:$,number:q,description:J,action:X,forced:Z=!1,standard:H})=>{let{signals:{[$]:Q}}=bQ,Y=Q!==void 0;return{name:$,number:Y?Q:q,description:J,supported:Y,action:X,forced:Z,standard:H}};var mQ=()=>{let $=N2();return Object.fromEntries($.map(uQ))},uQ=({name:$,number:q,description:J,supported:X,action:Z,forced:H,standard:Q})=>[$,{name:$,number:q,description:J,supported:X,action:Z,forced:H,standard:Q}],G8=mQ(),pQ=()=>{let $=N2(),q=O2+1,J=Array.from({length:q},(X,Z)=>lQ(Z,$));return Object.assign({},...J)},lQ=($,q)=>{let J=dQ($,q);if(J===void 0)return{};let{name:X,description:Z,supported:H,action:Q,forced:Y,standard:G}=J;return{[$]:{name:X,number:$,description:Z,supported:H,action:Q,forced:Y,standard:G}}},dQ=($,q)=>{let J=q.find(({name:X})=>cQ.signals[X]===$);if(J!==void 0)return J;return q.find((X)=>X.number===$)},tV=pQ();var U8=($)=>{if($===0)throw TypeError("Invalid option `killSignal`: 0 cannot be used.");return B8($,"option `killSignal`")},z8=($)=>$===0?$:B8($,"`subprocess.kill()`'s argument"),B8=($,q)=>{if(Number.isInteger($))return iQ($,q);if(typeof $==="string")return aQ($,q);throw TypeError(`Invalid ${q} ${String($)}: it must be a string or an integer.
|
|
37
|
+
${D2()}`)},iQ=($,q)=>{if(K8.has($))return K8.get($);throw TypeError(`Invalid ${q} ${$}: this signal integer does not exist.
|
|
38
|
+
${D2()}`)},nQ=()=>new Map(Object.entries(J0.signals).reverse().map(([$,q])=>[q,$])),K8=nQ(),aQ=($,q)=>{if($ in J0.signals)return $;if($.toUpperCase()in J0.signals)throw TypeError(`Invalid ${q} '${$}': please rename it to '${$.toUpperCase()}'.`);throw TypeError(`Invalid ${q} '${$}': this signal name does not exist.
|
|
39
|
+
${D2()}`)},D2=()=>`Available signal names: ${tQ()}.
|
|
40
|
+
Available signal numbers: ${oQ()}.`,tQ=()=>Object.keys(J0.signals).sort().map(($)=>`'${$}'`).join(", "),oQ=()=>[...new Set(Object.values(J0.signals).sort(($,q)=>$-q))].join(", "),u0=($)=>G8[$].description;var L8=($)=>{if($===!1)return $;if($===!0)return sQ;if(!Number.isFinite($)||$<0)throw TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${$}\` (${typeof $})`);return $},sQ=5000,V8=({kill:$,options:{forceKillAfterDelay:q,killSignal:J},onInternalError:X,context:Z,controller:H},Q,Y)=>{let{signal:G,error:K}=eQ(Q,Y,J);$9(K,X);let U=$(G);return q9({kill:$,signal:G,forceKillAfterDelay:q,killSignal:J,killResult:U,context:Z,controller:H}),U},eQ=($,q,J)=>{let[X=J,Z]=m0($)?[void 0,$]:[$,q];if(typeof X!=="string"&&!Number.isInteger(X))throw TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(X)}`);if(Z!==void 0&&!m0(Z))throw TypeError(`The second argument is optional. If specified, it must be an error instance: ${Z}`);return{signal:z8(X),error:Z}},$9=($,q)=>{if($!==void 0)q.reject($)},q9=async({kill:$,signal:q,forceKillAfterDelay:J,killSignal:X,killResult:Z,context:H,controller:Q})=>{if(q===X&&Z)v2({kill:$,forceKillAfterDelay:J,context:H,controllerSignal:Q.signal})},v2=async({kill:$,forceKillAfterDelay:q,context:J,controllerSignal:X})=>{if(q===!1)return;try{if(await rQ(q,void 0,{signal:X}),$("SIGKILL"))J.isForcefullyTerminated??=!0}catch{}};import{once as J9}from"node:events";var p0=async($,q)=>{if(!$.aborted)await J9($,"abort",{signal:q})};var W8=({cancelSignal:$})=>{if($!==void 0&&Object.prototype.toString.call($)!=="[object AbortSignal]")throw Error(`The \`cancelSignal\` option must be an AbortSignal: ${String($)}`)},_8=({subprocess:$,cancelSignal:q,gracefulCancel:J,context:X,controller:Z})=>q===void 0||J?[]:[X9($,q,X,Z)],X9=async($,q,J,{signal:X})=>{throw await p0(q,X),J.terminationReason??="cancel",$.kill(),q.reason};import{scheduler as M9}from"node:timers/promises";import{promisify as F9}from"node:util";var b1=({methodName:$,isSubprocess:q,ipc:J,isConnected:X})=>{Z9($,q,J),h2($,q,X)},Z9=($,q,J)=>{if(!J)throw Error(`${n($,q)} can only be used if the \`ipc\` option is \`true\`.`)},h2=($,q,J)=>{if(!J)throw Error(`${n($,q)} cannot be used: the ${V1(q)} has already exited or disconnected.`)},R8=($)=>{throw Error(`${n("getOneMessage",$)} could not complete: the ${V1($)} exited or disconnected.`)},T8=($)=>{throw Error(`${n("sendMessage",$)} failed: the ${V1($)} is sending a message too, instead of listening to incoming messages.
|
|
41
41
|
This can be fixed by both sending a message and listening to incoming messages at the same time:
|
|
42
42
|
|
|
43
43
|
const [receivedMessage] = await Promise.all([
|
|
44
|
-
${
|
|
45
|
-
${
|
|
46
|
-
]);`)},
|
|
44
|
+
${n("getOneMessage",$)},
|
|
45
|
+
${n("sendMessage",$,"message, {strict: true}")},
|
|
46
|
+
]);`)},l0=($,q)=>Error(`${n("sendMessage",q)} failed when sending an acknowledgment response to the ${V1(q)}.`,{cause:$}),P8=($)=>{throw Error(`${n("sendMessage",$)} failed: the ${V1($)} is not listening to incoming messages.`)},k8=($)=>{throw Error(`${n("sendMessage",$)} failed: the ${V1($)} exited without listening to incoming messages.`)},F8=()=>Error(`\`cancelSignal\` aborted: the ${V1(!0)} disconnected.`),x8=()=>{throw Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")},j8=({error:$,methodName:q,isSubprocess:J})=>{if($.code==="EPIPE")throw Error(`${n(q,J)} cannot be used: the ${V1(J)} is disconnecting.`,{cause:$})},M8=({error:$,methodName:q,isSubprocess:J,message:X})=>{if(Q9($))throw Error(`${n(q,J)}'s argument type is invalid: the message cannot be serialized: ${String(X)}.`,{cause:$})},Q9=({code:$,message:q})=>H9.has($)||Y9.some((J)=>q.includes(J)),H9=new Set(["ERR_MISSING_ARGS","ERR_INVALID_ARG_TYPE"]),Y9=["could not be cloned","circular structure","call stack size exceeded"],n=($,q,J="")=>$==="cancelSignal"?"`cancelSignal`'s `controller.abort()`":`${G9(q)}${$}(${J})`,G9=($)=>$?"":"subprocess.",V1=($)=>$?"parent process":"subprocess",g1=($)=>{if($.connected)$.disconnect()};var e=()=>{let $={},q=new Promise((J,X)=>{Object.assign($,{resolve:J,reject:X})});return Object.assign(q,$)};var i0=($,q="stdin")=>{let{options:X,fileDescriptors:Z}=$1.get($),H=C8(Z,q,!0),Q=$.stdio[H];if(Q===null)throw TypeError(w8(H,q,X,!0));return Q},c1=($,q="stdout")=>{let{options:X,fileDescriptors:Z}=$1.get($),H=C8(Z,q,!1),Q=H==="all"?$.all:$.stdio[H];if(Q===null||Q===void 0)throw TypeError(w8(H,q,X,!1));return Q},$1=new WeakMap,C8=($,q,J)=>{let X=K9(q,J);return U9(X,q,J,$),X},K9=($,q)=>{let J=R2($);if(J!==void 0)return J;let{validOptions:X,defaultValue:Z}=q?{validOptions:'"stdin"',defaultValue:"stdin"}:{validOptions:'"stdout", "stderr", "all"',defaultValue:"stdout"};throw TypeError(`"${X0(q)}" must not be "${$}".
|
|
47
47
|
It must be ${X} or "fd3", "fd4" (and so on).
|
|
48
|
-
It is optional and defaults to "${Z}".`)},
|
|
49
|
-
Please set the "stdio" option to ensure that file descriptor exists.`);if(Z.direction==="input"&&!J)throw TypeError(`"${
|
|
50
|
-
Please set this option with "pipe" instead.`},
|
|
51
|
-
Please rename it to ${
|
|
52
|
-
Please rename it to one of: ${J}.`)},
|
|
53
|
-
${$.message}`,$}},
|
|
48
|
+
It is optional and defaults to "${Z}".`)},U9=($,q,J,X)=>{let Z=X[I8($)];if(Z===void 0)throw TypeError(`"${X0(J)}" must not be ${q}. That file descriptor does not exist.
|
|
49
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);if(Z.direction==="input"&&!J)throw TypeError(`"${X0(J)}" must not be ${q}. It must be a readable stream, not writable.`);if(Z.direction!=="input"&&J)throw TypeError(`"${X0(J)}" must not be ${q}. It must be a writable stream, not readable.`)},w8=($,q,J,X)=>{if($==="all"&&!J.all)return`The "all" option must be true to use "from: 'all'".`;let{optionName:Z,optionValue:H}=z9($,J);return`The "${Z}: ${d0(H)}" option is incompatible with using "${X0(X)}: ${d0(q)}".
|
|
50
|
+
Please set this option with "pipe" instead.`},z9=($,{stdin:q,stdout:J,stderr:X,stdio:Z})=>{let H=I8($);if(H===0&&q!==void 0)return{optionName:"stdin",optionValue:q};if(H===1&&J!==void 0)return{optionName:"stdout",optionValue:J};if(H===2&&X!==void 0)return{optionName:"stderr",optionValue:X};return{optionName:`stdio[${H}]`,optionValue:Z[H]}},I8=($)=>$==="all"?1:$,X0=($)=>$?"to":"from",d0=($)=>{if(typeof $==="string")return`'${$}'`;return typeof $==="number"?`${$}`:"Stream"};import{once as R9}from"node:events";import{addAbortListener as B9}from"node:events";var F1=($,q,J)=>{let X=$.getMaxListeners();if(X===0||X===Number.POSITIVE_INFINITY)return;$.setMaxListeners(X+q),B9(J,()=>{$.setMaxListeners($.getMaxListeners()-q)})};import{EventEmitter as W9}from"node:events";import{once as L9}from"node:events";import{scheduler as V9}from"node:timers/promises";var n0=($,q)=>{if(q)f2($)},f2=($)=>{$.refCounted()},a0=($,q)=>{if(q)S2($)},S2=($)=>{$.unrefCounted()},A8=($,q)=>{if(q)S2($),S2($)},E8=($,q)=>{if(q)f2($),f2($)};var y8=async({anyProcess:$,channel:q,isSubprocess:J,ipcEmitter:X},Z)=>{if(D8(Z)||h8(Z))return;if(!t0.has($))t0.set($,[]);let H=t0.get($);if(H.push(Z),H.length>1)return;while(H.length>0){await v8($,X,Z),await V9.yield();let Q=await N8({wrappedMessage:H[0],anyProcess:$,channel:q,isSubprocess:J,ipcEmitter:X});H.shift(),X.emit("message",Q),X.emit("message:done")}},O8=async({anyProcess:$,channel:q,isSubprocess:J,ipcEmitter:X,boundOnMessage:Z})=>{b2();let H=t0.get($);while(H?.length>0)await L9(X,"message:done");$.removeListener("message",Z),E8(q,J),X.connected=!1,X.emit("disconnect")},t0=new WeakMap;var W1=($,q,J)=>{if(o0.has($))return o0.get($);let X=new W9;return X.connected=!0,o0.set($,X),_9({ipcEmitter:X,anyProcess:$,channel:q,isSubprocess:J}),X},o0=new WeakMap,_9=({ipcEmitter:$,anyProcess:q,channel:J,isSubprocess:X})=>{let Z=y8.bind(void 0,{anyProcess:q,channel:J,isSubprocess:X,ipcEmitter:$});q.on("message",Z),q.once("disconnect",O8.bind(void 0,{anyProcess:q,channel:J,isSubprocess:X,ipcEmitter:$,boundOnMessage:Z})),A8(J,X)},r0=($)=>{let q=o0.get($);return q===void 0?$.channel!==null:q.connected};var f8=({anyProcess:$,channel:q,isSubprocess:J,message:X,strict:Z})=>{if(!Z)return X;let H=W1($,q,J),Q=$$($,H);return{id:T9++,type:e0,message:X,hasListeners:Q}},T9=0n,S8=($,q)=>{if(q?.type!==e0||q.hasListeners)return;for(let{id:J}of $)if(J!==void 0)s0[J].resolve({isDeadlock:!0,hasListeners:!1})},N8=async({wrappedMessage:$,anyProcess:q,channel:J,isSubprocess:X,ipcEmitter:Z})=>{if($?.type!==e0||!q.connected)return $;let{id:H,message:Q}=$,Y={id:H,type:g8,message:$$(q,Z)};try{await q$({anyProcess:q,channel:J,isSubprocess:X,ipc:!0},Y)}catch(G){Z.emit("strict:error",G)}return Q},D8=($)=>{if($?.type!==g8)return!1;let{id:q,message:J}=$;return s0[q]?.resolve({isDeadlock:!1,hasListeners:J}),!0},b8=async($,q,J)=>{if($?.type!==e0)return;let X=e();s0[$.id]=X;let Z=new AbortController;try{let{isDeadlock:H,hasListeners:Q}=await Promise.race([X,P9(q,J,Z)]);if(H)T8(J);if(!Q)P8(J)}finally{Z.abort(),delete s0[$.id]}},s0={},P9=async($,q,{signal:J})=>{F1($,1,J),await R9($,"disconnect",{signal:J}),k8(q)},e0="execa:ipc:request",g8="execa:ipc:response";var c8=($,q,J)=>{if(!Z0.has($))Z0.set($,new Set);let X=Z0.get($),Z=e(),H=J?q.id:void 0,Q={onMessageSent:Z,id:H};return X.add(Q),{outgoingMessages:X,outgoingMessage:Q}},m8=({outgoingMessages:$,outgoingMessage:q})=>{$.delete(q),q.onMessageSent.resolve()},v8=async($,q,J)=>{while(!$$($,q)&&Z0.get($)?.size>0){let X=[...Z0.get($)];S8(X,J),await Promise.all(X.map(({onMessageSent:Z})=>Z))}},Z0=new WeakMap,$$=($,q)=>q.listenerCount("message")>k9($),k9=($)=>$1.has($)&&!Y1($1.get($).options.buffer,"ipc")?1:0;var q$=({anyProcess:$,channel:q,isSubprocess:J,ipc:X},Z,{strict:H=!1}={})=>{return b1({methodName:"sendMessage",isSubprocess:J,ipc:X,isConnected:$.connected}),x9({anyProcess:$,channel:q,methodName:"sendMessage",isSubprocess:J,message:Z,strict:H})},x9=async({anyProcess:$,channel:q,methodName:J,isSubprocess:X,message:Z,strict:H})=>{let Q=f8({anyProcess:$,channel:q,isSubprocess:X,message:Z,strict:H}),Y=c8($,Q,H);try{await c2({anyProcess:$,methodName:J,isSubprocess:X,wrappedMessage:Q,message:Z})}catch(G){throw g1($),G}finally{m8(Y)}},c2=async({anyProcess:$,methodName:q,isSubprocess:J,wrappedMessage:X,message:Z})=>{let H=j9($);try{await Promise.all([b8(X,$,J),H(X)])}catch(Q){throw j8({error:Q,methodName:q,isSubprocess:J}),M8({error:Q,methodName:q,isSubprocess:J,message:Z}),Q}},j9=($)=>{if(g2.has($))return g2.get($);let q=F9($.send.bind($));return g2.set($,q),q},g2=new WeakMap;var p8=($,q)=>{return h2("cancelSignal",!1,$.connected),c2({anyProcess:$,methodName:"cancelSignal",isSubprocess:!1,wrappedMessage:{type:d8,message:q},message:q})},l8=async({anyProcess:$,channel:q,isSubprocess:J,ipc:X})=>{return await C9({anyProcess:$,channel:q,isSubprocess:J,ipc:X}),m2.signal},C9=async({anyProcess:$,channel:q,isSubprocess:J,ipc:X})=>{if(u8)return;if(u8=!0,!X){x8();return}if(q===null){b2();return}W1($,q,J),await M9.yield()},u8=!1,h8=($)=>{if($?.type!==d8)return!1;return m2.abort($.message),!0},d8="execa:ipc:cancel",b2=()=>{m2.abort(F8())},m2=new AbortController;var i8=({gracefulCancel:$,cancelSignal:q,ipc:J,serialization:X})=>{if(!$)return;if(q===void 0)throw Error("The `cancelSignal` option must be defined when setting the `gracefulCancel` option.");if(!J)throw Error("The `ipc` option cannot be false when setting the `gracefulCancel` option.");if(X==="json")throw Error("The `serialization` option cannot be 'json' when setting the `gracefulCancel` option.")},n8=({subprocess:$,cancelSignal:q,gracefulCancel:J,forceKillAfterDelay:X,context:Z,controller:H})=>J?[w9({subprocess:$,cancelSignal:q,forceKillAfterDelay:X,context:Z,controller:H})]:[],w9=async({subprocess:$,cancelSignal:q,forceKillAfterDelay:J,context:X,controller:{signal:Z}})=>{await p0(q,Z);let H=I9(q);throw await p8($,H),v2({kill:$.kill,forceKillAfterDelay:J,context:X,controllerSignal:Z}),X.terminationReason??="gracefulCancel",q.reason},I9=({reason:$})=>{if(!($ instanceof DOMException))return $;let q=Error($.message);return Object.defineProperty(q,"stack",{value:$.stack,enumerable:!1,configurable:!0,writable:!0}),q};import{setTimeout as A9}from"node:timers/promises";var a8=({timeout:$})=>{if($!==void 0&&(!Number.isFinite($)||$<0))throw TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${$}\` (${typeof $})`)},t8=($,q,J,X)=>q===0||q===void 0?[]:[E9($,q,J,X)],E9=async($,q,J,{signal:X})=>{throw await A9(q,void 0,{signal:X}),J.terminationReason??="timeout",$.kill(),new s};import{execPath as y9,execArgv as O9}from"node:process";import o8 from"node:path";var r8=({options:$})=>{if($.node===!1)throw TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...$,node:!0}}},s8=($,q,{node:J=!1,nodePath:X=y9,nodeOptions:Z=O9.filter((G)=>!G.startsWith("--inspect")),cwd:H,execPath:Q,...Y})=>{if(Q!==void 0)throw TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');let G=D1(X,'The "nodePath" option'),K=o8.resolve(H,G),U={...Y,nodePath:K,node:J,cwd:H};if(!J)return[$,q,U];if(o8.basename($,".exe")==="node")throw TypeError('When the "node" option is true, the first argument does not need to be "node".');return[K,[...Z,$,...q],{ipc:!0,...U,shell:!1}]};import{serialize as N9}from"node:v8";var e8=({ipcInput:$,ipc:q,serialization:J})=>{if($===void 0)return;if(!q)throw Error("The `ipcInput` option cannot be set unless the `ipc` option is `true`.");h9[J]($)},D9=($)=>{try{N9($)}catch(q){throw Error("The `ipcInput` option is not serializable with a structured clone.",{cause:q})}},v9=($)=>{try{JSON.stringify($)}catch(q){throw Error("The `ipcInput` option is not serializable with JSON.",{cause:q})}},h9={advanced:D9,json:v9},$7=async($,q)=>{if(q===void 0)return;await $.sendMessage(q)};var J7=({encoding:$})=>{if(u2.has($))return;let q=S9($);if(q!==void 0)throw TypeError(`Invalid option \`encoding: ${J$($)}\`.
|
|
51
|
+
Please rename it to ${J$(q)}.`);let J=[...u2].map((X)=>J$(X)).join(", ");throw TypeError(`Invalid option \`encoding: ${J$($)}\`.
|
|
52
|
+
Please rename it to one of: ${J}.`)},f9=new Set(["utf8","utf16le"]),u=new Set(["buffer","hex","base64","base64url","latin1","ascii"]),u2=new Set([...f9,...u]),S9=($)=>{if($===null)return"buffer";if(typeof $!=="string")return;let q=$.toLowerCase();if(q in q7)return q7[q];if(u2.has(q))return q},q7={"utf-8":"utf8","utf-16le":"utf16le","ucs-2":"utf16le",ucs2:"utf16le",binary:"latin1"},J$=($)=>typeof $==="string"?`"${$}"`:String($);import{statSync as b9}from"node:fs";import g9 from"node:path";import c9 from"node:process";var X7=($=Z7())=>{let q=D1($,'The "cwd" option');return g9.resolve(q)},Z7=()=>{try{return c9.cwd()}catch($){throw $.message=`The current directory does not exist.
|
|
53
|
+
${$.message}`,$}},Q7=($,q)=>{if(q===Z7())return $;let J;try{J=b9(q)}catch(X){return`The "cwd" option is invalid: ${q}.
|
|
54
54
|
${X.message}
|
|
55
55
|
${$}`}if(!J.isDirectory())return`The "cwd" option is not a directory: ${q}.
|
|
56
|
-
${$}`;return $};var
|
|
57
|
-
`,
|
|
58
|
-
${x}`,N=`${v}: ${Y}${
|
|
59
|
-
`)].map((
|
|
56
|
+
${$}`;return $};var X$=($,q,J)=>{J.cwd=X7(J.cwd);let[X,Z,H]=s8($,q,J),{command:Q,args:Y,options:G}=Y7.default._parse(X,Z,H),K=n3(G),U=u9(K);if(a8(U),J7(U),e8(U),W8(U),i8(U),U.shell=L2(U.shell),U.env=p9(U),U.killSignal=U8(U.killSignal),U.forceKillAfterDelay=L8(U.forceKillAfterDelay),U.lines=U.lines.map((z,B)=>z&&!u.has(U.encoding)&&U.buffer[B]),H7.platform==="win32"&&m9.basename(Q,".exe")==="cmd")Y.unshift("/q");return{file:Q,commandArguments:Y,options:U}},u9=({extendEnv:$=!0,preferLocal:q=!1,cwd:J,localDir:X=J,encoding:Z="utf8",reject:H=!0,cleanup:Q=!0,all:Y=!1,windowsHide:G=!0,killSignal:K="SIGTERM",forceKillAfterDelay:U=!0,gracefulCancel:z=!1,ipcInput:B,ipc:L=B!==void 0||z,serialization:_="advanced",...P})=>({...P,extendEnv:$,preferLocal:q,cwd:J,localDirectory:X,encoding:Z,reject:H,cleanup:Q,all:Y,windowsHide:G,killSignal:K,forceKillAfterDelay:U,gracefulCancel:z,ipcInput:B,ipc:L,serialization:_}),p9=({env:$,extendEnv:q,preferLocal:J,node:X,localDirectory:Z,nodePath:H})=>{let Q=q?{...H7.env,...$}:$;if(J||X)return $8({env:Q,cwd:Z,execPath:H,preferLocal:J,addExecPath:X});return Q};var Z$=($,q,J)=>J.shell&&q.length>0?[[$,...q].join(" "),[],J]:[$,q,J];import{inspect as jH}from"node:util";function m1($){if(typeof $==="string")return l9($);if(!(ArrayBuffer.isView($)&&$.BYTES_PER_ELEMENT===1))throw Error("Input must be a string or a Uint8Array");return d9($)}var l9=($)=>$.at(-1)===G7?$.slice(0,$.at(-2)===K7?-2:-1):$,d9=($)=>$.at(-1)===i9?$.subarray(0,$.at(-2)===n9?-2:-1):$,G7=`
|
|
57
|
+
`,i9=G7.codePointAt(0),K7="\r",n9=K7.codePointAt(0);import{on as PH}from"node:events";import{finished as kH}from"node:stream/promises";function a($,{checkOpen:q=!0}={}){return $!==null&&typeof $==="object"&&($.writable||$.readable||!q||$.writable===void 0&&$.readable===void 0)&&typeof $.pipe==="function"}function p2($,{checkOpen:q=!0}={}){return a($,{checkOpen:q})&&($.writable||!q)&&typeof $.write==="function"&&typeof $.end==="function"&&typeof $.writable==="boolean"&&typeof $.writableObjectMode==="boolean"&&typeof $.destroy==="function"&&typeof $.destroyed==="boolean"}function x1($,{checkOpen:q=!0}={}){return a($,{checkOpen:q})&&($.readable||!q)&&typeof $.read==="function"&&typeof $.readable==="boolean"&&typeof $.readableObjectMode==="boolean"&&typeof $.destroy==="function"&&typeof $.destroyed==="boolean"}function l2($,q){return p2($,q)&&x1($,q)}var a9=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype);class U7{#q;#J;#$=!1;#X=void 0;constructor($,q){this.#q=$,this.#J=q}next(){let $=()=>this.#Q();return this.#X=this.#X?this.#X.then($,$):$(),this.#X}return($){let q=()=>this.#Z($);return this.#X?this.#X.then(q,q):q()}async#Q(){if(this.#$)return{done:!0,value:void 0};let $;try{$=await this.#q.read()}catch(q){throw this.#X=void 0,this.#$=!0,this.#q.releaseLock(),q}return $.done&&(this.#X=void 0,this.#$=!0,this.#q.releaseLock()),$}async#Z($){if(this.#$)return{done:!0,value:$};if(this.#$=!0,!this.#J){let q=this.#q.cancel($);return this.#q.releaseLock(),await q,{done:!0,value:$}}return this.#q.releaseLock(),{done:!0,value:$}}}var d2=Symbol();function z7(){return this[d2].next()}Object.defineProperty(z7,"name",{value:"next"});function B7($){return this[d2].return($)}Object.defineProperty(B7,"name",{value:"return"});var t9=Object.create(a9,{next:{enumerable:!0,configurable:!0,writable:!0,value:z7},return:{enumerable:!0,configurable:!0,writable:!0,value:B7}});function i2({preventCancel:$=!1}={}){let q=this.getReader(),J=new U7(q,$),X=Object.create(t9);return X[d2]=J,X}var L7=($)=>{if(x1($,{checkOpen:!1})&&Q0.on!==void 0)return r9($);if(typeof $?.[Symbol.asyncIterator]==="function")return $;if(o9.call($)==="[object ReadableStream]")return i2.call($);throw TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.")},{toString:o9}=Object.prototype,r9=async function*($){let q=new AbortController,J={};s9($,q,J);try{for await(let[X]of Q0.on($,"data",{signal:q.signal}))yield X}catch(X){if(J.error!==void 0)throw J.error;else if(!q.signal.aborted)throw X}finally{$.destroy()}},s9=async($,q,J)=>{try{await Q0.finished($,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(X){J.error=X}finally{q.abort()}},Q0={};var u1=async($,{init:q,convertChunk:J,getSize:X,truncateChunk:Z,addChunk:H,getFinalChunk:Q,finalize:Y},{maxBuffer:G=Number.POSITIVE_INFINITY}={})=>{let K=L7($),U=q();U.length=0;try{for await(let z of K){let B=$H(z),L=J[B](z,U);_7({convertedChunk:L,state:U,getSize:X,truncateChunk:Z,addChunk:H,maxBuffer:G})}return e9({state:U,convertChunk:J,getSize:X,truncateChunk:Z,addChunk:H,getFinalChunk:Q,maxBuffer:G}),Y(U)}catch(z){let B=typeof z==="object"&&z!==null?z:Error(z);throw B.bufferedData=Y(U),B}},e9=({state:$,getSize:q,truncateChunk:J,addChunk:X,getFinalChunk:Z,maxBuffer:H})=>{let Q=Z($);if(Q!==void 0)_7({convertedChunk:Q,state:$,getSize:q,truncateChunk:J,addChunk:X,maxBuffer:H})},_7=({convertedChunk:$,state:q,getSize:J,truncateChunk:X,addChunk:Z,maxBuffer:H})=>{let Q=J($),Y=q.length+Q;if(Y<=H){V7($,q,Z,Y);return}let G=X($,H-q.length);if(G!==void 0)V7(G,q,Z,H);throw new G1},V7=($,q,J,X)=>{q.contents=J($,q,X),q.length=X},$H=($)=>{let q=typeof $;if(q==="string")return"string";if(q!=="object"||$===null)return"others";if(globalThis.Buffer?.isBuffer($))return"buffer";let J=W7.call($);if(J==="[object ArrayBuffer]")return"arrayBuffer";if(J==="[object DataView]")return"dataView";if(Number.isInteger($.byteLength)&&Number.isInteger($.byteOffset)&&W7.call($.buffer)==="[object ArrayBuffer]")return"typedArray";return"others"},{toString:W7}=Object.prototype;class G1 extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}}var K1=($)=>$,H0=()=>{return},Q$=({contents:$})=>$,H$=($)=>{throw Error(`Streams in object mode are not supported: ${String($)}`)},Y$=($)=>$.length;async function G$($,q){return u1($,ZH,q)}var qH=()=>({contents:[]}),JH=()=>1,XH=($,{contents:q})=>{return q.push($),q},ZH={init:qH,convertChunk:{string:K1,buffer:K1,arrayBuffer:K1,dataView:K1,typedArray:K1,others:K1},getSize:JH,truncateChunk:H0,addChunk:XH,getFinalChunk:H0,finalize:Q$};async function K$($,q){return u1($,LH,q)}var QH=()=>({contents:new ArrayBuffer(0)}),HH=($)=>YH.encode($),YH=new TextEncoder,R7=($)=>new Uint8Array($),T7=($)=>new Uint8Array($.buffer,$.byteOffset,$.byteLength),GH=($,q)=>$.slice(0,q),KH=($,{contents:q,length:J},X)=>{let Z=F7()?zH(q,X):UH(q,X);return new Uint8Array(Z).set($,J),Z},UH=($,q)=>{if(q<=$.byteLength)return $;let J=new ArrayBuffer(k7(q));return new Uint8Array(J).set(new Uint8Array($),0),J},zH=($,q)=>{if(q<=$.maxByteLength)return $.resize(q),$;let J=new ArrayBuffer(q,{maxByteLength:k7(q)});return new Uint8Array(J).set(new Uint8Array($),0),J},k7=($)=>P7**Math.ceil(Math.log($)/Math.log(P7)),P7=2,BH=({contents:$,length:q})=>F7()?$:$.slice(0,q),F7=()=>("resize"in ArrayBuffer.prototype),LH={init:QH,convertChunk:{string:HH,buffer:R7,arrayBuffer:R7,dataView:T7,typedArray:T7,others:H$},getSize:Y$,truncateChunk:GH,addChunk:KH,getFinalChunk:H0,finalize:BH};async function z$($,q){return u1($,TH,q)}var VH=()=>({contents:"",textDecoder:new TextDecoder}),U$=($,{textDecoder:q})=>q.decode($,{stream:!0}),WH=($,{contents:q})=>q+$,_H=($,q)=>$.slice(0,q),RH=({textDecoder:$})=>{let q=$.decode();return q===""?void 0:q},TH={init:VH,convertChunk:{string:K1,buffer:U$,arrayBuffer:U$,dataView:U$,typedArray:U$,others:H$},getSize:Y$,truncateChunk:_H,addChunk:WH,getFinalChunk:RH,finalize:Q$};Object.assign(Q0,{on:PH,finished:kH});var x7=({error:$,stream:q,readableObjectMode:J,lines:X,encoding:Z,fdNumber:H})=>{if(!($ instanceof G1))throw $;if(H==="all")return $;let Q=FH(J,X,Z);throw $.maxBufferInfo={fdNumber:H,unit:Q},q.destroy(),$},FH=($,q,J)=>{if($)return"objects";if(q)return"lines";if(J==="buffer")return"bytes";return"characters"},j7=($,q,J)=>{if(q.length!==J)return;let X=new G1;throw X.maxBufferInfo={fdNumber:"ipc"},X},M7=($,q)=>{let{streamName:J,threshold:X,unit:Z}=xH($,q);return`Command's ${J} was larger than ${X} ${Z}`},xH=($,q)=>{if($?.maxBufferInfo===void 0)return{streamName:"output",threshold:q[1],unit:"bytes"};let{maxBufferInfo:{fdNumber:J,unit:X}}=$;delete $.maxBufferInfo;let Z=Y1(q,J);if(J==="ipc")return{streamName:"IPC output",threshold:Z,unit:"messages"};return{streamName:w0(J),threshold:Z,unit:X}},C7=($,q,J)=>$?.code==="ENOBUFS"&&q!==null&&q.some((X)=>X!==null&&X.length>B$(J)),w7=($,q,J)=>{if(!q)return $;let X=B$(J);return $.length>X?$.slice(0,X):$},B$=([,$])=>$;var A7=({stdio:$,all:q,ipcOutput:J,originalError:X,signal:Z,signalDescription:H,exitCode:Q,escapedCommand:Y,timedOut:G,isCanceled:K,isGracefullyCanceled:U,isMaxBuffer:z,isForcefullyTerminated:B,forceKillAfterDelay:L,killSignal:_,maxBuffer:P,timeout:M,cwd:F})=>{let O=X?.code,v=MH({originalError:X,timedOut:G,timeout:M,isMaxBuffer:z,maxBuffer:P,errorCode:O,signal:Z,signalDescription:H,exitCode:Q,isCanceled:K,isGracefullyCanceled:U,isForcefullyTerminated:B,forceKillAfterDelay:L,killSignal:_}),x=wH(X,F),I=x===void 0?"":`
|
|
58
|
+
${x}`,N=`${v}: ${Y}${I}`,c=q===void 0?[$[2],$[1]]:[q],B1=[N,...c,...$.slice(3),J.map((L1)=>IH(L1)).join(`
|
|
59
|
+
`)].map((L1)=>q0(m1(AH(L1)))).filter(Boolean).join(`
|
|
60
60
|
|
|
61
|
-
`);return{originalMessage:x,shortMessage:N,message:
|
|
62
|
-
`):k7($),k7=($)=>{if(typeof $==="string")return $;if(D($))return T0($);return""};var Y$=({command:$,escapedCommand:q,stdio:J,all:X,ipcOutput:Z,options:{cwd:H},startTime:Q})=>x7({command:$,escapedCommand:q,cwd:H,durationMs:z2(Q),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:J[1],stderr:J[2],all:X,stdio:J,ipcOutput:Z,pipedFrom:[]}),S1=({error:$,command:q,escapedCommand:J,fileDescriptors:X,options:Z,startTime:H,isSync:Q})=>q0({error:$,command:q,escapedCommand:J,startTime:H,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:X.length}),ipcOutput:[],options:Z,isSync:Q}),q0=({error:$,command:q,escapedCommand:J,startTime:X,timedOut:Z,isCanceled:H,isGracefullyCanceled:Q,isMaxBuffer:Y,isForcefullyTerminated:G,exitCode:K,signal:U,stdio:z,all:B,ipcOutput:L,options:{timeoutDuration:W,timeout:P=W,forceKillAfterDelay:M,killSignal:F,cwd:O,maxBuffer:v},isSync:x})=>{let{exitCode:w,signal:N,signalDescription:g}=T9(K,U),{originalMessage:K1,shortMessage:U1,message:d$}=F7({stdio:z,all:B,ipcOutput:L,originalError:$,signal:N,signalDescription:g,exitCode:w,escapedCommand:J,timedOut:Z,isCanceled:H,isGracefullyCanceled:Q,isMaxBuffer:Y,isForcefullyTerminated:G,forceKillAfterDelay:M,killSignal:F,maxBuffer:v,timeout:P,cwd:O}),i1=a6($,d$,x);return Object.assign(i1,W9({error:i1,command:q,escapedCommand:J,startTime:X,timedOut:Z,isCanceled:H,isGracefullyCanceled:Q,isMaxBuffer:Y,isForcefullyTerminated:G,exitCode:w,signal:N,signalDescription:g,stdio:z,all:B,ipcOutput:L,cwd:O,originalMessage:K1,shortMessage:U1})),i1},W9=({error:$,command:q,escapedCommand:J,startTime:X,timedOut:Z,isCanceled:H,isGracefullyCanceled:Q,isMaxBuffer:Y,isForcefullyTerminated:G,exitCode:K,signal:U,signalDescription:z,stdio:B,all:L,ipcOutput:W,cwd:P,originalMessage:M,shortMessage:F})=>x7({shortMessage:F,originalMessage:M,command:q,escapedCommand:J,cwd:P,durationMs:z2(X),failed:!0,timedOut:Z,isCanceled:H,isGracefullyCanceled:Q,isTerminated:U!==void 0,isMaxBuffer:Y,isForcefullyTerminated:G,exitCode:K,signal:U,signalDescription:z,code:$.cause?.code,stdout:B[1],stderr:B[2],all:L,stdio:B,ipcOutput:W,pipedFrom:[]}),x7=($)=>Object.fromEntries(Object.entries($).filter(([,q])=>q!==void 0)),T9=($,q)=>{let J=$===null?void 0:$,X=q===null?void 0:q,Z=X===void 0?void 0:h0(q);return{exitCode:J,signal:X,signalDescription:Z}};var j7=($)=>Number.isFinite($)?$:0;function P9($){return{days:Math.trunc($/86400000),hours:Math.trunc($/3600000%24),minutes:Math.trunc($/60000%60),seconds:Math.trunc($/1000%60),milliseconds:Math.trunc($%1000),microseconds:Math.trunc(j7($*1000)%1000),nanoseconds:Math.trunc(j7($*1e6)%1000)}}function k9($){return{days:$/86400000n,hours:$/3600000n%24n,minutes:$/60000n%60n,seconds:$/1000n%60n,milliseconds:$%1000n,microseconds:0n,nanoseconds:0n}}function S2($){switch(typeof $){case"number":{if(Number.isFinite($))return P9($);break}case"bigint":return k9($)}throw TypeError("Expected a finite number or bigint")}var F9=($)=>$===0||$===0n,x9=($,q)=>q===1||q===1n?$:`${$}s`,j9=0.0000001,M9=24n*60n*60n*1000n;function b2($,q){let J=typeof $==="bigint";if(!J&&!Number.isFinite($))throw TypeError("Expected a finite number or bigint");q={...q};let X=$<0?"-":"";if($=$<0?-$:$,q.colonNotation)q.compact=!1,q.formatSubMilliseconds=!1,q.separateMilliseconds=!1,q.verbose=!1;if(q.compact)q.unitCount=1,q.secondsDecimalDigits=0,q.millisecondsDecimalDigits=0;let Z=[],H=(U,z)=>{let B=Math.floor(U*10**z+j9);return(Math.round(B)/10**z).toFixed(z)},Q=(U,z,B,L)=>{if((Z.length===0||!q.colonNotation)&&F9(U)&&!(q.colonNotation&&B==="m"))return;if(L??=String(U),q.colonNotation){let W=L.includes(".")?L.split(".")[0].length:L.length,P=Z.length>0?2:1;L="0".repeat(Math.max(0,P-W))+L}else L+=q.verbose?" "+x9(z,U):B;Z.push(L)},Y=S2($),G=BigInt(Y.days);if(q.hideYearAndDays)Q(BigInt(G)*24n+BigInt(Y.hours),"hour","h");else{if(q.hideYear)Q(G,"day","d");else Q(G/365n,"year","y"),Q(G%365n,"day","d");Q(Number(Y.hours),"hour","h")}if(Q(Number(Y.minutes),"minute","m"),!q.hideSeconds)if(q.separateMilliseconds||q.formatSubMilliseconds||!q.colonNotation&&$<1000&&!q.subSecondsAsDecimals){let U=Number(Y.seconds),z=Number(Y.milliseconds),B=Number(Y.microseconds),L=Number(Y.nanoseconds);if(Q(U,"second","s"),q.formatSubMilliseconds)Q(z,"millisecond","ms"),Q(B,"microsecond","µs"),Q(L,"nanosecond","ns");else{let W=z+B/1000+L/1e6,P=typeof q.millisecondsDecimalDigits==="number"?q.millisecondsDecimalDigits:0,M=W>=1?Math.round(W):Math.ceil(W),F=P?W.toFixed(P):M;Q(Number.parseFloat(F),"millisecond","ms",F)}}else{let U=(J?Number($%M9):$)/1000%60,z=typeof q.secondsDecimalDigits==="number"?q.secondsDecimalDigits:1,B=H(U,z),L=q.keepDecimalsOnWholeSeconds?B:B.replace(/\.0+$/,"");Q(Number.parseFloat(L),"second","s",L)}if(Z.length===0)return X+"0"+(q.verbose?" milliseconds":"ms");let K=q.colonNotation?":":" ";if(typeof q.unitCount==="number")Z=Z.slice(0,Math.max(q.unitCount,1));return X+Z.join(K)}var M7=($,q)=>{if($.failed)o({type:"error",verboseMessage:$.shortMessage,verboseInfo:q,result:$})};var C7=($,q)=>{if(!A1(q))return;M7($,q),C9($,q)},C9=($,q)=>{let J=`(done in ${b2($.durationMs)})`;o({type:"duration",verboseMessage:J,verboseInfo:q,result:$})};var b1=($,q,{reject:J})=>{if(C7($,q),$.failed&&J)throw $;return $};import{readFileSync as s7}from"node:fs";var A7=($,q)=>{if(k1($))return"asyncGenerator";if(O7($))return"generator";if(G$($))return"fileUrl";if(y9($))return"filePath";if(D9($))return"webStream";if(n($,{checkOpen:!1}))return"native";if(D($))return"uint8Array";if(v9($))return"asyncIterable";if(f9($))return"iterable";if(m2($))return E7({transform:$},q);if(E9($))return I9($,q);return"native"},I9=($,q)=>{if(v2($.transform,{checkOpen:!1}))return w9($,q);if(m2($.transform))return E7($,q);return A9($,q)},w9=($,q)=>{return y7($,q,"Duplex stream"),"duplex"},E7=($,q)=>{return y7($,q,"web TransformStream"),"webTransform"},y7=({final:$,binary:q,objectMode:J},X,Z)=>{I7($,`${X}.final`,Z),I7(q,`${X}.binary`,Z),g2(J,`${X}.objectMode`)},I7=($,q,J)=>{if($!==void 0)throw TypeError(`The \`${q}\` option can only be defined when using a generator, not a ${J}.`)},A9=({transform:$,final:q,binary:J,objectMode:X},Z)=>{if($!==void 0&&!w7($))throw TypeError(`The \`${Z}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(v2(q,{checkOpen:!1}))throw TypeError(`The \`${Z}.final\` option must not be a Duplex stream.`);if(m2(q))throw TypeError(`The \`${Z}.final\` option must not be a web TransformStream.`);if(q!==void 0&&!w7(q))throw TypeError(`The \`${Z}.final\` option must be a generator.`);return g2(J,`${Z}.binary`),g2(X,`${Z}.objectMode`),k1($)||k1(q)?"asyncGenerator":"generator"},g2=($,q)=>{if($!==void 0&&typeof $!=="boolean")throw TypeError(`The \`${q}\` option must use a boolean.`)},w7=($)=>k1($)||O7($),k1=($)=>Object.prototype.toString.call($)==="[object AsyncGeneratorFunction]",O7=($)=>Object.prototype.toString.call($)==="[object GeneratorFunction]",E9=($)=>E($)&&($.transform!==void 0||$.final!==void 0),G$=($)=>Object.prototype.toString.call($)==="[object URL]",N7=($)=>G$($)&&$.protocol!=="file:",y9=($)=>E($)&&Object.keys($).length>0&&Object.keys($).every((q)=>O9.has(q))&&c2($.file),O9=new Set(["file","append"]),c2=($)=>typeof $==="string",D7=($,q)=>$==="native"&&typeof q==="string"&&!N9.has(q),N9=new Set(["ipc","ignore","inherit","overlapped","pipe"]),v7=($)=>Object.prototype.toString.call($)==="[object ReadableStream]",K$=($)=>Object.prototype.toString.call($)==="[object WritableStream]",D9=($)=>v7($)||K$($),m2=($)=>v7($?.readable)&&K$($?.writable),v9=($)=>f7($)&&typeof $[Symbol.asyncIterator]==="function",f9=($)=>f7($)&&typeof $[Symbol.iterator]==="function",f7=($)=>typeof $==="object"&&$!==null,l=new Set(["generator","asyncGenerator","duplex","webTransform"]),U$=new Set(["fileUrl","filePath","fileNumber"]),u2=new Set(["fileUrl","filePath"]),h7=new Set([...u2,"webStream","nodeStream"]),S7=new Set(["webTransform","duplex"]),L1={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"};var p2=($,q,J,X)=>X==="output"?h9($,q,J):S9($,q,J),h9=($,q,J)=>{let X=q!==0&&J[q-1].value.readableObjectMode;return{writableObjectMode:X,readableObjectMode:$??X}},S9=($,q,J)=>{let X=q===0?$===!0:J[q-1].value.readableObjectMode,Z=q!==J.length-1&&($??X);return{writableObjectMode:X,readableObjectMode:Z}},b7=($,q)=>{let J=$.findLast(({type:X})=>l.has(X));if(J===void 0)return!1;return q==="input"?J.value.writableObjectMode:J.value.readableObjectMode};var g7=($,q,J,X)=>[...$.filter(({type:Z})=>!l.has(Z)),...b9($,q,J,X)],b9=($,q,J,{encoding:X})=>{let Z=$.filter(({type:Q})=>l.has(Q)),H=Array.from({length:Z.length});for(let[Q,Y]of Object.entries(Z))H[Q]=g9({stdioItem:Y,index:Number(Q),newTransforms:H,optionName:q,direction:J,encoding:X});return p9(H,J)},g9=({stdioItem:$,stdioItem:{type:q},index:J,newTransforms:X,optionName:Z,direction:H,encoding:Q})=>{if(q==="duplex")return c9({stdioItem:$,optionName:Z});if(q==="webTransform")return m9({stdioItem:$,index:J,newTransforms:X,direction:H});return u9({stdioItem:$,index:J,newTransforms:X,direction:H,encoding:Q})},c9=({stdioItem:$,stdioItem:{value:{transform:q,transform:{writableObjectMode:J,readableObjectMode:X},objectMode:Z=X}},optionName:H})=>{if(Z&&!X)throw TypeError(`The \`${H}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!Z&&X)throw TypeError(`The \`${H}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...$,value:{transform:q,writableObjectMode:J,readableObjectMode:X}}},m9=({stdioItem:$,stdioItem:{value:q},index:J,newTransforms:X,direction:Z})=>{let{transform:H,objectMode:Q}=E(q)?q:{transform:q},{writableObjectMode:Y,readableObjectMode:G}=p2(Q,J,X,Z);return{...$,value:{transform:H,writableObjectMode:Y,readableObjectMode:G}}},u9=({stdioItem:$,stdioItem:{value:q},index:J,newTransforms:X,direction:Z,encoding:H})=>{let{transform:Q,final:Y,binary:G=!1,preserveNewlines:K=!1,objectMode:U}=E(q)?q:{transform:q},z=G||m.has(H),{writableObjectMode:B,readableObjectMode:L}=p2(U,J,X,Z);return{...$,value:{transform:Q,final:Y,binary:z,preserveNewlines:K,writableObjectMode:B,readableObjectMode:L}}},p9=($,q)=>q==="input"?$.reverse():$;import l2 from"node:process";var c7=($,q,J)=>{let X=$.map((Z)=>l9(Z,q));if(X.includes("input")&&X.includes("output"))throw TypeError(`The \`${J}\` option must not be an array of both readable and writable values.`);return X.find(Boolean)??n9},l9=({type:$,value:q},J)=>d9[J]??m7[$](q),d9=["input","output","output"],g1=()=>{return},d2=()=>"input",m7={generator:g1,asyncGenerator:g1,fileUrl:g1,filePath:g1,iterable:d2,asyncIterable:d2,uint8Array:d2,webStream:($)=>K$($)?"output":"input",nodeStream($){if(!P1($,{checkOpen:!1}))return"output";return D2($,{checkOpen:!1})?void 0:"input"},webTransform:g1,duplex:g1,native($){let q=i9($);if(q!==void 0)return q;if(n($,{checkOpen:!1}))return m7.nodeStream($)}},i9=($)=>{if([0,l2.stdin].includes($))return"input";if([1,2,l2.stdout,l2.stderr].includes($))return"output"},n9="output";var u7=($,q)=>q&&!$.includes("ipc")?[...$,"ipc"]:$;var p7=({stdio:$,ipc:q,buffer:J,...X},Z,H)=>{let Q=a9($,X).map((Y,G)=>l7(Y,G));return H?o9(Q,J,Z):u7(Q,q)},a9=($,q)=>{if($===void 0)return p.map((X)=>q[X]);if(t9(q))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${p.map((X)=>`\`${X}\``).join(", ")}`);if(typeof $==="string")return[$,$,$];if(!Array.isArray($))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof $}\``);let J=Math.max($.length,p.length);return Array.from({length:J},(X,Z)=>$[Z])},t9=($)=>p.some((q)=>$[q]!==void 0),l7=($,q)=>{if(Array.isArray($))return $.map((J)=>l7(J,q));if($===null||$===void 0)return q>=p.length?"ignore":"pipe";return $},o9=($,q,J)=>$.map((X,Z)=>!q[Z]&&Z!==0&&!E1(J,Z)&&r9(X)?"ignore":X),r9=($)=>$==="pipe"||Array.isArray($)&&$.every((q)=>q==="pipe");import{readFileSync as s9}from"node:fs";import e9 from"node:tty";var i7=({stdioItem:$,stdioItem:{type:q},isStdioArray:J,fdNumber:X,direction:Z,isSync:H})=>{if(!J||q!=="native")return $;return H?$Y({stdioItem:$,fdNumber:X,direction:Z}):XY({stdioItem:$,fdNumber:X})},$Y=({stdioItem:$,stdioItem:{value:q,optionName:J},fdNumber:X,direction:Z})=>{let H=qY({value:q,optionName:J,fdNumber:X,direction:Z});if(H!==void 0)return H;if(n(q,{checkOpen:!1}))throw TypeError(`The \`${J}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return $},qY=({value:$,optionName:q,fdNumber:J,direction:X})=>{let Z=JY($,J);if(Z===void 0)return;if(X==="output")return{type:"fileNumber",value:Z,optionName:q};if(e9.isatty(Z))throw TypeError(`The \`${q}: ${g0($)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:Z1(s9(Z)),optionName:q}},JY=($,q)=>{if($==="inherit")return q;if(typeof $==="number")return $;let J=P0.indexOf($);if(J!==-1)return J},XY=({stdioItem:$,stdioItem:{value:q,optionName:J},fdNumber:X})=>{if(q==="inherit")return{type:"nodeStream",value:d7(X,q,J),optionName:J};if(typeof q==="number")return{type:"nodeStream",value:d7(q,q,J),optionName:J};if(n(q,{checkOpen:!1}))return{type:"nodeStream",value:q,optionName:J};return $},d7=($,q,J)=>{let X=P0[$];if(X===void 0)throw TypeError(`The \`${J}: ${q}\` option is invalid: no such standard stream.`);return X};var n7=({input:$,inputFile:q},J)=>J===0?[...ZY($),...HY(q)]:[],ZY=($)=>$===void 0?[]:[{type:QY($),value:$,optionName:"input"}],QY=($)=>{if(P1($,{checkOpen:!1}))return"nodeStream";if(typeof $==="string")return"string";if(D($))return"uint8Array";throw Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},HY=($)=>$===void 0?[]:[{...YY($),optionName:"inputFile"}],YY=($)=>{if(G$($))return{type:"fileUrl",value:$};if(c2($))return{type:"filePath",value:{file:$}};throw Error("The `inputFile` option must be a file path string or a file URL.")};var a7=($)=>$.filter((q,J)=>$.every((X,Z)=>q.value!==X.value||J>=Z||q.type==="generator"||q.type==="asyncGenerator")),t7=({stdioItem:{type:$,value:q,optionName:J},direction:X,fileDescriptors:Z,isSync:H})=>{let Q=GY(Z,$);if(Q.length===0)return;if(H){KY({otherStdioItems:Q,type:$,value:q,optionName:J,direction:X});return}if(h7.has($))return o7({otherStdioItems:Q,type:$,value:q,optionName:J,direction:X});if(S7.has($))zY({otherStdioItems:Q,type:$,value:q,optionName:J})},GY=($,q)=>$.flatMap(({direction:J,stdioItems:X})=>X.filter((Z)=>Z.type===q).map((Z)=>({...Z,direction:J}))),KY=({otherStdioItems:$,type:q,value:J,optionName:X,direction:Z})=>{if(u2.has(q))o7({otherStdioItems:$,type:q,value:J,optionName:X,direction:Z})},o7=({otherStdioItems:$,type:q,value:J,optionName:X,direction:Z})=>{let H=$.filter((Y)=>UY(Y,J));if(H.length===0)return;let Q=H.find((Y)=>Y.direction!==Z);return r7(Q,X,q),Z==="output"?H[0].stream:void 0},UY=({type:$,value:q},J)=>{if($==="filePath")return q.file===J.file;if($==="fileUrl")return q.href===J.href;return q===J},zY=({otherStdioItems:$,type:q,value:J,optionName:X})=>{let Z=$.find(({value:{transform:H}})=>H===J.transform);r7(Z,X,q)},r7=($,q,J)=>{if($!==void 0)throw TypeError(`The \`${$.optionName}\` and \`${q}\` options must not target ${L1[J]} that is the same.`)};var z$=($,q,J,X)=>{let H=p7(q,J,X).map((Y,G)=>BY({stdioOption:Y,fdNumber:G,options:q,isSync:X})),Q=kY({initialFileDescriptors:H,addProperties:$,options:q,isSync:X});return q.stdio=Q.map(({stdioItems:Y})=>jY(Y)),Q},BY=({stdioOption:$,fdNumber:q,options:J,isSync:X})=>{let Z=k0(q),{stdioItems:H,isStdioArray:Q}=LY({stdioOption:$,fdNumber:q,options:J,optionName:Z}),Y=c7(H,q,Z),G=H.map((z)=>i7({stdioItem:z,isStdioArray:Q,fdNumber:q,direction:Y,isSync:X})),K=g7(G,Z,Y,J),U=b7(K,Y);return PY(K,U),{direction:Y,objectMode:U,stdioItems:K}},LY=({stdioOption:$,fdNumber:q,options:J,optionName:X})=>{let H=[...(Array.isArray($)?$:[$]).map((G)=>_Y(G,X)),...n7(J,q)],Q=a7(H),Y=Q.length>1;return VY(Q,Y,X),WY(Q),{stdioItems:Q,isStdioArray:Y}},_Y=($,q)=>({type:A7($,q),value:$,optionName:q}),VY=($,q,J)=>{if($.length===0)throw TypeError(`The \`${J}\` option must not be an empty array.`);if(!q)return;for(let{value:X,optionName:Z}of $)if(RY.has(X))throw Error(`The \`${Z}\` option must not include \`${X}\`.`)},RY=new Set(["ignore","ipc"]),WY=($)=>{for(let q of $)TY(q)},TY=({type:$,value:q,optionName:J})=>{if(N7(q))throw TypeError(`The \`${J}: URL\` option must use the \`file:\` scheme.
|
|
63
|
-
For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(
|
|
64
|
-
`){let Q=
|
|
61
|
+
`);return{originalMessage:x,shortMessage:N,message:B1}},MH=({originalError:$,timedOut:q,timeout:J,isMaxBuffer:X,maxBuffer:Z,errorCode:H,signal:Q,signalDescription:Y,exitCode:G,isCanceled:K,isGracefullyCanceled:U,isForcefullyTerminated:z,forceKillAfterDelay:B,killSignal:L})=>{let _=CH(z,B);if(q)return`Command timed out after ${J} milliseconds${_}`;if(U){if(Q===void 0)return`Command was gracefully canceled with exit code ${G}`;return z?`Command was gracefully canceled${_}`:`Command was gracefully canceled with ${Q} (${Y})`}if(K)return`Command was canceled${_}`;if(X)return`${M7($,Z)}${_}`;if(H!==void 0)return`Command failed with ${H}${_}`;if(z)return`Command was killed with ${L} (${u0(L)})${_}`;if(Q!==void 0)return`Command was killed with ${Q} (${Y})`;if(G!==void 0)return`Command failed with exit code ${G}`;return"Command failed"},CH=($,q)=>$?` and was forcefully terminated after ${q} milliseconds`:"",wH=($,q)=>{if($ instanceof s)return;let J=X8($)?$.originalMessage:String($?.message??$),X=q0(Q7(J,q));return X===""?void 0:X},IH=($)=>typeof $==="string"?$:jH($),AH=($)=>Array.isArray($)?$.map((q)=>m1(I7(q))).filter(Boolean).join(`
|
|
62
|
+
`):I7($),I7=($)=>{if(typeof $==="string")return $;if(D($))return M0($);return""};var L$=({command:$,escapedCommand:q,stdio:J,all:X,ipcOutput:Z,options:{cwd:H},startTime:Q})=>E7({command:$,escapedCommand:q,cwd:H,durationMs:F2(Q),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:J[1],stderr:J[2],all:X,stdio:J,ipcOutput:Z,pipedFrom:[]}),p1=({error:$,command:q,escapedCommand:J,fileDescriptors:X,options:Z,startTime:H,isSync:Q})=>Y0({error:$,command:q,escapedCommand:J,startTime:H,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:X.length}),ipcOutput:[],options:Z,isSync:Q}),Y0=({error:$,command:q,escapedCommand:J,startTime:X,timedOut:Z,isCanceled:H,isGracefullyCanceled:Q,isMaxBuffer:Y,isForcefullyTerminated:G,exitCode:K,signal:U,stdio:z,all:B,ipcOutput:L,options:{timeoutDuration:_,timeout:P=_,forceKillAfterDelay:M,killSignal:F,cwd:O,maxBuffer:v},isSync:x})=>{let{exitCode:I,signal:N,signalDescription:c}=yH(K,U),{originalMessage:B1,shortMessage:L1,message:q2}=A7({stdio:z,all:B,ipcOutput:L,originalError:$,signal:N,signalDescription:c,exitCode:I,escapedCommand:J,timedOut:Z,isCanceled:H,isGracefullyCanceled:Q,isMaxBuffer:Y,isForcefullyTerminated:G,forceKillAfterDelay:M,killSignal:F,maxBuffer:v,timeout:P,cwd:O}),s1=q8($,q2,x);return Object.assign(s1,EH({error:s1,command:q,escapedCommand:J,startTime:X,timedOut:Z,isCanceled:H,isGracefullyCanceled:Q,isMaxBuffer:Y,isForcefullyTerminated:G,exitCode:I,signal:N,signalDescription:c,stdio:z,all:B,ipcOutput:L,cwd:O,originalMessage:B1,shortMessage:L1})),s1},EH=({error:$,command:q,escapedCommand:J,startTime:X,timedOut:Z,isCanceled:H,isGracefullyCanceled:Q,isMaxBuffer:Y,isForcefullyTerminated:G,exitCode:K,signal:U,signalDescription:z,stdio:B,all:L,ipcOutput:_,cwd:P,originalMessage:M,shortMessage:F})=>E7({shortMessage:F,originalMessage:M,command:q,escapedCommand:J,cwd:P,durationMs:F2(X),failed:!0,timedOut:Z,isCanceled:H,isGracefullyCanceled:Q,isTerminated:U!==void 0,isMaxBuffer:Y,isForcefullyTerminated:G,exitCode:K,signal:U,signalDescription:z,code:$.cause?.code,stdout:B[1],stderr:B[2],all:L,stdio:B,ipcOutput:_,pipedFrom:[]}),E7=($)=>Object.fromEntries(Object.entries($).filter(([,q])=>q!==void 0)),yH=($,q)=>{let J=$===null?void 0:$,X=q===null?void 0:q,Z=X===void 0?void 0:u0(q);return{exitCode:J,signal:X,signalDescription:Z}};var y7=($)=>Number.isFinite($)?$:0;function OH($){return{days:Math.trunc($/86400000),hours:Math.trunc($/3600000%24),minutes:Math.trunc($/60000%60),seconds:Math.trunc($/1000%60),milliseconds:Math.trunc($%1000),microseconds:Math.trunc(y7($*1000)%1000),nanoseconds:Math.trunc(y7($*1e6)%1000)}}function NH($){return{days:$/86400000n,hours:$/3600000n%24n,minutes:$/60000n%60n,seconds:$/1000n%60n,milliseconds:$%1000n,microseconds:0n,nanoseconds:0n}}function n2($){switch(typeof $){case"number":{if(Number.isFinite($))return OH($);break}case"bigint":return NH($)}throw TypeError("Expected a finite number or bigint")}var DH=($)=>$===0||$===0n,vH=($,q)=>q===1||q===1n?$:`${$}s`,hH=0.0000001,fH=24n*60n*60n*1000n;function a2($,q){let J=typeof $==="bigint";if(!J&&!Number.isFinite($))throw TypeError("Expected a finite number or bigint");q={...q};let X=$<0?"-":"";if($=$<0?-$:$,q.colonNotation)q.compact=!1,q.formatSubMilliseconds=!1,q.separateMilliseconds=!1,q.verbose=!1;if(q.compact)q.unitCount=1,q.secondsDecimalDigits=0,q.millisecondsDecimalDigits=0;let Z=[],H=(U,z)=>{let B=Math.floor(U*10**z+hH);return(Math.round(B)/10**z).toFixed(z)},Q=(U,z,B,L)=>{if((Z.length===0||!q.colonNotation)&&DH(U)&&!(q.colonNotation&&B==="m"))return;if(L??=String(U),q.colonNotation){let _=L.includes(".")?L.split(".")[0].length:L.length,P=Z.length>0?2:1;L="0".repeat(Math.max(0,P-_))+L}else L+=q.verbose?" "+vH(z,U):B;Z.push(L)},Y=n2($),G=BigInt(Y.days);if(q.hideYearAndDays)Q(BigInt(G)*24n+BigInt(Y.hours),"hour","h");else{if(q.hideYear)Q(G,"day","d");else Q(G/365n,"year","y"),Q(G%365n,"day","d");Q(Number(Y.hours),"hour","h")}if(Q(Number(Y.minutes),"minute","m"),!q.hideSeconds)if(q.separateMilliseconds||q.formatSubMilliseconds||!q.colonNotation&&$<1000&&!q.subSecondsAsDecimals){let U=Number(Y.seconds),z=Number(Y.milliseconds),B=Number(Y.microseconds),L=Number(Y.nanoseconds);if(Q(U,"second","s"),q.formatSubMilliseconds)Q(z,"millisecond","ms"),Q(B,"microsecond","µs"),Q(L,"nanosecond","ns");else{let _=z+B/1000+L/1e6,P=typeof q.millisecondsDecimalDigits==="number"?q.millisecondsDecimalDigits:0,M=_>=1?Math.round(_):Math.ceil(_),F=P?_.toFixed(P):M;Q(Number.parseFloat(F),"millisecond","ms",F)}}else{let U=(J?Number($%fH):$)/1000%60,z=typeof q.secondsDecimalDigits==="number"?q.secondsDecimalDigits:1,B=H(U,z),L=q.keepDecimalsOnWholeSeconds?B:B.replace(/\.0+$/,"");Q(Number.parseFloat(L),"second","s",L)}if(Z.length===0)return X+"0"+(q.verbose?" milliseconds":"ms");let K=q.colonNotation?":":" ";if(typeof q.unitCount==="number")Z=Z.slice(0,Math.max(q.unitCount,1));return X+Z.join(K)}var O7=($,q)=>{if($.failed)r({type:"error",verboseMessage:$.shortMessage,verboseInfo:q,result:$})};var N7=($,q)=>{if(!v1(q))return;O7($,q),SH($,q)},SH=($,q)=>{let J=`(done in ${a2($.durationMs)})`;r({type:"duration",verboseMessage:J,verboseInfo:q,result:$})};var l1=($,q,{reject:J})=>{if(N7($,q),$.failed&&J)throw $;return $};import{readFileSync as Q5}from"node:fs";var h7=($,q)=>{if(j1($))return"asyncGenerator";if(b7($))return"generator";if(V$($))return"fileUrl";if(uH($))return"filePath";if(dH($))return"webStream";if(a($,{checkOpen:!1}))return"native";if(D($))return"uint8Array";if(iH($))return"asyncIterable";if(nH($))return"iterable";if(r2($))return f7({transform:$},q);if(mH($))return bH($,q);return"native"},bH=($,q)=>{if(l2($.transform,{checkOpen:!1}))return gH($,q);if(r2($.transform))return f7($,q);return cH($,q)},gH=($,q)=>{return S7($,q,"Duplex stream"),"duplex"},f7=($,q)=>{return S7($,q,"web TransformStream"),"webTransform"},S7=({final:$,binary:q,objectMode:J},X,Z)=>{D7($,`${X}.final`,Z),D7(q,`${X}.binary`,Z),t2(J,`${X}.objectMode`)},D7=($,q,J)=>{if($!==void 0)throw TypeError(`The \`${q}\` option can only be defined when using a generator, not a ${J}.`)},cH=({transform:$,final:q,binary:J,objectMode:X},Z)=>{if($!==void 0&&!v7($))throw TypeError(`The \`${Z}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(l2(q,{checkOpen:!1}))throw TypeError(`The \`${Z}.final\` option must not be a Duplex stream.`);if(r2(q))throw TypeError(`The \`${Z}.final\` option must not be a web TransformStream.`);if(q!==void 0&&!v7(q))throw TypeError(`The \`${Z}.final\` option must be a generator.`);return t2(J,`${Z}.binary`),t2(X,`${Z}.objectMode`),j1($)||j1(q)?"asyncGenerator":"generator"},t2=($,q)=>{if($!==void 0&&typeof $!=="boolean")throw TypeError(`The \`${q}\` option must use a boolean.`)},v7=($)=>j1($)||b7($),j1=($)=>Object.prototype.toString.call($)==="[object AsyncGeneratorFunction]",b7=($)=>Object.prototype.toString.call($)==="[object GeneratorFunction]",mH=($)=>E($)&&($.transform!==void 0||$.final!==void 0),V$=($)=>Object.prototype.toString.call($)==="[object URL]",g7=($)=>V$($)&&$.protocol!=="file:",uH=($)=>E($)&&Object.keys($).length>0&&Object.keys($).every((q)=>pH.has(q))&&o2($.file),pH=new Set(["file","append"]),o2=($)=>typeof $==="string",c7=($,q)=>$==="native"&&typeof q==="string"&&!lH.has(q),lH=new Set(["ipc","ignore","inherit","overlapped","pipe"]),m7=($)=>Object.prototype.toString.call($)==="[object ReadableStream]",W$=($)=>Object.prototype.toString.call($)==="[object WritableStream]",dH=($)=>m7($)||W$($),r2=($)=>m7($?.readable)&&W$($?.writable),iH=($)=>u7($)&&typeof $[Symbol.asyncIterator]==="function",nH=($)=>u7($)&&typeof $[Symbol.iterator]==="function",u7=($)=>typeof $==="object"&&$!==null,d=new Set(["generator","asyncGenerator","duplex","webTransform"]),_$=new Set(["fileUrl","filePath","fileNumber"]),s2=new Set(["fileUrl","filePath"]),p7=new Set([...s2,"webStream","nodeStream"]),l7=new Set(["webTransform","duplex"]),_1={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"};var e2=($,q,J,X)=>X==="output"?aH($,q,J):tH($,q,J),aH=($,q,J)=>{let X=q!==0&&J[q-1].value.readableObjectMode;return{writableObjectMode:X,readableObjectMode:$??X}},tH=($,q,J)=>{let X=q===0?$===!0:J[q-1].value.readableObjectMode,Z=q!==J.length-1&&($??X);return{writableObjectMode:X,readableObjectMode:Z}},d7=($,q)=>{let J=$.findLast(({type:X})=>d.has(X));if(J===void 0)return!1;return q==="input"?J.value.writableObjectMode:J.value.readableObjectMode};var i7=($,q,J,X)=>[...$.filter(({type:Z})=>!d.has(Z)),...oH($,q,J,X)],oH=($,q,J,{encoding:X})=>{let Z=$.filter(({type:Q})=>d.has(Q)),H=Array.from({length:Z.length});for(let[Q,Y]of Object.entries(Z))H[Q]=rH({stdioItem:Y,index:Number(Q),newTransforms:H,optionName:q,direction:J,encoding:X});return qY(H,J)},rH=({stdioItem:$,stdioItem:{type:q},index:J,newTransforms:X,optionName:Z,direction:H,encoding:Q})=>{if(q==="duplex")return sH({stdioItem:$,optionName:Z});if(q==="webTransform")return eH({stdioItem:$,index:J,newTransforms:X,direction:H});return $Y({stdioItem:$,index:J,newTransforms:X,direction:H,encoding:Q})},sH=({stdioItem:$,stdioItem:{value:{transform:q,transform:{writableObjectMode:J,readableObjectMode:X},objectMode:Z=X}},optionName:H})=>{if(Z&&!X)throw TypeError(`The \`${H}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!Z&&X)throw TypeError(`The \`${H}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...$,value:{transform:q,writableObjectMode:J,readableObjectMode:X}}},eH=({stdioItem:$,stdioItem:{value:q},index:J,newTransforms:X,direction:Z})=>{let{transform:H,objectMode:Q}=E(q)?q:{transform:q},{writableObjectMode:Y,readableObjectMode:G}=e2(Q,J,X,Z);return{...$,value:{transform:H,writableObjectMode:Y,readableObjectMode:G}}},$Y=({stdioItem:$,stdioItem:{value:q},index:J,newTransforms:X,direction:Z,encoding:H})=>{let{transform:Q,final:Y,binary:G=!1,preserveNewlines:K=!1,objectMode:U}=E(q)?q:{transform:q},z=G||u.has(H),{writableObjectMode:B,readableObjectMode:L}=e2(U,J,X,Z);return{...$,value:{transform:Q,final:Y,binary:z,preserveNewlines:K,writableObjectMode:B,readableObjectMode:L}}},qY=($,q)=>q==="input"?$.reverse():$;import $4 from"node:process";var n7=($,q,J)=>{let X=$.map((Z)=>JY(Z,q));if(X.includes("input")&&X.includes("output"))throw TypeError(`The \`${J}\` option must not be an array of both readable and writable values.`);return X.find(Boolean)??QY},JY=({type:$,value:q},J)=>XY[J]??a7[$](q),XY=["input","output","output"],d1=()=>{return},q4=()=>"input",a7={generator:d1,asyncGenerator:d1,fileUrl:d1,filePath:d1,iterable:q4,asyncIterable:q4,uint8Array:q4,webStream:($)=>W$($)?"output":"input",nodeStream($){if(!x1($,{checkOpen:!1}))return"output";return p2($,{checkOpen:!1})?void 0:"input"},webTransform:d1,duplex:d1,native($){let q=ZY($);if(q!==void 0)return q;if(a($,{checkOpen:!1}))return a7.nodeStream($)}},ZY=($)=>{if([0,$4.stdin].includes($))return"input";if([1,2,$4.stdout,$4.stderr].includes($))return"output"},QY="output";var t7=($,q)=>q&&!$.includes("ipc")?[...$,"ipc"]:$;var o7=({stdio:$,ipc:q,buffer:J,...X},Z,H)=>{let Q=HY($,X).map((Y,G)=>r7(Y,G));return H?GY(Q,J,Z):t7(Q,q)},HY=($,q)=>{if($===void 0)return l.map((X)=>q[X]);if(YY(q))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${l.map((X)=>`\`${X}\``).join(", ")}`);if(typeof $==="string")return[$,$,$];if(!Array.isArray($))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof $}\``);let J=Math.max($.length,l.length);return Array.from({length:J},(X,Z)=>$[Z])},YY=($)=>l.some((q)=>$[q]!==void 0),r7=($,q)=>{if(Array.isArray($))return $.map((J)=>r7(J,q));if($===null||$===void 0)return q>=l.length?"ignore":"pipe";return $},GY=($,q,J)=>$.map((X,Z)=>!q[Z]&&Z!==0&&!h1(J,Z)&&KY(X)?"ignore":X),KY=($)=>$==="pipe"||Array.isArray($)&&$.every((q)=>q==="pipe");import{readFileSync as UY}from"node:fs";import zY from"node:tty";var e7=({stdioItem:$,stdioItem:{type:q},isStdioArray:J,fdNumber:X,direction:Z,isSync:H})=>{if(!J||q!=="native")return $;return H?BY({stdioItem:$,fdNumber:X,direction:Z}):WY({stdioItem:$,fdNumber:X})},BY=({stdioItem:$,stdioItem:{value:q,optionName:J},fdNumber:X,direction:Z})=>{let H=LY({value:q,optionName:J,fdNumber:X,direction:Z});if(H!==void 0)return H;if(a(q,{checkOpen:!1}))throw TypeError(`The \`${J}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return $},LY=({value:$,optionName:q,fdNumber:J,direction:X})=>{let Z=VY($,J);if(Z===void 0)return;if(X==="output")return{type:"fileNumber",value:Z,optionName:q};if(zY.isatty(Z))throw TypeError(`The \`${q}: ${d0($)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:H1(UY(Z)),optionName:q}},VY=($,q)=>{if($==="inherit")return q;if(typeof $==="number")return $;let J=C0.indexOf($);if(J!==-1)return J},WY=({stdioItem:$,stdioItem:{value:q,optionName:J},fdNumber:X})=>{if(q==="inherit")return{type:"nodeStream",value:s7(X,q,J),optionName:J};if(typeof q==="number")return{type:"nodeStream",value:s7(q,q,J),optionName:J};if(a(q,{checkOpen:!1}))return{type:"nodeStream",value:q,optionName:J};return $},s7=($,q,J)=>{let X=C0[$];if(X===void 0)throw TypeError(`The \`${J}: ${q}\` option is invalid: no such standard stream.`);return X};var $5=({input:$,inputFile:q},J)=>J===0?[..._Y($),...TY(q)]:[],_Y=($)=>$===void 0?[]:[{type:RY($),value:$,optionName:"input"}],RY=($)=>{if(x1($,{checkOpen:!1}))return"nodeStream";if(typeof $==="string")return"string";if(D($))return"uint8Array";throw Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},TY=($)=>$===void 0?[]:[{...PY($),optionName:"inputFile"}],PY=($)=>{if(V$($))return{type:"fileUrl",value:$};if(o2($))return{type:"filePath",value:{file:$}};throw Error("The `inputFile` option must be a file path string or a file URL.")};var q5=($)=>$.filter((q,J)=>$.every((X,Z)=>q.value!==X.value||J>=Z||q.type==="generator"||q.type==="asyncGenerator")),J5=({stdioItem:{type:$,value:q,optionName:J},direction:X,fileDescriptors:Z,isSync:H})=>{let Q=kY(Z,$);if(Q.length===0)return;if(H){FY({otherStdioItems:Q,type:$,value:q,optionName:J,direction:X});return}if(p7.has($))return X5({otherStdioItems:Q,type:$,value:q,optionName:J,direction:X});if(l7.has($))jY({otherStdioItems:Q,type:$,value:q,optionName:J})},kY=($,q)=>$.flatMap(({direction:J,stdioItems:X})=>X.filter((Z)=>Z.type===q).map((Z)=>({...Z,direction:J}))),FY=({otherStdioItems:$,type:q,value:J,optionName:X,direction:Z})=>{if(s2.has(q))X5({otherStdioItems:$,type:q,value:J,optionName:X,direction:Z})},X5=({otherStdioItems:$,type:q,value:J,optionName:X,direction:Z})=>{let H=$.filter((Y)=>xY(Y,J));if(H.length===0)return;let Q=H.find((Y)=>Y.direction!==Z);return Z5(Q,X,q),Z==="output"?H[0].stream:void 0},xY=({type:$,value:q},J)=>{if($==="filePath")return q.file===J.file;if($==="fileUrl")return q.href===J.href;return q===J},jY=({otherStdioItems:$,type:q,value:J,optionName:X})=>{let Z=$.find(({value:{transform:H}})=>H===J.transform);Z5(Z,X,q)},Z5=($,q,J)=>{if($!==void 0)throw TypeError(`The \`${$.optionName}\` and \`${q}\` options must not target ${_1[J]} that is the same.`)};var R$=($,q,J,X)=>{let H=o7(q,J,X).map((Y,G)=>MY({stdioOption:Y,fdNumber:G,options:q,isSync:X})),Q=NY({initialFileDescriptors:H,addProperties:$,options:q,isSync:X});return q.stdio=Q.map(({stdioItems:Y})=>hY(Y)),Q},MY=({stdioOption:$,fdNumber:q,options:J,isSync:X})=>{let Z=w0(q),{stdioItems:H,isStdioArray:Q}=CY({stdioOption:$,fdNumber:q,options:J,optionName:Z}),Y=n7(H,q,Z),G=H.map((z)=>e7({stdioItem:z,isStdioArray:Q,fdNumber:q,direction:Y,isSync:X})),K=i7(G,Z,Y,J),U=d7(K,Y);return OY(K,U),{direction:Y,objectMode:U,stdioItems:K}},CY=({stdioOption:$,fdNumber:q,options:J,optionName:X})=>{let H=[...(Array.isArray($)?$:[$]).map((G)=>wY(G,X)),...$5(J,q)],Q=q5(H),Y=Q.length>1;return IY(Q,Y,X),EY(Q),{stdioItems:Q,isStdioArray:Y}},wY=($,q)=>({type:h7($,q),value:$,optionName:q}),IY=($,q,J)=>{if($.length===0)throw TypeError(`The \`${J}\` option must not be an empty array.`);if(!q)return;for(let{value:X,optionName:Z}of $)if(AY.has(X))throw Error(`The \`${Z}\` option must not include \`${X}\`.`)},AY=new Set(["ignore","ipc"]),EY=($)=>{for(let q of $)yY(q)},yY=({type:$,value:q,optionName:J})=>{if(g7(q))throw TypeError(`The \`${J}: URL\` option must use the \`file:\` scheme.
|
|
63
|
+
For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(c7($,q))throw TypeError(`The \`${J}: { file: '...' }\` option must be used instead of \`${J}: '...'\`.`)},OY=($,q)=>{if(!q)return;let J=$.find(({type:X})=>_$.has(X));if(J!==void 0)throw TypeError(`The \`${J.optionName}\` option cannot use both files and transforms in objectMode.`)},NY=({initialFileDescriptors:$,addProperties:q,options:J,isSync:X})=>{let Z=[];try{for(let H of $)Z.push(DY({fileDescriptor:H,fileDescriptors:Z,addProperties:q,options:J,isSync:X}));return Z}catch(H){throw J4(Z),H}},DY=({fileDescriptor:{direction:$,objectMode:q,stdioItems:J},fileDescriptors:X,addProperties:Z,options:H,isSync:Q})=>{let Y=J.map((G)=>vY({stdioItem:G,addProperties:Z,direction:$,options:H,fileDescriptors:X,isSync:Q}));return{direction:$,objectMode:q,stdioItems:Y}},vY=({stdioItem:$,addProperties:q,direction:J,options:X,fileDescriptors:Z,isSync:H})=>{let Q=J5({stdioItem:$,direction:J,fileDescriptors:Z,isSync:H});if(Q!==void 0)return{...$,stream:Q};return{...$,...q[J][$.type]($,X)}},J4=($)=>{for(let{stdioItems:q}of $)for(let{stream:J}of q)if(J!==void 0&&!i(J))J.destroy()},hY=($)=>{if($.length>1)return $.some(({value:X})=>X==="overlapped")?"overlapped":"pipe";let[{type:q,value:J}]=$;return q==="native"?J:"pipe"};var Y5=($,q)=>R$(SY,$,q,!0),q1=({type:$,optionName:q})=>{G5(q,_1[$])},fY=({optionName:$,value:q})=>{if(q==="ipc"||q==="overlapped")G5($,`"${q}"`);return{}},G5=($,q)=>{throw TypeError(`The \`${$}\` option cannot be ${q} with synchronous methods.`)},H5={generator(){},asyncGenerator:q1,webStream:q1,nodeStream:q1,webTransform:q1,duplex:q1,asyncIterable:q1,native:fY},SY={input:{...H5,fileUrl:({value:$})=>({contents:[H1(Q5($))]}),filePath:({value:{file:$}})=>({contents:[H1(Q5($))]}),fileNumber:q1,iterable:({value:$})=>({contents:[...$]}),string:({value:$})=>({contents:[$]}),uint8Array:({value:$})=>({contents:[$]})},output:{...H5,fileUrl:({value:$})=>({path:$}),filePath:({value:{file:$,append:q}})=>({path:$,append:q}),fileNumber:({value:$})=>({path:$}),iterable:q1,string:q1,uint8Array:q1}};var U1=($,{stripFinalNewline:q},J)=>X4(q,J)&&$!==void 0&&!Array.isArray($)?m1($):$,X4=($,q)=>q==="all"?$[1]||$[2]:$[q];import{Transform as ZG,getDefaultHighWaterMark as P5}from"node:stream";var T$=($,q,J,X)=>$||J?void 0:U5(q,X),Q4=($,q,J)=>J?$.flatMap((X)=>K5(X,q)):K5($,q),K5=($,q)=>{let{transform:J,final:X}=U5(q,{});return[...J($),...X()]},U5=($,q)=>{return q.previousChunks="",{transform:bY.bind(void 0,q,$),final:cY.bind(void 0,q)}},bY=function*($,q,J){if(typeof J!=="string"){yield J;return}let{previousChunks:X}=$,Z=-1;for(let H=0;H<J.length;H+=1)if(J[H]===`
|
|
64
|
+
`){let Q=gY(J,H,q,$),Y=J.slice(Z+1,H+1-Q);if(X.length>0)Y=Z4(X,Y),X="";yield Y,Z=H}if(Z!==J.length-1)X=Z4(X,J.slice(Z+1));$.previousChunks=X},gY=($,q,J,X)=>{if(J)return 0;return X.isWindowsNewline=q!==0&&$[q-1]==="\r",X.isWindowsNewline?2:1},cY=function*({previousChunks:$}){if($.length>0)yield $},z5=({binary:$,preserveNewlines:q,readableObjectMode:J,state:X})=>$||q||J?void 0:{transform:mY.bind(void 0,X)},mY=function*({isWindowsNewline:$=!1},q){let{unixNewline:J,windowsNewline:X,LF:Z,concatBytes:H}=typeof q==="string"?uY:lY;if(q.at(-1)===Z){yield q;return}yield H(q,$?X:J)},Z4=($,q)=>`${$}${q}`,uY={windowsNewline:`\r
|
|
65
65
|
`,unixNewline:`
|
|
66
66
|
`,LF:`
|
|
67
|
-
`,concatBytes:
|
|
67
|
+
`,concatBytes:Z4},pY=($,q)=>{let J=new Uint8Array($.length+q.length);return J.set($,0),J.set(q,$.length),J},lY={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:pY};import{Buffer as dY}from"node:buffer";var B5=($,q)=>$?void 0:iY.bind(void 0,q),iY=function*($,q){if(typeof q!=="string"&&!D(q)&&!dY.isBuffer(q))throw TypeError(`The \`${$}\` option's transform must use "objectMode: true" to receive as input: ${typeof q}.`);yield q},L5=($,q)=>$?nY.bind(void 0,q):aY.bind(void 0,q),nY=function*($,q){V5($,q),yield q},aY=function*($,q){if(V5($,q),typeof q!=="string"&&!D(q))throw TypeError(`The \`${$}\` option's function must yield a string or an Uint8Array, not ${typeof q}.`);yield q},V5=($,q)=>{if(q===null||q===void 0)throw TypeError(`The \`${$}\` option's function must not call \`yield ${q}\`.
|
|
68
68
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
69
|
-
if (condition) { yield value; }`)};import{Buffer as SY}from"node:buffer";import{StringDecoder as bY}from"node:string_decoder";var L$=($,q,J)=>{if(J)return;if($)return{transform:gY.bind(void 0,new TextEncoder)};let X=new bY(q);return{transform:cY.bind(void 0,X),final:mY.bind(void 0,X)}},gY=function*($,q){if(SY.isBuffer(q))yield Z1(q);else if(typeof q==="string")yield $.encode(q);else yield q},cY=function*($,q){yield D(q)?$.write(q):q},mY=function*($){let q=$.end();if(q!=="")yield q};import{callbackify as G5}from"node:util";var o2=G5(async($,q,J,X)=>{q.currentIterable=$(...J);try{for await(let Z of q.currentIterable)X.push(Z)}finally{delete q.currentIterable}}),_$=async function*($,q,J){if(J===q.length){yield $;return}let{transform:X=pY}=q[J];for await(let Z of X($))yield*_$(Z,q,J+1)},K5=async function*($){for(let[q,{final:J}]of Object.entries($))yield*uY(J,Number(q),$)},uY=async function*($,q,J){if($===void 0)return;for await(let X of $())yield*_$(X,J,q+1)},U5=G5(async({currentIterable:$},q)=>{if($!==void 0){await(q?$.throw(q):$.return());return}if(q)throw q}),pY=function*($){yield $};var r2=($,q,J,X)=>{try{for(let Z of $(...q))J.push(Z);X()}catch(Z){X(Z)}},z5=($,q)=>[...q.flatMap((J)=>[...F1(J,$,0)]),...J0($)],F1=function*($,q,J){if(J===q.length){yield $;return}let{transform:X=dY}=q[J];for(let Z of X($))yield*F1(Z,q,J+1)},J0=function*($){for(let[q,{final:J}]of Object.entries($))yield*lY(J,Number(q),$)},lY=function*($,q,J){if($===void 0)return;for(let X of $())yield*F1(X,J,q+1)},dY=function*($){yield $};var s2=({value:$,value:{transform:q,final:J,writableObjectMode:X,readableObjectMode:Z},optionName:H},{encoding:Q})=>{let Y={},G=L5($,Q,H),K=k1(q),U=k1(J),z=K?o2.bind(void 0,_$,Y):r2.bind(void 0,F1),B=K||U?o2.bind(void 0,K5,Y):r2.bind(void 0,J0),L=K||U?U5.bind(void 0,Y):void 0;return{stream:new iY({writableObjectMode:X,writableHighWaterMark:B5(X),readableObjectMode:Z,readableHighWaterMark:B5(Z),transform(P,M,F){z([P,G,0],this,F)},flush(P){B([G],this,P)},destroy:L})}},V$=($,q,J,X)=>{let Z=q.filter(({type:Q})=>Q==="generator"),H=X?Z.reverse():Z;for(let{value:Q,optionName:Y}of H){let G=L5(Q,J,Y);$=z5(G,$)}return $},L5=({transform:$,final:q,binary:J,writableObjectMode:X,readableObjectMode:Z,preserveNewlines:H},Q,Y)=>{let G={};return[{transform:Q5(X,Y)},L$(J,Q,X),B$(J,H,X,G),{transform:$,final:q},{transform:H5(Z,Y)},Z5({binary:J,preserveNewlines:H,readableObjectMode:Z,state:G})].filter(Boolean)};var _5=($,q)=>{for(let J of nY($))aY($,J,q)},nY=($)=>new Set(Object.entries($).filter(([,{direction:q}])=>q==="input").map(([q])=>Number(q))),aY=($,q,J)=>{let{stdioItems:X}=$[q],Z=X.filter(({contents:Y})=>Y!==void 0);if(Z.length===0)return;if(q!==0){let[{type:Y,optionName:G}]=Z;throw TypeError(`Only the \`stdin\` option, not \`${G}\`, can be ${L1[Y]} with synchronous methods.`)}let Q=Z.map(({contents:Y})=>Y).map((Y)=>tY(Y,X));J.input=a1(Q)},tY=($,q)=>{let J=V$($,q,"utf8",!0);return oY(J),a1(J)},oY=($)=>{let q=$.find((J)=>typeof J!=="string"&&!D(J));if(q!==void 0)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${q}.`)};import{writeFileSync as $G,appendFileSync as qG}from"node:fs";var R$=({stdioItems:$,encoding:q,verboseInfo:J,fdNumber:X})=>X!=="all"&&E1(J,X)&&!m.has(q)&&rY(X)&&($.some(({type:Z,value:H})=>Z==="native"&&sY.has(H))||$.every(({type:Z})=>l.has(Z))),rY=($)=>$===1||$===2,sY=new Set(["pipe","overlapped"]),V5=async($,q,J,X)=>{for await(let Z of $)if(!eY(q))W5(Z,J,X)},R5=($,q,J)=>{for(let X of $)W5(X,q,J)},eY=($)=>$._readableState.pipes.length>0,W5=($,q,J)=>{let X=I0($);o({type:"output",verboseMessage:X,fdNumber:q,verboseInfo:J})};var T5=({fileDescriptors:$,syncResult:{output:q},options:J,isMaxBuffer:X,verboseInfo:Z})=>{if(q===null)return{output:Array.from({length:3})};let H={},Q=new Set([]);return{output:q.map((G,K)=>JG({result:G,fileDescriptors:$,fdNumber:K,state:H,outputFiles:Q,isMaxBuffer:X,verboseInfo:Z},J)),...H}},JG=({result:$,fileDescriptors:q,fdNumber:J,state:X,outputFiles:Z,isMaxBuffer:H,verboseInfo:Q},{buffer:Y,encoding:G,lines:K,stripFinalNewline:U,maxBuffer:z})=>{if($===null)return;let B=P7($,H,z),L=Z1(B),{stdioItems:W,objectMode:P}=q[J],M=XG([L],W,G,X),{serializedResult:F,finalResult:O=F}=ZG({chunks:M,objectMode:P,encoding:G,lines:K,stripFinalNewline:U,fdNumber:J});QG({serializedResult:F,fdNumber:J,state:X,verboseInfo:Q,encoding:G,stdioItems:W,objectMode:P});let v=Y[J]?O:void 0;try{if(X.error===void 0)HG(F,W,Z);return v}catch(x){return X.error=x,v}},XG=($,q,J,X)=>{try{return V$($,q,J,!1)}catch(Z){return X.error=Z,$}},ZG=({chunks:$,objectMode:q,encoding:J,lines:X,stripFinalNewline:Z,fdNumber:H})=>{if(q)return{serializedResult:$};if(J==="buffer")return{serializedResult:a1($)};let Q=D3($,J);if(X[H])return{serializedResult:Q,finalResult:t2(Q,!Z[H],q)};return{serializedResult:Q}},QG=({serializedResult:$,fdNumber:q,state:J,verboseInfo:X,encoding:Z,stdioItems:H,objectMode:Q})=>{if(!R$({stdioItems:H,encoding:Z,verboseInfo:X,fdNumber:q}))return;let Y=t2($,!1,Q);try{R5(Y,q,X)}catch(G){J.error??=G}},HG=($,q,J)=>{for(let{path:X,append:Z}of q.filter(({type:H})=>U$.has(H))){let H=typeof X==="string"?X:X.toString();if(Z||J.has(H))qG(X,$);else J.add(H),$G(X,$)}};var P5=([,$,q],J)=>{if(!J.all)return;if($===void 0)return q;if(q===void 0)return $;if(Array.isArray($))return Array.isArray(q)?[...$,...q]:[...$,G1(q,J,"all")];if(Array.isArray(q))return[G1($,J,"all"),...q];if(D($)&&D(q))return Z2([$,q]);return`${$}${q}`};import{once as e2}from"node:events";var k5=async($,q)=>{let[J,X]=await YG($);return q.isForcefullyTerminated??=!1,[J,X]},YG=async($)=>{let[q,J]=await Promise.allSettled([e2($,"spawn"),e2($,"exit")]);if(q.status==="rejected")return[];return J.status==="rejected"?F5($):J.value},F5=async($)=>{try{return await e2($,"exit")}catch{return F5($)}},x5=async($)=>{let[q,J]=await $;if(!GG(q,J)&&$4(q,J))throw new r;return[q,J]},GG=($,q)=>$===void 0&&q===void 0,$4=($,q)=>$!==0||q!==null;var j5=({error:$,status:q,signal:J,output:X},{maxBuffer:Z})=>{let H=KG($,q,J),Q=H?.code==="ETIMEDOUT",Y=T7(H,X,Z);return{resultError:H,exitCode:q,signal:J,timedOut:Q,isMaxBuffer:Y}},KG=($,q,J)=>{if($!==void 0)return $;return $4(q,J)?new r:void 0};var M5=($,q,J)=>{let{file:X,commandArguments:Z,command:H,escapedCommand:Q,startTime:Y,verboseInfo:G,options:K,fileDescriptors:U}=zG($,q,J),z=_G({file:X,commandArguments:Z,options:K,command:H,escapedCommand:Q,verboseInfo:G,fileDescriptors:U,startTime:Y});return b1(z,G,K)},zG=($,q,J)=>{let{command:X,escapedCommand:Z,startTime:H,verboseInfo:Q}=A0($,q,J),Y=BG(J),{file:G,commandArguments:K,options:U}=r0($,q,Y);LG(U);let z=$5(U,Q);return{file:G,commandArguments:K,command:X,escapedCommand:Z,startTime:H,verboseInfo:Q,options:U,fileDescriptors:z}},BG=($)=>$.node&&!$.ipc?{...$,ipc:!1}:$,LG=({ipc:$,ipcInput:q,detached:J,cancelSignal:X})=>{if(q)W$("ipcInput");if($)W$("ipc: true");if(J)W$("detached: true");if(X)W$("cancelSignal")},W$=($)=>{throw TypeError(`The "${$}" option cannot be used with synchronous methods.`)},_G=({file:$,commandArguments:q,options:J,command:X,escapedCommand:Z,verboseInfo:H,fileDescriptors:Q,startTime:Y})=>{let G=VG({file:$,commandArguments:q,options:J,command:X,escapedCommand:Z,fileDescriptors:Q,startTime:Y});if(G.failed)return G;let{resultError:K,exitCode:U,signal:z,timedOut:B,isMaxBuffer:L}=j5(G,J),{output:W,error:P=K}=T5({fileDescriptors:Q,syncResult:G,options:J,isMaxBuffer:L,verboseInfo:H}),M=W.map((O,v)=>G1(O,J,v)),F=G1(P5(W,J),J,"all");return WG({error:P,exitCode:U,signal:z,timedOut:B,isMaxBuffer:L,stdio:M,all:F,options:J,command:X,escapedCommand:Z,startTime:Y})},VG=({file:$,commandArguments:q,options:J,command:X,escapedCommand:Z,fileDescriptors:H,startTime:Q})=>{try{_5(H,J);let Y=RG(J);return UG(...s0($,q,Y))}catch(Y){return S1({error:Y,command:X,escapedCommand:Z,fileDescriptors:H,options:J,startTime:Q,isSync:!0})}},RG=({encoding:$,maxBuffer:q,...J})=>({...J,encoding:"buffer",maxBuffer:H$(q)}),WG=({error:$,exitCode:q,signal:J,timedOut:X,isMaxBuffer:Z,stdio:H,all:Q,options:Y,command:G,escapedCommand:K,startTime:U})=>$===void 0?Y$({command:G,escapedCommand:K,stdio:H,all:Q,ipcOutput:[],options:Y,startTime:U}):q0({error:$,command:G,escapedCommand:K,timedOut:X,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:Z,isForcefullyTerminated:!1,exitCode:q,signal:J,stdio:H,all:Q,ipcOutput:[],options:Y,startTime:U,isSync:!0});import{setMaxListeners as ZU}from"node:events";import{spawn as QU}from"node:child_process";import E5 from"node:process";import{once as q4,on as TG}from"node:events";var C5=({anyProcess:$,channel:q,isSubprocess:J,ipc:X},{reference:Z=!0,filter:H}={})=>{return N1({methodName:"getOneMessage",isSubprocess:J,ipc:X,isConnected:d0($)}),PG({anyProcess:$,channel:q,isSubprocess:J,filter:H,reference:Z})},PG=async({anyProcess:$,channel:q,isSubprocess:J,filter:X,reference:Z})=>{m0(q,Z);let H=B1($,q,J),Q=new AbortController;try{return await Promise.race([kG(H,X,Q),FG(H,J,Q),xG(H,J,Q)])}catch(Y){throw D1($),Y}finally{Q.abort(),u0(q,Z)}},kG=async($,q,{signal:J})=>{if(q===void 0){let[X]=await q4($,"message",{signal:J});return X}for await(let[X]of TG($,"message",{signal:J}))if(q(X))return X},FG=async($,q,{signal:J})=>{await q4($,"disconnect",{signal:J}),U8(q)},xG=async($,q,{signal:J})=>{let[X]=await q4($,"strict:error",{signal:J});throw b0(X,q)};import{once as w5,on as jG}from"node:events";var A5=({anyProcess:$,channel:q,isSubprocess:J,ipc:X},{reference:Z=!0}={})=>J4({anyProcess:$,channel:q,isSubprocess:J,ipc:X,shouldAwait:!J,reference:Z}),J4=({anyProcess:$,channel:q,isSubprocess:J,ipc:X,shouldAwait:Z,reference:H})=>{N1({methodName:"getEachMessage",isSubprocess:J,ipc:X,isConnected:d0($)}),m0(q,H);let Q=B1($,q,J),Y=new AbortController,G={};return MG($,Q,Y),CG({ipcEmitter:Q,isSubprocess:J,controller:Y,state:G}),IG({anyProcess:$,channel:q,ipcEmitter:Q,isSubprocess:J,shouldAwait:Z,controller:Y,state:G,reference:H})},MG=async($,q,J)=>{try{await w5(q,"disconnect",{signal:J.signal}),J.abort()}catch{}},CG=async({ipcEmitter:$,isSubprocess:q,controller:J,state:X})=>{try{let[Z]=await w5($,"strict:error",{signal:J.signal});X.error=b0(Z,q),J.abort()}catch{}},IG=async function*({anyProcess:$,channel:q,ipcEmitter:J,isSubprocess:X,shouldAwait:Z,controller:H,state:Q,reference:Y}){try{for await(let[G]of jG(J,"message",{signal:H.signal}))I5(Q),yield G}catch{I5(Q)}finally{if(H.abort(),u0(q,Y),!X)D1($);if(Z)await $}},I5=({error:$})=>{if($)throw $};var y5=($,{ipc:q})=>{Object.assign($,N5($,!1,q))},O5=()=>{let $=E5,q=!0,J=E5.channel!==void 0;return{...N5($,!0,J),getCancelSignal:S8.bind(void 0,{anyProcess:$,channel:$.channel,isSubprocess:!0,ipc:J})}},N5=($,q,J)=>({sendMessage:t0.bind(void 0,{anyProcess:$,channel:$.channel,isSubprocess:q,ipc:J}),getOneMessage:C5.bind(void 0,{anyProcess:$,channel:$.channel,isSubprocess:q,ipc:J}),getEachMessage:A5.bind(void 0,{anyProcess:$,channel:$.channel,isSubprocess:q,ipc:J})});import{ChildProcess as wG}from"node:child_process";import{PassThrough as AG,Readable as EG,Writable as yG,Duplex as OG}from"node:stream";var D5=({error:$,command:q,escapedCommand:J,fileDescriptors:X,options:Z,startTime:H,verboseInfo:Q})=>{i2(X);let Y=new wG;NG(Y,X),Object.assign(Y,{readable:DG,writable:vG,duplex:fG});let G=S1({error:$,command:q,escapedCommand:J,fileDescriptors:X,options:Z,startTime:H,isSync:!1}),K=hG(G,Q,Z);return{subprocess:Y,promise:K}},NG=($,q)=>{let J=X0(),X=X0(),Z=X0(),H=Array.from({length:q.length-3},X0),Q=X0(),Y=[J,X,Z,...H];Object.assign($,{stdin:J,stdout:X,stderr:Z,all:Q,stdio:Y})},X0=()=>{let $=new AG;return $.end(),$},DG=()=>new EG({read(){}}),vG=()=>new yG({write(){}}),fG=()=>new OG({read(){},write(){}}),hG=async($,q,J)=>b1($,q,J);import{createReadStream as v5,createWriteStream as f5}from"node:fs";import{Buffer as SG}from"node:buffer";import{Readable as Z0,Writable as bG,Duplex as gG}from"node:stream";var S5=($,q)=>z$(cG,$,q,!1),Q0=({type:$,optionName:q})=>{throw TypeError(`The \`${q}\` option cannot be ${L1[$]}.`)},h5={fileNumber:Q0,generator:s2,asyncGenerator:s2,nodeStream:({value:$})=>({stream:$}),webTransform({value:{transform:$,writableObjectMode:q,readableObjectMode:J}}){let X=q||J;return{stream:gG.fromWeb($,{objectMode:X})}},duplex:({value:{transform:$}})=>({stream:$}),native(){}},cG={input:{...h5,fileUrl:({value:$})=>({stream:v5($)}),filePath:({value:{file:$}})=>({stream:v5($)}),webStream:({value:$})=>({stream:Z0.fromWeb($)}),iterable:({value:$})=>({stream:Z0.from($)}),asyncIterable:({value:$})=>({stream:Z0.from($)}),string:({value:$})=>({stream:Z0.from($)}),uint8Array:({value:$})=>({stream:Z0.from(SG.from($))})},output:{...h5,fileUrl:({value:$})=>({stream:f5($)}),filePath:({value:{file:$,append:q}})=>({stream:f5($,q?{flags:"a"}:{})}),webStream:({value:$})=>({stream:bG.fromWeb($)}),iterable:Q0,asyncIterable:Q0,string:Q0,uint8Array:Q0}};import{on as mG,once as b5}from"node:events";import{PassThrough as uG,getDefaultHighWaterMark as pG}from"node:stream";import{finished as m5}from"node:stream/promises";function x1($){if(!Array.isArray($))throw TypeError(`Expected an array, got \`${typeof $}\`.`);for(let Z of $)X4(Z);let q=$.some(({readableObjectMode:Z})=>Z),J=lG($,q),X=new u5({objectMode:q,writableHighWaterMark:J,readableHighWaterMark:J});for(let Z of $)X.add(Z);return X}var lG=($,q)=>{if($.length===0)return pG(q);let J=$.filter(({readableObjectMode:X})=>X===q).map(({readableHighWaterMark:X})=>X);return Math.max(...J)};class u5 extends uG{#q=new Set([]);#J=new Set([]);#$=new Set([]);#X;#Q=Symbol("unpipe");#Z=new WeakMap;add($){if(X4($),this.#q.has($))return;this.#q.add($),this.#X??=dG(this,this.#q,this.#Q);let q=aG({passThroughStream:this,stream:$,streams:this.#q,ended:this.#J,aborted:this.#$,onFinished:this.#X,unpipeEvent:this.#Q});this.#Z.set($,q),$.pipe(this,{end:!1})}async remove($){if(X4($),!this.#q.has($))return!1;let q=this.#Z.get($);if(q===void 0)return!1;return this.#Z.delete($),$.unpipe(this),await q,!0}}var dG=async($,q,J)=>{T$($,g5);let X=new AbortController;try{await Promise.race([iG($,X),nG($,q,J,X)])}finally{X.abort(),T$($,-g5)}},iG=async($,{signal:q})=>{try{await m5($,{signal:q,cleanup:!0})}catch(J){throw p5($,J),J}},nG=async($,q,J,{signal:X})=>{for await(let[Z]of mG($,"unpipe",{signal:X}))if(q.has(Z))Z.emit(J)},X4=($)=>{if(typeof $?.pipe!=="function")throw TypeError(`Expected a readable stream, got: \`${typeof $}\`.`)},aG=async({passThroughStream:$,stream:q,streams:J,ended:X,aborted:Z,onFinished:H,unpipeEvent:Q})=>{T$($,c5);let Y=new AbortController;try{await Promise.race([tG(H,q,Y),oG({passThroughStream:$,stream:q,streams:J,ended:X,aborted:Z,controller:Y}),rG({stream:q,streams:J,ended:X,aborted:Z,unpipeEvent:Q,controller:Y})])}finally{Y.abort(),T$($,-c5)}if(J.size>0&&J.size===X.size+Z.size)if(X.size===0&&Z.size>0)Z4($);else sG($)},tG=async($,q,{signal:J})=>{try{if(await $,!J.aborted)Z4(q)}catch(X){if(!J.aborted)p5(q,X)}},oG=async({passThroughStream:$,stream:q,streams:J,ended:X,aborted:Z,controller:{signal:H}})=>{try{if(await m5(q,{signal:H,cleanup:!0,readable:!0,writable:!1}),J.has(q))X.add(q)}catch(Q){if(H.aborted||!J.has(q))return;if(l5(Q))Z.add(q);else d5($,Q)}},rG=async({stream:$,streams:q,ended:J,aborted:X,unpipeEvent:Z,controller:{signal:H}})=>{if(await b5($,Z,{signal:H}),!$.readable)return b5(H,"abort",{signal:H});q.delete($),J.delete($),X.delete($)},sG=($)=>{if($.writable)$.end()},p5=($,q)=>{if(l5(q))Z4($);else d5($,q)},l5=($)=>$?.code==="ERR_STREAM_PREMATURE_CLOSE",Z4=($)=>{if($.readable||$.writable)$.destroy()},d5=($,q)=>{if(!$.destroyed)$.once("error",eG),$.destroy(q)},eG=()=>{},T$=($,q)=>{let J=$.getMaxListeners();if(J!==0&&J!==Number.POSITIVE_INFINITY)$.setMaxListeners(J+q)},g5=2,c5=1;import{finished as i5}from"node:stream/promises";var c1=($,q)=>{$.pipe(q),$K($,q),qK($,q)},$K=async($,q)=>{if(d($)||d(q))return;try{await i5($,{cleanup:!0,readable:!0,writable:!1})}catch{}Q4(q)},Q4=($)=>{if($.writable)$.end()},qK=async($,q)=>{if(d($)||d(q))return;try{await i5(q,{cleanup:!0,readable:!1,writable:!0})}catch{}H4($)},H4=($)=>{if($.readable)$.destroy()};var n5=($,q,J)=>{let X=new Map;for(let[Z,{stdioItems:H,direction:Q}]of Object.entries(q)){for(let{stream:Y}of H.filter(({type:G})=>l.has(G)))JK($,Y,Q,Z);for(let{stream:Y}of H.filter(({type:G})=>!l.has(G)))ZK({subprocess:$,stream:Y,direction:Q,fdNumber:Z,pipeGroups:X,controller:J})}for(let[Z,H]of X.entries()){let Q=H.length===1?H[0]:x1(H);c1(Q,Z)}},JK=($,q,J,X)=>{if(J==="output")c1($.stdio[X],q);else c1(q,$.stdio[X]);let Z=XK[X];if(Z!==void 0)$[Z]=q;$.stdio[X]=q},XK=["stdin","stdout","stderr"],ZK=({subprocess:$,stream:q,direction:J,fdNumber:X,pipeGroups:Z,controller:H})=>{if(q===void 0)return;QK(q,H);let[Q,Y]=J==="output"?[q,$.stdio[X]]:[$.stdio[X],q],G=Z.get(Q)??[];Z.set(Q,[...G,Y])},QK=($,{signal:q})=>{if(d($))T1($,HK,q)},HK=2;import{addAbortListener as KK}from"node:events";var j1=[];j1.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")j1.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")j1.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var P$=($)=>!!$&&typeof $==="object"&&typeof $.removeListener==="function"&&typeof $.emit==="function"&&typeof $.reallyExit==="function"&&typeof $.listeners==="function"&&typeof $.kill==="function"&&typeof $.pid==="number"&&typeof $.on==="function",Y4=Symbol.for("signal-exit emitter"),G4=globalThis,YK=Object.defineProperty.bind(Object);class a5{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(G4[Y4])return G4[Y4];YK(G4,Y4,{value:this,writable:!1,enumerable:!1,configurable:!1})}on($,q){this.listeners[$].push(q)}removeListener($,q){let J=this.listeners[$],X=J.indexOf(q);if(X===-1)return;if(X===0&&J.length===1)J.length=0;else J.splice(X,1)}emit($,q,J){if(this.emitted[$])return!1;this.emitted[$]=!0;let X=!1;for(let Z of this.listeners[$])X=Z(q,J)===!0||X;if($==="exit")X=this.emit("afterExit",q,J)||X;return X}}class U4{}var GK=($)=>{return{onExit(q,J){return $.onExit(q,J)},load(){return $.load()},unload(){return $.unload()}}};class t5 extends U4{onExit(){return()=>{}}load(){}unload(){}}class o5 extends U4{#q=K4.platform==="win32"?"SIGINT":"SIGHUP";#J=new a5;#$;#X;#Q;#Z={};#H=!1;constructor($){super();this.#$=$,this.#Z={};for(let q of j1)this.#Z[q]=()=>{let J=this.#$.listeners(q),{count:X}=this.#J,Z=$;if(typeof Z.__signal_exit_emitter__==="object"&&typeof Z.__signal_exit_emitter__.count==="number")X+=Z.__signal_exit_emitter__.count;if(J.length===X){this.unload();let H=this.#J.emit("exit",null,q),Q=q==="SIGHUP"?this.#q:q;if(!H)$.kill($.pid,Q)}};this.#Q=$.reallyExit,this.#X=$.emit}onExit($,q){if(!P$(this.#$))return()=>{};if(this.#H===!1)this.load();let J=q?.alwaysLast?"afterExit":"exit";return this.#J.on(J,$),()=>{if(this.#J.removeListener(J,$),this.#J.listeners.exit.length===0&&this.#J.listeners.afterExit.length===0)this.unload()}}load(){if(this.#H)return;this.#H=!0,this.#J.count+=1;for(let $ of j1)try{let q=this.#Z[$];if(q)this.#$.on($,q)}catch(q){}this.#$.emit=($,...q)=>{return this.#G($,...q)},this.#$.reallyExit=($)=>{return this.#Y($)}}unload(){if(!this.#H)return;this.#H=!1,j1.forEach(($)=>{let q=this.#Z[$];if(!q)throw Error("Listener not defined for signal: "+$);try{this.#$.removeListener($,q)}catch(J){}}),this.#$.emit=this.#X,this.#$.reallyExit=this.#Q,this.#J.count-=1}#Y($){if(!P$(this.#$))return 0;return this.#$.exitCode=$||0,this.#J.emit("exit",this.#$.exitCode,null),this.#Q.call(this.#$,this.#$.exitCode)}#G($,...q){let J=this.#X;if($==="exit"&&P$(this.#$)){if(typeof q[0]==="number")this.#$.exitCode=q[0];let X=J.call(this.#$,$,...q);return this.#J.emit("exit",this.#$.exitCode,null),X}else return J.call(this.#$,$,...q)}}var K4=globalThis.process,{onExit:r5,load:_k,unload:Vk}=GK(P$(K4)?new o5(K4):new t5);var s5=($,{cleanup:q,detached:J},{signal:X})=>{if(!q||J)return;let Z=r5(()=>{$.kill()});KK(X,()=>{Z()})};var $q=({source:$,sourcePromise:q,boundOptions:J,createNested:X},...Z)=>{let H=w0(),{destination:Q,destinationStream:Y,destinationError:G,from:K,unpipeSignal:U}=UK(J,X,Z),{sourceStream:z,sourceError:B}=BK($,K),{options:L,fileDescriptors:W}=e.get($);return{sourcePromise:q,sourceStream:z,sourceOptions:L,sourceError:B,destination:Q,destinationStream:Y,destinationError:G,unpipeSignal:U,fileDescriptors:W,startTime:H}},UK=($,q,J)=>{try{let{destination:X,pipeOptions:{from:Z,to:H,unpipeSignal:Q}={}}=zK($,q,...J),Y=c0(X,H);return{destination:X,destinationStream:Y,from:Z,unpipeSignal:Q}}catch(X){return{destinationError:X}}},zK=($,q,J,...X)=>{if(Array.isArray(J))return{destination:q(e5,$)(J,...X),pipeOptions:$};if(typeof J==="string"||J instanceof URL||J2(J)){if(Object.keys($).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[Z,H,Q]=W0(J,...X);return{destination:q(e5)(Z,H,Q),pipeOptions:Q}}if(e.has(J)){if(Object.keys($).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:J,pipeOptions:X[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${J}`)},e5=({options:$})=>({options:{...$,stdin:"pipe",piped:!0}}),BK=($,q)=>{try{return{sourceStream:v1($,q)}}catch(J){return{sourceError:J}}};var Jq=({sourceStream:$,sourceError:q,destinationStream:J,destinationError:X,fileDescriptors:Z,sourceOptions:H,startTime:Q})=>{let Y=LK({sourceStream:$,sourceError:q,destinationStream:J,destinationError:X});if(Y!==void 0)throw z4({error:Y,fileDescriptors:Z,sourceOptions:H,startTime:Q})},LK=({sourceStream:$,sourceError:q,destinationStream:J,destinationError:X})=>{if(q!==void 0&&X!==void 0)return X;if(X!==void 0)return H4($),X;if(q!==void 0)return Q4(J),q},z4=({error:$,fileDescriptors:q,sourceOptions:J,startTime:X})=>S1({error:$,command:qq,escapedCommand:qq,fileDescriptors:q,options:J,startTime:X,isSync:!1}),qq="source.pipe(destination)";var Xq=async($)=>{let[{status:q,reason:J,value:X=J},{status:Z,reason:H,value:Q=H}]=await $;if(!Q.pipedFrom.includes(X))Q.pipedFrom.push(X);if(Z==="rejected")throw Q;if(q==="rejected")throw X;return Q};import{finished as _K}from"node:stream/promises";var Zq=($,q,J)=>{let X=k$.has(q)?RK($,q):VK($,q);return T1($,TK,J.signal),T1(q,PK,J.signal),WK(q),X},VK=($,q)=>{let J=x1([$]);return c1(J,q),k$.set(q,J),J},RK=($,q)=>{let J=k$.get(q);return J.add($),J},WK=async($)=>{try{await _K($,{cleanup:!0,readable:!1,writable:!0})}catch{}k$.delete($)},k$=new WeakMap,TK=2,PK=1;import{aborted as kK}from"node:util";var Qq=($,q)=>$===void 0?[]:[FK($,q)],FK=async($,{sourceStream:q,mergedStream:J,fileDescriptors:X,sourceOptions:Z,startTime:H})=>{await kK($,q),await J.remove(q);let Q=Error("Pipe canceled by `unpipeSignal` option.");throw z4({error:Q,fileDescriptors:X,sourceOptions:Z,startTime:H})};var F$=($,...q)=>{if(E(q[0]))return F$.bind(void 0,{...$,boundOptions:{...$.boundOptions,...q[0]}});let{destination:J,...X}=$q($,...q),Z=xK({...X,destination:J});return Z.pipe=F$.bind(void 0,{...$,source:J,sourcePromise:Z,boundOptions:{}}),Z},xK=async({sourcePromise:$,sourceStream:q,sourceOptions:J,sourceError:X,destination:Z,destinationStream:H,destinationError:Q,unpipeSignal:Y,fileDescriptors:G,startTime:K})=>{let U=jK($,Z);Jq({sourceStream:q,sourceError:X,destinationStream:H,destinationError:Q,fileDescriptors:G,sourceOptions:J,startTime:K});let z=new AbortController;try{let B=Zq(q,H,z);return await Promise.race([Xq(U),...Qq(Y,{sourceStream:q,mergedStream:B,sourceOptions:J,fileDescriptors:G,startTime:K})])}finally{z.abort()}},jK=($,q)=>Promise.allSettled([$,q]);import{setImmediate as yK}from"node:timers/promises";import{on as MK}from"node:events";import{getDefaultHighWaterMark as CK}from"node:stream";var x$=({subprocessStdout:$,subprocess:q,binary:J,shouldEncode:X,encoding:Z,preserveNewlines:H})=>{let Q=new AbortController;return IK(q,Q),Yq({stream:$,controller:Q,binary:J,shouldEncode:!$.readableObjectMode&&X,encoding:Z,shouldSplit:!$.readableObjectMode,preserveNewlines:H})},IK=async($,q)=>{try{await $}catch{}finally{q.abort()}},B4=({stream:$,onStreamEnd:q,lines:J,encoding:X,stripFinalNewline:Z,allMixed:H})=>{let Q=new AbortController;wK(q,Q,$);let Y=$.readableObjectMode&&!H;return Yq({stream:$,controller:Q,binary:X==="buffer",shouldEncode:!Y,encoding:X,shouldSplit:!Y&&J,preserveNewlines:!Z})},wK=async($,q,J)=>{try{await $}catch{J.destroy()}finally{q.abort()}},Yq=({stream:$,controller:q,binary:J,shouldEncode:X,encoding:Z,shouldSplit:H,preserveNewlines:Q})=>{let Y=MK($,"data",{signal:q.signal,highWaterMark:Hq,highWatermark:Hq});return AK({onStdoutChunk:Y,controller:q,binary:J,shouldEncode:X,encoding:Z,shouldSplit:H,preserveNewlines:Q})},L4=CK(!0),Hq=L4,AK=async function*({onStdoutChunk:$,controller:q,binary:J,shouldEncode:X,encoding:Z,shouldSplit:H,preserveNewlines:Q}){let Y=EK({binary:J,shouldEncode:X,encoding:Z,shouldSplit:H,preserveNewlines:Q});try{for await(let[G]of $)yield*F1(G,Y,0)}catch(G){if(!q.signal.aborted)throw G}finally{yield*J0(Y)}},EK=({binary:$,shouldEncode:q,encoding:J,shouldSplit:X,preserveNewlines:Z})=>[L$($,J,!q),B$($,Z,!X,{})].filter(Boolean);var Gq=async({stream:$,onStreamEnd:q,fdNumber:J,encoding:X,buffer:Z,maxBuffer:H,lines:Q,allMixed:Y,stripFinalNewline:G,verboseInfo:K,streamInfo:U})=>{let z=OK({stream:$,onStreamEnd:q,fdNumber:J,encoding:X,allMixed:Y,verboseInfo:K,streamInfo:U});if(!Z){await Promise.all([NK($),z]);return}let B=n2(G,J),L=B4({stream:$,onStreamEnd:q,lines:Q,encoding:X,stripFinalNewline:B,allMixed:Y}),[W]=await Promise.all([DK({stream:$,iterable:L,fdNumber:J,encoding:X,maxBuffer:H,lines:Q}),z]);return W},OK=async({stream:$,onStreamEnd:q,fdNumber:J,encoding:X,allMixed:Z,verboseInfo:H,streamInfo:{fileDescriptors:Q}})=>{if(!R$({stdioItems:Q[J]?.stdioItems,encoding:X,verboseInfo:H,fdNumber:J}))return;let Y=B4({stream:$,onStreamEnd:q,lines:!0,encoding:X,stripFinalNewline:!0,allMixed:Z});await V5(Y,$,J,H)},NK=async($)=>{if(await yK(),$.readableFlowing===null)$.resume()},DK=async({stream:$,stream:{readableObjectMode:q},iterable:J,fdNumber:X,encoding:Z,maxBuffer:H,lines:Q})=>{try{if(q||Q)return await J$(J,{maxBuffer:H});if(Z==="buffer")return new Uint8Array(await X$(J,{maxBuffer:H}));return await Q$(J,{maxBuffer:H})}catch(Y){return Kq(V7({error:Y,stream:$,readableObjectMode:q,lines:Q,encoding:Z,fdNumber:X}))}},_4=async($)=>{try{return await $}catch(q){return Kq(q)}},Kq=({bufferedData:$})=>O3($)?new Uint8Array($):$;import{finished as vK}from"node:stream/promises";var H0=async($,q,J,{isSameDirection:X,stopOnExit:Z=!1}={})=>{let H=fK($,J),Q=new AbortController;try{await Promise.race([...Z?[J.exitPromise]:[],vK($,{cleanup:!0,signal:Q.signal})])}catch(Y){if(!H.stdinCleanedUp)bK(Y,q,J,X)}finally{Q.abort()}},fK=($,{originalStreams:[q],subprocess:J})=>{let X={stdinCleanedUp:!1};if($===q)hK($,J,X);return X},hK=($,q,J)=>{let{_destroy:X}=$;$._destroy=(...Z)=>{SK(q,J),X.call($,...Z)}},SK=({exitCode:$,signalCode:q},J)=>{if($!==null||q!==null)J.stdinCleanedUp=!0},bK=($,q,J,X)=>{if(!gK($,q,J,X))throw $},gK=($,q,J,X=!0)=>{if(J.propagating)return Uq($)||j$($);return J.propagating=!0,V4(J,q)===X?Uq($):j$($)},V4=({fileDescriptors:$},q)=>q!=="all"&&$[q].direction==="input",j$=($)=>$?.code==="ERR_STREAM_PREMATURE_CLOSE",Uq=($)=>$?.code==="EPIPE";var zq=({subprocess:$,encoding:q,buffer:J,maxBuffer:X,lines:Z,stripFinalNewline:H,verboseInfo:Q,streamInfo:Y})=>$.stdio.map((G,K)=>R4({stream:G,fdNumber:K,encoding:q,buffer:J[K],maxBuffer:X[K],lines:Z[K],allMixed:!1,stripFinalNewline:H,verboseInfo:Q,streamInfo:Y})),R4=async({stream:$,fdNumber:q,encoding:J,buffer:X,maxBuffer:Z,lines:H,allMixed:Q,stripFinalNewline:Y,verboseInfo:G,streamInfo:K})=>{if(!$)return;let U=H0($,q,K);if(V4(K,q)){await U;return}let[z]=await Promise.all([Gq({stream:$,onStreamEnd:U,fdNumber:q,encoding:J,buffer:X,maxBuffer:Z,lines:H,allMixed:Q,stripFinalNewline:Y,verboseInfo:G,streamInfo:K}),U]);return z};var Bq=({stdout:$,stderr:q},{all:J})=>J&&($||q)?x1([$,q].filter(Boolean)):void 0,Lq=({subprocess:$,encoding:q,buffer:J,maxBuffer:X,lines:Z,stripFinalNewline:H,verboseInfo:Q,streamInfo:Y})=>R4({...cK($,J),fdNumber:"all",encoding:q,maxBuffer:X[1]+X[2],lines:Z[1]||Z[2],allMixed:mK($),stripFinalNewline:H,verboseInfo:Q,streamInfo:Y}),cK=({stdout:$,stderr:q,all:J},[,X,Z])=>{let H=X||Z;if(!H)return{stream:J,buffer:H};if(!X)return{stream:q,buffer:H};if(!Z)return{stream:$,buffer:H};return{stream:J,buffer:H}},mK=({all:$,stdout:q,stderr:J})=>$&&q&&J&&q.readableObjectMode!==J.readableObjectMode;import{once as uK}from"node:events";var _q=($)=>E1($,"ipc"),Vq=($,q)=>{let J=I0($);o({type:"ipc",verboseMessage:J,fdNumber:"ipc",verboseInfo:q})};var Rq=async({subprocess:$,buffer:q,maxBuffer:J,ipc:X,ipcOutput:Z,verboseInfo:H})=>{if(!X)return Z;let Q=_q(H),Y=Q1(q,"ipc"),G=Q1(J,"ipc");for await(let K of J4({anyProcess:$,channel:$.channel,isSubprocess:!1,ipc:X,shouldAwait:!1,reference:!0})){if(Y)R7($,Z,G),Z.push(K);if(Q)Vq(K,H)}return Z},Wq=async($,q)=>{return await Promise.allSettled([$]),q};var Tq=async({subprocess:$,options:{encoding:q,buffer:J,maxBuffer:X,lines:Z,timeoutDuration:H,cancelSignal:Q,gracefulCancel:Y,forceKillAfterDelay:G,stripFinalNewline:K,ipc:U,ipcInput:z},context:B,verboseInfo:L,fileDescriptors:W,originalStreams:P,onInternalError:M,controller:F})=>{let O=k5($,B),v={originalStreams:P,fileDescriptors:W,subprocess:$,exitPromise:O,propagating:!1},x=zq({subprocess:$,encoding:q,buffer:J,maxBuffer:X,lines:Z,stripFinalNewline:K,verboseInfo:L,streamInfo:v}),w=Lq({subprocess:$,encoding:q,buffer:J,maxBuffer:X,lines:Z,stripFinalNewline:K,verboseInfo:L,streamInfo:v}),N=[],g=Rq({subprocess:$,buffer:J,maxBuffer:X,ipc:U,ipcOutput:N,verboseInfo:L}),K1=pK(P,$,v),U1=lK(W,v);try{return await Promise.race([Promise.all([{},x5(O),Promise.all(x),w,g,n8($,z),...K1,...U1]),M,dK($,F),...u8($,H,B,F),...K8({subprocess:$,cancelSignal:Q,gracefulCancel:Y,context:B,controller:F}),...c8({subprocess:$,cancelSignal:Q,gracefulCancel:Y,forceKillAfterDelay:G,context:B,controller:F})])}catch(d$){return B.terminationReason??="other",Promise.all([{error:d$},O,Promise.all(x.map((i1)=>_4(i1))),_4(w),Wq(g,N),Promise.allSettled(K1),Promise.allSettled(U1)])}},pK=($,q,J)=>$.map((X,Z)=>X===q.stdio[Z]?void 0:H0(X,Z,J)),lK=($,q)=>$.flatMap(({stdioItems:J},X)=>J.filter(({value:Z,stream:H=Z})=>n(H,{checkOpen:!1})&&!d(H)).map(({type:Z,value:H,stream:Q=H})=>H0(Q,X,q,{isSameDirection:l.has(Z),stopOnExit:Z==="native"}))),dK=async($,{signal:q})=>{let[J]=await uK($,"error",{signal:q});throw J};var Pq=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Y0=($,q,J)=>{let X=$[J];if(!X.has(q))X.set(q,[]);let Z=X.get(q),H=s();return Z.push(H),{resolve:H.resolve.bind(H),promises:Z}},m1=async({resolve:$,promises:q},J)=>{$();let[X]=await Promise.race([Promise.allSettled([!0,J]),Promise.all([!1,...q])]);return!X};import{Readable as iK}from"node:stream";import{callbackify as nK}from"node:util";import{finished as kq}from"node:stream/promises";var W4=async($)=>{if($===void 0)return;try{await T4($)}catch{}},Fq=async($)=>{if($===void 0)return;try{await P4($)}catch{}},T4=async($)=>{await kq($,{cleanup:!0,readable:!1,writable:!0})},P4=async($)=>{await kq($,{cleanup:!0,readable:!0,writable:!1})},M$=async($,q)=>{if(await $,q)throw q},C$=($,q,J)=>{if(J&&!j$(J))$.destroy(J);else if(q)$.destroy()};var xq=({subprocess:$,concurrentStreams:q,encoding:J},{from:X,binary:Z=!0,preserveNewlines:H=!0}={})=>{let Q=Z||m.has(J),{subprocessStdout:Y,waitReadableDestroy:G}=k4($,X,q),{readableEncoding:K,readableObjectMode:U,readableHighWaterMark:z}=F4(Y,Q),{read:B,onStdoutDataDone:L}=x4({subprocessStdout:Y,subprocess:$,binary:Q,encoding:J,preserveNewlines:H}),W=new iK({read:B,destroy:nK(M4.bind(void 0,{subprocessStdout:Y,subprocess:$,waitReadableDestroy:G})),highWaterMark:z,objectMode:U,encoding:K});return j4({subprocessStdout:Y,onStdoutDataDone:L,readable:W,subprocess:$}),W},k4=($,q,J)=>{let X=v1($,q),Z=Y0(J,X,"readableDestroy");return{subprocessStdout:X,waitReadableDestroy:Z}},F4=({readableEncoding:$,readableObjectMode:q,readableHighWaterMark:J},X)=>X?{readableEncoding:$,readableObjectMode:q,readableHighWaterMark:J}:{readableEncoding:$,readableObjectMode:!0,readableHighWaterMark:L4},x4=({subprocessStdout:$,subprocess:q,binary:J,encoding:X,preserveNewlines:Z})=>{let H=s(),Q=x$({subprocessStdout:$,subprocess:q,binary:J,shouldEncode:!J,encoding:X,preserveNewlines:Z});return{read(){aK(this,Q,H)},onStdoutDataDone:H}},aK=async($,q,J)=>{try{let{value:X,done:Z}=await q.next();if(Z)J.resolve();else $.push(X)}catch{}},j4=async({subprocessStdout:$,onStdoutDataDone:q,readable:J,subprocess:X,subprocessStdin:Z})=>{try{if(await P4($),await X,await W4(Z),await q,J.readable)J.push(null)}catch(H){await W4(Z),jq(J,H)}},M4=async({subprocessStdout:$,subprocess:q,waitReadableDestroy:J},X)=>{if(await m1(J,q))jq($,X),await M$(q,X)},jq=($,q)=>{C$($,$.readable,q)};import{Writable as tK}from"node:stream";import{callbackify as Mq}from"node:util";var Cq=({subprocess:$,concurrentStreams:q},{to:J}={})=>{let{subprocessStdin:X,waitWritableFinal:Z,waitWritableDestroy:H}=C4($,J,q),Q=new tK({...I4(X,$,Z),destroy:Mq(A4.bind(void 0,{subprocessStdin:X,subprocess:$,waitWritableFinal:Z,waitWritableDestroy:H})),highWaterMark:X.writableHighWaterMark,objectMode:X.writableObjectMode});return w4(X,Q),Q},C4=($,q,J)=>{let X=c0($,q),Z=Y0(J,X,"writableFinal"),H=Y0(J,X,"writableDestroy");return{subprocessStdin:X,waitWritableFinal:Z,waitWritableDestroy:H}},I4=($,q,J)=>({write:oK.bind(void 0,$),final:Mq(rK.bind(void 0,$,q,J))}),oK=($,q,J,X)=>{if($.write(q,J))X();else $.once("drain",X)},rK=async($,q,J)=>{if(await m1(J,q)){if($.writable)$.end();await q}},w4=async($,q,J)=>{try{if(await T4($),q.writable)q.end()}catch(X){await Fq(J),Iq(q,X)}},A4=async({subprocessStdin:$,subprocess:q,waitWritableFinal:J,waitWritableDestroy:X},Z)=>{if(await m1(J,q),await m1(X,q))Iq($,Z),await M$(q,Z)},Iq=($,q)=>{C$($,$.writable,q)};import{Duplex as sK}from"node:stream";import{callbackify as eK}from"node:util";var wq=({subprocess:$,concurrentStreams:q,encoding:J},{from:X,to:Z,binary:H=!0,preserveNewlines:Q=!0}={})=>{let Y=H||m.has(J),{subprocessStdout:G,waitReadableDestroy:K}=k4($,X,q),{subprocessStdin:U,waitWritableFinal:z,waitWritableDestroy:B}=C4($,Z,q),{readableEncoding:L,readableObjectMode:W,readableHighWaterMark:P}=F4(G,Y),{read:M,onStdoutDataDone:F}=x4({subprocessStdout:G,subprocess:$,binary:Y,encoding:J,preserveNewlines:Q}),O=new sK({read:M,...I4(U,$,z),destroy:eK($U.bind(void 0,{subprocessStdout:G,subprocessStdin:U,subprocess:$,waitReadableDestroy:K,waitWritableFinal:z,waitWritableDestroy:B})),readableHighWaterMark:P,writableHighWaterMark:U.writableHighWaterMark,readableObjectMode:W,writableObjectMode:U.writableObjectMode,encoding:L});return j4({subprocessStdout:G,onStdoutDataDone:F,readable:O,subprocess:$,subprocessStdin:U}),w4(U,O,G),O},$U=async({subprocessStdout:$,subprocessStdin:q,subprocess:J,waitReadableDestroy:X,waitWritableFinal:Z,waitWritableDestroy:H},Q)=>{await Promise.all([M4({subprocessStdout:$,subprocess:J,waitReadableDestroy:X},Q),A4({subprocessStdin:q,subprocess:J,waitWritableFinal:Z,waitWritableDestroy:H},Q)])};var E4=($,q,{from:J,binary:X=!1,preserveNewlines:Z=!1}={})=>{let H=X||m.has(q),Q=v1($,J),Y=x$({subprocessStdout:Q,subprocess:$,binary:H,shouldEncode:!0,encoding:q,preserveNewlines:Z});return qU(Y,Q,$)},qU=async function*($,q,J){try{yield*$}finally{if(q.readable)q.destroy();await J}};var Aq=($,{encoding:q})=>{let J=Pq();$.readable=xq.bind(void 0,{subprocess:$,concurrentStreams:J,encoding:q}),$.writable=Cq.bind(void 0,{subprocess:$,concurrentStreams:J}),$.duplex=wq.bind(void 0,{subprocess:$,concurrentStreams:J,encoding:q}),$.iterable=E4.bind(void 0,$,q),$[Symbol.asyncIterator]=E4.bind(void 0,$,q,{})};var Eq=($,q)=>{for(let[J,X]of XU){let Z=X.value.bind(q);Reflect.defineProperty($,J,{...X,value:Z})}},JU=(async()=>{})().constructor.prototype,XU=["then","catch","finally"].map(($)=>[$,Reflect.getOwnPropertyDescriptor(JU,$)]);var yq=($,q,J,X)=>{let{file:Z,commandArguments:H,command:Q,escapedCommand:Y,startTime:G,verboseInfo:K,options:U,fileDescriptors:z}=HU($,q,J),{subprocess:B,promise:L}=GU({file:Z,commandArguments:H,options:U,startTime:G,verboseInfo:K,command:Q,escapedCommand:Y,fileDescriptors:z});return B.pipe=F$.bind(void 0,{source:B,sourcePromise:L,boundOptions:{},createNested:X}),Eq(B,L),e.set(B,{options:U,fileDescriptors:z}),B},HU=($,q,J)=>{let{command:X,escapedCommand:Z,startTime:H,verboseInfo:Q}=A0($,q,J),{file:Y,commandArguments:G,options:K}=r0($,q,J),U=YU(K),z=S5(U,Q);return{file:Y,commandArguments:G,command:X,escapedCommand:Z,startTime:H,verboseInfo:Q,options:U,fileDescriptors:z}},YU=({timeout:$,signal:q,...J})=>{if(q!==void 0)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...J,timeoutDuration:$}},GU=({file:$,commandArguments:q,options:J,startTime:X,verboseInfo:Z,command:H,escapedCommand:Q,fileDescriptors:Y})=>{let G;try{G=QU(...s0($,q,J))}catch(W){return D5({error:W,command:H,escapedCommand:Q,fileDescriptors:Y,options:J,startTime:X,verboseInfo:Z})}let K=new AbortController;ZU(Number.POSITIVE_INFINITY,K.signal);let U=[...G.stdio];n5(G,Y,K),s5(G,J,K);let z={},B=s();G.kill=Y8.bind(void 0,{kill:G.kill.bind(G),options:J,onInternalError:B,context:z,controller:K}),G.all=Bq(G,J),Aq(G,J),y5(G,J);let L=KU({subprocess:G,options:J,startTime:X,verboseInfo:Z,fileDescriptors:Y,originalStreams:U,command:H,escapedCommand:Q,context:z,onInternalError:B,controller:K});return{subprocess:G,promise:L}},KU=async({subprocess:$,options:q,startTime:J,verboseInfo:X,fileDescriptors:Z,originalStreams:H,command:Q,escapedCommand:Y,context:G,onInternalError:K,controller:U})=>{let[z,[B,L],W,P,M]=await Tq({subprocess:$,options:q,context:G,verboseInfo:X,fileDescriptors:Z,originalStreams:H,onInternalError:K,controller:U});U.abort(),K.resolve();let F=W.map((x,w)=>G1(x,q,w)),O=G1(P,q,"all"),v=UU({errorInfo:z,exitCode:B,signal:L,stdio:F,all:O,ipcOutput:M,context:G,options:q,command:Q,escapedCommand:Y,startTime:J});return b1(v,X,q)},UU=({errorInfo:$,exitCode:q,signal:J,stdio:X,all:Z,ipcOutput:H,context:Q,options:Y,command:G,escapedCommand:K,startTime:U})=>("error"in $)?q0({error:$.error,command:G,escapedCommand:K,timedOut:Q.terminationReason==="timeout",isCanceled:Q.terminationReason==="cancel"||Q.terminationReason==="gracefulCancel",isGracefullyCanceled:Q.terminationReason==="gracefulCancel",isMaxBuffer:$.error instanceof H1,isForcefullyTerminated:Q.isForcefullyTerminated,exitCode:q,signal:J,stdio:X,all:Z,ipcOutput:H,options:Y,startTime:U,isSync:!1}):Y$({command:G,escapedCommand:K,stdio:X,all:Z,ipcOutput:H,options:Y,startTime:U});var I$=($,q)=>{let J=Object.fromEntries(Object.entries(q).map(([X,Z])=>[X,zU(X,$[X],Z)]));return{...$,...J}},zU=($,q,J)=>{if(BU.has($)&&E(q)&&E(J))return{...q,...J};return J},BU=new Set(["env",...G2]);var _1=($,q,J,X)=>{let Z=(Q,Y,G)=>_1(Q,Y,J,G),H=(...Q)=>LU({mapArguments:$,deepOptions:J,boundOptions:q,setBoundExeca:X,createNested:Z},...Q);if(X!==void 0)X(H,Z,q);return H},LU=({mapArguments:$,deepOptions:q={},boundOptions:J={},setBoundExeca:X,createNested:Z},H,...Q)=>{if(E(H))return Z($,I$(J,H),X);let{file:Y,commandArguments:G,options:K,isSync:U}=_U({mapArguments:$,firstArgument:H,nextArguments:Q,deepOptions:q,boundOptions:J});return U?M5(Y,G,K):yq(Y,G,K,Z)},_U=({mapArguments:$,firstArgument:q,nextArguments:J,deepOptions:X,boundOptions:Z})=>{let H=S3(q)?b3(q,J):[q,...J],[Q,Y,G]=W0(...H),K=I$(I$(X,Z),G),{file:U=Q,commandArguments:z=Y,options:B=K,isSync:L=!1}=$({file:Q,commandArguments:Y,options:K});return{file:U,commandArguments:z,options:B,isSync:L}};var Oq=({file:$,commandArguments:q})=>Dq($,q),Nq=({file:$,commandArguments:q})=>({...Dq($,q),isSync:!0}),Dq=($,q)=>{if(q.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${$} ${q}.`);let[J,...X]=VU($);return{file:J,commandArguments:X}},VU=($)=>{if(typeof $!=="string")throw TypeError(`The command must be a string: ${String($)}.`);let q=$.trim();if(q==="")return[];let J=[];for(let X of q.split(RU)){let Z=J.at(-1);if(Z&&Z.endsWith("\\"))J[J.length-1]=`${Z.slice(0,-1)} ${X}`;else J.push(X)}return J},RU=/ +/g;var vq=($,q,J)=>{$.sync=q(WU,J),$.s=$.sync},fq=({options:$})=>hq($),WU=({options:$})=>({...hq($),isSync:!0}),hq=($)=>({options:{...TU($),...$}}),TU=({input:$,inputFile:q,stdio:J})=>$===void 0&&q===void 0&&J===void 0?{stdin:"inherit"}:{},Sq={preferLocal:!0};var h=_1(()=>({})),Zj=_1(()=>({isSync:!0})),Qj=_1(Oq),Hj=_1(Nq),Yj=_1(l8),Gj=_1(fq,{},Sq,vq),{sendMessage:Kj,getOneMessage:Uj,getEachMessage:zj,getCancelSignal:Bj}=O5();import{access as bq,readFile as cq}from"fs/promises";import{join as y4,dirname as gq}from"path";async function O4(){if(process.env.IDF_PATH)try{return await bq(process.env.IDF_PATH),process.env.IDF_PATH}catch{}try{return await bq($2),$2}catch{}return null}async function w$($){let q=y4($,"version.txt");try{return(await cq(q,"utf-8")).trim()}catch{}try{return(await h("git",["describe","--tags"],{cwd:$})).stdout.trim()}catch{}return null}async function mq(){let $=await O4();if(!$)return{installed:!1};let q=await w$($);return{installed:!0,path:$,version:q||void 0}}async function M1($){let q=y4($,"CMakeLists.txt");try{let J=await cq(q,"utf-8");return J.includes("$ENV{IDF_PATH}")||J.includes("idf_component_register")}catch{return!1}}async function q1($){let q=$;while(q!==gq(q)){if(await M1(q))return q;q=gq(q)}return null}function N4($){return y4($,"export.sh")}async function D4($,q,J={}){let{cwd:X,operationId:Z,env:H}=J,Q={cwd:X,env:{...process.env,...H},reject:!1};try{let Y=h($,q,Q);if(Z)Y.stdout?.on("data",(K)=>{R.emit(Z,{type:"stdout",text:K.toString()})}),Y.stderr?.on("data",(K)=>{R.emit(Z,{type:"stderr",text:K.toString()})});let G=await Y;return{ok:!0,data:{stdout:String(G.stdout??""),stderr:String(G.stderr??""),exitCode:G.exitCode??0}}}catch(Y){return{ok:!1,error:`Failed to execute ${$}: ${Y}`}}}async function J1($,q,J={}){let X=await O4();if(!X)return{ok:!1,error:"ESP-IDF not found. Run `espcli install` first.",code:"IDF_NOT_FOUND"};let H=`source ${N4(X)} > /dev/null 2>&1 && ${$} ${q.join(" ")}`,{cwd:Q,operationId:Y,env:G}=J,K={cwd:Q,env:{...process.env,...G},shell:!0,reject:!1};try{let U=h(H,[],K);if(Y)U.stdout?.on("data",(B)=>{R.emit(Y,{type:"stdout",text:B.toString()})}),U.stderr?.on("data",(B)=>{R.emit(Y,{type:"stderr",text:B.toString()})});let z=await U;return{ok:!0,data:{stdout:String(z.stdout??""),stderr:String(z.stderr??""),exitCode:z.exitCode??0}}}catch(U){return{ok:!1,error:`Failed to execute ${$}: ${U}`}}}function uq($,q,J={}){let X=process.env.IDF_PATH;if(!X)return null;let H=`source ${N4(X)} > /dev/null 2>&1 && ${$} ${q.join(" ")}`,{cwd:Q,operationId:Y,env:G}=J,K=h(H,[],{cwd:Q,env:{...process.env,...G},shell:!0,reject:!1});if(Y)K.stdout?.on("data",(U)=>{R.emit(Y,{type:"stdout",text:U.toString()})}),K.stderr?.on("data",(U)=>{R.emit(Y,{type:"stderr",text:U.toString()})});return K}import{homedir as PU}from"os";import{join as kU}from"path";import{readFile as FU,appendFile as xU,access as wj}from"fs/promises";function pq(){let $=process.env.SHELL||"";if($.includes("zsh"))return"zsh";if($.includes("bash"))return"bash";if($.includes("fish"))return"fish";return"unknown"}function A$(){let $=pq(),q=w3[$]||"",J=q?kU(PU(),q):"";return{type:$,configPath:J}}async function jU($){let{configPath:q}=A$();if(!q)return!1;try{return(await FU(q,"utf-8")).includes($)}catch{return!1}}async function lq($){let{configPath:q,type:J}=A$();if(!q)return{ok:!1,error:`Unsupported shell: ${J}`};if(await jU($))return{ok:!0,data:void 0};try{return await xU(q,`
|
|
69
|
+
if (condition) { yield value; }`)};import{Buffer as tY}from"node:buffer";import{StringDecoder as oY}from"node:string_decoder";var P$=($,q,J)=>{if(J)return;if($)return{transform:rY.bind(void 0,new TextEncoder)};let X=new oY(q);return{transform:sY.bind(void 0,X),final:eY.bind(void 0,X)}},rY=function*($,q){if(tY.isBuffer(q))yield H1(q);else if(typeof q==="string")yield $.encode(q);else yield q},sY=function*($,q){yield D(q)?$.write(q):q},eY=function*($){let q=$.end();if(q!=="")yield q};import{callbackify as W5}from"node:util";var H4=W5(async($,q,J,X)=>{q.currentIterable=$(...J);try{for await(let Z of q.currentIterable)X.push(Z)}finally{delete q.currentIterable}}),k$=async function*($,q,J){if(J===q.length){yield $;return}let{transform:X=qG}=q[J];for await(let Z of X($))yield*k$(Z,q,J+1)},_5=async function*($){for(let[q,{final:J}]of Object.entries($))yield*$G(J,Number(q),$)},$G=async function*($,q,J){if($===void 0)return;for await(let X of $())yield*k$(X,J,q+1)},R5=W5(async({currentIterable:$},q)=>{if($!==void 0){await(q?$.throw(q):$.return());return}if(q)throw q}),qG=function*($){yield $};var Y4=($,q,J,X)=>{try{for(let Z of $(...q))J.push(Z);X()}catch(Z){X(Z)}},T5=($,q)=>[...q.flatMap((J)=>[...M1(J,$,0)]),...G0($)],M1=function*($,q,J){if(J===q.length){yield $;return}let{transform:X=XG}=q[J];for(let Z of X($))yield*M1(Z,q,J+1)},G0=function*($){for(let[q,{final:J}]of Object.entries($))yield*JG(J,Number(q),$)},JG=function*($,q,J){if($===void 0)return;for(let X of $())yield*M1(X,J,q+1)},XG=function*($){yield $};var G4=({value:$,value:{transform:q,final:J,writableObjectMode:X,readableObjectMode:Z},optionName:H},{encoding:Q})=>{let Y={},G=k5($,Q,H),K=j1(q),U=j1(J),z=K?H4.bind(void 0,k$,Y):Y4.bind(void 0,M1),B=K||U?H4.bind(void 0,_5,Y):Y4.bind(void 0,G0),L=K||U?R5.bind(void 0,Y):void 0;return{stream:new ZG({writableObjectMode:X,writableHighWaterMark:P5(X),readableObjectMode:Z,readableHighWaterMark:P5(Z),transform(P,M,F){z([P,G,0],this,F)},flush(P){B([G],this,P)},destroy:L})}},F$=($,q,J,X)=>{let Z=q.filter(({type:Q})=>Q==="generator"),H=X?Z.reverse():Z;for(let{value:Q,optionName:Y}of H){let G=k5(Q,J,Y);$=T5(G,$)}return $},k5=({transform:$,final:q,binary:J,writableObjectMode:X,readableObjectMode:Z,preserveNewlines:H},Q,Y)=>{let G={};return[{transform:B5(X,Y)},P$(J,Q,X),T$(J,H,X,G),{transform:$,final:q},{transform:L5(Z,Y)},z5({binary:J,preserveNewlines:H,readableObjectMode:Z,state:G})].filter(Boolean)};var F5=($,q)=>{for(let J of QG($))HG($,J,q)},QG=($)=>new Set(Object.entries($).filter(([,{direction:q}])=>q==="input").map(([q])=>Number(q))),HG=($,q,J)=>{let{stdioItems:X}=$[q],Z=X.filter(({contents:Y})=>Y!==void 0);if(Z.length===0)return;if(q!==0){let[{type:Y,optionName:G}]=Z;throw TypeError(`Only the \`stdin\` option, not \`${G}\`, can be ${_1[Y]} with synchronous methods.`)}let Q=Z.map(({contents:Y})=>Y).map((Y)=>YG(Y,X));J.input=$0(Q)},YG=($,q)=>{let J=F$($,q,"utf8",!0);return GG(J),$0(J)},GG=($)=>{let q=$.find((J)=>typeof J!=="string"&&!D(J));if(q!==void 0)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${q}.`)};import{writeFileSync as BG,appendFileSync as LG}from"node:fs";var x$=({stdioItems:$,encoding:q,verboseInfo:J,fdNumber:X})=>X!=="all"&&h1(J,X)&&!u.has(q)&&KG(X)&&($.some(({type:Z,value:H})=>Z==="native"&&UG.has(H))||$.every(({type:Z})=>d.has(Z))),KG=($)=>$===1||$===2,UG=new Set(["pipe","overlapped"]),x5=async($,q,J,X)=>{for await(let Z of $)if(!zG(q))M5(Z,J,X)},j5=($,q,J)=>{for(let X of $)M5(X,q,J)},zG=($)=>$._readableState.pipes.length>0,M5=($,q,J)=>{let X=N0($);r({type:"output",verboseMessage:X,fdNumber:q,verboseInfo:J})};var C5=({fileDescriptors:$,syncResult:{output:q},options:J,isMaxBuffer:X,verboseInfo:Z})=>{if(q===null)return{output:Array.from({length:3})};let H={},Q=new Set([]);return{output:q.map((G,K)=>VG({result:G,fileDescriptors:$,fdNumber:K,state:H,outputFiles:Q,isMaxBuffer:X,verboseInfo:Z},J)),...H}},VG=({result:$,fileDescriptors:q,fdNumber:J,state:X,outputFiles:Z,isMaxBuffer:H,verboseInfo:Q},{buffer:Y,encoding:G,lines:K,stripFinalNewline:U,maxBuffer:z})=>{if($===null)return;let B=w7($,H,z),L=H1(B),{stdioItems:_,objectMode:P}=q[J],M=WG([L],_,G,X),{serializedResult:F,finalResult:O=F}=_G({chunks:M,objectMode:P,encoding:G,lines:K,stripFinalNewline:U,fdNumber:J});RG({serializedResult:F,fdNumber:J,state:X,verboseInfo:Q,encoding:G,stdioItems:_,objectMode:P});let v=Y[J]?O:void 0;try{if(X.error===void 0)TG(F,_,Z);return v}catch(x){return X.error=x,v}},WG=($,q,J,X)=>{try{return F$($,q,J,!1)}catch(Z){return X.error=Z,$}},_G=({chunks:$,objectMode:q,encoding:J,lines:X,stripFinalNewline:Z,fdNumber:H})=>{if(q)return{serializedResult:$};if(J==="buffer")return{serializedResult:$0($)};let Q=c3($,J);if(X[H])return{serializedResult:Q,finalResult:Q4(Q,!Z[H],q)};return{serializedResult:Q}},RG=({serializedResult:$,fdNumber:q,state:J,verboseInfo:X,encoding:Z,stdioItems:H,objectMode:Q})=>{if(!x$({stdioItems:H,encoding:Z,verboseInfo:X,fdNumber:q}))return;let Y=Q4($,!1,Q);try{j5(Y,q,X)}catch(G){J.error??=G}},TG=($,q,J)=>{for(let{path:X,append:Z}of q.filter(({type:H})=>_$.has(H))){let H=typeof X==="string"?X:X.toString();if(Z||J.has(H))LG(X,$);else J.add(H),BG(X,$)}};var w5=([,$,q],J)=>{if(!J.all)return;if($===void 0)return q;if(q===void 0)return $;if(Array.isArray($))return Array.isArray(q)?[...$,...q]:[...$,U1(q,J,"all")];if(Array.isArray(q))return[U1($,J,"all"),...q];if(D($)&&D(q))return V2([$,q]);return`${$}${q}`};import{once as K4}from"node:events";var I5=async($,q)=>{let[J,X]=await PG($);return q.isForcefullyTerminated??=!1,[J,X]},PG=async($)=>{let[q,J]=await Promise.allSettled([K4($,"spawn"),K4($,"exit")]);if(q.status==="rejected")return[];return J.status==="rejected"?A5($):J.value},A5=async($)=>{try{return await K4($,"exit")}catch{return A5($)}},E5=async($)=>{let[q,J]=await $;if(!kG(q,J)&&U4(q,J))throw new s;return[q,J]},kG=($,q)=>$===void 0&&q===void 0,U4=($,q)=>$!==0||q!==null;var y5=({error:$,status:q,signal:J,output:X},{maxBuffer:Z})=>{let H=FG($,q,J),Q=H?.code==="ETIMEDOUT",Y=C7(H,X,Z);return{resultError:H,exitCode:q,signal:J,timedOut:Q,isMaxBuffer:Y}},FG=($,q,J)=>{if($!==void 0)return $;return U4(q,J)?new s:void 0};var O5=($,q,J)=>{let{file:X,commandArguments:Z,command:H,escapedCommand:Q,startTime:Y,verboseInfo:G,options:K,fileDescriptors:U}=jG($,q,J),z=wG({file:X,commandArguments:Z,options:K,command:H,escapedCommand:Q,verboseInfo:G,fileDescriptors:U,startTime:Y});return l1(z,G,K)},jG=($,q,J)=>{let{command:X,escapedCommand:Z,startTime:H,verboseInfo:Q}=v0($,q,J),Y=MG(J),{file:G,commandArguments:K,options:U}=X$($,q,Y);CG(U);let z=Y5(U,Q);return{file:G,commandArguments:K,command:X,escapedCommand:Z,startTime:H,verboseInfo:Q,options:U,fileDescriptors:z}},MG=($)=>$.node&&!$.ipc?{...$,ipc:!1}:$,CG=({ipc:$,ipcInput:q,detached:J,cancelSignal:X})=>{if(q)j$("ipcInput");if($)j$("ipc: true");if(J)j$("detached: true");if(X)j$("cancelSignal")},j$=($)=>{throw TypeError(`The "${$}" option cannot be used with synchronous methods.`)},wG=({file:$,commandArguments:q,options:J,command:X,escapedCommand:Z,verboseInfo:H,fileDescriptors:Q,startTime:Y})=>{let G=IG({file:$,commandArguments:q,options:J,command:X,escapedCommand:Z,fileDescriptors:Q,startTime:Y});if(G.failed)return G;let{resultError:K,exitCode:U,signal:z,timedOut:B,isMaxBuffer:L}=y5(G,J),{output:_,error:P=K}=C5({fileDescriptors:Q,syncResult:G,options:J,isMaxBuffer:L,verboseInfo:H}),M=_.map((O,v)=>U1(O,J,v)),F=U1(w5(_,J),J,"all");return EG({error:P,exitCode:U,signal:z,timedOut:B,isMaxBuffer:L,stdio:M,all:F,options:J,command:X,escapedCommand:Z,startTime:Y})},IG=({file:$,commandArguments:q,options:J,command:X,escapedCommand:Z,fileDescriptors:H,startTime:Q})=>{try{F5(H,J);let Y=AG(J);return xG(...Z$($,q,Y))}catch(Y){return p1({error:Y,command:X,escapedCommand:Z,fileDescriptors:H,options:J,startTime:Q,isSync:!0})}},AG=({encoding:$,maxBuffer:q,...J})=>({...J,encoding:"buffer",maxBuffer:B$(q)}),EG=({error:$,exitCode:q,signal:J,timedOut:X,isMaxBuffer:Z,stdio:H,all:Q,options:Y,command:G,escapedCommand:K,startTime:U})=>$===void 0?L$({command:G,escapedCommand:K,stdio:H,all:Q,ipcOutput:[],options:Y,startTime:U}):Y0({error:$,command:G,escapedCommand:K,timedOut:X,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:Z,isForcefullyTerminated:!1,exitCode:q,signal:J,stdio:H,all:Q,ipcOutput:[],options:Y,startTime:U,isSync:!0});import{setMaxListeners as _U}from"node:events";import{spawn as RU}from"node:child_process";import f5 from"node:process";import{once as z4,on as yG}from"node:events";var N5=({anyProcess:$,channel:q,isSubprocess:J,ipc:X},{reference:Z=!0,filter:H}={})=>{return b1({methodName:"getOneMessage",isSubprocess:J,ipc:X,isConnected:r0($)}),OG({anyProcess:$,channel:q,isSubprocess:J,filter:H,reference:Z})},OG=async({anyProcess:$,channel:q,isSubprocess:J,filter:X,reference:Z})=>{n0(q,Z);let H=W1($,q,J),Q=new AbortController;try{return await Promise.race([NG(H,X,Q),DG(H,J,Q),vG(H,J,Q)])}catch(Y){throw g1($),Y}finally{Q.abort(),a0(q,Z)}},NG=async($,q,{signal:J})=>{if(q===void 0){let[X]=await z4($,"message",{signal:J});return X}for await(let[X]of yG($,"message",{signal:J}))if(q(X))return X},DG=async($,q,{signal:J})=>{await z4($,"disconnect",{signal:J}),R8(q)},vG=async($,q,{signal:J})=>{let[X]=await z4($,"strict:error",{signal:J});throw l0(X,q)};import{once as v5,on as hG}from"node:events";var h5=({anyProcess:$,channel:q,isSubprocess:J,ipc:X},{reference:Z=!0}={})=>B4({anyProcess:$,channel:q,isSubprocess:J,ipc:X,shouldAwait:!J,reference:Z}),B4=({anyProcess:$,channel:q,isSubprocess:J,ipc:X,shouldAwait:Z,reference:H})=>{b1({methodName:"getEachMessage",isSubprocess:J,ipc:X,isConnected:r0($)}),n0(q,H);let Q=W1($,q,J),Y=new AbortController,G={};return fG($,Q,Y),SG({ipcEmitter:Q,isSubprocess:J,controller:Y,state:G}),bG({anyProcess:$,channel:q,ipcEmitter:Q,isSubprocess:J,shouldAwait:Z,controller:Y,state:G,reference:H})},fG=async($,q,J)=>{try{await v5(q,"disconnect",{signal:J.signal}),J.abort()}catch{}},SG=async({ipcEmitter:$,isSubprocess:q,controller:J,state:X})=>{try{let[Z]=await v5($,"strict:error",{signal:J.signal});X.error=l0(Z,q),J.abort()}catch{}},bG=async function*({anyProcess:$,channel:q,ipcEmitter:J,isSubprocess:X,shouldAwait:Z,controller:H,state:Q,reference:Y}){try{for await(let[G]of hG(J,"message",{signal:H.signal}))D5(Q),yield G}catch{D5(Q)}finally{if(H.abort(),a0(q,Y),!X)g1($);if(Z)await $}},D5=({error:$})=>{if($)throw $};var S5=($,{ipc:q})=>{Object.assign($,g5($,!1,q))},b5=()=>{let $=f5,q=!0,J=f5.channel!==void 0;return{...g5($,!0,J),getCancelSignal:l8.bind(void 0,{anyProcess:$,channel:$.channel,isSubprocess:!0,ipc:J})}},g5=($,q,J)=>({sendMessage:q$.bind(void 0,{anyProcess:$,channel:$.channel,isSubprocess:q,ipc:J}),getOneMessage:N5.bind(void 0,{anyProcess:$,channel:$.channel,isSubprocess:q,ipc:J}),getEachMessage:h5.bind(void 0,{anyProcess:$,channel:$.channel,isSubprocess:q,ipc:J})});import{ChildProcess as gG}from"node:child_process";import{PassThrough as cG,Readable as mG,Writable as uG,Duplex as pG}from"node:stream";var c5=({error:$,command:q,escapedCommand:J,fileDescriptors:X,options:Z,startTime:H,verboseInfo:Q})=>{J4(X);let Y=new gG;lG(Y,X),Object.assign(Y,{readable:dG,writable:iG,duplex:nG});let G=p1({error:$,command:q,escapedCommand:J,fileDescriptors:X,options:Z,startTime:H,isSync:!1}),K=aG(G,Q,Z);return{subprocess:Y,promise:K}},lG=($,q)=>{let J=K0(),X=K0(),Z=K0(),H=Array.from({length:q.length-3},K0),Q=K0(),Y=[J,X,Z,...H];Object.assign($,{stdin:J,stdout:X,stderr:Z,all:Q,stdio:Y})},K0=()=>{let $=new cG;return $.end(),$},dG=()=>new mG({read(){}}),iG=()=>new uG({write(){}}),nG=()=>new pG({read(){},write(){}}),aG=async($,q,J)=>l1($,q,J);import{createReadStream as m5,createWriteStream as u5}from"node:fs";import{Buffer as tG}from"node:buffer";import{Readable as U0,Writable as oG,Duplex as rG}from"node:stream";var l5=($,q)=>R$(sG,$,q,!1),z0=({type:$,optionName:q})=>{throw TypeError(`The \`${q}\` option cannot be ${_1[$]}.`)},p5={fileNumber:z0,generator:G4,asyncGenerator:G4,nodeStream:({value:$})=>({stream:$}),webTransform({value:{transform:$,writableObjectMode:q,readableObjectMode:J}}){let X=q||J;return{stream:rG.fromWeb($,{objectMode:X})}},duplex:({value:{transform:$}})=>({stream:$}),native(){}},sG={input:{...p5,fileUrl:({value:$})=>({stream:m5($)}),filePath:({value:{file:$}})=>({stream:m5($)}),webStream:({value:$})=>({stream:U0.fromWeb($)}),iterable:({value:$})=>({stream:U0.from($)}),asyncIterable:({value:$})=>({stream:U0.from($)}),string:({value:$})=>({stream:U0.from($)}),uint8Array:({value:$})=>({stream:U0.from(tG.from($))})},output:{...p5,fileUrl:({value:$})=>({stream:u5($)}),filePath:({value:{file:$,append:q}})=>({stream:u5($,q?{flags:"a"}:{})}),webStream:({value:$})=>({stream:oG.fromWeb($)}),iterable:z0,asyncIterable:z0,string:z0,uint8Array:z0}};import{on as eG,once as d5}from"node:events";import{PassThrough as $K,getDefaultHighWaterMark as qK}from"node:stream";import{finished as a5}from"node:stream/promises";function C1($){if(!Array.isArray($))throw TypeError(`Expected an array, got \`${typeof $}\`.`);for(let Z of $)L4(Z);let q=$.some(({readableObjectMode:Z})=>Z),J=JK($,q),X=new t5({objectMode:q,writableHighWaterMark:J,readableHighWaterMark:J});for(let Z of $)X.add(Z);return X}var JK=($,q)=>{if($.length===0)return qK(q);let J=$.filter(({readableObjectMode:X})=>X===q).map(({readableHighWaterMark:X})=>X);return Math.max(...J)};class t5 extends $K{#q=new Set([]);#J=new Set([]);#$=new Set([]);#X;#Q=Symbol("unpipe");#Z=new WeakMap;add($){if(L4($),this.#q.has($))return;this.#q.add($),this.#X??=XK(this,this.#q,this.#Q);let q=HK({passThroughStream:this,stream:$,streams:this.#q,ended:this.#J,aborted:this.#$,onFinished:this.#X,unpipeEvent:this.#Q});this.#Z.set($,q),$.pipe(this,{end:!1})}async remove($){if(L4($),!this.#q.has($))return!1;let q=this.#Z.get($);if(q===void 0)return!1;return this.#Z.delete($),$.unpipe(this),await q,!0}}var XK=async($,q,J)=>{M$($,i5);let X=new AbortController;try{await Promise.race([ZK($,X),QK($,q,J,X)])}finally{X.abort(),M$($,-i5)}},ZK=async($,{signal:q})=>{try{await a5($,{signal:q,cleanup:!0})}catch(J){throw o5($,J),J}},QK=async($,q,J,{signal:X})=>{for await(let[Z]of eG($,"unpipe",{signal:X}))if(q.has(Z))Z.emit(J)},L4=($)=>{if(typeof $?.pipe!=="function")throw TypeError(`Expected a readable stream, got: \`${typeof $}\`.`)},HK=async({passThroughStream:$,stream:q,streams:J,ended:X,aborted:Z,onFinished:H,unpipeEvent:Q})=>{M$($,n5);let Y=new AbortController;try{await Promise.race([YK(H,q,Y),GK({passThroughStream:$,stream:q,streams:J,ended:X,aborted:Z,controller:Y}),KK({stream:q,streams:J,ended:X,aborted:Z,unpipeEvent:Q,controller:Y})])}finally{Y.abort(),M$($,-n5)}if(J.size>0&&J.size===X.size+Z.size)if(X.size===0&&Z.size>0)V4($);else UK($)},YK=async($,q,{signal:J})=>{try{if(await $,!J.aborted)V4(q)}catch(X){if(!J.aborted)o5(q,X)}},GK=async({passThroughStream:$,stream:q,streams:J,ended:X,aborted:Z,controller:{signal:H}})=>{try{if(await a5(q,{signal:H,cleanup:!0,readable:!0,writable:!1}),J.has(q))X.add(q)}catch(Q){if(H.aborted||!J.has(q))return;if(r5(Q))Z.add(q);else s5($,Q)}},KK=async({stream:$,streams:q,ended:J,aborted:X,unpipeEvent:Z,controller:{signal:H}})=>{if(await d5($,Z,{signal:H}),!$.readable)return d5(H,"abort",{signal:H});q.delete($),J.delete($),X.delete($)},UK=($)=>{if($.writable)$.end()},o5=($,q)=>{if(r5(q))V4($);else s5($,q)},r5=($)=>$?.code==="ERR_STREAM_PREMATURE_CLOSE",V4=($)=>{if($.readable||$.writable)$.destroy()},s5=($,q)=>{if(!$.destroyed)$.once("error",zK),$.destroy(q)},zK=()=>{},M$=($,q)=>{let J=$.getMaxListeners();if(J!==0&&J!==Number.POSITIVE_INFINITY)$.setMaxListeners(J+q)},i5=2,n5=1;import{finished as e5}from"node:stream/promises";var i1=($,q)=>{$.pipe(q),BK($,q),LK($,q)},BK=async($,q)=>{if(i($)||i(q))return;try{await e5($,{cleanup:!0,readable:!0,writable:!1})}catch{}W4(q)},W4=($)=>{if($.writable)$.end()},LK=async($,q)=>{if(i($)||i(q))return;try{await e5(q,{cleanup:!0,readable:!1,writable:!0})}catch{}_4($)},_4=($)=>{if($.readable)$.destroy()};var $q=($,q,J)=>{let X=new Map;for(let[Z,{stdioItems:H,direction:Q}]of Object.entries(q)){for(let{stream:Y}of H.filter(({type:G})=>d.has(G)))VK($,Y,Q,Z);for(let{stream:Y}of H.filter(({type:G})=>!d.has(G)))_K({subprocess:$,stream:Y,direction:Q,fdNumber:Z,pipeGroups:X,controller:J})}for(let[Z,H]of X.entries()){let Q=H.length===1?H[0]:C1(H);i1(Q,Z)}},VK=($,q,J,X)=>{if(J==="output")i1($.stdio[X],q);else i1(q,$.stdio[X]);let Z=WK[X];if(Z!==void 0)$[Z]=q;$.stdio[X]=q},WK=["stdin","stdout","stderr"],_K=({subprocess:$,stream:q,direction:J,fdNumber:X,pipeGroups:Z,controller:H})=>{if(q===void 0)return;RK(q,H);let[Q,Y]=J==="output"?[q,$.stdio[X]]:[$.stdio[X],q],G=Z.get(Q)??[];Z.set(Q,[...G,Y])},RK=($,{signal:q})=>{if(i($))F1($,TK,q)},TK=2;import{addAbortListener as FK}from"node:events";var w1=[];w1.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")w1.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")w1.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var C$=($)=>!!$&&typeof $==="object"&&typeof $.removeListener==="function"&&typeof $.emit==="function"&&typeof $.reallyExit==="function"&&typeof $.listeners==="function"&&typeof $.kill==="function"&&typeof $.pid==="number"&&typeof $.on==="function",R4=Symbol.for("signal-exit emitter"),T4=globalThis,PK=Object.defineProperty.bind(Object);class qq{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(T4[R4])return T4[R4];PK(T4,R4,{value:this,writable:!1,enumerable:!1,configurable:!1})}on($,q){this.listeners[$].push(q)}removeListener($,q){let J=this.listeners[$],X=J.indexOf(q);if(X===-1)return;if(X===0&&J.length===1)J.length=0;else J.splice(X,1)}emit($,q,J){if(this.emitted[$])return!1;this.emitted[$]=!0;let X=!1;for(let Z of this.listeners[$])X=Z(q,J)===!0||X;if($==="exit")X=this.emit("afterExit",q,J)||X;return X}}class k4{}var kK=($)=>{return{onExit(q,J){return $.onExit(q,J)},load(){return $.load()},unload(){return $.unload()}}};class Jq extends k4{onExit(){return()=>{}}load(){}unload(){}}class Xq extends k4{#q=P4.platform==="win32"?"SIGINT":"SIGHUP";#J=new qq;#$;#X;#Q;#Z={};#H=!1;constructor($){super();this.#$=$,this.#Z={};for(let q of w1)this.#Z[q]=()=>{let J=this.#$.listeners(q),{count:X}=this.#J,Z=$;if(typeof Z.__signal_exit_emitter__==="object"&&typeof Z.__signal_exit_emitter__.count==="number")X+=Z.__signal_exit_emitter__.count;if(J.length===X){this.unload();let H=this.#J.emit("exit",null,q),Q=q==="SIGHUP"?this.#q:q;if(!H)$.kill($.pid,Q)}};this.#Q=$.reallyExit,this.#X=$.emit}onExit($,q){if(!C$(this.#$))return()=>{};if(this.#H===!1)this.load();let J=q?.alwaysLast?"afterExit":"exit";return this.#J.on(J,$),()=>{if(this.#J.removeListener(J,$),this.#J.listeners.exit.length===0&&this.#J.listeners.afterExit.length===0)this.unload()}}load(){if(this.#H)return;this.#H=!0,this.#J.count+=1;for(let $ of w1)try{let q=this.#Z[$];if(q)this.#$.on($,q)}catch(q){}this.#$.emit=($,...q)=>{return this.#G($,...q)},this.#$.reallyExit=($)=>{return this.#Y($)}}unload(){if(!this.#H)return;this.#H=!1,w1.forEach(($)=>{let q=this.#Z[$];if(!q)throw Error("Listener not defined for signal: "+$);try{this.#$.removeListener($,q)}catch(J){}}),this.#$.emit=this.#X,this.#$.reallyExit=this.#Q,this.#J.count-=1}#Y($){if(!C$(this.#$))return 0;return this.#$.exitCode=$||0,this.#J.emit("exit",this.#$.exitCode,null),this.#Q.call(this.#$,this.#$.exitCode)}#G($,...q){let J=this.#X;if($==="exit"&&C$(this.#$)){if(typeof q[0]==="number")this.#$.exitCode=q[0];let X=J.call(this.#$,$,...q);return this.#J.emit("exit",this.#$.exitCode,null),X}else return J.call(this.#$,$,...q)}}var P4=globalThis.process,{onExit:Zq,load:Nk,unload:Dk}=kK(C$(P4)?new Xq(P4):new Jq);var Qq=($,{cleanup:q,detached:J},{signal:X})=>{if(!q||J)return;let Z=Zq(()=>{$.kill()});FK(X,()=>{Z()})};var Yq=({source:$,sourcePromise:q,boundOptions:J,createNested:X},...Z)=>{let H=D0(),{destination:Q,destinationStream:Y,destinationError:G,from:K,unpipeSignal:U}=xK(J,X,Z),{sourceStream:z,sourceError:B}=MK($,K),{options:L,fileDescriptors:_}=$1.get($);return{sourcePromise:q,sourceStream:z,sourceOptions:L,sourceError:B,destination:Q,destinationStream:Y,destinationError:G,unpipeSignal:U,fileDescriptors:_,startTime:H}},xK=($,q,J)=>{try{let{destination:X,pipeOptions:{from:Z,to:H,unpipeSignal:Q}={}}=jK($,q,...J),Y=i0(X,H);return{destination:X,destinationStream:Y,from:Z,unpipeSignal:Q}}catch(X){return{destinationError:X}}},jK=($,q,J,...X)=>{if(Array.isArray(J))return{destination:q(Hq,$)(J,...X),pipeOptions:$};if(typeof J==="string"||J instanceof URL||B2(J)){if(Object.keys($).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[Z,H,Q]=j0(J,...X);return{destination:q(Hq)(Z,H,Q),pipeOptions:Q}}if($1.has(J)){if(Object.keys($).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:J,pipeOptions:X[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${J}`)},Hq=({options:$})=>({options:{...$,stdin:"pipe",piped:!0}}),MK=($,q)=>{try{return{sourceStream:c1($,q)}}catch(J){return{sourceError:J}}};var Kq=({sourceStream:$,sourceError:q,destinationStream:J,destinationError:X,fileDescriptors:Z,sourceOptions:H,startTime:Q})=>{let Y=CK({sourceStream:$,sourceError:q,destinationStream:J,destinationError:X});if(Y!==void 0)throw F4({error:Y,fileDescriptors:Z,sourceOptions:H,startTime:Q})},CK=({sourceStream:$,sourceError:q,destinationStream:J,destinationError:X})=>{if(q!==void 0&&X!==void 0)return X;if(X!==void 0)return _4($),X;if(q!==void 0)return W4(J),q},F4=({error:$,fileDescriptors:q,sourceOptions:J,startTime:X})=>p1({error:$,command:Gq,escapedCommand:Gq,fileDescriptors:q,options:J,startTime:X,isSync:!1}),Gq="source.pipe(destination)";var Uq=async($)=>{let[{status:q,reason:J,value:X=J},{status:Z,reason:H,value:Q=H}]=await $;if(!Q.pipedFrom.includes(X))Q.pipedFrom.push(X);if(Z==="rejected")throw Q;if(q==="rejected")throw X;return Q};import{finished as wK}from"node:stream/promises";var zq=($,q,J)=>{let X=w$.has(q)?AK($,q):IK($,q);return F1($,yK,J.signal),F1(q,OK,J.signal),EK(q),X},IK=($,q)=>{let J=C1([$]);return i1(J,q),w$.set(q,J),J},AK=($,q)=>{let J=w$.get(q);return J.add($),J},EK=async($)=>{try{await wK($,{cleanup:!0,readable:!1,writable:!0})}catch{}w$.delete($)},w$=new WeakMap,yK=2,OK=1;import{aborted as NK}from"node:util";var Bq=($,q)=>$===void 0?[]:[DK($,q)],DK=async($,{sourceStream:q,mergedStream:J,fileDescriptors:X,sourceOptions:Z,startTime:H})=>{await NK($,q),await J.remove(q);let Q=Error("Pipe canceled by `unpipeSignal` option.");throw F4({error:Q,fileDescriptors:X,sourceOptions:Z,startTime:H})};var I$=($,...q)=>{if(E(q[0]))return I$.bind(void 0,{...$,boundOptions:{...$.boundOptions,...q[0]}});let{destination:J,...X}=Yq($,...q),Z=vK({...X,destination:J});return Z.pipe=I$.bind(void 0,{...$,source:J,sourcePromise:Z,boundOptions:{}}),Z},vK=async({sourcePromise:$,sourceStream:q,sourceOptions:J,sourceError:X,destination:Z,destinationStream:H,destinationError:Q,unpipeSignal:Y,fileDescriptors:G,startTime:K})=>{let U=hK($,Z);Kq({sourceStream:q,sourceError:X,destinationStream:H,destinationError:Q,fileDescriptors:G,sourceOptions:J,startTime:K});let z=new AbortController;try{let B=zq(q,H,z);return await Promise.race([Uq(U),...Bq(Y,{sourceStream:q,mergedStream:B,sourceOptions:J,fileDescriptors:G,startTime:K})])}finally{z.abort()}},hK=($,q)=>Promise.allSettled([$,q]);import{setImmediate as uK}from"node:timers/promises";import{on as fK}from"node:events";import{getDefaultHighWaterMark as SK}from"node:stream";var A$=({subprocessStdout:$,subprocess:q,binary:J,shouldEncode:X,encoding:Z,preserveNewlines:H})=>{let Q=new AbortController;return bK(q,Q),Vq({stream:$,controller:Q,binary:J,shouldEncode:!$.readableObjectMode&&X,encoding:Z,shouldSplit:!$.readableObjectMode,preserveNewlines:H})},bK=async($,q)=>{try{await $}catch{}finally{q.abort()}},x4=({stream:$,onStreamEnd:q,lines:J,encoding:X,stripFinalNewline:Z,allMixed:H})=>{let Q=new AbortController;gK(q,Q,$);let Y=$.readableObjectMode&&!H;return Vq({stream:$,controller:Q,binary:X==="buffer",shouldEncode:!Y,encoding:X,shouldSplit:!Y&&J,preserveNewlines:!Z})},gK=async($,q,J)=>{try{await $}catch{J.destroy()}finally{q.abort()}},Vq=({stream:$,controller:q,binary:J,shouldEncode:X,encoding:Z,shouldSplit:H,preserveNewlines:Q})=>{let Y=fK($,"data",{signal:q.signal,highWaterMark:Lq,highWatermark:Lq});return cK({onStdoutChunk:Y,controller:q,binary:J,shouldEncode:X,encoding:Z,shouldSplit:H,preserveNewlines:Q})},j4=SK(!0),Lq=j4,cK=async function*({onStdoutChunk:$,controller:q,binary:J,shouldEncode:X,encoding:Z,shouldSplit:H,preserveNewlines:Q}){let Y=mK({binary:J,shouldEncode:X,encoding:Z,shouldSplit:H,preserveNewlines:Q});try{for await(let[G]of $)yield*M1(G,Y,0)}catch(G){if(!q.signal.aborted)throw G}finally{yield*G0(Y)}},mK=({binary:$,shouldEncode:q,encoding:J,shouldSplit:X,preserveNewlines:Z})=>[P$($,J,!q),T$($,Z,!X,{})].filter(Boolean);var Wq=async({stream:$,onStreamEnd:q,fdNumber:J,encoding:X,buffer:Z,maxBuffer:H,lines:Q,allMixed:Y,stripFinalNewline:G,verboseInfo:K,streamInfo:U})=>{let z=pK({stream:$,onStreamEnd:q,fdNumber:J,encoding:X,allMixed:Y,verboseInfo:K,streamInfo:U});if(!Z){await Promise.all([lK($),z]);return}let B=X4(G,J),L=x4({stream:$,onStreamEnd:q,lines:Q,encoding:X,stripFinalNewline:B,allMixed:Y}),[_]=await Promise.all([dK({stream:$,iterable:L,fdNumber:J,encoding:X,maxBuffer:H,lines:Q}),z]);return _},pK=async({stream:$,onStreamEnd:q,fdNumber:J,encoding:X,allMixed:Z,verboseInfo:H,streamInfo:{fileDescriptors:Q}})=>{if(!x$({stdioItems:Q[J]?.stdioItems,encoding:X,verboseInfo:H,fdNumber:J}))return;let Y=x4({stream:$,onStreamEnd:q,lines:!0,encoding:X,stripFinalNewline:!0,allMixed:Z});await x5(Y,$,J,H)},lK=async($)=>{if(await uK(),$.readableFlowing===null)$.resume()},dK=async({stream:$,stream:{readableObjectMode:q},iterable:J,fdNumber:X,encoding:Z,maxBuffer:H,lines:Q})=>{try{if(q||Q)return await G$(J,{maxBuffer:H});if(Z==="buffer")return new Uint8Array(await K$(J,{maxBuffer:H}));return await z$(J,{maxBuffer:H})}catch(Y){return _q(x7({error:Y,stream:$,readableObjectMode:q,lines:Q,encoding:Z,fdNumber:X}))}},M4=async($)=>{try{return await $}catch(q){return _q(q)}},_q=({bufferedData:$})=>b3($)?new Uint8Array($):$;import{finished as iK}from"node:stream/promises";var B0=async($,q,J,{isSameDirection:X,stopOnExit:Z=!1}={})=>{let H=nK($,J),Q=new AbortController;try{await Promise.race([...Z?[J.exitPromise]:[],iK($,{cleanup:!0,signal:Q.signal})])}catch(Y){if(!H.stdinCleanedUp)oK(Y,q,J,X)}finally{Q.abort()}},nK=($,{originalStreams:[q],subprocess:J})=>{let X={stdinCleanedUp:!1};if($===q)aK($,J,X);return X},aK=($,q,J)=>{let{_destroy:X}=$;$._destroy=(...Z)=>{tK(q,J),X.call($,...Z)}},tK=({exitCode:$,signalCode:q},J)=>{if($!==null||q!==null)J.stdinCleanedUp=!0},oK=($,q,J,X)=>{if(!rK($,q,J,X))throw $},rK=($,q,J,X=!0)=>{if(J.propagating)return Rq($)||E$($);return J.propagating=!0,C4(J,q)===X?Rq($):E$($)},C4=({fileDescriptors:$},q)=>q!=="all"&&$[q].direction==="input",E$=($)=>$?.code==="ERR_STREAM_PREMATURE_CLOSE",Rq=($)=>$?.code==="EPIPE";var Tq=({subprocess:$,encoding:q,buffer:J,maxBuffer:X,lines:Z,stripFinalNewline:H,verboseInfo:Q,streamInfo:Y})=>$.stdio.map((G,K)=>w4({stream:G,fdNumber:K,encoding:q,buffer:J[K],maxBuffer:X[K],lines:Z[K],allMixed:!1,stripFinalNewline:H,verboseInfo:Q,streamInfo:Y})),w4=async({stream:$,fdNumber:q,encoding:J,buffer:X,maxBuffer:Z,lines:H,allMixed:Q,stripFinalNewline:Y,verboseInfo:G,streamInfo:K})=>{if(!$)return;let U=B0($,q,K);if(C4(K,q)){await U;return}let[z]=await Promise.all([Wq({stream:$,onStreamEnd:U,fdNumber:q,encoding:J,buffer:X,maxBuffer:Z,lines:H,allMixed:Q,stripFinalNewline:Y,verboseInfo:G,streamInfo:K}),U]);return z};var Pq=({stdout:$,stderr:q},{all:J})=>J&&($||q)?C1([$,q].filter(Boolean)):void 0,kq=({subprocess:$,encoding:q,buffer:J,maxBuffer:X,lines:Z,stripFinalNewline:H,verboseInfo:Q,streamInfo:Y})=>w4({...sK($,J),fdNumber:"all",encoding:q,maxBuffer:X[1]+X[2],lines:Z[1]||Z[2],allMixed:eK($),stripFinalNewline:H,verboseInfo:Q,streamInfo:Y}),sK=({stdout:$,stderr:q,all:J},[,X,Z])=>{let H=X||Z;if(!H)return{stream:J,buffer:H};if(!X)return{stream:q,buffer:H};if(!Z)return{stream:$,buffer:H};return{stream:J,buffer:H}},eK=({all:$,stdout:q,stderr:J})=>$&&q&&J&&q.readableObjectMode!==J.readableObjectMode;import{once as $U}from"node:events";var Fq=($)=>h1($,"ipc"),xq=($,q)=>{let J=N0($);r({type:"ipc",verboseMessage:J,fdNumber:"ipc",verboseInfo:q})};var jq=async({subprocess:$,buffer:q,maxBuffer:J,ipc:X,ipcOutput:Z,verboseInfo:H})=>{if(!X)return Z;let Q=Fq(H),Y=Y1(q,"ipc"),G=Y1(J,"ipc");for await(let K of B4({anyProcess:$,channel:$.channel,isSubprocess:!1,ipc:X,shouldAwait:!1,reference:!0})){if(Y)j7($,Z,G),Z.push(K);if(Q)xq(K,H)}return Z},Mq=async($,q)=>{return await Promise.allSettled([$]),q};var Cq=async({subprocess:$,options:{encoding:q,buffer:J,maxBuffer:X,lines:Z,timeoutDuration:H,cancelSignal:Q,gracefulCancel:Y,forceKillAfterDelay:G,stripFinalNewline:K,ipc:U,ipcInput:z},context:B,verboseInfo:L,fileDescriptors:_,originalStreams:P,onInternalError:M,controller:F})=>{let O=I5($,B),v={originalStreams:P,fileDescriptors:_,subprocess:$,exitPromise:O,propagating:!1},x=Tq({subprocess:$,encoding:q,buffer:J,maxBuffer:X,lines:Z,stripFinalNewline:K,verboseInfo:L,streamInfo:v}),I=kq({subprocess:$,encoding:q,buffer:J,maxBuffer:X,lines:Z,stripFinalNewline:K,verboseInfo:L,streamInfo:v}),N=[],c=jq({subprocess:$,buffer:J,maxBuffer:X,ipc:U,ipcOutput:N,verboseInfo:L}),B1=qU(P,$,v),L1=JU(_,v);try{return await Promise.race([Promise.all([{},E5(O),Promise.all(x),I,c,$7($,z),...B1,...L1]),M,XU($,F),...t8($,H,B,F),..._8({subprocess:$,cancelSignal:Q,gracefulCancel:Y,context:B,controller:F}),...n8({subprocess:$,cancelSignal:Q,gracefulCancel:Y,forceKillAfterDelay:G,context:B,controller:F})])}catch(q2){return B.terminationReason??="other",Promise.all([{error:q2},O,Promise.all(x.map((s1)=>M4(s1))),M4(I),Mq(c,N),Promise.allSettled(B1),Promise.allSettled(L1)])}},qU=($,q,J)=>$.map((X,Z)=>X===q.stdio[Z]?void 0:B0(X,Z,J)),JU=($,q)=>$.flatMap(({stdioItems:J},X)=>J.filter(({value:Z,stream:H=Z})=>a(H,{checkOpen:!1})&&!i(H)).map(({type:Z,value:H,stream:Q=H})=>B0(Q,X,q,{isSameDirection:d.has(Z),stopOnExit:Z==="native"}))),XU=async($,{signal:q})=>{let[J]=await $U($,"error",{signal:q});throw J};var wq=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),L0=($,q,J)=>{let X=$[J];if(!X.has(q))X.set(q,[]);let Z=X.get(q),H=e();return Z.push(H),{resolve:H.resolve.bind(H),promises:Z}},n1=async({resolve:$,promises:q},J)=>{$();let[X]=await Promise.race([Promise.allSettled([!0,J]),Promise.all([!1,...q])]);return!X};import{Readable as ZU}from"node:stream";import{callbackify as QU}from"node:util";import{finished as Iq}from"node:stream/promises";var I4=async($)=>{if($===void 0)return;try{await A4($)}catch{}},Aq=async($)=>{if($===void 0)return;try{await E4($)}catch{}},A4=async($)=>{await Iq($,{cleanup:!0,readable:!1,writable:!0})},E4=async($)=>{await Iq($,{cleanup:!0,readable:!0,writable:!1})},y$=async($,q)=>{if(await $,q)throw q},O$=($,q,J)=>{if(J&&!E$(J))$.destroy(J);else if(q)$.destroy()};var Eq=({subprocess:$,concurrentStreams:q,encoding:J},{from:X,binary:Z=!0,preserveNewlines:H=!0}={})=>{let Q=Z||u.has(J),{subprocessStdout:Y,waitReadableDestroy:G}=y4($,X,q),{readableEncoding:K,readableObjectMode:U,readableHighWaterMark:z}=O4(Y,Q),{read:B,onStdoutDataDone:L}=N4({subprocessStdout:Y,subprocess:$,binary:Q,encoding:J,preserveNewlines:H}),_=new ZU({read:B,destroy:QU(v4.bind(void 0,{subprocessStdout:Y,subprocess:$,waitReadableDestroy:G})),highWaterMark:z,objectMode:U,encoding:K});return D4({subprocessStdout:Y,onStdoutDataDone:L,readable:_,subprocess:$}),_},y4=($,q,J)=>{let X=c1($,q),Z=L0(J,X,"readableDestroy");return{subprocessStdout:X,waitReadableDestroy:Z}},O4=({readableEncoding:$,readableObjectMode:q,readableHighWaterMark:J},X)=>X?{readableEncoding:$,readableObjectMode:q,readableHighWaterMark:J}:{readableEncoding:$,readableObjectMode:!0,readableHighWaterMark:j4},N4=({subprocessStdout:$,subprocess:q,binary:J,encoding:X,preserveNewlines:Z})=>{let H=e(),Q=A$({subprocessStdout:$,subprocess:q,binary:J,shouldEncode:!J,encoding:X,preserveNewlines:Z});return{read(){HU(this,Q,H)},onStdoutDataDone:H}},HU=async($,q,J)=>{try{let{value:X,done:Z}=await q.next();if(Z)J.resolve();else $.push(X)}catch{}},D4=async({subprocessStdout:$,onStdoutDataDone:q,readable:J,subprocess:X,subprocessStdin:Z})=>{try{if(await E4($),await X,await I4(Z),await q,J.readable)J.push(null)}catch(H){await I4(Z),yq(J,H)}},v4=async({subprocessStdout:$,subprocess:q,waitReadableDestroy:J},X)=>{if(await n1(J,q))yq($,X),await y$(q,X)},yq=($,q)=>{O$($,$.readable,q)};import{Writable as YU}from"node:stream";import{callbackify as Oq}from"node:util";var Nq=({subprocess:$,concurrentStreams:q},{to:J}={})=>{let{subprocessStdin:X,waitWritableFinal:Z,waitWritableDestroy:H}=h4($,J,q),Q=new YU({...f4(X,$,Z),destroy:Oq(b4.bind(void 0,{subprocessStdin:X,subprocess:$,waitWritableFinal:Z,waitWritableDestroy:H})),highWaterMark:X.writableHighWaterMark,objectMode:X.writableObjectMode});return S4(X,Q),Q},h4=($,q,J)=>{let X=i0($,q),Z=L0(J,X,"writableFinal"),H=L0(J,X,"writableDestroy");return{subprocessStdin:X,waitWritableFinal:Z,waitWritableDestroy:H}},f4=($,q,J)=>({write:GU.bind(void 0,$),final:Oq(KU.bind(void 0,$,q,J))}),GU=($,q,J,X)=>{if($.write(q,J))X();else $.once("drain",X)},KU=async($,q,J)=>{if(await n1(J,q)){if($.writable)$.end();await q}},S4=async($,q,J)=>{try{if(await A4($),q.writable)q.end()}catch(X){await Aq(J),Dq(q,X)}},b4=async({subprocessStdin:$,subprocess:q,waitWritableFinal:J,waitWritableDestroy:X},Z)=>{if(await n1(J,q),await n1(X,q))Dq($,Z),await y$(q,Z)},Dq=($,q)=>{O$($,$.writable,q)};import{Duplex as UU}from"node:stream";import{callbackify as zU}from"node:util";var vq=({subprocess:$,concurrentStreams:q,encoding:J},{from:X,to:Z,binary:H=!0,preserveNewlines:Q=!0}={})=>{let Y=H||u.has(J),{subprocessStdout:G,waitReadableDestroy:K}=y4($,X,q),{subprocessStdin:U,waitWritableFinal:z,waitWritableDestroy:B}=h4($,Z,q),{readableEncoding:L,readableObjectMode:_,readableHighWaterMark:P}=O4(G,Y),{read:M,onStdoutDataDone:F}=N4({subprocessStdout:G,subprocess:$,binary:Y,encoding:J,preserveNewlines:Q}),O=new UU({read:M,...f4(U,$,z),destroy:zU(BU.bind(void 0,{subprocessStdout:G,subprocessStdin:U,subprocess:$,waitReadableDestroy:K,waitWritableFinal:z,waitWritableDestroy:B})),readableHighWaterMark:P,writableHighWaterMark:U.writableHighWaterMark,readableObjectMode:_,writableObjectMode:U.writableObjectMode,encoding:L});return D4({subprocessStdout:G,onStdoutDataDone:F,readable:O,subprocess:$,subprocessStdin:U}),S4(U,O,G),O},BU=async({subprocessStdout:$,subprocessStdin:q,subprocess:J,waitReadableDestroy:X,waitWritableFinal:Z,waitWritableDestroy:H},Q)=>{await Promise.all([v4({subprocessStdout:$,subprocess:J,waitReadableDestroy:X},Q),b4({subprocessStdin:q,subprocess:J,waitWritableFinal:Z,waitWritableDestroy:H},Q)])};var g4=($,q,{from:J,binary:X=!1,preserveNewlines:Z=!1}={})=>{let H=X||u.has(q),Q=c1($,J),Y=A$({subprocessStdout:Q,subprocess:$,binary:H,shouldEncode:!0,encoding:q,preserveNewlines:Z});return LU(Y,Q,$)},LU=async function*($,q,J){try{yield*$}finally{if(q.readable)q.destroy();await J}};var hq=($,{encoding:q})=>{let J=wq();$.readable=Eq.bind(void 0,{subprocess:$,concurrentStreams:J,encoding:q}),$.writable=Nq.bind(void 0,{subprocess:$,concurrentStreams:J}),$.duplex=vq.bind(void 0,{subprocess:$,concurrentStreams:J,encoding:q}),$.iterable=g4.bind(void 0,$,q),$[Symbol.asyncIterator]=g4.bind(void 0,$,q,{})};var fq=($,q)=>{for(let[J,X]of WU){let Z=X.value.bind(q);Reflect.defineProperty($,J,{...X,value:Z})}},VU=(async()=>{})().constructor.prototype,WU=["then","catch","finally"].map(($)=>[$,Reflect.getOwnPropertyDescriptor(VU,$)]);var Sq=($,q,J,X)=>{let{file:Z,commandArguments:H,command:Q,escapedCommand:Y,startTime:G,verboseInfo:K,options:U,fileDescriptors:z}=TU($,q,J),{subprocess:B,promise:L}=kU({file:Z,commandArguments:H,options:U,startTime:G,verboseInfo:K,command:Q,escapedCommand:Y,fileDescriptors:z});return B.pipe=I$.bind(void 0,{source:B,sourcePromise:L,boundOptions:{},createNested:X}),fq(B,L),$1.set(B,{options:U,fileDescriptors:z}),B},TU=($,q,J)=>{let{command:X,escapedCommand:Z,startTime:H,verboseInfo:Q}=v0($,q,J),{file:Y,commandArguments:G,options:K}=X$($,q,J),U=PU(K),z=l5(U,Q);return{file:Y,commandArguments:G,command:X,escapedCommand:Z,startTime:H,verboseInfo:Q,options:U,fileDescriptors:z}},PU=({timeout:$,signal:q,...J})=>{if(q!==void 0)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...J,timeoutDuration:$}},kU=({file:$,commandArguments:q,options:J,startTime:X,verboseInfo:Z,command:H,escapedCommand:Q,fileDescriptors:Y})=>{let G;try{G=RU(...Z$($,q,J))}catch(_){return c5({error:_,command:H,escapedCommand:Q,fileDescriptors:Y,options:J,startTime:X,verboseInfo:Z})}let K=new AbortController;_U(Number.POSITIVE_INFINITY,K.signal);let U=[...G.stdio];$q(G,Y,K),Qq(G,J,K);let z={},B=e();G.kill=V8.bind(void 0,{kill:G.kill.bind(G),options:J,onInternalError:B,context:z,controller:K}),G.all=Pq(G,J),hq(G,J),S5(G,J);let L=FU({subprocess:G,options:J,startTime:X,verboseInfo:Z,fileDescriptors:Y,originalStreams:U,command:H,escapedCommand:Q,context:z,onInternalError:B,controller:K});return{subprocess:G,promise:L}},FU=async({subprocess:$,options:q,startTime:J,verboseInfo:X,fileDescriptors:Z,originalStreams:H,command:Q,escapedCommand:Y,context:G,onInternalError:K,controller:U})=>{let[z,[B,L],_,P,M]=await Cq({subprocess:$,options:q,context:G,verboseInfo:X,fileDescriptors:Z,originalStreams:H,onInternalError:K,controller:U});U.abort(),K.resolve();let F=_.map((x,I)=>U1(x,q,I)),O=U1(P,q,"all"),v=xU({errorInfo:z,exitCode:B,signal:L,stdio:F,all:O,ipcOutput:M,context:G,options:q,command:Q,escapedCommand:Y,startTime:J});return l1(v,X,q)},xU=({errorInfo:$,exitCode:q,signal:J,stdio:X,all:Z,ipcOutput:H,context:Q,options:Y,command:G,escapedCommand:K,startTime:U})=>("error"in $)?Y0({error:$.error,command:G,escapedCommand:K,timedOut:Q.terminationReason==="timeout",isCanceled:Q.terminationReason==="cancel"||Q.terminationReason==="gracefulCancel",isGracefullyCanceled:Q.terminationReason==="gracefulCancel",isMaxBuffer:$.error instanceof G1,isForcefullyTerminated:Q.isForcefullyTerminated,exitCode:q,signal:J,stdio:X,all:Z,ipcOutput:H,options:Y,startTime:U,isSync:!1}):L$({command:G,escapedCommand:K,stdio:X,all:Z,ipcOutput:H,options:Y,startTime:U});var N$=($,q)=>{let J=Object.fromEntries(Object.entries(q).map(([X,Z])=>[X,jU(X,$[X],Z)]));return{...$,...J}},jU=($,q,J)=>{if(MU.has($)&&E(q)&&E(J))return{...q,...J};return J},MU=new Set(["env",...T2]);var R1=($,q,J,X)=>{let Z=(Q,Y,G)=>R1(Q,Y,J,G),H=(...Q)=>CU({mapArguments:$,deepOptions:J,boundOptions:q,setBoundExeca:X,createNested:Z},...Q);if(X!==void 0)X(H,Z,q);return H},CU=({mapArguments:$,deepOptions:q={},boundOptions:J={},setBoundExeca:X,createNested:Z},H,...Q)=>{if(E(H))return Z($,N$(J,H),X);let{file:Y,commandArguments:G,options:K,isSync:U}=wU({mapArguments:$,firstArgument:H,nextArguments:Q,deepOptions:q,boundOptions:J});return U?O5(Y,G,K):Sq(Y,G,K,Z)},wU=({mapArguments:$,firstArgument:q,nextArguments:J,deepOptions:X,boundOptions:Z})=>{let H=l3(q)?d3(q,J):[q,...J],[Q,Y,G]=j0(...H),K=N$(N$(X,Z),G),{file:U=Q,commandArguments:z=Y,options:B=K,isSync:L=!1}=$({file:Q,commandArguments:Y,options:K});return{file:U,commandArguments:z,options:B,isSync:L}};var bq=({file:$,commandArguments:q})=>cq($,q),gq=({file:$,commandArguments:q})=>({...cq($,q),isSync:!0}),cq=($,q)=>{if(q.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${$} ${q}.`);let[J,...X]=IU($);return{file:J,commandArguments:X}},IU=($)=>{if(typeof $!=="string")throw TypeError(`The command must be a string: ${String($)}.`);let q=$.trim();if(q==="")return[];let J=[];for(let X of q.split(AU)){let Z=J.at(-1);if(Z&&Z.endsWith("\\"))J[J.length-1]=`${Z.slice(0,-1)} ${X}`;else J.push(X)}return J},AU=/ +/g;var mq=($,q,J)=>{$.sync=q(EU,J),$.s=$.sync},uq=({options:$})=>pq($),EU=({options:$})=>({...pq($),isSync:!0}),pq=($)=>({options:{...yU($),...$}}),yU=({input:$,inputFile:q,stdio:J})=>$===void 0&&q===void 0&&J===void 0?{stdin:"inherit"}:{},lq={preferLocal:!0};var f=R1(()=>({})),xj=R1(()=>({isSync:!0})),jj=R1(bq),Mj=R1(gq),Cj=R1(r8),wj=R1(uq,{},lq,mq),{sendMessage:Ij,getOneMessage:Aj,getEachMessage:Ej,getCancelSignal:yj}=b5();import{access as dq,readFile as nq}from"fs/promises";import{join as c4,dirname as iq}from"path";async function D$(){if(process.env.IDF_PATH)try{return await dq(process.env.IDF_PATH),process.env.IDF_PATH}catch{}try{return await dq(U2),U2}catch{}return null}async function v$($){let q=c4($,"version.txt");try{return(await nq(q,"utf-8")).trim()}catch{}try{return(await f("git",["describe","--tags"],{cwd:$})).stdout.trim()}catch{}return null}async function aq(){let $=await D$();if(!$)return{installed:!1};let q=await v$($);return{installed:!0,path:$,version:q||void 0}}async function I1($){let q=c4($,"CMakeLists.txt");try{let J=await nq(q,"utf-8");return J.includes("$ENV{IDF_PATH}")||J.includes("idf_component_register")}catch{return!1}}async function J1($){let q=$;while(q!==iq(q)){if(await I1(q))return q;q=iq(q)}return null}function m4($){return c4($,"export.sh")}async function u4($,q,J={}){let{cwd:X,operationId:Z,env:H}=J,Q={cwd:X,env:{...process.env,...H},reject:!1};try{let Y=f($,q,Q);if(Z)Y.stdout?.on("data",(K)=>{R.emit(Z,{type:"stdout",text:K.toString()})}),Y.stderr?.on("data",(K)=>{R.emit(Z,{type:"stderr",text:K.toString()})});let G=await Y;return{ok:!0,data:{stdout:String(G.stdout??""),stderr:String(G.stderr??""),exitCode:G.exitCode??0}}}catch(Y){return{ok:!1,error:`Failed to execute ${$}: ${Y}`}}}async function X1($,q,J={}){let X=await D$();if(!X)return{ok:!1,error:"ESP-IDF not found. Run `espcli install` first.",code:"IDF_NOT_FOUND"};let H=`source ${m4(X)} > /dev/null 2>&1 && ${$} ${q.join(" ")}`,{cwd:Q,operationId:Y,env:G}=J,K={cwd:Q,env:{...process.env,...G},shell:!0,reject:!1};try{let U=f(H,[],K);if(Y)U.stdout?.on("data",(B)=>{R.emit(Y,{type:"stdout",text:B.toString()})}),U.stderr?.on("data",(B)=>{R.emit(Y,{type:"stderr",text:B.toString()})});let z=await U;return{ok:!0,data:{stdout:String(z.stdout??""),stderr:String(z.stderr??""),exitCode:z.exitCode??0}}}catch(U){return{ok:!1,error:`Failed to execute ${$}: ${U}`}}}async function tq($,q,J={}){let X=await D$();if(!X)return null;let H=`source ${m4(X)} > /dev/null 2>&1 && ${$} ${q.join(" ")}`,{cwd:Q,operationId:Y,env:G,interactive:K}=J,U=f(H,[],{cwd:Q,env:{...process.env,...G},shell:!0,reject:!1,stdin:K?"inherit":"pipe",stdout:K?"inherit":"pipe",stderr:K?"inherit":"pipe"});if(Y&&!K)U.stdout?.on("data",(B)=>{R.emit(Y,{type:"stdout",text:B.toString()})}),U.stderr?.on("data",(B)=>{R.emit(Y,{type:"stderr",text:B.toString()})});let z=U.then(()=>{});return{proc:U,promise:z}}import{homedir as OU}from"os";import{join as NU}from"path";import{readFile as DU,appendFile as vU,access as dj}from"fs/promises";function oq(){let $=process.env.SHELL||"";if($.includes("zsh"))return"zsh";if($.includes("bash"))return"bash";if($.includes("fish"))return"fish";return"unknown"}function h$(){let $=oq(),q=v3[$]||"",J=q?NU(OU(),q):"";return{type:$,configPath:J}}async function hU($){let{configPath:q}=h$();if(!q)return!1;try{return(await DU(q,"utf-8")).includes($)}catch{return!1}}async function rq($){let{configPath:q,type:J}=h$();if(!q)return{ok:!1,error:`Unsupported shell: ${J}`};if(await hU($))return{ok:!0,data:void 0};try{return await vU(q,`
|
|
70
70
|
${$}
|
|
71
|
-
`),{ok:!0,data:void 0}}catch(Z){return{ok:!1,error:`Failed to modify ${q}: ${Z}`}}}function dq($){if(pq()==="fish")return`source ${$}/export.fish`;return`. ${$}/export.sh`}import{mkdir as MU,access as CU}from"fs/promises";import{join as IU}from"path";async function iq($={},q){let J=q||j(),X=$.path||R0,Z=$.target||"all",H=$.addToShell??!0,Q=IU(X,"esp-idf");try{await CU(Q);let B=await w$(Q);return R.emit(J,{type:"log",level:"info",message:`ESP-IDF already installed at ${Q}`}),{ok:!0,data:{idfPath:Q,version:B||"unknown",addedToShell:!1}}}catch{}R.emit(J,{type:"progress",message:"Creating ESP directory..."});try{await MU(X,{recursive:!0})}catch(B){return{ok:!1,error:`Failed to create directory: ${B}`}}R.emit(J,{type:"progress",message:"Cloning ESP-IDF repository...",percent:10});let Y=await D4("git",["clone","--recursive",M3],{cwd:X,operationId:J});if(!Y.ok)return{ok:!1,error:Y.error};if(Y.data.exitCode!==0)return{ok:!1,error:`Git clone failed with exit code ${Y.data.exitCode}`};R.emit(J,{type:"progress",message:"Running install script...",percent:50});let K=await D4("./install.sh",Z==="all"?["all"]:[Z],{cwd:Q,operationId:J});if(!K.ok)return{ok:!1,error:K.error};if(K.data.exitCode!==0)return{ok:!1,error:`Install script failed with exit code ${K.data.exitCode}`};let U=!1;if(H){R.emit(J,{type:"progress",message:"Configuring shell...",percent:90});let B=dq(Q),L=await lq(B);if(L.ok)U=!0;else R.emit(J,{type:"log",level:"warn",message:L.error})}let z=await w$(Q);return R.emit(J,{type:"complete",result:{idfPath:Q,version:z,addedToShell:U}}),{ok:!0,data:{idfPath:Q,version:z||"unknown",addedToShell:U}}}import{stripVTControlCharacters as i4}from"node:util";var S=t(f4(),1),HJ=t(C1(),1);import{stdin as ZJ,stdout as QJ}from"node:process";import*as V1 from"node:readline";import oq from"node:readline";import{Writable as NU}from"node:stream";function DU({onlyFirst:$=!1}={}){let q=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(q,$?void 0:"g")}var vU=DU();function YJ($){if(typeof $!="string")throw TypeError(`Expected a \`string\`, got \`${typeof $}\``);return $.replace(vU,"")}function GJ($){return $&&$.__esModule&&Object.prototype.hasOwnProperty.call($,"default")?$.default:$}var KJ={exports:{}};(function($){var q={};$.exports=q,q.eastAsianWidth=function(X){var Z=X.charCodeAt(0),H=X.length==2?X.charCodeAt(1):0,Q=Z;return 55296<=Z&&Z<=56319&&56320<=H&&H<=57343&&(Z&=1023,H&=1023,Q=Z<<10|H,Q+=65536),Q==12288||65281<=Q&&Q<=65376||65504<=Q&&Q<=65510?"F":Q==8361||65377<=Q&&Q<=65470||65474<=Q&&Q<=65479||65482<=Q&&Q<=65487||65490<=Q&&Q<=65495||65498<=Q&&Q<=65500||65512<=Q&&Q<=65518?"H":4352<=Q&&Q<=4447||4515<=Q&&Q<=4519||4602<=Q&&Q<=4607||9001<=Q&&Q<=9002||11904<=Q&&Q<=11929||11931<=Q&&Q<=12019||12032<=Q&&Q<=12245||12272<=Q&&Q<=12283||12289<=Q&&Q<=12350||12353<=Q&&Q<=12438||12441<=Q&&Q<=12543||12549<=Q&&Q<=12589||12593<=Q&&Q<=12686||12688<=Q&&Q<=12730||12736<=Q&&Q<=12771||12784<=Q&&Q<=12830||12832<=Q&&Q<=12871||12880<=Q&&Q<=13054||13056<=Q&&Q<=19903||19968<=Q&&Q<=42124||42128<=Q&&Q<=42182||43360<=Q&&Q<=43388||44032<=Q&&Q<=55203||55216<=Q&&Q<=55238||55243<=Q&&Q<=55291||63744<=Q&&Q<=64255||65040<=Q&&Q<=65049||65072<=Q&&Q<=65106||65108<=Q&&Q<=65126||65128<=Q&&Q<=65131||110592<=Q&&Q<=110593||127488<=Q&&Q<=127490||127504<=Q&&Q<=127546||127552<=Q&&Q<=127560||127568<=Q&&Q<=127569||131072<=Q&&Q<=194367||177984<=Q&&Q<=196605||196608<=Q&&Q<=262141?"W":32<=Q&&Q<=126||162<=Q&&Q<=163||165<=Q&&Q<=166||Q==172||Q==175||10214<=Q&&Q<=10221||10629<=Q&&Q<=10630?"Na":Q==161||Q==164||167<=Q&&Q<=168||Q==170||173<=Q&&Q<=174||176<=Q&&Q<=180||182<=Q&&Q<=186||188<=Q&&Q<=191||Q==198||Q==208||215<=Q&&Q<=216||222<=Q&&Q<=225||Q==230||232<=Q&&Q<=234||236<=Q&&Q<=237||Q==240||242<=Q&&Q<=243||247<=Q&&Q<=250||Q==252||Q==254||Q==257||Q==273||Q==275||Q==283||294<=Q&&Q<=295||Q==299||305<=Q&&Q<=307||Q==312||319<=Q&&Q<=322||Q==324||328<=Q&&Q<=331||Q==333||338<=Q&&Q<=339||358<=Q&&Q<=359||Q==363||Q==462||Q==464||Q==466||Q==468||Q==470||Q==472||Q==474||Q==476||Q==593||Q==609||Q==708||Q==711||713<=Q&&Q<=715||Q==717||Q==720||728<=Q&&Q<=731||Q==733||Q==735||768<=Q&&Q<=879||913<=Q&&Q<=929||931<=Q&&Q<=937||945<=Q&&Q<=961||963<=Q&&Q<=969||Q==1025||1040<=Q&&Q<=1103||Q==1105||Q==8208||8211<=Q&&Q<=8214||8216<=Q&&Q<=8217||8220<=Q&&Q<=8221||8224<=Q&&Q<=8226||8228<=Q&&Q<=8231||Q==8240||8242<=Q&&Q<=8243||Q==8245||Q==8251||Q==8254||Q==8308||Q==8319||8321<=Q&&Q<=8324||Q==8364||Q==8451||Q==8453||Q==8457||Q==8467||Q==8470||8481<=Q&&Q<=8482||Q==8486||Q==8491||8531<=Q&&Q<=8532||8539<=Q&&Q<=8542||8544<=Q&&Q<=8555||8560<=Q&&Q<=8569||Q==8585||8592<=Q&&Q<=8601||8632<=Q&&Q<=8633||Q==8658||Q==8660||Q==8679||Q==8704||8706<=Q&&Q<=8707||8711<=Q&&Q<=8712||Q==8715||Q==8719||Q==8721||Q==8725||Q==8730||8733<=Q&&Q<=8736||Q==8739||Q==8741||8743<=Q&&Q<=8748||Q==8750||8756<=Q&&Q<=8759||8764<=Q&&Q<=8765||Q==8776||Q==8780||Q==8786||8800<=Q&&Q<=8801||8804<=Q&&Q<=8807||8810<=Q&&Q<=8811||8814<=Q&&Q<=8815||8834<=Q&&Q<=8835||8838<=Q&&Q<=8839||Q==8853||Q==8857||Q==8869||Q==8895||Q==8978||9312<=Q&&Q<=9449||9451<=Q&&Q<=9547||9552<=Q&&Q<=9587||9600<=Q&&Q<=9615||9618<=Q&&Q<=9621||9632<=Q&&Q<=9633||9635<=Q&&Q<=9641||9650<=Q&&Q<=9651||9654<=Q&&Q<=9655||9660<=Q&&Q<=9661||9664<=Q&&Q<=9665||9670<=Q&&Q<=9672||Q==9675||9678<=Q&&Q<=9681||9698<=Q&&Q<=9701||Q==9711||9733<=Q&&Q<=9734||Q==9737||9742<=Q&&Q<=9743||9748<=Q&&Q<=9749||Q==9756||Q==9758||Q==9792||Q==9794||9824<=Q&&Q<=9825||9827<=Q&&Q<=9829||9831<=Q&&Q<=9834||9836<=Q&&Q<=9837||Q==9839||9886<=Q&&Q<=9887||9918<=Q&&Q<=9919||9924<=Q&&Q<=9933||9935<=Q&&Q<=9953||Q==9955||9960<=Q&&Q<=9983||Q==10045||Q==10071||10102<=Q&&Q<=10111||11093<=Q&&Q<=11097||12872<=Q&&Q<=12879||57344<=Q&&Q<=63743||65024<=Q&&Q<=65039||Q==65533||127232<=Q&&Q<=127242||127248<=Q&&Q<=127277||127280<=Q&&Q<=127337||127344<=Q&&Q<=127386||917760<=Q&&Q<=917999||983040<=Q&&Q<=1048573||1048576<=Q&&Q<=1114109?"A":"N"},q.characterLength=function(X){var Z=this.eastAsianWidth(X);return Z=="F"||Z=="W"||Z=="A"?2:1};function J(X){return X.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}q.length=function(X){for(var Z=J(X),H=0,Q=0;Q<Z.length;Q++)H=H+this.characterLength(Z[Q]);return H},q.slice=function(X,Z,H){textLen=q.length(X),Z=Z||0,H=H||1,Z<0&&(Z=textLen+Z),H<0&&(H=textLen+H);for(var Q="",Y=0,G=J(X),K=0;K<G.length;K++){var U=G[K],z=q.length(U);if(Y>=Z-(z==2?1:0))if(Y+z<=H)Q+=U;else break;Y+=z}return Q}})(KJ);var fU=KJ.exports,hU=GJ(fU),SU=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},bU=GJ(SU);function G0($,q={}){if(typeof $!="string"||$.length===0||(q={ambiguousIsNarrow:!0,...q},$=YJ($),$.length===0))return 0;$=$.replace(bU()," ");let J=q.ambiguousIsNarrow?1:2,X=0;for(let Z of $){let H=Z.codePointAt(0);if(H<=31||H>=127&&H<=159||H>=768&&H<=879)continue;switch(hU.eastAsianWidth(Z)){case"F":case"W":X+=2;break;case"A":X+=J;break;default:X+=1}}return X}var S4=10,rq=($=0)=>(q)=>`\x1B[${q+$}m`,sq=($=0)=>(q)=>`\x1B[${38+$};5;${q}m`,eq=($=0)=>(q,J,X)=>`\x1B[${38+$};2;${q};${J};${X}m`,C={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(C.modifier);var gU=Object.keys(C.color),cU=Object.keys(C.bgColor);[...gU,...cU];function mU(){let $=new Map;for(let[q,J]of Object.entries(C)){for(let[X,Z]of Object.entries(J))C[X]={open:`\x1B[${Z[0]}m`,close:`\x1B[${Z[1]}m`},J[X]=C[X],$.set(Z[0],Z[1]);Object.defineProperty(C,q,{value:J,enumerable:!1})}return Object.defineProperty(C,"codes",{value:$,enumerable:!1}),C.color.close="\x1B[39m",C.bgColor.close="\x1B[49m",C.color.ansi=rq(),C.color.ansi256=sq(),C.color.ansi16m=eq(),C.bgColor.ansi=rq(S4),C.bgColor.ansi256=sq(S4),C.bgColor.ansi16m=eq(S4),Object.defineProperties(C,{rgbToAnsi256:{value:(q,J,X)=>q===J&&J===X?q<8?16:q>248?231:Math.round((q-8)/247*24)+232:16+36*Math.round(q/255*5)+6*Math.round(J/255*5)+Math.round(X/255*5),enumerable:!1},hexToRgb:{value:(q)=>{let J=/[a-f\d]{6}|[a-f\d]{3}/i.exec(q.toString(16));if(!J)return[0,0,0];let[X]=J;X.length===3&&(X=[...X].map((H)=>H+H).join(""));let Z=Number.parseInt(X,16);return[Z>>16&255,Z>>8&255,Z&255]},enumerable:!1},hexToAnsi256:{value:(q)=>C.rgbToAnsi256(...C.hexToRgb(q)),enumerable:!1},ansi256ToAnsi:{value:(q)=>{if(q<8)return 30+q;if(q<16)return 90+(q-8);let J,X,Z;if(q>=232)J=((q-232)*10+8)/255,X=J,Z=J;else{q-=16;let Y=q%36;J=Math.floor(q/36)/5,X=Math.floor(Y/6)/5,Z=Y%6/5}let H=Math.max(J,X,Z)*2;if(H===0)return 30;let Q=30+(Math.round(Z)<<2|Math.round(X)<<1|Math.round(J));return H===2&&(Q+=60),Q},enumerable:!1},rgbToAnsi:{value:(q,J,X)=>C.ansi256ToAnsi(C.rgbToAnsi256(q,J,X)),enumerable:!1},hexToAnsi:{value:(q)=>C.ansi256ToAnsi(C.hexToAnsi256(q)),enumerable:!1}}),C}var uU=mU(),D$=new Set(["\x1B",""]),pU=39,c4="\x07",UJ="[",lU="]",zJ="m",m4=`${lU}8;;`,$J=($)=>`${D$.values().next().value}${UJ}${$}${zJ}`,qJ=($)=>`${D$.values().next().value}${m4}${$}${c4}`,dU=($)=>$.split(" ").map((q)=>G0(q)),b4=($,q,J)=>{let X=[...q],Z=!1,H=!1,Q=G0(YJ($[$.length-1]));for(let[Y,G]of X.entries()){let K=G0(G);if(Q+K<=J?$[$.length-1]+=G:($.push(G),Q=0),D$.has(G)&&(Z=!0,H=X.slice(Y+1).join("").startsWith(m4)),Z){H?G===c4&&(Z=!1,H=!1):G===zJ&&(Z=!1);continue}Q+=K,Q===J&&Y<X.length-1&&($.push(""),Q=0)}!Q&&$[$.length-1].length>0&&$.length>1&&($[$.length-2]+=$.pop())},iU=($)=>{let q=$.split(" "),J=q.length;for(;J>0&&!(G0(q[J-1])>0);)J--;return J===q.length?$:q.slice(0,J).join(" ")+q.slice(J).join("")},nU=($,q,J={})=>{if(J.trim!==!1&&$.trim()==="")return"";let X="",Z,H,Q=dU($),Y=[""];for(let[K,U]of $.split(" ").entries()){J.trim!==!1&&(Y[Y.length-1]=Y[Y.length-1].trimStart());let z=G0(Y[Y.length-1]);if(K!==0&&(z>=q&&(J.wordWrap===!1||J.trim===!1)&&(Y.push(""),z=0),(z>0||J.trim===!1)&&(Y[Y.length-1]+=" ",z++)),J.hard&&Q[K]>q){let B=q-z,L=1+Math.floor((Q[K]-B-1)/q);Math.floor((Q[K]-1)/q)<L&&Y.push(""),b4(Y,U,q);continue}if(z+Q[K]>q&&z>0&&Q[K]>0){if(J.wordWrap===!1&&z<q){b4(Y,U,q);continue}Y.push("")}if(z+Q[K]>q&&J.wordWrap===!1){b4(Y,U,q);continue}Y[Y.length-1]+=U}J.trim!==!1&&(Y=Y.map((K)=>iU(K)));let G=[...Y.join(`
|
|
72
|
-
`)];for(let[K,U]of G.entries()){if(X+=U,
|
|
73
|
-
`?(H&&(X+=
|
|
74
|
-
`&&(Z&&z&&(X
|
|
71
|
+
`),{ok:!0,data:void 0}}catch(Z){return{ok:!1,error:`Failed to modify ${q}: ${Z}`}}}function sq($){if(oq()==="fish")return`source ${$}/export.fish`;return`. ${$}/export.sh`}import{mkdir as fU,access as SU}from"fs/promises";import{join as bU}from"path";async function eq($={},q){let J=q||j(),X=$.path||x0,Z=$.target||"all",H=$.addToShell??!0,Q=bU(X,"esp-idf");try{await SU(Q);let B=await v$(Q);return R.emit(J,{type:"log",level:"info",message:`ESP-IDF already installed at ${Q}`}),{ok:!0,data:{idfPath:Q,version:B||"unknown",addedToShell:!1}}}catch{}R.emit(J,{type:"progress",message:"Creating ESP directory..."});try{await fU(X,{recursive:!0})}catch(B){return{ok:!1,error:`Failed to create directory: ${B}`}}R.emit(J,{type:"progress",message:"Cloning ESP-IDF repository...",percent:10});let Y=await u4("git",["clone","--recursive",O3],{cwd:X,operationId:J});if(!Y.ok)return{ok:!1,error:Y.error};if(Y.data.exitCode!==0)return{ok:!1,error:`Git clone failed with exit code ${Y.data.exitCode}`};R.emit(J,{type:"progress",message:"Running install script...",percent:50});let K=await u4("./install.sh",Z==="all"?["all"]:[Z],{cwd:Q,operationId:J});if(!K.ok)return{ok:!1,error:K.error};if(K.data.exitCode!==0)return{ok:!1,error:`Install script failed with exit code ${K.data.exitCode}`};let U=!1;if(H){R.emit(J,{type:"progress",message:"Configuring shell...",percent:90});let B=sq(Q),L=await rq(B);if(L.ok)U=!0;else R.emit(J,{type:"log",level:"warn",message:L.error})}let z=await v$(Q);return R.emit(J,{type:"complete",result:{idfPath:Q,version:z,addedToShell:U}}),{ok:!0,data:{idfPath:Q,version:z||"unknown",addedToShell:U}}}import{stripVTControlCharacters as q3}from"node:util";var S=o(l4(),1),LJ=o(A1(),1);import{stdin as zJ,stdout as BJ}from"node:process";import*as T1 from"node:readline";import XJ from"node:readline";import{Writable as lU}from"node:stream";function dU({onlyFirst:$=!1}={}){let q=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(q,$?void 0:"g")}var iU=dU();function VJ($){if(typeof $!="string")throw TypeError(`Expected a \`string\`, got \`${typeof $}\``);return $.replace(iU,"")}function WJ($){return $&&$.__esModule&&Object.prototype.hasOwnProperty.call($,"default")?$.default:$}var _J={exports:{}};(function($){var q={};$.exports=q,q.eastAsianWidth=function(X){var Z=X.charCodeAt(0),H=X.length==2?X.charCodeAt(1):0,Q=Z;return 55296<=Z&&Z<=56319&&56320<=H&&H<=57343&&(Z&=1023,H&=1023,Q=Z<<10|H,Q+=65536),Q==12288||65281<=Q&&Q<=65376||65504<=Q&&Q<=65510?"F":Q==8361||65377<=Q&&Q<=65470||65474<=Q&&Q<=65479||65482<=Q&&Q<=65487||65490<=Q&&Q<=65495||65498<=Q&&Q<=65500||65512<=Q&&Q<=65518?"H":4352<=Q&&Q<=4447||4515<=Q&&Q<=4519||4602<=Q&&Q<=4607||9001<=Q&&Q<=9002||11904<=Q&&Q<=11929||11931<=Q&&Q<=12019||12032<=Q&&Q<=12245||12272<=Q&&Q<=12283||12289<=Q&&Q<=12350||12353<=Q&&Q<=12438||12441<=Q&&Q<=12543||12549<=Q&&Q<=12589||12593<=Q&&Q<=12686||12688<=Q&&Q<=12730||12736<=Q&&Q<=12771||12784<=Q&&Q<=12830||12832<=Q&&Q<=12871||12880<=Q&&Q<=13054||13056<=Q&&Q<=19903||19968<=Q&&Q<=42124||42128<=Q&&Q<=42182||43360<=Q&&Q<=43388||44032<=Q&&Q<=55203||55216<=Q&&Q<=55238||55243<=Q&&Q<=55291||63744<=Q&&Q<=64255||65040<=Q&&Q<=65049||65072<=Q&&Q<=65106||65108<=Q&&Q<=65126||65128<=Q&&Q<=65131||110592<=Q&&Q<=110593||127488<=Q&&Q<=127490||127504<=Q&&Q<=127546||127552<=Q&&Q<=127560||127568<=Q&&Q<=127569||131072<=Q&&Q<=194367||177984<=Q&&Q<=196605||196608<=Q&&Q<=262141?"W":32<=Q&&Q<=126||162<=Q&&Q<=163||165<=Q&&Q<=166||Q==172||Q==175||10214<=Q&&Q<=10221||10629<=Q&&Q<=10630?"Na":Q==161||Q==164||167<=Q&&Q<=168||Q==170||173<=Q&&Q<=174||176<=Q&&Q<=180||182<=Q&&Q<=186||188<=Q&&Q<=191||Q==198||Q==208||215<=Q&&Q<=216||222<=Q&&Q<=225||Q==230||232<=Q&&Q<=234||236<=Q&&Q<=237||Q==240||242<=Q&&Q<=243||247<=Q&&Q<=250||Q==252||Q==254||Q==257||Q==273||Q==275||Q==283||294<=Q&&Q<=295||Q==299||305<=Q&&Q<=307||Q==312||319<=Q&&Q<=322||Q==324||328<=Q&&Q<=331||Q==333||338<=Q&&Q<=339||358<=Q&&Q<=359||Q==363||Q==462||Q==464||Q==466||Q==468||Q==470||Q==472||Q==474||Q==476||Q==593||Q==609||Q==708||Q==711||713<=Q&&Q<=715||Q==717||Q==720||728<=Q&&Q<=731||Q==733||Q==735||768<=Q&&Q<=879||913<=Q&&Q<=929||931<=Q&&Q<=937||945<=Q&&Q<=961||963<=Q&&Q<=969||Q==1025||1040<=Q&&Q<=1103||Q==1105||Q==8208||8211<=Q&&Q<=8214||8216<=Q&&Q<=8217||8220<=Q&&Q<=8221||8224<=Q&&Q<=8226||8228<=Q&&Q<=8231||Q==8240||8242<=Q&&Q<=8243||Q==8245||Q==8251||Q==8254||Q==8308||Q==8319||8321<=Q&&Q<=8324||Q==8364||Q==8451||Q==8453||Q==8457||Q==8467||Q==8470||8481<=Q&&Q<=8482||Q==8486||Q==8491||8531<=Q&&Q<=8532||8539<=Q&&Q<=8542||8544<=Q&&Q<=8555||8560<=Q&&Q<=8569||Q==8585||8592<=Q&&Q<=8601||8632<=Q&&Q<=8633||Q==8658||Q==8660||Q==8679||Q==8704||8706<=Q&&Q<=8707||8711<=Q&&Q<=8712||Q==8715||Q==8719||Q==8721||Q==8725||Q==8730||8733<=Q&&Q<=8736||Q==8739||Q==8741||8743<=Q&&Q<=8748||Q==8750||8756<=Q&&Q<=8759||8764<=Q&&Q<=8765||Q==8776||Q==8780||Q==8786||8800<=Q&&Q<=8801||8804<=Q&&Q<=8807||8810<=Q&&Q<=8811||8814<=Q&&Q<=8815||8834<=Q&&Q<=8835||8838<=Q&&Q<=8839||Q==8853||Q==8857||Q==8869||Q==8895||Q==8978||9312<=Q&&Q<=9449||9451<=Q&&Q<=9547||9552<=Q&&Q<=9587||9600<=Q&&Q<=9615||9618<=Q&&Q<=9621||9632<=Q&&Q<=9633||9635<=Q&&Q<=9641||9650<=Q&&Q<=9651||9654<=Q&&Q<=9655||9660<=Q&&Q<=9661||9664<=Q&&Q<=9665||9670<=Q&&Q<=9672||Q==9675||9678<=Q&&Q<=9681||9698<=Q&&Q<=9701||Q==9711||9733<=Q&&Q<=9734||Q==9737||9742<=Q&&Q<=9743||9748<=Q&&Q<=9749||Q==9756||Q==9758||Q==9792||Q==9794||9824<=Q&&Q<=9825||9827<=Q&&Q<=9829||9831<=Q&&Q<=9834||9836<=Q&&Q<=9837||Q==9839||9886<=Q&&Q<=9887||9918<=Q&&Q<=9919||9924<=Q&&Q<=9933||9935<=Q&&Q<=9953||Q==9955||9960<=Q&&Q<=9983||Q==10045||Q==10071||10102<=Q&&Q<=10111||11093<=Q&&Q<=11097||12872<=Q&&Q<=12879||57344<=Q&&Q<=63743||65024<=Q&&Q<=65039||Q==65533||127232<=Q&&Q<=127242||127248<=Q&&Q<=127277||127280<=Q&&Q<=127337||127344<=Q&&Q<=127386||917760<=Q&&Q<=917999||983040<=Q&&Q<=1048573||1048576<=Q&&Q<=1114109?"A":"N"},q.characterLength=function(X){var Z=this.eastAsianWidth(X);return Z=="F"||Z=="W"||Z=="A"?2:1};function J(X){return X.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}q.length=function(X){for(var Z=J(X),H=0,Q=0;Q<Z.length;Q++)H=H+this.characterLength(Z[Q]);return H},q.slice=function(X,Z,H){textLen=q.length(X),Z=Z||0,H=H||1,Z<0&&(Z=textLen+Z),H<0&&(H=textLen+H);for(var Q="",Y=0,G=J(X),K=0;K<G.length;K++){var U=G[K],z=q.length(U);if(Y>=Z-(z==2?1:0))if(Y+z<=H)Q+=U;else break;Y+=z}return Q}})(_J);var nU=_J.exports,aU=WJ(nU),tU=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},oU=WJ(tU);function V0($,q={}){if(typeof $!="string"||$.length===0||(q={ambiguousIsNarrow:!0,...q},$=VJ($),$.length===0))return 0;$=$.replace(oU()," ");let J=q.ambiguousIsNarrow?1:2,X=0;for(let Z of $){let H=Z.codePointAt(0);if(H<=31||H>=127&&H<=159||H>=768&&H<=879)continue;switch(aU.eastAsianWidth(Z)){case"F":case"W":X+=2;break;case"A":X+=J;break;default:X+=1}}return X}var i4=10,ZJ=($=0)=>(q)=>`\x1B[${q+$}m`,QJ=($=0)=>(q)=>`\x1B[${38+$};5;${q}m`,HJ=($=0)=>(q,J,X)=>`\x1B[${38+$};2;${q};${J};${X}m`,C={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(C.modifier);var rU=Object.keys(C.color),sU=Object.keys(C.bgColor);[...rU,...sU];function eU(){let $=new Map;for(let[q,J]of Object.entries(C)){for(let[X,Z]of Object.entries(J))C[X]={open:`\x1B[${Z[0]}m`,close:`\x1B[${Z[1]}m`},J[X]=C[X],$.set(Z[0],Z[1]);Object.defineProperty(C,q,{value:J,enumerable:!1})}return Object.defineProperty(C,"codes",{value:$,enumerable:!1}),C.color.close="\x1B[39m",C.bgColor.close="\x1B[49m",C.color.ansi=ZJ(),C.color.ansi256=QJ(),C.color.ansi16m=HJ(),C.bgColor.ansi=ZJ(i4),C.bgColor.ansi256=QJ(i4),C.bgColor.ansi16m=HJ(i4),Object.defineProperties(C,{rgbToAnsi256:{value:(q,J,X)=>q===J&&J===X?q<8?16:q>248?231:Math.round((q-8)/247*24)+232:16+36*Math.round(q/255*5)+6*Math.round(J/255*5)+Math.round(X/255*5),enumerable:!1},hexToRgb:{value:(q)=>{let J=/[a-f\d]{6}|[a-f\d]{3}/i.exec(q.toString(16));if(!J)return[0,0,0];let[X]=J;X.length===3&&(X=[...X].map((H)=>H+H).join(""));let Z=Number.parseInt(X,16);return[Z>>16&255,Z>>8&255,Z&255]},enumerable:!1},hexToAnsi256:{value:(q)=>C.rgbToAnsi256(...C.hexToRgb(q)),enumerable:!1},ansi256ToAnsi:{value:(q)=>{if(q<8)return 30+q;if(q<16)return 90+(q-8);let J,X,Z;if(q>=232)J=((q-232)*10+8)/255,X=J,Z=J;else{q-=16;let Y=q%36;J=Math.floor(q/36)/5,X=Math.floor(Y/6)/5,Z=Y%6/5}let H=Math.max(J,X,Z)*2;if(H===0)return 30;let Q=30+(Math.round(Z)<<2|Math.round(X)<<1|Math.round(J));return H===2&&(Q+=60),Q},enumerable:!1},rgbToAnsi:{value:(q,J,X)=>C.ansi256ToAnsi(C.rgbToAnsi256(q,J,X)),enumerable:!1},hexToAnsi:{value:(q)=>C.ansi256ToAnsi(C.hexToAnsi256(q)),enumerable:!1}}),C}var $z=eU(),c$=new Set(["\x1B",""]),qz=39,t4="\x07",RJ="[",Jz="]",TJ="m",o4=`${Jz}8;;`,YJ=($)=>`${c$.values().next().value}${RJ}${$}${TJ}`,GJ=($)=>`${c$.values().next().value}${o4}${$}${t4}`,Xz=($)=>$.split(" ").map((q)=>V0(q)),n4=($,q,J)=>{let X=[...q],Z=!1,H=!1,Q=V0(VJ($[$.length-1]));for(let[Y,G]of X.entries()){let K=V0(G);if(Q+K<=J?$[$.length-1]+=G:($.push(G),Q=0),c$.has(G)&&(Z=!0,H=X.slice(Y+1).join("").startsWith(o4)),Z){H?G===t4&&(Z=!1,H=!1):G===TJ&&(Z=!1);continue}Q+=K,Q===J&&Y<X.length-1&&($.push(""),Q=0)}!Q&&$[$.length-1].length>0&&$.length>1&&($[$.length-2]+=$.pop())},Zz=($)=>{let q=$.split(" "),J=q.length;for(;J>0&&!(V0(q[J-1])>0);)J--;return J===q.length?$:q.slice(0,J).join(" ")+q.slice(J).join("")},Qz=($,q,J={})=>{if(J.trim!==!1&&$.trim()==="")return"";let X="",Z,H,Q=Xz($),Y=[""];for(let[K,U]of $.split(" ").entries()){J.trim!==!1&&(Y[Y.length-1]=Y[Y.length-1].trimStart());let z=V0(Y[Y.length-1]);if(K!==0&&(z>=q&&(J.wordWrap===!1||J.trim===!1)&&(Y.push(""),z=0),(z>0||J.trim===!1)&&(Y[Y.length-1]+=" ",z++)),J.hard&&Q[K]>q){let B=q-z,L=1+Math.floor((Q[K]-B-1)/q);Math.floor((Q[K]-1)/q)<L&&Y.push(""),n4(Y,U,q);continue}if(z+Q[K]>q&&z>0&&Q[K]>0){if(J.wordWrap===!1&&z<q){n4(Y,U,q);continue}Y.push("")}if(z+Q[K]>q&&J.wordWrap===!1){n4(Y,U,q);continue}Y[Y.length-1]+=U}J.trim!==!1&&(Y=Y.map((K)=>Zz(K)));let G=[...Y.join(`
|
|
72
|
+
`)];for(let[K,U]of G.entries()){if(X+=U,c$.has(U)){let{groups:B}=new RegExp(`(?:\\${RJ}(?<code>\\d+)m|\\${o4}(?<uri>.*)${t4})`).exec(G.slice(K).join(""))||{groups:{}};if(B.code!==void 0){let L=Number.parseFloat(B.code);Z=L===qz?void 0:L}else B.uri!==void 0&&(H=B.uri.length===0?void 0:B.uri)}let z=$z.codes.get(Number(Z));G[K+1]===`
|
|
73
|
+
`?(H&&(X+=GJ("")),Z&&z&&(X+=YJ(z))):U===`
|
|
74
|
+
`&&(Z&&z&&(X+=YJ(Z)),H&&(X+=GJ(H)))}return X};function KJ($,q,J){return String($).normalize().replace(/\r\n/g,`
|
|
75
75
|
`).split(`
|
|
76
|
-
`).map((X)=>
|
|
77
|
-
`)}var
|
|
76
|
+
`).map((X)=>Qz(X,q,J)).join(`
|
|
77
|
+
`)}var Hz=["up","down","left","right","space","enter","cancel"],g$={actions:new Set(Hz),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]])};function r4($,q){if(typeof $=="string")return g$.aliases.get($)===q;for(let J of $)if(J!==void 0&&r4(J,q))return!0;return!1}function Yz($,q){if($===q)return;let J=$.split(`
|
|
78
78
|
`),X=q.split(`
|
|
79
|
-
`),Z=[];for(let H=0;H<Math.max(J.length,X.length);H++)J[H]!==X[H]&&Z.push(H);return Z}var
|
|
80
|
-
`),
|
|
81
|
-
`).length-1;this.output.write(S.cursor.move(-999,$*-1))}render(){let $=
|
|
79
|
+
`),Z=[];for(let H=0;H<Math.max(J.length,X.length);H++)J[H]!==X[H]&&Z.push(H);return Z}var Gz=globalThis.process.platform.startsWith("win"),a4=Symbol("clack:cancel");function a1($){return $===a4}function b$($,q){let J=$;J.isTTY&&J.setRawMode(q)}function PJ({input:$=zJ,output:q=BJ,overwrite:J=!0,hideCursor:X=!0}={}){let Z=T1.createInterface({input:$,output:q,prompt:"",tabSize:1});T1.emitKeypressEvents($,Z),$.isTTY&&$.setRawMode(!0);let H=(Q,{name:Y,sequence:G})=>{let K=String(Q);if(r4([K,Y,G],"cancel")){X&&q.write(S.cursor.show),process.exit(0);return}if(!J)return;T1.moveCursor(q,Y==="return"?0:-1,Y==="return"?-1:0,()=>{T1.clearLine(q,1,()=>{$.once("keypress",H)})})};return X&&q.write(S.cursor.hide),$.once("keypress",H),()=>{$.off("keypress",H),X&&q.write(S.cursor.show),$.isTTY&&!Gz&&$.setRawMode(!1),Z.terminal=!1,Z.close()}}var Kz=Object.defineProperty,Uz=($,q,J)=>(q in $)?Kz($,q,{enumerable:!0,configurable:!0,writable:!0,value:J}):$[q]=J,p=($,q,J)=>(Uz($,typeof q!="symbol"?q+"":q,J),J);class m${constructor($,q=!0){p(this,"input"),p(this,"output"),p(this,"_abortSignal"),p(this,"rl"),p(this,"opts"),p(this,"_render"),p(this,"_track",!1),p(this,"_prevFrame",""),p(this,"_subscribers",new Map),p(this,"_cursor",0),p(this,"state","initial"),p(this,"error",""),p(this,"value");let{input:J=zJ,output:X=BJ,render:Z,signal:H,...Q}=$;this.opts=Q,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Z.bind(this),this._track=q,this._abortSignal=H,this.input=J,this.output=X}unsubscribe(){this._subscribers.clear()}setSubscriber($,q){let J=this._subscribers.get($)??[];J.push(q),this._subscribers.set($,J)}on($,q){this.setSubscriber($,{cb:q})}once($,q){this.setSubscriber($,{cb:q,once:!0})}emit($,...q){let J=this._subscribers.get($)??[],X=[];for(let Z of J)Z.cb(...q),Z.once&&X.push(()=>J.splice(J.indexOf(Z),1));for(let Z of X)Z()}prompt(){return new Promise(($,q)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),$(a4);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let J=new lU;J._write=(X,Z,H)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),H()},this.input.pipe(J),this.rl=XJ.createInterface({input:this.input,output:J,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),XJ.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),b$(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(S.cursor.show),this.output.off("resize",this.render),b$(this.input,!1),$(this.value)}),this.once("cancel",()=>{this.output.write(S.cursor.show),this.output.off("resize",this.render),b$(this.input,!1),$(a4)})})}onKeypress($,q){if(this.state==="error"&&(this.state="active"),q?.name&&(!this._track&&g$.aliases.has(q.name)&&this.emit("cursor",g$.aliases.get(q.name)),g$.actions.has(q.name)&&this.emit("cursor",q.name)),$&&($.toLowerCase()==="y"||$.toLowerCase()==="n")&&this.emit("confirm",$.toLowerCase()==="y"),$==="\t"&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),$&&this.emit("key",$.toLowerCase()),q?.name==="return"){if(this.opts.validate){let J=this.opts.validate(this.value);J&&(this.error=J instanceof Error?J.message:J,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}r4([$,q?.name,q?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
80
|
+
`),b$(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let $=KJ(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
81
|
+
`).length-1;this.output.write(S.cursor.move(-999,$*-1))}render(){let $=KJ(this._render(this)??"",process.stdout.columns,{hard:!0});if($!==this._prevFrame){if(this.state==="initial")this.output.write(S.cursor.hide);else{let q=Yz(this._prevFrame,$);if(this.restoreCursor(),q&&q?.length===1){let J=q[0];this.output.write(S.cursor.move(0,J)),this.output.write(S.erase.lines(1));let X=$.split(`
|
|
82
82
|
`);this.output.write(X[J]),this._prevFrame=$,this.output.write(S.cursor.move(0,X.length-J-1));return}if(q&&q?.length>1){let J=q[0];this.output.write(S.cursor.move(0,J)),this.output.write(S.erase.down());let X=$.split(`
|
|
83
83
|
`).slice(J);this.output.write(X.join(`
|
|
84
|
-
`)),this._prevFrame=$;return}this.output.write(S.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}class
|
|
85
|
-
${
|
|
86
|
-
`,J=$.placeholder?
|
|
87
|
-
${
|
|
88
|
-
${
|
|
89
|
-
`;case"submit":return`${q}${
|
|
90
|
-
${
|
|
91
|
-
${
|
|
92
|
-
`}}}).prompt();var
|
|
93
|
-
${
|
|
94
|
-
`,Z=this.value?q:J;switch(this.state){case"submit":return`${X}${
|
|
95
|
-
${
|
|
96
|
-
${
|
|
97
|
-
`}}}).prompt()},
|
|
98
|
-
${
|
|
99
|
-
`;switch(this.state){case"submit":return`${J}${
|
|
100
|
-
${
|
|
101
|
-
${
|
|
102
|
-
${
|
|
103
|
-
`}}}).prompt()};var
|
|
84
|
+
`)),this._prevFrame=$;return}this.output.write(S.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}class s4 extends m${get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor($){super($,!1),this.value=!!$.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(q)=>{this.output.write(S.cursor.move(0,-1)),this.value=q,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var zz;zz=new WeakMap;var Bz=Object.defineProperty,Lz=($,q,J)=>(q in $)?Bz($,q,{enumerable:!0,configurable:!0,writable:!0,value:J}):$[q]=J,UJ=($,q,J)=>(Lz($,typeof q!="symbol"?q+"":q,J),J);class e4 extends m${constructor($){super($,!1),UJ(this,"options"),UJ(this,"cursor",0),this.options=$.options,this.cursor=this.options.findIndex(({value:q})=>q===$.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(q)=>{switch(q){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}}class $3 extends m${get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}█`;let $=this.value.slice(0,this.cursor),[q,...J]=this.value.slice(this.cursor);return`${$}${LJ.default.inverse(q)}${J.join("")}`}get cursor(){return this._cursor}constructor($){super($),this.on("finalize",()=>{this.value||(this.value=$.defaultValue)})}}var W=o(A1(),1),u$=o(l4(),1);import t from"node:process";function Vz(){return t.platform!=="win32"?t.env.TERM!=="linux":!!t.env.CI||!!t.env.WT_SESSION||!!t.env.TERMINUS_SUBLIME||t.env.ConEmuTask==="{cmd::Cmder}"||t.env.TERM_PROGRAM==="Terminus-Sublime"||t.env.TERM_PROGRAM==="vscode"||t.env.TERM==="xterm-256color"||t.env.TERM==="alacritty"||t.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var J3=Vz(),y=($,q)=>J3?$:q,Wz=y("◆","*"),FJ=y("■","x"),xJ=y("▲","x"),Q3=y("◇","o"),_z=y("┌","T"),w=y("│","|"),t1=y("└","—"),X3=y("●",">"),Z3=y("○"," "),WM=y("◻","[•]"),_M=y("◼","[+]"),RM=y("◻","[ ]"),TM=y("▪","•"),kJ=y("─","-"),Rz=y("╮","+"),Tz=y("├","+"),Pz=y("╯","+"),PM=y("●","•"),kM=y("◆","*"),FM=y("▲","!"),xM=y("■","x"),H3=($)=>{switch($){case"initial":case"active":return W.default.cyan(Wz);case"cancel":return W.default.red(FJ);case"error":return W.default.yellow(xJ);case"submit":return W.default.green(Q3)}},kz=($)=>{let{cursor:q,options:J,style:X}=$,Z=$.maxItems??Number.POSITIVE_INFINITY,H=Math.max(process.stdout.rows-4,0),Q=Math.min(H,Math.max(Z,5)),Y=0;q>=Y+Q-3?Y=Math.max(Math.min(q-Q+3,J.length-Q),0):q<Y+2&&(Y=Math.max(q-2,0));let G=Q<J.length&&Y>0,K=Q<J.length&&Y+Q<J.length;return J.slice(Y,Y+Q).map((U,z,B)=>{let L=z===0&&G,_=z===B.length-1&&K;return L||_?W.default.dim("..."):X(U,z+Y===q)})},jJ=($)=>new $3({validate:$.validate,placeholder:$.placeholder,defaultValue:$.defaultValue,initialValue:$.initialValue,render(){let q=`${W.default.gray(w)}
|
|
85
|
+
${H3(this.state)} ${$.message}
|
|
86
|
+
`,J=$.placeholder?W.default.inverse($.placeholder[0])+W.default.dim($.placeholder.slice(1)):W.default.inverse(W.default.hidden("_")),X=this.value?this.valueWithCursor:J;switch(this.state){case"error":return`${q.trim()}
|
|
87
|
+
${W.default.yellow(w)} ${X}
|
|
88
|
+
${W.default.yellow(t1)} ${W.default.yellow(this.error)}
|
|
89
|
+
`;case"submit":return`${q}${W.default.gray(w)} ${W.default.dim(this.value||$.placeholder)}`;case"cancel":return`${q}${W.default.gray(w)} ${W.default.strikethrough(W.default.dim(this.value??""))}${this.value?.trim()?`
|
|
90
|
+
${W.default.gray(w)}`:""}`;default:return`${q}${W.default.cyan(w)} ${X}
|
|
91
|
+
${W.default.cyan(t1)}
|
|
92
|
+
`}}}).prompt();var MJ=($)=>{let q=$.active??"Yes",J=$.inactive??"No";return new s4({active:q,inactive:J,initialValue:$.initialValue??!0,render(){let X=`${W.default.gray(w)}
|
|
93
|
+
${H3(this.state)} ${$.message}
|
|
94
|
+
`,Z=this.value?q:J;switch(this.state){case"submit":return`${X}${W.default.gray(w)} ${W.default.dim(Z)}`;case"cancel":return`${X}${W.default.gray(w)} ${W.default.strikethrough(W.default.dim(Z))}
|
|
95
|
+
${W.default.gray(w)}`;default:return`${X}${W.default.cyan(w)} ${this.value?`${W.default.green(X3)} ${q}`:`${W.default.dim(Z3)} ${W.default.dim(q)}`} ${W.default.dim("/")} ${this.value?`${W.default.dim(Z3)} ${W.default.dim(J)}`:`${W.default.green(X3)} ${J}`}
|
|
96
|
+
${W.default.cyan(t1)}
|
|
97
|
+
`}}}).prompt()},CJ=($)=>{let q=(J,X)=>{let Z=J.label??String(J.value);switch(X){case"selected":return`${W.default.dim(Z)}`;case"active":return`${W.default.green(X3)} ${Z} ${J.hint?W.default.dim(`(${J.hint})`):""}`;case"cancelled":return`${W.default.strikethrough(W.default.dim(Z))}`;default:return`${W.default.dim(Z3)} ${W.default.dim(Z)}`}};return new e4({options:$.options,initialValue:$.initialValue,render(){let J=`${W.default.gray(w)}
|
|
98
|
+
${H3(this.state)} ${$.message}
|
|
99
|
+
`;switch(this.state){case"submit":return`${J}${W.default.gray(w)} ${q(this.options[this.cursor],"selected")}`;case"cancel":return`${J}${W.default.gray(w)} ${q(this.options[this.cursor],"cancelled")}
|
|
100
|
+
${W.default.gray(w)}`;default:return`${J}${W.default.cyan(w)} ${kz({cursor:this.cursor,options:this.options,maxItems:$.maxItems,style:(X,Z)=>q(X,Z?"active":"inactive")}).join(`
|
|
101
|
+
${W.default.cyan(w)} `)}
|
|
102
|
+
${W.default.cyan(t1)}
|
|
103
|
+
`}}}).prompt()};var wJ=($="",q="")=>{let J=`
|
|
104
104
|
${$}
|
|
105
105
|
`.split(`
|
|
106
|
-
`),X=
|
|
107
|
-
`);process.stdout.write(`${
|
|
108
|
-
${
|
|
106
|
+
`),X=q3(q).length,Z=Math.max(J.reduce((Q,Y)=>{let G=q3(Y);return G.length>Q?G.length:Q},0),X)+2,H=J.map((Q)=>`${W.default.gray(w)} ${W.default.dim(Q)}${" ".repeat(Z-q3(Q).length)}${W.default.gray(w)}`).join(`
|
|
107
|
+
`);process.stdout.write(`${W.default.gray(w)}
|
|
108
|
+
${W.default.green(Q3)} ${W.default.reset(q)} ${W.default.gray(kJ.repeat(Math.max(Z-X-1,1))+Rz)}
|
|
109
109
|
${H}
|
|
110
|
-
${
|
|
111
|
-
`)},
|
|
110
|
+
${W.default.gray(Tz+kJ.repeat(Z+2)+Pz)}
|
|
111
|
+
`)},o1=($="")=>{process.stdout.write(`${W.default.gray(t1)} ${W.default.red($)}
|
|
112
112
|
|
|
113
|
-
`)},
|
|
114
|
-
`)},
|
|
115
|
-
${
|
|
113
|
+
`)},IJ=($="")=>{process.stdout.write(`${W.default.gray(_z)} ${$}
|
|
114
|
+
`)},AJ=($="")=>{process.stdout.write(`${W.default.gray(w)}
|
|
115
|
+
${W.default.gray(t1)} ${$}
|
|
116
116
|
|
|
117
|
-
`)};var
|
|
117
|
+
`)};var jM=`${W.default.gray(w)} `;var EJ=({indicator:$="dots"}={})=>{let q=J3?["◒","◐","◓","◑"]:["•","o","O","0"],J=J3?80:120,X=process.env.CI==="true",Z,H,Q=!1,Y="",G,K=performance.now(),U=(x)=>{let I=x>1?"Something went wrong":"Canceled";Q&&v(I,x)},z=()=>U(2),B=()=>U(1),L=()=>{process.on("uncaughtExceptionMonitor",z),process.on("unhandledRejection",z),process.on("SIGINT",B),process.on("SIGTERM",B),process.on("exit",U)},_=()=>{process.removeListener("uncaughtExceptionMonitor",z),process.removeListener("unhandledRejection",z),process.removeListener("SIGINT",B),process.removeListener("SIGTERM",B),process.removeListener("exit",U)},P=()=>{if(G===void 0)return;X&&process.stdout.write(`
|
|
118
118
|
`);let x=G.split(`
|
|
119
|
-
`);process.stdout.write(
|
|
120
|
-
`);let
|
|
119
|
+
`);process.stdout.write(u$.cursor.move(-999,x.length-1)),process.stdout.write(u$.erase.down(x.length))},M=(x)=>x.replace(/\.+$/,""),F=(x)=>{let I=(performance.now()-x)/1000,N=Math.floor(I/60),c=Math.floor(I%60);return N>0?`[${N}m ${c}s]`:`[${c}s]`},O=(x="")=>{Q=!0,Z=PJ(),Y=M(x),K=performance.now(),process.stdout.write(`${W.default.gray(w)}
|
|
120
|
+
`);let I=0,N=0;L(),H=setInterval(()=>{if(X&&Y===G)return;P(),G=Y;let c=W.default.magenta(q[I]);if(X)process.stdout.write(`${c} ${Y}...`);else if($==="timer")process.stdout.write(`${c} ${Y} ${F(K)}`);else{let B1=".".repeat(Math.floor(N)).slice(0,3);process.stdout.write(`${c} ${Y}${B1}`)}I=I+1<q.length?I+1:0,N=N<q.length?N+0.125:0},J)},v=(x="",I=0)=>{Q=!1,clearInterval(H),P();let N=I===0?W.default.green(Q3):I===1?W.default.red(FJ):W.default.red(xJ);Y=M(x??Y),$==="timer"?process.stdout.write(`${N} ${Y} ${F(K)}
|
|
121
121
|
`):process.stdout.write(`${N} ${Y}
|
|
122
|
-
`),
|
|
122
|
+
`),_(),Z()};return{start:O,stop:v,message:(x="")=>{Y=M(x??Y)}}};var yJ=o(A1(),1);async function g($,q=!0){let J=await MJ({message:$,initialValue:q});if(a1(J))o1("Operation cancelled"),process.exit(0);return J}async function OJ($,q,J){let X=await jJ({message:$,placeholder:q,initialValue:J});if(a1(X))o1("Operation cancelled"),process.exit(0);return X}async function W0($,q){let J=q.map((Z)=>({value:Z.value,label:Z.label,...Z.hint&&{hint:Z.hint}})),X=await CJ({message:$,options:J});if(a1(X))o1("Operation cancelled"),process.exit(0);return X}async function NJ(){return W0("Select target chip",y3.map(($)=>({value:$.id,label:$.name,hint:$.description+($.stable?"":" (preview)")})))}async function DJ(){return W0("Select language",[{value:"c",label:"C",hint:"Standard C project"},{value:"cpp",label:"C++",hint:'C++ with extern "C" linkage'}])}async function z1($){if($.length===0)o1("No devices found"),process.exit(1);return W0("Select device",$.map((q)=>({value:q.port,label:q.port,hint:xz(q)})))}function xz($){let q=[];if($.espChip)q.push($.espChip);else if($.chip)q.push($.chip);else if($.manufacturer)q.push($.manufacturer);if($.connectionType==="native-usb")q.push("USB");else if($.connectionType==="uart-bridge")q.push("UART");return q.join(" · ")}function Z1($,q){return $.find((J)=>J.port===q)}function p$($){if($.connectionType==="uart-bridge"&&$.espChip?.includes("S3"))return{ok:!1,warning:`Port ${$.port} is a UART bridge. ESP32-S3 flashing works better with native USB port.`};return{ok:!0}}function vJ($){return{ok:!0}}async function jz($){let q=N3.map((X)=>({value:String(X.value),label:X.label,hint:X.hint+(X.value===$?" (current)":"")})),J=await W0("Select flash baud rate",q);return parseInt(J,10)}async function Mz($){let q=D3.map((X)=>({value:String(X.value),label:X.label,hint:X.hint+(X.value===$?" (current)":"")})),J=await W0("Select monitor baud rate",q);return parseInt(J,10)}async function l$($,q){if(await g(`Use ${$} baud rate ${q}?`,!0))return q;return $==="flash"?jz(q):Mz(q)}function d$(){return EJ()}function i$($){IJ(yJ.default.inverse(` ${$} `))}function _0($){AJ($)}function n$($){o1($)}function a$($,q){wJ($,q)}var E1=o(A1(),1);function Cz($){console.log(E1.default.blue("ℹ"),$)}function wz($){console.log(E1.default.green("✔"),$)}function Iz($){console.log(E1.default.yellow("⚠"),$)}function Az($){console.log(E1.default.red("✖"),$)}function Ez($){console.log(E1.default.cyan("→"),$)}function yz($){console.log(E1.default.dim($))}function Oz($){process.stdout.write($)}function Nz(){console.log()}var V={info:Cz,success:wz,warn:Iz,error:Az,step:Ez,dim:yz,output:Oz,newline:Nz};async function hJ($){i$("ESP-IDF Installation");let q=await aq();if(q.installed){if(V.info(`ESP-IDF already installed at ${q.path}`),q.version)V.info(`Version: ${q.version}`);if(!await g("Reinstall ESP-IDF?",!1)){_0("Installation skipped");return}}let J=$.path||x0,X=$.target||"all",Z=h$();if(!$.yes){if(a$(`Install path: ${J}
|
|
123
123
|
Target: ${X}
|
|
124
124
|
Shell: ${Z.type}
|
|
125
|
-
Config: ${Z.configPath}`,"Installation Plan"),!await
|
|
125
|
+
Config: ${Z.configPath}`,"Installation Plan"),!await g("Proceed with installation?")){n$("Installation cancelled");return}}let H=j(),Q=d$();R.subscribe(H,(G)=>{if(G.data.type==="progress")Q.message(G.data.message);else if(G.data.type==="stdout"||G.data.type==="stderr")Q.stop(),V.output(G.data.text),Q.start()}),Q.start("Installing ESP-IDF...");let Y=await eq({path:J,target:X,addToShell:!0},H);if(Q.stop(),!Y.ok)V.error(Y.error),process.exit(1);if(V.success(`ESP-IDF installed at ${Y.data.idfPath}`),Y.data.addedToShell)V.info(`Added to ${Z.configPath}`),V.dim("Restart your shell or run: source "+Z.configPath);_0("Installation complete")}import{mkdir as pJ,writeFile as Dz}from"fs/promises";import{join as t$}from"path";function fJ($){return`cmake_minimum_required(VERSION 3.16)
|
|
126
126
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
|
127
127
|
project(${$})
|
|
128
|
-
`}function
|
|
128
|
+
`}function SJ($){return`idf_component_register(SRCS "${$}"
|
|
129
129
|
INCLUDE_DIRS ".")
|
|
130
|
-
`}function
|
|
130
|
+
`}function bJ($){return`#include <stdio.h>
|
|
131
131
|
#include "freertos/FreeRTOS.h"
|
|
132
132
|
#include "freertos/task.h"
|
|
133
133
|
|
|
@@ -138,7 +138,7 @@ void app_main(void)
|
|
|
138
138
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
`}function
|
|
141
|
+
`}function gJ($){return`#include <cstdio>
|
|
142
142
|
#include "freertos/FreeRTOS.h"
|
|
143
143
|
#include "freertos/task.h"
|
|
144
144
|
|
|
@@ -149,14 +149,13 @@ extern "C" void app_main(void)
|
|
|
149
149
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
`}function
|
|
152
|
+
`}function cJ(){return`build/
|
|
153
153
|
sdkconfig
|
|
154
154
|
sdkconfig.old
|
|
155
|
-
.vscode/
|
|
156
155
|
*.pyc
|
|
157
156
|
__pycache__/
|
|
158
157
|
.DS_Store
|
|
159
|
-
`}function
|
|
158
|
+
`}function mJ($,q){return`# ${$}
|
|
160
159
|
|
|
161
160
|
ESP-IDF project targeting ${q}.
|
|
162
161
|
|
|
@@ -177,8 +176,35 @@ idf.py -p PORT flash
|
|
|
177
176
|
\`\`\`bash
|
|
178
177
|
idf.py -p PORT monitor
|
|
179
178
|
\`\`\`
|
|
180
|
-
`}function
|
|
179
|
+
`}function uJ(){return`{
|
|
180
|
+
"version": 4,
|
|
181
|
+
"configurations": [
|
|
182
|
+
{
|
|
183
|
+
"name": "ESP-IDF",
|
|
184
|
+
"compileCommands": "\${workspaceFolder}/build/compile_commands.json",
|
|
185
|
+
"includePath": [
|
|
186
|
+
"\${workspaceFolder}/**",
|
|
187
|
+
"\${env:HOME}/esp/esp-idf/components/**",
|
|
188
|
+
"\${env:IDF_PATH}/components/**"
|
|
189
|
+
],
|
|
190
|
+
"browse": {
|
|
191
|
+
"path": [
|
|
192
|
+
"\${workspaceFolder}",
|
|
193
|
+
"\${env:HOME}/esp/esp-idf/components",
|
|
194
|
+
"\${env:IDF_PATH}/components"
|
|
195
|
+
],
|
|
196
|
+
"limitSymbolsToIncludedHeaders": false
|
|
197
|
+
},
|
|
198
|
+
"defines": [],
|
|
199
|
+
"intelliSenseMode": "gcc-x64",
|
|
200
|
+
"cStandard": "c17",
|
|
201
|
+
"cppStandard": "c++17"
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
`}function vz($){let{name:q,language:J,target:X}=$,Z=J==="cpp"?"main.cpp":"main.c",H=J==="cpp"?gJ(q):bJ(q);return[{path:"CMakeLists.txt",content:fJ(q)},{path:"main/CMakeLists.txt",content:SJ(Z)},{path:`main/${Z}`,content:H},{path:".gitignore",content:cJ()},{path:"README.md",content:mJ(q,X)},{path:".vscode/c_cpp_properties.json",content:uJ()}]}async function lJ($){let q=t$($.directory,$.name),J=vz($);try{await pJ(t$(q,"main"),{recursive:!0}),await pJ(t$(q,".vscode"),{recursive:!0});let X=[];for(let Z of J){let H=t$(q,Z.path);await Dz(H,Z.content),X.push(Z.path)}return{ok:!0,data:{projectPath:q,files:X}}}catch(X){return{ok:!1,error:`Failed to create project: ${X}`}}}async function dJ($,q){let J=q||j();R.emit(J,{type:"progress",message:`Creating project ${$.name}...`});let X=await lJ($);if(!X.ok)return R.emit(J,{type:"error",message:X.error}),X;R.emit(J,{type:"progress",message:"Setting target...",percent:80});let Z=await X1("idf.py",["set-target",$.target],{cwd:X.data.projectPath,operationId:J});if(!Z.ok||Z.data.exitCode!==0)R.emit(J,{type:"log",level:"warn",message:"Failed to set target. You may need to run: idf.py set-target "+$.target});return R.emit(J,{type:"complete",result:X.data}),X}import{resolve as hz}from"path";async function iJ($,q){i$("Create ESP-IDF Project");let J=$||await OJ("Project name","my-esp-project"),X=q.lang||await DJ(),Z=q.target||await NJ(),H={name:J,directory:hz(process.cwd()),language:X,target:Z};if(a$(`Name: ${H.name}
|
|
181
206
|
Language: ${X.toUpperCase()}
|
|
182
207
|
Target: ${Z}
|
|
183
|
-
Path: ${H.directory}/${H.name}`,"Project Configuration"),!await
|
|
184
|
-
`),H=null,Q="",Y="";for(let G of Z)if(G.startsWith("/dev/")){if(H){let K=bJ(H,Q,Y);if(K)X.push(K)}H=G.trim(),Q="",Y=""}else if(G.includes("desc:"))Q=G.split("desc:")[1]?.trim()||"";else if(G.includes("hwid:"))Y=G.split("hwid:")[1]?.trim()||"";if(H){let G=bJ(H,Q,Y);if(G)X.push(G)}return await fz(q,X)}catch{return[]}}function bJ($,q,J){if(J==="n/a"||!J.includes("VID:PID="))return null;let X=J.match(/VID:PID=([0-9A-Fa-f]+):([0-9A-Fa-f]+)/),Z=X?.[1]?.toUpperCase(),H=X?.[2]?.toUpperCase(),Q=Dz(Z),Y=vz(Z,H);return{port:$,connectionType:Q,vendorId:Z,productId:H,manufacturer:q2[Z||""]?.name,chip:Y,description:q!=="n/a"?q:void 0}}function Dz($){if(!$)return"unknown";return $.toUpperCase()===Nz?"native-usb":"uart-bridge"}function vz($,q){if(!$)return;let J=q2[$.toUpperCase()];if(!J)return;if(q){let X=J.chips[q.toUpperCase()];if(X)return X}return J.name}async function fz($,q){return await Promise.all(q.map(async(X)=>{if(X.connectionType==="native-usb"||X.chip?.includes("CH34")||X.chip?.includes("CP210")||X.chip?.includes("FT232")||X.chip?.includes("CH9")){let H=await hz($,X.port);return{...X,espChip:H}}return X}))}async function hz($,q){try{let{stdout:J,stderr:X}=await h($,["-m","esptool","--port",q,"chip_id"],{timeout:1e4,reject:!1}),Z=J+X,H=[/Chip is (ESP32[A-Za-z0-9-]*)/i,/Detecting chip type[.\s]*(ESP32[A-Za-z0-9-]*)/i,/Chip type:\s*(ESP32[A-Za-z0-9-]*)/i];for(let Q of H){let Y=Z.match(Q);if(Y)return Y[1].toUpperCase()}}catch{}return}async function R1(){try{return{ok:!0,data:await m$()}}catch($){return{ok:!1,error:`Failed to list devices: ${$}`}}}var b=t(C1(),1);function Sz($){return $.replace(/\x1b\[[0-9;]*m/g,"")}function gJ($){return Sz($).length}function bz($,q){let J=$.map((K,U)=>{let z=Math.max(...q.map((B)=>gJ(B[U]||"")));return Math.max(K.length,z)}),X="─",Z="┌"+J.map((K)=>"─".repeat(K+2)).join("┬")+"┐",H="├"+J.map((K)=>"─".repeat(K+2)).join("┼")+"┤",Q="└"+J.map((K)=>"─".repeat(K+2)).join("┴")+"┘",Y=(K,U)=>{let z=gJ(K),B=U-z;return K+" ".repeat(Math.max(0,B))},G=(K)=>"│"+K.map((U,z)=>` ${Y(U||"",J[z])} `).join("│")+"│";console.log(b.default.dim(Z)),console.log(b.default.bold(G($))),console.log(b.default.dim(H)),q.forEach((K)=>console.log(G(K))),console.log(b.default.dim(Q))}function cJ($){if($.length===0){console.log(b.default.dim("No devices found"));return}let q=["Port","Type","Chip","ESP"],J=$.map((H)=>{let Q=gz(H.connectionType),Y=H.espChip||(H.connectionType==="native-usb"?"?":"-");return[H.port,Q,H.chip||"-",Y]});bz(q,J);let X=$.some((H)=>H.connectionType==="native-usb"),Z=$.some((H)=>H.connectionType==="uart-bridge");if(X&&Z)console.log(""),console.log(b.default.dim(" Hint: Multiple ports from same board")),console.log(b.default.dim(" • ")+b.default.cyan("UART")+b.default.dim(" - Reliable flashing & monitoring")),console.log(b.default.dim(" • ")+b.default.magenta("USB")+b.default.dim(" - JTAG debugging"))}function gz($){switch($){case"native-usb":return b.default.magenta("USB");case"uart-bridge":return b.default.cyan("UART");default:return b.default.dim("?")}}async function mJ(){_.info("Scanning for devices...");let $=await R1();if(!$.ok)_.error($.error),process.exit(1);_.newline(),cJ($.data),_.newline()}async function u$($,q){let J=q||j(),{projectDir:X,target:Z,clean:H}=$;if(!await M1(X))return R.emit(J,{type:"error",message:"Not an ESP-IDF project directory"}),{ok:!1,error:"Not an ESP-IDF project directory"};if(Z){R.emit(J,{type:"progress",message:`Setting target to ${Z}...`});let G=await J1("idf.py",["set-target",Z],{cwd:X,operationId:J});if(!G.ok||G.data.exitCode!==0)return R.emit(J,{type:"error",message:"Failed to set target"}),{ok:!1,error:"Failed to set target"}}if(H)R.emit(J,{type:"progress",message:"Cleaning..."}),await J1("idf.py",["clean"],{cwd:X,operationId:J});R.emit(J,{type:"progress",message:"Building project..."});let Y=await J1("idf.py",["build"],{cwd:X,operationId:J});if(!Y.ok)return R.emit(J,{type:"error",message:Y.error}),{ok:!1,error:Y.error};if(Y.data.exitCode!==0)return R.emit(J,{type:"error",message:"Build failed"}),{ok:!1,error:"Build failed"};return R.emit(J,{type:"complete",result:{success:!0,projectDir:X}}),{ok:!0,data:{success:!0,projectDir:X}}}async function uJ($){let q=await q1(process.cwd());if(!q)_.error("Not in an ESP-IDF project directory"),process.exit(1);let J=j();R.subscribe(J,(Z)=>{if(Z.data.type==="stdout")_.output(Z.data.text);else if(Z.data.type==="stderr")_.output(Z.data.text)}),_.step("Building project...");let X=await u$({projectDir:q,target:$.target,clean:$.clean},J);if(!X.ok)_.newline(),_.error(X.error),process.exit(1);_.newline(),_.success("Build complete")}async function p$($,q){let J=q||j(),{projectDir:X,port:Z,baud:H=C3}=$;if(!await M1(X))return R.emit(J,{type:"error",message:"Not an ESP-IDF project directory"}),{ok:!1,error:"Not an ESP-IDF project directory"};R.emit(J,{type:"progress",message:`Flashing to ${Z}...`});let Y=["-p",Z,"-b",String(H),"flash"],G=await J1("idf.py",Y,{cwd:X,operationId:J});if(!G.ok)return R.emit(J,{type:"error",message:G.error}),{ok:!1,error:G.error};if(G.data.exitCode!==0)return R.emit(J,{type:"error",message:"Flash failed"}),{ok:!1,error:"Flash failed"};return R.emit(J,{type:"complete",result:{success:!0,port:Z}}),{ok:!0,data:{success:!0,port:Z}}}async function pJ($){let q=await q1(process.cwd());if(!q)_.error("Not in an ESP-IDF project directory"),process.exit(1);let J=$.port;if(!J){let H=await R1();if(!H.ok)_.error(H.error),process.exit(1);J=await d1(H.data)}let X=j();R.subscribe(X,(H)=>{if(H.data.type==="stdout"||H.data.type==="stderr")_.output(H.data.text)}),_.step(`Flashing to ${J}...`);let Z=await p$({projectDir:q,port:J,baud:$.baud},X);if(!Z.ok)_.newline(),_.error(Z.error),process.exit(1);_.newline(),_.success("Flash complete")}var q3=new Map;function l$($,q){let J=q||j(),{port:X,baud:Z=I3,projectDir:H}=$,Q=["-p",X,"-b",String(Z),"monitor"],Y=uq("idf.py",Q,{cwd:H||process.cwd(),operationId:J});if(!Y)return R.emit(J,{type:"error",message:"ESP-IDF not found"}),{ok:!1,error:"ESP-IDF not found"};return q3.set(J,Y),Y.then(()=>{q3.delete(J),R.emit(J,{type:"complete",result:{stopped:!0}})}),{ok:!0,data:{operationId:J,stop:()=>{Y.kill("SIGTERM"),q3.delete(J)},sendInput:(K)=>{Y.stdin?.write(K)}}}}async function lJ($){let q=await q1(process.cwd()),J=$.port;if(!J){let H=await R1();if(!H.ok)_.error(H.error),process.exit(1);J=await d1(H.data)}let X=j();R.subscribe(X,(H)=>{if(H.data.type==="stdout"||H.data.type==="stderr")_.output(H.data.text)}),_.step(`Connecting to ${J}...`),_.dim("Press Ctrl+C to exit"),_.newline();let Z=l$({port:J,baud:$.baud,projectDir:q||void 0},X);if(!Z.ok)_.error(Z.error),process.exit(1);process.on("SIGINT",()=>{Z.data.stop(),_.newline(),_.info("Monitor stopped"),process.exit(0)}),await new Promise(()=>{})}async function dJ($,q){let J=q||j(),{projectDir:X,full:Z}=$;if(!await M1(X))return R.emit(J,{type:"error",message:"Not an ESP-IDF project directory"}),{ok:!1,error:"Not an ESP-IDF project directory"};let Q=Z?"fullclean":"clean";R.emit(J,{type:"progress",message:`Running ${Q}...`});let Y=await J1("idf.py",[Q],{cwd:X,operationId:J});if(!Y.ok)return R.emit(J,{type:"error",message:Y.error}),{ok:!1,error:Y.error};if(Y.data.exitCode!==0){let G=`${Q} failed`;return R.emit(J,{type:"error",message:G}),{ok:!1,error:G}}return R.emit(J,{type:"complete",result:null}),{ok:!0,data:void 0}}async function iJ($){let q=await q1(process.cwd());if(!q)_.error("Not in an ESP-IDF project directory"),process.exit(1);let J=j();_.step($.full?"Running fullclean...":"Cleaning build...");let X=await dJ({projectDir:q,full:$.full},J);if(!X.ok)_.error(X.error),process.exit(1);_.success("Clean complete")}async function nJ($){let q=await q1(process.cwd());if(!q)_.error("Not in an ESP-IDF project directory"),process.exit(1);let J=$.port;if(!J){let G=await R1();if(!G.ok)_.error(G.error),process.exit(1);J=await d1(G.data)}let X=(G)=>{if(G.data.type==="stdout"||G.data.type==="stderr")_.output(G.data.text)};if(!$.skipBuild){let G=j();R.subscribe(G,X),_.step("Building...");let K=await u$({projectDir:q},G);if(!K.ok)_.newline(),_.error(K.error),process.exit(1);_.newline(),_.success("Build complete")}let Z=j();R.subscribe(Z,X),_.step(`Flashing to ${J}...`);let H=await p$({projectDir:q,port:J,baud:$.baud},Z);if(!H.ok)_.newline(),_.error(H.error),process.exit(1);_.newline(),_.success("Flash complete");let Q=j();R.subscribe(Q,X),_.step("Starting monitor..."),_.dim("Press Ctrl+C to exit"),_.newline();let Y=l$({port:J,baud:$.baud,projectDir:q},Q);if(!Y.ok)_.error(Y.error),process.exit(1);process.on("SIGINT",()=>{Y.data.stop(),_.newline(),_.info("Monitor stopped"),process.exit(0)}),await new Promise(()=>{})}var f=t(C1(),1);async function aJ(){_.info("Checking system health..."),_.newline();let $=await $3();if(L0($.python),L0($.git),L0($.idf),L0($.pyserial),L0($.esptool),_.newline(),await cz(),_.newline(),$.python.ok&&$.git.ok&&$.idf.ok&&$.pyserial.ok&&$.esptool.ok)console.log(f.default.green("✓ All checks passed! Ready for ESP32 development."));else console.log(f.default.yellow("⚠ Some checks failed. See hints above to fix issues."));_.newline()}function L0($){let q=$.ok?f.default.green("✓"):f.default.red("✗"),J=$.name.padEnd(10),X=$.version?f.default.dim(`v${$.version}`):"",Z=$.path?f.default.dim(` (${$.path})`):"";if($.ok)console.log(` ${q} ${f.default.bold(J)} ${X}${Z}`);else if(console.log(` ${q} ${f.default.bold(J)} ${f.default.red($.error||"Not found")}`),$.hint)console.log(` ${f.default.dim("→")} ${f.default.yellow($.hint)}`)}async function cz(){console.log(f.default.bold(" Devices:"));try{let $=await m$();if($.length===0)console.log(` ${f.default.dim("No ESP devices connected")}`);else for(let q of $){let J=q.espChip||q.chip||"Unknown",X=q.connectionType==="native-usb"?"USB":"UART";console.log(` ${f.default.green("•")} ${q.port} ${f.default.dim(`(${J} via ${X})`)}`)}}catch{console.log(` ${f.default.dim("Could not check devices")}`)}}function tJ(){let $=new k3;return $.name("espcli").description("CLI tool for ESP-IDF development").version(A3),$.command("install").description("Install ESP-IDF framework").option("-p, --path <path>","Installation path").option("-t, --target <target>","Target chip (default: all)").option("-y, --yes","Skip confirmation prompts").action(wJ),$.command("init [name]").description("Create a new ESP-IDF project").option("-l, --lang <lang>","Language: c or cpp").option("-t, --target <target>","Target chip").action(hJ),$.command("devices").alias("ports").description("List connected ESP devices").action(mJ),$.command("build").description("Build the current project").option("-t, --target <target>","Set target before build").option("-c, --clean","Clean before build").action(uJ),$.command("flash").description("Flash firmware to device").option("-p, --port <port>","Serial port").option("-b, --baud <baud>","Flash baud rate",parseInt).action(pJ),$.command("monitor").description("Open serial monitor").option("-p, --port <port>","Serial port").option("-b, --baud <baud>","Monitor baud rate",parseInt).action(lJ),$.command("run").description("Build, flash, and monitor").option("-p, --port <port>","Serial port").option("-b, --baud <baud>","Baud rate",parseInt).option("--skip-build","Skip build step").action(nJ),$.command("clean").description("Clean build artifacts").option("-f, --full","Full clean (includes sdkconfig)").action(iJ),$.command("doctor").alias("check").description("Check system health and dependencies").action(aJ),$}var mz=tJ();mz.parse();
|
|
208
|
+
Path: ${H.directory}/${H.name}`,"Project Configuration"),!await g("Create project?")){n$("Cancelled");return}let Y=d$();Y.start("Creating project...");let G=j(),K=await dJ(H,G);if(Y.stop(),!K.ok)V.error(K.error),process.exit(1);V.success(`Created project at ${K.data.projectPath}`),V.newline(),V.dim("Files created:"),K.data.files.forEach((U)=>V.dim(` ${U}`)),V.newline(),V.info(`cd ${J} && espcli build`),_0("Project ready")}import{readdir as fz,access as Sz,readFile as bz}from"fs/promises";import{join as T0}from"path";var o$=null;async function Y3(){if(o$)return o$;return o$=await gz(),o$}async function gz(){let[$,q]=await Promise.all([cz(),mz()]),J=await uz(),X=J.ok?await pz():void 0,[Z,H]=X?await Promise.all([lz(X),dz(X)]):[{ok:!1,name:"pyserial",error:"ESP-IDF not installed",hint:"Run: espcli install"},{ok:!1,name:"esptool",error:"ESP-IDF not installed",hint:"Run: espcli install"}];return{python:$,idf:J,pyserial:Z,esptool:H,git:q,idfPython:X}}async function cz(){try{let{stdout:$}=await f("python3",["--version"],{timeout:3000});return{ok:!0,name:"Python",version:$.replace("Python ","").trim()}}catch{return{ok:!1,name:"Python",error:"Python 3 not found",hint:"Install Python 3: https://www.python.org/downloads/"}}}async function mz(){try{let{stdout:$}=await f("git",["--version"],{timeout:3000});return{ok:!0,name:"Git",version:$.replace("git version ","").trim()}}catch{return{ok:!1,name:"Git",error:"Git not found",hint:"Install Git: https://git-scm.com/downloads"}}}async function uz(){let $=process.env.HOME||"",q=[process.env.IDF_PATH,T0($,"esp","esp-idf"),T0($,"esp-idf")].filter(Boolean);for(let J of q)try{await Sz(J);let X;try{let Z=T0(J,"version.txt");X=(await bz(Z,"utf-8")).trim()}catch{try{let{stdout:Z}=await f("git",["describe","--tags"],{cwd:J,timeout:3000});X=Z.trim()}catch{X="unknown"}}return{ok:!0,name:"ESP-IDF",version:X,path:J}}catch{continue}return{ok:!1,name:"ESP-IDF",error:"ESP-IDF not found",hint:"Run: espcli install"}}async function pz(){let $=process.env.HOME||"",q=T0($,".espressif","python_env");try{let J=await fz(q);for(let X of J)if(X.startsWith("idf")){let Z=T0(q,X,"bin","python");try{return await f(Z,["--version"],{timeout:2000}),Z}catch{continue}}}catch{}return}async function lz($){try{let{stdout:q}=await f($,["-c","import serial; print(serial.__version__)"],{timeout:3000});return{ok:!0,name:"pyserial",version:q.trim()}}catch{return{ok:!1,name:"pyserial",error:"pyserial not installed in IDF environment",hint:"Reinstall ESP-IDF: espcli install"}}}async function dz($){try{let{stdout:q}=await f($,["-m","esptool","version"],{timeout:3000});return{ok:!0,name:"esptool",version:q.match(/v?([\d.]+)/)?.[1]||"unknown"}}catch{return{ok:!1,name:"esptool",error:"esptool not installed in IDF environment",hint:"Reinstall ESP-IDF: espcli install"}}}async function nJ(){let $=await Y3();if(!$.idf.ok)return{ok:!1,error:`${$.idf.error}. ${$.idf.hint}`};if(!$.idfPython)return{ok:!1,error:"ESP-IDF Python environment not found. Run: espcli install"};return{ok:!0,python:$.idfPython}}var iz="303A";async function r$(){let $=await nJ();if(!$.ok)return[];let q=$.python;try{let{stdout:J}=await f(q,["-m","serial.tools.list_ports","-v"],{timeout:5000}),X=[],Z=J.split(`
|
|
209
|
+
`),H=null,Q="",Y="";for(let G of Z)if(G.startsWith("/dev/")){if(H){let K=aJ(H,Q,Y);if(K)X.push(K)}H=G.trim(),Q="",Y=""}else if(G.includes("desc:"))Q=G.split("desc:")[1]?.trim()||"";else if(G.includes("hwid:"))Y=G.split("hwid:")[1]?.trim()||"";if(H){let G=aJ(H,Q,Y);if(G)X.push(G)}return await tz(q,X)}catch{return[]}}function aJ($,q,J){if(J==="n/a"||!J.includes("VID:PID="))return null;let X=J.match(/VID:PID=([0-9A-Fa-f]+):([0-9A-Fa-f]+)/),Z=X?.[1]?.toUpperCase(),H=X?.[2]?.toUpperCase(),Q=nz(Z),Y=az(Z,H);return{port:$,connectionType:Q,vendorId:Z,productId:H,manufacturer:z2[Z||""]?.name,chip:Y,description:q!=="n/a"?q:void 0}}function nz($){if(!$)return"unknown";return $.toUpperCase()===iz?"native-usb":"uart-bridge"}function az($,q){if(!$)return;let J=z2[$.toUpperCase()];if(!J)return;if(q){let X=J.chips[q.toUpperCase()];if(X)return X}return J.name}async function tz($,q){return await Promise.all(q.map(async(X)=>{if(X.connectionType==="native-usb"||X.chip?.includes("CH34")||X.chip?.includes("CP210")||X.chip?.includes("FT232")||X.chip?.includes("CH9")){let H=await oz($,X.port);return{...X,espChip:H}}return X}))}async function oz($,q){try{let{stdout:J,stderr:X}=await f($,["-m","esptool","--port",q,"chip_id"],{timeout:1e4,reject:!1}),Z=J+X,H=[/Chip is (ESP32[A-Za-z0-9-]*)/i,/Detecting chip type[.\s]*(ESP32[A-Za-z0-9-]*)/i,/Chip type:\s*(ESP32[A-Za-z0-9-]*)/i];for(let Q of H){let Y=Z.match(Q);if(Y)return Y[1].toUpperCase()}}catch{}return}async function P1(){try{return{ok:!0,data:await r$()}}catch($){return{ok:!1,error:`Failed to list devices: ${$}`}}}var b=o(A1(),1);function rz($){return $.replace(/\x1b\[[0-9;]*m/g,"")}function tJ($){return rz($).length}function sz($,q){let J=$.map((K,U)=>{let z=Math.max(...q.map((B)=>tJ(B[U]||"")));return Math.max(K.length,z)}),X="─",Z="┌"+J.map((K)=>"─".repeat(K+2)).join("┬")+"┐",H="├"+J.map((K)=>"─".repeat(K+2)).join("┼")+"┤",Q="└"+J.map((K)=>"─".repeat(K+2)).join("┴")+"┘",Y=(K,U)=>{let z=tJ(K),B=U-z;return K+" ".repeat(Math.max(0,B))},G=(K)=>"│"+K.map((U,z)=>` ${Y(U||"",J[z])} `).join("│")+"│";console.log(b.default.dim(Z)),console.log(b.default.bold(G($))),console.log(b.default.dim(H)),q.forEach((K)=>console.log(G(K))),console.log(b.default.dim(Q))}function oJ($){if($.length===0){console.log(b.default.dim("No devices found"));return}let q=["Port","Type","Chip","ESP"],J=$.map((H)=>{let Q=ez(H.connectionType),Y=H.espChip||(H.connectionType==="native-usb"?"?":"-");return[H.port,Q,H.chip||"-",Y]});sz(q,J);let X=$.some((H)=>H.connectionType==="native-usb"),Z=$.some((H)=>H.connectionType==="uart-bridge");if(X&&Z)console.log(""),console.log(b.default.dim(" Hint: Multiple ports from same board")),console.log(b.default.dim(" • ")+b.default.cyan("UART")+b.default.dim(" - Reliable flashing & monitoring")),console.log(b.default.dim(" • ")+b.default.magenta("USB")+b.default.dim(" - JTAG debugging"))}function ez($){switch($){case"native-usb":return b.default.magenta("USB");case"uart-bridge":return b.default.cyan("UART");default:return b.default.dim("?")}}async function rJ(){V.info("Scanning for devices...");let $=await P1();if(!$.ok)V.error($.error),process.exit(1);V.newline(),oJ($.data),V.newline()}async function s$($,q){let J=q||j(),{projectDir:X,target:Z,clean:H}=$;if(!await I1(X))return R.emit(J,{type:"error",message:"Not an ESP-IDF project directory"}),{ok:!1,error:"Not an ESP-IDF project directory"};if(Z){R.emit(J,{type:"progress",message:`Setting target to ${Z}...`});let G=await X1("idf.py",["set-target",Z],{cwd:X,operationId:J});if(!G.ok||G.data.exitCode!==0)return R.emit(J,{type:"error",message:"Failed to set target"}),{ok:!1,error:"Failed to set target"}}if(H)R.emit(J,{type:"progress",message:"Cleaning..."}),await X1("idf.py",["clean"],{cwd:X,operationId:J});R.emit(J,{type:"progress",message:"Building project..."});let Y=await X1("idf.py",["build"],{cwd:X,operationId:J});if(!Y.ok)return R.emit(J,{type:"error",message:Y.error}),{ok:!1,error:Y.error};if(Y.data.exitCode!==0)return R.emit(J,{type:"error",message:"Build failed"}),{ok:!1,error:"Build failed"};return R.emit(J,{type:"complete",result:{success:!0,projectDir:X}}),{ok:!0,data:{success:!0,projectDir:X}}}async function sJ($){let q=await J1(process.cwd());if(!q)V.error("Not in an ESP-IDF project directory"),process.exit(1);let J=j();R.subscribe(J,(Z)=>{if(Z.data.type==="stdout")V.output(Z.data.text);else if(Z.data.type==="stderr")V.output(Z.data.text)}),V.step("Building project...");let X=await s$({projectDir:q,target:$.target,clean:$.clean},J);if(!X.ok)V.newline(),V.error(X.error),process.exit(1);V.newline(),V.success("Build complete")}async function e$($,q){let J=q||j(),{projectDir:X,port:Z,baud:H=O1}=$;if(!await I1(X))return R.emit(J,{type:"error",message:"Not an ESP-IDF project directory"}),{ok:!1,error:"Not an ESP-IDF project directory"};R.emit(J,{type:"progress",message:`Flashing to ${Z}...`});let Y=["-p",Z,"-b",String(H),"flash"],G=await X1("idf.py",Y,{cwd:X,operationId:J});if(!G.ok)return R.emit(J,{type:"error",message:G.error}),{ok:!1,error:G.error};if(G.data.exitCode!==0)return R.emit(J,{type:"error",message:"Flash failed"}),{ok:!1,error:"Flash failed"};return R.emit(J,{type:"complete",result:{success:!0,port:Z}}),{ok:!0,data:{success:!0,port:Z}}}import{readFile as $B,writeFile as qB,access as JB}from"fs/promises";import{join as eJ}from"path";var $X="espcli.json";async function y1($){let q=eJ($,$X);try{await JB(q);let J=await $B(q,"utf-8");return JSON.parse(J)}catch{return{}}}async function XB($,q){let J=eJ($,$X);try{let X=JSON.stringify(q,null,2)+`
|
|
210
|
+
`;return await qB(J,X,"utf-8"),{ok:!0,data:void 0}}catch(X){return{ok:!1,error:`Failed to save config: ${X}`}}}async function r1($,q){let X={...await y1($),...q},Z=await XB($,X);if(!Z.ok)return Z;return{ok:!0,data:X}}async function qX($){let q=await J1(process.cwd());if(!q)V.error("Not in an ESP-IDF project directory"),process.exit(1);let J=await y1(q),X=await P1();if(!X.ok)V.error(X.error),process.exit(1);let Z=$.port||J.port,H=Z?Z1(X.data,Z):void 0;if(!Z||!H)Z=await z1(X.data),H=Z1(X.data,Z);if(H){let K=p$(H);if(!K.ok&&K.warning){if(V.warn(K.warning),!await g("Continue with this port?",!1))Z=await z1(X.data),H=Z1(X.data,Z)}}let Q=$.baud||J.flashBaud||O1;if(!$.baud&&!J.flashBaud)Q=await l$("flash",Q);if(Z!==J.port||Q!==J.flashBaud){if(await g("Save port and baud rate to project config?",!0))await r1(q,{port:Z,flashBaud:Q}),V.dim("Settings saved to espcli.json")}let Y=j();R.subscribe(Y,(K)=>{if(K.data.type==="stdout"||K.data.type==="stderr")V.output(K.data.text)}),V.step(`Flashing to ${Z} at ${Q} baud...`);let G=await e$({projectDir:q,port:Z,baud:Q},Y);if(!G.ok)V.newline(),V.error(G.error),process.exit(1);V.newline(),V.success("Flash complete")}var G3=new Map;async function $2($,q){let J=q||j(),{port:X,baud:Z=N1,projectDir:H}=$,Q=["-p",X,"-b",String(Z),"monitor"],Y=await tq("idf.py",Q,{cwd:H||process.cwd(),operationId:J,interactive:!0});if(!Y)return R.emit(J,{type:"error",message:"ESP-IDF not found"}),{ok:!1,error:"ESP-IDF not found"};let{proc:G,promise:K}=Y;return G3.set(J,G),K.then(()=>{G3.delete(J),R.emit(J,{type:"complete",result:{stopped:!0}})}),{ok:!0,data:{operationId:J,stop:()=>{G.kill("SIGTERM"),G3.delete(J)},wait:()=>K}}}async function JX($){let q=await J1(process.cwd());if(!q)V.error("Not an ESP-IDF project directory"),V.dim('Run this command from within an ESP-IDF project, or use "espcli init" to create one'),process.exit(1);let J=await y1(q),X=await P1();if(!X.ok)V.error(X.error),process.exit(1);let Z=$.port||J.port,H=Z?Z1(X.data,Z):void 0;if(!Z||!H)Z=await z1(X.data),H=Z1(X.data,Z);if(H){let G=vJ(H);if(!G.ok&&G.warning){if(V.warn(G.warning),!await g("Continue with this port?",!1))Z=await z1(X.data)}}let Q=$.baud||J.monitorBaud||N1;if(!$.baud&&!J.monitorBaud)Q=await l$("monitor",Q);if(Z!==J.port||Q!==J.monitorBaud){if(await g("Save port and baud rate to project config?",!0))await r1(q,{port:Z,monitorBaud:Q}),V.dim("Settings saved to espcli.json")}V.step(`Connecting to ${Z} at ${Q} baud...`),V.dim("Press Ctrl+] to exit"),V.newline();let Y=await $2({port:Z,baud:Q,projectDir:q});if(!Y.ok)V.error(Y.error),process.exit(1);await Y.data.wait(),V.newline(),V.info("Monitor stopped"),process.exit(0)}async function XX($,q){let J=q||j(),{projectDir:X,full:Z}=$;if(!await I1(X))return R.emit(J,{type:"error",message:"Not an ESP-IDF project directory"}),{ok:!1,error:"Not an ESP-IDF project directory"};let Q=Z?"fullclean":"clean";R.emit(J,{type:"progress",message:`Running ${Q}...`});let Y=await X1("idf.py",[Q],{cwd:X,operationId:J});if(!Y.ok)return R.emit(J,{type:"error",message:Y.error}),{ok:!1,error:Y.error};if(Y.data.exitCode!==0){let G=`${Q} failed`;return R.emit(J,{type:"error",message:G}),{ok:!1,error:G}}return R.emit(J,{type:"complete",result:null}),{ok:!0,data:void 0}}async function ZX($){let q=await J1(process.cwd());if(!q)V.error("Not in an ESP-IDF project directory"),process.exit(1);let J=j();V.step($.full?"Running fullclean...":"Cleaning build...");let X=await XX({projectDir:q,full:$.full},J);if(!X.ok)V.error(X.error),process.exit(1);V.success("Clean complete")}async function QX($){let q=await J1(process.cwd());if(!q)V.error("Not in an ESP-IDF project directory"),process.exit(1);let J=await y1(q),X=await P1();if(!X.ok)V.error(X.error),process.exit(1);let Z=$.port||J.port,H=Z?Z1(X.data,Z):void 0;if(!Z||!H)Z=await z1(X.data),H=Z1(X.data,Z);if(H){let B=p$(H);if(!B.ok&&B.warning){if(V.warn(B.warning),!await g("Continue with this port?",!1))Z=await z1(X.data)}}let Q=$.baud||J.flashBaud||O1,Y=J.monitorBaud||N1;if(Z!==J.port||Q!==J.flashBaud){if(await g("Save port and baud rate to project config?",!0))await r1(q,{port:Z,flashBaud:Q,monitorBaud:Y}),V.dim("Settings saved to espcli.json")}let G=(B)=>{if(B.data.type==="stdout"||B.data.type==="stderr")V.output(B.data.text)};if(!$.skipBuild){let B=j();R.subscribe(B,G),V.step("Building...");let L=await s$({projectDir:q},B);if(!L.ok)V.newline(),V.error(L.error),process.exit(1);V.newline(),V.success("Build complete")}let K=j();R.subscribe(K,G),V.step(`Flashing to ${Z} at ${Q} baud...`);let U=await e$({projectDir:q,port:Z,baud:Q},K);if(!U.ok)V.newline(),V.error(U.error),process.exit(1);V.newline(),V.success("Flash complete"),V.step(`Starting monitor at ${Y} baud...`),V.dim("Press Ctrl+] to exit"),V.newline();let z=await $2({port:Z,baud:Y,projectDir:q});if(!z.ok)V.error(z.error),process.exit(1);await z.data.wait(),V.newline(),V.info("Monitor stopped")}var h=o(A1(),1);async function HX(){V.info("Checking system health..."),V.newline();let $=await Y3();if(P0($.python),P0($.git),P0($.idf),P0($.pyserial),P0($.esptool),V.newline(),await ZB(),V.newline(),$.python.ok&&$.git.ok&&$.idf.ok&&$.pyserial.ok&&$.esptool.ok)console.log(h.default.green("✓ All checks passed! Ready for ESP32 development."));else console.log(h.default.yellow("⚠ Some checks failed. See hints above to fix issues."));V.newline()}function P0($){let q=$.ok?h.default.green("✓"):h.default.red("✗"),J=$.name.padEnd(10),X=$.version?h.default.dim(`v${$.version}`):"",Z=$.path?h.default.dim(` (${$.path})`):"";if($.ok)console.log(` ${q} ${h.default.bold(J)} ${X}${Z}`);else if(console.log(` ${q} ${h.default.bold(J)} ${h.default.red($.error||"Not found")}`),$.hint)console.log(` ${h.default.dim("→")} ${h.default.yellow($.hint)}`)}async function ZB(){console.log(h.default.bold(" Devices:"));try{let $=await r$();if($.length===0)console.log(` ${h.default.dim("No ESP devices connected")}`);else for(let q of $){let J=q.espChip||q.chip||"Unknown",X=q.connectionType==="native-usb"?"USB":"UART";console.log(` ${h.default.green("•")} ${q.port} ${h.default.dim(`(${J} via ${X})`)}`)}}catch{console.log(` ${h.default.dim("Could not check devices")}`)}}function YX(){let $=new I3;return $.name("espcli").description("CLI tool for ESP-IDF development").version(h3),$.command("install").description("Install ESP-IDF framework").option("-p, --path <path>","Installation path").option("-t, --target <target>","Target chip (default: all)").option("-y, --yes","Skip confirmation prompts").action(hJ),$.command("init [name]").description("Create a new ESP-IDF project").option("-l, --lang <lang>","Language: c or cpp").option("-t, --target <target>","Target chip").action(iJ),$.command("devices").alias("ports").description("List connected ESP devices").action(rJ),$.command("build").description("Build the current project").option("-t, --target <target>","Set target before build").option("-c, --clean","Clean before build").action(sJ),$.command("flash").description("Flash firmware to device").option("-p, --port <port>","Serial port").option("-b, --baud <baud>","Flash baud rate",parseInt).action(qX),$.command("monitor").description("Open serial monitor").option("-p, --port <port>","Serial port").option("-b, --baud <baud>","Monitor baud rate",parseInt).action(JX),$.command("run").description("Build, flash, and monitor").option("-p, --port <port>","Serial port").option("-b, --baud <baud>","Baud rate",parseInt).option("--skip-build","Skip build step").action(QX),$.command("clean").description("Clean build artifacts").option("-f, --full","Full clean (includes sdkconfig)").action(ZX),$.command("doctor").alias("check").description("Check system health and dependencies").action(HX),$}var QB=YX();QB.parse();
|