@agentshouse/mdmodel 0.1.0-ce8ce7ff57e88 → 0.1.0-cf26f43c2e4d9
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/API.md +85 -75
- package/README.md +1 -1
- package/dist/blocks.d.ts.map +1 -1
- package/dist/blocks.js +29 -7
- package/dist/condition.d.ts +23 -9
- package/dist/condition.d.ts.map +1 -1
- package/dist/condition.js +202 -86
- package/dist/definition.d.ts +2 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +96 -20
- package/dist/divide.js +9 -9
- package/dist/document.d.ts +4 -4
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +38 -38
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/links.d.ts +1 -0
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +85 -39
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -1
- package/dist/pattern.d.ts +10 -0
- package/dist/pattern.d.ts.map +1 -0
- package/dist/pattern.js +355 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +3 -5
- package/dist/schema.d.ts +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +55 -4
- package/dist/types.d.ts +9 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +25 -4
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +163 -65
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +27 -1
- package/fixtures/README.md +9 -4
- package/fixtures/cases/conditional-section/context.json +1 -0
- package/fixtures/cases/conditional-section/expected.json +6 -0
- package/fixtures/cases/conditional-section/library/questions/hosting.md +9 -0
- package/fixtures/cases/conditional-section/library/questions/payments.md +12 -0
- package/fixtures/cases/conditional-section/schema.yaml +14 -0
- package/fixtures/division.json +26 -26
- package/package.json +7 -2
package/dist/divide.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { blockRanges, headingLines } from './blocks.js';
|
|
2
2
|
import { firstEditFrom, projectionInput, rangeText, } from './project.js';
|
|
3
3
|
import { refusal } from './refuse.js';
|
|
4
|
-
const
|
|
4
|
+
const SMALLEST_BOUND = 2;
|
|
5
5
|
function node(draft) {
|
|
6
6
|
return {
|
|
7
7
|
start: draft.start,
|
|
@@ -86,8 +86,8 @@ function isTrailingSurrogate(text, index) {
|
|
|
86
86
|
function characterLength(text, index) {
|
|
87
87
|
return isTrailingSurrogate(text, index + 1) ? 2 : 1;
|
|
88
88
|
}
|
|
89
|
-
function boundOf(cutting, from, to,
|
|
90
|
-
const limit = from +
|
|
89
|
+
function boundOf(cutting, from, to, bound) {
|
|
90
|
+
const limit = from + bound;
|
|
91
91
|
if (limit >= to)
|
|
92
92
|
return to;
|
|
93
93
|
for (let index = limit; index > from + 1; index -= 1) {
|
|
@@ -168,12 +168,12 @@ function valueCutting(value) {
|
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
function prefixOf(state, body) {
|
|
171
|
-
if (body.emitted === 0 || body.heading.length >= state.
|
|
171
|
+
if (body.emitted === 0 || body.heading.length >= state.bound)
|
|
172
172
|
return '';
|
|
173
173
|
return body.heading;
|
|
174
174
|
}
|
|
175
175
|
function available(state, body) {
|
|
176
|
-
return state.
|
|
176
|
+
return state.bound - prefixOf(state, body).length;
|
|
177
177
|
}
|
|
178
178
|
function emit(state, body, piece, bare = false) {
|
|
179
179
|
if (piece.text.trim() === '')
|
|
@@ -216,7 +216,7 @@ function divideBound(state, body, cutting, range) {
|
|
|
216
216
|
let start = range.start;
|
|
217
217
|
while (start < range.end) {
|
|
218
218
|
const bare = available(state, body) < characterLength(cutting.text, start);
|
|
219
|
-
const room = bare ? state.
|
|
219
|
+
const room = bare ? state.bound : available(state, body);
|
|
220
220
|
const stop = boundOf(cutting, start, range.end, room);
|
|
221
221
|
const piece = cutting.piece(start, stop);
|
|
222
222
|
if (cutting.masks.length === 0 || piece.text.length <= room) {
|
|
@@ -303,8 +303,8 @@ function divideInput(state, input) {
|
|
|
303
303
|
]);
|
|
304
304
|
}
|
|
305
305
|
export function divide(document, file, context) {
|
|
306
|
-
if (!Number.isInteger(context.
|
|
307
|
-
return { ok: false, refusal: refusal(file, 'division-
|
|
306
|
+
if (!Number.isInteger(context.bound) || context.bound < SMALLEST_BOUND) {
|
|
307
|
+
return { ok: false, refusal: refusal(file, 'division-bound') };
|
|
308
308
|
}
|
|
309
309
|
const result = projectionInput(document, file, context);
|
|
310
310
|
if (!result.ok)
|
|
@@ -312,7 +312,7 @@ export function divide(document, file, context) {
|
|
|
312
312
|
const state = {
|
|
313
313
|
content: document.content,
|
|
314
314
|
edits: result.input.edits,
|
|
315
|
-
|
|
315
|
+
bound: context.bound,
|
|
316
316
|
spans: [],
|
|
317
317
|
};
|
|
318
318
|
divideInput(state, result.input);
|
package/dist/document.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { type Definition } from './definition.js';
|
|
2
|
-
import
|
|
2
|
+
import { type LinkInventory } from './links.js';
|
|
3
|
+
import type { ApplyResult, BodyResult, FrontmatterResult, Change, Document, Link, ParseResult } from './types.js';
|
|
3
4
|
import { type YamlMap } from './yaml.js';
|
|
5
|
+
export declare function inventoryOf(document: Document): LinkInventory;
|
|
4
6
|
export declare function parseFrontmatter(content: string, file?: string): FrontmatterResult;
|
|
5
7
|
export declare function parse(content: string, file?: string): ParseResult;
|
|
6
|
-
export declare function relativize(document: Document, file: string, handle: string, definition?: Definition): ApplyResult;
|
|
8
|
+
export declare function relativize(document: Document, file: string, handle: string, definition?: Definition, kept?: ReadonlySet<string>): ApplyResult;
|
|
7
9
|
export declare function relativizeBody(body: string, file: string, handle: string): BodyResult;
|
|
8
10
|
export declare function relinkBody(body: string, file: string, moves: ReadonlyMap<string, string>): BodyResult;
|
|
9
11
|
export declare function links(document: Document, file: string): readonly Link[];
|
|
10
|
-
export declare function linkOccurrences(document: Document, file: string): readonly LinkOccurrence[];
|
|
11
12
|
export declare function bodyLinks(body: string, file: string): readonly Link[];
|
|
12
13
|
export declare function apply(document: Document, changes: readonly Change[]): ApplyResult;
|
|
13
14
|
export declare function serialize(document: Document): string;
|
|
14
|
-
export declare function fieldStart(document: Document, pointer: string): number | undefined;
|
|
15
15
|
export declare function frontmatter(document: Document): YamlMap | null;
|
|
16
16
|
//# sourceMappingURL=document.d.ts.map
|
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AAcpB,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAcL,KAAK,OAAO,EAEb,MAAM,WAAW,CAAC;AAgBnB,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,CAM7D;AAgED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,iBAAiB,CAW9E;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,WAAW,CAgB7D;AAmED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,UAAU,EACvB,IAAI,GAAE,WAAW,CAAC,MAAM,CAAa,GACpC,WAAW,CAuBb;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAUrF;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC,UAAU,CAkBZ;AAeD,wBAAgB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,IAAI,EAAE,CAEvE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,IAAI,EAAE,CAErE;AA4LD,wBAAgB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,WAAW,CA4CjF;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAEpD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAE9D"}
|
package/dist/document.js
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
import { ARRAY_INDEX, pointerSegments } from './definition.js';
|
|
2
|
-
import { hrefOccurrences } from './links.js';
|
|
2
|
+
import { destinations, hrefOccurrences, linkInventory, } from './links.js';
|
|
3
3
|
import { destinationPath, relative, retarget, roomPath, roomTarget, SHELL_ROOMS, shellTarget, target, } from './paths.js';
|
|
4
4
|
import { references } from './references.js';
|
|
5
5
|
import { headingSpans, sectionsRecord } from './sections.js';
|
|
6
6
|
import { refusal } from './refuse.js';
|
|
7
7
|
import { bodyStartAfterYaml, bodyStartOf, equalValue, extractFrontmatter, frontmatterValue, jsValue, lineEnding, mapEntry, parseYamlMapping, serializeJs, serializeKey, YamlError, } from './yaml.js';
|
|
8
|
-
const
|
|
8
|
+
const HELD = Symbol('held');
|
|
9
|
+
function heldOf(document) {
|
|
10
|
+
return document[HELD];
|
|
11
|
+
}
|
|
12
|
+
export function inventoryOf(document) {
|
|
13
|
+
const held = heldOf(document);
|
|
14
|
+
if (held?.inventory !== undefined)
|
|
15
|
+
return held.inventory;
|
|
16
|
+
const inventory = linkInventory(document.content.slice(bodyStartOf(document.content)));
|
|
17
|
+
if (held !== undefined)
|
|
18
|
+
held.inventory = inventory;
|
|
19
|
+
return inventory;
|
|
20
|
+
}
|
|
9
21
|
function refuse(file, rule, location) {
|
|
10
22
|
return location === undefined ? refusal(file, rule) : refusal(file, rule, { location });
|
|
11
23
|
}
|
|
12
24
|
function freezeDocument(content, type, fields, preamble, sections, internal) {
|
|
13
|
-
const
|
|
25
|
+
const held = { internal, inventory: undefined };
|
|
26
|
+
return Object.freeze(Object.defineProperty({
|
|
14
27
|
content,
|
|
15
28
|
type,
|
|
16
29
|
fields: Object.freeze(fields),
|
|
17
30
|
preamble,
|
|
18
31
|
sections: Object.freeze(sections),
|
|
19
|
-
});
|
|
20
|
-
internals.set(document, internal);
|
|
21
|
-
return document;
|
|
32
|
+
}, HELD, { value: held }));
|
|
22
33
|
}
|
|
23
34
|
function declaredType(fields) {
|
|
24
35
|
const value = fields.type;
|
|
@@ -141,12 +152,16 @@ function scalarText(source, value) {
|
|
|
141
152
|
return JSON.stringify(value);
|
|
142
153
|
return serializeJs(value);
|
|
143
154
|
}
|
|
144
|
-
export function relativize(document, file, handle, definition) {
|
|
155
|
+
export function relativize(document, file, handle, definition, kept = new Set()) {
|
|
156
|
+
const relativized = (href) => {
|
|
157
|
+
const path = shellTarget(href, handle);
|
|
158
|
+
return path === null || kept.has(`${SHELL_ROOMS}${handle}/${path}`) ? null : path;
|
|
159
|
+
};
|
|
145
160
|
const changes = [];
|
|
146
161
|
for (const { pointer, value } of definition === undefined
|
|
147
162
|
? []
|
|
148
163
|
: references(document, definition)) {
|
|
149
|
-
const path =
|
|
164
|
+
const path = relativized(value);
|
|
150
165
|
if (path !== null)
|
|
151
166
|
changes.push({
|
|
152
167
|
kind: 'reference',
|
|
@@ -155,9 +170,8 @@ export function relativize(document, file, handle, definition) {
|
|
|
155
170
|
prior: value,
|
|
156
171
|
});
|
|
157
172
|
}
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
const path = shellTarget(href, handle);
|
|
173
|
+
for (const href of new Set(destinations(inventoryOf(document)).map(({ href }) => href))) {
|
|
174
|
+
const path = relativized(href);
|
|
161
175
|
if (path !== null)
|
|
162
176
|
changes.push({ kind: 'link', href, to: relative(file, path) });
|
|
163
177
|
}
|
|
@@ -180,7 +194,7 @@ export function relinkBody(body, file, moves) {
|
|
|
180
194
|
const to = from === null ? undefined : moves.get(from);
|
|
181
195
|
if (to === undefined)
|
|
182
196
|
continue;
|
|
183
|
-
const written = retarget(match.href, from.startsWith(SHELL_ROOMS) ? to : relative(file, to));
|
|
197
|
+
const written = retarget(match.href, from.startsWith(SHELL_ROOMS) || to.startsWith(SHELL_ROOMS) ? to : relative(file, to));
|
|
184
198
|
const text = destinationText(written, match.bracketed);
|
|
185
199
|
if (text === null)
|
|
186
200
|
return { outcome: 'refuse', refusal: refuse(file, 'unwritable-link', written) };
|
|
@@ -189,40 +203,30 @@ export function relinkBody(body, file, moves) {
|
|
|
189
203
|
}
|
|
190
204
|
return { outcome: 'applied', body: rewritten + body.slice(cursor) };
|
|
191
205
|
}
|
|
192
|
-
function
|
|
193
|
-
const found = [];
|
|
194
|
-
for (const occurrence of hrefOccurrences(text)) {
|
|
195
|
-
const resolved = target(file, occurrence.href);
|
|
196
|
-
if (resolved !== null)
|
|
197
|
-
found.push({ href: occurrence.href, target: resolved, start: offset + occurrence.start });
|
|
198
|
-
}
|
|
199
|
-
return found;
|
|
200
|
-
}
|
|
201
|
-
function linksIn(text, file) {
|
|
206
|
+
function linksIn(occurrences, file) {
|
|
202
207
|
const found = [];
|
|
203
208
|
const seen = new Set();
|
|
204
|
-
for (const occurrence of
|
|
209
|
+
for (const occurrence of occurrences) {
|
|
205
210
|
if (seen.has(occurrence.href))
|
|
206
211
|
continue;
|
|
212
|
+
const resolved = target(file, occurrence.href);
|
|
213
|
+
if (resolved === null)
|
|
214
|
+
continue;
|
|
207
215
|
seen.add(occurrence.href);
|
|
208
|
-
found.push({ href: occurrence.href, target:
|
|
216
|
+
found.push({ href: occurrence.href, target: resolved });
|
|
209
217
|
}
|
|
210
218
|
return found;
|
|
211
219
|
}
|
|
212
220
|
export function links(document, file) {
|
|
213
|
-
return linksIn(
|
|
214
|
-
}
|
|
215
|
-
export function linkOccurrences(document, file) {
|
|
216
|
-
const bodyStart = bodyStartOf(document.content);
|
|
217
|
-
return occurrencesIn(document.content.slice(bodyStart), file, bodyStart);
|
|
221
|
+
return linksIn(destinations(inventoryOf(document)), file);
|
|
218
222
|
}
|
|
219
223
|
export function bodyLinks(body, file) {
|
|
220
|
-
return linksIn(body, file);
|
|
224
|
+
return linksIn(hrefOccurrences(body), file);
|
|
221
225
|
}
|
|
222
226
|
function internalOf(document) {
|
|
223
|
-
const held =
|
|
227
|
+
const held = heldOf(document);
|
|
224
228
|
if (held !== undefined)
|
|
225
|
-
return held;
|
|
229
|
+
return held.internal;
|
|
226
230
|
const read = opened(document.content, '');
|
|
227
231
|
if (!read.ok)
|
|
228
232
|
return read.refusal;
|
|
@@ -303,7 +307,7 @@ function planner(document, internal) {
|
|
|
303
307
|
const link = (href, to, at) => {
|
|
304
308
|
if (occurrences === undefined) {
|
|
305
309
|
occurrences = new Map();
|
|
306
|
-
for (const occurrence of
|
|
310
|
+
for (const occurrence of destinations(inventoryOf(document))) {
|
|
307
311
|
const same = occurrences.get(occurrence.href);
|
|
308
312
|
if (same === undefined)
|
|
309
313
|
occurrences.set(occurrence.href, [occurrence]);
|
|
@@ -458,10 +462,6 @@ export function apply(document, changes) {
|
|
|
458
462
|
export function serialize(document) {
|
|
459
463
|
return document.content;
|
|
460
464
|
}
|
|
461
|
-
export function fieldStart(document, pointer) {
|
|
462
|
-
const root = internals.get(document)?.root;
|
|
463
|
-
return root === null || root === undefined ? undefined : nodeAt(root, pointer)?.start;
|
|
464
|
-
}
|
|
465
465
|
export function frontmatter(document) {
|
|
466
|
-
return
|
|
466
|
+
return heldOf(document)?.internal.root ?? null;
|
|
467
467
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
export { dated, datePointers, factKind, facts, fires, holds, instant, itemFires, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
|
|
2
|
-
export type { Actor, Condition, ConditionScope, ConditionTest, ConditionValue, CronCondition, DateCondition, DocumentCondition, DocumentEvent, DocumentFacts, Fact, FactKind, ItemCondition, ItemFacts, Resolved, WriteDoor, } from './condition.js';
|
|
1
|
+
export { ACTOR_PATHS, actorOperators, changeFields, CONDITION_OPERATORS, dated, datePointers, DOCUMENT_PATHS, factKind, facts, fires, holds, instant, ITEM_PATHS, itemFires, itemKind, itemOperators, memberPointers, members, pointed, prosePaths, testOperators, TEXT_FIELD, valuedChange, WRITE_DOORS, } from './condition.js';
|
|
2
|
+
export type { Actor, Condition, ConditionOperator, ConditionScope, ConditionTest, ConditionValue, CronCondition, DateCondition, DocumentCondition, DocumentEvent, DocumentFacts, Fact, FactKind, ItemCondition, ItemFacts, Resolved, WriteDoor, } from './condition.js';
|
|
3
3
|
export { headingLines } from './blocks.js';
|
|
4
4
|
export type { HeadingLine } from './blocks.js';
|
|
5
5
|
export { divide } from './divide.js';
|
|
6
|
-
export { apply, bodyLinks,
|
|
6
|
+
export { apply, bodyLinks, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
|
|
7
7
|
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
8
8
|
export { relative, retarget, roomPath, roomTarget, target } from './paths.js';
|
|
9
9
|
export type { RoomTarget } from './paths.js';
|
|
10
10
|
export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
11
11
|
export { project } from './project.js';
|
|
12
12
|
export { references } from './references.js';
|
|
13
|
-
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
13
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
14
14
|
export type { Definition, FieldRules, JsonType, PatternFacts, PointerFacts, RuleValue, SectionSpec, Shape, Transition, ValueFacts, } from './definition.js';
|
|
15
|
-
export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link,
|
|
16
|
-
export { bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verify, } from './validate.js';
|
|
15
|
+
export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, RoomReference, Span, Validation, ValidationContext, ValidationStep, VerifiedModel, } from './types.js';
|
|
16
|
+
export { assess, bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verdicts, verify, } from './validate.js';
|
|
17
|
+
export type { Assessment, Verdicts } from './validate.js';
|
|
17
18
|
export { VERSION } from './version.js';
|
|
18
19
|
export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
|
|
19
20
|
export type { FrontmatterValue } from './yaml.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,KAAK,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,QAAQ,EACR,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,KAAK,EACL,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,KAAK,EACL,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,UAAU,EACV,SAAS,EACT,QAAQ,EACR,aAAa,EACb,cAAc,EACd,OAAO,EACP,OAAO,EACP,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,KAAK,EACL,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,QAAQ,EACR,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,KAAK,EACL,SAAS,EACT,KAAK,EACL,KAAK,EACL,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,UAAU,EACV,SAAS,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C;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC/E,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { dated, datePointers, factKind, facts, fires, holds, instant, itemFires, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
|
|
1
|
+
export { ACTOR_PATHS, actorOperators, changeFields, CONDITION_OPERATORS, dated, datePointers, DOCUMENT_PATHS, factKind, facts, fires, holds, instant, ITEM_PATHS, itemFires, itemKind, itemOperators, memberPointers, members, pointed, prosePaths, testOperators, TEXT_FIELD, valuedChange, WRITE_DOORS, } from './condition.js';
|
|
2
2
|
export { headingLines } from './blocks.js';
|
|
3
3
|
export { divide } from './divide.js';
|
|
4
|
-
export { apply, bodyLinks,
|
|
4
|
+
export { apply, bodyLinks, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
|
|
5
5
|
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
6
6
|
export { relative, retarget, roomPath, roomTarget, target } from './paths.js';
|
|
7
7
|
export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
8
8
|
export { project } from './project.js';
|
|
9
9
|
export { references } from './references.js';
|
|
10
|
-
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
11
|
-
export { bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verify, } from './validate.js';
|
|
10
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
11
|
+
export { assess, bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verdicts, verify, } from './validate.js';
|
|
12
12
|
export { VERSION } from './version.js';
|
|
13
13
|
export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
|
package/dist/links.d.ts
CHANGED
|
@@ -24,5 +24,6 @@ export type LinkInventory = {
|
|
|
24
24
|
};
|
|
25
25
|
export declare function fenceSpans(text: string): readonly (readonly [number, number])[];
|
|
26
26
|
export declare function linkInventory(body: string): LinkInventory;
|
|
27
|
+
export declare function destinations(inventory: LinkInventory): readonly HrefOccurrence[];
|
|
27
28
|
export declare function hrefOccurrences(body: string): readonly HrefOccurrence[];
|
|
28
29
|
//# sourceMappingURL=links.d.ts.map
|
package/dist/links.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAgiBA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAE5D;AAyLD,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,GAC5C,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAOvC;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UA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:[^ \\t\\n\\v\\f\\r"\'=<>`]+|\'[^\']*\'|"[^"]*"))?)*[ \\t\\n\\v\\f\\r]*\\/?>',
|
|
22
22
|
'<\\/[A-Za-z][A-Za-z0-9-]*[ \\t\\n\\v\\f\\r]*>',
|
|
23
23
|
'<!--(?!-?>)(?:-?[^-])*-->',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'<!\\[CDATA\\[[\\s\\S]*?\\]\\]>',
|
|
24
|
+
].join('|'), 'y');
|
|
25
|
+
const AUTOLINK = new RegExp([
|
|
27
26
|
'<[A-Za-z][A-Za-z0-9+.-]{1,31}:[^\\x00-\\x20<>]*>',
|
|
28
27
|
"<[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*>",
|
|
29
28
|
].join('|'), 'y');
|
|
30
|
-
const
|
|
29
|
+
const DECLARATION = /<![A-Z]+[ \t\n\v\f\r]/y;
|
|
30
|
+
const INSTRUCTION = '<?';
|
|
31
|
+
const CDATA = '<![CDATA[';
|
|
32
|
+
const BACKSLASH = 0x5c;
|
|
33
|
+
const BACKTICK = 0x60;
|
|
34
|
+
const LINE_FEED = 0x0a;
|
|
35
|
+
const CARRIAGE_RETURN = 0x0d;
|
|
36
|
+
const LESS_THAN = 0x3c;
|
|
37
|
+
const OPEN_BRACKET = 0x5b;
|
|
38
|
+
const CLOSE_BRACKET = 0x5d;
|
|
39
|
+
const EXCLAMATION = 0x21;
|
|
40
|
+
const OPEN_PAREN = 0x28;
|
|
41
|
+
const DELIMITER_ROW = /^\|?[ \t]*:?-+:?(?:[ \t]*\|[ \t]*:?-+:?)*(?:[ \t]*\|)?[ \t]*$/;
|
|
31
42
|
const GAP = /^[ \t\v\f]+/;
|
|
32
43
|
function endOfLine(text, from) {
|
|
33
44
|
const nl = text.indexOf('\n', from);
|
|
@@ -164,10 +175,10 @@ function skipInlineCode(text, index, joins, unclosed) {
|
|
|
164
175
|
const runs = new Map();
|
|
165
176
|
let i = index + ticks;
|
|
166
177
|
while (i < text.length) {
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
178
|
+
const code = text.charCodeAt(i);
|
|
179
|
+
if (code === BACKTICK) {
|
|
169
180
|
let run = 0;
|
|
170
|
-
while (text
|
|
181
|
+
while (text.charCodeAt(i + run) === BACKTICK)
|
|
171
182
|
run += 1;
|
|
172
183
|
if (run === ticks)
|
|
173
184
|
return i + run;
|
|
@@ -175,9 +186,9 @@ function skipInlineCode(text, index, joins, unclosed) {
|
|
|
175
186
|
i += run;
|
|
176
187
|
continue;
|
|
177
188
|
}
|
|
178
|
-
if (
|
|
189
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(i + 1) !== LINE_FEED)
|
|
179
190
|
break;
|
|
180
|
-
if (
|
|
191
|
+
if (code === LINE_FEED && !joins.has(i))
|
|
181
192
|
break;
|
|
182
193
|
i += 1;
|
|
183
194
|
}
|
|
@@ -200,21 +211,21 @@ function skipInlineSpace(text, start, joins) {
|
|
|
200
211
|
return afterIndent(text, readLine(text, i + 1, endOfLine(text, i + 1)));
|
|
201
212
|
}
|
|
202
213
|
function closeEnd(text, start, open, joins) {
|
|
203
|
-
const close = open === '(' ? ')' : open;
|
|
214
|
+
const close = (open === '(' ? ')' : open).charCodeAt(0);
|
|
204
215
|
let i = start;
|
|
205
216
|
while (i < text.length) {
|
|
206
|
-
const
|
|
217
|
+
const code = text.charCodeAt(i);
|
|
207
218
|
if (escapes(text, i)) {
|
|
208
219
|
i += 2;
|
|
209
220
|
continue;
|
|
210
221
|
}
|
|
211
|
-
if (
|
|
222
|
+
if (code === close)
|
|
212
223
|
return i + 1;
|
|
213
|
-
if (open === '(' &&
|
|
224
|
+
if (open === '(' && code === OPEN_PAREN)
|
|
214
225
|
return null;
|
|
215
|
-
if (
|
|
226
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(i + 1) !== LINE_FEED)
|
|
216
227
|
return null;
|
|
217
|
-
if (
|
|
228
|
+
if (code === LINE_FEED && !joins.has(i))
|
|
218
229
|
return null;
|
|
219
230
|
i += 1;
|
|
220
231
|
}
|
|
@@ -511,23 +522,23 @@ function structure(text) {
|
|
|
511
522
|
return { joins, raw };
|
|
512
523
|
}
|
|
513
524
|
export function escapes(text, index) {
|
|
514
|
-
return text
|
|
525
|
+
return text.charCodeAt(index) === BACKSLASH && PUNCTUATION.test(text[index + 1] ?? '');
|
|
515
526
|
}
|
|
516
527
|
function referenceEnd(text, start, joins) {
|
|
517
528
|
let i = start;
|
|
518
529
|
while (i < text.length) {
|
|
519
|
-
const
|
|
530
|
+
const code = text.charCodeAt(i);
|
|
520
531
|
if (escapes(text, i)) {
|
|
521
532
|
i += 2;
|
|
522
533
|
continue;
|
|
523
534
|
}
|
|
524
|
-
if (
|
|
535
|
+
if (code === CLOSE_BRACKET)
|
|
525
536
|
return i + 1;
|
|
526
|
-
if (
|
|
537
|
+
if (code === OPEN_BRACKET)
|
|
527
538
|
return -1;
|
|
528
|
-
if (
|
|
539
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(i + 1) !== LINE_FEED)
|
|
529
540
|
return -1;
|
|
530
|
-
if (
|
|
541
|
+
if (code === LINE_FEED && !joins.has(i))
|
|
531
542
|
return -1;
|
|
532
543
|
i += 1;
|
|
533
544
|
}
|
|
@@ -702,14 +713,45 @@ export function fenceSpans(text) {
|
|
|
702
713
|
function paragraphEnd(text, from, joins) {
|
|
703
714
|
let i = from;
|
|
704
715
|
while (i < text.length) {
|
|
705
|
-
|
|
716
|
+
const code = text.charCodeAt(i);
|
|
717
|
+
if (code === LINE_FEED && !joins.has(i))
|
|
706
718
|
return i;
|
|
707
|
-
if (
|
|
719
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(i + 1) !== LINE_FEED)
|
|
708
720
|
return i;
|
|
709
721
|
i += 1;
|
|
710
722
|
}
|
|
711
723
|
return i;
|
|
712
724
|
}
|
|
725
|
+
function closerAt(text, closer, from, closers) {
|
|
726
|
+
const held = closers.get(closer);
|
|
727
|
+
if (held !== undefined && from >= held[0] && (held[1] === -1 || from <= held[1]))
|
|
728
|
+
return held[1];
|
|
729
|
+
const at = text.indexOf(closer, from);
|
|
730
|
+
closers.set(closer, [from, at]);
|
|
731
|
+
return at;
|
|
732
|
+
}
|
|
733
|
+
function closedAfter(text, closer, from, closers) {
|
|
734
|
+
const at = closerAt(text, closer, from, closers);
|
|
735
|
+
return at === -1 ? -1 : at + closer.length;
|
|
736
|
+
}
|
|
737
|
+
function stuck(pattern, text, at) {
|
|
738
|
+
pattern.lastIndex = at;
|
|
739
|
+
return pattern.test(text) ? pattern.lastIndex : -1;
|
|
740
|
+
}
|
|
741
|
+
function markupEnd(text, at, closers) {
|
|
742
|
+
if (text.startsWith(INSTRUCTION, at))
|
|
743
|
+
return closedAfter(text, '?>', at + INSTRUCTION.length, closers);
|
|
744
|
+
if (text.startsWith(CDATA, at))
|
|
745
|
+
return closedAfter(text, ']]>', at + CDATA.length, closers);
|
|
746
|
+
const declared = stuck(DECLARATION, text, at);
|
|
747
|
+
if (declared !== -1)
|
|
748
|
+
return closedAfter(text, '>', declared, closers);
|
|
749
|
+
return stuck(INLINE_TAG, text, at);
|
|
750
|
+
}
|
|
751
|
+
function inlineRawEnd(text, at, closers) {
|
|
752
|
+
const end = markupEnd(text, at, closers);
|
|
753
|
+
return end === -1 ? stuck(AUTOLINK, text, at) : end;
|
|
754
|
+
}
|
|
713
755
|
export function linkInventory(body) {
|
|
714
756
|
const { raw, definitions, blocks, joins } = scanBlocks(body);
|
|
715
757
|
const rawEnd = spanCursor(raw);
|
|
@@ -717,7 +759,7 @@ export function linkInventory(body) {
|
|
|
717
759
|
const uses = [];
|
|
718
760
|
const openers = [];
|
|
719
761
|
const unclosed = { stop: 0, runs: new Map() };
|
|
720
|
-
let paragraph = { start: 0, end: -1, text: '' };
|
|
762
|
+
let paragraph = { start: 0, end: -1, text: '', closers: new Map() };
|
|
721
763
|
let i = 0;
|
|
722
764
|
while (i < body.length) {
|
|
723
765
|
const skipEnd = rawEnd(i) ?? blockEnd(i);
|
|
@@ -726,39 +768,40 @@ export function linkInventory(body) {
|
|
|
726
768
|
i = skipEnd;
|
|
727
769
|
continue;
|
|
728
770
|
}
|
|
729
|
-
const
|
|
771
|
+
const code = body.charCodeAt(i);
|
|
730
772
|
if (escapes(body, i)) {
|
|
731
773
|
i += 2;
|
|
732
774
|
continue;
|
|
733
775
|
}
|
|
734
|
-
if (
|
|
776
|
+
if (code === BACKTICK) {
|
|
735
777
|
i = skipInlineCode(body, i, joins, unclosed);
|
|
736
778
|
continue;
|
|
737
779
|
}
|
|
738
|
-
if (
|
|
780
|
+
if (code === LESS_THAN) {
|
|
739
781
|
if (i >= paragraph.end) {
|
|
740
782
|
const end = paragraphEnd(body, i, joins);
|
|
741
|
-
paragraph = { start: i, end, text: body.slice(i, end) };
|
|
783
|
+
paragraph = { start: i, end, text: body.slice(i, end), closers: new Map() };
|
|
742
784
|
}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
i += raw[0].length;
|
|
785
|
+
const raw = inlineRawEnd(paragraph.text, i - paragraph.start, paragraph.closers);
|
|
786
|
+
if (raw !== -1) {
|
|
787
|
+
i = paragraph.start + raw;
|
|
747
788
|
continue;
|
|
748
789
|
}
|
|
749
790
|
}
|
|
750
|
-
if ((
|
|
791
|
+
if ((code === LINE_FEED && !joins.has(i)) ||
|
|
792
|
+
(code === CARRIAGE_RETURN && body.charCodeAt(i + 1) !== LINE_FEED))
|
|
751
793
|
openers.length = 0;
|
|
752
|
-
if (
|
|
794
|
+
if (code === OPEN_BRACKET ||
|
|
795
|
+
(code === EXCLAMATION && body.charCodeAt(i + 1) === OPEN_BRACKET)) {
|
|
753
796
|
const previous = openers.at(-1);
|
|
754
797
|
if (previous !== undefined)
|
|
755
798
|
previous.bracketAfter = true;
|
|
756
|
-
const image =
|
|
799
|
+
const image = code === EXCLAMATION;
|
|
757
800
|
openers.push({ at: image ? i + 1 : i, start: i, image, active: true, bracketAfter: false });
|
|
758
801
|
i += image ? 2 : 1;
|
|
759
802
|
continue;
|
|
760
803
|
}
|
|
761
|
-
if (
|
|
804
|
+
if (code === CLOSE_BRACKET) {
|
|
762
805
|
const opener = openers.pop();
|
|
763
806
|
const use = opener?.active ? closeLink(body, opener, i, definitions, joins) : null;
|
|
764
807
|
if (opener === undefined || use === null) {
|
|
@@ -777,9 +820,12 @@ export function linkInventory(body) {
|
|
|
777
820
|
}
|
|
778
821
|
return { uses, blocks };
|
|
779
822
|
}
|
|
780
|
-
export function
|
|
823
|
+
export function destinations(inventory) {
|
|
781
824
|
const byStart = new Map();
|
|
782
|
-
for (const use of
|
|
825
|
+
for (const use of inventory.uses)
|
|
783
826
|
byStart.set(use.destination.start, use.destination);
|
|
784
827
|
return [...byStart.values()].sort((left, right) => left.start - right.start);
|
|
785
828
|
}
|
|
829
|
+
export function hrefOccurrences(body) {
|
|
830
|
+
return destinations(linkInventory(body));
|
|
831
|
+
}
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYrD;
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM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
|
62
62
|
const { base, suffix } = unescaped(written);
|
|
63
63
|
const url = base.replace(/[\t\n\r]/g, '').replace(/^[\u0000-\u0020]+/, '');
|
|
64
|
-
return {
|
|
64
|
+
return {
|
|
65
|
+
base: suffix === written.length ? url.replace(/(?<![\u0000-\u0020])[\u0000-\u0020]+$/, '') : url,
|
|
66
|
+
suffix,
|
|
67
|
+
};
|
|
65
68
|
}
|
|
66
69
|
const ENCODED = /(?:%[0-9a-fA-F]{2})+/g;
|
|
67
70
|
function decodedRun(run) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const PATTERN_STATES = 1000;
|
|
2
|
+
export declare class PatternTooCostly extends Error {
|
|
3
|
+
}
|
|
4
|
+
export type Pattern = {
|
|
5
|
+
readonly test: (text: string) => boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function linearPattern(source: string): Pattern | null;
|
|
8
|
+
export declare function withLinearRegExp<T>(run: () => T): T;
|
|
9
|
+
export declare function openPatternBudget(): () => void;
|
|
10
|
+
//# sourceMappingURL=pattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../src/pattern.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,OAAQ,CAAC;AAMpC,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AAQ9C,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,CAAC;AAiUnE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAM5D;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAkBnD;AAED,wBAAgB,iBAAiB,IAAI,MAAM,IAAI,CAM9C"}
|