@fncts/schema 0.0.4 → 0.0.6

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 (151) hide show
  1. package/AST.d.ts +528 -0
  2. package/ASTAnnotation.d.ts +82 -0
  3. package/ASTAnnotationMap.d.ts +14 -0
  4. package/Gen.d.ts +15 -0
  5. package/InvalidInterpretationError.d.ts +5 -0
  6. package/ParseError.d.ts +107 -0
  7. package/ParseResult.d.ts +24 -0
  8. package/Parser/api.d.ts +42 -0
  9. package/Parser/definition.d.ts +22 -0
  10. package/Parser/interpreter.d.ts +6 -0
  11. package/Parser.d.ts +2 -0
  12. package/Schema/api/conc.d.ts +18 -0
  13. package/Schema/api/hashMap.d.ts +21 -0
  14. package/Schema/api/immutableArray.d.ts +23 -0
  15. package/Schema/api/list.d.ts +23 -0
  16. package/Schema/api/maybe.d.ts +21 -0
  17. package/Schema/api.d.ts +243 -0
  18. package/Schema/definition.d.ts +29 -0
  19. package/Schema/derivations.d.ts +70 -0
  20. package/Schema.d.ts +2 -144
  21. package/_cjs/AST.cjs +1171 -0
  22. package/_cjs/AST.cjs.map +1 -0
  23. package/_cjs/ASTAnnotation.cjs +111 -0
  24. package/_cjs/ASTAnnotation.cjs.map +1 -0
  25. package/_cjs/ASTAnnotationMap.cjs +35 -0
  26. package/_cjs/ASTAnnotationMap.cjs.map +1 -0
  27. package/_cjs/Gen.cjs +185 -0
  28. package/_cjs/Gen.cjs.map +1 -0
  29. package/_cjs/InvalidInterpretationError.cjs +18 -0
  30. package/_cjs/InvalidInterpretationError.cjs.map +1 -0
  31. package/_cjs/ParseError.cjs +222 -0
  32. package/_cjs/ParseError.cjs.map +1 -0
  33. package/_cjs/{Decoder.cjs → ParseResult.cjs} +24 -22
  34. package/_cjs/ParseResult.cjs.map +1 -0
  35. package/_cjs/Parser/api.cjs +80 -0
  36. package/_cjs/Parser/api.cjs.map +1 -0
  37. package/_cjs/{Guard.cjs → Parser/definition.cjs} +17 -22
  38. package/_cjs/Parser/definition.cjs.map +1 -0
  39. package/_cjs/Parser/interpreter.cjs +409 -0
  40. package/_cjs/Parser/interpreter.cjs.map +1 -0
  41. package/_cjs/Parser.cjs +28 -0
  42. package/_cjs/Parser.cjs.map +1 -0
  43. package/_cjs/Schema/api/conc.cjs +84 -0
  44. package/_cjs/Schema/api/conc.cjs.map +1 -0
  45. package/_cjs/Schema/api/hashMap.cjs +161 -0
  46. package/_cjs/Schema/api/hashMap.cjs.map +1 -0
  47. package/_cjs/Schema/api/immutableArray.cjs +90 -0
  48. package/_cjs/Schema/api/immutableArray.cjs.map +1 -0
  49. package/_cjs/Schema/api/list.cjs +98 -0
  50. package/_cjs/Schema/api/list.cjs.map +1 -0
  51. package/_cjs/Schema/api/maybe.cjs +75 -0
  52. package/_cjs/Schema/api/maybe.cjs.map +1 -0
  53. package/_cjs/Schema/api.cjs +424 -0
  54. package/_cjs/Schema/api.cjs.map +1 -0
  55. package/_cjs/Schema/definition.cjs +26 -0
  56. package/_cjs/Schema/definition.cjs.map +1 -0
  57. package/_cjs/Schema/derivations.cjs +108 -0
  58. package/_cjs/Schema/derivations.cjs.map +1 -0
  59. package/_cjs/Schema.cjs +20 -237
  60. package/_cjs/Schema.cjs.map +1 -1
  61. package/_cjs/utils.cjs +52 -0
  62. package/_cjs/utils.cjs.map +1 -0
  63. package/_mjs/AST.mjs +1060 -0
  64. package/_mjs/AST.mjs.map +1 -0
  65. package/_mjs/ASTAnnotation.mjs +80 -0
  66. package/_mjs/ASTAnnotation.mjs.map +1 -0
  67. package/_mjs/ASTAnnotationMap.mjs +27 -0
  68. package/_mjs/ASTAnnotationMap.mjs.map +1 -0
  69. package/_mjs/Gen.mjs +176 -0
  70. package/_mjs/Gen.mjs.map +1 -0
  71. package/_mjs/InvalidInterpretationError.mjs +10 -0
  72. package/_mjs/InvalidInterpretationError.mjs.map +1 -0
  73. package/_mjs/ParseError.mjs +200 -0
  74. package/_mjs/ParseError.mjs.map +1 -0
  75. package/_mjs/ParseResult.mjs +21 -0
  76. package/_mjs/ParseResult.mjs.map +1 -0
  77. package/_mjs/Parser/api.mjs +67 -0
  78. package/_mjs/Parser/api.mjs.map +1 -0
  79. package/_mjs/Parser/definition.mjs +15 -0
  80. package/_mjs/Parser/definition.mjs.map +1 -0
  81. package/_mjs/Parser/interpreter.mjs +401 -0
  82. package/_mjs/Parser/interpreter.mjs.map +1 -0
  83. package/_mjs/Parser.mjs +4 -0
  84. package/_mjs/Parser.mjs.map +1 -0
  85. package/_mjs/Schema/api/conc.mjs +72 -0
  86. package/_mjs/Schema/api/conc.mjs.map +1 -0
  87. package/_mjs/Schema/api/hashMap.mjs +150 -0
  88. package/_mjs/Schema/api/hashMap.mjs.map +1 -0
  89. package/_mjs/Schema/api/immutableArray.mjs +79 -0
  90. package/_mjs/Schema/api/immutableArray.mjs.map +1 -0
  91. package/_mjs/Schema/api/list.mjs +87 -0
  92. package/_mjs/Schema/api/list.mjs.map +1 -0
  93. package/_mjs/Schema/api/maybe.mjs +64 -0
  94. package/_mjs/Schema/api/maybe.mjs.map +1 -0
  95. package/_mjs/Schema/api.mjs +367 -0
  96. package/_mjs/Schema/api.mjs.map +1 -0
  97. package/_mjs/Schema/definition.mjs +16 -0
  98. package/_mjs/Schema/definition.mjs.map +1 -0
  99. package/_mjs/Schema/derivations.mjs +94 -0
  100. package/_mjs/Schema/derivations.mjs.map +1 -0
  101. package/_mjs/Schema.mjs +3 -212
  102. package/_mjs/Schema.mjs.map +1 -1
  103. package/_mjs/utils.mjs +41 -0
  104. package/_mjs/utils.mjs.map +1 -0
  105. package/_src/AST.ts +1353 -0
  106. package/_src/ASTAnnotation.ts +98 -0
  107. package/_src/ASTAnnotationMap.ts +38 -0
  108. package/_src/Gen.ts +171 -0
  109. package/_src/InvalidInterpretationError.ts +6 -0
  110. package/_src/ParseError.ts +237 -0
  111. package/_src/ParseResult.ts +26 -0
  112. package/_src/Parser/api.ts +71 -0
  113. package/_src/Parser/definition.ts +24 -0
  114. package/_src/Parser/interpreter.ts +442 -0
  115. package/_src/Parser.ts +4 -0
  116. package/_src/Schema/api/conc.ts +78 -0
  117. package/_src/Schema/api/hashMap.ts +184 -0
  118. package/_src/Schema/api/immutableArray.ts +88 -0
  119. package/_src/Schema/api/list.ts +96 -0
  120. package/_src/Schema/api/maybe.ts +68 -0
  121. package/_src/Schema/api.ts +530 -0
  122. package/_src/Schema/definition.ts +32 -0
  123. package/_src/Schema/derivations.ts +185 -0
  124. package/_src/Schema.ts +4 -254
  125. package/_src/global.ts +53 -0
  126. package/_src/utils.ts +48 -0
  127. package/global.d.ts +52 -0
  128. package/package.json +2 -2
  129. package/utils.d.ts +8 -0
  130. package/Decoder.d.ts +0 -3
  131. package/Encoder.d.ts +0 -4
  132. package/Guard.d.ts +0 -3
  133. package/Schemable.d.ts +0 -39
  134. package/_cjs/Decoder.cjs.map +0 -1
  135. package/_cjs/Encoder.cjs +0 -45
  136. package/_cjs/Encoder.cjs.map +0 -1
  137. package/_cjs/Guard.cjs.map +0 -1
  138. package/_cjs/Schemable.cjs +0 -6
  139. package/_cjs/Schemable.cjs.map +0 -1
  140. package/_mjs/Decoder.mjs +0 -20
  141. package/_mjs/Decoder.mjs.map +0 -1
  142. package/_mjs/Encoder.mjs +0 -36
  143. package/_mjs/Encoder.mjs.map +0 -1
  144. package/_mjs/Guard.mjs +0 -20
  145. package/_mjs/Guard.mjs.map +0 -1
  146. package/_mjs/Schemable.mjs +0 -2
  147. package/_mjs/Schemable.mjs.map +0 -1
  148. package/_src/Decoder.ts +0 -20
  149. package/_src/Encoder.ts +0 -38
  150. package/_src/Guard.ts +0 -20
  151. package/_src/Schemable.ts +0 -46
package/_cjs/AST.cjs ADDED
@@ -0,0 +1,1171 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.anyKeyword = exports.VoidKeyword = exports.Validation = exports.UnknownKeyword = exports.UniqueSymbol = exports.Union = exports.UndefinedKeyword = exports.TypeLiteral = exports.Tuple = exports.Transform = exports.TemplateLiteralSpan = exports.TemplateLiteral = exports.SymbolKeyword = exports.StringKeyword = exports.Refinement = exports.PropertySignature = exports.ObjectKeyword = exports.NumberKeyword = exports.NeverKeyword = exports.Literal = exports.Lazy = exports.IndexSignature = exports.Enum = exports.Element = exports.Declaration = exports.BooleanKeyword = exports.BigIntKeyword = exports.AnyKeyword = exports.Annotated = exports.ASTTypeId = exports.AST = void 0;
7
+ exports.appendElement = appendElement;
8
+ exports.appendRestElement = appendRestElement;
9
+ exports.booleanKeyword = exports.bigIntKeyword = void 0;
10
+ exports.combineAnnotations = combineAnnotations;
11
+ exports.concrete = concrete;
12
+ exports.createElement = exports.createDeclaration = void 0;
13
+ exports.createEnum = createEnum;
14
+ exports.createIndexSignature = void 0;
15
+ exports.createKey = createKey;
16
+ exports.createPropertySignature = exports.createLiteral = exports.createLazy = void 0;
17
+ exports.createRecord = createRecord;
18
+ exports.createUniqueSymbol = exports.createUnion = exports.createTypeLiteral = exports.createTuple = exports.createTransform = exports.createTemplateLiteral = exports.createRefinement = void 0;
19
+ exports.createValidation = createValidation;
20
+ exports.getAnnotations = getAnnotations;
21
+ exports.getCardinality = getCardinality;
22
+ exports.getCompiler = getCompiler;
23
+ exports.getFrom = void 0;
24
+ exports.getParameter = getParameter;
25
+ exports.getTo = exports.getPropertySignatures = void 0;
26
+ exports.getWeight = getWeight;
27
+ exports.isBigIntKeyword = isBigIntKeyword;
28
+ exports.isBooleanKeyword = isBooleanKeyword;
29
+ exports.isDeclaration = isDeclaration;
30
+ exports.isLazy = isLazy;
31
+ exports.isNumberKeyword = exports.isLiteral = void 0;
32
+ exports.isRefinement = isRefinement;
33
+ exports.isSymbolKeyword = exports.isStringKeyword = void 0;
34
+ exports.isTypeLiteral = isTypeLiteral;
35
+ exports.isUnion = isUnion;
36
+ exports.isUniqueSymbol = void 0;
37
+ exports.keyof = keyof;
38
+ exports.objectKeyword = exports.numberKeyword = exports.neverKeyword = exports.keysOf = void 0;
39
+ exports.omit = omit;
40
+ exports.partial = void 0;
41
+ exports.pick = pick;
42
+ exports.reverse = void 0;
43
+ exports.setAnnotation = setAnnotation;
44
+ exports.voidKeyword = exports.unknownKeyword = exports.undefinedKeyword = exports.symbolKeyword = exports.stringKeyword = void 0;
45
+ var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/schema/ASTAnnotation"));
46
+ var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Vector/api"));
47
+ var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/number/instances"));
48
+ var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Ord/api/contramap"));
49
+ var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/definition"));
50
+ var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/constructors"));
51
+ var tsplus_module_7 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/destructors"));
52
+ var tsplus_module_8 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Vector/internal"));
53
+ var tsplus_module_9 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/api"));
54
+ var _Showable = /*#__PURE__*/require("@fncts/base/data/Showable");
55
+ var _utils = /*#__PURE__*/require("@fncts/schema/utils");
56
+ var _ASTAnnotationMap = /*#__PURE__*/require("./ASTAnnotationMap.cjs");
57
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
58
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
59
+ var _a;
60
+ const createDeclaration = createDeclaration_1;
61
+ exports.createDeclaration = createDeclaration;
62
+ const createLiteral = createLiteral_1;
63
+ exports.createLiteral = createLiteral;
64
+ const isLiteral = isLiteral_1;
65
+ exports.isLiteral = isLiteral;
66
+ const createUniqueSymbol = createUniqueSymbol_1;
67
+ exports.createUniqueSymbol = createUniqueSymbol;
68
+ const isUniqueSymbol = isUniqueSymbol_1;
69
+ exports.isUniqueSymbol = isUniqueSymbol;
70
+ const isStringKeyword = isStringKeyword_1;
71
+ exports.isStringKeyword = isStringKeyword;
72
+ const isNumberKeyword = isNumberKeyword_1;
73
+ exports.isNumberKeyword = isNumberKeyword;
74
+ const isSymbolKeyword = isSymbolKeyword_1;
75
+ exports.isSymbolKeyword = isSymbolKeyword;
76
+ const createTemplateLiteral = createTemplateLiteral_1;
77
+ exports.createTemplateLiteral = createTemplateLiteral;
78
+ const createElement = createElement_1;
79
+ exports.createElement = createElement;
80
+ const createTuple = createTuple_1;
81
+ exports.createTuple = createTuple;
82
+ const createPropertySignature = createPropertySignature_1;
83
+ exports.createPropertySignature = createPropertySignature;
84
+ const createIndexSignature = createIndexSignature_1;
85
+ exports.createIndexSignature = createIndexSignature;
86
+ const createTypeLiteral = createTypeLiteral_1;
87
+ exports.createTypeLiteral = createTypeLiteral;
88
+ const createUnion = createUnion_1;
89
+ exports.createUnion = createUnion;
90
+ const createLazy = createLazy_1;
91
+ exports.createLazy = createLazy;
92
+ const createRefinement = createRefinement_1;
93
+ exports.createRefinement = createRefinement;
94
+ const createTransform = createTransform_1;
95
+ exports.createTransform = createTransform;
96
+ const getPropertySignatures = getPropertySignatures_1;
97
+ exports.getPropertySignatures = getPropertySignatures;
98
+ const keysOf = keysOf_1;
99
+ exports.keysOf = keysOf;
100
+ const partial = partial_1;
101
+ exports.partial = partial;
102
+ const getFrom = getFrom_1;
103
+ exports.getFrom = getFrom;
104
+ const getTo = getTo_1;
105
+ exports.getTo = getTo;
106
+ const reverse = reverse_1;
107
+ exports.reverse = reverse;
108
+ const ASTTypeId = /*#__PURE__*/Symbol.for("fncts.schema.AST");
109
+ exports.ASTTypeId = ASTTypeId;
110
+ class Annotated {
111
+ constructor() {
112
+ this.annotations = _ASTAnnotationMap.ASTAnnotationMap.empty;
113
+ }
114
+ }
115
+ /**
116
+ * @tsplus type fncts.schema.AST
117
+ * @tsplus companion fncts.schema.ASTOps
118
+ */
119
+ exports.Annotated = Annotated;
120
+ class AST extends Annotated {
121
+ constructor() {
122
+ super(...arguments);
123
+ this[_a] = ASTTypeId;
124
+ }
125
+ }
126
+ exports.AST = AST;
127
+ _a = ASTTypeId;
128
+ /**
129
+ * @tsplus static fncts.schema.ASTOps concrete
130
+ * @tsplus macro remove
131
+ */
132
+ function concrete(_) {
133
+ //
134
+ }
135
+ function getAnnotations(key) {
136
+ return self => {
137
+ return self.annotations.get(key);
138
+ };
139
+ }
140
+ /*
141
+ * Declaration
142
+ */
143
+ class Declaration extends AST {
144
+ constructor(typeParameters, type, decode, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
145
+ super();
146
+ this.typeParameters = typeParameters;
147
+ this.type = type;
148
+ this.decode = decode;
149
+ this.annotations = annotations;
150
+ this._tag = 0 /* ASTTag.Declaration */;
151
+ }
152
+
153
+ clone(newProperties) {
154
+ return new Declaration(newProperties.typeParameters ?? this.typeParameters, newProperties.type ?? this.type, newProperties.decode ?? this.decode, newProperties.annotations ?? this.annotations);
155
+ }
156
+ }
157
+ /**
158
+ * @tsplus static fncts.schema.ASTOps createDeclaration
159
+ */
160
+ exports.Declaration = Declaration;
161
+ function createDeclaration_1(typeParameters, type, decode, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
162
+ return new Declaration(typeParameters, type, decode, annotations);
163
+ }
164
+ /**
165
+ * @tsplus fluent fncts.schema.AST isDeclaration
166
+ */
167
+ function isDeclaration(self) {
168
+ void 0;
169
+ return self._tag === 0 /* ASTTag.Declaration */;
170
+ }
171
+
172
+ class Literal extends AST {
173
+ constructor(literal, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
174
+ super();
175
+ this.literal = literal;
176
+ this.annotations = annotations;
177
+ this._tag = 1 /* ASTTag.Literal */;
178
+ }
179
+
180
+ clone(newProperties) {
181
+ return new Literal(newProperties.literal ?? this.literal, newProperties.annotations ?? this.annotations);
182
+ }
183
+ }
184
+ /**
185
+ * @tsplus static fncts.schema.ASTOps createLiteral
186
+ */
187
+ exports.Literal = Literal;
188
+ function createLiteral_1(literal, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
189
+ return new Literal(literal, annotations);
190
+ }
191
+ /**
192
+ * @tsplus fluent fncts.schema.AST isLiteral
193
+ */
194
+ function isLiteral_1(self) {
195
+ void 0;
196
+ return self._tag === 1 /* ASTTag.Literal */;
197
+ }
198
+ /*
199
+ * UniqueSymbol
200
+ */
201
+ class UniqueSymbol extends AST {
202
+ constructor(symbol, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
203
+ super();
204
+ this.symbol = symbol;
205
+ this.annotations = annotations;
206
+ this._tag = 2 /* ASTTag.UniqueSymbol */;
207
+ }
208
+
209
+ clone(newProperties) {
210
+ return new UniqueSymbol(newProperties.symbol ?? this.symbol, newProperties.annotations ?? this.annotations);
211
+ }
212
+ }
213
+ /**
214
+ * @tsplus static fncts.schema.ASTOps createUniqueSymbol
215
+ */
216
+ exports.UniqueSymbol = UniqueSymbol;
217
+ function createUniqueSymbol_1(symbol, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
218
+ return new UniqueSymbol(symbol, annotations);
219
+ }
220
+ /**
221
+ * @tsplus fluent fncts.schema.AST isUniqueSymbol
222
+ */
223
+ function isUniqueSymbol_1(self) {
224
+ void 0;
225
+ return self._tag === 2 /* ASTTag.UniqueSymbol */;
226
+ }
227
+ /*
228
+ * UndefinedKeyword
229
+ */
230
+ class UndefinedKeyword extends AST {
231
+ constructor(annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
232
+ super();
233
+ this.annotations = annotations;
234
+ this._tag = 3 /* ASTTag.UndefinedKeyword */;
235
+ }
236
+
237
+ clone(newProperties) {
238
+ return new UndefinedKeyword(newProperties.annotations ?? this.annotations);
239
+ }
240
+ }
241
+ /**
242
+ * @tsplus static fncts.schema.ASTOps undefinedKeyword
243
+ */
244
+ exports.UndefinedKeyword = UndefinedKeyword;
245
+ const undefinedKeyword_1 = /*#__PURE__*/new UndefinedKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "undefined"));
246
+ const undefinedKeyword = undefinedKeyword_1;
247
+ /*
248
+ * VoidKeyword
249
+ */
250
+ exports.undefinedKeyword = undefinedKeyword;
251
+ class VoidKeyword extends AST {
252
+ constructor(annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
253
+ super();
254
+ this.annotations = annotations;
255
+ this._tag = 4 /* ASTTag.VoidKeyword */;
256
+ }
257
+
258
+ clone(newProperties) {
259
+ return new VoidKeyword(newProperties.annotations ?? this.annotations);
260
+ }
261
+ }
262
+ /**
263
+ * @tsplus static fncts.schema.ASTOps voidKeyword
264
+ */
265
+ exports.VoidKeyword = VoidKeyword;
266
+ const voidKeyword = /*#__PURE__*/new VoidKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "void"));
267
+ /*
268
+ * NeverKeyword
269
+ */
270
+ exports.voidKeyword = voidKeyword;
271
+ class NeverKeyword extends AST {
272
+ constructor(annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
273
+ super();
274
+ this.annotations = annotations;
275
+ this._tag = 5 /* ASTTag.NeverKeyword */;
276
+ }
277
+
278
+ clone(newProperties) {
279
+ return new NeverKeyword(newProperties.annotations ?? this.annotations);
280
+ }
281
+ }
282
+ /**
283
+ * @tsplus static fncts.schema.ASTOps neverKeyword
284
+ */
285
+ exports.NeverKeyword = NeverKeyword;
286
+ const neverKeyword_1 = /*#__PURE__*/new NeverKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "never"));
287
+ const neverKeyword = neverKeyword_1;
288
+ /*
289
+ * UnknownKeyword
290
+ */
291
+ exports.neverKeyword = neverKeyword;
292
+ class UnknownKeyword extends AST {
293
+ constructor(annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
294
+ super();
295
+ this.annotations = annotations;
296
+ this._tag = 6 /* ASTTag.UnknownKeyword */;
297
+ }
298
+
299
+ clone(newProperties) {
300
+ return new UnknownKeyword(newProperties.annotations ?? this.annotations);
301
+ }
302
+ }
303
+ /**
304
+ * @tsplus static fncts.schema.ASTOps unknownKeyword
305
+ */
306
+ exports.UnknownKeyword = UnknownKeyword;
307
+ const unknownKeyword = /*#__PURE__*/new UnknownKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "unknown"));
308
+ /*
309
+ * AnyKeyword
310
+ */
311
+ exports.unknownKeyword = unknownKeyword;
312
+ class AnyKeyword extends AST {
313
+ constructor(annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
314
+ super();
315
+ this.annotations = annotations;
316
+ this._tag = 7 /* ASTTag.AnyKeyword */;
317
+ }
318
+
319
+ clone(newProperties) {
320
+ return new AnyKeyword(newProperties.annotations ?? this.annotations);
321
+ }
322
+ }
323
+ /**
324
+ * @tsplus static fncts.schema.ASTOps anyKeyword
325
+ */
326
+ exports.AnyKeyword = AnyKeyword;
327
+ const anyKeyword = /*#__PURE__*/new AnyKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "any"));
328
+ /*
329
+ * StringKeyword
330
+ */
331
+ exports.anyKeyword = anyKeyword;
332
+ class StringKeyword extends AST {
333
+ constructor(annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
334
+ super();
335
+ this.annotations = annotations;
336
+ this._tag = 8 /* ASTTag.StringKeyword */;
337
+ }
338
+
339
+ clone(newProperties) {
340
+ return new StringKeyword(newProperties.annotations ?? this.annotations);
341
+ }
342
+ }
343
+ /**
344
+ * @tsplus static fncts.schema.ASTOps stringKeyword
345
+ */
346
+ exports.StringKeyword = StringKeyword;
347
+ const stringKeyword_1 = /*#__PURE__*/new StringKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "string"));
348
+ const stringKeyword = stringKeyword_1;
349
+ /**
350
+ * @tsplus fluent fncts.schema.AST isStringKeyword
351
+ */
352
+ exports.stringKeyword = stringKeyword;
353
+ function isStringKeyword_1(self) {
354
+ void 0;
355
+ return self._tag === 8 /* ASTTag.StringKeyword */;
356
+ }
357
+ /*
358
+ * NumberKeyword
359
+ */
360
+ class NumberKeyword extends AST {
361
+ constructor(annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
362
+ super();
363
+ this.annotations = annotations;
364
+ this._tag = 9 /* ASTTag.NumberKeyword */;
365
+ }
366
+
367
+ clone(newProperties) {
368
+ return new NumberKeyword(newProperties.annotations ?? this.annotations);
369
+ }
370
+ }
371
+ /**
372
+ * @tsplus static fncts.schema.ASTOps numberKeyword
373
+ */
374
+ exports.NumberKeyword = NumberKeyword;
375
+ const numberKeyword_1 = /*#__PURE__*/new NumberKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "number"));
376
+ const numberKeyword = numberKeyword_1;
377
+ /**
378
+ * @tsplus fluent fncts.schema.AST isNumberKeyword
379
+ */
380
+ exports.numberKeyword = numberKeyword;
381
+ function isNumberKeyword_1(self) {
382
+ void 0;
383
+ return self._tag === 9 /* ASTTag.NumberKeyword */;
384
+ }
385
+ /*
386
+ * BooleanKeyword
387
+ */
388
+ class BooleanKeyword extends AST {
389
+ constructor(annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
390
+ super();
391
+ this.annotations = annotations;
392
+ this._tag = 10 /* ASTTag.BooleanKeyword */;
393
+ }
394
+
395
+ clone(newProperties) {
396
+ return new BooleanKeyword(newProperties.annotations ?? this.annotations);
397
+ }
398
+ }
399
+ /**
400
+ * @tsplus static fncts.schema.ASTOps booleanKeyword
401
+ */
402
+ exports.BooleanKeyword = BooleanKeyword;
403
+ const booleanKeyword = /*#__PURE__*/new BooleanKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "boolean"));
404
+ /**
405
+ * @tsplus fluent fncts.schema.AST isBooleanKeyword
406
+ */
407
+ exports.booleanKeyword = booleanKeyword;
408
+ function isBooleanKeyword(self) {
409
+ void 0;
410
+ return self._tag === 10 /* ASTTag.BooleanKeyword */;
411
+ }
412
+ /*
413
+ * BigIntKeyword
414
+ */
415
+ class BigIntKeyword extends AST {
416
+ constructor(annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
417
+ super();
418
+ this.annotations = annotations;
419
+ this._tag = 11 /* ASTTag.BigIntKeyword */;
420
+ }
421
+
422
+ clone(newProperties) {
423
+ return new BigIntKeyword(newProperties.annotations ?? this.annotations);
424
+ }
425
+ }
426
+ /**
427
+ * @tsplus static fncts.schema.ASTOps bigIntKeyword
428
+ */
429
+ exports.BigIntKeyword = BigIntKeyword;
430
+ const bigIntKeyword = /*#__PURE__*/new BigIntKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "bigint"));
431
+ /**
432
+ * @tsplus fluent fncts.schema.AST isBigIntKeyword
433
+ */
434
+ exports.bigIntKeyword = bigIntKeyword;
435
+ function isBigIntKeyword(self) {
436
+ void 0;
437
+ return self._tag === 11 /* ASTTag.BigIntKeyword */;
438
+ }
439
+ /*
440
+ * SymbolKeyword
441
+ */
442
+ class SymbolKeyword extends AST {
443
+ constructor(annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
444
+ super();
445
+ this.annotations = annotations;
446
+ this._tag = 12 /* ASTTag.SymbolKeyword */;
447
+ }
448
+
449
+ clone(newProperties) {
450
+ return new SymbolKeyword(newProperties.annotations ?? this.annotations);
451
+ }
452
+ }
453
+ /**
454
+ * @tsplus static fncts.schema.ASTOps symbolKeyword
455
+ */
456
+ exports.SymbolKeyword = SymbolKeyword;
457
+ const symbolKeyword_1 = /*#__PURE__*/new SymbolKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "symbol"));
458
+ const symbolKeyword = symbolKeyword_1;
459
+ /**
460
+ * @tsplus fluent fncts.schema.AST isSymbolKeyword
461
+ */
462
+ exports.symbolKeyword = symbolKeyword;
463
+ function isSymbolKeyword_1(self) {
464
+ void 0;
465
+ return self._tag === 12 /* ASTTag.SymbolKeyword */;
466
+ }
467
+ /*
468
+ * ObjectKeyword
469
+ */
470
+ class ObjectKeyword extends AST {
471
+ constructor(annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
472
+ super();
473
+ this.annotations = annotations;
474
+ this._tag = 13 /* ASTTag.ObjectKeyword */;
475
+ }
476
+
477
+ clone(newProperties) {
478
+ return new ObjectKeyword(newProperties.annotations ?? this.annotations);
479
+ }
480
+ }
481
+ /**
482
+ * @tsplus static fncts.schema.ASTOps objectKeyword
483
+ */
484
+ exports.ObjectKeyword = ObjectKeyword;
485
+ const objectKeyword = /*#__PURE__*/new ObjectKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "object"));
486
+ /*
487
+ * Enum
488
+ */
489
+ exports.objectKeyword = objectKeyword;
490
+ class Enum extends AST {
491
+ constructor(enums, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
492
+ super();
493
+ this.enums = enums;
494
+ this.annotations = annotations;
495
+ this._tag = 14 /* ASTTag.Enum */;
496
+ }
497
+
498
+ clone(newProperties) {
499
+ return new Enum(newProperties.enums ?? this.enums, newProperties.annotations ?? this.annotations);
500
+ }
501
+ }
502
+ /**
503
+ * @tsplus static fncts.schema.ASTOps createEnum
504
+ */
505
+ exports.Enum = Enum;
506
+ function createEnum(enums, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
507
+ return new Enum(enums, annotations);
508
+ }
509
+ class TemplateLiteralSpan {
510
+ constructor(type, literal) {
511
+ this.type = type;
512
+ this.literal = literal;
513
+ }
514
+ }
515
+ /*
516
+ * TemplateLiteral
517
+ */
518
+ exports.TemplateLiteralSpan = TemplateLiteralSpan;
519
+ class TemplateLiteral extends AST {
520
+ constructor(head, spans, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
521
+ super();
522
+ this.head = head;
523
+ this.spans = spans;
524
+ this.annotations = annotations;
525
+ this._tag = 15 /* ASTTag.TemplateLiteral */;
526
+ }
527
+
528
+ clone(newProperties) {
529
+ return createTemplateLiteral_1(newProperties.head ?? this.head, newProperties.spans ?? this.spans, newProperties.annotations ?? this.annotations);
530
+ }
531
+ }
532
+ /**
533
+ * @tsplus static fncts.schema.ASTOps createTemplateLiteral
534
+ */
535
+ exports.TemplateLiteral = TemplateLiteral;
536
+ function createTemplateLiteral_1(head, spans, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
537
+ if (tsplus_module_2.isNonEmpty(spans)) {
538
+ return new TemplateLiteral(head, spans, annotations);
539
+ } else {
540
+ return createLiteral_1(head, annotations);
541
+ }
542
+ }
543
+ /*
544
+ * Element
545
+ */
546
+ class Element {
547
+ constructor(type, isOptional) {
548
+ this.type = type;
549
+ this.isOptional = isOptional;
550
+ }
551
+ }
552
+ /**
553
+ * @tsplus static fncts.schema.ASTOps createElement
554
+ */
555
+ exports.Element = Element;
556
+ function createElement_1(type, isOptional) {
557
+ return new Element(type, isOptional);
558
+ }
559
+ /*
560
+ * Tuple
561
+ */
562
+ class Tuple extends AST {
563
+ constructor(elements, rest, isReadonly, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
564
+ super();
565
+ this.elements = elements;
566
+ this.rest = rest;
567
+ this.isReadonly = isReadonly;
568
+ this.annotations = annotations;
569
+ this._tag = 16 /* ASTTag.Tuple */;
570
+ }
571
+
572
+ clone(newProperties) {
573
+ return new Tuple(newProperties.elements ?? this.elements, newProperties.rest ?? this.rest, newProperties.isReadonly ?? this.isReadonly, newProperties.annotations ?? this.annotations);
574
+ }
575
+ }
576
+ /**
577
+ * @tsplus static fncts.schema.ASTOps createTuple
578
+ */
579
+ exports.Tuple = Tuple;
580
+ function createTuple_1(elements, rest, isReadonly, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
581
+ return new Tuple(elements, rest, isReadonly, annotations);
582
+ }
583
+ /*
584
+ * PropertySignature
585
+ */
586
+ class PropertySignature extends AST {
587
+ constructor(name, type, isOptional, isReadonly, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
588
+ super();
589
+ this.name = name;
590
+ this.type = type;
591
+ this.isOptional = isOptional;
592
+ this.isReadonly = isReadonly;
593
+ this.annotations = annotations;
594
+ }
595
+ clone(newProperties) {
596
+ return new PropertySignature(newProperties.name ?? this.name, newProperties.type ?? this.type, newProperties.isOptional ?? this.isOptional, newProperties.isReadonly ?? this.isReadonly, newProperties.annotations ?? this.annotations);
597
+ }
598
+ }
599
+ /**
600
+ * @tsplus static fncts.schema.ASTOps createPropertySignature
601
+ */
602
+ exports.PropertySignature = PropertySignature;
603
+ function createPropertySignature_1(name, type, isOptional, isReadonly, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
604
+ return new PropertySignature(name, type, isOptional, isReadonly, annotations);
605
+ }
606
+ /*
607
+ * IndexSignature
608
+ */
609
+ class IndexSignature {
610
+ constructor(parameter, type, isReadonly) {
611
+ this.parameter = parameter;
612
+ this.type = type;
613
+ this.isReadonly = isReadonly;
614
+ }
615
+ }
616
+ /**
617
+ * @tsplus static fncts.schema.ASTOps createIndexSignature
618
+ */
619
+ exports.IndexSignature = IndexSignature;
620
+ function createIndexSignature_1(parameter, type, isReadonly) {
621
+ return new IndexSignature(parameter, type, isReadonly);
622
+ }
623
+ /*
624
+ * TypeLiteral
625
+ */
626
+ class TypeLiteral extends AST {
627
+ constructor(propertySignatures, indexSignatures, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
628
+ super();
629
+ this.annotations = annotations;
630
+ this._tag = 17 /* ASTTag.TypeLiteral */;
631
+ this.propertySignatures = sortByAscendingCardinality(propertySignatures);
632
+ this.indexSignatures = sortByAscendingCardinality(indexSignatures);
633
+ }
634
+ clone(newProperties) {
635
+ return new TypeLiteral(newProperties.propertySignatures ?? this.propertySignatures, newProperties.indexSignatures ?? this.indexSignatures, newProperties.annotations ?? this.annotations);
636
+ }
637
+ }
638
+ /**
639
+ * @tsplus static fncts.schema.ASTOps isTypeLiteral
640
+ * @tsplus fluent fncts.schema.AST isTypeLiteral
641
+ */
642
+ exports.TypeLiteral = TypeLiteral;
643
+ function isTypeLiteral(self) {
644
+ void 0;
645
+ return self._tag === 17 /* ASTTag.TypeLiteral */;
646
+ }
647
+ /**
648
+ * @tsplus static fncts.schema.ASTOps createTypeLiteral
649
+ */
650
+ function createTypeLiteral_1(propertySignatures, indexSignatures, annotations) {
651
+ return new TypeLiteral(propertySignatures, indexSignatures, annotations);
652
+ }
653
+ /*
654
+ * Union
655
+ */
656
+ class Union extends AST {
657
+ constructor(types, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
658
+ super();
659
+ this.types = types;
660
+ this.annotations = annotations;
661
+ this._tag = 18 /* ASTTag.Union */;
662
+ }
663
+
664
+ clone(newProperties) {
665
+ return createUnion_1(newProperties.types ?? this.types, newProperties.annotations ?? this.annotations);
666
+ }
667
+ }
668
+ /**
669
+ * @tsplus fluent fncts.schema.AST isUnion
670
+ */
671
+ exports.Union = Union;
672
+ function isUnion(self) {
673
+ void 0;
674
+ return self._tag === 18 /* ASTTag.Union */;
675
+ }
676
+ /**
677
+ * @tsplus static fncts.schema.ASTOps createUnion
678
+ */
679
+ function createUnion_1(candidates, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
680
+ const types = unify(candidates);
681
+ switch (types.length) {
682
+ case 0:
683
+ return neverKeyword_1;
684
+ case 1:
685
+ return tsplus_module_2.unsafeGet(0)(types);
686
+ default:
687
+ return new Union(sortByDescendingWeight(types), annotations);
688
+ }
689
+ }
690
+ /*
691
+ * Lazy
692
+ */
693
+ class Lazy extends AST {
694
+ constructor(getAST, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
695
+ super();
696
+ this.getAST = getAST;
697
+ this.annotations = annotations;
698
+ this._tag = 19 /* ASTTag.Lazy */;
699
+ }
700
+
701
+ clone(newProperties) {
702
+ return new Lazy(newProperties.getAST ?? this.getAST, newProperties.annotations ?? this.annotations);
703
+ }
704
+ }
705
+ /**
706
+ * @tsplus static fncts.schema.ASTOps createLazy
707
+ */
708
+ exports.Lazy = Lazy;
709
+ function createLazy_1(getAST, annotations) {
710
+ return new Lazy(getAST, annotations);
711
+ }
712
+ /**
713
+ * @tsplus fluent fncts.schema.AST isLazy
714
+ */
715
+ function isLazy(self) {
716
+ void 0;
717
+ return self._tag === 19 /* ASTTag.Lazy */;
718
+ }
719
+ /*
720
+ * Refinement
721
+ */
722
+ class Refinement extends AST {
723
+ constructor(from, decode, isReversed, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
724
+ super();
725
+ this.from = from;
726
+ this.decode = decode;
727
+ this.isReversed = isReversed;
728
+ this.annotations = annotations;
729
+ this._tag = 20 /* ASTTag.Refinement */;
730
+ }
731
+
732
+ clone(newProperties) {
733
+ return new Refinement(newProperties.from ?? this.from, newProperties.decode ?? this.decode, newProperties.isReversed ?? this.isReversed, newProperties.annotations ?? this.annotations);
734
+ }
735
+ }
736
+ /**
737
+ * @tsplus static fncts.schema.ASTOps createRefinement
738
+ */
739
+ exports.Refinement = Refinement;
740
+ function createRefinement_1(from, decode, isReversed, annotations) {
741
+ return new Refinement(from, decode, isReversed, annotations);
742
+ }
743
+ function isRefinement(self) {
744
+ void 0;
745
+ return self._tag === 20 /* ASTTag.Refinement */;
746
+ }
747
+ /*
748
+ * Transform
749
+ */
750
+ class Transform extends AST {
751
+ constructor(from, to, decode, encode, isReversed, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
752
+ super();
753
+ this.from = from;
754
+ this.to = to;
755
+ this.decode = decode;
756
+ this.encode = encode;
757
+ this.isReversed = isReversed;
758
+ this.annotations = annotations;
759
+ this._tag = 21 /* ASTTag.Transform */;
760
+ }
761
+
762
+ clone(newProperties) {
763
+ return new Transform(newProperties.from ?? this.from, newProperties.to ?? this.to, newProperties.decode ?? this.decode, newProperties.encode ?? this.encode, newProperties.isReversed ?? this.isReversed, newProperties.annotations ?? this.annotations);
764
+ }
765
+ }
766
+ /**
767
+ * @tsplus static fncts.schema.ASTOps createTransform
768
+ */
769
+ exports.Transform = Transform;
770
+ function createTransform_1(from, to, decode, encode, isReversed, annotations) {
771
+ return new Transform(from, getTo_1(to), decode, encode, isReversed, annotations);
772
+ }
773
+ /*
774
+ * Validation
775
+ */
776
+ class Validation extends AST {
777
+ constructor(from, validation, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
778
+ super();
779
+ this.from = from;
780
+ this.validation = validation;
781
+ this.annotations = annotations;
782
+ this._tag = 22 /* ASTTag.Validation */;
783
+ }
784
+
785
+ clone(newProperties) {
786
+ return new Validation(newProperties.from ?? this.from, newProperties.validation ?? this.validation, newProperties.annotations ?? this.annotations);
787
+ }
788
+ }
789
+ /**
790
+ * @tsplus static fncts.schema.ASTOps createValidation
791
+ */
792
+ exports.Validation = Validation;
793
+ function createValidation(from, validation, annotations) {
794
+ return new Validation(from, validation, annotations);
795
+ }
796
+ /**
797
+ * @tsplus tailRec
798
+ */
799
+ function getCardinality(ast) {
800
+ var ast_1 = ast;
801
+ var ast_2 = ast;
802
+ while (1) {
803
+ void 0;
804
+ switch (ast_1._tag) {
805
+ case 0 /* ASTTag.Declaration */:
806
+ ast_2 = ast_1.type;
807
+ ast_1 = ast_2;
808
+ continue;
809
+ case 5 /* ASTTag.NeverKeyword */:
810
+ return 0;
811
+ case 1 /* ASTTag.Literal */:
812
+ case 3 /* ASTTag.UndefinedKeyword */:
813
+ case 4 /* ASTTag.VoidKeyword */:
814
+ case 2 /* ASTTag.UniqueSymbol */:
815
+ return 1;
816
+ case 10 /* ASTTag.BooleanKeyword */:
817
+ return 2;
818
+ case 8 /* ASTTag.StringKeyword */:
819
+ case 9 /* ASTTag.NumberKeyword */:
820
+ case 11 /* ASTTag.BigIntKeyword */:
821
+ case 12 /* ASTTag.SymbolKeyword */:
822
+ return 3;
823
+ case 13 /* ASTTag.ObjectKeyword */:
824
+ return 4;
825
+ case 6 /* ASTTag.UnknownKeyword */:
826
+ case 7 /* ASTTag.AnyKeyword */:
827
+ return 6;
828
+ case 20 /* ASTTag.Refinement */:
829
+ ast_2 = ast_1.from;
830
+ ast_1 = ast_2;
831
+ continue;
832
+ case 21 /* ASTTag.Transform */:
833
+ ast_2 = ast_1.to;
834
+ ast_1 = ast_2;
835
+ continue;
836
+ default:
837
+ return 5;
838
+ }
839
+ }
840
+ }
841
+ function sortByAscendingCardinality(types) {
842
+ return tsplus_module_2.sort(tsplus_module_4.contramap(({
843
+ type
844
+ }) => getCardinality(type))(tsplus_module_3.Ord))(types);
845
+ }
846
+ function getWeight(ast) {
847
+ void 0;
848
+ switch (ast._tag) {
849
+ case 0 /* ASTTag.Declaration */:
850
+ return getWeight(ast.type);
851
+ case 16 /* ASTTag.Tuple */:
852
+ return ast.elements.length + (tsplus_module_5.isJust(ast.rest) ? ast.rest.value.length : 0);
853
+ case 17 /* ASTTag.TypeLiteral */:
854
+ return ast.propertySignatures.length + ast.indexSignatures.length;
855
+ case 18 /* ASTTag.Union */:
856
+ return tsplus_module_2.foldLeft(0, (n, member) => n + getWeight(member))(ast.types);
857
+ case 19 /* ASTTag.Lazy */:
858
+ return 10;
859
+ case 20 /* ASTTag.Refinement */:
860
+ return getWeight(ast.from);
861
+ case 21 /* ASTTag.Transform */:
862
+ return getWeight(ast.to);
863
+ default:
864
+ return 0;
865
+ }
866
+ }
867
+ function sortByDescendingWeight(types) {
868
+ return tsplus_module_2.sort(tsplus_module_4.contramap(getWeight)(tsplus_module_3.Ord))(types);
869
+ }
870
+ function unify(candidates) {
871
+ let out = tsplus_module_2.flatMap(ast => {
872
+ void 0;
873
+ switch (ast._tag) {
874
+ case 5 /* ASTTag.NeverKeyword */:
875
+ return tsplus_module_2.empty();
876
+ case 18 /* ASTTag.Union */:
877
+ return ast.types;
878
+ default:
879
+ return tsplus_module_2.vector(ast);
880
+ }
881
+ })(candidates);
882
+ if (tsplus_module_2.some(isStringKeyword_1)(out)) {
883
+ out = tsplus_module_2.filter(m => !(isLiteral_1(m) && typeof m.literal === "string"))(out);
884
+ }
885
+ if (tsplus_module_2.some(isNumberKeyword_1)(out)) {
886
+ out = tsplus_module_2.filter(m => !(isLiteral_1(m) && typeof m.literal === "number"))(out);
887
+ }
888
+ if (tsplus_module_2.some(isSymbolKeyword_1)(out)) {
889
+ out = tsplus_module_2.filter(m => !isUniqueSymbol_1(m))(out);
890
+ }
891
+ return out;
892
+ }
893
+ /**
894
+ * @tsplus pipeable fncts.schema.AST combineAnnotations
895
+ */
896
+ function combineAnnotations(annotations) {
897
+ return self => {
898
+ return self.clone({
899
+ annotations: self.annotations.combine(annotations)
900
+ });
901
+ };
902
+ }
903
+ /**
904
+ * @tsplus pipeable fncts.schema.AST setAnnotation
905
+ */
906
+ function setAnnotation(annotation, value) {
907
+ return self => {
908
+ return self.clone({
909
+ annotations: self.annotations.annotate(annotation, value)
910
+ });
911
+ };
912
+ }
913
+ /**
914
+ * @tsplus pipeable fncts.schema.AST appendRestElement
915
+ */
916
+ function appendRestElement(restElement) {
917
+ return self => {
918
+ if (tsplus_module_5.isJust(self.rest)) {
919
+ throw new Error("A rest element cannot follow another rest element. ts(1265)");
920
+ }
921
+ return createTuple_1(self.elements, tsplus_module_6.just(tsplus_module_2.vector(restElement)), self.isReadonly, self.annotations);
922
+ };
923
+ }
924
+ /**
925
+ * @tsplus pipeable fncts.schema.AST appendElement
926
+ */
927
+ function appendElement(element) {
928
+ return self => {
929
+ if (tsplus_module_2.some(e => e.isOptional)(self.elements) && !element.isOptional) {
930
+ throw new Error("A required element cannot follow an optional element. ts(1257)");
931
+ }
932
+ return tsplus_module_7.match(() => createTuple_1(tsplus_module_2.append(element)(self.elements), tsplus_module_6.nothing(), self.isReadonly, self.annotations), rest => {
933
+ if (element.isOptional) {
934
+ throw new Error("A required element cannot follow an optional element. ts(1257)");
935
+ }
936
+ return createTuple_1(self.elements, tsplus_module_6.just(tsplus_module_2.append(element.type)(rest)), self.isReadonly, self.annotations);
937
+ })(self.rest);
938
+ };
939
+ }
940
+ function getParameter(x) {
941
+ return isRefinement(x) ? getParameter(x.from) : x;
942
+ }
943
+ /**
944
+ * @tsplus getter fncts.schema.AST getPropertySignatures
945
+ */
946
+ function getPropertySignatures_1(self) {
947
+ void 0;
948
+ switch (self._tag) {
949
+ case 0 /* ASTTag.Declaration */:
950
+ return getPropertySignatures_1(self.type);
951
+ case 16 /* ASTTag.Tuple */:
952
+ return tsplus_module_2.mapWithIndex((i, element) => createPropertySignature_1(i, element.type, element.isOptional, self.isReadonly))(self.elements);
953
+ case 18 /* ASTTag.Union */:
954
+ {
955
+ const propertySignatures = tsplus_module_2.map(getPropertySignatures_1)(self.types);
956
+ return tsplus_module_2.filterMap(({
957
+ name
958
+ }) => {
959
+ if (tsplus_module_2.every(ps => tsplus_module_2.some(p => p.name === name)(ps))(propertySignatures)) {
960
+ const members = tsplus_module_2.flatMap(ps => tsplus_module_2.filter(p => p.name === name)(ps))(propertySignatures);
961
+ return tsplus_module_6.just(createPropertySignature_1(name, createUnion_1(tsplus_module_2.map(p => p.type)(members)), tsplus_module_2.some(p => p.isOptional)(members), tsplus_module_2.some(p => p.isReadonly)(members)));
962
+ }
963
+ return tsplus_module_6.nothing();
964
+ })(tsplus_module_2.unsafeGet(0)(propertySignatures));
965
+ }
966
+ case 19 /* ASTTag.Lazy */:
967
+ return getPropertySignatures_1(self.getAST());
968
+ case 20 /* ASTTag.Refinement */:
969
+ return getPropertySignatures_1(self.from);
970
+ case 21 /* ASTTag.Transform */:
971
+ return getPropertySignatures_1(self.to);
972
+ default:
973
+ return tsplus_module_2.empty();
974
+ }
975
+ }
976
+ /**
977
+ * @tsplus getter fncts.schema.AST keysof
978
+ */
979
+ function keysOf_1(ast) {
980
+ void 0;
981
+ switch (ast._tag) {
982
+ case 0 /* ASTTag.Declaration */:
983
+ return keysOf_1(ast.type);
984
+ case 5 /* ASTTag.NeverKeyword */:
985
+ case 7 /* ASTTag.AnyKeyword */:
986
+ return tsplus_module_2.vector(stringKeyword_1, numberKeyword_1, symbolKeyword_1);
987
+ case 8 /* ASTTag.StringKeyword */:
988
+ return tsplus_module_2.vector(createLiteral_1("length"));
989
+ case 17 /* ASTTag.TypeLiteral */:
990
+ return tsplus_module_2.concat(tsplus_module_2.map(is => getParameter(is.parameter))(ast.indexSignatures))(tsplus_module_2.map(p => typeof p.name === "symbol" ? createUniqueSymbol_1(p.name) : createLiteral_1(p.name))(ast.propertySignatures));
991
+ case 18 /* ASTTag.Union */:
992
+ return tsplus_module_2.map(p => typeof p.name === "symbol" ? createUniqueSymbol_1(p.name) : createLiteral_1(p.name))(getPropertySignatures_1(ast));
993
+ case 19 /* ASTTag.Lazy */:
994
+ return keysOf_1(ast.getAST());
995
+ case 20 /* ASTTag.Refinement */:
996
+ return keysOf_1(ast.from);
997
+ case 21 /* ASTTag.Transform */:
998
+ return keysOf_1(ast.to);
999
+ default:
1000
+ return tsplus_module_2.empty();
1001
+ }
1002
+ }
1003
+ /**
1004
+ * @tsplus getter fncts.schema.AST keyof
1005
+ */
1006
+ function keyof(self) {
1007
+ return createUnion_1(keysOf_1(self));
1008
+ }
1009
+ /**
1010
+ * @tsplus static fncts.schema.ASTOps createRecord
1011
+ */
1012
+ function createRecord(key, value, isReadonly) {
1013
+ const propertySignatures = tsplus_module_2.emptyPushable();
1014
+ const indexSignatures = tsplus_module_2.emptyPushable();
1015
+ function go(key) {
1016
+ void 0;
1017
+ switch (key._tag) {
1018
+ case 0 /* ASTTag.Declaration */:
1019
+ go(key.type);
1020
+ break;
1021
+ case 5 /* ASTTag.NeverKeyword */:
1022
+ break;
1023
+ case 8 /* ASTTag.StringKeyword */:
1024
+ case 12 /* ASTTag.SymbolKeyword */:
1025
+ case 15 /* ASTTag.TemplateLiteral */:
1026
+ case 20 /* ASTTag.Refinement */:
1027
+ tsplus_module_8.push(createIndexSignature_1(key, value, isReadonly))(indexSignatures);
1028
+ break;
1029
+ case 1 /* ASTTag.Literal */:
1030
+ if (typeof key.literal === "string" || typeof key.literal === "number") {
1031
+ tsplus_module_8.push(createPropertySignature_1(key.literal, value, false, isReadonly))(propertySignatures);
1032
+ }
1033
+ break;
1034
+ case 2 /* ASTTag.UniqueSymbol */:
1035
+ tsplus_module_8.push(createPropertySignature_1(key.symbol, value, false, isReadonly))(propertySignatures);
1036
+ break;
1037
+ case 18 /* ASTTag.Union */:
1038
+ tsplus_module_2.forEach(go)(key.types);
1039
+ break;
1040
+ default:
1041
+ throw new Error(`createRecord: Unsupported key\n${(0, _Showable.show)(key)}`);
1042
+ }
1043
+ }
1044
+ go(key);
1045
+ return createTypeLiteral_1(propertySignatures, indexSignatures);
1046
+ }
1047
+ /**
1048
+ * @tsplus pipeable fncts.schema.AST pick
1049
+ */
1050
+ function pick(keys) {
1051
+ return self => {
1052
+ return createTypeLiteral_1(tsplus_module_2.filter(ps => tsplus_module_2.includes(ps.name)(keys))(getPropertySignatures_1(self)), tsplus_module_2.empty());
1053
+ };
1054
+ }
1055
+ /**
1056
+ * @tsplus pipeable fncts.schema.AST omit
1057
+ */
1058
+ function omit(keys) {
1059
+ return self => {
1060
+ return createTypeLiteral_1(tsplus_module_2.filter(ps => !tsplus_module_2.includes(ps.name)(keys))(getPropertySignatures_1(self)), tsplus_module_2.empty());
1061
+ };
1062
+ }
1063
+ /**
1064
+ * @tsplus getter fncts.schema.AST partial
1065
+ */
1066
+ function partial_1(self) {
1067
+ void 0;
1068
+ switch (self._tag) {
1069
+ case 0 /* ASTTag.Declaration */:
1070
+ return partial_1(self.type);
1071
+ case 16 /* ASTTag.Tuple */:
1072
+ return createTuple_1(tsplus_module_2.map(e => createElement_1(e.type, true))(self.elements), tsplus_module_9.map(rest => tsplus_module_2.vector(createUnion_1(tsplus_module_2.append(undefinedKeyword_1)(rest))))(self.rest), self.isReadonly);
1073
+ case 17 /* ASTTag.TypeLiteral */:
1074
+ return createTypeLiteral_1(tsplus_module_2.map(f => createPropertySignature_1(f.name, f.type, true, f.isReadonly, f.annotations))(self.propertySignatures), self.indexSignatures);
1075
+ case 18 /* ASTTag.Union */:
1076
+ return createUnion_1(tsplus_module_2.map(partial_1)(self.types));
1077
+ case 19 /* ASTTag.Lazy */:
1078
+ return createLazy_1(() => partial_1(self.getAST()));
1079
+ case 20 /* ASTTag.Refinement */:
1080
+ return partial_1(self.from);
1081
+ case 21 /* ASTTag.Transform */:
1082
+ return partial_1(self.to);
1083
+ default:
1084
+ return self;
1085
+ }
1086
+ }
1087
+ /**
1088
+ * @tsplus static fncts.schema.AST createKey
1089
+ */
1090
+ function createKey(key) {
1091
+ return typeof key === "symbol" ? createUniqueSymbol_1(key) : createLiteral_1(key);
1092
+ }
1093
+ /**
1094
+ * @tsplus getter fncts.schema.AST getFrom
1095
+ */
1096
+ function getFrom_1(ast) {
1097
+ void 0;
1098
+ switch (ast._tag) {
1099
+ case 0 /* ASTTag.Declaration */:
1100
+ return createDeclaration_1(tsplus_module_2.map(getFrom_1)(ast.typeParameters), ast.type, ast.decode, ast.annotations);
1101
+ case 16 /* ASTTag.Tuple */:
1102
+ return createTuple_1(tsplus_module_2.map(element => createElement_1(getFrom_1(element.type), element.isOptional))(ast.elements), tsplus_module_9.map(restElement => tsplus_module_2.map(getFrom_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
1103
+ case 17 /* ASTTag.TypeLiteral */:
1104
+ return createTypeLiteral_1(tsplus_module_2.map(ps => createPropertySignature_1(ps.name, getFrom_1(ps.type), ps.isOptional, ps.isReadonly, ps.annotations))(ast.propertySignatures), tsplus_module_2.map(is => createIndexSignature_1(is.parameter, getFrom_1(is.type), is.isReadonly))(ast.indexSignatures), ast.annotations);
1105
+ case 18 /* ASTTag.Union */:
1106
+ return createUnion_1(tsplus_module_2.map(getFrom_1)(ast.types), ast.annotations);
1107
+ case 19 /* ASTTag.Lazy */:
1108
+ return createLazy_1(() => getFrom_1(ast.getAST()), ast.annotations);
1109
+ case 20 /* ASTTag.Refinement */:
1110
+ case 21 /* ASTTag.Transform */:
1111
+ return getFrom_1(ast.from);
1112
+ }
1113
+ return ast;
1114
+ }
1115
+ /**
1116
+ * @tsplus getter fncts.schema.AST getTo
1117
+ */
1118
+ function getTo_1(ast) {
1119
+ void 0;
1120
+ switch (ast._tag) {
1121
+ case 0 /* ASTTag.Declaration */:
1122
+ return createDeclaration_1(tsplus_module_2.map(getTo_1)(ast.typeParameters), ast.type, ast.decode, ast.annotations);
1123
+ case 16 /* ASTTag.Tuple */:
1124
+ return createTuple_1(tsplus_module_2.map(element => createElement_1(getTo_1(element.type), element.isOptional))(ast.elements), tsplus_module_9.map(restElement => tsplus_module_2.map(getTo_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
1125
+ case 17 /* ASTTag.TypeLiteral */:
1126
+ return createTypeLiteral_1(tsplus_module_2.map(ps => createPropertySignature_1(ps.name, getTo_1(ps.type), ps.isOptional, ps.isReadonly, ps.annotations))(ast.propertySignatures), tsplus_module_2.map(is => createIndexSignature_1(is.parameter, getTo_1(is.type), is.isReadonly))(ast.indexSignatures), ast.annotations);
1127
+ case 18 /* ASTTag.Union */:
1128
+ return createUnion_1(tsplus_module_2.map(getTo_1)(ast.types), ast.annotations);
1129
+ case 19 /* ASTTag.Lazy */:
1130
+ return createLazy_1(() => getTo_1(ast.getAST()), ast.annotations);
1131
+ case 20 /* ASTTag.Refinement */:
1132
+ return createRefinement_1(getTo_1(ast.from), ast.decode, false, ast.annotations);
1133
+ case 21 /* ASTTag.Transform */:
1134
+ return getTo_1(ast.to);
1135
+ }
1136
+ return ast;
1137
+ }
1138
+ /**
1139
+ * @tsplus getter fncts.schema.AST reverse
1140
+ */
1141
+ function reverse_1(ast) {
1142
+ void 0;
1143
+ switch (ast._tag) {
1144
+ case 0 /* ASTTag.Declaration */:
1145
+ return createDeclaration_1(tsplus_module_2.map(reverse_1)(ast.typeParameters), ast.type, ast.decode, ast.annotations);
1146
+ case 16 /* ASTTag.Tuple */:
1147
+ return createTuple_1(tsplus_module_2.map(element => createElement_1(reverse_1(element.type), element.isOptional))(ast.elements), tsplus_module_9.map(restElement => tsplus_module_2.map(reverse_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
1148
+ case 17 /* ASTTag.TypeLiteral */:
1149
+ return createTypeLiteral_1(tsplus_module_2.map(ps => createPropertySignature_1(ps.name, reverse_1(ps.type), ps.isOptional, ps.isReadonly, ps.annotations))(ast.propertySignatures), tsplus_module_2.map(is => createIndexSignature_1(is.parameter, reverse_1(is.type), is.isReadonly))(ast.indexSignatures), ast.annotations);
1150
+ case 18 /* ASTTag.Union */:
1151
+ return createUnion_1(tsplus_module_2.map(reverse_1)(ast.types), ast.annotations);
1152
+ case 19 /* ASTTag.Lazy */:
1153
+ return createLazy_1(() => reverse_1(ast.getAST()), ast.annotations);
1154
+ case 20 /* ASTTag.Refinement */:
1155
+ return createRefinement_1(ast.from, ast.decode, !ast.isReversed, ast.annotations);
1156
+ case 21 /* ASTTag.Transform */:
1157
+ return createTransform_1(reverse_1(ast.from), ast.to, ast.decode, ast.encode, !ast.isReversed, ast.annotations);
1158
+ }
1159
+ return ast;
1160
+ }
1161
+ /**
1162
+ * @tsplus static fncts.schema.AST getCompiler
1163
+ */
1164
+ function getCompiler(match) {
1165
+ const compile = (0, _utils.memoize)(ast => {
1166
+ void 0;
1167
+ return match[ast._tag](ast, compile);
1168
+ });
1169
+ return compile;
1170
+ }
1171
+ //# sourceMappingURL=AST.cjs.map