mason4agents 0.1.0

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,4301 @@
1
+ // @bun
2
+ var __defProp = Object.defineProperty;
3
+ var __returnValue = (v) => v;
4
+ function __exportSetter(name, newValue) {
5
+ this[name] = __returnValue.bind(null, newValue);
6
+ }
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true,
12
+ configurable: true,
13
+ set: __exportSetter.bind(all, name)
14
+ });
15
+ };
16
+
17
+ // src/pi/cli.ts
18
+ import { spawn } from "child_process";
19
+
20
+ // src/pi/binary.ts
21
+ import { accessSync, constants, existsSync, statSync } from "fs";
22
+ import { dirname, join, resolve } from "path";
23
+ import { fileURLToPath } from "url";
24
+ function resolveMasonBinary(env = process.env, startUrl = import.meta.url) {
25
+ return resolveMasonBinaryDetailed(env, startUrl).path;
26
+ }
27
+ function resolveMasonBinaryDetailed(env = process.env, startUrl = import.meta.url) {
28
+ if (env.MASON4AGENTS_BIN && env.MASON4AGENTS_BIN.length > 0) {
29
+ const explicit = resolve(env.MASON4AGENTS_BIN);
30
+ if (!existsSync(explicit)) {
31
+ throw new Error(`MASON4AGENTS_BIN points to a missing file: ${explicit}`);
32
+ }
33
+ const stat = statSync(explicit);
34
+ if (!stat.isFile()) {
35
+ throw new Error(`MASON4AGENTS_BIN points to a non-file path: ${explicit}`);
36
+ }
37
+ if (process.platform !== "win32" && (stat.mode & 73) === 0) {
38
+ throw new Error(`MASON4AGENTS_BIN points to a non-executable file: ${explicit}`);
39
+ }
40
+ return { path: explicit, source: "env" };
41
+ }
42
+ const root = packageRoot(startUrl);
43
+ for (const candidate of bundledCandidates(root)) {
44
+ if (existsSync(candidate) && isExecutable(candidate)) {
45
+ return { path: candidate, source: "bundled" };
46
+ }
47
+ }
48
+ for (const candidate of developmentCandidates(root)) {
49
+ if (existsSync(candidate) && isExecutable(candidate)) {
50
+ return { path: candidate, source: "development" };
51
+ }
52
+ }
53
+ throw new Error(`Unable to locate mason4agents native binary. Set MASON4AGENTS_BIN or build crates/mason4agents.`);
54
+ }
55
+ function isExecutable(filePath) {
56
+ if (process.platform === "win32") {
57
+ return existsSync(filePath) && statSync(filePath).isFile();
58
+ }
59
+ try {
60
+ return statSync(filePath).isFile() && (accessSync(filePath, constants.X_OK), true);
61
+ } catch {
62
+ return false;
63
+ }
64
+ }
65
+ function packageRoot(startUrl = import.meta.url) {
66
+ let dir = dirname(fileURLToPath(startUrl));
67
+ for (let i = 0;i < 8; i += 1) {
68
+ if (existsSync(join(dir, "package.json"))) {
69
+ return dir;
70
+ }
71
+ const parent = dirname(dir);
72
+ if (parent === dir) {
73
+ break;
74
+ }
75
+ dir = parent;
76
+ }
77
+ return resolve(dirname(fileURLToPath(startUrl)), "..", "..");
78
+ }
79
+ function bundledCandidates(root) {
80
+ const platform = process.platform;
81
+ const arch = normalizeArch(process.arch);
82
+ const exe = platform === "win32" ? ".exe" : "";
83
+ const candidates = [
84
+ join(root, "native", `mason4agents-${platform}-${arch}${exe}`),
85
+ join(root, "native", `mason4agents${exe}`),
86
+ join(root, "dist", "native", `mason4agents-${platform}-${arch}${exe}`),
87
+ join(root, "dist", "native", `mason4agents${exe}`)
88
+ ];
89
+ if (platform === "win32") {
90
+ candidates.unshift(join(root, "native", `mason4agents-${platform}-${arch}`), join(root, "dist", "native", `mason4agents-${platform}-${arch}`));
91
+ }
92
+ return candidates;
93
+ }
94
+ function developmentCandidates(root) {
95
+ const exe = process.platform === "win32" ? ".exe" : "";
96
+ return [
97
+ join(root, "target", "debug", "mason4agents" + exe),
98
+ join(root, "target", "release", "mason4agents" + exe),
99
+ join(root, "..", "target", "debug", "mason4agents" + exe),
100
+ join(root, "..", "target", "release", "mason4agents" + exe)
101
+ ];
102
+ }
103
+ function normalizeArch(arch) {
104
+ if (arch === "x64")
105
+ return "x64";
106
+ if (arch === "arm64")
107
+ return "arm64";
108
+ return arch;
109
+ }
110
+
111
+ // src/pi/cli.ts
112
+ class MasonCliError extends Error {
113
+ code;
114
+ details;
115
+ stderr;
116
+ constructor(message, code, details, stderr) {
117
+ super(message);
118
+ this.name = "MasonCliError";
119
+ this.code = code;
120
+ this.details = details;
121
+ this.stderr = stderr;
122
+ }
123
+ }
124
+ function createCliBridge(binary) {
125
+ return {
126
+ run(args, options) {
127
+ return runCliJson(binary ?? resolveMasonBinary(), args, options);
128
+ }
129
+ };
130
+ }
131
+ function runCliJson(binary, args, options = {}) {
132
+ const finalArgs = args.includes("--json") ? args : [...args, "--json"];
133
+ if (options.signal?.aborted) {
134
+ return Promise.reject(new MasonCliError("mason4agents command aborted before start", "aborted", undefined, ""));
135
+ }
136
+ return new Promise((resolve2, reject) => {
137
+ const child = spawn(binary, finalArgs, { stdio: ["ignore", "pipe", "pipe"], env: process.env });
138
+ let stdout = "";
139
+ let stderr = "";
140
+ let settled = false;
141
+ const abort = () => {
142
+ if (settled)
143
+ return;
144
+ child.kill("SIGTERM");
145
+ settled = true;
146
+ reject(new MasonCliError("mason4agents command aborted", "aborted", undefined, stderr));
147
+ };
148
+ options.signal?.addEventListener("abort", abort, { once: true });
149
+ child.stdout.setEncoding("utf8");
150
+ child.stderr.setEncoding("utf8");
151
+ child.stdout.on("data", (chunk) => {
152
+ stdout += chunk;
153
+ });
154
+ child.stderr.on("data", (chunk) => {
155
+ stderr += chunk;
156
+ });
157
+ child.on("error", (err) => {
158
+ if (settled)
159
+ return;
160
+ settled = true;
161
+ options.signal?.removeEventListener("abort", abort);
162
+ reject(err);
163
+ });
164
+ child.on("close", (code) => {
165
+ if (settled)
166
+ return;
167
+ settled = true;
168
+ options.signal?.removeEventListener("abort", abort);
169
+ let parsed;
170
+ if (code === 0 || stdout.startsWith("{")) {
171
+ try {
172
+ parsed = parseJson(stdout, stderr);
173
+ } catch (err) {
174
+ reject(err);
175
+ return;
176
+ }
177
+ }
178
+ if (code === 0 && isOkEnvelope(parsed)) {
179
+ resolve2(parsed.data);
180
+ return;
181
+ }
182
+ if (code === 0) {
183
+ resolve2(parsed);
184
+ return;
185
+ }
186
+ if (isErrorEnvelope(parsed)) {
187
+ reject(new MasonCliError(parsed.error.message, parsed.error.code, parsed, stderr));
188
+ return;
189
+ }
190
+ reject(new MasonCliError(stderr || `mason4agents exited with code ${code ?? -1}`, "command_failed", parsed, stderr));
191
+ });
192
+ });
193
+ }
194
+ function parseJson(stdout, stderr) {
195
+ try {
196
+ return JSON.parse(stdout);
197
+ } catch (cause) {
198
+ throw new MasonCliError(`mason4agents produced invalid JSON on stdout: ${cause.message}`, "invalid_json", stdout, stderr);
199
+ }
200
+ }
201
+ function isOkEnvelope(value) {
202
+ return typeof value === "object" && value !== null && value.ok === true && "data" in value;
203
+ }
204
+ function isErrorEnvelope(value) {
205
+ if (typeof value !== "object" || value === null)
206
+ return false;
207
+ const envelope = value;
208
+ if (envelope.ok !== false || typeof envelope.error !== "object" || envelope.error === null)
209
+ return false;
210
+ const error = envelope.error;
211
+ return typeof error.code === "string" && typeof error.message === "string";
212
+ }
213
+
214
+ // src/pi/mason-render.ts
215
+ var TABLE_SEPARATOR = " ";
216
+ var DEFAULT_MAX_ROWS = 24;
217
+ function usageDisplay() {
218
+ return {
219
+ kind: "usage",
220
+ title: "mason4agents commands",
221
+ lines: [
222
+ "/mason open interactive panel",
223
+ "/mason refresh [--registry <source>]",
224
+ "/mason search [query] [--category <category>] [--language <language>] [--registry <source>]",
225
+ "/mason list [--installed] [--outdated] [--registry <source>]",
226
+ "/mason installed alias for list --installed",
227
+ "/mason outdated alias for list --outdated",
228
+ "/mason install <pkg[@version]>... [--registry <source>] [--allow-build-scripts]",
229
+ "/mason uninstall <pkg>...",
230
+ "/mason update [pkg...] [--registry <source>] [--allow-build-scripts]",
231
+ "/mason which <executable>",
232
+ "/mason bin-dir",
233
+ "/mason env --shell bash|zsh|fish|powershell|cmd|json",
234
+ "/mason doctor",
235
+ "",
236
+ "Table views: use / to filter, \u2191/\u2193 or PgUp/PgDn to scroll, q or Esc to close."
237
+ ]
238
+ };
239
+ }
240
+ function errorDisplay(title, message, lines = []) {
241
+ return { kind: "error", title, message, lines };
242
+ }
243
+ function modelForResult(kind, data, title) {
244
+ switch (kind) {
245
+ case "packages":
246
+ return packageTable(title, data);
247
+ case "installed":
248
+ return installedTable(title, data);
249
+ case "install":
250
+ return installTable(title, data);
251
+ case "uninstall":
252
+ return uninstallTable(title, data);
253
+ case "which":
254
+ return whichSummary(title, data);
255
+ case "bin-dir":
256
+ return binDirSummary(title, data);
257
+ case "env":
258
+ return envSummary(title, data);
259
+ case "doctor":
260
+ return doctorSummary(title, data);
261
+ case "refresh":
262
+ return refreshSummary(title, data);
263
+ }
264
+ }
265
+ function renderDisplay(model, options) {
266
+ const width = normalizeWidth(options.width);
267
+ switch (model.kind) {
268
+ case "table":
269
+ return renderTableDisplay(model, width, options);
270
+ case "summary":
271
+ return renderTextDisplay(model.title, model.lines, width);
272
+ case "usage":
273
+ return renderTextDisplay(model.title, model.lines, width);
274
+ case "error": {
275
+ const lines = [`Error: ${model.message}`, ...model.lines ?? []];
276
+ return renderTextDisplay(model.title, lines, width);
277
+ }
278
+ }
279
+ }
280
+ function renderDisplayText(model, width = 120) {
281
+ return renderDisplay(model, { width, maxRows: 100 }).join(`
282
+ `);
283
+ }
284
+ function modelSupportsFiltering(model) {
285
+ return model.kind === "table" && model.searchable;
286
+ }
287
+ function packageTable(title, data) {
288
+ const rows = Array.isArray(data) ? data.map(packageRow) : [];
289
+ const display = {
290
+ kind: "table",
291
+ title,
292
+ columns: [
293
+ { label: "Name", minWidth: 8, maxWidth: 28 },
294
+ { label: "Version", minWidth: 7, maxWidth: 16 },
295
+ { label: "Status", minWidth: 8, maxWidth: 12 },
296
+ { label: "Installed", minWidth: 9, maxWidth: 16 },
297
+ { label: "Languages", minWidth: 9, maxWidth: 18 },
298
+ { label: "Categories", minWidth: 10, maxWidth: 18 },
299
+ { label: "Description", minWidth: 12, maxWidth: 48 }
300
+ ],
301
+ rows,
302
+ emptyMessage: Array.isArray(data) ? "No packages found." : "Unexpected package list response.",
303
+ searchable: true
304
+ };
305
+ return display;
306
+ }
307
+ function installedTable(title, data) {
308
+ const rows = Array.isArray(data) ? data.map(installedRow) : [];
309
+ return {
310
+ kind: "table",
311
+ title,
312
+ columns: [
313
+ { label: "Name", minWidth: 8, maxWidth: 30 },
314
+ { label: "Version", minWidth: 7, maxWidth: 16 },
315
+ { label: "Bins", minWidth: 4, maxWidth: 32 },
316
+ { label: "Installed At", minWidth: 12, maxWidth: 24 }
317
+ ],
318
+ rows,
319
+ emptyMessage: Array.isArray(data) ? "No packages installed." : "Unexpected installed package response.",
320
+ searchable: true
321
+ };
322
+ }
323
+ function installTable(title, data) {
324
+ if (!Array.isArray(data))
325
+ return summaryFromUnknown(title, data);
326
+ return {
327
+ kind: "table",
328
+ title,
329
+ columns: [
330
+ { label: "Package", minWidth: 8, maxWidth: 30 },
331
+ { label: "Version", minWidth: 7, maxWidth: 16 },
332
+ { label: "Source", minWidth: 8, maxWidth: 36 },
333
+ { label: "Bins", minWidth: 4, maxWidth: 32 },
334
+ { label: "Package Dir", minWidth: 11, maxWidth: 48 }
335
+ ],
336
+ rows: data.map(installRow),
337
+ emptyMessage: "Nothing to install or update.",
338
+ searchable: true
339
+ };
340
+ }
341
+ function uninstallTable(title, data) {
342
+ if (!Array.isArray(data))
343
+ return summaryFromUnknown(title, data);
344
+ return {
345
+ kind: "table",
346
+ title,
347
+ columns: [
348
+ { label: "Package", minWidth: 8, maxWidth: 32 },
349
+ { label: "Result", minWidth: 7, maxWidth: 16 }
350
+ ],
351
+ rows: data.map(uninstallRow),
352
+ emptyMessage: "Nothing to uninstall.",
353
+ searchable: true
354
+ };
355
+ }
356
+ function whichSummary(title, data) {
357
+ if (!isRecord(data))
358
+ return summaryFromUnknown(title, data);
359
+ const executable = stringValue(data.executable) || "<unknown>";
360
+ const path = stringValue(data.path);
361
+ const pkg = stringValue(data.package);
362
+ const lines = path.length > 0 ? [`${executable}: ${path}`, pkg.length > 0 ? `Package: ${pkg}` : ""] : [`${executable}: not found`, pkg.length > 0 ? `Package: ${pkg}` : ""];
363
+ return { kind: "summary", title, lines: lines.filter((line) => line.length > 0) };
364
+ }
365
+ function binDirSummary(title, data) {
366
+ if (isRecord(data)) {
367
+ const binDir = stringValue(data.bin_dir);
368
+ if (binDir.length > 0)
369
+ return { kind: "summary", title, lines: [`Bin dir: ${binDir}`] };
370
+ }
371
+ if (typeof data === "string")
372
+ return { kind: "summary", title, lines: [`Bin dir: ${data}`] };
373
+ return summaryFromUnknown(title, data);
374
+ }
375
+ function envSummary(title, data) {
376
+ if (!isRecord(data))
377
+ return summaryFromUnknown(title, data);
378
+ const shell = stringValue(data.shell);
379
+ if (shell.length > 0)
380
+ return { kind: "summary", title, lines: [shell] };
381
+ const path = stringValue(data.PATH);
382
+ if (path.length > 0)
383
+ return { kind: "summary", title, lines: [`PATH=${path}`] };
384
+ return summaryFromUnknown(title, data);
385
+ }
386
+ function refreshSummary(title, data) {
387
+ if (!isRecord(data))
388
+ return summaryFromUnknown(title, data);
389
+ return {
390
+ kind: "summary",
391
+ title,
392
+ lines: [
393
+ `Source: ${stringValue(data.source) || "-"}`,
394
+ `Packages: ${stringValue(data.package_count) || "0"}`,
395
+ `Cache: ${stringValue(data.cache_file) || "-"}`,
396
+ `Checksum: ${stringValue(data.checksum) || "-"}`
397
+ ]
398
+ };
399
+ }
400
+ function doctorSummary(title, data) {
401
+ if (!isRecord(data))
402
+ return summaryFromUnknown(title, data);
403
+ const lines = [];
404
+ const paths = recordValue(data.paths);
405
+ if (paths) {
406
+ pushLine(lines, "Bin dir", paths.bin_dir);
407
+ pushLine(lines, "Bin dir exists", yesNo(paths.bin_dir_exists));
408
+ pushLine(lines, "Data writable", yesNo(paths.data_dir_writable));
409
+ }
410
+ const registry = recordValue(data.registry);
411
+ if (registry) {
412
+ if (registry.cache_present === true) {
413
+ lines.push(`Registry cache: ${stringValue(registry.package_count) || "0"} packages`);
414
+ } else {
415
+ lines.push(`Registry cache: ${stringValue(registry.error) || "missing"}`);
416
+ }
417
+ }
418
+ const pathEnv = recordValue(data.path_env);
419
+ if (pathEnv) {
420
+ pushLine(lines, "PATH contains bin", yesNo(pathEnv.contains_bin_dir));
421
+ pushLine(lines, "PATH bin first", yesNo(pathEnv.bin_dir_first));
422
+ }
423
+ const managers = Array.isArray(data.managers) ? data.managers : [];
424
+ if (managers.length > 0) {
425
+ lines.push("Managers:");
426
+ for (const manager of managers) {
427
+ if (!isRecord(manager))
428
+ continue;
429
+ const name = stringValue(manager.source_type) || "<unknown>";
430
+ lines.push(` ${name}: ${manager.available === true ? "installed" : "missing"}`);
431
+ }
432
+ }
433
+ lines.push(`Overall: ${data.ok === true ? "ok" : "needs attention"}`);
434
+ return { kind: "summary", title, lines };
435
+ }
436
+ function summaryFromUnknown(title, data) {
437
+ return { kind: "summary", title, lines: summarizeUnknown(data) };
438
+ }
439
+ function packageRow(value) {
440
+ if (!isRecord(value))
441
+ return [String(value), "", "", "", "", "", ""];
442
+ return [
443
+ stringValue(value.name) || "<unknown>",
444
+ stringValue(value.version) || "-",
445
+ packageStatus(value),
446
+ stringValue(value.installed_version) || "-",
447
+ stringList(value.languages),
448
+ stringList(value.categories),
449
+ stringValue(value.description)
450
+ ];
451
+ }
452
+ function installedRow(value) {
453
+ if (!isRecord(value))
454
+ return [String(value), "", "", ""];
455
+ return [
456
+ stringValue(value.name) || "<unknown>",
457
+ stringValue(value.version) || "-",
458
+ keyList(value.bins),
459
+ stringValue(value.installed_at) || "-"
460
+ ];
461
+ }
462
+ function installRow(value) {
463
+ if (!isRecord(value))
464
+ return [String(value), "", "", "", ""];
465
+ return [
466
+ stringValue(value.package) || "<unknown>",
467
+ stringValue(value.version) || "-",
468
+ stringValue(value.source_id) || "-",
469
+ keyList(value.bins),
470
+ stringValue(value.package_dir) || "-"
471
+ ];
472
+ }
473
+ function uninstallRow(value) {
474
+ if (!isRecord(value))
475
+ return [String(value), ""];
476
+ return [stringValue(value.package) || "<unknown>", value.removed === true ? "removed" : "not installed"];
477
+ }
478
+ function packageStatus(value) {
479
+ if (value.deprecated === true)
480
+ return "deprecated";
481
+ if (value.installed === true && value.outdated === true)
482
+ return "outdated";
483
+ if (value.installed === true)
484
+ return "installed";
485
+ return "available";
486
+ }
487
+ function renderTableDisplay(model, width, options) {
488
+ const filter = options.filter?.trim() ?? "";
489
+ const filteredRows = filterTableRows(model.rows, filter);
490
+ const maxRows = Math.max(1, Math.floor(options.maxRows ?? DEFAULT_MAX_ROWS));
491
+ const maxScroll = Math.max(0, filteredRows.length - maxRows);
492
+ const scroll = clamp(Math.floor(options.scroll ?? 0), 0, maxScroll);
493
+ const end = Math.min(filteredRows.length, scroll + maxRows);
494
+ const titleParts = [`${model.title} \u2014 ${filteredRows.length}/${model.rows.length}`];
495
+ if (filter.length > 0)
496
+ titleParts.push(`filter: ${filter}`);
497
+ const lines = [truncateToWidth(titleParts.join(" "), width)];
498
+ if (model.subtitle && model.subtitle.length > 0)
499
+ lines.push(truncateToWidth(model.subtitle, width));
500
+ if (filteredRows.length === 0) {
501
+ lines.push(truncateToWidth(model.emptyMessage, width));
502
+ return lines;
503
+ }
504
+ const visibleRows = filteredRows.slice(scroll, end);
505
+ const layout = computeColumnLayout(model.columns, visibleRows, width);
506
+ lines.push(formatTableRow(model.columns.map((column) => column.label), layout, width));
507
+ lines.push(truncateToWidth(layout.separator, width));
508
+ for (const row of visibleRows)
509
+ lines.push(formatTableRow(row, layout, width));
510
+ const range = `showing ${scroll + 1}-${end} of ${filteredRows.length}`;
511
+ const help = model.searchable ? `${range} / filter \u2191\u2193 scroll q close` : `${range} \u2191\u2193 scroll q close`;
512
+ lines.push(truncateToWidth(help, width));
513
+ if (model.footer) {
514
+ for (const line of model.footer)
515
+ lines.push(truncateToWidth(line, width));
516
+ }
517
+ return lines;
518
+ }
519
+ function renderTextDisplay(title, textLines, width) {
520
+ const lines = [truncateToWidth(title, width)];
521
+ for (const line of textLines)
522
+ lines.push(truncateToWidth(line, width));
523
+ return lines;
524
+ }
525
+ function filterTableRows(rows, filter) {
526
+ if (filter.length === 0)
527
+ return rows;
528
+ const needle = filter.toLocaleLowerCase();
529
+ return rows.filter((row) => row.join(" ").toLocaleLowerCase().includes(needle));
530
+ }
531
+ function computeColumnLayout(columns, rows, width) {
532
+ if (columns.length === 0)
533
+ return { widths: [width], separator: "" };
534
+ let count = columns.length;
535
+ while (count > 1 && minimumTableWidth(columns, count) > width)
536
+ count -= 1;
537
+ const widths = [];
538
+ for (let index = 0;index < count; index += 1) {
539
+ const column = columns[index];
540
+ const minWidth = columnMinWidth(column);
541
+ const maxWidth = Math.max(minWidth, column.maxWidth ?? 80);
542
+ let desired = clamp(column.label.length, minWidth, maxWidth);
543
+ for (const row of rows) {
544
+ desired = Math.max(desired, clamp((row[index] ?? "").length, minWidth, maxWidth));
545
+ }
546
+ widths.push(desired);
547
+ }
548
+ let total = widths.reduce((sum, value) => sum + value, 0) + TABLE_SEPARATOR.length * Math.max(0, count - 1);
549
+ while (total > width && widths.some((value, index) => value > columnMinWidth(columns[index]))) {
550
+ let widest = 0;
551
+ for (let index = 1;index < widths.length; index += 1) {
552
+ if (widths[index] > widths[widest])
553
+ widest = index;
554
+ }
555
+ const minWidth = columnMinWidth(columns[widest]);
556
+ if (widths[widest] <= minWidth)
557
+ break;
558
+ widths[widest] = widths[widest] - 1;
559
+ total -= 1;
560
+ }
561
+ if (total > width && widths.length === 1)
562
+ widths[0] = width;
563
+ return { widths, separator: "\u2500".repeat(Math.min(width, Math.max(1, total))) };
564
+ }
565
+ function minimumTableWidth(columns, count) {
566
+ let total = TABLE_SEPARATOR.length * Math.max(0, count - 1);
567
+ for (let index = 0;index < count; index += 1)
568
+ total += columnMinWidth(columns[index]);
569
+ return total;
570
+ }
571
+ function columnMinWidth(column) {
572
+ return Math.max(1, column.minWidth ?? Math.min(8, Math.max(1, column.label.length)));
573
+ }
574
+ function formatTableRow(row, layout, width) {
575
+ const cells = layout.widths.map((cellWidth, index) => padRight(truncateToWidth(row[index] ?? "", cellWidth), cellWidth));
576
+ return truncateToWidth(cells.join(TABLE_SEPARATOR), width);
577
+ }
578
+ function truncateToWidth(value, width) {
579
+ if (width <= 0)
580
+ return "";
581
+ if (value.length <= width)
582
+ return value;
583
+ if (width === 1)
584
+ return value.slice(0, 1);
585
+ return `${value.slice(0, width - 1)}\u2026`;
586
+ }
587
+ function padRight(value, width) {
588
+ if (value.length >= width)
589
+ return value;
590
+ return value + " ".repeat(width - value.length);
591
+ }
592
+ function normalizeWidth(width) {
593
+ if (!Number.isFinite(width))
594
+ return 80;
595
+ return Math.max(1, Math.floor(width));
596
+ }
597
+ function clamp(value, min, max) {
598
+ return Math.min(max, Math.max(min, value));
599
+ }
600
+ function isRecord(value) {
601
+ return typeof value === "object" && value !== null;
602
+ }
603
+ function recordValue(value) {
604
+ return isRecord(value) ? value : undefined;
605
+ }
606
+ function stringValue(value) {
607
+ if (value === null || value === undefined)
608
+ return "";
609
+ if (typeof value === "string")
610
+ return value;
611
+ if (typeof value === "number" || typeof value === "boolean")
612
+ return String(value);
613
+ return "";
614
+ }
615
+ function stringList(value) {
616
+ if (!Array.isArray(value))
617
+ return "";
618
+ return value.map(stringValue).filter((item) => item.length > 0).join(",");
619
+ }
620
+ function keyList(value) {
621
+ if (!isRecord(value))
622
+ return "";
623
+ return Object.keys(value).join(",");
624
+ }
625
+ function yesNo(value) {
626
+ if (value === true)
627
+ return "yes";
628
+ if (value === false)
629
+ return "no";
630
+ return stringValue(value) || "unknown";
631
+ }
632
+ function pushLine(lines, label, value) {
633
+ const rendered = stringValue(value);
634
+ if (rendered.length > 0)
635
+ lines.push(`${label}: ${rendered}`);
636
+ }
637
+ function summarizeUnknown(value) {
638
+ if (value === null || value === undefined)
639
+ return ["No data returned."];
640
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
641
+ return [String(value)];
642
+ if (Array.isArray(value))
643
+ return [`${value.length} item(s) returned.`];
644
+ if (!isRecord(value))
645
+ return [String(value)];
646
+ const lines = [];
647
+ for (const [key, child] of Object.entries(value)) {
648
+ if (child === null || child === undefined) {
649
+ lines.push(`${key}: -`);
650
+ } else if (typeof child === "string" || typeof child === "number" || typeof child === "boolean") {
651
+ lines.push(`${key}: ${String(child)}`);
652
+ } else if (Array.isArray(child)) {
653
+ lines.push(`${key}: ${child.length} item(s)`);
654
+ } else {
655
+ lines.push(`${key}: object`);
656
+ }
657
+ }
658
+ return lines.length > 0 ? lines : ["No displayable fields returned."];
659
+ }
660
+
661
+ // src/pi/mason-command.ts
662
+ class MasonCommandInputError extends Error {
663
+ constructor(message) {
664
+ super(message);
665
+ this.name = "MasonCommandInputError";
666
+ }
667
+ }
668
+ var SHELLS = new Set(["bash", "zsh", "fish", "powershell", "cmd", "json"]);
669
+ async function executeMasonCommand(input, bridge, options = {}) {
670
+ let parsed;
671
+ try {
672
+ parsed = parseMasonCommandInput(input);
673
+ } catch (err) {
674
+ return errorDisplay("mason4agents", messageFromError(err), usageDisplay().lines);
675
+ }
676
+ if (parsed.kind === "usage")
677
+ return usageDisplay();
678
+ try {
679
+ const data = await bridge.run(parsed.argv, options);
680
+ return modelForResult(parsed.resultKind, data, parsed.title);
681
+ } catch (err) {
682
+ return errorDisplay(parsed.title, messageFromError(err));
683
+ }
684
+ }
685
+ function parseMasonCommandInput(input) {
686
+ const tokens = tokenizeMasonArgs(input);
687
+ if (tokens.length === 0 || tokens[0] === "help" || tokens[0] === "--help" || tokens[0] === "-h")
688
+ return { kind: "usage" };
689
+ return parseMasonCommandTokens(tokens);
690
+ }
691
+ function parseMasonCommandTokens(tokens) {
692
+ const command = tokens[0];
693
+ if (!command)
694
+ return { kind: "usage" };
695
+ if (command === "help" || command === "--help" || command === "-h")
696
+ return { kind: "usage" };
697
+ const rest = tokens.slice(1);
698
+ switch (command) {
699
+ case "refresh":
700
+ return parseRefresh(rest);
701
+ case "search":
702
+ return parseSearch(rest);
703
+ case "list":
704
+ return parseList(rest);
705
+ case "installed":
706
+ return parseInstalled(rest);
707
+ case "outdated":
708
+ return parseOutdated(rest);
709
+ case "install":
710
+ return parseInstall(rest);
711
+ case "uninstall":
712
+ return parseUninstall(rest);
713
+ case "update":
714
+ return parseUpdate(rest);
715
+ case "which":
716
+ return parseWhich(rest);
717
+ case "bin-dir":
718
+ return parseNoArgCommand("bin-dir", rest, ["bin-dir"], "bin-dir", "mason bin-dir");
719
+ case "env":
720
+ return parseEnv(rest);
721
+ case "doctor":
722
+ return parseNoArgCommand("doctor", rest, ["doctor"], "doctor", "mason doctor");
723
+ default:
724
+ throw new MasonCommandInputError(`Unknown /mason subcommand: ${command}`);
725
+ }
726
+ }
727
+ function tokenizeMasonArgs(input) {
728
+ const tokens = [];
729
+ let current = "";
730
+ let quote;
731
+ let escaped = false;
732
+ for (let index = 0;index < input.length; index += 1) {
733
+ const char = input[index];
734
+ if (escaped) {
735
+ current += char;
736
+ escaped = false;
737
+ continue;
738
+ }
739
+ if (char === "\\") {
740
+ escaped = true;
741
+ continue;
742
+ }
743
+ if (quote) {
744
+ if (char === quote) {
745
+ quote = undefined;
746
+ } else {
747
+ current += char;
748
+ }
749
+ continue;
750
+ }
751
+ if (char === "'" || char === '"') {
752
+ quote = char;
753
+ continue;
754
+ }
755
+ if (isWhitespace(char)) {
756
+ if (current.length > 0) {
757
+ tokens.push(current);
758
+ current = "";
759
+ }
760
+ continue;
761
+ }
762
+ current += char;
763
+ }
764
+ if (escaped)
765
+ current += "\\";
766
+ if (quote)
767
+ throw new MasonCommandInputError("Unterminated quoted string.");
768
+ if (current.length > 0)
769
+ tokens.push(current);
770
+ return tokens;
771
+ }
772
+ function parseRefresh(tokens) {
773
+ let registry;
774
+ for (let index = 0;index < tokens.length; index += 1) {
775
+ const token = tokens[index];
776
+ if (isHelp(token))
777
+ return usageAsError("refresh");
778
+ const option = readOption(tokens, index, "--registry");
779
+ if (option) {
780
+ registry = option.value;
781
+ index = option.nextIndex;
782
+ continue;
783
+ }
784
+ throw new MasonCommandInputError(`refresh does not accept positional argument: ${token}`);
785
+ }
786
+ const argv = ["refresh"];
787
+ pushOption(argv, "--registry", registry);
788
+ return command("refresh", argv, "refresh", "mason refresh");
789
+ }
790
+ function parseSearch(tokens) {
791
+ let query;
792
+ let category;
793
+ let language;
794
+ let registry;
795
+ for (let index = 0;index < tokens.length; index += 1) {
796
+ const token = tokens[index];
797
+ if (isHelp(token))
798
+ return usageAsError("search");
799
+ const categoryOption = readOption(tokens, index, "--category");
800
+ if (categoryOption) {
801
+ category = categoryOption.value;
802
+ index = categoryOption.nextIndex;
803
+ continue;
804
+ }
805
+ const languageOption = readOption(tokens, index, "--language");
806
+ if (languageOption) {
807
+ language = languageOption.value;
808
+ index = languageOption.nextIndex;
809
+ continue;
810
+ }
811
+ const registryOption = readOption(tokens, index, "--registry");
812
+ if (registryOption) {
813
+ registry = registryOption.value;
814
+ index = registryOption.nextIndex;
815
+ continue;
816
+ }
817
+ rejectUnknownOption(token);
818
+ if (query !== undefined)
819
+ throw new MasonCommandInputError("search accepts at most one query; quote spaces if needed.");
820
+ query = token;
821
+ }
822
+ const argv = ["search"];
823
+ if (query && query.length > 0)
824
+ argv.push(query);
825
+ pushOption(argv, "--category", category);
826
+ pushOption(argv, "--language", language);
827
+ pushOption(argv, "--registry", registry);
828
+ const title = language && language.length > 0 ? `mason search${query ? ` ${query}` : ""} language=${language}` : `mason search${query ? ` ${query}` : ""}`;
829
+ return command("search", argv, "packages", title);
830
+ }
831
+ function parseList(tokens) {
832
+ let installed = false;
833
+ let outdated = false;
834
+ let registry;
835
+ for (let index = 0;index < tokens.length; index += 1) {
836
+ const token = tokens[index];
837
+ if (isHelp(token))
838
+ return usageAsError("list");
839
+ if (token === "--installed") {
840
+ installed = true;
841
+ continue;
842
+ }
843
+ if (token === "--outdated") {
844
+ outdated = true;
845
+ continue;
846
+ }
847
+ const registryOption = readOption(tokens, index, "--registry");
848
+ if (registryOption) {
849
+ registry = registryOption.value;
850
+ index = registryOption.nextIndex;
851
+ continue;
852
+ }
853
+ rejectUnknownOption(token);
854
+ throw new MasonCommandInputError(`list does not accept positional argument: ${token}`);
855
+ }
856
+ if (installed && outdated)
857
+ throw new MasonCommandInputError("list cannot combine --installed and --outdated.");
858
+ const argv = ["list"];
859
+ if (installed)
860
+ argv.push("--installed");
861
+ if (outdated)
862
+ argv.push("--outdated");
863
+ pushOption(argv, "--registry", registry);
864
+ if (installed)
865
+ return command("list", argv, "installed", "mason list --installed");
866
+ return command("list", argv, "packages", outdated ? "mason list --outdated" : "mason list");
867
+ }
868
+ function parseInstalled(tokens) {
869
+ if (tokens.length > 0)
870
+ rejectUnexpectedArgs("installed", tokens);
871
+ return command("installed", ["list", "--installed"], "installed", "mason installed");
872
+ }
873
+ function parseOutdated(tokens) {
874
+ let registry;
875
+ for (let index = 0;index < tokens.length; index += 1) {
876
+ const token = tokens[index];
877
+ const registryOption = readOption(tokens, index, "--registry");
878
+ if (registryOption) {
879
+ registry = registryOption.value;
880
+ index = registryOption.nextIndex;
881
+ continue;
882
+ }
883
+ rejectUnknownOption(token);
884
+ throw new MasonCommandInputError(`outdated does not accept positional argument: ${token}`);
885
+ }
886
+ const argv = ["list", "--outdated"];
887
+ pushOption(argv, "--registry", registry);
888
+ return command("outdated", argv, "packages", "mason outdated");
889
+ }
890
+ function parseInstall(tokens) {
891
+ const parsed = parsePackageCommand("install", tokens, true);
892
+ if (parsed.packages.length === 0)
893
+ throw new MasonCommandInputError("install requires at least one package.");
894
+ const argv = ["install", ...parsed.packages];
895
+ pushOption(argv, "--registry", parsed.registry);
896
+ if (parsed.allowBuildScripts)
897
+ argv.push("--allow-build-scripts");
898
+ return command("install", argv, "install", "mason install");
899
+ }
900
+ function parseUninstall(tokens) {
901
+ const packages = parsePlainPositionals("uninstall", tokens);
902
+ if (packages.length === 0)
903
+ throw new MasonCommandInputError("uninstall requires at least one package.");
904
+ return command("uninstall", ["uninstall", ...packages], "uninstall", "mason uninstall");
905
+ }
906
+ function parseUpdate(tokens) {
907
+ const parsed = parsePackageCommand("update", tokens, true);
908
+ const argv = ["update", ...parsed.packages];
909
+ pushOption(argv, "--registry", parsed.registry);
910
+ if (parsed.allowBuildScripts)
911
+ argv.push("--allow-build-scripts");
912
+ return command("update", argv, "install", "mason update");
913
+ }
914
+ function parseWhich(tokens) {
915
+ const positionals = parsePlainPositionals("which", tokens);
916
+ if (positionals.length !== 1)
917
+ throw new MasonCommandInputError("which requires exactly one executable.");
918
+ return command("which", ["which", positionals[0]], "which", `mason which ${positionals[0]}`);
919
+ }
920
+ function parseEnv(tokens) {
921
+ let shell;
922
+ for (let index = 0;index < tokens.length; index += 1) {
923
+ const token = tokens[index];
924
+ if (isHelp(token))
925
+ return usageAsError("env");
926
+ const shellOption = readOption(tokens, index, "--shell");
927
+ if (shellOption) {
928
+ shell = shellOption.value;
929
+ index = shellOption.nextIndex;
930
+ continue;
931
+ }
932
+ rejectUnknownOption(token);
933
+ throw new MasonCommandInputError(`env does not accept positional argument: ${token}`);
934
+ }
935
+ if (!shell)
936
+ throw new MasonCommandInputError("env requires --shell bash|zsh|fish|powershell|cmd|json.");
937
+ if (!SHELLS.has(shell))
938
+ throw new MasonCommandInputError(`Unsupported shell: ${shell}`);
939
+ return command("env", ["env", "--shell", shell], "env", `mason env --shell ${shell}`);
940
+ }
941
+ function parseNoArgCommand(commandName, tokens, argv, resultKind, title) {
942
+ if (tokens.length > 0)
943
+ rejectUnexpectedArgs(commandName, tokens);
944
+ return command(commandName, argv, resultKind, title);
945
+ }
946
+ function parsePackageCommand(commandName, tokens, allowRegistry) {
947
+ const packages = [];
948
+ let registry;
949
+ let allowBuildScripts = false;
950
+ for (let index = 0;index < tokens.length; index += 1) {
951
+ const token = tokens[index];
952
+ if (isHelp(token))
953
+ return usageAsError(commandName);
954
+ if (token === "--allow-build-scripts") {
955
+ allowBuildScripts = true;
956
+ continue;
957
+ }
958
+ if (allowRegistry) {
959
+ const registryOption = readOption(tokens, index, "--registry");
960
+ if (registryOption) {
961
+ registry = registryOption.value;
962
+ index = registryOption.nextIndex;
963
+ continue;
964
+ }
965
+ }
966
+ rejectUnknownOption(token);
967
+ packages.push(token);
968
+ }
969
+ const result = { packages, allowBuildScripts };
970
+ if (registry !== undefined)
971
+ result.registry = registry;
972
+ return result;
973
+ }
974
+ function parsePlainPositionals(commandName, tokens) {
975
+ const positionals = [];
976
+ for (const token of tokens) {
977
+ if (isHelp(token))
978
+ return usageAsError(commandName);
979
+ rejectUnknownOption(token);
980
+ positionals.push(token);
981
+ }
982
+ return positionals;
983
+ }
984
+ function command(commandName, argv, resultKind, title) {
985
+ return { kind: "command", command: commandName, argv, resultKind, title };
986
+ }
987
+ function pushOption(argv, name, value) {
988
+ if (value !== undefined && value.length > 0)
989
+ argv.push(name, value);
990
+ }
991
+ function readOption(tokens, index, name) {
992
+ const token = tokens[index];
993
+ if (token === name) {
994
+ const value = tokens[index + 1];
995
+ if (value === undefined || value.startsWith("--"))
996
+ throw new MasonCommandInputError(`${name} requires a value.`);
997
+ return { value, nextIndex: index + 1 };
998
+ }
999
+ const prefix = `${name}=`;
1000
+ if (token.startsWith(prefix)) {
1001
+ const value = token.slice(prefix.length);
1002
+ if (value.length === 0)
1003
+ throw new MasonCommandInputError(`${name} requires a value.`);
1004
+ return { value, nextIndex: index };
1005
+ }
1006
+ return;
1007
+ }
1008
+ function rejectUnknownOption(token) {
1009
+ if (token.startsWith("--"))
1010
+ throw new MasonCommandInputError(`Unknown option: ${token}`);
1011
+ }
1012
+ function rejectUnexpectedArgs(commandName, tokens) {
1013
+ throw new MasonCommandInputError(`${commandName} does not accept arguments: ${tokens.join(" ")}`);
1014
+ }
1015
+ function usageAsError(commandName) {
1016
+ throw new MasonCommandInputError(`Use /mason help for ${commandName} usage.`);
1017
+ }
1018
+ function isHelp(token) {
1019
+ return token === "--help" || token === "-h";
1020
+ }
1021
+ function isWhitespace(char) {
1022
+ return char === " " || char === "\t" || char === `
1023
+ ` || char === "\r";
1024
+ }
1025
+ function messageFromError(err) {
1026
+ return err instanceof Error ? err.message : String(err);
1027
+ }
1028
+
1029
+ // src/pi/mason-panel.ts
1030
+ var PANEL_COMMANDS = [
1031
+ { id: "search", label: "search", inputLabel: "query" },
1032
+ { id: "list", label: "list" },
1033
+ { id: "installed", label: "installed" },
1034
+ { id: "install", label: "install", inputLabel: "packages" },
1035
+ { id: "uninstall", label: "uninstall", inputLabel: "packages" },
1036
+ { id: "update", label: "update", inputLabel: "packages" },
1037
+ { id: "which", label: "which", inputLabel: "executable" },
1038
+ { id: "refresh", label: "refresh" },
1039
+ { id: "doctor", label: "doctor" },
1040
+ { id: "env", label: "env", inputLabel: "shell" },
1041
+ { id: "bin-dir", label: "bin-dir" }
1042
+ ];
1043
+ var SHELLS2 = new Set(["bash", "zsh", "fish", "powershell", "cmd", "json"]);
1044
+ function createMasonPanel(bridge) {
1045
+ const state = {
1046
+ command: "search",
1047
+ commandIndex: 0,
1048
+ query: "",
1049
+ category: undefined,
1050
+ language: undefined,
1051
+ inputs: {
1052
+ search: "",
1053
+ list: "",
1054
+ installed: "",
1055
+ install: "",
1056
+ uninstall: "",
1057
+ update: "",
1058
+ which: "",
1059
+ refresh: "",
1060
+ doctor: "",
1061
+ env: "bash",
1062
+ "bin-dir": ""
1063
+ },
1064
+ filter: "",
1065
+ scroll: 0,
1066
+ loading: false,
1067
+ edit: undefined,
1068
+ model: modelForResult("packages", [], "mason search"),
1069
+ packages: []
1070
+ };
1071
+ async function execute(planned) {
1072
+ state.loading = true;
1073
+ state.model = { kind: "summary", title: planned.title, lines: ["Loading..."] };
1074
+ try {
1075
+ const data = await bridge.run(planned.argv);
1076
+ state.lastAction = data;
1077
+ state.model = modelForResult(planned.resultKind, data, planned.title);
1078
+ state.packages = Array.isArray(data) && (planned.resultKind === "packages" || planned.resultKind === "installed") ? data : state.packages;
1079
+ } catch (err) {
1080
+ state.model = errorDisplay(planned.title, messageFromError2(err));
1081
+ } finally {
1082
+ state.loading = false;
1083
+ }
1084
+ return state;
1085
+ }
1086
+ const panel = {
1087
+ title: "mason4agents",
1088
+ state,
1089
+ async refresh() {
1090
+ const refreshResult = await bridge.run(["refresh"]);
1091
+ state.lastAction = refreshResult;
1092
+ return this.search(state.query, { category: state.category, language: state.language });
1093
+ },
1094
+ async search(query = "", filters = { category: undefined, language: undefined }) {
1095
+ state.commandIndex = commandIndex("search");
1096
+ state.command = "search";
1097
+ state.query = query;
1098
+ state.inputs.search = query;
1099
+ state.category = filters.category;
1100
+ state.language = filters.language;
1101
+ return execute(buildSearchInvocation(state));
1102
+ },
1103
+ async install(packages) {
1104
+ state.lastAction = await bridge.run(["install", ...packages]);
1105
+ return this.search(state.query, { category: state.category, language: state.language });
1106
+ },
1107
+ async uninstall(packages) {
1108
+ state.lastAction = await bridge.run(["uninstall", ...packages]);
1109
+ return this.search(state.query, { category: state.category, language: state.language });
1110
+ },
1111
+ async update(packages = []) {
1112
+ state.lastAction = await bridge.run(["update", ...packages]);
1113
+ return this.search(state.query, { category: state.category, language: state.language });
1114
+ },
1115
+ async doctor() {
1116
+ state.commandIndex = commandIndex("doctor");
1117
+ state.command = "doctor";
1118
+ return execute({ argv: ["doctor"], resultKind: "doctor", title: "mason doctor" });
1119
+ },
1120
+ async runCurrent() {
1121
+ try {
1122
+ return await execute(buildInvocation(state));
1123
+ } catch (err) {
1124
+ state.model = errorDisplay("mason4agents", messageFromError2(err));
1125
+ return state;
1126
+ }
1127
+ },
1128
+ async handleInput(key) {
1129
+ if (state.edit) {
1130
+ await handleEditKey(state, key, () => panel.runCurrent());
1131
+ return;
1132
+ }
1133
+ if (isCloseKey(key))
1134
+ return "close";
1135
+ if (isNextCommandKey(key)) {
1136
+ selectCommand(state, state.commandIndex + 1);
1137
+ await panel.runCurrent();
1138
+ return;
1139
+ }
1140
+ if (isPreviousCommandKey(key)) {
1141
+ selectCommand(state, state.commandIndex - 1);
1142
+ await panel.runCurrent();
1143
+ return;
1144
+ }
1145
+ if (key === "/") {
1146
+ state.edit = { kind: "filter", draft: state.filter };
1147
+ return;
1148
+ }
1149
+ if ((key === "l" || key === "L") && state.command === "search") {
1150
+ state.edit = { kind: "language", draft: state.language ?? "" };
1151
+ return;
1152
+ }
1153
+ if (key === "e" && currentCommand(state).inputLabel) {
1154
+ state.edit = { kind: "input", draft: state.inputs[state.command] };
1155
+ return;
1156
+ }
1157
+ if (isScrollDownKey(key)) {
1158
+ state.scroll += 1;
1159
+ return;
1160
+ }
1161
+ if (isScrollUpKey(key)) {
1162
+ state.scroll = Math.max(0, state.scroll - 1);
1163
+ return;
1164
+ }
1165
+ if (isPageDownKey(key)) {
1166
+ state.scroll += 10;
1167
+ return;
1168
+ }
1169
+ if (isPageUpKey(key)) {
1170
+ state.scroll = Math.max(0, state.scroll - 10);
1171
+ return;
1172
+ }
1173
+ if (isEnterKey(key)) {
1174
+ await panel.runCurrent();
1175
+ return;
1176
+ }
1177
+ },
1178
+ render() {
1179
+ return renderPanelLines(state, 120).join(`
1180
+ `);
1181
+ },
1182
+ renderLines(width) {
1183
+ return renderPanelLines(state, width);
1184
+ }
1185
+ };
1186
+ return panel;
1187
+ }
1188
+ async function openMasonPanel(ctx, bridge) {
1189
+ const panel = createMasonPanel(bridge);
1190
+ await panel.runCurrent();
1191
+ const anyCtx = ctx;
1192
+ if (anyCtx.hasUI !== false && typeof anyCtx.ui?.custom === "function") {
1193
+ await anyCtx.ui.custom((tui, _theme, _keybindings, done) => ({
1194
+ render(width) {
1195
+ return panel.renderLines(width);
1196
+ },
1197
+ handleInput(key) {
1198
+ panel.handleInput(key).then((result) => {
1199
+ if (result === "close") {
1200
+ done(undefined);
1201
+ } else {
1202
+ requestTuiRender(tui);
1203
+ }
1204
+ });
1205
+ },
1206
+ invalidate() {}
1207
+ }));
1208
+ }
1209
+ return panel;
1210
+ }
1211
+ function buildInvocation(state) {
1212
+ switch (state.command) {
1213
+ case "search":
1214
+ return buildSearchInvocation(state);
1215
+ case "list":
1216
+ return { argv: ["list"], resultKind: "packages", title: "mason list" };
1217
+ case "installed":
1218
+ return { argv: ["list", "--installed"], resultKind: "installed", title: "mason installed" };
1219
+ case "install": {
1220
+ const packages = splitInput(state.inputs.install);
1221
+ if (packages.length === 0)
1222
+ throw new MasonCommandInputError("install requires package names. Press e to enter packages.");
1223
+ return { argv: ["install", ...packages], resultKind: "install", title: "mason install" };
1224
+ }
1225
+ case "uninstall": {
1226
+ const packages = splitInput(state.inputs.uninstall);
1227
+ if (packages.length === 0)
1228
+ throw new MasonCommandInputError("uninstall requires package names. Press e to enter packages.");
1229
+ return { argv: ["uninstall", ...packages], resultKind: "uninstall", title: "mason uninstall" };
1230
+ }
1231
+ case "update":
1232
+ return { argv: ["update", ...splitInput(state.inputs.update)], resultKind: "install", title: "mason update" };
1233
+ case "which": {
1234
+ const executable = splitInput(state.inputs.which);
1235
+ if (executable.length !== 1)
1236
+ throw new MasonCommandInputError("which requires one executable. Press e to enter it.");
1237
+ return { argv: ["which", executable[0]], resultKind: "which", title: `mason which ${executable[0]}` };
1238
+ }
1239
+ case "refresh":
1240
+ return { argv: ["refresh"], resultKind: "refresh", title: "mason refresh" };
1241
+ case "doctor":
1242
+ return { argv: ["doctor"], resultKind: "doctor", title: "mason doctor" };
1243
+ case "env": {
1244
+ const shell = state.inputs.env.trim() || "bash";
1245
+ if (!SHELLS2.has(shell))
1246
+ throw new MasonCommandInputError("env shell must be one of bash, zsh, fish, powershell, cmd, json.");
1247
+ return { argv: ["env", "--shell", shell], resultKind: "env", title: `mason env --shell ${shell}` };
1248
+ }
1249
+ case "bin-dir":
1250
+ return { argv: ["bin-dir"], resultKind: "bin-dir", title: "mason bin-dir" };
1251
+ }
1252
+ }
1253
+ function buildSearchInvocation(state) {
1254
+ const query = state.inputs.search.trim();
1255
+ state.query = query;
1256
+ const argv = ["search"];
1257
+ if (query.length > 0)
1258
+ argv.push(query);
1259
+ if (state.category)
1260
+ argv.push("--category", state.category);
1261
+ if (state.language && state.language.trim().length > 0)
1262
+ argv.push("--language", state.language.trim());
1263
+ const title = state.language && state.language.trim().length > 0 ? `mason search${query ? ` ${query}` : ""} language=${state.language.trim()}` : `mason search${query ? ` ${query}` : ""}`;
1264
+ return { argv, resultKind: "packages", title };
1265
+ }
1266
+ function renderPanelLines(state, width) {
1267
+ const safeWidth = Math.max(1, Math.floor(width));
1268
+ const lines = [
1269
+ truncateToWidth2("mason4agents package manager", safeWidth),
1270
+ truncateToWidth2(renderCommandTabs(state), safeWidth),
1271
+ truncateToWidth2(renderStateLine(state), safeWidth)
1272
+ ];
1273
+ if (state.edit)
1274
+ lines.push(truncateToWidth2(`${state.edit.kind}> ${state.edit.draft}`, safeWidth));
1275
+ lines.push("");
1276
+ const output = renderDisplay(state.model, { width: safeWidth, filter: state.filter, scroll: state.scroll, maxRows: 18 });
1277
+ lines.push(...output);
1278
+ lines.push("");
1279
+ lines.push(truncateToWidth2("Keys: \u2190/\u2192 or Tab command Enter run e edit / filter l language \u2191/\u2193 scroll q/Esc close", safeWidth));
1280
+ return lines.map((line) => truncateToWidth2(line, safeWidth));
1281
+ }
1282
+ function renderCommandTabs(state) {
1283
+ return PANEL_COMMANDS.map((command2, index) => index === state.commandIndex ? `[${command2.label}]` : ` ${command2.label} `).join(" ");
1284
+ }
1285
+ function renderStateLine(state) {
1286
+ const command2 = currentCommand(state);
1287
+ const parts = [`command=${command2.label}`];
1288
+ if (command2.inputLabel) {
1289
+ const value = state.inputs[state.command];
1290
+ parts.push(`${command2.inputLabel}=${value.length > 0 ? value : "-"}`);
1291
+ }
1292
+ if (state.command === "search")
1293
+ parts.push(`language=${state.language && state.language.length > 0 ? state.language : "-"}`);
1294
+ if (state.filter.length > 0)
1295
+ parts.push(`filter=${state.filter}`);
1296
+ if (state.loading)
1297
+ parts.push("loading");
1298
+ return parts.join(" ");
1299
+ }
1300
+ function handleEditKey(state, key, runCurrent) {
1301
+ const edit = state.edit;
1302
+ if (!edit)
1303
+ return;
1304
+ if (isEnterKey(key)) {
1305
+ const draft = edit.draft.trim();
1306
+ if (edit.kind === "filter") {
1307
+ state.filter = draft;
1308
+ state.scroll = 0;
1309
+ state.edit = undefined;
1310
+ return;
1311
+ }
1312
+ if (edit.kind === "language") {
1313
+ state.language = draft.length > 0 ? draft : undefined;
1314
+ state.scroll = 0;
1315
+ state.edit = undefined;
1316
+ return runCurrent();
1317
+ }
1318
+ state.inputs[state.command] = draft;
1319
+ if (state.command === "search")
1320
+ state.query = draft;
1321
+ state.scroll = 0;
1322
+ state.edit = undefined;
1323
+ return runCurrent();
1324
+ }
1325
+ if (isCloseKey(key)) {
1326
+ state.edit = undefined;
1327
+ return;
1328
+ }
1329
+ if (key === "\b" || key === "\x7F" || key === "backspace") {
1330
+ edit.draft = edit.draft.slice(0, -1);
1331
+ return;
1332
+ }
1333
+ if (key.length === 1 && key >= " ")
1334
+ edit.draft += key;
1335
+ }
1336
+ function selectCommand(state, nextIndex) {
1337
+ const count = PANEL_COMMANDS.length;
1338
+ state.commandIndex = (nextIndex % count + count) % count;
1339
+ state.command = PANEL_COMMANDS[state.commandIndex].id;
1340
+ state.scroll = 0;
1341
+ state.filter = "";
1342
+ state.edit = undefined;
1343
+ }
1344
+ function currentCommand(state) {
1345
+ return PANEL_COMMANDS[state.commandIndex];
1346
+ }
1347
+ function commandIndex(command2) {
1348
+ return PANEL_COMMANDS.findIndex((item) => item.id === command2);
1349
+ }
1350
+ function splitInput(input) {
1351
+ return tokenizeMasonArgs(input.trim());
1352
+ }
1353
+ function messageFromError2(err) {
1354
+ return err instanceof Error ? err.message : String(err);
1355
+ }
1356
+ function truncateToWidth2(value, width) {
1357
+ if (value.length <= width)
1358
+ return value;
1359
+ if (width <= 1)
1360
+ return value.slice(0, width);
1361
+ return `${value.slice(0, width - 1)}\u2026`;
1362
+ }
1363
+ function isCloseKey(key) {
1364
+ return key === "q" || key === "\x1B" || key === "escape" || key === "esc";
1365
+ }
1366
+ function isEnterKey(key) {
1367
+ return key === "\r" || key === `
1368
+ ` || key === "enter" || key === "return";
1369
+ }
1370
+ function isNextCommandKey(key) {
1371
+ return key === "tab" || key === "right" || key === "\x1B[C";
1372
+ }
1373
+ function isPreviousCommandKey(key) {
1374
+ return key === "shift+tab" || key === "left" || key === "\x1B[D";
1375
+ }
1376
+ function isScrollDownKey(key) {
1377
+ return key === "down" || key === "j" || key === "\x1B[B";
1378
+ }
1379
+ function isScrollUpKey(key) {
1380
+ return key === "up" || key === "k" || key === "\x1B[A";
1381
+ }
1382
+ function isPageDownKey(key) {
1383
+ return key === "pagedown" || key === "\x1B[6~";
1384
+ }
1385
+ function isPageUpKey(key) {
1386
+ return key === "pageup" || key === "\x1B[5~";
1387
+ }
1388
+ function requestTuiRender(tui) {
1389
+ if (typeof tui !== "object" || tui === null)
1390
+ return;
1391
+ const candidate = tui;
1392
+ if (typeof candidate.requestRender === "function") {
1393
+ candidate.requestRender(true);
1394
+ } else if (typeof candidate.invalidate === "function") {
1395
+ candidate.invalidate();
1396
+ }
1397
+ }
1398
+
1399
+ // node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
1400
+ var exports_value = {};
1401
+ __export(exports_value, {
1402
+ IsUndefined: () => IsUndefined,
1403
+ IsUint8Array: () => IsUint8Array,
1404
+ IsSymbol: () => IsSymbol,
1405
+ IsString: () => IsString,
1406
+ IsRegExp: () => IsRegExp,
1407
+ IsObject: () => IsObject,
1408
+ IsNumber: () => IsNumber,
1409
+ IsNull: () => IsNull,
1410
+ IsIterator: () => IsIterator,
1411
+ IsFunction: () => IsFunction,
1412
+ IsDate: () => IsDate,
1413
+ IsBoolean: () => IsBoolean,
1414
+ IsBigInt: () => IsBigInt,
1415
+ IsAsyncIterator: () => IsAsyncIterator,
1416
+ IsArray: () => IsArray,
1417
+ HasPropertyKey: () => HasPropertyKey
1418
+ });
1419
+ function HasPropertyKey(value, key) {
1420
+ return key in value;
1421
+ }
1422
+ function IsAsyncIterator(value) {
1423
+ return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.asyncIterator in value;
1424
+ }
1425
+ function IsArray(value) {
1426
+ return Array.isArray(value);
1427
+ }
1428
+ function IsBigInt(value) {
1429
+ return typeof value === "bigint";
1430
+ }
1431
+ function IsBoolean(value) {
1432
+ return typeof value === "boolean";
1433
+ }
1434
+ function IsDate(value) {
1435
+ return value instanceof globalThis.Date;
1436
+ }
1437
+ function IsFunction(value) {
1438
+ return typeof value === "function";
1439
+ }
1440
+ function IsIterator(value) {
1441
+ return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.iterator in value;
1442
+ }
1443
+ function IsNull(value) {
1444
+ return value === null;
1445
+ }
1446
+ function IsNumber(value) {
1447
+ return typeof value === "number";
1448
+ }
1449
+ function IsObject(value) {
1450
+ return typeof value === "object" && value !== null;
1451
+ }
1452
+ function IsRegExp(value) {
1453
+ return value instanceof globalThis.RegExp;
1454
+ }
1455
+ function IsString(value) {
1456
+ return typeof value === "string";
1457
+ }
1458
+ function IsSymbol(value) {
1459
+ return typeof value === "symbol";
1460
+ }
1461
+ function IsUint8Array(value) {
1462
+ return value instanceof globalThis.Uint8Array;
1463
+ }
1464
+ function IsUndefined(value) {
1465
+ return value === undefined;
1466
+ }
1467
+
1468
+ // node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
1469
+ function ArrayType(value) {
1470
+ return value.map((value2) => Visit(value2));
1471
+ }
1472
+ function DateType(value) {
1473
+ return new Date(value.getTime());
1474
+ }
1475
+ function Uint8ArrayType(value) {
1476
+ return new Uint8Array(value);
1477
+ }
1478
+ function RegExpType(value) {
1479
+ return new RegExp(value.source, value.flags);
1480
+ }
1481
+ function ObjectType(value) {
1482
+ const result = {};
1483
+ for (const key of Object.getOwnPropertyNames(value)) {
1484
+ result[key] = Visit(value[key]);
1485
+ }
1486
+ for (const key of Object.getOwnPropertySymbols(value)) {
1487
+ result[key] = Visit(value[key]);
1488
+ }
1489
+ return result;
1490
+ }
1491
+ function Visit(value) {
1492
+ return IsArray(value) ? ArrayType(value) : IsDate(value) ? DateType(value) : IsUint8Array(value) ? Uint8ArrayType(value) : IsRegExp(value) ? RegExpType(value) : IsObject(value) ? ObjectType(value) : value;
1493
+ }
1494
+ function Clone(value) {
1495
+ return Visit(value);
1496
+ }
1497
+
1498
+ // node_modules/@sinclair/typebox/build/esm/type/clone/type.mjs
1499
+ function CloneType(schema, options) {
1500
+ return options === undefined ? Clone(schema) : Clone({ ...options, ...schema });
1501
+ }
1502
+
1503
+ // node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
1504
+ function IsObject2(value) {
1505
+ return value !== null && typeof value === "object";
1506
+ }
1507
+ function IsArray2(value) {
1508
+ return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
1509
+ }
1510
+ function IsUndefined2(value) {
1511
+ return value === undefined;
1512
+ }
1513
+ function IsNumber2(value) {
1514
+ return typeof value === "number";
1515
+ }
1516
+
1517
+ // node_modules/@sinclair/typebox/build/esm/system/policy.mjs
1518
+ var TypeSystemPolicy;
1519
+ (function(TypeSystemPolicy2) {
1520
+ TypeSystemPolicy2.InstanceMode = "default";
1521
+ TypeSystemPolicy2.ExactOptionalPropertyTypes = false;
1522
+ TypeSystemPolicy2.AllowArrayObject = false;
1523
+ TypeSystemPolicy2.AllowNaN = false;
1524
+ TypeSystemPolicy2.AllowNullVoid = false;
1525
+ function IsExactOptionalProperty(value, key) {
1526
+ return TypeSystemPolicy2.ExactOptionalPropertyTypes ? key in value : value[key] !== undefined;
1527
+ }
1528
+ TypeSystemPolicy2.IsExactOptionalProperty = IsExactOptionalProperty;
1529
+ function IsObjectLike(value) {
1530
+ const isObject = IsObject2(value);
1531
+ return TypeSystemPolicy2.AllowArrayObject ? isObject : isObject && !IsArray2(value);
1532
+ }
1533
+ TypeSystemPolicy2.IsObjectLike = IsObjectLike;
1534
+ function IsRecordLike(value) {
1535
+ return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
1536
+ }
1537
+ TypeSystemPolicy2.IsRecordLike = IsRecordLike;
1538
+ function IsNumberLike(value) {
1539
+ return TypeSystemPolicy2.AllowNaN ? IsNumber2(value) : Number.isFinite(value);
1540
+ }
1541
+ TypeSystemPolicy2.IsNumberLike = IsNumberLike;
1542
+ function IsVoidLike(value) {
1543
+ const isUndefined = IsUndefined2(value);
1544
+ return TypeSystemPolicy2.AllowNullVoid ? isUndefined || value === null : isUndefined;
1545
+ }
1546
+ TypeSystemPolicy2.IsVoidLike = IsVoidLike;
1547
+ })(TypeSystemPolicy || (TypeSystemPolicy = {}));
1548
+
1549
+ // node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
1550
+ function ImmutableArray(value) {
1551
+ return globalThis.Object.freeze(value).map((value2) => Immutable(value2));
1552
+ }
1553
+ function ImmutableDate(value) {
1554
+ return value;
1555
+ }
1556
+ function ImmutableUint8Array(value) {
1557
+ return value;
1558
+ }
1559
+ function ImmutableRegExp(value) {
1560
+ return value;
1561
+ }
1562
+ function ImmutableObject(value) {
1563
+ const result = {};
1564
+ for (const key of Object.getOwnPropertyNames(value)) {
1565
+ result[key] = Immutable(value[key]);
1566
+ }
1567
+ for (const key of Object.getOwnPropertySymbols(value)) {
1568
+ result[key] = Immutable(value[key]);
1569
+ }
1570
+ return globalThis.Object.freeze(result);
1571
+ }
1572
+ function Immutable(value) {
1573
+ return IsArray(value) ? ImmutableArray(value) : IsDate(value) ? ImmutableDate(value) : IsUint8Array(value) ? ImmutableUint8Array(value) : IsRegExp(value) ? ImmutableRegExp(value) : IsObject(value) ? ImmutableObject(value) : value;
1574
+ }
1575
+
1576
+ // node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
1577
+ function CreateType(schema, options) {
1578
+ const result = options !== undefined ? { ...options, ...schema } : schema;
1579
+ switch (TypeSystemPolicy.InstanceMode) {
1580
+ case "freeze":
1581
+ return Immutable(result);
1582
+ case "clone":
1583
+ return Clone(result);
1584
+ default:
1585
+ return result;
1586
+ }
1587
+ }
1588
+
1589
+ // node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
1590
+ class TypeBoxError extends Error {
1591
+ constructor(message) {
1592
+ super(message);
1593
+ }
1594
+ }
1595
+
1596
+ // node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
1597
+ var TransformKind = Symbol.for("TypeBox.Transform");
1598
+ var ReadonlyKind = Symbol.for("TypeBox.Readonly");
1599
+ var OptionalKind = Symbol.for("TypeBox.Optional");
1600
+ var Hint = Symbol.for("TypeBox.Hint");
1601
+ var Kind = Symbol.for("TypeBox.Kind");
1602
+
1603
+ // node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
1604
+ function IsReadonly(value) {
1605
+ return IsObject(value) && value[ReadonlyKind] === "Readonly";
1606
+ }
1607
+ function IsOptional(value) {
1608
+ return IsObject(value) && value[OptionalKind] === "Optional";
1609
+ }
1610
+ function IsAny(value) {
1611
+ return IsKindOf(value, "Any");
1612
+ }
1613
+ function IsArgument(value) {
1614
+ return IsKindOf(value, "Argument");
1615
+ }
1616
+ function IsArray3(value) {
1617
+ return IsKindOf(value, "Array");
1618
+ }
1619
+ function IsAsyncIterator2(value) {
1620
+ return IsKindOf(value, "AsyncIterator");
1621
+ }
1622
+ function IsBigInt2(value) {
1623
+ return IsKindOf(value, "BigInt");
1624
+ }
1625
+ function IsBoolean2(value) {
1626
+ return IsKindOf(value, "Boolean");
1627
+ }
1628
+ function IsComputed(value) {
1629
+ return IsKindOf(value, "Computed");
1630
+ }
1631
+ function IsConstructor(value) {
1632
+ return IsKindOf(value, "Constructor");
1633
+ }
1634
+ function IsDate2(value) {
1635
+ return IsKindOf(value, "Date");
1636
+ }
1637
+ function IsFunction2(value) {
1638
+ return IsKindOf(value, "Function");
1639
+ }
1640
+ function IsInteger(value) {
1641
+ return IsKindOf(value, "Integer");
1642
+ }
1643
+ function IsIntersect(value) {
1644
+ return IsKindOf(value, "Intersect");
1645
+ }
1646
+ function IsIterator2(value) {
1647
+ return IsKindOf(value, "Iterator");
1648
+ }
1649
+ function IsKindOf(value, kind) {
1650
+ return IsObject(value) && Kind in value && value[Kind] === kind;
1651
+ }
1652
+ function IsLiteralValue(value) {
1653
+ return IsBoolean(value) || IsNumber(value) || IsString(value);
1654
+ }
1655
+ function IsLiteral(value) {
1656
+ return IsKindOf(value, "Literal");
1657
+ }
1658
+ function IsMappedKey(value) {
1659
+ return IsKindOf(value, "MappedKey");
1660
+ }
1661
+ function IsMappedResult(value) {
1662
+ return IsKindOf(value, "MappedResult");
1663
+ }
1664
+ function IsNever(value) {
1665
+ return IsKindOf(value, "Never");
1666
+ }
1667
+ function IsNot(value) {
1668
+ return IsKindOf(value, "Not");
1669
+ }
1670
+ function IsNull2(value) {
1671
+ return IsKindOf(value, "Null");
1672
+ }
1673
+ function IsNumber3(value) {
1674
+ return IsKindOf(value, "Number");
1675
+ }
1676
+ function IsObject3(value) {
1677
+ return IsKindOf(value, "Object");
1678
+ }
1679
+ function IsPromise(value) {
1680
+ return IsKindOf(value, "Promise");
1681
+ }
1682
+ function IsRecord(value) {
1683
+ return IsKindOf(value, "Record");
1684
+ }
1685
+ function IsRef(value) {
1686
+ return IsKindOf(value, "Ref");
1687
+ }
1688
+ function IsRegExp2(value) {
1689
+ return IsKindOf(value, "RegExp");
1690
+ }
1691
+ function IsString2(value) {
1692
+ return IsKindOf(value, "String");
1693
+ }
1694
+ function IsSymbol2(value) {
1695
+ return IsKindOf(value, "Symbol");
1696
+ }
1697
+ function IsTemplateLiteral(value) {
1698
+ return IsKindOf(value, "TemplateLiteral");
1699
+ }
1700
+ function IsThis(value) {
1701
+ return IsKindOf(value, "This");
1702
+ }
1703
+ function IsTransform(value) {
1704
+ return IsObject(value) && TransformKind in value;
1705
+ }
1706
+ function IsTuple(value) {
1707
+ return IsKindOf(value, "Tuple");
1708
+ }
1709
+ function IsUndefined3(value) {
1710
+ return IsKindOf(value, "Undefined");
1711
+ }
1712
+ function IsUnion(value) {
1713
+ return IsKindOf(value, "Union");
1714
+ }
1715
+ function IsUint8Array2(value) {
1716
+ return IsKindOf(value, "Uint8Array");
1717
+ }
1718
+ function IsUnknown(value) {
1719
+ return IsKindOf(value, "Unknown");
1720
+ }
1721
+ function IsUnsafe(value) {
1722
+ return IsKindOf(value, "Unsafe");
1723
+ }
1724
+ function IsVoid(value) {
1725
+ return IsKindOf(value, "Void");
1726
+ }
1727
+ function IsKind(value) {
1728
+ return IsObject(value) && Kind in value && IsString(value[Kind]);
1729
+ }
1730
+ function IsSchema(value) {
1731
+ return IsAny(value) || IsArgument(value) || IsArray3(value) || IsBoolean2(value) || IsBigInt2(value) || IsAsyncIterator2(value) || IsComputed(value) || IsConstructor(value) || IsDate2(value) || IsFunction2(value) || IsInteger(value) || IsIntersect(value) || IsIterator2(value) || IsLiteral(value) || IsMappedKey(value) || IsMappedResult(value) || IsNever(value) || IsNot(value) || IsNull2(value) || IsNumber3(value) || IsObject3(value) || IsPromise(value) || IsRecord(value) || IsRef(value) || IsRegExp2(value) || IsString2(value) || IsSymbol2(value) || IsTemplateLiteral(value) || IsThis(value) || IsTuple(value) || IsUndefined3(value) || IsUnion(value) || IsUint8Array2(value) || IsUnknown(value) || IsUnsafe(value) || IsVoid(value) || IsKind(value);
1732
+ }
1733
+ // node_modules/@sinclair/typebox/build/esm/type/guard/type.mjs
1734
+ var exports_type = {};
1735
+ __export(exports_type, {
1736
+ TypeGuardUnknownTypeError: () => TypeGuardUnknownTypeError,
1737
+ IsVoid: () => IsVoid2,
1738
+ IsUnsafe: () => IsUnsafe2,
1739
+ IsUnknown: () => IsUnknown2,
1740
+ IsUnionLiteral: () => IsUnionLiteral,
1741
+ IsUnion: () => IsUnion2,
1742
+ IsUndefined: () => IsUndefined4,
1743
+ IsUint8Array: () => IsUint8Array3,
1744
+ IsTuple: () => IsTuple2,
1745
+ IsTransform: () => IsTransform2,
1746
+ IsThis: () => IsThis2,
1747
+ IsTemplateLiteral: () => IsTemplateLiteral2,
1748
+ IsSymbol: () => IsSymbol3,
1749
+ IsString: () => IsString3,
1750
+ IsSchema: () => IsSchema2,
1751
+ IsRegExp: () => IsRegExp3,
1752
+ IsRef: () => IsRef2,
1753
+ IsRecursive: () => IsRecursive,
1754
+ IsRecord: () => IsRecord2,
1755
+ IsReadonly: () => IsReadonly2,
1756
+ IsProperties: () => IsProperties,
1757
+ IsPromise: () => IsPromise2,
1758
+ IsOptional: () => IsOptional2,
1759
+ IsObject: () => IsObject4,
1760
+ IsNumber: () => IsNumber4,
1761
+ IsNull: () => IsNull3,
1762
+ IsNot: () => IsNot2,
1763
+ IsNever: () => IsNever2,
1764
+ IsMappedResult: () => IsMappedResult2,
1765
+ IsMappedKey: () => IsMappedKey2,
1766
+ IsLiteralValue: () => IsLiteralValue2,
1767
+ IsLiteralString: () => IsLiteralString,
1768
+ IsLiteralNumber: () => IsLiteralNumber,
1769
+ IsLiteralBoolean: () => IsLiteralBoolean,
1770
+ IsLiteral: () => IsLiteral2,
1771
+ IsKindOf: () => IsKindOf2,
1772
+ IsKind: () => IsKind2,
1773
+ IsIterator: () => IsIterator3,
1774
+ IsIntersect: () => IsIntersect2,
1775
+ IsInteger: () => IsInteger2,
1776
+ IsImport: () => IsImport,
1777
+ IsFunction: () => IsFunction3,
1778
+ IsDate: () => IsDate3,
1779
+ IsConstructor: () => IsConstructor2,
1780
+ IsComputed: () => IsComputed2,
1781
+ IsBoolean: () => IsBoolean3,
1782
+ IsBigInt: () => IsBigInt3,
1783
+ IsAsyncIterator: () => IsAsyncIterator3,
1784
+ IsArray: () => IsArray4,
1785
+ IsArgument: () => IsArgument2,
1786
+ IsAny: () => IsAny2
1787
+ });
1788
+ class TypeGuardUnknownTypeError extends TypeBoxError {
1789
+ }
1790
+ var KnownTypes = [
1791
+ "Argument",
1792
+ "Any",
1793
+ "Array",
1794
+ "AsyncIterator",
1795
+ "BigInt",
1796
+ "Boolean",
1797
+ "Computed",
1798
+ "Constructor",
1799
+ "Date",
1800
+ "Enum",
1801
+ "Function",
1802
+ "Integer",
1803
+ "Intersect",
1804
+ "Iterator",
1805
+ "Literal",
1806
+ "MappedKey",
1807
+ "MappedResult",
1808
+ "Not",
1809
+ "Null",
1810
+ "Number",
1811
+ "Object",
1812
+ "Promise",
1813
+ "Record",
1814
+ "Ref",
1815
+ "RegExp",
1816
+ "String",
1817
+ "Symbol",
1818
+ "TemplateLiteral",
1819
+ "This",
1820
+ "Tuple",
1821
+ "Undefined",
1822
+ "Union",
1823
+ "Uint8Array",
1824
+ "Unknown",
1825
+ "Void"
1826
+ ];
1827
+ function IsPattern(value) {
1828
+ try {
1829
+ new RegExp(value);
1830
+ return true;
1831
+ } catch {
1832
+ return false;
1833
+ }
1834
+ }
1835
+ function IsControlCharacterFree(value) {
1836
+ if (!IsString(value))
1837
+ return false;
1838
+ for (let i = 0;i < value.length; i++) {
1839
+ const code = value.charCodeAt(i);
1840
+ if (code >= 7 && code <= 13 || code === 27 || code === 127) {
1841
+ return false;
1842
+ }
1843
+ }
1844
+ return true;
1845
+ }
1846
+ function IsAdditionalProperties(value) {
1847
+ return IsOptionalBoolean(value) || IsSchema2(value);
1848
+ }
1849
+ function IsOptionalBigInt(value) {
1850
+ return IsUndefined(value) || IsBigInt(value);
1851
+ }
1852
+ function IsOptionalNumber(value) {
1853
+ return IsUndefined(value) || IsNumber(value);
1854
+ }
1855
+ function IsOptionalBoolean(value) {
1856
+ return IsUndefined(value) || IsBoolean(value);
1857
+ }
1858
+ function IsOptionalString(value) {
1859
+ return IsUndefined(value) || IsString(value);
1860
+ }
1861
+ function IsOptionalPattern(value) {
1862
+ return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value) && IsPattern(value);
1863
+ }
1864
+ function IsOptionalFormat(value) {
1865
+ return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value);
1866
+ }
1867
+ function IsOptionalSchema(value) {
1868
+ return IsUndefined(value) || IsSchema2(value);
1869
+ }
1870
+ function IsReadonly2(value) {
1871
+ return IsObject(value) && value[ReadonlyKind] === "Readonly";
1872
+ }
1873
+ function IsOptional2(value) {
1874
+ return IsObject(value) && value[OptionalKind] === "Optional";
1875
+ }
1876
+ function IsAny2(value) {
1877
+ return IsKindOf2(value, "Any") && IsOptionalString(value.$id);
1878
+ }
1879
+ function IsArgument2(value) {
1880
+ return IsKindOf2(value, "Argument") && IsNumber(value.index);
1881
+ }
1882
+ function IsArray4(value) {
1883
+ return IsKindOf2(value, "Array") && value.type === "array" && IsOptionalString(value.$id) && IsSchema2(value.items) && IsOptionalNumber(value.minItems) && IsOptionalNumber(value.maxItems) && IsOptionalBoolean(value.uniqueItems) && IsOptionalSchema(value.contains) && IsOptionalNumber(value.minContains) && IsOptionalNumber(value.maxContains);
1884
+ }
1885
+ function IsAsyncIterator3(value) {
1886
+ return IsKindOf2(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
1887
+ }
1888
+ function IsBigInt3(value) {
1889
+ return IsKindOf2(value, "BigInt") && value.type === "bigint" && IsOptionalString(value.$id) && IsOptionalBigInt(value.exclusiveMaximum) && IsOptionalBigInt(value.exclusiveMinimum) && IsOptionalBigInt(value.maximum) && IsOptionalBigInt(value.minimum) && IsOptionalBigInt(value.multipleOf);
1890
+ }
1891
+ function IsBoolean3(value) {
1892
+ return IsKindOf2(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
1893
+ }
1894
+ function IsComputed2(value) {
1895
+ return IsKindOf2(value, "Computed") && IsString(value.target) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema));
1896
+ }
1897
+ function IsConstructor2(value) {
1898
+ return IsKindOf2(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
1899
+ }
1900
+ function IsDate3(value) {
1901
+ return IsKindOf2(value, "Date") && value.type === "Date" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximumTimestamp) && IsOptionalNumber(value.exclusiveMinimumTimestamp) && IsOptionalNumber(value.maximumTimestamp) && IsOptionalNumber(value.minimumTimestamp) && IsOptionalNumber(value.multipleOfTimestamp);
1902
+ }
1903
+ function IsFunction3(value) {
1904
+ return IsKindOf2(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
1905
+ }
1906
+ function IsImport(value) {
1907
+ return IsKindOf2(value, "Import") && HasPropertyKey(value, "$defs") && IsObject(value.$defs) && IsProperties(value.$defs) && HasPropertyKey(value, "$ref") && IsString(value.$ref) && value.$ref in value.$defs;
1908
+ }
1909
+ function IsInteger2(value) {
1910
+ return IsKindOf2(value, "Integer") && value.type === "integer" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
1911
+ }
1912
+ function IsProperties(value) {
1913
+ return IsObject(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema2(schema));
1914
+ }
1915
+ function IsIntersect2(value) {
1916
+ return IsKindOf2(value, "Intersect") && (IsString(value.type) && value.type !== "object" ? false : true) && IsArray(value.allOf) && value.allOf.every((schema) => IsSchema2(schema) && !IsTransform2(schema)) && IsOptionalString(value.type) && (IsOptionalBoolean(value.unevaluatedProperties) || IsOptionalSchema(value.unevaluatedProperties)) && IsOptionalString(value.$id);
1917
+ }
1918
+ function IsIterator3(value) {
1919
+ return IsKindOf2(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
1920
+ }
1921
+ function IsKindOf2(value, kind) {
1922
+ return IsObject(value) && Kind in value && value[Kind] === kind;
1923
+ }
1924
+ function IsLiteralString(value) {
1925
+ return IsLiteral2(value) && IsString(value.const);
1926
+ }
1927
+ function IsLiteralNumber(value) {
1928
+ return IsLiteral2(value) && IsNumber(value.const);
1929
+ }
1930
+ function IsLiteralBoolean(value) {
1931
+ return IsLiteral2(value) && IsBoolean(value.const);
1932
+ }
1933
+ function IsLiteral2(value) {
1934
+ return IsKindOf2(value, "Literal") && IsOptionalString(value.$id) && IsLiteralValue2(value.const);
1935
+ }
1936
+ function IsLiteralValue2(value) {
1937
+ return IsBoolean(value) || IsNumber(value) || IsString(value);
1938
+ }
1939
+ function IsMappedKey2(value) {
1940
+ return IsKindOf2(value, "MappedKey") && IsArray(value.keys) && value.keys.every((key) => IsNumber(key) || IsString(key));
1941
+ }
1942
+ function IsMappedResult2(value) {
1943
+ return IsKindOf2(value, "MappedResult") && IsProperties(value.properties);
1944
+ }
1945
+ function IsNever2(value) {
1946
+ return IsKindOf2(value, "Never") && IsObject(value.not) && Object.getOwnPropertyNames(value.not).length === 0;
1947
+ }
1948
+ function IsNot2(value) {
1949
+ return IsKindOf2(value, "Not") && IsSchema2(value.not);
1950
+ }
1951
+ function IsNull3(value) {
1952
+ return IsKindOf2(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
1953
+ }
1954
+ function IsNumber4(value) {
1955
+ return IsKindOf2(value, "Number") && value.type === "number" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
1956
+ }
1957
+ function IsObject4(value) {
1958
+ return IsKindOf2(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
1959
+ }
1960
+ function IsPromise2(value) {
1961
+ return IsKindOf2(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema2(value.item);
1962
+ }
1963
+ function IsRecord2(value) {
1964
+ return IsKindOf2(value, "Record") && value.type === "object" && IsOptionalString(value.$id) && IsAdditionalProperties(value.additionalProperties) && IsObject(value.patternProperties) && ((schema) => {
1965
+ const keys = Object.getOwnPropertyNames(schema.patternProperties);
1966
+ return keys.length === 1 && IsPattern(keys[0]) && IsObject(schema.patternProperties) && IsSchema2(schema.patternProperties[keys[0]]);
1967
+ })(value);
1968
+ }
1969
+ function IsRecursive(value) {
1970
+ return IsObject(value) && Hint in value && value[Hint] === "Recursive";
1971
+ }
1972
+ function IsRef2(value) {
1973
+ return IsKindOf2(value, "Ref") && IsOptionalString(value.$id) && IsString(value.$ref);
1974
+ }
1975
+ function IsRegExp3(value) {
1976
+ return IsKindOf2(value, "RegExp") && IsOptionalString(value.$id) && IsString(value.source) && IsString(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
1977
+ }
1978
+ function IsString3(value) {
1979
+ return IsKindOf2(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
1980
+ }
1981
+ function IsSymbol3(value) {
1982
+ return IsKindOf2(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
1983
+ }
1984
+ function IsTemplateLiteral2(value) {
1985
+ return IsKindOf2(value, "TemplateLiteral") && value.type === "string" && IsString(value.pattern) && value.pattern[0] === "^" && value.pattern[value.pattern.length - 1] === "$";
1986
+ }
1987
+ function IsThis2(value) {
1988
+ return IsKindOf2(value, "This") && IsOptionalString(value.$id) && IsString(value.$ref);
1989
+ }
1990
+ function IsTransform2(value) {
1991
+ return IsObject(value) && TransformKind in value;
1992
+ }
1993
+ function IsTuple2(value) {
1994
+ return IsKindOf2(value, "Tuple") && value.type === "array" && IsOptionalString(value.$id) && IsNumber(value.minItems) && IsNumber(value.maxItems) && value.minItems === value.maxItems && (IsUndefined(value.items) && IsUndefined(value.additionalItems) && value.minItems === 0 || IsArray(value.items) && value.items.every((schema) => IsSchema2(schema)));
1995
+ }
1996
+ function IsUndefined4(value) {
1997
+ return IsKindOf2(value, "Undefined") && value.type === "undefined" && IsOptionalString(value.$id);
1998
+ }
1999
+ function IsUnionLiteral(value) {
2000
+ return IsUnion2(value) && value.anyOf.every((schema) => IsLiteralString(schema) || IsLiteralNumber(schema));
2001
+ }
2002
+ function IsUnion2(value) {
2003
+ return IsKindOf2(value, "Union") && IsOptionalString(value.$id) && IsObject(value) && IsArray(value.anyOf) && value.anyOf.every((schema) => IsSchema2(schema));
2004
+ }
2005
+ function IsUint8Array3(value) {
2006
+ return IsKindOf2(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
2007
+ }
2008
+ function IsUnknown2(value) {
2009
+ return IsKindOf2(value, "Unknown") && IsOptionalString(value.$id);
2010
+ }
2011
+ function IsUnsafe2(value) {
2012
+ return IsKindOf2(value, "Unsafe");
2013
+ }
2014
+ function IsVoid2(value) {
2015
+ return IsKindOf2(value, "Void") && value.type === "void" && IsOptionalString(value.$id);
2016
+ }
2017
+ function IsKind2(value) {
2018
+ return IsObject(value) && Kind in value && IsString(value[Kind]) && !KnownTypes.includes(value[Kind]);
2019
+ }
2020
+ function IsSchema2(value) {
2021
+ return IsObject(value) && (IsAny2(value) || IsArgument2(value) || IsArray4(value) || IsBoolean3(value) || IsBigInt3(value) || IsAsyncIterator3(value) || IsComputed2(value) || IsConstructor2(value) || IsDate3(value) || IsFunction3(value) || IsInteger2(value) || IsIntersect2(value) || IsIterator3(value) || IsLiteral2(value) || IsMappedKey2(value) || IsMappedResult2(value) || IsNever2(value) || IsNot2(value) || IsNull3(value) || IsNumber4(value) || IsObject4(value) || IsPromise2(value) || IsRecord2(value) || IsRef2(value) || IsRegExp3(value) || IsString3(value) || IsSymbol3(value) || IsTemplateLiteral2(value) || IsThis2(value) || IsTuple2(value) || IsUndefined4(value) || IsUnion2(value) || IsUint8Array3(value) || IsUnknown2(value) || IsUnsafe2(value) || IsVoid2(value) || IsKind2(value));
2022
+ }
2023
+ // node_modules/@sinclair/typebox/build/esm/type/patterns/patterns.mjs
2024
+ var PatternBoolean = "(true|false)";
2025
+ var PatternNumber = "(0|[1-9][0-9]*)";
2026
+ var PatternString = "(.*)";
2027
+ var PatternNever = "(?!.*)";
2028
+ var PatternBooleanExact = `^${PatternBoolean}$`;
2029
+ var PatternNumberExact = `^${PatternNumber}$`;
2030
+ var PatternStringExact = `^${PatternString}$`;
2031
+ var PatternNeverExact = `^${PatternNever}$`;
2032
+
2033
+ // node_modules/@sinclair/typebox/build/esm/type/sets/set.mjs
2034
+ function SetIncludes(T, S) {
2035
+ return T.includes(S);
2036
+ }
2037
+ function SetDistinct(T) {
2038
+ return [...new Set(T)];
2039
+ }
2040
+ function SetIntersect(T, S) {
2041
+ return T.filter((L) => S.includes(L));
2042
+ }
2043
+ function SetIntersectManyResolve(T, Init) {
2044
+ return T.reduce((Acc, L) => {
2045
+ return SetIntersect(Acc, L);
2046
+ }, Init);
2047
+ }
2048
+ function SetIntersectMany(T) {
2049
+ return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
2050
+ }
2051
+ function SetUnionMany(T) {
2052
+ const Acc = [];
2053
+ for (const L of T)
2054
+ Acc.push(...L);
2055
+ return Acc;
2056
+ }
2057
+
2058
+ // node_modules/@sinclair/typebox/build/esm/type/any/any.mjs
2059
+ function Any(options) {
2060
+ return CreateType({ [Kind]: "Any" }, options);
2061
+ }
2062
+
2063
+ // node_modules/@sinclair/typebox/build/esm/type/array/array.mjs
2064
+ function Array2(items, options) {
2065
+ return CreateType({ [Kind]: "Array", type: "array", items }, options);
2066
+ }
2067
+
2068
+ // node_modules/@sinclair/typebox/build/esm/type/argument/argument.mjs
2069
+ function Argument(index) {
2070
+ return CreateType({ [Kind]: "Argument", index });
2071
+ }
2072
+
2073
+ // node_modules/@sinclair/typebox/build/esm/type/async-iterator/async-iterator.mjs
2074
+ function AsyncIterator(items, options) {
2075
+ return CreateType({ [Kind]: "AsyncIterator", type: "AsyncIterator", items }, options);
2076
+ }
2077
+
2078
+ // node_modules/@sinclair/typebox/build/esm/type/computed/computed.mjs
2079
+ function Computed(target, parameters, options) {
2080
+ return CreateType({ [Kind]: "Computed", target, parameters }, options);
2081
+ }
2082
+
2083
+ // node_modules/@sinclair/typebox/build/esm/type/discard/discard.mjs
2084
+ function DiscardKey(value, key) {
2085
+ const { [key]: _, ...rest } = value;
2086
+ return rest;
2087
+ }
2088
+ function Discard(value, keys) {
2089
+ return keys.reduce((acc, key) => DiscardKey(acc, key), value);
2090
+ }
2091
+
2092
+ // node_modules/@sinclair/typebox/build/esm/type/never/never.mjs
2093
+ function Never(options) {
2094
+ return CreateType({ [Kind]: "Never", not: {} }, options);
2095
+ }
2096
+
2097
+ // node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-result.mjs
2098
+ function MappedResult(properties) {
2099
+ return CreateType({
2100
+ [Kind]: "MappedResult",
2101
+ properties
2102
+ });
2103
+ }
2104
+
2105
+ // node_modules/@sinclair/typebox/build/esm/type/constructor/constructor.mjs
2106
+ function Constructor(parameters, returns, options) {
2107
+ return CreateType({ [Kind]: "Constructor", type: "Constructor", parameters, returns }, options);
2108
+ }
2109
+
2110
+ // node_modules/@sinclair/typebox/build/esm/type/function/function.mjs
2111
+ function Function(parameters, returns, options) {
2112
+ return CreateType({ [Kind]: "Function", type: "Function", parameters, returns }, options);
2113
+ }
2114
+
2115
+ // node_modules/@sinclair/typebox/build/esm/type/union/union-create.mjs
2116
+ function UnionCreate(T, options) {
2117
+ return CreateType({ [Kind]: "Union", anyOf: T }, options);
2118
+ }
2119
+
2120
+ // node_modules/@sinclair/typebox/build/esm/type/union/union-evaluated.mjs
2121
+ function IsUnionOptional(types) {
2122
+ return types.some((type) => IsOptional(type));
2123
+ }
2124
+ function RemoveOptionalFromRest(types) {
2125
+ return types.map((left) => IsOptional(left) ? RemoveOptionalFromType(left) : left);
2126
+ }
2127
+ function RemoveOptionalFromType(T) {
2128
+ return Discard(T, [OptionalKind]);
2129
+ }
2130
+ function ResolveUnion(types, options) {
2131
+ const isOptional = IsUnionOptional(types);
2132
+ return isOptional ? Optional(UnionCreate(RemoveOptionalFromRest(types), options)) : UnionCreate(RemoveOptionalFromRest(types), options);
2133
+ }
2134
+ function UnionEvaluated(T, options) {
2135
+ return T.length === 1 ? CreateType(T[0], options) : T.length === 0 ? Never(options) : ResolveUnion(T, options);
2136
+ }
2137
+
2138
+ // node_modules/@sinclair/typebox/build/esm/type/union/union.mjs
2139
+ function Union(types, options) {
2140
+ return types.length === 0 ? Never(options) : types.length === 1 ? CreateType(types[0], options) : UnionCreate(types, options);
2141
+ }
2142
+
2143
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/parse.mjs
2144
+ class TemplateLiteralParserError extends TypeBoxError {
2145
+ }
2146
+ function Unescape(pattern) {
2147
+ return pattern.replace(/\\\$/g, "$").replace(/\\\*/g, "*").replace(/\\\^/g, "^").replace(/\\\|/g, "|").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
2148
+ }
2149
+ function IsNonEscaped(pattern, index, char) {
2150
+ return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
2151
+ }
2152
+ function IsOpenParen(pattern, index) {
2153
+ return IsNonEscaped(pattern, index, "(");
2154
+ }
2155
+ function IsCloseParen(pattern, index) {
2156
+ return IsNonEscaped(pattern, index, ")");
2157
+ }
2158
+ function IsSeparator(pattern, index) {
2159
+ return IsNonEscaped(pattern, index, "|");
2160
+ }
2161
+ function IsGroup(pattern) {
2162
+ if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1)))
2163
+ return false;
2164
+ let count = 0;
2165
+ for (let index = 0;index < pattern.length; index++) {
2166
+ if (IsOpenParen(pattern, index))
2167
+ count += 1;
2168
+ if (IsCloseParen(pattern, index))
2169
+ count -= 1;
2170
+ if (count === 0 && index !== pattern.length - 1)
2171
+ return false;
2172
+ }
2173
+ return true;
2174
+ }
2175
+ function InGroup(pattern) {
2176
+ return pattern.slice(1, pattern.length - 1);
2177
+ }
2178
+ function IsPrecedenceOr(pattern) {
2179
+ let count = 0;
2180
+ for (let index = 0;index < pattern.length; index++) {
2181
+ if (IsOpenParen(pattern, index))
2182
+ count += 1;
2183
+ if (IsCloseParen(pattern, index))
2184
+ count -= 1;
2185
+ if (IsSeparator(pattern, index) && count === 0)
2186
+ return true;
2187
+ }
2188
+ return false;
2189
+ }
2190
+ function IsPrecedenceAnd(pattern) {
2191
+ for (let index = 0;index < pattern.length; index++) {
2192
+ if (IsOpenParen(pattern, index))
2193
+ return true;
2194
+ }
2195
+ return false;
2196
+ }
2197
+ function Or(pattern) {
2198
+ let [count, start] = [0, 0];
2199
+ const expressions = [];
2200
+ for (let index = 0;index < pattern.length; index++) {
2201
+ if (IsOpenParen(pattern, index))
2202
+ count += 1;
2203
+ if (IsCloseParen(pattern, index))
2204
+ count -= 1;
2205
+ if (IsSeparator(pattern, index) && count === 0) {
2206
+ const range2 = pattern.slice(start, index);
2207
+ if (range2.length > 0)
2208
+ expressions.push(TemplateLiteralParse(range2));
2209
+ start = index + 1;
2210
+ }
2211
+ }
2212
+ const range = pattern.slice(start);
2213
+ if (range.length > 0)
2214
+ expressions.push(TemplateLiteralParse(range));
2215
+ if (expressions.length === 0)
2216
+ return { type: "const", const: "" };
2217
+ if (expressions.length === 1)
2218
+ return expressions[0];
2219
+ return { type: "or", expr: expressions };
2220
+ }
2221
+ function And(pattern) {
2222
+ function Group(value, index) {
2223
+ if (!IsOpenParen(value, index))
2224
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
2225
+ let count = 0;
2226
+ for (let scan = index;scan < value.length; scan++) {
2227
+ if (IsOpenParen(value, scan))
2228
+ count += 1;
2229
+ if (IsCloseParen(value, scan))
2230
+ count -= 1;
2231
+ if (count === 0)
2232
+ return [index, scan];
2233
+ }
2234
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
2235
+ }
2236
+ function Range(pattern2, index) {
2237
+ for (let scan = index;scan < pattern2.length; scan++) {
2238
+ if (IsOpenParen(pattern2, scan))
2239
+ return [index, scan];
2240
+ }
2241
+ return [index, pattern2.length];
2242
+ }
2243
+ const expressions = [];
2244
+ for (let index = 0;index < pattern.length; index++) {
2245
+ if (IsOpenParen(pattern, index)) {
2246
+ const [start, end] = Group(pattern, index);
2247
+ const range = pattern.slice(start, end + 1);
2248
+ expressions.push(TemplateLiteralParse(range));
2249
+ index = end;
2250
+ } else {
2251
+ const [start, end] = Range(pattern, index);
2252
+ const range = pattern.slice(start, end);
2253
+ if (range.length > 0)
2254
+ expressions.push(TemplateLiteralParse(range));
2255
+ index = end - 1;
2256
+ }
2257
+ }
2258
+ return expressions.length === 0 ? { type: "const", const: "" } : expressions.length === 1 ? expressions[0] : { type: "and", expr: expressions };
2259
+ }
2260
+ function TemplateLiteralParse(pattern) {
2261
+ return IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) : IsPrecedenceOr(pattern) ? Or(pattern) : IsPrecedenceAnd(pattern) ? And(pattern) : { type: "const", const: Unescape(pattern) };
2262
+ }
2263
+ function TemplateLiteralParseExact(pattern) {
2264
+ return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
2265
+ }
2266
+
2267
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/finite.mjs
2268
+ class TemplateLiteralFiniteError extends TypeBoxError {
2269
+ }
2270
+ function IsNumberExpression(expression) {
2271
+ return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "0" && expression.expr[1].type === "const" && expression.expr[1].const === "[1-9][0-9]*";
2272
+ }
2273
+ function IsBooleanExpression(expression) {
2274
+ return expression.type === "or" && expression.expr.length === 2 && expression.expr[0].type === "const" && expression.expr[0].const === "true" && expression.expr[1].type === "const" && expression.expr[1].const === "false";
2275
+ }
2276
+ function IsStringExpression(expression) {
2277
+ return expression.type === "const" && expression.const === ".*";
2278
+ }
2279
+ function IsTemplateLiteralExpressionFinite(expression) {
2280
+ return IsNumberExpression(expression) || IsStringExpression(expression) ? false : IsBooleanExpression(expression) ? true : expression.type === "and" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "or" ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) : expression.type === "const" ? true : (() => {
2281
+ throw new TemplateLiteralFiniteError(`Unknown expression type`);
2282
+ })();
2283
+ }
2284
+ function IsTemplateLiteralFinite(schema) {
2285
+ const expression = TemplateLiteralParseExact(schema.pattern);
2286
+ return IsTemplateLiteralExpressionFinite(expression);
2287
+ }
2288
+
2289
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/generate.mjs
2290
+ class TemplateLiteralGenerateError extends TypeBoxError {
2291
+ }
2292
+ function* GenerateReduce(buffer) {
2293
+ if (buffer.length === 1)
2294
+ return yield* buffer[0];
2295
+ for (const left of buffer[0]) {
2296
+ for (const right of GenerateReduce(buffer.slice(1))) {
2297
+ yield `${left}${right}`;
2298
+ }
2299
+ }
2300
+ }
2301
+ function* GenerateAnd(expression) {
2302
+ return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
2303
+ }
2304
+ function* GenerateOr(expression) {
2305
+ for (const expr of expression.expr)
2306
+ yield* TemplateLiteralExpressionGenerate(expr);
2307
+ }
2308
+ function* GenerateConst(expression) {
2309
+ return yield expression.const;
2310
+ }
2311
+ function* TemplateLiteralExpressionGenerate(expression) {
2312
+ return expression.type === "and" ? yield* GenerateAnd(expression) : expression.type === "or" ? yield* GenerateOr(expression) : expression.type === "const" ? yield* GenerateConst(expression) : (() => {
2313
+ throw new TemplateLiteralGenerateError("Unknown expression");
2314
+ })();
2315
+ }
2316
+ function TemplateLiteralGenerate(schema) {
2317
+ const expression = TemplateLiteralParseExact(schema.pattern);
2318
+ return IsTemplateLiteralExpressionFinite(expression) ? [...TemplateLiteralExpressionGenerate(expression)] : [];
2319
+ }
2320
+
2321
+ // node_modules/@sinclair/typebox/build/esm/type/literal/literal.mjs
2322
+ function Literal(value, options) {
2323
+ return CreateType({
2324
+ [Kind]: "Literal",
2325
+ const: value,
2326
+ type: typeof value
2327
+ }, options);
2328
+ }
2329
+
2330
+ // node_modules/@sinclair/typebox/build/esm/type/boolean/boolean.mjs
2331
+ function Boolean(options) {
2332
+ return CreateType({ [Kind]: "Boolean", type: "boolean" }, options);
2333
+ }
2334
+
2335
+ // node_modules/@sinclair/typebox/build/esm/type/bigint/bigint.mjs
2336
+ function BigInt(options) {
2337
+ return CreateType({ [Kind]: "BigInt", type: "bigint" }, options);
2338
+ }
2339
+
2340
+ // node_modules/@sinclair/typebox/build/esm/type/number/number.mjs
2341
+ function Number2(options) {
2342
+ return CreateType({ [Kind]: "Number", type: "number" }, options);
2343
+ }
2344
+
2345
+ // node_modules/@sinclair/typebox/build/esm/type/string/string.mjs
2346
+ function String2(options) {
2347
+ return CreateType({ [Kind]: "String", type: "string" }, options);
2348
+ }
2349
+
2350
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/syntax.mjs
2351
+ function* FromUnion(syntax) {
2352
+ const trim = syntax.trim().replace(/"|'/g, "");
2353
+ return trim === "boolean" ? yield Boolean() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt() : trim === "string" ? yield String2() : yield (() => {
2354
+ const literals = trim.split("|").map((literal) => Literal(literal.trim()));
2355
+ return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
2356
+ })();
2357
+ }
2358
+ function* FromTerminal(syntax) {
2359
+ if (syntax[1] !== "{") {
2360
+ const L = Literal("$");
2361
+ const R = FromSyntax(syntax.slice(1));
2362
+ return yield* [L, ...R];
2363
+ }
2364
+ for (let i = 2;i < syntax.length; i++) {
2365
+ if (syntax[i] === "}") {
2366
+ const L = FromUnion(syntax.slice(2, i));
2367
+ const R = FromSyntax(syntax.slice(i + 1));
2368
+ return yield* [...L, ...R];
2369
+ }
2370
+ }
2371
+ yield Literal(syntax);
2372
+ }
2373
+ function* FromSyntax(syntax) {
2374
+ for (let i = 0;i < syntax.length; i++) {
2375
+ if (syntax[i] === "$") {
2376
+ const L = Literal(syntax.slice(0, i));
2377
+ const R = FromTerminal(syntax.slice(i));
2378
+ return yield* [L, ...R];
2379
+ }
2380
+ }
2381
+ yield Literal(syntax);
2382
+ }
2383
+ function TemplateLiteralSyntax(syntax) {
2384
+ return [...FromSyntax(syntax)];
2385
+ }
2386
+
2387
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/pattern.mjs
2388
+ class TemplateLiteralPatternError extends TypeBoxError {
2389
+ }
2390
+ function Escape(value) {
2391
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2392
+ }
2393
+ function Visit2(schema, acc) {
2394
+ return IsTemplateLiteral(schema) ? schema.pattern.slice(1, schema.pattern.length - 1) : IsUnion(schema) ? `(${schema.anyOf.map((schema2) => Visit2(schema2, acc)).join("|")})` : IsNumber3(schema) ? `${acc}${PatternNumber}` : IsInteger(schema) ? `${acc}${PatternNumber}` : IsBigInt2(schema) ? `${acc}${PatternNumber}` : IsString2(schema) ? `${acc}${PatternString}` : IsLiteral(schema) ? `${acc}${Escape(schema.const.toString())}` : IsBoolean2(schema) ? `${acc}${PatternBoolean}` : (() => {
2395
+ throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
2396
+ })();
2397
+ }
2398
+ function TemplateLiteralPattern(kinds) {
2399
+ return `^${kinds.map((schema) => Visit2(schema, "")).join("")}$`;
2400
+ }
2401
+
2402
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/union.mjs
2403
+ function TemplateLiteralToUnion(schema) {
2404
+ const R = TemplateLiteralGenerate(schema);
2405
+ const L = R.map((S) => Literal(S));
2406
+ return UnionEvaluated(L);
2407
+ }
2408
+
2409
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/template-literal.mjs
2410
+ function TemplateLiteral(unresolved, options) {
2411
+ const pattern = IsString(unresolved) ? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved)) : TemplateLiteralPattern(unresolved);
2412
+ return CreateType({ [Kind]: "TemplateLiteral", type: "string", pattern }, options);
2413
+ }
2414
+
2415
+ // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-property-keys.mjs
2416
+ function FromTemplateLiteral(templateLiteral) {
2417
+ const keys = TemplateLiteralGenerate(templateLiteral);
2418
+ return keys.map((key) => key.toString());
2419
+ }
2420
+ function FromUnion2(types) {
2421
+ const result = [];
2422
+ for (const type of types)
2423
+ result.push(...IndexPropertyKeys(type));
2424
+ return result;
2425
+ }
2426
+ function FromLiteral(literalValue) {
2427
+ return [literalValue.toString()];
2428
+ }
2429
+ function IndexPropertyKeys(type) {
2430
+ return [...new Set(IsTemplateLiteral(type) ? FromTemplateLiteral(type) : IsUnion(type) ? FromUnion2(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : IsNumber3(type) ? ["[number]"] : IsInteger(type) ? ["[number]"] : [])];
2431
+ }
2432
+
2433
+ // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-result.mjs
2434
+ function FromProperties(type, properties, options) {
2435
+ const result = {};
2436
+ for (const K2 of Object.getOwnPropertyNames(properties)) {
2437
+ result[K2] = Index(type, IndexPropertyKeys(properties[K2]), options);
2438
+ }
2439
+ return result;
2440
+ }
2441
+ function FromMappedResult(type, mappedResult, options) {
2442
+ return FromProperties(type, mappedResult.properties, options);
2443
+ }
2444
+ function IndexFromMappedResult(type, mappedResult, options) {
2445
+ const properties = FromMappedResult(type, mappedResult, options);
2446
+ return MappedResult(properties);
2447
+ }
2448
+
2449
+ // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed.mjs
2450
+ function FromRest(types, key) {
2451
+ return types.map((type) => IndexFromPropertyKey(type, key));
2452
+ }
2453
+ function FromIntersectRest(types) {
2454
+ return types.filter((type) => !IsNever(type));
2455
+ }
2456
+ function FromIntersect(types, key) {
2457
+ return IntersectEvaluated(FromIntersectRest(FromRest(types, key)));
2458
+ }
2459
+ function FromUnionRest(types) {
2460
+ return types.some((L) => IsNever(L)) ? [] : types;
2461
+ }
2462
+ function FromUnion3(types, key) {
2463
+ return UnionEvaluated(FromUnionRest(FromRest(types, key)));
2464
+ }
2465
+ function FromTuple(types, key) {
2466
+ return key in types ? types[key] : key === "[number]" ? UnionEvaluated(types) : Never();
2467
+ }
2468
+ function FromArray(type, key) {
2469
+ return key === "[number]" ? type : Never();
2470
+ }
2471
+ function FromProperty(properties, propertyKey) {
2472
+ return propertyKey in properties ? properties[propertyKey] : Never();
2473
+ }
2474
+ function IndexFromPropertyKey(type, propertyKey) {
2475
+ return IsIntersect(type) ? FromIntersect(type.allOf, propertyKey) : IsUnion(type) ? FromUnion3(type.anyOf, propertyKey) : IsTuple(type) ? FromTuple(type.items ?? [], propertyKey) : IsArray3(type) ? FromArray(type.items, propertyKey) : IsObject3(type) ? FromProperty(type.properties, propertyKey) : Never();
2476
+ }
2477
+ function IndexFromPropertyKeys(type, propertyKeys) {
2478
+ return propertyKeys.map((propertyKey) => IndexFromPropertyKey(type, propertyKey));
2479
+ }
2480
+ function FromSchema(type, propertyKeys) {
2481
+ return UnionEvaluated(IndexFromPropertyKeys(type, propertyKeys));
2482
+ }
2483
+ function Index(type, key, options) {
2484
+ if (IsRef(type) || IsRef(key)) {
2485
+ const error = `Index types using Ref parameters require both Type and Key to be of TSchema`;
2486
+ if (!IsSchema(type) || !IsSchema(key))
2487
+ throw new TypeBoxError(error);
2488
+ return Computed("Index", [type, key]);
2489
+ }
2490
+ if (IsMappedResult(key))
2491
+ return IndexFromMappedResult(type, key, options);
2492
+ if (IsMappedKey(key))
2493
+ return IndexFromMappedKey(type, key, options);
2494
+ return CreateType(IsSchema(key) ? FromSchema(type, IndexPropertyKeys(key)) : FromSchema(type, key), options);
2495
+ }
2496
+
2497
+ // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-key.mjs
2498
+ function MappedIndexPropertyKey(type, key, options) {
2499
+ return { [key]: Index(type, [key], Clone(options)) };
2500
+ }
2501
+ function MappedIndexPropertyKeys(type, propertyKeys, options) {
2502
+ return propertyKeys.reduce((result, left) => {
2503
+ return { ...result, ...MappedIndexPropertyKey(type, left, options) };
2504
+ }, {});
2505
+ }
2506
+ function MappedIndexProperties(type, mappedKey, options) {
2507
+ return MappedIndexPropertyKeys(type, mappedKey.keys, options);
2508
+ }
2509
+ function IndexFromMappedKey(type, mappedKey, options) {
2510
+ const properties = MappedIndexProperties(type, mappedKey, options);
2511
+ return MappedResult(properties);
2512
+ }
2513
+
2514
+ // node_modules/@sinclair/typebox/build/esm/type/iterator/iterator.mjs
2515
+ function Iterator(items, options) {
2516
+ return CreateType({ [Kind]: "Iterator", type: "Iterator", items }, options);
2517
+ }
2518
+
2519
+ // node_modules/@sinclair/typebox/build/esm/type/object/object.mjs
2520
+ function RequiredArray(properties) {
2521
+ return globalThis.Object.keys(properties).filter((key) => !IsOptional(properties[key]));
2522
+ }
2523
+ function _Object(properties, options) {
2524
+ const required = RequiredArray(properties);
2525
+ const schema = required.length > 0 ? { [Kind]: "Object", type: "object", required, properties } : { [Kind]: "Object", type: "object", properties };
2526
+ return CreateType(schema, options);
2527
+ }
2528
+ var Object2 = _Object;
2529
+
2530
+ // node_modules/@sinclair/typebox/build/esm/type/promise/promise.mjs
2531
+ function Promise2(item, options) {
2532
+ return CreateType({ [Kind]: "Promise", type: "Promise", item }, options);
2533
+ }
2534
+
2535
+ // node_modules/@sinclair/typebox/build/esm/type/readonly/readonly.mjs
2536
+ function RemoveReadonly(schema) {
2537
+ return CreateType(Discard(schema, [ReadonlyKind]));
2538
+ }
2539
+ function AddReadonly(schema) {
2540
+ return CreateType({ ...schema, [ReadonlyKind]: "Readonly" });
2541
+ }
2542
+ function ReadonlyWithFlag(schema, F) {
2543
+ return F === false ? RemoveReadonly(schema) : AddReadonly(schema);
2544
+ }
2545
+ function Readonly(schema, enable) {
2546
+ const F = enable ?? true;
2547
+ return IsMappedResult(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
2548
+ }
2549
+
2550
+ // node_modules/@sinclair/typebox/build/esm/type/readonly/readonly-from-mapped-result.mjs
2551
+ function FromProperties2(K, F) {
2552
+ const Acc = {};
2553
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K))
2554
+ Acc[K2] = Readonly(K[K2], F);
2555
+ return Acc;
2556
+ }
2557
+ function FromMappedResult2(R, F) {
2558
+ return FromProperties2(R.properties, F);
2559
+ }
2560
+ function ReadonlyFromMappedResult(R, F) {
2561
+ const P = FromMappedResult2(R, F);
2562
+ return MappedResult(P);
2563
+ }
2564
+
2565
+ // node_modules/@sinclair/typebox/build/esm/type/tuple/tuple.mjs
2566
+ function Tuple(types, options) {
2567
+ return CreateType(types.length > 0 ? { [Kind]: "Tuple", type: "array", items: types, additionalItems: false, minItems: types.length, maxItems: types.length } : { [Kind]: "Tuple", type: "array", minItems: types.length, maxItems: types.length }, options);
2568
+ }
2569
+
2570
+ // node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs
2571
+ function FromMappedResult3(K, P) {
2572
+ return K in P ? FromSchemaType(K, P[K]) : MappedResult(P);
2573
+ }
2574
+ function MappedKeyToKnownMappedResultProperties(K) {
2575
+ return { [K]: Literal(K) };
2576
+ }
2577
+ function MappedKeyToUnknownMappedResultProperties(P) {
2578
+ const Acc = {};
2579
+ for (const L of P)
2580
+ Acc[L] = Literal(L);
2581
+ return Acc;
2582
+ }
2583
+ function MappedKeyToMappedResultProperties(K, P) {
2584
+ return SetIncludes(P, K) ? MappedKeyToKnownMappedResultProperties(K) : MappedKeyToUnknownMappedResultProperties(P);
2585
+ }
2586
+ function FromMappedKey(K, P) {
2587
+ const R = MappedKeyToMappedResultProperties(K, P);
2588
+ return FromMappedResult3(K, R);
2589
+ }
2590
+ function FromRest2(K, T) {
2591
+ return T.map((L) => FromSchemaType(K, L));
2592
+ }
2593
+ function FromProperties3(K, T) {
2594
+ const Acc = {};
2595
+ for (const K2 of globalThis.Object.getOwnPropertyNames(T))
2596
+ Acc[K2] = FromSchemaType(K, T[K2]);
2597
+ return Acc;
2598
+ }
2599
+ function FromSchemaType(K, T) {
2600
+ const options = { ...T };
2601
+ return IsOptional(T) ? Optional(FromSchemaType(K, Discard(T, [OptionalKind]))) : IsReadonly(T) ? Readonly(FromSchemaType(K, Discard(T, [ReadonlyKind]))) : IsMappedResult(T) ? FromMappedResult3(K, T.properties) : IsMappedKey(T) ? FromMappedKey(K, T.keys) : IsConstructor(T) ? Constructor(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsFunction2(T) ? Function(FromRest2(K, T.parameters), FromSchemaType(K, T.returns), options) : IsAsyncIterator2(T) ? AsyncIterator(FromSchemaType(K, T.items), options) : IsIterator2(T) ? Iterator(FromSchemaType(K, T.items), options) : IsIntersect(T) ? Intersect(FromRest2(K, T.allOf), options) : IsUnion(T) ? Union(FromRest2(K, T.anyOf), options) : IsTuple(T) ? Tuple(FromRest2(K, T.items ?? []), options) : IsObject3(T) ? Object2(FromProperties3(K, T.properties), options) : IsArray3(T) ? Array2(FromSchemaType(K, T.items), options) : IsPromise(T) ? Promise2(FromSchemaType(K, T.item), options) : T;
2602
+ }
2603
+ function MappedFunctionReturnType(K, T) {
2604
+ const Acc = {};
2605
+ for (const L of K)
2606
+ Acc[L] = FromSchemaType(L, T);
2607
+ return Acc;
2608
+ }
2609
+ function Mapped(key, map, options) {
2610
+ const K = IsSchema(key) ? IndexPropertyKeys(key) : key;
2611
+ const RT = map({ [Kind]: "MappedKey", keys: K });
2612
+ const R = MappedFunctionReturnType(K, RT);
2613
+ return Object2(R, options);
2614
+ }
2615
+
2616
+ // node_modules/@sinclair/typebox/build/esm/type/optional/optional.mjs
2617
+ function RemoveOptional(schema) {
2618
+ return CreateType(Discard(schema, [OptionalKind]));
2619
+ }
2620
+ function AddOptional(schema) {
2621
+ return CreateType({ ...schema, [OptionalKind]: "Optional" });
2622
+ }
2623
+ function OptionalWithFlag(schema, F) {
2624
+ return F === false ? RemoveOptional(schema) : AddOptional(schema);
2625
+ }
2626
+ function Optional(schema, enable) {
2627
+ const F = enable ?? true;
2628
+ return IsMappedResult(schema) ? OptionalFromMappedResult(schema, F) : OptionalWithFlag(schema, F);
2629
+ }
2630
+
2631
+ // node_modules/@sinclair/typebox/build/esm/type/optional/optional-from-mapped-result.mjs
2632
+ function FromProperties4(P, F) {
2633
+ const Acc = {};
2634
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
2635
+ Acc[K2] = Optional(P[K2], F);
2636
+ return Acc;
2637
+ }
2638
+ function FromMappedResult4(R, F) {
2639
+ return FromProperties4(R.properties, F);
2640
+ }
2641
+ function OptionalFromMappedResult(R, F) {
2642
+ const P = FromMappedResult4(R, F);
2643
+ return MappedResult(P);
2644
+ }
2645
+
2646
+ // node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-create.mjs
2647
+ function IntersectCreate(T, options = {}) {
2648
+ const allObjects = T.every((schema) => IsObject3(schema));
2649
+ const clonedUnevaluatedProperties = IsSchema(options.unevaluatedProperties) ? { unevaluatedProperties: options.unevaluatedProperties } : {};
2650
+ return CreateType(options.unevaluatedProperties === false || IsSchema(options.unevaluatedProperties) || allObjects ? { ...clonedUnevaluatedProperties, [Kind]: "Intersect", type: "object", allOf: T } : { ...clonedUnevaluatedProperties, [Kind]: "Intersect", allOf: T }, options);
2651
+ }
2652
+
2653
+ // node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-evaluated.mjs
2654
+ function IsIntersectOptional(types) {
2655
+ return types.every((left) => IsOptional(left));
2656
+ }
2657
+ function RemoveOptionalFromType2(type) {
2658
+ return Discard(type, [OptionalKind]);
2659
+ }
2660
+ function RemoveOptionalFromRest2(types) {
2661
+ return types.map((left) => IsOptional(left) ? RemoveOptionalFromType2(left) : left);
2662
+ }
2663
+ function ResolveIntersect(types, options) {
2664
+ return IsIntersectOptional(types) ? Optional(IntersectCreate(RemoveOptionalFromRest2(types), options)) : IntersectCreate(RemoveOptionalFromRest2(types), options);
2665
+ }
2666
+ function IntersectEvaluated(types, options = {}) {
2667
+ if (types.length === 1)
2668
+ return CreateType(types[0], options);
2669
+ if (types.length === 0)
2670
+ return Never(options);
2671
+ if (types.some((schema) => IsTransform(schema)))
2672
+ throw new Error("Cannot intersect transform types");
2673
+ return ResolveIntersect(types, options);
2674
+ }
2675
+
2676
+ // node_modules/@sinclair/typebox/build/esm/type/intersect/intersect.mjs
2677
+ function Intersect(types, options) {
2678
+ if (types.length === 1)
2679
+ return CreateType(types[0], options);
2680
+ if (types.length === 0)
2681
+ return Never(options);
2682
+ if (types.some((schema) => IsTransform(schema)))
2683
+ throw new Error("Cannot intersect transform types");
2684
+ return IntersectCreate(types, options);
2685
+ }
2686
+
2687
+ // node_modules/@sinclair/typebox/build/esm/type/ref/ref.mjs
2688
+ function Ref(...args) {
2689
+ const [$ref, options] = typeof args[0] === "string" ? [args[0], args[1]] : [args[0].$id, args[1]];
2690
+ if (typeof $ref !== "string")
2691
+ throw new TypeBoxError("Ref: $ref must be a string");
2692
+ return CreateType({ [Kind]: "Ref", $ref }, options);
2693
+ }
2694
+
2695
+ // node_modules/@sinclair/typebox/build/esm/type/awaited/awaited.mjs
2696
+ function FromComputed(target, parameters) {
2697
+ return Computed("Awaited", [Computed(target, parameters)]);
2698
+ }
2699
+ function FromRef($ref) {
2700
+ return Computed("Awaited", [Ref($ref)]);
2701
+ }
2702
+ function FromIntersect2(types) {
2703
+ return Intersect(FromRest3(types));
2704
+ }
2705
+ function FromUnion4(types) {
2706
+ return Union(FromRest3(types));
2707
+ }
2708
+ function FromPromise(type) {
2709
+ return Awaited(type);
2710
+ }
2711
+ function FromRest3(types) {
2712
+ return types.map((type) => Awaited(type));
2713
+ }
2714
+ function Awaited(type, options) {
2715
+ return CreateType(IsComputed(type) ? FromComputed(type.target, type.parameters) : IsIntersect(type) ? FromIntersect2(type.allOf) : IsUnion(type) ? FromUnion4(type.anyOf) : IsPromise(type) ? FromPromise(type.item) : IsRef(type) ? FromRef(type.$ref) : type, options);
2716
+ }
2717
+
2718
+ // node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.mjs
2719
+ function FromRest4(types) {
2720
+ const result = [];
2721
+ for (const L of types)
2722
+ result.push(KeyOfPropertyKeys(L));
2723
+ return result;
2724
+ }
2725
+ function FromIntersect3(types) {
2726
+ const propertyKeysArray = FromRest4(types);
2727
+ const propertyKeys = SetUnionMany(propertyKeysArray);
2728
+ return propertyKeys;
2729
+ }
2730
+ function FromUnion5(types) {
2731
+ const propertyKeysArray = FromRest4(types);
2732
+ const propertyKeys = SetIntersectMany(propertyKeysArray);
2733
+ return propertyKeys;
2734
+ }
2735
+ function FromTuple2(types) {
2736
+ return types.map((_, indexer) => indexer.toString());
2737
+ }
2738
+ function FromArray2(_) {
2739
+ return ["[number]"];
2740
+ }
2741
+ function FromProperties5(T) {
2742
+ return globalThis.Object.getOwnPropertyNames(T);
2743
+ }
2744
+ function FromPatternProperties(patternProperties) {
2745
+ if (!includePatternProperties)
2746
+ return [];
2747
+ const patternPropertyKeys = globalThis.Object.getOwnPropertyNames(patternProperties);
2748
+ return patternPropertyKeys.map((key) => {
2749
+ return key[0] === "^" && key[key.length - 1] === "$" ? key.slice(1, key.length - 1) : key;
2750
+ });
2751
+ }
2752
+ function KeyOfPropertyKeys(type) {
2753
+ return IsIntersect(type) ? FromIntersect3(type.allOf) : IsUnion(type) ? FromUnion5(type.anyOf) : IsTuple(type) ? FromTuple2(type.items ?? []) : IsArray3(type) ? FromArray2(type.items) : IsObject3(type) ? FromProperties5(type.properties) : IsRecord(type) ? FromPatternProperties(type.patternProperties) : [];
2754
+ }
2755
+ var includePatternProperties = false;
2756
+
2757
+ // node_modules/@sinclair/typebox/build/esm/type/keyof/keyof.mjs
2758
+ function FromComputed2(target, parameters) {
2759
+ return Computed("KeyOf", [Computed(target, parameters)]);
2760
+ }
2761
+ function FromRef2($ref) {
2762
+ return Computed("KeyOf", [Ref($ref)]);
2763
+ }
2764
+ function KeyOfFromType(type, options) {
2765
+ const propertyKeys = KeyOfPropertyKeys(type);
2766
+ const propertyKeyTypes = KeyOfPropertyKeysToRest(propertyKeys);
2767
+ const result = UnionEvaluated(propertyKeyTypes);
2768
+ return CreateType(result, options);
2769
+ }
2770
+ function KeyOfPropertyKeysToRest(propertyKeys) {
2771
+ return propertyKeys.map((L) => L === "[number]" ? Number2() : Literal(L));
2772
+ }
2773
+ function KeyOf(type, options) {
2774
+ return IsComputed(type) ? FromComputed2(type.target, type.parameters) : IsRef(type) ? FromRef2(type.$ref) : IsMappedResult(type) ? KeyOfFromMappedResult(type, options) : KeyOfFromType(type, options);
2775
+ }
2776
+
2777
+ // node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-from-mapped-result.mjs
2778
+ function FromProperties6(properties, options) {
2779
+ const result = {};
2780
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
2781
+ result[K2] = KeyOf(properties[K2], Clone(options));
2782
+ return result;
2783
+ }
2784
+ function FromMappedResult5(mappedResult, options) {
2785
+ return FromProperties6(mappedResult.properties, options);
2786
+ }
2787
+ function KeyOfFromMappedResult(mappedResult, options) {
2788
+ const properties = FromMappedResult5(mappedResult, options);
2789
+ return MappedResult(properties);
2790
+ }
2791
+
2792
+ // node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs
2793
+ function CompositeKeys(T) {
2794
+ const Acc = [];
2795
+ for (const L of T)
2796
+ Acc.push(...KeyOfPropertyKeys(L));
2797
+ return SetDistinct(Acc);
2798
+ }
2799
+ function FilterNever(T) {
2800
+ return T.filter((L) => !IsNever(L));
2801
+ }
2802
+ function CompositeProperty(T, K) {
2803
+ const Acc = [];
2804
+ for (const L of T)
2805
+ Acc.push(...IndexFromPropertyKeys(L, [K]));
2806
+ return FilterNever(Acc);
2807
+ }
2808
+ function CompositeProperties(T, K) {
2809
+ const Acc = {};
2810
+ for (const L of K) {
2811
+ Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
2812
+ }
2813
+ return Acc;
2814
+ }
2815
+ function Composite(T, options) {
2816
+ const K = CompositeKeys(T);
2817
+ const P = CompositeProperties(T, K);
2818
+ const R = Object2(P, options);
2819
+ return R;
2820
+ }
2821
+
2822
+ // node_modules/@sinclair/typebox/build/esm/type/date/date.mjs
2823
+ function Date2(options) {
2824
+ return CreateType({ [Kind]: "Date", type: "Date" }, options);
2825
+ }
2826
+
2827
+ // node_modules/@sinclair/typebox/build/esm/type/null/null.mjs
2828
+ function Null(options) {
2829
+ return CreateType({ [Kind]: "Null", type: "null" }, options);
2830
+ }
2831
+
2832
+ // node_modules/@sinclair/typebox/build/esm/type/symbol/symbol.mjs
2833
+ function Symbol2(options) {
2834
+ return CreateType({ [Kind]: "Symbol", type: "symbol" }, options);
2835
+ }
2836
+
2837
+ // node_modules/@sinclair/typebox/build/esm/type/undefined/undefined.mjs
2838
+ function Undefined(options) {
2839
+ return CreateType({ [Kind]: "Undefined", type: "undefined" }, options);
2840
+ }
2841
+
2842
+ // node_modules/@sinclair/typebox/build/esm/type/uint8array/uint8array.mjs
2843
+ function Uint8Array2(options) {
2844
+ return CreateType({ [Kind]: "Uint8Array", type: "Uint8Array" }, options);
2845
+ }
2846
+
2847
+ // node_modules/@sinclair/typebox/build/esm/type/unknown/unknown.mjs
2848
+ function Unknown(options) {
2849
+ return CreateType({ [Kind]: "Unknown" }, options);
2850
+ }
2851
+
2852
+ // node_modules/@sinclair/typebox/build/esm/type/const/const.mjs
2853
+ function FromArray3(T) {
2854
+ return T.map((L) => FromValue(L, false));
2855
+ }
2856
+ function FromProperties7(value) {
2857
+ const Acc = {};
2858
+ for (const K of globalThis.Object.getOwnPropertyNames(value))
2859
+ Acc[K] = Readonly(FromValue(value[K], false));
2860
+ return Acc;
2861
+ }
2862
+ function ConditionalReadonly(T, root) {
2863
+ return root === true ? T : Readonly(T);
2864
+ }
2865
+ function FromValue(value, root) {
2866
+ return IsAsyncIterator(value) ? ConditionalReadonly(Any(), root) : IsIterator(value) ? ConditionalReadonly(Any(), root) : IsArray(value) ? Readonly(Tuple(FromArray3(value))) : IsUint8Array(value) ? Uint8Array2() : IsDate(value) ? Date2() : IsObject(value) ? ConditionalReadonly(Object2(FromProperties7(value)), root) : IsFunction(value) ? ConditionalReadonly(Function([], Unknown()), root) : IsUndefined(value) ? Undefined() : IsNull(value) ? Null() : IsSymbol(value) ? Symbol2() : IsBigInt(value) ? BigInt() : IsNumber(value) ? Literal(value) : IsBoolean(value) ? Literal(value) : IsString(value) ? Literal(value) : Object2({});
2867
+ }
2868
+ function Const(T, options) {
2869
+ return CreateType(FromValue(T, true), options);
2870
+ }
2871
+
2872
+ // node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/constructor-parameters.mjs
2873
+ function ConstructorParameters(schema, options) {
2874
+ return IsConstructor(schema) ? Tuple(schema.parameters, options) : Never(options);
2875
+ }
2876
+
2877
+ // node_modules/@sinclair/typebox/build/esm/type/enum/enum.mjs
2878
+ function Enum(item, options) {
2879
+ if (IsUndefined(item))
2880
+ throw new Error("Enum undefined or empty");
2881
+ const values1 = globalThis.Object.getOwnPropertyNames(item).filter((key) => isNaN(key)).map((key) => item[key]);
2882
+ const values2 = [...new Set(values1)];
2883
+ const anyOf = values2.map((value) => Literal(value));
2884
+ return Union(anyOf, { ...options, [Hint]: "Enum" });
2885
+ }
2886
+
2887
+ // node_modules/@sinclair/typebox/build/esm/type/extends/extends-check.mjs
2888
+ class ExtendsResolverError extends TypeBoxError {
2889
+ }
2890
+ var ExtendsResult;
2891
+ (function(ExtendsResult2) {
2892
+ ExtendsResult2[ExtendsResult2["Union"] = 0] = "Union";
2893
+ ExtendsResult2[ExtendsResult2["True"] = 1] = "True";
2894
+ ExtendsResult2[ExtendsResult2["False"] = 2] = "False";
2895
+ })(ExtendsResult || (ExtendsResult = {}));
2896
+ function IntoBooleanResult(result) {
2897
+ return result === ExtendsResult.False ? result : ExtendsResult.True;
2898
+ }
2899
+ function Throw(message) {
2900
+ throw new ExtendsResolverError(message);
2901
+ }
2902
+ function IsStructuralRight(right) {
2903
+ return exports_type.IsNever(right) || exports_type.IsIntersect(right) || exports_type.IsUnion(right) || exports_type.IsUnknown(right) || exports_type.IsAny(right);
2904
+ }
2905
+ function StructuralRight(left, right) {
2906
+ return exports_type.IsNever(right) ? FromNeverRight(left, right) : exports_type.IsIntersect(right) ? FromIntersectRight(left, right) : exports_type.IsUnion(right) ? FromUnionRight(left, right) : exports_type.IsUnknown(right) ? FromUnknownRight(left, right) : exports_type.IsAny(right) ? FromAnyRight(left, right) : Throw("StructuralRight");
2907
+ }
2908
+ function FromAnyRight(left, right) {
2909
+ return ExtendsResult.True;
2910
+ }
2911
+ function FromAny(left, right) {
2912
+ return exports_type.IsIntersect(right) ? FromIntersectRight(left, right) : exports_type.IsUnion(right) && right.anyOf.some((schema) => exports_type.IsAny(schema) || exports_type.IsUnknown(schema)) ? ExtendsResult.True : exports_type.IsUnion(right) ? ExtendsResult.Union : exports_type.IsUnknown(right) ? ExtendsResult.True : exports_type.IsAny(right) ? ExtendsResult.True : ExtendsResult.Union;
2913
+ }
2914
+ function FromArrayRight(left, right) {
2915
+ return exports_type.IsUnknown(left) ? ExtendsResult.False : exports_type.IsAny(left) ? ExtendsResult.Union : exports_type.IsNever(left) ? ExtendsResult.True : ExtendsResult.False;
2916
+ }
2917
+ function FromArray4(left, right) {
2918
+ return exports_type.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : !exports_type.IsArray(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
2919
+ }
2920
+ function FromAsyncIterator(left, right) {
2921
+ return IsStructuralRight(right) ? StructuralRight(left, right) : !exports_type.IsAsyncIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
2922
+ }
2923
+ function FromBigInt(left, right) {
2924
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsRecord(right) ? FromRecordRight(left, right) : exports_type.IsBigInt(right) ? ExtendsResult.True : ExtendsResult.False;
2925
+ }
2926
+ function FromBooleanRight(left, right) {
2927
+ return exports_type.IsLiteralBoolean(left) ? ExtendsResult.True : exports_type.IsBoolean(left) ? ExtendsResult.True : ExtendsResult.False;
2928
+ }
2929
+ function FromBoolean(left, right) {
2930
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsRecord(right) ? FromRecordRight(left, right) : exports_type.IsBoolean(right) ? ExtendsResult.True : ExtendsResult.False;
2931
+ }
2932
+ function FromConstructor(left, right) {
2933
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : !exports_type.IsConstructor(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit3(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.returns, right.returns));
2934
+ }
2935
+ function FromDate(left, right) {
2936
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsRecord(right) ? FromRecordRight(left, right) : exports_type.IsDate(right) ? ExtendsResult.True : ExtendsResult.False;
2937
+ }
2938
+ function FromFunction(left, right) {
2939
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : !exports_type.IsFunction(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit3(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.returns, right.returns));
2940
+ }
2941
+ function FromIntegerRight(left, right) {
2942
+ return exports_type.IsLiteral(left) && exports_value.IsNumber(left.const) ? ExtendsResult.True : exports_type.IsNumber(left) || exports_type.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
2943
+ }
2944
+ function FromInteger(left, right) {
2945
+ return exports_type.IsInteger(right) || exports_type.IsNumber(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsRecord(right) ? FromRecordRight(left, right) : ExtendsResult.False;
2946
+ }
2947
+ function FromIntersectRight(left, right) {
2948
+ return right.allOf.every((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
2949
+ }
2950
+ function FromIntersect4(left, right) {
2951
+ return left.allOf.some((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
2952
+ }
2953
+ function FromIterator(left, right) {
2954
+ return IsStructuralRight(right) ? StructuralRight(left, right) : !exports_type.IsIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
2955
+ }
2956
+ function FromLiteral2(left, right) {
2957
+ return exports_type.IsLiteral(right) && right.const === left.const ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsRecord(right) ? FromRecordRight(left, right) : exports_type.IsString(right) ? FromStringRight(left, right) : exports_type.IsNumber(right) ? FromNumberRight(left, right) : exports_type.IsInteger(right) ? FromIntegerRight(left, right) : exports_type.IsBoolean(right) ? FromBooleanRight(left, right) : ExtendsResult.False;
2958
+ }
2959
+ function FromNeverRight(left, right) {
2960
+ return ExtendsResult.False;
2961
+ }
2962
+ function FromNever(left, right) {
2963
+ return ExtendsResult.True;
2964
+ }
2965
+ function UnwrapTNot(schema) {
2966
+ let [current, depth] = [schema, 0];
2967
+ while (true) {
2968
+ if (!exports_type.IsNot(current))
2969
+ break;
2970
+ current = current.not;
2971
+ depth += 1;
2972
+ }
2973
+ return depth % 2 === 0 ? current : Unknown();
2974
+ }
2975
+ function FromNot(left, right) {
2976
+ return exports_type.IsNot(left) ? Visit3(UnwrapTNot(left), right) : exports_type.IsNot(right) ? Visit3(left, UnwrapTNot(right)) : Throw("Invalid fallthrough for Not");
2977
+ }
2978
+ function FromNull(left, right) {
2979
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsRecord(right) ? FromRecordRight(left, right) : exports_type.IsNull(right) ? ExtendsResult.True : ExtendsResult.False;
2980
+ }
2981
+ function FromNumberRight(left, right) {
2982
+ return exports_type.IsLiteralNumber(left) ? ExtendsResult.True : exports_type.IsNumber(left) || exports_type.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
2983
+ }
2984
+ function FromNumber(left, right) {
2985
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsRecord(right) ? FromRecordRight(left, right) : exports_type.IsInteger(right) || exports_type.IsNumber(right) ? ExtendsResult.True : ExtendsResult.False;
2986
+ }
2987
+ function IsObjectPropertyCount(schema, count) {
2988
+ return Object.getOwnPropertyNames(schema.properties).length === count;
2989
+ }
2990
+ function IsObjectStringLike(schema) {
2991
+ return IsObjectArrayLike(schema);
2992
+ }
2993
+ function IsObjectSymbolLike(schema) {
2994
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "description" in schema.properties && exports_type.IsUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && (exports_type.IsString(schema.properties.description.anyOf[0]) && exports_type.IsUndefined(schema.properties.description.anyOf[1]) || exports_type.IsString(schema.properties.description.anyOf[1]) && exports_type.IsUndefined(schema.properties.description.anyOf[0]));
2995
+ }
2996
+ function IsObjectNumberLike(schema) {
2997
+ return IsObjectPropertyCount(schema, 0);
2998
+ }
2999
+ function IsObjectBooleanLike(schema) {
3000
+ return IsObjectPropertyCount(schema, 0);
3001
+ }
3002
+ function IsObjectBigIntLike(schema) {
3003
+ return IsObjectPropertyCount(schema, 0);
3004
+ }
3005
+ function IsObjectDateLike(schema) {
3006
+ return IsObjectPropertyCount(schema, 0);
3007
+ }
3008
+ function IsObjectUint8ArrayLike(schema) {
3009
+ return IsObjectArrayLike(schema);
3010
+ }
3011
+ function IsObjectFunctionLike(schema) {
3012
+ const length = Number2();
3013
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
3014
+ }
3015
+ function IsObjectConstructorLike(schema) {
3016
+ return IsObjectPropertyCount(schema, 0);
3017
+ }
3018
+ function IsObjectArrayLike(schema) {
3019
+ const length = Number2();
3020
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
3021
+ }
3022
+ function IsObjectPromiseLike(schema) {
3023
+ const then = Function([Any()], Any());
3024
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "then" in schema.properties && IntoBooleanResult(Visit3(schema.properties["then"], then)) === ExtendsResult.True;
3025
+ }
3026
+ function Property(left, right) {
3027
+ return Visit3(left, right) === ExtendsResult.False ? ExtendsResult.False : exports_type.IsOptional(left) && !exports_type.IsOptional(right) ? ExtendsResult.False : ExtendsResult.True;
3028
+ }
3029
+ function FromObjectRight(left, right) {
3030
+ return exports_type.IsUnknown(left) ? ExtendsResult.False : exports_type.IsAny(left) ? ExtendsResult.Union : exports_type.IsNever(left) || exports_type.IsLiteralString(left) && IsObjectStringLike(right) || exports_type.IsLiteralNumber(left) && IsObjectNumberLike(right) || exports_type.IsLiteralBoolean(left) && IsObjectBooleanLike(right) || exports_type.IsSymbol(left) && IsObjectSymbolLike(right) || exports_type.IsBigInt(left) && IsObjectBigIntLike(right) || exports_type.IsString(left) && IsObjectStringLike(right) || exports_type.IsSymbol(left) && IsObjectSymbolLike(right) || exports_type.IsNumber(left) && IsObjectNumberLike(right) || exports_type.IsInteger(left) && IsObjectNumberLike(right) || exports_type.IsBoolean(left) && IsObjectBooleanLike(right) || exports_type.IsUint8Array(left) && IsObjectUint8ArrayLike(right) || exports_type.IsDate(left) && IsObjectDateLike(right) || exports_type.IsConstructor(left) && IsObjectConstructorLike(right) || exports_type.IsFunction(left) && IsObjectFunctionLike(right) ? ExtendsResult.True : exports_type.IsRecord(left) && exports_type.IsString(RecordKey(left)) ? (() => {
3031
+ return right[Hint] === "Record" ? ExtendsResult.True : ExtendsResult.False;
3032
+ })() : exports_type.IsRecord(left) && exports_type.IsNumber(RecordKey(left)) ? (() => {
3033
+ return IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False;
3034
+ })() : ExtendsResult.False;
3035
+ }
3036
+ function FromObject(left, right) {
3037
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsRecord(right) ? FromRecordRight(left, right) : !exports_type.IsObject(right) ? ExtendsResult.False : (() => {
3038
+ for (const key of Object.getOwnPropertyNames(right.properties)) {
3039
+ if (!(key in left.properties) && !exports_type.IsOptional(right.properties[key])) {
3040
+ return ExtendsResult.False;
3041
+ }
3042
+ if (exports_type.IsOptional(right.properties[key])) {
3043
+ return ExtendsResult.True;
3044
+ }
3045
+ if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) {
3046
+ return ExtendsResult.False;
3047
+ }
3048
+ }
3049
+ return ExtendsResult.True;
3050
+ })();
3051
+ }
3052
+ function FromPromise2(left, right) {
3053
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True : !exports_type.IsPromise(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.item, right.item));
3054
+ }
3055
+ function RecordKey(schema) {
3056
+ return PatternNumberExact in schema.patternProperties ? Number2() : (PatternStringExact in schema.patternProperties) ? String2() : Throw("Unknown record key pattern");
3057
+ }
3058
+ function RecordValue(schema) {
3059
+ return PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] : (PatternStringExact in schema.patternProperties) ? schema.patternProperties[PatternStringExact] : Throw("Unable to get record value schema");
3060
+ }
3061
+ function FromRecordRight(left, right) {
3062
+ const [Key, Value] = [RecordKey(right), RecordValue(right)];
3063
+ return exports_type.IsLiteralString(left) && exports_type.IsNumber(Key) && IntoBooleanResult(Visit3(left, Value)) === ExtendsResult.True ? ExtendsResult.True : exports_type.IsUint8Array(left) && exports_type.IsNumber(Key) ? Visit3(left, Value) : exports_type.IsString(left) && exports_type.IsNumber(Key) ? Visit3(left, Value) : exports_type.IsArray(left) && exports_type.IsNumber(Key) ? Visit3(left, Value) : exports_type.IsObject(left) ? (() => {
3064
+ for (const key of Object.getOwnPropertyNames(left.properties)) {
3065
+ if (Property(Value, left.properties[key]) === ExtendsResult.False) {
3066
+ return ExtendsResult.False;
3067
+ }
3068
+ }
3069
+ return ExtendsResult.True;
3070
+ })() : ExtendsResult.False;
3071
+ }
3072
+ function FromRecord(left, right) {
3073
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : !exports_type.IsRecord(right) ? ExtendsResult.False : Visit3(RecordValue(left), RecordValue(right));
3074
+ }
3075
+ function FromRegExp(left, right) {
3076
+ const L = exports_type.IsRegExp(left) ? String2() : left;
3077
+ const R = exports_type.IsRegExp(right) ? String2() : right;
3078
+ return Visit3(L, R);
3079
+ }
3080
+ function FromStringRight(left, right) {
3081
+ return exports_type.IsLiteral(left) && exports_value.IsString(left.const) ? ExtendsResult.True : exports_type.IsString(left) ? ExtendsResult.True : ExtendsResult.False;
3082
+ }
3083
+ function FromString(left, right) {
3084
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsRecord(right) ? FromRecordRight(left, right) : exports_type.IsString(right) ? ExtendsResult.True : ExtendsResult.False;
3085
+ }
3086
+ function FromSymbol(left, right) {
3087
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsRecord(right) ? FromRecordRight(left, right) : exports_type.IsSymbol(right) ? ExtendsResult.True : ExtendsResult.False;
3088
+ }
3089
+ function FromTemplateLiteral2(left, right) {
3090
+ return exports_type.IsTemplateLiteral(left) ? Visit3(TemplateLiteralToUnion(left), right) : exports_type.IsTemplateLiteral(right) ? Visit3(left, TemplateLiteralToUnion(right)) : Throw("Invalid fallthrough for TemplateLiteral");
3091
+ }
3092
+ function IsArrayOfTuple(left, right) {
3093
+ return exports_type.IsArray(right) && left.items !== undefined && left.items.every((schema) => Visit3(schema, right.items) === ExtendsResult.True);
3094
+ }
3095
+ function FromTupleRight(left, right) {
3096
+ return exports_type.IsNever(left) ? ExtendsResult.True : exports_type.IsUnknown(left) ? ExtendsResult.False : exports_type.IsAny(left) ? ExtendsResult.Union : ExtendsResult.False;
3097
+ }
3098
+ function FromTuple3(left, right) {
3099
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : exports_type.IsArray(right) && IsArrayOfTuple(left, right) ? ExtendsResult.True : !exports_type.IsTuple(right) ? ExtendsResult.False : exports_value.IsUndefined(left.items) && !exports_value.IsUndefined(right.items) || !exports_value.IsUndefined(left.items) && exports_value.IsUndefined(right.items) ? ExtendsResult.False : exports_value.IsUndefined(left.items) && !exports_value.IsUndefined(right.items) ? ExtendsResult.True : left.items.every((schema, index) => Visit3(schema, right.items[index]) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
3100
+ }
3101
+ function FromUint8Array(left, right) {
3102
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsRecord(right) ? FromRecordRight(left, right) : exports_type.IsUint8Array(right) ? ExtendsResult.True : ExtendsResult.False;
3103
+ }
3104
+ function FromUndefined(left, right) {
3105
+ return IsStructuralRight(right) ? StructuralRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsRecord(right) ? FromRecordRight(left, right) : exports_type.IsVoid(right) ? FromVoidRight(left, right) : exports_type.IsUndefined(right) ? ExtendsResult.True : ExtendsResult.False;
3106
+ }
3107
+ function FromUnionRight(left, right) {
3108
+ return right.anyOf.some((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
3109
+ }
3110
+ function FromUnion6(left, right) {
3111
+ return left.anyOf.every((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
3112
+ }
3113
+ function FromUnknownRight(left, right) {
3114
+ return ExtendsResult.True;
3115
+ }
3116
+ function FromUnknown(left, right) {
3117
+ return exports_type.IsNever(right) ? FromNeverRight(left, right) : exports_type.IsIntersect(right) ? FromIntersectRight(left, right) : exports_type.IsUnion(right) ? FromUnionRight(left, right) : exports_type.IsAny(right) ? FromAnyRight(left, right) : exports_type.IsString(right) ? FromStringRight(left, right) : exports_type.IsNumber(right) ? FromNumberRight(left, right) : exports_type.IsInteger(right) ? FromIntegerRight(left, right) : exports_type.IsBoolean(right) ? FromBooleanRight(left, right) : exports_type.IsArray(right) ? FromArrayRight(left, right) : exports_type.IsTuple(right) ? FromTupleRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsUnknown(right) ? ExtendsResult.True : ExtendsResult.False;
3118
+ }
3119
+ function FromVoidRight(left, right) {
3120
+ return exports_type.IsUndefined(left) ? ExtendsResult.True : exports_type.IsUndefined(left) ? ExtendsResult.True : ExtendsResult.False;
3121
+ }
3122
+ function FromVoid(left, right) {
3123
+ return exports_type.IsIntersect(right) ? FromIntersectRight(left, right) : exports_type.IsUnion(right) ? FromUnionRight(left, right) : exports_type.IsUnknown(right) ? FromUnknownRight(left, right) : exports_type.IsAny(right) ? FromAnyRight(left, right) : exports_type.IsObject(right) ? FromObjectRight(left, right) : exports_type.IsVoid(right) ? ExtendsResult.True : ExtendsResult.False;
3124
+ }
3125
+ function Visit3(left, right) {
3126
+ return exports_type.IsTemplateLiteral(left) || exports_type.IsTemplateLiteral(right) ? FromTemplateLiteral2(left, right) : exports_type.IsRegExp(left) || exports_type.IsRegExp(right) ? FromRegExp(left, right) : exports_type.IsNot(left) || exports_type.IsNot(right) ? FromNot(left, right) : exports_type.IsAny(left) ? FromAny(left, right) : exports_type.IsArray(left) ? FromArray4(left, right) : exports_type.IsBigInt(left) ? FromBigInt(left, right) : exports_type.IsBoolean(left) ? FromBoolean(left, right) : exports_type.IsAsyncIterator(left) ? FromAsyncIterator(left, right) : exports_type.IsConstructor(left) ? FromConstructor(left, right) : exports_type.IsDate(left) ? FromDate(left, right) : exports_type.IsFunction(left) ? FromFunction(left, right) : exports_type.IsInteger(left) ? FromInteger(left, right) : exports_type.IsIntersect(left) ? FromIntersect4(left, right) : exports_type.IsIterator(left) ? FromIterator(left, right) : exports_type.IsLiteral(left) ? FromLiteral2(left, right) : exports_type.IsNever(left) ? FromNever(left, right) : exports_type.IsNull(left) ? FromNull(left, right) : exports_type.IsNumber(left) ? FromNumber(left, right) : exports_type.IsObject(left) ? FromObject(left, right) : exports_type.IsRecord(left) ? FromRecord(left, right) : exports_type.IsString(left) ? FromString(left, right) : exports_type.IsSymbol(left) ? FromSymbol(left, right) : exports_type.IsTuple(left) ? FromTuple3(left, right) : exports_type.IsPromise(left) ? FromPromise2(left, right) : exports_type.IsUint8Array(left) ? FromUint8Array(left, right) : exports_type.IsUndefined(left) ? FromUndefined(left, right) : exports_type.IsUnion(left) ? FromUnion6(left, right) : exports_type.IsUnknown(left) ? FromUnknown(left, right) : exports_type.IsVoid(left) ? FromVoid(left, right) : Throw(`Unknown left type operand '${left[Kind]}'`);
3127
+ }
3128
+ function ExtendsCheck(left, right) {
3129
+ return Visit3(left, right);
3130
+ }
3131
+
3132
+ // node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-result.mjs
3133
+ function FromProperties8(P, Right, True, False, options) {
3134
+ const Acc = {};
3135
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
3136
+ Acc[K2] = Extends(P[K2], Right, True, False, Clone(options));
3137
+ return Acc;
3138
+ }
3139
+ function FromMappedResult6(Left, Right, True, False, options) {
3140
+ return FromProperties8(Left.properties, Right, True, False, options);
3141
+ }
3142
+ function ExtendsFromMappedResult(Left, Right, True, False, options) {
3143
+ const P = FromMappedResult6(Left, Right, True, False, options);
3144
+ return MappedResult(P);
3145
+ }
3146
+
3147
+ // node_modules/@sinclair/typebox/build/esm/type/extends/extends.mjs
3148
+ function ExtendsResolve(left, right, trueType, falseType) {
3149
+ const R = ExtendsCheck(left, right);
3150
+ return R === ExtendsResult.Union ? Union([trueType, falseType]) : R === ExtendsResult.True ? trueType : falseType;
3151
+ }
3152
+ function Extends(L, R, T, F, options) {
3153
+ return IsMappedResult(L) ? ExtendsFromMappedResult(L, R, T, F, options) : IsMappedKey(L) ? CreateType(ExtendsFromMappedKey(L, R, T, F, options)) : CreateType(ExtendsResolve(L, R, T, F), options);
3154
+ }
3155
+
3156
+ // node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-key.mjs
3157
+ function FromPropertyKey(K, U, L, R, options) {
3158
+ return {
3159
+ [K]: Extends(Literal(K), U, L, R, Clone(options))
3160
+ };
3161
+ }
3162
+ function FromPropertyKeys(K, U, L, R, options) {
3163
+ return K.reduce((Acc, LK) => {
3164
+ return { ...Acc, ...FromPropertyKey(LK, U, L, R, options) };
3165
+ }, {});
3166
+ }
3167
+ function FromMappedKey2(K, U, L, R, options) {
3168
+ return FromPropertyKeys(K.keys, U, L, R, options);
3169
+ }
3170
+ function ExtendsFromMappedKey(T, U, L, R, options) {
3171
+ const P = FromMappedKey2(T, U, L, R, options);
3172
+ return MappedResult(P);
3173
+ }
3174
+
3175
+ // node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-template-literal.mjs
3176
+ function ExcludeFromTemplateLiteral(L, R) {
3177
+ return Exclude(TemplateLiteralToUnion(L), R);
3178
+ }
3179
+
3180
+ // node_modules/@sinclair/typebox/build/esm/type/exclude/exclude.mjs
3181
+ function ExcludeRest(L, R) {
3182
+ const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
3183
+ return excluded.length === 1 ? excluded[0] : Union(excluded);
3184
+ }
3185
+ function Exclude(L, R, options = {}) {
3186
+ if (IsTemplateLiteral(L))
3187
+ return CreateType(ExcludeFromTemplateLiteral(L, R), options);
3188
+ if (IsMappedResult(L))
3189
+ return CreateType(ExcludeFromMappedResult(L, R), options);
3190
+ return CreateType(IsUnion(L) ? ExcludeRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
3191
+ }
3192
+
3193
+ // node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-mapped-result.mjs
3194
+ function FromProperties9(P, U) {
3195
+ const Acc = {};
3196
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
3197
+ Acc[K2] = Exclude(P[K2], U);
3198
+ return Acc;
3199
+ }
3200
+ function FromMappedResult7(R, T) {
3201
+ return FromProperties9(R.properties, T);
3202
+ }
3203
+ function ExcludeFromMappedResult(R, T) {
3204
+ const P = FromMappedResult7(R, T);
3205
+ return MappedResult(P);
3206
+ }
3207
+
3208
+ // node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-template-literal.mjs
3209
+ function ExtractFromTemplateLiteral(L, R) {
3210
+ return Extract(TemplateLiteralToUnion(L), R);
3211
+ }
3212
+
3213
+ // node_modules/@sinclair/typebox/build/esm/type/extract/extract.mjs
3214
+ function ExtractRest(L, R) {
3215
+ const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
3216
+ return extracted.length === 1 ? extracted[0] : Union(extracted);
3217
+ }
3218
+ function Extract(L, R, options) {
3219
+ if (IsTemplateLiteral(L))
3220
+ return CreateType(ExtractFromTemplateLiteral(L, R), options);
3221
+ if (IsMappedResult(L))
3222
+ return CreateType(ExtractFromMappedResult(L, R), options);
3223
+ return CreateType(IsUnion(L) ? ExtractRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
3224
+ }
3225
+
3226
+ // node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-mapped-result.mjs
3227
+ function FromProperties10(P, T) {
3228
+ const Acc = {};
3229
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
3230
+ Acc[K2] = Extract(P[K2], T);
3231
+ return Acc;
3232
+ }
3233
+ function FromMappedResult8(R, T) {
3234
+ return FromProperties10(R.properties, T);
3235
+ }
3236
+ function ExtractFromMappedResult(R, T) {
3237
+ const P = FromMappedResult8(R, T);
3238
+ return MappedResult(P);
3239
+ }
3240
+
3241
+ // node_modules/@sinclair/typebox/build/esm/type/instance-type/instance-type.mjs
3242
+ function InstanceType(schema, options) {
3243
+ return IsConstructor(schema) ? CreateType(schema.returns, options) : Never(options);
3244
+ }
3245
+
3246
+ // node_modules/@sinclair/typebox/build/esm/type/readonly-optional/readonly-optional.mjs
3247
+ function ReadonlyOptional(schema) {
3248
+ return Readonly(Optional(schema));
3249
+ }
3250
+
3251
+ // node_modules/@sinclair/typebox/build/esm/type/record/record.mjs
3252
+ function RecordCreateFromPattern(pattern, T, options) {
3253
+ return CreateType({ [Kind]: "Record", type: "object", patternProperties: { [pattern]: T } }, options);
3254
+ }
3255
+ function RecordCreateFromKeys(K, T, options) {
3256
+ const result = {};
3257
+ for (const K2 of K)
3258
+ result[K2] = T;
3259
+ return Object2(result, { ...options, [Hint]: "Record" });
3260
+ }
3261
+ function FromTemplateLiteralKey(K, T, options) {
3262
+ return IsTemplateLiteralFinite(K) ? RecordCreateFromKeys(IndexPropertyKeys(K), T, options) : RecordCreateFromPattern(K.pattern, T, options);
3263
+ }
3264
+ function FromUnionKey(key, type, options) {
3265
+ return RecordCreateFromKeys(IndexPropertyKeys(Union(key)), type, options);
3266
+ }
3267
+ function FromLiteralKey(key, type, options) {
3268
+ return RecordCreateFromKeys([key.toString()], type, options);
3269
+ }
3270
+ function FromRegExpKey(key, type, options) {
3271
+ return RecordCreateFromPattern(key.source, type, options);
3272
+ }
3273
+ function FromStringKey(key, type, options) {
3274
+ const pattern = IsUndefined(key.pattern) ? PatternStringExact : key.pattern;
3275
+ return RecordCreateFromPattern(pattern, type, options);
3276
+ }
3277
+ function FromAnyKey(_, type, options) {
3278
+ return RecordCreateFromPattern(PatternStringExact, type, options);
3279
+ }
3280
+ function FromNeverKey(_key, type, options) {
3281
+ return RecordCreateFromPattern(PatternNeverExact, type, options);
3282
+ }
3283
+ function FromBooleanKey(_key, type, options) {
3284
+ return Object2({ true: type, false: type }, options);
3285
+ }
3286
+ function FromIntegerKey(_key, type, options) {
3287
+ return RecordCreateFromPattern(PatternNumberExact, type, options);
3288
+ }
3289
+ function FromNumberKey(_, type, options) {
3290
+ return RecordCreateFromPattern(PatternNumberExact, type, options);
3291
+ }
3292
+ function Record(key, type, options = {}) {
3293
+ return IsUnion(key) ? FromUnionKey(key.anyOf, type, options) : IsTemplateLiteral(key) ? FromTemplateLiteralKey(key, type, options) : IsLiteral(key) ? FromLiteralKey(key.const, type, options) : IsBoolean2(key) ? FromBooleanKey(key, type, options) : IsInteger(key) ? FromIntegerKey(key, type, options) : IsNumber3(key) ? FromNumberKey(key, type, options) : IsRegExp2(key) ? FromRegExpKey(key, type, options) : IsString2(key) ? FromStringKey(key, type, options) : IsAny(key) ? FromAnyKey(key, type, options) : IsNever(key) ? FromNeverKey(key, type, options) : Never(options);
3294
+ }
3295
+ function RecordPattern(record) {
3296
+ return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
3297
+ }
3298
+ function RecordKey2(type) {
3299
+ const pattern = RecordPattern(type);
3300
+ return pattern === PatternStringExact ? String2() : pattern === PatternNumberExact ? Number2() : String2({ pattern });
3301
+ }
3302
+ function RecordValue2(type) {
3303
+ return type.patternProperties[RecordPattern(type)];
3304
+ }
3305
+
3306
+ // node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs
3307
+ function FromConstructor2(args, type) {
3308
+ type.parameters = FromTypes(args, type.parameters);
3309
+ type.returns = FromType(args, type.returns);
3310
+ return type;
3311
+ }
3312
+ function FromFunction2(args, type) {
3313
+ type.parameters = FromTypes(args, type.parameters);
3314
+ type.returns = FromType(args, type.returns);
3315
+ return type;
3316
+ }
3317
+ function FromIntersect5(args, type) {
3318
+ type.allOf = FromTypes(args, type.allOf);
3319
+ return type;
3320
+ }
3321
+ function FromUnion7(args, type) {
3322
+ type.anyOf = FromTypes(args, type.anyOf);
3323
+ return type;
3324
+ }
3325
+ function FromTuple4(args, type) {
3326
+ if (IsUndefined(type.items))
3327
+ return type;
3328
+ type.items = FromTypes(args, type.items);
3329
+ return type;
3330
+ }
3331
+ function FromArray5(args, type) {
3332
+ type.items = FromType(args, type.items);
3333
+ return type;
3334
+ }
3335
+ function FromAsyncIterator2(args, type) {
3336
+ type.items = FromType(args, type.items);
3337
+ return type;
3338
+ }
3339
+ function FromIterator2(args, type) {
3340
+ type.items = FromType(args, type.items);
3341
+ return type;
3342
+ }
3343
+ function FromPromise3(args, type) {
3344
+ type.item = FromType(args, type.item);
3345
+ return type;
3346
+ }
3347
+ function FromObject2(args, type) {
3348
+ const mappedProperties = FromProperties11(args, type.properties);
3349
+ return { ...type, ...Object2(mappedProperties) };
3350
+ }
3351
+ function FromRecord2(args, type) {
3352
+ const mappedKey = FromType(args, RecordKey2(type));
3353
+ const mappedValue = FromType(args, RecordValue2(type));
3354
+ const result = Record(mappedKey, mappedValue);
3355
+ return { ...type, ...result };
3356
+ }
3357
+ function FromArgument(args, argument) {
3358
+ return argument.index in args ? args[argument.index] : Unknown();
3359
+ }
3360
+ function FromProperty2(args, type) {
3361
+ const isReadonly = IsReadonly(type);
3362
+ const isOptional = IsOptional(type);
3363
+ const mapped = FromType(args, type);
3364
+ return isReadonly && isOptional ? ReadonlyOptional(mapped) : isReadonly && !isOptional ? Readonly(mapped) : !isReadonly && isOptional ? Optional(mapped) : mapped;
3365
+ }
3366
+ function FromProperties11(args, properties) {
3367
+ return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
3368
+ return { ...result, [key]: FromProperty2(args, properties[key]) };
3369
+ }, {});
3370
+ }
3371
+ function FromTypes(args, types) {
3372
+ return types.map((type) => FromType(args, type));
3373
+ }
3374
+ function FromType(args, type) {
3375
+ return IsConstructor(type) ? FromConstructor2(args, type) : IsFunction2(type) ? FromFunction2(args, type) : IsIntersect(type) ? FromIntersect5(args, type) : IsUnion(type) ? FromUnion7(args, type) : IsTuple(type) ? FromTuple4(args, type) : IsArray3(type) ? FromArray5(args, type) : IsAsyncIterator2(type) ? FromAsyncIterator2(args, type) : IsIterator2(type) ? FromIterator2(args, type) : IsPromise(type) ? FromPromise3(args, type) : IsObject3(type) ? FromObject2(args, type) : IsRecord(type) ? FromRecord2(args, type) : IsArgument(type) ? FromArgument(args, type) : type;
3376
+ }
3377
+ function Instantiate(type, args) {
3378
+ return FromType(args, CloneType(type));
3379
+ }
3380
+
3381
+ // node_modules/@sinclair/typebox/build/esm/type/integer/integer.mjs
3382
+ function Integer(options) {
3383
+ return CreateType({ [Kind]: "Integer", type: "integer" }, options);
3384
+ }
3385
+
3386
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs
3387
+ function MappedIntrinsicPropertyKey(K, M, options) {
3388
+ return {
3389
+ [K]: Intrinsic(Literal(K), M, Clone(options))
3390
+ };
3391
+ }
3392
+ function MappedIntrinsicPropertyKeys(K, M, options) {
3393
+ const result = K.reduce((Acc, L) => {
3394
+ return { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) };
3395
+ }, {});
3396
+ return result;
3397
+ }
3398
+ function MappedIntrinsicProperties(T, M, options) {
3399
+ return MappedIntrinsicPropertyKeys(T["keys"], M, options);
3400
+ }
3401
+ function IntrinsicFromMappedKey(T, M, options) {
3402
+ const P = MappedIntrinsicProperties(T, M, options);
3403
+ return MappedResult(P);
3404
+ }
3405
+
3406
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic.mjs
3407
+ function ApplyUncapitalize(value) {
3408
+ const [first, rest] = [value.slice(0, 1), value.slice(1)];
3409
+ return [first.toLowerCase(), rest].join("");
3410
+ }
3411
+ function ApplyCapitalize(value) {
3412
+ const [first, rest] = [value.slice(0, 1), value.slice(1)];
3413
+ return [first.toUpperCase(), rest].join("");
3414
+ }
3415
+ function ApplyUppercase(value) {
3416
+ return value.toUpperCase();
3417
+ }
3418
+ function ApplyLowercase(value) {
3419
+ return value.toLowerCase();
3420
+ }
3421
+ function FromTemplateLiteral3(schema, mode, options) {
3422
+ const expression = TemplateLiteralParseExact(schema.pattern);
3423
+ const finite = IsTemplateLiteralExpressionFinite(expression);
3424
+ if (!finite)
3425
+ return { ...schema, pattern: FromLiteralValue(schema.pattern, mode) };
3426
+ const strings = [...TemplateLiteralExpressionGenerate(expression)];
3427
+ const literals = strings.map((value) => Literal(value));
3428
+ const mapped = FromRest5(literals, mode);
3429
+ const union = Union(mapped);
3430
+ return TemplateLiteral([union], options);
3431
+ }
3432
+ function FromLiteralValue(value, mode) {
3433
+ return typeof value === "string" ? mode === "Uncapitalize" ? ApplyUncapitalize(value) : mode === "Capitalize" ? ApplyCapitalize(value) : mode === "Uppercase" ? ApplyUppercase(value) : mode === "Lowercase" ? ApplyLowercase(value) : value : value.toString();
3434
+ }
3435
+ function FromRest5(T, M) {
3436
+ return T.map((L) => Intrinsic(L, M));
3437
+ }
3438
+ function Intrinsic(schema, mode, options = {}) {
3439
+ return IsMappedKey(schema) ? IntrinsicFromMappedKey(schema, mode, options) : IsTemplateLiteral(schema) ? FromTemplateLiteral3(schema, mode, options) : IsUnion(schema) ? Union(FromRest5(schema.anyOf, mode), options) : IsLiteral(schema) ? Literal(FromLiteralValue(schema.const, mode), options) : CreateType(schema, options);
3440
+ }
3441
+
3442
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/capitalize.mjs
3443
+ function Capitalize(T, options = {}) {
3444
+ return Intrinsic(T, "Capitalize", options);
3445
+ }
3446
+
3447
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/lowercase.mjs
3448
+ function Lowercase(T, options = {}) {
3449
+ return Intrinsic(T, "Lowercase", options);
3450
+ }
3451
+
3452
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/uncapitalize.mjs
3453
+ function Uncapitalize(T, options = {}) {
3454
+ return Intrinsic(T, "Uncapitalize", options);
3455
+ }
3456
+
3457
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/uppercase.mjs
3458
+ function Uppercase(T, options = {}) {
3459
+ return Intrinsic(T, "Uppercase", options);
3460
+ }
3461
+
3462
+ // node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-result.mjs
3463
+ function FromProperties12(properties, propertyKeys, options) {
3464
+ const result = {};
3465
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
3466
+ result[K2] = Omit(properties[K2], propertyKeys, Clone(options));
3467
+ return result;
3468
+ }
3469
+ function FromMappedResult9(mappedResult, propertyKeys, options) {
3470
+ return FromProperties12(mappedResult.properties, propertyKeys, options);
3471
+ }
3472
+ function OmitFromMappedResult(mappedResult, propertyKeys, options) {
3473
+ const properties = FromMappedResult9(mappedResult, propertyKeys, options);
3474
+ return MappedResult(properties);
3475
+ }
3476
+
3477
+ // node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs
3478
+ function FromIntersect6(types, propertyKeys) {
3479
+ return types.map((type) => OmitResolve(type, propertyKeys));
3480
+ }
3481
+ function FromUnion8(types, propertyKeys) {
3482
+ return types.map((type) => OmitResolve(type, propertyKeys));
3483
+ }
3484
+ function FromProperty3(properties, key) {
3485
+ const { [key]: _, ...R } = properties;
3486
+ return R;
3487
+ }
3488
+ function FromProperties13(properties, propertyKeys) {
3489
+ return propertyKeys.reduce((T, K2) => FromProperty3(T, K2), properties);
3490
+ }
3491
+ function FromObject3(type, propertyKeys, properties) {
3492
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
3493
+ const mappedProperties = FromProperties13(properties, propertyKeys);
3494
+ return Object2(mappedProperties, options);
3495
+ }
3496
+ function UnionFromPropertyKeys(propertyKeys) {
3497
+ const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
3498
+ return Union(result);
3499
+ }
3500
+ function OmitResolve(type, propertyKeys) {
3501
+ return IsIntersect(type) ? Intersect(FromIntersect6(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion8(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject3(type, propertyKeys, type.properties) : Object2({});
3502
+ }
3503
+ function Omit(type, key, options) {
3504
+ const typeKey = IsArray(key) ? UnionFromPropertyKeys(key) : key;
3505
+ const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
3506
+ const isTypeRef = IsRef(type);
3507
+ const isKeyRef = IsRef(key);
3508
+ return IsMappedResult(type) ? OmitFromMappedResult(type, propertyKeys, options) : IsMappedKey(key) ? OmitFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Omit", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Omit", [type, typeKey], options) : CreateType({ ...OmitResolve(type, propertyKeys), ...options });
3509
+ }
3510
+
3511
+ // node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-key.mjs
3512
+ function FromPropertyKey2(type, key, options) {
3513
+ return { [key]: Omit(type, [key], Clone(options)) };
3514
+ }
3515
+ function FromPropertyKeys2(type, propertyKeys, options) {
3516
+ return propertyKeys.reduce((Acc, LK) => {
3517
+ return { ...Acc, ...FromPropertyKey2(type, LK, options) };
3518
+ }, {});
3519
+ }
3520
+ function FromMappedKey3(type, mappedKey, options) {
3521
+ return FromPropertyKeys2(type, mappedKey.keys, options);
3522
+ }
3523
+ function OmitFromMappedKey(type, mappedKey, options) {
3524
+ const properties = FromMappedKey3(type, mappedKey, options);
3525
+ return MappedResult(properties);
3526
+ }
3527
+
3528
+ // node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-result.mjs
3529
+ function FromProperties14(properties, propertyKeys, options) {
3530
+ const result = {};
3531
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
3532
+ result[K2] = Pick(properties[K2], propertyKeys, Clone(options));
3533
+ return result;
3534
+ }
3535
+ function FromMappedResult10(mappedResult, propertyKeys, options) {
3536
+ return FromProperties14(mappedResult.properties, propertyKeys, options);
3537
+ }
3538
+ function PickFromMappedResult(mappedResult, propertyKeys, options) {
3539
+ const properties = FromMappedResult10(mappedResult, propertyKeys, options);
3540
+ return MappedResult(properties);
3541
+ }
3542
+
3543
+ // node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs
3544
+ function FromIntersect7(types, propertyKeys) {
3545
+ return types.map((type) => PickResolve(type, propertyKeys));
3546
+ }
3547
+ function FromUnion9(types, propertyKeys) {
3548
+ return types.map((type) => PickResolve(type, propertyKeys));
3549
+ }
3550
+ function FromProperties15(properties, propertyKeys) {
3551
+ const result = {};
3552
+ for (const K2 of propertyKeys)
3553
+ if (K2 in properties)
3554
+ result[K2] = properties[K2];
3555
+ return result;
3556
+ }
3557
+ function FromObject4(Type, keys, properties) {
3558
+ const options = Discard(Type, [TransformKind, "$id", "required", "properties"]);
3559
+ const mappedProperties = FromProperties15(properties, keys);
3560
+ return Object2(mappedProperties, options);
3561
+ }
3562
+ function UnionFromPropertyKeys2(propertyKeys) {
3563
+ const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
3564
+ return Union(result);
3565
+ }
3566
+ function PickResolve(type, propertyKeys) {
3567
+ return IsIntersect(type) ? Intersect(FromIntersect7(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion9(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject4(type, propertyKeys, type.properties) : Object2({});
3568
+ }
3569
+ function Pick(type, key, options) {
3570
+ const typeKey = IsArray(key) ? UnionFromPropertyKeys2(key) : key;
3571
+ const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
3572
+ const isTypeRef = IsRef(type);
3573
+ const isKeyRef = IsRef(key);
3574
+ return IsMappedResult(type) ? PickFromMappedResult(type, propertyKeys, options) : IsMappedKey(key) ? PickFromMappedKey(type, key, options) : isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : !isTypeRef && isKeyRef ? Computed("Pick", [type, typeKey], options) : isTypeRef && !isKeyRef ? Computed("Pick", [type, typeKey], options) : CreateType({ ...PickResolve(type, propertyKeys), ...options });
3575
+ }
3576
+
3577
+ // node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-key.mjs
3578
+ function FromPropertyKey3(type, key, options) {
3579
+ return {
3580
+ [key]: Pick(type, [key], Clone(options))
3581
+ };
3582
+ }
3583
+ function FromPropertyKeys3(type, propertyKeys, options) {
3584
+ return propertyKeys.reduce((result, leftKey) => {
3585
+ return { ...result, ...FromPropertyKey3(type, leftKey, options) };
3586
+ }, {});
3587
+ }
3588
+ function FromMappedKey4(type, mappedKey, options) {
3589
+ return FromPropertyKeys3(type, mappedKey.keys, options);
3590
+ }
3591
+ function PickFromMappedKey(type, mappedKey, options) {
3592
+ const properties = FromMappedKey4(type, mappedKey, options);
3593
+ return MappedResult(properties);
3594
+ }
3595
+
3596
+ // node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs
3597
+ function FromComputed3(target, parameters) {
3598
+ return Computed("Partial", [Computed(target, parameters)]);
3599
+ }
3600
+ function FromRef3($ref) {
3601
+ return Computed("Partial", [Ref($ref)]);
3602
+ }
3603
+ function FromProperties16(properties) {
3604
+ const partialProperties = {};
3605
+ for (const K of globalThis.Object.getOwnPropertyNames(properties))
3606
+ partialProperties[K] = Optional(properties[K]);
3607
+ return partialProperties;
3608
+ }
3609
+ function FromObject5(type, properties) {
3610
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
3611
+ const mappedProperties = FromProperties16(properties);
3612
+ return Object2(mappedProperties, options);
3613
+ }
3614
+ function FromRest6(types) {
3615
+ return types.map((type) => PartialResolve(type));
3616
+ }
3617
+ function PartialResolve(type) {
3618
+ return IsComputed(type) ? FromComputed3(type.target, type.parameters) : IsRef(type) ? FromRef3(type.$ref) : IsIntersect(type) ? Intersect(FromRest6(type.allOf)) : IsUnion(type) ? Union(FromRest6(type.anyOf)) : IsObject3(type) ? FromObject5(type, type.properties) : IsBigInt2(type) ? type : IsBoolean2(type) ? type : IsInteger(type) ? type : IsLiteral(type) ? type : IsNull2(type) ? type : IsNumber3(type) ? type : IsString2(type) ? type : IsSymbol2(type) ? type : IsUndefined3(type) ? type : Object2({});
3619
+ }
3620
+ function Partial(type, options) {
3621
+ if (IsMappedResult(type)) {
3622
+ return PartialFromMappedResult(type, options);
3623
+ } else {
3624
+ return CreateType({ ...PartialResolve(type), ...options });
3625
+ }
3626
+ }
3627
+
3628
+ // node_modules/@sinclair/typebox/build/esm/type/partial/partial-from-mapped-result.mjs
3629
+ function FromProperties17(K, options) {
3630
+ const Acc = {};
3631
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K))
3632
+ Acc[K2] = Partial(K[K2], Clone(options));
3633
+ return Acc;
3634
+ }
3635
+ function FromMappedResult11(R, options) {
3636
+ return FromProperties17(R.properties, options);
3637
+ }
3638
+ function PartialFromMappedResult(R, options) {
3639
+ const P = FromMappedResult11(R, options);
3640
+ return MappedResult(P);
3641
+ }
3642
+
3643
+ // node_modules/@sinclair/typebox/build/esm/type/required/required.mjs
3644
+ function FromComputed4(target, parameters) {
3645
+ return Computed("Required", [Computed(target, parameters)]);
3646
+ }
3647
+ function FromRef4($ref) {
3648
+ return Computed("Required", [Ref($ref)]);
3649
+ }
3650
+ function FromProperties18(properties) {
3651
+ const requiredProperties = {};
3652
+ for (const K of globalThis.Object.getOwnPropertyNames(properties))
3653
+ requiredProperties[K] = Discard(properties[K], [OptionalKind]);
3654
+ return requiredProperties;
3655
+ }
3656
+ function FromObject6(type, properties) {
3657
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
3658
+ const mappedProperties = FromProperties18(properties);
3659
+ return Object2(mappedProperties, options);
3660
+ }
3661
+ function FromRest7(types) {
3662
+ return types.map((type) => RequiredResolve(type));
3663
+ }
3664
+ function RequiredResolve(type) {
3665
+ return IsComputed(type) ? FromComputed4(type.target, type.parameters) : IsRef(type) ? FromRef4(type.$ref) : IsIntersect(type) ? Intersect(FromRest7(type.allOf)) : IsUnion(type) ? Union(FromRest7(type.anyOf)) : IsObject3(type) ? FromObject6(type, type.properties) : IsBigInt2(type) ? type : IsBoolean2(type) ? type : IsInteger(type) ? type : IsLiteral(type) ? type : IsNull2(type) ? type : IsNumber3(type) ? type : IsString2(type) ? type : IsSymbol2(type) ? type : IsUndefined3(type) ? type : Object2({});
3666
+ }
3667
+ function Required(type, options) {
3668
+ if (IsMappedResult(type)) {
3669
+ return RequiredFromMappedResult(type, options);
3670
+ } else {
3671
+ return CreateType({ ...RequiredResolve(type), ...options });
3672
+ }
3673
+ }
3674
+
3675
+ // node_modules/@sinclair/typebox/build/esm/type/required/required-from-mapped-result.mjs
3676
+ function FromProperties19(P, options) {
3677
+ const Acc = {};
3678
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
3679
+ Acc[K2] = Required(P[K2], options);
3680
+ return Acc;
3681
+ }
3682
+ function FromMappedResult12(R, options) {
3683
+ return FromProperties19(R.properties, options);
3684
+ }
3685
+ function RequiredFromMappedResult(R, options) {
3686
+ const P = FromMappedResult12(R, options);
3687
+ return MappedResult(P);
3688
+ }
3689
+
3690
+ // node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs
3691
+ function DereferenceParameters(moduleProperties, types) {
3692
+ return types.map((type) => {
3693
+ return IsRef(type) ? Dereference(moduleProperties, type.$ref) : FromType2(moduleProperties, type);
3694
+ });
3695
+ }
3696
+ function Dereference(moduleProperties, ref) {
3697
+ return ref in moduleProperties ? IsRef(moduleProperties[ref]) ? Dereference(moduleProperties, moduleProperties[ref].$ref) : FromType2(moduleProperties, moduleProperties[ref]) : Never();
3698
+ }
3699
+ function FromAwaited(parameters) {
3700
+ return Awaited(parameters[0]);
3701
+ }
3702
+ function FromIndex(parameters) {
3703
+ return Index(parameters[0], parameters[1]);
3704
+ }
3705
+ function FromKeyOf(parameters) {
3706
+ return KeyOf(parameters[0]);
3707
+ }
3708
+ function FromPartial(parameters) {
3709
+ return Partial(parameters[0]);
3710
+ }
3711
+ function FromOmit(parameters) {
3712
+ return Omit(parameters[0], parameters[1]);
3713
+ }
3714
+ function FromPick(parameters) {
3715
+ return Pick(parameters[0], parameters[1]);
3716
+ }
3717
+ function FromRequired(parameters) {
3718
+ return Required(parameters[0]);
3719
+ }
3720
+ function FromComputed5(moduleProperties, target, parameters) {
3721
+ const dereferenced = DereferenceParameters(moduleProperties, parameters);
3722
+ return target === "Awaited" ? FromAwaited(dereferenced) : target === "Index" ? FromIndex(dereferenced) : target === "KeyOf" ? FromKeyOf(dereferenced) : target === "Partial" ? FromPartial(dereferenced) : target === "Omit" ? FromOmit(dereferenced) : target === "Pick" ? FromPick(dereferenced) : target === "Required" ? FromRequired(dereferenced) : Never();
3723
+ }
3724
+ function FromArray6(moduleProperties, type) {
3725
+ return Array2(FromType2(moduleProperties, type));
3726
+ }
3727
+ function FromAsyncIterator3(moduleProperties, type) {
3728
+ return AsyncIterator(FromType2(moduleProperties, type));
3729
+ }
3730
+ function FromConstructor3(moduleProperties, parameters, instanceType) {
3731
+ return Constructor(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, instanceType));
3732
+ }
3733
+ function FromFunction3(moduleProperties, parameters, returnType) {
3734
+ return Function(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, returnType));
3735
+ }
3736
+ function FromIntersect8(moduleProperties, types) {
3737
+ return Intersect(FromTypes2(moduleProperties, types));
3738
+ }
3739
+ function FromIterator3(moduleProperties, type) {
3740
+ return Iterator(FromType2(moduleProperties, type));
3741
+ }
3742
+ function FromObject7(moduleProperties, properties) {
3743
+ return Object2(globalThis.Object.keys(properties).reduce((result, key) => {
3744
+ return { ...result, [key]: FromType2(moduleProperties, properties[key]) };
3745
+ }, {}));
3746
+ }
3747
+ function FromRecord3(moduleProperties, type) {
3748
+ const [value, pattern] = [FromType2(moduleProperties, RecordValue2(type)), RecordPattern(type)];
3749
+ const result = CloneType(type);
3750
+ result.patternProperties[pattern] = value;
3751
+ return result;
3752
+ }
3753
+ function FromTransform(moduleProperties, transform) {
3754
+ return IsRef(transform) ? { ...Dereference(moduleProperties, transform.$ref), [TransformKind]: transform[TransformKind] } : transform;
3755
+ }
3756
+ function FromTuple5(moduleProperties, types) {
3757
+ return Tuple(FromTypes2(moduleProperties, types));
3758
+ }
3759
+ function FromUnion10(moduleProperties, types) {
3760
+ return Union(FromTypes2(moduleProperties, types));
3761
+ }
3762
+ function FromTypes2(moduleProperties, types) {
3763
+ return types.map((type) => FromType2(moduleProperties, type));
3764
+ }
3765
+ function FromType2(moduleProperties, type) {
3766
+ return IsOptional(type) ? CreateType(FromType2(moduleProperties, Discard(type, [OptionalKind])), type) : IsReadonly(type) ? CreateType(FromType2(moduleProperties, Discard(type, [ReadonlyKind])), type) : IsTransform(type) ? CreateType(FromTransform(moduleProperties, type), type) : IsArray3(type) ? CreateType(FromArray6(moduleProperties, type.items), type) : IsAsyncIterator2(type) ? CreateType(FromAsyncIterator3(moduleProperties, type.items), type) : IsComputed(type) ? CreateType(FromComputed5(moduleProperties, type.target, type.parameters)) : IsConstructor(type) ? CreateType(FromConstructor3(moduleProperties, type.parameters, type.returns), type) : IsFunction2(type) ? CreateType(FromFunction3(moduleProperties, type.parameters, type.returns), type) : IsIntersect(type) ? CreateType(FromIntersect8(moduleProperties, type.allOf), type) : IsIterator2(type) ? CreateType(FromIterator3(moduleProperties, type.items), type) : IsObject3(type) ? CreateType(FromObject7(moduleProperties, type.properties), type) : IsRecord(type) ? CreateType(FromRecord3(moduleProperties, type)) : IsTuple(type) ? CreateType(FromTuple5(moduleProperties, type.items || []), type) : IsUnion(type) ? CreateType(FromUnion10(moduleProperties, type.anyOf), type) : type;
3767
+ }
3768
+ function ComputeType(moduleProperties, key) {
3769
+ return key in moduleProperties ? FromType2(moduleProperties, moduleProperties[key]) : Never();
3770
+ }
3771
+ function ComputeModuleProperties(moduleProperties) {
3772
+ return globalThis.Object.getOwnPropertyNames(moduleProperties).reduce((result, key) => {
3773
+ return { ...result, [key]: ComputeType(moduleProperties, key) };
3774
+ }, {});
3775
+ }
3776
+
3777
+ // node_modules/@sinclair/typebox/build/esm/type/module/module.mjs
3778
+ class TModule {
3779
+ constructor($defs) {
3780
+ const computed = ComputeModuleProperties($defs);
3781
+ const identified = this.WithIdentifiers(computed);
3782
+ this.$defs = identified;
3783
+ }
3784
+ Import(key, options) {
3785
+ const $defs = { ...this.$defs, [key]: CreateType(this.$defs[key], options) };
3786
+ return CreateType({ [Kind]: "Import", $defs, $ref: key });
3787
+ }
3788
+ WithIdentifiers($defs) {
3789
+ return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
3790
+ return { ...result, [key]: { ...$defs[key], $id: key } };
3791
+ }, {});
3792
+ }
3793
+ }
3794
+ function Module(properties) {
3795
+ return new TModule(properties);
3796
+ }
3797
+
3798
+ // node_modules/@sinclair/typebox/build/esm/type/not/not.mjs
3799
+ function Not(type, options) {
3800
+ return CreateType({ [Kind]: "Not", not: type }, options);
3801
+ }
3802
+
3803
+ // node_modules/@sinclair/typebox/build/esm/type/parameters/parameters.mjs
3804
+ function Parameters(schema, options) {
3805
+ return IsFunction2(schema) ? Tuple(schema.parameters, options) : Never();
3806
+ }
3807
+
3808
+ // node_modules/@sinclair/typebox/build/esm/type/recursive/recursive.mjs
3809
+ var Ordinal = 0;
3810
+ function Recursive(callback, options = {}) {
3811
+ if (IsUndefined(options.$id))
3812
+ options.$id = `T${Ordinal++}`;
3813
+ const thisType = CloneType(callback({ [Kind]: "This", $ref: `${options.$id}` }));
3814
+ thisType.$id = options.$id;
3815
+ return CreateType({ [Hint]: "Recursive", ...thisType }, options);
3816
+ }
3817
+
3818
+ // node_modules/@sinclair/typebox/build/esm/type/regexp/regexp.mjs
3819
+ function RegExp2(unresolved, options) {
3820
+ const expr = IsString(unresolved) ? new globalThis.RegExp(unresolved) : unresolved;
3821
+ return CreateType({ [Kind]: "RegExp", type: "RegExp", source: expr.source, flags: expr.flags }, options);
3822
+ }
3823
+
3824
+ // node_modules/@sinclair/typebox/build/esm/type/rest/rest.mjs
3825
+ function RestResolve(T) {
3826
+ return IsIntersect(T) ? T.allOf : IsUnion(T) ? T.anyOf : IsTuple(T) ? T.items ?? [] : [];
3827
+ }
3828
+ function Rest(T) {
3829
+ return RestResolve(T);
3830
+ }
3831
+
3832
+ // node_modules/@sinclair/typebox/build/esm/type/return-type/return-type.mjs
3833
+ function ReturnType(schema, options) {
3834
+ return IsFunction2(schema) ? CreateType(schema.returns, options) : Never(options);
3835
+ }
3836
+
3837
+ // node_modules/@sinclair/typebox/build/esm/type/transform/transform.mjs
3838
+ class TransformDecodeBuilder {
3839
+ constructor(schema) {
3840
+ this.schema = schema;
3841
+ }
3842
+ Decode(decode) {
3843
+ return new TransformEncodeBuilder(this.schema, decode);
3844
+ }
3845
+ }
3846
+
3847
+ class TransformEncodeBuilder {
3848
+ constructor(schema, decode) {
3849
+ this.schema = schema;
3850
+ this.decode = decode;
3851
+ }
3852
+ EncodeTransform(encode, schema) {
3853
+ const Encode = (value) => schema[TransformKind].Encode(encode(value));
3854
+ const Decode = (value) => this.decode(schema[TransformKind].Decode(value));
3855
+ const Codec = { Encode, Decode };
3856
+ return { ...schema, [TransformKind]: Codec };
3857
+ }
3858
+ EncodeSchema(encode, schema) {
3859
+ const Codec = { Decode: this.decode, Encode: encode };
3860
+ return { ...schema, [TransformKind]: Codec };
3861
+ }
3862
+ Encode(encode) {
3863
+ return IsTransform(this.schema) ? this.EncodeTransform(encode, this.schema) : this.EncodeSchema(encode, this.schema);
3864
+ }
3865
+ }
3866
+ function Transform(schema) {
3867
+ return new TransformDecodeBuilder(schema);
3868
+ }
3869
+
3870
+ // node_modules/@sinclair/typebox/build/esm/type/unsafe/unsafe.mjs
3871
+ function Unsafe(options = {}) {
3872
+ return CreateType({ [Kind]: options[Kind] ?? "Unsafe" }, options);
3873
+ }
3874
+
3875
+ // node_modules/@sinclair/typebox/build/esm/type/void/void.mjs
3876
+ function Void(options) {
3877
+ return CreateType({ [Kind]: "Void", type: "void" }, options);
3878
+ }
3879
+
3880
+ // node_modules/@sinclair/typebox/build/esm/type/type/type.mjs
3881
+ var exports_type2 = {};
3882
+ __export(exports_type2, {
3883
+ Void: () => Void,
3884
+ Uppercase: () => Uppercase,
3885
+ Unsafe: () => Unsafe,
3886
+ Unknown: () => Unknown,
3887
+ Union: () => Union,
3888
+ Undefined: () => Undefined,
3889
+ Uncapitalize: () => Uncapitalize,
3890
+ Uint8Array: () => Uint8Array2,
3891
+ Tuple: () => Tuple,
3892
+ Transform: () => Transform,
3893
+ TemplateLiteral: () => TemplateLiteral,
3894
+ Symbol: () => Symbol2,
3895
+ String: () => String2,
3896
+ ReturnType: () => ReturnType,
3897
+ Rest: () => Rest,
3898
+ Required: () => Required,
3899
+ RegExp: () => RegExp2,
3900
+ Ref: () => Ref,
3901
+ Recursive: () => Recursive,
3902
+ Record: () => Record,
3903
+ ReadonlyOptional: () => ReadonlyOptional,
3904
+ Readonly: () => Readonly,
3905
+ Promise: () => Promise2,
3906
+ Pick: () => Pick,
3907
+ Partial: () => Partial,
3908
+ Parameters: () => Parameters,
3909
+ Optional: () => Optional,
3910
+ Omit: () => Omit,
3911
+ Object: () => Object2,
3912
+ Number: () => Number2,
3913
+ Null: () => Null,
3914
+ Not: () => Not,
3915
+ Never: () => Never,
3916
+ Module: () => Module,
3917
+ Mapped: () => Mapped,
3918
+ Lowercase: () => Lowercase,
3919
+ Literal: () => Literal,
3920
+ KeyOf: () => KeyOf,
3921
+ Iterator: () => Iterator,
3922
+ Intersect: () => Intersect,
3923
+ Integer: () => Integer,
3924
+ Instantiate: () => Instantiate,
3925
+ InstanceType: () => InstanceType,
3926
+ Index: () => Index,
3927
+ Function: () => Function,
3928
+ Extract: () => Extract,
3929
+ Extends: () => Extends,
3930
+ Exclude: () => Exclude,
3931
+ Enum: () => Enum,
3932
+ Date: () => Date2,
3933
+ ConstructorParameters: () => ConstructorParameters,
3934
+ Constructor: () => Constructor,
3935
+ Const: () => Const,
3936
+ Composite: () => Composite,
3937
+ Capitalize: () => Capitalize,
3938
+ Boolean: () => Boolean,
3939
+ BigInt: () => BigInt,
3940
+ Awaited: () => Awaited,
3941
+ AsyncIterator: () => AsyncIterator,
3942
+ Array: () => Array2,
3943
+ Argument: () => Argument,
3944
+ Any: () => Any
3945
+ });
3946
+
3947
+ // node_modules/@sinclair/typebox/build/esm/type/type/index.mjs
3948
+ var Type = exports_type2;
3949
+
3950
+ // src/pi/pi-tools.ts
3951
+ function createPiTools(bridge) {
3952
+ return [
3953
+ tool("mason_list", "mason list", "List Mason packages", listSchema(), async (input, options) => {
3954
+ const args = validateObject(input);
3955
+ const argv = ["list"];
3956
+ if (args.installed === true)
3957
+ argv.push("--installed");
3958
+ if (args.outdated === true)
3959
+ argv.push("--outdated");
3960
+ return result(await bridge.run(argv, options));
3961
+ }),
3962
+ tool("mason_search", "mason search", "Search Mason Registry packages", searchSchema(), async (input, options) => {
3963
+ const args = validateObject(input);
3964
+ const argv = ["search"];
3965
+ if (typeof args.query === "string" && args.query.length > 0)
3966
+ argv.push(args.query);
3967
+ if (typeof args.category === "string" && args.category.length > 0)
3968
+ argv.push("--category", args.category);
3969
+ if (typeof args.language === "string" && args.language.length > 0)
3970
+ argv.push("--language", args.language);
3971
+ return result(await bridge.run(argv, options));
3972
+ }),
3973
+ tool("mason_install", "mason install", "Install Mason packages", installSchema(), async (input, options) => {
3974
+ const args = validateObject(input);
3975
+ const packages = validateStringArray(args.packages, "packages");
3976
+ const argv = ["install", ...packages];
3977
+ if (typeof args.registry === "string" && args.registry.length > 0)
3978
+ argv.push("--registry", args.registry);
3979
+ if (args.allow_build_scripts === true)
3980
+ argv.push("--allow-build-scripts");
3981
+ return result(await bridge.run(argv, options));
3982
+ }),
3983
+ tool("mason_uninstall", "mason uninstall", "Uninstall Mason packages", uninstallSchema(), async (input, options) => {
3984
+ const args = validateObject(input);
3985
+ const packages = validateStringArray(args.packages, "packages");
3986
+ return result(await bridge.run(["uninstall", ...packages], options));
3987
+ }),
3988
+ tool("mason_update", "mason update", "Update Mason packages", updateSchema(), async (input, options) => {
3989
+ const args = validateObject(input);
3990
+ const packages = args.packages === undefined || Array.isArray(args.packages) && args.packages.length === 0 ? [] : validateStringArray(args.packages, "packages");
3991
+ const argv = ["update", ...packages];
3992
+ if (typeof args.registry === "string" && args.registry.length > 0)
3993
+ argv.push("--registry", args.registry);
3994
+ if (args.allow_build_scripts === true)
3995
+ argv.push("--allow-build-scripts");
3996
+ return result(await bridge.run(argv, options));
3997
+ }),
3998
+ tool("mason_which", "mason which", "Resolve an installed executable", whichSchema(), async (input, options) => {
3999
+ const args = validateObject(input);
4000
+ if (typeof args.executable !== "string" || args.executable.length === 0)
4001
+ throw new Error("executable must be a non-empty string");
4002
+ return result(await bridge.run(["which", args.executable], options));
4003
+ }),
4004
+ tool("mason_env", "mason env", "Print PATH setup for shells", envSchema(), async (input, options) => {
4005
+ const args = validateObject(input);
4006
+ const shell = typeof args.shell === "string" && args.shell.length > 0 ? args.shell : "json";
4007
+ return result(await bridge.run(["env", "--shell", shell], options));
4008
+ })
4009
+ ];
4010
+ }
4011
+ function registerPiTools(ctx, bridge) {
4012
+ const tools = createPiTools(bridge);
4013
+ for (const definition of tools) {
4014
+ registerTool(ctx, definition);
4015
+ }
4016
+ return tools;
4017
+ }
4018
+ function tool(name, label, description, parameters, executor) {
4019
+ return {
4020
+ name,
4021
+ label,
4022
+ description,
4023
+ promptSnippet: description,
4024
+ parameters,
4025
+ execute(_toolCallId, params, signal) {
4026
+ return signal ? executor(params, { signal }) : executor(params);
4027
+ }
4028
+ };
4029
+ }
4030
+ function registerTool(ctx, definition) {
4031
+ const anyCtx = ctx;
4032
+ if (typeof anyCtx.registerTool === "function") {
4033
+ anyCtx.registerTool(definition);
4034
+ } else if (typeof anyCtx.tools?.registerTool === "function") {
4035
+ anyCtx.tools.registerTool(definition);
4036
+ } else if (typeof anyCtx.tools?.register === "function") {
4037
+ anyCtx.tools.register(definition);
4038
+ }
4039
+ }
4040
+ function result(details) {
4041
+ return { content: [{ type: "text", text: JSON.stringify(details, null, 2) }], details };
4042
+ }
4043
+ function validateObject(input) {
4044
+ if (input === undefined || input === null)
4045
+ return {};
4046
+ if (typeof input !== "object" || Array.isArray(input))
4047
+ throw new Error("tool input must be an object");
4048
+ return input;
4049
+ }
4050
+ function validateStringArray(value, name) {
4051
+ if (!Array.isArray(value) || value.length === 0 || value.some((item) => typeof item !== "string" || item.length === 0)) {
4052
+ throw new Error(`${name} must be a non-empty string array`);
4053
+ }
4054
+ return value;
4055
+ }
4056
+ function listSchema() {
4057
+ return Type.Object({ installed: Type.Optional(Type.Boolean()), outdated: Type.Optional(Type.Boolean()) }, { additionalProperties: false });
4058
+ }
4059
+ function searchSchema() {
4060
+ return Type.Object({ query: Type.Optional(Type.String()), category: Type.Optional(Type.String()), language: Type.Optional(Type.String()) }, { additionalProperties: false });
4061
+ }
4062
+ function installSchema() {
4063
+ return Type.Object({ packages: Type.Array(Type.String(), { minItems: 1 }), registry: Type.Optional(Type.String()), allow_build_scripts: Type.Optional(Type.Boolean()) }, { additionalProperties: false, required: ["packages"] });
4064
+ }
4065
+ function uninstallSchema() {
4066
+ return Type.Object({ packages: Type.Array(Type.String(), { minItems: 1 }) }, { additionalProperties: false, required: ["packages"] });
4067
+ }
4068
+ function updateSchema() {
4069
+ return Type.Object({ packages: Type.Optional(Type.Array(Type.String())), registry: Type.Optional(Type.String()), allow_build_scripts: Type.Optional(Type.Boolean()) }, { additionalProperties: false });
4070
+ }
4071
+ function whichSchema() {
4072
+ return Type.Object({ executable: Type.String() }, { additionalProperties: false, required: ["executable"] });
4073
+ }
4074
+ function envSchema() {
4075
+ return Type.Object({ shell: Type.Optional(Type.Union([Type.Literal("bash"), Type.Literal("zsh"), Type.Literal("fish"), Type.Literal("powershell"), Type.Literal("cmd"), Type.Literal("json")])) }, { additionalProperties: false });
4076
+ }
4077
+
4078
+ // src/pi/path-env.ts
4079
+ import { mkdirSync } from "fs";
4080
+ import { join as join2, delimiter } from "path";
4081
+ function masonDataDir(env = process.env) {
4082
+ const xdgDataHome = env.XDG_DATA_HOME ?? (env.LOCALAPPDATA ? env.LOCALAPPDATA : undefined);
4083
+ if (env.MASON4AGENTS_DATA_HOME && env.MASON4AGENTS_DATA_HOME.length > 0) {
4084
+ const p = env.MASON4AGENTS_DATA_HOME;
4085
+ if (!p.startsWith(".") && (p.startsWith("/") || /^[A-Za-z]:[/\\]/.test(p))) {
4086
+ return join2(p, "mason4agents");
4087
+ }
4088
+ }
4089
+ if (xdgDataHome && xdgDataHome.length > 0) {
4090
+ if (!xdgDataHome.startsWith(".") && (xdgDataHome.startsWith("/") || /^[A-Za-z]:[/\\]/.test(xdgDataHome))) {
4091
+ return join2(xdgDataHome, "mason4agents");
4092
+ }
4093
+ }
4094
+ const home = env.HOME ?? env.USERPROFILE;
4095
+ if (!home) {
4096
+ throw new Error("HOME or USERPROFILE is required to resolve mason4agents data directory");
4097
+ }
4098
+ return join2(home, ".local", "share", "mason4agents");
4099
+ }
4100
+ function ensureMasonBinOnPath(env = process.env) {
4101
+ const dataDir = masonDataDir(env);
4102
+ const binDir = join2(dataDir, "bin");
4103
+ mkdirSync(binDir, { recursive: true });
4104
+ const current = env.PATH;
4105
+ if (current === undefined) {
4106
+ env.PATH = binDir;
4107
+ return { dataDir, binDir, changed: true, path: binDir };
4108
+ }
4109
+ const parts = current === "" ? [""] : current.split(delimiter);
4110
+ const alreadyFirst = parts[0] === binDir;
4111
+ const nextParts = alreadyFirst ? parts : [binDir, ...parts.filter((part) => part !== binDir)];
4112
+ const next = nextParts.join(delimiter);
4113
+ if (!alreadyFirst) {
4114
+ env.PATH = next;
4115
+ }
4116
+ return { dataDir, binDir, changed: !alreadyFirst, path: env.PATH ?? next };
4117
+ }
4118
+
4119
+ // src/pi/extension.ts
4120
+ async function activate(ctx, bridge = createCliBridge()) {
4121
+ const pathInfo = ensureMasonBinOnPath();
4122
+ const apiCtx = ctx;
4123
+ registerCommand(ctx, "mason", "Open mason4agents package manager", async (args, commandCtx) => {
4124
+ try {
4125
+ const input = typeof args === "string" ? args.trim() : "";
4126
+ const shownInUi = canShowCustomUi(commandCtx);
4127
+ if (input.length === 0) {
4128
+ const panel = await openMasonPanel(commandCtx, bridge);
4129
+ if (!shownInUi) {
4130
+ publishMessage(apiCtx, "mason4agents", panel.render());
4131
+ }
4132
+ return;
4133
+ }
4134
+ const model = await executeMasonCommand(input, bridge);
4135
+ if (shownInUi) {
4136
+ await showDisplayPanel(commandCtx, model);
4137
+ } else {
4138
+ publishMessage(apiCtx, "mason4agents", renderDisplayText(model));
4139
+ }
4140
+ } catch (err) {
4141
+ reportCommandError(commandCtx, apiCtx, "mason", err);
4142
+ }
4143
+ });
4144
+ registerCommand(ctx, "mason-doctor", "Run mason4agents doctor", async (_args, commandCtx) => {
4145
+ try {
4146
+ const model = await executeMasonCommand("doctor", bridge);
4147
+ if (canShowCustomUi(commandCtx)) {
4148
+ await showDisplayPanel(commandCtx, model);
4149
+ } else {
4150
+ publishMessage(apiCtx, "mason4agents-doctor", renderDisplayText(model));
4151
+ }
4152
+ } catch (err) {
4153
+ reportCommandError(commandCtx, apiCtx, "mason-doctor", err);
4154
+ }
4155
+ });
4156
+ const tools = registerPiTools(ctx, bridge);
4157
+ registerSessionStart(ctx, () => ensureMasonBinOnPath());
4158
+ return { name: "mason4agents", binDir: pathInfo.binDir, tools };
4159
+ }
4160
+ var extension_default = activate;
4161
+ function registerCommand(ctx, name, description, handler) {
4162
+ const anyCtx = ctx;
4163
+ const options = { description, handler };
4164
+ if (typeof anyCtx.registerCommand === "function") {
4165
+ anyCtx.registerCommand(name, options);
4166
+ } else if (typeof anyCtx.commands?.registerCommand === "function") {
4167
+ anyCtx.commands.registerCommand(name, options);
4168
+ } else if (typeof anyCtx.commands?.register === "function") {
4169
+ anyCtx.commands.register(name, options);
4170
+ } else if (typeof anyCtx.command?.register === "function") {
4171
+ anyCtx.command.register(name, options);
4172
+ }
4173
+ }
4174
+ function canShowCustomUi(ctx) {
4175
+ const anyCtx = ctx;
4176
+ return anyCtx.hasUI !== false && typeof anyCtx.ui?.custom === "function";
4177
+ }
4178
+ async function showDisplayPanel(ctx, model) {
4179
+ const anyCtx = ctx;
4180
+ await anyCtx.ui?.custom?.((tui, _theme, _keybindings, done) => {
4181
+ const state = { filter: "", filterDraft: "", editingFilter: false, scroll: 0 };
4182
+ return {
4183
+ render(width) {
4184
+ return renderDisplayPanel(model, state, width);
4185
+ },
4186
+ handleInput(key) {
4187
+ if (state.editingFilter) {
4188
+ handleFilterInput(state, key);
4189
+ requestTuiRender2(tui);
4190
+ return;
4191
+ }
4192
+ if (isCloseKey2(key)) {
4193
+ done(undefined);
4194
+ return;
4195
+ }
4196
+ if (key === "/" && modelSupportsFiltering(model)) {
4197
+ state.filterDraft = state.filter;
4198
+ state.editingFilter = true;
4199
+ requestTuiRender2(tui);
4200
+ return;
4201
+ }
4202
+ if (isScrollDownKey2(key))
4203
+ state.scroll += 1;
4204
+ if (isScrollUpKey2(key))
4205
+ state.scroll = Math.max(0, state.scroll - 1);
4206
+ if (isPageDownKey2(key))
4207
+ state.scroll += 10;
4208
+ if (isPageUpKey2(key))
4209
+ state.scroll = Math.max(0, state.scroll - 10);
4210
+ requestTuiRender2(tui);
4211
+ },
4212
+ invalidate() {}
4213
+ };
4214
+ });
4215
+ }
4216
+ function publishMessage(ctx, customType, content) {
4217
+ const anyCtx = ctx;
4218
+ if (typeof anyCtx.sendMessage === "function") {
4219
+ anyCtx.sendMessage({ customType, content, display: true }, { deliverAs: "nextTurn" });
4220
+ }
4221
+ }
4222
+ function reportCommandError(commandCtx, apiCtx, command2, err) {
4223
+ const msg = err instanceof Error ? err.message : String(err);
4224
+ const anyCommandCtx = commandCtx;
4225
+ if (typeof anyCommandCtx.ui?.notify === "function") {
4226
+ anyCommandCtx.ui.notify(`${command2}: ${msg}`, "error");
4227
+ } else {
4228
+ publishMessage(apiCtx, `mason4agents-${command2}-error`, `${command2}: ${msg}`);
4229
+ }
4230
+ }
4231
+ function renderDisplayPanel(model, state, width) {
4232
+ const safeWidth = Math.max(1, Math.floor(width));
4233
+ const lines = renderDisplay(model, { width: safeWidth, filter: state.filter, scroll: state.scroll });
4234
+ if (state.editingFilter) {
4235
+ lines.splice(1, 0, truncateToWidth3(`filter> ${state.filterDraft}`, safeWidth));
4236
+ }
4237
+ return lines.map((line) => truncateToWidth3(line, safeWidth));
4238
+ }
4239
+ function handleFilterInput(state, key) {
4240
+ if (key === "\r" || key === `
4241
+ ` || key === "enter" || key === "return") {
4242
+ state.filter = state.filterDraft.trim();
4243
+ state.scroll = 0;
4244
+ state.editingFilter = false;
4245
+ return;
4246
+ }
4247
+ if (key === "\x1B" || key === "escape" || key === "esc") {
4248
+ state.editingFilter = false;
4249
+ return;
4250
+ }
4251
+ if (key === "\b" || key === "\x7F" || key === "backspace") {
4252
+ state.filterDraft = state.filterDraft.slice(0, -1);
4253
+ return;
4254
+ }
4255
+ if (key.length === 1 && key >= " ")
4256
+ state.filterDraft += key;
4257
+ }
4258
+ function truncateToWidth3(value, width) {
4259
+ if (value.length <= width)
4260
+ return value;
4261
+ if (width <= 1)
4262
+ return value.slice(0, width);
4263
+ return `${value.slice(0, width - 1)}\u2026`;
4264
+ }
4265
+ function isCloseKey2(key) {
4266
+ return key === "q" || key === "\x1B" || key === "escape" || key === "esc";
4267
+ }
4268
+ function isScrollDownKey2(key) {
4269
+ return key === "down" || key === "j" || key === "\x1B[B";
4270
+ }
4271
+ function isScrollUpKey2(key) {
4272
+ return key === "up" || key === "k" || key === "\x1B[A";
4273
+ }
4274
+ function isPageDownKey2(key) {
4275
+ return key === "pagedown" || key === "\x1B[6~";
4276
+ }
4277
+ function isPageUpKey2(key) {
4278
+ return key === "pageup" || key === "\x1B[5~";
4279
+ }
4280
+ function requestTuiRender2(tui) {
4281
+ if (typeof tui !== "object" || tui === null)
4282
+ return;
4283
+ const candidate = tui;
4284
+ if (typeof candidate.requestRender === "function") {
4285
+ candidate.requestRender(true);
4286
+ } else if (typeof candidate.invalidate === "function") {
4287
+ candidate.invalidate();
4288
+ }
4289
+ }
4290
+ function registerSessionStart(ctx, handler) {
4291
+ const anyCtx = ctx;
4292
+ if (typeof anyCtx.events?.on === "function") {
4293
+ anyCtx.events.on("session_start", handler);
4294
+ } else if (typeof anyCtx.on === "function") {
4295
+ anyCtx.on("session_start", handler);
4296
+ }
4297
+ }
4298
+ export {
4299
+ extension_default as default,
4300
+ activate
4301
+ };