@vitejs/devtools 0.0.0-alpha.32 → 0.0.0-alpha.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/{DockIcon-DC06YRV1.js → DockIcon-LqhTiyo7.js} +11 -14
  2. package/dist/DockStandalone-D15T7P8h.js +82 -0
  3. package/dist/FloatingElements-DiZY-fXn.js +988 -0
  4. package/dist/{ViewBuiltinLogs-BpU8wNYx.js → ViewBuiltinLogs-DAC3EpNy.js} +3 -5
  5. package/dist/{ViewBuiltinTerminals-1w0Jz6t0.js → ViewBuiltinTerminals-CaCzY10v.js} +5 -11
  6. package/dist/cli-commands-B8AbW52w.js +178 -0
  7. package/dist/cli-commands.js +3 -67
  8. package/dist/cli.js +3 -5
  9. package/dist/client/inject.js +40 -19
  10. package/dist/client/standalone/assets/DockStandalone-Be2ebLC6.js +8 -0
  11. package/dist/client/standalone/assets/ViewBuiltinLogs-gqCacjSC.js +1 -0
  12. package/dist/client/standalone/assets/{ViewBuiltinTerminals-BfkQ4Bsj.js → ViewBuiltinTerminals-EMrVQ_he.js} +2 -2
  13. package/dist/client/standalone/assets/_plugin-vue_export-helper-DdUndd8v.js +1 -0
  14. package/dist/client/standalone/assets/index-CkMgpkZF.css +1 -0
  15. package/dist/client/standalone/assets/index-xigFHEkA.js +4 -0
  16. package/dist/client/standalone/index.html +3 -2
  17. package/dist/client/webcomponents.d.ts +20329 -145
  18. package/dist/client/webcomponents.js +79 -985
  19. package/dist/config.js +2 -8
  20. package/dist/dirs.js +1 -3
  21. package/dist/{dist-B1eLoAag.js → dist-CnHQWaMb.js} +11 -50
  22. package/dist/{export-helper-DjM8b2QE.js → export-helper-DOmNQzh6.js} +1 -2
  23. package/dist/index.d.ts +5 -5
  24. package/dist/index.js +2 -3
  25. package/dist/plugins-tIIgS7bh.js +1911 -0
  26. package/dist/popup-CqYAUdYG.js +366 -0
  27. package/dist/utils--qjmgani.js +6 -0
  28. package/dist/{vue.runtime.esm-bundler-CHmRsJSH.js → vue.runtime.esm-bundler-Bou7Nbd4.js} +135 -115
  29. package/package.json +34 -16
  30. package/dist/client/standalone/assets/ViewBuiltinLogs-D_1j1vpl.js +0 -1
  31. package/dist/client/standalone/assets/index-DWcF5wcd.js +0 -2
  32. package/dist/client/standalone/assets/index-DzhHPm4X.css +0 -1
  33. package/dist/docks-BVWse3rL.js +0 -131
  34. package/dist/plugins-CM-4geJK.js +0 -3040
  35. package/dist/standalone-CfUW6ZhV.js +0 -34
@@ -0,0 +1,1911 @@
1
+ import { t as isObject } from "./utils--qjmgani.js";
2
+ import { dirClientStandalone, dirDist } from "./dirs.js";
3
+ import { createDebug } from "obug";
4
+ import { debounce } from "perfect-debounce";
5
+ import { normalizePath, searchForWorkspaceRoot } from "vite";
6
+ import { toDataURL } from "mlly";
7
+ import { DEFAULT_STATE_USER_SETTINGS, DEVTOOLS_CONNECTION_META_FILENAME, DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID, DEVTOOLS_MOUNT_PATH } from "@vitejs/devtools-kit/constants";
8
+ import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
9
+ import { dirname, join } from "pathe";
10
+ import fs, { existsSync } from "node:fs";
11
+ import { createSharedState } from "@vitejs/devtools-kit/utils/shared-state";
12
+ import { RpcFunctionsCollectorBase } from "@vitejs/devtools-rpc";
13
+ import process$1, { stdin, stdout } from "node:process";
14
+ import sirv from "sirv";
15
+ import { stripVTControlCharacters, styleText } from "node:util";
16
+ import "node:readline";
17
+ import ot from "node:readline";
18
+ import "node:tty";
19
+ import { join as join$1 } from "node:path";
20
+ import { defineRpcFunction } from "@vitejs/devtools-kit";
21
+ import { createApp, eventHandler, fromNodeMiddleware, toNodeListener } from "h3";
22
+ import { AsyncLocalStorage } from "node:async_hooks";
23
+ import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/server";
24
+ import { createRpcServer } from "@vitejs/devtools-rpc/server";
25
+ import { createServer } from "node:net";
26
+ import { networkInterfaces } from "node:os";
27
+ import "node:fs/promises";
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") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
38
+ key = keys[i];
39
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
40
+ get: ((k) => from[k]).bind(null, key),
41
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
42
+ });
43
+ }
44
+ return to;
45
+ };
46
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
47
+ value: mod,
48
+ enumerable: true
49
+ }) : target, mod));
50
+ //#endregion
51
+ //#region src/node/context-utils.ts
52
+ const ContextUtils = { createSimpleClientScript(fn) {
53
+ return {
54
+ importFrom: toDataURL(`const fn = ${fn.toString()}; export default fn`),
55
+ importName: "default"
56
+ };
57
+ } };
58
+ //#endregion
59
+ //#region src/node/storage.ts
60
+ function createStorage(options) {
61
+ const { mergeInitialValue = (initialValue, savedValue) => ({
62
+ ...initialValue,
63
+ ...savedValue
64
+ }), debounce: debounceTime = 100 } = options;
65
+ let initialValue = options.initialValue;
66
+ if (fs.existsSync(options.filepath)) try {
67
+ const savedValue = JSON.parse(fs.readFileSync(options.filepath, "utf-8"));
68
+ initialValue = mergeInitialValue ? mergeInitialValue(options.initialValue, savedValue) : savedValue;
69
+ } catch (error) {
70
+ console.warn(`[Vite DevTools] Failed to parse storage file: ${options.filepath}, falling back to defaults.`);
71
+ console.warn(error);
72
+ initialValue = options.initialValue;
73
+ }
74
+ const state = createSharedState({
75
+ initialValue,
76
+ enablePatches: false
77
+ });
78
+ state.on("updated", debounce((newState) => {
79
+ fs.mkdirSync(dirname(options.filepath), { recursive: true });
80
+ fs.writeFileSync(options.filepath, `${JSON.stringify(newState, null, 2)}\n`);
81
+ }, debounceTime));
82
+ return state;
83
+ }
84
+ //#endregion
85
+ //#region src/node/host-docks.ts
86
+ var DevToolsDockHost = class {
87
+ views = /* @__PURE__ */ new Map();
88
+ events = createEventEmitter();
89
+ userSettings = void 0;
90
+ constructor(context) {
91
+ this.context = context;
92
+ }
93
+ async init() {
94
+ this.userSettings = await this.context.rpc.sharedState.get("devtoolskit:internal:user-settings", { sharedState: createStorage({
95
+ filepath: join(this.context.workspaceRoot, "node_modules/.vite/devtools/settings.json"),
96
+ initialValue: DEFAULT_STATE_USER_SETTINGS()
97
+ }) });
98
+ }
99
+ values({ includeBuiltin = true } = {}) {
100
+ const context = this.context;
101
+ const builtinDocksEntries = [
102
+ {
103
+ type: "~builtin",
104
+ id: "~terminals",
105
+ title: "Terminals",
106
+ icon: "ph:terminal-duotone",
107
+ category: "~builtin",
108
+ get isHidden() {
109
+ return context.terminals.sessions.size === 0;
110
+ }
111
+ },
112
+ {
113
+ type: "~builtin",
114
+ id: "~logs",
115
+ title: "Logs",
116
+ icon: "ph:notification-duotone",
117
+ category: "~builtin",
118
+ isHidden: true
119
+ },
120
+ {
121
+ type: "~builtin",
122
+ id: "~popup",
123
+ title: "Popup",
124
+ category: "~builtin",
125
+ icon: "ph:arrow-square-out-duotone"
126
+ },
127
+ {
128
+ type: "~builtin",
129
+ id: "~settings",
130
+ title: "Settings",
131
+ category: "~builtin",
132
+ icon: "ph:gear-duotone"
133
+ }
134
+ ];
135
+ return [...Array.from(this.views.values()), ...includeBuiltin ? builtinDocksEntries : []];
136
+ }
137
+ register(view, force) {
138
+ if (this.views.has(view.id) && !force) throw new Error(`Dock with id "${view.id}" is already registered`);
139
+ this.views.set(view.id, view);
140
+ this.events.emit("dock:entry:updated", view);
141
+ return { update: (patch) => {
142
+ if (patch.id && patch.id !== view.id) throw new Error(`Cannot change the id of a dock. Use register() to add new docks.`);
143
+ this.update(Object.assign(this.views.get(view.id), patch));
144
+ } };
145
+ }
146
+ update(view) {
147
+ if (!this.views.has(view.id)) throw new Error(`Dock with id "${view.id}" is not registered. Use register() to add new docks.`);
148
+ this.views.set(view.id, view);
149
+ this.events.emit("dock:entry:updated", view);
150
+ }
151
+ };
152
+ //#endregion
153
+ //#region src/node/rpc-shared-state.ts
154
+ const debug$1 = createDebug("vite:devtools:rpc:state:changed");
155
+ function createRpcSharedStateServerHost(rpc) {
156
+ const sharedState = /* @__PURE__ */ new Map();
157
+ function registerSharedState(key, state) {
158
+ const offs = [];
159
+ offs.push(state.on("updated", (fullState, patches, syncId) => {
160
+ if (patches) {
161
+ debug$1("patch", {
162
+ key,
163
+ syncId
164
+ });
165
+ rpc.broadcast({
166
+ method: "devtoolskit:internal:rpc:client-state:patch",
167
+ args: [
168
+ key,
169
+ patches,
170
+ syncId
171
+ ],
172
+ filter: (client) => client.$meta.subscribedStates.has(key)
173
+ });
174
+ } else {
175
+ debug$1("updated", {
176
+ key,
177
+ syncId
178
+ });
179
+ rpc.broadcast({
180
+ method: "devtoolskit:internal:rpc:client-state:updated",
181
+ args: [
182
+ key,
183
+ fullState,
184
+ syncId
185
+ ],
186
+ filter: (client) => client.$meta.subscribedStates.has(key)
187
+ });
188
+ }
189
+ }));
190
+ return () => {
191
+ for (const off of offs) off();
192
+ };
193
+ }
194
+ return {
195
+ get: async (key, options) => {
196
+ if (sharedState.has(key)) return sharedState.get(key);
197
+ 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`);
198
+ debug$1("new-state", key);
199
+ const state = options.sharedState ?? createSharedState({
200
+ initialValue: options.initialValue,
201
+ enablePatches: false
202
+ });
203
+ registerSharedState(key, state);
204
+ sharedState.set(key, state);
205
+ return state;
206
+ },
207
+ keys() {
208
+ return Array.from(sharedState.keys());
209
+ }
210
+ };
211
+ }
212
+ //#endregion
213
+ //#region src/node/host-functions.ts
214
+ const debugBroadcast = createDebug("vite:devtools:rpc:broadcast");
215
+ var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
216
+ /**
217
+ * @internal
218
+ */
219
+ _rpcGroup = void 0;
220
+ _asyncStorage = void 0;
221
+ constructor(context) {
222
+ super(context);
223
+ this.sharedState = createRpcSharedStateServerHost(this);
224
+ }
225
+ sharedState;
226
+ async invokeLocal(method, ...args) {
227
+ if (!this.definitions.has(method)) throw new Error(`RPC function "${String(method)}" is not registered`);
228
+ const handler = await this.getHandler(method);
229
+ return await Promise.resolve(handler(...args));
230
+ }
231
+ async broadcast(options) {
232
+ if (!this._rpcGroup) {
233
+ if (this.context.mode === "build") return;
234
+ throw new Error("RpcFunctionsHost] RpcGroup is not set, it likely to be an internal bug of Vite DevTools");
235
+ }
236
+ debugBroadcast(JSON.stringify(options.method));
237
+ await Promise.all(this._rpcGroup.clients.map((client) => {
238
+ if (options.filter?.(client) === false) return void 0;
239
+ return client.$callRaw({
240
+ optional: true,
241
+ event: true,
242
+ ...options
243
+ });
244
+ }));
245
+ }
246
+ getCurrentRpcSession() {
247
+ if (!this._asyncStorage) throw new Error("RpcFunctionsHost] AsyncLocalStorage is not set, it likely to be an internal bug of Vite DevTools");
248
+ return this._asyncStorage.getStore();
249
+ }
250
+ };
251
+ //#endregion
252
+ //#region src/node/host-terminals.ts
253
+ var DevToolsTerminalHost = class {
254
+ sessions = /* @__PURE__ */ new Map();
255
+ events = createEventEmitter();
256
+ _boundStreams = /* @__PURE__ */ new Map();
257
+ constructor(context) {
258
+ this.context = context;
259
+ }
260
+ register(session) {
261
+ if (this.sessions.has(session.id)) throw new Error(`Terminal session with id "${session.id}" already registered`);
262
+ this.sessions.set(session.id, session);
263
+ this.bindStream(session);
264
+ this.events.emit("terminal:session:updated", session);
265
+ return session;
266
+ }
267
+ update(patch) {
268
+ if (!this.sessions.has(patch.id)) throw new Error(`Terminal session with id "${patch.id}" not registered`);
269
+ const session = this.sessions.get(patch.id);
270
+ Object.assign(session, patch);
271
+ this.sessions.set(patch.id, session);
272
+ this.bindStream(session);
273
+ this.events.emit("terminal:session:updated", session);
274
+ }
275
+ remove(session) {
276
+ this._boundStreams.get(session.id)?.dispose();
277
+ this.sessions.delete(session.id);
278
+ this.events.emit("terminal:session:updated", session);
279
+ this._boundStreams.delete(session.id);
280
+ }
281
+ bindStream(session) {
282
+ if (this._boundStreams.has(session.id) && this._boundStreams.get(session.id)?.stream === session.stream) return;
283
+ this._boundStreams.get(session.id)?.dispose();
284
+ this._boundStreams.delete(session.id);
285
+ if (!session.stream) return;
286
+ session.buffer ||= [];
287
+ const events = this.events;
288
+ const writer = new WritableStream({ write(chunk) {
289
+ session.buffer.push(chunk);
290
+ events.emit("terminal:session:stream-chunk", {
291
+ id: session.id,
292
+ chunks: [chunk],
293
+ ts: Date.now()
294
+ });
295
+ } });
296
+ session.stream.pipeTo(writer);
297
+ this._boundStreams.set(session.id, {
298
+ dispose: () => {
299
+ writer.close();
300
+ },
301
+ stream: session.stream
302
+ });
303
+ }
304
+ async startChildProcess(executeOptions, terminal) {
305
+ if (this.sessions.has(terminal.id)) throw new Error(`Terminal session with id "${terminal.id}" already registered`);
306
+ const { exec } = await import("tinyexec");
307
+ let controller;
308
+ const stream = new ReadableStream({ start(_controller) {
309
+ controller = _controller;
310
+ } });
311
+ function createChildProcess() {
312
+ const cp = exec(executeOptions.command, executeOptions.args || [], { nodeOptions: {
313
+ env: {
314
+ COLORS: "true",
315
+ FORCE_COLOR: "true",
316
+ ...executeOptions.env || {}
317
+ },
318
+ cwd: executeOptions.cwd ?? process$1.cwd(),
319
+ stdio: "pipe"
320
+ } });
321
+ (async () => {
322
+ for await (const chunk of cp) controller?.enqueue(chunk);
323
+ })();
324
+ return cp;
325
+ }
326
+ let cp = createChildProcess();
327
+ const restart = async () => {
328
+ cp?.kill();
329
+ cp = createChildProcess();
330
+ };
331
+ const terminate = async () => {
332
+ cp?.kill();
333
+ cp = void 0;
334
+ };
335
+ const session = {
336
+ ...terminal,
337
+ status: "running",
338
+ stream,
339
+ type: "child-process",
340
+ executeOptions,
341
+ getChildProcess: () => cp?.process,
342
+ terminate,
343
+ restart
344
+ };
345
+ this.register(session);
346
+ return Promise.resolve(session);
347
+ }
348
+ };
349
+ //#endregion
350
+ //#region src/node/host-views.ts
351
+ var DevToolsViewHost = class {
352
+ /**
353
+ * @internal
354
+ */
355
+ buildStaticDirs = [];
356
+ constructor(context) {
357
+ this.context = context;
358
+ }
359
+ hostStatic(baseUrl, distDir) {
360
+ if (!existsSync(distDir)) throw new Error(`[Vite DevTools] distDir ${distDir} does not exist`);
361
+ this.buildStaticDirs.push({
362
+ baseUrl,
363
+ distDir
364
+ });
365
+ if (this.context.viteConfig.command === "serve") {
366
+ if (!this.context.viteServer) throw new Error("[Vite DevTools] viteServer is required in dev mode");
367
+ this.context.viteServer.middlewares.use(baseUrl, sirv(distDir, {
368
+ dev: true,
369
+ single: true
370
+ }));
371
+ }
372
+ }
373
+ };
374
+ //#endregion
375
+ //#region ../../node_modules/.pnpm/@clack+core@1.1.0/node_modules/@clack/core/dist/index.mjs
376
+ var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
377
+ const ESC = "\x1B";
378
+ const CSI = `${ESC}[`;
379
+ const beep = "\x07";
380
+ const cursor = {
381
+ to(x, y) {
382
+ if (!y) return `${CSI}${x + 1}G`;
383
+ return `${CSI}${y + 1};${x + 1}H`;
384
+ },
385
+ move(x, y) {
386
+ let ret = "";
387
+ if (x < 0) ret += `${CSI}${-x}D`;
388
+ else if (x > 0) ret += `${CSI}${x}C`;
389
+ if (y < 0) ret += `${CSI}${-y}A`;
390
+ else if (y > 0) ret += `${CSI}${y}B`;
391
+ return ret;
392
+ },
393
+ up: (count = 1) => `${CSI}${count}A`,
394
+ down: (count = 1) => `${CSI}${count}B`,
395
+ forward: (count = 1) => `${CSI}${count}C`,
396
+ backward: (count = 1) => `${CSI}${count}D`,
397
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
398
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
399
+ left: `${CSI}G`,
400
+ hide: `${CSI}?25l`,
401
+ show: `${CSI}?25h`,
402
+ save: `${ESC}7`,
403
+ restore: `${ESC}8`
404
+ };
405
+ module.exports = {
406
+ cursor,
407
+ scroll: {
408
+ up: (count = 1) => `${CSI}S`.repeat(count),
409
+ down: (count = 1) => `${CSI}T`.repeat(count)
410
+ },
411
+ erase: {
412
+ screen: `${CSI}2J`,
413
+ up: (count = 1) => `${CSI}1J`.repeat(count),
414
+ down: (count = 1) => `${CSI}J`.repeat(count),
415
+ line: `${CSI}2K`,
416
+ lineEnd: `${CSI}K`,
417
+ lineStart: `${CSI}1K`,
418
+ lines(count) {
419
+ let clear = "";
420
+ for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
421
+ if (count) clear += cursor.left;
422
+ return clear;
423
+ }
424
+ },
425
+ beep
426
+ };
427
+ })))();
428
+ function x$1(t, e, s) {
429
+ if (!s.some((u) => !u.disabled)) return t;
430
+ const i = t + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
431
+ return s[n].disabled ? x$1(n, e < 0 ? -1 : 1, s) : n;
432
+ }
433
+ 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 = (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, L = /\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, M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct = /\p{M}+/gu, ft$1 = {
434
+ limit: Infinity,
435
+ ellipsis: ""
436
+ }, X$1 = (t, e = {}, s = {}) => {
437
+ const i = e.limit ?? Infinity, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X$1(r, ft$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;
438
+ let h = 0, o = 0, p = t.length, v = 0, F = !1, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
439
+ t: for (;;) {
440
+ if (w > C || o >= p && o > h) {
441
+ const ut = t.slice(C, w) || t.slice(h, o);
442
+ v = 0;
443
+ for (const Y of ut.replaceAll(ct, "")) {
444
+ const $ = Y.codePointAt(0) || 0;
445
+ if (lt($) ? f = m : ht($) ? f = V : E !== A && at($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h) + v)), c + f > i) {
446
+ F = !0;
447
+ break t;
448
+ }
449
+ v += Y.length, c += f;
450
+ }
451
+ C = w = 0;
452
+ }
453
+ if (o >= p) break;
454
+ if (M.lastIndex = o, M.test(t)) {
455
+ if (v = M.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
456
+ F = !0;
457
+ break;
458
+ }
459
+ c += f, C = h, w = o, o = h = M.lastIndex;
460
+ continue;
461
+ }
462
+ if (O.lastIndex = o, O.test(t)) {
463
+ if (c + u > b && (d = Math.min(d, o)), c + u > i) {
464
+ F = !0;
465
+ break;
466
+ }
467
+ c += u, C = h, w = o, o = h = O.lastIndex;
468
+ continue;
469
+ }
470
+ if (y.lastIndex = o, y.test(t)) {
471
+ if (v = y.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
472
+ F = !0;
473
+ break;
474
+ }
475
+ c += f, C = h, w = o, o = h = y.lastIndex;
476
+ continue;
477
+ }
478
+ if (L.lastIndex = o, L.test(t)) {
479
+ if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
480
+ F = !0;
481
+ break;
482
+ }
483
+ c += f, C = h, w = o, o = h = L.lastIndex;
484
+ continue;
485
+ }
486
+ if (P.lastIndex = o, P.test(t)) {
487
+ if (c + g > b && (d = Math.min(d, o)), c + g > i) {
488
+ F = !0;
489
+ break;
490
+ }
491
+ c += g, C = h, w = o, o = h = P.lastIndex;
492
+ continue;
493
+ }
494
+ o += 1;
495
+ }
496
+ return {
497
+ width: F ? b : c,
498
+ index: F ? d : p,
499
+ truncated: F,
500
+ ellipsed: F && i >= n
501
+ };
502
+ }, pt$1 = {
503
+ limit: Infinity,
504
+ ellipsis: "",
505
+ ellipsisWidth: 0
506
+ }, S = (t, e = {}) => X$1(t, pt$1, e).width, T = "\x1B", Z = "›", Ft$1 = 39, j = "\x07", Q$1 = "[", dt = "]", tt = "m", U$1 = `${dt}8;;`, et = new RegExp(`(?:\\${Q$1}(?<code>\\d+)m|\\${U$1}(?<uri>.*)${j})`, "y"), mt$1 = (t) => {
507
+ if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
508
+ if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
509
+ if (t === 1 || t === 2) return 22;
510
+ if (t === 3) return 23;
511
+ if (t === 4) return 24;
512
+ if (t === 7) return 27;
513
+ if (t === 8) return 28;
514
+ if (t === 9) return 29;
515
+ if (t === 0) return 0;
516
+ }, st = (t) => `${T}${Q$1}${t}${tt}`, it = (t) => `${T}${U$1}${t}${j}`, gt$1 = (t) => t.map((e) => S(e)), G = (t, e, s) => {
517
+ const i = e[Symbol.iterator]();
518
+ let r = !1, n = !1, u = t.at(-1), a = u === void 0 ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
519
+ for (; !l.done;) {
520
+ const m = l.value, A = S(m);
521
+ a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === T || m === Z) && (r = !0, n = e.startsWith(U$1, 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;
522
+ }
523
+ u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
524
+ }, vt$1 = (t) => {
525
+ const e = t.split(" ");
526
+ let s = e.length;
527
+ for (; s > 0 && !(S(e[s - 1]) > 0);) s--;
528
+ return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
529
+ }, Et$1 = (t, e, s = {}) => {
530
+ if (s.trim !== !1 && t.trim() === "") return "";
531
+ let i = "", r, n;
532
+ const u = t.split(" "), a = gt$1(u);
533
+ let l = [""];
534
+ for (const [h, o] of u.entries()) {
535
+ s.trim !== !1 && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
536
+ let p = S(l.at(-1) ?? "");
537
+ if (h !== 0 && (p >= e && (s.wordWrap === !1 || s.trim === !1) && (l.push(""), p = 0), (p > 0 || s.trim === !1) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e) {
538
+ const v = e - p, F = 1 + Math.floor((a[h] - v - 1) / e);
539
+ Math.floor((a[h] - 1) / e) < F && l.push(""), G(l, o, e);
540
+ continue;
541
+ }
542
+ if (p + a[h] > e && p > 0 && a[h] > 0) {
543
+ if (s.wordWrap === !1 && p < e) {
544
+ G(l, o, e);
545
+ continue;
546
+ }
547
+ l.push("");
548
+ }
549
+ if (p + a[h] > e && s.wordWrap === !1) {
550
+ G(l, o, e);
551
+ continue;
552
+ }
553
+ l[l.length - 1] += o;
554
+ }
555
+ s.trim !== !1 && (l = l.map((h) => vt$1(h)));
556
+ const E = l.join(`
557
+ `), g = E[Symbol.iterator]();
558
+ let m = g.next(), A = g.next(), V = 0;
559
+ for (; !m.done;) {
560
+ const h = m.value, o = A.value;
561
+ if (i += h, h === T || h === Z) {
562
+ et.lastIndex = V + 1;
563
+ const F = et.exec(E)?.groups;
564
+ if (F?.code !== void 0) {
565
+ const d = Number.parseFloat(F.code);
566
+ r = d === Ft$1 ? void 0 : d;
567
+ } else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
568
+ }
569
+ const p = r ? mt$1(r) : void 0;
570
+ o === `
571
+ ` ? (n && (i += it("")), r && p && (i += st(p))) : h === `
572
+ ` && (r && p && (i += st(r)), n && (i += it(n))), V += h.length, m = A, A = g.next();
573
+ }
574
+ return i;
575
+ };
576
+ function K$1(t, e, s) {
577
+ return String(t).normalize().replaceAll(`\r
578
+ `, `
579
+ `).split(`
580
+ `).map((i) => Et$1(i, e, s)).join(`
581
+ `);
582
+ }
583
+ const _ = {
584
+ actions: new Set([
585
+ "up",
586
+ "down",
587
+ "left",
588
+ "right",
589
+ "space",
590
+ "enter",
591
+ "cancel"
592
+ ]),
593
+ aliases: new Map([
594
+ ["k", "up"],
595
+ ["j", "down"],
596
+ ["h", "left"],
597
+ ["l", "right"],
598
+ ["", "cancel"],
599
+ ["escape", "cancel"]
600
+ ]),
601
+ messages: {
602
+ cancel: "Canceled",
603
+ error: "Something went wrong"
604
+ },
605
+ withGuide: !0
606
+ };
607
+ function H$1(t, e) {
608
+ if (typeof t == "string") return _.aliases.get(t) === e;
609
+ for (const s of t) if (s !== void 0 && H$1(s, e)) return !0;
610
+ return !1;
611
+ }
612
+ function _t$1(t, e) {
613
+ if (t === e) return;
614
+ const s = t.split(`
615
+ `), i = e.split(`
616
+ `), r = Math.max(s.length, i.length), n = [];
617
+ for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
618
+ return {
619
+ lines: n,
620
+ numLinesBefore: s.length,
621
+ numLinesAfter: i.length,
622
+ numLines: r
623
+ };
624
+ }
625
+ globalThis.process.platform.startsWith("win");
626
+ const z$1 = Symbol("clack:cancel");
627
+ function W$1(t, e) {
628
+ const s = t;
629
+ s.isTTY && s.setRawMode(e);
630
+ }
631
+ 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;
632
+ var B = class {
633
+ input;
634
+ output;
635
+ _abortSignal;
636
+ rl;
637
+ opts;
638
+ _render;
639
+ _track = !1;
640
+ _prevFrame = "";
641
+ _subscribers = /* @__PURE__ */ new Map();
642
+ _cursor = 0;
643
+ state = "initial";
644
+ error = "";
645
+ value;
646
+ userInput = "";
647
+ constructor(e, s = !0) {
648
+ const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e;
649
+ 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;
650
+ }
651
+ unsubscribe() {
652
+ this._subscribers.clear();
653
+ }
654
+ setSubscriber(e, s) {
655
+ const i = this._subscribers.get(e) ?? [];
656
+ i.push(s), this._subscribers.set(e, i);
657
+ }
658
+ on(e, s) {
659
+ this.setSubscriber(e, { cb: s });
660
+ }
661
+ once(e, s) {
662
+ this.setSubscriber(e, {
663
+ cb: s,
664
+ once: !0
665
+ });
666
+ }
667
+ emit(e, ...s) {
668
+ const i = this._subscribers.get(e) ?? [], r = [];
669
+ for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
670
+ for (const n of r) n();
671
+ }
672
+ prompt() {
673
+ return new Promise((e) => {
674
+ if (this._abortSignal) {
675
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z$1);
676
+ this._abortSignal.addEventListener("abort", () => {
677
+ this.state = "cancel", this.close();
678
+ }, { once: !0 });
679
+ }
680
+ this.rl = ot.createInterface({
681
+ input: this.input,
682
+ tabSize: 2,
683
+ prompt: "",
684
+ escapeCodeTimeout: 50,
685
+ terminal: !0
686
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), W$1(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
687
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), W$1(this.input, !1), e(this.value);
688
+ }), this.once("cancel", () => {
689
+ this.output.write(import_src.cursor.show), this.output.off("resize", this.render), W$1(this.input, !1), e(z$1);
690
+ });
691
+ });
692
+ }
693
+ _isActionKey(e, s) {
694
+ return e === " ";
695
+ }
696
+ _setValue(e) {
697
+ this.value = e, this.emit("value", this.value);
698
+ }
699
+ _setUserInput(e, s) {
700
+ this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
701
+ }
702
+ _clearUserInput() {
703
+ this.rl?.write(null, {
704
+ ctrl: !0,
705
+ name: "u"
706
+ }), this._setUserInput("");
707
+ }
708
+ onKeypress(e, s) {
709
+ if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, {
710
+ ctrl: !0,
711
+ name: "h"
712
+ }), 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") {
713
+ if (this.opts.validate) {
714
+ const i = this.opts.validate(this.value);
715
+ i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
716
+ }
717
+ this.state !== "error" && (this.state = "submit");
718
+ }
719
+ H$1([
720
+ e,
721
+ s?.name,
722
+ s?.sequence
723
+ ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
724
+ }
725
+ close() {
726
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
727
+ `), W$1(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
728
+ }
729
+ restoreCursor() {
730
+ const e = K$1(this._prevFrame, process.stdout.columns, {
731
+ hard: !0,
732
+ trim: !1
733
+ }).split(`
734
+ `).length - 1;
735
+ this.output.write(import_src.cursor.move(-999, e * -1));
736
+ }
737
+ render() {
738
+ const e = K$1(this._render(this) ?? "", process.stdout.columns, {
739
+ hard: !0,
740
+ trim: !1
741
+ });
742
+ if (e !== this._prevFrame) {
743
+ if (this.state === "initial") this.output.write(import_src.cursor.hide);
744
+ else {
745
+ const s = _t$1(this._prevFrame, e), i = nt(this.output);
746
+ if (this.restoreCursor(), s) {
747
+ const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
748
+ let u = s.lines.find((a) => a >= r);
749
+ if (u === void 0) {
750
+ this._prevFrame = e;
751
+ return;
752
+ }
753
+ if (s.lines.length === 1) {
754
+ this.output.write(import_src.cursor.move(0, u - n)), this.output.write(import_src.erase.lines(1));
755
+ const a = e.split(`
756
+ `);
757
+ this.output.write(a[u]), this._prevFrame = e, this.output.write(import_src.cursor.move(0, a.length - u - 1));
758
+ return;
759
+ } else if (s.lines.length > 1) {
760
+ if (r < n) u = r;
761
+ else {
762
+ const l = u - n;
763
+ l > 0 && this.output.write(import_src.cursor.move(0, l));
764
+ }
765
+ this.output.write(import_src.erase.down());
766
+ const a = e.split(`
767
+ `).slice(u);
768
+ this.output.write(a.join(`
769
+ `)), this._prevFrame = e;
770
+ return;
771
+ }
772
+ }
773
+ this.output.write(import_src.erase.down());
774
+ }
775
+ this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
776
+ }
777
+ }
778
+ };
779
+ var kt$1 = class extends B {
780
+ get cursor() {
781
+ return this.value ? 0 : 1;
782
+ }
783
+ get _value() {
784
+ return this.cursor === 0;
785
+ }
786
+ constructor(e) {
787
+ super(e, !1), this.value = !!e.initialValue, this.on("userInput", () => {
788
+ this.value = this._value;
789
+ }), this.on("confirm", (s) => {
790
+ this.output.write(import_src.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
791
+ }), this.on("cursor", () => {
792
+ this.value = !this.value;
793
+ });
794
+ }
795
+ };
796
+ //#endregion
797
+ //#region ../../node_modules/.pnpm/@clack+prompts@1.1.0/node_modules/@clack/prompts/dist/index.mjs
798
+ function pt() {
799
+ 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";
800
+ }
801
+ const ee = pt(), I = (e, r) => ee ? e : r, Re = I("◆", "*"), $e = I("■", "x"), de = I("▲", "x"), V = I("◇", "o");
802
+ I("┌", "T");
803
+ const h = I("│", "|"), x = I("└", "—");
804
+ I("┐", "T");
805
+ I("┘", "—");
806
+ const z = I("●", ">"), H = I("○", " ");
807
+ I("◻", "[•]");
808
+ I("◼", "[+]");
809
+ I("◻", "[ ]");
810
+ I("▪", "•");
811
+ const se = I("─", "-"), pe = I("╮", "+"), We = I("├", "+"), me = I("╯", "+"), ge = I("╰", "+");
812
+ I("╭", "+");
813
+ const fe = I("●", "•"), Fe = I("◆", "*"), ye = I("▲", "!"), Ee = I("■", "x"), W = (e) => {
814
+ switch (e) {
815
+ case "initial":
816
+ case "active": return styleText("cyan", Re);
817
+ case "cancel": return styleText("red", $e);
818
+ case "error": return styleText("yellow", de);
819
+ case "submit": return styleText("green", V);
820
+ }
821
+ }, 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, gt = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510, ft = (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, we = /[\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, yt = {
822
+ limit: Infinity,
823
+ ellipsis: ""
824
+ }, Le = (e, r = {}, s = {}) => {
825
+ const i = r.limit ?? Infinity, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? Le(a, yt, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, p = s.emojiWidth ?? 2, f = s.fullWidthWidth ?? 2, g = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
826
+ let $ = 0, m = 0, d = e.length, F = 0, y = !1, v = d, C = Math.max(0, i - o), A = 0, b = 0, w = 0, S = 0;
827
+ e: for (;;) {
828
+ if (b > A || m >= d && m > $) {
829
+ const T = e.slice(A, b) || e.slice($, m);
830
+ F = 0;
831
+ for (const M of T.replaceAll(Ft, "")) {
832
+ const O = M.codePointAt(0) || 0;
833
+ if (gt(O) ? S = f : ft(O) ? S = E : c !== g && mt(O) ? S = c : S = g, w + S > C && (v = Math.min(v, Math.max(A, $) + F)), w + S > i) {
834
+ y = !0;
835
+ break e;
836
+ }
837
+ F += M.length, w += S;
838
+ }
839
+ A = b = 0;
840
+ }
841
+ if (m >= d) break;
842
+ if (ne.lastIndex = m, ne.test(e)) {
843
+ if (F = ne.lastIndex - m, S = F * g, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / g))), w + S > i) {
844
+ y = !0;
845
+ break;
846
+ }
847
+ w += S, A = $, b = m, m = $ = ne.lastIndex;
848
+ continue;
849
+ }
850
+ if (we.lastIndex = m, we.test(e)) {
851
+ if (w + u > C && (v = Math.min(v, m)), w + u > i) {
852
+ y = !0;
853
+ break;
854
+ }
855
+ w += u, A = $, b = m, m = $ = we.lastIndex;
856
+ continue;
857
+ }
858
+ if (re.lastIndex = m, re.test(e)) {
859
+ if (F = re.lastIndex - m, S = F * l, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / l))), w + S > i) {
860
+ y = !0;
861
+ break;
862
+ }
863
+ w += S, A = $, b = m, m = $ = re.lastIndex;
864
+ continue;
865
+ }
866
+ if (ie.lastIndex = m, ie.test(e)) {
867
+ if (F = ie.lastIndex - m, S = F * n, w + S > C && (v = Math.min(v, m + Math.floor((C - w) / n))), w + S > i) {
868
+ y = !0;
869
+ break;
870
+ }
871
+ w += S, A = $, b = m, m = $ = ie.lastIndex;
872
+ continue;
873
+ }
874
+ if (Ae.lastIndex = m, Ae.test(e)) {
875
+ if (w + p > C && (v = Math.min(v, m)), w + p > i) {
876
+ y = !0;
877
+ break;
878
+ }
879
+ w += p, A = $, b = m, m = $ = Ae.lastIndex;
880
+ continue;
881
+ }
882
+ m += 1;
883
+ }
884
+ return {
885
+ width: y ? C : w,
886
+ index: y ? v : d,
887
+ truncated: y,
888
+ ellipsed: y && i >= o
889
+ };
890
+ }, Et = {
891
+ limit: Infinity,
892
+ ellipsis: "",
893
+ ellipsisWidth: 0
894
+ }, D = (e, r = {}) => Le(e, Et, r).width, ae = "\x1B", je = "›", vt = 39, Ce = "\x07", ke = "[", wt = "]", Ve = "m", Se = `${wt}8;;`, He = new RegExp(`(?:\\${ke}(?<code>\\d+)m|\\${Se}(?<uri>.*)${Ce})`, "y"), At = (e) => {
895
+ if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
896
+ if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
897
+ if (e === 1 || e === 2) return 22;
898
+ if (e === 3) return 23;
899
+ if (e === 4) return 24;
900
+ if (e === 7) return 27;
901
+ if (e === 8) return 28;
902
+ if (e === 9) return 29;
903
+ if (e === 0) return 0;
904
+ }, Ue = (e) => `${ae}${ke}${e}${Ve}`, Ke = (e) => `${ae}${Se}${e}${Ce}`, Ct = (e) => e.map((r) => D(r)), Ie = (e, r, s) => {
905
+ const i = r[Symbol.iterator]();
906
+ let a = !1, o = !1, u = e.at(-1), l = u === void 0 ? 0 : D(u), n = i.next(), c = i.next(), p = 0;
907
+ for (; !n.done;) {
908
+ const f = n.value, g = D(f);
909
+ l + g <= s ? e[e.length - 1] += f : (e.push(f), l = 0), (f === ae || f === je) && (a = !0, o = r.startsWith(Se, p + 1)), a ? o ? f === Ce && (a = !1, o = !1) : f === Ve && (a = !1) : (l += g, l === s && !c.done && (e.push(""), l = 0)), n = c, c = i.next(), p += f.length;
910
+ }
911
+ u = e.at(-1), !l && u !== void 0 && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
912
+ }, St = (e) => {
913
+ const r = e.split(" ");
914
+ let s = r.length;
915
+ for (; s > 0 && !(D(r[s - 1]) > 0);) s--;
916
+ return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
917
+ }, It = (e, r, s = {}) => {
918
+ if (s.trim !== !1 && e.trim() === "") return "";
919
+ let i = "", a, o;
920
+ const u = e.split(" "), l = Ct(u);
921
+ let n = [""];
922
+ for (const [$, m] of u.entries()) {
923
+ s.trim !== !1 && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
924
+ let d = D(n.at(-1) ?? "");
925
+ if ($ !== 0 && (d >= r && (s.wordWrap === !1 || s.trim === !1) && (n.push(""), d = 0), (d > 0 || s.trim === !1) && (n[n.length - 1] += " ", d++)), s.hard && l[$] > r) {
926
+ const F = r - d, y = 1 + Math.floor((l[$] - F - 1) / r);
927
+ Math.floor((l[$] - 1) / r) < y && n.push(""), Ie(n, m, r);
928
+ continue;
929
+ }
930
+ if (d + l[$] > r && d > 0 && l[$] > 0) {
931
+ if (s.wordWrap === !1 && d < r) {
932
+ Ie(n, m, r);
933
+ continue;
934
+ }
935
+ n.push("");
936
+ }
937
+ if (d + l[$] > r && s.wordWrap === !1) {
938
+ Ie(n, m, r);
939
+ continue;
940
+ }
941
+ n[n.length - 1] += m;
942
+ }
943
+ s.trim !== !1 && (n = n.map(($) => St($)));
944
+ const c = n.join(`
945
+ `), p = c[Symbol.iterator]();
946
+ let f = p.next(), g = p.next(), E = 0;
947
+ for (; !f.done;) {
948
+ const $ = f.value, m = g.value;
949
+ if (i += $, $ === ae || $ === je) {
950
+ He.lastIndex = E + 1;
951
+ const y = He.exec(c)?.groups;
952
+ if (y?.code !== void 0) {
953
+ const v = Number.parseFloat(y.code);
954
+ a = v === vt ? void 0 : v;
955
+ } else y?.uri !== void 0 && (o = y.uri.length === 0 ? void 0 : y.uri);
956
+ }
957
+ const d = a ? At(a) : void 0;
958
+ m === `
959
+ ` ? (o && (i += Ke("")), a && d && (i += Ue(d))) : $ === `
960
+ ` && (a && d && (i += Ue(a)), o && (i += Ke(o))), E += $.length, f = g, g = p.next();
961
+ }
962
+ return i;
963
+ };
964
+ function J(e, r, s) {
965
+ return String(e).normalize().replaceAll(`\r
966
+ `, `
967
+ `).split(`
968
+ `).map((i) => It(i, r, s)).join(`
969
+ `);
970
+ }
971
+ const Rt = (e) => {
972
+ const r = e.active ?? "Yes", s = e.inactive ?? "No";
973
+ return new kt$1({
974
+ active: r,
975
+ inactive: s,
976
+ signal: e.signal,
977
+ input: e.input,
978
+ output: e.output,
979
+ initialValue: e.initialValue ?? !0,
980
+ render() {
981
+ const i = e.withGuide ?? _.withGuide, a = `${i ? `${styleText("gray", h)}
982
+ ` : ""}${W(this.state)} ${e.message}
983
+ `, o = this.value ? r : s;
984
+ switch (this.state) {
985
+ case "submit": return `${a}${i ? `${styleText("gray", h)} ` : ""}${styleText("dim", o)}`;
986
+ case "cancel": return `${a}${i ? `${styleText("gray", h)} ` : ""}${styleText(["strikethrough", "dim"], o)}${i ? `
987
+ ${styleText("gray", h)}` : ""}`;
988
+ default: {
989
+ const u = i ? `${styleText("cyan", h)} ` : "", l = i ? styleText("cyan", x) : "";
990
+ return `${a}${u}${this.value ? `${styleText("green", z)} ${r}` : `${styleText("dim", H)} ${styleText("dim", r)}`}${e.vertical ? i ? `
991
+ ${styleText("cyan", h)} ` : `
992
+ ` : ` ${styleText("dim", "/")} `}${this.value ? `${styleText("dim", H)} ${styleText("dim", s)}` : `${styleText("green", z)} ${s}`}
993
+ ${l}
994
+ `;
995
+ }
996
+ }
997
+ }
998
+ }).prompt();
999
+ }, R = {
1000
+ message: (e = [], { symbol: r = styleText("gray", h), secondarySymbol: s = styleText("gray", h), output: i = process.stdout, spacing: a = 1, withGuide: o } = {}) => {
1001
+ const u = [], l = o ?? _.withGuide, n = l ? s : "", c = l ? `${r} ` : "", p = l ? `${s} ` : "";
1002
+ for (let g = 0; g < a; g++) u.push(n);
1003
+ const f = Array.isArray(e) ? e : e.split(`
1004
+ `);
1005
+ if (f.length > 0) {
1006
+ const [g, ...E] = f;
1007
+ g.length > 0 ? u.push(`${c}${g}`) : u.push(l ? r : "");
1008
+ for (const $ of E) $.length > 0 ? u.push(`${p}${$}`) : u.push(l ? s : "");
1009
+ }
1010
+ i.write(`${u.join(`
1011
+ `)}
1012
+ `);
1013
+ },
1014
+ info: (e, r) => {
1015
+ R.message(e, {
1016
+ ...r,
1017
+ symbol: styleText("blue", fe)
1018
+ });
1019
+ },
1020
+ success: (e, r) => {
1021
+ R.message(e, {
1022
+ ...r,
1023
+ symbol: styleText("green", Fe)
1024
+ });
1025
+ },
1026
+ step: (e, r) => {
1027
+ R.message(e, {
1028
+ ...r,
1029
+ symbol: styleText("green", V)
1030
+ });
1031
+ },
1032
+ warn: (e, r) => {
1033
+ R.message(e, {
1034
+ ...r,
1035
+ symbol: styleText("yellow", ye)
1036
+ });
1037
+ },
1038
+ warning: (e, r) => {
1039
+ R.warn(e, r);
1040
+ },
1041
+ error: (e, r) => {
1042
+ R.message(e, {
1043
+ ...r,
1044
+ symbol: styleText("red", Ee)
1045
+ });
1046
+ }
1047
+ }, Gt = (e = "", r) => {
1048
+ const s = r?.output ?? process.stdout, i = r?.withGuide ?? _.withGuide ? `${styleText("gray", h)}
1049
+ ${styleText("gray", x)} ` : "";
1050
+ s.write(`${i}${e}
1051
+
1052
+ `);
1053
+ }, jt = (e) => styleText("dim", e), kt = (e, r, s) => {
1054
+ const i = {
1055
+ hard: !0,
1056
+ trim: !1
1057
+ }, a = J(e, r, i).split(`
1058
+ `), o = a.reduce((n, c) => Math.max(D(c), n), 0);
1059
+ return J(e, r - (a.map(s).reduce((n, c) => Math.max(D(c), n), 0) - o), i);
1060
+ }, Vt = (e = "", r = "", s) => {
1061
+ const i = s?.output ?? process$1.stdout, a = s?.withGuide ?? _.withGuide, o = s?.format ?? jt, u = [
1062
+ "",
1063
+ ...kt(e, rt(i) - 6, o).split(`
1064
+ `).map(o),
1065
+ ""
1066
+ ], l = D(r), n = Math.max(u.reduce((g, E) => {
1067
+ const $ = D(E);
1068
+ return $ > g ? $ : g;
1069
+ }, 0), l) + 2, c = u.map((g) => `${styleText("gray", h)} ${g}${" ".repeat(n - D(g))}${styleText("gray", h)}`).join(`
1070
+ `), p = a ? `${styleText("gray", h)}
1071
+ ` : "", f = a ? We : ge;
1072
+ i.write(`${p}${styleText("green", V)} ${styleText("reset", r)} ${styleText("gray", se.repeat(Math.max(n - l - 1, 1)) + pe)}
1073
+ ${c}
1074
+ ${styleText("gray", f + se.repeat(n + 2) + me)}
1075
+ `);
1076
+ };
1077
+ I("─", "-"), I("━", "="), I("█", "#");
1078
+ const Qe = `${styleText("gray", h)} `, K = {
1079
+ message: async (e, { symbol: r = styleText("gray", h) } = {}) => {
1080
+ process.stdout.write(`${styleText("gray", h)}
1081
+ ${r} `);
1082
+ let s = 3;
1083
+ for await (let i of e) {
1084
+ i = i.replace(/\n/g, `
1085
+ ${Qe}`), i.includes(`
1086
+ `) && (s = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
1087
+ `))).length);
1088
+ const a = stripVTControlCharacters(i).length;
1089
+ s + a < process.stdout.columns ? (s += a, process.stdout.write(i)) : (process.stdout.write(`
1090
+ ${Qe}${i.trimStart()}`), s = 3 + stripVTControlCharacters(i.trimStart()).length);
1091
+ }
1092
+ process.stdout.write(`
1093
+ `);
1094
+ },
1095
+ info: (e) => K.message(e, { symbol: styleText("blue", fe) }),
1096
+ success: (e) => K.message(e, { symbol: styleText("green", Fe) }),
1097
+ step: (e) => K.message(e, { symbol: styleText("green", V) }),
1098
+ warn: (e) => K.message(e, { symbol: styleText("yellow", ye) }),
1099
+ warning: (e) => K.warn(e),
1100
+ error: (e) => K.message(e, { symbol: styleText("red", Ee) })
1101
+ };
1102
+ //#endregion
1103
+ //#region ../../node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.mjs
1104
+ var import_ansis = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
1105
+ let e, t, r, { defineProperty: l, setPrototypeOf: n, create: o, keys: s } = Object, i = "", { round: c, max: a } = Math, p = (e) => {
1106
+ 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);
1107
+ return [
1108
+ l >> 16 & 255,
1109
+ l >> 8 & 255,
1110
+ 255 & l
1111
+ ];
1112
+ }, 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) => {
1113
+ let t, r, l, n, o;
1114
+ 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);
1115
+ }, f = (() => {
1116
+ let r = (e) => o.some(((t) => e.test(t))), l = globalThis, n = l.process ?? {}, o = n.argv ?? [], i = n.env ?? {}, c = -1;
1117
+ try {
1118
+ e = "," + s(i).join(",");
1119
+ } catch (e) {
1120
+ i = {}, c = 0;
1121
+ }
1122
+ let a = "FORCE_COLOR", p = {
1123
+ false: 0,
1124
+ 0: 0,
1125
+ 1: 1,
1126
+ 2: 2,
1127
+ 3: 3
1128
+ }[i[a]] ?? -1, u = a in i && p || r(/^--color=?(true|always)?$/);
1129
+ return u && (c = p), ~c || (c = ((r, l, n) => (t = r.TERM, {
1130
+ "24bit": 3,
1131
+ truecolor: 3,
1132
+ ansi256: 2,
1133
+ ansi: 1
1134
+ }[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;
1135
+ })(), g = {
1136
+ open: i,
1137
+ close: i
1138
+ }, h = 39, b = 49, O = {}, m = ({ p: e }, { open: t, close: l }) => {
1139
+ let o = (e, ...r) => {
1140
+ if (!e) {
1141
+ if (t && t === l) return t;
1142
+ if ((e ?? i) === i) return i;
1143
+ }
1144
+ let n, s = e.raw ? String.raw({ raw: e }, ...r) : i + e, c = o.p, a = c.o, p = c.c;
1145
+ if (s.includes("\x1B")) for (; c; c = c.p) {
1146
+ let { open: e, close: t } = c, r = t.length, l = i, o = 0;
1147
+ if (r) for (; ~(n = s.indexOf(t, o)); o = n + r) l += s.slice(o, n) + e;
1148
+ s = l + s.slice(o);
1149
+ }
1150
+ return a + (s.includes("\n") ? s.replace(/(\r?\n)/g, p + "$1" + a) : s) + p;
1151
+ }, s = t, c = l;
1152
+ return e && (s = e.o + t, c = l + e.c), n(o, r), o.p = {
1153
+ open: t,
1154
+ close: l,
1155
+ o: s,
1156
+ c,
1157
+ p: e
1158
+ }, o.open = s, o.close = c, o;
1159
+ };
1160
+ const w = new function e(t = f) {
1161
+ let s = {
1162
+ Ansis: e,
1163
+ level: t,
1164
+ isSupported: () => a,
1165
+ strip: (e) => e.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i),
1166
+ extend(e) {
1167
+ for (let t in e) {
1168
+ let r = e[t], l = (typeof r)[0];
1169
+ "s" === l ? (c(t, T(...p(r))), c(_(t), v(...p(r)))) : c(t, r, "f" === l);
1170
+ }
1171
+ return r = o({}, O), n(s, r), s;
1172
+ }
1173
+ }, c = (e, t, r) => {
1174
+ O[e] = { get() {
1175
+ let n = r ? (...e) => m(this, t(...e)) : m(this, t);
1176
+ return l(this, e, { value: n }), n;
1177
+ } };
1178
+ }, a = t > 0, w = (e, t) => a ? {
1179
+ open: `[${e}m`,
1180
+ close: `[${t}m`
1181
+ } : 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);
1182
+ 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));
1183
+ let M, I = {
1184
+ fg: C,
1185
+ bg: E,
1186
+ rgb: T,
1187
+ bgRgb: v,
1188
+ hex: y(T),
1189
+ bgHex: y(v),
1190
+ visible: g,
1191
+ reset: w(0, 0),
1192
+ bold: w(1, 22),
1193
+ dim: w(2, 22),
1194
+ italic: w(3, 23),
1195
+ underline: w(4, 24),
1196
+ inverse: w(7, 27),
1197
+ hidden: w(8, 28),
1198
+ strikethrough: w(9, 29)
1199
+ }, _ = (e) => "bg" + e[0].toUpperCase() + e.slice(1), k = "Bright";
1200
+ return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map(((e, t) => {
1201
+ 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);
1202
+ })), s.extend(I);
1203
+ }();
1204
+ module.exports = w, w.default = w;
1205
+ })))(), 1);
1206
+ var ansis_default = import_ansis.default;
1207
+ 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;
1208
+ //#endregion
1209
+ //#region src/node/context-internal.ts
1210
+ const internalContextMap = /* @__PURE__ */ new WeakMap();
1211
+ function getInternalContext(context) {
1212
+ if (!internalContextMap.has(context)) {
1213
+ const internalContext = { storage: { auth: createStorage({
1214
+ filepath: join(context.workspaceRoot, "node_modules/.vite/devtools/auth.json"),
1215
+ initialValue: { trusted: {} }
1216
+ }) } };
1217
+ internalContextMap.set(context, internalContext);
1218
+ }
1219
+ return internalContextMap.get(context);
1220
+ }
1221
+ //#endregion
1222
+ //#region src/node/rpc/anonymous/auth.ts
1223
+ const anonymousAuth = defineRpcFunction({
1224
+ name: "vite:anonymous:auth",
1225
+ type: "action",
1226
+ setup: (context) => {
1227
+ const storage = getInternalContext(context).storage.auth;
1228
+ return { handler: async (query) => {
1229
+ const session = context.rpc.getCurrentRpcSession();
1230
+ if (!session) throw new Error("Failed to retrieve the current RPC session");
1231
+ if (session.meta.isTrusted || storage.value().trusted[query.authId]) {
1232
+ session.meta.clientAuthId = query.authId;
1233
+ session.meta.isTrusted = true;
1234
+ return { isTrusted: true };
1235
+ }
1236
+ const message = [
1237
+ `A browser is requesting permissions to connect to the Vite DevTools.`,
1238
+ "",
1239
+ `User Agent: ${ansis_default.yellow(ansis_default.bold(query.ua || "Unknown"))}`,
1240
+ `Origin : ${ansis_default.cyan(ansis_default.bold(query.origin || "Unknown"))}`,
1241
+ `Identifier: ${ansis_default.green(ansis_default.bold(query.authId))}`,
1242
+ "",
1243
+ "This will allow the browser to interact with the server, make file changes and run commands.",
1244
+ ansis_default.red(ansis_default.bold("You should only trust your local development browsers."))
1245
+ ];
1246
+ Vt(ansis_default.reset(message.join("\n")), ansis_default.bold(ansis_default.yellow(" Vite DevTools Permission Request ")));
1247
+ if (await Rt({
1248
+ message: ansis_default.bold(`Do you trust this client (${ansis_default.green(ansis_default.bold(query.authId))})?`),
1249
+ initialValue: false
1250
+ })) {
1251
+ storage.mutate((state) => {
1252
+ state.trusted[query.authId] = {
1253
+ authId: query.authId,
1254
+ ua: query.ua,
1255
+ origin: query.origin,
1256
+ timestamp: Date.now()
1257
+ };
1258
+ });
1259
+ session.meta.clientAuthId = query.authId;
1260
+ session.meta.isTrusted = true;
1261
+ Gt(ansis_default.green(ansis_default.bold(`You have granted permissions to ${ansis_default.bold(query.authId)}`)));
1262
+ return { isTrusted: true };
1263
+ }
1264
+ Gt(ansis_default.red(ansis_default.bold(`You have denied permissions to ${ansis_default.bold(query.authId)}`)));
1265
+ return { isTrusted: false };
1266
+ } };
1267
+ }
1268
+ });
1269
+ //#endregion
1270
+ //#region src/node/rpc/internal/docks-on-launch.ts
1271
+ const docksOnLaunch = defineRpcFunction({
1272
+ name: "devtoolskit:internal:docks:on-launch",
1273
+ type: "action",
1274
+ setup: (context) => {
1275
+ const launchMap = /* @__PURE__ */ new Map();
1276
+ return { handler: async (entryId) => {
1277
+ if (launchMap.has(entryId)) return launchMap.get(entryId);
1278
+ const entry = context.docks.values().find((entry) => entry.id === entryId);
1279
+ if (!entry) throw new Error(`Dock entry with id "${entryId}" not found`);
1280
+ if (entry.type !== "launcher") throw new Error(`Dock entry with id "${entryId}" is not a launcher`);
1281
+ try {
1282
+ context.docks.update({
1283
+ ...entry,
1284
+ launcher: {
1285
+ ...entry.launcher,
1286
+ status: "loading"
1287
+ }
1288
+ });
1289
+ const promise = entry.launcher.onLaunch();
1290
+ launchMap.set(entryId, promise);
1291
+ const result = await promise;
1292
+ const newEntry = context.docks.values().find((entry) => entry.id === entryId) || entry;
1293
+ if (newEntry.type === "launcher") context.docks.update({
1294
+ ...newEntry,
1295
+ launcher: {
1296
+ ...newEntry.launcher,
1297
+ status: "success"
1298
+ }
1299
+ });
1300
+ return result;
1301
+ } catch (error) {
1302
+ console.error(`[VITE DEVTOOLS] Error launching dock entry "${entryId}"`, error);
1303
+ context.docks.update({
1304
+ ...entry,
1305
+ launcher: {
1306
+ ...entry.launcher,
1307
+ status: "error",
1308
+ error: error instanceof Error ? error.message : String(error)
1309
+ }
1310
+ });
1311
+ }
1312
+ } };
1313
+ }
1314
+ });
1315
+ //#endregion
1316
+ //#region src/node/rpc/internal/rpc-server-list.ts
1317
+ const rpcServerList = defineRpcFunction({
1318
+ name: "devtoolskit:internal:rpc:server:list",
1319
+ type: "static",
1320
+ setup: (context) => {
1321
+ return { async handler() {
1322
+ return Object.fromEntries(Array.from(context.rpc.definitions.entries()).map(([name, fn]) => [name, { type: fn.type }]));
1323
+ } };
1324
+ }
1325
+ });
1326
+ //#endregion
1327
+ //#region src/node/rpc/internal/state/get.ts
1328
+ const sharedStateGet = defineRpcFunction({
1329
+ name: "devtoolskit:internal:rpc:server-state:get",
1330
+ type: "query",
1331
+ dump: (context) => {
1332
+ return { inputs: context.rpc.sharedState.keys().map((key) => [key]) };
1333
+ },
1334
+ setup: (context) => {
1335
+ return { handler: async (key) => {
1336
+ return (await context.rpc.sharedState.get(key)).value();
1337
+ } };
1338
+ }
1339
+ });
1340
+ //#endregion
1341
+ //#region src/node/rpc/internal/state/patch.ts
1342
+ const sharedStatePatch = defineRpcFunction({
1343
+ name: "devtoolskit:internal:rpc:server-state:patch",
1344
+ type: "query",
1345
+ setup: (context) => {
1346
+ return { handler: async (key, patches, syncId) => {
1347
+ (await context.rpc.sharedState.get(key)).patch(patches, syncId);
1348
+ } };
1349
+ }
1350
+ });
1351
+ //#endregion
1352
+ //#region src/node/rpc/internal/state/set.ts
1353
+ const sharedStateSet = defineRpcFunction({
1354
+ name: "devtoolskit:internal:rpc:server-state:set",
1355
+ type: "query",
1356
+ setup: (context) => {
1357
+ return { handler: async (key, value, syncId) => {
1358
+ (await context.rpc.sharedState.get(key)).mutate(() => value, syncId);
1359
+ } };
1360
+ }
1361
+ });
1362
+ //#endregion
1363
+ //#region src/node/rpc/internal/state/subscribe.ts
1364
+ const debug = createDebug("vite:devtools:rpc:state:subscribe");
1365
+ const sharedStateSubscribe = defineRpcFunction({
1366
+ name: "devtoolskit:internal:rpc:server-state:subscribe",
1367
+ type: "event",
1368
+ setup: (context) => {
1369
+ return { handler: async (key) => {
1370
+ const session = context.rpc.getCurrentRpcSession();
1371
+ if (!session) return;
1372
+ debug("subscribe", {
1373
+ key,
1374
+ session: session.meta.id
1375
+ });
1376
+ session.meta.subscribedStates.add(key);
1377
+ } };
1378
+ }
1379
+ });
1380
+ //#endregion
1381
+ //#region src/node/rpc/internal/terminals-list.ts
1382
+ const terminalsList = defineRpcFunction({
1383
+ name: "devtoolskit:internal:terminals:list",
1384
+ type: "static",
1385
+ setup: (context) => {
1386
+ return { async handler() {
1387
+ return Array.from(context.terminals.sessions.values()).map((i) => {
1388
+ return {
1389
+ id: i.id,
1390
+ title: i.title,
1391
+ description: i.description,
1392
+ status: i.status
1393
+ };
1394
+ });
1395
+ } };
1396
+ }
1397
+ });
1398
+ //#endregion
1399
+ //#region src/node/rpc/internal/terminals-read.ts
1400
+ const terminalsRead = defineRpcFunction({
1401
+ name: "devtoolskit:internal:terminals:read",
1402
+ type: "query",
1403
+ setup: (context) => {
1404
+ return { async handler(id) {
1405
+ const session = context.terminals.sessions.get(id);
1406
+ if (!session) throw new Error(`Terminal session with id "${id}" not found`);
1407
+ return {
1408
+ buffer: session.buffer ?? [],
1409
+ ts: Date.now()
1410
+ };
1411
+ } };
1412
+ }
1413
+ });
1414
+ //#endregion
1415
+ //#region src/node/rpc/index.ts
1416
+ const builtinPublicRpcDeclarations = [defineRpcFunction({
1417
+ name: "vite:core:open-in-editor",
1418
+ type: "action",
1419
+ setup: () => {
1420
+ return { handler: async (path) => {
1421
+ await import("launch-editor").then((r) => r.default(path));
1422
+ } };
1423
+ }
1424
+ }), defineRpcFunction({
1425
+ name: "vite:core:open-in-finder",
1426
+ type: "action",
1427
+ setup: () => {
1428
+ return { handler: async (path) => {
1429
+ await import("open").then((r) => r.default(path));
1430
+ } };
1431
+ }
1432
+ })];
1433
+ const builtinAnonymousRpcDeclarations = [anonymousAuth];
1434
+ const builtinInternalRpcDeclarations = [
1435
+ docksOnLaunch,
1436
+ rpcServerList,
1437
+ sharedStateGet,
1438
+ sharedStatePatch,
1439
+ sharedStateSet,
1440
+ sharedStateSubscribe,
1441
+ terminalsList,
1442
+ terminalsRead
1443
+ ];
1444
+ const builtinRpcDeclarations = [
1445
+ ...builtinPublicRpcDeclarations,
1446
+ ...builtinAnonymousRpcDeclarations,
1447
+ ...builtinInternalRpcDeclarations
1448
+ ];
1449
+ //#endregion
1450
+ //#region src/node/context.ts
1451
+ const debugSetup = createDebug("vite:devtools:context:setup");
1452
+ function shouldSkipSetupByCapabilities(plugin, mode) {
1453
+ const modeCapabilities = plugin.devtools?.capabilities?.[mode];
1454
+ if (modeCapabilities === false) return true;
1455
+ if (!isObject(modeCapabilities)) return false;
1456
+ return Object.values(modeCapabilities).includes(false);
1457
+ }
1458
+ async function createDevToolsContext(viteConfig, viteServer) {
1459
+ const cwd = viteConfig.root;
1460
+ const context = {
1461
+ cwd,
1462
+ workspaceRoot: searchForWorkspaceRoot(cwd) ?? cwd,
1463
+ viteConfig,
1464
+ viteServer,
1465
+ mode: viteConfig.command === "serve" ? "dev" : "build",
1466
+ rpc: void 0,
1467
+ docks: void 0,
1468
+ views: void 0,
1469
+ utils: ContextUtils,
1470
+ terminals: void 0
1471
+ };
1472
+ const rpcHost = new RpcFunctionsHost(context);
1473
+ const docksHost = new DevToolsDockHost(context);
1474
+ const viewsHost = new DevToolsViewHost(context);
1475
+ const terminalsHost = new DevToolsTerminalHost(context);
1476
+ context.rpc = rpcHost;
1477
+ context.docks = docksHost;
1478
+ context.views = viewsHost;
1479
+ context.terminals = terminalsHost;
1480
+ for (const fn of builtinRpcDeclarations) rpcHost.register(fn);
1481
+ await docksHost.init();
1482
+ const docksSharedState = await rpcHost.sharedState.get("devtoolskit:internal:docks", { initialValue: [] });
1483
+ docksHost.events.on("dock:entry:updated", debounce(() => {
1484
+ docksSharedState.mutate(() => context.docks.values());
1485
+ }, context.mode === "build" ? 0 : 10));
1486
+ terminalsHost.events.on("terminal:session:updated", debounce(() => {
1487
+ rpcHost.broadcast({
1488
+ method: "devtoolskit:internal:terminals:updated",
1489
+ args: []
1490
+ });
1491
+ docksSharedState.mutate(() => context.docks.values());
1492
+ }, context.mode === "build" ? 0 : 10));
1493
+ terminalsHost.events.on("terminal:session:stream-chunk", (data) => {
1494
+ rpcHost.broadcast({
1495
+ method: "devtoolskit:internal:terminals:stream-chunk",
1496
+ args: [data]
1497
+ });
1498
+ });
1499
+ const plugins = viteConfig.plugins.filter((plugin) => "devtools" in plugin);
1500
+ for (const plugin of plugins) {
1501
+ if (!plugin.devtools?.setup) continue;
1502
+ if (shouldSkipSetupByCapabilities(plugin, context.mode)) {
1503
+ debugSetup(`skipping plugin ${JSON.stringify(plugin.name)} due to disabled capabilities in ${context.mode} mode`);
1504
+ continue;
1505
+ }
1506
+ try {
1507
+ debugSetup(`setting up plugin ${JSON.stringify(plugin.name)}`);
1508
+ await plugin.devtools?.setup?.(context);
1509
+ } catch (error) {
1510
+ console.error(`[Vite DevTools] Error setting up plugin ${plugin.name}:`, error);
1511
+ throw error;
1512
+ }
1513
+ }
1514
+ return context;
1515
+ }
1516
+ //#endregion
1517
+ //#region src/node/plugins/injection.ts
1518
+ function DevToolsInjection() {
1519
+ return {
1520
+ name: "vite:devtools:injection",
1521
+ enforce: "post",
1522
+ transformIndexHtml() {
1523
+ return [{
1524
+ tag: "script",
1525
+ attrs: {
1526
+ 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"))}`,
1527
+ type: "module"
1528
+ },
1529
+ injectTo: "body"
1530
+ }];
1531
+ }
1532
+ };
1533
+ }
1534
+ //#endregion
1535
+ //#region ../../node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs
1536
+ const unsafePorts = /* @__PURE__ */ new Set([
1537
+ 1,
1538
+ 7,
1539
+ 9,
1540
+ 11,
1541
+ 13,
1542
+ 15,
1543
+ 17,
1544
+ 19,
1545
+ 20,
1546
+ 21,
1547
+ 22,
1548
+ 23,
1549
+ 25,
1550
+ 37,
1551
+ 42,
1552
+ 43,
1553
+ 53,
1554
+ 69,
1555
+ 77,
1556
+ 79,
1557
+ 87,
1558
+ 95,
1559
+ 101,
1560
+ 102,
1561
+ 103,
1562
+ 104,
1563
+ 109,
1564
+ 110,
1565
+ 111,
1566
+ 113,
1567
+ 115,
1568
+ 117,
1569
+ 119,
1570
+ 123,
1571
+ 135,
1572
+ 137,
1573
+ 139,
1574
+ 143,
1575
+ 161,
1576
+ 179,
1577
+ 389,
1578
+ 427,
1579
+ 465,
1580
+ 512,
1581
+ 513,
1582
+ 514,
1583
+ 515,
1584
+ 526,
1585
+ 530,
1586
+ 531,
1587
+ 532,
1588
+ 540,
1589
+ 548,
1590
+ 554,
1591
+ 556,
1592
+ 563,
1593
+ 587,
1594
+ 601,
1595
+ 636,
1596
+ 989,
1597
+ 990,
1598
+ 993,
1599
+ 995,
1600
+ 1719,
1601
+ 1720,
1602
+ 1723,
1603
+ 2049,
1604
+ 3659,
1605
+ 4045,
1606
+ 5060,
1607
+ 5061,
1608
+ 6e3,
1609
+ 6566,
1610
+ 6665,
1611
+ 6666,
1612
+ 6667,
1613
+ 6668,
1614
+ 6669,
1615
+ 6697,
1616
+ 10080
1617
+ ]);
1618
+ function isUnsafePort(port) {
1619
+ return unsafePorts.has(port);
1620
+ }
1621
+ function isSafePort(port) {
1622
+ return !isUnsafePort(port);
1623
+ }
1624
+ var GetPortError = class extends Error {
1625
+ constructor(message, opts) {
1626
+ super(message, opts);
1627
+ this.message = message;
1628
+ }
1629
+ name = "GetPortError";
1630
+ };
1631
+ function _log(verbose, message) {
1632
+ if (verbose) console.log(`[get-port] ${message}`);
1633
+ }
1634
+ function _generateRange(from, to) {
1635
+ if (to < from) return [];
1636
+ const r = [];
1637
+ for (let index = from; index <= to; index++) r.push(index);
1638
+ return r;
1639
+ }
1640
+ function _tryPort(port, host) {
1641
+ return new Promise((resolve) => {
1642
+ const server = createServer();
1643
+ server.unref();
1644
+ server.on("error", () => {
1645
+ resolve(false);
1646
+ });
1647
+ server.listen({
1648
+ port,
1649
+ host
1650
+ }, () => {
1651
+ const { port: port2 } = server.address();
1652
+ server.close(() => {
1653
+ resolve(isSafePort(port2) && port2);
1654
+ });
1655
+ });
1656
+ });
1657
+ }
1658
+ function _getLocalHosts(additional) {
1659
+ const hosts = new Set(additional);
1660
+ 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);
1661
+ return [...hosts];
1662
+ }
1663
+ async function _findPort(ports, host) {
1664
+ for (const port of ports) {
1665
+ const r = await _tryPort(port, host);
1666
+ if (r) return r;
1667
+ }
1668
+ }
1669
+ function _fmtOnHost(hostname) {
1670
+ return hostname ? `on host ${JSON.stringify(hostname)}` : "on any host";
1671
+ }
1672
+ const HOSTNAME_RE = /^(?!-)[\d.:A-Za-z-]{1,63}(?<!-)$/;
1673
+ function _validateHostname(hostname, _public, verbose) {
1674
+ if (hostname && !HOSTNAME_RE.test(hostname)) {
1675
+ const fallbackHost = _public ? "0.0.0.0" : "127.0.0.1";
1676
+ _log(verbose, `Invalid hostname: ${JSON.stringify(hostname)}. Using ${JSON.stringify(fallbackHost)} as fallback.`);
1677
+ return fallbackHost;
1678
+ }
1679
+ return hostname;
1680
+ }
1681
+ async function getPort(_userOptions = {}) {
1682
+ if (typeof _userOptions === "number" || typeof _userOptions === "string") _userOptions = { port: Number.parseInt(_userOptions + "") || 0 };
1683
+ const _port = Number(_userOptions.port ?? process.env.PORT);
1684
+ const _userSpecifiedAnyPort = Boolean(_userOptions.port || _userOptions.ports?.length || _userOptions.portRange?.length);
1685
+ const options = {
1686
+ random: _port === 0,
1687
+ ports: [],
1688
+ portRange: [],
1689
+ alternativePortRange: _userSpecifiedAnyPort ? [] : [3e3, 3100],
1690
+ verbose: false,
1691
+ ..._userOptions,
1692
+ port: _port,
1693
+ host: _validateHostname(_userOptions.host ?? process.env.HOST, _userOptions.public, _userOptions.verbose)
1694
+ };
1695
+ if (options.random && !_userSpecifiedAnyPort) return getRandomPort(options.host);
1696
+ const portsToCheck = [
1697
+ options.port,
1698
+ ...options.ports,
1699
+ ..._generateRange(...options.portRange)
1700
+ ].filter((port) => {
1701
+ if (!port) return false;
1702
+ if (!isSafePort(port)) {
1703
+ _log(options.verbose, `Ignoring unsafe port: ${port}`);
1704
+ return false;
1705
+ }
1706
+ return true;
1707
+ });
1708
+ if (portsToCheck.length === 0) portsToCheck.push(3e3);
1709
+ let availablePort = await _findPort(portsToCheck, options.host);
1710
+ if (!availablePort && options.alternativePortRange.length > 0) {
1711
+ availablePort = await _findPort(_generateRange(...options.alternativePortRange), options.host);
1712
+ if (portsToCheck.length > 0) {
1713
+ let message = `Unable to find an available port (tried ${portsToCheck.join("-")} ${_fmtOnHost(options.host)}).`;
1714
+ if (availablePort) message += ` Using alternative port ${availablePort}.`;
1715
+ _log(options.verbose, message);
1716
+ }
1717
+ }
1718
+ if (!availablePort && _userOptions.random !== false) {
1719
+ availablePort = await getRandomPort(options.host);
1720
+ if (availablePort) _log(options.verbose, `Using random port ${availablePort}`);
1721
+ }
1722
+ if (!availablePort) {
1723
+ const triedRanges = [
1724
+ options.port,
1725
+ options.portRange.join("-"),
1726
+ options.alternativePortRange.join("-")
1727
+ ].filter(Boolean).join(", ");
1728
+ throw new GetPortError(`Unable to find an available port ${_fmtOnHost(options.host)} (tried ${triedRanges})`);
1729
+ }
1730
+ return availablePort;
1731
+ }
1732
+ async function getRandomPort(host) {
1733
+ const port = await checkPort(0, host);
1734
+ if (port === false) throw new GetPortError(`Unable to find a random port ${_fmtOnHost(host)}`);
1735
+ return port;
1736
+ }
1737
+ async function checkPort(port, host = process.env.HOST, verbose) {
1738
+ if (!host) host = _getLocalHosts([void 0, "0.0.0.0"]);
1739
+ if (!Array.isArray(host)) return _tryPort(port, host);
1740
+ for (const _host of host) {
1741
+ const _port = await _tryPort(port, _host);
1742
+ if (_port === false) {
1743
+ if (port < 1024 && verbose) _log(verbose, `Unable to listen to the privileged port ${port} ${_fmtOnHost(_host)}`);
1744
+ return false;
1745
+ }
1746
+ if (port === 0 && _port !== 0) port = _port;
1747
+ }
1748
+ return port;
1749
+ }
1750
+ ansis_default.green("✔");
1751
+ const MARK_INFO = ansis_default.blue("ℹ");
1752
+ ansis_default.red("✖");
1753
+ //#endregion
1754
+ //#region src/node/ws.ts
1755
+ const debugInvoked = createDebug("vite:devtools:rpc:invoked");
1756
+ const ANONYMOUS_SCOPE = "vite:anonymous:";
1757
+ async function createWsServer(options) {
1758
+ const rpcHost = options.context.rpc;
1759
+ const host = options.hostWebSocket ?? "localhost";
1760
+ const https = options.context.viteConfig.server.https;
1761
+ const port = options.portWebSocket ?? await getPort({
1762
+ port: 7812,
1763
+ host,
1764
+ random: true
1765
+ });
1766
+ const wsClients = /* @__PURE__ */ new Set();
1767
+ const context = options.context;
1768
+ const contextInternal = getInternalContext(context);
1769
+ const isClientAuthDisabled = context.mode === "build" || context.viteConfig.devtools?.config?.clientAuth === false || process$1.env.VITE_DEVTOOLS_DISABLE_CLIENT_AUTH === "true";
1770
+ if (isClientAuthDisabled) console.warn("[Vite DevTools] Client authentication is disabled. Any browser can connect to the devtools and access to your server and filesystem.");
1771
+ const preset = createWsRpcPreset({
1772
+ port,
1773
+ host,
1774
+ https,
1775
+ onConnected: (ws, req, meta) => {
1776
+ const authId = new URL(req.url ?? "", "http://localhost").searchParams.get("vite_devtools_auth_id") ?? void 0;
1777
+ if (isClientAuthDisabled) meta.isTrusted = true;
1778
+ else if (authId && contextInternal.storage.auth.value().trusted[authId]) {
1779
+ meta.isTrusted = true;
1780
+ meta.clientAuthId = authId;
1781
+ }
1782
+ wsClients.add(ws);
1783
+ const color = meta.isTrusted ? ansis_default.green : ansis_default.yellow;
1784
+ console.log(color`${MARK_INFO} Websocket client connected. [${meta.id}] [${meta.clientAuthId}] (${meta.isTrusted ? "trusted" : "untrusted"})`);
1785
+ },
1786
+ onDisconnected: (ws, meta) => {
1787
+ wsClients.delete(ws);
1788
+ console.log(ansis_default.red`${MARK_INFO} Websocket client disconnected. [${meta.id}]`);
1789
+ }
1790
+ });
1791
+ const asyncStorage = new AsyncLocalStorage();
1792
+ const rpcGroup = createRpcServer(rpcHost.functions, {
1793
+ preset,
1794
+ rpcOptions: {
1795
+ onFunctionError(error, name) {
1796
+ console.error(ansis_default.red`⬢ RPC error on executing "${ansis_default.bold(name)}":`);
1797
+ console.error(error);
1798
+ },
1799
+ onGeneralError(error) {
1800
+ console.error(ansis_default.red`⬢ RPC error on executing rpc`);
1801
+ console.error(error);
1802
+ },
1803
+ resolver(name, fn) {
1804
+ const rpc = this;
1805
+ if (!name.startsWith(ANONYMOUS_SCOPE) && !rpc.$meta.isTrusted) return () => {
1806
+ throw new Error(`Unauthorized access to method ${JSON.stringify(name)} from client [${rpc.$meta.id}]`);
1807
+ };
1808
+ if (!fn) return void 0;
1809
+ return async function(...args) {
1810
+ debugInvoked(`${JSON.stringify(name)} from #${rpc.$meta.id}`);
1811
+ return await asyncStorage.run({
1812
+ rpc,
1813
+ meta: rpc.$meta
1814
+ }, async () => {
1815
+ return (await fn).apply(this, args);
1816
+ });
1817
+ };
1818
+ }
1819
+ }
1820
+ });
1821
+ rpcHost._rpcGroup = rpcGroup;
1822
+ rpcHost._asyncStorage = asyncStorage;
1823
+ const getConnectionMeta = async () => {
1824
+ return {
1825
+ backend: "websocket",
1826
+ websocket: port
1827
+ };
1828
+ };
1829
+ return {
1830
+ port,
1831
+ rpc: rpcGroup,
1832
+ rpcHost,
1833
+ getConnectionMeta
1834
+ };
1835
+ }
1836
+ //#endregion
1837
+ //#region src/node/server.ts
1838
+ async function createDevToolsMiddleware(options) {
1839
+ const h3 = createApp();
1840
+ const { rpc, getConnectionMeta } = await createWsServer(options);
1841
+ h3.use(`/${DEVTOOLS_CONNECTION_META_FILENAME}`, eventHandler(async (event) => {
1842
+ event.node.res.setHeader("Content-Type", "application/json");
1843
+ return event.node.res.end(JSON.stringify(await getConnectionMeta()));
1844
+ }));
1845
+ h3.use(fromNodeMiddleware(sirv(dirClientStandalone, {
1846
+ dev: true,
1847
+ single: true
1848
+ })));
1849
+ return {
1850
+ h3,
1851
+ rpc,
1852
+ middleware: toNodeListener(h3),
1853
+ getConnectionMeta
1854
+ };
1855
+ }
1856
+ //#endregion
1857
+ //#region src/node/plugins/server.ts
1858
+ /**
1859
+ * Core plugin for enabling Vite DevTools
1860
+ */
1861
+ function renderDockImportsMap(docks) {
1862
+ const map = /* @__PURE__ */ new Map();
1863
+ for (const dock of docks) {
1864
+ const id = `${dock.type}:${dock.id}`;
1865
+ if (dock.type === "action") map.set(id, dock.action);
1866
+ else if (dock.type === "custom-render") map.set(id, dock.renderer);
1867
+ else if (dock.type === "iframe" && dock.clientScript) map.set(id, dock.clientScript);
1868
+ }
1869
+ return [
1870
+ `export const importsMap = {`,
1871
+ ...[...map.entries()].filter(([, entry]) => entry != null).map(([id, { importFrom, importName }]) => ` [${JSON.stringify(id)}]: () => import(${JSON.stringify(importFrom)}).then(r => r[${JSON.stringify(importName ?? "default")}]),`),
1872
+ "}"
1873
+ ].join("\n");
1874
+ }
1875
+ function DevToolsServer() {
1876
+ let context;
1877
+ return {
1878
+ name: "vite:devtools:server",
1879
+ enforce: "post",
1880
+ apply: "serve",
1881
+ async configureServer(viteDevServer) {
1882
+ context = await createDevToolsContext(viteDevServer.config, viteDevServer);
1883
+ const host = viteDevServer.config.server.host === true ? "0.0.0.0" : viteDevServer.config.server.host || "localhost";
1884
+ const { middleware } = await createDevToolsMiddleware({
1885
+ cwd: viteDevServer.config.root,
1886
+ hostWebSocket: host,
1887
+ context
1888
+ });
1889
+ viteDevServer.middlewares.use(DEVTOOLS_MOUNT_PATH, middleware);
1890
+ },
1891
+ resolveId(id) {
1892
+ if (id === DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID) return id;
1893
+ },
1894
+ load(id) {
1895
+ if (id === DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID) {
1896
+ if (!context) throw new Error("DevTools context is not initialized");
1897
+ return renderDockImportsMap(context.docks.values());
1898
+ }
1899
+ }
1900
+ };
1901
+ }
1902
+ //#endregion
1903
+ //#region src/node/plugins/index.ts
1904
+ async function DevTools(options = {}) {
1905
+ const { builtinDevTools = true } = options;
1906
+ const plugins = [DevToolsInjection(), DevToolsServer()];
1907
+ if (builtinDevTools) plugins.push(await import("@vitejs/devtools-rolldown").then((m) => m.DevToolsRolldownUI()));
1908
+ return plugins;
1909
+ }
1910
+ //#endregion
1911
+ export { createDevToolsContext as a, getPort as i, renderDockImportsMap as n, ansis_default as o, createDevToolsMiddleware as r, DevTools as t };