sv
Version:
A command line interface (CLI) for creating and maintaining Svelte applications
993 lines (991 loc) • 444 kB
JavaScript
import { createRequire } from "node:module";
import { AGENTS, COMMANDS, Walker, coerceVersion, color, constructCommand, createPrinter, dedent, detect, downloadJson, fileExists, isVersionUnsupportedBelow, js, loadFile, loadPackageJson, minVersion, parse, pnpm, resolveCommand, resolveCommandArray, sanitizeName, saveFile, svelte, transforms } from "@sveltejs/sv-utils";
import fs, { existsSync } from "node:fs";
import path, { delimiter, dirname, isAbsolute, join, normalize, resolve } from "node:path";
import process$1, { cwd, stdin, stdout } from "node:process";
import * as k$1 from "node:readline";
import c from "node:readline";
import { ReadStream } from "node:tty";
import { promisify, stripVTControlCharacters } from "node:util";
import { fileURLToPath } from "node:url";
import { exec, spawn } from "node:child_process";
import { PassThrough } from "node:stream";
import crypto from "node:crypto";
import { platform } from "node:os";
import { pipeline } from "node:stream/promises";
import { createGunzip } from "node:zlib";
//#region \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
var __require = /* @__PURE__ */ createRequire(import.meta.url);
//#endregion
//#region src/core/deprecated.ts
const warned = /* @__PURE__ */ new Set();
/** Emit a one-time deprecation warning. */
function svDeprecated(message) {
if (warned.has(message)) return;
warned.add(message);
console.warn();
console.warn(` ${color.dim("[sv] Deprecated:")} ${message}`);
console.warn(` Still works. ${color.warning("Warn add-on's author about it.")}`);
console.warn();
}
//#endregion
//#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
let p = process || {}, argv = p.argv || [], env = p.env || {};
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
let formatter = (open, close, replace = open) => (input) => {
let string = "" + input, index = string.indexOf(close, open.length);
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
};
let replaceClose = (string, close, replace, index) => {
let result = "", cursor = 0;
do {
result += string.substring(cursor, index) + replace;
cursor = index + close.length;
index = string.indexOf(close, cursor);
} while (~index);
return result + string.substring(cursor);
};
let createColors = (enabled = isColorSupported) => {
let f = enabled ? formatter : () => String;
return {
isColorSupported: enabled,
reset: f("\x1B[0m", "\x1B[0m"),
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
italic: f("\x1B[3m", "\x1B[23m"),
underline: f("\x1B[4m", "\x1B[24m"),
inverse: f("\x1B[7m", "\x1B[27m"),
hidden: f("\x1B[8m", "\x1B[28m"),
strikethrough: f("\x1B[9m", "\x1B[29m"),
black: f("\x1B[30m", "\x1B[39m"),
red: f("\x1B[31m", "\x1B[39m"),
green: f("\x1B[32m", "\x1B[39m"),
yellow: f("\x1B[33m", "\x1B[39m"),
blue: f("\x1B[34m", "\x1B[39m"),
magenta: f("\x1B[35m", "\x1B[39m"),
cyan: f("\x1B[36m", "\x1B[39m"),
white: f("\x1B[37m", "\x1B[39m"),
gray: f("\x1B[90m", "\x1B[39m"),
bgBlack: f("\x1B[40m", "\x1B[49m"),
bgRed: f("\x1B[41m", "\x1B[49m"),
bgGreen: f("\x1B[42m", "\x1B[49m"),
bgYellow: f("\x1B[43m", "\x1B[49m"),
bgBlue: f("\x1B[44m", "\x1B[49m"),
bgMagenta: f("\x1B[45m", "\x1B[49m"),
bgCyan: f("\x1B[46m", "\x1B[49m"),
bgWhite: f("\x1B[47m", "\x1B[49m"),
blackBright: f("\x1B[90m", "\x1B[39m"),
redBright: f("\x1B[91m", "\x1B[39m"),
greenBright: f("\x1B[92m", "\x1B[39m"),
yellowBright: f("\x1B[93m", "\x1B[39m"),
blueBright: f("\x1B[94m", "\x1B[39m"),
magentaBright: f("\x1B[95m", "\x1B[39m"),
cyanBright: f("\x1B[96m", "\x1B[39m"),
whiteBright: f("\x1B[97m", "\x1B[39m"),
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
bgRedBright: f("\x1B[101m", "\x1B[49m"),
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
};
};
module.exports = createColors();
module.exports.createColors = createColors;
}));
//#endregion
//#region ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
var require_src = /* @__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
};
}));
//#endregion
//#region ../../node_modules/.pnpm/@clack+core@1.0.0/node_modules/@clack/core/dist/index.mjs
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
var import_src = require_src();
const at = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109, lt = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, ht$1 = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141, O$1 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, y$1 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, M$2 = /\t{1,1000}/y, P$1 = /[\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, L$1 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct = /\p{M}+/gu, pt$1 = {
limit: Infinity,
ellipsis: ""
}, X = (t, e = {}, s = {}) => {
const i = e.limit ?? Infinity, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X(r, pt$1, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V = s.wideWidth ?? 2;
let h = 0, o = 0, f = t.length, v = 0, F = !1, d = f, b = Math.max(0, i - n), C = 0, B = 0, c = 0, p = 0;
t: for (;;) {
if (B > C || o >= f && o > h) {
const ut = t.slice(C, B) || t.slice(h, o);
v = 0;
for (const Y of ut.replaceAll(ct, "")) {
const $ = Y.codePointAt(0) || 0;
if (lt($) ? p = m : ht$1($) ? p = V : E !== A && at($) ? p = E : p = A, c + p > b && (d = Math.min(d, Math.max(C, h) + v)), c + p > i) {
F = !0;
break t;
}
v += Y.length, c += p;
}
C = B = 0;
}
if (o >= f) break;
if (L$1.lastIndex = o, L$1.test(t)) {
if (v = L$1.lastIndex - o, p = v * A, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + p > i) {
F = !0;
break;
}
c += p, C = h, B = o, o = h = L$1.lastIndex;
continue;
}
if (O$1.lastIndex = o, O$1.test(t)) {
if (c + u > b && (d = Math.min(d, o)), c + u > i) {
F = !0;
break;
}
c += u, C = h, B = o, o = h = O$1.lastIndex;
continue;
}
if (y$1.lastIndex = o, y$1.test(t)) {
if (v = y$1.lastIndex - o, p = v * a, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + p > i) {
F = !0;
break;
}
c += p, C = h, B = o, o = h = y$1.lastIndex;
continue;
}
if (M$2.lastIndex = o, M$2.test(t)) {
if (v = M$2.lastIndex - o, p = v * l, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + p > i) {
F = !0;
break;
}
c += p, C = h, B = o, o = h = M$2.lastIndex;
continue;
}
if (P$1.lastIndex = o, P$1.test(t)) {
if (c + g > b && (d = Math.min(d, o)), c + g > i) {
F = !0;
break;
}
c += g, C = h, B = o, o = h = P$1.lastIndex;
continue;
}
o += 1;
}
return {
width: F ? b : c,
index: F ? d : f,
truncated: F,
ellipsed: F && i >= n
};
}, ft$1 = {
limit: Infinity,
ellipsis: "",
ellipsisWidth: 0
}, S$1 = (t, e = {}) => X(t, ft$1, e).width, W = "\x1B", Z = "", Ft$1 = 39, j$1 = "\x07", Q$1 = "[", dt = "]", tt = "m", U = `${dt}8;;`, et = new RegExp(`(?:\\${Q$1}(?<code>\\d+)m|\\${U}(?<uri>.*)${j$1})`, "y"), mt$1 = (t) => {
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
if (t === 1 || t === 2) return 22;
if (t === 3) return 23;
if (t === 4) return 24;
if (t === 7) return 27;
if (t === 8) return 28;
if (t === 9) return 29;
if (t === 0) return 0;
}, st = (t) => `${W}${Q$1}${t}${tt}`, it = (t) => `${W}${U}${t}${j$1}`, gt$1 = (t) => t.map((e) => S$1(e)), G$1 = (t, e, s) => {
const i = e[Symbol.iterator]();
let r = !1, n = !1, u = t.at(-1), a = u === void 0 ? 0 : S$1(u), l = i.next(), E = i.next(), g = 0;
for (; !l.done;) {
const m = l.value, A = S$1(m);
a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === W || m === Z) && (r = !0, n = e.startsWith(U, g + 1)), r ? n ? m === j$1 && (r = !1, n = !1) : m === tt && (r = !1) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
}
u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
}, vt$1 = (t) => {
const e = t.split(" ");
let s = e.length;
for (; s > 0 && !(S$1(e[s - 1]) > 0);) s--;
return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
}, Et$1 = (t, e, s = {}) => {
if (s.trim !== !1 && t.trim() === "") return "";
let i = "", r, n;
const u = t.split(" "), a = gt$1(u);
let l = [""];
for (const [h, o] of u.entries()) {
s.trim !== !1 && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
let f = S$1(l.at(-1) ?? "");
if (h !== 0 && (f >= e && (s.wordWrap === !1 || s.trim === !1) && (l.push(""), f = 0), (f > 0 || s.trim === !1) && (l[l.length - 1] += " ", f++)), s.hard && a[h] > e) {
const v = e - f, F = 1 + Math.floor((a[h] - v - 1) / e);
Math.floor((a[h] - 1) / e) < F && l.push(""), G$1(l, o, e);
continue;
}
if (f + a[h] > e && f > 0 && a[h] > 0) {
if (s.wordWrap === !1 && f < e) {
G$1(l, o, e);
continue;
}
l.push("");
}
if (f + a[h] > e && s.wordWrap === !1) {
G$1(l, o, e);
continue;
}
l[l.length - 1] += o;
}
s.trim !== !1 && (l = l.map((h) => vt$1(h)));
const E = l.join(`
`), g = E[Symbol.iterator]();
let m = g.next(), A = g.next(), V = 0;
for (; !m.done;) {
const h = m.value, o = A.value;
if (i += h, h === W || h === Z) {
et.lastIndex = V + 1;
const F = et.exec(E)?.groups;
if (F?.code !== void 0) {
const d = Number.parseFloat(F.code);
r = d === Ft$1 ? void 0 : d;
} else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
}
const f = r ? mt$1(r) : void 0;
o === `
` ? (n && (i += it("")), r && f && (i += st(f))) : h === `
` && (r && f && (i += st(r)), n && (i += it(n))), V += h.length, m = A, A = g.next();
}
return i;
};
function K$1(t, e, s) {
return String(t).normalize().replaceAll(`\r
`, `
`).split(`
`).map((i) => Et$1(i, e, s)).join(`
`);
}
const _$1 = {
actions: new Set([
"up",
"down",
"left",
"right",
"space",
"enter",
"cancel"
]),
aliases: new Map([
["k", "up"],
["j", "down"],
["h", "left"],
["l", "right"],
["", "cancel"],
["escape", "cancel"]
]),
messages: {
cancel: "Canceled",
error: "Something went wrong"
},
withGuide: !0
};
function H$1(t, e) {
if (typeof t == "string") return _$1.aliases.get(t) === e;
for (const s of t) if (s !== void 0 && H$1(s, e)) return !0;
return !1;
}
function _t$1(t, e) {
if (t === e) return;
const s = t.split(`
`), i = e.split(`
`), r = Math.max(s.length, i.length), n = [];
for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
return {
lines: n,
numLinesBefore: s.length,
numLinesAfter: i.length,
numLines: r
};
}
const bt$1 = globalThis.process.platform.startsWith("win"), z$2 = Symbol("clack:cancel");
function Ct$1(t) {
return t === z$2;
}
function T$1(t, e) {
const s = t;
s.isTTY && s.setRawMode(e);
}
function xt$1({ input: t = stdin, output: e = stdout, overwrite: s = !0, hideCursor: i = !0 } = {}) {
const r = k$1.createInterface({
input: t,
output: e,
prompt: "",
tabSize: 1
});
k$1.emitKeypressEvents(t, r), t instanceof ReadStream && t.isTTY && t.setRawMode(!0);
const n = (u, { name: a, sequence: l }) => {
if (H$1([
String(u),
a,
l
], "cancel")) {
i && e.write(import_src.cursor.show), process.exit(0);
return;
}
if (!s) return;
const g = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
k$1.moveCursor(e, g, m, () => {
k$1.clearLine(e, 1, () => {
t.once("keypress", n);
});
});
};
return i && e.write(import_src.cursor.hide), t.once("keypress", n), () => {
t.off("keypress", n), i && e.write(import_src.cursor.show), t instanceof ReadStream && t.isTTY && !bt$1 && t.setRawMode(!1), r.terminal = !1, r.close();
};
}
const rt = (t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80, nt = (t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20;
function Bt$1(t, e, s, i = s) {
return K$1(e, rt(t ?? stdout) - s.length, {
hard: !0,
trim: !1
}).split(`
`).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
`);
}
var x$2 = class {
input;
output;
_abortSignal;
rl;
opts;
_render;
_track = !1;
_prevFrame = "";
_subscribers = /* @__PURE__ */ new Map();
_cursor = 0;
state = "initial";
error = "";
value;
userInput = "";
constructor(e, s = !0) {
const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e;
this.opts = a, 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 = u, this.input = i, this.output = r;
}
unsubscribe() {
this._subscribers.clear();
}
setSubscriber(e, s) {
const i = this._subscribers.get(e) ?? [];
i.push(s), this._subscribers.set(e, i);
}
on(e, s) {
this.setSubscriber(e, { cb: s });
}
once(e, s) {
this.setSubscriber(e, {
cb: s,
once: !0
});
}
emit(e, ...s) {
const i = this._subscribers.get(e) ?? [], r = [];
for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
for (const n of r) n();
}
prompt() {
return new Promise((e) => {
if (this._abortSignal) {
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z$2);
this._abortSignal.addEventListener("abort", () => {
this.state = "cancel", this.close();
}, { once: !0 });
}
this.rl = c.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), T$1(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), T$1(this.input, !1), e(this.value);
}), this.once("cancel", () => {
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), T$1(this.input, !1), e(z$2);
});
});
}
_isActionKey(e, s) {
return e === " ";
}
_setValue(e) {
this.value = e, this.emit("value", this.value);
}
_setUserInput(e, s) {
this.userInput = e ?? "", 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(e, s) {
if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, 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 && _$1.aliases.has(s.name) && this.emit("cursor", _$1.aliases.get(s.name)), _$1.actions.has(s.name) && this.emit("cursor", s.name)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e?.toLowerCase(), s), s?.name === "return") {
if (this.opts.validate) {
const i = this.opts.validate(this.value);
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
}
this.state !== "error" && (this.state = "submit");
}
H$1([
e,
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(`
`), T$1(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
}
restoreCursor() {
const e = K$1(this._prevFrame, process.stdout.columns, {
hard: !0,
trim: !1
}).split(`
`).length - 1;
this.output.write(import_src.cursor.move(-999, e * -1));
}
render() {
const e = K$1(this._render(this) ?? "", process.stdout.columns, {
hard: !0,
trim: !1
});
if (e !== this._prevFrame) {
if (this.state === "initial") this.output.write(import_src.cursor.hide);
else {
const s = _t$1(this._prevFrame, e), i = nt(this.output);
if (this.restoreCursor(), s) {
const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
let u = s.lines.find((a) => a >= r);
if (u === void 0) {
this._prevFrame = e;
return;
}
if (s.lines.length === 1) {
this.output.write(import_src.cursor.move(0, u - n)), this.output.write(import_src.erase.lines(1));
const a = e.split(`
`);
this.output.write(a[u]), this._prevFrame = e, this.output.write(import_src.cursor.move(0, a.length - u - 1));
return;
} else if (s.lines.length > 1) {
if (r < n) u = r;
else {
const l = u - n;
l > 0 && this.output.write(import_src.cursor.move(0, l));
}
this.output.write(import_src.erase.down());
const a = e.split(`
`).slice(u);
this.output.write(a.join(`
`)), this._prevFrame = e;
return;
}
}
this.output.write(import_src.erase.down());
}
this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
}
}
};
var kt$1 = class extends x$2 {
get cursor() {
return this.value ? 0 : 1;
}
get _value() {
return this.cursor === 0;
}
constructor(e) {
super(e, !1), this.value = !!e.initialValue, this.on("userInput", () => {
this.value = this._value;
}), this.on("confirm", (s) => {
this.output.write(import_src.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
}), this.on("cursor", () => {
this.value = !this.value;
});
}
};
function D$1(t, e, s) {
const i = t + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
return s[n].disabled ? D$1(n, e < 0 ? -1 : 1, s) : n;
}
var Mt$1 = class extends x$2 {
options;
cursor = 0;
get _value() {
return this.options[this.cursor].value;
}
get _enabledOptions() {
return this.options.filter((e) => e.disabled !== !0);
}
toggleAll() {
const e = this._enabledOptions;
this.value = this.value !== void 0 && this.value.length === e.length ? [] : e.map((i) => i.value);
}
toggleInvert() {
const e = this.value;
if (!e) return;
this.value = this._enabledOptions.filter((i) => !e.includes(i.value)).map((i) => i.value);
}
toggleValue() {
this.value === void 0 && (this.value = []);
this.value = this.value.includes(this._value) ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
}
constructor(e) {
super(e, !1), this.options = e.options, this.value = [...e.initialValues ?? []];
const s = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), 0);
this.cursor = this.options[s].disabled ? D$1(s, 1, this.options) : s, this.on("key", (i) => {
i === "a" && this.toggleAll(), i === "i" && this.toggleInvert();
}), this.on("cursor", (i) => {
switch (i) {
case "left":
case "up":
this.cursor = D$1(this.cursor, -1, this.options);
break;
case "down":
case "right":
this.cursor = D$1(this.cursor, 1, this.options);
break;
case "space":
this.toggleValue();
break;
}
});
}
};
var Wt$1 = class extends x$2 {
options;
cursor = 0;
get _selectedValue() {
return this.options[this.cursor];
}
changeValue() {
this.value = this._selectedValue.value;
}
constructor(e) {
super(e, !1), this.options = e.options;
const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
this.cursor = this.options[i].disabled ? D$1(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
switch (r) {
case "left":
case "up":
this.cursor = D$1(this.cursor, -1, this.options);
break;
case "down":
case "right":
this.cursor = D$1(this.cursor, 1, this.options);
break;
}
this.changeValue();
});
}
};
var $t = class extends x$2 {
get userInputWithCursor() {
if (this.state === "submit") return this.userInput;
const e = this.userInput;
if (this.cursor >= e.length) return `${this.userInput}\u2588`;
const s = e.slice(0, this.cursor), [i, ...r] = e.slice(this.cursor);
return `${s}${import_picocolors.default.inverse(i)}${r.join("")}`;
}
get cursor() {
return this._cursor;
}
constructor(e) {
super({
...e,
initialUserInput: e.initialUserInput ?? e.initialValue
}), this.on("userInput", (s) => {
this._setValue(s);
}), this.on("finalize", () => {
this.value || (this.value = e.defaultValue), this.value === void 0 && (this.value = "");
});
}
};
//#endregion
//#region ../../node_modules/.pnpm/@clack+prompts@1.0.0/node_modules/@clack/prompts/dist/index.mjs
function ht() {
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 ee = ht(), ue = () => process.env.CI === "true", Te = (e) => e.isTTY === !0, w$1 = (e, r) => ee ? e : r, Me = w$1("◆", "*"), ce = w$1("■", "x"), de = w$1("▲", "x"), k = w$1("◇", "o"), $e = w$1("┌", "T"), h$1 = w$1("│", "|"), x$1 = w$1("└", "—");
w$1("┐", "T");
w$1("┘", "—");
const Y = w$1("●", ">"), K = w$1("○", " "), te = w$1("◻", "[•]"), G = w$1("◼", "[+]"), z$1 = w$1("◻", "[ ]");
w$1("▪", "•");
const se = w$1("─", "-"), he = w$1("╮", "+"), Ne = w$1("├", "+"), me = w$1("╯", "+"), pe = w$1("╰", "+");
w$1("╭", "+");
const ge = w$1("●", "•"), fe = w$1("◆", "*"), Fe = w$1("▲", "!"), ye = w$1("■", "x"), N$1 = (e) => {
switch (e) {
case "initial":
case "active": return import_picocolors.default.cyan(Me);
case "cancel": return import_picocolors.default.red(ce);
case "error": return import_picocolors.default.yellow(de);
case "submit": return import_picocolors.default.green(k);
}
}, Ee = (e) => {
switch (e) {
case "initial":
case "active": return import_picocolors.default.cyan(h$1);
case "cancel": return import_picocolors.default.red(h$1);
case "error": return import_picocolors.default.yellow(h$1);
case "submit": return import_picocolors.default.green(h$1);
}
}, mt = (e) => e === 161 || e === 164 || e === 167 || e === 168 || e === 170 || e === 173 || e === 174 || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || e === 198 || e === 208 || e === 215 || e === 216 || e >= 222 && e <= 225 || e === 230 || e >= 232 && e <= 234 || e === 236 || e === 237 || e === 240 || e === 242 || e === 243 || e >= 247 && e <= 250 || e === 252 || e === 254 || e === 257 || e === 273 || e === 275 || e === 283 || e === 294 || e === 295 || e === 299 || e >= 305 && e <= 307 || e === 312 || e >= 319 && e <= 322 || e === 324 || e >= 328 && e <= 331 || e === 333 || e === 338 || e === 339 || e === 358 || e === 359 || e === 363 || e === 462 || e === 464 || e === 466 || e === 468 || e === 470 || e === 472 || e === 474 || e === 476 || e === 593 || e === 609 || e === 708 || e === 711 || e >= 713 && e <= 715 || e === 717 || e === 720 || e >= 728 && e <= 731 || e === 733 || e === 735 || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || e === 1025 || e >= 1040 && e <= 1103 || e === 1105 || e === 8208 || e >= 8211 && e <= 8214 || e === 8216 || e === 8217 || e === 8220 || e === 8221 || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || e === 8240 || e === 8242 || e === 8243 || e === 8245 || e === 8251 || e === 8254 || e === 8308 || e === 8319 || e >= 8321 && e <= 8324 || e === 8364 || e === 8451 || e === 8453 || e === 8457 || e === 8467 || e === 8470 || e === 8481 || e === 8482 || e === 8486 || e === 8491 || e === 8531 || e === 8532 || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || e === 8585 || e >= 8592 && e <= 8601 || e === 8632 || e === 8633 || e === 8658 || e === 8660 || e === 8679 || e === 8704 || e === 8706 || e === 8707 || e === 8711 || e === 8712 || e === 8715 || e === 8719 || e === 8721 || e === 8725 || e === 8730 || e >= 8733 && e <= 8736 || e === 8739 || e === 8741 || e >= 8743 && e <= 8748 || e === 8750 || e >= 8756 && e <= 8759 || e === 8764 || e === 8765 || e === 8776 || e === 8780 || e === 8786 || e === 8800 || e === 8801 || e >= 8804 && e <= 8807 || e === 8810 || e === 8811 || e === 8814 || e === 8815 || e === 8834 || e === 8835 || e === 8838 || e === 8839 || e === 8853 || e === 8857 || e === 8869 || e === 8895 || e === 8978 || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || e === 9632 || e === 9633 || e >= 9635 && e <= 9641 || e === 9650 || e === 9651 || e === 9654 || e === 9655 || e === 9660 || e === 9661 || e === 9664 || e === 9665 || e >= 9670 && e <= 9672 || e === 9675 || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || e === 9711 || e === 9733 || e === 9734 || e === 9737 || e === 9742 || e === 9743 || e === 9756 || e === 9758 || e === 9792 || e === 9794 || e === 9824 || e === 9825 || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || e === 9836 || e === 9837 || e === 9839 || e === 9886 || e === 9887 || e === 9919 || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || e === 9955 || e === 9960 || e === 9961 || e >= 9963 && e <= 9969 || e === 9972 || e >= 9974 && e <= 9977 || e === 9979 || e === 9980 || e === 9982 || e === 9983 || e === 10045 || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || e === 65533 || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || e === 127375 || e === 127376 || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109, pt = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510, gt = (e) => e >= 4352 && e <= 4447 || e === 8986 || e === 8987 || e === 9001 || e === 9002 || e >= 9193 && e <= 9196 || e === 9200 || e === 9203 || e === 9725 || e === 9726 || e === 9748 || e === 9749 || e >= 9800 && e <= 9811 || e === 9855 || e === 9875 || e === 9889 || e === 9898 || e === 9899 || e === 9917 || e === 9918 || e === 9924 || e === 9925 || e === 9934 || e === 9940 || e === 9962 || e === 9970 || e === 9971 || e === 9973 || e === 9978 || e === 9981 || e === 9989 || e === 9994 || e === 9995 || e === 10024 || e === 10060 || e === 10062 || e >= 10067 && e <= 10069 || e === 10071 || e >= 10133 && e <= 10135 || e === 10160 || e === 10175 || e === 11035 || e === 11036 || e === 11088 || e === 11093 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || e === 94192 || e === 94193 || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || e === 110589 || e === 110590 || e >= 110592 && e <= 110882 || e === 110898 || e >= 110928 && e <= 110930 || e === 110933 || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || e === 126980 || e === 127183 || e === 127374 || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e === 127568 || e === 127569 || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || e === 127988 || e >= 127992 && e <= 128062 || e === 128064 || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || e === 128378 || e === 128405 || e === 128406 || e === 128420 || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || e === 128716 || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || e === 128747 || e === 128748 || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || e === 129008 || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141, ve = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, re = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, ie = /\t{1,1000}/y, Ae = /[\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, ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ft = /\p{M}+/gu, Ft = {
limit: Infinity,
ellipsis: ""
}, Le = (e, r = {}, s = {}) => {
const i = r.limit ?? Infinity, n = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (n ? Le(n, Ft, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, a = s.tabWidth ?? 8, d = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, E = s.fullWidthWidth ?? 2, p = s.regularWidth ?? 1, y = s.wideWidth ?? 2;
let $ = 0, c = 0, m = e.length, f = 0, F = !1, v = m, S = Math.max(0, i - o), B = 0, b = 0, A = 0, C = 0;
e: for (;;) {
if (b > B || c >= m && c > $) {
const _ = e.slice(B, b) || e.slice($, c);
f = 0;
for (const D of _.replaceAll(ft, "")) {
const T = D.codePointAt(0) || 0;
if (pt(T) ? C = E : gt(T) ? C = y : d !== p && mt(T) ? C = d : C = p, A + C > S && (v = Math.min(v, Math.max(B, $) + f)), A + C > i) {
F = !0;
break e;
}
f += D.length, A += C;
}
B = b = 0;
}
if (c >= m) break;
if (ne.lastIndex = c, ne.test(e)) {
if (f = ne.lastIndex - c, C = f * p, A + C > S && (v = Math.min(v, c + Math.floor((S - A) / p))), A + C > i) {
F = !0;
break;
}
A += C, B = $, b = c, c = $ = ne.lastIndex;
continue;
}
if (ve.lastIndex = c, ve.test(e)) {
if (A + u > S && (v = Math.min(v, c)), A + u > i) {
F = !0;
break;
}
A += u, B = $, b = c, c = $ = ve.lastIndex;
continue;
}
if (re.lastIndex = c, re.test(e)) {
if (f = re.lastIndex - c, C = f * l, A + C > S && (v = Math.min(v, c + Math.floor((S - A) / l))), A + C > i) {
F = !0;
break;
}
A += C, B = $, b = c, c = $ = re.lastIndex;
continue;
}
if (ie.lastIndex = c, ie.test(e)) {
if (f = ie.lastIndex - c, C = f * a, A + C > S && (v = Math.min(v, c + Math.floor((S - A) / a))), A + C > i) {
F = !0;
break;
}
A += C, B = $, b = c, c = $ = ie.lastIndex;
continue;
}
if (Ae.lastIndex = c, Ae.test(e)) {
if (A + g > S && (v = Math.min(v, c)), A + g > i) {
F = !0;
break;
}
A += g, B = $, b = c, c = $ = Ae.lastIndex;
continue;
}
c += 1;
}
return {
width: F ? S : A,
index: F ? v : m,
truncated: F,
ellipsed: F && i >= o
};
}, yt = {
limit: Infinity,
ellipsis: "",
ellipsisWidth: 0
}, M$1 = (e, r = {}) => Le(e, yt, r).width, ae = "\x1B", je = "", Et = 39, Ce = "\x07", Ve = "[", vt = "]", ke = "m", we = `${vt}8;;`, Ge = new RegExp(`(?:\\${Ve}(?<code>\\d+)m|\\${we}(?<uri>.*)${Ce})`, "y"), At = (e) => {
if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
if (e === 1 || e === 2) return 22;
if (e === 3) return 23;
if (e === 4) return 24;
if (e === 7) return 27;
if (e === 8) return 28;
if (e === 9) return 29;
if (e === 0) return 0;
}, He = (e) => `${ae}${Ve}${e}${ke}`, Ue = (e) => `${ae}${we}${e}${Ce}`, Ct = (e) => e.map((r) => M$1(r)), Se = (e, r, s) => {
const i = r[Symbol.iterator]();
let n = !1, o = !1, u = e.at(-1), l = u === void 0 ? 0 : M$1(u), a = i.next(), d = i.next(), g = 0;
for (; !a.done;) {
const E = a.value, p = M$1(E);
l + p <= s ? e[e.length - 1] += E : (e.push(E), l = 0), (E === ae || E === je) && (n = !0, o = r.startsWith(we, g + 1)), n ? o ? E === Ce && (n = !1, o = !1) : E === ke && (n = !1) : (l += p, l === s && !d.done && (e.push(""), l = 0)), a = d, d = i.next(), g += E.length;
}
u = e.at(-1), !l && u !== void 0 && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
}, wt = (e) => {
const r = e.split(" ");
let s = r.length;
for (; s > 0 && !(M$1(r[s - 1]) > 0);) s--;
return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
}, St = (e, r, s = {}) => {
if (s.trim !== !1 && e.trim() === "") return "";
let i = "", n, o;
const u = e.split(" "), l = Ct(u);
let a = [""];
for (const [$, c] of u.entries()) {
s.trim !== !1 && (a[a.length - 1] = (a.at(-1) ?? "").trimStart());
let m = M$1(a.at(-1) ?? "");
if ($ !== 0 && (m >= r && (s.wordWrap === !1 || s.trim === !1) && (a.push(""), m = 0), (m > 0 || s.trim === !1) && (a[a.length - 1] += " ", m++)), s.hard && l[$] > r) {
const f = r - m, F = 1 + Math.floor((l[$] - f - 1) / r);
Math.floor((l[$] - 1) / r) < F && a.push(""), Se(a, c, r);
continue;
}
if (m + l[$] > r && m > 0 && l[$] > 0) {
if (s.wordWrap === !1 && m < r) {
Se(a, c, r);
continue;
}
a.push("");
}
if (m + l[$] > r && s.wordWrap === !1) {
Se(a, c, r);
continue;
}
a[a.length - 1] += c;
}
s.trim !== !1 && (a = a.map(($) => wt($)));
const d = a.join(`
`), g = d[Symbol.iterator]();
let E = g.next(), p = g.next(), y = 0;
for (; !E.done;) {
const $ = E.value, c = p.value;
if (i += $, $ === ae || $ === je) {
Ge.lastIndex = y + 1;
const F = Ge.exec(d)?.groups;
if (F?.code !== void 0) {
const v = Number.parseFloat(F.code);
n = v === Et ? void 0 : v;
} else F?.uri !== void 0 && (o = F.uri.length === 0 ? void 0 : F.uri);
}
const m = n ? At(n) : void 0;
c === `
` ? (o && (i += Ue("")), n && m && (i += He(m))) : $ === `
` && (n && m && (i += He(n)), o && (i += Ue(o))), y += $.length, E = p, p = g.next();
}
return i;
};
function q(e, r, s) {
return String(e).normalize().replaceAll(`\r
`, `
`).split(`
`).map((i) => St(i, r, s)).join(`
`);
}
const It = (e, r, s, i, n) => {
let o = r, u = 0;
for (let l = s; l < i; l++) {
const a = e[l];
if (o = o - a.length, u++, o <= n) break;
}
return {
lineCount: o,
removals: u
};
}, J = (e) => {
const { cursor: r, options: s, style: i } = e, n = e.output ?? process.stdout, o = rt(n), u = e.columnPadding ?? 0, l = e.rowPadding ?? 4, a = o - u, d = nt(n), g = import_picocolors.default.dim("..."), E = e.maxItems ?? Number.POSITIVE_INFINITY, p = Math.max(d - l, 0), y = Math.max(Math.min(E, p), 5);
let $ = 0;
r >= y - 3 && ($ = Math.max(Math.min(r - y + 3, s.length - y), 0));
let c = y < s.length && $ > 0, m = y < s.length && $ + y < s.length;
const f = Math.min($ + y, s.length), F = [];
let v = 0;
c && v++, m && v++;
const S = $ + (c ? 1 : 0), B = f - (m ? 1 : 0);
for (let A = S; A < B; A++) {
const C = q(i(s[A], A === r), a, {
hard: !0,
trim: !1
}).split(`
`);
F.push(C), v += C.length;
}
if (v > p) {
let A = 0, C = 0, _ = v;
const D = r - S, T = (W, I) => It(F, _, W, I, p);
c ? ({lineCount: _, removals: A} = T(0, D), _ > p && ({lineCount: _, removals: C} = T(D + 1, F.length))) : ({lineCount: _, removals: C} = T(D + 1, F.length), _ > p && ({lineCount: _, removals: A} = T(0, D))), A > 0 && (c = !0, F.splice(0, A)), C > 0 && (m = !0, F.splice(F.length - C, C));
}
const b = [];
c && b.push(g);
for (const A of F) for (const C of A) b.push(C);
return m && b.push(g), b;
};
const Mt = (e) => {
const r = e.active ?? "Yes", s = e.inactive ?? "No";
return new kt$1({
active: r,
inactive: s,
signal: e.signal,
input: e.input,
output: e.output,
initialValue: e.initialValue ?? !0,
render() {
const i = `${import_picocolors.default.gray(h$1)}
${N$1(this.state)} ${e.message}
`, n = this.value ? r : s;
switch (this.state) {
case "submit": return `${i}${import_picocolors.default.gray(h$1)} ${import_picocolors.default.dim(n)}`;
case "cancel": return `${i}${import_picocolors.default.gray(h$1)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(n))}
${import_picocolors.default.gray(h$1)}`;
default: return `${i}${import_picocolors.default.cyan(h$1)} ${this.value ? `${import_picocolors.default.green(Y)} ${r}` : `${import_picocolors.default.dim(K)} ${import_picocolors.default.dim(r)}`} ${import_picocolors.default.dim("/")} ${this.value ? `${import_picocolors.default.dim(K)} ${import_picocolors.default.dim(s)}` : `${import_picocolors.default.green(Y)} ${s}`}
${import_picocolors.default.cyan(x$1)}
`;
}
}
}).prompt();
}, Rt = async (e, r) => {
const s = {}, i = Object.keys(e);
for (const n of i) {
const o = e[n], u = await o({ results: s })?.catch((l) => {
throw l;
});
if (typeof r?.onCancel == "function" && Ct$1(u)) {
s[n] = "canceled", r.onCancel({ results: s });
continue;
}
s[n] = u;
}
return s;
}, R$1 = {
message: (e = [], { symbol: r = import_picocolors.default.gray(h$1), secondarySymbol: s = import_picocolors.default.gray(h$1), output: i = process.stdout, spacing: n = 1, withGuide: o } = {}) => {
const u = [], l = (o ?? _$1.withGuide) !== !1, a = l ? s : "", d = l ? `${r} ` : "", g = l ? `${s} ` : "";
for (let p = 0; p < n; p++) u.push(a);
const E = Array.isArray(e) ? e : e.split(`
`);
if (E.length > 0) {
const [p, ...y] = E;
p.length > 0 ? u.push(`${d}${p}`) : u.push(l ? r : "");
for (const $ of y) $.length > 0 ? u.push(`${g}${$}`) : u.push(l ? s : "");
}
i.write(`${u.join(`
`)}
`);
},
info: (e, r) => {
R$1.message(e, {
...r,
symbol: import_picocolors.default.blue(ge)
});
},
success: (e, r) => {
R$1.message(e, {
...r,
symbol: import_picocolors.default.green(fe)
});
},
step: (e, r) => {
R$1.message(e, {
...r,
symbol: import_picocolors.default.green(k)
});
},
warn: (e, r) => {
R$1.message(e, {
...r,
symbol: import_picocolors.default.yellow(Fe)
});
},
warning: (e, r) => {
R$1.warn(e, r);
},
error: (e, r) => {
R$1.message(e, {
...r,
symbol: import_picocolors.default.red(ye)
});
}
}, Pt = (e = "", r) => {
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(x$1)} ${import_picocolors.default.red(e)}
`);
}, Nt = (e = "", r) => {
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray($e)} ${e}
`);
}, Wt = (e = "", r) => {
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(h$1)}
${import_picocolors.default.gray(x$1)} ${e}
`);
}, Q = (e, r) => e.split(`
`).map((s) => r(s)).join(`
`), Lt = (e) => {
const r = (i, n) => {
const o = i.label ?? String(i.value);
return n === "disabled" ? `${import_picocolors.default.gray(z$1)} ${Q(o, (u) => import_picocolors.default.strikethrough(import_picocolors.default.gray(u)))}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint ?? "disabled"})`)}` : ""}` : n === "active" ? `${import_picocolors.default.cyan(te)} ${o}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : n === "selected" ? `${import_picocolors.default.green(G)} $