@izagood/avcs 0.1.0 → 0.2.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.
@@ -1,150 +0,0 @@
1
- // Phase 4: lightweight contract analysis for semantic-conflict detection.
2
- //
3
- // The dangerous merge in agentic coding is the one with NO text overlap: agent A
4
- // changes a function's contract while agent B, blind to that, adds a caller under
5
- // the old contract. Line-based VCS pass it; the build then breaks. This module
6
- // extracts exported symbol signatures and finds references to a symbol, so the
7
- // reducer can escalate "broke a contract + someone depends on it" to a human.
8
- //
9
- // MVP scope: a TS/JS-shaped heuristic over the symbol spans from `symbols.ts`. It is
10
- // intentionally conservative (favors flagging) and pluggable per language, to be
11
- // replaced by real type analysis in a later phase.
12
- import { tsIndexer } from "./symbols.js";
13
- const SIG = /^(export\s+(default\s+)?)?(async\s+)?function\s+([A-Za-z0-9_$]+)\s*\(([^)]*)\)\s*(?::\s*([^={]+))?/;
14
- /** Extract top-level function signatures from a file's content. */
15
- export function signatures(content, indexer = tsIndexer) {
16
- const out = new Map();
17
- for (const span of indexer.parse(content)) {
18
- if (span.kind !== "symbol")
19
- continue;
20
- const m = SIG.exec(span.text.trim().split("\n")[0] ?? "");
21
- if (!m)
22
- continue;
23
- out.set(m[4], {
24
- name: m[4],
25
- params: normalizeParams(m[5] ?? ""),
26
- returns: (m[6] ?? "").trim(),
27
- exported: !!m[1],
28
- });
29
- }
30
- return out;
31
- }
32
- function normalizeParams(raw) {
33
- return raw
34
- .split(",")
35
- .map((p) => p.trim().split(":")[0].trim().replace(/[?=].*$/, "").trim())
36
- .filter(Boolean)
37
- .join(",");
38
- }
39
- /** Did the public contract of `name` change between two file versions? */
40
- export function contractChanged(beforeContent, afterContent, name) {
41
- const a = signatures(beforeContent).get(name);
42
- const b = signatures(afterContent).get(name);
43
- if (!a || !b)
44
- return false; // appeared/disappeared handled elsewhere
45
- return a.params !== b.params || a.returns !== b.returns;
46
- }
47
- /**
48
- * Does `content` reference symbol `name` as a call or member access? Excludes the
49
- * symbol's own declaration line so a function doesn't "reference itself".
50
- */
51
- export function referencesSymbol(content, name) {
52
- const re = new RegExp(`(?<![A-Za-z0-9_$.])${escapeRe(name)}\\s*\\(`);
53
- for (const line of content.split("\n")) {
54
- if (new RegExp(`function\\s+${escapeRe(name)}\\b`).test(line))
55
- continue; // its own decl
56
- if (re.test(line))
57
- return true;
58
- }
59
- return false;
60
- }
61
- function escapeRe(s) {
62
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
63
- }
64
- /** Localize the symbol a breaking op changed, if it can be pinned down. */
65
- function brokenSymbol(op) {
66
- if (op.target.entityKind === "symbol" && op.target.entityId.includes("#")) {
67
- const [file, name] = op.target.entityId.split("#");
68
- if (file && name)
69
- return { file, name };
70
- }
71
- if (op.body.kind === "set_symbol" && op.body.path && op.body.symbolName) {
72
- return { file: op.body.path, name: op.body.symbolName };
73
- }
74
- return null;
75
- }
76
- /**
77
- * Find contract breaks: an accepted op actually CHANGED a symbol's signature (params
78
- * or return), while another accepted op references that symbol — a text-clean but
79
- * meaning-broken merge. Crucially this works whether or not the author declared
80
- * `breaksPublicApi`: it compares signatures, so it catches the *undeclared* break
81
- * the policy gate would otherwise miss. An op with trusted `api_compat=pass`
82
- * evidence is exonerated.
83
- *
84
- * `evidence` should already be the trust-filtered set. Pure over its inputs.
85
- */
86
- export function detectSemanticConflicts(ops, result, evidence, blobContent) {
87
- const accepted = ops.filter((o) => result.statuses.get(o.oid) === "accepted");
88
- const contentOf = (path) => {
89
- if (!path)
90
- return "";
91
- const oid = result.tree.get(path);
92
- if (!oid)
93
- return "";
94
- return result.synthBlobs.get(oid) ?? blobContent.get(oid) ?? "";
95
- };
96
- const blob = (oid) => (oid ? blobContent.get(oid) ?? "" : "");
97
- const hasApiCompat = (opOid) => evidence.some((e) => e.forOps.includes(opOid) && e.kind === "api_compat" && e.result === "pass");
98
- // Base signature of a symbol in a file = its signature in the put_file that
99
- // established that file (the scaffold), so we can see what a later edit changed.
100
- const baseSigFor = (file, name) => {
101
- const baseOp = accepted.find((o) => o.body.kind === "put_file" && o.body.path === file);
102
- if (!baseOp)
103
- return undefined;
104
- return signatures(blob(baseOp.body.blobOid)).get(name);
105
- };
106
- const out = [];
107
- for (const O of accepted) {
108
- // Localize the symbol this op edits and the new signature it installs.
109
- let file;
110
- let name;
111
- let newSig;
112
- if (O.body.kind === "set_symbol" && O.body.path && O.body.symbolName) {
113
- file = O.body.path;
114
- name = O.body.symbolName;
115
- newSig = signatures(blob(O.body.blobOid)).get(name);
116
- }
117
- else {
118
- const sym = brokenSymbol(O);
119
- if (sym) {
120
- file = sym.file;
121
- name = sym.name;
122
- newSig = signatures(contentOf(file)).get(name);
123
- }
124
- }
125
- if (!file || !name || !newSig)
126
- continue;
127
- const baseSig = baseSigFor(file, name);
128
- const changed = baseSig
129
- ? baseSig.params !== newSig.params || baseSig.returns !== newSig.returns
130
- : !!O.effects?.breaksPublicApi; // no base to diff → trust the declared flag
131
- if (!changed)
132
- continue;
133
- if (hasApiCompat(O.oid))
134
- continue;
135
- const dependentOps = accepted
136
- .filter((P) => P !== O && P.body.path !== file && referencesSymbol(contentOf(P.body.path), name))
137
- .map((P) => P.oid);
138
- if (dependentOps.length === 0)
139
- continue;
140
- out.push({
141
- kind: "contract_break",
142
- symbol: `${file}#${name}`,
143
- breakingOp: O.oid,
144
- dependentOps,
145
- reason: `${name}'s signature changed (${baseSig?.params ?? "?"} → ${newSig.params}), but ${dependentOps.length} accepted op(s) call it under the old contract, with no api_compat=pass evidence`,
146
- });
147
- }
148
- return out;
149
- }
150
- //# sourceMappingURL=contract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/semantic/contract.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,iFAAiF;AACjF,kFAAkF;AAClF,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,EAAE;AACF,qFAAqF;AACrF,iF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,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QAExC,GAAG,CAAC,IAAI,CAAC;YACP,IAAI,EAAE,gBAAgB;YACtB,MAAM,EAAE,GAAG,IAAI,IAAI,IAAI,EAAE;YACzB,UAAU,EAAE,CAAC,CAAC,GAAa;YAC3B,YAAY;YACZ,MAAM,EAAE,GAAG,IAAI,yBAAyB,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,UAAU,YAAY,CAAC,MAAM,kFAAkF;SACjM,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,45 +0,0 @@
1
- export interface Span {
2
- kind: "symbol" | "gap";
3
- /** Stable key within the file: the symbol name, or `@gap:<index>` for gaps. */
4
- key: string;
5
- name?: string;
6
- text: string;
7
- }
8
- export interface EntityIndexer {
9
- language: string;
10
- parse(content: string): Span[];
11
- reassemble(spans: Span[]): string;
12
- }
13
- export declare const tsIndexer: EntityIndexer;
14
- /** List the symbol names in a file (stable ids), in source order. */
15
- export declare function symbolNames(content: string, indexer?: EntityIndexer): string[];
16
- /**
17
- * Replace one symbol's text, returning the new file content. If the symbol does not
18
- * exist, it is appended. Pure and deterministic.
19
- *
20
- * D5 duplicate-guard: when the brace scanner can't find the symbol as a span but a
21
- * top-level declaration of that name DOES exist in the text (the scanner mis-parsed —
22
- * e.g. a template literal containing `}`), blindly appending would create a SECOND
23
- * definition of the symbol: a `set_symbol` meant to UPDATE silently duplicates instead.
24
- * We fall back to a column-0 declaration scan and replace the existing decl in place. A
25
- * genuinely-new symbol (no existing decl) is still appended.
26
- */
27
- export declare function spliceSymbol(content: string, symbolName: string, newText: string, indexer?: EntityIndexer): string;
28
- /**
29
- * M3 AST op: rename a top-level symbol — its declaration AND its references WITHIN
30
- * the same file. Renames only whole-identifier occurrences in CODE, deliberately
31
- * skipping strings, template-literal text, and comments (a regex `\bfrom\b` would
32
- * also rewrite `from` inside a comment or a "from" string — silent corruption; D5).
33
- * Template interpolations `${…}` are treated as code, so identifiers there ARE renamed.
34
- * Cross-file references need real reference analysis (tree-sitter) — Track C. Pure.
35
- */
36
- export declare function renameSymbol(content: string, from: string, to: string): string;
37
- /**
38
- * M3 AST op support: extract one top-level symbol's text and return it together with
39
- * the file content that remains (symbol removed). Returns null if the symbol is absent.
40
- */
41
- export declare function extractSymbol(content: string, symbolName: string, indexer?: EntityIndexer): {
42
- text: string;
43
- rest: string;
44
- } | null;
45
- //# sourceMappingURL=symbols.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"symbols.d.ts","sourceRoot":"","sources":["../../src/semantic/symbols.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,QAAQ,GAAG,KAAK,CAAC;IACvB,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,CAAC;IAC/B,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;CACnC;AA2FD,eAAO,MAAM,SAAS,EAAE,aAA6D,CAAC;AAEtF,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,aAAyB,GAAG,MAAM,EAAE,CAEzF;AAwBD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,aAAyB,GACjC,MAAM,CAYR;AAID;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAuD9E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,aAAyB,GACjC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAOvC"}
@@ -1,323 +0,0 @@
1
- // Phase 2: structured (symbol-granular) view of a source file.
2
- //
3
- // This is the seam that turns "same file" conflicts into "same symbol" conflicts.
4
- // A file is parsed into an ordered list of spans — named top-level symbols and the
5
- // gaps between them (imports, blank lines). Two operations that edit *different*
6
- // symbols of the same file then occupy different conflict keys and auto-merge (L1),
7
- // while two edits to the *same* symbol still contend.
8
- //
9
- // MVP scope: a brace/line scanner for TS/JS-shaped code. It is deliberately a
10
- // pluggable `EntityIndexer` so a Tree-sitter backend can replace it per language
11
- // without touching the reducer. It is approximate (well-formatted code), and falls
12
- // back to whole-file semantics when a file does not parse into named symbols.
13
- const DECL = /^(export\s+(default\s+)?)?(async\s+)?(function|class|interface|enum|namespace|type|const|let|var)\s+([A-Za-z0-9_$]+)/;
14
- /** Top-level declaration kinds that own a brace-delimited body. */
15
- const BRACE_FORMS = new Set(["function", "class", "interface", "enum", "namespace"]);
16
- /**
17
- * Split TS/JS source into symbol + gap spans. Brace depth is tracked across the
18
- * whole text so nested braces inside a symbol don't end it early. Strings and line
19
- * comments are handled well enough for ordinary code.
20
- */
21
- function parse(content) {
22
- const lines = content.split("\n");
23
- const spans = [];
24
- let gapBuf = [];
25
- let gapIdx = 0;
26
- const flushGap = () => {
27
- if (gapBuf.length) {
28
- spans.push({ kind: "gap", key: `@gap:${gapIdx++}`, text: gapBuf.join("\n") });
29
- gapBuf = [];
30
- }
31
- };
32
- let i = 0;
33
- while (i < lines.length) {
34
- const line = lines[i];
35
- const m = DECL.exec(line.trim());
36
- if (!m) {
37
- gapBuf.push(line);
38
- i++;
39
- continue;
40
- }
41
- const keyword = m[4];
42
- const name = m[5];
43
- flushGap();
44
- if (BRACE_FORMS.has(keyword) || /[{(]/.test(line)) {
45
- // Consume lines until brace depth returns to 0 after having opened.
46
- let depth = 0;
47
- let opened = false;
48
- const body = [];
49
- while (i < lines.length) {
50
- const l = lines[i];
51
- body.push(l);
52
- depth += braceDelta(l);
53
- if (depth > 0)
54
- opened = true;
55
- i++;
56
- if (opened && depth <= 0)
57
- break;
58
- if (!opened && /;\s*$/.test(l))
59
- break; // e.g. `const x = 1;` with parens but no block
60
- }
61
- spans.push({ kind: "symbol", key: name, name, text: body.join("\n") });
62
- }
63
- else {
64
- // Single-line / statement form (const/type/let), may span to a `;`.
65
- const body = [];
66
- while (i < lines.length) {
67
- const l = lines[i];
68
- body.push(l);
69
- i++;
70
- if (/;\s*$/.test(l) || !lines[i] || DECL.test((lines[i] ?? "").trim()))
71
- break;
72
- }
73
- spans.push({ kind: "symbol", key: name, name, text: body.join("\n") });
74
- }
75
- }
76
- flushGap();
77
- return spans;
78
- }
79
- /** Net `{`+`(` minus `}`+`)` on a line, ignoring those in strings/line comments. */
80
- function braceDelta(line) {
81
- let depth = 0;
82
- let str = null;
83
- for (let j = 0; j < line.length; j++) {
84
- const c = line[j];
85
- if (str) {
86
- if (c === "\\")
87
- j++;
88
- else if (c === str)
89
- str = null;
90
- continue;
91
- }
92
- if (c === '"' || c === "'" || c === "`")
93
- str = c;
94
- else if (c === "/" && line[j + 1] === "/")
95
- break;
96
- else if (c === "{")
97
- depth++;
98
- else if (c === "}")
99
- depth--;
100
- }
101
- return depth;
102
- }
103
- function reassemble(spans) {
104
- return spans.map((s) => s.text).join("\n");
105
- }
106
- export const tsIndexer = { language: "typescript", parse, reassemble };
107
- /** List the symbol names in a file (stable ids), in source order. */
108
- export function symbolNames(content, indexer = tsIndexer) {
109
- return indexer.parse(content).filter((s) => s.kind === "symbol").map((s) => s.name);
110
- }
111
- /** A top-level declaration line starts at column 0 (no leading whitespace). This is the
112
- * fallback used when the brace scanner fails to surface a symbol that nonetheless exists
113
- * in the text — replacing its declaration in place instead of blindly appending a
114
- * duplicate. Returns null if no top-level declaration of `name` is found. */
115
- function replaceTopLevelDecl(content, name, newText) {
116
- const lines = content.split("\n");
117
- const topDeclName = (line) => {
118
- if (!/^\S/.test(line))
119
- return null; // must be column 0
120
- const m = DECL.exec(line.trim());
121
- return m && m[5] === name ? name : null;
122
- };
123
- let start = -1;
124
- for (let i = 0; i < lines.length; i++)
125
- if (topDeclName(lines[i]) === name) {
126
- start = i;
127
- break;
128
- }
129
- if (start === -1)
130
- return null;
131
- let end = lines.length;
132
- for (let j = start + 1; j < lines.length; j++) {
133
- const l = lines[j];
134
- if (/^\S/.test(l) && DECL.test(l.trim())) {
135
- end = j;
136
- break;
137
- } // next top-level decl
138
- }
139
- return [...lines.slice(0, start), newText, ...lines.slice(end)].join("\n");
140
- }
141
- /**
142
- * Replace one symbol's text, returning the new file content. If the symbol does not
143
- * exist, it is appended. Pure and deterministic.
144
- *
145
- * D5 duplicate-guard: when the brace scanner can't find the symbol as a span but a
146
- * top-level declaration of that name DOES exist in the text (the scanner mis-parsed —
147
- * e.g. a template literal containing `}`), blindly appending would create a SECOND
148
- * definition of the symbol: a `set_symbol` meant to UPDATE silently duplicates instead.
149
- * We fall back to a column-0 declaration scan and replace the existing decl in place. A
150
- * genuinely-new symbol (no existing decl) is still appended.
151
- */
152
- export function spliceSymbol(content, symbolName, newText, indexer = tsIndexer) {
153
- const spans = indexer.parse(content);
154
- const idx = spans.findIndex((s) => s.kind === "symbol" && s.name === symbolName);
155
- if (idx !== -1) {
156
- spans[idx] = { kind: "symbol", key: symbolName, name: symbolName, text: newText };
157
- return indexer.reassemble(spans);
158
- }
159
- // Not found as a span. Avoid a duplicate definition if the decl actually exists.
160
- const replaced = replaceTopLevelDecl(content, symbolName, newText);
161
- if (replaced !== null)
162
- return replaced;
163
- spans.push({ kind: "symbol", key: symbolName, name: symbolName, text: newText });
164
- return indexer.reassemble(spans);
165
- }
166
- const isIdChar = (c) => c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9" || c === "_" || c === "$";
167
- /**
168
- * M3 AST op: rename a top-level symbol — its declaration AND its references WITHIN
169
- * the same file. Renames only whole-identifier occurrences in CODE, deliberately
170
- * skipping strings, template-literal text, and comments (a regex `\bfrom\b` would
171
- * also rewrite `from` inside a comment or a "from" string — silent corruption; D5).
172
- * Template interpolations `${…}` are treated as code, so identifiers there ARE renamed.
173
- * Cross-file references need real reference analysis (tree-sitter) — Track C. Pure.
174
- */
175
- export function renameSymbol(content, from, to) {
176
- if (!from || !to || from === to)
177
- return content;
178
- const stack = [{ k: "code", interp: false, depth: 0 }];
179
- let out = "";
180
- let i = 0;
181
- const n = content.length;
182
- while (i < n) {
183
- const m = stack[stack.length - 1];
184
- const c = content[i];
185
- const c2 = content[i + 1];
186
- if (m.k === "code") {
187
- if (c === "/" && c2 === "/") {
188
- out += "//";
189
- i += 2;
190
- stack.push({ k: "line" });
191
- continue;
192
- }
193
- if (c === "/" && c2 === "*") {
194
- out += "/*";
195
- i += 2;
196
- stack.push({ k: "block" });
197
- continue;
198
- }
199
- if (c === "'") {
200
- out += c;
201
- i++;
202
- stack.push({ k: "sq" });
203
- continue;
204
- }
205
- if (c === '"') {
206
- out += c;
207
- i++;
208
- stack.push({ k: "dq" });
209
- continue;
210
- }
211
- if (c === "`") {
212
- out += c;
213
- i++;
214
- stack.push({ k: "tmpl" });
215
- continue;
216
- }
217
- if (m.interp && c === "{") {
218
- m.depth++;
219
- out += c;
220
- i++;
221
- continue;
222
- }
223
- if (m.interp && c === "}") {
224
- if (m.depth === 0) {
225
- stack.pop();
226
- out += c;
227
- i++;
228
- continue;
229
- } // closes ${…} → back to tmpl
230
- m.depth--;
231
- out += c;
232
- i++;
233
- continue;
234
- }
235
- if (isIdChar(c) && !(c >= "0" && c <= "9")) {
236
- let j = i;
237
- while (j < n && isIdChar(content[j]))
238
- j++;
239
- const word = content.slice(i, j);
240
- out += word === from ? to : word;
241
- i = j;
242
- continue;
243
- }
244
- if (isIdChar(c)) { // a numeric/identifier run starting with a digit — never a rename target
245
- let j = i;
246
- while (j < n && isIdChar(content[j]))
247
- j++;
248
- out += content.slice(i, j);
249
- i = j;
250
- continue;
251
- }
252
- out += c;
253
- i++;
254
- continue;
255
- }
256
- if (m.k === "line") {
257
- out += c;
258
- i++;
259
- if (c === "\n")
260
- stack.pop();
261
- continue;
262
- }
263
- if (m.k === "block") {
264
- if (c === "*" && c2 === "/") {
265
- out += "*/";
266
- i += 2;
267
- stack.pop();
268
- continue;
269
- }
270
- out += c;
271
- i++;
272
- continue;
273
- }
274
- if (m.k === "sq" || m.k === "dq") {
275
- const q = m.k === "sq" ? "'" : '"';
276
- if (c === "\\") {
277
- out += content.slice(i, i + 2);
278
- i += 2;
279
- continue;
280
- }
281
- out += c;
282
- i++;
283
- if (c === q)
284
- stack.pop();
285
- continue;
286
- }
287
- // template literal
288
- if (c === "\\") {
289
- out += content.slice(i, i + 2);
290
- i += 2;
291
- continue;
292
- }
293
- if (c === "`") {
294
- out += c;
295
- i++;
296
- stack.pop();
297
- continue;
298
- }
299
- if (c === "$" && c2 === "{") {
300
- out += "${";
301
- i += 2;
302
- stack.push({ k: "code", interp: true, depth: 0 });
303
- continue;
304
- }
305
- out += c;
306
- i++;
307
- }
308
- return out;
309
- }
310
- /**
311
- * M3 AST op support: extract one top-level symbol's text and return it together with
312
- * the file content that remains (symbol removed). Returns null if the symbol is absent.
313
- */
314
- export function extractSymbol(content, symbolName, indexer = tsIndexer) {
315
- const spans = indexer.parse(content);
316
- const idx = spans.findIndex((s) => s.kind === "symbol" && s.name === symbolName);
317
- if (idx === -1)
318
- return null;
319
- const text = spans[idx].text;
320
- const rest = indexer.reassemble(spans.filter((_, i) => i !== idx));
321
- return { text, rest };
322
- }
323
- //# sourceMappingURL=symbols.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"symbols.js","sourceRoot":"","sources":["../../src/semantic/symbols.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,EAAE;AACF,k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