@abruncloud/cli 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/abrun.js +22 -22
  2. package/package.json +1 -1
package/dist/abrun.js CHANGED
@@ -1,8 +1,8 @@
1
- import{createRequire as JJ}from"node:module";var AJ=Object.create;var{getPrototypeOf:$J,defineProperty:c6,getOwnPropertyNames:fJ}=Object;var PJ=Object.prototype.hasOwnProperty;function BJ(D){return this[D]}var GJ,zJ,B0=(D,R,A)=>{var $=D!=null&&typeof D==="object";if($){var f=R?GJ??=new WeakMap:zJ??=new WeakMap,P=f.get(D);if(P)return P}A=D!=null?AJ($J(D)):{};let B=R||!D||!D.__esModule?c6(A,"default",{value:D,enumerable:!0}):A;for(let G of fJ(D))if(!PJ.call(B,G))c6(B,G,{get:BJ.bind(D,G),enumerable:!0});if($)f.set(D,B);return B};var q=(D,R)=>()=>(R||D((R={exports:{}}).exports,R),R.exports);var p=JJ(import.meta.url);var XR=q((HJ)=>{class t2 extends Error{constructor(D,R,A){super(A);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=R,this.exitCode=D,this.nestedError=void 0}}class t6 extends t2{constructor(D){super(1,"commander.invalidArgument",D);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}HJ.CommanderError=t2;HJ.InvalidArgumentError=t6});var uA=q((TJ)=>{var{InvalidArgumentError:XJ}=XR();class e6{constructor(D,R){switch(this.description=R||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,D[0]){case"<":this.required=!0,this._name=D.slice(1,-1);break;case"[":this.required=!1,this._name=D.slice(1,-1);break;default:this.required=!0,this._name=D;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(D,R){if(R===this.defaultValue||!Array.isArray(R))return[D];return R.push(D),R}default(D,R){return this.defaultValue=D,this.defaultValueDescription=R,this}argParser(D){return this.parseArg=D,this}choices(D){return this.argChoices=D.slice(),this.parseArg=(R,A)=>{if(!this.argChoices.includes(R))throw new XJ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(R,A);return R},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function QJ(D){let R=D.name()+(D.variadic===!0?"...":"");return D.required?"<"+R+">":"["+R+"]"}TJ.Argument=e6;TJ.humanReadableArgName=QJ});var e2=q((UJ)=>{var{humanReadableArgName:_J}=uA();class D4{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(D){this.helpWidth=this.helpWidth??D.helpWidth??80}visibleCommands(D){let R=D.commands.filter(($)=>!$._hidden),A=D._getHelpCommand();if(A&&!A._hidden)R.push(A);if(this.sortSubcommands)R.sort(($,f)=>{return $.name().localeCompare(f.name())});return R}compareOptions(D,R){let A=($)=>{return $.short?$.short.replace(/^-/,""):$.long.replace(/^--/,"")};return A(D).localeCompare(A(R))}visibleOptions(D){let R=D.options.filter(($)=>!$.hidden),A=D._getHelpOption();if(A&&!A.hidden){let $=A.short&&D._findOption(A.short),f=A.long&&D._findOption(A.long);if(!$&&!f)R.push(A);else if(A.long&&!f)R.push(D.createOption(A.long,A.description));else if(A.short&&!$)R.push(D.createOption(A.short,A.description))}if(this.sortOptions)R.sort(this.compareOptions);return R}visibleGlobalOptions(D){if(!this.showGlobalOptions)return[];let R=[];for(let A=D.parent;A;A=A.parent){let $=A.options.filter((f)=>!f.hidden);R.push(...$)}if(this.sortOptions)R.sort(this.compareOptions);return R}visibleArguments(D){if(D._argsDescription)D.registeredArguments.forEach((R)=>{R.description=R.description||D._argsDescription[R.name()]||""});if(D.registeredArguments.find((R)=>R.description))return D.registeredArguments;return[]}subcommandTerm(D){let R=D.registeredArguments.map((A)=>_J(A)).join(" ");return D._name+(D._aliases[0]?"|"+D._aliases[0]:"")+(D.options.length?" [options]":"")+(R?" "+R:"")}optionTerm(D){return D.flags}argumentTerm(D){return D.name()}longestSubcommandTermLength(D,R){return R.visibleCommands(D).reduce((A,$)=>{return Math.max(A,this.displayWidth(R.styleSubcommandTerm(R.subcommandTerm($))))},0)}longestOptionTermLength(D,R){return R.visibleOptions(D).reduce((A,$)=>{return Math.max(A,this.displayWidth(R.styleOptionTerm(R.optionTerm($))))},0)}longestGlobalOptionTermLength(D,R){return R.visibleGlobalOptions(D).reduce((A,$)=>{return Math.max(A,this.displayWidth(R.styleOptionTerm(R.optionTerm($))))},0)}longestArgumentTermLength(D,R){return R.visibleArguments(D).reduce((A,$)=>{return Math.max(A,this.displayWidth(R.styleArgumentTerm(R.argumentTerm($))))},0)}commandUsage(D){let R=D._name;if(D._aliases[0])R=R+"|"+D._aliases[0];let A="";for(let $=D.parent;$;$=$.parent)A=$.name()+" "+A;return A+R+" "+D.usage()}commandDescription(D){return D.description()}subcommandDescription(D){return D.summary()||D.description()}optionDescription(D){let R=[];if(D.argChoices)R.push(`choices: ${D.argChoices.map((A)=>JSON.stringify(A)).join(", ")}`);if(D.defaultValue!==void 0){if(D.required||D.optional||D.isBoolean()&&typeof D.defaultValue==="boolean")R.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`)}if(D.presetArg!==void 0&&D.optional)R.push(`preset: ${JSON.stringify(D.presetArg)}`);if(D.envVar!==void 0)R.push(`env: ${D.envVar}`);if(R.length>0){let A=`(${R.join(", ")})`;if(D.description)return`${D.description} ${A}`;return A}return D.description}argumentDescription(D){let R=[];if(D.argChoices)R.push(`choices: ${D.argChoices.map((A)=>JSON.stringify(A)).join(", ")}`);if(D.defaultValue!==void 0)R.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`);if(R.length>0){let A=`(${R.join(", ")})`;if(D.description)return`${D.description} ${A}`;return A}return D.description}formatItemList(D,R,A){if(R.length===0)return[];return[A.styleTitle(D),...R,""]}groupItems(D,R,A){let $=new Map;return D.forEach((f)=>{let P=A(f);if(!$.has(P))$.set(P,[])}),R.forEach((f)=>{let P=A(f);if(!$.has(P))$.set(P,[]);$.get(P).push(f)}),$}formatHelp(D,R){let A=R.padWidth(D,R),$=R.helpWidth??80;function f(Z,H){return R.formatItem(Z,A,H,R)}let P=[`${R.styleTitle("Usage:")} ${R.styleUsage(R.commandUsage(D))}`,""],B=R.commandDescription(D);if(B.length>0)P=P.concat([R.boxWrap(R.styleCommandDescription(B),$),""]);let G=R.visibleArguments(D).map((Z)=>{return f(R.styleArgumentTerm(R.argumentTerm(Z)),R.styleArgumentDescription(R.argumentDescription(Z)))});if(P=P.concat(this.formatItemList("Arguments:",G,R)),this.groupItems(D.options,R.visibleOptions(D),(Z)=>Z.helpGroupHeading??"Options:").forEach((Z,H)=>{let M=Z.map((Q)=>{return f(R.styleOptionTerm(R.optionTerm(Q)),R.styleOptionDescription(R.optionDescription(Q)))});P=P.concat(this.formatItemList(H,M,R))}),R.showGlobalOptions){let Z=R.visibleGlobalOptions(D).map((H)=>{return f(R.styleOptionTerm(R.optionTerm(H)),R.styleOptionDescription(R.optionDescription(H)))});P=P.concat(this.formatItemList("Global Options:",Z,R))}return this.groupItems(D.commands,R.visibleCommands(D),(Z)=>Z.helpGroup()||"Commands:").forEach((Z,H)=>{let M=Z.map((Q)=>{return f(R.styleSubcommandTerm(R.subcommandTerm(Q)),R.styleSubcommandDescription(R.subcommandDescription(Q)))});P=P.concat(this.formatItemList(H,M,R))}),P.join(`
1
+ import{createRequire as JJ}from"node:module";var AJ=Object.create;var{getPrototypeOf:$J,defineProperty:c6,getOwnPropertyNames:fJ}=Object;var PJ=Object.prototype.hasOwnProperty;function BJ(D){return this[D]}var GJ,zJ,B0=(D,R,A)=>{var $=D!=null&&typeof D==="object";if($){var f=R?GJ??=new WeakMap:zJ??=new WeakMap,P=f.get(D);if(P)return P}A=D!=null?AJ($J(D)):{};let B=R||!D||!D.__esModule?c6(A,"default",{value:D,enumerable:!0}):A;for(let G of fJ(D))if(!PJ.call(B,G))c6(B,G,{get:BJ.bind(D,G),enumerable:!0});if($)f.set(D,B);return B};var q=(D,R)=>()=>(R||D((R={exports:{}}).exports,R),R.exports);var p=JJ(import.meta.url);var XR=q((HJ)=>{class ef extends Error{constructor(D,R,A){super(A);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=R,this.exitCode=D,this.nestedError=void 0}}class t6 extends ef{constructor(D){super(1,"commander.invalidArgument",D);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}HJ.CommanderError=ef;HJ.InvalidArgumentError=t6});var uA=q((TJ)=>{var{InvalidArgumentError:XJ}=XR();class e6{constructor(D,R){switch(this.description=R||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,D[0]){case"<":this.required=!0,this._name=D.slice(1,-1);break;case"[":this.required=!1,this._name=D.slice(1,-1);break;default:this.required=!0,this._name=D;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(D,R){if(R===this.defaultValue||!Array.isArray(R))return[D];return R.push(D),R}default(D,R){return this.defaultValue=D,this.defaultValueDescription=R,this}argParser(D){return this.parseArg=D,this}choices(D){return this.argChoices=D.slice(),this.parseArg=(R,A)=>{if(!this.argChoices.includes(R))throw new XJ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(R,A);return R},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function QJ(D){let R=D.name()+(D.variadic===!0?"...":"");return D.required?"<"+R+">":"["+R+"]"}TJ.Argument=e6;TJ.humanReadableArgName=QJ});var D2=q((UJ)=>{var{humanReadableArgName:_J}=uA();class D4{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(D){this.helpWidth=this.helpWidth??D.helpWidth??80}visibleCommands(D){let R=D.commands.filter(($)=>!$._hidden),A=D._getHelpCommand();if(A&&!A._hidden)R.push(A);if(this.sortSubcommands)R.sort(($,f)=>{return $.name().localeCompare(f.name())});return R}compareOptions(D,R){let A=($)=>{return $.short?$.short.replace(/^-/,""):$.long.replace(/^--/,"")};return A(D).localeCompare(A(R))}visibleOptions(D){let R=D.options.filter(($)=>!$.hidden),A=D._getHelpOption();if(A&&!A.hidden){let $=A.short&&D._findOption(A.short),f=A.long&&D._findOption(A.long);if(!$&&!f)R.push(A);else if(A.long&&!f)R.push(D.createOption(A.long,A.description));else if(A.short&&!$)R.push(D.createOption(A.short,A.description))}if(this.sortOptions)R.sort(this.compareOptions);return R}visibleGlobalOptions(D){if(!this.showGlobalOptions)return[];let R=[];for(let A=D.parent;A;A=A.parent){let $=A.options.filter((f)=>!f.hidden);R.push(...$)}if(this.sortOptions)R.sort(this.compareOptions);return R}visibleArguments(D){if(D._argsDescription)D.registeredArguments.forEach((R)=>{R.description=R.description||D._argsDescription[R.name()]||""});if(D.registeredArguments.find((R)=>R.description))return D.registeredArguments;return[]}subcommandTerm(D){let R=D.registeredArguments.map((A)=>_J(A)).join(" ");return D._name+(D._aliases[0]?"|"+D._aliases[0]:"")+(D.options.length?" [options]":"")+(R?" "+R:"")}optionTerm(D){return D.flags}argumentTerm(D){return D.name()}longestSubcommandTermLength(D,R){return R.visibleCommands(D).reduce((A,$)=>{return Math.max(A,this.displayWidth(R.styleSubcommandTerm(R.subcommandTerm($))))},0)}longestOptionTermLength(D,R){return R.visibleOptions(D).reduce((A,$)=>{return Math.max(A,this.displayWidth(R.styleOptionTerm(R.optionTerm($))))},0)}longestGlobalOptionTermLength(D,R){return R.visibleGlobalOptions(D).reduce((A,$)=>{return Math.max(A,this.displayWidth(R.styleOptionTerm(R.optionTerm($))))},0)}longestArgumentTermLength(D,R){return R.visibleArguments(D).reduce((A,$)=>{return Math.max(A,this.displayWidth(R.styleArgumentTerm(R.argumentTerm($))))},0)}commandUsage(D){let R=D._name;if(D._aliases[0])R=R+"|"+D._aliases[0];let A="";for(let $=D.parent;$;$=$.parent)A=$.name()+" "+A;return A+R+" "+D.usage()}commandDescription(D){return D.description()}subcommandDescription(D){return D.summary()||D.description()}optionDescription(D){let R=[];if(D.argChoices)R.push(`choices: ${D.argChoices.map((A)=>JSON.stringify(A)).join(", ")}`);if(D.defaultValue!==void 0){if(D.required||D.optional||D.isBoolean()&&typeof D.defaultValue==="boolean")R.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`)}if(D.presetArg!==void 0&&D.optional)R.push(`preset: ${JSON.stringify(D.presetArg)}`);if(D.envVar!==void 0)R.push(`env: ${D.envVar}`);if(R.length>0){let A=`(${R.join(", ")})`;if(D.description)return`${D.description} ${A}`;return A}return D.description}argumentDescription(D){let R=[];if(D.argChoices)R.push(`choices: ${D.argChoices.map((A)=>JSON.stringify(A)).join(", ")}`);if(D.defaultValue!==void 0)R.push(`default: ${D.defaultValueDescription||JSON.stringify(D.defaultValue)}`);if(R.length>0){let A=`(${R.join(", ")})`;if(D.description)return`${D.description} ${A}`;return A}return D.description}formatItemList(D,R,A){if(R.length===0)return[];return[A.styleTitle(D),...R,""]}groupItems(D,R,A){let $=new Map;return D.forEach((f)=>{let P=A(f);if(!$.has(P))$.set(P,[])}),R.forEach((f)=>{let P=A(f);if(!$.has(P))$.set(P,[]);$.get(P).push(f)}),$}formatHelp(D,R){let A=R.padWidth(D,R),$=R.helpWidth??80;function f(Z,H){return R.formatItem(Z,A,H,R)}let P=[`${R.styleTitle("Usage:")} ${R.styleUsage(R.commandUsage(D))}`,""],B=R.commandDescription(D);if(B.length>0)P=P.concat([R.boxWrap(R.styleCommandDescription(B),$),""]);let G=R.visibleArguments(D).map((Z)=>{return f(R.styleArgumentTerm(R.argumentTerm(Z)),R.styleArgumentDescription(R.argumentDescription(Z)))});if(P=P.concat(this.formatItemList("Arguments:",G,R)),this.groupItems(D.options,R.visibleOptions(D),(Z)=>Z.helpGroupHeading??"Options:").forEach((Z,H)=>{let M=Z.map((Q)=>{return f(R.styleOptionTerm(R.optionTerm(Q)),R.styleOptionDescription(R.optionDescription(Q)))});P=P.concat(this.formatItemList(H,M,R))}),R.showGlobalOptions){let Z=R.visibleGlobalOptions(D).map((H)=>{return f(R.styleOptionTerm(R.optionTerm(H)),R.styleOptionDescription(R.optionDescription(H)))});P=P.concat(this.formatItemList("Global Options:",Z,R))}return this.groupItems(D.commands,R.visibleCommands(D),(Z)=>Z.helpGroup()||"Commands:").forEach((Z,H)=>{let M=Z.map((Q)=>{return f(R.styleSubcommandTerm(R.subcommandTerm(Q)),R.styleSubcommandDescription(R.subcommandDescription(Q)))});P=P.concat(this.formatItemList(H,M,R))}),P.join(`
2
2
  `)}displayWidth(D){return R4(D).length}styleTitle(D){return D}styleUsage(D){return D.split(" ").map((R)=>{if(R==="[options]")return this.styleOptionText(R);if(R==="[command]")return this.styleSubcommandText(R);if(R[0]==="["||R[0]==="<")return this.styleArgumentText(R);return this.styleCommandText(R)}).join(" ")}styleCommandDescription(D){return this.styleDescriptionText(D)}styleOptionDescription(D){return this.styleDescriptionText(D)}styleSubcommandDescription(D){return this.styleDescriptionText(D)}styleArgumentDescription(D){return this.styleDescriptionText(D)}styleDescriptionText(D){return D}styleOptionTerm(D){return this.styleOptionText(D)}styleSubcommandTerm(D){return D.split(" ").map((R)=>{if(R==="[options]")return this.styleOptionText(R);if(R[0]==="["||R[0]==="<")return this.styleArgumentText(R);return this.styleSubcommandText(R)}).join(" ")}styleArgumentTerm(D){return this.styleArgumentText(D)}styleOptionText(D){return D}styleArgumentText(D){return D}styleSubcommandText(D){return D}styleCommandText(D){return D}padWidth(D,R){return Math.max(R.longestOptionTermLength(D,R),R.longestGlobalOptionTermLength(D,R),R.longestSubcommandTermLength(D,R),R.longestArgumentTermLength(D,R))}preformatted(D){return/\n[^\S\r\n]/.test(D)}formatItem(D,R,A,$){let P=" ".repeat(2);if(!A)return P+D;let B=D.padEnd(R+D.length-$.displayWidth(D)),G=2,J=(this.helpWidth??80)-R-G-2,Z;if(J<this.minWidthToWrap||$.preformatted(A))Z=A;else Z=$.boxWrap(A,J).replace(/\n/g,`
3
3
  `+" ".repeat(R+G));return P+B+" ".repeat(G)+Z.replace(/\n/g,`
4
4
  ${P}`)}boxWrap(D,R){if(R<this.minWidthToWrap)return D;let A=D.split(/\r\n|\n/),$=/[\s]*[^\s]+/g,f=[];return A.forEach((P)=>{let B=P.match($);if(B===null){f.push("");return}let G=[B.shift()],z=this.displayWidth(G[0]);B.forEach((J)=>{let Z=this.displayWidth(J);if(z+Z<=R){G.push(J),z+=Z;return}f.push(G.join(""));let H=J.trimStart();G=[H],z=this.displayWidth(H)}),f.push(G.join(""))}),f.join(`
5
- `)}}function R4(D){let R=/\x1b\[\d*(;\d*)*m/g;return D.replace(R,"")}UJ.Help=D4;UJ.stripColor=R4});var Df=q((LJ)=>{var{InvalidArgumentError:wJ}=XR();class $4{constructor(D,R){this.flags=D,this.description=R||"",this.required=D.includes("<"),this.optional=D.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(D),this.mandatory=!1;let A=CJ(D);if(this.short=A.shortFlag,this.long=A.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(D,R){return this.defaultValue=D,this.defaultValueDescription=R,this}preset(D){return this.presetArg=D,this}conflicts(D){return this.conflictsWith=this.conflictsWith.concat(D),this}implies(D){let R=D;if(typeof D==="string")R={[D]:!0};return this.implied=Object.assign(this.implied||{},R),this}env(D){return this.envVar=D,this}argParser(D){return this.parseArg=D,this}makeOptionMandatory(D=!0){return this.mandatory=!!D,this}hideHelp(D=!0){return this.hidden=!!D,this}_collectValue(D,R){if(R===this.defaultValue||!Array.isArray(R))return[D];return R.push(D),R}choices(D){return this.argChoices=D.slice(),this.parseArg=(R,A)=>{if(!this.argChoices.includes(R))throw new wJ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(R,A);return R},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return A4(this.name().replace(/^no-/,""));return A4(this.name())}helpGroup(D){return this.helpGroupHeading=D,this}is(D){return this.short===D||this.long===D}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class f4{constructor(D){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,D.forEach((R)=>{if(R.negate)this.negativeOptions.set(R.attributeName(),R);else this.positiveOptions.set(R.attributeName(),R)}),this.negativeOptions.forEach((R,A)=>{if(this.positiveOptions.has(A))this.dualOptions.add(A)})}valueFromOption(D,R){let A=R.attributeName();if(!this.dualOptions.has(A))return!0;let $=this.negativeOptions.get(A).presetArg,f=$!==void 0?$:!1;return R.negate===(f===D)}}function A4(D){return D.split("-").reduce((R,A)=>{return R+A[0].toUpperCase()+A.slice(1)})}function CJ(D){let R,A,$=/^-[^-]$/,f=/^--[^-]/,P=D.split(/[ |,]+/).concat("guard");if($.test(P[0]))R=P.shift();if(f.test(P[0]))A=P.shift();if(!R&&$.test(P[0]))R=P.shift();if(!R&&f.test(P[0]))R=A,A=P.shift();if(P[0].startsWith("-")){let B=P[0],G=`option creation failed due to '${B}' in option flags '${D}'`;if(/^-[^-][^-]/.test(B))throw Error(`${G}
5
+ `)}}function R4(D){let R=/\x1b\[\d*(;\d*)*m/g;return D.replace(R,"")}UJ.Help=D4;UJ.stripColor=R4});var R2=q((LJ)=>{var{InvalidArgumentError:wJ}=XR();class $4{constructor(D,R){this.flags=D,this.description=R||"",this.required=D.includes("<"),this.optional=D.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(D),this.mandatory=!1;let A=CJ(D);if(this.short=A.shortFlag,this.long=A.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(D,R){return this.defaultValue=D,this.defaultValueDescription=R,this}preset(D){return this.presetArg=D,this}conflicts(D){return this.conflictsWith=this.conflictsWith.concat(D),this}implies(D){let R=D;if(typeof D==="string")R={[D]:!0};return this.implied=Object.assign(this.implied||{},R),this}env(D){return this.envVar=D,this}argParser(D){return this.parseArg=D,this}makeOptionMandatory(D=!0){return this.mandatory=!!D,this}hideHelp(D=!0){return this.hidden=!!D,this}_collectValue(D,R){if(R===this.defaultValue||!Array.isArray(R))return[D];return R.push(D),R}choices(D){return this.argChoices=D.slice(),this.parseArg=(R,A)=>{if(!this.argChoices.includes(R))throw new wJ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(R,A);return R},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return A4(this.name().replace(/^no-/,""));return A4(this.name())}helpGroup(D){return this.helpGroupHeading=D,this}is(D){return this.short===D||this.long===D}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class f4{constructor(D){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,D.forEach((R)=>{if(R.negate)this.negativeOptions.set(R.attributeName(),R);else this.positiveOptions.set(R.attributeName(),R)}),this.negativeOptions.forEach((R,A)=>{if(this.positiveOptions.has(A))this.dualOptions.add(A)})}valueFromOption(D,R){let A=R.attributeName();if(!this.dualOptions.has(A))return!0;let $=this.negativeOptions.get(A).presetArg,f=$!==void 0?$:!1;return R.negate===(f===D)}}function A4(D){return D.split("-").reduce((R,A)=>{return R+A[0].toUpperCase()+A.slice(1)})}function CJ(D){let R,A,$=/^-[^-]$/,f=/^--[^-]/,P=D.split(/[ |,]+/).concat("guard");if($.test(P[0]))R=P.shift();if(f.test(P[0]))A=P.shift();if(!R&&$.test(P[0]))R=P.shift();if(!R&&f.test(P[0]))R=A,A=P.shift();if(P[0].startsWith("-")){let B=P[0],G=`option creation failed due to '${B}' in option flags '${D}'`;if(/^-[^-][^-]/.test(B))throw Error(`${G}
6
6
  - a short flag is a single dash and a single character
7
7
  - either use a single dash and a single character (for a short flag)
8
8
  - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if($.test(B))throw Error(`${G}
@@ -10,20 +10,20 @@ ${P}`)}boxWrap(D,R){if(R<this.minWidthToWrap)return D;let A=D.split(/\r\n|\n/),$
10
10
  - too many long flags`);throw Error(`${G}
11
11
  - unrecognised flag format`)}if(R===void 0&&A===void 0)throw Error(`option creation failed due to no flags found in '${D}'.`);return{shortFlag:R,longFlag:A}}LJ.Option=$4;LJ.DualOptions=f4});var P4=q((WJ)=>{function IJ(D,R){if(Math.abs(D.length-R.length)>3)return Math.max(D.length,R.length);let A=[];for(let $=0;$<=D.length;$++)A[$]=[$];for(let $=0;$<=R.length;$++)A[0][$]=$;for(let $=1;$<=R.length;$++)for(let f=1;f<=D.length;f++){let P=1;if(D[f-1]===R[$-1])P=0;else P=1;if(A[f][$]=Math.min(A[f-1][$]+1,A[f][$-1]+1,A[f-1][$-1]+P),f>1&&$>1&&D[f-1]===R[$-2]&&D[f-2]===R[$-1])A[f][$]=Math.min(A[f][$],A[f-2][$-2]+1)}return A[D.length][R.length]}function KJ(D,R){if(!R||R.length===0)return"";R=Array.from(new Set(R));let A=D.startsWith("--");if(A)D=D.slice(2),R=R.map((B)=>B.slice(2));let $=[],f=3,P=0.4;if(R.forEach((B)=>{if(B.length<=1)return;let G=IJ(D,B),z=Math.max(D.length,B.length);if((z-G)/z>P){if(G<f)f=G,$=[B];else if(G===f)$.push(B)}}),$.sort((B,G)=>B.localeCompare(G)),A)$=$.map((B)=>`--${B}`);if($.length>1)return`
12
12
  (Did you mean one of ${$.join(", ")}?)`;if($.length===1)return`
13
- (Did you mean ${$[0]}?)`;return""}WJ.suggestSimilar=KJ});var J4=q((mJ)=>{var SJ=p("node:events").EventEmitter,Rf=p("node:child_process"),s0=p("node:path"),EA=p("node:fs"),h=p("node:process"),{Argument:bJ,humanReadableArgName:uJ}=uA(),{CommanderError:Af}=XR(),{Help:EJ,stripColor:yJ}=e2(),{Option:B4,DualOptions:gJ}=Df(),{suggestSimilar:G4}=P4();class ff extends SJ{constructor(D){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=D||"",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:(R)=>h.stdout.write(R),writeErr:(R)=>h.stderr.write(R),outputError:(R,A)=>A(R),getOutHelpWidth:()=>h.stdout.isTTY?h.stdout.columns:void 0,getErrHelpWidth:()=>h.stderr.isTTY?h.stderr.columns:void 0,getOutHasColors:()=>$f()??(h.stdout.isTTY&&h.stdout.hasColors?.()),getErrHasColors:()=>$f()??(h.stderr.isTTY&&h.stderr.hasColors?.()),stripColor:(R)=>yJ(R)},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(D){return this._outputConfiguration=D._outputConfiguration,this._helpOption=D._helpOption,this._helpCommand=D._helpCommand,this._helpConfiguration=D._helpConfiguration,this._exitCallback=D._exitCallback,this._storeOptionsAsProperties=D._storeOptionsAsProperties,this._combineFlagAndOptionalValue=D._combineFlagAndOptionalValue,this._allowExcessArguments=D._allowExcessArguments,this._enablePositionalOptions=D._enablePositionalOptions,this._showHelpAfterError=D._showHelpAfterError,this._showSuggestionAfterError=D._showSuggestionAfterError,this}_getCommandAndAncestors(){let D=[];for(let R=this;R;R=R.parent)D.push(R);return D}command(D,R,A){let $=R,f=A;if(typeof $==="object"&&$!==null)f=$,$=null;f=f||{};let[,P,B]=D.match(/([^ ]+) *(.*)/),G=this.createCommand(P);if($)G.description($),G._executableHandler=!0;if(f.isDefault)this._defaultCommandName=G._name;if(G._hidden=!!(f.noHelp||f.hidden),G._executableFile=f.executableFile||null,B)G.arguments(B);if(this._registerCommand(G),G.parent=this,G.copyInheritedSettings(this),$)return this;return G}createCommand(D){return new ff(D)}createHelp(){return Object.assign(new EJ,this.configureHelp())}configureHelp(D){if(D===void 0)return this._helpConfiguration;return this._helpConfiguration=D,this}configureOutput(D){if(D===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...D},this}showHelpAfterError(D=!0){if(typeof D!=="string")D=!!D;return this._showHelpAfterError=D,this}showSuggestionAfterError(D=!0){return this._showSuggestionAfterError=!!D,this}addCommand(D,R){if(!D._name)throw Error(`Command passed to .addCommand() must have a name
13
+ (Did you mean ${$[0]}?)`;return""}WJ.suggestSimilar=KJ});var J4=q((mJ)=>{var SJ=p("node:events").EventEmitter,A2=p("node:child_process"),s0=p("node:path"),EA=p("node:fs"),h=p("node:process"),{Argument:bJ,humanReadableArgName:uJ}=uA(),{CommanderError:$2}=XR(),{Help:EJ,stripColor:yJ}=D2(),{Option:B4,DualOptions:gJ}=R2(),{suggestSimilar:G4}=P4();class P2 extends SJ{constructor(D){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=D||"",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:(R)=>h.stdout.write(R),writeErr:(R)=>h.stderr.write(R),outputError:(R,A)=>A(R),getOutHelpWidth:()=>h.stdout.isTTY?h.stdout.columns:void 0,getErrHelpWidth:()=>h.stderr.isTTY?h.stderr.columns:void 0,getOutHasColors:()=>f2()??(h.stdout.isTTY&&h.stdout.hasColors?.()),getErrHasColors:()=>f2()??(h.stderr.isTTY&&h.stderr.hasColors?.()),stripColor:(R)=>yJ(R)},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(D){return this._outputConfiguration=D._outputConfiguration,this._helpOption=D._helpOption,this._helpCommand=D._helpCommand,this._helpConfiguration=D._helpConfiguration,this._exitCallback=D._exitCallback,this._storeOptionsAsProperties=D._storeOptionsAsProperties,this._combineFlagAndOptionalValue=D._combineFlagAndOptionalValue,this._allowExcessArguments=D._allowExcessArguments,this._enablePositionalOptions=D._enablePositionalOptions,this._showHelpAfterError=D._showHelpAfterError,this._showSuggestionAfterError=D._showSuggestionAfterError,this}_getCommandAndAncestors(){let D=[];for(let R=this;R;R=R.parent)D.push(R);return D}command(D,R,A){let $=R,f=A;if(typeof $==="object"&&$!==null)f=$,$=null;f=f||{};let[,P,B]=D.match(/([^ ]+) *(.*)/),G=this.createCommand(P);if($)G.description($),G._executableHandler=!0;if(f.isDefault)this._defaultCommandName=G._name;if(G._hidden=!!(f.noHelp||f.hidden),G._executableFile=f.executableFile||null,B)G.arguments(B);if(this._registerCommand(G),G.parent=this,G.copyInheritedSettings(this),$)return this;return G}createCommand(D){return new P2(D)}createHelp(){return Object.assign(new EJ,this.configureHelp())}configureHelp(D){if(D===void 0)return this._helpConfiguration;return this._helpConfiguration=D,this}configureOutput(D){if(D===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...D},this}showHelpAfterError(D=!0){if(typeof D!=="string")D=!!D;return this._showHelpAfterError=D,this}showSuggestionAfterError(D=!0){return this._showSuggestionAfterError=!!D,this}addCommand(D,R){if(!D._name)throw Error(`Command passed to .addCommand() must have a name
14
14
  - specify the name in Command constructor or using .name()`);if(R=R||{},R.isDefault)this._defaultCommandName=D._name;if(R.noHelp||R.hidden)D._hidden=!0;return this._registerCommand(D),D.parent=this,D._checkForBrokenPassThrough(),this}createArgument(D,R){return new bJ(D,R)}argument(D,R,A,$){let f=this.createArgument(D,R);if(typeof A==="function")f.default($).argParser(A);else f.default(A);return this.addArgument(f),this}arguments(D){return D.trim().split(/ +/).forEach((R)=>{this.argument(R)}),this}addArgument(D){let R=this.registeredArguments.slice(-1)[0];if(R?.variadic)throw Error(`only the last argument can be variadic '${R.name()}'`);if(D.required&&D.defaultValue!==void 0&&D.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${D.name()}'`);return this.registeredArguments.push(D),this}helpCommand(D,R){if(typeof D==="boolean"){if(this._addImplicitHelpCommand=D,D&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let A=D??"help [command]",[,$,f]=A.match(/([^ ]+) *(.*)/),P=R??"display help for command",B=this.createCommand($);if(B.helpOption(!1),f)B.arguments(f);if(P)B.description(P);if(this._addImplicitHelpCommand=!0,this._helpCommand=B,D||R)this._initCommandGroup(B);return this}addHelpCommand(D,R){if(typeof D!=="object")return this.helpCommand(D,R),this;return this._addImplicitHelpCommand=!0,this._helpCommand=D,this._initCommandGroup(D),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(D,R){let A=["preSubcommand","preAction","postAction"];if(!A.includes(D))throw Error(`Unexpected value for event passed to hook : '${D}'.
15
- Expecting one of '${A.join("', '")}'`);if(this._lifeCycleHooks[D])this._lifeCycleHooks[D].push(R);else this._lifeCycleHooks[D]=[R];return this}exitOverride(D){if(D)this._exitCallback=D;else this._exitCallback=(R)=>{if(R.code!=="commander.executeSubCommandAsync")throw R};return this}_exit(D,R,A){if(this._exitCallback)this._exitCallback(new Af(D,R,A));h.exit(D)}action(D){let R=(A)=>{let $=this.registeredArguments.length,f=A.slice(0,$);if(this._storeOptionsAsProperties)f[$]=this;else f[$]=this.opts();return f.push(this),D.apply(this,f)};return this._actionHandler=R,this}createOption(D,R){return new B4(D,R)}_callParseArg(D,R,A,$){try{return D.parseArg(R,A)}catch(f){if(f.code==="commander.invalidArgument"){let P=`${$} ${f.message}`;this.error(P,{exitCode:f.exitCode,code:f.code})}throw f}}_registerOption(D){let R=D.short&&this._findOption(D.short)||D.long&&this._findOption(D.long);if(R){let A=D.long&&this._findOption(D.long)?D.long:D.short;throw Error(`Cannot add option '${D.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${A}'
15
+ Expecting one of '${A.join("', '")}'`);if(this._lifeCycleHooks[D])this._lifeCycleHooks[D].push(R);else this._lifeCycleHooks[D]=[R];return this}exitOverride(D){if(D)this._exitCallback=D;else this._exitCallback=(R)=>{if(R.code!=="commander.executeSubCommandAsync")throw R};return this}_exit(D,R,A){if(this._exitCallback)this._exitCallback(new $2(D,R,A));h.exit(D)}action(D){let R=(A)=>{let $=this.registeredArguments.length,f=A.slice(0,$);if(this._storeOptionsAsProperties)f[$]=this;else f[$]=this.opts();return f.push(this),D.apply(this,f)};return this._actionHandler=R,this}createOption(D,R){return new B4(D,R)}_callParseArg(D,R,A,$){try{return D.parseArg(R,A)}catch(f){if(f.code==="commander.invalidArgument"){let P=`${$} ${f.message}`;this.error(P,{exitCode:f.exitCode,code:f.code})}throw f}}_registerOption(D){let R=D.short&&this._findOption(D.short)||D.long&&this._findOption(D.long);if(R){let A=D.long&&this._findOption(D.long)?D.long:D.short;throw Error(`Cannot add option '${D.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${A}'
16
16
  - already used by option '${R.flags}'`)}this._initOptionGroup(D),this.options.push(D)}_registerCommand(D){let R=($)=>{return[$.name()].concat($.aliases())},A=R(D).find(($)=>this._findCommand($));if(A){let $=R(this._findCommand(A)).join("|"),f=R(D).join("|");throw Error(`cannot add command '${f}' as already have command '${$}'`)}this._initCommandGroup(D),this.commands.push(D)}addOption(D){this._registerOption(D);let R=D.name(),A=D.attributeName();if(D.negate){let f=D.long.replace(/^--no-/,"--");if(!this._findOption(f))this.setOptionValueWithSource(A,D.defaultValue===void 0?!0:D.defaultValue,"default")}else if(D.defaultValue!==void 0)this.setOptionValueWithSource(A,D.defaultValue,"default");let $=(f,P,B)=>{if(f==null&&D.presetArg!==void 0)f=D.presetArg;let G=this.getOptionValue(A);if(f!==null&&D.parseArg)f=this._callParseArg(D,f,G,P);else if(f!==null&&D.variadic)f=D._collectValue(f,G);if(f==null)if(D.negate)f=!1;else if(D.isBoolean()||D.optional)f=!0;else f="";this.setOptionValueWithSource(A,f,B)};if(this.on("option:"+R,(f)=>{let P=`error: option '${D.flags}' argument '${f}' is invalid.`;$(f,P,"cli")}),D.envVar)this.on("optionEnv:"+R,(f)=>{let P=`error: option '${D.flags}' value '${f}' from env '${D.envVar}' is invalid.`;$(f,P,"env")});return this}_optionEx(D,R,A,$,f){if(typeof R==="object"&&R instanceof B4)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let P=this.createOption(R,A);if(P.makeOptionMandatory(!!D.mandatory),typeof $==="function")P.default(f).argParser($);else if($ instanceof RegExp){let B=$;$=(G,z)=>{let J=B.exec(G);return J?J[0]:z},P.default(f).argParser($)}else P.default($);return this.addOption(P)}option(D,R,A,$){return this._optionEx({},D,R,A,$)}requiredOption(D,R,A,$){return this._optionEx({mandatory:!0},D,R,A,$)}combineFlagAndOptionalValue(D=!0){return this._combineFlagAndOptionalValue=!!D,this}allowUnknownOption(D=!0){return this._allowUnknownOption=!!D,this}allowExcessArguments(D=!0){return this._allowExcessArguments=!!D,this}enablePositionalOptions(D=!0){return this._enablePositionalOptions=!!D,this}passThroughOptions(D=!0){return this._passThroughOptions=!!D,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(D=!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=!!D,this}getOptionValue(D){if(this._storeOptionsAsProperties)return this[D];return this._optionValues[D]}setOptionValue(D,R){return this.setOptionValueWithSource(D,R,void 0)}setOptionValueWithSource(D,R,A){if(this._storeOptionsAsProperties)this[D]=R;else this._optionValues[D]=R;return this._optionValueSources[D]=A,this}getOptionValueSource(D){return this._optionValueSources[D]}getOptionValueSourceWithGlobals(D){let R;return this._getCommandAndAncestors().forEach((A)=>{if(A.getOptionValueSource(D)!==void 0)R=A.getOptionValueSource(D)}),R}_prepareUserArgs(D,R){if(D!==void 0&&!Array.isArray(D))throw Error("first parameter to parse must be array or undefined");if(R=R||{},D===void 0&&R.from===void 0){if(h.versions?.electron)R.from="electron";let $=h.execArgv??[];if($.includes("-e")||$.includes("--eval")||$.includes("-p")||$.includes("--print"))R.from="eval"}if(D===void 0)D=h.argv;this.rawArgs=D.slice();let A;switch(R.from){case void 0:case"node":this._scriptPath=D[1],A=D.slice(2);break;case"electron":if(h.defaultApp)this._scriptPath=D[1],A=D.slice(2);else A=D.slice(1);break;case"user":A=D.slice(0);break;case"eval":A=D.slice(1);break;default:throw Error(`unexpected parse option { from: '${R.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",A}parse(D,R){this._prepareForParse();let A=this._prepareUserArgs(D,R);return this._parseCommand([],A),this}async parseAsync(D,R){this._prepareForParse();let A=this._prepareUserArgs(D,R);return await this._parseCommand([],A),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.
17
17
  - 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(D,R,A){if(EA.existsSync(D))return;let $=R?`searched for local subcommand relative to directory '${R}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",f=`'${D}' does not exist
18
18
  - if '${A}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
19
19
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
20
- - ${$}`;throw Error(f)}_executeSubCommand(D,R){R=R.slice();let A=!1,$=[".js",".ts",".tsx",".mjs",".cjs"];function f(J,Z){let H=s0.resolve(J,Z);if(EA.existsSync(H))return H;if($.includes(s0.extname(Z)))return;let M=$.find((Q)=>EA.existsSync(`${H}${Q}`));if(M)return`${H}${M}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let P=D._executableFile||`${this._name}-${D._name}`,B=this._executableDir||"";if(this._scriptPath){let J;try{J=EA.realpathSync(this._scriptPath)}catch{J=this._scriptPath}B=s0.resolve(s0.dirname(J),B)}if(B){let J=f(B,P);if(!J&&!D._executableFile&&this._scriptPath){let Z=s0.basename(this._scriptPath,s0.extname(this._scriptPath));if(Z!==this._name)J=f(B,`${Z}-${D._name}`)}P=J||P}A=$.includes(s0.extname(P));let G;if(h.platform!=="win32")if(A)R.unshift(P),R=z4(h.execArgv).concat(R),G=Rf.spawn(h.argv[0],R,{stdio:"inherit"});else G=Rf.spawn(P,R,{stdio:"inherit"});else this._checkForMissingExecutable(P,B,D._name),R.unshift(P),R=z4(h.execArgv).concat(R),G=Rf.spawn(h.execPath,R,{stdio:"inherit"});if(!G.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((Z)=>{h.on(Z,()=>{if(G.killed===!1&&G.exitCode===null)G.kill(Z)})});let z=this._exitCallback;G.on("close",(J)=>{if(J=J??1,!z)h.exit(J);else z(new Af(J,"commander.executeSubCommandAsync","(close)"))}),G.on("error",(J)=>{if(J.code==="ENOENT")this._checkForMissingExecutable(P,B,D._name);else if(J.code==="EACCES")throw Error(`'${P}' not executable`);if(!z)h.exit(1);else{let Z=new Af(1,"commander.executeSubCommandAsync","(error)");Z.nestedError=J,z(Z)}}),this.runningCommand=G}_dispatchSubcommand(D,R,A){let $=this._findCommand(D);if(!$)this.help({error:!0});$._prepareForParse();let f;return f=this._chainOrCallSubCommandHook(f,$,"preSubcommand"),f=this._chainOrCall(f,()=>{if($._executableHandler)this._executeSubCommand($,R.concat(A));else return $._parseCommand(R,A)}),f}_dispatchHelpCommand(D){if(!D)this.help();let R=this._findCommand(D);if(R&&!R._executableHandler)R.help();return this._dispatchSubcommand(D,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((D,R)=>{if(D.required&&this.args[R]==null)this.missingArgument(D.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 D=(A,$,f)=>{let P=$;if($!==null&&A.parseArg){let B=`error: command-argument value '${$}' is invalid for argument '${A.name()}'.`;P=this._callParseArg(A,$,f,B)}return P};this._checkNumberOfArguments();let R=[];this.registeredArguments.forEach((A,$)=>{let f=A.defaultValue;if(A.variadic){if($<this.args.length){if(f=this.args.slice($),A.parseArg)f=f.reduce((P,B)=>{return D(A,B,P)},A.defaultValue)}else if(f===void 0)f=[]}else if($<this.args.length){if(f=this.args[$],A.parseArg)f=D(A,f,A.defaultValue)}R[$]=f}),this.processedArgs=R}_chainOrCall(D,R){if(D?.then&&typeof D.then==="function")return D.then(()=>R());return R()}_chainOrCallHooks(D,R){let A=D,$=[];if(this._getCommandAndAncestors().reverse().filter((f)=>f._lifeCycleHooks[R]!==void 0).forEach((f)=>{f._lifeCycleHooks[R].forEach((P)=>{$.push({hookedCommand:f,callback:P})})}),R==="postAction")$.reverse();return $.forEach((f)=>{A=this._chainOrCall(A,()=>{return f.callback(f.hookedCommand,this)})}),A}_chainOrCallSubCommandHook(D,R,A){let $=D;if(this._lifeCycleHooks[A]!==void 0)this._lifeCycleHooks[A].forEach((f)=>{$=this._chainOrCall($,()=>{return f(this,R)})});return $}_parseCommand(D,R){let A=this.parseOptions(R);if(this._parseOptionsEnv(),this._parseOptionsImplied(),D=D.concat(A.operands),R=A.unknown,this.args=D.concat(R),D&&this._findCommand(D[0]))return this._dispatchSubcommand(D[0],D.slice(1),R);if(this._getHelpCommand()&&D[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(D[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(R),this._dispatchSubcommand(this._defaultCommandName,D,R);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(A.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let $=()=>{if(A.unknown.length>0)this.unknownOption(A.unknown[0])},f=`command:${this.name()}`;if(this._actionHandler){$(),this._processArguments();let P;if(P=this._chainOrCallHooks(P,"preAction"),P=this._chainOrCall(P,()=>this._actionHandler(this.processedArgs)),this.parent)P=this._chainOrCall(P,()=>{this.parent.emit(f,D,R)});return P=this._chainOrCallHooks(P,"postAction"),P}if(this.parent?.listenerCount(f))$(),this._processArguments(),this.parent.emit(f,D,R);else if(D.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",D,R);if(this.listenerCount("command:*"))this.emit("command:*",D,R);else if(this.commands.length)this.unknownCommand();else $(),this._processArguments()}else if(this.commands.length)$(),this.help({error:!0});else $(),this._processArguments()}_findCommand(D){if(!D)return;return this.commands.find((R)=>R._name===D||R._aliases.includes(D))}_findOption(D){return this.options.find((R)=>R.is(D))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((D)=>{D.options.forEach((R)=>{if(R.mandatory&&D.getOptionValue(R.attributeName())===void 0)D.missingMandatoryOptionValue(R)})})}_checkForConflictingLocalOptions(){let D=this.options.filter((A)=>{let $=A.attributeName();if(this.getOptionValue($)===void 0)return!1;return this.getOptionValueSource($)!=="default"});D.filter((A)=>A.conflictsWith.length>0).forEach((A)=>{let $=D.find((f)=>A.conflictsWith.includes(f.attributeName()));if($)this._conflictingOption(A,$)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((D)=>{D._checkForConflictingLocalOptions()})}parseOptions(D){let R=[],A=[],$=R;function f(J){return J.length>1&&J[0]==="-"}let P=(J)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(J))return!1;return!this._getCommandAndAncestors().some((Z)=>Z.options.map((H)=>H.short).some((H)=>/^-\d$/.test(H)))},B=null,G=null,z=0;while(z<D.length||G){let J=G??D[z++];if(G=null,J==="--"){if($===A)$.push(J);$.push(...D.slice(z));break}if(B&&(!f(J)||P(J))){this.emit(`option:${B.name()}`,J);continue}if(B=null,f(J)){let Z=this._findOption(J);if(Z){if(Z.required){let H=D[z++];if(H===void 0)this.optionMissingArgument(Z);this.emit(`option:${Z.name()}`,H)}else if(Z.optional){let H=null;if(z<D.length&&(!f(D[z])||P(D[z])))H=D[z++];this.emit(`option:${Z.name()}`,H)}else this.emit(`option:${Z.name()}`);B=Z.variadic?Z:null;continue}}if(J.length>2&&J[0]==="-"&&J[1]!=="-"){let Z=this._findOption(`-${J[1]}`);if(Z){if(Z.required||Z.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${Z.name()}`,J.slice(2));else this.emit(`option:${Z.name()}`),G=`-${J.slice(2)}`;continue}}if(/^--[^=]+=/.test(J)){let Z=J.indexOf("="),H=this._findOption(J.slice(0,Z));if(H&&(H.required||H.optional)){this.emit(`option:${H.name()}`,J.slice(Z+1));continue}}if($===R&&f(J)&&!(this.commands.length===0&&P(J)))$=A;if((this._enablePositionalOptions||this._passThroughOptions)&&R.length===0&&A.length===0){if(this._findCommand(J)){R.push(J),A.push(...D.slice(z));break}else if(this._getHelpCommand()&&J===this._getHelpCommand().name()){R.push(J,...D.slice(z));break}else if(this._defaultCommandName){A.push(J,...D.slice(z));break}}if(this._passThroughOptions){$.push(J,...D.slice(z));break}$.push(J)}return{operands:R,unknown:A}}opts(){if(this._storeOptionsAsProperties){let D={},R=this.options.length;for(let A=0;A<R;A++){let $=this.options[A].attributeName();D[$]=$===this._versionOptionName?this._version:this[$]}return D}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((D,R)=>Object.assign(D,R.opts()),{})}error(D,R){if(this._outputConfiguration.outputError(`${D}
20
+ - ${$}`;throw Error(f)}_executeSubCommand(D,R){R=R.slice();let A=!1,$=[".js",".ts",".tsx",".mjs",".cjs"];function f(J,Z){let H=s0.resolve(J,Z);if(EA.existsSync(H))return H;if($.includes(s0.extname(Z)))return;let M=$.find((Q)=>EA.existsSync(`${H}${Q}`));if(M)return`${H}${M}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let P=D._executableFile||`${this._name}-${D._name}`,B=this._executableDir||"";if(this._scriptPath){let J;try{J=EA.realpathSync(this._scriptPath)}catch{J=this._scriptPath}B=s0.resolve(s0.dirname(J),B)}if(B){let J=f(B,P);if(!J&&!D._executableFile&&this._scriptPath){let Z=s0.basename(this._scriptPath,s0.extname(this._scriptPath));if(Z!==this._name)J=f(B,`${Z}-${D._name}`)}P=J||P}A=$.includes(s0.extname(P));let G;if(h.platform!=="win32")if(A)R.unshift(P),R=z4(h.execArgv).concat(R),G=A2.spawn(h.argv[0],R,{stdio:"inherit"});else G=A2.spawn(P,R,{stdio:"inherit"});else this._checkForMissingExecutable(P,B,D._name),R.unshift(P),R=z4(h.execArgv).concat(R),G=A2.spawn(h.execPath,R,{stdio:"inherit"});if(!G.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((Z)=>{h.on(Z,()=>{if(G.killed===!1&&G.exitCode===null)G.kill(Z)})});let z=this._exitCallback;G.on("close",(J)=>{if(J=J??1,!z)h.exit(J);else z(new $2(J,"commander.executeSubCommandAsync","(close)"))}),G.on("error",(J)=>{if(J.code==="ENOENT")this._checkForMissingExecutable(P,B,D._name);else if(J.code==="EACCES")throw Error(`'${P}' not executable`);if(!z)h.exit(1);else{let Z=new $2(1,"commander.executeSubCommandAsync","(error)");Z.nestedError=J,z(Z)}}),this.runningCommand=G}_dispatchSubcommand(D,R,A){let $=this._findCommand(D);if(!$)this.help({error:!0});$._prepareForParse();let f;return f=this._chainOrCallSubCommandHook(f,$,"preSubcommand"),f=this._chainOrCall(f,()=>{if($._executableHandler)this._executeSubCommand($,R.concat(A));else return $._parseCommand(R,A)}),f}_dispatchHelpCommand(D){if(!D)this.help();let R=this._findCommand(D);if(R&&!R._executableHandler)R.help();return this._dispatchSubcommand(D,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((D,R)=>{if(D.required&&this.args[R]==null)this.missingArgument(D.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 D=(A,$,f)=>{let P=$;if($!==null&&A.parseArg){let B=`error: command-argument value '${$}' is invalid for argument '${A.name()}'.`;P=this._callParseArg(A,$,f,B)}return P};this._checkNumberOfArguments();let R=[];this.registeredArguments.forEach((A,$)=>{let f=A.defaultValue;if(A.variadic){if($<this.args.length){if(f=this.args.slice($),A.parseArg)f=f.reduce((P,B)=>{return D(A,B,P)},A.defaultValue)}else if(f===void 0)f=[]}else if($<this.args.length){if(f=this.args[$],A.parseArg)f=D(A,f,A.defaultValue)}R[$]=f}),this.processedArgs=R}_chainOrCall(D,R){if(D?.then&&typeof D.then==="function")return D.then(()=>R());return R()}_chainOrCallHooks(D,R){let A=D,$=[];if(this._getCommandAndAncestors().reverse().filter((f)=>f._lifeCycleHooks[R]!==void 0).forEach((f)=>{f._lifeCycleHooks[R].forEach((P)=>{$.push({hookedCommand:f,callback:P})})}),R==="postAction")$.reverse();return $.forEach((f)=>{A=this._chainOrCall(A,()=>{return f.callback(f.hookedCommand,this)})}),A}_chainOrCallSubCommandHook(D,R,A){let $=D;if(this._lifeCycleHooks[A]!==void 0)this._lifeCycleHooks[A].forEach((f)=>{$=this._chainOrCall($,()=>{return f(this,R)})});return $}_parseCommand(D,R){let A=this.parseOptions(R);if(this._parseOptionsEnv(),this._parseOptionsImplied(),D=D.concat(A.operands),R=A.unknown,this.args=D.concat(R),D&&this._findCommand(D[0]))return this._dispatchSubcommand(D[0],D.slice(1),R);if(this._getHelpCommand()&&D[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(D[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(R),this._dispatchSubcommand(this._defaultCommandName,D,R);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(A.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let $=()=>{if(A.unknown.length>0)this.unknownOption(A.unknown[0])},f=`command:${this.name()}`;if(this._actionHandler){$(),this._processArguments();let P;if(P=this._chainOrCallHooks(P,"preAction"),P=this._chainOrCall(P,()=>this._actionHandler(this.processedArgs)),this.parent)P=this._chainOrCall(P,()=>{this.parent.emit(f,D,R)});return P=this._chainOrCallHooks(P,"postAction"),P}if(this.parent?.listenerCount(f))$(),this._processArguments(),this.parent.emit(f,D,R);else if(D.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",D,R);if(this.listenerCount("command:*"))this.emit("command:*",D,R);else if(this.commands.length)this.unknownCommand();else $(),this._processArguments()}else if(this.commands.length)$(),this.help({error:!0});else $(),this._processArguments()}_findCommand(D){if(!D)return;return this.commands.find((R)=>R._name===D||R._aliases.includes(D))}_findOption(D){return this.options.find((R)=>R.is(D))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((D)=>{D.options.forEach((R)=>{if(R.mandatory&&D.getOptionValue(R.attributeName())===void 0)D.missingMandatoryOptionValue(R)})})}_checkForConflictingLocalOptions(){let D=this.options.filter((A)=>{let $=A.attributeName();if(this.getOptionValue($)===void 0)return!1;return this.getOptionValueSource($)!=="default"});D.filter((A)=>A.conflictsWith.length>0).forEach((A)=>{let $=D.find((f)=>A.conflictsWith.includes(f.attributeName()));if($)this._conflictingOption(A,$)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((D)=>{D._checkForConflictingLocalOptions()})}parseOptions(D){let R=[],A=[],$=R;function f(J){return J.length>1&&J[0]==="-"}let P=(J)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(J))return!1;return!this._getCommandAndAncestors().some((Z)=>Z.options.map((H)=>H.short).some((H)=>/^-\d$/.test(H)))},B=null,G=null,z=0;while(z<D.length||G){let J=G??D[z++];if(G=null,J==="--"){if($===A)$.push(J);$.push(...D.slice(z));break}if(B&&(!f(J)||P(J))){this.emit(`option:${B.name()}`,J);continue}if(B=null,f(J)){let Z=this._findOption(J);if(Z){if(Z.required){let H=D[z++];if(H===void 0)this.optionMissingArgument(Z);this.emit(`option:${Z.name()}`,H)}else if(Z.optional){let H=null;if(z<D.length&&(!f(D[z])||P(D[z])))H=D[z++];this.emit(`option:${Z.name()}`,H)}else this.emit(`option:${Z.name()}`);B=Z.variadic?Z:null;continue}}if(J.length>2&&J[0]==="-"&&J[1]!=="-"){let Z=this._findOption(`-${J[1]}`);if(Z){if(Z.required||Z.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${Z.name()}`,J.slice(2));else this.emit(`option:${Z.name()}`),G=`-${J.slice(2)}`;continue}}if(/^--[^=]+=/.test(J)){let Z=J.indexOf("="),H=this._findOption(J.slice(0,Z));if(H&&(H.required||H.optional)){this.emit(`option:${H.name()}`,J.slice(Z+1));continue}}if($===R&&f(J)&&!(this.commands.length===0&&P(J)))$=A;if((this._enablePositionalOptions||this._passThroughOptions)&&R.length===0&&A.length===0){if(this._findCommand(J)){R.push(J),A.push(...D.slice(z));break}else if(this._getHelpCommand()&&J===this._getHelpCommand().name()){R.push(J,...D.slice(z));break}else if(this._defaultCommandName){A.push(J,...D.slice(z));break}}if(this._passThroughOptions){$.push(J,...D.slice(z));break}$.push(J)}return{operands:R,unknown:A}}opts(){if(this._storeOptionsAsProperties){let D={},R=this.options.length;for(let A=0;A<R;A++){let $=this.options[A].attributeName();D[$]=$===this._versionOptionName?this._version:this[$]}return D}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((D,R)=>Object.assign(D,R.opts()),{})}error(D,R){if(this._outputConfiguration.outputError(`${D}
21
21
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
22
22
  `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
23
23
  `),this.outputHelp({error:!0});let A=R||{},$=A.exitCode||1,f=A.code||"commander.error";this._exit($,f,D)}_parseOptionsEnv(){this.options.forEach((D)=>{if(D.envVar&&D.envVar in h.env){let R=D.attributeName();if(this.getOptionValue(R)===void 0||["default","config","env"].includes(this.getOptionValueSource(R)))if(D.required||D.optional)this.emit(`optionEnv:${D.name()}`,h.env[D.envVar]);else this.emit(`optionEnv:${D.name()}`)}})}_parseOptionsImplied(){let D=new gJ(this.options),R=(A)=>{return this.getOptionValue(A)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(A))};this.options.filter((A)=>A.implied!==void 0&&R(A.attributeName())&&D.valueFromOption(this.getOptionValue(A.attributeName()),A)).forEach((A)=>{Object.keys(A.implied).filter(($)=>!R($)).forEach(($)=>{this.setOptionValueWithSource($,A.implied[$],"implied")})})}missingArgument(D){let R=`error: missing required argument '${D}'`;this.error(R,{code:"commander.missingArgument"})}optionMissingArgument(D){let R=`error: option '${D.flags}' argument missing`;this.error(R,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(D){let R=`error: required option '${D.flags}' not specified`;this.error(R,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(D,R){let A=(P)=>{let B=P.attributeName(),G=this.getOptionValue(B),z=this.options.find((Z)=>Z.negate&&B===Z.attributeName()),J=this.options.find((Z)=>!Z.negate&&B===Z.attributeName());if(z&&(z.presetArg===void 0&&G===!1||z.presetArg!==void 0&&G===z.presetArg))return z;return J||P},$=(P)=>{let B=A(P),G=B.attributeName();if(this.getOptionValueSource(G)==="env")return`environment variable '${B.envVar}'`;return`option '${B.flags}'`},f=`error: ${$(D)} cannot be used with ${$(R)}`;this.error(f,{code:"commander.conflictingOption"})}unknownOption(D){if(this._allowUnknownOption)return;let R="";if(D.startsWith("--")&&this._showSuggestionAfterError){let $=[],f=this;do{let P=f.createHelp().visibleOptions(f).filter((B)=>B.long).map((B)=>B.long);$=$.concat(P),f=f.parent}while(f&&!f._enablePositionalOptions);R=G4(D,$)}let A=`error: unknown option '${D}'${R}`;this.error(A,{code:"commander.unknownOption"})}_excessArguments(D){if(this._allowExcessArguments)return;let R=this.registeredArguments.length,A=R===1?"":"s",f=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${R} argument${A} but got ${D.length}.`;this.error(f,{code:"commander.excessArguments"})}unknownCommand(){let D=this.args[0],R="";if(this._showSuggestionAfterError){let $=[];this.createHelp().visibleCommands(this).forEach((f)=>{if($.push(f.name()),f.alias())$.push(f.alias())}),R=G4(D,$)}let A=`error: unknown command '${D}'${R}`;this.error(A,{code:"commander.unknownCommand"})}version(D,R,A){if(D===void 0)return this._version;this._version=D,R=R||"-V, --version",A=A||"output the version number";let $=this.createOption(R,A);return this._versionOptionName=$.attributeName(),this._registerOption($),this.on("option:"+$.name(),()=>{this._outputConfiguration.writeOut(`${D}
24
24
  `),this._exit(0,"commander.version",D)}),this}description(D,R){if(D===void 0&&R===void 0)return this._description;if(this._description=D,R)this._argsDescription=R;return this}summary(D){if(D===void 0)return this._summary;return this._summary=D,this}alias(D){if(D===void 0)return this._aliases[0];let R=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)R=this.commands[this.commands.length-1];if(D===R._name)throw Error("Command alias can't be the same as its name");let A=this.parent?._findCommand(D);if(A){let $=[A.name()].concat(A.aliases()).join("|");throw Error(`cannot add alias '${D}' to command '${this.name()}' as already have command '${$}'`)}return R._aliases.push(D),this}aliases(D){if(D===void 0)return this._aliases;return D.forEach((R)=>this.alias(R)),this}usage(D){if(D===void 0){if(this._usage)return this._usage;let R=this.registeredArguments.map((A)=>{return uJ(A)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?R:[]).join(" ")}return this._usage=D,this}name(D){if(D===void 0)return this._name;return this._name=D,this}helpGroup(D){if(D===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=D,this}commandsGroup(D){if(D===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=D,this}optionsGroup(D){if(D===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=D,this}_initOptionGroup(D){if(this._defaultOptionGroup&&!D.helpGroupHeading)D.helpGroup(this._defaultOptionGroup)}_initCommandGroup(D){if(this._defaultCommandGroup&&!D.helpGroup())D.helpGroup(this._defaultCommandGroup)}nameFromFilename(D){return this._name=s0.basename(D,s0.extname(D)),this}executableDir(D){if(D===void 0)return this._executableDir;return this._executableDir=D,this}helpInformation(D){let R=this.createHelp(),A=this._getOutputContext(D);R.prepareContext({error:A.error,helpWidth:A.helpWidth,outputHasColors:A.hasColors});let $=R.formatHelp(this,R);if(A.hasColors)return $;return this._outputConfiguration.stripColor($)}_getOutputContext(D){D=D||{};let R=!!D.error,A,$,f;if(R)A=(B)=>this._outputConfiguration.writeErr(B),$=this._outputConfiguration.getErrHasColors(),f=this._outputConfiguration.getErrHelpWidth();else A=(B)=>this._outputConfiguration.writeOut(B),$=this._outputConfiguration.getOutHasColors(),f=this._outputConfiguration.getOutHelpWidth();return{error:R,write:(B)=>{if(!$)B=this._outputConfiguration.stripColor(B);return A(B)},hasColors:$,helpWidth:f}}outputHelp(D){let R;if(typeof D==="function")R=D,D=void 0;let A=this._getOutputContext(D),$={error:A.error,write:A.write,command:this};this._getCommandAndAncestors().reverse().forEach((P)=>P.emit("beforeAllHelp",$)),this.emit("beforeHelp",$);let f=this.helpInformation({error:A.error});if(R){if(f=R(f),typeof f!=="string"&&!Buffer.isBuffer(f))throw Error("outputHelp callback must return a string or a Buffer")}if(A.write(f),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",$),this._getCommandAndAncestors().forEach((P)=>P.emit("afterAllHelp",$))}helpOption(D,R){if(typeof D==="boolean"){if(D){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(D??"-h, --help",R??"display help for command"),D||R)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(D){return this._helpOption=D,this._initOptionGroup(D),this}help(D){this.outputHelp(D);let R=Number(h.exitCode??0);if(R===0&&D&&typeof D!=="function"&&D.error)R=1;this._exit(R,"commander.help","(outputHelp)")}addHelpText(D,R){let A=["beforeAll","before","after","afterAll"];if(!A.includes(D))throw Error(`Unexpected value for position to addHelpText.
25
25
  Expecting one of '${A.join("', '")}'`);let $=`${D}Help`;return this.on($,(f)=>{let P;if(typeof R==="function")P=R({error:f.error,command:f.command});else P=R;if(P)f.write(`${P}
26
- `)}),this}_outputHelpIfRequested(D){let R=this._getHelpOption();if(R&&D.find(($)=>R.is($)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function z4(D){return D.map((R)=>{if(!R.startsWith("--inspect"))return R;let A,$="127.0.0.1",f="9229",P;if((P=R.match(/^(--inspect(-brk)?)$/))!==null)A=P[1];else if((P=R.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(A=P[1],/^\d+$/.test(P[3]))f=P[3];else $=P[3];else if((P=R.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)A=P[1],$=P[3],f=P[4];if(A&&f!=="0")return`${A}=${$}:${parseInt(f)+1}`;return R})}function $f(){if(h.env.NO_COLOR||h.env.FORCE_COLOR==="0"||h.env.FORCE_COLOR==="false")return!1;if(h.env.FORCE_COLOR||h.env.CLICOLOR_FORCE!==void 0)return!0;return}mJ.Command=ff;mJ.useColor=$f});var X4=q((vJ)=>{var{Argument:H4}=uA(),{Command:Pf}=J4(),{CommanderError:pJ,InvalidArgumentError:Z4}=XR(),{Help:hJ}=e2(),{Option:M4}=Df();vJ.program=new Pf;vJ.createCommand=(D)=>new Pf(D);vJ.createOption=(D,R)=>new M4(D,R);vJ.createArgument=(D,R)=>new H4(D,R);vJ.Command=Pf;vJ.Option=M4;vJ.Argument=H4;vJ.Help=hJ;vJ.CommanderError=pJ;vJ.InvalidArgumentError=Z4;vJ.InvalidOptionArgumentError=Z4});var mA=q((NN,Gf)=>{var gA=process||{},O4=gA.argv||[],yA=gA.env||{},DH=!(!!yA.NO_COLOR||O4.includes("--no-color"))&&(!!yA.FORCE_COLOR||O4.includes("--color")||gA.platform==="win32"||(gA.stdout||{}).isTTY&&yA.TERM!=="dumb"||!!yA.CI),RH=(D,R,A=D)=>($)=>{let f=""+$,P=f.indexOf(R,D.length);return~P?D+AH(f,R,A,P)+R:D+f+R},AH=(D,R,A,$)=>{let f="",P=0;do f+=D.substring(P,$)+A,P=$+R.length,$=D.indexOf(R,P);while(~$);return f+D.substring(P)},Y4=(D=DH)=>{let R=D?RH:()=>String;return{isColorSupported:D,reset:R("\x1B[0m","\x1B[0m"),bold:R("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:R("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:R("\x1B[3m","\x1B[23m"),underline:R("\x1B[4m","\x1B[24m"),inverse:R("\x1B[7m","\x1B[27m"),hidden:R("\x1B[8m","\x1B[28m"),strikethrough:R("\x1B[9m","\x1B[29m"),black:R("\x1B[30m","\x1B[39m"),red:R("\x1B[31m","\x1B[39m"),green:R("\x1B[32m","\x1B[39m"),yellow:R("\x1B[33m","\x1B[39m"),blue:R("\x1B[34m","\x1B[39m"),magenta:R("\x1B[35m","\x1B[39m"),cyan:R("\x1B[36m","\x1B[39m"),white:R("\x1B[37m","\x1B[39m"),gray:R("\x1B[90m","\x1B[39m"),bgBlack:R("\x1B[40m","\x1B[49m"),bgRed:R("\x1B[41m","\x1B[49m"),bgGreen:R("\x1B[42m","\x1B[49m"),bgYellow:R("\x1B[43m","\x1B[49m"),bgBlue:R("\x1B[44m","\x1B[49m"),bgMagenta:R("\x1B[45m","\x1B[49m"),bgCyan:R("\x1B[46m","\x1B[49m"),bgWhite:R("\x1B[47m","\x1B[49m"),blackBright:R("\x1B[90m","\x1B[39m"),redBright:R("\x1B[91m","\x1B[39m"),greenBright:R("\x1B[92m","\x1B[39m"),yellowBright:R("\x1B[93m","\x1B[39m"),blueBright:R("\x1B[94m","\x1B[39m"),magentaBright:R("\x1B[95m","\x1B[39m"),cyanBright:R("\x1B[96m","\x1B[39m"),whiteBright:R("\x1B[97m","\x1B[39m"),bgBlackBright:R("\x1B[100m","\x1B[49m"),bgRedBright:R("\x1B[101m","\x1B[49m"),bgGreenBright:R("\x1B[102m","\x1B[49m"),bgYellowBright:R("\x1B[103m","\x1B[49m"),bgBlueBright:R("\x1B[104m","\x1B[49m"),bgMagentaBright:R("\x1B[105m","\x1B[49m"),bgCyanBright:R("\x1B[106m","\x1B[49m"),bgWhiteBright:R("\x1B[107m","\x1B[49m")}};Gf.exports=Y4();Gf.exports.createColors=Y4});var h4=q((KV,p4)=>{p4.exports=wH;function qH(D){let R={defaultWidth:0,output:process.stdout,tty:p("tty")};if(!D)return R;return Object.keys(R).forEach(function(A){if(!D[A])D[A]=R[A]}),D}function wH(D){let R=qH(D);if(R.output.getWindowSize)return R.output.getWindowSize()[0]||R.defaultWidth;if(R.tty.getWindowSize)return R.tty.getWindowSize()[1]||R.defaultWidth;if(R.output.columns)return R.output.columns;if(process.env.CLI_WIDTH){let A=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(A)&&A!==0)return A}return R.defaultWidth}});var B9=q((vV,P9)=>{var mH=p("stream");class f9 extends mH{#D=null;constructor(D={}){super(D);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=D.replace,this._prompt=D.prompt||null,this._hadControl=!1}#A(D,R){if(this._dest)return this._dest[D];if(this._src)return this._src[D];return R}#R(D,...R){if(typeof this._dest?.[D]==="function")this._dest[D](...R);if(typeof this._src?.[D]==="function")this._src[D](...R)}get isTTY(){if(this.#D!==null)return this.#D;return this.#A("isTTY",!1)}set isTTY(D){this.#D=D}get rows(){return this.#A("rows")}get columns(){return this.#A("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(D){this._src=D}pipe(D,R){return this._dest=D,super.pipe(D,R)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(D){if(this.muted){if(!this.replace)return!0;if(D.match(/^\u001b/)){if(D.indexOf(this._prompt)===0)D=D.slice(this._prompt.length),D=D.replace(/./g,this.replace),D=this._prompt+D;return this._hadControl=!0,this.emit("data",D)}else{if(this._prompt&&this._hadControl&&D.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),D=D.slice(this._prompt.length);D=D.toString().replace(/./g,this.replace)}}this.emit("data",D)}end(D){if(this.muted)if(D&&this.replace)D=D.toString().replace(/./g,this.replace);else D=null;if(D)this.emit("data",D);this.emit("end")}destroy(...D){return this.#R("destroy",...D)}destroySoon(...D){return this.#R("destroySoon",...D)}close(...D){return this.#R("close",...D)}}P9.exports=f9});var m=q((BZ)=>{var A3=Symbol.for("yaml.alias"),F9=Symbol.for("yaml.document"),D$=Symbol.for("yaml.map"),q9=Symbol.for("yaml.pair"),$3=Symbol.for("yaml.scalar"),R$=Symbol.for("yaml.seq"),fD=Symbol.for("yaml.node.type"),eH=(D)=>!!D&&typeof D==="object"&&D[fD]===A3,DZ=(D)=>!!D&&typeof D==="object"&&D[fD]===F9,RZ=(D)=>!!D&&typeof D==="object"&&D[fD]===D$,AZ=(D)=>!!D&&typeof D==="object"&&D[fD]===q9,w9=(D)=>!!D&&typeof D==="object"&&D[fD]===$3,$Z=(D)=>!!D&&typeof D==="object"&&D[fD]===R$;function C9(D){if(D&&typeof D==="object")switch(D[fD]){case D$:case R$:return!0}return!1}function fZ(D){if(D&&typeof D==="object")switch(D[fD]){case A3:case D$:case $3:case R$:return!0}return!1}var PZ=(D)=>(w9(D)||C9(D))&&!!D.anchor;BZ.ALIAS=A3;BZ.DOC=F9;BZ.MAP=D$;BZ.NODE_TYPE=fD;BZ.PAIR=q9;BZ.SCALAR=$3;BZ.SEQ=R$;BZ.hasAnchor=PZ;BZ.isAlias=eH;BZ.isCollection=C9;BZ.isDocument=DZ;BZ.isMap=RZ;BZ.isNode=fZ;BZ.isPair=AZ;BZ.isScalar=w9;BZ.isSeq=$Z});var WR=q((CZ)=>{var t=m(),Z0=Symbol("break visit"),L9=Symbol("skip children"),x0=Symbol("remove node");function A$(D,R){let A=N9(R);if(t.isDocument(D)){if(W1(null,D.contents,A,Object.freeze([D]))===x0)D.contents=null}else W1(null,D,A,Object.freeze([]))}A$.BREAK=Z0;A$.SKIP=L9;A$.REMOVE=x0;function W1(D,R,A,$){let f=V9(D,R,A,$);if(t.isNode(f)||t.isPair(f))return I9(D,$,f),W1(D,f,A,$);if(typeof f!=="symbol"){if(t.isCollection(R)){$=Object.freeze($.concat(R));for(let P=0;P<R.items.length;++P){let B=W1(P,R.items[P],A,$);if(typeof B==="number")P=B-1;else if(B===Z0)return Z0;else if(B===x0)R.items.splice(P,1),P-=1}}else if(t.isPair(R)){$=Object.freeze($.concat(R));let P=W1("key",R.key,A,$);if(P===Z0)return Z0;else if(P===x0)R.key=null;let B=W1("value",R.value,A,$);if(B===Z0)return Z0;else if(B===x0)R.value=null}}return f}async function $$(D,R){let A=N9(R);if(t.isDocument(D)){if(await j1(null,D.contents,A,Object.freeze([D]))===x0)D.contents=null}else await j1(null,D,A,Object.freeze([]))}$$.BREAK=Z0;$$.SKIP=L9;$$.REMOVE=x0;async function j1(D,R,A,$){let f=await V9(D,R,A,$);if(t.isNode(f)||t.isPair(f))return I9(D,$,f),j1(D,f,A,$);if(typeof f!=="symbol"){if(t.isCollection(R)){$=Object.freeze($.concat(R));for(let P=0;P<R.items.length;++P){let B=await j1(P,R.items[P],A,$);if(typeof B==="number")P=B-1;else if(B===Z0)return Z0;else if(B===x0)R.items.splice(P,1),P-=1}}else if(t.isPair(R)){$=Object.freeze($.concat(R));let P=await j1("key",R.key,A,$);if(P===Z0)return Z0;else if(P===x0)R.key=null;let B=await j1("value",R.value,A,$);if(B===Z0)return Z0;else if(B===x0)R.value=null}}return f}function N9(D){if(typeof D==="object"&&(D.Collection||D.Node||D.Value))return Object.assign({Alias:D.Node,Map:D.Node,Scalar:D.Node,Seq:D.Node},D.Value&&{Map:D.Value,Scalar:D.Value,Seq:D.Value},D.Collection&&{Map:D.Collection,Seq:D.Collection},D);return D}function V9(D,R,A,$){if(typeof A==="function")return A(D,R,$);if(t.isMap(R))return A.Map?.(D,R,$);if(t.isSeq(R))return A.Seq?.(D,R,$);if(t.isPair(R))return A.Pair?.(D,R,$);if(t.isScalar(R))return A.Scalar?.(D,R,$);if(t.isAlias(R))return A.Alias?.(D,R,$);return}function I9(D,R,A){let $=R[R.length-1];if(t.isCollection($))$.items[D]=A;else if(t.isPair($))if(D==="key")$.key=A;else $.value=A;else if(t.isDocument($))$.contents=A;else{let f=t.isAlias($)?"alias":"scalar";throw Error(`Cannot replace node with ${f} parent`)}}CZ.visit=A$;CZ.visitAsync=$$});var f3=q((WZ)=>{var K9=m(),VZ=WR(),IZ={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},KZ=(D)=>D.replace(/[!,[\]{}]/g,(R)=>IZ[R]);class U0{constructor(D,R){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},U0.defaultYaml,D),this.tags=Object.assign({},U0.defaultTags,R)}clone(){let D=new U0(this.yaml,this.tags);return D.docStart=this.docStart,D}atDocument(){let D=new U0(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:U0.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},U0.defaultTags);break}return D}add(D,R){if(this.atNextDocument)this.yaml={explicit:U0.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},U0.defaultTags),this.atNextDocument=!1;let A=D.trim().split(/[ \t]+/),$=A.shift();switch($){case"%TAG":{if(A.length!==2){if(R(0,"%TAG directive should contain exactly two parts"),A.length<2)return!1}let[f,P]=A;return this.tags[f]=P,!0}case"%YAML":{if(this.yaml.explicit=!0,A.length!==1)return R(0,"%YAML directive should contain exactly one part"),!1;let[f]=A;if(f==="1.1"||f==="1.2")return this.yaml.version=f,!0;else{let P=/^\d+\.\d+$/.test(f);return R(6,`Unsupported YAML version ${f}`,P),!1}}default:return R(0,`Unknown directive ${$}`,!0),!1}}tagName(D,R){if(D==="!")return"!";if(D[0]!=="!")return R(`Not a valid tag: ${D}`),null;if(D[1]==="<"){let P=D.slice(2,-1);if(P==="!"||P==="!!")return R(`Verbatim tags aren't resolved, so ${D} is invalid.`),null;if(D[D.length-1]!==">")R("Verbatim tags must end with a >");return P}let[,A,$]=D.match(/^(.*!)([^!]*)$/s);if(!$)R(`The ${D} tag has no suffix`);let f=this.tags[A];if(f)try{return f+decodeURIComponent($)}catch(P){return R(String(P)),null}if(A==="!")return D;return R(`Could not resolve tag: ${D}`),null}tagString(D){for(let[R,A]of Object.entries(this.tags))if(D.startsWith(A))return R+KZ(D.substring(A.length));return D[0]==="!"?D:`!<${D}>`}toString(D){let R=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],A=Object.entries(this.tags),$;if(D&&A.length>0&&K9.isNode(D.contents)){let f={};VZ.visit(D.contents,(P,B)=>{if(K9.isNode(B)&&B.tag)f[B.tag]=!0}),$=Object.keys(f)}else $=[];for(let[f,P]of A){if(f==="!!"&&P==="tag:yaml.org,2002:")continue;if(!D||$.some((B)=>B.startsWith(P)))R.push(`%TAG ${f} ${P}`)}return R.join(`
26
+ `)}),this}_outputHelpIfRequested(D){let R=this._getHelpOption();if(R&&D.find(($)=>R.is($)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function z4(D){return D.map((R)=>{if(!R.startsWith("--inspect"))return R;let A,$="127.0.0.1",f="9229",P;if((P=R.match(/^(--inspect(-brk)?)$/))!==null)A=P[1];else if((P=R.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(A=P[1],/^\d+$/.test(P[3]))f=P[3];else $=P[3];else if((P=R.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)A=P[1],$=P[3],f=P[4];if(A&&f!=="0")return`${A}=${$}:${parseInt(f)+1}`;return R})}function f2(){if(h.env.NO_COLOR||h.env.FORCE_COLOR==="0"||h.env.FORCE_COLOR==="false")return!1;if(h.env.FORCE_COLOR||h.env.CLICOLOR_FORCE!==void 0)return!0;return}mJ.Command=P2;mJ.useColor=f2});var X4=q((vJ)=>{var{Argument:H4}=uA(),{Command:B2}=J4(),{CommanderError:pJ,InvalidArgumentError:Z4}=XR(),{Help:hJ}=D2(),{Option:M4}=R2();vJ.program=new B2;vJ.createCommand=(D)=>new B2(D);vJ.createOption=(D,R)=>new M4(D,R);vJ.createArgument=(D,R)=>new H4(D,R);vJ.Command=B2;vJ.Option=M4;vJ.Argument=H4;vJ.Help=hJ;vJ.CommanderError=pJ;vJ.InvalidArgumentError=Z4;vJ.InvalidOptionArgumentError=Z4});var mA=q((CN,z2)=>{var gA=process||{},O4=gA.argv||[],yA=gA.env||{},DH=!(!!yA.NO_COLOR||O4.includes("--no-color"))&&(!!yA.FORCE_COLOR||O4.includes("--color")||gA.platform==="win32"||(gA.stdout||{}).isTTY&&yA.TERM!=="dumb"||!!yA.CI),RH=(D,R,A=D)=>($)=>{let f=""+$,P=f.indexOf(R,D.length);return~P?D+AH(f,R,A,P)+R:D+f+R},AH=(D,R,A,$)=>{let f="",P=0;do f+=D.substring(P,$)+A,P=$+R.length,$=D.indexOf(R,P);while(~$);return f+D.substring(P)},Y4=(D=DH)=>{let R=D?RH:()=>String;return{isColorSupported:D,reset:R("\x1B[0m","\x1B[0m"),bold:R("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:R("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:R("\x1B[3m","\x1B[23m"),underline:R("\x1B[4m","\x1B[24m"),inverse:R("\x1B[7m","\x1B[27m"),hidden:R("\x1B[8m","\x1B[28m"),strikethrough:R("\x1B[9m","\x1B[29m"),black:R("\x1B[30m","\x1B[39m"),red:R("\x1B[31m","\x1B[39m"),green:R("\x1B[32m","\x1B[39m"),yellow:R("\x1B[33m","\x1B[39m"),blue:R("\x1B[34m","\x1B[39m"),magenta:R("\x1B[35m","\x1B[39m"),cyan:R("\x1B[36m","\x1B[39m"),white:R("\x1B[37m","\x1B[39m"),gray:R("\x1B[90m","\x1B[39m"),bgBlack:R("\x1B[40m","\x1B[49m"),bgRed:R("\x1B[41m","\x1B[49m"),bgGreen:R("\x1B[42m","\x1B[49m"),bgYellow:R("\x1B[43m","\x1B[49m"),bgBlue:R("\x1B[44m","\x1B[49m"),bgMagenta:R("\x1B[45m","\x1B[49m"),bgCyan:R("\x1B[46m","\x1B[49m"),bgWhite:R("\x1B[47m","\x1B[49m"),blackBright:R("\x1B[90m","\x1B[39m"),redBright:R("\x1B[91m","\x1B[39m"),greenBright:R("\x1B[92m","\x1B[39m"),yellowBright:R("\x1B[93m","\x1B[39m"),blueBright:R("\x1B[94m","\x1B[39m"),magentaBright:R("\x1B[95m","\x1B[39m"),cyanBright:R("\x1B[96m","\x1B[39m"),whiteBright:R("\x1B[97m","\x1B[39m"),bgBlackBright:R("\x1B[100m","\x1B[49m"),bgRedBright:R("\x1B[101m","\x1B[49m"),bgGreenBright:R("\x1B[102m","\x1B[49m"),bgYellowBright:R("\x1B[103m","\x1B[49m"),bgBlueBright:R("\x1B[104m","\x1B[49m"),bgMagentaBright:R("\x1B[105m","\x1B[49m"),bgCyanBright:R("\x1B[106m","\x1B[49m"),bgWhiteBright:R("\x1B[107m","\x1B[49m")}};z2.exports=Y4();z2.exports.createColors=Y4});var h4=q((VV,p4)=>{p4.exports=wH;function qH(D){let R={defaultWidth:0,output:process.stdout,tty:p("tty")};if(!D)return R;return Object.keys(R).forEach(function(A){if(!D[A])D[A]=R[A]}),D}function wH(D){let R=qH(D);if(R.output.getWindowSize)return R.output.getWindowSize()[0]||R.defaultWidth;if(R.tty.getWindowSize)return R.tty.getWindowSize()[1]||R.defaultWidth;if(R.output.columns)return R.output.columns;if(process.env.CLI_WIDTH){let A=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(A)&&A!==0)return A}return R.defaultWidth}});var B9=q((pV,P9)=>{var mH=p("stream");class f9 extends mH{#D=null;constructor(D={}){super(D);this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=D.replace,this._prompt=D.prompt||null,this._hadControl=!1}#A(D,R){if(this._dest)return this._dest[D];if(this._src)return this._src[D];return R}#R(D,...R){if(typeof this._dest?.[D]==="function")this._dest[D](...R);if(typeof this._src?.[D]==="function")this._src[D](...R)}get isTTY(){if(this.#D!==null)return this.#D;return this.#A("isTTY",!1)}set isTTY(D){this.#D=D}get rows(){return this.#A("rows")}get columns(){return this.#A("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(D){this._src=D}pipe(D,R){return this._dest=D,super.pipe(D,R)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(D){if(this.muted){if(!this.replace)return!0;if(D.match(/^\u001b/)){if(D.indexOf(this._prompt)===0)D=D.slice(this._prompt.length),D=D.replace(/./g,this.replace),D=this._prompt+D;return this._hadControl=!0,this.emit("data",D)}else{if(this._prompt&&this._hadControl&&D.indexOf(this._prompt)===0)this._hadControl=!1,this.emit("data",this._prompt),D=D.slice(this._prompt.length);D=D.toString().replace(/./g,this.replace)}}this.emit("data",D)}end(D){if(this.muted)if(D&&this.replace)D=D.toString().replace(/./g,this.replace);else D=null;if(D)this.emit("data",D);this.emit("end")}destroy(...D){return this.#R("destroy",...D)}destroySoon(...D){return this.#R("destroySoon",...D)}close(...D){return this.#R("close",...D)}}P9.exports=f9});var m=q((BZ)=>{var A3=Symbol.for("yaml.alias"),F9=Symbol.for("yaml.document"),D$=Symbol.for("yaml.map"),q9=Symbol.for("yaml.pair"),$3=Symbol.for("yaml.scalar"),R$=Symbol.for("yaml.seq"),fD=Symbol.for("yaml.node.type"),eH=(D)=>!!D&&typeof D==="object"&&D[fD]===A3,DZ=(D)=>!!D&&typeof D==="object"&&D[fD]===F9,RZ=(D)=>!!D&&typeof D==="object"&&D[fD]===D$,AZ=(D)=>!!D&&typeof D==="object"&&D[fD]===q9,w9=(D)=>!!D&&typeof D==="object"&&D[fD]===$3,$Z=(D)=>!!D&&typeof D==="object"&&D[fD]===R$;function C9(D){if(D&&typeof D==="object")switch(D[fD]){case D$:case R$:return!0}return!1}function fZ(D){if(D&&typeof D==="object")switch(D[fD]){case A3:case D$:case $3:case R$:return!0}return!1}var PZ=(D)=>(w9(D)||C9(D))&&!!D.anchor;BZ.ALIAS=A3;BZ.DOC=F9;BZ.MAP=D$;BZ.NODE_TYPE=fD;BZ.PAIR=q9;BZ.SCALAR=$3;BZ.SEQ=R$;BZ.hasAnchor=PZ;BZ.isAlias=eH;BZ.isCollection=C9;BZ.isDocument=DZ;BZ.isMap=RZ;BZ.isNode=fZ;BZ.isPair=AZ;BZ.isScalar=w9;BZ.isSeq=$Z});var WR=q((CZ)=>{var t=m(),Z0=Symbol("break visit"),L9=Symbol("skip children"),x0=Symbol("remove node");function A$(D,R){let A=N9(R);if(t.isDocument(D)){if(W1(null,D.contents,A,Object.freeze([D]))===x0)D.contents=null}else W1(null,D,A,Object.freeze([]))}A$.BREAK=Z0;A$.SKIP=L9;A$.REMOVE=x0;function W1(D,R,A,$){let f=V9(D,R,A,$);if(t.isNode(f)||t.isPair(f))return I9(D,$,f),W1(D,f,A,$);if(typeof f!=="symbol"){if(t.isCollection(R)){$=Object.freeze($.concat(R));for(let P=0;P<R.items.length;++P){let B=W1(P,R.items[P],A,$);if(typeof B==="number")P=B-1;else if(B===Z0)return Z0;else if(B===x0)R.items.splice(P,1),P-=1}}else if(t.isPair(R)){$=Object.freeze($.concat(R));let P=W1("key",R.key,A,$);if(P===Z0)return Z0;else if(P===x0)R.key=null;let B=W1("value",R.value,A,$);if(B===Z0)return Z0;else if(B===x0)R.value=null}}return f}async function $$(D,R){let A=N9(R);if(t.isDocument(D)){if(await j1(null,D.contents,A,Object.freeze([D]))===x0)D.contents=null}else await j1(null,D,A,Object.freeze([]))}$$.BREAK=Z0;$$.SKIP=L9;$$.REMOVE=x0;async function j1(D,R,A,$){let f=await V9(D,R,A,$);if(t.isNode(f)||t.isPair(f))return I9(D,$,f),j1(D,f,A,$);if(typeof f!=="symbol"){if(t.isCollection(R)){$=Object.freeze($.concat(R));for(let P=0;P<R.items.length;++P){let B=await j1(P,R.items[P],A,$);if(typeof B==="number")P=B-1;else if(B===Z0)return Z0;else if(B===x0)R.items.splice(P,1),P-=1}}else if(t.isPair(R)){$=Object.freeze($.concat(R));let P=await j1("key",R.key,A,$);if(P===Z0)return Z0;else if(P===x0)R.key=null;let B=await j1("value",R.value,A,$);if(B===Z0)return Z0;else if(B===x0)R.value=null}}return f}function N9(D){if(typeof D==="object"&&(D.Collection||D.Node||D.Value))return Object.assign({Alias:D.Node,Map:D.Node,Scalar:D.Node,Seq:D.Node},D.Value&&{Map:D.Value,Scalar:D.Value,Seq:D.Value},D.Collection&&{Map:D.Collection,Seq:D.Collection},D);return D}function V9(D,R,A,$){if(typeof A==="function")return A(D,R,$);if(t.isMap(R))return A.Map?.(D,R,$);if(t.isSeq(R))return A.Seq?.(D,R,$);if(t.isPair(R))return A.Pair?.(D,R,$);if(t.isScalar(R))return A.Scalar?.(D,R,$);if(t.isAlias(R))return A.Alias?.(D,R,$);return}function I9(D,R,A){let $=R[R.length-1];if(t.isCollection($))$.items[D]=A;else if(t.isPair($))if(D==="key")$.key=A;else $.value=A;else if(t.isDocument($))$.contents=A;else{let f=t.isAlias($)?"alias":"scalar";throw Error(`Cannot replace node with ${f} parent`)}}CZ.visit=A$;CZ.visitAsync=$$});var f3=q((WZ)=>{var K9=m(),VZ=WR(),IZ={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},KZ=(D)=>D.replace(/[!,[\]{}]/g,(R)=>IZ[R]);class U0{constructor(D,R){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},U0.defaultYaml,D),this.tags=Object.assign({},U0.defaultTags,R)}clone(){let D=new U0(this.yaml,this.tags);return D.docStart=this.docStart,D}atDocument(){let D=new U0(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:U0.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},U0.defaultTags);break}return D}add(D,R){if(this.atNextDocument)this.yaml={explicit:U0.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},U0.defaultTags),this.atNextDocument=!1;let A=D.trim().split(/[ \t]+/),$=A.shift();switch($){case"%TAG":{if(A.length!==2){if(R(0,"%TAG directive should contain exactly two parts"),A.length<2)return!1}let[f,P]=A;return this.tags[f]=P,!0}case"%YAML":{if(this.yaml.explicit=!0,A.length!==1)return R(0,"%YAML directive should contain exactly one part"),!1;let[f]=A;if(f==="1.1"||f==="1.2")return this.yaml.version=f,!0;else{let P=/^\d+\.\d+$/.test(f);return R(6,`Unsupported YAML version ${f}`,P),!1}}default:return R(0,`Unknown directive ${$}`,!0),!1}}tagName(D,R){if(D==="!")return"!";if(D[0]!=="!")return R(`Not a valid tag: ${D}`),null;if(D[1]==="<"){let P=D.slice(2,-1);if(P==="!"||P==="!!")return R(`Verbatim tags aren't resolved, so ${D} is invalid.`),null;if(D[D.length-1]!==">")R("Verbatim tags must end with a >");return P}let[,A,$]=D.match(/^(.*!)([^!]*)$/s);if(!$)R(`The ${D} tag has no suffix`);let f=this.tags[A];if(f)try{return f+decodeURIComponent($)}catch(P){return R(String(P)),null}if(A==="!")return D;return R(`Could not resolve tag: ${D}`),null}tagString(D){for(let[R,A]of Object.entries(this.tags))if(D.startsWith(A))return R+KZ(D.substring(A.length));return D[0]==="!"?D:`!<${D}>`}toString(D){let R=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],A=Object.entries(this.tags),$;if(D&&A.length>0&&K9.isNode(D.contents)){let f={};VZ.visit(D.contents,(P,B)=>{if(K9.isNode(B)&&B.tag)f[B.tag]=!0}),$=Object.keys(f)}else $=[];for(let[f,P]of A){if(f==="!!"&&P==="tag:yaml.org,2002:")continue;if(!D||$.some((B)=>B.startsWith(P)))R.push(`%TAG ${f} ${P}`)}return R.join(`
27
27
  `)}}U0.defaultYaml={explicit:!1,version:"1.2"};U0.defaultTags={"!!":"tag:yaml.org,2002:"};WZ.Directives=U0});var f$=q((EZ)=>{var W9=m(),SZ=WR();function bZ(D){if(/[\x00-\x19\s,[\]{}]/.test(D)){let A=`Anchor must not contain whitespace or control characters: ${JSON.stringify(D)}`;throw Error(A)}return!0}function j9(D){let R=new Set;return SZ.visit(D,{Value(A,$){if($.anchor)R.add($.anchor)}}),R}function S9(D,R){for(let A=1;;++A){let $=`${D}${A}`;if(!R.has($))return $}}function uZ(D,R){let A=[],$=new Map,f=null;return{onAnchor:(P)=>{A.push(P),f??(f=j9(D));let B=S9(R,f);return f.add(B),B},setAnchors:()=>{for(let P of A){let B=$.get(P);if(typeof B==="object"&&B.anchor&&(W9.isScalar(B.node)||W9.isCollection(B.node)))B.node.anchor=B.anchor;else{let G=Error("Failed to resolve repeated object (this should not happen)");throw G.source=P,G}}},sourceObjects:$}}EZ.anchorIsValid=bZ;EZ.anchorNames=j9;EZ.createNodeAnchors=uZ;EZ.findNewAnchor=S9});var P3=q((nZ)=>{function jR(D,R,A,$){if($&&typeof $==="object")if(Array.isArray($))for(let f=0,P=$.length;f<P;++f){let B=$[f],G=jR(D,$,String(f),B);if(G===void 0)delete $[f];else if(G!==B)$[f]=G}else if($ instanceof Map)for(let f of Array.from($.keys())){let P=$.get(f),B=jR(D,$,f,P);if(B===void 0)$.delete(f);else if(B!==P)$.set(f,B)}else if($ instanceof Set)for(let f of Array.from($)){let P=jR(D,$,f,f);if(P===void 0)$.delete(f);else if(P!==f)$.delete(f),$.add(P)}else for(let[f,P]of Object.entries($)){let B=jR(D,$,f,P);if(B===void 0)delete $[f];else if(B!==P)$[f]=B}return D.call(R,A,$)}nZ.applyReviver=jR});var FD=q((vZ)=>{var hZ=m();function b9(D,R,A){if(Array.isArray(D))return D.map(($,f)=>b9($,String(f),A));if(D&&typeof D.toJSON==="function"){if(!A||!hZ.hasAnchor(D))return D.toJSON(R,A);let $={aliasCount:0,count:1,res:void 0};A.anchors.set(D,$),A.onCreate=(P)=>{$.res=P,delete A.onCreate};let f=D.toJSON(R,A);if(A.onCreate)A.onCreate(f);return f}if(typeof D==="bigint"&&!A?.keep)return Number(D);return D}vZ.toJS=b9});var P$=q((iZ)=>{var kZ=P3(),u9=m(),dZ=FD();class E9{constructor(D){Object.defineProperty(this,u9.NODE_TYPE,{value:D})}clone(){let D=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)D.range=this.range.slice();return D}toJS(D,{mapAsMap:R,maxAliasCount:A,onAnchor:$,reviver:f}={}){if(!u9.isDocument(D))throw TypeError("A document argument is required");let P={anchors:new Map,doc:D,keep:!0,mapAsMap:R===!0,mapKeyWarned:!1,maxAliasCount:typeof A==="number"?A:100},B=dZ.toJS(this,"",P);if(typeof $==="function")for(let{count:G,res:z}of P.anchors.values())$(z,G);return typeof f==="function"?kZ.applyReviver(f,{"":B},"",B):B}}iZ.NodeBase=E9});var SR=q((tZ)=>{var rZ=f$(),sZ=WR(),S1=m(),oZ=P$(),cZ=FD();class y9 extends oZ.NodeBase{constructor(D){super(S1.ALIAS);this.source=D,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(D,R){let A;if(R?.aliasResolveCache)A=R.aliasResolveCache;else if(A=[],sZ.visit(D,{Node:(f,P)=>{if(S1.isAlias(P)||S1.hasAnchor(P))A.push(P)}}),R)R.aliasResolveCache=A;let $=void 0;for(let f of A){if(f===this)break;if(f.anchor===this.source)$=f}return $}toJSON(D,R){if(!R)return{source:this.source};let{anchors:A,doc:$,maxAliasCount:f}=R,P=this.resolve($,R);if(!P){let G=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(G)}let B=A.get(P);if(!B)cZ.toJS(P,null,R),B=A.get(P);if(B?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(f>=0){if(B.count+=1,B.aliasCount===0)B.aliasCount=B$($,P,A);if(B.count*B.aliasCount>f)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return B.res}toString(D,R,A){let $=`*${this.source}`;if(D){if(rZ.anchorIsValid(this.source),D.options.verifyAliasOrder&&!D.anchors.has(this.source)){let f=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(f)}if(D.implicitKey)return`${$} `}return $}}function B$(D,R,A){if(S1.isAlias(R)){let $=R.resolve(D),f=A&&$&&A.get($);return f?f.count*f.aliasCount:0}else if(S1.isCollection(R)){let $=0;for(let f of R.items){let P=B$(D,f,A);if(P>$)$=P}return $}else if(S1.isPair(R)){let $=B$(D,R.key,A),f=B$(D,R.value,A);return Math.max($,f)}return 1}tZ.Alias=y9});var o=q((fM)=>{var DM=m(),RM=P$(),AM=FD(),$M=(D)=>!D||typeof D!=="function"&&typeof D!=="object";class tD extends RM.NodeBase{constructor(D){super(DM.SCALAR);this.value=D}toJSON(D,R){return R?.keep?this.value:AM.toJS(this.value,D,R)}toString(){return String(this.value)}}tD.BLOCK_FOLDED="BLOCK_FOLDED";tD.BLOCK_LITERAL="BLOCK_LITERAL";tD.PLAIN="PLAIN";tD.QUOTE_DOUBLE="QUOTE_DOUBLE";tD.QUOTE_SINGLE="QUOTE_SINGLE";fM.Scalar=tD;fM.isScalarValue=$M});var bR=q((ZM)=>{var GM=SR(),eD=m(),g9=o(),zM="tag:yaml.org,2002:";function JM(D,R,A){if(R){let $=A.filter((P)=>P.tag===R),f=$.find((P)=>!P.format)??$[0];if(!f)throw Error(`Tag ${R} not found`);return f}return A.find(($)=>$.identify?.(D)&&!$.format)}function HM(D,R,A){if(eD.isDocument(D))D=D.contents;if(eD.isNode(D))return D;if(eD.isPair(D)){let H=A.schema[eD.MAP].createNode?.(A.schema,null,A);return H.items.push(D),H}if(D instanceof String||D instanceof Number||D instanceof Boolean||typeof BigInt<"u"&&D instanceof BigInt)D=D.valueOf();let{aliasDuplicateObjects:$,onAnchor:f,onTagObj:P,schema:B,sourceObjects:G}=A,z=void 0;if($&&D&&typeof D==="object")if(z=G.get(D),z)return z.anchor??(z.anchor=f(D)),new GM.Alias(z.anchor);else z={anchor:null,node:null},G.set(D,z);if(R?.startsWith("!!"))R=zM+R.slice(2);let J=JM(D,R,B.tags);if(!J){if(D&&typeof D.toJSON==="function")D=D.toJSON();if(!D||typeof D!=="object"){let H=new g9.Scalar(D);if(z)z.node=H;return H}J=D instanceof Map?B[eD.MAP]:(Symbol.iterator in Object(D))?B[eD.SEQ]:B[eD.MAP]}if(P)P(J),delete A.onTagObj;let Z=J?.createNode?J.createNode(A.schema,D,A):typeof J?.nodeClass?.from==="function"?J.nodeClass.from(A.schema,D,A):new g9.Scalar(D);if(R)Z.tag=R;else if(!J.default)Z.tag=J.tag;if(z)z.node=Z;return Z}ZM.createNode=HM});var G$=q((TM)=>{var XM=bR(),n0=m(),QM=P$();function B3(D,R,A){let $=A;for(let f=R.length-1;f>=0;--f){let P=R[f];if(typeof P==="number"&&Number.isInteger(P)&&P>=0){let B=[];B[P]=$,$=B}else $=new Map([[P,$]])}return XM.createNode($,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:D,sourceObjects:new Map})}var m9=(D)=>D==null||typeof D==="object"&&!!D[Symbol.iterator]().next().done;class x9 extends QM.NodeBase{constructor(D,R){super(D);Object.defineProperty(this,"schema",{value:R,configurable:!0,enumerable:!1,writable:!0})}clone(D){let R=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(D)R.schema=D;if(R.items=R.items.map((A)=>n0.isNode(A)||n0.isPair(A)?A.clone(D):A),this.range)R.range=this.range.slice();return R}addIn(D,R){if(m9(D))this.add(R);else{let[A,...$]=D,f=this.get(A,!0);if(n0.isCollection(f))f.addIn($,R);else if(f===void 0&&this.schema)this.set(A,B3(this.schema,$,R));else throw Error(`Expected YAML collection at ${A}. Remaining path: ${$}`)}}deleteIn(D){let[R,...A]=D;if(A.length===0)return this.delete(R);let $=this.get(R,!0);if(n0.isCollection($))return $.deleteIn(A);else throw Error(`Expected YAML collection at ${R}. Remaining path: ${A}`)}getIn(D,R){let[A,...$]=D,f=this.get(A,!0);if($.length===0)return!R&&n0.isScalar(f)?f.value:f;else return n0.isCollection(f)?f.getIn($,R):void 0}hasAllNullValues(D){return this.items.every((R)=>{if(!n0.isPair(R))return!1;let A=R.value;return A==null||D&&n0.isScalar(A)&&A.value==null&&!A.commentBefore&&!A.comment&&!A.tag})}hasIn(D){let[R,...A]=D;if(A.length===0)return this.has(R);let $=this.get(R,!0);return n0.isCollection($)?$.hasIn(A):!1}setIn(D,R){let[A,...$]=D;if($.length===0)this.set(A,R);else{let f=this.get(A,!0);if(n0.isCollection(f))f.setIn($,R);else if(f===void 0&&this.schema)this.set(A,B3(this.schema,$,R));else throw Error(`Expected YAML collection at ${A}. Remaining path: ${$}`)}}}TM.Collection=x9;TM.collectionFromPath=B3;TM.isEmptyPath=m9});var uR=q((qM)=>{var UM=(D)=>D.replace(/^(?!$)(?: $)?/gm,"#");function G3(D,R){if(/^\n+$/.test(D))return D.substring(1);return R?D.replace(/^(?! *$)/gm,R):D}var FM=(D,R,A)=>D.endsWith(`
28
28
  `)?G3(A,R):A.includes(`
29
29
  `)?`
@@ -161,40 +161,40 @@ ${R.comment}`:R.comment}this.doc.range[2]=R.offset;break}default:this.errors.pus
161
161
  `)+1;while(R!==0)this.onNewLine(this.offset+R),R=this.source.indexOf(`
162
162
  `,R)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(D){let R=D.items[D.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,R.value){let A="end"in R.value?R.value.end:void 0;if((Array.isArray(A)?A[A.length-1]:void 0)?.type==="comment")A?.push(this.sourceToken);else D.items.push({start:[this.sourceToken]})}else if(R.sep)R.sep.push(this.sourceToken);else R.start.push(this.sourceToken);return;case"space":case"comment":if(R.value)D.items.push({start:[this.sourceToken]});else if(R.sep)R.sep.push(this.sourceToken);else{if(this.atIndentedComment(R.start,D.indent)){let $=D.items[D.items.length-2]?.value?.end;if(Array.isArray($)){Array.prototype.push.apply($,R.start),$.push(this.sourceToken),D.items.pop();return}}R.start.push(this.sourceToken)}return}if(this.indent>=D.indent){let A=!this.onKeyLine&&this.indent===D.indent,$=A&&(R.sep||R.explicitKey)&&this.type!=="seq-item-ind",f=[];if($&&R.sep&&!R.value){let P=[];for(let B=0;B<R.sep.length;++B){let G=R.sep[B];switch(G.type){case"newline":P.push(B);break;case"space":break;case"comment":if(G.indent>D.indent)P.length=0;break;default:P.length=0}}if(P.length>=2)f=R.sep.splice(P[1])}switch(this.type){case"anchor":case"tag":if($||R.value)f.push(this.sourceToken),D.items.push({start:f}),this.onKeyLine=!0;else if(R.sep)R.sep.push(this.sourceToken);else R.start.push(this.sourceToken);return;case"explicit-key-ind":if(!R.sep&&!R.explicitKey)R.start.push(this.sourceToken),R.explicitKey=!0;else if($||R.value)f.push(this.sourceToken),D.items.push({start:f,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(R.explicitKey)if(!R.sep)if(ID(R.start,"newline"))Object.assign(R,{key:null,sep:[this.sourceToken]});else{let P=n1(R.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:P,key:null,sep:[this.sourceToken]}]})}else if(R.value)D.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ID(R.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:f,key:null,sep:[this.sourceToken]}]});else if(FB(R.key)&&!ID(R.sep,"newline")){let P=n1(R.start),B=R.key,G=R.sep;G.push(this.sourceToken),delete R.key,delete R.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:P,key:B,sep:G}]})}else if(f.length>0)R.sep=R.sep.concat(f,this.sourceToken);else R.sep.push(this.sourceToken);else if(!R.sep)Object.assign(R,{key:null,sep:[this.sourceToken]});else if(R.value||$)D.items.push({start:f,key:null,sep:[this.sourceToken]});else if(ID(R.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else R.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let P=this.flowScalar(this.type);if($||R.value)D.items.push({start:f,key:P,sep:[]}),this.onKeyLine=!0;else if(R.sep)this.stack.push(P);else Object.assign(R,{key:P,sep:[]}),this.onKeyLine=!0;return}default:{let P=this.startBlockValue(D);if(P){if(P.type==="block-seq"){if(!R.explicitKey&&R.sep&&!ID(R.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(A)D.items.push({start:f});this.stack.push(P);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(D){let R=D.items[D.items.length-1];switch(this.type){case"newline":if(R.value){let A="end"in R.value?R.value.end:void 0;if((Array.isArray(A)?A[A.length-1]:void 0)?.type==="comment")A?.push(this.sourceToken);else D.items.push({start:[this.sourceToken]})}else R.start.push(this.sourceToken);return;case"space":case"comment":if(R.value)D.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(R.start,D.indent)){let $=D.items[D.items.length-2]?.value?.end;if(Array.isArray($)){Array.prototype.push.apply($,R.start),$.push(this.sourceToken),D.items.pop();return}}R.start.push(this.sourceToken)}return;case"anchor":case"tag":if(R.value||this.indent<=D.indent)break;R.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==D.indent)break;if(R.value||ID(R.start,"seq-item-ind"))D.items.push({start:[this.sourceToken]});else R.start.push(this.sourceToken);return}if(this.indent>D.indent){let A=this.startBlockValue(D);if(A){this.stack.push(A);return}}yield*this.pop(),yield*this.step()}*flowCollection(D){let R=D.items[D.items.length-1];if(this.type==="flow-error-end"){let A;do yield*this.pop(),A=this.peek(1);while(A?.type==="flow-collection")}else if(D.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!R||R.sep)D.items.push({start:[this.sourceToken]});else R.start.push(this.sourceToken);return;case"map-value-ind":if(!R||R.value)D.items.push({start:[],key:null,sep:[this.sourceToken]});else if(R.sep)R.sep.push(this.sourceToken);else Object.assign(R,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!R||R.value)D.items.push({start:[this.sourceToken]});else if(R.sep)R.sep.push(this.sourceToken);else R.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let $=this.flowScalar(this.type);if(!R||R.value)D.items.push({start:[],key:$,sep:[]});else if(R.sep)this.stack.push($);else Object.assign(R,{key:$,sep:[]});return}case"flow-map-end":case"flow-seq-end":D.end.push(this.sourceToken);return}let A=this.startBlockValue(D);if(A)this.stack.push(A);else yield*this.pop(),yield*this.step()}else{let A=this.peek(2);if(A.type==="block-map"&&(this.type==="map-value-ind"&&A.indent===D.indent||this.type==="newline"&&!A.items[A.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&A.type!=="flow-collection"){let $=n$(A),f=n1($);UB(D);let P=D.end.splice(1,D.end.length);P.push(this.sourceToken);let B={type:"block-map",offset:D.offset,indent:D.indent,items:[{start:f,key:D,sep:P}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=B}else yield*this.lineEnd(D)}}flowScalar(D){if(this.onNewLine){let R=this.source.indexOf(`
163
163
  `)+1;while(R!==0)this.onNewLine(this.offset+R),R=this.source.indexOf(`
164
- `,R)+1}return{type:D,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(D){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let R=n$(D),A=n1(R);return A.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:A,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let R=n$(D),A=n1(R);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:A,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(D,R){if(this.type!=="comment")return!1;if(this.indent<=R)return!1;return D.every((A)=>A.type==="newline"||A.type==="space")}*documentEnd(D){if(this.type!=="doc-mode"){if(D.end)D.end.push(this.sourceToken);else D.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(D){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(D.end)D.end.push(this.sourceToken);else D.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}o_.Parser=qB});var VB=q((PU)=>{var wB=DP(),t_=iR(),tR=aR(),e_=H3(),DU=m(),RU=HP(),CB=ZP();function LB(D){let R=D.prettyErrors!==!1;return{lineCounter:D.lineCounter||R&&new RU.LineCounter||null,prettyErrors:R}}function AU(D,R={}){let{lineCounter:A,prettyErrors:$}=LB(R),f=new CB.Parser(A?.addNewLine),P=new wB.Composer(R),B=Array.from(P.compose(f.parse(D)));if($&&A)for(let G of B)G.errors.forEach(tR.prettifyError(D,A)),G.warnings.forEach(tR.prettifyError(D,A));if(B.length>0)return B;return Object.assign([],{empty:!0},P.streamInfo())}function NB(D,R={}){let{lineCounter:A,prettyErrors:$}=LB(R),f=new CB.Parser(A?.addNewLine),P=new wB.Composer(R),B=null;for(let G of P.compose(f.parse(D),!0,D.length))if(!B)B=G;else if(B.options.logLevel!=="silent"){B.errors.push(new tR.YAMLParseError(G.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if($&&A)B.errors.forEach(tR.prettifyError(D,A)),B.warnings.forEach(tR.prettifyError(D,A));return B}function $U(D,R,A){let $=void 0;if(typeof R==="function")$=R;else if(A===void 0&&R&&typeof R==="object")A=R;let f=NB(D,A);if(!f)return null;if(f.warnings.forEach((P)=>e_.warn(f.options.logLevel,P)),f.errors.length>0)if(f.options.logLevel!=="silent")throw f.errors[0];else f.errors=[];return f.toJS(Object.assign({reviver:$},A))}function fU(D,R,A){let $=null;if(typeof R==="function"||Array.isArray(R))$=R;else if(A===void 0&&R)A=R;if(typeof A==="string")A=A.length;if(typeof A==="number"){let f=Math.round(A);A=f<1?void 0:f>8?{indent:8}:{indent:f}}if(D===void 0){let{keepUndefined:f}=A??R??{};if(!f)return}if(DU.isDocument(D)&&!$)return D.toString(A);return new t_.Document(D,$,A).toString(A)}PU.parse=$U;PU.parseAllDocuments=AU;PU.parseDocument=NB;PU.stringify=fU});var KB=q((wU)=>{var HU=DP(),ZU=iR(),MU=x3(),MP=aR(),XU=SR(),KD=m(),QU=CD(),TU=o(),OU=ND(),YU=VD(),_U=m$(),UU=JP(),FU=HP(),qU=ZP(),p$=VB(),IB=WR();wU.Composer=HU.Composer;wU.Document=ZU.Document;wU.Schema=MU.Schema;wU.YAMLError=MP.YAMLError;wU.YAMLParseError=MP.YAMLParseError;wU.YAMLWarning=MP.YAMLWarning;wU.Alias=XU.Alias;wU.isAlias=KD.isAlias;wU.isCollection=KD.isCollection;wU.isDocument=KD.isDocument;wU.isMap=KD.isMap;wU.isNode=KD.isNode;wU.isPair=KD.isPair;wU.isScalar=KD.isScalar;wU.isSeq=KD.isSeq;wU.Pair=QU.Pair;wU.Scalar=TU.Scalar;wU.YAMLMap=OU.YAMLMap;wU.YAMLSeq=YU.YAMLSeq;wU.CST=_U;wU.Lexer=UU.Lexer;wU.LineCounter=FU.LineCounter;wU.Parser=qU.Parser;wU.parse=p$.parse;wU.parseAllDocuments=p$.parseAllDocuments;wU.parseDocument=p$.parseDocument;wU.stringify=p$.stringify;wU.visit=IB.visit;wU.visitAsync=IB.visitAsync});var FG=q((LS,I2)=>{function ZG(D){return Array.isArray(D)?D:[D]}var Qw=void 0,L6="",JG=" ",C6="\\",Tw=/^\s+$/,Ow=/(?:[^\\]|^)\\$/,Yw=/^\\!/,_w=/^\\#/,Uw=/\r?\n/g,Fw=/^\.{0,2}\/|^\.{1,2}$/,qw=/\/$/,t1="/",MG="node-ignore";if(typeof Symbol<"u")MG=Symbol.for("node-ignore");var XG=MG,e1=(D,R,A)=>{return Object.defineProperty(D,R,{value:A}),A},ww=/([0-z])-([0-z])/g,QG=()=>!1,Cw=(D)=>D.replace(ww,(R,A,$)=>A.charCodeAt(0)<=$.charCodeAt(0)?R:L6),Lw=(D)=>{let{length:R}=D;return D.slice(0,R-R%2)},Nw=[[/^\uFEFF/,()=>L6],[/((?:\\\\)*?)(\\?\s+)$/,(D,R,A)=>R+(A.indexOf("\\")===0?JG:L6)],[/(\\+?)\s/g,(D,R)=>{let{length:A}=R;return R.slice(0,A-A%2)+JG}],[/[\\$.|*+(){^]/g,(D)=>`\\${D}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return!/\/(?!$)/.test(this)?"(?:^|\\/)":"^"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(D,R,A)=>R+6<A.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(D,R,A)=>{let $=A.replace(/\\\*/g,"[^\\/]*");return R+$}],[/\\\\\\(?=[$.|*+(){^])/g,()=>C6],[/\\\\/g,()=>C6],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(D,R,A,$,f)=>R===C6?`\\[${A}${Lw($)}${f}`:f==="]"?$.length%2===0?`[${Cw(A)}${$}]`:"[]":"[]"],[/(?:[^*])$/,(D)=>/\/$/.test(D)?`${D}$`:`${D}(?=$|\\/$)`]],Vw=/(^|\\\/)?\\\*$/,CA="regex",N2="checkRegex",HG="_",Iw={[CA](D,R){return`${R?`${R}[^/]+`:"[^/]*"}(?=$|\\/$)`},[N2](D,R){return`${R?`${R}[^/]*`:"[^/]*"}(?=$|\\/$)`}},Kw=(D)=>Nw.reduce((R,[A,$])=>R.replace(A,$.bind(D)),D),V2=(D)=>typeof D==="string",Ww=(D)=>D&&V2(D)&&!Tw.test(D)&&!Ow.test(D)&&D.indexOf("#")!==0,jw=(D)=>D.split(Uw).filter(Boolean);class TG{constructor(D,R,A,$,f,P){this.pattern=D,this.mark=R,this.negative=f,e1(this,"body",A),e1(this,"ignoreCase",$),e1(this,"regexPrefix",P)}get regex(){let D=HG+CA;if(this[D])return this[D];return this._make(CA,D)}get checkRegex(){let D=HG+N2;if(this[D])return this[D];return this._make(N2,D)}_make(D,R){let A=this.regexPrefix.replace(Vw,Iw[D]),$=this.ignoreCase?new RegExp(A,"i"):new RegExp(A);return e1(this,R,$)}}var Sw=({pattern:D,mark:R},A)=>{let $=!1,f=D;if(f.indexOf("!")===0)$=!0,f=f.substr(1);f=f.replace(Yw,"!").replace(_w,"#");let P=Kw(f);return new TG(D,R,f,A,$,P)};class OG{constructor(D){this._ignoreCase=D,this._rules=[]}_add(D){if(D&&D[XG]){this._rules=this._rules.concat(D._rules._rules),this._added=!0;return}if(V2(D))D={pattern:D};if(Ww(D.pattern)){let R=Sw(D,this._ignoreCase);this._added=!0,this._rules.push(R)}}add(D){return this._added=!1,ZG(V2(D)?jw(D):D).forEach(this._add,this),this._added}test(D,R,A){let $=!1,f=!1,P;this._rules.forEach((G)=>{let{negative:z}=G;if(f===z&&$!==f||z&&!$&&!f&&!R)return;if(!G[A].test(D))return;$=!z,f=z,P=z?Qw:G});let B={ignored:$,unignored:f};if(P)B.rule=P;return B}}var bw=(D,R)=>{throw new R(D)},MD=(D,R,A)=>{if(!V2(D))return A(`path must be a string, but got \`${R}\``,TypeError);if(!D)return A("path must not be empty",TypeError);if(MD.isNotRelative(D))return A(`path should be a \`path.relative()\`d string, but got "${R}"`,RangeError);return!0},YG=(D)=>Fw.test(D);MD.isNotRelative=YG;MD.convert=(D)=>D;class _G{constructor({ignorecase:D=!0,ignoreCase:R=D,allowRelativePaths:A=!1}={}){e1(this,XG,!0),this._rules=new OG(R),this._strictPathCheck=!A,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(D){if(this._rules.add(D))this._initCache();return this}addPattern(D){return this.add(D)}_test(D,R,A,$){let f=D&&MD.convert(D);return MD(f,D,this._strictPathCheck?bw:QG),this._t(f,R,A,$)}checkIgnore(D){if(!qw.test(D))return this.test(D);let R=D.split(t1).filter(Boolean);if(R.pop(),R.length){let A=this._t(R.join(t1)+t1,this._testCache,!0,R);if(A.ignored)return A}return this._rules.test(D,!1,N2)}_t(D,R,A,$){if(D in R)return R[D];if(!$)$=D.split(t1).filter(Boolean);if($.pop(),!$.length)return R[D]=this._rules.test(D,A,CA);let f=this._t($.join(t1)+t1,R,A,$);return R[D]=f.ignored?f:this._rules.test(D,A,CA)}ignores(D){return this._test(D,this._ignoreCache,!1).ignored}createFilter(){return(D)=>!this.ignores(D)}filter(D){return ZG(D).filter(this.createFilter())}test(D){return this._test(D,this._testCache,!0)}}var N6=(D)=>new _G(D),uw=(D)=>MD(D&&MD.convert(D),D,QG),UG=()=>{let D=(A)=>/^\\\\\?\\/.test(A)||/["<>|\u0000-\u001F]+/u.test(A)?A:A.replace(/\\/g,"/");MD.convert=D;let R=/^[a-z]:\//i;MD.isNotRelative=(A)=>R.test(A)||YG(A)};if(typeof process<"u"&&process.platform==="win32")UG();I2.exports=N6;N6.default=N6;I2.exports.isPathValid=uw;e1(I2.exports,Symbol.for("setupWindows"),UG)});var QD=q((nb,Jz)=>{var Gz=["nodebuffer","arraybuffer","fragments"],zz=typeof Blob<"u";if(zz)Gz.push("blob");Jz.exports={BINARY_TYPES:Gz,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:zz,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var NA=q((pb,g2)=>{var{EMPTY_BUFFER:FC}=QD(),u6=Buffer[Symbol.species];function qC(D,R){if(D.length===0)return FC;if(D.length===1)return D[0];let A=Buffer.allocUnsafe(R),$=0;for(let f=0;f<D.length;f++){let P=D[f];A.set(P,$),$+=P.length}if($<R)return new u6(A.buffer,A.byteOffset,$);return A}function Hz(D,R,A,$,f){for(let P=0;P<f;P++)A[$+P]=D[P]^R[P&3]}function Zz(D,R){for(let A=0;A<D.length;A++)D[A]^=R[A&3]}function wC(D){if(D.length===D.buffer.byteLength)return D.buffer;return D.buffer.slice(D.byteOffset,D.byteOffset+D.length)}function E6(D){if(E6.readOnly=!0,Buffer.isBuffer(D))return D;let R;if(D instanceof ArrayBuffer)R=new u6(D);else if(ArrayBuffer.isView(D))R=new u6(D.buffer,D.byteOffset,D.byteLength);else R=Buffer.from(D),E6.readOnly=!1;return R}g2.exports={concat:qC,mask:Hz,toArrayBuffer:wC,toBuffer:E6,unmask:Zz};if(!process.env.WS_NO_BUFFER_UTIL)try{let D=(()=>{throw new Error("Cannot require module "+"bufferutil");})();g2.exports.mask=function(R,A,$,f,P){if(P<48)Hz(R,A,$,f,P);else D.mask(R,A,$,f,P)},g2.exports.unmask=function(R,A){if(R.length<32)Zz(R,A);else D.unmask(R,A)}}catch(D){}});var Tz=q((hb,Qz)=>{var Mz=Symbol("kDone"),y6=Symbol("kRun");class Xz{constructor(D){this[Mz]=()=>{this.pending--,this[y6]()},this.concurrency=D||1/0,this.jobs=[],this.pending=0}add(D){this.jobs.push(D),this[y6]()}[y6](){if(this.pending===this.concurrency)return;if(this.jobs.length){let D=this.jobs.shift();this.pending++,D(this[Mz])}}}Qz.exports=Xz});var fR=q((vb,Fz)=>{var VA=p("zlib"),Oz=NA(),CC=Tz(),{kStatusCode:Yz}=QD(),LC=Buffer[Symbol.species],NC=Buffer.from([0,0,255,255]),x2=Symbol("permessage-deflate"),TD=Symbol("total-length"),AR=Symbol("callback"),pD=Symbol("buffers"),$R=Symbol("error"),m2;class _z{constructor(D){if(this._options=D||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!m2){let R=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;m2=new CC(R)}}static get extensionName(){return"permessage-deflate"}offer(){let D={};if(this._options.serverNoContextTakeover)D.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)D.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)D.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)D.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)D.client_max_window_bits=!0;return D}accept(D){return D=this.normalizeParams(D),this.params=this._isServer?this.acceptAsServer(D):this.acceptAsClient(D),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let D=this._deflate[AR];if(this._deflate.close(),this._deflate=null,D)D(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(D){let R=this._options,A=D.find(($)=>{if(R.serverNoContextTakeover===!1&&$.server_no_context_takeover||$.server_max_window_bits&&(R.serverMaxWindowBits===!1||typeof R.serverMaxWindowBits==="number"&&R.serverMaxWindowBits>$.server_max_window_bits)||typeof R.clientMaxWindowBits==="number"&&!$.client_max_window_bits)return!1;return!0});if(!A)throw Error("None of the extension offers can be accepted");if(R.serverNoContextTakeover)A.server_no_context_takeover=!0;if(R.clientNoContextTakeover)A.client_no_context_takeover=!0;if(typeof R.serverMaxWindowBits==="number")A.server_max_window_bits=R.serverMaxWindowBits;if(typeof R.clientMaxWindowBits==="number")A.client_max_window_bits=R.clientMaxWindowBits;else if(A.client_max_window_bits===!0||R.clientMaxWindowBits===!1)delete A.client_max_window_bits;return A}acceptAsClient(D){let R=D[0];if(this._options.clientNoContextTakeover===!1&&R.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!R.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")R.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&R.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return R}normalizeParams(D){return D.forEach((R)=>{Object.keys(R).forEach((A)=>{let $=R[A];if($.length>1)throw Error(`Parameter "${A}" must have only a single value`);if($=$[0],A==="client_max_window_bits"){if($!==!0){let f=+$;if(!Number.isInteger(f)||f<8||f>15)throw TypeError(`Invalid value for parameter "${A}": ${$}`);$=f}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${A}": ${$}`)}else if(A==="server_max_window_bits"){let f=+$;if(!Number.isInteger(f)||f<8||f>15)throw TypeError(`Invalid value for parameter "${A}": ${$}`);$=f}else if(A==="client_no_context_takeover"||A==="server_no_context_takeover"){if($!==!0)throw TypeError(`Invalid value for parameter "${A}": ${$}`)}else throw Error(`Unknown parameter "${A}"`);R[A]=$})}),D}decompress(D,R,A){m2.add(($)=>{this._decompress(D,R,(f,P)=>{$(),A(f,P)})})}compress(D,R,A){m2.add(($)=>{this._compress(D,R,(f,P)=>{$(),A(f,P)})})}_decompress(D,R,A){let $=this._isServer?"client":"server";if(!this._inflate){let f=`${$}_max_window_bits`,P=typeof this.params[f]!=="number"?VA.Z_DEFAULT_WINDOWBITS:this.params[f];this._inflate=VA.createInflateRaw({...this._options.zlibInflateOptions,windowBits:P}),this._inflate[x2]=this,this._inflate[TD]=0,this._inflate[pD]=[],this._inflate.on("error",IC),this._inflate.on("data",Uz)}if(this._inflate[AR]=A,this._inflate.write(D),R)this._inflate.write(NC);this._inflate.flush(()=>{let f=this._inflate[$R];if(f){this._inflate.close(),this._inflate=null,A(f);return}let P=Oz.concat(this._inflate[pD],this._inflate[TD]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[TD]=0,this._inflate[pD]=[],R&&this.params[`${$}_no_context_takeover`])this._inflate.reset();A(null,P)})}_compress(D,R,A){let $=this._isServer?"server":"client";if(!this._deflate){let f=`${$}_max_window_bits`,P=typeof this.params[f]!=="number"?VA.Z_DEFAULT_WINDOWBITS:this.params[f];this._deflate=VA.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:P}),this._deflate[TD]=0,this._deflate[pD]=[],this._deflate.on("data",VC)}this._deflate[AR]=A,this._deflate.write(D),this._deflate.flush(VA.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let f=Oz.concat(this._deflate[pD],this._deflate[TD]);if(R)f=new LC(f.buffer,f.byteOffset,f.length-4);if(this._deflate[AR]=null,this._deflate[TD]=0,this._deflate[pD]=[],R&&this.params[`${$}_no_context_takeover`])this._deflate.reset();A(null,f)})}}Fz.exports=_z;function VC(D){this[pD].push(D),this[TD]+=D.length}function Uz(D){if(this[TD]+=D.length,this[x2]._maxPayload<1||this[TD]<=this[x2]._maxPayload){this[pD].push(D);return}this[$R]=RangeError("Max payload size exceeded"),this[$R].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[$R][Yz]=1009,this.removeListener("data",Uz),this.reset()}function IC(D){if(this[x2]._inflate=null,this[$R]){this[AR](this[$R]);return}D[Yz]=1007,this[AR](D)}});var PR=q((lb,n2)=>{var{isUtf8:qz}=p("buffer"),{hasBlob:KC}=QD(),WC=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function jC(D){return D>=1000&&D<=1014&&D!==1004&&D!==1005&&D!==1006||D>=3000&&D<=4999}function g6(D){let R=D.length,A=0;while(A<R)if((D[A]&128)===0)A++;else if((D[A]&224)===192){if(A+1===R||(D[A+1]&192)!==128||(D[A]&254)===192)return!1;A+=2}else if((D[A]&240)===224){if(A+2>=R||(D[A+1]&192)!==128||(D[A+2]&192)!==128||D[A]===224&&(D[A+1]&224)===128||D[A]===237&&(D[A+1]&224)===160)return!1;A+=3}else if((D[A]&248)===240){if(A+3>=R||(D[A+1]&192)!==128||(D[A+2]&192)!==128||(D[A+3]&192)!==128||D[A]===240&&(D[A+1]&240)===128||D[A]===244&&D[A+1]>143||D[A]>244)return!1;A+=4}else return!1;return!0}function SC(D){return KC&&typeof D==="object"&&typeof D.arrayBuffer==="function"&&typeof D.type==="string"&&typeof D.stream==="function"&&(D[Symbol.toStringTag]==="Blob"||D[Symbol.toStringTag]==="File")}n2.exports={isBlob:SC,isValidStatusCode:jC,isValidUTF8:g6,tokenChars:WC};if(qz)n2.exports.isValidUTF8=function(D){return D.length<24?g6(D):qz(D)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let D=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();n2.exports.isValidUTF8=function(R){return R.length<32?g6(R):D(R)}}catch(D){}});var x6=q((kb,Vz)=>{var{Writable:bC}=p("stream"),wz=fR(),{BINARY_TYPES:uC,EMPTY_BUFFER:Cz,kStatusCode:EC,kWebSocket:yC}=QD(),{concat:m6,toArrayBuffer:gC,unmask:mC}=NA(),{isValidStatusCode:xC,isValidUTF8:Lz}=PR(),p2=Buffer[Symbol.species];class Nz extends bC{constructor(D={}){super();this._allowSynchronousEvents=D.allowSynchronousEvents!==void 0?D.allowSynchronousEvents:!0,this._binaryType=D.binaryType||uC[0],this._extensions=D.extensions||{},this._isServer=!!D.isServer,this._maxPayload=D.maxPayload|0,this._skipUTF8Validation=!!D.skipUTF8Validation,this[yC]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(D,R,A){if(this._opcode===8&&this._state==0)return A();this._bufferedBytes+=D.length,this._buffers.push(D),this.startLoop(A)}consume(D){if(this._bufferedBytes-=D,D===this._buffers[0].length)return this._buffers.shift();if(D<this._buffers[0].length){let A=this._buffers[0];return this._buffers[0]=new p2(A.buffer,A.byteOffset+D,A.length-D),new p2(A.buffer,A.byteOffset,D)}let R=Buffer.allocUnsafe(D);do{let A=this._buffers[0],$=R.length-D;if(D>=A.length)R.set(this._buffers.shift(),$);else R.set(new Uint8Array(A.buffer,A.byteOffset,D),$),this._buffers[0]=new p2(A.buffer,A.byteOffset+D,A.length-D);D-=A.length}while(D>0);return R}startLoop(D){this._loop=!0;do switch(this._state){case 0:this.getInfo(D);break;case 1:this.getPayloadLength16(D);break;case 2:this.getPayloadLength64(D);break;case 3:this.getMask();break;case 4:this.getData(D);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)D()}getInfo(D){if(this._bufferedBytes<2){this._loop=!1;return}let R=this.consume(2);if((R[0]&48)!==0){let $=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");D($);return}let A=(R[0]&64)===64;if(A&&!this._extensions[wz.extensionName]){let $=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");D($);return}if(this._fin=(R[0]&128)===128,this._opcode=R[0]&15,this._payloadLength=R[1]&127,this._opcode===0){if(A){let $=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");D($);return}if(!this._fragmented){let $=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");D($);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let $=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");D($);return}this._compressed=A}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let $=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");D($);return}if(A){let $=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");D($);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let $=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");D($);return}}else{let $=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");D($);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(R[1]&128)===128,this._isServer){if(!this._masked){let $=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");D($);return}}else if(this._masked){let $=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");D($);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength(D)}getPayloadLength16(D){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(D)}getPayloadLength64(D){if(this._bufferedBytes<8){this._loop=!1;return}let R=this.consume(8),A=R.readUInt32BE(0);if(A>Math.pow(2,21)-1){let $=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");D($);return}this._payloadLength=A*Math.pow(2,32)+R.readUInt32BE(4),this.haveLength(D)}haveLength(D){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let R=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");D(R);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(D){let R=Cz;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(R=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)mC(R,this._mask)}if(this._opcode>7){this.controlMessage(R,D);return}if(this._compressed){this._state=5,this.decompress(R,D);return}if(R.length)this._messageLength=this._totalPayloadLength,this._fragments.push(R);this.dataMessage(D)}decompress(D,R){this._extensions[wz.extensionName].decompress(D,this._fin,($,f)=>{if($)return R($);if(f.length){if(this._messageLength+=f.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let P=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");R(P);return}this._fragments.push(f)}if(this.dataMessage(R),this._state===0)this.startLoop(R)})}dataMessage(D){if(!this._fin){this._state=0;return}let R=this._messageLength,A=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let $;if(this._binaryType==="nodebuffer")$=m6(A,R);else if(this._binaryType==="arraybuffer")$=gC(m6(A,R));else if(this._binaryType==="blob")$=new Blob(A);else $=A;if(this._allowSynchronousEvents)this.emit("message",$,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",$,!0),this._state=0,this.startLoop(D)})}else{let $=m6(A,R);if(!this._skipUTF8Validation&&!Lz($)){let f=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");D(f);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",$,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",$,!1),this._state=0,this.startLoop(D)})}}controlMessage(D,R){if(this._opcode===8){if(D.length===0)this._loop=!1,this.emit("conclude",1005,Cz),this.end();else{let A=D.readUInt16BE(0);if(!xC(A)){let f=this.createError(RangeError,`invalid status code ${A}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");R(f);return}let $=new p2(D.buffer,D.byteOffset+2,D.length-2);if(!this._skipUTF8Validation&&!Lz($)){let f=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");R(f);return}this._loop=!1,this.emit("conclude",A,$),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",D),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",D),this._state=0,this.startLoop(R)})}createError(D,R,A,$,f){this._loop=!1,this._errored=!0;let P=new D(A?`Invalid WebSocket frame: ${R}`:R);return Error.captureStackTrace(P,this.createError),P.code=f,P[EC]=$,P}}Vz.exports=Nz});var p6=q((ib,Wz)=>{var{Duplex:db}=p("stream"),{randomFillSync:nC}=p("crypto"),Iz=fR(),{EMPTY_BUFFER:pC,kWebSocket:hC,NOOP:vC}=QD(),{isBlob:BR,isValidStatusCode:lC}=PR(),{mask:Kz,toBuffer:F1}=NA(),C0=Symbol("kByteLength"),kC=Buffer.alloc(4),q1,GR=8192,y0=0,dC=1,iC=2;class hD{constructor(D,R,A){if(this._extensions=R||{},A)this._generateMask=A,this._maskBuffer=Buffer.alloc(4);this._socket=D,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=y0,this.onerror=vC,this[hC]=void 0}static frame(D,R){let A,$=!1,f=2,P=!1;if(R.mask){if(A=R.maskBuffer||kC,R.generateMask)R.generateMask(A);else{if(GR===8192){if(q1===void 0)q1=Buffer.alloc(8192);nC(q1,0,8192),GR=0}A[0]=q1[GR++],A[1]=q1[GR++],A[2]=q1[GR++],A[3]=q1[GR++]}P=(A[0]|A[1]|A[2]|A[3])===0,f=6}let B;if(typeof D==="string")if((!R.mask||P)&&R[C0]!==void 0)B=R[C0];else D=Buffer.from(D),B=D.length;else B=D.length,$=R.mask&&R.readOnly&&!P;let G=B;if(B>=65536)f+=8,G=127;else if(B>125)f+=2,G=126;let z=Buffer.allocUnsafe($?B+f:f);if(z[0]=R.fin?R.opcode|128:R.opcode,R.rsv1)z[0]|=64;if(z[1]=G,G===126)z.writeUInt16BE(B,2);else if(G===127)z[2]=z[3]=0,z.writeUIntBE(B,4,6);if(!R.mask)return[z,D];if(z[1]|=128,z[f-4]=A[0],z[f-3]=A[1],z[f-2]=A[2],z[f-1]=A[3],P)return[z,D];if($)return Kz(D,A,z,f,B),[z];return Kz(D,A,D,0,B),[z,D]}close(D,R,A,$){let f;if(D===void 0)f=pC;else if(typeof D!=="number"||!lC(D))throw TypeError("First argument must be a valid error code number");else if(R===void 0||!R.length)f=Buffer.allocUnsafe(2),f.writeUInt16BE(D,0);else{let B=Buffer.byteLength(R);if(B>123)throw RangeError("The message must not be greater than 123 bytes");if(f=Buffer.allocUnsafe(2+B),f.writeUInt16BE(D,0),typeof R==="string")f.write(R,2);else f.set(R,2)}let P={[C0]:f.length,fin:!0,generateMask:this._generateMask,mask:A,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==y0)this.enqueue([this.dispatch,f,!1,P,$]);else this.sendFrame(hD.frame(f,P),$)}ping(D,R,A){let $,f;if(typeof D==="string")$=Buffer.byteLength(D),f=!1;else if(BR(D))$=D.size,f=!1;else D=F1(D),$=D.length,f=F1.readOnly;if($>125)throw RangeError("The data size must not be greater than 125 bytes");let P={[C0]:$,fin:!0,generateMask:this._generateMask,mask:R,maskBuffer:this._maskBuffer,opcode:9,readOnly:f,rsv1:!1};if(BR(D))if(this._state!==y0)this.enqueue([this.getBlobData,D,!1,P,A]);else this.getBlobData(D,!1,P,A);else if(this._state!==y0)this.enqueue([this.dispatch,D,!1,P,A]);else this.sendFrame(hD.frame(D,P),A)}pong(D,R,A){let $,f;if(typeof D==="string")$=Buffer.byteLength(D),f=!1;else if(BR(D))$=D.size,f=!1;else D=F1(D),$=D.length,f=F1.readOnly;if($>125)throw RangeError("The data size must not be greater than 125 bytes");let P={[C0]:$,fin:!0,generateMask:this._generateMask,mask:R,maskBuffer:this._maskBuffer,opcode:10,readOnly:f,rsv1:!1};if(BR(D))if(this._state!==y0)this.enqueue([this.getBlobData,D,!1,P,A]);else this.getBlobData(D,!1,P,A);else if(this._state!==y0)this.enqueue([this.dispatch,D,!1,P,A]);else this.sendFrame(hD.frame(D,P),A)}send(D,R,A){let $=this._extensions[Iz.extensionName],f=R.binary?2:1,P=R.compress,B,G;if(typeof D==="string")B=Buffer.byteLength(D),G=!1;else if(BR(D))B=D.size,G=!1;else D=F1(D),B=D.length,G=F1.readOnly;if(this._firstFragment){if(this._firstFragment=!1,P&&$&&$.params[$._isServer?"server_no_context_takeover":"client_no_context_takeover"])P=B>=$._threshold;this._compress=P}else P=!1,f=0;if(R.fin)this._firstFragment=!0;let z={[C0]:B,fin:R.fin,generateMask:this._generateMask,mask:R.mask,maskBuffer:this._maskBuffer,opcode:f,readOnly:G,rsv1:P};if(BR(D))if(this._state!==y0)this.enqueue([this.getBlobData,D,this._compress,z,A]);else this.getBlobData(D,this._compress,z,A);else if(this._state!==y0)this.enqueue([this.dispatch,D,this._compress,z,A]);else this.dispatch(D,this._compress,z,A)}getBlobData(D,R,A,$){this._bufferedBytes+=A[C0],this._state=iC,D.arrayBuffer().then((f)=>{if(this._socket.destroyed){let B=Error("The socket was closed while the blob was being read");process.nextTick(n6,this,B,$);return}this._bufferedBytes-=A[C0];let P=F1(f);if(!R)this._state=y0,this.sendFrame(hD.frame(P,A),$),this.dequeue();else this.dispatch(P,R,A,$)}).catch((f)=>{process.nextTick(aC,this,f,$)})}dispatch(D,R,A,$){if(!R){this.sendFrame(hD.frame(D,A),$);return}let f=this._extensions[Iz.extensionName];this._bufferedBytes+=A[C0],this._state=dC,f.compress(D,A.fin,(P,B)=>{if(this._socket.destroyed){let G=Error("The socket was closed while data was being compressed");n6(this,G,$);return}this._bufferedBytes-=A[C0],this._state=y0,A.readOnly=!1,this.sendFrame(hD.frame(B,A),$),this.dequeue()})}dequeue(){while(this._state===y0&&this._queue.length){let D=this._queue.shift();this._bufferedBytes-=D[3][C0],Reflect.apply(D[0],this,D.slice(1))}}enqueue(D){this._bufferedBytes+=D[3][C0],this._queue.push(D)}sendFrame(D,R){if(D.length===2)this._socket.cork(),this._socket.write(D[0]),this._socket.write(D[1],R),this._socket.uncork();else this._socket.write(D[0],R)}}Wz.exports=hD;function n6(D,R,A){if(typeof A==="function")A(R);for(let $=0;$<D._queue.length;$++){let f=D._queue[$],P=f[f.length-1];if(typeof P==="function")P(R)}}function aC(D,R,A){n6(D,R,A),D.onerror(R)}});var xz=q((ab,mz)=>{var{kForOnEventAttribute:IA,kListener:h6}=QD(),jz=Symbol("kCode"),Sz=Symbol("kData"),bz=Symbol("kError"),uz=Symbol("kMessage"),Ez=Symbol("kReason"),zR=Symbol("kTarget"),yz=Symbol("kType"),gz=Symbol("kWasClean");class vD{constructor(D){this[zR]=null,this[yz]=D}get target(){return this[zR]}get type(){return this[yz]}}Object.defineProperty(vD.prototype,"target",{enumerable:!0});Object.defineProperty(vD.prototype,"type",{enumerable:!0});class JR extends vD{constructor(D,R={}){super(D);this[jz]=R.code===void 0?0:R.code,this[Ez]=R.reason===void 0?"":R.reason,this[gz]=R.wasClean===void 0?!1:R.wasClean}get code(){return this[jz]}get reason(){return this[Ez]}get wasClean(){return this[gz]}}Object.defineProperty(JR.prototype,"code",{enumerable:!0});Object.defineProperty(JR.prototype,"reason",{enumerable:!0});Object.defineProperty(JR.prototype,"wasClean",{enumerable:!0});class KA extends vD{constructor(D,R={}){super(D);this[bz]=R.error===void 0?null:R.error,this[uz]=R.message===void 0?"":R.message}get error(){return this[bz]}get message(){return this[uz]}}Object.defineProperty(KA.prototype,"error",{enumerable:!0});Object.defineProperty(KA.prototype,"message",{enumerable:!0});class v2 extends vD{constructor(D,R={}){super(D);this[Sz]=R.data===void 0?null:R.data}get data(){return this[Sz]}}Object.defineProperty(v2.prototype,"data",{enumerable:!0});var rC={addEventListener(D,R,A={}){for(let f of this.listeners(D))if(!A[IA]&&f[h6]===R&&!f[IA])return;let $;if(D==="message")$=function(P,B){let G=new v2("message",{data:B?P:P.toString()});G[zR]=this,h2(R,this,G)};else if(D==="close")$=function(P,B){let G=new JR("close",{code:P,reason:B.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});G[zR]=this,h2(R,this,G)};else if(D==="error")$=function(P){let B=new KA("error",{error:P,message:P.message});B[zR]=this,h2(R,this,B)};else if(D==="open")$=function(){let P=new vD("open");P[zR]=this,h2(R,this,P)};else return;if($[IA]=!!A[IA],$[h6]=R,A.once)this.once(D,$);else this.on(D,$)},removeEventListener(D,R){for(let A of this.listeners(D))if(A[h6]===R&&!A[IA]){this.removeListener(D,A);break}}};mz.exports={CloseEvent:JR,ErrorEvent:KA,Event:vD,EventTarget:rC,MessageEvent:v2};function h2(D,R,A){if(typeof D==="object"&&D.handleEvent)D.handleEvent.call(D,A);else D.call(R,A)}});var l2=q((rb,nz)=>{var{tokenChars:WA}=PR();function r0(D,R,A){if(D[R]===void 0)D[R]=[A];else D[R].push(A)}function sC(D){let R=Object.create(null),A=Object.create(null),$=!1,f=!1,P=!1,B,G,z=-1,J=-1,Z=-1,H=0;for(;H<D.length;H++)if(J=D.charCodeAt(H),B===void 0)if(Z===-1&&WA[J]===1){if(z===-1)z=H}else if(H!==0&&(J===32||J===9)){if(Z===-1&&z!==-1)Z=H}else if(J===59||J===44){if(z===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(Z===-1)Z=H;let Q=D.slice(z,Z);if(J===44)r0(R,Q,A),A=Object.create(null);else B=Q;z=Z=-1}else throw SyntaxError(`Unexpected character at index ${H}`);else if(G===void 0)if(Z===-1&&WA[J]===1){if(z===-1)z=H}else if(J===32||J===9){if(Z===-1&&z!==-1)Z=H}else if(J===59||J===44){if(z===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(Z===-1)Z=H;if(r0(A,D.slice(z,Z),!0),J===44)r0(R,B,A),A=Object.create(null),B=void 0;z=Z=-1}else if(J===61&&z!==-1&&Z===-1)G=D.slice(z,H),z=Z=-1;else throw SyntaxError(`Unexpected character at index ${H}`);else if(f){if(WA[J]!==1)throw SyntaxError(`Unexpected character at index ${H}`);if(z===-1)z=H;else if(!$)$=!0;f=!1}else if(P)if(WA[J]===1){if(z===-1)z=H}else if(J===34&&z!==-1)P=!1,Z=H;else if(J===92)f=!0;else throw SyntaxError(`Unexpected character at index ${H}`);else if(J===34&&D.charCodeAt(H-1)===61)P=!0;else if(Z===-1&&WA[J]===1){if(z===-1)z=H}else if(z!==-1&&(J===32||J===9)){if(Z===-1)Z=H}else if(J===59||J===44){if(z===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(Z===-1)Z=H;let Q=D.slice(z,Z);if($)Q=Q.replace(/\\/g,""),$=!1;if(r0(A,G,Q),J===44)r0(R,B,A),A=Object.create(null),B=void 0;G=void 0,z=Z=-1}else throw SyntaxError(`Unexpected character at index ${H}`);if(z===-1||P||J===32||J===9)throw SyntaxError("Unexpected end of input");if(Z===-1)Z=H;let M=D.slice(z,Z);if(B===void 0)r0(R,M,A);else{if(G===void 0)r0(A,M,!0);else if($)r0(A,G,M.replace(/\\/g,""));else r0(A,G,M);r0(R,B,A)}return R}function oC(D){return Object.keys(D).map((R)=>{let A=D[R];if(!Array.isArray(A))A=[A];return A.map(($)=>{return[R].concat(Object.keys($).map((f)=>{let P=$[f];if(!Array.isArray(P))P=[P];return P.map((B)=>B===!0?f:`${f}=${B}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}nz.exports={format:oC,parse:sC}});var a2=q((cb,cz)=>{var cC=p("events"),tC=p("https"),eC=p("http"),vz=p("net"),DL=p("tls"),{randomBytes:RL,createHash:AL}=p("crypto"),{Duplex:sb,Readable:ob}=p("stream"),{URL:v6}=p("url"),lD=fR(),$L=x6(),fL=p6(),{isBlob:PL}=PR(),{BINARY_TYPES:pz,CLOSE_TIMEOUT:BL,EMPTY_BUFFER:k2,GUID:GL,kForOnEventAttribute:l6,kListener:zL,kStatusCode:JL,kWebSocket:P0,NOOP:lz}=QD(),{EventTarget:{addEventListener:HL,removeEventListener:ZL}}=xz(),{format:ML,parse:XL}=l2(),{toBuffer:QL}=NA(),kz=Symbol("kAborted"),k6=[8,13],OD=["CONNECTING","OPEN","CLOSING","CLOSED"],TL=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class E extends cC{constructor(D,R,A){super();if(this._binaryType=pz[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=k2,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=E.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,D!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,R===void 0)R=[];else if(!Array.isArray(R))if(typeof R==="object"&&R!==null)A=R,R=[];else R=[R];dz(this,D,R,A)}else this._autoPong=A.autoPong,this._closeTimeout=A.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(D){if(!pz.includes(D))return;if(this._binaryType=D,this._receiver)this._receiver._binaryType=D}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(D,R,A){let $=new $L({allowSynchronousEvents:A.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:A.maxPayload,skipUTF8Validation:A.skipUTF8Validation}),f=new fL(D,this._extensions,A.generateMask);if(this._receiver=$,this._sender=f,this._socket=D,$[P0]=this,f[P0]=this,D[P0]=this,$.on("conclude",_L),$.on("drain",UL),$.on("error",FL),$.on("message",qL),$.on("ping",wL),$.on("pong",CL),f.onerror=LL,D.setTimeout)D.setTimeout(0);if(D.setNoDelay)D.setNoDelay();if(R.length>0)D.unshift(R);D.on("close",rz),D.on("data",i2),D.on("end",sz),D.on("error",oz),this._readyState=E.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=E.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[lD.extensionName])this._extensions[lD.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=E.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(D,R){if(this.readyState===E.CLOSED)return;if(this.readyState===E.CONNECTING){O0(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===E.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=E.CLOSING,this._sender.close(D,R,!this._isServer,(A)=>{if(A)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),az(this)}pause(){if(this.readyState===E.CONNECTING||this.readyState===E.CLOSED)return;this._paused=!0,this._socket.pause()}ping(D,R,A){if(this.readyState===E.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof D==="function")A=D,D=R=void 0;else if(typeof R==="function")A=R,R=void 0;if(typeof D==="number")D=D.toString();if(this.readyState!==E.OPEN){d6(this,D,A);return}if(R===void 0)R=!this._isServer;this._sender.ping(D||k2,R,A)}pong(D,R,A){if(this.readyState===E.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof D==="function")A=D,D=R=void 0;else if(typeof R==="function")A=R,R=void 0;if(typeof D==="number")D=D.toString();if(this.readyState!==E.OPEN){d6(this,D,A);return}if(R===void 0)R=!this._isServer;this._sender.pong(D||k2,R,A)}resume(){if(this.readyState===E.CONNECTING||this.readyState===E.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send(D,R,A){if(this.readyState===E.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof R==="function")A=R,R={};if(typeof D==="number")D=D.toString();if(this.readyState!==E.OPEN){d6(this,D,A);return}let $={binary:typeof D!=="string",mask:!this._isServer,compress:!0,fin:!0,...R};if(!this._extensions[lD.extensionName])$.compress=!1;this._sender.send(D||k2,$,A)}terminate(){if(this.readyState===E.CLOSED)return;if(this.readyState===E.CONNECTING){O0(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=E.CLOSING,this._socket.destroy()}}Object.defineProperty(E,"CONNECTING",{enumerable:!0,value:OD.indexOf("CONNECTING")});Object.defineProperty(E.prototype,"CONNECTING",{enumerable:!0,value:OD.indexOf("CONNECTING")});Object.defineProperty(E,"OPEN",{enumerable:!0,value:OD.indexOf("OPEN")});Object.defineProperty(E.prototype,"OPEN",{enumerable:!0,value:OD.indexOf("OPEN")});Object.defineProperty(E,"CLOSING",{enumerable:!0,value:OD.indexOf("CLOSING")});Object.defineProperty(E.prototype,"CLOSING",{enumerable:!0,value:OD.indexOf("CLOSING")});Object.defineProperty(E,"CLOSED",{enumerable:!0,value:OD.indexOf("CLOSED")});Object.defineProperty(E.prototype,"CLOSED",{enumerable:!0,value:OD.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((D)=>{Object.defineProperty(E.prototype,D,{enumerable:!0})});["open","error","close","message"].forEach((D)=>{Object.defineProperty(E.prototype,`on${D}`,{enumerable:!0,get(){for(let R of this.listeners(D))if(R[l6])return R[zL];return null},set(R){for(let A of this.listeners(D))if(A[l6]){this.removeListener(D,A);break}if(typeof R!=="function")return;this.addEventListener(D,R,{[l6]:!0})}})});E.prototype.addEventListener=HL;E.prototype.removeEventListener=ZL;cz.exports=E;function dz(D,R,A,$){let f={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:BL,protocolVersion:k6[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...$,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(D._autoPong=f.autoPong,D._closeTimeout=f.closeTimeout,!k6.includes(f.protocolVersion))throw RangeError(`Unsupported protocol version: ${f.protocolVersion} (supported versions: ${k6.join(", ")})`);let P;if(R instanceof v6)P=R;else try{P=new v6(R)}catch{throw SyntaxError(`Invalid URL: ${R}`)}if(P.protocol==="http:")P.protocol="ws:";else if(P.protocol==="https:")P.protocol="wss:";D._url=P.href;let B=P.protocol==="wss:",G=P.protocol==="ws+unix:",z;if(P.protocol!=="ws:"&&!B&&!G)z=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(G&&!P.pathname)z="The URL's pathname is empty";else if(P.hash)z="The URL contains a fragment identifier";if(z){let X=SyntaxError(z);if(D._redirects===0)throw X;else{d2(D,X);return}}let J=B?443:80,Z=RL(16).toString("base64"),H=B?tC.request:eC.request,M=new Set,Q;if(f.createConnection=f.createConnection||(B?YL:OL),f.defaultPort=f.defaultPort||J,f.port=P.port||J,f.host=P.hostname.startsWith("[")?P.hostname.slice(1,-1):P.hostname,f.headers={...f.headers,"Sec-WebSocket-Version":f.protocolVersion,"Sec-WebSocket-Key":Z,Connection:"Upgrade",Upgrade:"websocket"},f.path=P.pathname+P.search,f.timeout=f.handshakeTimeout,f.perMessageDeflate)Q=new lD({...f.perMessageDeflate,isServer:!1,maxPayload:f.maxPayload}),f.headers["Sec-WebSocket-Extensions"]=ML({[lD.extensionName]:Q.offer()});if(A.length){for(let X of A){if(typeof X!=="string"||!TL.test(X)||M.has(X))throw SyntaxError("An invalid or duplicated subprotocol was specified");M.add(X)}f.headers["Sec-WebSocket-Protocol"]=A.join(",")}if(f.origin)if(f.protocolVersion<13)f.headers["Sec-WebSocket-Origin"]=f.origin;else f.headers.Origin=f.origin;if(P.username||P.password)f.auth=`${P.username}:${P.password}`;if(G){let X=f.path.split(":");f.socketPath=X[0],f.path=X[1]}let O;if(f.followRedirects){if(D._redirects===0){D._originalIpc=G,D._originalSecure=B,D._originalHostOrSocketPath=G?f.socketPath:P.host;let X=$&&$.headers;if($={...$,headers:{}},X)for(let[T,U]of Object.entries(X))$.headers[T.toLowerCase()]=U}else if(D.listenerCount("redirect")===0){let X=G?D._originalIpc?f.socketPath===D._originalHostOrSocketPath:!1:D._originalIpc?!1:P.host===D._originalHostOrSocketPath;if(!X||D._originalSecure&&!B){if(delete f.headers.authorization,delete f.headers.cookie,!X)delete f.headers.host;f.auth=void 0}}if(f.auth&&!$.headers.authorization)$.headers.authorization="Basic "+Buffer.from(f.auth).toString("base64");if(O=D._req=H(f),D._redirects)D.emit("redirect",D.url,O)}else O=D._req=H(f);if(f.timeout)O.on("timeout",()=>{O0(D,O,"Opening handshake has timed out")});if(O.on("error",(X)=>{if(O===null||O[kz])return;O=D._req=null,d2(D,X)}),O.on("response",(X)=>{let T=X.headers.location,U=X.statusCode;if(T&&f.followRedirects&&U>=300&&U<400){if(++D._redirects>f.maxRedirects){O0(D,O,"Maximum redirects exceeded");return}O.abort();let F;try{F=new v6(T,R)}catch(w){let V=SyntaxError(`Invalid URL: ${T}`);d2(D,V);return}dz(D,F,A,$)}else if(!D.emit("unexpected-response",O,X))O0(D,O,`Unexpected server response: ${X.statusCode}`)}),O.on("upgrade",(X,T,U)=>{if(D.emit("upgrade",X),D.readyState!==E.CONNECTING)return;O=D._req=null;let F=X.headers.upgrade;if(F===void 0||F.toLowerCase()!=="websocket"){O0(D,T,"Invalid Upgrade header");return}let w=AL("sha1").update(Z+GL).digest("base64");if(X.headers["sec-websocket-accept"]!==w){O0(D,T,"Invalid Sec-WebSocket-Accept header");return}let V=X.headers["sec-websocket-protocol"],I;if(V!==void 0){if(!M.size)I="Server sent a subprotocol but none was requested";else if(!M.has(V))I="Server sent an invalid subprotocol"}else if(M.size)I="Server sent no subprotocol";if(I){O0(D,T,I);return}if(V)D._protocol=V;let j=X.headers["sec-websocket-extensions"];if(j!==void 0){if(!Q){O0(D,T,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let u;try{u=XL(j)}catch(S){O0(D,T,"Invalid Sec-WebSocket-Extensions header");return}let L=Object.keys(u);if(L.length!==1||L[0]!==lD.extensionName){O0(D,T,"Server indicated an extension that was not requested");return}try{Q.accept(u[lD.extensionName])}catch(S){O0(D,T,"Invalid Sec-WebSocket-Extensions header");return}D._extensions[lD.extensionName]=Q}D.setSocket(T,U,{allowSynchronousEvents:f.allowSynchronousEvents,generateMask:f.generateMask,maxPayload:f.maxPayload,skipUTF8Validation:f.skipUTF8Validation})}),f.finishRequest)f.finishRequest(O,D);else O.end()}function d2(D,R){D._readyState=E.CLOSING,D._errorEmitted=!0,D.emit("error",R),D.emitClose()}function OL(D){return D.path=D.socketPath,vz.connect(D)}function YL(D){if(D.path=void 0,!D.servername&&D.servername!=="")D.servername=vz.isIP(D.host)?"":D.host;return DL.connect(D)}function O0(D,R,A){D._readyState=E.CLOSING;let $=Error(A);if(Error.captureStackTrace($,O0),R.setHeader){if(R[kz]=!0,R.abort(),R.socket&&!R.socket.destroyed)R.socket.destroy();process.nextTick(d2,D,$)}else R.destroy($),R.once("error",D.emit.bind(D,"error")),R.once("close",D.emitClose.bind(D))}function d6(D,R,A){if(R){let $=PL(R)?R.size:QL(R).length;if(D._socket)D._sender._bufferedBytes+=$;else D._bufferedAmount+=$}if(A){let $=Error(`WebSocket is not open: readyState ${D.readyState} (${OD[D.readyState]})`);process.nextTick(A,$)}}function _L(D,R){let A=this[P0];if(A._closeFrameReceived=!0,A._closeMessage=R,A._closeCode=D,A._socket[P0]===void 0)return;if(A._socket.removeListener("data",i2),process.nextTick(iz,A._socket),D===1005)A.close();else A.close(D,R)}function UL(){let D=this[P0];if(!D.isPaused)D._socket.resume()}function FL(D){let R=this[P0];if(R._socket[P0]!==void 0)R._socket.removeListener("data",i2),process.nextTick(iz,R._socket),R.close(D[JL]);if(!R._errorEmitted)R._errorEmitted=!0,R.emit("error",D)}function hz(){this[P0].emitClose()}function qL(D,R){this[P0].emit("message",D,R)}function wL(D){let R=this[P0];if(R._autoPong)R.pong(D,!this._isServer,lz);R.emit("ping",D)}function CL(D){this[P0].emit("pong",D)}function iz(D){D.resume()}function LL(D){let R=this[P0];if(R.readyState===E.CLOSED)return;if(R.readyState===E.OPEN)R._readyState=E.CLOSING,az(R);if(this._socket.end(),!R._errorEmitted)R._errorEmitted=!0,R.emit("error",D)}function az(D){D._closeTimer=setTimeout(D._socket.destroy.bind(D._socket),D._closeTimeout)}function rz(){let D=this[P0];if(this.removeListener("close",rz),this.removeListener("data",i2),this.removeListener("end",sz),D._readyState=E.CLOSING,!this._readableState.endEmitted&&!D._closeFrameReceived&&!D._receiver._writableState.errorEmitted&&this._readableState.length!==0){let R=this.read(this._readableState.length);D._receiver.write(R)}if(D._receiver.end(),this[P0]=void 0,clearTimeout(D._closeTimer),D._receiver._writableState.finished||D._receiver._writableState.errorEmitted)D.emitClose();else D._receiver.on("error",hz),D._receiver.on("finish",hz)}function i2(D){if(!this[P0]._receiver.write(D))this.pause()}function sz(){let D=this[P0];D._readyState=E.CLOSING,D._receiver.end(),this.end()}function oz(){let D=this[P0];if(this.removeListener("error",oz),this.on("error",lz),D)D._readyState=E.CLOSING,this.destroy()}});var R7=q((eb,D7)=>{var tb=a2(),{Duplex:NL}=p("stream");function tz(D){D.emit("close")}function VL(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function ez(D){if(this.removeListener("error",ez),this.destroy(),this.listenerCount("error")===0)this.emit("error",D)}function IL(D,R){let A=!0,$=new NL({...R,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return D.on("message",function(P,B){let G=!B&&$._readableState.objectMode?P.toString():P;if(!$.push(G))D.pause()}),D.once("error",function(P){if($.destroyed)return;A=!1,$.destroy(P)}),D.once("close",function(){if($.destroyed)return;$.push(null)}),$._destroy=function(f,P){if(D.readyState===D.CLOSED){P(f),process.nextTick(tz,$);return}let B=!1;if(D.once("error",function(z){B=!0,P(z)}),D.once("close",function(){if(!B)P(f);process.nextTick(tz,$)}),A)D.terminate()},$._final=function(f){if(D.readyState===D.CONNECTING){D.once("open",function(){$._final(f)});return}if(D._socket===null)return;if(D._socket._writableState.finished){if(f(),$._readableState.endEmitted)$.destroy()}else D._socket.once("finish",function(){f()}),D.close()},$._read=function(){if(D.isPaused)D.resume()},$._write=function(f,P,B){if(D.readyState===D.CONNECTING){D.once("open",function(){$._write(f,P,B)});return}D.send(f,B)},$.on("end",VL),$.on("error",ez),$}D7.exports=IL});var i6=q((Du,A7)=>{var{tokenChars:KL}=PR();function WL(D){let R=new Set,A=-1,$=-1,f=0;for(f;f<D.length;f++){let B=D.charCodeAt(f);if($===-1&&KL[B]===1){if(A===-1)A=f}else if(f!==0&&(B===32||B===9)){if($===-1&&A!==-1)$=f}else if(B===44){if(A===-1)throw SyntaxError(`Unexpected character at index ${f}`);if($===-1)$=f;let G=D.slice(A,$);if(R.has(G))throw SyntaxError(`The "${G}" subprotocol is duplicated`);R.add(G),A=$=-1}else throw SyntaxError(`Unexpected character at index ${f}`)}if(A===-1||$!==-1)throw SyntaxError("Unexpected end of input");let P=D.slice(A,f);if(R.has(P))throw SyntaxError(`The "${P}" subprotocol is duplicated`);return R.add(P),R}A7.exports={parse:WL}});var G7=q((Au,B7)=>{var jL=p("events"),r2=p("http"),{Duplex:Ru}=p("stream"),{createHash:SL}=p("crypto"),$7=l2(),w1=fR(),bL=i6(),uL=a2(),{CLOSE_TIMEOUT:EL,GUID:yL,kWebSocket:gL}=QD(),mL=/^[+/0-9A-Za-z]{22}==$/;class P7 extends jL{constructor(D,R){super();if(D={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:EL,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:uL,...D},D.port==null&&!D.server&&!D.noServer||D.port!=null&&(D.server||D.noServer)||D.server&&D.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(D.port!=null)this._server=r2.createServer((A,$)=>{let f=r2.STATUS_CODES[426];$.writeHead(426,{"Content-Length":f.length,"Content-Type":"text/plain"}),$.end(f)}),this._server.listen(D.port,D.host,D.backlog,R);else if(D.server)this._server=D.server;if(this._server){let A=this.emit.bind(this,"connection");this._removeListeners=xL(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:($,f,P)=>{this.handleUpgrade($,f,P,A)}})}if(D.perMessageDeflate===!0)D.perMessageDeflate={};if(D.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=D,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close(D){if(this._state===2){if(D)this.once("close",()=>{D(Error("The server is not running"))});process.nextTick(jA,this);return}if(D)this.once("close",D);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(jA,this);else this._shouldEmitClose=!0;else process.nextTick(jA,this)}else{let R=this._server;this._removeListeners(),this._removeListeners=this._server=null,R.close(()=>{jA(this)})}}shouldHandle(D){if(this.options.path){let R=D.url.indexOf("?");if((R!==-1?D.url.slice(0,R):D.url)!==this.options.path)return!1}return!0}handleUpgrade(D,R,A,$){R.on("error",f7);let f=D.headers["sec-websocket-key"],P=D.headers.upgrade,B=+D.headers["sec-websocket-version"];if(D.method!=="GET"){C1(this,D,R,405,"Invalid HTTP method");return}if(P===void 0||P.toLowerCase()!=="websocket"){C1(this,D,R,400,"Invalid Upgrade header");return}if(f===void 0||!mL.test(f)){C1(this,D,R,400,"Missing or invalid Sec-WebSocket-Key header");return}if(B!==13&&B!==8){C1(this,D,R,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(D)){SA(R,400);return}let G=D.headers["sec-websocket-protocol"],z=new Set;if(G!==void 0)try{z=bL.parse(G)}catch(H){C1(this,D,R,400,"Invalid Sec-WebSocket-Protocol header");return}let J=D.headers["sec-websocket-extensions"],Z={};if(this.options.perMessageDeflate&&J!==void 0){let H=new w1({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let M=$7.parse(J);if(M[w1.extensionName])H.accept(M[w1.extensionName]),Z[w1.extensionName]=H}catch(M){C1(this,D,R,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let H={origin:D.headers[`${B===8?"sec-websocket-origin":"origin"}`],secure:!!(D.socket.authorized||D.socket.encrypted),req:D};if(this.options.verifyClient.length===2){this.options.verifyClient(H,(M,Q,O,X)=>{if(!M)return SA(R,Q||401,O,X);this.completeUpgrade(Z,f,z,D,R,A,$)});return}if(!this.options.verifyClient(H))return SA(R,401)}this.completeUpgrade(Z,f,z,D,R,A,$)}completeUpgrade(D,R,A,$,f,P,B){if(!f.readable||!f.writable)return f.destroy();if(f[gL])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return SA(f,503);let z=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${SL("sha1").update(R+yL).digest("base64")}`],J=new this.options.WebSocket(null,void 0,this.options);if(A.size){let Z=this.options.handleProtocols?this.options.handleProtocols(A,$):A.values().next().value;if(Z)z.push(`Sec-WebSocket-Protocol: ${Z}`),J._protocol=Z}if(D[w1.extensionName]){let Z=D[w1.extensionName].params,H=$7.format({[w1.extensionName]:[Z]});z.push(`Sec-WebSocket-Extensions: ${H}`),J._extensions=D}if(this.emit("headers",z,$),f.write(z.concat(`\r
164
+ `,R)+1}return{type:D,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(D){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let R=n$(D),A=n1(R);return A.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:A,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let R=n$(D),A=n1(R);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:A,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(D,R){if(this.type!=="comment")return!1;if(this.indent<=R)return!1;return D.every((A)=>A.type==="newline"||A.type==="space")}*documentEnd(D){if(this.type!=="doc-mode"){if(D.end)D.end.push(this.sourceToken);else D.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(D){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if(D.end)D.end.push(this.sourceToken);else D.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}o_.Parser=qB});var VB=q((PU)=>{var wB=DP(),t_=iR(),tR=aR(),e_=H3(),DU=m(),RU=HP(),CB=ZP();function LB(D){let R=D.prettyErrors!==!1;return{lineCounter:D.lineCounter||R&&new RU.LineCounter||null,prettyErrors:R}}function AU(D,R={}){let{lineCounter:A,prettyErrors:$}=LB(R),f=new CB.Parser(A?.addNewLine),P=new wB.Composer(R),B=Array.from(P.compose(f.parse(D)));if($&&A)for(let G of B)G.errors.forEach(tR.prettifyError(D,A)),G.warnings.forEach(tR.prettifyError(D,A));if(B.length>0)return B;return Object.assign([],{empty:!0},P.streamInfo())}function NB(D,R={}){let{lineCounter:A,prettyErrors:$}=LB(R),f=new CB.Parser(A?.addNewLine),P=new wB.Composer(R),B=null;for(let G of P.compose(f.parse(D),!0,D.length))if(!B)B=G;else if(B.options.logLevel!=="silent"){B.errors.push(new tR.YAMLParseError(G.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if($&&A)B.errors.forEach(tR.prettifyError(D,A)),B.warnings.forEach(tR.prettifyError(D,A));return B}function $U(D,R,A){let $=void 0;if(typeof R==="function")$=R;else if(A===void 0&&R&&typeof R==="object")A=R;let f=NB(D,A);if(!f)return null;if(f.warnings.forEach((P)=>e_.warn(f.options.logLevel,P)),f.errors.length>0)if(f.options.logLevel!=="silent")throw f.errors[0];else f.errors=[];return f.toJS(Object.assign({reviver:$},A))}function fU(D,R,A){let $=null;if(typeof R==="function"||Array.isArray(R))$=R;else if(A===void 0&&R)A=R;if(typeof A==="string")A=A.length;if(typeof A==="number"){let f=Math.round(A);A=f<1?void 0:f>8?{indent:8}:{indent:f}}if(D===void 0){let{keepUndefined:f}=A??R??{};if(!f)return}if(DU.isDocument(D)&&!$)return D.toString(A);return new t_.Document(D,$,A).toString(A)}PU.parse=$U;PU.parseAllDocuments=AU;PU.parseDocument=NB;PU.stringify=fU});var KB=q((wU)=>{var HU=DP(),ZU=iR(),MU=x3(),MP=aR(),XU=SR(),KD=m(),QU=CD(),TU=o(),OU=ND(),YU=VD(),_U=m$(),UU=JP(),FU=HP(),qU=ZP(),p$=VB(),IB=WR();wU.Composer=HU.Composer;wU.Document=ZU.Document;wU.Schema=MU.Schema;wU.YAMLError=MP.YAMLError;wU.YAMLParseError=MP.YAMLParseError;wU.YAMLWarning=MP.YAMLWarning;wU.Alias=XU.Alias;wU.isAlias=KD.isAlias;wU.isCollection=KD.isCollection;wU.isDocument=KD.isDocument;wU.isMap=KD.isMap;wU.isNode=KD.isNode;wU.isPair=KD.isPair;wU.isScalar=KD.isScalar;wU.isSeq=KD.isSeq;wU.Pair=QU.Pair;wU.Scalar=TU.Scalar;wU.YAMLMap=OU.YAMLMap;wU.YAMLSeq=YU.YAMLSeq;wU.CST=_U;wU.Lexer=UU.Lexer;wU.LineCounter=FU.LineCounter;wU.Parser=qU.Parser;wU.parse=p$.parse;wU.parseAllDocuments=p$.parseAllDocuments;wU.parseDocument=p$.parseDocument;wU.stringify=p$.stringify;wU.visit=IB.visit;wU.visitAsync=IB.visitAsync});var FG=q((wS,If)=>{function ZG(D){return Array.isArray(D)?D:[D]}var Qw=void 0,L6="",JG=" ",C6="\\",Tw=/^\s+$/,Ow=/(?:[^\\]|^)\\$/,Yw=/^\\!/,_w=/^\\#/,Uw=/\r?\n/g,Fw=/^\.{0,2}\/|^\.{1,2}$/,qw=/\/$/,t1="/",MG="node-ignore";if(typeof Symbol<"u")MG=Symbol.for("node-ignore");var XG=MG,e1=(D,R,A)=>{return Object.defineProperty(D,R,{value:A}),A},ww=/([0-z])-([0-z])/g,QG=()=>!1,Cw=(D)=>D.replace(ww,(R,A,$)=>A.charCodeAt(0)<=$.charCodeAt(0)?R:L6),Lw=(D)=>{let{length:R}=D;return D.slice(0,R-R%2)},Nw=[[/^\uFEFF/,()=>L6],[/((?:\\\\)*?)(\\?\s+)$/,(D,R,A)=>R+(A.indexOf("\\")===0?JG:L6)],[/(\\+?)\s/g,(D,R)=>{let{length:A}=R;return R.slice(0,A-A%2)+JG}],[/[\\$.|*+(){^]/g,(D)=>`\\${D}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return!/\/(?!$)/.test(this)?"(?:^|\\/)":"^"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(D,R,A)=>R+6<A.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(D,R,A)=>{let $=A.replace(/\\\*/g,"[^\\/]*");return R+$}],[/\\\\\\(?=[$.|*+(){^])/g,()=>C6],[/\\\\/g,()=>C6],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(D,R,A,$,f)=>R===C6?`\\[${A}${Lw($)}${f}`:f==="]"?$.length%2===0?`[${Cw(A)}${$}]`:"[]":"[]"],[/(?:[^*])$/,(D)=>/\/$/.test(D)?`${D}$`:`${D}(?=$|\\/$)`]],Vw=/(^|\\\/)?\\\*$/,CA="regex",Nf="checkRegex",HG="_",Iw={[CA](D,R){return`${R?`${R}[^/]+`:"[^/]*"}(?=$|\\/$)`},[Nf](D,R){return`${R?`${R}[^/]*`:"[^/]*"}(?=$|\\/$)`}},Kw=(D)=>Nw.reduce((R,[A,$])=>R.replace(A,$.bind(D)),D),Vf=(D)=>typeof D==="string",Ww=(D)=>D&&Vf(D)&&!Tw.test(D)&&!Ow.test(D)&&D.indexOf("#")!==0,jw=(D)=>D.split(Uw).filter(Boolean);class TG{constructor(D,R,A,$,f,P){this.pattern=D,this.mark=R,this.negative=f,e1(this,"body",A),e1(this,"ignoreCase",$),e1(this,"regexPrefix",P)}get regex(){let D=HG+CA;if(this[D])return this[D];return this._make(CA,D)}get checkRegex(){let D=HG+Nf;if(this[D])return this[D];return this._make(Nf,D)}_make(D,R){let A=this.regexPrefix.replace(Vw,Iw[D]),$=this.ignoreCase?new RegExp(A,"i"):new RegExp(A);return e1(this,R,$)}}var Sw=({pattern:D,mark:R},A)=>{let $=!1,f=D;if(f.indexOf("!")===0)$=!0,f=f.substr(1);f=f.replace(Yw,"!").replace(_w,"#");let P=Kw(f);return new TG(D,R,f,A,$,P)};class OG{constructor(D){this._ignoreCase=D,this._rules=[]}_add(D){if(D&&D[XG]){this._rules=this._rules.concat(D._rules._rules),this._added=!0;return}if(Vf(D))D={pattern:D};if(Ww(D.pattern)){let R=Sw(D,this._ignoreCase);this._added=!0,this._rules.push(R)}}add(D){return this._added=!1,ZG(Vf(D)?jw(D):D).forEach(this._add,this),this._added}test(D,R,A){let $=!1,f=!1,P;this._rules.forEach((G)=>{let{negative:z}=G;if(f===z&&$!==f||z&&!$&&!f&&!R)return;if(!G[A].test(D))return;$=!z,f=z,P=z?Qw:G});let B={ignored:$,unignored:f};if(P)B.rule=P;return B}}var bw=(D,R)=>{throw new R(D)},MD=(D,R,A)=>{if(!Vf(D))return A(`path must be a string, but got \`${R}\``,TypeError);if(!D)return A("path must not be empty",TypeError);if(MD.isNotRelative(D))return A(`path should be a \`path.relative()\`d string, but got "${R}"`,RangeError);return!0},YG=(D)=>Fw.test(D);MD.isNotRelative=YG;MD.convert=(D)=>D;class _G{constructor({ignorecase:D=!0,ignoreCase:R=D,allowRelativePaths:A=!1}={}){e1(this,XG,!0),this._rules=new OG(R),this._strictPathCheck=!A,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(D){if(this._rules.add(D))this._initCache();return this}addPattern(D){return this.add(D)}_test(D,R,A,$){let f=D&&MD.convert(D);return MD(f,D,this._strictPathCheck?bw:QG),this._t(f,R,A,$)}checkIgnore(D){if(!qw.test(D))return this.test(D);let R=D.split(t1).filter(Boolean);if(R.pop(),R.length){let A=this._t(R.join(t1)+t1,this._testCache,!0,R);if(A.ignored)return A}return this._rules.test(D,!1,Nf)}_t(D,R,A,$){if(D in R)return R[D];if(!$)$=D.split(t1).filter(Boolean);if($.pop(),!$.length)return R[D]=this._rules.test(D,A,CA);let f=this._t($.join(t1)+t1,R,A,$);return R[D]=f.ignored?f:this._rules.test(D,A,CA)}ignores(D){return this._test(D,this._ignoreCache,!1).ignored}createFilter(){return(D)=>!this.ignores(D)}filter(D){return ZG(D).filter(this.createFilter())}test(D){return this._test(D,this._testCache,!0)}}var N6=(D)=>new _G(D),uw=(D)=>MD(D&&MD.convert(D),D,QG),UG=()=>{let D=(A)=>/^\\\\\?\\/.test(A)||/["<>|\u0000-\u001F]+/u.test(A)?A:A.replace(/\\/g,"/");MD.convert=D;let R=/^[a-z]:\//i;MD.isNotRelative=(A)=>R.test(A)||YG(A)};if(typeof process<"u"&&process.platform==="win32")UG();If.exports=N6;N6.default=N6;If.exports.isPathValid=uw;e1(If.exports,Symbol.for("setupWindows"),UG)});var QD=q((mb,Jz)=>{var Gz=["nodebuffer","arraybuffer","fragments"],zz=typeof Blob<"u";if(zz)Gz.push("blob");Jz.exports={BINARY_TYPES:Gz,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:zz,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var NA=q((xb,gf)=>{var{EMPTY_BUFFER:_C}=QD(),u6=Buffer[Symbol.species];function UC(D,R){if(D.length===0)return _C;if(D.length===1)return D[0];let A=Buffer.allocUnsafe(R),$=0;for(let f=0;f<D.length;f++){let P=D[f];A.set(P,$),$+=P.length}if($<R)return new u6(A.buffer,A.byteOffset,$);return A}function Hz(D,R,A,$,f){for(let P=0;P<f;P++)A[$+P]=D[P]^R[P&3]}function Zz(D,R){for(let A=0;A<D.length;A++)D[A]^=R[A&3]}function FC(D){if(D.length===D.buffer.byteLength)return D.buffer;return D.buffer.slice(D.byteOffset,D.byteOffset+D.length)}function E6(D){if(E6.readOnly=!0,Buffer.isBuffer(D))return D;let R;if(D instanceof ArrayBuffer)R=new u6(D);else if(ArrayBuffer.isView(D))R=new u6(D.buffer,D.byteOffset,D.byteLength);else R=Buffer.from(D),E6.readOnly=!1;return R}gf.exports={concat:UC,mask:Hz,toArrayBuffer:FC,toBuffer:E6,unmask:Zz};if(!process.env.WS_NO_BUFFER_UTIL)try{let D=(()=>{throw new Error("Cannot require module "+"bufferutil");})();gf.exports.mask=function(R,A,$,f,P){if(P<48)Hz(R,A,$,f,P);else D.mask(R,A,$,f,P)},gf.exports.unmask=function(R,A){if(R.length<32)Zz(R,A);else D.unmask(R,A)}}catch(D){}});var Tz=q((nb,Qz)=>{var Mz=Symbol("kDone"),y6=Symbol("kRun");class Xz{constructor(D){this[Mz]=()=>{this.pending--,this[y6]()},this.concurrency=D||1/0,this.jobs=[],this.pending=0}add(D){this.jobs.push(D),this[y6]()}[y6](){if(this.pending===this.concurrency)return;if(this.jobs.length){let D=this.jobs.shift();this.pending++,D(this[Mz])}}}Qz.exports=Xz});var fR=q((pb,Fz)=>{var VA=p("zlib"),Oz=NA(),qC=Tz(),{kStatusCode:Yz}=QD(),wC=Buffer[Symbol.species],CC=Buffer.from([0,0,255,255]),xf=Symbol("permessage-deflate"),TD=Symbol("total-length"),AR=Symbol("callback"),pD=Symbol("buffers"),$R=Symbol("error"),mf;class _z{constructor(D){if(this._options=D||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!mf){let R=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;mf=new qC(R)}}static get extensionName(){return"permessage-deflate"}offer(){let D={};if(this._options.serverNoContextTakeover)D.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)D.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)D.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)D.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)D.client_max_window_bits=!0;return D}accept(D){return D=this.normalizeParams(D),this.params=this._isServer?this.acceptAsServer(D):this.acceptAsClient(D),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let D=this._deflate[AR];if(this._deflate.close(),this._deflate=null,D)D(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(D){let R=this._options,A=D.find(($)=>{if(R.serverNoContextTakeover===!1&&$.server_no_context_takeover||$.server_max_window_bits&&(R.serverMaxWindowBits===!1||typeof R.serverMaxWindowBits==="number"&&R.serverMaxWindowBits>$.server_max_window_bits)||typeof R.clientMaxWindowBits==="number"&&!$.client_max_window_bits)return!1;return!0});if(!A)throw Error("None of the extension offers can be accepted");if(R.serverNoContextTakeover)A.server_no_context_takeover=!0;if(R.clientNoContextTakeover)A.client_no_context_takeover=!0;if(typeof R.serverMaxWindowBits==="number")A.server_max_window_bits=R.serverMaxWindowBits;if(typeof R.clientMaxWindowBits==="number")A.client_max_window_bits=R.clientMaxWindowBits;else if(A.client_max_window_bits===!0||R.clientMaxWindowBits===!1)delete A.client_max_window_bits;return A}acceptAsClient(D){let R=D[0];if(this._options.clientNoContextTakeover===!1&&R.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!R.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")R.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&R.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return R}normalizeParams(D){return D.forEach((R)=>{Object.keys(R).forEach((A)=>{let $=R[A];if($.length>1)throw Error(`Parameter "${A}" must have only a single value`);if($=$[0],A==="client_max_window_bits"){if($!==!0){let f=+$;if(!Number.isInteger(f)||f<8||f>15)throw TypeError(`Invalid value for parameter "${A}": ${$}`);$=f}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${A}": ${$}`)}else if(A==="server_max_window_bits"){let f=+$;if(!Number.isInteger(f)||f<8||f>15)throw TypeError(`Invalid value for parameter "${A}": ${$}`);$=f}else if(A==="client_no_context_takeover"||A==="server_no_context_takeover"){if($!==!0)throw TypeError(`Invalid value for parameter "${A}": ${$}`)}else throw Error(`Unknown parameter "${A}"`);R[A]=$})}),D}decompress(D,R,A){mf.add(($)=>{this._decompress(D,R,(f,P)=>{$(),A(f,P)})})}compress(D,R,A){mf.add(($)=>{this._compress(D,R,(f,P)=>{$(),A(f,P)})})}_decompress(D,R,A){let $=this._isServer?"client":"server";if(!this._inflate){let f=`${$}_max_window_bits`,P=typeof this.params[f]!=="number"?VA.Z_DEFAULT_WINDOWBITS:this.params[f];this._inflate=VA.createInflateRaw({...this._options.zlibInflateOptions,windowBits:P}),this._inflate[xf]=this,this._inflate[TD]=0,this._inflate[pD]=[],this._inflate.on("error",NC),this._inflate.on("data",Uz)}if(this._inflate[AR]=A,this._inflate.write(D),R)this._inflate.write(CC);this._inflate.flush(()=>{let f=this._inflate[$R];if(f){this._inflate.close(),this._inflate=null,A(f);return}let P=Oz.concat(this._inflate[pD],this._inflate[TD]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[TD]=0,this._inflate[pD]=[],R&&this.params[`${$}_no_context_takeover`])this._inflate.reset();A(null,P)})}_compress(D,R,A){let $=this._isServer?"server":"client";if(!this._deflate){let f=`${$}_max_window_bits`,P=typeof this.params[f]!=="number"?VA.Z_DEFAULT_WINDOWBITS:this.params[f];this._deflate=VA.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:P}),this._deflate[TD]=0,this._deflate[pD]=[],this._deflate.on("data",LC)}this._deflate[AR]=A,this._deflate.write(D),this._deflate.flush(VA.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let f=Oz.concat(this._deflate[pD],this._deflate[TD]);if(R)f=new wC(f.buffer,f.byteOffset,f.length-4);if(this._deflate[AR]=null,this._deflate[TD]=0,this._deflate[pD]=[],R&&this.params[`${$}_no_context_takeover`])this._deflate.reset();A(null,f)})}}Fz.exports=_z;function LC(D){this[pD].push(D),this[TD]+=D.length}function Uz(D){if(this[TD]+=D.length,this[xf]._maxPayload<1||this[TD]<=this[xf]._maxPayload){this[pD].push(D);return}this[$R]=RangeError("Max payload size exceeded"),this[$R].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[$R][Yz]=1009,this.removeListener("data",Uz),this.reset()}function NC(D){if(this[xf]._inflate=null,this[$R]){this[AR](this[$R]);return}D[Yz]=1007,this[AR](D)}});var PR=q((hb,nf)=>{var{isUtf8:qz}=p("buffer"),{hasBlob:VC}=QD(),IC=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function KC(D){return D>=1000&&D<=1014&&D!==1004&&D!==1005&&D!==1006||D>=3000&&D<=4999}function g6(D){let R=D.length,A=0;while(A<R)if((D[A]&128)===0)A++;else if((D[A]&224)===192){if(A+1===R||(D[A+1]&192)!==128||(D[A]&254)===192)return!1;A+=2}else if((D[A]&240)===224){if(A+2>=R||(D[A+1]&192)!==128||(D[A+2]&192)!==128||D[A]===224&&(D[A+1]&224)===128||D[A]===237&&(D[A+1]&224)===160)return!1;A+=3}else if((D[A]&248)===240){if(A+3>=R||(D[A+1]&192)!==128||(D[A+2]&192)!==128||(D[A+3]&192)!==128||D[A]===240&&(D[A+1]&240)===128||D[A]===244&&D[A+1]>143||D[A]>244)return!1;A+=4}else return!1;return!0}function WC(D){return VC&&typeof D==="object"&&typeof D.arrayBuffer==="function"&&typeof D.type==="string"&&typeof D.stream==="function"&&(D[Symbol.toStringTag]==="Blob"||D[Symbol.toStringTag]==="File")}nf.exports={isBlob:WC,isValidStatusCode:KC,isValidUTF8:g6,tokenChars:IC};if(qz)nf.exports.isValidUTF8=function(D){return D.length<24?g6(D):qz(D)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let D=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();nf.exports.isValidUTF8=function(R){return R.length<32?g6(R):D(R)}}catch(D){}});var x6=q((vb,Vz)=>{var{Writable:jC}=p("stream"),wz=fR(),{BINARY_TYPES:SC,EMPTY_BUFFER:Cz,kStatusCode:bC,kWebSocket:uC}=QD(),{concat:m6,toArrayBuffer:EC,unmask:yC}=NA(),{isValidStatusCode:gC,isValidUTF8:Lz}=PR(),pf=Buffer[Symbol.species];class Nz extends jC{constructor(D={}){super();this._allowSynchronousEvents=D.allowSynchronousEvents!==void 0?D.allowSynchronousEvents:!0,this._binaryType=D.binaryType||SC[0],this._extensions=D.extensions||{},this._isServer=!!D.isServer,this._maxPayload=D.maxPayload|0,this._skipUTF8Validation=!!D.skipUTF8Validation,this[uC]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(D,R,A){if(this._opcode===8&&this._state==0)return A();this._bufferedBytes+=D.length,this._buffers.push(D),this.startLoop(A)}consume(D){if(this._bufferedBytes-=D,D===this._buffers[0].length)return this._buffers.shift();if(D<this._buffers[0].length){let A=this._buffers[0];return this._buffers[0]=new pf(A.buffer,A.byteOffset+D,A.length-D),new pf(A.buffer,A.byteOffset,D)}let R=Buffer.allocUnsafe(D);do{let A=this._buffers[0],$=R.length-D;if(D>=A.length)R.set(this._buffers.shift(),$);else R.set(new Uint8Array(A.buffer,A.byteOffset,D),$),this._buffers[0]=new pf(A.buffer,A.byteOffset+D,A.length-D);D-=A.length}while(D>0);return R}startLoop(D){this._loop=!0;do switch(this._state){case 0:this.getInfo(D);break;case 1:this.getPayloadLength16(D);break;case 2:this.getPayloadLength64(D);break;case 3:this.getMask();break;case 4:this.getData(D);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)D()}getInfo(D){if(this._bufferedBytes<2){this._loop=!1;return}let R=this.consume(2);if((R[0]&48)!==0){let $=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");D($);return}let A=(R[0]&64)===64;if(A&&!this._extensions[wz.extensionName]){let $=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");D($);return}if(this._fin=(R[0]&128)===128,this._opcode=R[0]&15,this._payloadLength=R[1]&127,this._opcode===0){if(A){let $=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");D($);return}if(!this._fragmented){let $=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");D($);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let $=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");D($);return}this._compressed=A}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let $=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");D($);return}if(A){let $=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");D($);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let $=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");D($);return}}else{let $=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");D($);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(R[1]&128)===128,this._isServer){if(!this._masked){let $=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");D($);return}}else if(this._masked){let $=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");D($);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength(D)}getPayloadLength16(D){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(D)}getPayloadLength64(D){if(this._bufferedBytes<8){this._loop=!1;return}let R=this.consume(8),A=R.readUInt32BE(0);if(A>Math.pow(2,21)-1){let $=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");D($);return}this._payloadLength=A*Math.pow(2,32)+R.readUInt32BE(4),this.haveLength(D)}haveLength(D){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let R=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");D(R);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(D){let R=Cz;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(R=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)yC(R,this._mask)}if(this._opcode>7){this.controlMessage(R,D);return}if(this._compressed){this._state=5,this.decompress(R,D);return}if(R.length)this._messageLength=this._totalPayloadLength,this._fragments.push(R);this.dataMessage(D)}decompress(D,R){this._extensions[wz.extensionName].decompress(D,this._fin,($,f)=>{if($)return R($);if(f.length){if(this._messageLength+=f.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let P=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");R(P);return}this._fragments.push(f)}if(this.dataMessage(R),this._state===0)this.startLoop(R)})}dataMessage(D){if(!this._fin){this._state=0;return}let R=this._messageLength,A=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let $;if(this._binaryType==="nodebuffer")$=m6(A,R);else if(this._binaryType==="arraybuffer")$=EC(m6(A,R));else if(this._binaryType==="blob")$=new Blob(A);else $=A;if(this._allowSynchronousEvents)this.emit("message",$,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",$,!0),this._state=0,this.startLoop(D)})}else{let $=m6(A,R);if(!this._skipUTF8Validation&&!Lz($)){let f=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");D(f);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",$,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",$,!1),this._state=0,this.startLoop(D)})}}controlMessage(D,R){if(this._opcode===8){if(D.length===0)this._loop=!1,this.emit("conclude",1005,Cz),this.end();else{let A=D.readUInt16BE(0);if(!gC(A)){let f=this.createError(RangeError,`invalid status code ${A}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");R(f);return}let $=new pf(D.buffer,D.byteOffset+2,D.length-2);if(!this._skipUTF8Validation&&!Lz($)){let f=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");R(f);return}this._loop=!1,this.emit("conclude",A,$),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",D),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",D),this._state=0,this.startLoop(R)})}createError(D,R,A,$,f){this._loop=!1,this._errored=!0;let P=new D(A?`Invalid WebSocket frame: ${R}`:R);return Error.captureStackTrace(P,this.createError),P.code=f,P[bC]=$,P}}Vz.exports=Nz});var p6=q((kb,Wz)=>{var{Duplex:lb}=p("stream"),{randomFillSync:mC}=p("crypto"),Iz=fR(),{EMPTY_BUFFER:xC,kWebSocket:nC,NOOP:pC}=QD(),{isBlob:BR,isValidStatusCode:hC}=PR(),{mask:Kz,toBuffer:F1}=NA(),C0=Symbol("kByteLength"),vC=Buffer.alloc(4),q1,GR=8192,y0=0,lC=1,kC=2;class hD{constructor(D,R,A){if(this._extensions=R||{},A)this._generateMask=A,this._maskBuffer=Buffer.alloc(4);this._socket=D,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=y0,this.onerror=pC,this[nC]=void 0}static frame(D,R){let A,$=!1,f=2,P=!1;if(R.mask){if(A=R.maskBuffer||vC,R.generateMask)R.generateMask(A);else{if(GR===8192){if(q1===void 0)q1=Buffer.alloc(8192);mC(q1,0,8192),GR=0}A[0]=q1[GR++],A[1]=q1[GR++],A[2]=q1[GR++],A[3]=q1[GR++]}P=(A[0]|A[1]|A[2]|A[3])===0,f=6}let B;if(typeof D==="string")if((!R.mask||P)&&R[C0]!==void 0)B=R[C0];else D=Buffer.from(D),B=D.length;else B=D.length,$=R.mask&&R.readOnly&&!P;let G=B;if(B>=65536)f+=8,G=127;else if(B>125)f+=2,G=126;let z=Buffer.allocUnsafe($?B+f:f);if(z[0]=R.fin?R.opcode|128:R.opcode,R.rsv1)z[0]|=64;if(z[1]=G,G===126)z.writeUInt16BE(B,2);else if(G===127)z[2]=z[3]=0,z.writeUIntBE(B,4,6);if(!R.mask)return[z,D];if(z[1]|=128,z[f-4]=A[0],z[f-3]=A[1],z[f-2]=A[2],z[f-1]=A[3],P)return[z,D];if($)return Kz(D,A,z,f,B),[z];return Kz(D,A,D,0,B),[z,D]}close(D,R,A,$){let f;if(D===void 0)f=xC;else if(typeof D!=="number"||!hC(D))throw TypeError("First argument must be a valid error code number");else if(R===void 0||!R.length)f=Buffer.allocUnsafe(2),f.writeUInt16BE(D,0);else{let B=Buffer.byteLength(R);if(B>123)throw RangeError("The message must not be greater than 123 bytes");if(f=Buffer.allocUnsafe(2+B),f.writeUInt16BE(D,0),typeof R==="string")f.write(R,2);else f.set(R,2)}let P={[C0]:f.length,fin:!0,generateMask:this._generateMask,mask:A,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==y0)this.enqueue([this.dispatch,f,!1,P,$]);else this.sendFrame(hD.frame(f,P),$)}ping(D,R,A){let $,f;if(typeof D==="string")$=Buffer.byteLength(D),f=!1;else if(BR(D))$=D.size,f=!1;else D=F1(D),$=D.length,f=F1.readOnly;if($>125)throw RangeError("The data size must not be greater than 125 bytes");let P={[C0]:$,fin:!0,generateMask:this._generateMask,mask:R,maskBuffer:this._maskBuffer,opcode:9,readOnly:f,rsv1:!1};if(BR(D))if(this._state!==y0)this.enqueue([this.getBlobData,D,!1,P,A]);else this.getBlobData(D,!1,P,A);else if(this._state!==y0)this.enqueue([this.dispatch,D,!1,P,A]);else this.sendFrame(hD.frame(D,P),A)}pong(D,R,A){let $,f;if(typeof D==="string")$=Buffer.byteLength(D),f=!1;else if(BR(D))$=D.size,f=!1;else D=F1(D),$=D.length,f=F1.readOnly;if($>125)throw RangeError("The data size must not be greater than 125 bytes");let P={[C0]:$,fin:!0,generateMask:this._generateMask,mask:R,maskBuffer:this._maskBuffer,opcode:10,readOnly:f,rsv1:!1};if(BR(D))if(this._state!==y0)this.enqueue([this.getBlobData,D,!1,P,A]);else this.getBlobData(D,!1,P,A);else if(this._state!==y0)this.enqueue([this.dispatch,D,!1,P,A]);else this.sendFrame(hD.frame(D,P),A)}send(D,R,A){let $=this._extensions[Iz.extensionName],f=R.binary?2:1,P=R.compress,B,G;if(typeof D==="string")B=Buffer.byteLength(D),G=!1;else if(BR(D))B=D.size,G=!1;else D=F1(D),B=D.length,G=F1.readOnly;if(this._firstFragment){if(this._firstFragment=!1,P&&$&&$.params[$._isServer?"server_no_context_takeover":"client_no_context_takeover"])P=B>=$._threshold;this._compress=P}else P=!1,f=0;if(R.fin)this._firstFragment=!0;let z={[C0]:B,fin:R.fin,generateMask:this._generateMask,mask:R.mask,maskBuffer:this._maskBuffer,opcode:f,readOnly:G,rsv1:P};if(BR(D))if(this._state!==y0)this.enqueue([this.getBlobData,D,this._compress,z,A]);else this.getBlobData(D,this._compress,z,A);else if(this._state!==y0)this.enqueue([this.dispatch,D,this._compress,z,A]);else this.dispatch(D,this._compress,z,A)}getBlobData(D,R,A,$){this._bufferedBytes+=A[C0],this._state=kC,D.arrayBuffer().then((f)=>{if(this._socket.destroyed){let B=Error("The socket was closed while the blob was being read");process.nextTick(n6,this,B,$);return}this._bufferedBytes-=A[C0];let P=F1(f);if(!R)this._state=y0,this.sendFrame(hD.frame(P,A),$),this.dequeue();else this.dispatch(P,R,A,$)}).catch((f)=>{process.nextTick(dC,this,f,$)})}dispatch(D,R,A,$){if(!R){this.sendFrame(hD.frame(D,A),$);return}let f=this._extensions[Iz.extensionName];this._bufferedBytes+=A[C0],this._state=lC,f.compress(D,A.fin,(P,B)=>{if(this._socket.destroyed){let G=Error("The socket was closed while data was being compressed");n6(this,G,$);return}this._bufferedBytes-=A[C0],this._state=y0,A.readOnly=!1,this.sendFrame(hD.frame(B,A),$),this.dequeue()})}dequeue(){while(this._state===y0&&this._queue.length){let D=this._queue.shift();this._bufferedBytes-=D[3][C0],Reflect.apply(D[0],this,D.slice(1))}}enqueue(D){this._bufferedBytes+=D[3][C0],this._queue.push(D)}sendFrame(D,R){if(D.length===2)this._socket.cork(),this._socket.write(D[0]),this._socket.write(D[1],R),this._socket.uncork();else this._socket.write(D[0],R)}}Wz.exports=hD;function n6(D,R,A){if(typeof A==="function")A(R);for(let $=0;$<D._queue.length;$++){let f=D._queue[$],P=f[f.length-1];if(typeof P==="function")P(R)}}function dC(D,R,A){n6(D,R,A),D.onerror(R)}});var xz=q((db,mz)=>{var{kForOnEventAttribute:IA,kListener:h6}=QD(),jz=Symbol("kCode"),Sz=Symbol("kData"),bz=Symbol("kError"),uz=Symbol("kMessage"),Ez=Symbol("kReason"),zR=Symbol("kTarget"),yz=Symbol("kType"),gz=Symbol("kWasClean");class vD{constructor(D){this[zR]=null,this[yz]=D}get target(){return this[zR]}get type(){return this[yz]}}Object.defineProperty(vD.prototype,"target",{enumerable:!0});Object.defineProperty(vD.prototype,"type",{enumerable:!0});class JR extends vD{constructor(D,R={}){super(D);this[jz]=R.code===void 0?0:R.code,this[Ez]=R.reason===void 0?"":R.reason,this[gz]=R.wasClean===void 0?!1:R.wasClean}get code(){return this[jz]}get reason(){return this[Ez]}get wasClean(){return this[gz]}}Object.defineProperty(JR.prototype,"code",{enumerable:!0});Object.defineProperty(JR.prototype,"reason",{enumerable:!0});Object.defineProperty(JR.prototype,"wasClean",{enumerable:!0});class KA extends vD{constructor(D,R={}){super(D);this[bz]=R.error===void 0?null:R.error,this[uz]=R.message===void 0?"":R.message}get error(){return this[bz]}get message(){return this[uz]}}Object.defineProperty(KA.prototype,"error",{enumerable:!0});Object.defineProperty(KA.prototype,"message",{enumerable:!0});class vf extends vD{constructor(D,R={}){super(D);this[Sz]=R.data===void 0?null:R.data}get data(){return this[Sz]}}Object.defineProperty(vf.prototype,"data",{enumerable:!0});var iC={addEventListener(D,R,A={}){for(let f of this.listeners(D))if(!A[IA]&&f[h6]===R&&!f[IA])return;let $;if(D==="message")$=function(P,B){let G=new vf("message",{data:B?P:P.toString()});G[zR]=this,hf(R,this,G)};else if(D==="close")$=function(P,B){let G=new JR("close",{code:P,reason:B.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});G[zR]=this,hf(R,this,G)};else if(D==="error")$=function(P){let B=new KA("error",{error:P,message:P.message});B[zR]=this,hf(R,this,B)};else if(D==="open")$=function(){let P=new vD("open");P[zR]=this,hf(R,this,P)};else return;if($[IA]=!!A[IA],$[h6]=R,A.once)this.once(D,$);else this.on(D,$)},removeEventListener(D,R){for(let A of this.listeners(D))if(A[h6]===R&&!A[IA]){this.removeListener(D,A);break}}};mz.exports={CloseEvent:JR,ErrorEvent:KA,Event:vD,EventTarget:iC,MessageEvent:vf};function hf(D,R,A){if(typeof D==="object"&&D.handleEvent)D.handleEvent.call(D,A);else D.call(R,A)}});var lf=q((ib,nz)=>{var{tokenChars:WA}=PR();function r0(D,R,A){if(D[R]===void 0)D[R]=[A];else D[R].push(A)}function aC(D){let R=Object.create(null),A=Object.create(null),$=!1,f=!1,P=!1,B,G,z=-1,J=-1,Z=-1,H=0;for(;H<D.length;H++)if(J=D.charCodeAt(H),B===void 0)if(Z===-1&&WA[J]===1){if(z===-1)z=H}else if(H!==0&&(J===32||J===9)){if(Z===-1&&z!==-1)Z=H}else if(J===59||J===44){if(z===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(Z===-1)Z=H;let Q=D.slice(z,Z);if(J===44)r0(R,Q,A),A=Object.create(null);else B=Q;z=Z=-1}else throw SyntaxError(`Unexpected character at index ${H}`);else if(G===void 0)if(Z===-1&&WA[J]===1){if(z===-1)z=H}else if(J===32||J===9){if(Z===-1&&z!==-1)Z=H}else if(J===59||J===44){if(z===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(Z===-1)Z=H;if(r0(A,D.slice(z,Z),!0),J===44)r0(R,B,A),A=Object.create(null),B=void 0;z=Z=-1}else if(J===61&&z!==-1&&Z===-1)G=D.slice(z,H),z=Z=-1;else throw SyntaxError(`Unexpected character at index ${H}`);else if(f){if(WA[J]!==1)throw SyntaxError(`Unexpected character at index ${H}`);if(z===-1)z=H;else if(!$)$=!0;f=!1}else if(P)if(WA[J]===1){if(z===-1)z=H}else if(J===34&&z!==-1)P=!1,Z=H;else if(J===92)f=!0;else throw SyntaxError(`Unexpected character at index ${H}`);else if(J===34&&D.charCodeAt(H-1)===61)P=!0;else if(Z===-1&&WA[J]===1){if(z===-1)z=H}else if(z!==-1&&(J===32||J===9)){if(Z===-1)Z=H}else if(J===59||J===44){if(z===-1)throw SyntaxError(`Unexpected character at index ${H}`);if(Z===-1)Z=H;let Q=D.slice(z,Z);if($)Q=Q.replace(/\\/g,""),$=!1;if(r0(A,G,Q),J===44)r0(R,B,A),A=Object.create(null),B=void 0;G=void 0,z=Z=-1}else throw SyntaxError(`Unexpected character at index ${H}`);if(z===-1||P||J===32||J===9)throw SyntaxError("Unexpected end of input");if(Z===-1)Z=H;let M=D.slice(z,Z);if(B===void 0)r0(R,M,A);else{if(G===void 0)r0(A,M,!0);else if($)r0(A,G,M.replace(/\\/g,""));else r0(A,G,M);r0(R,B,A)}return R}function rC(D){return Object.keys(D).map((R)=>{let A=D[R];if(!Array.isArray(A))A=[A];return A.map(($)=>{return[R].concat(Object.keys($).map((f)=>{let P=$[f];if(!Array.isArray(P))P=[P];return P.map((B)=>B===!0?f:`${f}=${B}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}nz.exports={format:rC,parse:aC}});var rf=q((sb,cz)=>{var sC=p("events"),oC=p("https"),cC=p("http"),vz=p("net"),tC=p("tls"),{randomBytes:eC,createHash:DL}=p("crypto"),{Duplex:ab,Readable:rb}=p("stream"),{URL:v6}=p("url"),lD=fR(),RL=x6(),AL=p6(),{isBlob:$L}=PR(),{BINARY_TYPES:pz,CLOSE_TIMEOUT:fL,EMPTY_BUFFER:kf,GUID:PL,kForOnEventAttribute:l6,kListener:BL,kStatusCode:GL,kWebSocket:P0,NOOP:lz}=QD(),{EventTarget:{addEventListener:zL,removeEventListener:JL}}=xz(),{format:HL,parse:ZL}=lf(),{toBuffer:ML}=NA(),kz=Symbol("kAborted"),k6=[8,13],OD=["CONNECTING","OPEN","CLOSING","CLOSED"],XL=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class E extends sC{constructor(D,R,A){super();if(this._binaryType=pz[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=kf,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=E.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,D!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,R===void 0)R=[];else if(!Array.isArray(R))if(typeof R==="object"&&R!==null)A=R,R=[];else R=[R];dz(this,D,R,A)}else this._autoPong=A.autoPong,this._closeTimeout=A.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(D){if(!pz.includes(D))return;if(this._binaryType=D,this._receiver)this._receiver._binaryType=D}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(D,R,A){let $=new RL({allowSynchronousEvents:A.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:A.maxPayload,skipUTF8Validation:A.skipUTF8Validation}),f=new AL(D,this._extensions,A.generateMask);if(this._receiver=$,this._sender=f,this._socket=D,$[P0]=this,f[P0]=this,D[P0]=this,$.on("conclude",OL),$.on("drain",YL),$.on("error",_L),$.on("message",UL),$.on("ping",FL),$.on("pong",qL),f.onerror=wL,D.setTimeout)D.setTimeout(0);if(D.setNoDelay)D.setNoDelay();if(R.length>0)D.unshift(R);D.on("close",rz),D.on("data",af),D.on("end",sz),D.on("error",oz),this._readyState=E.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=E.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[lD.extensionName])this._extensions[lD.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=E.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(D,R){if(this.readyState===E.CLOSED)return;if(this.readyState===E.CONNECTING){O0(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===E.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=E.CLOSING,this._sender.close(D,R,!this._isServer,(A)=>{if(A)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),az(this)}pause(){if(this.readyState===E.CONNECTING||this.readyState===E.CLOSED)return;this._paused=!0,this._socket.pause()}ping(D,R,A){if(this.readyState===E.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof D==="function")A=D,D=R=void 0;else if(typeof R==="function")A=R,R=void 0;if(typeof D==="number")D=D.toString();if(this.readyState!==E.OPEN){d6(this,D,A);return}if(R===void 0)R=!this._isServer;this._sender.ping(D||kf,R,A)}pong(D,R,A){if(this.readyState===E.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof D==="function")A=D,D=R=void 0;else if(typeof R==="function")A=R,R=void 0;if(typeof D==="number")D=D.toString();if(this.readyState!==E.OPEN){d6(this,D,A);return}if(R===void 0)R=!this._isServer;this._sender.pong(D||kf,R,A)}resume(){if(this.readyState===E.CONNECTING||this.readyState===E.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send(D,R,A){if(this.readyState===E.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof R==="function")A=R,R={};if(typeof D==="number")D=D.toString();if(this.readyState!==E.OPEN){d6(this,D,A);return}let $={binary:typeof D!=="string",mask:!this._isServer,compress:!0,fin:!0,...R};if(!this._extensions[lD.extensionName])$.compress=!1;this._sender.send(D||kf,$,A)}terminate(){if(this.readyState===E.CLOSED)return;if(this.readyState===E.CONNECTING){O0(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=E.CLOSING,this._socket.destroy()}}Object.defineProperty(E,"CONNECTING",{enumerable:!0,value:OD.indexOf("CONNECTING")});Object.defineProperty(E.prototype,"CONNECTING",{enumerable:!0,value:OD.indexOf("CONNECTING")});Object.defineProperty(E,"OPEN",{enumerable:!0,value:OD.indexOf("OPEN")});Object.defineProperty(E.prototype,"OPEN",{enumerable:!0,value:OD.indexOf("OPEN")});Object.defineProperty(E,"CLOSING",{enumerable:!0,value:OD.indexOf("CLOSING")});Object.defineProperty(E.prototype,"CLOSING",{enumerable:!0,value:OD.indexOf("CLOSING")});Object.defineProperty(E,"CLOSED",{enumerable:!0,value:OD.indexOf("CLOSED")});Object.defineProperty(E.prototype,"CLOSED",{enumerable:!0,value:OD.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((D)=>{Object.defineProperty(E.prototype,D,{enumerable:!0})});["open","error","close","message"].forEach((D)=>{Object.defineProperty(E.prototype,`on${D}`,{enumerable:!0,get(){for(let R of this.listeners(D))if(R[l6])return R[BL];return null},set(R){for(let A of this.listeners(D))if(A[l6]){this.removeListener(D,A);break}if(typeof R!=="function")return;this.addEventListener(D,R,{[l6]:!0})}})});E.prototype.addEventListener=zL;E.prototype.removeEventListener=JL;cz.exports=E;function dz(D,R,A,$){let f={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:fL,protocolVersion:k6[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...$,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(D._autoPong=f.autoPong,D._closeTimeout=f.closeTimeout,!k6.includes(f.protocolVersion))throw RangeError(`Unsupported protocol version: ${f.protocolVersion} (supported versions: ${k6.join(", ")})`);let P;if(R instanceof v6)P=R;else try{P=new v6(R)}catch{throw SyntaxError(`Invalid URL: ${R}`)}if(P.protocol==="http:")P.protocol="ws:";else if(P.protocol==="https:")P.protocol="wss:";D._url=P.href;let B=P.protocol==="wss:",G=P.protocol==="ws+unix:",z;if(P.protocol!=="ws:"&&!B&&!G)z=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(G&&!P.pathname)z="The URL's pathname is empty";else if(P.hash)z="The URL contains a fragment identifier";if(z){let X=SyntaxError(z);if(D._redirects===0)throw X;else{df(D,X);return}}let J=B?443:80,Z=eC(16).toString("base64"),H=B?oC.request:cC.request,M=new Set,Q;if(f.createConnection=f.createConnection||(B?TL:QL),f.defaultPort=f.defaultPort||J,f.port=P.port||J,f.host=P.hostname.startsWith("[")?P.hostname.slice(1,-1):P.hostname,f.headers={...f.headers,"Sec-WebSocket-Version":f.protocolVersion,"Sec-WebSocket-Key":Z,Connection:"Upgrade",Upgrade:"websocket"},f.path=P.pathname+P.search,f.timeout=f.handshakeTimeout,f.perMessageDeflate)Q=new lD({...f.perMessageDeflate,isServer:!1,maxPayload:f.maxPayload}),f.headers["Sec-WebSocket-Extensions"]=HL({[lD.extensionName]:Q.offer()});if(A.length){for(let X of A){if(typeof X!=="string"||!XL.test(X)||M.has(X))throw SyntaxError("An invalid or duplicated subprotocol was specified");M.add(X)}f.headers["Sec-WebSocket-Protocol"]=A.join(",")}if(f.origin)if(f.protocolVersion<13)f.headers["Sec-WebSocket-Origin"]=f.origin;else f.headers.Origin=f.origin;if(P.username||P.password)f.auth=`${P.username}:${P.password}`;if(G){let X=f.path.split(":");f.socketPath=X[0],f.path=X[1]}let O;if(f.followRedirects){if(D._redirects===0){D._originalIpc=G,D._originalSecure=B,D._originalHostOrSocketPath=G?f.socketPath:P.host;let X=$&&$.headers;if($={...$,headers:{}},X)for(let[T,U]of Object.entries(X))$.headers[T.toLowerCase()]=U}else if(D.listenerCount("redirect")===0){let X=G?D._originalIpc?f.socketPath===D._originalHostOrSocketPath:!1:D._originalIpc?!1:P.host===D._originalHostOrSocketPath;if(!X||D._originalSecure&&!B){if(delete f.headers.authorization,delete f.headers.cookie,!X)delete f.headers.host;f.auth=void 0}}if(f.auth&&!$.headers.authorization)$.headers.authorization="Basic "+Buffer.from(f.auth).toString("base64");if(O=D._req=H(f),D._redirects)D.emit("redirect",D.url,O)}else O=D._req=H(f);if(f.timeout)O.on("timeout",()=>{O0(D,O,"Opening handshake has timed out")});if(O.on("error",(X)=>{if(O===null||O[kz])return;O=D._req=null,df(D,X)}),O.on("response",(X)=>{let T=X.headers.location,U=X.statusCode;if(T&&f.followRedirects&&U>=300&&U<400){if(++D._redirects>f.maxRedirects){O0(D,O,"Maximum redirects exceeded");return}O.abort();let F;try{F=new v6(T,R)}catch(w){let V=SyntaxError(`Invalid URL: ${T}`);df(D,V);return}dz(D,F,A,$)}else if(!D.emit("unexpected-response",O,X))O0(D,O,`Unexpected server response: ${X.statusCode}`)}),O.on("upgrade",(X,T,U)=>{if(D.emit("upgrade",X),D.readyState!==E.CONNECTING)return;O=D._req=null;let F=X.headers.upgrade;if(F===void 0||F.toLowerCase()!=="websocket"){O0(D,T,"Invalid Upgrade header");return}let w=DL("sha1").update(Z+PL).digest("base64");if(X.headers["sec-websocket-accept"]!==w){O0(D,T,"Invalid Sec-WebSocket-Accept header");return}let V=X.headers["sec-websocket-protocol"],I;if(V!==void 0){if(!M.size)I="Server sent a subprotocol but none was requested";else if(!M.has(V))I="Server sent an invalid subprotocol"}else if(M.size)I="Server sent no subprotocol";if(I){O0(D,T,I);return}if(V)D._protocol=V;let j=X.headers["sec-websocket-extensions"];if(j!==void 0){if(!Q){O0(D,T,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let u;try{u=ZL(j)}catch(S){O0(D,T,"Invalid Sec-WebSocket-Extensions header");return}let L=Object.keys(u);if(L.length!==1||L[0]!==lD.extensionName){O0(D,T,"Server indicated an extension that was not requested");return}try{Q.accept(u[lD.extensionName])}catch(S){O0(D,T,"Invalid Sec-WebSocket-Extensions header");return}D._extensions[lD.extensionName]=Q}D.setSocket(T,U,{allowSynchronousEvents:f.allowSynchronousEvents,generateMask:f.generateMask,maxPayload:f.maxPayload,skipUTF8Validation:f.skipUTF8Validation})}),f.finishRequest)f.finishRequest(O,D);else O.end()}function df(D,R){D._readyState=E.CLOSING,D._errorEmitted=!0,D.emit("error",R),D.emitClose()}function QL(D){return D.path=D.socketPath,vz.connect(D)}function TL(D){if(D.path=void 0,!D.servername&&D.servername!=="")D.servername=vz.isIP(D.host)?"":D.host;return tC.connect(D)}function O0(D,R,A){D._readyState=E.CLOSING;let $=Error(A);if(Error.captureStackTrace($,O0),R.setHeader){if(R[kz]=!0,R.abort(),R.socket&&!R.socket.destroyed)R.socket.destroy();process.nextTick(df,D,$)}else R.destroy($),R.once("error",D.emit.bind(D,"error")),R.once("close",D.emitClose.bind(D))}function d6(D,R,A){if(R){let $=$L(R)?R.size:ML(R).length;if(D._socket)D._sender._bufferedBytes+=$;else D._bufferedAmount+=$}if(A){let $=Error(`WebSocket is not open: readyState ${D.readyState} (${OD[D.readyState]})`);process.nextTick(A,$)}}function OL(D,R){let A=this[P0];if(A._closeFrameReceived=!0,A._closeMessage=R,A._closeCode=D,A._socket[P0]===void 0)return;if(A._socket.removeListener("data",af),process.nextTick(iz,A._socket),D===1005)A.close();else A.close(D,R)}function YL(){let D=this[P0];if(!D.isPaused)D._socket.resume()}function _L(D){let R=this[P0];if(R._socket[P0]!==void 0)R._socket.removeListener("data",af),process.nextTick(iz,R._socket),R.close(D[GL]);if(!R._errorEmitted)R._errorEmitted=!0,R.emit("error",D)}function hz(){this[P0].emitClose()}function UL(D,R){this[P0].emit("message",D,R)}function FL(D){let R=this[P0];if(R._autoPong)R.pong(D,!this._isServer,lz);R.emit("ping",D)}function qL(D){this[P0].emit("pong",D)}function iz(D){D.resume()}function wL(D){let R=this[P0];if(R.readyState===E.CLOSED)return;if(R.readyState===E.OPEN)R._readyState=E.CLOSING,az(R);if(this._socket.end(),!R._errorEmitted)R._errorEmitted=!0,R.emit("error",D)}function az(D){D._closeTimer=setTimeout(D._socket.destroy.bind(D._socket),D._closeTimeout)}function rz(){let D=this[P0];if(this.removeListener("close",rz),this.removeListener("data",af),this.removeListener("end",sz),D._readyState=E.CLOSING,!this._readableState.endEmitted&&!D._closeFrameReceived&&!D._receiver._writableState.errorEmitted&&this._readableState.length!==0){let R=this.read(this._readableState.length);D._receiver.write(R)}if(D._receiver.end(),this[P0]=void 0,clearTimeout(D._closeTimer),D._receiver._writableState.finished||D._receiver._writableState.errorEmitted)D.emitClose();else D._receiver.on("error",hz),D._receiver.on("finish",hz)}function af(D){if(!this[P0]._receiver.write(D))this.pause()}function sz(){let D=this[P0];D._readyState=E.CLOSING,D._receiver.end(),this.end()}function oz(){let D=this[P0];if(this.removeListener("error",oz),this.on("error",lz),D)D._readyState=E.CLOSING,this.destroy()}});var R7=q((cb,D7)=>{var ob=rf(),{Duplex:CL}=p("stream");function tz(D){D.emit("close")}function LL(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function ez(D){if(this.removeListener("error",ez),this.destroy(),this.listenerCount("error")===0)this.emit("error",D)}function NL(D,R){let A=!0,$=new CL({...R,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return D.on("message",function(P,B){let G=!B&&$._readableState.objectMode?P.toString():P;if(!$.push(G))D.pause()}),D.once("error",function(P){if($.destroyed)return;A=!1,$.destroy(P)}),D.once("close",function(){if($.destroyed)return;$.push(null)}),$._destroy=function(f,P){if(D.readyState===D.CLOSED){P(f),process.nextTick(tz,$);return}let B=!1;if(D.once("error",function(z){B=!0,P(z)}),D.once("close",function(){if(!B)P(f);process.nextTick(tz,$)}),A)D.terminate()},$._final=function(f){if(D.readyState===D.CONNECTING){D.once("open",function(){$._final(f)});return}if(D._socket===null)return;if(D._socket._writableState.finished){if(f(),$._readableState.endEmitted)$.destroy()}else D._socket.once("finish",function(){f()}),D.close()},$._read=function(){if(D.isPaused)D.resume()},$._write=function(f,P,B){if(D.readyState===D.CONNECTING){D.once("open",function(){$._write(f,P,B)});return}D.send(f,B)},$.on("end",LL),$.on("error",ez),$}D7.exports=NL});var i6=q((tb,A7)=>{var{tokenChars:VL}=PR();function IL(D){let R=new Set,A=-1,$=-1,f=0;for(f;f<D.length;f++){let B=D.charCodeAt(f);if($===-1&&VL[B]===1){if(A===-1)A=f}else if(f!==0&&(B===32||B===9)){if($===-1&&A!==-1)$=f}else if(B===44){if(A===-1)throw SyntaxError(`Unexpected character at index ${f}`);if($===-1)$=f;let G=D.slice(A,$);if(R.has(G))throw SyntaxError(`The "${G}" subprotocol is duplicated`);R.add(G),A=$=-1}else throw SyntaxError(`Unexpected character at index ${f}`)}if(A===-1||$!==-1)throw SyntaxError("Unexpected end of input");let P=D.slice(A,f);if(R.has(P))throw SyntaxError(`The "${P}" subprotocol is duplicated`);return R.add(P),R}A7.exports={parse:IL}});var G7=q((Du,B7)=>{var KL=p("events"),sf=p("http"),{Duplex:eb}=p("stream"),{createHash:WL}=p("crypto"),$7=lf(),w1=fR(),jL=i6(),SL=rf(),{CLOSE_TIMEOUT:bL,GUID:uL,kWebSocket:EL}=QD(),yL=/^[+/0-9A-Za-z]{22}==$/;class P7 extends KL{constructor(D,R){super();if(D={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:bL,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:SL,...D},D.port==null&&!D.server&&!D.noServer||D.port!=null&&(D.server||D.noServer)||D.server&&D.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(D.port!=null)this._server=sf.createServer((A,$)=>{let f=sf.STATUS_CODES[426];$.writeHead(426,{"Content-Length":f.length,"Content-Type":"text/plain"}),$.end(f)}),this._server.listen(D.port,D.host,D.backlog,R);else if(D.server)this._server=D.server;if(this._server){let A=this.emit.bind(this,"connection");this._removeListeners=gL(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:($,f,P)=>{this.handleUpgrade($,f,P,A)}})}if(D.perMessageDeflate===!0)D.perMessageDeflate={};if(D.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=D,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close(D){if(this._state===2){if(D)this.once("close",()=>{D(Error("The server is not running"))});process.nextTick(jA,this);return}if(D)this.once("close",D);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(jA,this);else this._shouldEmitClose=!0;else process.nextTick(jA,this)}else{let R=this._server;this._removeListeners(),this._removeListeners=this._server=null,R.close(()=>{jA(this)})}}shouldHandle(D){if(this.options.path){let R=D.url.indexOf("?");if((R!==-1?D.url.slice(0,R):D.url)!==this.options.path)return!1}return!0}handleUpgrade(D,R,A,$){R.on("error",f7);let f=D.headers["sec-websocket-key"],P=D.headers.upgrade,B=+D.headers["sec-websocket-version"];if(D.method!=="GET"){C1(this,D,R,405,"Invalid HTTP method");return}if(P===void 0||P.toLowerCase()!=="websocket"){C1(this,D,R,400,"Invalid Upgrade header");return}if(f===void 0||!yL.test(f)){C1(this,D,R,400,"Missing or invalid Sec-WebSocket-Key header");return}if(B!==13&&B!==8){C1(this,D,R,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(D)){SA(R,400);return}let G=D.headers["sec-websocket-protocol"],z=new Set;if(G!==void 0)try{z=jL.parse(G)}catch(H){C1(this,D,R,400,"Invalid Sec-WebSocket-Protocol header");return}let J=D.headers["sec-websocket-extensions"],Z={};if(this.options.perMessageDeflate&&J!==void 0){let H=new w1({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let M=$7.parse(J);if(M[w1.extensionName])H.accept(M[w1.extensionName]),Z[w1.extensionName]=H}catch(M){C1(this,D,R,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let H={origin:D.headers[`${B===8?"sec-websocket-origin":"origin"}`],secure:!!(D.socket.authorized||D.socket.encrypted),req:D};if(this.options.verifyClient.length===2){this.options.verifyClient(H,(M,Q,O,X)=>{if(!M)return SA(R,Q||401,O,X);this.completeUpgrade(Z,f,z,D,R,A,$)});return}if(!this.options.verifyClient(H))return SA(R,401)}this.completeUpgrade(Z,f,z,D,R,A,$)}completeUpgrade(D,R,A,$,f,P,B){if(!f.readable||!f.writable)return f.destroy();if(f[EL])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return SA(f,503);let z=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${WL("sha1").update(R+uL).digest("base64")}`],J=new this.options.WebSocket(null,void 0,this.options);if(A.size){let Z=this.options.handleProtocols?this.options.handleProtocols(A,$):A.values().next().value;if(Z)z.push(`Sec-WebSocket-Protocol: ${Z}`),J._protocol=Z}if(D[w1.extensionName]){let Z=D[w1.extensionName].params,H=$7.format({[w1.extensionName]:[Z]});z.push(`Sec-WebSocket-Extensions: ${H}`),J._extensions=D}if(this.emit("headers",z,$),f.write(z.concat(`\r
165
165
  `).join(`\r
166
- `)),f.removeListener("error",f7),J.setSocket(f,P,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(J),J.on("close",()=>{if(this.clients.delete(J),this._shouldEmitClose&&!this.clients.size)process.nextTick(jA,this)});B(J,$)}}B7.exports=P7;function xL(D,R){for(let A of Object.keys(R))D.on(A,R[A]);return function(){for(let $ of Object.keys(R))D.removeListener($,R[$])}}function jA(D){D._state=2,D.emit("close")}function f7(){this.destroy()}function SA(D,R,A,$){A=A||r2.STATUS_CODES[R],$={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(A),...$},D.once("finish",D.destroy),D.end(`HTTP/1.1 ${R} ${r2.STATUS_CODES[R]}\r
166
+ `)),f.removeListener("error",f7),J.setSocket(f,P,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(J),J.on("close",()=>{if(this.clients.delete(J),this._shouldEmitClose&&!this.clients.size)process.nextTick(jA,this)});B(J,$)}}B7.exports=P7;function gL(D,R){for(let A of Object.keys(R))D.on(A,R[A]);return function(){for(let $ of Object.keys(R))D.removeListener($,R[$])}}function jA(D){D._state=2,D.emit("close")}function f7(){this.destroy()}function SA(D,R,A,$){A=A||sf.STATUS_CODES[R],$={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(A),...$},D.once("finish",D.destroy),D.end(`HTTP/1.1 ${R} ${sf.STATUS_CODES[R]}\r
167
167
  `+Object.keys($).map((f)=>`${f}: ${$[f]}`).join(`\r
168
168
  `)+`\r
169
169
  \r
170
- `+A)}function C1(D,R,A,$,f,P){if(D.listenerCount("wsClientError")){let B=Error(f);Error.captureStackTrace(B,C1),D.emit("wsClientError",B,A,R)}else SA(A,$,f,P)}});var Q4=B0(X4(),1),{program:TN,createCommand:ON,createArgument:YN,createOption:_N,CommanderError:UN,InvalidArgumentError:T4,InvalidOptionArgumentError:FN,Command:Bf,Argument:qN,Option:wN,Help:CN}=Q4.default;var a=B0(mA(),1);function W(D,R=!1){if(R){console.log(JSON.stringify(D,null,2));return}if(Array.isArray(D)){if(D.length===0){console.log(a.default.dim("No results"));return}console.table(D);return}console.log(D)}function o0(D){for(let[R,A]of Object.entries(D))console.log(`${a.default.cyan(R)}: ${q4(A)}`)}function YD(D){let R=Object.entries(D).filter(([,$])=>$!==""),A=R.reduce(($,[f])=>Math.max($,f.length),0);for(let[$,f]of R)console.log(`${a.default.dim($.padEnd(A," "))} ${q4(f)}`)}function s(D,R){if(R.length===0){console.log(a.default.dim("No results"));return}let A=D.map((f,P)=>{let B=R.reduce((G,z)=>{return Math.max(G,Jf(f.render(z),f.width).length)},0);return Math.max(D[P].header.length,f.width??B)}),$=D.map((f,P)=>U4(f.header.toUpperCase(),A[P])).join(" ");console.log(a.default.bold($));for(let f of R)console.log(D.map((P,B)=>U4(Jf(P.render(f),D[B].width),A[B])).join(" "))}function Hf(D){pA("App"),o0({id:D.id,name:D.name,status:D.status,endpoint:D.url??"",defaultDomain:D.defaultDomain,plan:D.plan??"",bundle:D.bundle??""})}function Zf(D){pA("Deployment"),o0({id:D.id,status:D.status,method:D.method,trigger:D.trigger,message:D.message??"",createdAt:D.createdAt,updatedAt:D.updatedAt})}function QR(D){s([{header:"Kind",width:24,render:(R)=>R.kind},{header:"Effective",width:20,render:(R)=>R.effectiveAt},{header:"Age",width:6,render:(R)=>H0(R.createdAt)},{header:"Data",width:52,render:(R)=>w4(R.data)},{header:"ID",width:8,render:(R)=>String(R.id)}],D)}function TR(D){YD({id:D.id,kind:D.kind,effectiveAt:D.effectiveAt,userId:D.userId??"",data:w4(D.data),createdAt:D.createdAt})}function OR(D){s([{header:"Time",width:24,render:(R)=>L0(R,"time","timestamp","createdAt")},{header:"Source",width:20,render:(R)=>L0(R,"pod","source")},{header:"Container",width:16,render:(R)=>L0(R,"container")},{header:"Message",width:96,render:(R)=>L0(R,"message","line")}],D)}function Mf(D){s([{header:"Key",render:(R)=>R.key},{header:"Value",width:36,render:(R)=>R.value},{header:"Updated",width:20,render:(R)=>R.updatedAt??""}],D)}function Xf(D){pA("Domain"),o0({hostname:D.hostname,verification:D.verificationStatus,tlsEnabled:D.tlsEnabled,tlsStatus:D.tlsStatus,forceHttps:D.forceHttps})}function kD(D){pA("Disk"),o0({id:D.id,name:D.name,size:D.size,mounted:D.mounted,mountPath:D.mountPath??""})}function Qf(D){s([{header:"Name",width:18,render:(R)=>R.name??""},{header:"Mounted",width:8,render:(R)=>R.mounted?"yes":"no"},{header:"Size",width:6,render:(R)=>`${R.size}G`},{header:"Mount Path",width:28,render:(R)=>R.mountPath??""},{header:"Age",width:6,render:(R)=>H0(R.createdAt)}],D)}function Tf(D,R){let A=D.publicAccess&&D.publicPort?`${D.host??""}:${D.publicPort}`:D.publicAccess?"pending":"",$={id:D.id,name:D.name,engine:D.engine,status:D.status,plan:D.plan??"",bundle:D.bundle??"",user:L0(D,"username"),host:D.host,port:D.port,database:D.databaseName,published:C4(D,"publicAccess"),publicAddress:A,version:D.version,error:L0(D,"statusMessage","statusReason","lastError")};if(YD($),R?.password)console.log(),console.log(a.default.bold("password")),console.log(a.default.yellow(R.password))}function Of(D,R,A){console.log(`Database credentials for ${D}`),console.log(),YD({user:R.username,password:A?.reveal?R.password:"********",host:R.host,port:R.port,database:R.databaseName})}function Yf(D,R){s([{header:"Project",width:22,render:()=>D},{header:"Name",width:22,render:(A)=>A.name??""},{header:"Engine",width:8,render:(A)=>A.engine??""},{header:"Status",width:12,render:(A)=>A.status??""},{header:"Plan",width:12,render:(A)=>A.plan??""},{header:"Bundle",width:12,render:(A)=>A.bundle??""},{header:"Public",width:24,render:(A)=>A.publicAccess&&A.publicPort?`${A.host??""}:${A.publicPort}`:C4(A,"publicAccess")?"pending":""},{header:"Age",width:6,render:(A)=>H0(A.createdAt)}],R)}function _f(D){s([{header:"Name",width:16,render:(R)=>R.name??""},{header:"CPU",width:6,render:(R)=>String(N1(R,"cpuMilli")??"")},{header:"Memory",width:8,render:(R)=>String(N1(R,"memoryMb")??"")},{header:"Disk",width:6,render:(R)=>String(N1(R,"diskGb")??"")},{header:"Price",width:8,render:(R)=>String(R.priceHourly??"")}],D)}function Uf(D){s([{header:"Engine",width:12,render:(R)=>R.engine},{header:"Versions",width:32,render:(R)=>R.versions.join(", ")}],D)}function Ff(D){YD({name:D.name,cpu:N1(D,"cpuMilli")??"",memory:N1(D,"memoryMb")??"",disk:N1(D,"diskGb")??""})}function qf(D){s([{header:"Name",width:16,render:(R)=>R.name??""},{header:"Backup GB",width:8,render:(R)=>String(R.backupStorageGb??"")},{header:"Daily",width:10,render:(R)=>R.dailyBackupRetentionDays?`${R.dailyBackupRetentionDays}d`:""},{header:"Metrics",width:8,render:(R)=>R.metricsRetentionDays?`${R.metricsRetentionDays}d`:""},{header:"Public",width:6,render:(R)=>R.publicAccess===void 0?"":R.publicAccess?"yes":"no"},{header:"Price",width:8,render:(R)=>String(R.priceHourly??"")}],D)}function wf(D){YD({name:D.name,priceHourly:D.priceHourly,priceMonthly:D.priceMonthly,backupStorageGb:D.backupStorageGb,dailyBackupRetention:`${D.dailyBackupRetentionDays??0}d`,weeklyBackupRetention:`${D.weeklyBackupRetentionDays??0}d`,manualBackupsPerHour:D.manualBackupsPerHour,metricsRetention:`${D.metricsRetentionDays}d`,publicExposure:D.publicAccess,databasePlugins:D.databasePlugins,databaseCustomConfig:D.databaseCustomConfig})}function xA(D){YD({id:D.id,status:D.status,storageKey:D.storageKey??"",sizeBytes:D.sizeBytes??"",startedAt:D.startedAt??"",completedAt:D.completedAt??"",expiresAt:D.expiresAt??"",error:D.errorMessage??""})}function Cf(D){s([{header:"Status",width:10,render:(R)=>R.status??""},{header:"Size",width:12,render:(R)=>String(R.sizeBytes??"")},{header:"Expires",width:8,render:(R)=>hA(R.expiresAt)},{header:"Age",width:6,render:(R)=>H0(R.createdAt)},{header:"ID",width:8,render:(R)=>String(R.id)}],D)}function Lf(D){let R=D;YD({connections:R.connections,qps:R.qps??"",readQps:R.readQps??"",writeQps:R.writeQps??"",slowQueriesQps:R.slowQueriesQps??"",cpuUsageCores:R.cpuUsageCores??"",memoryUsageBytes:R.memoryUsageBytes??"",storageBytes:R.storageBytes??"",storageUsedBytes:R.storageUsedBytes??"",window:R.window,measuredAt:R.measuredAt})}function nA(D,R){let A=L0(D,"status"),$=L0(D,"prefix"),f=L0(D,"lastUsedAt"),P={id:D.id,name:D.name,prefix:$,access:L4(D,R?.projectLabel),expiresAt:D.expiresAt??""};if(A&&A!=="active")P.status=A;if(f)P.lastUsedAt=f;if(YD(P),R?.plaintextToken)console.log(),console.log(a.default.bold("token")),console.log(a.default.yellow(R.plaintextToken))}function Nf(D,R){s([{header:"Name",width:22,render:(A)=>A.name??""},{header:"Status",width:10,render:(A)=>L0(A,"status")||(A.revokedAt?"revoked":"active")},{header:"Access",width:34,render:(A)=>L4(A,R?.projectLabel)},{header:"Expires",width:8,render:(A)=>hA(A.expiresAt)},{header:"Last Used",width:9,render:(A)=>H0(L0(A,"lastUsedAt")||A.lastUsedAt)},{header:"Age",width:6,render:(A)=>H0(A.createdAt)},{header:"ID",width:18,render:(A)=>String(A.id)}],D)}function F4(D){let R=D.indexOf("=");if(R<=0)throw Error(`Invalid env entry: ${D}. Expected KEY=VALUE`);return{key:D.slice(0,R),value:D.slice(R+1)}}function Vf(D){if(typeof D==="object"&&D!==null){let R=D;if(typeof R.status==="number"){let $=R.status?`Request failed (${R.status}${R.statusText?` ${R.statusText}`:""})`:"Request failed",f=R.error??R.data,P=zf(f);if(P)return`${$}: ${P}`;return $}let A=D;if(A.response?.data){let $=A.response.status?`Request failed (${A.response.status})`:"Request failed",f=zf(A.response.data);if(f)return`${$}: ${f}`}if(A.message){let $=_4(D);if($)return`${A.message}: ${$}`;return A.message}}if(D instanceof Error){let R=_4(D);if(R)return`${D.message}: ${R}`;return D.message}if(typeof D==="string")return D;return String(D)}function zf(D){if(typeof D==="string"&&D)return D;if(typeof D!=="object"||D===null)return D==null?"":String(D);if("error"in D){let R=D.error,A=zf(R);if(A)return A}if("message"in D&&typeof D.message==="string")return D.message;if("code"in D&&typeof D.code==="string")return D.code;return JSON.stringify(D)}function _4(D){if(typeof D!=="object"||D===null||!("cause"in D))return"";let R=D.cause;if(typeof R==="string")return R;if(typeof R!=="object"||R===null)return"";let A=R;return[A.syscall,A.code,A.address,A.port].filter(Boolean).join(" ")||A.message||""}function If(D){let R=D.split(/\r?\n/),[A="",...$]=R;console.error(a.default.red(`Error: ${A}`));for(let f of $)console.error(a.default.red(` ${f}`))}function pA(D){console.log(a.default.bold(a.default.magenta(D))),console.log(a.default.dim("-".repeat(D.length)))}function q4(D){if(D==null)return"";if(typeof D==="boolean")return D?a.default.green("yes"):a.default.dim("no");if(typeof D==="number")return a.default.yellow(String(D));if(typeof D==="string")return $H(D);return JSON.stringify(D)}function $H(D){let R=D.toLowerCase();if(["ready","active","approved","healthy","running","mounted","verified","available"].includes(R))return a.default.green(D);if(["pending","building","provisioning","mounting","unmounting","expanding"].includes(R))return a.default.yellow(D);if(["failed","denied","revoked","expired","cancelled","error","frozen"].includes(R))return a.default.red(D);return D}function H0(D){if(!D)return"";let R=new Date(D).getTime();if(!Number.isFinite(R))return"";let A=Math.max(0,Math.floor((Date.now()-R)/1000));if(A<60)return`${A}s`;let $=Math.floor(A/60);if($<60)return`${$}m`;let f=Math.floor($/60);if(f<24)return`${f}h`;let P=Math.floor(f/24);if(P<30)return`${P}d`;let B=Math.floor(P/30);if(B<12)return`${B}mo`;return`${Math.floor(P/365)}y`}function hA(D){if(!D)return"never";let R=new Date(D).getTime();if(!Number.isFinite(R))return"";let A=Math.max(0,Math.floor((R-Date.now())/1000));if(A<60)return`${A}s`;let $=Math.floor(A/60);if($<60)return`${$}m`;let f=Math.floor($/60);if(f<24)return`${f}h`;let P=Math.floor(f/24);if(P<30)return`${P}d`;let B=Math.floor(P/30);if(B<12)return`${B}mo`;return`${Math.floor(P/365)}y`}function Jf(D,R){if(!R||D.length<=R)return D;if(R<=1)return D.slice(0,R);return`${D.slice(0,R-1)}…`}function U4(D,R){return D.padEnd(R," ")}function w4(D){if(Object.keys(D).length===0)return"";return Jf(JSON.stringify(D),52)}function N1(D,...R){let A=D;for(let $ of R)if(typeof A[$]==="number")return A[$];return}function L0(D,...R){let A=D;for(let $ of R)if(typeof A[$]==="string")return A[$];return""}function C4(D,...R){let A=D;for(let $ of R)if(typeof A[$]==="boolean")return A[$];return}function L4(D,R){return(D.projectAccess??[]).map(($)=>`${R?.($.projectId)??`#${$.projectId}`}:${$.role}`).join(", ")}function _(D){return D}function _D(D){return(R)=>{if(D.includes(R))return R;throw new T4(`Invalid value "${R}". Expected one of: ${D.join(", ")}`)}}async function fH(D,R){let A=-1,$=async()=>{A+=1;let f=R[A];if(!f)return;await Promise.resolve(f(D,$))};await $()}class vA{raw;state;constructor(D,R){this.raw=D??new Bf,this.state=R??{argDefs:[],middlewares:[]}}name(D){return this.raw.name(D),this}description(D){return this.raw.description(D),this}alias(D){return this.raw.alias(D),this}option(D,R,A,$){if(A){let f=A;this.raw.option(D,R??"",f,$)}else if(R!==void 0)this.raw.option(D,R);else this.raw.option(D);return this}argument(D,R,A){return this.raw.argument(D,R,A),this.state.argDefs.push(PH(D)),this}onions(D){return this.state.middlewares=[...D],this.raw.action(async(...R)=>{let A=R.at(-1);if(!(A instanceof Bf))throw Error("Unable to resolve command context");let $=this.getOptions(A),f=this.getArgs(R.slice(0,-1)),P=this.createContext(A,$,f);try{await fH(P,this.state.middlewares)}catch(B){P.abort(Vf(B))}}),this}command(D){let R=this.raw.command(D);return new vA(R)}parse(D){try{this.raw.parse(D)}catch(R){If(Vf(R)),process.exit(1)}return this}unwrap(){return this.raw}getOptions(D){let R=D.optsWithGlobals;if(typeof R==="function")return R.call(D);return D.opts()}getArgs(D){return this.state.argDefs.reduce((R,A,$)=>{let f=D[$];if(f!==void 0)R[A.key]=f;return R},{})}createContext(D,R,A){return{argv:R,options:R,args:A,command:D,abort($){If($??"Aborted"),process.exit(1)}}}}function PH(D){let R=D.trim();if(R.startsWith("<")&&R.endsWith(">"))return{key:R.slice(1,-1),required:!0};if(R.startsWith("[")&&R.endsWith("]"))return{key:R.slice(1,-1),required:!1};throw Error(`Unsupported argument spec: ${D}`)}function _0(D){if(D===void 0)return;let R=typeof D==="number"?D:Number(D);if(!Number.isInteger(R)||R<0)throw Error("Tail must be a non-negative integer.");return R}function lA(D){let R=typeof D==="number"?D:Number(D);if(!Number.isInteger(R)||R<1||R>65535)throw Error("Port must be an integer between 1 and 65535.");return R}function YR(D,R){return D.id===R||D.label===R||D.email===R}function _R(D,R){return String(D.id)===R||D.slug===R||D.name===R}function N4(D,R){return String(D.id)===R||D.name===R}function V4(D,R){return String(D.id)===R||D.name===R}function I4(D,R){return String(D.id)===R||D.name===R}function kA(D,R){return(D.name??"").toLowerCase()===R.toLowerCase()}function dA(D,R){return(D.name??"").toLowerCase()===R.toLowerCase()}function K4(D,R){return String(D.id)===R||D.name===R||D.prefix===R}function dD(D,R,A){let $=R?D.find((f)=>(f.name??"").toLowerCase()===R.toLowerCase()):(A?D.find((f)=>(f.name??"").toLowerCase()===A.toLowerCase()):void 0)||D[0];if(!$)throw Error(R?`App plan not found: ${R}`:"No app plan available.");return $}function iD(D,R,A){let $=R?D.find((f)=>(f.name??"").toLowerCase()===R.toLowerCase()):(A?D.find((f)=>(f.name??"").toLowerCase()===A.toLowerCase()):void 0)||D[0];if(!$)throw Error(R?`App bundle not found: ${R}`:"No app bundle available.");return $}function UD(D,R,A){let $=(R?D.find((f)=>kA(f,R)):void 0)||(A?D.find((f)=>kA(f,A)):void 0)||D[0];if(!$)throw Error("No database plan available.");return $}function V1(D,R,A){let $=(R?D.find((f)=>dA(f,R)):void 0)||(A?D.find((f)=>dA(f,A)):void 0)||D[0];if(!$)throw Error("No database bundle available.");return $}function W4(D){return D.plan}function j4(D){return D.bundle}var K=_(async(D,R)=>{let A=process.env.ABRUN_TOKEN??D.options.token;if(A){D.auth={id:process.env.ABRUN_TOKEN?"env":"flag",label:process.env.ABRUN_TOKEN?"env":"flag",email:process.env.ABRUN_TOKEN?"env-token":"flag-token",token:A,endpoint:D.endpoint},D.token=A,await R();return}let $=D.options.auth?D.state.auths.find((f)=>YR(f,D.options.auth)):D.state.currentAuthId?D.state.auths.find((f)=>f.id===D.state.currentAuthId):void 0;if(!$)D.abort("No active auth. Run `abrun login` first or set ABRUN_TOKEN.");D.auth=$,D.token=$.token,D.endpoint=D.options.endpoint??$.endpoint??D.endpoint,await R()});var S4;((P)=>{P.Json="application/json";P.JsonApi="application/vnd.api+json";P.FormData="multipart/form-data";P.UrlEncoded="application/x-www-form-urlencoded";P.Text="text/plain"})(S4||={});class Kf{baseUrl="https://api.abr.run";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...D)=>fetch(...D);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(D={}){Object.assign(this,D)}setSecurityData=(D)=>{this.securityData=D};encodeQueryParam(D,R){return`${encodeURIComponent(D)}=${encodeURIComponent(typeof R==="number"?R:`${R}`)}`}addQueryParam(D,R){return this.encodeQueryParam(R,D[R])}addArrayQueryParam(D,R){return D[R].map(($)=>this.encodeQueryParam(R,$)).join("&")}toQueryString(D){let R=D||{};return Object.keys(R).filter(($)=>typeof R[$]<"u").map(($)=>Array.isArray(R[$])?this.addArrayQueryParam(R,$):this.addQueryParam(R,$)).join("&")}addQueryParams(D){let R=this.toQueryString(D);return R?`?${R}`:""}contentFormatters={["application/json"]:(D)=>D!==null&&(typeof D==="object"||typeof D==="string")?JSON.stringify(D):D,["application/vnd.api+json"]:(D)=>D!==null&&(typeof D==="object"||typeof D==="string")?JSON.stringify(D):D,["text/plain"]:(D)=>D!==null&&typeof D!=="string"?JSON.stringify(D):D,["multipart/form-data"]:(D)=>{if(D instanceof FormData)return D;return Object.keys(D||{}).reduce((R,A)=>{let $=D[A];return R.append(A,$ instanceof Blob?$:typeof $==="object"&&$!==null?JSON.stringify($):`${$}`),R},new FormData)},["application/x-www-form-urlencoded"]:(D)=>this.toQueryString(D)};mergeRequestParams(D,R){return{...this.baseApiParams,...D,...R||{},headers:{...this.baseApiParams.headers||{},...D.headers||{},...R&&R.headers||{}}}}createAbortSignal=(D)=>{if(this.abortControllers.has(D)){let A=this.abortControllers.get(D);if(A)return A.signal;return}let R=new AbortController;return this.abortControllers.set(D,R),R.signal};abortRequest=(D)=>{let R=this.abortControllers.get(D);if(R)R.abort(),this.abortControllers.delete(D)};request=async({body:D,secure:R,path:A,type:$,query:f,format:P,baseUrl:B,cancelToken:G,...z})=>{let J=(typeof R==="boolean"?R:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},Z=this.mergeRequestParams(z,J),H=f&&this.toQueryString(f),M=this.contentFormatters[$||"application/json"],Q=P||Z.format;return this.customFetch(`${B||this.baseUrl||""}${A}${H?`?${H}`:""}`,{...Z,headers:{...Z.headers||{},...$&&$!=="multipart/form-data"?{"Content-Type":$}:{}},signal:(G?this.createAbortSignal(G):Z.signal)||null,body:typeof D>"u"||D===null?null:M(D)}).then(async(O)=>{let X=O;X.data=null,X.error=null;let T=Q?O.clone():O,U=!Q?X:await T[Q]().then((F)=>{if(X.ok)X.data=F;else X.error=F;return X}).catch((F)=>{return X.error=F,X});if(G)this.abortControllers.delete(G);if(!O.ok)throw U;return U.data})}}class Wf{http;constructor(D){this.http=D}appPlansBundlesList=({planName:D},R={})=>this.http.request({path:`/v1/app-plans/${D}/bundles`,method:"GET",secure:!0,format:"json",...R});appPlansDetail=({planName:D},R={})=>this.http.request({path:`/v1/app-plans/${D}`,method:"GET",secure:!0,format:"json",...R});appPlansList=(D={})=>this.http.request({path:"/v1/app-plans",method:"GET",secure:!0,format:"json",...D});appsAnalyticsBreakdownList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/analytics/breakdown`,method:"GET",query:R,secure:!0,format:"json",...A});appsAnalyticsFilterValuesList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/analytics/filter-values`,method:"GET",query:R,secure:!0,format:"json",...A});appsAnalyticsList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/analytics`,method:"GET",query:R,secure:!0,format:"json",...A});appsAnalyticsSeriesList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/analytics/series`,method:"GET",query:R,secure:!0,format:"json",...A});appsApplyCreate=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/apply`,method:"POST",secure:!0,format:"json",...R});appsAvailabilityList=(D,R={})=>this.http.request({path:"/v1/apps/availability",method:"GET",query:D,secure:!0,format:"json",...R});appsConsoleList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/console`,method:"GET",query:R,secure:!0,...A});appsConsoleSessionCreate=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/console/session`,method:"POST",query:R,secure:!0,format:"json",...A});appsCreate=(D,R={})=>this.http.request({path:"/v1/apps",method:"POST",body:D,secure:!0,type:"application/json",format:"json",...R});appsDelete=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}`,method:"DELETE",secure:!0,format:"json",...R});appsDeployCreate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/deploy`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});appsDeploymentsCancelCreate=({appId:D,deploymentId:R},A={})=>this.http.request({path:`/v1/apps/${D}/deployments/${R}/cancel`,method:"POST",secure:!0,format:"json",...A});appsDeploymentsDetail=({appId:D,deploymentId:R},A={})=>this.http.request({path:`/v1/apps/${D}/deployments/${R}`,method:"GET",secure:!0,format:"json",...A});appsDeploymentsList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/deployments`,method:"GET",query:R,secure:!0,format:"json",...A});appsDeploymentsLogsList=({appId:D,deploymentId:R,...A},$={})=>this.http.request({path:`/v1/apps/${D}/deployments/${R}/logs`,method:"GET",query:A,secure:!0,format:"json",...$});appsDeploymentsRollbackCreate=({appId:D,deploymentId:R},A={})=>this.http.request({path:`/v1/apps/${D}/deployments/${R}/rollback`,method:"POST",secure:!0,format:"json",...A});appsDetail=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}`,method:"GET",secure:!0,format:"json",...R});appsDisksCreate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/disks`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});appsDisksDelete=({appId:D,diskId:R},A={})=>this.http.request({path:`/v1/apps/${D}/disks/${R}`,method:"DELETE",secure:!0,...A});appsDisksDetail=({appId:D,diskId:R},A={})=>this.http.request({path:`/v1/apps/${D}/disks/${R}`,method:"GET",secure:!0,format:"json",...A});appsDisksExpandCreate=({appId:D,diskId:R},A,$={})=>this.http.request({path:`/v1/apps/${D}/disks/${R}/expand`,method:"POST",body:A,secure:!0,type:"application/json",format:"json",...$});appsDisksList=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/disks`,method:"GET",secure:!0,format:"json",...R});appsDisksMountCreate=({appId:D,diskId:R},A,$={})=>this.http.request({path:`/v1/apps/${D}/disks/${R}/mount`,method:"POST",body:A,secure:!0,type:"application/json",format:"json",...$});appsDisksPartialUpdate=({appId:D,diskId:R},A,$={})=>this.http.request({path:`/v1/apps/${D}/disks/${R}`,method:"PATCH",body:A,secure:!0,type:"application/json",format:"json",...$});appsDisksUnmountCreate=({appId:D,diskId:R},A={})=>this.http.request({path:`/v1/apps/${D}/disks/${R}/unmount`,method:"POST",secure:!0,format:"json",...A});appsDomainsAvailabilityList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/domains/availability`,method:"GET",query:R,secure:!0,format:"json",...A});appsDomainsCreate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/domains`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});appsDomainsDelete=({appId:D,domainId:R},A={})=>this.http.request({path:`/v1/apps/${D}/domains/${R}`,method:"DELETE",secure:!0,...A});appsDomainsDetail=({appId:D,domainId:R},A={})=>this.http.request({path:`/v1/apps/${D}/domains/${R}`,method:"GET",secure:!0,format:"json",...A});appsDomainsList=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/domains`,method:"GET",secure:!0,format:"json",...R});appsDomainsPartialUpdate=({appId:D,domainId:R},A,$={})=>this.http.request({path:`/v1/apps/${D}/domains/${R}`,method:"PATCH",body:A,secure:!0,type:"application/json",format:"json",...$});appsDomainsVerifyCreate=({appId:D,domainId:R},A={})=>this.http.request({path:`/v1/apps/${D}/domains/${R}/verify`,method:"POST",secure:!0,format:"json",...A});appsEnvList=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/env`,method:"GET",secure:!0,format:"json",...R});appsEnvUpdate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/env`,method:"PUT",body:R,secure:!0,type:"application/json",format:"json",...A});appsEventsList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/events`,method:"GET",query:R,secure:!0,format:"json",...A});appsGitSourceDelete=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/git-source`,method:"DELETE",secure:!0,...R});appsGitSourceList=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/git-source`,method:"GET",secure:!0,format:"json",...R});appsGitSourceUpdate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/git-source`,method:"PUT",body:R,secure:!0,type:"application/json",format:"json",...A});appsList=(D={})=>this.http.request({path:"/v1/apps",method:"GET",secure:!0,format:"json",...D});appsLogsList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/logs`,method:"GET",query:R,secure:!0,format:"json",...A});appsPartialUpdate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}`,method:"PATCH",body:R,secure:!0,type:"application/json",format:"json",...A});appsResizeCreate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/resize`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});appsRestartCreate=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/restart`,method:"POST",secure:!0,format:"json",...R});appsStartCreate=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/start`,method:"POST",secure:!0,format:"json",...R});appsStopCreate=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/stop`,method:"POST",secure:!0,format:"json",...R});appsUploadCreate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/upload`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});appsUsageDetail=({appId:D,metric:R},A={})=>this.http.request({path:`/v1/apps/${D}/usage/${R}`,method:"GET",secure:!0,format:"json",...A});appsUsageList=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/usage`,method:"GET",secure:!0,format:"json",...R});authApiTokensCreate=(D,R={})=>this.http.request({path:"/v1/auth/api-tokens",method:"POST",body:D,secure:!0,type:"application/json",format:"json",...R});authApiTokensDelete=({tokenId:D},R={})=>this.http.request({path:`/v1/auth/api-tokens/${D}`,method:"DELETE",secure:!0,...R});authApiTokensList=(D,R={})=>this.http.request({path:"/v1/auth/api-tokens",method:"GET",query:D,secure:!0,format:"json",...R});authCliLoginDecisionCreate=({browserCode:D},R,A={})=>this.http.request({path:`/v1/auth/cli-login/${D}`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});authCliLoginPromptDetail=({browserCode:D},R={})=>this.http.request({path:`/v1/auth/cli-login/${D}`,method:"GET",secure:!0,format:"json",...R});authCliLoginStartOrPoll=(D,R={})=>this.http.request({path:"/v1/auth/cli-login",method:"POST",body:D,type:"application/json",format:"json",...R});authLoginCreate=(D,R={})=>this.http.request({path:"/v1/auth/login",method:"POST",body:D,type:"application/json",format:"json",...R});authLogoutAllCreate=(D,R={})=>this.http.request({path:"/v1/auth/logout-all",method:"POST",body:D,secure:!0,type:"application/json",...R});authLogoutCreate=(D={})=>this.http.request({path:"/v1/auth/logout",method:"POST",secure:!0,...D});authMeList=(D={})=>this.http.request({path:"/v1/auth/me",method:"GET",secure:!0,format:"json",...D});authMePartialUpdate=(D,R={})=>this.http.request({path:"/v1/auth/me",method:"PATCH",body:D,secure:!0,type:"application/json",format:"json",...R});authPasswordChangeCreate=(D,R={})=>this.http.request({path:"/v1/auth/password/change",method:"POST",body:D,secure:!0,type:"application/json",...R});authPasswordForgotCreate=(D,R={})=>this.http.request({path:"/v1/auth/password/forgot",method:"POST",body:D,type:"application/json",format:"json",...R});authPasswordResetCreate=(D,R={})=>this.http.request({path:"/v1/auth/password/reset",method:"POST",body:D,type:"application/json",format:"json",...R});authResendVerificationCreate=(D={})=>this.http.request({path:"/v1/auth/resend-verification",method:"POST",secure:!0,format:"json",...D});authSessionsDelete=({sessionId:D},R={})=>this.http.request({path:`/v1/auth/sessions/${D}`,method:"DELETE",secure:!0,...R});authSessionsList=(D={})=>this.http.request({path:"/v1/auth/sessions",method:"GET",secure:!0,format:"json",...D});authSignupCreate=(D,R={})=>this.http.request({path:"/v1/auth/signup",method:"POST",body:D,type:"application/json",format:"json",...R});authVerifyEmailCreate=(D,R={})=>this.http.request({path:"/v1/auth/verify-email",method:"POST",body:D,type:"application/json",format:"json",...R});databaseBackupsDownloadUrlCreate=({backupId:D},R,A={})=>this.http.request({path:`/v1/database-backups/${D}/download-url`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});databaseEnginesList=(D={})=>this.http.request({path:"/v1/database-engines",method:"GET",secure:!0,format:"json",...D});databasePlansBundlesList=({planName:D},R={})=>this.http.request({path:`/v1/database-plans/${D}/bundles`,method:"GET",secure:!0,format:"json",...R});databasePlansDetail=({planName:D},R={})=>this.http.request({path:`/v1/database-plans/${D}`,method:"GET",secure:!0,format:"json",...R});databasePlansList=(D={})=>this.http.request({path:"/v1/database-plans",method:"GET",secure:!0,format:"json",...D});databasesAvailabilityList=(D,R={})=>this.http.request({path:"/v1/databases/availability",method:"GET",query:D,secure:!0,format:"json",...R});databasesBackupsCreate=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}/backups`,method:"POST",secure:!0,format:"json",...R});databasesBackupsDetail=({databaseId:D,backupId:R},A={})=>this.http.request({path:`/v1/databases/${D}/backups/${R}`,method:"GET",secure:!0,format:"json",...A});databasesBackupsList=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}/backups`,method:"GET",secure:!0,format:"json",...R});databasesCreate=(D,R={})=>this.http.request({path:"/v1/databases",method:"POST",body:D,secure:!0,type:"application/json",format:"json",...R});databasesCredentialsList=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}/credentials`,method:"GET",secure:!0,format:"json",...R});databasesDelete=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}`,method:"DELETE",secure:!0,format:"json",...R});databasesDetail=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}`,method:"GET",secure:!0,format:"json",...R});databasesEventsList=({databaseId:D,...R},A={})=>this.http.request({path:`/v1/databases/${D}/events`,method:"GET",query:R,secure:!0,format:"json",...A});databasesList=(D={})=>this.http.request({path:"/v1/databases",method:"GET",secure:!0,format:"json",...D});databasesLogsList=({databaseId:D,...R},A={})=>this.http.request({path:`/v1/databases/${D}/logs`,method:"GET",query:R,secure:!0,format:"json",...A});databasesPartialUpdate=({databaseId:D},R,A={})=>this.http.request({path:`/v1/databases/${D}`,method:"PATCH",body:R,secure:!0,type:"application/json",format:"json",...A});databasesResizeCreate=({databaseId:D},R,A={})=>this.http.request({path:`/v1/databases/${D}/resize`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});databasesStartCreate=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}/start`,method:"POST",secure:!0,format:"json",...R});databasesStopCreate=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}/stop`,method:"POST",secure:!0,format:"json",...R});databasesUsageDetail=({databaseId:D,metric:R},A={})=>this.http.request({path:`/v1/databases/${D}/usage/${R}`,method:"GET",secure:!0,format:"json",...A});databasesUsageList=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}/usage`,method:"GET",secure:!0,format:"json",...R});healthList=(D={})=>this.http.request({path:"/v1/health",method:"GET",format:"json",...D});integrationsGitDelete=({integrationId:D},R={})=>this.http.request({path:`/v1/integrations/git/${D}`,method:"DELETE",secure:!0,...R});integrationsGitList=(D={})=>this.http.request({path:"/v1/integrations/git",method:"GET",secure:!0,format:"json",...D});integrationsGitOauthCallbackList=({provider:D},R={})=>this.http.request({path:`/v1/integrations/git/${D}/oauth/callback`,method:"GET",secure:!0,format:"json",...R});integrationsGitOauthStartCreate=({provider:D},R={})=>this.http.request({path:`/v1/integrations/git/${D}/oauth/start`,method:"POST",secure:!0,format:"json",...R});invitesAcceptCreate=({token:D},R={})=>this.http.request({path:`/v1/invites/${D}/accept`,method:"POST",secure:!0,format:"json",...R});invitesDeclineCreate=({token:D},R={})=>this.http.request({path:`/v1/invites/${D}/decline`,method:"POST",secure:!0,format:"json",...R});invitesDetail=({token:D},R={})=>this.http.request({path:`/v1/invites/${D}`,method:"GET",secure:!0,format:"json",...R});notificationPreferencesList=(D={})=>this.http.request({path:"/v1/notification-preferences",method:"GET",secure:!0,format:"json",...D});notificationPreferencesUpdate=(D,R={})=>this.http.request({path:"/v1/notification-preferences",method:"PUT",body:D,secure:!0,type:"application/json",format:"json",...R});notificationsList=(D,R={})=>this.http.request({path:"/v1/notifications",method:"GET",query:D,secure:!0,format:"json",...R});notificationsPartialUpdate=({notificationId:D},R={})=>this.http.request({path:`/v1/notifications/${D}`,method:"PATCH",secure:!0,format:"json",...R});notificationsReadAllCreate=(D={})=>this.http.request({path:"/v1/notifications/read-all",method:"POST",secure:!0,...D});paymentsProvidersList=(D={})=>this.http.request({path:"/v1/payments/providers",method:"GET",secure:!0,format:"json",...D});projectsAvailabilityList=(D,R={})=>this.http.request({path:"/v1/projects/availability",method:"GET",query:D,secure:!0,format:"json",...R});projectsCreate=(D,R={})=>this.http.request({path:"/v1/projects",method:"POST",body:D,secure:!0,type:"application/json",format:"json",...R});projectsDelete=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}`,method:"DELETE",secure:!0,format:"json",...R});projectsDetail=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}`,method:"GET",secure:!0,format:"json",...R});projectsEventsList=({projectId:D,...R},A={})=>this.http.request({path:`/v1/projects/${D}/events`,method:"GET",query:R,secure:!0,format:"json",...A});projectsInvitesCreate=({projectId:D},R,A={})=>this.http.request({path:`/v1/projects/${D}/invites`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});projectsInvitesDelete=({projectId:D,inviteId:R},A={})=>this.http.request({path:`/v1/projects/${D}/invites/${R}`,method:"DELETE",secure:!0,...A});projectsInvitesList=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}/invites`,method:"GET",secure:!0,format:"json",...R});projectsList=(D={})=>this.http.request({path:"/v1/projects",method:"GET",secure:!0,format:"json",...D});projectsMembersDelete=({projectId:D,userId:R},A={})=>this.http.request({path:`/v1/projects/${D}/members/${R}`,method:"DELETE",secure:!0,...A});projectsMembersList=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}/members`,method:"GET",secure:!0,format:"json",...R});projectsMembersPartialUpdate=({projectId:D,userId:R},A,$={})=>this.http.request({path:`/v1/projects/${D}/members/${R}`,method:"PATCH",body:A,secure:!0,type:"application/json",format:"json",...$});projectsNotificationRoutesList=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}/notification-routes`,method:"GET",secure:!0,format:"json",...R});projectsNotificationRoutesUpdate=({projectId:D},R,A={})=>this.http.request({path:`/v1/projects/${D}/notification-routes`,method:"PUT",body:R,secure:!0,type:"application/json",format:"json",...A});projectsPartialUpdate=({projectId:D},R,A={})=>this.http.request({path:`/v1/projects/${D}`,method:"PATCH",body:R,secure:!0,type:"application/json",format:"json",...A});projectsWalletList=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}/wallet`,method:"GET",secure:!0,format:"json",...R});projectsWalletPaymentsCreate=({projectId:D},R,A={})=>this.http.request({path:`/v1/projects/${D}/wallet/payments`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});projectsWalletPaymentsDetail=({projectId:D,paymentId:R},A={})=>this.http.request({path:`/v1/projects/${D}/wallet/payments/${R}`,method:"GET",secure:!0,format:"json",...A});projectsWalletPaymentsList=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}/wallet/payments`,method:"GET",secure:!0,format:"json",...R});projectsWalletTransactionsList=({projectId:D,...R},A={})=>this.http.request({path:`/v1/projects/${D}/wallet/transactions`,method:"GET",query:R,secure:!0,format:"json",...A});registriesCreate=(D,R={})=>this.http.request({path:"/v1/registries",method:"POST",body:D,secure:!0,type:"application/json",format:"json",...R});registriesDelete=({registryId:D},R={})=>this.http.request({path:`/v1/registries/${D}`,method:"DELETE",secure:!0,...R});registriesDetail=({registryId:D},R={})=>this.http.request({path:`/v1/registries/${D}`,method:"GET",secure:!0,format:"json",...R});registriesList=(D={})=>this.http.request({path:"/v1/registries",method:"GET",secure:!0,format:"json",...D});registriesPartialUpdate=({registryId:D},R,A={})=>this.http.request({path:`/v1/registries/${D}`,method:"PATCH",body:R,secure:!0,type:"application/json",format:"json",...A});registriesRepositoriesList=({registryId:D,...R},A={})=>this.http.request({path:`/v1/registries/${D}/repositories`,method:"GET",query:R,secure:!0,format:"json",...A});registriesRepositoriesTagsList=({registryId:D,repository:R,...A},$={})=>this.http.request({path:`/v1/registries/${D}/repositories/${R}/tags`,method:"GET",query:A,secure:!0,format:"json",...$});registriesValidateCreate=({registryId:D},R,A={})=>this.http.request({path:`/v1/registries/${D}/validate`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});webhooksGitCreate=({provider:D},R={})=>this.http.request({path:`/v1/webhooks/git/${D}`,method:"POST",...R});webhooksPaymentsCreate=({provider:D},R={})=>this.http.request({path:`/v1/webhooks/payments/${D}`,method:"POST",...R})}import{createRequire as BH}from"node:module";var GH="https://api.abr.run",zH=BH(import.meta.url),JH=zH("../package.json"),jf=JH.version||"dev",UR=`abrun-cli/${jf}`;function Sf(){return process.env.ABRUN_ENDPOINT?.trim()||GH}function aD(D){let R=D.project?{"x-project-id":String(D.project.id)}:void 0,$=new Kf((()=>({baseUrl:D.endpoint??Sf(),baseApiParams:{secure:!0,headers:{"User-Agent":UR}},securityWorker:(f)=>{let P={...R??{}};if(f)P.Authorization=`Bearer ${f}`;return{headers:P}}}))());return $.setSecurityData(D.token??null),{http:$,api:new Wf($)}}function iA(D,R,A){let $=new URL(R,D);$.protocol=$.protocol==="https:"?"wss:":"ws:";for(let[f,P]of Object.entries(A??{}))if(P!==void 0)$.searchParams.set(f,String(P));return $.toString()}function c0(D){return new Promise((R)=>setTimeout(R,D))}var Y=_(async(D,R)=>{D.client=aD({endpoint:D.endpoint,token:D.token??D.options.token,project:D.project}),await R()});var D0=_(async(D)=>{D.command.help()});var FR=(D,R=[])=>D.name==="up"||R.includes("vim")&&D.name==="k"||R.includes("emacs")&&D.ctrl&&D.name==="p",aA=(D,R=[])=>D.name==="down"||R.includes("vim")&&D.name==="j"||R.includes("emacs")&&D.ctrl&&D.name==="n";var qR=(D)=>D.name==="backspace",wR=(D)=>D.name==="tab",bf=(D)=>"1234567890".includes(D.name),t0=(D)=>D.name==="enter"||D.name==="return";class uf extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class Ef extends Error{name="CancelPromptError";message="Prompt was canceled"}class rA extends Error{name="ExitPromptError"}class yf extends Error{name="HookError"}class CR extends Error{name="ValidationError"}import{AsyncResource as XH}from"node:async_hooks";import{AsyncLocalStorage as HH,AsyncResource as ZH}from"node:async_hooks";var b4=new HH;function MH(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function u4(D,R){let A=MH(D);return b4.run(A,()=>{function $(f){A.handleChange=()=>{A.index=0,f()},A.handleChange()}return R($)})}function rD(){let D=b4.getStore();if(!D)throw new yf("[Inquirer] Hook functions can only be called from within a prompt");return D}function gf(){return rD().rl}function mf(D){let R=(...A)=>{let $=rD(),f=!1,P=$.handleChange;$.handleChange=()=>{f=!0};let B=D(...A);if(f)P();return $.handleChange=P,B};return ZH.bind(R)}function I1(D){let R=rD(),{index:A}=R,$={get(){return R.hooks[A]},set(P){R.hooks[A]=P},initialized:A in R.hooks},f=D($);return R.index++,f}function E4(){rD().handleChange()}var sD={queue(D){let R=rD(),{index:A}=R;R.hooksEffect.push(()=>{R.hooksCleanup[A]?.();let $=D(gf());if($!=null&&typeof $!=="function")throw new CR("useEffect return value must be a cleanup function or nothing.");R.hooksCleanup[A]=$})},run(){let D=rD();mf(()=>{D.hooksEffect.forEach((R)=>{R()}),D.hooksEffect.length=0})()},clearAll(){let D=rD();D.hooksCleanup.forEach((R)=>{R?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function QH(D){return typeof D==="function"}function i(D){return I1((R)=>{let A=XH.bind(function(P){if(R.get()!==P)R.set(P),E4()});if(R.initialized)return[R.get(),A];let $=QH(D)?D():D;return R.set($),[$,A]})}function e0(D,R){I1((A)=>{let $=A.get();if(!Array.isArray($)||R.some((P,B)=>!Object.is(P,$[B])))sD.queue(D);A.set(R)})}import{styleText as V0}from"node:util";import N0 from"node:process";function TH(){if(!N0.platform.startsWith("win"))return N0.env.TERM!=="linux";return Boolean(N0.env.CI)||Boolean(N0.env.WT_SESSION)||Boolean(N0.env.TERMINUS_SUBLIME)||N0.env.ConEmuTask==="{cmd::Cmder}"||N0.env.TERM_PROGRAM==="Terminus-Sublime"||N0.env.TERM_PROGRAM==="vscode"||N0.env.TERM==="xterm-256color"||N0.env.TERM==="alacritty"||N0.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var y4={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:"╱"},g4={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:"⅒"},OH={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"},YH={...y4,...g4},_H={...y4,...OH},UH=TH(),FH=UH?YH:_H,K1=FH,JV=Object.entries(g4);var m4={prefix:{idle:V0("blue","?"),done:V0("green",K1.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map((D)=>V0("yellow",D))},style:{answer:(D)=>V0("cyan",D),message:(D)=>V0("bold",D),error:(D)=>V0("red",`> ${D}`),defaultAnswer:(D)=>V0("dim",`(${D})`),help:(D)=>V0("dim",D),highlight:(D)=>V0("cyan",D),key:(D)=>V0("cyan",V0("bold",`<${D}>`))}};function x4(D){if(typeof D!=="object"||D===null)return!1;let R=D;while(Object.getPrototypeOf(R)!==null)R=Object.getPrototypeOf(R);return Object.getPrototypeOf(D)===R}function n4(...D){let R={};for(let A of D)for(let[$,f]of Object.entries(A)){let P=R[$];R[$]=x4(P)&&x4(f)?n4(P,f):f}return R}function I0(...D){let R=[m4,...D.filter((A)=>A!=null)];return n4(...R)}function DD({status:D="idle",theme:R}){let[A,$]=i(!1),[f,P]=i(0),{prefix:B,spinner:G}=I0(R);if(e0(()=>{if(D==="loading"){let J,Z=-1,H=setTimeout(()=>{$(!0),J=setInterval(()=>{Z=Z+1,P(Z%G.frames.length)},G.interval)},300);return()=>{clearTimeout(H),clearInterval(J)}}else $(!1)},[D]),A)return G.frames[f];return typeof B==="string"?B:B[D==="loading"?"idle":D]??B.idle}function LR(D,R){return I1((A)=>{let $=A.get();if(!$||$.dependencies.length!==R.length||$.dependencies.some((f,P)=>f!==R[P])){let f=D();return A.set({value:f,dependencies:R}),f}return $.value})}function oD(D){return i({current:D})[0]}function RD(D){let R=oD(D);R.current=D,e0((A)=>{let $=!1,f=mf((P,B)=>{if($)return;R.current(B,A)});return A.input.on("keypress",f),()=>{$=!0,A.input.removeListener("keypress",f)}},[])}var $9=B0(h4(),1);var v4=(()=>{let D=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(R)=>{let A=0;D.lastIndex=0;while(D.test(R))A+=1;return R.length-A}})(),l4=(D)=>{return D===12288||D>=65281&&D<=65376||D>=65504&&D<=65510},k4=(D)=>{return D===8987||D===9001||D>=12272&&D<=12287||D>=12289&&D<=12350||D>=12441&&D<=12543||D>=12549&&D<=12591||D>=12593&&D<=12686||D>=12688&&D<=12771||D>=12783&&D<=12830||D>=12832&&D<=12871||D>=12880&&D<=19903||D>=65040&&D<=65049||D>=65072&&D<=65106||D>=65108&&D<=65126||D>=65128&&D<=65131||D>=127488&&D<=127490||D>=127504&&D<=127547||D>=127552&&D<=127560||D>=131072&&D<=196605||D>=196608&&D<=262141};var CH=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,LH=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,d4=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,NH=/\t{1,1000}/y,i4=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,VH=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,IH=/\p{M}+/gu,KH={limit:1/0,ellipsis:""},a4=(D,R={},A={})=>{let $=R.limit??1/0,f=R.ellipsis??"",P=R?.ellipsisWidth??(f?a4(f,KH,A).width:0),B=0,G=A.controlWidth??0,z=A.tabWidth??8,J=A.emojiWidth??2,Z=2,H=A.regularWidth??1,M=A.wideWidth??2,Q=[[VH,H],[CH,0],[LH,G],[NH,z],[i4,J],[d4,M]],O=0,X=0,T=D.length,U=0,F=!1,w=T,V=Math.max(0,$-P),I=0,j=0,u=0,L=0;D:while(!0){if(j>I||X>=T&&X>O){let S=D.slice(I,j)||D.slice(O,X);U=0;for(let l of S.replaceAll(IH,"")){let k=l.codePointAt(0)||0;if(l4(k))L=2;else if(k4(k))L=M;else L=H;if(u+L>V)w=Math.min(w,Math.max(I,O)+U);if(u+L>$){F=!0;break D}U+=l.length,u+=L}I=j=0}if(X>=T)break D;for(let S=0,l=Q.length;S<l;S++){let[k,g]=Q[S];if(k.lastIndex=X,k.test(D)){if(U=k===d4?v4(D.slice(X,k.lastIndex)):k===i4?1:k.lastIndex-X,L=U*g,u+L>V)w=Math.min(w,X+Math.floor((V-u)/g));if(u+L>$){F=!0;break D}u+=L,I=O,j=X,X=O=k.lastIndex;continue D}}X+=1}return{width:F?V:u,index:F?w:T,truncated:F,ellipsed:F&&$>=P}},r4=a4;var WH={limit:1/0,ellipsis:"",ellipsisWidth:0},jH=(D,R={})=>{return r4(D,WH,R).width},AD=jH;var sA="\x1B",e4="›",SH=39,nf="\x07",D9="[",bH="]",R9="m",pf=`${bH}8;;`,s4=new RegExp(`(?:\\${D9}(?<code>\\d+)m|\\${pf}(?<uri>.*)${nf})`,"y"),o4=(D)=>{if(D>=30&&D<=37)return 39;if(D>=90&&D<=97)return 39;if(D>=40&&D<=47)return 49;if(D>=100&&D<=107)return 49;if(D===1||D===2)return 22;if(D===3)return 23;if(D===4)return 24;if(D===7)return 27;if(D===8)return 28;if(D===9)return 29;if(D===0)return 0;return},c4=(D)=>`${sA}${D9}${D}${R9}`,t4=(D)=>`${sA}${pf}${D}${nf}`,xf=(D,R,A)=>{let $=R[Symbol.iterator](),f=!1,P=!1,B=D.at(-1),G=B===void 0?0:AD(B),z=$.next(),J=$.next(),Z=0;while(!z.done){let H=z.value,M=AD(H);if(G+M<=A)D[D.length-1]+=H;else D.push(H),G=0;if(H===sA||H===e4)f=!0,P=R.startsWith(pf,Z+1);if(f){if(P){if(H===nf)f=!1,P=!1}else if(H===R9)f=!1}else if(G+=M,G===A&&!J.done)D.push(""),G=0;z=J,J=$.next(),Z+=H.length}if(B=D.at(-1),!G&&B!==void 0&&B.length&&D.length>1)D[D.length-2]+=D.pop()},uH=(D)=>{let R=D.split(" "),A=R.length;while(A){if(AD(R[A-1]))break;A--}if(A===R.length)return D;return R.slice(0,A).join(" ")+R.slice(A).join("")},EH=(D,R,A={})=>{if(A.trim!==!1&&D.trim()==="")return"";let $="",f,P,B=D.split(" "),G=[""],z=0;for(let H=0;H<B.length;H++){let M=B[H];if(A.trim!==!1){let O=G.at(-1)??"",X=O.trimStart();if(O.length!==X.length)G[G.length-1]=X,z=AD(X)}if(H!==0){if(z>=R&&(A.wordWrap===!1||A.trim===!1))G.push(""),z=0;if(z||A.trim===!1)G[G.length-1]+=" ",z++}let Q=AD(M);if(A.hard&&Q>R){let O=R-z,X=1+Math.floor((Q-O-1)/R);if(Math.floor((Q-1)/R)<X)G.push("");xf(G,M,R),z=AD(G.at(-1)??"");continue}if(z+Q>R&&z&&Q){if(A.wordWrap===!1&&z<R){xf(G,M,R),z=AD(G.at(-1)??"");continue}G.push(""),z=0}if(z+Q>R&&A.wordWrap===!1){xf(G,M,R),z=AD(G.at(-1)??"");continue}G[G.length-1]+=M,z+=Q}if(A.trim!==!1)G=G.map((H)=>uH(H));let J=G.join(`
170
+ `+A)}function C1(D,R,A,$,f,P){if(D.listenerCount("wsClientError")){let B=Error(f);Error.captureStackTrace(B,C1),D.emit("wsClientError",B,A,R)}else SA(A,$,f,P)}});var Q4=B0(X4(),1),{program:XN,createCommand:QN,createArgument:TN,createOption:ON,CommanderError:YN,InvalidArgumentError:T4,InvalidOptionArgumentError:_N,Command:G2,Argument:UN,Option:FN,Help:qN}=Q4.default;var a=B0(mA(),1);function W(D,R=!1){if(R){console.log(JSON.stringify(D,null,2));return}if(Array.isArray(D)){if(D.length===0){console.log(a.default.dim("No results"));return}console.table(D);return}console.log(D)}function o0(D){for(let[R,A]of Object.entries(D))console.log(`${a.default.cyan(R)}: ${q4(A)}`)}function YD(D){let R=Object.entries(D).filter(([,$])=>$!==""),A=R.reduce(($,[f])=>Math.max($,f.length),0);for(let[$,f]of R)console.log(`${a.default.dim($.padEnd(A," "))} ${q4(f)}`)}function s(D,R){if(R.length===0){console.log(a.default.dim("No results"));return}let A=D.map((f,P)=>{let B=R.reduce((G,z)=>{return Math.max(G,H2(f.render(z),f.width).length)},0);return Math.max(D[P].header.length,f.width??B)}),$=D.map((f,P)=>U4(f.header.toUpperCase(),A[P])).join(" ");console.log(a.default.bold($));for(let f of R)console.log(D.map((P,B)=>U4(H2(P.render(f),D[B].width),A[B])).join(" "))}function Z2(D){pA("App"),o0({id:D.id,name:D.name,status:D.status,endpoint:D.url??"",defaultDomain:D.defaultDomain,plan:D.plan??"",bundle:D.bundle??""})}function M2(D){pA("Deployment"),o0({id:D.id,status:D.status,method:D.method,trigger:D.trigger,message:D.message??"",createdAt:D.createdAt,updatedAt:D.updatedAt})}function QR(D){s([{header:"Kind",width:24,render:(R)=>R.kind},{header:"Effective",width:20,render:(R)=>R.effectiveAt},{header:"Age",width:6,render:(R)=>H0(R.createdAt)},{header:"Data",width:52,render:(R)=>w4(R.data)},{header:"ID",width:8,render:(R)=>String(R.id)}],D)}function TR(D){YD({id:D.id,kind:D.kind,effectiveAt:D.effectiveAt,userId:D.userId??"",data:w4(D.data),createdAt:D.createdAt})}function OR(D){s([{header:"Time",width:24,render:(R)=>L0(R,"time","timestamp","createdAt")},{header:"Source",width:20,render:(R)=>L0(R,"pod","source")},{header:"Container",width:16,render:(R)=>L0(R,"container")},{header:"Message",width:96,render:(R)=>L0(R,"message","line")}],D)}function X2(D){s([{header:"Key",render:(R)=>R.key},{header:"Value",width:36,render:(R)=>R.value},{header:"Updated",width:20,render:(R)=>R.updatedAt??""}],D)}function Q2(D){pA("Domain"),o0({hostname:D.hostname,verification:D.verificationStatus,tlsEnabled:D.tlsEnabled,tlsStatus:D.tlsStatus,forceHttps:D.forceHttps})}function kD(D){pA("Disk"),o0({id:D.id,name:D.name,size:D.size,mounted:D.mounted,mountPath:D.mountPath??""})}function T2(D){s([{header:"Name",width:18,render:(R)=>R.name??""},{header:"Mounted",width:8,render:(R)=>R.mounted?"yes":"no"},{header:"Size",width:6,render:(R)=>`${R.size}G`},{header:"Mount Path",width:28,render:(R)=>R.mountPath??""},{header:"Age",width:6,render:(R)=>H0(R.createdAt)}],D)}function O2(D,R){let A=D.publicAccess&&D.publicPort?`${D.host??""}:${D.publicPort}`:D.publicAccess?"pending":"",$={id:D.id,name:D.name,engine:D.engine,status:D.status,plan:D.plan??"",bundle:D.bundle??"",user:L0(D,"username"),host:D.host,port:D.port,database:D.databaseName,published:C4(D,"publicAccess"),publicAddress:A,version:D.version,error:L0(D,"statusMessage","statusReason","lastError")};if(YD($),R?.password)console.log(),console.log(a.default.bold("password")),console.log(a.default.yellow(R.password))}function Y2(D,R,A){console.log(`Database credentials for ${D}`),console.log(),YD({user:R.username,password:A?.reveal?R.password:"********",host:R.host,port:R.port,database:R.databaseName})}function _2(D,R){s([{header:"Project",width:22,render:()=>D},{header:"Name",width:22,render:(A)=>A.name??""},{header:"Engine",width:8,render:(A)=>A.engine??""},{header:"Status",width:12,render:(A)=>A.status??""},{header:"Plan",width:12,render:(A)=>A.plan??""},{header:"Bundle",width:12,render:(A)=>A.bundle??""},{header:"Public",width:24,render:(A)=>A.publicAccess&&A.publicPort?`${A.host??""}:${A.publicPort}`:C4(A,"publicAccess")?"pending":""},{header:"Age",width:6,render:(A)=>H0(A.createdAt)}],R)}function U2(D){s([{header:"Name",width:16,render:(R)=>R.name??""},{header:"CPU",width:6,render:(R)=>String(N1(R,"cpuMilli")??"")},{header:"Memory",width:8,render:(R)=>String(N1(R,"memoryMb")??"")},{header:"Disk",width:6,render:(R)=>String(N1(R,"diskGb")??"")},{header:"Price",width:8,render:(R)=>String(R.priceHourly??"")}],D)}function F2(D){s([{header:"Engine",width:12,render:(R)=>R.engine},{header:"Versions",width:32,render:(R)=>R.versions.join(", ")}],D)}function q2(D){YD({name:D.name,cpu:N1(D,"cpuMilli")??"",memory:N1(D,"memoryMb")??"",disk:N1(D,"diskGb")??""})}function w2(D){s([{header:"Name",width:16,render:(R)=>R.name??""},{header:"Backup GB",width:8,render:(R)=>String(R.backupStorageGb??"")},{header:"Daily",width:10,render:(R)=>R.dailyBackupRetentionDays?`${R.dailyBackupRetentionDays}d`:""},{header:"Metrics",width:8,render:(R)=>R.metricsRetentionDays?`${R.metricsRetentionDays}d`:""},{header:"Public",width:6,render:(R)=>R.publicAccess===void 0?"":R.publicAccess?"yes":"no"},{header:"Price",width:8,render:(R)=>String(R.priceHourly??"")}],D)}function C2(D){YD({name:D.name,priceHourly:D.priceHourly,priceMonthly:D.priceMonthly,backupStorageGb:D.backupStorageGb,dailyBackupRetention:`${D.dailyBackupRetentionDays??0}d`,weeklyBackupRetention:`${D.weeklyBackupRetentionDays??0}d`,manualBackupsPerHour:D.manualBackupsPerHour,metricsRetention:`${D.metricsRetentionDays}d`,publicExposure:D.publicAccess,databasePlugins:D.databasePlugins,databaseCustomConfig:D.databaseCustomConfig})}function xA(D){YD({id:D.id,status:D.status,storageKey:D.storageKey??"",sizeBytes:D.sizeBytes??"",startedAt:D.startedAt??"",completedAt:D.completedAt??"",expiresAt:D.expiresAt??"",error:D.errorMessage??""})}function L2(D){s([{header:"Status",width:10,render:(R)=>R.status??""},{header:"Size",width:12,render:(R)=>String(R.sizeBytes??"")},{header:"Expires",width:8,render:(R)=>hA(R.expiresAt)},{header:"Age",width:6,render:(R)=>H0(R.createdAt)},{header:"ID",width:8,render:(R)=>String(R.id)}],D)}function N2(D){let R=D;YD({connections:R.connections,qps:R.qps??"",readQps:R.readQps??"",writeQps:R.writeQps??"",slowQueriesQps:R.slowQueriesQps??"",cpuUsageCores:R.cpuUsageCores??"",memoryUsageBytes:R.memoryUsageBytes??"",storageBytes:R.storageBytes??"",storageUsedBytes:R.storageUsedBytes??"",window:R.window,measuredAt:R.measuredAt})}function nA(D,R){let A=L0(D,"status"),$=L0(D,"prefix"),f=L0(D,"lastUsedAt"),P={id:D.id,name:D.name,prefix:$,access:L4(D,R?.projectLabel),expiresAt:D.expiresAt??""};if(A&&A!=="active")P.status=A;if(f)P.lastUsedAt=f;if(YD(P),R?.plaintextToken)console.log(),console.log(a.default.bold("token")),console.log(a.default.yellow(R.plaintextToken))}function V2(D,R){s([{header:"Name",width:22,render:(A)=>A.name??""},{header:"Status",width:10,render:(A)=>L0(A,"status")||(A.revokedAt?"revoked":"active")},{header:"Access",width:34,render:(A)=>L4(A,R?.projectLabel)},{header:"Expires",width:8,render:(A)=>hA(A.expiresAt)},{header:"Last Used",width:9,render:(A)=>H0(L0(A,"lastUsedAt")||A.lastUsedAt)},{header:"Age",width:6,render:(A)=>H0(A.createdAt)},{header:"ID",width:18,render:(A)=>String(A.id)}],D)}function F4(D){let R=D.indexOf("=");if(R<=0)throw Error(`Invalid env entry: ${D}. Expected KEY=VALUE`);return{key:D.slice(0,R),value:D.slice(R+1)}}function I2(D){if(typeof D==="object"&&D!==null){let R=D;if(typeof R.status==="number"){let $=R.status?`Request failed (${R.status}${R.statusText?` ${R.statusText}`:""})`:"Request failed",f=R.error??R.data,P=J2(f);if(P)return`${$}: ${P}`;return $}let A=D;if(A.response?.data){let $=A.response.status?`Request failed (${A.response.status})`:"Request failed",f=J2(A.response.data);if(f)return`${$}: ${f}`}if(A.message){let $=_4(D);if($)return`${A.message}: ${$}`;return A.message}}if(D instanceof Error){let R=_4(D);if(R)return`${D.message}: ${R}`;return D.message}if(typeof D==="string")return D;return String(D)}function J2(D){if(typeof D==="string"&&D)return D;if(typeof D!=="object"||D===null)return D==null?"":String(D);if("error"in D){let R=D.error,A=J2(R);if(A)return A}if("message"in D&&typeof D.message==="string")return D.message;if("code"in D&&typeof D.code==="string")return D.code;return JSON.stringify(D)}function _4(D){if(typeof D!=="object"||D===null||!("cause"in D))return"";let R=D.cause;if(typeof R==="string")return R;if(typeof R!=="object"||R===null)return"";let A=R;return[A.syscall,A.code,A.address,A.port].filter(Boolean).join(" ")||A.message||""}function K2(D){let R=D.split(/\r?\n/),[A="",...$]=R;console.error(a.default.red(`Error: ${A}`));for(let f of $)console.error(a.default.red(` ${f}`))}function pA(D){console.log(a.default.bold(a.default.magenta(D))),console.log(a.default.dim("-".repeat(D.length)))}function q4(D){if(D==null)return"";if(typeof D==="boolean")return D?a.default.green("yes"):a.default.dim("no");if(typeof D==="number")return a.default.yellow(String(D));if(typeof D==="string")return $H(D);return JSON.stringify(D)}function $H(D){let R=D.toLowerCase();if(["ready","active","approved","healthy","running","mounted","verified","available"].includes(R))return a.default.green(D);if(["pending","building","provisioning","mounting","unmounting","expanding"].includes(R))return a.default.yellow(D);if(["failed","denied","revoked","expired","cancelled","error","frozen"].includes(R))return a.default.red(D);return D}function H0(D){if(!D)return"";let R=new Date(D).getTime();if(!Number.isFinite(R))return"";let A=Math.max(0,Math.floor((Date.now()-R)/1000));if(A<60)return`${A}s`;let $=Math.floor(A/60);if($<60)return`${$}m`;let f=Math.floor($/60);if(f<24)return`${f}h`;let P=Math.floor(f/24);if(P<30)return`${P}d`;let B=Math.floor(P/30);if(B<12)return`${B}mo`;return`${Math.floor(P/365)}y`}function hA(D){if(!D)return"never";let R=new Date(D).getTime();if(!Number.isFinite(R))return"";let A=Math.max(0,Math.floor((R-Date.now())/1000));if(A<60)return`${A}s`;let $=Math.floor(A/60);if($<60)return`${$}m`;let f=Math.floor($/60);if(f<24)return`${f}h`;let P=Math.floor(f/24);if(P<30)return`${P}d`;let B=Math.floor(P/30);if(B<12)return`${B}mo`;return`${Math.floor(P/365)}y`}function H2(D,R){if(!R||D.length<=R)return D;if(R<=1)return D.slice(0,R);return`${D.slice(0,R-1)}…`}function U4(D,R){return D.padEnd(R," ")}function w4(D){if(Object.keys(D).length===0)return"";return H2(JSON.stringify(D),52)}function N1(D,...R){let A=D;for(let $ of R)if(typeof A[$]==="number")return A[$];return}function L0(D,...R){let A=D;for(let $ of R)if(typeof A[$]==="string")return A[$];return""}function C4(D,...R){let A=D;for(let $ of R)if(typeof A[$]==="boolean")return A[$];return}function L4(D,R){return(D.projectAccess??[]).map(($)=>`${R?.($.projectId)??`#${$.projectId}`}:${$.role}`).join(", ")}function _(D){return D}function _D(D){return(R)=>{if(D.includes(R))return R;throw new T4(`Invalid value "${R}". Expected one of: ${D.join(", ")}`)}}async function fH(D,R){let A=-1,$=async()=>{A+=1;let f=R[A];if(!f)return;await Promise.resolve(f(D,$))};await $()}class vA{raw;state;constructor(D,R){this.raw=D??new G2,this.state=R??{argDefs:[],middlewares:[]}}name(D){return this.raw.name(D),this}description(D){return this.raw.description(D),this}alias(D){return this.raw.alias(D),this}option(D,R,A,$){if(A){let f=A;this.raw.option(D,R??"",f,$)}else if(R!==void 0)this.raw.option(D,R);else this.raw.option(D);return this}argument(D,R,A){return this.raw.argument(D,R,A),this.state.argDefs.push(PH(D)),this}onions(D){return this.state.middlewares=[...D],this.raw.action(async(...R)=>{let A=R.at(-1);if(!(A instanceof G2))throw Error("Unable to resolve command context");let $=this.getOptions(A),f=this.getArgs(R.slice(0,-1)),P=this.createContext(A,$,f);try{await fH(P,this.state.middlewares)}catch(B){P.abort(I2(B))}}),this}command(D){let R=this.raw.command(D);return new vA(R)}parse(D){try{this.raw.parse(D)}catch(R){K2(I2(R)),process.exit(1)}return this}unwrap(){return this.raw}getOptions(D){let R=D.optsWithGlobals;if(typeof R==="function")return R.call(D);return D.opts()}getArgs(D){return this.state.argDefs.reduce((R,A,$)=>{let f=D[$];if(f!==void 0)R[A.key]=f;return R},{})}createContext(D,R,A){return{argv:R,options:R,args:A,command:D,abort($){K2($??"Aborted"),process.exit(1)}}}}function PH(D){let R=D.trim();if(R.startsWith("<")&&R.endsWith(">"))return{key:R.slice(1,-1),required:!0};if(R.startsWith("[")&&R.endsWith("]"))return{key:R.slice(1,-1),required:!1};throw Error(`Unsupported argument spec: ${D}`)}function _0(D){if(D===void 0)return;let R=typeof D==="number"?D:Number(D);if(!Number.isInteger(R)||R<0)throw Error("Tail must be a non-negative integer.");return R}function lA(D){let R=typeof D==="number"?D:Number(D);if(!Number.isInteger(R)||R<1||R>65535)throw Error("Port must be an integer between 1 and 65535.");return R}function YR(D,R){return D.id===R||D.label===R||D.email===R}function _R(D,R){return String(D.id)===R||D.slug===R||D.name===R}function N4(D,R){return String(D.id)===R||D.name===R}function V4(D,R){return String(D.id)===R||D.name===R}function I4(D,R){return String(D.id)===R||D.name===R}function kA(D,R){return(D.name??"").toLowerCase()===R.toLowerCase()}function dA(D,R){return(D.name??"").toLowerCase()===R.toLowerCase()}function K4(D,R){return String(D.id)===R||D.name===R||D.prefix===R}function dD(D,R,A){let $=R?D.find((f)=>(f.name??"").toLowerCase()===R.toLowerCase()):(A?D.find((f)=>(f.name??"").toLowerCase()===A.toLowerCase()):void 0)||D[0];if(!$)throw Error(R?`App plan not found: ${R}`:"No app plan available.");return $}function iD(D,R,A){let $=R?D.find((f)=>(f.name??"").toLowerCase()===R.toLowerCase()):(A?D.find((f)=>(f.name??"").toLowerCase()===A.toLowerCase()):void 0)||D[0];if(!$)throw Error(R?`App bundle not found: ${R}`:"No app bundle available.");return $}function UD(D,R,A){let $=(R?D.find((f)=>kA(f,R)):void 0)||(A?D.find((f)=>kA(f,A)):void 0)||D[0];if(!$)throw Error("No database plan available.");return $}function V1(D,R,A){let $=(R?D.find((f)=>dA(f,R)):void 0)||(A?D.find((f)=>dA(f,A)):void 0)||D[0];if(!$)throw Error("No database bundle available.");return $}function W4(D){return D.plan}function j4(D){return D.bundle}var K=_(async(D,R)=>{let A=process.env.ABRUN_TOKEN??D.options.token;if(A){D.auth={id:process.env.ABRUN_TOKEN?"env":"flag",label:process.env.ABRUN_TOKEN?"env":"flag",email:process.env.ABRUN_TOKEN?"env-token":"flag-token",token:A,endpoint:D.endpoint},D.token=A,await R();return}let $=D.options.auth?D.state.auths.find((f)=>YR(f,D.options.auth)):D.state.currentAuthId?D.state.auths.find((f)=>f.id===D.state.currentAuthId):void 0;if(!$)D.abort("No active auth. Run `abrun login` first or set ABRUN_TOKEN.");D.auth=$,D.token=$.token,D.endpoint=D.options.endpoint??$.endpoint??D.endpoint,await R()});var S4;((P)=>{P.Json="application/json";P.JsonApi="application/vnd.api+json";P.FormData="multipart/form-data";P.UrlEncoded="application/x-www-form-urlencoded";P.Text="text/plain"})(S4||={});class W2{baseUrl="https://api.abr.run";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...D)=>fetch(...D);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(D={}){Object.assign(this,D)}setSecurityData=(D)=>{this.securityData=D};encodeQueryParam(D,R){return`${encodeURIComponent(D)}=${encodeURIComponent(typeof R==="number"?R:`${R}`)}`}addQueryParam(D,R){return this.encodeQueryParam(R,D[R])}addArrayQueryParam(D,R){return D[R].map(($)=>this.encodeQueryParam(R,$)).join("&")}toQueryString(D){let R=D||{};return Object.keys(R).filter(($)=>typeof R[$]<"u").map(($)=>Array.isArray(R[$])?this.addArrayQueryParam(R,$):this.addQueryParam(R,$)).join("&")}addQueryParams(D){let R=this.toQueryString(D);return R?`?${R}`:""}contentFormatters={["application/json"]:(D)=>D!==null&&(typeof D==="object"||typeof D==="string")?JSON.stringify(D):D,["application/vnd.api+json"]:(D)=>D!==null&&(typeof D==="object"||typeof D==="string")?JSON.stringify(D):D,["text/plain"]:(D)=>D!==null&&typeof D!=="string"?JSON.stringify(D):D,["multipart/form-data"]:(D)=>{if(D instanceof FormData)return D;return Object.keys(D||{}).reduce((R,A)=>{let $=D[A];return R.append(A,$ instanceof Blob?$:typeof $==="object"&&$!==null?JSON.stringify($):`${$}`),R},new FormData)},["application/x-www-form-urlencoded"]:(D)=>this.toQueryString(D)};mergeRequestParams(D,R){return{...this.baseApiParams,...D,...R||{},headers:{...this.baseApiParams.headers||{},...D.headers||{},...R&&R.headers||{}}}}createAbortSignal=(D)=>{if(this.abortControllers.has(D)){let A=this.abortControllers.get(D);if(A)return A.signal;return}let R=new AbortController;return this.abortControllers.set(D,R),R.signal};abortRequest=(D)=>{let R=this.abortControllers.get(D);if(R)R.abort(),this.abortControllers.delete(D)};request=async({body:D,secure:R,path:A,type:$,query:f,format:P,baseUrl:B,cancelToken:G,...z})=>{let J=(typeof R==="boolean"?R:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},Z=this.mergeRequestParams(z,J),H=f&&this.toQueryString(f),M=this.contentFormatters[$||"application/json"],Q=P||Z.format;return this.customFetch(`${B||this.baseUrl||""}${A}${H?`?${H}`:""}`,{...Z,headers:{...Z.headers||{},...$&&$!=="multipart/form-data"?{"Content-Type":$}:{}},signal:(G?this.createAbortSignal(G):Z.signal)||null,body:typeof D>"u"||D===null?null:M(D)}).then(async(O)=>{let X=O;X.data=null,X.error=null;let T=Q?O.clone():O,U=!Q?X:await T[Q]().then((F)=>{if(X.ok)X.data=F;else X.error=F;return X}).catch((F)=>{return X.error=F,X});if(G)this.abortControllers.delete(G);if(!O.ok)throw U;return U.data})}}class j2{http;constructor(D){this.http=D}appPlansBundlesList=({planName:D},R={})=>this.http.request({path:`/v1/app-plans/${D}/bundles`,method:"GET",secure:!0,format:"json",...R});appPlansDetail=({planName:D},R={})=>this.http.request({path:`/v1/app-plans/${D}`,method:"GET",secure:!0,format:"json",...R});appPlansList=(D={})=>this.http.request({path:"/v1/app-plans",method:"GET",secure:!0,format:"json",...D});appsAnalyticsBreakdownList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/analytics/breakdown`,method:"GET",query:R,secure:!0,format:"json",...A});appsAnalyticsFilterValuesList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/analytics/filter-values`,method:"GET",query:R,secure:!0,format:"json",...A});appsAnalyticsList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/analytics`,method:"GET",query:R,secure:!0,format:"json",...A});appsAnalyticsSeriesList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/analytics/series`,method:"GET",query:R,secure:!0,format:"json",...A});appsApplyCreate=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/apply`,method:"POST",secure:!0,format:"json",...R});appsAvailabilityList=(D,R={})=>this.http.request({path:"/v1/apps/availability",method:"GET",query:D,secure:!0,format:"json",...R});appsConsoleList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/console`,method:"GET",query:R,secure:!0,...A});appsConsoleSessionCreate=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/console/session`,method:"POST",query:R,secure:!0,format:"json",...A});appsCreate=(D,R={})=>this.http.request({path:"/v1/apps",method:"POST",body:D,secure:!0,type:"application/json",format:"json",...R});appsDelete=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}`,method:"DELETE",secure:!0,format:"json",...R});appsDeployCreate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/deploy`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});appsDeploymentsCancelCreate=({appId:D,deploymentId:R},A={})=>this.http.request({path:`/v1/apps/${D}/deployments/${R}/cancel`,method:"POST",secure:!0,format:"json",...A});appsDeploymentsDetail=({appId:D,deploymentId:R},A={})=>this.http.request({path:`/v1/apps/${D}/deployments/${R}`,method:"GET",secure:!0,format:"json",...A});appsDeploymentsList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/deployments`,method:"GET",query:R,secure:!0,format:"json",...A});appsDeploymentsLogsList=({appId:D,deploymentId:R,...A},$={})=>this.http.request({path:`/v1/apps/${D}/deployments/${R}/logs`,method:"GET",query:A,secure:!0,format:"json",...$});appsDeploymentsRollbackCreate=({appId:D,deploymentId:R},A={})=>this.http.request({path:`/v1/apps/${D}/deployments/${R}/rollback`,method:"POST",secure:!0,format:"json",...A});appsDetail=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}`,method:"GET",secure:!0,format:"json",...R});appsDisksCreate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/disks`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});appsDisksDelete=({appId:D,diskId:R},A={})=>this.http.request({path:`/v1/apps/${D}/disks/${R}`,method:"DELETE",secure:!0,...A});appsDisksDetail=({appId:D,diskId:R},A={})=>this.http.request({path:`/v1/apps/${D}/disks/${R}`,method:"GET",secure:!0,format:"json",...A});appsDisksExpandCreate=({appId:D,diskId:R},A,$={})=>this.http.request({path:`/v1/apps/${D}/disks/${R}/expand`,method:"POST",body:A,secure:!0,type:"application/json",format:"json",...$});appsDisksList=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/disks`,method:"GET",secure:!0,format:"json",...R});appsDisksMountCreate=({appId:D,diskId:R},A,$={})=>this.http.request({path:`/v1/apps/${D}/disks/${R}/mount`,method:"POST",body:A,secure:!0,type:"application/json",format:"json",...$});appsDisksPartialUpdate=({appId:D,diskId:R},A,$={})=>this.http.request({path:`/v1/apps/${D}/disks/${R}`,method:"PATCH",body:A,secure:!0,type:"application/json",format:"json",...$});appsDisksUnmountCreate=({appId:D,diskId:R},A={})=>this.http.request({path:`/v1/apps/${D}/disks/${R}/unmount`,method:"POST",secure:!0,format:"json",...A});appsDomainsAvailabilityList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/domains/availability`,method:"GET",query:R,secure:!0,format:"json",...A});appsDomainsCreate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/domains`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});appsDomainsDelete=({appId:D,domainId:R},A={})=>this.http.request({path:`/v1/apps/${D}/domains/${R}`,method:"DELETE",secure:!0,...A});appsDomainsDetail=({appId:D,domainId:R},A={})=>this.http.request({path:`/v1/apps/${D}/domains/${R}`,method:"GET",secure:!0,format:"json",...A});appsDomainsList=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/domains`,method:"GET",secure:!0,format:"json",...R});appsDomainsPartialUpdate=({appId:D,domainId:R},A,$={})=>this.http.request({path:`/v1/apps/${D}/domains/${R}`,method:"PATCH",body:A,secure:!0,type:"application/json",format:"json",...$});appsDomainsVerifyCreate=({appId:D,domainId:R},A={})=>this.http.request({path:`/v1/apps/${D}/domains/${R}/verify`,method:"POST",secure:!0,format:"json",...A});appsEnvList=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/env`,method:"GET",secure:!0,format:"json",...R});appsEnvUpdate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/env`,method:"PUT",body:R,secure:!0,type:"application/json",format:"json",...A});appsEventsList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/events`,method:"GET",query:R,secure:!0,format:"json",...A});appsGitSourceDelete=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/git-source`,method:"DELETE",secure:!0,...R});appsGitSourceList=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/git-source`,method:"GET",secure:!0,format:"json",...R});appsGitSourceUpdate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/git-source`,method:"PUT",body:R,secure:!0,type:"application/json",format:"json",...A});appsList=(D={})=>this.http.request({path:"/v1/apps",method:"GET",secure:!0,format:"json",...D});appsLogsList=({appId:D,...R},A={})=>this.http.request({path:`/v1/apps/${D}/logs`,method:"GET",query:R,secure:!0,format:"json",...A});appsPartialUpdate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}`,method:"PATCH",body:R,secure:!0,type:"application/json",format:"json",...A});appsResizeCreate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/resize`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});appsRestartCreate=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/restart`,method:"POST",secure:!0,format:"json",...R});appsStartCreate=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/start`,method:"POST",secure:!0,format:"json",...R});appsStopCreate=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/stop`,method:"POST",secure:!0,format:"json",...R});appsUploadCreate=({appId:D},R,A={})=>this.http.request({path:`/v1/apps/${D}/upload`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});appsUsageDetail=({appId:D,metric:R},A={})=>this.http.request({path:`/v1/apps/${D}/usage/${R}`,method:"GET",secure:!0,format:"json",...A});appsUsageList=({appId:D},R={})=>this.http.request({path:`/v1/apps/${D}/usage`,method:"GET",secure:!0,format:"json",...R});authApiTokensCreate=(D,R={})=>this.http.request({path:"/v1/auth/api-tokens",method:"POST",body:D,secure:!0,type:"application/json",format:"json",...R});authApiTokensDelete=({tokenId:D},R={})=>this.http.request({path:`/v1/auth/api-tokens/${D}`,method:"DELETE",secure:!0,...R});authApiTokensList=(D,R={})=>this.http.request({path:"/v1/auth/api-tokens",method:"GET",query:D,secure:!0,format:"json",...R});authCliLoginDecisionCreate=({browserCode:D},R,A={})=>this.http.request({path:`/v1/auth/cli-login/${D}`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});authCliLoginPromptDetail=({browserCode:D},R={})=>this.http.request({path:`/v1/auth/cli-login/${D}`,method:"GET",secure:!0,format:"json",...R});authCliLoginStartOrPoll=(D,R={})=>this.http.request({path:"/v1/auth/cli-login",method:"POST",body:D,type:"application/json",format:"json",...R});authLoginCreate=(D,R={})=>this.http.request({path:"/v1/auth/login",method:"POST",body:D,type:"application/json",format:"json",...R});authLogoutAllCreate=(D,R={})=>this.http.request({path:"/v1/auth/logout-all",method:"POST",body:D,secure:!0,type:"application/json",...R});authLogoutCreate=(D={})=>this.http.request({path:"/v1/auth/logout",method:"POST",secure:!0,...D});authMeList=(D={})=>this.http.request({path:"/v1/auth/me",method:"GET",secure:!0,format:"json",...D});authMePartialUpdate=(D,R={})=>this.http.request({path:"/v1/auth/me",method:"PATCH",body:D,secure:!0,type:"application/json",format:"json",...R});authPasswordChangeCreate=(D,R={})=>this.http.request({path:"/v1/auth/password/change",method:"POST",body:D,secure:!0,type:"application/json",...R});authPasswordForgotCreate=(D,R={})=>this.http.request({path:"/v1/auth/password/forgot",method:"POST",body:D,type:"application/json",format:"json",...R});authPasswordResetCreate=(D,R={})=>this.http.request({path:"/v1/auth/password/reset",method:"POST",body:D,type:"application/json",format:"json",...R});authResendVerificationCreate=(D={})=>this.http.request({path:"/v1/auth/resend-verification",method:"POST",secure:!0,format:"json",...D});authSessionsDelete=({sessionId:D},R={})=>this.http.request({path:`/v1/auth/sessions/${D}`,method:"DELETE",secure:!0,...R});authSessionsList=(D={})=>this.http.request({path:"/v1/auth/sessions",method:"GET",secure:!0,format:"json",...D});authSignupCreate=(D,R={})=>this.http.request({path:"/v1/auth/signup",method:"POST",body:D,type:"application/json",format:"json",...R});authVerifyEmailCreate=(D,R={})=>this.http.request({path:"/v1/auth/verify-email",method:"POST",body:D,type:"application/json",format:"json",...R});databaseBackupsDownloadUrlCreate=({backupId:D},R,A={})=>this.http.request({path:`/v1/database-backups/${D}/download-url`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});databaseEnginesList=(D={})=>this.http.request({path:"/v1/database-engines",method:"GET",secure:!0,format:"json",...D});databasePlansBundlesList=({planName:D},R={})=>this.http.request({path:`/v1/database-plans/${D}/bundles`,method:"GET",secure:!0,format:"json",...R});databasePlansDetail=({planName:D},R={})=>this.http.request({path:`/v1/database-plans/${D}`,method:"GET",secure:!0,format:"json",...R});databasePlansList=(D={})=>this.http.request({path:"/v1/database-plans",method:"GET",secure:!0,format:"json",...D});databasesAvailabilityList=(D,R={})=>this.http.request({path:"/v1/databases/availability",method:"GET",query:D,secure:!0,format:"json",...R});databasesBackupsCreate=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}/backups`,method:"POST",secure:!0,format:"json",...R});databasesBackupsDetail=({databaseId:D,backupId:R},A={})=>this.http.request({path:`/v1/databases/${D}/backups/${R}`,method:"GET",secure:!0,format:"json",...A});databasesBackupsList=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}/backups`,method:"GET",secure:!0,format:"json",...R});databasesCreate=(D,R={})=>this.http.request({path:"/v1/databases",method:"POST",body:D,secure:!0,type:"application/json",format:"json",...R});databasesCredentialsList=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}/credentials`,method:"GET",secure:!0,format:"json",...R});databasesDelete=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}`,method:"DELETE",secure:!0,format:"json",...R});databasesDetail=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}`,method:"GET",secure:!0,format:"json",...R});databasesEventsList=({databaseId:D,...R},A={})=>this.http.request({path:`/v1/databases/${D}/events`,method:"GET",query:R,secure:!0,format:"json",...A});databasesList=(D={})=>this.http.request({path:"/v1/databases",method:"GET",secure:!0,format:"json",...D});databasesLogsList=({databaseId:D,...R},A={})=>this.http.request({path:`/v1/databases/${D}/logs`,method:"GET",query:R,secure:!0,format:"json",...A});databasesPartialUpdate=({databaseId:D},R,A={})=>this.http.request({path:`/v1/databases/${D}`,method:"PATCH",body:R,secure:!0,type:"application/json",format:"json",...A});databasesResizeCreate=({databaseId:D},R,A={})=>this.http.request({path:`/v1/databases/${D}/resize`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});databasesStartCreate=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}/start`,method:"POST",secure:!0,format:"json",...R});databasesStopCreate=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}/stop`,method:"POST",secure:!0,format:"json",...R});databasesUsageDetail=({databaseId:D,metric:R},A={})=>this.http.request({path:`/v1/databases/${D}/usage/${R}`,method:"GET",secure:!0,format:"json",...A});databasesUsageList=({databaseId:D},R={})=>this.http.request({path:`/v1/databases/${D}/usage`,method:"GET",secure:!0,format:"json",...R});healthList=(D={})=>this.http.request({path:"/v1/health",method:"GET",format:"json",...D});integrationsGitDelete=({integrationId:D},R={})=>this.http.request({path:`/v1/integrations/git/${D}`,method:"DELETE",secure:!0,...R});integrationsGitList=(D={})=>this.http.request({path:"/v1/integrations/git",method:"GET",secure:!0,format:"json",...D});integrationsGitOauthCallbackList=({provider:D},R={})=>this.http.request({path:`/v1/integrations/git/${D}/oauth/callback`,method:"GET",secure:!0,format:"json",...R});integrationsGitOauthStartCreate=({provider:D},R={})=>this.http.request({path:`/v1/integrations/git/${D}/oauth/start`,method:"POST",secure:!0,format:"json",...R});invitesAcceptCreate=({token:D},R={})=>this.http.request({path:`/v1/invites/${D}/accept`,method:"POST",secure:!0,format:"json",...R});invitesDeclineCreate=({token:D},R={})=>this.http.request({path:`/v1/invites/${D}/decline`,method:"POST",secure:!0,format:"json",...R});invitesDetail=({token:D},R={})=>this.http.request({path:`/v1/invites/${D}`,method:"GET",secure:!0,format:"json",...R});notificationPreferencesList=(D={})=>this.http.request({path:"/v1/notification-preferences",method:"GET",secure:!0,format:"json",...D});notificationPreferencesUpdate=(D,R={})=>this.http.request({path:"/v1/notification-preferences",method:"PUT",body:D,secure:!0,type:"application/json",format:"json",...R});notificationsList=(D,R={})=>this.http.request({path:"/v1/notifications",method:"GET",query:D,secure:!0,format:"json",...R});notificationsPartialUpdate=({notificationId:D},R={})=>this.http.request({path:`/v1/notifications/${D}`,method:"PATCH",secure:!0,format:"json",...R});notificationsReadAllCreate=(D={})=>this.http.request({path:"/v1/notifications/read-all",method:"POST",secure:!0,...D});paymentsProvidersList=(D={})=>this.http.request({path:"/v1/payments/providers",method:"GET",secure:!0,format:"json",...D});projectsAvailabilityList=(D,R={})=>this.http.request({path:"/v1/projects/availability",method:"GET",query:D,secure:!0,format:"json",...R});projectsCreate=(D,R={})=>this.http.request({path:"/v1/projects",method:"POST",body:D,secure:!0,type:"application/json",format:"json",...R});projectsDelete=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}`,method:"DELETE",secure:!0,format:"json",...R});projectsDetail=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}`,method:"GET",secure:!0,format:"json",...R});projectsEventsList=({projectId:D,...R},A={})=>this.http.request({path:`/v1/projects/${D}/events`,method:"GET",query:R,secure:!0,format:"json",...A});projectsInvitesCreate=({projectId:D},R,A={})=>this.http.request({path:`/v1/projects/${D}/invites`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});projectsInvitesDelete=({projectId:D,inviteId:R},A={})=>this.http.request({path:`/v1/projects/${D}/invites/${R}`,method:"DELETE",secure:!0,...A});projectsInvitesList=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}/invites`,method:"GET",secure:!0,format:"json",...R});projectsList=(D={})=>this.http.request({path:"/v1/projects",method:"GET",secure:!0,format:"json",...D});projectsMembersDelete=({projectId:D,userId:R},A={})=>this.http.request({path:`/v1/projects/${D}/members/${R}`,method:"DELETE",secure:!0,...A});projectsMembersList=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}/members`,method:"GET",secure:!0,format:"json",...R});projectsMembersPartialUpdate=({projectId:D,userId:R},A,$={})=>this.http.request({path:`/v1/projects/${D}/members/${R}`,method:"PATCH",body:A,secure:!0,type:"application/json",format:"json",...$});projectsNotificationRoutesList=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}/notification-routes`,method:"GET",secure:!0,format:"json",...R});projectsNotificationRoutesUpdate=({projectId:D},R,A={})=>this.http.request({path:`/v1/projects/${D}/notification-routes`,method:"PUT",body:R,secure:!0,type:"application/json",format:"json",...A});projectsPartialUpdate=({projectId:D},R,A={})=>this.http.request({path:`/v1/projects/${D}`,method:"PATCH",body:R,secure:!0,type:"application/json",format:"json",...A});projectsWalletList=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}/wallet`,method:"GET",secure:!0,format:"json",...R});projectsWalletPaymentsCreate=({projectId:D},R,A={})=>this.http.request({path:`/v1/projects/${D}/wallet/payments`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});projectsWalletPaymentsDetail=({projectId:D,paymentId:R},A={})=>this.http.request({path:`/v1/projects/${D}/wallet/payments/${R}`,method:"GET",secure:!0,format:"json",...A});projectsWalletPaymentsList=({projectId:D},R={})=>this.http.request({path:`/v1/projects/${D}/wallet/payments`,method:"GET",secure:!0,format:"json",...R});projectsWalletTransactionsList=({projectId:D,...R},A={})=>this.http.request({path:`/v1/projects/${D}/wallet/transactions`,method:"GET",query:R,secure:!0,format:"json",...A});registriesCreate=(D,R={})=>this.http.request({path:"/v1/registries",method:"POST",body:D,secure:!0,type:"application/json",format:"json",...R});registriesDelete=({registryId:D},R={})=>this.http.request({path:`/v1/registries/${D}`,method:"DELETE",secure:!0,...R});registriesDetail=({registryId:D},R={})=>this.http.request({path:`/v1/registries/${D}`,method:"GET",secure:!0,format:"json",...R});registriesList=(D={})=>this.http.request({path:"/v1/registries",method:"GET",secure:!0,format:"json",...D});registriesPartialUpdate=({registryId:D},R,A={})=>this.http.request({path:`/v1/registries/${D}`,method:"PATCH",body:R,secure:!0,type:"application/json",format:"json",...A});registriesRepositoriesList=({registryId:D,...R},A={})=>this.http.request({path:`/v1/registries/${D}/repositories`,method:"GET",query:R,secure:!0,format:"json",...A});registriesRepositoriesTagsList=({registryId:D,repository:R,...A},$={})=>this.http.request({path:`/v1/registries/${D}/repositories/${R}/tags`,method:"GET",query:A,secure:!0,format:"json",...$});registriesValidateCreate=({registryId:D},R,A={})=>this.http.request({path:`/v1/registries/${D}/validate`,method:"POST",body:R,secure:!0,type:"application/json",format:"json",...A});webhooksGitCreate=({provider:D},R={})=>this.http.request({path:`/v1/webhooks/git/${D}`,method:"POST",...R});webhooksPaymentsCreate=({provider:D},R={})=>this.http.request({path:`/v1/webhooks/payments/${D}`,method:"POST",...R})}import{createRequire as BH}from"node:module";var GH="https://api.abr.run",zH=BH(import.meta.url),JH=zH("../package.json"),S2=JH.version||"dev",UR=`abrun-cli/${S2}`;function b2(){return process.env.ABRUN_ENDPOINT?.trim()||GH}function aD(D){let R=D.project?{"x-project-id":String(D.project.id)}:void 0,$=new W2((()=>({baseUrl:D.endpoint??b2(),baseApiParams:{secure:!0,headers:{"User-Agent":UR}},securityWorker:(f)=>{let P={...R??{}};if(f)P.Authorization=`Bearer ${f}`;return{headers:P}}}))());return $.setSecurityData(D.token??null),{http:$,api:new j2($)}}function iA(D,R,A){let $=new URL(R,D);$.protocol=$.protocol==="https:"?"wss:":"ws:";for(let[f,P]of Object.entries(A??{}))if(P!==void 0)$.searchParams.set(f,String(P));return $.toString()}function c0(D){return new Promise((R)=>setTimeout(R,D))}var Y=_(async(D,R)=>{D.client=aD({endpoint:D.endpoint,token:D.token??D.options.token,project:D.project}),await R()});var D0=_(async(D)=>{D.command.help()});var FR=(D,R=[])=>D.name==="up"||R.includes("vim")&&D.name==="k"||R.includes("emacs")&&D.ctrl&&D.name==="p",aA=(D,R=[])=>D.name==="down"||R.includes("vim")&&D.name==="j"||R.includes("emacs")&&D.ctrl&&D.name==="n";var qR=(D)=>D.name==="backspace",wR=(D)=>D.name==="tab",u2=(D)=>"1234567890".includes(D.name),t0=(D)=>D.name==="enter"||D.name==="return";class E2 extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class y2 extends Error{name="CancelPromptError";message="Prompt was canceled"}class rA extends Error{name="ExitPromptError"}class g2 extends Error{name="HookError"}class CR extends Error{name="ValidationError"}import{AsyncResource as XH}from"node:async_hooks";import{AsyncLocalStorage as HH,AsyncResource as ZH}from"node:async_hooks";var b4=new HH;function MH(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function u4(D,R){let A=MH(D);return b4.run(A,()=>{function $(f){A.handleChange=()=>{A.index=0,f()},A.handleChange()}return R($)})}function rD(){let D=b4.getStore();if(!D)throw new g2("[Inquirer] Hook functions can only be called from within a prompt");return D}function m2(){return rD().rl}function x2(D){let R=(...A)=>{let $=rD(),f=!1,P=$.handleChange;$.handleChange=()=>{f=!0};let B=D(...A);if(f)P();return $.handleChange=P,B};return ZH.bind(R)}function I1(D){let R=rD(),{index:A}=R,$={get(){return R.hooks[A]},set(P){R.hooks[A]=P},initialized:A in R.hooks},f=D($);return R.index++,f}function E4(){rD().handleChange()}var sD={queue(D){let R=rD(),{index:A}=R;R.hooksEffect.push(()=>{R.hooksCleanup[A]?.();let $=D(m2());if($!=null&&typeof $!=="function")throw new CR("useEffect return value must be a cleanup function or nothing.");R.hooksCleanup[A]=$})},run(){let D=rD();x2(()=>{D.hooksEffect.forEach((R)=>{R()}),D.hooksEffect.length=0})()},clearAll(){let D=rD();D.hooksCleanup.forEach((R)=>{R?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function QH(D){return typeof D==="function"}function i(D){return I1((R)=>{let A=XH.bind(function(P){if(R.get()!==P)R.set(P),E4()});if(R.initialized)return[R.get(),A];let $=QH(D)?D():D;return R.set($),[$,A]})}function e0(D,R){I1((A)=>{let $=A.get();if(!Array.isArray($)||R.some((P,B)=>!Object.is(P,$[B])))sD.queue(D);A.set(R)})}import{styleText as V0}from"node:util";import N0 from"node:process";function TH(){if(!N0.platform.startsWith("win"))return N0.env.TERM!=="linux";return Boolean(N0.env.CI)||Boolean(N0.env.WT_SESSION)||Boolean(N0.env.TERMINUS_SUBLIME)||N0.env.ConEmuTask==="{cmd::Cmder}"||N0.env.TERM_PROGRAM==="Terminus-Sublime"||N0.env.TERM_PROGRAM==="vscode"||N0.env.TERM==="xterm-256color"||N0.env.TERM==="alacritty"||N0.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var y4={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:"╱"},g4={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:"⅒"},OH={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"},YH={...y4,...g4},_H={...y4,...OH},UH=TH(),FH=UH?YH:_H,K1=FH,GV=Object.entries(g4);var m4={prefix:{idle:V0("blue","?"),done:V0("green",K1.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map((D)=>V0("yellow",D))},style:{answer:(D)=>V0("cyan",D),message:(D)=>V0("bold",D),error:(D)=>V0("red",`> ${D}`),defaultAnswer:(D)=>V0("dim",`(${D})`),help:(D)=>V0("dim",D),highlight:(D)=>V0("cyan",D),key:(D)=>V0("cyan",V0("bold",`<${D}>`))}};function x4(D){if(typeof D!=="object"||D===null)return!1;let R=D;while(Object.getPrototypeOf(R)!==null)R=Object.getPrototypeOf(R);return Object.getPrototypeOf(D)===R}function n4(...D){let R={};for(let A of D)for(let[$,f]of Object.entries(A)){let P=R[$];R[$]=x4(P)&&x4(f)?n4(P,f):f}return R}function I0(...D){let R=[m4,...D.filter((A)=>A!=null)];return n4(...R)}function DD({status:D="idle",theme:R}){let[A,$]=i(!1),[f,P]=i(0),{prefix:B,spinner:G}=I0(R);if(e0(()=>{if(D==="loading"){let J,Z=-1,H=setTimeout(()=>{$(!0),J=setInterval(()=>{Z=Z+1,P(Z%G.frames.length)},G.interval)},300);return()=>{clearTimeout(H),clearInterval(J)}}else $(!1)},[D]),A)return G.frames[f];return typeof B==="string"?B:B[D==="loading"?"idle":D]??B.idle}function LR(D,R){return I1((A)=>{let $=A.get();if(!$||$.dependencies.length!==R.length||$.dependencies.some((f,P)=>f!==R[P])){let f=D();return A.set({value:f,dependencies:R}),f}return $.value})}function oD(D){return i({current:D})[0]}function RD(D){let R=oD(D);R.current=D,e0((A)=>{let $=!1,f=x2((P,B)=>{if($)return;R.current(B,A)});return A.input.on("keypress",f),()=>{$=!0,A.input.removeListener("keypress",f)}},[])}var $9=B0(h4(),1);var v4=(()=>{let D=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(R)=>{let A=0;D.lastIndex=0;while(D.test(R))A+=1;return R.length-A}})(),l4=(D)=>{return D===12288||D>=65281&&D<=65376||D>=65504&&D<=65510},k4=(D)=>{return D===8987||D===9001||D>=12272&&D<=12287||D>=12289&&D<=12350||D>=12441&&D<=12543||D>=12549&&D<=12591||D>=12593&&D<=12686||D>=12688&&D<=12771||D>=12783&&D<=12830||D>=12832&&D<=12871||D>=12880&&D<=19903||D>=65040&&D<=65049||D>=65072&&D<=65106||D>=65108&&D<=65126||D>=65128&&D<=65131||D>=127488&&D<=127490||D>=127504&&D<=127547||D>=127552&&D<=127560||D>=131072&&D<=196605||D>=196608&&D<=262141};var CH=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,LH=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,d4=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,NH=/\t{1,1000}/y,i4=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,VH=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,IH=/\p{M}+/gu,KH={limit:1/0,ellipsis:""},a4=(D,R={},A={})=>{let $=R.limit??1/0,f=R.ellipsis??"",P=R?.ellipsisWidth??(f?a4(f,KH,A).width:0),B=0,G=A.controlWidth??0,z=A.tabWidth??8,J=A.emojiWidth??2,Z=2,H=A.regularWidth??1,M=A.wideWidth??2,Q=[[VH,H],[CH,0],[LH,G],[NH,z],[i4,J],[d4,M]],O=0,X=0,T=D.length,U=0,F=!1,w=T,V=Math.max(0,$-P),I=0,j=0,u=0,L=0;D:while(!0){if(j>I||X>=T&&X>O){let S=D.slice(I,j)||D.slice(O,X);U=0;for(let l of S.replaceAll(IH,"")){let k=l.codePointAt(0)||0;if(l4(k))L=2;else if(k4(k))L=M;else L=H;if(u+L>V)w=Math.min(w,Math.max(I,O)+U);if(u+L>$){F=!0;break D}U+=l.length,u+=L}I=j=0}if(X>=T)break D;for(let S=0,l=Q.length;S<l;S++){let[k,g]=Q[S];if(k.lastIndex=X,k.test(D)){if(U=k===d4?v4(D.slice(X,k.lastIndex)):k===i4?1:k.lastIndex-X,L=U*g,u+L>V)w=Math.min(w,X+Math.floor((V-u)/g));if(u+L>$){F=!0;break D}u+=L,I=O,j=X,X=O=k.lastIndex;continue D}}X+=1}return{width:F?V:u,index:F?w:T,truncated:F,ellipsed:F&&$>=P}},r4=a4;var WH={limit:1/0,ellipsis:"",ellipsisWidth:0},jH=(D,R={})=>{return r4(D,WH,R).width},AD=jH;var sA="\x1B",e4="›",SH=39,p2="\x07",D9="[",bH="]",R9="m",h2=`${bH}8;;`,s4=new RegExp(`(?:\\${D9}(?<code>\\d+)m|\\${h2}(?<uri>.*)${p2})`,"y"),o4=(D)=>{if(D>=30&&D<=37)return 39;if(D>=90&&D<=97)return 39;if(D>=40&&D<=47)return 49;if(D>=100&&D<=107)return 49;if(D===1||D===2)return 22;if(D===3)return 23;if(D===4)return 24;if(D===7)return 27;if(D===8)return 28;if(D===9)return 29;if(D===0)return 0;return},c4=(D)=>`${sA}${D9}${D}${R9}`,t4=(D)=>`${sA}${h2}${D}${p2}`,n2=(D,R,A)=>{let $=R[Symbol.iterator](),f=!1,P=!1,B=D.at(-1),G=B===void 0?0:AD(B),z=$.next(),J=$.next(),Z=0;while(!z.done){let H=z.value,M=AD(H);if(G+M<=A)D[D.length-1]+=H;else D.push(H),G=0;if(H===sA||H===e4)f=!0,P=R.startsWith(h2,Z+1);if(f){if(P){if(H===p2)f=!1,P=!1}else if(H===R9)f=!1}else if(G+=M,G===A&&!J.done)D.push(""),G=0;z=J,J=$.next(),Z+=H.length}if(B=D.at(-1),!G&&B!==void 0&&B.length&&D.length>1)D[D.length-2]+=D.pop()},uH=(D)=>{let R=D.split(" "),A=R.length;while(A){if(AD(R[A-1]))break;A--}if(A===R.length)return D;return R.slice(0,A).join(" ")+R.slice(A).join("")},EH=(D,R,A={})=>{if(A.trim!==!1&&D.trim()==="")return"";let $="",f,P,B=D.split(" "),G=[""],z=0;for(let H=0;H<B.length;H++){let M=B[H];if(A.trim!==!1){let O=G.at(-1)??"",X=O.trimStart();if(O.length!==X.length)G[G.length-1]=X,z=AD(X)}if(H!==0){if(z>=R&&(A.wordWrap===!1||A.trim===!1))G.push(""),z=0;if(z||A.trim===!1)G[G.length-1]+=" ",z++}let Q=AD(M);if(A.hard&&Q>R){let O=R-z,X=1+Math.floor((Q-O-1)/R);if(Math.floor((Q-1)/R)<X)G.push("");n2(G,M,R),z=AD(G.at(-1)??"");continue}if(z+Q>R&&z&&Q){if(A.wordWrap===!1&&z<R){n2(G,M,R),z=AD(G.at(-1)??"");continue}G.push(""),z=0}if(z+Q>R&&A.wordWrap===!1){n2(G,M,R),z=AD(G.at(-1)??"");continue}G[G.length-1]+=M,z+=Q}if(A.trim!==!1)G=G.map((H)=>uH(H));let J=G.join(`
171
171
  `),Z=!1;for(let H=0;H<J.length;H++){let M=J[H];if($+=M,!Z){if(Z=M>="\uD800"&&M<="\uDBFF",Z)continue}else Z=!1;if(M===sA||M===e4){s4.lastIndex=H+1;let O=s4.exec(J)?.groups;if(O?.code!==void 0){let X=Number.parseFloat(O.code);f=X===SH?void 0:X}else if(O?.uri!==void 0)P=O.uri.length===0?void 0:O.uri}if(J[H+1]===`
172
172
  `){if(P)$+=t4("");let Q=f?o4(f):void 0;if(f&&Q)$+=c4(Q)}else if(M===`
173
173
  `){if(f&&o4(f))$+=c4(f);if(P)$+=t4(P)}}return $},yH=/\r?\n/;function A9(D,R,A){return String(D).normalize().split(yH).map(($)=>EH($,R,A)).join(`
174
174
  `)}function NR(D,R){return D.split(`
175
175
  `).flatMap((A)=>A9(A,R,{trim:!1,hard:!0}).split(`
176
176
  `).map(($)=>$.trimEnd())).join(`
177
- `)}function oA(){return $9.default({defaultWidth:80,output:gf().output})}function gH({active:D,renderedItems:R,pageSize:A,loop:$}){let f=oD({lastPointer:D,lastActive:void 0}),{lastPointer:P,lastActive:B}=f.current,G=Math.floor(A/2),z=R.reduce((H,M)=>H+M.length,0),J=R.slice(0,D).reduce((H,M)=>H+M.length,0),Z=J;if(z>A)if($){if(Z=P,B!=null&&B<D&&D-B<A)Z=Math.min(G,Math.abs(D-B)===1?Math.min(P+(R[B]?.length??0),Math.max(J,P)):P+D-B)}else{let H=R.slice(D).reduce((M,Q)=>M+Q.length,0);Z=H<A-G?A-H:Math.min(J,G)}return f.current.lastPointer=Z,f.current.lastActive=D,Z}function hf({items:D,active:R,renderItem:A,pageSize:$,loop:f=!0}){let P=oA(),B=(U)=>(U%D.length+D.length)%D.length,G=D.map((U,F)=>{if(U==null)return[];return NR(A({item:U,index:F,isActive:F===R}),P).split(`
177
+ `)}function oA(){return $9.default({defaultWidth:80,output:m2().output})}function gH({active:D,renderedItems:R,pageSize:A,loop:$}){let f=oD({lastPointer:D,lastActive:void 0}),{lastPointer:P,lastActive:B}=f.current,G=Math.floor(A/2),z=R.reduce((H,M)=>H+M.length,0),J=R.slice(0,D).reduce((H,M)=>H+M.length,0),Z=J;if(z>A)if($){if(Z=P,B!=null&&B<D&&D-B<A)Z=Math.min(G,Math.abs(D-B)===1?Math.min(P+(R[B]?.length??0),Math.max(J,P)):P+D-B)}else{let H=R.slice(D).reduce((M,Q)=>M+Q.length,0);Z=H<A-G?A-H:Math.min(J,G)}return f.current.lastPointer=Z,f.current.lastActive=D,Z}function v2({items:D,active:R,renderItem:A,pageSize:$,loop:f=!0}){let P=oA(),B=(U)=>(U%D.length+D.length)%D.length,G=D.map((U,F)=>{if(U==null)return[];return NR(A({item:U,index:F,isActive:F===R}),P).split(`
178
178
  `)}),z=G.reduce((U,F)=>U+F.length,0),J=(U)=>G[U]??[],Z=gH({active:R,renderedItems:G,pageSize:$,loop:f}),H=J(R).slice(0,$),M=Z+H.length<=$?Z:$-H.length,Q=Array.from({length:$});Q.splice(M,H.length,...H);let O=new Set([R]),X=M+H.length,T=B(R+1);while(X<$&&!O.has(T)&&(f&&z>$?T!==R:T>R)){let F=J(T).slice(0,$-X);Q.splice(X,F.length,...F),O.add(T),X+=F.length,T=B(T+1)}X=M-1,T=B(R-1);while(X>=0&&!O.has(T)&&(f&&z>$?T!==R:T<R)){let U=J(T),F=U.slice(Math.max(0,U.length-X-1));Q.splice(X-F.length+1,F.length,...F),O.add(T),X-=F.length,T=B(T-1)}return Q.filter((U)=>typeof U==="string").join(`
179
- `)}var T9=B0(B9(),1);import*as Q9 from"node:readline";import{AsyncResource as lH}from"node:async_hooks";var cD=[];cD.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")cD.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")cD.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var cA=(D)=>!!D&&typeof D==="object"&&typeof D.removeListener==="function"&&typeof D.emit==="function"&&typeof D.reallyExit==="function"&&typeof D.listeners==="function"&&typeof D.kill==="function"&&typeof D.pid==="number"&&typeof D.on==="function",vf=Symbol.for("signal-exit emitter"),lf=globalThis,xH=Object.defineProperty.bind(Object);class G9{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(lf[vf])return lf[vf];xH(lf,vf,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(D,R){this.listeners[D].push(R)}removeListener(D,R){let A=this.listeners[D],$=A.indexOf(R);if($===-1)return;if($===0&&A.length===1)A.length=0;else A.splice($,1)}emit(D,R,A){if(this.emitted[D])return!1;this.emitted[D]=!0;let $=!1;for(let f of this.listeners[D])$=f(R,A)===!0||$;if(D==="exit")$=this.emit("afterExit",R,A)||$;return $}}class df{}var nH=(D)=>{return{onExit(R,A){return D.onExit(R,A)},load(){return D.load()},unload(){return D.unload()}}};class z9 extends df{onExit(){return()=>{}}load(){}unload(){}}class J9 extends df{#D=kf.platform==="win32"?"SIGINT":"SIGHUP";#A=new G9;#R;#B;#P;#$={};#f=!1;constructor(D){super();this.#R=D,this.#$={};for(let R of cD)this.#$[R]=()=>{let A=this.#R.listeners(R),{count:$}=this.#A,f=D;if(typeof f.__signal_exit_emitter__==="object"&&typeof f.__signal_exit_emitter__.count==="number")$+=f.__signal_exit_emitter__.count;if(A.length===$){this.unload();let P=this.#A.emit("exit",null,R),B=R==="SIGHUP"?this.#D:R;if(!P)D.kill(D.pid,B)}};this.#P=D.reallyExit,this.#B=D.emit}onExit(D,R){if(!cA(this.#R))return()=>{};if(this.#f===!1)this.load();let A=R?.alwaysLast?"afterExit":"exit";return this.#A.on(A,D),()=>{if(this.#A.removeListener(A,D),this.#A.listeners.exit.length===0&&this.#A.listeners.afterExit.length===0)this.unload()}}load(){if(this.#f)return;this.#f=!0,this.#A.count+=1;for(let D of cD)try{let R=this.#$[D];if(R)this.#R.on(D,R)}catch(R){}this.#R.emit=(D,...R)=>{return this.#z(D,...R)},this.#R.reallyExit=(D)=>{return this.#G(D)}}unload(){if(!this.#f)return;this.#f=!1,cD.forEach((D)=>{let R=this.#$[D];if(!R)throw Error("Listener not defined for signal: "+D);try{this.#R.removeListener(D,R)}catch(A){}}),this.#R.emit=this.#B,this.#R.reallyExit=this.#P,this.#A.count-=1}#G(D){if(!cA(this.#R))return 0;return this.#R.exitCode=D||0,this.#A.emit("exit",this.#R.exitCode,null),this.#P.call(this.#R,this.#R.exitCode)}#z(D,...R){let A=this.#B;if(D==="exit"&&cA(this.#R)){if(typeof R[0]==="number")this.#R.exitCode=R[0];let $=A.call(this.#R,D,...R);return this.#A.emit("exit",this.#R.exitCode,null),$}else return A.call(this.#R,D,...R)}}var kf=globalThis.process,{onExit:H9,load:dV,unload:iV}=nH(cA(kf)?new J9(kf):new z9);import{stripVTControlCharacters as hH}from"node:util";var pH="\x1B[G",tA="\x1B[?25l",M9="\x1B[?25h",af=(D=1)=>D>0?`\x1B[${D}A`:"",rf=(D=1)=>D>0?`\x1B[${D}B`:"",sf=(D,R)=>{if(typeof R==="number"&&!Number.isNaN(R))return`\x1B[${R+1};${D+1}H`;return`\x1B[${D+1}G`},Z9="\x1B[2K",of=(D)=>D>0?(Z9+af(1)).repeat(D-1)+Z9+pH:"";var X9=(D)=>D.split(`
179
+ `)}var T9=B0(B9(),1);import*as Q9 from"node:readline";import{AsyncResource as lH}from"node:async_hooks";var cD=[];cD.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")cD.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")cD.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var cA=(D)=>!!D&&typeof D==="object"&&typeof D.removeListener==="function"&&typeof D.emit==="function"&&typeof D.reallyExit==="function"&&typeof D.listeners==="function"&&typeof D.kill==="function"&&typeof D.pid==="number"&&typeof D.on==="function",l2=Symbol.for("signal-exit emitter"),k2=globalThis,xH=Object.defineProperty.bind(Object);class G9{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(k2[l2])return k2[l2];xH(k2,l2,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(D,R){this.listeners[D].push(R)}removeListener(D,R){let A=this.listeners[D],$=A.indexOf(R);if($===-1)return;if($===0&&A.length===1)A.length=0;else A.splice($,1)}emit(D,R,A){if(this.emitted[D])return!1;this.emitted[D]=!0;let $=!1;for(let f of this.listeners[D])$=f(R,A)===!0||$;if(D==="exit")$=this.emit("afterExit",R,A)||$;return $}}class i2{}var nH=(D)=>{return{onExit(R,A){return D.onExit(R,A)},load(){return D.load()},unload(){return D.unload()}}};class z9 extends i2{onExit(){return()=>{}}load(){}unload(){}}class J9 extends i2{#D=d2.platform==="win32"?"SIGINT":"SIGHUP";#A=new G9;#R;#B;#P;#$={};#f=!1;constructor(D){super();this.#R=D,this.#$={};for(let R of cD)this.#$[R]=()=>{let A=this.#R.listeners(R),{count:$}=this.#A,f=D;if(typeof f.__signal_exit_emitter__==="object"&&typeof f.__signal_exit_emitter__.count==="number")$+=f.__signal_exit_emitter__.count;if(A.length===$){this.unload();let P=this.#A.emit("exit",null,R),B=R==="SIGHUP"?this.#D:R;if(!P)D.kill(D.pid,B)}};this.#P=D.reallyExit,this.#B=D.emit}onExit(D,R){if(!cA(this.#R))return()=>{};if(this.#f===!1)this.load();let A=R?.alwaysLast?"afterExit":"exit";return this.#A.on(A,D),()=>{if(this.#A.removeListener(A,D),this.#A.listeners.exit.length===0&&this.#A.listeners.afterExit.length===0)this.unload()}}load(){if(this.#f)return;this.#f=!0,this.#A.count+=1;for(let D of cD)try{let R=this.#$[D];if(R)this.#R.on(D,R)}catch(R){}this.#R.emit=(D,...R)=>{return this.#z(D,...R)},this.#R.reallyExit=(D)=>{return this.#G(D)}}unload(){if(!this.#f)return;this.#f=!1,cD.forEach((D)=>{let R=this.#$[D];if(!R)throw Error("Listener not defined for signal: "+D);try{this.#R.removeListener(D,R)}catch(A){}}),this.#R.emit=this.#B,this.#R.reallyExit=this.#P,this.#A.count-=1}#G(D){if(!cA(this.#R))return 0;return this.#R.exitCode=D||0,this.#A.emit("exit",this.#R.exitCode,null),this.#P.call(this.#R,this.#R.exitCode)}#z(D,...R){let A=this.#B;if(D==="exit"&&cA(this.#R)){if(typeof R[0]==="number")this.#R.exitCode=R[0];let $=A.call(this.#R,D,...R);return this.#A.emit("exit",this.#R.exitCode,null),$}else return A.call(this.#R,D,...R)}}var d2=globalThis.process,{onExit:H9,load:lV,unload:kV}=nH(cA(d2)?new J9(d2):new z9);import{stripVTControlCharacters as hH}from"node:util";var pH="\x1B[G",tA="\x1B[?25l",M9="\x1B[?25h",a2=(D=1)=>D>0?`\x1B[${D}A`:"",r2=(D=1)=>D>0?`\x1B[${D}B`:"",s2=(D,R)=>{if(typeof R==="number"&&!Number.isNaN(R))return`\x1B[${R+1};${D+1}H`;return`\x1B[${D+1}G`},Z9="\x1B[2K",o2=(D)=>D>0?(Z9+a2(1)).repeat(D-1)+Z9+pH:"";var X9=(D)=>D.split(`
180
180
  `).length,vH=(D)=>D.split(`
181
181
  `).pop()??"";class eA{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(D){this.rl=D,this.cursorPos=D.getCursorPos()}write(D){this.rl.output.unmute(),this.rl.output.write(D),this.rl.output.mute()}render(D,R=""){let A=vH(D),$=hH(A),f=$;if(this.rl.line.length>0)f=f.slice(0,-this.rl.line.length);this.rl.setPrompt(f),this.cursorPos=this.rl.getCursorPos();let P=oA();if(D=NR(D,P),R=NR(R,P),$.length%P===0)D+=`
182
182
  `;let B=D+(R?`
183
- `+R:""),z=Math.floor($.length/P)-this.cursorPos.rows+(R?X9(R):0);if(z>0)B+=af(z);B+=sf(this.cursorPos.cols),this.write(rf(this.extraLinesUnderPrompt)+of(this.height)+B),this.extraLinesUnderPrompt=z,this.height=X9(B)}checkCursorPos(){let D=this.rl.getCursorPos();if(D.cols!==this.cursorPos.cols)this.write(sf(D.cols)),this.cursorPos=D}done({clearContent:D}){this.rl.setPrompt("");let R=rf(this.extraLinesUnderPrompt);R+=D?of(this.height):`
184
- `,R+=M9,this.write(R),this.rl.close()}}class cf extends Promise{static withResolver(){let D,R;return{promise:new Promise(($,f)=>{D=$,R=f}),resolve:D,reject:R}}}import kH from"node:path";var dH=globalThis.setImmediate;function iH(){let D=Error.prepareStackTrace,R=[];try{Error.prepareStackTrace=(A,$)=>{let f=$.slice(1);return R=f,f},Error().stack}catch{return R}return Error.prepareStackTrace=D,R}function $D(D){let R=iH();return($,f={})=>{let{input:P=process.stdin,signal:B}=f,G=new Set,z=new T9.default;z.pipe(f.output??process.stdout),z.mute();let J=Q9.createInterface({terminal:!0,input:P,output:z}),Z=new eA(J),{promise:H,resolve:M,reject:Q}=cf.withResolver(),O=()=>Q(new Ef);if(B){let T=()=>Q(new uf({cause:B.reason}));if(B.aborted)return T(),Object.assign(H,{cancel:O});B.addEventListener("abort",T),G.add(()=>B.removeEventListener("abort",T))}G.add(H9((T,U)=>{Q(new rA(`User force closed the prompt with ${T} ${U}`))}));let X=()=>Q(new rA("User force closed the prompt with SIGINT"));return J.on("SIGINT",X),G.add(()=>J.removeListener("SIGINT",X)),u4(J,(T)=>{let U=lH.bind(()=>sD.clearAll());J.on("close",U),G.add(()=>J.removeListener("close",U));let F=()=>{let w=()=>Z.checkCursorPos();J.input.on("keypress",w),G.add(()=>J.input.removeListener("keypress",w));let V=null;T(()=>{let I=!1;try{let j=D($,(S)=>{if(I)M(S);else V={value:S}});if(j===void 0){let S=R[1]?.getFileName();if(S&&!S.startsWith("file://"))S=kH.resolve(S);throw Error(`Prompt functions must return a string.
185
- at ${S}`)}let[u,L]=typeof j==="string"?[j]:j;Z.render(u,L),sD.run()}catch(j){Q(j)}if(I=!0,V!==null){let{value:j}=V;V=null,M(j)}})};if("readableFlowing"in P)dH(F);else F();return Object.assign(H.then((w)=>{return sD.clearAll(),w},(w)=>{throw sD.clearAll(),w}).finally(()=>{G.forEach((w)=>w()),Z.done({clearContent:Boolean(f.clearPromptOnDone)}),z.end()}).then(()=>H),{cancel:O})})}}import{styleText as aH}from"node:util";class m0{separator=aH("dim",Array.from({length:15}).join(K1.line));type="separator";constructor(D){if(D)this.separator=D}static isSeparator(D){return Boolean(D&&typeof D==="object"&&"type"in D&&D.type==="separator")}}function O9(D,R){let A=R!==!1;if(/^(y|yes)/i.test(D))A=!0;else if(/^(n|no)/i.test(D))A=!1;return A}function Y9(D){return D?"Yes":"No"}var tf=$D((D,R)=>{let{transformer:A=Y9}=D,[$,f]=i("idle"),[P,B]=i(""),G=I0(D.theme),z=DD({status:$,theme:G});RD((M,Q)=>{if($!=="idle")return;if(t0(M)){let O=O9(P,D.default);B(A(O)),f("done"),R(O)}else if(wR(M)){let O=Y9(!O9(P,D.default));Q.clearLine(0),Q.write(O),B(O)}else B(Q.line)});let J=P,Z="";if($==="done")J=G.style.answer(P);else Z=` ${G.style.defaultAnswer(D.default===!1?"y/N":"Y/n")}`;let H=G.style.message(D.message,$);return`${z} ${H}${Z} ${J}`});var rH={validationFailureMode:"keep"},VR=$D((D,R)=>{let{prefill:A="tab"}=D,$=I0(rH,D.theme),[f,P]=i("idle"),[B,G]=i(String(D.default??"")),[z,J]=i(),[Z,H]=i(""),M=DD({status:f,theme:$});async function Q(F){let{required:w,pattern:V,patternError:I="Invalid input"}=D;if(w&&!F)return"You must provide a value";if(V&&!V.test(F))return I;if(typeof D.validate==="function")return await D.validate(F)||"You must provide a valid value";return!0}RD(async(F,w)=>{if(f!=="idle")return;if(t0(F)){let V=Z||B;P("loading");let I=await Q(V);if(I===!0)H(V),P("done"),R(V);else{if($.validationFailureMode==="clear")H("");else w.write(Z);J(I),P("idle")}}else if(qR(F)&&!Z)G("");else if(wR(F)&&!Z)G(""),w.clearLine(0),w.write(B),H(B);else H(w.line),J(void 0)}),e0((F)=>{if(A==="editable"&&B)F.write(B),H(B)},[]);let O=$.style.message(D.message,f),X=Z;if(typeof D.transformer==="function")X=D.transformer(Z,{isFinal:f==="done"});else if(f==="done")X=$.style.answer(Z);let T;if(B&&f!=="done"&&!Z)T=$.style.defaultAnswer(B);let U="";if(z)U=$.style.error(z);return[[M,O,T,X].filter((F)=>F!==void 0).join(" "),U]});var sH={style:{maskedText:"[input is masked]"}},ef=$D((D,R)=>{let{validate:A=()=>!0}=D,$=I0(sH,D.theme),[f,P]=i("idle"),[B,G]=i(),[z,J]=i(""),Z=DD({status:f,theme:$});RD(async(X,T)=>{if(f!=="idle")return;if(t0(X)){let U=z;P("loading");let F=await A(U);if(F===!0)J(U),P("done"),R(U);else T.write(z),G(F||"You must provide a valid value"),P("idle")}else J(T.line),G(void 0)});let H=$.style.message(D.message,f),M="",Q;if(D.mask)M=(typeof D.mask==="string"?D.mask:"*").repeat(z.length);else if(f!=="done")Q=`${$.style.help($.style.maskedText)}${tA}`;if(f==="done")M=$.style.answer(M);let O="";if(B)O=$.style.error(B);return[[Z,H,D.mask?M:Q].join(" "),O]});import{styleText as IR}from"node:util";var oH={icon:{cursor:K1.pointer},style:{disabled:(D)=>IR("dim",D),description:(D)=>IR("cyan",D),keysHelpTip:(D)=>D.map(([R,A])=>`${IR("bold",R)} ${IR("dim",A)}`).join(IR("dim"," • "))},i18n:{disabledError:"This option is disabled and cannot be selected."},indexMode:"hidden",keybindings:[]};function D3(D){return!m0.isSeparator(D)&&!D.disabled}function R3(D){return!m0.isSeparator(D)}function cH(D){return D.map((R)=>{if(m0.isSeparator(R))return R;if(typeof R!=="object"||R===null||!("value"in R)){let f=String(R);return{value:R,name:f,short:f,disabled:!1}}let A=R.name??String(R.value),$={value:R.value,name:A,short:R.short??A,disabled:R.disabled??!1};if(R.description)$.description=R.description;return $})}var KR=$D((D,R)=>{let{loop:A=!0,pageSize:$=7}=D,f=I0(oH,D.theme),{keybindings:P}=f,[B,G]=i("idle"),z=DD({status:B,theme:f}),J=oD(),Z=!P.includes("vim"),H=LR(()=>cH(D.choices),[D.choices]),M=LR(()=>{let S=H.findIndex(R3),l=H.findLastIndex(R3);if(S===-1)throw new CR("[select prompt] No selectable choices. All choices are disabled.");return{first:S,last:l}},[H]),Q=LR(()=>{if(!("default"in D))return-1;return H.findIndex((S)=>D3(S)&&S.value===D.default)},[D.default,H]),[O,X]=i(Q===-1?M.first:Q),T=H[O];if(T==null||m0.isSeparator(T))throw Error("Active index does not point to a choice");let[U,F]=i();RD((S,l)=>{if(clearTimeout(J.current),U)F(void 0);if(t0(S))if(T.disabled)F(f.i18n.disabledError);else G("done"),R(T.value);else if(FR(S,P)||aA(S,P)){if(l.clearLine(0),A||FR(S,P)&&O!==M.first||aA(S,P)&&O!==M.last){let k=FR(S,P)?-1:1,g=O;do g=(g+k+H.length)%H.length;while(!R3(H[g]));X(g)}}else if(bf(S)&&!Number.isNaN(Number(l.line))){let k=Number(l.line)-1,g=-1,Y0=H.findIndex((MR)=>{if(m0.isSeparator(MR))return!1;return g++,g===k}),c2=H[Y0];if(c2!=null&&D3(c2))X(Y0);J.current=setTimeout(()=>{l.clearLine(0)},700)}else if(qR(S))l.clearLine(0);else if(Z){let k=l.line.toLowerCase(),g=H.findIndex((Y0)=>{if(m0.isSeparator(Y0)||!D3(Y0))return!1;return Y0.name.toLowerCase().startsWith(k)});if(g!==-1)X(g);J.current=setTimeout(()=>{l.clearLine(0)},700)}}),e0(()=>()=>{clearTimeout(J.current)},[]);let w=f.style.message(D.message,B),V=f.style.keysHelpTip([["↑↓","navigate"],["⏎","select"]]),I=0,j=hf({items:H,active:O,renderItem({item:S,isActive:l,index:k}){if(m0.isSeparator(S))return I++,` ${S.separator}`;let g=l?f.icon.cursor:" ",Y0=f.indexMode==="number"?`${k+1-I}. `:"";if(S.disabled){let MR=typeof S.disabled==="string"?S.disabled:"(disabled)",RJ=l?f.icon.cursor:"-";return f.style.disabled(`${RJ} ${Y0}${S.name} ${MR}`)}return(l?f.style.highlight:(MR)=>MR)(`${g} ${Y0}${S.name}`)},pageSize:$,loop:A});if(B==="done")return[z,w,f.style.answer(T.short)].filter(Boolean).join(" ");let{description:u}=T;return`${[[z,w].filter(Boolean).join(" "),j," ",u?f.style.description(u):"",U?f.style.error(U):"",V].filter(Boolean).join(`
186
- `).trimEnd()}${tA}`});function _9(D){if(D==="table"||D==="json"||D==="yaml")return D;throw Error("Output must be one of: table, json, yaml.")}function U9(D){if(D.json)D.output="json";if(D.output??="table",D.json=D.output==="json",D.color===!1)process.env.NO_COLOR=process.env.NO_COLOR??"1"}function tH(D){if(D.output)return D.output;return D.json?"json":"table"}function C(D){return tH(D)==="json"}var XP=B0(KB(),1);import{mkdir as tU,readFile as eU,rm as wW,writeFile as DF}from"node:fs/promises";import RF from"node:os";import WB from"node:path";var AF={version:1,currentProjectByAuthId:{},auths:[]};function jB(){return WB.join(RF.homedir(),".abrun","config.yaml")}async function SB(){try{let D=await eU(jB(),"utf8"),R=XP.default.parse(D);return{version:1,currentProjectByAuthId:R?.currentProjectByAuthId??{},auths:R?.auths??[],currentAuthId:R?.currentAuthId}}catch(D){if(D.code==="ENOENT")return structuredClone(AF);throw D}}async function p0(D){let R=jB();await tU(WB.dirname(R),{recursive:!0}),await DF(R,XP.default.stringify(D),"utf8")}var b=_(async(D,R)=>{let A=await D.client.api.projectsList(),$=D.options.project&&A.find((P)=>_R(P,D.options.project))||(D.auth&&D.state.currentProjectByAuthId[D.auth.id]?A.find((P)=>_R(P,D.state.currentProjectByAuthId[D.auth.id])):void 0);if(!$&&A.length===1)$=A[0];if(!$&&A.length>1&&process.stdout.isTTY&&!C(D.options)){let P=await KR({message:"Select project",choices:A.map((B)=>({value:String(B.id),name:`${B.name} (${B.slug}, #${B.id})`}))});$=A.find((B)=>String(B.id)===P)}if(!$)D.abort("No project available for the selected auth.");let f=$;D.project=f,D.state.currentProjectByAuthId[D.auth.id]=String(f.id),await p0(D.state),await R()});var N=_(async(D,R)=>{U9(D.options),D.state=await SB(),D.endpoint=D.options.endpoint??Sf(),await R()});var x=_(async(D,R)=>{let $=((await D.client.api.appsList()).items??[]).find((f)=>N4(f,D.args.app));if(!$)D.abort(`App not found: ${D.args.app}`);D.app=$,await R()});async function h0(D,R,A,$,f){if(A.length===0)throw Error("No available options.");if(!process.stdout.isTTY||C(D.options))D.abort($);if(A.length===1&&!f?.forcePromptSingle)return A[0].value;return KR({message:R,choices:A})}async function p1(D,R,A){if(!process.stdout.isTTY||C(D.options))D.abort(A);return tf({message:R,default:!1})}async function bB(D,R,A){if(!process.stdout.isTTY||C(D.options))D.abort(A);let $=await VR({message:R,validate:(f)=>{let P=Number(f);return Number.isInteger(P)&&P>=1&&P<=65535?!0:"Port must be an integer between 1 and 65535."}});return Number($)}async function uB(D,R){let A=await h0(D,"Select app plan",R.map(($)=>({value:$.name??"",name:`${$.name??""} (${$.cpuMilli??0}m CPU / ${$.memoryMb??0}Mi / ${$.diskGb??0}Gi)`})),"App plan is required. Use --plan or run in an interactive terminal.",{forcePromptSingle:!0});return dD(R,A)}async function EB(D,R){let A=await h0(D,"Select app bundle",R.map(($)=>({value:$.name??"",name:`${$.name??""} (${$.backupStorageGb??0}Gi backup, ${$.priceHourly??0}/hour)`})),"App bundle is required. Use --bundle or run in an interactive terminal.",{forcePromptSingle:!0});return iD(R,A)}async function QP(D,R){let A=await h0(D,"Select database plan",R.map(($)=>({value:$.name??"",name:`${$.name??""} (${$.cpuMilli??0}m CPU / ${$.memoryMb??0}Mi / ${$.diskGb??0}Gi)`})),"Database plan is required. Use --plan or run in an interactive terminal.");return UD(R,A)}async function TP(D,R){let A=await h0(D,"Select database bundle",R.map(($)=>({value:$.name??"",name:`${$.name??""} (${$.publicAccess?"public":"private"}, plugins: ${$.databasePlugins?"yes":"no"})`})),"Database bundle is required. Use --bundle or run in an interactive terminal.");return V1(R,A)}var yB=_(async(D,R)=>{let A=await D.client.api.appPlansList(),$=D.options.plan?.trim()||await h0(D,"Select app plan",A.map((J)=>({value:J.name??"",name:J.name??""})),"App plan is required. Use --plan or run in an interactive terminal.",{forcePromptSingle:!0}),f=dD(A,$),P=await D.client.api.appPlansBundlesList({planName:f.name}),B=D.options.bundle?.trim()||await h0(D,"Select app bundle",P.map((J)=>({value:J.name??"",name:J.name??""})),"App bundle is required. Use --bundle or run in an interactive terminal.",{forcePromptSingle:!0}),G=iD(P,B),z=D.options.port??await bB(D,"App runtime port","App port is required. Use --port or run in an interactive terminal.");D.plan=f,D.bundle=G,D.app=await D.client.api.appsCreate({name:D.args.name,plan:f.name,bundle:G.name,port:z,securityProfile:D.options.securityProfile}),await R()}),gB=_(async(D)=>{if(C(D.options)){W(D.app,!0);return}console.log(`Created app ${D.app.name} (${D.app.status})`)});var mB=_(async(D)=>{await D.client.api.appsDelete({appId:D.app.id}),console.log(`Removed app ${D.app.name}`)});import{rm as SG}from"node:fs/promises";import ZC from"node:path";import{mkdtemp as Bw}from"node:fs/promises";import Gw from"node:os";import t5 from"node:path";import PF from"events";import M0 from"fs";import{EventEmitter as H6}from"node:events";import _5 from"node:stream";import{StringDecoder as BF}from"node:string_decoder";import q5 from"node:path";import s1 from"node:fs";import{dirname as UF,parse as FF}from"path";import{EventEmitter as KF}from"events";import dP from"assert";import{Buffer as T1}from"buffer";import*as vB from"zlib";import WF from"zlib";import{posix as v1}from"node:path";import{basename as Aq}from"node:path";import X2 from"fs";import d0 from"fs";import sB from"path";import{win32 as Xq}from"node:path";import A5 from"path";import g5 from"node:fs";import jq from"node:assert";import{randomBytes as m5}from"node:crypto";import n from"node:fs";import e from"node:path";import x5 from"fs";import C2 from"node:fs";import TA from"node:path";import T0 from"node:fs";import mq from"node:fs/promises";import O2 from"node:path";import{join as s5}from"node:path";import Q0 from"node:fs";import c5 from"node:path";var $F=Object.defineProperty,fF=(D,R)=>{for(var A in R)$F(D,A,{get:R[A],enumerable:!0})},xB=typeof process=="object"&&process?process:{stdout:null,stderr:null},GF=(D)=>!!D&&typeof D=="object"&&(D instanceof _1||D instanceof _5||zF(D)||JF(D)),zF=(D)=>!!D&&typeof D=="object"&&D instanceof H6&&typeof D.pipe=="function"&&D.pipe!==_5.Writable.prototype.pipe,JF=(D)=>!!D&&typeof D=="object"&&D instanceof H6&&typeof D.write=="function"&&typeof D.end=="function",BD=Symbol("EOF"),GD=Symbol("maybeEmitEnd"),WD=Symbol("emittedEnd"),h$=Symbol("emittingEnd"),eR=Symbol("emittedError"),v$=Symbol("closed"),nB=Symbol("read"),l$=Symbol("flush"),pB=Symbol("flushChunk"),j0=Symbol("encoding"),h1=Symbol("decoder"),R0=Symbol("flowing"),DA=Symbol("paused"),i1=Symbol("resume"),A0=Symbol("buffer"),z0=Symbol("pipes"),$0=Symbol("bufferLength"),OP=Symbol("bufferPush"),k$=Symbol("bufferShift"),G0=Symbol("objectMode"),r=Symbol("destroyed"),YP=Symbol("error"),_P=Symbol("emitData"),hB=Symbol("emitEnd"),UP=Symbol("emitEnd2"),v0=Symbol("async"),FP=Symbol("abort"),d$=Symbol("aborted"),RA=Symbol("signal"),P1=Symbol("dataListeners"),X0=Symbol("discarded"),AA=(D)=>Promise.resolve().then(D),HF=(D)=>D(),ZF=(D)=>D==="end"||D==="finish"||D==="prefinish",MF=(D)=>D instanceof ArrayBuffer||!!D&&typeof D=="object"&&D.constructor&&D.constructor.name==="ArrayBuffer"&&D.byteLength>=0,XF=(D)=>!Buffer.isBuffer(D)&&ArrayBuffer.isView(D),U5=class{src;dest;opts;ondrain;constructor(D,R,A){this.src=D,this.dest=R,this.opts=A,this.ondrain=()=>D[i1](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(D){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},QF=class extends U5{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(D,R,A){super(D,R,A),this.proxyErrors=($)=>this.dest.emit("error",$),D.on("error",this.proxyErrors)}},TF=(D)=>!!D.objectMode,OF=(D)=>!D.objectMode&&!!D.encoding&&D.encoding!=="buffer",_1=class extends H6{[R0]=!1;[DA]=!1;[z0]=[];[A0]=[];[G0];[j0];[v0];[h1];[BD]=!1;[WD]=!1;[h$]=!1;[v$]=!1;[eR]=null;[$0]=0;[r]=!1;[RA];[d$]=!1;[P1]=0;[X0]=!1;writable=!0;readable=!0;constructor(...D){let R=D[0]||{};if(super(),R.objectMode&&typeof R.encoding=="string")throw TypeError("Encoding and objectMode may not be used together");TF(R)?(this[G0]=!0,this[j0]=null):OF(R)?(this[j0]=R.encoding,this[G0]=!1):(this[G0]=!1,this[j0]=null),this[v0]=!!R.async,this[h1]=this[j0]?new BF(this[j0]):null,R&&R.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[A0]}),R&&R.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[z0]});let{signal:A}=R;A&&(this[RA]=A,A.aborted?this[FP]():A.addEventListener("abort",()=>this[FP]()))}get bufferLength(){return this[$0]}get encoding(){return this[j0]}set encoding(D){throw Error("Encoding must be set at instantiation time")}setEncoding(D){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[G0]}set objectMode(D){throw Error("objectMode must be set at instantiation time")}get async(){return this[v0]}set async(D){this[v0]=this[v0]||!!D}[FP](){this[d$]=!0,this.emit("abort",this[RA]?.reason),this.destroy(this[RA]?.reason)}get aborted(){return this[d$]}set aborted(D){}write(D,R,A){if(this[d$])return!1;if(this[BD])throw Error("write after end");if(this[r])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof R=="function"&&(A=R,R="utf8"),R||(R="utf8");let $=this[v0]?AA:HF;if(!this[G0]&&!Buffer.isBuffer(D)){if(XF(D))D=Buffer.from(D.buffer,D.byteOffset,D.byteLength);else if(MF(D))D=Buffer.from(D);else if(typeof D!="string")throw Error("Non-contiguous data written to non-objectMode stream")}return this[G0]?(this[R0]&&this[$0]!==0&&this[l$](!0),this[R0]?this.emit("data",D):this[OP](D),this[$0]!==0&&this.emit("readable"),A&&$(A),this[R0]):D.length?(typeof D=="string"&&!(R===this[j0]&&!this[h1]?.lastNeed)&&(D=Buffer.from(D,R)),Buffer.isBuffer(D)&&this[j0]&&(D=this[h1].write(D)),this[R0]&&this[$0]!==0&&this[l$](!0),this[R0]?this.emit("data",D):this[OP](D),this[$0]!==0&&this.emit("readable"),A&&$(A),this[R0]):(this[$0]!==0&&this.emit("readable"),A&&$(A),this[R0])}read(D){if(this[r])return null;if(this[X0]=!1,this[$0]===0||D===0||D&&D>this[$0])return this[GD](),null;this[G0]&&(D=null),this[A0].length>1&&!this[G0]&&(this[A0]=[this[j0]?this[A0].join(""):Buffer.concat(this[A0],this[$0])]);let R=this[nB](D||null,this[A0][0]);return this[GD](),R}[nB](D,R){if(this[G0])this[k$]();else{let A=R;D===A.length||D===null?this[k$]():typeof A=="string"?(this[A0][0]=A.slice(D),R=A.slice(0,D),this[$0]-=D):(this[A0][0]=A.subarray(D),R=A.subarray(0,D),this[$0]-=D)}return this.emit("data",R),!this[A0].length&&!this[BD]&&this.emit("drain"),R}end(D,R,A){return typeof D=="function"&&(A=D,D=void 0),typeof R=="function"&&(A=R,R="utf8"),D!==void 0&&this.write(D,R),A&&this.once("end",A),this[BD]=!0,this.writable=!1,(this[R0]||!this[DA])&&this[GD](),this}[i1](){this[r]||(!this[P1]&&!this[z0].length&&(this[X0]=!0),this[DA]=!1,this[R0]=!0,this.emit("resume"),this[A0].length?this[l$]():this[BD]?this[GD]():this.emit("drain"))}resume(){return this[i1]()}pause(){this[R0]=!1,this[DA]=!0,this[X0]=!1}get destroyed(){return this[r]}get flowing(){return this[R0]}get paused(){return this[DA]}[OP](D){this[G0]?this[$0]+=1:this[$0]+=D.length,this[A0].push(D)}[k$](){return this[G0]?this[$0]-=1:this[$0]-=this[A0][0].length,this[A0].shift()}[l$](D=!1){do;while(this[pB](this[k$]())&&this[A0].length);!D&&!this[A0].length&&!this[BD]&&this.emit("drain")}[pB](D){return this.emit("data",D),this[R0]}pipe(D,R){if(this[r])return D;this[X0]=!1;let A=this[WD];return R=R||{},D===xB.stdout||D===xB.stderr?R.end=!1:R.end=R.end!==!1,R.proxyErrors=!!R.proxyErrors,A?R.end&&D.end():(this[z0].push(R.proxyErrors?new QF(this,D,R):new U5(this,D,R)),this[v0]?AA(()=>this[i1]()):this[i1]()),D}unpipe(D){let R=this[z0].find((A)=>A.dest===D);R&&(this[z0].length===1?(this[R0]&&this[P1]===0&&(this[R0]=!1),this[z0]=[]):this[z0].splice(this[z0].indexOf(R),1),R.unpipe())}addListener(D,R){return this.on(D,R)}on(D,R){let A=super.on(D,R);if(D==="data")this[X0]=!1,this[P1]++,!this[z0].length&&!this[R0]&&this[i1]();else if(D==="readable"&&this[$0]!==0)super.emit("readable");else if(ZF(D)&&this[WD])super.emit(D),this.removeAllListeners(D);else if(D==="error"&&this[eR]){let $=R;this[v0]?AA(()=>$.call(this,this[eR])):$.call(this,this[eR])}return A}removeListener(D,R){return this.off(D,R)}off(D,R){let A=super.off(D,R);return D==="data"&&(this[P1]=this.listeners("data").length,this[P1]===0&&!this[X0]&&!this[z0].length&&(this[R0]=!1)),A}removeAllListeners(D){let R=super.removeAllListeners(D);return(D==="data"||D===void 0)&&(this[P1]=0,!this[X0]&&!this[z0].length&&(this[R0]=!1)),R}get emittedEnd(){return this[WD]}[GD](){!this[h$]&&!this[WD]&&!this[r]&&this[A0].length===0&&this[BD]&&(this[h$]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[v$]&&this.emit("close"),this[h$]=!1)}emit(D,...R){let A=R[0];if(D!=="error"&&D!=="close"&&D!==r&&this[r])return!1;if(D==="data")return!this[G0]&&!A?!1:this[v0]?(AA(()=>this[_P](A)),!0):this[_P](A);if(D==="end")return this[hB]();if(D==="close"){if(this[v$]=!0,!this[WD]&&!this[r])return!1;let f=super.emit("close");return this.removeAllListeners("close"),f}else if(D==="error"){this[eR]=A,super.emit(YP,A);let f=!this[RA]||this.listeners("error").length?super.emit("error",A):!1;return this[GD](),f}else if(D==="resume"){let f=super.emit("resume");return this[GD](),f}else if(D==="finish"||D==="prefinish"){let f=super.emit(D);return this.removeAllListeners(D),f}let $=super.emit(D,...R);return this[GD](),$}[_P](D){for(let A of this[z0])A.dest.write(D)===!1&&this.pause();let R=this[X0]?!1:super.emit("data",D);return this[GD](),R}[hB](){return this[WD]?!1:(this[WD]=!0,this.readable=!1,this[v0]?(AA(()=>this[UP]()),!0):this[UP]())}[UP](){if(this[h1]){let R=this[h1].end();if(R){for(let A of this[z0])A.dest.write(R);this[X0]||super.emit("data",R)}}for(let R of this[z0])R.end();let D=super.emit("end");return this.removeAllListeners("end"),D}async collect(){let D=Object.assign([],{dataLength:0});this[G0]||(D.dataLength=0);let R=this.promise();return this.on("data",(A)=>{D.push(A),this[G0]||(D.dataLength+=A.length)}),await R,D}async concat(){if(this[G0])throw Error("cannot concat in objectMode");let D=await this.collect();return this[j0]?D.join(""):Buffer.concat(D,D.dataLength)}async promise(){return new Promise((D,R)=>{this.on(r,()=>R(Error("stream destroyed"))),this.on("error",(A)=>R(A)),this.on("end",()=>D())})}[Symbol.asyncIterator](){this[X0]=!1;let D=!1,R=async()=>(this.pause(),D=!0,{value:void 0,done:!0});return{next:()=>{if(D)return R();let A=this.read();if(A!==null)return Promise.resolve({done:!1,value:A});if(this[BD])return R();let $,f,P=(J)=>{this.off("data",B),this.off("end",G),this.off(r,z),R(),f(J)},B=(J)=>{this.off("error",P),this.off("end",G),this.off(r,z),this.pause(),$({value:J,done:!!this[BD]})},G=()=>{this.off("error",P),this.off("data",B),this.off(r,z),R(),$({done:!0,value:void 0})},z=()=>P(Error("stream destroyed"));return new Promise((J,Z)=>{f=Z,$=J,this.once(r,z),this.once("error",P),this.once("end",G),this.once("data",B)})},throw:R,return:R,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[X0]=!1;let D=!1,R=()=>(this.pause(),this.off(YP,R),this.off(r,R),this.off("end",R),D=!0,{done:!0,value:void 0}),A=()=>{if(D)return R();let $=this.read();return $===null?R():{done:!1,value:$}};return this.once("end",R),this.once(YP,R),this.once(r,R),{next:A,throw:R,return:R,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(D){if(this[r])return D?this.emit("error",D):this.emit(r),this;this[r]=!0,this[X0]=!0,this[A0].length=0,this[$0]=0;let R=this;return typeof R.close=="function"&&!this[v$]&&R.close(),D?this.emit("error",D):this.emit(r),this}static get isStream(){return GF}},YF=M0.writev,xD=Symbol("_autoClose"),E0=Symbol("_close"),$A=Symbol("_ended"),v=Symbol("_fd"),qP=Symbol("_finished"),ZD=Symbol("_flags"),wP=Symbol("_flush"),lP=Symbol("_handleChunk"),kP=Symbol("_makeBuf"),XA=Symbol("_mode"),i$=Symbol("_needDrain"),o1=Symbol("_onerror"),c1=Symbol("_onopen"),CP=Symbol("_onread"),a1=Symbol("_onwrite"),nD=Symbol("_open"),u0=Symbol("_path"),uD=Symbol("_pos"),l0=Symbol("_queue"),r1=Symbol("_read"),LP=Symbol("_readSize"),HD=Symbol("_reading"),fA=Symbol("_remain"),NP=Symbol("_size"),R2=Symbol("_write"),B1=Symbol("_writing"),A2=Symbol("_defaultFlag"),Q1=Symbol("_errored"),Z6=class extends _1{[Q1]=!1;[v];[u0];[LP];[HD]=!1;[NP];[fA];[xD];constructor(D,R){if(R=R||{},super(R),this.readable=!0,this.writable=!1,typeof D!="string")throw TypeError("path must be a string");this[Q1]=!1,this[v]=typeof R.fd=="number"?R.fd:void 0,this[u0]=D,this[LP]=R.readSize||16777216,this[HD]=!1,this[NP]=typeof R.size=="number"?R.size:1/0,this[fA]=this[NP],this[xD]=typeof R.autoClose=="boolean"?R.autoClose:!0,typeof this[v]=="number"?this[r1]():this[nD]()}get fd(){return this[v]}get path(){return this[u0]}write(){throw TypeError("this is a readable stream")}end(){throw TypeError("this is a readable stream")}[nD](){M0.open(this[u0],"r",(D,R)=>this[c1](D,R))}[c1](D,R){D?this[o1](D):(this[v]=R,this.emit("open",R),this[r1]())}[kP](){return Buffer.allocUnsafe(Math.min(this[LP],this[fA]))}[r1](){if(!this[HD]){this[HD]=!0;let D=this[kP]();if(D.length===0)return process.nextTick(()=>this[CP](null,0,D));M0.read(this[v],D,0,D.length,null,(R,A,$)=>this[CP](R,A,$))}}[CP](D,R,A){this[HD]=!1,D?this[o1](D):this[lP](R,A)&&this[r1]()}[E0](){if(this[xD]&&typeof this[v]=="number"){let D=this[v];this[v]=void 0,M0.close(D,(R)=>R?this.emit("error",R):this.emit("close"))}}[o1](D){this[HD]=!0,this[E0](),this.emit("error",D)}[lP](D,R){let A=!1;return this[fA]-=D,D>0&&(A=super.write(D<R.length?R.subarray(0,D):R)),(D===0||this[fA]<=0)&&(A=!1,this[E0](),super.end()),A}emit(D,...R){switch(D){case"prefinish":case"finish":return!1;case"drain":return typeof this[v]=="number"&&this[r1](),!1;case"error":return this[Q1]?!1:(this[Q1]=!0,super.emit(D,...R));default:return super.emit(D,...R)}}},_F=class extends Z6{[nD](){let D=!0;try{this[c1](null,M0.openSync(this[u0],"r")),D=!1}finally{D&&this[E0]()}}[r1](){let D=!0;try{if(!this[HD]){this[HD]=!0;do{let R=this[kP](),A=R.length===0?0:M0.readSync(this[v],R,0,R.length,null);if(!this[lP](A,R))break}while(!0);this[HD]=!1}D=!1}finally{D&&this[E0]()}}[E0](){if(this[xD]&&typeof this[v]=="number"){let D=this[v];this[v]=void 0,M0.closeSync(D),this.emit("close")}}},Y2=class extends PF{readable=!1;writable=!0;[Q1]=!1;[B1]=!1;[$A]=!1;[l0]=[];[i$]=!1;[u0];[XA];[xD];[v];[A2];[ZD];[qP]=!1;[uD];constructor(D,R){R=R||{},super(R),this[u0]=D,this[v]=typeof R.fd=="number"?R.fd:void 0,this[XA]=R.mode===void 0?438:R.mode,this[uD]=typeof R.start=="number"?R.start:void 0,this[xD]=typeof R.autoClose=="boolean"?R.autoClose:!0;let A=this[uD]!==void 0?"r+":"w";this[A2]=R.flags===void 0,this[ZD]=R.flags===void 0?A:R.flags,this[v]===void 0&&this[nD]()}emit(D,...R){if(D==="error"){if(this[Q1])return!1;this[Q1]=!0}return super.emit(D,...R)}get fd(){return this[v]}get path(){return this[u0]}[o1](D){this[E0](),this[B1]=!0,this.emit("error",D)}[nD](){M0.open(this[u0],this[ZD],this[XA],(D,R)=>this[c1](D,R))}[c1](D,R){this[A2]&&this[ZD]==="r+"&&D&&D.code==="ENOENT"?(this[ZD]="w",this[nD]()):D?this[o1](D):(this[v]=R,this.emit("open",R),this[B1]||this[wP]())}end(D,R){return D&&this.write(D,R),this[$A]=!0,!this[B1]&&!this[l0].length&&typeof this[v]=="number"&&this[a1](null,0),this}write(D,R){return typeof D=="string"&&(D=Buffer.from(D,R)),this[$A]?(this.emit("error",Error("write() after end()")),!1):this[v]===void 0||this[B1]||this[l0].length?(this[l0].push(D),this[i$]=!0,!1):(this[B1]=!0,this[R2](D),!0)}[R2](D){M0.write(this[v],D,0,D.length,this[uD],(R,A)=>this[a1](R,A))}[a1](D,R){D?this[o1](D):(this[uD]!==void 0&&typeof R=="number"&&(this[uD]+=R),this[l0].length?this[wP]():(this[B1]=!1,this[$A]&&!this[qP]?(this[qP]=!0,this[E0](),this.emit("finish")):this[i$]&&(this[i$]=!1,this.emit("drain"))))}[wP](){if(this[l0].length===0)this[$A]&&this[a1](null,0);else if(this[l0].length===1)this[R2](this[l0].pop());else{let D=this[l0];this[l0]=[],YF(this[v],D,this[uD],(R,A)=>this[a1](R,A))}}[E0](){if(this[xD]&&typeof this[v]=="number"){let D=this[v];this[v]=void 0,M0.close(D,(R)=>R?this.emit("error",R):this.emit("close"))}}},F5=class extends Y2{[nD](){let D;if(this[A2]&&this[ZD]==="r+")try{D=M0.openSync(this[u0],this[ZD],this[XA])}catch(R){if(R?.code==="ENOENT")return this[ZD]="w",this[nD]();throw R}else D=M0.openSync(this[u0],this[ZD],this[XA]);this[c1](null,D)}[E0](){if(this[xD]&&typeof this[v]=="number"){let D=this[v];this[v]=void 0,M0.closeSync(D),this.emit("close")}}[R2](D){let R=!0;try{this[a1](null,M0.writeSync(this[v],D,0,D.length,this[uD])),R=!1}finally{if(R)try{this[E0]()}catch{}}}},qF=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),wF=(D)=>!!D.sync&&!!D.file,CF=(D)=>!D.sync&&!!D.file,LF=(D)=>!!D.sync&&!D.file,NF=(D)=>!D.sync&&!D.file,VF=(D)=>!!D.file,IF=(D)=>{return qF.get(D)||D},M6=(D={})=>{if(!D)return{};let R={};for(let[A,$]of Object.entries(D)){let f=IF(A);R[f]=$}return R.chmod===void 0&&R.noChmod===!1&&(R.chmod=!0),delete R.noChmod,R},wA=(D,R,A,$,f)=>Object.assign((P=[],B,G)=>{Array.isArray(P)&&(B=P,P={}),typeof B=="function"&&(G=B,B=void 0),B=B?Array.from(B):[];let z=M6(P);if(f?.(z,B),wF(z)){if(typeof G=="function")throw TypeError("callback not supported for sync tar functions");return D(z,B)}else if(CF(z)){let J=R(z,B);return G?J.then(()=>G(),G):J}else if(LF(z)){if(typeof G=="function")throw TypeError("callback not supported for sync tar functions");return A(z,B)}else if(NF(z)){if(typeof G=="function")throw TypeError("callback only supported with file option");return $(z,B)}throw Error("impossible options??")},{syncFile:D,asyncFile:R,syncNoFile:A,asyncNoFile:$,validate:f}),jF=WF.constants||{ZLIB_VERNUM:4736},a0=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},jF)),SF=T1.concat,lB=Object.getOwnPropertyDescriptor(T1,"concat"),bF=(D)=>D,VP=lB?.writable===!0||lB?.set!==void 0?(D)=>{T1.concat=D?bF:SF}:(D)=>{},O1=Symbol("_superWrite"),a$=class extends Error{code;errno;constructor(D,R){super("zlib: "+D.message,{cause:D}),this.code=D.code,this.errno=D.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+D.message,Error.captureStackTrace(this,R??this.constructor)}get name(){return"ZlibError"}},IP=Symbol("flushFlag"),X6=class extends _1{#D=!1;#A=!1;#R;#B;#P;#$;#f;get sawError(){return this.#D}get handle(){return this.#$}get flushFlag(){return this.#R}constructor(D,R){if(!D||typeof D!="object")throw TypeError("invalid options for ZlibBase constructor");if(super(D),this.#R=D.flush??0,this.#B=D.finishFlush??0,this.#P=D.fullFlushFlag??0,typeof vB[R]!="function")throw TypeError("Compression method not supported: "+R);try{this.#$=new vB[R](D)}catch(A){throw new a$(A,this.constructor)}this.#f=(A)=>{this.#D||(this.#D=!0,this.close(),this.emit("error",A))},this.#$?.on("error",(A)=>this.#f(new a$(A))),this.once("end",()=>this.close)}close(){this.#$&&(this.#$.close(),this.#$=void 0,this.emit("close"))}reset(){if(!this.#D)return dP(this.#$,"zlib binding closed"),this.#$.reset?.()}flush(D){this.ended||(typeof D!="number"&&(D=this.#P),this.write(Object.assign(T1.alloc(0),{[IP]:D})))}end(D,R,A){return typeof D=="function"&&(A=D,R=void 0,D=void 0),typeof R=="function"&&(A=R,R=void 0),D&&(R?this.write(D,R):this.write(D)),this.flush(this.#B),this.#A=!0,super.end(A)}get ended(){return this.#A}[O1](D){return super.write(D)}write(D,R,A){if(typeof R=="function"&&(A=R,R="utf8"),typeof D=="string"&&(D=T1.from(D,R)),this.#D)return;dP(this.#$,"zlib binding closed");let $=this.#$._handle,f=$.close;$.close=()=>{};let P=this.#$.close;this.#$.close=()=>{},VP(!0);let B;try{let z=typeof D[IP]=="number"?D[IP]:this.#R;B=this.#$._processChunk(D,z),VP(!1)}catch(z){VP(!1),this.#f(new a$(z,this.write))}finally{this.#$&&(this.#$._handle=$,$.close=f,this.#$.close=P,this.#$.removeAllListeners("error"))}this.#$&&this.#$.on("error",(z)=>this.#f(new a$(z,this.write)));let G;if(B)if(Array.isArray(B)&&B.length>0){let z=B[0];G=this[O1](T1.from(z));for(let J=1;J<B.length;J++)G=this[O1](B[J])}else G=this[O1](T1.from(B));return A&&A(),G}},w5=class extends X6{#D;#A;constructor(D,R){D=D||{},D.flush=D.flush||a0.Z_NO_FLUSH,D.finishFlush=D.finishFlush||a0.Z_FINISH,D.fullFlushFlag=a0.Z_FULL_FLUSH,super(D,R),this.#D=D.level,this.#A=D.strategy}params(D,R){if(!this.sawError){if(!this.handle)throw Error("cannot switch params when binding is closed");if(!this.handle.params)throw Error("not supported in this implementation");if(this.#D!==D||this.#A!==R){this.flush(a0.Z_SYNC_FLUSH),dP(this.handle,"zlib binding closed");let A=this.handle.flush;this.handle.flush=($,f)=>{typeof $=="function"&&(f=$,$=this.flushFlag),this.flush($),f?.()};try{this.handle.params(D,R)}finally{this.handle.flush=A}this.handle&&(this.#D=D,this.#A=R)}}}},uF=class extends w5{#D;constructor(D){super(D,"Gzip"),this.#D=D&&!!D.portable}[O1](D){return this.#D?(this.#D=!1,D[9]=255,super[O1](D)):super[O1](D)}},EF=class extends w5{constructor(D){super(D,"Unzip")}},C5=class extends X6{constructor(D,R){D=D||{},D.flush=D.flush||a0.BROTLI_OPERATION_PROCESS,D.finishFlush=D.finishFlush||a0.BROTLI_OPERATION_FINISH,D.fullFlushFlag=a0.BROTLI_OPERATION_FLUSH,super(D,R)}},yF=class extends C5{constructor(D){super(D,"BrotliCompress")}},gF=class extends C5{constructor(D){super(D,"BrotliDecompress")}},L5=class extends X6{constructor(D,R){D=D||{},D.flush=D.flush||a0.ZSTD_e_continue,D.finishFlush=D.finishFlush||a0.ZSTD_e_end,D.fullFlushFlag=a0.ZSTD_e_flush,super(D,R)}},mF=class extends L5{constructor(D){super(D,"ZstdCompress")}},xF=class extends L5{constructor(D){super(D,"ZstdDecompress")}},nF=(D,R)=>{if(Number.isSafeInteger(D))D<0?hF(D,R):pF(D,R);else throw Error("cannot encode number outside of javascript safe integer range");return R},pF=(D,R)=>{R[0]=128;for(var A=R.length;A>1;A--)R[A-1]=D&255,D=Math.floor(D/256)},hF=(D,R)=>{R[0]=255;var A=!1;D=D*-1;for(var $=R.length;$>1;$--){var f=D&255;D=Math.floor(D/256),A?R[$-1]=N5(f):f===0?R[$-1]=0:(A=!0,R[$-1]=V5(f))}},vF=(D)=>{let R=D[0],A=R===128?kF(D.subarray(1,D.length)):R===255?lF(D):null;if(A===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(A))throw Error("parsed number outside of javascript safe integer range");return A},lF=(D)=>{for(var R=D.length,A=0,$=!1,f=R-1;f>-1;f--){var P=Number(D[f]),B;$?B=N5(P):P===0?B=P:($=!0,B=V5(P)),B!==0&&(A-=B*Math.pow(256,R-f-1))}return A},kF=(D)=>{for(var R=D.length,A=0,$=R-1;$>-1;$--){var f=Number(D[$]);f!==0&&(A+=f*Math.pow(256,R-$-1))}return A},N5=(D)=>(255^D)&255,V5=(D)=>(255^D)+1&255,dF={};fF(dF,{code:()=>Q6,isCode:()=>$2,isName:()=>iF,name:()=>_2});var $2=(D)=>_2.has(D),iF=(D)=>Q6.has(D),_2=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Q6=new Map(Array.from(_2).map((D)=>[D[1],D[0]])),Y1=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#D="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(D,R=0,A,$){Buffer.isBuffer(D)?this.decode(D,R||0,A,$):D&&this.#A(D)}decode(D,R,A,$){if(R||(R=0),!D||!(D.length>=R+512))throw Error("need 512 bytes for header");this.path=A?.path??G1(D,R,100),this.mode=A?.mode??$?.mode??ED(D,R+100,8),this.uid=A?.uid??$?.uid??ED(D,R+108,8),this.gid=A?.gid??$?.gid??ED(D,R+116,8),this.size=A?.size??$?.size??ED(D,R+124,12),this.mtime=A?.mtime??$?.mtime??KP(D,R+136,12),this.cksum=ED(D,R+148,12),$&&this.#A($,!0),A&&this.#A(A);let f=G1(D,R+156,1);if($2(f)&&(this.#D=f||"0"),this.#D==="0"&&this.path.slice(-1)==="/"&&(this.#D="5"),this.#D==="5"&&(this.size=0),this.linkpath=G1(D,R+157,100),D.subarray(R+257,R+265).toString()==="ustar\x0000")if(this.uname=A?.uname??$?.uname??G1(D,R+265,32),this.gname=A?.gname??$?.gname??G1(D,R+297,32),this.devmaj=A?.devmaj??$?.devmaj??ED(D,R+329,8)??0,this.devmin=A?.devmin??$?.devmin??ED(D,R+337,8)??0,D[R+475]!==0){let B=G1(D,R+345,155);this.path=B+"/"+this.path}else{let B=G1(D,R+345,130);B&&(this.path=B+"/"+this.path),this.atime=A?.atime??$?.atime??KP(D,R+476,12),this.ctime=A?.ctime??$?.ctime??KP(D,R+488,12)}let P=256;for(let B=R;B<R+148;B++)P+=D[B];for(let B=R+156;B<R+512;B++)P+=D[B];this.cksumValid=P===this.cksum,this.cksum===void 0&&P===256&&(this.nullBlock=!0)}#A(D,R=!1){Object.assign(this,Object.fromEntries(Object.entries(D).filter(([A,$])=>!($==null||A==="path"&&R||A==="linkpath"&&R||A==="global"))))}encode(D,R=0){if(D||(D=this.block=Buffer.alloc(512)),this.#D==="Unsupported"&&(this.#D="0"),!(D.length>=R+512))throw Error("need 512 bytes for header");let A=this.ctime||this.atime?130:155,$=aF(this.path||"",A),f=$[0],P=$[1];this.needPax=!!$[2],this.needPax=z1(D,R,100,f)||this.needPax,this.needPax=yD(D,R+100,8,this.mode)||this.needPax,this.needPax=yD(D,R+108,8,this.uid)||this.needPax,this.needPax=yD(D,R+116,8,this.gid)||this.needPax,this.needPax=yD(D,R+124,12,this.size)||this.needPax,this.needPax=WP(D,R+136,12,this.mtime)||this.needPax,D[R+156]=Number(this.#D.codePointAt(0)),this.needPax=z1(D,R+157,100,this.linkpath)||this.needPax,D.write("ustar\x0000",R+257,8),this.needPax=z1(D,R+265,32,this.uname)||this.needPax,this.needPax=z1(D,R+297,32,this.gname)||this.needPax,this.needPax=yD(D,R+329,8,this.devmaj)||this.needPax,this.needPax=yD(D,R+337,8,this.devmin)||this.needPax,this.needPax=z1(D,R+345,A,P)||this.needPax,D[R+475]!==0?this.needPax=z1(D,R+345,155,P)||this.needPax:(this.needPax=z1(D,R+345,130,P)||this.needPax,this.needPax=WP(D,R+476,12,this.atime)||this.needPax,this.needPax=WP(D,R+488,12,this.ctime)||this.needPax);let B=256;for(let G=R;G<R+148;G++)B+=D[G];for(let G=R+156;G<R+512;G++)B+=D[G];return this.cksum=B,yD(D,R+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#D==="Unsupported"?this.#D:_2.get(this.#D)}get typeKey(){return this.#D}set type(D){let R=String(Q6.get(D));if($2(R)||R==="Unsupported")this.#D=R;else if($2(D))this.#D=D;else throw TypeError("invalid entry type: "+D)}},aF=(D,R)=>{let A=D,$="",f,P=v1.parse(D).root||".";if(Buffer.byteLength(A)<100)f=[A,$,!1];else{$=v1.dirname(A),A=v1.basename(A);do Buffer.byteLength(A)<=100&&Buffer.byteLength($)<=R?f=[A,$,!1]:Buffer.byteLength(A)>100&&Buffer.byteLength($)<=R?f=[A.slice(0,99),$,!0]:(A=v1.join(v1.basename($),A),$=v1.dirname($));while($!==P&&f===void 0);f||(f=[D.slice(0,99),"",!0])}return f},G1=(D,R,A)=>D.subarray(R,R+A).toString("utf8").replace(/\0.*/,""),KP=(D,R,A)=>rF(ED(D,R,A)),rF=(D)=>D===void 0?void 0:new Date(D*1000),ED=(D,R,A)=>Number(D[R])&128?vF(D.subarray(R,R+A)):oF(D,R,A),sF=(D)=>isNaN(D)?void 0:D,oF=(D,R,A)=>sF(parseInt(D.subarray(R,R+A).toString("utf8").replace(/\0.*$/,"").trim(),8)),cF={12:8589934591,8:2097151},yD=(D,R,A,$)=>$===void 0?!1:$>cF[A]||$<0?(nF($,D.subarray(R,R+A)),!0):(tF(D,R,A,$),!1),tF=(D,R,A,$)=>D.write(eF($,A),R,A,"ascii"),eF=(D,R)=>Dq(Math.floor(D).toString(8),R),Dq=(D,R)=>(D.length===R-1?D:Array(R-D.length-1).join("0")+D+" ")+"\x00",WP=(D,R,A,$)=>$===void 0?!1:yD(D,R,A,$.getTime()/1000),Rq=Array(156).join("\x00"),z1=(D,R,A,$)=>$===void 0?!1:(D.write($+Rq,R,A,"utf8"),$.length!==Buffer.byteLength($)||$.length>A),M2=class D{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(R,A=!1){this.atime=R.atime,this.charset=R.charset,this.comment=R.comment,this.ctime=R.ctime,this.dev=R.dev,this.gid=R.gid,this.global=A,this.gname=R.gname,this.ino=R.ino,this.linkpath=R.linkpath,this.mtime=R.mtime,this.nlink=R.nlink,this.path=R.path,this.size=R.size,this.uid=R.uid,this.uname=R.uname}encode(){let R=this.encodeBody();if(R==="")return Buffer.allocUnsafe(0);let A=Buffer.byteLength(R),$=512*Math.ceil(1+A/512),f=Buffer.allocUnsafe($);for(let P=0;P<512;P++)f[P]=0;new Y1({path:("PaxHeader/"+Aq(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:A,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(f),f.write(R,512,A,"utf8");for(let P=A+512;P<f.length;P++)f[P]=0;return f}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(R){if(this[R]===void 0)return"";let A=this[R],$=A instanceof Date?A.getTime()/1000:A,f=" "+(R==="dev"||R==="ino"||R==="nlink"?"SCHILY.":"")+R+"="+$+`
183
+ `+R:""),z=Math.floor($.length/P)-this.cursorPos.rows+(R?X9(R):0);if(z>0)B+=a2(z);B+=s2(this.cursorPos.cols),this.write(r2(this.extraLinesUnderPrompt)+o2(this.height)+B),this.extraLinesUnderPrompt=z,this.height=X9(B)}checkCursorPos(){let D=this.rl.getCursorPos();if(D.cols!==this.cursorPos.cols)this.write(s2(D.cols)),this.cursorPos=D}done({clearContent:D}){this.rl.setPrompt("");let R=r2(this.extraLinesUnderPrompt);R+=D?o2(this.height):`
184
+ `,R+=M9,this.write(R),this.rl.close()}}class c2 extends Promise{static withResolver(){let D,R;return{promise:new Promise(($,f)=>{D=$,R=f}),resolve:D,reject:R}}}import kH from"node:path";var dH=globalThis.setImmediate;function iH(){let D=Error.prepareStackTrace,R=[];try{Error.prepareStackTrace=(A,$)=>{let f=$.slice(1);return R=f,f},Error().stack}catch{return R}return Error.prepareStackTrace=D,R}function $D(D){let R=iH();return($,f={})=>{let{input:P=process.stdin,signal:B}=f,G=new Set,z=new T9.default;z.pipe(f.output??process.stdout),z.mute();let J=Q9.createInterface({terminal:!0,input:P,output:z}),Z=new eA(J),{promise:H,resolve:M,reject:Q}=c2.withResolver(),O=()=>Q(new y2);if(B){let T=()=>Q(new E2({cause:B.reason}));if(B.aborted)return T(),Object.assign(H,{cancel:O});B.addEventListener("abort",T),G.add(()=>B.removeEventListener("abort",T))}G.add(H9((T,U)=>{Q(new rA(`User force closed the prompt with ${T} ${U}`))}));let X=()=>Q(new rA("User force closed the prompt with SIGINT"));return J.on("SIGINT",X),G.add(()=>J.removeListener("SIGINT",X)),u4(J,(T)=>{let U=lH.bind(()=>sD.clearAll());J.on("close",U),G.add(()=>J.removeListener("close",U));let F=()=>{let w=()=>Z.checkCursorPos();J.input.on("keypress",w),G.add(()=>J.input.removeListener("keypress",w));let V=null;T(()=>{let I=!1;try{let j=D($,(S)=>{if(I)M(S);else V={value:S}});if(j===void 0){let S=R[1]?.getFileName();if(S&&!S.startsWith("file://"))S=kH.resolve(S);throw Error(`Prompt functions must return a string.
185
+ at ${S}`)}let[u,L]=typeof j==="string"?[j]:j;Z.render(u,L),sD.run()}catch(j){Q(j)}if(I=!0,V!==null){let{value:j}=V;V=null,M(j)}})};if("readableFlowing"in P)dH(F);else F();return Object.assign(H.then((w)=>{return sD.clearAll(),w},(w)=>{throw sD.clearAll(),w}).finally(()=>{G.forEach((w)=>w()),Z.done({clearContent:Boolean(f.clearPromptOnDone)}),z.end()}).then(()=>H),{cancel:O})})}}import{styleText as aH}from"node:util";class m0{separator=aH("dim",Array.from({length:15}).join(K1.line));type="separator";constructor(D){if(D)this.separator=D}static isSeparator(D){return Boolean(D&&typeof D==="object"&&"type"in D&&D.type==="separator")}}function O9(D,R){let A=R!==!1;if(/^(y|yes)/i.test(D))A=!0;else if(/^(n|no)/i.test(D))A=!1;return A}function Y9(D){return D?"Yes":"No"}var t2=$D((D,R)=>{let{transformer:A=Y9}=D,[$,f]=i("idle"),[P,B]=i(""),G=I0(D.theme),z=DD({status:$,theme:G});RD((M,Q)=>{if($!=="idle")return;if(t0(M)){let O=O9(P,D.default);B(A(O)),f("done"),R(O)}else if(wR(M)){let O=Y9(!O9(P,D.default));Q.clearLine(0),Q.write(O),B(O)}else B(Q.line)});let J=P,Z="";if($==="done")J=G.style.answer(P);else Z=` ${G.style.defaultAnswer(D.default===!1?"y/N":"Y/n")}`;let H=G.style.message(D.message,$);return`${z} ${H}${Z} ${J}`});var rH={validationFailureMode:"keep"},VR=$D((D,R)=>{let{prefill:A="tab"}=D,$=I0(rH,D.theme),[f,P]=i("idle"),[B,G]=i(String(D.default??"")),[z,J]=i(),[Z,H]=i(""),M=DD({status:f,theme:$});async function Q(F){let{required:w,pattern:V,patternError:I="Invalid input"}=D;if(w&&!F)return"You must provide a value";if(V&&!V.test(F))return I;if(typeof D.validate==="function")return await D.validate(F)||"You must provide a valid value";return!0}RD(async(F,w)=>{if(f!=="idle")return;if(t0(F)){let V=Z||B;P("loading");let I=await Q(V);if(I===!0)H(V),P("done"),R(V);else{if($.validationFailureMode==="clear")H("");else w.write(Z);J(I),P("idle")}}else if(qR(F)&&!Z)G("");else if(wR(F)&&!Z)G(""),w.clearLine(0),w.write(B),H(B);else H(w.line),J(void 0)}),e0((F)=>{if(A==="editable"&&B)F.write(B),H(B)},[]);let O=$.style.message(D.message,f),X=Z;if(typeof D.transformer==="function")X=D.transformer(Z,{isFinal:f==="done"});else if(f==="done")X=$.style.answer(Z);let T;if(B&&f!=="done"&&!Z)T=$.style.defaultAnswer(B);let U="";if(z)U=$.style.error(z);return[[M,O,T,X].filter((F)=>F!==void 0).join(" "),U]});var sH={style:{maskedText:"[input is masked]"}},e2=$D((D,R)=>{let{validate:A=()=>!0}=D,$=I0(sH,D.theme),[f,P]=i("idle"),[B,G]=i(),[z,J]=i(""),Z=DD({status:f,theme:$});RD(async(X,T)=>{if(f!=="idle")return;if(t0(X)){let U=z;P("loading");let F=await A(U);if(F===!0)J(U),P("done"),R(U);else T.write(z),G(F||"You must provide a valid value"),P("idle")}else J(T.line),G(void 0)});let H=$.style.message(D.message,f),M="",Q;if(D.mask)M=(typeof D.mask==="string"?D.mask:"*").repeat(z.length);else if(f!=="done")Q=`${$.style.help($.style.maskedText)}${tA}`;if(f==="done")M=$.style.answer(M);let O="";if(B)O=$.style.error(B);return[[Z,H,D.mask?M:Q].join(" "),O]});import{styleText as IR}from"node:util";var oH={icon:{cursor:K1.pointer},style:{disabled:(D)=>IR("dim",D),description:(D)=>IR("cyan",D),keysHelpTip:(D)=>D.map(([R,A])=>`${IR("bold",R)} ${IR("dim",A)}`).join(IR("dim"," • "))},i18n:{disabledError:"This option is disabled and cannot be selected."},indexMode:"hidden",keybindings:[]};function D3(D){return!m0.isSeparator(D)&&!D.disabled}function R3(D){return!m0.isSeparator(D)}function cH(D){return D.map((R)=>{if(m0.isSeparator(R))return R;if(typeof R!=="object"||R===null||!("value"in R)){let f=String(R);return{value:R,name:f,short:f,disabled:!1}}let A=R.name??String(R.value),$={value:R.value,name:A,short:R.short??A,disabled:R.disabled??!1};if(R.description)$.description=R.description;return $})}var KR=$D((D,R)=>{let{loop:A=!0,pageSize:$=7}=D,f=I0(oH,D.theme),{keybindings:P}=f,[B,G]=i("idle"),z=DD({status:B,theme:f}),J=oD(),Z=!P.includes("vim"),H=LR(()=>cH(D.choices),[D.choices]),M=LR(()=>{let S=H.findIndex(R3),l=H.findLastIndex(R3);if(S===-1)throw new CR("[select prompt] No selectable choices. All choices are disabled.");return{first:S,last:l}},[H]),Q=LR(()=>{if(!("default"in D))return-1;return H.findIndex((S)=>D3(S)&&S.value===D.default)},[D.default,H]),[O,X]=i(Q===-1?M.first:Q),T=H[O];if(T==null||m0.isSeparator(T))throw Error("Active index does not point to a choice");let[U,F]=i();RD((S,l)=>{if(clearTimeout(J.current),U)F(void 0);if(t0(S))if(T.disabled)F(f.i18n.disabledError);else G("done"),R(T.value);else if(FR(S,P)||aA(S,P)){if(l.clearLine(0),A||FR(S,P)&&O!==M.first||aA(S,P)&&O!==M.last){let k=FR(S,P)?-1:1,g=O;do g=(g+k+H.length)%H.length;while(!R3(H[g]));X(g)}}else if(u2(S)&&!Number.isNaN(Number(l.line))){let k=Number(l.line)-1,g=-1,Y0=H.findIndex((MR)=>{if(m0.isSeparator(MR))return!1;return g++,g===k}),tf=H[Y0];if(tf!=null&&D3(tf))X(Y0);J.current=setTimeout(()=>{l.clearLine(0)},700)}else if(qR(S))l.clearLine(0);else if(Z){let k=l.line.toLowerCase(),g=H.findIndex((Y0)=>{if(m0.isSeparator(Y0)||!D3(Y0))return!1;return Y0.name.toLowerCase().startsWith(k)});if(g!==-1)X(g);J.current=setTimeout(()=>{l.clearLine(0)},700)}}),e0(()=>()=>{clearTimeout(J.current)},[]);let w=f.style.message(D.message,B),V=f.style.keysHelpTip([["↑↓","navigate"],["⏎","select"]]),I=0,j=v2({items:H,active:O,renderItem({item:S,isActive:l,index:k}){if(m0.isSeparator(S))return I++,` ${S.separator}`;let g=l?f.icon.cursor:" ",Y0=f.indexMode==="number"?`${k+1-I}. `:"";if(S.disabled){let MR=typeof S.disabled==="string"?S.disabled:"(disabled)",RJ=l?f.icon.cursor:"-";return f.style.disabled(`${RJ} ${Y0}${S.name} ${MR}`)}return(l?f.style.highlight:(MR)=>MR)(`${g} ${Y0}${S.name}`)},pageSize:$,loop:A});if(B==="done")return[z,w,f.style.answer(T.short)].filter(Boolean).join(" ");let{description:u}=T;return`${[[z,w].filter(Boolean).join(" "),j," ",u?f.style.description(u):"",U?f.style.error(U):"",V].filter(Boolean).join(`
186
+ `).trimEnd()}${tA}`});function _9(D){if(D==="table"||D==="json"||D==="yaml")return D;throw Error("Output must be one of: table, json, yaml.")}function U9(D){if(D.json)D.output="json";if(D.output??="table",D.json=D.output==="json",D.color===!1)process.env.NO_COLOR=process.env.NO_COLOR??"1"}function tH(D){if(D.output)return D.output;return D.json?"json":"table"}function C(D){return tH(D)==="json"}var XP=B0(KB(),1);import{mkdir as tU,readFile as eU,rm as FW,writeFile as DF}from"node:fs/promises";import RF from"node:os";import WB from"node:path";var AF={version:1,currentProjectByAuthId:{},auths:[]};function jB(){return WB.join(RF.homedir(),".abrun","config.yaml")}async function SB(){try{let D=await eU(jB(),"utf8"),R=XP.default.parse(D);return{version:1,currentProjectByAuthId:R?.currentProjectByAuthId??{},auths:R?.auths??[],currentAuthId:R?.currentAuthId}}catch(D){if(D.code==="ENOENT")return structuredClone(AF);throw D}}async function p0(D){let R=jB();await tU(WB.dirname(R),{recursive:!0}),await DF(R,XP.default.stringify(D),"utf8")}var b=_(async(D,R)=>{let A=await D.client.api.projectsList(),$=D.options.project&&A.find((P)=>_R(P,D.options.project))||(D.auth&&D.state.currentProjectByAuthId[D.auth.id]?A.find((P)=>_R(P,D.state.currentProjectByAuthId[D.auth.id])):void 0);if(!$&&A.length===1)$=A[0];if(!$&&A.length>1&&process.stdout.isTTY&&!C(D.options)){let P=await KR({message:"Select project",choices:A.map((B)=>({value:String(B.id),name:`${B.name} (${B.slug}, #${B.id})`}))});$=A.find((B)=>String(B.id)===P)}if(!$)D.abort("No project available for the selected auth.");let f=$;D.project=f,D.state.currentProjectByAuthId[D.auth.id]=String(f.id),await p0(D.state),await R()});var N=_(async(D,R)=>{U9(D.options),D.state=await SB(),D.endpoint=D.options.endpoint??b2(),await R()});var x=_(async(D,R)=>{let $=((await D.client.api.appsList()).items??[]).find((f)=>N4(f,D.args.app));if(!$)D.abort(`App not found: ${D.args.app}`);D.app=$,await R()});async function h0(D,R,A,$,f){if(A.length===0)throw Error("No available options.");if(!process.stdout.isTTY||C(D.options))D.abort($);if(A.length===1&&!f?.forcePromptSingle)return A[0].value;return KR({message:R,choices:A})}async function p1(D,R,A){if(!process.stdout.isTTY||C(D.options))D.abort(A);return t2({message:R,default:!1})}async function bB(D,R,A){if(!process.stdout.isTTY||C(D.options))D.abort(A);let $=await VR({message:R,validate:(f)=>{let P=Number(f);return Number.isInteger(P)&&P>=1&&P<=65535?!0:"Port must be an integer between 1 and 65535."}});return Number($)}async function uB(D,R){let A=await h0(D,"Select app plan",R.map(($)=>({value:$.name??"",name:`${$.name??""} (${$.cpuMilli??0}m CPU / ${$.memoryMb??0}Mi / ${$.diskGb??0}Gi)`})),"App plan is required. Use --plan or run in an interactive terminal.",{forcePromptSingle:!0});return dD(R,A)}async function EB(D,R){let A=await h0(D,"Select app bundle",R.map(($)=>({value:$.name??"",name:`${$.name??""} (${$.backupStorageGb??0}Gi backup, ${$.priceHourly??0}/hour)`})),"App bundle is required. Use --bundle or run in an interactive terminal.",{forcePromptSingle:!0});return iD(R,A)}async function QP(D,R){let A=await h0(D,"Select database plan",R.map(($)=>({value:$.name??"",name:`${$.name??""} (${$.cpuMilli??0}m CPU / ${$.memoryMb??0}Mi / ${$.diskGb??0}Gi)`})),"Database plan is required. Use --plan or run in an interactive terminal.");return UD(R,A)}async function TP(D,R){let A=await h0(D,"Select database bundle",R.map(($)=>({value:$.name??"",name:`${$.name??""} (${$.publicAccess?"public":"private"}, plugins: ${$.databasePlugins?"yes":"no"})`})),"Database bundle is required. Use --bundle or run in an interactive terminal.");return V1(R,A)}var yB=_(async(D,R)=>{let A=await D.client.api.appPlansList(),$=D.options.plan?.trim()||await h0(D,"Select app plan",A.map((J)=>({value:J.name??"",name:J.name??""})),"App plan is required. Use --plan or run in an interactive terminal.",{forcePromptSingle:!0}),f=dD(A,$),P=await D.client.api.appPlansBundlesList({planName:f.name}),B=D.options.bundle?.trim()||await h0(D,"Select app bundle",P.map((J)=>({value:J.name??"",name:J.name??""})),"App bundle is required. Use --bundle or run in an interactive terminal.",{forcePromptSingle:!0}),G=iD(P,B),z=D.options.port??await bB(D,"App runtime port","App port is required. Use --port or run in an interactive terminal.");D.plan=f,D.bundle=G,D.app=await D.client.api.appsCreate({name:D.args.name,plan:f.name,bundle:G.name,port:z,securityProfile:D.options.securityProfile}),await R()}),gB=_(async(D)=>{if(C(D.options)){W(D.app,!0);return}console.log(`Created app ${D.app.name} (${D.app.status})`)});var mB=_(async(D)=>{await D.client.api.appsDelete({appId:D.app.id}),console.log(`Removed app ${D.app.name}`)});import{rm as SG}from"node:fs/promises";import JC from"node:path";import{mkdtemp as Bw}from"node:fs/promises";import Gw from"node:os";import t5 from"node:path";import PF from"events";import M0 from"fs";import{EventEmitter as H6}from"node:events";import _5 from"node:stream";import{StringDecoder as BF}from"node:string_decoder";import q5 from"node:path";import s1 from"node:fs";import{dirname as UF,parse as FF}from"path";import{EventEmitter as KF}from"events";import dP from"assert";import{Buffer as T1}from"buffer";import*as vB from"zlib";import WF from"zlib";import{posix as v1}from"node:path";import{basename as Aq}from"node:path";import Xf from"fs";import d0 from"fs";import sB from"path";import{win32 as Xq}from"node:path";import A5 from"path";import g5 from"node:fs";import jq from"node:assert";import{randomBytes as m5}from"node:crypto";import n from"node:fs";import e from"node:path";import x5 from"fs";import Cf from"node:fs";import TA from"node:path";import T0 from"node:fs";import mq from"node:fs/promises";import Of from"node:path";import{join as s5}from"node:path";import Q0 from"node:fs";import c5 from"node:path";var $F=Object.defineProperty,fF=(D,R)=>{for(var A in R)$F(D,A,{get:R[A],enumerable:!0})},xB=typeof process=="object"&&process?process:{stdout:null,stderr:null},GF=(D)=>!!D&&typeof D=="object"&&(D instanceof _1||D instanceof _5||zF(D)||JF(D)),zF=(D)=>!!D&&typeof D=="object"&&D instanceof H6&&typeof D.pipe=="function"&&D.pipe!==_5.Writable.prototype.pipe,JF=(D)=>!!D&&typeof D=="object"&&D instanceof H6&&typeof D.write=="function"&&typeof D.end=="function",BD=Symbol("EOF"),GD=Symbol("maybeEmitEnd"),WD=Symbol("emittedEnd"),h$=Symbol("emittingEnd"),eR=Symbol("emittedError"),v$=Symbol("closed"),nB=Symbol("read"),l$=Symbol("flush"),pB=Symbol("flushChunk"),j0=Symbol("encoding"),h1=Symbol("decoder"),R0=Symbol("flowing"),DA=Symbol("paused"),i1=Symbol("resume"),A0=Symbol("buffer"),z0=Symbol("pipes"),$0=Symbol("bufferLength"),OP=Symbol("bufferPush"),k$=Symbol("bufferShift"),G0=Symbol("objectMode"),r=Symbol("destroyed"),YP=Symbol("error"),_P=Symbol("emitData"),hB=Symbol("emitEnd"),UP=Symbol("emitEnd2"),v0=Symbol("async"),FP=Symbol("abort"),d$=Symbol("aborted"),RA=Symbol("signal"),P1=Symbol("dataListeners"),X0=Symbol("discarded"),AA=(D)=>Promise.resolve().then(D),HF=(D)=>D(),ZF=(D)=>D==="end"||D==="finish"||D==="prefinish",MF=(D)=>D instanceof ArrayBuffer||!!D&&typeof D=="object"&&D.constructor&&D.constructor.name==="ArrayBuffer"&&D.byteLength>=0,XF=(D)=>!Buffer.isBuffer(D)&&ArrayBuffer.isView(D),U5=class{src;dest;opts;ondrain;constructor(D,R,A){this.src=D,this.dest=R,this.opts=A,this.ondrain=()=>D[i1](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(D){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},QF=class extends U5{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(D,R,A){super(D,R,A),this.proxyErrors=($)=>this.dest.emit("error",$),D.on("error",this.proxyErrors)}},TF=(D)=>!!D.objectMode,OF=(D)=>!D.objectMode&&!!D.encoding&&D.encoding!=="buffer",_1=class extends H6{[R0]=!1;[DA]=!1;[z0]=[];[A0]=[];[G0];[j0];[v0];[h1];[BD]=!1;[WD]=!1;[h$]=!1;[v$]=!1;[eR]=null;[$0]=0;[r]=!1;[RA];[d$]=!1;[P1]=0;[X0]=!1;writable=!0;readable=!0;constructor(...D){let R=D[0]||{};if(super(),R.objectMode&&typeof R.encoding=="string")throw TypeError("Encoding and objectMode may not be used together");TF(R)?(this[G0]=!0,this[j0]=null):OF(R)?(this[j0]=R.encoding,this[G0]=!1):(this[G0]=!1,this[j0]=null),this[v0]=!!R.async,this[h1]=this[j0]?new BF(this[j0]):null,R&&R.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[A0]}),R&&R.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[z0]});let{signal:A}=R;A&&(this[RA]=A,A.aborted?this[FP]():A.addEventListener("abort",()=>this[FP]()))}get bufferLength(){return this[$0]}get encoding(){return this[j0]}set encoding(D){throw Error("Encoding must be set at instantiation time")}setEncoding(D){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[G0]}set objectMode(D){throw Error("objectMode must be set at instantiation time")}get async(){return this[v0]}set async(D){this[v0]=this[v0]||!!D}[FP](){this[d$]=!0,this.emit("abort",this[RA]?.reason),this.destroy(this[RA]?.reason)}get aborted(){return this[d$]}set aborted(D){}write(D,R,A){if(this[d$])return!1;if(this[BD])throw Error("write after end");if(this[r])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof R=="function"&&(A=R,R="utf8"),R||(R="utf8");let $=this[v0]?AA:HF;if(!this[G0]&&!Buffer.isBuffer(D)){if(XF(D))D=Buffer.from(D.buffer,D.byteOffset,D.byteLength);else if(MF(D))D=Buffer.from(D);else if(typeof D!="string")throw Error("Non-contiguous data written to non-objectMode stream")}return this[G0]?(this[R0]&&this[$0]!==0&&this[l$](!0),this[R0]?this.emit("data",D):this[OP](D),this[$0]!==0&&this.emit("readable"),A&&$(A),this[R0]):D.length?(typeof D=="string"&&!(R===this[j0]&&!this[h1]?.lastNeed)&&(D=Buffer.from(D,R)),Buffer.isBuffer(D)&&this[j0]&&(D=this[h1].write(D)),this[R0]&&this[$0]!==0&&this[l$](!0),this[R0]?this.emit("data",D):this[OP](D),this[$0]!==0&&this.emit("readable"),A&&$(A),this[R0]):(this[$0]!==0&&this.emit("readable"),A&&$(A),this[R0])}read(D){if(this[r])return null;if(this[X0]=!1,this[$0]===0||D===0||D&&D>this[$0])return this[GD](),null;this[G0]&&(D=null),this[A0].length>1&&!this[G0]&&(this[A0]=[this[j0]?this[A0].join(""):Buffer.concat(this[A0],this[$0])]);let R=this[nB](D||null,this[A0][0]);return this[GD](),R}[nB](D,R){if(this[G0])this[k$]();else{let A=R;D===A.length||D===null?this[k$]():typeof A=="string"?(this[A0][0]=A.slice(D),R=A.slice(0,D),this[$0]-=D):(this[A0][0]=A.subarray(D),R=A.subarray(0,D),this[$0]-=D)}return this.emit("data",R),!this[A0].length&&!this[BD]&&this.emit("drain"),R}end(D,R,A){return typeof D=="function"&&(A=D,D=void 0),typeof R=="function"&&(A=R,R="utf8"),D!==void 0&&this.write(D,R),A&&this.once("end",A),this[BD]=!0,this.writable=!1,(this[R0]||!this[DA])&&this[GD](),this}[i1](){this[r]||(!this[P1]&&!this[z0].length&&(this[X0]=!0),this[DA]=!1,this[R0]=!0,this.emit("resume"),this[A0].length?this[l$]():this[BD]?this[GD]():this.emit("drain"))}resume(){return this[i1]()}pause(){this[R0]=!1,this[DA]=!0,this[X0]=!1}get destroyed(){return this[r]}get flowing(){return this[R0]}get paused(){return this[DA]}[OP](D){this[G0]?this[$0]+=1:this[$0]+=D.length,this[A0].push(D)}[k$](){return this[G0]?this[$0]-=1:this[$0]-=this[A0][0].length,this[A0].shift()}[l$](D=!1){do;while(this[pB](this[k$]())&&this[A0].length);!D&&!this[A0].length&&!this[BD]&&this.emit("drain")}[pB](D){return this.emit("data",D),this[R0]}pipe(D,R){if(this[r])return D;this[X0]=!1;let A=this[WD];return R=R||{},D===xB.stdout||D===xB.stderr?R.end=!1:R.end=R.end!==!1,R.proxyErrors=!!R.proxyErrors,A?R.end&&D.end():(this[z0].push(R.proxyErrors?new QF(this,D,R):new U5(this,D,R)),this[v0]?AA(()=>this[i1]()):this[i1]()),D}unpipe(D){let R=this[z0].find((A)=>A.dest===D);R&&(this[z0].length===1?(this[R0]&&this[P1]===0&&(this[R0]=!1),this[z0]=[]):this[z0].splice(this[z0].indexOf(R),1),R.unpipe())}addListener(D,R){return this.on(D,R)}on(D,R){let A=super.on(D,R);if(D==="data")this[X0]=!1,this[P1]++,!this[z0].length&&!this[R0]&&this[i1]();else if(D==="readable"&&this[$0]!==0)super.emit("readable");else if(ZF(D)&&this[WD])super.emit(D),this.removeAllListeners(D);else if(D==="error"&&this[eR]){let $=R;this[v0]?AA(()=>$.call(this,this[eR])):$.call(this,this[eR])}return A}removeListener(D,R){return this.off(D,R)}off(D,R){let A=super.off(D,R);return D==="data"&&(this[P1]=this.listeners("data").length,this[P1]===0&&!this[X0]&&!this[z0].length&&(this[R0]=!1)),A}removeAllListeners(D){let R=super.removeAllListeners(D);return(D==="data"||D===void 0)&&(this[P1]=0,!this[X0]&&!this[z0].length&&(this[R0]=!1)),R}get emittedEnd(){return this[WD]}[GD](){!this[h$]&&!this[WD]&&!this[r]&&this[A0].length===0&&this[BD]&&(this[h$]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[v$]&&this.emit("close"),this[h$]=!1)}emit(D,...R){let A=R[0];if(D!=="error"&&D!=="close"&&D!==r&&this[r])return!1;if(D==="data")return!this[G0]&&!A?!1:this[v0]?(AA(()=>this[_P](A)),!0):this[_P](A);if(D==="end")return this[hB]();if(D==="close"){if(this[v$]=!0,!this[WD]&&!this[r])return!1;let f=super.emit("close");return this.removeAllListeners("close"),f}else if(D==="error"){this[eR]=A,super.emit(YP,A);let f=!this[RA]||this.listeners("error").length?super.emit("error",A):!1;return this[GD](),f}else if(D==="resume"){let f=super.emit("resume");return this[GD](),f}else if(D==="finish"||D==="prefinish"){let f=super.emit(D);return this.removeAllListeners(D),f}let $=super.emit(D,...R);return this[GD](),$}[_P](D){for(let A of this[z0])A.dest.write(D)===!1&&this.pause();let R=this[X0]?!1:super.emit("data",D);return this[GD](),R}[hB](){return this[WD]?!1:(this[WD]=!0,this.readable=!1,this[v0]?(AA(()=>this[UP]()),!0):this[UP]())}[UP](){if(this[h1]){let R=this[h1].end();if(R){for(let A of this[z0])A.dest.write(R);this[X0]||super.emit("data",R)}}for(let R of this[z0])R.end();let D=super.emit("end");return this.removeAllListeners("end"),D}async collect(){let D=Object.assign([],{dataLength:0});this[G0]||(D.dataLength=0);let R=this.promise();return this.on("data",(A)=>{D.push(A),this[G0]||(D.dataLength+=A.length)}),await R,D}async concat(){if(this[G0])throw Error("cannot concat in objectMode");let D=await this.collect();return this[j0]?D.join(""):Buffer.concat(D,D.dataLength)}async promise(){return new Promise((D,R)=>{this.on(r,()=>R(Error("stream destroyed"))),this.on("error",(A)=>R(A)),this.on("end",()=>D())})}[Symbol.asyncIterator](){this[X0]=!1;let D=!1,R=async()=>(this.pause(),D=!0,{value:void 0,done:!0});return{next:()=>{if(D)return R();let A=this.read();if(A!==null)return Promise.resolve({done:!1,value:A});if(this[BD])return R();let $,f,P=(J)=>{this.off("data",B),this.off("end",G),this.off(r,z),R(),f(J)},B=(J)=>{this.off("error",P),this.off("end",G),this.off(r,z),this.pause(),$({value:J,done:!!this[BD]})},G=()=>{this.off("error",P),this.off("data",B),this.off(r,z),R(),$({done:!0,value:void 0})},z=()=>P(Error("stream destroyed"));return new Promise((J,Z)=>{f=Z,$=J,this.once(r,z),this.once("error",P),this.once("end",G),this.once("data",B)})},throw:R,return:R,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[X0]=!1;let D=!1,R=()=>(this.pause(),this.off(YP,R),this.off(r,R),this.off("end",R),D=!0,{done:!0,value:void 0}),A=()=>{if(D)return R();let $=this.read();return $===null?R():{done:!1,value:$}};return this.once("end",R),this.once(YP,R),this.once(r,R),{next:A,throw:R,return:R,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(D){if(this[r])return D?this.emit("error",D):this.emit(r),this;this[r]=!0,this[X0]=!0,this[A0].length=0,this[$0]=0;let R=this;return typeof R.close=="function"&&!this[v$]&&R.close(),D?this.emit("error",D):this.emit(r),this}static get isStream(){return GF}},YF=M0.writev,xD=Symbol("_autoClose"),E0=Symbol("_close"),$A=Symbol("_ended"),v=Symbol("_fd"),qP=Symbol("_finished"),ZD=Symbol("_flags"),wP=Symbol("_flush"),lP=Symbol("_handleChunk"),kP=Symbol("_makeBuf"),XA=Symbol("_mode"),i$=Symbol("_needDrain"),o1=Symbol("_onerror"),c1=Symbol("_onopen"),CP=Symbol("_onread"),a1=Symbol("_onwrite"),nD=Symbol("_open"),u0=Symbol("_path"),uD=Symbol("_pos"),l0=Symbol("_queue"),r1=Symbol("_read"),LP=Symbol("_readSize"),HD=Symbol("_reading"),fA=Symbol("_remain"),NP=Symbol("_size"),Rf=Symbol("_write"),B1=Symbol("_writing"),Af=Symbol("_defaultFlag"),Q1=Symbol("_errored"),Z6=class extends _1{[Q1]=!1;[v];[u0];[LP];[HD]=!1;[NP];[fA];[xD];constructor(D,R){if(R=R||{},super(R),this.readable=!0,this.writable=!1,typeof D!="string")throw TypeError("path must be a string");this[Q1]=!1,this[v]=typeof R.fd=="number"?R.fd:void 0,this[u0]=D,this[LP]=R.readSize||16777216,this[HD]=!1,this[NP]=typeof R.size=="number"?R.size:1/0,this[fA]=this[NP],this[xD]=typeof R.autoClose=="boolean"?R.autoClose:!0,typeof this[v]=="number"?this[r1]():this[nD]()}get fd(){return this[v]}get path(){return this[u0]}write(){throw TypeError("this is a readable stream")}end(){throw TypeError("this is a readable stream")}[nD](){M0.open(this[u0],"r",(D,R)=>this[c1](D,R))}[c1](D,R){D?this[o1](D):(this[v]=R,this.emit("open",R),this[r1]())}[kP](){return Buffer.allocUnsafe(Math.min(this[LP],this[fA]))}[r1](){if(!this[HD]){this[HD]=!0;let D=this[kP]();if(D.length===0)return process.nextTick(()=>this[CP](null,0,D));M0.read(this[v],D,0,D.length,null,(R,A,$)=>this[CP](R,A,$))}}[CP](D,R,A){this[HD]=!1,D?this[o1](D):this[lP](R,A)&&this[r1]()}[E0](){if(this[xD]&&typeof this[v]=="number"){let D=this[v];this[v]=void 0,M0.close(D,(R)=>R?this.emit("error",R):this.emit("close"))}}[o1](D){this[HD]=!0,this[E0](),this.emit("error",D)}[lP](D,R){let A=!1;return this[fA]-=D,D>0&&(A=super.write(D<R.length?R.subarray(0,D):R)),(D===0||this[fA]<=0)&&(A=!1,this[E0](),super.end()),A}emit(D,...R){switch(D){case"prefinish":case"finish":return!1;case"drain":return typeof this[v]=="number"&&this[r1](),!1;case"error":return this[Q1]?!1:(this[Q1]=!0,super.emit(D,...R));default:return super.emit(D,...R)}}},_F=class extends Z6{[nD](){let D=!0;try{this[c1](null,M0.openSync(this[u0],"r")),D=!1}finally{D&&this[E0]()}}[r1](){let D=!0;try{if(!this[HD]){this[HD]=!0;do{let R=this[kP](),A=R.length===0?0:M0.readSync(this[v],R,0,R.length,null);if(!this[lP](A,R))break}while(!0);this[HD]=!1}D=!1}finally{D&&this[E0]()}}[E0](){if(this[xD]&&typeof this[v]=="number"){let D=this[v];this[v]=void 0,M0.closeSync(D),this.emit("close")}}},Yf=class extends PF{readable=!1;writable=!0;[Q1]=!1;[B1]=!1;[$A]=!1;[l0]=[];[i$]=!1;[u0];[XA];[xD];[v];[Af];[ZD];[qP]=!1;[uD];constructor(D,R){R=R||{},super(R),this[u0]=D,this[v]=typeof R.fd=="number"?R.fd:void 0,this[XA]=R.mode===void 0?438:R.mode,this[uD]=typeof R.start=="number"?R.start:void 0,this[xD]=typeof R.autoClose=="boolean"?R.autoClose:!0;let A=this[uD]!==void 0?"r+":"w";this[Af]=R.flags===void 0,this[ZD]=R.flags===void 0?A:R.flags,this[v]===void 0&&this[nD]()}emit(D,...R){if(D==="error"){if(this[Q1])return!1;this[Q1]=!0}return super.emit(D,...R)}get fd(){return this[v]}get path(){return this[u0]}[o1](D){this[E0](),this[B1]=!0,this.emit("error",D)}[nD](){M0.open(this[u0],this[ZD],this[XA],(D,R)=>this[c1](D,R))}[c1](D,R){this[Af]&&this[ZD]==="r+"&&D&&D.code==="ENOENT"?(this[ZD]="w",this[nD]()):D?this[o1](D):(this[v]=R,this.emit("open",R),this[B1]||this[wP]())}end(D,R){return D&&this.write(D,R),this[$A]=!0,!this[B1]&&!this[l0].length&&typeof this[v]=="number"&&this[a1](null,0),this}write(D,R){return typeof D=="string"&&(D=Buffer.from(D,R)),this[$A]?(this.emit("error",Error("write() after end()")),!1):this[v]===void 0||this[B1]||this[l0].length?(this[l0].push(D),this[i$]=!0,!1):(this[B1]=!0,this[Rf](D),!0)}[Rf](D){M0.write(this[v],D,0,D.length,this[uD],(R,A)=>this[a1](R,A))}[a1](D,R){D?this[o1](D):(this[uD]!==void 0&&typeof R=="number"&&(this[uD]+=R),this[l0].length?this[wP]():(this[B1]=!1,this[$A]&&!this[qP]?(this[qP]=!0,this[E0](),this.emit("finish")):this[i$]&&(this[i$]=!1,this.emit("drain"))))}[wP](){if(this[l0].length===0)this[$A]&&this[a1](null,0);else if(this[l0].length===1)this[Rf](this[l0].pop());else{let D=this[l0];this[l0]=[],YF(this[v],D,this[uD],(R,A)=>this[a1](R,A))}}[E0](){if(this[xD]&&typeof this[v]=="number"){let D=this[v];this[v]=void 0,M0.close(D,(R)=>R?this.emit("error",R):this.emit("close"))}}},F5=class extends Yf{[nD](){let D;if(this[Af]&&this[ZD]==="r+")try{D=M0.openSync(this[u0],this[ZD],this[XA])}catch(R){if(R?.code==="ENOENT")return this[ZD]="w",this[nD]();throw R}else D=M0.openSync(this[u0],this[ZD],this[XA]);this[c1](null,D)}[E0](){if(this[xD]&&typeof this[v]=="number"){let D=this[v];this[v]=void 0,M0.closeSync(D),this.emit("close")}}[Rf](D){let R=!0;try{this[a1](null,M0.writeSync(this[v],D,0,D.length,this[uD])),R=!1}finally{if(R)try{this[E0]()}catch{}}}},qF=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),wF=(D)=>!!D.sync&&!!D.file,CF=(D)=>!D.sync&&!!D.file,LF=(D)=>!!D.sync&&!D.file,NF=(D)=>!D.sync&&!D.file,VF=(D)=>!!D.file,IF=(D)=>{return qF.get(D)||D},M6=(D={})=>{if(!D)return{};let R={};for(let[A,$]of Object.entries(D)){let f=IF(A);R[f]=$}return R.chmod===void 0&&R.noChmod===!1&&(R.chmod=!0),delete R.noChmod,R},wA=(D,R,A,$,f)=>Object.assign((P=[],B,G)=>{Array.isArray(P)&&(B=P,P={}),typeof B=="function"&&(G=B,B=void 0),B=B?Array.from(B):[];let z=M6(P);if(f?.(z,B),wF(z)){if(typeof G=="function")throw TypeError("callback not supported for sync tar functions");return D(z,B)}else if(CF(z)){let J=R(z,B);return G?J.then(()=>G(),G):J}else if(LF(z)){if(typeof G=="function")throw TypeError("callback not supported for sync tar functions");return A(z,B)}else if(NF(z)){if(typeof G=="function")throw TypeError("callback only supported with file option");return $(z,B)}throw Error("impossible options??")},{syncFile:D,asyncFile:R,syncNoFile:A,asyncNoFile:$,validate:f}),jF=WF.constants||{ZLIB_VERNUM:4736},a0=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},jF)),SF=T1.concat,lB=Object.getOwnPropertyDescriptor(T1,"concat"),bF=(D)=>D,VP=lB?.writable===!0||lB?.set!==void 0?(D)=>{T1.concat=D?bF:SF}:(D)=>{},O1=Symbol("_superWrite"),a$=class extends Error{code;errno;constructor(D,R){super("zlib: "+D.message,{cause:D}),this.code=D.code,this.errno=D.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+D.message,Error.captureStackTrace(this,R??this.constructor)}get name(){return"ZlibError"}},IP=Symbol("flushFlag"),X6=class extends _1{#D=!1;#A=!1;#R;#B;#P;#$;#f;get sawError(){return this.#D}get handle(){return this.#$}get flushFlag(){return this.#R}constructor(D,R){if(!D||typeof D!="object")throw TypeError("invalid options for ZlibBase constructor");if(super(D),this.#R=D.flush??0,this.#B=D.finishFlush??0,this.#P=D.fullFlushFlag??0,typeof vB[R]!="function")throw TypeError("Compression method not supported: "+R);try{this.#$=new vB[R](D)}catch(A){throw new a$(A,this.constructor)}this.#f=(A)=>{this.#D||(this.#D=!0,this.close(),this.emit("error",A))},this.#$?.on("error",(A)=>this.#f(new a$(A))),this.once("end",()=>this.close)}close(){this.#$&&(this.#$.close(),this.#$=void 0,this.emit("close"))}reset(){if(!this.#D)return dP(this.#$,"zlib binding closed"),this.#$.reset?.()}flush(D){this.ended||(typeof D!="number"&&(D=this.#P),this.write(Object.assign(T1.alloc(0),{[IP]:D})))}end(D,R,A){return typeof D=="function"&&(A=D,R=void 0,D=void 0),typeof R=="function"&&(A=R,R=void 0),D&&(R?this.write(D,R):this.write(D)),this.flush(this.#B),this.#A=!0,super.end(A)}get ended(){return this.#A}[O1](D){return super.write(D)}write(D,R,A){if(typeof R=="function"&&(A=R,R="utf8"),typeof D=="string"&&(D=T1.from(D,R)),this.#D)return;dP(this.#$,"zlib binding closed");let $=this.#$._handle,f=$.close;$.close=()=>{};let P=this.#$.close;this.#$.close=()=>{},VP(!0);let B;try{let z=typeof D[IP]=="number"?D[IP]:this.#R;B=this.#$._processChunk(D,z),VP(!1)}catch(z){VP(!1),this.#f(new a$(z,this.write))}finally{this.#$&&(this.#$._handle=$,$.close=f,this.#$.close=P,this.#$.removeAllListeners("error"))}this.#$&&this.#$.on("error",(z)=>this.#f(new a$(z,this.write)));let G;if(B)if(Array.isArray(B)&&B.length>0){let z=B[0];G=this[O1](T1.from(z));for(let J=1;J<B.length;J++)G=this[O1](B[J])}else G=this[O1](T1.from(B));return A&&A(),G}},w5=class extends X6{#D;#A;constructor(D,R){D=D||{},D.flush=D.flush||a0.Z_NO_FLUSH,D.finishFlush=D.finishFlush||a0.Z_FINISH,D.fullFlushFlag=a0.Z_FULL_FLUSH,super(D,R),this.#D=D.level,this.#A=D.strategy}params(D,R){if(!this.sawError){if(!this.handle)throw Error("cannot switch params when binding is closed");if(!this.handle.params)throw Error("not supported in this implementation");if(this.#D!==D||this.#A!==R){this.flush(a0.Z_SYNC_FLUSH),dP(this.handle,"zlib binding closed");let A=this.handle.flush;this.handle.flush=($,f)=>{typeof $=="function"&&(f=$,$=this.flushFlag),this.flush($),f?.()};try{this.handle.params(D,R)}finally{this.handle.flush=A}this.handle&&(this.#D=D,this.#A=R)}}}},uF=class extends w5{#D;constructor(D){super(D,"Gzip"),this.#D=D&&!!D.portable}[O1](D){return this.#D?(this.#D=!1,D[9]=255,super[O1](D)):super[O1](D)}},EF=class extends w5{constructor(D){super(D,"Unzip")}},C5=class extends X6{constructor(D,R){D=D||{},D.flush=D.flush||a0.BROTLI_OPERATION_PROCESS,D.finishFlush=D.finishFlush||a0.BROTLI_OPERATION_FINISH,D.fullFlushFlag=a0.BROTLI_OPERATION_FLUSH,super(D,R)}},yF=class extends C5{constructor(D){super(D,"BrotliCompress")}},gF=class extends C5{constructor(D){super(D,"BrotliDecompress")}},L5=class extends X6{constructor(D,R){D=D||{},D.flush=D.flush||a0.ZSTD_e_continue,D.finishFlush=D.finishFlush||a0.ZSTD_e_end,D.fullFlushFlag=a0.ZSTD_e_flush,super(D,R)}},mF=class extends L5{constructor(D){super(D,"ZstdCompress")}},xF=class extends L5{constructor(D){super(D,"ZstdDecompress")}},nF=(D,R)=>{if(Number.isSafeInteger(D))D<0?hF(D,R):pF(D,R);else throw Error("cannot encode number outside of javascript safe integer range");return R},pF=(D,R)=>{R[0]=128;for(var A=R.length;A>1;A--)R[A-1]=D&255,D=Math.floor(D/256)},hF=(D,R)=>{R[0]=255;var A=!1;D=D*-1;for(var $=R.length;$>1;$--){var f=D&255;D=Math.floor(D/256),A?R[$-1]=N5(f):f===0?R[$-1]=0:(A=!0,R[$-1]=V5(f))}},vF=(D)=>{let R=D[0],A=R===128?kF(D.subarray(1,D.length)):R===255?lF(D):null;if(A===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(A))throw Error("parsed number outside of javascript safe integer range");return A},lF=(D)=>{for(var R=D.length,A=0,$=!1,f=R-1;f>-1;f--){var P=Number(D[f]),B;$?B=N5(P):P===0?B=P:($=!0,B=V5(P)),B!==0&&(A-=B*Math.pow(256,R-f-1))}return A},kF=(D)=>{for(var R=D.length,A=0,$=R-1;$>-1;$--){var f=Number(D[$]);f!==0&&(A+=f*Math.pow(256,R-$-1))}return A},N5=(D)=>(255^D)&255,V5=(D)=>(255^D)+1&255,dF={};fF(dF,{code:()=>Q6,isCode:()=>$f,isName:()=>iF,name:()=>_f});var $f=(D)=>_f.has(D),iF=(D)=>Q6.has(D),_f=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Q6=new Map(Array.from(_f).map((D)=>[D[1],D[0]])),Y1=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#D="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(D,R=0,A,$){Buffer.isBuffer(D)?this.decode(D,R||0,A,$):D&&this.#A(D)}decode(D,R,A,$){if(R||(R=0),!D||!(D.length>=R+512))throw Error("need 512 bytes for header");this.path=A?.path??G1(D,R,100),this.mode=A?.mode??$?.mode??ED(D,R+100,8),this.uid=A?.uid??$?.uid??ED(D,R+108,8),this.gid=A?.gid??$?.gid??ED(D,R+116,8),this.size=A?.size??$?.size??ED(D,R+124,12),this.mtime=A?.mtime??$?.mtime??KP(D,R+136,12),this.cksum=ED(D,R+148,12),$&&this.#A($,!0),A&&this.#A(A);let f=G1(D,R+156,1);if($f(f)&&(this.#D=f||"0"),this.#D==="0"&&this.path.slice(-1)==="/"&&(this.#D="5"),this.#D==="5"&&(this.size=0),this.linkpath=G1(D,R+157,100),D.subarray(R+257,R+265).toString()==="ustar\x0000")if(this.uname=A?.uname??$?.uname??G1(D,R+265,32),this.gname=A?.gname??$?.gname??G1(D,R+297,32),this.devmaj=A?.devmaj??$?.devmaj??ED(D,R+329,8)??0,this.devmin=A?.devmin??$?.devmin??ED(D,R+337,8)??0,D[R+475]!==0){let B=G1(D,R+345,155);this.path=B+"/"+this.path}else{let B=G1(D,R+345,130);B&&(this.path=B+"/"+this.path),this.atime=A?.atime??$?.atime??KP(D,R+476,12),this.ctime=A?.ctime??$?.ctime??KP(D,R+488,12)}let P=256;for(let B=R;B<R+148;B++)P+=D[B];for(let B=R+156;B<R+512;B++)P+=D[B];this.cksumValid=P===this.cksum,this.cksum===void 0&&P===256&&(this.nullBlock=!0)}#A(D,R=!1){Object.assign(this,Object.fromEntries(Object.entries(D).filter(([A,$])=>!($==null||A==="path"&&R||A==="linkpath"&&R||A==="global"))))}encode(D,R=0){if(D||(D=this.block=Buffer.alloc(512)),this.#D==="Unsupported"&&(this.#D="0"),!(D.length>=R+512))throw Error("need 512 bytes for header");let A=this.ctime||this.atime?130:155,$=aF(this.path||"",A),f=$[0],P=$[1];this.needPax=!!$[2],this.needPax=z1(D,R,100,f)||this.needPax,this.needPax=yD(D,R+100,8,this.mode)||this.needPax,this.needPax=yD(D,R+108,8,this.uid)||this.needPax,this.needPax=yD(D,R+116,8,this.gid)||this.needPax,this.needPax=yD(D,R+124,12,this.size)||this.needPax,this.needPax=WP(D,R+136,12,this.mtime)||this.needPax,D[R+156]=Number(this.#D.codePointAt(0)),this.needPax=z1(D,R+157,100,this.linkpath)||this.needPax,D.write("ustar\x0000",R+257,8),this.needPax=z1(D,R+265,32,this.uname)||this.needPax,this.needPax=z1(D,R+297,32,this.gname)||this.needPax,this.needPax=yD(D,R+329,8,this.devmaj)||this.needPax,this.needPax=yD(D,R+337,8,this.devmin)||this.needPax,this.needPax=z1(D,R+345,A,P)||this.needPax,D[R+475]!==0?this.needPax=z1(D,R+345,155,P)||this.needPax:(this.needPax=z1(D,R+345,130,P)||this.needPax,this.needPax=WP(D,R+476,12,this.atime)||this.needPax,this.needPax=WP(D,R+488,12,this.ctime)||this.needPax);let B=256;for(let G=R;G<R+148;G++)B+=D[G];for(let G=R+156;G<R+512;G++)B+=D[G];return this.cksum=B,yD(D,R+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#D==="Unsupported"?this.#D:_f.get(this.#D)}get typeKey(){return this.#D}set type(D){let R=String(Q6.get(D));if($f(R)||R==="Unsupported")this.#D=R;else if($f(D))this.#D=D;else throw TypeError("invalid entry type: "+D)}},aF=(D,R)=>{let A=D,$="",f,P=v1.parse(D).root||".";if(Buffer.byteLength(A)<100)f=[A,$,!1];else{$=v1.dirname(A),A=v1.basename(A);do Buffer.byteLength(A)<=100&&Buffer.byteLength($)<=R?f=[A,$,!1]:Buffer.byteLength(A)>100&&Buffer.byteLength($)<=R?f=[A.slice(0,99),$,!0]:(A=v1.join(v1.basename($),A),$=v1.dirname($));while($!==P&&f===void 0);f||(f=[D.slice(0,99),"",!0])}return f},G1=(D,R,A)=>D.subarray(R,R+A).toString("utf8").replace(/\0.*/,""),KP=(D,R,A)=>rF(ED(D,R,A)),rF=(D)=>D===void 0?void 0:new Date(D*1000),ED=(D,R,A)=>Number(D[R])&128?vF(D.subarray(R,R+A)):oF(D,R,A),sF=(D)=>isNaN(D)?void 0:D,oF=(D,R,A)=>sF(parseInt(D.subarray(R,R+A).toString("utf8").replace(/\0.*$/,"").trim(),8)),cF={12:8589934591,8:2097151},yD=(D,R,A,$)=>$===void 0?!1:$>cF[A]||$<0?(nF($,D.subarray(R,R+A)),!0):(tF(D,R,A,$),!1),tF=(D,R,A,$)=>D.write(eF($,A),R,A,"ascii"),eF=(D,R)=>Dq(Math.floor(D).toString(8),R),Dq=(D,R)=>(D.length===R-1?D:Array(R-D.length-1).join("0")+D+" ")+"\x00",WP=(D,R,A,$)=>$===void 0?!1:yD(D,R,A,$.getTime()/1000),Rq=Array(156).join("\x00"),z1=(D,R,A,$)=>$===void 0?!1:(D.write($+Rq,R,A,"utf8"),$.length!==Buffer.byteLength($)||$.length>A),Mf=class D{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(R,A=!1){this.atime=R.atime,this.charset=R.charset,this.comment=R.comment,this.ctime=R.ctime,this.dev=R.dev,this.gid=R.gid,this.global=A,this.gname=R.gname,this.ino=R.ino,this.linkpath=R.linkpath,this.mtime=R.mtime,this.nlink=R.nlink,this.path=R.path,this.size=R.size,this.uid=R.uid,this.uname=R.uname}encode(){let R=this.encodeBody();if(R==="")return Buffer.allocUnsafe(0);let A=Buffer.byteLength(R),$=512*Math.ceil(1+A/512),f=Buffer.allocUnsafe($);for(let P=0;P<512;P++)f[P]=0;new Y1({path:("PaxHeader/"+Aq(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:A,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(f),f.write(R,512,A,"utf8");for(let P=A+512;P<f.length;P++)f[P]=0;return f}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(R){if(this[R]===void 0)return"";let A=this[R],$=A instanceof Date?A.getTime()/1000:A,f=" "+(R==="dev"||R==="ino"||R==="nlink"?"SCHILY.":"")+R+"="+$+`
187
187
  `,P=Buffer.byteLength(f),B=Math.floor(Math.log(P)/Math.log(10))+1;return P+B>=Math.pow(10,B)&&(B+=1),B+P+f}static parse(R,A,$=!1){return new D($q(fq(R),A),$)}},$q=(D,R)=>R?Object.assign({},R,D):D,fq=(D)=>D.replace(/\n$/,"").split(`
188
- `).reduce(Pq,Object.create(null)),Pq=(D,R)=>{let A=parseInt(R,10);if(A!==Buffer.byteLength(R)+1)return D;R=R.slice((A+" ").length);let $=R.split("="),f=$.shift();if(!f)return D;let P=f.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),B=$.join("=");return D[P]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(P)?new Date(Number(B)*1000):/^[0-9]+$/.test(B)?+B:B,D},Bq=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,y=Bq!=="win32"?(D)=>D:(D)=>D&&D.replaceAll(/\\/g,"/"),I5=class extends _1{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(D,R,A){switch(super({}),this.pause(),this.extended=R,this.globalExtended=A,this.header=D,this.remain=D.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=D.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!D.path)throw Error("no path provided for tar.ReadEntry");this.path=y(D.path),this.mode=D.mode,this.mode&&(this.mode=this.mode&4095),this.uid=D.uid,this.gid=D.gid,this.uname=D.uname,this.gname=D.gname,this.size=this.remain,this.mtime=D.mtime,this.atime=D.atime,this.ctime=D.ctime,this.linkpath=D.linkpath?y(D.linkpath):void 0,this.uname=D.uname,this.gname=D.gname,R&&this.#D(R),A&&this.#D(A,!0)}write(D){let R=D.length;if(R>this.blockRemain)throw Error("writing more to entry than is appropriate");let A=this.remain,$=this.blockRemain;return this.remain=Math.max(0,A-R),this.blockRemain=Math.max(0,$-R),this.ignore?!0:A>=R?super.write(D):super.write(D.subarray(0,A))}#D(D,R=!1){D.path&&(D.path=y(D.path)),D.linkpath&&(D.linkpath=y(D.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(D).filter(([A,$])=>!($==null||A==="path"&&R))))}},U2=(D,R,A,$={})=>{D.file&&($.file=D.file),D.cwd&&($.cwd=D.cwd),$.code=A instanceof Error&&A.code||R,$.tarCode=R,!D.strict&&$.recoverable!==!1?(A instanceof Error&&($=Object.assign(A,$),A=A.message),D.emit("warn",R,A,$)):A instanceof Error?D.emit("error",Object.assign(A,$)):D.emit("error",Object.assign(Error(`${R}: ${A}`),$))},Gq=1048576,iP=Buffer.from([31,139]),aP=Buffer.from([40,181,47,253]),zq=Math.max(iP.length,aP.length),q0=Symbol("state"),J1=Symbol("writeEntry"),zD=Symbol("readEntry"),jP=Symbol("nextEntry"),kB=Symbol("processEntry"),k0=Symbol("extendedHeader"),PA=Symbol("globalExtendedHeader"),jD=Symbol("meta"),dB=Symbol("emitMeta"),d=Symbol("buffer"),JD=Symbol("queue"),SD=Symbol("ended"),SP=Symbol("emittedEnd"),H1=Symbol("emit"),c=Symbol("unzip"),r$=Symbol("consumeChunk"),s$=Symbol("consumeChunkSub"),bP=Symbol("consumeBody"),iB=Symbol("consumeMeta"),aB=Symbol("consumeHeader"),BA=Symbol("consuming"),uP=Symbol("bufferConcat"),o$=Symbol("maybeEnd"),l1=Symbol("writing"),bD=Symbol("aborted"),c$=Symbol("onDone"),Z1=Symbol("sawValidEntry"),t$=Symbol("sawNullBlock"),e$=Symbol("sawEOF"),rB=Symbol("closeStream"),Jq=()=>!0,qA=class extends KF{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[JD]=[];[d];[zD];[J1];[q0]="begin";[jD]="";[k0];[PA];[SD]=!1;[c];[bD]=!1;[Z1];[t$]=!1;[e$]=!1;[l1]=!1;[BA]=!1;[SP]=!1;constructor(D={}){super(),this.file=D.file||"",this.on(c$,()=>{(this[q0]==="begin"||this[Z1]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),D.ondone?this.on(c$,D.ondone):this.on(c$,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!D.strict,this.maxMetaEntrySize=D.maxMetaEntrySize||Gq,this.filter=typeof D.filter=="function"?D.filter:Jq;let R=D.file&&(D.file.endsWith(".tar.br")||D.file.endsWith(".tbr"));this.brotli=!(D.gzip||D.zstd)&&D.brotli!==void 0?D.brotli:R?void 0:!1;let A=D.file&&(D.file.endsWith(".tar.zst")||D.file.endsWith(".tzst"));this.zstd=!(D.gzip||D.brotli)&&D.zstd!==void 0?D.zstd:A?!0:void 0,this.on("end",()=>this[rB]()),typeof D.onwarn=="function"&&this.on("warn",D.onwarn),typeof D.onReadEntry=="function"&&this.on("entry",D.onReadEntry)}warn(D,R,A={}){U2(this,D,R,A)}[aB](D,R){this[Z1]===void 0&&(this[Z1]=!1);let A;try{A=new Y1(D,R,this[k0],this[PA])}catch($){return this.warn("TAR_ENTRY_INVALID",$)}if(A.nullBlock)this[t$]?(this[e$]=!0,this[q0]==="begin"&&(this[q0]="header"),this[H1]("eof")):(this[t$]=!0,this[H1]("nullBlock"));else if(this[t$]=!1,!A.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:A});else if(!A.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:A});else{let $=A.type;if(/^(Symbolic)?Link$/.test($)&&!A.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:A});else if(!/^(Symbolic)?Link$/.test($)&&!/^(Global)?ExtendedHeader$/.test($)&&A.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:A});else{let f=this[J1]=new I5(A,this[k0],this[PA]);if(!this[Z1])if(f.remain){let P=()=>{f.invalid||(this[Z1]=!0)};f.on("end",P)}else this[Z1]=!0;f.meta?f.size>this.maxMetaEntrySize?(f.ignore=!0,this[H1]("ignoredEntry",f),this[q0]="ignore",f.resume()):f.size>0&&(this[jD]="",f.on("data",(P)=>this[jD]+=P),this[q0]="meta"):(this[k0]=void 0,f.ignore=f.ignore||!this.filter(f.path,f),f.ignore?(this[H1]("ignoredEntry",f),this[q0]=f.remain?"ignore":"header",f.resume()):(f.remain?this[q0]="body":(this[q0]="header",f.end()),this[zD]?this[JD].push(f):(this[JD].push(f),this[jP]())))}}}[rB](){queueMicrotask(()=>this.emit("close"))}[kB](D){let R=!0;if(!D)this[zD]=void 0,R=!1;else if(Array.isArray(D)){let[A,...$]=D;this.emit(A,...$)}else this[zD]=D,this.emit("entry",D),D.emittedEnd||(D.on("end",()=>this[jP]()),R=!1);return R}[jP](){do;while(this[kB](this[JD].shift()));if(this[JD].length===0){let D=this[zD];!D||D.flowing||D.size===D.remain?this[l1]||this.emit("drain"):D.once("drain",()=>this.emit("drain"))}}[bP](D,R){let A=this[J1];if(!A)throw Error("attempt to consume body without entry??");let $=A.blockRemain??0,f=$>=D.length&&R===0?D:D.subarray(R,R+$);return A.write(f),A.blockRemain||(this[q0]="header",this[J1]=void 0,A.end()),f.length}[iB](D,R){let A=this[J1],$=this[bP](D,R);return!this[J1]&&A&&this[dB](A),$}[H1](D,R,A){this[JD].length===0&&!this[zD]?this.emit(D,R,A):this[JD].push([D,R,A])}[dB](D){switch(this[H1]("meta",this[jD]),D.type){case"ExtendedHeader":case"OldExtendedHeader":this[k0]=M2.parse(this[jD],this[k0],!1);break;case"GlobalExtendedHeader":this[PA]=M2.parse(this[jD],this[PA],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let R=this[k0]??Object.create(null);this[k0]=R,R.path=this[jD].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let R=this[k0]||Object.create(null);this[k0]=R,R.linkpath=this[jD].replace(/\0.*/,"");break}default:throw Error("unknown meta: "+D.type)}}abort(D){this[bD]=!0,this.emit("abort",D),this.warn("TAR_ABORT",D,{recoverable:!1})}write(D,R,A){if(typeof R=="function"&&(A=R,R=void 0),typeof D=="string"&&(D=Buffer.from(D,typeof R=="string"?R:"utf8")),this[bD])return A?.(),!1;if((this[c]===void 0||this.brotli===void 0&&this[c]===!1)&&D){if(this[d]&&(D=Buffer.concat([this[d],D]),this[d]=void 0),D.length<zq)return this[d]=D,A?.(),!0;for(let B=0;this[c]===void 0&&B<iP.length;B++)D[B]!==iP[B]&&(this[c]=!1);let f=!1;if(this[c]===!1&&this.zstd!==!1){f=!0;for(let B=0;B<aP.length;B++)if(D[B]!==aP[B]){f=!1;break}}let P=this.brotli===void 0&&!f;if(this[c]===!1&&P)if(D.length<512)if(this[SD])this.brotli=!0;else return this[d]=D,A?.(),!0;else try{new Y1(D.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[c]===void 0||this[c]===!1&&(this.brotli||f)){let B=this[SD];this[SD]=!1,this[c]=this[c]===void 0?new EF({}):f?new xF({}):new gF({}),this[c].on("data",(z)=>this[r$](z)),this[c].on("error",(z)=>this.abort(z)),this[c].on("end",()=>{this[SD]=!0,this[r$]()}),this[l1]=!0;let G=!!this[c][B?"end":"write"](D);return this[l1]=!1,A?.(),G}}this[l1]=!0,this[c]?this[c].write(D):this[r$](D),this[l1]=!1;let $=this[JD].length>0?!1:this[zD]?this[zD].flowing:!0;return!$&&this[JD].length===0&&this[zD]?.once("drain",()=>this.emit("drain")),A?.(),$}[uP](D){D&&!this[bD]&&(this[d]=this[d]?Buffer.concat([this[d],D]):D)}[o$](){if(this[SD]&&!this[SP]&&!this[bD]&&!this[BA]){this[SP]=!0;let D=this[J1];if(D&&D.blockRemain){let R=this[d]?this[d].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${D.blockRemain} more bytes, only ${R} available)`,{entry:D}),this[d]&&D.write(this[d]),D.end()}this[H1](c$)}}[r$](D){if(this[BA]&&D)this[uP](D);else if(!D&&!this[d])this[o$]();else if(D){if(this[BA]=!0,this[d]){this[uP](D);let R=this[d];this[d]=void 0,this[s$](R)}else this[s$](D);for(;this[d]&&this[d]?.length>=512&&!this[bD]&&!this[e$];){let R=this[d];this[d]=void 0,this[s$](R)}this[BA]=!1}(!this[d]||this[SD])&&this[o$]()}[s$](D){let R=0,A=D.length;for(;R+512<=A&&!this[bD]&&!this[e$];)switch(this[q0]){case"begin":case"header":this[aB](D,R),R+=512;break;case"ignore":case"body":R+=this[bP](D,R);break;case"meta":R+=this[iB](D,R);break;default:throw Error("invalid state: "+this[q0])}R<A&&(this[d]=this[d]?Buffer.concat([D.subarray(R),this[d]]):D.subarray(R))}end(D,R,A){return typeof D=="function"&&(A=D,R=void 0,D=void 0),typeof R=="function"&&(A=R,R=void 0),typeof D=="string"&&(D=Buffer.from(D,R)),A&&this.once("finish",A),this[bD]||(this[c]?(D&&this[c].write(D),this[c].end()):(this[SD]=!0,(this.brotli===void 0||this.zstd===void 0)&&(D=D||Buffer.alloc(0)),D&&this.write(D),this[o$]())),this}},QA=(D)=>{let R=D.length-1,A=-1;for(;R>-1&&D.charAt(R)==="/";)A=R,R--;return A===-1?D:D.slice(0,A)},Hq=(D)=>{let R=D.onReadEntry;D.onReadEntry=R?(A)=>{R(A),A.resume()}:(A)=>A.resume()},K5=(D,R)=>{let A=new Map(R.map((P)=>[QA(P),!0])),$=D.filter,f=(P,B="")=>{let G=B||FF(P).root||".",z;if(P===G)z=!1;else{let J=A.get(P);z=J!==void 0?J:f(UF(P),G)}return A.set(P,z),z};D.filter=$?(P,B)=>$(P,B)&&f(QA(P)):(P)=>f(QA(P))},Zq=(D)=>{let R=new qA(D),A=D.file,$;try{$=s1.openSync(A,"r");let f=s1.fstatSync($),P=D.maxReadSize||16777216;if(f.size<P){let B=Buffer.allocUnsafe(f.size),G=s1.readSync($,B,0,f.size,0);R.end(G===B.byteLength?B:B.subarray(0,G))}else{let B=0,G=Buffer.allocUnsafe(P);for(;B<f.size;){let z=s1.readSync($,G,0,P,B);if(z===0)break;B+=z,R.write(G.subarray(0,z))}R.end()}}finally{if(typeof $=="number")try{s1.closeSync($)}catch{}}},Mq=(D,R)=>{let A=new qA(D),$=D.maxReadSize||16777216,f=D.file;return new Promise((P,B)=>{A.on("error",B),A.on("end",P),s1.stat(f,(G,z)=>{if(G)B(G);else{let J=new Z6(f,{readSize:$,size:z.size});J.on("error",B),J.pipe(A)}})})},F2=wA(Zq,Mq,(D)=>new qA(D),(D)=>new qA(D),(D,R)=>{R?.length&&K5(D,R),D.noResume||Hq(D)}),W5=(D,R,A)=>(D&=4095,A&&(D=(D|384)&-19),R&&(D&256&&(D|=64),D&32&&(D|=8),D&4&&(D|=1)),D),{isAbsolute:Qq,parse:oB}=Xq,T6=(D)=>{let R="",A=oB(D);for(;Qq(D)||A.root;){let $=D.charAt(0)==="/"&&D.slice(0,4)!=="//?/"?"/":A.root;D=D.slice($.length),R+=$,A=oB(D)}return[R,D]},q2=["|","<",">","?",":"],O6=q2.map((D)=>String.fromCodePoint(61440+Number(D.codePointAt(0)))),Tq=new Map(q2.map((D,R)=>[D,O6[R]])),Oq=new Map(O6.map((D,R)=>[D,q2[R]])),cB=(D)=>q2.reduce((R,A)=>R.split(A).join(Tq.get(A)),D),Yq=(D)=>O6.reduce((R,A)=>R.split(A).join(Oq.get(A)),D),j5=(D,R)=>R?(D=y(D).replace(/^\.(\/|$)/,""),QA(R)+"/"+D):y(D),_q=16777216,tB=Symbol("process"),eB=Symbol("file"),D5=Symbol("directory"),rP=Symbol("symlink"),R5=Symbol("hardlink"),GA=Symbol("header"),f2=Symbol("read"),sP=Symbol("lstat"),P2=Symbol("onlstat"),oP=Symbol("onread"),cP=Symbol("onreadlink"),tP=Symbol("openfile"),eP=Symbol("onopenfile"),gD=Symbol("close"),Q2=Symbol("mode"),D6=Symbol("awaitDrain"),EP=Symbol("ondrain"),i0=Symbol("prefix"),S5=class extends _1{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#D=!1;constructor(D,R={}){let A=M6(R);super(),this.path=y(D),this.portable=!!A.portable,this.maxReadSize=A.maxReadSize||_q,this.linkCache=A.linkCache||new Map,this.statCache=A.statCache||new Map,this.preservePaths=!!A.preservePaths,this.cwd=y(A.cwd||process.cwd()),this.strict=!!A.strict,this.noPax=!!A.noPax,this.noMtime=!!A.noMtime,this.mtime=A.mtime,this.prefix=A.prefix?y(A.prefix):void 0,this.onWriteEntry=A.onWriteEntry,typeof A.onwarn=="function"&&this.on("warn",A.onwarn);let $=!1;if(!this.preservePaths){let[P,B]=T6(this.path);P&&typeof B=="string"&&(this.path=B,$=P)}this.win32=!!A.win32||process.platform==="win32",this.win32&&(this.path=Yq(this.path.replaceAll(/\\/g,"/")),D=D.replaceAll(/\\/g,"/")),this.absolute=y(A.absolute||sB.resolve(this.cwd,D)),this.path===""&&(this.path="./"),$&&this.warn("TAR_ENTRY_INFO",`stripping ${$} from absolute path`,{entry:this,path:$+this.path});let f=this.statCache.get(this.absolute);f?this[P2](f):this[sP]()}warn(D,R,A={}){return U2(this,D,R,A)}emit(D,...R){return D==="error"&&(this.#D=!0),super.emit(D,...R)}[sP](){d0.lstat(this.absolute,(D,R)=>{if(D)return this.emit("error",D);this[P2](R)})}[P2](D){this.statCache.set(this.absolute,D),this.stat=D,D.isFile()||(D.size=0),this.type=qq(D),this.emit("stat",D),this[tB]()}[tB](){switch(this.type){case"File":return this[eB]();case"Directory":return this[D5]();case"SymbolicLink":return this[rP]();default:return this.end()}}[Q2](D){return W5(D,this.type==="Directory",this.portable)}[i0](D){return j5(D,this.prefix)}[GA](){if(!this.stat)throw Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Y1({path:this[i0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[i0](this.linkpath):this.linkpath,mode:this[Q2](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new M2({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[i0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[i0](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let D=this.header?.block;if(!D)throw Error("failed to encode header");super.write(D)}[D5](){if(!this.stat)throw Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[GA](),this.end()}[rP](){d0.readlink(this.absolute,(D,R)=>{if(D)return this.emit("error",D);this[cP](R)})}[cP](D){this.linkpath=y(D),this[GA](),this.end()}[R5](D){if(!this.stat)throw Error("cannot create link entry without stat");this.type="Link",this.linkpath=y(sB.relative(this.cwd,D)),this.stat.size=0,this[GA](),this.end()}[eB](){if(!this.stat)throw Error("cannot create file entry without stat");if(this.stat.nlink>1){let D=`${this.stat.dev}:${this.stat.ino}`,R=this.linkCache.get(D);if(R?.indexOf(this.cwd)===0)return this[R5](R);this.linkCache.set(D,this.absolute)}if(this[GA](),this.stat.size===0)return this.end();this[tP]()}[tP](){d0.open(this.absolute,"r",(D,R)=>{if(D)return this.emit("error",D);this[eP](R)})}[eP](D){if(this.fd=D,this.#D)return this[gD]();if(!this.stat)throw Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let R=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(R),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[f2]()}[f2](){let{fd:D,buf:R,offset:A,length:$,pos:f}=this;if(D===void 0||R===void 0)throw Error("cannot read file without first opening");d0.read(D,R,A,$,f,(P,B)=>{if(P)return this[gD](()=>this.emit("error",P));this[oP](B)})}[gD](D=()=>{}){this.fd!==void 0&&d0.close(this.fd,D)}[oP](D){if(D<=0&&this.remain>0){let A=Object.assign(Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[gD](()=>this.emit("error",A))}if(D>this.remain){let A=Object.assign(Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[gD](()=>this.emit("error",A))}if(!this.buf)throw Error("should have created buffer prior to reading");if(D===this.remain)for(let A=D;A<this.length&&D<this.blockRemain;A++)this.buf[A+this.offset]=0,D++,this.remain++;let R=this.offset===0&&D===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+D);this.write(R)?this[EP]():this[D6](()=>this[EP]())}[D6](D){this.once("drain",D)}write(D,R,A){if(typeof R=="function"&&(A=R,R=void 0),typeof D=="string"&&(D=Buffer.from(D,typeof R=="string"?R:"utf8")),this.blockRemain<D.length){let $=Object.assign(Error("writing more data than expected"),{path:this.absolute});return this.emit("error",$)}return this.remain-=D.length,this.blockRemain-=D.length,this.pos+=D.length,this.offset+=D.length,super.write(D,null,A)}[EP](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[gD]((D)=>D?this.emit("error",D):this.end());if(!this.buf)throw Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[f2]()}},Uq=class extends S5{sync=!0;[sP](){this[P2](d0.lstatSync(this.absolute))}[rP](){this[cP](d0.readlinkSync(this.absolute))}[tP](){this[eP](d0.openSync(this.absolute,"r"))}[f2](){let D=!0;try{let{fd:R,buf:A,offset:$,length:f,pos:P}=this;if(R===void 0||A===void 0)throw Error("fd and buf must be set in READ method");let B=d0.readSync(R,A,$,f,P);this[oP](B),D=!1}finally{if(D)try{this[gD](()=>{})}catch{}}}[D6](D){D()}[gD](D=()=>{}){this.fd!==void 0&&d0.closeSync(this.fd),D()}},Fq=class extends _1{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(D,R,A={}){return U2(this,D,R,A)}constructor(D,R={}){let A=M6(R);super(),this.preservePaths=!!A.preservePaths,this.portable=!!A.portable,this.strict=!!A.strict,this.noPax=!!A.noPax,this.noMtime=!!A.noMtime,this.onWriteEntry=A.onWriteEntry,this.readEntry=D;let{type:$}=D;if($==="Unsupported")throw Error("writing entry that should be ignored");this.type=$,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=A.prefix,this.path=y(D.path),this.mode=D.mode!==void 0?this[Q2](D.mode):void 0,this.uid=this.portable?void 0:D.uid,this.gid=this.portable?void 0:D.gid,this.uname=this.portable?void 0:D.uname,this.gname=this.portable?void 0:D.gname,this.size=D.size,this.mtime=this.noMtime?void 0:A.mtime||D.mtime,this.atime=this.portable?void 0:D.atime,this.ctime=this.portable?void 0:D.ctime,this.linkpath=D.linkpath!==void 0?y(D.linkpath):void 0,typeof A.onwarn=="function"&&this.on("warn",A.onwarn);let f=!1;if(!this.preservePaths){let[B,G]=T6(this.path);B&&typeof G=="string"&&(this.path=G,f=B)}this.remain=D.size,this.blockRemain=D.startBlockSize,this.onWriteEntry?.(this),this.header=new Y1({path:this[i0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[i0](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),f&&this.warn("TAR_ENTRY_INFO",`stripping ${f} from absolute path`,{entry:this,path:f+this.path}),this.header.encode()&&!this.noPax&&super.write(new M2({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[i0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[i0](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let P=this.header?.block;if(!P)throw Error("failed to encode header");super.write(P),D.pipe(this)}[i0](D){return j5(D,this.prefix)}[Q2](D){return W5(D,this.type==="Directory",this.portable)}write(D,R,A){typeof R=="function"&&(A=R,R=void 0),typeof D=="string"&&(D=Buffer.from(D,typeof R=="string"?R:"utf8"));let $=D.length;if($>this.blockRemain)throw Error("writing more to entry than is appropriate");return this.blockRemain-=$,super.write(D,A)}end(D,R,A){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof D=="function"&&(A=D,R=void 0,D=void 0),typeof R=="function"&&(A=R,R=void 0),typeof D=="string"&&(D=Buffer.from(D,R??"utf8")),A&&this.once("finish",A),D?super.end(D,A):super.end(A),this}},qq=(D)=>D.isFile()?"File":D.isDirectory()?"Directory":D.isSymbolicLink()?"SymbolicLink":"Unsupported",wq=class D{tail;head;length=0;static create(R=[]){return new D(R)}constructor(R=[]){for(let A of R)this.push(A)}*[Symbol.iterator](){for(let R=this.head;R;R=R.next)yield R.value}removeNode(R){if(R.list!==this)throw Error("removing node which does not belong to this list");let{next:A,prev:$}=R;return A&&(A.prev=$),$&&($.next=A),R===this.head&&(this.head=A),R===this.tail&&(this.tail=$),this.length--,R.next=void 0,R.prev=void 0,R.list=void 0,A}unshiftNode(R){if(R===this.head)return;R.list&&R.list.removeNode(R);let A=this.head;R.list=this,R.next=A,A&&(A.prev=R),this.head=R,this.tail||(this.tail=R),this.length++}pushNode(R){if(R===this.tail)return;R.list&&R.list.removeNode(R);let A=this.tail;R.list=this,R.prev=A,A&&(A.next=R),this.tail=R,this.head||(this.head=R),this.length++}push(...R){for(let A=0,$=R.length;A<$;A++)Lq(this,R[A]);return this.length}unshift(...R){for(var A=0,$=R.length;A<$;A++)Nq(this,R[A]);return this.length}pop(){if(!this.tail)return;let R=this.tail.value,A=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,A.list=void 0,this.length--,R}shift(){if(!this.head)return;let R=this.head.value,A=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,A.list=void 0,this.length--,R}forEach(R,A){A=A||this;for(let $=this.head,f=0;$;f++)R.call(A,$.value,f,this),$=$.next}forEachReverse(R,A){A=A||this;for(let $=this.tail,f=this.length-1;$;f--)R.call(A,$.value,f,this),$=$.prev}get(R){let A=0,$=this.head;for(;$&&A<R;A++)$=$.next;if(A===R&&$)return $.value}getReverse(R){let A=0,$=this.tail;for(;$&&A<R;A++)$=$.prev;if(A===R&&$)return $.value}map(R,A){A=A||this;let $=new D;for(let f=this.head;f;)$.push(R.call(A,f.value,this)),f=f.next;return $}mapReverse(R,A){A=A||this;var $=new D;for(let f=this.tail;f;)$.push(R.call(A,f.value,this)),f=f.prev;return $}reduce(R,A){let $,f=this.head;if(arguments.length>1)$=A;else if(this.head)f=this.head.next,$=this.head.value;else throw TypeError("Reduce of empty list with no initial value");for(var P=0;f;P++)$=R($,f.value,P),f=f.next;return $}reduceReverse(R,A){let $,f=this.tail;if(arguments.length>1)$=A;else if(this.tail)f=this.tail.prev,$=this.tail.value;else throw TypeError("Reduce of empty list with no initial value");for(let P=this.length-1;f;P--)$=R($,f.value,P),f=f.prev;return $}toArray(){let R=Array(this.length);for(let A=0,$=this.head;$;A++)R[A]=$.value,$=$.next;return R}toArrayReverse(){let R=Array(this.length);for(let A=0,$=this.tail;$;A++)R[A]=$.value,$=$.prev;return R}slice(R=0,A=this.length){A<0&&(A+=this.length),R<0&&(R+=this.length);let $=new D;if(A<R||A<0)return $;R<0&&(R=0),A>this.length&&(A=this.length);let f=this.head,P=0;for(P=0;f&&P<R;P++)f=f.next;for(;f&&P<A;P++,f=f.next)$.push(f.value);return $}sliceReverse(R=0,A=this.length){A<0&&(A+=this.length),R<0&&(R+=this.length);let $=new D;if(A<R||A<0)return $;R<0&&(R=0),A>this.length&&(A=this.length);let f=this.length,P=this.tail;for(;P&&f>A;f--)P=P.prev;for(;P&&f>R;f--,P=P.prev)$.push(P.value);return $}splice(R,A=0,...$){R>this.length&&(R=this.length-1),R<0&&(R=this.length+R);let f=this.head;for(let B=0;f&&B<R;B++)f=f.next;let P=[];for(let B=0;f&&B<A;B++)P.push(f.value),f=this.removeNode(f);f?f!==this.tail&&(f=f.prev):f=this.tail;for(let B of $)f=Cq(this,f,B);return P}reverse(){let R=this.head,A=this.tail;for(let $=R;$;$=$.prev){let f=$.prev;$.prev=$.next,$.next=f}return this.head=A,this.tail=R,this}};function Cq(D,R,A){let $=R,f=R?R.next:D.head,P=new Y6(A,$,f,D);return P.next===void 0&&(D.tail=P),P.prev===void 0&&(D.head=P),D.length++,P}function Lq(D,R){D.tail=new Y6(R,D.tail,void 0,D),D.head||(D.head=D.tail),D.length++}function Nq(D,R){D.head=new Y6(R,void 0,D.head,D),D.tail||(D.tail=D.head),D.length++}var Y6=class{list;next;prev;value;constructor(D,R,A,$){this.list=$,this.value=D,R?(R.next=this,this.prev=R):this.prev=void 0,A?(A.prev=this,this.next=A):this.next=void 0}},$5=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(D,R){this.path=D||"./",this.absolute=R}},f5=Buffer.alloc(1024),B2=Symbol("onStat"),zA=Symbol("ended"),S0=Symbol("queue"),M1=Symbol("current"),X1=Symbol("process"),JA=Symbol("processing"),yP=Symbol("processJob"),b0=Symbol("jobs"),gP=Symbol("jobDone"),G2=Symbol("addFSEntry"),P5=Symbol("addTarEntry"),R6=Symbol("stat"),A6=Symbol("readdir"),z2=Symbol("onreaddir"),J2=Symbol("pipe"),B5=Symbol("entry"),mP=Symbol("entryOpt"),H2=Symbol("writeEntryClass"),b5=Symbol("write"),xP=Symbol("ondrain"),w2=class extends _1{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[H2];onWriteEntry;[S0];[b0]=0;[JA]=!1;[zA]=!1;constructor(D={}){if(super(),this.opt=D,this.file=D.file||"",this.cwd=D.cwd||process.cwd(),this.maxReadSize=D.maxReadSize,this.preservePaths=!!D.preservePaths,this.strict=!!D.strict,this.noPax=!!D.noPax,this.prefix=y(D.prefix||""),this.linkCache=D.linkCache||new Map,this.statCache=D.statCache||new Map,this.readdirCache=D.readdirCache||new Map,this.onWriteEntry=D.onWriteEntry,this[H2]=S5,typeof D.onwarn=="function"&&this.on("warn",D.onwarn),this.portable=!!D.portable,D.gzip||D.brotli||D.zstd){if((D.gzip?1:0)+(D.brotli?1:0)+(D.zstd?1:0)>1)throw TypeError("gzip, brotli, zstd are mutually exclusive");if(D.gzip&&(typeof D.gzip!="object"&&(D.gzip={}),this.portable&&(D.gzip.portable=!0),this.zip=new uF(D.gzip)),D.brotli&&(typeof D.brotli!="object"&&(D.brotli={}),this.zip=new yF(D.brotli)),D.zstd&&(typeof D.zstd!="object"&&(D.zstd={}),this.zip=new mF(D.zstd)),!this.zip)throw Error("impossible");let R=this.zip;R.on("data",(A)=>super.write(A)),R.on("end",()=>super.end()),R.on("drain",()=>this[xP]()),this.on("resume",()=>R.resume())}else this.on("drain",this[xP]);this.noDirRecurse=!!D.noDirRecurse,this.follow=!!D.follow,this.noMtime=!!D.noMtime,D.mtime&&(this.mtime=D.mtime),this.filter=typeof D.filter=="function"?D.filter:()=>!0,this[S0]=new wq,this[b0]=0,this.jobs=Number(D.jobs)||4,this[JA]=!1,this[zA]=!1}[b5](D){return super.write(D)}add(D){return this.write(D),this}end(D,R,A){return typeof D=="function"&&(A=D,D=void 0),typeof R=="function"&&(A=R,R=void 0),D&&this.add(D),this[zA]=!0,this[X1](),A&&A(),this}write(D){if(this[zA])throw Error("write after end");return D instanceof I5?this[P5](D):this[G2](D),this.flowing}[P5](D){let R=y(A5.resolve(this.cwd,D.path));if(!this.filter(D.path,D))D.resume();else{let A=new $5(D.path,R);A.entry=new Fq(D,this[mP](A)),A.entry.on("end",()=>this[gP](A)),this[b0]+=1,this[S0].push(A)}this[X1]()}[G2](D){let R=y(A5.resolve(this.cwd,D));this[S0].push(new $5(D,R)),this[X1]()}[R6](D){D.pending=!0,this[b0]+=1;let R=this.follow?"stat":"lstat";X2[R](D.absolute,(A,$)=>{D.pending=!1,this[b0]-=1,A?this.emit("error",A):this[B2](D,$)})}[B2](D,R){this.statCache.set(D.absolute,R),D.stat=R,this.filter(D.path,R)?R.isFile()&&R.nlink>1&&D===this[M1]&&!this.linkCache.get(`${R.dev}:${R.ino}`)&&!this.sync&&this[yP](D):D.ignore=!0,this[X1]()}[A6](D){D.pending=!0,this[b0]+=1,X2.readdir(D.absolute,(R,A)=>{if(D.pending=!1,this[b0]-=1,R)return this.emit("error",R);this[z2](D,A)})}[z2](D,R){this.readdirCache.set(D.absolute,R),D.readdir=R,this[X1]()}[X1](){if(!this[JA]){this[JA]=!0;for(let D=this[S0].head;D&&this[b0]<this.jobs;D=D.next)if(this[yP](D.value),D.value.ignore){let R=D.next;this[S0].removeNode(D),D.next=R}this[JA]=!1,this[zA]&&this[S0].length===0&&this[b0]===0&&(this.zip?this.zip.end(f5):(super.write(f5),super.end()))}}get[M1](){return this[S0]&&this[S0].head&&this[S0].head.value}[gP](D){this[S0].shift(),this[b0]-=1,this[X1]()}[yP](D){if(!D.pending){if(D.entry){D===this[M1]&&!D.piped&&this[J2](D);return}if(!D.stat){let R=this.statCache.get(D.absolute);R?this[B2](D,R):this[R6](D)}if(D.stat&&!D.ignore){if(!this.noDirRecurse&&D.stat.isDirectory()&&!D.readdir){let R=this.readdirCache.get(D.absolute);if(R?this[z2](D,R):this[A6](D),!D.readdir)return}if(D.entry=this[B5](D),!D.entry){D.ignore=!0;return}D===this[M1]&&!D.piped&&this[J2](D)}}}[mP](D){return{onwarn:(R,A,$)=>this.warn(R,A,$),noPax:this.noPax,cwd:this.cwd,absolute:D.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[B5](D){this[b0]+=1;try{return new this[H2](D.path,this[mP](D)).on("end",()=>this[gP](D)).on("error",(R)=>this.emit("error",R))}catch(R){this.emit("error",R)}}[xP](){this[M1]&&this[M1].entry&&this[M1].entry.resume()}[J2](D){D.piped=!0,D.readdir&&D.readdir.forEach(($)=>{let f=D.path,P=f==="./"?"":f.replace(/\/*$/,"/");this[G2](P+$)});let R=D.entry,A=this.zip;if(!R)throw Error("cannot pipe without source");A?R.on("data",($)=>{A.write($)||R.pause()}):R.on("data",($)=>{super.write($)||R.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(D,R,A={}){U2(this,D,R,A)}},_6=class extends w2{sync=!0;constructor(D){super(D),this[H2]=Uq}pause(){}resume(){}[R6](D){let R=this.follow?"statSync":"lstatSync";this[B2](D,X2[R](D.absolute))}[A6](D){this[z2](D,X2.readdirSync(D.absolute))}[J2](D){let R=D.entry,A=this.zip;if(D.readdir&&D.readdir.forEach(($)=>{let f=D.path,P=f==="./"?"":f.replace(/\/*$/,"/");this[G2](P+$)}),!R)throw Error("Cannot pipe without source");A?R.on("data",($)=>{A.write($)}):R.on("data",($)=>{super[b5]($)})}},Vq=(D,R)=>{let A=new _6(D),$=new F5(D.file,{mode:D.mode||438});A.pipe($),u5(A,R)},Iq=(D,R)=>{let A=new w2(D),$=new Y2(D.file,{mode:D.mode||438});A.pipe($);let f=new Promise((P,B)=>{$.on("error",B),$.on("close",P),A.on("error",B)});return E5(A,R).catch((P)=>A.emit("error",P)),f},u5=(D,R)=>{R.forEach((A)=>{A.charAt(0)==="@"?F2({file:q5.resolve(D.cwd,A.slice(1)),sync:!0,noResume:!0,onReadEntry:($)=>D.add($)}):D.add(A)}),D.end()},E5=async(D,R)=>{for(let A of R)A.charAt(0)==="@"?await F2({file:q5.resolve(String(D.cwd),A.slice(1)),noResume:!0,onReadEntry:($)=>{D.add($)}}):D.add(A);D.end()},Kq=(D,R)=>{let A=new _6(D);return u5(A,R),A},Wq=(D,R)=>{let A=new w2(D);return E5(A,R).catch(($)=>A.emit("error",$)),A},y5=wA(Vq,Iq,Kq,Wq,(D,R)=>{if(!R?.length)throw TypeError("no paths specified to add to archive")}),Sq=process.env.__FAKE_PLATFORM__||process.platform,n5=Sq==="win32",{O_CREAT:p5,O_NOFOLLOW:G5,O_TRUNC:h5,O_WRONLY:v5}=x5.constants,l5=Number(process.env.__FAKE_FS_O_FILENAME__)||x5.constants.UV_FS_O_FILEMAP||0,bq=n5&&!!l5,uq=524288,Eq=l5|h5|p5|v5,z5=!n5&&typeof G5=="number"?G5|h5|p5|v5:null,k5=z5!==null?()=>z5:bq?(D)=>D<uq?Eq:"w":()=>"w",$6=(D,R,A)=>{try{return C2.lchownSync(D,R,A)}catch($){if($?.code!=="ENOENT")throw $}},T2=(D,R,A,$)=>{C2.lchown(D,R,A,(f)=>{$(f&&f?.code!=="ENOENT"?f:null)})},yq=(D,R,A,$,f)=>{if(R.isDirectory())d5(TA.resolve(D,R.name),A,$,(P)=>{if(P)return f(P);let B=TA.resolve(D,R.name);T2(B,A,$,f)});else{let P=TA.resolve(D,R.name);T2(P,A,$,f)}},d5=(D,R,A,$)=>{C2.readdir(D,{withFileTypes:!0},(f,P)=>{if(f){if(f.code==="ENOENT")return $();if(f.code!=="ENOTDIR"&&f.code!=="ENOTSUP")return $(f)}if(f||!P.length)return T2(D,R,A,$);let B=P.length,G=null,z=(J)=>{if(!G){if(J)return $(G=J);if(--B===0)return T2(D,R,A,$)}};for(let J of P)yq(D,J,R,A,z)})},gq=(D,R,A,$)=>{R.isDirectory()&&i5(TA.resolve(D,R.name),A,$),$6(TA.resolve(D,R.name),A,$)},i5=(D,R,A)=>{let $;try{$=C2.readdirSync(D,{withFileTypes:!0})}catch(f){let P=f;if(P?.code==="ENOENT")return;if(P?.code==="ENOTDIR"||P?.code==="ENOTSUP")return $6(D,R,A);throw P}for(let f of $)gq(D,f,R,A);return $6(D,R,A)},a5=class extends Error{path;code;syscall="chdir";constructor(D,R){super(`${R}: Cannot cd into '${D}'`),this.path=D,this.code=R}get name(){return"CwdError"}},L2=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(D,R){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=D,this.path=R}get name(){return"SymlinkError"}},xq=(D,R)=>{T0.stat(D,(A,$)=>{(A||!$.isDirectory())&&(A=new a5(D,A?.code||"ENOTDIR")),R(A)})},nq=(D,R,A)=>{D=y(D);let $=R.umask??18,f=R.mode|448,P=(f&$)!==0,B=R.uid,G=R.gid,z=typeof B=="number"&&typeof G=="number"&&(B!==R.processUid||G!==R.processGid),J=R.preserve,Z=R.unlink,H=y(R.cwd),M=(O,X)=>{O?A(O):X&&z?d5(X,B,G,(T)=>M(T)):P?T0.chmod(D,f,A):A()};if(D===H)return xq(D,M);if(J)return mq.mkdir(D,{mode:f,recursive:!0}).then((O)=>M(null,O??void 0),M);let Q=y(O2.relative(H,D)).split("/");f6(H,Q,f,Z,H,void 0,M)},f6=(D,R,A,$,f,P,B)=>{if(R.length===0)return B(null,P);let G=R.shift(),z=y(O2.resolve(D+"/"+G));T0.mkdir(z,A,r5(z,R,A,$,f,P,B))},r5=(D,R,A,$,f,P,B)=>(G)=>{G?T0.lstat(D,(z,J)=>{if(z)z.path=z.path&&y(z.path),B(z);else if(J.isDirectory())f6(D,R,A,$,f,P,B);else if($)T0.unlink(D,(Z)=>{if(Z)return B(Z);T0.mkdir(D,A,r5(D,R,A,$,f,P,B))});else{if(J.isSymbolicLink())return B(new L2(D,D+"/"+R.join("/")));B(G)}}):(P=P||D,f6(D,R,A,$,f,P,B))},pq=(D)=>{let R=!1,A;try{R=T0.statSync(D).isDirectory()}catch($){A=$?.code}finally{if(!R)throw new a5(D,A??"ENOTDIR")}},hq=(D,R)=>{D=y(D);let A=R.umask??18,$=R.mode|448,f=($&A)!==0,P=R.uid,B=R.gid,G=typeof P=="number"&&typeof B=="number"&&(P!==R.processUid||B!==R.processGid),z=R.preserve,J=R.unlink,Z=y(R.cwd),H=(O)=>{O&&G&&i5(O,P,B),f&&T0.chmodSync(D,$)};if(D===Z)return pq(Z),H();if(z)return H(T0.mkdirSync(D,{mode:$,recursive:!0})??void 0);let M=y(O2.relative(Z,D)).split("/"),Q;for(let O=M.shift(),X=Z;O&&(X+="/"+O);O=M.shift()){X=y(O2.resolve(X));try{T0.mkdirSync(X,$),Q=Q||X}catch{let T=T0.lstatSync(X);if(T.isDirectory())continue;if(J){T0.unlinkSync(X),T0.mkdirSync(X,$),Q=Q||X;continue}else if(T.isSymbolicLink())return new L2(X,X+"/"+M.join("/"))}}return H(Q)},nP=Object.create(null),J5=1e4,k1=new Set,vq=(D)=>{k1.has(D)?k1.delete(D):nP[D]=D.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),k1.add(D);let R=nP[D],A=k1.size-J5;if(A>J5/10){for(let $ of k1)if(k1.delete($),delete nP[$],--A<=0)break}return R},lq=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,kq=lq==="win32",dq=(D)=>D.split("/").slice(0,-1).reduce((R,A)=>{let $=R.at(-1);return $!==void 0&&(A=s5($,A)),R.push(A||"/"),R},[]),iq=class{#D=new Map;#A=new Map;#R=new Set;reserve(D,R){D=kq?["win32 parallelization disabled"]:D.map(($)=>QA(s5(vq($))));let A=new Set(D.map(($)=>dq($)).reduce(($,f)=>$.concat(f)));this.#A.set(R,{dirs:A,paths:D});for(let $ of D){let f=this.#D.get($);f?f.push(R):this.#D.set($,[R])}for(let $ of A){let f=this.#D.get($);if(!f)this.#D.set($,[new Set([R])]);else{let P=f.at(-1);P instanceof Set?P.add(R):f.push(new Set([R]))}}return this.#P(R)}#B(D){let R=this.#A.get(D);if(!R)throw Error("function does not have any path reservations");return{paths:R.paths.map((A)=>this.#D.get(A)),dirs:[...R.dirs].map((A)=>this.#D.get(A))}}check(D){let{paths:R,dirs:A}=this.#B(D);return R.every(($)=>$&&$[0]===D)&&A.every(($)=>$&&$[0]instanceof Set&&$[0].has(D))}#P(D){return this.#R.has(D)||!this.check(D)?!1:(this.#R.add(D),D(()=>this.#$(D)),!0)}#$(D){if(!this.#R.has(D))return!1;let R=this.#A.get(D);if(!R)throw Error("invalid reservation");let{paths:A,dirs:$}=R,f=new Set;for(let P of A){let B=this.#D.get(P);if(!B||B?.[0]!==D)continue;let G=B[1];if(!G){this.#D.delete(P);continue}if(B.shift(),typeof G=="function")f.add(G);else for(let z of G)f.add(z)}for(let P of $){let B=this.#D.get(P),G=B?.[0];if(!(!B||!(G instanceof Set)))if(G.size===1&&B.length===1){this.#D.delete(P);continue}else if(G.size===1){B.shift();let z=B[0];typeof z=="function"&&f.add(z)}else G.delete(D)}return this.#R.delete(D),f.forEach((P)=>this.#P(P)),!0}},aq=()=>process.umask(),H5=Symbol("onEntry"),P6=Symbol("checkFs"),Z5=Symbol("checkFs2"),B6=Symbol("isReusable"),w0=Symbol("makeFs"),G6=Symbol("file"),z6=Symbol("directory"),Z2=Symbol("link"),M5=Symbol("symlink"),X5=Symbol("hardlink"),MA=Symbol("ensureNoSymlink"),Q5=Symbol("unsupported"),T5=Symbol("checkPath"),pP=Symbol("stripAbsolutePath"),mD=Symbol("mkdir"),f0=Symbol("onError"),D2=Symbol("pending"),O5=Symbol("pend"),d1=Symbol("unpend"),hP=Symbol("ended"),vP=Symbol("maybeClose"),J6=Symbol("skip"),OA=Symbol("doChown"),YA=Symbol("uid"),_A=Symbol("gid"),UA=Symbol("checkedCwd"),rq=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,FA=rq==="win32",sq=1024,oq=(D,R)=>{if(!FA)return n.unlink(D,R);let A=D+".DELETE."+m5(16).toString("hex");n.rename(D,A,($)=>{if($)return R($);n.unlink(A,R)})},cq=(D)=>{if(!FA)return n.unlinkSync(D);let R=D+".DELETE."+m5(16).toString("hex");n.renameSync(D,R),n.unlinkSync(R)},Y5=(D,R,A)=>D!==void 0&&D===D>>>0?D:R!==void 0&&R===R>>>0?R:A,U6=class extends qA{[hP]=!1;[UA]=!1;[D2]=0;reservations=new iq;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(D={}){if(D.ondone=()=>{this[hP]=!0,this[vP]()},super(D),this.transform=D.transform,this.chmod=!!D.chmod,typeof D.uid=="number"||typeof D.gid=="number"){if(typeof D.uid!="number"||typeof D.gid!="number")throw TypeError("cannot set owner without number uid and gid");if(D.preserveOwner)throw TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=D.uid,this.gid=D.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=D.preserveOwner===void 0&&typeof D.uid!="number"?!!(process.getuid&&process.getuid()===0):!!D.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof D.maxDepth=="number"?D.maxDepth:sq,this.forceChown=D.forceChown===!0,this.win32=!!D.win32||FA,this.newer=!!D.newer,this.keep=!!D.keep,this.noMtime=!!D.noMtime,this.preservePaths=!!D.preservePaths,this.unlink=!!D.unlink,this.cwd=y(e.resolve(D.cwd||process.cwd())),this.strip=Number(D.strip)||0,this.processUmask=this.chmod?typeof D.processUmask=="number"?D.processUmask:aq():0,this.umask=typeof D.umask=="number"?D.umask:this.processUmask,this.dmode=D.dmode||511&~this.umask,this.fmode=D.fmode||438&~this.umask,this.on("entry",(R)=>this[H5](R))}warn(D,R,A={}){return(D==="TAR_BAD_ARCHIVE"||D==="TAR_ABORT")&&(A.recoverable=!1),super.warn(D,R,A)}[vP](){this[hP]&&this[D2]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[pP](D,R){let A=D[R],{type:$}=D;if(!A||this.preservePaths)return!0;let[f,P]=T6(A),B=P.replaceAll(/\\/g,"/").split("/");if(B.includes("..")||FA&&/^[a-z]:\.\.$/i.test(B[0]??"")){if(R==="path"||$==="Link")return this.warn("TAR_ENTRY_ERROR",`${R} contains '..'`,{entry:D,[R]:A}),!1;let G=e.posix.dirname(D.path),z=e.posix.normalize(e.posix.join(G,B.join("/")));if(z.startsWith("../")||z==="..")return this.warn("TAR_ENTRY_ERROR",`${R} escapes extraction directory`,{entry:D,[R]:A}),!1}return f&&(D[R]=String(P),this.warn("TAR_ENTRY_INFO",`stripping ${f} from absolute ${R}`,{entry:D,[R]:A})),!0}[T5](D){let R=y(D.path),A=R.split("/");if(this.strip){if(A.length<this.strip)return!1;if(D.type==="Link"){let $=y(String(D.linkpath)).split("/");if($.length>=this.strip)D.linkpath=$.slice(this.strip).join("/");else return!1}A.splice(0,this.strip),D.path=A.join("/")}if(isFinite(this.maxDepth)&&A.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:D,path:R,depth:A.length,maxDepth:this.maxDepth}),!1;if(!this[pP](D,"path")||!this[pP](D,"linkpath"))return!1;if(D.absolute=e.isAbsolute(D.path)?y(e.resolve(D.path)):y(e.resolve(this.cwd,D.path)),!this.preservePaths&&typeof D.absolute=="string"&&D.absolute.indexOf(this.cwd+"/")!==0&&D.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:D,path:y(D.path),resolvedPath:D.absolute,cwd:this.cwd}),!1;if(D.absolute===this.cwd&&D.type!=="Directory"&&D.type!=="GNUDumpDir")return!1;if(this.win32){let{root:$}=e.win32.parse(String(D.absolute));D.absolute=$+cB(String(D.absolute).slice($.length));let{root:f}=e.win32.parse(D.path);D.path=f+cB(D.path.slice(f.length))}return!0}[H5](D){if(!this[T5](D))return D.resume();switch(jq.equal(typeof D.absolute,"string"),D.type){case"Directory":case"GNUDumpDir":D.mode&&(D.mode=D.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[P6](D);default:return this[Q5](D)}}[f0](D,R){D.name==="CwdError"?this.emit("error",D):(this.warn("TAR_ENTRY_ERROR",D,{entry:R}),this[d1](),R.resume())}[mD](D,R,A){nq(y(D),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:R},A)}[OA](D){return this.forceChown||this.preserveOwner&&(typeof D.uid=="number"&&D.uid!==this.processUid||typeof D.gid=="number"&&D.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[YA](D){return Y5(this.uid,D.uid,this.processUid)}[_A](D){return Y5(this.gid,D.gid,this.processGid)}[G6](D,R){let A=typeof D.mode=="number"?D.mode&4095:this.fmode,$=new Y2(String(D.absolute),{flags:k5(D.size),mode:A,autoClose:!1});$.on("error",(G)=>{$.fd&&n.close($.fd,()=>{}),$.write=()=>!0,this[f0](G,D),R()});let f=1,P=(G)=>{if(G){$.fd&&n.close($.fd,()=>{}),this[f0](G,D),R();return}--f===0&&$.fd!==void 0&&n.close($.fd,(z)=>{z?this[f0](z,D):this[d1](),R()})};$.on("finish",()=>{let G=String(D.absolute),z=$.fd;if(typeof z=="number"&&D.mtime&&!this.noMtime){f++;let J=D.atime||new Date,Z=D.mtime;n.futimes(z,J,Z,(H)=>H?n.utimes(G,J,Z,(M)=>P(M&&H)):P())}if(typeof z=="number"&&this[OA](D)){f++;let J=this[YA](D),Z=this[_A](D);typeof J=="number"&&typeof Z=="number"&&n.fchown(z,J,Z,(H)=>H?n.chown(G,J,Z,(M)=>P(M&&H)):P())}P()});let B=this.transform&&this.transform(D)||D;B!==D&&(B.on("error",(G)=>{this[f0](G,D),R()}),D.pipe(B)),B.pipe($)}[z6](D,R){let A=typeof D.mode=="number"?D.mode&4095:this.dmode;this[mD](String(D.absolute),A,($)=>{if($){this[f0]($,D),R();return}let f=1,P=()=>{--f===0&&(R(),this[d1](),D.resume())};D.mtime&&!this.noMtime&&(f++,n.utimes(String(D.absolute),D.atime||new Date,D.mtime,P)),this[OA](D)&&(f++,n.chown(String(D.absolute),Number(this[YA](D)),Number(this[_A](D)),P)),P()})}[Q5](D){D.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${D.type}`,{entry:D}),D.resume()}[M5](D,R){let A=y(e.relative(this.cwd,e.resolve(e.dirname(String(D.absolute)),String(D.linkpath)))).split("/");this[MA](D,this.cwd,A,()=>this[Z2](D,String(D.linkpath),"symlink",R),($)=>{this[f0]($,D),R()})}[X5](D,R){let A=y(e.resolve(this.cwd,String(D.linkpath))),$=y(String(D.linkpath)).split("/");this[MA](D,this.cwd,$,()=>this[Z2](D,A,"link",R),(f)=>{this[f0](f,D),R()})}[MA](D,R,A,$,f){let P=A.shift();if(this.preservePaths||P===void 0)return $();let B=e.resolve(R,P);n.lstat(B,(G,z)=>{if(G)return $();if(z?.isSymbolicLink())return f(new L2(B,e.resolve(B,A.join("/"))));this[MA](D,B,A,$,f)})}[O5](){this[D2]++}[d1](){this[D2]--,this[vP]()}[J6](D){this[d1](),D.resume()}[B6](D,R){return D.type==="File"&&!this.unlink&&R.isFile()&&R.nlink<=1&&!FA}[P6](D){this[O5]();let R=[D.path];D.linkpath&&R.push(D.linkpath),this.reservations.reserve(R,(A)=>this[Z5](D,A))}[Z5](D,R){let A=(B)=>{R(B)},$=()=>{this[mD](this.cwd,this.dmode,(B)=>{if(B){this[f0](B,D),A();return}this[UA]=!0,f()})},f=()=>{if(D.absolute!==this.cwd){let B=y(e.dirname(String(D.absolute)));if(B!==this.cwd)return this[mD](B,this.dmode,(G)=>{if(G){this[f0](G,D),A();return}P()})}P()},P=()=>{n.lstat(String(D.absolute),(B,G)=>{if(G&&(this.keep||this.newer&&G.mtime>(D.mtime??G.mtime))){this[J6](D),A();return}if(B||this[B6](D,G))return this[w0](null,D,A);if(G.isDirectory()){if(D.type==="Directory"){let z=this.chmod&&D.mode&&(G.mode&4095)!==D.mode,J=(Z)=>this[w0](Z??null,D,A);return z?n.chmod(String(D.absolute),Number(D.mode),J):J()}if(D.absolute!==this.cwd)return n.rmdir(String(D.absolute),(z)=>this[w0](z??null,D,A))}if(D.absolute===this.cwd)return this[w0](null,D,A);oq(String(D.absolute),(z)=>this[w0](z??null,D,A))})};this[UA]?f():$()}[w0](D,R,A){if(D){this[f0](D,R),A();return}switch(R.type){case"File":case"OldFile":case"ContiguousFile":return this[G6](R,A);case"Link":return this[X5](R,A);case"SymbolicLink":return this[M5](R,A);case"Directory":case"GNUDumpDir":return this[z6](R,A)}}[Z2](D,R,A,$){n[A](R,String(D.absolute),(f)=>{f?this[f0](f,D):(this[d1](),D.resume()),$()})}},HA=(D)=>{try{return[null,D()]}catch(R){return[R,null]}},o5=class extends U6{sync=!0;[w0](D,R){return super[w0](D,R,()=>{})}[P6](D){if(!this[UA]){let f=this[mD](this.cwd,this.dmode);if(f)return this[f0](f,D);this[UA]=!0}if(D.absolute!==this.cwd){let f=y(e.dirname(String(D.absolute)));if(f!==this.cwd){let P=this[mD](f,this.dmode);if(P)return this[f0](P,D)}}let[R,A]=HA(()=>n.lstatSync(String(D.absolute)));if(A&&(this.keep||this.newer&&A.mtime>(D.mtime??A.mtime)))return this[J6](D);if(R||this[B6](D,A))return this[w0](null,D);if(A.isDirectory()){if(D.type==="Directory"){let P=this.chmod&&D.mode&&(A.mode&4095)!==D.mode,[B]=P?HA(()=>{n.chmodSync(String(D.absolute),Number(D.mode))}):[];return this[w0](B,D)}let[f]=HA(()=>n.rmdirSync(String(D.absolute)));this[w0](f,D)}let[$]=D.absolute===this.cwd?[]:HA(()=>cq(String(D.absolute)));this[w0]($,D)}[G6](D,R){let A=typeof D.mode=="number"?D.mode&4095:this.fmode,$=(B)=>{let G;try{n.closeSync(f)}catch(z){G=z}(B||G)&&this[f0](B||G,D),R()},f;try{f=n.openSync(String(D.absolute),k5(D.size),A)}catch(B){return $(B)}let P=this.transform&&this.transform(D)||D;P!==D&&(P.on("error",(B)=>this[f0](B,D)),D.pipe(P)),P.on("data",(B)=>{try{n.writeSync(f,B,0,B.length)}catch(G){$(G)}}),P.on("end",()=>{let B=null;if(D.mtime&&!this.noMtime){let G=D.atime||new Date,z=D.mtime;try{n.futimesSync(f,G,z)}catch(J){try{n.utimesSync(String(D.absolute),G,z)}catch{B=J}}}if(this[OA](D)){let G=this[YA](D),z=this[_A](D);try{n.fchownSync(f,Number(G),Number(z))}catch(J){try{n.chownSync(String(D.absolute),Number(G),Number(z))}catch{B=B||J}}}$(B)})}[z6](D,R){let A=typeof D.mode=="number"?D.mode&4095:this.dmode,$=this[mD](String(D.absolute),A);if($){this[f0]($,D),R();return}if(D.mtime&&!this.noMtime)try{n.utimesSync(String(D.absolute),D.atime||new Date,D.mtime)}catch{}if(this[OA](D))try{n.chownSync(String(D.absolute),Number(this[YA](D)),Number(this[_A](D)))}catch{}R(),D.resume()}[mD](D,R){try{return hq(y(D),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:R})}catch(A){return A}}[MA](D,R,A,$,f){if(this.preservePaths||A.length===0)return $();let P=R;for(let B of A){P=e.resolve(P,B);let[G,z]=HA(()=>n.lstatSync(P));if(G)return $();if(z.isSymbolicLink())return f(new L2(P,e.resolve(R,A.join("/"))))}$()}[Z2](D,R,A,$){let f=`${A}Sync`;try{n[f](R,String(D.absolute)),$(),D.resume()}catch(P){return this[f0](P,D)}}},tq=(D)=>{let R=new o5(D),A=D.file,$=g5.statSync(A),f=D.maxReadSize||16777216;new _F(A,{readSize:f,size:$.size}).pipe(R)},eq=(D,R)=>{let A=new U6(D),$=D.maxReadSize||16777216,f=D.file;return new Promise((P,B)=>{A.on("error",B),A.on("close",P),g5.stat(f,(G,z)=>{if(G)B(G);else{let J=new Z6(f,{readSize:$,size:z.size});J.on("error",B),J.pipe(A)}})})},Wj=wA(tq,eq,(D)=>new o5(D),(D)=>new U6(D),(D,R)=>{R?.length&&K5(D,R)}),Dw=(D,R)=>{let A=new _6(D),$=!0,f,P;try{try{f=Q0.openSync(D.file,"r+")}catch(z){if(z?.code==="ENOENT")f=Q0.openSync(D.file,"w+");else throw z}let B=Q0.fstatSync(f),G=Buffer.alloc(512);D:for(P=0;P<B.size;P+=512){for(let Z=0,H=0;Z<512;Z+=H){if(H=Q0.readSync(f,G,Z,G.length-Z,P+Z),P===0&&G[0]===31&&G[1]===139)throw Error("cannot append to compressed archives");if(!H)break D}let z=new Y1(G);if(!z.cksumValid)break;let J=512*Math.ceil((z.size||0)/512);if(P+J+512>B.size)break;P+=J,D.mtimeCache&&z.mtime&&D.mtimeCache.set(String(z.path),z.mtime)}$=!1,Rw(D,A,P,f,R)}finally{if($)try{Q0.closeSync(f)}catch{}}},Rw=(D,R,A,$,f)=>{let P=new F5(D.file,{fd:$,start:A});R.pipe(P),$w(R,f)},Aw=(D,R)=>{R=Array.from(R);let A=new w2(D),$=(f,P,B)=>{let G=(M,Q)=>{M?Q0.close(f,(O)=>B(M)):B(null,Q)},z=0;if(P===0)return G(null,0);let J=0,Z=Buffer.alloc(512),H=(M,Q)=>{if(M||Q===void 0)return G(M);if(J+=Q,J<512&&Q)return Q0.read(f,Z,J,Z.length-J,z+J,H);if(z===0&&Z[0]===31&&Z[1]===139)return G(Error("cannot append to compressed archives"));if(J<512)return G(null,z);let O=new Y1(Z);if(!O.cksumValid)return G(null,z);let X=512*Math.ceil((O.size??0)/512);if(z+X+512>P||(z+=X+512,z>=P))return G(null,z);D.mtimeCache&&O.mtime&&D.mtimeCache.set(String(O.path),O.mtime),J=0,Q0.read(f,Z,0,512,z,H)};Q0.read(f,Z,0,512,z,H)};return new Promise((f,P)=>{A.on("error",P);let B="r+",G=(z,J)=>{if(z&&z.code==="ENOENT"&&B==="r+")return B="w+",Q0.open(D.file,B,G);if(z||!J)return P(z);Q0.fstat(J,(Z,H)=>{if(Z)return Q0.close(J,()=>P(Z));$(J,H.size,(M,Q)=>{if(M)return P(M);let O=new Y2(D.file,{fd:J,start:Q});A.pipe(O),O.on("error",P),O.on("close",f),fw(A,R)})})};Q0.open(D.file,B,G)})},$w=(D,R)=>{R.forEach((A)=>{A.charAt(0)==="@"?F2({file:c5.resolve(D.cwd,A.slice(1)),sync:!0,noResume:!0,onReadEntry:($)=>D.add($)}):D.add(A)}),D.end()},fw=async(D,R)=>{for(let A of R)A.charAt(0)==="@"?await F2({file:c5.resolve(String(D.cwd),A.slice(1)),noResume:!0,onReadEntry:($)=>D.add($)}):D.add(A);D.end()},ZA=wA(Dw,Aw,()=>{throw TypeError("file is required")},()=>{throw TypeError("file is required")},(D,R)=>{if(!VF(D))throw TypeError("file is required");if(D.gzip||D.brotli||D.zstd||D.file.endsWith(".br")||D.file.endsWith(".tbr"))throw TypeError("cannot append to compressed archives");if(!R?.length)throw TypeError("no paths specified to add/replace")}),bj=wA(ZA.syncFile,ZA.asyncFile,ZA.syncNoFile,ZA.asyncNoFile,(D,R=[])=>{ZA.validate?.(D,R),Pw(D)}),Pw=(D)=>{let R=D.filter;D.mtimeCache||(D.mtimeCache=new Map),D.filter=R?(A,$)=>R(A,$)&&!((D.mtimeCache?.get(A)??$.mtime??0)>($.mtime??0)):(A,$)=>!((D.mtimeCache?.get(A)??$.mtime??0)>($.mtime??0))};async function e5(D,R){if(R.length===0)return;let A=t5.join(await Bw(t5.join(Gw.tmpdir(),"abrun-cli-deploy-")),"source.tar.gz");return await y5({gzip:!0,cwd:D,file:A,portable:!0},R.map(($)=>$.path)),A}import{readFile as zw}from"node:fs/promises";async function q6(D){let R=new AbortController;D.deployState.activeController=R;let A=Symbol("deploy-create");try{return R.signal.addEventListener("abort",()=>D.client.http.abortRequest(A),{once:!0}),await D.client.api.appsDeployCreate({appId:D.app.id},Jw(D),{cancelToken:A})}finally{if(D.deployState.activeController===R)D.deployState.activeController=null}}async function RG(D,R){let A=Date.now()+8000,$;while(Date.now()<A)try{return await q6(D)}catch(f){if(f.status!==409)throw f;$=f,await R(250)}throw $??Error("Deployment could not be created after source upload")}async function AG(D,R,A,$,f){let P=0,B="";if(A){let J=await zw(A);P=J.byteLength,B=J.toString("base64")}f(DG(0,P));let G=new AbortController;D.deployState.activeController=G;let z=Symbol("deploy-upload");try{G.signal.addEventListener("abort",()=>D.client.http.abortRequest(z),{once:!0});let J=await D.client.api.appsUploadCreate({appId:D.app.id},{kind:"cli",manifest:BG(D.manifestEntries),manifestHash:"",archiveBase64:B,message:$},{cancelToken:z});return f(DG(P,P)),{uploadedFiles:R.files.length,uploadedBytes:P,commitSha:typeof J==="object"&&J!==null?String(J.commit??""):void 0}}finally{if(D.deployState.activeController===G)D.deployState.activeController=null}}async function $G(D,R){let A=new AbortController;R.activeController=A;let $=Symbol("deployment-detail");try{return A.signal.addEventListener("abort",()=>D.client.http.abortRequest($),{once:!0}),await D.client.api.appsDeploymentsDetail({appId:D.appId,deploymentId:D.deploymentId},{cancelToken:$})}finally{if(R.activeController===A)R.activeController=null}}async function fG(D,R){let A=new AbortController;R.activeController=A;let $=Symbol("deployment-logs");try{return A.signal.addEventListener("abort",()=>D.client.http.abortRequest($),{once:!0}),await D.client.api.appsDeploymentsLogsList({appId:D.appId,deploymentId:D.deploymentId,offset:D.offset,limit:D.limit??100},{cancelToken:$})}finally{if(R.activeController===A)R.activeController=null}}async function PG(D){let R=Symbol("deployment-cancel"),A=setTimeout(()=>D.client.http.abortRequest(R),5000);try{await D.client.api.appsDeploymentsCancelCreate({appId:D.appId,deploymentId:D.deploymentId},{cancelToken:R}).catch(()=>{return})}finally{clearTimeout(A)}}function Jw(D){let R=Hw(D);if(D.options.image?.trim())return{method:"image",image:D.options.image.trim(),port:D.options.port,message:R};return{method:"cli",port:D.options.port,message:R,source:{kind:"cli",manifest:BG(D.manifestEntries),...Zw(D)}}}function Hw(D){return D.options.message?.trim()||D.localGit.commitMessage}function Zw(D){let R={};if(D.localGit.commitSha)R.gitCommit=D.localGit.commitSha;if(D.localGit.commitMessage)R.commitMessage=D.localGit.commitMessage;if(D.localGit.authorName)R.authorName=D.localGit.authorName;if(D.localGit.authorEmail)R.authorEmail=D.localGit.authorEmail;return R}function BG(D){return D.map((R)=>({path:R.path,sha256:R.sha256,size:R.size??R.sizeBytes??0}))}function DG(D,R){if(R>0)return`${Math.min(100,Math.max(0,Math.round(D/R*100)))}% ${F6(D)} / ${F6(R)}`;return F6(D)}function F6(D){if(!Number.isFinite(D)||D<=0)return"0 B";let R=["B","KiB","MiB","GiB","TiB"],A=D,$=0;while(A>=1024&&$<R.length-1)A/=1024,$+=1;let f=A>=10||$===0?0:1;return`${A.toFixed(f)} ${R[$]}`}function GG(D,R=[]){let A=null;if(typeof D==="object"&&D!==null){let $=D;if($.status===409)A=$.error??$.data}if(!A)return null;if(typeof A==="object"&&A!==null&&"error"in A)A=A.error;if(typeof A==="object"&&A!==null&&"status"in A&&A.status==="sync_required"&&"requiredFiles"in A&&Array.isArray(A.requiredFiles)&&A.requiredFiles.length>0){let $=A.requiredFiles,f=new Set($.map((G)=>G.trim()).filter(Boolean)),P=new Map(R.map((G)=>[G.path,G])),B=[...f].map((G)=>P.get(G)??{path:G});return{code:"FilesMissing",message:"Source upload required before deployment.",details:{files:B,summary:{added:B.length,changed:0}}}}if(typeof A==="object"&&A!==null&&"code"in A&&A.code==="FilesMissing"&&"details"in A&&typeof A.details==="object"&&A.details!==null){let $=A.details,f=A;return{code:"FilesMissing",message:typeof f.message==="string"?f.message:"Source upload required before deployment.",details:{files:Array.isArray($.files)?$.files:[],summary:typeof $.summary==="object"&&$.summary!==null?{added:Number($.summary.added||0),changed:Number($.summary.changed||0)}:{added:0,changed:0}}}}return null}import{execFile as Mw}from"node:child_process";import{promisify as Xw}from"node:util";var w6=Xw(Mw);async function zG(D){try{await w6("git",["rev-parse","--is-inside-work-tree"],{cwd:D});let R=(await w6("git",["rev-parse","HEAD"],{cwd:D})).stdout.trim(),{stdout:A}=await w6("git",["show","-s","--format=%s%n%an%n%ae","HEAD"],{cwd:D}),[$,f,P]=A.split(`
189
- `);return{commitSha:R||void 0,commitMessage:$?.trim()||void 0,authorName:f?.trim()||void 0,authorEmail:P?.trim()||void 0}}catch{return{}}}var V6=B0(FG(),1);import{createHash as Ew}from"node:crypto";import{readdir as yw,readFile as qG,stat as gw}from"node:fs/promises";import U1 from"node:path";var mw=V6.default().add([".git",".git/",".abrun",".abrun/","node_modules","node_modules/",".bun",".bun/",".next",".next/",".nuxt",".nuxt/",".svelte-kit",".svelte-kit/",".turbo",".turbo/",".cache",".cache/",".parcel-cache",".parcel-cache/",".vercel",".vercel/","dist","dist/","build","build/","coverage","coverage/","__pycache__","__pycache__/",".pytest_cache",".pytest_cache/",".mypy_cache",".mypy_cache/",".venv",".venv/","venv","venv/","target","target/",".gradle",".gradle/","out","out/",".DS_Store",".env",".env.*","*.pyc","*.pyo","*.class"]);async function wG(D){let R=[];return await CG(D,"",[],R),R.sort((A,$)=>A.path.localeCompare($.path))}async function xw(D,R){let A=V6.default();if(!R)A.add([".git",".git/",".abrun",".abrun/"]);for(let $ of[".gitignore",".abrunignore"])try{let f=await qG(U1.join(D,R,$),"utf8");A.add(f)}catch{continue}return{baseDir:LG(R),matcher:A}}async function CG(D,R,A,$){let f=R?U1.join(D,R):D,P=[...A,await xw(D,R)],B=await yw(f,{withFileTypes:!0});for(let G of B){let z=LG(R?U1.join(R,G.name):G.name);if(nw(z,G.isDirectory(),P))continue;let J=U1.join(D,z),Z=await gw(J);if(G.isSymbolicLink())throw Error(`Symlinks are not supported for CLI deploy: ${z}`);if(Z.isDirectory()){await CG(D,z,P,$);continue}if(!Z.isFile())continue;let H=await qG(J);$.push({path:z,sha256:Ew("sha256").update(H).digest("hex"),size:H.byteLength,sizeBytes:H.byteLength})}}function nw(D,R,A){let $=R?`${D}/`:D;if(mw.ignores($))return!0;let f=!1;for(let P of A){let B=pw(P.baseDir,$);if(B===null)continue;let G=P.matcher.test(B);if(G.ignored)f=!0;if(G.unignored)f=!1}return f}function pw(D,R){if(!D)return R;let A=U1.posix.relative(D,R);if(!A||A===".."||A.startsWith("../"))return null;return A}function LG(D){return D.split(U1.sep).join(U1.posix.sep)}var hw=["ready","degraded","failed","cancelled"];function K2(D){return hw.includes(D??"")}function LA(D){return D.status==="ready"}function W2(D,R){return D.result?.url?.trim()||R?.trim()||""}function vw(D){let R=D.errorMessage?.trim()||D.result?.message?.trim();if(R)return R;if(D.status==="degraded")return"App did not become healthy";if(D.status==="cancelled")return"Deployment cancelled";return"Deployment failed"}function j2(D,R="<app>"){let A=D.id??0,$=D.status??"unknown",f=lw(R);return[$==="degraded"?"Deployment applied, but the app did not become healthy.":$==="cancelled"?"Deployment was cancelled.":"Deployment failed.",`Reason: ${vw(D)}`,"Next steps:",` View logs: abrun app logs ${f} --tail 100`,` Roll back: abrun app deployment rollback ${f} ${A}`,` Redeploy: abrun deploy ${f}`].join(`
190
- `)}function lw(D){if(!D||D==="<app>")return"<app>";if(/^[A-Za-z0-9._:@/-]+$/.test(D))return D;return`'${D.replaceAll("'","'\\''")}'`}async function S2(D){let R=D.timeoutMs??900000,A=D.sleepMs??2000,$=D.now??Date.now,f=$()+R,P=D.initial,B=P.status??"pending";while(!K2(P.status)){if(D.shouldAbort?.())return P;if($()>=f)throw Error(`Deployment timed out after ${kw(R)}`);await D.onPoll?.(P),P=await D.fetch(P);let G=P.status??"pending";if(B!==G)await D.onStatusChange?.(B,G,P);if(B=G,!K2(P.status))await D.sleep(A)}return await D.onPoll?.(P),P}function kw(D){let R=Math.ceil(D/1000);if(R<60)return`${R}s`;return`${Math.ceil(R/60)}m`}function NG(){return{aborted:!1,deploymentId:null,activeController:null,logController:null,cancellationRequested:!1}}function I6(D,R){let A=null,$=process.stdin,f=Boolean($&&$.isTTY&&typeof $.setRawMode==="function"),P=f?Boolean($.isRaw):!1,B=f?$.isPaused():!0,G=()=>{if(D.aborted)process.exit(130);D.aborted=!0,D.activeController?.abort(),D.logController?.abort(),R?.(),A=setTimeout(()=>{process.exit(130)},2000),A.unref?.()},z=()=>{G()},J=(Z)=>{if(Z.toString().includes("\x03"))G()};if(D.signalHandler=z,process.on("SIGINT",z),f)$.setRawMode(!0),$.resume(),$.on("data",J);return()=>{if(D.signalHandler)process.removeListener("SIGINT",D.signalHandler),D.signalHandler=void 0;if(f){if($.removeListener("data",J),$.setRawMode(P),B)$.pause()}if(A)clearTimeout(A),A=null}}function b2(D){if(D.aborted)throw Error("Deployment cancelled by user")}function K6(D){return D instanceof Error&&(D.name==="AbortError"||/aborted|cancelled/i.test(D.message))}var XD=B0(mA(),1),VG=["Syncing source","Building image","Pushing image","Deploying","Waiting for app","Ready"],dw=new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]`,"g");function IG(D,R,A,$){if(D)return RC();console.log(`${XD.default.bold("App")}: ${A}`);let f=iw(),P=new KG({write:(G)=>f(G)}),B="";return{completeScan(G){P.detail("Syncing source",R?`${G} files checked`:"Image deploy")},showUploadRequired(G){P.detail("Syncing source",BC(G))},startPackaging(G){P.detail("Syncing source",`Packaging ${G} changed files`)},completePackaging(){},startUploading(){P.detail("Syncing source","Uploading source")},updateUploading(G,z){B=z},completeUploading(G,z,J){let Z=[`${G} files`,z];if(J)Z.push(`commit ${zC(J)}`);if(B)Z.push(B);P.detail("Syncing source",`Uploaded ${Z.join(", ")}`),B=""},startDeploying(){P.detail("Syncing source","Creating deployment")},completeDeploying(){P.detail("Syncing source","Deployment accepted")},updatePhase(G){let z=W6(G);if(!z)return;P.phase(z,G==="ready"?"Rollout ready":void 0)},printLog(G,z){let J=sw(G,z,$);if(!J)return;P.detail(J.phase,J.message,J.kind)},showBuildActivity(G){P.detail("Building image",G)},note(G){P.detail("Ready",G)},finish(G){if(G==="ready"){P.phase("Ready","Rollout ready","success");return}let z=W6(G)??"Deploying";P.detail(z,rw(G),"failure")}}}class KG{writer;printedPhases=new Set;lastDetailByPhase=new Map;constructor(D){this.writer=D}phase(D,R,A="phase"){this.ensurePhase(D,R,A)}detail(D,R,A="detail"){let $=R.trim();if(!$)return;if(this.ensurePhase(D),this.lastDetailByPhase.get(D)===$)return;this.lastDetailByPhase.set(D,$),this.writer.write({phase:D,message:$,kind:A})}ensurePhase(D,R,A="phase"){let $=VG.indexOf(D);for(let f=0;f<=$;f+=1){let P=VG[f];if(this.printedPhases.has(P))continue;this.printedPhases.add(P),this.writer.write({phase:P,message:P===D?R:void 0,kind:P==="Ready"?"success":A})}}}function iw(){let D=!1,R=0;return(A)=>{if(A.kind==="progress"){let $=` ${WG(A.phase).padEnd(7," ")} ${A.message??""}`,f=R>$.length?" ".repeat(R-$.length):"";process.stdout.write(`\r${XD.default.dim($)}${f}`),D=!0,R=$.length;return}if(D)process.stdout.write(`
191
- `),D=!1,R=0;aw(A)}}function aw(D){if(D.kind==="detail"){console.log(` ${XD.default.dim(WG(D.phase).padEnd(7," "))} ${D.message??""}`);return}let R=D.kind==="failure"?XD.default.red("x"):D.kind==="success"?XD.default.green("✓"):XD.default.cyan("•"),A=D.message?XD.default.dim(` — ${D.message}`):"";console.log(`${R} ${XD.default.bold(D.phase)}${A}`)}function W6(D){switch(D){case"queued":return"Syncing source";case"building":return"Building image";case"deploying":return"Deploying";case"pulling":case"starting":return"Waiting for app";case"ready":return"Ready";case"degraded":case"failed":case"cancelled":return"Waiting for app";default:return null}}function rw(D){switch(D){case"queued":return"Syncing source";case"building":return"Building image";case"deploying":return"Deploying";case"pulling":return"Waiting for app";case"starting":return"Waiting for app";case"ready":return"Ready";case"degraded":return"Degraded";case"failed":return"Failed";case"cancelled":return"Cancelled";default:return"Deploying"}}function sw(D,R,A){let $=fC(D);if(PC($))return null;let f=$C($);if(!f)return null;let P=AC(f);if(P)return{phase:"Building image",message:P};let B=ow(f);if(B)return B;if(cw(f))return{phase:ew(f),message:f};if(A||DC(f))return{phase:W6(R)??"Deploying",message:f};return null}function ow(D){if(/^selected dockerfile builder$/i.test(D))return{phase:"Building image",message:"Preparing build"};if(/^running dockerfile build with buildkit$/i.test(D))return{phase:"Building image",message:"Running BuildKit"};if(/^building and pushing image\b/i.test(D))return{phase:"Pushing image",message:D};if(/^runtime apply accepted\b/i.test(D))return{phase:"Deploying",message:"Runtime applied"};if(/^pulling image$/i.test(D))return{phase:"Waiting for app",message:"Pulling image"};if(/^starting app$/i.test(D))return{phase:"Waiting for app",message:"Starting app"};if(/^deployment is ready$/i.test(D))return{phase:"Ready",message:"Rollout ready",kind:"success"};if(tw(D))return{phase:"Pushing image",message:D,kind:"progress"};if(/\b(push|pushing|pushed|layer already exists|mounted from|digest:|writing image|naming to docker\.io)\b/i.test(D))return{phase:"Pushing image",message:D};if(/\b(cache hit|cached|cache miss|importing cache|exporting cache|using cache)\b/i.test(D))return{phase:"Building image",message:D};return null}function cw(D){return/^#\d+\s+/i.test(D)}function tw(D){return/^[a-f0-9]{12,64}\s+Pushing\s+\[[=>\s]+]\s+\S+/i.test(D)}function ew(D){if(/\b(push|pushing|pushed|exporting to image|exporting manifest|exporting config|naming to|digest:)\b/i.test(D))return"Pushing image";return"Building image"}function DC(D){if(/^Prepared managed source workspace\b/i.test(D)||/^Packages$/i.test(D)||/^Steps$/i.test(D)||/^Deploy$/i.test(D)||/^install$/i.test(D)||/^[╭╰│─-]+$/u.test(D)||/^\$ /.test(D)||/^>\s+/i.test(D)||/docker-image:\/\//i.test(D)||/^node\s+[│|]/i.test(D)||/^yarn\s+[│|]/i.test(D)||/^▸\s+/u.test(D))return!1;return!0}function WG(D){switch(D){case"Syncing source":return"source";case"Building image":return"build";case"Pushing image":return"push";case"Deploying":return"deploy";case"Waiting for app":return"rollout";case"Ready":return"ready"}}function RC(){return{completeScan(){},showUploadRequired(){},startPackaging(){},completePackaging(){},startUploading(){},updateUploading(){},completeUploading(){},startDeploying(){},completeDeploying(){},updatePhase(){},printLog(){},showBuildActivity(){},note(){},finish(){}}}function AC(D){let R=/^detected build metadata:\s*(.+)$/i.exec(D);if(!R)return null;let A=R[1]??"",$=Object.fromEntries(A.split(/\s+/).map((P)=>P.split("=")).filter((P)=>P.length===2&&P[0]!==""&&P[1]!=="")),f=$.framework?GC($.framework):"";if(f)return`Platform ${f}`;if($.dockerfile)return"Platform Dockerfile";return null}function $C(D){return D.replace(/\r/g,`
188
+ `).reduce(Pq,Object.create(null)),Pq=(D,R)=>{let A=parseInt(R,10);if(A!==Buffer.byteLength(R)+1)return D;R=R.slice((A+" ").length);let $=R.split("="),f=$.shift();if(!f)return D;let P=f.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),B=$.join("=");return D[P]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(P)?new Date(Number(B)*1000):/^[0-9]+$/.test(B)?+B:B,D},Bq=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,y=Bq!=="win32"?(D)=>D:(D)=>D&&D.replaceAll(/\\/g,"/"),I5=class extends _1{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(D,R,A){switch(super({}),this.pause(),this.extended=R,this.globalExtended=A,this.header=D,this.remain=D.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=D.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!D.path)throw Error("no path provided for tar.ReadEntry");this.path=y(D.path),this.mode=D.mode,this.mode&&(this.mode=this.mode&4095),this.uid=D.uid,this.gid=D.gid,this.uname=D.uname,this.gname=D.gname,this.size=this.remain,this.mtime=D.mtime,this.atime=D.atime,this.ctime=D.ctime,this.linkpath=D.linkpath?y(D.linkpath):void 0,this.uname=D.uname,this.gname=D.gname,R&&this.#D(R),A&&this.#D(A,!0)}write(D){let R=D.length;if(R>this.blockRemain)throw Error("writing more to entry than is appropriate");let A=this.remain,$=this.blockRemain;return this.remain=Math.max(0,A-R),this.blockRemain=Math.max(0,$-R),this.ignore?!0:A>=R?super.write(D):super.write(D.subarray(0,A))}#D(D,R=!1){D.path&&(D.path=y(D.path)),D.linkpath&&(D.linkpath=y(D.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(D).filter(([A,$])=>!($==null||A==="path"&&R))))}},Uf=(D,R,A,$={})=>{D.file&&($.file=D.file),D.cwd&&($.cwd=D.cwd),$.code=A instanceof Error&&A.code||R,$.tarCode=R,!D.strict&&$.recoverable!==!1?(A instanceof Error&&($=Object.assign(A,$),A=A.message),D.emit("warn",R,A,$)):A instanceof Error?D.emit("error",Object.assign(A,$)):D.emit("error",Object.assign(Error(`${R}: ${A}`),$))},Gq=1048576,iP=Buffer.from([31,139]),aP=Buffer.from([40,181,47,253]),zq=Math.max(iP.length,aP.length),q0=Symbol("state"),J1=Symbol("writeEntry"),zD=Symbol("readEntry"),jP=Symbol("nextEntry"),kB=Symbol("processEntry"),k0=Symbol("extendedHeader"),PA=Symbol("globalExtendedHeader"),jD=Symbol("meta"),dB=Symbol("emitMeta"),d=Symbol("buffer"),JD=Symbol("queue"),SD=Symbol("ended"),SP=Symbol("emittedEnd"),H1=Symbol("emit"),c=Symbol("unzip"),r$=Symbol("consumeChunk"),s$=Symbol("consumeChunkSub"),bP=Symbol("consumeBody"),iB=Symbol("consumeMeta"),aB=Symbol("consumeHeader"),BA=Symbol("consuming"),uP=Symbol("bufferConcat"),o$=Symbol("maybeEnd"),l1=Symbol("writing"),bD=Symbol("aborted"),c$=Symbol("onDone"),Z1=Symbol("sawValidEntry"),t$=Symbol("sawNullBlock"),e$=Symbol("sawEOF"),rB=Symbol("closeStream"),Jq=()=>!0,qA=class extends KF{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[JD]=[];[d];[zD];[J1];[q0]="begin";[jD]="";[k0];[PA];[SD]=!1;[c];[bD]=!1;[Z1];[t$]=!1;[e$]=!1;[l1]=!1;[BA]=!1;[SP]=!1;constructor(D={}){super(),this.file=D.file||"",this.on(c$,()=>{(this[q0]==="begin"||this[Z1]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),D.ondone?this.on(c$,D.ondone):this.on(c$,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!D.strict,this.maxMetaEntrySize=D.maxMetaEntrySize||Gq,this.filter=typeof D.filter=="function"?D.filter:Jq;let R=D.file&&(D.file.endsWith(".tar.br")||D.file.endsWith(".tbr"));this.brotli=!(D.gzip||D.zstd)&&D.brotli!==void 0?D.brotli:R?void 0:!1;let A=D.file&&(D.file.endsWith(".tar.zst")||D.file.endsWith(".tzst"));this.zstd=!(D.gzip||D.brotli)&&D.zstd!==void 0?D.zstd:A?!0:void 0,this.on("end",()=>this[rB]()),typeof D.onwarn=="function"&&this.on("warn",D.onwarn),typeof D.onReadEntry=="function"&&this.on("entry",D.onReadEntry)}warn(D,R,A={}){Uf(this,D,R,A)}[aB](D,R){this[Z1]===void 0&&(this[Z1]=!1);let A;try{A=new Y1(D,R,this[k0],this[PA])}catch($){return this.warn("TAR_ENTRY_INVALID",$)}if(A.nullBlock)this[t$]?(this[e$]=!0,this[q0]==="begin"&&(this[q0]="header"),this[H1]("eof")):(this[t$]=!0,this[H1]("nullBlock"));else if(this[t$]=!1,!A.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:A});else if(!A.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:A});else{let $=A.type;if(/^(Symbolic)?Link$/.test($)&&!A.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:A});else if(!/^(Symbolic)?Link$/.test($)&&!/^(Global)?ExtendedHeader$/.test($)&&A.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:A});else{let f=this[J1]=new I5(A,this[k0],this[PA]);if(!this[Z1])if(f.remain){let P=()=>{f.invalid||(this[Z1]=!0)};f.on("end",P)}else this[Z1]=!0;f.meta?f.size>this.maxMetaEntrySize?(f.ignore=!0,this[H1]("ignoredEntry",f),this[q0]="ignore",f.resume()):f.size>0&&(this[jD]="",f.on("data",(P)=>this[jD]+=P),this[q0]="meta"):(this[k0]=void 0,f.ignore=f.ignore||!this.filter(f.path,f),f.ignore?(this[H1]("ignoredEntry",f),this[q0]=f.remain?"ignore":"header",f.resume()):(f.remain?this[q0]="body":(this[q0]="header",f.end()),this[zD]?this[JD].push(f):(this[JD].push(f),this[jP]())))}}}[rB](){queueMicrotask(()=>this.emit("close"))}[kB](D){let R=!0;if(!D)this[zD]=void 0,R=!1;else if(Array.isArray(D)){let[A,...$]=D;this.emit(A,...$)}else this[zD]=D,this.emit("entry",D),D.emittedEnd||(D.on("end",()=>this[jP]()),R=!1);return R}[jP](){do;while(this[kB](this[JD].shift()));if(this[JD].length===0){let D=this[zD];!D||D.flowing||D.size===D.remain?this[l1]||this.emit("drain"):D.once("drain",()=>this.emit("drain"))}}[bP](D,R){let A=this[J1];if(!A)throw Error("attempt to consume body without entry??");let $=A.blockRemain??0,f=$>=D.length&&R===0?D:D.subarray(R,R+$);return A.write(f),A.blockRemain||(this[q0]="header",this[J1]=void 0,A.end()),f.length}[iB](D,R){let A=this[J1],$=this[bP](D,R);return!this[J1]&&A&&this[dB](A),$}[H1](D,R,A){this[JD].length===0&&!this[zD]?this.emit(D,R,A):this[JD].push([D,R,A])}[dB](D){switch(this[H1]("meta",this[jD]),D.type){case"ExtendedHeader":case"OldExtendedHeader":this[k0]=Mf.parse(this[jD],this[k0],!1);break;case"GlobalExtendedHeader":this[PA]=Mf.parse(this[jD],this[PA],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let R=this[k0]??Object.create(null);this[k0]=R,R.path=this[jD].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let R=this[k0]||Object.create(null);this[k0]=R,R.linkpath=this[jD].replace(/\0.*/,"");break}default:throw Error("unknown meta: "+D.type)}}abort(D){this[bD]=!0,this.emit("abort",D),this.warn("TAR_ABORT",D,{recoverable:!1})}write(D,R,A){if(typeof R=="function"&&(A=R,R=void 0),typeof D=="string"&&(D=Buffer.from(D,typeof R=="string"?R:"utf8")),this[bD])return A?.(),!1;if((this[c]===void 0||this.brotli===void 0&&this[c]===!1)&&D){if(this[d]&&(D=Buffer.concat([this[d],D]),this[d]=void 0),D.length<zq)return this[d]=D,A?.(),!0;for(let B=0;this[c]===void 0&&B<iP.length;B++)D[B]!==iP[B]&&(this[c]=!1);let f=!1;if(this[c]===!1&&this.zstd!==!1){f=!0;for(let B=0;B<aP.length;B++)if(D[B]!==aP[B]){f=!1;break}}let P=this.brotli===void 0&&!f;if(this[c]===!1&&P)if(D.length<512)if(this[SD])this.brotli=!0;else return this[d]=D,A?.(),!0;else try{new Y1(D.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[c]===void 0||this[c]===!1&&(this.brotli||f)){let B=this[SD];this[SD]=!1,this[c]=this[c]===void 0?new EF({}):f?new xF({}):new gF({}),this[c].on("data",(z)=>this[r$](z)),this[c].on("error",(z)=>this.abort(z)),this[c].on("end",()=>{this[SD]=!0,this[r$]()}),this[l1]=!0;let G=!!this[c][B?"end":"write"](D);return this[l1]=!1,A?.(),G}}this[l1]=!0,this[c]?this[c].write(D):this[r$](D),this[l1]=!1;let $=this[JD].length>0?!1:this[zD]?this[zD].flowing:!0;return!$&&this[JD].length===0&&this[zD]?.once("drain",()=>this.emit("drain")),A?.(),$}[uP](D){D&&!this[bD]&&(this[d]=this[d]?Buffer.concat([this[d],D]):D)}[o$](){if(this[SD]&&!this[SP]&&!this[bD]&&!this[BA]){this[SP]=!0;let D=this[J1];if(D&&D.blockRemain){let R=this[d]?this[d].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${D.blockRemain} more bytes, only ${R} available)`,{entry:D}),this[d]&&D.write(this[d]),D.end()}this[H1](c$)}}[r$](D){if(this[BA]&&D)this[uP](D);else if(!D&&!this[d])this[o$]();else if(D){if(this[BA]=!0,this[d]){this[uP](D);let R=this[d];this[d]=void 0,this[s$](R)}else this[s$](D);for(;this[d]&&this[d]?.length>=512&&!this[bD]&&!this[e$];){let R=this[d];this[d]=void 0,this[s$](R)}this[BA]=!1}(!this[d]||this[SD])&&this[o$]()}[s$](D){let R=0,A=D.length;for(;R+512<=A&&!this[bD]&&!this[e$];)switch(this[q0]){case"begin":case"header":this[aB](D,R),R+=512;break;case"ignore":case"body":R+=this[bP](D,R);break;case"meta":R+=this[iB](D,R);break;default:throw Error("invalid state: "+this[q0])}R<A&&(this[d]=this[d]?Buffer.concat([D.subarray(R),this[d]]):D.subarray(R))}end(D,R,A){return typeof D=="function"&&(A=D,R=void 0,D=void 0),typeof R=="function"&&(A=R,R=void 0),typeof D=="string"&&(D=Buffer.from(D,R)),A&&this.once("finish",A),this[bD]||(this[c]?(D&&this[c].write(D),this[c].end()):(this[SD]=!0,(this.brotli===void 0||this.zstd===void 0)&&(D=D||Buffer.alloc(0)),D&&this.write(D),this[o$]())),this}},QA=(D)=>{let R=D.length-1,A=-1;for(;R>-1&&D.charAt(R)==="/";)A=R,R--;return A===-1?D:D.slice(0,A)},Hq=(D)=>{let R=D.onReadEntry;D.onReadEntry=R?(A)=>{R(A),A.resume()}:(A)=>A.resume()},K5=(D,R)=>{let A=new Map(R.map((P)=>[QA(P),!0])),$=D.filter,f=(P,B="")=>{let G=B||FF(P).root||".",z;if(P===G)z=!1;else{let J=A.get(P);z=J!==void 0?J:f(UF(P),G)}return A.set(P,z),z};D.filter=$?(P,B)=>$(P,B)&&f(QA(P)):(P)=>f(QA(P))},Zq=(D)=>{let R=new qA(D),A=D.file,$;try{$=s1.openSync(A,"r");let f=s1.fstatSync($),P=D.maxReadSize||16777216;if(f.size<P){let B=Buffer.allocUnsafe(f.size),G=s1.readSync($,B,0,f.size,0);R.end(G===B.byteLength?B:B.subarray(0,G))}else{let B=0,G=Buffer.allocUnsafe(P);for(;B<f.size;){let z=s1.readSync($,G,0,P,B);if(z===0)break;B+=z,R.write(G.subarray(0,z))}R.end()}}finally{if(typeof $=="number")try{s1.closeSync($)}catch{}}},Mq=(D,R)=>{let A=new qA(D),$=D.maxReadSize||16777216,f=D.file;return new Promise((P,B)=>{A.on("error",B),A.on("end",P),s1.stat(f,(G,z)=>{if(G)B(G);else{let J=new Z6(f,{readSize:$,size:z.size});J.on("error",B),J.pipe(A)}})})},Ff=wA(Zq,Mq,(D)=>new qA(D),(D)=>new qA(D),(D,R)=>{R?.length&&K5(D,R),D.noResume||Hq(D)}),W5=(D,R,A)=>(D&=4095,A&&(D=(D|384)&-19),R&&(D&256&&(D|=64),D&32&&(D|=8),D&4&&(D|=1)),D),{isAbsolute:Qq,parse:oB}=Xq,T6=(D)=>{let R="",A=oB(D);for(;Qq(D)||A.root;){let $=D.charAt(0)==="/"&&D.slice(0,4)!=="//?/"?"/":A.root;D=D.slice($.length),R+=$,A=oB(D)}return[R,D]},qf=["|","<",">","?",":"],O6=qf.map((D)=>String.fromCodePoint(61440+Number(D.codePointAt(0)))),Tq=new Map(qf.map((D,R)=>[D,O6[R]])),Oq=new Map(O6.map((D,R)=>[D,qf[R]])),cB=(D)=>qf.reduce((R,A)=>R.split(A).join(Tq.get(A)),D),Yq=(D)=>O6.reduce((R,A)=>R.split(A).join(Oq.get(A)),D),j5=(D,R)=>R?(D=y(D).replace(/^\.(\/|$)/,""),QA(R)+"/"+D):y(D),_q=16777216,tB=Symbol("process"),eB=Symbol("file"),D5=Symbol("directory"),rP=Symbol("symlink"),R5=Symbol("hardlink"),GA=Symbol("header"),ff=Symbol("read"),sP=Symbol("lstat"),Pf=Symbol("onlstat"),oP=Symbol("onread"),cP=Symbol("onreadlink"),tP=Symbol("openfile"),eP=Symbol("onopenfile"),gD=Symbol("close"),Qf=Symbol("mode"),D6=Symbol("awaitDrain"),EP=Symbol("ondrain"),i0=Symbol("prefix"),S5=class extends _1{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#D=!1;constructor(D,R={}){let A=M6(R);super(),this.path=y(D),this.portable=!!A.portable,this.maxReadSize=A.maxReadSize||_q,this.linkCache=A.linkCache||new Map,this.statCache=A.statCache||new Map,this.preservePaths=!!A.preservePaths,this.cwd=y(A.cwd||process.cwd()),this.strict=!!A.strict,this.noPax=!!A.noPax,this.noMtime=!!A.noMtime,this.mtime=A.mtime,this.prefix=A.prefix?y(A.prefix):void 0,this.onWriteEntry=A.onWriteEntry,typeof A.onwarn=="function"&&this.on("warn",A.onwarn);let $=!1;if(!this.preservePaths){let[P,B]=T6(this.path);P&&typeof B=="string"&&(this.path=B,$=P)}this.win32=!!A.win32||process.platform==="win32",this.win32&&(this.path=Yq(this.path.replaceAll(/\\/g,"/")),D=D.replaceAll(/\\/g,"/")),this.absolute=y(A.absolute||sB.resolve(this.cwd,D)),this.path===""&&(this.path="./"),$&&this.warn("TAR_ENTRY_INFO",`stripping ${$} from absolute path`,{entry:this,path:$+this.path});let f=this.statCache.get(this.absolute);f?this[Pf](f):this[sP]()}warn(D,R,A={}){return Uf(this,D,R,A)}emit(D,...R){return D==="error"&&(this.#D=!0),super.emit(D,...R)}[sP](){d0.lstat(this.absolute,(D,R)=>{if(D)return this.emit("error",D);this[Pf](R)})}[Pf](D){this.statCache.set(this.absolute,D),this.stat=D,D.isFile()||(D.size=0),this.type=qq(D),this.emit("stat",D),this[tB]()}[tB](){switch(this.type){case"File":return this[eB]();case"Directory":return this[D5]();case"SymbolicLink":return this[rP]();default:return this.end()}}[Qf](D){return W5(D,this.type==="Directory",this.portable)}[i0](D){return j5(D,this.prefix)}[GA](){if(!this.stat)throw Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Y1({path:this[i0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[i0](this.linkpath):this.linkpath,mode:this[Qf](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new Mf({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[i0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[i0](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let D=this.header?.block;if(!D)throw Error("failed to encode header");super.write(D)}[D5](){if(!this.stat)throw Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[GA](),this.end()}[rP](){d0.readlink(this.absolute,(D,R)=>{if(D)return this.emit("error",D);this[cP](R)})}[cP](D){this.linkpath=y(D),this[GA](),this.end()}[R5](D){if(!this.stat)throw Error("cannot create link entry without stat");this.type="Link",this.linkpath=y(sB.relative(this.cwd,D)),this.stat.size=0,this[GA](),this.end()}[eB](){if(!this.stat)throw Error("cannot create file entry without stat");if(this.stat.nlink>1){let D=`${this.stat.dev}:${this.stat.ino}`,R=this.linkCache.get(D);if(R?.indexOf(this.cwd)===0)return this[R5](R);this.linkCache.set(D,this.absolute)}if(this[GA](),this.stat.size===0)return this.end();this[tP]()}[tP](){d0.open(this.absolute,"r",(D,R)=>{if(D)return this.emit("error",D);this[eP](R)})}[eP](D){if(this.fd=D,this.#D)return this[gD]();if(!this.stat)throw Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let R=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(R),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[ff]()}[ff](){let{fd:D,buf:R,offset:A,length:$,pos:f}=this;if(D===void 0||R===void 0)throw Error("cannot read file without first opening");d0.read(D,R,A,$,f,(P,B)=>{if(P)return this[gD](()=>this.emit("error",P));this[oP](B)})}[gD](D=()=>{}){this.fd!==void 0&&d0.close(this.fd,D)}[oP](D){if(D<=0&&this.remain>0){let A=Object.assign(Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[gD](()=>this.emit("error",A))}if(D>this.remain){let A=Object.assign(Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[gD](()=>this.emit("error",A))}if(!this.buf)throw Error("should have created buffer prior to reading");if(D===this.remain)for(let A=D;A<this.length&&D<this.blockRemain;A++)this.buf[A+this.offset]=0,D++,this.remain++;let R=this.offset===0&&D===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+D);this.write(R)?this[EP]():this[D6](()=>this[EP]())}[D6](D){this.once("drain",D)}write(D,R,A){if(typeof R=="function"&&(A=R,R=void 0),typeof D=="string"&&(D=Buffer.from(D,typeof R=="string"?R:"utf8")),this.blockRemain<D.length){let $=Object.assign(Error("writing more data than expected"),{path:this.absolute});return this.emit("error",$)}return this.remain-=D.length,this.blockRemain-=D.length,this.pos+=D.length,this.offset+=D.length,super.write(D,null,A)}[EP](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[gD]((D)=>D?this.emit("error",D):this.end());if(!this.buf)throw Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[ff]()}},Uq=class extends S5{sync=!0;[sP](){this[Pf](d0.lstatSync(this.absolute))}[rP](){this[cP](d0.readlinkSync(this.absolute))}[tP](){this[eP](d0.openSync(this.absolute,"r"))}[ff](){let D=!0;try{let{fd:R,buf:A,offset:$,length:f,pos:P}=this;if(R===void 0||A===void 0)throw Error("fd and buf must be set in READ method");let B=d0.readSync(R,A,$,f,P);this[oP](B),D=!1}finally{if(D)try{this[gD](()=>{})}catch{}}}[D6](D){D()}[gD](D=()=>{}){this.fd!==void 0&&d0.closeSync(this.fd),D()}},Fq=class extends _1{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(D,R,A={}){return Uf(this,D,R,A)}constructor(D,R={}){let A=M6(R);super(),this.preservePaths=!!A.preservePaths,this.portable=!!A.portable,this.strict=!!A.strict,this.noPax=!!A.noPax,this.noMtime=!!A.noMtime,this.onWriteEntry=A.onWriteEntry,this.readEntry=D;let{type:$}=D;if($==="Unsupported")throw Error("writing entry that should be ignored");this.type=$,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=A.prefix,this.path=y(D.path),this.mode=D.mode!==void 0?this[Qf](D.mode):void 0,this.uid=this.portable?void 0:D.uid,this.gid=this.portable?void 0:D.gid,this.uname=this.portable?void 0:D.uname,this.gname=this.portable?void 0:D.gname,this.size=D.size,this.mtime=this.noMtime?void 0:A.mtime||D.mtime,this.atime=this.portable?void 0:D.atime,this.ctime=this.portable?void 0:D.ctime,this.linkpath=D.linkpath!==void 0?y(D.linkpath):void 0,typeof A.onwarn=="function"&&this.on("warn",A.onwarn);let f=!1;if(!this.preservePaths){let[B,G]=T6(this.path);B&&typeof G=="string"&&(this.path=G,f=B)}this.remain=D.size,this.blockRemain=D.startBlockSize,this.onWriteEntry?.(this),this.header=new Y1({path:this[i0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[i0](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),f&&this.warn("TAR_ENTRY_INFO",`stripping ${f} from absolute path`,{entry:this,path:f+this.path}),this.header.encode()&&!this.noPax&&super.write(new Mf({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[i0](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[i0](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let P=this.header?.block;if(!P)throw Error("failed to encode header");super.write(P),D.pipe(this)}[i0](D){return j5(D,this.prefix)}[Qf](D){return W5(D,this.type==="Directory",this.portable)}write(D,R,A){typeof R=="function"&&(A=R,R=void 0),typeof D=="string"&&(D=Buffer.from(D,typeof R=="string"?R:"utf8"));let $=D.length;if($>this.blockRemain)throw Error("writing more to entry than is appropriate");return this.blockRemain-=$,super.write(D,A)}end(D,R,A){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof D=="function"&&(A=D,R=void 0,D=void 0),typeof R=="function"&&(A=R,R=void 0),typeof D=="string"&&(D=Buffer.from(D,R??"utf8")),A&&this.once("finish",A),D?super.end(D,A):super.end(A),this}},qq=(D)=>D.isFile()?"File":D.isDirectory()?"Directory":D.isSymbolicLink()?"SymbolicLink":"Unsupported",wq=class D{tail;head;length=0;static create(R=[]){return new D(R)}constructor(R=[]){for(let A of R)this.push(A)}*[Symbol.iterator](){for(let R=this.head;R;R=R.next)yield R.value}removeNode(R){if(R.list!==this)throw Error("removing node which does not belong to this list");let{next:A,prev:$}=R;return A&&(A.prev=$),$&&($.next=A),R===this.head&&(this.head=A),R===this.tail&&(this.tail=$),this.length--,R.next=void 0,R.prev=void 0,R.list=void 0,A}unshiftNode(R){if(R===this.head)return;R.list&&R.list.removeNode(R);let A=this.head;R.list=this,R.next=A,A&&(A.prev=R),this.head=R,this.tail||(this.tail=R),this.length++}pushNode(R){if(R===this.tail)return;R.list&&R.list.removeNode(R);let A=this.tail;R.list=this,R.prev=A,A&&(A.next=R),this.tail=R,this.head||(this.head=R),this.length++}push(...R){for(let A=0,$=R.length;A<$;A++)Lq(this,R[A]);return this.length}unshift(...R){for(var A=0,$=R.length;A<$;A++)Nq(this,R[A]);return this.length}pop(){if(!this.tail)return;let R=this.tail.value,A=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,A.list=void 0,this.length--,R}shift(){if(!this.head)return;let R=this.head.value,A=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,A.list=void 0,this.length--,R}forEach(R,A){A=A||this;for(let $=this.head,f=0;$;f++)R.call(A,$.value,f,this),$=$.next}forEachReverse(R,A){A=A||this;for(let $=this.tail,f=this.length-1;$;f--)R.call(A,$.value,f,this),$=$.prev}get(R){let A=0,$=this.head;for(;$&&A<R;A++)$=$.next;if(A===R&&$)return $.value}getReverse(R){let A=0,$=this.tail;for(;$&&A<R;A++)$=$.prev;if(A===R&&$)return $.value}map(R,A){A=A||this;let $=new D;for(let f=this.head;f;)$.push(R.call(A,f.value,this)),f=f.next;return $}mapReverse(R,A){A=A||this;var $=new D;for(let f=this.tail;f;)$.push(R.call(A,f.value,this)),f=f.prev;return $}reduce(R,A){let $,f=this.head;if(arguments.length>1)$=A;else if(this.head)f=this.head.next,$=this.head.value;else throw TypeError("Reduce of empty list with no initial value");for(var P=0;f;P++)$=R($,f.value,P),f=f.next;return $}reduceReverse(R,A){let $,f=this.tail;if(arguments.length>1)$=A;else if(this.tail)f=this.tail.prev,$=this.tail.value;else throw TypeError("Reduce of empty list with no initial value");for(let P=this.length-1;f;P--)$=R($,f.value,P),f=f.prev;return $}toArray(){let R=Array(this.length);for(let A=0,$=this.head;$;A++)R[A]=$.value,$=$.next;return R}toArrayReverse(){let R=Array(this.length);for(let A=0,$=this.tail;$;A++)R[A]=$.value,$=$.prev;return R}slice(R=0,A=this.length){A<0&&(A+=this.length),R<0&&(R+=this.length);let $=new D;if(A<R||A<0)return $;R<0&&(R=0),A>this.length&&(A=this.length);let f=this.head,P=0;for(P=0;f&&P<R;P++)f=f.next;for(;f&&P<A;P++,f=f.next)$.push(f.value);return $}sliceReverse(R=0,A=this.length){A<0&&(A+=this.length),R<0&&(R+=this.length);let $=new D;if(A<R||A<0)return $;R<0&&(R=0),A>this.length&&(A=this.length);let f=this.length,P=this.tail;for(;P&&f>A;f--)P=P.prev;for(;P&&f>R;f--,P=P.prev)$.push(P.value);return $}splice(R,A=0,...$){R>this.length&&(R=this.length-1),R<0&&(R=this.length+R);let f=this.head;for(let B=0;f&&B<R;B++)f=f.next;let P=[];for(let B=0;f&&B<A;B++)P.push(f.value),f=this.removeNode(f);f?f!==this.tail&&(f=f.prev):f=this.tail;for(let B of $)f=Cq(this,f,B);return P}reverse(){let R=this.head,A=this.tail;for(let $=R;$;$=$.prev){let f=$.prev;$.prev=$.next,$.next=f}return this.head=A,this.tail=R,this}};function Cq(D,R,A){let $=R,f=R?R.next:D.head,P=new Y6(A,$,f,D);return P.next===void 0&&(D.tail=P),P.prev===void 0&&(D.head=P),D.length++,P}function Lq(D,R){D.tail=new Y6(R,D.tail,void 0,D),D.head||(D.head=D.tail),D.length++}function Nq(D,R){D.head=new Y6(R,void 0,D.head,D),D.tail||(D.tail=D.head),D.length++}var Y6=class{list;next;prev;value;constructor(D,R,A,$){this.list=$,this.value=D,R?(R.next=this,this.prev=R):this.prev=void 0,A?(A.prev=this,this.next=A):this.next=void 0}},$5=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(D,R){this.path=D||"./",this.absolute=R}},f5=Buffer.alloc(1024),Bf=Symbol("onStat"),zA=Symbol("ended"),S0=Symbol("queue"),M1=Symbol("current"),X1=Symbol("process"),JA=Symbol("processing"),yP=Symbol("processJob"),b0=Symbol("jobs"),gP=Symbol("jobDone"),Gf=Symbol("addFSEntry"),P5=Symbol("addTarEntry"),R6=Symbol("stat"),A6=Symbol("readdir"),zf=Symbol("onreaddir"),Jf=Symbol("pipe"),B5=Symbol("entry"),mP=Symbol("entryOpt"),Hf=Symbol("writeEntryClass"),b5=Symbol("write"),xP=Symbol("ondrain"),wf=class extends _1{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Hf];onWriteEntry;[S0];[b0]=0;[JA]=!1;[zA]=!1;constructor(D={}){if(super(),this.opt=D,this.file=D.file||"",this.cwd=D.cwd||process.cwd(),this.maxReadSize=D.maxReadSize,this.preservePaths=!!D.preservePaths,this.strict=!!D.strict,this.noPax=!!D.noPax,this.prefix=y(D.prefix||""),this.linkCache=D.linkCache||new Map,this.statCache=D.statCache||new Map,this.readdirCache=D.readdirCache||new Map,this.onWriteEntry=D.onWriteEntry,this[Hf]=S5,typeof D.onwarn=="function"&&this.on("warn",D.onwarn),this.portable=!!D.portable,D.gzip||D.brotli||D.zstd){if((D.gzip?1:0)+(D.brotli?1:0)+(D.zstd?1:0)>1)throw TypeError("gzip, brotli, zstd are mutually exclusive");if(D.gzip&&(typeof D.gzip!="object"&&(D.gzip={}),this.portable&&(D.gzip.portable=!0),this.zip=new uF(D.gzip)),D.brotli&&(typeof D.brotli!="object"&&(D.brotli={}),this.zip=new yF(D.brotli)),D.zstd&&(typeof D.zstd!="object"&&(D.zstd={}),this.zip=new mF(D.zstd)),!this.zip)throw Error("impossible");let R=this.zip;R.on("data",(A)=>super.write(A)),R.on("end",()=>super.end()),R.on("drain",()=>this[xP]()),this.on("resume",()=>R.resume())}else this.on("drain",this[xP]);this.noDirRecurse=!!D.noDirRecurse,this.follow=!!D.follow,this.noMtime=!!D.noMtime,D.mtime&&(this.mtime=D.mtime),this.filter=typeof D.filter=="function"?D.filter:()=>!0,this[S0]=new wq,this[b0]=0,this.jobs=Number(D.jobs)||4,this[JA]=!1,this[zA]=!1}[b5](D){return super.write(D)}add(D){return this.write(D),this}end(D,R,A){return typeof D=="function"&&(A=D,D=void 0),typeof R=="function"&&(A=R,R=void 0),D&&this.add(D),this[zA]=!0,this[X1](),A&&A(),this}write(D){if(this[zA])throw Error("write after end");return D instanceof I5?this[P5](D):this[Gf](D),this.flowing}[P5](D){let R=y(A5.resolve(this.cwd,D.path));if(!this.filter(D.path,D))D.resume();else{let A=new $5(D.path,R);A.entry=new Fq(D,this[mP](A)),A.entry.on("end",()=>this[gP](A)),this[b0]+=1,this[S0].push(A)}this[X1]()}[Gf](D){let R=y(A5.resolve(this.cwd,D));this[S0].push(new $5(D,R)),this[X1]()}[R6](D){D.pending=!0,this[b0]+=1;let R=this.follow?"stat":"lstat";Xf[R](D.absolute,(A,$)=>{D.pending=!1,this[b0]-=1,A?this.emit("error",A):this[Bf](D,$)})}[Bf](D,R){this.statCache.set(D.absolute,R),D.stat=R,this.filter(D.path,R)?R.isFile()&&R.nlink>1&&D===this[M1]&&!this.linkCache.get(`${R.dev}:${R.ino}`)&&!this.sync&&this[yP](D):D.ignore=!0,this[X1]()}[A6](D){D.pending=!0,this[b0]+=1,Xf.readdir(D.absolute,(R,A)=>{if(D.pending=!1,this[b0]-=1,R)return this.emit("error",R);this[zf](D,A)})}[zf](D,R){this.readdirCache.set(D.absolute,R),D.readdir=R,this[X1]()}[X1](){if(!this[JA]){this[JA]=!0;for(let D=this[S0].head;D&&this[b0]<this.jobs;D=D.next)if(this[yP](D.value),D.value.ignore){let R=D.next;this[S0].removeNode(D),D.next=R}this[JA]=!1,this[zA]&&this[S0].length===0&&this[b0]===0&&(this.zip?this.zip.end(f5):(super.write(f5),super.end()))}}get[M1](){return this[S0]&&this[S0].head&&this[S0].head.value}[gP](D){this[S0].shift(),this[b0]-=1,this[X1]()}[yP](D){if(!D.pending){if(D.entry){D===this[M1]&&!D.piped&&this[Jf](D);return}if(!D.stat){let R=this.statCache.get(D.absolute);R?this[Bf](D,R):this[R6](D)}if(D.stat&&!D.ignore){if(!this.noDirRecurse&&D.stat.isDirectory()&&!D.readdir){let R=this.readdirCache.get(D.absolute);if(R?this[zf](D,R):this[A6](D),!D.readdir)return}if(D.entry=this[B5](D),!D.entry){D.ignore=!0;return}D===this[M1]&&!D.piped&&this[Jf](D)}}}[mP](D){return{onwarn:(R,A,$)=>this.warn(R,A,$),noPax:this.noPax,cwd:this.cwd,absolute:D.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[B5](D){this[b0]+=1;try{return new this[Hf](D.path,this[mP](D)).on("end",()=>this[gP](D)).on("error",(R)=>this.emit("error",R))}catch(R){this.emit("error",R)}}[xP](){this[M1]&&this[M1].entry&&this[M1].entry.resume()}[Jf](D){D.piped=!0,D.readdir&&D.readdir.forEach(($)=>{let f=D.path,P=f==="./"?"":f.replace(/\/*$/,"/");this[Gf](P+$)});let R=D.entry,A=this.zip;if(!R)throw Error("cannot pipe without source");A?R.on("data",($)=>{A.write($)||R.pause()}):R.on("data",($)=>{super.write($)||R.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(D,R,A={}){Uf(this,D,R,A)}},_6=class extends wf{sync=!0;constructor(D){super(D),this[Hf]=Uq}pause(){}resume(){}[R6](D){let R=this.follow?"statSync":"lstatSync";this[Bf](D,Xf[R](D.absolute))}[A6](D){this[zf](D,Xf.readdirSync(D.absolute))}[Jf](D){let R=D.entry,A=this.zip;if(D.readdir&&D.readdir.forEach(($)=>{let f=D.path,P=f==="./"?"":f.replace(/\/*$/,"/");this[Gf](P+$)}),!R)throw Error("Cannot pipe without source");A?R.on("data",($)=>{A.write($)}):R.on("data",($)=>{super[b5]($)})}},Vq=(D,R)=>{let A=new _6(D),$=new F5(D.file,{mode:D.mode||438});A.pipe($),u5(A,R)},Iq=(D,R)=>{let A=new wf(D),$=new Yf(D.file,{mode:D.mode||438});A.pipe($);let f=new Promise((P,B)=>{$.on("error",B),$.on("close",P),A.on("error",B)});return E5(A,R).catch((P)=>A.emit("error",P)),f},u5=(D,R)=>{R.forEach((A)=>{A.charAt(0)==="@"?Ff({file:q5.resolve(D.cwd,A.slice(1)),sync:!0,noResume:!0,onReadEntry:($)=>D.add($)}):D.add(A)}),D.end()},E5=async(D,R)=>{for(let A of R)A.charAt(0)==="@"?await Ff({file:q5.resolve(String(D.cwd),A.slice(1)),noResume:!0,onReadEntry:($)=>{D.add($)}}):D.add(A);D.end()},Kq=(D,R)=>{let A=new _6(D);return u5(A,R),A},Wq=(D,R)=>{let A=new wf(D);return E5(A,R).catch(($)=>A.emit("error",$)),A},y5=wA(Vq,Iq,Kq,Wq,(D,R)=>{if(!R?.length)throw TypeError("no paths specified to add to archive")}),Sq=process.env.__FAKE_PLATFORM__||process.platform,n5=Sq==="win32",{O_CREAT:p5,O_NOFOLLOW:G5,O_TRUNC:h5,O_WRONLY:v5}=x5.constants,l5=Number(process.env.__FAKE_FS_O_FILENAME__)||x5.constants.UV_FS_O_FILEMAP||0,bq=n5&&!!l5,uq=524288,Eq=l5|h5|p5|v5,z5=!n5&&typeof G5=="number"?G5|h5|p5|v5:null,k5=z5!==null?()=>z5:bq?(D)=>D<uq?Eq:"w":()=>"w",$6=(D,R,A)=>{try{return Cf.lchownSync(D,R,A)}catch($){if($?.code!=="ENOENT")throw $}},Tf=(D,R,A,$)=>{Cf.lchown(D,R,A,(f)=>{$(f&&f?.code!=="ENOENT"?f:null)})},yq=(D,R,A,$,f)=>{if(R.isDirectory())d5(TA.resolve(D,R.name),A,$,(P)=>{if(P)return f(P);let B=TA.resolve(D,R.name);Tf(B,A,$,f)});else{let P=TA.resolve(D,R.name);Tf(P,A,$,f)}},d5=(D,R,A,$)=>{Cf.readdir(D,{withFileTypes:!0},(f,P)=>{if(f){if(f.code==="ENOENT")return $();if(f.code!=="ENOTDIR"&&f.code!=="ENOTSUP")return $(f)}if(f||!P.length)return Tf(D,R,A,$);let B=P.length,G=null,z=(J)=>{if(!G){if(J)return $(G=J);if(--B===0)return Tf(D,R,A,$)}};for(let J of P)yq(D,J,R,A,z)})},gq=(D,R,A,$)=>{R.isDirectory()&&i5(TA.resolve(D,R.name),A,$),$6(TA.resolve(D,R.name),A,$)},i5=(D,R,A)=>{let $;try{$=Cf.readdirSync(D,{withFileTypes:!0})}catch(f){let P=f;if(P?.code==="ENOENT")return;if(P?.code==="ENOTDIR"||P?.code==="ENOTSUP")return $6(D,R,A);throw P}for(let f of $)gq(D,f,R,A);return $6(D,R,A)},a5=class extends Error{path;code;syscall="chdir";constructor(D,R){super(`${R}: Cannot cd into '${D}'`),this.path=D,this.code=R}get name(){return"CwdError"}},Lf=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(D,R){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=D,this.path=R}get name(){return"SymlinkError"}},xq=(D,R)=>{T0.stat(D,(A,$)=>{(A||!$.isDirectory())&&(A=new a5(D,A?.code||"ENOTDIR")),R(A)})},nq=(D,R,A)=>{D=y(D);let $=R.umask??18,f=R.mode|448,P=(f&$)!==0,B=R.uid,G=R.gid,z=typeof B=="number"&&typeof G=="number"&&(B!==R.processUid||G!==R.processGid),J=R.preserve,Z=R.unlink,H=y(R.cwd),M=(O,X)=>{O?A(O):X&&z?d5(X,B,G,(T)=>M(T)):P?T0.chmod(D,f,A):A()};if(D===H)return xq(D,M);if(J)return mq.mkdir(D,{mode:f,recursive:!0}).then((O)=>M(null,O??void 0),M);let Q=y(Of.relative(H,D)).split("/");f6(H,Q,f,Z,H,void 0,M)},f6=(D,R,A,$,f,P,B)=>{if(R.length===0)return B(null,P);let G=R.shift(),z=y(Of.resolve(D+"/"+G));T0.mkdir(z,A,r5(z,R,A,$,f,P,B))},r5=(D,R,A,$,f,P,B)=>(G)=>{G?T0.lstat(D,(z,J)=>{if(z)z.path=z.path&&y(z.path),B(z);else if(J.isDirectory())f6(D,R,A,$,f,P,B);else if($)T0.unlink(D,(Z)=>{if(Z)return B(Z);T0.mkdir(D,A,r5(D,R,A,$,f,P,B))});else{if(J.isSymbolicLink())return B(new Lf(D,D+"/"+R.join("/")));B(G)}}):(P=P||D,f6(D,R,A,$,f,P,B))},pq=(D)=>{let R=!1,A;try{R=T0.statSync(D).isDirectory()}catch($){A=$?.code}finally{if(!R)throw new a5(D,A??"ENOTDIR")}},hq=(D,R)=>{D=y(D);let A=R.umask??18,$=R.mode|448,f=($&A)!==0,P=R.uid,B=R.gid,G=typeof P=="number"&&typeof B=="number"&&(P!==R.processUid||B!==R.processGid),z=R.preserve,J=R.unlink,Z=y(R.cwd),H=(O)=>{O&&G&&i5(O,P,B),f&&T0.chmodSync(D,$)};if(D===Z)return pq(Z),H();if(z)return H(T0.mkdirSync(D,{mode:$,recursive:!0})??void 0);let M=y(Of.relative(Z,D)).split("/"),Q;for(let O=M.shift(),X=Z;O&&(X+="/"+O);O=M.shift()){X=y(Of.resolve(X));try{T0.mkdirSync(X,$),Q=Q||X}catch{let T=T0.lstatSync(X);if(T.isDirectory())continue;if(J){T0.unlinkSync(X),T0.mkdirSync(X,$),Q=Q||X;continue}else if(T.isSymbolicLink())return new Lf(X,X+"/"+M.join("/"))}}return H(Q)},nP=Object.create(null),J5=1e4,k1=new Set,vq=(D)=>{k1.has(D)?k1.delete(D):nP[D]=D.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),k1.add(D);let R=nP[D],A=k1.size-J5;if(A>J5/10){for(let $ of k1)if(k1.delete($),delete nP[$],--A<=0)break}return R},lq=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,kq=lq==="win32",dq=(D)=>D.split("/").slice(0,-1).reduce((R,A)=>{let $=R.at(-1);return $!==void 0&&(A=s5($,A)),R.push(A||"/"),R},[]),iq=class{#D=new Map;#A=new Map;#R=new Set;reserve(D,R){D=kq?["win32 parallelization disabled"]:D.map(($)=>QA(s5(vq($))));let A=new Set(D.map(($)=>dq($)).reduce(($,f)=>$.concat(f)));this.#A.set(R,{dirs:A,paths:D});for(let $ of D){let f=this.#D.get($);f?f.push(R):this.#D.set($,[R])}for(let $ of A){let f=this.#D.get($);if(!f)this.#D.set($,[new Set([R])]);else{let P=f.at(-1);P instanceof Set?P.add(R):f.push(new Set([R]))}}return this.#P(R)}#B(D){let R=this.#A.get(D);if(!R)throw Error("function does not have any path reservations");return{paths:R.paths.map((A)=>this.#D.get(A)),dirs:[...R.dirs].map((A)=>this.#D.get(A))}}check(D){let{paths:R,dirs:A}=this.#B(D);return R.every(($)=>$&&$[0]===D)&&A.every(($)=>$&&$[0]instanceof Set&&$[0].has(D))}#P(D){return this.#R.has(D)||!this.check(D)?!1:(this.#R.add(D),D(()=>this.#$(D)),!0)}#$(D){if(!this.#R.has(D))return!1;let R=this.#A.get(D);if(!R)throw Error("invalid reservation");let{paths:A,dirs:$}=R,f=new Set;for(let P of A){let B=this.#D.get(P);if(!B||B?.[0]!==D)continue;let G=B[1];if(!G){this.#D.delete(P);continue}if(B.shift(),typeof G=="function")f.add(G);else for(let z of G)f.add(z)}for(let P of $){let B=this.#D.get(P),G=B?.[0];if(!(!B||!(G instanceof Set)))if(G.size===1&&B.length===1){this.#D.delete(P);continue}else if(G.size===1){B.shift();let z=B[0];typeof z=="function"&&f.add(z)}else G.delete(D)}return this.#R.delete(D),f.forEach((P)=>this.#P(P)),!0}},aq=()=>process.umask(),H5=Symbol("onEntry"),P6=Symbol("checkFs"),Z5=Symbol("checkFs2"),B6=Symbol("isReusable"),w0=Symbol("makeFs"),G6=Symbol("file"),z6=Symbol("directory"),Zf=Symbol("link"),M5=Symbol("symlink"),X5=Symbol("hardlink"),MA=Symbol("ensureNoSymlink"),Q5=Symbol("unsupported"),T5=Symbol("checkPath"),pP=Symbol("stripAbsolutePath"),mD=Symbol("mkdir"),f0=Symbol("onError"),Df=Symbol("pending"),O5=Symbol("pend"),d1=Symbol("unpend"),hP=Symbol("ended"),vP=Symbol("maybeClose"),J6=Symbol("skip"),OA=Symbol("doChown"),YA=Symbol("uid"),_A=Symbol("gid"),UA=Symbol("checkedCwd"),rq=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,FA=rq==="win32",sq=1024,oq=(D,R)=>{if(!FA)return n.unlink(D,R);let A=D+".DELETE."+m5(16).toString("hex");n.rename(D,A,($)=>{if($)return R($);n.unlink(A,R)})},cq=(D)=>{if(!FA)return n.unlinkSync(D);let R=D+".DELETE."+m5(16).toString("hex");n.renameSync(D,R),n.unlinkSync(R)},Y5=(D,R,A)=>D!==void 0&&D===D>>>0?D:R!==void 0&&R===R>>>0?R:A,U6=class extends qA{[hP]=!1;[UA]=!1;[Df]=0;reservations=new iq;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(D={}){if(D.ondone=()=>{this[hP]=!0,this[vP]()},super(D),this.transform=D.transform,this.chmod=!!D.chmod,typeof D.uid=="number"||typeof D.gid=="number"){if(typeof D.uid!="number"||typeof D.gid!="number")throw TypeError("cannot set owner without number uid and gid");if(D.preserveOwner)throw TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=D.uid,this.gid=D.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=D.preserveOwner===void 0&&typeof D.uid!="number"?!!(process.getuid&&process.getuid()===0):!!D.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof D.maxDepth=="number"?D.maxDepth:sq,this.forceChown=D.forceChown===!0,this.win32=!!D.win32||FA,this.newer=!!D.newer,this.keep=!!D.keep,this.noMtime=!!D.noMtime,this.preservePaths=!!D.preservePaths,this.unlink=!!D.unlink,this.cwd=y(e.resolve(D.cwd||process.cwd())),this.strip=Number(D.strip)||0,this.processUmask=this.chmod?typeof D.processUmask=="number"?D.processUmask:aq():0,this.umask=typeof D.umask=="number"?D.umask:this.processUmask,this.dmode=D.dmode||511&~this.umask,this.fmode=D.fmode||438&~this.umask,this.on("entry",(R)=>this[H5](R))}warn(D,R,A={}){return(D==="TAR_BAD_ARCHIVE"||D==="TAR_ABORT")&&(A.recoverable=!1),super.warn(D,R,A)}[vP](){this[hP]&&this[Df]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[pP](D,R){let A=D[R],{type:$}=D;if(!A||this.preservePaths)return!0;let[f,P]=T6(A),B=P.replaceAll(/\\/g,"/").split("/");if(B.includes("..")||FA&&/^[a-z]:\.\.$/i.test(B[0]??"")){if(R==="path"||$==="Link")return this.warn("TAR_ENTRY_ERROR",`${R} contains '..'`,{entry:D,[R]:A}),!1;let G=e.posix.dirname(D.path),z=e.posix.normalize(e.posix.join(G,B.join("/")));if(z.startsWith("../")||z==="..")return this.warn("TAR_ENTRY_ERROR",`${R} escapes extraction directory`,{entry:D,[R]:A}),!1}return f&&(D[R]=String(P),this.warn("TAR_ENTRY_INFO",`stripping ${f} from absolute ${R}`,{entry:D,[R]:A})),!0}[T5](D){let R=y(D.path),A=R.split("/");if(this.strip){if(A.length<this.strip)return!1;if(D.type==="Link"){let $=y(String(D.linkpath)).split("/");if($.length>=this.strip)D.linkpath=$.slice(this.strip).join("/");else return!1}A.splice(0,this.strip),D.path=A.join("/")}if(isFinite(this.maxDepth)&&A.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:D,path:R,depth:A.length,maxDepth:this.maxDepth}),!1;if(!this[pP](D,"path")||!this[pP](D,"linkpath"))return!1;if(D.absolute=e.isAbsolute(D.path)?y(e.resolve(D.path)):y(e.resolve(this.cwd,D.path)),!this.preservePaths&&typeof D.absolute=="string"&&D.absolute.indexOf(this.cwd+"/")!==0&&D.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:D,path:y(D.path),resolvedPath:D.absolute,cwd:this.cwd}),!1;if(D.absolute===this.cwd&&D.type!=="Directory"&&D.type!=="GNUDumpDir")return!1;if(this.win32){let{root:$}=e.win32.parse(String(D.absolute));D.absolute=$+cB(String(D.absolute).slice($.length));let{root:f}=e.win32.parse(D.path);D.path=f+cB(D.path.slice(f.length))}return!0}[H5](D){if(!this[T5](D))return D.resume();switch(jq.equal(typeof D.absolute,"string"),D.type){case"Directory":case"GNUDumpDir":D.mode&&(D.mode=D.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[P6](D);default:return this[Q5](D)}}[f0](D,R){D.name==="CwdError"?this.emit("error",D):(this.warn("TAR_ENTRY_ERROR",D,{entry:R}),this[d1](),R.resume())}[mD](D,R,A){nq(y(D),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:R},A)}[OA](D){return this.forceChown||this.preserveOwner&&(typeof D.uid=="number"&&D.uid!==this.processUid||typeof D.gid=="number"&&D.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[YA](D){return Y5(this.uid,D.uid,this.processUid)}[_A](D){return Y5(this.gid,D.gid,this.processGid)}[G6](D,R){let A=typeof D.mode=="number"?D.mode&4095:this.fmode,$=new Yf(String(D.absolute),{flags:k5(D.size),mode:A,autoClose:!1});$.on("error",(G)=>{$.fd&&n.close($.fd,()=>{}),$.write=()=>!0,this[f0](G,D),R()});let f=1,P=(G)=>{if(G){$.fd&&n.close($.fd,()=>{}),this[f0](G,D),R();return}--f===0&&$.fd!==void 0&&n.close($.fd,(z)=>{z?this[f0](z,D):this[d1](),R()})};$.on("finish",()=>{let G=String(D.absolute),z=$.fd;if(typeof z=="number"&&D.mtime&&!this.noMtime){f++;let J=D.atime||new Date,Z=D.mtime;n.futimes(z,J,Z,(H)=>H?n.utimes(G,J,Z,(M)=>P(M&&H)):P())}if(typeof z=="number"&&this[OA](D)){f++;let J=this[YA](D),Z=this[_A](D);typeof J=="number"&&typeof Z=="number"&&n.fchown(z,J,Z,(H)=>H?n.chown(G,J,Z,(M)=>P(M&&H)):P())}P()});let B=this.transform&&this.transform(D)||D;B!==D&&(B.on("error",(G)=>{this[f0](G,D),R()}),D.pipe(B)),B.pipe($)}[z6](D,R){let A=typeof D.mode=="number"?D.mode&4095:this.dmode;this[mD](String(D.absolute),A,($)=>{if($){this[f0]($,D),R();return}let f=1,P=()=>{--f===0&&(R(),this[d1](),D.resume())};D.mtime&&!this.noMtime&&(f++,n.utimes(String(D.absolute),D.atime||new Date,D.mtime,P)),this[OA](D)&&(f++,n.chown(String(D.absolute),Number(this[YA](D)),Number(this[_A](D)),P)),P()})}[Q5](D){D.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${D.type}`,{entry:D}),D.resume()}[M5](D,R){let A=y(e.relative(this.cwd,e.resolve(e.dirname(String(D.absolute)),String(D.linkpath)))).split("/");this[MA](D,this.cwd,A,()=>this[Zf](D,String(D.linkpath),"symlink",R),($)=>{this[f0]($,D),R()})}[X5](D,R){let A=y(e.resolve(this.cwd,String(D.linkpath))),$=y(String(D.linkpath)).split("/");this[MA](D,this.cwd,$,()=>this[Zf](D,A,"link",R),(f)=>{this[f0](f,D),R()})}[MA](D,R,A,$,f){let P=A.shift();if(this.preservePaths||P===void 0)return $();let B=e.resolve(R,P);n.lstat(B,(G,z)=>{if(G)return $();if(z?.isSymbolicLink())return f(new Lf(B,e.resolve(B,A.join("/"))));this[MA](D,B,A,$,f)})}[O5](){this[Df]++}[d1](){this[Df]--,this[vP]()}[J6](D){this[d1](),D.resume()}[B6](D,R){return D.type==="File"&&!this.unlink&&R.isFile()&&R.nlink<=1&&!FA}[P6](D){this[O5]();let R=[D.path];D.linkpath&&R.push(D.linkpath),this.reservations.reserve(R,(A)=>this[Z5](D,A))}[Z5](D,R){let A=(B)=>{R(B)},$=()=>{this[mD](this.cwd,this.dmode,(B)=>{if(B){this[f0](B,D),A();return}this[UA]=!0,f()})},f=()=>{if(D.absolute!==this.cwd){let B=y(e.dirname(String(D.absolute)));if(B!==this.cwd)return this[mD](B,this.dmode,(G)=>{if(G){this[f0](G,D),A();return}P()})}P()},P=()=>{n.lstat(String(D.absolute),(B,G)=>{if(G&&(this.keep||this.newer&&G.mtime>(D.mtime??G.mtime))){this[J6](D),A();return}if(B||this[B6](D,G))return this[w0](null,D,A);if(G.isDirectory()){if(D.type==="Directory"){let z=this.chmod&&D.mode&&(G.mode&4095)!==D.mode,J=(Z)=>this[w0](Z??null,D,A);return z?n.chmod(String(D.absolute),Number(D.mode),J):J()}if(D.absolute!==this.cwd)return n.rmdir(String(D.absolute),(z)=>this[w0](z??null,D,A))}if(D.absolute===this.cwd)return this[w0](null,D,A);oq(String(D.absolute),(z)=>this[w0](z??null,D,A))})};this[UA]?f():$()}[w0](D,R,A){if(D){this[f0](D,R),A();return}switch(R.type){case"File":case"OldFile":case"ContiguousFile":return this[G6](R,A);case"Link":return this[X5](R,A);case"SymbolicLink":return this[M5](R,A);case"Directory":case"GNUDumpDir":return this[z6](R,A)}}[Zf](D,R,A,$){n[A](R,String(D.absolute),(f)=>{f?this[f0](f,D):(this[d1](),D.resume()),$()})}},HA=(D)=>{try{return[null,D()]}catch(R){return[R,null]}},o5=class extends U6{sync=!0;[w0](D,R){return super[w0](D,R,()=>{})}[P6](D){if(!this[UA]){let f=this[mD](this.cwd,this.dmode);if(f)return this[f0](f,D);this[UA]=!0}if(D.absolute!==this.cwd){let f=y(e.dirname(String(D.absolute)));if(f!==this.cwd){let P=this[mD](f,this.dmode);if(P)return this[f0](P,D)}}let[R,A]=HA(()=>n.lstatSync(String(D.absolute)));if(A&&(this.keep||this.newer&&A.mtime>(D.mtime??A.mtime)))return this[J6](D);if(R||this[B6](D,A))return this[w0](null,D);if(A.isDirectory()){if(D.type==="Directory"){let P=this.chmod&&D.mode&&(A.mode&4095)!==D.mode,[B]=P?HA(()=>{n.chmodSync(String(D.absolute),Number(D.mode))}):[];return this[w0](B,D)}let[f]=HA(()=>n.rmdirSync(String(D.absolute)));this[w0](f,D)}let[$]=D.absolute===this.cwd?[]:HA(()=>cq(String(D.absolute)));this[w0]($,D)}[G6](D,R){let A=typeof D.mode=="number"?D.mode&4095:this.fmode,$=(B)=>{let G;try{n.closeSync(f)}catch(z){G=z}(B||G)&&this[f0](B||G,D),R()},f;try{f=n.openSync(String(D.absolute),k5(D.size),A)}catch(B){return $(B)}let P=this.transform&&this.transform(D)||D;P!==D&&(P.on("error",(B)=>this[f0](B,D)),D.pipe(P)),P.on("data",(B)=>{try{n.writeSync(f,B,0,B.length)}catch(G){$(G)}}),P.on("end",()=>{let B=null;if(D.mtime&&!this.noMtime){let G=D.atime||new Date,z=D.mtime;try{n.futimesSync(f,G,z)}catch(J){try{n.utimesSync(String(D.absolute),G,z)}catch{B=J}}}if(this[OA](D)){let G=this[YA](D),z=this[_A](D);try{n.fchownSync(f,Number(G),Number(z))}catch(J){try{n.chownSync(String(D.absolute),Number(G),Number(z))}catch{B=B||J}}}$(B)})}[z6](D,R){let A=typeof D.mode=="number"?D.mode&4095:this.dmode,$=this[mD](String(D.absolute),A);if($){this[f0]($,D),R();return}if(D.mtime&&!this.noMtime)try{n.utimesSync(String(D.absolute),D.atime||new Date,D.mtime)}catch{}if(this[OA](D))try{n.chownSync(String(D.absolute),Number(this[YA](D)),Number(this[_A](D)))}catch{}R(),D.resume()}[mD](D,R){try{return hq(y(D),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:R})}catch(A){return A}}[MA](D,R,A,$,f){if(this.preservePaths||A.length===0)return $();let P=R;for(let B of A){P=e.resolve(P,B);let[G,z]=HA(()=>n.lstatSync(P));if(G)return $();if(z.isSymbolicLink())return f(new Lf(P,e.resolve(R,A.join("/"))))}$()}[Zf](D,R,A,$){let f=`${A}Sync`;try{n[f](R,String(D.absolute)),$(),D.resume()}catch(P){return this[f0](P,D)}}},tq=(D)=>{let R=new o5(D),A=D.file,$=g5.statSync(A),f=D.maxReadSize||16777216;new _F(A,{readSize:f,size:$.size}).pipe(R)},eq=(D,R)=>{let A=new U6(D),$=D.maxReadSize||16777216,f=D.file;return new Promise((P,B)=>{A.on("error",B),A.on("close",P),g5.stat(f,(G,z)=>{if(G)B(G);else{let J=new Z6(f,{readSize:$,size:z.size});J.on("error",B),J.pipe(A)}})})},Ij=wA(tq,eq,(D)=>new o5(D),(D)=>new U6(D),(D,R)=>{R?.length&&K5(D,R)}),Dw=(D,R)=>{let A=new _6(D),$=!0,f,P;try{try{f=Q0.openSync(D.file,"r+")}catch(z){if(z?.code==="ENOENT")f=Q0.openSync(D.file,"w+");else throw z}let B=Q0.fstatSync(f),G=Buffer.alloc(512);D:for(P=0;P<B.size;P+=512){for(let Z=0,H=0;Z<512;Z+=H){if(H=Q0.readSync(f,G,Z,G.length-Z,P+Z),P===0&&G[0]===31&&G[1]===139)throw Error("cannot append to compressed archives");if(!H)break D}let z=new Y1(G);if(!z.cksumValid)break;let J=512*Math.ceil((z.size||0)/512);if(P+J+512>B.size)break;P+=J,D.mtimeCache&&z.mtime&&D.mtimeCache.set(String(z.path),z.mtime)}$=!1,Rw(D,A,P,f,R)}finally{if($)try{Q0.closeSync(f)}catch{}}},Rw=(D,R,A,$,f)=>{let P=new F5(D.file,{fd:$,start:A});R.pipe(P),$w(R,f)},Aw=(D,R)=>{R=Array.from(R);let A=new wf(D),$=(f,P,B)=>{let G=(M,Q)=>{M?Q0.close(f,(O)=>B(M)):B(null,Q)},z=0;if(P===0)return G(null,0);let J=0,Z=Buffer.alloc(512),H=(M,Q)=>{if(M||Q===void 0)return G(M);if(J+=Q,J<512&&Q)return Q0.read(f,Z,J,Z.length-J,z+J,H);if(z===0&&Z[0]===31&&Z[1]===139)return G(Error("cannot append to compressed archives"));if(J<512)return G(null,z);let O=new Y1(Z);if(!O.cksumValid)return G(null,z);let X=512*Math.ceil((O.size??0)/512);if(z+X+512>P||(z+=X+512,z>=P))return G(null,z);D.mtimeCache&&O.mtime&&D.mtimeCache.set(String(O.path),O.mtime),J=0,Q0.read(f,Z,0,512,z,H)};Q0.read(f,Z,0,512,z,H)};return new Promise((f,P)=>{A.on("error",P);let B="r+",G=(z,J)=>{if(z&&z.code==="ENOENT"&&B==="r+")return B="w+",Q0.open(D.file,B,G);if(z||!J)return P(z);Q0.fstat(J,(Z,H)=>{if(Z)return Q0.close(J,()=>P(Z));$(J,H.size,(M,Q)=>{if(M)return P(M);let O=new Yf(D.file,{fd:J,start:Q});A.pipe(O),O.on("error",P),O.on("close",f),fw(A,R)})})};Q0.open(D.file,B,G)})},$w=(D,R)=>{R.forEach((A)=>{A.charAt(0)==="@"?Ff({file:c5.resolve(D.cwd,A.slice(1)),sync:!0,noResume:!0,onReadEntry:($)=>D.add($)}):D.add(A)}),D.end()},fw=async(D,R)=>{for(let A of R)A.charAt(0)==="@"?await Ff({file:c5.resolve(String(D.cwd),A.slice(1)),noResume:!0,onReadEntry:($)=>D.add($)}):D.add(A);D.end()},ZA=wA(Dw,Aw,()=>{throw TypeError("file is required")},()=>{throw TypeError("file is required")},(D,R)=>{if(!VF(D))throw TypeError("file is required");if(D.gzip||D.brotli||D.zstd||D.file.endsWith(".br")||D.file.endsWith(".tbr"))throw TypeError("cannot append to compressed archives");if(!R?.length)throw TypeError("no paths specified to add/replace")}),jj=wA(ZA.syncFile,ZA.asyncFile,ZA.syncNoFile,ZA.asyncNoFile,(D,R=[])=>{ZA.validate?.(D,R),Pw(D)}),Pw=(D)=>{let R=D.filter;D.mtimeCache||(D.mtimeCache=new Map),D.filter=R?(A,$)=>R(A,$)&&!((D.mtimeCache?.get(A)??$.mtime??0)>($.mtime??0)):(A,$)=>!((D.mtimeCache?.get(A)??$.mtime??0)>($.mtime??0))};async function e5(D,R){if(R.length===0)return;let A=t5.join(await Bw(t5.join(Gw.tmpdir(),"abrun-cli-deploy-")),"source.tar.gz");return await y5({gzip:!0,cwd:D,file:A,portable:!0},R.map(($)=>$.path)),A}import{readFile as zw}from"node:fs/promises";async function q6(D){let R=new AbortController;D.deployState.activeController=R;let A=Symbol("deploy-create");try{return R.signal.addEventListener("abort",()=>D.client.http.abortRequest(A),{once:!0}),await D.client.api.appsDeployCreate({appId:D.app.id},Jw(D),{cancelToken:A})}finally{if(D.deployState.activeController===R)D.deployState.activeController=null}}async function RG(D,R){let A=Date.now()+8000,$;while(Date.now()<A)try{return await q6(D)}catch(f){if(f.status!==409)throw f;$=f,await R(250)}throw $??Error("Deployment could not be created after source upload")}async function AG(D,R,A,$,f){let P=0,B="";if(A){let J=await zw(A);P=J.byteLength,B=J.toString("base64")}f(DG(0,P));let G=new AbortController;D.deployState.activeController=G;let z=Symbol("deploy-upload");try{G.signal.addEventListener("abort",()=>D.client.http.abortRequest(z),{once:!0});let J=await D.client.api.appsUploadCreate({appId:D.app.id},{kind:"cli",manifest:BG(D.manifestEntries),manifestHash:"",archiveBase64:B,message:$},{cancelToken:z});return f(DG(P,P)),{uploadedFiles:R.files.length,uploadedBytes:P,commitSha:typeof J==="object"&&J!==null?String(J.commit??""):void 0}}finally{if(D.deployState.activeController===G)D.deployState.activeController=null}}async function $G(D,R){let A=new AbortController;R.activeController=A;let $=Symbol("deployment-detail");try{return A.signal.addEventListener("abort",()=>D.client.http.abortRequest($),{once:!0}),await D.client.api.appsDeploymentsDetail({appId:D.appId,deploymentId:D.deploymentId},{cancelToken:$})}finally{if(R.activeController===A)R.activeController=null}}async function fG(D,R){let A=new AbortController;R.activeController=A;let $=Symbol("deployment-logs");try{return A.signal.addEventListener("abort",()=>D.client.http.abortRequest($),{once:!0}),await D.client.api.appsDeploymentsLogsList({appId:D.appId,deploymentId:D.deploymentId,offset:D.offset,limit:D.limit??100},{cancelToken:$})}finally{if(R.activeController===A)R.activeController=null}}async function PG(D){let R=Symbol("deployment-cancel"),A=setTimeout(()=>D.client.http.abortRequest(R),5000);try{await D.client.api.appsDeploymentsCancelCreate({appId:D.appId,deploymentId:D.deploymentId},{cancelToken:R}).catch(()=>{return})}finally{clearTimeout(A)}}function Jw(D){let R=Hw(D);if(D.options.image?.trim())return{method:"image",image:D.options.image.trim(),port:D.options.port,message:R};return{method:"cli",port:D.options.port,message:R,source:{kind:"cli",manifest:BG(D.manifestEntries),...Zw(D)}}}function Hw(D){return D.options.message?.trim()||D.localGit.commitMessage}function Zw(D){let R={};if(D.localGit.commitSha)R.gitCommit=D.localGit.commitSha;if(D.localGit.commitMessage)R.commitMessage=D.localGit.commitMessage;if(D.localGit.authorName)R.authorName=D.localGit.authorName;if(D.localGit.authorEmail)R.authorEmail=D.localGit.authorEmail;return R}function BG(D){return D.map((R)=>({path:R.path,sha256:R.sha256,size:R.size??R.sizeBytes??0}))}function DG(D,R){if(R>0)return`${Math.min(100,Math.max(0,Math.round(D/R*100)))}% ${F6(D)} / ${F6(R)}`;return F6(D)}function F6(D){if(!Number.isFinite(D)||D<=0)return"0 B";let R=["B","KiB","MiB","GiB","TiB"],A=D,$=0;while(A>=1024&&$<R.length-1)A/=1024,$+=1;let f=A>=10||$===0?0:1;return`${A.toFixed(f)} ${R[$]}`}function GG(D,R=[]){let A=null;if(typeof D==="object"&&D!==null){let $=D;if($.status===409)A=$.error??$.data}if(!A)return null;if(typeof A==="object"&&A!==null&&"error"in A)A=A.error;if(typeof A==="object"&&A!==null&&"status"in A&&A.status==="sync_required"&&"requiredFiles"in A&&Array.isArray(A.requiredFiles)&&A.requiredFiles.length>0){let $=A.requiredFiles,f=new Set($.map((G)=>G.trim()).filter(Boolean)),P=new Map(R.map((G)=>[G.path,G])),B=[...f].map((G)=>P.get(G)??{path:G});return{code:"FilesMissing",message:"Source upload required before deployment.",details:{files:B,summary:{added:B.length,changed:0}}}}if(typeof A==="object"&&A!==null&&"code"in A&&A.code==="FilesMissing"&&"details"in A&&typeof A.details==="object"&&A.details!==null){let $=A.details,f=A;return{code:"FilesMissing",message:typeof f.message==="string"?f.message:"Source upload required before deployment.",details:{files:Array.isArray($.files)?$.files:[],summary:typeof $.summary==="object"&&$.summary!==null?{added:Number($.summary.added||0),changed:Number($.summary.changed||0)}:{added:0,changed:0}}}}return null}import{execFile as Mw}from"node:child_process";import{promisify as Xw}from"node:util";var w6=Xw(Mw);async function zG(D){try{await w6("git",["rev-parse","--is-inside-work-tree"],{cwd:D});let R=(await w6("git",["rev-parse","HEAD"],{cwd:D})).stdout.trim(),{stdout:A}=await w6("git",["show","-s","--format=%s%n%an%n%ae","HEAD"],{cwd:D}),[$,f,P]=A.split(`
189
+ `);return{commitSha:R||void 0,commitMessage:$?.trim()||void 0,authorName:f?.trim()||void 0,authorEmail:P?.trim()||void 0}}catch{return{}}}var V6=B0(FG(),1);import{createHash as Ew}from"node:crypto";import{readdir as yw,readFile as qG,stat as gw}from"node:fs/promises";import U1 from"node:path";var mw=V6.default().add([".git",".git/",".abrun",".abrun/","node_modules","node_modules/",".bun",".bun/",".next",".next/",".nuxt",".nuxt/",".svelte-kit",".svelte-kit/",".turbo",".turbo/",".cache",".cache/",".parcel-cache",".parcel-cache/",".vercel",".vercel/","dist","dist/","build","build/","coverage","coverage/","__pycache__","__pycache__/",".pytest_cache",".pytest_cache/",".mypy_cache",".mypy_cache/",".venv",".venv/","venv","venv/","target","target/",".gradle",".gradle/","out","out/",".DS_Store",".env",".env.*","*.pyc","*.pyo","*.class"]);async function wG(D){let R=[];return await CG(D,"",[],R),R.sort((A,$)=>A.path.localeCompare($.path))}async function xw(D,R){let A=V6.default();if(!R)A.add([".git",".git/",".abrun",".abrun/"]);for(let $ of[".gitignore",".abrunignore"])try{let f=await qG(U1.join(D,R,$),"utf8");A.add(f)}catch{continue}return{baseDir:LG(R),matcher:A}}async function CG(D,R,A,$){let f=R?U1.join(D,R):D,P=[...A,await xw(D,R)],B=await yw(f,{withFileTypes:!0});for(let G of B){let z=LG(R?U1.join(R,G.name):G.name);if(nw(z,G.isDirectory(),P))continue;let J=U1.join(D,z),Z=await gw(J);if(G.isSymbolicLink())throw Error(`Symlinks are not supported for CLI deploy: ${z}`);if(Z.isDirectory()){await CG(D,z,P,$);continue}if(!Z.isFile())continue;let H=await qG(J);$.push({path:z,sha256:Ew("sha256").update(H).digest("hex"),size:H.byteLength,sizeBytes:H.byteLength})}}function nw(D,R,A){let $=R?`${D}/`:D;if(mw.ignores($))return!0;let f=!1;for(let P of A){let B=pw(P.baseDir,$);if(B===null)continue;let G=P.matcher.test(B);if(G.ignored)f=!0;if(G.unignored)f=!1}return f}function pw(D,R){if(!D)return R;let A=U1.posix.relative(D,R);if(!A||A===".."||A.startsWith("../"))return null;return A}function LG(D){return D.split(U1.sep).join(U1.posix.sep)}var hw=["ready","degraded","failed","cancelled"];function Kf(D){return hw.includes(D??"")}function LA(D){return D.status==="ready"}function Wf(D,R){return D.result?.url?.trim()||R?.trim()||""}function vw(D){let R=D.errorMessage?.trim()||D.result?.message?.trim();if(R)return R;if(D.status==="degraded")return"App did not become healthy";if(D.status==="cancelled")return"Deployment cancelled";return"Deployment failed"}function jf(D,R="<app>"){let A=D.id??0,$=D.status??"unknown",f=lw(R);return[$==="degraded"?"Deployment applied, but the app did not become healthy.":$==="cancelled"?"Deployment was cancelled.":"Deployment failed.",`Reason: ${vw(D)}`,"Next steps:",` View logs: abrun app logs ${f} --tail 100`,` Roll back: abrun app deployment rollback ${f} ${A}`,` Redeploy: abrun deploy ${f}`].join(`
190
+ `)}function lw(D){if(!D||D==="<app>")return"<app>";if(/^[A-Za-z0-9._:@/-]+$/.test(D))return D;return`'${D.replaceAll("'","'\\''")}'`}async function Sf(D){let R=D.timeoutMs??900000,A=D.sleepMs??2000,$=D.now??Date.now,f=$()+R,P=D.initial,B=P.status??"pending";while(!Kf(P.status)){if(D.shouldAbort?.())return P;if($()>=f)throw Error(`Deployment timed out after ${kw(R)}`);await D.onPoll?.(P),P=await D.fetch(P);let G=P.status??"pending";if(B!==G)await D.onStatusChange?.(B,G,P);if(B=G,!Kf(P.status))await D.sleep(A)}return await D.onPoll?.(P),P}function kw(D){let R=Math.ceil(D/1000);if(R<60)return`${R}s`;return`${Math.ceil(R/60)}m`}function NG(){return{aborted:!1,deploymentId:null,activeController:null,logController:null,cancellationRequested:!1}}function I6(D,R){let A=null,$=process.stdin,f=Boolean($&&$.isTTY&&typeof $.setRawMode==="function"),P=f?Boolean($.isRaw):!1,B=f?$.isPaused():!0,G=()=>{if(D.aborted)process.exit(130);D.aborted=!0,D.activeController?.abort(),D.logController?.abort(),R?.(),A=setTimeout(()=>{process.exit(130)},2000),A.unref?.()},z=()=>{G()},J=(Z)=>{if(Z.toString().includes("\x03"))G()};if(D.signalHandler=z,process.on("SIGINT",z),f)$.setRawMode(!0),$.resume(),$.on("data",J);return()=>{if(D.signalHandler)process.removeListener("SIGINT",D.signalHandler),D.signalHandler=void 0;if(f){if($.removeListener("data",J),$.setRawMode(P),B)$.pause()}if(A)clearTimeout(A),A=null}}function bf(D){if(D.aborted)throw Error("Deployment cancelled by user")}function K6(D){return D instanceof Error&&(D.name==="AbortError"||/aborted|cancelled/i.test(D.message))}var XD=B0(mA(),1),VG=["Syncing source","Building image","Pushing image","Deploying","Waiting for app","Ready"],dw=new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]`,"g");function IG(D,R,A,$){if(D)return RC();console.log(`${XD.default.bold("App")}: ${A}`);let f=iw(),P=new KG({write:(G)=>f(G)}),B="";return{completeScan(G){P.detail("Syncing source",R?`${G} files checked`:"Image deploy")},showUploadRequired(G){P.detail("Syncing source",PC(G))},startPackaging(G){P.detail("Syncing source",`Packaging ${G} changed files`)},completePackaging(){},startUploading(){P.detail("Syncing source","Uploading source")},updateUploading(G,z){B=z},completeUploading(G,z,J){let Z=[`${G} files`,z];if(J)Z.push(`commit ${BC(J)}`);if(B)Z.push(B);P.detail("Syncing source",`Uploaded ${Z.join(", ")}`),B=""},startDeploying(){P.detail("Syncing source","Creating deployment")},completeDeploying(){P.detail("Syncing source","Deployment accepted")},updatePhase(G){let z=W6(G);if(!z)return;P.phase(z,G==="ready"?"Rollout ready":void 0)},printLog(G,z){let J=sw(G,z,$);if(!J)return;P.detail(J.phase,J.message,J.kind)},showBuildActivity(G){P.detail("Building image",G)},note(G){P.detail("Ready",G)},finish(G){if(G==="ready"){P.phase("Ready","Rollout ready","success");return}let z=W6(G)??"Deploying";P.detail(z,rw(G),"failure")}}}class KG{writer;printedPhases=new Set;lastDetailByPhase=new Map;constructor(D){this.writer=D}phase(D,R,A="phase"){this.ensurePhase(D,R,A)}detail(D,R,A="detail"){let $=R.trim();if(!$)return;if(this.ensurePhase(D),this.lastDetailByPhase.get(D)===$)return;this.lastDetailByPhase.set(D,$),this.writer.write({phase:D,message:$,kind:A})}ensurePhase(D,R,A="phase"){let $=VG.indexOf(D);for(let f=0;f<=$;f+=1){let P=VG[f];if(this.printedPhases.has(P))continue;this.printedPhases.add(P),this.writer.write({phase:P,message:P===D?R:void 0,kind:P==="Ready"?"success":A})}}}function iw(){let D=!1,R=0;return(A)=>{if(A.kind==="progress"){let $=` ${WG(A.phase).padEnd(7," ")} ${A.message??""}`,f=R>$.length?" ".repeat(R-$.length):"";process.stdout.write(`\r${XD.default.dim($)}${f}`),D=!0,R=$.length;return}if(D)process.stdout.write(`
191
+ `),D=!1,R=0;aw(A)}}function aw(D){if(D.kind==="detail"){console.log(` ${XD.default.dim(WG(D.phase).padEnd(7," "))} ${D.message??""}`);return}let R=D.kind==="failure"?XD.default.red("x"):D.kind==="success"?XD.default.green("✓"):XD.default.cyan("•"),A=D.message?XD.default.dim(` — ${D.message}`):"";console.log(`${R} ${XD.default.bold(D.phase)}${A}`)}function W6(D){switch(D){case"queued":return"Syncing source";case"building":return"Building image";case"deploying":return"Deploying";case"pulling":case"starting":return"Waiting for app";case"ready":return"Ready";case"degraded":case"failed":case"cancelled":return"Waiting for app";default:return null}}function rw(D){switch(D){case"queued":return"Syncing source";case"building":return"Building image";case"deploying":return"Deploying";case"pulling":return"Waiting for app";case"starting":return"Waiting for app";case"ready":return"Ready";case"degraded":return"Degraded";case"failed":return"Failed";case"cancelled":return"Cancelled";default:return"Deploying"}}function sw(D,R,A){let $=$C(D);if(fC($))return null;let f=AC($);if(!f)return null;let P=ow(f);if(P)return P;if(cw(f))return{phase:ew(f),message:f};if(A||DC(f))return{phase:W6(R)??"Deploying",message:f};return null}function ow(D){if(/^selected dockerfile builder$/i.test(D))return{phase:"Building image",message:"Preparing build"};if(/^running dockerfile build with buildkit$/i.test(D))return{phase:"Building image",message:"Running BuildKit"};if(/^building and pushing image\b/i.test(D))return{phase:"Pushing image",message:D};if(/^runtime apply accepted\b/i.test(D))return{phase:"Deploying",message:"Runtime applied"};if(/^pulling image$/i.test(D))return{phase:"Waiting for app",message:"Pulling image"};if(/^starting app$/i.test(D))return{phase:"Waiting for app",message:"Starting app"};if(/^deployment is ready$/i.test(D))return{phase:"Ready",message:"Rollout ready",kind:"success"};if(tw(D))return{phase:"Pushing image",message:D,kind:"progress"};if(/\b(push|pushing|pushed|layer already exists|mounted from|digest:|writing image|naming to docker\.io)\b/i.test(D))return{phase:"Pushing image",message:D};if(/\b(cache hit|cached|cache miss|importing cache|exporting cache|using cache)\b/i.test(D))return{phase:"Building image",message:D};return null}function cw(D){return/^#\d+\s+/i.test(D)}function tw(D){return/^[a-f0-9]{12,64}\s+Pushing\s+\[[=>\s]+]\s+\S+/i.test(D)}function ew(D){if(/\b(push|pushing|pushed|exporting to image|exporting manifest|exporting config|naming to|digest:)\b/i.test(D))return"Pushing image";return"Building image"}function DC(D){if(/^Prepared managed source workspace\b/i.test(D)||/^Packages$/i.test(D)||/^Steps$/i.test(D)||/^Deploy$/i.test(D)||/^install$/i.test(D)||/^[╭╰│─-]+$/u.test(D)||/^\$ /.test(D)||/^>\s+/i.test(D)||/docker-image:\/\//i.test(D)||/^node\s+[│|]/i.test(D)||/^yarn\s+[│|]/i.test(D)||/^▸\s+/u.test(D))return!1;return!0}function WG(D){switch(D){case"Syncing source":return"source";case"Building image":return"build";case"Pushing image":return"push";case"Deploying":return"deploy";case"Waiting for app":return"rollout";case"Ready":return"ready"}}function RC(){return{completeScan(){},showUploadRequired(){},startPackaging(){},completePackaging(){},startUploading(){},updateUploading(){},completeUploading(){},startDeploying(){},completeDeploying(){},updatePhase(){},printLog(){},showBuildActivity(){},note(){},finish(){}}}function AC(D){return D.replace(/\r/g,`
192
192
  `).split(`
193
- `).map((A)=>A.trim()).filter(Boolean).at(-1)?.trim()??""}function fC(D){return D.replace(dw,"")}function PC(D){return/^[╭╰│─\s]+$/u.test(D.trim())}function BC(D){let R=D.summary.added??0,A=D.summary.changed??0,$=D.files.length;if($===0)return"Source is up to date";let f=[];if(R>0)f.push(`${R} added`);if(A>0)f.push(`${A} changed`);let P=R+A;if($>P)f.push(`${$-P} removed`);return`${$} changed files (${f.join(", ")})`}function GC(D){return D.split(/[-_]/).filter(Boolean).map((R)=>R.charAt(0).toUpperCase()+R.slice(1)).join(" ")}function zC(D){return D.trim().slice(0,7)}async function DR(D,R,A){let $=await D.client.http.request({path:R,method:"GET",query:JC(A),secure:!0,format:void 0,headers:{Accept:"text/event-stream"}});if(!$.ok||!$.body)throw Error(`Failed to open log stream (${$.status} ${$.statusText})`);await HC($,(f)=>{let P=jG(f);console.log(P.message??P.line??"")})}async function u2(D,R){let A=new Set,$=!0;for(;;){let P=[...(await D.list()).items??[]].filter((B)=>B.id!==void 0&&B.id!==null).sort((B,G)=>(B.createdAt??"").localeCompare(G.createdAt??""));for(let B of P){if(D.since&&B.createdAt&&B.createdAt<D.since)continue;let G=Number(B.id);if(Number.isFinite(G)&&!A.has(G)){if(!$)D.onEvent(B);A.add(G)}}$=!1,await c0(R?.intervalMs??2000)}}function E2(D){return(Array.isArray(D)?D:Array.isArray(D?.items)?D.items:[]).map(jG)}function jG(D){let R=D;return{time:R.time??R.timestamp??R.createdAt,message:R.message??R.line??"",pod:R.pod??R.source??"",container:R.container??""}}function JC(D){return Object.fromEntries(Object.entries(D).filter(([,R])=>R!==void 0&&R!==!1).map(([R,A])=>[R,typeof A==="boolean"?String(A):A]))}async function HC(D,R){let A=new TextDecoder,$=D.body.getReader(),f="";for(;;){let{done:P,value:B}=await $.read();if(P)break;f+=A.decode(B,{stream:!0});let G=f.indexOf(`
193
+ `).map((A)=>A.trim()).filter(Boolean).at(-1)?.trim()??""}function $C(D){return D.replace(dw,"")}function fC(D){return/^[╭╰│─\s]+$/u.test(D.trim())}function PC(D){let R=D.summary.added??0,A=D.summary.changed??0,$=D.files.length;if($===0)return"Source is up to date";let f=[];if(R>0)f.push(`${R} added`);if(A>0)f.push(`${A} changed`);let P=R+A;if($>P)f.push(`${$-P} removed`);return`${$} changed files (${f.join(", ")})`}function BC(D){return D.trim().slice(0,7)}async function DR(D,R,A){let $=await D.client.http.request({path:R,method:"GET",query:GC(A),secure:!0,format:void 0,headers:{Accept:"text/event-stream"}});if(!$.ok||!$.body)throw Error(`Failed to open log stream (${$.status} ${$.statusText})`);await zC($,(f)=>{let P=jG(f);console.log(P.message??P.line??"")})}async function uf(D,R){let A=new Set,$=!0;for(;;){let P=[...(await D.list()).items??[]].filter((B)=>B.id!==void 0&&B.id!==null).sort((B,G)=>(B.createdAt??"").localeCompare(G.createdAt??""));for(let B of P){if(D.since&&B.createdAt&&B.createdAt<D.since)continue;let G=Number(B.id);if(Number.isFinite(G)&&!A.has(G)){if(!$)D.onEvent(B);A.add(G)}}$=!1,await c0(R?.intervalMs??2000)}}function Ef(D){return(Array.isArray(D)?D:Array.isArray(D?.items)?D.items:[]).map(jG)}function jG(D){let R=D;return{time:R.time??R.timestamp??R.createdAt,message:R.message??R.line??"",pod:R.pod??R.source??"",container:R.container??""}}function GC(D){return Object.fromEntries(Object.entries(D).filter(([,R])=>R!==void 0&&R!==!1).map(([R,A])=>[R,typeof A==="boolean"?String(A):A]))}async function zC(D,R){let A=new TextDecoder,$=D.body.getReader(),f="";for(;;){let{done:P,value:B}=await $.read();if(P)break;f+=A.decode(B,{stream:!0});let G=f.indexOf(`
194
194
 
195
195
  `);while(G>=0){let z=f.slice(0,G);f=f.slice(G+2);let J=z.split(`
196
196
  `).filter((Z)=>Z.startsWith("data:")).map((Z)=>Z.slice(5).trim());if(J.length>0)R(JSON.parse(J.join(`
197
197
  `)));G=f.indexOf(`
198
198
 
199
- `)}}}var j6=_(async(D)=>{let R=NG();R.disposeSignal=I6(R);let A=D.options.image?"":YC(D.args.path),$=Object.assign(D,{deployState:R,manifestEntries:[],appDiff:{files:[],summary:{added:0,changed:0}},localGit:{},archivePath:void 0,deployment:void 0,ui:IG(C(D.options),A,D.app.name,D.options.verbose===!0)});try{if(!D.options.image)await MC($,A);else $.ui.completeScan(0);await XC($,A);let f=$.deployment;$.deployState.deploymentId=f.id??null,$.deployState.disposeSignal?.(),$.deployState.disposeSignal=I6($.deployState,async()=>{if(!$.deployState.cancellationRequested)$.deployState.cancellationRequested=!0,await PG({client:$.client,appId:$.app.id,deploymentId:f.id})}),await QC($)}finally{if($.archivePath)await SG($.archivePath,{force:!0}).catch(()=>{return});R.disposeSignal?.(),R.disposeSignal=void 0}});async function MC(D,R){D.manifestEntries=await wG(R),D.localGit=await zG(R),b2(D.deployState),D.ui.completeScan(D.manifestEntries.length)}async function XC(D,R){if(D.options.port!==void 0&&(!Number.isFinite(D.options.port)||D.options.port<=0))throw Error("Deploy port must be a positive number");try{D.deployment=await q6(D),D.ui.startDeploying(D.app.name),D.ui.completeDeploying();return}catch(A){if(D.deployState.aborted&&K6(A))throw Error("Deployment cancelled by user");let $=GG(A,D.manifestEntries);if(!$)throw A;D.appDiff=$.details,D.ui.showUploadRequired(D.appDiff),D.ui.startPackaging(D.appDiff.files.length),D.archivePath=await e5(R,D.appDiff.files),b2(D.deployState),D.ui.completePackaging(D.appDiff.files.length),D.ui.startUploading(D.app.name);let f=await AG(D,D.appDiff,D.archivePath,D.options.message??D.localGit.commitMessage,(P)=>D.ui.updateUploading(D.app.name,P));b2(D.deployState),D.ui.completeUploading(f.uploadedFiles,_C(f.uploadedBytes),f.commitSha),D.ui.startDeploying(D.app.name),D.deployment=await RG(D,c0),D.ui.completeDeploying()}finally{if(D.archivePath)await SG(D.archivePath,{force:!0}).catch(()=>{return}),D.archivePath=void 0}}async function QC(D){let R=D.deployment;D.ui.updatePhase(R.status??"pending");let A=0,$=R;try{$=await S2({initial:R,sleep:c0,shouldAbort:()=>D.deployState.aborted,onPoll:async(f)=>{if(TC(D,f))A=await OC(D,f,A)},onStatusChange:(f,P)=>{if(!C(D.options))UC(D,f,P);D.ui.updatePhase(P)},fetch:async(f)=>{try{return await $G({client:D.client,appId:D.app.id,deploymentId:f.id},D.deployState)}catch(P){if(D.deployState.aborted&&K6(P))return f;throw P}}})}finally{D.deployState.activeController?.abort(),D.deployState.activeController=null,D.deployState.logController?.abort(),D.deployState.logController=null}if(D.deployState.aborted)throw Error("Deployment cancelled by user");if(C(D.options))W($,!0);else{D.ui.finish($.status??"pending");let f=W2($,D.app.url);if(LA($)&&f)D.ui.note(`URL: ${f}`)}if(!LA($))throw Error(j2($,D.app.name));if(D.options.logs===!0&&!C(D.options))console.log("Following app logs"),await DR(D,`/v1/apps/${D.app.id}/logs`,{lines:10,stream:!0})}function TC(D,R){return!C(D.options)&&!K2(R.status)}async function OC(D,R,A){let f=(await fG({client:D.client,appId:D.app.id,deploymentId:R.id,offset:A,limit:100},D.deployState)).items??[];for(let P of f)D.ui.printLog(P.message??P.line??"",R.status??"pending");return A+f.length}function YC(D){return ZC.resolve(process.cwd(),D??".")}function _C(D){if(!Number.isFinite(D)||D<=0)return"0 B";let R=["B","KiB","MiB","GiB","TiB"],A=D,$=0;while(A>=1024&&$<R.length-1)A/=1024,$+=1;let f=A>=10||$===0?0:1;return`${A.toFixed(f)} ${R[$]}`}function UC(D,R,A){if(R==="building"&&["deploying","pulling","starting","ready","degraded"].includes(A)){D.ui.note("Build completed");return}if(R==="pulling"&&["starting","ready","degraded"].includes(A))D.ui.note("Image pulled")}var bG=_(async(D)=>{let A=(await D.client.api.appsDeploymentsList({appId:D.app.id})).items??[];if(C(D.options)){W(A,!0);return}s([{header:"Status",width:12,render:($)=>$.status??""},{header:"Method",width:8,render:($)=>$.method??""},{header:"Trigger",width:10,render:($)=>$.trigger??""},{header:"Message",width:28,render:($)=>$.message??""},{header:"Age",width:6,render:($)=>H0($.createdAt)},{header:"ID",width:9,render:($)=>String($.id)}],A)}),uG=_(async(D)=>{let R=Number(D.args.deployment),A=await D.client.api.appsDeploymentsDetail({appId:D.app.id,deploymentId:R});if(C(D.options)){W(A,!0);return}Zf(A)}),EG=_(async(D)=>{let R=Number(D.args.deployment);await D.client.api.appsDeploymentsCancelCreate({appId:D.app.id,deploymentId:R}),console.log(`Cancelled deployment ${R}`)}),yG=_(async(D)=>{let R=Number(D.args.deployment),A=await D.client.api.appsDeploymentsRollbackCreate({appId:D.app.id,deploymentId:R});if(C(D.options)){W(A,!0);return}console.log(`Rollback deployment ${A.id} created from deployment ${A.source?.rollbackFromDeploymentID}`)}),gG=_(async(D)=>{let R=Number(D.args.deployment),A=await D.client.api.appsDeploymentsLogsList({appId:D.app.id,deploymentId:R});W(A,C(D.options))}),mG=_(async(D)=>{let R=Number(D.args.deployment),A=await D.client.api.appsDeploymentsDetail({appId:D.app.id,deploymentId:R}),$=await S2({initial:A,sleep:c0,fetch:async()=>await D.client.api.appsDeploymentsDetail({appId:D.app.id,deploymentId:R}),onStatusChange:(f,P)=>{if(!C(D.options))console.log(`Status: ${P}`)}});if(C(D.options)){W($,!0);return}if(LA($)){console.log("Ready");let f=W2($,D.app.url);if(f)console.log(`URL: ${f}`);return}D.abort(j2($,D.app.name))});var RR=_(async(D,R)=>{let $=((await D.client.api.appsDisksList({appId:D.app.id})).items??[]).find((f)=>V4(f,D.args.disk));if(!$)D.abort(`Disk not found: ${D.args.disk}`);D.disk=$,await R()}),xG=_(async(D)=>{let A=(await D.client.api.appsDisksList({appId:D.app.id})).items??[];if(C(D.options)){W(A,!0);return}Qf(A)}),nG=_(async(D)=>{let R=await D.client.api.appsDisksDetail({appId:D.app.id,diskId:D.disk.id});if(C(D.options)){W(R,!0);return}kD(R)}),pG=_(async(D)=>{if(!Number.isFinite(D.options.size)||D.options.size<=0)D.abort("Disk size must be a positive number");let R=await D.client.api.appsDisksCreate({appId:D.app.id},{name:D.args.name,size:D.options.size});if(C(D.options)){W(R,!0);return}kD(R)}),hG=_(async(D)=>{let R=await D.client.api.appsDisksMountCreate({appId:D.app.id,diskId:D.disk.id},{mountPath:D.args.mountPath});if(C(D.options)){W(R,!0);return}kD(R)}),vG=_(async(D)=>{let R=await D.client.api.appsDisksUnmountCreate({appId:D.app.id,diskId:D.disk.id});if(C(D.options)){W(R,!0);return}kD(R)}),lG=_(async(D)=>{if(!Number.isFinite(D.options.size)||D.options.size<=0)D.abort("Disk size must be a positive number");let R=await D.client.api.appsDisksExpandCreate({appId:D.app.id,diskId:D.disk.id},{size:D.options.size});if(C(D.options)){W(R,!0);return}kD(R)}),kG=_(async(D)=>{if(await D.client.api.appsDisksDelete({appId:D.app.id,diskId:D.disk.id}),C(D.options)){W({deleted:!0,id:D.disk.id,name:D.disk.name},!0);return}console.log(`Deleted disk ${D.disk.name}`)});var dG=_(async(D)=>{let R=await D.client.api.appsDomainsList({appId:D.app.id});if(C(D.options)){W(R,!0);return}s([{header:"Hostname",width:36,render:(A)=>A.hostname??""},{header:"Verify",width:12,render:(A)=>A.verificationStatus??""},{header:"TLS",width:12,render:(A)=>A.tlsStatus??""},{header:"TLS On",width:8,render:(A)=>A.tlsEnabled?"yes":"no"},{header:"HTTPS",width:8,render:(A)=>A.forceHttps?"yes":"no"},{header:"Age",width:6,render:(A)=>H0(A.createdAt)}],R)}),iG=_(async(D,R)=>{D.domain=await D.client.api.appsDomainsCreate({appId:D.app.id},{hostname:D.args.hostname,tlsEnabled:D.options.tlsMode==="disabled"?!1:!0,forceHttps:D.options.forceHttps}),await R()}),aG=_(async(D)=>{if(C(D.options)){W(D.domain,!0);return}Xf(D.domain)}),rG=_(async(D)=>{let A=(await D.client.api.appsDomainsList({appId:D.app.id})).find(($)=>$.hostname===D.args.hostname);if(!A)D.abort(`Domain not found: ${D.args.hostname}`);await D.client.api.appsDomainsDelete({appId:D.app.id,domainId:A.id}),console.log(`Removed domain ${A.hostname}`)}),sG=_(async(D)=>{let A=(await D.client.api.appsDomainsList({appId:D.app.id})).find((f)=>f.hostname===D.args.hostname);if(!A)D.abort(`Domain not found: ${D.args.hostname}`);let $=await D.client.api.appsDomainsVerifyCreate({appId:D.app.id,domainId:A.id});W($,C(D.options))}),oG=_(async(D)=>{let R=await D.client.api.appsDomainsAvailabilityList({appId:D.app.id,hostname:D.args.hostname});W(R,C(D.options))});var cG=_(async(D)=>{let R=S6(await D.client.api.appsEnvList({appId:D.app.id}));if(C(D.options)){W(R,!0);return}Mf(R)}),tG=_(async(D)=>{let R=F4(D.args.entry),$=[...S6(await D.client.api.appsEnvList({appId:D.app.id})).filter((f)=>y2(f)!==R.key),{name:R.key,value:R.value}];await D.client.api.appsEnvUpdate({appId:D.app.id},{items:$}),await D.client.api.appsApplyCreate({appId:D.app.id}),console.log(`Updated ${R.key}`)}),eG=_(async(D)=>{let A=S6(await D.client.api.appsEnvList({appId:D.app.id})).filter(($)=>y2($)!==D.args.key).map(($)=>({name:y2($),value:Dz($)}));await D.client.api.appsEnvUpdate({appId:D.app.id},{items:A}),await D.client.api.appsApplyCreate({appId:D.app.id}),console.log(`Removed ${D.args.key}`)});function S6(D){return(Array.isArray(D)?D:Array.isArray(D?.items)?D.items:[]).map((A)=>{let $=A;return{key:y2($),value:Dz($),updatedAt:$.updatedAt??""}})}function y2(D){return D.name??D.key??""}function Dz(D){return D.value??""}var Rz=_(async(D)=>{await D.client.api.appsStartCreate({appId:D.app.id}),console.log(`Started app ${D.app.name}`)}),Az=_(async(D)=>{await D.client.api.appsStopCreate({appId:D.app.id}),console.log(`Stopped app ${D.app.name}`)}),$z=_(async(D)=>{await D.client.api.appsRestartCreate({appId:D.app.id}),console.log(`Restarted app ${D.app.name}`)});var fz=_(async(D)=>{if(C(D.options)){W(D.app,!0);return}Hf(D.app)});var b6=_(async(D)=>{let A=(await D.client.api.appsList()).items??[];if(C(D.options)){W(A,!0);return}s([{header:"Project",width:22,render:()=>D.project.name},{header:"Name",width:22,render:($)=>$.name??""},{header:"Status",width:12,render:($)=>$.status??""},{header:"Plan",width:12,render:($)=>$.plan??""},{header:"Bundle",width:12,render:($)=>$.bundle??""},{header:"Age",width:6,render:($)=>H0($.createdAt)},{header:"URL",width:36,render:($)=>$.url??""}],A)});var Pz=_(async(D)=>{let R=_0(D.options.tail)??10,A={since:D.options.since,lines:R,filter:D.options.filter,previous:D.options.previous,stream:D.options.follow};if(D.options.follow&&!C(D.options)){await DR(D,`/v1/apps/${D.app.id}/logs`,A);return}let $=await D.client.api.appsLogsList({appId:D.app.id,...A});if(C(D.options)){W($,!0);return}OR(E2($))}),Bz=_(async(D)=>{if(D.options.watch){await u2({list:()=>D.client.api.appsEventsList({appId:D.app.id,limit:50,offset:0}),since:D.options.since,onEvent:(f)=>{TR(f),console.log()}});return}let R=_0(D.options.tail)??10,$=(await D.client.api.appsEventsList({appId:D.app.id,limit:R,offset:0})).items??[];if(C(D.options)){W($,!0);return}QR($)});var nL=B0(R7(),1),pL=B0(l2(),1),hL=B0(fR(),1),vL=B0(x6(),1),lL=B0(p6(),1),kL=B0(i6(),1),z7=B0(a2(),1),dL=B0(G7(),1);var g0=z7.default;var J7=_(async(D)=>{if(D.token.startsWith("abr_"))D.abort("App shell requires session authentication. Run `abrun login --email <email>` and try again.");let R=iA(D.endpoint,`/v1/apps/${D.app.id}/console`,{command:"shell"});await new Promise((A,$)=>{let f=new g0(R,{headers:{Authorization:`Bearer ${D.token}`,"User-Agent":UR,"x-project-id":String(D.project.id)}}),P=process.stdin,B=process.stdout,G=P.isTTY?P.isRaw:void 0,z=!1,J=!1,Z=()=>{if(P.off("data",M),P.off("end",Q),B.off("resize",O),f.off("open",U),f.off("message",F),f.off("error",X),f.off("close",T),P.isTTY)P.pause(),P.setRawMode(G??!1)},H=(w,V=0)=>{if(J)return;if(J=!0,Z(),w){$(w);return}process.exitCode=V,A()},M=(w)=>{if(f.readyState===g0.OPEN)f.send(w,{binary:!0})},Q=()=>{if(f.readyState===g0.OPEN)f.send(JSON.stringify({type:"close"}))},O=()=>{if(!P.isTTY||f.readyState!==g0.OPEN||!z)return;f.send(JSON.stringify({type:"resize",cols:B.columns,rows:B.rows}))},X=(w)=>{H(w)},T=()=>{H()},U=()=>{if(z=!0,P.on("data",M),P.on("end",Q),P.isTTY)P.resume(),P.setRawMode(!0);if(B.isTTY)B.on("resize",O),O()},F=(w,V)=>{if(V){let j=Array.isArray(w)?Buffer.concat(w.map((u)=>Buffer.isBuffer(u)?u:Buffer.from(u))):Buffer.isBuffer(w)?w:Buffer.from(w);B.write(j);return}let I=JSON.parse(String(w));if(I.type==="ready")return;if(I.type==="started"){if(z=!0,P.isTTY)P.resume(),P.setRawMode(!0),O();return}if(I.type==="error"){H(Error(I.message));return}if(I.type==="exit"){if(f.readyState===g0.OPEN)f.close();H(void 0,I.exitCode??(I.succeeded?0:1))}};f.on("open",U),f.on("message",F),f.on("error",X),f.on("close",T)})});var H7=_(async(D)=>{let R=D.options.plan!==void 0||D.options.bundle!==void 0,A=D.options.defaultDomain!==void 0||D.options.securityProfile!==void 0;if(R)D.abort("Use `abrun app resize` for plan and bundle changes.");if(!A)D.abort("Nothing to update. Use --security-profile.");if(D.options.defaultDomain!==void 0)D.abort("Updating default domains is not implemented by the public API.");let $=await D.client.api.appsPartialUpdate({appId:D.app.id},{buildConfig:D.app.buildConfig,image:D.app.image,name:D.app.name,port:D.app.port,runtimeConfig:D.app.runtimeConfig,securityProfile:D.options.securityProfile});if(C(D.options)){W($,!0);return}console.log(`Updated app ${$.name} (${$.status})`)}),Z7=_(async(D)=>{let R=await D.client.api.appPlansList(),A=D.options.plan!==void 0||D.options.bundle===void 0&&await p1(D,"Change app plan?","Use --plan and/or --bundle, or run in an interactive terminal."),$=A?await iL(D,R):dD(R,void 0,W4(D.app)),f=await D.client.api.appPlansBundlesList({planName:$.name}),P=D.options.bundle!==void 0||D.options.plan===void 0&&await p1(D,"Change app bundle?","Use --plan and/or --bundle, or run in an interactive terminal."),B=P?await aL(D,f):iD(f,void 0,j4(D.app));if(!A&&!P)D.abort("Nothing to resize.");let G=await D.client.api.appsResizeCreate({appId:D.app.id},{plan:$.name,bundle:B.name});if(C(D.options)){W(G,!0);return}console.log(`Resized app ${G.name} (${G.status})`)});async function iL(D,R){return D.options.plan?.trim()?dD(R,D.options.plan.trim()):uB(D,R)}async function aL(D,R){return D.options.bundle?.trim()?iD(R,D.options.bundle.trim()):EB(D,R)}function M7(D){let R=D.command("app").description("Manage apps").onions([D0]);D.command("apps").description("List apps").onions([N,K,Y,b,Y,b6]),D.command("deploy").description("Deploy source or an image to an app").argument("<app>").argument("[path]").option("--image <image>","Deploy an image instead of source").option("--port <port>","Update runtime port for this deploy",(B)=>Number(B)).option("--message <message>","Deployment message").option("--logs","Follow app logs after a successful deploy").option("--verbose","Print raw build and rollout logs").onions([N,K,Y,b,Y,x,j6]),R.command("list").alias("ls").description("List apps").onions([N,K,Y,b,Y,b6]),R.command("inspect").alias("get").description("Inspect one app").argument("<app>").onions([N,K,Y,b,Y,x,fz]),R.command("events").description("List app events").argument("<app>").option("--watch","Watch app events continuously").option("--tail <count>","Number of recent events to fetch",_0).option("--since <value>","Only include events since an ISO timestamp or relative value like 5h").onions([N,K,Y,b,Y,x,Bz]),R.command("logs").description("Fetch app runtime logs").argument("<app>").option("--tail <count>","Number of recent log lines to fetch",_0).option("--since <value>","Only include logs since an ISO timestamp or relative value like 5h").option("--filter <pattern>","Filter log messages with a regular expression").option("--previous","Fetch previous crashed container logs").option("--follow","Stream logs continuously").onions([N,K,Y,b,Y,x,Pz]),R.command("create").description("Create an app").argument("<name>").option("--plan <name>","Plan name").option("--bundle <name>","Bundle name").option("--port <port>","Runtime port",lA).option("--security-profile <profile>","Runtime security profile",_D(["restricted","compatible"])).onions([N,K,Y,b,Y,yB,gB]),R.command("update").description("Update app settings").argument("<app>").option("--default-domain <hostname>","Set app default domain").option("--security-profile <profile>","Runtime security profile",_D(["restricted","compatible"])).onions([N,K,Y,b,Y,x,H7]),R.command("resize").description("Resize an app plan or bundle").argument("<app>").option("--plan <name>","Plan name").option("--bundle <name>","Bundle name").onions([N,K,Y,b,Y,x,Z7]),R.command("delete").alias("rm").description("Delete an app").argument("<app>").onions([N,K,Y,b,Y,x,mB]),R.command("start").description("Start an app").argument("<app>").onions([N,K,Y,b,Y,x,Rz]),R.command("stop").description("Stop an app").argument("<app>").onions([N,K,Y,b,Y,x,Az]),R.command("restart").description("Restart an app").argument("<app>").onions([N,K,Y,b,Y,x,$z]),R.command("shell").alias("exec").description("Open an interactive shell in an app").argument("<app>").onions([N,K,Y,b,Y,x,J7]),R.command("deploy").description("Deploy source or an image").argument("<app>").argument("[path]").option("--image <image>","Deploy an image instead of source").option("--port <port>","Update runtime port for this deploy",(B)=>Number(B)).option("--message <message>","Deployment message").option("--logs","Follow app logs after a successful deploy").option("--verbose","Print raw build and rollout logs").onions([N,K,Y,b,Y,x,j6]);let A=R.command("disk").description("Manage app disks").onions([D0]);A.command("list").alias("ls").description("List disks").argument("<app>").onions([N,K,Y,b,Y,x,xG]),A.command("inspect").alias("get").description("Inspect one disk").argument("<app>").argument("<disk>").onions([N,K,Y,b,Y,x,RR,nG]),A.command("create").description("Create a disk").argument("<app>").argument("<name>").option("--size <size>","Disk size in GB",(B)=>Number(B)).onions([N,K,Y,b,Y,x,pG]),A.command("mount").description("Mount a disk").argument("<app>").argument("<disk>").argument("<mountPath>").onions([N,K,Y,b,Y,x,RR,hG]),A.command("unmount").description("Unmount a disk").argument("<app>").argument("<disk>").onions([N,K,Y,b,Y,x,RR,vG]),A.command("expand").description("Expand a disk").argument("<app>").argument("<disk>").option("--size <size>","New disk size in GB",(B)=>Number(B)).onions([N,K,Y,b,Y,x,RR,lG]),A.command("delete").alias("rm").description("Delete a disk").argument("<app>").argument("<disk>").onions([N,K,Y,b,Y,x,RR,kG]);let $=R.command("env").description("Manage app environment variables").onions([D0]);$.command("list").alias("ls").description("List env vars").argument("<app>").onions([N,K,Y,b,Y,x,cG]),$.command("set").description("Set an env var").argument("<app>").argument("<entry>").onions([N,K,Y,b,Y,x,tG]),$.command("unset").description("Remove an env var").argument("<app>").argument("<key>").onions([N,K,Y,b,Y,x,eG]);let f=R.command("domain").description("Manage app domains").onions([D0]);f.command("list").alias("ls").description("List domains").argument("<app>").onions([N,K,Y,b,Y,x,dG]),f.command("add").description("Add a domain").argument("<app>").argument("<hostname>").option("--tls-mode <mode>","TLS mode",_D(["auto","manual","disabled"])).option("--force-https","Force HTTPS redirect").onions([N,K,Y,b,Y,x,iG,aG]),f.command("delete").alias("rm").description("Delete a domain").argument("<app>").argument("<hostname>").onions([N,K,Y,b,Y,x,rG]),f.command("verify").description("Verify a domain").argument("<app>").argument("<hostname>").onions([N,K,Y,b,Y,x,sG]),f.command("check").description("Check domain availability").argument("<app>").argument("<hostname>").onions([N,K,Y,b,Y,x,oG]);let P=R.command("deployment").description("Manage deployments").onions([D0]);P.command("list").alias("ls").description("List deployments").argument("<app>").onions([N,K,Y,b,Y,x,bG]),P.command("inspect").alias("get").description("Inspect one deployment").argument("<app>").argument("<deployment>").onions([N,K,Y,b,Y,x,uG]),P.command("logs").description("Fetch deployment logs").argument("<app>").argument("<deployment>").onions([N,K,Y,b,Y,x,gG]),P.command("watch").description("Watch a deployment").argument("<app>").argument("<deployment>").onions([N,K,Y,b,Y,x,mG]),P.command("cancel").description("Cancel a deployment").argument("<app>").argument("<deployment>").onions([N,K,Y,b,Y,x,EG]),P.command("rollback").description("Roll back to the last ready deployment").argument("<app>").argument("<deployment>").onions([N,K,Y,b,Y,x,yG])}import{execFile as rL}from"node:child_process";import{promisify as sL}from"node:util";var oL=sL(rL),Q7=_(async(D)=>{let R=D.endpoint,A;if(D.options.token){let P=await aD({endpoint:R,token:D.options.token}).api.authMeList();A={token:D.options.token,expiresAt:"",user:P}}else if(D.options.browser){let P=await D.client.api.authCliLoginStartOrPoll({deviceName:`abrun ${jf}`}),B=DN(P,R);console.log(`Open: ${B}`),await RN(B),A=await eL(R,P)}else{let P=await cL(D),B=await tL(D);A=await D.client.api.authLoginCreate({email:P,password:B})}let $=D.options.label??A.user.email,f={id:String(A.user.id),label:$,email:A.user.email,token:A.token,endpoint:R,userId:A.user.id,expiresAt:A.expiresAt};D.state.auths=[...D.state.auths.filter((P)=>P.id!==f.id),f],D.state.currentAuthId=f.id,await p0(D.state),o0({auth:$,email:A.user.email,endpoint:R})});async function cL(D){let R=D.options.email?.trim();if(R)return R;if(!T7(D.options))D.abort("Email is required. Use --email or run in an interactive terminal.");let A=(await VR({message:"Email"})).trim();if(!A)D.abort("Email is required.");return A}async function tL(D){if(D.options.password)return D.options.password;if(!T7(D.options))D.abort("Password is required. Use --password or run in an interactive terminal.");let R=await ef({message:"Password",mask:"*"});if(!R)D.abort("Password is required.");return R}function T7(D){return Boolean(process.stdin.isTTY&&process.stdout.isTTY&&!C(D))}var O7=_(async(D)=>{if(D.options.all){await Promise.all(D.state.auths.map((A)=>X7(A.endpoint??D.endpoint,A.token))),D.state.auths=[],D.state.currentAuthId=void 0,D.state.currentProjectByAuthId={},await p0(D.state),console.log("All local auth entries removed.");return}let R=D.state.currentAuthId?D.state.auths.find((A)=>A.id===D.state.currentAuthId):D.state.auths[0];if(!R){console.log("No saved auth.");return}if(await X7(R.endpoint??D.endpoint,R.token),D.state.auths=D.state.auths.filter((A)=>A.id!==R.id),D.state.currentAuthId===R.id)D.state.currentAuthId=D.state.auths[0]?.id;delete D.state.currentProjectByAuthId[R.id],await p0(D.state),console.log(`Removed auth ${R.label}`)}),Y7=_(async(D)=>{let R=await D.client.api.authMeList();o0({auth:D.auth.label,email:R.email,endpoint:D.endpoint,expiresIn:hA(D.auth.expiresAt)})}),_7=_(async(D)=>{if(C(D.options)){W(D.state.auths,!0);return}s([{header:"Current",width:7,render:(R)=>R.id===D.state.currentAuthId?"*":""},{header:"Auth",width:18,render:(R)=>R.label},{header:"Email",width:28,render:(R)=>R.email},{header:"Endpoint",width:36,render:(R)=>R.endpoint}],D.state.auths)}),U7=_(async(D)=>{let R=D.state.auths.find((A)=>YR(A,D.args.auth));if(!R)D.abort(`Auth not found: ${D.args.auth}`);D.state.currentAuthId=R.id,await p0(D.state),console.log(`Current auth: ${R.label}`)}),F7=_(async(D)=>{let R=D.state.auths.find((A)=>YR(A,D.args.auth));if(!R)D.abort(`Auth not found: ${D.args.auth}`);if(D.state.auths=D.state.auths.filter((A)=>A.id!==R.id),D.state.currentAuthId===R.id)D.state.currentAuthId=D.state.auths[0]?.id;delete D.state.currentProjectByAuthId[R.id],await p0(D.state),console.log(`Removed auth: ${R.label}`)});async function eL(D,R){if(!R.pollToken)throw Error("CLI login did not return a poll token.");let A=aD({endpoint:D});for(;;){let $=await A.api.authCliLoginStartOrPoll({pollToken:R.pollToken});if($.status==="allowed"&&$.token){let f=await aD({endpoint:D,token:$.token}).api.authMeList();return{token:$.token,expiresAt:"",user:f}}await c0(($.pollIntervalSeconds??R.pollIntervalSeconds??2)*1000)}}function DN(D,R){let A=D.browserURL;if(A)return A;let $=new URL(R);if($.hostname.startsWith("api."))$.hostname=$.hostname.slice(4);return $.pathname="/cli-login",$.search="",$.toString()}async function RN(D){let R=process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open",A=process.platform==="win32"?["/c","start","",D]:[D];try{await oL(R,A)}catch{console.log("Open the URL above in your browser to continue.")}}async function X7(D,R){try{await aD({endpoint:D,token:R}).api.authLogoutCreate()}catch{}}function q7(D){D.command("login").description("Login with email/password, token, or browser approval").option("--token <token>","API token").option("--email <email>","User email for password login").option("--password <password>","User password for password login").option("--label <label>","Saved auth label").option("--browser","Use browser approval flow").onions([N,Y,Q7]),D.command("logout").description("Remove the current saved auth").option("--all","Remove all saved auth entries").onions([N,O7]),D.command("whoami").description("Show the current authenticated identity").onions([N,K,Y,Y7]);let R=D.command("auth").description("Manage saved auth entries").onions([D0]);R.command("list").alias("ls").description("List saved auth entries").onions([N,_7]),R.command("use").description("Switch current auth").argument("<auth>").onions([N,U7]),R.command("remove").alias("rm").description("Remove a saved auth entry").argument("<auth>").onions([N,F7])}var w7=_(async(D,R)=>{let $=((await D.client.api.databasesBackupsList({databaseId:D.database.id})).items??[]).find((f)=>String(f.id)===D.args.backup);if(!$)D.abort(`Database backup not found: ${D.args.backup}`);D.backup=$,await R()}),C7=_(async(D)=>{let A=(await D.client.api.databasesBackupsList({databaseId:D.database.id})).items??[];if(C(D.options)){W(A,!0);return}Cf(A)}),L7=_(async(D)=>{let R=await D.client.api.databasesBackupsDetail({databaseId:D.database.id,backupId:D.backup.id});if(C(D.options)){W(R,!0);return}xA(R)}),N7=_(async(D)=>{let R=await D.client.api.databasesBackupsCreate({databaseId:D.database.id});if(C(D.options)){W(R,!0);return}xA(R)});async function bA(D,R){return D.client.api.databasesDetail({databaseId:R})}async function s2(D){return D.client.api.databasesList({})}async function V7(D,R){return D.client.api.databasesCreate({name:R.name,engine:R.engine,version:R.version,plan:R.plan,bundle:R.bundle,publicAccess:R.published,password:R.password,engineConfig:K7(R.configOverrides)})}async function a6(D,R,A){let $={publicAccess:A.publicAccess,engineConfig:K7(A.configOverrides)};if(A.plan!==void 0||A.bundle!==void 0)await D.client.api.databasesResizeCreate({databaseId:R},{plan:A.plan,bundle:A.bundle});if($.publicAccess===void 0&&$.engineConfig===void 0)return bA(D,R);return D.client.api.databasesPartialUpdate({databaseId:R},$)}async function L1(D){return{items:await D.client.api.databasePlansList()}}async function o2(D){return(await D.client.api.databaseEnginesList()).filter((A)=>A.name).map((A)=>({engine:A.name,versions:A.versions??[]}))}async function HR(D,R){return await D.client.api.databasePlansBundlesList({planName:R})}function I7(D,R){let A=D.find(($)=>$.engine===R);if(!A)throw Error(`Unsupported database engine: ${R}`);return A}function K7(D){if(!D?.trim())return;return JSON.parse(D)}var W7=_(async(D)=>{let R=D.options.plan?.trim();if(!R)D.abort("Database bundle list requires --plan because bundles are resolved per plan.");let A=await HR(D,R);if(C(D.options)){W(A,!0);return}qf(A)}),j7=_(async(D)=>{let R=await L1(D),A=UD(R.items??[],D.options.plan),f=(await HR(D,A.name)).find((P)=>dA(P,D.args.bundle));if(!f)D.abort(`Database bundle not found: ${D.args.bundle}`);if(C(D.options)){W(f,!0);return}wf(f)});var S7=_(async(D)=>{let R=await o2(D);if(C(D.options)){W(R,!0);return}Uf(R)});var VE=_(async(D)=>{let A=(await L1(D)).items??[];if(C(D.options)){W(A,!0);return}_f(A)}),b7=_(async(D)=>{let A=(await D.client.api.databasePlansList()).find(($)=>kA($,D.args.plan));if(!A)D.abort(`Database plan not found: ${D.args.plan}`);if(C(D.options)){W(A,!0);return}Ff(A)});var r6=B0(mA(),1);var s6=_(async(D)=>{let A=(await s2(D)).items??[];if(C(D.options)){W(A,!0);return}Yf(D.project.name,A)}),u7=_(async(D)=>{let R=await bA(D,D.database.id);if(C(D.options)){W(R,!0);return}Tf(R)}),E7=_(async(D)=>{let R=await D.client.api.databasesCredentialsList({databaseId:D.database.id});if(C(D.options)){if(!D.options.reveal&&!D.options.showPassword)D.abort("Refusing to print database credentials as JSON without --show-password.");W(R,!0);return}Of(D.database.name,R,{reveal:D.options.reveal||D.options.showPassword})}),y7=_(async(D)=>{let R=await o2(D),A=D.options.engine?.trim()||await h0(D,"Select database engine",R.map((Z)=>({value:Z.engine,name:Z.engine})),"Database engine is required. Use --engine or run in an interactive terminal."),$=I7(R,A),f=D.options.version?.trim()||await h0(D,`Select ${A} version`,$.versions.map((Z)=>({value:Z,name:Z})),"Database version is required. Use --version or run in an interactive terminal.",{forcePromptSingle:!0}),P=await L1(D),B=D.options.plan?.trim()?UD(P.items??[],D.options.plan.trim()):await QP(D,P.items??[]),G=await HR(D,B.name),z=D.options.bundle?.trim()?V1(G,D.options.bundle.trim()):await TP(D,G),J=await V7(D,{name:D.args.name,engine:A,plan:B.name,bundle:z.name,password:D.options.password,published:D.options.publicAccess,version:f,configOverrides:D.options.config});if(C(D.options)){W(J,!0);return}console.log(`Created database ${J.database.name} (${J.database.status})`),console.log(),console.log(r6.default.bold("password")),console.log(r6.default.yellow(J.password??""))}),g7=_(async(D)=>{let R=D.options.config!==void 0||D.options.publicAccess!==void 0;if(D.options.plan!==void 0||D.options.bundle!==void 0)D.abort("Use `abrun database resize` for plan and bundle changes.");if(!R)D.abort("Nothing to update. Use --config, --public-access, or --no-public-access.");let A=await a6(D,D.database.id,{configOverrides:D.options.config,publicAccess:D.options.publicAccess});if(C(D.options)){W(A,!0);return}console.log(`Updated database ${A.name} (${A.status})`)}),m7=_(async(D)=>{let R=await L1(D),A=D.options.plan!==void 0||D.options.bundle===void 0&&await p1(D,"Change database plan?","Use --plan and/or --bundle, or run in an interactive terminal."),$=D.options.plan?.trim()?UD(R.items??[],D.options.plan.trim()):A?await QP(D,R.items??[]):UD(R.items??[],void 0,D.database.plan),f=await HR(D,$.name),P=D.options.bundle!==void 0||D.options.plan===void 0&&await p1(D,"Change database bundle?","Use --plan and/or --bundle, or run in an interactive terminal."),B=D.options.bundle?.trim()?V1(f,D.options.bundle.trim()):P?await TP(D,f):V1(f,void 0,D.database.bundle);if(!A&&!P)D.abort("Nothing to resize.");let G=await a6(D,D.database.id,{plan:$.name,bundle:B.name});if(C(D.options)){W(G,!0);return}console.log(`Resized database ${G.name} (${G.status})`)}),x7=_(async(D)=>{if(await D.client.api.databasesDelete({databaseId:D.database.id}),C(D.options)){W({deleted:!0,id:D.database.id,name:D.database.name},!0);return}console.log(`Removed database ${D.database.name}`)}),n7=_(async(D)=>{await D.client.api.databasesStartCreate({databaseId:D.database.id});let R=await bA(D,D.database.id);console.log(`Started database ${R.name} (${R.status})`)}),p7=_(async(D)=>{await D.client.api.databasesStopCreate({databaseId:D.database.id});let R=await bA(D,D.database.id);console.log(`Stopped database ${R.name} (${R.status})`)}),h7=_(async(D)=>{let R=await D.client.api.databasesUsageList({databaseId:D.database.id});if(C(D.options)){W(R,!0);return}Lf(R)});var J0=_(async(D,R)=>{let $=((await s2(D)).items??[]).find((f)=>I4(f,D.args.database));if(!$)D.abort(`Database not found: ${D.args.database}`);D.database=$,await R()});var v7=_(async(D)=>{let R=_0(D.options.tail)??10,A={since:D.options.since,lines:R,filter:D.options.filter,previous:D.options.previous,stream:D.options.follow};if(D.options.follow&&!C(D.options)){await DR(D,`/v1/databases/${D.database.id}/logs`,A);return}let $=await D.client.api.databasesLogsList({databaseId:D.database.id,...A});if(C(D.options)){W($,!0);return}OR(E2($))}),l7=_(async(D)=>{if(D.options.watch){await u2({list:()=>D.client.api.databasesEventsList({databaseId:D.database.id,limit:50,offset:0}),since:D.options.since,onEvent:(f)=>{TR(f),console.log()}});return}let R=_0(D.options.tail)??10,$=(await D.client.api.databasesEventsList({databaseId:D.database.id,limit:R,offset:0})).items??[];if(C(D.options)){W($,!0);return}QR($)});import AN from"node:net";function $N(D){let R=D.host?.trim()||"127.0.0.1",A=D.port;if(A===void 0)throw Error("--port is required.");return{host:R,port:A}}function fN(D,R){return["Tunnel established","",`Database: ${D.name}`,`Engine: ${D.engine??""}`,`Local: ${R}`].join(`
200
- `)}var k7=_(async(D)=>{let{host:R,port:A}=$N(D.options),$=`${R}:${A}`,f=new Set,P=AN.createServer((B)=>{f.add(B),B.on("close",()=>f.delete(B)),B.on("error",()=>f.delete(B)),B.pause();let G=iA(D.endpoint,`/v1/databases/${D.database.id}/tunnel`),z=new g0(G,{headers:{Authorization:`Bearer ${D.token}`,"User-Agent":UR,"x-project-id":String(D.project.id)}}),J=!1,Z=!1,H=()=>{if(J)return;if(J=!0,B.destroy(),z.readyState===g0.OPEN||z.readyState===g0.CONNECTING)z.close()},M=(Q)=>{console.error(Q),P.close(),H()};B.on("data",(Q)=>{if(z.readyState===g0.OPEN)z.send(Q,{binary:!0})}),B.on("end",()=>{Z=!0,H()}),B.on("error",()=>{Z=!0,H()}),B.on("close",()=>{Z=!0,H()}),z.on("open",()=>{B.resume()}),z.on("message",(Q,O)=>{if(!O)return;let X=Array.isArray(Q)?Buffer.concat(Q.map((T)=>Buffer.isBuffer(T)?T:Buffer.from(T))):Buffer.isBuffer(Q)?Q:Buffer.from(Q);B.write(X)}),z.on("error",(Q)=>{if(!Z)M(`Tunnel connection failed: ${Q.message}`)}),z.on("close",(Q,O)=>{if(!Z&&Q!==1000){let X=O.length>0?`: ${O.toString()}`:"";M(`Tunnel connection closed${X}`)}H()})});await new Promise((B,G)=>{let z=!1,J=!1,Z=()=>{process.off("SIGINT",M),process.off("SIGTERM",M),P.off("error",Q),P.off("close",O),P.off("listening",X);for(let T of f)T.destroy()},H=(T)=>{if(J)return;if(J=!0,Z(),T){G(T);return}B()},M=()=>{P.close();for(let T of f)T.destroy()},Q=(T)=>{H(T)},O=()=>{if(z)H()},X=()=>{z=!0,console.log(fN(D.database,$))};process.once("SIGINT",M),process.once("SIGTERM",M),P.once("error",Q),P.once("close",O),P.once("listening",X),P.listen(A,R)})});function d7(D){let R=D.command("database").description("Manage databases").onions([D0]);R.alias("db"),D.command("dbs").description("List databases").onions([N,K,Y,b,Y,s6]),R.command("credentials").description("Get database credentials").argument("<database>").option("--reveal","Show plaintext password in human output").option("--show-password","Show plaintext password in human output").onions([N,K,Y,b,Y,J0,E7]),R.command("events").description("List database events").argument("<database>").option("--watch","Watch database events continuously").option("--tail <count>","Number of recent events to fetch",_0).option("--since <value>","Only include events since an ISO timestamp or relative value like 5h").onions([N,K,Y,b,Y,J0,l7]),R.command("logs").description("Fetch database runtime logs").argument("<database>").option("--tail <count>","Number of recent log lines to fetch",_0).option("--since <value>","Only include logs since a relative value like 5h").option("--filter <pattern>","Filter log messages with a regular expression").option("--previous","Fetch previous crashed container logs").option("--follow","Stream logs continuously").onions([N,K,Y,b,Y,J0,v7]),R.command("tunnel").description("Open a local TCP tunnel to a database").argument("<database>").option("--port <port>","Local TCP port",lA).option("--host <host>","Local bind host").onions([N,K,Y,b,Y,J0,k7]),R.command("list").alias("ls").description("List databases").onions([N,K,Y,b,Y,s6]),R.command("inspect").alias("get").description("Inspect one database").argument("<database>").onions([N,K,Y,b,Y,J0,u7]),R.command("create").description("Create a database").argument("<name>").option("--engine <engine>","Database engine",_D(["mysql","postgres","redis"])).option("--plan <name>","Plan name").option("--bundle <name>","Bundle name").option("--password <password>","Primary database password").option("--public-access","Enable public database access").option("--version <version>","Database engine version").option("--config <text>","Additional config overrides text").onions([N,K,Y,b,Y,y7]),R.command("update").description("Update a database").argument("<database>").option("--config <text>","Additional config overrides text").option("--public-access","Enable public database access").option("--no-public-access","Disable public database access").onions([N,K,Y,b,Y,J0,g7]),R.command("resize").description("Resize a database plan or bundle").argument("<database>").option("--plan <name>","Plan name").option("--bundle <name>","Bundle name").onions([N,K,Y,b,Y,J0,m7]),R.command("delete").alias("rm").description("Delete a database").argument("<database>").onions([N,K,Y,b,Y,J0,x7]),R.command("start").description("Start a database").argument("<database>").onions([N,K,Y,b,Y,J0,n7]),R.command("stop").description("Stop a database").argument("<database>").onions([N,K,Y,b,Y,J0,p7]),R.command("metrics").description("Get current database metrics").argument("<database>").onions([N,K,Y,b,Y,J0,h7]),R.command("plan").description("Manage database plans").onions([D0]).command("inspect").alias("get").description("Inspect one database plan").argument("<plan>").onions([N,K,Y,b7]),R.command("engine").description("List available database engines and versions").onions([D0]).command("list").alias("ls").description("List database engines").onions([N,K,Y,S7]);let f=R.command("bundle").description("Manage database bundles").onions([D0]);f.command("list").alias("ls").description("List database bundles for a plan").option("--plan <name>","Plan name").onions([N,K,Y,W7]),f.command("inspect").alias("get").description("Inspect one database bundle").argument("<bundle>").option("--plan <name>","Plan name").onions([N,K,Y,j7]);let P=R.command("backup").description("Manage database backups").onions([D0]);P.command("list").alias("ls").description("List database backups").argument("<database>").onions([N,K,Y,b,Y,J0,C7]),P.command("inspect").alias("get").description("Inspect one database backup").argument("<database>").argument("<backup>").onions([N,K,Y,b,Y,J0,w7,L7]),P.command("create").description("Create a database backup").argument("<database>").onions([N,K,Y,b,Y,J0,N7])}var i7=_(async(D)=>{let R=(await D.client.api.projectsList()).map((A)=>({...A,current:D.state.currentProjectByAuthId[D.auth.id]===String(A.id)}));if(C(D.options)){W(R,!0);return}s([{header:"Current",width:7,render:(A)=>A.current?"*":""},{header:"Name",width:22,render:(A)=>A.name??""},{header:"Slug",width:22,render:(A)=>A.slug??""},{header:"Status",width:12,render:(A)=>A.status??""},{header:"Age",width:6,render:(A)=>H0(A.createdAt)},{header:"ID",width:8,render:(A)=>String(A.id)}],R)}),a7=_(async(D)=>{let R=(await D.client.api.projectsList()).find((A)=>_R(A,D.args.project));if(!R)D.abort(`Project not found: ${D.args.project}`);D.state.currentProjectByAuthId[D.auth.id]=String(R.id),await p0(D.state),console.log(`Current project: ${R.name} (${R.slug}, #${R.id})`)}),r7=_(async(D)=>{let R={id:D.project.id,name:D.project.name,slug:D.project.slug,status:D.project.status};if(C(D.options)){W(R,!0);return}o0(R)});function s7(D){let R=D.command("project").description("Manage current project context").onions([D0]);R.command("list").alias("ls").description("List available projects").onions([N,K,Y,i7]),R.command("use").description("Switch current project").argument("<project>","Project ID, slug, or name").onions([N,K,Y,a7]),R.command("current").description("Show current project").onions([N,K,Y,b,r7])}var o6=_(async(D,R)=>{let f=((await D.client.api.authApiTokensList({})).items??[]).find((P)=>K4(P,D.args.token));if(!f)D.abort(`Token not found: ${D.args.token}`);D.tokenInfo=f,await R()}),o7=_(async(D)=>{let[R,A]=await Promise.all([D.client.api.authApiTokensList({}),D.client.api.projectsList()]),$=R.items??[];if(!D.options.includeRevoked)$=$.filter((P)=>!P.revokedAt);let f=new Map(A.map((P)=>[P.id,P.name]));if(C(D.options)){W($,!0);return}Nf($,{projectLabel:(P)=>f.get(P)??`#${P}`})}),c7=_(async(D)=>{let R=await D.client.api.projectsList(),A=D.tokenInfo,$=new Map(R.map((f)=>[f.id,f.name]));if(C(D.options)){W(A,!0);return}nA(A,{projectLabel:(f)=>$.get(f)??`#${f}`})}),t7=_(async(D)=>{let R=PN(D.options.expire),A=await D.client.api.authApiTokensCreate({name:D.args.name,expiresAt:R});if(C(D.options)){W(A,!0);return}nA(A,{plaintextToken:A.token})}),e7=_(async(D)=>{if(await D.client.api.authApiTokensDelete({tokenId:D.tokenInfo.id}),C(D.options)){W({revoked:!0,id:D.tokenInfo.id,name:D.tokenInfo.name},!0);return}console.log(`Removed token ${D.tokenInfo.name}`)});function PN(D){if(!D||D==="never")return;let R=/^(\d+)([smhdw])$/i.exec(D.trim());if(R){let $=Number(R[1]),f=R[2].toLowerCase(),P=f==="s"?1000:f==="m"?60000:f==="h"?3600000:f==="d"?86400000:604800000;return new Date(Date.now()+$*P).toISOString()}let A=new Date(D);if(Number.isFinite(A.getTime()))return A.toISOString();throw Error("Invalid expiry. Use values like 30d, 12h, 7d, never, or an ISO timestamp.")}function DJ(D){let R=D.command("token").description("Manage personal access tokens").onions([D0]);R.command("list").alias("ls").description("List tokens").option("--include-revoked","Include revoked tokens").onions([N,K,Y,o7]),R.command("get").description("Get one token").argument("<token>").onions([N,K,Y,o6,c7]),R.command("create").description("Create a token").argument("<name>").option("--for-project <project>","Project name or id to grant").option("--role <role>","Token role",_D(["read","deploy","admin","billing"])).option("--expire <value>","Expiry like 30d, 12h, never, or an ISO timestamp").onions([N,K,Y,b,t7]),R.command("remove").alias("rm").description("Remove a token").argument("<token>").onions([N,K,Y,o6,e7])}var ZR=new vA().name("abrun").description("CLI for managing apps on the abrun platform").option("--endpoint <url>","API endpoint").option("--auth <auth>","Override current auth").option("--project <project>","Override current project").option("--token <token>","Override bearer token").option("-o, --output <format>","Output format: table, json, yaml",_9).option("--json","Render raw JSON").option("--no-color","Disable colored output").option("--debug","Print debug information");q7(ZR);s7(ZR);DJ(ZR);M7(ZR);d7(ZR);ZR.parse(process.argv.length>2?process.argv:[...process.argv,"--help"]);
199
+ `)}}}var j6=_(async(D)=>{let R=NG();R.disposeSignal=I6(R);let A=D.options.image?"":TC(D.args.path),$=Object.assign(D,{deployState:R,manifestEntries:[],appDiff:{files:[],summary:{added:0,changed:0}},localGit:{},archivePath:void 0,deployment:void 0,ui:IG(C(D.options),A,D.app.name,D.options.verbose===!0)});try{if(!D.options.image)await HC($,A);else $.ui.completeScan(0);await ZC($,A);let f=$.deployment;$.deployState.deploymentId=f.id??null,$.deployState.disposeSignal?.(),$.deployState.disposeSignal=I6($.deployState,async()=>{if(!$.deployState.cancellationRequested)$.deployState.cancellationRequested=!0,await PG({client:$.client,appId:$.app.id,deploymentId:f.id})}),await MC($)}finally{if($.archivePath)await SG($.archivePath,{force:!0}).catch(()=>{return});R.disposeSignal?.(),R.disposeSignal=void 0}});async function HC(D,R){D.manifestEntries=await wG(R),D.localGit=await zG(R),bf(D.deployState),D.ui.completeScan(D.manifestEntries.length)}async function ZC(D,R){if(D.options.port!==void 0&&(!Number.isFinite(D.options.port)||D.options.port<=0))throw Error("Deploy port must be a positive number");try{D.deployment=await q6(D),D.ui.startDeploying(D.app.name),D.ui.completeDeploying();return}catch(A){if(D.deployState.aborted&&K6(A))throw Error("Deployment cancelled by user");let $=GG(A,D.manifestEntries);if(!$)throw A;D.appDiff=$.details,D.ui.showUploadRequired(D.appDiff),D.ui.startPackaging(D.appDiff.files.length),D.archivePath=await e5(R,D.appDiff.files),bf(D.deployState),D.ui.completePackaging(D.appDiff.files.length),D.ui.startUploading(D.app.name);let f=await AG(D,D.appDiff,D.archivePath,D.options.message??D.localGit.commitMessage,(P)=>D.ui.updateUploading(D.app.name,P));bf(D.deployState),D.ui.completeUploading(f.uploadedFiles,OC(f.uploadedBytes),f.commitSha),D.ui.startDeploying(D.app.name),D.deployment=await RG(D,c0),D.ui.completeDeploying()}finally{if(D.archivePath)await SG(D.archivePath,{force:!0}).catch(()=>{return}),D.archivePath=void 0}}async function MC(D){let R=D.deployment;D.ui.updatePhase(R.status??"pending");let A=0,$=R;try{$=await Sf({initial:R,sleep:c0,shouldAbort:()=>D.deployState.aborted,onPoll:async(f)=>{if(XC(D,f))A=await QC(D,f,A)},onStatusChange:(f,P)=>{if(!C(D.options))YC(D,f,P);D.ui.updatePhase(P)},fetch:async(f)=>{try{return await $G({client:D.client,appId:D.app.id,deploymentId:f.id},D.deployState)}catch(P){if(D.deployState.aborted&&K6(P))return f;throw P}}})}finally{D.deployState.activeController?.abort(),D.deployState.activeController=null,D.deployState.logController?.abort(),D.deployState.logController=null}if(D.deployState.aborted)throw Error("Deployment cancelled by user");if(C(D.options))W($,!0);else{D.ui.finish($.status??"pending");let f=Wf($,D.app.url);if(LA($)&&f)D.ui.note(`URL: ${f}`)}if(!LA($))throw Error(jf($,D.app.name));if(D.options.logs===!0&&!C(D.options))console.log("Following app logs"),await DR(D,`/v1/apps/${D.app.id}/logs`,{lines:10,stream:!0})}function XC(D,R){return!C(D.options)&&!Kf(R.status)}async function QC(D,R,A){let f=(await fG({client:D.client,appId:D.app.id,deploymentId:R.id,offset:A,limit:100},D.deployState)).items??[];for(let P of f)D.ui.printLog(P.message??P.line??"",R.status??"pending");return A+f.length}function TC(D){return JC.resolve(process.cwd(),D??".")}function OC(D){if(!Number.isFinite(D)||D<=0)return"0 B";let R=["B","KiB","MiB","GiB","TiB"],A=D,$=0;while(A>=1024&&$<R.length-1)A/=1024,$+=1;let f=A>=10||$===0?0:1;return`${A.toFixed(f)} ${R[$]}`}function YC(D,R,A){if(R==="building"&&["deploying","pulling","starting","ready","degraded"].includes(A)){D.ui.note("Build completed");return}if(R==="pulling"&&["starting","ready","degraded"].includes(A))D.ui.note("Image pulled")}var bG=_(async(D)=>{let A=(await D.client.api.appsDeploymentsList({appId:D.app.id})).items??[];if(C(D.options)){W(A,!0);return}s([{header:"Status",width:12,render:($)=>$.status??""},{header:"Method",width:8,render:($)=>$.method??""},{header:"Trigger",width:10,render:($)=>$.trigger??""},{header:"Message",width:28,render:($)=>$.message??""},{header:"Age",width:6,render:($)=>H0($.createdAt)},{header:"ID",width:9,render:($)=>String($.id)}],A)}),uG=_(async(D)=>{let R=Number(D.args.deployment),A=await D.client.api.appsDeploymentsDetail({appId:D.app.id,deploymentId:R});if(C(D.options)){W(A,!0);return}M2(A)}),EG=_(async(D)=>{let R=Number(D.args.deployment);await D.client.api.appsDeploymentsCancelCreate({appId:D.app.id,deploymentId:R}),console.log(`Cancelled deployment ${R}`)}),yG=_(async(D)=>{let R=Number(D.args.deployment),A=await D.client.api.appsDeploymentsRollbackCreate({appId:D.app.id,deploymentId:R});if(C(D.options)){W(A,!0);return}console.log(`Rollback deployment ${A.id} created from deployment ${A.source?.rollbackFromDeploymentID}`)}),gG=_(async(D)=>{let R=Number(D.args.deployment),A=await D.client.api.appsDeploymentsLogsList({appId:D.app.id,deploymentId:R});W(A,C(D.options))}),mG=_(async(D)=>{let R=Number(D.args.deployment),A=await D.client.api.appsDeploymentsDetail({appId:D.app.id,deploymentId:R}),$=await Sf({initial:A,sleep:c0,fetch:async()=>await D.client.api.appsDeploymentsDetail({appId:D.app.id,deploymentId:R}),onStatusChange:(f,P)=>{if(!C(D.options))console.log(`Status: ${P}`)}});if(C(D.options)){W($,!0);return}if(LA($)){console.log("Ready");let f=Wf($,D.app.url);if(f)console.log(`URL: ${f}`);return}D.abort(jf($,D.app.name))});var RR=_(async(D,R)=>{let $=((await D.client.api.appsDisksList({appId:D.app.id})).items??[]).find((f)=>V4(f,D.args.disk));if(!$)D.abort(`Disk not found: ${D.args.disk}`);D.disk=$,await R()}),xG=_(async(D)=>{let A=(await D.client.api.appsDisksList({appId:D.app.id})).items??[];if(C(D.options)){W(A,!0);return}T2(A)}),nG=_(async(D)=>{let R=await D.client.api.appsDisksDetail({appId:D.app.id,diskId:D.disk.id});if(C(D.options)){W(R,!0);return}kD(R)}),pG=_(async(D)=>{if(!Number.isFinite(D.options.size)||D.options.size<=0)D.abort("Disk size must be a positive number");let R=await D.client.api.appsDisksCreate({appId:D.app.id},{name:D.args.name,size:D.options.size});if(C(D.options)){W(R,!0);return}kD(R)}),hG=_(async(D)=>{let R=await D.client.api.appsDisksMountCreate({appId:D.app.id,diskId:D.disk.id},{mountPath:D.args.mountPath});if(C(D.options)){W(R,!0);return}kD(R)}),vG=_(async(D)=>{let R=await D.client.api.appsDisksUnmountCreate({appId:D.app.id,diskId:D.disk.id});if(C(D.options)){W(R,!0);return}kD(R)}),lG=_(async(D)=>{if(!Number.isFinite(D.options.size)||D.options.size<=0)D.abort("Disk size must be a positive number");let R=await D.client.api.appsDisksExpandCreate({appId:D.app.id,diskId:D.disk.id},{size:D.options.size});if(C(D.options)){W(R,!0);return}kD(R)}),kG=_(async(D)=>{if(await D.client.api.appsDisksDelete({appId:D.app.id,diskId:D.disk.id}),C(D.options)){W({deleted:!0,id:D.disk.id,name:D.disk.name},!0);return}console.log(`Deleted disk ${D.disk.name}`)});var dG=_(async(D)=>{let R=await D.client.api.appsDomainsList({appId:D.app.id});if(C(D.options)){W(R,!0);return}s([{header:"Hostname",width:36,render:(A)=>A.hostname??""},{header:"Verify",width:12,render:(A)=>A.verificationStatus??""},{header:"TLS",width:12,render:(A)=>A.tlsStatus??""},{header:"TLS On",width:8,render:(A)=>A.tlsEnabled?"yes":"no"},{header:"HTTPS",width:8,render:(A)=>A.forceHttps?"yes":"no"},{header:"Age",width:6,render:(A)=>H0(A.createdAt)}],R)}),iG=_(async(D,R)=>{D.domain=await D.client.api.appsDomainsCreate({appId:D.app.id},{hostname:D.args.hostname,tlsEnabled:D.options.tlsMode==="disabled"?!1:!0,forceHttps:D.options.forceHttps}),await R()}),aG=_(async(D)=>{if(C(D.options)){W(D.domain,!0);return}Q2(D.domain)}),rG=_(async(D)=>{let A=(await D.client.api.appsDomainsList({appId:D.app.id})).find(($)=>$.hostname===D.args.hostname);if(!A)D.abort(`Domain not found: ${D.args.hostname}`);await D.client.api.appsDomainsDelete({appId:D.app.id,domainId:A.id}),console.log(`Removed domain ${A.hostname}`)}),sG=_(async(D)=>{let A=(await D.client.api.appsDomainsList({appId:D.app.id})).find((f)=>f.hostname===D.args.hostname);if(!A)D.abort(`Domain not found: ${D.args.hostname}`);let $=await D.client.api.appsDomainsVerifyCreate({appId:D.app.id,domainId:A.id});W($,C(D.options))}),oG=_(async(D)=>{let R=await D.client.api.appsDomainsAvailabilityList({appId:D.app.id,hostname:D.args.hostname});W(R,C(D.options))});var cG=_(async(D)=>{let R=S6(await D.client.api.appsEnvList({appId:D.app.id}));if(C(D.options)){W(R,!0);return}X2(R)}),tG=_(async(D)=>{let R=F4(D.args.entry),$=[...S6(await D.client.api.appsEnvList({appId:D.app.id})).filter((f)=>yf(f)!==R.key),{name:R.key,value:R.value}];await D.client.api.appsEnvUpdate({appId:D.app.id},{items:$}),await D.client.api.appsApplyCreate({appId:D.app.id}),console.log(`Updated ${R.key}`)}),eG=_(async(D)=>{let A=S6(await D.client.api.appsEnvList({appId:D.app.id})).filter(($)=>yf($)!==D.args.key).map(($)=>({name:yf($),value:Dz($)}));await D.client.api.appsEnvUpdate({appId:D.app.id},{items:A}),await D.client.api.appsApplyCreate({appId:D.app.id}),console.log(`Removed ${D.args.key}`)});function S6(D){return(Array.isArray(D)?D:Array.isArray(D?.items)?D.items:[]).map((A)=>{let $=A;return{key:yf($),value:Dz($),updatedAt:$.updatedAt??""}})}function yf(D){return D.name??D.key??""}function Dz(D){return D.value??""}var Rz=_(async(D)=>{await D.client.api.appsStartCreate({appId:D.app.id}),console.log(`Started app ${D.app.name}`)}),Az=_(async(D)=>{await D.client.api.appsStopCreate({appId:D.app.id}),console.log(`Stopped app ${D.app.name}`)}),$z=_(async(D)=>{await D.client.api.appsRestartCreate({appId:D.app.id}),console.log(`Restarted app ${D.app.name}`)});var fz=_(async(D)=>{if(C(D.options)){W(D.app,!0);return}Z2(D.app)});var b6=_(async(D)=>{let A=(await D.client.api.appsList()).items??[];if(C(D.options)){W(A,!0);return}s([{header:"Project",width:22,render:()=>D.project.name},{header:"Name",width:22,render:($)=>$.name??""},{header:"Status",width:12,render:($)=>$.status??""},{header:"Plan",width:12,render:($)=>$.plan??""},{header:"Bundle",width:12,render:($)=>$.bundle??""},{header:"Age",width:6,render:($)=>H0($.createdAt)},{header:"URL",width:36,render:($)=>$.url??""}],A)});var Pz=_(async(D)=>{let R=_0(D.options.tail)??10,A={since:D.options.since,lines:R,filter:D.options.filter,previous:D.options.previous,stream:D.options.follow};if(D.options.follow&&!C(D.options)){await DR(D,`/v1/apps/${D.app.id}/logs`,A);return}let $=await D.client.api.appsLogsList({appId:D.app.id,...A});if(C(D.options)){W($,!0);return}OR(Ef($))}),Bz=_(async(D)=>{if(D.options.watch){await uf({list:()=>D.client.api.appsEventsList({appId:D.app.id,limit:50,offset:0}),since:D.options.since,onEvent:(f)=>{TR(f),console.log()}});return}let R=_0(D.options.tail)??10,$=(await D.client.api.appsEventsList({appId:D.app.id,limit:R,offset:0})).items??[];if(C(D.options)){W($,!0);return}QR($)});var mL=B0(R7(),1),xL=B0(lf(),1),nL=B0(fR(),1),pL=B0(x6(),1),hL=B0(p6(),1),vL=B0(i6(),1),z7=B0(rf(),1),lL=B0(G7(),1);var g0=z7.default;var J7=_(async(D)=>{if(D.token.startsWith("abr_"))D.abort("App shell requires session authentication. Run `abrun login --email <email>` and try again.");let R=iA(D.endpoint,`/v1/apps/${D.app.id}/console`,{command:"shell"});await new Promise((A,$)=>{let f=new g0(R,{headers:{Authorization:`Bearer ${D.token}`,"User-Agent":UR,"x-project-id":String(D.project.id)}}),P=process.stdin,B=process.stdout,G=P.isTTY?P.isRaw:void 0,z=!1,J=!1,Z=()=>{if(P.off("data",M),P.off("end",Q),B.off("resize",O),f.off("open",U),f.off("message",F),f.off("error",X),f.off("close",T),P.isTTY)P.pause(),P.setRawMode(G??!1)},H=(w,V=0)=>{if(J)return;if(J=!0,Z(),w){$(w);return}process.exitCode=V,A()},M=(w)=>{if(f.readyState===g0.OPEN)f.send(w,{binary:!0})},Q=()=>{if(f.readyState===g0.OPEN)f.send(JSON.stringify({type:"close"}))},O=()=>{if(!P.isTTY||f.readyState!==g0.OPEN||!z)return;f.send(JSON.stringify({type:"resize",cols:B.columns,rows:B.rows}))},X=(w)=>{H(w)},T=()=>{H()},U=()=>{if(z=!0,P.on("data",M),P.on("end",Q),P.isTTY)P.resume(),P.setRawMode(!0);if(B.isTTY)B.on("resize",O),O()},F=(w,V)=>{if(V){let j=Array.isArray(w)?Buffer.concat(w.map((u)=>Buffer.isBuffer(u)?u:Buffer.from(u))):Buffer.isBuffer(w)?w:Buffer.from(w);B.write(j);return}let I=JSON.parse(String(w));if(I.type==="ready")return;if(I.type==="started"){if(z=!0,P.isTTY)P.resume(),P.setRawMode(!0),O();return}if(I.type==="error"){H(Error(I.message));return}if(I.type==="exit"){if(f.readyState===g0.OPEN)f.close();H(void 0,I.exitCode??(I.succeeded?0:1))}};f.on("open",U),f.on("message",F),f.on("error",X),f.on("close",T)})});var H7=_(async(D)=>{let R=D.options.plan!==void 0||D.options.bundle!==void 0,A=D.options.defaultDomain!==void 0||D.options.securityProfile!==void 0;if(R)D.abort("Use `abrun app resize` for plan and bundle changes.");if(!A)D.abort("Nothing to update. Use --security-profile.");if(D.options.defaultDomain!==void 0)D.abort("Updating default domains is not implemented by the public API.");let $=await D.client.api.appsPartialUpdate({appId:D.app.id},{buildConfig:D.app.buildConfig,image:D.app.image,name:D.app.name,port:D.app.port,runtimeConfig:D.app.runtimeConfig,securityProfile:D.options.securityProfile});if(C(D.options)){W($,!0);return}console.log(`Updated app ${$.name} (${$.status})`)}),Z7=_(async(D)=>{let R=await D.client.api.appPlansList(),A=D.options.plan!==void 0||D.options.bundle===void 0&&await p1(D,"Change app plan?","Use --plan and/or --bundle, or run in an interactive terminal."),$=A?await kL(D,R):dD(R,void 0,W4(D.app)),f=await D.client.api.appPlansBundlesList({planName:$.name}),P=D.options.bundle!==void 0||D.options.plan===void 0&&await p1(D,"Change app bundle?","Use --plan and/or --bundle, or run in an interactive terminal."),B=P?await dL(D,f):iD(f,void 0,j4(D.app));if(!A&&!P)D.abort("Nothing to resize.");let G=await D.client.api.appsResizeCreate({appId:D.app.id},{plan:$.name,bundle:B.name});if(C(D.options)){W(G,!0);return}console.log(`Resized app ${G.name} (${G.status})`)});async function kL(D,R){return D.options.plan?.trim()?dD(R,D.options.plan.trim()):uB(D,R)}async function dL(D,R){return D.options.bundle?.trim()?iD(R,D.options.bundle.trim()):EB(D,R)}function M7(D){let R=D.command("app").description("Manage apps").onions([D0]);D.command("apps").description("List apps").onions([N,K,Y,b,Y,b6]),D.command("deploy").description("Deploy source or an image to an app").argument("<app>").argument("[path]").option("--image <image>","Deploy an image instead of source").option("--port <port>","Update runtime port for this deploy",(B)=>Number(B)).option("--message <message>","Deployment message").option("--logs","Follow app logs after a successful deploy").option("--verbose","Print raw build and rollout logs").onions([N,K,Y,b,Y,x,j6]),R.command("list").alias("ls").description("List apps").onions([N,K,Y,b,Y,b6]),R.command("inspect").alias("get").description("Inspect one app").argument("<app>").onions([N,K,Y,b,Y,x,fz]),R.command("events").description("List app events").argument("<app>").option("--watch","Watch app events continuously").option("--tail <count>","Number of recent events to fetch",_0).option("--since <value>","Only include events since an ISO timestamp or relative value like 5h").onions([N,K,Y,b,Y,x,Bz]),R.command("logs").description("Fetch app runtime logs").argument("<app>").option("--tail <count>","Number of recent log lines to fetch",_0).option("--since <value>","Only include logs since an ISO timestamp or relative value like 5h").option("--filter <pattern>","Filter log messages with a regular expression").option("--previous","Fetch previous crashed container logs").option("--follow","Stream logs continuously").onions([N,K,Y,b,Y,x,Pz]),R.command("create").description("Create an app").argument("<name>").option("--plan <name>","Plan name").option("--bundle <name>","Bundle name").option("--port <port>","Runtime port",lA).option("--security-profile <profile>","Runtime security profile",_D(["restricted","compatible"])).onions([N,K,Y,b,Y,yB,gB]),R.command("update").description("Update app settings").argument("<app>").option("--default-domain <hostname>","Set app default domain").option("--security-profile <profile>","Runtime security profile",_D(["restricted","compatible"])).onions([N,K,Y,b,Y,x,H7]),R.command("resize").description("Resize an app plan or bundle").argument("<app>").option("--plan <name>","Plan name").option("--bundle <name>","Bundle name").onions([N,K,Y,b,Y,x,Z7]),R.command("delete").alias("rm").description("Delete an app").argument("<app>").onions([N,K,Y,b,Y,x,mB]),R.command("start").description("Start an app").argument("<app>").onions([N,K,Y,b,Y,x,Rz]),R.command("stop").description("Stop an app").argument("<app>").onions([N,K,Y,b,Y,x,Az]),R.command("restart").description("Restart an app").argument("<app>").onions([N,K,Y,b,Y,x,$z]),R.command("shell").alias("exec").description("Open an interactive shell in an app").argument("<app>").onions([N,K,Y,b,Y,x,J7]),R.command("deploy").description("Deploy source or an image").argument("<app>").argument("[path]").option("--image <image>","Deploy an image instead of source").option("--port <port>","Update runtime port for this deploy",(B)=>Number(B)).option("--message <message>","Deployment message").option("--logs","Follow app logs after a successful deploy").option("--verbose","Print raw build and rollout logs").onions([N,K,Y,b,Y,x,j6]);let A=R.command("disk").description("Manage app disks").onions([D0]);A.command("list").alias("ls").description("List disks").argument("<app>").onions([N,K,Y,b,Y,x,xG]),A.command("inspect").alias("get").description("Inspect one disk").argument("<app>").argument("<disk>").onions([N,K,Y,b,Y,x,RR,nG]),A.command("create").description("Create a disk").argument("<app>").argument("<name>").option("--size <size>","Disk size in GB",(B)=>Number(B)).onions([N,K,Y,b,Y,x,pG]),A.command("mount").description("Mount a disk").argument("<app>").argument("<disk>").argument("<mountPath>").onions([N,K,Y,b,Y,x,RR,hG]),A.command("unmount").description("Unmount a disk").argument("<app>").argument("<disk>").onions([N,K,Y,b,Y,x,RR,vG]),A.command("expand").description("Expand a disk").argument("<app>").argument("<disk>").option("--size <size>","New disk size in GB",(B)=>Number(B)).onions([N,K,Y,b,Y,x,RR,lG]),A.command("delete").alias("rm").description("Delete a disk").argument("<app>").argument("<disk>").onions([N,K,Y,b,Y,x,RR,kG]);let $=R.command("env").description("Manage app environment variables").onions([D0]);$.command("list").alias("ls").description("List env vars").argument("<app>").onions([N,K,Y,b,Y,x,cG]),$.command("set").description("Set an env var").argument("<app>").argument("<entry>").onions([N,K,Y,b,Y,x,tG]),$.command("unset").description("Remove an env var").argument("<app>").argument("<key>").onions([N,K,Y,b,Y,x,eG]);let f=R.command("domain").description("Manage app domains").onions([D0]);f.command("list").alias("ls").description("List domains").argument("<app>").onions([N,K,Y,b,Y,x,dG]),f.command("add").description("Add a domain").argument("<app>").argument("<hostname>").option("--tls-mode <mode>","TLS mode",_D(["auto","manual","disabled"])).option("--force-https","Force HTTPS redirect").onions([N,K,Y,b,Y,x,iG,aG]),f.command("delete").alias("rm").description("Delete a domain").argument("<app>").argument("<hostname>").onions([N,K,Y,b,Y,x,rG]),f.command("verify").description("Verify a domain").argument("<app>").argument("<hostname>").onions([N,K,Y,b,Y,x,sG]),f.command("check").description("Check domain availability").argument("<app>").argument("<hostname>").onions([N,K,Y,b,Y,x,oG]);let P=R.command("deployment").description("Manage deployments").onions([D0]);P.command("list").alias("ls").description("List deployments").argument("<app>").onions([N,K,Y,b,Y,x,bG]),P.command("inspect").alias("get").description("Inspect one deployment").argument("<app>").argument("<deployment>").onions([N,K,Y,b,Y,x,uG]),P.command("logs").description("Fetch deployment logs").argument("<app>").argument("<deployment>").onions([N,K,Y,b,Y,x,gG]),P.command("watch").description("Watch a deployment").argument("<app>").argument("<deployment>").onions([N,K,Y,b,Y,x,mG]),P.command("cancel").description("Cancel a deployment").argument("<app>").argument("<deployment>").onions([N,K,Y,b,Y,x,EG]),P.command("rollback").description("Roll back to the last ready deployment").argument("<app>").argument("<deployment>").onions([N,K,Y,b,Y,x,yG])}import{execFile as iL}from"node:child_process";import{promisify as aL}from"node:util";var rL=aL(iL),Q7=_(async(D)=>{let R=D.endpoint,A;if(D.options.token){let P=await aD({endpoint:R,token:D.options.token}).api.authMeList();A={token:D.options.token,expiresAt:"",user:P}}else if(D.options.browser){let P=await D.client.api.authCliLoginStartOrPoll({deviceName:`abrun ${S2}`}),B=tL(P,R);console.log(`Open: ${B}`),await eL(B),A=await cL(R,P)}else{let P=await sL(D),B=await oL(D);A=await D.client.api.authLoginCreate({email:P,password:B})}let $=D.options.label??A.user.email,f={id:String(A.user.id),label:$,email:A.user.email,token:A.token,endpoint:R,userId:A.user.id,expiresAt:A.expiresAt};D.state.auths=[...D.state.auths.filter((P)=>P.id!==f.id),f],D.state.currentAuthId=f.id,await p0(D.state),o0({auth:$,email:A.user.email,endpoint:R})});async function sL(D){let R=D.options.email?.trim();if(R)return R;if(!T7(D.options))D.abort("Email is required. Use --email or run in an interactive terminal.");let A=(await VR({message:"Email"})).trim();if(!A)D.abort("Email is required.");return A}async function oL(D){if(D.options.password)return D.options.password;if(!T7(D.options))D.abort("Password is required. Use --password or run in an interactive terminal.");let R=await e2({message:"Password",mask:"*"});if(!R)D.abort("Password is required.");return R}function T7(D){return Boolean(process.stdin.isTTY&&process.stdout.isTTY&&!C(D))}var O7=_(async(D)=>{if(D.options.all){await Promise.all(D.state.auths.map((A)=>X7(A.endpoint??D.endpoint,A.token))),D.state.auths=[],D.state.currentAuthId=void 0,D.state.currentProjectByAuthId={},await p0(D.state),console.log("All local auth entries removed.");return}let R=D.state.currentAuthId?D.state.auths.find((A)=>A.id===D.state.currentAuthId):D.state.auths[0];if(!R){console.log("No saved auth.");return}if(await X7(R.endpoint??D.endpoint,R.token),D.state.auths=D.state.auths.filter((A)=>A.id!==R.id),D.state.currentAuthId===R.id)D.state.currentAuthId=D.state.auths[0]?.id;delete D.state.currentProjectByAuthId[R.id],await p0(D.state),console.log(`Removed auth ${R.label}`)}),Y7=_(async(D)=>{let R=await D.client.api.authMeList();o0({auth:D.auth.label,email:R.email,endpoint:D.endpoint,expiresIn:hA(D.auth.expiresAt)})}),_7=_(async(D)=>{if(C(D.options)){W(D.state.auths,!0);return}s([{header:"Current",width:7,render:(R)=>R.id===D.state.currentAuthId?"*":""},{header:"Auth",width:18,render:(R)=>R.label},{header:"Email",width:28,render:(R)=>R.email},{header:"Endpoint",width:36,render:(R)=>R.endpoint}],D.state.auths)}),U7=_(async(D)=>{let R=D.state.auths.find((A)=>YR(A,D.args.auth));if(!R)D.abort(`Auth not found: ${D.args.auth}`);D.state.currentAuthId=R.id,await p0(D.state),console.log(`Current auth: ${R.label}`)}),F7=_(async(D)=>{let R=D.state.auths.find((A)=>YR(A,D.args.auth));if(!R)D.abort(`Auth not found: ${D.args.auth}`);if(D.state.auths=D.state.auths.filter((A)=>A.id!==R.id),D.state.currentAuthId===R.id)D.state.currentAuthId=D.state.auths[0]?.id;delete D.state.currentProjectByAuthId[R.id],await p0(D.state),console.log(`Removed auth: ${R.label}`)});async function cL(D,R){if(!R.pollToken)throw Error("CLI login did not return a poll token.");let A=aD({endpoint:D});for(;;){let $=await A.api.authCliLoginStartOrPoll({pollToken:R.pollToken});if($.status==="allowed"&&$.token){let f=await aD({endpoint:D,token:$.token}).api.authMeList();return{token:$.token,expiresAt:"",user:f}}await c0(($.pollIntervalSeconds??R.pollIntervalSeconds??2)*1000)}}function tL(D,R){let A=D.browserURL;if(A)return A;let $=new URL(R);if($.hostname.startsWith("api."))$.hostname=$.hostname.slice(4);return $.pathname="/cli-login",$.search="",$.toString()}async function eL(D){let R=process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open",A=process.platform==="win32"?["/c","start","",D]:[D];try{await rL(R,A)}catch{console.log("Open the URL above in your browser to continue.")}}async function X7(D,R){try{await aD({endpoint:D,token:R}).api.authLogoutCreate()}catch{}}function q7(D){D.command("login").description("Login with email/password, token, or browser approval").option("--token <token>","API token").option("--email <email>","User email for password login").option("--password <password>","User password for password login").option("--label <label>","Saved auth label").option("--browser","Use browser approval flow").onions([N,Y,Q7]),D.command("logout").description("Remove the current saved auth").option("--all","Remove all saved auth entries").onions([N,O7]),D.command("whoami").description("Show the current authenticated identity").onions([N,K,Y,Y7]);let R=D.command("auth").description("Manage saved auth entries").onions([D0]);R.command("list").alias("ls").description("List saved auth entries").onions([N,_7]),R.command("use").description("Switch current auth").argument("<auth>").onions([N,U7]),R.command("remove").alias("rm").description("Remove a saved auth entry").argument("<auth>").onions([N,F7])}var w7=_(async(D,R)=>{let $=((await D.client.api.databasesBackupsList({databaseId:D.database.id})).items??[]).find((f)=>String(f.id)===D.args.backup);if(!$)D.abort(`Database backup not found: ${D.args.backup}`);D.backup=$,await R()}),C7=_(async(D)=>{let A=(await D.client.api.databasesBackupsList({databaseId:D.database.id})).items??[];if(C(D.options)){W(A,!0);return}L2(A)}),L7=_(async(D)=>{let R=await D.client.api.databasesBackupsDetail({databaseId:D.database.id,backupId:D.backup.id});if(C(D.options)){W(R,!0);return}xA(R)}),N7=_(async(D)=>{let R=await D.client.api.databasesBackupsCreate({databaseId:D.database.id});if(C(D.options)){W(R,!0);return}xA(R)});async function bA(D,R){return D.client.api.databasesDetail({databaseId:R})}async function of(D){return D.client.api.databasesList({})}async function V7(D,R){return D.client.api.databasesCreate({name:R.name,engine:R.engine,version:R.version,plan:R.plan,bundle:R.bundle,publicAccess:R.published,password:R.password,engineConfig:K7(R.configOverrides)})}async function a6(D,R,A){let $={publicAccess:A.publicAccess,engineConfig:K7(A.configOverrides)};if(A.plan!==void 0||A.bundle!==void 0)await D.client.api.databasesResizeCreate({databaseId:R},{plan:A.plan,bundle:A.bundle});if($.publicAccess===void 0&&$.engineConfig===void 0)return bA(D,R);return D.client.api.databasesPartialUpdate({databaseId:R},$)}async function L1(D){return{items:await D.client.api.databasePlansList()}}async function cf(D){return(await D.client.api.databaseEnginesList()).filter((A)=>A.name).map((A)=>({engine:A.name,versions:A.versions??[]}))}async function HR(D,R){return await D.client.api.databasePlansBundlesList({planName:R})}function I7(D,R){let A=D.find(($)=>$.engine===R);if(!A)throw Error(`Unsupported database engine: ${R}`);return A}function K7(D){if(!D?.trim())return;return JSON.parse(D)}var W7=_(async(D)=>{let R=D.options.plan?.trim();if(!R)D.abort("Database bundle list requires --plan because bundles are resolved per plan.");let A=await HR(D,R);if(C(D.options)){W(A,!0);return}w2(A)}),j7=_(async(D)=>{let R=await L1(D),A=UD(R.items??[],D.options.plan),f=(await HR(D,A.name)).find((P)=>dA(P,D.args.bundle));if(!f)D.abort(`Database bundle not found: ${D.args.bundle}`);if(C(D.options)){W(f,!0);return}C2(f)});var S7=_(async(D)=>{let R=await cf(D);if(C(D.options)){W(R,!0);return}F2(R)});var LE=_(async(D)=>{let A=(await L1(D)).items??[];if(C(D.options)){W(A,!0);return}U2(A)}),b7=_(async(D)=>{let A=(await D.client.api.databasePlansList()).find(($)=>kA($,D.args.plan));if(!A)D.abort(`Database plan not found: ${D.args.plan}`);if(C(D.options)){W(A,!0);return}q2(A)});var r6=B0(mA(),1);var s6=_(async(D)=>{let A=(await of(D)).items??[];if(C(D.options)){W(A,!0);return}_2(D.project.name,A)}),u7=_(async(D)=>{let R=await bA(D,D.database.id);if(C(D.options)){W(R,!0);return}O2(R)}),E7=_(async(D)=>{let R=await D.client.api.databasesCredentialsList({databaseId:D.database.id});if(C(D.options)){if(!D.options.reveal&&!D.options.showPassword)D.abort("Refusing to print database credentials as JSON without --show-password.");W(R,!0);return}Y2(D.database.name,R,{reveal:D.options.reveal||D.options.showPassword})}),y7=_(async(D)=>{let R=await cf(D),A=D.options.engine?.trim()||await h0(D,"Select database engine",R.map((Z)=>({value:Z.engine,name:Z.engine})),"Database engine is required. Use --engine or run in an interactive terminal."),$=I7(R,A),f=D.options.version?.trim()||await h0(D,`Select ${A} version`,$.versions.map((Z)=>({value:Z,name:Z})),"Database version is required. Use --version or run in an interactive terminal.",{forcePromptSingle:!0}),P=await L1(D),B=D.options.plan?.trim()?UD(P.items??[],D.options.plan.trim()):await QP(D,P.items??[]),G=await HR(D,B.name),z=D.options.bundle?.trim()?V1(G,D.options.bundle.trim()):await TP(D,G),J=await V7(D,{name:D.args.name,engine:A,plan:B.name,bundle:z.name,password:D.options.password,published:D.options.publicAccess,version:f,configOverrides:D.options.config});if(C(D.options)){W(J,!0);return}console.log(`Created database ${J.database.name} (${J.database.status})`),console.log(),console.log(r6.default.bold("password")),console.log(r6.default.yellow(J.password??""))}),g7=_(async(D)=>{let R=D.options.config!==void 0||D.options.publicAccess!==void 0;if(D.options.plan!==void 0||D.options.bundle!==void 0)D.abort("Use `abrun database resize` for plan and bundle changes.");if(!R)D.abort("Nothing to update. Use --config, --public-access, or --no-public-access.");let A=await a6(D,D.database.id,{configOverrides:D.options.config,publicAccess:D.options.publicAccess});if(C(D.options)){W(A,!0);return}console.log(`Updated database ${A.name} (${A.status})`)}),m7=_(async(D)=>{let R=await L1(D),A=D.options.plan!==void 0||D.options.bundle===void 0&&await p1(D,"Change database plan?","Use --plan and/or --bundle, or run in an interactive terminal."),$=D.options.plan?.trim()?UD(R.items??[],D.options.plan.trim()):A?await QP(D,R.items??[]):UD(R.items??[],void 0,D.database.plan),f=await HR(D,$.name),P=D.options.bundle!==void 0||D.options.plan===void 0&&await p1(D,"Change database bundle?","Use --plan and/or --bundle, or run in an interactive terminal."),B=D.options.bundle?.trim()?V1(f,D.options.bundle.trim()):P?await TP(D,f):V1(f,void 0,D.database.bundle);if(!A&&!P)D.abort("Nothing to resize.");let G=await a6(D,D.database.id,{plan:$.name,bundle:B.name});if(C(D.options)){W(G,!0);return}console.log(`Resized database ${G.name} (${G.status})`)}),x7=_(async(D)=>{if(await D.client.api.databasesDelete({databaseId:D.database.id}),C(D.options)){W({deleted:!0,id:D.database.id,name:D.database.name},!0);return}console.log(`Removed database ${D.database.name}`)}),n7=_(async(D)=>{await D.client.api.databasesStartCreate({databaseId:D.database.id});let R=await bA(D,D.database.id);console.log(`Started database ${R.name} (${R.status})`)}),p7=_(async(D)=>{await D.client.api.databasesStopCreate({databaseId:D.database.id});let R=await bA(D,D.database.id);console.log(`Stopped database ${R.name} (${R.status})`)}),h7=_(async(D)=>{let R=await D.client.api.databasesUsageList({databaseId:D.database.id});if(C(D.options)){W(R,!0);return}N2(R)});var J0=_(async(D,R)=>{let $=((await of(D)).items??[]).find((f)=>I4(f,D.args.database));if(!$)D.abort(`Database not found: ${D.args.database}`);D.database=$,await R()});var v7=_(async(D)=>{let R=_0(D.options.tail)??10,A={since:D.options.since,lines:R,filter:D.options.filter,previous:D.options.previous,stream:D.options.follow};if(D.options.follow&&!C(D.options)){await DR(D,`/v1/databases/${D.database.id}/logs`,A);return}let $=await D.client.api.databasesLogsList({databaseId:D.database.id,...A});if(C(D.options)){W($,!0);return}OR(Ef($))}),l7=_(async(D)=>{if(D.options.watch){await uf({list:()=>D.client.api.databasesEventsList({databaseId:D.database.id,limit:50,offset:0}),since:D.options.since,onEvent:(f)=>{TR(f),console.log()}});return}let R=_0(D.options.tail)??10,$=(await D.client.api.databasesEventsList({databaseId:D.database.id,limit:R,offset:0})).items??[];if(C(D.options)){W($,!0);return}QR($)});import DN from"node:net";function RN(D){let R=D.host?.trim()||"127.0.0.1",A=D.port;if(A===void 0)throw Error("--port is required.");return{host:R,port:A}}function AN(D,R){return["Tunnel established","",`Database: ${D.name}`,`Engine: ${D.engine??""}`,`Local: ${R}`].join(`
200
+ `)}var k7=_(async(D)=>{let{host:R,port:A}=RN(D.options),$=`${R}:${A}`,f=new Set,P=DN.createServer((B)=>{f.add(B),B.on("close",()=>f.delete(B)),B.on("error",()=>f.delete(B)),B.pause();let G=iA(D.endpoint,`/v1/databases/${D.database.id}/tunnel`),z=new g0(G,{headers:{Authorization:`Bearer ${D.token}`,"User-Agent":UR,"x-project-id":String(D.project.id)}}),J=!1,Z=!1,H=()=>{if(J)return;if(J=!0,B.destroy(),z.readyState===g0.OPEN||z.readyState===g0.CONNECTING)z.close()},M=(Q)=>{console.error(Q),P.close(),H()};B.on("data",(Q)=>{if(z.readyState===g0.OPEN)z.send(Q,{binary:!0})}),B.on("end",()=>{Z=!0,H()}),B.on("error",()=>{Z=!0,H()}),B.on("close",()=>{Z=!0,H()}),z.on("open",()=>{B.resume()}),z.on("message",(Q,O)=>{if(!O)return;let X=Array.isArray(Q)?Buffer.concat(Q.map((T)=>Buffer.isBuffer(T)?T:Buffer.from(T))):Buffer.isBuffer(Q)?Q:Buffer.from(Q);B.write(X)}),z.on("error",(Q)=>{if(!Z)M(`Tunnel connection failed: ${Q.message}`)}),z.on("close",(Q,O)=>{if(!Z&&Q!==1000){let X=O.length>0?`: ${O.toString()}`:"";M(`Tunnel connection closed${X}`)}H()})});await new Promise((B,G)=>{let z=!1,J=!1,Z=()=>{process.off("SIGINT",M),process.off("SIGTERM",M),P.off("error",Q),P.off("close",O),P.off("listening",X);for(let T of f)T.destroy()},H=(T)=>{if(J)return;if(J=!0,Z(),T){G(T);return}B()},M=()=>{P.close();for(let T of f)T.destroy()},Q=(T)=>{H(T)},O=()=>{if(z)H()},X=()=>{z=!0,console.log(AN(D.database,$))};process.once("SIGINT",M),process.once("SIGTERM",M),P.once("error",Q),P.once("close",O),P.once("listening",X),P.listen(A,R)})});function d7(D){let R=D.command("database").description("Manage databases").onions([D0]);R.alias("db"),D.command("dbs").description("List databases").onions([N,K,Y,b,Y,s6]),R.command("credentials").description("Get database credentials").argument("<database>").option("--reveal","Show plaintext password in human output").option("--show-password","Show plaintext password in human output").onions([N,K,Y,b,Y,J0,E7]),R.command("events").description("List database events").argument("<database>").option("--watch","Watch database events continuously").option("--tail <count>","Number of recent events to fetch",_0).option("--since <value>","Only include events since an ISO timestamp or relative value like 5h").onions([N,K,Y,b,Y,J0,l7]),R.command("logs").description("Fetch database runtime logs").argument("<database>").option("--tail <count>","Number of recent log lines to fetch",_0).option("--since <value>","Only include logs since a relative value like 5h").option("--filter <pattern>","Filter log messages with a regular expression").option("--previous","Fetch previous crashed container logs").option("--follow","Stream logs continuously").onions([N,K,Y,b,Y,J0,v7]),R.command("tunnel").description("Open a local TCP tunnel to a database").argument("<database>").option("--port <port>","Local TCP port",lA).option("--host <host>","Local bind host").onions([N,K,Y,b,Y,J0,k7]),R.command("list").alias("ls").description("List databases").onions([N,K,Y,b,Y,s6]),R.command("inspect").alias("get").description("Inspect one database").argument("<database>").onions([N,K,Y,b,Y,J0,u7]),R.command("create").description("Create a database").argument("<name>").option("--engine <engine>","Database engine",_D(["mysql","postgres","redis"])).option("--plan <name>","Plan name").option("--bundle <name>","Bundle name").option("--password <password>","Primary database password").option("--public-access","Enable public database access").option("--version <version>","Database engine version").option("--config <text>","Additional config overrides text").onions([N,K,Y,b,Y,y7]),R.command("update").description("Update a database").argument("<database>").option("--config <text>","Additional config overrides text").option("--public-access","Enable public database access").option("--no-public-access","Disable public database access").onions([N,K,Y,b,Y,J0,g7]),R.command("resize").description("Resize a database plan or bundle").argument("<database>").option("--plan <name>","Plan name").option("--bundle <name>","Bundle name").onions([N,K,Y,b,Y,J0,m7]),R.command("delete").alias("rm").description("Delete a database").argument("<database>").onions([N,K,Y,b,Y,J0,x7]),R.command("start").description("Start a database").argument("<database>").onions([N,K,Y,b,Y,J0,n7]),R.command("stop").description("Stop a database").argument("<database>").onions([N,K,Y,b,Y,J0,p7]),R.command("metrics").description("Get current database metrics").argument("<database>").onions([N,K,Y,b,Y,J0,h7]),R.command("plan").description("Manage database plans").onions([D0]).command("inspect").alias("get").description("Inspect one database plan").argument("<plan>").onions([N,K,Y,b7]),R.command("engine").description("List available database engines and versions").onions([D0]).command("list").alias("ls").description("List database engines").onions([N,K,Y,S7]);let f=R.command("bundle").description("Manage database bundles").onions([D0]);f.command("list").alias("ls").description("List database bundles for a plan").option("--plan <name>","Plan name").onions([N,K,Y,W7]),f.command("inspect").alias("get").description("Inspect one database bundle").argument("<bundle>").option("--plan <name>","Plan name").onions([N,K,Y,j7]);let P=R.command("backup").description("Manage database backups").onions([D0]);P.command("list").alias("ls").description("List database backups").argument("<database>").onions([N,K,Y,b,Y,J0,C7]),P.command("inspect").alias("get").description("Inspect one database backup").argument("<database>").argument("<backup>").onions([N,K,Y,b,Y,J0,w7,L7]),P.command("create").description("Create a database backup").argument("<database>").onions([N,K,Y,b,Y,J0,N7])}var i7=_(async(D)=>{let R=(await D.client.api.projectsList()).map((A)=>({...A,current:D.state.currentProjectByAuthId[D.auth.id]===String(A.id)}));if(C(D.options)){W(R,!0);return}s([{header:"Current",width:7,render:(A)=>A.current?"*":""},{header:"Name",width:22,render:(A)=>A.name??""},{header:"Slug",width:22,render:(A)=>A.slug??""},{header:"Status",width:12,render:(A)=>A.status??""},{header:"Age",width:6,render:(A)=>H0(A.createdAt)},{header:"ID",width:8,render:(A)=>String(A.id)}],R)}),a7=_(async(D)=>{let R=(await D.client.api.projectsList()).find((A)=>_R(A,D.args.project));if(!R)D.abort(`Project not found: ${D.args.project}`);D.state.currentProjectByAuthId[D.auth.id]=String(R.id),await p0(D.state),console.log(`Current project: ${R.name} (${R.slug}, #${R.id})`)}),r7=_(async(D)=>{let R={id:D.project.id,name:D.project.name,slug:D.project.slug,status:D.project.status};if(C(D.options)){W(R,!0);return}o0(R)});function s7(D){let R=D.command("project").description("Manage current project context").onions([D0]);R.command("list").alias("ls").description("List available projects").onions([N,K,Y,i7]),R.command("use").description("Switch current project").argument("<project>","Project ID, slug, or name").onions([N,K,Y,a7]),R.command("current").description("Show current project").onions([N,K,Y,b,r7])}var o6=_(async(D,R)=>{let f=((await D.client.api.authApiTokensList({})).items??[]).find((P)=>K4(P,D.args.token));if(!f)D.abort(`Token not found: ${D.args.token}`);D.tokenInfo=f,await R()}),o7=_(async(D)=>{let[R,A]=await Promise.all([D.client.api.authApiTokensList({}),D.client.api.projectsList()]),$=R.items??[];if(!D.options.includeRevoked)$=$.filter((P)=>!P.revokedAt);let f=new Map(A.map((P)=>[P.id,P.name]));if(C(D.options)){W($,!0);return}V2($,{projectLabel:(P)=>f.get(P)??`#${P}`})}),c7=_(async(D)=>{let R=await D.client.api.projectsList(),A=D.tokenInfo,$=new Map(R.map((f)=>[f.id,f.name]));if(C(D.options)){W(A,!0);return}nA(A,{projectLabel:(f)=>$.get(f)??`#${f}`})}),t7=_(async(D)=>{let R=$N(D.options.expire),A=await D.client.api.authApiTokensCreate({name:D.args.name,expiresAt:R});if(C(D.options)){W(A,!0);return}nA(A,{plaintextToken:A.token})}),e7=_(async(D)=>{if(await D.client.api.authApiTokensDelete({tokenId:D.tokenInfo.id}),C(D.options)){W({revoked:!0,id:D.tokenInfo.id,name:D.tokenInfo.name},!0);return}console.log(`Removed token ${D.tokenInfo.name}`)});function $N(D){if(!D||D==="never")return;let R=/^(\d+)([smhdw])$/i.exec(D.trim());if(R){let $=Number(R[1]),f=R[2].toLowerCase(),P=f==="s"?1000:f==="m"?60000:f==="h"?3600000:f==="d"?86400000:604800000;return new Date(Date.now()+$*P).toISOString()}let A=new Date(D);if(Number.isFinite(A.getTime()))return A.toISOString();throw Error("Invalid expiry. Use values like 30d, 12h, 7d, never, or an ISO timestamp.")}function DJ(D){let R=D.command("token").description("Manage personal access tokens").onions([D0]);R.command("list").alias("ls").description("List tokens").option("--include-revoked","Include revoked tokens").onions([N,K,Y,o7]),R.command("get").description("Get one token").argument("<token>").onions([N,K,Y,o6,c7]),R.command("create").description("Create a token").argument("<name>").option("--for-project <project>","Project name or id to grant").option("--role <role>","Token role",_D(["read","deploy","admin","billing"])).option("--expire <value>","Expiry like 30d, 12h, never, or an ISO timestamp").onions([N,K,Y,b,t7]),R.command("remove").alias("rm").description("Remove a token").argument("<token>").onions([N,K,Y,o6,e7])}var ZR=new vA().name("abrun").description("CLI for managing apps on the abrun platform").option("--endpoint <url>","API endpoint").option("--auth <auth>","Override current auth").option("--project <project>","Override current project").option("--token <token>","Override bearer token").option("-o, --output <format>","Output format: table, json, yaml",_9).option("--json","Render raw JSON").option("--no-color","Disable colored output").option("--debug","Print debug information");q7(ZR);s7(ZR);DJ(ZR);M7(ZR);d7(ZR);ZR.parse(process.argv.length>2?process.argv:[...process.argv,"--help"]);