@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,639 @@
1
+ import type { ReportViews } from "../report-view";
2
+ import type { Summary } from "../lib/summary";
3
+ import type { ReportData } from "../types";
4
+ import { badge, barEl, levelLegend, medal, splitUnassessed, unrunIn } from "../lib/bars";
5
+ import { lockIcon } from "../lib/basis";
6
+ import { campaignStanding, campaignState, checkBar, goalBar, includeProgress, kpiPips, nextMedalEl, scCaption, stuckNote, verifiedMover } from "../lib/campaigns";
7
+ import { cardName, num } from "../lib/compare";
8
+ import { el, enc, link } from "../lib/dom";
9
+ import { kindCount, kindDescription, kindGroupsOf, kindTitle } from "../lib/kinds";
10
+ import { fill, ink, known } from "../lib/levels";
11
+ import { isTop, ring, shortId, title, topNote } from "../lib/rings";
12
+ import { LADDER, floorOf, floorPill, isComparative, ruleTitle } from "../lib/rules";
13
+ import { blockers, daysLeft } from "../lib/status";
14
+ import { campaignNamesSorted, healthVerdict, noFacts, share as shareOf } from "../lib/summary";
15
+ import { furthestTrack, trackStats, trackTitle, tracksSorted } from "../lib/tracks";
16
+ import { andList, fmt, plural, scPurpose } from "../lib/words";
17
+
18
+ // The entity furthest from its own top level, outside the standards that set the repository medal.
19
+ // The overview names it, with the rule that holds it, so a reader does not have to search the catalog.
20
+ function furthestOff(D: ReportData, S: Summary): { rank: number; id: string; name: string; rule: string | null; fails: boolean } | null {
21
+ var standards: Record<string, boolean> = {};
22
+ ((S.repo && S.repo.constituents) || []).forEach(function (c) {
23
+ standards[c.name] = true;
24
+ });
25
+ var best: { rank: number; id: string; name: string; rule: string | null; fails: boolean } | null = null;
26
+ Object.keys(D.scorecards || {}).forEach(function (name) {
27
+ if (standards[name] || isComparative(D, name)) return;
28
+ var sc = D.scorecards[name];
29
+ var levels = sc.levels || [];
30
+ var top = levels[levels.length - 1];
31
+ Object.keys((D.scores || {})[name] || {}).forEach(function (id) {
32
+ var score = D.scores[name][id];
33
+ if (!score || score.level === "skipped" || score.level === top) return;
34
+ var unrun = unrunIn(sc, score);
35
+ var idx = levels.indexOf(score.level);
36
+ var gap = idx < 0 ? levels.length : levels.length - 1 - idx;
37
+ if (unrun.length) gap += 1;
38
+ var fails = Object.keys(score.rules || {}).filter(function (k) {
39
+ return score.rules[k] === "fail";
40
+ });
41
+ var next = idx >= 0 ? levels[idx + 1] : top;
42
+ var held = next ? blockers(sc, score, next) : [];
43
+ var rule = (fails.length ? held[0] || fails[0] : unrun[0]) || null;
44
+ var rank = gap * 1000 + fails.length * 10 + unrun.length;
45
+ if (!best || rank > best.rank || (rank === best.rank && (id < best.id || (id === best.id && name < best.name))))
46
+ best = { rank: rank, id: id, name: name, rule: rule, fails: !!(rule && fails.indexOf(rule) >= 0) };
47
+ });
48
+ });
49
+ return best;
50
+ }
51
+
52
+ // Sections the navigation omits. The status card says so, the way a first run says nothing is scored.
53
+ function absentSections(D: ReportData, campaignNames) {
54
+ var missing: string[] = [];
55
+ if (!Object.keys(D.tracks || {}).length) missing.push("tracks");
56
+ if (!campaignNames.length) missing.push("campaigns");
57
+ if (!Object.keys(D.comparisons || {}).length) missing.push("a comparison");
58
+ if (!missing.length) return "";
59
+ var list = missing.length === 1 ? missing[0] : missing.slice(0, -1).join(", ") + " or " + missing[missing.length - 1];
60
+ return "This portal has no " + list + ", so " + (missing.length === 1 ? "that section is" : "those sections are") + " not in the navigation.";
61
+ }
62
+
63
+ // The weakest scorecard on these cards, when lifting it does not move the track.
64
+ function idleWhy(D: ReportData, cards) {
65
+ var lead = verifiedMover(D, cards);
66
+ var wk = cards[0] && cards[0].floor && !isTop(D, cards[0].row.name, cards[0].floor) ? cards[0] : null;
67
+ var track = wk && ((D.scorecards || {})[wk.row.name] || {}).track;
68
+ if (!lead || !wk || !track || lead.r.name === wk.row.name) return "";
69
+ return " " + title(D, wk.row.name) + " is the lowest level on this track and does not move it until those entities reach its top level.";
70
+ }
71
+
72
+ export const overviewViews = {
73
+ hero(D: ReportData, S: Summary, campaignNames) {
74
+ const R = S.repo;
75
+ var verdict = healthVerdict(D, S, campaignNames);
76
+ if (noFacts(S)) {
77
+ var start = el(
78
+ "section",
79
+ { className: "hero first-run" },
80
+ el(
81
+ "div",
82
+ {},
83
+ el("div", { className: "kicker", textContent: "First run" }),
84
+ el("h2", { className: "levelword", textContent: "Not scored yet" }),
85
+ el("p", { className: "verdict", textContent: "No connector has delivered facts, so no entity has a level." }),
86
+ el(
87
+ "div",
88
+ { className: "next" },
89
+ el("b", { textContent: "Next: " }),
90
+ "run ",
91
+ el("code", { textContent: "seikika doctor" }),
92
+ " in the repository to see which connector or tool is missing, then ",
93
+ el("code", { textContent: "seikika report" }),
94
+ " again. Connectors are listed under ",
95
+ el("code", { textContent: "connectors:" }),
96
+ " in the portal's ",
97
+ el("code", { textContent: "seikika.yaml" }),
98
+ ". The " + plural(S.rows.length, "scorecard") + " below will fill in.",
99
+ ),
100
+ absentSections(D, campaignNames) ? el("p", { className: "sub", style: "margin:8px 0 0", textContent: absentSections(D, campaignNames) }) : null,
101
+ ),
102
+ );
103
+ start.setAttribute("aria-label", "Status");
104
+ return start;
105
+ }
106
+ if (!R) {
107
+ var at = verdict.indexOf(": ");
108
+ var needs = at > 0 && verdict.indexOf("Needs") === 0;
109
+ var almost = at > 0 && verdict.indexOf("Almost") === 0;
110
+ var tone = needs ? "none" : almost ? "bronze" : "gold";
111
+ // The furthest track's lowest scorecard, as its track card names it; with no tracks, every scorecard's.
112
+ var far = furthestTrack(D, S);
113
+ var farCards = trackStats(D, S, far || undefined).cards;
114
+ var next = needs || almost ? nextMedalEl(D, farCards, "Next: ", idleWhy(D, farCards)) : null;
115
+ var plain = el("section", { className: "hero plain", style: "--lvl:" + fill(tone) + ";--lvl-ink:" + ink(tone) }, el("div", {}, el("div", { className: "kicker", textContent: "Status" }), el("h2", { className: "levelword", textContent: at > 0 ? verdict.slice(0, at) : verdict }), at > 0 ? el("p", { className: "verdict", textContent: verdict.slice(at + 2).replace(/^./, function (ch) { return ch.toUpperCase(); }) }) : null, next, S.rows.length ? el("p", { className: "sub", style: "margin:8px 0 0", textContent: "No overall level: this portal does not combine its scorecards into one level for the repository, so each scorecard stands on its own." }) : null, absentSections(D, campaignNames) ? el("p", { className: "sub", style: "margin:8px 0 0", textContent: absentSections(D, campaignNames) }) : null));
116
+ plain.setAttribute("aria-label", "Status");
117
+ return plain;
118
+ }
119
+ var level = R.floor;
120
+ var section = el("section", { className: "hero", style: "--lvl:" + fill(level) + ";--lvl-ink:" + ink(level) });
121
+ section.setAttribute("aria-label", "Status");
122
+ var holdingNames = R.holding.map(function (c) {
123
+ return title(D, c.name);
124
+ });
125
+ var rated = " The repository is rated by the weakest of its " + plural(R.constituents.length, "standard") + ".";
126
+ var sentence = R.next ? "Held at " + level + " by " + plural(R.holding.length, "standard") + ", listed below." + rated : "Every one of its " + plural(R.constituents.length, "standard") + " is at the top level.";
127
+ var wins = R.ladder
128
+ .slice()
129
+ .reverse()
130
+ .filter(function (l) {
131
+ return l !== "none" && l !== level;
132
+ })
133
+ .map(function (l) {
134
+ var n = R.constituents.filter(function (c) {
135
+ return c.level === l;
136
+ }).length;
137
+ return n ? plural(n, "standard") + " at " + l : null;
138
+ })
139
+ .filter(Boolean);
140
+ var capped = R.holding.filter(function (c) {
141
+ return c.level === c.top;
142
+ });
143
+ var liftNames = R.holding
144
+ .filter(function (c) {
145
+ return c.level !== c.top;
146
+ })
147
+ .map(function (c) {
148
+ return title(D, c.name);
149
+ });
150
+ if (R.next && capped.length)
151
+ // Lead with the cause: the capping standard is fully met, it just has no higher level to reach.
152
+ sentence =
153
+ "Capped at " +
154
+ level +
155
+ ": " +
156
+ capped
157
+ .map(function (c) {
158
+ return title(D, c.name);
159
+ })
160
+ .join(", ") +
161
+ (capped.length === 1 ? " is fully met, but its top level is " : " are fully met, but their top level is ") +
162
+ level +
163
+ ", so the repository cannot rise until " +
164
+ (capped.length === 1 ? "its owner adds" : "their owners add") +
165
+ " a " +
166
+ R.next +
167
+ " level." +
168
+ (liftNames.length ? " After that, " + plural(liftNames.length, "more standard needs", "more standards need") + " " + R.next + "." : "") +
169
+ rated;
170
+ var nextBox = !R.next
171
+ ? el("div", { className: "next" }, el("b", { textContent: "Top of the ladder. " }), "Every repository standard is at its highest level.")
172
+ : capped.length
173
+ ? null
174
+ : el("div", { className: "next" }, el("b", { textContent: "Next: " }), "reach ", badge(R.next), " by lifting " + plural(holdingNames.length, "standard") + " to " + R.next + ", listed below.");
175
+ var climb: HTMLElement | null = null;
176
+ if (R.next) {
177
+ var rank = function (l) {
178
+ return R.ladder.indexOf(l);
179
+ };
180
+ var there = R.constituents.filter(function (c) {
181
+ return rank(c.level) >= rank(R.next);
182
+ }).length;
183
+ var share = shareOf(there, R.constituents.length);
184
+ var bar = el("div", { className: "climb-bar" }, el("span", { style: "width:" + share + "%;background:" + ink(R.next) }));
185
+ bar.setAttribute("role", "img");
186
+ var blockedBy = capped.length
187
+ ? capped
188
+ .map(function (c) {
189
+ return title(D, c.name);
190
+ })
191
+ .join(", ")
192
+ : "";
193
+ bar.setAttribute("aria-label", there + " of " + R.constituents.length + " repository standards at " + R.next + " or above" + (blockedBy ? "; blocked until " + blockedBy + " gains a " + R.next + " level" : ""));
194
+ climb = el(
195
+ "div",
196
+ { className: "climb" + (blockedBy ? " blocked" : "") },
197
+ el("div", { className: "climb-head" }, el("span", {}, "Toward ", badge(R.next)), el("span", { className: "sub", textContent: there + " of " + R.constituents.length + " standards there (" + share + "%)" })),
198
+ blockedBy ? el("div", { className: "climb-track" }, bar, el("span", { className: "climb-lock", title: "No " + R.next + " level exists yet on " + blockedBy }, lockIcon(), " blocked by a missing level")) : bar, el(
199
+ "ul",
200
+ {},
201
+ ...R.holding.map(function (c) {
202
+ var stuck = c.level === c.top;
203
+ return el("li", { className: stuck ? "stuck" : "" }, el("span", { className: "mark", ariaHidden: "true", textContent: stuck ? "⊘" : "↑" }), el("span", {}, link("scorecard/" + enc(c.name), "", title(D, c.name)), stuck ? stuckNote(D, c.name, R.next) : el("span", { className: "sub", textContent: " lift from " + c.level + " to " + R.next })));
204
+ }),
205
+ ),
206
+ );
207
+ }
208
+ var left = el(
209
+ "div",
210
+ {},
211
+ el(
212
+ "div",
213
+ { className: "badge-big" },
214
+ medal(level, 72),
215
+ el("div", {}, el("div", { className: "kicker", textContent: "Repository level" }), el("h2", { className: "levelword", textContent: level })),
216
+ ),
217
+ el("p", { className: "verdict", textContent: sentence }),
218
+ wins.length ? el("p", { className: "wins" }, el("b", { textContent: "✓ Already: " }), wins.join(" · ")) : null,
219
+ (function () {
220
+ var off = furthestOff(D, S);
221
+ if (!off) return null;
222
+ return el(
223
+ "p",
224
+ { className: "attn" },
225
+ el("b", { textContent: "One entity, apart from the repository level: " }),
226
+ link("entity/" + enc(off.id), "", shortId(off.id)),
227
+ " on ",
228
+ link("scorecard/" + enc(off.name), "", title(D, off.name)),
229
+ off.rule
230
+ ? el("span", {}, off.fails ? ", held by " : ", waiting on ", link("rule/" + enc(off.name) + "/" + enc(off.rule), "", ruleTitle(off.name, off.rule)), off.fails ? ", which fails." : ", which was not run in this build.")
231
+ : ".",
232
+ );
233
+ })(),
234
+ nextBox,
235
+ climb,
236
+ );
237
+ var ladder = el("div", { className: "ladder", style: "--steps:" + R.ladder.length });
238
+ ladder.setAttribute("aria-label", "Repository standards by lowest level");
239
+ R.ladder.forEach(function (l) {
240
+ var here = R.constituents.filter(function (c) {
241
+ return c.level === l;
242
+ });
243
+ var rung = el(
244
+ "div",
245
+ { className: "rung" + (l === level ? " here" : "") + (here.length ? "" : " vacant"), style: "--lvl:" + fill(l) },
246
+ el("div", { className: "rh" }, medal(l, 22), l, el("span", { className: "n", textContent: String(here.length) })),
247
+ );
248
+ if (!here.length) rung.append(l === "none" ? el("div", { className: "empty good", textContent: "✓ No repository standard at none" }) : el("div", { className: "empty", textContent: "—" }));
249
+ here.forEach(function (c) {
250
+ var done = c.level === c.top;
251
+ var caps = done && R.next && c.level === level;
252
+ var a = link("scorecard/" + enc(c.name), caps ? "capped" : done ? "done" : "", [title(D, c.name), caps ? el("span", { className: "capmark" }, lockIcon(), " at its top level, so it caps the repository") : done ? el("span", { className: "topmark", textContent: "✓ top level" }) : null]);
253
+ a.title = caps ? c.name + ": at its only top level, " + c.level + ", which holds the repository there" : done ? c.name + ": already at its top level, " + c.level : c.name;
254
+ rung.append(a);
255
+ });
256
+ ladder.append(rung);
257
+ });
258
+ var at = verdict.indexOf(": ");
259
+ var needs = at > 0 && verdict.indexOf("Needs") === 0;
260
+ var almost = at > 0 && verdict.indexOf("Almost") === 0;
261
+ var tone = needs ? "none" : almost ? "bronze" : "gold";
262
+ var seeThem = function (this: HTMLElement) {
263
+ var h = this.closest(".seikika-report")?.querySelector("#need-att");
264
+ if (h) h.scrollIntoView({ behavior: "smooth", block: "start" });
265
+ };
266
+ var statusLead = el(
267
+ "div",
268
+ { className: "status-lead" },
269
+ el("div", { className: "kicker", textContent: "Status" }),
270
+ el("h2", { className: "levelword", style: "color:" + ink(tone) }, at > 0 ? verdict.slice(0, at) : verdict),
271
+ at > 0
272
+ ? el(
273
+ "p",
274
+ { className: "verdict" },
275
+ verdict.slice(at + 2).replace(/^./, function (ch) { return ch.toUpperCase(); }) + " ",
276
+ el("button", { className: "link", textContent: "See them ↓", onclick: seeThem }),
277
+ )
278
+ : null,
279
+ absentSections(D, campaignNames) ? el("p", { className: "sub", style: "margin:8px 0 0", textContent: absentSections(D, campaignNames) }) : null,
280
+ );
281
+ section.append(
282
+ statusLead,
283
+ left,
284
+ el(
285
+ "div",
286
+ {},
287
+ el("h3", { style: "margin-top:0", textContent: "Where each repository standard stands" }),
288
+ ladder,
289
+ el(
290
+ "p",
291
+ { className: "sub", style: "margin:10px 0 0" },
292
+ "Only these standards set the repository level. The other scorecards rate single entities, such as one rule or one skill, and are listed below." +
293
+ (R.ceiling !== R.ladder[R.ladder.length - 1] && R.ceiling !== level
294
+ ? " " +
295
+ plural(
296
+ R.constituents.filter(function (c) {
297
+ return c.top === R.ceiling;
298
+ }).length,
299
+ "standard tops",
300
+ "standards top",
301
+ ) +
302
+ " out at " +
303
+ R.ceiling +
304
+ ", so " +
305
+ R.ceiling +
306
+ " is the highest level the repository can reach."
307
+ : ""),
308
+ ),
309
+ ),
310
+ );
311
+ return section;
312
+ },
313
+
314
+ tiles(D: ReportData, S: Summary, campaignNames) {
315
+ var campaigns = D.campaigns || {};
316
+ var c = S.checks;
317
+ var total = c.pass + c.vacuous + c.fail + c.unknown;
318
+ var pct = shareOf(c.pass, total);
319
+ var checkParts = [
320
+ { cls: "pass", n: c.pass, name: "pass" },
321
+ { cls: "fail", n: c.fail, name: "fail" },
322
+ { cls: "unknown", n: c.unknown, name: "not run" },
323
+ { cls: "vacuous", n: c.vacuous, name: "not assessed" },
324
+ ];
325
+ var checkLine = checkParts.map(function (p) { return fmt(p.n) + " " + p.name; }).join(", ");
326
+ var checkLabel = checkLine + ", of " + fmt(total) + " checks";
327
+ var on = campaignNames.filter(function (n) {
328
+ return campaignStanding(D, campaigns[n]) === "on";
329
+ }).length;
330
+ var debt = S.rows.filter(function (r) {
331
+ return r.none > 0 && !r.compare;
332
+ }).length;
333
+ var scoredEntities = Object.keys(S.worst).length;
334
+ var tops = new Set(
335
+ S.rows
336
+ .filter(function (r) {
337
+ return !r.compare;
338
+ })
339
+ .map(function (r) {
340
+ return known((r.sc.levels || []).slice(-1)[0]) || "gold";
341
+ }),
342
+ );
343
+ var topList = LADDER.filter(function (l) {
344
+ return tops.has(l);
345
+ });
346
+ var topMedal = topList[topList.length - 1] || "gold";
347
+ var goldIds = S.atTop;
348
+ var golden = goldIds.length;
349
+ var unjudged = new Set();
350
+ Object.keys(D.unassessed || {}).forEach(function (card) {
351
+ var rows = (D.scores || {})[card] || {};
352
+ (D.unassessed || {})[card].forEach(function (id) {
353
+ if (rows[id] && rows[id].level !== "skipped") unjudged.add(id);
354
+ });
355
+ });
356
+ var goldUnjudged = goldIds.filter(function (id) {
357
+ return unjudged.has(id);
358
+ }).length;
359
+ // Counted per entity, one numerous kind can carry the figure; say so when it is a large share.
360
+ var perKind: Record<string, number> = {};
361
+ Object.keys(S.worst).forEach(function (id) {
362
+ var k = S.kindOf[id] || "";
363
+ perKind[k] = (perKind[k] || 0) + 1;
364
+ });
365
+ var bigKind = Object.entries(perKind).sort(function (a, b) {
366
+ return b[1] - a[1];
367
+ })[0];
368
+ var kindNote = bigKind && bigKind[0] && bigKind[1] * 3 >= scoredEntities && Object.keys(perKind).length > 1 ? "Counted per entity; the largest group is " + kindCount(D, bigKind[0], bigKind[1]) + "." : null;
369
+ var tile = function (path, cls, lead, big, text) {
370
+ return link(path, "tile " + (cls || ""), [lead, el("div", {}, el("strong", { textContent: big }), el("span", {}, ...[].concat(text)))]);
371
+ };
372
+ var shown = [
373
+ total ? tile("scorecards", "good", checkBar(checkParts, checkLabel), pct + "%", [checkLine, el("small", { className: "tile-note", textContent: "of " + fmt(total) + " checks. The four counts add up to that total." })]) : null,
374
+ scoredEntities ? tile("catalog", "", medal(topMedal, 40), fmt(golden), ["of " + fmt(scoredEntities) + " scored entities are at the top level of every scorecard that rates them", topList.length > 1 ? el("small", { className: "tile-note", textContent: "Top levels differ by scorecard: " + andList(topList) + "." }) : null, goldUnjudged ? el("small", { className: "tile-note", textContent: fmt(goldUnjudged) + " of those still await an agent's assessment" }) : null, kindNote ? el("small", { className: "tile-note", textContent: kindNote }) : null]) : null,
375
+ scoredEntities ? tile("scorecards", debt ? "bad" : "good", medal(debt ? "none" : "gold", 40), String(debt), debt === 1 ? "scorecard has entities at none" : debt ? "scorecards have entities at none" : "scorecards with entities at none") : null,
376
+ campaignNames.length ? tile("campaigns", on === campaignNames.length ? "good" : "", kpiPips(on, campaignNames.length, on + " of " + campaignNames.length + " campaigns on target"), on + " of " + campaignNames.length, "campaigns on target") : null,
377
+ ].filter(Boolean);
378
+ return shown.length ? el("div", { className: "tiles" }, ...shown) : null;
379
+ },
380
+
381
+ campaignCard(D: ReportData, name, current?) {
382
+ var c = (D.campaigns || {})[name];
383
+ var state = campaignState(c);
384
+ var pct = c.percent == null ? 0 : c.percent;
385
+ var target = c.targetPercent == null ? 100 : c.targetPercent;
386
+ var days = daysLeft(c.end);
387
+ var each = includeProgress(D, c);
388
+ var toGo = each.reduce(function (n, p) {
389
+ return n + (p.met ? 0 : p.below);
390
+ }, 0);
391
+ // A campaign with no shared scope still has a share. Draw that share like every other card,
392
+ // and keep "on target" for a card that has met the target.
393
+ var rated = each.reduce(function (n, p) {
394
+ return n + (p.known ? p.rated : 0);
395
+ }, 0);
396
+ var meeting = each.reduce(function (n, p) {
397
+ return n + (p.known ? p.rated - p.below : 0);
398
+ }, 0);
399
+ var drawn = state;
400
+ var drawnPct = pct;
401
+ var drawnEach = each;
402
+ if (state === "empty" && rated) {
403
+ drawnPct = Math.floor((100 * meeting) / rated);
404
+ drawn = drawnPct >= target ? "on" : "off";
405
+ drawnEach = [];
406
+ }
407
+ var status =
408
+ drawn === "empty"
409
+ ? toGo
410
+ ? el("span", { className: "pill bad", textContent: plural(toGo, "entity", "entities") + " to go" })
411
+ : el("span", { className: "pill good", textContent: "on target" })
412
+ : drawn === "on"
413
+ ? el("span", { className: "pill good", textContent: "on target" })
414
+ : el("span", { className: "pill bad", textContent: plural(state === "empty" ? toGo : (c.inScope || 0) - (c.meeting || 0), "entity", "entities") + " to go" });
415
+ var a = link("campaign/" + enc(name), "card", [
416
+ goalBar(drawn, drawnPct, target, false, drawnEach),
417
+ el(
418
+ "div",
419
+ {},
420
+ el("div", { className: "t", textContent: c.title || name }),
421
+ el("div", { className: "s" }, status, days != null && days >= 0 && c.status !== "ended" ? " · " + plural(days, "day") + " left" : c.status === "ended" ? " · ended" : ""),
422
+ ),
423
+ ]);
424
+ if (current) a.setAttribute("aria-current", "true");
425
+ return a;
426
+ },
427
+
428
+ scorecardTable(D: ReportData, rows, floors?) {
429
+ var why = function (r, indent) {
430
+ var p = scPurpose(r.sc);
431
+ return p ? el("span", { className: "rp" + (indent ? " in" : ""), textContent: p }) : null;
432
+ };
433
+ var wrap = el("div", { className: "rows" });
434
+ wrap.append(el("div", { className: "rows-head" }, el("span", { textContent: "Scorecard" }), el("span", { className: "dist", textContent: "Entities by level" }), el("span", { textContent: rows.some(function (r) { return r.scored; }) ? "At none" : "Status" })));
435
+ rows.forEach(function (r) {
436
+ wrap.append(
437
+ link("scorecard/" + enc(r.name), "row", [
438
+ floors
439
+ ? el("div", { className: "medal-col" }, medal(floorOf(D, r.name) || "not scored", 30), el("div", {}, ...cardName(D, r.name), el("span", { className: "weakest" }, "weakest ", floorOf(D, r.name) ? floorPill(D, r.name) : "not scored", topNote(D, r.name, floorOf(D, r.name)))))
440
+ : el("div", {}, ...cardName(D, r.name)),
441
+ el("div", { className: "dist" }, barEl(splitUnassessed(D, r.name, r.parts)), el("div", { className: "sub", style: "font-size:12px;margin-top:4px" }, ...scCaption(D, r, true))),
442
+ el("div", { className: "num" + (r.none ? " bad" : "") }, el("strong", { textContent: r.scored ? String(r.none) : "—" }), el("span", { textContent: r.scored ? "at none" : "not scored" })),
443
+ why(r, floors),
444
+ ]),
445
+ );
446
+ });
447
+ return wrap;
448
+ },
449
+
450
+ overview(D: ReportData, S: Summary) {
451
+ var catalog = D.catalog || {};
452
+ var campaignNames = campaignNamesSorted(D);
453
+ var self = this;
454
+ var attention = S.rows.filter(function (r) {
455
+ return r.none > 0 && !r.compare;
456
+ });
457
+ var clear = S.rows.filter(function (r) {
458
+ return r.none === 0 && !r.compare && r.scored;
459
+ });
460
+ var unscored = S.rows.filter(function (r) {
461
+ return !r.compare && !r.scored;
462
+ });
463
+ var clearHollow = clear.filter(function (r) {
464
+ return splitUnassessed(D, r.name, r.parts).some(function (p) {
465
+ return p.hollow;
466
+ });
467
+ });
468
+ var clearBelow = clear.filter(function (r) {
469
+ return clearHollow.indexOf(r) < 0 && r.topShare < 100;
470
+ });
471
+ var accounted = attention.length + clear.length + unscored.length;
472
+ var clean = clear.length - clearHollow.length;
473
+ var named = function (rows) {
474
+ return rows.flatMap(function (r, i) {
475
+ return [i ? ", " : "", link("scorecard/" + enc(r.name), "", title(D, r.name))];
476
+ });
477
+ };
478
+ // Each clause is a part of the scorecard count in the header, so the parts add to it.
479
+ var clearLine = el(
480
+ "span",
481
+ {},
482
+ "Of " + plural(accounted, "scorecard") + ", " + (attention.length ? plural(attention.length, "has an entity at none", "have an entity at none") : "none has an entity at none") + ". ",
483
+ clean
484
+ ? el(
485
+ "span",
486
+ {},
487
+ plural(clean, "has no entity at none", "have no entity at none"),
488
+ clearBelow.length
489
+ ? el("span", {}, " (", plural(clearBelow.length, "of which still has entities below its top level", "of which still have entities below their top level"), ": ", ...named(clearBelow), ")")
490
+ : null,
491
+ ". ",
492
+ )
493
+ : null,
494
+ clearHollow.length
495
+ ? el("span", { className: "unjudged-n" }, plural(clearHollow.length, "has no entity at none only because no agent has assessed it yet", "have no entity at none only because no agent has assessed them yet"), " (", ...named(clearHollow), "). ")
496
+ : null,
497
+ unscored.length ? plural(unscored.length, "is not scored yet", "are not scored yet") + ". " : null,
498
+ );
499
+ var showAll = false;
500
+ var clearWrap = el("div");
501
+ var drawClear = function () {
502
+ clearWrap.replaceChildren(
503
+ showAll
504
+ ? el(
505
+ "div",
506
+ {},
507
+ el(
508
+ "p",
509
+ { className: "empty good" },
510
+ clearLine,
511
+ el("button", {
512
+ className: "link",
513
+ textContent: "Hide them",
514
+ ariaExpanded: "true",
515
+ onclick: function () {
516
+ showAll = false;
517
+ drawClear();
518
+ var b = clearWrap.querySelector("button");
519
+ if (b) b.focus();
520
+ },
521
+ }),
522
+ ),
523
+ self.scorecardTable(D, clear),
524
+ )
525
+ : el(
526
+ "p",
527
+ { className: "empty good" },
528
+ clearLine,
529
+ el("button", {
530
+ className: "link",
531
+ textContent: "Show them",
532
+ ariaExpanded: "false",
533
+ onclick: function () {
534
+ showAll = true;
535
+ drawClear();
536
+ var b = clearWrap.querySelector("button");
537
+ if (b) b.focus();
538
+ },
539
+ }),
540
+ ),
541
+ );
542
+ };
543
+ drawClear();
544
+ var attFold = attention.length > 4 ? 3 : attention.length;
545
+ var attTable = attention.length ? this.scorecardTable(D, attention.slice(0, attFold)) : null;
546
+ var attMore =
547
+ attention.length > attFold
548
+ ? el(
549
+ "div",
550
+ { className: "more" },
551
+ el("button", {
552
+ className: "link",
553
+ ariaExpanded: "false",
554
+ textContent: "Show the other " + fmt(attention.length - attFold) + " that need attention",
555
+ onclick: function (this: HTMLElement) {
556
+ var open = this.getAttribute("aria-expanded") !== "true";
557
+ var shown = open ? self.scorecardTable(D, attention) : self.scorecardTable(D, attention.slice(0, attFold));
558
+ (attTable as HTMLElement).replaceWith(shown);
559
+ attTable = shown;
560
+ this.setAttribute("aria-expanded", String(open));
561
+ this.textContent = open ? "Show only the first " + attFold : "Show the other " + fmt(attention.length - attFold) + " that need attention";
562
+ var next = open && shown.querySelectorAll<HTMLElement>("a.row")[attFold];
563
+ if (next) next.focus();
564
+ },
565
+ }),
566
+ )
567
+ : null;
568
+ return el(
569
+ "div",
570
+ {},
571
+ this.hero(D, S, campaignNames),
572
+ tracksSorted(D, S).length
573
+ ? el(
574
+ "section",
575
+ {},
576
+ el("div", { className: "head" }, el("h2", { textContent: "Tracks" }), link("tracks", "", "All tracks →")),
577
+ el("p", { className: "lede", textContent: (furthestTrack(D, S) ? plural(tracksSorted(D, S).length, "long-running line") + " of work. " + trackTitle(D, furthestTrack(D, S)) + " has the lowest share of entities at the top level. " : "") + "Each ring is its scorecards' average share of entities at the top level." + (tracksSorted(D, S).some(function (t) {
578
+ return t.compare;
579
+ })
580
+ ? " The comparison track's ring counts factors ahead of a rival instead."
581
+ : "") + " Open a track for its scorecards and campaigns." }),
582
+ this.trackStrip(D, S, tracksSorted(D, S), "Tracks", true),
583
+ )
584
+ : null,
585
+ this.tiles(D, S, campaignNames),
586
+ campaignNames.length
587
+ ? el(
588
+ "section",
589
+ {},
590
+ el("div", { className: "head" }, el("h2", { textContent: "Campaigns" }), el("span", { className: "sub", textContent: "Goals with a target, behind target first; a bar turns green once it passes its target mark" })),
591
+ el(
592
+ "div",
593
+ { className: "cards" },
594
+ ...campaignNames.map(function (n) {
595
+ return self.campaignCard(D, n);
596
+ }),
597
+ ),
598
+ )
599
+ : null,
600
+ el(
601
+ "section",
602
+ {},
603
+ el(
604
+ "div",
605
+ { className: "head" },
606
+ el("h2", { id: "need-att", textContent: attention.length ? "Scorecards that need attention" : "Scorecards" }),
607
+ attention.length ? el("span", { className: "sub", textContent: "Most entities at none first" }) : null,
608
+ ),
609
+ el("p", { className: "lede", textContent: noFacts(S) ? "No entity has a level yet, so these scorecards have nothing to show." : "Each scorecard rates every entity of one kind against levels of rules. An entity is at none until it passes every rule of the first level." }),
610
+ unscored.length === S.rows.length ? null : levelLegend(D, S.rows),
611
+ attTable,
612
+ attMore,
613
+ clear.length ? clearWrap : null,
614
+ unscored.length ? el("div", {}, el("p", { className: "empty", textContent: plural(unscored.length, "scorecard has", "scorecards have") + " no scored entity yet:" }), this.scorecardTable(D, unscored)) : null,
615
+ ),
616
+ !S.entityCount ? null : el(
617
+ "section",
618
+ {},
619
+ el("div", { className: "head" }, el("h2", { textContent: "What's in the box" }), link("catalog", "", "Browse the catalog →")),
620
+ ...kindGroupsOf(D).map(function (g) {
621
+ return el(
622
+ "div",
623
+ { className: "boxrow" },
624
+ el("div", { className: "bg" }, g.title, el("small", { textContent: plural(g.count, "entity", "entities") })),
625
+ el(
626
+ "div",
627
+ { className: "box" },
628
+ ...g.kinds.map(function (k) {
629
+ var a = link("catalog/" + enc(k), "", [kindTitle(D, k), el("b", { textContent: fmt(catalog[k].length) })]);
630
+ if (kindDescription(D, k)) a.title = kindDescription(D, k).replace(/`/g, "");
631
+ return a;
632
+ }),
633
+ ),
634
+ );
635
+ }),
636
+ ),
637
+ );
638
+ },
639
+ } satisfies ThisType<ReportViews>;