@aight-cool/aight-utils 0.1.17 → 0.1.19

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.
package/dist/index.js ADDED
@@ -0,0 +1,3805 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/defaults.ts
8
+ var DEFAULT_RELAY_URL = "https://push.aight.cool";
9
+ var DEFAULT_PUSH_MODE = "rich";
10
+
11
+ // src/config.ts
12
+ var PLUGIN_CONFIG_KEYS = /* @__PURE__ */ new Set(["push", "today"]);
13
+ var SECRET_KEYS = ["relaySecret"];
14
+ function getClientSafeConfig(config) {
15
+ const safe = JSON.parse(JSON.stringify(config));
16
+ if (safe.push) {
17
+ for (const key of SECRET_KEYS) {
18
+ if (key in safe.push) {
19
+ safe.push[key] = safe.push[key] ? "[REDACTED]" : void 0;
20
+ }
21
+ }
22
+ }
23
+ return safe;
24
+ }
25
+ function getPluginConfig(api) {
26
+ const raw = api.pluginConfig;
27
+ return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
28
+ }
29
+ function registerConfig(api) {
30
+ api.registerGatewayMethod("aight.config.get", ({ respond }) => {
31
+ respond(true, getClientSafeConfig(getPluginConfig(api)));
32
+ });
33
+ api.registerGatewayMethod(
34
+ "aight.config.patch",
35
+ async ({ params, respond }) => {
36
+ if (!params || typeof params !== "object") {
37
+ respond(false, { error: "params must be an object" });
38
+ return;
39
+ }
40
+ try {
41
+ const incoming = params;
42
+ for (const key of Object.keys(incoming)) {
43
+ if (!PLUGIN_CONFIG_KEYS.has(key)) {
44
+ respond(false, { error: `Key "${key}" is not allowed in config.patch` });
45
+ return;
46
+ }
47
+ }
48
+ const currentConfig = await api.runtime.config.loadConfig();
49
+ const pluginEntry = currentConfig?.plugins?.entries?.["aight-utils"] ?? {};
50
+ const currentPluginConfig = pluginEntry.config ?? {};
51
+ const merged = { ...currentPluginConfig };
52
+ for (const [key, value] of Object.entries(incoming)) {
53
+ if (value && typeof value === "object" && !Array.isArray(value) && merged[key] && typeof merged[key] === "object") {
54
+ merged[key] = { ...merged[key], ...value };
55
+ } else {
56
+ merged[key] = value;
57
+ }
58
+ }
59
+ const updatedConfig = {
60
+ ...currentConfig,
61
+ plugins: {
62
+ ...currentConfig?.plugins ?? {},
63
+ entries: {
64
+ ...currentConfig?.plugins?.entries ?? {},
65
+ "aight-utils": {
66
+ ...pluginEntry,
67
+ config: merged
68
+ }
69
+ }
70
+ }
71
+ };
72
+ await api.runtime.config.writeConfigFile(updatedConfig);
73
+ respond(true, { ok: true, config: getClientSafeConfig(merged) });
74
+ } catch (err) {
75
+ const msg = err instanceof Error ? err.message : String(err);
76
+ api.logger.error(`[aight-utils] config.patch failed: ${msg}`);
77
+ respond(false, { error: msg });
78
+ }
79
+ }
80
+ );
81
+ api.registerGatewayMethod("aight.status", ({ respond }) => {
82
+ const cfg = getPluginConfig(api);
83
+ respond(true, {
84
+ ok: true,
85
+ version: "0.1.0",
86
+ push: {
87
+ mode: cfg.push?.mode ?? DEFAULT_PUSH_MODE,
88
+ relayUrl: cfg.push?.relayUrl ?? "https://push.aight.app"
89
+ },
90
+ today: {
91
+ enabled: cfg.today?.enabled ?? true
92
+ }
93
+ });
94
+ });
95
+ }
96
+
97
+ // node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
98
+ var value_exports = {};
99
+ __export(value_exports, {
100
+ HasPropertyKey: () => HasPropertyKey,
101
+ IsArray: () => IsArray,
102
+ IsAsyncIterator: () => IsAsyncIterator,
103
+ IsBigInt: () => IsBigInt,
104
+ IsBoolean: () => IsBoolean,
105
+ IsDate: () => IsDate,
106
+ IsFunction: () => IsFunction,
107
+ IsIterator: () => IsIterator,
108
+ IsNull: () => IsNull,
109
+ IsNumber: () => IsNumber,
110
+ IsObject: () => IsObject,
111
+ IsRegExp: () => IsRegExp,
112
+ IsString: () => IsString,
113
+ IsSymbol: () => IsSymbol,
114
+ IsUint8Array: () => IsUint8Array,
115
+ IsUndefined: () => IsUndefined
116
+ });
117
+ function HasPropertyKey(value, key) {
118
+ return key in value;
119
+ }
120
+ function IsAsyncIterator(value) {
121
+ return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.asyncIterator in value;
122
+ }
123
+ function IsArray(value) {
124
+ return Array.isArray(value);
125
+ }
126
+ function IsBigInt(value) {
127
+ return typeof value === "bigint";
128
+ }
129
+ function IsBoolean(value) {
130
+ return typeof value === "boolean";
131
+ }
132
+ function IsDate(value) {
133
+ return value instanceof globalThis.Date;
134
+ }
135
+ function IsFunction(value) {
136
+ return typeof value === "function";
137
+ }
138
+ function IsIterator(value) {
139
+ return IsObject(value) && !IsArray(value) && !IsUint8Array(value) && Symbol.iterator in value;
140
+ }
141
+ function IsNull(value) {
142
+ return value === null;
143
+ }
144
+ function IsNumber(value) {
145
+ return typeof value === "number";
146
+ }
147
+ function IsObject(value) {
148
+ return typeof value === "object" && value !== null;
149
+ }
150
+ function IsRegExp(value) {
151
+ return value instanceof globalThis.RegExp;
152
+ }
153
+ function IsString(value) {
154
+ return typeof value === "string";
155
+ }
156
+ function IsSymbol(value) {
157
+ return typeof value === "symbol";
158
+ }
159
+ function IsUint8Array(value) {
160
+ return value instanceof globalThis.Uint8Array;
161
+ }
162
+ function IsUndefined(value) {
163
+ return value === void 0;
164
+ }
165
+
166
+ // node_modules/@sinclair/typebox/build/esm/type/clone/value.mjs
167
+ function ArrayType(value) {
168
+ return value.map((value2) => Visit(value2));
169
+ }
170
+ function DateType(value) {
171
+ return new Date(value.getTime());
172
+ }
173
+ function Uint8ArrayType(value) {
174
+ return new Uint8Array(value);
175
+ }
176
+ function RegExpType(value) {
177
+ return new RegExp(value.source, value.flags);
178
+ }
179
+ function ObjectType(value) {
180
+ const result = {};
181
+ for (const key of Object.getOwnPropertyNames(value)) {
182
+ result[key] = Visit(value[key]);
183
+ }
184
+ for (const key of Object.getOwnPropertySymbols(value)) {
185
+ result[key] = Visit(value[key]);
186
+ }
187
+ return result;
188
+ }
189
+ function Visit(value) {
190
+ return IsArray(value) ? ArrayType(value) : IsDate(value) ? DateType(value) : IsUint8Array(value) ? Uint8ArrayType(value) : IsRegExp(value) ? RegExpType(value) : IsObject(value) ? ObjectType(value) : value;
191
+ }
192
+ function Clone(value) {
193
+ return Visit(value);
194
+ }
195
+
196
+ // node_modules/@sinclair/typebox/build/esm/type/clone/type.mjs
197
+ function CloneType(schema, options) {
198
+ return options === void 0 ? Clone(schema) : Clone({ ...options, ...schema });
199
+ }
200
+
201
+ // node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
202
+ function IsObject2(value) {
203
+ return value !== null && typeof value === "object";
204
+ }
205
+ function IsArray2(value) {
206
+ return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
207
+ }
208
+ function IsUndefined2(value) {
209
+ return value === void 0;
210
+ }
211
+ function IsNumber2(value) {
212
+ return typeof value === "number";
213
+ }
214
+
215
+ // node_modules/@sinclair/typebox/build/esm/system/policy.mjs
216
+ var TypeSystemPolicy;
217
+ (function(TypeSystemPolicy2) {
218
+ TypeSystemPolicy2.InstanceMode = "default";
219
+ TypeSystemPolicy2.ExactOptionalPropertyTypes = false;
220
+ TypeSystemPolicy2.AllowArrayObject = false;
221
+ TypeSystemPolicy2.AllowNaN = false;
222
+ TypeSystemPolicy2.AllowNullVoid = false;
223
+ function IsExactOptionalProperty(value, key) {
224
+ return TypeSystemPolicy2.ExactOptionalPropertyTypes ? key in value : value[key] !== void 0;
225
+ }
226
+ TypeSystemPolicy2.IsExactOptionalProperty = IsExactOptionalProperty;
227
+ function IsObjectLike(value) {
228
+ const isObject = IsObject2(value);
229
+ return TypeSystemPolicy2.AllowArrayObject ? isObject : isObject && !IsArray2(value);
230
+ }
231
+ TypeSystemPolicy2.IsObjectLike = IsObjectLike;
232
+ function IsRecordLike(value) {
233
+ return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
234
+ }
235
+ TypeSystemPolicy2.IsRecordLike = IsRecordLike;
236
+ function IsNumberLike(value) {
237
+ return TypeSystemPolicy2.AllowNaN ? IsNumber2(value) : Number.isFinite(value);
238
+ }
239
+ TypeSystemPolicy2.IsNumberLike = IsNumberLike;
240
+ function IsVoidLike(value) {
241
+ const isUndefined = IsUndefined2(value);
242
+ return TypeSystemPolicy2.AllowNullVoid ? isUndefined || value === null : isUndefined;
243
+ }
244
+ TypeSystemPolicy2.IsVoidLike = IsVoidLike;
245
+ })(TypeSystemPolicy || (TypeSystemPolicy = {}));
246
+
247
+ // node_modules/@sinclair/typebox/build/esm/type/create/immutable.mjs
248
+ function ImmutableArray(value) {
249
+ return globalThis.Object.freeze(value).map((value2) => Immutable(value2));
250
+ }
251
+ function ImmutableDate(value) {
252
+ return value;
253
+ }
254
+ function ImmutableUint8Array(value) {
255
+ return value;
256
+ }
257
+ function ImmutableRegExp(value) {
258
+ return value;
259
+ }
260
+ function ImmutableObject(value) {
261
+ const result = {};
262
+ for (const key of Object.getOwnPropertyNames(value)) {
263
+ result[key] = Immutable(value[key]);
264
+ }
265
+ for (const key of Object.getOwnPropertySymbols(value)) {
266
+ result[key] = Immutable(value[key]);
267
+ }
268
+ return globalThis.Object.freeze(result);
269
+ }
270
+ function Immutable(value) {
271
+ return IsArray(value) ? ImmutableArray(value) : IsDate(value) ? ImmutableDate(value) : IsUint8Array(value) ? ImmutableUint8Array(value) : IsRegExp(value) ? ImmutableRegExp(value) : IsObject(value) ? ImmutableObject(value) : value;
272
+ }
273
+
274
+ // node_modules/@sinclair/typebox/build/esm/type/create/type.mjs
275
+ function CreateType(schema, options) {
276
+ const result = options !== void 0 ? { ...options, ...schema } : schema;
277
+ switch (TypeSystemPolicy.InstanceMode) {
278
+ case "freeze":
279
+ return Immutable(result);
280
+ case "clone":
281
+ return Clone(result);
282
+ default:
283
+ return result;
284
+ }
285
+ }
286
+
287
+ // node_modules/@sinclair/typebox/build/esm/type/error/error.mjs
288
+ var TypeBoxError = class extends Error {
289
+ constructor(message) {
290
+ super(message);
291
+ }
292
+ };
293
+
294
+ // node_modules/@sinclair/typebox/build/esm/type/symbols/symbols.mjs
295
+ var TransformKind = /* @__PURE__ */ Symbol.for("TypeBox.Transform");
296
+ var ReadonlyKind = /* @__PURE__ */ Symbol.for("TypeBox.Readonly");
297
+ var OptionalKind = /* @__PURE__ */ Symbol.for("TypeBox.Optional");
298
+ var Hint = /* @__PURE__ */ Symbol.for("TypeBox.Hint");
299
+ var Kind = /* @__PURE__ */ Symbol.for("TypeBox.Kind");
300
+
301
+ // node_modules/@sinclair/typebox/build/esm/type/guard/kind.mjs
302
+ function IsReadonly(value) {
303
+ return IsObject(value) && value[ReadonlyKind] === "Readonly";
304
+ }
305
+ function IsOptional(value) {
306
+ return IsObject(value) && value[OptionalKind] === "Optional";
307
+ }
308
+ function IsAny(value) {
309
+ return IsKindOf(value, "Any");
310
+ }
311
+ function IsArgument(value) {
312
+ return IsKindOf(value, "Argument");
313
+ }
314
+ function IsArray3(value) {
315
+ return IsKindOf(value, "Array");
316
+ }
317
+ function IsAsyncIterator2(value) {
318
+ return IsKindOf(value, "AsyncIterator");
319
+ }
320
+ function IsBigInt2(value) {
321
+ return IsKindOf(value, "BigInt");
322
+ }
323
+ function IsBoolean2(value) {
324
+ return IsKindOf(value, "Boolean");
325
+ }
326
+ function IsComputed(value) {
327
+ return IsKindOf(value, "Computed");
328
+ }
329
+ function IsConstructor(value) {
330
+ return IsKindOf(value, "Constructor");
331
+ }
332
+ function IsDate2(value) {
333
+ return IsKindOf(value, "Date");
334
+ }
335
+ function IsFunction2(value) {
336
+ return IsKindOf(value, "Function");
337
+ }
338
+ function IsInteger(value) {
339
+ return IsKindOf(value, "Integer");
340
+ }
341
+ function IsIntersect(value) {
342
+ return IsKindOf(value, "Intersect");
343
+ }
344
+ function IsIterator2(value) {
345
+ return IsKindOf(value, "Iterator");
346
+ }
347
+ function IsKindOf(value, kind) {
348
+ return IsObject(value) && Kind in value && value[Kind] === kind;
349
+ }
350
+ function IsLiteralValue(value) {
351
+ return IsBoolean(value) || IsNumber(value) || IsString(value);
352
+ }
353
+ function IsLiteral(value) {
354
+ return IsKindOf(value, "Literal");
355
+ }
356
+ function IsMappedKey(value) {
357
+ return IsKindOf(value, "MappedKey");
358
+ }
359
+ function IsMappedResult(value) {
360
+ return IsKindOf(value, "MappedResult");
361
+ }
362
+ function IsNever(value) {
363
+ return IsKindOf(value, "Never");
364
+ }
365
+ function IsNot(value) {
366
+ return IsKindOf(value, "Not");
367
+ }
368
+ function IsNull2(value) {
369
+ return IsKindOf(value, "Null");
370
+ }
371
+ function IsNumber3(value) {
372
+ return IsKindOf(value, "Number");
373
+ }
374
+ function IsObject3(value) {
375
+ return IsKindOf(value, "Object");
376
+ }
377
+ function IsPromise(value) {
378
+ return IsKindOf(value, "Promise");
379
+ }
380
+ function IsRecord(value) {
381
+ return IsKindOf(value, "Record");
382
+ }
383
+ function IsRef(value) {
384
+ return IsKindOf(value, "Ref");
385
+ }
386
+ function IsRegExp2(value) {
387
+ return IsKindOf(value, "RegExp");
388
+ }
389
+ function IsString2(value) {
390
+ return IsKindOf(value, "String");
391
+ }
392
+ function IsSymbol2(value) {
393
+ return IsKindOf(value, "Symbol");
394
+ }
395
+ function IsTemplateLiteral(value) {
396
+ return IsKindOf(value, "TemplateLiteral");
397
+ }
398
+ function IsThis(value) {
399
+ return IsKindOf(value, "This");
400
+ }
401
+ function IsTransform(value) {
402
+ return IsObject(value) && TransformKind in value;
403
+ }
404
+ function IsTuple(value) {
405
+ return IsKindOf(value, "Tuple");
406
+ }
407
+ function IsUndefined3(value) {
408
+ return IsKindOf(value, "Undefined");
409
+ }
410
+ function IsUnion(value) {
411
+ return IsKindOf(value, "Union");
412
+ }
413
+ function IsUint8Array2(value) {
414
+ return IsKindOf(value, "Uint8Array");
415
+ }
416
+ function IsUnknown(value) {
417
+ return IsKindOf(value, "Unknown");
418
+ }
419
+ function IsUnsafe(value) {
420
+ return IsKindOf(value, "Unsafe");
421
+ }
422
+ function IsVoid(value) {
423
+ return IsKindOf(value, "Void");
424
+ }
425
+ function IsKind(value) {
426
+ return IsObject(value) && Kind in value && IsString(value[Kind]);
427
+ }
428
+ function IsSchema(value) {
429
+ 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);
430
+ }
431
+
432
+ // node_modules/@sinclair/typebox/build/esm/type/guard/type.mjs
433
+ var type_exports = {};
434
+ __export(type_exports, {
435
+ IsAny: () => IsAny2,
436
+ IsArgument: () => IsArgument2,
437
+ IsArray: () => IsArray4,
438
+ IsAsyncIterator: () => IsAsyncIterator3,
439
+ IsBigInt: () => IsBigInt3,
440
+ IsBoolean: () => IsBoolean3,
441
+ IsComputed: () => IsComputed2,
442
+ IsConstructor: () => IsConstructor2,
443
+ IsDate: () => IsDate3,
444
+ IsFunction: () => IsFunction3,
445
+ IsImport: () => IsImport,
446
+ IsInteger: () => IsInteger2,
447
+ IsIntersect: () => IsIntersect2,
448
+ IsIterator: () => IsIterator3,
449
+ IsKind: () => IsKind2,
450
+ IsKindOf: () => IsKindOf2,
451
+ IsLiteral: () => IsLiteral2,
452
+ IsLiteralBoolean: () => IsLiteralBoolean,
453
+ IsLiteralNumber: () => IsLiteralNumber,
454
+ IsLiteralString: () => IsLiteralString,
455
+ IsLiteralValue: () => IsLiteralValue2,
456
+ IsMappedKey: () => IsMappedKey2,
457
+ IsMappedResult: () => IsMappedResult2,
458
+ IsNever: () => IsNever2,
459
+ IsNot: () => IsNot2,
460
+ IsNull: () => IsNull3,
461
+ IsNumber: () => IsNumber4,
462
+ IsObject: () => IsObject4,
463
+ IsOptional: () => IsOptional2,
464
+ IsPromise: () => IsPromise2,
465
+ IsProperties: () => IsProperties,
466
+ IsReadonly: () => IsReadonly2,
467
+ IsRecord: () => IsRecord2,
468
+ IsRecursive: () => IsRecursive,
469
+ IsRef: () => IsRef2,
470
+ IsRegExp: () => IsRegExp3,
471
+ IsSchema: () => IsSchema2,
472
+ IsString: () => IsString3,
473
+ IsSymbol: () => IsSymbol3,
474
+ IsTemplateLiteral: () => IsTemplateLiteral2,
475
+ IsThis: () => IsThis2,
476
+ IsTransform: () => IsTransform2,
477
+ IsTuple: () => IsTuple2,
478
+ IsUint8Array: () => IsUint8Array3,
479
+ IsUndefined: () => IsUndefined4,
480
+ IsUnion: () => IsUnion2,
481
+ IsUnionLiteral: () => IsUnionLiteral,
482
+ IsUnknown: () => IsUnknown2,
483
+ IsUnsafe: () => IsUnsafe2,
484
+ IsVoid: () => IsVoid2,
485
+ TypeGuardUnknownTypeError: () => TypeGuardUnknownTypeError
486
+ });
487
+ var TypeGuardUnknownTypeError = class extends TypeBoxError {
488
+ };
489
+ var KnownTypes = [
490
+ "Argument",
491
+ "Any",
492
+ "Array",
493
+ "AsyncIterator",
494
+ "BigInt",
495
+ "Boolean",
496
+ "Computed",
497
+ "Constructor",
498
+ "Date",
499
+ "Enum",
500
+ "Function",
501
+ "Integer",
502
+ "Intersect",
503
+ "Iterator",
504
+ "Literal",
505
+ "MappedKey",
506
+ "MappedResult",
507
+ "Not",
508
+ "Null",
509
+ "Number",
510
+ "Object",
511
+ "Promise",
512
+ "Record",
513
+ "Ref",
514
+ "RegExp",
515
+ "String",
516
+ "Symbol",
517
+ "TemplateLiteral",
518
+ "This",
519
+ "Tuple",
520
+ "Undefined",
521
+ "Union",
522
+ "Uint8Array",
523
+ "Unknown",
524
+ "Void"
525
+ ];
526
+ function IsPattern(value) {
527
+ try {
528
+ new RegExp(value);
529
+ return true;
530
+ } catch {
531
+ return false;
532
+ }
533
+ }
534
+ function IsControlCharacterFree(value) {
535
+ if (!IsString(value))
536
+ return false;
537
+ for (let i = 0; i < value.length; i++) {
538
+ const code = value.charCodeAt(i);
539
+ if (code >= 7 && code <= 13 || code === 27 || code === 127) {
540
+ return false;
541
+ }
542
+ }
543
+ return true;
544
+ }
545
+ function IsAdditionalProperties(value) {
546
+ return IsOptionalBoolean(value) || IsSchema2(value);
547
+ }
548
+ function IsOptionalBigInt(value) {
549
+ return IsUndefined(value) || IsBigInt(value);
550
+ }
551
+ function IsOptionalNumber(value) {
552
+ return IsUndefined(value) || IsNumber(value);
553
+ }
554
+ function IsOptionalBoolean(value) {
555
+ return IsUndefined(value) || IsBoolean(value);
556
+ }
557
+ function IsOptionalString(value) {
558
+ return IsUndefined(value) || IsString(value);
559
+ }
560
+ function IsOptionalPattern(value) {
561
+ return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value) && IsPattern(value);
562
+ }
563
+ function IsOptionalFormat(value) {
564
+ return IsUndefined(value) || IsString(value) && IsControlCharacterFree(value);
565
+ }
566
+ function IsOptionalSchema(value) {
567
+ return IsUndefined(value) || IsSchema2(value);
568
+ }
569
+ function IsReadonly2(value) {
570
+ return IsObject(value) && value[ReadonlyKind] === "Readonly";
571
+ }
572
+ function IsOptional2(value) {
573
+ return IsObject(value) && value[OptionalKind] === "Optional";
574
+ }
575
+ function IsAny2(value) {
576
+ return IsKindOf2(value, "Any") && IsOptionalString(value.$id);
577
+ }
578
+ function IsArgument2(value) {
579
+ return IsKindOf2(value, "Argument") && IsNumber(value.index);
580
+ }
581
+ function IsArray4(value) {
582
+ 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);
583
+ }
584
+ function IsAsyncIterator3(value) {
585
+ return IsKindOf2(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
586
+ }
587
+ function IsBigInt3(value) {
588
+ 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);
589
+ }
590
+ function IsBoolean3(value) {
591
+ return IsKindOf2(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
592
+ }
593
+ function IsComputed2(value) {
594
+ return IsKindOf2(value, "Computed") && IsString(value.target) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema));
595
+ }
596
+ function IsConstructor2(value) {
597
+ return IsKindOf2(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
598
+ }
599
+ function IsDate3(value) {
600
+ 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);
601
+ }
602
+ function IsFunction3(value) {
603
+ return IsKindOf2(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray(value.parameters) && value.parameters.every((schema) => IsSchema2(schema)) && IsSchema2(value.returns);
604
+ }
605
+ function IsImport(value) {
606
+ return IsKindOf2(value, "Import") && HasPropertyKey(value, "$defs") && IsObject(value.$defs) && IsProperties(value.$defs) && HasPropertyKey(value, "$ref") && IsString(value.$ref) && value.$ref in value.$defs;
607
+ }
608
+ function IsInteger2(value) {
609
+ 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);
610
+ }
611
+ function IsProperties(value) {
612
+ return IsObject(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema2(schema));
613
+ }
614
+ function IsIntersect2(value) {
615
+ 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);
616
+ }
617
+ function IsIterator3(value) {
618
+ return IsKindOf2(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema2(value.items);
619
+ }
620
+ function IsKindOf2(value, kind) {
621
+ return IsObject(value) && Kind in value && value[Kind] === kind;
622
+ }
623
+ function IsLiteralString(value) {
624
+ return IsLiteral2(value) && IsString(value.const);
625
+ }
626
+ function IsLiteralNumber(value) {
627
+ return IsLiteral2(value) && IsNumber(value.const);
628
+ }
629
+ function IsLiteralBoolean(value) {
630
+ return IsLiteral2(value) && IsBoolean(value.const);
631
+ }
632
+ function IsLiteral2(value) {
633
+ return IsKindOf2(value, "Literal") && IsOptionalString(value.$id) && IsLiteralValue2(value.const);
634
+ }
635
+ function IsLiteralValue2(value) {
636
+ return IsBoolean(value) || IsNumber(value) || IsString(value);
637
+ }
638
+ function IsMappedKey2(value) {
639
+ return IsKindOf2(value, "MappedKey") && IsArray(value.keys) && value.keys.every((key) => IsNumber(key) || IsString(key));
640
+ }
641
+ function IsMappedResult2(value) {
642
+ return IsKindOf2(value, "MappedResult") && IsProperties(value.properties);
643
+ }
644
+ function IsNever2(value) {
645
+ return IsKindOf2(value, "Never") && IsObject(value.not) && Object.getOwnPropertyNames(value.not).length === 0;
646
+ }
647
+ function IsNot2(value) {
648
+ return IsKindOf2(value, "Not") && IsSchema2(value.not);
649
+ }
650
+ function IsNull3(value) {
651
+ return IsKindOf2(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
652
+ }
653
+ function IsNumber4(value) {
654
+ 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);
655
+ }
656
+ function IsObject4(value) {
657
+ return IsKindOf2(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
658
+ }
659
+ function IsPromise2(value) {
660
+ return IsKindOf2(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema2(value.item);
661
+ }
662
+ function IsRecord2(value) {
663
+ return IsKindOf2(value, "Record") && value.type === "object" && IsOptionalString(value.$id) && IsAdditionalProperties(value.additionalProperties) && IsObject(value.patternProperties) && ((schema) => {
664
+ const keys = Object.getOwnPropertyNames(schema.patternProperties);
665
+ return keys.length === 1 && IsPattern(keys[0]) && IsObject(schema.patternProperties) && IsSchema2(schema.patternProperties[keys[0]]);
666
+ })(value);
667
+ }
668
+ function IsRecursive(value) {
669
+ return IsObject(value) && Hint in value && value[Hint] === "Recursive";
670
+ }
671
+ function IsRef2(value) {
672
+ return IsKindOf2(value, "Ref") && IsOptionalString(value.$id) && IsString(value.$ref);
673
+ }
674
+ function IsRegExp3(value) {
675
+ return IsKindOf2(value, "RegExp") && IsOptionalString(value.$id) && IsString(value.source) && IsString(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
676
+ }
677
+ function IsString3(value) {
678
+ return IsKindOf2(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
679
+ }
680
+ function IsSymbol3(value) {
681
+ return IsKindOf2(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
682
+ }
683
+ function IsTemplateLiteral2(value) {
684
+ return IsKindOf2(value, "TemplateLiteral") && value.type === "string" && IsString(value.pattern) && value.pattern[0] === "^" && value.pattern[value.pattern.length - 1] === "$";
685
+ }
686
+ function IsThis2(value) {
687
+ return IsKindOf2(value, "This") && IsOptionalString(value.$id) && IsString(value.$ref);
688
+ }
689
+ function IsTransform2(value) {
690
+ return IsObject(value) && TransformKind in value;
691
+ }
692
+ function IsTuple2(value) {
693
+ return IsKindOf2(value, "Tuple") && value.type === "array" && IsOptionalString(value.$id) && IsNumber(value.minItems) && IsNumber(value.maxItems) && value.minItems === value.maxItems && // empty
694
+ (IsUndefined(value.items) && IsUndefined(value.additionalItems) && value.minItems === 0 || IsArray(value.items) && value.items.every((schema) => IsSchema2(schema)));
695
+ }
696
+ function IsUndefined4(value) {
697
+ return IsKindOf2(value, "Undefined") && value.type === "undefined" && IsOptionalString(value.$id);
698
+ }
699
+ function IsUnionLiteral(value) {
700
+ return IsUnion2(value) && value.anyOf.every((schema) => IsLiteralString(schema) || IsLiteralNumber(schema));
701
+ }
702
+ function IsUnion2(value) {
703
+ return IsKindOf2(value, "Union") && IsOptionalString(value.$id) && IsObject(value) && IsArray(value.anyOf) && value.anyOf.every((schema) => IsSchema2(schema));
704
+ }
705
+ function IsUint8Array3(value) {
706
+ return IsKindOf2(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
707
+ }
708
+ function IsUnknown2(value) {
709
+ return IsKindOf2(value, "Unknown") && IsOptionalString(value.$id);
710
+ }
711
+ function IsUnsafe2(value) {
712
+ return IsKindOf2(value, "Unsafe");
713
+ }
714
+ function IsVoid2(value) {
715
+ return IsKindOf2(value, "Void") && value.type === "void" && IsOptionalString(value.$id);
716
+ }
717
+ function IsKind2(value) {
718
+ return IsObject(value) && Kind in value && IsString(value[Kind]) && !KnownTypes.includes(value[Kind]);
719
+ }
720
+ function IsSchema2(value) {
721
+ 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));
722
+ }
723
+
724
+ // node_modules/@sinclair/typebox/build/esm/type/patterns/patterns.mjs
725
+ var PatternBoolean = "(true|false)";
726
+ var PatternNumber = "(0|[1-9][0-9]*)";
727
+ var PatternString = "(.*)";
728
+ var PatternNever = "(?!.*)";
729
+ var PatternBooleanExact = `^${PatternBoolean}$`;
730
+ var PatternNumberExact = `^${PatternNumber}$`;
731
+ var PatternStringExact = `^${PatternString}$`;
732
+ var PatternNeverExact = `^${PatternNever}$`;
733
+
734
+ // node_modules/@sinclair/typebox/build/esm/type/sets/set.mjs
735
+ function SetIncludes(T, S) {
736
+ return T.includes(S);
737
+ }
738
+ function SetDistinct(T) {
739
+ return [...new Set(T)];
740
+ }
741
+ function SetIntersect(T, S) {
742
+ return T.filter((L) => S.includes(L));
743
+ }
744
+ function SetIntersectManyResolve(T, Init) {
745
+ return T.reduce((Acc, L) => {
746
+ return SetIntersect(Acc, L);
747
+ }, Init);
748
+ }
749
+ function SetIntersectMany(T) {
750
+ return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
751
+ }
752
+ function SetUnionMany(T) {
753
+ const Acc = [];
754
+ for (const L of T)
755
+ Acc.push(...L);
756
+ return Acc;
757
+ }
758
+
759
+ // node_modules/@sinclair/typebox/build/esm/type/any/any.mjs
760
+ function Any(options) {
761
+ return CreateType({ [Kind]: "Any" }, options);
762
+ }
763
+
764
+ // node_modules/@sinclair/typebox/build/esm/type/array/array.mjs
765
+ function Array2(items, options) {
766
+ return CreateType({ [Kind]: "Array", type: "array", items }, options);
767
+ }
768
+
769
+ // node_modules/@sinclair/typebox/build/esm/type/argument/argument.mjs
770
+ function Argument(index) {
771
+ return CreateType({ [Kind]: "Argument", index });
772
+ }
773
+
774
+ // node_modules/@sinclair/typebox/build/esm/type/async-iterator/async-iterator.mjs
775
+ function AsyncIterator(items, options) {
776
+ return CreateType({ [Kind]: "AsyncIterator", type: "AsyncIterator", items }, options);
777
+ }
778
+
779
+ // node_modules/@sinclair/typebox/build/esm/type/computed/computed.mjs
780
+ function Computed(target, parameters, options) {
781
+ return CreateType({ [Kind]: "Computed", target, parameters }, options);
782
+ }
783
+
784
+ // node_modules/@sinclair/typebox/build/esm/type/discard/discard.mjs
785
+ function DiscardKey(value, key) {
786
+ const { [key]: _, ...rest } = value;
787
+ return rest;
788
+ }
789
+ function Discard(value, keys) {
790
+ return keys.reduce((acc, key) => DiscardKey(acc, key), value);
791
+ }
792
+
793
+ // node_modules/@sinclair/typebox/build/esm/type/never/never.mjs
794
+ function Never(options) {
795
+ return CreateType({ [Kind]: "Never", not: {} }, options);
796
+ }
797
+
798
+ // node_modules/@sinclair/typebox/build/esm/type/mapped/mapped-result.mjs
799
+ function MappedResult(properties) {
800
+ return CreateType({
801
+ [Kind]: "MappedResult",
802
+ properties
803
+ });
804
+ }
805
+
806
+ // node_modules/@sinclair/typebox/build/esm/type/constructor/constructor.mjs
807
+ function Constructor(parameters, returns, options) {
808
+ return CreateType({ [Kind]: "Constructor", type: "Constructor", parameters, returns }, options);
809
+ }
810
+
811
+ // node_modules/@sinclair/typebox/build/esm/type/function/function.mjs
812
+ function Function(parameters, returns, options) {
813
+ return CreateType({ [Kind]: "Function", type: "Function", parameters, returns }, options);
814
+ }
815
+
816
+ // node_modules/@sinclair/typebox/build/esm/type/union/union-create.mjs
817
+ function UnionCreate(T, options) {
818
+ return CreateType({ [Kind]: "Union", anyOf: T }, options);
819
+ }
820
+
821
+ // node_modules/@sinclair/typebox/build/esm/type/union/union-evaluated.mjs
822
+ function IsUnionOptional(types) {
823
+ return types.some((type) => IsOptional(type));
824
+ }
825
+ function RemoveOptionalFromRest(types) {
826
+ return types.map((left) => IsOptional(left) ? RemoveOptionalFromType(left) : left);
827
+ }
828
+ function RemoveOptionalFromType(T) {
829
+ return Discard(T, [OptionalKind]);
830
+ }
831
+ function ResolveUnion(types, options) {
832
+ const isOptional = IsUnionOptional(types);
833
+ return isOptional ? Optional(UnionCreate(RemoveOptionalFromRest(types), options)) : UnionCreate(RemoveOptionalFromRest(types), options);
834
+ }
835
+ function UnionEvaluated(T, options) {
836
+ return T.length === 1 ? CreateType(T[0], options) : T.length === 0 ? Never(options) : ResolveUnion(T, options);
837
+ }
838
+
839
+ // node_modules/@sinclair/typebox/build/esm/type/union/union.mjs
840
+ function Union(types, options) {
841
+ return types.length === 0 ? Never(options) : types.length === 1 ? CreateType(types[0], options) : UnionCreate(types, options);
842
+ }
843
+
844
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/parse.mjs
845
+ var TemplateLiteralParserError = class extends TypeBoxError {
846
+ };
847
+ function Unescape(pattern) {
848
+ return pattern.replace(/\\\$/g, "$").replace(/\\\*/g, "*").replace(/\\\^/g, "^").replace(/\\\|/g, "|").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
849
+ }
850
+ function IsNonEscaped(pattern, index, char) {
851
+ return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
852
+ }
853
+ function IsOpenParen(pattern, index) {
854
+ return IsNonEscaped(pattern, index, "(");
855
+ }
856
+ function IsCloseParen(pattern, index) {
857
+ return IsNonEscaped(pattern, index, ")");
858
+ }
859
+ function IsSeparator(pattern, index) {
860
+ return IsNonEscaped(pattern, index, "|");
861
+ }
862
+ function IsGroup(pattern) {
863
+ if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1)))
864
+ return false;
865
+ let count = 0;
866
+ for (let index = 0; index < pattern.length; index++) {
867
+ if (IsOpenParen(pattern, index))
868
+ count += 1;
869
+ if (IsCloseParen(pattern, index))
870
+ count -= 1;
871
+ if (count === 0 && index !== pattern.length - 1)
872
+ return false;
873
+ }
874
+ return true;
875
+ }
876
+ function InGroup(pattern) {
877
+ return pattern.slice(1, pattern.length - 1);
878
+ }
879
+ function IsPrecedenceOr(pattern) {
880
+ let count = 0;
881
+ for (let index = 0; index < pattern.length; index++) {
882
+ if (IsOpenParen(pattern, index))
883
+ count += 1;
884
+ if (IsCloseParen(pattern, index))
885
+ count -= 1;
886
+ if (IsSeparator(pattern, index) && count === 0)
887
+ return true;
888
+ }
889
+ return false;
890
+ }
891
+ function IsPrecedenceAnd(pattern) {
892
+ for (let index = 0; index < pattern.length; index++) {
893
+ if (IsOpenParen(pattern, index))
894
+ return true;
895
+ }
896
+ return false;
897
+ }
898
+ function Or(pattern) {
899
+ let [count, start] = [0, 0];
900
+ const expressions = [];
901
+ for (let index = 0; index < pattern.length; index++) {
902
+ if (IsOpenParen(pattern, index))
903
+ count += 1;
904
+ if (IsCloseParen(pattern, index))
905
+ count -= 1;
906
+ if (IsSeparator(pattern, index) && count === 0) {
907
+ const range2 = pattern.slice(start, index);
908
+ if (range2.length > 0)
909
+ expressions.push(TemplateLiteralParse(range2));
910
+ start = index + 1;
911
+ }
912
+ }
913
+ const range = pattern.slice(start);
914
+ if (range.length > 0)
915
+ expressions.push(TemplateLiteralParse(range));
916
+ if (expressions.length === 0)
917
+ return { type: "const", const: "" };
918
+ if (expressions.length === 1)
919
+ return expressions[0];
920
+ return { type: "or", expr: expressions };
921
+ }
922
+ function And(pattern) {
923
+ function Group(value, index) {
924
+ if (!IsOpenParen(value, index))
925
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
926
+ let count = 0;
927
+ for (let scan = index; scan < value.length; scan++) {
928
+ if (IsOpenParen(value, scan))
929
+ count += 1;
930
+ if (IsCloseParen(value, scan))
931
+ count -= 1;
932
+ if (count === 0)
933
+ return [index, scan];
934
+ }
935
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
936
+ }
937
+ function Range(pattern2, index) {
938
+ for (let scan = index; scan < pattern2.length; scan++) {
939
+ if (IsOpenParen(pattern2, scan))
940
+ return [index, scan];
941
+ }
942
+ return [index, pattern2.length];
943
+ }
944
+ const expressions = [];
945
+ for (let index = 0; index < pattern.length; index++) {
946
+ if (IsOpenParen(pattern, index)) {
947
+ const [start, end] = Group(pattern, index);
948
+ const range = pattern.slice(start, end + 1);
949
+ expressions.push(TemplateLiteralParse(range));
950
+ index = end;
951
+ } else {
952
+ const [start, end] = Range(pattern, index);
953
+ const range = pattern.slice(start, end);
954
+ if (range.length > 0)
955
+ expressions.push(TemplateLiteralParse(range));
956
+ index = end - 1;
957
+ }
958
+ }
959
+ return expressions.length === 0 ? { type: "const", const: "" } : expressions.length === 1 ? expressions[0] : { type: "and", expr: expressions };
960
+ }
961
+ function TemplateLiteralParse(pattern) {
962
+ return IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) : IsPrecedenceOr(pattern) ? Or(pattern) : IsPrecedenceAnd(pattern) ? And(pattern) : { type: "const", const: Unescape(pattern) };
963
+ }
964
+ function TemplateLiteralParseExact(pattern) {
965
+ return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
966
+ }
967
+
968
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/finite.mjs
969
+ var TemplateLiteralFiniteError = class extends TypeBoxError {
970
+ };
971
+ function IsNumberExpression(expression) {
972
+ 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]*";
973
+ }
974
+ function IsBooleanExpression(expression) {
975
+ 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";
976
+ }
977
+ function IsStringExpression(expression) {
978
+ return expression.type === "const" && expression.const === ".*";
979
+ }
980
+ function IsTemplateLiteralExpressionFinite(expression) {
981
+ 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 : (() => {
982
+ throw new TemplateLiteralFiniteError(`Unknown expression type`);
983
+ })();
984
+ }
985
+ function IsTemplateLiteralFinite(schema) {
986
+ const expression = TemplateLiteralParseExact(schema.pattern);
987
+ return IsTemplateLiteralExpressionFinite(expression);
988
+ }
989
+
990
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/generate.mjs
991
+ var TemplateLiteralGenerateError = class extends TypeBoxError {
992
+ };
993
+ function* GenerateReduce(buffer) {
994
+ if (buffer.length === 1)
995
+ return yield* buffer[0];
996
+ for (const left of buffer[0]) {
997
+ for (const right of GenerateReduce(buffer.slice(1))) {
998
+ yield `${left}${right}`;
999
+ }
1000
+ }
1001
+ }
1002
+ function* GenerateAnd(expression) {
1003
+ return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
1004
+ }
1005
+ function* GenerateOr(expression) {
1006
+ for (const expr of expression.expr)
1007
+ yield* TemplateLiteralExpressionGenerate(expr);
1008
+ }
1009
+ function* GenerateConst(expression) {
1010
+ return yield expression.const;
1011
+ }
1012
+ function* TemplateLiteralExpressionGenerate(expression) {
1013
+ return expression.type === "and" ? yield* GenerateAnd(expression) : expression.type === "or" ? yield* GenerateOr(expression) : expression.type === "const" ? yield* GenerateConst(expression) : (() => {
1014
+ throw new TemplateLiteralGenerateError("Unknown expression");
1015
+ })();
1016
+ }
1017
+ function TemplateLiteralGenerate(schema) {
1018
+ const expression = TemplateLiteralParseExact(schema.pattern);
1019
+ return IsTemplateLiteralExpressionFinite(expression) ? [...TemplateLiteralExpressionGenerate(expression)] : [];
1020
+ }
1021
+
1022
+ // node_modules/@sinclair/typebox/build/esm/type/literal/literal.mjs
1023
+ function Literal(value, options) {
1024
+ return CreateType({
1025
+ [Kind]: "Literal",
1026
+ const: value,
1027
+ type: typeof value
1028
+ }, options);
1029
+ }
1030
+
1031
+ // node_modules/@sinclair/typebox/build/esm/type/boolean/boolean.mjs
1032
+ function Boolean(options) {
1033
+ return CreateType({ [Kind]: "Boolean", type: "boolean" }, options);
1034
+ }
1035
+
1036
+ // node_modules/@sinclair/typebox/build/esm/type/bigint/bigint.mjs
1037
+ function BigInt(options) {
1038
+ return CreateType({ [Kind]: "BigInt", type: "bigint" }, options);
1039
+ }
1040
+
1041
+ // node_modules/@sinclair/typebox/build/esm/type/number/number.mjs
1042
+ function Number2(options) {
1043
+ return CreateType({ [Kind]: "Number", type: "number" }, options);
1044
+ }
1045
+
1046
+ // node_modules/@sinclair/typebox/build/esm/type/string/string.mjs
1047
+ function String2(options) {
1048
+ return CreateType({ [Kind]: "String", type: "string" }, options);
1049
+ }
1050
+
1051
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/syntax.mjs
1052
+ function* FromUnion(syntax) {
1053
+ const trim = syntax.trim().replace(/"|'/g, "");
1054
+ return trim === "boolean" ? yield Boolean() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt() : trim === "string" ? yield String2() : yield (() => {
1055
+ const literals = trim.split("|").map((literal) => Literal(literal.trim()));
1056
+ return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
1057
+ })();
1058
+ }
1059
+ function* FromTerminal(syntax) {
1060
+ if (syntax[1] !== "{") {
1061
+ const L = Literal("$");
1062
+ const R = FromSyntax(syntax.slice(1));
1063
+ return yield* [L, ...R];
1064
+ }
1065
+ for (let i = 2; i < syntax.length; i++) {
1066
+ if (syntax[i] === "}") {
1067
+ const L = FromUnion(syntax.slice(2, i));
1068
+ const R = FromSyntax(syntax.slice(i + 1));
1069
+ return yield* [...L, ...R];
1070
+ }
1071
+ }
1072
+ yield Literal(syntax);
1073
+ }
1074
+ function* FromSyntax(syntax) {
1075
+ for (let i = 0; i < syntax.length; i++) {
1076
+ if (syntax[i] === "$") {
1077
+ const L = Literal(syntax.slice(0, i));
1078
+ const R = FromTerminal(syntax.slice(i));
1079
+ return yield* [L, ...R];
1080
+ }
1081
+ }
1082
+ yield Literal(syntax);
1083
+ }
1084
+ function TemplateLiteralSyntax(syntax) {
1085
+ return [...FromSyntax(syntax)];
1086
+ }
1087
+
1088
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/pattern.mjs
1089
+ var TemplateLiteralPatternError = class extends TypeBoxError {
1090
+ };
1091
+ function Escape(value) {
1092
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1093
+ }
1094
+ function Visit2(schema, acc) {
1095
+ 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}` : (() => {
1096
+ throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
1097
+ })();
1098
+ }
1099
+ function TemplateLiteralPattern(kinds) {
1100
+ return `^${kinds.map((schema) => Visit2(schema, "")).join("")}$`;
1101
+ }
1102
+
1103
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/union.mjs
1104
+ function TemplateLiteralToUnion(schema) {
1105
+ const R = TemplateLiteralGenerate(schema);
1106
+ const L = R.map((S) => Literal(S));
1107
+ return UnionEvaluated(L);
1108
+ }
1109
+
1110
+ // node_modules/@sinclair/typebox/build/esm/type/template-literal/template-literal.mjs
1111
+ function TemplateLiteral(unresolved, options) {
1112
+ const pattern = IsString(unresolved) ? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved)) : TemplateLiteralPattern(unresolved);
1113
+ return CreateType({ [Kind]: "TemplateLiteral", type: "string", pattern }, options);
1114
+ }
1115
+
1116
+ // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-property-keys.mjs
1117
+ function FromTemplateLiteral(templateLiteral) {
1118
+ const keys = TemplateLiteralGenerate(templateLiteral);
1119
+ return keys.map((key) => key.toString());
1120
+ }
1121
+ function FromUnion2(types) {
1122
+ const result = [];
1123
+ for (const type of types)
1124
+ result.push(...IndexPropertyKeys(type));
1125
+ return result;
1126
+ }
1127
+ function FromLiteral(literalValue) {
1128
+ return [literalValue.toString()];
1129
+ }
1130
+ function IndexPropertyKeys(type) {
1131
+ return [...new Set(IsTemplateLiteral(type) ? FromTemplateLiteral(type) : IsUnion(type) ? FromUnion2(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : IsNumber3(type) ? ["[number]"] : IsInteger(type) ? ["[number]"] : [])];
1132
+ }
1133
+
1134
+ // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-result.mjs
1135
+ function FromProperties(type, properties, options) {
1136
+ const result = {};
1137
+ for (const K2 of Object.getOwnPropertyNames(properties)) {
1138
+ result[K2] = Index(type, IndexPropertyKeys(properties[K2]), options);
1139
+ }
1140
+ return result;
1141
+ }
1142
+ function FromMappedResult(type, mappedResult, options) {
1143
+ return FromProperties(type, mappedResult.properties, options);
1144
+ }
1145
+ function IndexFromMappedResult(type, mappedResult, options) {
1146
+ const properties = FromMappedResult(type, mappedResult, options);
1147
+ return MappedResult(properties);
1148
+ }
1149
+
1150
+ // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed.mjs
1151
+ function FromRest(types, key) {
1152
+ return types.map((type) => IndexFromPropertyKey(type, key));
1153
+ }
1154
+ function FromIntersectRest(types) {
1155
+ return types.filter((type) => !IsNever(type));
1156
+ }
1157
+ function FromIntersect(types, key) {
1158
+ return IntersectEvaluated(FromIntersectRest(FromRest(types, key)));
1159
+ }
1160
+ function FromUnionRest(types) {
1161
+ return types.some((L) => IsNever(L)) ? [] : types;
1162
+ }
1163
+ function FromUnion3(types, key) {
1164
+ return UnionEvaluated(FromUnionRest(FromRest(types, key)));
1165
+ }
1166
+ function FromTuple(types, key) {
1167
+ return key in types ? types[key] : key === "[number]" ? UnionEvaluated(types) : Never();
1168
+ }
1169
+ function FromArray(type, key) {
1170
+ return key === "[number]" ? type : Never();
1171
+ }
1172
+ function FromProperty(properties, propertyKey) {
1173
+ return propertyKey in properties ? properties[propertyKey] : Never();
1174
+ }
1175
+ function IndexFromPropertyKey(type, propertyKey) {
1176
+ 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();
1177
+ }
1178
+ function IndexFromPropertyKeys(type, propertyKeys) {
1179
+ return propertyKeys.map((propertyKey) => IndexFromPropertyKey(type, propertyKey));
1180
+ }
1181
+ function FromSchema(type, propertyKeys) {
1182
+ return UnionEvaluated(IndexFromPropertyKeys(type, propertyKeys));
1183
+ }
1184
+ function Index(type, key, options) {
1185
+ if (IsRef(type) || IsRef(key)) {
1186
+ const error = `Index types using Ref parameters require both Type and Key to be of TSchema`;
1187
+ if (!IsSchema(type) || !IsSchema(key))
1188
+ throw new TypeBoxError(error);
1189
+ return Computed("Index", [type, key]);
1190
+ }
1191
+ if (IsMappedResult(key))
1192
+ return IndexFromMappedResult(type, key, options);
1193
+ if (IsMappedKey(key))
1194
+ return IndexFromMappedKey(type, key, options);
1195
+ return CreateType(IsSchema(key) ? FromSchema(type, IndexPropertyKeys(key)) : FromSchema(type, key), options);
1196
+ }
1197
+
1198
+ // node_modules/@sinclair/typebox/build/esm/type/indexed/indexed-from-mapped-key.mjs
1199
+ function MappedIndexPropertyKey(type, key, options) {
1200
+ return { [key]: Index(type, [key], Clone(options)) };
1201
+ }
1202
+ function MappedIndexPropertyKeys(type, propertyKeys, options) {
1203
+ return propertyKeys.reduce((result, left) => {
1204
+ return { ...result, ...MappedIndexPropertyKey(type, left, options) };
1205
+ }, {});
1206
+ }
1207
+ function MappedIndexProperties(type, mappedKey, options) {
1208
+ return MappedIndexPropertyKeys(type, mappedKey.keys, options);
1209
+ }
1210
+ function IndexFromMappedKey(type, mappedKey, options) {
1211
+ const properties = MappedIndexProperties(type, mappedKey, options);
1212
+ return MappedResult(properties);
1213
+ }
1214
+
1215
+ // node_modules/@sinclair/typebox/build/esm/type/iterator/iterator.mjs
1216
+ function Iterator(items, options) {
1217
+ return CreateType({ [Kind]: "Iterator", type: "Iterator", items }, options);
1218
+ }
1219
+
1220
+ // node_modules/@sinclair/typebox/build/esm/type/object/object.mjs
1221
+ function RequiredArray(properties) {
1222
+ return globalThis.Object.keys(properties).filter((key) => !IsOptional(properties[key]));
1223
+ }
1224
+ function _Object(properties, options) {
1225
+ const required = RequiredArray(properties);
1226
+ const schema = required.length > 0 ? { [Kind]: "Object", type: "object", required, properties } : { [Kind]: "Object", type: "object", properties };
1227
+ return CreateType(schema, options);
1228
+ }
1229
+ var Object2 = _Object;
1230
+
1231
+ // node_modules/@sinclair/typebox/build/esm/type/promise/promise.mjs
1232
+ function Promise2(item, options) {
1233
+ return CreateType({ [Kind]: "Promise", type: "Promise", item }, options);
1234
+ }
1235
+
1236
+ // node_modules/@sinclair/typebox/build/esm/type/readonly/readonly.mjs
1237
+ function RemoveReadonly(schema) {
1238
+ return CreateType(Discard(schema, [ReadonlyKind]));
1239
+ }
1240
+ function AddReadonly(schema) {
1241
+ return CreateType({ ...schema, [ReadonlyKind]: "Readonly" });
1242
+ }
1243
+ function ReadonlyWithFlag(schema, F) {
1244
+ return F === false ? RemoveReadonly(schema) : AddReadonly(schema);
1245
+ }
1246
+ function Readonly(schema, enable) {
1247
+ const F = enable ?? true;
1248
+ return IsMappedResult(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
1249
+ }
1250
+
1251
+ // node_modules/@sinclair/typebox/build/esm/type/readonly/readonly-from-mapped-result.mjs
1252
+ function FromProperties2(K, F) {
1253
+ const Acc = {};
1254
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K))
1255
+ Acc[K2] = Readonly(K[K2], F);
1256
+ return Acc;
1257
+ }
1258
+ function FromMappedResult2(R, F) {
1259
+ return FromProperties2(R.properties, F);
1260
+ }
1261
+ function ReadonlyFromMappedResult(R, F) {
1262
+ const P = FromMappedResult2(R, F);
1263
+ return MappedResult(P);
1264
+ }
1265
+
1266
+ // node_modules/@sinclair/typebox/build/esm/type/tuple/tuple.mjs
1267
+ function Tuple(types, options) {
1268
+ 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);
1269
+ }
1270
+
1271
+ // node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs
1272
+ function FromMappedResult3(K, P) {
1273
+ return K in P ? FromSchemaType(K, P[K]) : MappedResult(P);
1274
+ }
1275
+ function MappedKeyToKnownMappedResultProperties(K) {
1276
+ return { [K]: Literal(K) };
1277
+ }
1278
+ function MappedKeyToUnknownMappedResultProperties(P) {
1279
+ const Acc = {};
1280
+ for (const L of P)
1281
+ Acc[L] = Literal(L);
1282
+ return Acc;
1283
+ }
1284
+ function MappedKeyToMappedResultProperties(K, P) {
1285
+ return SetIncludes(P, K) ? MappedKeyToKnownMappedResultProperties(K) : MappedKeyToUnknownMappedResultProperties(P);
1286
+ }
1287
+ function FromMappedKey(K, P) {
1288
+ const R = MappedKeyToMappedResultProperties(K, P);
1289
+ return FromMappedResult3(K, R);
1290
+ }
1291
+ function FromRest2(K, T) {
1292
+ return T.map((L) => FromSchemaType(K, L));
1293
+ }
1294
+ function FromProperties3(K, T) {
1295
+ const Acc = {};
1296
+ for (const K2 of globalThis.Object.getOwnPropertyNames(T))
1297
+ Acc[K2] = FromSchemaType(K, T[K2]);
1298
+ return Acc;
1299
+ }
1300
+ function FromSchemaType(K, T) {
1301
+ const options = { ...T };
1302
+ return (
1303
+ // unevaluated modifier types
1304
+ IsOptional(T) ? Optional(FromSchemaType(K, Discard(T, [OptionalKind]))) : IsReadonly(T) ? Readonly(FromSchemaType(K, Discard(T, [ReadonlyKind]))) : (
1305
+ // unevaluated mapped types
1306
+ IsMappedResult(T) ? FromMappedResult3(K, T.properties) : IsMappedKey(T) ? FromMappedKey(K, T.keys) : (
1307
+ // unevaluated types
1308
+ 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
1309
+ )
1310
+ )
1311
+ );
1312
+ }
1313
+ function MappedFunctionReturnType(K, T) {
1314
+ const Acc = {};
1315
+ for (const L of K)
1316
+ Acc[L] = FromSchemaType(L, T);
1317
+ return Acc;
1318
+ }
1319
+ function Mapped(key, map, options) {
1320
+ const K = IsSchema(key) ? IndexPropertyKeys(key) : key;
1321
+ const RT = map({ [Kind]: "MappedKey", keys: K });
1322
+ const R = MappedFunctionReturnType(K, RT);
1323
+ return Object2(R, options);
1324
+ }
1325
+
1326
+ // node_modules/@sinclair/typebox/build/esm/type/optional/optional.mjs
1327
+ function RemoveOptional(schema) {
1328
+ return CreateType(Discard(schema, [OptionalKind]));
1329
+ }
1330
+ function AddOptional(schema) {
1331
+ return CreateType({ ...schema, [OptionalKind]: "Optional" });
1332
+ }
1333
+ function OptionalWithFlag(schema, F) {
1334
+ return F === false ? RemoveOptional(schema) : AddOptional(schema);
1335
+ }
1336
+ function Optional(schema, enable) {
1337
+ const F = enable ?? true;
1338
+ return IsMappedResult(schema) ? OptionalFromMappedResult(schema, F) : OptionalWithFlag(schema, F);
1339
+ }
1340
+
1341
+ // node_modules/@sinclair/typebox/build/esm/type/optional/optional-from-mapped-result.mjs
1342
+ function FromProperties4(P, F) {
1343
+ const Acc = {};
1344
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
1345
+ Acc[K2] = Optional(P[K2], F);
1346
+ return Acc;
1347
+ }
1348
+ function FromMappedResult4(R, F) {
1349
+ return FromProperties4(R.properties, F);
1350
+ }
1351
+ function OptionalFromMappedResult(R, F) {
1352
+ const P = FromMappedResult4(R, F);
1353
+ return MappedResult(P);
1354
+ }
1355
+
1356
+ // node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-create.mjs
1357
+ function IntersectCreate(T, options = {}) {
1358
+ const allObjects = T.every((schema) => IsObject3(schema));
1359
+ const clonedUnevaluatedProperties = IsSchema(options.unevaluatedProperties) ? { unevaluatedProperties: options.unevaluatedProperties } : {};
1360
+ return CreateType(options.unevaluatedProperties === false || IsSchema(options.unevaluatedProperties) || allObjects ? { ...clonedUnevaluatedProperties, [Kind]: "Intersect", type: "object", allOf: T } : { ...clonedUnevaluatedProperties, [Kind]: "Intersect", allOf: T }, options);
1361
+ }
1362
+
1363
+ // node_modules/@sinclair/typebox/build/esm/type/intersect/intersect-evaluated.mjs
1364
+ function IsIntersectOptional(types) {
1365
+ return types.every((left) => IsOptional(left));
1366
+ }
1367
+ function RemoveOptionalFromType2(type) {
1368
+ return Discard(type, [OptionalKind]);
1369
+ }
1370
+ function RemoveOptionalFromRest2(types) {
1371
+ return types.map((left) => IsOptional(left) ? RemoveOptionalFromType2(left) : left);
1372
+ }
1373
+ function ResolveIntersect(types, options) {
1374
+ return IsIntersectOptional(types) ? Optional(IntersectCreate(RemoveOptionalFromRest2(types), options)) : IntersectCreate(RemoveOptionalFromRest2(types), options);
1375
+ }
1376
+ function IntersectEvaluated(types, options = {}) {
1377
+ if (types.length === 1)
1378
+ return CreateType(types[0], options);
1379
+ if (types.length === 0)
1380
+ return Never(options);
1381
+ if (types.some((schema) => IsTransform(schema)))
1382
+ throw new Error("Cannot intersect transform types");
1383
+ return ResolveIntersect(types, options);
1384
+ }
1385
+
1386
+ // node_modules/@sinclair/typebox/build/esm/type/intersect/intersect.mjs
1387
+ function Intersect(types, options) {
1388
+ if (types.length === 1)
1389
+ return CreateType(types[0], options);
1390
+ if (types.length === 0)
1391
+ return Never(options);
1392
+ if (types.some((schema) => IsTransform(schema)))
1393
+ throw new Error("Cannot intersect transform types");
1394
+ return IntersectCreate(types, options);
1395
+ }
1396
+
1397
+ // node_modules/@sinclair/typebox/build/esm/type/ref/ref.mjs
1398
+ function Ref(...args) {
1399
+ const [$ref, options] = typeof args[0] === "string" ? [args[0], args[1]] : [args[0].$id, args[1]];
1400
+ if (typeof $ref !== "string")
1401
+ throw new TypeBoxError("Ref: $ref must be a string");
1402
+ return CreateType({ [Kind]: "Ref", $ref }, options);
1403
+ }
1404
+
1405
+ // node_modules/@sinclair/typebox/build/esm/type/awaited/awaited.mjs
1406
+ function FromComputed(target, parameters) {
1407
+ return Computed("Awaited", [Computed(target, parameters)]);
1408
+ }
1409
+ function FromRef($ref) {
1410
+ return Computed("Awaited", [Ref($ref)]);
1411
+ }
1412
+ function FromIntersect2(types) {
1413
+ return Intersect(FromRest3(types));
1414
+ }
1415
+ function FromUnion4(types) {
1416
+ return Union(FromRest3(types));
1417
+ }
1418
+ function FromPromise(type) {
1419
+ return Awaited(type);
1420
+ }
1421
+ function FromRest3(types) {
1422
+ return types.map((type) => Awaited(type));
1423
+ }
1424
+ function Awaited(type, options) {
1425
+ 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);
1426
+ }
1427
+
1428
+ // node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-property-keys.mjs
1429
+ function FromRest4(types) {
1430
+ const result = [];
1431
+ for (const L of types)
1432
+ result.push(KeyOfPropertyKeys(L));
1433
+ return result;
1434
+ }
1435
+ function FromIntersect3(types) {
1436
+ const propertyKeysArray = FromRest4(types);
1437
+ const propertyKeys = SetUnionMany(propertyKeysArray);
1438
+ return propertyKeys;
1439
+ }
1440
+ function FromUnion5(types) {
1441
+ const propertyKeysArray = FromRest4(types);
1442
+ const propertyKeys = SetIntersectMany(propertyKeysArray);
1443
+ return propertyKeys;
1444
+ }
1445
+ function FromTuple2(types) {
1446
+ return types.map((_, indexer) => indexer.toString());
1447
+ }
1448
+ function FromArray2(_) {
1449
+ return ["[number]"];
1450
+ }
1451
+ function FromProperties5(T) {
1452
+ return globalThis.Object.getOwnPropertyNames(T);
1453
+ }
1454
+ function FromPatternProperties(patternProperties) {
1455
+ if (!includePatternProperties)
1456
+ return [];
1457
+ const patternPropertyKeys = globalThis.Object.getOwnPropertyNames(patternProperties);
1458
+ return patternPropertyKeys.map((key) => {
1459
+ return key[0] === "^" && key[key.length - 1] === "$" ? key.slice(1, key.length - 1) : key;
1460
+ });
1461
+ }
1462
+ function KeyOfPropertyKeys(type) {
1463
+ 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) : [];
1464
+ }
1465
+ var includePatternProperties = false;
1466
+
1467
+ // node_modules/@sinclair/typebox/build/esm/type/keyof/keyof.mjs
1468
+ function FromComputed2(target, parameters) {
1469
+ return Computed("KeyOf", [Computed(target, parameters)]);
1470
+ }
1471
+ function FromRef2($ref) {
1472
+ return Computed("KeyOf", [Ref($ref)]);
1473
+ }
1474
+ function KeyOfFromType(type, options) {
1475
+ const propertyKeys = KeyOfPropertyKeys(type);
1476
+ const propertyKeyTypes = KeyOfPropertyKeysToRest(propertyKeys);
1477
+ const result = UnionEvaluated(propertyKeyTypes);
1478
+ return CreateType(result, options);
1479
+ }
1480
+ function KeyOfPropertyKeysToRest(propertyKeys) {
1481
+ return propertyKeys.map((L) => L === "[number]" ? Number2() : Literal(L));
1482
+ }
1483
+ function KeyOf(type, options) {
1484
+ return IsComputed(type) ? FromComputed2(type.target, type.parameters) : IsRef(type) ? FromRef2(type.$ref) : IsMappedResult(type) ? KeyOfFromMappedResult(type, options) : KeyOfFromType(type, options);
1485
+ }
1486
+
1487
+ // node_modules/@sinclair/typebox/build/esm/type/keyof/keyof-from-mapped-result.mjs
1488
+ function FromProperties6(properties, options) {
1489
+ const result = {};
1490
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
1491
+ result[K2] = KeyOf(properties[K2], Clone(options));
1492
+ return result;
1493
+ }
1494
+ function FromMappedResult5(mappedResult, options) {
1495
+ return FromProperties6(mappedResult.properties, options);
1496
+ }
1497
+ function KeyOfFromMappedResult(mappedResult, options) {
1498
+ const properties = FromMappedResult5(mappedResult, options);
1499
+ return MappedResult(properties);
1500
+ }
1501
+
1502
+ // node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs
1503
+ function CompositeKeys(T) {
1504
+ const Acc = [];
1505
+ for (const L of T)
1506
+ Acc.push(...KeyOfPropertyKeys(L));
1507
+ return SetDistinct(Acc);
1508
+ }
1509
+ function FilterNever(T) {
1510
+ return T.filter((L) => !IsNever(L));
1511
+ }
1512
+ function CompositeProperty(T, K) {
1513
+ const Acc = [];
1514
+ for (const L of T)
1515
+ Acc.push(...IndexFromPropertyKeys(L, [K]));
1516
+ return FilterNever(Acc);
1517
+ }
1518
+ function CompositeProperties(T, K) {
1519
+ const Acc = {};
1520
+ for (const L of K) {
1521
+ Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
1522
+ }
1523
+ return Acc;
1524
+ }
1525
+ function Composite(T, options) {
1526
+ const K = CompositeKeys(T);
1527
+ const P = CompositeProperties(T, K);
1528
+ const R = Object2(P, options);
1529
+ return R;
1530
+ }
1531
+
1532
+ // node_modules/@sinclair/typebox/build/esm/type/date/date.mjs
1533
+ function Date2(options) {
1534
+ return CreateType({ [Kind]: "Date", type: "Date" }, options);
1535
+ }
1536
+
1537
+ // node_modules/@sinclair/typebox/build/esm/type/null/null.mjs
1538
+ function Null(options) {
1539
+ return CreateType({ [Kind]: "Null", type: "null" }, options);
1540
+ }
1541
+
1542
+ // node_modules/@sinclair/typebox/build/esm/type/symbol/symbol.mjs
1543
+ function Symbol2(options) {
1544
+ return CreateType({ [Kind]: "Symbol", type: "symbol" }, options);
1545
+ }
1546
+
1547
+ // node_modules/@sinclair/typebox/build/esm/type/undefined/undefined.mjs
1548
+ function Undefined(options) {
1549
+ return CreateType({ [Kind]: "Undefined", type: "undefined" }, options);
1550
+ }
1551
+
1552
+ // node_modules/@sinclair/typebox/build/esm/type/uint8array/uint8array.mjs
1553
+ function Uint8Array2(options) {
1554
+ return CreateType({ [Kind]: "Uint8Array", type: "Uint8Array" }, options);
1555
+ }
1556
+
1557
+ // node_modules/@sinclair/typebox/build/esm/type/unknown/unknown.mjs
1558
+ function Unknown(options) {
1559
+ return CreateType({ [Kind]: "Unknown" }, options);
1560
+ }
1561
+
1562
+ // node_modules/@sinclair/typebox/build/esm/type/const/const.mjs
1563
+ function FromArray3(T) {
1564
+ return T.map((L) => FromValue(L, false));
1565
+ }
1566
+ function FromProperties7(value) {
1567
+ const Acc = {};
1568
+ for (const K of globalThis.Object.getOwnPropertyNames(value))
1569
+ Acc[K] = Readonly(FromValue(value[K], false));
1570
+ return Acc;
1571
+ }
1572
+ function ConditionalReadonly(T, root) {
1573
+ return root === true ? T : Readonly(T);
1574
+ }
1575
+ function FromValue(value, root) {
1576
+ 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({});
1577
+ }
1578
+ function Const(T, options) {
1579
+ return CreateType(FromValue(T, true), options);
1580
+ }
1581
+
1582
+ // node_modules/@sinclair/typebox/build/esm/type/constructor-parameters/constructor-parameters.mjs
1583
+ function ConstructorParameters(schema, options) {
1584
+ return IsConstructor(schema) ? Tuple(schema.parameters, options) : Never(options);
1585
+ }
1586
+
1587
+ // node_modules/@sinclair/typebox/build/esm/type/enum/enum.mjs
1588
+ function Enum(item, options) {
1589
+ if (IsUndefined(item))
1590
+ throw new Error("Enum undefined or empty");
1591
+ const values1 = globalThis.Object.getOwnPropertyNames(item).filter((key) => isNaN(key)).map((key) => item[key]);
1592
+ const values2 = [...new Set(values1)];
1593
+ const anyOf = values2.map((value) => Literal(value));
1594
+ return Union(anyOf, { ...options, [Hint]: "Enum" });
1595
+ }
1596
+
1597
+ // node_modules/@sinclair/typebox/build/esm/type/extends/extends-check.mjs
1598
+ var ExtendsResolverError = class extends TypeBoxError {
1599
+ };
1600
+ var ExtendsResult;
1601
+ (function(ExtendsResult2) {
1602
+ ExtendsResult2[ExtendsResult2["Union"] = 0] = "Union";
1603
+ ExtendsResult2[ExtendsResult2["True"] = 1] = "True";
1604
+ ExtendsResult2[ExtendsResult2["False"] = 2] = "False";
1605
+ })(ExtendsResult || (ExtendsResult = {}));
1606
+ function IntoBooleanResult(result) {
1607
+ return result === ExtendsResult.False ? result : ExtendsResult.True;
1608
+ }
1609
+ function Throw(message) {
1610
+ throw new ExtendsResolverError(message);
1611
+ }
1612
+ function IsStructuralRight(right) {
1613
+ return type_exports.IsNever(right) || type_exports.IsIntersect(right) || type_exports.IsUnion(right) || type_exports.IsUnknown(right) || type_exports.IsAny(right);
1614
+ }
1615
+ function StructuralRight(left, right) {
1616
+ return type_exports.IsNever(right) ? FromNeverRight(left, right) : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : Throw("StructuralRight");
1617
+ }
1618
+ function FromAnyRight(left, right) {
1619
+ return ExtendsResult.True;
1620
+ }
1621
+ function FromAny(left, right) {
1622
+ return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) && right.anyOf.some((schema) => type_exports.IsAny(schema) || type_exports.IsUnknown(schema)) ? ExtendsResult.True : type_exports.IsUnion(right) ? ExtendsResult.Union : type_exports.IsUnknown(right) ? ExtendsResult.True : type_exports.IsAny(right) ? ExtendsResult.True : ExtendsResult.Union;
1623
+ }
1624
+ function FromArrayRight(left, right) {
1625
+ return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) ? ExtendsResult.True : ExtendsResult.False;
1626
+ }
1627
+ function FromArray4(left, right) {
1628
+ return type_exports.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsArray(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
1629
+ }
1630
+ function FromAsyncIterator(left, right) {
1631
+ return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsAsyncIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
1632
+ }
1633
+ function FromBigInt(left, right) {
1634
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsBigInt(right) ? ExtendsResult.True : ExtendsResult.False;
1635
+ }
1636
+ function FromBooleanRight(left, right) {
1637
+ return type_exports.IsLiteralBoolean(left) ? ExtendsResult.True : type_exports.IsBoolean(left) ? ExtendsResult.True : ExtendsResult.False;
1638
+ }
1639
+ function FromBoolean(left, right) {
1640
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsBoolean(right) ? ExtendsResult.True : ExtendsResult.False;
1641
+ }
1642
+ function FromConstructor(left, right) {
1643
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.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));
1644
+ }
1645
+ function FromDate(left, right) {
1646
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsDate(right) ? ExtendsResult.True : ExtendsResult.False;
1647
+ }
1648
+ function FromFunction(left, right) {
1649
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.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));
1650
+ }
1651
+ function FromIntegerRight(left, right) {
1652
+ return type_exports.IsLiteral(left) && value_exports.IsNumber(left.const) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
1653
+ }
1654
+ function FromInteger(left, right) {
1655
+ return type_exports.IsInteger(right) || type_exports.IsNumber(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : ExtendsResult.False;
1656
+ }
1657
+ function FromIntersectRight(left, right) {
1658
+ return right.allOf.every((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1659
+ }
1660
+ function FromIntersect4(left, right) {
1661
+ return left.allOf.some((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1662
+ }
1663
+ function FromIterator(left, right) {
1664
+ return IsStructuralRight(right) ? StructuralRight(left, right) : !type_exports.IsIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.items, right.items));
1665
+ }
1666
+ function FromLiteral2(left, right) {
1667
+ return type_exports.IsLiteral(right) && right.const === left.const ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsString(right) ? FromStringRight(left, right) : type_exports.IsNumber(right) ? FromNumberRight(left, right) : type_exports.IsInteger(right) ? FromIntegerRight(left, right) : type_exports.IsBoolean(right) ? FromBooleanRight(left, right) : ExtendsResult.False;
1668
+ }
1669
+ function FromNeverRight(left, right) {
1670
+ return ExtendsResult.False;
1671
+ }
1672
+ function FromNever(left, right) {
1673
+ return ExtendsResult.True;
1674
+ }
1675
+ function UnwrapTNot(schema) {
1676
+ let [current, depth] = [schema, 0];
1677
+ while (true) {
1678
+ if (!type_exports.IsNot(current))
1679
+ break;
1680
+ current = current.not;
1681
+ depth += 1;
1682
+ }
1683
+ return depth % 2 === 0 ? current : Unknown();
1684
+ }
1685
+ function FromNot(left, right) {
1686
+ return type_exports.IsNot(left) ? Visit3(UnwrapTNot(left), right) : type_exports.IsNot(right) ? Visit3(left, UnwrapTNot(right)) : Throw("Invalid fallthrough for Not");
1687
+ }
1688
+ function FromNull(left, right) {
1689
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsNull(right) ? ExtendsResult.True : ExtendsResult.False;
1690
+ }
1691
+ function FromNumberRight(left, right) {
1692
+ return type_exports.IsLiteralNumber(left) ? ExtendsResult.True : type_exports.IsNumber(left) || type_exports.IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
1693
+ }
1694
+ function FromNumber(left, right) {
1695
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsInteger(right) || type_exports.IsNumber(right) ? ExtendsResult.True : ExtendsResult.False;
1696
+ }
1697
+ function IsObjectPropertyCount(schema, count) {
1698
+ return Object.getOwnPropertyNames(schema.properties).length === count;
1699
+ }
1700
+ function IsObjectStringLike(schema) {
1701
+ return IsObjectArrayLike(schema);
1702
+ }
1703
+ function IsObjectSymbolLike(schema) {
1704
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "description" in schema.properties && type_exports.IsUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && (type_exports.IsString(schema.properties.description.anyOf[0]) && type_exports.IsUndefined(schema.properties.description.anyOf[1]) || type_exports.IsString(schema.properties.description.anyOf[1]) && type_exports.IsUndefined(schema.properties.description.anyOf[0]));
1705
+ }
1706
+ function IsObjectNumberLike(schema) {
1707
+ return IsObjectPropertyCount(schema, 0);
1708
+ }
1709
+ function IsObjectBooleanLike(schema) {
1710
+ return IsObjectPropertyCount(schema, 0);
1711
+ }
1712
+ function IsObjectBigIntLike(schema) {
1713
+ return IsObjectPropertyCount(schema, 0);
1714
+ }
1715
+ function IsObjectDateLike(schema) {
1716
+ return IsObjectPropertyCount(schema, 0);
1717
+ }
1718
+ function IsObjectUint8ArrayLike(schema) {
1719
+ return IsObjectArrayLike(schema);
1720
+ }
1721
+ function IsObjectFunctionLike(schema) {
1722
+ const length = Number2();
1723
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
1724
+ }
1725
+ function IsObjectConstructorLike(schema) {
1726
+ return IsObjectPropertyCount(schema, 0);
1727
+ }
1728
+ function IsObjectArrayLike(schema) {
1729
+ const length = Number2();
1730
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit3(schema.properties["length"], length)) === ExtendsResult.True;
1731
+ }
1732
+ function IsObjectPromiseLike(schema) {
1733
+ const then = Function([Any()], Any());
1734
+ return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "then" in schema.properties && IntoBooleanResult(Visit3(schema.properties["then"], then)) === ExtendsResult.True;
1735
+ }
1736
+ function Property(left, right) {
1737
+ return Visit3(left, right) === ExtendsResult.False ? ExtendsResult.False : type_exports.IsOptional(left) && !type_exports.IsOptional(right) ? ExtendsResult.False : ExtendsResult.True;
1738
+ }
1739
+ function FromObjectRight(left, right) {
1740
+ return type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : type_exports.IsNever(left) || type_exports.IsLiteralString(left) && IsObjectStringLike(right) || type_exports.IsLiteralNumber(left) && IsObjectNumberLike(right) || type_exports.IsLiteralBoolean(left) && IsObjectBooleanLike(right) || type_exports.IsSymbol(left) && IsObjectSymbolLike(right) || type_exports.IsBigInt(left) && IsObjectBigIntLike(right) || type_exports.IsString(left) && IsObjectStringLike(right) || type_exports.IsSymbol(left) && IsObjectSymbolLike(right) || type_exports.IsNumber(left) && IsObjectNumberLike(right) || type_exports.IsInteger(left) && IsObjectNumberLike(right) || type_exports.IsBoolean(left) && IsObjectBooleanLike(right) || type_exports.IsUint8Array(left) && IsObjectUint8ArrayLike(right) || type_exports.IsDate(left) && IsObjectDateLike(right) || type_exports.IsConstructor(left) && IsObjectConstructorLike(right) || type_exports.IsFunction(left) && IsObjectFunctionLike(right) ? ExtendsResult.True : type_exports.IsRecord(left) && type_exports.IsString(RecordKey(left)) ? (() => {
1741
+ return right[Hint] === "Record" ? ExtendsResult.True : ExtendsResult.False;
1742
+ })() : type_exports.IsRecord(left) && type_exports.IsNumber(RecordKey(left)) ? (() => {
1743
+ return IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False;
1744
+ })() : ExtendsResult.False;
1745
+ }
1746
+ function FromObject(left, right) {
1747
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : !type_exports.IsObject(right) ? ExtendsResult.False : (() => {
1748
+ for (const key of Object.getOwnPropertyNames(right.properties)) {
1749
+ if (!(key in left.properties) && !type_exports.IsOptional(right.properties[key])) {
1750
+ return ExtendsResult.False;
1751
+ }
1752
+ if (type_exports.IsOptional(right.properties[key])) {
1753
+ return ExtendsResult.True;
1754
+ }
1755
+ if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) {
1756
+ return ExtendsResult.False;
1757
+ }
1758
+ }
1759
+ return ExtendsResult.True;
1760
+ })();
1761
+ }
1762
+ function FromPromise2(left, right) {
1763
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True : !type_exports.IsPromise(right) ? ExtendsResult.False : IntoBooleanResult(Visit3(left.item, right.item));
1764
+ }
1765
+ function RecordKey(schema) {
1766
+ return PatternNumberExact in schema.patternProperties ? Number2() : PatternStringExact in schema.patternProperties ? String2() : Throw("Unknown record key pattern");
1767
+ }
1768
+ function RecordValue(schema) {
1769
+ return PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] : PatternStringExact in schema.patternProperties ? schema.patternProperties[PatternStringExact] : Throw("Unable to get record value schema");
1770
+ }
1771
+ function FromRecordRight(left, right) {
1772
+ const [Key, Value] = [RecordKey(right), RecordValue(right)];
1773
+ return type_exports.IsLiteralString(left) && type_exports.IsNumber(Key) && IntoBooleanResult(Visit3(left, Value)) === ExtendsResult.True ? ExtendsResult.True : type_exports.IsUint8Array(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsString(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsArray(left) && type_exports.IsNumber(Key) ? Visit3(left, Value) : type_exports.IsObject(left) ? (() => {
1774
+ for (const key of Object.getOwnPropertyNames(left.properties)) {
1775
+ if (Property(Value, left.properties[key]) === ExtendsResult.False) {
1776
+ return ExtendsResult.False;
1777
+ }
1778
+ }
1779
+ return ExtendsResult.True;
1780
+ })() : ExtendsResult.False;
1781
+ }
1782
+ function FromRecord(left, right) {
1783
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : !type_exports.IsRecord(right) ? ExtendsResult.False : Visit3(RecordValue(left), RecordValue(right));
1784
+ }
1785
+ function FromRegExp(left, right) {
1786
+ const L = type_exports.IsRegExp(left) ? String2() : left;
1787
+ const R = type_exports.IsRegExp(right) ? String2() : right;
1788
+ return Visit3(L, R);
1789
+ }
1790
+ function FromStringRight(left, right) {
1791
+ return type_exports.IsLiteral(left) && value_exports.IsString(left.const) ? ExtendsResult.True : type_exports.IsString(left) ? ExtendsResult.True : ExtendsResult.False;
1792
+ }
1793
+ function FromString(left, right) {
1794
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsString(right) ? ExtendsResult.True : ExtendsResult.False;
1795
+ }
1796
+ function FromSymbol(left, right) {
1797
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsSymbol(right) ? ExtendsResult.True : ExtendsResult.False;
1798
+ }
1799
+ function FromTemplateLiteral2(left, right) {
1800
+ return type_exports.IsTemplateLiteral(left) ? Visit3(TemplateLiteralToUnion(left), right) : type_exports.IsTemplateLiteral(right) ? Visit3(left, TemplateLiteralToUnion(right)) : Throw("Invalid fallthrough for TemplateLiteral");
1801
+ }
1802
+ function IsArrayOfTuple(left, right) {
1803
+ return type_exports.IsArray(right) && left.items !== void 0 && left.items.every((schema) => Visit3(schema, right.items) === ExtendsResult.True);
1804
+ }
1805
+ function FromTupleRight(left, right) {
1806
+ return type_exports.IsNever(left) ? ExtendsResult.True : type_exports.IsUnknown(left) ? ExtendsResult.False : type_exports.IsAny(left) ? ExtendsResult.Union : ExtendsResult.False;
1807
+ }
1808
+ function FromTuple3(left, right) {
1809
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : type_exports.IsArray(right) && IsArrayOfTuple(left, right) ? ExtendsResult.True : !type_exports.IsTuple(right) ? ExtendsResult.False : value_exports.IsUndefined(left.items) && !value_exports.IsUndefined(right.items) || !value_exports.IsUndefined(left.items) && value_exports.IsUndefined(right.items) ? ExtendsResult.False : value_exports.IsUndefined(left.items) && !value_exports.IsUndefined(right.items) ? ExtendsResult.True : left.items.every((schema, index) => Visit3(schema, right.items[index]) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1810
+ }
1811
+ function FromUint8Array(left, right) {
1812
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsUint8Array(right) ? ExtendsResult.True : ExtendsResult.False;
1813
+ }
1814
+ function FromUndefined(left, right) {
1815
+ return IsStructuralRight(right) ? StructuralRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsRecord(right) ? FromRecordRight(left, right) : type_exports.IsVoid(right) ? FromVoidRight(left, right) : type_exports.IsUndefined(right) ? ExtendsResult.True : ExtendsResult.False;
1816
+ }
1817
+ function FromUnionRight(left, right) {
1818
+ return right.anyOf.some((schema) => Visit3(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1819
+ }
1820
+ function FromUnion6(left, right) {
1821
+ return left.anyOf.every((schema) => Visit3(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1822
+ }
1823
+ function FromUnknownRight(left, right) {
1824
+ return ExtendsResult.True;
1825
+ }
1826
+ function FromUnknown(left, right) {
1827
+ return type_exports.IsNever(right) ? FromNeverRight(left, right) : type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : type_exports.IsString(right) ? FromStringRight(left, right) : type_exports.IsNumber(right) ? FromNumberRight(left, right) : type_exports.IsInteger(right) ? FromIntegerRight(left, right) : type_exports.IsBoolean(right) ? FromBooleanRight(left, right) : type_exports.IsArray(right) ? FromArrayRight(left, right) : type_exports.IsTuple(right) ? FromTupleRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsUnknown(right) ? ExtendsResult.True : ExtendsResult.False;
1828
+ }
1829
+ function FromVoidRight(left, right) {
1830
+ return type_exports.IsUndefined(left) ? ExtendsResult.True : type_exports.IsUndefined(left) ? ExtendsResult.True : ExtendsResult.False;
1831
+ }
1832
+ function FromVoid(left, right) {
1833
+ return type_exports.IsIntersect(right) ? FromIntersectRight(left, right) : type_exports.IsUnion(right) ? FromUnionRight(left, right) : type_exports.IsUnknown(right) ? FromUnknownRight(left, right) : type_exports.IsAny(right) ? FromAnyRight(left, right) : type_exports.IsObject(right) ? FromObjectRight(left, right) : type_exports.IsVoid(right) ? ExtendsResult.True : ExtendsResult.False;
1834
+ }
1835
+ function Visit3(left, right) {
1836
+ return (
1837
+ // resolvable
1838
+ type_exports.IsTemplateLiteral(left) || type_exports.IsTemplateLiteral(right) ? FromTemplateLiteral2(left, right) : type_exports.IsRegExp(left) || type_exports.IsRegExp(right) ? FromRegExp(left, right) : type_exports.IsNot(left) || type_exports.IsNot(right) ? FromNot(left, right) : (
1839
+ // standard
1840
+ type_exports.IsAny(left) ? FromAny(left, right) : type_exports.IsArray(left) ? FromArray4(left, right) : type_exports.IsBigInt(left) ? FromBigInt(left, right) : type_exports.IsBoolean(left) ? FromBoolean(left, right) : type_exports.IsAsyncIterator(left) ? FromAsyncIterator(left, right) : type_exports.IsConstructor(left) ? FromConstructor(left, right) : type_exports.IsDate(left) ? FromDate(left, right) : type_exports.IsFunction(left) ? FromFunction(left, right) : type_exports.IsInteger(left) ? FromInteger(left, right) : type_exports.IsIntersect(left) ? FromIntersect4(left, right) : type_exports.IsIterator(left) ? FromIterator(left, right) : type_exports.IsLiteral(left) ? FromLiteral2(left, right) : type_exports.IsNever(left) ? FromNever(left, right) : type_exports.IsNull(left) ? FromNull(left, right) : type_exports.IsNumber(left) ? FromNumber(left, right) : type_exports.IsObject(left) ? FromObject(left, right) : type_exports.IsRecord(left) ? FromRecord(left, right) : type_exports.IsString(left) ? FromString(left, right) : type_exports.IsSymbol(left) ? FromSymbol(left, right) : type_exports.IsTuple(left) ? FromTuple3(left, right) : type_exports.IsPromise(left) ? FromPromise2(left, right) : type_exports.IsUint8Array(left) ? FromUint8Array(left, right) : type_exports.IsUndefined(left) ? FromUndefined(left, right) : type_exports.IsUnion(left) ? FromUnion6(left, right) : type_exports.IsUnknown(left) ? FromUnknown(left, right) : type_exports.IsVoid(left) ? FromVoid(left, right) : Throw(`Unknown left type operand '${left[Kind]}'`)
1841
+ )
1842
+ );
1843
+ }
1844
+ function ExtendsCheck(left, right) {
1845
+ return Visit3(left, right);
1846
+ }
1847
+
1848
+ // node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-result.mjs
1849
+ function FromProperties8(P, Right, True, False, options) {
1850
+ const Acc = {};
1851
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
1852
+ Acc[K2] = Extends(P[K2], Right, True, False, Clone(options));
1853
+ return Acc;
1854
+ }
1855
+ function FromMappedResult6(Left, Right, True, False, options) {
1856
+ return FromProperties8(Left.properties, Right, True, False, options);
1857
+ }
1858
+ function ExtendsFromMappedResult(Left, Right, True, False, options) {
1859
+ const P = FromMappedResult6(Left, Right, True, False, options);
1860
+ return MappedResult(P);
1861
+ }
1862
+
1863
+ // node_modules/@sinclair/typebox/build/esm/type/extends/extends.mjs
1864
+ function ExtendsResolve(left, right, trueType, falseType) {
1865
+ const R = ExtendsCheck(left, right);
1866
+ return R === ExtendsResult.Union ? Union([trueType, falseType]) : R === ExtendsResult.True ? trueType : falseType;
1867
+ }
1868
+ function Extends(L, R, T, F, options) {
1869
+ 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);
1870
+ }
1871
+
1872
+ // node_modules/@sinclair/typebox/build/esm/type/extends/extends-from-mapped-key.mjs
1873
+ function FromPropertyKey(K, U, L, R, options) {
1874
+ return {
1875
+ [K]: Extends(Literal(K), U, L, R, Clone(options))
1876
+ };
1877
+ }
1878
+ function FromPropertyKeys(K, U, L, R, options) {
1879
+ return K.reduce((Acc, LK) => {
1880
+ return { ...Acc, ...FromPropertyKey(LK, U, L, R, options) };
1881
+ }, {});
1882
+ }
1883
+ function FromMappedKey2(K, U, L, R, options) {
1884
+ return FromPropertyKeys(K.keys, U, L, R, options);
1885
+ }
1886
+ function ExtendsFromMappedKey(T, U, L, R, options) {
1887
+ const P = FromMappedKey2(T, U, L, R, options);
1888
+ return MappedResult(P);
1889
+ }
1890
+
1891
+ // node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-template-literal.mjs
1892
+ function ExcludeFromTemplateLiteral(L, R) {
1893
+ return Exclude(TemplateLiteralToUnion(L), R);
1894
+ }
1895
+
1896
+ // node_modules/@sinclair/typebox/build/esm/type/exclude/exclude.mjs
1897
+ function ExcludeRest(L, R) {
1898
+ const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
1899
+ return excluded.length === 1 ? excluded[0] : Union(excluded);
1900
+ }
1901
+ function Exclude(L, R, options = {}) {
1902
+ if (IsTemplateLiteral(L))
1903
+ return CreateType(ExcludeFromTemplateLiteral(L, R), options);
1904
+ if (IsMappedResult(L))
1905
+ return CreateType(ExcludeFromMappedResult(L, R), options);
1906
+ return CreateType(IsUnion(L) ? ExcludeRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
1907
+ }
1908
+
1909
+ // node_modules/@sinclair/typebox/build/esm/type/exclude/exclude-from-mapped-result.mjs
1910
+ function FromProperties9(P, U) {
1911
+ const Acc = {};
1912
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
1913
+ Acc[K2] = Exclude(P[K2], U);
1914
+ return Acc;
1915
+ }
1916
+ function FromMappedResult7(R, T) {
1917
+ return FromProperties9(R.properties, T);
1918
+ }
1919
+ function ExcludeFromMappedResult(R, T) {
1920
+ const P = FromMappedResult7(R, T);
1921
+ return MappedResult(P);
1922
+ }
1923
+
1924
+ // node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-template-literal.mjs
1925
+ function ExtractFromTemplateLiteral(L, R) {
1926
+ return Extract(TemplateLiteralToUnion(L), R);
1927
+ }
1928
+
1929
+ // node_modules/@sinclair/typebox/build/esm/type/extract/extract.mjs
1930
+ function ExtractRest(L, R) {
1931
+ const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
1932
+ return extracted.length === 1 ? extracted[0] : Union(extracted);
1933
+ }
1934
+ function Extract(L, R, options) {
1935
+ if (IsTemplateLiteral(L))
1936
+ return CreateType(ExtractFromTemplateLiteral(L, R), options);
1937
+ if (IsMappedResult(L))
1938
+ return CreateType(ExtractFromMappedResult(L, R), options);
1939
+ return CreateType(IsUnion(L) ? ExtractRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
1940
+ }
1941
+
1942
+ // node_modules/@sinclair/typebox/build/esm/type/extract/extract-from-mapped-result.mjs
1943
+ function FromProperties10(P, T) {
1944
+ const Acc = {};
1945
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
1946
+ Acc[K2] = Extract(P[K2], T);
1947
+ return Acc;
1948
+ }
1949
+ function FromMappedResult8(R, T) {
1950
+ return FromProperties10(R.properties, T);
1951
+ }
1952
+ function ExtractFromMappedResult(R, T) {
1953
+ const P = FromMappedResult8(R, T);
1954
+ return MappedResult(P);
1955
+ }
1956
+
1957
+ // node_modules/@sinclair/typebox/build/esm/type/instance-type/instance-type.mjs
1958
+ function InstanceType(schema, options) {
1959
+ return IsConstructor(schema) ? CreateType(schema.returns, options) : Never(options);
1960
+ }
1961
+
1962
+ // node_modules/@sinclair/typebox/build/esm/type/readonly-optional/readonly-optional.mjs
1963
+ function ReadonlyOptional(schema) {
1964
+ return Readonly(Optional(schema));
1965
+ }
1966
+
1967
+ // node_modules/@sinclair/typebox/build/esm/type/record/record.mjs
1968
+ function RecordCreateFromPattern(pattern, T, options) {
1969
+ return CreateType({ [Kind]: "Record", type: "object", patternProperties: { [pattern]: T } }, options);
1970
+ }
1971
+ function RecordCreateFromKeys(K, T, options) {
1972
+ const result = {};
1973
+ for (const K2 of K)
1974
+ result[K2] = T;
1975
+ return Object2(result, { ...options, [Hint]: "Record" });
1976
+ }
1977
+ function FromTemplateLiteralKey(K, T, options) {
1978
+ return IsTemplateLiteralFinite(K) ? RecordCreateFromKeys(IndexPropertyKeys(K), T, options) : RecordCreateFromPattern(K.pattern, T, options);
1979
+ }
1980
+ function FromUnionKey(key, type, options) {
1981
+ return RecordCreateFromKeys(IndexPropertyKeys(Union(key)), type, options);
1982
+ }
1983
+ function FromLiteralKey(key, type, options) {
1984
+ return RecordCreateFromKeys([key.toString()], type, options);
1985
+ }
1986
+ function FromRegExpKey(key, type, options) {
1987
+ return RecordCreateFromPattern(key.source, type, options);
1988
+ }
1989
+ function FromStringKey(key, type, options) {
1990
+ const pattern = IsUndefined(key.pattern) ? PatternStringExact : key.pattern;
1991
+ return RecordCreateFromPattern(pattern, type, options);
1992
+ }
1993
+ function FromAnyKey(_, type, options) {
1994
+ return RecordCreateFromPattern(PatternStringExact, type, options);
1995
+ }
1996
+ function FromNeverKey(_key, type, options) {
1997
+ return RecordCreateFromPattern(PatternNeverExact, type, options);
1998
+ }
1999
+ function FromBooleanKey(_key, type, options) {
2000
+ return Object2({ true: type, false: type }, options);
2001
+ }
2002
+ function FromIntegerKey(_key, type, options) {
2003
+ return RecordCreateFromPattern(PatternNumberExact, type, options);
2004
+ }
2005
+ function FromNumberKey(_, type, options) {
2006
+ return RecordCreateFromPattern(PatternNumberExact, type, options);
2007
+ }
2008
+ function Record(key, type, options = {}) {
2009
+ 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);
2010
+ }
2011
+ function RecordPattern(record) {
2012
+ return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
2013
+ }
2014
+ function RecordKey2(type) {
2015
+ const pattern = RecordPattern(type);
2016
+ return pattern === PatternStringExact ? String2() : pattern === PatternNumberExact ? Number2() : String2({ pattern });
2017
+ }
2018
+ function RecordValue2(type) {
2019
+ return type.patternProperties[RecordPattern(type)];
2020
+ }
2021
+
2022
+ // node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs
2023
+ function FromConstructor2(args, type) {
2024
+ type.parameters = FromTypes(args, type.parameters);
2025
+ type.returns = FromType(args, type.returns);
2026
+ return type;
2027
+ }
2028
+ function FromFunction2(args, type) {
2029
+ type.parameters = FromTypes(args, type.parameters);
2030
+ type.returns = FromType(args, type.returns);
2031
+ return type;
2032
+ }
2033
+ function FromIntersect5(args, type) {
2034
+ type.allOf = FromTypes(args, type.allOf);
2035
+ return type;
2036
+ }
2037
+ function FromUnion7(args, type) {
2038
+ type.anyOf = FromTypes(args, type.anyOf);
2039
+ return type;
2040
+ }
2041
+ function FromTuple4(args, type) {
2042
+ if (IsUndefined(type.items))
2043
+ return type;
2044
+ type.items = FromTypes(args, type.items);
2045
+ return type;
2046
+ }
2047
+ function FromArray5(args, type) {
2048
+ type.items = FromType(args, type.items);
2049
+ return type;
2050
+ }
2051
+ function FromAsyncIterator2(args, type) {
2052
+ type.items = FromType(args, type.items);
2053
+ return type;
2054
+ }
2055
+ function FromIterator2(args, type) {
2056
+ type.items = FromType(args, type.items);
2057
+ return type;
2058
+ }
2059
+ function FromPromise3(args, type) {
2060
+ type.item = FromType(args, type.item);
2061
+ return type;
2062
+ }
2063
+ function FromObject2(args, type) {
2064
+ const mappedProperties = FromProperties11(args, type.properties);
2065
+ return { ...type, ...Object2(mappedProperties) };
2066
+ }
2067
+ function FromRecord2(args, type) {
2068
+ const mappedKey = FromType(args, RecordKey2(type));
2069
+ const mappedValue = FromType(args, RecordValue2(type));
2070
+ const result = Record(mappedKey, mappedValue);
2071
+ return { ...type, ...result };
2072
+ }
2073
+ function FromArgument(args, argument) {
2074
+ return argument.index in args ? args[argument.index] : Unknown();
2075
+ }
2076
+ function FromProperty2(args, type) {
2077
+ const isReadonly = IsReadonly(type);
2078
+ const isOptional = IsOptional(type);
2079
+ const mapped = FromType(args, type);
2080
+ return isReadonly && isOptional ? ReadonlyOptional(mapped) : isReadonly && !isOptional ? Readonly(mapped) : !isReadonly && isOptional ? Optional(mapped) : mapped;
2081
+ }
2082
+ function FromProperties11(args, properties) {
2083
+ return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
2084
+ return { ...result, [key]: FromProperty2(args, properties[key]) };
2085
+ }, {});
2086
+ }
2087
+ function FromTypes(args, types) {
2088
+ return types.map((type) => FromType(args, type));
2089
+ }
2090
+ function FromType(args, type) {
2091
+ 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;
2092
+ }
2093
+ function Instantiate(type, args) {
2094
+ return FromType(args, CloneType(type));
2095
+ }
2096
+
2097
+ // node_modules/@sinclair/typebox/build/esm/type/integer/integer.mjs
2098
+ function Integer(options) {
2099
+ return CreateType({ [Kind]: "Integer", type: "integer" }, options);
2100
+ }
2101
+
2102
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs
2103
+ function MappedIntrinsicPropertyKey(K, M, options) {
2104
+ return {
2105
+ [K]: Intrinsic(Literal(K), M, Clone(options))
2106
+ };
2107
+ }
2108
+ function MappedIntrinsicPropertyKeys(K, M, options) {
2109
+ const result = K.reduce((Acc, L) => {
2110
+ return { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) };
2111
+ }, {});
2112
+ return result;
2113
+ }
2114
+ function MappedIntrinsicProperties(T, M, options) {
2115
+ return MappedIntrinsicPropertyKeys(T["keys"], M, options);
2116
+ }
2117
+ function IntrinsicFromMappedKey(T, M, options) {
2118
+ const P = MappedIntrinsicProperties(T, M, options);
2119
+ return MappedResult(P);
2120
+ }
2121
+
2122
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/intrinsic.mjs
2123
+ function ApplyUncapitalize(value) {
2124
+ const [first, rest] = [value.slice(0, 1), value.slice(1)];
2125
+ return [first.toLowerCase(), rest].join("");
2126
+ }
2127
+ function ApplyCapitalize(value) {
2128
+ const [first, rest] = [value.slice(0, 1), value.slice(1)];
2129
+ return [first.toUpperCase(), rest].join("");
2130
+ }
2131
+ function ApplyUppercase(value) {
2132
+ return value.toUpperCase();
2133
+ }
2134
+ function ApplyLowercase(value) {
2135
+ return value.toLowerCase();
2136
+ }
2137
+ function FromTemplateLiteral3(schema, mode, options) {
2138
+ const expression = TemplateLiteralParseExact(schema.pattern);
2139
+ const finite = IsTemplateLiteralExpressionFinite(expression);
2140
+ if (!finite)
2141
+ return { ...schema, pattern: FromLiteralValue(schema.pattern, mode) };
2142
+ const strings = [...TemplateLiteralExpressionGenerate(expression)];
2143
+ const literals = strings.map((value) => Literal(value));
2144
+ const mapped = FromRest5(literals, mode);
2145
+ const union = Union(mapped);
2146
+ return TemplateLiteral([union], options);
2147
+ }
2148
+ function FromLiteralValue(value, mode) {
2149
+ return typeof value === "string" ? mode === "Uncapitalize" ? ApplyUncapitalize(value) : mode === "Capitalize" ? ApplyCapitalize(value) : mode === "Uppercase" ? ApplyUppercase(value) : mode === "Lowercase" ? ApplyLowercase(value) : value : value.toString();
2150
+ }
2151
+ function FromRest5(T, M) {
2152
+ return T.map((L) => Intrinsic(L, M));
2153
+ }
2154
+ function Intrinsic(schema, mode, options = {}) {
2155
+ return (
2156
+ // Intrinsic-Mapped-Inference
2157
+ IsMappedKey(schema) ? IntrinsicFromMappedKey(schema, mode, options) : (
2158
+ // Standard-Inference
2159
+ IsTemplateLiteral(schema) ? FromTemplateLiteral3(schema, mode, options) : IsUnion(schema) ? Union(FromRest5(schema.anyOf, mode), options) : IsLiteral(schema) ? Literal(FromLiteralValue(schema.const, mode), options) : (
2160
+ // Default Type
2161
+ CreateType(schema, options)
2162
+ )
2163
+ )
2164
+ );
2165
+ }
2166
+
2167
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/capitalize.mjs
2168
+ function Capitalize(T, options = {}) {
2169
+ return Intrinsic(T, "Capitalize", options);
2170
+ }
2171
+
2172
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/lowercase.mjs
2173
+ function Lowercase(T, options = {}) {
2174
+ return Intrinsic(T, "Lowercase", options);
2175
+ }
2176
+
2177
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/uncapitalize.mjs
2178
+ function Uncapitalize(T, options = {}) {
2179
+ return Intrinsic(T, "Uncapitalize", options);
2180
+ }
2181
+
2182
+ // node_modules/@sinclair/typebox/build/esm/type/intrinsic/uppercase.mjs
2183
+ function Uppercase(T, options = {}) {
2184
+ return Intrinsic(T, "Uppercase", options);
2185
+ }
2186
+
2187
+ // node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-result.mjs
2188
+ function FromProperties12(properties, propertyKeys, options) {
2189
+ const result = {};
2190
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
2191
+ result[K2] = Omit(properties[K2], propertyKeys, Clone(options));
2192
+ return result;
2193
+ }
2194
+ function FromMappedResult9(mappedResult, propertyKeys, options) {
2195
+ return FromProperties12(mappedResult.properties, propertyKeys, options);
2196
+ }
2197
+ function OmitFromMappedResult(mappedResult, propertyKeys, options) {
2198
+ const properties = FromMappedResult9(mappedResult, propertyKeys, options);
2199
+ return MappedResult(properties);
2200
+ }
2201
+
2202
+ // node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs
2203
+ function FromIntersect6(types, propertyKeys) {
2204
+ return types.map((type) => OmitResolve(type, propertyKeys));
2205
+ }
2206
+ function FromUnion8(types, propertyKeys) {
2207
+ return types.map((type) => OmitResolve(type, propertyKeys));
2208
+ }
2209
+ function FromProperty3(properties, key) {
2210
+ const { [key]: _, ...R } = properties;
2211
+ return R;
2212
+ }
2213
+ function FromProperties13(properties, propertyKeys) {
2214
+ return propertyKeys.reduce((T, K2) => FromProperty3(T, K2), properties);
2215
+ }
2216
+ function FromObject3(type, propertyKeys, properties) {
2217
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
2218
+ const mappedProperties = FromProperties13(properties, propertyKeys);
2219
+ return Object2(mappedProperties, options);
2220
+ }
2221
+ function UnionFromPropertyKeys(propertyKeys) {
2222
+ const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
2223
+ return Union(result);
2224
+ }
2225
+ function OmitResolve(type, propertyKeys) {
2226
+ return IsIntersect(type) ? Intersect(FromIntersect6(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion8(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject3(type, propertyKeys, type.properties) : Object2({});
2227
+ }
2228
+ function Omit(type, key, options) {
2229
+ const typeKey = IsArray(key) ? UnionFromPropertyKeys(key) : key;
2230
+ const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
2231
+ const isTypeRef = IsRef(type);
2232
+ const isKeyRef = IsRef(key);
2233
+ 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 });
2234
+ }
2235
+
2236
+ // node_modules/@sinclair/typebox/build/esm/type/omit/omit-from-mapped-key.mjs
2237
+ function FromPropertyKey2(type, key, options) {
2238
+ return { [key]: Omit(type, [key], Clone(options)) };
2239
+ }
2240
+ function FromPropertyKeys2(type, propertyKeys, options) {
2241
+ return propertyKeys.reduce((Acc, LK) => {
2242
+ return { ...Acc, ...FromPropertyKey2(type, LK, options) };
2243
+ }, {});
2244
+ }
2245
+ function FromMappedKey3(type, mappedKey, options) {
2246
+ return FromPropertyKeys2(type, mappedKey.keys, options);
2247
+ }
2248
+ function OmitFromMappedKey(type, mappedKey, options) {
2249
+ const properties = FromMappedKey3(type, mappedKey, options);
2250
+ return MappedResult(properties);
2251
+ }
2252
+
2253
+ // node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-result.mjs
2254
+ function FromProperties14(properties, propertyKeys, options) {
2255
+ const result = {};
2256
+ for (const K2 of globalThis.Object.getOwnPropertyNames(properties))
2257
+ result[K2] = Pick(properties[K2], propertyKeys, Clone(options));
2258
+ return result;
2259
+ }
2260
+ function FromMappedResult10(mappedResult, propertyKeys, options) {
2261
+ return FromProperties14(mappedResult.properties, propertyKeys, options);
2262
+ }
2263
+ function PickFromMappedResult(mappedResult, propertyKeys, options) {
2264
+ const properties = FromMappedResult10(mappedResult, propertyKeys, options);
2265
+ return MappedResult(properties);
2266
+ }
2267
+
2268
+ // node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs
2269
+ function FromIntersect7(types, propertyKeys) {
2270
+ return types.map((type) => PickResolve(type, propertyKeys));
2271
+ }
2272
+ function FromUnion9(types, propertyKeys) {
2273
+ return types.map((type) => PickResolve(type, propertyKeys));
2274
+ }
2275
+ function FromProperties15(properties, propertyKeys) {
2276
+ const result = {};
2277
+ for (const K2 of propertyKeys)
2278
+ if (K2 in properties)
2279
+ result[K2] = properties[K2];
2280
+ return result;
2281
+ }
2282
+ function FromObject4(Type2, keys, properties) {
2283
+ const options = Discard(Type2, [TransformKind, "$id", "required", "properties"]);
2284
+ const mappedProperties = FromProperties15(properties, keys);
2285
+ return Object2(mappedProperties, options);
2286
+ }
2287
+ function UnionFromPropertyKeys2(propertyKeys) {
2288
+ const result = propertyKeys.reduce((result2, key) => IsLiteralValue(key) ? [...result2, Literal(key)] : result2, []);
2289
+ return Union(result);
2290
+ }
2291
+ function PickResolve(type, propertyKeys) {
2292
+ return IsIntersect(type) ? Intersect(FromIntersect7(type.allOf, propertyKeys)) : IsUnion(type) ? Union(FromUnion9(type.anyOf, propertyKeys)) : IsObject3(type) ? FromObject4(type, propertyKeys, type.properties) : Object2({});
2293
+ }
2294
+ function Pick(type, key, options) {
2295
+ const typeKey = IsArray(key) ? UnionFromPropertyKeys2(key) : key;
2296
+ const propertyKeys = IsSchema(key) ? IndexPropertyKeys(key) : key;
2297
+ const isTypeRef = IsRef(type);
2298
+ const isKeyRef = IsRef(key);
2299
+ 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 });
2300
+ }
2301
+
2302
+ // node_modules/@sinclair/typebox/build/esm/type/pick/pick-from-mapped-key.mjs
2303
+ function FromPropertyKey3(type, key, options) {
2304
+ return {
2305
+ [key]: Pick(type, [key], Clone(options))
2306
+ };
2307
+ }
2308
+ function FromPropertyKeys3(type, propertyKeys, options) {
2309
+ return propertyKeys.reduce((result, leftKey) => {
2310
+ return { ...result, ...FromPropertyKey3(type, leftKey, options) };
2311
+ }, {});
2312
+ }
2313
+ function FromMappedKey4(type, mappedKey, options) {
2314
+ return FromPropertyKeys3(type, mappedKey.keys, options);
2315
+ }
2316
+ function PickFromMappedKey(type, mappedKey, options) {
2317
+ const properties = FromMappedKey4(type, mappedKey, options);
2318
+ return MappedResult(properties);
2319
+ }
2320
+
2321
+ // node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs
2322
+ function FromComputed3(target, parameters) {
2323
+ return Computed("Partial", [Computed(target, parameters)]);
2324
+ }
2325
+ function FromRef3($ref) {
2326
+ return Computed("Partial", [Ref($ref)]);
2327
+ }
2328
+ function FromProperties16(properties) {
2329
+ const partialProperties = {};
2330
+ for (const K of globalThis.Object.getOwnPropertyNames(properties))
2331
+ partialProperties[K] = Optional(properties[K]);
2332
+ return partialProperties;
2333
+ }
2334
+ function FromObject5(type, properties) {
2335
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
2336
+ const mappedProperties = FromProperties16(properties);
2337
+ return Object2(mappedProperties, options);
2338
+ }
2339
+ function FromRest6(types) {
2340
+ return types.map((type) => PartialResolve(type));
2341
+ }
2342
+ function PartialResolve(type) {
2343
+ return (
2344
+ // Mappable
2345
+ 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) : (
2346
+ // Intrinsic
2347
+ 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 : (
2348
+ // Passthrough
2349
+ Object2({})
2350
+ )
2351
+ )
2352
+ );
2353
+ }
2354
+ function Partial(type, options) {
2355
+ if (IsMappedResult(type)) {
2356
+ return PartialFromMappedResult(type, options);
2357
+ } else {
2358
+ return CreateType({ ...PartialResolve(type), ...options });
2359
+ }
2360
+ }
2361
+
2362
+ // node_modules/@sinclair/typebox/build/esm/type/partial/partial-from-mapped-result.mjs
2363
+ function FromProperties17(K, options) {
2364
+ const Acc = {};
2365
+ for (const K2 of globalThis.Object.getOwnPropertyNames(K))
2366
+ Acc[K2] = Partial(K[K2], Clone(options));
2367
+ return Acc;
2368
+ }
2369
+ function FromMappedResult11(R, options) {
2370
+ return FromProperties17(R.properties, options);
2371
+ }
2372
+ function PartialFromMappedResult(R, options) {
2373
+ const P = FromMappedResult11(R, options);
2374
+ return MappedResult(P);
2375
+ }
2376
+
2377
+ // node_modules/@sinclair/typebox/build/esm/type/required/required.mjs
2378
+ function FromComputed4(target, parameters) {
2379
+ return Computed("Required", [Computed(target, parameters)]);
2380
+ }
2381
+ function FromRef4($ref) {
2382
+ return Computed("Required", [Ref($ref)]);
2383
+ }
2384
+ function FromProperties18(properties) {
2385
+ const requiredProperties = {};
2386
+ for (const K of globalThis.Object.getOwnPropertyNames(properties))
2387
+ requiredProperties[K] = Discard(properties[K], [OptionalKind]);
2388
+ return requiredProperties;
2389
+ }
2390
+ function FromObject6(type, properties) {
2391
+ const options = Discard(type, [TransformKind, "$id", "required", "properties"]);
2392
+ const mappedProperties = FromProperties18(properties);
2393
+ return Object2(mappedProperties, options);
2394
+ }
2395
+ function FromRest7(types) {
2396
+ return types.map((type) => RequiredResolve(type));
2397
+ }
2398
+ function RequiredResolve(type) {
2399
+ return (
2400
+ // Mappable
2401
+ 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) : (
2402
+ // Intrinsic
2403
+ 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 : (
2404
+ // Passthrough
2405
+ Object2({})
2406
+ )
2407
+ )
2408
+ );
2409
+ }
2410
+ function Required(type, options) {
2411
+ if (IsMappedResult(type)) {
2412
+ return RequiredFromMappedResult(type, options);
2413
+ } else {
2414
+ return CreateType({ ...RequiredResolve(type), ...options });
2415
+ }
2416
+ }
2417
+
2418
+ // node_modules/@sinclair/typebox/build/esm/type/required/required-from-mapped-result.mjs
2419
+ function FromProperties19(P, options) {
2420
+ const Acc = {};
2421
+ for (const K2 of globalThis.Object.getOwnPropertyNames(P))
2422
+ Acc[K2] = Required(P[K2], options);
2423
+ return Acc;
2424
+ }
2425
+ function FromMappedResult12(R, options) {
2426
+ return FromProperties19(R.properties, options);
2427
+ }
2428
+ function RequiredFromMappedResult(R, options) {
2429
+ const P = FromMappedResult12(R, options);
2430
+ return MappedResult(P);
2431
+ }
2432
+
2433
+ // node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs
2434
+ function DereferenceParameters(moduleProperties, types) {
2435
+ return types.map((type) => {
2436
+ return IsRef(type) ? Dereference(moduleProperties, type.$ref) : FromType2(moduleProperties, type);
2437
+ });
2438
+ }
2439
+ function Dereference(moduleProperties, ref) {
2440
+ return ref in moduleProperties ? IsRef(moduleProperties[ref]) ? Dereference(moduleProperties, moduleProperties[ref].$ref) : FromType2(moduleProperties, moduleProperties[ref]) : Never();
2441
+ }
2442
+ function FromAwaited(parameters) {
2443
+ return Awaited(parameters[0]);
2444
+ }
2445
+ function FromIndex(parameters) {
2446
+ return Index(parameters[0], parameters[1]);
2447
+ }
2448
+ function FromKeyOf(parameters) {
2449
+ return KeyOf(parameters[0]);
2450
+ }
2451
+ function FromPartial(parameters) {
2452
+ return Partial(parameters[0]);
2453
+ }
2454
+ function FromOmit(parameters) {
2455
+ return Omit(parameters[0], parameters[1]);
2456
+ }
2457
+ function FromPick(parameters) {
2458
+ return Pick(parameters[0], parameters[1]);
2459
+ }
2460
+ function FromRequired(parameters) {
2461
+ return Required(parameters[0]);
2462
+ }
2463
+ function FromComputed5(moduleProperties, target, parameters) {
2464
+ const dereferenced = DereferenceParameters(moduleProperties, parameters);
2465
+ 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();
2466
+ }
2467
+ function FromArray6(moduleProperties, type) {
2468
+ return Array2(FromType2(moduleProperties, type));
2469
+ }
2470
+ function FromAsyncIterator3(moduleProperties, type) {
2471
+ return AsyncIterator(FromType2(moduleProperties, type));
2472
+ }
2473
+ function FromConstructor3(moduleProperties, parameters, instanceType) {
2474
+ return Constructor(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, instanceType));
2475
+ }
2476
+ function FromFunction3(moduleProperties, parameters, returnType) {
2477
+ return Function(FromTypes2(moduleProperties, parameters), FromType2(moduleProperties, returnType));
2478
+ }
2479
+ function FromIntersect8(moduleProperties, types) {
2480
+ return Intersect(FromTypes2(moduleProperties, types));
2481
+ }
2482
+ function FromIterator3(moduleProperties, type) {
2483
+ return Iterator(FromType2(moduleProperties, type));
2484
+ }
2485
+ function FromObject7(moduleProperties, properties) {
2486
+ return Object2(globalThis.Object.keys(properties).reduce((result, key) => {
2487
+ return { ...result, [key]: FromType2(moduleProperties, properties[key]) };
2488
+ }, {}));
2489
+ }
2490
+ function FromRecord3(moduleProperties, type) {
2491
+ const [value, pattern] = [FromType2(moduleProperties, RecordValue2(type)), RecordPattern(type)];
2492
+ const result = CloneType(type);
2493
+ result.patternProperties[pattern] = value;
2494
+ return result;
2495
+ }
2496
+ function FromTransform(moduleProperties, transform) {
2497
+ return IsRef(transform) ? { ...Dereference(moduleProperties, transform.$ref), [TransformKind]: transform[TransformKind] } : transform;
2498
+ }
2499
+ function FromTuple5(moduleProperties, types) {
2500
+ return Tuple(FromTypes2(moduleProperties, types));
2501
+ }
2502
+ function FromUnion10(moduleProperties, types) {
2503
+ return Union(FromTypes2(moduleProperties, types));
2504
+ }
2505
+ function FromTypes2(moduleProperties, types) {
2506
+ return types.map((type) => FromType2(moduleProperties, type));
2507
+ }
2508
+ function FromType2(moduleProperties, type) {
2509
+ return (
2510
+ // Modifiers
2511
+ IsOptional(type) ? CreateType(FromType2(moduleProperties, Discard(type, [OptionalKind])), type) : IsReadonly(type) ? CreateType(FromType2(moduleProperties, Discard(type, [ReadonlyKind])), type) : (
2512
+ // Transform
2513
+ IsTransform(type) ? CreateType(FromTransform(moduleProperties, type), type) : (
2514
+ // Types
2515
+ 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
2516
+ )
2517
+ )
2518
+ );
2519
+ }
2520
+ function ComputeType(moduleProperties, key) {
2521
+ return key in moduleProperties ? FromType2(moduleProperties, moduleProperties[key]) : Never();
2522
+ }
2523
+ function ComputeModuleProperties(moduleProperties) {
2524
+ return globalThis.Object.getOwnPropertyNames(moduleProperties).reduce((result, key) => {
2525
+ return { ...result, [key]: ComputeType(moduleProperties, key) };
2526
+ }, {});
2527
+ }
2528
+
2529
+ // node_modules/@sinclair/typebox/build/esm/type/module/module.mjs
2530
+ var TModule = class {
2531
+ constructor($defs) {
2532
+ const computed = ComputeModuleProperties($defs);
2533
+ const identified = this.WithIdentifiers(computed);
2534
+ this.$defs = identified;
2535
+ }
2536
+ /** `[Json]` Imports a Type by Key. */
2537
+ Import(key, options) {
2538
+ const $defs = { ...this.$defs, [key]: CreateType(this.$defs[key], options) };
2539
+ return CreateType({ [Kind]: "Import", $defs, $ref: key });
2540
+ }
2541
+ // prettier-ignore
2542
+ WithIdentifiers($defs) {
2543
+ return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
2544
+ return { ...result, [key]: { ...$defs[key], $id: key } };
2545
+ }, {});
2546
+ }
2547
+ };
2548
+ function Module(properties) {
2549
+ return new TModule(properties);
2550
+ }
2551
+
2552
+ // node_modules/@sinclair/typebox/build/esm/type/not/not.mjs
2553
+ function Not(type, options) {
2554
+ return CreateType({ [Kind]: "Not", not: type }, options);
2555
+ }
2556
+
2557
+ // node_modules/@sinclair/typebox/build/esm/type/parameters/parameters.mjs
2558
+ function Parameters(schema, options) {
2559
+ return IsFunction2(schema) ? Tuple(schema.parameters, options) : Never();
2560
+ }
2561
+
2562
+ // node_modules/@sinclair/typebox/build/esm/type/recursive/recursive.mjs
2563
+ var Ordinal = 0;
2564
+ function Recursive(callback, options = {}) {
2565
+ if (IsUndefined(options.$id))
2566
+ options.$id = `T${Ordinal++}`;
2567
+ const thisType = CloneType(callback({ [Kind]: "This", $ref: `${options.$id}` }));
2568
+ thisType.$id = options.$id;
2569
+ return CreateType({ [Hint]: "Recursive", ...thisType }, options);
2570
+ }
2571
+
2572
+ // node_modules/@sinclair/typebox/build/esm/type/regexp/regexp.mjs
2573
+ function RegExp2(unresolved, options) {
2574
+ const expr = IsString(unresolved) ? new globalThis.RegExp(unresolved) : unresolved;
2575
+ return CreateType({ [Kind]: "RegExp", type: "RegExp", source: expr.source, flags: expr.flags }, options);
2576
+ }
2577
+
2578
+ // node_modules/@sinclair/typebox/build/esm/type/rest/rest.mjs
2579
+ function RestResolve(T) {
2580
+ return IsIntersect(T) ? T.allOf : IsUnion(T) ? T.anyOf : IsTuple(T) ? T.items ?? [] : [];
2581
+ }
2582
+ function Rest(T) {
2583
+ return RestResolve(T);
2584
+ }
2585
+
2586
+ // node_modules/@sinclair/typebox/build/esm/type/return-type/return-type.mjs
2587
+ function ReturnType(schema, options) {
2588
+ return IsFunction2(schema) ? CreateType(schema.returns, options) : Never(options);
2589
+ }
2590
+
2591
+ // node_modules/@sinclair/typebox/build/esm/type/transform/transform.mjs
2592
+ var TransformDecodeBuilder = class {
2593
+ constructor(schema) {
2594
+ this.schema = schema;
2595
+ }
2596
+ Decode(decode) {
2597
+ return new TransformEncodeBuilder(this.schema, decode);
2598
+ }
2599
+ };
2600
+ var TransformEncodeBuilder = class {
2601
+ constructor(schema, decode) {
2602
+ this.schema = schema;
2603
+ this.decode = decode;
2604
+ }
2605
+ EncodeTransform(encode, schema) {
2606
+ const Encode = (value) => schema[TransformKind].Encode(encode(value));
2607
+ const Decode = (value) => this.decode(schema[TransformKind].Decode(value));
2608
+ const Codec = { Encode, Decode };
2609
+ return { ...schema, [TransformKind]: Codec };
2610
+ }
2611
+ EncodeSchema(encode, schema) {
2612
+ const Codec = { Decode: this.decode, Encode: encode };
2613
+ return { ...schema, [TransformKind]: Codec };
2614
+ }
2615
+ Encode(encode) {
2616
+ return IsTransform(this.schema) ? this.EncodeTransform(encode, this.schema) : this.EncodeSchema(encode, this.schema);
2617
+ }
2618
+ };
2619
+ function Transform(schema) {
2620
+ return new TransformDecodeBuilder(schema);
2621
+ }
2622
+
2623
+ // node_modules/@sinclair/typebox/build/esm/type/unsafe/unsafe.mjs
2624
+ function Unsafe(options = {}) {
2625
+ return CreateType({ [Kind]: options[Kind] ?? "Unsafe" }, options);
2626
+ }
2627
+
2628
+ // node_modules/@sinclair/typebox/build/esm/type/void/void.mjs
2629
+ function Void(options) {
2630
+ return CreateType({ [Kind]: "Void", type: "void" }, options);
2631
+ }
2632
+
2633
+ // node_modules/@sinclair/typebox/build/esm/type/type/type.mjs
2634
+ var type_exports2 = {};
2635
+ __export(type_exports2, {
2636
+ Any: () => Any,
2637
+ Argument: () => Argument,
2638
+ Array: () => Array2,
2639
+ AsyncIterator: () => AsyncIterator,
2640
+ Awaited: () => Awaited,
2641
+ BigInt: () => BigInt,
2642
+ Boolean: () => Boolean,
2643
+ Capitalize: () => Capitalize,
2644
+ Composite: () => Composite,
2645
+ Const: () => Const,
2646
+ Constructor: () => Constructor,
2647
+ ConstructorParameters: () => ConstructorParameters,
2648
+ Date: () => Date2,
2649
+ Enum: () => Enum,
2650
+ Exclude: () => Exclude,
2651
+ Extends: () => Extends,
2652
+ Extract: () => Extract,
2653
+ Function: () => Function,
2654
+ Index: () => Index,
2655
+ InstanceType: () => InstanceType,
2656
+ Instantiate: () => Instantiate,
2657
+ Integer: () => Integer,
2658
+ Intersect: () => Intersect,
2659
+ Iterator: () => Iterator,
2660
+ KeyOf: () => KeyOf,
2661
+ Literal: () => Literal,
2662
+ Lowercase: () => Lowercase,
2663
+ Mapped: () => Mapped,
2664
+ Module: () => Module,
2665
+ Never: () => Never,
2666
+ Not: () => Not,
2667
+ Null: () => Null,
2668
+ Number: () => Number2,
2669
+ Object: () => Object2,
2670
+ Omit: () => Omit,
2671
+ Optional: () => Optional,
2672
+ Parameters: () => Parameters,
2673
+ Partial: () => Partial,
2674
+ Pick: () => Pick,
2675
+ Promise: () => Promise2,
2676
+ Readonly: () => Readonly,
2677
+ ReadonlyOptional: () => ReadonlyOptional,
2678
+ Record: () => Record,
2679
+ Recursive: () => Recursive,
2680
+ Ref: () => Ref,
2681
+ RegExp: () => RegExp2,
2682
+ Required: () => Required,
2683
+ Rest: () => Rest,
2684
+ ReturnType: () => ReturnType,
2685
+ String: () => String2,
2686
+ Symbol: () => Symbol2,
2687
+ TemplateLiteral: () => TemplateLiteral,
2688
+ Transform: () => Transform,
2689
+ Tuple: () => Tuple,
2690
+ Uint8Array: () => Uint8Array2,
2691
+ Uncapitalize: () => Uncapitalize,
2692
+ Undefined: () => Undefined,
2693
+ Union: () => Union,
2694
+ Unknown: () => Unknown,
2695
+ Unsafe: () => Unsafe,
2696
+ Uppercase: () => Uppercase,
2697
+ Void: () => Void
2698
+ });
2699
+
2700
+ // node_modules/@sinclair/typebox/build/esm/type/type/index.mjs
2701
+ var Type = type_exports2;
2702
+
2703
+ // src/items.ts
2704
+ import * as fs from "fs";
2705
+ import * as path from "path";
2706
+ import * as os from "os";
2707
+ var ItemType = Type.Union([
2708
+ Type.Literal("trigger"),
2709
+ Type.Literal("item"),
2710
+ Type.Literal("process")
2711
+ ]);
2712
+ var ItemStatus = Type.Union([
2713
+ Type.Literal("active"),
2714
+ Type.Literal("done"),
2715
+ Type.Literal("fired"),
2716
+ Type.Literal("cancelled"),
2717
+ Type.Literal("deleted")
2718
+ ]);
2719
+ var ItemSchema = Type.Object({
2720
+ id: Type.String({ description: "Unique item ID" }),
2721
+ type: ItemType,
2722
+ title: Type.String({ description: "Display title" }),
2723
+ status: Type.Optional(ItemStatus),
2724
+ labels: Type.Optional(Type.Array(Type.String())),
2725
+ scheduledFor: Type.Optional(Type.String({ description: "ISO 8601 datetime for triggers" })),
2726
+ description: Type.Optional(Type.String()),
2727
+ url: Type.Optional(Type.String({ description: "Related URL (PR, issue, etc.)" })),
2728
+ metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
2729
+ createdAt: Type.Optional(Type.String()),
2730
+ updatedAt: Type.Optional(Type.String())
2731
+ });
2732
+ var STORE_DIR = path.join(os.homedir(), ".openclaw", "aight");
2733
+ var STORE_FILE = path.join(STORE_DIR, "items.json");
2734
+ function loadItems() {
2735
+ try {
2736
+ if (!fs.existsSync(STORE_FILE)) return [];
2737
+ const raw = fs.readFileSync(STORE_FILE, "utf-8");
2738
+ const parsed = JSON.parse(raw);
2739
+ return Array.isArray(parsed) ? parsed : [];
2740
+ } catch {
2741
+ return [];
2742
+ }
2743
+ }
2744
+ function saveItems(items) {
2745
+ fs.mkdirSync(STORE_DIR, { recursive: true });
2746
+ fs.writeFileSync(STORE_FILE, JSON.stringify(items, null, 2), { encoding: "utf-8", mode: 384 });
2747
+ }
2748
+ var MAX_TITLE_LEN = 500;
2749
+ var MAX_DESC_LEN = 5e3;
2750
+ var MAX_ITEMS = 1e4;
2751
+ function upsertItem(item) {
2752
+ if (item.title && item.title.length > MAX_TITLE_LEN) {
2753
+ throw new Error(`title exceeds max length of ${MAX_TITLE_LEN}`);
2754
+ }
2755
+ if (item.description && item.description.length > MAX_DESC_LEN) {
2756
+ throw new Error(`description exceeds max length of ${MAX_DESC_LEN}`);
2757
+ }
2758
+ const items = loadItems();
2759
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2760
+ const idx = items.findIndex((i) => i.id === item.id);
2761
+ if (idx < 0 && items.length >= MAX_ITEMS) {
2762
+ throw new Error(`item store full (max ${MAX_ITEMS})`);
2763
+ }
2764
+ const merged = {
2765
+ ...item,
2766
+ status: item.status ?? "active",
2767
+ updatedAt: now,
2768
+ createdAt: idx >= 0 ? items[idx].createdAt : now
2769
+ };
2770
+ if (idx >= 0) {
2771
+ items[idx] = merged;
2772
+ } else {
2773
+ items.push(merged);
2774
+ }
2775
+ saveItems(items);
2776
+ return merged;
2777
+ }
2778
+ function deleteItem(id) {
2779
+ const items = loadItems();
2780
+ const idx = items.findIndex((i) => i.id === id);
2781
+ if (idx < 0) return false;
2782
+ items[idx] = { ...items[idx], status: "deleted", updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
2783
+ saveItems(items);
2784
+ return true;
2785
+ }
2786
+ function listItems(filters = {}) {
2787
+ let items = loadItems().filter((i) => i.status !== "deleted");
2788
+ if (filters.type) {
2789
+ items = items.filter((i) => i.type === filters.type);
2790
+ }
2791
+ if (filters.status) {
2792
+ items = items.filter((i) => i.status === filters.status);
2793
+ }
2794
+ if (filters.labels && filters.labels.length > 0) {
2795
+ items = items.filter((i) => filters.labels.some((l) => i.labels?.includes(l)));
2796
+ }
2797
+ if (filters.from) {
2798
+ const fromTs = new Date(filters.from).getTime();
2799
+ items = items.filter((i) => {
2800
+ if (!i.scheduledFor) return true;
2801
+ return new Date(i.scheduledFor).getTime() >= fromTs;
2802
+ });
2803
+ }
2804
+ if (filters.to) {
2805
+ const toTs = new Date(filters.to).getTime();
2806
+ items = items.filter((i) => {
2807
+ if (!i.scheduledFor) return true;
2808
+ return new Date(i.scheduledFor).getTime() <= toTs;
2809
+ });
2810
+ }
2811
+ return items;
2812
+ }
2813
+ var AightItemToolParams = Type.Object({
2814
+ action: Type.Union([Type.Literal("create"), Type.Literal("update"), Type.Literal("delete")]),
2815
+ item: Type.Optional(ItemSchema),
2816
+ id: Type.Optional(Type.String({ description: "Item ID (for delete)" }))
2817
+ });
2818
+ function toLightItem(item) {
2819
+ const { description: _d, metadata: _m, url: _u, ...light } = item;
2820
+ return light;
2821
+ }
2822
+ function registerItems(api) {
2823
+ api.registerGatewayMethod(
2824
+ "aight.items.list",
2825
+ ({ params, respond }) => {
2826
+ const filters = params && typeof params === "object" ? params : {};
2827
+ respond(true, { items: listItems(filters).map(toLightItem) });
2828
+ }
2829
+ );
2830
+ api.registerGatewayMethod(
2831
+ "aight.items.get",
2832
+ ({ params, respond }) => {
2833
+ const id = typeof params?.id === "string" ? params.id : "";
2834
+ if (!id) {
2835
+ respond(false, { error: "id required" });
2836
+ return;
2837
+ }
2838
+ const all = loadItems();
2839
+ const item = all.find((i) => i.id === id);
2840
+ if (!item || item.status === "deleted") {
2841
+ respond(false, { error: "item not found" });
2842
+ return;
2843
+ }
2844
+ respond(true, { item });
2845
+ }
2846
+ );
2847
+ api.registerGatewayMethod(
2848
+ "aight.items.upsert",
2849
+ ({ params, respond }) => {
2850
+ if (!params || typeof params !== "object" || !("id" in params) || !("type" in params) || !("title" in params)) {
2851
+ respond(false, { error: "item must have id, type, and title" });
2852
+ return;
2853
+ }
2854
+ const item = upsertItem(params);
2855
+ respond(true, { item });
2856
+ }
2857
+ );
2858
+ api.registerGatewayMethod(
2859
+ "aight.items.delete",
2860
+ ({ params, respond }) => {
2861
+ const id = typeof params?.id === "string" ? params.id : "";
2862
+ if (!id) {
2863
+ respond(false, { error: "id required" });
2864
+ return;
2865
+ }
2866
+ const ok = deleteItem(id);
2867
+ respond(true, { ok, id });
2868
+ }
2869
+ );
2870
+ api.registerTool({
2871
+ name: "aight_item",
2872
+ label: "Aight Item",
2873
+ description: "Create, update, or delete a structured item in the Aight Today view. Use for reminders, tasks, events, deadlines, and process tracking. Parse natural language dates/times before calling (e.g. 'tomorrow at 3pm' \u2192 ISO 8601).",
2874
+ parameters: AightItemToolParams,
2875
+ async execute(_toolCallId, params) {
2876
+ const json = (payload) => ({
2877
+ content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
2878
+ details: payload
2879
+ });
2880
+ try {
2881
+ if (params.action === "delete") {
2882
+ const id = params.id ?? params.item?.id;
2883
+ if (!id) throw new Error("id required for delete");
2884
+ const ok = deleteItem(id);
2885
+ return json({ ok, id });
2886
+ }
2887
+ if (!params.item) throw new Error("item required for create/update");
2888
+ if (!params.item.id || !params.item.type || !params.item.title) {
2889
+ throw new Error("item must have id, type, and title");
2890
+ }
2891
+ const item = upsertItem(params.item);
2892
+ return json({ action: params.action, item });
2893
+ } catch (err) {
2894
+ return json({ error: err instanceof Error ? err.message : String(err) });
2895
+ }
2896
+ }
2897
+ });
2898
+ }
2899
+
2900
+ // src/push.ts
2901
+ import * as fs2 from "fs";
2902
+ import * as path2 from "path";
2903
+ import * as os2 from "os";
2904
+ var TOKEN_DIR = path2.join(os2.homedir(), ".openclaw", "aight");
2905
+ var TOKEN_FILE = path2.join(TOKEN_DIR, "devices.json");
2906
+ function loadTokens() {
2907
+ try {
2908
+ if (!fs2.existsSync(TOKEN_FILE)) return [];
2909
+ const raw = fs2.readFileSync(TOKEN_FILE, "utf-8");
2910
+ const parsed = JSON.parse(raw);
2911
+ return Array.isArray(parsed) ? parsed : [];
2912
+ } catch {
2913
+ return [];
2914
+ }
2915
+ }
2916
+ function saveTokens(tokens) {
2917
+ fs2.mkdirSync(TOKEN_DIR, { recursive: true, mode: 448 });
2918
+ fs2.writeFileSync(TOKEN_FILE, JSON.stringify(tokens, null, 2), { encoding: "utf-8", mode: 384 });
2919
+ }
2920
+ function registerToken(token) {
2921
+ const tokens = loadTokens();
2922
+ const idx = tokens.findIndex((t) => t.deviceId === token.deviceId);
2923
+ if (idx >= 0) {
2924
+ tokens[idx] = token;
2925
+ } else {
2926
+ tokens.push(token);
2927
+ }
2928
+ saveTokens(tokens);
2929
+ }
2930
+ function unregisterToken(deviceId) {
2931
+ const tokens = loadTokens();
2932
+ const filtered = tokens.filter((t) => t.deviceId !== deviceId);
2933
+ if (filtered.length === tokens.length) return false;
2934
+ saveTokens(filtered);
2935
+ return true;
2936
+ }
2937
+ async function obtainSendKey(relayUrl, pushToken) {
2938
+ const res = await fetch(`${relayUrl}/register`, {
2939
+ method: "POST",
2940
+ headers: { "Content-Type": "application/json" },
2941
+ body: JSON.stringify({ token: pushToken })
2942
+ });
2943
+ if (!res.ok) {
2944
+ const text = await res.text();
2945
+ throw new Error(`Relay /register returned ${res.status}: ${text}`);
2946
+ }
2947
+ const data = await res.json();
2948
+ if (!data.sendKey) throw new Error("Relay did not return a sendKey");
2949
+ return data.sendKey;
2950
+ }
2951
+ async function sendPush(deviceId, payload, config) {
2952
+ const tokens = loadTokens();
2953
+ const device = tokens.find((t) => t.deviceId === deviceId);
2954
+ if (!device) {
2955
+ return { ok: false, error: `No device token for ${deviceId}` };
2956
+ }
2957
+ if (!device.sendKey) {
2958
+ return { ok: false, error: `No sendKey for device ${deviceId} \u2014 re-register to obtain one` };
2959
+ }
2960
+ const relayUrl = config.push?.relayUrl ?? DEFAULT_RELAY_URL;
2961
+ const mode = config.push?.mode ?? DEFAULT_PUSH_MODE;
2962
+ const pushBody = {
2963
+ token: device.pushToken,
2964
+ sendKey: device.sendKey,
2965
+ platform: device.platform,
2966
+ sandbox: device.sandbox ?? false
2967
+ };
2968
+ if (mode === "rich" && !payload.silent) {
2969
+ pushBody.title = payload.title;
2970
+ if (payload.subtitle) pushBody.subtitle = payload.subtitle;
2971
+ pushBody.body = payload.body;
2972
+ }
2973
+ if (payload.data) {
2974
+ pushBody.data = payload.data;
2975
+ }
2976
+ try {
2977
+ const res = await fetch(`${relayUrl}/send`, {
2978
+ method: "POST",
2979
+ headers: { "Content-Type": "application/json" },
2980
+ body: JSON.stringify(pushBody)
2981
+ });
2982
+ if (!res.ok) {
2983
+ const text = await res.text();
2984
+ return { ok: false, error: `Relay returned ${res.status}: ${text}` };
2985
+ }
2986
+ return { ok: true };
2987
+ } catch (err) {
2988
+ return { ok: false, error: err instanceof Error ? err.message : String(err) };
2989
+ }
2990
+ }
2991
+ function registerPush(api, _config) {
2992
+ api.registerGatewayMethod(
2993
+ "aight.push.register",
2994
+ ({ params, respond }) => {
2995
+ if (!params || typeof params !== "object" || typeof params.deviceId !== "string" || typeof params.pushToken !== "string" || params.platform !== "ios" && params.platform !== "android") {
2996
+ respond(false, { error: "deviceId, pushToken, and platform (ios|android) required" });
2997
+ return;
2998
+ }
2999
+ const deviceId = params.deviceId;
3000
+ const pushToken = params.pushToken;
3001
+ const platform = params.platform;
3002
+ const sandbox = !!params.sandbox;
3003
+ registerToken({
3004
+ deviceId,
3005
+ pushToken,
3006
+ platform,
3007
+ sandbox,
3008
+ registeredAt: (/* @__PURE__ */ new Date()).toISOString()
3009
+ });
3010
+ respond(true, { ok: true, deviceId });
3011
+ api.logger.info(`[aight-utils] Push token registered for device ${deviceId}`);
3012
+ const relayUrl = _config.push?.relayUrl ?? DEFAULT_RELAY_URL;
3013
+ obtainSendKey(relayUrl, pushToken).then((sendKey) => {
3014
+ registerToken({
3015
+ deviceId,
3016
+ pushToken,
3017
+ platform,
3018
+ sandbox,
3019
+ sendKey,
3020
+ registeredAt: (/* @__PURE__ */ new Date()).toISOString()
3021
+ });
3022
+ api.logger.info(`[aight-utils] sendKey obtained for device ${deviceId}`);
3023
+ }).catch((err) => {
3024
+ const msg = err instanceof Error ? err.message : String(err);
3025
+ api.logger.warn(`[aight-utils] Failed to obtain sendKey: ${msg}`);
3026
+ });
3027
+ }
3028
+ );
3029
+ api.registerGatewayMethod(
3030
+ "aight.push.unregister",
3031
+ ({ params, respond }) => {
3032
+ const deviceId = typeof params?.deviceId === "string" ? params.deviceId : "";
3033
+ if (!deviceId) {
3034
+ respond(false, { error: "deviceId required" });
3035
+ return;
3036
+ }
3037
+ const ok = unregisterToken(deviceId);
3038
+ respond(true, { ok, deviceId });
3039
+ }
3040
+ );
3041
+ api.registerGatewayMethod(
3042
+ "aight.push.test",
3043
+ async ({ params, respond }) => {
3044
+ const deviceId = typeof params?.deviceId === "string" ? params.deviceId : "";
3045
+ const tokens = loadTokens();
3046
+ const device = deviceId ? tokens.find((t) => t.deviceId === deviceId) : tokens[0];
3047
+ if (!device) {
3048
+ respond(false, { error: "No registered device" });
3049
+ return;
3050
+ }
3051
+ const result = await sendPush(
3052
+ device.deviceId,
3053
+ {
3054
+ title: "Aight \u{1F919}",
3055
+ body: "Push notifications are working!"
3056
+ },
3057
+ { ..._config, push: { ..._config.push, mode: "rich" } }
3058
+ );
3059
+ respond(true, result);
3060
+ }
3061
+ );
3062
+ }
3063
+
3064
+ // src/reminders.ts
3065
+ var CHECK_INTERVAL_MS = 3e4;
3066
+ function registerReminders(api, config) {
3067
+ let timer = null;
3068
+ async function checkReminders() {
3069
+ const now = Date.now();
3070
+ const items = loadItems();
3071
+ let changed = false;
3072
+ const dueItems = items.filter(
3073
+ (i) => i.type === "trigger" && i.status === "active" && i.scheduledFor && new Date(i.scheduledFor).getTime() <= now
3074
+ );
3075
+ if (dueItems.length === 0) return;
3076
+ const tokens = loadTokens();
3077
+ for (const item of dueItems) {
3078
+ item.status = "fired";
3079
+ item.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
3080
+ changed = true;
3081
+ api.logger.info(`[aight-utils] Trigger fired: ${item.title} (${item.id})`);
3082
+ for (const device of tokens) {
3083
+ try {
3084
+ await sendPush(
3085
+ device.deviceId,
3086
+ {
3087
+ title: "Reminder",
3088
+ body: item.title,
3089
+ data: { itemId: item.id, type: "trigger" }
3090
+ },
3091
+ config
3092
+ );
3093
+ } catch (err) {
3094
+ api.logger.error(
3095
+ `[aight-utils] Push failed for ${device.deviceId}: ${err instanceof Error ? err.message : String(err)}`
3096
+ );
3097
+ }
3098
+ }
3099
+ }
3100
+ if (changed) {
3101
+ saveItems(items);
3102
+ }
3103
+ }
3104
+ api.registerService({
3105
+ id: "aight-reminders",
3106
+ start: () => {
3107
+ if (config.today?.enabled === false) {
3108
+ api.logger.info("[aight-utils] Today view disabled, skipping reminders service");
3109
+ return;
3110
+ }
3111
+ timer = setInterval(() => {
3112
+ checkReminders().catch((err) => {
3113
+ api.logger.error(
3114
+ `[aight-utils] Reminder check error: ${err instanceof Error ? err.message : String(err)}`
3115
+ );
3116
+ });
3117
+ }, CHECK_INTERVAL_MS);
3118
+ api.logger.info("[aight-utils] Reminders service started (30s interval)");
3119
+ },
3120
+ stop: () => {
3121
+ if (timer) {
3122
+ clearInterval(timer);
3123
+ timer = null;
3124
+ }
3125
+ api.logger.info("[aight-utils] Reminders service stopped");
3126
+ }
3127
+ });
3128
+ }
3129
+
3130
+ // src/bootstrap.ts
3131
+ var AIGHT_MD = `# Aight Integration
3132
+
3133
+ ## \u26A0\uFE0F Shortcuts Protocol (CRITICAL \u2014 follow exactly)
3134
+
3135
+ When you receive a message starting with "shortcut:", you MUST reply with ONLY a JSON object \u2014 no explanation, no markdown fences, no other text:
3136
+ {"short_name": "Example Name", "emoji": "\u{1F3AF}"}
3137
+ Rules:
3138
+ - short_name: 2-4 words, Title Case, describing what the shortcut does
3139
+ - emoji: a single relevant emoji
3140
+ - Do NOT answer the question in the shortcut text. Just label it.
3141
+ - Reply with NOTHING else \u2014 just the raw JSON object
3142
+
3143
+ Aight is the iOS app the user is chatting through. It connects to the OpenClaw gateway running on their machine, giving them a native mobile interface for their AI agent.
3144
+
3145
+ ## What You Can Do (via Aight)
3146
+
3147
+ When the user asks "What can you do?" \u2014 here's what to highlight:
3148
+
3149
+ - **Chat naturally** \u2014 Ask anything, get help with tasks, brainstorm ideas
3150
+ - **Set reminders & track tasks** \u2014 "Remind me to call the dentist tomorrow at 2pm" \u2192 creates a reminder in the Today view
3151
+ - **Voice mode** \u2014 Tap the mic to talk instead of type; you respond with voice too
3152
+ - **Manage calendar & email** \u2014 Check schedule, draft emails, summarize inbox
3153
+ - **Search the web** \u2014 Real-time web search, fetch pages, summarize articles
3154
+ - **Run shortcuts** \u2014 Quick-access saved prompts for things you do often
3155
+ - **Browse the Skills marketplace** \u2014 700+ skills to extend capabilities (weather, GitHub, music, finance, etc.)
3156
+ - **Create custom agents** \u2014 Spin up specialized AI personas for different tasks
3157
+ - **Today view** \u2014 A personal dashboard with reminders, tasks, deadlines, and background processes
3158
+ - **Sub-agents** \u2014 Delegate complex tasks to background workers that report back when done
3159
+ - **Group chats** \u2014 Multi-agent conversations where your agents collaborate
3160
+ - **Security built-in** \u2014 All data stays on your machine; nothing phones home
3161
+
3162
+ Keep the response conversational and concise \u2014 don't dump the whole list. Pick 4-5 highlights that feel most relevant, and mention there's more to explore in Skills and Settings.
3163
+
3164
+ ## Audio / Voice (Aight App)
3165
+
3166
+ The Aight app handles all speech-to-text and text-to-speech on the client side.
3167
+ - **Inbound:** The app converts the user's voice to text before sending it to the gateway. You always receive text.
3168
+ - **Outbound:** Always respond with plain text only. If the user has voice mode enabled, the app will convert your text response to speech automatically.
3169
+ - **Never use the TTS tool or send audio files** when the channel is an Aight app client. The app cannot stream audio from the gateway and it will cause playback issues.
3170
+
3171
+ ## When to Use \`aight_item\` (Aight App)
3172
+
3173
+ - User asks to **set a reminder**: create a trigger with \`scheduledFor\` (ISO 8601)
3174
+ - User asks to **create a task**: create an item with labels
3175
+ - User mentions a **deadline or event**: create a trigger with appropriate type
3176
+ - User wants to **track a PR/issue**: create an item with a URL
3177
+ - User says **"done"** or **"cancel"**: update status to "done" or "cancelled"
3178
+
3179
+ ## Item Types (Aight App)
3180
+
3181
+ | Type | Use For | Examples |
3182
+ |------|---------|---------|
3183
+ | \`trigger\` | Time-based, fire-once | Reminders, events, deadlines |
3184
+ | \`item\` | Stateful, lifecycle | Tasks, PRs, issues, projects |
3185
+ | \`process\` | Background work | Subagent runs, builds, deploys |
3186
+
3187
+ ## Rules (Aight App)
3188
+
3189
+ - Always generate a unique \`id\` (use a short slug like \`remind-groceries-1708012800\`)
3190
+ - Parse natural language dates to ISO 8601 before calling the tool
3191
+ - Set \`labels\` for categorization (e.g. \`["work", "urgent"]\`)
3192
+ - Default status is \`"active"\` \u2014 don't set it unless changing state
3193
+ - For reminders: set \`type: "trigger"\` and include \`scheduledFor\`
3194
+ - For tasks: set \`type: "item"\`
3195
+
3196
+ ## Public Figure Agent Creation (Aight App)
3197
+
3198
+ When you receive a message starting with "[PUBLIC_FIGURE_AGENT]", **immediately spawn a
3199
+ sub-agent** to handle the creation. This ensures a fresh session with no stale context.
3200
+
3201
+ **Do NOT try to create the agent yourself inline.** Always delegate via \`sessions_spawn\`.
3202
+
3203
+ \`\`\`
3204
+ sessions_spawn({
3205
+ task: <the full instructions below, with the person's name filled in>,
3206
+ model: "sonnet",
3207
+ label: "create-agent-<kebab-name>"
3208
+ })
3209
+ \`\`\`
3210
+
3211
+ The sub-agent task message should contain ALL of the following instructions:
3212
+
3213
+ ---
3214
+
3215
+ Create a new OpenClaw agent based on the public figure: "<Person's Name>"
3216
+
3217
+ ### Step 1: Research
3218
+ 1. Search the web for: their career, public persona, communication style, notable quotes
3219
+ 2. Search X/Twitter if relevant for their voice/tone
3220
+ 3. Identify: communication style, core expertise, personality traits, catchphrases, how they respond to questions
3221
+
3222
+ ### Step 2: Create the Agent
3223
+ Use these tools in order:
3224
+
3225
+ 1. **Read the OpenClaw config** to check the agent doesn't already exist:
3226
+ \`\`\`
3227
+ exec: grep "<agent-id>" ~/.openclaw/openclaw.json
3228
+ \`\`\`
3229
+
3230
+ 2. **Create workspace and agent directories:**
3231
+ \`\`\`
3232
+ exec: mkdir -p ~/.openclaw/workspace-<agent-id>/memory ~/.openclaw/agents/<agent-id>/agent ~/.openclaw/agents/<agent-id>/sessions
3233
+ \`\`\`
3234
+
3235
+ 3. **Copy model/auth config from an existing agent:**
3236
+ \`\`\`
3237
+ exec: cp ~/.openclaw/agents/the-strategist/agent/models.json ~/.openclaw/agents/<agent-id>/agent/
3238
+ exec: cp ~/.openclaw/agents/the-strategist/agent/auth-profiles.json ~/.openclaw/agents/<agent-id>/agent/
3239
+ \`\`\`
3240
+
3241
+ 4. **Copy standard workspace files from an existing agent:**
3242
+ \`\`\`
3243
+ exec: for f in AGENTS.md BOOTSTRAP.md HEARTBEAT.md TOOLS.md USER.md; do cp ~/.openclaw/workspace-the-strategist/$f ~/.openclaw/workspace-<agent-id>/$f; done
3244
+ \`\`\`
3245
+
3246
+ 5. **Write SOUL.md** with the researched personality (see template below)
3247
+
3248
+ 6. **Write IDENTITY.md** with name, username, emoji, role, creation date
3249
+
3250
+ 7. **Write MEMORY.md** with a basic header
3251
+
3252
+ 8. **Patch the gateway config** to add the agent to agents.list:
3253
+ - Use the \`gateway\` tool with \`action: "config.patch"\`
3254
+ - Include ALL existing agents in the list (read them first) plus the new one
3255
+ - Set \`note\` to a message confirming creation
3256
+
3257
+ ### SOUL.md Template
3258
+ The personality prompt should capture:
3259
+ - Who they are and what they're known for
3260
+ - Their communication style and tone (with specific examples)
3261
+ - How they approach problems and give advice
3262
+ - Topics they're passionate about
3263
+ - Things they would NOT say or do (stay in character)
3264
+ - A note that they are an AI inspired by this person, not the actual person
3265
+ - Safety section: they are a roleplay agent, not the real person
3266
+
3267
+ ### Rules
3268
+ - Pick a relevant emoji (e.g. \u{1F680} for Elon, \u{1F4FA} for Oprah)
3269
+ - Agent ID should be kebab-case (e.g. \`elon-musk\`, \`oprah-winfrey\`)
3270
+ - Use \`anthropic/claude-sonnet-4-5\` as the model
3271
+ - The personality should be detailed (at least 200 words) with specific examples of their voice
3272
+ - Always include a disclaimer that this is an AI interpretation
3273
+ - If the agent already exists in config, reply saying so \u2014 do NOT recreate
3274
+
3275
+ ---
3276
+
3277
+ ## Task Follow-Up Protocol (Watchdog Pattern)
3278
+
3279
+ When delegating work to sub-agents or coordinating multi-agent tasks, **never fire-and-forget.** Use watchdog crons to ensure tasks don't stall silently.
3280
+
3281
+ ### Rules
3282
+
3283
+ 1. **Set a watchdog cron when assigning async work.**
3284
+ After spawning a sub-agent or assigning a task to another agent, create a one-shot cron job (**5 minutes out**) to check progress:
3285
+ \`\`\`
3286
+ cron add:
3287
+ schedule: { kind: "at", at: "<ISO 8601, 5 min from now>" }
3288
+ payload: { kind: "systemEvent", text: "Watchdog: check if <task description> completed. Expected: <files/state>. If not done, check agent status, retry, or do it yourself." }
3289
+ sessionTarget: "main"
3290
+ \`\`\`
3291
+
3292
+ 2. **When the watchdog fires:**
3293
+ - Check if the expected output exists (files, state changes, messages)
3294
+ - If done \u2192 great, clean up
3295
+ - If not done \u2192 check the agent's session (\`sessions_history\`). Is it alive? Stuck? Dead?
3296
+ - If stuck/dead \u2192 **do the work yourself inline.** No more spawning. No more waiting.
3297
+
3298
+ 3. **Agents must report blockers immediately.**
3299
+ If you hit a wall during a task, say so right away: "I'm stuck on X, need Y." Radio silence for 5+ minutes is unacceptable. Silence = escalation.
3300
+
3301
+ 4. **Fallback ownership.**
3302
+ If an agent (or you as coordinator) hasn't made progress in 5 minutes, take over or reassign. No task sits in limbo.
3303
+
3304
+ 5. **Never report failure as a final answer.**
3305
+ "The sub-agent died" is not acceptable. "The sub-agent died so I did it myself" is. You own the outcome, not the sub-agent.
3306
+
3307
+ ### When to Use Watchdogs
3308
+ - Sub-agent spawns (\`sessions_spawn\`)
3309
+ - Multi-step group chat tasks (e.g., "build and test this PR")
3310
+ - Any async work where you're waiting on another agent
3311
+ - Background processes (builds, deploys, long-running scripts)
3312
+
3313
+ ### When NOT Needed
3314
+ - Simple inline tasks you do yourself
3315
+ - Quick questions to another agent in a group chat
3316
+ - One-shot tool calls that return immediately
3317
+
3318
+ ## Group Chat Message Format
3319
+
3320
+ When you receive a message prefixed with \`[Group Chat: "Name" \u2014 Members: ...]\`, you are in a group chat. The format is:
3321
+
3322
+ \`\`\`
3323
+ [Group Chat: "Name" \u2014 Members: emoji Name (@username), ...]
3324
+ [Recent messages]
3325
+ emoji SenderName: message text
3326
+ emoji SenderName: [your message at HH:MM]
3327
+ emoji SenderName: message text
3328
+ ...
3329
+
3330
+ [Your turn]
3331
+ The user's actual message
3332
+ \`\`\`
3333
+
3334
+ **Your own messages are stubbed.** To save tokens, the app replaces the body of your own messages in the recent messages block with \`[your message at HH:MM]\`. You already have the full text in your session history, so no information is lost. Other agents' and the user's messages are shown in full.
3335
+
3336
+ Rules:
3337
+ - To address another agent, **@mention them** in your reply text. The app routes automatically.
3338
+ - Do **NOT** use \`sessions_send\` \u2014 just @mention in your message.
3339
+ - Recent messages provide conversational context \u2014 the gateway session has full history.
3340
+ - \`[Your turn]\` marks the boundary between context and the new message you should respond to.
3341
+ - If you need to recall what you said at a specific time, check your own session history \u2014 it has the full text.
3342
+
3343
+ ## Group Chat \u2014 Task Protocol
3344
+
3345
+ When a task is posted in any group chat, follow these rules **without exception:**
3346
+
3347
+ ### 1. Claim Immediately
3348
+ When you start working on something, say so in the group chat. No silent pickups.
3349
+ Example: "Claiming this \u2014 looking at the inline code rendering in CodeRenderer.m now."
3350
+
3351
+ ### 2. Report Completion
3352
+ When done, post in the group:
3353
+ - **Commit hash** (or what you changed)
3354
+ - **What changed** (1-2 sentences)
3355
+ - **What's needed next** (e.g. "needs native rebuild", "ready for QA", "blocked on X")
3356
+
3357
+ Don't wait to be asked. Don't go silent after finishing.
3358
+
3359
+ ### 3. Report Blockers Fast (<2 min)
3360
+ If you're stuck, say so immediately. Don't spend 10 minutes silently struggling.
3361
+ Example: "Blocker: CocoaPods fails with Ruby 4.0 encoding error. Need to downgrade Ruby or find workaround."
3362
+
3363
+ ### 4. No Limbo
3364
+ If you've been working on something for 5+ minutes with no progress, escalate or hand it off. Tasks do not sit in limbo.
3365
+
3366
+ ### 5. Silence = Escalation
3367
+ If an agent goes silent for 5+ minutes during an active task, any other agent (or the coordinator) should take over. Don't wait for permission.
3368
+
3369
+ **This protocol exists because agents repeatedly picked up tasks, worked silently, and never reported back \u2014 forcing Bruno to chase every time. That stops now.**
3370
+
3371
+ ## Shortcuts (Aight App)
3372
+
3373
+ See the Shortcuts Protocol at the top of this document.
3374
+
3375
+ `;
3376
+ function registerBootstrap(api) {
3377
+ try {
3378
+ api.logger.info("[aight-utils] Attempting to register bootstrap hook...");
3379
+ api.logger.info(`[aight-utils] api.on type: ${typeof api.on}`);
3380
+ api.on("before_agent_start", (_event, ctx) => {
3381
+ api.logger.info(
3382
+ `[aight-utils] Bootstrap: injecting AIGHT.md into session ${ctx?.sessionKey}`
3383
+ );
3384
+ return { systemPrompt: AIGHT_MD };
3385
+ });
3386
+ api.logger.info("[aight-utils] Bootstrap hook registered (before_agent_start)");
3387
+ } catch (err) {
3388
+ api.logger.error(`[aight-utils] Failed to register bootstrap hook: ${err}`);
3389
+ }
3390
+ }
3391
+
3392
+ // src/groups.ts
3393
+ import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "fs";
3394
+ import { join as join3 } from "path";
3395
+ var FILENAME = "group-names.json";
3396
+ function filePath(api) {
3397
+ const dir = api.dataDir ?? join3(process.env.HOME ?? "/tmp", ".openclaw", "plugin-data", "aight-utils");
3398
+ mkdirSync3(dir, { recursive: true });
3399
+ return join3(dir, FILENAME);
3400
+ }
3401
+ function loadAll(api) {
3402
+ try {
3403
+ return JSON.parse(readFileSync3(filePath(api), "utf-8"));
3404
+ } catch {
3405
+ return {};
3406
+ }
3407
+ }
3408
+ function saveAll(api, data) {
3409
+ writeFileSync3(filePath(api), JSON.stringify(data), "utf-8");
3410
+ }
3411
+ function loadGroupName(api, groupId) {
3412
+ return loadAll(api)[groupId];
3413
+ }
3414
+ function registerGroupName(api, groupId, name) {
3415
+ const data = loadAll(api);
3416
+ data[groupId] = name;
3417
+ saveAll(api, data);
3418
+ }
3419
+ function removeGroupName(api, groupId) {
3420
+ const data = loadAll(api);
3421
+ delete data[groupId];
3422
+ saveAll(api, data);
3423
+ }
3424
+ function registerGroupRpc(api) {
3425
+ api.registerGatewayMethod("aight.groups.setName", ({ params, respond }) => {
3426
+ const { groupId, name } = params ?? {};
3427
+ if (!groupId || !name) {
3428
+ respond(false, { error: "groupId and name are required" });
3429
+ return;
3430
+ }
3431
+ registerGroupName(api, groupId, name);
3432
+ respond(true, { ok: true });
3433
+ });
3434
+ api.registerGatewayMethod("aight.groups.removeName", ({ params, respond }) => {
3435
+ const { groupId } = params ?? {};
3436
+ if (!groupId) {
3437
+ respond(false, { error: "groupId is required" });
3438
+ return;
3439
+ }
3440
+ removeGroupName(api, groupId);
3441
+ respond(true, { ok: true });
3442
+ });
3443
+ api.logger.info("[aight-utils] Group name RPC registered");
3444
+ }
3445
+
3446
+ // src/notif-prefs.ts
3447
+ import * as fs3 from "fs";
3448
+ import * as path3 from "path";
3449
+ import * as os3 from "os";
3450
+ var DEFAULTS = {
3451
+ globalMute: false,
3452
+ muteUntil: null,
3453
+ agentReplies: true,
3454
+ groupChat: true,
3455
+ cron: false
3456
+ };
3457
+ var PREFS_DIR = path3.join(os3.homedir(), ".openclaw", "aight");
3458
+ var PREFS_FILE = path3.join(PREFS_DIR, "notif-prefs.json");
3459
+ function loadNotifPrefs() {
3460
+ try {
3461
+ if (!fs3.existsSync(PREFS_FILE)) return { ...DEFAULTS };
3462
+ const raw = fs3.readFileSync(PREFS_FILE, "utf-8");
3463
+ const parsed = JSON.parse(raw);
3464
+ return { ...DEFAULTS, ...parsed };
3465
+ } catch {
3466
+ return { ...DEFAULTS };
3467
+ }
3468
+ }
3469
+ function saveNotifPrefs(prefs) {
3470
+ fs3.mkdirSync(PREFS_DIR, { recursive: true, mode: 448 });
3471
+ fs3.writeFileSync(PREFS_FILE, JSON.stringify(prefs, null, 2), "utf-8");
3472
+ }
3473
+ function classifySessionKey(sessionKey) {
3474
+ if (sessionKey.includes(":cron:")) return "cron";
3475
+ if (sessionKey.includes(":group-chat:")) return "groupChat";
3476
+ return "agentReplies";
3477
+ }
3478
+ function shouldSendPush(sessionKey) {
3479
+ if (!sessionKey) return true;
3480
+ const prefs = loadNotifPrefs();
3481
+ if (prefs.globalMute) {
3482
+ if (!prefs.muteUntil) return false;
3483
+ const expiry = new Date(prefs.muteUntil).getTime();
3484
+ if (Date.now() < expiry) return false;
3485
+ prefs.globalMute = false;
3486
+ prefs.muteUntil = null;
3487
+ saveNotifPrefs(prefs);
3488
+ }
3489
+ const category = classifySessionKey(sessionKey);
3490
+ return prefs[category];
3491
+ }
3492
+ function registerNotifPrefsRPC(api) {
3493
+ api.registerGatewayMethod("aight.notif.getPrefs", ({ respond }) => {
3494
+ respond(true, loadNotifPrefs());
3495
+ });
3496
+ api.registerGatewayMethod(
3497
+ "aight.notif.setPrefs",
3498
+ ({ params, respond }) => {
3499
+ const update = params ?? {};
3500
+ const current = loadNotifPrefs();
3501
+ if (typeof update.globalMute === "boolean") current.globalMute = update.globalMute;
3502
+ if (typeof update.agentReplies === "boolean") current.agentReplies = update.agentReplies;
3503
+ if (typeof update.groupChat === "boolean") current.groupChat = update.groupChat;
3504
+ if (typeof update.cron === "boolean") current.cron = update.cron;
3505
+ if (update.muteUntil !== void 0) current.muteUntil = update.muteUntil;
3506
+ saveNotifPrefs(current);
3507
+ api.logger.info(`[aight-utils] Notification prefs updated: ${JSON.stringify(current)}`);
3508
+ respond(true, current);
3509
+ }
3510
+ );
3511
+ api.logger.info("[aight-utils] Notification prefs RPC registered");
3512
+ }
3513
+
3514
+ // src/push-hook.ts
3515
+ function registerPushHook(api) {
3516
+ try {
3517
+ api.on("agent_end", async (event, ctx) => {
3518
+ api.logger.info(
3519
+ `[aight-utils] agent_end fired session=${ctx.sessionKey} agent=${ctx.agentId}`
3520
+ );
3521
+ const tokens = loadTokens();
3522
+ if (tokens.length === 0) return;
3523
+ const sk = ctx.sessionKey ?? "";
3524
+ if (sk.endsWith(":aight-config") || sk.endsWith(":aight-pentest") || sk.endsWith(":speak") || sk.endsWith(":structured_content") || sk.endsWith(":main") || sk.includes("subagent") || sk.includes("security-audit") || sk.includes("_skill-audit-") || sk.includes("_ensure-skill-defender") || sk.endsWith("security-fix") || sk.endsWith("skill-scan")) {
3525
+ api.logger.info(`[aight-utils] Skipping hidden session push: ${sk}`);
3526
+ return;
3527
+ }
3528
+ const msgs = event.messages ?? [];
3529
+ api.logger.info(
3530
+ `[aight-utils] messages count=${msgs.length} roles=${msgs.map((m) => m.role).join(",")}`
3531
+ );
3532
+ let preview = "";
3533
+ for (let i = msgs.length - 1; i >= 0; i--) {
3534
+ const m = msgs[i];
3535
+ if (m.role === "assistant") {
3536
+ if (typeof m.content === "string" && m.content.trim()) {
3537
+ preview = m.content.slice(0, 200);
3538
+ break;
3539
+ }
3540
+ if (Array.isArray(m.content)) {
3541
+ const textBlock = m.content.find(
3542
+ (b) => b.type === "text" && typeof b.text === "string"
3543
+ );
3544
+ if (textBlock) {
3545
+ preview = textBlock.text.slice(0, 200);
3546
+ break;
3547
+ }
3548
+ }
3549
+ }
3550
+ }
3551
+ if (!preview) {
3552
+ api.logger.info(`[aight-utils] No preview found, skipping push`);
3553
+ return;
3554
+ }
3555
+ const sessionKey_ = ctx.sessionKey ?? "";
3556
+ const HIDDEN_SESSIONS = ["aight-config", "structured_content"];
3557
+ if (HIDDEN_SESSIONS.some((h) => sessionKey_.includes(h))) {
3558
+ api.logger.info(`[aight-utils] Skipping hidden session: ${sessionKey_}`);
3559
+ return;
3560
+ }
3561
+ const skip = ["NO_REPLY", "REPLY_SKIP", "ANNOUNCE_SKIP", "HEARTBEAT_OK"];
3562
+ if (skip.includes(preview.trim())) {
3563
+ api.logger.info(`[aight-utils] Skipping meta response: ${preview.trim()}`);
3564
+ return;
3565
+ }
3566
+ const freshConfig = getPluginConfig(api);
3567
+ const agentId = ctx.agentId ?? "agent";
3568
+ const agents = api.config?.agents?.list ?? [];
3569
+ const agent = agents.find((a) => a.id === agentId);
3570
+ const displayName = agent?.name ?? agent?.identity?.name ?? agentId;
3571
+ const pushTitle = displayName;
3572
+ let pushSubtitle;
3573
+ const sessionKey = ctx.sessionKey ?? "";
3574
+ if (sessionKey.includes(":group-chat:")) {
3575
+ const groupId = sessionKey.split(":group-chat:")[1];
3576
+ if (groupId) {
3577
+ const groupName = loadGroupName(api, groupId);
3578
+ if (groupName) {
3579
+ pushSubtitle = groupName;
3580
+ }
3581
+ }
3582
+ }
3583
+ const cleanBody = preview.trim().replace(/\n+/g, " ").trim();
3584
+ const sk_ = ctx.sessionKey ?? "";
3585
+ if (!shouldSendPush(sk_)) {
3586
+ api.logger.info(`[aight-utils] Push suppressed by notification prefs: ${sk_}`);
3587
+ return;
3588
+ }
3589
+ for (const device of tokens) {
3590
+ if (!device.sendKey) continue;
3591
+ try {
3592
+ const pushResult = await sendPush(
3593
+ device.deviceId,
3594
+ {
3595
+ title: pushTitle.trim(),
3596
+ subtitle: pushSubtitle,
3597
+ body: cleanBody,
3598
+ data: { sessionKey: ctx.sessionKey, agentId }
3599
+ },
3600
+ freshConfig
3601
+ );
3602
+ api.logger.info(
3603
+ `[aight-utils] Push sent: session=${ctx.sessionKey} device=${device.deviceId} ok=${pushResult.ok}${pushResult.error ? ` error=${pushResult.error}` : ""}`
3604
+ );
3605
+ if (!pushResult.ok && pushResult.error) {
3606
+ const err = pushResult.error.toLowerCase();
3607
+ if (err.includes("baddevicetoken") || err.includes("unregistered") || err.includes("devicetokennotfortopic") || err.includes("expired")) {
3608
+ api.logger.info(`[aight-utils] Pruning stale device token: ${device.deviceId}`);
3609
+ unregisterToken(device.deviceId);
3610
+ }
3611
+ }
3612
+ } catch (err) {
3613
+ api.logger.warn(
3614
+ `[aight-utils] Push failed: ${err instanceof Error ? err.message : String(err)}`
3615
+ );
3616
+ }
3617
+ }
3618
+ });
3619
+ api.logger.info("[aight-utils] Push hook registered (agent_end)");
3620
+ } catch (err) {
3621
+ api.logger.error(
3622
+ `[aight-utils] Failed to register push hook: ${err instanceof Error ? err.message : String(err)}`
3623
+ );
3624
+ }
3625
+ }
3626
+
3627
+ // src/health.ts
3628
+ import * as os4 from "os";
3629
+ import * as fs4 from "fs";
3630
+ function getStats() {
3631
+ let memory = null;
3632
+ let cpu = null;
3633
+ let disk = null;
3634
+ try {
3635
+ const totalBytes = os4.totalmem();
3636
+ const freeBytes = os4.freemem();
3637
+ const usedBytes = totalBytes - freeBytes;
3638
+ const totalGB = totalBytes / 1073741824;
3639
+ const usedGB = usedBytes / 1073741824;
3640
+ memory = {
3641
+ usedGB: Math.round(usedGB * 10) / 10,
3642
+ totalGB: Math.round(totalGB * 10) / 10,
3643
+ percent: Math.round(usedGB / totalGB * 100)
3644
+ };
3645
+ const load1m = os4.loadavg()[0];
3646
+ const cores = os4.cpus().length;
3647
+ cpu = { percent: Math.round(Math.min(load1m / cores * 100, 100)) };
3648
+ const stat = fs4.statfsSync("/");
3649
+ const totalDiskBytes = stat.blocks * stat.bsize;
3650
+ const freeDiskBytes = stat.bfree * stat.bsize;
3651
+ const usedDiskBytes = totalDiskBytes - freeDiskBytes;
3652
+ disk = {
3653
+ totalGB: Math.round(totalDiskBytes / 1073741824),
3654
+ usedGB: Math.round(usedDiskBytes / 1073741824),
3655
+ percent: Math.round(usedDiskBytes / totalDiskBytes * 100)
3656
+ };
3657
+ } catch {
3658
+ }
3659
+ return { memory, cpu, disk };
3660
+ }
3661
+ function registerHealth(api) {
3662
+ api.registerGatewayMethod("aight.health", async ({ respond }) => {
3663
+ try {
3664
+ const stats = getStats();
3665
+ respond(true, stats);
3666
+ } catch (err) {
3667
+ respond(false, {
3668
+ error: err instanceof Error ? err.message : String(err)
3669
+ });
3670
+ }
3671
+ });
3672
+ }
3673
+
3674
+ // src/version.ts
3675
+ import { createRequire } from "module";
3676
+ import { readFileSync as readFileSync5 } from "fs";
3677
+ import { join as join5, dirname } from "path";
3678
+ import { fileURLToPath } from "url";
3679
+ var cachedVersion = null;
3680
+ var CACHE_TTL_MS = 60 * 60 * 1e3;
3681
+ function getCurrentVersion() {
3682
+ if (cachedVersion) return cachedVersion;
3683
+ try {
3684
+ const dir = dirname(fileURLToPath(import.meta.url));
3685
+ const pkg = JSON.parse(readFileSync5(join5(dir, "..", "package.json"), "utf8"));
3686
+ cachedVersion = pkg.version ?? "unknown";
3687
+ } catch {
3688
+ cachedVersion = "unknown";
3689
+ }
3690
+ return cachedVersion;
3691
+ }
3692
+ var cachedGatewayVersion = null;
3693
+ function getGatewayVersion() {
3694
+ if (cachedGatewayVersion) return cachedGatewayVersion;
3695
+ try {
3696
+ const require_ = createRequire(import.meta.url);
3697
+ const resolved = require_.resolve("openclaw");
3698
+ const pkgPath = join5(dirname(resolved), "package.json");
3699
+ const pkg = JSON.parse(readFileSync5(pkgPath, "utf8"));
3700
+ cachedGatewayVersion = pkg.version ?? "unknown";
3701
+ } catch {
3702
+ cachedGatewayVersion = "unknown";
3703
+ }
3704
+ return cachedGatewayVersion;
3705
+ }
3706
+ var npmCache = /* @__PURE__ */ new Map();
3707
+ async function getLatestNpmVersion(pkg) {
3708
+ const cached = npmCache.get(pkg);
3709
+ if (cached && Date.now() - cached.checkedAt < CACHE_TTL_MS) {
3710
+ return cached.version;
3711
+ }
3712
+ try {
3713
+ const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(pkg)}/latest`, {
3714
+ headers: { accept: "application/json" },
3715
+ signal: AbortSignal.timeout(5e3)
3716
+ });
3717
+ if (!res.ok) return "unknown";
3718
+ const data = await res.json();
3719
+ const version = data.version ?? "unknown";
3720
+ npmCache.set(pkg, { version, checkedAt: Date.now() });
3721
+ return version;
3722
+ } catch {
3723
+ return cached?.version ?? "unknown";
3724
+ }
3725
+ }
3726
+ function registerVersion(api) {
3727
+ api.registerGatewayMethod("aight.version", async ({ respond }) => {
3728
+ try {
3729
+ const current = getCurrentVersion();
3730
+ const latest = await getLatestNpmVersion("@aight-cool/aight-utils");
3731
+ const gateway = getGatewayVersion();
3732
+ const gatewayLatest = await getLatestNpmVersion("openclaw");
3733
+ respond(true, {
3734
+ current,
3735
+ latest,
3736
+ updateAvailable: latest !== "unknown" && current !== latest,
3737
+ gatewayVersion: gateway,
3738
+ gatewayLatest,
3739
+ gatewayUpdateAvailable: gatewayLatest !== "unknown" && gateway !== "unknown" && gateway !== gatewayLatest
3740
+ });
3741
+ } catch (err) {
3742
+ respond(false, {
3743
+ error: err instanceof Error ? err.message : String(err)
3744
+ });
3745
+ }
3746
+ });
3747
+ }
3748
+
3749
+ // index.ts
3750
+ var aightPlugin = {
3751
+ id: "aight-utils",
3752
+ name: "Aight Utilities",
3753
+ description: "Push notifications, Today items, config RPC, and agent bootstrap for the Aight app",
3754
+ configSchema: {
3755
+ parse(value) {
3756
+ const raw = value && typeof value === "object" && !Array.isArray(value) ? value : {};
3757
+ return {
3758
+ push: {
3759
+ mode: raw.push?.mode ?? "private",
3760
+ relayUrl: raw.push?.relayUrl ?? "https://push.aight.app",
3761
+ relaySecret: raw.push?.relaySecret
3762
+ },
3763
+ today: {
3764
+ enabled: raw.today?.enabled ?? true
3765
+ }
3766
+ };
3767
+ },
3768
+ uiHints: {
3769
+ "push.mode": {
3770
+ label: "Notification Mode",
3771
+ help: "Private = silent wake. Rich = preview text in notification."
3772
+ },
3773
+ "push.relayUrl": {
3774
+ label: "Push Relay URL",
3775
+ placeholder: "https://push.aight.app"
3776
+ },
3777
+ "push.relaySecret": {
3778
+ label: "Relay Shared Secret",
3779
+ sensitive: true
3780
+ },
3781
+ "today.enabled": {
3782
+ label: "Today View"
3783
+ }
3784
+ }
3785
+ },
3786
+ register(api) {
3787
+ const cfg = getPluginConfig(api);
3788
+ registerConfig(api);
3789
+ registerItems(api);
3790
+ registerPush(api, cfg);
3791
+ registerReminders(api, cfg);
3792
+ registerBootstrap(api);
3793
+ registerPushHook(api);
3794
+ registerHealth(api);
3795
+ registerVersion(api);
3796
+ registerGroupRpc(api);
3797
+ registerNotifPrefsRPC(api);
3798
+ api.logger.info("[aight-utils] Plugin loaded");
3799
+ }
3800
+ };
3801
+ var index_default = aightPlugin;
3802
+ export {
3803
+ index_default as default
3804
+ };
3805
+ //# sourceMappingURL=index.js.map