npm-check-updates
Version:
Find newer versions of dependencies than what your package.json allows
1,229 lines (1,228 loc) • 1.79 MB
JavaScript
import { createRequire as vh } from "node:module";
import We from "path";
import Wr from "fs";
import Jr from "os";
import hm from "util";
import Qe from "fs/promises";
import qi from "node:process";
import Ri from "node:os";
import bc from "node:tty";
import { URL as fm } from "url";
import lt, { dirname as dm } from "node:path";
import { fileURLToPath as Wo } from "node:url";
import { promisify as yh, stripVTControlCharacters as pm } from "node:util";
import ua, { promises as wc } from "node:fs";
import gm, { execFile as mm } from "node:child_process";
import { text as vm } from "node:stream/consumers";
var ym = Object.create, Oi = Object.defineProperty, _m = Object.getOwnPropertyDescriptor, bm = Object.getOwnPropertyNames, wm = Object.getPrototypeOf, _h = Object.prototype.hasOwnProperty, $t = (e, t) => () => (e && (t = e(e = 0)), t), U = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), ft = (e, t) => {
let r = {};
for (var i in e)
Oi(r, i, {
get: e[i],
enumerable: !0
});
return t || Oi(r, Symbol.toStringTag, { value: "Module" }), r;
}, bh = (e, t, r, i) => {
if (t && typeof t == "object" || typeof t == "function")
for (var n = bm(t), h = 0, a = n.length, s; h < a; h++)
s = n[h], !_h.call(e, s) && s !== r && Oi(e, s, {
get: ((c) => t[c]).bind(null, s),
enumerable: !(i = _m(t, s)) || i.enumerable
});
return e;
}, Bt = (e, t, r) => (r = e != null ? ym(wm(e)) : {}, bh(t || !e || !e.__esModule ? Oi(r, "default", {
value: e,
enumerable: !0
}) : r, e)), yt = (e) => _h.call(e, "module.exports") ? e["module.exports"] : bh(Oi({}, "__esModule", { value: !0 }), e), ge = /* @__PURE__ */ vh(import.meta.url), Gt = /* @__PURE__ */ U(((e, t) => {
var r, i, n, h, a = !0;
typeof process < "u" && ({ FORCE_COLOR: r, NODE_DISABLE_COLORS: i, NO_COLOR: n, TERM: h } = process.env || {}, a = process.stdout && process.stdout.isTTY);
var s = {
enabled: !i && n == null && h !== "dumb" && (r != null && r !== "0" || a),
reset: f(0, 0),
bold: f(1, 22),
dim: f(2, 22),
italic: f(3, 23),
underline: f(4, 24),
inverse: f(7, 27),
hidden: f(8, 28),
strikethrough: f(9, 29),
black: f(30, 39),
red: f(31, 39),
green: f(32, 39),
yellow: f(33, 39),
blue: f(34, 39),
magenta: f(35, 39),
cyan: f(36, 39),
white: f(37, 39),
gray: f(90, 39),
grey: f(90, 39),
bgBlack: f(40, 49),
bgRed: f(41, 49),
bgGreen: f(42, 49),
bgYellow: f(43, 49),
bgBlue: f(44, 49),
bgMagenta: f(45, 49),
bgCyan: f(46, 49),
bgWhite: f(47, 49)
};
function c(l, u) {
let d = 0, p, g = "", m = "";
for (; d < l.length; d++)
p = l[d], g += p.open, m += p.close, ~u.indexOf(p.close) && (u = u.replace(p.rgx, p.close + p.open));
return g + u + m;
}
function o(l, u) {
let d = {
has: l,
keys: u
};
return d.reset = s.reset.bind(d), d.bold = s.bold.bind(d), d.dim = s.dim.bind(d), d.italic = s.italic.bind(d), d.underline = s.underline.bind(d), d.inverse = s.inverse.bind(d), d.hidden = s.hidden.bind(d), d.strikethrough = s.strikethrough.bind(d), d.black = s.black.bind(d), d.red = s.red.bind(d), d.green = s.green.bind(d), d.yellow = s.yellow.bind(d), d.blue = s.blue.bind(d), d.magenta = s.magenta.bind(d), d.cyan = s.cyan.bind(d), d.white = s.white.bind(d), d.gray = s.gray.bind(d), d.grey = s.grey.bind(d), d.bgBlack = s.bgBlack.bind(d), d.bgRed = s.bgRed.bind(d), d.bgGreen = s.bgGreen.bind(d), d.bgYellow = s.bgYellow.bind(d), d.bgBlue = s.bgBlue.bind(d), d.bgMagenta = s.bgMagenta.bind(d), d.bgCyan = s.bgCyan.bind(d), d.bgWhite = s.bgWhite.bind(d), d;
}
function f(l, u) {
let d = {
open: `\x1B[${l}m`,
close: `\x1B[${u}m`,
rgx: new RegExp(`\\x1b\\[${u}m`, "g")
};
return function(p) {
return this !== void 0 && this.has !== void 0 ? (~this.has.indexOf(l) || (this.has.push(l), this.keys.push(d)), p === void 0 ? this : s.enabled ? c(this.keys, p + "") : p + "") : p === void 0 ? o([l], [d]) : s.enabled ? c([d], p + "") : p + "";
};
}
t.exports = s;
})), Em = /* @__PURE__ */ U(((e, t) => {
t.exports = (r, i) => {
if (!(r.meta && r.name !== "escape")) {
if (r.ctrl) {
if (r.name === "a") return "first";
if (r.name === "c" || r.name === "d") return "abort";
if (r.name === "e") return "last";
if (r.name === "g") return "reset";
}
if (i) {
if (r.name === "j") return "down";
if (r.name === "k") return "up";
}
return r.name === "return" || r.name === "enter" ? "submit" : r.name === "backspace" ? "delete" : r.name === "delete" ? "deleteForward" : r.name === "abort" ? "abort" : r.name === "escape" ? "exit" : r.name === "tab" ? "next" : r.name === "pagedown" ? "nextPage" : r.name === "pageup" ? "prevPage" : r.name === "home" ? "home" : r.name === "end" ? "end" : r.name === "up" ? "up" : r.name === "down" ? "down" : r.name === "right" ? "right" : r.name === "left" ? "left" : !1;
}
};
})), Vo = /* @__PURE__ */ U(((e, t) => {
t.exports = (r) => {
const i = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"), n = new RegExp(i, "g");
return typeof r == "string" ? r.replace(n, "") : r;
};
})), zt = /* @__PURE__ */ U(((e, t) => {
var r = "\x1B", i = `${r}[`, n = "\x07", h = {
to(c, o) {
return o ? `${i}${o + 1};${c + 1}H` : `${i}${c + 1}G`;
},
move(c, o) {
let f = "";
return c < 0 ? f += `${i}${-c}D` : c > 0 && (f += `${i}${c}C`), o < 0 ? f += `${i}${-o}A` : o > 0 && (f += `${i}${o}B`), f;
},
up: (c = 1) => `${i}${c}A`,
down: (c = 1) => `${i}${c}B`,
forward: (c = 1) => `${i}${c}C`,
backward: (c = 1) => `${i}${c}D`,
nextLine: (c = 1) => `${i}E`.repeat(c),
prevLine: (c = 1) => `${i}F`.repeat(c),
left: `${i}G`,
hide: `${i}?25l`,
show: `${i}?25h`,
save: `${r}7`,
restore: `${r}8`
}, a = {
up: (c = 1) => `${i}S`.repeat(c),
down: (c = 1) => `${i}T`.repeat(c)
}, s = {
screen: `${i}2J`,
up: (c = 1) => `${i}1J`.repeat(c),
down: (c = 1) => `${i}J`.repeat(c),
line: `${i}2K`,
lineEnd: `${i}K`,
lineStart: `${i}1K`,
lines(c) {
let o = "";
for (let f = 0; f < c; f++) o += this.line + (f < c - 1 ? h.up() : "");
return c && (o += h.left), o;
}
};
t.exports = {
cursor: h,
scroll: a,
erase: s,
beep: n
};
})), Sm = /* @__PURE__ */ U(((e, t) => {
var r = Vo(), { erase: i, cursor: n } = zt(), h = (a) => [...r(a)].length;
t.exports = function(a, s) {
if (!s) return i.line + n.to(0);
let c = 0;
const o = a.split(/\r?\n/);
for (let f of o) c += 1 + Math.floor(Math.max(h(f) - 1, 0) / s);
return i.lines(c);
};
})), wh = /* @__PURE__ */ U(((e, t) => {
var r = {
arrowUp: "↑",
arrowDown: "↓",
arrowLeft: "←",
arrowRight: "→",
radioOn: "◉",
radioOff: "◯",
tick: "✔",
cross: "✖",
ellipsis: "…",
pointerSmall: "›",
line: "─",
pointer: "❯"
}, i = {
arrowUp: r.arrowUp,
arrowDown: r.arrowDown,
arrowLeft: r.arrowLeft,
arrowRight: r.arrowRight,
radioOn: "(*)",
radioOff: "( )",
tick: "√",
cross: "×",
ellipsis: "...",
pointerSmall: "»",
line: "─",
pointer: ">"
}, n = process.platform === "win32" ? i : r;
t.exports = n;
})), Am = /* @__PURE__ */ U(((e, t) => {
var r = Gt(), i = wh(), n = Object.freeze({
password: {
scale: 1,
render: (f) => "*".repeat(f.length)
},
emoji: {
scale: 2,
render: (f) => "😃".repeat(f.length)
},
invisible: {
scale: 0,
render: (f) => ""
},
default: {
scale: 1,
render: (f) => `${f}`
}
}), h = (f) => n[f] || n.default, a = Object.freeze({
aborted: r.red(i.cross),
done: r.green(i.tick),
exited: r.yellow(i.cross),
default: r.cyan("?")
}), s = (f, l, u) => l ? a.aborted : u ? a.exited : f ? a.done : a.default, c = (f) => r.gray(f ? i.ellipsis : i.pointerSmall), o = (f, l) => r.gray(f ? l ? i.pointerSmall : "+" : i.line);
t.exports = {
styles: n,
render: h,
symbols: a,
symbol: s,
delimiter: c,
item: o
};
})), Tm = /* @__PURE__ */ U(((e, t) => {
var r = Vo();
t.exports = function(i, n) {
let h = String(r(i) || "").split(/\r?\n/);
return n ? h.map((a) => Math.ceil(a.length / n)).reduce((a, s) => a + s) : h.length;
};
})), Dm = /* @__PURE__ */ U(((e, t) => {
t.exports = (r, i = {}) => {
const n = Number.isSafeInteger(parseInt(i.margin)) ? new Array(parseInt(i.margin)).fill(" ").join("") : i.margin || "", h = i.width;
return (r || "").split(/\r?\n/g).map((a) => a.split(/\s+/g).reduce((s, c) => (c.length + n.length >= h || s[s.length - 1].length + c.length + 1 < h ? s[s.length - 1] += ` ${c}` : s.push(`${n}${c}`), s), [n]).join(`
`)).join(`
`);
};
})), Rm = /* @__PURE__ */ U(((e, t) => {
t.exports = (r, i, n) => {
n = n || i;
let h = Math.min(i - n, r - Math.floor(n / 2));
h < 0 && (h = 0);
let a = Math.min(h + n, i);
return {
startIndex: h,
endIndex: a
};
};
})), er = /* @__PURE__ */ U(((e, t) => {
t.exports = {
action: Em(),
clear: Sm(),
style: Am(),
strip: Vo(),
figures: wh(),
lines: Tm(),
wrap: Dm(),
entriesToDisplay: Rm()
};
})), fr = /* @__PURE__ */ U(((e, t) => {
var r = ge("readline"), { action: i } = er(), n = ge("events"), { beep: h, cursor: a } = zt(), s = Gt(), c = class extends n {
constructor(o = {}) {
super(), this.firstRender = !0, this.in = o.stdin || process.stdin, this.out = o.stdout || process.stdout, this.onRender = (o.onRender || (() => {
})).bind(this);
const f = r.createInterface({
input: this.in,
escapeCodeTimeout: 50
});
r.emitKeypressEvents(this.in, f), this.in.isTTY && this.in.setRawMode(!0);
const l = (u, d) => {
let p = i(d, this.isSelect);
p === !1 ? this._ && this._(u, d) : typeof this[p] == "function" ? this[p](d) : this.bell();
};
this.close = () => {
this.out.write(a.show), this.in.removeListener("keypress", l), this.in.isTTY && this.in.setRawMode(!1), f.close(), this.emit(this.aborted ? "abort" : this.exited ? "exit" : "submit", this.value), this.closed = !0;
}, this.in.on("keypress", l);
}
fire() {
this.emit("state", {
value: this.value,
aborted: !!this.aborted,
exited: !!this.exited
});
}
bell() {
this.out.write(h);
}
render() {
this.onRender(s), this.firstRender && (this.firstRender = !1);
}
};
t.exports = c;
})), Om = /* @__PURE__ */ U(((e, t) => {
var r = Gt(), i = fr(), { erase: n, cursor: h } = zt(), { style: a, clear: s, lines: c, figures: o } = er(), f = class extends i {
constructor(l = {}) {
super(l), this.transform = a.render(l.style), this.scale = this.transform.scale, this.msg = l.message, this.initial = l.initial || "", this.validator = l.validate || (() => !0), this.value = "", this.errorMsg = l.error || "Please Enter A Valid Value", this.cursor = +!!this.initial, this.cursorOffset = 0, this.clear = s("", this.out.columns), this.render();
}
set value(l) {
!l && this.initial ? (this.placeholder = !0, this.rendered = r.gray(this.transform.render(this.initial))) : (this.placeholder = !1, this.rendered = this.transform.render(l)), this._value = l, this.fire();
}
get value() {
return this._value;
}
reset() {
this.value = "", this.cursor = +!!this.initial, this.cursorOffset = 0, this.fire(), this.render();
}
exit() {
this.abort();
}
abort() {
this.value = this.value || this.initial, this.done = this.aborted = !0, this.error = !1, this.red = !1, this.fire(), this.render(), this.out.write(`
`), this.close();
}
async validate() {
let l = await this.validator(this.value);
typeof l == "string" && (this.errorMsg = l, l = !1), this.error = !l;
}
async submit() {
if (this.value = this.value || this.initial, this.cursorOffset = 0, this.cursor = this.rendered.length, await this.validate(), this.error) {
this.red = !0, this.fire(), this.render();
return;
}
this.done = !0, this.aborted = !1, this.fire(), this.render(), this.out.write(`
`), this.close();
}
next() {
if (!this.placeholder) return this.bell();
this.value = this.initial, this.cursor = this.rendered.length, this.fire(), this.render();
}
moveCursor(l) {
this.placeholder || (this.cursor = this.cursor + l, this.cursorOffset += l);
}
_(l, u) {
let d = this.value.slice(0, this.cursor), p = this.value.slice(this.cursor);
this.value = `${d}${l}${p}`, this.red = !1, this.cursor = this.placeholder ? 0 : d.length + 1, this.render();
}
delete() {
if (this.isCursorAtStart()) return this.bell();
let l = this.value.slice(0, this.cursor - 1), u = this.value.slice(this.cursor);
this.value = `${l}${u}`, this.red = !1, this.isCursorAtStart() ? this.cursorOffset = 0 : (this.cursorOffset++, this.moveCursor(-1)), this.render();
}
deleteForward() {
if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell();
let l = this.value.slice(0, this.cursor), u = this.value.slice(this.cursor + 1);
this.value = `${l}${u}`, this.red = !1, this.isCursorAtEnd() ? this.cursorOffset = 0 : this.cursorOffset++, this.render();
}
first() {
this.cursor = 0, this.render();
}
last() {
this.cursor = this.value.length, this.render();
}
left() {
if (this.cursor <= 0 || this.placeholder) return this.bell();
this.moveCursor(-1), this.render();
}
right() {
if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell();
this.moveCursor(1), this.render();
}
isCursorAtStart() {
return this.cursor === 0 || this.placeholder && this.cursor === 1;
}
isCursorAtEnd() {
return this.cursor === this.rendered.length || this.placeholder && this.cursor === this.rendered.length + 1;
}
render() {
this.closed || (this.firstRender || (this.outputError && this.out.write(h.down(c(this.outputError, this.out.columns) - 1) + s(this.outputError, this.out.columns)), this.out.write(s(this.outputText, this.out.columns))), super.render(), this.outputError = "", this.outputText = [
a.symbol(this.done, this.aborted),
r.bold(this.msg),
a.delimiter(this.done),
this.red ? r.red(this.rendered) : this.rendered
].join(" "), this.error && (this.outputError += this.errorMsg.split(`
`).reduce((l, u, d) => l + `
${d ? " " : o.pointerSmall} ${r.red().italic(u)}`, "")), this.out.write(n.line + h.to(0) + this.outputText + h.save + this.outputError + h.restore + h.move(this.cursorOffset, 0)));
}
};
t.exports = f;
})), Cm = /* @__PURE__ */ U(((e, t) => {
var r = Gt(), i = fr(), { style: n, clear: h, figures: a, wrap: s, entriesToDisplay: c } = er(), { cursor: o } = zt(), f = class extends i {
constructor(l = {}) {
super(l), this.isSelect = !0, this.msg = l.message, this.hint = l.hint || "- Use arrow-keys. Return to submit.", this.warn = l.warn || "- This option is disabled", this.cursor = l.initial || 0, this.choices = l.choices.map((u, d) => (typeof u == "string" && (u = {
title: u,
value: d
}), {
title: u && (u.title || u.value || u),
value: u && (u.value === void 0 ? d : u.value),
description: u && u.description,
selected: u && u.selected,
disabled: u && u.disabled
})), this.optionsPerPage = l.optionsPerPage || 10, this.value = (this.choices[this.cursor] || {}).value, this.clear = h("", this.out.columns), this.render();
}
moveCursor(l) {
this.cursor = l, this.value = this.choices[l].value, this.fire();
}
reset() {
this.moveCursor(0), this.fire(), this.render();
}
exit() {
this.abort();
}
abort() {
this.done = this.aborted = !0, this.fire(), this.render(), this.out.write(`
`), this.close();
}
submit() {
this.selection.disabled ? this.bell() : (this.done = !0, this.aborted = !1, this.fire(), this.render(), this.out.write(`
`), this.close());
}
first() {
this.moveCursor(0), this.render();
}
last() {
this.moveCursor(this.choices.length - 1), this.render();
}
up() {
this.cursor === 0 ? this.moveCursor(this.choices.length - 1) : this.moveCursor(this.cursor - 1), this.render();
}
down() {
this.cursor === this.choices.length - 1 ? this.moveCursor(0) : this.moveCursor(this.cursor + 1), this.render();
}
next() {
this.moveCursor((this.cursor + 1) % this.choices.length), this.render();
}
_(l, u) {
if (l === " ") return this.submit();
}
get selection() {
return this.choices[this.cursor];
}
render() {
if (this.closed) return;
this.firstRender ? this.out.write(o.hide) : this.out.write(h(this.outputText, this.out.columns)), super.render();
let { startIndex: l, endIndex: u } = c(this.cursor, this.choices.length, this.optionsPerPage);
if (this.outputText = [
n.symbol(this.done, this.aborted),
r.bold(this.msg),
n.delimiter(!1),
this.done ? this.selection.title : this.selection.disabled ? r.yellow(this.warn) : r.gray(this.hint)
].join(" "), !this.done) {
this.outputText += `
`;
for (let d = l; d < u; d++) {
let p, g, m = "", v = this.choices[d];
d === l && l > 0 ? g = a.arrowUp : d === u - 1 && u < this.choices.length ? g = a.arrowDown : g = " ", v.disabled ? (p = this.cursor === d ? r.gray().underline(v.title) : r.strikethrough().gray(v.title), g = (this.cursor === d ? r.bold().gray(a.pointer) + " " : " ") + g) : (p = this.cursor === d ? r.cyan().underline(v.title) : v.title, g = (this.cursor === d ? r.cyan(a.pointer) + " " : " ") + g, v.description && this.cursor === d && (m = ` - ${v.description}`, (g.length + p.length + m.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) && (m = `
` + s(v.description, {
margin: 3,
width: this.out.columns
})))), this.outputText += `${g} ${p}${r.gray(m)}
`;
}
}
this.out.write(this.outputText);
}
};
t.exports = f;
})), Im = /* @__PURE__ */ U(((e, t) => {
var r = Gt(), i = fr(), { style: n, clear: h } = er(), { cursor: a, erase: s } = zt(), c = class extends i {
constructor(o = {}) {
super(o), this.msg = o.message, this.value = !!o.initial, this.active = o.active || "on", this.inactive = o.inactive || "off", this.initialValue = this.value, this.render();
}
reset() {
this.value = this.initialValue, this.fire(), this.render();
}
exit() {
this.abort();
}
abort() {
this.done = this.aborted = !0, this.fire(), this.render(), this.out.write(`
`), this.close();
}
submit() {
this.done = !0, this.aborted = !1, this.fire(), this.render(), this.out.write(`
`), this.close();
}
deactivate() {
if (this.value === !1) return this.bell();
this.value = !1, this.render();
}
activate() {
if (this.value === !0) return this.bell();
this.value = !0, this.render();
}
delete() {
this.deactivate();
}
left() {
this.deactivate();
}
right() {
this.activate();
}
down() {
this.deactivate();
}
up() {
this.activate();
}
next() {
this.value = !this.value, this.fire(), this.render();
}
_(o, f) {
if (o === " ") this.value = !this.value;
else if (o === "1") this.value = !0;
else if (o === "0") this.value = !1;
else return this.bell();
this.render();
}
render() {
this.closed || (this.firstRender ? this.out.write(a.hide) : this.out.write(h(this.outputText, this.out.columns)), super.render(), this.outputText = [
n.symbol(this.done, this.aborted),
r.bold(this.msg),
n.delimiter(this.done),
this.value ? this.inactive : r.cyan().underline(this.inactive),
r.gray("/"),
this.value ? r.cyan().underline(this.active) : this.active
].join(" "), this.out.write(s.line + a.to(0) + this.outputText));
}
};
t.exports = c;
})), ar = /* @__PURE__ */ U(((e, t) => {
var r = class ha {
constructor({ token: n, date: h, parts: a, locales: s }) {
this.token = n, this.date = h || /* @__PURE__ */ new Date(), this.parts = a || [this], this.locales = s || {};
}
up() {
}
down() {
}
next() {
const n = this.parts.indexOf(this);
return this.parts.find((h, a) => a > n && h instanceof ha);
}
setTo(n) {
}
prev() {
let n = [].concat(this.parts).reverse();
const h = n.indexOf(this);
return n.find((a, s) => s > h && a instanceof ha);
}
toString() {
return String(this.date);
}
};
t.exports = r;
})), km = /* @__PURE__ */ U(((e, t) => {
var r = ar(), i = class extends r {
constructor(n = {}) {
super(n);
}
up() {
this.date.setHours((this.date.getHours() + 12) % 24);
}
down() {
this.up();
}
toString() {
let n = this.date.getHours() > 12 ? "pm" : "am";
return /\A/.test(this.token) ? n.toUpperCase() : n;
}
};
t.exports = i;
})), Lm = /* @__PURE__ */ U(((e, t) => {
var r = ar(), i = (h) => (h = h % 10, h === 1 ? "st" : h === 2 ? "nd" : h === 3 ? "rd" : "th"), n = class extends r {
constructor(h = {}) {
super(h);
}
up() {
this.date.setDate(this.date.getDate() + 1);
}
down() {
this.date.setDate(this.date.getDate() - 1);
}
setTo(h) {
this.date.setDate(parseInt(h.substr(-2)));
}
toString() {
let h = this.date.getDate(), a = this.date.getDay();
return this.token === "DD" ? String(h).padStart(2, "0") : this.token === "Do" ? h + i(h) : this.token === "d" ? a + 1 : this.token === "ddd" ? this.locales.weekdaysShort[a] : this.token === "dddd" ? this.locales.weekdays[a] : h;
}
};
t.exports = n;
})), $m = /* @__PURE__ */ U(((e, t) => {
var r = ar(), i = class extends r {
constructor(n = {}) {
super(n);
}
up() {
this.date.setHours(this.date.getHours() + 1);
}
down() {
this.date.setHours(this.date.getHours() - 1);
}
setTo(n) {
this.date.setHours(parseInt(n.substr(-2)));
}
toString() {
let n = this.date.getHours();
return /h/.test(this.token) && (n = n % 12 || 12), this.token.length > 1 ? String(n).padStart(2, "0") : n;
}
};
t.exports = i;
})), xm = /* @__PURE__ */ U(((e, t) => {
var r = ar(), i = class extends r {
constructor(n = {}) {
super(n);
}
up() {
this.date.setMilliseconds(this.date.getMilliseconds() + 1);
}
down() {
this.date.setMilliseconds(this.date.getMilliseconds() - 1);
}
setTo(n) {
this.date.setMilliseconds(parseInt(n.substr(-this.token.length)));
}
toString() {
return String(this.date.getMilliseconds()).padStart(4, "0").substr(0, this.token.length);
}
};
t.exports = i;
})), Nm = /* @__PURE__ */ U(((e, t) => {
var r = ar(), i = class extends r {
constructor(n = {}) {
super(n);
}
up() {
this.date.setMinutes(this.date.getMinutes() + 1);
}
down() {
this.date.setMinutes(this.date.getMinutes() - 1);
}
setTo(n) {
this.date.setMinutes(parseInt(n.substr(-2)));
}
toString() {
let n = this.date.getMinutes();
return this.token.length > 1 ? String(n).padStart(2, "0") : n;
}
};
t.exports = i;
})), Pm = /* @__PURE__ */ U(((e, t) => {
var r = ar(), i = class extends r {
constructor(n = {}) {
super(n);
}
up() {
this.date.setMonth(this.date.getMonth() + 1);
}
down() {
this.date.setMonth(this.date.getMonth() - 1);
}
setTo(n) {
n = parseInt(n.substr(-2)) - 1, this.date.setMonth(n < 0 ? 0 : n);
}
toString() {
let n = this.date.getMonth(), h = this.token.length;
return h === 2 ? String(n + 1).padStart(2, "0") : h === 3 ? this.locales.monthsShort[n] : h === 4 ? this.locales.months[n] : String(n + 1);
}
};
t.exports = i;
})), Bm = /* @__PURE__ */ U(((e, t) => {
var r = ar(), i = class extends r {
constructor(n = {}) {
super(n);
}
up() {
this.date.setSeconds(this.date.getSeconds() + 1);
}
down() {
this.date.setSeconds(this.date.getSeconds() - 1);
}
setTo(n) {
this.date.setSeconds(parseInt(n.substr(-2)));
}
toString() {
let n = this.date.getSeconds();
return this.token.length > 1 ? String(n).padStart(2, "0") : n;
}
};
t.exports = i;
})), Fm = /* @__PURE__ */ U(((e, t) => {
var r = ar(), i = class extends r {
constructor(n = {}) {
super(n);
}
up() {
this.date.setFullYear(this.date.getFullYear() + 1);
}
down() {
this.date.setFullYear(this.date.getFullYear() - 1);
}
setTo(n) {
this.date.setFullYear(n.substr(-4));
}
toString() {
let n = String(this.date.getFullYear()).padStart(4, "0");
return this.token.length === 2 ? n.substr(-2) : n;
}
};
t.exports = i;
})), Mm = /* @__PURE__ */ U(((e, t) => {
t.exports = {
DatePart: ar(),
Meridiem: km(),
Day: Lm(),
Hours: $m(),
Milliseconds: xm(),
Minutes: Nm(),
Month: Pm(),
Seconds: Bm(),
Year: Fm()
};
})), jm = /* @__PURE__ */ U(((e, t) => {
var r = Gt(), i = fr(), { style: n, clear: h, figures: a } = er(), { erase: s, cursor: c } = zt(), { DatePart: o, Meridiem: f, Day: l, Hours: u, Milliseconds: d, Minutes: p, Month: g, Seconds: m, Year: v } = Mm(), y = /\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g, b = {
1: ({ token: _ }) => _.replace(/\\(.)/g, "$1"),
2: (_) => new l(_),
3: (_) => new g(_),
4: (_) => new v(_),
5: (_) => new f(_),
6: (_) => new u(_),
7: (_) => new p(_),
8: (_) => new m(_),
9: (_) => new d(_)
}, E = {
months: "January,February,March,April,May,June,July,August,September,October,November,December".split(","),
monthsShort: "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),
weekdays: "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),
weekdaysShort: "Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")
}, w = class extends i {
constructor(_ = {}) {
super(_), this.msg = _.message, this.cursor = 0, this.typed = "", this.locales = Object.assign(E, _.locales), this._date = _.initial || /* @__PURE__ */ new Date(), this.errorMsg = _.error || "Please Enter A Valid Value", this.validator = _.validate || (() => !0), this.mask = _.mask || "YYYY-MM-DD HH:mm:ss", this.clear = h("", this.out.columns), this.render();
}
get value() {
return this.date;
}
get date() {
return this._date;
}
set date(_) {
_ && this._date.setTime(_.getTime());
}
set mask(_) {
let S;
for (this.parts = []; S = y.exec(_); ) {
let R = S.shift(), D = S.findIndex((O) => O != null);
this.parts.push(D in b ? b[D]({
token: S[D] || R,
date: this.date,
parts: this.parts,
locales: this.locales
}) : S[D] || R);
}
let T = this.parts.reduce((R, D) => (typeof D == "string" && typeof R[R.length - 1] == "string" ? R[R.length - 1] += D : R.push(D), R), []);
this.parts.splice(0), this.parts.push(...T), this.reset();
}
moveCursor(_) {
this.typed = "", this.cursor = _, this.fire();
}
reset() {
this.moveCursor(this.parts.findIndex((_) => _ instanceof o)), this.fire(), this.render();
}
exit() {
this.abort();
}
abort() {
this.done = this.aborted = !0, this.error = !1, this.fire(), this.render(), this.out.write(`
`), this.close();
}
async validate() {
let _ = await this.validator(this.value);
typeof _ == "string" && (this.errorMsg = _, _ = !1), this.error = !_;
}
async submit() {
if (await this.validate(), this.error) {
this.color = "red", this.fire(), this.render();
return;
}
this.done = !0, this.aborted = !1, this.fire(), this.render(), this.out.write(`
`), this.close();
}
up() {
this.typed = "", this.parts[this.cursor].up(), this.render();
}
down() {
this.typed = "", this.parts[this.cursor].down(), this.render();
}
left() {
let _ = this.parts[this.cursor].prev();
if (_ == null) return this.bell();
this.moveCursor(this.parts.indexOf(_)), this.render();
}
right() {
let _ = this.parts[this.cursor].next();
if (_ == null) return this.bell();
this.moveCursor(this.parts.indexOf(_)), this.render();
}
next() {
let _ = this.parts[this.cursor].next();
this.moveCursor(_ ? this.parts.indexOf(_) : this.parts.findIndex((S) => S instanceof o)), this.render();
}
_(_) {
/\d/.test(_) && (this.typed += _, this.parts[this.cursor].setTo(this.typed), this.render());
}
render() {
this.closed || (this.firstRender ? this.out.write(c.hide) : this.out.write(h(this.outputText, this.out.columns)), super.render(), this.outputText = [
n.symbol(this.done, this.aborted),
r.bold(this.msg),
n.delimiter(!1),
this.parts.reduce((_, S, T) => _.concat(T === this.cursor && !this.done ? r.cyan().underline(S.toString()) : S), []).join("")
].join(" "), this.error && (this.outputText += this.errorMsg.split(`
`).reduce((_, S, T) => _ + `
${T ? " " : a.pointerSmall} ${r.red().italic(S)}`, "")), this.out.write(s.line + c.to(0) + this.outputText));
}
};
t.exports = w;
})), Um = /* @__PURE__ */ U(((e, t) => {
var r = Gt(), i = fr(), { cursor: n, erase: h } = zt(), { style: a, figures: s, clear: c, lines: o } = er(), f = /[0-9]/, l = (p) => p !== void 0, u = (p, g) => {
let m = Math.pow(10, g);
return Math.round(p * m) / m;
}, d = class extends i {
constructor(p = {}) {
super(p), this.transform = a.render(p.style), this.msg = p.message, this.initial = l(p.initial) ? p.initial : "", this.float = !!p.float, this.round = p.round || 2, this.inc = p.increment || 1, this.min = l(p.min) ? p.min : -1 / 0, this.max = l(p.max) ? p.max : 1 / 0, this.errorMsg = p.error || "Please Enter A Valid Value", this.validator = p.validate || (() => !0), this.color = "cyan", this.value = "", this.typed = "", this.lastHit = 0, this.render();
}
set value(p) {
!p && p !== 0 ? (this.placeholder = !0, this.rendered = r.gray(this.transform.render(`${this.initial}`)), this._value = "") : (this.placeholder = !1, this.rendered = this.transform.render(`${u(p, this.round)}`), this._value = u(p, this.round)), this.fire();
}
get value() {
return this._value;
}
parse(p) {
return this.float ? parseFloat(p) : parseInt(p);
}
valid(p) {
return p === "-" || p === "." && this.float || f.test(p);
}
reset() {
this.typed = "", this.value = "", this.fire(), this.render();
}
exit() {
this.abort();
}
abort() {
let p = this.value;
this.value = p !== "" ? p : this.initial, this.done = this.aborted = !0, this.error = !1, this.fire(), this.render(), this.out.write(`
`), this.close();
}
async validate() {
let p = await this.validator(this.value);
typeof p == "string" && (this.errorMsg = p, p = !1), this.error = !p;
}
async submit() {
if (await this.validate(), this.error) {
this.color = "red", this.fire(), this.render();
return;
}
let p = this.value;
this.value = p !== "" ? p : this.initial, this.done = !0, this.aborted = !1, this.error = !1, this.fire(), this.render(), this.out.write(`
`), this.close();
}
up() {
if (this.typed = "", this.value === "" && (this.value = this.min - this.inc), this.value >= this.max) return this.bell();
this.value += this.inc, this.color = "cyan", this.fire(), this.render();
}
down() {
if (this.typed = "", this.value === "" && (this.value = this.min + this.inc), this.value <= this.min) return this.bell();
this.value -= this.inc, this.color = "cyan", this.fire(), this.render();
}
delete() {
let p = this.value.toString();
if (p.length === 0) return this.bell();
this.value = this.parse(p = p.slice(0, -1)) || "", this.value !== "" && this.value < this.min && (this.value = this.min), this.color = "cyan", this.fire(), this.render();
}
next() {
this.value = this.initial, this.fire(), this.render();
}
_(p, g) {
if (!this.valid(p)) return this.bell();
const m = Date.now();
if (m - this.lastHit > 1e3 && (this.typed = ""), this.typed += p, this.lastHit = m, this.color = "cyan", p === ".") return this.fire();
this.value = Math.min(this.parse(this.typed), this.max), this.value > this.max && (this.value = this.max), this.value < this.min && (this.value = this.min), this.fire(), this.render();
}
render() {
this.closed || (this.firstRender || (this.outputError && this.out.write(n.down(o(this.outputError, this.out.columns) - 1) + c(this.outputError, this.out.columns)), this.out.write(c(this.outputText, this.out.columns))), super.render(), this.outputError = "", this.outputText = [
a.symbol(this.done, this.aborted),
r.bold(this.msg),
a.delimiter(this.done),
!this.done || !this.done && !this.placeholder ? r[this.color]().underline(this.rendered) : this.rendered
].join(" "), this.error && (this.outputError += this.errorMsg.split(`
`).reduce((p, g, m) => p + `
${m ? " " : s.pointerSmall} ${r.red().italic(g)}`, "")), this.out.write(h.line + n.to(0) + this.outputText + n.save + this.outputError + n.restore));
}
};
t.exports = d;
})), Eh = /* @__PURE__ */ U(((e, t) => {
var r = Gt(), { cursor: i } = zt(), n = fr(), { clear: h, figures: a, style: s, wrap: c, entriesToDisplay: o } = er(), f = class extends n {
constructor(l = {}) {
super(l), this.isSelect = !0, this.msg = l.message, this.cursorStart = l.choices.findIndex((u) => !u.heading), this.cursor = l.cursor || this.cursorStart, this.scrollIndex = l.cursor || 0, this.hint = l.hint || "", this.warn = l.warn || "- This option is disabled -", this.minSelected = l.min, this.showMinError = !1, this.maxChoices = l.max, this.instructions = l.instructions, this.optionsPerPage = l.optionsPerPage || 10, this.value = l.choices.map((u, d) => (typeof u == "string" && (u = {
title: u,
value: d
}), {
title: u && (u.title || u.value || u),
description: u && u.description,
value: u && (u.value === void 0 ? d : u.value),
selected: u && u.selected,
disabled: u && u.disabled,
heading: u && u.heading
})), this.clear = h("", this.out.columns), l.overrideRender || this.render();
}
reset() {
this.value.map((l) => !l.selected), this.cursor = this.cursorStart, this.fire(), this.render();
}
selected() {
return this.value.filter((l) => l.selected);
}
exit() {
this.abort();
}
abort() {
this.done = this.aborted = !0, this.fire(), this.render(), this.out.write(`
`), this.close();
}
submit() {
const l = this.value.filter((u) => u.selected);
this.minSelected && l.length < this.minSelected ? (this.showMinError = !0, this.render()) : (this.done = !0, this.aborted = !1, this.fire(), this.render(), this.out.write(`
`), this.close());
}
first() {
this.cursor = this.cursorStart, this.render();
}
last() {
this.cursor = this.value.length - 1, this.render();
}
next() {
this.cursor = (this.cursor + 1) % this.value.length, this.value[this.cursor].heading && this.next(), this.render();
}
up() {
this.cursor === this.cursorStart ? this.cursor = this.value.length - 1 : this.cursor--, this.value[this.cursor].heading && this.up(), this.render();
}
down() {
this.cursor === this.value.length - 1 ? this.cursor = this.cursorStart : this.cursor++, this.value[this.cursor].heading && this.down(), this.render();
}
left() {
this.value[this.cursor].selected = !1, this.render();
}
right() {
if (this.value.filter((l) => l.selected).length >= this.maxChoices) return this.bell();
this.value[this.cursor].selected = !0, this.render();
}
handleSpaceToggle() {
const l = this.value[this.cursor];
if (l.selected)
l.selected = !1, this.render();
else {
if (l.disabled || this.value.filter((u) => u.selected).length >= this.maxChoices) return this.bell();
l.selected = !0, this.render();
}
}
toggleAll() {
if (this.maxChoices !== void 0 || this.value[this.cursor].disabled) return this.bell();
const l = !this.value[this.cursor].selected;
this.value.filter((u) => !u.disabled && !u.heading).forEach((u) => u.selected = l), this.render();
}
_(l, u) {
if (l === " ") this.handleSpaceToggle();
else if (l === "a") this.toggleAll();
else return this.bell();
}
renderInstructions() {
return this.instructions === void 0 || this.instructions ? typeof this.instructions == "string" ? this.instructions : `
Instructions:
${a.arrowUp}/${a.arrowDown}: Highlight option
${a.arrowLeft}/${a.arrowRight}/[space]: Toggle selection
` + (this.maxChoices === void 0 ? ` a: Toggle all
` : "") + " enter/return: Complete answer" : "";
}
renderOption(l, u, d, p) {
const g = (l === d ? "❯ " : " ") + (u.selected ? r.green(a.radioOn) : a.radioOff) + " ";
let m, v;
if (u.disabled) m = l === d ? r.gray(u.title) : r.strikethrough().gray(u.title);
else {
if (u.heading)
return m = u.title, m + r.gray(v || "");
m = u.title, l === d && u.description && (v = ` - ${u.description}`, (g.length + m.length + v.length >= this.out.columns || u.description.split(/\r?\n/).length > 1) && (v = `
` + c(u.description, {
margin: g.length,
width: this.out.columns
})));
}
return g + m + r.gray(v || "");
}
paginateOptions(l) {
if (l.length === 0) return r.red("No matches for this query.");
let { startIndex: u, endIndex: d } = o(this.cursor, l.length, this.optionsPerPage), p, g = [];
for (let m = u; m < d; m++)
m === u && u > 0 ? p = a.arrowUp : m === d - 1 && d < l.length ? p = a.arrowDown : p = " ", g.push(this.renderOption(this.cursor, l[m], m, p));
return `
` + g.join(`
`);
}
renderOptions(l) {
return this.done ? "" : this.paginateOptions(l);
}
renderDoneOrInstructions() {
if (this.done) return "";
const l = [r.gray(this.hint), this.renderInstructions()];
return this.value[this.cursor].disabled && l.push(r.yellow(this.warn)), l.join(" ");
}
render() {
if (this.closed) return;
this.firstRender && this.out.write(i.hide), super.render();
let l = [
s.symbol(this.done, this.aborted),
r.bold(this.msg),
s.delimiter(!1),
this.renderDoneOrInstructions()
].join(" ");
this.showMinError && (l += r.red(`You must select a minimum of ${this.minSelected} choices.`), this.showMinError = !1), l += this.renderOptions(this.value), this.out.write(this.clear + l), this.clear = h(l, this.out.columns);
}
};
t.exports = f;
})), Hm = /* @__PURE__ */ U(((e, t) => {
var r = Gt(), i = fr(), { erase: n, cursor: h } = zt(), { style: a, clear: s, figures: c, wrap: o, entriesToDisplay: f } = er(), l = (g, m) => g[m] && (g[m].value || g[m].title || g[m]), u = (g, m) => g[m] && (g[m].title || g[m].value || g[m]), d = (g, m) => {
const v = g.findIndex((y) => y.value === m || y.title === m);
return v > -1 ? v : void 0;
}, p = class extends i {
constructor(g = {}) {
super(g), this.msg = g.message, this.suggest = g.suggest, this.choices = g.choices, this.initial = typeof g.initial == "number" ? g.initial : d(g.choices, g.initial), this.select = this.initial || g.cursor || 0, this.i18n = { noMatches: g.noMatches || "no matches found" }, this.fallback = g.fallback || this.initial, this.clearFirst = g.clearFirst || !1, this.suggestions = [], this.input = "", this.limit = g.limit || 10, this.cursor = 0, this.transform = a.render(g.style), this.scale = this.transform.scale, this.render = this.render.bind(this), this.complete = this.complete.bind(this), this.clear = s("", this.out.columns), this.complete(this.render), this.render();
}
set fallback(g) {
this._fb = Number.isSafeInteger(parseInt(g)) ? parseInt(g) : g;
}
get fallback() {
let g;
return typeof this._fb == "number" ? g = this.choices[this._fb] : typeof this._fb == "string" && (g = { title: this._fb }), g || this._fb || { title: this.i18n.noMatches };
}
moveSelect(g) {
this.select = g, this.suggestions.length > 0 ? this.value = l(this.suggestions, g) : this.value = this.fallback.value, this.fire();
}
async complete(g) {
const m = this.completing = this.suggest(this.input, this.choices), v = await m;
if (this.completing !== m) return;
this.suggestions = v.map((b, E, w) => ({
title: u(w, E),
value: l(w, E),
description: b.description
})), this.completing = !1;
const y = Math.max(v.length - 1, 0);
this.moveSelect(Math.min(y, this.select)), g && g();
}
reset() {
this.input = "", this.complete(() => {
this.moveSelect(this.initial !== void 0 ? this.initial : 0), this.render();
}), this.render();
}
exit() {
this.clearFirst && this.input.length > 0 ? this.reset() : (this.done = this.exited = !0, this.aborted = !1, this.fire(), this.render(), this.out.write(`
`), this.close());
}
abort() {
this.done = this.aborted = !0, this.exited = !1, this.fire(), this.render(), this.out.write(`
`), this.close();
}
submit() {
this.done = !0, this.aborted = this.exited = !1, this.fire(), this.render(), this.out.write(`
`), this.close();
}
_(g, m) {
let v = this.input.slice(0, this.cursor), y = this.input.slice(this.cursor);
this.input = `${v}${g}${y}`, this.cursor = v.length + 1, this.complete(this.render), this.render();
}
delete() {
if (this.cursor === 0) return this.bell();
let g = this.input.slice(0, this.cursor - 1), m = this.input.slice(this.cursor);
this.input = `${g}${m}`, this.complete(this.render), this.cursor = this.cursor - 1, this.render();
}
deleteForward() {
if (this.cursor * this.scale >= this.rendered.length) return this.bell();
let g = this.input.slice(0, this.cursor), m = this.input.slice(this.cursor + 1);
this.input = `${g}${m}`, this.complete(this.render), this.render();
}
first() {
this.moveSelect(0), this.render();
}
last() {
this.moveSelect(this.suggestions.length - 1), this.render();
}
up() {
this.select === 0 ? this.moveSelect(this.suggestions.length - 1) : this.moveSelect(this.select - 1), this.render();
}
down() {
this.select === this.suggestions.length - 1 ? this.moveSelect(0) : this.moveSelect(this.select + 1), this.render();
}
next() {
this.select === this.suggestions.length - 1 ? this.moveSelect(0) : this.moveSelect(this.select + 1), this.render();
}
nextPage() {
this.moveSelect(Math.min(this.select + this.limit, this.suggestions.length - 1)), this.render();
}
prevPage() {
this.moveSelect(Math.max(this.select - this.limit, 0)), this.render();
}
left() {
if (this.cursor <= 0) return this.bell();
this.cursor = this.cursor - 1, this.render();
}
right() {
if (this.cursor * this.scale >= this.rendered.length) return this.bell();
this.cursor = this.cursor + 1, this.render();
}
renderOption(g, m, v, y) {
let b, E = v ? c.arrowUp : y ? c.arrowDown : " ", w = m ? r.cyan().underline(g.title) : g.title;
return E = (m ? r.cyan(c.pointer) + " " : " ") + E, g.description && (b = ` - ${g.description}`, (E.length + w.length + b.length >= this.out.columns || g.description.split(/\r?\n/).length > 1) && (b = `
` + o(g.description, {
margin: 3,
width: this.out.columns
}))), E + " " + w + r.gray(b || "");
}
render() {
if (this.closed) return;
this.firstRender ? this.out.write(h.hide) : this.out.write(s(this.outputText, this.out.columns)), super.render();
let { startIndex: g, endIndex: m } = f(this.select, this.choices.length, this.limit);
if (this.outputText = [
a.symbol(this.done, this.aborted, this.exited),
r.bold(this.msg),
a.delimiter(this.completing),
this.done && this.suggestions[this.select] ? this.suggestions[this.select].title : this.rendered = this.transform.render(this.input)
].join(" "), !this.done) {
const v = this.suggestions.slice(g, m).map((y, b) => this.renderOption(y, this.select === b + g, b === 0 && g > 0, b + g === m - 1 && m < this.choices.length)).join(`
`);
this.outputText += `
` + (v || r.gray(this.fallback.title));
}
this.out.write(n.line + h.to(0) + this.outputText);
}
};
t.exports = p;
})), qm = /* @__PURE__ */ U(((e, t) => {
var r = Gt(), { cursor: i } = zt(), n = Eh(), { clear: h, style: a, figures: s } = er(), c = class extends n {
constructor(o = {}) {
o.overrideRender = !0, super(o), this.inputValue = "", this.clear = h("", this.out.columns), this.filteredOptions = this.value, this.render();
}
last() {
this.cursor = this.filteredOptions.length - 1, this.render();
}
next() {
this.cursor = (this.cursor + 1) % this.filteredOptions.length, this.render();
}
up() {
this.cursor === 0 ? this.cursor = this.filteredOptions.length - 1 : this.cursor--, this.render();
}
down() {
this.cursor === this.filteredOptions.length - 1 ? this.cursor = 0 : this.cursor++, this.render();
}
left() {
this.filteredOptions[this.cursor].selected = !1, this.render();
}
right() {
if (this.value.filter((o) => o.selected).length >= this.maxChoices) return this.bell();
this.filteredOptions[this.cursor].selected = !0, this.render();
}
delete() {
this.inputValue.length && (this.inputValue = this.inputValue.substr(0, this.inputValue.length - 1), this.updateFilteredOptions());
}
updateFilteredOptions() {
const o = this.filteredOptions[this.cursor];
this.filteredOptions = this.value.filter((l) => this.inputValue ? !!(typeof l.title == "string" && l.title.toLowerCase().includes(this.inputValue.toLowerCase()) || typeof l.value == "string" && l.value.toLowerCase().includes(this.inputValue.toLowerCase())) : !0);
const f = this.filteredOptions.findIndex((l) => l === o);
this.cursor = f < 0 ? 0 : f, this.render();
}
handleSpaceToggle() {
const o = this.filteredOptions[this.cursor];
if (o.selected)
o.selected = !1, this.render();
else {
if (o.disabled || this.value.filter((f) => f.selected).length >= this.maxChoices) return this.bell();
o.selected = !0, this.render();
}
}
handleInputChange(o) {
this.inputValue = this.inputValue + o, this.updateFilteredOptions();
}
_(o, f) {
o === " " ? this.handleSpaceToggle() : this.handleInputChange(o);
}
renderInstructions() {
return this.instructions === void 0 || this.instructions ? typeof this.instructions == "string" ? this.instructions : `
Instructions:
${s.arrowUp}/${s.arrowDown}: Highlight option
${s.arrowLeft}/${s.arrowRight}/[space]: Toggle selection
[a,b,c]/delete: Filter choices
enter/return: Complete answer
` : "";
}
renderCurrentInput() {
return `
Filtered results for: ${this.inputValue ? this.inputValue : r.gray("Enter something to filter")}
`;
}
renderOption(o, f, l, u) {
const d = (f.selected ? r.green(s.radioOn) : s.radioOff) + " " + u + " ";
let p;
return f.disabled ? p = o === l ? r.gray().underline(f.title) : r.strikethrough().gray(f.title) : p = o === l ? r.cyan().underline(f.title) : f.title, d + p;
}
renderDoneOrInstructions() {
if (this.done) return this.value.filter((f) => f.selected).map((f) => f.title).join(", ");
const o = [
r.gray(this.hint),
this.renderInstructions(),
this.renderCurrentInput()
];
return this.filteredOptions.length && this.filteredOptions[this.cursor].disabled && o.push(r.yellow(this.warn)), o.join(" ");
}
render() {
if (this.closed) return;
this.firstRender && this.out.write(i.hide), super.render();
let o = [
a.symbol(this.done, this.aborted),
r.bold(this.msg),
a.delimiter(!1),
this.renderDoneOrInstructions()
].join(" ");
this.showMinError && (o += r.red(`You must select a minimum of ${this.minSelected} choices.`), this.showMinError = !1), o += this.renderOptions(this.filteredOptions), this.out.write(this.clear + o), this.clear = h(o, this.out.columns);
}
};
t.exports = c;
})), Gm = /* @__PURE__ */ U(((e, t) => {
var r = Gt(), i = fr(), { style: n, clear: h } = er(), { erase: a, cursor: s } = zt(), c = class extends i {