nuxi
Version:
Nuxt CLI
1,430 lines (1,427 loc) • 71 kB
JavaScript
import { a as __toCommonJS, i as __require, n as __esmMin, o as __toESM, r as __exportAll, t as __commonJSMin } from "./chunk-Vs_PY4HZ.mjs";
import "node:path";
import process$1, { stdin, stdout } from "node:process";
import { stripVTControlCharacters, styleText } from "node:util";
import tty, { ReadStream } from "node:tty";
import * as b from "node:readline";
import l from "node:readline";
import "node:fs";
import os from "node:os";
//#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
const getCodePointsLength = (() => {
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
return (input) => {
let surrogatePairsNr = 0;
SURROGATE_PAIR_RE.lastIndex = 0;
while (SURROGATE_PAIR_RE.test(input)) surrogatePairsNr += 1;
return input.length - surrogatePairsNr;
};
})();
const isFullWidth = (x) => {
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
};
const isWideNotCJKTNotEmoji = (x) => {
return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
};
//#endregion
//#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
const TAB_RE = /\t{1,1000}/y;
const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy;
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
const MODIFIER_RE = /\p{M}+/gu;
const NO_TRUNCATION$1 = {
limit: Infinity,
ellipsis: ""
};
const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
const LIMIT = truncationOptions.limit ?? Infinity;
const ELLIPSIS = truncationOptions.ellipsis ?? "";
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION$1, widthOptions).width : 0);
const ANSI_WIDTH = 0;
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
const FULL_WIDTH_WIDTH = 2;
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
const PARSE_BLOCKS = [
[LATIN_RE, REGULAR_WIDTH],
[ANSI_RE, ANSI_WIDTH],
[CONTROL_RE, CONTROL_WIDTH],
[TAB_RE, TAB_WIDTH],
[EMOJI_RE, EMOJI_WIDTH],
[CJKT_WIDE_RE, WIDE_WIDTH]
];
let indexPrev = 0;
let index = 0;
let length = input.length;
let lengthExtra = 0;
let truncationEnabled = false;
let truncationIndex = length;
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
let unmatchedStart = 0;
let unmatchedEnd = 0;
let width = 0;
let widthExtra = 0;
outer: while (true) {
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
lengthExtra = 0;
for (const char of unmatched.replaceAll(MODIFIER_RE, "")) {
const codePoint = char.codePointAt(0) || 0;
if (isFullWidth(codePoint)) widthExtra = FULL_WIDTH_WIDTH;
else if (isWideNotCJKTNotEmoji(codePoint)) widthExtra = WIDE_WIDTH;
else widthExtra = REGULAR_WIDTH;
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
if (width + widthExtra > LIMIT) {
truncationEnabled = true;
break outer;
}
lengthExtra += char.length;
width += widthExtra;
}
unmatchedStart = unmatchedEnd = 0;
}
if (index >= length) break outer;
for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
BLOCK_RE.lastIndex = index;
if (BLOCK_RE.test(input)) {
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
widthExtra = lengthExtra * BLOCK_WIDTH;
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
if (width + widthExtra > LIMIT) {
truncationEnabled = true;
break outer;
}
width += widthExtra;
unmatchedStart = indexPrev;
unmatchedEnd = index;
index = indexPrev = BLOCK_RE.lastIndex;
continue outer;
}
}
index += 1;
}
return {
width: truncationEnabled ? truncationLimit : width,
index: truncationEnabled ? truncationIndex : length,
truncated: truncationEnabled,
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
};
};
//#endregion
//#region ../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
const NO_TRUNCATION = {
limit: Infinity,
ellipsis: "",
ellipsisWidth: 0
};
const fastStringWidth = (input, options = {}) => {
return getStringTruncatedWidth(input, NO_TRUNCATION, options).width;
};
//#endregion
//#region ../../node_modules/.pnpm/fast-wrap-ansi@0.2.0/node_modules/fast-wrap-ansi/lib/main.js
const ESC = "\x1B";
const CSI = "";
const END_CODE = 39;
const ANSI_ESCAPE_BELL = "\x07";
const ANSI_CSI = "[";
const ANSI_OSC = "]";
const ANSI_SGR_TERMINATOR = "m";
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, "y");
const getClosingCode = (openingCode) => {
if (openingCode >= 30 && openingCode <= 37) return 39;
if (openingCode >= 90 && openingCode <= 97) return 39;
if (openingCode >= 40 && openingCode <= 47) return 49;
if (openingCode >= 100 && openingCode <= 107) return 49;
if (openingCode === 1 || openingCode === 2) return 22;
if (openingCode === 3) return 23;
if (openingCode === 4) return 24;
if (openingCode === 7) return 27;
if (openingCode === 8) return 28;
if (openingCode === 9) return 29;
if (openingCode === 0) return 0;
};
const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
const wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
const wrapWord = (rows, word, columns) => {
const characters = word[Symbol.iterator]();
let isInsideEscape = false;
let isInsideLinkEscape = false;
let lastRow = rows.at(-1);
let visible = lastRow === void 0 ? 0 : fastStringWidth(lastRow);
let currentCharacter = characters.next();
let nextCharacter = characters.next();
let rawCharacterIndex = 0;
while (!currentCharacter.done) {
const character = currentCharacter.value;
const characterLength = fastStringWidth(character);
if (visible + characterLength <= columns) rows[rows.length - 1] += character;
else {
rows.push(character);
visible = 0;
}
if (character === ESC || character === CSI) {
isInsideEscape = true;
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
}
if (isInsideEscape) {
if (isInsideLinkEscape) {
if (character === ANSI_ESCAPE_BELL) {
isInsideEscape = false;
isInsideLinkEscape = false;
}
} else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
} else {
visible += characterLength;
if (visible === columns && !nextCharacter.done) {
rows.push("");
visible = 0;
}
}
currentCharacter = nextCharacter;
nextCharacter = characters.next();
rawCharacterIndex += character.length;
}
lastRow = rows.at(-1);
if (!visible && lastRow !== void 0 && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
};
const stringVisibleTrimSpacesRight = (string) => {
const words = string.split(" ");
let last = words.length;
while (last) {
if (fastStringWidth(words[last - 1])) break;
last--;
}
if (last === words.length) return string;
return words.slice(0, last).join(" ") + words.slice(last).join("");
};
const exec = (string, columns, options = {}) => {
if (options.trim !== false && string.trim() === "") return "";
let returnValue = "";
let escapeCode;
let escapeUrl;
const words = string.split(" ");
let rows = [""];
let rowLength = 0;
for (let index = 0; index < words.length; index++) {
const word = words[index];
if (options.trim !== false) {
const row = rows.at(-1) ?? "";
const trimmed = row.trimStart();
if (row.length !== trimmed.length) {
rows[rows.length - 1] = trimmed;
rowLength = fastStringWidth(trimmed);
}
}
if (index !== 0) {
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
rows.push("");
rowLength = 0;
}
if (rowLength || options.trim === false) {
rows[rows.length - 1] += " ";
rowLength++;
}
}
const wordLength = fastStringWidth(word);
if (options.hard && wordLength > columns) {
const remainingColumns = columns - rowLength;
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
if (Math.floor((wordLength - 1) / columns) < breaksStartingThisLine) rows.push("");
wrapWord(rows, word, columns);
rowLength = fastStringWidth(rows.at(-1) ?? "");
continue;
}
if (rowLength + wordLength > columns && rowLength && wordLength) {
if (options.wordWrap === false && rowLength < columns) {
wrapWord(rows, word, columns);
rowLength = fastStringWidth(rows.at(-1) ?? "");
continue;
}
rows.push("");
rowLength = 0;
}
if (rowLength + wordLength > columns && options.wordWrap === false) {
wrapWord(rows, word, columns);
rowLength = fastStringWidth(rows.at(-1) ?? "");
continue;
}
rows[rows.length - 1] += word;
rowLength += wordLength;
}
if (options.trim !== false) rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
const preString = rows.join("\n");
let inSurrogate = false;
for (let i = 0; i < preString.length; i++) {
const character = preString[i];
returnValue += character;
if (!inSurrogate) {
inSurrogate = character >= "\ud800" && character <= "\udbff";
if (inSurrogate) continue;
} else inSurrogate = false;
if (character === ESC || character === CSI) {
GROUP_REGEX.lastIndex = i + 1;
const groups = GROUP_REGEX.exec(preString)?.groups;
if (groups?.code !== void 0) {
const code = Number.parseFloat(groups.code);
escapeCode = code === END_CODE ? void 0 : code;
} else if (groups?.uri !== void 0) escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
}
if (preString[i + 1] === "\n") {
if (escapeUrl) returnValue += wrapAnsiHyperlink("");
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
} else if (character === "\n") {
if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
}
}
return returnValue;
};
const CRLF_OR_LF = /\r?\n/;
function wrapAnsi(string, columns, options) {
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
}
//#endregion
//#region ../../node_modules/.pnpm/@clack+core@1.3.0/node_modules/@clack/core/dist/index.mjs
var import_src$1 = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
const ESC = "\x1B";
const CSI = `${ESC}[`;
const beep = "\x07";
const cursor = {
to(x, y) {
if (!y) return `${CSI}${x + 1}G`;
return `${CSI}${y + 1};${x + 1}H`;
},
move(x, y) {
let ret = "";
if (x < 0) ret += `${CSI}${-x}D`;
else if (x > 0) ret += `${CSI}${x}C`;
if (y < 0) ret += `${CSI}${-y}A`;
else if (y > 0) ret += `${CSI}${y}B`;
return ret;
},
up: (count = 1) => `${CSI}${count}A`,
down: (count = 1) => `${CSI}${count}B`,
forward: (count = 1) => `${CSI}${count}C`,
backward: (count = 1) => `${CSI}${count}D`,
nextLine: (count = 1) => `${CSI}E`.repeat(count),
prevLine: (count = 1) => `${CSI}F`.repeat(count),
left: `${CSI}G`,
hide: `${CSI}?25l`,
show: `${CSI}?25h`,
save: `${ESC}7`,
restore: `${ESC}8`
};
module.exports = {
cursor,
scroll: {
up: (count = 1) => `${CSI}S`.repeat(count),
down: (count = 1) => `${CSI}T`.repeat(count)
},
erase: {
screen: `${CSI}2J`,
up: (count = 1) => `${CSI}1J`.repeat(count),
down: (count = 1) => `${CSI}J`.repeat(count),
line: `${CSI}2K`,
lineEnd: `${CSI}K`,
lineStart: `${CSI}1K`,
lines(count) {
let clear = "";
for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
if (count) clear += cursor.left;
return clear;
}
},
beep
};
})))();
function d(r, t, s) {
if (!s.some((o) => !o.disabled)) return r;
const e = r + t, i = Math.max(s.length - 1, 0), n = e < 0 ? i : e > i ? 0 : e;
return s[n].disabled ? d(n, t < 0 ? -1 : 1, s) : n;
}
const h = {
actions: new Set([
"up",
"down",
"left",
"right",
"space",
"enter",
"cancel"
]),
aliases: new Map([
["k", "up"],
["j", "down"],
["h", "left"],
["l", "right"],
["", "cancel"],
["escape", "cancel"]
]),
messages: {
cancel: "Canceled",
error: "Something went wrong"
},
withGuide: !0,
date: {
monthNames: [...[
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]],
messages: {
required: "Please enter a valid date",
invalidMonth: "There are only 12 months in a year",
invalidDay: (r, t) => `There are only ${r} days in ${t}`,
afterMin: (r) => `Date must be on or after ${r.toISOString().slice(0, 10)}`,
beforeMax: (r) => `Date must be on or before ${r.toISOString().slice(0, 10)}`
}
}
};
function C(r, t) {
if (typeof r == "string") return h.aliases.get(r) === t;
for (const s of r) if (s !== void 0 && C(s, t)) return !0;
return !1;
}
function z$1(r, t) {
if (r === t) return;
const s = r.split(`
`), e = t.split(`
`), i = Math.max(s.length, e.length), n = [];
for (let o = 0; o < i; o++) s[o] !== e[o] && n.push(o);
return {
lines: n,
numLinesBefore: s.length,
numLinesAfter: e.length,
numLines: i
};
}
const Y$1 = globalThis.process.platform.startsWith("win"), k = Symbol("clack:cancel");
function q(r) {
return r === k;
}
function w$1(r, t) {
const s = r;
s.isTTY && s.setRawMode(t);
}
function R$1({ input: r = stdin, output: t = stdout, overwrite: s = !0, hideCursor: e = !0 } = {}) {
const i = b.createInterface({
input: r,
output: t,
prompt: "",
tabSize: 1
});
b.emitKeypressEvents(r, i), r instanceof ReadStream && r.isTTY && r.setRawMode(!0);
const n = (o, { name: u, sequence: a }) => {
if (C([
String(o),
u,
a
], "cancel")) {
e && t.write(import_src$1.cursor.show), process.exit(0);
return;
}
if (!s) return;
const f = u === "return" ? 0 : -1, y = u === "return" ? -1 : 0;
b.moveCursor(t, f, y, () => {
b.clearLine(t, 1, () => {
r.once("keypress", n);
});
});
};
return e && t.write(import_src$1.cursor.hide), r.once("keypress", n), () => {
r.off("keypress", n), e && t.write(import_src$1.cursor.show), r instanceof ReadStream && r.isTTY && !Y$1 && r.setRawMode(!1), i.terminal = !1, i.close();
};
}
const A = (r) => "columns" in r && typeof r.columns == "number" ? r.columns : 80, L = (r) => "rows" in r && typeof r.rows == "number" ? r.rows : 20;
function W(r, t, s, e = s, i) {
return wrapAnsi(t, A(r ?? stdout) - s.length, {
hard: !0,
trim: !1
}).split(`
`).map((o, u) => {
const a = i ? i(o, u) : o;
return `${u === 0 ? e : s}${a}`;
}).join(`
`);
}
let p = class {
input;
output;
_abortSignal;
rl;
opts;
_render;
_track = !1;
_prevFrame = "";
_subscribers = /* @__PURE__ */ new Map();
_cursor = 0;
state = "initial";
error = "";
value;
userInput = "";
constructor(t, s = !0) {
const { input: e = stdin, output: i = stdout, render: n, signal: o, ...u } = t;
this.opts = u, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = o, this.input = e, this.output = i;
}
unsubscribe() {
this._subscribers.clear();
}
setSubscriber(t, s) {
const e = this._subscribers.get(t) ?? [];
e.push(s), this._subscribers.set(t, e);
}
on(t, s) {
this.setSubscriber(t, { cb: s });
}
once(t, s) {
this.setSubscriber(t, {
cb: s,
once: !0
});
}
emit(t, ...s) {
const e = this._subscribers.get(t) ?? [], i = [];
for (const n of e) n.cb(...s), n.once && i.push(() => e.splice(e.indexOf(n), 1));
for (const n of i) n();
}
prompt() {
return new Promise((t) => {
if (this._abortSignal) {
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(k);
this._abortSignal.addEventListener("abort", () => {
this.state = "cancel", this.close();
}, { once: !0 });
}
this.rl = l.createInterface({
input: this.input,
tabSize: 2,
prompt: "",
escapeCodeTimeout: 50,
terminal: !0
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), w$1(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
this.output.write(import_src$1.cursor.show), this.output.off("resize", this.render), w$1(this.input, !1), t(this.value);
}), this.once("cancel", () => {
this.output.write(import_src$1.cursor.show), this.output.off("resize", this.render), w$1(this.input, !1), t(k);
});
});
}
_isActionKey(t, s) {
return t === " ";
}
_shouldSubmit(t, s) {
return !0;
}
_setValue(t) {
this.value = t, this.emit("value", this.value);
}
_setUserInput(t, s) {
this.userInput = t ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
}
_clearUserInput() {
this.rl?.write(null, {
ctrl: !0,
name: "u"
}), this._setUserInput("");
}
onKeypress(t, s) {
if (this._track && s.name !== "return" && (s.name && this._isActionKey(t, s) && this.rl?.write(null, {
ctrl: !0,
name: "h"
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && h.aliases.has(s.name) && this.emit("cursor", h.aliases.get(s.name)), h.actions.has(s.name) && this.emit("cursor", s.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t?.toLowerCase(), s), s?.name === "return" && this._shouldSubmit(t, s)) {
if (this.opts.validate) {
const e = this.opts.validate(this.value);
e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.userInput));
}
this.state !== "error" && (this.state = "submit");
}
C([
t,
s?.name,
s?.sequence
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
}
close() {
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
`), w$1(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
}
restoreCursor() {
const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
hard: !0,
trim: !1
}).split(`
`).length - 1;
this.output.write(import_src$1.cursor.move(-999, t * -1));
}
render() {
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
hard: !0,
trim: !1
});
if (t !== this._prevFrame) {
if (this.state === "initial") this.output.write(import_src$1.cursor.hide);
else {
const s = z$1(this._prevFrame, t), e = L(this.output);
if (this.restoreCursor(), s) {
const i = Math.max(0, s.numLinesAfter - e), n = Math.max(0, s.numLinesBefore - e);
let o = s.lines.find((u) => u >= i);
if (o === void 0) {
this._prevFrame = t;
return;
}
if (s.lines.length === 1) {
this.output.write(import_src$1.cursor.move(0, o - n)), this.output.write(import_src$1.erase.lines(1));
const u = t.split(`
`);
this.output.write(u[o]), this._prevFrame = t, this.output.write(import_src$1.cursor.move(0, u.length - o - 1));
return;
} else if (s.lines.length > 1) {
if (i < n) o = i;
else {
const a = o - n;
a > 0 && this.output.write(import_src$1.cursor.move(0, a));
}
this.output.write(import_src$1.erase.down());
const u = t.split(`
`).slice(o);
this.output.write(u.join(`
`)), this._prevFrame = t;
return;
}
}
this.output.write(import_src$1.erase.down());
}
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
}
}
};
function B(r, t) {
if (r === void 0 || t.length === 0) return 0;
const s = t.findIndex((e) => e.value === r);
return s !== -1 ? s : 0;
}
function J$1(r, t) {
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
}
function H$1(r, t) {
if (t) return r ? t : t[0];
}
let Q$1 = class extends p {
filteredOptions;
multiple;
isNavigating = !1;
selectedValues = [];
focusedValue;
#s = 0;
#r = "";
#t;
#n;
#u;
get cursor() {
return this.#s;
}
get userInputWithCursor() {
if (!this.userInput) return styleText(["inverse", "hidden"], "_");
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
const t = this.userInput.slice(0, this._cursor), [s, ...e] = this.userInput.slice(this._cursor);
return `${t}${styleText("inverse", s)}${e.join("")}`;
}
get options() {
return typeof this.#n == "function" ? this.#n() : this.#n;
}
constructor(t) {
super(t), this.#n = t.options, this.#u = t.placeholder;
const s = this.options;
this.filteredOptions = [...s], this.multiple = t.multiple === !0, this.#t = typeof t.options == "function" ? t.filter : t.filter ?? J$1;
let e;
if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? e = t.initialValue : e = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (e = [this.options[0].value]), e) for (const i of e) {
const n = s.findIndex((o) => o.value === i);
n !== -1 && (this.toggleSelected(i), this.#s = n);
}
this.focusedValue = this.options[this.#s]?.value, this.on("key", (i, n) => this.#e(i, n)), this.on("userInput", (i) => this.#i(i));
}
_isActionKey(t, s) {
return t === " " || this.multiple && this.isNavigating && s.name === "space" && t !== void 0 && t !== "";
}
#e(t, s) {
const e = s.name === "up", i = s.name === "down", n = s.name === "return", o = this.userInput === "" || this.userInput === " ", u = this.#u, a = this.options, l = u !== void 0 && u !== "" && a.some((f) => !f.disabled && (this.#t ? this.#t(u, f) : !0));
if (s.name === "tab" && o && l) {
this.userInput === " " && this._clearUserInput(), this._setUserInput(u, !0), this.isNavigating = !1;
return;
}
e || i ? (this.#s = d(this.#s, e ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#s]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = !0) : n ? this.value = H$1(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = !1);
}
deselectAll() {
this.selectedValues = [];
}
toggleSelected(t) {
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((s) => s !== t) : this.selectedValues = [...this.selectedValues, t] : this.selectedValues = [t]);
}
#i(t) {
if (t !== this.#r) {
this.#r = t;
const s = this.options;
t && this.#t ? this.filteredOptions = s.filter((n) => this.#t?.(t, n)) : this.filteredOptions = [...s];
const e = B(this.focusedValue, this.filteredOptions);
this.#s = d(e, 0, this.filteredOptions);
const i = this.filteredOptions[this.#s];
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
}
}
};
var X = class extends p {
get cursor() {
return this.value ? 0 : 1;
}
get _value() {
return this.cursor === 0;
}
constructor(t) {
super(t, !1), this.value = !!t.initialValue, this.on("userInput", () => {
this.value = this._value;
}), this.on("confirm", (s) => {
this.output.write(import_src$1.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
}), this.on("cursor", () => {
this.value = !this.value;
});
}
};
var ut$1 = class extends p {
options;
cursor = 0;
get _selectedValue() {
return this.options[this.cursor];
}
changeValue() {
this.value = this._selectedValue.value;
}
constructor(t) {
super(t, !1), this.options = t.options;
const s = this.options.findIndex(({ value: i }) => i === t.initialValue), e = s === -1 ? 0 : s;
this.cursor = this.options[e].disabled ? d(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (i) => {
switch (i) {
case "left":
case "up":
this.cursor = d(this.cursor, -1, this.options);
break;
case "down":
case "right":
this.cursor = d(this.cursor, 1, this.options);
break;
}
this.changeValue();
});
}
};
var ht$1 = class extends p {
get userInputWithCursor() {
if (this.state === "submit") return this.userInput;
const t = this.userInput;
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
const s = t.slice(0, this.cursor), [e, ...i] = t.slice(this.cursor);
return `${s}${styleText("inverse", e)}${i.join("")}`;
}
get cursor() {
return this._cursor;
}
constructor(t) {
super({
...t,
initialUserInput: t.initialUserInput ?? t.initialValue
}), this.on("userInput", (s) => {
this._setValue(s);
}), this.on("finalize", () => {
this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
});
}
};
//#endregion
//#region ../../node_modules/.pnpm/@clack+prompts@1.3.0/node_modules/@clack/prompts/dist/index.mjs
function te() {
return process$1.platform !== "win32" ? process$1.env.TERM !== "linux" : !!process$1.env.CI || !!process$1.env.WT_SESSION || !!process$1.env.TERMINUS_SUBLIME || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
}
const tt = te(), at = () => process.env.CI === "true", Tt = (t) => t.isTTY === !0, w = (t, r) => tt ? t : r, _t = w("◆", "*"), ot = w("■", "x"), ut = w("▲", "x"), F = w("◇", "o"), lt = w("┌", "T"), $ = w("│", "|"), E = w("└", "—"), It = w("┐", "T"), Et = w("┘", "—"), z = w("●", ">"), H = w("○", " ");
w("◻", "[•]");
const U = w("◼", "[+]"), J = w("◻", "[ ]");
w("▪", "•");
const st = w("─", "-"), ct = w("╮", "+"), xt = w("├", "+"), $t = w("╯", "+"), dt = w("╰", "+"), Ot = w("╭", "+"), ht = w("●", "•"), pt = w("◆", "*"), mt = w("▲", "!"), gt = w("■", "x"), M = (t) => {
switch (t) {
case "initial":
case "active": return styleText("cyan", _t);
case "cancel": return styleText("red", ot);
case "error": return styleText("yellow", ut);
case "submit": return styleText("green", F);
}
}, yt = (t) => {
switch (t) {
case "initial":
case "active": return styleText("cyan", $);
case "cancel": return styleText("red", $);
case "error": return styleText("yellow", $);
case "submit": return styleText("green", $);
}
}, ee = (t, r, s, i, u) => {
let n = r, o = 0;
for (let c = s; c < i; c++) {
const a = t[c];
if (n = n - a.length, o++, n <= u) break;
}
return {
lineCount: n,
removals: o
};
}, Y = ({ cursor: t, options: r, style: s, output: i = process.stdout, maxItems: u = Number.POSITIVE_INFINITY, columnPadding: n = 0, rowPadding: o = 4 }) => {
const c = A(i) - n, a = L(i), l = styleText("dim", "..."), d = Math.max(a - o, 0), y = Math.max(Math.min(u, d), 5);
let p = 0;
t >= y - 3 && (p = Math.max(Math.min(t - y + 3, r.length - y), 0));
let m = y < r.length && p > 0, g = y < r.length && p + y < r.length;
const S = Math.min(p + y, r.length), h = [];
let f = 0;
m && f++, g && f++;
const v = p + (m ? 1 : 0), T = S - (g ? 1 : 0);
for (let b = v; b < T; b++) {
const G = wrapAnsi(s(r[b], b === t), c, {
hard: !0,
trim: !1
}).split(`
`);
h.push(G), f += G.length;
}
if (f > d) {
let b = 0, G = 0, x = f;
const A = t - v, P = (N, D) => ee(h, x, N, D, d);
m ? ({lineCount: x, removals: b} = P(0, A), x > d && ({lineCount: x, removals: G} = P(A + 1, h.length))) : ({lineCount: x, removals: G} = P(A + 1, h.length), x > d && ({lineCount: x, removals: b} = P(0, A))), b > 0 && (m = !0, h.splice(0, b)), G > 0 && (g = !0, h.splice(h.length - G, G));
}
const C = [];
m && C.push(l);
for (const b of h) for (const G of b) C.push(G);
return g && C.push(l), C;
};
function Rt(t, r) {
if (!t) return !0;
const s = (r.label ?? String(r.value ?? "")).toLowerCase(), i = (r.hint ?? "").toLowerCase(), u = String(r.value).toLowerCase(), n = t.toLowerCase();
return s.includes(n) || i.includes(n) || u.includes(n);
}
const ie = (t) => {
const r = (i, u, n, o) => {
const c = n.includes(i.value), a = i.label ?? String(i.value ?? ""), l = i.hint && o !== void 0 && i.value === o ? styleText("dim", ` (${i.hint})`) : "", d = c ? styleText("green", U) : styleText("dim", J);
return i.disabled ? `${styleText("gray", J)} ${styleText(["strikethrough", "gray"], a)}` : u ? `${d} ${a}${l}` : `${d} ${styleText("dim", a)}`;
}, s = new Q$1({
options: t.options,
multiple: !0,
placeholder: t.placeholder,
filter: t.filter ?? ((i, u) => Rt(i, u)),
validate: () => {
if (t.required && s.selectedValues.length === 0) return "Please select at least one item";
},
initialValue: t.initialValues,
signal: t.signal,
input: t.input,
output: t.output,
render() {
const i = t.withGuide ?? h.withGuide, u = `${i ? `${styleText("gray", $)}
` : ""}${M(this.state)} ${t.message}
`, n = this.userInput, o = t.placeholder, c = n === "" && o !== void 0, a = this.isNavigating || c ? styleText("dim", c ? o : n) : this.userInputWithCursor, l = this.options, d = this.filteredOptions.length !== l.length ? styleText("dim", ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
switch (this.state) {
case "submit": return `${u}${i ? `${styleText("gray", $)} ` : ""}${styleText("dim", `${this.selectedValues.length} items selected`)}`;
case "cancel": return `${u}${i ? `${styleText("gray", $)} ` : ""}${styleText(["strikethrough", "dim"], n)}`;
default: {
const y = this.state === "error" ? "yellow" : "cyan", p = i ? `${styleText(y, $)} ` : "", m = i ? styleText(y, E) : "", g = [
`${styleText("dim", "↑/↓")} to navigate`,
`${styleText("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
`${styleText("dim", "Enter:")} confirm`,
`${styleText("dim", "Type:")} to search`
], S = this.filteredOptions.length === 0 && n ? [`${p}${styleText("yellow", "No matches found")}`] : [], h = this.state === "error" ? [`${p}${styleText("yellow", this.error)}`] : [], f = [
...`${u}${i ? styleText(y, $) : ""}`.split(`
`),
`${p}${styleText("dim", "Search:")} ${a}${d}`,
...S,
...h
], v = [`${p}${g.join(" • ")}`, m], T = Y({
cursor: this.cursor,
options: this.filteredOptions,
style: (C, b) => r(C, b, this.selectedValues, this.focusedValue),
maxItems: t.maxItems,
output: t.output,
rowPadding: f.length + v.length
});
return [
...f,
...T.map((C) => `${p}${C}`),
...v
].join(`
`);
}
}
}
});
return s.prompt();
}, re = [
Ot,
ct,
dt,
$t
], ne = [
lt,
It,
E,
Et
];
function Pt(t, r, s, i) {
let u = s, n = s;
return i === "center" ? u = Math.floor((r - t) / 2) : i === "right" && (u = r - t - s), n = r - u - t, [u, n];
}
const ae = (t) => t, oe = (t = "", r = "", s) => {
const i = s?.output ?? process.stdout, u = A(i), n = 2, o = s?.titlePadding ?? 1, c = s?.contentPadding ?? 2, a = s?.width === void 0 || s.width === "auto" ? 1 : Math.min(1, s.width), l = s?.withGuide ?? h.withGuide ? `${$} ` : "", d = s?.formatBorder ?? ae, y = (s?.rounded ? re : ne).map(d), p = d(st), m = d($), g = fastStringWidth(l), S = fastStringWidth(r), h$1 = u - g;
let f = Math.floor(u * a) - g;
if (s?.width === "auto") {
const P = t.split(`
`);
let N = S + o * 2;
for (const rt of P) {
const W = fastStringWidth(rt) + c * 2;
W > N && (N = W);
}
const D = N + n;
D < f && (f = D);
}
f % 2 !== 0 && (f < h$1 ? f++ : f--);
const v = f - n, T = v - o * 2, C = S > T ? `${r.slice(0, T - 3)}...` : r, [b, G] = Pt(fastStringWidth(C), v, o, s?.titleAlign), x = wrapAnsi(t, v - c * 2, {
hard: !0,
trim: !1
});
i.write(`${l}${y[0]}${p.repeat(b)}${C}${p.repeat(G)}${y[1]}
`);
const A$1 = x.split(`
`);
for (const P of A$1) {
const [N, D] = Pt(fastStringWidth(P), v, c, s?.contentAlign);
i.write(`${l}${m}${" ".repeat(N)}${P}${" ".repeat(D)}${m}
`);
}
i.write(`${l}${y[2]}${p.repeat(v)}${y[3]}
`);
}, ue = (t) => {
const r = t.active ?? "Yes", s = t.inactive ?? "No";
return new X({
active: r,
inactive: s,
signal: t.signal,
input: t.input,
output: t.output,
initialValue: t.initialValue ?? !0,
render() {
const i = t.withGuide ?? h.withGuide, u = `${M(this.state)} `, n = i ? `${styleText("gray", $)} ` : "", o = W(t.output, t.message, n, u), c = `${i ? `${styleText("gray", $)}
` : ""}${o}
`, a = this.value ? r : s;
switch (this.state) {
case "submit": return `${c}${i ? `${styleText("gray", $)} ` : ""}${styleText("dim", a)}`;
case "cancel": return `${c}${i ? `${styleText("gray", $)} ` : ""}${styleText(["strikethrough", "dim"], a)}${i ? `
${styleText("gray", $)}` : ""}`;
default: {
const l = i ? `${styleText("cyan", $)} ` : "", d = i ? styleText("cyan", E) : "";
return `${c}${l}${this.value ? `${styleText("green", z)} ${r}` : `${styleText("dim", H)} ${styleText("dim", r)}`}${t.vertical ? i ? `
${styleText("cyan", $)} ` : `
` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", H)} ${styleText("dim", s)}` : `${styleText("green", z)} ${s}`}
${d}
`;
}
}
}
}).prompt();
}, R = {
message: (t = [], { symbol: r = styleText("gray", $), secondarySymbol: s = styleText("gray", $), output: i = process.stdout, spacing: u = 1, withGuide: n } = {}) => {
const o = [], c = n ?? h.withGuide, a = c ? s : "", l = c ? `${r} ` : "", d = c ? `${s} ` : "";
for (let p = 0; p < u; p++) o.push(a);
const y = Array.isArray(t) ? t : t.split(`
`);
if (y.length > 0) {
const [p, ...m] = y;
p.length > 0 ? o.push(`${l}${p}`) : o.push(c ? r : "");
for (const g of m) g.length > 0 ? o.push(`${d}${g}`) : o.push(c ? s : "");
}
i.write(`${o.join(`
`)}
`);
},
info: (t, r) => {
R.message(t, {
...r,
symbol: styleText("blue", ht)
});
},
success: (t, r) => {
R.message(t, {
...r,
symbol: styleText("green", pt)
});
},
step: (t, r) => {
R.message(t, {
...r,
symbol: styleText("green", F)
});
},
warn: (t, r) => {
R.message(t, {
...r,
symbol: styleText("yellow", mt)
});
},
warning: (t, r) => {
R.warn(t, r);
},
error: (t, r) => {
R.message(t, {
...r,
symbol: styleText("red", gt)
});
}
}, me = (t = "", r) => {
const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${styleText("gray", E)} ` : "";
s.write(`${i}${styleText("red", t)}
`);
}, ge = (t = "", r) => {
const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${styleText("gray", lt)} ` : "";
s.write(`${i}${t}
`);
}, ye = (t = "", r) => {
const s = r?.output ?? process.stdout, i = r?.withGuide ?? h.withGuide ? `${styleText("gray", $)}
${styleText("gray", E)} ` : "";
s.write(`${i}${t}
`);
}, we = (t) => styleText("dim", t), be = (t, r, s) => {
const i = {
hard: !0,
trim: !1
}, u = wrapAnsi(t, r, i).split(`
`), n = u.reduce((a, l) => Math.max(fastStringWidth(l), a), 0);
return wrapAnsi(t, r - (u.map(s).reduce((a, l) => Math.max(fastStringWidth(l), a), 0) - n), i);
}, Se = (t = "", r = "", s) => {
const i = s?.output ?? process$1.stdout, u = s?.withGuide ?? h.withGuide, n = s?.format ?? we, o = [
"",
...be(t, A(i) - 6, n).split(`
`).map(n),
""
], c = fastStringWidth(r), a = Math.max(o.reduce((p, m) => {
const g = fastStringWidth(m);
return g > p ? g : p;
}, 0), c) + 2, l = o.map((p) => `${styleText("gray", $)} ${p}${" ".repeat(a - fastStringWidth(p))}${styleText("gray", $)}`).join(`
`), d = u ? `${styleText("gray", $)}
` : "", y = u ? xt : dt;
i.write(`${d}${styleText("green", F)} ${styleText("reset", r)} ${styleText("gray", st.repeat(Math.max(a - c - 1, 1)) + ct)}
${l}
${styleText("gray", y + st.repeat(a + 2) + $t)}
`);
}, _e = (t) => styleText("magenta", t), ft = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: u, frames: n = tt ? [
"◒",
"◐",
"◓",
"◑"
] : [
"•",
"o",
"O",
"0"
], delay: o = tt ? 80 : 120, signal: c, ...a } = {}) => {
const l = at();
let d, y, p = !1, m = !1, g = "", S, h$2 = performance.now();
const f = A(s), v = a?.styleFrame ?? _e, T = (I) => {
const V = I > 1 ? u ?? h.messages.error : i ?? h.messages.cancel;
m = I === 1, p && (W(V, I), m && typeof r == "function" && r());
}, C = () => T(2), b = () => T(1), G = () => {
process.on("uncaughtExceptionMonitor", C), process.on("unhandledRejection", C), process.on("SIGINT", b), process.on("SIGTERM", b), process.on("exit", T), c && c.addEventListener("abort", b);
}, x = () => {
process.removeListener("uncaughtExceptionMonitor", C), process.removeListener("unhandledRejection", C), process.removeListener("SIGINT", b), process.removeListener("SIGTERM", b), process.removeListener("exit", T), c && c.removeEventListener("abort", b);
}, A$2 = () => {
if (S === void 0) return;
l && s.write(`
`);
const I = wrapAnsi(S, f, {
hard: !0,
trim: !1
}).split(`
`);
I.length > 1 && s.write(import_src$1.cursor.up(I.length - 1)), s.write(import_src$1.cursor.to(0)), s.write(import_src$1.erase.down());
}, P = (I) => I.replace(/\.+$/, ""), N = (I) => {
const V = (performance.now() - I) / 1e3, B = Math.floor(V / 60), L = Math.floor(V % 60);
return B > 0 ? `[${B}m ${L}s]` : `[${L}s]`;
}, D = a.withGuide ?? h.withGuide, rt = (I = "") => {
p = !0, d = R$1({ output: s }), g = P(I), h$2 = performance.now(), D && s.write(`${styleText("gray", $)}
`);
let V = 0, B = 0;
G(), y = setInterval(() => {
if (l && g === S) return;
A$2(), S = g;
const L = v(n[V]);
let Z;
if (l) Z = `${L} ${g}...`;
else if (t === "timer") Z = `${L} ${g} ${N(h$2)}`;
else {
const kt = ".".repeat(Math.floor(B)).slice(0, 3);
Z = `${L} ${g}${kt}`;
}
const Nt = wrapAnsi(Z, f, {
hard: !0,
trim: !1
});
s.write(Nt), V = V + 1 < n.length ? V + 1 : 0, B = B < 4 ? B + .125 : 0;
}, o);
}, W = (I = "", V = 0, B = !1) => {
if (!p) return;
p = !1, clearInterval(y), A$2();
const L = V === 0 ? styleText("green", F) : V === 1 ? styleText("red", ot) : styleText("red", ut);
g = I ?? g, B || (t === "timer" ? s.write(`${L} ${g} ${N(h$2)}
`) : s.write(`${L} ${g}
`)), x(), d();
};
return {
start: rt,
stop: (I = "") => W(I, 0),
message: (I = "") => {
g = P(I ?? g);
},
cancel: (I = "") => W(I, 1),
error: (I = "") => W(I, 2),
clear: () => W("", 0, !0),
get isCancelled() {
return m;
}
};
};
w("─", "-"), w("━", "="), w("█", "#");
const it = (t, r) => t.includes(`
`) ? t.split(`
`).map((s) => r(s)).join(`
`) : r(t), Ee = (t) => {
const r = (s, i) => {
const u = s.label ?? String(s.value);
switch (i) {
case "disabled": return `${styleText("gray", H)} ${it(u, (n) => styleText("gray", n))}${s.hint ? ` ${styleText("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
case "selected": return `${it(u, (n) => styleText("dim", n))}`;
case "active": return `${styleText("green", z)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
case "cancelled": return `${it(u, (n) => styleText(["strikethrough", "dim"], n))}`;
default: return `${styleText("dim", H)} ${it(u, (n) => styleText("dim", n))}`;
}
};
return new ut$1({
options: t.options,
signal: t.signal,
input: t.input,
output: t.output,
initialValue: t.initialValue,
render() {
const s = t.withGuide ?? h.withGuide, i = `${M(this.state)} `, u = `${yt(this.state)} `, n = W(t.output, t.message, u, i), o = `${s ? `${styleText("gray", $)}
` : ""}${n}
`;
switch (this.state) {
case "submit": {
const c = s ? `${styleText("gray", $)} ` : "";
return `${o}${W(t.output, r(this.options[this.cursor], "selected"), c)}`;
}
case "cancel": {
const c = s ? `${styleText("gray", $)} ` : "";
return `${o}${W(t.output, r(this.options[this.cursor], "cancelled"), c)}${s ? `
${styleText("gray", $)}` : ""}`;
}
default: {
const c = s ? `${styleText("cyan", $)} ` : "", a = s ? styleText("cyan", E) : "", l = o.split(`
`).length, d = s ? 2 : 1;
return `${o}${c}${Y({
output: t.output,
cursor: this.cursor,
options: this.options,
maxItems: t.maxItems,
columnPadding: c.length,
rowPadding: l + d,
style: (y, p) => r(y, y.disabled ? "disabled" : p ? "active" : "inactive")
}).join(`
${c}`)}
${a}
`;
}
}
}
}).prompt();
}, jt = `${styleText("gray", $)} `, K = {
message: async (t, { symbol: r = styleText("gray", $) } = {}) => {
process.stdout.write(`${styleText("gray", $)}
${r} `);
let s = 3;
for await (let i of t) {
i = i.replace(/\n/g, `
${jt}`), i.includes(`
`) && (s = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
`))).length);
const u = stripVTControlCharacters(i).length;
s + u < process.stdout.columns ? (s += u, process.stdout.write(i)) : (process.stdout.write(`
${jt}${i.trimStart()}`), s = 3 + stripVTControlCharacters(i.trimStart()).length);
}
process.stdout.write(`
`);
},
info: (t) => K.message(t, { symbol: styleText("blue", ht) }),
success: (t) => K.message(t, { symbol: styleText("green", pt) }),
step: (t) => K.message(t, { symbol: styleText("green", F) }),
warn: (t) => K.message(t, { symbol: styleText("yellow", mt) }),
warning: (t) => K.warn(t),
error: (t) => K.message(t, { symbol: styleText("red", gt) })
}, xe = async (t, r) => {
for (const s of t) {
if (s.enabled === !1) continue;
const i = ft(r);
i.start(s.title);
const u = await s.task(i.message);
i.stop(u || s.title);
}
}, Oe = (t) => t.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), Me = (t) => {
const r = t.output ?? process.stdout, s = A(r), i = styleText("gray", $), u = t.spacing ?? 1, n = 3, o = t.retainLog === !0, c = !at() && Tt(r);
r.write(`${i}
`), r.write(`${styleText("green", F)} ${t.title}
`);
for (let h = 0; h < u; h++) r.write(`${i}
`);
const a = [{
value: "",
full: ""
}];
let l = !1;
const d = (h) => {
if (a.length === 0) return;
let f = 0;
h && (f += u + 2);
for (const v of a) {
const { value: T, result: C } = v;
let b = C?.message ?? T;
if (b.length === 0) continue;
C === void 0 && v.header !== void 0 && v.header !== "" && (b += `
${v.header}`);
const G = b.split(`
`).reduce((x, A) => A === "" ? x + 1 : x + Math.ceil((A.length + n) / s), 0);
f += G;
}
f > 0 && (f += 1, r.write(import_src$1.erase.lines(f)));
}, y = (h, f, v) => {
const T = v ? `${h.full}
${h.value}` : h.value;
h.header !== void 0 && h.header !== "" && R.message(h.header.split(`
`).map((C) => styleText("bold", C)), {
output: r,
secondarySymbol: i,
symbol: i,
spacing: 0
}), R.message(T.split(`
`).map((C) => styleText("dim", C)), {
output: r,
secondarySymbol: i,
symbol: i,
spacing: f ?? u
});
}, p = () => {
for (const h of a) {
const { header: f, value: v, full: T } = h;
(f === void 0 || f.length === 0) && v.length === 0 || y(h, void 0, o === !0 && T.length > 0);
}
}, m = (h, f, v) => {
if (d(!1), (v?.raw !== !0 || !l) && h.value !== "" && (h.value += `
`), h.value += Oe(f), l = v?.raw === !0, t.limit !== void 0) {
const T = h.value.split(`
`), C = T.length - t.limit;
if (C > 0) {
const b = T.splice(0, C);
o && (h.full += (h.full === "" ? "" : `
`) + b.join(`
`));
}
h.value = T.join(`
`);
}
c && g();
}, g = () => {
for (const h of a) h.result ? h.result.status === "error" ? R.error(h.result.message, {
output: r,
secondarySymbol: i,
spacing: 0
}) : R.success(h.result.message, {
output: r,
secondarySymbol: i,
spacing: 0
}) : h.value !== "" && y(h, 0);
}, S = (h, f) => {
d(!1), h.result = f, c && g();
};
return {
message(h, f) {
m(a[0], h, f);
},
group(h) {
const f = {
header: h,
value: "",
full: ""
};
return a.push(f), {
message(v, T) {
m(f, v, T);
},
error(v) {
S(f, {
status: "error",
message: v
});
},
success(v) {
S(f, {
status: "success",
message: v
});
}
};
},
error(h, f) {
d(!0), R.error(h, {
output: r,
secondarySymbol: i,
spacing: 1
}), f?.showLog !== !1 && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
},
success(h, f) {
d(!0), R.success(h, {
output: r,
secondarySymbol: i,
spacing: 1
}), f?.showLog === !0 && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
}
};
}, Re = (t) => new ht$1({
validate: t.validate,
placeholder: t.placeholder,
defaultValue: t.defaultValue,
initialValue: t.initialValue,
output: t.output,
signal: t.signal,
input: t.input,
render() {
const r = t?.withGuide ?? h.withGuide, s = `${`${r ? `${styleText("gray", $)}
` : ""}${M(this.state)} `}${t.message}
`, i = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText(["inverse", "hidden"], "_"), u = this.userInput ? this.userInputWithCursor : i, n = this.value ?? "";
switch (this.state) {
case "error": {
const o = this.error ? ` ${styleText("yellow", this.error)}` : "", c = r ? `${styleText("yellow", $)} ` : "", a = r ? styleText("yellow", E) : "";
return `${s.trim()}
${c}${u}
${a}${o}
`;
}
case "submit": {
const o = n ? ` ${styleText("dim", n)}` : "";
return `${s}${r ? styleText("gray", $) : ""}${o}`;
}
case "cancel": {
const o = n ? ` ${styleText(["strikethrough", "dim"], n)}` : "", c = r ? styleText("gray", $) : "";
return `${s}${c}${o}${n.trim() ? `
${c}` : ""}`;
}
default: return `${s}${r ? `${styleText("cyan", $)} ` : ""}${u}
${r ? styleText("cyan", E) : ""}
`;
}
}
}).prompt();
//#endregion
//#region ../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
var require_ms = /* @__PURE__ */ __commonJSMin(((exports, module) => {
/**
* Helpers.
*/
var s = 1e3;
var m = s * 60;
var h = m * 60;
var d = h * 24;
var w = d * 7;
var y = d * 365.25;
/**
* Parse or format the given `val`.
*
* Options:
*
* - `long` verbose formatting [false]
*
* @param {String|Number} val
* @param {Object} [options]
* @throws {Error} throw an error if val is not a non-empty string or a number
* @return {String|Number}
* @api public
*/
module.exports = function(val, options) {
options = options || {};
var type = typeof val;
if (type === "string" && val.length > 0) return parse(val);
else if (type === "number" && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
};
/**
* Parse the given `str` and return milliseconds.
*
* @param {String} str
* @return {Number}
* @api private
*/
function parse(str) {
str = String(str);
if (str.length > 100) return;
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
if (!match) return;
var n = parseFloat(match[1]);
switch ((match[2] || "ms").toLowerCase()) {
case "years":
case "year":
case "yrs":
case "yr":
case "y": return n * y;
case "weeks":
case "week":
case "w": return n * w;
case "days":
case "day":
case "d": return n * d;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h": return n * h;
case "minutes":
case "minute":
case "mins":
case "min":
case "m": return n * m;
case "seconds":
case "second":
case "secs":
case "sec":
case "s": return n * s;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms": return n;
default: return;
}
}
/**