@vitejs/devtools 0.0.0-alpha.20 → 0.0.0-alpha.21

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,2756 @@
1
+ import { n as dirDist, t as dirClientStandalone } from "./dirs-C0s1Ghvy.js";
2
+ import Debug from "debug";
3
+ import { debounce } from "perfect-debounce";
4
+ import { normalizePath, searchForWorkspaceRoot } from "vite";
5
+ import { toDataURL } from "mlly";
6
+ import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
7
+ import { RpcFunctionsCollectorBase } from "birpc-x";
8
+ import process$1, { stdin, stdout } from "node:process";
9
+ import fs, { existsSync } from "node:fs";
10
+ import sirv from "sirv";
11
+ import { stripVTControlCharacters } from "node:util";
12
+ import { cursor, erase } from "sisteransi";
13
+ import * as g from "node:readline";
14
+ import O from "node:readline";
15
+ import { Writable } from "node:stream";
16
+ import e from "picocolors";
17
+ import { defineRpcFunction } from "@vitejs/devtools-kit";
18
+ import { dirname, join } from "pathe";
19
+ import { createSharedState } from "@vitejs/devtools-kit/utils/shared-state";
20
+ import { join as join$1 } from "node:path";
21
+ import { AsyncLocalStorage } from "node:async_hooks";
22
+ import { createRpcServer } from "@vitejs/devtools-rpc";
23
+ import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/server";
24
+ import { createServer } from "node:net";
25
+ import { networkInterfaces } from "node:os";
26
+ import "node:fs/promises";
27
+
28
+ //#region rolldown:runtime
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$2) => from[k$2]).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/host-docks.ts
66
+ var DevToolsDockHost = class {
67
+ views = /* @__PURE__ */ new Map();
68
+ events = createEventEmitter();
69
+ constructor(context) {
70
+ this.context = context;
71
+ }
72
+ values() {
73
+ return Array.from(this.views.values());
74
+ }
75
+ register(view, force) {
76
+ if (this.views.has(view.id) && !force) throw new Error(`Dock with id "${view.id}" is already registered`);
77
+ this.views.set(view.id, view);
78
+ this.events.emit("dock:entry:updated", view);
79
+ return { update: (patch) => {
80
+ if (patch.id && patch.id !== view.id) throw new Error(`Cannot change the id of a dock. Use register() to add new docks.`);
81
+ this.update(Object.assign(this.views.get(view.id), patch));
82
+ } };
83
+ }
84
+ update(view) {
85
+ if (!this.views.has(view.id)) throw new Error(`Dock with id "${view.id}" is not registered. Use register() to add new docks.`);
86
+ this.views.set(view.id, view);
87
+ this.events.emit("dock:entry:updated", view);
88
+ }
89
+ };
90
+
91
+ //#endregion
92
+ //#region src/node/host-functions.ts
93
+ var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
94
+ /**
95
+ * @internal
96
+ */
97
+ _rpcGroup = void 0;
98
+ _asyncStorage = void 0;
99
+ constructor(context) {
100
+ super(context);
101
+ }
102
+ broadcast(name, ...args) {
103
+ if (!this._rpcGroup) throw new Error("RpcFunctionsHost] RpcGroup is not set, it likely to be an internal bug of Vite DevTools");
104
+ return this._rpcGroup.broadcast.$callOptional(name, ...args);
105
+ }
106
+ getCurrentRpcSession() {
107
+ if (!this._asyncStorage) throw new Error("RpcFunctionsHost] AsyncLocalStorage is not set, it likely to be an internal bug of Vite DevTools");
108
+ return this._asyncStorage.getStore();
109
+ }
110
+ };
111
+
112
+ //#endregion
113
+ //#region src/node/host-terminals.ts
114
+ var DevToolsTerminalHost = class {
115
+ sessions = /* @__PURE__ */ new Map();
116
+ events = createEventEmitter();
117
+ _boundStreams = /* @__PURE__ */ new Map();
118
+ constructor(context) {
119
+ this.context = context;
120
+ }
121
+ register(session) {
122
+ if (this.sessions.has(session.id)) throw new Error(`Terminal session with id "${session.id}" already registered`);
123
+ this.sessions.set(session.id, session);
124
+ this.bindStream(session);
125
+ this.events.emit("terminal:session:updated", session);
126
+ return session;
127
+ }
128
+ update(patch) {
129
+ if (!this.sessions.has(patch.id)) throw new Error(`Terminal session with id "${patch.id}" not registered`);
130
+ const session = this.sessions.get(patch.id);
131
+ Object.assign(session, patch);
132
+ this.sessions.set(patch.id, session);
133
+ this.bindStream(session);
134
+ this.events.emit("terminal:session:updated", session);
135
+ }
136
+ remove(session) {
137
+ this.sessions.delete(session.id);
138
+ this.events.emit("terminal:session:updated", session);
139
+ this._boundStreams.delete(session.id);
140
+ }
141
+ bindStream(session) {
142
+ if (this._boundStreams.has(session.id) && this._boundStreams.get(session.id)?.stream === session.stream) return;
143
+ this._boundStreams.get(session.id)?.dispose();
144
+ this._boundStreams.delete(session.id);
145
+ if (!session.stream) return;
146
+ session.buffer ||= [];
147
+ const events = this.events;
148
+ const writer = new WritableStream({ write(chunk) {
149
+ session.buffer.push(chunk);
150
+ events.emit("terminal:session:stream-chunk", {
151
+ id: session.id,
152
+ chunks: [chunk],
153
+ ts: Date.now()
154
+ });
155
+ } });
156
+ session.stream.pipeTo(writer);
157
+ this._boundStreams.set(session.id, {
158
+ dispose: () => {
159
+ writer.close();
160
+ },
161
+ stream: session.stream
162
+ });
163
+ }
164
+ async startChildProcess(executeOptions, terminal) {
165
+ if (this.sessions.has(terminal.id)) throw new Error(`Terminal session with id "${terminal.id}" already registered`);
166
+ const { exec } = await import("tinyexec");
167
+ let controller;
168
+ const stream = new ReadableStream({ start(_controller) {
169
+ controller = _controller;
170
+ } });
171
+ function createChildProcess() {
172
+ const cp$1 = exec(executeOptions.command, executeOptions.args || [], { nodeOptions: {
173
+ env: {
174
+ COLORS: "true",
175
+ FORCE_COLOR: "true",
176
+ ...executeOptions.env || {}
177
+ },
178
+ cwd: executeOptions.cwd ?? process$1.cwd(),
179
+ stdio: "pipe"
180
+ } });
181
+ (async () => {
182
+ for await (const chunk of cp$1) controller?.enqueue(chunk);
183
+ })();
184
+ return cp$1;
185
+ }
186
+ let cp = createChildProcess();
187
+ const restart = async () => {
188
+ cp?.kill();
189
+ cp = createChildProcess();
190
+ };
191
+ const terminate = async () => {
192
+ cp?.kill();
193
+ cp = void 0;
194
+ };
195
+ const session = {
196
+ ...terminal,
197
+ status: "running",
198
+ stream,
199
+ type: "child-process",
200
+ executeOptions,
201
+ getChildProcess: () => cp?.process,
202
+ terminate,
203
+ restart
204
+ };
205
+ this.register(session);
206
+ return Promise.resolve(session);
207
+ }
208
+ };
209
+
210
+ //#endregion
211
+ //#region src/node/host-views.ts
212
+ var DevToolsViewHost = class {
213
+ /**
214
+ * @internal
215
+ */
216
+ buildStaticDirs = [];
217
+ constructor(context) {
218
+ this.context = context;
219
+ }
220
+ hostStatic(baseUrl, distDir) {
221
+ if (!existsSync(distDir)) throw new Error(`[Vite DevTools] distDir ${distDir} does not exist`);
222
+ this.buildStaticDirs.push({
223
+ baseUrl,
224
+ distDir
225
+ });
226
+ if (this.context.viteConfig.command === "serve") {
227
+ if (!this.context.viteServer) throw new Error("[Vite DevTools] viteServer is required in dev mode");
228
+ this.context.viteServer.middlewares.use(baseUrl, sirv(distDir, {
229
+ dev: true,
230
+ single: true
231
+ }));
232
+ }
233
+ }
234
+ };
235
+
236
+ //#endregion
237
+ //#region ../../node_modules/.pnpm/@clack+core@0.5.0/node_modules/@clack/core/dist/index.mjs
238
+ function DD({ onlyFirst: e$1 = !1 } = {}) {
239
+ const t = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
240
+ return new RegExp(t, e$1 ? void 0 : "g");
241
+ }
242
+ const uD = DD();
243
+ function P$1(e$1) {
244
+ if (typeof e$1 != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof e$1}\``);
245
+ return e$1.replace(uD, "");
246
+ }
247
+ function L$1(e$1) {
248
+ return e$1 && e$1.__esModule && Object.prototype.hasOwnProperty.call(e$1, "default") ? e$1.default : e$1;
249
+ }
250
+ var W$1 = { exports: {} };
251
+ (function(e$1) {
252
+ var u$1 = {};
253
+ e$1.exports = u$1, u$1.eastAsianWidth = function(F$1) {
254
+ var s = F$1.charCodeAt(0), i = F$1.length == 2 ? F$1.charCodeAt(1) : 0, D$1 = s;
255
+ return 55296 <= s && s <= 56319 && 56320 <= i && i <= 57343 && (s &= 1023, i &= 1023, D$1 = s << 10 | i, D$1 += 65536), D$1 == 12288 || 65281 <= D$1 && D$1 <= 65376 || 65504 <= D$1 && D$1 <= 65510 ? "F" : D$1 == 8361 || 65377 <= D$1 && D$1 <= 65470 || 65474 <= D$1 && D$1 <= 65479 || 65482 <= D$1 && D$1 <= 65487 || 65490 <= D$1 && D$1 <= 65495 || 65498 <= D$1 && D$1 <= 65500 || 65512 <= D$1 && D$1 <= 65518 ? "H" : 4352 <= D$1 && D$1 <= 4447 || 4515 <= D$1 && D$1 <= 4519 || 4602 <= D$1 && D$1 <= 4607 || 9001 <= D$1 && D$1 <= 9002 || 11904 <= D$1 && D$1 <= 11929 || 11931 <= D$1 && D$1 <= 12019 || 12032 <= D$1 && D$1 <= 12245 || 12272 <= D$1 && D$1 <= 12283 || 12289 <= D$1 && D$1 <= 12350 || 12353 <= D$1 && D$1 <= 12438 || 12441 <= D$1 && D$1 <= 12543 || 12549 <= D$1 && D$1 <= 12589 || 12593 <= D$1 && D$1 <= 12686 || 12688 <= D$1 && D$1 <= 12730 || 12736 <= D$1 && D$1 <= 12771 || 12784 <= D$1 && D$1 <= 12830 || 12832 <= D$1 && D$1 <= 12871 || 12880 <= D$1 && D$1 <= 13054 || 13056 <= D$1 && D$1 <= 19903 || 19968 <= D$1 && D$1 <= 42124 || 42128 <= D$1 && D$1 <= 42182 || 43360 <= D$1 && D$1 <= 43388 || 44032 <= D$1 && D$1 <= 55203 || 55216 <= D$1 && D$1 <= 55238 || 55243 <= D$1 && D$1 <= 55291 || 63744 <= D$1 && D$1 <= 64255 || 65040 <= D$1 && D$1 <= 65049 || 65072 <= D$1 && D$1 <= 65106 || 65108 <= D$1 && D$1 <= 65126 || 65128 <= D$1 && D$1 <= 65131 || 110592 <= D$1 && D$1 <= 110593 || 127488 <= D$1 && D$1 <= 127490 || 127504 <= D$1 && D$1 <= 127546 || 127552 <= D$1 && D$1 <= 127560 || 127568 <= D$1 && D$1 <= 127569 || 131072 <= D$1 && D$1 <= 194367 || 177984 <= D$1 && D$1 <= 196605 || 196608 <= D$1 && D$1 <= 262141 ? "W" : 32 <= D$1 && D$1 <= 126 || 162 <= D$1 && D$1 <= 163 || 165 <= D$1 && D$1 <= 166 || D$1 == 172 || D$1 == 175 || 10214 <= D$1 && D$1 <= 10221 || 10629 <= D$1 && D$1 <= 10630 ? "Na" : D$1 == 161 || D$1 == 164 || 167 <= D$1 && D$1 <= 168 || D$1 == 170 || 173 <= D$1 && D$1 <= 174 || 176 <= D$1 && D$1 <= 180 || 182 <= D$1 && D$1 <= 186 || 188 <= D$1 && D$1 <= 191 || D$1 == 198 || D$1 == 208 || 215 <= D$1 && D$1 <= 216 || 222 <= D$1 && D$1 <= 225 || D$1 == 230 || 232 <= D$1 && D$1 <= 234 || 236 <= D$1 && D$1 <= 237 || D$1 == 240 || 242 <= D$1 && D$1 <= 243 || 247 <= D$1 && D$1 <= 250 || D$1 == 252 || D$1 == 254 || D$1 == 257 || D$1 == 273 || D$1 == 275 || D$1 == 283 || 294 <= D$1 && D$1 <= 295 || D$1 == 299 || 305 <= D$1 && D$1 <= 307 || D$1 == 312 || 319 <= D$1 && D$1 <= 322 || D$1 == 324 || 328 <= D$1 && D$1 <= 331 || D$1 == 333 || 338 <= D$1 && D$1 <= 339 || 358 <= D$1 && D$1 <= 359 || D$1 == 363 || D$1 == 462 || D$1 == 464 || D$1 == 466 || D$1 == 468 || D$1 == 470 || D$1 == 472 || D$1 == 474 || D$1 == 476 || D$1 == 593 || D$1 == 609 || D$1 == 708 || D$1 == 711 || 713 <= D$1 && D$1 <= 715 || D$1 == 717 || D$1 == 720 || 728 <= D$1 && D$1 <= 731 || D$1 == 733 || D$1 == 735 || 768 <= D$1 && D$1 <= 879 || 913 <= D$1 && D$1 <= 929 || 931 <= D$1 && D$1 <= 937 || 945 <= D$1 && D$1 <= 961 || 963 <= D$1 && D$1 <= 969 || D$1 == 1025 || 1040 <= D$1 && D$1 <= 1103 || D$1 == 1105 || D$1 == 8208 || 8211 <= D$1 && D$1 <= 8214 || 8216 <= D$1 && D$1 <= 8217 || 8220 <= D$1 && D$1 <= 8221 || 8224 <= D$1 && D$1 <= 8226 || 8228 <= D$1 && D$1 <= 8231 || D$1 == 8240 || 8242 <= D$1 && D$1 <= 8243 || D$1 == 8245 || D$1 == 8251 || D$1 == 8254 || D$1 == 8308 || D$1 == 8319 || 8321 <= D$1 && D$1 <= 8324 || D$1 == 8364 || D$1 == 8451 || D$1 == 8453 || D$1 == 8457 || D$1 == 8467 || D$1 == 8470 || 8481 <= D$1 && D$1 <= 8482 || D$1 == 8486 || D$1 == 8491 || 8531 <= D$1 && D$1 <= 8532 || 8539 <= D$1 && D$1 <= 8542 || 8544 <= D$1 && D$1 <= 8555 || 8560 <= D$1 && D$1 <= 8569 || D$1 == 8585 || 8592 <= D$1 && D$1 <= 8601 || 8632 <= D$1 && D$1 <= 8633 || D$1 == 8658 || D$1 == 8660 || D$1 == 8679 || D$1 == 8704 || 8706 <= D$1 && D$1 <= 8707 || 8711 <= D$1 && D$1 <= 8712 || D$1 == 8715 || D$1 == 8719 || D$1 == 8721 || D$1 == 8725 || D$1 == 8730 || 8733 <= D$1 && D$1 <= 8736 || D$1 == 8739 || D$1 == 8741 || 8743 <= D$1 && D$1 <= 8748 || D$1 == 8750 || 8756 <= D$1 && D$1 <= 8759 || 8764 <= D$1 && D$1 <= 8765 || D$1 == 8776 || D$1 == 8780 || D$1 == 8786 || 8800 <= D$1 && D$1 <= 8801 || 8804 <= D$1 && D$1 <= 8807 || 8810 <= D$1 && D$1 <= 8811 || 8814 <= D$1 && D$1 <= 8815 || 8834 <= D$1 && D$1 <= 8835 || 8838 <= D$1 && D$1 <= 8839 || D$1 == 8853 || D$1 == 8857 || D$1 == 8869 || D$1 == 8895 || D$1 == 8978 || 9312 <= D$1 && D$1 <= 9449 || 9451 <= D$1 && D$1 <= 9547 || 9552 <= D$1 && D$1 <= 9587 || 9600 <= D$1 && D$1 <= 9615 || 9618 <= D$1 && D$1 <= 9621 || 9632 <= D$1 && D$1 <= 9633 || 9635 <= D$1 && D$1 <= 9641 || 9650 <= D$1 && D$1 <= 9651 || 9654 <= D$1 && D$1 <= 9655 || 9660 <= D$1 && D$1 <= 9661 || 9664 <= D$1 && D$1 <= 9665 || 9670 <= D$1 && D$1 <= 9672 || D$1 == 9675 || 9678 <= D$1 && D$1 <= 9681 || 9698 <= D$1 && D$1 <= 9701 || D$1 == 9711 || 9733 <= D$1 && D$1 <= 9734 || D$1 == 9737 || 9742 <= D$1 && D$1 <= 9743 || 9748 <= D$1 && D$1 <= 9749 || D$1 == 9756 || D$1 == 9758 || D$1 == 9792 || D$1 == 9794 || 9824 <= D$1 && D$1 <= 9825 || 9827 <= D$1 && D$1 <= 9829 || 9831 <= D$1 && D$1 <= 9834 || 9836 <= D$1 && D$1 <= 9837 || D$1 == 9839 || 9886 <= D$1 && D$1 <= 9887 || 9918 <= D$1 && D$1 <= 9919 || 9924 <= D$1 && D$1 <= 9933 || 9935 <= D$1 && D$1 <= 9953 || D$1 == 9955 || 9960 <= D$1 && D$1 <= 9983 || D$1 == 10045 || D$1 == 10071 || 10102 <= D$1 && D$1 <= 10111 || 11093 <= D$1 && D$1 <= 11097 || 12872 <= D$1 && D$1 <= 12879 || 57344 <= D$1 && D$1 <= 63743 || 65024 <= D$1 && D$1 <= 65039 || D$1 == 65533 || 127232 <= D$1 && D$1 <= 127242 || 127248 <= D$1 && D$1 <= 127277 || 127280 <= D$1 && D$1 <= 127337 || 127344 <= D$1 && D$1 <= 127386 || 917760 <= D$1 && D$1 <= 917999 || 983040 <= D$1 && D$1 <= 1048573 || 1048576 <= D$1 && D$1 <= 1114109 ? "A" : "N";
256
+ }, u$1.characterLength = function(F$1) {
257
+ var s = this.eastAsianWidth(F$1);
258
+ return s == "F" || s == "W" || s == "A" ? 2 : 1;
259
+ };
260
+ function t(F$1) {
261
+ return F$1.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
262
+ }
263
+ u$1.length = function(F$1) {
264
+ for (var s = t(F$1), i = 0, D$1 = 0; D$1 < s.length; D$1++) i = i + this.characterLength(s[D$1]);
265
+ return i;
266
+ }, u$1.slice = function(F$1, s, i) {
267
+ textLen = u$1.length(F$1), s = s || 0, i = i || 1, s < 0 && (s = textLen + s), i < 0 && (i = textLen + i);
268
+ for (var D$1 = "", C$1 = 0, n = t(F$1), E = 0; E < n.length; E++) {
269
+ var a$1 = n[E], o$1 = u$1.length(a$1);
270
+ if (C$1 >= s - (o$1 == 2 ? 1 : 0)) if (C$1 + o$1 <= i) D$1 += a$1;
271
+ else break;
272
+ C$1 += o$1;
273
+ }
274
+ return D$1;
275
+ };
276
+ })(W$1);
277
+ var tD = W$1.exports;
278
+ const eD = L$1(tD);
279
+ var FD = function() {
280
+ return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
281
+ };
282
+ const sD = L$1(FD);
283
+ function p(e$1, u$1 = {}) {
284
+ if (typeof e$1 != "string" || e$1.length === 0 || (u$1 = {
285
+ ambiguousIsNarrow: !0,
286
+ ...u$1
287
+ }, e$1 = P$1(e$1), e$1.length === 0)) return 0;
288
+ e$1 = e$1.replace(sD(), " ");
289
+ const t = u$1.ambiguousIsNarrow ? 1 : 2;
290
+ let F$1 = 0;
291
+ for (const s of e$1) {
292
+ const i = s.codePointAt(0);
293
+ if (i <= 31 || i >= 127 && i <= 159 || i >= 768 && i <= 879) continue;
294
+ switch (eD.eastAsianWidth(s)) {
295
+ case "F":
296
+ case "W":
297
+ F$1 += 2;
298
+ break;
299
+ case "A":
300
+ F$1 += t;
301
+ break;
302
+ default: F$1 += 1;
303
+ }
304
+ }
305
+ return F$1;
306
+ }
307
+ const w = 10, N = (e$1 = 0) => (u$1) => `\x1B[${u$1 + e$1}m`, I = (e$1 = 0) => (u$1) => `\x1B[${38 + e$1};5;${u$1}m`, R = (e$1 = 0) => (u$1, t, F$1) => `\x1B[${38 + e$1};2;${u$1};${t};${F$1}m`, r$1 = {
308
+ modifier: {
309
+ reset: [0, 0],
310
+ bold: [1, 22],
311
+ dim: [2, 22],
312
+ italic: [3, 23],
313
+ underline: [4, 24],
314
+ overline: [53, 55],
315
+ inverse: [7, 27],
316
+ hidden: [8, 28],
317
+ strikethrough: [9, 29]
318
+ },
319
+ color: {
320
+ black: [30, 39],
321
+ red: [31, 39],
322
+ green: [32, 39],
323
+ yellow: [33, 39],
324
+ blue: [34, 39],
325
+ magenta: [35, 39],
326
+ cyan: [36, 39],
327
+ white: [37, 39],
328
+ blackBright: [90, 39],
329
+ gray: [90, 39],
330
+ grey: [90, 39],
331
+ redBright: [91, 39],
332
+ greenBright: [92, 39],
333
+ yellowBright: [93, 39],
334
+ blueBright: [94, 39],
335
+ magentaBright: [95, 39],
336
+ cyanBright: [96, 39],
337
+ whiteBright: [97, 39]
338
+ },
339
+ bgColor: {
340
+ bgBlack: [40, 49],
341
+ bgRed: [41, 49],
342
+ bgGreen: [42, 49],
343
+ bgYellow: [43, 49],
344
+ bgBlue: [44, 49],
345
+ bgMagenta: [45, 49],
346
+ bgCyan: [46, 49],
347
+ bgWhite: [47, 49],
348
+ bgBlackBright: [100, 49],
349
+ bgGray: [100, 49],
350
+ bgGrey: [100, 49],
351
+ bgRedBright: [101, 49],
352
+ bgGreenBright: [102, 49],
353
+ bgYellowBright: [103, 49],
354
+ bgBlueBright: [104, 49],
355
+ bgMagentaBright: [105, 49],
356
+ bgCyanBright: [106, 49],
357
+ bgWhiteBright: [107, 49]
358
+ }
359
+ };
360
+ Object.keys(r$1.modifier);
361
+ const iD = Object.keys(r$1.color), CD = Object.keys(r$1.bgColor);
362
+ [...iD, ...CD];
363
+ function rD() {
364
+ const e$1 = /* @__PURE__ */ new Map();
365
+ for (const [u$1, t] of Object.entries(r$1)) {
366
+ for (const [F$1, s] of Object.entries(t)) r$1[F$1] = {
367
+ open: `\x1B[${s[0]}m`,
368
+ close: `\x1B[${s[1]}m`
369
+ }, t[F$1] = r$1[F$1], e$1.set(s[0], s[1]);
370
+ Object.defineProperty(r$1, u$1, {
371
+ value: t,
372
+ enumerable: !1
373
+ });
374
+ }
375
+ return Object.defineProperty(r$1, "codes", {
376
+ value: e$1,
377
+ enumerable: !1
378
+ }), r$1.color.close = "\x1B[39m", r$1.bgColor.close = "\x1B[49m", r$1.color.ansi = N(), r$1.color.ansi256 = I(), r$1.color.ansi16m = R(), r$1.bgColor.ansi = N(w), r$1.bgColor.ansi256 = I(w), r$1.bgColor.ansi16m = R(w), Object.defineProperties(r$1, {
379
+ rgbToAnsi256: {
380
+ value: (u$1, t, F$1) => u$1 === t && t === F$1 ? u$1 < 8 ? 16 : u$1 > 248 ? 231 : Math.round((u$1 - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u$1 / 255 * 5) + 6 * Math.round(t / 255 * 5) + Math.round(F$1 / 255 * 5),
381
+ enumerable: !1
382
+ },
383
+ hexToRgb: {
384
+ value: (u$1) => {
385
+ const t = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u$1.toString(16));
386
+ if (!t) return [
387
+ 0,
388
+ 0,
389
+ 0
390
+ ];
391
+ let [F$1] = t;
392
+ F$1.length === 3 && (F$1 = [...F$1].map((i) => i + i).join(""));
393
+ const s = Number.parseInt(F$1, 16);
394
+ return [
395
+ s >> 16 & 255,
396
+ s >> 8 & 255,
397
+ s & 255
398
+ ];
399
+ },
400
+ enumerable: !1
401
+ },
402
+ hexToAnsi256: {
403
+ value: (u$1) => r$1.rgbToAnsi256(...r$1.hexToRgb(u$1)),
404
+ enumerable: !1
405
+ },
406
+ ansi256ToAnsi: {
407
+ value: (u$1) => {
408
+ if (u$1 < 8) return 30 + u$1;
409
+ if (u$1 < 16) return 90 + (u$1 - 8);
410
+ let t, F$1, s;
411
+ if (u$1 >= 232) t = ((u$1 - 232) * 10 + 8) / 255, F$1 = t, s = t;
412
+ else {
413
+ u$1 -= 16;
414
+ const C$1 = u$1 % 36;
415
+ t = Math.floor(u$1 / 36) / 5, F$1 = Math.floor(C$1 / 6) / 5, s = C$1 % 6 / 5;
416
+ }
417
+ const i = Math.max(t, F$1, s) * 2;
418
+ if (i === 0) return 30;
419
+ let D$1 = 30 + (Math.round(s) << 2 | Math.round(F$1) << 1 | Math.round(t));
420
+ return i === 2 && (D$1 += 60), D$1;
421
+ },
422
+ enumerable: !1
423
+ },
424
+ rgbToAnsi: {
425
+ value: (u$1, t, F$1) => r$1.ansi256ToAnsi(r$1.rgbToAnsi256(u$1, t, F$1)),
426
+ enumerable: !1
427
+ },
428
+ hexToAnsi: {
429
+ value: (u$1) => r$1.ansi256ToAnsi(r$1.hexToAnsi256(u$1)),
430
+ enumerable: !1
431
+ }
432
+ }), r$1;
433
+ }
434
+ const ED = rD(), d$1 = new Set(["\x1B", "›"]), oD = 39, y = "\x07", V$1 = "[", nD = "]", G$1 = "m", _$1 = `${nD}8;;`, z = (e$1) => `${d$1.values().next().value}${V$1}${e$1}${G$1}`, K$1 = (e$1) => `${d$1.values().next().value}${_$1}${e$1}${y}`, aD = (e$1) => e$1.split(" ").map((u$1) => p(u$1)), k$1 = (e$1, u$1, t) => {
435
+ const F$1 = [...u$1];
436
+ let s = !1, i = !1, D$1 = p(P$1(e$1[e$1.length - 1]));
437
+ for (const [C$1, n] of F$1.entries()) {
438
+ const E = p(n);
439
+ if (D$1 + E <= t ? e$1[e$1.length - 1] += n : (e$1.push(n), D$1 = 0), d$1.has(n) && (s = !0, i = F$1.slice(C$1 + 1).join("").startsWith(_$1)), s) {
440
+ i ? n === y && (s = !1, i = !1) : n === G$1 && (s = !1);
441
+ continue;
442
+ }
443
+ D$1 += E, D$1 === t && C$1 < F$1.length - 1 && (e$1.push(""), D$1 = 0);
444
+ }
445
+ !D$1 && e$1[e$1.length - 1].length > 0 && e$1.length > 1 && (e$1[e$1.length - 2] += e$1.pop());
446
+ }, hD = (e$1) => {
447
+ const u$1 = e$1.split(" ");
448
+ let t = u$1.length;
449
+ for (; t > 0 && !(p(u$1[t - 1]) > 0);) t--;
450
+ return t === u$1.length ? e$1 : u$1.slice(0, t).join(" ") + u$1.slice(t).join("");
451
+ }, lD = (e$1, u$1, t = {}) => {
452
+ if (t.trim !== !1 && e$1.trim() === "") return "";
453
+ let F$1 = "", s, i;
454
+ const D$1 = aD(e$1);
455
+ let C$1 = [""];
456
+ for (const [E, a$1] of e$1.split(" ").entries()) {
457
+ t.trim !== !1 && (C$1[C$1.length - 1] = C$1[C$1.length - 1].trimStart());
458
+ let o$1 = p(C$1[C$1.length - 1]);
459
+ if (E !== 0 && (o$1 >= u$1 && (t.wordWrap === !1 || t.trim === !1) && (C$1.push(""), o$1 = 0), (o$1 > 0 || t.trim === !1) && (C$1[C$1.length - 1] += " ", o$1++)), t.hard && D$1[E] > u$1) {
460
+ const c = u$1 - o$1, f = 1 + Math.floor((D$1[E] - c - 1) / u$1);
461
+ Math.floor((D$1[E] - 1) / u$1) < f && C$1.push(""), k$1(C$1, a$1, u$1);
462
+ continue;
463
+ }
464
+ if (o$1 + D$1[E] > u$1 && o$1 > 0 && D$1[E] > 0) {
465
+ if (t.wordWrap === !1 && o$1 < u$1) {
466
+ k$1(C$1, a$1, u$1);
467
+ continue;
468
+ }
469
+ C$1.push("");
470
+ }
471
+ if (o$1 + D$1[E] > u$1 && t.wordWrap === !1) {
472
+ k$1(C$1, a$1, u$1);
473
+ continue;
474
+ }
475
+ C$1[C$1.length - 1] += a$1;
476
+ }
477
+ t.trim !== !1 && (C$1 = C$1.map((E) => hD(E)));
478
+ const n = [...C$1.join(`
479
+ `)];
480
+ for (const [E, a$1] of n.entries()) {
481
+ if (F$1 += a$1, d$1.has(a$1)) {
482
+ const { groups: c } = (/* @__PURE__ */ new RegExp(`(?:\\${V$1}(?<code>\\d+)m|\\${_$1}(?<uri>.*)${y})`)).exec(n.slice(E).join("")) || { groups: {} };
483
+ if (c.code !== void 0) {
484
+ const f = Number.parseFloat(c.code);
485
+ s = f === oD ? void 0 : f;
486
+ } else c.uri !== void 0 && (i = c.uri.length === 0 ? void 0 : c.uri);
487
+ }
488
+ const o$1 = ED.codes.get(Number(s));
489
+ n[E + 1] === `
490
+ ` ? (i && (F$1 += K$1("")), s && o$1 && (F$1 += z(o$1))) : a$1 === `
491
+ ` && (s && o$1 && (F$1 += z(s)), i && (F$1 += K$1(i)));
492
+ }
493
+ return F$1;
494
+ };
495
+ function Y$1(e$1, u$1, t) {
496
+ return String(e$1).normalize().replace(/\r\n/g, `
497
+ `).split(`
498
+ `).map((F$1) => lD(F$1, u$1, t)).join(`
499
+ `);
500
+ }
501
+ const B = {
502
+ actions: new Set([
503
+ "up",
504
+ "down",
505
+ "left",
506
+ "right",
507
+ "space",
508
+ "enter",
509
+ "cancel"
510
+ ]),
511
+ aliases: new Map([
512
+ ["k", "up"],
513
+ ["j", "down"],
514
+ ["h", "left"],
515
+ ["l", "right"],
516
+ ["", "cancel"],
517
+ ["escape", "cancel"]
518
+ ])
519
+ };
520
+ function $(e$1, u$1) {
521
+ if (typeof e$1 == "string") return B.aliases.get(e$1) === u$1;
522
+ for (const t of e$1) if (t !== void 0 && $(t, u$1)) return !0;
523
+ return !1;
524
+ }
525
+ function BD(e$1, u$1) {
526
+ if (e$1 === u$1) return;
527
+ const t = e$1.split(`
528
+ `), F$1 = u$1.split(`
529
+ `), s = [];
530
+ for (let i = 0; i < Math.max(t.length, F$1.length); i++) t[i] !== F$1[i] && s.push(i);
531
+ return s;
532
+ }
533
+ const AD = globalThis.process.platform.startsWith("win"), S = Symbol("clack:cancel");
534
+ function pD(e$1) {
535
+ return e$1 === S;
536
+ }
537
+ function m(e$1, u$1) {
538
+ const t = e$1;
539
+ t.isTTY && t.setRawMode(u$1);
540
+ }
541
+ function fD({ input: e$1 = stdin, output: u$1 = stdout, overwrite: t = !0, hideCursor: F$1 = !0 } = {}) {
542
+ const s = g.createInterface({
543
+ input: e$1,
544
+ output: u$1,
545
+ prompt: "",
546
+ tabSize: 1
547
+ });
548
+ g.emitKeypressEvents(e$1, s), e$1.isTTY && e$1.setRawMode(!0);
549
+ const i = (D$1, { name: C$1, sequence: n }) => {
550
+ if ($([
551
+ String(D$1),
552
+ C$1,
553
+ n
554
+ ], "cancel")) {
555
+ F$1 && u$1.write(cursor.show), process.exit(0);
556
+ return;
557
+ }
558
+ if (!t) return;
559
+ const a$1 = C$1 === "return" ? 0 : -1, o$1 = C$1 === "return" ? -1 : 0;
560
+ g.moveCursor(u$1, a$1, o$1, () => {
561
+ g.clearLine(u$1, 1, () => {
562
+ e$1.once("keypress", i);
563
+ });
564
+ });
565
+ };
566
+ return F$1 && u$1.write(cursor.hide), e$1.once("keypress", i), () => {
567
+ e$1.off("keypress", i), F$1 && u$1.write(cursor.show), e$1.isTTY && !AD && e$1.setRawMode(!1), s.terminal = !1, s.close();
568
+ };
569
+ }
570
+ var gD = Object.defineProperty, vD = (e$1, u$1, t) => u$1 in e$1 ? gD(e$1, u$1, {
571
+ enumerable: !0,
572
+ configurable: !0,
573
+ writable: !0,
574
+ value: t
575
+ }) : e$1[u$1] = t, h = (e$1, u$1, t) => (vD(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
576
+ var x$1 = class {
577
+ constructor(u$1, t = !0) {
578
+ h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", !1), h(this, "_prevFrame", ""), h(this, "_subscribers", /* @__PURE__ */ new Map()), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
579
+ const { input: F$1 = stdin, output: s = stdout, render: i, signal: D$1, ...C$1 } = u$1;
580
+ this.opts = C$1, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i.bind(this), this._track = t, this._abortSignal = D$1, this.input = F$1, this.output = s;
581
+ }
582
+ unsubscribe() {
583
+ this._subscribers.clear();
584
+ }
585
+ setSubscriber(u$1, t) {
586
+ const F$1 = this._subscribers.get(u$1) ?? [];
587
+ F$1.push(t), this._subscribers.set(u$1, F$1);
588
+ }
589
+ on(u$1, t) {
590
+ this.setSubscriber(u$1, { cb: t });
591
+ }
592
+ once(u$1, t) {
593
+ this.setSubscriber(u$1, {
594
+ cb: t,
595
+ once: !0
596
+ });
597
+ }
598
+ emit(u$1, ...t) {
599
+ const F$1 = this._subscribers.get(u$1) ?? [], s = [];
600
+ for (const i of F$1) i.cb(...t), i.once && s.push(() => F$1.splice(F$1.indexOf(i), 1));
601
+ for (const i of s) i();
602
+ }
603
+ prompt() {
604
+ return new Promise((u$1, t) => {
605
+ if (this._abortSignal) {
606
+ if (this._abortSignal.aborted) return this.state = "cancel", this.close(), u$1(S);
607
+ this._abortSignal.addEventListener("abort", () => {
608
+ this.state = "cancel", this.close();
609
+ }, { once: !0 });
610
+ }
611
+ const F$1 = new Writable();
612
+ F$1._write = (s, i, D$1) => {
613
+ this._track && (this.value = this.rl?.line.replace(/\t/g, ""), this._cursor = this.rl?.cursor ?? 0, this.emit("value", this.value)), D$1();
614
+ }, this.input.pipe(F$1), this.rl = O.createInterface({
615
+ input: this.input,
616
+ output: F$1,
617
+ tabSize: 2,
618
+ prompt: "",
619
+ escapeCodeTimeout: 50,
620
+ terminal: !0
621
+ }), O.emitKeypressEvents(this.input, this.rl), this.rl.prompt(), this.opts.initialValue !== void 0 && this._track && this.rl.write(this.opts.initialValue), this.input.on("keypress", this.onKeypress), m(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
622
+ this.output.write(cursor.show), this.output.off("resize", this.render), m(this.input, !1), u$1(this.value);
623
+ }), this.once("cancel", () => {
624
+ this.output.write(cursor.show), this.output.off("resize", this.render), m(this.input, !1), u$1(S);
625
+ });
626
+ });
627
+ }
628
+ onKeypress(u$1, t) {
629
+ if (this.state === "error" && (this.state = "active"), t?.name && (!this._track && B.aliases.has(t.name) && this.emit("cursor", B.aliases.get(t.name)), B.actions.has(t.name) && this.emit("cursor", t.name)), u$1 && (u$1.toLowerCase() === "y" || u$1.toLowerCase() === "n") && this.emit("confirm", u$1.toLowerCase() === "y"), u$1 === " " && this.opts.placeholder && (this.value || (this.rl?.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u$1 && this.emit("key", u$1.toLowerCase()), t?.name === "return") {
630
+ if (this.opts.validate) {
631
+ const F$1 = this.opts.validate(this.value);
632
+ F$1 && (this.error = F$1 instanceof Error ? F$1.message : F$1, this.state = "error", this.rl?.write(this.value));
633
+ }
634
+ this.state !== "error" && (this.state = "submit");
635
+ }
636
+ $([
637
+ u$1,
638
+ t?.name,
639
+ t?.sequence
640
+ ], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
641
+ }
642
+ close() {
643
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
644
+ `), m(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
645
+ }
646
+ restoreCursor() {
647
+ const u$1 = Y$1(this._prevFrame, process.stdout.columns, { hard: !0 }).split(`
648
+ `).length - 1;
649
+ this.output.write(cursor.move(-999, u$1 * -1));
650
+ }
651
+ render() {
652
+ const u$1 = Y$1(this._render(this) ?? "", process.stdout.columns, { hard: !0 });
653
+ if (u$1 !== this._prevFrame) {
654
+ if (this.state === "initial") this.output.write(cursor.hide);
655
+ else {
656
+ const t = BD(this._prevFrame, u$1);
657
+ if (this.restoreCursor(), t && t?.length === 1) {
658
+ const F$1 = t[0];
659
+ this.output.write(cursor.move(0, F$1)), this.output.write(erase.lines(1));
660
+ const s = u$1.split(`
661
+ `);
662
+ this.output.write(s[F$1]), this._prevFrame = u$1, this.output.write(cursor.move(0, s.length - F$1 - 1));
663
+ return;
664
+ }
665
+ if (t && t?.length > 1) {
666
+ const F$1 = t[0];
667
+ this.output.write(cursor.move(0, F$1)), this.output.write(erase.down());
668
+ const s = u$1.split(`
669
+ `).slice(F$1);
670
+ this.output.write(s.join(`
671
+ `)), this._prevFrame = u$1;
672
+ return;
673
+ }
674
+ this.output.write(erase.down());
675
+ }
676
+ this.output.write(u$1), this.state === "initial" && (this.state = "active"), this._prevFrame = u$1;
677
+ }
678
+ }
679
+ };
680
+ var dD = class extends x$1 {
681
+ get cursor() {
682
+ return this.value ? 0 : 1;
683
+ }
684
+ get _value() {
685
+ return this.cursor === 0;
686
+ }
687
+ constructor(u$1) {
688
+ super(u$1, !1), this.value = !!u$1.initialValue, this.on("value", () => {
689
+ this.value = this._value;
690
+ }), this.on("confirm", (t) => {
691
+ this.output.write(cursor.move(0, -1)), this.value = t, this.state = "submit", this.close();
692
+ }), this.on("cursor", () => {
693
+ this.value = !this.value;
694
+ });
695
+ }
696
+ };
697
+ var mD = Object.defineProperty, bD = (e$1, u$1, t) => u$1 in e$1 ? mD(e$1, u$1, {
698
+ enumerable: !0,
699
+ configurable: !0,
700
+ writable: !0,
701
+ value: t
702
+ }) : e$1[u$1] = t, Z = (e$1, u$1, t) => (bD(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t), q$1 = (e$1, u$1, t) => {
703
+ if (!u$1.has(e$1)) throw TypeError("Cannot " + t);
704
+ }, T$1 = (e$1, u$1, t) => (q$1(e$1, u$1, "read from private field"), t ? t.call(e$1) : u$1.get(e$1)), wD = (e$1, u$1, t) => {
705
+ if (u$1.has(e$1)) throw TypeError("Cannot add the same private member more than once");
706
+ u$1 instanceof WeakSet ? u$1.add(e$1) : u$1.set(e$1, t);
707
+ }, yD = (e$1, u$1, t, F$1) => (q$1(e$1, u$1, "write to private field"), F$1 ? F$1.call(e$1, t) : u$1.set(e$1, t), t), A$1;
708
+ let _D = class extends x$1 {
709
+ constructor(u$1) {
710
+ super(u$1, !1), Z(this, "options"), Z(this, "cursor", 0), wD(this, A$1, void 0);
711
+ const { options: t } = u$1;
712
+ yD(this, A$1, u$1.selectableGroups !== !1), this.options = Object.entries(t).flatMap(([F$1, s]) => [{
713
+ value: F$1,
714
+ group: !0,
715
+ label: F$1
716
+ }, ...s.map((i) => ({
717
+ ...i,
718
+ group: F$1
719
+ }))]), this.value = [...u$1.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: F$1 }) => F$1 === u$1.cursorAt), T$1(this, A$1) ? 0 : 1), this.on("cursor", (F$1) => {
720
+ switch (F$1) {
721
+ case "left":
722
+ case "up": {
723
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
724
+ const s = this.options[this.cursor]?.group === !0;
725
+ !T$1(this, A$1) && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
726
+ break;
727
+ }
728
+ case "down":
729
+ case "right": {
730
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
731
+ const s = this.options[this.cursor]?.group === !0;
732
+ !T$1(this, A$1) && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
733
+ break;
734
+ }
735
+ case "space":
736
+ this.toggleValue();
737
+ break;
738
+ }
739
+ });
740
+ }
741
+ getGroupItems(u$1) {
742
+ return this.options.filter((t) => t.group === u$1);
743
+ }
744
+ isGroupSelected(u$1) {
745
+ return this.getGroupItems(u$1).every((t) => this.value.includes(t.value));
746
+ }
747
+ toggleValue() {
748
+ const u$1 = this.options[this.cursor];
749
+ if (u$1.group === !0) {
750
+ const t = u$1.value, F$1 = this.getGroupItems(t);
751
+ this.isGroupSelected(t) ? this.value = this.value.filter((s) => F$1.findIndex((i) => i.value === s) === -1) : this.value = [...this.value, ...F$1.map((s) => s.value)], this.value = Array.from(new Set(this.value));
752
+ } else this.value = this.value.includes(u$1.value) ? this.value.filter((F$1) => F$1 !== u$1.value) : [...this.value, u$1.value];
753
+ }
754
+ };
755
+ A$1 = /* @__PURE__ */ new WeakMap();
756
+ var kD = Object.defineProperty, $D = (e$1, u$1, t) => u$1 in e$1 ? kD(e$1, u$1, {
757
+ enumerable: !0,
758
+ configurable: !0,
759
+ writable: !0,
760
+ value: t
761
+ }) : e$1[u$1] = t, H = (e$1, u$1, t) => ($D(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
762
+ let SD = class extends x$1 {
763
+ constructor(u$1) {
764
+ super(u$1, !1), H(this, "options"), H(this, "cursor", 0), this.options = u$1.options, this.value = [...u$1.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: t }) => t === u$1.cursorAt), 0), this.on("key", (t) => {
765
+ t === "a" && this.toggleAll();
766
+ }), this.on("cursor", (t) => {
767
+ switch (t) {
768
+ case "left":
769
+ case "up":
770
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
771
+ break;
772
+ case "down":
773
+ case "right":
774
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
775
+ break;
776
+ case "space":
777
+ this.toggleValue();
778
+ break;
779
+ }
780
+ });
781
+ }
782
+ get _value() {
783
+ return this.options[this.cursor].value;
784
+ }
785
+ toggleAll() {
786
+ this.value = this.value.length === this.options.length ? [] : this.options.map((t) => t.value);
787
+ }
788
+ toggleValue() {
789
+ this.value = this.value.includes(this._value) ? this.value.filter((t) => t !== this._value) : [...this.value, this._value];
790
+ }
791
+ };
792
+ var TD = Object.defineProperty, jD = (e$1, u$1, t) => u$1 in e$1 ? TD(e$1, u$1, {
793
+ enumerable: !0,
794
+ configurable: !0,
795
+ writable: !0,
796
+ value: t
797
+ }) : e$1[u$1] = t, U$1 = (e$1, u$1, t) => (jD(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
798
+ var MD = class extends x$1 {
799
+ constructor({ mask: u$1, ...t }) {
800
+ super(t), U$1(this, "valueWithCursor", ""), U$1(this, "_mask", "•"), this._mask = u$1 ?? "•", this.on("finalize", () => {
801
+ this.valueWithCursor = this.masked;
802
+ }), this.on("value", () => {
803
+ if (this.cursor >= this.value.length) this.valueWithCursor = `${this.masked}${e.inverse(e.hidden("_"))}`;
804
+ else {
805
+ const F$1 = this.masked.slice(0, this.cursor), s = this.masked.slice(this.cursor);
806
+ this.valueWithCursor = `${F$1}${e.inverse(s[0])}${s.slice(1)}`;
807
+ }
808
+ });
809
+ }
810
+ get cursor() {
811
+ return this._cursor;
812
+ }
813
+ get masked() {
814
+ return this.value.replaceAll(/./g, this._mask);
815
+ }
816
+ };
817
+ var OD = Object.defineProperty, PD = (e$1, u$1, t) => u$1 in e$1 ? OD(e$1, u$1, {
818
+ enumerable: !0,
819
+ configurable: !0,
820
+ writable: !0,
821
+ value: t
822
+ }) : e$1[u$1] = t, J$1 = (e$1, u$1, t) => (PD(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
823
+ var LD = class extends x$1 {
824
+ constructor(u$1) {
825
+ super(u$1, !1), J$1(this, "options"), J$1(this, "cursor", 0), this.options = u$1.options, this.cursor = this.options.findIndex(({ value: t }) => t === u$1.initialValue), this.cursor === -1 && (this.cursor = 0), this.changeValue(), this.on("cursor", (t) => {
826
+ switch (t) {
827
+ case "left":
828
+ case "up":
829
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
830
+ break;
831
+ case "down":
832
+ case "right":
833
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
834
+ break;
835
+ }
836
+ this.changeValue();
837
+ });
838
+ }
839
+ get _value() {
840
+ return this.options[this.cursor];
841
+ }
842
+ changeValue() {
843
+ this.value = this._value.value;
844
+ }
845
+ };
846
+ var WD = Object.defineProperty, ND = (e$1, u$1, t) => u$1 in e$1 ? WD(e$1, u$1, {
847
+ enumerable: !0,
848
+ configurable: !0,
849
+ writable: !0,
850
+ value: t
851
+ }) : e$1[u$1] = t, Q = (e$1, u$1, t) => (ND(e$1, typeof u$1 != "symbol" ? u$1 + "" : u$1, t), t);
852
+ var ID = class extends x$1 {
853
+ constructor(u$1) {
854
+ super(u$1, !1), Q(this, "options"), Q(this, "cursor", 0), this.options = u$1.options;
855
+ const t = this.options.map(({ value: [F$1] }) => F$1?.toLowerCase());
856
+ this.cursor = Math.max(t.indexOf(u$1.initialValue), 0), this.on("key", (F$1) => {
857
+ if (!t.includes(F$1)) return;
858
+ const s = this.options.find(({ value: [i] }) => i?.toLowerCase() === F$1);
859
+ s && (this.value = s.value, this.state = "submit", this.emit("submit"));
860
+ });
861
+ }
862
+ };
863
+ var RD = class extends x$1 {
864
+ get valueWithCursor() {
865
+ if (this.state === "submit") return this.value;
866
+ if (this.cursor >= this.value.length) return `${this.value}\u2588`;
867
+ const u$1 = this.value.slice(0, this.cursor), [t, ...F$1] = this.value.slice(this.cursor);
868
+ return `${u$1}${e.inverse(t)}${F$1.join("")}`;
869
+ }
870
+ get cursor() {
871
+ return this._cursor;
872
+ }
873
+ constructor(u$1) {
874
+ super(u$1), this.on("finalize", () => {
875
+ this.value || (this.value = u$1.defaultValue);
876
+ });
877
+ }
878
+ };
879
+
880
+ //#endregion
881
+ //#region ../../node_modules/.pnpm/@clack+prompts@0.11.0/node_modules/@clack/prompts/dist/index.mjs
882
+ function ce() {
883
+ 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";
884
+ }
885
+ const V = ce(), u = (t, n) => V ? t : n, le = u("◆", "*"), L = u("■", "x"), W = u("▲", "x"), C = u("◇", "o"), ue = u("┌", "T"), o = u("│", "|"), d = u("└", "—"), k = u("●", ">"), P = u("○", " "), A = u("◻", "[•]"), T = u("◼", "[+]"), F = u("◻", "[ ]"), $e = u("▪", "•"), _ = u("─", "-"), me = u("╮", "+"), de = u("├", "+"), pe = u("╯", "+"), q = u("●", "•"), D = u("◆", "*"), U = u("▲", "!"), K = u("■", "x"), b = (t) => {
886
+ switch (t) {
887
+ case "initial":
888
+ case "active": return e.cyan(le);
889
+ case "cancel": return e.red(L);
890
+ case "error": return e.yellow(W);
891
+ case "submit": return e.green(C);
892
+ }
893
+ }, G = (t) => {
894
+ const { cursor: n, options: r$2, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a$1 = Math.min(c, Math.max(s, 5));
895
+ let l = 0;
896
+ n >= l + a$1 - 3 ? l = Math.max(Math.min(n - a$1 + 3, r$2.length - a$1), 0) : n < l + 2 && (l = Math.max(n - 2, 0));
897
+ const $$1 = a$1 < r$2.length && l > 0, g$1 = a$1 < r$2.length && l + a$1 < r$2.length;
898
+ return r$2.slice(l, l + a$1).map((p$1, v, f) => {
899
+ const j = v === 0 && $$1, E = v === f.length - 1 && g$1;
900
+ return j || E ? e.dim("...") : i(p$1, v + l === n);
901
+ });
902
+ }, he = (t) => new RD({
903
+ validate: t.validate,
904
+ placeholder: t.placeholder,
905
+ defaultValue: t.defaultValue,
906
+ initialValue: t.initialValue,
907
+ render() {
908
+ const n = `${e.gray(o)}
909
+ ${b(this.state)} ${t.message}
910
+ `, r$2 = t.placeholder ? e.inverse(t.placeholder[0]) + e.dim(t.placeholder.slice(1)) : e.inverse(e.hidden("_")), i = this.value ? this.valueWithCursor : r$2;
911
+ switch (this.state) {
912
+ case "error": return `${n.trim()}
913
+ ${e.yellow(o)} ${i}
914
+ ${e.yellow(d)} ${e.yellow(this.error)}
915
+ `;
916
+ case "submit": return `${n}${e.gray(o)} ${e.dim(this.value || t.placeholder)}`;
917
+ case "cancel": return `${n}${e.gray(o)} ${e.strikethrough(e.dim(this.value ?? ""))}${this.value?.trim() ? `
918
+ ${e.gray(o)}` : ""}`;
919
+ default: return `${n}${e.cyan(o)} ${i}
920
+ ${e.cyan(d)}
921
+ `;
922
+ }
923
+ }
924
+ }).prompt(), ge = (t) => new MD({
925
+ validate: t.validate,
926
+ mask: t.mask ?? $e,
927
+ render() {
928
+ const n = `${e.gray(o)}
929
+ ${b(this.state)} ${t.message}
930
+ `, r$2 = this.valueWithCursor, i = this.masked;
931
+ switch (this.state) {
932
+ case "error": return `${n.trim()}
933
+ ${e.yellow(o)} ${i}
934
+ ${e.yellow(d)} ${e.yellow(this.error)}
935
+ `;
936
+ case "submit": return `${n}${e.gray(o)} ${e.dim(i)}`;
937
+ case "cancel": return `${n}${e.gray(o)} ${e.strikethrough(e.dim(i ?? ""))}${i ? `
938
+ ${e.gray(o)}` : ""}`;
939
+ default: return `${n}${e.cyan(o)} ${r$2}
940
+ ${e.cyan(d)}
941
+ `;
942
+ }
943
+ }
944
+ }).prompt(), ye = (t) => {
945
+ const n = t.active ?? "Yes", r$2 = t.inactive ?? "No";
946
+ return new dD({
947
+ active: n,
948
+ inactive: r$2,
949
+ initialValue: t.initialValue ?? !0,
950
+ render() {
951
+ const i = `${e.gray(o)}
952
+ ${b(this.state)} ${t.message}
953
+ `, s = this.value ? n : r$2;
954
+ switch (this.state) {
955
+ case "submit": return `${i}${e.gray(o)} ${e.dim(s)}`;
956
+ case "cancel": return `${i}${e.gray(o)} ${e.strikethrough(e.dim(s))}
957
+ ${e.gray(o)}`;
958
+ default: return `${i}${e.cyan(o)} ${this.value ? `${e.green(k)} ${n}` : `${e.dim(P)} ${e.dim(n)}`} ${e.dim("/")} ${this.value ? `${e.dim(P)} ${e.dim(r$2)}` : `${e.green(k)} ${r$2}`}
959
+ ${e.cyan(d)}
960
+ `;
961
+ }
962
+ }
963
+ }).prompt();
964
+ }, ve = (t) => {
965
+ const n = (r$2, i) => {
966
+ const s = r$2.label ?? String(r$2.value);
967
+ switch (i) {
968
+ case "selected": return `${e.dim(s)}`;
969
+ case "active": return `${e.green(k)} ${s} ${r$2.hint ? e.dim(`(${r$2.hint})`) : ""}`;
970
+ case "cancelled": return `${e.strikethrough(e.dim(s))}`;
971
+ default: return `${e.dim(P)} ${e.dim(s)}`;
972
+ }
973
+ };
974
+ return new LD({
975
+ options: t.options,
976
+ initialValue: t.initialValue,
977
+ render() {
978
+ const r$2 = `${e.gray(o)}
979
+ ${b(this.state)} ${t.message}
980
+ `;
981
+ switch (this.state) {
982
+ case "submit": return `${r$2}${e.gray(o)} ${n(this.options[this.cursor], "selected")}`;
983
+ case "cancel": return `${r$2}${e.gray(o)} ${n(this.options[this.cursor], "cancelled")}
984
+ ${e.gray(o)}`;
985
+ default: return `${r$2}${e.cyan(o)} ${G({
986
+ cursor: this.cursor,
987
+ options: this.options,
988
+ maxItems: t.maxItems,
989
+ style: (i, s) => n(i, s ? "active" : "inactive")
990
+ }).join(`
991
+ ${e.cyan(o)} `)}
992
+ ${e.cyan(d)}
993
+ `;
994
+ }
995
+ }
996
+ }).prompt();
997
+ }, we = (t) => {
998
+ const n = (r$2, i = "inactive") => {
999
+ const s = r$2.label ?? String(r$2.value);
1000
+ return i === "selected" ? `${e.dim(s)}` : i === "cancelled" ? `${e.strikethrough(e.dim(s))}` : i === "active" ? `${e.bgCyan(e.gray(` ${r$2.value} `))} ${s} ${r$2.hint ? e.dim(`(${r$2.hint})`) : ""}` : `${e.gray(e.bgWhite(e.inverse(` ${r$2.value} `)))} ${s} ${r$2.hint ? e.dim(`(${r$2.hint})`) : ""}`;
1001
+ };
1002
+ return new ID({
1003
+ options: t.options,
1004
+ initialValue: t.initialValue,
1005
+ render() {
1006
+ const r$2 = `${e.gray(o)}
1007
+ ${b(this.state)} ${t.message}
1008
+ `;
1009
+ switch (this.state) {
1010
+ case "submit": return `${r$2}${e.gray(o)} ${n(this.options.find((i) => i.value === this.value) ?? t.options[0], "selected")}`;
1011
+ case "cancel": return `${r$2}${e.gray(o)} ${n(this.options[0], "cancelled")}
1012
+ ${e.gray(o)}`;
1013
+ default: return `${r$2}${e.cyan(o)} ${this.options.map((i, s) => n(i, s === this.cursor ? "active" : "inactive")).join(`
1014
+ ${e.cyan(o)} `)}
1015
+ ${e.cyan(d)}
1016
+ `;
1017
+ }
1018
+ }
1019
+ }).prompt();
1020
+ }, fe = (t) => {
1021
+ const n = (r$2, i) => {
1022
+ const s = r$2.label ?? String(r$2.value);
1023
+ return i === "active" ? `${e.cyan(A)} ${s} ${r$2.hint ? e.dim(`(${r$2.hint})`) : ""}` : i === "selected" ? `${e.green(T)} ${e.dim(s)} ${r$2.hint ? e.dim(`(${r$2.hint})`) : ""}` : i === "cancelled" ? `${e.strikethrough(e.dim(s))}` : i === "active-selected" ? `${e.green(T)} ${s} ${r$2.hint ? e.dim(`(${r$2.hint})`) : ""}` : i === "submitted" ? `${e.dim(s)}` : `${e.dim(F)} ${e.dim(s)}`;
1024
+ };
1025
+ return new SD({
1026
+ options: t.options,
1027
+ initialValues: t.initialValues,
1028
+ required: t.required ?? !0,
1029
+ cursorAt: t.cursorAt,
1030
+ validate(r$2) {
1031
+ if (this.required && r$2.length === 0) return `Please select at least one option.
1032
+ ${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`;
1033
+ },
1034
+ render() {
1035
+ const r$2 = `${e.gray(o)}
1036
+ ${b(this.state)} ${t.message}
1037
+ `, i = (s, c) => {
1038
+ const a$1 = this.value.includes(s.value);
1039
+ return c && a$1 ? n(s, "active-selected") : a$1 ? n(s, "selected") : n(s, c ? "active" : "inactive");
1040
+ };
1041
+ switch (this.state) {
1042
+ case "submit": return `${r$2}${e.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(e.dim(", ")) || e.dim("none")}`;
1043
+ case "cancel": {
1044
+ const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(e.dim(", "));
1045
+ return `${r$2}${e.gray(o)} ${s.trim() ? `${s}
1046
+ ${e.gray(o)}` : ""}`;
1047
+ }
1048
+ case "error": {
1049
+ const s = this.error.split(`
1050
+ `).map((c, a$1) => a$1 === 0 ? `${e.yellow(d)} ${e.yellow(c)}` : ` ${c}`).join(`
1051
+ `);
1052
+ return `${r$2 + e.yellow(o)} ${G({
1053
+ options: this.options,
1054
+ cursor: this.cursor,
1055
+ maxItems: t.maxItems,
1056
+ style: i
1057
+ }).join(`
1058
+ ${e.yellow(o)} `)}
1059
+ ${s}
1060
+ `;
1061
+ }
1062
+ default: return `${r$2}${e.cyan(o)} ${G({
1063
+ options: this.options,
1064
+ cursor: this.cursor,
1065
+ maxItems: t.maxItems,
1066
+ style: i
1067
+ }).join(`
1068
+ ${e.cyan(o)} `)}
1069
+ ${e.cyan(d)}
1070
+ `;
1071
+ }
1072
+ }
1073
+ }).prompt();
1074
+ }, be = (t) => {
1075
+ const { selectableGroups: n = !0 } = t, r$2 = (i, s, c = []) => {
1076
+ const a$1 = i.label ?? String(i.value), l = typeof i.group == "string", $$1 = l && (c[c.indexOf(i) + 1] ?? { group: !0 }), g$1 = l && $$1.group === !0, p$1 = l ? n ? `${g$1 ? d : o} ` : " " : "";
1077
+ if (s === "active") return `${e.dim(p$1)}${e.cyan(A)} ${a$1} ${i.hint ? e.dim(`(${i.hint})`) : ""}`;
1078
+ if (s === "group-active") return `${p$1}${e.cyan(A)} ${e.dim(a$1)}`;
1079
+ if (s === "group-active-selected") return `${p$1}${e.green(T)} ${e.dim(a$1)}`;
1080
+ if (s === "selected") {
1081
+ const f = l || n ? e.green(T) : "";
1082
+ return `${e.dim(p$1)}${f} ${e.dim(a$1)} ${i.hint ? e.dim(`(${i.hint})`) : ""}`;
1083
+ }
1084
+ if (s === "cancelled") return `${e.strikethrough(e.dim(a$1))}`;
1085
+ if (s === "active-selected") return `${e.dim(p$1)}${e.green(T)} ${a$1} ${i.hint ? e.dim(`(${i.hint})`) : ""}`;
1086
+ if (s === "submitted") return `${e.dim(a$1)}`;
1087
+ const v = l || n ? e.dim(F) : "";
1088
+ return `${e.dim(p$1)}${v} ${e.dim(a$1)}`;
1089
+ };
1090
+ return new _D({
1091
+ options: t.options,
1092
+ initialValues: t.initialValues,
1093
+ required: t.required ?? !0,
1094
+ cursorAt: t.cursorAt,
1095
+ selectableGroups: n,
1096
+ validate(i) {
1097
+ if (this.required && i.length === 0) return `Please select at least one option.
1098
+ ${e.reset(e.dim(`Press ${e.gray(e.bgWhite(e.inverse(" space ")))} to select, ${e.gray(e.bgWhite(e.inverse(" enter ")))} to submit`))}`;
1099
+ },
1100
+ render() {
1101
+ const i = `${e.gray(o)}
1102
+ ${b(this.state)} ${t.message}
1103
+ `;
1104
+ switch (this.state) {
1105
+ case "submit": return `${i}${e.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => r$2(s, "submitted")).join(e.dim(", "))}`;
1106
+ case "cancel": {
1107
+ const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => r$2(c, "cancelled")).join(e.dim(", "));
1108
+ return `${i}${e.gray(o)} ${s.trim() ? `${s}
1109
+ ${e.gray(o)}` : ""}`;
1110
+ }
1111
+ case "error": {
1112
+ const s = this.error.split(`
1113
+ `).map((c, a$1) => a$1 === 0 ? `${e.yellow(d)} ${e.yellow(c)}` : ` ${c}`).join(`
1114
+ `);
1115
+ return `${i}${e.yellow(o)} ${this.options.map((c, a$1, l) => {
1116
+ const $$1 = this.value.includes(c.value) || c.group === !0 && this.isGroupSelected(`${c.value}`), g$1 = a$1 === this.cursor;
1117
+ return !g$1 && typeof c.group == "string" && this.options[this.cursor].value === c.group ? r$2(c, $$1 ? "group-active-selected" : "group-active", l) : g$1 && $$1 ? r$2(c, "active-selected", l) : $$1 ? r$2(c, "selected", l) : r$2(c, g$1 ? "active" : "inactive", l);
1118
+ }).join(`
1119
+ ${e.yellow(o)} `)}
1120
+ ${s}
1121
+ `;
1122
+ }
1123
+ default: return `${i}${e.cyan(o)} ${this.options.map((s, c, a$1) => {
1124
+ const l = this.value.includes(s.value) || s.group === !0 && this.isGroupSelected(`${s.value}`), $$1 = c === this.cursor;
1125
+ return !$$1 && typeof s.group == "string" && this.options[this.cursor].value === s.group ? r$2(s, l ? "group-active-selected" : "group-active", a$1) : $$1 && l ? r$2(s, "active-selected", a$1) : l ? r$2(s, "selected", a$1) : r$2(s, $$1 ? "active" : "inactive", a$1);
1126
+ }).join(`
1127
+ ${e.cyan(o)} `)}
1128
+ ${e.cyan(d)}
1129
+ `;
1130
+ }
1131
+ }
1132
+ }).prompt();
1133
+ }, Me = (t = "", n = "") => {
1134
+ const r$2 = `
1135
+ ${t}
1136
+ `.split(`
1137
+ `), i = stripVTControlCharacters(n).length, s = Math.max(r$2.reduce((a$1, l) => {
1138
+ const $$1 = stripVTControlCharacters(l);
1139
+ return $$1.length > a$1 ? $$1.length : a$1;
1140
+ }, 0), i) + 2, c = r$2.map((a$1) => `${e.gray(o)} ${e.dim(a$1)}${" ".repeat(s - stripVTControlCharacters(a$1).length)}${e.gray(o)}`).join(`
1141
+ `);
1142
+ process.stdout.write(`${e.gray(o)}
1143
+ ${e.green(C)} ${e.reset(n)} ${e.gray(_.repeat(Math.max(s - i - 1, 1)) + me)}
1144
+ ${c}
1145
+ ${e.gray(de + _.repeat(s + 2) + pe)}
1146
+ `);
1147
+ }, xe = (t = "") => {
1148
+ process.stdout.write(`${e.gray(d)} ${e.red(t)}
1149
+
1150
+ `);
1151
+ }, Ie = (t = "") => {
1152
+ process.stdout.write(`${e.gray(ue)} ${t}
1153
+ `);
1154
+ }, Se = (t = "") => {
1155
+ process.stdout.write(`${e.gray(o)}
1156
+ ${e.gray(d)} ${t}
1157
+
1158
+ `);
1159
+ }, M = {
1160
+ message: (t = "", { symbol: n = e.gray(o) } = {}) => {
1161
+ const r$2 = [`${e.gray(o)}`];
1162
+ if (t) {
1163
+ const [i, ...s] = t.split(`
1164
+ `);
1165
+ r$2.push(`${n} ${i}`, ...s.map((c) => `${e.gray(o)} ${c}`));
1166
+ }
1167
+ process.stdout.write(`${r$2.join(`
1168
+ `)}
1169
+ `);
1170
+ },
1171
+ info: (t) => {
1172
+ M.message(t, { symbol: e.blue(q) });
1173
+ },
1174
+ success: (t) => {
1175
+ M.message(t, { symbol: e.green(D) });
1176
+ },
1177
+ step: (t) => {
1178
+ M.message(t, { symbol: e.green(C) });
1179
+ },
1180
+ warn: (t) => {
1181
+ M.message(t, { symbol: e.yellow(U) });
1182
+ },
1183
+ warning: (t) => {
1184
+ M.warn(t);
1185
+ },
1186
+ error: (t) => {
1187
+ M.message(t, { symbol: e.red(K) });
1188
+ }
1189
+ }, J = `${e.gray(o)} `, x = {
1190
+ message: async (t, { symbol: n = e.gray(o) } = {}) => {
1191
+ process.stdout.write(`${e.gray(o)}
1192
+ ${n} `);
1193
+ let r$2 = 3;
1194
+ for await (let i of t) {
1195
+ i = i.replace(/\n/g, `
1196
+ ${J}`), i.includes(`
1197
+ `) && (r$2 = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
1198
+ `))).length);
1199
+ const s = stripVTControlCharacters(i).length;
1200
+ r$2 + s < process.stdout.columns ? (r$2 += s, process.stdout.write(i)) : (process.stdout.write(`
1201
+ ${J}${i.trimStart()}`), r$2 = 3 + stripVTControlCharacters(i.trimStart()).length);
1202
+ }
1203
+ process.stdout.write(`
1204
+ `);
1205
+ },
1206
+ info: (t) => x.message(t, { symbol: e.blue(q) }),
1207
+ success: (t) => x.message(t, { symbol: e.green(D) }),
1208
+ step: (t) => x.message(t, { symbol: e.green(C) }),
1209
+ warn: (t) => x.message(t, { symbol: e.yellow(U) }),
1210
+ warning: (t) => x.warn(t),
1211
+ error: (t) => x.message(t, { symbol: e.red(K) })
1212
+ }, Y = ({ indicator: t = "dots" } = {}) => {
1213
+ const n = V ? [
1214
+ "◒",
1215
+ "◐",
1216
+ "◓",
1217
+ "◑"
1218
+ ] : [
1219
+ "•",
1220
+ "o",
1221
+ "O",
1222
+ "0"
1223
+ ], r$2 = V ? 80 : 120, i = process.env.CI === "true";
1224
+ let s, c, a$1 = !1, l = "", $$1, g$1 = performance.now();
1225
+ const p$1 = (m$1) => {
1226
+ a$1 && N$1(m$1 > 1 ? "Something went wrong" : "Canceled", m$1);
1227
+ }, v = () => p$1(2), f = () => p$1(1), j = () => {
1228
+ process.on("uncaughtExceptionMonitor", v), process.on("unhandledRejection", v), process.on("SIGINT", f), process.on("SIGTERM", f), process.on("exit", p$1);
1229
+ }, E = () => {
1230
+ process.removeListener("uncaughtExceptionMonitor", v), process.removeListener("unhandledRejection", v), process.removeListener("SIGINT", f), process.removeListener("SIGTERM", f), process.removeListener("exit", p$1);
1231
+ }, B$1 = () => {
1232
+ if ($$1 === void 0) return;
1233
+ i && process.stdout.write(`
1234
+ `);
1235
+ const m$1 = $$1.split(`
1236
+ `);
1237
+ process.stdout.write(cursor.move(-999, m$1.length - 1)), process.stdout.write(erase.down(m$1.length));
1238
+ }, R$1 = (m$1) => m$1.replace(/\.+$/, ""), O$1 = (m$1) => {
1239
+ const h$1 = (performance.now() - m$1) / 1e3, w$1 = Math.floor(h$1 / 60), I$1 = Math.floor(h$1 % 60);
1240
+ return w$1 > 0 ? `[${w$1}m ${I$1}s]` : `[${I$1}s]`;
1241
+ }, H$1 = (m$1 = "") => {
1242
+ a$1 = !0, s = fD(), l = R$1(m$1), g$1 = performance.now(), process.stdout.write(`${e.gray(o)}
1243
+ `);
1244
+ let h$1 = 0, w$1 = 0;
1245
+ j(), c = setInterval(() => {
1246
+ if (i && l === $$1) return;
1247
+ B$1(), $$1 = l;
1248
+ const I$1 = e.magenta(n[h$1]);
1249
+ if (i) process.stdout.write(`${I$1} ${l}...`);
1250
+ else if (t === "timer") process.stdout.write(`${I$1} ${l} ${O$1(g$1)}`);
1251
+ else {
1252
+ const z$1 = ".".repeat(Math.floor(w$1)).slice(0, 3);
1253
+ process.stdout.write(`${I$1} ${l}${z$1}`);
1254
+ }
1255
+ h$1 = h$1 + 1 < n.length ? h$1 + 1 : 0, w$1 = w$1 < n.length ? w$1 + .125 : 0;
1256
+ }, r$2);
1257
+ }, N$1 = (m$1 = "", h$1 = 0) => {
1258
+ a$1 = !1, clearInterval(c), B$1();
1259
+ const w$1 = h$1 === 0 ? e.green(C) : h$1 === 1 ? e.red(L) : e.red(W);
1260
+ l = R$1(m$1 ?? l), t === "timer" ? process.stdout.write(`${w$1} ${l} ${O$1(g$1)}
1261
+ `) : process.stdout.write(`${w$1} ${l}
1262
+ `), E(), s();
1263
+ };
1264
+ return {
1265
+ start: H$1,
1266
+ stop: N$1,
1267
+ message: (m$1 = "") => {
1268
+ l = R$1(m$1 ?? l);
1269
+ }
1270
+ };
1271
+ }, Ce = async (t, n) => {
1272
+ const r$2 = {}, i = Object.keys(t);
1273
+ for (const s of i) {
1274
+ const c = t[s], a$1 = await c({ results: r$2 })?.catch((l) => {
1275
+ throw l;
1276
+ });
1277
+ if (typeof n?.onCancel == "function" && pD(a$1)) {
1278
+ r$2[s] = "canceled", n.onCancel({ results: r$2 });
1279
+ continue;
1280
+ }
1281
+ r$2[s] = a$1;
1282
+ }
1283
+ return r$2;
1284
+ }, Te = async (t) => {
1285
+ for (const n of t) {
1286
+ if (n.enabled === !1) continue;
1287
+ const r$2 = Y();
1288
+ r$2.start(n.title);
1289
+ const i = await n.task(r$2.message);
1290
+ r$2.stop(i || n.title);
1291
+ }
1292
+ };
1293
+
1294
+ //#endregion
1295
+ //#region ../../node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.cjs
1296
+ var require_ansis = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1297
+ let e, t, r, { defineProperty: l, setPrototypeOf: n, create: o, keys: s } = Object, i = "", { round: c, max: a } = Math, p = (e$1) => {
1298
+ let t = /([a-f\d]{3,6})/i.exec(e$1)?.[1], r$2 = t?.length, l = parseInt(6 ^ r$2 ? 3 ^ r$2 ? "0" : t[0] + t[0] + t[1] + t[1] + t[2] + t[2] : t, 16);
1299
+ return [
1300
+ l >> 16 & 255,
1301
+ l >> 8 & 255,
1302
+ 255 & l
1303
+ ];
1304
+ }, u = (e$1, t, r$2) => e$1 ^ t || t ^ r$2 ? 16 + 36 * c(e$1 / 51) + 6 * c(t / 51) + c(r$2 / 51) : 8 > e$1 ? 16 : e$1 > 248 ? 231 : c(24 * (e$1 - 8) / 247) + 232, d = (e$1) => {
1305
+ let t, r$2, l, n, o$1;
1306
+ return 8 > e$1 ? 30 + e$1 : 16 > e$1 ? e$1 - 8 + 90 : (232 > e$1 ? (o$1 = (e$1 -= 16) % 36, t = (e$1 / 36 | 0) / 5, r$2 = (o$1 / 6 | 0) / 5, l = o$1 % 6 / 5) : t = r$2 = l = (10 * (e$1 - 232) + 8) / 255, n = 2 * a(t, r$2, l), n ? 30 + (c(l) << 2 | c(r$2) << 1 | c(t)) + (2 ^ n ? 0 : 60) : 30);
1307
+ }, f = (() => {
1308
+ let r$2 = (e$1) => o$1.some(((t) => e$1.test(t))), l = globalThis, n = l.process ?? {}, o$1 = n.argv ?? [], i = n.env ?? {}, c = -1;
1309
+ try {
1310
+ e = "," + s(i).join(",");
1311
+ } catch (e$1) {
1312
+ i = {}, c = 0;
1313
+ }
1314
+ let a$1 = "FORCE_COLOR", p$1 = {
1315
+ false: 0,
1316
+ 0: 0,
1317
+ 1: 1,
1318
+ 2: 2,
1319
+ 3: 3
1320
+ }[i[a$1]] ?? -1, u$1 = a$1 in i && p$1 || r$2(/^--color=?(true|always)?$/);
1321
+ return u$1 && (c = p$1), ~c || (c = ((r$3, l$1, n$1) => (t = r$3.TERM, {
1322
+ "24bit": 3,
1323
+ truecolor: 3,
1324
+ ansi256: 2,
1325
+ ansi: 1
1326
+ }[r$3.COLORTERM] || (r$3.CI ? /,GITHUB/.test(e) ? 3 : 1 : l$1 && "dumb" !== t ? n$1 ? 3 : /-256/.test(t) ? 2 : 1 : 0)))(i, !!i.PM2_HOME || i.NEXT_RUNTIME?.includes("edge") || !!n.stdout?.isTTY, "win32" === n.platform)), !p$1 || i.NO_COLOR || r$2(/^--(no-color|color=(false|never))$/) ? 0 : l.window?.chrome || u$1 && !c ? 3 : c;
1327
+ })(), g = {
1328
+ open: i,
1329
+ close: i
1330
+ }, h = 39, b = 49, O = {}, m = ({ p: e$1 }, { open: t, close: l }) => {
1331
+ let o$1 = (e$2, ...r$2) => {
1332
+ if (!e$2) {
1333
+ if (t && t === l) return t;
1334
+ if ((e$2 ?? i) === i) return i;
1335
+ }
1336
+ let n, s$1 = e$2.raw ? String.raw({ raw: e$2 }, ...r$2) : i + e$2, c$1 = o$1.p, a$1 = c$1.o, p$1 = c$1.c;
1337
+ if (s$1.includes("\x1B")) for (; c$1; c$1 = c$1.p) {
1338
+ let { open: e$3, close: t$1 } = c$1, r$3 = t$1.length, l$1 = i, o$2 = 0;
1339
+ if (r$3) for (; ~(n = s$1.indexOf(t$1, o$2)); o$2 = n + r$3) l$1 += s$1.slice(o$2, n) + e$3;
1340
+ s$1 = l$1 + s$1.slice(o$2);
1341
+ }
1342
+ return a$1 + (s$1.includes("\n") ? s$1.replace(/(\r?\n)/g, p$1 + "$1" + a$1) : s$1) + p$1;
1343
+ }, s = t, c = l;
1344
+ return e$1 && (s = e$1.o + t, c = l + e$1.c), n(o$1, r), o$1.p = {
1345
+ open: t,
1346
+ close: l,
1347
+ o: s,
1348
+ c,
1349
+ p: e$1
1350
+ }, o$1.open = s, o$1.close = c, o$1;
1351
+ };
1352
+ const w = new function e$1(t = f) {
1353
+ let s = {
1354
+ Ansis: e$1,
1355
+ level: t,
1356
+ isSupported: () => a$1,
1357
+ strip: (e$2) => e$2.replace(/[›][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i),
1358
+ extend(e$2) {
1359
+ for (let t$1 in e$2) {
1360
+ let r$2 = e$2[t$1], l = (typeof r$2)[0];
1361
+ "s" === l ? (c(t$1, T$2(...p(r$2))), c(_$2(t$1), v(...p(r$2)))) : c(t$1, r$2, "f" === l);
1362
+ }
1363
+ return r = o({}, O), n(s, r), s;
1364
+ }
1365
+ }, c = (e$2, t$1, r$2) => {
1366
+ O[e$2] = { get() {
1367
+ let n = r$2 ? (...e$3) => m(this, t$1(...e$3)) : m(this, t$1);
1368
+ return l(this, e$2, { value: n }), n;
1369
+ } };
1370
+ }, a$1 = t > 0, w$1 = (e$2, t$1) => a$1 ? {
1371
+ open: `[${e$2}m`,
1372
+ close: `[${t$1}m`
1373
+ } : g, y$1 = (e$2) => (t$1) => e$2(...p(t$1)), R$1 = (e$2, t$1) => (r$2, l, n) => w$1(`${e$2}8;2;${r$2};${l};${n}`, t$1), $$1 = (e$2, t$1) => (r$2, l, n) => w$1(((e$3, t$2, r$3) => d(u(e$3, t$2, r$3)))(r$2, l, n) + e$2, t$1), x$2 = (e$2) => (t$1, r$2, l) => e$2(u(t$1, r$2, l)), T$2 = R$1(3, h), v = R$1(4, b), C$1 = (e$2) => w$1("38;5;" + e$2, h), E = (e$2) => w$1("48;5;" + e$2, b);
1374
+ 2 === t ? (T$2 = x$2(C$1), v = x$2(E)) : 1 === t && (T$2 = $$1(0, h), v = $$1(10, b), C$1 = (e$2) => w$1(d(e$2), h), E = (e$2) => w$1(d(e$2) + 10, b));
1375
+ let M$1, I$1 = {
1376
+ fg: C$1,
1377
+ bg: E,
1378
+ rgb: T$2,
1379
+ bgRgb: v,
1380
+ hex: y$1(T$2),
1381
+ bgHex: y$1(v),
1382
+ visible: g,
1383
+ reset: w$1(0, 0),
1384
+ bold: w$1(1, 22),
1385
+ dim: w$1(2, 22),
1386
+ italic: w$1(3, 23),
1387
+ underline: w$1(4, 24),
1388
+ inverse: w$1(7, 27),
1389
+ hidden: w$1(8, 28),
1390
+ strikethrough: w$1(9, 29)
1391
+ }, _$2 = (e$2) => "bg" + e$2[0].toUpperCase() + e$2.slice(1), k$2 = "Bright";
1392
+ return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map(((e$2, t$1) => {
1393
+ M$1 = _$2(e$2), 8 > t$1 ? (I$1[e$2 + k$2] = w$1(90 + t$1, h), I$1[M$1 + k$2] = w$1(100 + t$1, b)) : t$1 = 60, I$1[e$2] = w$1(30 + t$1, h), I$1[M$1] = w$1(40 + t$1, b);
1394
+ })), s.extend(I$1);
1395
+ }();
1396
+ module.exports = w, w.default = w;
1397
+ }));
1398
+
1399
+ //#endregion
1400
+ //#region ../../node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.mjs
1401
+ var import_ansis = /* @__PURE__ */ __toESM(require_ansis(), 1);
1402
+ var ansis_default = import_ansis.default;
1403
+ 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;
1404
+
1405
+ //#endregion
1406
+ //#region src/node/storage.ts
1407
+ function createStorage(options) {
1408
+ let initialState;
1409
+ if (fs.existsSync(options.filepath)) initialState = JSON.parse(fs.readFileSync(options.filepath, "utf-8"));
1410
+ else initialState = options.initialValue;
1411
+ const state = createSharedState({
1412
+ initialState,
1413
+ enablePatches: false
1414
+ });
1415
+ state.on("updated", (newState) => {
1416
+ fs.mkdirSync(dirname(options.filepath), { recursive: true });
1417
+ fs.writeFileSync(options.filepath, `${JSON.stringify(newState, null, 2)}\n`);
1418
+ });
1419
+ return state;
1420
+ }
1421
+
1422
+ //#endregion
1423
+ //#region src/node/context-internal.ts
1424
+ const internalContextMap = /* @__PURE__ */ new WeakMap();
1425
+ function getInternalContext(context) {
1426
+ if (!internalContextMap.has(context)) {
1427
+ const internalContext = { storage: { auth: createStorage({
1428
+ filepath: join(context.workspaceRoot, "node_modules/.vite/devtools/auth.json"),
1429
+ initialValue: { trusted: {} }
1430
+ }) } };
1431
+ internalContextMap.set(context, internalContext);
1432
+ }
1433
+ return internalContextMap.get(context);
1434
+ }
1435
+
1436
+ //#endregion
1437
+ //#region src/node/rpc/anonymous/auth.ts
1438
+ const anonymousAuth = defineRpcFunction({
1439
+ name: "vite:anonymous:auth",
1440
+ type: "action",
1441
+ setup: (context) => {
1442
+ const storage = getInternalContext(context).storage.auth;
1443
+ const isClientAuthDisabled = context.mode === "build" || context.viteConfig.devtools?.clientAuth === false || process$1.env.VITE_DEVTOOLS_DISABLE_CLIENT_AUTH === "true";
1444
+ if (isClientAuthDisabled) console.warn("[Vite DevTools] Client authentication is disabled. Any browser can connect to the devtools and access to your server and filesystem.");
1445
+ return { handler: async (query) => {
1446
+ const session = context.rpc.getCurrentRpcSession();
1447
+ if (!session) throw new Error("Failed to retrieve the current RPC session");
1448
+ if (isClientAuthDisabled || storage.get().trusted[query.authId]) {
1449
+ session.meta.clientAuthId = query.authId;
1450
+ session.meta.isTrusted = true;
1451
+ return { isTrusted: true };
1452
+ }
1453
+ const message = [
1454
+ `A browser is requesting permissions to connect to the Vite DevTools.`,
1455
+ "",
1456
+ `User Agent: ${ansis_default.yellow(ansis_default.bold(query.ua || "Unknown"))}`,
1457
+ `Origin : ${ansis_default.cyan(ansis_default.bold(query.origin || "Unknown"))}`,
1458
+ `Identifier: ${ansis_default.green(ansis_default.bold(query.authId))}`,
1459
+ "",
1460
+ "This will allow the browser to interact with the server, make file changes and run commands.",
1461
+ ansis_default.red(ansis_default.bold("You should only trust your local development browsers."))
1462
+ ];
1463
+ Me(ansis_default.reset(message.join("\n")), ansis_default.bold(ansis_default.yellow(" Vite DevTools Permission Request ")));
1464
+ if (await ye({
1465
+ message: ansis_default.bold(`Do you trust this client (${ansis_default.green(ansis_default.bold(query.authId))})?`),
1466
+ initialValue: false
1467
+ })) {
1468
+ storage.mutate((state) => {
1469
+ state.trusted[query.authId] = {
1470
+ authId: query.authId,
1471
+ ua: query.ua,
1472
+ origin: query.origin,
1473
+ timestamp: Date.now()
1474
+ };
1475
+ });
1476
+ session.meta.clientAuthId = query.authId;
1477
+ session.meta.isTrusted = true;
1478
+ Se(ansis_default.green(ansis_default.bold(`You have granted permissions to ${ansis_default.bold(query.authId)}`)));
1479
+ return { isTrusted: true };
1480
+ }
1481
+ Se(ansis_default.red(ansis_default.bold(`You have denied permissions to ${ansis_default.bold(query.authId)}`)));
1482
+ return { isTrusted: false };
1483
+ } };
1484
+ }
1485
+ });
1486
+
1487
+ //#endregion
1488
+ //#region src/node/rpc/internal/docks-list.ts
1489
+ const docksList = defineRpcFunction({
1490
+ name: "vite:internal:docks:list",
1491
+ type: "static",
1492
+ setup: (context) => {
1493
+ const builtinDocksEntries = [{
1494
+ type: "~builtin",
1495
+ id: "~terminals",
1496
+ title: "Terminals",
1497
+ icon: "ph:terminal-duotone",
1498
+ get isHidden() {
1499
+ return context.terminals.sessions.size === 0;
1500
+ }
1501
+ }];
1502
+ return { handler() {
1503
+ return [...Array.from(context.docks.values()), ...builtinDocksEntries];
1504
+ } };
1505
+ }
1506
+ });
1507
+
1508
+ //#endregion
1509
+ //#region src/node/rpc/internal/docks-on-launch.ts
1510
+ const docksOnLaunch = defineRpcFunction({
1511
+ name: "vite:internal:docks:on-launch",
1512
+ type: "action",
1513
+ setup: (context) => {
1514
+ const launchMap = /* @__PURE__ */ new Map();
1515
+ return { handler: async (entryId) => {
1516
+ if (launchMap.has(entryId)) return launchMap.get(entryId);
1517
+ const entry = context.docks.values().find((entry$1) => entry$1.id === entryId);
1518
+ if (!entry) throw new Error(`Dock entry with id "${entryId}" not found`);
1519
+ if (entry.type !== "launcher") throw new Error(`Dock entry with id "${entryId}" is not a launcher`);
1520
+ try {
1521
+ context.docks.update({
1522
+ ...entry,
1523
+ launcher: {
1524
+ ...entry.launcher,
1525
+ status: "loading"
1526
+ }
1527
+ });
1528
+ const promise = entry.launcher.onLaunch();
1529
+ launchMap.set(entryId, promise);
1530
+ const result = await promise;
1531
+ const newEntry = context.docks.values().find((entry$1) => entry$1.id === entryId) || entry;
1532
+ if (newEntry.type === "launcher") context.docks.update({
1533
+ ...newEntry,
1534
+ launcher: {
1535
+ ...newEntry.launcher,
1536
+ status: "success"
1537
+ }
1538
+ });
1539
+ return result;
1540
+ } catch (error) {
1541
+ console.error(`[VITE DEVTOOLS] Error launching dock entry "${entryId}"`, error);
1542
+ context.docks.update({
1543
+ ...entry,
1544
+ launcher: {
1545
+ ...entry.launcher,
1546
+ status: "error",
1547
+ error: error instanceof Error ? error.message : String(error)
1548
+ }
1549
+ });
1550
+ }
1551
+ } };
1552
+ }
1553
+ });
1554
+
1555
+ //#endregion
1556
+ //#region src/node/rpc/internal/rpc-server-list.ts
1557
+ const rpcServerList = defineRpcFunction({
1558
+ name: "vite:internal:rpc:server:list",
1559
+ type: "static",
1560
+ setup: (context) => {
1561
+ return { async handler() {
1562
+ return Object.fromEntries(Array.from(context.rpc.definitions.entries()).map(([name, fn]) => [name, { type: fn.type }]));
1563
+ } };
1564
+ }
1565
+ });
1566
+
1567
+ //#endregion
1568
+ //#region src/node/rpc/internal/terminals-list.ts
1569
+ const terminalsList = defineRpcFunction({
1570
+ name: "vite:internal:terminals:list",
1571
+ type: "static",
1572
+ setup: (context) => {
1573
+ return { async handler() {
1574
+ return Array.from(context.terminals.sessions.values()).map((i) => {
1575
+ return {
1576
+ id: i.id,
1577
+ title: i.title,
1578
+ description: i.description,
1579
+ status: i.status
1580
+ };
1581
+ });
1582
+ } };
1583
+ }
1584
+ });
1585
+
1586
+ //#endregion
1587
+ //#region src/node/rpc/internal/terminals-read.ts
1588
+ const terminalsRead = defineRpcFunction({
1589
+ name: "vite:internal:terminals:read",
1590
+ type: "query",
1591
+ setup: (context) => {
1592
+ return { async handler(id) {
1593
+ const seesion = context.terminals.sessions.get(id);
1594
+ if (!seesion) throw new Error(`Terminal session with id "${id}" not found`);
1595
+ return {
1596
+ buffer: seesion.buffer ?? [],
1597
+ ts: Date.now()
1598
+ };
1599
+ } };
1600
+ }
1601
+ });
1602
+
1603
+ //#endregion
1604
+ //#region src/node/rpc/public/open-in-editor.ts
1605
+ const openInEditor = defineRpcFunction({
1606
+ name: "vite:core:open-in-editor",
1607
+ type: "action",
1608
+ setup: () => {
1609
+ return { handler: async (path) => {
1610
+ await import("launch-editor").then((r$2) => r$2.default(path));
1611
+ } };
1612
+ }
1613
+ });
1614
+
1615
+ //#endregion
1616
+ //#region src/node/rpc/public/open-in-finder.ts
1617
+ const openInFinder = defineRpcFunction({
1618
+ name: "vite:core:open-in-finder",
1619
+ type: "action",
1620
+ setup: () => {
1621
+ return { handler: async (path) => {
1622
+ await import("open").then((r$2) => r$2.default(path));
1623
+ } };
1624
+ }
1625
+ });
1626
+
1627
+ //#endregion
1628
+ //#region src/node/rpc/index.ts
1629
+ const builtinPublicRpcDecalrations = [openInEditor, openInFinder];
1630
+ const builtinAnonymousRpcDecalrations = [anonymousAuth];
1631
+ const builtinInternalRpcDecalrations = [
1632
+ docksList,
1633
+ docksOnLaunch,
1634
+ rpcServerList,
1635
+ terminalsList,
1636
+ terminalsRead
1637
+ ];
1638
+ const builtinRpcDecalrations = [
1639
+ ...builtinPublicRpcDecalrations,
1640
+ ...builtinAnonymousRpcDecalrations,
1641
+ ...builtinInternalRpcDecalrations
1642
+ ];
1643
+
1644
+ //#endregion
1645
+ //#region src/node/context.ts
1646
+ const debug = Debug("vite:devtools:context");
1647
+ async function createDevToolsContext(viteConfig, viteServer) {
1648
+ const cwd = viteConfig.root;
1649
+ const context = {
1650
+ cwd,
1651
+ workspaceRoot: searchForWorkspaceRoot(cwd) ?? cwd,
1652
+ viteConfig,
1653
+ viteServer,
1654
+ mode: viteConfig.command === "serve" ? "dev" : "build",
1655
+ rpc: void 0,
1656
+ docks: void 0,
1657
+ views: void 0,
1658
+ utils: ContextUtils,
1659
+ terminals: void 0
1660
+ };
1661
+ const rpcHost = new RpcFunctionsHost(context);
1662
+ const docksHost = new DevToolsDockHost(context);
1663
+ const viewsHost = new DevToolsViewHost(context);
1664
+ const terminalsHost = new DevToolsTerminalHost(context);
1665
+ context.rpc = rpcHost;
1666
+ context.docks = docksHost;
1667
+ context.views = viewsHost;
1668
+ context.terminals = terminalsHost;
1669
+ for (const fn of builtinRpcDecalrations) rpcHost.register(fn);
1670
+ docksHost.events.on("dock:entry:updated", debounce(() => {
1671
+ rpcHost.broadcast("vite:internal:docks:updated");
1672
+ }, 10));
1673
+ terminalsHost.events.on("terminal:session:updated", debounce(() => {
1674
+ rpcHost.broadcast("vite:internal:terminals:updated");
1675
+ rpcHost.broadcast("vite:internal:docks:updated");
1676
+ }, 10));
1677
+ terminalsHost.events.on("terminal:session:stream-chunk", (data) => {
1678
+ rpcHost.broadcast("vite:internal:terminals:stream-chunk", data);
1679
+ });
1680
+ const plugins = viteConfig.plugins.filter((plugin) => "devtools" in plugin);
1681
+ for (const plugin of plugins) {
1682
+ if (!plugin.devtools?.setup) continue;
1683
+ try {
1684
+ debug(`Setting up plugin ${plugin.name}`);
1685
+ await plugin.devtools?.setup?.(context);
1686
+ } catch (error) {
1687
+ console.error(`[Vite DevTools] Error setting up plugin ${plugin.name}:`, error);
1688
+ throw error;
1689
+ }
1690
+ }
1691
+ return context;
1692
+ }
1693
+
1694
+ //#endregion
1695
+ //#region src/node/plugins/injection.ts
1696
+ function DevToolsInjection() {
1697
+ return {
1698
+ name: "vite:devtools:injection",
1699
+ enforce: "post",
1700
+ transformIndexHtml() {
1701
+ return [{
1702
+ tag: "script",
1703
+ attrs: {
1704
+ 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"))}`,
1705
+ type: "module"
1706
+ },
1707
+ injectTo: "body"
1708
+ }];
1709
+ }
1710
+ };
1711
+ }
1712
+
1713
+ //#endregion
1714
+ //#region ../../node_modules/.pnpm/ufo@1.6.1/node_modules/ufo/dist/index.mjs
1715
+ const r = String.fromCharCode;
1716
+ const PROTOCOL_STRICT_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
1717
+ const PROTOCOL_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
1718
+ const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
1719
+ const TRAILING_SLASH_RE = /\/$|\/\?|\/#/;
1720
+ const JOIN_LEADING_SLASH_RE = /^\.?\//;
1721
+ function hasProtocol(inputString, opts = {}) {
1722
+ if (typeof opts === "boolean") opts = { acceptRelative: opts };
1723
+ if (opts.strict) return PROTOCOL_STRICT_REGEX.test(inputString);
1724
+ return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
1725
+ }
1726
+ function hasTrailingSlash(input = "", respectQueryAndFragment) {
1727
+ if (!respectQueryAndFragment) return input.endsWith("/");
1728
+ return TRAILING_SLASH_RE.test(input);
1729
+ }
1730
+ function withoutTrailingSlash(input = "", respectQueryAndFragment) {
1731
+ if (!respectQueryAndFragment) return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
1732
+ if (!hasTrailingSlash(input, true)) return input || "/";
1733
+ let path = input;
1734
+ let fragment = "";
1735
+ const fragmentIndex = input.indexOf("#");
1736
+ if (fragmentIndex !== -1) {
1737
+ path = input.slice(0, fragmentIndex);
1738
+ fragment = input.slice(fragmentIndex);
1739
+ }
1740
+ const [s0, ...s] = path.split("?");
1741
+ return ((s0.endsWith("/") ? s0.slice(0, -1) : s0) || "/") + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
1742
+ }
1743
+ function withTrailingSlash(input = "", respectQueryAndFragment) {
1744
+ if (!respectQueryAndFragment) return input.endsWith("/") ? input : input + "/";
1745
+ if (hasTrailingSlash(input, true)) return input || "/";
1746
+ let path = input;
1747
+ let fragment = "";
1748
+ const fragmentIndex = input.indexOf("#");
1749
+ if (fragmentIndex !== -1) {
1750
+ path = input.slice(0, fragmentIndex);
1751
+ fragment = input.slice(fragmentIndex);
1752
+ if (!path) return fragment;
1753
+ }
1754
+ const [s0, ...s] = path.split("?");
1755
+ return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
1756
+ }
1757
+ function isNonEmptyURL(url) {
1758
+ return url && url !== "/";
1759
+ }
1760
+ function joinURL(base, ...input) {
1761
+ let url = base || "";
1762
+ for (const segment of input.filter((url2) => isNonEmptyURL(url2))) if (url) {
1763
+ const _segment = segment.replace(JOIN_LEADING_SLASH_RE, "");
1764
+ url = withTrailingSlash(url) + _segment;
1765
+ } else url = segment;
1766
+ return url;
1767
+ }
1768
+ const protocolRelative = Symbol.for("ufo:protocolRelative");
1769
+ function parseURL(input = "", defaultProto) {
1770
+ const _specialProtoMatch = input.match(/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i);
1771
+ if (_specialProtoMatch) {
1772
+ const [, _proto, _pathname = ""] = _specialProtoMatch;
1773
+ return {
1774
+ protocol: _proto.toLowerCase(),
1775
+ pathname: _pathname,
1776
+ href: _proto + _pathname,
1777
+ auth: "",
1778
+ host: "",
1779
+ search: "",
1780
+ hash: ""
1781
+ };
1782
+ }
1783
+ if (!hasProtocol(input, { acceptRelative: true })) return defaultProto ? parseURL(defaultProto + input) : parsePath(input);
1784
+ const [, protocol = "", auth, hostAndPath = ""] = input.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
1785
+ let [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];
1786
+ if (protocol === "file:") path = path.replace(/\/(?=[A-Za-z]:)/, "");
1787
+ const { pathname, search, hash } = parsePath(path);
1788
+ return {
1789
+ protocol: protocol.toLowerCase(),
1790
+ auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : "",
1791
+ host,
1792
+ pathname,
1793
+ search,
1794
+ hash,
1795
+ [protocolRelative]: !protocol
1796
+ };
1797
+ }
1798
+ function parsePath(input = "") {
1799
+ const [pathname = "", search = "", hash = ""] = (input.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
1800
+ return {
1801
+ pathname,
1802
+ search,
1803
+ hash
1804
+ };
1805
+ }
1806
+
1807
+ //#endregion
1808
+ //#region ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
1809
+ function isPlainObject(value) {
1810
+ if (value === null || typeof value !== "object") return false;
1811
+ const prototype = Object.getPrototypeOf(value);
1812
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
1813
+ if (Symbol.iterator in value) return false;
1814
+ if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
1815
+ return true;
1816
+ }
1817
+ function _defu(baseObject, defaults, namespace = ".", merger) {
1818
+ if (!isPlainObject(defaults)) return _defu(baseObject, {}, namespace, merger);
1819
+ const object = Object.assign({}, defaults);
1820
+ for (const key in baseObject) {
1821
+ if (key === "__proto__" || key === "constructor") continue;
1822
+ const value = baseObject[key];
1823
+ if (value === null || value === void 0) continue;
1824
+ if (merger && merger(object, key, value, namespace)) continue;
1825
+ if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
1826
+ else if (isPlainObject(value) && isPlainObject(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
1827
+ else object[key] = value;
1828
+ }
1829
+ return object;
1830
+ }
1831
+ function createDefu(merger) {
1832
+ return (...arguments_) => arguments_.reduce((p$1, c) => _defu(p$1, c, "", merger), {});
1833
+ }
1834
+ const defu = createDefu();
1835
+ const defuFn = createDefu((object, key, currentValue) => {
1836
+ if (object[key] !== void 0 && typeof currentValue === "function") {
1837
+ object[key] = currentValue(object[key]);
1838
+ return true;
1839
+ }
1840
+ });
1841
+ const defuArrayFn = createDefu((object, key, currentValue) => {
1842
+ if (Array.isArray(object[key]) && typeof currentValue === "function") {
1843
+ object[key] = currentValue(object[key]);
1844
+ return true;
1845
+ }
1846
+ });
1847
+
1848
+ //#endregion
1849
+ //#region ../../node_modules/.pnpm/h3@1.15.4/node_modules/h3/dist/index.mjs
1850
+ function hasProp(obj, prop) {
1851
+ try {
1852
+ return prop in obj;
1853
+ } catch {
1854
+ return false;
1855
+ }
1856
+ }
1857
+ var H3Error = class extends Error {
1858
+ static __h3_error__ = true;
1859
+ statusCode = 500;
1860
+ fatal = false;
1861
+ unhandled = false;
1862
+ statusMessage;
1863
+ data;
1864
+ cause;
1865
+ constructor(message, opts = {}) {
1866
+ super(message, opts);
1867
+ if (opts.cause && !this.cause) this.cause = opts.cause;
1868
+ }
1869
+ toJSON() {
1870
+ const obj = {
1871
+ message: this.message,
1872
+ statusCode: sanitizeStatusCode(this.statusCode, 500)
1873
+ };
1874
+ if (this.statusMessage) obj.statusMessage = sanitizeStatusMessage(this.statusMessage);
1875
+ if (this.data !== void 0) obj.data = this.data;
1876
+ return obj;
1877
+ }
1878
+ };
1879
+ function createError(input) {
1880
+ if (typeof input === "string") return new H3Error(input);
1881
+ if (isError(input)) return input;
1882
+ const err = new H3Error(input.message ?? input.statusMessage ?? "", { cause: input.cause || input });
1883
+ if (hasProp(input, "stack")) try {
1884
+ Object.defineProperty(err, "stack", { get() {
1885
+ return input.stack;
1886
+ } });
1887
+ } catch {
1888
+ try {
1889
+ err.stack = input.stack;
1890
+ } catch {}
1891
+ }
1892
+ if (input.data) err.data = input.data;
1893
+ if (input.statusCode) err.statusCode = sanitizeStatusCode(input.statusCode, err.statusCode);
1894
+ else if (input.status) err.statusCode = sanitizeStatusCode(input.status, err.statusCode);
1895
+ if (input.statusMessage) err.statusMessage = input.statusMessage;
1896
+ else if (input.statusText) err.statusMessage = input.statusText;
1897
+ if (err.statusMessage) {
1898
+ const originalMessage = err.statusMessage;
1899
+ if (sanitizeStatusMessage(err.statusMessage) !== originalMessage) console.warn("[h3] Please prefer using `message` for longer error messages instead of `statusMessage`. In the future, `statusMessage` will be sanitized by default.");
1900
+ }
1901
+ if (input.fatal !== void 0) err.fatal = input.fatal;
1902
+ if (input.unhandled !== void 0) err.unhandled = input.unhandled;
1903
+ return err;
1904
+ }
1905
+ function sendError(event, error, debug$1) {
1906
+ if (event.handled) return;
1907
+ const h3Error = isError(error) ? error : createError(error);
1908
+ const responseBody = {
1909
+ statusCode: h3Error.statusCode,
1910
+ statusMessage: h3Error.statusMessage,
1911
+ stack: [],
1912
+ data: h3Error.data
1913
+ };
1914
+ if (debug$1) responseBody.stack = (h3Error.stack || "").split("\n").map((l) => l.trim());
1915
+ if (event.handled) return;
1916
+ setResponseStatus(event, Number.parseInt(h3Error.statusCode), h3Error.statusMessage);
1917
+ event.node.res.setHeader("content-type", MIMES.json);
1918
+ event.node.res.end(JSON.stringify(responseBody, void 0, 2));
1919
+ }
1920
+ function isError(input) {
1921
+ return input?.constructor?.__h3_error__ === true;
1922
+ }
1923
+ const RawBodySymbol = Symbol.for("h3RawBody");
1924
+ const ParsedBodySymbol = Symbol.for("h3ParsedBody");
1925
+ const MIMES = {
1926
+ html: "text/html",
1927
+ json: "application/json"
1928
+ };
1929
+ const DISALLOWED_STATUS_CHARS = /[^\u0009\u0020-\u007E]/g;
1930
+ function sanitizeStatusMessage(statusMessage = "") {
1931
+ return statusMessage.replace(DISALLOWED_STATUS_CHARS, "");
1932
+ }
1933
+ function sanitizeStatusCode(statusCode, defaultStatusCode = 200) {
1934
+ if (!statusCode) return defaultStatusCode;
1935
+ if (typeof statusCode === "string") statusCode = Number.parseInt(statusCode, 10);
1936
+ if (statusCode < 100 || statusCode > 999) return defaultStatusCode;
1937
+ return statusCode;
1938
+ }
1939
+ function splitCookiesString(cookiesString) {
1940
+ if (Array.isArray(cookiesString)) return cookiesString.flatMap((c) => splitCookiesString(c));
1941
+ if (typeof cookiesString !== "string") return [];
1942
+ const cookiesStrings = [];
1943
+ let pos = 0;
1944
+ let start;
1945
+ let ch;
1946
+ let lastComma;
1947
+ let nextStart;
1948
+ let cookiesSeparatorFound;
1949
+ const skipWhitespace = () => {
1950
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) pos += 1;
1951
+ return pos < cookiesString.length;
1952
+ };
1953
+ const notSpecialChar = () => {
1954
+ ch = cookiesString.charAt(pos);
1955
+ return ch !== "=" && ch !== ";" && ch !== ",";
1956
+ };
1957
+ while (pos < cookiesString.length) {
1958
+ start = pos;
1959
+ cookiesSeparatorFound = false;
1960
+ while (skipWhitespace()) {
1961
+ ch = cookiesString.charAt(pos);
1962
+ if (ch === ",") {
1963
+ lastComma = pos;
1964
+ pos += 1;
1965
+ skipWhitespace();
1966
+ nextStart = pos;
1967
+ while (pos < cookiesString.length && notSpecialChar()) pos += 1;
1968
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
1969
+ cookiesSeparatorFound = true;
1970
+ pos = nextStart;
1971
+ cookiesStrings.push(cookiesString.slice(start, lastComma));
1972
+ start = pos;
1973
+ } else pos = lastComma + 1;
1974
+ } else pos += 1;
1975
+ }
1976
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) cookiesStrings.push(cookiesString.slice(start));
1977
+ }
1978
+ return cookiesStrings;
1979
+ }
1980
+ const defer = typeof setImmediate === "undefined" ? (fn) => fn() : setImmediate;
1981
+ function send(event, data, type) {
1982
+ if (type) defaultContentType(event, type);
1983
+ return new Promise((resolve$1) => {
1984
+ defer(() => {
1985
+ if (!event.handled) event.node.res.end(data);
1986
+ resolve$1();
1987
+ });
1988
+ });
1989
+ }
1990
+ function sendNoContent(event, code) {
1991
+ if (event.handled) return;
1992
+ if (!code && event.node.res.statusCode !== 200) code = event.node.res.statusCode;
1993
+ const _code = sanitizeStatusCode(code, 204);
1994
+ if (_code === 204) event.node.res.removeHeader("content-length");
1995
+ event.node.res.writeHead(_code);
1996
+ event.node.res.end();
1997
+ }
1998
+ function setResponseStatus(event, code, text) {
1999
+ if (code) event.node.res.statusCode = sanitizeStatusCode(code, event.node.res.statusCode);
2000
+ if (text) event.node.res.statusMessage = sanitizeStatusMessage(text);
2001
+ }
2002
+ function defaultContentType(event, type) {
2003
+ if (type && event.node.res.statusCode !== 304 && !event.node.res.getHeader("content-type")) event.node.res.setHeader("content-type", type);
2004
+ }
2005
+ function sendRedirect(event, location, code = 302) {
2006
+ event.node.res.statusCode = sanitizeStatusCode(code, event.node.res.statusCode);
2007
+ event.node.res.setHeader("location", location);
2008
+ return send(event, `<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=${location.replace(/"/g, "%22")}"></head></html>`, MIMES.html);
2009
+ }
2010
+ function isStream(data) {
2011
+ if (!data || typeof data !== "object") return false;
2012
+ if (typeof data.pipe === "function") {
2013
+ if (typeof data._read === "function") return true;
2014
+ if (typeof data.abort === "function") return true;
2015
+ }
2016
+ if (typeof data.pipeTo === "function") return true;
2017
+ return false;
2018
+ }
2019
+ function isWebResponse(data) {
2020
+ return typeof Response !== "undefined" && data instanceof Response;
2021
+ }
2022
+ function sendStream(event, stream) {
2023
+ if (!stream || typeof stream !== "object") throw new Error("[h3] Invalid stream provided.");
2024
+ event.node.res._data = stream;
2025
+ if (!event.node.res.socket) {
2026
+ event._handled = true;
2027
+ return Promise.resolve();
2028
+ }
2029
+ if (hasProp(stream, "pipeTo") && typeof stream.pipeTo === "function") return stream.pipeTo(new WritableStream({ write(chunk) {
2030
+ event.node.res.write(chunk);
2031
+ } })).then(() => {
2032
+ event.node.res.end();
2033
+ });
2034
+ if (hasProp(stream, "pipe") && typeof stream.pipe === "function") return new Promise((resolve$1, reject) => {
2035
+ stream.pipe(event.node.res);
2036
+ if (stream.on) {
2037
+ stream.on("end", () => {
2038
+ event.node.res.end();
2039
+ resolve$1();
2040
+ });
2041
+ stream.on("error", (error) => {
2042
+ reject(error);
2043
+ });
2044
+ }
2045
+ event.node.res.on("close", () => {
2046
+ if (stream.abort) stream.abort();
2047
+ });
2048
+ });
2049
+ throw new Error("[h3] Invalid or incompatible stream provided.");
2050
+ }
2051
+ function sendWebResponse(event, response) {
2052
+ for (const [key, value] of response.headers) if (key === "set-cookie") event.node.res.appendHeader(key, splitCookiesString(value));
2053
+ else event.node.res.setHeader(key, value);
2054
+ if (response.status) event.node.res.statusCode = sanitizeStatusCode(response.status, event.node.res.statusCode);
2055
+ if (response.statusText) event.node.res.statusMessage = sanitizeStatusMessage(response.statusText);
2056
+ if (response.redirected) event.node.res.setHeader("location", response.url);
2057
+ if (!response.body) {
2058
+ event.node.res.end();
2059
+ return;
2060
+ }
2061
+ return sendStream(event, response.body);
2062
+ }
2063
+ var H3Event = class {
2064
+ "__is_event__" = true;
2065
+ node;
2066
+ web;
2067
+ context = {};
2068
+ _method;
2069
+ _path;
2070
+ _headers;
2071
+ _requestBody;
2072
+ _handled = false;
2073
+ _onBeforeResponseCalled;
2074
+ _onAfterResponseCalled;
2075
+ constructor(req, res) {
2076
+ this.node = {
2077
+ req,
2078
+ res
2079
+ };
2080
+ }
2081
+ get method() {
2082
+ if (!this._method) this._method = (this.node.req.method || "GET").toUpperCase();
2083
+ return this._method;
2084
+ }
2085
+ get path() {
2086
+ return this._path || this.node.req.url || "/";
2087
+ }
2088
+ get headers() {
2089
+ if (!this._headers) this._headers = _normalizeNodeHeaders(this.node.req.headers);
2090
+ return this._headers;
2091
+ }
2092
+ get handled() {
2093
+ return this._handled || this.node.res.writableEnded || this.node.res.headersSent;
2094
+ }
2095
+ respondWith(response) {
2096
+ return Promise.resolve(response).then((_response) => sendWebResponse(this, _response));
2097
+ }
2098
+ toString() {
2099
+ return `[${this.method}] ${this.path}`;
2100
+ }
2101
+ toJSON() {
2102
+ return this.toString();
2103
+ }
2104
+ /** @deprecated Please use `event.node.req` instead. */
2105
+ get req() {
2106
+ return this.node.req;
2107
+ }
2108
+ /** @deprecated Please use `event.node.res` instead. */
2109
+ get res() {
2110
+ return this.node.res;
2111
+ }
2112
+ };
2113
+ function createEvent(req, res) {
2114
+ return new H3Event(req, res);
2115
+ }
2116
+ function _normalizeNodeHeaders(nodeHeaders) {
2117
+ const headers = new Headers();
2118
+ for (const [name, value] of Object.entries(nodeHeaders)) if (Array.isArray(value)) for (const item of value) headers.append(name, item);
2119
+ else if (value) headers.set(name, value);
2120
+ return headers;
2121
+ }
2122
+ function defineEventHandler(handler) {
2123
+ if (typeof handler === "function") {
2124
+ handler.__is_handler__ = true;
2125
+ return handler;
2126
+ }
2127
+ const _hooks = {
2128
+ onRequest: _normalizeArray(handler.onRequest),
2129
+ onBeforeResponse: _normalizeArray(handler.onBeforeResponse)
2130
+ };
2131
+ const _handler = (event) => {
2132
+ return _callHandler(event, handler.handler, _hooks);
2133
+ };
2134
+ _handler.__is_handler__ = true;
2135
+ _handler.__resolve__ = handler.handler.__resolve__;
2136
+ _handler.__websocket__ = handler.websocket;
2137
+ return _handler;
2138
+ }
2139
+ function _normalizeArray(input) {
2140
+ return input ? Array.isArray(input) ? input : [input] : void 0;
2141
+ }
2142
+ async function _callHandler(event, handler, hooks) {
2143
+ if (hooks.onRequest) for (const hook of hooks.onRequest) {
2144
+ await hook(event);
2145
+ if (event.handled) return;
2146
+ }
2147
+ const response = { body: await handler(event) };
2148
+ if (hooks.onBeforeResponse) for (const hook of hooks.onBeforeResponse) await hook(event, response);
2149
+ return response.body;
2150
+ }
2151
+ const eventHandler = defineEventHandler;
2152
+ function isEventHandler(input) {
2153
+ return hasProp(input, "__is_handler__");
2154
+ }
2155
+ function toEventHandler(input, _$2, _route) {
2156
+ if (!isEventHandler(input)) console.warn("[h3] Implicit event handler conversion is deprecated. Use `eventHandler()` or `fromNodeMiddleware()` to define event handlers.", _route && _route !== "/" ? `
2157
+ Route: ${_route}` : "", `
2158
+ Handler: ${input}`);
2159
+ return input;
2160
+ }
2161
+ function defineLazyEventHandler(factory) {
2162
+ let _promise;
2163
+ let _resolved;
2164
+ const resolveHandler = () => {
2165
+ if (_resolved) return Promise.resolve(_resolved);
2166
+ if (!_promise) _promise = Promise.resolve(factory()).then((r$2) => {
2167
+ const handler2 = r$2.default || r$2;
2168
+ if (typeof handler2 !== "function") throw new TypeError("Invalid lazy handler result. It should be a function:", handler2);
2169
+ _resolved = { handler: toEventHandler(r$2.default || r$2) };
2170
+ return _resolved;
2171
+ });
2172
+ return _promise;
2173
+ };
2174
+ const handler = eventHandler((event) => {
2175
+ if (_resolved) return _resolved.handler(event);
2176
+ return resolveHandler().then((r$2) => r$2.handler(event));
2177
+ });
2178
+ handler.__resolve__ = resolveHandler;
2179
+ return handler;
2180
+ }
2181
+ const lazyEventHandler = defineLazyEventHandler;
2182
+ const H3Headers = globalThis.Headers;
2183
+ const H3Response = globalThis.Response;
2184
+ function createApp(options = {}) {
2185
+ const stack = [];
2186
+ const handler = createAppEventHandler(stack, options);
2187
+ const resolve$1 = createResolver(stack);
2188
+ handler.__resolve__ = resolve$1;
2189
+ const getWebsocket = cachedFn(() => websocketOptions(resolve$1, options));
2190
+ const app = {
2191
+ use: (arg1, arg2, arg3) => use(app, arg1, arg2, arg3),
2192
+ resolve: resolve$1,
2193
+ handler,
2194
+ stack,
2195
+ options,
2196
+ get websocket() {
2197
+ return getWebsocket();
2198
+ }
2199
+ };
2200
+ return app;
2201
+ }
2202
+ function use(app, arg1, arg2, arg3) {
2203
+ if (Array.isArray(arg1)) for (const i of arg1) use(app, i, arg2, arg3);
2204
+ else if (Array.isArray(arg2)) for (const i of arg2) use(app, arg1, i, arg3);
2205
+ else if (typeof arg1 === "string") app.stack.push(normalizeLayer({
2206
+ ...arg3,
2207
+ route: arg1,
2208
+ handler: arg2
2209
+ }));
2210
+ else if (typeof arg1 === "function") app.stack.push(normalizeLayer({
2211
+ ...arg2,
2212
+ handler: arg1
2213
+ }));
2214
+ else app.stack.push(normalizeLayer({ ...arg1 }));
2215
+ return app;
2216
+ }
2217
+ function createAppEventHandler(stack, options) {
2218
+ const spacing = options.debug ? 2 : void 0;
2219
+ return eventHandler(async (event) => {
2220
+ event.node.req.originalUrl = event.node.req.originalUrl || event.node.req.url || "/";
2221
+ const _reqPath = event._path || event.node.req.url || "/";
2222
+ let _layerPath;
2223
+ if (options.onRequest) await options.onRequest(event);
2224
+ for (const layer of stack) {
2225
+ if (layer.route.length > 1) {
2226
+ if (!_reqPath.startsWith(layer.route)) continue;
2227
+ _layerPath = _reqPath.slice(layer.route.length) || "/";
2228
+ } else _layerPath = _reqPath;
2229
+ if (layer.match && !layer.match(_layerPath, event)) continue;
2230
+ event._path = _layerPath;
2231
+ event.node.req.url = _layerPath;
2232
+ const val = await layer.handler(event);
2233
+ const _body = val === void 0 ? void 0 : await val;
2234
+ if (_body !== void 0) {
2235
+ const _response = { body: _body };
2236
+ if (options.onBeforeResponse) {
2237
+ event._onBeforeResponseCalled = true;
2238
+ await options.onBeforeResponse(event, _response);
2239
+ }
2240
+ await handleHandlerResponse(event, _response.body, spacing);
2241
+ if (options.onAfterResponse) {
2242
+ event._onAfterResponseCalled = true;
2243
+ await options.onAfterResponse(event, _response);
2244
+ }
2245
+ return;
2246
+ }
2247
+ if (event.handled) {
2248
+ if (options.onAfterResponse) {
2249
+ event._onAfterResponseCalled = true;
2250
+ await options.onAfterResponse(event, void 0);
2251
+ }
2252
+ return;
2253
+ }
2254
+ }
2255
+ if (!event.handled) throw createError({
2256
+ statusCode: 404,
2257
+ statusMessage: `Cannot find any path matching ${event.path || "/"}.`
2258
+ });
2259
+ if (options.onAfterResponse) {
2260
+ event._onAfterResponseCalled = true;
2261
+ await options.onAfterResponse(event, void 0);
2262
+ }
2263
+ });
2264
+ }
2265
+ function createResolver(stack) {
2266
+ return async (path) => {
2267
+ let _layerPath;
2268
+ for (const layer of stack) {
2269
+ if (layer.route === "/" && !layer.handler.__resolve__) continue;
2270
+ if (!path.startsWith(layer.route)) continue;
2271
+ _layerPath = path.slice(layer.route.length) || "/";
2272
+ if (layer.match && !layer.match(_layerPath, void 0)) continue;
2273
+ let res = {
2274
+ route: layer.route,
2275
+ handler: layer.handler
2276
+ };
2277
+ if (res.handler.__resolve__) {
2278
+ const _res = await res.handler.__resolve__(_layerPath);
2279
+ if (!_res) continue;
2280
+ res = {
2281
+ ...res,
2282
+ ..._res,
2283
+ route: joinURL(res.route || "/", _res.route || "/")
2284
+ };
2285
+ }
2286
+ return res;
2287
+ }
2288
+ };
2289
+ }
2290
+ function normalizeLayer(input) {
2291
+ let handler = input.handler;
2292
+ if (handler.handler) handler = handler.handler;
2293
+ if (input.lazy) handler = lazyEventHandler(handler);
2294
+ else if (!isEventHandler(handler)) handler = toEventHandler(handler, void 0, input.route);
2295
+ return {
2296
+ route: withoutTrailingSlash(input.route),
2297
+ match: input.match,
2298
+ handler
2299
+ };
2300
+ }
2301
+ function handleHandlerResponse(event, val, jsonSpace) {
2302
+ if (val === null) return sendNoContent(event);
2303
+ if (val) {
2304
+ if (isWebResponse(val)) return sendWebResponse(event, val);
2305
+ if (isStream(val)) return sendStream(event, val);
2306
+ if (val.buffer) return send(event, val);
2307
+ if (val.arrayBuffer && typeof val.arrayBuffer === "function") return val.arrayBuffer().then((arrayBuffer) => {
2308
+ return send(event, Buffer.from(arrayBuffer), val.type);
2309
+ });
2310
+ if (val instanceof Error) throw createError(val);
2311
+ if (typeof val.end === "function") return true;
2312
+ }
2313
+ const valType = typeof val;
2314
+ if (valType === "string") return send(event, val, MIMES.html);
2315
+ if (valType === "object" || valType === "boolean" || valType === "number") return send(event, JSON.stringify(val, void 0, jsonSpace), MIMES.json);
2316
+ if (valType === "bigint") return send(event, val.toString(), MIMES.json);
2317
+ throw createError({
2318
+ statusCode: 500,
2319
+ statusMessage: `[h3] Cannot send ${valType} as response.`
2320
+ });
2321
+ }
2322
+ function cachedFn(fn) {
2323
+ let cache;
2324
+ return () => {
2325
+ if (!cache) cache = fn();
2326
+ return cache;
2327
+ };
2328
+ }
2329
+ function websocketOptions(evResolver, appOptions) {
2330
+ return {
2331
+ ...appOptions.websocket,
2332
+ async resolve(info) {
2333
+ const url = info.request?.url || info.url || "/";
2334
+ const { pathname } = typeof url === "string" ? parseURL(url) : url;
2335
+ return (await evResolver(pathname))?.handler?.__websocket__ || {};
2336
+ }
2337
+ };
2338
+ }
2339
+ function fromNodeMiddleware(handler) {
2340
+ if (isEventHandler(handler)) return handler;
2341
+ if (typeof handler !== "function") throw new TypeError("Invalid handler. It should be a function:", handler);
2342
+ return eventHandler((event) => {
2343
+ return callNodeListener(handler, event.node.req, event.node.res);
2344
+ });
2345
+ }
2346
+ function toNodeListener(app) {
2347
+ const toNodeHandle = async function(req, res) {
2348
+ const event = createEvent(req, res);
2349
+ try {
2350
+ await app.handler(event);
2351
+ } catch (_error) {
2352
+ const error = createError(_error);
2353
+ if (!isError(_error)) error.unhandled = true;
2354
+ setResponseStatus(event, error.statusCode, error.statusMessage);
2355
+ if (app.options.onError) await app.options.onError(error, event);
2356
+ if (event.handled) return;
2357
+ if (error.unhandled || error.fatal) console.error("[h3]", error.fatal ? "[fatal]" : "[unhandled]", error);
2358
+ if (app.options.onBeforeResponse && !event._onBeforeResponseCalled) await app.options.onBeforeResponse(event, { body: error });
2359
+ await sendError(event, error, !!app.options.debug);
2360
+ if (app.options.onAfterResponse && !event._onAfterResponseCalled) await app.options.onAfterResponse(event, { body: error });
2361
+ }
2362
+ };
2363
+ return toNodeHandle;
2364
+ }
2365
+ function callNodeListener(handler, req, res) {
2366
+ const isMiddleware = handler.length > 2;
2367
+ return new Promise((resolve$1, reject) => {
2368
+ const next = (err) => {
2369
+ if (isMiddleware) {
2370
+ res.off("close", next);
2371
+ res.off("error", next);
2372
+ }
2373
+ return err ? reject(createError(err)) : resolve$1(void 0);
2374
+ };
2375
+ try {
2376
+ const returned = handler(req, res, next);
2377
+ if (isMiddleware && returned === void 0) {
2378
+ res.once("close", next);
2379
+ res.once("error", next);
2380
+ } else resolve$1(returned);
2381
+ } catch (error) {
2382
+ next(error);
2383
+ }
2384
+ });
2385
+ }
2386
+
2387
+ //#endregion
2388
+ //#region ../../node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs
2389
+ const unsafePorts = /* @__PURE__ */ new Set([
2390
+ 1,
2391
+ 7,
2392
+ 9,
2393
+ 11,
2394
+ 13,
2395
+ 15,
2396
+ 17,
2397
+ 19,
2398
+ 20,
2399
+ 21,
2400
+ 22,
2401
+ 23,
2402
+ 25,
2403
+ 37,
2404
+ 42,
2405
+ 43,
2406
+ 53,
2407
+ 69,
2408
+ 77,
2409
+ 79,
2410
+ 87,
2411
+ 95,
2412
+ 101,
2413
+ 102,
2414
+ 103,
2415
+ 104,
2416
+ 109,
2417
+ 110,
2418
+ 111,
2419
+ 113,
2420
+ 115,
2421
+ 117,
2422
+ 119,
2423
+ 123,
2424
+ 135,
2425
+ 137,
2426
+ 139,
2427
+ 143,
2428
+ 161,
2429
+ 179,
2430
+ 389,
2431
+ 427,
2432
+ 465,
2433
+ 512,
2434
+ 513,
2435
+ 514,
2436
+ 515,
2437
+ 526,
2438
+ 530,
2439
+ 531,
2440
+ 532,
2441
+ 540,
2442
+ 548,
2443
+ 554,
2444
+ 556,
2445
+ 563,
2446
+ 587,
2447
+ 601,
2448
+ 636,
2449
+ 989,
2450
+ 990,
2451
+ 993,
2452
+ 995,
2453
+ 1719,
2454
+ 1720,
2455
+ 1723,
2456
+ 2049,
2457
+ 3659,
2458
+ 4045,
2459
+ 5060,
2460
+ 5061,
2461
+ 6e3,
2462
+ 6566,
2463
+ 6665,
2464
+ 6666,
2465
+ 6667,
2466
+ 6668,
2467
+ 6669,
2468
+ 6697,
2469
+ 10080
2470
+ ]);
2471
+ function isUnsafePort(port) {
2472
+ return unsafePorts.has(port);
2473
+ }
2474
+ function isSafePort(port) {
2475
+ return !isUnsafePort(port);
2476
+ }
2477
+ var GetPortError = class extends Error {
2478
+ constructor(message, opts) {
2479
+ super(message, opts);
2480
+ this.message = message;
2481
+ }
2482
+ name = "GetPortError";
2483
+ };
2484
+ function _log(verbose, message) {
2485
+ if (verbose) console.log(`[get-port] ${message}`);
2486
+ }
2487
+ function _generateRange(from, to) {
2488
+ if (to < from) return [];
2489
+ const r$2 = [];
2490
+ for (let index = from; index <= to; index++) r$2.push(index);
2491
+ return r$2;
2492
+ }
2493
+ function _tryPort(port, host) {
2494
+ return new Promise((resolve$1) => {
2495
+ const server = createServer();
2496
+ server.unref();
2497
+ server.on("error", () => {
2498
+ resolve$1(false);
2499
+ });
2500
+ server.listen({
2501
+ port,
2502
+ host
2503
+ }, () => {
2504
+ const { port: port2 } = server.address();
2505
+ server.close(() => {
2506
+ resolve$1(isSafePort(port2) && port2);
2507
+ });
2508
+ });
2509
+ });
2510
+ }
2511
+ function _getLocalHosts(additional) {
2512
+ const hosts = new Set(additional);
2513
+ 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);
2514
+ return [...hosts];
2515
+ }
2516
+ async function _findPort(ports, host) {
2517
+ for (const port of ports) {
2518
+ const r$2 = await _tryPort(port, host);
2519
+ if (r$2) return r$2;
2520
+ }
2521
+ }
2522
+ function _fmtOnHost(hostname) {
2523
+ return hostname ? `on host ${JSON.stringify(hostname)}` : "on any host";
2524
+ }
2525
+ const HOSTNAME_RE = /^(?!-)[\d.:A-Za-z-]{1,63}(?<!-)$/;
2526
+ function _validateHostname(hostname, _public, verbose) {
2527
+ if (hostname && !HOSTNAME_RE.test(hostname)) {
2528
+ const fallbackHost = _public ? "0.0.0.0" : "127.0.0.1";
2529
+ _log(verbose, `Invalid hostname: ${JSON.stringify(hostname)}. Using ${JSON.stringify(fallbackHost)} as fallback.`);
2530
+ return fallbackHost;
2531
+ }
2532
+ return hostname;
2533
+ }
2534
+ async function getPort(_userOptions = {}) {
2535
+ if (typeof _userOptions === "number" || typeof _userOptions === "string") _userOptions = { port: Number.parseInt(_userOptions + "") || 0 };
2536
+ const _port = Number(_userOptions.port ?? process.env.PORT);
2537
+ const _userSpecifiedAnyPort = Boolean(_userOptions.port || _userOptions.ports?.length || _userOptions.portRange?.length);
2538
+ const options = {
2539
+ random: _port === 0,
2540
+ ports: [],
2541
+ portRange: [],
2542
+ alternativePortRange: _userSpecifiedAnyPort ? [] : [3e3, 3100],
2543
+ verbose: false,
2544
+ ..._userOptions,
2545
+ port: _port,
2546
+ host: _validateHostname(_userOptions.host ?? process.env.HOST, _userOptions.public, _userOptions.verbose)
2547
+ };
2548
+ if (options.random && !_userSpecifiedAnyPort) return getRandomPort(options.host);
2549
+ const portsToCheck = [
2550
+ options.port,
2551
+ ...options.ports,
2552
+ ..._generateRange(...options.portRange)
2553
+ ].filter((port) => {
2554
+ if (!port) return false;
2555
+ if (!isSafePort(port)) {
2556
+ _log(options.verbose, `Ignoring unsafe port: ${port}`);
2557
+ return false;
2558
+ }
2559
+ return true;
2560
+ });
2561
+ if (portsToCheck.length === 0) portsToCheck.push(3e3);
2562
+ let availablePort = await _findPort(portsToCheck, options.host);
2563
+ if (!availablePort && options.alternativePortRange.length > 0) {
2564
+ availablePort = await _findPort(_generateRange(...options.alternativePortRange), options.host);
2565
+ if (portsToCheck.length > 0) {
2566
+ let message = `Unable to find an available port (tried ${portsToCheck.join("-")} ${_fmtOnHost(options.host)}).`;
2567
+ if (availablePort) message += ` Using alternative port ${availablePort}.`;
2568
+ _log(options.verbose, message);
2569
+ }
2570
+ }
2571
+ if (!availablePort && _userOptions.random !== false) {
2572
+ availablePort = await getRandomPort(options.host);
2573
+ if (availablePort) _log(options.verbose, `Using random port ${availablePort}`);
2574
+ }
2575
+ if (!availablePort) {
2576
+ const triedRanges = [
2577
+ options.port,
2578
+ options.portRange.join("-"),
2579
+ options.alternativePortRange.join("-")
2580
+ ].filter(Boolean).join(", ");
2581
+ throw new GetPortError(`Unable to find an available port ${_fmtOnHost(options.host)} (tried ${triedRanges})`);
2582
+ }
2583
+ return availablePort;
2584
+ }
2585
+ async function getRandomPort(host) {
2586
+ const port = await checkPort(0, host);
2587
+ if (port === false) throw new GetPortError(`Unable to find a random port ${_fmtOnHost(host)}`);
2588
+ return port;
2589
+ }
2590
+ async function checkPort(port, host = process.env.HOST, verbose) {
2591
+ if (!host) host = _getLocalHosts([void 0, "0.0.0.0"]);
2592
+ if (!Array.isArray(host)) return _tryPort(port, host);
2593
+ for (const _host of host) {
2594
+ const _port = await _tryPort(port, _host);
2595
+ if (_port === false) {
2596
+ if (port < 1024 && verbose) _log(verbose, `Unable to listen to the privileged port ${port} ${_fmtOnHost(_host)}`);
2597
+ return false;
2598
+ }
2599
+ if (port === 0 && _port !== 0) port = _port;
2600
+ }
2601
+ return port;
2602
+ }
2603
+
2604
+ //#endregion
2605
+ //#region src/node/constants.ts
2606
+ const MARK_CHECK = ansis_default.green("✔");
2607
+ const MARK_INFO = ansis_default.blue("ℹ");
2608
+ const MARK_ERROR = ansis_default.red("✖");
2609
+ const MARK_NODE = "⬢";
2610
+
2611
+ //#endregion
2612
+ //#region src/node/ws.ts
2613
+ const ANONYMOUS_SCOPE = "vite:anonymous:";
2614
+ async function createWsServer(options) {
2615
+ const rpcHost = options.context.rpc;
2616
+ const port = options.portWebSocket ?? await getPort({
2617
+ port: 7812,
2618
+ random: true
2619
+ });
2620
+ const host = options.hostWebSocket ?? "localhost";
2621
+ const wsClients = /* @__PURE__ */ new Set();
2622
+ const preset = createWsRpcPreset({
2623
+ port,
2624
+ host,
2625
+ onConnected: (ws, meta) => {
2626
+ wsClients.add(ws);
2627
+ console.log(ansis_default.green`${MARK_CHECK} Websocket client [${meta.id}] connected`);
2628
+ },
2629
+ onDisconnected: (ws, meta) => {
2630
+ wsClients.delete(ws);
2631
+ console.log(ansis_default.red`${MARK_CHECK} Websocket client [${meta.id}] disconnected`);
2632
+ }
2633
+ });
2634
+ const asyncStorage = new AsyncLocalStorage();
2635
+ const isClientAuthDisabled = options.context.mode === "build" || options.context.viteConfig.devtools?.clientAuth === false || process$1.env.VITE_DEVTOOLS_DISABLE_CLIENT_AUTH === "true";
2636
+ const rpcGroup = createRpcServer(rpcHost.functions, {
2637
+ preset,
2638
+ rpcOptions: {
2639
+ onFunctionError(error, name) {
2640
+ console.error(ansis_default.red`⬢ RPC error on executing "${ansis_default.bold(name)}":`);
2641
+ console.error(error);
2642
+ },
2643
+ onGeneralError(error) {
2644
+ console.error(ansis_default.red`⬢ RPC error on executing rpc`);
2645
+ console.error(error);
2646
+ },
2647
+ resolver(name, fn) {
2648
+ const rpc = this;
2649
+ if (!name.startsWith(ANONYMOUS_SCOPE) && !rpc.$meta.isTrusted && !isClientAuthDisabled) return () => {
2650
+ throw new Error(`Unauthorized access to method ${JSON.stringify(name)} from client [${rpc.$meta.id}]`);
2651
+ };
2652
+ if (!fn) return void 0;
2653
+ return async function(...args) {
2654
+ return await asyncStorage.run({
2655
+ rpc,
2656
+ meta: rpc.$meta
2657
+ }, async () => {
2658
+ return (await fn).apply(this, args);
2659
+ });
2660
+ };
2661
+ }
2662
+ }
2663
+ });
2664
+ rpcHost._rpcGroup = rpcGroup;
2665
+ rpcHost._asyncStorage = asyncStorage;
2666
+ const getConnectionMeta = async () => {
2667
+ return {
2668
+ backend: "websocket",
2669
+ websocket: port
2670
+ };
2671
+ };
2672
+ return {
2673
+ port,
2674
+ rpc: rpcGroup,
2675
+ rpcHost,
2676
+ getConnectionMeta
2677
+ };
2678
+ }
2679
+
2680
+ //#endregion
2681
+ //#region src/node/server.ts
2682
+ async function createDevToolsMiddleware(options) {
2683
+ const h3 = createApp();
2684
+ const { rpc, getConnectionMeta } = await createWsServer(options);
2685
+ h3.use("/.vdt-connection.json", eventHandler(async (event) => {
2686
+ event.node.res.setHeader("Content-Type", "application/json");
2687
+ return event.node.res.end(JSON.stringify(await getConnectionMeta()));
2688
+ }));
2689
+ h3.use(fromNodeMiddleware(sirv(dirClientStandalone, {
2690
+ dev: true,
2691
+ single: true
2692
+ })));
2693
+ return {
2694
+ h3,
2695
+ rpc,
2696
+ middleware: toNodeListener(h3),
2697
+ getConnectionMeta
2698
+ };
2699
+ }
2700
+
2701
+ //#endregion
2702
+ //#region src/node/plugins/server.ts
2703
+ /**
2704
+ * Core plugin for enabling Vite DevTools
2705
+ */
2706
+ function DevToolsServer() {
2707
+ let context;
2708
+ return {
2709
+ name: "vite:devtools:server",
2710
+ enforce: "post",
2711
+ apply: "serve",
2712
+ async configureServer(viteDevServer) {
2713
+ context = await createDevToolsContext(viteDevServer.config, viteDevServer);
2714
+ const host = viteDevServer.config.server.host === true ? "0.0.0.0" : viteDevServer.config.server.host || "localhost";
2715
+ const { middleware } = await createDevToolsMiddleware({
2716
+ cwd: viteDevServer.config.root,
2717
+ hostWebSocket: host,
2718
+ context
2719
+ });
2720
+ viteDevServer.middlewares.use("/.devtools/", middleware);
2721
+ },
2722
+ resolveId(id) {
2723
+ if (id === "/.devtools-imports") return id;
2724
+ },
2725
+ load(id) {
2726
+ if (id === "/.devtools-imports") {
2727
+ if (!context) throw new Error("DevTools context is not initialized");
2728
+ const docks = Array.from(context.docks.values());
2729
+ const map = /* @__PURE__ */ new Map();
2730
+ for (const dock of docks) {
2731
+ const id$1 = `${dock.type}:${dock.id}`;
2732
+ if (dock.type === "action") map.set(id$1, dock.action);
2733
+ else if (dock.type === "custom-render") map.set(id$1, dock.renderer);
2734
+ else if (dock.type === "iframe" && dock.clientScript) map.set(id$1, dock.clientScript);
2735
+ }
2736
+ return [
2737
+ `export const importsMap = {`,
2738
+ ...[...map.entries()].filter(([, entry]) => entry != null).map(([id$1, { importFrom, importName }]) => ` [${JSON.stringify(id$1)}]: () => import(${JSON.stringify(importFrom)}).then(r => r[${JSON.stringify(importName)}]),`),
2739
+ "}"
2740
+ ].join("\n");
2741
+ }
2742
+ }
2743
+ };
2744
+ }
2745
+
2746
+ //#endregion
2747
+ //#region src/node/plugins/index.ts
2748
+ async function DevTools(options = {}) {
2749
+ const { builtinDevTools = true } = options;
2750
+ const plugins = [DevToolsInjection(), DevToolsServer()];
2751
+ if (builtinDevTools) plugins.push(await import("@vitejs/devtools-vite").then((m$1) => m$1.DevToolsViteUI()));
2752
+ return plugins;
2753
+ }
2754
+
2755
+ //#endregion
2756
+ export { createApp as a, sendRedirect as c, ansis_default as d, getPort as i, toNodeListener as l, createDevToolsMiddleware as n, eventHandler as o, MARK_NODE as r, fromNodeMiddleware as s, DevTools as t, createDevToolsContext as u };