@seikika/astro-report 0.0.0-stage → 0.1.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.
@@ -0,0 +1,290 @@
1
+ import type { Summary } from "./summary";
2
+ import type { ReportData } from "../types";
3
+ import { levelName } from "./campaigns";
4
+ import { el, svg } from "./dom";
5
+ import { LEVEL_NOTE, ONLY_LEVEL, fill, ink, known } from "./levels";
6
+ import { title } from "./rings";
7
+ import { ruleTitleOf } from "./rules";
8
+ import { andList, fmt, plural } from "./words";
9
+
10
+ export function levelOrder(levels) {
11
+ return ["none"].concat(levels || [], ["skipped"]);
12
+ }
13
+
14
+ // One segment of a level bar: entities at a level, split out when the level may not hold.
15
+ export interface Part {
16
+ level: string;
17
+ n: number;
18
+ unrun?: boolean;
19
+ hollow?: boolean;
20
+ }
21
+
22
+ export function tallyLevels(rows: [string, { level: string }][], order: string[]): Part[] {
23
+ var tally = {};
24
+ rows.forEach(function (pair) {
25
+ tally[pair[1].level] = (tally[pair[1].level] || 0) + 1;
26
+ });
27
+ return order
28
+ .filter(function (l) {
29
+ return tally[l];
30
+ })
31
+ .map(function (l) {
32
+ return { level: l, n: tally[l] };
33
+ });
34
+ }
35
+
36
+ // Grow from zero on the next frame so a re-render reads as movement, not a jump.
37
+ export function grow(nodes, targets) {
38
+ requestAnimationFrame(function () {
39
+ requestAnimationFrame(function () {
40
+ nodes.forEach(function (n, i) {
41
+ n.style.flexGrow = targets[i];
42
+ });
43
+ });
44
+ });
45
+ }
46
+
47
+ // Skipped entities are outside a scorecard's scope, so they take no length in a bar.
48
+ export function barEl(all, cls?, label?) {
49
+ var parts = all.filter(function (p) {
50
+ return p.level !== "skipped";
51
+ });
52
+ var spans = parts.map(function (p) {
53
+ return p.hollow
54
+ ? el("span", { className: "hollow", style: "flex-grow:0;flex-basis:0;--seg:" + fill(p.level), title: (p.label || p.level) + ": " + p.n + ", not assessed by an agent yet" })
55
+ : p.unrun
56
+ ? el("span", { className: "unrun", style: "flex-grow:0;flex-basis:0;--seg:" + fill(p.level), title: (p.label || p.level) + ": " + p.n + ", provisional: checks it needs were not run in this build" })
57
+ : p.level === "unscored"
58
+ ? el("span", { className: "unscored", style: "flex-grow:0;flex-basis:0", title: "not scored: " + p.n })
59
+ : el("span", { style: "flex-grow:0;flex-basis:0;background:" + fill(p.level), title: (p.label || p.level) + ": " + p.n });
60
+ });
61
+ grow(
62
+ spans,
63
+ parts.map(function (p) {
64
+ return p.n;
65
+ }),
66
+ );
67
+ var bar = el("div", { className: "bar" + (cls ? " " + cls : "") }, ...spans);
68
+ bar.setAttribute("role", "img");
69
+ bar.setAttribute(
70
+ "aria-label",
71
+ label ||
72
+ parts
73
+ .map(function (p) {
74
+ return p.n + " " + (p.label || p.level) + (p.hollow ? " not assessed" : p.unrun ? " provisional" : "");
75
+ })
76
+ .join(", ") ||
77
+ "no entities scored yet",
78
+ );
79
+ return bar;
80
+ }
81
+
82
+ // A scorecard's level parts with the entities no agent has assessed split out, so a bar draws them hollow.
83
+ // The level key above a scorecard table, with the hatched swatch when any row draws one.
84
+ export function levelLegend(D: ReportData, rows) {
85
+ var hollow = (rows || []).some(function (r) {
86
+ return !r.compare && unassessedOf(D, r.name);
87
+ });
88
+ var unrun = (rows || []).some(function (r) {
89
+ return !r.compare && provisionalOf(D, r.name);
90
+ });
91
+ // Only the levels some scorecard here defines, so a portal that stops at bronze shows no silver or gold.
92
+ var used = new Set();
93
+ // A scorecard's own level names ("within-limit", "ten") take the colour of the metal they rank as.
94
+ var own: Record<string, string[]> = {};
95
+ (rows || []).forEach(function (r) {
96
+ if (!r.compare)
97
+ ((r.sc || {}).levels || []).forEach(function (l) {
98
+ var metal = known(l) || "gold";
99
+ used.add(metal);
100
+ if (known(l) && l !== metal && (own[metal] || (own[metal] = [])).indexOf(l) < 0) own[metal].push(l);
101
+ });
102
+ });
103
+ return el(
104
+ "div",
105
+ { className: "legend", style: "margin-bottom:8px" },
106
+ ...["none", "bronze", "silver", "gold"]
107
+ .filter(function (l) {
108
+ return l === "none" || !used.size || used.has(l);
109
+ })
110
+ .map(function (l) {
111
+ var names = (own[l] || []).sort();
112
+ return el("span", {}, el("span", { className: "dot", style: "background:" + fill(l) }), l + (names.length ? ", or a scorecard's own level ranked as " + l + ": " + names.map(function (n) {
113
+ return "“" + n + "”";
114
+ }).join(", ") : ""));
115
+ }),
116
+ hollow ? el("span", {}, el("span", { className: "dot hatch", style: "--seg:" + fill("bronze") }), "hatched, on a bar or a pill: not assessed by an agent yet") : null,
117
+ unrun ? el("span", {}, el("span", { className: "dot dots", style: "--seg:" + fill("silver") }), "◌ dotted, or on a pill: provisional, checks not run in this build") : null,
118
+ );
119
+ }
120
+
121
+ export function splitUnassessed(D: ReportData, name, parts: Part[]) {
122
+ var ids = (D.unassessed || {})[name] || [];
123
+ var sc = (D.scorecards || {})[name];
124
+ var rows = (D.scores || {})[name] || {};
125
+ var unassessed = new Set(ids);
126
+ var by = new Map();
127
+ var unrunBy = new Map();
128
+ Object.keys(rows).forEach(function (id) {
129
+ var s = rows[id];
130
+ if (!s || s.level === "skipped") return;
131
+ if (unassessed.has(id)) by.set(s.level, (by.get(s.level) || 0) + 1);
132
+ else if (unrunIn(sc, s).length) unrunBy.set(s.level, (unrunBy.get(s.level) || 0) + 1);
133
+ });
134
+ var out: Part[] = [];
135
+ parts.forEach(function (p) {
136
+ var u = Math.min(by.get(p.level) || 0, p.n);
137
+ var r = Math.min(unrunBy.get(p.level) || 0, p.n - u);
138
+ if (p.n - u - r) out.push({ level: p.level, n: p.n - u - r });
139
+ if (r) out.push({ level: p.level, n: r, unrun: true });
140
+ if (u) out.push({ level: p.level, n: u, hollow: true });
141
+ });
142
+ return out;
143
+ }
144
+
145
+ // A kind's entities by their weakest level, with the levels that may not hold split out as in a scorecard bar.
146
+ export function kindParts(S: Summary, ids) {
147
+ var tally = new Map();
148
+ ids.forEach(function (id) {
149
+ var key = (S.worst[id] || "unscored") + "|" + (S.worst[id] ? S.worstState.get(id) || "" : "");
150
+ tally.set(key, (tally.get(key) || 0) + 1);
151
+ });
152
+ var out: Part[] = [];
153
+ ["none", "bronze", "silver", "gold", "unscored"].forEach(function (l) {
154
+ ["", "unrun", "hollow"].forEach(function (st) {
155
+ var n = tally.get(l + "|" + st);
156
+ if (n) out.push({ level: l, n: n, unrun: st === "unrun", hollow: st === "hollow" });
157
+ });
158
+ });
159
+ return out;
160
+ }
161
+
162
+ export function unassessedOf(D: ReportData, name) {
163
+ var rows = (D.scores || {})[name] || {};
164
+ return ((D.unassessed || {})[name] || []).filter(function (id) {
165
+ return rows[id] && rows[id].level !== "skipped";
166
+ }).length;
167
+ }
168
+
169
+ export function legendEl(parts) {
170
+ return el(
171
+ "div",
172
+ { className: "legend" },
173
+ ...parts.map(function (p) {
174
+ if (p.level === "skipped") return el("span", {}, el("b", { textContent: fmt(p.n) }), " not in scope");
175
+ if (p.level === "unscored") return el("span", {}, el("span", { className: "dot unscored" }), el("b", { textContent: fmt(p.n) }), " not scored");
176
+ return el(
177
+ "span",
178
+ {},
179
+ el("span", { className: "dot" + (p.hollow ? " hatch" : p.unrun ? " dots" : ""), style: p.hollow || p.unrun ? "--seg:" + fill(p.level) : "background:" + fill(p.level) }),
180
+ el("b", { textContent: fmt(p.n) }),
181
+ " " + (p.label || p.level) + (p.hollow ? " not assessed" : p.unrun ? " ◌ provisional" : ""),
182
+ );
183
+ }),
184
+ );
185
+ }
186
+
187
+ export function badge(level) {
188
+ var only = ONLY_LEVEL.has(level);
189
+ var span = el("span", { className: "lvl " + level, style: "--fill:" + fill(level) + ";--ink:" + ink(level) }, el("i"), level === "skipped" ? "not in scope" : level, only ? el("span", { className: "lvl-top", ariaHidden: "true", textContent: " ✓ top" }) : null);
190
+ span.setAttribute("aria-label", level === "skipped" ? "not in this scorecard's scope" : "level " + level + (only ? ", its scorecard's only and top level" : ""));
191
+ if (LEVEL_NOTE[level]) span.title = LEVEL_NOTE[level];
192
+ return span;
193
+ }
194
+
195
+ // An agent-judged level with no assessment behind it is drawn dashed, the same everywhere it is shown.
196
+ // Checks at or below an entity's level that were not run in this build: the level holds only if they pass.
197
+ export function unrunIn(sc, score) {
198
+ var order = (sc && sc.levels) || [];
199
+ var here = order.indexOf(score.level);
200
+ return Object.keys(score.rules || {}).filter(function (r) {
201
+ return score.rules[r] === "unknown" && order.indexOf(((sc.rules || {})[r] || {}).level) <= here;
202
+ });
203
+ }
204
+
205
+ // How many in-scope entities of a scorecard hold a level that rests on checks not run in this build.
206
+ export function provisionalOf(D: ReportData, name) {
207
+ var sc = (D.scorecards || {})[name];
208
+ var rows = (D.scores || {})[name] || {};
209
+ return Object.keys(rows).filter(function (id) {
210
+ return rows[id].level !== "skipped" && unrunIn(sc, rows[id]).length > 0;
211
+ }).length;
212
+ }
213
+
214
+ // A level that may not hold is dashed everywhere it is drawn, with the reason beside it. `quiet`
215
+ // keeps the outline but drops the tag, for a column whose header already says it once.
216
+ // "2 checks were not run in this build: A and B, both needed for bronze."
217
+ export function unrunWords(sc, names) {
218
+ var lv = names.map(function (n) {
219
+ return ((sc.rules || {})[n] || {}).level;
220
+ });
221
+ var same = lv.every(function (l) {
222
+ return l === lv[0];
223
+ });
224
+ var list = same
225
+ ? andList(names.map(function (n) {
226
+ return ruleTitleOf(sc, n);
227
+ })) + (lv[0] ? (names.length === 1 ? ", needed for " : names.length === 2 ? ", both needed for " : ", all needed for ") + levelName(lv[0]) : "")
228
+ : andList(names.map(function (n, i) {
229
+ return ruleTitleOf(sc, n) + (lv[i] ? " (" + levelName(lv[i]) + ")" : "");
230
+ }));
231
+ return plural(names.length, "check") + " " + (names.length === 1 ? "was" : "were") + " not run in this build: " + list + ".";
232
+ }
233
+
234
+ export function levelPill(level, unassessed, unrun, quiet?) {
235
+ var pill = badge(level);
236
+ if (!unassessed && !(unrun && unrun.length)) return pill;
237
+ pill.classList.add("vacuous", unassessed ? "unjudged" : "unrun");
238
+ pill.append(unassessed ? el("span", { className: "vhatch", ariaHidden: "true" }) : el("span", { className: "vglyph", ariaHidden: "true", textContent: " ◌" }));
239
+ var why = unassessed
240
+ ? "No agent has assessed this entity, so its agent-judged rules have nothing to read: this level is provisional"
241
+ : plural(unrun.length, "check") + " this level needs " + (unrun.length === 1 ? "was" : "were") + " not run in this build (" + unrun.join(", ") + "): the level holds only if " + (unrun.length === 1 ? "it passes" : "they pass");
242
+ pill.setAttribute("aria-label", "level " + level + ", " + (unassessed ? "not assessed" : "provisional"));
243
+ if (quiet) return el("span", { className: "pillwrap", title: why }, pill, el("span", { className: "unassessed-tag quiet" + (unassessed ? "" : " unrun"), ariaHidden: "true" }, unassessed ? " not assessed" : "provisional: not run"));
244
+ return el("span", { className: "pillwrap", title: why }, pill, el("span", { className: "unassessed-tag" + (unassessed ? "" : " unrun"), ariaHidden: "true" }, unassessed ? el("span", { className: "vhatch", ariaHidden: "true" }) : null, unassessed ? " not assessed" : "provisional: not run"));
245
+ }
246
+
247
+ export function medal(level, size) {
248
+ var s = size || 56;
249
+ var none = level === "none" || !known(level);
250
+ var c = fill(level);
251
+ var g = svg(
252
+ "svg",
253
+ { width: s, height: s, viewBox: "0 0 56 56", "aria-hidden": "true" },
254
+ svg("path", { d: "M18 4h8l-4 22h-8z", fill: none ? "var(--line)" : "var(--accent)", opacity: ".85" }),
255
+ svg("path", { d: "M30 4h8l2 22h-8z", fill: none ? "var(--line)" : "var(--accent)", opacity: ".6" }),
256
+ svg("circle", {
257
+ cx: 28,
258
+ cy: 34,
259
+ r: 17,
260
+ fill: none ? "var(--card)" : c,
261
+ stroke: none ? "var(--muted)" : c,
262
+ "stroke-width": none ? 2.5 : 0,
263
+ "stroke-dasharray": none ? "4 3" : "",
264
+ }),
265
+ none ? null : svg("circle", { cx: 28, cy: 34, r: 12, fill: "none", stroke: "#fff", "stroke-opacity": ".55", "stroke-width": 1.5 }),
266
+ level === "not scored"
267
+ ? svg("text", { x: 28, y: 41, "text-anchor": "middle", "font-size": 20, "font-weight": 700, fill: "var(--muted)", "font-family": "inherit" }, "?")
268
+ : none
269
+ ? null
270
+ : ONLY_LEVEL.has(level)
271
+ ? svg("path", { d: "M21 34.5l5 5 9.5-10", fill: "none", stroke: "#fff", "stroke-opacity": ".9", "stroke-width": 3.2, "stroke-linecap": "round", "stroke-linejoin": "round" })
272
+ : svg("path", {
273
+ d: "M28 26.5l2.3 4.7 5.2.8-3.8 3.7.9 5.1-4.6-2.4-4.6 2.4.9-5.1-3.8-3.7 5.2-.8z",
274
+ fill: "#fff",
275
+ "fill-opacity": ".8",
276
+ }),
277
+ );
278
+ return g;
279
+ }
280
+
281
+ export function boxLogo() {
282
+ return svg(
283
+ "svg",
284
+ { width: 34, height: 34, viewBox: "0 0 34 34", "aria-hidden": "true" },
285
+ svg("rect", { x: 3, y: 11, width: 28, height: 19, rx: 4, fill: "var(--accent)" }),
286
+ svg("path", { d: "M12 11V8a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v3", fill: "none", stroke: "var(--accent)", "stroke-width": 2.4 }),
287
+ svg("rect", { x: 3, y: 17, width: 28, height: 3, fill: "var(--card)", opacity: ".35" }),
288
+ svg("rect", { x: 14.5, y: 15.5, width: 5, height: 6, rx: 1.2, fill: "var(--gold)" }),
289
+ );
290
+ }
@@ -0,0 +1,157 @@
1
+ import { badge } from "./bars";
2
+ import { el, link, svg } from "./dom";
3
+ import { fill } from "./levels";
4
+ import { title } from "./rings";
5
+ import { rich } from "./text";
6
+ import { plural } from "./words";
7
+
8
+ export var BASIS = {
9
+ measured: {
10
+ label: "Tool-checked",
11
+ desc: "A tool, connector or script decides it from the facts it reads. The same input gives the same result.",
12
+ },
13
+ judged: {
14
+ label: "Agent-judged",
15
+ desc: "Passes on an agent's written assessment against a rubric, reviewed by a second agent; whether that assessment exists and holds counts too. It changes when a verdict does.",
16
+ },
17
+ };
18
+
19
+ export function basisIcon(b) {
20
+ if (b === "judged")
21
+ return svg("svg", { width: 12, height: 12, viewBox: "0 0 12 12", "aria-hidden": "true" }, svg("path", { d: "M6 .6l1.5 3.8 3.9 1.6-3.9 1.6L6 11.4 4.5 7.6.6 6l3.9-1.6z", fill: "currentColor" }));
22
+ return svg(
23
+ "svg",
24
+ { width: 12, height: 12, viewBox: "0 0 12 12", "aria-hidden": "true" },
25
+ svg("path", { d: "M1.4 9.2a4.6 4.6 0 0 1 9.2 0", fill: "none", stroke: "currentColor", "stroke-width": 1.6, "stroke-linecap": "round" }),
26
+ svg("path", { d: "M6 9.2l2.3-3.3", stroke: "currentColor", "stroke-width": 1.6, "stroke-linecap": "round" }),
27
+ svg("circle", { cx: 6, cy: 9.2, r: 1.2, fill: "currentColor" }),
28
+ );
29
+ }
30
+
31
+ export function lockIcon() {
32
+ return svg(
33
+ "svg",
34
+ { width: 12, height: 12, viewBox: "0 0 12 12", "aria-hidden": "true" },
35
+ svg("rect", { x: 2, y: 5.2, width: 8, height: 6, rx: 1.2, fill: "currentColor" }),
36
+ svg("path", { d: "M3.8 5.2V3.8a2.2 2.2 0 0 1 4.4 0v1.4", fill: "none", stroke: "currentColor", "stroke-width": 1.4 }),
37
+ );
38
+ }
39
+
40
+ export function basisOf(rule) {
41
+ return (rule || {}).basis === "judged" ? "judged" : "measured";
42
+ }
43
+
44
+ export function basisBadge(b, mini?, inControl?) {
45
+ // Mini badges sit inside links and dense rows: the same word, smaller, joins the row's accessible name
46
+ // rather than adding a focus stop of its own, and the page's key explains it in full.
47
+ // A mini badge outside any link ("tip") is its own focus stop, so its meaning opens on focus or tap.
48
+ if (mini === "tip") {
49
+ var tip = el("span", { className: "basis tip " + b + " mini", tabIndex: 0 }, basisIcon(b), el("span", { className: "bl", textContent: BASIS[b].label }), el("span", { className: "sr", textContent: ": " + BASIS[b].desc }));
50
+ tip.dataset.tip = BASIS[b].label + ": " + BASIS[b].desc;
51
+ return tip;
52
+ }
53
+ var quiet = mini
54
+ ? el("span", { className: "basis " + b + " mini" }, basisIcon(b), el("span", {}, el("span", { className: "sr", textContent: " (" }), el("span", { className: "bl", textContent: BASIS[b].label }), el("span", { className: "sr", textContent: ")" })))
55
+ : inControl
56
+ ? el("span", { className: "basis ctl " + b }, basisIcon(b), el("span", { className: "sr", textContent: " (" }), el("span", { className: "bl", textContent: BASIS[b].label }), el("span", { className: "sr", textContent: ")" }))
57
+ : null;
58
+ if (quiet) {
59
+ quiet.dataset.tip = BASIS[b].label + ": " + BASIS[b].desc;
60
+ return quiet;
61
+ }
62
+ // A full badge stands on its own, so keyboard and touch readers can open what it means.
63
+ var full = el("span", { className: "basis tip " + b, tabIndex: 0 }, basisIcon(b), BASIS[b].label, el("span", { className: "sr", textContent: ": " + BASIS[b].desc }));
64
+ full.dataset.tip = BASIS[b].desc;
65
+ return full;
66
+ }
67
+
68
+ // One basis for every rule: the badge and its count, in the line that says what the scorecard rates.
69
+ export function basisInline(counts, noun?) {
70
+ var only = counts && (counts.measured || 0) + (counts.judged || 0) > 0 && !(counts.measured && counts.judged) ? (counts.measured ? "measured" : "judged") : null;
71
+ if (!only) return null;
72
+ return el(
73
+ "span",
74
+ { className: "basis-inline" },
75
+ " · ",
76
+ basisBadge(only),
77
+ " " + (counts[only] === 1 ? "its one " + (noun || "rule") : "all " + plural(counts[only], noun || "rule")),
78
+ only === "judged" ? ": an agent's assessment is the evidence, so whether one exists and still holds counts too" : null,
79
+ );
80
+ }
81
+
82
+ // What the two badges mean, with how many rules (or checks) each covers when counts are given.
83
+ export function basisKey(counts, noun?) {
84
+ var row = function (b) {
85
+ var n = counts ? counts[b] || 0 : null;
86
+ return el("div", {}, basisBadge(b), el("span", {}, n != null ? el("b", { textContent: plural(n, noun || "rule") + ". " }) : null, BASIS[b].desc));
87
+ };
88
+ var only = counts && (counts.measured || 0) + (counts.judged || 0) > 0 && !(counts.measured && counts.judged) ? (counts.measured ? "measured" : "judged") : null;
89
+ // One basis only: say so in a line, and name the other so its absence is visible.
90
+ var k = only
91
+ ? el("div", { className: "basis-key one" }, el("div", {}, basisBadge(only), el("span", {}, el("b", { textContent: (counts[only] === 1 ? "" : "All ") + plural(counts[only], noun || "rule") + ". " }), BASIS[only].desc + " None here is " + BASIS[only === "measured" ? "judged" : "measured"].label.toLowerCase() + ".")))
92
+ : el("div", { className: "basis-key" }, row("measured"), row("judged"));
93
+ k.setAttribute("role", "note");
94
+ k.setAttribute("aria-label", "How a rule is decided");
95
+ return k;
96
+ }
97
+
98
+ export function basisCounts(rules) {
99
+ var n = { measured: 0, judged: 0 };
100
+ Object.keys(rules || {}).forEach(function (r) {
101
+ n[basisOf(rules[r])]++;
102
+ });
103
+ return n;
104
+ }
105
+
106
+ export function refs(links, lead: string | false = "Further reading") {
107
+ var safe = (links || []).filter(function (l) {
108
+ return l && /^https?:\/\//.test(l.url || "");
109
+ });
110
+ if (!safe.length) return null;
111
+ // Name where the links lead, so a portal built from shared packages does not pass off a
112
+ // package's own docs as its own.
113
+ var sources = Array.from(new Set(safe.map(function (l) {
114
+ var u = /^https?:\/\/([^/]+)\/?([^/]*)\/?([^/]*)/.exec(l.url) || [];
115
+ return u[1] === "github.com" && u[2] && u[3] ? u[2] + "/" + u[3] : u[1] || "";
116
+ })));
117
+ return el(
118
+ "span",
119
+ { className: "refs" },
120
+ lead === false ? null : el("span", { className: "sub", textContent: lead + (sources.length === 1 && sources[0] ? ", from " + sources[0] : "") + ":" }),
121
+ ...safe.map(function (l) {
122
+ // A title that leads with a decision id reads as its claim; the id stays in the hover text.
123
+ var m = /^(D\d+|D0[0-9A-Z]{20,}) (.+)$/.exec(l.title || "");
124
+ var a = el("a", { href: l.url, target: "_blank", rel: "noopener" }, el("span", {}, m ? "Decision: " + m[2] : l.title || l.url, el("span", { className: "ext", ariaHidden: "true", textContent: "\u00a0\u2197" })));
125
+ if (m) a.title = m[1] + ": " + m[2];
126
+ return a;
127
+ }),
128
+ );
129
+ }
130
+
131
+ export function evidenceEl(items, seen, rule) {
132
+ if (!items.length) return "";
133
+ var text = function (i) {
134
+ return typeof i === "string" ? i : JSON.stringify(i);
135
+ };
136
+ var key = items.map(text).join("\n");
137
+ if (seen && seen[key]) return el("p", { className: "sub", textContent: "Evidence: the same as for " + seen[key] + ", above." });
138
+ if (seen) seen[key] = rule;
139
+ var li = function (i) {
140
+ var off = typeof i === "string" && /^no data from connector (\S+)$/.exec(i);
141
+ if (off) return el("li", { className: "sub" }, "Not measured: the ", el("code", { textContent: off[1] }), " connector did not run in this build, so the facts this check reads are missing.");
142
+ return el("li", {}, el("code", { textContent: text(i) }));
143
+ };
144
+ var SHOW = 3;
145
+ if (items.length <= SHOW + 1) return el("ul", { className: "evidence" }, ...items.map(li));
146
+ return el(
147
+ "div",
148
+ { className: "evidence" },
149
+ el("ul", {}, ...items.slice(0, SHOW).map(li)),
150
+ el("details", {}, el("summary", { textContent: "Show " + (items.length - SHOW) + " more" }), el("ul", {}, ...items.slice(SHOW, 50).map(li), items.length > 50 ? el("li", { textContent: "… and " + (items.length - 50) + " more" }) : null)),
151
+ );
152
+ }
153
+
154
+ export function whyEl(def, label?) {
155
+ if (!def || (!def.rationale && !(def.links || []).length)) return null;
156
+ return el("div", { className: "why" }, def.rationale ? el("b", { textContent: label || "Why: " }) : null, ...(def.rationale ? rich(def.rationale) : []), refs(def.links));
157
+ }