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

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 (53) hide show
  1. package/dist/app.cjs +51 -31
  2. package/dist/app.d.cts +5 -145
  3. package/dist/app.d.ts +5 -145
  4. package/dist/app.js +2 -31
  5. package/dist/{chunk-QOS4IC75.js → chunk-2Y3GKARZ.js} +16 -1354
  6. package/dist/chunk-3RWGG5EC.js +296 -342
  7. package/dist/chunk-4DDV6Z2X.js +389 -0
  8. package/dist/chunk-ETV4XYOV.cjs +4 -6
  9. package/dist/chunk-IMUVIIJR.cjs +317 -354
  10. package/dist/chunk-LA5LKIEL.cjs +396 -0
  11. package/dist/chunk-MD6MNOEQ.cjs +121 -142
  12. package/dist/chunk-NV6UV5ID.cjs +2145 -0
  13. package/dist/chunk-PKBMQBKP.js +1 -3
  14. package/dist/{chunk-7VTK6LHL.cjs → chunk-SAN6CJEE.cjs} +96 -1421
  15. package/dist/chunk-TQSOLTMZ.js +2132 -0
  16. package/dist/chunk-V3HVWC7C.js +1 -32
  17. package/dist/chunk-XYACLXXF.js +4 -132
  18. package/dist/chunk-ZPHNXJRY.cjs +158 -180
  19. package/dist/index-BD_4rXH-.d.cts +1031 -0
  20. package/dist/{index-Br7pNaf3.d.cts → index-BEnsO2kE.d.ts} +144 -2
  21. package/dist/{index-G906GEtg.d.cts → index-BlNYFaZd.d.cts} +2 -2
  22. package/dist/{index-CghCKUPx.d.ts → index-Cx4-VXVS.d.ts} +2 -2
  23. package/dist/{index-Da_B3eoM.d.ts → index-YSIzfhOd.d.cts} +144 -2
  24. package/dist/index-g9yV20xb.d.ts +1031 -0
  25. package/dist/index.cjs +939 -429
  26. package/dist/index.d.cts +16 -193
  27. package/dist/index.d.ts +16 -193
  28. package/dist/index.js +210 -396
  29. package/dist/interaction.cjs +26 -17
  30. package/dist/interaction.d.cts +2 -2
  31. package/dist/interaction.d.ts +2 -2
  32. package/dist/interaction.js +1 -17
  33. package/dist/parser.cjs +38 -21
  34. package/dist/parser.d.cts +3 -3
  35. package/dist/parser.d.ts +3 -3
  36. package/dist/parser.js +1 -21
  37. package/dist/renderer.cjs +124 -68
  38. package/dist/renderer.d.cts +4 -756
  39. package/dist/renderer.d.ts +4 -756
  40. package/dist/renderer.js +3 -68
  41. package/dist/spec.cjs +94 -49
  42. package/dist/spec.js +1 -49
  43. package/dist/{types-vhPCZpAW.d.cts → types-CGRi1k2N.d.cts} +1 -1
  44. package/dist/{types-vhPCZpAW.d.ts → types-CGRi1k2N.d.ts} +1 -1
  45. package/dist/{v4-types-Baz9yqAS.d.cts → v4-types-2ORUg6To.d.cts} +1 -1
  46. package/dist/{v4-types-Baz9yqAS.d.ts → v4-types-2ORUg6To.d.ts} +1 -1
  47. package/package.json +21 -23
  48. package/dist/chunk-4TMDPWPR.cjs +0 -196
  49. package/dist/chunk-5DGRIQDU.cjs +0 -842
  50. package/dist/chunk-JJWAFHSV.js +0 -842
  51. package/dist/chunk-R5WBZWBC.js +0 -196
  52. package/dist/chunk-WV724EAW.js +0 -0
  53. package/dist/chunk-XENFKHRC.cjs +0 -1
@@ -1,15 +1,8 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ 'use strict';
2
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');
3
+ var chunkNV6UV5ID_cjs = require('./chunk-NV6UV5ID.cjs');
4
+ var chunkIMUVIIJR_cjs = require('./chunk-IMUVIIJR.cjs');
5
+ var chunkETV4XYOV_cjs = require('./chunk-ETV4XYOV.cjs');
13
6
 
14
7
  // src/ast/component-parameters.ts
15
8
  var PARAMETER_REFERENCE = /^\$([a-zA-Z_][a-zA-Z0-9_-]*)$/;
@@ -49,1317 +42,6 @@ function collectParameterReferences(children) {
49
42
  return found;
50
43
  }
51
44
 
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
45
  // src/app/linker.ts
1364
46
  function createAppNodeId(namespace, kind, id) {
1365
47
  return `${encodeURIComponent(namespace)}:${kind}:${encodeURIComponent(id)}`;
@@ -1402,20 +84,18 @@ function componentUses(node) {
1402
84
  }
1403
85
  function referencesOf(pending) {
1404
86
  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
- );
87
+ const inferred = componentUses(pending.input.node).map((use) => {
88
+ var _a2;
89
+ return {
90
+ kind: "component",
91
+ id: use.name,
92
+ ...use.namespace === void 0 ? {} : { namespace: use.namespace },
93
+ source: {
94
+ sourceId: pending.input.source.sourceId,
95
+ location: (_a2 = use.loc) != null ? _a2 : pending.input.source.location
96
+ }
97
+ };
98
+ });
1419
99
  return [...(_a = pending.input.references) != null ? _a : [], ...inferred];
1420
100
  }
1421
101
  function resolveReferences(pending, definitions, diagnostics) {
@@ -1725,7 +405,7 @@ function expandNode(node, path, context) {
1725
405
  return clone;
1726
406
  }
1727
407
  function linkApp(input, modules) {
1728
- if (modules === void 0) return linkAppV4(input);
408
+ if (modules === void 0) return chunkNV6UV5ID_cjs.linkAppV4(input);
1729
409
  return linkLegacyApp(input, modules);
1730
410
  }
1731
411
  function linkLegacyApp(manifest, modules) {
@@ -1937,7 +617,7 @@ function compileApp(document2, options = {}) {
1937
617
  type: "Document",
1938
618
  children: [...document2.layouts.map(projectLayout), ...document2.screens.map(projectScreen)]
1939
619
  };
1940
- return _chunk5DGRIQDUcjs.renderSite.call(void 0, projected, { ...options, annotationStyle: "neutral" });
620
+ return chunkNV6UV5ID_cjs.renderSite(projected, { ...options, annotationStyle: "neutral" });
1941
621
  }
1942
622
  function linkAndCompileApp(input, modules, options = {}) {
1943
623
  if (modules === void 0) {
@@ -1949,20 +629,20 @@ function linkAndCompileApp(input, modules, options = {}) {
1949
629
  return { ...linked, html: compileApp(linked.document, options) };
1950
630
  }
1951
631
  function escape(value) {
1952
- return textValue(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
632
+ return chunkNV6UV5ID_cjs.textValue(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1953
633
  }
1954
634
  function attribute(name, value) {
1955
635
  return value === void 0 || value === false ? "" : ` ${name}="${escape(value === true ? "" : value)}"`;
1956
636
  }
1957
637
  function jsonBlock(value) {
1958
- return jcs(value).replace(/</g, "\\u003c");
638
+ return chunkNV6UV5ID_cjs.jcs(value).replace(/</g, "\\u003c");
1959
639
  }
1960
640
  function address(route) {
1961
641
  return `#wf/${encodeURIComponent(route.namespace)}/${encodeURIComponent(route.id)}${route.variant === void 0 ? "" : `?variant=${encodeURIComponent(route.variant)}`}`;
1962
642
  }
1963
643
  function hashBase64(value) {
1964
644
  var _a, _b;
1965
- const hex = _chunkIMUVIIJRcjs.digestV4.call(void 0, value).slice(7), alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
645
+ const hex = chunkIMUVIIJR_cjs.digestV4(value).slice(7), alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1966
646
  const bytes = Array.from(
1967
647
  { length: 32 },
1968
648
  (_, index) => Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16)
@@ -1976,49 +656,49 @@ function hashBase64(value) {
1976
656
  }
1977
657
  var HtmlArtifact = class {
1978
658
  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", []);
659
+ chunkETV4XYOV_cjs.__publicField(this, "data", data);
660
+ chunkETV4XYOV_cjs.__publicField(this, "program", program);
661
+ chunkETV4XYOV_cjs.__publicField(this, "unsupported", []);
662
+ chunkETV4XYOV_cjs.__publicField(this, "rules", []);
1983
663
  }
1984
664
  node(entry) {
1985
665
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1986
666
  const { node, renderedId } = entry;
1987
667
  const attrs = node.attributes;
1988
- const label = (_b = node.label) != null ? _b : textValue((_a = attrs.label) != null ? _a : "");
668
+ const label = (_b = node.label) != null ? _b : chunkNV6UV5ID_cjs.textValue((_a = attrs.label) != null ? _a : "");
1989
669
  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(
670
+ 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", chunkNV6UV5ID_cjs.jcs(entry.identity)) + attribute(
1991
671
  "data-wf-requirements",
1992
- attrs.requirementRefs === void 0 ? void 0 : jcs(attrs.requirementRefs)
672
+ attrs.requirementRefs === void 0 ? void 0 : chunkNV6UV5ID_cjs.jcs(attrs.requirementRefs)
1993
673
  ) + attribute(
1994
674
  "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(
675
+ attrs.obligationRefs === void 0 ? void 0 : chunkNV6UV5ID_cjs.jcs(attrs.obligationRefs)
676
+ ) + attribute("data-wf-on", attrs.on === void 0 ? void 0 : chunkNV6UV5ID_cjs.jcs(attrs.on)) + attribute("data-wf-bind", attrs.bind === void 0 ? void 0 : chunkNV6UV5ID_cjs.jcs(attrs.bind)) + attribute("data-wf-data", attrs.data === void 0 ? void 0 : chunkNV6UV5ID_cjs.jcs(attrs.data)) + attribute("data-wf-columns", attrs.columns === void 0 ? void 0 : chunkNV6UV5ID_cjs.jcs(attrs.columns)) + attribute(
1997
677
  "data-wf-targets",
1998
- entry.effectTargets === void 0 ? void 0 : jcs(entry.effectTargets)
678
+ entry.effectTargets === void 0 ? void 0 : chunkNV6UV5ID_cjs.jcs(entry.effectTargets)
1999
679
  ) + attribute(
2000
680
  "data-wf-visible-when",
2001
- attrs.visibleWhen === void 0 ? void 0 : jcs(attrs.visibleWhen)
681
+ attrs.visibleWhen === void 0 ? void 0 : chunkNV6UV5ID_cjs.jcs(attrs.visibleWhen)
2002
682
  ) + attribute(
2003
683
  "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(
684
+ attrs.enabledWhen === void 0 ? void 0 : chunkNV6UV5ID_cjs.jcs(attrs.enabledWhen)
685
+ ) + attribute("data-wf-when", attrs.when === void 0 ? void 0 : chunkNV6UV5ID_cjs.jcs(attrs.when)) + attribute("data-wf-state-bindings", chunkNV6UV5ID_cjs.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
686
  "data-wf-disabled",
2007
687
  attrs.disabled === true || attrs.loading === true ? true : void 0
2008
688
  ) + attribute("data-wf-action", attrs.action);
2009
- for (const handler of asObjects(attrs.on))
2010
- for (const operation of asObjects(handler.operations)) {
689
+ for (const handler of chunkNV6UV5ID_cjs.asObjects(attrs.on))
690
+ for (const operation of chunkNV6UV5ID_cjs.asObjects(handler.operations)) {
2011
691
  if (operation.executionClass === "specified") {
2012
692
  this.unsupported.push({
2013
693
  renderedId,
2014
- handlerId: textValue(handler.id),
2015
- operationId: textValue(operation.id)
694
+ handlerId: chunkNV6UV5ID_cjs.textValue(handler.id),
695
+ operationId: chunkNV6UV5ID_cjs.textValue(operation.id)
2016
696
  });
2017
697
  }
2018
698
  }
2019
699
  if (entry.slot) return `<div${common} data-wf-slot="${escape(entry.owner.key)}"></div>`;
2020
700
  this.layout(entry);
2021
- const bound = object(attrs.bind) ? entry.stateBindings[textValue(attrs.bind.state)] : void 0;
701
+ const bound = chunkNV6UV5ID_cjs.object(attrs.bind) ? entry.stateBindings[chunkNV6UV5ID_cjs.textValue(attrs.bind.state)] : void 0;
2022
702
  const value = (_d = bound == null ? void 0 : bound.initial) != null ? _d : attrs.value;
2023
703
  const disabled = attrs.disabled === true || attrs.loading === true;
2024
704
  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>`;
@@ -2035,7 +715,7 @@ var HtmlArtifact = class {
2035
715
  );
2036
716
  if (node.kind === "select")
2037
717
  return labelled(
2038
- `<select${common}${scalarAttrs}>${asObjects(attrs.options).map(
718
+ `<select${common}${scalarAttrs}>${chunkNV6UV5ID_cjs.asObjects(attrs.options).map(
2039
719
  (option) => `<option${attribute("value", option.value)}${attribute("selected", value === option.value)}${attribute("disabled", option.disabled)}>${escape(option.label)}</option>`
2040
720
  ).join("")}</select>`
2041
721
  );
@@ -2075,11 +755,11 @@ var HtmlArtifact = class {
2075
755
  if (node.kind === "table") {
2076
756
  const columns = Array.isArray(attrs.columns) ? attrs.columns : [];
2077
757
  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;
758
+ if (chunkNV6UV5ID_cjs.object(attrs.data)) {
759
+ const initial = (_l = entry.stateBindings[chunkNV6UV5ID_cjs.textValue(attrs.data.state)]) == null ? void 0 : _l.initial;
2080
760
  if (Array.isArray(initial))
2081
761
  rows = initial.map(
2082
- (record) => columns.map((column) => object(record) ? record[textValue(column)] : null)
762
+ (record) => columns.map((column) => chunkNV6UV5ID_cjs.object(record) ? record[chunkNV6UV5ID_cjs.textValue(column)] : null)
2083
763
  );
2084
764
  }
2085
765
  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>`;
@@ -2117,9 +797,9 @@ var HtmlArtifact = class {
2117
797
  const length = (value, axis, spacing = false) => {
2118
798
  if (typeof value === "number")
2119
799
  return `${spacing && [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20].includes(value) ? value * 4 : value}px`;
2120
- if (object(value)) {
800
+ if (chunkNV6UV5ID_cjs.object(value)) {
2121
801
  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)}`;
802
+ 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}${chunkNV6UV5ID_cjs.textValue(value.unit)}`;
2123
803
  }
2124
804
  return value === "full" ? "100%" : value === "screen" ? `${Number(profile[axis])}px` : value === "fit" ? "fit-content" : "auto";
2125
805
  };
@@ -2156,10 +836,10 @@ var HtmlArtifact = class {
2156
836
  if (["row", "col", "stack"].includes(kind)) {
2157
837
  styles.push(
2158
838
  "display:flex",
2159
- `flex-direction:${textValue((_a = a.direction) != null ? _a : kind === "row" ? "row" : "column")}`,
839
+ `flex-direction:${chunkNV6UV5ID_cjs.textValue((_a = a.direction) != null ? _a : kind === "row" ? "row" : "column")}`,
2160
840
  `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")}`
841
+ `justify-content:${(_c = { start: "flex-start", end: "flex-end", between: "space-between", around: "space-around", evenly: "space-evenly" }[chunkNV6UV5ID_cjs.textValue(a.justify)]) != null ? _c : chunkNV6UV5ID_cjs.textValue((_b = a.justify) != null ? _b : "flex-start")}`,
842
+ `align-items:${(_e = { start: "flex-start", end: "flex-end" }[chunkNV6UV5ID_cjs.textValue(a.align)]) != null ? _e : chunkNV6UV5ID_cjs.textValue((_d = a.align) != null ? _d : "stretch")}`
2163
843
  );
2164
844
  }
2165
845
  if (a.flex !== void 0)
@@ -2177,7 +857,7 @@ var HtmlArtifact = class {
2177
857
  if (a.order !== void 0) styles.push(`order:${Number(a.order)}`);
2178
858
  if (a.scroll === true) styles.push("overflow:auto");
2179
859
  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];
860
+ const anchor = chunkNV6UV5ID_cjs.textValue((_i = a.anchor) != null ? _i : "top-left"), vertical = anchor === "center" ? "center" : anchor.split("-")[0], horizontal = anchor === "center" ? "center" : anchor.split("-")[1];
2181
861
  styles.push(
2182
862
  "position:absolute",
2183
863
  `left:calc(${horizontal === "center" ? "50%" : horizontal === "right" ? "100%" : "0%"} + ${Number((_j = a.x) != null ? _j : 0)}px)`,
@@ -2195,11 +875,11 @@ var HtmlArtifact = class {
2195
875
  styles.push("background:#f4f4f5");
2196
876
  if (a.shadow !== void 0 && a.shadow !== "none")
2197
877
  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`
878
+ `box-shadow:0 ${{ sm: 1, md: 2, lg: 4, xl: 8 }[chunkNV6UV5ID_cjs.textValue(a.shadow)]}px ${{ sm: 1, md: 2, lg: 4, xl: 8 }[chunkNV6UV5ID_cjs.textValue(a.shadow)]}px #71717a`
2199
879
  );
2200
880
  if (a.bold === true || a.weight !== void 0)
2201
881
  styles.push(
2202
- `font-weight:${a.bold === true ? 700 : { normal: 400, medium: 500, semibold: 600, bold: 700 }[textValue(a.weight)]}`
882
+ `font-weight:${a.bold === true ? 700 : { normal: 400, medium: 500, semibold: 600, bold: 700 }[chunkNV6UV5ID_cjs.textValue(a.weight)]}`
2203
883
  );
2204
884
  if (typeof a.size === "string") {
2205
885
  const font = { xs: 12, sm: 14, base: 16, md: 16, lg: 18, xl: 20, "2xl": 24, "3xl": 30 }[a.size];
@@ -2212,7 +892,7 @@ var HtmlArtifact = class {
2212
892
  );
2213
893
  } else if (typeof a.size === "number") styles.push(`width:${a.size}px`, `height:${a.size}px`);
2214
894
  if (["text", "title", "link"].includes(kind) && a.align !== void 0)
2215
- styles.push(`text-align:${textValue(a.align)}`);
895
+ styles.push(`text-align:${chunkNV6UV5ID_cjs.textValue(a.align)}`);
2216
896
  if (styles.length) this.rules.push(`#wireweave-app .${entry.renderedId}{${styles.join(";")}}`);
2217
897
  }
2218
898
  html() {
@@ -2229,7 +909,7 @@ var HtmlArtifact = class {
2229
909
  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
910
  }
2231
911
  ).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}`;
912
+ 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:${chunkNV6UV5ID_cjs.textValue(bundle.profile.width)}px;height:${chunkNV6UV5ID_cjs.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
913
  const runtimeData = this.program;
2234
914
  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
915
  return `<!DOCTYPE html>
@@ -2521,7 +1201,6 @@ function runtimeEngine(program) {
2521
1201
  );
2522
1202
  return screen && (result.variant === void 0 || screen.variants.includes(result.variant)) ? result : null;
2523
1203
  } catch (error) {
2524
- void error;
2525
1204
  return null;
2526
1205
  }
2527
1206
  }
@@ -2713,7 +1392,6 @@ function runtimeEngine(program) {
2713
1392
  const url = new URL(text);
2714
1393
  if (!url.protocol) return "url";
2715
1394
  } catch (error) {
2716
- void error;
2717
1395
  return "url";
2718
1396
  }
2719
1397
  }
@@ -3774,15 +2452,15 @@ var snapshotPrograms = /* @__PURE__ */ new WeakMap();
3774
2452
  function runtimeProgram(linked) {
3775
2453
  const cached = programCache.get(linked);
3776
2454
  if (cached) return cached;
3777
- const data = getLinkedAppData(linked);
2455
+ const data = chunkNV6UV5ID_cjs.getLinkedAppData(linked);
3778
2456
  if (!data) throw new TypeError("Untrusted LinkedApp");
3779
2457
  const states = {};
3780
2458
  for (const state of data.bundle.states) {
3781
- const key = `app:${textValue(state.id)}`;
2459
+ const key = `app:${chunkNV6UV5ID_cjs.textValue(state.id)}`;
3782
2460
  states[key] = {
3783
2461
  key,
3784
2462
  initial: state.initial,
3785
- type: textValue(state.type),
2463
+ type: chunkNV6UV5ID_cjs.textValue(state.type),
3786
2464
  lifetime: "session",
3787
2465
  sensitive: state.sensitive === true,
3788
2466
  root: "app"
@@ -3794,14 +2472,14 @@ function runtimeProgram(linked) {
3794
2472
  let form = entry.parent;
3795
2473
  while (form && form.node.kind !== "form") form = form.parent;
3796
2474
  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) },
2475
+ const handlers = chunkNV6UV5ID_cjs.asObjects(entry.node.attributes.on).map((handler) => ({
2476
+ id: chunkNV6UV5ID_cjs.textValue(handler.id),
2477
+ event: chunkNV6UV5ID_cjs.textValue(handler.event),
2478
+ ...handler.key === void 0 ? {} : { key: chunkNV6UV5ID_cjs.textValue(handler.key) },
3801
2479
  ...handler.guard === void 0 ? {} : { guard: handler.guard },
3802
2480
  concurrency: handler.concurrency === "queue" ? "queue" : "drop",
3803
- operations: asObjects(handler.operations).map((operation) => ({
3804
- id: textValue(operation.id),
2481
+ operations: chunkNV6UV5ID_cjs.asObjects(handler.operations).map((operation) => ({
2482
+ id: chunkNV6UV5ID_cjs.textValue(operation.id),
3805
2483
  executionClass: operation.executionClass,
3806
2484
  effect: operation.effect,
3807
2485
  after: operation.after,
@@ -3836,10 +2514,10 @@ function runtimeProgram(linked) {
3836
2514
  form: (_e = (_d = entry.formTarget) != null ? _d : form == null ? void 0 : form.renderedId) != null ? _e : null
3837
2515
  };
3838
2516
  });
3839
- const program = freeze({
2517
+ const program = chunkNV6UV5ID_cjs.freeze({
3840
2518
  appId: data.bundle.id,
3841
2519
  modelDigest: linked.digest,
3842
- profileDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, jcs(data.bundle.profile)),
2520
+ profileDigest: chunkIMUVIIJR_cjs.digestV4(chunkNV6UV5ID_cjs.jcs(data.bundle.profile)),
3843
2521
  profile: data.bundle.profile,
3844
2522
  entry: data.bundle.entry,
3845
2523
  nodes: runtimeNodes,
@@ -3859,11 +2537,11 @@ function runtimeProgram(linked) {
3859
2537
  slot: shell.slotId
3860
2538
  })),
3861
2539
  fixtures: data.bundle.fixtures.map((fixture) => ({
3862
- id: textValue(fixture.id),
3863
- exhaustion: textValue(fixture.exhaustion),
3864
- steps: asObjects(fixture.steps).map((step) => ({
2540
+ id: chunkNV6UV5ID_cjs.textValue(fixture.id),
2541
+ exhaustion: chunkNV6UV5ID_cjs.textValue(fixture.exhaustion),
2542
+ steps: chunkNV6UV5ID_cjs.asObjects(fixture.steps).map((step) => ({
3865
2543
  delayMs: Number(step.delayMs),
3866
- outcome: textValue(step.outcome),
2544
+ outcome: chunkNV6UV5ID_cjs.textValue(step.outcome),
3867
2545
  value: step.value
3868
2546
  }))
3869
2547
  })),
@@ -3873,7 +2551,7 @@ function runtimeProgram(linked) {
3873
2551
  return program;
3874
2552
  }
3875
2553
  function ownSnapshot(snapshot, program) {
3876
- freeze(snapshot);
2554
+ chunkNV6UV5ID_cjs.freeze(snapshot);
3877
2555
  snapshotPrograms.set(snapshot, program);
3878
2556
  return snapshot;
3879
2557
  }
@@ -4300,15 +2978,15 @@ function browserAdapter(engine, program) {
4300
2978
  }
4301
2979
  var NATIVE_RUNTIME = `(()=>{const program=JSON.parse(document.getElementById("wf-runtime-data").textContent);(${browserAdapter.toString()})((${runtimeEngine.toString()})(program),program);})();`;
4302
2980
  function compileAppV4(linked) {
4303
- const data = getLinkedAppData(linked);
2981
+ const data = chunkNV6UV5ID_cjs.getLinkedAppData(linked);
4304
2982
  if (data === void 0)
4305
- return failed([diagnostic("WW_SCHEMA", "app.untrusted-linked-model", void 0, {}, "compile")]);
2983
+ return chunkNV6UV5ID_cjs.failed([chunkNV6UV5ID_cjs.diagnostic("WW_SCHEMA", "app.untrusted-linked-model", void 0, {}, "compile")]);
4306
2984
  if (data.artifact !== void 0) return { ok: true, value: data.artifact, diagnostics: [] };
4307
2985
  const renderer = new HtmlArtifact(data, runtimeProgram(linked));
4308
2986
  const html = renderer.html();
4309
2987
  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({
2988
+ return chunkNV6UV5ID_cjs.failed([chunkNV6UV5ID_cjs.diagnostic("WW_LIMIT", "app.html-byte-limit", void 0, {}, "compile")]);
2989
+ const artifact = chunkNV6UV5ID_cjs.freeze({
4312
2990
  kind: "AppArtifact",
4313
2991
  schemaVersion: "1.0.0",
4314
2992
  languageVersion: "4.0.0",
@@ -4316,10 +2994,10 @@ function compileAppV4(linked) {
4316
2994
  sourceMap: data.sourceMap,
4317
2995
  mediaType: "text/html",
4318
2996
  byteLength: new TextEncoder().encode(html).byteLength,
4319
- digest: _chunkIMUVIIJRcjs.digestV4.call(void 0, html),
2997
+ digest: chunkIMUVIIJR_cjs.digestV4(html),
4320
2998
  modelDigest: linked.digest,
4321
- profileDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, jcs(data.bundle.profile)),
4322
- runtimeDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, NATIVE_RUNTIME),
2999
+ profileDigest: chunkIMUVIIJR_cjs.digestV4(chunkNV6UV5ID_cjs.jcs(data.bundle.profile)),
3000
+ runtimeDigest: chunkIMUVIIJR_cjs.digestV4(NATIVE_RUNTIME),
4323
3001
  registryDigest: data.bundle.registry.digest,
4324
3002
  entry: data.bundle.entry,
4325
3003
  screenIndex: data.screens.map((screen) => ({
@@ -4327,12 +3005,12 @@ function compileAppV4(linked) {
4327
3005
  renderedId: screen.children[0].renderedId
4328
3006
  })),
4329
3007
  operationIndex: data.nodes.flatMap(
4330
- (node) => asObjects(node.node.attributes.on).flatMap(
4331
- (handler) => asObjects(handler.operations).map((operation) => ({
3008
+ (node) => chunkNV6UV5ID_cjs.asObjects(node.node.attributes.on).flatMap(
3009
+ (handler) => chunkNV6UV5ID_cjs.asObjects(handler.operations).map((operation) => ({
4332
3010
  renderedId: node.renderedId,
4333
- handlerId: textValue(handler.id),
4334
- operationId: textValue(operation.id),
4335
- executionClass: textValue(operation.executionClass),
3011
+ handlerId: chunkNV6UV5ID_cjs.textValue(handler.id),
3012
+ operationId: chunkNV6UV5ID_cjs.textValue(operation.id),
3013
+ executionClass: chunkNV6UV5ID_cjs.textValue(operation.executionClass),
4336
3014
  operation
4337
3015
  }))
4338
3016
  )
@@ -4341,10 +3019,10 @@ function compileAppV4(linked) {
4341
3019
  manifest: {
4342
3020
  appId: data.bundle.id,
4343
3021
  modelDigest: linked.digest,
4344
- profileDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, jcs(data.bundle.profile)),
3022
+ profileDigest: chunkIMUVIIJR_cjs.digestV4(chunkNV6UV5ID_cjs.jcs(data.bundle.profile)),
4345
3023
  registryDigest: data.bundle.registry.digest,
4346
- htmlDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, html),
4347
- runtimeDigest: _chunkIMUVIIJRcjs.digestV4.call(void 0, NATIVE_RUNTIME),
3024
+ htmlDigest: chunkIMUVIIJR_cjs.digestV4(html),
3025
+ runtimeDigest: chunkIMUVIIJR_cjs.digestV4(NATIVE_RUNTIME),
4348
3026
  executionScope: "standard-1",
4349
3027
  unsupportedOperations: renderer.unsupported
4350
3028
  }
@@ -4357,18 +3035,15 @@ function renderSite2(bundle) {
4357
3035
  return linked.ok ? compileAppV4(linked.value) : linked;
4358
3036
  }
4359
3037
 
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;
3038
+ exports.advanceClock = advanceClock;
3039
+ exports.collectParameterReferences = collectParameterReferences;
3040
+ exports.compileApp = compileApp;
3041
+ exports.createAppComponentInstanceId = createAppComponentInstanceId;
3042
+ exports.createAppNodeId = createAppNodeId;
3043
+ exports.createRuntime = createRuntime;
3044
+ exports.linkAndCompileApp = linkAndCompileApp;
3045
+ exports.linkApp = linkApp;
3046
+ exports.parameterReferenceName = parameterReferenceName;
3047
+ exports.reduceEvent = reduceEvent;
3048
+ exports.renderSite = renderSite2;
3049
+ exports.resetRuntime = resetRuntime;