@ldclabs/kip-lang 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -5
- package/dist/ast.d.ts +10 -1
- package/dist/ast.d.ts.map +1 -1
- package/dist/budget.d.ts +37 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +105 -0
- package/dist/budget.js.map +1 -0
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +7 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/errors.d.ts +29 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +27 -0
- package/dist/errors.js.map +1 -0
- package/dist/exec-ast.d.ts +314 -0
- package/dist/exec-ast.d.ts.map +1 -0
- package/dist/exec-ast.js +23 -0
- package/dist/exec-ast.js.map +1 -0
- package/dist/formatter.d.ts +5 -7
- package/dist/formatter.d.ts.map +1 -1
- package/dist/formatter.js +71 -143
- package/dist/formatter.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/lexer.d.ts.map +1 -1
- package/dist/lexer.js +42 -11
- package/dist/lexer.js.map +1 -1
- package/dist/lower.d.ts +18 -0
- package/dist/lower.d.ts.map +1 -0
- package/dist/lower.js +877 -0
- package/dist/lower.js.map +1 -0
- package/dist/parser.js +311 -82
- package/dist/parser.js.map +1 -1
- package/dist/semantics.d.ts +13 -0
- package/dist/semantics.d.ts.map +1 -0
- package/dist/semantics.js +228 -0
- package/dist/semantics.js.map +1 -0
- package/dist/token.d.ts +4 -4
- package/dist/token.d.ts.map +1 -1
- package/dist/token.js +5 -10
- package/dist/token.js.map +1 -1
- package/dist/version.d.ts +13 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +13 -0
- package/dist/version.js.map +1 -0
- package/package.json +9 -4
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The *executable* KIP AST.
|
|
3
|
+
*
|
|
4
|
+
* This is a different tree from `ast.ts`, on purpose. `ast.ts` is a syntax
|
|
5
|
+
* tree: it keeps ranges, comments, quoting style and raw number text, because
|
|
6
|
+
* a formatter and an editor need to reproduce the source. This tree is what an
|
|
7
|
+
* engine needs instead — every construct already collapsed to the one shape it
|
|
8
|
+
* means, with the open-ended parts of the grammar closed:
|
|
9
|
+
*
|
|
10
|
+
* - a concept matcher is one of four identified forms, not a bag of entries;
|
|
11
|
+
* - a filter is a comparison, a logical node, a negation, or a call to one of
|
|
12
|
+
* seven functions, not a general expression tree;
|
|
13
|
+
* - a variable is a name and a dot path, not a chain of member accesses.
|
|
14
|
+
*
|
|
15
|
+
* A consumer switching on these tags is total: there is no "some other
|
|
16
|
+
* function name" case to defend against, because `lower` rejected it.
|
|
17
|
+
*
|
|
18
|
+
* The shape is the wire form of `anda_kip`'s Rust AST (serde's default
|
|
19
|
+
* externally-tagged enum encoding), so an engine can consume either
|
|
20
|
+
* interchangeably and a differential test can compare them field for field.
|
|
21
|
+
*/
|
|
22
|
+
/** A JSON value, as carried by attribute and metadata blocks. */
|
|
23
|
+
export type Json = null | boolean | number | string | Json[] | {
|
|
24
|
+
[key: string]: Json;
|
|
25
|
+
};
|
|
26
|
+
/** A KIP literal. Externally tagged; `Null` is a bare string. */
|
|
27
|
+
export type KipValue = 'Null' | {
|
|
28
|
+
Bool: boolean;
|
|
29
|
+
} | {
|
|
30
|
+
Number: number;
|
|
31
|
+
} | {
|
|
32
|
+
String: string;
|
|
33
|
+
} | {
|
|
34
|
+
Array: KipValue[];
|
|
35
|
+
} | {
|
|
36
|
+
Object: Record<string, KipValue>;
|
|
37
|
+
};
|
|
38
|
+
/** One parsed command. */
|
|
39
|
+
export type Command = {
|
|
40
|
+
Kql: KqlQuery;
|
|
41
|
+
} | {
|
|
42
|
+
Kml: KmlStatement;
|
|
43
|
+
} | {
|
|
44
|
+
Meta: MetaCommand;
|
|
45
|
+
};
|
|
46
|
+
export interface KqlQuery {
|
|
47
|
+
find_clause: FindClause;
|
|
48
|
+
where_clauses: WhereClause[];
|
|
49
|
+
order_by: OrderByItem[] | null;
|
|
50
|
+
limit: number | null;
|
|
51
|
+
cursor: string | null;
|
|
52
|
+
}
|
|
53
|
+
export interface FindClause {
|
|
54
|
+
expressions: FindExpression[];
|
|
55
|
+
}
|
|
56
|
+
/** `?var` with an optional dot path, e.g. `?d.attributes.risk`. Names carry no `?`. */
|
|
57
|
+
export interface DotPathVar {
|
|
58
|
+
var: string;
|
|
59
|
+
path: string[];
|
|
60
|
+
}
|
|
61
|
+
export type FindExpression = {
|
|
62
|
+
Variable: DotPathVar;
|
|
63
|
+
} | {
|
|
64
|
+
Aggregation: {
|
|
65
|
+
func: AggregationFunction;
|
|
66
|
+
var: DotPathVar;
|
|
67
|
+
distinct: boolean;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export type AggregationFunction = 'Count' | 'Sum' | 'Avg' | 'Min' | 'Max';
|
|
71
|
+
export interface OrderByItem {
|
|
72
|
+
variable: DotPathVar;
|
|
73
|
+
direction: OrderDirection;
|
|
74
|
+
aggregation: AggregationFunction | null;
|
|
75
|
+
}
|
|
76
|
+
export type OrderDirection = 'Asc' | 'Desc';
|
|
77
|
+
export type WhereClause = {
|
|
78
|
+
Concept: {
|
|
79
|
+
variable: string;
|
|
80
|
+
matcher: ConceptMatcher;
|
|
81
|
+
};
|
|
82
|
+
} | {
|
|
83
|
+
Proposition: {
|
|
84
|
+
variable: string | null;
|
|
85
|
+
matcher: PropositionMatcher;
|
|
86
|
+
};
|
|
87
|
+
} | {
|
|
88
|
+
Filter: {
|
|
89
|
+
expression: FilterExpression;
|
|
90
|
+
};
|
|
91
|
+
} | {
|
|
92
|
+
Not: WhereClause[];
|
|
93
|
+
} | {
|
|
94
|
+
Optional: WhereClause[];
|
|
95
|
+
} | {
|
|
96
|
+
Union: WhereClause[];
|
|
97
|
+
};
|
|
98
|
+
export type ConceptMatcher = {
|
|
99
|
+
ID: string;
|
|
100
|
+
} | {
|
|
101
|
+
Type: string;
|
|
102
|
+
} | {
|
|
103
|
+
Name: string;
|
|
104
|
+
} | {
|
|
105
|
+
Object: {
|
|
106
|
+
type: string;
|
|
107
|
+
name: string;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export type PropositionMatcher = {
|
|
111
|
+
ID: string;
|
|
112
|
+
} | {
|
|
113
|
+
Object: {
|
|
114
|
+
subject: TargetTerm;
|
|
115
|
+
predicate: PredTerm;
|
|
116
|
+
object: TargetTerm;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* One endpoint of a proposition pattern.
|
|
121
|
+
*
|
|
122
|
+
* `Proposition` is the meta-statement case: an endpoint may itself be a
|
|
123
|
+
* proposition, which is how KIP states things about statements. It nests
|
|
124
|
+
* arbitrarily deep.
|
|
125
|
+
*/
|
|
126
|
+
export type TargetTerm = {
|
|
127
|
+
Variable: string;
|
|
128
|
+
} | {
|
|
129
|
+
Concept: ConceptMatcher;
|
|
130
|
+
} | {
|
|
131
|
+
Proposition: PropositionMatcher;
|
|
132
|
+
};
|
|
133
|
+
export type PredTerm = {
|
|
134
|
+
Variable: string;
|
|
135
|
+
} | {
|
|
136
|
+
Literal: string;
|
|
137
|
+
} | {
|
|
138
|
+
Alternative: string[];
|
|
139
|
+
} | {
|
|
140
|
+
MultiHop: {
|
|
141
|
+
predicate: string;
|
|
142
|
+
min: number;
|
|
143
|
+
max: number | null;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
export type FilterExpression = {
|
|
147
|
+
Comparison: {
|
|
148
|
+
left: FilterOperand;
|
|
149
|
+
operator: ComparisonOperator;
|
|
150
|
+
right: FilterOperand;
|
|
151
|
+
};
|
|
152
|
+
} | {
|
|
153
|
+
Logical: {
|
|
154
|
+
left: FilterExpression;
|
|
155
|
+
operator: LogicalOperator;
|
|
156
|
+
right: FilterExpression;
|
|
157
|
+
};
|
|
158
|
+
} | {
|
|
159
|
+
Not: FilterExpression;
|
|
160
|
+
} | {
|
|
161
|
+
Function: {
|
|
162
|
+
func: FilterFunction;
|
|
163
|
+
args: FilterOperand[];
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
export type FilterOperand = {
|
|
167
|
+
Variable: DotPathVar;
|
|
168
|
+
} | {
|
|
169
|
+
Literal: KipValue;
|
|
170
|
+
} | {
|
|
171
|
+
List: KipValue[];
|
|
172
|
+
};
|
|
173
|
+
export type ComparisonOperator = 'Equal' | 'NotEqual' | 'LessThan' | 'GreaterThan' | 'LessEqual' | 'GreaterEqual';
|
|
174
|
+
export type LogicalOperator = 'And' | 'Or';
|
|
175
|
+
export type FilterFunction = 'Contains' | 'StartsWith' | 'EndsWith' | 'Regex'
|
|
176
|
+
/** `IN(?expr, [a, b])` — membership. A function, not a comparison operator. */
|
|
177
|
+
| 'In' | 'IsNull' | 'IsNotNull';
|
|
178
|
+
export type KmlStatement = {
|
|
179
|
+
Upsert: UpsertBlock[];
|
|
180
|
+
} | {
|
|
181
|
+
Update: UpdateStatement;
|
|
182
|
+
} | {
|
|
183
|
+
Merge: MergeStatement;
|
|
184
|
+
} | {
|
|
185
|
+
Delete: DeleteStatement;
|
|
186
|
+
};
|
|
187
|
+
export interface UpsertBlock {
|
|
188
|
+
items: UpsertItem[];
|
|
189
|
+
metadata: Record<string, Json> | null;
|
|
190
|
+
}
|
|
191
|
+
export type UpsertItem = {
|
|
192
|
+
Concept: ConceptBlock;
|
|
193
|
+
} | {
|
|
194
|
+
Proposition: PropositionBlock;
|
|
195
|
+
};
|
|
196
|
+
export interface ConceptBlock {
|
|
197
|
+
handle: string | null;
|
|
198
|
+
concept: ConceptMatcher;
|
|
199
|
+
set_attributes: Record<string, Json> | null;
|
|
200
|
+
set_propositions: SetProposition[] | null;
|
|
201
|
+
metadata: Record<string, Json> | null;
|
|
202
|
+
/** `EXPECT VERSION <n>` — optimistic guard, omitted when not written. */
|
|
203
|
+
expect_version?: number;
|
|
204
|
+
}
|
|
205
|
+
export interface SetProposition {
|
|
206
|
+
predicate: string;
|
|
207
|
+
object: TargetTerm;
|
|
208
|
+
metadata: Record<string, Json> | null;
|
|
209
|
+
}
|
|
210
|
+
export interface PropositionBlock {
|
|
211
|
+
handle: string | null;
|
|
212
|
+
proposition: PropositionMatcher;
|
|
213
|
+
set_attributes: Record<string, Json> | null;
|
|
214
|
+
metadata: Record<string, Json> | null;
|
|
215
|
+
expect_version?: number;
|
|
216
|
+
}
|
|
217
|
+
export interface UpdateStatement {
|
|
218
|
+
target: string;
|
|
219
|
+
set_attributes: [string, UpdateValue][] | null;
|
|
220
|
+
set_metadata: [string, UpdateValue][] | null;
|
|
221
|
+
where_clauses: WhereClause[];
|
|
222
|
+
limit: number | null;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* An UPDATE right-hand side: a literal, or arithmetic over the target's *own*
|
|
226
|
+
* fields. References to any other variable are rejected during lowering, which
|
|
227
|
+
* is what lets each matched element be updated from its own row without a join.
|
|
228
|
+
*/
|
|
229
|
+
export type UpdateValue = {
|
|
230
|
+
Json: Json;
|
|
231
|
+
} | {
|
|
232
|
+
Expr: UpdateExpr;
|
|
233
|
+
};
|
|
234
|
+
export type UpdateExpr = {
|
|
235
|
+
Variable: DotPathVar;
|
|
236
|
+
} | {
|
|
237
|
+
Number: number;
|
|
238
|
+
} | {
|
|
239
|
+
Function: {
|
|
240
|
+
func: UpdateFunction;
|
|
241
|
+
args: UpdateExpr[];
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
export type UpdateFunction = 'Add' | 'Mul' | 'Clamp' | 'Coalesce';
|
|
245
|
+
export interface MergeStatement {
|
|
246
|
+
source: string;
|
|
247
|
+
target: string;
|
|
248
|
+
where_clauses: WhereClause[];
|
|
249
|
+
}
|
|
250
|
+
export type DeleteStatement = {
|
|
251
|
+
DeleteAttributes: {
|
|
252
|
+
attributes: string[];
|
|
253
|
+
target: string;
|
|
254
|
+
where_clauses: WhereClause[];
|
|
255
|
+
};
|
|
256
|
+
} | {
|
|
257
|
+
DeleteMetadata: {
|
|
258
|
+
keys: string[];
|
|
259
|
+
target: string;
|
|
260
|
+
where_clauses: WhereClause[];
|
|
261
|
+
};
|
|
262
|
+
} | {
|
|
263
|
+
DeletePropositions: {
|
|
264
|
+
target: string;
|
|
265
|
+
where_clauses: WhereClause[];
|
|
266
|
+
};
|
|
267
|
+
} | {
|
|
268
|
+
DeleteConcept: {
|
|
269
|
+
target: string;
|
|
270
|
+
where_clauses: WhereClause[];
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
export type MetaCommand = {
|
|
274
|
+
Describe: DescribeTarget;
|
|
275
|
+
} | {
|
|
276
|
+
Search: SearchCommand;
|
|
277
|
+
} | {
|
|
278
|
+
Export: ExportCommand;
|
|
279
|
+
};
|
|
280
|
+
export type DescribeTarget = 'Primer' | 'Domains' | {
|
|
281
|
+
ConceptTypes: {
|
|
282
|
+
limit: number | null;
|
|
283
|
+
cursor: string | null;
|
|
284
|
+
};
|
|
285
|
+
} | {
|
|
286
|
+
ConceptType: string;
|
|
287
|
+
} | {
|
|
288
|
+
PropositionTypes: {
|
|
289
|
+
limit: number | null;
|
|
290
|
+
cursor: string | null;
|
|
291
|
+
};
|
|
292
|
+
} | {
|
|
293
|
+
PropositionType: string;
|
|
294
|
+
};
|
|
295
|
+
export interface SearchCommand {
|
|
296
|
+
target: SearchTarget;
|
|
297
|
+
term: string;
|
|
298
|
+
in_type: string | null;
|
|
299
|
+
/** Omitted when the command wrote no `MODE`. */
|
|
300
|
+
mode?: SearchMode;
|
|
301
|
+
/** Omitted when the command wrote no `THRESHOLD`. */
|
|
302
|
+
threshold?: number;
|
|
303
|
+
limit: number | null;
|
|
304
|
+
}
|
|
305
|
+
export type SearchTarget = 'Concept' | 'Proposition';
|
|
306
|
+
export type SearchMode = 'Keyword' | 'Semantic' | 'Hybrid';
|
|
307
|
+
export interface ExportCommand {
|
|
308
|
+
target: string;
|
|
309
|
+
where_clauses: WhereClause[];
|
|
310
|
+
limit: number | null;
|
|
311
|
+
/** Omitted when the command wrote no `CURSOR`. */
|
|
312
|
+
cursor?: string;
|
|
313
|
+
}
|
|
314
|
+
//# sourceMappingURL=exec-ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-ast.d.ts","sourceRoot":"","sources":["../src/exec-ast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,iEAAiE;AACjE,MAAM,MAAM,IAAI,GACZ,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,IAAI,EAAE,GACN;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAA;AAE3B,iEAAiE;AACjE,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;CAAE,CAAA;AAExC,0BAA0B;AAC1B,MAAM,MAAM,OAAO,GACf;IAAE,GAAG,EAAE,QAAQ,CAAA;CAAE,GACjB;IAAE,GAAG,EAAE,YAAY,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,CAAA;AAMzB,MAAM,WAAW,QAAQ;IACvB,WAAW,EAAE,UAAU,CAAA;IACvB,aAAa,EAAE,WAAW,EAAE,CAAA;IAC5B,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,CAAA;IAC9B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,E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,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,gDAAgD;IAChD,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,aAAa,CAAA;AAEpD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAA;AAE1D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,WAAW,EAAE,CAAA;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB"}
|
package/dist/exec-ast.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The *executable* KIP AST.
|
|
3
|
+
*
|
|
4
|
+
* This is a different tree from `ast.ts`, on purpose. `ast.ts` is a syntax
|
|
5
|
+
* tree: it keeps ranges, comments, quoting style and raw number text, because
|
|
6
|
+
* a formatter and an editor need to reproduce the source. This tree is what an
|
|
7
|
+
* engine needs instead — every construct already collapsed to the one shape it
|
|
8
|
+
* means, with the open-ended parts of the grammar closed:
|
|
9
|
+
*
|
|
10
|
+
* - a concept matcher is one of four identified forms, not a bag of entries;
|
|
11
|
+
* - a filter is a comparison, a logical node, a negation, or a call to one of
|
|
12
|
+
* seven functions, not a general expression tree;
|
|
13
|
+
* - a variable is a name and a dot path, not a chain of member accesses.
|
|
14
|
+
*
|
|
15
|
+
* A consumer switching on these tags is total: there is no "some other
|
|
16
|
+
* function name" case to defend against, because `lower` rejected it.
|
|
17
|
+
*
|
|
18
|
+
* The shape is the wire form of `anda_kip`'s Rust AST (serde's default
|
|
19
|
+
* externally-tagged enum encoding), so an engine can consume either
|
|
20
|
+
* interchangeably and a differential test can compare them field for field.
|
|
21
|
+
*/
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=exec-ast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-ast.js","sourceRoot":"","sources":["../src/exec-ast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG"}
|
package/dist/formatter.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
export interface FormatOptions {
|
|
2
2
|
/** Number of spaces per indentation level (default: 4) */
|
|
3
3
|
indentSize?: number;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Alphabetically sort keys inside `SET ATTRIBUTES` (default: false).
|
|
6
|
+
* Author key order is preserved by default; sorting is skipped for any block
|
|
7
|
+
* that contains comments, since reordering would detach a comment from its key.
|
|
8
|
+
*/
|
|
5
9
|
sortAttributes?: boolean;
|
|
6
10
|
}
|
|
7
11
|
export declare function format(source: string, options?: FormatOptions): string;
|
|
8
|
-
/**
|
|
9
|
-
* A simpler comment-preserving formatter that works at the token level.
|
|
10
|
-
* It re-parses the source and reconstructs it line by line, preserving
|
|
11
|
-
* all comments in their relative positions while normalizing indentation.
|
|
12
|
-
*/
|
|
13
|
-
export declare function formatPreservingComments(source: string, options?: FormatOptions): string;
|
|
14
12
|
//# sourceMappingURL=formatter.d.ts.map
|
package/dist/formatter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AA8CA,MAAM,WAAW,aAAa;IAC5B,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AA8CA,MAAM,WAAW,aAAa;IAC5B,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAgBtE"}
|