@wireweave/core 4.0.0-beta.0 → 4.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +17 -462
  2. package/dist/app.cjs +31 -0
  3. package/dist/app.d.cts +488 -0
  4. package/dist/app.d.ts +488 -0
  5. package/dist/app.js +31 -0
  6. package/dist/chunk-3RWGG5EC.js +18088 -0
  7. package/dist/chunk-4TMDPWPR.cjs +196 -0
  8. package/dist/chunk-5DGRIQDU.cjs +842 -0
  9. package/dist/chunk-7VTK6LHL.cjs +4374 -0
  10. package/dist/chunk-ETV4XYOV.cjs +7 -0
  11. package/dist/chunk-IMUVIIJR.cjs +18088 -0
  12. package/dist/chunk-JJWAFHSV.js +842 -0
  13. package/dist/chunk-MD6MNOEQ.cjs +2905 -0
  14. package/dist/chunk-PKBMQBKP.js +7 -0
  15. package/dist/chunk-QOS4IC75.js +4374 -0
  16. package/dist/chunk-R5WBZWBC.js +196 -0
  17. package/dist/chunk-V3HVWC7C.js +2905 -0
  18. package/dist/chunk-WV724EAW.js +0 -0
  19. package/dist/chunk-XENFKHRC.cjs +1 -0
  20. package/dist/chunk-XYACLXXF.js +51612 -0
  21. package/dist/chunk-ZPHNXJRY.cjs +51612 -0
  22. package/dist/index-Br7pNaf3.d.cts +240 -0
  23. package/dist/index-CghCKUPx.d.ts +337 -0
  24. package/dist/index-Da_B3eoM.d.ts +240 -0
  25. package/dist/index-G906GEtg.d.cts +337 -0
  26. package/dist/index.cjs +1522 -58235
  27. package/dist/index.d.cts +556 -102
  28. package/dist/index.d.ts +556 -102
  29. package/dist/index.js +1414 -57982
  30. package/dist/interaction.cjs +17 -0
  31. package/dist/interaction.d.cts +3 -0
  32. package/dist/interaction.d.ts +3 -0
  33. package/dist/interaction.js +17 -0
  34. package/dist/parser.cjs +18 -6612
  35. package/dist/parser.d.cts +11 -2
  36. package/dist/parser.d.ts +11 -2
  37. package/dist/parser.js +16 -6580
  38. package/dist/renderer.cjs +7 -50481
  39. package/dist/renderer.d.cts +358 -133
  40. package/dist/renderer.d.ts +358 -133
  41. package/dist/renderer.js +49 -50480
  42. package/dist/spec.cjs +49 -0
  43. package/dist/spec.d.cts +301 -0
  44. package/dist/spec.d.ts +301 -0
  45. package/dist/spec.js +49 -0
  46. package/dist/types-Dkgr0Wyc.d.cts +75 -0
  47. package/dist/types-Dkgr0Wyc.d.ts +75 -0
  48. package/dist/{types-hEr_afgw.d.cts → types-vhPCZpAW.d.cts} +307 -27
  49. package/dist/{types-hEr_afgw.d.ts → types-vhPCZpAW.d.ts} +307 -27
  50. package/dist/v4-types-Baz9yqAS.d.cts +137 -0
  51. package/dist/v4-types-Baz9yqAS.d.ts +137 -0
  52. package/package.json +103 -24
@@ -0,0 +1,4374 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+ var _chunkIMUVIIJRcjs = require('./chunk-IMUVIIJR.cjs');
7
+
8
+
9
+ var _chunk5DGRIQDUcjs = require('./chunk-5DGRIQDU.cjs');
10
+
11
+
12
+ var _chunkETV4XYOVcjs = require('./chunk-ETV4XYOV.cjs');
13
+
14
+ // src/ast/component-parameters.ts
15
+ var PARAMETER_REFERENCE = /^\$([a-zA-Z_][a-zA-Z0-9_-]*)$/;
16
+ function parameterReferenceName(value) {
17
+ var _a;
18
+ return typeof value === "string" ? (_a = PARAMETER_REFERENCE.exec(value)) == null ? void 0 : _a[1] : void 0;
19
+ }
20
+ function collectParameterReferences(children) {
21
+ const found = [];
22
+ const visitValue = (value, key, node) => {
23
+ const name = parameterReferenceName(value);
24
+ if (name !== void 0) {
25
+ found.push({ name, key, node });
26
+ return;
27
+ }
28
+ if (Array.isArray(value)) {
29
+ for (const item of value) visitValue(item, key, node);
30
+ return;
31
+ }
32
+ if (value === null || typeof value !== "object") return;
33
+ for (const [childKey, item] of Object.entries(value)) {
34
+ if (childKey === "loc") continue;
35
+ visitValue(item, childKey, node);
36
+ }
37
+ };
38
+ const visitNode = (node) => {
39
+ if (node.type === "ComponentUse") return;
40
+ for (const [key, value] of Object.entries(node)) {
41
+ if (key === "loc" || key === "children") continue;
42
+ visitValue(value, key, node);
43
+ }
44
+ if ("children" in node && Array.isArray(node.children)) {
45
+ for (const child of node.children) visitNode(child);
46
+ }
47
+ };
48
+ for (const child of children) visitNode(child);
49
+ return found;
50
+ }
51
+
52
+ // src/app/v4.ts
53
+ var bundleBrand = /* @__PURE__ */ Symbol("AppBundle");
54
+ var linkedBrand = /* @__PURE__ */ Symbol("LinkedApp");
55
+ var bundles = /* @__PURE__ */ new WeakMap();
56
+ var links = /* @__PURE__ */ new WeakMap();
57
+ var identifiers = /^[A-Za-z_][A-Za-z0-9_-]{0,127}$/;
58
+ var uuids = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
59
+ var containers = new Set(
60
+ "page header main footer sidebar section row col stack relative card modal drawer accordion popover form tab nav-group list-item annotation-item".split(
61
+ " "
62
+ )
63
+ );
64
+ function textValue(value) {
65
+ if (typeof value === "string") return value;
66
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
67
+ return value === void 0 || value === null ? "" : jcs(value);
68
+ }
69
+ function object(value) {
70
+ return value !== null && typeof value === "object" && !Array.isArray(value);
71
+ }
72
+ function isArray(value) {
73
+ return Array.isArray(value);
74
+ }
75
+ function diagnostic(code, messageKey, source, details = {}, phase = "link", path = "") {
76
+ var _a, _b, _c;
77
+ return {
78
+ severity: "error",
79
+ code,
80
+ phase,
81
+ sourceId: (_a = source == null ? void 0 : source.sourceId) != null ? _a : "app",
82
+ start: (_b = source == null ? void 0 : source.start) != null ? _b : 0,
83
+ end: (_c = source == null ? void 0 : source.end) != null ? _c : 0,
84
+ path,
85
+ messageKey,
86
+ details,
87
+ related: []
88
+ };
89
+ }
90
+ function failed(diagnostics) {
91
+ const sorted = diagnostics.slice().sort(
92
+ (a, b) => (a.sourceId < b.sourceId ? -1 : a.sourceId > b.sourceId ? 1 : 0) || a.start - b.start || (a.phase < b.phase ? -1 : a.phase > b.phase ? 1 : 0) || (a.code < b.code ? -1 : a.code > b.code ? 1 : 0)
93
+ );
94
+ if (sorted.length > 1e3) {
95
+ const omitted = sorted.length - 999;
96
+ sorted.length = 999;
97
+ sorted.push(diagnostic("WW_DIAGNOSTIC_LIMIT", "app.diagnostic-limit", void 0, { omitted }));
98
+ }
99
+ return { ok: false, value: null, html: null, diagnostics: sorted };
100
+ }
101
+ function jcs(value, depth = 0, ancestors = /* @__PURE__ */ new Set()) {
102
+ if (depth > 512) throw new TypeError("JSON nesting limit");
103
+ if (value === null || typeof value === "boolean" || typeof value === "string")
104
+ return JSON.stringify(value);
105
+ if (typeof value === "number") {
106
+ if (!Number.isFinite(value)) throw new TypeError("Non-finite JSON number");
107
+ return JSON.stringify(value);
108
+ }
109
+ if (typeof value !== "object" || value === null || ancestors.has(value))
110
+ throw new TypeError("Invalid or cyclic JSON value");
111
+ ancestors.add(value);
112
+ try {
113
+ if (Array.isArray(value))
114
+ return `[${value.map((item) => jcs(item, depth + 1, ancestors)).join(",")}]`;
115
+ if (Object.prototype.toString.call(value) !== "[object Object]")
116
+ throw new TypeError("Invalid JSON object");
117
+ return `{${Object.keys(value).sort().map(
118
+ (key) => `${JSON.stringify(key)}:${jcs(value[key], depth + 1, ancestors)}`
119
+ ).join(",")}}`;
120
+ } finally {
121
+ ancestors.delete(value);
122
+ }
123
+ }
124
+ function freeze(value) {
125
+ const stack = [value];
126
+ while (stack.length > 0) {
127
+ const current = stack.pop();
128
+ if (current !== null && typeof current === "object" && !Object.isFrozen(current)) {
129
+ for (const child of Object.values(current)) stack.push(child);
130
+ Object.freeze(current);
131
+ }
132
+ }
133
+ return value;
134
+ }
135
+ function dsl(value) {
136
+ if (Array.isArray(value)) return `[${value.map(dsl).join(",")}]`;
137
+ if (object(value))
138
+ return `{${Object.entries(value).map(([key, item]) => `${JSON.stringify(key)}=${dsl(item)}`).join(",")}}`;
139
+ return JSON.stringify(value);
140
+ }
141
+ function plain(value) {
142
+ return JSON.parse(jcs(value));
143
+ }
144
+ function sourceId(value) {
145
+ var _a;
146
+ return (_a = value.split(/[\\/]/).filter(Boolean).at(-1)) != null ? _a : "source.wf";
147
+ }
148
+ function sourceOf(value, fallback) {
149
+ var _a;
150
+ const found = (_a = _chunkIMUVIIJRcjs.getV4SourceSpan.call(void 0, value)) != null ? _a : fallback;
151
+ return found === void 0 ? { sourceId: "app", start: 0, end: 0, startLine: 1, startColumn: 1, endLine: 1, endColumn: 1 } : { ...found, sourceId: sourceId(found.sourceId) };
152
+ }
153
+ function createAppBundle(documents, options) {
154
+ if (!isArray(documents) || !object(options) || !object(options.moduleSources))
155
+ throw new TypeError("Parsed documents and explicit bundle options are required");
156
+ const diagnostics = [];
157
+ const modules = [];
158
+ const sourceByPath = /* @__PURE__ */ new Map();
159
+ try {
160
+ jcs(options);
161
+ if (!identifiers.test(options.id))
162
+ return failed([diagnostic("WW_SCHEMA", "app.invalid-id", void 0, {}, "schema")]);
163
+ const configuration = _chunkIMUVIIJRcjs.parseV4.call(void 0,
164
+ `app ${options.id} entry=${dsl(options.entry)} profile=${dsl(options.profile)} states=${dsl(options.states)} registry=${dsl(options.registry)} fixtures=${dsl(options.fixtures)} {}`,
165
+ { languageVersion: "4.0.0", sourceId: "app" }
166
+ );
167
+ for (const document2 of documents) {
168
+ if (document2.languageVersion !== "4.0.0" || document2.schemaVersion !== "1.0.0" || !isArray(document2.modules)) {
169
+ diagnostics.push(
170
+ diagnostic("WW_UNSUPPORTED_VERSION", "app.document-version", void 0, {}, "schema")
171
+ );
172
+ continue;
173
+ }
174
+ for (const module of document2.modules) {
175
+ const bytes = options.moduleSources[module.id];
176
+ if (modules.some((prior) => prior.id === module.id)) {
177
+ diagnostics.push(
178
+ diagnostic("WW_DUPLICATE_ID", "app.duplicate-module", sourceOf(module), {
179
+ id: module.id
180
+ })
181
+ );
182
+ continue;
183
+ }
184
+ if (typeof bytes !== "string") {
185
+ diagnostics.push(
186
+ diagnostic(
187
+ "WW_IMPORT",
188
+ "app.missing-source-bytes",
189
+ sourceOf(module),
190
+ { id: module.id },
191
+ "import"
192
+ )
193
+ );
194
+ continue;
195
+ }
196
+ const reparsed = _chunkIMUVIIJRcjs.parseV4.call(void 0, bytes, { languageVersion: "4.0.0", sourceId: `${module.id}.wf` });
197
+ if (_chunkIMUVIIJRcjs.digestV4.call(void 0, bytes) !== module.sourceDigest || reparsed.modules.length !== 1 || jcs(reparsed.modules[0]) !== jcs(module)) {
198
+ diagnostics.push(
199
+ diagnostic(
200
+ "WW_IMPORT",
201
+ "app.source-content-mismatch",
202
+ sourceOf(module),
203
+ { id: module.id },
204
+ "import"
205
+ )
206
+ );
207
+ continue;
208
+ }
209
+ const stack = [
210
+ { value: reparsed.modules[0], path: module.id, fallback: sourceOf(reparsed.modules[0]) }
211
+ ];
212
+ while (stack.length > 0) {
213
+ const item = stack.pop();
214
+ if (item.value !== null && typeof item.value === "object") {
215
+ const span = sourceOf(item.value, item.fallback);
216
+ sourceByPath.set(item.path, span);
217
+ for (const [key, value] of Object.entries(item.value))
218
+ stack.push({ value, path: `${item.path}/${key}`, fallback: span });
219
+ }
220
+ }
221
+ modules.push(plain(module));
222
+ }
223
+ }
224
+ if (modules.length === 0 || modules.length > 256)
225
+ diagnostics.push(diagnostic("WW_LIMIT", "app.module-count", void 0, {}, "schema"));
226
+ for (const id of Object.keys(options.moduleSources))
227
+ if (!modules.some((module) => module.id === id)) {
228
+ diagnostics.push(
229
+ diagnostic("WW_IMPORT", "app.unselected-source", void 0, { id }, "import")
230
+ );
231
+ }
232
+ if (diagnostics.length > 0) return failed(diagnostics);
233
+ const candidate = {
234
+ [bundleBrand]: true,
235
+ schemaVersion: "1.0.0",
236
+ languageVersion: "4.0.0",
237
+ id: configuration.app.id,
238
+ entry: configuration.app.entry,
239
+ profile: configuration.app.profile,
240
+ states: configuration.states,
241
+ registry: configuration.registry,
242
+ fixtures: configuration.fixtures,
243
+ modules
244
+ };
245
+ if (new TextEncoder().encode(jcs(candidate)).byteLength > 64 * 1024 * 1024)
246
+ return failed([diagnostic("WW_LIMIT", "app.bundle-byte-limit")]);
247
+ const bundle = freeze(candidate);
248
+ bundles.set(bundle, { sourceByPath });
249
+ return { ok: true, value: bundle, diagnostics: [] };
250
+ } catch (error) {
251
+ if (error instanceof _chunkIMUVIIJRcjs.V4ParseError)
252
+ return failed(error.diagnostics.map((item) => ({ ...item, phase: "schema" })));
253
+ if (error instanceof TypeError)
254
+ return failed([diagnostic("WW_SCHEMA", "app.invalid-json", void 0, {}, "schema")]);
255
+ throw error;
256
+ }
257
+ }
258
+ var Linker = class {
259
+ constructor(bundle, data) {
260
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "bundle", bundle);
261
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "data", data);
262
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "diagnostics", []);
263
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "owners", /* @__PURE__ */ new Map());
264
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "moduleById", /* @__PURE__ */ new Map());
265
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "ownerByNode", /* @__PURE__ */ new WeakMap());
266
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "pathByNode", /* @__PURE__ */ new WeakMap());
267
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "expanded", []);
268
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "screens", []);
269
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "shells", []);
270
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "moduleEdges", /* @__PURE__ */ new Map());
271
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "definitionEdges", /* @__PURE__ */ new Map());
272
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "registry", /* @__PURE__ */ new Map());
273
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "expandedCount", 0);
274
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "domIds", /* @__PURE__ */ new Set());
275
+ }
276
+ source(node) {
277
+ var _a, _b;
278
+ return (_b = this.data.sourceByPath.get((_a = this.pathByNode.get(node)) != null ? _a : "")) != null ? _b : sourceOf(node);
279
+ }
280
+ error(code, key, node, details = {}) {
281
+ var _a;
282
+ this.diagnostics.push(
283
+ diagnostic(
284
+ code,
285
+ key,
286
+ node === void 0 ? void 0 : this.source(node),
287
+ details,
288
+ code === "WW_IMPORT" ? "import" : "link",
289
+ node === void 0 ? "" : (_a = this.pathByNode.get(node)) != null ? _a : ""
290
+ )
291
+ );
292
+ }
293
+ key(namespace, kind, id) {
294
+ return `${namespace}/${kind}/${id}`;
295
+ }
296
+ walk(root, visit, rootPath) {
297
+ const stack = [{ node: root, path: rootPath }];
298
+ while (stack.length > 0) {
299
+ const { node, path } = stack.pop();
300
+ visit(node, path);
301
+ if (node.kind === "use") {
302
+ for (let i = node.fills.length - 1; i >= 0; i--)
303
+ for (let j = node.fills[i].children.length - 1; j >= 0; j--)
304
+ stack.push({
305
+ node: node.fills[i].children[j],
306
+ path: `${path}/fills/${i}/children/${j}`
307
+ });
308
+ } else if ("children" in node)
309
+ for (let i = node.children.length - 1; i >= 0; i--)
310
+ stack.push({ node: node.children[i], path: `${path}/children/${i}` });
311
+ }
312
+ }
313
+ index() {
314
+ const namespaces = /* @__PURE__ */ new Set();
315
+ for (const module of this.bundle.modules) {
316
+ this.pathByNode.set(module, module.id);
317
+ this.moduleById.set(module.id, module);
318
+ if (namespaces.has(module.namespace))
319
+ this.error("WW_DUPLICATE_ID", "app.duplicate-namespace", module, {
320
+ namespace: module.namespace
321
+ });
322
+ namespaces.add(module.namespace);
323
+ for (const [index, definition] of module.definitions.entries()) {
324
+ const id = definition.id;
325
+ if (id === void 0) {
326
+ this.error("WW_REFERENCE", "app.page-id-required", module);
327
+ continue;
328
+ }
329
+ const key = this.key(module.namespace, definition.kind, id);
330
+ const owner = { module, definition, key };
331
+ this.walk(
332
+ definition,
333
+ (node, path) => {
334
+ this.ownerByNode.set(node, owner);
335
+ this.pathByNode.set(node, path);
336
+ },
337
+ `${module.id}/definitions/${index}`
338
+ );
339
+ if (this.owners.has(key))
340
+ this.error("WW_DUPLICATE_ID", "app.duplicate-definition", definition, { id });
341
+ else this.owners.set(key, owner);
342
+ const localIds = /* @__PURE__ */ new Set();
343
+ this.walk(
344
+ definition,
345
+ (node) => {
346
+ if ("id" in node && node.id !== void 0) {
347
+ if (localIds.has(node.id))
348
+ this.error("WW_DUPLICATE_ID", "app.duplicate-local-id", node, { id: node.id });
349
+ localIds.add(node.id);
350
+ }
351
+ },
352
+ ""
353
+ );
354
+ }
355
+ }
356
+ }
357
+ resolve(owner, kind, id, alias, node = owner.definition) {
358
+ let namespace = owner.module.namespace;
359
+ if (alias !== void 0) {
360
+ const imported = owner.module.imports.find((item) => item.namespace === alias);
361
+ const target2 = imported === void 0 ? void 0 : this.moduleById.get(imported.moduleId);
362
+ if (target2 === void 0 || imported === void 0 || !imported.symbols.some((symbol) => symbol.kind === kind && symbol.id === id)) {
363
+ this.error("WW_REFERENCE", "app.unimported-symbol", node, { kind, id, namespace: alias });
364
+ return void 0;
365
+ }
366
+ namespace = target2.namespace;
367
+ }
368
+ const target = this.owners.get(this.key(namespace, kind, id));
369
+ if (target === void 0)
370
+ this.error("WW_REFERENCE", "app.missing-symbol", node, { kind, id, namespace });
371
+ return target;
372
+ }
373
+ imports() {
374
+ for (const module of this.bundle.modules) {
375
+ const aliases = /* @__PURE__ */ new Set();
376
+ const edges = [];
377
+ for (const [index, imported] of module.imports.entries()) {
378
+ this.pathByNode.set(imported, `${module.id}/imports/${index}`);
379
+ if (aliases.has(imported.namespace))
380
+ this.error("WW_DUPLICATE_ID", "app.duplicate-import-alias", imported);
381
+ aliases.add(imported.namespace);
382
+ const target = this.moduleById.get(imported.moduleId);
383
+ if (target === void 0 || target.sourceDigest !== imported.digest) {
384
+ this.error("WW_IMPORT", "app.import-digest-or-module", imported);
385
+ continue;
386
+ }
387
+ edges.push(target.id);
388
+ const selected = /* @__PURE__ */ new Set();
389
+ for (const symbol of imported.symbols) {
390
+ const key = `${symbol.kind}/${symbol.id}`;
391
+ if (selected.has(key))
392
+ this.error("WW_DUPLICATE_ID", "app.duplicate-import-symbol", imported);
393
+ selected.add(key);
394
+ if (!target.exports.some((entry) => entry.kind === symbol.kind && entry.id === symbol.id))
395
+ this.error("WW_IMPORT", "app.unexported-symbol", imported, { symbol: key });
396
+ }
397
+ }
398
+ const exports = /* @__PURE__ */ new Set();
399
+ for (const item of module.exports) {
400
+ const key = this.key(module.namespace, item.kind, item.id);
401
+ if (exports.has(key)) this.error("WW_DUPLICATE_ID", "app.duplicate-export", module);
402
+ exports.add(key);
403
+ if (!this.owners.has(key))
404
+ this.error("WW_IMPORT", "app.missing-export", module, { id: item.id });
405
+ }
406
+ this.moduleEdges.set(module.id, edges);
407
+ }
408
+ this.cycles(this.moduleEdges, 64);
409
+ }
410
+ cycles(edges, depthLimit) {
411
+ var _a, _b, _c;
412
+ const colors = /* @__PURE__ */ new Map();
413
+ for (const start of edges.keys()) {
414
+ if (colors.has(start)) continue;
415
+ const frames = [{ id: start, cursor: 0 }];
416
+ colors.set(start, 1);
417
+ while (frames.length > 0) {
418
+ const current = frames[frames.length - 1];
419
+ const neighbors = (_a = edges.get(current.id)) != null ? _a : [];
420
+ if (current.cursor === neighbors.length) {
421
+ colors.set(current.id, 2);
422
+ frames.pop();
423
+ continue;
424
+ }
425
+ const next = neighbors[current.cursor++];
426
+ if (colors.get(next) === 1) {
427
+ this.error(
428
+ "WW_CYCLE",
429
+ "app.dependency-cycle",
430
+ (_c = (_b = this.owners.get(current.id)) == null ? void 0 : _b.definition) != null ? _c : this.moduleById.get(current.id),
431
+ { from: current.id, to: next }
432
+ );
433
+ continue;
434
+ }
435
+ if (colors.has(next)) continue;
436
+ if (frames.length >= depthLimit) {
437
+ this.error("WW_LIMIT", "app.dependency-depth", void 0, { id: next });
438
+ continue;
439
+ }
440
+ colors.set(next, 1);
441
+ frames.push({ id: next, cursor: 0 });
442
+ }
443
+ }
444
+ }
445
+ references() {
446
+ for (const owner of this.owners.values()) {
447
+ const edges = [];
448
+ const slots = /* @__PURE__ */ new Set();
449
+ this.walk(
450
+ owner.definition,
451
+ (node) => {
452
+ var _a;
453
+ if (node.kind === "use") {
454
+ const target = this.resolve(owner, "component", node.name, node.namespace, node);
455
+ if (target !== void 0) edges.push(target.key);
456
+ }
457
+ if (node.kind === "slot") {
458
+ const name = (_a = node.name) != null ? _a : "";
459
+ if (slots.has(name)) this.error("WW_SLOT", "app.duplicate-slot", node);
460
+ slots.add(name);
461
+ if (owner.definition.kind === "component" && name === "")
462
+ this.error("WW_SLOT", "app.component-slot-name", node);
463
+ }
464
+ },
465
+ ""
466
+ );
467
+ if (owner.definition.kind === "layout" && (slots.size !== 1 || !slots.has("")))
468
+ this.error("WW_SLOT", "app.layout-slot-cardinality", owner.definition);
469
+ const uses = owner.definition.attributes.uses;
470
+ if (typeof uses === "string") {
471
+ if (owner.definition.kind !== "page")
472
+ this.error("WW_REFERENCE", "app.layout-nesting", owner.definition);
473
+ const [alias, id] = uses.includes("::") ? uses.split("::") : [void 0, uses];
474
+ const target = this.resolve(owner, "layout", id, alias);
475
+ if (target !== void 0) edges.push(target.key);
476
+ }
477
+ this.definitionEdges.set(owner.key, edges);
478
+ }
479
+ this.cycles(this.definitionEdges, 1e4);
480
+ }
481
+ registryChecks() {
482
+ const entries = this.bundle.registry.entries;
483
+ const sorted = entries.slice().sort((a, b) => {
484
+ const left = `${textValue(a.kind)}\0${textValue(a.namespace)}\0${textValue(a.id)}`;
485
+ const right = `${textValue(b.kind)}\0${textValue(b.namespace)}\0${textValue(b.id)}`;
486
+ return left < right ? -1 : left > right ? 1 : 0;
487
+ });
488
+ if (jcs(entries) !== jcs(sorted) || _chunkIMUVIIJRcjs.digestV4.call(void 0, jcs(entries)) !== this.bundle.registry.digest)
489
+ this.error("WW_REGISTRY", "app.registry-digest");
490
+ for (const entry of entries) {
491
+ if (typeof entry.id !== "string" || !uuids.test(entry.id) || typeof entry.namespace !== "string" || !["Requirement", "ImplementationObligation"].includes(textValue(entry.kind))) {
492
+ this.error("WW_REGISTRY", "app.registry-identity");
493
+ continue;
494
+ }
495
+ if (this.registry.has(entry.id))
496
+ this.error("WW_REGISTRY", "app.duplicate-registry-id", void 0, { id: entry.id });
497
+ this.registry.set(entry.id, entry);
498
+ if (typeof entry.title !== "string" || entry.title.length === 0 || !Array.isArray(entry.acceptance) || entry.acceptance.length === 0)
499
+ this.error("WW_REGISTRY", "app.incomplete-requirement", void 0, { id: entry.id });
500
+ if (entry.kind === "ImplementationObligation") {
501
+ for (const field of ["trigger", "authority"])
502
+ if (typeof entry[field] !== "string" || entry[field].length === 0)
503
+ this.error("WW_REGISTRY", "app.incomplete-obligation", void 0, {
504
+ id: entry.id,
505
+ field
506
+ });
507
+ for (const field of ["preconditions", "success", "failureCases", "requirementRefs"])
508
+ if (!Array.isArray(entry[field]) || field !== "preconditions" && entry[field].length === 0)
509
+ this.error("WW_REGISTRY", "app.incomplete-obligation", void 0, {
510
+ id: entry.id,
511
+ field
512
+ });
513
+ for (const field of ["request", "response"])
514
+ if (!object(entry[field]) || !["schema", "not-applicable"].includes(textValue(entry[field].mode)))
515
+ this.error("WW_REGISTRY", "app.incomplete-obligation", void 0, {
516
+ id: entry.id,
517
+ field
518
+ });
519
+ }
520
+ }
521
+ for (const entry of entries) {
522
+ for (const ref of Array.isArray(entry.requirementRefs) ? entry.requirementRefs : []) {
523
+ const target = object(ref) ? this.registry.get(textValue(ref.id)) : void 0;
524
+ if ((target == null ? void 0 : target.kind) !== "Requirement" || !object(ref) || ref.namespace !== target.namespace || ref.kind !== "Requirement")
525
+ this.error("WW_REGISTRY", "app.obligation-requirement-reference");
526
+ }
527
+ }
528
+ for (const owner of this.owners.values())
529
+ this.walk(
530
+ owner.definition,
531
+ (node) => {
532
+ if (!("attributes" in node)) return;
533
+ this.registryRefs(node.attributes, node);
534
+ for (const handler of asObjects(node.attributes.on))
535
+ for (const operation of asObjects(handler.operations))
536
+ this.registryRefs(operation, node);
537
+ },
538
+ ""
539
+ );
540
+ }
541
+ registryRefs(value, node) {
542
+ var _a;
543
+ for (const [field, kind] of [
544
+ ["requirementRefs", "Requirement"],
545
+ ["obligationRefs", "ImplementationObligation"]
546
+ ]) {
547
+ for (const id of Array.isArray(value[field]) ? value[field] : []) {
548
+ if (typeof id !== "string" || ((_a = this.registry.get(id)) == null ? void 0 : _a.kind) !== kind)
549
+ this.error("WW_REGISTRY", "app.unresolved-registry-reference", node, { field, id });
550
+ }
551
+ }
552
+ }
553
+ binding(value) {
554
+ if (!object(value)) {
555
+ this.error("WW_REGISTRY", "app.invalid-source-binding");
556
+ return;
557
+ }
558
+ if (value.scope === "instance" && (!object(value.instanceRoot) || !Array.isArray(value.instancePath))) {
559
+ this.error("WW_REGISTRY", "app.invalid-instance-binding");
560
+ return;
561
+ }
562
+ if (!["module", "definition", "instance", "app-state"].includes(textValue(value.scope))) {
563
+ this.error("WW_REGISTRY", "app.invalid-source-binding");
564
+ return;
565
+ }
566
+ if (value.scope === "app-state") {
567
+ if (value.appId !== this.bundle.id || !this.bundle.states.some((state) => `app:${textValue(state.id)}` === value.stateRef))
568
+ this.error("WW_REGISTRY", "app.unresolved-source-binding");
569
+ return;
570
+ }
571
+ const module = this.moduleById.get(textValue(value.moduleId));
572
+ if (module === void 0) {
573
+ this.error("WW_REGISTRY", "app.unresolved-source-binding");
574
+ return;
575
+ }
576
+ if (value.scope === "module") return;
577
+ const owner = this.owners.get(
578
+ this.key(module.namespace, textValue(value.definitionKind), textValue(value.definitionId))
579
+ );
580
+ if (owner === void 0) {
581
+ this.error("WW_REGISTRY", "app.unresolved-source-binding");
582
+ return;
583
+ }
584
+ if (value.scope === "instance" && (value.appId !== this.bundle.id || !this.expanded.some(
585
+ (entry) => entry.owner === owner && jcs(entry.identity.instanceRoot) === jcs(value.instanceRoot) && jcs(entry.identity.instancePath) === jcs(value.instancePath) && (!["element", "operation"].includes(textValue(value.targetKind)) || entry.node.id === value.elementId)
586
+ )))
587
+ this.error("WW_REGISTRY", "app.unresolved-instance-binding");
588
+ if (value.targetKind === "definition") return;
589
+ if (value.targetKind === "variant") {
590
+ if (!Array.isArray(owner.definition.attributes.variants) || !owner.definition.attributes.variants.includes(value.variantId))
591
+ this.error("WW_REGISTRY", "app.unresolved-source-binding");
592
+ return;
593
+ }
594
+ if (value.targetKind === "state") {
595
+ const scope = owner.definition.kind === "page" ? "screen" : owner.definition.kind === "layout" ? "shell" : "component";
596
+ if (!asObjects(owner.definition.attributes.states).some(
597
+ (state) => value.stateRef === `${scope}:${textValue(state.id)}`
598
+ ))
599
+ this.error("WW_REGISTRY", "app.unresolved-source-binding");
600
+ return;
601
+ }
602
+ let found = false;
603
+ this.walk(
604
+ owner.definition,
605
+ (node) => {
606
+ if (!("id" in node) || node.id !== value.elementId || !("attributes" in node)) return;
607
+ found = value.targetKind === "element" || asObjects(node.attributes.on).some(
608
+ (handler) => asObjects(handler.operations).some((operation) => operation.id === value.operationId)
609
+ );
610
+ },
611
+ ""
612
+ );
613
+ if (!found) this.error("WW_REGISTRY", "app.unresolved-source-binding");
614
+ }
615
+ route(reference, node, code = "WW_REFERENCE") {
616
+ const target = this.owners.get(this.key(reference.namespace, "page", reference.id));
617
+ if (target === void 0 || reference.variant !== void 0 && (!Array.isArray(target.definition.attributes.variants) || !target.definition.attributes.variants.includes(reference.variant))) {
618
+ this.error(code, "app.unresolved-route", node, {
619
+ namespace: reference.namespace,
620
+ id: reference.id
621
+ });
622
+ return void 0;
623
+ }
624
+ return target;
625
+ }
626
+ frame(owner) {
627
+ var _a;
628
+ const attrs = owner.definition.attributes;
629
+ const { width, height } = this.bundle.profile;
630
+ const pair = attrs.viewport === void 0 ? null : /^(\d+)(?:x(\d+))?$/.exec(textValue(attrs.viewport));
631
+ const presets = {
632
+ "desktop-sm": [1280, 800],
633
+ desktop: [1440, 900],
634
+ "desktop-lg": [1920, 1080],
635
+ "desktop-xl": [2560, 1440],
636
+ ipad: [1024, 768],
637
+ "ipad-portrait": [768, 1024],
638
+ "ipad-pro": [1366, 1024],
639
+ "ipad-pro-portrait": [1024, 1366],
640
+ "iphone-se": [375, 667],
641
+ iphone14: [390, 844],
642
+ "iphone14-pro": [393, 852],
643
+ "iphone14-pro-max": [430, 932],
644
+ android: [360, 800],
645
+ "android-lg": [412, 915]
646
+ };
647
+ const device = presets[textValue(attrs.device)];
648
+ if (attrs.viewport !== void 0 && (pair === null || Number(pair[1]) !== width || Number((_a = pair[2]) != null ? _a : 900) !== height) || attrs.device !== void 0 && (!device || device[0] !== width || device[1] !== height) || ["w", "width"].some(
649
+ (key) => attrs[key] !== void 0 && attrs[key] !== width && attrs[key] !== "screen" && attrs[key] !== "full"
650
+ ) || ["h", "height"].some(
651
+ (key) => attrs[key] !== void 0 && attrs[key] !== height && attrs[key] !== "screen" && attrs[key] !== "full"
652
+ ))
653
+ this.error("WW_VIEWPORT", "app.incompatible-frame", owner.definition);
654
+ }
655
+ expandAll() {
656
+ var _a;
657
+ this.route(this.bundle.entry, void 0, "WW_ROUTE");
658
+ const pages = [...this.owners.values()].filter((owner) => owner.definition.kind === "page");
659
+ if (pages.length === 0 || pages.length > 2e3) this.error("WW_LIMIT", "app.screen-count");
660
+ for (const owner of pages) {
661
+ this.frame(owner);
662
+ const screen = {
663
+ owner,
664
+ route: { namespace: owner.module.namespace, id: owner.definition.id },
665
+ children: []
666
+ };
667
+ const root = { kind: "screen", ...screen.route };
668
+ const uses = owner.definition.attributes.uses;
669
+ if (typeof uses === "string") {
670
+ const [alias, id] = uses.includes("::") ? uses.split("::") : [void 0, uses];
671
+ const layout = this.resolve(owner, "layout", id, alias);
672
+ if (layout !== void 0) {
673
+ screen.shell = layout.key;
674
+ if (!this.shells.some((shell) => shell.owner === layout)) {
675
+ this.frame(layout);
676
+ const shellRoot = {
677
+ kind: "shell",
678
+ namespace: layout.module.namespace,
679
+ id: layout.definition.id,
680
+ profileDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, jcs(this.bundle.profile))
681
+ };
682
+ const children = this.expandChildren([layout.definition], {
683
+ owner: layout,
684
+ root: shellRoot,
685
+ path: [],
686
+ bindings: {},
687
+ fills: /* @__PURE__ */ new Map(),
688
+ invocationSources: [],
689
+ depth: 0
690
+ });
691
+ const slot = this.expanded.find((node) => node.slot && node.owner === layout);
692
+ this.shells.push({ owner: layout, children, slotId: (_a = slot == null ? void 0 : slot.renderedId) != null ? _a : "" });
693
+ }
694
+ }
695
+ }
696
+ screen.children = this.expandChildren([owner.definition], {
697
+ owner,
698
+ root,
699
+ path: [],
700
+ bindings: {},
701
+ fills: /* @__PURE__ */ new Map(),
702
+ invocationSources: [],
703
+ depth: 0
704
+ });
705
+ this.screens.push(screen);
706
+ if (this.expandedCount > 1e6) break;
707
+ }
708
+ }
709
+ expandChildren(nodes, context) {
710
+ var _a, _b, _c, _d, _e;
711
+ const result = [];
712
+ for (const node of nodes) {
713
+ if (++this.expandedCount > 1e6 || context.depth > 128) {
714
+ this.error("WW_LIMIT", "app.expansion-limit", node);
715
+ break;
716
+ }
717
+ if (node.kind === "use") {
718
+ const target = this.resolve(context.owner, "component", node.name, node.namespace, node);
719
+ if (target === void 0 || target.definition.kind !== "component") continue;
720
+ if (this.bundle.profile.id === "neutral-app" && this.source(node).authoredId === false)
721
+ this.error("WW_REFERENCE", "app.invocation-id-required", node);
722
+ const bindings = {};
723
+ const parameters = target.definition.parameters;
724
+ for (const name of Object.keys(node.inputs))
725
+ if (!parameters.some((parameter) => parameter.id === name))
726
+ this.error("WW_PARAMETER", "app.unknown-argument", node, { name });
727
+ for (const parameter of parameters) {
728
+ const input = node.inputs[parameter.id];
729
+ const value = input === void 0 ? parameter.default : "literal" in input ? input.literal : context.bindings[input.param];
730
+ if (!matchesType(value, parameter.type))
731
+ this.error("WW_PARAMETER", "app.argument-type", node, {
732
+ name: parameter.id,
733
+ type: parameter.type
734
+ });
735
+ else Object.defineProperty(bindings, parameter.id, { value, enumerable: true });
736
+ }
737
+ const slots = /* @__PURE__ */ new Set();
738
+ this.walk(
739
+ target.definition,
740
+ (child) => {
741
+ var _a2;
742
+ if (child.kind === "slot") slots.add((_a2 = child.name) != null ? _a2 : "");
743
+ },
744
+ ""
745
+ );
746
+ const fills = /* @__PURE__ */ new Map();
747
+ for (const fill of node.fills) {
748
+ if (!slots.has(fill.name))
749
+ this.error("WW_SLOT", "app.unknown-fill", node, { name: fill.name });
750
+ if (fills.has(fill.name))
751
+ this.error("WW_SLOT", "app.duplicate-fill", node, { name: fill.name });
752
+ fills.set(fill.name, { nodes: fill.children, context });
753
+ }
754
+ if (this.diagnostics.length > 0) continue;
755
+ const children = this.expandChildren(target.definition.children, {
756
+ ...context,
757
+ owner: target,
758
+ bindings,
759
+ fills,
760
+ path: [...context.path, { kind: "use", id: node.id }],
761
+ invocationSources: [...context.invocationSources, this.source(node)],
762
+ depth: context.depth + 1
763
+ });
764
+ for (const child of children) result.push(child);
765
+ } else if (node.kind === "repeat") {
766
+ if (this.bundle.profile.id === "neutral-app" && node.id === void 0)
767
+ this.error("WW_REFERENCE", "app.repeat-id-required", node);
768
+ if (node.count > 0 && node.count * node.children.length + this.expandedCount > 1e6) {
769
+ this.error("WW_LIMIT", "app.expansion-limit", node);
770
+ continue;
771
+ }
772
+ for (let index = 0; index < node.count; index++) {
773
+ const children = this.expandChildren(node.children, {
774
+ ...context,
775
+ path: [
776
+ ...context.path,
777
+ { kind: "repeat", id: (_a = node.id) != null ? _a : `_repeat_${this.source(node).start}`, index }
778
+ ],
779
+ depth: context.depth + 1
780
+ });
781
+ for (const child of children) result.push(child);
782
+ if (this.expandedCount > 1e6) break;
783
+ }
784
+ } else if (node.kind === "slot" && context.owner.definition.kind === "component") {
785
+ const fill = context.fills.get((_b = node.name) != null ? _b : "");
786
+ if (fill !== void 0) {
787
+ const children = this.expandChildren(fill.nodes, {
788
+ ...fill.context,
789
+ root: context.root,
790
+ path: context.path,
791
+ invocationSources: context.invocationSources,
792
+ depth: context.depth + 1
793
+ });
794
+ for (const child of children) result.push(child);
795
+ }
796
+ } else {
797
+ if (node.kind === "component" || node.kind === "layout" && node !== context.owner.definition) {
798
+ this.error("WW_SCHEMA", "app.nested-definition", node);
799
+ continue;
800
+ }
801
+ const slot = node.kind === "slot";
802
+ const source = this.source(node);
803
+ const replacement = (value) => context.owner.definition.kind === "component" ? substitute(
804
+ value,
805
+ context.bindings,
806
+ (name) => this.error("WW_PARAMETER", "app.unbound-parameter", node, { name })
807
+ ) : value;
808
+ const authored = node;
809
+ const primitive = slot ? { kind: "section", attributes: {}, children: [] } : {
810
+ ...authored,
811
+ ...node.kind === "layout" ? { kind: "section" } : {},
812
+ attributes: plain(replacement(authored.attributes)),
813
+ ...authored.label === void 0 ? {} : { label: replacement(authored.label) },
814
+ children: []
815
+ };
816
+ this.pathByNode.set(primitive, (_c = this.pathByNode.get(node)) != null ? _c : "");
817
+ if (context.owner.definition.kind === "component") this.checkSubstituted(primitive, node);
818
+ const identity = {
819
+ namespace: context.owner.module.namespace,
820
+ definitionKind: context.owner.definition.kind,
821
+ definitionId: context.owner.definition.id,
822
+ instanceRoot: context.root,
823
+ instancePath: context.path,
824
+ localId: (_e = primitive.id) != null ? _e : slot ? "_slot" : `_node_${_chunkIMUVIIJRcjs.digestV4.call(void 0, (_d = this.pathByNode.get(node)) != null ? _d : textValue(source.start)).slice(7)}`
825
+ };
826
+ const renderedId = `wf-${_chunkIMUVIIJRcjs.digestV4.call(void 0, jcs({ identity, projectionId: this.bundle.profile.id })).slice(7)}`;
827
+ if (this.domIds.has(renderedId))
828
+ this.error("WW_DUPLICATE_ID", "app.rendered-identity-collision", node);
829
+ this.domIds.add(renderedId);
830
+ const expanded = {
831
+ node: primitive,
832
+ owner: context.owner,
833
+ identity,
834
+ renderedId,
835
+ source,
836
+ invocationSources: context.invocationSources,
837
+ children: [],
838
+ stateBindings: {},
839
+ ...slot ? { slot: true } : {}
840
+ };
841
+ this.expanded.push(expanded);
842
+ if (!slot && "children" in node) {
843
+ expanded.children = this.expandChildren(node.children, {
844
+ ...context,
845
+ depth: context.depth + 1
846
+ });
847
+ for (const child of expanded.children) child.parent = expanded;
848
+ }
849
+ result.push(expanded);
850
+ }
851
+ }
852
+ return result;
853
+ }
854
+ checkSubstituted(node, source) {
855
+ const name = node.kind === "nav-item" || node.kind === "dropdown-item" || node.kind === "list-item" || node.kind === "annotation-item" ? "item" : node.kind === "nav-group" ? "group" : node.kind;
856
+ const label = node.label === void 0 ? "" : ` ${dsl(node.label)}`;
857
+ let snippet = `${name}${node.number === void 0 ? "" : ` ${node.number}`}${label} ${attrsDsl(node.attributes)}${containers.has(node.kind) ? " {}" : ""}`;
858
+ if (node.kind === "table") snippet = `table ${attrsDsl(node.attributes)} {}`;
859
+ const parent = {
860
+ "nav-item": "nav",
861
+ "nav-group": "nav",
862
+ "dropdown-item": "dropdown",
863
+ "list-item": "list",
864
+ tab: "tabs",
865
+ option: "select",
866
+ "annotation-item": "annotations"
867
+ }[node.kind];
868
+ if (parent !== void 0) snippet = `${parent} { ${snippet} }`;
869
+ try {
870
+ _chunkIMUVIIJRcjs.parseV4.call(void 0, `page { ${snippet} }`, { languageVersion: "4.0.0" });
871
+ } catch (error) {
872
+ if (error instanceof _chunkIMUVIIJRcjs.V4ParseError)
873
+ this.error("WW_PARAMETER", "app.substituted-attribute-domain", source);
874
+ else throw error;
875
+ }
876
+ }
877
+ state(ref, expanded) {
878
+ var _a, _b, _c;
879
+ const [scope, id] = ref.split(":");
880
+ let declarations = [];
881
+ if (scope === "app") declarations = this.bundle.states;
882
+ else if (scope === "component" && expanded.owner.definition.kind === "component")
883
+ declarations = asObjects(expanded.owner.definition.attributes.states);
884
+ else if (scope === "screen" && expanded.identity.instanceRoot.kind === "screen") {
885
+ const root = expanded.identity.instanceRoot;
886
+ const owner = this.owners.get(this.key(root.namespace, "page", root.id));
887
+ declarations = asObjects(owner == null ? void 0 : owner.definition.attributes.states);
888
+ } else if (scope === "shell") {
889
+ const root = expanded.identity.instanceRoot;
890
+ const screen = root.kind === "screen" ? this.screens.find(
891
+ (screen2) => screen2.route.namespace === root.namespace && screen2.route.id === root.id
892
+ ) : void 0;
893
+ const owner = root.kind === "shell" ? this.owners.get(this.key(root.namespace, "layout", root.id)) : this.owners.get((_a = screen == null ? void 0 : screen.shell) != null ? _a : "");
894
+ declarations = asObjects(owner == null ? void 0 : owner.definition.attributes.states);
895
+ }
896
+ const state = declarations.find((state2) => state2.id === id);
897
+ if (state === void 0) this.error("WW_STATE", "app.unresolved-state", expanded.node, { ref });
898
+ else {
899
+ const root = expanded.identity.instanceRoot;
900
+ const shellOwner = root.kind === "shell" ? this.owners.get(this.key(root.namespace, "layout", root.id)) : this.owners.get(
901
+ (_c = (_b = this.screens.find(
902
+ (screen) => screen.route.namespace === root.namespace && screen.route.id === root.id
903
+ )) == null ? void 0 : _b.shell) != null ? _c : ""
904
+ );
905
+ const stateRoot = scope === "app" ? "app" : scope === "shell" ? `shell/${shellOwner == null ? void 0 : shellOwner.module.namespace}/${shellOwner == null ? void 0 : shellOwner.definition.id}` : `${root.kind}/${root.namespace}/${root.id}`;
906
+ const key = scope === "app" ? ref : scope === "component" ? `${expanded.owner.key}/${jcs(root)}/${jcs(componentPath(expanded.identity.instancePath))}/${id}` : scope === "screen" ? `screen/${root.namespace}/${root.id}/${id}` : `${stateRoot}/${id}`;
907
+ expanded.stateBindings[ref] = {
908
+ key,
909
+ initial: state.initial,
910
+ type: textValue(state.type),
911
+ lifetime: state.lifetime === "mount" ? "mount" : "session",
912
+ sensitive: state.sensitive === true,
913
+ root: stateRoot
914
+ };
915
+ }
916
+ return state;
917
+ }
918
+ semantics() {
919
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
920
+ for (const entry of this.bundle.registry.entries)
921
+ for (const binding of Array.isArray(entry.bindings) ? entry.bindings : [])
922
+ this.binding(binding);
923
+ if (asObjects(this.bundle.profile.assets).length > 0 || this.bundle.profile.fontAssetId !== void 0)
924
+ this.error("WW_ASSET", "app.asset-decoder-unavailable");
925
+ const scopes = [
926
+ { node: void 0, states: this.bundle.states, app: true },
927
+ ...[...this.owners.values()].map((owner) => ({
928
+ node: owner.definition,
929
+ states: asObjects(owner.definition.attributes.states),
930
+ app: false
931
+ }))
932
+ ];
933
+ for (const scope of scopes) {
934
+ const ids = /* @__PURE__ */ new Set();
935
+ for (const state of scope.states) {
936
+ const id = textValue(state.id);
937
+ if (!matchesType(state.initial, textValue(state.type)))
938
+ this.error("WW_STATE", "app.state-initial-type", scope.node);
939
+ if (ids.has(id)) this.error("WW_DUPLICATE_ID", "app.duplicate-state", scope.node, { id });
940
+ ids.add(id);
941
+ if (scope.app && state.lifetime !== "session")
942
+ this.error("WW_STATE", "app.app-state-lifetime", scope.node);
943
+ }
944
+ }
945
+ const fixtureIds = /* @__PURE__ */ new Set();
946
+ for (const fixture of this.bundle.fixtures) {
947
+ const id = textValue(fixture.id);
948
+ if (fixtureIds.has(id))
949
+ this.error("WW_DUPLICATE_ID", "app.duplicate-fixture", void 0, { id });
950
+ fixtureIds.add(id);
951
+ }
952
+ for (const expanded of this.expanded) {
953
+ const { node, owner } = expanded;
954
+ const attrs = node.attributes;
955
+ const strict = this.bundle.profile.id === "neutral-app";
956
+ if (["row", "col", "stack"].includes(node.kind) && ["left", "right", "justify"].includes(textValue(attrs.align)))
957
+ this.error("WW_LAYOUT", "app.container-alignment", node);
958
+ if (attrs.src !== void 0 && attrs.src !== true)
959
+ this.error("WW_ASSET", "app.unresolved-asset", node);
960
+ const interactive = [
961
+ "input",
962
+ "textarea",
963
+ "select",
964
+ "checkbox",
965
+ "radio",
966
+ "switch",
967
+ "slider",
968
+ "button",
969
+ "link",
970
+ "nav-item",
971
+ "dropdown-item"
972
+ ];
973
+ const descendants = (root) => {
974
+ const result = [], pending = [...root.children];
975
+ while (pending.length) {
976
+ const child = pending.pop();
977
+ result.push(child);
978
+ pending.push(...child.children);
979
+ }
980
+ return result;
981
+ };
982
+ const descend = ["form", "card", "tooltip"].includes(node.kind) || attrs.initialFocus !== void 0 || attrs.order !== void 0 ? descendants(expanded) : [];
983
+ if (node.kind === "form") {
984
+ if (descend.some((child) => child.node.kind === "form"))
985
+ this.error("WW_FORM", "app.nested-form", node);
986
+ const names = /* @__PURE__ */ new Map();
987
+ for (const child of descend.filter(
988
+ (child2) => ["input", "textarea", "select", "checkbox", "radio", "switch", "slider"].includes(
989
+ child2.node.kind
990
+ )
991
+ )) {
992
+ const name = textValue((_a = child.node.attributes.name) != null ? _a : child.node.id);
993
+ const previous = names.get(name);
994
+ if (previous && !(previous.node.kind === "radio" && child.node.kind === "radio" && jcs(previous.node.attributes.bind) === jcs(child.node.attributes.bind) && jcs(previous.node.attributes.value) !== jcs(child.node.attributes.value)))
995
+ this.error("WW_FORM", "app.duplicate-field-name", child.node, { name });
996
+ names.set(name, child);
997
+ }
998
+ }
999
+ if (node.kind === "card" && (attrs.on !== void 0 || attrs.navigate !== void 0) && descend.some((child) => interactive.includes(child.node.kind)))
1000
+ this.error("WW_ACCESSIBILITY", "app.nested-interactive-card", node);
1001
+ if (attrs.role !== void 0) {
1002
+ const natural = {
1003
+ button: ["button"],
1004
+ link: ["link"],
1005
+ image: ["img"],
1006
+ alert: ["alert", "status"],
1007
+ toast: ["status", "alert"],
1008
+ spinner: ["status"],
1009
+ section: ["region"]
1010
+ };
1011
+ if (!((_b = natural[node.kind]) != null ? _b : []).includes(textValue(attrs.role)))
1012
+ this.error("WW_ACCESSIBILITY", "app.incompatible-role", node);
1013
+ }
1014
+ if (attrs.initialFocus !== void 0 && !descend.some(
1015
+ (child) => child.node.id === attrs.initialFocus && interactive.includes(child.node.kind) && child.node.attributes.disabled !== true
1016
+ ))
1017
+ this.error("WW_ACCESSIBILITY", "app.invalid-initial-focus", node);
1018
+ if (node.kind === "tooltip" && (expanded.children.length !== 1 || descend.slice(1).some((child) => interactive.includes(child.node.kind))))
1019
+ this.error("WW_ACCESSIBILITY", "app.tooltip-trigger", node);
1020
+ if (node.kind === "tabs" && (typeof attrs.active === "boolean" || Number((_c = attrs.active) != null ? _c : 0) >= expanded.children.filter((child) => child.node.kind === "tab").length || ((_e = expanded.children.filter((child) => child.node.kind === "tab")[Number((_d = attrs.active) != null ? _d : 0)]) == null ? void 0 : _e.node.attributes.disabled) === true))
1021
+ this.error("WW_ACCESSIBILITY", "app.tab-selection", node);
1022
+ if (attrs.order !== void 0 && attrs.order !== 0 && (interactive.includes(node.kind) || descend.some((child) => interactive.includes(child.node.kind))))
1023
+ this.error("WW_ACCESSIBILITY", "app.visual-focus-order", node);
1024
+ for (const key of ["p", "px", "py", "pt", "pr", "pb", "pl", "gap"])
1025
+ if (attrs[key] === "auto" || (typeof attrs[key] === "number" ? Number(attrs[key]) < 0 : object(attrs[key]) && Number(attrs[key].value) < 0))
1026
+ this.error("WW_LAYOUT", "app.invalid-spacing", node, { key });
1027
+ for (const key of ["m", "my", "mt", "mr", "mb", "ml"])
1028
+ if (attrs[key] === "auto") this.error("WW_LAYOUT", "app.invalid-spacing", node, { key });
1029
+ for (const [minimum, maximum] of [
1030
+ ["minW", "maxW"],
1031
+ ["minH", "maxH"],
1032
+ ["minLength", "maxLength"],
1033
+ ["min", "max"]
1034
+ ])
1035
+ if (typeof attrs[minimum] === "number" && typeof attrs[maximum] === "number" && Number(attrs[minimum]) > Number(attrs[maximum]))
1036
+ this.error("WW_LAYOUT", "app.inverted-bounds", node, { minimum, maximum });
1037
+ for (const key of ["minW", "maxW", "minH", "maxH"])
1038
+ if (typeof attrs[key] === "string")
1039
+ this.error("WW_LAYOUT", "app.bound-keyword", node, { key });
1040
+ if (attrs.h === "fit" || typeof attrs.flex === "number" && attrs.flex < 0 || typeof attrs.step === "number" && attrs.step <= 0)
1041
+ this.error("WW_LAYOUT", "app.invalid-layout-value", node);
1042
+ if (attrs.bold === true && attrs.weight !== void 0 && attrs.weight !== "bold" || attrs.primary === true && attrs.secondary === true || attrs.outline === true && attrs.ghost === true)
1043
+ this.error("WW_LAYOUT", "app.conflicting-presentation", node);
1044
+ if (node.kind !== "page" && (attrs.x !== void 0 || attrs.y !== void 0 || attrs.anchor !== void 0)) {
1045
+ let parent = expanded.parent;
1046
+ while (parent && parent.node.kind !== "relative") parent = parent.parent;
1047
+ if (!parent) this.error("WW_LAYOUT", "app.missing-relative-container", node);
1048
+ }
1049
+ if (object(attrs.h) && attrs.h.unit === "%") {
1050
+ const height = (_h = (_f = expanded.parent) == null ? void 0 : _f.node.attributes.h) != null ? _h : (_g = expanded.parent) == null ? void 0 : _g.node.attributes.height;
1051
+ if (((_i = expanded.parent) == null ? void 0 : _i.node.kind) !== "page" && (height === void 0 || height === "auto"))
1052
+ this.error("WW_LAYOUT", "app.indefinite-percentage-height", node);
1053
+ }
1054
+ if (strict && ["input", "textarea", "select", "checkbox", "radio", "switch", "slider", "button"].includes(
1055
+ node.kind
1056
+ ) && ![node.label, attrs.label, attrs.aria, attrs["aria-label"]].some(
1057
+ (label) => typeof label === "string" && label.trim().length > 0
1058
+ ))
1059
+ this.error("WW_ACCESSIBILITY", "app.missing-control-name", node);
1060
+ if (attrs.aria !== void 0 && attrs["aria-label"] !== void 0 && attrs.aria !== attrs["aria-label"])
1061
+ this.error("WW_ACCESSIBILITY", "app.conflicting-name", node);
1062
+ if (node.kind === "button" && (attrs.buttonType === "submit" || attrs.action === "submit" || attrs.form !== void 0)) {
1063
+ let target = expanded.parent;
1064
+ if (typeof attrs.form === "string")
1065
+ target = this.element(
1066
+ {
1067
+ scope: owner.definition.kind === "component" ? "component" : owner.definition.kind === "layout" ? "shell" : "screen",
1068
+ id: attrs.form
1069
+ },
1070
+ expanded
1071
+ );
1072
+ else while (target !== void 0 && target.node.kind !== "form") target = target.parent;
1073
+ if ((target == null ? void 0 : target.node.kind) !== "form" || target.node.id === void 0)
1074
+ this.error("WW_REFERENCE", "app.missing-form", node);
1075
+ else expanded.formTarget = target.renderedId;
1076
+ if (attrs.action === "submit" && attrs.buttonType !== void 0 && attrs.buttonType !== "submit")
1077
+ this.error("WW_EVENT", "app.conflicting-submit-button", node);
1078
+ }
1079
+ if (strict && node.id === void 0 && ["on", "bind", "navigate", "opens", "toggles", "action"].some(
1080
+ (key) => attrs[key] !== void 0
1081
+ ))
1082
+ this.error("WW_REFERENCE", "app.addressed-id-required", node);
1083
+ if (attrs.navigate !== void 0) {
1084
+ if (typeof attrs.navigate !== "string" || !attrs.navigate.includes("::") && /^[A-Za-z][A-Za-z0-9+.-]*:/.test(attrs.navigate))
1085
+ this.error("WW_REFERENCE", "app.explicit-url-required", node);
1086
+ else {
1087
+ const [alias, id] = attrs.navigate.includes("::") ? attrs.navigate.split("::") : [void 0, attrs.navigate];
1088
+ const target = this.resolve(owner, "page", id, alias, node);
1089
+ if (target !== void 0)
1090
+ expanded.route = { namespace: target.module.namespace, id: target.definition.id };
1091
+ }
1092
+ }
1093
+ if (typeof attrs.href === "string" && !safeUrl(attrs.href))
1094
+ this.error("WW_REFERENCE", "app.unsafe-url", node);
1095
+ if (attrs.action !== void 0 && !["back", "close", "submit"].includes(textValue(attrs.action)))
1096
+ this.error("WW_REFERENCE", "app.unknown-action", node);
1097
+ const shorthand = ["navigate", "opens", "toggles"].filter((key) => attrs[key] !== void 0);
1098
+ if (attrs.action === "back" || attrs.action === "close") shorthand.push("action");
1099
+ if (shorthand.length > 1 || shorthand.length > 0 && asObjects(attrs.on).some((handler) => handler.event === "click"))
1100
+ this.error("WW_EVENT", "app.competing-click-handlers", node);
1101
+ if (shorthand.length === 1) {
1102
+ let effect;
1103
+ if (expanded.route)
1104
+ effect = {
1105
+ kind: "navigate",
1106
+ target: { kind: "screen", screen: { ...expanded.route } },
1107
+ history: "push"
1108
+ };
1109
+ else if (attrs.action === "back") effect = { kind: "navigateBack" };
1110
+ else {
1111
+ const scope = owner.definition.kind === "component" ? "component" : owner.definition.kind === "layout" ? "shell" : "screen";
1112
+ let id = textValue((_j = attrs.opens) != null ? _j : attrs.toggles);
1113
+ if (attrs.action === "close") {
1114
+ let parent = expanded.parent;
1115
+ while (parent && !["modal", "drawer", "popover", "dropdown"].includes(parent.node.kind))
1116
+ parent = parent.parent;
1117
+ if (!(parent == null ? void 0 : parent.node.id)) this.error("WW_REFERENCE", "app.missing-owning-overlay", node);
1118
+ else id = parent.node.id;
1119
+ }
1120
+ if (id)
1121
+ effect = {
1122
+ kind: attrs.action === "close" ? "close" : attrs.toggles === void 0 ? "open" : "toggleOverlay",
1123
+ target: { scope, id }
1124
+ };
1125
+ }
1126
+ if (effect)
1127
+ attrs.on = [
1128
+ ...asObjects(attrs.on),
1129
+ {
1130
+ id: "shorthand_click",
1131
+ event: "click",
1132
+ concurrency: "drop",
1133
+ operations: [
1134
+ {
1135
+ id: "primary_click",
1136
+ executionClass: "executable",
1137
+ effect,
1138
+ after: [],
1139
+ onFailure: "stop",
1140
+ obligationRefs: []
1141
+ }
1142
+ ]
1143
+ }
1144
+ ];
1145
+ }
1146
+ const declarationScope = owner.definition.kind === "component" ? "component" : owner.definition.kind === "layout" ? "shell" : "screen";
1147
+ for (const declaration of asObjects(owner.definition.attributes.states))
1148
+ this.state(`${declarationScope}:${textValue(declaration.id)}`, expanded);
1149
+ const stack = [attrs];
1150
+ while (stack.length > 0) {
1151
+ const value = stack.pop();
1152
+ if (Array.isArray(value)) {
1153
+ for (const item of value) stack.push(item);
1154
+ continue;
1155
+ }
1156
+ if (!object(value)) continue;
1157
+ if (typeof value.state === "string") this.state(value.state, expanded);
1158
+ for (const key of ["resultState", "statusState", "errorState", "source", "target"])
1159
+ if (typeof value[key] === "string" && /^(app|shell|screen|component):/.test(value[key]))
1160
+ this.state(value[key], expanded);
1161
+ if (object(value.read) && Array.isArray(value.read.path) && value.read.path.some(
1162
+ (part) => ["__proto__", "constructor", "prototype"].includes(textValue(part))
1163
+ ))
1164
+ this.error("WW_EFFECT", "app.unsafe-read-path", node);
1165
+ for (const [key, child] of Object.entries(value))
1166
+ if (!["literal", "initial", "states", "options"].includes(key)) stack.push(child);
1167
+ }
1168
+ if (object(attrs.bind)) {
1169
+ const state = this.state(textValue(attrs.bind.state), expanded);
1170
+ if (state !== void 0 && (attrs.bind.property === "checked" && state.type !== "boolean" || attrs.bind.property === "value" && !["number", "string", "boolean"].includes(textValue(state.type))))
1171
+ this.error("WW_STATE", "app.binding-type", node);
1172
+ }
1173
+ if (object(attrs.data) && typeof attrs.data.state === "string") {
1174
+ const state = this.state(attrs.data.state, expanded);
1175
+ if (state !== void 0) {
1176
+ const rows = state.initial;
1177
+ const columns = Array.isArray(attrs.columns) ? attrs.columns : [];
1178
+ if (!Array.isArray(rows) || node.kind === "table" && rows.some(
1179
+ (row) => !object(row) || columns.some(
1180
+ (column) => typeof column !== "string" || !Object.hasOwn(row, column) || row[column] !== null && !["string", "number", "boolean"].includes(typeof row[column])
1181
+ )
1182
+ ))
1183
+ this.error("WW_STATE", "app.bound-data-shape", node);
1184
+ }
1185
+ }
1186
+ const handlerIds = /* @__PURE__ */ new Set(), events = /* @__PURE__ */ new Set(), operationIds = /* @__PURE__ */ new Set();
1187
+ for (const handler of asObjects(attrs.on)) {
1188
+ const event = `${textValue(handler.event)}/${textValue((_k = handler.key) != null ? _k : "")}`;
1189
+ if (handlerIds.has(textValue(handler.id)) || events.has(event))
1190
+ this.error("WW_DUPLICATE_ID", "app.duplicate-handler", node);
1191
+ handlerIds.add(textValue(handler.id));
1192
+ events.add(event);
1193
+ const lifecycleOwner = node.kind === "page" || owner.definition.kind === "layout" && node.id === owner.definition.id;
1194
+ if (["enter", "exit"].includes(textValue(handler.event)) && !lifecycleOwner || handler.event === "submit" && node.kind !== "form")
1195
+ this.error("WW_EVENT", "app.event-owner", node);
1196
+ const previous = /* @__PURE__ */ new Set();
1197
+ for (const operation of asObjects(handler.operations)) {
1198
+ const id = textValue(operation.id);
1199
+ if (operationIds.has(id)) this.error("WW_DUPLICATE_ID", "app.duplicate-operation", node);
1200
+ operationIds.add(id);
1201
+ for (const dependency of Array.isArray(operation.after) ? operation.after : [])
1202
+ if (!previous.has(textValue(dependency)))
1203
+ this.error("WW_EFFECT", "app.operation-dependency", node, { id });
1204
+ previous.add(id);
1205
+ const effect = object(operation.effect) ? operation.effect : {};
1206
+ if (object(effect.target) && ["open", "close", "toggleOverlay", "focus", "validate"].includes(textValue(effect.kind))) {
1207
+ const target = this.element(effect.target, expanded);
1208
+ if (target === void 0 || effect.kind === "validate" && target.node.kind !== "form" || ["open", "close", "toggleOverlay"].includes(textValue(effect.kind)) && !["modal", "drawer", "popover", "dropdown", "tooltip"].includes(target.node.kind))
1209
+ this.error("WW_REFERENCE", "app.invalid-effect-target", node);
1210
+ else {
1211
+ (_l = expanded.effectTargets) != null ? _l : expanded.effectTargets = {};
1212
+ expanded.effectTargets[`${textValue(effect.target.scope)}:${textValue(effect.target.id)}`] = target.renderedId;
1213
+ }
1214
+ }
1215
+ if (handler.event === "exit" && (operation.executionClass !== "executable" || !["set", "reset", "toggle", "filter", "sort", "close"].includes(
1216
+ textValue(effect.kind)
1217
+ )))
1218
+ this.error("WW_EVENT", "app.exit-effect", node);
1219
+ if (effect.kind === "simulate") {
1220
+ const fixture = this.bundle.fixtures.find((fixture2) => fixture2.id === effect.fixtureRef);
1221
+ if (!fixtureIds.has(textValue(effect.fixtureRef)))
1222
+ this.error("WW_EFFECT", "app.missing-fixture", node);
1223
+ const result = expanded.stateBindings[textValue(effect.resultState)], status = expanded.stateBindings[textValue(effect.statusState)], error = expanded.stateBindings[textValue(effect.errorState)];
1224
+ if (!result || !status || !error || (/* @__PURE__ */ new Set([result.key, status.key, error.key])).size !== 3 || status.type !== "string" || status.initial !== "idle" || error.type !== "record" || jcs(error.initial) !== "{}")
1225
+ this.error("WW_EFFECT", "app.fixture-output-contract", node);
1226
+ else if (asObjects(fixture == null ? void 0 : fixture.steps).some(
1227
+ (step) => step.outcome === "success" && !matchesType(step.value, result.type)
1228
+ ))
1229
+ this.error("WW_EFFECT", "app.fixture-result-type", node);
1230
+ }
1231
+ if (effect.kind === "navigate" && object(effect.target)) {
1232
+ if (effect.target.kind === "screen" && object(effect.target.screen))
1233
+ this.route(effect.target.screen, node);
1234
+ if (effect.target.kind === "url" && !safeUrl(textValue(effect.target.url)))
1235
+ this.error("WW_REFERENCE", "app.unsafe-url", node);
1236
+ }
1237
+ }
1238
+ }
1239
+ }
1240
+ const stateKeys = new Set(this.bundle.states.map((state) => `app:${textValue(state.id)}`));
1241
+ for (const entry of this.expanded)
1242
+ for (const state of Object.values(entry.stateBindings)) stateKeys.add(state.key);
1243
+ if (stateKeys.size > 4096) this.error("WW_LIMIT", "app.state-count");
1244
+ for (const screen of this.screens) {
1245
+ const active = this.expanded.filter(
1246
+ (entry) => entry.identity.instanceRoot.kind === "screen" ? entry.identity.instanceRoot.namespace === screen.route.namespace && entry.identity.instanceRoot.id === screen.route.id : entry.owner.key === screen.shell
1247
+ );
1248
+ if (active.filter((entry) => entry.node.kind === "main").length > 1)
1249
+ this.error("WW_ACCESSIBILITY", "app.multiple-main-landmarks", (_m = screen.children[0]) == null ? void 0 : _m.node);
1250
+ }
1251
+ }
1252
+ element(ref, source) {
1253
+ const kind = ref.scope === "screen" ? "page" : ref.scope === "shell" ? "layout" : "component";
1254
+ const candidates = this.expanded.filter(
1255
+ (entry) => entry.node.id === ref.id && entry.owner.definition.kind === kind && (kind === "component" ? entry.owner === source.owner : true) && jcs(entry.identity.instanceRoot) === jcs(source.identity.instanceRoot) && entry.identity.instancePath.length <= source.identity.instancePath.length && entry.identity.instancePath.every(
1256
+ (step, index) => jcs(step) === jcs(source.identity.instancePath[index])
1257
+ )
1258
+ );
1259
+ candidates.sort((a, b) => b.identity.instancePath.length - a.identity.instancePath.length);
1260
+ return candidates[0];
1261
+ }
1262
+ };
1263
+ function matchesType(value, type) {
1264
+ return type === "record" ? object(value) : type === "list" ? Array.isArray(value) : typeof value === type;
1265
+ }
1266
+ function componentPath(path) {
1267
+ for (let index = path.length - 1; index >= 0; index--)
1268
+ if (path[index].kind === "use") return path.slice(0, index + 1);
1269
+ return [];
1270
+ }
1271
+ function substitute(value, bindings, missing) {
1272
+ if (typeof value === "string") {
1273
+ if (value.startsWith("$$")) return value.slice(1);
1274
+ const match = /^\$([A-Za-z_][A-Za-z0-9_-]*)$/.exec(value);
1275
+ if (match === null) return value;
1276
+ if (!Object.hasOwn(bindings, match[1])) {
1277
+ missing(match[1]);
1278
+ return value;
1279
+ }
1280
+ return bindings[match[1]];
1281
+ }
1282
+ if (Array.isArray(value)) return value.map((item) => substitute(item, bindings, missing));
1283
+ if (object(value)) {
1284
+ if (typeof value.param === "string" && Object.keys(value).length === 1) {
1285
+ if (!Object.hasOwn(bindings, value.param)) {
1286
+ missing(value.param);
1287
+ return value;
1288
+ }
1289
+ return { literal: bindings[value.param] };
1290
+ }
1291
+ return Object.fromEntries(
1292
+ Object.entries(value).map(([key, item]) => [key, substitute(item, bindings, missing)])
1293
+ );
1294
+ }
1295
+ return value;
1296
+ }
1297
+ function attrsDsl(attrs) {
1298
+ return Object.entries(attrs).map(([key, value]) => `${key}=${dsl(value)}`).join(" ");
1299
+ }
1300
+ function safeUrl(value) {
1301
+ if ([...value].some((character) => character.charCodeAt(0) <= 32 || character.charCodeAt(0) === 127))
1302
+ return false;
1303
+ try {
1304
+ const url = new URL(value);
1305
+ return ["https:", "http:", "mailto:", "tel:"].includes(url.protocol) && !url.username && !url.password;
1306
+ } catch (e2) {
1307
+ return false;
1308
+ }
1309
+ }
1310
+ function asObjects(value) {
1311
+ return Array.isArray(value) ? value.filter(object) : [];
1312
+ }
1313
+ function linkAppV4(bundle) {
1314
+ const data = typeof bundle === "object" && bundle !== null ? bundles.get(bundle) : void 0;
1315
+ if (data === void 0) return failed([diagnostic("WW_SCHEMA", "app.untrusted-bundle")]);
1316
+ const linker = new Linker(bundle, data);
1317
+ linker.index();
1318
+ linker.imports();
1319
+ linker.references();
1320
+ linker.registryChecks();
1321
+ if (linker.diagnostics.length > 0) return failed(linker.diagnostics);
1322
+ linker.expandAll();
1323
+ linker.semantics();
1324
+ if (linker.diagnostics.length > 0) return failed(linker.diagnostics);
1325
+ const sourceMap = linker.expanded.map(
1326
+ (entry) => ({
1327
+ renderedId: entry.renderedId,
1328
+ identity: entry.identity,
1329
+ moduleId: entry.owner.module.id,
1330
+ source: entry.source,
1331
+ invocationSources: entry.invocationSources,
1332
+ requirementRefs: stringArray(entry.node.attributes.requirementRefs),
1333
+ obligationRefs: stringArray(entry.node.attributes.obligationRefs),
1334
+ operationIds: asObjects(entry.node.attributes.on).flatMap(
1335
+ (handler) => asObjects(handler.operations).map((operation) => textValue(operation.id))
1336
+ )
1337
+ })
1338
+ );
1339
+ const linked = freeze({
1340
+ [linkedBrand]: true,
1341
+ kind: "LinkedApp",
1342
+ languageVersion: "4.0.0",
1343
+ id: bundle.id,
1344
+ digest: _chunkIMUVIIJRcjs.digestV4.call(void 0, jcs(bundle)),
1345
+ sourceMap
1346
+ });
1347
+ links.set(linked, {
1348
+ bundle,
1349
+ screens: linker.screens,
1350
+ shells: linker.shells,
1351
+ nodes: linker.expanded,
1352
+ sourceMap
1353
+ });
1354
+ return { ok: true, value: linked, diagnostics: [] };
1355
+ }
1356
+ function stringArray(value) {
1357
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
1358
+ }
1359
+ function getLinkedAppData(linked) {
1360
+ return typeof linked === "object" && linked !== null ? links.get(linked) : void 0;
1361
+ }
1362
+
1363
+ // src/app/linker.ts
1364
+ function createAppNodeId(namespace, kind, id) {
1365
+ return `${encodeURIComponent(namespace)}:${kind}:${encodeURIComponent(id)}`;
1366
+ }
1367
+ function createAppComponentInstanceId(ownerId, targetId, path) {
1368
+ return `${ownerId}:instance:${encodeURIComponent(targetId)}:${path.join(".")}`;
1369
+ }
1370
+ function compareSource(left, right) {
1371
+ return compareText(left.sourceId, right.sourceId) || left.location.start.offset - right.location.start.offset || left.location.end.offset - right.location.end.offset;
1372
+ }
1373
+ function compareText(left, right) {
1374
+ return left < right ? -1 : left > right ? 1 : 0;
1375
+ }
1376
+ function compareDiagnostic(left, right) {
1377
+ return compareSource(left.source, right.source) || compareText(left.code, right.code) || compareText(left.message, right.message);
1378
+ }
1379
+ function definitionKey(namespace, kind, id) {
1380
+ return `${namespace}\0${kind}\0${id}`;
1381
+ }
1382
+ function nodeSource(module) {
1383
+ return module.source;
1384
+ }
1385
+ function manifestSource(manifest, location2) {
1386
+ return { sourceId: manifest.sourceId, location: location2 };
1387
+ }
1388
+ function componentUses(node) {
1389
+ const uses = [];
1390
+ const visit = (current) => {
1391
+ if (current.type === "ComponentUse") {
1392
+ uses.push(current);
1393
+ for (const fill of current.fills) for (const child of fill.children) visit(child);
1394
+ return;
1395
+ }
1396
+ if ("children" in current && Array.isArray(current.children)) {
1397
+ for (const child of current.children) visit(child);
1398
+ }
1399
+ };
1400
+ visit(node);
1401
+ return uses;
1402
+ }
1403
+ function referencesOf(pending) {
1404
+ var _a;
1405
+ const inferred = componentUses(pending.input.node).map(
1406
+ (use) => {
1407
+ var _a2;
1408
+ return {
1409
+ kind: "component",
1410
+ id: use.name,
1411
+ ...use.namespace === void 0 ? {} : { namespace: use.namespace },
1412
+ source: {
1413
+ sourceId: pending.input.source.sourceId,
1414
+ location: (_a2 = use.loc) != null ? _a2 : pending.input.source.location
1415
+ }
1416
+ };
1417
+ }
1418
+ );
1419
+ return [...(_a = pending.input.references) != null ? _a : [], ...inferred];
1420
+ }
1421
+ function resolveReferences(pending, definitions, diagnostics) {
1422
+ var _a;
1423
+ const resolved = [];
1424
+ for (const reference of referencesOf(pending)) {
1425
+ const namespace = (_a = reference.namespace) != null ? _a : pending.namespace;
1426
+ const target = definitions.get(definitionKey(namespace, reference.kind, reference.id));
1427
+ if (target === void 0) {
1428
+ diagnostics.push({
1429
+ code: "missing-reference",
1430
+ message: `Missing ${reference.kind} reference "${namespace}:${reference.id}"`,
1431
+ source: reference.source
1432
+ });
1433
+ continue;
1434
+ }
1435
+ resolved.push({
1436
+ kind: reference.kind,
1437
+ id: reference.id,
1438
+ namespace,
1439
+ targetId: target.nodeId,
1440
+ source: reference.source
1441
+ });
1442
+ }
1443
+ return resolved;
1444
+ }
1445
+ function findCyclicReferences(definitions, diagnostics) {
1446
+ const byId = new Map(definitions.map((definition) => [definition.nodeId, definition]));
1447
+ const indexById = /* @__PURE__ */ new Map();
1448
+ const lowById = /* @__PURE__ */ new Map();
1449
+ const stack = [];
1450
+ const onStack = /* @__PURE__ */ new Set();
1451
+ let nextIndex = 0;
1452
+ const enter = (nodeId) => {
1453
+ const index = nextIndex++;
1454
+ indexById.set(nodeId, index);
1455
+ lowById.set(nodeId, index);
1456
+ stack.push(nodeId);
1457
+ onStack.add(nodeId);
1458
+ return { nodeId, index, nextReference: 0 };
1459
+ };
1460
+ const visit = (start) => {
1461
+ var _a, _b, _c, _d, _e, _f;
1462
+ const frames = [enter(start)];
1463
+ while (frames.length > 0) {
1464
+ const frame = frames[frames.length - 1];
1465
+ if (frame === void 0) break;
1466
+ const { nodeId, index } = frame;
1467
+ const references = (_b = (_a = byId.get(nodeId)) == null ? void 0 : _a.references) != null ? _b : [];
1468
+ if (frame.nextReference < references.length) {
1469
+ const reference = references[frame.nextReference++];
1470
+ if (reference === void 0 || !byId.has(reference.targetId)) continue;
1471
+ if (!indexById.has(reference.targetId)) {
1472
+ frames.push(enter(reference.targetId));
1473
+ } else if (onStack.has(reference.targetId)) {
1474
+ lowById.set(
1475
+ nodeId,
1476
+ Math.min((_c = lowById.get(nodeId)) != null ? _c : index, (_d = indexById.get(reference.targetId)) != null ? _d : index)
1477
+ );
1478
+ }
1479
+ continue;
1480
+ }
1481
+ frames.pop();
1482
+ const parent = frames[frames.length - 1];
1483
+ if (parent !== void 0) {
1484
+ lowById.set(
1485
+ parent.nodeId,
1486
+ Math.min((_e = lowById.get(parent.nodeId)) != null ? _e : parent.index, (_f = lowById.get(nodeId)) != null ? _f : index)
1487
+ );
1488
+ }
1489
+ if (lowById.get(nodeId) !== index) continue;
1490
+ const members = [];
1491
+ let member;
1492
+ do {
1493
+ member = stack.pop();
1494
+ if (member === void 0) break;
1495
+ onStack.delete(member);
1496
+ members.push(member);
1497
+ } while (member !== nodeId);
1498
+ const memberSet = new Set(members);
1499
+ const cyclicEdges = members.flatMap((id) => {
1500
+ var _a2;
1501
+ const owner = byId.get(id);
1502
+ return ((_a2 = owner == null ? void 0 : owner.references) != null ? _a2 : []).filter((reference) => memberSet.has(reference.targetId));
1503
+ });
1504
+ const selfCycle = members.length === 1 && cyclicEdges.some((edge) => edge.targetId === nodeId);
1505
+ if (members.length < 2 && !selfCycle) continue;
1506
+ const source = cyclicEdges.map((edge) => edge.source).sort(compareSource)[0];
1507
+ if (source === void 0) continue;
1508
+ const names = [...members].sort().join(", ");
1509
+ diagnostics.push({
1510
+ code: "cyclic-reference",
1511
+ message: `Cyclic layout/component reference among ${names}`,
1512
+ source
1513
+ });
1514
+ }
1515
+ };
1516
+ for (const definition of [...definitions].sort(
1517
+ (left, right) => compareText(left.nodeId, right.nodeId)
1518
+ )) {
1519
+ if (!indexById.has(definition.nodeId)) visit(definition.nodeId);
1520
+ }
1521
+ }
1522
+ function useSource(owner, use) {
1523
+ var _a;
1524
+ return {
1525
+ sourceId: owner.input.source.sourceId,
1526
+ location: (_a = use.loc) != null ? _a : owner.input.source.location
1527
+ };
1528
+ }
1529
+ function childNodes(node) {
1530
+ return "children" in node && Array.isArray(node.children) ? node.children : [];
1531
+ }
1532
+ function namedSlots(definition) {
1533
+ const slots = /* @__PURE__ */ new Map();
1534
+ const visit = (node) => {
1535
+ if (node.type === "ComponentUse") return;
1536
+ if (node.type === "Slot" && node.name !== void 0 && !slots.has(node.name)) {
1537
+ slots.set(node.name, node);
1538
+ }
1539
+ for (const child of childNodes(node)) visit(child);
1540
+ };
1541
+ for (const child of definition.children) visit(child);
1542
+ return slots;
1543
+ }
1544
+ function validateComponentDefinitions(definitions, diagnostics) {
1545
+ var _a;
1546
+ const invalid = /* @__PURE__ */ new Set();
1547
+ for (const pending of definitions.values()) {
1548
+ if (pending.kind !== "component") continue;
1549
+ const definition = pending.input.node;
1550
+ const parameterNames = /* @__PURE__ */ new Set();
1551
+ for (const parameter of (_a = definition.parameters) != null ? _a : []) {
1552
+ if (parameterNames.has(parameter.name)) {
1553
+ diagnostics.push({
1554
+ code: "invalid-component-definition",
1555
+ message: `Duplicate parameter "${parameter.name}" in component "${pending.namespace}:${pending.input.id}"`,
1556
+ source: pending.input.source
1557
+ });
1558
+ invalid.add(pending.nodeId);
1559
+ }
1560
+ parameterNames.add(parameter.name);
1561
+ }
1562
+ const slotNames = /* @__PURE__ */ new Set();
1563
+ const inspect = (node) => {
1564
+ var _a2;
1565
+ if (node.type === "ComponentUse") return;
1566
+ if (node.type === "Slot") {
1567
+ const name = (_a2 = node.name) == null ? void 0 : _a2.trim();
1568
+ if (name === void 0 || name.length === 0) {
1569
+ diagnostics.push({
1570
+ code: "invalid-component-definition",
1571
+ message: `Unnamed slot in component "${pending.namespace}:${pending.input.id}"`,
1572
+ source: pending.input.source
1573
+ });
1574
+ invalid.add(pending.nodeId);
1575
+ } else if (slotNames.has(name)) {
1576
+ diagnostics.push({
1577
+ code: "invalid-component-definition",
1578
+ message: `Duplicate slot "${name}" in component "${pending.namespace}:${pending.input.id}"`,
1579
+ source: pending.input.source
1580
+ });
1581
+ invalid.add(pending.nodeId);
1582
+ } else {
1583
+ slotNames.add(name);
1584
+ }
1585
+ }
1586
+ for (const child of childNodes(node)) inspect(child);
1587
+ };
1588
+ for (const child of definition.children) inspect(child);
1589
+ for (const reference of collectParameterReferences(definition.children)) {
1590
+ if (parameterNames.has(reference.name)) continue;
1591
+ diagnostics.push({
1592
+ code: "invalid-component-definition",
1593
+ message: `Unknown parameter reference "$${reference.name}" in component "${pending.namespace}:${pending.input.id}"`,
1594
+ source: pending.input.source
1595
+ });
1596
+ invalid.add(pending.nodeId);
1597
+ }
1598
+ }
1599
+ return invalid;
1600
+ }
1601
+ function substituteTemplate(value, inputs) {
1602
+ if (typeof value === "string") {
1603
+ const name = parameterReferenceName(value);
1604
+ return name !== void 0 && name in inputs ? inputs[name] : value;
1605
+ }
1606
+ if (Array.isArray(value)) return value.map((item) => substituteTemplate(item, inputs));
1607
+ if (value === null || typeof value !== "object") return value;
1608
+ const result = {};
1609
+ for (const [key, item] of Object.entries(value)) {
1610
+ result[key] = key === "loc" ? item : substituteTemplate(item, inputs);
1611
+ }
1612
+ return result;
1613
+ }
1614
+ function expandComponentUse(use, path, context) {
1615
+ var _a, _b;
1616
+ const namespace = (_a = use.namespace) != null ? _a : context.declaration.namespace;
1617
+ const target = context.definitions.get(definitionKey(namespace, "component", use.name));
1618
+ if (target === void 0 || target.kind !== "component") return use;
1619
+ const definition = target.input.node;
1620
+ const source = useSource(context.declaration, use);
1621
+ let valid = !context.invalidDefinitions.has(target.nodeId);
1622
+ const declaredParameters = (_b = definition.parameters) != null ? _b : [];
1623
+ const parameters = new Map(declaredParameters.map((item) => [item.name, item.valueType]));
1624
+ for (const parameter of declaredParameters) {
1625
+ if (!(parameter.name in use.inputs)) {
1626
+ context.diagnostics.push({
1627
+ code: "invalid-component-invocation",
1628
+ message: `Missing input "${parameter.name}" for component "${namespace}:${use.name}"`,
1629
+ source
1630
+ });
1631
+ valid = false;
1632
+ }
1633
+ }
1634
+ for (const [name, value] of Object.entries(use.inputs)) {
1635
+ const expected = parameters.get(name);
1636
+ if (expected === void 0) {
1637
+ context.diagnostics.push({
1638
+ code: "invalid-component-invocation",
1639
+ message: `Unknown input "${name}" for component "${namespace}:${use.name}"`,
1640
+ source
1641
+ });
1642
+ valid = false;
1643
+ } else if (typeof value !== expected) {
1644
+ context.diagnostics.push({
1645
+ code: "invalid-component-invocation",
1646
+ message: `Input "${name}" for component "${namespace}:${use.name}" must be ${expected}, received ${typeof value}`,
1647
+ source
1648
+ });
1649
+ valid = false;
1650
+ }
1651
+ }
1652
+ const slots = namedSlots(definition);
1653
+ const fills = /* @__PURE__ */ new Map();
1654
+ for (const fill of use.fills) {
1655
+ if (fills.has(fill.name)) {
1656
+ context.diagnostics.push({
1657
+ code: "invalid-component-invocation",
1658
+ message: `Duplicate fill "${fill.name}" for component "${namespace}:${use.name}"`,
1659
+ source
1660
+ });
1661
+ valid = false;
1662
+ } else {
1663
+ fills.set(fill.name, fill);
1664
+ }
1665
+ if (!slots.has(fill.name)) {
1666
+ context.diagnostics.push({
1667
+ code: "invalid-component-invocation",
1668
+ message: `Unknown slot "${fill.name}" for component "${namespace}:${use.name}"`,
1669
+ source
1670
+ });
1671
+ valid = false;
1672
+ }
1673
+ }
1674
+ for (const slot of slots.keys()) {
1675
+ if (!fills.has(slot)) {
1676
+ context.diagnostics.push({
1677
+ code: "invalid-component-invocation",
1678
+ message: `Missing fill for slot "${slot}" in component "${namespace}:${use.name}"`,
1679
+ source
1680
+ });
1681
+ valid = false;
1682
+ }
1683
+ }
1684
+ if (!valid) return use;
1685
+ const expandNodes = (nodes, basePath, expansion, inputs) => nodes.flatMap((node, index) => {
1686
+ const nodePath = [...basePath, index];
1687
+ if (node.type === "Slot" && node.name !== void 0) {
1688
+ const fill = fills.get(node.name);
1689
+ return fill === void 0 ? [] : expandNodes(fill.children, [...nodePath, 0], context);
1690
+ }
1691
+ const substituted = inputs === void 0 ? node : substituteTemplate(node, inputs);
1692
+ if (substituted.type === "ComponentUse") {
1693
+ return [expandComponentUse(substituted, nodePath, expansion)];
1694
+ }
1695
+ if ("children" in substituted && Array.isArray(substituted.children)) {
1696
+ substituted.children = expandNodes(
1697
+ substituted.children,
1698
+ nodePath,
1699
+ expansion,
1700
+ inputs
1701
+ );
1702
+ }
1703
+ return [substituted];
1704
+ });
1705
+ return {
1706
+ ...use,
1707
+ targetId: target.nodeId,
1708
+ instanceId: createAppComponentInstanceId(context.owner.nodeId, target.nodeId, path),
1709
+ children: expandNodes(
1710
+ definition.children,
1711
+ path,
1712
+ { ...context, declaration: target },
1713
+ use.inputs
1714
+ )
1715
+ };
1716
+ }
1717
+ function expandNode(node, path, context) {
1718
+ if (node.type === "ComponentUse") return expandComponentUse(node, path, context);
1719
+ const clone = substituteTemplate(node, {});
1720
+ if ("children" in clone && Array.isArray(clone.children)) {
1721
+ clone.children = clone.children.map(
1722
+ (child, index) => expandNode(child, [...path, index], context)
1723
+ );
1724
+ }
1725
+ return clone;
1726
+ }
1727
+ function linkApp(input, modules) {
1728
+ if (modules === void 0) return linkAppV4(input);
1729
+ return linkLegacyApp(input, modules);
1730
+ }
1731
+ function linkLegacyApp(manifest, modules) {
1732
+ const diagnostics = [];
1733
+ const moduleGroups = /* @__PURE__ */ new Map();
1734
+ for (const module of modules) {
1735
+ const group = moduleGroups.get(module.id);
1736
+ if (group === void 0) moduleGroups.set(module.id, [module]);
1737
+ else group.push(module);
1738
+ }
1739
+ for (const group of moduleGroups.values()) group.sort((a, b) => compareSource(a.source, b.source));
1740
+ for (const [id, group] of moduleGroups) {
1741
+ for (const duplicate of group.slice(1)) {
1742
+ diagnostics.push({
1743
+ code: "duplicate-module",
1744
+ message: `Duplicate module input "${id}"`,
1745
+ source: nodeSource(duplicate)
1746
+ });
1747
+ }
1748
+ }
1749
+ const selected = [];
1750
+ const seenModuleIds = /* @__PURE__ */ new Set();
1751
+ const seenNamespaces = /* @__PURE__ */ new Set();
1752
+ for (const entry of manifest.modules) {
1753
+ const source = manifestSource(manifest, entry.location);
1754
+ if (seenModuleIds.has(entry.id)) {
1755
+ diagnostics.push({
1756
+ code: "duplicate-module",
1757
+ message: `Duplicate module manifest entry "${entry.id}"`,
1758
+ source
1759
+ });
1760
+ continue;
1761
+ }
1762
+ seenModuleIds.add(entry.id);
1763
+ if (seenNamespaces.has(entry.namespace)) {
1764
+ diagnostics.push({
1765
+ code: "duplicate-namespace",
1766
+ message: `Duplicate module namespace "${entry.namespace}"`,
1767
+ source
1768
+ });
1769
+ continue;
1770
+ }
1771
+ seenNamespaces.add(entry.namespace);
1772
+ const group = moduleGroups.get(entry.id);
1773
+ if (group === void 0) {
1774
+ diagnostics.push({
1775
+ code: "missing-module",
1776
+ message: `Missing module input "${entry.id}"`,
1777
+ source
1778
+ });
1779
+ continue;
1780
+ }
1781
+ if (group.length > 1) continue;
1782
+ const module = group[0];
1783
+ if (module === void 0) continue;
1784
+ selected.push({ module, namespace: entry.namespace });
1785
+ }
1786
+ const definitions = /* @__PURE__ */ new Map();
1787
+ const screens = /* @__PURE__ */ new Map();
1788
+ const pendingModules = [];
1789
+ for (const { module, namespace } of selected) {
1790
+ const nodes = [];
1791
+ const addDefinition = (kind, input) => {
1792
+ const pending = {
1793
+ kind,
1794
+ moduleId: module.id,
1795
+ namespace,
1796
+ input,
1797
+ nodeId: createAppNodeId(namespace, kind, input.id)
1798
+ };
1799
+ const key = definitionKey(namespace, kind, input.id);
1800
+ if (definitions.has(key)) {
1801
+ diagnostics.push({
1802
+ code: "duplicate-definition",
1803
+ message: `Duplicate ${kind} definition "${namespace}:${input.id}"`,
1804
+ source: input.source
1805
+ });
1806
+ } else {
1807
+ definitions.set(key, pending);
1808
+ nodes.push(pending);
1809
+ }
1810
+ };
1811
+ for (const layout of module.layouts) addDefinition("layout", layout);
1812
+ for (const component of module.components) addDefinition("component", component);
1813
+ for (const screen of module.screens) {
1814
+ const pending = {
1815
+ kind: "screen",
1816
+ moduleId: module.id,
1817
+ namespace,
1818
+ input: screen,
1819
+ nodeId: createAppNodeId(namespace, "screen", screen.id)
1820
+ };
1821
+ const key = `${namespace}\0${screen.id}`;
1822
+ if (screens.has(key)) {
1823
+ diagnostics.push({
1824
+ code: "duplicate-screen",
1825
+ message: `Duplicate screen definition "${namespace}:${screen.id}"`,
1826
+ source: screen.source
1827
+ });
1828
+ } else {
1829
+ screens.set(key, pending);
1830
+ nodes.push(pending);
1831
+ }
1832
+ }
1833
+ pendingModules.push({ id: module.id, namespace, nodes });
1834
+ }
1835
+ const resolvedById = /* @__PURE__ */ new Map();
1836
+ const toParts = (pending) => ({
1837
+ nodeId: pending.nodeId,
1838
+ id: pending.input.id,
1839
+ moduleId: pending.moduleId,
1840
+ namespace: pending.namespace,
1841
+ source: pending.input.source,
1842
+ references: resolveReferences(pending, definitions, diagnostics)
1843
+ });
1844
+ const referencedNodes = pendingModules.flatMap(
1845
+ (module) => module.nodes.map((pending) => ({ pending, parts: toParts(pending) }))
1846
+ );
1847
+ findCyclicReferences(
1848
+ referencedNodes.filter(({ pending }) => pending.kind !== "screen").map(({ parts }) => parts),
1849
+ diagnostics
1850
+ );
1851
+ diagnostics.sort(compareDiagnostic);
1852
+ if (diagnostics.length > 0) return { ok: false, document: null, diagnostics };
1853
+ const invalidDefinitions = validateComponentDefinitions(definitions, diagnostics);
1854
+ for (const { pending, parts } of referencedNodes) {
1855
+ const expansion = {
1856
+ owner: pending,
1857
+ declaration: pending,
1858
+ definitions,
1859
+ invalidDefinitions,
1860
+ diagnostics
1861
+ };
1862
+ if (pending.kind === "layout") {
1863
+ resolvedById.set(pending.nodeId, {
1864
+ ...parts,
1865
+ kind: "layout",
1866
+ node: expandNode(pending.input.node, [], expansion)
1867
+ });
1868
+ } else if (pending.kind === "component") {
1869
+ resolvedById.set(pending.nodeId, {
1870
+ ...parts,
1871
+ kind: "component",
1872
+ node: pending.input.node
1873
+ });
1874
+ } else {
1875
+ resolvedById.set(pending.nodeId, {
1876
+ ...parts,
1877
+ kind: "screen",
1878
+ node: expandNode(pending.input.node, [], expansion)
1879
+ });
1880
+ }
1881
+ }
1882
+ diagnostics.sort(compareDiagnostic);
1883
+ if (diagnostics.length > 0) return { ok: false, document: null, diagnostics };
1884
+ const resolvedModules = pendingModules.map((pendingModule) => {
1885
+ const nodes = pendingModule.nodes.map((node) => resolvedById.get(node.nodeId));
1886
+ return {
1887
+ id: pendingModule.id,
1888
+ namespace: pendingModule.namespace,
1889
+ layouts: nodes.filter((node) => (node == null ? void 0 : node.kind) === "layout"),
1890
+ components: nodes.filter((node) => (node == null ? void 0 : node.kind) === "component"),
1891
+ screens: nodes.filter((node) => (node == null ? void 0 : node.kind) === "screen")
1892
+ };
1893
+ });
1894
+ const layouts = resolvedModules.flatMap((module) => module.layouts);
1895
+ const components = resolvedModules.flatMap((module) => module.components);
1896
+ const linkedScreens = resolvedModules.flatMap((module) => module.screens);
1897
+ const sourceMap = resolvedModules.flatMap(
1898
+ (module) => [...module.layouts, ...module.components, ...module.screens].map((node) => ({
1899
+ nodeId: node.nodeId,
1900
+ source: node.source
1901
+ }))
1902
+ );
1903
+ const document2 = {
1904
+ type: "AppDocument",
1905
+ id: manifest.id,
1906
+ modules: resolvedModules,
1907
+ layouts,
1908
+ components,
1909
+ screens: linkedScreens,
1910
+ sourceMap
1911
+ };
1912
+ return { ok: true, document: document2, diagnostics: [] };
1913
+ }
1914
+
1915
+ // src/app/compiler.ts
1916
+ function layoutName(layout) {
1917
+ return layout.nodeId;
1918
+ }
1919
+ function projectLayout(layout) {
1920
+ return { ...layout.node, name: layoutName(layout) };
1921
+ }
1922
+ function projectScreen(screen) {
1923
+ var _a;
1924
+ const uses = (_a = screen.node.uses) == null ? void 0 : _a.trim();
1925
+ if (uses === void 0 || uses.length === 0) return { ...screen.node };
1926
+ const target = screen.references.find(
1927
+ (reference) => reference.kind === "layout" && reference.id === uses
1928
+ );
1929
+ return {
1930
+ ...screen.node,
1931
+ uses: target === void 0 ? screen.node.uses : target.targetId
1932
+ };
1933
+ }
1934
+ function compileApp(document2, options = {}) {
1935
+ if (!("screens" in document2)) return compileAppV4(document2);
1936
+ const projected = {
1937
+ type: "Document",
1938
+ children: [...document2.layouts.map(projectLayout), ...document2.screens.map(projectScreen)]
1939
+ };
1940
+ return _chunk5DGRIQDUcjs.renderSite.call(void 0, projected, { ...options, annotationStyle: "neutral" });
1941
+ }
1942
+ function linkAndCompileApp(input, modules, options = {}) {
1943
+ if (modules === void 0) {
1944
+ const linked2 = linkApp(input);
1945
+ return linked2.ok ? compileApp(linked2.value) : linked2;
1946
+ }
1947
+ const linked = linkApp(input, modules);
1948
+ if (!linked.ok) return { ...linked, html: null };
1949
+ return { ...linked, html: compileApp(linked.document, options) };
1950
+ }
1951
+ function escape(value) {
1952
+ return textValue(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1953
+ }
1954
+ function attribute(name, value) {
1955
+ return value === void 0 || value === false ? "" : ` ${name}="${escape(value === true ? "" : value)}"`;
1956
+ }
1957
+ function jsonBlock(value) {
1958
+ return jcs(value).replace(/</g, "\\u003c");
1959
+ }
1960
+ function address(route) {
1961
+ return `#wf/${encodeURIComponent(route.namespace)}/${encodeURIComponent(route.id)}${route.variant === void 0 ? "" : `?variant=${encodeURIComponent(route.variant)}`}`;
1962
+ }
1963
+ function hashBase64(value) {
1964
+ var _a, _b;
1965
+ const hex = _chunkIMUVIIJRcjs.digestV4.call(void 0, value).slice(7), alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1966
+ const bytes = Array.from(
1967
+ { length: 32 },
1968
+ (_, index) => Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16)
1969
+ );
1970
+ let output = "";
1971
+ for (let index = 0; index < bytes.length; index += 3) {
1972
+ const value2 = bytes[index] << 16 | ((_a = bytes[index + 1]) != null ? _a : 0) << 8 | ((_b = bytes[index + 2]) != null ? _b : 0);
1973
+ output += alphabet[value2 >>> 18 & 63] + alphabet[value2 >>> 12 & 63] + (index + 1 < bytes.length ? alphabet[value2 >>> 6 & 63] : "=") + (index + 2 < bytes.length ? alphabet[value2 & 63] : "=");
1974
+ }
1975
+ return output;
1976
+ }
1977
+ var HtmlArtifact = class {
1978
+ constructor(data, program) {
1979
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "data", data);
1980
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "program", program);
1981
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "unsupported", []);
1982
+ _chunkETV4XYOVcjs.__publicField.call(void 0, this, "rules", []);
1983
+ }
1984
+ node(entry) {
1985
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1986
+ const { node, renderedId } = entry;
1987
+ const attrs = node.attributes;
1988
+ const label = (_b = node.label) != null ? _b : textValue((_a = attrs.label) != null ? _a : "");
1989
+ const children = () => entry.children.map((child) => this.node(child)).join("");
1990
+ let common = attribute("id", renderedId) + attribute("class", `wf-node wf-${node.kind} ${renderedId}`) + attribute("data-wf-kind", node.kind) + attribute("data-wf-source", entry.owner.module.id) + attribute("data-wf-identity", jcs(entry.identity)) + attribute(
1991
+ "data-wf-requirements",
1992
+ attrs.requirementRefs === void 0 ? void 0 : jcs(attrs.requirementRefs)
1993
+ ) + attribute(
1994
+ "data-wf-obligations",
1995
+ attrs.obligationRefs === void 0 ? void 0 : jcs(attrs.obligationRefs)
1996
+ ) + attribute("data-wf-on", attrs.on === void 0 ? void 0 : jcs(attrs.on)) + attribute("data-wf-bind", attrs.bind === void 0 ? void 0 : jcs(attrs.bind)) + attribute("data-wf-data", attrs.data === void 0 ? void 0 : jcs(attrs.data)) + attribute("data-wf-columns", attrs.columns === void 0 ? void 0 : jcs(attrs.columns)) + attribute(
1997
+ "data-wf-targets",
1998
+ entry.effectTargets === void 0 ? void 0 : jcs(entry.effectTargets)
1999
+ ) + attribute(
2000
+ "data-wf-visible-when",
2001
+ attrs.visibleWhen === void 0 ? void 0 : jcs(attrs.visibleWhen)
2002
+ ) + attribute(
2003
+ "data-wf-enabled-when",
2004
+ attrs.enabledWhen === void 0 ? void 0 : jcs(attrs.enabledWhen)
2005
+ ) + attribute("data-wf-when", attrs.when === void 0 ? void 0 : jcs(attrs.when)) + attribute("data-wf-state-bindings", jcs(entry.stateBindings)) + attribute("data-wf-navigate", entry.route === void 0 ? void 0 : address(entry.route)) + attribute("aria-label", (_c = attrs["aria-label"]) != null ? _c : attrs.aria) + attribute("aria-busy", attrs.loading === true ? "true" : void 0) + attribute(
2006
+ "data-wf-disabled",
2007
+ attrs.disabled === true || attrs.loading === true ? true : void 0
2008
+ ) + attribute("data-wf-action", attrs.action);
2009
+ for (const handler of asObjects(attrs.on))
2010
+ for (const operation of asObjects(handler.operations)) {
2011
+ if (operation.executionClass === "specified") {
2012
+ this.unsupported.push({
2013
+ renderedId,
2014
+ handlerId: textValue(handler.id),
2015
+ operationId: textValue(operation.id)
2016
+ });
2017
+ }
2018
+ }
2019
+ if (entry.slot) return `<div${common} data-wf-slot="${escape(entry.owner.key)}"></div>`;
2020
+ this.layout(entry);
2021
+ const bound = object(attrs.bind) ? entry.stateBindings[textValue(attrs.bind.state)] : void 0;
2022
+ const value = (_d = bound == null ? void 0 : bound.initial) != null ? _d : attrs.value;
2023
+ const disabled = attrs.disabled === true || attrs.loading === true;
2024
+ const labelled = (control) => `<div class="wf-field" data-wf-field="${renderedId}">${label ? `<label for="${renderedId}">${escape(label)}</label>` : ""}${control}<span id="${renderedId}-error" role="alert" hidden></span></div>`;
2025
+ const scalarAttrs = attribute("name", attrs.name) + attribute("disabled", disabled) + attribute("required", attrs.required) + attribute("readonly", attrs.readonly) + attribute("placeholder", attrs.placeholder) + attribute("autocomplete", attrs.autocomplete) + attribute("min", attrs.min) + attribute("max", attrs.max) + attribute("step", attrs.step) + attribute("data-wf-min-length", attrs.minLength) + attribute("data-wf-max-length", attrs.maxLength);
2026
+ if (node.kind === "input" || ["checkbox", "radio", "switch", "slider"].includes(node.kind)) {
2027
+ const type = node.kind === "input" ? (_e = attrs.inputType) != null ? _e : "text" : node.kind === "switch" ? "checkbox" : node.kind === "slider" ? "range" : node.kind;
2028
+ return labelled(
2029
+ `<input${common}${scalarAttrs}${attribute("type", type)}${attribute("role", node.kind === "switch" ? "switch" : void 0)}${attribute("value", value)}${attribute("checked", (bound == null ? void 0 : bound.type) === "boolean" ? bound.initial : attrs.checked)}>`
2030
+ );
2031
+ }
2032
+ if (node.kind === "textarea")
2033
+ return labelled(
2034
+ `<textarea${common}${scalarAttrs}${attribute("rows", attrs.rows)}>${escape(value != null ? value : "")}</textarea>`
2035
+ );
2036
+ if (node.kind === "select")
2037
+ return labelled(
2038
+ `<select${common}${scalarAttrs}>${asObjects(attrs.options).map(
2039
+ (option) => `<option${attribute("value", option.value)}${attribute("selected", value === option.value)}${attribute("disabled", option.disabled)}>${escape(option.label)}</option>`
2040
+ ).join("")}</select>`
2041
+ );
2042
+ if (node.kind === "button") {
2043
+ const form = entry.formTarget;
2044
+ return `<button${common}${attribute("type", (_f = attrs.buttonType) != null ? _f : attrs.action === "submit" ? "submit" : "button")}${attribute("form", form)}${attribute("disabled", disabled)}>${escape(label || attrs.aria || attrs["aria-label"] || "")}</button>`;
2045
+ }
2046
+ if (node.kind === "link" || node.kind === "nav-item" || node.kind === "dropdown-item") {
2047
+ if (entry.route !== void 0 || attrs.href !== void 0)
2048
+ return `<a${common}${attribute("href", entry.route === void 0 ? attrs.href : address(entry.route))}${attribute("rel", attrs.href === void 0 ? void 0 : "noopener noreferrer")}${attribute("target", attrs.external === true ? "_blank" : void 0)}>${escape(label)}</a>`;
2049
+ return node.kind === "dropdown-item" ? `<button${common} type="button" role="menuitem" tabindex="-1">${escape(label)}</button>` : `<span${common}>${escape(label)}</span>`;
2050
+ }
2051
+ if (node.kind === "form")
2052
+ return `<form${common} novalidate>${children()}<p data-wf-form-error role="alert" hidden></p></form>`;
2053
+ if (node.kind === "text") return `<p${common}>${escape(label)}</p>`;
2054
+ if (node.kind === "title") {
2055
+ const rank = typeof attrs.level === "number" ? attrs.level : 2;
2056
+ return `<h${rank}${common}>${escape(label)}</h${rank}>`;
2057
+ }
2058
+ if (node.kind === "divider") return `<hr${common}>`;
2059
+ if (node.kind === "image")
2060
+ return attrs.src === void 0 ? `<div${common} role="img"${attribute("aria-label", (_g = attrs.alt) != null ? _g : "Image placeholder")}></div>` : `<img${common}${attribute("src", attrs.src)}${attribute("alt", (_h = attrs.alt) != null ? _h : "")}>`;
2061
+ if (node.kind === "avatar" || node.kind === "icon" || node.kind === "badge" || node.kind === "marker")
2062
+ return `<span${common}>${escape((_i = node.number) != null ? _i : label || attrs.name || "")}</span>`;
2063
+ if (node.kind === "progress")
2064
+ return `<progress${common}${attribute("value", attrs.indeterminate === true ? void 0 : value != null ? value : 0)}${attribute("max", (_j = attrs.max) != null ? _j : 100)}>${escape(label)}</progress>`;
2065
+ if (node.kind === "alert" || node.kind === "toast" || node.kind === "spinner")
2066
+ return `<p${common}${attribute("role", node.kind === "alert" ? "alert" : "status")}>${escape(label)}${attrs.dismissible === true ? `<button type="button" data-wf-event-owner="${renderedId}" aria-label="Dismiss ${escape(label)}">Dismiss</button>` : ""}</p>`;
2067
+ if (node.kind === "accordion")
2068
+ return `<details${common}${attribute("open", attrs.expanded)}><summary>${escape(label)}</summary>${children()}</details>`;
2069
+ if (["modal", "drawer", "popover"].includes(node.kind))
2070
+ return `<dialog${common}${attribute("aria-label", label)} tabindex="-1">${children()}</dialog>`;
2071
+ if (node.kind === "dropdown")
2072
+ return `<div${common}><button type="button" id="${renderedId}-trigger" data-wf-event-owner="${renderedId}" aria-haspopup="menu" aria-expanded="false" aria-controls="${renderedId}-menu">${escape(label)}</button><div id="${renderedId}-menu" role="menu" data-wf-overlay-body hidden>${children()}</div></div>`;
2073
+ if (node.kind === "tooltip")
2074
+ return `<div${common}>${children()}<span id="${renderedId}-tooltip" role="tooltip" hidden>${escape(label)}</span></div>`;
2075
+ if (node.kind === "table") {
2076
+ const columns = Array.isArray(attrs.columns) ? attrs.columns : [];
2077
+ let rows = (_k = node.items) != null ? _k : [];
2078
+ if (object(attrs.data)) {
2079
+ const initial = (_l = entry.stateBindings[textValue(attrs.data.state)]) == null ? void 0 : _l.initial;
2080
+ if (Array.isArray(initial))
2081
+ rows = initial.map(
2082
+ (record) => columns.map((column) => object(record) ? record[textValue(column)] : null)
2083
+ );
2084
+ }
2085
+ return `<table${common}><thead><tr>${columns.map((column) => `<th scope="col">${escape(column)}</th>`).join("")}</tr></thead><tbody>${rows.map((row) => `<tr>${(Array.isArray(row) ? row : []).map((cell) => `<td>${escape(cell != null ? cell : "")}</td>`).join("")}</tr>`).join("")}</tbody></table>`;
2086
+ }
2087
+ if (node.kind === "list")
2088
+ return `<${attrs.ordered === true ? "ol" : "ul"}${common}>${children()}</${attrs.ordered === true ? "ol" : "ul"}>`;
2089
+ if (node.kind === "list-item")
2090
+ return `<li${common}>${escape(label)}${entry.children.length ? `<ul>${children()}</ul>` : ""}</li>`;
2091
+ if (node.kind === "tabs") {
2092
+ const tabs = entry.children.filter((child) => child.node.kind === "tab");
2093
+ return `<div${common}><div role="tablist"${attribute("aria-label", label || "Tabs")}${attribute("aria-orientation", attrs.vertical === true ? "vertical" : "horizontal")}>${tabs.map((tab) => {
2094
+ var _a2, _b2;
2095
+ return `<button type="button" id="${tab.renderedId}-tab" data-wf-event-owner="${tab.renderedId}" role="tab" aria-controls="${tab.renderedId}" aria-selected="false" tabindex="-1">${escape((_b2 = (_a2 = tab.node.label) != null ? _a2 : tab.node.attributes.label) != null ? _b2 : "")}</button>`;
2096
+ }).join("")}</div>${children()}</div>`;
2097
+ }
2098
+ if (node.kind === "tab")
2099
+ return `<section${common} role="tabpanel" aria-labelledby="${renderedId}-tab" tabindex="0">${children()}</section>`;
2100
+ const tag = (_m = {
2101
+ header: "header",
2102
+ main: "main",
2103
+ footer: "footer",
2104
+ sidebar: "aside",
2105
+ nav: "nav",
2106
+ breadcrumb: "nav",
2107
+ section: "section",
2108
+ page: "section",
2109
+ "annotation-item": "section"
2110
+ }[node.kind]) != null ? _m : "div";
2111
+ if (node.kind === "page") common += ' tabindex="-1"';
2112
+ return `<${tag}${common}>${label ? `<span class="wf-label">${escape(label)}</span>` : ""}${children()}</${tag}>`;
2113
+ }
2114
+ layout(entry) {
2115
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2116
+ const a = entry.node.attributes, kind = entry.node.kind, profile = this.data.bundle.profile, styles = [];
2117
+ const length = (value, axis, spacing = false) => {
2118
+ if (typeof value === "number")
2119
+ return `${spacing && [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20].includes(value) ? value * 4 : value}px`;
2120
+ if (object(value)) {
2121
+ const amount = Number(value.value);
2122
+ return value.unit === "vh" ? `${amount * Number(profile.height) / 100}px` : value.unit === "vw" ? `${amount * Number(profile.width) / 100}px` : value.unit === "rem" ? `${amount * 16}px` : `${amount}${textValue(value.unit)}`;
2123
+ }
2124
+ return value === "full" ? "100%" : value === "screen" ? `${Number(profile[axis])}px` : value === "fit" ? "fit-content" : "auto";
2125
+ };
2126
+ for (const [key, css] of Object.entries({
2127
+ w: "width",
2128
+ h: "height",
2129
+ width: "width",
2130
+ height: "height",
2131
+ minW: "min-width",
2132
+ maxW: "max-width",
2133
+ minH: "min-height",
2134
+ maxH: "max-height"
2135
+ }))
2136
+ if (a[key] !== void 0)
2137
+ styles.push(`${css}:${length(a[key], css.includes("width") ? "width" : "height")}`);
2138
+ for (const [key, css] of Object.entries({
2139
+ p: "padding",
2140
+ m: "margin",
2141
+ px: "padding-inline",
2142
+ py: "padding-block",
2143
+ mx: "margin-inline",
2144
+ my: "margin-block",
2145
+ pt: "padding-top",
2146
+ pr: "padding-right",
2147
+ pb: "padding-bottom",
2148
+ pl: "padding-left",
2149
+ mt: "margin-top",
2150
+ mr: "margin-right",
2151
+ mb: "margin-bottom",
2152
+ ml: "margin-left",
2153
+ gap: "gap"
2154
+ }))
2155
+ if (a[key] !== void 0) styles.push(`${css}:${length(a[key], "width", true)}`);
2156
+ if (["row", "col", "stack"].includes(kind)) {
2157
+ styles.push(
2158
+ "display:flex",
2159
+ `flex-direction:${textValue((_a = a.direction) != null ? _a : kind === "row" ? "row" : "column")}`,
2160
+ `flex-wrap:${a.wrap === true ? "wrap" : "nowrap"}`,
2161
+ `justify-content:${(_c = { start: "flex-start", end: "flex-end", between: "space-between", around: "space-around", evenly: "space-evenly" }[textValue(a.justify)]) != null ? _c : textValue((_b = a.justify) != null ? _b : "flex-start")}`,
2162
+ `align-items:${(_e = { start: "flex-start", end: "flex-end" }[textValue(a.align)]) != null ? _e : textValue((_d = a.align) != null ? _d : "stretch")}`
2163
+ );
2164
+ }
2165
+ if (a.flex !== void 0)
2166
+ styles.push(`flex-grow:${a.flex === true ? 1 : a.flex === false ? 0 : Number(a.flex)}`);
2167
+ if (kind === "col" && ((_f = entry.parent) == null ? void 0 : _f.node.kind) === "row") {
2168
+ let span = Number((_g = a.span) != null ? _g : 12);
2169
+ for (const [key, width] of Object.entries({ sm: 576, md: 768, lg: 992, xl: 1200 }))
2170
+ if (Number(profile.width) >= width && a[key] !== void 0) span = Number(a[key]);
2171
+ const gap = length((_h = entry.parent.node.attributes.gap) != null ? _h : 0, "width", true);
2172
+ styles.push(
2173
+ `flex-basis:calc((100% - 11 * ${gap}) * ${span}/12 + ${span - 1} * ${gap})`,
2174
+ `max-width:calc((100% - 11 * ${gap}) * ${span}/12 + ${span - 1} * ${gap})`
2175
+ );
2176
+ }
2177
+ if (a.order !== void 0) styles.push(`order:${Number(a.order)}`);
2178
+ if (a.scroll === true) styles.push("overflow:auto");
2179
+ if (kind !== "page" && (a.x !== void 0 || a.y !== void 0 || a.anchor !== void 0)) {
2180
+ const anchor = textValue((_i = a.anchor) != null ? _i : "top-left"), vertical = anchor === "center" ? "center" : anchor.split("-")[0], horizontal = anchor === "center" ? "center" : anchor.split("-")[1];
2181
+ styles.push(
2182
+ "position:absolute",
2183
+ `left:calc(${horizontal === "center" ? "50%" : horizontal === "right" ? "100%" : "0%"} + ${Number((_j = a.x) != null ? _j : 0)}px)`,
2184
+ `top:calc(${vertical === "center" ? "50%" : vertical === "bottom" ? "100%" : "0%"} + ${Number((_k = a.y) != null ? _k : 0)}px)`,
2185
+ `transform:translate(${horizontal === "center" ? "-50%" : horizontal === "right" ? "-100%" : "0"},${vertical === "center" ? "-50%" : vertical === "bottom" ? "-100%" : "0"})`
2186
+ );
2187
+ }
2188
+ if (a.border === true || a.outline === true || a.bordered === true)
2189
+ styles.push("border:1px solid #71717a");
2190
+ if (a.ghost === true) styles.push("background:transparent", "border-color:transparent");
2191
+ if (a.rounded === true || a.pill === true)
2192
+ styles.push(`border-radius:${a.pill === true ? "999px" : "4px"}`);
2193
+ if (a.muted === true) styles.push("color:#52525b");
2194
+ if (a.bg !== void 0 || a.primary === true || a.secondary === true)
2195
+ styles.push("background:#f4f4f5");
2196
+ if (a.shadow !== void 0 && a.shadow !== "none")
2197
+ styles.push(
2198
+ `box-shadow:0 ${{ sm: 1, md: 2, lg: 4, xl: 8 }[textValue(a.shadow)]}px ${{ sm: 1, md: 2, lg: 4, xl: 8 }[textValue(a.shadow)]}px #71717a`
2199
+ );
2200
+ if (a.bold === true || a.weight !== void 0)
2201
+ styles.push(
2202
+ `font-weight:${a.bold === true ? 700 : { normal: 400, medium: 500, semibold: 600, bold: 700 }[textValue(a.weight)]}`
2203
+ );
2204
+ if (typeof a.size === "string") {
2205
+ const font = { xs: 12, sm: 14, base: 16, md: 16, lg: 18, xl: 20, "2xl": 24, "3xl": 30 }[a.size];
2206
+ if (font) styles.push(`font-size:${font}px`);
2207
+ if (["button", "input", "textarea", "select", "checkbox", "radio", "switch", "slider"].includes(
2208
+ kind
2209
+ ))
2210
+ styles.push(
2211
+ `min-height:${(_l = { xs: 24, sm: 28, md: 36, lg: 44, xl: 52 }[a.size]) != null ? _l : 24}px`
2212
+ );
2213
+ } else if (typeof a.size === "number") styles.push(`width:${a.size}px`, `height:${a.size}px`);
2214
+ if (["text", "title", "link"].includes(kind) && a.align !== void 0)
2215
+ styles.push(`text-align:${textValue(a.align)}`);
2216
+ if (styles.length) this.rules.push(`#wireweave-app .${entry.renderedId}{${styles.join(";")}}`);
2217
+ }
2218
+ html() {
2219
+ const bundle = this.data.bundle;
2220
+ const screens = this.data.screens.map(
2221
+ (screen) => `<article data-wf-screen="${escape(address(screen.route))}"${attribute("data-wf-shell-ref", screen.shell)} hidden>${screen.children.map((node) => this.node(node)).join("")}</article>`
2222
+ ).join("");
2223
+ const shells = this.data.shells.map(
2224
+ (shell) => `<section data-wf-shell="${escape(shell.owner.key)}" hidden>${shell.children.map((node) => this.node(node)).join("")}</section>`
2225
+ ).join("");
2226
+ const registryPanels = bundle.registry.entries.map(
2227
+ (entry) => {
2228
+ var _a, _b;
2229
+ return `<section data-wf-requirement="${escape(entry.id)}"><h3>${escape(entry.title)}</h3><p>${escape((_b = (_a = entry.behavior) != null ? _a : entry.trigger) != null ? _b : "")}</p></section>`;
2230
+ }
2231
+ ).join("");
2232
+ const css = `#wireweave-app{font:16px/1.5 system-ui,sans-serif;color:#18181b;background:white}#wireweave-app [hidden]{display:none!important}#wireweave-app *{box-sizing:border-box}#wireweave-app :focus-visible{outline:2px solid #18181b;outline-offset:2px}#wireweave-app button,#wireweave-app input,#wireweave-app select{min-height:24px;font:inherit}#wireweave-app .wf-row{display:flex;gap:0}#wireweave-app .wf-col{flex:1}#wireweave-app .wf-stack,#wireweave-app .wf-field{display:flex;flex-direction:column;gap:8px}#wireweave-app .wf-page,#wireweave-app [data-wf-shell]{width:${textValue(bundle.profile.width)}px;height:${textValue(bundle.profile.height)}px;overflow:auto}#wireweave-app .wf-card,#wireweave-app th,#wireweave-app td{border:1px solid #71717a;padding:8px}#wireweave-app .wf-relative{position:relative}#wireweave-app [data-wf-slot]{display:contents}${this.rules.join("")}#wireweave-app[data-wf-view=accessible] .wf-node,#wireweave-app[data-wf-view=accessible] [data-wf-shell]{position:static!important;transform:none!important;width:auto!important;height:auto!important;min-width:0!important;max-width:100%!important;min-height:0!important;overflow-wrap:anywhere;order:0!important}#wireweave-app[data-wf-view=accessible] .wf-row{flex-direction:column!important;flex-wrap:wrap!important}#wireweave-app[data-wf-view=accessible] .wf-col{flex-basis:auto!important}#wireweave-app .wf-field{min-width:0}#wireweave-app .wf-field input,#wireweave-app .wf-field textarea,#wireweave-app .wf-field select{max-width:100%}#wireweave-app [data-wf-field][hidden]{display:none!important}#wireweave-app [role=tablist]{display:flex;flex-wrap:wrap}#wireweave-app [role=tooltip]{background:#f4f4f5;border:1px solid #71717a}#wireweave-app dialog{color:#18181b;background:white;max-width:100%;max-height:100%;overflow:auto}`;
2233
+ const runtimeData = this.program;
2234
+ const csp = `default-src 'none'; script-src 'sha256-${hashBase64(NATIVE_RUNTIME)}'; style-src 'sha256-${hashBase64(css)}'; img-src data:; font-src data:; connect-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'; frame-src 'none'`;
2235
+ return `<!DOCTYPE html>
2236
+ <html lang="${escape(bundle.profile.language)}"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="Content-Security-Policy" content="${escape(csp)}"><title>${escape(bundle.id)}</title><style>${css}</style></head><body><div id="wireweave-app">${shells}<div data-wf-screen-storage>${screens}</div><section data-wf-route-error role="alert" hidden><h1 tabindex="-1">Unknown screen</h1><p data-wf-invalid-address></p><a href="${escape(address(bundle.entry))}">Open entry screen</a></section><div role="group" aria-label="Execution view"><button type="button" data-wf-tooling="view">Switch fixed or accessible view</button><button type="button" data-wf-tooling="reset">Reset scenario</button></div><p data-wf-runtime-status role="status" aria-live="polite"></p><details data-wf-requirement-panel><summary>Implementation requirements</summary>${registryPanels}</details></div><script type="application/json" id="wf-model">${jsonBlock(bundle)}</script><script type="application/json" id="wf-source-map">${jsonBlock(this.data.sourceMap)}</script><script type="application/json" id="wf-runtime-data">${jsonBlock(runtimeData)}</script><script type="application/json" id="wf-runtime-trace">[]</script><script>${NATIVE_RUNTIME}</script></body></html>`;
2237
+ }
2238
+ };
2239
+ function runtimeEngine(program) {
2240
+ const nodes = new Map(program.nodes.map((node) => [node.id, node]));
2241
+ const byIdentity = new Map(program.nodes.map((node) => [canonical(node.identity), node]));
2242
+ const fixtures = new Map(program.fixtures.map((fixture) => [fixture.id, fixture]));
2243
+ const clone = (value) => JSON.parse(JSON.stringify(value));
2244
+ const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
2245
+ const scalar = (value) => {
2246
+ if (value == null) return "";
2247
+ if (typeof value === "string") return value;
2248
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
2249
+ if (typeof value === "object") return canonical(value);
2250
+ throw Error("scalar-type");
2251
+ };
2252
+ function canonical(value) {
2253
+ if (Array.isArray(value)) return "[" + value.map(canonical).join(",") + "]";
2254
+ if (value !== null && typeof value === "object")
2255
+ return "{" + Object.keys(value).sort().map(
2256
+ (key) => JSON.stringify(key) + ":" + canonical(value[key])
2257
+ ).join(",") + "}";
2258
+ return JSON.stringify(value);
2259
+ }
2260
+ function bounded(value) {
2261
+ const stack = [{ value, depth: 0 }];
2262
+ let count = 0;
2263
+ while (stack.length) {
2264
+ const entry = stack.pop();
2265
+ if (++count > 25e4 || entry.depth > 128) throw Error("limit-json");
2266
+ const item = entry.value;
2267
+ if (typeof item === "string") {
2268
+ for (const character of item) {
2269
+ const code = character.codePointAt(0);
2270
+ if (code >= 55296 && code <= 57343) throw Error("invalid-unicode");
2271
+ }
2272
+ } else if (typeof item === "number") {
2273
+ if (!Number.isFinite(item)) throw Error("non-finite-number");
2274
+ } else if (Array.isArray(item)) {
2275
+ if (item.length > 1e4) throw Error("limit-list");
2276
+ for (const child of item) stack.push({ value: child, depth: entry.depth + 1 });
2277
+ } else if (item !== null && typeof item === "object") {
2278
+ const entries = Object.entries(item);
2279
+ if (entries.length > 1e3) throw Error("limit-record");
2280
+ for (const [key, child] of entries) {
2281
+ bounded(key);
2282
+ stack.push({ value: child, depth: entry.depth + 1 });
2283
+ }
2284
+ } else if (item !== null && typeof item !== "boolean") throw Error("invalid-json");
2285
+ }
2286
+ }
2287
+ function hash(source) {
2288
+ var _a, _b, _c, _d, _e, _f, _g;
2289
+ const k = [
2290
+ 1116352408,
2291
+ 1899447441,
2292
+ 3049323471,
2293
+ 3921009573,
2294
+ 961987163,
2295
+ 1508970993,
2296
+ 2453635748,
2297
+ 2870763221,
2298
+ 3624381080,
2299
+ 310598401,
2300
+ 607225278,
2301
+ 1426881987,
2302
+ 1925078388,
2303
+ 2162078206,
2304
+ 2614888103,
2305
+ 3248222580,
2306
+ 3835390401,
2307
+ 4022224774,
2308
+ 264347078,
2309
+ 604807628,
2310
+ 770255983,
2311
+ 1249150122,
2312
+ 1555081692,
2313
+ 1996064986,
2314
+ 2554220882,
2315
+ 2821834349,
2316
+ 2952996808,
2317
+ 3210313671,
2318
+ 3336571891,
2319
+ 3584528711,
2320
+ 113926993,
2321
+ 338241895,
2322
+ 666307205,
2323
+ 773529912,
2324
+ 1294757372,
2325
+ 1396182291,
2326
+ 1695183700,
2327
+ 1986661051,
2328
+ 2177026350,
2329
+ 2456956037,
2330
+ 2730485921,
2331
+ 2820302411,
2332
+ 3259730800,
2333
+ 3345764771,
2334
+ 3516065817,
2335
+ 3600352804,
2336
+ 4094571909,
2337
+ 275423344,
2338
+ 430227734,
2339
+ 506948616,
2340
+ 659060556,
2341
+ 883997877,
2342
+ 958139571,
2343
+ 1322822218,
2344
+ 1537002063,
2345
+ 1747873779,
2346
+ 1955562222,
2347
+ 2024104815,
2348
+ 2227730452,
2349
+ 2361852424,
2350
+ 2428436474,
2351
+ 2756734187,
2352
+ 3204031479,
2353
+ 3329325298
2354
+ ];
2355
+ const bytes = new TextEncoder().encode(source), padded = new Uint8Array(Math.ceil((bytes.length + 9) / 64) * 64);
2356
+ padded.set(bytes);
2357
+ padded[bytes.length] = 128;
2358
+ const view2 = new DataView(padded.buffer);
2359
+ view2.setUint32(padded.length - 8, Math.floor(bytes.length / 536870912));
2360
+ view2.setUint32(padded.length - 4, bytes.length * 8 >>> 0);
2361
+ const h = [
2362
+ 1779033703,
2363
+ 3144134277,
2364
+ 1013904242,
2365
+ 2773480762,
2366
+ 1359893119,
2367
+ 2600822924,
2368
+ 528734635,
2369
+ 1541459225
2370
+ ], words = new Uint32Array(64);
2371
+ const rotate = (value, shift) => value >>> shift | value << 32 - shift;
2372
+ for (let block = 0; block < padded.length; block += 64) {
2373
+ for (let index = 0; index < 16; index++) words[index] = view2.getUint32(block + index * 4);
2374
+ for (let index = 16; index < 64; index++) {
2375
+ const x = (_a = words[index - 15]) != null ? _a : 0, y = (_b = words[index - 2]) != null ? _b : 0;
2376
+ words[index] = ((_c = words[index - 16]) != null ? _c : 0) + (rotate(x, 7) ^ rotate(x, 18) ^ x >>> 3) + ((_d = words[index - 7]) != null ? _d : 0) + (rotate(y, 17) ^ rotate(y, 19) ^ y >>> 10) >>> 0;
2377
+ }
2378
+ let [a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, v = 0] = h;
2379
+ for (let index = 0; index < 64; index++) {
2380
+ const first = v + (rotate(e, 6) ^ rotate(e, 11) ^ rotate(e, 25)) + (e & f ^ ~e & g) + ((_e = k[index]) != null ? _e : 0) + ((_f = words[index]) != null ? _f : 0) >>> 0, second = (rotate(a, 2) ^ rotate(a, 13) ^ rotate(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
2381
+ v = g;
2382
+ g = f;
2383
+ f = e;
2384
+ e = d + first >>> 0;
2385
+ d = c;
2386
+ c = b;
2387
+ b = a;
2388
+ a = first + second >>> 0;
2389
+ }
2390
+ for (const [index, value] of [a, b, c, d, e, f, g, v].entries())
2391
+ h[index] = ((_g = h[index]) != null ? _g : 0) + value >>> 0;
2392
+ }
2393
+ return "sha256:" + h.map((value) => value.toString(16).padStart(8, "0")).join("");
2394
+ }
2395
+ function range(code, ranges) {
2396
+ let low = 0, high = ranges.length - 1;
2397
+ while (low <= high) {
2398
+ const middle = low + high >>> 1, pair = ranges[middle];
2399
+ if (code < pair[0]) high = middle - 1;
2400
+ else if (code > pair[1]) low = middle + 1;
2401
+ else return true;
2402
+ }
2403
+ return false;
2404
+ }
2405
+ function convert(value, mode) {
2406
+ if (typeof value !== "string") throw Error("value-type");
2407
+ const chars = Array.from(value);
2408
+ if (mode === "trim") {
2409
+ let start = 0, end = chars.length;
2410
+ while (start < end && range(chars[start].codePointAt(0), program.unicode.whitespace)) start++;
2411
+ while (end > start && range(chars[end - 1].codePointAt(0), program.unicode.whitespace)) end--;
2412
+ return chars.slice(start, end).join("");
2413
+ }
2414
+ return chars.map((character, index) => {
2415
+ var _a;
2416
+ if (mode === "lower" && character === "\u03A3") {
2417
+ let before = index - 1, after = index + 1;
2418
+ while (before >= 0 && range(chars[before].codePointAt(0), program.unicode.ignorable))
2419
+ before--;
2420
+ while (after < chars.length && range(chars[after].codePointAt(0), program.unicode.ignorable))
2421
+ after++;
2422
+ if (before >= 0 && range(chars[before].codePointAt(0), program.unicode.cased) && !(after < chars.length && range(chars[after].codePointAt(0), program.unicode.cased)))
2423
+ return "\u03C2";
2424
+ }
2425
+ return (_a = (mode === "upper" ? program.unicode.upper : program.unicode.lower)[String(character.codePointAt(0))]) != null ? _a : character;
2426
+ }).join("");
2427
+ }
2428
+ function expression(raw, node, state, event = {}, depth = 0) {
2429
+ var _a;
2430
+ if (depth > 128) throw Error("limit-expression");
2431
+ const value = record(raw);
2432
+ if (Object.hasOwn(value, "literal")) return value.literal;
2433
+ if (typeof value.state === "string") {
2434
+ const binding = node.bindings[value.state];
2435
+ if (!binding) throw Error("missing-state");
2436
+ return state.states[binding.key];
2437
+ }
2438
+ if (typeof value.event === "string") {
2439
+ if (!Object.hasOwn(event, value.event)) throw Error("event-value-unavailable");
2440
+ return event[value.event];
2441
+ }
2442
+ if (value.read) {
2443
+ const read = record(value.read);
2444
+ let result = expression(read.source, node, state, event, depth + 1);
2445
+ for (const key of read.path) {
2446
+ if (["__proto__", "constructor", "prototype"].includes(String(key)) || result === null || typeof result !== "object" || !Object.hasOwn(result, key))
2447
+ throw Error("missing-read-path");
2448
+ result = result[key];
2449
+ }
2450
+ return result;
2451
+ }
2452
+ if (typeof value.call === "string") {
2453
+ const args = value.args.map(
2454
+ (arg) => expression(arg, node, state, event, depth + 1)
2455
+ );
2456
+ if (value.call === "length" && args.length === 1 && (typeof args[0] === "string" || Array.isArray(args[0])))
2457
+ return Array.from(args[0]).length;
2458
+ if (["lower", "upper", "trim"].includes(value.call) && args.length === 1)
2459
+ return convert(args[0], value.call);
2460
+ if (value.call === "concat" && args.length >= 2 && args.length <= 16 && args.every((arg) => typeof arg === "string"))
2461
+ return args.join("");
2462
+ if (value.call === "coalesce" && args.length >= 2 && args.length <= 16)
2463
+ return (_a = args.find((arg) => arg !== null)) != null ? _a : null;
2464
+ if (["add", "subtract", "multiply", "divide"].includes(value.call) && args.length === 2 && args.every((arg) => typeof arg === "number")) {
2465
+ const a = args[0], b = args[1];
2466
+ if (value.call === "divide" && b === 0) throw Error("division-by-zero");
2467
+ const result = value.call === "add" ? a + b : value.call === "subtract" ? a - b : value.call === "multiply" ? a * b : a / b;
2468
+ if (!Number.isFinite(result)) throw Error("non-finite-number");
2469
+ return result;
2470
+ }
2471
+ }
2472
+ throw Error("expression-type");
2473
+ }
2474
+ function compare(a, b) {
2475
+ if (typeof a !== typeof b || !["number", "string"].includes(typeof a))
2476
+ throw Error("comparison-type");
2477
+ if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
2478
+ const left = Array.from(a), right = Array.from(b);
2479
+ for (let index = 0; index < Math.min(left.length, right.length); index++)
2480
+ if (left[index] !== right[index])
2481
+ return left[index].codePointAt(0) < right[index].codePointAt(0) ? -1 : 1;
2482
+ return left.length - right.length;
2483
+ }
2484
+ function guard(raw, node, state, event = {}) {
2485
+ if (raw === void 0) return true;
2486
+ const value = record(raw);
2487
+ if (value.op === "all")
2488
+ return value.guards.every((item) => guard(item, node, state, event));
2489
+ if (value.op === "any")
2490
+ return value.guards.some((item) => guard(item, node, state, event));
2491
+ if (value.op === "not") return !guard(value.guard, node, state, event);
2492
+ const left = expression(value.left, node, state, event), right = expression(value.right, node, state, event);
2493
+ if (value.op === "eq") return canonical(left) === canonical(right);
2494
+ if (value.op === "ne") return canonical(left) !== canonical(right);
2495
+ if (value.op === "in" && Array.isArray(right))
2496
+ return right.some((item) => canonical(item) === canonical(left));
2497
+ if (["contains", "startsWith"].includes(scalar(value.op)) && typeof left === "string" && typeof right === "string")
2498
+ return value.op === "contains" ? left.includes(right) : left.startsWith(right);
2499
+ const order = compare(left, right);
2500
+ if (value.op === "lt") return order < 0;
2501
+ if (value.op === "lte") return order <= 0;
2502
+ if (value.op === "gt") return order > 0;
2503
+ if (value.op === "gte") return order >= 0;
2504
+ throw Error("guard-type");
2505
+ }
2506
+ function routeAddress(route) {
2507
+ return "#wf/" + encodeURIComponent(route.namespace) + "/" + encodeURIComponent(route.id) + (route.variant === void 0 ? "" : "?variant=" + encodeURIComponent(route.variant));
2508
+ }
2509
+ function parseAddress(fragment) {
2510
+ if (fragment === "") return clone(program.entry);
2511
+ try {
2512
+ const match = /^#wf\/([^/?]+)\/([^/?]+)(?:\?variant=([^&]*))?$/.exec(fragment);
2513
+ if (!match) return null;
2514
+ const result = {
2515
+ namespace: decodeURIComponent(match[1]),
2516
+ id: decodeURIComponent(match[2])
2517
+ };
2518
+ if (match[3] !== void 0) result.variant = decodeURIComponent(match[3]);
2519
+ const screen = program.screens.find(
2520
+ (screen2) => screen2.route.namespace === result.namespace && screen2.route.id === result.id
2521
+ );
2522
+ return screen && (result.variant === void 0 || screen.variants.includes(result.variant)) ? result : null;
2523
+ } catch (error) {
2524
+ void error;
2525
+ return null;
2526
+ }
2527
+ }
2528
+ function screenOf(state) {
2529
+ return program.screens.find(
2530
+ (screen) => {
2531
+ var _a, _b;
2532
+ return screen.route.namespace === ((_a = state.route) == null ? void 0 : _a.namespace) && screen.route.id === ((_b = state.route) == null ? void 0 : _b.id);
2533
+ }
2534
+ );
2535
+ }
2536
+ function roots(state) {
2537
+ const screen = screenOf(state);
2538
+ return screen ? [
2539
+ "app",
2540
+ "screen/" + screen.route.namespace + "/" + screen.route.id,
2541
+ ...screen.shell ? [program.shells.find((shell) => shell.id === screen.shell).root] : []
2542
+ ] : ["app"];
2543
+ }
2544
+ function descendant(id, ancestor) {
2545
+ let node = nodes.get(id);
2546
+ while (node) {
2547
+ if (node.id === ancestor) return true;
2548
+ node = node.parent ? nodes.get(node.parent) : void 0;
2549
+ }
2550
+ return false;
2551
+ }
2552
+ function visible(node, state) {
2553
+ var _a, _b, _c;
2554
+ const mounted = roots(state);
2555
+ let current = node;
2556
+ while (current) {
2557
+ if (!mounted.includes(current.root) || !guard(current.attributes.visibleWhen, current, state))
2558
+ return false;
2559
+ if ((["modal", "drawer", "popover"].includes(current.kind) || current.kind === "dropdown" && current.id !== node.id) && !state.overlays.some((overlay) => overlay.id === current.id))
2560
+ return false;
2561
+ if (current.kind === "tab" && current.parent && current.id !== node.id) {
2562
+ const owner = nodes.get(current.parent);
2563
+ if ((owner == null ? void 0 : owner.kind) === "tabs" && owner.children.filter((id) => {
2564
+ var _a2;
2565
+ return ((_a2 = nodes.get(id)) == null ? void 0 : _a2.kind) === "tab";
2566
+ })[(_a = state.selection[owner.id]) != null ? _a : 0] !== current.id)
2567
+ return false;
2568
+ }
2569
+ const when = current.attributes.when;
2570
+ if (when !== void 0) {
2571
+ const screen = screenOf(state);
2572
+ const variant = (_c = (_b = state.route) == null ? void 0 : _b.variant) != null ? _c : screen == null ? void 0 : screen.variants[0];
2573
+ if (!(Array.isArray(when) ? when.includes(variant != null ? variant : "") : when === variant)) return false;
2574
+ }
2575
+ current = current.parent ? nodes.get(current.parent) : void 0;
2576
+ }
2577
+ return true;
2578
+ }
2579
+ function enabled(node, state) {
2580
+ let current = node;
2581
+ while (current) {
2582
+ if (current.attributes.disabled === true || current.attributes.loading === true || !guard(current.attributes.enabledWhen, current, state))
2583
+ return false;
2584
+ current = current.parent ? nodes.get(current.parent) : void 0;
2585
+ }
2586
+ return true;
2587
+ }
2588
+ function active(node, state) {
2589
+ if (!visible(node, state) || !enabled(node, state)) return false;
2590
+ const modal = state.overlays.filter((overlay) => overlay.modal).at(-1);
2591
+ return !modal || descendant(node.id, modal.id);
2592
+ }
2593
+ function focusable(node, state) {
2594
+ return active(node, state) && ([
2595
+ "input",
2596
+ "textarea",
2597
+ "select",
2598
+ "checkbox",
2599
+ "radio",
2600
+ "switch",
2601
+ "slider",
2602
+ "button",
2603
+ "link",
2604
+ "nav-item",
2605
+ "dropdown-item",
2606
+ "page",
2607
+ "modal",
2608
+ "drawer",
2609
+ "popover",
2610
+ "dropdown",
2611
+ "tabs",
2612
+ "tab",
2613
+ "accordion"
2614
+ ].includes(node.kind) || node.attributes.scroll === true);
2615
+ }
2616
+ function controlValue(node, state) {
2617
+ var _a, _b, _c, _d;
2618
+ const raw = (_a = state.controls[node.id]) != null ? _a : { value: "", checked: false }, bind = record(node.attributes.bind), binding = node.bindings[scalar(bind.state)];
2619
+ if (!binding || state.invalid[node.id] || raw.pending) return raw;
2620
+ const value = state.states[binding.key];
2621
+ if (node.kind === "radio")
2622
+ return {
2623
+ value: (_b = node.attributes.value) != null ? _b : "",
2624
+ checked: canonical(value) === canonical((_c = node.attributes.value) != null ? _c : "")
2625
+ };
2626
+ return bind.property === "checked" ? { value: (_d = node.attributes.value) != null ? _d : "", checked: value === true } : { value, checked: raw.checked };
2627
+ }
2628
+ function view(state) {
2629
+ const result = {
2630
+ visible: {},
2631
+ enabled: {},
2632
+ controls: {},
2633
+ states: state.states,
2634
+ data: {}
2635
+ };
2636
+ for (const node of program.nodes) {
2637
+ result.visible[node.id] = visible(node, state);
2638
+ result.enabled[node.id] = enabled(node, state);
2639
+ result.controls[node.id] = controlValue(node, state);
2640
+ if (node.attributes.data) result.data[node.id] = expression(node.attributes.data, node, state);
2641
+ }
2642
+ return result;
2643
+ }
2644
+ function append(state, node, handler, operation, event, result, diagnostic2 = null, before = state.states) {
2645
+ var _a, _b, _c, _d, _e, _f;
2646
+ const delta = {};
2647
+ for (const [key, value] of Object.entries(state.states))
2648
+ if (canonical(before[key]) !== canonical(value))
2649
+ delta[key] = ((_a = program.states[key]) == null ? void 0 : _a.sensitive) ? "[redacted]" : value;
2650
+ const normalized = clone(event), binding = node == null ? void 0 : node.bindings[scalar(record(node == null ? void 0 : node.attributes.bind).state)];
2651
+ if ((binding == null ? void 0 : binding.sensitive) || (node == null ? void 0 : node.attributes.inputType) === "password") {
2652
+ if ("value" in normalized) normalized.value = "[redacted]";
2653
+ if ("checked" in normalized) normalized.checked = "[redacted]";
2654
+ }
2655
+ state.trace.push({
2656
+ schemaVersion: "1.0.0",
2657
+ appId: program.appId,
2658
+ modelDigest: program.modelDigest,
2659
+ profileDigest: program.profileDigest,
2660
+ sequence: ++state.sequence,
2661
+ resetGeneration: state.resetGeneration,
2662
+ virtualTime: state.virtualTime,
2663
+ route: clone(state.route),
2664
+ source: (_b = node == null ? void 0 : node.identity) != null ? _b : null,
2665
+ renderedId: (_c = node == null ? void 0 : node.id) != null ? _c : null,
2666
+ handlerId: (_d = handler == null ? void 0 : handler.id) != null ? _d : null,
2667
+ operationId: (_e = operation == null ? void 0 : operation.id) != null ? _e : null,
2668
+ executionClass: (_f = operation == null ? void 0 : operation.executionClass) != null ? _f : "runtime",
2669
+ event: normalized,
2670
+ stateDeltaDigest: hash(canonical(delta)),
2671
+ result,
2672
+ diagnostic: diagnostic2
2673
+ });
2674
+ if (diagnostic2) state.diagnostic = diagnostic2;
2675
+ }
2676
+ function write(state, binding, value, requestId) {
2677
+ if (!binding) throw Error("missing-state");
2678
+ const held = state.reservations[binding.key];
2679
+ if (held && held !== requestId) throw Error("state-busy");
2680
+ bounded(value);
2681
+ const valid = binding.type === "list" ? Array.isArray(value) : binding.type === "record" ? value !== null && typeof value === "object" && !Array.isArray(value) : typeof value === binding.type;
2682
+ if (!valid) throw Error("state-type");
2683
+ state.states[binding.key] = clone(value);
2684
+ }
2685
+ let microsteps = 0;
2686
+ function tick() {
2687
+ if (++microsteps > 256) throw Error("limit-microsteps");
2688
+ }
2689
+ function enqueue(state, item) {
2690
+ if (state.queue.length >= 4096) throw Error("limit-queue");
2691
+ state.queue.push(item);
2692
+ }
2693
+ function fieldError(node, state) {
2694
+ var _a, _b;
2695
+ const attrs = node.attributes, control = controlValue(node, state);
2696
+ if (!visible(node, state) || !enabled(node, state) || attrs.readonly === true) return null;
2697
+ const value = control.value, text = scalar(value), type = node.kind === "input" ? scalar((_a = attrs.inputType) != null ? _a : "text") : node.kind;
2698
+ if (attrs.required === true && (["checkbox", "switch"].includes(type) && !control.checked || type === "radio" && !program.nodes.some(
2699
+ (other) => other.kind === "radio" && other.form === node.form && other.attributes.name === attrs.name && controlValue(other, state).checked
2700
+ ) || !["checkbox", "switch", "radio"].includes(type) && text === ""))
2701
+ return "required";
2702
+ if (text === "") return null;
2703
+ if (typeof attrs.minLength === "number" && Array.from(text).length < attrs.minLength)
2704
+ return "too-short";
2705
+ if (typeof attrs.maxLength === "number" && Array.from(text).length > attrs.maxLength)
2706
+ return "too-long";
2707
+ if (type === "email" && !/^[a-zA-Z0-9.!#$%&'*+\-/=?^_`{|}~]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*$/.test(
2708
+ text
2709
+ ))
2710
+ return "email";
2711
+ if (type === "url") {
2712
+ try {
2713
+ const url = new URL(text);
2714
+ if (!url.protocol) return "url";
2715
+ } catch (error) {
2716
+ void error;
2717
+ return "url";
2718
+ }
2719
+ }
2720
+ if (type === "date") {
2721
+ const match = /^(\d{4,})-(\d\d)-(\d\d)$/.exec(text);
2722
+ if (!match) return "date";
2723
+ const year = Number(match[1]), month = Number(match[2]), day = Number(match[3]), days = [
2724
+ 31,
2725
+ year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) ? 29 : 28,
2726
+ 31,
2727
+ 30,
2728
+ 31,
2729
+ 30,
2730
+ 31,
2731
+ 31,
2732
+ 30,
2733
+ 31,
2734
+ 30,
2735
+ 31
2736
+ ];
2737
+ if (year < 1 || month < 1 || month > 12 || day < 1 || day > ((_b = days[month - 1]) != null ? _b : 0))
2738
+ return "date";
2739
+ }
2740
+ if (type === "number" || type === "slider") {
2741
+ const number = typeof value === "number" ? value : Number(text);
2742
+ if (!Number.isFinite(number)) return "number";
2743
+ const min = typeof attrs.min === "number" ? attrs.min : type === "slider" ? 0 : void 0, max = typeof attrs.max === "number" ? attrs.max : type === "slider" ? 100 : void 0, step = typeof attrs.step === "number" ? attrs.step : 1;
2744
+ if (min !== void 0 && number < min) return "range-underflow";
2745
+ if (max !== void 0 && number > max) return "range-overflow";
2746
+ const remainder = (number - (min != null ? min : 0)) / step;
2747
+ if (Math.abs(remainder - Math.round(remainder)) > 1e-9) return "step-mismatch";
2748
+ }
2749
+ if (node.kind === "select" && !attrs.options.some(
2750
+ (option) => option.disabled !== true && canonical(option.value) === canonical(value)
2751
+ ))
2752
+ return "option";
2753
+ return null;
2754
+ }
2755
+ function validateForm(state, form) {
2756
+ let first;
2757
+ for (const control of program.nodes.filter(
2758
+ (node) => node.form === form.id && ["input", "textarea", "select", "checkbox", "radio", "switch", "slider"].includes(
2759
+ node.kind
2760
+ )
2761
+ )) {
2762
+ const error = fieldError(control, state);
2763
+ if (error) {
2764
+ state.invalid[control.id] = error;
2765
+ first != null ? first : first = control;
2766
+ } else delete state.invalid[control.id];
2767
+ }
2768
+ if (first) {
2769
+ state.invalid[form.id] = "form-invalid";
2770
+ state.focus = first.id;
2771
+ return false;
2772
+ }
2773
+ delete state.invalid[form.id];
2774
+ return true;
2775
+ }
2776
+ function normalizeControl(state, node, event) {
2777
+ var _a, _b;
2778
+ const bind = record(node.attributes.bind), target = node.bindings[scalar(bind.state)], previous = (_a = state.controls[node.id]) != null ? _a : { value: "", checked: false };
2779
+ const raw = {
2780
+ value: Object.hasOwn(event, "value") ? event.value : previous.value,
2781
+ checked: typeof event.checked === "boolean" ? event.checked : previous.checked,
2782
+ pending: !!target && bind.update !== event.type
2783
+ };
2784
+ if (node.attributes.readonly === true) throw Error("readonly-control");
2785
+ state.controls[node.id] = raw;
2786
+ if (!target || bind.update !== event.type) return;
2787
+ if (node.kind === "radio" && !raw.checked) return;
2788
+ let value = bind.property === "checked" ? raw.checked : raw.value;
2789
+ if (node.kind === "radio") value = (_b = node.attributes.value) != null ? _b : "";
2790
+ else if (node.kind === "select") {
2791
+ const option = node.attributes.options.find(
2792
+ (option2) => option2.disabled !== true && scalar(option2.value) === scalar(raw.value)
2793
+ );
2794
+ if (!option) throw Error("option");
2795
+ value = option.value;
2796
+ } else if (target.type === "number") {
2797
+ if (value === "") {
2798
+ state.invalid[node.id] = "number";
2799
+ throw Error("invalid-edit");
2800
+ }
2801
+ value = typeof value === "number" ? value : Number(value);
2802
+ if (!Number.isFinite(value)) {
2803
+ state.invalid[node.id] = "number";
2804
+ throw Error("invalid-edit");
2805
+ }
2806
+ } else if (target.type === "boolean" && bind.property !== "checked") {
2807
+ if (![true, false, "true", "false"].includes(value)) throw Error("state-type");
2808
+ value = value === true || value === "true";
2809
+ }
2810
+ const check = clone(state);
2811
+ delete check.invalid[node.id];
2812
+ check.controls[node.id] = { ...raw, value };
2813
+ if (target) check.states[target.key] = value;
2814
+ const error = fieldError(node, check);
2815
+ if (error && [
2816
+ "too-short",
2817
+ "too-long",
2818
+ "range-underflow",
2819
+ "range-overflow",
2820
+ "step-mismatch",
2821
+ "number",
2822
+ "option"
2823
+ ].includes(error)) {
2824
+ state.invalid[node.id] = error;
2825
+ throw Error("invalid-edit");
2826
+ }
2827
+ write(state, target, value);
2828
+ raw.pending = false;
2829
+ delete state.invalid[node.id];
2830
+ }
2831
+ function resolveTarget(node, effect) {
2832
+ const target = record(effect.target), id = node.targets[scalar(target.scope) + ":" + scalar(target.id)], resolved = nodes.get(id != null ? id : "");
2833
+ if (!resolved) throw Error("missing-target");
2834
+ return resolved;
2835
+ }
2836
+ function openOverlay(state, target, opener) {
2837
+ var _a, _b;
2838
+ if (state.overlays.some((overlay) => overlay.id === target.id)) return;
2839
+ if (!roots(state).includes(target.root) || !guard(target.attributes.visibleWhen, target, state) || target.parent && !visible(nodes.get(target.parent), state))
2840
+ throw Error("inactive-target");
2841
+ const modal = target.kind === "modal" || target.kind === "drawer" && target.attributes.modal !== false;
2842
+ state.overlays.push({ id: target.id, opener: opener.id, modal });
2843
+ if (target.kind === "tooltip") return;
2844
+ const initial2 = nodes.get((_a = target.targets.initialFocus) != null ? _a : "");
2845
+ const first = initial2 != null ? initial2 : program.nodes.find(
2846
+ (node) => node.id !== target.id && descendant(node.id, target.id) && focusable(node, state)
2847
+ );
2848
+ if (initial2 && !focusable(initial2, state)) throw Error("invalid-focus");
2849
+ state.focus = (_b = first == null ? void 0 : first.id) != null ? _b : target.id;
2850
+ }
2851
+ function closeOverlay(state, target) {
2852
+ var _a, _b;
2853
+ const index = state.overlays.findIndex((overlay) => overlay.id === target.id);
2854
+ if (index < 0) return;
2855
+ const opener = state.overlays[index].opener;
2856
+ if (target.kind === "tooltip") {
2857
+ state.overlays.splice(index, 1);
2858
+ return;
2859
+ }
2860
+ state.overlays.splice(index);
2861
+ const candidate = opener ? nodes.get(opener) : void 0;
2862
+ state.focus = candidate && focusable(candidate, state) ? candidate.id : (_b = (_a = screenOf(state)) == null ? void 0 : _a.id) != null ? _b : null;
2863
+ }
2864
+ function schedule(state, node, activation, operation) {
2865
+ var _a, _b, _c, _d, _e;
2866
+ const effect = operation.effect, fixture = fixtures.get(scalar(effect.fixtureRef));
2867
+ if (!fixture) throw Error("missing-fixture");
2868
+ if (Object.keys(state.requests).length >= 128) throw Error("limit-requests");
2869
+ const output = [
2870
+ scalar(effect.resultState),
2871
+ scalar(effect.statusState),
2872
+ scalar(effect.errorState)
2873
+ ].map((ref) => node.bindings[ref]);
2874
+ if (output.some((item) => !item) || new Set(output.map((item) => item.key)).size !== 3)
2875
+ throw Error("fixture-output-alias");
2876
+ for (const item of output) if (state.reservations[item.key]) throw Error("state-busy");
2877
+ const cursor = (_a = state.fixtureCursors[fixture.id]) != null ? _a : 0, step = (_b = fixture.steps[cursor]) != null ? _b : fixture.exhaustion === "repeat-last" ? fixture.steps.at(-1) : void 0;
2878
+ state.fixtureCursors[fixture.id] = cursor + 1;
2879
+ const sequence = ++state.requestSequence, id = state.resetGeneration + ":" + sequence, timeout = Number(effect.timeoutMs);
2880
+ const deadline = state.virtualTime + timeout, responseAt = state.virtualTime + ((_c = step == null ? void 0 : step.delayMs) != null ? _c : 0);
2881
+ if (!Number.isSafeInteger(deadline) || !Number.isSafeInteger(responseAt))
2882
+ throw Error("limit-clock");
2883
+ const request = {
2884
+ id,
2885
+ generation: state.resetGeneration,
2886
+ sequence,
2887
+ activation: activation.id,
2888
+ owner: node.id,
2889
+ operation: clone(operation),
2890
+ resultKey: output[0].key,
2891
+ statusKey: output[1].key,
2892
+ errorKey: output[2].key,
2893
+ deadline,
2894
+ responseAt,
2895
+ outcome: (_d = step == null ? void 0 : step.outcome) != null ? _d : "exhausted",
2896
+ value: clone((_e = step == null ? void 0 : step.value) != null ? _e : null)
2897
+ };
2898
+ for (const item of output) state.reservations[item.key] = id;
2899
+ write(state, output[1], "pending", id);
2900
+ write(state, output[2], {}, id);
2901
+ state.requests[id] = request;
2902
+ state.scheduled.push({
2903
+ time: deadline,
2904
+ priority: 0,
2905
+ sequence,
2906
+ requestId: id,
2907
+ generation: state.resetGeneration,
2908
+ owner: node.id,
2909
+ operationId: operation.id
2910
+ });
2911
+ if (request.outcome !== "timeout")
2912
+ state.scheduled.push({
2913
+ time: responseAt,
2914
+ priority: 1,
2915
+ sequence,
2916
+ requestId: id,
2917
+ generation: state.resetGeneration,
2918
+ owner: node.id,
2919
+ operationId: operation.id
2920
+ });
2921
+ if (state.scheduled.length > 4096) throw Error("limit-queue");
2922
+ state.activations[String(activation.id)] = clone(activation);
2923
+ }
2924
+ function applyOperation(state, node, activation, operation, segment) {
2925
+ var _a;
2926
+ tick();
2927
+ const effect = operation.effect, kind = scalar(effect.kind), event = activation.event;
2928
+ if (kind === "specify") return "specified-unexecuted";
2929
+ if (kind === "simulate") {
2930
+ schedule(state, node, activation, operation);
2931
+ return "pending";
2932
+ }
2933
+ if (kind === "set") {
2934
+ write(
2935
+ state,
2936
+ node.bindings[scalar(effect.state)],
2937
+ expression(effect.value, node, state, event)
2938
+ );
2939
+ return "succeeded";
2940
+ }
2941
+ if (kind === "reset") {
2942
+ const binding = node.bindings[scalar(effect.state)];
2943
+ write(state, binding, binding.initial);
2944
+ for (const child of program.nodes)
2945
+ if (((_a = child.bindings[scalar(record(child.attributes.bind).state)]) == null ? void 0 : _a.key) === binding.key)
2946
+ delete state.invalid[child.id];
2947
+ return "succeeded";
2948
+ }
2949
+ if (kind === "toggle") {
2950
+ const binding = node.bindings[scalar(effect.state)], value = state.states[binding.key];
2951
+ if (typeof value !== "boolean") throw Error("state-type");
2952
+ write(state, binding, !value);
2953
+ return "succeeded";
2954
+ }
2955
+ if (kind === "filter" || kind === "sort") {
2956
+ const source = state.states[node.bindings[scalar(effect.source)].key];
2957
+ if (!Array.isArray(source)) throw Error("list-type");
2958
+ const field = scalar(effect.field);
2959
+ let result;
2960
+ if (kind === "filter") {
2961
+ const query = convert(expression(effect.query, node, state, event), "lower");
2962
+ for (const item of source)
2963
+ if (!Object.hasOwn(record(item), field) || typeof record(item)[field] !== "string")
2964
+ throw Error("filter-field-type");
2965
+ result = source.filter((item) => convert(record(item)[field], "lower").includes(query));
2966
+ } else {
2967
+ let type;
2968
+ for (const item of source) {
2969
+ const value = record(item)[field];
2970
+ if (!Object.hasOwn(record(item), field) || !["number", "string"].includes(typeof value) || type && type !== typeof value)
2971
+ throw Error("sort-field-type");
2972
+ type = typeof value;
2973
+ }
2974
+ result = source.map((value, index) => ({ value, index })).sort(
2975
+ (a, b) => compare(record(a.value)[field], record(b.value)[field]) * (effect.direction === "descending" ? -1 : 1) || a.index - b.index
2976
+ ).map((item) => item.value);
2977
+ }
2978
+ write(state, node.bindings[scalar(effect.target)], result);
2979
+ return "succeeded";
2980
+ }
2981
+ if (["open", "close", "toggleOverlay", "focus", "validate"].includes(kind)) {
2982
+ const target = resolveTarget(node, effect);
2983
+ if (kind === "validate") {
2984
+ if (!active(target, state)) throw Error("inactive-target");
2985
+ if (!validateForm(state, target)) throw Error("form-invalid");
2986
+ } else if (kind === "focus") {
2987
+ if (!focusable(target, state)) throw Error("invalid-focus");
2988
+ state.focus = target.id;
2989
+ } else if (kind === "close" || kind === "toggleOverlay" && state.overlays.some((item) => item.id === target.id))
2990
+ closeOverlay(state, target);
2991
+ else openOverlay(state, target, node);
2992
+ return "succeeded";
2993
+ }
2994
+ if (kind === "navigate") {
2995
+ const target = record(effect.target);
2996
+ if (target.kind === "url") {
2997
+ state.effects.push({
2998
+ kind: "external",
2999
+ fragment: scalar(target.url),
3000
+ sequence: 0,
3001
+ delta: 0
3002
+ });
3003
+ return "succeeded";
3004
+ }
3005
+ const route = target.screen;
3006
+ const fragment = routeAddress(route);
3007
+ if (!parseAddress(fragment)) throw Error("missing-route");
3008
+ segment.route = {
3009
+ fragment,
3010
+ mode: effect.history === "replace" ? "replace" : "push",
3011
+ index: null,
3012
+ browserSequence: null
3013
+ };
3014
+ return "succeeded";
3015
+ }
3016
+ if (kind === "navigateBack" || kind === "navigateForward") {
3017
+ const index = state.historyIndex + (kind === "navigateBack" ? -1 : 1);
3018
+ if (index < 0 || index >= state.history.length) return "history-boundary";
3019
+ segment.route = {
3020
+ fragment: state.history[index].fragment,
3021
+ mode: "traverse",
3022
+ index,
3023
+ browserSequence: null
3024
+ };
3025
+ return "succeeded";
3026
+ }
3027
+ if (kind === "resetScenario") {
3028
+ segment.reset = true;
3029
+ return "succeeded";
3030
+ }
3031
+ throw Error("unsupported-operation");
3032
+ }
3033
+ function cancelRequest(state, request, surviving, reset2 = false) {
3034
+ var _a, _b;
3035
+ for (const key of [request.resultKey, request.statusKey, request.errorKey])
3036
+ delete state.reservations[key];
3037
+ if (!reset2) {
3038
+ for (const [key, value] of [
3039
+ [request.statusKey, "cancelled"],
3040
+ [request.errorKey, { code: "cancelled", value: null, operationId: request.operation.id }]
3041
+ ]) {
3042
+ const binding = program.states[key];
3043
+ if (binding && (binding.lifetime === "session" || surviving.includes(binding.root)))
3044
+ write(state, binding, value);
3045
+ }
3046
+ }
3047
+ const node = nodes.get(request.owner), activation = state.activations[String(request.activation)], handler = (_a = node.handlers.find((handler2) => handler2.id === (activation == null ? void 0 : activation.handlerId))) != null ? _a : null;
3048
+ delete state.requests[request.id];
3049
+ state.scheduled = state.scheduled.filter(
3050
+ (item) => item.requestId !== request.id || item.priority === 1
3051
+ );
3052
+ delete state.activations[String(request.activation)];
3053
+ state.queue = state.queue.filter((item) => item.source !== request.owner);
3054
+ append(state, node, handler, request.operation, (_b = activation == null ? void 0 : activation.event) != null ? _b : {}, "cancelled");
3055
+ }
3056
+ function ensureFocus(state, previous, observed) {
3057
+ var _a, _b, _c;
3058
+ for (const overlay of [...state.overlays]) {
3059
+ const node = nodes.get(overlay.id);
3060
+ if (node && !visible(node, state)) closeOverlay(state, node);
3061
+ }
3062
+ let target = state.focus ? nodes.get(state.focus) : void 0;
3063
+ if (target && !focusable(target, state)) {
3064
+ while (target == null ? void 0 : target.parent) {
3065
+ target = nodes.get(target.parent);
3066
+ if (target && focusable(target, state)) break;
3067
+ }
3068
+ state.focus = target && focusable(target, state) ? target.id : (_b = (_a = screenOf(state)) == null ? void 0 : _a.id) != null ? _b : null;
3069
+ }
3070
+ if (state.focus !== previous.focus) {
3071
+ for (const [source, type] of [
3072
+ [previous.focus, "blur"],
3073
+ [state.focus, "focus"]
3074
+ ]) {
3075
+ if (!source || (observed == null ? void 0 : observed.source) === source && observed.type === type || !((_c = nodes.get(source)) == null ? void 0 : _c.handlers.some((handler) => handler.event === type)) || state.queue.some(
3076
+ (item) => item.source === source && item.event.type === type && item.handlerId === null
3077
+ ))
3078
+ continue;
3079
+ enqueue(state, { source, event: { type }, handlerId: null });
3080
+ }
3081
+ }
3082
+ }
3083
+ function lifecycle(state, ids, event) {
3084
+ for (const id of ids) {
3085
+ const node = nodes.get(id != null ? id : "");
3086
+ if (!node) continue;
3087
+ const handler = node.handlers.find((handler2) => handler2.event === event);
3088
+ if (!handler) continue;
3089
+ tick();
3090
+ if (!guard(handler.guard, node, state)) continue;
3091
+ const activation = {
3092
+ id: ++state.activationSequence,
3093
+ owner: node.id,
3094
+ handlerId: handler.id,
3095
+ event: { type: event },
3096
+ index: 0,
3097
+ statuses: {}
3098
+ }, segment = { route: null, reset: false };
3099
+ for (const operation of handler.operations) {
3100
+ const before = clone(state.states);
3101
+ if (operation.after.some((id2) => activation.statuses[id2] !== "succeeded")) {
3102
+ activation.statuses[operation.id] = "skipped-dependency";
3103
+ append(state, node, handler, operation, activation.event, "skipped-dependency");
3104
+ continue;
3105
+ }
3106
+ try {
3107
+ const result = applyOperation(state, node, activation, operation, segment);
3108
+ activation.statuses[operation.id] = result;
3109
+ append(state, node, handler, operation, activation.event, result, null, before);
3110
+ } catch (error) {
3111
+ activation.statuses[operation.id] = "failed";
3112
+ append(
3113
+ state,
3114
+ node,
3115
+ handler,
3116
+ operation,
3117
+ activation.event,
3118
+ "failed",
3119
+ error.message
3120
+ );
3121
+ if (operation.onFailure === "stop") throw error;
3122
+ }
3123
+ }
3124
+ if (segment.route || segment.reset) throw Error("exit-effect");
3125
+ }
3126
+ }
3127
+ function changeRoute(state, request) {
3128
+ var _a;
3129
+ const route = parseAddress(request.fragment), current = screenOf(state), next = program.screens.find(
3130
+ (screen) => screen.route.namespace === (route == null ? void 0 : route.namespace) && screen.route.id === (route == null ? void 0 : route.id)
3131
+ );
3132
+ const identical = canonical(state.route) === canonical(route) && state.address === (request.fragment || routeAddress(program.entry));
3133
+ if (identical && request.mode === "push") return;
3134
+ const departed = (current == null ? void 0 : current.id) !== (next == null ? void 0 : next.id), oldRoots = roots(state), nextRoots = next ? [
3135
+ "app",
3136
+ "screen/" + next.route.namespace + "/" + next.route.id,
3137
+ ...next.shell ? [program.shells.find((shell) => shell.id === next.shell).root] : []
3138
+ ] : ["app"];
3139
+ if (departed) {
3140
+ for (const pending of Object.values(state.requests))
3141
+ if (!nextRoots.includes(nodes.get(pending.owner).root))
3142
+ cancelRequest(state, pending, nextRoots);
3143
+ lifecycle(
3144
+ state,
3145
+ [current == null ? void 0 : current.id, (current == null ? void 0 : current.shell) !== (next == null ? void 0 : next.shell) ? current == null ? void 0 : current.shell : null],
3146
+ "exit"
3147
+ );
3148
+ state.overlays = state.overlays.filter(
3149
+ (overlay) => nextRoots.includes(nodes.get(overlay.id).root)
3150
+ );
3151
+ for (const binding of Object.values(program.states))
3152
+ if (binding.lifetime === "mount" && oldRoots.includes(binding.root) && !nextRoots.includes(binding.root))
3153
+ state.states[binding.key] = clone(binding.initial);
3154
+ for (const node of program.nodes)
3155
+ if (oldRoots.includes(node.root) && !nextRoots.includes(node.root)) {
3156
+ delete state.invalid[node.id];
3157
+ state.controls[node.id] = initialControl(node);
3158
+ }
3159
+ state.queue = state.queue.filter(
3160
+ (item) => {
3161
+ var _a2, _b;
3162
+ return nextRoots.includes((_b = (_a2 = nodes.get(item.source)) == null ? void 0 : _a2.root) != null ? _b : "");
3163
+ }
3164
+ );
3165
+ }
3166
+ state.route = route;
3167
+ state.address = request.fragment || routeAddress(program.entry);
3168
+ if (request.mode === "push") {
3169
+ state.history = state.history.slice(0, state.historyIndex + 1);
3170
+ const sequence = state.nextHistorySequence++;
3171
+ state.history.push({ fragment: state.address, sequence });
3172
+ state.historyIndex = state.history.length - 1;
3173
+ state.effects.push({ kind: "push", fragment: state.address, sequence, delta: 0 });
3174
+ } else if (request.mode === "replace") {
3175
+ const sequence = state.history[state.historyIndex].sequence;
3176
+ state.history[state.historyIndex] = { fragment: state.address, sequence };
3177
+ state.effects.push({ kind: "replace", fragment: state.address, sequence, delta: 0 });
3178
+ } else if (request.index !== null) {
3179
+ const delta = request.index - state.historyIndex;
3180
+ state.historyIndex = request.index;
3181
+ if (request.mode === "traverse")
3182
+ state.effects.push({
3183
+ kind: "traverse",
3184
+ fragment: state.address,
3185
+ sequence: state.history[request.index].sequence,
3186
+ delta
3187
+ });
3188
+ } else {
3189
+ const sequence = state.nextHistorySequence++;
3190
+ state.history = [{ fragment: state.address, sequence }];
3191
+ state.historyIndex = 0;
3192
+ state.effects.push({ kind: "replace", fragment: state.address, sequence, delta: 0 });
3193
+ }
3194
+ if (departed && next) {
3195
+ if ((current == null ? void 0 : current.shell) !== next.shell && next.shell)
3196
+ enqueue(state, { source: next.shell, event: { type: "enter" }, handlerId: null });
3197
+ enqueue(state, { source: next.id, event: { type: "enter" }, handlerId: null });
3198
+ }
3199
+ if (departed) state.focus = (_a = next == null ? void 0 : next.id) != null ? _a : null;
3200
+ }
3201
+ function initialControl(node) {
3202
+ var _a, _b, _c, _d;
3203
+ return {
3204
+ value: (_d = node.attributes.value) != null ? _d : node.kind === "select" ? Array.isArray(node.attributes.options) ? (_b = (_a = node.attributes.options.map(record).find((option) => option.disabled !== true)) == null ? void 0 : _a.value) != null ? _b : "" : "" : ["slider", "progress"].includes(node.kind) ? (_c = node.attributes.min) != null ? _c : 0 : "",
3205
+ checked: node.attributes.checked === true
3206
+ };
3207
+ }
3208
+ function fresh(fragment = routeAddress(program.entry)) {
3209
+ var _a, _b;
3210
+ const route = parseAddress(fragment), state = {
3211
+ modelDigest: program.modelDigest,
3212
+ profileDigest: program.profileDigest,
3213
+ resetGeneration: 0,
3214
+ virtualTime: Number(program.profile.clockStartMs),
3215
+ sequence: 0,
3216
+ requestSequence: 0,
3217
+ activationSequence: 0,
3218
+ states: {},
3219
+ controls: {},
3220
+ invalid: {},
3221
+ route,
3222
+ address: fragment || routeAddress(program.entry),
3223
+ history: [{ fragment: fragment || routeAddress(program.entry), sequence: 0 }],
3224
+ historyIndex: 0,
3225
+ nextHistorySequence: 1,
3226
+ overlays: [],
3227
+ focus: null,
3228
+ selection: {},
3229
+ expanded: {},
3230
+ viewMode: "fixed",
3231
+ fixtureCursors: {},
3232
+ requests: {},
3233
+ reservations: {},
3234
+ activations: {},
3235
+ queue: [],
3236
+ scheduled: [],
3237
+ trace: [],
3238
+ effects: [],
3239
+ diagnostic: null,
3240
+ suspended: false
3241
+ };
3242
+ for (const [key, binding] of Object.entries(program.states))
3243
+ state.states[key] = clone(binding.initial);
3244
+ for (const node of program.nodes) {
3245
+ state.controls[node.id] = initialControl(node);
3246
+ if (node.kind === "tabs") state.selection[node.id] = Number((_a = node.attributes.active) != null ? _a : 0);
3247
+ state.expanded[node.id] = node.attributes.expanded === true || node.attributes.dismissible === true;
3248
+ }
3249
+ const screen = screenOf(state);
3250
+ state.focus = (_b = screen == null ? void 0 : screen.id) != null ? _b : null;
3251
+ if (screen == null ? void 0 : screen.shell)
3252
+ enqueue(state, { source: screen.shell, event: { type: "enter" }, handlerId: null });
3253
+ if (screen) enqueue(state, { source: screen.id, event: { type: "enter" }, handlerId: null });
3254
+ return state;
3255
+ }
3256
+ function reset(state) {
3257
+ const next = fresh(), previousTrace = state.trace;
3258
+ next.resetGeneration = state.resetGeneration + 1;
3259
+ next.sequence = state.sequence;
3260
+ next.trace = previousTrace;
3261
+ next.nextHistorySequence = state.nextHistorySequence + 1;
3262
+ next.history[0].sequence = state.nextHistorySequence;
3263
+ next.effects = [
3264
+ { kind: "replace", fragment: next.address, sequence: next.history[0].sequence, delta: 0 }
3265
+ ];
3266
+ Object.assign(state, next);
3267
+ append(state, null, null, null, { type: "reset" }, "succeeded");
3268
+ }
3269
+ function runHandler(state, node, handler, event, resumed) {
3270
+ var _a;
3271
+ tick();
3272
+ if (!resumed && !["input", "change"].includes(scalar(event.type)) && Object.values(state.requests).some(
3273
+ (request) => {
3274
+ var _a2;
3275
+ return request.owner === node.id && ((_a2 = state.activations[String(request.activation)]) == null ? void 0 : _a2.handlerId) === handler.id;
3276
+ }
3277
+ )) {
3278
+ if (handler.concurrency === "queue")
3279
+ enqueue(state, { source: node.id, event: clone(event), handlerId: handler.id });
3280
+ else append(state, node, handler, null, event, "busy", "busy");
3281
+ return;
3282
+ }
3283
+ const before = clone(state), draft = clone(state), segment = { route: null, reset: false }, records = [];
3284
+ const activation = resumed ? clone(resumed) : {
3285
+ id: ++draft.activationSequence,
3286
+ owner: node.id,
3287
+ handlerId: handler.id,
3288
+ event: clone(event),
3289
+ index: 0,
3290
+ statuses: {}
3291
+ };
3292
+ let pending = false;
3293
+ try {
3294
+ if (!resumed && ["input", "change"].includes(scalar(event.type)))
3295
+ normalizeControl(draft, node, event);
3296
+ const busy = Object.values(draft.requests).some(
3297
+ (request) => {
3298
+ var _a2;
3299
+ return request.owner === node.id && ((_a2 = draft.activations[String(request.activation)]) == null ? void 0 : _a2.handlerId) === handler.id;
3300
+ }
3301
+ );
3302
+ if (!resumed && busy) {
3303
+ if (handler.concurrency === "queue") {
3304
+ enqueue(draft, { source: node.id, event: clone(event), handlerId: handler.id });
3305
+ Object.assign(state, draft);
3306
+ return;
3307
+ }
3308
+ Object.assign(state, draft);
3309
+ append(state, node, handler, null, event, "busy", "busy", before.states);
3310
+ return;
3311
+ }
3312
+ if (!resumed && !guard(handler.guard, node, draft, event)) {
3313
+ Object.assign(state, draft);
3314
+ for (const operation of handler.operations)
3315
+ append(state, node, handler, operation, event, "guard-false", null, before.states);
3316
+ return;
3317
+ }
3318
+ for (let index = activation.index; index < handler.operations.length; index++) {
3319
+ const operation = handler.operations[index];
3320
+ activation.index = index + 1;
3321
+ if (operation.after.some((id) => activation.statuses[id] !== "succeeded")) {
3322
+ activation.statuses[operation.id] = "skipped-dependency";
3323
+ records.push({ operation, result: "skipped-dependency", code: null });
3324
+ continue;
3325
+ }
3326
+ const prior = clone(draft), priorSegment = clone(segment);
3327
+ try {
3328
+ const result = applyOperation(draft, node, activation, operation, segment);
3329
+ activation.statuses[operation.id] = result;
3330
+ records.push({
3331
+ operation,
3332
+ result,
3333
+ code: result === "history-boundary" ? "history-boundary" : null
3334
+ });
3335
+ if (result === "pending") {
3336
+ pending = true;
3337
+ draft.activations[String(activation.id)] = clone(activation);
3338
+ break;
3339
+ }
3340
+ if (segment.reset || (result === "specified-unexecuted" || result === "history-boundary") && operation.onFailure === "stop")
3341
+ break;
3342
+ } catch (error) {
3343
+ const validation = clone(draft.invalid), focus = draft.focus;
3344
+ Object.assign(draft, prior);
3345
+ Object.assign(segment, priorSegment);
3346
+ if (error.message === "form-invalid") {
3347
+ draft.invalid = validation;
3348
+ draft.focus = focus;
3349
+ }
3350
+ activation.statuses[operation.id] = "failed";
3351
+ records.push({ operation, result: "failed", code: error.message });
3352
+ if (operation.onFailure === "stop") throw error;
3353
+ }
3354
+ }
3355
+ if (segment.route) changeRoute(draft, segment.route);
3356
+ view(draft);
3357
+ ensureFocus(draft, before, { source: node.id, type: scalar(event.type) });
3358
+ if (!pending) delete draft.activations[String(activation.id)];
3359
+ Object.assign(state, draft);
3360
+ for (const item of records)
3361
+ append(state, node, handler, item.operation, event, item.result, item.code, before.states);
3362
+ if (segment.reset) reset(state);
3363
+ } catch (error) {
3364
+ const code = error.message;
3365
+ if (code === "invalid-edit") {
3366
+ state.controls[node.id] = draft.controls[node.id];
3367
+ state.invalid[node.id] = draft.invalid[node.id];
3368
+ append(state, node, handler, null, event, "failed", "invalid-edit");
3369
+ return;
3370
+ }
3371
+ if (code === "form-invalid") {
3372
+ state.invalid = clone(draft.invalid);
3373
+ state.focus = draft.focus;
3374
+ }
3375
+ if (resumed) delete state.activations[String(activation.id)];
3376
+ if (!records.length) append(state, node, handler, null, event, "failed", code);
3377
+ for (const item of records)
3378
+ append(
3379
+ state,
3380
+ node,
3381
+ handler,
3382
+ item.operation,
3383
+ event,
3384
+ item.result === "succeeded" || item.result === "pending" ? "cancelled" : item.result,
3385
+ (_a = item.code) != null ? _a : item.result === "succeeded" ? null : code
3386
+ );
3387
+ if (!records.some((item) => item.code === code))
3388
+ append(state, node, handler, null, event, "failed", code);
3389
+ if (code.startsWith("limit-")) throw error;
3390
+ }
3391
+ }
3392
+ function composite(state, node, event) {
3393
+ const type = event.type, key = event.key;
3394
+ if (node.kind === "accordion" && type === "click")
3395
+ state.expanded[node.id] = !state.expanded[node.id];
3396
+ if (["alert", "toast"].includes(node.kind) && node.attributes.dismissible === true && type === "click")
3397
+ state.expanded[node.id] = false;
3398
+ const tabs = node.kind === "tab" && node.parent ? nodes.get(node.parent) : node.kind === "tabs" ? node : void 0;
3399
+ if ((tabs == null ? void 0 : tabs.kind) === "tabs") {
3400
+ const list = tabs.children.map((id) => nodes.get(id)).filter((child) => child.kind === "tab" && enabled(child, state));
3401
+ const selected = list.findIndex((child) => child.id === node.id), current = selected < 0 ? 0 : selected;
3402
+ const backwards = tabs.attributes.vertical === true ? "ArrowUp" : "ArrowLeft", forwards = tabs.attributes.vertical === true ? "ArrowDown" : "ArrowRight";
3403
+ let next = current;
3404
+ if (type === "keydown" && key === backwards) next = (current - 1 + list.length) % list.length;
3405
+ else if (type === "keydown" && key === forwards) next = (current + 1) % list.length;
3406
+ else if (type === "keydown" && key === "Home") next = 0;
3407
+ else if (type === "keydown" && key === "End") next = list.length - 1;
3408
+ if (type === "click" || type === "keydown" && ["Enter", " "].includes(scalar(key)))
3409
+ state.selection[tabs.id] = tabs.children.filter((id) => {
3410
+ var _a;
3411
+ return ((_a = nodes.get(id)) == null ? void 0 : _a.kind) === "tab";
3412
+ }).indexOf(node.id);
3413
+ if (list[next]) state.focus = list[next].id;
3414
+ }
3415
+ if (node.kind === "dropdown" && (type === "click" || type === "keydown" && ["Enter", " ", "ArrowDown", "ArrowUp"].includes(scalar(key)))) {
3416
+ if (state.overlays.some((overlay) => overlay.id === node.id) && type === "click")
3417
+ closeOverlay(state, node);
3418
+ else openOverlay(state, node, node);
3419
+ }
3420
+ let menu = node;
3421
+ while (menu && menu.kind !== "dropdown") menu = menu.parent ? nodes.get(menu.parent) : void 0;
3422
+ if (menu && node.kind === "dropdown-item" && type === "click") closeOverlay(state, menu);
3423
+ if (menu && state.overlays.some((overlay) => overlay.id === menu.id) && type === "keydown") {
3424
+ const list = program.nodes.filter(
3425
+ (candidate) => candidate.kind === "dropdown-item" && descendant(candidate.id, menu.id) && enabled(candidate, state)
3426
+ );
3427
+ let index = list.findIndex((candidate) => candidate.id === node.id);
3428
+ if (key === "ArrowDown") index = (index + 1) % list.length;
3429
+ else if (key === "ArrowUp") index = (index - 1 + list.length) % list.length;
3430
+ else if (key === "Home") index = 0;
3431
+ else if (key === "End") index = list.length - 1;
3432
+ else index = -1;
3433
+ if (list[index]) state.focus = list[index].id;
3434
+ }
3435
+ if (type === "keydown" && key === "Escape") {
3436
+ const top = state.overlays.at(-1), target = top ? nodes.get(top.id) : void 0;
3437
+ if (target && target.attributes.dismissible !== false) closeOverlay(state, target);
3438
+ }
3439
+ const tooltip = node.parent ? nodes.get(node.parent) : void 0;
3440
+ if ((tooltip == null ? void 0 : tooltip.kind) === "tooltip") {
3441
+ if (type === "focus") openOverlay(state, tooltip, node);
3442
+ else if (type === "blur") closeOverlay(state, tooltip);
3443
+ }
3444
+ if (type === "focus") state.focus = node.id;
3445
+ else if (type === "blur" && state.focus === node.id) state.focus = null;
3446
+ }
3447
+ function dispatch(state, node, event, handlerId = null) {
3448
+ var _a;
3449
+ tick();
3450
+ const internal = ["enter", "exit"].includes(scalar(event.type));
3451
+ if (!internal && !active(node, state)) {
3452
+ append(state, node, null, null, event, "failed", "inactive-owner");
3453
+ return;
3454
+ }
3455
+ if (internal && !roots(state).includes(node.root)) return;
3456
+ const handlers = node.handlers.filter(
3457
+ (handler) => handlerId ? handler.id === handlerId : handler.event === event.type && (handler.event !== "keydown" || handler.key === event.key)
3458
+ );
3459
+ if (event.type === "submit") {
3460
+ const validated = clone(state);
3461
+ if (!validateForm(validated, node)) {
3462
+ state.invalid = validated.invalid;
3463
+ state.focus = validated.focus;
3464
+ append(state, node, null, null, event, "failed", "form-invalid");
3465
+ return;
3466
+ }
3467
+ state.invalid = validated.invalid;
3468
+ if (state.diagnostic === "form-invalid") state.diagnostic = null;
3469
+ }
3470
+ const previous = { ...state, states: { ...state.states } };
3471
+ composite(state, node, event);
3472
+ if (!handlers.length && ["input", "change"].includes(scalar(event.type))) {
3473
+ const draft = clone(state);
3474
+ try {
3475
+ normalizeControl(draft, node, event);
3476
+ view(draft);
3477
+ Object.assign(state, draft);
3478
+ append(state, node, null, null, event, "succeeded", null, previous.states);
3479
+ } catch (error) {
3480
+ const code = error.message;
3481
+ if (code === "invalid-edit") {
3482
+ state.controls[node.id] = draft.controls[node.id];
3483
+ state.invalid[node.id] = draft.invalid[node.id];
3484
+ }
3485
+ append(state, node, null, null, event, "failed", code);
3486
+ }
3487
+ }
3488
+ for (const handler of handlers) runHandler(state, node, handler, event);
3489
+ if (event.type === "keydown" && node.kind === "dropdown-item" && ["Enter", " "].includes(scalar(event.key)))
3490
+ enqueue(state, { source: node.id, event: { type: "click" }, handlerId: null });
3491
+ if (event.type === "click" && node.kind === "button" && (node.attributes.buttonType === "submit" || node.attributes.action === "submit") && !handlers.some((handler) => handler.event === "click")) {
3492
+ const form = nodes.get((_a = node.form) != null ? _a : "");
3493
+ if (form) enqueue(state, { source: form.id, event: { type: "submit" }, handlerId: null });
3494
+ }
3495
+ if (event.type === "click" && node.kind === "button" && node.attributes.buttonType === "reset") {
3496
+ for (const child of program.nodes.filter((child2) => child2.form === node.form)) {
3497
+ const target = child.bindings[scalar(record(child.attributes.bind).state)];
3498
+ if (target) write(state, target, target.initial);
3499
+ state.controls[child.id] = initialControl(child);
3500
+ delete state.invalid[child.id];
3501
+ }
3502
+ }
3503
+ ensureFocus(state, previous, { source: node.id, type: scalar(event.type) });
3504
+ }
3505
+ function drain(state) {
3506
+ let blocked = 0;
3507
+ while (state.queue.length) {
3508
+ if (blocked >= state.queue.length) break;
3509
+ const next = state.queue.shift(), node = nodes.get(next.source);
3510
+ if (!node) continue;
3511
+ if (next.handlerId && Object.values(state.requests).some(
3512
+ (request) => {
3513
+ var _a;
3514
+ return request.owner === node.id && ((_a = state.activations[String(request.activation)]) == null ? void 0 : _a.handlerId) === next.handlerId;
3515
+ }
3516
+ )) {
3517
+ state.queue.push(next);
3518
+ blocked++;
3519
+ continue;
3520
+ }
3521
+ blocked = 0;
3522
+ dispatch(state, node, next.event, next.handlerId);
3523
+ }
3524
+ }
3525
+ function completion(state, due) {
3526
+ var _a, _b, _c;
3527
+ const request = state.requests[due.requestId], node = (_a = nodes.get(due.owner)) != null ? _a : null;
3528
+ if (!request || request.generation !== state.resetGeneration) {
3529
+ const handler2 = (_b = node == null ? void 0 : node.handlers.find(
3530
+ (handler3) => handler3.operations.some((operation) => operation.id === due.operationId)
3531
+ )) != null ? _b : null;
3532
+ if (due.priority === 1)
3533
+ append(
3534
+ state,
3535
+ node,
3536
+ handler2,
3537
+ (_c = handler2 == null ? void 0 : handler2.operations.find((operation) => operation.id === due.operationId)) != null ? _c : null,
3538
+ { type: "fixture-response", requestId: due.requestId },
3539
+ "stale-response",
3540
+ "stale-response"
3541
+ );
3542
+ return;
3543
+ }
3544
+ const activation = state.activations[String(request.activation)], owner = nodes.get(request.owner), handler = owner.handlers.find((handler2) => handler2.id === (activation == null ? void 0 : activation.handlerId));
3545
+ if (!activation || !handler || !roots(state).includes(owner.root)) {
3546
+ cancelRequest(state, request, roots(state));
3547
+ append(
3548
+ state,
3549
+ owner,
3550
+ handler != null ? handler : null,
3551
+ request.operation,
3552
+ { type: "fixture-response" },
3553
+ "stale-response",
3554
+ "stale-response"
3555
+ );
3556
+ return;
3557
+ }
3558
+ const before = clone(state.states), timedOut = due.priority === 0, success = !timedOut && request.outcome === "success";
3559
+ for (const key of [request.resultKey, request.statusKey, request.errorKey])
3560
+ delete state.reservations[key];
3561
+ delete state.requests[request.id];
3562
+ state.scheduled = state.scheduled.filter(
3563
+ (item) => item.requestId !== request.id || timedOut && item.priority === 1
3564
+ );
3565
+ const code = success ? null : timedOut ? "timeout" : request.outcome === "exhausted" ? "fixture-exhausted" : "fixture-error";
3566
+ if (success) write(state, program.states[request.resultKey], request.value);
3567
+ write(state, program.states[request.statusKey], success ? "succeeded" : "failed");
3568
+ write(
3569
+ state,
3570
+ program.states[request.errorKey],
3571
+ success ? {} : {
3572
+ code,
3573
+ value: timedOut || request.outcome === "exhausted" ? null : request.value,
3574
+ operationId: request.operation.id
3575
+ }
3576
+ );
3577
+ activation.statuses[request.operation.id] = success ? "succeeded" : "failed";
3578
+ append(
3579
+ state,
3580
+ owner,
3581
+ handler,
3582
+ request.operation,
3583
+ activation.event,
3584
+ success ? "succeeded" : "failed",
3585
+ code,
3586
+ before
3587
+ );
3588
+ if (!success && request.operation.onFailure === "stop")
3589
+ delete state.activations[String(activation.id)];
3590
+ else runHandler(state, owner, handler, activation.event, activation);
3591
+ drain(state);
3592
+ }
3593
+ function initial(fragment) {
3594
+ microsteps = 0;
3595
+ const state = fresh(fragment);
3596
+ try {
3597
+ drain(state);
3598
+ } catch (error) {
3599
+ state.queue = [];
3600
+ append(state, null, null, null, { type: "initial" }, "failed", error.message);
3601
+ }
3602
+ state.effects = [];
3603
+ return state;
3604
+ }
3605
+ function reduce(previous, input, browserSequence = null) {
3606
+ const state = clone(previous);
3607
+ state.effects = [];
3608
+ microsteps = 0;
3609
+ try {
3610
+ if (!input || typeof input !== "object" || Array.isArray(input)) throw Error("input-shape");
3611
+ const keys = input.kind === "reset" ? ["kind"] : input.kind === "advanceClock" ? ["kind", "deltaMs"] : input.kind === "address" ? ["kind", "fragment"] : input.kind === "event" ? ["kind", "source", "event", "key", "value", "checked"] : [];
3612
+ if (!keys.length || Object.keys(input).some((key) => !keys.includes(key)))
3613
+ throw Error("input-shape");
3614
+ if (state.suspended && input.kind !== "address" && input.kind !== "reset") {
3615
+ append(state, null, null, null, { type: input.kind }, "busy", "history-compensation");
3616
+ return state;
3617
+ }
3618
+ if (input.kind === "reset") {
3619
+ reset(state);
3620
+ drain(state);
3621
+ return state;
3622
+ }
3623
+ if (input.kind === "advanceClock") {
3624
+ if (!Number.isInteger(input.deltaMs) || input.deltaMs < 0 || input.deltaMs > 6e5 || !Number.isSafeInteger(state.virtualTime + input.deltaMs))
3625
+ throw Error("limit-clock");
3626
+ const target = state.virtualTime + input.deltaMs;
3627
+ for (; ; ) {
3628
+ state.scheduled.sort(
3629
+ (a, b) => a.time - b.time || a.priority - b.priority || a.sequence - b.sequence
3630
+ );
3631
+ const due = state.scheduled[0];
3632
+ if (!due || due.time > target) break;
3633
+ state.scheduled.shift();
3634
+ state.virtualTime = due.time;
3635
+ microsteps = 0;
3636
+ completion(state, due);
3637
+ }
3638
+ state.virtualTime = target;
3639
+ return state;
3640
+ }
3641
+ if (input.kind === "address") {
3642
+ if (typeof input.fragment !== "string") throw Error("input-shape");
3643
+ bounded(input.fragment);
3644
+ const fragment = input.fragment || routeAddress(program.entry);
3645
+ if (state.suspended && fragment === state.address && browserSequence === state.history[state.historyIndex].sequence) {
3646
+ state.suspended = false;
3647
+ return state;
3648
+ }
3649
+ const index = browserSequence === null ? -1 : state.history.findIndex(
3650
+ (entry) => entry.sequence === browserSequence && entry.fragment === fragment
3651
+ );
3652
+ try {
3653
+ changeRoute(state, {
3654
+ fragment: input.fragment,
3655
+ mode: "address",
3656
+ index: index < 0 ? null : index,
3657
+ browserSequence
3658
+ });
3659
+ ensureFocus(state, previous);
3660
+ drain(state);
3661
+ return state;
3662
+ } catch (error) {
3663
+ const restored = clone(previous);
3664
+ restored.effects = [];
3665
+ const code = error.message;
3666
+ append(
3667
+ restored,
3668
+ null,
3669
+ null,
3670
+ null,
3671
+ { type: "address", fragment: input.fragment },
3672
+ "failed",
3673
+ code
3674
+ );
3675
+ if (index >= 0) {
3676
+ restored.suspended = true;
3677
+ restored.effects.push({
3678
+ kind: "compensate",
3679
+ fragment: restored.address,
3680
+ sequence: restored.history[restored.historyIndex].sequence,
3681
+ delta: restored.historyIndex - index
3682
+ });
3683
+ } else {
3684
+ const sequence = restored.nextHistorySequence++;
3685
+ restored.history = [{ fragment: restored.address, sequence }];
3686
+ restored.historyIndex = 0;
3687
+ restored.effects.push({
3688
+ kind: "replace",
3689
+ fragment: restored.address,
3690
+ sequence,
3691
+ delta: 0
3692
+ });
3693
+ }
3694
+ return restored;
3695
+ }
3696
+ }
3697
+ const node = byIdentity.get(canonical(input.source));
3698
+ if (!node) throw Error("unknown-source");
3699
+ if (!["click", "input", "change", "submit", "keydown", "focus", "blur"].includes(input.event))
3700
+ throw Error("event-type");
3701
+ if (input.event === "keydown" && (typeof input.key !== "string" || "value" in input || "checked" in input))
3702
+ throw Error("event-payload");
3703
+ if (!["input", "change", "keydown"].includes(input.event) && ("value" in input || "checked" in input || "key" in input))
3704
+ throw Error("event-payload");
3705
+ if (["input", "change"].includes(input.event) && !["input", "textarea", "select", "checkbox", "radio", "switch", "slider"].includes(
3706
+ node.kind
3707
+ ))
3708
+ throw Error("event-owner");
3709
+ if (input.event === "submit" && node.kind !== "form") throw Error("event-owner");
3710
+ const event = { type: input.event };
3711
+ if (input.value !== void 0) {
3712
+ bounded(input.value);
3713
+ event.value = input.value;
3714
+ }
3715
+ if (input.checked !== void 0) event.checked = input.checked;
3716
+ if (input.key !== void 0) event.key = input.key;
3717
+ dispatch(state, node, event);
3718
+ drain(state);
3719
+ view(state);
3720
+ return state;
3721
+ } catch (error) {
3722
+ const restored = clone(previous);
3723
+ restored.effects = [];
3724
+ append(
3725
+ restored,
3726
+ null,
3727
+ null,
3728
+ null,
3729
+ { type: scalar(record(input).kind) || "invalid" },
3730
+ "failed",
3731
+ error.message
3732
+ );
3733
+ return restored;
3734
+ }
3735
+ }
3736
+ function hover(previous, id, open) {
3737
+ const state = clone(previous), node = nodes.get(id);
3738
+ state.effects = [];
3739
+ if ((node == null ? void 0 : node.kind) === "tooltip" && active(node, state)) {
3740
+ if (open) openOverlay(state, node, node);
3741
+ else closeOverlay(state, node);
3742
+ }
3743
+ return state;
3744
+ }
3745
+ return { initial, reduce, view, parseAddress, routeAddress, hover };
3746
+ }
3747
+ var UNICODE_15_1 = JSON.parse(
3748
+ [
3749
+ '{"lower":{"65":"a","66":"b","67":"c","68":"d","69":"e","70":"f","71":"g","72":"h","73":"i","74":"j","75":"k","76":"l","77":"m","78":"n","79":"o","80":"p","81":"q","82":"r","83":"s","84":"t","85":"u","86":"v","87":"w","88":"x","89":"y","90":"z","192":"\\u00e0","193":"\\u00e1","194":"\\u00e2","195":"\\u00e3","196":"\\u00e4","197":"\\u00e5","198":"\\u00e6","199":"\\u00e7","200":"\\u00e8","201":"\\u00e9","202":"\\u00ea","203":"\\u00eb","204":"\\u00ec","205":"\\u00ed","206":"\\u00ee","207":"\\u00ef","208":"\\u00f0","209":"\\u00f1","210":"\\u00f2","211":"\\u00f3","212":"\\u00f4","213":"\\u00f5","214":"\\u00f6","216":"\\u00f8","217":"\\u00f9","218":"\\u00fa","219":"\\u00fb","220":"\\u00fc","221":"\\u00fd","222":"\\u00fe","256":"\\u0101","258":"\\u0103","260":"\\u0105","262":"\\u0107","264":"\\u0109","266":"\\u010b","268":"\\u010d","270":"\\u010f","272":"\\u0111","274":"\\u0113","276":"\\u0115","278":"\\u0117","280":"\\u0119","282":"\\u011b","284":"\\u011d","286":"\\u011f","288":"\\u0121","290":"\\u0123","292":"\\u0125","294":"\\u0127","296":"\\u0129","298":"\\u012b","300":"\\u012d","302":"\\u012f","304":"i\\u0307","306":"\\u0133","308":"\\u0135","310":"\\u0137","313":"\\u013a","315":"\\u013c","317":"\\u013e","319":"\\u0140","321":"\\u0142","323":"\\u0144","325":"\\u0146","327":"\\u0148","330":"\\u014b","332":"\\u014d","334":"\\u014f","336":"\\u0151","338":"\\u0153","340":"\\u0155","342":"\\u0157","344":"\\u0159","346":"\\u015b","348":"\\u015d","350":"\\u015f","352":"\\u0161","354":"\\u0163","356":"\\u0165","358":"\\u0167","360":"\\u0169","362":"\\u016b","364":"\\u016d","366":"\\u016f","368":"\\u0171","370":"\\u0173","372":"\\u0175","374":"\\u0177","376":"\\u00ff","377":"\\u017a","379":"\\u017c","381":"\\u017e","385":"\\u0253","386":"\\u0183","388":"\\u0185","390":"\\u0254","391":"\\u0188","393":"\\u0256","394":"\\u0257","395":"\\u018c","398":"\\u01dd","399":"\\u0259","400":"\\u025b","401":"\\u0192","403":"\\u0260","404":"\\u0263","406":"\\u0269","407":"\\u0268","408":"\\u0199","412":"\\u026f","413":"\\u0272","415":"\\u0275","416":"\\u01a1","418":"\\u01a3","420":"\\u01a5","422":"\\u0280","423":"\\u01a8","425":"\\u0283","428":"\\u01ad","430":"\\u0288","431":"\\u01b0","433":"\\u028a","434":"\\u028b","435":"\\u01b4","437":"\\u01b6","439":"\\u0292","440":"\\u01b9","444":"\\u01bd","452":"\\u01c6","453":"\\u01c6","455":"\\u01c9","456":"\\u01c9","458":"\\u01cc","459":"\\u01cc","461":"\\u01ce","463":"\\u01d0","465":"\\u01d2","467":"\\u01d4","469":"\\u01d6","471":"\\u01d8","473":"\\u01da","475":"\\u01dc","478":"\\u01df","480":"\\u01e1","482":"\\u01e3","484":"\\u01e5","486":"\\u01e7","488":"\\u01e9","490":"\\u01eb","492":"\\u01ed","494":"\\u01ef","497":"\\u01f3","498":"\\u01f3","500":"\\u01f5","502":"\\u0195","503":"\\u01bf","504":"\\u01f9","506":"\\u01fb","508":"\\u01fd","510":"\\u01ff","512":"\\u0201","514":"\\u0203","516":"\\u0205","518":"\\u0207","520":"\\u0209","522":"\\u020b","524":"\\u020d","526":"\\u020f","528":"\\u0211","530":"\\u0213","532":"\\u0215","534":"\\u0217","536":"\\u0219","538":"\\u021b","540":"\\u021d","542":"\\u021f","544":"\\u019e","546":"\\u0223","548":"\\u0225","550":"\\u0227","552":"\\u0229","554":"\\u022b","556":"\\u0',
3750
+ '22d","558":"\\u022f","560":"\\u0231","562":"\\u0233","570":"\\u2c65","571":"\\u023c","573":"\\u019a","574":"\\u2c66","577":"\\u0242","579":"\\u0180","580":"\\u0289","581":"\\u028c","582":"\\u0247","584":"\\u0249","586":"\\u024b","588":"\\u024d","590":"\\u024f","880":"\\u0371","882":"\\u0373","886":"\\u0377","895":"\\u03f3","902":"\\u03ac","904":"\\u03ad","905":"\\u03ae","906":"\\u03af","908":"\\u03cc","910":"\\u03cd","911":"\\u03ce","913":"\\u03b1","914":"\\u03b2","915":"\\u03b3","916":"\\u03b4","917":"\\u03b5","918":"\\u03b6","919":"\\u03b7","920":"\\u03b8","921":"\\u03b9","922":"\\u03ba","923":"\\u03bb","924":"\\u03bc","925":"\\u03bd","926":"\\u03be","927":"\\u03bf","928":"\\u03c0","929":"\\u03c1","931":"\\u03c3","932":"\\u03c4","933":"\\u03c5","934":"\\u03c6","935":"\\u03c7","936":"\\u03c8","937":"\\u03c9","938":"\\u03ca","939":"\\u03cb","975":"\\u03d7","984":"\\u03d9","986":"\\u03db","988":"\\u03dd","990":"\\u03df","992":"\\u03e1","994":"\\u03e3","996":"\\u03e5","998":"\\u03e7","1000":"\\u03e9","1002":"\\u03eb","1004":"\\u03ed","1006":"\\u03ef","1012":"\\u03b8","1015":"\\u03f8","1017":"\\u03f2","1018":"\\u03fb","1021":"\\u037b","1022":"\\u037c","1023":"\\u037d","1024":"\\u0450","1025":"\\u0451","1026":"\\u0452","1027":"\\u0453","1028":"\\u0454","1029":"\\u0455","1030":"\\u0456","1031":"\\u0457","1032":"\\u0458","1033":"\\u0459","1034":"\\u045a","1035":"\\u045b","1036":"\\u045c","1037":"\\u045d","1038":"\\u045e","1039":"\\u045f","1040":"\\u0430","1041":"\\u0431","1042":"\\u0432","1043":"\\u0433","1044":"\\u0434","1045":"\\u0435","1046":"\\u0436","1047":"\\u0437","1048":"\\u0438","1049":"\\u0439","1050":"\\u043a","1051":"\\u043b","1052":"\\u043c","1053":"\\u043d","1054":"\\u043e","1055":"\\u043f","1056":"\\u0440","1057":"\\u0441","1058":"\\u0442","1059":"\\u0443","1060":"\\u0444","1061":"\\u0445","1062":"\\u0446","1063":"\\u0447","1064":"\\u0448","1065":"\\u0449","1066":"\\u044a","1067":"\\u044b","1068":"\\u044c","1069":"\\u044d","1070":"\\u044e","1071":"\\u044f","1120":"\\u0461","1122":"\\u0463","1124":"\\u0465","1126":"\\u0467","1128":"\\u0469","1130":"\\u046b","1132":"\\u046d","1134":"\\u046f","1136":"\\u0471","1138":"\\u0473","1140":"\\u0475","1142":"\\u0477","1144":"\\u0479","1146":"\\u047b","1148":"\\u047d","1150":"\\u047f","1152":"\\u0481","1162":"\\u048b","1164":"\\u048d","1166":"\\u048f","1168":"\\u0491","1170":"\\u0493","1172":"\\u0495","1174":"\\u0497","1176":"\\u0499","1178":"\\u049b","1180":"\\u049d","1182":"\\u049f","1184":"\\u04a1","1186":"\\u04a3","1188":"\\u04a5","1190":"\\u04a7","1192":"\\u04a9","1194":"\\u04ab","1196":"\\u04ad","1198":"\\u04af","1200":"\\u04b1","1202":"\\u04b3","1204":"\\u04b5","1206":"\\u04b7","1208":"\\u04b9","1210":"\\u04bb","1212":"\\u04bd","1214":"\\u04bf","1216":"\\u04cf","1217":"\\u04c2","1219":"\\u04c4","1221":"\\u04c6","1223":"\\u04c8","1225":"\\u04ca","1227":"\\u04cc","1229":"\\u04ce","1232":"\\u04d1","1234":"\\u04d3","1236":"\\u04d5","1238":"\\u04d7","1240":"\\u04d9","1242":"\\u04db","1244":"\\u04dd","1246":"\\u04df","1248":"\\u04e1","1250":"\\u04e3","1252":"\\u04e5","1254":"\\u04e7","1256":"\\u04e9","1258":"\\u04eb","1260":"\\u04ed","1262":"\\u04ef","1264":"\\u04f1","1266":"\\u04f3","',
3751
+ '1268":"\\u04f5","1270":"\\u04f7","1272":"\\u04f9","1274":"\\u04fb","1276":"\\u04fd","1278":"\\u04ff","1280":"\\u0501","1282":"\\u0503","1284":"\\u0505","1286":"\\u0507","1288":"\\u0509","1290":"\\u050b","1292":"\\u050d","1294":"\\u050f","1296":"\\u0511","1298":"\\u0513","1300":"\\u0515","1302":"\\u0517","1304":"\\u0519","1306":"\\u051b","1308":"\\u051d","1310":"\\u051f","1312":"\\u0521","1314":"\\u0523","1316":"\\u0525","1318":"\\u0527","1320":"\\u0529","1322":"\\u052b","1324":"\\u052d","1326":"\\u052f","1329":"\\u0561","1330":"\\u0562","1331":"\\u0563","1332":"\\u0564","1333":"\\u0565","1334":"\\u0566","1335":"\\u0567","1336":"\\u0568","1337":"\\u0569","1338":"\\u056a","1339":"\\u056b","1340":"\\u056c","1341":"\\u056d","1342":"\\u056e","1343":"\\u056f","1344":"\\u0570","1345":"\\u0571","1346":"\\u0572","1347":"\\u0573","1348":"\\u0574","1349":"\\u0575","1350":"\\u0576","1351":"\\u0577","1352":"\\u0578","1353":"\\u0579","1354":"\\u057a","1355":"\\u057b","1356":"\\u057c","1357":"\\u057d","1358":"\\u057e","1359":"\\u057f","1360":"\\u0580","1361":"\\u0581","1362":"\\u0582","1363":"\\u0583","1364":"\\u0584","1365":"\\u0585","1366":"\\u0586","4256":"\\u2d00","4257":"\\u2d01","4258":"\\u2d02","4259":"\\u2d03","4260":"\\u2d04","4261":"\\u2d05","4262":"\\u2d06","4263":"\\u2d07","4264":"\\u2d08","4265":"\\u2d09","4266":"\\u2d0a","4267":"\\u2d0b","4268":"\\u2d0c","4269":"\\u2d0d","4270":"\\u2d0e","4271":"\\u2d0f","4272":"\\u2d10","4273":"\\u2d11","4274":"\\u2d12","4275":"\\u2d13","4276":"\\u2d14","4277":"\\u2d15","4278":"\\u2d16","4279":"\\u2d17","4280":"\\u2d18","4281":"\\u2d19","4282":"\\u2d1a","4283":"\\u2d1b","4284":"\\u2d1c","4285":"\\u2d1d","4286":"\\u2d1e","4287":"\\u2d1f","4288":"\\u2d20","4289":"\\u2d21","4290":"\\u2d22","4291":"\\u2d23","4292":"\\u2d24","4293":"\\u2d25","4295":"\\u2d27","4301":"\\u2d2d","5024":"\\uab70","5025":"\\uab71","5026":"\\uab72","5027":"\\uab73","5028":"\\uab74","5029":"\\uab75","5030":"\\uab76","5031":"\\uab77","5032":"\\uab78","5033":"\\uab79","5034":"\\uab7a","5035":"\\uab7b","5036":"\\uab7c","5037":"\\uab7d","5038":"\\uab7e","5039":"\\uab7f","5040":"\\uab80","5041":"\\uab81","5042":"\\uab82","5043":"\\uab83","5044":"\\uab84","5045":"\\uab85","5046":"\\uab86","5047":"\\uab87","5048":"\\uab88","5049":"\\uab89","5050":"\\uab8a","5051":"\\uab8b","5052":"\\uab8c","5053":"\\uab8d","5054":"\\uab8e","5055":"\\uab8f","5056":"\\uab90","5057":"\\uab91","5058":"\\uab92","5059":"\\uab93","5060":"\\uab94","5061":"\\uab95","5062":"\\uab96","5063":"\\uab97","5064":"\\uab98","5065":"\\uab99","5066":"\\uab9a","5067":"\\uab9b","5068":"\\uab9c","5069":"\\uab9d","5070":"\\uab9e","5071":"\\uab9f","5072":"\\uaba0","5073":"\\uaba1","5074":"\\uaba2","5075":"\\uaba3","5076":"\\uaba4","5077":"\\uaba5","5078":"\\uaba6","5079":"\\uaba7","5080":"\\uaba8","5081":"\\uaba9","5082":"\\uabaa","5083":"\\uabab","5084":"\\uabac","5085":"\\uabad","5086":"\\uabae","5087":"\\uabaf","5088":"\\uabb0","5089":"\\uabb1","5090":"\\uabb2","5091":"\\uabb3","5092":"\\uabb4","5093":"\\uabb5","5094":"\\uabb6","5095":"\\uabb7","5096":"\\uabb8","5097":"\\uabb9","5098":"\\uabba","5099":"\\uabbb","5100":"\\uabbc","5101":"\\uabbd","5102":"\\uabbe","5103":"\\',
3752
+ 'uabbf","5104":"\\u13f8","5105":"\\u13f9","5106":"\\u13fa","5107":"\\u13fb","5108":"\\u13fc","5109":"\\u13fd","7312":"\\u10d0","7313":"\\u10d1","7314":"\\u10d2","7315":"\\u10d3","7316":"\\u10d4","7317":"\\u10d5","7318":"\\u10d6","7319":"\\u10d7","7320":"\\u10d8","7321":"\\u10d9","7322":"\\u10da","7323":"\\u10db","7324":"\\u10dc","7325":"\\u10dd","7326":"\\u10de","7327":"\\u10df","7328":"\\u10e0","7329":"\\u10e1","7330":"\\u10e2","7331":"\\u10e3","7332":"\\u10e4","7333":"\\u10e5","7334":"\\u10e6","7335":"\\u10e7","7336":"\\u10e8","7337":"\\u10e9","7338":"\\u10ea","7339":"\\u10eb","7340":"\\u10ec","7341":"\\u10ed","7342":"\\u10ee","7343":"\\u10ef","7344":"\\u10f0","7345":"\\u10f1","7346":"\\u10f2","7347":"\\u10f3","7348":"\\u10f4","7349":"\\u10f5","7350":"\\u10f6","7351":"\\u10f7","7352":"\\u10f8","7353":"\\u10f9","7354":"\\u10fa","7357":"\\u10fd","7358":"\\u10fe","7359":"\\u10ff","7680":"\\u1e01","7682":"\\u1e03","7684":"\\u1e05","7686":"\\u1e07","7688":"\\u1e09","7690":"\\u1e0b","7692":"\\u1e0d","7694":"\\u1e0f","7696":"\\u1e11","7698":"\\u1e13","7700":"\\u1e15","7702":"\\u1e17","7704":"\\u1e19","7706":"\\u1e1b","7708":"\\u1e1d","7710":"\\u1e1f","7712":"\\u1e21","7714":"\\u1e23","7716":"\\u1e25","7718":"\\u1e27","7720":"\\u1e29","7722":"\\u1e2b","7724":"\\u1e2d","7726":"\\u1e2f","7728":"\\u1e31","7730":"\\u1e33","7732":"\\u1e35","7734":"\\u1e37","7736":"\\u1e39","7738":"\\u1e3b","7740":"\\u1e3d","7742":"\\u1e3f","7744":"\\u1e41","7746":"\\u1e43","7748":"\\u1e45","7750":"\\u1e47","7752":"\\u1e49","7754":"\\u1e4b","7756":"\\u1e4d","7758":"\\u1e4f","7760":"\\u1e51","7762":"\\u1e53","7764":"\\u1e55","7766":"\\u1e57","7768":"\\u1e59","7770":"\\u1e5b","7772":"\\u1e5d","7774":"\\u1e5f","7776":"\\u1e61","7778":"\\u1e63","7780":"\\u1e65","7782":"\\u1e67","7784":"\\u1e69","7786":"\\u1e6b","7788":"\\u1e6d","7790":"\\u1e6f","7792":"\\u1e71","7794":"\\u1e73","7796":"\\u1e75","7798":"\\u1e77","7800":"\\u1e79","7802":"\\u1e7b","7804":"\\u1e7d","7806":"\\u1e7f","7808":"\\u1e81","7810":"\\u1e83","7812":"\\u1e85","7814":"\\u1e87","7816":"\\u1e89","7818":"\\u1e8b","7820":"\\u1e8d","7822":"\\u1e8f","7824":"\\u1e91","7826":"\\u1e93","7828":"\\u1e95","7838":"\\u00df","7840":"\\u1ea1","7842":"\\u1ea3","7844":"\\u1ea5","7846":"\\u1ea7","7848":"\\u1ea9","7850":"\\u1eab","7852":"\\u1ead","7854":"\\u1eaf","7856":"\\u1eb1","7858":"\\u1eb3","7860":"\\u1eb5","7862":"\\u1eb7","7864":"\\u1eb9","7866":"\\u1ebb","7868":"\\u1ebd","7870":"\\u1ebf","7872":"\\u1ec1","7874":"\\u1ec3","7876":"\\u1ec5","7878":"\\u1ec7","7880":"\\u1ec9","7882":"\\u1ecb","7884":"\\u1ecd","7886":"\\u1ecf","7888":"\\u1ed1","7890":"\\u1ed3","7892":"\\u1ed5","7894":"\\u1ed7","7896":"\\u1ed9","7898":"\\u1edb","7900":"\\u1edd","7902":"\\u1edf","7904":"\\u1ee1","7906":"\\u1ee3","7908":"\\u1ee5","7910":"\\u1ee7","7912":"\\u1ee9","7914":"\\u1eeb","7916":"\\u1eed","7918":"\\u1eef","7920":"\\u1ef1","7922":"\\u1ef3","7924":"\\u1ef5","7926":"\\u1ef7","7928":"\\u1ef9","7930":"\\u1efb","7932":"\\u1efd","7934":"\\u1eff","7944":"\\u1f00","7945":"\\u1f01","7946":"\\u1f02","7947":"\\u1f03","7948":"\\u1f04","7949":"\\u1f05","7950":"\\u1f06","7951":"\\u1f07","7960":"\\u1f10","7961":"\\u1f11","7962":"\\u1f12","',
3753
+ '7963":"\\u1f13","7964":"\\u1f14","7965":"\\u1f15","7976":"\\u1f20","7977":"\\u1f21","7978":"\\u1f22","7979":"\\u1f23","7980":"\\u1f24","7981":"\\u1f25","7982":"\\u1f26","7983":"\\u1f27","7992":"\\u1f30","7993":"\\u1f31","7994":"\\u1f32","7995":"\\u1f33","7996":"\\u1f34","7997":"\\u1f35","7998":"\\u1f36","7999":"\\u1f37","8008":"\\u1f40","8009":"\\u1f41","8010":"\\u1f42","8011":"\\u1f43","8012":"\\u1f44","8013":"\\u1f45","8025":"\\u1f51","8027":"\\u1f53","8029":"\\u1f55","8031":"\\u1f57","8040":"\\u1f60","8041":"\\u1f61","8042":"\\u1f62","8043":"\\u1f63","8044":"\\u1f64","8045":"\\u1f65","8046":"\\u1f66","8047":"\\u1f67","8072":"\\u1f80","8073":"\\u1f81","8074":"\\u1f82","8075":"\\u1f83","8076":"\\u1f84","8077":"\\u1f85","8078":"\\u1f86","8079":"\\u1f87","8088":"\\u1f90","8089":"\\u1f91","8090":"\\u1f92","8091":"\\u1f93","8092":"\\u1f94","8093":"\\u1f95","8094":"\\u1f96","8095":"\\u1f97","8104":"\\u1fa0","8105":"\\u1fa1","8106":"\\u1fa2","8107":"\\u1fa3","8108":"\\u1fa4","8109":"\\u1fa5","8110":"\\u1fa6","8111":"\\u1fa7","8120":"\\u1fb0","8121":"\\u1fb1","8122":"\\u1f70","8123":"\\u1f71","8124":"\\u1fb3","8136":"\\u1f72","8137":"\\u1f73","8138":"\\u1f74","8139":"\\u1f75","8140":"\\u1fc3","8152":"\\u1fd0","8153":"\\u1fd1","8154":"\\u1f76","8155":"\\u1f77","8168":"\\u1fe0","8169":"\\u1fe1","8170":"\\u1f7a","8171":"\\u1f7b","8172":"\\u1fe5","8184":"\\u1f78","8185":"\\u1f79","8186":"\\u1f7c","8187":"\\u1f7d","8188":"\\u1ff3","8486":"\\u03c9","8490":"k","8491":"\\u00e5","8498":"\\u214e","8544":"\\u2170","8545":"\\u2171","8546":"\\u2172","8547":"\\u2173","8548":"\\u2174","8549":"\\u2175","8550":"\\u2176","8551":"\\u2177","8552":"\\u2178","8553":"\\u2179","8554":"\\u217a","8555":"\\u217b","8556":"\\u217c","8557":"\\u217d","8558":"\\u217e","8559":"\\u217f","8579":"\\u2184","9398":"\\u24d0","9399":"\\u24d1","9400":"\\u24d2","9401":"\\u24d3","9402":"\\u24d4","9403":"\\u24d5","9404":"\\u24d6","9405":"\\u24d7","9406":"\\u24d8","9407":"\\u24d9","9408":"\\u24da","9409":"\\u24db","9410":"\\u24dc","9411":"\\u24dd","9412":"\\u24de","9413":"\\u24df","9414":"\\u24e0","9415":"\\u24e1","9416":"\\u24e2","9417":"\\u24e3","9418":"\\u24e4","9419":"\\u24e5","9420":"\\u24e6","9421":"\\u24e7","9422":"\\u24e8","9423":"\\u24e9","11264":"\\u2c30","11265":"\\u2c31","11266":"\\u2c32","11267":"\\u2c33","11268":"\\u2c34","11269":"\\u2c35","11270":"\\u2c36","11271":"\\u2c37","11272":"\\u2c38","11273":"\\u2c39","11274":"\\u2c3a","11275":"\\u2c3b","11276":"\\u2c3c","11277":"\\u2c3d","11278":"\\u2c3e","11279":"\\u2c3f","11280":"\\u2c40","11281":"\\u2c41","11282":"\\u2c42","11283":"\\u2c43","11284":"\\u2c44","11285":"\\u2c45","11286":"\\u2c46","11287":"\\u2c47","11288":"\\u2c48","11289":"\\u2c49","11290":"\\u2c4a","11291":"\\u2c4b","11292":"\\u2c4c","11293":"\\u2c4d","11294":"\\u2c4e","11295":"\\u2c4f","11296":"\\u2c50","11297":"\\u2c51","11298":"\\u2c52","11299":"\\u2c53","11300":"\\u2c54","11301":"\\u2c55","11302":"\\u2c56","11303":"\\u2c57","11304":"\\u2c58","11305":"\\u2c59","11306":"\\u2c5a","11307":"\\u2c5b","11308":"\\u2c5c","11309":"\\u2c5d","11310":"\\u2c5e","11311":"\\u2c5f","11360":"\\u2c61","11362":"\\u026b","11363":"\\u1d7d","11364":"\\u027d","11367":"\\',
3754
+ 'u2c68","11369":"\\u2c6a","11371":"\\u2c6c","11373":"\\u0251","11374":"\\u0271","11375":"\\u0250","11376":"\\u0252","11378":"\\u2c73","11381":"\\u2c76","11390":"\\u023f","11391":"\\u0240","11392":"\\u2c81","11394":"\\u2c83","11396":"\\u2c85","11398":"\\u2c87","11400":"\\u2c89","11402":"\\u2c8b","11404":"\\u2c8d","11406":"\\u2c8f","11408":"\\u2c91","11410":"\\u2c93","11412":"\\u2c95","11414":"\\u2c97","11416":"\\u2c99","11418":"\\u2c9b","11420":"\\u2c9d","11422":"\\u2c9f","11424":"\\u2ca1","11426":"\\u2ca3","11428":"\\u2ca5","11430":"\\u2ca7","11432":"\\u2ca9","11434":"\\u2cab","11436":"\\u2cad","11438":"\\u2caf","11440":"\\u2cb1","11442":"\\u2cb3","11444":"\\u2cb5","11446":"\\u2cb7","11448":"\\u2cb9","11450":"\\u2cbb","11452":"\\u2cbd","11454":"\\u2cbf","11456":"\\u2cc1","11458":"\\u2cc3","11460":"\\u2cc5","11462":"\\u2cc7","11464":"\\u2cc9","11466":"\\u2ccb","11468":"\\u2ccd","11470":"\\u2ccf","11472":"\\u2cd1","11474":"\\u2cd3","11476":"\\u2cd5","11478":"\\u2cd7","11480":"\\u2cd9","11482":"\\u2cdb","11484":"\\u2cdd","11486":"\\u2cdf","11488":"\\u2ce1","11490":"\\u2ce3","11499":"\\u2cec","11501":"\\u2cee","11506":"\\u2cf3","42560":"\\ua641","42562":"\\ua643","42564":"\\ua645","42566":"\\ua647","42568":"\\ua649","42570":"\\ua64b","42572":"\\ua64d","42574":"\\ua64f","42576":"\\ua651","42578":"\\ua653","42580":"\\ua655","42582":"\\ua657","42584":"\\ua659","42586":"\\ua65b","42588":"\\ua65d","42590":"\\ua65f","42592":"\\ua661","42594":"\\ua663","42596":"\\ua665","42598":"\\ua667","42600":"\\ua669","42602":"\\ua66b","42604":"\\ua66d","42624":"\\ua681","42626":"\\ua683","42628":"\\ua685","42630":"\\ua687","42632":"\\ua689","42634":"\\ua68b","42636":"\\ua68d","42638":"\\ua68f","42640":"\\ua691","42642":"\\ua693","42644":"\\ua695","42646":"\\ua697","42648":"\\ua699","42650":"\\ua69b","42786":"\\ua723","42788":"\\ua725","42790":"\\ua727","42792":"\\ua729","42794":"\\ua72b","42796":"\\ua72d","42798":"\\ua72f","42802":"\\ua733","42804":"\\ua735","42806":"\\ua737","42808":"\\ua739","42810":"\\ua73b","42812":"\\ua73d","42814":"\\ua73f","42816":"\\ua741","42818":"\\ua743","42820":"\\ua745","42822":"\\ua747","42824":"\\ua749","42826":"\\ua74b","42828":"\\ua74d","42830":"\\ua74f","42832":"\\ua751","42834":"\\ua753","42836":"\\ua755","42838":"\\ua757","42840":"\\ua759","42842":"\\ua75b","42844":"\\ua75d","42846":"\\ua75f","42848":"\\ua761","42850":"\\ua763","42852":"\\ua765","42854":"\\ua767","42856":"\\ua769","42858":"\\ua76b","42860":"\\ua76d","42862":"\\ua76f","42873":"\\ua77a","42875":"\\ua77c","42877":"\\u1d79","42878":"\\ua77f","42880":"\\ua781","42882":"\\ua783","42884":"\\ua785","42886":"\\ua787","42891":"\\ua78c","42893":"\\u0265","42896":"\\ua791","42898":"\\ua793","42902":"\\ua797","42904":"\\ua799","42906":"\\ua79b","42908":"\\ua79d","42910":"\\ua79f","42912":"\\ua7a1","42914":"\\ua7a3","42916":"\\ua7a5","42918":"\\ua7a7","42920":"\\ua7a9","42922":"\\u0266","42923":"\\u025c","42924":"\\u0261","42925":"\\u026c","42926":"\\u026a","42928":"\\u029e","42929":"\\u0287","42930":"\\u029d","42931":"\\uab53","42932":"\\ua7b5","42934":"\\ua7b7","42936":"\\ua7b9","42938":"\\ua7bb","42940":"\\ua7bd","42942":"\\ua7bf","42944":"\\ua7c1","',
3755
+ '42946":"\\ua7c3","42948":"\\ua794","42949":"\\u0282","42950":"\\u1d8e","42951":"\\ua7c8","42953":"\\ua7ca","42960":"\\ua7d1","42966":"\\ua7d7","42968":"\\ua7d9","42997":"\\ua7f6","65313":"\\uff41","65314":"\\uff42","65315":"\\uff43","65316":"\\uff44","65317":"\\uff45","65318":"\\uff46","65319":"\\uff47","65320":"\\uff48","65321":"\\uff49","65322":"\\uff4a","65323":"\\uff4b","65324":"\\uff4c","65325":"\\uff4d","65326":"\\uff4e","65327":"\\uff4f","65328":"\\uff50","65329":"\\uff51","65330":"\\uff52","65331":"\\uff53","65332":"\\uff54","65333":"\\uff55","65334":"\\uff56","65335":"\\uff57","65336":"\\uff58","65337":"\\uff59","65338":"\\uff5a","66560":"\\ud801\\udc28","66561":"\\ud801\\udc29","66562":"\\ud801\\udc2a","66563":"\\ud801\\udc2b","66564":"\\ud801\\udc2c","66565":"\\ud801\\udc2d","66566":"\\ud801\\udc2e","66567":"\\ud801\\udc2f","66568":"\\ud801\\udc30","66569":"\\ud801\\udc31","66570":"\\ud801\\udc32","66571":"\\ud801\\udc33","66572":"\\ud801\\udc34","66573":"\\ud801\\udc35","66574":"\\ud801\\udc36","66575":"\\ud801\\udc37","66576":"\\ud801\\udc38","66577":"\\ud801\\udc39","66578":"\\ud801\\udc3a","66579":"\\ud801\\udc3b","66580":"\\ud801\\udc3c","66581":"\\ud801\\udc3d","66582":"\\ud801\\udc3e","66583":"\\ud801\\udc3f","66584":"\\ud801\\udc40","66585":"\\ud801\\udc41","66586":"\\ud801\\udc42","66587":"\\ud801\\udc43","66588":"\\ud801\\udc44","66589":"\\ud801\\udc45","66590":"\\ud801\\udc46","66591":"\\ud801\\udc47","66592":"\\ud801\\udc48","66593":"\\ud801\\udc49","66594":"\\ud801\\udc4a","66595":"\\ud801\\udc4b","66596":"\\ud801\\udc4c","66597":"\\ud801\\udc4d","66598":"\\ud801\\udc4e","66599":"\\ud801\\udc4f","66736":"\\ud801\\udcd8","66737":"\\ud801\\udcd9","66738":"\\ud801\\udcda","66739":"\\ud801\\udcdb","66740":"\\ud801\\udcdc","66741":"\\ud801\\udcdd","66742":"\\ud801\\udcde","66743":"\\ud801\\udcdf","66744":"\\ud801\\udce0","66745":"\\ud801\\udce1","66746":"\\ud801\\udce2","66747":"\\ud801\\udce3","66748":"\\ud801\\udce4","66749":"\\ud801\\udce5","66750":"\\ud801\\udce6","66751":"\\ud801\\udce7","66752":"\\ud801\\udce8","66753":"\\ud801\\udce9","66754":"\\ud801\\udcea","66755":"\\ud801\\udceb","66756":"\\ud801\\udcec","66757":"\\ud801\\udced","66758":"\\ud801\\udcee","66759":"\\ud801\\udcef","66760":"\\ud801\\udcf0","66761":"\\ud801\\udcf1","66762":"\\ud801\\udcf2","66763":"\\ud801\\udcf3","66764":"\\ud801\\udcf4","66765":"\\ud801\\udcf5","66766":"\\ud801\\udcf6","66767":"\\ud801\\udcf7","66768":"\\ud801\\udcf8","66769":"\\ud801\\udcf9","66770":"\\ud801\\udcfa","66771":"\\ud801\\udcfb","66928":"\\ud801\\udd97","66929":"\\ud801\\udd98","66930":"\\ud801\\udd99","66931":"\\ud801\\udd9a","66932":"\\ud801\\udd9b","66933":"\\ud801\\udd9c","66934":"\\ud801\\udd9d","66935":"\\ud801\\udd9e","66936":"\\ud801\\udd9f","66937":"\\ud801\\udda0","66938":"\\ud801\\udda1","66940":"\\ud801\\udda3","66941":"\\ud801\\udda4","66942":"\\ud801\\udda5","66943":"\\ud801\\udda6","66944":"\\ud801\\udda7","66945":"\\ud801\\udda8","66946":"\\ud801\\udda9","66947":"\\ud801\\uddaa","66948":"\\ud801\\uddab","66949":"\\ud801\\uddac","66950":"\\ud801\\uddad","66951":"\\ud801\\uddae","66952":"\\ud801\\uddaf","66953":"\\ud801\\uddb0","66954":"\\ud801\\uddb1","66956":"\\ud801\\uddb3","66957":"\\ud801\\uddb',
3756
+ '4","66958":"\\ud801\\uddb5","66959":"\\ud801\\uddb6","66960":"\\ud801\\uddb7","66961":"\\ud801\\uddb8","66962":"\\ud801\\uddb9","66964":"\\ud801\\uddbb","66965":"\\ud801\\uddbc","68736":"\\ud803\\udcc0","68737":"\\ud803\\udcc1","68738":"\\ud803\\udcc2","68739":"\\ud803\\udcc3","68740":"\\ud803\\udcc4","68741":"\\ud803\\udcc5","68742":"\\ud803\\udcc6","68743":"\\ud803\\udcc7","68744":"\\ud803\\udcc8","68745":"\\ud803\\udcc9","68746":"\\ud803\\udcca","68747":"\\ud803\\udccb","68748":"\\ud803\\udccc","68749":"\\ud803\\udccd","68750":"\\ud803\\udcce","68751":"\\ud803\\udccf","68752":"\\ud803\\udcd0","68753":"\\ud803\\udcd1","68754":"\\ud803\\udcd2","68755":"\\ud803\\udcd3","68756":"\\ud803\\udcd4","68757":"\\ud803\\udcd5","68758":"\\ud803\\udcd6","68759":"\\ud803\\udcd7","68760":"\\ud803\\udcd8","68761":"\\ud803\\udcd9","68762":"\\ud803\\udcda","68763":"\\ud803\\udcdb","68764":"\\ud803\\udcdc","68765":"\\ud803\\udcdd","68766":"\\ud803\\udcde","68767":"\\ud803\\udcdf","68768":"\\ud803\\udce0","68769":"\\ud803\\udce1","68770":"\\ud803\\udce2","68771":"\\ud803\\udce3","68772":"\\ud803\\udce4","68773":"\\ud803\\udce5","68774":"\\ud803\\udce6","68775":"\\ud803\\udce7","68776":"\\ud803\\udce8","68777":"\\ud803\\udce9","68778":"\\ud803\\udcea","68779":"\\ud803\\udceb","68780":"\\ud803\\udcec","68781":"\\ud803\\udced","68782":"\\ud803\\udcee","68783":"\\ud803\\udcef","68784":"\\ud803\\udcf0","68785":"\\ud803\\udcf1","68786":"\\ud803\\udcf2","71840":"\\ud806\\udcc0","71841":"\\ud806\\udcc1","71842":"\\ud806\\udcc2","71843":"\\ud806\\udcc3","71844":"\\ud806\\udcc4","71845":"\\ud806\\udcc5","71846":"\\ud806\\udcc6","71847":"\\ud806\\udcc7","71848":"\\ud806\\udcc8","71849":"\\ud806\\udcc9","71850":"\\ud806\\udcca","71851":"\\ud806\\udccb","71852":"\\ud806\\udccc","71853":"\\ud806\\udccd","71854":"\\ud806\\udcce","71855":"\\ud806\\udccf","71856":"\\ud806\\udcd0","71857":"\\ud806\\udcd1","71858":"\\ud806\\udcd2","71859":"\\ud806\\udcd3","71860":"\\ud806\\udcd4","71861":"\\ud806\\udcd5","71862":"\\ud806\\udcd6","71863":"\\ud806\\udcd7","71864":"\\ud806\\udcd8","71865":"\\ud806\\udcd9","71866":"\\ud806\\udcda","71867":"\\ud806\\udcdb","71868":"\\ud806\\udcdc","71869":"\\ud806\\udcdd","71870":"\\ud806\\udcde","71871":"\\ud806\\udcdf","93760":"\\ud81b\\ude60","93761":"\\ud81b\\ude61","93762":"\\ud81b\\ude62","93763":"\\ud81b\\ude63","93764":"\\ud81b\\ude64","93765":"\\ud81b\\ude65","93766":"\\ud81b\\ude66","93767":"\\ud81b\\ude67","93768":"\\ud81b\\ude68","93769":"\\ud81b\\ude69","93770":"\\ud81b\\ude6a","93771":"\\ud81b\\ude6b","93772":"\\ud81b\\ude6c","93773":"\\ud81b\\ude6d","93774":"\\ud81b\\ude6e","93775":"\\ud81b\\ude6f","93776":"\\ud81b\\ude70","93777":"\\ud81b\\ude71","93778":"\\ud81b\\ude72","93779":"\\ud81b\\ude73","93780":"\\ud81b\\ude74","93781":"\\ud81b\\ude75","93782":"\\ud81b\\ude76","93783":"\\ud81b\\ude77","93784":"\\ud81b\\ude78","93785":"\\ud81b\\ude79","93786":"\\ud81b\\ude7a","93787":"\\ud81b\\ude7b","93788":"\\ud81b\\ude7c","93789":"\\ud81b\\ude7d","93790":"\\ud81b\\ude7e","93791":"\\ud81b\\ude7f","125184":"\\ud83a\\udd22","125185":"\\ud83a\\udd23","125186":"\\ud83a\\udd24","125187":"\\ud83a\\udd25","125188":"\\ud83a\\udd26","125189":"\\ud83a\\udd27","125190":"\\ud83a\\udd28","125191":"\\ud83a\\udd29"',
3757
+ ',"125192":"\\ud83a\\udd2a","125193":"\\ud83a\\udd2b","125194":"\\ud83a\\udd2c","125195":"\\ud83a\\udd2d","125196":"\\ud83a\\udd2e","125197":"\\ud83a\\udd2f","125198":"\\ud83a\\udd30","125199":"\\ud83a\\udd31","125200":"\\ud83a\\udd32","125201":"\\ud83a\\udd33","125202":"\\ud83a\\udd34","125203":"\\ud83a\\udd35","125204":"\\ud83a\\udd36","125205":"\\ud83a\\udd37","125206":"\\ud83a\\udd38","125207":"\\ud83a\\udd39","125208":"\\ud83a\\udd3a","125209":"\\ud83a\\udd3b","125210":"\\ud83a\\udd3c","125211":"\\ud83a\\udd3d","125212":"\\ud83a\\udd3e","125213":"\\ud83a\\udd3f","125214":"\\ud83a\\udd40","125215":"\\ud83a\\udd41","125216":"\\ud83a\\udd42","125217":"\\ud83a\\udd43","223":"\\u00df","64256":"\\ufb00","64257":"\\ufb01","64258":"\\ufb02","64259":"\\ufb03","64260":"\\ufb04","64261":"\\ufb05","64262":"\\ufb06","1415":"\\u0587","64275":"\\ufb13","64276":"\\ufb14","64277":"\\ufb15","64278":"\\ufb16","64279":"\\ufb17","329":"\\u0149","912":"\\u0390","944":"\\u03b0","496":"\\u01f0","7830":"\\u1e96","7831":"\\u1e97","7832":"\\u1e98","7833":"\\u1e99","7834":"\\u1e9a","8016":"\\u1f50","8018":"\\u1f52","8020":"\\u1f54","8022":"\\u1f56","8118":"\\u1fb6","8134":"\\u1fc6","8146":"\\u1fd2","8147":"\\u1fd3","8150":"\\u1fd6","8151":"\\u1fd7","8162":"\\u1fe2","8163":"\\u1fe3","8164":"\\u1fe4","8166":"\\u1fe6","8167":"\\u1fe7","8182":"\\u1ff6","8064":"\\u1f80","8065":"\\u1f81","8066":"\\u1f82","8067":"\\u1f83","8068":"\\u1f84","8069":"\\u1f85","8070":"\\u1f86","8071":"\\u1f87","8080":"\\u1f90","8081":"\\u1f91","8082":"\\u1f92","8083":"\\u1f93","8084":"\\u1f94","8085":"\\u1f95","8086":"\\u1f96","8087":"\\u1f97","8096":"\\u1fa0","8097":"\\u1fa1","8098":"\\u1fa2","8099":"\\u1fa3","8100":"\\u1fa4","8101":"\\u1fa5","8102":"\\u1fa6","8103":"\\u1fa7","8115":"\\u1fb3","8131":"\\u1fc3","8179":"\\u1ff3","8114":"\\u1fb2","8116":"\\u1fb4","8130":"\\u1fc2","8132":"\\u1fc4","8178":"\\u1ff2","8180":"\\u1ff4","8119":"\\u1fb7","8135":"\\u1fc7","8183":"\\u1ff7"},"upper":{"97":"A","98":"B","99":"C","100":"D","101":"E","102":"F","103":"G","104":"H","105":"I","106":"J","107":"K","108":"L","109":"M","110":"N","111":"O","112":"P","113":"Q","114":"R","115":"S","116":"T","117":"U","118":"V","119":"W","120":"X","121":"Y","122":"Z","181":"\\u039c","224":"\\u00c0","225":"\\u00c1","226":"\\u00c2","227":"\\u00c3","228":"\\u00c4","229":"\\u00c5","230":"\\u00c6","231":"\\u00c7","232":"\\u00c8","233":"\\u00c9","234":"\\u00ca","235":"\\u00cb","236":"\\u00cc","237":"\\u00cd","238":"\\u00ce","239":"\\u00cf","240":"\\u00d0","241":"\\u00d1","242":"\\u00d2","243":"\\u00d3","244":"\\u00d4","245":"\\u00d5","246":"\\u00d6","248":"\\u00d8","249":"\\u00d9","250":"\\u00da","251":"\\u00db","252":"\\u00dc","253":"\\u00dd","254":"\\u00de","255":"\\u0178","257":"\\u0100","259":"\\u0102","261":"\\u0104","263":"\\u0106","265":"\\u0108","267":"\\u010a","269":"\\u010c","271":"\\u010e","273":"\\u0110","275":"\\u0112","277":"\\u0114","279":"\\u0116","281":"\\u0118","283":"\\u011a","285":"\\u011c","287":"\\u011e","289":"\\u0120","291":"\\u0122","293":"\\u0124","295":"\\u0126","297":"\\u0128","299":"\\u012a","301":"\\u012c","303":"\\u012e","305":"I","307":"\\u0132","309":"\\u0134","311":"\\u0136","314":',
3758
+ '"\\u0139","316":"\\u013b","318":"\\u013d","320":"\\u013f","322":"\\u0141","324":"\\u0143","326":"\\u0145","328":"\\u0147","331":"\\u014a","333":"\\u014c","335":"\\u014e","337":"\\u0150","339":"\\u0152","341":"\\u0154","343":"\\u0156","345":"\\u0158","347":"\\u015a","349":"\\u015c","351":"\\u015e","353":"\\u0160","355":"\\u0162","357":"\\u0164","359":"\\u0166","361":"\\u0168","363":"\\u016a","365":"\\u016c","367":"\\u016e","369":"\\u0170","371":"\\u0172","373":"\\u0174","375":"\\u0176","378":"\\u0179","380":"\\u017b","382":"\\u017d","383":"S","384":"\\u0243","387":"\\u0182","389":"\\u0184","392":"\\u0187","396":"\\u018b","402":"\\u0191","405":"\\u01f6","409":"\\u0198","410":"\\u023d","414":"\\u0220","417":"\\u01a0","419":"\\u01a2","421":"\\u01a4","424":"\\u01a7","429":"\\u01ac","432":"\\u01af","436":"\\u01b3","438":"\\u01b5","441":"\\u01b8","445":"\\u01bc","447":"\\u01f7","453":"\\u01c4","454":"\\u01c4","456":"\\u01c7","457":"\\u01c7","459":"\\u01ca","460":"\\u01ca","462":"\\u01cd","464":"\\u01cf","466":"\\u01d1","468":"\\u01d3","470":"\\u01d5","472":"\\u01d7","474":"\\u01d9","476":"\\u01db","477":"\\u018e","479":"\\u01de","481":"\\u01e0","483":"\\u01e2","485":"\\u01e4","487":"\\u01e6","489":"\\u01e8","491":"\\u01ea","493":"\\u01ec","495":"\\u01ee","498":"\\u01f1","499":"\\u01f1","501":"\\u01f4","505":"\\u01f8","507":"\\u01fa","509":"\\u01fc","511":"\\u01fe","513":"\\u0200","515":"\\u0202","517":"\\u0204","519":"\\u0206","521":"\\u0208","523":"\\u020a","525":"\\u020c","527":"\\u020e","529":"\\u0210","531":"\\u0212","533":"\\u0214","535":"\\u0216","537":"\\u0218","539":"\\u021a","541":"\\u021c","543":"\\u021e","547":"\\u0222","549":"\\u0224","551":"\\u0226","553":"\\u0228","555":"\\u022a","557":"\\u022c","559":"\\u022e","561":"\\u0230","563":"\\u0232","572":"\\u023b","575":"\\u2c7e","576":"\\u2c7f","578":"\\u0241","583":"\\u0246","585":"\\u0248","587":"\\u024a","589":"\\u024c","591":"\\u024e","592":"\\u2c6f","593":"\\u2c6d","594":"\\u2c70","595":"\\u0181","596":"\\u0186","598":"\\u0189","599":"\\u018a","601":"\\u018f","603":"\\u0190","604":"\\ua7ab","608":"\\u0193","609":"\\ua7ac","611":"\\u0194","613":"\\ua78d","614":"\\ua7aa","616":"\\u0197","617":"\\u0196","618":"\\ua7ae","619":"\\u2c62","620":"\\ua7ad","623":"\\u019c","625":"\\u2c6e","626":"\\u019d","629":"\\u019f","637":"\\u2c64","640":"\\u01a6","642":"\\ua7c5","643":"\\u01a9","647":"\\ua7b1","648":"\\u01ae","649":"\\u0244","650":"\\u01b1","651":"\\u01b2","652":"\\u0245","658":"\\u01b7","669":"\\ua7b2","670":"\\ua7b0","837":"\\u0399","881":"\\u0370","883":"\\u0372","887":"\\u0376","891":"\\u03fd","892":"\\u03fe","893":"\\u03ff","940":"\\u0386","941":"\\u0388","942":"\\u0389","943":"\\u038a","945":"\\u0391","946":"\\u0392","947":"\\u0393","948":"\\u0394","949":"\\u0395","950":"\\u0396","951":"\\u0397","952":"\\u0398","953":"\\u0399","954":"\\u039a","955":"\\u039b","956":"\\u039c","957":"\\u039d","958":"\\u039e","959":"\\u039f","960":"\\u03a0","961":"\\u03a1","962":"\\u03a3","963":"\\u03a3","964":"\\u03a4","965":"\\u03a5","966":"\\u03a6","967":"\\u03a7","968":"\\u03a8","969":"\\u03a9","970":"\\u03aa","971":"\\u03ab","972":"\\u038c","973":"\\u038e","974":"\\u038f","976":"\\u0392","977":"\\u03',
3759
+ '98","981":"\\u03a6","982":"\\u03a0","983":"\\u03cf","985":"\\u03d8","987":"\\u03da","989":"\\u03dc","991":"\\u03de","993":"\\u03e0","995":"\\u03e2","997":"\\u03e4","999":"\\u03e6","1001":"\\u03e8","1003":"\\u03ea","1005":"\\u03ec","1007":"\\u03ee","1008":"\\u039a","1009":"\\u03a1","1010":"\\u03f9","1011":"\\u037f","1013":"\\u0395","1016":"\\u03f7","1019":"\\u03fa","1072":"\\u0410","1073":"\\u0411","1074":"\\u0412","1075":"\\u0413","1076":"\\u0414","1077":"\\u0415","1078":"\\u0416","1079":"\\u0417","1080":"\\u0418","1081":"\\u0419","1082":"\\u041a","1083":"\\u041b","1084":"\\u041c","1085":"\\u041d","1086":"\\u041e","1087":"\\u041f","1088":"\\u0420","1089":"\\u0421","1090":"\\u0422","1091":"\\u0423","1092":"\\u0424","1093":"\\u0425","1094":"\\u0426","1095":"\\u0427","1096":"\\u0428","1097":"\\u0429","1098":"\\u042a","1099":"\\u042b","1100":"\\u042c","1101":"\\u042d","1102":"\\u042e","1103":"\\u042f","1104":"\\u0400","1105":"\\u0401","1106":"\\u0402","1107":"\\u0403","1108":"\\u0404","1109":"\\u0405","1110":"\\u0406","1111":"\\u0407","1112":"\\u0408","1113":"\\u0409","1114":"\\u040a","1115":"\\u040b","1116":"\\u040c","1117":"\\u040d","1118":"\\u040e","1119":"\\u040f","1121":"\\u0460","1123":"\\u0462","1125":"\\u0464","1127":"\\u0466","1129":"\\u0468","1131":"\\u046a","1133":"\\u046c","1135":"\\u046e","1137":"\\u0470","1139":"\\u0472","1141":"\\u0474","1143":"\\u0476","1145":"\\u0478","1147":"\\u047a","1149":"\\u047c","1151":"\\u047e","1153":"\\u0480","1163":"\\u048a","1165":"\\u048c","1167":"\\u048e","1169":"\\u0490","1171":"\\u0492","1173":"\\u0494","1175":"\\u0496","1177":"\\u0498","1179":"\\u049a","1181":"\\u049c","1183":"\\u049e","1185":"\\u04a0","1187":"\\u04a2","1189":"\\u04a4","1191":"\\u04a6","1193":"\\u04a8","1195":"\\u04aa","1197":"\\u04ac","1199":"\\u04ae","1201":"\\u04b0","1203":"\\u04b2","1205":"\\u04b4","1207":"\\u04b6","1209":"\\u04b8","1211":"\\u04ba","1213":"\\u04bc","1215":"\\u04be","1218":"\\u04c1","1220":"\\u04c3","1222":"\\u04c5","1224":"\\u04c7","1226":"\\u04c9","1228":"\\u04cb","1230":"\\u04cd","1231":"\\u04c0","1233":"\\u04d0","1235":"\\u04d2","1237":"\\u04d4","1239":"\\u04d6","1241":"\\u04d8","1243":"\\u04da","1245":"\\u04dc","1247":"\\u04de","1249":"\\u04e0","1251":"\\u04e2","1253":"\\u04e4","1255":"\\u04e6","1257":"\\u04e8","1259":"\\u04ea","1261":"\\u04ec","1263":"\\u04ee","1265":"\\u04f0","1267":"\\u04f2","1269":"\\u04f4","1271":"\\u04f6","1273":"\\u04f8","1275":"\\u04fa","1277":"\\u04fc","1279":"\\u04fe","1281":"\\u0500","1283":"\\u0502","1285":"\\u0504","1287":"\\u0506","1289":"\\u0508","1291":"\\u050a","1293":"\\u050c","1295":"\\u050e","1297":"\\u0510","1299":"\\u0512","1301":"\\u0514","1303":"\\u0516","1305":"\\u0518","1307":"\\u051a","1309":"\\u051c","1311":"\\u051e","1313":"\\u0520","1315":"\\u0522","1317":"\\u0524","1319":"\\u0526","1321":"\\u0528","1323":"\\u052a","1325":"\\u052c","1327":"\\u052e","1377":"\\u0531","1378":"\\u0532","1379":"\\u0533","1380":"\\u0534","1381":"\\u0535","1382":"\\u0536","1383":"\\u0537","1384":"\\u0538","1385":"\\u0539","1386":"\\u053a","1387":"\\u053b","1388":"\\u053c","1389":"\\u053d","1390":"\\u053e","1391":"\\u053f","1392":"\\u0540","1393":"\\u0541","1394":"\\u0542"',
3760
+ ',"1395":"\\u0543","1396":"\\u0544","1397":"\\u0545","1398":"\\u0546","1399":"\\u0547","1400":"\\u0548","1401":"\\u0549","1402":"\\u054a","1403":"\\u054b","1404":"\\u054c","1405":"\\u054d","1406":"\\u054e","1407":"\\u054f","1408":"\\u0550","1409":"\\u0551","1410":"\\u0552","1411":"\\u0553","1412":"\\u0554","1413":"\\u0555","1414":"\\u0556","4304":"\\u1c90","4305":"\\u1c91","4306":"\\u1c92","4307":"\\u1c93","4308":"\\u1c94","4309":"\\u1c95","4310":"\\u1c96","4311":"\\u1c97","4312":"\\u1c98","4313":"\\u1c99","4314":"\\u1c9a","4315":"\\u1c9b","4316":"\\u1c9c","4317":"\\u1c9d","4318":"\\u1c9e","4319":"\\u1c9f","4320":"\\u1ca0","4321":"\\u1ca1","4322":"\\u1ca2","4323":"\\u1ca3","4324":"\\u1ca4","4325":"\\u1ca5","4326":"\\u1ca6","4327":"\\u1ca7","4328":"\\u1ca8","4329":"\\u1ca9","4330":"\\u1caa","4331":"\\u1cab","4332":"\\u1cac","4333":"\\u1cad","4334":"\\u1cae","4335":"\\u1caf","4336":"\\u1cb0","4337":"\\u1cb1","4338":"\\u1cb2","4339":"\\u1cb3","4340":"\\u1cb4","4341":"\\u1cb5","4342":"\\u1cb6","4343":"\\u1cb7","4344":"\\u1cb8","4345":"\\u1cb9","4346":"\\u1cba","4349":"\\u1cbd","4350":"\\u1cbe","4351":"\\u1cbf","5112":"\\u13f0","5113":"\\u13f1","5114":"\\u13f2","5115":"\\u13f3","5116":"\\u13f4","5117":"\\u13f5","7296":"\\u0412","7297":"\\u0414","7298":"\\u041e","7299":"\\u0421","7300":"\\u0422","7301":"\\u0422","7302":"\\u042a","7303":"\\u0462","7304":"\\ua64a","7545":"\\ua77d","7549":"\\u2c63","7566":"\\ua7c6","7681":"\\u1e00","7683":"\\u1e02","7685":"\\u1e04","7687":"\\u1e06","7689":"\\u1e08","7691":"\\u1e0a","7693":"\\u1e0c","7695":"\\u1e0e","7697":"\\u1e10","7699":"\\u1e12","7701":"\\u1e14","7703":"\\u1e16","7705":"\\u1e18","7707":"\\u1e1a","7709":"\\u1e1c","7711":"\\u1e1e","7713":"\\u1e20","7715":"\\u1e22","7717":"\\u1e24","7719":"\\u1e26","7721":"\\u1e28","7723":"\\u1e2a","7725":"\\u1e2c","7727":"\\u1e2e","7729":"\\u1e30","7731":"\\u1e32","7733":"\\u1e34","7735":"\\u1e36","7737":"\\u1e38","7739":"\\u1e3a","7741":"\\u1e3c","7743":"\\u1e3e","7745":"\\u1e40","7747":"\\u1e42","7749":"\\u1e44","7751":"\\u1e46","7753":"\\u1e48","7755":"\\u1e4a","7757":"\\u1e4c","7759":"\\u1e4e","7761":"\\u1e50","7763":"\\u1e52","7765":"\\u1e54","7767":"\\u1e56","7769":"\\u1e58","7771":"\\u1e5a","7773":"\\u1e5c","7775":"\\u1e5e","7777":"\\u1e60","7779":"\\u1e62","7781":"\\u1e64","7783":"\\u1e66","7785":"\\u1e68","7787":"\\u1e6a","7789":"\\u1e6c","7791":"\\u1e6e","7793":"\\u1e70","7795":"\\u1e72","7797":"\\u1e74","7799":"\\u1e76","7801":"\\u1e78","7803":"\\u1e7a","7805":"\\u1e7c","7807":"\\u1e7e","7809":"\\u1e80","7811":"\\u1e82","7813":"\\u1e84","7815":"\\u1e86","7817":"\\u1e88","7819":"\\u1e8a","7821":"\\u1e8c","7823":"\\u1e8e","7825":"\\u1e90","7827":"\\u1e92","7829":"\\u1e94","7835":"\\u1e60","7841":"\\u1ea0","7843":"\\u1ea2","7845":"\\u1ea4","7847":"\\u1ea6","7849":"\\u1ea8","7851":"\\u1eaa","7853":"\\u1eac","7855":"\\u1eae","7857":"\\u1eb0","7859":"\\u1eb2","7861":"\\u1eb4","7863":"\\u1eb6","7865":"\\u1eb8","7867":"\\u1eba","7869":"\\u1ebc","7871":"\\u1ebe","7873":"\\u1ec0","7875":"\\u1ec2","7877":"\\u1ec4","7879":"\\u1ec6","7881":"\\u1ec8","7883":"\\u1eca","7885":"\\u1ecc","7887":"\\u1ece","7889":"\\u1ed0","7891":"\\u1ed2","7893":"\\u1ed4","7895":',
3761
+ '"\\u1ed6","7897":"\\u1ed8","7899":"\\u1eda","7901":"\\u1edc","7903":"\\u1ede","7905":"\\u1ee0","7907":"\\u1ee2","7909":"\\u1ee4","7911":"\\u1ee6","7913":"\\u1ee8","7915":"\\u1eea","7917":"\\u1eec","7919":"\\u1eee","7921":"\\u1ef0","7923":"\\u1ef2","7925":"\\u1ef4","7927":"\\u1ef6","7929":"\\u1ef8","7931":"\\u1efa","7933":"\\u1efc","7935":"\\u1efe","7936":"\\u1f08","7937":"\\u1f09","7938":"\\u1f0a","7939":"\\u1f0b","7940":"\\u1f0c","7941":"\\u1f0d","7942":"\\u1f0e","7943":"\\u1f0f","7952":"\\u1f18","7953":"\\u1f19","7954":"\\u1f1a","7955":"\\u1f1b","7956":"\\u1f1c","7957":"\\u1f1d","7968":"\\u1f28","7969":"\\u1f29","7970":"\\u1f2a","7971":"\\u1f2b","7972":"\\u1f2c","7973":"\\u1f2d","7974":"\\u1f2e","7975":"\\u1f2f","7984":"\\u1f38","7985":"\\u1f39","7986":"\\u1f3a","7987":"\\u1f3b","7988":"\\u1f3c","7989":"\\u1f3d","7990":"\\u1f3e","7991":"\\u1f3f","8000":"\\u1f48","8001":"\\u1f49","8002":"\\u1f4a","8003":"\\u1f4b","8004":"\\u1f4c","8005":"\\u1f4d","8017":"\\u1f59","8019":"\\u1f5b","8021":"\\u1f5d","8023":"\\u1f5f","8032":"\\u1f68","8033":"\\u1f69","8034":"\\u1f6a","8035":"\\u1f6b","8036":"\\u1f6c","8037":"\\u1f6d","8038":"\\u1f6e","8039":"\\u1f6f","8048":"\\u1fba","8049":"\\u1fbb","8050":"\\u1fc8","8051":"\\u1fc9","8052":"\\u1fca","8053":"\\u1fcb","8054":"\\u1fda","8055":"\\u1fdb","8056":"\\u1ff8","8057":"\\u1ff9","8058":"\\u1fea","8059":"\\u1feb","8060":"\\u1ffa","8061":"\\u1ffb","8064":"\\u1f08\\u0399","8065":"\\u1f09\\u0399","8066":"\\u1f0a\\u0399","8067":"\\u1f0b\\u0399","8068":"\\u1f0c\\u0399","8069":"\\u1f0d\\u0399","8070":"\\u1f0e\\u0399","8071":"\\u1f0f\\u0399","8080":"\\u1f28\\u0399","8081":"\\u1f29\\u0399","8082":"\\u1f2a\\u0399","8083":"\\u1f2b\\u0399","8084":"\\u1f2c\\u0399","8085":"\\u1f2d\\u0399","8086":"\\u1f2e\\u0399","8087":"\\u1f2f\\u0399","8096":"\\u1f68\\u0399","8097":"\\u1f69\\u0399","8098":"\\u1f6a\\u0399","8099":"\\u1f6b\\u0399","8100":"\\u1f6c\\u0399","8101":"\\u1f6d\\u0399","8102":"\\u1f6e\\u0399","8103":"\\u1f6f\\u0399","8112":"\\u1fb8","8113":"\\u1fb9","8115":"\\u0391\\u0399","8126":"\\u0399","8131":"\\u0397\\u0399","8144":"\\u1fd8","8145":"\\u1fd9","8160":"\\u1fe8","8161":"\\u1fe9","8165":"\\u1fec","8179":"\\u03a9\\u0399","8526":"\\u2132","8560":"\\u2160","8561":"\\u2161","8562":"\\u2162","8563":"\\u2163","8564":"\\u2164","8565":"\\u2165","8566":"\\u2166","8567":"\\u2167","8568":"\\u2168","8569":"\\u2169","8570":"\\u216a","8571":"\\u216b","8572":"\\u216c","8573":"\\u216d","8574":"\\u216e","8575":"\\u216f","8580":"\\u2183","9424":"\\u24b6","9425":"\\u24b7","9426":"\\u24b8","9427":"\\u24b9","9428":"\\u24ba","9429":"\\u24bb","9430":"\\u24bc","9431":"\\u24bd","9432":"\\u24be","9433":"\\u24bf","9434":"\\u24c0","9435":"\\u24c1","9436":"\\u24c2","9437":"\\u24c3","9438":"\\u24c4","9439":"\\u24c5","9440":"\\u24c6","9441":"\\u24c7","9442":"\\u24c8","9443":"\\u24c9","9444":"\\u24ca","9445":"\\u24cb","9446":"\\u24cc","9447":"\\u24cd","9448":"\\u24ce","9449":"\\u24cf","11312":"\\u2c00","11313":"\\u2c01","11314":"\\u2c02","11315":"\\u2c03","11316":"\\u2c04","11317":"\\u2c05","11318":"\\u2c06","11319":"\\u2c07","11320":"\\u2c08","11321":"\\u2c09","11322":"\\u2c0a","11323":"\\u2c0b","11324":"\\u2c0c","11325":"\\u2c0d","11326":"\\u2c0e',
3762
+ '","11327":"\\u2c0f","11328":"\\u2c10","11329":"\\u2c11","11330":"\\u2c12","11331":"\\u2c13","11332":"\\u2c14","11333":"\\u2c15","11334":"\\u2c16","11335":"\\u2c17","11336":"\\u2c18","11337":"\\u2c19","11338":"\\u2c1a","11339":"\\u2c1b","11340":"\\u2c1c","11341":"\\u2c1d","11342":"\\u2c1e","11343":"\\u2c1f","11344":"\\u2c20","11345":"\\u2c21","11346":"\\u2c22","11347":"\\u2c23","11348":"\\u2c24","11349":"\\u2c25","11350":"\\u2c26","11351":"\\u2c27","11352":"\\u2c28","11353":"\\u2c29","11354":"\\u2c2a","11355":"\\u2c2b","11356":"\\u2c2c","11357":"\\u2c2d","11358":"\\u2c2e","11359":"\\u2c2f","11361":"\\u2c60","11365":"\\u023a","11366":"\\u023e","11368":"\\u2c67","11370":"\\u2c69","11372":"\\u2c6b","11379":"\\u2c72","11382":"\\u2c75","11393":"\\u2c80","11395":"\\u2c82","11397":"\\u2c84","11399":"\\u2c86","11401":"\\u2c88","11403":"\\u2c8a","11405":"\\u2c8c","11407":"\\u2c8e","11409":"\\u2c90","11411":"\\u2c92","11413":"\\u2c94","11415":"\\u2c96","11417":"\\u2c98","11419":"\\u2c9a","11421":"\\u2c9c","11423":"\\u2c9e","11425":"\\u2ca0","11427":"\\u2ca2","11429":"\\u2ca4","11431":"\\u2ca6","11433":"\\u2ca8","11435":"\\u2caa","11437":"\\u2cac","11439":"\\u2cae","11441":"\\u2cb0","11443":"\\u2cb2","11445":"\\u2cb4","11447":"\\u2cb6","11449":"\\u2cb8","11451":"\\u2cba","11453":"\\u2cbc","11455":"\\u2cbe","11457":"\\u2cc0","11459":"\\u2cc2","11461":"\\u2cc4","11463":"\\u2cc6","11465":"\\u2cc8","11467":"\\u2cca","11469":"\\u2ccc","11471":"\\u2cce","11473":"\\u2cd0","11475":"\\u2cd2","11477":"\\u2cd4","11479":"\\u2cd6","11481":"\\u2cd8","11483":"\\u2cda","11485":"\\u2cdc","11487":"\\u2cde","11489":"\\u2ce0","11491":"\\u2ce2","11500":"\\u2ceb","11502":"\\u2ced","11507":"\\u2cf2","11520":"\\u10a0","11521":"\\u10a1","11522":"\\u10a2","11523":"\\u10a3","11524":"\\u10a4","11525":"\\u10a5","11526":"\\u10a6","11527":"\\u10a7","11528":"\\u10a8","11529":"\\u10a9","11530":"\\u10aa","11531":"\\u10ab","11532":"\\u10ac","11533":"\\u10ad","11534":"\\u10ae","11535":"\\u10af","11536":"\\u10b0","11537":"\\u10b1","11538":"\\u10b2","11539":"\\u10b3","11540":"\\u10b4","11541":"\\u10b5","11542":"\\u10b6","11543":"\\u10b7","11544":"\\u10b8","11545":"\\u10b9","11546":"\\u10ba","11547":"\\u10bb","11548":"\\u10bc","11549":"\\u10bd","11550":"\\u10be","11551":"\\u10bf","11552":"\\u10c0","11553":"\\u10c1","11554":"\\u10c2","11555":"\\u10c3","11556":"\\u10c4","11557":"\\u10c5","11559":"\\u10c7","11565":"\\u10cd","42561":"\\ua640","42563":"\\ua642","42565":"\\ua644","42567":"\\ua646","42569":"\\ua648","42571":"\\ua64a","42573":"\\ua64c","42575":"\\ua64e","42577":"\\ua650","42579":"\\ua652","42581":"\\ua654","42583":"\\ua656","42585":"\\ua658","42587":"\\ua65a","42589":"\\ua65c","42591":"\\ua65e","42593":"\\ua660","42595":"\\ua662","42597":"\\ua664","42599":"\\ua666","42601":"\\ua668","42603":"\\ua66a","42605":"\\ua66c","42625":"\\ua680","42627":"\\ua682","42629":"\\ua684","42631":"\\ua686","42633":"\\ua688","42635":"\\ua68a","42637":"\\ua68c","42639":"\\ua68e","42641":"\\ua690","42643":"\\ua692","42645":"\\ua694","42647":"\\ua696","42649":"\\ua698","42651":"\\ua69a","42787":"\\ua722","42789":"\\ua724","42791":"\\ua726","42793":"\\ua728","42795":"\\ua72a","42797',
3763
+ '":"\\ua72c","42799":"\\ua72e","42803":"\\ua732","42805":"\\ua734","42807":"\\ua736","42809":"\\ua738","42811":"\\ua73a","42813":"\\ua73c","42815":"\\ua73e","42817":"\\ua740","42819":"\\ua742","42821":"\\ua744","42823":"\\ua746","42825":"\\ua748","42827":"\\ua74a","42829":"\\ua74c","42831":"\\ua74e","42833":"\\ua750","42835":"\\ua752","42837":"\\ua754","42839":"\\ua756","42841":"\\ua758","42843":"\\ua75a","42845":"\\ua75c","42847":"\\ua75e","42849":"\\ua760","42851":"\\ua762","42853":"\\ua764","42855":"\\ua766","42857":"\\ua768","42859":"\\ua76a","42861":"\\ua76c","42863":"\\ua76e","42874":"\\ua779","42876":"\\ua77b","42879":"\\ua77e","42881":"\\ua780","42883":"\\ua782","42885":"\\ua784","42887":"\\ua786","42892":"\\ua78b","42897":"\\ua790","42899":"\\ua792","42900":"\\ua7c4","42903":"\\ua796","42905":"\\ua798","42907":"\\ua79a","42909":"\\ua79c","42911":"\\ua79e","42913":"\\ua7a0","42915":"\\ua7a2","42917":"\\ua7a4","42919":"\\ua7a6","42921":"\\ua7a8","42933":"\\ua7b4","42935":"\\ua7b6","42937":"\\ua7b8","42939":"\\ua7ba","42941":"\\ua7bc","42943":"\\ua7be","42945":"\\ua7c0","42947":"\\ua7c2","42952":"\\ua7c7","42954":"\\ua7c9","42961":"\\ua7d0","42967":"\\ua7d6","42969":"\\ua7d8","42998":"\\ua7f5","43859":"\\ua7b3","43888":"\\u13a0","43889":"\\u13a1","43890":"\\u13a2","43891":"\\u13a3","43892":"\\u13a4","43893":"\\u13a5","43894":"\\u13a6","43895":"\\u13a7","43896":"\\u13a8","43897":"\\u13a9","43898":"\\u13aa","43899":"\\u13ab","43900":"\\u13ac","43901":"\\u13ad","43902":"\\u13ae","43903":"\\u13af","43904":"\\u13b0","43905":"\\u13b1","43906":"\\u13b2","43907":"\\u13b3","43908":"\\u13b4","43909":"\\u13b5","43910":"\\u13b6","43911":"\\u13b7","43912":"\\u13b8","43913":"\\u13b9","43914":"\\u13ba","43915":"\\u13bb","43916":"\\u13bc","43917":"\\u13bd","43918":"\\u13be","43919":"\\u13bf","43920":"\\u13c0","43921":"\\u13c1","43922":"\\u13c2","43923":"\\u13c3","43924":"\\u13c4","43925":"\\u13c5","43926":"\\u13c6","43927":"\\u13c7","43928":"\\u13c8","43929":"\\u13c9","43930":"\\u13ca","43931":"\\u13cb","43932":"\\u13cc","43933":"\\u13cd","43934":"\\u13ce","43935":"\\u13cf","43936":"\\u13d0","43937":"\\u13d1","43938":"\\u13d2","43939":"\\u13d3","43940":"\\u13d4","43941":"\\u13d5","43942":"\\u13d6","43943":"\\u13d7","43944":"\\u13d8","43945":"\\u13d9","43946":"\\u13da","43947":"\\u13db","43948":"\\u13dc","43949":"\\u13dd","43950":"\\u13de","43951":"\\u13df","43952":"\\u13e0","43953":"\\u13e1","43954":"\\u13e2","43955":"\\u13e3","43956":"\\u13e4","43957":"\\u13e5","43958":"\\u13e6","43959":"\\u13e7","43960":"\\u13e8","43961":"\\u13e9","43962":"\\u13ea","43963":"\\u13eb","43964":"\\u13ec","43965":"\\u13ed","43966":"\\u13ee","43967":"\\u13ef","65345":"\\uff21","65346":"\\uff22","65347":"\\uff23","65348":"\\uff24","65349":"\\uff25","65350":"\\uff26","65351":"\\uff27","65352":"\\uff28","65353":"\\uff29","65354":"\\uff2a","65355":"\\uff2b","65356":"\\uff2c","65357":"\\uff2d","65358":"\\uff2e","65359":"\\uff2f","65360":"\\uff30","65361":"\\uff31","65362":"\\uff32","65363":"\\uff33","65364":"\\uff34","65365":"\\uff35","65366":"\\uff36","65367":"\\uff37","65368":"\\uff38","65369":"\\uff39","65370":"\\uff3a","66600":"\\ud801\\udc00","66601":',
3764
+ '"\\ud801\\udc01","66602":"\\ud801\\udc02","66603":"\\ud801\\udc03","66604":"\\ud801\\udc04","66605":"\\ud801\\udc05","66606":"\\ud801\\udc06","66607":"\\ud801\\udc07","66608":"\\ud801\\udc08","66609":"\\ud801\\udc09","66610":"\\ud801\\udc0a","66611":"\\ud801\\udc0b","66612":"\\ud801\\udc0c","66613":"\\ud801\\udc0d","66614":"\\ud801\\udc0e","66615":"\\ud801\\udc0f","66616":"\\ud801\\udc10","66617":"\\ud801\\udc11","66618":"\\ud801\\udc12","66619":"\\ud801\\udc13","66620":"\\ud801\\udc14","66621":"\\ud801\\udc15","66622":"\\ud801\\udc16","66623":"\\ud801\\udc17","66624":"\\ud801\\udc18","66625":"\\ud801\\udc19","66626":"\\ud801\\udc1a","66627":"\\ud801\\udc1b","66628":"\\ud801\\udc1c","66629":"\\ud801\\udc1d","66630":"\\ud801\\udc1e","66631":"\\ud801\\udc1f","66632":"\\ud801\\udc20","66633":"\\ud801\\udc21","66634":"\\ud801\\udc22","66635":"\\ud801\\udc23","66636":"\\ud801\\udc24","66637":"\\ud801\\udc25","66638":"\\ud801\\udc26","66639":"\\ud801\\udc27","66776":"\\ud801\\udcb0","66777":"\\ud801\\udcb1","66778":"\\ud801\\udcb2","66779":"\\ud801\\udcb3","66780":"\\ud801\\udcb4","66781":"\\ud801\\udcb5","66782":"\\ud801\\udcb6","66783":"\\ud801\\udcb7","66784":"\\ud801\\udcb8","66785":"\\ud801\\udcb9","66786":"\\ud801\\udcba","66787":"\\ud801\\udcbb","66788":"\\ud801\\udcbc","66789":"\\ud801\\udcbd","66790":"\\ud801\\udcbe","66791":"\\ud801\\udcbf","66792":"\\ud801\\udcc0","66793":"\\ud801\\udcc1","66794":"\\ud801\\udcc2","66795":"\\ud801\\udcc3","66796":"\\ud801\\udcc4","66797":"\\ud801\\udcc5","66798":"\\ud801\\udcc6","66799":"\\ud801\\udcc7","66800":"\\ud801\\udcc8","66801":"\\ud801\\udcc9","66802":"\\ud801\\udcca","66803":"\\ud801\\udccb","66804":"\\ud801\\udccc","66805":"\\ud801\\udccd","66806":"\\ud801\\udcce","66807":"\\ud801\\udccf","66808":"\\ud801\\udcd0","66809":"\\ud801\\udcd1","66810":"\\ud801\\udcd2","66811":"\\ud801\\udcd3","66967":"\\ud801\\udd70","66968":"\\ud801\\udd71","66969":"\\ud801\\udd72","66970":"\\ud801\\udd73","66971":"\\ud801\\udd74","66972":"\\ud801\\udd75","66973":"\\ud801\\udd76","66974":"\\ud801\\udd77","66975":"\\ud801\\udd78","66976":"\\ud801\\udd79","66977":"\\ud801\\udd7a","66979":"\\ud801\\udd7c","66980":"\\ud801\\udd7d","66981":"\\ud801\\udd7e","66982":"\\ud801\\udd7f","66983":"\\ud801\\udd80","66984":"\\ud801\\udd81","66985":"\\ud801\\udd82","66986":"\\ud801\\udd83","66987":"\\ud801\\udd84","66988":"\\ud801\\udd85","66989":"\\ud801\\udd86","66990":"\\ud801\\udd87","66991":"\\ud801\\udd88","66992":"\\ud801\\udd89","66993":"\\ud801\\udd8a","66995":"\\ud801\\udd8c","66996":"\\ud801\\udd8d","66997":"\\ud801\\udd8e","66998":"\\ud801\\udd8f","66999":"\\ud801\\udd90","67000":"\\ud801\\udd91","67001":"\\ud801\\udd92","67003":"\\ud801\\udd94","67004":"\\ud801\\udd95","68800":"\\ud803\\udc80","68801":"\\ud803\\udc81","68802":"\\ud803\\udc82","68803":"\\ud803\\udc83","68804":"\\ud803\\udc84","68805":"\\ud803\\udc85","68806":"\\ud803\\udc86","68807":"\\ud803\\udc87","68808":"\\ud803\\udc88","68809":"\\ud803\\udc89","68810":"\\ud803\\udc8a","68811":"\\ud803\\udc8b","68812":"\\ud803\\udc8c","68813":"\\ud803\\udc8d","68814":"\\ud803\\udc8e","68815":"\\ud803\\udc8f","68816":"\\ud803\\udc90","68817":"\\ud803\\udc91","68818":"\\ud803\\udc92","68819":"\\ud803\\udc93","68820":"\\ud803\\ud',
3765
+ 'c94","68821":"\\ud803\\udc95","68822":"\\ud803\\udc96","68823":"\\ud803\\udc97","68824":"\\ud803\\udc98","68825":"\\ud803\\udc99","68826":"\\ud803\\udc9a","68827":"\\ud803\\udc9b","68828":"\\ud803\\udc9c","68829":"\\ud803\\udc9d","68830":"\\ud803\\udc9e","68831":"\\ud803\\udc9f","68832":"\\ud803\\udca0","68833":"\\ud803\\udca1","68834":"\\ud803\\udca2","68835":"\\ud803\\udca3","68836":"\\ud803\\udca4","68837":"\\ud803\\udca5","68838":"\\ud803\\udca6","68839":"\\ud803\\udca7","68840":"\\ud803\\udca8","68841":"\\ud803\\udca9","68842":"\\ud803\\udcaa","68843":"\\ud803\\udcab","68844":"\\ud803\\udcac","68845":"\\ud803\\udcad","68846":"\\ud803\\udcae","68847":"\\ud803\\udcaf","68848":"\\ud803\\udcb0","68849":"\\ud803\\udcb1","68850":"\\ud803\\udcb2","71872":"\\ud806\\udca0","71873":"\\ud806\\udca1","71874":"\\ud806\\udca2","71875":"\\ud806\\udca3","71876":"\\ud806\\udca4","71877":"\\ud806\\udca5","71878":"\\ud806\\udca6","71879":"\\ud806\\udca7","71880":"\\ud806\\udca8","71881":"\\ud806\\udca9","71882":"\\ud806\\udcaa","71883":"\\ud806\\udcab","71884":"\\ud806\\udcac","71885":"\\ud806\\udcad","71886":"\\ud806\\udcae","71887":"\\ud806\\udcaf","71888":"\\ud806\\udcb0","71889":"\\ud806\\udcb1","71890":"\\ud806\\udcb2","71891":"\\ud806\\udcb3","71892":"\\ud806\\udcb4","71893":"\\ud806\\udcb5","71894":"\\ud806\\udcb6","71895":"\\ud806\\udcb7","71896":"\\ud806\\udcb8","71897":"\\ud806\\udcb9","71898":"\\ud806\\udcba","71899":"\\ud806\\udcbb","71900":"\\ud806\\udcbc","71901":"\\ud806\\udcbd","71902":"\\ud806\\udcbe","71903":"\\ud806\\udcbf","93792":"\\ud81b\\ude40","93793":"\\ud81b\\ude41","93794":"\\ud81b\\ude42","93795":"\\ud81b\\ude43","93796":"\\ud81b\\ude44","93797":"\\ud81b\\ude45","93798":"\\ud81b\\ude46","93799":"\\ud81b\\ude47","93800":"\\ud81b\\ude48","93801":"\\ud81b\\ude49","93802":"\\ud81b\\ude4a","93803":"\\ud81b\\ude4b","93804":"\\ud81b\\ude4c","93805":"\\ud81b\\ude4d","93806":"\\ud81b\\ude4e","93807":"\\ud81b\\ude4f","93808":"\\ud81b\\ude50","93809":"\\ud81b\\ude51","93810":"\\ud81b\\ude52","93811":"\\ud81b\\ude53","93812":"\\ud81b\\ude54","93813":"\\ud81b\\ude55","93814":"\\ud81b\\ude56","93815":"\\ud81b\\ude57","93816":"\\ud81b\\ude58","93817":"\\ud81b\\ude59","93818":"\\ud81b\\ude5a","93819":"\\ud81b\\ude5b","93820":"\\ud81b\\ude5c","93821":"\\ud81b\\ude5d","93822":"\\ud81b\\ude5e","93823":"\\ud81b\\ude5f","125218":"\\ud83a\\udd00","125219":"\\ud83a\\udd01","125220":"\\ud83a\\udd02","125221":"\\ud83a\\udd03","125222":"\\ud83a\\udd04","125223":"\\ud83a\\udd05","125224":"\\ud83a\\udd06","125225":"\\ud83a\\udd07","125226":"\\ud83a\\udd08","125227":"\\ud83a\\udd09","125228":"\\ud83a\\udd0a","125229":"\\ud83a\\udd0b","125230":"\\ud83a\\udd0c","125231":"\\ud83a\\udd0d","125232":"\\ud83a\\udd0e","125233":"\\ud83a\\udd0f","125234":"\\ud83a\\udd10","125235":"\\ud83a\\udd11","125236":"\\ud83a\\udd12","125237":"\\ud83a\\udd13","125238":"\\ud83a\\udd14","125239":"\\ud83a\\udd15","125240":"\\ud83a\\udd16","125241":"\\ud83a\\udd17","125242":"\\ud83a\\udd18","125243":"\\ud83a\\udd19","125244":"\\ud83a\\udd1a","125245":"\\ud83a\\udd1b","125246":"\\ud83a\\udd1c","125247":"\\ud83a\\udd1d","125248":"\\ud83a\\udd1e","125249":"\\ud83a\\udd1f","125250":"\\ud83a\\udd20","125251":"\\ud83a\\udd21","223":"SS","304":',
3766
+ '"\\u0130","64256":"FF","64257":"FI","64258":"FL","64259":"FFI","64260":"FFL","64261":"ST","64262":"ST","1415":"\\u0535\\u0552","64275":"\\u0544\\u0546","64276":"\\u0544\\u0535","64277":"\\u0544\\u053b","64278":"\\u054e\\u0546","64279":"\\u0544\\u053d","329":"\\u02bcN","912":"\\u0399\\u0308\\u0301","944":"\\u03a5\\u0308\\u0301","496":"J\\u030c","7830":"H\\u0331","7831":"T\\u0308","7832":"W\\u030a","7833":"Y\\u030a","7834":"A\\u02be","8016":"\\u03a5\\u0313","8018":"\\u03a5\\u0313\\u0300","8020":"\\u03a5\\u0313\\u0301","8022":"\\u03a5\\u0313\\u0342","8118":"\\u0391\\u0342","8134":"\\u0397\\u0342","8146":"\\u0399\\u0308\\u0300","8147":"\\u0399\\u0308\\u0301","8150":"\\u0399\\u0342","8151":"\\u0399\\u0308\\u0342","8162":"\\u03a5\\u0308\\u0300","8163":"\\u03a5\\u0308\\u0301","8164":"\\u03a1\\u0313","8166":"\\u03a5\\u0342","8167":"\\u03a5\\u0308\\u0342","8182":"\\u03a9\\u0342","8072":"\\u1f08\\u0399","8073":"\\u1f09\\u0399","8074":"\\u1f0a\\u0399","8075":"\\u1f0b\\u0399","8076":"\\u1f0c\\u0399","8077":"\\u1f0d\\u0399","8078":"\\u1f0e\\u0399","8079":"\\u1f0f\\u0399","8088":"\\u1f28\\u0399","8089":"\\u1f29\\u0399","8090":"\\u1f2a\\u0399","8091":"\\u1f2b\\u0399","8092":"\\u1f2c\\u0399","8093":"\\u1f2d\\u0399","8094":"\\u1f2e\\u0399","8095":"\\u1f2f\\u0399","8104":"\\u1f68\\u0399","8105":"\\u1f69\\u0399","8106":"\\u1f6a\\u0399","8107":"\\u1f6b\\u0399","8108":"\\u1f6c\\u0399","8109":"\\u1f6d\\u0399","8110":"\\u1f6e\\u0399","8111":"\\u1f6f\\u0399","8124":"\\u0391\\u0399","8140":"\\u0397\\u0399","8188":"\\u03a9\\u0399","8114":"\\u1fba\\u0399","8116":"\\u0386\\u0399","8130":"\\u1fca\\u0399","8132":"\\u0389\\u0399","8178":"\\u1ffa\\u0399","8180":"\\u038f\\u0399","8119":"\\u0391\\u0342\\u0399","8135":"\\u0397\\u0342\\u0399","8183":"\\u03a9\\u0342\\u0399"},"cased":[[65,90],[97,122],[170,170],[181,181],[186,186],[192,214],[216,246],[248,442],[444,447],[452,659],[661,696],[704,705],[736,740],[837,837],[880,883],[886,887],[890,893],[895,895],[902,902],[904,906],[908,908],[910,929],[931,1013],[1015,1153],[1162,1327],[1329,1366],[1376,1416],[4256,4293],[4295,4295],[4301,4301],[4304,4346],[4348,4351],[5024,5109],[5112,5117],[7296,7304],[7312,7354],[7357,7359],[7424,7615],[7680,7957],[7960,7965],[7968,8005],[8008,8013],[8016,8023],[8025,8025],[8027,8027],[8029,8029],[8031,8061],[8064,8116],[8118,8124],[8126,8126],[8130,8132],[8134,8140],[8144,8147],[8150,8155],[8160,8172],[8178,8180],[8182,8188],[8305,8305],[8319,8319],[8336,8348],[8450,8450],[8455,8455],[8458,8467],[8469,8469],[8473,8477],[8484,8484],[8486,8486],[8488,8488],[8490,8493],[8495,8500],[8505,8505],[8508,8511],[8517,8521],[8526,8526],[8544,8575],[8579,8580],[9398,9449],[11264,11492],[11499,11502],[11506,11507],[11520,11557],[11559,11559],[11565,11565],[42560,42605],[42624,42653],[42786,42887],[42891,42894],[42896,42954],[42960,42961],[42963,42963],[42965,42969],[42994,42998],[43000,43002],[43824,43866],[43868,43881],[43888,43967],[64256,64262],[64275,64279],[65313,65338],[65345,65370],[66560,66639],[66736,66771],[66776,66811],[66928,66938],[66940,66954],[66956,66962],[66964,66965],[66967,66977],[66979,66993],[66995,67001],[67003,67004],[67456,67456',
3767
+ '],[67459,67461],[67463,67504],[67506,67514],[68736,68786],[68800,68850],[71840,71903],[93760,93823],[119808,119892],[119894,119964],[119966,119967],[119970,119970],[119973,119974],[119977,119980],[119982,119993],[119995,119995],[119997,120003],[120005,120069],[120071,120074],[120077,120084],[120086,120092],[120094,120121],[120123,120126],[120128,120132],[120134,120134],[120138,120144],[120146,120485],[120488,120512],[120514,120538],[120540,120570],[120572,120596],[120598,120628],[120630,120654],[120656,120686],[120688,120712],[120714,120744],[120746,120770],[120772,120779],[122624,122633],[122635,122654],[122661,122666],[122928,122989],[125184,125251],[127280,127305],[127312,127337],[127344,127369]],"ignorable":[[39,39],[46,46],[58,58],[94,94],[96,96],[168,168],[173,173],[175,175],[180,180],[183,184],[688,879],[884,885],[890,890],[900,901],[903,903],[1155,1161],[1369,1369],[1375,1375],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1524,1524],[1536,1541],[1552,1562],[1564,1564],[1600,1600],[1611,1631],[1648,1648],[1750,1757],[1759,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2037],[2042,2042],[2045,2045],[2070,2093],[2137,2139],[2184,2184],[2192,2193],[2200,2207],[2249,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2417,2417],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2901,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3132,3132],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3457,3457],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3654,3662],[3761,3761],[3764,3772],[3782,3782],[3784,3790],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4348,4348],[4957,4959],[5906,5908],[5938,5939],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6103,6103],[6109,6109],[6155,6159],[6211,6211],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6823,6823],[6832,6862],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7288,7293],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7468,7530],[7544,7544],[7579,7679],[8125,8125],[8',
3768
+ "127,8129],[8141,8143],[8157,8159],[8173,8175],[8189,8190],[8203,8207],[8216,8217],[8228,8228],[8231,8231],[8234,8238],[8288,8292],[8294,8303],[8305,8305],[8319,8319],[8336,8348],[8400,8432],[11388,11389],[11503,11505],[11631,11631],[11647,11647],[11744,11775],[11823,11823],[12293,12293],[12330,12333],[12337,12341],[12347,12347],[12441,12446],[12540,12542],[40981,40981],[42232,42237],[42508,42508],[42607,42610],[42612,42621],[42623,42623],[42652,42655],[42736,42737],[42752,42785],[42864,42864],[42888,42890],[42994,42996],[43000,43001],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43052,43052],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43471,43471],[43493,43494],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43632,43632],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43741,43741],[43756,43757],[43763,43764],[43766,43766],[43867,43871],[43881,43883],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[64434,64450],[65024,65039],[65043,65043],[65056,65071],[65106,65106],[65109,65109],[65279,65279],[65287,65287],[65294,65294],[65306,65306],[65342,65342],[65344,65344],[65392,65392],[65438,65439],[65507,65507],[65529,65531],[66045,66045],[66272,66272],[66422,66426],[67456,67461],[67463,67504],[67506,67514],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69291,69292],[69373,69375],[69446,69456],[69506,69509],[69633,69633],[69688,69702],[69744,69744],[69747,69748],[69759,69761],[69811,69814],[69817,69818],[69821,69821],[69826,69826],[69837,69837],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70095,70095],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70209,70209],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[71995,71996],[71998,71998],[72003,72003],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[73472,73473],[73526,73530],[73536,73536],[73538,73538],[78896,78912],[78919,78933],[92912,92916],[92976,92982],[92992,92995],[94031,94031],[94095,94111],[94176,94177],[94179,94180],[110576,110579],[110581,110587],[110589,110590],[113821,113822],[113824,113827],[118528,118573],[118576,1185",
3769
+ '98],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[122928,122989],[123023,123023],[123184,123197],[123566,123566],[123628,123631],[124139,124143],[125136,125142],[125252,125259],[127995,127999],[917505,917505],[917536,917631],[917760,917999]],"whitespace":[[9,13],[32,32],[133,133],[160,160],[5760,5760],[8192,8202],[8232,8233],[8239,8239],[8287,8287],[12288,12288]]}'
3770
+ ].join("")
3771
+ );
3772
+ var programCache = /* @__PURE__ */ new WeakMap();
3773
+ var snapshotPrograms = /* @__PURE__ */ new WeakMap();
3774
+ function runtimeProgram(linked) {
3775
+ const cached = programCache.get(linked);
3776
+ if (cached) return cached;
3777
+ const data = getLinkedAppData(linked);
3778
+ if (!data) throw new TypeError("Untrusted LinkedApp");
3779
+ const states = {};
3780
+ for (const state of data.bundle.states) {
3781
+ const key = `app:${textValue(state.id)}`;
3782
+ states[key] = {
3783
+ key,
3784
+ initial: state.initial,
3785
+ type: textValue(state.type),
3786
+ lifetime: "session",
3787
+ sensitive: state.sensitive === true,
3788
+ root: "app"
3789
+ };
3790
+ }
3791
+ const runtimeNodes = data.nodes.map((entry) => {
3792
+ var _a, _b, _c, _d, _e;
3793
+ for (const binding of Object.values(entry.stateBindings)) states[binding.key] = binding;
3794
+ let form = entry.parent;
3795
+ while (form && form.node.kind !== "form") form = form.parent;
3796
+ const root = entry.identity.instanceRoot;
3797
+ const handlers = asObjects(entry.node.attributes.on).map((handler) => ({
3798
+ id: textValue(handler.id),
3799
+ event: textValue(handler.event),
3800
+ ...handler.key === void 0 ? {} : { key: textValue(handler.key) },
3801
+ ...handler.guard === void 0 ? {} : { guard: handler.guard },
3802
+ concurrency: handler.concurrency === "queue" ? "queue" : "drop",
3803
+ operations: asObjects(handler.operations).map((operation) => ({
3804
+ id: textValue(operation.id),
3805
+ executionClass: operation.executionClass,
3806
+ effect: operation.effect,
3807
+ after: operation.after,
3808
+ onFailure: operation.onFailure === "continue" ? "continue" : "stop"
3809
+ }))
3810
+ }));
3811
+ const targets = { ...entry.effectTargets };
3812
+ if (typeof entry.node.attributes.initialFocus === "string") {
3813
+ const find = (node) => {
3814
+ if (node.node.id === entry.node.attributes.initialFocus) return node;
3815
+ for (const child of node.children) {
3816
+ const found = find(child);
3817
+ if (found) return found;
3818
+ }
3819
+ return void 0;
3820
+ };
3821
+ const initial = find(entry);
3822
+ if (initial) targets.initialFocus = initial.renderedId;
3823
+ }
3824
+ return {
3825
+ id: entry.renderedId,
3826
+ identity: entry.identity,
3827
+ kind: entry.node.kind,
3828
+ label: (_a = entry.node.label) != null ? _a : "",
3829
+ parent: (_c = (_b = entry.parent) == null ? void 0 : _b.renderedId) != null ? _c : null,
3830
+ root: `${root.kind}/${root.namespace}/${root.id}`,
3831
+ attributes: entry.node.attributes,
3832
+ bindings: entry.stateBindings,
3833
+ handlers,
3834
+ targets,
3835
+ children: entry.children.map((child) => child.renderedId),
3836
+ form: (_e = (_d = entry.formTarget) != null ? _d : form == null ? void 0 : form.renderedId) != null ? _e : null
3837
+ };
3838
+ });
3839
+ const program = freeze({
3840
+ appId: data.bundle.id,
3841
+ modelDigest: linked.digest,
3842
+ profileDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, jcs(data.bundle.profile)),
3843
+ profile: data.bundle.profile,
3844
+ entry: data.bundle.entry,
3845
+ nodes: runtimeNodes,
3846
+ states,
3847
+ screens: data.screens.map((screen) => {
3848
+ var _a;
3849
+ return {
3850
+ route: screen.route,
3851
+ id: screen.children[0].renderedId,
3852
+ shell: screen.shell ? data.shells.find((shell) => shell.owner.key === screen.shell).children[0].renderedId : null,
3853
+ variants: (_a = screen.owner.definition.attributes.variants) != null ? _a : []
3854
+ };
3855
+ }),
3856
+ shells: data.shells.map((shell) => ({
3857
+ id: shell.children[0].renderedId,
3858
+ root: `shell/${shell.owner.module.namespace}/${shell.owner.definition.id}`,
3859
+ slot: shell.slotId
3860
+ })),
3861
+ fixtures: data.bundle.fixtures.map((fixture) => ({
3862
+ id: textValue(fixture.id),
3863
+ exhaustion: textValue(fixture.exhaustion),
3864
+ steps: asObjects(fixture.steps).map((step) => ({
3865
+ delayMs: Number(step.delayMs),
3866
+ outcome: textValue(step.outcome),
3867
+ value: step.value
3868
+ }))
3869
+ })),
3870
+ unicode: UNICODE_15_1
3871
+ });
3872
+ programCache.set(linked, program);
3873
+ return program;
3874
+ }
3875
+ function ownSnapshot(snapshot, program) {
3876
+ freeze(snapshot);
3877
+ snapshotPrograms.set(snapshot, program);
3878
+ return snapshot;
3879
+ }
3880
+ function createRuntime(linked, options = {}) {
3881
+ const program = runtimeProgram(linked);
3882
+ return ownSnapshot(runtimeEngine(program).initial(options.fragment), program);
3883
+ }
3884
+ function reduceEvent(snapshot, input) {
3885
+ const program = snapshotPrograms.get(snapshot);
3886
+ if (!program) throw new TypeError("Untrusted RuntimeSnapshot");
3887
+ return ownSnapshot(runtimeEngine(program).reduce(snapshot, input), program);
3888
+ }
3889
+ function advanceClock(snapshot, deltaMs) {
3890
+ return reduceEvent(snapshot, { kind: "advanceClock", deltaMs });
3891
+ }
3892
+ function resetRuntime(snapshot) {
3893
+ return reduceEvent(snapshot, { kind: "reset" });
3894
+ }
3895
+ function browserAdapter(engine, program) {
3896
+ const root = document.getElementById("wireweave-app"), storage = root.querySelector("[data-wf-screen-storage]");
3897
+ const nodes = new Map(program.nodes.map((node) => [node.id, node]));
3898
+ let state = engine.initial(location.hash), projecting = false, processing = false, paused = false, last = performance.now(), timer;
3899
+ let projectedFocus;
3900
+ let projectionTimer;
3901
+ const queue = [];
3902
+ let composition = null;
3903
+ const present = (value) => value == null ? "" : typeof value === "object" ? JSON.stringify(value) : String(value);
3904
+ function element(id) {
3905
+ return document.getElementById(id);
3906
+ }
3907
+ function focusElement(id) {
3908
+ const node = nodes.get(id);
3909
+ if ((node == null ? void 0 : node.kind) === "tab") return document.getElementById(id + "-tab");
3910
+ if ((node == null ? void 0 : node.kind) === "dropdown") return document.getElementById(id + "-trigger");
3911
+ return element(id);
3912
+ }
3913
+ function metadata(sequence) {
3914
+ return { wireweave: { modelDigest: program.modelDigest, sequence } };
3915
+ }
3916
+ function browserSequence() {
3917
+ const outer = history.state;
3918
+ const value = outer && typeof outer === "object" ? outer.wireweave : void 0;
3919
+ if (!value || typeof value !== "object") return null;
3920
+ const entry = value;
3921
+ return entry.modelDigest === program.modelDigest && typeof entry.sequence === "number" && Number.isInteger(entry.sequence) ? entry.sequence : null;
3922
+ }
3923
+ function effectCommands() {
3924
+ for (const effect of state.effects) {
3925
+ if (effect.kind === "push") history.pushState(metadata(effect.sequence), "", effect.fragment);
3926
+ else if (effect.kind === "replace")
3927
+ history.replaceState(metadata(effect.sequence), "", effect.fragment);
3928
+ else if (effect.kind === "traverse" || effect.kind === "compensate") {
3929
+ if (effect.delta !== 0) history.go(effect.delta);
3930
+ else history.replaceState(metadata(effect.sequence), "", effect.fragment);
3931
+ } else location.assign(effect.fragment);
3932
+ }
3933
+ }
3934
+ function render() {
3935
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3936
+ if (projectionTimer !== void 0) {
3937
+ clearTimeout(projectionTimer);
3938
+ projectionTimer = void 0;
3939
+ }
3940
+ projecting = true;
3941
+ try {
3942
+ const view = engine.view(state), active = program.screens.find(
3943
+ (screen) => {
3944
+ var _a2, _b2;
3945
+ return screen.route.namespace === ((_a2 = state.route) == null ? void 0 : _a2.namespace) && screen.route.id === ((_b2 = state.route) == null ? void 0 : _b2.id);
3946
+ }
3947
+ );
3948
+ for (const wrapper of root.querySelectorAll("[data-wf-screen]")) {
3949
+ const visible = wrapper.contains(element((_a = active == null ? void 0 : active.id) != null ? _a : ""));
3950
+ wrapper.hidden = !visible;
3951
+ wrapper.inert = !visible;
3952
+ if (!visible && wrapper.parentElement !== storage) storage.append(wrapper);
3953
+ }
3954
+ for (const wrapper of root.querySelectorAll("[data-wf-shell]")) {
3955
+ const visible = !!(active == null ? void 0 : active.shell) && wrapper.contains(element(active.shell));
3956
+ wrapper.hidden = !visible;
3957
+ wrapper.inert = !visible;
3958
+ }
3959
+ if (active) {
3960
+ const screen = element(active.id).closest("[data-wf-screen]");
3961
+ if (active.shell) {
3962
+ const shell = program.shells.find((shell2) => shell2.id === active.shell);
3963
+ const slot = element(shell.slot);
3964
+ if (screen.parentElement !== slot) slot.append(screen);
3965
+ } else if (screen.parentElement !== storage) storage.append(screen);
3966
+ screen.hidden = false;
3967
+ screen.inert = false;
3968
+ }
3969
+ const routeError = root.querySelector("[data-wf-route-error]");
3970
+ routeError.hidden = state.route !== null;
3971
+ root.querySelector("[data-wf-invalid-address]").textContent = state.address;
3972
+ root.setAttribute("data-wf-route", state.route ? state.address : "error");
3973
+ root.setAttribute("data-wf-view", state.viewMode);
3974
+ root.setAttribute("aria-busy", String(state.suspended));
3975
+ for (const node of program.nodes) {
3976
+ const el = element(node.id);
3977
+ if (!el) continue;
3978
+ el.hidden = view.visible[node.id] !== true;
3979
+ const field = el.closest("[data-wf-field]");
3980
+ if (field) field.hidden = el.hidden;
3981
+ if (node.kind === "tab") {
3982
+ const owner2 = nodes.get((_b = node.parent) != null ? _b : ""), tabs = (_c = owner2 == null ? void 0 : owner2.children.filter((id) => {
3983
+ var _a2;
3984
+ return ((_a2 = nodes.get(id)) == null ? void 0 : _a2.kind) === "tab";
3985
+ })) != null ? _c : [], selected = tabs[(_e = state.selection[(_d = owner2 == null ? void 0 : owner2.id) != null ? _d : ""]) != null ? _e : 0] === node.id;
3986
+ el.hidden = !view.visible[node.id] || !selected;
3987
+ const button = document.getElementById(node.id + "-tab");
3988
+ if (button) {
3989
+ button.setAttribute("aria-selected", String(selected));
3990
+ button.tabIndex = state.focus === node.id ? 0 : tabs.includes((_f = state.focus) != null ? _f : "") ? -1 : selected ? 0 : -1;
3991
+ button.disabled = !view.enabled[node.id];
3992
+ }
3993
+ }
3994
+ if ("disabled" in el) el.disabled = view.enabled[node.id] !== true;
3995
+ const control = view.controls[node.id];
3996
+ if (["input", "textarea", "select", "checkbox", "radio", "switch", "slider"].includes(
3997
+ node.kind
3998
+ )) {
3999
+ const input = el;
4000
+ if (["checkbox", "radio", "switch"].includes(node.kind)) input.checked = control.checked;
4001
+ else if (!composition || composition.id !== node.id) input.value = present(control.value);
4002
+ }
4003
+ if (state.invalid[node.id]) {
4004
+ el.setAttribute("aria-invalid", "true");
4005
+ const message = element(node.id + "-error");
4006
+ if (message) {
4007
+ message.textContent = state.invalid[node.id];
4008
+ message.hidden = false;
4009
+ el.setAttribute("aria-describedby", message.id);
4010
+ }
4011
+ } else {
4012
+ el.removeAttribute("aria-invalid");
4013
+ const message = element(node.id + "-error");
4014
+ if (message) message.hidden = true;
4015
+ el.removeAttribute("aria-describedby");
4016
+ }
4017
+ if (node.kind === "form") {
4018
+ const error = el.querySelector("[data-wf-form-error]");
4019
+ if (error) {
4020
+ error.textContent = state.invalid[node.id] ? "Check the required input values." : "";
4021
+ error.hidden = !state.invalid[node.id];
4022
+ }
4023
+ el.setAttribute(
4024
+ "aria-busy",
4025
+ String(Object.values(state.requests).some((request) => request.owner === node.id))
4026
+ );
4027
+ }
4028
+ if (node.kind === "accordion")
4029
+ el.open = state.expanded[node.id] === true;
4030
+ if (["modal", "drawer", "popover"].includes(node.kind)) {
4031
+ const overlay = state.overlays.find((overlay2) => overlay2.id === node.id), dialog = el;
4032
+ if (overlay) {
4033
+ dialog.hidden = false;
4034
+ if (!dialog.open) {
4035
+ if (overlay.modal) dialog.showModal();
4036
+ else dialog.show();
4037
+ }
4038
+ dialog.setAttribute("aria-modal", String(overlay.modal));
4039
+ } else if (dialog.open) dialog.close();
4040
+ }
4041
+ if (node.kind === "dropdown") {
4042
+ const open = state.overlays.some((overlay) => overlay.id === node.id);
4043
+ const body = el.querySelector("[data-wf-overlay-body]");
4044
+ if (body) body.hidden = !open;
4045
+ const button = document.getElementById(node.id + "-trigger");
4046
+ button == null ? void 0 : button.setAttribute("aria-expanded", String(open));
4047
+ }
4048
+ if (node.kind === "tooltip") {
4049
+ const tooltip = el.querySelector("[role=tooltip]");
4050
+ if (tooltip) tooltip.hidden = !state.overlays.some((overlay) => overlay.id === node.id);
4051
+ const trigger = node.children[0] ? element(node.children[0]) : null;
4052
+ if (trigger && tooltip) trigger.setAttribute("aria-describedby", tooltip.id);
4053
+ }
4054
+ if (node.attributes.dismissible === true && ["toast", "alert"].includes(node.kind))
4055
+ el.hidden = el.hidden || state.expanded[node.id] === false;
4056
+ if (el instanceof HTMLAnchorElement) {
4057
+ if (el.getAttribute("href") === state.address) el.setAttribute("aria-current", "page");
4058
+ else el.removeAttribute("aria-current");
4059
+ }
4060
+ if (node.attributes.data) {
4061
+ const value = view.data[node.id];
4062
+ if (node.kind === "table" && Array.isArray(value)) {
4063
+ const body = el.querySelector("tbody"), fragment = document.createDocumentFragment();
4064
+ for (const row of value) {
4065
+ const tr = document.createElement("tr");
4066
+ for (const key of node.attributes.columns) {
4067
+ const td = document.createElement("td");
4068
+ td.textContent = present(row[key]);
4069
+ tr.append(td);
4070
+ }
4071
+ fragment.append(tr);
4072
+ }
4073
+ body.replaceChildren(fragment);
4074
+ } else if (node.kind === "list" && Array.isArray(value)) {
4075
+ const fragment = document.createDocumentFragment();
4076
+ for (const item of value) {
4077
+ const li = document.createElement("li");
4078
+ li.textContent = present(item);
4079
+ fragment.append(li);
4080
+ }
4081
+ el.replaceChildren(fragment);
4082
+ } else if (node.kind === "text" && value !== void 0) el.textContent = present(value);
4083
+ }
4084
+ }
4085
+ for (const screen of program.screens) (_g = element(screen.id)) == null ? void 0 : _g.removeAttribute("role");
4086
+ if (active && ![...root.querySelectorAll("main")].some((main) => !main.closest("[hidden]")))
4087
+ (_h = element(active.id)) == null ? void 0 : _h.setAttribute("role", "main");
4088
+ const status = root.querySelector("[data-wf-runtime-status]");
4089
+ status.textContent = state.diagnostic ? "The action could not complete: " + state.diagnostic : "";
4090
+ if (state.diagnostic) root.setAttribute("data-wf-runtime-diagnostic", state.diagnostic);
4091
+ else root.removeAttribute("data-wf-runtime-diagnostic");
4092
+ const lastTrace = state.trace.at(-1);
4093
+ if (lastTrace) root.setAttribute("data-wf-operation-result", lastTrace.result);
4094
+ document.getElementById("wf-runtime-trace").textContent = JSON.stringify(state.trace);
4095
+ if (state.focus && state.focus !== projectedFocus) {
4096
+ const focus = focusElement(state.focus);
4097
+ if (focus && focus !== document.activeElement && !focus.closest("[hidden],[inert]"))
4098
+ focus.focus();
4099
+ } else if (!state.route && projectedFocus !== null) {
4100
+ const heading = routeError.querySelector("h1");
4101
+ heading == null ? void 0 : heading.focus();
4102
+ }
4103
+ projectedFocus = state.focus;
4104
+ } finally {
4105
+ projecting = false;
4106
+ }
4107
+ }
4108
+ function apply(input, sequence = null, deferProjection = false) {
4109
+ if (queue.length >= 4096) throw Error("limit-queue");
4110
+ queue.push({ input, sequence, deferProjection });
4111
+ if (processing) return;
4112
+ processing = true;
4113
+ try {
4114
+ while (queue.length) {
4115
+ const item = queue.shift();
4116
+ state = engine.reduce(state, item.input, item.sequence);
4117
+ effectCommands();
4118
+ if (item.deferProjection) {
4119
+ if (projectionTimer === void 0) projectionTimer = setTimeout(render, 0);
4120
+ } else render();
4121
+ }
4122
+ } finally {
4123
+ processing = false;
4124
+ }
4125
+ }
4126
+ function owner(target) {
4127
+ var _a, _b;
4128
+ if (!(target instanceof Element)) return void 0;
4129
+ const el = target.closest("[data-wf-event-owner], [data-wf-kind]");
4130
+ return nodes.get((_b = (_a = el == null ? void 0 : el.getAttribute("data-wf-event-owner")) != null ? _a : el == null ? void 0 : el.id) != null ? _b : "");
4131
+ }
4132
+ function nativeEvent(event) {
4133
+ if (projecting) return;
4134
+ const node = owner(event.target);
4135
+ if (!node) return;
4136
+ const kind = event.type;
4137
+ const input = { kind: "event", source: node.identity, event: kind };
4138
+ if (kind === "input" || kind === "change") {
4139
+ const control = event.target;
4140
+ if (event.isComposing) return;
4141
+ if ((composition == null ? void 0 : composition.id) === node.id) {
4142
+ if (composition.value === control.value) {
4143
+ composition = null;
4144
+ return;
4145
+ }
4146
+ composition = null;
4147
+ }
4148
+ if (["checkbox", "radio", "switch"].includes(node.kind)) input.checked = control.checked;
4149
+ else input.value = control.value;
4150
+ }
4151
+ apply(input);
4152
+ }
4153
+ root.addEventListener("input", nativeEvent);
4154
+ root.addEventListener("change", nativeEvent);
4155
+ root.addEventListener("focus", nativeEvent, true);
4156
+ root.addEventListener("blur", nativeEvent, true);
4157
+ root.addEventListener("compositionstart", (event) => {
4158
+ const node = owner(event.target);
4159
+ if (node) composition = { id: node.id, value: event.target.value };
4160
+ });
4161
+ root.addEventListener("compositionend", (event) => {
4162
+ const node = owner(event.target);
4163
+ if (!node) return;
4164
+ const value = event.target.value;
4165
+ composition = null;
4166
+ apply({ kind: "event", source: node.identity, event: "input", value });
4167
+ composition = { id: node.id, value };
4168
+ });
4169
+ root.addEventListener("submit", (event) => {
4170
+ event.preventDefault();
4171
+ if (projecting) return;
4172
+ const node = owner(event.target);
4173
+ if (node) apply({ kind: "event", source: node.identity, event: "submit" });
4174
+ });
4175
+ root.addEventListener("click", (event) => {
4176
+ if (projecting) return;
4177
+ const target = event.target, tool = target.closest("[data-wf-tooling]");
4178
+ if (tool) {
4179
+ event.preventDefault();
4180
+ projectedFocus = void 0;
4181
+ if (tool.getAttribute("data-wf-tooling") === "view") {
4182
+ state = { ...state, viewMode: state.viewMode === "fixed" ? "accessible" : "fixed" };
4183
+ render();
4184
+ } else if (tool.getAttribute("data-wf-tooling") === "reset") apply({ kind: "reset" });
4185
+ return;
4186
+ }
4187
+ const node = owner(event.target);
4188
+ if (!node) return;
4189
+ if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
4190
+ return;
4191
+ const anchor = target.closest("a");
4192
+ if (["input", "textarea", "select", "checkbox", "radio", "switch", "slider"].includes(node.kind)) {
4193
+ if (node.handlers.some((handler) => handler.event === "click"))
4194
+ apply({ kind: "event", source: node.identity, event: "click" }, null, true);
4195
+ return;
4196
+ }
4197
+ if (anchor && node.attributes.href !== void 0 && !node.handlers.some((handler) => handler.event === "click"))
4198
+ return;
4199
+ event.preventDefault();
4200
+ apply({ kind: "event", source: node.identity, event: "click" });
4201
+ });
4202
+ root.addEventListener("keydown", (event) => {
4203
+ if (projecting) return;
4204
+ const node = owner(event.target);
4205
+ if (!node) return;
4206
+ const explicit = node.handlers.some(
4207
+ (handler) => handler.event === "keydown" && handler.key === event.key
4208
+ ), widget = ["tab", "tabs", "dropdown", "dropdown-item"].includes(node.kind) && ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End", "Enter", " "].includes(
4209
+ event.key
4210
+ );
4211
+ if (explicit || widget || event.key === "Escape") {
4212
+ event.preventDefault();
4213
+ apply({ kind: "event", source: node.identity, event: "keydown", key: event.key });
4214
+ } else if (event.key === "Enter" && ["input", "select"].includes(node.kind) && node.form) {
4215
+ event.preventDefault();
4216
+ const form = nodes.get(node.form);
4217
+ apply({ kind: "event", source: form.identity, event: "submit" });
4218
+ }
4219
+ });
4220
+ root.addEventListener(
4221
+ "cancel",
4222
+ (event) => {
4223
+ event.preventDefault();
4224
+ const node = owner(event.target);
4225
+ if (node) apply({ kind: "event", source: node.identity, event: "keydown", key: "Escape" });
4226
+ },
4227
+ true
4228
+ );
4229
+ function addressChanged() {
4230
+ const sequence = browserSequence(), fragment = location.hash, canonical = fragment || engine.routeAddress(program.entry);
4231
+ if (!state.suspended && canonical === state.address && sequence === state.history[state.historyIndex].sequence)
4232
+ return;
4233
+ apply({ kind: "address", fragment }, sequence);
4234
+ }
4235
+ addEventListener("hashchange", addressChanged);
4236
+ addEventListener("popstate", addressChanged);
4237
+ for (const type of ["pointerover", "pointerout"])
4238
+ root.addEventListener(type, (event) => {
4239
+ const target = event.target instanceof Element ? event.target.closest("[data-wf-kind=tooltip]") : null;
4240
+ if (!target || target.contains(event.relatedTarget)) return;
4241
+ if (type === "pointerout" && target.contains(document.activeElement)) return;
4242
+ state = engine.hover(state, target.id, type === "pointerover");
4243
+ render();
4244
+ });
4245
+ function schedule() {
4246
+ timer = setTimeout(() => {
4247
+ const now = performance.now();
4248
+ if (!paused && !state.suspended) {
4249
+ let delta = Math.max(0, Math.floor(now - last));
4250
+ while (delta > 0) {
4251
+ const part = Math.min(delta, 6e5);
4252
+ const next = engine.reduce(state, { kind: "advanceClock", deltaMs: part });
4253
+ const changed = next.sequence !== state.sequence;
4254
+ state = next;
4255
+ if (changed) {
4256
+ effectCommands();
4257
+ render();
4258
+ }
4259
+ delta -= part;
4260
+ }
4261
+ }
4262
+ last = now;
4263
+ schedule();
4264
+ }, 16);
4265
+ }
4266
+ history.replaceState(metadata(state.history[state.historyIndex].sequence), "", location.href);
4267
+ render();
4268
+ schedule();
4269
+ Object.defineProperty(window, "wireweaveRuntime", {
4270
+ value: Object.freeze({
4271
+ pause() {
4272
+ paused = true;
4273
+ last = performance.now();
4274
+ },
4275
+ resume() {
4276
+ paused = false;
4277
+ last = performance.now();
4278
+ },
4279
+ dispatch(input) {
4280
+ apply(input);
4281
+ },
4282
+ advanceClock(deltaMs) {
4283
+ paused = true;
4284
+ apply({ kind: "advanceClock", deltaMs });
4285
+ },
4286
+ reset() {
4287
+ apply({ kind: "reset" });
4288
+ },
4289
+ snapshot() {
4290
+ return JSON.parse(JSON.stringify(state));
4291
+ }
4292
+ }),
4293
+ enumerable: false,
4294
+ writable: false,
4295
+ configurable: false
4296
+ });
4297
+ addEventListener("pagehide", () => {
4298
+ if (timer !== void 0) clearTimeout(timer);
4299
+ });
4300
+ }
4301
+ var NATIVE_RUNTIME = `(()=>{const program=JSON.parse(document.getElementById("wf-runtime-data").textContent);(${browserAdapter.toString()})((${runtimeEngine.toString()})(program),program);})();`;
4302
+ function compileAppV4(linked) {
4303
+ const data = getLinkedAppData(linked);
4304
+ if (data === void 0)
4305
+ return failed([diagnostic("WW_SCHEMA", "app.untrusted-linked-model", void 0, {}, "compile")]);
4306
+ if (data.artifact !== void 0) return { ok: true, value: data.artifact, diagnostics: [] };
4307
+ const renderer = new HtmlArtifact(data, runtimeProgram(linked));
4308
+ const html = renderer.html();
4309
+ if (new TextEncoder().encode(html).byteLength > 64 * 1024 * 1024)
4310
+ return failed([diagnostic("WW_LIMIT", "app.html-byte-limit", void 0, {}, "compile")]);
4311
+ const artifact = freeze({
4312
+ kind: "AppArtifact",
4313
+ schemaVersion: "1.0.0",
4314
+ languageVersion: "4.0.0",
4315
+ html,
4316
+ sourceMap: data.sourceMap,
4317
+ mediaType: "text/html",
4318
+ byteLength: new TextEncoder().encode(html).byteLength,
4319
+ digest: _chunkIMUVIIJRcjs.digestV4.call(void 0, html),
4320
+ modelDigest: linked.digest,
4321
+ profileDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, jcs(data.bundle.profile)),
4322
+ runtimeDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, NATIVE_RUNTIME),
4323
+ registryDigest: data.bundle.registry.digest,
4324
+ entry: data.bundle.entry,
4325
+ screenIndex: data.screens.map((screen) => ({
4326
+ route: screen.route,
4327
+ renderedId: screen.children[0].renderedId
4328
+ })),
4329
+ operationIndex: data.nodes.flatMap(
4330
+ (node) => asObjects(node.node.attributes.on).flatMap(
4331
+ (handler) => asObjects(handler.operations).map((operation) => ({
4332
+ renderedId: node.renderedId,
4333
+ handlerId: textValue(handler.id),
4334
+ operationId: textValue(operation.id),
4335
+ executionClass: textValue(operation.executionClass),
4336
+ operation
4337
+ }))
4338
+ )
4339
+ ),
4340
+ diagnostics: [],
4341
+ manifest: {
4342
+ appId: data.bundle.id,
4343
+ modelDigest: linked.digest,
4344
+ profileDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, jcs(data.bundle.profile)),
4345
+ registryDigest: data.bundle.registry.digest,
4346
+ htmlDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, html),
4347
+ runtimeDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, NATIVE_RUNTIME),
4348
+ executionScope: "standard-1",
4349
+ unsupportedOperations: renderer.unsupported
4350
+ }
4351
+ });
4352
+ data.artifact = artifact;
4353
+ return { ok: true, value: artifact, diagnostics: [] };
4354
+ }
4355
+ function renderSite2(bundle) {
4356
+ const linked = linkApp(bundle);
4357
+ return linked.ok ? compileAppV4(linked.value) : linked;
4358
+ }
4359
+
4360
+
4361
+
4362
+
4363
+
4364
+
4365
+
4366
+
4367
+
4368
+
4369
+
4370
+
4371
+
4372
+
4373
+
4374
+ exports.parameterReferenceName = parameterReferenceName; exports.collectParameterReferences = collectParameterReferences; exports.createAppBundle = createAppBundle; exports.createAppNodeId = createAppNodeId; exports.createAppComponentInstanceId = createAppComponentInstanceId; exports.linkApp = linkApp; exports.compileApp = compileApp; exports.linkAndCompileApp = linkAndCompileApp; exports.createRuntime = createRuntime; exports.reduceEvent = reduceEvent; exports.advanceClock = advanceClock; exports.resetRuntime = resetRuntime; exports.renderSite = renderSite2;