@vitejs/devtools 0.0.0-alpha.3 → 0.0.0-alpha.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3038 @@
1
+ import { dirClientStandalone, dirDist } from "./dirs.js";
2
+ import { createDebug } from "obug";
3
+ import { debounce } from "perfect-debounce";
4
+ import { normalizePath, searchForWorkspaceRoot } from "vite";
5
+ import { toDataURL } from "mlly";
6
+ import { DEFAULT_STATE_USER_SETTINGS } from "@vitejs/devtools-kit/constants";
7
+ import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
8
+ import { dirname, join } from "pathe";
9
+ import fs, { existsSync, lstatSync, readdirSync } from "node:fs";
10
+ import { createSharedState } from "@vitejs/devtools-kit/utils/shared-state";
11
+ import { RpcFunctionsCollectorBase } from "@vitejs/devtools-rpc";
12
+ import process$1, { stdin, stdout } from "node:process";
13
+ import sirv from "sirv";
14
+ import * as k$1 from "node:readline";
15
+ import ot from "node:readline";
16
+ import { ReadStream } from "node:tty";
17
+ import { dirname as dirname$1, join as join$1 } from "node:path";
18
+ import { stripVTControlCharacters } from "node:util";
19
+ import { defineRpcFunction } from "@vitejs/devtools-kit";
20
+ import { createApp, eventHandler, fromNodeMiddleware, toNodeListener } from "h3";
21
+ import { AsyncLocalStorage } from "node:async_hooks";
22
+ import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/server";
23
+ import { createRpcServer } from "@vitejs/devtools-rpc/server";
24
+ import { createServer } from "node:net";
25
+ import { networkInterfaces } from "node:os";
26
+ import "node:fs/promises";
27
+
28
+ //#region \0rolldown/runtime.js
29
+ var __create = Object.create;
30
+ var __defProp = Object.defineProperty;
31
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
32
+ var __getOwnPropNames = Object.getOwnPropertyNames;
33
+ var __getProtoOf = Object.getPrototypeOf;
34
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
35
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
36
+ var __copyProps = (to, from, except, desc) => {
37
+ if (from && typeof from === "object" || typeof from === "function") {
38
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
39
+ key = keys[i];
40
+ if (!__hasOwnProp.call(to, key) && key !== except) {
41
+ __defProp(to, key, {
42
+ get: ((k) => from[k]).bind(null, key),
43
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
44
+ });
45
+ }
46
+ }
47
+ }
48
+ return to;
49
+ };
50
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
51
+ value: mod,
52
+ enumerable: true
53
+ }) : target, mod));
54
+
55
+ //#endregion
56
+ //#region src/node/context-utils.ts
57
+ const ContextUtils = { createSimpleClientScript(fn) {
58
+ return {
59
+ importFrom: toDataURL(`const fn = ${fn.toString()}; export default fn`),
60
+ importName: "default"
61
+ };
62
+ } };
63
+
64
+ //#endregion
65
+ //#region src/node/storage.ts
66
+ function createStorage(options) {
67
+ const { mergeInitialValue = (initialValue, savedValue) => ({
68
+ ...initialValue,
69
+ ...savedValue
70
+ }), debounce: debounceTime = 100 } = options;
71
+ let initialValue;
72
+ if (fs.existsSync(options.filepath)) {
73
+ const savedValue = JSON.parse(fs.readFileSync(options.filepath, "utf-8"));
74
+ initialValue = mergeInitialValue ? mergeInitialValue(options.initialValue, savedValue) : savedValue;
75
+ } else initialValue = options.initialValue;
76
+ const state = createSharedState({
77
+ initialValue,
78
+ enablePatches: false
79
+ });
80
+ state.on("updated", debounce((newState) => {
81
+ fs.mkdirSync(dirname(options.filepath), { recursive: true });
82
+ fs.writeFileSync(options.filepath, `${JSON.stringify(newState, null, 2)}\n`);
83
+ }, debounceTime));
84
+ return state;
85
+ }
86
+
87
+ //#endregion
88
+ //#region src/node/host-docks.ts
89
+ var DevToolsDockHost = class {
90
+ views = /* @__PURE__ */ new Map();
91
+ events = createEventEmitter();
92
+ userSettings = void 0;
93
+ constructor(context) {
94
+ this.context = context;
95
+ }
96
+ async init() {
97
+ this.userSettings = await this.context.rpc.sharedState.get("devtoolskit:internal:user-settings", { sharedState: createStorage({
98
+ filepath: join(this.context.workspaceRoot, "node_modules/.vite/devtools/settings.json"),
99
+ initialValue: DEFAULT_STATE_USER_SETTINGS()
100
+ }) });
101
+ }
102
+ values({ includeBuiltin = true } = {}) {
103
+ const context = this.context;
104
+ const builtinDocksEntries = [
105
+ {
106
+ type: "~builtin",
107
+ id: "~terminals",
108
+ title: "Terminals",
109
+ icon: "ph:terminal-duotone",
110
+ category: "~builtin",
111
+ get isHidden() {
112
+ return context.terminals.sessions.size === 0;
113
+ }
114
+ },
115
+ {
116
+ type: "~builtin",
117
+ id: "~logs",
118
+ title: "Logs",
119
+ icon: "ph:notification-duotone",
120
+ category: "~builtin",
121
+ isHidden: true
122
+ },
123
+ {
124
+ type: "~builtin",
125
+ id: "~settings",
126
+ title: "Settings",
127
+ category: "~builtin",
128
+ icon: "ph:gear-duotone"
129
+ }
130
+ ];
131
+ return [...Array.from(this.views.values()), ...includeBuiltin ? builtinDocksEntries : []];
132
+ }
133
+ register(view, force) {
134
+ if (this.views.has(view.id) && !force) throw new Error(`Dock with id "${view.id}" is already registered`);
135
+ this.views.set(view.id, view);
136
+ this.events.emit("dock:entry:updated", view);
137
+ return { update: (patch) => {
138
+ if (patch.id && patch.id !== view.id) throw new Error(`Cannot change the id of a dock. Use register() to add new docks.`);
139
+ this.update(Object.assign(this.views.get(view.id), patch));
140
+ } };
141
+ }
142
+ update(view) {
143
+ if (!this.views.has(view.id)) throw new Error(`Dock with id "${view.id}" is not registered. Use register() to add new docks.`);
144
+ this.views.set(view.id, view);
145
+ this.events.emit("dock:entry:updated", view);
146
+ }
147
+ };
148
+
149
+ //#endregion
150
+ //#region src/node/rpc-shared-state.ts
151
+ const debug$1 = createDebug("vite:devtools:rpc:state:changed");
152
+ function createRpcSharedStateServerHost(rpc) {
153
+ const sharedState = /* @__PURE__ */ new Map();
154
+ function registerSharedState(key, state) {
155
+ const offs = [];
156
+ offs.push(state.on("updated", (fullState, patches, syncId) => {
157
+ if (patches) {
158
+ debug$1("patch", {
159
+ key,
160
+ syncId
161
+ });
162
+ rpc.broadcast({
163
+ method: "devtoolskit:internal:rpc:client-state:patch",
164
+ args: [
165
+ key,
166
+ patches,
167
+ syncId
168
+ ],
169
+ filter: (client) => client.$meta.subscribedStates.has(key)
170
+ });
171
+ } else {
172
+ debug$1("updated", {
173
+ key,
174
+ syncId
175
+ });
176
+ rpc.broadcast({
177
+ method: "devtoolskit:internal:rpc:client-state:updated",
178
+ args: [
179
+ key,
180
+ fullState,
181
+ syncId
182
+ ],
183
+ filter: (client) => client.$meta.subscribedStates.has(key)
184
+ });
185
+ }
186
+ }));
187
+ return () => {
188
+ for (const off of offs) off();
189
+ };
190
+ }
191
+ return { get: async (key, options) => {
192
+ if (sharedState.has(key)) return sharedState.get(key);
193
+ if (options?.initialValue === void 0 && options?.sharedState === void 0) throw new Error(`Shared state of "${key}" is not found, please provide an initial value for the first time`);
194
+ debug$1("new-state", key);
195
+ const state = options.sharedState ?? createSharedState({
196
+ initialValue: options.initialValue,
197
+ enablePatches: false
198
+ });
199
+ registerSharedState(key, state);
200
+ sharedState.set(key, state);
201
+ return state;
202
+ } };
203
+ }
204
+
205
+ //#endregion
206
+ //#region src/node/host-functions.ts
207
+ const debugBroadcast = createDebug("vite:devtools:rpc:broadcast");
208
+ var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
209
+ /**
210
+ * @internal
211
+ */
212
+ _rpcGroup = void 0;
213
+ _asyncStorage = void 0;
214
+ constructor(context) {
215
+ super(context);
216
+ this.sharedState = createRpcSharedStateServerHost(this);
217
+ }
218
+ sharedState;
219
+ async broadcast(options) {
220
+ if (!this._rpcGroup) throw new Error("RpcFunctionsHost] RpcGroup is not set, it likely to be an internal bug of Vite DevTools");
221
+ debugBroadcast(JSON.stringify(options.method));
222
+ await Promise.all(this._rpcGroup.clients.map((client) => {
223
+ if (options.filter?.(client) === false) return void 0;
224
+ return client.$callRaw({
225
+ optional: true,
226
+ event: true,
227
+ ...options
228
+ });
229
+ }));
230
+ }
231
+ getCurrentRpcSession() {
232
+ if (!this._asyncStorage) throw new Error("RpcFunctionsHost] AsyncLocalStorage is not set, it likely to be an internal bug of Vite DevTools");
233
+ return this._asyncStorage.getStore();
234
+ }
235
+ };
236
+
237
+ //#endregion
238
+ //#region src/node/host-terminals.ts
239
+ var DevToolsTerminalHost = class {
240
+ sessions = /* @__PURE__ */ new Map();
241
+ events = createEventEmitter();
242
+ _boundStreams = /* @__PURE__ */ new Map();
243
+ constructor(context) {
244
+ this.context = context;
245
+ }
246
+ register(session) {
247
+ if (this.sessions.has(session.id)) throw new Error(`Terminal session with id "${session.id}" already registered`);
248
+ this.sessions.set(session.id, session);
249
+ this.bindStream(session);
250
+ this.events.emit("terminal:session:updated", session);
251
+ return session;
252
+ }
253
+ update(patch) {
254
+ if (!this.sessions.has(patch.id)) throw new Error(`Terminal session with id "${patch.id}" not registered`);
255
+ const session = this.sessions.get(patch.id);
256
+ Object.assign(session, patch);
257
+ this.sessions.set(patch.id, session);
258
+ this.bindStream(session);
259
+ this.events.emit("terminal:session:updated", session);
260
+ }
261
+ remove(session) {
262
+ this.sessions.delete(session.id);
263
+ this.events.emit("terminal:session:updated", session);
264
+ this._boundStreams.delete(session.id);
265
+ }
266
+ bindStream(session) {
267
+ if (this._boundStreams.has(session.id) && this._boundStreams.get(session.id)?.stream === session.stream) return;
268
+ this._boundStreams.get(session.id)?.dispose();
269
+ this._boundStreams.delete(session.id);
270
+ if (!session.stream) return;
271
+ session.buffer ||= [];
272
+ const events = this.events;
273
+ const writer = new WritableStream({ write(chunk) {
274
+ session.buffer.push(chunk);
275
+ events.emit("terminal:session:stream-chunk", {
276
+ id: session.id,
277
+ chunks: [chunk],
278
+ ts: Date.now()
279
+ });
280
+ } });
281
+ session.stream.pipeTo(writer);
282
+ this._boundStreams.set(session.id, {
283
+ dispose: () => {
284
+ writer.close();
285
+ },
286
+ stream: session.stream
287
+ });
288
+ }
289
+ async startChildProcess(executeOptions, terminal) {
290
+ if (this.sessions.has(terminal.id)) throw new Error(`Terminal session with id "${terminal.id}" already registered`);
291
+ const { exec } = await import("tinyexec");
292
+ let controller;
293
+ const stream = new ReadableStream({ start(_controller) {
294
+ controller = _controller;
295
+ } });
296
+ function createChildProcess() {
297
+ const cp = exec(executeOptions.command, executeOptions.args || [], { nodeOptions: {
298
+ env: {
299
+ COLORS: "true",
300
+ FORCE_COLOR: "true",
301
+ ...executeOptions.env || {}
302
+ },
303
+ cwd: executeOptions.cwd ?? process$1.cwd(),
304
+ stdio: "pipe"
305
+ } });
306
+ (async () => {
307
+ for await (const chunk of cp) controller?.enqueue(chunk);
308
+ })();
309
+ return cp;
310
+ }
311
+ let cp = createChildProcess();
312
+ const restart = async () => {
313
+ cp?.kill();
314
+ cp = createChildProcess();
315
+ };
316
+ const terminate = async () => {
317
+ cp?.kill();
318
+ cp = void 0;
319
+ };
320
+ const session = {
321
+ ...terminal,
322
+ status: "running",
323
+ stream,
324
+ type: "child-process",
325
+ executeOptions,
326
+ getChildProcess: () => cp?.process,
327
+ terminate,
328
+ restart
329
+ };
330
+ this.register(session);
331
+ return Promise.resolve(session);
332
+ }
333
+ };
334
+
335
+ //#endregion
336
+ //#region src/node/host-views.ts
337
+ var DevToolsViewHost = class {
338
+ /**
339
+ * @internal
340
+ */
341
+ buildStaticDirs = [];
342
+ constructor(context) {
343
+ this.context = context;
344
+ }
345
+ hostStatic(baseUrl, distDir) {
346
+ if (!existsSync(distDir)) throw new Error(`[Vite DevTools] distDir ${distDir} does not exist`);
347
+ this.buildStaticDirs.push({
348
+ baseUrl,
349
+ distDir
350
+ });
351
+ if (this.context.viteConfig.command === "serve") {
352
+ if (!this.context.viteServer) throw new Error("[Vite DevTools] viteServer is required in dev mode");
353
+ this.context.viteServer.middlewares.use(baseUrl, sirv(distDir, {
354
+ dev: true,
355
+ single: true
356
+ }));
357
+ }
358
+ }
359
+ };
360
+
361
+ //#endregion
362
+ //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
363
+ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
364
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
365
+ 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);
366
+ let formatter = (open, close, replace = open) => (input) => {
367
+ let string = "" + input, index = string.indexOf(close, open.length);
368
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
369
+ };
370
+ let replaceClose = (string, close, replace, index) => {
371
+ let result = "", cursor = 0;
372
+ do {
373
+ result += string.substring(cursor, index) + replace;
374
+ cursor = index + close.length;
375
+ index = string.indexOf(close, cursor);
376
+ } while (~index);
377
+ return result + string.substring(cursor);
378
+ };
379
+ let createColors = (enabled = isColorSupported) => {
380
+ let f = enabled ? formatter : () => String;
381
+ return {
382
+ isColorSupported: enabled,
383
+ reset: f("\x1B[0m", "\x1B[0m"),
384
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
385
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
386
+ italic: f("\x1B[3m", "\x1B[23m"),
387
+ underline: f("\x1B[4m", "\x1B[24m"),
388
+ inverse: f("\x1B[7m", "\x1B[27m"),
389
+ hidden: f("\x1B[8m", "\x1B[28m"),
390
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
391
+ black: f("\x1B[30m", "\x1B[39m"),
392
+ red: f("\x1B[31m", "\x1B[39m"),
393
+ green: f("\x1B[32m", "\x1B[39m"),
394
+ yellow: f("\x1B[33m", "\x1B[39m"),
395
+ blue: f("\x1B[34m", "\x1B[39m"),
396
+ magenta: f("\x1B[35m", "\x1B[39m"),
397
+ cyan: f("\x1B[36m", "\x1B[39m"),
398
+ white: f("\x1B[37m", "\x1B[39m"),
399
+ gray: f("\x1B[90m", "\x1B[39m"),
400
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
401
+ bgRed: f("\x1B[41m", "\x1B[49m"),
402
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
403
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
404
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
405
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
406
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
407
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
408
+ blackBright: f("\x1B[90m", "\x1B[39m"),
409
+ redBright: f("\x1B[91m", "\x1B[39m"),
410
+ greenBright: f("\x1B[92m", "\x1B[39m"),
411
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
412
+ blueBright: f("\x1B[94m", "\x1B[39m"),
413
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
414
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
415
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
416
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
417
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
418
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
419
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
420
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
421
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
422
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
423
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
424
+ };
425
+ };
426
+ module.exports = createColors();
427
+ module.exports.createColors = createColors;
428
+ }));
429
+
430
+ //#endregion
431
+ //#region ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
432
+ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
433
+ const ESC = "\x1B";
434
+ const CSI = `${ESC}[`;
435
+ const beep = "\x07";
436
+ const cursor = {
437
+ to(x, y) {
438
+ if (!y) return `${CSI}${x + 1}G`;
439
+ return `${CSI}${y + 1};${x + 1}H`;
440
+ },
441
+ move(x, y) {
442
+ let ret = "";
443
+ if (x < 0) ret += `${CSI}${-x}D`;
444
+ else if (x > 0) ret += `${CSI}${x}C`;
445
+ if (y < 0) ret += `${CSI}${-y}A`;
446
+ else if (y > 0) ret += `${CSI}${y}B`;
447
+ return ret;
448
+ },
449
+ up: (count = 1) => `${CSI}${count}A`,
450
+ down: (count = 1) => `${CSI}${count}B`,
451
+ forward: (count = 1) => `${CSI}${count}C`,
452
+ backward: (count = 1) => `${CSI}${count}D`,
453
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
454
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
455
+ left: `${CSI}G`,
456
+ hide: `${CSI}?25l`,
457
+ show: `${CSI}?25h`,
458
+ save: `${ESC}7`,
459
+ restore: `${ESC}8`
460
+ };
461
+ const scroll = {
462
+ up: (count = 1) => `${CSI}S`.repeat(count),
463
+ down: (count = 1) => `${CSI}T`.repeat(count)
464
+ };
465
+ const erase = {
466
+ screen: `${CSI}2J`,
467
+ up: (count = 1) => `${CSI}1J`.repeat(count),
468
+ down: (count = 1) => `${CSI}J`.repeat(count),
469
+ line: `${CSI}2K`,
470
+ lineEnd: `${CSI}K`,
471
+ lineStart: `${CSI}1K`,
472
+ lines(count) {
473
+ let clear = "";
474
+ for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
475
+ if (count) clear += cursor.left;
476
+ return clear;
477
+ }
478
+ };
479
+ module.exports = {
480
+ cursor,
481
+ scroll,
482
+ erase,
483
+ beep
484
+ };
485
+ }));
486
+
487
+ //#endregion
488
+ //#region ../../node_modules/.pnpm/@clack+core@1.0.0/node_modules/@clack/core/dist/index.mjs
489
+ var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
490
+ var import_src = require_src();
491
+ 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 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, M$1 = /\t{1,1000}/y, P = /[\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 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct = /\p{M}+/gu, pt$1 = {
492
+ limit: Infinity,
493
+ ellipsis: ""
494
+ }, X = (t, e = {}, s = {}) => {
495
+ 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;
496
+ 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;
497
+ t: for (;;) {
498
+ if (B > C || o >= f && o > h) {
499
+ const ut = t.slice(C, B) || t.slice(h, o);
500
+ v = 0;
501
+ for (const Y of ut.replaceAll(ct, "")) {
502
+ const $ = Y.codePointAt(0) || 0;
503
+ 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) {
504
+ F = !0;
505
+ break t;
506
+ }
507
+ v += Y.length, c += p;
508
+ }
509
+ C = B = 0;
510
+ }
511
+ if (o >= f) break;
512
+ if (L.lastIndex = o, L.test(t)) {
513
+ if (v = L.lastIndex - o, p = v * A, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + p > i) {
514
+ F = !0;
515
+ break;
516
+ }
517
+ c += p, C = h, B = o, o = h = L.lastIndex;
518
+ continue;
519
+ }
520
+ if (O.lastIndex = o, O.test(t)) {
521
+ if (c + u > b && (d = Math.min(d, o)), c + u > i) {
522
+ F = !0;
523
+ break;
524
+ }
525
+ c += u, C = h, B = o, o = h = O.lastIndex;
526
+ continue;
527
+ }
528
+ if (y.lastIndex = o, y.test(t)) {
529
+ if (v = y.lastIndex - o, p = v * a, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + p > i) {
530
+ F = !0;
531
+ break;
532
+ }
533
+ c += p, C = h, B = o, o = h = y.lastIndex;
534
+ continue;
535
+ }
536
+ if (M$1.lastIndex = o, M$1.test(t)) {
537
+ if (v = M$1.lastIndex - o, p = v * l, c + p > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + p > i) {
538
+ F = !0;
539
+ break;
540
+ }
541
+ c += p, C = h, B = o, o = h = M$1.lastIndex;
542
+ continue;
543
+ }
544
+ if (P.lastIndex = o, P.test(t)) {
545
+ if (c + g > b && (d = Math.min(d, o)), c + g > i) {
546
+ F = !0;
547
+ break;
548
+ }
549
+ c += g, C = h, B = o, o = h = P.lastIndex;
550
+ continue;
551
+ }
552
+ o += 1;
553
+ }
554
+ return {
555
+ width: F ? b : c,
556
+ index: F ? d : f,
557
+ truncated: F,
558
+ ellipsed: F && i >= n
559
+ };
560
+ }, ft$1 = {
561
+ limit: Infinity,
562
+ ellipsis: "",
563
+ ellipsisWidth: 0
564
+ }, S = (t, e = {}) => X(t, ft$1, e).width, W = "\x1B", Z = "›", Ft$1 = 39, j = "\x07", Q$1 = "[", dt = "]", tt = "m", U = `${dt}8;;`, et = new RegExp(`(?:\\${Q$1}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y"), mt$1 = (t) => {
565
+ if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
566
+ if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
567
+ if (t === 1 || t === 2) return 22;
568
+ if (t === 3) return 23;
569
+ if (t === 4) return 24;
570
+ if (t === 7) return 27;
571
+ if (t === 8) return 28;
572
+ if (t === 9) return 29;
573
+ if (t === 0) return 0;
574
+ }, st = (t) => `${W}${Q$1}${t}${tt}`, it = (t) => `${W}${U}${t}${j}`, gt$1 = (t) => t.map((e) => S(e)), G$1 = (t, e, s) => {
575
+ const i = e[Symbol.iterator]();
576
+ let r = !1, n = !1, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
577
+ for (; !l.done;) {
578
+ const m = l.value, A = S(m);
579
+ 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 && (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;
580
+ }
581
+ u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
582
+ }, vt$1 = (t) => {
583
+ const e = t.split(" ");
584
+ let s = e.length;
585
+ for (; s > 0 && !(S(e[s - 1]) > 0);) s--;
586
+ return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
587
+ }, Et$1 = (t, e, s = {}) => {
588
+ if (s.trim !== !1 && t.trim() === "") return "";
589
+ let i = "", r, n;
590
+ const u = t.split(" "), a = gt$1(u);
591
+ let l = [""];
592
+ for (const [h, o] of u.entries()) {
593
+ s.trim !== !1 && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
594
+ let f = S(l.at(-1) ?? "");
595
+ 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) {
596
+ const v = e - f, F = 1 + Math.floor((a[h] - v - 1) / e);
597
+ Math.floor((a[h] - 1) / e) < F && l.push(""), G$1(l, o, e);
598
+ continue;
599
+ }
600
+ if (f + a[h] > e && f > 0 && a[h] > 0) {
601
+ if (s.wordWrap === !1 && f < e) {
602
+ G$1(l, o, e);
603
+ continue;
604
+ }
605
+ l.push("");
606
+ }
607
+ if (f + a[h] > e && s.wordWrap === !1) {
608
+ G$1(l, o, e);
609
+ continue;
610
+ }
611
+ l[l.length - 1] += o;
612
+ }
613
+ s.trim !== !1 && (l = l.map((h) => vt$1(h)));
614
+ const E = l.join(`
615
+ `), g = E[Symbol.iterator]();
616
+ let m = g.next(), A = g.next(), V = 0;
617
+ for (; !m.done;) {
618
+ const h = m.value, o = A.value;
619
+ if (i += h, h === W || h === Z) {
620
+ et.lastIndex = V + 1;
621
+ const F = et.exec(E)?.groups;
622
+ if (F?.code !== void 0) {
623
+ const d = Number.parseFloat(F.code);
624
+ r = d === Ft$1 ? void 0 : d;
625
+ } else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
626
+ }
627
+ const f = r ? mt$1(r) : void 0;
628
+ o === `
629
+ ` ? (n && (i += it("")), r && f && (i += st(f))) : h === `
630
+ ` && (r && f && (i += st(r)), n && (i += it(n))), V += h.length, m = A, A = g.next();
631
+ }
632
+ return i;
633
+ };
634
+ function K$1(t, e, s) {
635
+ return String(t).normalize().replaceAll(`\r
636
+ `, `
637
+ `).split(`
638
+ `).map((i) => Et$1(i, e, s)).join(`
639
+ `);
640
+ }
641
+ const _ = {
642
+ actions: new Set([
643
+ "up",
644
+ "down",
645
+ "left",
646
+ "right",
647
+ "space",
648
+ "enter",
649
+ "cancel"
650
+ ]),
651
+ aliases: new Map([
652
+ ["k", "up"],
653
+ ["j", "down"],
654
+ ["h", "left"],
655
+ ["l", "right"],
656
+ ["", "cancel"],
657
+ ["escape", "cancel"]
658
+ ]),
659
+ messages: {
660
+ cancel: "Canceled",
661
+ error: "Something went wrong"
662
+ },
663
+ withGuide: !0
664
+ };
665
+ function H$1(t, e) {
666
+ if (typeof t == "string") return _.aliases.get(t) === e;
667
+ for (const s of t) if (s !== void 0 && H$1(s, e)) return !0;
668
+ return !1;
669
+ }
670
+ function _t$1(t, e) {
671
+ if (t === e) return;
672
+ const s = t.split(`
673
+ `), i = e.split(`
674
+ `), r = Math.max(s.length, i.length), n = [];
675
+ for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
676
+ return {
677
+ lines: n,
678
+ numLinesBefore: s.length,
679
+ numLinesAfter: i.length,
680
+ numLines: r
681
+ };
682
+ }
683
+ const bt$1 = globalThis.process.platform.startsWith("win"), z$1 = Symbol("clack:cancel");
684
+ function Ct$1(t) {
685
+ return t === z$1;
686
+ }
687
+ function T(t, e) {
688
+ const s = t;
689
+ s.isTTY && s.setRawMode(e);
690
+ }
691
+ function xt$1({ input: t = stdin, output: e = stdout, overwrite: s = !0, hideCursor: i = !0 } = {}) {
692
+ const r = k$1.createInterface({
693
+ input: t,
694
+ output: e,
695
+ prompt: "",
696
+ tabSize: 1
697
+ });
698
+ k$1.emitKeypressEvents(t, r), t instanceof ReadStream && t.isTTY && t.setRawMode(!0);
699
+ const n = (u, { name: a, sequence: l }) => {
700
+ if (H$1([
701
+ String(u),
702
+ a,
703
+ l
704
+ ], "cancel")) {
705
+ i && e.write(import_src.cursor.show), process.exit(0);
706
+ return;
707
+ }
708
+ if (!s) return;
709
+ const g = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
710
+ k$1.moveCursor(e, g, m, () => {
711
+ k$1.clearLine(e, 1, () => {
712
+ t.once("keypress", n);
713
+ });
714
+ });
715
+ };
716
+ return i && e.write(import_src.cursor.hide), t.once("keypress", n), () => {
717
+ 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();
718
+ };
719
+ }
720
+ 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;
721
+ function Bt$1(t, e, s, i = s) {
722
+ return K$1(e, rt(t ?? stdout) - s.length, {
723
+ hard: !0,
724
+ trim: !1
725
+ }).split(`
726
+ `).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
727
+ `);
728
+ }
729
+ var x$1 = class {
730
+ input;
731
+ output;
732
+ _abortSignal;
733
+ rl;
734
+ opts;
735
+ _render;
736
+ _track = !1;
737
+ _prevFrame = "";
738
+ _subscribers = /* @__PURE__ */ new Map();
739
+ _cursor = 0;
740
+ state = "initial";
741
+ error = "";
742
+ value;
743
+ userInput = "";
744
+ constructor(e, s = !0) {
745
+ const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e;
746
+ 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;
747
+ }
748
+ unsubscribe() {
749
+ this._subscribers.clear();
750
+ }
751
+ setSubscriber(e, s) {
752
+ const i = this._subscribers.get(e) ?? [];
753
+ i.push(s), this._subscribers.set(e, i);
754
+ }
755
+ on(e, s) {
756
+ this.setSubscriber(e, { cb: s });
757
+ }
758
+ once(e, s) {
759
+ this.setSubscriber(e, {
760
+ cb: s,
761
+ once: !0
762
+ });
763
+ }
764
+ emit(e, ...s) {
765
+ const i = this._subscribers.get(e) ?? [], r = [];
766
+ for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
767
+ for (const n of r) n();
768
+ }
769
+ prompt() {
770
+ return new Promise((e) => {
771
+ if (this._abortSignal) {
772
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z$1);
773
+ this._abortSignal.addEventListener("abort", () => {
774
+ this.state = "cancel", this.close();
775
+ }, { once: !0 });
776
+ }
777
+ this.rl = ot.createInterface({
778
+ input: this.input,
779
+ tabSize: 2,
780
+ prompt: "",
781
+ escapeCodeTimeout: 50,
782
+ terminal: !0
783
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), T(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
784
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), T(this.input, !1), e(this.value);
785
+ }), this.once("cancel", () => {
786
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), T(this.input, !1), e(z$1);
787
+ });
788
+ });
789
+ }
790
+ _isActionKey(e, s) {
791
+ return e === " ";
792
+ }
793
+ _setValue(e) {
794
+ this.value = e, this.emit("value", this.value);
795
+ }
796
+ _setUserInput(e, s) {
797
+ this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
798
+ }
799
+ _clearUserInput() {
800
+ this.rl?.write(null, {
801
+ ctrl: !0,
802
+ name: "u"
803
+ }), this._setUserInput("");
804
+ }
805
+ onKeypress(e, s) {
806
+ if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, {
807
+ ctrl: !0,
808
+ name: "h"
809
+ }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.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") {
810
+ if (this.opts.validate) {
811
+ const i = this.opts.validate(this.value);
812
+ i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
813
+ }
814
+ this.state !== "error" && (this.state = "submit");
815
+ }
816
+ H$1([
817
+ e,
818
+ s?.name,
819
+ s?.sequence
820
+ ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
821
+ }
822
+ close() {
823
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
824
+ `), T(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
825
+ }
826
+ restoreCursor() {
827
+ const e = K$1(this._prevFrame, process.stdout.columns, {
828
+ hard: !0,
829
+ trim: !1
830
+ }).split(`
831
+ `).length - 1;
832
+ this.output.write(import_src.cursor.move(-999, e * -1));
833
+ }
834
+ render() {
835
+ const e = K$1(this._render(this) ?? "", process.stdout.columns, {
836
+ hard: !0,
837
+ trim: !1
838
+ });
839
+ if (e !== this._prevFrame) {
840
+ if (this.state === "initial") this.output.write(import_src.cursor.hide);
841
+ else {
842
+ const s = _t$1(this._prevFrame, e), i = nt(this.output);
843
+ if (this.restoreCursor(), s) {
844
+ const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
845
+ let u = s.lines.find((a) => a >= r);
846
+ if (u === void 0) {
847
+ this._prevFrame = e;
848
+ return;
849
+ }
850
+ if (s.lines.length === 1) {
851
+ this.output.write(import_src.cursor.move(0, u - n)), this.output.write(import_src.erase.lines(1));
852
+ const a = e.split(`
853
+ `);
854
+ this.output.write(a[u]), this._prevFrame = e, this.output.write(import_src.cursor.move(0, a.length - u - 1));
855
+ return;
856
+ } else if (s.lines.length > 1) {
857
+ if (r < n) u = r;
858
+ else {
859
+ const l = u - n;
860
+ l > 0 && this.output.write(import_src.cursor.move(0, l));
861
+ }
862
+ this.output.write(import_src.erase.down());
863
+ const a = e.split(`
864
+ `).slice(u);
865
+ this.output.write(a.join(`
866
+ `)), this._prevFrame = e;
867
+ return;
868
+ }
869
+ }
870
+ this.output.write(import_src.erase.down());
871
+ }
872
+ this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
873
+ }
874
+ }
875
+ };
876
+ function wt$1(t, e) {
877
+ if (t === void 0 || e.length === 0) return 0;
878
+ const s = e.findIndex((i) => i.value === t);
879
+ return s !== -1 ? s : 0;
880
+ }
881
+ function Dt$1(t, e) {
882
+ return (e.label ?? String(e.value)).toLowerCase().includes(t.toLowerCase());
883
+ }
884
+ function St$1(t, e) {
885
+ if (e) return t ? e : e[0];
886
+ }
887
+ var Vt$1 = class extends x$1 {
888
+ filteredOptions;
889
+ multiple;
890
+ isNavigating = !1;
891
+ selectedValues = [];
892
+ focusedValue;
893
+ #t = 0;
894
+ #s = "";
895
+ #i;
896
+ #e;
897
+ get cursor() {
898
+ return this.#t;
899
+ }
900
+ get userInputWithCursor() {
901
+ if (!this.userInput) return import_picocolors.default.inverse(import_picocolors.default.hidden("_"));
902
+ if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
903
+ const e = this.userInput.slice(0, this._cursor), [s, ...i] = this.userInput.slice(this._cursor);
904
+ return `${e}${import_picocolors.default.inverse(s)}${i.join("")}`;
905
+ }
906
+ get options() {
907
+ return typeof this.#e == "function" ? this.#e() : this.#e;
908
+ }
909
+ constructor(e) {
910
+ super(e), this.#e = e.options;
911
+ const s = this.options;
912
+ this.filteredOptions = [...s], this.multiple = e.multiple === !0, this.#i = e.filter ?? Dt$1;
913
+ let i;
914
+ if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i) for (const r of i) {
915
+ const n = s.findIndex((u) => u.value === r);
916
+ n !== -1 && (this.toggleSelected(r), this.#t = n);
917
+ }
918
+ this.focusedValue = this.options[this.#t]?.value, this.on("key", (r, n) => this.#r(r, n)), this.on("userInput", (r) => this.#n(r));
919
+ }
920
+ _isActionKey(e, s) {
921
+ return e === " " || this.multiple && this.isNavigating && s.name === "space" && e !== void 0 && e !== "";
922
+ }
923
+ #r(e, s) {
924
+ const i = s.name === "up", r = s.name === "down", n = s.name === "return";
925
+ i || r ? (this.#t = Math.max(0, Math.min(this.#t + (i ? -1 : 1), this.filteredOptions.length - 1)), this.focusedValue = this.filteredOptions[this.#t]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = !0) : n ? this.value = St$1(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = !1);
926
+ }
927
+ deselectAll() {
928
+ this.selectedValues = [];
929
+ }
930
+ toggleSelected(e) {
931
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((s) => s !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
932
+ }
933
+ #n(e) {
934
+ if (e !== this.#s) {
935
+ this.#s = e;
936
+ const s = this.options;
937
+ e ? this.filteredOptions = s.filter((i) => this.#i(e, i)) : this.filteredOptions = [...s], this.#t = wt$1(this.focusedValue, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#t]?.value, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
938
+ }
939
+ }
940
+ };
941
+ var kt$1 = class extends x$1 {
942
+ get cursor() {
943
+ return this.value ? 0 : 1;
944
+ }
945
+ get _value() {
946
+ return this.cursor === 0;
947
+ }
948
+ constructor(e) {
949
+ super(e, !1), this.value = !!e.initialValue, this.on("userInput", () => {
950
+ this.value = this._value;
951
+ }), this.on("confirm", (s) => {
952
+ this.output.write(import_src.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
953
+ }), this.on("cursor", () => {
954
+ this.value = !this.value;
955
+ });
956
+ }
957
+ };
958
+ var yt$1 = class extends x$1 {
959
+ options;
960
+ cursor = 0;
961
+ #t;
962
+ getGroupItems(e) {
963
+ return this.options.filter((s) => s.group === e);
964
+ }
965
+ isGroupSelected(e) {
966
+ const s = this.getGroupItems(e), i = this.value;
967
+ return i === void 0 ? !1 : s.every((r) => i.includes(r.value));
968
+ }
969
+ toggleValue() {
970
+ const e = this.options[this.cursor];
971
+ if (this.value === void 0 && (this.value = []), e.group === !0) {
972
+ const s = e.value, i = this.getGroupItems(s);
973
+ this.isGroupSelected(s) ? this.value = this.value.filter((r) => i.findIndex((n) => n.value === r) === -1) : this.value = [...this.value, ...i.map((r) => r.value)], this.value = Array.from(new Set(this.value));
974
+ } else this.value = this.value.includes(e.value) ? this.value.filter((i) => i !== e.value) : [...this.value, e.value];
975
+ }
976
+ constructor(e) {
977
+ super(e, !1);
978
+ const { options: s } = e;
979
+ this.#t = e.selectableGroups !== !1, this.options = Object.entries(s).flatMap(([i, r]) => [{
980
+ value: i,
981
+ group: !0,
982
+ label: i
983
+ }, ...r.map((n) => ({
984
+ ...n,
985
+ group: i
986
+ }))]), this.value = [...e.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), this.#t ? 0 : 1), this.on("cursor", (i) => {
987
+ switch (i) {
988
+ case "left":
989
+ case "up": {
990
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
991
+ const r = this.options[this.cursor]?.group === !0;
992
+ !this.#t && r && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
993
+ break;
994
+ }
995
+ case "down":
996
+ case "right": {
997
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
998
+ const r = this.options[this.cursor]?.group === !0;
999
+ !this.#t && r && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
1000
+ break;
1001
+ }
1002
+ case "space":
1003
+ this.toggleValue();
1004
+ break;
1005
+ }
1006
+ });
1007
+ }
1008
+ };
1009
+ function D(t, e, s) {
1010
+ const i = t + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
1011
+ return s[n].disabled ? D(n, e < 0 ? -1 : 1, s) : n;
1012
+ }
1013
+ var Mt$1 = class extends x$1 {
1014
+ options;
1015
+ cursor = 0;
1016
+ get _value() {
1017
+ return this.options[this.cursor].value;
1018
+ }
1019
+ get _enabledOptions() {
1020
+ return this.options.filter((e) => e.disabled !== !0);
1021
+ }
1022
+ toggleAll() {
1023
+ const e = this._enabledOptions;
1024
+ this.value = this.value !== void 0 && this.value.length === e.length ? [] : e.map((i) => i.value);
1025
+ }
1026
+ toggleInvert() {
1027
+ const e = this.value;
1028
+ if (!e) return;
1029
+ this.value = this._enabledOptions.filter((i) => !e.includes(i.value)).map((i) => i.value);
1030
+ }
1031
+ toggleValue() {
1032
+ this.value === void 0 && (this.value = []);
1033
+ this.value = this.value.includes(this._value) ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
1034
+ }
1035
+ constructor(e) {
1036
+ super(e, !1), this.options = e.options, this.value = [...e.initialValues ?? []];
1037
+ const s = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), 0);
1038
+ this.cursor = this.options[s].disabled ? D(s, 1, this.options) : s, this.on("key", (i) => {
1039
+ i === "a" && this.toggleAll(), i === "i" && this.toggleInvert();
1040
+ }), this.on("cursor", (i) => {
1041
+ switch (i) {
1042
+ case "left":
1043
+ case "up":
1044
+ this.cursor = D(this.cursor, -1, this.options);
1045
+ break;
1046
+ case "down":
1047
+ case "right":
1048
+ this.cursor = D(this.cursor, 1, this.options);
1049
+ break;
1050
+ case "space":
1051
+ this.toggleValue();
1052
+ break;
1053
+ }
1054
+ });
1055
+ }
1056
+ };
1057
+ let Lt$1 = class extends x$1 {
1058
+ _mask = "•";
1059
+ get cursor() {
1060
+ return this._cursor;
1061
+ }
1062
+ get masked() {
1063
+ return this.userInput.replaceAll(/./g, this._mask);
1064
+ }
1065
+ get userInputWithCursor() {
1066
+ if (this.state === "submit" || this.state === "cancel") return this.masked;
1067
+ const e = this.userInput;
1068
+ if (this.cursor >= e.length) return `${this.masked}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
1069
+ const s = this.masked, i = s.slice(0, this.cursor), r = s.slice(this.cursor);
1070
+ return `${i}${import_picocolors.default.inverse(r[0])}${r.slice(1)}`;
1071
+ }
1072
+ clear() {
1073
+ this._clearUserInput();
1074
+ }
1075
+ constructor({ mask: e, ...s }) {
1076
+ super(s), this._mask = e ?? "•", this.on("userInput", (i) => {
1077
+ this._setValue(i);
1078
+ });
1079
+ }
1080
+ };
1081
+ var Wt$1 = class extends x$1 {
1082
+ options;
1083
+ cursor = 0;
1084
+ get _selectedValue() {
1085
+ return this.options[this.cursor];
1086
+ }
1087
+ changeValue() {
1088
+ this.value = this._selectedValue.value;
1089
+ }
1090
+ constructor(e) {
1091
+ super(e, !1), this.options = e.options;
1092
+ const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
1093
+ this.cursor = this.options[i].disabled ? D(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
1094
+ switch (r) {
1095
+ case "left":
1096
+ case "up":
1097
+ this.cursor = D(this.cursor, -1, this.options);
1098
+ break;
1099
+ case "down":
1100
+ case "right":
1101
+ this.cursor = D(this.cursor, 1, this.options);
1102
+ break;
1103
+ }
1104
+ this.changeValue();
1105
+ });
1106
+ }
1107
+ };
1108
+ var Tt$1 = class extends x$1 {
1109
+ options;
1110
+ cursor = 0;
1111
+ constructor(e) {
1112
+ super(e, !1), this.options = e.options;
1113
+ const s = e.caseSensitive === !0, i = this.options.map(({ value: [r] }) => s ? r : r?.toLowerCase());
1114
+ this.cursor = Math.max(i.indexOf(e.initialValue), 0), this.on("key", (r, n) => {
1115
+ if (!r) return;
1116
+ const u = s && n.shift ? r.toUpperCase() : r;
1117
+ if (!i.includes(u)) return;
1118
+ const a = this.options.find(({ value: [l] }) => s ? l === u : l?.toLowerCase() === r);
1119
+ a && (this.value = a.value, this.state = "submit", this.emit("submit"));
1120
+ });
1121
+ }
1122
+ };
1123
+ var $t = class extends x$1 {
1124
+ get userInputWithCursor() {
1125
+ if (this.state === "submit") return this.userInput;
1126
+ const e = this.userInput;
1127
+ if (this.cursor >= e.length) return `${this.userInput}\u2588`;
1128
+ const s = e.slice(0, this.cursor), [i, ...r] = e.slice(this.cursor);
1129
+ return `${s}${import_picocolors.default.inverse(i)}${r.join("")}`;
1130
+ }
1131
+ get cursor() {
1132
+ return this._cursor;
1133
+ }
1134
+ constructor(e) {
1135
+ super({
1136
+ ...e,
1137
+ initialUserInput: e.initialUserInput ?? e.initialValue
1138
+ }), this.on("userInput", (s) => {
1139
+ this._setValue(s);
1140
+ }), this.on("finalize", () => {
1141
+ this.value || (this.value = e.defaultValue), this.value === void 0 && (this.value = "");
1142
+ });
1143
+ }
1144
+ };
1145
+
1146
+ //#endregion
1147
+ //#region ../../node_modules/.pnpm/@clack+prompts@1.0.0/node_modules/@clack/prompts/dist/index.mjs
1148
+ function ht() {
1149
+ 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";
1150
+ }
1151
+ const ee = ht(), ue = () => process.env.CI === "true", Te = (e) => e.isTTY === !0, w = (e, r) => ee ? e : r, Me = w("◆", "*"), ce = w("■", "x"), de = w("▲", "x"), k = w("◇", "o"), $e = w("┌", "T"), h = w("│", "|"), x = w("└", "—"), Re = w("┐", "T"), Oe = w("┘", "—"), Y = w("●", ">"), K = w("○", " "), te = w("◻", "[•]"), G = w("◼", "[+]"), z = w("◻", "[ ]"), Pe = w("▪", "•"), se = w("─", "-"), he = w("╮", "+"), Ne = w("├", "+"), me = w("╯", "+"), pe = w("╰", "+"), We = w("╭", "+"), ge = w("●", "•"), fe = w("◆", "*"), Fe = w("▲", "!"), ye = w("■", "x"), N = (e) => {
1152
+ switch (e) {
1153
+ case "initial":
1154
+ case "active": return import_picocolors.default.cyan(Me);
1155
+ case "cancel": return import_picocolors.default.red(ce);
1156
+ case "error": return import_picocolors.default.yellow(de);
1157
+ case "submit": return import_picocolors.default.green(k);
1158
+ }
1159
+ }, Ee = (e) => {
1160
+ switch (e) {
1161
+ case "initial":
1162
+ case "active": return import_picocolors.default.cyan(h);
1163
+ case "cancel": return import_picocolors.default.red(h);
1164
+ case "error": return import_picocolors.default.yellow(h);
1165
+ case "submit": return import_picocolors.default.green(h);
1166
+ }
1167
+ }, 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 = {
1168
+ limit: Infinity,
1169
+ ellipsis: ""
1170
+ }, Le = (e, r = {}, s = {}) => {
1171
+ 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;
1172
+ 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;
1173
+ e: for (;;) {
1174
+ if (b > B || c >= m && c > $) {
1175
+ const _ = e.slice(B, b) || e.slice($, c);
1176
+ f = 0;
1177
+ for (const D of _.replaceAll(ft, "")) {
1178
+ const T = D.codePointAt(0) || 0;
1179
+ 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) {
1180
+ F = !0;
1181
+ break e;
1182
+ }
1183
+ f += D.length, A += C;
1184
+ }
1185
+ B = b = 0;
1186
+ }
1187
+ if (c >= m) break;
1188
+ if (ne.lastIndex = c, ne.test(e)) {
1189
+ if (f = ne.lastIndex - c, C = f * p, A + C > S && (v = Math.min(v, c + Math.floor((S - A) / p))), A + C > i) {
1190
+ F = !0;
1191
+ break;
1192
+ }
1193
+ A += C, B = $, b = c, c = $ = ne.lastIndex;
1194
+ continue;
1195
+ }
1196
+ if (ve.lastIndex = c, ve.test(e)) {
1197
+ if (A + u > S && (v = Math.min(v, c)), A + u > i) {
1198
+ F = !0;
1199
+ break;
1200
+ }
1201
+ A += u, B = $, b = c, c = $ = ve.lastIndex;
1202
+ continue;
1203
+ }
1204
+ if (re.lastIndex = c, re.test(e)) {
1205
+ if (f = re.lastIndex - c, C = f * l, A + C > S && (v = Math.min(v, c + Math.floor((S - A) / l))), A + C > i) {
1206
+ F = !0;
1207
+ break;
1208
+ }
1209
+ A += C, B = $, b = c, c = $ = re.lastIndex;
1210
+ continue;
1211
+ }
1212
+ if (ie.lastIndex = c, ie.test(e)) {
1213
+ if (f = ie.lastIndex - c, C = f * a, A + C > S && (v = Math.min(v, c + Math.floor((S - A) / a))), A + C > i) {
1214
+ F = !0;
1215
+ break;
1216
+ }
1217
+ A += C, B = $, b = c, c = $ = ie.lastIndex;
1218
+ continue;
1219
+ }
1220
+ if (Ae.lastIndex = c, Ae.test(e)) {
1221
+ if (A + g > S && (v = Math.min(v, c)), A + g > i) {
1222
+ F = !0;
1223
+ break;
1224
+ }
1225
+ A += g, B = $, b = c, c = $ = Ae.lastIndex;
1226
+ continue;
1227
+ }
1228
+ c += 1;
1229
+ }
1230
+ return {
1231
+ width: F ? S : A,
1232
+ index: F ? v : m,
1233
+ truncated: F,
1234
+ ellipsed: F && i >= o
1235
+ };
1236
+ }, yt = {
1237
+ limit: Infinity,
1238
+ ellipsis: "",
1239
+ ellipsisWidth: 0
1240
+ }, M = (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) => {
1241
+ if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
1242
+ if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
1243
+ if (e === 1 || e === 2) return 22;
1244
+ if (e === 3) return 23;
1245
+ if (e === 4) return 24;
1246
+ if (e === 7) return 27;
1247
+ if (e === 8) return 28;
1248
+ if (e === 9) return 29;
1249
+ if (e === 0) return 0;
1250
+ }, He = (e) => `${ae}${Ve}${e}${ke}`, Ue = (e) => `${ae}${we}${e}${Ce}`, Ct = (e) => e.map((r) => M(r)), Se = (e, r, s) => {
1251
+ const i = r[Symbol.iterator]();
1252
+ let n = !1, o = !1, u = e.at(-1), l = u === void 0 ? 0 : M(u), a = i.next(), d = i.next(), g = 0;
1253
+ for (; !a.done;) {
1254
+ const E = a.value, p = M(E);
1255
+ 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;
1256
+ }
1257
+ u = e.at(-1), !l && u !== void 0 && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
1258
+ }, wt = (e) => {
1259
+ const r = e.split(" ");
1260
+ let s = r.length;
1261
+ for (; s > 0 && !(M(r[s - 1]) > 0);) s--;
1262
+ return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
1263
+ }, St = (e, r, s = {}) => {
1264
+ if (s.trim !== !1 && e.trim() === "") return "";
1265
+ let i = "", n, o;
1266
+ const u = e.split(" "), l = Ct(u);
1267
+ let a = [""];
1268
+ for (const [$, c] of u.entries()) {
1269
+ s.trim !== !1 && (a[a.length - 1] = (a.at(-1) ?? "").trimStart());
1270
+ let m = M(a.at(-1) ?? "");
1271
+ 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) {
1272
+ const f = r - m, F = 1 + Math.floor((l[$] - f - 1) / r);
1273
+ Math.floor((l[$] - 1) / r) < F && a.push(""), Se(a, c, r);
1274
+ continue;
1275
+ }
1276
+ if (m + l[$] > r && m > 0 && l[$] > 0) {
1277
+ if (s.wordWrap === !1 && m < r) {
1278
+ Se(a, c, r);
1279
+ continue;
1280
+ }
1281
+ a.push("");
1282
+ }
1283
+ if (m + l[$] > r && s.wordWrap === !1) {
1284
+ Se(a, c, r);
1285
+ continue;
1286
+ }
1287
+ a[a.length - 1] += c;
1288
+ }
1289
+ s.trim !== !1 && (a = a.map(($) => wt($)));
1290
+ const d = a.join(`
1291
+ `), g = d[Symbol.iterator]();
1292
+ let E = g.next(), p = g.next(), y = 0;
1293
+ for (; !E.done;) {
1294
+ const $ = E.value, c = p.value;
1295
+ if (i += $, $ === ae || $ === je) {
1296
+ Ge.lastIndex = y + 1;
1297
+ const F = Ge.exec(d)?.groups;
1298
+ if (F?.code !== void 0) {
1299
+ const v = Number.parseFloat(F.code);
1300
+ n = v === Et ? void 0 : v;
1301
+ } else F?.uri !== void 0 && (o = F.uri.length === 0 ? void 0 : F.uri);
1302
+ }
1303
+ const m = n ? At(n) : void 0;
1304
+ c === `
1305
+ ` ? (o && (i += Ue("")), n && m && (i += He(m))) : $ === `
1306
+ ` && (n && m && (i += He(n)), o && (i += Ue(o))), y += $.length, E = p, p = g.next();
1307
+ }
1308
+ return i;
1309
+ };
1310
+ function q(e, r, s) {
1311
+ return String(e).normalize().replaceAll(`\r
1312
+ `, `
1313
+ `).split(`
1314
+ `).map((i) => St(i, r, s)).join(`
1315
+ `);
1316
+ }
1317
+ const It = (e, r, s, i, n) => {
1318
+ let o = r, u = 0;
1319
+ for (let l = s; l < i; l++) {
1320
+ const a = e[l];
1321
+ if (o = o - a.length, u++, o <= n) break;
1322
+ }
1323
+ return {
1324
+ lineCount: o,
1325
+ removals: u
1326
+ };
1327
+ }, J = (e) => {
1328
+ 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);
1329
+ let $ = 0;
1330
+ r >= y - 3 && ($ = Math.max(Math.min(r - y + 3, s.length - y), 0));
1331
+ let c = y < s.length && $ > 0, m = y < s.length && $ + y < s.length;
1332
+ const f = Math.min($ + y, s.length), F = [];
1333
+ let v = 0;
1334
+ c && v++, m && v++;
1335
+ const S = $ + (c ? 1 : 0), B = f - (m ? 1 : 0);
1336
+ for (let A = S; A < B; A++) {
1337
+ const C = q(i(s[A], A === r), a, {
1338
+ hard: !0,
1339
+ trim: !1
1340
+ }).split(`
1341
+ `);
1342
+ F.push(C), v += C.length;
1343
+ }
1344
+ if (v > p) {
1345
+ let A = 0, C = 0, _ = v;
1346
+ const D = r - S, T = (W, I) => It(F, _, W, I, p);
1347
+ 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));
1348
+ }
1349
+ const b = [];
1350
+ c && b.push(g);
1351
+ for (const A of F) for (const C of A) b.push(C);
1352
+ return m && b.push(g), b;
1353
+ };
1354
+ function Ke(e) {
1355
+ return e.label ?? String(e.value ?? "");
1356
+ }
1357
+ function qe(e, r) {
1358
+ if (!e) return !0;
1359
+ const s = (r.label ?? String(r.value ?? "")).toLowerCase(), i = (r.hint ?? "").toLowerCase(), n = String(r.value).toLowerCase(), o = e.toLowerCase();
1360
+ return s.includes(o) || i.includes(o) || n.includes(o);
1361
+ }
1362
+ function Bt(e, r) {
1363
+ const s = [];
1364
+ for (const i of r) e.includes(i.value) && s.push(i);
1365
+ return s;
1366
+ }
1367
+ const Je = (e) => new Vt$1({
1368
+ options: e.options,
1369
+ initialValue: e.initialValue ? [e.initialValue] : void 0,
1370
+ initialUserInput: e.initialUserInput,
1371
+ filter: e.filter ?? ((r, s) => qe(r, s)),
1372
+ signal: e.signal,
1373
+ input: e.input,
1374
+ output: e.output,
1375
+ validate: e.validate,
1376
+ render() {
1377
+ const r = [`${import_picocolors.default.gray(h)}`, `${N(this.state)} ${e.message}`], s = this.userInput, i = this.options, n = e.placeholder, o = s === "" && n !== void 0;
1378
+ switch (this.state) {
1379
+ case "submit": {
1380
+ const u = Bt(this.selectedValues, i), l = u.length > 0 ? ` ${import_picocolors.default.dim(u.map(Ke).join(", "))}` : "";
1381
+ return `${r.join(`
1382
+ `)}
1383
+ ${import_picocolors.default.gray(h)}${l}`;
1384
+ }
1385
+ case "cancel": {
1386
+ const u = s ? ` ${import_picocolors.default.strikethrough(import_picocolors.default.dim(s))}` : "";
1387
+ return `${r.join(`
1388
+ `)}
1389
+ ${import_picocolors.default.gray(h)}${u}`;
1390
+ }
1391
+ default: {
1392
+ const u = `${(this.state === "error" ? import_picocolors.default.yellow : import_picocolors.default.cyan)(h)} `, l = (this.state === "error" ? import_picocolors.default.yellow : import_picocolors.default.cyan)(x);
1393
+ let a = "";
1394
+ if (this.isNavigating || o) {
1395
+ const c = o ? n : s;
1396
+ a = c !== "" ? ` ${import_picocolors.default.dim(c)}` : "";
1397
+ } else a = ` ${this.userInputWithCursor}`;
1398
+ const d = this.filteredOptions.length !== i.length ? import_picocolors.default.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", g = this.filteredOptions.length === 0 && s ? [`${u}${import_picocolors.default.yellow("No matches found")}`] : [], E = this.state === "error" ? [`${u}${import_picocolors.default.yellow(this.error)}`] : [];
1399
+ r.push(`${u.trimEnd()}`, `${u}${import_picocolors.default.dim("Search:")}${a}${d}`, ...g, ...E);
1400
+ const p = [
1401
+ `${import_picocolors.default.dim("↑/↓")} to select`,
1402
+ `${import_picocolors.default.dim("Enter:")} confirm`,
1403
+ `${import_picocolors.default.dim("Type:")} to search`
1404
+ ], y = [`${u}${import_picocolors.default.dim(p.join(" • "))}`, `${l}`], $ = this.filteredOptions.length === 0 ? [] : J({
1405
+ cursor: this.cursor,
1406
+ options: this.filteredOptions,
1407
+ columnPadding: 3,
1408
+ rowPadding: r.length + y.length,
1409
+ style: (c, m) => {
1410
+ const f = Ke(c), F = c.hint && c.value === this.focusedValue ? import_picocolors.default.dim(` (${c.hint})`) : "";
1411
+ return m ? `${import_picocolors.default.green(Y)} ${f}${F}` : `${import_picocolors.default.dim(K)} ${import_picocolors.default.dim(f)}${F}`;
1412
+ },
1413
+ maxItems: e.maxItems,
1414
+ output: e.output
1415
+ });
1416
+ return [
1417
+ ...r,
1418
+ ...$.map((c) => `${u}${c}`),
1419
+ ...y
1420
+ ].join(`
1421
+ `);
1422
+ }
1423
+ }
1424
+ }
1425
+ }).prompt(), bt = (e) => {
1426
+ const r = (i, n, o, u) => {
1427
+ const l = o.includes(i.value), a = i.label ?? String(i.value ?? ""), d = i.hint && u !== void 0 && i.value === u ? import_picocolors.default.dim(` (${i.hint})`) : "", g = l ? import_picocolors.default.green(G) : import_picocolors.default.dim(z);
1428
+ return n ? `${g} ${a}${d}` : `${g} ${import_picocolors.default.dim(a)}`;
1429
+ }, s = new Vt$1({
1430
+ options: e.options,
1431
+ multiple: !0,
1432
+ filter: e.filter ?? ((i, n) => qe(i, n)),
1433
+ validate: () => {
1434
+ if (e.required && s.selectedValues.length === 0) return "Please select at least one item";
1435
+ },
1436
+ initialValue: e.initialValues,
1437
+ signal: e.signal,
1438
+ input: e.input,
1439
+ output: e.output,
1440
+ render() {
1441
+ const i = `${import_picocolors.default.gray(h)}
1442
+ ${N(this.state)} ${e.message}
1443
+ `, n = this.userInput, o = e.placeholder, u = n === "" && o !== void 0, l = this.isNavigating || u ? import_picocolors.default.dim(u ? o : n) : this.userInputWithCursor, a = this.options, d = this.filteredOptions.length !== a.length ? import_picocolors.default.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
1444
+ switch (this.state) {
1445
+ case "submit": return `${i}${import_picocolors.default.gray(h)} ${import_picocolors.default.dim(`${this.selectedValues.length} items selected`)}`;
1446
+ case "cancel": return `${i}${import_picocolors.default.gray(h)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(n))}`;
1447
+ default: {
1448
+ const g = this.state === "error" ? import_picocolors.default.yellow : import_picocolors.default.cyan, E = [
1449
+ `${import_picocolors.default.dim("↑/↓")} to navigate`,
1450
+ `${import_picocolors.default.dim(this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
1451
+ `${import_picocolors.default.dim("Enter:")} confirm`,
1452
+ `${import_picocolors.default.dim("Type:")} to search`
1453
+ ], p = this.filteredOptions.length === 0 && n ? [`${g(h)} ${import_picocolors.default.yellow("No matches found")}`] : [], y = this.state === "error" ? [`${g(h)} ${import_picocolors.default.yellow(this.error)}`] : [], $ = [
1454
+ ...`${i}${g(h)}`.split(`
1455
+ `),
1456
+ `${g(h)} ${import_picocolors.default.dim("Search:")} ${l}${d}`,
1457
+ ...p,
1458
+ ...y
1459
+ ], c = [`${g(h)} ${import_picocolors.default.dim(E.join(" • "))}`, `${g(x)}`], m = J({
1460
+ cursor: this.cursor,
1461
+ options: this.filteredOptions,
1462
+ style: (f, F) => r(f, F, this.selectedValues, this.focusedValue),
1463
+ maxItems: e.maxItems,
1464
+ output: e.output,
1465
+ rowPadding: $.length + c.length
1466
+ });
1467
+ return [
1468
+ ...$,
1469
+ ...m.map((f) => `${g(h)} ${f}`),
1470
+ ...c
1471
+ ].join(`
1472
+ `);
1473
+ }
1474
+ }
1475
+ }
1476
+ });
1477
+ return s.prompt();
1478
+ }, xt = [
1479
+ We,
1480
+ he,
1481
+ pe,
1482
+ me
1483
+ ], _t = [
1484
+ $e,
1485
+ Re,
1486
+ x,
1487
+ Oe
1488
+ ];
1489
+ function Xe(e, r, s, i) {
1490
+ let n = s, o = s;
1491
+ return i === "center" ? n = Math.floor((r - e) / 2) : i === "right" && (n = r - e - s), o = r - n - e, [n, o];
1492
+ }
1493
+ const Dt = (e) => e, Tt = (e = "", r = "", s) => {
1494
+ const i = s?.output ?? process.stdout, n = rt(i), o = 2, u = s?.titlePadding ?? 1, l = s?.contentPadding ?? 2, a = s?.width === void 0 || s.width === "auto" ? 1 : Math.min(1, s.width), d = (s?.withGuide ?? _.withGuide) !== !1 ? `${h} ` : "", g = s?.formatBorder ?? Dt, E = (s?.rounded ? xt : _t).map(g), p = g(se), y = g(h), $ = M(d), c = M(r), m = n - $;
1495
+ let f = Math.floor(n * a) - $;
1496
+ if (s?.width === "auto") {
1497
+ const _ = e.split(`
1498
+ `);
1499
+ let D = c + u * 2;
1500
+ for (const W of _) {
1501
+ const I = M(W) + l * 2;
1502
+ I > D && (D = I);
1503
+ }
1504
+ const T = D + o;
1505
+ T < f && (f = T);
1506
+ }
1507
+ f % 2 !== 0 && (f < m ? f++ : f--);
1508
+ const F = f - o, v = F - u * 2, S = c > v ? `${r.slice(0, v - 3)}...` : r, [B, b] = Xe(M(S), F, u, s?.titleAlign), A = q(e, F - l * 2, {
1509
+ hard: !0,
1510
+ trim: !1
1511
+ });
1512
+ i.write(`${d}${E[0]}${p.repeat(B)}${S}${p.repeat(b)}${E[1]}
1513
+ `);
1514
+ const C = A.split(`
1515
+ `);
1516
+ for (const _ of C) {
1517
+ const [D, T] = Xe(M(_), F, l, s?.contentAlign);
1518
+ i.write(`${d}${y}${" ".repeat(D)}${_}${" ".repeat(T)}${y}
1519
+ `);
1520
+ }
1521
+ i.write(`${d}${E[2]}${p.repeat(F)}${E[3]}
1522
+ `);
1523
+ }, Mt = (e) => {
1524
+ const r = e.active ?? "Yes", s = e.inactive ?? "No";
1525
+ return new kt$1({
1526
+ active: r,
1527
+ inactive: s,
1528
+ signal: e.signal,
1529
+ input: e.input,
1530
+ output: e.output,
1531
+ initialValue: e.initialValue ?? !0,
1532
+ render() {
1533
+ const i = `${import_picocolors.default.gray(h)}
1534
+ ${N(this.state)} ${e.message}
1535
+ `, n = this.value ? r : s;
1536
+ switch (this.state) {
1537
+ case "submit": return `${i}${import_picocolors.default.gray(h)} ${import_picocolors.default.dim(n)}`;
1538
+ case "cancel": return `${i}${import_picocolors.default.gray(h)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(n))}
1539
+ ${import_picocolors.default.gray(h)}`;
1540
+ default: return `${i}${import_picocolors.default.cyan(h)} ${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}`}
1541
+ ${import_picocolors.default.cyan(x)}
1542
+ `;
1543
+ }
1544
+ }
1545
+ }).prompt();
1546
+ }, Rt = async (e, r) => {
1547
+ const s = {}, i = Object.keys(e);
1548
+ for (const n of i) {
1549
+ const o = e[n], u = await o({ results: s })?.catch((l) => {
1550
+ throw l;
1551
+ });
1552
+ if (typeof r?.onCancel == "function" && Ct$1(u)) {
1553
+ s[n] = "canceled", r.onCancel({ results: s });
1554
+ continue;
1555
+ }
1556
+ s[n] = u;
1557
+ }
1558
+ return s;
1559
+ }, Ot = (e) => {
1560
+ const { selectableGroups: r = !0, groupSpacing: s = 0 } = e, i = (o, u, l = []) => {
1561
+ const a = o.label ?? String(o.value), d = typeof o.group == "string", g = d && (l[l.indexOf(o) + 1] ?? { group: !0 }), E = d && g && g.group === !0, p = d ? r ? `${E ? x : h} ` : " " : "";
1562
+ let y = "";
1563
+ if (s > 0 && !d) {
1564
+ const c = `
1565
+ ${import_picocolors.default.cyan(h)}`;
1566
+ y = `${c.repeat(s - 1)}${c} `;
1567
+ }
1568
+ if (u === "active") return `${y}${import_picocolors.default.dim(p)}${import_picocolors.default.cyan(te)} ${a}${o.hint ? ` ${import_picocolors.default.dim(`(${o.hint})`)}` : ""}`;
1569
+ if (u === "group-active") return `${y}${p}${import_picocolors.default.cyan(te)} ${import_picocolors.default.dim(a)}`;
1570
+ if (u === "group-active-selected") return `${y}${p}${import_picocolors.default.green(G)} ${import_picocolors.default.dim(a)}`;
1571
+ if (u === "selected") {
1572
+ const c = d || r ? import_picocolors.default.green(G) : "";
1573
+ return `${y}${import_picocolors.default.dim(p)}${c} ${import_picocolors.default.dim(a)}${o.hint ? ` ${import_picocolors.default.dim(`(${o.hint})`)}` : ""}`;
1574
+ }
1575
+ if (u === "cancelled") return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(a))}`;
1576
+ if (u === "active-selected") return `${y}${import_picocolors.default.dim(p)}${import_picocolors.default.green(G)} ${a}${o.hint ? ` ${import_picocolors.default.dim(`(${o.hint})`)}` : ""}`;
1577
+ if (u === "submitted") return `${import_picocolors.default.dim(a)}`;
1578
+ const $ = d || r ? import_picocolors.default.dim(z) : "";
1579
+ return `${y}${import_picocolors.default.dim(p)}${$} ${import_picocolors.default.dim(a)}`;
1580
+ }, n = e.required ?? !0;
1581
+ return new yt$1({
1582
+ options: e.options,
1583
+ signal: e.signal,
1584
+ input: e.input,
1585
+ output: e.output,
1586
+ initialValues: e.initialValues,
1587
+ required: n,
1588
+ cursorAt: e.cursorAt,
1589
+ selectableGroups: r,
1590
+ validate(o) {
1591
+ if (n && (o === void 0 || o.length === 0)) return `Please select at least one option.
1592
+ ${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
1593
+ },
1594
+ render() {
1595
+ const o = `${import_picocolors.default.gray(h)}
1596
+ ${N(this.state)} ${e.message}
1597
+ `, u = this.value ?? [];
1598
+ switch (this.state) {
1599
+ case "submit": {
1600
+ const l = this.options.filter(({ value: d }) => u.includes(d)).map((d) => i(d, "submitted")), a = l.length === 0 ? "" : ` ${l.join(import_picocolors.default.dim(", "))}`;
1601
+ return `${o}${import_picocolors.default.gray(h)}${a}`;
1602
+ }
1603
+ case "cancel": {
1604
+ const l = this.options.filter(({ value: a }) => u.includes(a)).map((a) => i(a, "cancelled")).join(import_picocolors.default.dim(", "));
1605
+ return `${o}${import_picocolors.default.gray(h)} ${l.trim() ? `${l}
1606
+ ${import_picocolors.default.gray(h)}` : ""}`;
1607
+ }
1608
+ case "error": {
1609
+ const l = this.error.split(`
1610
+ `).map((a, d) => d === 0 ? `${import_picocolors.default.yellow(x)} ${import_picocolors.default.yellow(a)}` : ` ${a}`).join(`
1611
+ `);
1612
+ return `${o}${import_picocolors.default.yellow(h)} ${this.options.map((a, d, g) => {
1613
+ const E = u.includes(a.value) || a.group === !0 && this.isGroupSelected(`${a.value}`), p = d === this.cursor;
1614
+ return !p && typeof a.group == "string" && this.options[this.cursor].value === a.group ? i(a, E ? "group-active-selected" : "group-active", g) : p && E ? i(a, "active-selected", g) : E ? i(a, "selected", g) : i(a, p ? "active" : "inactive", g);
1615
+ }).join(`
1616
+ ${import_picocolors.default.yellow(h)} `)}
1617
+ ${l}
1618
+ `;
1619
+ }
1620
+ default: {
1621
+ const l = this.options.map((d, g, E) => {
1622
+ const p = u.includes(d.value) || d.group === !0 && this.isGroupSelected(`${d.value}`), y = g === this.cursor, $ = !y && typeof d.group == "string" && this.options[this.cursor].value === d.group;
1623
+ let c = "";
1624
+ return $ ? c = i(d, p ? "group-active-selected" : "group-active", E) : y && p ? c = i(d, "active-selected", E) : p ? c = i(d, "selected", E) : c = i(d, y ? "active" : "inactive", E), `${g !== 0 && !c.startsWith(`
1625
+ `) ? " " : ""}${c}`;
1626
+ }).join(`
1627
+ ${import_picocolors.default.cyan(h)}`), a = l.startsWith(`
1628
+ `) ? "" : " ";
1629
+ return `${o}${import_picocolors.default.cyan(h)}${a}${l}
1630
+ ${import_picocolors.default.cyan(x)}
1631
+ `;
1632
+ }
1633
+ }
1634
+ }
1635
+ }).prompt();
1636
+ }, R = {
1637
+ message: (e = [], { symbol: r = import_picocolors.default.gray(h), secondarySymbol: s = import_picocolors.default.gray(h), output: i = process.stdout, spacing: n = 1, withGuide: o } = {}) => {
1638
+ const u = [], l = (o ?? _.withGuide) !== !1, a = l ? s : "", d = l ? `${r} ` : "", g = l ? `${s} ` : "";
1639
+ for (let p = 0; p < n; p++) u.push(a);
1640
+ const E = Array.isArray(e) ? e : e.split(`
1641
+ `);
1642
+ if (E.length > 0) {
1643
+ const [p, ...y] = E;
1644
+ p.length > 0 ? u.push(`${d}${p}`) : u.push(l ? r : "");
1645
+ for (const $ of y) $.length > 0 ? u.push(`${g}${$}`) : u.push(l ? s : "");
1646
+ }
1647
+ i.write(`${u.join(`
1648
+ `)}
1649
+ `);
1650
+ },
1651
+ info: (e, r) => {
1652
+ R.message(e, {
1653
+ ...r,
1654
+ symbol: import_picocolors.default.blue(ge)
1655
+ });
1656
+ },
1657
+ success: (e, r) => {
1658
+ R.message(e, {
1659
+ ...r,
1660
+ symbol: import_picocolors.default.green(fe)
1661
+ });
1662
+ },
1663
+ step: (e, r) => {
1664
+ R.message(e, {
1665
+ ...r,
1666
+ symbol: import_picocolors.default.green(k)
1667
+ });
1668
+ },
1669
+ warn: (e, r) => {
1670
+ R.message(e, {
1671
+ ...r,
1672
+ symbol: import_picocolors.default.yellow(Fe)
1673
+ });
1674
+ },
1675
+ warning: (e, r) => {
1676
+ R.warn(e, r);
1677
+ },
1678
+ error: (e, r) => {
1679
+ R.message(e, {
1680
+ ...r,
1681
+ symbol: import_picocolors.default.red(ye)
1682
+ });
1683
+ }
1684
+ }, Pt = (e = "", r) => {
1685
+ (r?.output ?? process.stdout).write(`${import_picocolors.default.gray(x)} ${import_picocolors.default.red(e)}
1686
+
1687
+ `);
1688
+ }, Nt = (e = "", r) => {
1689
+ (r?.output ?? process.stdout).write(`${import_picocolors.default.gray($e)} ${e}
1690
+ `);
1691
+ }, Wt = (e = "", r) => {
1692
+ (r?.output ?? process.stdout).write(`${import_picocolors.default.gray(h)}
1693
+ ${import_picocolors.default.gray(x)} ${e}
1694
+
1695
+ `);
1696
+ }, Q = (e, r) => e.split(`
1697
+ `).map((s) => r(s)).join(`
1698
+ `), Lt = (e) => {
1699
+ const r = (i, n) => {
1700
+ const o = i.label ?? String(i.value);
1701
+ return n === "disabled" ? `${import_picocolors.default.gray(z)} ${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)} ${Q(o, import_picocolors.default.dim)}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : n === "cancelled" ? `${Q(o, (u) => import_picocolors.default.strikethrough(import_picocolors.default.dim(u)))}` : n === "active-selected" ? `${import_picocolors.default.green(G)} ${o}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : n === "submitted" ? `${Q(o, import_picocolors.default.dim)}` : `${import_picocolors.default.dim(z)} ${Q(o, import_picocolors.default.dim)}`;
1702
+ }, s = e.required ?? !0;
1703
+ return new Mt$1({
1704
+ options: e.options,
1705
+ signal: e.signal,
1706
+ input: e.input,
1707
+ output: e.output,
1708
+ initialValues: e.initialValues,
1709
+ required: s,
1710
+ cursorAt: e.cursorAt,
1711
+ validate(i) {
1712
+ if (s && (i === void 0 || i.length === 0)) return `Please select at least one option.
1713
+ ${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
1714
+ },
1715
+ render() {
1716
+ const i = Bt$1(e.output, e.message, `${Ee(this.state)} `, `${N(this.state)} `), n = `${import_picocolors.default.gray(h)}
1717
+ ${i}
1718
+ `, o = this.value ?? [], u = (l, a) => {
1719
+ if (l.disabled) return r(l, "disabled");
1720
+ const d = o.includes(l.value);
1721
+ return a && d ? r(l, "active-selected") : d ? r(l, "selected") : r(l, a ? "active" : "inactive");
1722
+ };
1723
+ switch (this.state) {
1724
+ case "submit": {
1725
+ const l = this.options.filter(({ value: d }) => o.includes(d)).map((d) => r(d, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none");
1726
+ return `${n}${Bt$1(e.output, l, `${import_picocolors.default.gray(h)} `)}`;
1727
+ }
1728
+ case "cancel": {
1729
+ const l = this.options.filter(({ value: d }) => o.includes(d)).map((d) => r(d, "cancelled")).join(import_picocolors.default.dim(", "));
1730
+ if (l.trim() === "") return `${n}${import_picocolors.default.gray(h)}`;
1731
+ return `${n}${Bt$1(e.output, l, `${import_picocolors.default.gray(h)} `)}
1732
+ ${import_picocolors.default.gray(h)}`;
1733
+ }
1734
+ case "error": {
1735
+ const l = `${import_picocolors.default.yellow(h)} `, a = this.error.split(`
1736
+ `).map((E, p) => p === 0 ? `${import_picocolors.default.yellow(x)} ${import_picocolors.default.yellow(E)}` : ` ${E}`).join(`
1737
+ `), d = n.split(`
1738
+ `).length, g = a.split(`
1739
+ `).length + 1;
1740
+ return `${n}${l}${J({
1741
+ output: e.output,
1742
+ options: this.options,
1743
+ cursor: this.cursor,
1744
+ maxItems: e.maxItems,
1745
+ columnPadding: l.length,
1746
+ rowPadding: d + g,
1747
+ style: u
1748
+ }).join(`
1749
+ ${l}`)}
1750
+ ${a}
1751
+ `;
1752
+ }
1753
+ default: {
1754
+ const l = `${import_picocolors.default.cyan(h)} `, a = n.split(`
1755
+ `).length;
1756
+ return `${n}${l}${J({
1757
+ output: e.output,
1758
+ options: this.options,
1759
+ cursor: this.cursor,
1760
+ maxItems: e.maxItems,
1761
+ columnPadding: l.length,
1762
+ rowPadding: a + 2,
1763
+ style: u
1764
+ }).join(`
1765
+ ${l}`)}
1766
+ ${import_picocolors.default.cyan(x)}
1767
+ `;
1768
+ }
1769
+ }
1770
+ }
1771
+ }).prompt();
1772
+ }, jt = (e) => import_picocolors.default.dim(e), Vt = (e, r, s) => {
1773
+ const i = {
1774
+ hard: !0,
1775
+ trim: !1
1776
+ }, n = q(e, r, i).split(`
1777
+ `), o = n.reduce((a, d) => Math.max(M(d), a), 0);
1778
+ return q(e, r - (n.map(s).reduce((a, d) => Math.max(M(d), a), 0) - o), i);
1779
+ }, kt = (e = "", r = "", s) => {
1780
+ const i = s?.output ?? process$1.stdout, n = (s?.withGuide ?? _.withGuide) !== !1, o = s?.format ?? jt, u = [
1781
+ "",
1782
+ ...Vt(e, rt(i) - 6, o).split(`
1783
+ `).map(o),
1784
+ ""
1785
+ ], l = M(r), a = Math.max(u.reduce((p, y) => {
1786
+ const $ = M(y);
1787
+ return $ > p ? $ : p;
1788
+ }, 0), l) + 2, d = u.map((p) => `${import_picocolors.default.gray(h)} ${p}${" ".repeat(a - M(p))}${import_picocolors.default.gray(h)}`).join(`
1789
+ `), g = n ? `${import_picocolors.default.gray(h)}
1790
+ ` : "", E = n ? Ne : pe;
1791
+ i.write(`${g}${import_picocolors.default.green(k)} ${import_picocolors.default.reset(r)} ${import_picocolors.default.gray(se.repeat(Math.max(a - l - 1, 1)) + he)}
1792
+ ${d}
1793
+ ${import_picocolors.default.gray(E + se.repeat(a + 2) + me)}
1794
+ `);
1795
+ }, Gt = (e) => new Lt$1({
1796
+ validate: e.validate,
1797
+ mask: e.mask ?? Pe,
1798
+ signal: e.signal,
1799
+ input: e.input,
1800
+ output: e.output,
1801
+ render() {
1802
+ const r = `${import_picocolors.default.gray(h)}
1803
+ ${N(this.state)} ${e.message}
1804
+ `, s = this.userInputWithCursor, i = this.masked;
1805
+ switch (this.state) {
1806
+ case "error": {
1807
+ const n = i ? ` ${i}` : "";
1808
+ return e.clearOnError && this.clear(), `${r.trim()}
1809
+ ${import_picocolors.default.yellow(h)}${n}
1810
+ ${import_picocolors.default.yellow(x)} ${import_picocolors.default.yellow(this.error)}
1811
+ `;
1812
+ }
1813
+ case "submit": {
1814
+ const n = i ? ` ${import_picocolors.default.dim(i)}` : "";
1815
+ return `${r}${import_picocolors.default.gray(h)}${n}`;
1816
+ }
1817
+ case "cancel": {
1818
+ const n = i ? ` ${import_picocolors.default.strikethrough(import_picocolors.default.dim(i))}` : "";
1819
+ return `${r}${import_picocolors.default.gray(h)}${n}${i ? `
1820
+ ${import_picocolors.default.gray(h)}` : ""}`;
1821
+ }
1822
+ default: return `${r}${import_picocolors.default.cyan(h)} ${s}
1823
+ ${import_picocolors.default.cyan(x)}
1824
+ `;
1825
+ }
1826
+ }
1827
+ }).prompt(), Ht = (e) => {
1828
+ const r = e.validate;
1829
+ return Je({
1830
+ ...e,
1831
+ initialUserInput: e.initialValue ?? e.root ?? process.cwd(),
1832
+ maxItems: 5,
1833
+ validate(s) {
1834
+ if (!Array.isArray(s)) {
1835
+ if (!s) return "Please select a path";
1836
+ if (r) return r(s);
1837
+ }
1838
+ },
1839
+ options() {
1840
+ const s = this.userInput;
1841
+ if (s === "") return [];
1842
+ try {
1843
+ let i;
1844
+ return existsSync(s) ? lstatSync(s).isDirectory() ? i = s : i = dirname$1(s) : i = dirname$1(s), readdirSync(i).map((n) => {
1845
+ const o = join$1(i, n);
1846
+ return {
1847
+ name: n,
1848
+ path: o,
1849
+ isDirectory: lstatSync(o).isDirectory()
1850
+ };
1851
+ }).filter(({ path: n, isDirectory: o }) => n.startsWith(s) && (e.directory || !o)).map((n) => ({ value: n.path }));
1852
+ } catch {
1853
+ return [];
1854
+ }
1855
+ }
1856
+ });
1857
+ }, Ut = import_picocolors.default.magenta, Ie = ({ indicator: e = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: n, frames: o = ee ? [
1858
+ "◒",
1859
+ "◐",
1860
+ "◓",
1861
+ "◑"
1862
+ ] : [
1863
+ "•",
1864
+ "o",
1865
+ "O",
1866
+ "0"
1867
+ ], delay: u = ee ? 80 : 120, signal: l, ...a } = {}) => {
1868
+ const d = ue();
1869
+ let g, E, p = !1, y = !1, $ = "", c, m = performance.now();
1870
+ const f = rt(s), F = a?.styleFrame ?? Ut, v = (I) => {
1871
+ const O = I > 1 ? n ?? _.messages.error : i ?? _.messages.cancel;
1872
+ y = I === 1, p && (W(O, I), y && typeof r == "function" && r());
1873
+ }, S = () => v(2), B = () => v(1), b = () => {
1874
+ process.on("uncaughtExceptionMonitor", S), process.on("unhandledRejection", S), process.on("SIGINT", B), process.on("SIGTERM", B), process.on("exit", v), l && l.addEventListener("abort", B);
1875
+ }, A = () => {
1876
+ process.removeListener("uncaughtExceptionMonitor", S), process.removeListener("unhandledRejection", S), process.removeListener("SIGINT", B), process.removeListener("SIGTERM", B), process.removeListener("exit", v), l && l.removeEventListener("abort", B);
1877
+ }, C = () => {
1878
+ if (c === void 0) return;
1879
+ d && s.write(`
1880
+ `);
1881
+ const I = q(c, f, {
1882
+ hard: !0,
1883
+ trim: !1
1884
+ }).split(`
1885
+ `);
1886
+ I.length > 1 && s.write(import_src.cursor.up(I.length - 1)), s.write(import_src.cursor.to(0)), s.write(import_src.erase.down());
1887
+ }, _$1 = (I) => I.replace(/\.+$/, ""), D = (I) => {
1888
+ const O = (performance.now() - I) / 1e3, L = Math.floor(O / 60), j = Math.floor(O % 60);
1889
+ return L > 0 ? `[${L}m ${j}s]` : `[${j}s]`;
1890
+ }, T = (I = "") => {
1891
+ p = !0, g = xt$1({ output: s }), $ = _$1(I), m = performance.now(), s.write(`${import_picocolors.default.gray(h)}
1892
+ `);
1893
+ let O = 0, L = 0;
1894
+ b(), E = setInterval(() => {
1895
+ if (d && $ === c) return;
1896
+ C(), c = $;
1897
+ const j = F(o[O]);
1898
+ let Z;
1899
+ if (d) Z = `${j} ${$}...`;
1900
+ else if (e === "timer") Z = `${j} ${$} ${D(m)}`;
1901
+ else {
1902
+ const Ze = ".".repeat(Math.floor(L)).slice(0, 3);
1903
+ Z = `${j} ${$}${Ze}`;
1904
+ }
1905
+ const Qe = q(Z, f, {
1906
+ hard: !0,
1907
+ trim: !1
1908
+ });
1909
+ s.write(Qe), O = O + 1 < o.length ? O + 1 : 0, L = L < 4 ? L + .125 : 0;
1910
+ }, u);
1911
+ }, W = (I = "", O = 0, L = !1) => {
1912
+ if (!p) return;
1913
+ p = !1, clearInterval(E), C();
1914
+ const j = O === 0 ? import_picocolors.default.green(k) : O === 1 ? import_picocolors.default.red(ce) : import_picocolors.default.red(de);
1915
+ $ = I ?? $, L || (e === "timer" ? s.write(`${j} ${$} ${D(m)}
1916
+ `) : s.write(`${j} ${$}
1917
+ `)), A(), g();
1918
+ };
1919
+ return {
1920
+ start: T,
1921
+ stop: (I = "") => W(I, 0),
1922
+ message: (I = "") => {
1923
+ $ = _$1(I ?? $);
1924
+ },
1925
+ cancel: (I = "") => W(I, 1),
1926
+ error: (I = "") => W(I, 2),
1927
+ clear: () => W("", 0, !0),
1928
+ get isCancelled() {
1929
+ return y;
1930
+ }
1931
+ };
1932
+ }, Ye = {
1933
+ light: w("─", "-"),
1934
+ heavy: w("━", "="),
1935
+ block: w("█", "#")
1936
+ };
1937
+ const oe = (e, r) => e.includes(`
1938
+ `) ? e.split(`
1939
+ `).map((s) => r(s)).join(`
1940
+ `) : r(e), qt = (e) => {
1941
+ const r = (s, i) => {
1942
+ const n = s.label ?? String(s.value);
1943
+ switch (i) {
1944
+ case "disabled": return `${import_picocolors.default.gray(K)} ${oe(n, import_picocolors.default.gray)}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint ?? "disabled"})`)}` : ""}`;
1945
+ case "selected": return `${oe(n, import_picocolors.default.dim)}`;
1946
+ case "active": return `${import_picocolors.default.green(Y)} ${n}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}`;
1947
+ case "cancelled": return `${oe(n, (o) => import_picocolors.default.strikethrough(import_picocolors.default.dim(o)))}`;
1948
+ default: return `${import_picocolors.default.dim(K)} ${oe(n, import_picocolors.default.dim)}`;
1949
+ }
1950
+ };
1951
+ return new Wt$1({
1952
+ options: e.options,
1953
+ signal: e.signal,
1954
+ input: e.input,
1955
+ output: e.output,
1956
+ initialValue: e.initialValue,
1957
+ render() {
1958
+ const s = `${N(this.state)} `, i = `${Ee(this.state)} `, n = Bt$1(e.output, e.message, i, s), o = `${import_picocolors.default.gray(h)}
1959
+ ${n}
1960
+ `;
1961
+ switch (this.state) {
1962
+ case "submit": {
1963
+ const u = `${import_picocolors.default.gray(h)} `;
1964
+ return `${o}${Bt$1(e.output, r(this.options[this.cursor], "selected"), u)}`;
1965
+ }
1966
+ case "cancel": {
1967
+ const u = `${import_picocolors.default.gray(h)} `;
1968
+ return `${o}${Bt$1(e.output, r(this.options[this.cursor], "cancelled"), u)}
1969
+ ${import_picocolors.default.gray(h)}`;
1970
+ }
1971
+ default: {
1972
+ const u = `${import_picocolors.default.cyan(h)} `, l = o.split(`
1973
+ `).length;
1974
+ return `${o}${u}${J({
1975
+ output: e.output,
1976
+ cursor: this.cursor,
1977
+ options: this.options,
1978
+ maxItems: e.maxItems,
1979
+ columnPadding: u.length,
1980
+ rowPadding: l + 2,
1981
+ style: (a, d) => r(a, a.disabled ? "disabled" : d ? "active" : "inactive")
1982
+ }).join(`
1983
+ ${u}`)}
1984
+ ${import_picocolors.default.cyan(x)}
1985
+ `;
1986
+ }
1987
+ }
1988
+ }
1989
+ }).prompt();
1990
+ }, Jt = (e) => {
1991
+ const r = (s, i = "inactive") => {
1992
+ const n = s.label ?? String(s.value);
1993
+ return i === "selected" ? `${import_picocolors.default.dim(n)}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(n))}` : i === "active" ? `${import_picocolors.default.bgCyan(import_picocolors.default.gray(` ${s.value} `))} ${n}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}` : `${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(` ${s.value} `)))} ${n}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}`;
1994
+ };
1995
+ return new Tt$1({
1996
+ options: e.options,
1997
+ signal: e.signal,
1998
+ input: e.input,
1999
+ output: e.output,
2000
+ initialValue: e.initialValue,
2001
+ caseSensitive: e.caseSensitive,
2002
+ render() {
2003
+ const s = `${import_picocolors.default.gray(h)}
2004
+ ${N(this.state)} ${e.message}
2005
+ `;
2006
+ switch (this.state) {
2007
+ case "submit": {
2008
+ const i = `${import_picocolors.default.gray(h)} `, n = this.options.find((u) => u.value === this.value) ?? e.options[0];
2009
+ return `${s}${Bt$1(e.output, r(n, "selected"), i)}`;
2010
+ }
2011
+ case "cancel": {
2012
+ const i = `${import_picocolors.default.gray(h)} `;
2013
+ return `${s}${Bt$1(e.output, r(this.options[0], "cancelled"), i)}
2014
+ ${import_picocolors.default.gray(h)}`;
2015
+ }
2016
+ default: {
2017
+ const i = `${import_picocolors.default.cyan(h)} `;
2018
+ return `${s}${this.options.map((o, u) => Bt$1(e.output, r(o, u === this.cursor ? "active" : "inactive"), i)).join(`
2019
+ `)}
2020
+ ${import_picocolors.default.cyan(x)}
2021
+ `;
2022
+ }
2023
+ }
2024
+ }
2025
+ }).prompt();
2026
+ }, ze = `${import_picocolors.default.gray(h)} `, H = {
2027
+ message: async (e, { symbol: r = import_picocolors.default.gray(h) } = {}) => {
2028
+ process.stdout.write(`${import_picocolors.default.gray(h)}
2029
+ ${r} `);
2030
+ let s = 3;
2031
+ for await (let i of e) {
2032
+ i = i.replace(/\n/g, `
2033
+ ${ze}`), i.includes(`
2034
+ `) && (s = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
2035
+ `))).length);
2036
+ const n = stripVTControlCharacters(i).length;
2037
+ s + n < process.stdout.columns ? (s += n, process.stdout.write(i)) : (process.stdout.write(`
2038
+ ${ze}${i.trimStart()}`), s = 3 + stripVTControlCharacters(i.trimStart()).length);
2039
+ }
2040
+ process.stdout.write(`
2041
+ `);
2042
+ },
2043
+ info: (e) => H.message(e, { symbol: import_picocolors.default.blue(ge) }),
2044
+ success: (e) => H.message(e, { symbol: import_picocolors.default.green(fe) }),
2045
+ step: (e) => H.message(e, { symbol: import_picocolors.default.green(k) }),
2046
+ warn: (e) => H.message(e, { symbol: import_picocolors.default.yellow(Fe) }),
2047
+ warning: (e) => H.warn(e),
2048
+ error: (e) => H.message(e, { symbol: import_picocolors.default.red(ye) })
2049
+ }, Xt = async (e, r) => {
2050
+ for (const s of e) {
2051
+ if (s.enabled === !1) continue;
2052
+ const i = Ie(r);
2053
+ i.start(s.title);
2054
+ const n = await s.task(i.message);
2055
+ i.stop(n || s.title);
2056
+ }
2057
+ }, Yt = (e) => e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), zt = (e) => {
2058
+ const r = e.output ?? process.stdout, s = rt(r), i = import_picocolors.default.gray(h), n = e.spacing ?? 1, o = 3, u = e.retainLog === !0, l = !ue() && Te(r);
2059
+ r.write(`${i}
2060
+ `), r.write(`${import_picocolors.default.green(k)} ${e.title}
2061
+ `);
2062
+ for (let m = 0; m < n; m++) r.write(`${i}
2063
+ `);
2064
+ const a = [{
2065
+ value: "",
2066
+ full: ""
2067
+ }];
2068
+ let d = !1;
2069
+ const g = (m) => {
2070
+ if (a.length === 0) return;
2071
+ let f = 0;
2072
+ m && (f += n + 2);
2073
+ for (const F of a) {
2074
+ const { value: v, result: S } = F;
2075
+ let B = S?.message ?? v;
2076
+ if (B.length === 0) continue;
2077
+ S === void 0 && F.header !== void 0 && F.header !== "" && (B += `
2078
+ ${F.header}`);
2079
+ const b = B.split(`
2080
+ `).reduce((A, C) => C === "" ? A + 1 : A + Math.ceil((C.length + o) / s), 0);
2081
+ f += b;
2082
+ }
2083
+ f > 0 && (f += 1, r.write(import_src.erase.lines(f)));
2084
+ }, E = (m, f, F) => {
2085
+ const v = F ? `${m.full}
2086
+ ${m.value}` : m.value;
2087
+ m.header !== void 0 && m.header !== "" && R.message(m.header.split(`
2088
+ `).map(import_picocolors.default.bold), {
2089
+ output: r,
2090
+ secondarySymbol: i,
2091
+ symbol: i,
2092
+ spacing: 0
2093
+ }), R.message(v.split(`
2094
+ `).map(import_picocolors.default.dim), {
2095
+ output: r,
2096
+ secondarySymbol: i,
2097
+ symbol: i,
2098
+ spacing: f ?? n
2099
+ });
2100
+ }, p = () => {
2101
+ for (const m of a) {
2102
+ const { header: f, value: F, full: v } = m;
2103
+ (f === void 0 || f.length === 0) && F.length === 0 || E(m, void 0, u === !0 && v.length > 0);
2104
+ }
2105
+ }, y = (m, f, F) => {
2106
+ if (g(!1), (F?.raw !== !0 || !d) && m.value !== "" && (m.value += `
2107
+ `), m.value += Yt(f), d = F?.raw === !0, e.limit !== void 0) {
2108
+ const v = m.value.split(`
2109
+ `), S = v.length - e.limit;
2110
+ if (S > 0) {
2111
+ const B = v.splice(0, S);
2112
+ u && (m.full += (m.full === "" ? "" : `
2113
+ `) + B.join(`
2114
+ `));
2115
+ }
2116
+ m.value = v.join(`
2117
+ `);
2118
+ }
2119
+ l && $();
2120
+ }, $ = () => {
2121
+ for (const m of a) m.result ? m.result.status === "error" ? R.error(m.result.message, {
2122
+ output: r,
2123
+ secondarySymbol: i,
2124
+ spacing: 0
2125
+ }) : R.success(m.result.message, {
2126
+ output: r,
2127
+ secondarySymbol: i,
2128
+ spacing: 0
2129
+ }) : m.value !== "" && E(m, 0);
2130
+ }, c = (m, f) => {
2131
+ g(!1), m.result = f, l && $();
2132
+ };
2133
+ return {
2134
+ message(m, f) {
2135
+ y(a[0], m, f);
2136
+ },
2137
+ group(m) {
2138
+ const f = {
2139
+ header: m,
2140
+ value: "",
2141
+ full: ""
2142
+ };
2143
+ return a.push(f), {
2144
+ message(F, v) {
2145
+ y(f, F, v);
2146
+ },
2147
+ error(F) {
2148
+ c(f, {
2149
+ status: "error",
2150
+ message: F
2151
+ });
2152
+ },
2153
+ success(F) {
2154
+ c(f, {
2155
+ status: "success",
2156
+ message: F
2157
+ });
2158
+ }
2159
+ };
2160
+ },
2161
+ error(m, f) {
2162
+ g(!0), R.error(m, {
2163
+ output: r,
2164
+ secondarySymbol: i,
2165
+ spacing: 1
2166
+ }), f?.showLog !== !1 && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
2167
+ },
2168
+ success(m, f) {
2169
+ g(!0), R.success(m, {
2170
+ output: r,
2171
+ secondarySymbol: i,
2172
+ spacing: 1
2173
+ }), f?.showLog === !0 && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
2174
+ }
2175
+ };
2176
+ }, Qt = (e) => new $t({
2177
+ validate: e.validate,
2178
+ placeholder: e.placeholder,
2179
+ defaultValue: e.defaultValue,
2180
+ initialValue: e.initialValue,
2181
+ output: e.output,
2182
+ signal: e.signal,
2183
+ input: e.input,
2184
+ render() {
2185
+ const r = (e?.withGuide ?? _.withGuide) !== !1, s = `${`${r ? `${import_picocolors.default.gray(h)}
2186
+ ` : ""}${N(this.state)} `}${e.message}
2187
+ `, i = e.placeholder ? import_picocolors.default.inverse(e.placeholder[0]) + import_picocolors.default.dim(e.placeholder.slice(1)) : import_picocolors.default.inverse(import_picocolors.default.hidden("_")), n = this.userInput ? this.userInputWithCursor : i, o = this.value ?? "";
2188
+ switch (this.state) {
2189
+ case "error": {
2190
+ const u = this.error ? ` ${import_picocolors.default.yellow(this.error)}` : "", l = r ? `${import_picocolors.default.yellow(h)} ` : "", a = r ? import_picocolors.default.yellow(x) : "";
2191
+ return `${s.trim()}
2192
+ ${l}${n}
2193
+ ${a}${u}
2194
+ `;
2195
+ }
2196
+ case "submit": {
2197
+ const u = o ? ` ${import_picocolors.default.dim(o)}` : "";
2198
+ return `${s}${r ? import_picocolors.default.gray(h) : ""}${u}`;
2199
+ }
2200
+ case "cancel": {
2201
+ const u = o ? ` ${import_picocolors.default.strikethrough(import_picocolors.default.dim(o))}` : "", l = r ? import_picocolors.default.gray(h) : "";
2202
+ return `${s}${l}${u}${o.trim() ? `
2203
+ ${l}` : ""}`;
2204
+ }
2205
+ default: return `${s}${r ? `${import_picocolors.default.cyan(h)} ` : ""}${n}
2206
+ ${r ? import_picocolors.default.cyan(x) : ""}
2207
+ `;
2208
+ }
2209
+ }
2210
+ }).prompt();
2211
+
2212
+ //#endregion
2213
+ //#region ../../node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.cjs
2214
+ var require_ansis = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2215
+ let e, t, r, { defineProperty: l, setPrototypeOf: n, create: o, keys: s } = Object, i = "", { round: c, max: a } = Math, p = (e) => {
2216
+ let t = /([a-f\d]{3,6})/i.exec(e)?.[1], r = t?.length, l = parseInt(6 ^ r ? 3 ^ r ? "0" : t[0] + t[0] + t[1] + t[1] + t[2] + t[2] : t, 16);
2217
+ return [
2218
+ l >> 16 & 255,
2219
+ l >> 8 & 255,
2220
+ 255 & l
2221
+ ];
2222
+ }, u = (e, t, r) => e ^ t || t ^ r ? 16 + 36 * c(e / 51) + 6 * c(t / 51) + c(r / 51) : 8 > e ? 16 : e > 248 ? 231 : c(24 * (e - 8) / 247) + 232, d = (e) => {
2223
+ let t, r, l, n, o;
2224
+ return 8 > e ? 30 + e : 16 > e ? e - 8 + 90 : (232 > e ? (o = (e -= 16) % 36, t = (e / 36 | 0) / 5, r = (o / 6 | 0) / 5, l = o % 6 / 5) : t = r = l = (10 * (e - 232) + 8) / 255, n = 2 * a(t, r, l), n ? 30 + (c(l) << 2 | c(r) << 1 | c(t)) + (2 ^ n ? 0 : 60) : 30);
2225
+ }, f = (() => {
2226
+ let r = (e) => o.some(((t) => e.test(t))), l = globalThis, n = l.process ?? {}, o = n.argv ?? [], i = n.env ?? {}, c = -1;
2227
+ try {
2228
+ e = "," + s(i).join(",");
2229
+ } catch (e) {
2230
+ i = {}, c = 0;
2231
+ }
2232
+ let a = "FORCE_COLOR", p = {
2233
+ false: 0,
2234
+ 0: 0,
2235
+ 1: 1,
2236
+ 2: 2,
2237
+ 3: 3
2238
+ }[i[a]] ?? -1, u = a in i && p || r(/^--color=?(true|always)?$/);
2239
+ return u && (c = p), ~c || (c = ((r, l, n) => (t = r.TERM, {
2240
+ "24bit": 3,
2241
+ truecolor: 3,
2242
+ ansi256: 2,
2243
+ ansi: 1
2244
+ }[r.COLORTERM] || (r.CI ? /,GITHUB/.test(e) ? 3 : 1 : l && "dumb" !== t ? n ? 3 : /-256/.test(t) ? 2 : 1 : 0)))(i, !!i.PM2_HOME || i.NEXT_RUNTIME?.includes("edge") || !!n.stdout?.isTTY, "win32" === n.platform)), !p || i.NO_COLOR || r(/^--(no-color|color=(false|never))$/) ? 0 : l.window?.chrome || u && !c ? 3 : c;
2245
+ })(), g = {
2246
+ open: i,
2247
+ close: i
2248
+ }, h = 39, b = 49, O = {}, m = ({ p: e }, { open: t, close: l }) => {
2249
+ let o = (e, ...r) => {
2250
+ if (!e) {
2251
+ if (t && t === l) return t;
2252
+ if ((e ?? i) === i) return i;
2253
+ }
2254
+ let n, s = e.raw ? String.raw({ raw: e }, ...r) : i + e, c = o.p, a = c.o, p = c.c;
2255
+ if (s.includes("\x1B")) for (; c; c = c.p) {
2256
+ let { open: e, close: t } = c, r = t.length, l = i, o = 0;
2257
+ if (r) for (; ~(n = s.indexOf(t, o)); o = n + r) l += s.slice(o, n) + e;
2258
+ s = l + s.slice(o);
2259
+ }
2260
+ return a + (s.includes("\n") ? s.replace(/(\r?\n)/g, p + "$1" + a) : s) + p;
2261
+ }, s = t, c = l;
2262
+ return e && (s = e.o + t, c = l + e.c), n(o, r), o.p = {
2263
+ open: t,
2264
+ close: l,
2265
+ o: s,
2266
+ c,
2267
+ p: e
2268
+ }, o.open = s, o.close = c, o;
2269
+ };
2270
+ const w = new function e(t = f) {
2271
+ let s = {
2272
+ Ansis: e,
2273
+ level: t,
2274
+ isSupported: () => a,
2275
+ strip: (e) => e.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i),
2276
+ extend(e) {
2277
+ for (let t in e) {
2278
+ let r = e[t], l = (typeof r)[0];
2279
+ "s" === l ? (c(t, T(...p(r))), c(_(t), v(...p(r)))) : c(t, r, "f" === l);
2280
+ }
2281
+ return r = o({}, O), n(s, r), s;
2282
+ }
2283
+ }, c = (e, t, r) => {
2284
+ O[e] = { get() {
2285
+ let n = r ? (...e) => m(this, t(...e)) : m(this, t);
2286
+ return l(this, e, { value: n }), n;
2287
+ } };
2288
+ }, a = t > 0, w = (e, t) => a ? {
2289
+ open: `[${e}m`,
2290
+ close: `[${t}m`
2291
+ } : g, y = (e) => (t) => e(...p(t)), R = (e, t) => (r, l, n) => w(`${e}8;2;${r};${l};${n}`, t), $ = (e, t) => (r, l, n) => w(((e, t, r) => d(u(e, t, r)))(r, l, n) + e, t), x = (e) => (t, r, l) => e(u(t, r, l)), T = R(3, h), v = R(4, b), C = (e) => w("38;5;" + e, h), E = (e) => w("48;5;" + e, b);
2292
+ 2 === t ? (T = x(C), v = x(E)) : 1 === t && (T = $(0, h), v = $(10, b), C = (e) => w(d(e), h), E = (e) => w(d(e) + 10, b));
2293
+ let M, I = {
2294
+ fg: C,
2295
+ bg: E,
2296
+ rgb: T,
2297
+ bgRgb: v,
2298
+ hex: y(T),
2299
+ bgHex: y(v),
2300
+ visible: g,
2301
+ reset: w(0, 0),
2302
+ bold: w(1, 22),
2303
+ dim: w(2, 22),
2304
+ italic: w(3, 23),
2305
+ underline: w(4, 24),
2306
+ inverse: w(7, 27),
2307
+ hidden: w(8, 28),
2308
+ strikethrough: w(9, 29)
2309
+ }, _ = (e) => "bg" + e[0].toUpperCase() + e.slice(1), k = "Bright";
2310
+ return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map(((e, t) => {
2311
+ M = _(e), 8 > t ? (I[e + k] = w(90 + t, h), I[M + k] = w(100 + t, b)) : t = 60, I[e] = w(30 + t, h), I[M] = w(40 + t, b);
2312
+ })), s.extend(I);
2313
+ }();
2314
+ module.exports = w, w.default = w;
2315
+ }));
2316
+
2317
+ //#endregion
2318
+ //#region ../../node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.mjs
2319
+ var import_ansis = /* @__PURE__ */ __toESM(require_ansis(), 1);
2320
+ var ansis_default = import_ansis.default;
2321
+ const { Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible, bold, dim, italic, underline, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = import_ansis.default;
2322
+
2323
+ //#endregion
2324
+ //#region src/node/context-internal.ts
2325
+ const internalContextMap = /* @__PURE__ */ new WeakMap();
2326
+ function getInternalContext(context) {
2327
+ if (!internalContextMap.has(context)) {
2328
+ const internalContext = { storage: { auth: createStorage({
2329
+ filepath: join(context.workspaceRoot, "node_modules/.vite/devtools/auth.json"),
2330
+ initialValue: { trusted: {} }
2331
+ }) } };
2332
+ internalContextMap.set(context, internalContext);
2333
+ }
2334
+ return internalContextMap.get(context);
2335
+ }
2336
+
2337
+ //#endregion
2338
+ //#region src/node/rpc/anonymous/auth.ts
2339
+ const anonymousAuth = defineRpcFunction({
2340
+ name: "vite:anonymous:auth",
2341
+ type: "action",
2342
+ setup: (context) => {
2343
+ const storage = getInternalContext(context).storage.auth;
2344
+ return { handler: async (query) => {
2345
+ const session = context.rpc.getCurrentRpcSession();
2346
+ if (!session) throw new Error("Failed to retrieve the current RPC session");
2347
+ if (session.meta.isTrusted || storage.value().trusted[query.authId]) {
2348
+ session.meta.clientAuthId = query.authId;
2349
+ session.meta.isTrusted = true;
2350
+ return { isTrusted: true };
2351
+ }
2352
+ const message = [
2353
+ `A browser is requesting permissions to connect to the Vite DevTools.`,
2354
+ "",
2355
+ `User Agent: ${ansis_default.yellow(ansis_default.bold(query.ua || "Unknown"))}`,
2356
+ `Origin : ${ansis_default.cyan(ansis_default.bold(query.origin || "Unknown"))}`,
2357
+ `Identifier: ${ansis_default.green(ansis_default.bold(query.authId))}`,
2358
+ "",
2359
+ "This will allow the browser to interact with the server, make file changes and run commands.",
2360
+ ansis_default.red(ansis_default.bold("You should only trust your local development browsers."))
2361
+ ];
2362
+ kt(ansis_default.reset(message.join("\n")), ansis_default.bold(ansis_default.yellow(" Vite DevTools Permission Request ")));
2363
+ if (await Mt({
2364
+ message: ansis_default.bold(`Do you trust this client (${ansis_default.green(ansis_default.bold(query.authId))})?`),
2365
+ initialValue: false
2366
+ })) {
2367
+ storage.mutate((state) => {
2368
+ state.trusted[query.authId] = {
2369
+ authId: query.authId,
2370
+ ua: query.ua,
2371
+ origin: query.origin,
2372
+ timestamp: Date.now()
2373
+ };
2374
+ });
2375
+ session.meta.clientAuthId = query.authId;
2376
+ session.meta.isTrusted = true;
2377
+ Wt(ansis_default.green(ansis_default.bold(`You have granted permissions to ${ansis_default.bold(query.authId)}`)));
2378
+ return { isTrusted: true };
2379
+ }
2380
+ Wt(ansis_default.red(ansis_default.bold(`You have denied permissions to ${ansis_default.bold(query.authId)}`)));
2381
+ return { isTrusted: false };
2382
+ } };
2383
+ }
2384
+ });
2385
+
2386
+ //#endregion
2387
+ //#region src/node/rpc/internal/docks-on-launch.ts
2388
+ const docksOnLaunch = defineRpcFunction({
2389
+ name: "devtoolskit:internal:docks:on-launch",
2390
+ type: "action",
2391
+ setup: (context) => {
2392
+ const launchMap = /* @__PURE__ */ new Map();
2393
+ return { handler: async (entryId) => {
2394
+ if (launchMap.has(entryId)) return launchMap.get(entryId);
2395
+ const entry = context.docks.values().find((entry) => entry.id === entryId);
2396
+ if (!entry) throw new Error(`Dock entry with id "${entryId}" not found`);
2397
+ if (entry.type !== "launcher") throw new Error(`Dock entry with id "${entryId}" is not a launcher`);
2398
+ try {
2399
+ context.docks.update({
2400
+ ...entry,
2401
+ launcher: {
2402
+ ...entry.launcher,
2403
+ status: "loading"
2404
+ }
2405
+ });
2406
+ const promise = entry.launcher.onLaunch();
2407
+ launchMap.set(entryId, promise);
2408
+ const result = await promise;
2409
+ const newEntry = context.docks.values().find((entry) => entry.id === entryId) || entry;
2410
+ if (newEntry.type === "launcher") context.docks.update({
2411
+ ...newEntry,
2412
+ launcher: {
2413
+ ...newEntry.launcher,
2414
+ status: "success"
2415
+ }
2416
+ });
2417
+ return result;
2418
+ } catch (error) {
2419
+ console.error(`[VITE DEVTOOLS] Error launching dock entry "${entryId}"`, error);
2420
+ context.docks.update({
2421
+ ...entry,
2422
+ launcher: {
2423
+ ...entry.launcher,
2424
+ status: "error",
2425
+ error: error instanceof Error ? error.message : String(error)
2426
+ }
2427
+ });
2428
+ }
2429
+ } };
2430
+ }
2431
+ });
2432
+
2433
+ //#endregion
2434
+ //#region src/node/rpc/internal/rpc-server-list.ts
2435
+ const rpcServerList = defineRpcFunction({
2436
+ name: "devtoolskit:internal:rpc:server:list",
2437
+ type: "static",
2438
+ setup: (context) => {
2439
+ return { async handler() {
2440
+ return Object.fromEntries(Array.from(context.rpc.definitions.entries()).map(([name, fn]) => [name, { type: fn.type }]));
2441
+ } };
2442
+ }
2443
+ });
2444
+
2445
+ //#endregion
2446
+ //#region src/node/rpc/internal/state/get.ts
2447
+ const sharedStateGet = defineRpcFunction({
2448
+ name: "devtoolskit:internal:rpc:server-state:get",
2449
+ type: "query",
2450
+ setup: (context) => {
2451
+ return { handler: async (key) => {
2452
+ return (await context.rpc.sharedState.get(key)).value();
2453
+ } };
2454
+ }
2455
+ });
2456
+
2457
+ //#endregion
2458
+ //#region src/node/rpc/internal/state/patch.ts
2459
+ const sharedStatePatch = defineRpcFunction({
2460
+ name: "devtoolskit:internal:rpc:server-state:patch",
2461
+ type: "query",
2462
+ setup: (context) => {
2463
+ return { handler: async (key, patches, syncId) => {
2464
+ (await context.rpc.sharedState.get(key)).patch(patches, syncId);
2465
+ } };
2466
+ }
2467
+ });
2468
+
2469
+ //#endregion
2470
+ //#region src/node/rpc/internal/state/set.ts
2471
+ const sharedStateSet = defineRpcFunction({
2472
+ name: "devtoolskit:internal:rpc:server-state:set",
2473
+ type: "query",
2474
+ setup: (context) => {
2475
+ return { handler: async (key, value, syncId) => {
2476
+ (await context.rpc.sharedState.get(key)).mutate(() => value, syncId);
2477
+ } };
2478
+ }
2479
+ });
2480
+
2481
+ //#endregion
2482
+ //#region src/node/rpc/internal/state/subscribe.ts
2483
+ const debug = createDebug("vite:devtools:rpc:state:subscribe");
2484
+ const sharedStateSubscribe = defineRpcFunction({
2485
+ name: "devtoolskit:internal:rpc:server-state:subscribe",
2486
+ type: "event",
2487
+ setup: (context) => {
2488
+ return { handler: async (key) => {
2489
+ const session = context.rpc.getCurrentRpcSession();
2490
+ if (!session) return;
2491
+ debug("subscribe", {
2492
+ key,
2493
+ session: session.meta.id
2494
+ });
2495
+ session.meta.subscribedStates.add(key);
2496
+ } };
2497
+ }
2498
+ });
2499
+
2500
+ //#endregion
2501
+ //#region src/node/rpc/internal/terminals-list.ts
2502
+ const terminalsList = defineRpcFunction({
2503
+ name: "devtoolskit:internal:terminals:list",
2504
+ type: "static",
2505
+ setup: (context) => {
2506
+ return { async handler() {
2507
+ return Array.from(context.terminals.sessions.values()).map((i) => {
2508
+ return {
2509
+ id: i.id,
2510
+ title: i.title,
2511
+ description: i.description,
2512
+ status: i.status
2513
+ };
2514
+ });
2515
+ } };
2516
+ }
2517
+ });
2518
+
2519
+ //#endregion
2520
+ //#region src/node/rpc/internal/terminals-read.ts
2521
+ const terminalsRead = defineRpcFunction({
2522
+ name: "devtoolskit:internal:terminals:read",
2523
+ type: "query",
2524
+ setup: (context) => {
2525
+ return { async handler(id) {
2526
+ const session = context.terminals.sessions.get(id);
2527
+ if (!session) throw new Error(`Terminal session with id "${id}" not found`);
2528
+ return {
2529
+ buffer: session.buffer ?? [],
2530
+ ts: Date.now()
2531
+ };
2532
+ } };
2533
+ }
2534
+ });
2535
+
2536
+ //#endregion
2537
+ //#region src/node/rpc/public/open-in-editor.ts
2538
+ const openInEditor = defineRpcFunction({
2539
+ name: "vite:core:open-in-editor",
2540
+ type: "action",
2541
+ setup: () => {
2542
+ return { handler: async (path) => {
2543
+ await import("launch-editor").then((r) => r.default(path));
2544
+ } };
2545
+ }
2546
+ });
2547
+
2548
+ //#endregion
2549
+ //#region src/node/rpc/public/open-in-finder.ts
2550
+ const openInFinder = defineRpcFunction({
2551
+ name: "vite:core:open-in-finder",
2552
+ type: "action",
2553
+ setup: () => {
2554
+ return { handler: async (path) => {
2555
+ await import("open").then((r) => r.default(path));
2556
+ } };
2557
+ }
2558
+ });
2559
+
2560
+ //#endregion
2561
+ //#region src/node/rpc/index.ts
2562
+ const builtinPublicRpcDeclarations = [openInEditor, openInFinder];
2563
+ const builtinAnonymousRpcDeclarations = [anonymousAuth];
2564
+ const builtinInternalRpcDeclarations = [
2565
+ docksOnLaunch,
2566
+ rpcServerList,
2567
+ sharedStateGet,
2568
+ sharedStatePatch,
2569
+ sharedStateSet,
2570
+ sharedStateSubscribe,
2571
+ terminalsList,
2572
+ terminalsRead
2573
+ ];
2574
+ const builtinRpcDeclarations = [
2575
+ ...builtinPublicRpcDeclarations,
2576
+ ...builtinAnonymousRpcDeclarations,
2577
+ ...builtinInternalRpcDeclarations
2578
+ ];
2579
+
2580
+ //#endregion
2581
+ //#region src/node/context.ts
2582
+ const debugSetup = createDebug("vite:devtools:context:setup");
2583
+ async function createDevToolsContext(viteConfig, viteServer) {
2584
+ const cwd = viteConfig.root;
2585
+ const context = {
2586
+ cwd,
2587
+ workspaceRoot: searchForWorkspaceRoot(cwd) ?? cwd,
2588
+ viteConfig,
2589
+ viteServer,
2590
+ mode: viteConfig.command === "serve" ? "dev" : "build",
2591
+ rpc: void 0,
2592
+ docks: void 0,
2593
+ views: void 0,
2594
+ utils: ContextUtils,
2595
+ terminals: void 0
2596
+ };
2597
+ const rpcHost = new RpcFunctionsHost(context);
2598
+ const docksHost = new DevToolsDockHost(context);
2599
+ const viewsHost = new DevToolsViewHost(context);
2600
+ const terminalsHost = new DevToolsTerminalHost(context);
2601
+ context.rpc = rpcHost;
2602
+ context.docks = docksHost;
2603
+ context.views = viewsHost;
2604
+ context.terminals = terminalsHost;
2605
+ for (const fn of builtinRpcDeclarations) rpcHost.register(fn);
2606
+ await docksHost.init();
2607
+ const docksSharedState = await rpcHost.sharedState.get("devtoolskit:internal:docks", { initialValue: [] });
2608
+ docksHost.events.on("dock:entry:updated", debounce(() => {
2609
+ docksSharedState.mutate(() => context.docks.values());
2610
+ }, 10));
2611
+ terminalsHost.events.on("terminal:session:updated", debounce(() => {
2612
+ rpcHost.broadcast({
2613
+ method: "devtoolskit:internal:terminals:updated",
2614
+ args: []
2615
+ });
2616
+ docksSharedState.mutate(() => context.docks.values());
2617
+ }, 10));
2618
+ terminalsHost.events.on("terminal:session:stream-chunk", (data) => {
2619
+ rpcHost.broadcast({
2620
+ method: "devtoolskit:internal:terminals:stream-chunk",
2621
+ args: [data]
2622
+ });
2623
+ });
2624
+ const plugins = viteConfig.plugins.filter((plugin) => "devtools" in plugin);
2625
+ for (const plugin of plugins) {
2626
+ if (!plugin.devtools?.setup) continue;
2627
+ try {
2628
+ debugSetup(`setting up plugin ${JSON.stringify(plugin.name)}`);
2629
+ await plugin.devtools?.setup?.(context);
2630
+ } catch (error) {
2631
+ console.error(`[Vite DevTools] Error setting up plugin ${plugin.name}:`, error);
2632
+ throw error;
2633
+ }
2634
+ }
2635
+ return context;
2636
+ }
2637
+
2638
+ //#endregion
2639
+ //#region src/node/plugins/injection.ts
2640
+ function DevToolsInjection() {
2641
+ return {
2642
+ name: "vite:devtools:injection",
2643
+ enforce: "post",
2644
+ transformIndexHtml() {
2645
+ return [{
2646
+ tag: "script",
2647
+ attrs: {
2648
+ src: `/@fs/${process$1.env.VITE_DEVTOOLS_LOCAL_DEV ? normalizePath(join$1(dirDist, "..", "src/client/inject/index.ts")) : normalizePath(join$1(dirDist, "client/inject.js"))}`,
2649
+ type: "module"
2650
+ },
2651
+ injectTo: "body"
2652
+ }];
2653
+ }
2654
+ };
2655
+ }
2656
+
2657
+ //#endregion
2658
+ //#region ../../node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs
2659
+ const unsafePorts = /* @__PURE__ */ new Set([
2660
+ 1,
2661
+ 7,
2662
+ 9,
2663
+ 11,
2664
+ 13,
2665
+ 15,
2666
+ 17,
2667
+ 19,
2668
+ 20,
2669
+ 21,
2670
+ 22,
2671
+ 23,
2672
+ 25,
2673
+ 37,
2674
+ 42,
2675
+ 43,
2676
+ 53,
2677
+ 69,
2678
+ 77,
2679
+ 79,
2680
+ 87,
2681
+ 95,
2682
+ 101,
2683
+ 102,
2684
+ 103,
2685
+ 104,
2686
+ 109,
2687
+ 110,
2688
+ 111,
2689
+ 113,
2690
+ 115,
2691
+ 117,
2692
+ 119,
2693
+ 123,
2694
+ 135,
2695
+ 137,
2696
+ 139,
2697
+ 143,
2698
+ 161,
2699
+ 179,
2700
+ 389,
2701
+ 427,
2702
+ 465,
2703
+ 512,
2704
+ 513,
2705
+ 514,
2706
+ 515,
2707
+ 526,
2708
+ 530,
2709
+ 531,
2710
+ 532,
2711
+ 540,
2712
+ 548,
2713
+ 554,
2714
+ 556,
2715
+ 563,
2716
+ 587,
2717
+ 601,
2718
+ 636,
2719
+ 989,
2720
+ 990,
2721
+ 993,
2722
+ 995,
2723
+ 1719,
2724
+ 1720,
2725
+ 1723,
2726
+ 2049,
2727
+ 3659,
2728
+ 4045,
2729
+ 5060,
2730
+ 5061,
2731
+ 6e3,
2732
+ 6566,
2733
+ 6665,
2734
+ 6666,
2735
+ 6667,
2736
+ 6668,
2737
+ 6669,
2738
+ 6697,
2739
+ 10080
2740
+ ]);
2741
+ function isUnsafePort(port) {
2742
+ return unsafePorts.has(port);
2743
+ }
2744
+ function isSafePort(port) {
2745
+ return !isUnsafePort(port);
2746
+ }
2747
+ var GetPortError = class extends Error {
2748
+ constructor(message, opts) {
2749
+ super(message, opts);
2750
+ this.message = message;
2751
+ }
2752
+ name = "GetPortError";
2753
+ };
2754
+ function _log(verbose, message) {
2755
+ if (verbose) console.log(`[get-port] ${message}`);
2756
+ }
2757
+ function _generateRange(from, to) {
2758
+ if (to < from) return [];
2759
+ const r = [];
2760
+ for (let index = from; index <= to; index++) r.push(index);
2761
+ return r;
2762
+ }
2763
+ function _tryPort(port, host) {
2764
+ return new Promise((resolve) => {
2765
+ const server = createServer();
2766
+ server.unref();
2767
+ server.on("error", () => {
2768
+ resolve(false);
2769
+ });
2770
+ server.listen({
2771
+ port,
2772
+ host
2773
+ }, () => {
2774
+ const { port: port2 } = server.address();
2775
+ server.close(() => {
2776
+ resolve(isSafePort(port2) && port2);
2777
+ });
2778
+ });
2779
+ });
2780
+ }
2781
+ function _getLocalHosts(additional) {
2782
+ const hosts = new Set(additional);
2783
+ for (const _interface of Object.values(networkInterfaces())) for (const config of _interface || []) if (config.address && !config.internal && !config.address.startsWith("fe80::") && !config.address.startsWith("169.254")) hosts.add(config.address);
2784
+ return [...hosts];
2785
+ }
2786
+ async function _findPort(ports, host) {
2787
+ for (const port of ports) {
2788
+ const r = await _tryPort(port, host);
2789
+ if (r) return r;
2790
+ }
2791
+ }
2792
+ function _fmtOnHost(hostname) {
2793
+ return hostname ? `on host ${JSON.stringify(hostname)}` : "on any host";
2794
+ }
2795
+ const HOSTNAME_RE = /^(?!-)[\d.:A-Za-z-]{1,63}(?<!-)$/;
2796
+ function _validateHostname(hostname, _public, verbose) {
2797
+ if (hostname && !HOSTNAME_RE.test(hostname)) {
2798
+ const fallbackHost = _public ? "0.0.0.0" : "127.0.0.1";
2799
+ _log(verbose, `Invalid hostname: ${JSON.stringify(hostname)}. Using ${JSON.stringify(fallbackHost)} as fallback.`);
2800
+ return fallbackHost;
2801
+ }
2802
+ return hostname;
2803
+ }
2804
+ async function getPort(_userOptions = {}) {
2805
+ if (typeof _userOptions === "number" || typeof _userOptions === "string") _userOptions = { port: Number.parseInt(_userOptions + "") || 0 };
2806
+ const _port = Number(_userOptions.port ?? process.env.PORT);
2807
+ const _userSpecifiedAnyPort = Boolean(_userOptions.port || _userOptions.ports?.length || _userOptions.portRange?.length);
2808
+ const options = {
2809
+ random: _port === 0,
2810
+ ports: [],
2811
+ portRange: [],
2812
+ alternativePortRange: _userSpecifiedAnyPort ? [] : [3e3, 3100],
2813
+ verbose: false,
2814
+ ..._userOptions,
2815
+ port: _port,
2816
+ host: _validateHostname(_userOptions.host ?? process.env.HOST, _userOptions.public, _userOptions.verbose)
2817
+ };
2818
+ if (options.random && !_userSpecifiedAnyPort) return getRandomPort(options.host);
2819
+ const portsToCheck = [
2820
+ options.port,
2821
+ ...options.ports,
2822
+ ..._generateRange(...options.portRange)
2823
+ ].filter((port) => {
2824
+ if (!port) return false;
2825
+ if (!isSafePort(port)) {
2826
+ _log(options.verbose, `Ignoring unsafe port: ${port}`);
2827
+ return false;
2828
+ }
2829
+ return true;
2830
+ });
2831
+ if (portsToCheck.length === 0) portsToCheck.push(3e3);
2832
+ let availablePort = await _findPort(portsToCheck, options.host);
2833
+ if (!availablePort && options.alternativePortRange.length > 0) {
2834
+ availablePort = await _findPort(_generateRange(...options.alternativePortRange), options.host);
2835
+ if (portsToCheck.length > 0) {
2836
+ let message = `Unable to find an available port (tried ${portsToCheck.join("-")} ${_fmtOnHost(options.host)}).`;
2837
+ if (availablePort) message += ` Using alternative port ${availablePort}.`;
2838
+ _log(options.verbose, message);
2839
+ }
2840
+ }
2841
+ if (!availablePort && _userOptions.random !== false) {
2842
+ availablePort = await getRandomPort(options.host);
2843
+ if (availablePort) _log(options.verbose, `Using random port ${availablePort}`);
2844
+ }
2845
+ if (!availablePort) {
2846
+ const triedRanges = [
2847
+ options.port,
2848
+ options.portRange.join("-"),
2849
+ options.alternativePortRange.join("-")
2850
+ ].filter(Boolean).join(", ");
2851
+ throw new GetPortError(`Unable to find an available port ${_fmtOnHost(options.host)} (tried ${triedRanges})`);
2852
+ }
2853
+ return availablePort;
2854
+ }
2855
+ async function getRandomPort(host) {
2856
+ const port = await checkPort(0, host);
2857
+ if (port === false) throw new GetPortError(`Unable to find a random port ${_fmtOnHost(host)}`);
2858
+ return port;
2859
+ }
2860
+ async function checkPort(port, host = process.env.HOST, verbose) {
2861
+ if (!host) host = _getLocalHosts([void 0, "0.0.0.0"]);
2862
+ if (!Array.isArray(host)) return _tryPort(port, host);
2863
+ for (const _host of host) {
2864
+ const _port = await _tryPort(port, _host);
2865
+ if (_port === false) {
2866
+ if (port < 1024 && verbose) _log(verbose, `Unable to listen to the privileged port ${port} ${_fmtOnHost(_host)}`);
2867
+ return false;
2868
+ }
2869
+ if (port === 0 && _port !== 0) port = _port;
2870
+ }
2871
+ return port;
2872
+ }
2873
+
2874
+ //#endregion
2875
+ //#region src/node/constants.ts
2876
+ const MARK_CHECK = ansis_default.green("✔");
2877
+ const MARK_INFO = ansis_default.blue("ℹ");
2878
+ const MARK_ERROR = ansis_default.red("✖");
2879
+ const MARK_NODE = "⬢";
2880
+
2881
+ //#endregion
2882
+ //#region src/node/ws.ts
2883
+ const debugInvoked = createDebug("vite:devtools:rpc:invoked");
2884
+ const ANONYMOUS_SCOPE = "vite:anonymous:";
2885
+ async function createWsServer(options) {
2886
+ const rpcHost = options.context.rpc;
2887
+ const port = options.portWebSocket ?? await getPort({
2888
+ port: 7812,
2889
+ random: true
2890
+ });
2891
+ const host = options.hostWebSocket ?? "localhost";
2892
+ const wsClients = /* @__PURE__ */ new Set();
2893
+ const context = options.context;
2894
+ const contextInternal = getInternalContext(context);
2895
+ const isClientAuthDisabled = context.mode === "build" || context.viteConfig.devtools?.clientAuth === false || process$1.env.VITE_DEVTOOLS_DISABLE_CLIENT_AUTH === "true";
2896
+ if (isClientAuthDisabled) console.warn("[Vite DevTools] Client authentication is disabled. Any browser can connect to the devtools and access to your server and filesystem.");
2897
+ const preset = createWsRpcPreset({
2898
+ port,
2899
+ host,
2900
+ onConnected: (ws, req, meta) => {
2901
+ const authId = new URL(req.url ?? "", "http://localhost").searchParams.get("vite_devtools_auth_id") ?? void 0;
2902
+ if (isClientAuthDisabled) meta.isTrusted = true;
2903
+ else if (authId && contextInternal.storage.auth.value().trusted[authId]) {
2904
+ meta.isTrusted = true;
2905
+ meta.clientAuthId = authId;
2906
+ }
2907
+ wsClients.add(ws);
2908
+ const color = meta.isTrusted ? ansis_default.green : ansis_default.yellow;
2909
+ console.log(color`${MARK_INFO} Websocket client connected. [${meta.id}] [${meta.clientAuthId}] (${meta.isTrusted ? "trusted" : "untrusted"})`);
2910
+ },
2911
+ onDisconnected: (ws, meta) => {
2912
+ wsClients.delete(ws);
2913
+ console.log(ansis_default.red`${MARK_INFO} Websocket client disconnected. [${meta.id}]`);
2914
+ }
2915
+ });
2916
+ const asyncStorage = new AsyncLocalStorage();
2917
+ const rpcGroup = createRpcServer(rpcHost.functions, {
2918
+ preset,
2919
+ rpcOptions: {
2920
+ onFunctionError(error, name) {
2921
+ console.error(ansis_default.red`⬢ RPC error on executing "${ansis_default.bold(name)}":`);
2922
+ console.error(error);
2923
+ },
2924
+ onGeneralError(error) {
2925
+ console.error(ansis_default.red`⬢ RPC error on executing rpc`);
2926
+ console.error(error);
2927
+ },
2928
+ resolver(name, fn) {
2929
+ const rpc = this;
2930
+ if (!name.startsWith(ANONYMOUS_SCOPE) && !rpc.$meta.isTrusted) return () => {
2931
+ throw new Error(`Unauthorized access to method ${JSON.stringify(name)} from client [${rpc.$meta.id}]`);
2932
+ };
2933
+ if (!fn) return void 0;
2934
+ return async function(...args) {
2935
+ debugInvoked(`${JSON.stringify(name)} from #${rpc.$meta.id}`);
2936
+ return await asyncStorage.run({
2937
+ rpc,
2938
+ meta: rpc.$meta
2939
+ }, async () => {
2940
+ return (await fn).apply(this, args);
2941
+ });
2942
+ };
2943
+ }
2944
+ }
2945
+ });
2946
+ rpcHost._rpcGroup = rpcGroup;
2947
+ rpcHost._asyncStorage = asyncStorage;
2948
+ const getConnectionMeta = async () => {
2949
+ return {
2950
+ backend: "websocket",
2951
+ websocket: port
2952
+ };
2953
+ };
2954
+ return {
2955
+ port,
2956
+ rpc: rpcGroup,
2957
+ rpcHost,
2958
+ getConnectionMeta
2959
+ };
2960
+ }
2961
+
2962
+ //#endregion
2963
+ //#region src/node/server.ts
2964
+ async function createDevToolsMiddleware(options) {
2965
+ const h3 = createApp();
2966
+ const { rpc, getConnectionMeta } = await createWsServer(options);
2967
+ h3.use("/.vdt-connection.json", eventHandler(async (event) => {
2968
+ event.node.res.setHeader("Content-Type", "application/json");
2969
+ return event.node.res.end(JSON.stringify(await getConnectionMeta()));
2970
+ }));
2971
+ h3.use(fromNodeMiddleware(sirv(dirClientStandalone, {
2972
+ dev: true,
2973
+ single: true
2974
+ })));
2975
+ return {
2976
+ h3,
2977
+ rpc,
2978
+ middleware: toNodeListener(h3),
2979
+ getConnectionMeta
2980
+ };
2981
+ }
2982
+
2983
+ //#endregion
2984
+ //#region src/node/plugins/server.ts
2985
+ /**
2986
+ * Core plugin for enabling Vite DevTools
2987
+ */
2988
+ function DevToolsServer() {
2989
+ let context;
2990
+ return {
2991
+ name: "vite:devtools:server",
2992
+ enforce: "post",
2993
+ apply: "serve",
2994
+ async configureServer(viteDevServer) {
2995
+ context = await createDevToolsContext(viteDevServer.config, viteDevServer);
2996
+ const host = viteDevServer.config.server.host === true ? "0.0.0.0" : viteDevServer.config.server.host || "localhost";
2997
+ const { middleware } = await createDevToolsMiddleware({
2998
+ cwd: viteDevServer.config.root,
2999
+ hostWebSocket: host,
3000
+ context
3001
+ });
3002
+ viteDevServer.middlewares.use("/.devtools/", middleware);
3003
+ },
3004
+ resolveId(id) {
3005
+ if (id === "/.devtools-imports") return id;
3006
+ },
3007
+ load(id) {
3008
+ if (id === "/.devtools-imports") {
3009
+ if (!context) throw new Error("DevTools context is not initialized");
3010
+ const docks = Array.from(context.docks.values());
3011
+ const map = /* @__PURE__ */ new Map();
3012
+ for (const dock of docks) {
3013
+ const id = `${dock.type}:${dock.id}`;
3014
+ if (dock.type === "action") map.set(id, dock.action);
3015
+ else if (dock.type === "custom-render") map.set(id, dock.renderer);
3016
+ else if (dock.type === "iframe" && dock.clientScript) map.set(id, dock.clientScript);
3017
+ }
3018
+ return [
3019
+ `export const importsMap = {`,
3020
+ ...[...map.entries()].filter(([, entry]) => entry != null).map(([id, { importFrom, importName }]) => ` [${JSON.stringify(id)}]: () => import(${JSON.stringify(importFrom)}).then(r => r[${JSON.stringify(importName)}]),`),
3021
+ "}"
3022
+ ].join("\n");
3023
+ }
3024
+ }
3025
+ };
3026
+ }
3027
+
3028
+ //#endregion
3029
+ //#region src/node/plugins/index.ts
3030
+ async function DevTools(options = {}) {
3031
+ const { builtinDevTools = true } = options;
3032
+ const plugins = [DevToolsInjection(), DevToolsServer()];
3033
+ if (builtinDevTools) plugins.push(await import("@vitejs/devtools-rolldown").then((m) => m.DevToolsRolldownUI()));
3034
+ return plugins;
3035
+ }
3036
+
3037
+ //#endregion
3038
+ export { createDevToolsContext as a, getPort as i, createDevToolsMiddleware as n, ansis_default as o, MARK_NODE as r, DevTools as t };