@intentius/behold 0.30.1 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/AGENTS.md +475 -16
  2. package/README.md +25 -19
  3. package/demos.json +14 -9
  4. package/dist/cli.js +54900 -26771
  5. package/example-carve/README.md +19 -23
  6. package/example-carve/app/package.json +1 -1
  7. package/example-carve/app/src/carved.ts +3 -3
  8. package/example-carve/carve-report.json +1 -1
  9. package/example-carve/{legacy-tf → tf-root}/terraform.tfstate +1 -1
  10. package/example-choudoufu-estate/README.md +7 -0
  11. package/example-choudoufu-estate/chant.workspace.json +1 -1
  12. package/example-choudoufu-estate/scripts/choudoufu-down.sh +2 -1
  13. package/example-choudoufu-estate/scripts/choudoufu-up.sh +10 -3
  14. package/example-terraform-estate/README.md +32 -5
  15. package/example-terraform-estate/chant.workspace.json +1 -1
  16. package/example-terraform-estate/recorded/adoption/platform.json +72 -0
  17. package/example-terraform-estate/recorded/adoption/prod.json +224 -0
  18. package/example-terralith/README.md +1 -1
  19. package/example-three-cloud/README.md +111 -18
  20. package/example-three-cloud/aws/Pulumi.yaml +15 -0
  21. package/example-three-cloud/aws/index.ts +174 -0
  22. package/example-three-cloud/aws/package-lock.json +2725 -0
  23. package/example-three-cloud/aws/package.json +14 -0
  24. package/example-three-cloud/aws/tsconfig.json +17 -0
  25. package/example-three-cloud/azure/main.tf +48 -0
  26. package/example-three-cloud/azure/site.tf +104 -0
  27. package/example-three-cloud/chant.config.json +9 -0
  28. package/example-three-cloud/chant.workspace.json +30 -4
  29. package/example-three-cloud/dns/chant.config.ts +26 -1
  30. package/example-three-cloud/dns/src/records.component.ts +32 -6
  31. package/example-three-cloud/package-lock.json +48 -27
  32. package/example-three-cloud/package.json +8 -6
  33. package/example-three-cloud/scripts/emulators-up.sh +28 -1
  34. package/example-three-cloud/scripts/front-door.ts +679 -86
  35. package/package.json +13 -6
  36. package/web/adopt-pulumi.js +114 -0
  37. package/web/adopt-pulumi.test.js +28 -0
  38. package/web/adopt.js +203 -0
  39. package/web/adopt.test.js +27 -0
  40. package/web/app.js +614 -19
  41. package/web/carve-steps.js +1 -1
  42. package/web/carve-steps.test.js +2 -2
  43. package/web/change-set-overlay.js +12 -5
  44. package/web/change-set-overlay.test.js +22 -0
  45. package/web/drift-stream.js +241 -0
  46. package/web/drift-stream.test.js +146 -0
  47. package/web/edge-weight.d.ts +1 -1
  48. package/web/edge-weight.js +5 -1
  49. package/web/edge-weight.test.js +19 -0
  50. package/web/embed.js +2 -2
  51. package/web/event-help-modal.js +18 -12
  52. package/web/event-help-modal.test.js +28 -1
  53. package/web/graph-query.js +180 -0
  54. package/web/graph-query.test.js +49 -0
  55. package/web/graph.html +107 -0
  56. package/web/index-diff.js +109 -0
  57. package/web/index-diff.test.js +39 -0
  58. package/web/index.html +55 -0
  59. package/web/kiosk-ask-layout.js +85 -0
  60. package/web/kiosk-ask-layout.test.js +83 -0
  61. package/web/kiosk-ask-tips.js +477 -0
  62. package/web/kiosk-ask-tips.test.js +372 -0
  63. package/web/kiosk-ask.js +774 -0
  64. package/web/kiosk-ask.test.js +593 -0
  65. package/web/kiosk-banner.js +108 -0
  66. package/web/kiosk-banner.test.js +72 -0
  67. package/web/kiosk-center-cards.test.js +110 -0
  68. package/web/kiosk-estate-scene.js +267 -0
  69. package/web/kiosk-estate-scene.test.js +21 -0
  70. package/web/kiosk-event-help.js +4 -1
  71. package/web/kiosk-graph-pane.js +63 -0
  72. package/web/kiosk-graph-pane.test.js +105 -0
  73. package/web/kiosk-light-frame.js +197 -0
  74. package/web/kiosk-light.js +547 -0
  75. package/web/kiosk-light.test.js +297 -0
  76. package/web/kiosk-member-kind.test.js +140 -0
  77. package/web/kiosk-metrics.js +7 -4
  78. package/web/kiosk-modal-sticky.test.js +2 -1
  79. package/web/kiosk-popover.js +4 -1
  80. package/web/kiosk-refit.test.js +81 -0
  81. package/web/kiosk-reset.js +49 -0
  82. package/web/kiosk-reset.test.js +11 -0
  83. package/web/kiosk-shot.js +40 -2
  84. package/web/kiosk-shot.test.js +23 -1
  85. package/web/kiosk-side.js +296 -0
  86. package/web/kiosk-side.test.js +249 -0
  87. package/web/kiosk-vendor.js +85 -7
  88. package/web/kiosk-vendor.test.js +9 -9
  89. package/web/kiosk-watch.js +20 -4
  90. package/web/kiosk-watch.test.js +15 -1
  91. package/web/kiosk.html +153 -1
  92. package/web/kiosk.js +252 -27
  93. package/web/kiosk.test.js +25 -1
  94. package/web/member-kind.js +31 -0
  95. package/web/small-stage.test.js +4 -0
  96. package/web/template-apps.js +245 -0
  97. package/web/template-apps.test.js +252 -0
  98. package/web/templates.js +285 -0
  99. package/web/templates.test.js +155 -0
  100. package/web/terragucci-change.js +30 -13
  101. package/web/terragucci-lifecycle.js +112 -62
  102. package/web/terragucci-lifecycle.test.js +29 -1
  103. package/web/terragucci-timeline.js +39 -2
  104. package/web/terragucci-timeline.test.js +42 -1
  105. package/web/tool-mark.js +4 -4
  106. package/web/tool-mark.test.js +1 -1
  107. package/web/vendors/atmos.svg +1 -0
  108. package/web/vendors/chant.svg +1 -0
  109. package/web/vendors/choudoufu.svg +1 -0
  110. package/web/vendors/terragrunt.svg +9 -0
  111. package/web/vendors/terragucci.svg +1 -0
  112. package/example-three-cloud/aws/chant.config.ts +0 -8
  113. package/example-three-cloud/aws/site.component.ts +0 -13
  114. package/example-three-cloud/aws/src/site.ts +0 -27
  115. package/example-three-cloud/azure/chant.config.ts +0 -1
  116. package/example-three-cloud/azure/src/site.component.ts +0 -13
  117. package/example-three-cloud/azure/src/site.ts +0 -18
  118. package/web/vendors/choudoufu-128.png +0 -0
  119. package/web/vendors/choudoufu-64.png +0 -0
  120. /package/example-carve/{legacy-tf → tf-root}/cdn.tf +0 -0
  121. /package/example-carve/{legacy-tf → tf-root}/compute.tf +0 -0
  122. /package/example-carve/{legacy-tf → tf-root}/floci-override.tf.disabled +0 -0
  123. /package/example-carve/{legacy-tf → tf-root}/modules/cdn/main.tf +0 -0
  124. /package/example-carve/{legacy-tf → tf-root}/naming.tf +0 -0
  125. /package/example-carve/{legacy-tf → tf-root}/network.tf +0 -0
  126. /package/example-carve/{legacy-tf → tf-root}/observability.tf +0 -0
  127. /package/example-carve/{legacy-tf → tf-root}/outputs.tf +0 -0
  128. /package/example-carve/{legacy-tf → tf-root}/storage.tf +0 -0
  129. /package/example-carve/{legacy-tf → tf-root}/versions.tf +0 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Whether the graph pane folds away (body.k-nograph hides it and gives its width to the runs).
3
+ *
4
+ * It folds for a tool whose pipeline has no graph to show, and for nothing else. It never folds:
5
+ * - before the page has read what it needs to know (the served project, the terragucci answer): a reload lands here
6
+ * for a second or two, and the pane is dark and in its place, not gone and then back;
7
+ * - in ask mode, where the graph is half of the story;
8
+ * - once the graph has been shown on this page: a read that fails or is stale for a moment (the reports being
9
+ * written at the apply) keeps the pane, and the last drawn scene with it.
10
+ */
11
+ export function graphFolds({ vendor, ok, askOn, seen, pending }) {
12
+ if (!vendor || ok) return false;
13
+ return !(askOn || seen || pending);
14
+ }
15
+
16
+ /** Whether the page still has a read to wait for before it can say the graph is not coming. */
17
+ export function graphPending({ own, single, answer }) {
18
+ return single === null || (!own && (answer === null || answer === undefined));
19
+ }
20
+
21
+ /**
22
+ * Whether the frame may show what is in its svg. In ask mode the graph is the estate scene (web/kiosk-estate-scene.js)
23
+ * and never the checkout's plain resource graph: the pane holds (dark, "Drawing the graph...") until the scene is up,
24
+ * and a scene that is up stays when its reads go missing for a moment (a pin that fits no plan yet, a read in flight).
25
+ *
26
+ * - not in ask mode, or on the components view: always (Inspect and the rest are as they were);
27
+ * - a scene is drawn: yes;
28
+ * - the reports are in, hold no estate scene at all, and say so: yes, the repo's own graph is the scene (a repo
29
+ * that is not a composed run);
30
+ * - anything else (no reads yet, a read that failed, a scene the pin hides for now): no.
31
+ */
32
+ export function graphMayShow({ askOn, components = false, sceneUp, answerSettled, answerHasScene }) {
33
+ if (!askOn || components) return true;
34
+ if (sceneUp) return true;
35
+ return !!answerSettled && !answerHasScene;
36
+ }
37
+
38
+ /**
39
+ * Whether the frame may tell the kiosk it has drawn. In ask mode it waits until the graph may show, and, until the
40
+ * kiosk has said whether ask mode is on (a load tells it right after), a short while at most: the kiosk swaps a
41
+ * reloaded frame in on this word, and a frame swapped in too early shows the plain graph.
42
+ */
43
+ export function mayTellDrawn({ askHeard, waitedMs, askOn, mayShow, graceMs = 3000 }) {
44
+ if (!askHeard && waitedMs < graceMs) return false;
45
+ return !askOn || mayShow;
46
+ }
47
+
48
+ /** Whether a scene that is up stays when the scene model is gone: in ask mode always, for the plain graph never paints. */
49
+ export function keepsSceneInAsk({ askOn, sceneUp }) {
50
+ return !!askOn && !!sceneUp;
51
+ }
52
+
53
+ /**
54
+ * Whether a kiosk frame draws its reports' scene on an empty svg in place of the graph's refusal (`refusal`, the
55
+ * precondition body /api/graph answered): a composed run's scene comes from its reports alone, so a checkout the graph
56
+ * refuses (a chant project the view never installed) is no reason to draw nothing. Only in a frame (`bare`), and only
57
+ * once the reports hold a scene; without one the refusal's card stays.
58
+ */
59
+ export function refusalHoldsScene({ refusal, bare, answer }) {
60
+ if (!refusal || !bare || !answer || answer.error) return false;
61
+ const scene = answer.estateScene;
62
+ return !!(scene && Array.isArray(scene.roots) && scene.roots.some((r) => r && Array.isArray(r.resources) && r.resources.length));
63
+ }
@@ -0,0 +1,105 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { graphFolds, graphPending } from "./kiosk-graph-pane.js";
3
+
4
+ const base = { vendor: { id: "terragucci" }, ok: false, askOn: false, seen: false, pending: false };
5
+
6
+ describe("when the graph pane folds away", () => {
7
+ it("folds for a tool with no graph, once the reads are in", () => {
8
+ expect(graphFolds(base)).toBe(true);
9
+ });
10
+ it("never folds while the graph is there", () => {
11
+ expect(graphFolds({ ...base, ok: true })).toBe(false);
12
+ });
13
+ it("not before the page has read the project and the answer (the moment after a reload)", () => {
14
+ expect(graphFolds({ ...base, pending: true })).toBe(false);
15
+ });
16
+ it("not in ask mode: the graph is half of the story", () => {
17
+ expect(graphFolds({ ...base, askOn: true })).toBe(false);
18
+ });
19
+ it("not after the graph has been shown on this page (a stale or failed read keeps it)", () => {
20
+ expect(graphFolds({ ...base, seen: true })).toBe(false);
21
+ });
22
+ it("a page with no tool folds nothing", () => {
23
+ expect(graphFolds({ ...base, vendor: null })).toBe(false);
24
+ });
25
+ });
26
+
27
+ describe("whether a read is still to come", () => {
28
+ it("until /api/project has answered", () => {
29
+ expect(graphPending({ own: false, single: null, answer: { a: 1 } })).toBe(true);
30
+ });
31
+ it("until the terragucci answer is in, for a tool that reads it", () => {
32
+ expect(graphPending({ own: false, single: true, answer: null })).toBe(true);
33
+ expect(graphPending({ own: false, single: true, answer: { error: "x" } })).toBe(false);
34
+ });
35
+ it("a tool with its own reads waits for the project only", () => {
36
+ expect(graphPending({ own: true, single: false, answer: null })).toBe(false);
37
+ });
38
+ });
39
+
40
+ import { graphMayShow, keepsSceneInAsk, mayTellDrawn } from "./kiosk-graph-pane.js";
41
+
42
+ describe("graphMayShow: ask mode never paints the plain resource graph", () => {
43
+ const ask = { askOn: true, components: false, sceneUp: false, answerSettled: false, answerHasScene: false };
44
+ it("Inspect (not ask mode) always shows the graph", () => {
45
+ expect(graphMayShow({ ...ask, askOn: false })).toBe(true);
46
+ });
47
+ it("the components view always shows", () => {
48
+ expect(graphMayShow({ ...ask, components: true })).toBe(true);
49
+ });
50
+ it("holds before the reports are in", () => {
51
+ expect(graphMayShow(ask)).toBe(false);
52
+ });
53
+ it("holds while the reports have a scene the pin hides for now", () => {
54
+ expect(graphMayShow({ ...ask, answerSettled: true, answerHasScene: true })).toBe(false);
55
+ });
56
+ it("holds on a failed read", () => {
57
+ expect(graphMayShow({ ...ask, answerSettled: false })).toBe(false);
58
+ });
59
+ it("shows once the scene is drawn, and keeps showing when the reads go missing", () => {
60
+ expect(graphMayShow({ ...ask, sceneUp: true })).toBe(true);
61
+ });
62
+ it("a repo whose reports hold no scene shows its own graph", () => {
63
+ expect(graphMayShow({ ...ask, answerSettled: true, answerHasScene: false })).toBe(true);
64
+ });
65
+ });
66
+
67
+ describe("keepsSceneInAsk", () => {
68
+ it("keeps a drawn scene in ask mode, never outside it", () => {
69
+ expect(keepsSceneInAsk({ askOn: true, sceneUp: true })).toBe(true);
70
+ expect(keepsSceneInAsk({ askOn: true, sceneUp: false })).toBe(false);
71
+ expect(keepsSceneInAsk({ askOn: false, sceneUp: true })).toBe(false);
72
+ });
73
+ });
74
+
75
+ describe("mayTellDrawn", () => {
76
+ it("waits for the kiosk's word on ask mode, for a while", () => {
77
+ expect(mayTellDrawn({ askHeard: false, waitedMs: 500, askOn: false, mayShow: true })).toBe(false);
78
+ expect(mayTellDrawn({ askHeard: false, waitedMs: 3500, askOn: false, mayShow: true })).toBe(true);
79
+ });
80
+ it("in ask mode, not until the graph may show", () => {
81
+ expect(mayTellDrawn({ askHeard: true, waitedMs: 9000, askOn: true, mayShow: false })).toBe(false);
82
+ expect(mayTellDrawn({ askHeard: true, waitedMs: 9000, askOn: true, mayShow: true })).toBe(true);
83
+ });
84
+ it("outside ask mode, as before", () => {
85
+ expect(mayTellDrawn({ askHeard: true, waitedMs: 0, askOn: false, mayShow: false })).toBe(true);
86
+ });
87
+ });
88
+
89
+ import { refusalHoldsScene } from "./kiosk-graph-pane.js";
90
+
91
+ describe("refusalHoldsScene: a composed run's scene needs no graph", () => {
92
+ const refusal = { code: "lint", error: "dependencies not installed" };
93
+ const scene = { estateScene: { roots: [{ path: "network", resources: [{ address: "aws_subnet.b" }] }] } };
94
+ it("draws the scene in a frame whose graph refused the checkout, once the reports hold one", () => {
95
+ expect(refusalHoldsScene({ refusal, bare: true, answer: scene })).toBe(true);
96
+ });
97
+ it("keeps the refusal's card without a scene, outside a frame, or with no refusal", () => {
98
+ expect(refusalHoldsScene({ refusal, bare: true, answer: { roots: [] } })).toBe(false);
99
+ expect(refusalHoldsScene({ refusal, bare: true, answer: { estateScene: { roots: [{ path: "a", resources: [] }] } } })).toBe(false);
100
+ expect(refusalHoldsScene({ refusal, bare: true, answer: { error: "x", ...scene } })).toBe(false);
101
+ expect(refusalHoldsScene({ refusal, bare: true, answer: null })).toBe(false);
102
+ expect(refusalHoldsScene({ refusal, bare: false, answer: scene })).toBe(false);
103
+ expect(refusalHoldsScene({ refusal: null, bare: true, answer: scene })).toBe(false);
104
+ });
105
+ });
@@ -0,0 +1,197 @@
1
+ // behold#937: the graph frame's half of a step's lighting (web/kiosk-light.js decides).
2
+ // Draws, over the terragucci marks the frame already has:
3
+ // - lit and dimmed cards, the edges between lit cards at full weight (the `q`
4
+ // view's look, #913, under its own `data-kl` marks so a query's repaint
5
+ // never clears them), and a one-time pulse on what lit;
6
+ // - each root's state file and its "written" mark, in one of three looks
7
+ // (applied, partly applied, not applied);
8
+ // - at most two attribute lines on a card: a value read from another estate ("known after apply", dashed amber,
9
+ // until its producer applied, then the real value in green), or a known value that changed; no other attribute;
10
+ // - the ghosted "plan again, approve again" approval, struck through;
11
+ // - the resource's name first on its card, its type second.
12
+ // All of it is removed and drawn again on each call, so a redraw of the marks is harmless.
13
+
14
+ import { cardLines, cardTitle, lineState, planOf, rootsOf, stateMarks, stateWords } from "./kiosk-light.js";
15
+
16
+ const NS = "http://www.w3.org/2000/svg";
17
+ const make = (tag, attrs, text) => {
18
+ const n = document.createElementNS(NS, tag);
19
+ for (const [k, v] of Object.entries(attrs || {})) n.setAttribute(k, String(v));
20
+ if (text !== undefined) n.textContent = text;
21
+ return n;
22
+ };
23
+
24
+ /** Take back what the last call drew or changed. */
25
+ export function clearLight(svg) {
26
+ if (!svg) return;
27
+ for (const el of svg.querySelectorAll("[data-kl-layer]")) el.remove();
28
+ for (const el of svg.querySelectorAll("[data-kl]")) el.removeAttribute("data-kl");
29
+ for (const el of svg.querySelectorAll("[data-kl-pulse]")) el.removeAttribute("data-kl-pulse");
30
+ }
31
+
32
+ /**
33
+ * Draw a step's lighting. `msg` is the last `behold:light` message (or null),
34
+ * `answer` and `progress` the frame's reads (the paced run view), and `h` the
35
+ * frame's helpers: `{ cardsOf(root), rootBox(root), compMode, pulsed }`.
36
+ * `pulsed` is a `{ token }` box kept between calls so a beat pulses once.
37
+ */
38
+ export function drawLight(svg, msg, answer, progress, h) {
39
+ clearLight(svg);
40
+ if (!svg || !msg || !answer || answer.error || !Array.isArray(answer.roots)) return;
41
+ const plan = planOf(answer, progress);
42
+ const layer = make("g", { "data-kl-layer": "1", "pointer-events": "none" });
43
+ svg.appendChild(layer);
44
+
45
+ // Cards lead with the resource's name, its type second.
46
+ if (!h.compMode) nameFirst(svg, plan);
47
+
48
+ // Lit and dimmed.
49
+ if (msg.lit) {
50
+ const lit = new Set(msg.ids);
51
+ const litRoots = new Set(msg.roots);
52
+ const cards = [...svg.querySelectorAll("[data-node-id]")];
53
+ const isLit = (g) => (h.compMode ? litRoots.has(rootOfCard(answer, g.getAttribute("data-node-id"), h)) : lit.has(g.getAttribute("data-node-id")));
54
+ const fresh = h.pulsed && h.pulsed.token !== msg.token;
55
+ for (const g of cards) {
56
+ const on = isLit(g);
57
+ g.setAttribute("data-kl", on ? "lit" : "dim");
58
+ if (on && fresh) g.setAttribute("data-kl-pulse", "1");
59
+ }
60
+ if (h.pulsed) h.pulsed.token = msg.token;
61
+ const state = new Map(cards.map((g) => [g.getAttribute("data-node-id"), g.getAttribute("data-kl")]));
62
+ for (const e of svg.querySelectorAll("g[data-edge-from]")) {
63
+ e.setAttribute("data-kl", state.get(e.getAttribute("data-edge-from")) === "lit" && state.get(e.getAttribute("data-edge-to")) === "lit" ? "path" : "dim");
64
+ }
65
+ // The reads between roots: at full weight between two lit roots, dim otherwise.
66
+ for (const l of svg.querySelectorAll("line[data-tg-read-from]")) {
67
+ l.setAttribute("data-kl", litRoots.has(l.getAttribute("data-tg-read-from")) && litRoots.has(l.getAttribute("data-tg-read-to")) ? "path" : "dim");
68
+ }
69
+ } else if (h.pulsed) h.pulsed.token = msg.token;
70
+
71
+ if (msg.labels) {
72
+ drawStates(layer, answer, progress, h);
73
+ if (!h.compMode) drawSlots(layer, svg, plan, answer, progress, h, msg);
74
+ }
75
+ if (msg.ghost) drawGhost(layer, h);
76
+ }
77
+
78
+ function rootOfCard(answer, id, h) {
79
+ const r = (answer.roots || []).find((x) => h.cardsOf(x.path).some((g) => g.getAttribute("data-node-id") === id));
80
+ return r ? r.path : null;
81
+ }
82
+
83
+ function nameFirst(svg, plan) {
84
+ const byCard = new Map([...plan.resources.values()].filter((r) => r.cardId).map((r) => [r.cardId, r]));
85
+ for (const g of svg.querySelectorAll("[data-node-id]")) {
86
+ const res = byCard.get(g.getAttribute("data-node-id"));
87
+ if (!res || !res.type) continue;
88
+ const texts = [...g.querySelectorAll(":scope > text")];
89
+ const title = texts.find((t) => t.getAttribute("visibility") !== "hidden" && (t.textContent || "").trim());
90
+ if (!title) continue;
91
+ const { name, type } = cardTitle(res.address);
92
+ title.textContent = name;
93
+ // The kind line the kiosk hides ("terraform_data · terraform") becomes the type, second.
94
+ const kind = texts.find((t) => t.hasAttribute("data-kiosk-quiet") && / · /.test(t.textContent || ""));
95
+ if (kind) {
96
+ kind.textContent = type;
97
+ kind.removeAttribute("visibility");
98
+ kind.setAttribute("data-kl", "type");
99
+ }
100
+ }
101
+ }
102
+
103
+ /** Each root's state file label, with its written mark and its look. */
104
+ function drawStates(layer, answer, progress, h) {
105
+ const marks = stateMarks(answer, progress);
106
+ for (const r of rootsOf(answer)) {
107
+ const m = marks[r.path];
108
+ // behold#940: a label rides inside its box's own group when the graph has one, so it moves, grows and reflows with the box.
109
+ const host = h.boxHost ? h.boxHost(r.path) : null;
110
+ const box = host || h.rootBox(r.path);
111
+ if (!m || !box) continue;
112
+ // behold#939: a prompt-driven step draws the roots' resources, which fill their boxes: the label goes under the box, off the cards.
113
+ const y = h.below ? box.y2 + 26 : box.y2 - 12;
114
+ const g = make("g", { "data-kl-state": r.path, "data-kl-look": m.look || "none", "pointer-events": "none" });
115
+ if (host) g.setAttribute("data-kl-layer", "1");
116
+ const words = stateWords(m);
117
+ if (!words) continue; // an estate with nothing decided yet: its box's title already names it
118
+ const w = Math.max(120, words.length * 7.4 + 20);
119
+ const x = box.x + 14;
120
+ const rect = make("rect", { x, y: y - 17, width: w, height: 22, rx: 4, fill: "var(--panel, var(--bg))", stroke: "var(--frame-neutral, var(--neutral))", "stroke-width": 1.5 });
121
+ // Three looks, by shape as well as colour: solid is applied, half filled with a dashed edge is partly applied, hollow dotted is not applied.
122
+ let ink = "var(--fg)";
123
+ if (m.look === "applied") {
124
+ rect.setAttribute("fill", "var(--frame-managed, var(--managed))");
125
+ rect.setAttribute("stroke", "var(--frame-managed, var(--managed))");
126
+ ink = "var(--bg)";
127
+ g.appendChild(rect);
128
+ } else if (m.look === "partial") {
129
+ rect.setAttribute("stroke", "var(--frame-pending, var(--pending))");
130
+ rect.setAttribute("stroke-dasharray", "6 3");
131
+ g.appendChild(rect);
132
+ g.appendChild(make("rect", { x, y: y - 17, width: w / 2, height: 22, rx: 4, fill: "var(--frame-pending, var(--pending))", opacity: 0.45 }));
133
+ } else if (m.look === "not-applied") {
134
+ rect.setAttribute("stroke-dasharray", "2 3");
135
+ rect.setAttribute("fill", "none");
136
+ g.appendChild(rect);
137
+ ink = "var(--muted)";
138
+ } else g.appendChild(rect);
139
+ g.appendChild(make("text", { x: x + 10, y: y - 1.5, "font-size": 13, "font-weight": 700, fill: ink }, words));
140
+ g.appendChild(make("title", {}, m.estate ? `${r.path} is an estate: it keeps records, not a state file${m.written ? "; the apply wrote them" : ""}` : `${r.path}'s state file is ${m.file}${m.from === "path" ? " (named from the root's path)" : ""}${m.written ? "; the apply wrote it" : ""}`));
141
+ (host ? host.parent : layer).appendChild(g);
142
+ }
143
+ }
144
+
145
+ /** A card's attribute lines (web/kiosk-light.js cardLines): unknown dashed amber, applied or changed solid. */
146
+ function drawSlots(layer, svg, plan, answer, progress, h, msg) {
147
+ const byCard = new Map();
148
+ for (const s of cardLines(plan, msg && msg.light)) {
149
+ if (!byCard.has(s.cardId)) byCard.set(s.cardId, []);
150
+ byCard.get(s.cardId).push(s);
151
+ }
152
+ for (const [id, slots] of byCard) {
153
+ const card = svg.querySelector(`[data-node-id="${CSS.escape(id)}"]`);
154
+ const rect = card && card.querySelector(":scope > rect");
155
+ if (!rect) continue;
156
+ const b = rect.getBBox();
157
+ slots.forEach((s, i) => {
158
+ const st = lineState(s, answer, progress);
159
+ const words = st.text;
160
+ // behold#940: a card the scene drew (data-kl-synth) has room under it for its lines, in bigger type; a graph card's hang over its foot.
161
+ const synth = card.hasAttribute("data-kl-synth");
162
+ const size = synth ? 14 : 11.5;
163
+ // One line, inside the card: a long value ends in an ellipsis.
164
+ const fit = Math.max(8, Math.floor((b.width - 28) / (size * 0.6)));
165
+ // A filled line's payoff is its end (the id the producer made): cut from the middle, and drop the attribute's name before the end.
166
+ const shown = words.length <= fit ? words : fit - 9 >= 14 ? `${words.slice(0, 6)}...${words.slice(words.length - (fit - 9))}` : `...${words.slice(words.length - (fit - 3))}`;
167
+ const w = synth ? b.width - 12 : Math.min(b.width - 12, Math.max(90, shown.length * 6.8 + 16));
168
+ const rowH = synth ? 22 : 18;
169
+ const y = synth ? b.y + b.height + 6 + rowH + i * 26 : b.y + b.height - 3 + i * 22;
170
+ const ink = st.state === "applied" ? "var(--frame-managed, var(--managed))" : "var(--frame-pending, var(--pending))";
171
+ const g = make("g", { "data-kl-slot": id, "data-kl-filled": st.state === "applied" ? "1" : "0", "data-kl-line": st.state });
172
+ g.setAttribute("transform", card.getAttribute("transform") || "");
173
+ // Unknown: a dashed amber outline with a hollow inside. Applied: solid green, tinted. A changed value: solid amber.
174
+ g.appendChild(make("rect", { x: b.x + 6, y: y - rowH, width: w, height: rowH, rx: 3, fill: st.state === "unknown" ? "var(--bg)" : ink, "fill-opacity": st.state === "unknown" ? 1 : 0.25, stroke: ink, "stroke-width": 1.5, "stroke-dasharray": st.state === "unknown" ? "4 3" : "none" }));
175
+ g.appendChild(make("text", { x: b.x + 12, y: y - (synth ? 6 : 5), "font-size": size, "font-weight": 600, fill: "var(--fg)" }, shown));
176
+ layer.appendChild(g);
177
+ });
178
+ }
179
+ }
180
+
181
+ /** The approval the change does not need: faded, between network and app, then struck through. */
182
+ function drawGhost(layer, h) {
183
+ const a = h.rootBox("network");
184
+ const b = h.rootBox("app");
185
+ if (!a || !b) return;
186
+ const cx = (a.x + a.x2 + b.x + b.x2) / 4;
187
+ const cy = (a.y + a.y2 + b.y + b.y2) / 4;
188
+ const words = "plan again, approve again";
189
+ const w = words.length * 8.6 + 28;
190
+ const g = make("g", { "data-kl-ghost": "1", opacity: 0.55 });
191
+ g.appendChild(make("rect", { x: cx - w / 2, y: cy - 16, width: w, height: 32, rx: 6, fill: "var(--panel, var(--bg))", stroke: "var(--frame-foreign, var(--foreign))", "stroke-width": 2, "stroke-dasharray": "6 4" }));
192
+ g.appendChild(make("text", { x: cx, y: cy + 5, "text-anchor": "middle", "font-size": 15, "font-weight": 600, fill: "var(--fg)" }, words));
193
+ // The strike draws itself after the approval has been on screen a moment.
194
+ const strike = make("line", { x1: cx - w / 2 + 6, y1: cy, x2: cx + w / 2 - 6, y2: cy, stroke: "var(--frame-degraded, var(--degraded))", "stroke-width": 3, class: "kl-strike", pathLength: 1 });
195
+ g.appendChild(strike);
196
+ layer.appendChild(g);
197
+ }