skilld 1.7.0 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/_chunks/agent.mjs +14 -5
  2. package/dist/_chunks/agent.mjs.map +1 -1
  3. package/dist/_chunks/assemble.mjs +1 -1
  4. package/dist/_chunks/author.mjs +6 -9
  5. package/dist/_chunks/author.mjs.map +1 -1
  6. package/dist/_chunks/cache.mjs +11 -1
  7. package/dist/_chunks/cache.mjs.map +1 -1
  8. package/dist/_chunks/cli-helpers.mjs +1 -1
  9. package/dist/_chunks/core.mjs +1 -1
  10. package/dist/_chunks/index.d.mts +4 -1
  11. package/dist/_chunks/index.d.mts.map +1 -1
  12. package/dist/_chunks/index3.d.mts +3 -1
  13. package/dist/_chunks/index3.d.mts.map +1 -1
  14. package/dist/_chunks/install.mjs +523 -85
  15. package/dist/_chunks/install.mjs.map +1 -1
  16. package/dist/_chunks/list.mjs +1 -1
  17. package/dist/_chunks/lockfile.mjs +4 -1
  18. package/dist/_chunks/lockfile.mjs.map +1 -1
  19. package/dist/_chunks/prefix.mjs +5 -5
  20. package/dist/_chunks/prefix.mjs.map +1 -1
  21. package/dist/_chunks/prepare2.mjs +4 -4
  22. package/dist/_chunks/prepare2.mjs.map +1 -1
  23. package/dist/_chunks/prompts.mjs +3 -142
  24. package/dist/_chunks/prompts.mjs.map +1 -1
  25. package/dist/_chunks/search-helpers.mjs +2 -2
  26. package/dist/_chunks/search-interactive.mjs +1 -1
  27. package/dist/_chunks/search.mjs +1 -1
  28. package/dist/_chunks/shared.mjs +463 -1
  29. package/dist/_chunks/shared.mjs.map +1 -1
  30. package/dist/_chunks/skill.mjs +329 -0
  31. package/dist/_chunks/skill.mjs.map +1 -0
  32. package/dist/_chunks/skills.mjs +3 -3
  33. package/dist/_chunks/sources.mjs +7 -3
  34. package/dist/_chunks/sources.mjs.map +1 -1
  35. package/dist/_chunks/sync-registry.mjs +4 -4
  36. package/dist/_chunks/sync-registry.mjs.map +1 -1
  37. package/dist/_chunks/sync-shared2.mjs +9 -10
  38. package/dist/_chunks/sync-shared2.mjs.map +1 -1
  39. package/dist/_chunks/sync.mjs +48 -62
  40. package/dist/_chunks/sync.mjs.map +1 -1
  41. package/dist/_chunks/uninstall.mjs +2 -2
  42. package/dist/_chunks/upload.mjs +1 -1
  43. package/dist/_chunks/validate.mjs +1 -1
  44. package/dist/_chunks/wizard.mjs +1 -1
  45. package/dist/agent/index.d.mts +3 -1
  46. package/dist/agent/index.d.mts.map +1 -1
  47. package/dist/agent/index.mjs +4 -4
  48. package/dist/cache/index.d.mts +2 -2
  49. package/dist/cache/index.mjs +2 -2
  50. package/dist/cli.mjs +5 -6
  51. package/dist/cli.mjs.map +1 -1
  52. package/dist/index.d.mts +2 -2
  53. package/dist/index.mjs +1 -1
  54. package/dist/prepare.mjs +1 -1
  55. package/dist/sources/index.d.mts +2 -2
  56. package/dist/sources/index.mjs +3 -3
  57. package/dist/types.d.mts +2 -2
  58. package/package.json +6 -5
  59. package/dist/THIRD-PARTY-LICENSES.md +0 -38
  60. package/dist/_chunks/formatting.mjs +0 -82
  61. package/dist/_chunks/formatting.mjs.map +0 -1
  62. package/dist/_chunks/install2.mjs +0 -554
  63. package/dist/_chunks/install2.mjs.map +0 -1
  64. package/dist/_chunks/libs/@sinclair/typebox.mjs +0 -2304
  65. package/dist/_chunks/libs/@sinclair/typebox.mjs.map +0 -1
  66. package/dist/_chunks/package-registry.mjs +0 -465
  67. package/dist/_chunks/package-registry.mjs.map +0 -1
  68. package/dist/_chunks/rolldown-runtime.mjs +0 -11
@@ -1,2304 +0,0 @@
1
- import { t as __exportAll } from "../../rolldown-runtime.mjs";
2
- function IsAsyncIterator$2(value) {
3
- return IsObject$3(value) && !IsArray$3(value) && !IsUint8Array$2(value) && Symbol.asyncIterator in value;
4
- }
5
- function IsArray$3(value) {
6
- return Array.isArray(value);
7
- }
8
- function IsBigInt$2(value) {
9
- return typeof value === "bigint";
10
- }
11
- function IsBoolean$2(value) {
12
- return typeof value === "boolean";
13
- }
14
- function IsDate$2(value) {
15
- return value instanceof globalThis.Date;
16
- }
17
- function IsFunction$2(value) {
18
- return typeof value === "function";
19
- }
20
- function IsIterator$2(value) {
21
- return IsObject$3(value) && !IsArray$3(value) && !IsUint8Array$2(value) && Symbol.iterator in value;
22
- }
23
- function IsNull$2(value) {
24
- return value === null;
25
- }
26
- function IsNumber$3(value) {
27
- return typeof value === "number";
28
- }
29
- function IsObject$3(value) {
30
- return typeof value === "object" && value !== null;
31
- }
32
- function IsRegExp$2(value) {
33
- return value instanceof globalThis.RegExp;
34
- }
35
- function IsString$2(value) {
36
- return typeof value === "string";
37
- }
38
- function IsSymbol$2(value) {
39
- return typeof value === "symbol";
40
- }
41
- function IsUint8Array$2(value) {
42
- return value instanceof globalThis.Uint8Array;
43
- }
44
- function IsUndefined$3(value) {
45
- return value === void 0;
46
- }
47
- function ArrayType(value) {
48
- return value.map((value) => Visit$2(value));
49
- }
50
- function DateType(value) {
51
- return new Date(value.getTime());
52
- }
53
- function Uint8ArrayType(value) {
54
- return new Uint8Array(value);
55
- }
56
- function RegExpType(value) {
57
- return new RegExp(value.source, value.flags);
58
- }
59
- function ObjectType(value) {
60
- const result = {};
61
- for (const key of Object.getOwnPropertyNames(value)) result[key] = Visit$2(value[key]);
62
- for (const key of Object.getOwnPropertySymbols(value)) result[key] = Visit$2(value[key]);
63
- return result;
64
- }
65
- function Visit$2(value) {
66
- return IsArray$3(value) ? ArrayType(value) : IsDate$2(value) ? DateType(value) : IsUint8Array$2(value) ? Uint8ArrayType(value) : IsRegExp$2(value) ? RegExpType(value) : IsObject$3(value) ? ObjectType(value) : value;
67
- }
68
- function Clone(value) {
69
- return Visit$2(value);
70
- }
71
- function CloneType(schema, options) {
72
- return options === void 0 ? Clone(schema) : Clone({
73
- ...options,
74
- ...schema
75
- });
76
- }
77
- function IsObject$2(value) {
78
- return value !== null && typeof value === "object";
79
- }
80
- function IsArray$2(value) {
81
- return globalThis.Array.isArray(value) && !globalThis.ArrayBuffer.isView(value);
82
- }
83
- function IsUndefined$2(value) {
84
- return value === void 0;
85
- }
86
- function IsNumber$2(value) {
87
- return typeof value === "number";
88
- }
89
- var TypeSystemPolicy;
90
- (function(TypeSystemPolicy) {
91
- TypeSystemPolicy.InstanceMode = "default";
92
- TypeSystemPolicy.ExactOptionalPropertyTypes = false;
93
- TypeSystemPolicy.AllowArrayObject = false;
94
- TypeSystemPolicy.AllowNaN = false;
95
- TypeSystemPolicy.AllowNullVoid = false;
96
- function IsExactOptionalProperty(value, key) {
97
- return TypeSystemPolicy.ExactOptionalPropertyTypes ? key in value : value[key] !== void 0;
98
- }
99
- TypeSystemPolicy.IsExactOptionalProperty = IsExactOptionalProperty;
100
- function IsObjectLike(value) {
101
- const isObject = IsObject$2(value);
102
- return TypeSystemPolicy.AllowArrayObject ? isObject : isObject && !IsArray$2(value);
103
- }
104
- TypeSystemPolicy.IsObjectLike = IsObjectLike;
105
- function IsRecordLike(value) {
106
- return IsObjectLike(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
107
- }
108
- TypeSystemPolicy.IsRecordLike = IsRecordLike;
109
- function IsNumberLike(value) {
110
- return TypeSystemPolicy.AllowNaN ? IsNumber$2(value) : Number.isFinite(value);
111
- }
112
- TypeSystemPolicy.IsNumberLike = IsNumberLike;
113
- function IsVoidLike(value) {
114
- const isUndefined = IsUndefined$2(value);
115
- return TypeSystemPolicy.AllowNullVoid ? isUndefined || value === null : isUndefined;
116
- }
117
- TypeSystemPolicy.IsVoidLike = IsVoidLike;
118
- })(TypeSystemPolicy || (TypeSystemPolicy = {}));
119
- function ImmutableArray(value) {
120
- return globalThis.Object.freeze(value).map((value) => Immutable(value));
121
- }
122
- function ImmutableDate(value) {
123
- return value;
124
- }
125
- function ImmutableUint8Array(value) {
126
- return value;
127
- }
128
- function ImmutableRegExp(value) {
129
- return value;
130
- }
131
- function ImmutableObject(value) {
132
- const result = {};
133
- for (const key of Object.getOwnPropertyNames(value)) result[key] = Immutable(value[key]);
134
- for (const key of Object.getOwnPropertySymbols(value)) result[key] = Immutable(value[key]);
135
- return globalThis.Object.freeze(result);
136
- }
137
- function Immutable(value) {
138
- return IsArray$3(value) ? ImmutableArray(value) : IsDate$2(value) ? ImmutableDate(value) : IsUint8Array$2(value) ? ImmutableUint8Array(value) : IsRegExp$2(value) ? ImmutableRegExp(value) : IsObject$3(value) ? ImmutableObject(value) : value;
139
- }
140
- function CreateType(schema, options) {
141
- const result = options !== void 0 ? {
142
- ...options,
143
- ...schema
144
- } : schema;
145
- switch (TypeSystemPolicy.InstanceMode) {
146
- case "freeze": return Immutable(result);
147
- case "clone": return Clone(result);
148
- default: return result;
149
- }
150
- }
151
- var TypeBoxError = class extends Error {
152
- constructor(message) {
153
- super(message);
154
- }
155
- };
156
- const TransformKind = Symbol.for("TypeBox.Transform");
157
- const ReadonlyKind = Symbol.for("TypeBox.Readonly");
158
- const OptionalKind = Symbol.for("TypeBox.Optional");
159
- const Hint = Symbol.for("TypeBox.Hint");
160
- const Kind = Symbol.for("TypeBox.Kind");
161
- function IsReadonly(value) {
162
- return IsObject$3(value) && value[ReadonlyKind] === "Readonly";
163
- }
164
- function IsOptional$1(value) {
165
- return IsObject$3(value) && value[OptionalKind] === "Optional";
166
- }
167
- function IsAny$1(value) {
168
- return IsKindOf$1(value, "Any");
169
- }
170
- function IsArgument$1(value) {
171
- return IsKindOf$1(value, "Argument");
172
- }
173
- function IsArray$1(value) {
174
- return IsKindOf$1(value, "Array");
175
- }
176
- function IsAsyncIterator$1(value) {
177
- return IsKindOf$1(value, "AsyncIterator");
178
- }
179
- function IsBigInt$1(value) {
180
- return IsKindOf$1(value, "BigInt");
181
- }
182
- function IsBoolean$1(value) {
183
- return IsKindOf$1(value, "Boolean");
184
- }
185
- function IsComputed$1(value) {
186
- return IsKindOf$1(value, "Computed");
187
- }
188
- function IsConstructor$1(value) {
189
- return IsKindOf$1(value, "Constructor");
190
- }
191
- function IsDate$1(value) {
192
- return IsKindOf$1(value, "Date");
193
- }
194
- function IsFunction$1(value) {
195
- return IsKindOf$1(value, "Function");
196
- }
197
- function IsInteger$1(value) {
198
- return IsKindOf$1(value, "Integer");
199
- }
200
- function IsIntersect$1(value) {
201
- return IsKindOf$1(value, "Intersect");
202
- }
203
- function IsIterator$1(value) {
204
- return IsKindOf$1(value, "Iterator");
205
- }
206
- function IsKindOf$1(value, kind) {
207
- return IsObject$3(value) && Kind in value && value[Kind] === kind;
208
- }
209
- function IsLiteralValue$1(value) {
210
- return IsBoolean$2(value) || IsNumber$3(value) || IsString$2(value);
211
- }
212
- function IsLiteral$1(value) {
213
- return IsKindOf$1(value, "Literal");
214
- }
215
- function IsMappedKey$1(value) {
216
- return IsKindOf$1(value, "MappedKey");
217
- }
218
- function IsMappedResult$1(value) {
219
- return IsKindOf$1(value, "MappedResult");
220
- }
221
- function IsNever$1(value) {
222
- return IsKindOf$1(value, "Never");
223
- }
224
- function IsNot$1(value) {
225
- return IsKindOf$1(value, "Not");
226
- }
227
- function IsNull$1(value) {
228
- return IsKindOf$1(value, "Null");
229
- }
230
- function IsNumber$1(value) {
231
- return IsKindOf$1(value, "Number");
232
- }
233
- function IsObject$1(value) {
234
- return IsKindOf$1(value, "Object");
235
- }
236
- function IsPromise$1(value) {
237
- return IsKindOf$1(value, "Promise");
238
- }
239
- function IsRecord$1(value) {
240
- return IsKindOf$1(value, "Record");
241
- }
242
- function IsRef$1(value) {
243
- return IsKindOf$1(value, "Ref");
244
- }
245
- function IsRegExp$1(value) {
246
- return IsKindOf$1(value, "RegExp");
247
- }
248
- function IsString$1(value) {
249
- return IsKindOf$1(value, "String");
250
- }
251
- function IsSymbol$1(value) {
252
- return IsKindOf$1(value, "Symbol");
253
- }
254
- function IsTemplateLiteral$1(value) {
255
- return IsKindOf$1(value, "TemplateLiteral");
256
- }
257
- function IsThis$1(value) {
258
- return IsKindOf$1(value, "This");
259
- }
260
- function IsTransform$1(value) {
261
- return IsObject$3(value) && TransformKind in value;
262
- }
263
- function IsTuple$1(value) {
264
- return IsKindOf$1(value, "Tuple");
265
- }
266
- function IsUndefined$1(value) {
267
- return IsKindOf$1(value, "Undefined");
268
- }
269
- function IsUnion$1(value) {
270
- return IsKindOf$1(value, "Union");
271
- }
272
- function IsUint8Array$1(value) {
273
- return IsKindOf$1(value, "Uint8Array");
274
- }
275
- function IsUnknown$1(value) {
276
- return IsKindOf$1(value, "Unknown");
277
- }
278
- function IsUnsafe$1(value) {
279
- return IsKindOf$1(value, "Unsafe");
280
- }
281
- function IsVoid$1(value) {
282
- return IsKindOf$1(value, "Void");
283
- }
284
- function IsKind$1(value) {
285
- return IsObject$3(value) && Kind in value && IsString$2(value[Kind]);
286
- }
287
- function IsSchema$1(value) {
288
- return IsAny$1(value) || IsArgument$1(value) || IsArray$1(value) || IsBoolean$1(value) || IsBigInt$1(value) || IsAsyncIterator$1(value) || IsComputed$1(value) || IsConstructor$1(value) || IsDate$1(value) || IsFunction$1(value) || IsInteger$1(value) || IsIntersect$1(value) || IsIterator$1(value) || IsLiteral$1(value) || IsMappedKey$1(value) || IsMappedResult$1(value) || IsNever$1(value) || IsNot$1(value) || IsNull$1(value) || IsNumber$1(value) || IsObject$1(value) || IsPromise$1(value) || IsRecord$1(value) || IsRef$1(value) || IsRegExp$1(value) || IsString$1(value) || IsSymbol$1(value) || IsTemplateLiteral$1(value) || IsThis$1(value) || IsTuple$1(value) || IsUndefined$1(value) || IsUnion$1(value) || IsUint8Array$1(value) || IsUnknown$1(value) || IsUnsafe$1(value) || IsVoid$1(value) || IsKind$1(value);
289
- }
290
- const KnownTypes = [
291
- "Argument",
292
- "Any",
293
- "Array",
294
- "AsyncIterator",
295
- "BigInt",
296
- "Boolean",
297
- "Computed",
298
- "Constructor",
299
- "Date",
300
- "Enum",
301
- "Function",
302
- "Integer",
303
- "Intersect",
304
- "Iterator",
305
- "Literal",
306
- "MappedKey",
307
- "MappedResult",
308
- "Not",
309
- "Null",
310
- "Number",
311
- "Object",
312
- "Promise",
313
- "Record",
314
- "Ref",
315
- "RegExp",
316
- "String",
317
- "Symbol",
318
- "TemplateLiteral",
319
- "This",
320
- "Tuple",
321
- "Undefined",
322
- "Union",
323
- "Uint8Array",
324
- "Unknown",
325
- "Void"
326
- ];
327
- function IsPattern(value) {
328
- try {
329
- new RegExp(value);
330
- return true;
331
- } catch {
332
- return false;
333
- }
334
- }
335
- function IsControlCharacterFree(value) {
336
- if (!IsString$2(value)) return false;
337
- for (let i = 0; i < value.length; i++) {
338
- const code = value.charCodeAt(i);
339
- if (code >= 7 && code <= 13 || code === 27 || code === 127) return false;
340
- }
341
- return true;
342
- }
343
- function IsAdditionalProperties(value) {
344
- return IsOptionalBoolean(value) || IsSchema(value);
345
- }
346
- function IsOptionalBigInt(value) {
347
- return IsUndefined$3(value) || IsBigInt$2(value);
348
- }
349
- function IsOptionalNumber(value) {
350
- return IsUndefined$3(value) || IsNumber$3(value);
351
- }
352
- function IsOptionalBoolean(value) {
353
- return IsUndefined$3(value) || IsBoolean$2(value);
354
- }
355
- function IsOptionalString(value) {
356
- return IsUndefined$3(value) || IsString$2(value);
357
- }
358
- function IsOptionalPattern(value) {
359
- return IsUndefined$3(value) || IsString$2(value) && IsControlCharacterFree(value) && IsPattern(value);
360
- }
361
- function IsOptionalFormat(value) {
362
- return IsUndefined$3(value) || IsString$2(value) && IsControlCharacterFree(value);
363
- }
364
- function IsOptionalSchema(value) {
365
- return IsUndefined$3(value) || IsSchema(value);
366
- }
367
- function IsOptional(value) {
368
- return IsObject$3(value) && value[OptionalKind] === "Optional";
369
- }
370
- function IsAny(value) {
371
- return IsKindOf(value, "Any") && IsOptionalString(value.$id);
372
- }
373
- function IsArgument(value) {
374
- return IsKindOf(value, "Argument") && IsNumber$3(value.index);
375
- }
376
- function IsArray(value) {
377
- return IsKindOf(value, "Array") && value.type === "array" && IsOptionalString(value.$id) && IsSchema(value.items) && IsOptionalNumber(value.minItems) && IsOptionalNumber(value.maxItems) && IsOptionalBoolean(value.uniqueItems) && IsOptionalSchema(value.contains) && IsOptionalNumber(value.minContains) && IsOptionalNumber(value.maxContains);
378
- }
379
- function IsAsyncIterator(value) {
380
- return IsKindOf(value, "AsyncIterator") && value.type === "AsyncIterator" && IsOptionalString(value.$id) && IsSchema(value.items);
381
- }
382
- function IsBigInt(value) {
383
- return IsKindOf(value, "BigInt") && value.type === "bigint" && IsOptionalString(value.$id) && IsOptionalBigInt(value.exclusiveMaximum) && IsOptionalBigInt(value.exclusiveMinimum) && IsOptionalBigInt(value.maximum) && IsOptionalBigInt(value.minimum) && IsOptionalBigInt(value.multipleOf);
384
- }
385
- function IsBoolean(value) {
386
- return IsKindOf(value, "Boolean") && value.type === "boolean" && IsOptionalString(value.$id);
387
- }
388
- function IsComputed(value) {
389
- return IsKindOf(value, "Computed") && IsString$2(value.target) && IsArray$3(value.parameters) && value.parameters.every((schema) => IsSchema(schema));
390
- }
391
- function IsConstructor(value) {
392
- return IsKindOf(value, "Constructor") && value.type === "Constructor" && IsOptionalString(value.$id) && IsArray$3(value.parameters) && value.parameters.every((schema) => IsSchema(schema)) && IsSchema(value.returns);
393
- }
394
- function IsDate(value) {
395
- return IsKindOf(value, "Date") && value.type === "Date" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximumTimestamp) && IsOptionalNumber(value.exclusiveMinimumTimestamp) && IsOptionalNumber(value.maximumTimestamp) && IsOptionalNumber(value.minimumTimestamp) && IsOptionalNumber(value.multipleOfTimestamp);
396
- }
397
- function IsFunction(value) {
398
- return IsKindOf(value, "Function") && value.type === "Function" && IsOptionalString(value.$id) && IsArray$3(value.parameters) && value.parameters.every((schema) => IsSchema(schema)) && IsSchema(value.returns);
399
- }
400
- function IsInteger(value) {
401
- return IsKindOf(value, "Integer") && value.type === "integer" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
402
- }
403
- function IsProperties(value) {
404
- return IsObject$3(value) && Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && IsSchema(schema));
405
- }
406
- function IsIntersect(value) {
407
- return IsKindOf(value, "Intersect") && (IsString$2(value.type) && value.type !== "object" ? false : true) && IsArray$3(value.allOf) && value.allOf.every((schema) => IsSchema(schema) && !IsTransform(schema)) && IsOptionalString(value.type) && (IsOptionalBoolean(value.unevaluatedProperties) || IsOptionalSchema(value.unevaluatedProperties)) && IsOptionalString(value.$id);
408
- }
409
- function IsIterator(value) {
410
- return IsKindOf(value, "Iterator") && value.type === "Iterator" && IsOptionalString(value.$id) && IsSchema(value.items);
411
- }
412
- function IsKindOf(value, kind) {
413
- return IsObject$3(value) && Kind in value && value[Kind] === kind;
414
- }
415
- function IsLiteralString(value) {
416
- return IsLiteral(value) && IsString$2(value.const);
417
- }
418
- function IsLiteralNumber(value) {
419
- return IsLiteral(value) && IsNumber$3(value.const);
420
- }
421
- function IsLiteralBoolean(value) {
422
- return IsLiteral(value) && IsBoolean$2(value.const);
423
- }
424
- function IsLiteral(value) {
425
- return IsKindOf(value, "Literal") && IsOptionalString(value.$id) && IsLiteralValue(value.const);
426
- }
427
- function IsLiteralValue(value) {
428
- return IsBoolean$2(value) || IsNumber$3(value) || IsString$2(value);
429
- }
430
- function IsMappedKey(value) {
431
- return IsKindOf(value, "MappedKey") && IsArray$3(value.keys) && value.keys.every((key) => IsNumber$3(key) || IsString$2(key));
432
- }
433
- function IsMappedResult(value) {
434
- return IsKindOf(value, "MappedResult") && IsProperties(value.properties);
435
- }
436
- function IsNever(value) {
437
- return IsKindOf(value, "Never") && IsObject$3(value.not) && Object.getOwnPropertyNames(value.not).length === 0;
438
- }
439
- function IsNot(value) {
440
- return IsKindOf(value, "Not") && IsSchema(value.not);
441
- }
442
- function IsNull(value) {
443
- return IsKindOf(value, "Null") && value.type === "null" && IsOptionalString(value.$id);
444
- }
445
- function IsNumber(value) {
446
- return IsKindOf(value, "Number") && value.type === "number" && IsOptionalString(value.$id) && IsOptionalNumber(value.exclusiveMaximum) && IsOptionalNumber(value.exclusiveMinimum) && IsOptionalNumber(value.maximum) && IsOptionalNumber(value.minimum) && IsOptionalNumber(value.multipleOf);
447
- }
448
- function IsObject(value) {
449
- return IsKindOf(value, "Object") && value.type === "object" && IsOptionalString(value.$id) && IsProperties(value.properties) && IsAdditionalProperties(value.additionalProperties) && IsOptionalNumber(value.minProperties) && IsOptionalNumber(value.maxProperties);
450
- }
451
- function IsPromise(value) {
452
- return IsKindOf(value, "Promise") && value.type === "Promise" && IsOptionalString(value.$id) && IsSchema(value.item);
453
- }
454
- function IsRecord(value) {
455
- return IsKindOf(value, "Record") && value.type === "object" && IsOptionalString(value.$id) && IsAdditionalProperties(value.additionalProperties) && IsObject$3(value.patternProperties) && ((schema) => {
456
- const keys = Object.getOwnPropertyNames(schema.patternProperties);
457
- return keys.length === 1 && IsPattern(keys[0]) && IsObject$3(schema.patternProperties) && IsSchema(schema.patternProperties[keys[0]]);
458
- })(value);
459
- }
460
- function IsRef(value) {
461
- return IsKindOf(value, "Ref") && IsOptionalString(value.$id) && IsString$2(value.$ref);
462
- }
463
- function IsRegExp(value) {
464
- return IsKindOf(value, "RegExp") && IsOptionalString(value.$id) && IsString$2(value.source) && IsString$2(value.flags) && IsOptionalNumber(value.maxLength) && IsOptionalNumber(value.minLength);
465
- }
466
- function IsString(value) {
467
- return IsKindOf(value, "String") && value.type === "string" && IsOptionalString(value.$id) && IsOptionalNumber(value.minLength) && IsOptionalNumber(value.maxLength) && IsOptionalPattern(value.pattern) && IsOptionalFormat(value.format);
468
- }
469
- function IsSymbol(value) {
470
- return IsKindOf(value, "Symbol") && value.type === "symbol" && IsOptionalString(value.$id);
471
- }
472
- function IsTemplateLiteral(value) {
473
- return IsKindOf(value, "TemplateLiteral") && value.type === "string" && IsString$2(value.pattern) && value.pattern[0] === "^" && value.pattern[value.pattern.length - 1] === "$";
474
- }
475
- function IsThis(value) {
476
- return IsKindOf(value, "This") && IsOptionalString(value.$id) && IsString$2(value.$ref);
477
- }
478
- function IsTransform(value) {
479
- return IsObject$3(value) && TransformKind in value;
480
- }
481
- function IsTuple(value) {
482
- return IsKindOf(value, "Tuple") && value.type === "array" && IsOptionalString(value.$id) && IsNumber$3(value.minItems) && IsNumber$3(value.maxItems) && value.minItems === value.maxItems && (IsUndefined$3(value.items) && IsUndefined$3(value.additionalItems) && value.minItems === 0 || IsArray$3(value.items) && value.items.every((schema) => IsSchema(schema)));
483
- }
484
- function IsUndefined(value) {
485
- return IsKindOf(value, "Undefined") && value.type === "undefined" && IsOptionalString(value.$id);
486
- }
487
- function IsUnion(value) {
488
- return IsKindOf(value, "Union") && IsOptionalString(value.$id) && IsObject$3(value) && IsArray$3(value.anyOf) && value.anyOf.every((schema) => IsSchema(schema));
489
- }
490
- function IsUint8Array(value) {
491
- return IsKindOf(value, "Uint8Array") && value.type === "Uint8Array" && IsOptionalString(value.$id) && IsOptionalNumber(value.minByteLength) && IsOptionalNumber(value.maxByteLength);
492
- }
493
- function IsUnknown(value) {
494
- return IsKindOf(value, "Unknown") && IsOptionalString(value.$id);
495
- }
496
- function IsUnsafe(value) {
497
- return IsKindOf(value, "Unsafe");
498
- }
499
- function IsVoid(value) {
500
- return IsKindOf(value, "Void") && value.type === "void" && IsOptionalString(value.$id);
501
- }
502
- function IsKind(value) {
503
- return IsObject$3(value) && Kind in value && IsString$2(value[Kind]) && !KnownTypes.includes(value[Kind]);
504
- }
505
- function IsSchema(value) {
506
- return IsObject$3(value) && (IsAny(value) || IsArgument(value) || IsArray(value) || IsBoolean(value) || IsBigInt(value) || IsAsyncIterator(value) || IsComputed(value) || IsConstructor(value) || IsDate(value) || IsFunction(value) || IsInteger(value) || IsIntersect(value) || IsIterator(value) || IsLiteral(value) || IsMappedKey(value) || IsMappedResult(value) || IsNever(value) || IsNot(value) || IsNull(value) || IsNumber(value) || IsObject(value) || IsPromise(value) || IsRecord(value) || IsRef(value) || IsRegExp(value) || IsString(value) || IsSymbol(value) || IsTemplateLiteral(value) || IsThis(value) || IsTuple(value) || IsUndefined(value) || IsUnion(value) || IsUint8Array(value) || IsUnknown(value) || IsUnsafe(value) || IsVoid(value) || IsKind(value));
507
- }
508
- const PatternBoolean = "(true|false)";
509
- const PatternNumber = "(0|[1-9][0-9]*)";
510
- const PatternString = "(.*)";
511
- const PatternNever = "(?!.*)";
512
- `${PatternBoolean}`;
513
- const PatternNumberExact = `^${PatternNumber}$`;
514
- const PatternStringExact = `^${PatternString}$`;
515
- const PatternNeverExact = `^${PatternNever}$`;
516
- function SetIncludes(T, S) {
517
- return T.includes(S);
518
- }
519
- function SetDistinct(T) {
520
- return [...new Set(T)];
521
- }
522
- function SetIntersect(T, S) {
523
- return T.filter((L) => S.includes(L));
524
- }
525
- function SetIntersectManyResolve(T, Init) {
526
- return T.reduce((Acc, L) => {
527
- return SetIntersect(Acc, L);
528
- }, Init);
529
- }
530
- function SetIntersectMany(T) {
531
- return T.length === 1 ? T[0] : T.length > 1 ? SetIntersectManyResolve(T.slice(1), T[0]) : [];
532
- }
533
- function SetUnionMany(T) {
534
- const Acc = [];
535
- for (const L of T) Acc.push(...L);
536
- return Acc;
537
- }
538
- function Any(options) {
539
- return CreateType({ [Kind]: "Any" }, options);
540
- }
541
- function Array$1(items, options) {
542
- return CreateType({
543
- [Kind]: "Array",
544
- type: "array",
545
- items
546
- }, options);
547
- }
548
- function Argument(index) {
549
- return CreateType({
550
- [Kind]: "Argument",
551
- index
552
- });
553
- }
554
- function AsyncIterator(items, options) {
555
- return CreateType({
556
- [Kind]: "AsyncIterator",
557
- type: "AsyncIterator",
558
- items
559
- }, options);
560
- }
561
- function Computed(target, parameters, options) {
562
- return CreateType({
563
- [Kind]: "Computed",
564
- target,
565
- parameters
566
- }, options);
567
- }
568
- function DiscardKey(value, key) {
569
- const { [key]: _, ...rest } = value;
570
- return rest;
571
- }
572
- function Discard(value, keys) {
573
- return keys.reduce((acc, key) => DiscardKey(acc, key), value);
574
- }
575
- function Never(options) {
576
- return CreateType({
577
- [Kind]: "Never",
578
- not: {}
579
- }, options);
580
- }
581
- function MappedResult(properties) {
582
- return CreateType({
583
- [Kind]: "MappedResult",
584
- properties
585
- });
586
- }
587
- function Constructor(parameters, returns, options) {
588
- return CreateType({
589
- [Kind]: "Constructor",
590
- type: "Constructor",
591
- parameters,
592
- returns
593
- }, options);
594
- }
595
- function Function(parameters, returns, options) {
596
- return CreateType({
597
- [Kind]: "Function",
598
- type: "Function",
599
- parameters,
600
- returns
601
- }, options);
602
- }
603
- function UnionCreate(T, options) {
604
- return CreateType({
605
- [Kind]: "Union",
606
- anyOf: T
607
- }, options);
608
- }
609
- function IsUnionOptional(types) {
610
- return types.some((type) => IsOptional$1(type));
611
- }
612
- function RemoveOptionalFromRest$1(types) {
613
- return types.map((left) => IsOptional$1(left) ? RemoveOptionalFromType$1(left) : left);
614
- }
615
- function RemoveOptionalFromType$1(T) {
616
- return Discard(T, [OptionalKind]);
617
- }
618
- function ResolveUnion(types, options) {
619
- return IsUnionOptional(types) ? Optional(UnionCreate(RemoveOptionalFromRest$1(types), options)) : UnionCreate(RemoveOptionalFromRest$1(types), options);
620
- }
621
- function UnionEvaluated(T, options) {
622
- return T.length === 1 ? CreateType(T[0], options) : T.length === 0 ? Never(options) : ResolveUnion(T, options);
623
- }
624
- function Union(types, options) {
625
- return types.length === 0 ? Never(options) : types.length === 1 ? CreateType(types[0], options) : UnionCreate(types, options);
626
- }
627
- var TemplateLiteralParserError = class extends TypeBoxError {};
628
- function Unescape(pattern) {
629
- return pattern.replace(/\\\$/g, "$").replace(/\\\*/g, "*").replace(/\\\^/g, "^").replace(/\\\|/g, "|").replace(/\\\(/g, "(").replace(/\\\)/g, ")");
630
- }
631
- function IsNonEscaped(pattern, index, char) {
632
- return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
633
- }
634
- function IsOpenParen(pattern, index) {
635
- return IsNonEscaped(pattern, index, "(");
636
- }
637
- function IsCloseParen(pattern, index) {
638
- return IsNonEscaped(pattern, index, ")");
639
- }
640
- function IsSeparator(pattern, index) {
641
- return IsNonEscaped(pattern, index, "|");
642
- }
643
- function IsGroup(pattern) {
644
- if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1))) return false;
645
- let count = 0;
646
- for (let index = 0; index < pattern.length; index++) {
647
- if (IsOpenParen(pattern, index)) count += 1;
648
- if (IsCloseParen(pattern, index)) count -= 1;
649
- if (count === 0 && index !== pattern.length - 1) return false;
650
- }
651
- return true;
652
- }
653
- function InGroup(pattern) {
654
- return pattern.slice(1, pattern.length - 1);
655
- }
656
- function IsPrecedenceOr(pattern) {
657
- let count = 0;
658
- for (let index = 0; index < pattern.length; index++) {
659
- if (IsOpenParen(pattern, index)) count += 1;
660
- if (IsCloseParen(pattern, index)) count -= 1;
661
- if (IsSeparator(pattern, index) && count === 0) return true;
662
- }
663
- return false;
664
- }
665
- function IsPrecedenceAnd(pattern) {
666
- for (let index = 0; index < pattern.length; index++) if (IsOpenParen(pattern, index)) return true;
667
- return false;
668
- }
669
- function Or(pattern) {
670
- let [count, start] = [0, 0];
671
- const expressions = [];
672
- for (let index = 0; index < pattern.length; index++) {
673
- if (IsOpenParen(pattern, index)) count += 1;
674
- if (IsCloseParen(pattern, index)) count -= 1;
675
- if (IsSeparator(pattern, index) && count === 0) {
676
- const range = pattern.slice(start, index);
677
- if (range.length > 0) expressions.push(TemplateLiteralParse(range));
678
- start = index + 1;
679
- }
680
- }
681
- const range = pattern.slice(start);
682
- if (range.length > 0) expressions.push(TemplateLiteralParse(range));
683
- if (expressions.length === 0) return {
684
- type: "const",
685
- const: ""
686
- };
687
- if (expressions.length === 1) return expressions[0];
688
- return {
689
- type: "or",
690
- expr: expressions
691
- };
692
- }
693
- function And(pattern) {
694
- function Group(value, index) {
695
- if (!IsOpenParen(value, index)) throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
696
- let count = 0;
697
- for (let scan = index; scan < value.length; scan++) {
698
- if (IsOpenParen(value, scan)) count += 1;
699
- if (IsCloseParen(value, scan)) count -= 1;
700
- if (count === 0) return [index, scan];
701
- }
702
- throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
703
- }
704
- function Range(pattern, index) {
705
- for (let scan = index; scan < pattern.length; scan++) if (IsOpenParen(pattern, scan)) return [index, scan];
706
- return [index, pattern.length];
707
- }
708
- const expressions = [];
709
- for (let index = 0; index < pattern.length; index++) if (IsOpenParen(pattern, index)) {
710
- const [start, end] = Group(pattern, index);
711
- const range = pattern.slice(start, end + 1);
712
- expressions.push(TemplateLiteralParse(range));
713
- index = end;
714
- } else {
715
- const [start, end] = Range(pattern, index);
716
- const range = pattern.slice(start, end);
717
- if (range.length > 0) expressions.push(TemplateLiteralParse(range));
718
- index = end - 1;
719
- }
720
- return expressions.length === 0 ? {
721
- type: "const",
722
- const: ""
723
- } : expressions.length === 1 ? expressions[0] : {
724
- type: "and",
725
- expr: expressions
726
- };
727
- }
728
- function TemplateLiteralParse(pattern) {
729
- return IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) : IsPrecedenceOr(pattern) ? Or(pattern) : IsPrecedenceAnd(pattern) ? And(pattern) : {
730
- type: "const",
731
- const: Unescape(pattern)
732
- };
733
- }
734
- function TemplateLiteralParseExact(pattern) {
735
- return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
736
- }
737
- var TemplateLiteralFiniteError = class extends TypeBoxError {};
738
- function IsNumberExpression(expression) {
739
- 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]*";
740
- }
741
- function IsBooleanExpression(expression) {
742
- 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";
743
- }
744
- function IsStringExpression(expression) {
745
- return expression.type === "const" && expression.const === ".*";
746
- }
747
- function IsTemplateLiteralExpressionFinite(expression) {
748
- 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 : (() => {
749
- throw new TemplateLiteralFiniteError(`Unknown expression type`);
750
- })();
751
- }
752
- function IsTemplateLiteralFinite(schema) {
753
- return IsTemplateLiteralExpressionFinite(TemplateLiteralParseExact(schema.pattern));
754
- }
755
- var TemplateLiteralGenerateError = class extends TypeBoxError {};
756
- function* GenerateReduce(buffer) {
757
- if (buffer.length === 1) return yield* buffer[0];
758
- for (const left of buffer[0]) for (const right of GenerateReduce(buffer.slice(1))) yield `${left}${right}`;
759
- }
760
- function* GenerateAnd(expression) {
761
- return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
762
- }
763
- function* GenerateOr(expression) {
764
- for (const expr of expression.expr) yield* TemplateLiteralExpressionGenerate(expr);
765
- }
766
- function* GenerateConst(expression) {
767
- return yield expression.const;
768
- }
769
- function* TemplateLiteralExpressionGenerate(expression) {
770
- return expression.type === "and" ? yield* GenerateAnd(expression) : expression.type === "or" ? yield* GenerateOr(expression) : expression.type === "const" ? yield* GenerateConst(expression) : (() => {
771
- throw new TemplateLiteralGenerateError("Unknown expression");
772
- })();
773
- }
774
- function TemplateLiteralGenerate(schema) {
775
- const expression = TemplateLiteralParseExact(schema.pattern);
776
- return IsTemplateLiteralExpressionFinite(expression) ? [...TemplateLiteralExpressionGenerate(expression)] : [];
777
- }
778
- function Literal(value, options) {
779
- return CreateType({
780
- [Kind]: "Literal",
781
- const: value,
782
- type: typeof value
783
- }, options);
784
- }
785
- function Boolean(options) {
786
- return CreateType({
787
- [Kind]: "Boolean",
788
- type: "boolean"
789
- }, options);
790
- }
791
- function BigInt(options) {
792
- return CreateType({
793
- [Kind]: "BigInt",
794
- type: "bigint"
795
- }, options);
796
- }
797
- function Number$1(options) {
798
- return CreateType({
799
- [Kind]: "Number",
800
- type: "number"
801
- }, options);
802
- }
803
- function String(options) {
804
- return CreateType({
805
- [Kind]: "String",
806
- type: "string"
807
- }, options);
808
- }
809
- function* FromUnion$9(syntax) {
810
- const trim = syntax.trim().replace(/"|'/g, "");
811
- return trim === "boolean" ? yield Boolean() : trim === "number" ? yield Number$1() : trim === "bigint" ? yield BigInt() : trim === "string" ? yield String() : yield (() => {
812
- const literals = trim.split("|").map((literal) => Literal(literal.trim()));
813
- return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
814
- })();
815
- }
816
- function* FromTerminal(syntax) {
817
- if (syntax[1] !== "{") return yield* [Literal("$"), ...FromSyntax(syntax.slice(1))];
818
- for (let i = 2; i < syntax.length; i++) if (syntax[i] === "}") {
819
- const L = FromUnion$9(syntax.slice(2, i));
820
- const R = FromSyntax(syntax.slice(i + 1));
821
- return yield* [...L, ...R];
822
- }
823
- yield Literal(syntax);
824
- }
825
- function* FromSyntax(syntax) {
826
- for (let i = 0; i < syntax.length; i++) if (syntax[i] === "$") return yield* [Literal(syntax.slice(0, i)), ...FromTerminal(syntax.slice(i))];
827
- yield Literal(syntax);
828
- }
829
- function TemplateLiteralSyntax(syntax) {
830
- return [...FromSyntax(syntax)];
831
- }
832
- var TemplateLiteralPatternError = class extends TypeBoxError {};
833
- function Escape(value) {
834
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
835
- }
836
- function Visit$1(schema, acc) {
837
- return IsTemplateLiteral$1(schema) ? schema.pattern.slice(1, schema.pattern.length - 1) : IsUnion$1(schema) ? `(${schema.anyOf.map((schema) => Visit$1(schema, acc)).join("|")})` : IsNumber$1(schema) ? `${acc}${PatternNumber}` : IsInteger$1(schema) ? `${acc}${PatternNumber}` : IsBigInt$1(schema) ? `${acc}${PatternNumber}` : IsString$1(schema) ? `${acc}${PatternString}` : IsLiteral$1(schema) ? `${acc}${Escape(schema.const.toString())}` : IsBoolean$1(schema) ? `${acc}${PatternBoolean}` : (() => {
838
- throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[Kind]}'`);
839
- })();
840
- }
841
- function TemplateLiteralPattern(kinds) {
842
- return `^${kinds.map((schema) => Visit$1(schema, "")).join("")}\$`;
843
- }
844
- function TemplateLiteralToUnion(schema) {
845
- return UnionEvaluated(TemplateLiteralGenerate(schema).map((S) => Literal(S)));
846
- }
847
- function TemplateLiteral(unresolved, options) {
848
- const pattern = IsString$2(unresolved) ? TemplateLiteralPattern(TemplateLiteralSyntax(unresolved)) : TemplateLiteralPattern(unresolved);
849
- return CreateType({
850
- [Kind]: "TemplateLiteral",
851
- type: "string",
852
- pattern
853
- }, options);
854
- }
855
- function FromTemplateLiteral$2(templateLiteral) {
856
- return TemplateLiteralGenerate(templateLiteral).map((key) => key.toString());
857
- }
858
- function FromUnion$8(types) {
859
- const result = [];
860
- for (const type of types) result.push(...IndexPropertyKeys(type));
861
- return result;
862
- }
863
- function FromLiteral$1(literalValue) {
864
- return [literalValue.toString()];
865
- }
866
- function IndexPropertyKeys(type) {
867
- return [...new Set(IsTemplateLiteral$1(type) ? FromTemplateLiteral$2(type) : IsUnion$1(type) ? FromUnion$8(type.anyOf) : IsLiteral$1(type) ? FromLiteral$1(type.const) : IsNumber$1(type) ? ["[number]"] : IsInteger$1(type) ? ["[number]"] : [])];
868
- }
869
- function FromProperties$18(type, properties, options) {
870
- const result = {};
871
- for (const K2 of Object.getOwnPropertyNames(properties)) result[K2] = Index(type, IndexPropertyKeys(properties[K2]), options);
872
- return result;
873
- }
874
- function FromMappedResult$11(type, mappedResult, options) {
875
- return FromProperties$18(type, mappedResult.properties, options);
876
- }
877
- function IndexFromMappedResult(type, mappedResult, options) {
878
- return MappedResult(FromMappedResult$11(type, mappedResult, options));
879
- }
880
- function FromRest$6(types, key) {
881
- return types.map((type) => IndexFromPropertyKey(type, key));
882
- }
883
- function FromIntersectRest(types) {
884
- return types.filter((type) => !IsNever$1(type));
885
- }
886
- function FromIntersect$7(types, key) {
887
- return IntersectEvaluated(FromIntersectRest(FromRest$6(types, key)));
888
- }
889
- function FromUnionRest(types) {
890
- return types.some((L) => IsNever$1(L)) ? [] : types;
891
- }
892
- function FromUnion$7(types, key) {
893
- return UnionEvaluated(FromUnionRest(FromRest$6(types, key)));
894
- }
895
- function FromTuple$4(types, key) {
896
- return key in types ? types[key] : key === "[number]" ? UnionEvaluated(types) : Never();
897
- }
898
- function FromArray$5(type, key) {
899
- return key === "[number]" ? type : Never();
900
- }
901
- function FromProperty$2(properties, propertyKey) {
902
- return propertyKey in properties ? properties[propertyKey] : Never();
903
- }
904
- function IndexFromPropertyKey(type, propertyKey) {
905
- return IsIntersect$1(type) ? FromIntersect$7(type.allOf, propertyKey) : IsUnion$1(type) ? FromUnion$7(type.anyOf, propertyKey) : IsTuple$1(type) ? FromTuple$4(type.items ?? [], propertyKey) : IsArray$1(type) ? FromArray$5(type.items, propertyKey) : IsObject$1(type) ? FromProperty$2(type.properties, propertyKey) : Never();
906
- }
907
- function IndexFromPropertyKeys(type, propertyKeys) {
908
- return propertyKeys.map((propertyKey) => IndexFromPropertyKey(type, propertyKey));
909
- }
910
- function FromSchema(type, propertyKeys) {
911
- return UnionEvaluated(IndexFromPropertyKeys(type, propertyKeys));
912
- }
913
- function Index(type, key, options) {
914
- if (IsRef$1(type) || IsRef$1(key)) {
915
- const error = `Index types using Ref parameters require both Type and Key to be of TSchema`;
916
- if (!IsSchema$1(type) || !IsSchema$1(key)) throw new TypeBoxError(error);
917
- return Computed("Index", [type, key]);
918
- }
919
- if (IsMappedResult$1(key)) return IndexFromMappedResult(type, key, options);
920
- if (IsMappedKey$1(key)) return IndexFromMappedKey(type, key, options);
921
- return CreateType(IsSchema$1(key) ? FromSchema(type, IndexPropertyKeys(key)) : FromSchema(type, key), options);
922
- }
923
- function MappedIndexPropertyKey(type, key, options) {
924
- return { [key]: Index(type, [key], Clone(options)) };
925
- }
926
- function MappedIndexPropertyKeys(type, propertyKeys, options) {
927
- return propertyKeys.reduce((result, left) => {
928
- return {
929
- ...result,
930
- ...MappedIndexPropertyKey(type, left, options)
931
- };
932
- }, {});
933
- }
934
- function MappedIndexProperties(type, mappedKey, options) {
935
- return MappedIndexPropertyKeys(type, mappedKey.keys, options);
936
- }
937
- function IndexFromMappedKey(type, mappedKey, options) {
938
- return MappedResult(MappedIndexProperties(type, mappedKey, options));
939
- }
940
- function Iterator(items, options) {
941
- return CreateType({
942
- [Kind]: "Iterator",
943
- type: "Iterator",
944
- items
945
- }, options);
946
- }
947
- function RequiredArray(properties) {
948
- return globalThis.Object.keys(properties).filter((key) => !IsOptional$1(properties[key]));
949
- }
950
- function _Object(properties, options) {
951
- const required = RequiredArray(properties);
952
- return CreateType(required.length > 0 ? {
953
- [Kind]: "Object",
954
- type: "object",
955
- required,
956
- properties
957
- } : {
958
- [Kind]: "Object",
959
- type: "object",
960
- properties
961
- }, options);
962
- }
963
- var Object$1 = _Object;
964
- function Promise$1(item, options) {
965
- return CreateType({
966
- [Kind]: "Promise",
967
- type: "Promise",
968
- item
969
- }, options);
970
- }
971
- function RemoveReadonly(schema) {
972
- return CreateType(Discard(schema, [ReadonlyKind]));
973
- }
974
- function AddReadonly(schema) {
975
- return CreateType({
976
- ...schema,
977
- [ReadonlyKind]: "Readonly"
978
- });
979
- }
980
- function ReadonlyWithFlag(schema, F) {
981
- return F === false ? RemoveReadonly(schema) : AddReadonly(schema);
982
- }
983
- function Readonly(schema, enable) {
984
- const F = enable ?? true;
985
- return IsMappedResult$1(schema) ? ReadonlyFromMappedResult(schema, F) : ReadonlyWithFlag(schema, F);
986
- }
987
- function FromProperties$17(K, F) {
988
- const Acc = {};
989
- for (const K2 of globalThis.Object.getOwnPropertyNames(K)) Acc[K2] = Readonly(K[K2], F);
990
- return Acc;
991
- }
992
- function FromMappedResult$10(R, F) {
993
- return FromProperties$17(R.properties, F);
994
- }
995
- function ReadonlyFromMappedResult(R, F) {
996
- return MappedResult(FromMappedResult$10(R, F));
997
- }
998
- function Tuple(types, options) {
999
- return CreateType(types.length > 0 ? {
1000
- [Kind]: "Tuple",
1001
- type: "array",
1002
- items: types,
1003
- additionalItems: false,
1004
- minItems: types.length,
1005
- maxItems: types.length
1006
- } : {
1007
- [Kind]: "Tuple",
1008
- type: "array",
1009
- minItems: types.length,
1010
- maxItems: types.length
1011
- }, options);
1012
- }
1013
- function FromMappedResult$9(K, P) {
1014
- return K in P ? FromSchemaType(K, P[K]) : MappedResult(P);
1015
- }
1016
- function MappedKeyToKnownMappedResultProperties(K) {
1017
- return { [K]: Literal(K) };
1018
- }
1019
- function MappedKeyToUnknownMappedResultProperties(P) {
1020
- const Acc = {};
1021
- for (const L of P) Acc[L] = Literal(L);
1022
- return Acc;
1023
- }
1024
- function MappedKeyToMappedResultProperties(K, P) {
1025
- return SetIncludes(P, K) ? MappedKeyToKnownMappedResultProperties(K) : MappedKeyToUnknownMappedResultProperties(P);
1026
- }
1027
- function FromMappedKey$3(K, P) {
1028
- return FromMappedResult$9(K, MappedKeyToMappedResultProperties(K, P));
1029
- }
1030
- function FromRest$5(K, T) {
1031
- return T.map((L) => FromSchemaType(K, L));
1032
- }
1033
- function FromProperties$16(K, T) {
1034
- const Acc = {};
1035
- for (const K2 of globalThis.Object.getOwnPropertyNames(T)) Acc[K2] = FromSchemaType(K, T[K2]);
1036
- return Acc;
1037
- }
1038
- function FromSchemaType(K, T) {
1039
- const options = { ...T };
1040
- return IsOptional$1(T) ? Optional(FromSchemaType(K, Discard(T, [OptionalKind]))) : IsReadonly(T) ? Readonly(FromSchemaType(K, Discard(T, [ReadonlyKind]))) : IsMappedResult$1(T) ? FromMappedResult$9(K, T.properties) : IsMappedKey$1(T) ? FromMappedKey$3(K, T.keys) : IsConstructor$1(T) ? Constructor(FromRest$5(K, T.parameters), FromSchemaType(K, T.returns), options) : IsFunction$1(T) ? Function(FromRest$5(K, T.parameters), FromSchemaType(K, T.returns), options) : IsAsyncIterator$1(T) ? AsyncIterator(FromSchemaType(K, T.items), options) : IsIterator$1(T) ? Iterator(FromSchemaType(K, T.items), options) : IsIntersect$1(T) ? Intersect(FromRest$5(K, T.allOf), options) : IsUnion$1(T) ? Union(FromRest$5(K, T.anyOf), options) : IsTuple$1(T) ? Tuple(FromRest$5(K, T.items ?? []), options) : IsObject$1(T) ? Object$1(FromProperties$16(K, T.properties), options) : IsArray$1(T) ? Array$1(FromSchemaType(K, T.items), options) : IsPromise$1(T) ? Promise$1(FromSchemaType(K, T.item), options) : T;
1041
- }
1042
- function MappedFunctionReturnType(K, T) {
1043
- const Acc = {};
1044
- for (const L of K) Acc[L] = FromSchemaType(L, T);
1045
- return Acc;
1046
- }
1047
- function Mapped(key, map, options) {
1048
- const K = IsSchema$1(key) ? IndexPropertyKeys(key) : key;
1049
- return Object$1(MappedFunctionReturnType(K, map({
1050
- [Kind]: "MappedKey",
1051
- keys: K
1052
- })), options);
1053
- }
1054
- function RemoveOptional(schema) {
1055
- return CreateType(Discard(schema, [OptionalKind]));
1056
- }
1057
- function AddOptional(schema) {
1058
- return CreateType({
1059
- ...schema,
1060
- [OptionalKind]: "Optional"
1061
- });
1062
- }
1063
- function OptionalWithFlag(schema, F) {
1064
- return F === false ? RemoveOptional(schema) : AddOptional(schema);
1065
- }
1066
- function Optional(schema, enable) {
1067
- const F = enable ?? true;
1068
- return IsMappedResult$1(schema) ? OptionalFromMappedResult(schema, F) : OptionalWithFlag(schema, F);
1069
- }
1070
- function FromProperties$15(P, F) {
1071
- const Acc = {};
1072
- for (const K2 of globalThis.Object.getOwnPropertyNames(P)) Acc[K2] = Optional(P[K2], F);
1073
- return Acc;
1074
- }
1075
- function FromMappedResult$8(R, F) {
1076
- return FromProperties$15(R.properties, F);
1077
- }
1078
- function OptionalFromMappedResult(R, F) {
1079
- return MappedResult(FromMappedResult$8(R, F));
1080
- }
1081
- function IntersectCreate(T, options = {}) {
1082
- const allObjects = T.every((schema) => IsObject$1(schema));
1083
- const clonedUnevaluatedProperties = IsSchema$1(options.unevaluatedProperties) ? { unevaluatedProperties: options.unevaluatedProperties } : {};
1084
- return CreateType(options.unevaluatedProperties === false || IsSchema$1(options.unevaluatedProperties) || allObjects ? {
1085
- ...clonedUnevaluatedProperties,
1086
- [Kind]: "Intersect",
1087
- type: "object",
1088
- allOf: T
1089
- } : {
1090
- ...clonedUnevaluatedProperties,
1091
- [Kind]: "Intersect",
1092
- allOf: T
1093
- }, options);
1094
- }
1095
- function IsIntersectOptional(types) {
1096
- return types.every((left) => IsOptional$1(left));
1097
- }
1098
- function RemoveOptionalFromType(type) {
1099
- return Discard(type, [OptionalKind]);
1100
- }
1101
- function RemoveOptionalFromRest(types) {
1102
- return types.map((left) => IsOptional$1(left) ? RemoveOptionalFromType(left) : left);
1103
- }
1104
- function ResolveIntersect(types, options) {
1105
- return IsIntersectOptional(types) ? Optional(IntersectCreate(RemoveOptionalFromRest(types), options)) : IntersectCreate(RemoveOptionalFromRest(types), options);
1106
- }
1107
- function IntersectEvaluated(types, options = {}) {
1108
- if (types.length === 1) return CreateType(types[0], options);
1109
- if (types.length === 0) return Never(options);
1110
- if (types.some((schema) => IsTransform$1(schema))) throw new Error("Cannot intersect transform types");
1111
- return ResolveIntersect(types, options);
1112
- }
1113
- function Intersect(types, options) {
1114
- if (types.length === 1) return CreateType(types[0], options);
1115
- if (types.length === 0) return Never(options);
1116
- if (types.some((schema) => IsTransform$1(schema))) throw new Error("Cannot intersect transform types");
1117
- return IntersectCreate(types, options);
1118
- }
1119
- function Ref(...args) {
1120
- const [$ref, options] = typeof args[0] === "string" ? [args[0], args[1]] : [args[0].$id, args[1]];
1121
- if (typeof $ref !== "string") throw new TypeBoxError("Ref: $ref must be a string");
1122
- return CreateType({
1123
- [Kind]: "Ref",
1124
- $ref
1125
- }, options);
1126
- }
1127
- function FromComputed$4(target, parameters) {
1128
- return Computed("Awaited", [Computed(target, parameters)]);
1129
- }
1130
- function FromRef$3($ref) {
1131
- return Computed("Awaited", [Ref($ref)]);
1132
- }
1133
- function FromIntersect$6(types) {
1134
- return Intersect(FromRest$4(types));
1135
- }
1136
- function FromUnion$6(types) {
1137
- return Union(FromRest$4(types));
1138
- }
1139
- function FromPromise$2(type) {
1140
- return Awaited(type);
1141
- }
1142
- function FromRest$4(types) {
1143
- return types.map((type) => Awaited(type));
1144
- }
1145
- function Awaited(type, options) {
1146
- return CreateType(IsComputed$1(type) ? FromComputed$4(type.target, type.parameters) : IsIntersect$1(type) ? FromIntersect$6(type.allOf) : IsUnion$1(type) ? FromUnion$6(type.anyOf) : IsPromise$1(type) ? FromPromise$2(type.item) : IsRef$1(type) ? FromRef$3(type.$ref) : type, options);
1147
- }
1148
- function FromRest$3(types) {
1149
- const result = [];
1150
- for (const L of types) result.push(KeyOfPropertyKeys(L));
1151
- return result;
1152
- }
1153
- function FromIntersect$5(types) {
1154
- return SetUnionMany(FromRest$3(types));
1155
- }
1156
- function FromUnion$5(types) {
1157
- return SetIntersectMany(FromRest$3(types));
1158
- }
1159
- function FromTuple$3(types) {
1160
- return types.map((_, indexer) => indexer.toString());
1161
- }
1162
- function FromArray$4(_) {
1163
- return ["[number]"];
1164
- }
1165
- function FromProperties$14(T) {
1166
- return globalThis.Object.getOwnPropertyNames(T);
1167
- }
1168
- function FromPatternProperties(patternProperties) {
1169
- if (!includePatternProperties) return [];
1170
- return globalThis.Object.getOwnPropertyNames(patternProperties).map((key) => {
1171
- return key[0] === "^" && key[key.length - 1] === "$" ? key.slice(1, key.length - 1) : key;
1172
- });
1173
- }
1174
- function KeyOfPropertyKeys(type) {
1175
- return IsIntersect$1(type) ? FromIntersect$5(type.allOf) : IsUnion$1(type) ? FromUnion$5(type.anyOf) : IsTuple$1(type) ? FromTuple$3(type.items ?? []) : IsArray$1(type) ? FromArray$4(type.items) : IsObject$1(type) ? FromProperties$14(type.properties) : IsRecord$1(type) ? FromPatternProperties(type.patternProperties) : [];
1176
- }
1177
- let includePatternProperties = false;
1178
- function FromComputed$3(target, parameters) {
1179
- return Computed("KeyOf", [Computed(target, parameters)]);
1180
- }
1181
- function FromRef$2($ref) {
1182
- return Computed("KeyOf", [Ref($ref)]);
1183
- }
1184
- function KeyOfFromType(type, options) {
1185
- return CreateType(UnionEvaluated(KeyOfPropertyKeysToRest(KeyOfPropertyKeys(type))), options);
1186
- }
1187
- function KeyOfPropertyKeysToRest(propertyKeys) {
1188
- return propertyKeys.map((L) => L === "[number]" ? Number$1() : Literal(L));
1189
- }
1190
- function KeyOf(type, options) {
1191
- return IsComputed$1(type) ? FromComputed$3(type.target, type.parameters) : IsRef$1(type) ? FromRef$2(type.$ref) : IsMappedResult$1(type) ? KeyOfFromMappedResult(type, options) : KeyOfFromType(type, options);
1192
- }
1193
- function FromProperties$13(properties, options) {
1194
- const result = {};
1195
- for (const K2 of globalThis.Object.getOwnPropertyNames(properties)) result[K2] = KeyOf(properties[K2], Clone(options));
1196
- return result;
1197
- }
1198
- function FromMappedResult$7(mappedResult, options) {
1199
- return FromProperties$13(mappedResult.properties, options);
1200
- }
1201
- function KeyOfFromMappedResult(mappedResult, options) {
1202
- return MappedResult(FromMappedResult$7(mappedResult, options));
1203
- }
1204
- function CompositeKeys(T) {
1205
- const Acc = [];
1206
- for (const L of T) Acc.push(...KeyOfPropertyKeys(L));
1207
- return SetDistinct(Acc);
1208
- }
1209
- function FilterNever(T) {
1210
- return T.filter((L) => !IsNever$1(L));
1211
- }
1212
- function CompositeProperty(T, K) {
1213
- const Acc = [];
1214
- for (const L of T) Acc.push(...IndexFromPropertyKeys(L, [K]));
1215
- return FilterNever(Acc);
1216
- }
1217
- function CompositeProperties(T, K) {
1218
- const Acc = {};
1219
- for (const L of K) Acc[L] = IntersectEvaluated(CompositeProperty(T, L));
1220
- return Acc;
1221
- }
1222
- function Composite(T, options) {
1223
- return Object$1(CompositeProperties(T, CompositeKeys(T)), options);
1224
- }
1225
- function Date$1(options) {
1226
- return CreateType({
1227
- [Kind]: "Date",
1228
- type: "Date"
1229
- }, options);
1230
- }
1231
- function Null(options) {
1232
- return CreateType({
1233
- [Kind]: "Null",
1234
- type: "null"
1235
- }, options);
1236
- }
1237
- function Symbol$1(options) {
1238
- return CreateType({
1239
- [Kind]: "Symbol",
1240
- type: "symbol"
1241
- }, options);
1242
- }
1243
- function Undefined(options) {
1244
- return CreateType({
1245
- [Kind]: "Undefined",
1246
- type: "undefined"
1247
- }, options);
1248
- }
1249
- function Uint8Array$1(options) {
1250
- return CreateType({
1251
- [Kind]: "Uint8Array",
1252
- type: "Uint8Array"
1253
- }, options);
1254
- }
1255
- function Unknown(options) {
1256
- return CreateType({ [Kind]: "Unknown" }, options);
1257
- }
1258
- function FromArray$3(T) {
1259
- return T.map((L) => FromValue(L, false));
1260
- }
1261
- function FromProperties$12(value) {
1262
- const Acc = {};
1263
- for (const K of globalThis.Object.getOwnPropertyNames(value)) Acc[K] = Readonly(FromValue(value[K], false));
1264
- return Acc;
1265
- }
1266
- function ConditionalReadonly(T, root) {
1267
- return root === true ? T : Readonly(T);
1268
- }
1269
- function FromValue(value, root) {
1270
- return IsAsyncIterator$2(value) ? ConditionalReadonly(Any(), root) : IsIterator$2(value) ? ConditionalReadonly(Any(), root) : IsArray$3(value) ? Readonly(Tuple(FromArray$3(value))) : IsUint8Array$2(value) ? Uint8Array$1() : IsDate$2(value) ? Date$1() : IsObject$3(value) ? ConditionalReadonly(Object$1(FromProperties$12(value)), root) : IsFunction$2(value) ? ConditionalReadonly(Function([], Unknown()), root) : IsUndefined$3(value) ? Undefined() : IsNull$2(value) ? Null() : IsSymbol$2(value) ? Symbol$1() : IsBigInt$2(value) ? BigInt() : IsNumber$3(value) ? Literal(value) : IsBoolean$2(value) ? Literal(value) : IsString$2(value) ? Literal(value) : Object$1({});
1271
- }
1272
- function Const(T, options) {
1273
- return CreateType(FromValue(T, true), options);
1274
- }
1275
- function ConstructorParameters(schema, options) {
1276
- return IsConstructor$1(schema) ? Tuple(schema.parameters, options) : Never(options);
1277
- }
1278
- function Enum(item, options) {
1279
- if (IsUndefined$3(item)) throw new Error("Enum undefined or empty");
1280
- const values1 = globalThis.Object.getOwnPropertyNames(item).filter((key) => isNaN(key)).map((key) => item[key]);
1281
- return Union([...new Set(values1)].map((value) => Literal(value)), {
1282
- ...options,
1283
- [Hint]: "Enum"
1284
- });
1285
- }
1286
- var ExtendsResolverError = class extends TypeBoxError {};
1287
- var ExtendsResult;
1288
- (function(ExtendsResult) {
1289
- ExtendsResult[ExtendsResult["Union"] = 0] = "Union";
1290
- ExtendsResult[ExtendsResult["True"] = 1] = "True";
1291
- ExtendsResult[ExtendsResult["False"] = 2] = "False";
1292
- })(ExtendsResult || (ExtendsResult = {}));
1293
- function IntoBooleanResult(result) {
1294
- return result === ExtendsResult.False ? result : ExtendsResult.True;
1295
- }
1296
- function Throw(message) {
1297
- throw new ExtendsResolverError(message);
1298
- }
1299
- function IsStructuralRight(right) {
1300
- return IsNever(right) || IsIntersect(right) || IsUnion(right) || IsUnknown(right) || IsAny(right);
1301
- }
1302
- function StructuralRight(left, right) {
1303
- return IsNever(right) ? FromNeverRight(left, right) : IsIntersect(right) ? FromIntersectRight(left, right) : IsUnion(right) ? FromUnionRight(left, right) : IsUnknown(right) ? FromUnknownRight(left, right) : IsAny(right) ? FromAnyRight(left, right) : Throw("StructuralRight");
1304
- }
1305
- function FromAnyRight(left, right) {
1306
- return ExtendsResult.True;
1307
- }
1308
- function FromAny(left, right) {
1309
- return IsIntersect(right) ? FromIntersectRight(left, right) : IsUnion(right) && right.anyOf.some((schema) => IsAny(schema) || IsUnknown(schema)) ? ExtendsResult.True : IsUnion(right) ? ExtendsResult.Union : IsUnknown(right) ? ExtendsResult.True : IsAny(right) ? ExtendsResult.True : ExtendsResult.Union;
1310
- }
1311
- function FromArrayRight(left, right) {
1312
- return IsUnknown(left) ? ExtendsResult.False : IsAny(left) ? ExtendsResult.Union : IsNever(left) ? ExtendsResult.True : ExtendsResult.False;
1313
- }
1314
- function FromArray$2(left, right) {
1315
- return IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : !IsArray(right) ? ExtendsResult.False : IntoBooleanResult(Visit(left.items, right.items));
1316
- }
1317
- function FromAsyncIterator$2(left, right) {
1318
- return IsStructuralRight(right) ? StructuralRight(left, right) : !IsAsyncIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit(left.items, right.items));
1319
- }
1320
- function FromBigInt(left, right) {
1321
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsBigInt(right) ? ExtendsResult.True : ExtendsResult.False;
1322
- }
1323
- function FromBooleanRight(left, right) {
1324
- return IsLiteralBoolean(left) ? ExtendsResult.True : IsBoolean(left) ? ExtendsResult.True : ExtendsResult.False;
1325
- }
1326
- function FromBoolean(left, right) {
1327
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsBoolean(right) ? ExtendsResult.True : ExtendsResult.False;
1328
- }
1329
- function FromConstructor$2(left, right) {
1330
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : !IsConstructor(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit(left.returns, right.returns));
1331
- }
1332
- function FromDate(left, right) {
1333
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsDate(right) ? ExtendsResult.True : ExtendsResult.False;
1334
- }
1335
- function FromFunction$2(left, right) {
1336
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : !IsFunction(right) ? ExtendsResult.False : left.parameters.length > right.parameters.length ? ExtendsResult.False : !left.parameters.every((schema, index) => IntoBooleanResult(Visit(right.parameters[index], schema)) === ExtendsResult.True) ? ExtendsResult.False : IntoBooleanResult(Visit(left.returns, right.returns));
1337
- }
1338
- function FromIntegerRight(left, right) {
1339
- return IsLiteral(left) && IsNumber$3(left.const) ? ExtendsResult.True : IsNumber(left) || IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
1340
- }
1341
- function FromInteger(left, right) {
1342
- return IsInteger(right) || IsNumber(right) ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : ExtendsResult.False;
1343
- }
1344
- function FromIntersectRight(left, right) {
1345
- return right.allOf.every((schema) => Visit(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1346
- }
1347
- function FromIntersect$4(left, right) {
1348
- return left.allOf.some((schema) => Visit(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1349
- }
1350
- function FromIterator$2(left, right) {
1351
- return IsStructuralRight(right) ? StructuralRight(left, right) : !IsIterator(right) ? ExtendsResult.False : IntoBooleanResult(Visit(left.items, right.items));
1352
- }
1353
- function FromLiteral(left, right) {
1354
- return IsLiteral(right) && right.const === left.const ? ExtendsResult.True : IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsString(right) ? FromStringRight(left, right) : IsNumber(right) ? FromNumberRight(left, right) : IsInteger(right) ? FromIntegerRight(left, right) : IsBoolean(right) ? FromBooleanRight(left, right) : ExtendsResult.False;
1355
- }
1356
- function FromNeverRight(left, right) {
1357
- return ExtendsResult.False;
1358
- }
1359
- function FromNever(left, right) {
1360
- return ExtendsResult.True;
1361
- }
1362
- function UnwrapTNot(schema) {
1363
- let [current, depth] = [schema, 0];
1364
- while (true) {
1365
- if (!IsNot(current)) break;
1366
- current = current.not;
1367
- depth += 1;
1368
- }
1369
- return depth % 2 === 0 ? current : Unknown();
1370
- }
1371
- function FromNot(left, right) {
1372
- return IsNot(left) ? Visit(UnwrapTNot(left), right) : IsNot(right) ? Visit(left, UnwrapTNot(right)) : Throw("Invalid fallthrough for Not");
1373
- }
1374
- function FromNull(left, right) {
1375
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsNull(right) ? ExtendsResult.True : ExtendsResult.False;
1376
- }
1377
- function FromNumberRight(left, right) {
1378
- return IsLiteralNumber(left) ? ExtendsResult.True : IsNumber(left) || IsInteger(left) ? ExtendsResult.True : ExtendsResult.False;
1379
- }
1380
- function FromNumber(left, right) {
1381
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsInteger(right) || IsNumber(right) ? ExtendsResult.True : ExtendsResult.False;
1382
- }
1383
- function IsObjectPropertyCount(schema, count) {
1384
- return Object.getOwnPropertyNames(schema.properties).length === count;
1385
- }
1386
- function IsObjectStringLike(schema) {
1387
- return IsObjectArrayLike(schema);
1388
- }
1389
- function IsObjectSymbolLike(schema) {
1390
- return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "description" in schema.properties && IsUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && (IsString(schema.properties.description.anyOf[0]) && IsUndefined(schema.properties.description.anyOf[1]) || IsString(schema.properties.description.anyOf[1]) && IsUndefined(schema.properties.description.anyOf[0]));
1391
- }
1392
- function IsObjectNumberLike(schema) {
1393
- return IsObjectPropertyCount(schema, 0);
1394
- }
1395
- function IsObjectBooleanLike(schema) {
1396
- return IsObjectPropertyCount(schema, 0);
1397
- }
1398
- function IsObjectBigIntLike(schema) {
1399
- return IsObjectPropertyCount(schema, 0);
1400
- }
1401
- function IsObjectDateLike(schema) {
1402
- return IsObjectPropertyCount(schema, 0);
1403
- }
1404
- function IsObjectUint8ArrayLike(schema) {
1405
- return IsObjectArrayLike(schema);
1406
- }
1407
- function IsObjectFunctionLike(schema) {
1408
- const length = Number$1();
1409
- return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit(schema.properties["length"], length)) === ExtendsResult.True;
1410
- }
1411
- function IsObjectConstructorLike(schema) {
1412
- return IsObjectPropertyCount(schema, 0);
1413
- }
1414
- function IsObjectArrayLike(schema) {
1415
- const length = Number$1();
1416
- return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "length" in schema.properties && IntoBooleanResult(Visit(schema.properties["length"], length)) === ExtendsResult.True;
1417
- }
1418
- function IsObjectPromiseLike(schema) {
1419
- const then = Function([Any()], Any());
1420
- return IsObjectPropertyCount(schema, 0) || IsObjectPropertyCount(schema, 1) && "then" in schema.properties && IntoBooleanResult(Visit(schema.properties["then"], then)) === ExtendsResult.True;
1421
- }
1422
- function Property(left, right) {
1423
- return Visit(left, right) === ExtendsResult.False ? ExtendsResult.False : IsOptional(left) && !IsOptional(right) ? ExtendsResult.False : ExtendsResult.True;
1424
- }
1425
- function FromObjectRight(left, right) {
1426
- return IsUnknown(left) ? ExtendsResult.False : IsAny(left) ? ExtendsResult.Union : IsNever(left) || IsLiteralString(left) && IsObjectStringLike(right) || IsLiteralNumber(left) && IsObjectNumberLike(right) || IsLiteralBoolean(left) && IsObjectBooleanLike(right) || IsSymbol(left) && IsObjectSymbolLike(right) || IsBigInt(left) && IsObjectBigIntLike(right) || IsString(left) && IsObjectStringLike(right) || IsSymbol(left) && IsObjectSymbolLike(right) || IsNumber(left) && IsObjectNumberLike(right) || IsInteger(left) && IsObjectNumberLike(right) || IsBoolean(left) && IsObjectBooleanLike(right) || IsUint8Array(left) && IsObjectUint8ArrayLike(right) || IsDate(left) && IsObjectDateLike(right) || IsConstructor(left) && IsObjectConstructorLike(right) || IsFunction(left) && IsObjectFunctionLike(right) ? ExtendsResult.True : IsRecord(left) && IsString(RecordKey$1(left)) ? right[Hint] === "Record" ? ExtendsResult.True : ExtendsResult.False : IsRecord(left) && IsNumber(RecordKey$1(left)) ? IsObjectPropertyCount(right, 0) ? ExtendsResult.True : ExtendsResult.False : ExtendsResult.False;
1427
- }
1428
- function FromObject$6(left, right) {
1429
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : !IsObject(right) ? ExtendsResult.False : (() => {
1430
- for (const key of Object.getOwnPropertyNames(right.properties)) {
1431
- if (!(key in left.properties) && !IsOptional(right.properties[key])) return ExtendsResult.False;
1432
- if (IsOptional(right.properties[key])) return ExtendsResult.True;
1433
- if (Property(left.properties[key], right.properties[key]) === ExtendsResult.False) return ExtendsResult.False;
1434
- }
1435
- return ExtendsResult.True;
1436
- })();
1437
- }
1438
- function FromPromise$1(left, right) {
1439
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) && IsObjectPromiseLike(right) ? ExtendsResult.True : !IsPromise(right) ? ExtendsResult.False : IntoBooleanResult(Visit(left.item, right.item));
1440
- }
1441
- function RecordKey$1(schema) {
1442
- return PatternNumberExact in schema.patternProperties ? Number$1() : PatternStringExact in schema.patternProperties ? String() : Throw("Unknown record key pattern");
1443
- }
1444
- function RecordValue$1(schema) {
1445
- return PatternNumberExact in schema.patternProperties ? schema.patternProperties[PatternNumberExact] : PatternStringExact in schema.patternProperties ? schema.patternProperties[PatternStringExact] : Throw("Unable to get record value schema");
1446
- }
1447
- function FromRecordRight(left, right) {
1448
- const [Key, Value] = [RecordKey$1(right), RecordValue$1(right)];
1449
- return IsLiteralString(left) && IsNumber(Key) && IntoBooleanResult(Visit(left, Value)) === ExtendsResult.True ? ExtendsResult.True : IsUint8Array(left) && IsNumber(Key) ? Visit(left, Value) : IsString(left) && IsNumber(Key) ? Visit(left, Value) : IsArray(left) && IsNumber(Key) ? Visit(left, Value) : IsObject(left) ? (() => {
1450
- for (const key of Object.getOwnPropertyNames(left.properties)) if (Property(Value, left.properties[key]) === ExtendsResult.False) return ExtendsResult.False;
1451
- return ExtendsResult.True;
1452
- })() : ExtendsResult.False;
1453
- }
1454
- function FromRecord$2(left, right) {
1455
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : !IsRecord(right) ? ExtendsResult.False : Visit(RecordValue$1(left), RecordValue$1(right));
1456
- }
1457
- function FromRegExp(left, right) {
1458
- return Visit(IsRegExp(left) ? String() : left, IsRegExp(right) ? String() : right);
1459
- }
1460
- function FromStringRight(left, right) {
1461
- return IsLiteral(left) && IsString$2(left.const) ? ExtendsResult.True : IsString(left) ? ExtendsResult.True : ExtendsResult.False;
1462
- }
1463
- function FromString(left, right) {
1464
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsString(right) ? ExtendsResult.True : ExtendsResult.False;
1465
- }
1466
- function FromSymbol(left, right) {
1467
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsSymbol(right) ? ExtendsResult.True : ExtendsResult.False;
1468
- }
1469
- function FromTemplateLiteral$1(left, right) {
1470
- return IsTemplateLiteral(left) ? Visit(TemplateLiteralToUnion(left), right) : IsTemplateLiteral(right) ? Visit(left, TemplateLiteralToUnion(right)) : Throw("Invalid fallthrough for TemplateLiteral");
1471
- }
1472
- function IsArrayOfTuple(left, right) {
1473
- return IsArray(right) && left.items !== void 0 && left.items.every((schema) => Visit(schema, right.items) === ExtendsResult.True);
1474
- }
1475
- function FromTupleRight(left, right) {
1476
- return IsNever(left) ? ExtendsResult.True : IsUnknown(left) ? ExtendsResult.False : IsAny(left) ? ExtendsResult.Union : ExtendsResult.False;
1477
- }
1478
- function FromTuple$2(left, right) {
1479
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) && IsObjectArrayLike(right) ? ExtendsResult.True : IsArray(right) && IsArrayOfTuple(left, right) ? ExtendsResult.True : !IsTuple(right) ? ExtendsResult.False : IsUndefined$3(left.items) && !IsUndefined$3(right.items) || !IsUndefined$3(left.items) && IsUndefined$3(right.items) ? ExtendsResult.False : IsUndefined$3(left.items) && !IsUndefined$3(right.items) ? ExtendsResult.True : left.items.every((schema, index) => Visit(schema, right.items[index]) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1480
- }
1481
- function FromUint8Array(left, right) {
1482
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsUint8Array(right) ? ExtendsResult.True : ExtendsResult.False;
1483
- }
1484
- function FromUndefined(left, right) {
1485
- return IsStructuralRight(right) ? StructuralRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsRecord(right) ? FromRecordRight(left, right) : IsVoid(right) ? FromVoidRight(left, right) : IsUndefined(right) ? ExtendsResult.True : ExtendsResult.False;
1486
- }
1487
- function FromUnionRight(left, right) {
1488
- return right.anyOf.some((schema) => Visit(left, schema) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1489
- }
1490
- function FromUnion$4(left, right) {
1491
- return left.anyOf.every((schema) => Visit(schema, right) === ExtendsResult.True) ? ExtendsResult.True : ExtendsResult.False;
1492
- }
1493
- function FromUnknownRight(left, right) {
1494
- return ExtendsResult.True;
1495
- }
1496
- function FromUnknown(left, right) {
1497
- return IsNever(right) ? FromNeverRight(left, right) : IsIntersect(right) ? FromIntersectRight(left, right) : IsUnion(right) ? FromUnionRight(left, right) : IsAny(right) ? FromAnyRight(left, right) : IsString(right) ? FromStringRight(left, right) : IsNumber(right) ? FromNumberRight(left, right) : IsInteger(right) ? FromIntegerRight(left, right) : IsBoolean(right) ? FromBooleanRight(left, right) : IsArray(right) ? FromArrayRight(left, right) : IsTuple(right) ? FromTupleRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsUnknown(right) ? ExtendsResult.True : ExtendsResult.False;
1498
- }
1499
- function FromVoidRight(left, right) {
1500
- return IsUndefined(left) ? ExtendsResult.True : IsUndefined(left) ? ExtendsResult.True : ExtendsResult.False;
1501
- }
1502
- function FromVoid(left, right) {
1503
- return IsIntersect(right) ? FromIntersectRight(left, right) : IsUnion(right) ? FromUnionRight(left, right) : IsUnknown(right) ? FromUnknownRight(left, right) : IsAny(right) ? FromAnyRight(left, right) : IsObject(right) ? FromObjectRight(left, right) : IsVoid(right) ? ExtendsResult.True : ExtendsResult.False;
1504
- }
1505
- function Visit(left, right) {
1506
- return IsTemplateLiteral(left) || IsTemplateLiteral(right) ? FromTemplateLiteral$1(left, right) : IsRegExp(left) || IsRegExp(right) ? FromRegExp(left, right) : IsNot(left) || IsNot(right) ? FromNot(left, right) : IsAny(left) ? FromAny(left, right) : IsArray(left) ? FromArray$2(left, right) : IsBigInt(left) ? FromBigInt(left, right) : IsBoolean(left) ? FromBoolean(left, right) : IsAsyncIterator(left) ? FromAsyncIterator$2(left, right) : IsConstructor(left) ? FromConstructor$2(left, right) : IsDate(left) ? FromDate(left, right) : IsFunction(left) ? FromFunction$2(left, right) : IsInteger(left) ? FromInteger(left, right) : IsIntersect(left) ? FromIntersect$4(left, right) : IsIterator(left) ? FromIterator$2(left, right) : IsLiteral(left) ? FromLiteral(left, right) : IsNever(left) ? FromNever(left, right) : IsNull(left) ? FromNull(left, right) : IsNumber(left) ? FromNumber(left, right) : IsObject(left) ? FromObject$6(left, right) : IsRecord(left) ? FromRecord$2(left, right) : IsString(left) ? FromString(left, right) : IsSymbol(left) ? FromSymbol(left, right) : IsTuple(left) ? FromTuple$2(left, right) : IsPromise(left) ? FromPromise$1(left, right) : IsUint8Array(left) ? FromUint8Array(left, right) : IsUndefined(left) ? FromUndefined(left, right) : IsUnion(left) ? FromUnion$4(left, right) : IsUnknown(left) ? FromUnknown(left, right) : IsVoid(left) ? FromVoid(left, right) : Throw(`Unknown left type operand '${left[Kind]}'`);
1507
- }
1508
- function ExtendsCheck(left, right) {
1509
- return Visit(left, right);
1510
- }
1511
- function FromProperties$11(P, Right, True, False, options) {
1512
- const Acc = {};
1513
- for (const K2 of globalThis.Object.getOwnPropertyNames(P)) Acc[K2] = Extends(P[K2], Right, True, False, Clone(options));
1514
- return Acc;
1515
- }
1516
- function FromMappedResult$6(Left, Right, True, False, options) {
1517
- return FromProperties$11(Left.properties, Right, True, False, options);
1518
- }
1519
- function ExtendsFromMappedResult(Left, Right, True, False, options) {
1520
- return MappedResult(FromMappedResult$6(Left, Right, True, False, options));
1521
- }
1522
- function ExtendsResolve(left, right, trueType, falseType) {
1523
- const R = ExtendsCheck(left, right);
1524
- return R === ExtendsResult.Union ? Union([trueType, falseType]) : R === ExtendsResult.True ? trueType : falseType;
1525
- }
1526
- function Extends(L, R, T, F, options) {
1527
- return IsMappedResult$1(L) ? ExtendsFromMappedResult(L, R, T, F, options) : IsMappedKey$1(L) ? CreateType(ExtendsFromMappedKey(L, R, T, F, options)) : CreateType(ExtendsResolve(L, R, T, F), options);
1528
- }
1529
- function FromPropertyKey$2(K, U, L, R, options) {
1530
- return { [K]: Extends(Literal(K), U, L, R, Clone(options)) };
1531
- }
1532
- function FromPropertyKeys$2(K, U, L, R, options) {
1533
- return K.reduce((Acc, LK) => {
1534
- return {
1535
- ...Acc,
1536
- ...FromPropertyKey$2(LK, U, L, R, options)
1537
- };
1538
- }, {});
1539
- }
1540
- function FromMappedKey$2(K, U, L, R, options) {
1541
- return FromPropertyKeys$2(K.keys, U, L, R, options);
1542
- }
1543
- function ExtendsFromMappedKey(T, U, L, R, options) {
1544
- return MappedResult(FromMappedKey$2(T, U, L, R, options));
1545
- }
1546
- function ExcludeFromTemplateLiteral(L, R) {
1547
- return Exclude(TemplateLiteralToUnion(L), R);
1548
- }
1549
- function ExcludeRest(L, R) {
1550
- const excluded = L.filter((inner) => ExtendsCheck(inner, R) === ExtendsResult.False);
1551
- return excluded.length === 1 ? excluded[0] : Union(excluded);
1552
- }
1553
- function Exclude(L, R, options = {}) {
1554
- if (IsTemplateLiteral$1(L)) return CreateType(ExcludeFromTemplateLiteral(L, R), options);
1555
- if (IsMappedResult$1(L)) return CreateType(ExcludeFromMappedResult(L, R), options);
1556
- return CreateType(IsUnion$1(L) ? ExcludeRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? Never() : L, options);
1557
- }
1558
- function FromProperties$10(P, U) {
1559
- const Acc = {};
1560
- for (const K2 of globalThis.Object.getOwnPropertyNames(P)) Acc[K2] = Exclude(P[K2], U);
1561
- return Acc;
1562
- }
1563
- function FromMappedResult$5(R, T) {
1564
- return FromProperties$10(R.properties, T);
1565
- }
1566
- function ExcludeFromMappedResult(R, T) {
1567
- return MappedResult(FromMappedResult$5(R, T));
1568
- }
1569
- function ExtractFromTemplateLiteral(L, R) {
1570
- return Extract(TemplateLiteralToUnion(L), R);
1571
- }
1572
- function ExtractRest(L, R) {
1573
- const extracted = L.filter((inner) => ExtendsCheck(inner, R) !== ExtendsResult.False);
1574
- return extracted.length === 1 ? extracted[0] : Union(extracted);
1575
- }
1576
- function Extract(L, R, options) {
1577
- if (IsTemplateLiteral$1(L)) return CreateType(ExtractFromTemplateLiteral(L, R), options);
1578
- if (IsMappedResult$1(L)) return CreateType(ExtractFromMappedResult(L, R), options);
1579
- return CreateType(IsUnion$1(L) ? ExtractRest(L.anyOf, R) : ExtendsCheck(L, R) !== ExtendsResult.False ? L : Never(), options);
1580
- }
1581
- function FromProperties$9(P, T) {
1582
- const Acc = {};
1583
- for (const K2 of globalThis.Object.getOwnPropertyNames(P)) Acc[K2] = Extract(P[K2], T);
1584
- return Acc;
1585
- }
1586
- function FromMappedResult$4(R, T) {
1587
- return FromProperties$9(R.properties, T);
1588
- }
1589
- function ExtractFromMappedResult(R, T) {
1590
- return MappedResult(FromMappedResult$4(R, T));
1591
- }
1592
- function InstanceType(schema, options) {
1593
- return IsConstructor$1(schema) ? CreateType(schema.returns, options) : Never(options);
1594
- }
1595
- function ReadonlyOptional(schema) {
1596
- return Readonly(Optional(schema));
1597
- }
1598
- function RecordCreateFromPattern(pattern, T, options) {
1599
- return CreateType({
1600
- [Kind]: "Record",
1601
- type: "object",
1602
- patternProperties: { [pattern]: T }
1603
- }, options);
1604
- }
1605
- function RecordCreateFromKeys(K, T, options) {
1606
- const result = {};
1607
- for (const K2 of K) result[K2] = T;
1608
- return Object$1(result, {
1609
- ...options,
1610
- [Hint]: "Record"
1611
- });
1612
- }
1613
- function FromTemplateLiteralKey(K, T, options) {
1614
- return IsTemplateLiteralFinite(K) ? RecordCreateFromKeys(IndexPropertyKeys(K), T, options) : RecordCreateFromPattern(K.pattern, T, options);
1615
- }
1616
- function FromUnionKey(key, type, options) {
1617
- return RecordCreateFromKeys(IndexPropertyKeys(Union(key)), type, options);
1618
- }
1619
- function FromLiteralKey(key, type, options) {
1620
- return RecordCreateFromKeys([key.toString()], type, options);
1621
- }
1622
- function FromRegExpKey(key, type, options) {
1623
- return RecordCreateFromPattern(key.source, type, options);
1624
- }
1625
- function FromStringKey(key, type, options) {
1626
- return RecordCreateFromPattern(IsUndefined$3(key.pattern) ? PatternStringExact : key.pattern, type, options);
1627
- }
1628
- function FromAnyKey(_, type, options) {
1629
- return RecordCreateFromPattern(PatternStringExact, type, options);
1630
- }
1631
- function FromNeverKey(_key, type, options) {
1632
- return RecordCreateFromPattern(PatternNeverExact, type, options);
1633
- }
1634
- function FromBooleanKey(_key, type, options) {
1635
- return Object$1({
1636
- true: type,
1637
- false: type
1638
- }, options);
1639
- }
1640
- function FromIntegerKey(_key, type, options) {
1641
- return RecordCreateFromPattern(PatternNumberExact, type, options);
1642
- }
1643
- function FromNumberKey(_, type, options) {
1644
- return RecordCreateFromPattern(PatternNumberExact, type, options);
1645
- }
1646
- function Record(key, type, options = {}) {
1647
- return IsUnion$1(key) ? FromUnionKey(key.anyOf, type, options) : IsTemplateLiteral$1(key) ? FromTemplateLiteralKey(key, type, options) : IsLiteral$1(key) ? FromLiteralKey(key.const, type, options) : IsBoolean$1(key) ? FromBooleanKey(key, type, options) : IsInteger$1(key) ? FromIntegerKey(key, type, options) : IsNumber$1(key) ? FromNumberKey(key, type, options) : IsRegExp$1(key) ? FromRegExpKey(key, type, options) : IsString$1(key) ? FromStringKey(key, type, options) : IsAny$1(key) ? FromAnyKey(key, type, options) : IsNever$1(key) ? FromNeverKey(key, type, options) : Never(options);
1648
- }
1649
- function RecordPattern(record) {
1650
- return globalThis.Object.getOwnPropertyNames(record.patternProperties)[0];
1651
- }
1652
- function RecordKey(type) {
1653
- const pattern = RecordPattern(type);
1654
- return pattern === PatternStringExact ? String() : pattern === PatternNumberExact ? Number$1() : String({ pattern });
1655
- }
1656
- function RecordValue(type) {
1657
- return type.patternProperties[RecordPattern(type)];
1658
- }
1659
- function FromConstructor$1(args, type) {
1660
- type.parameters = FromTypes$1(args, type.parameters);
1661
- type.returns = FromType$1(args, type.returns);
1662
- return type;
1663
- }
1664
- function FromFunction$1(args, type) {
1665
- type.parameters = FromTypes$1(args, type.parameters);
1666
- type.returns = FromType$1(args, type.returns);
1667
- return type;
1668
- }
1669
- function FromIntersect$3(args, type) {
1670
- type.allOf = FromTypes$1(args, type.allOf);
1671
- return type;
1672
- }
1673
- function FromUnion$3(args, type) {
1674
- type.anyOf = FromTypes$1(args, type.anyOf);
1675
- return type;
1676
- }
1677
- function FromTuple$1(args, type) {
1678
- if (IsUndefined$3(type.items)) return type;
1679
- type.items = FromTypes$1(args, type.items);
1680
- return type;
1681
- }
1682
- function FromArray$1(args, type) {
1683
- type.items = FromType$1(args, type.items);
1684
- return type;
1685
- }
1686
- function FromAsyncIterator$1(args, type) {
1687
- type.items = FromType$1(args, type.items);
1688
- return type;
1689
- }
1690
- function FromIterator$1(args, type) {
1691
- type.items = FromType$1(args, type.items);
1692
- return type;
1693
- }
1694
- function FromPromise(args, type) {
1695
- type.item = FromType$1(args, type.item);
1696
- return type;
1697
- }
1698
- function FromObject$5(args, type) {
1699
- const mappedProperties = FromProperties$8(args, type.properties);
1700
- return {
1701
- ...type,
1702
- ...Object$1(mappedProperties)
1703
- };
1704
- }
1705
- function FromRecord$1(args, type) {
1706
- const result = Record(FromType$1(args, RecordKey(type)), FromType$1(args, RecordValue(type)));
1707
- return {
1708
- ...type,
1709
- ...result
1710
- };
1711
- }
1712
- function FromArgument(args, argument) {
1713
- return argument.index in args ? args[argument.index] : Unknown();
1714
- }
1715
- function FromProperty$1(args, type) {
1716
- const isReadonly = IsReadonly(type);
1717
- const isOptional = IsOptional$1(type);
1718
- const mapped = FromType$1(args, type);
1719
- return isReadonly && isOptional ? ReadonlyOptional(mapped) : isReadonly && !isOptional ? Readonly(mapped) : !isReadonly && isOptional ? Optional(mapped) : mapped;
1720
- }
1721
- function FromProperties$8(args, properties) {
1722
- return globalThis.Object.getOwnPropertyNames(properties).reduce((result, key) => {
1723
- return {
1724
- ...result,
1725
- [key]: FromProperty$1(args, properties[key])
1726
- };
1727
- }, {});
1728
- }
1729
- function FromTypes$1(args, types) {
1730
- return types.map((type) => FromType$1(args, type));
1731
- }
1732
- function FromType$1(args, type) {
1733
- return IsConstructor$1(type) ? FromConstructor$1(args, type) : IsFunction$1(type) ? FromFunction$1(args, type) : IsIntersect$1(type) ? FromIntersect$3(args, type) : IsUnion$1(type) ? FromUnion$3(args, type) : IsTuple$1(type) ? FromTuple$1(args, type) : IsArray$1(type) ? FromArray$1(args, type) : IsAsyncIterator$1(type) ? FromAsyncIterator$1(args, type) : IsIterator$1(type) ? FromIterator$1(args, type) : IsPromise$1(type) ? FromPromise(args, type) : IsObject$1(type) ? FromObject$5(args, type) : IsRecord$1(type) ? FromRecord$1(args, type) : IsArgument$1(type) ? FromArgument(args, type) : type;
1734
- }
1735
- function Instantiate(type, args) {
1736
- return FromType$1(args, CloneType(type));
1737
- }
1738
- function Integer(options) {
1739
- return CreateType({
1740
- [Kind]: "Integer",
1741
- type: "integer"
1742
- }, options);
1743
- }
1744
- function MappedIntrinsicPropertyKey(K, M, options) {
1745
- return { [K]: Intrinsic(Literal(K), M, Clone(options)) };
1746
- }
1747
- function MappedIntrinsicPropertyKeys(K, M, options) {
1748
- return K.reduce((Acc, L) => {
1749
- return {
1750
- ...Acc,
1751
- ...MappedIntrinsicPropertyKey(L, M, options)
1752
- };
1753
- }, {});
1754
- }
1755
- function MappedIntrinsicProperties(T, M, options) {
1756
- return MappedIntrinsicPropertyKeys(T["keys"], M, options);
1757
- }
1758
- function IntrinsicFromMappedKey(T, M, options) {
1759
- return MappedResult(MappedIntrinsicProperties(T, M, options));
1760
- }
1761
- function ApplyUncapitalize(value) {
1762
- const [first, rest] = [value.slice(0, 1), value.slice(1)];
1763
- return [first.toLowerCase(), rest].join("");
1764
- }
1765
- function ApplyCapitalize(value) {
1766
- const [first, rest] = [value.slice(0, 1), value.slice(1)];
1767
- return [first.toUpperCase(), rest].join("");
1768
- }
1769
- function ApplyUppercase(value) {
1770
- return value.toUpperCase();
1771
- }
1772
- function ApplyLowercase(value) {
1773
- return value.toLowerCase();
1774
- }
1775
- function FromTemplateLiteral(schema, mode, options) {
1776
- const expression = TemplateLiteralParseExact(schema.pattern);
1777
- if (!IsTemplateLiteralExpressionFinite(expression)) return {
1778
- ...schema,
1779
- pattern: FromLiteralValue(schema.pattern, mode)
1780
- };
1781
- return TemplateLiteral([Union(FromRest$2([...TemplateLiteralExpressionGenerate(expression)].map((value) => Literal(value)), mode))], options);
1782
- }
1783
- function FromLiteralValue(value, mode) {
1784
- return typeof value === "string" ? mode === "Uncapitalize" ? ApplyUncapitalize(value) : mode === "Capitalize" ? ApplyCapitalize(value) : mode === "Uppercase" ? ApplyUppercase(value) : mode === "Lowercase" ? ApplyLowercase(value) : value : value.toString();
1785
- }
1786
- function FromRest$2(T, M) {
1787
- return T.map((L) => Intrinsic(L, M));
1788
- }
1789
- function Intrinsic(schema, mode, options = {}) {
1790
- return IsMappedKey$1(schema) ? IntrinsicFromMappedKey(schema, mode, options) : IsTemplateLiteral$1(schema) ? FromTemplateLiteral(schema, mode, options) : IsUnion$1(schema) ? Union(FromRest$2(schema.anyOf, mode), options) : IsLiteral$1(schema) ? Literal(FromLiteralValue(schema.const, mode), options) : CreateType(schema, options);
1791
- }
1792
- function Capitalize(T, options = {}) {
1793
- return Intrinsic(T, "Capitalize", options);
1794
- }
1795
- function Lowercase(T, options = {}) {
1796
- return Intrinsic(T, "Lowercase", options);
1797
- }
1798
- function Uncapitalize(T, options = {}) {
1799
- return Intrinsic(T, "Uncapitalize", options);
1800
- }
1801
- function Uppercase(T, options = {}) {
1802
- return Intrinsic(T, "Uppercase", options);
1803
- }
1804
- function FromProperties$7(properties, propertyKeys, options) {
1805
- const result = {};
1806
- for (const K2 of globalThis.Object.getOwnPropertyNames(properties)) result[K2] = Omit(properties[K2], propertyKeys, Clone(options));
1807
- return result;
1808
- }
1809
- function FromMappedResult$3(mappedResult, propertyKeys, options) {
1810
- return FromProperties$7(mappedResult.properties, propertyKeys, options);
1811
- }
1812
- function OmitFromMappedResult(mappedResult, propertyKeys, options) {
1813
- return MappedResult(FromMappedResult$3(mappedResult, propertyKeys, options));
1814
- }
1815
- function FromIntersect$2(types, propertyKeys) {
1816
- return types.map((type) => OmitResolve(type, propertyKeys));
1817
- }
1818
- function FromUnion$2(types, propertyKeys) {
1819
- return types.map((type) => OmitResolve(type, propertyKeys));
1820
- }
1821
- function FromProperty(properties, key) {
1822
- const { [key]: _, ...R } = properties;
1823
- return R;
1824
- }
1825
- function FromProperties$6(properties, propertyKeys) {
1826
- return propertyKeys.reduce((T, K2) => FromProperty(T, K2), properties);
1827
- }
1828
- function FromObject$4(type, propertyKeys, properties) {
1829
- const options = Discard(type, [
1830
- TransformKind,
1831
- "$id",
1832
- "required",
1833
- "properties"
1834
- ]);
1835
- return Object$1(FromProperties$6(properties, propertyKeys), options);
1836
- }
1837
- function UnionFromPropertyKeys$1(propertyKeys) {
1838
- return Union(propertyKeys.reduce((result, key) => IsLiteralValue$1(key) ? [...result, Literal(key)] : result, []));
1839
- }
1840
- function OmitResolve(type, propertyKeys) {
1841
- return IsIntersect$1(type) ? Intersect(FromIntersect$2(type.allOf, propertyKeys)) : IsUnion$1(type) ? Union(FromUnion$2(type.anyOf, propertyKeys)) : IsObject$1(type) ? FromObject$4(type, propertyKeys, type.properties) : Object$1({});
1842
- }
1843
- function Omit(type, key, options) {
1844
- const typeKey = IsArray$3(key) ? UnionFromPropertyKeys$1(key) : key;
1845
- const propertyKeys = IsSchema$1(key) ? IndexPropertyKeys(key) : key;
1846
- const isTypeRef = IsRef$1(type);
1847
- const isKeyRef = IsRef$1(key);
1848
- return IsMappedResult$1(type) ? OmitFromMappedResult(type, propertyKeys, options) : IsMappedKey$1(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({
1849
- ...OmitResolve(type, propertyKeys),
1850
- ...options
1851
- });
1852
- }
1853
- function FromPropertyKey$1(type, key, options) {
1854
- return { [key]: Omit(type, [key], Clone(options)) };
1855
- }
1856
- function FromPropertyKeys$1(type, propertyKeys, options) {
1857
- return propertyKeys.reduce((Acc, LK) => {
1858
- return {
1859
- ...Acc,
1860
- ...FromPropertyKey$1(type, LK, options)
1861
- };
1862
- }, {});
1863
- }
1864
- function FromMappedKey$1(type, mappedKey, options) {
1865
- return FromPropertyKeys$1(type, mappedKey.keys, options);
1866
- }
1867
- function OmitFromMappedKey(type, mappedKey, options) {
1868
- return MappedResult(FromMappedKey$1(type, mappedKey, options));
1869
- }
1870
- function FromProperties$5(properties, propertyKeys, options) {
1871
- const result = {};
1872
- for (const K2 of globalThis.Object.getOwnPropertyNames(properties)) result[K2] = Pick(properties[K2], propertyKeys, Clone(options));
1873
- return result;
1874
- }
1875
- function FromMappedResult$2(mappedResult, propertyKeys, options) {
1876
- return FromProperties$5(mappedResult.properties, propertyKeys, options);
1877
- }
1878
- function PickFromMappedResult(mappedResult, propertyKeys, options) {
1879
- return MappedResult(FromMappedResult$2(mappedResult, propertyKeys, options));
1880
- }
1881
- function FromIntersect$1(types, propertyKeys) {
1882
- return types.map((type) => PickResolve(type, propertyKeys));
1883
- }
1884
- function FromUnion$1(types, propertyKeys) {
1885
- return types.map((type) => PickResolve(type, propertyKeys));
1886
- }
1887
- function FromProperties$4(properties, propertyKeys) {
1888
- const result = {};
1889
- for (const K2 of propertyKeys) if (K2 in properties) result[K2] = properties[K2];
1890
- return result;
1891
- }
1892
- function FromObject$3(Type, keys, properties) {
1893
- const options = Discard(Type, [
1894
- TransformKind,
1895
- "$id",
1896
- "required",
1897
- "properties"
1898
- ]);
1899
- return Object$1(FromProperties$4(properties, keys), options);
1900
- }
1901
- function UnionFromPropertyKeys(propertyKeys) {
1902
- return Union(propertyKeys.reduce((result, key) => IsLiteralValue$1(key) ? [...result, Literal(key)] : result, []));
1903
- }
1904
- function PickResolve(type, propertyKeys) {
1905
- return IsIntersect$1(type) ? Intersect(FromIntersect$1(type.allOf, propertyKeys)) : IsUnion$1(type) ? Union(FromUnion$1(type.anyOf, propertyKeys)) : IsObject$1(type) ? FromObject$3(type, propertyKeys, type.properties) : Object$1({});
1906
- }
1907
- function Pick(type, key, options) {
1908
- const typeKey = IsArray$3(key) ? UnionFromPropertyKeys(key) : key;
1909
- const propertyKeys = IsSchema$1(key) ? IndexPropertyKeys(key) : key;
1910
- const isTypeRef = IsRef$1(type);
1911
- const isKeyRef = IsRef$1(key);
1912
- return IsMappedResult$1(type) ? PickFromMappedResult(type, propertyKeys, options) : IsMappedKey$1(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({
1913
- ...PickResolve(type, propertyKeys),
1914
- ...options
1915
- });
1916
- }
1917
- function FromPropertyKey(type, key, options) {
1918
- return { [key]: Pick(type, [key], Clone(options)) };
1919
- }
1920
- function FromPropertyKeys(type, propertyKeys, options) {
1921
- return propertyKeys.reduce((result, leftKey) => {
1922
- return {
1923
- ...result,
1924
- ...FromPropertyKey(type, leftKey, options)
1925
- };
1926
- }, {});
1927
- }
1928
- function FromMappedKey(type, mappedKey, options) {
1929
- return FromPropertyKeys(type, mappedKey.keys, options);
1930
- }
1931
- function PickFromMappedKey(type, mappedKey, options) {
1932
- return MappedResult(FromMappedKey(type, mappedKey, options));
1933
- }
1934
- function FromComputed$2(target, parameters) {
1935
- return Computed("Partial", [Computed(target, parameters)]);
1936
- }
1937
- function FromRef$1($ref) {
1938
- return Computed("Partial", [Ref($ref)]);
1939
- }
1940
- function FromProperties$3(properties) {
1941
- const partialProperties = {};
1942
- for (const K of globalThis.Object.getOwnPropertyNames(properties)) partialProperties[K] = Optional(properties[K]);
1943
- return partialProperties;
1944
- }
1945
- function FromObject$2(type, properties) {
1946
- const options = Discard(type, [
1947
- TransformKind,
1948
- "$id",
1949
- "required",
1950
- "properties"
1951
- ]);
1952
- return Object$1(FromProperties$3(properties), options);
1953
- }
1954
- function FromRest$1(types) {
1955
- return types.map((type) => PartialResolve(type));
1956
- }
1957
- function PartialResolve(type) {
1958
- return IsComputed$1(type) ? FromComputed$2(type.target, type.parameters) : IsRef$1(type) ? FromRef$1(type.$ref) : IsIntersect$1(type) ? Intersect(FromRest$1(type.allOf)) : IsUnion$1(type) ? Union(FromRest$1(type.anyOf)) : IsObject$1(type) ? FromObject$2(type, type.properties) : IsBigInt$1(type) ? type : IsBoolean$1(type) ? type : IsInteger$1(type) ? type : IsLiteral$1(type) ? type : IsNull$1(type) ? type : IsNumber$1(type) ? type : IsString$1(type) ? type : IsSymbol$1(type) ? type : IsUndefined$1(type) ? type : Object$1({});
1959
- }
1960
- function Partial(type, options) {
1961
- if (IsMappedResult$1(type)) return PartialFromMappedResult(type, options);
1962
- else return CreateType({
1963
- ...PartialResolve(type),
1964
- ...options
1965
- });
1966
- }
1967
- function FromProperties$2(K, options) {
1968
- const Acc = {};
1969
- for (const K2 of globalThis.Object.getOwnPropertyNames(K)) Acc[K2] = Partial(K[K2], Clone(options));
1970
- return Acc;
1971
- }
1972
- function FromMappedResult$1(R, options) {
1973
- return FromProperties$2(R.properties, options);
1974
- }
1975
- function PartialFromMappedResult(R, options) {
1976
- return MappedResult(FromMappedResult$1(R, options));
1977
- }
1978
- function FromComputed$1(target, parameters) {
1979
- return Computed("Required", [Computed(target, parameters)]);
1980
- }
1981
- function FromRef($ref) {
1982
- return Computed("Required", [Ref($ref)]);
1983
- }
1984
- function FromProperties$1(properties) {
1985
- const requiredProperties = {};
1986
- for (const K of globalThis.Object.getOwnPropertyNames(properties)) requiredProperties[K] = Discard(properties[K], [OptionalKind]);
1987
- return requiredProperties;
1988
- }
1989
- function FromObject$1(type, properties) {
1990
- const options = Discard(type, [
1991
- TransformKind,
1992
- "$id",
1993
- "required",
1994
- "properties"
1995
- ]);
1996
- return Object$1(FromProperties$1(properties), options);
1997
- }
1998
- function FromRest(types) {
1999
- return types.map((type) => RequiredResolve(type));
2000
- }
2001
- function RequiredResolve(type) {
2002
- return IsComputed$1(type) ? FromComputed$1(type.target, type.parameters) : IsRef$1(type) ? FromRef(type.$ref) : IsIntersect$1(type) ? Intersect(FromRest(type.allOf)) : IsUnion$1(type) ? Union(FromRest(type.anyOf)) : IsObject$1(type) ? FromObject$1(type, type.properties) : IsBigInt$1(type) ? type : IsBoolean$1(type) ? type : IsInteger$1(type) ? type : IsLiteral$1(type) ? type : IsNull$1(type) ? type : IsNumber$1(type) ? type : IsString$1(type) ? type : IsSymbol$1(type) ? type : IsUndefined$1(type) ? type : Object$1({});
2003
- }
2004
- function Required(type, options) {
2005
- if (IsMappedResult$1(type)) return RequiredFromMappedResult(type, options);
2006
- else return CreateType({
2007
- ...RequiredResolve(type),
2008
- ...options
2009
- });
2010
- }
2011
- function FromProperties(P, options) {
2012
- const Acc = {};
2013
- for (const K2 of globalThis.Object.getOwnPropertyNames(P)) Acc[K2] = Required(P[K2], options);
2014
- return Acc;
2015
- }
2016
- function FromMappedResult(R, options) {
2017
- return FromProperties(R.properties, options);
2018
- }
2019
- function RequiredFromMappedResult(R, options) {
2020
- return MappedResult(FromMappedResult(R, options));
2021
- }
2022
- function DereferenceParameters(moduleProperties, types) {
2023
- return types.map((type) => {
2024
- return IsRef$1(type) ? Dereference(moduleProperties, type.$ref) : FromType(moduleProperties, type);
2025
- });
2026
- }
2027
- function Dereference(moduleProperties, ref) {
2028
- return ref in moduleProperties ? IsRef$1(moduleProperties[ref]) ? Dereference(moduleProperties, moduleProperties[ref].$ref) : FromType(moduleProperties, moduleProperties[ref]) : Never();
2029
- }
2030
- function FromAwaited(parameters) {
2031
- return Awaited(parameters[0]);
2032
- }
2033
- function FromIndex(parameters) {
2034
- return Index(parameters[0], parameters[1]);
2035
- }
2036
- function FromKeyOf(parameters) {
2037
- return KeyOf(parameters[0]);
2038
- }
2039
- function FromPartial(parameters) {
2040
- return Partial(parameters[0]);
2041
- }
2042
- function FromOmit(parameters) {
2043
- return Omit(parameters[0], parameters[1]);
2044
- }
2045
- function FromPick(parameters) {
2046
- return Pick(parameters[0], parameters[1]);
2047
- }
2048
- function FromRequired(parameters) {
2049
- return Required(parameters[0]);
2050
- }
2051
- function FromComputed(moduleProperties, target, parameters) {
2052
- const dereferenced = DereferenceParameters(moduleProperties, parameters);
2053
- 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();
2054
- }
2055
- function FromArray(moduleProperties, type) {
2056
- return Array$1(FromType(moduleProperties, type));
2057
- }
2058
- function FromAsyncIterator(moduleProperties, type) {
2059
- return AsyncIterator(FromType(moduleProperties, type));
2060
- }
2061
- function FromConstructor(moduleProperties, parameters, instanceType) {
2062
- return Constructor(FromTypes(moduleProperties, parameters), FromType(moduleProperties, instanceType));
2063
- }
2064
- function FromFunction(moduleProperties, parameters, returnType) {
2065
- return Function(FromTypes(moduleProperties, parameters), FromType(moduleProperties, returnType));
2066
- }
2067
- function FromIntersect(moduleProperties, types) {
2068
- return Intersect(FromTypes(moduleProperties, types));
2069
- }
2070
- function FromIterator(moduleProperties, type) {
2071
- return Iterator(FromType(moduleProperties, type));
2072
- }
2073
- function FromObject(moduleProperties, properties) {
2074
- return Object$1(globalThis.Object.keys(properties).reduce((result, key) => {
2075
- return {
2076
- ...result,
2077
- [key]: FromType(moduleProperties, properties[key])
2078
- };
2079
- }, {}));
2080
- }
2081
- function FromRecord(moduleProperties, type) {
2082
- const [value, pattern] = [FromType(moduleProperties, RecordValue(type)), RecordPattern(type)];
2083
- const result = CloneType(type);
2084
- result.patternProperties[pattern] = value;
2085
- return result;
2086
- }
2087
- function FromTransform(moduleProperties, transform) {
2088
- return IsRef$1(transform) ? {
2089
- ...Dereference(moduleProperties, transform.$ref),
2090
- [TransformKind]: transform[TransformKind]
2091
- } : transform;
2092
- }
2093
- function FromTuple(moduleProperties, types) {
2094
- return Tuple(FromTypes(moduleProperties, types));
2095
- }
2096
- function FromUnion(moduleProperties, types) {
2097
- return Union(FromTypes(moduleProperties, types));
2098
- }
2099
- function FromTypes(moduleProperties, types) {
2100
- return types.map((type) => FromType(moduleProperties, type));
2101
- }
2102
- function FromType(moduleProperties, type) {
2103
- return IsOptional$1(type) ? CreateType(FromType(moduleProperties, Discard(type, [OptionalKind])), type) : IsReadonly(type) ? CreateType(FromType(moduleProperties, Discard(type, [ReadonlyKind])), type) : IsTransform$1(type) ? CreateType(FromTransform(moduleProperties, type), type) : IsArray$1(type) ? CreateType(FromArray(moduleProperties, type.items), type) : IsAsyncIterator$1(type) ? CreateType(FromAsyncIterator(moduleProperties, type.items), type) : IsComputed$1(type) ? CreateType(FromComputed(moduleProperties, type.target, type.parameters)) : IsConstructor$1(type) ? CreateType(FromConstructor(moduleProperties, type.parameters, type.returns), type) : IsFunction$1(type) ? CreateType(FromFunction(moduleProperties, type.parameters, type.returns), type) : IsIntersect$1(type) ? CreateType(FromIntersect(moduleProperties, type.allOf), type) : IsIterator$1(type) ? CreateType(FromIterator(moduleProperties, type.items), type) : IsObject$1(type) ? CreateType(FromObject(moduleProperties, type.properties), type) : IsRecord$1(type) ? CreateType(FromRecord(moduleProperties, type)) : IsTuple$1(type) ? CreateType(FromTuple(moduleProperties, type.items || []), type) : IsUnion$1(type) ? CreateType(FromUnion(moduleProperties, type.anyOf), type) : type;
2104
- }
2105
- function ComputeType(moduleProperties, key) {
2106
- return key in moduleProperties ? FromType(moduleProperties, moduleProperties[key]) : Never();
2107
- }
2108
- function ComputeModuleProperties(moduleProperties) {
2109
- return globalThis.Object.getOwnPropertyNames(moduleProperties).reduce((result, key) => {
2110
- return {
2111
- ...result,
2112
- [key]: ComputeType(moduleProperties, key)
2113
- };
2114
- }, {});
2115
- }
2116
- var TModule = class {
2117
- constructor($defs) {
2118
- const computed = ComputeModuleProperties($defs);
2119
- this.$defs = this.WithIdentifiers(computed);
2120
- }
2121
- Import(key, options) {
2122
- const $defs = {
2123
- ...this.$defs,
2124
- [key]: CreateType(this.$defs[key], options)
2125
- };
2126
- return CreateType({
2127
- [Kind]: "Import",
2128
- $defs,
2129
- $ref: key
2130
- });
2131
- }
2132
- WithIdentifiers($defs) {
2133
- return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
2134
- return {
2135
- ...result,
2136
- [key]: {
2137
- ...$defs[key],
2138
- $id: key
2139
- }
2140
- };
2141
- }, {});
2142
- }
2143
- };
2144
- function Module(properties) {
2145
- return new TModule(properties);
2146
- }
2147
- function Not(type, options) {
2148
- return CreateType({
2149
- [Kind]: "Not",
2150
- not: type
2151
- }, options);
2152
- }
2153
- function Parameters(schema, options) {
2154
- return IsFunction$1(schema) ? Tuple(schema.parameters, options) : Never();
2155
- }
2156
- let Ordinal = 0;
2157
- function Recursive(callback, options = {}) {
2158
- if (IsUndefined$3(options.$id)) options.$id = `T${Ordinal++}`;
2159
- const thisType = CloneType(callback({
2160
- [Kind]: "This",
2161
- $ref: `${options.$id}`
2162
- }));
2163
- thisType.$id = options.$id;
2164
- return CreateType({
2165
- [Hint]: "Recursive",
2166
- ...thisType
2167
- }, options);
2168
- }
2169
- function RegExp$1(unresolved, options) {
2170
- const expr = IsString$2(unresolved) ? new globalThis.RegExp(unresolved) : unresolved;
2171
- return CreateType({
2172
- [Kind]: "RegExp",
2173
- type: "RegExp",
2174
- source: expr.source,
2175
- flags: expr.flags
2176
- }, options);
2177
- }
2178
- function RestResolve(T) {
2179
- return IsIntersect$1(T) ? T.allOf : IsUnion$1(T) ? T.anyOf : IsTuple$1(T) ? T.items ?? [] : [];
2180
- }
2181
- function Rest(T) {
2182
- return RestResolve(T);
2183
- }
2184
- function ReturnType(schema, options) {
2185
- return IsFunction$1(schema) ? CreateType(schema.returns, options) : Never(options);
2186
- }
2187
- var TransformDecodeBuilder = class {
2188
- constructor(schema) {
2189
- this.schema = schema;
2190
- }
2191
- Decode(decode) {
2192
- return new TransformEncodeBuilder(this.schema, decode);
2193
- }
2194
- };
2195
- var TransformEncodeBuilder = class {
2196
- constructor(schema, decode) {
2197
- this.schema = schema;
2198
- this.decode = decode;
2199
- }
2200
- EncodeTransform(encode, schema) {
2201
- const Encode = (value) => schema[TransformKind].Encode(encode(value));
2202
- const Decode = (value) => this.decode(schema[TransformKind].Decode(value));
2203
- const Codec = {
2204
- Encode,
2205
- Decode
2206
- };
2207
- return {
2208
- ...schema,
2209
- [TransformKind]: Codec
2210
- };
2211
- }
2212
- EncodeSchema(encode, schema) {
2213
- const Codec = {
2214
- Decode: this.decode,
2215
- Encode: encode
2216
- };
2217
- return {
2218
- ...schema,
2219
- [TransformKind]: Codec
2220
- };
2221
- }
2222
- Encode(encode) {
2223
- return IsTransform$1(this.schema) ? this.EncodeTransform(encode, this.schema) : this.EncodeSchema(encode, this.schema);
2224
- }
2225
- };
2226
- function Transform(schema) {
2227
- return new TransformDecodeBuilder(schema);
2228
- }
2229
- function Unsafe(options = {}) {
2230
- return CreateType({ [Kind]: options[Kind] ?? "Unsafe" }, options);
2231
- }
2232
- function Void(options) {
2233
- return CreateType({
2234
- [Kind]: "Void",
2235
- type: "void"
2236
- }, options);
2237
- }
2238
- const Type = /* @__PURE__ */ __exportAll({
2239
- Any: () => Any,
2240
- Argument: () => Argument,
2241
- Array: () => Array$1,
2242
- AsyncIterator: () => AsyncIterator,
2243
- Awaited: () => Awaited,
2244
- BigInt: () => BigInt,
2245
- Boolean: () => Boolean,
2246
- Capitalize: () => Capitalize,
2247
- Composite: () => Composite,
2248
- Const: () => Const,
2249
- Constructor: () => Constructor,
2250
- ConstructorParameters: () => ConstructorParameters,
2251
- Date: () => Date$1,
2252
- Enum: () => Enum,
2253
- Exclude: () => Exclude,
2254
- Extends: () => Extends,
2255
- Extract: () => Extract,
2256
- Function: () => Function,
2257
- Index: () => Index,
2258
- InstanceType: () => InstanceType,
2259
- Instantiate: () => Instantiate,
2260
- Integer: () => Integer,
2261
- Intersect: () => Intersect,
2262
- Iterator: () => Iterator,
2263
- KeyOf: () => KeyOf,
2264
- Literal: () => Literal,
2265
- Lowercase: () => Lowercase,
2266
- Mapped: () => Mapped,
2267
- Module: () => Module,
2268
- Never: () => Never,
2269
- Not: () => Not,
2270
- Null: () => Null,
2271
- Number: () => Number$1,
2272
- Object: () => Object$1,
2273
- Omit: () => Omit,
2274
- Optional: () => Optional,
2275
- Parameters: () => Parameters,
2276
- Partial: () => Partial,
2277
- Pick: () => Pick,
2278
- Promise: () => Promise$1,
2279
- Readonly: () => Readonly,
2280
- ReadonlyOptional: () => ReadonlyOptional,
2281
- Record: () => Record,
2282
- Recursive: () => Recursive,
2283
- Ref: () => Ref,
2284
- RegExp: () => RegExp$1,
2285
- Required: () => Required,
2286
- Rest: () => Rest,
2287
- ReturnType: () => ReturnType,
2288
- String: () => String,
2289
- Symbol: () => Symbol$1,
2290
- TemplateLiteral: () => TemplateLiteral,
2291
- Transform: () => Transform,
2292
- Tuple: () => Tuple,
2293
- Uint8Array: () => Uint8Array$1,
2294
- Uncapitalize: () => Uncapitalize,
2295
- Undefined: () => Undefined,
2296
- Union: () => Union,
2297
- Unknown: () => Unknown,
2298
- Unsafe: () => Unsafe,
2299
- Uppercase: () => Uppercase,
2300
- Void: () => Void
2301
- });
2302
- export { Type as t };
2303
-
2304
- //# sourceMappingURL=typebox.mjs.map