aontu 0.60.0 → 0.62.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 +3 -3
- package/dist/agentsmd.d.ts +1 -0
- package/dist/agentsmd.js +7 -1
- package/dist/agentsmd.js.map +1 -1
- package/dist/allow.d.ts +23 -0
- package/dist/allow.js +230 -0
- package/dist/allow.js.map +1 -0
- package/dist/aontu.d.ts +4 -2
- package/dist/aontu.js +4 -2
- package/dist/aontu.js.map +1 -1
- package/dist/cli.d.ts +10 -1
- package/dist/cli.js +1000 -47
- package/dist/cli.js.map +1 -1
- package/dist/format.d.ts +1 -0
- package/dist/format.js +154 -12
- package/dist/format.js.map +1 -1
- package/dist/helpdoc.d.ts +16 -0
- package/dist/helpdoc.js +59 -0
- package/dist/helpdoc.js.map +1 -0
- package/dist/hints.js +15 -2
- package/dist/hints.js.map +1 -1
- package/dist/lang.js +93 -40
- package/dist/lang.js.map +1 -1
- package/dist/lower.d.ts +3 -0
- package/dist/lower.js +3 -0
- package/dist/lower.js.map +1 -1
- package/dist/lsp.d.ts +1 -1
- package/dist/lsp.js +1 -1
- package/dist/lsp.js.map +1 -1
- package/dist/relation.d.ts +2 -0
- package/dist/relation.js +7 -1
- package/dist/relation.js.map +1 -1
- package/dist/render.js +26 -21
- package/dist/render.js.map +1 -1
- package/dist/sigdecl.js +1 -1
- package/dist/sigdecl.js.map +1 -1
- package/dist/std.js +112 -69
- package/dist/std.js.map +1 -1
- package/dist/template.d.ts +2 -1
- package/dist/template.js +51 -15
- package/dist/template.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/val/AggFuncVal.js +2 -2
- package/dist/val/AggFuncVal.js.map +1 -1
- package/dist/val/CmpFuncVal.d.ts +20 -0
- package/dist/val/CmpFuncVal.js +245 -0
- package/dist/val/CmpFuncVal.js.map +1 -0
- package/dist/val/EachFuncVal.d.ts +1 -2
- package/dist/val/EachFuncVal.js +15 -29
- package/dist/val/EachFuncVal.js.map +1 -1
- package/dist/val/FormFuncVal.js.map +1 -1
- package/dist/val/LowerFuncVal.js +17 -1
- package/dist/val/LowerFuncVal.js.map +1 -1
- package/dist/val/NamerFuncVal.d.ts +12 -0
- package/dist/val/NamerFuncVal.js +176 -0
- package/dist/val/NamerFuncVal.js.map +1 -0
- package/dist/val/NilVal.js +29 -3
- package/dist/val/NilVal.js.map +1 -1
- package/dist/val/NomFuncVal.d.ts +12 -0
- package/dist/val/NomFuncVal.js +187 -0
- package/dist/val/NomFuncVal.js.map +1 -0
- package/dist/val/PackFuncVal.js +3 -3
- package/dist/val/PackFuncVal.js.map +1 -1
- package/dist/val/RefVal.js +1 -1
- package/dist/val/TranslateFuncVal.d.ts +12 -0
- package/dist/val/TranslateFuncVal.js +101 -0
- package/dist/val/TranslateFuncVal.js.map +1 -0
- package/dist/val/UpperFuncVal.js +17 -1
- package/dist/val/UpperFuncVal.js.map +1 -1
- package/dist/val/caserange.d.ts +3 -0
- package/dist/val/caserange.js +110 -0
- package/dist/val/caserange.js.map +1 -0
- package/dist/vet.d.ts +12 -0
- package/dist/vet.js +209 -1
- package/dist/vet.js.map +1 -1
- package/grammar/aontu.abnf +1 -1
- package/grammar/aontu.gbnf +1 -1
- package/grammar/aontu.lark +1 -1
- package/grammar/aontu.tmLanguage.json +1 -1
- package/package.json +1 -1
- package/skill/SKILL.md +8 -0
- package/skill/init/check.sh +28 -0
- package/skill/init/data.aon +12 -0
- package/skill/init/model.aon +19 -0
- package/skill/tasks.md +151 -0
- package/src/agentsmd.ts +13 -2
- package/src/allow.ts +316 -0
- package/src/aontu.ts +10 -1
- package/src/cli.ts +1131 -53
- package/src/format.ts +191 -14
- package/src/helpdoc.ts +77 -0
- package/src/hints.ts +16 -2
- package/src/lang.ts +98 -42
- package/src/lower.ts +3 -3
- package/src/lsp.ts +1 -1
- package/src/relation.ts +21 -1
- package/src/render.ts +26 -21
- package/src/sigdecl.ts +1 -1
- package/src/std.ts +112 -69
- package/src/template.ts +55 -15
- package/src/val/AggFuncVal.ts +2 -2
- package/src/val/CmpFuncVal.ts +411 -0
- package/src/val/EachFuncVal.ts +49 -50
- package/src/val/LowerFuncVal.ts +18 -1
- package/src/val/NilVal.ts +29 -3
- package/src/val/NomFuncVal.ts +287 -0
- package/src/val/PackFuncVal.ts +3 -3
- package/src/val/RefVal.ts +1 -1
- package/src/val/TranslateFuncVal.ts +182 -0
- package/src/val/UpperFuncVal.ts +18 -1
- package/src/val/caserange.ts +115 -0
- package/src/vet.ts +287 -1
- package/src/val/FormFuncVal.ts +0 -119
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Copyright (c) 2026 Richard Rodger, MIT License */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.NamerFuncVal = exports.NAMER_STYLES = void 0;
|
|
5
|
+
const err_1 = require("../err");
|
|
6
|
+
const lower_1 = require("../lower");
|
|
7
|
+
const MapVal_1 = require("./MapVal");
|
|
8
|
+
const StringVal_1 = require("./StringVal");
|
|
9
|
+
const FuncBaseVal_1 = require("./FuncBaseVal");
|
|
10
|
+
// The styles, and the map's keys. The first five are `caseName`'s --
|
|
11
|
+
// `aontu:profile`'s `%case` vocabulary, shared with the renderer --
|
|
12
|
+
// and the last four are namer's own (see the note above). `as-is` is
|
|
13
|
+
// not among them: it is the profile's way of saying "do nothing",
|
|
14
|
+
// which is not a spelling anyone asks a namer for.
|
|
15
|
+
const NAMER_STYLES = [
|
|
16
|
+
'camel', // userId
|
|
17
|
+
'dot', // user.id
|
|
18
|
+
'human', // User id
|
|
19
|
+
'kebab', // user-id
|
|
20
|
+
'pascal', // UserId
|
|
21
|
+
'path', // user/id
|
|
22
|
+
'screaming', // USER_ID
|
|
23
|
+
'snake', // user_id
|
|
24
|
+
'title', // User Id
|
|
25
|
+
];
|
|
26
|
+
exports.NAMER_STYLES = NAMER_STYLES;
|
|
27
|
+
const CASENAME_STYLES = ['camel', 'kebab', 'pascal', 'screaming', 'snake'];
|
|
28
|
+
// One name in one style, or undefined when the style is not one, or
|
|
29
|
+
// when the name holds no words at all.
|
|
30
|
+
function styleName(name, style, acronyms) {
|
|
31
|
+
// `.` and `/` are namer's separators, folded before the shared
|
|
32
|
+
// splitter is asked (see the note above). Everything else that is
|
|
33
|
+
// not a separator is word content: a `$` or a `@` rides into the
|
|
34
|
+
// word it sits in, which is why `namer` renames a spelled path's
|
|
35
|
+
// text and does not tidy it.
|
|
36
|
+
const src = name.replace(/[./]/g, '_');
|
|
37
|
+
// A NAME WITH NO WORDS IS NOT A NAME, and it is refused in every
|
|
38
|
+
// style. `caseName` answers its INPUT for one (it is lowering a
|
|
39
|
+
// declaration, where the name has already been vetted), so
|
|
40
|
+
// `namer("_", pascal)` came back as `"_"` while `namer("_")`
|
|
41
|
+
// refused -- the same argument, accepted by one spelling of the
|
|
42
|
+
// call and refused by the other.
|
|
43
|
+
const words = (0, lower_1.splitWords)(src);
|
|
44
|
+
if (0 === words.length) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
if (CASENAME_STYLES.includes(style)) {
|
|
48
|
+
return (0, lower_1.caseName)(src, style, acronyms);
|
|
49
|
+
}
|
|
50
|
+
if ('dot' === style) {
|
|
51
|
+
return words.map(lower_1.lowerASCII).join('.');
|
|
52
|
+
}
|
|
53
|
+
if ('path' === style) {
|
|
54
|
+
return words.map(lower_1.lowerASCII).join('/');
|
|
55
|
+
}
|
|
56
|
+
if ('title' === style) {
|
|
57
|
+
return words.map((w) => (0, lower_1.capitalise)(w, acronyms)).join(' ');
|
|
58
|
+
}
|
|
59
|
+
if ('human' === style) {
|
|
60
|
+
// Sentence case: the first word capitalised, the rest lower --
|
|
61
|
+
// EXCEPT an acronym, which stays one, because `ledger id` loses
|
|
62
|
+
// what `ID` was. Membership in the set decides that, not how the
|
|
63
|
+
// input happened to spell the word: asking whether `capitalise`
|
|
64
|
+
// changed it made `namer("ledgerId", human, [ID])` answer
|
|
65
|
+
// `Ledger id` while `namer("ledgerID", human, [ID])` answered
|
|
66
|
+
// `Ledger ID` -- the same name, two answers, decided by its
|
|
67
|
+
// source spelling, which is the one thing a namer must not do.
|
|
68
|
+
const isAcronym = (w) => acronyms.some((a) => (0, lower_1.lowerASCII)(a) === (0, lower_1.lowerASCII)(w));
|
|
69
|
+
return [(0, lower_1.capitalise)(words[0], acronyms)]
|
|
70
|
+
.concat(words.slice(1).map((w) => isAcronym(w) ? (0, lower_1.capitalise)(w, acronyms) : (0, lower_1.lowerASCII)(w)))
|
|
71
|
+
.join(' ');
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
// The text a value carries, when it is a concrete string. A path is a
|
|
76
|
+
// string too (ScalarKindVal's Path sits under String), so a spelled
|
|
77
|
+
// address may be renamed like any other text.
|
|
78
|
+
function textOf(v) {
|
|
79
|
+
const s = v;
|
|
80
|
+
return (true === s?.isScalar && 'string' === typeof s.peg) ? s.peg : undefined;
|
|
81
|
+
}
|
|
82
|
+
// An acronym set: a list of concrete strings, or undefined when the
|
|
83
|
+
// value is not one.
|
|
84
|
+
function acronymsOf(v) {
|
|
85
|
+
const l = v;
|
|
86
|
+
if (true !== l?.isList) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
const out = [];
|
|
90
|
+
for (const el of l.peg) {
|
|
91
|
+
const t = textOf(el);
|
|
92
|
+
if (undefined === t || '' === t) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
out.push(t);
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
class NamerFuncVal extends FuncBaseVal_1.FuncBaseVal {
|
|
100
|
+
constructor(spec, ctx) {
|
|
101
|
+
super(spec, ctx);
|
|
102
|
+
this.isNamerFunc = true;
|
|
103
|
+
}
|
|
104
|
+
make(_ctx, spec) {
|
|
105
|
+
return new NamerFuncVal(spec);
|
|
106
|
+
}
|
|
107
|
+
funcname() {
|
|
108
|
+
return 'namer';
|
|
109
|
+
}
|
|
110
|
+
resolve(ctx, args) {
|
|
111
|
+
if (args.length < 1 || 3 < args.length) {
|
|
112
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, undefined, 'arity');
|
|
113
|
+
}
|
|
114
|
+
const name = textOf(args[0]);
|
|
115
|
+
if (undefined === name || '' === name) {
|
|
116
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[0], 'name');
|
|
117
|
+
}
|
|
118
|
+
// THE SECOND ARGUMENT SAYS WHICH OF THE FOUR CALLS THIS IS, by
|
|
119
|
+
// its shape rather than by its position: a STRING is the style, a
|
|
120
|
+
// LIST is the acronym set. The same rule the component primitives
|
|
121
|
+
// read their spec by, and it is what keeps the acronym set
|
|
122
|
+
// reachable from the map form without a placeholder argument.
|
|
123
|
+
let style;
|
|
124
|
+
let acronyms = [];
|
|
125
|
+
if (2 <= args.length) {
|
|
126
|
+
const second = args[1];
|
|
127
|
+
if (true === second?.isList) {
|
|
128
|
+
if (3 === args.length) {
|
|
129
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[2], 'arity');
|
|
130
|
+
}
|
|
131
|
+
const acr = acronymsOf(second);
|
|
132
|
+
if (undefined === acr) {
|
|
133
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, second, 'acronyms');
|
|
134
|
+
}
|
|
135
|
+
acronyms = acr;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
style = textOf(second);
|
|
139
|
+
if (undefined === style) {
|
|
140
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, second, 'style');
|
|
141
|
+
}
|
|
142
|
+
if (3 === args.length) {
|
|
143
|
+
const acr = acronymsOf(args[2]);
|
|
144
|
+
if (undefined === acr) {
|
|
145
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[2], 'acronyms');
|
|
146
|
+
}
|
|
147
|
+
acronyms = acr;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// One style: the string.
|
|
152
|
+
if (undefined !== style) {
|
|
153
|
+
const out = styleName(name, style, acronyms);
|
|
154
|
+
if (undefined === out) {
|
|
155
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[1], 'style');
|
|
156
|
+
}
|
|
157
|
+
return this.place(new StringVal_1.StringVal({ peg: out }, ctx));
|
|
158
|
+
}
|
|
159
|
+
// Every style: the map. Closed, because the nine keys ARE the
|
|
160
|
+
// vocabulary and a tenth is a typo -- `namer($.n).pascel` is
|
|
161
|
+
// refused where every other mistake in an aontu document is.
|
|
162
|
+
const peg = {};
|
|
163
|
+
for (const s of NAMER_STYLES) {
|
|
164
|
+
const out = styleName(name, s, acronyms);
|
|
165
|
+
if (undefined === out) {
|
|
166
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[0], 'name');
|
|
167
|
+
}
|
|
168
|
+
peg[s] = new StringVal_1.StringVal({ peg: out }, ctx);
|
|
169
|
+
}
|
|
170
|
+
const map = new MapVal_1.MapVal({ peg }, ctx);
|
|
171
|
+
map.closed = true;
|
|
172
|
+
return this.place(map);
|
|
173
|
+
}
|
|
174
|
+
} /* node:coverage ignore next 6 */
|
|
175
|
+
exports.NamerFuncVal = NamerFuncVal;
|
|
176
|
+
//# sourceMappingURL=NamerFuncVal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NamerFuncVal.js","sourceRoot":"","sources":["../../src/val/NamerFuncVal.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;AAgEpD,gCAAmC;AAEnC,oCAKiB;AAEjB,qCAAiC;AACjC,2CAAuC;AACvC,+CAA2C;AAG3C,qEAAqE;AACrE,oEAAoE;AACpE,qEAAqE;AACrE,kEAAkE;AAClE,mDAAmD;AACnD,MAAM,YAAY,GAAG;IACnB,OAAO,EAAO,SAAS;IACvB,KAAK,EAAS,UAAU;IACxB,OAAO,EAAO,UAAU;IACxB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M,GAAG,IAAI,CAAA;QAEjB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;CAEF,CAAC,iCAAiC;QAKjC,YAAY"}
|
package/dist/val/NilVal.js
CHANGED
|
@@ -116,9 +116,35 @@ NilVal.make = (ctx, why, av, bv, attempt, details) => {
|
|
|
116
116
|
// unconditionally was tried and reverted -- it moved the closed-key,
|
|
117
117
|
// spread-template and every `--at` finding to the driving location,
|
|
118
118
|
// which is not where those belong.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
// A MEET OF TWO OPERANDS HAPPENS AT THE SLOT, always. A value that
|
|
120
|
+
// arrives by REFERENCE carries a path re-based onto the referring
|
|
121
|
+
// field -- `$.p.Port.direction` for a `p: $.lib.Port` whose
|
|
122
|
+
// `direction` conflicts -- and the two ports corrupt it DIFFERENTLY
|
|
123
|
+
// (Go's fallback is the slot plus the schema's own tail), so neither
|
|
124
|
+
// operand path is trustworthy once a reference is in play. The
|
|
125
|
+
// prefix test below cannot tell the corrupt case from a legitimately
|
|
126
|
+
// deeper one, because Go's corrupt path EXTENDS the right answer.
|
|
127
|
+
// The slot is the one thing both ports know exactly, so a real meet
|
|
128
|
+
// takes it.
|
|
129
|
+
//
|
|
130
|
+
// A SINGLE-OPERAND nil is left alone: a residue, a closed key, a
|
|
131
|
+
// generation failure and an `--at` finding are not meets, they are
|
|
132
|
+
// facts about one value, and taking the driving location for those
|
|
133
|
+
// is what the unconditional version got wrong. The ONE exception is
|
|
134
|
+
// an operand that was MINTED -- a preference's yardstick, an
|
|
135
|
+
// arithmetic or concat result -- which carries no path at all, so a
|
|
136
|
+
// conflict at `$.a` reported `$`, the whole document rather than the
|
|
137
|
+
// key to edit.
|
|
138
|
+
//
|
|
139
|
+
// This used to ask whether the operand's path was a PREFIX of the
|
|
140
|
+
// slot, and extend it when so. Once a meet takes the slot outright
|
|
141
|
+
// the question is vacuous: every nil still reaching here carries
|
|
142
|
+
// either no path or one at least as long as the slot, so the prefix
|
|
143
|
+
// walk never ran a single comparison across the whole suite. ADR-002
|
|
144
|
+
// closes unreachable code by deleting it rather than by covering it,
|
|
145
|
+
// and the emptiness test below is what the walk actually decided.
|
|
146
|
+
if (null != ctx?.path && 0 < ctx.path.length &&
|
|
147
|
+
(null != bv || null == nil.path || 0 === nil.path.length)) {
|
|
122
148
|
nil.path = [...ctx.path];
|
|
123
149
|
}
|
|
124
150
|
if (ctx) {
|
package/dist/val/NilVal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NilVal.js","sourceRoot":"","sources":["../../src/val/NilVal.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAOzD,kCAEgB;AAOhB,+BAAsC;AAEtC,gCAA4C;AAE5C,oCAAoC;AAGpC,MAAM,MAAO,SAAQ,SAAG;
|
|
1
|
+
{"version":3,"file":"NilVal.js","sourceRoot":"","sources":["../../src/val/NilVal.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAOzD,kCAEgB;AAOhB,+BAAsC;AAEtC,gCAA4C;AAE5C,oCAAoC;AAGpC,MAAM,MAAO,SAAQ,SAAG;IAqHtB,YACE,IAIU,EACV,GAAkB;QAElB,KAAK,CAAC,IAAI,IAAI,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;QA5H1D,UAAK,GAAG,IAAI,CAAA;QACZ,cAAS,GAAG,IAAI,CAAA;QAEhB,QAAG,GAAG,IAAI,CAAA;QAIV,QAAG,GAAW,EAAE,CAAA;QAuHd,IAAI,IAAI,IAAI,QAAQ,KAAK,OAAO,IAAI,EAAE,CAAC;YACrC,IAAI,CAAC,GAAG,GAAG,IAAI,EAAE,GAAG,CAAA;YACpB,IAAI,CAAC,GAAG,GAAG,QAAQ,KAAK,OAAO,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,C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E,kEAAkE;IAClE,4DAA4D;IAC5D,oEAAoE;IACpE,qEAAqE;IACrE,+DAA+D;IAC/D,qEAAqE;IACrE,kEAAkE;IAClE,oEAAoE;IACpE,YAAY;IACZ,EAAE;IACF,iEAAiE;IACjE,mEAAmE;IACnE,mEAAmE;IACnE,oEAAoE;IACpE,6DAA6D;IAC7D,oEAAoE;IACpE,qEAAqE;IACrE,eAAe;IACf,EAAE;IACF,kEAAkE;IAClE,mEAAmE;IACnE,iEAAiE;IACjE,oEAAoE;IACpE,qEAAqE;IACrE,qEAAqE;IACrE,kEAAkE;IAClE,IAAI,IAAI,IAAI,GAAG,EAAE,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM;QAC1C,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5D,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;IAED,IAAI,GAAG,EAAE,CAAC;QACR,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACjB,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,AAlGU,CAkGV;AA2FH,iEAAiE;AACjE,kEAAkE;AAClE,+DAA+D;AAC/D,mEAAmE;AACnE,kEAAkE;AAClE,kCAAkC;AAClC,EAAE;AACF,mEAAmE;AACnE,kEAAkE;AAClE,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC,CAAA,CAAC,iCAAiC;QAKpF,SAAS"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Val, ValSpec } from '../type';
|
|
2
|
+
import { AontuContext } from '../ctx';
|
|
3
|
+
import { FuncBaseVal } from './FuncBaseVal';
|
|
4
|
+
declare const NOM_STYLES: string[];
|
|
5
|
+
declare class NomFuncVal extends FuncBaseVal {
|
|
6
|
+
isNamerFunc: boolean;
|
|
7
|
+
constructor(spec: ValSpec, ctx?: AontuContext);
|
|
8
|
+
make(_ctx: AontuContext, spec: ValSpec): Val;
|
|
9
|
+
funcname(): string;
|
|
10
|
+
resolve(ctx: AontuContext, args: Val[]): Val;
|
|
11
|
+
}
|
|
12
|
+
export { NOM_STYLES, NomFuncVal, };
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Copyright (c) 2026 Richard Rodger, MIT License */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.NomFuncVal = exports.NOM_STYLES = void 0;
|
|
5
|
+
const err_1 = require("../err");
|
|
6
|
+
const lower_1 = require("../lower");
|
|
7
|
+
const MapVal_1 = require("./MapVal");
|
|
8
|
+
const StringVal_1 = require("./StringVal");
|
|
9
|
+
const FuncBaseVal_1 = require("./FuncBaseVal");
|
|
10
|
+
// The styles, and the map's keys. The first five are `caseName`'s --
|
|
11
|
+
// `aontu:profile`'s `%case` vocabulary, shared with the renderer --
|
|
12
|
+
// and the last four are nom's own (see the note above). `as-is` is
|
|
13
|
+
// not among them: it is the profile's way of saying "do nothing",
|
|
14
|
+
// which is not a spelling anyone asks a namer for.
|
|
15
|
+
const NOM_STYLES = [
|
|
16
|
+
'camel', // userId
|
|
17
|
+
'dot', // user.id
|
|
18
|
+
'kebab', // user-id
|
|
19
|
+
'pascal', // UserId
|
|
20
|
+
'path', // user/id
|
|
21
|
+
'snake', // user_id
|
|
22
|
+
'text', // User id
|
|
23
|
+
'title', // User Id
|
|
24
|
+
'upper', // USER_ID
|
|
25
|
+
];
|
|
26
|
+
exports.NOM_STYLES = NOM_STYLES;
|
|
27
|
+
// nom's style name -> the `%case` style `caseName` serves. `upper` and
|
|
28
|
+
// `text` are nom's spellings: `screaming` is what `aontu:profile` calls
|
|
29
|
+
// SCREAMING_SNAKE and that name is pinned cross-port, so the mapping
|
|
30
|
+
// lives here rather than in the shared vocabulary.
|
|
31
|
+
const CASENAME_STYLES = {
|
|
32
|
+
camel: 'camel',
|
|
33
|
+
kebab: 'kebab',
|
|
34
|
+
pascal: 'pascal',
|
|
35
|
+
snake: 'snake',
|
|
36
|
+
upper: 'screaming',
|
|
37
|
+
};
|
|
38
|
+
// One name in one style, or undefined when the style is not one, or
|
|
39
|
+
// when the name holds no words at all.
|
|
40
|
+
function styleName(name, style, acronyms) {
|
|
41
|
+
// `.` and `/` are nom's separators, folded before the shared
|
|
42
|
+
// splitter is asked (see the note above). Everything else that is
|
|
43
|
+
// not a separator is word content: a `$` or a `@` rides into the
|
|
44
|
+
// word it sits in, which is why `nom` renames a spelled path's
|
|
45
|
+
// text and does not tidy it.
|
|
46
|
+
const src = name.replace(/[./]/g, '_');
|
|
47
|
+
// A NAME WITH NO WORDS IS NOT A NAME, and it is refused in every
|
|
48
|
+
// style. `caseName` answers its INPUT for one (it is lowering a
|
|
49
|
+
// declaration, where the name has already been vetted), so
|
|
50
|
+
// `nom("_", pascal)` came back as `"_"` while `nom("_")`
|
|
51
|
+
// refused -- the same argument, accepted by one spelling of the
|
|
52
|
+
// call and refused by the other.
|
|
53
|
+
const words = (0, lower_1.splitWords)(src);
|
|
54
|
+
if (0 === words.length) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const cased = CASENAME_STYLES[style];
|
|
58
|
+
if (undefined !== cased) {
|
|
59
|
+
return (0, lower_1.caseName)(src, cased, acronyms);
|
|
60
|
+
}
|
|
61
|
+
if ('dot' === style) {
|
|
62
|
+
return words.map(lower_1.lowerASCII).join('.');
|
|
63
|
+
}
|
|
64
|
+
if ('path' === style) {
|
|
65
|
+
return words.map(lower_1.lowerASCII).join('/');
|
|
66
|
+
}
|
|
67
|
+
if ('title' === style) {
|
|
68
|
+
return words.map((w) => (0, lower_1.capitalise)(w, acronyms)).join(' ');
|
|
69
|
+
}
|
|
70
|
+
if ('text' === style) {
|
|
71
|
+
// Sentence case: the first word capitalised, the rest lower --
|
|
72
|
+
// EXCEPT an acronym, which stays one, because `ledger id` loses
|
|
73
|
+
// what `ID` was. Membership in the set decides that, not how the
|
|
74
|
+
// input happened to spell the word: asking whether `capitalise`
|
|
75
|
+
// changed it made `nom("ledgerId", text, [ID])` answer
|
|
76
|
+
// `Ledger id` while `nom("ledgerID", text, [ID])` answered
|
|
77
|
+
// `Ledger ID` -- the same name, two answers, decided by its
|
|
78
|
+
// source spelling, which is the one thing a namer must not do.
|
|
79
|
+
const isAcronym = (w) => acronyms.some((a) => (0, lower_1.lowerASCII)(a) === (0, lower_1.lowerASCII)(w));
|
|
80
|
+
return [(0, lower_1.capitalise)(words[0], acronyms)]
|
|
81
|
+
.concat(words.slice(1).map((w) => isAcronym(w) ? (0, lower_1.capitalise)(w, acronyms) : (0, lower_1.lowerASCII)(w)))
|
|
82
|
+
.join(' ');
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
// The text a value carries, when it is a concrete string. A path is a
|
|
87
|
+
// string too (ScalarKindVal's Path sits under String), so a spelled
|
|
88
|
+
// address may be renamed like any other text.
|
|
89
|
+
function textOf(v) {
|
|
90
|
+
const s = v;
|
|
91
|
+
return (true === s?.isScalar && 'string' === typeof s.peg) ? s.peg : undefined;
|
|
92
|
+
}
|
|
93
|
+
// An acronym set: a list of concrete strings, or undefined when the
|
|
94
|
+
// value is not one.
|
|
95
|
+
function acronymsOf(v) {
|
|
96
|
+
const l = v;
|
|
97
|
+
if (true !== l?.isList) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
const out = [];
|
|
101
|
+
for (const el of l.peg) {
|
|
102
|
+
const t = textOf(el);
|
|
103
|
+
if (undefined === t || '' === t) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
out.push(t);
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
class NomFuncVal extends FuncBaseVal_1.FuncBaseVal {
|
|
111
|
+
constructor(spec, ctx) {
|
|
112
|
+
super(spec, ctx);
|
|
113
|
+
this.isNamerFunc = true;
|
|
114
|
+
}
|
|
115
|
+
make(_ctx, spec) {
|
|
116
|
+
return new NomFuncVal(spec);
|
|
117
|
+
}
|
|
118
|
+
funcname() {
|
|
119
|
+
return 'nom';
|
|
120
|
+
}
|
|
121
|
+
resolve(ctx, args) {
|
|
122
|
+
if (args.length < 1 || 3 < args.length) {
|
|
123
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, undefined, 'arity');
|
|
124
|
+
}
|
|
125
|
+
const name = textOf(args[0]);
|
|
126
|
+
if (undefined === name || '' === name) {
|
|
127
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[0], 'name');
|
|
128
|
+
}
|
|
129
|
+
// THE SECOND ARGUMENT SAYS WHICH OF THE FOUR CALLS THIS IS, by
|
|
130
|
+
// its shape rather than by its position: a STRING is the style, a
|
|
131
|
+
// LIST is the acronym set. The same rule the component primitives
|
|
132
|
+
// read their spec by, and it is what keeps the acronym set
|
|
133
|
+
// reachable from the map form without a placeholder argument.
|
|
134
|
+
let style;
|
|
135
|
+
let acronyms = [];
|
|
136
|
+
if (2 <= args.length) {
|
|
137
|
+
const second = args[1];
|
|
138
|
+
if (true === second?.isList) {
|
|
139
|
+
if (3 === args.length) {
|
|
140
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[2], 'arity');
|
|
141
|
+
}
|
|
142
|
+
const acr = acronymsOf(second);
|
|
143
|
+
if (undefined === acr) {
|
|
144
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, second, 'acronyms');
|
|
145
|
+
}
|
|
146
|
+
acronyms = acr;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
style = textOf(second);
|
|
150
|
+
if (undefined === style) {
|
|
151
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, second, 'style');
|
|
152
|
+
}
|
|
153
|
+
if (3 === args.length) {
|
|
154
|
+
const acr = acronymsOf(args[2]);
|
|
155
|
+
if (undefined === acr) {
|
|
156
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[2], 'acronyms');
|
|
157
|
+
}
|
|
158
|
+
acronyms = acr;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// One style: the string.
|
|
163
|
+
if (undefined !== style) {
|
|
164
|
+
const out = styleName(name, style, acronyms);
|
|
165
|
+
if (undefined === out) {
|
|
166
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[1], 'style');
|
|
167
|
+
}
|
|
168
|
+
return this.place(new StringVal_1.StringVal({ peg: out }, ctx));
|
|
169
|
+
}
|
|
170
|
+
// Every style: the map. Closed, because the nine keys ARE the
|
|
171
|
+
// vocabulary and a tenth is a typo -- `nom($.n).pascel` is
|
|
172
|
+
// refused where every other mistake in an aontu document is.
|
|
173
|
+
const peg = {};
|
|
174
|
+
for (const s of NOM_STYLES) {
|
|
175
|
+
const out = styleName(name, s, acronyms);
|
|
176
|
+
if (undefined === out) {
|
|
177
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[0], 'name');
|
|
178
|
+
}
|
|
179
|
+
peg[s] = new StringVal_1.StringVal({ peg: out }, ctx);
|
|
180
|
+
}
|
|
181
|
+
const map = new MapVal_1.MapVal({ peg }, ctx);
|
|
182
|
+
map.closed = true;
|
|
183
|
+
return this.place(map);
|
|
184
|
+
}
|
|
185
|
+
} /* node:coverage ignore next 6 */
|
|
186
|
+
exports.NomFuncVal = NomFuncVal;
|
|
187
|
+
//# sourceMappingURL=NomFuncVal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NomFuncVal.js","sourceRoot":"","sources":["../../src/val/NomFuncVal.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;AAgEpD,gCAAmC;AAEnC,oCAKiB;AAEjB,qCAAiC;AACjC,2CAAuC;AACvC,+CAA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C,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;YAC9D,CAAC;YACD,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,qBAAS,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,CAAA;QAC3C,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,eAAM,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,CAAA;QACpC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAA;QAEjB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;CAEF,CAAC,iCAAiC;QAKjC,UAAU"}
|
package/dist/val/PackFuncVal.js
CHANGED
|
@@ -11,9 +11,9 @@ const Val_1 = require("./Val");
|
|
|
11
11
|
const PlaceVal_1 = require("./PlaceVal");
|
|
12
12
|
const members_1 = require("./members");
|
|
13
13
|
// The keys a data bag names, in the order the result must carry them,
|
|
14
|
-
// or a code naming what is wrong with it.
|
|
15
|
-
//
|
|
16
|
-
//
|
|
14
|
+
// or a code naming what is wrong with it. `each` asks the same
|
|
15
|
+
// question of the same argument and answers it with the values rather
|
|
16
|
+
// than the keys (members.ts).
|
|
17
17
|
function dataKeys(data, ctx) {
|
|
18
18
|
// The candidates are the bag's MEMBERS -- what generation would
|
|
19
19
|
// emit (./members.ts, BUGS.md §79) -- so a hidden key, or a hidden
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackFuncVal.js","sourceRoot":"","sources":["../../src/val/PackFuncVal.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;QA8KlD,QAAQ;AAtIV,oCAAgC;AAChC,gCAAmC;AACnC,qCAAiC;AACjC,+CAA2C;AAC3C,+BAAsC;AACtC,yCAAsC;AACtC,uCAAsC;AAGtC,sEAAsE;AACtE
|
|
1
|
+
{"version":3,"file":"PackFuncVal.js","sourceRoot":"","sources":["../../src/val/PackFu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,IAAI,KAAK,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;YACnF,iEAAiE;YACjE,gEAAgE;YAChE,gEAAgE;YAChE,iEAAiE;YACjE,kEAAkE;YAClE,kEAAkE;YAClE,kDAAkD;YAClD,EAAE;YACF,gEAAgE;YAChE,wDAAwD;YACxD,gEAAgE;YAChE,gEAAgE;YAChE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAA;YAC9C,IAAA,oBAAc,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;YAC/B,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;YAC7C,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACzC,IAAA,aAAK,EAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;QAC1C,CAAC;QAED,OAAO,IAAI,eAAM,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,CAAA;IACjC,CAAC;CAEF,CAAC,iCAAiC;QAKjC,WAAW"}
|
package/dist/val/RefVal.js
CHANGED
|
@@ -558,7 +558,7 @@ class RefVal extends FeatureVal_1.FeatureVal {
|
|
|
558
558
|
// hidden IN ITS OWN RIGHT, and the verb's enumeration
|
|
559
559
|
// (ts/src/val/members.ts, BUGS.md §79) needs to see that
|
|
560
560
|
// mark to leave the member out, as generation does. A marked
|
|
561
|
-
// target lifts even there, or `
|
|
561
|
+
// target lifts even there, or `form($.schema.entities, _)`
|
|
562
562
|
// under `schema: hide({...})` would see every entity as
|
|
563
563
|
// hidden, since hide() marks to the leaves.
|
|
564
564
|
const lifted = true !== ctx.argsnap
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Val, ValSpec } from '../type';
|
|
2
|
+
import { AontuContext } from '../ctx';
|
|
3
|
+
import { FuncBaseVal } from './FuncBaseVal';
|
|
4
|
+
declare function expandSet(set: string): string[] | undefined;
|
|
5
|
+
declare class TranslateFuncVal extends FuncBaseVal {
|
|
6
|
+
isTranslateFunc: boolean;
|
|
7
|
+
constructor(spec: ValSpec, ctx?: AontuContext);
|
|
8
|
+
make(_ctx: AontuContext, spec: ValSpec): Val;
|
|
9
|
+
funcname(): string;
|
|
10
|
+
resolve(ctx: AontuContext, args: Val[]): Val;
|
|
11
|
+
}
|
|
12
|
+
export { expandSet, TranslateFuncVal, };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Copyright (c) 2026 Richard Rodger, MIT License */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TranslateFuncVal = void 0;
|
|
5
|
+
exports.expandSet = expandSet;
|
|
6
|
+
const err_1 = require("../err");
|
|
7
|
+
const StringVal_1 = require("./StringVal");
|
|
8
|
+
const FuncBaseVal_1 = require("./FuncBaseVal");
|
|
9
|
+
// A set with its ranges expanded, or undefined when a range descends.
|
|
10
|
+
// `-` first or last is a literal.
|
|
11
|
+
function expandSet(set) {
|
|
12
|
+
const cps = Array.from(set);
|
|
13
|
+
const out = [];
|
|
14
|
+
for (let i = 0; i < cps.length; i++) {
|
|
15
|
+
const c = cps[i];
|
|
16
|
+
const next = cps[i + 1];
|
|
17
|
+
const after = cps[i + 2];
|
|
18
|
+
if ('-' === next && undefined !== after && 0 < i + 2) {
|
|
19
|
+
const lo = c.codePointAt(0);
|
|
20
|
+
const hi = after.codePointAt(0);
|
|
21
|
+
if (hi < lo) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
for (let cp = lo; cp <= hi; cp++) {
|
|
25
|
+
out.push(String.fromCodePoint(cp));
|
|
26
|
+
}
|
|
27
|
+
i += 2;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
out.push(c);
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
// The text a value carries, when it is a concrete string.
|
|
35
|
+
function textOf(v) {
|
|
36
|
+
const s = v;
|
|
37
|
+
return (true === s?.isScalar && 'string' === typeof s.peg) ? s.peg : undefined;
|
|
38
|
+
}
|
|
39
|
+
class TranslateFuncVal extends FuncBaseVal_1.FuncBaseVal {
|
|
40
|
+
constructor(spec, ctx) {
|
|
41
|
+
super(spec, ctx);
|
|
42
|
+
this.isTranslateFunc = true;
|
|
43
|
+
}
|
|
44
|
+
make(_ctx, spec) {
|
|
45
|
+
return new TranslateFuncVal(spec);
|
|
46
|
+
}
|
|
47
|
+
funcname() {
|
|
48
|
+
return 'translate';
|
|
49
|
+
}
|
|
50
|
+
resolve(ctx, args) {
|
|
51
|
+
if (args.length < 2 || 3 < args.length) {
|
|
52
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, undefined, 'arity');
|
|
53
|
+
}
|
|
54
|
+
const src = textOf(args[0]);
|
|
55
|
+
if (undefined === src) {
|
|
56
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[0], 'src');
|
|
57
|
+
}
|
|
58
|
+
const fromText = textOf(args[1]);
|
|
59
|
+
if (undefined === fromText) {
|
|
60
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[1], 'from');
|
|
61
|
+
}
|
|
62
|
+
const from = expandSet(fromText);
|
|
63
|
+
if (undefined === from) {
|
|
64
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[1], 'from');
|
|
65
|
+
}
|
|
66
|
+
let to = [];
|
|
67
|
+
if (3 === args.length) {
|
|
68
|
+
const toText = textOf(args[2]);
|
|
69
|
+
if (undefined === toText) {
|
|
70
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[2], 'to');
|
|
71
|
+
}
|
|
72
|
+
const expanded = expandSet(toText);
|
|
73
|
+
if (undefined === expanded) {
|
|
74
|
+
return (0, err_1.makeNilErr)(ctx, 'invalid-arg', this, args[2], 'to');
|
|
75
|
+
}
|
|
76
|
+
to = expanded;
|
|
77
|
+
}
|
|
78
|
+
// The table, built left to right so a character named twice takes
|
|
79
|
+
// its last mapping. An empty `to` maps to nothing, which is the
|
|
80
|
+
// deletion: there is no last character to pad with.
|
|
81
|
+
const pad = 0 < to.length ? to[to.length - 1] : undefined;
|
|
82
|
+
const table = new Map();
|
|
83
|
+
for (let i = 0; i < from.length; i++) {
|
|
84
|
+
table.set(from[i], i < to.length ? to[i] : pad);
|
|
85
|
+
}
|
|
86
|
+
let out = '';
|
|
87
|
+
for (const c of Array.from(src)) {
|
|
88
|
+
if (table.has(c)) {
|
|
89
|
+
const sub = table.get(c);
|
|
90
|
+
if (undefined !== sub) {
|
|
91
|
+
out += sub;
|
|
92
|
+
}
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
out += c;
|
|
96
|
+
}
|
|
97
|
+
return this.place(new StringVal_1.StringVal({ peg: out }, ctx));
|
|
98
|
+
}
|
|
99
|
+
} /* node:coverage ignore next 6 */
|
|
100
|
+
exports.TranslateFuncVal = TranslateFuncVal;
|
|
101
|
+
//# sourceMappingURL=TranslateFuncVal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranslateFuncVal.js","sourceRoot":"","sources":["../../src/val/TranslateFuncVal.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;QAmLlD,SAAS;AAxHX,gCAAmC;AAEnC,2CAAuC;AACvC,+CAA2C;AAG3C,sEAAsE;AACtE,kCAAkC;AAClC,SAAS,SAAS,CAAC,GAAW;IAC5B,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;I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