@action-state-group/capsule-viewer 0.1.0 → 0.3.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 (90) hide show
  1. package/README.md +73 -2
  2. package/dist/alias-interpreters.d.ts +18 -0
  3. package/dist/alias-interpreters.js +50 -0
  4. package/dist/alias-interpreters.js.map +1 -0
  5. package/dist/browser.d.ts +5 -2
  6. package/dist/browser.js +19 -5
  7. package/dist/browser.js.map +1 -1
  8. package/dist/builtin-manifests.d.ts +51 -0
  9. package/dist/builtin-manifests.js +196 -0
  10. package/dist/builtin-manifests.js.map +1 -0
  11. package/dist/compliance-styles.d.ts +1 -8
  12. package/dist/compliance-styles.js +41 -3
  13. package/dist/compliance-styles.js.map +1 -1
  14. package/dist/compliance-view.d.ts +41 -1
  15. package/dist/compliance-view.js +737 -303
  16. package/dist/compliance-view.js.map +1 -1
  17. package/dist/compliance.d.ts +33 -4
  18. package/dist/compliance.js +92 -13
  19. package/dist/compliance.js.map +1 -1
  20. package/dist/composed-styles.d.ts +12 -0
  21. package/dist/composed-styles.js +20 -0
  22. package/dist/composed-styles.js.map +1 -0
  23. package/dist/composed-view.d.ts +1 -1
  24. package/dist/composed-view.js +9 -2
  25. package/dist/composed-view.js.map +1 -1
  26. package/dist/contract-report-wording.d.ts +195 -0
  27. package/dist/contract-report-wording.js +1141 -0
  28. package/dist/contract-report-wording.js.map +1 -0
  29. package/dist/contract-report.d.ts +92 -0
  30. package/dist/contract-report.js +63 -0
  31. package/dist/contract-report.js.map +1 -0
  32. package/dist/emitter-shell.html +176 -2
  33. package/dist/emitter.d.ts +36 -0
  34. package/dist/emitter.js +64 -1
  35. package/dist/emitter.js.map +1 -1
  36. package/dist/evidence-graph-view.d.ts +60 -7
  37. package/dist/evidence-graph-view.js +1344 -106
  38. package/dist/evidence-graph-view.js.map +1 -1
  39. package/dist/evidence-graph.iife.js +12410 -5624
  40. package/dist/frame-tokens.generated.d.ts +3 -0
  41. package/dist/frame-tokens.generated.js +5 -0
  42. package/dist/frame-tokens.generated.js.map +1 -0
  43. package/dist/index.d.ts +3 -0
  44. package/dist/index.js +5 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/outcome-report-presentation.d.ts +48 -0
  47. package/dist/outcome-report-presentation.js +90 -0
  48. package/dist/outcome-report-presentation.js.map +1 -0
  49. package/dist/outcome-report-styles.d.ts +1 -16
  50. package/dist/outcome-report-styles.js +48 -45
  51. package/dist/outcome-report-styles.js.map +1 -1
  52. package/dist/outcome-report-view.d.ts +75 -2
  53. package/dist/outcome-report-view.js +1039 -436
  54. package/dist/outcome-report-view.js.map +1 -1
  55. package/dist/presentation-builder.d.ts +55 -6
  56. package/dist/presentation-builder.js +163 -69
  57. package/dist/presentation-builder.js.map +1 -1
  58. package/dist/presentation-fragment.d.ts +129 -0
  59. package/dist/presentation-fragment.js +213 -0
  60. package/dist/presentation-fragment.js.map +1 -0
  61. package/dist/presentation-mount.d.ts +2 -2
  62. package/dist/presentation-mount.js +1 -1
  63. package/dist/presentation-mount.js.map +1 -1
  64. package/dist/presentation-registry.d.ts +277 -0
  65. package/dist/presentation-registry.js +416 -0
  66. package/dist/presentation-registry.js.map +1 -0
  67. package/dist/record-content.d.ts +68 -0
  68. package/dist/record-content.js +153 -0
  69. package/dist/record-content.js.map +1 -0
  70. package/dist/record-dating.d.ts +10 -0
  71. package/dist/record-dating.js +76 -0
  72. package/dist/record-dating.js.map +1 -0
  73. package/dist/report-front-styles.d.ts +9 -0
  74. package/dist/report-front-styles.js +55 -0
  75. package/dist/report-front-styles.js.map +1 -0
  76. package/dist/report-front.d.ts +78 -0
  77. package/dist/report-front.js +274 -0
  78. package/dist/report-front.js.map +1 -0
  79. package/dist/report-levels.d.ts +206 -0
  80. package/dist/report-levels.js +739 -0
  81. package/dist/report-levels.js.map +1 -0
  82. package/dist/report-provenance.d.ts +111 -0
  83. package/dist/report-provenance.js +535 -0
  84. package/dist/report-provenance.js.map +1 -0
  85. package/dist/viewer-build.d.ts +37 -0
  86. package/dist/viewer-build.js +29 -0
  87. package/dist/viewer-build.js.map +1 -0
  88. package/dist/wording/contract-report-eu-ai-act.en.json +295 -0
  89. package/dist/wording/contract-report-outcomes.en.json +394 -0
  90. package/package.json +3 -2
@@ -0,0 +1,153 @@
1
+ import { renderTurns } from "./report-levels.js";
2
+ const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
3
+ /**
4
+ * JSON text of the value with every object's members in canonical order
5
+ * (RFC 8785 JCS: by key, compared as UTF-16 code units), indented by
6
+ * `indent` spaces when given. A record commits to its content's canonical
7
+ * form, and the same content reaches the page with its members in a
8
+ * different order depending on how the bundle was packaged; drawing the
9
+ * canonical order shows every packaging the same text, in the order that
10
+ * was sealed.
11
+ *
12
+ * Written out here rather than by re-ordering an object for JSON.stringify:
13
+ * an object puts integer-like keys ("9", "10") first in numeric order
14
+ * whatever order they are added in, and assigning a member named
15
+ * `__proto__` would set the object's prototype instead of keeping the
16
+ * member. Strings and numbers are written by JSON.stringify, so a number
17
+ * JSON cannot hold exactly was already rounded when the payload was parsed.
18
+ */
19
+ export function canonicalJson(value, indent) {
20
+ const pad = indent === undefined ? "" : " ".repeat(indent);
21
+ const write = (v, depth) => {
22
+ const open = pad === "" ? "" : `\n${pad.repeat(depth + 1)}`;
23
+ const close = pad === "" ? "" : `\n${pad.repeat(depth)}`;
24
+ const colon = pad === "" ? ":" : ": ";
25
+ if (Array.isArray(v))
26
+ return v.length === 0
27
+ ? "[]"
28
+ : `[${v.map((item) => open + write(item, depth + 1)).join(",")}${close}]`;
29
+ if (isObject(v)) {
30
+ const keys = Object.keys(v).sort(byCodeUnits);
31
+ return keys.length === 0
32
+ ? "{}"
33
+ : `{${keys
34
+ .map((key) => `${open}${JSON.stringify(key)}${colon}${write(v[key], depth + 1)}`)
35
+ .join(",")}${close}}`;
36
+ }
37
+ return JSON.stringify(v) ?? "null";
38
+ };
39
+ return write(value, 0);
40
+ }
41
+ /** Orders strings by UTF-16 code units, as JCS does. */
42
+ function byCodeUnits(a, b) {
43
+ return a < b ? -1 : a > b ? 1 : 0;
44
+ }
45
+ /**
46
+ * The turns of a conversation payload, or undefined when the content is not
47
+ * one. Mirrors agent-action-capsule `ts/src/outcome-report.ts`
48
+ * `transcriptTurns` (0.6.0), which that package does not export: an
49
+ * `agent_interaction.messages` array, each message's `role`, `content` and
50
+ * `tool_calls`, the call arguments re-serialised (there with JSON.stringify,
51
+ * here in canonical member order). Keep the two in step.
52
+ */
53
+ export function conversationTurns(content) {
54
+ if (!isObject(content))
55
+ return undefined;
56
+ const interaction = isObject(content.agent_interaction)
57
+ ? content.agent_interaction
58
+ : undefined;
59
+ if (interaction === undefined || !Array.isArray(interaction.messages))
60
+ return undefined;
61
+ return interaction.messages.flatMap((m) => {
62
+ if (!isObject(m))
63
+ return [];
64
+ const role = typeof m.role === "string" ? m.role : "unknown";
65
+ const text = typeof m.content === "string" ? m.content : undefined;
66
+ const calls = Array.isArray(m.tool_calls) ? m.tool_calls : [];
67
+ return [
68
+ {
69
+ role,
70
+ ...(text === undefined ? {} : { content: text }),
71
+ toolCalls: calls.flatMap((call) => isObject(call)
72
+ ? [
73
+ {
74
+ name: typeof call.name === "string" ? call.name : "unnamed",
75
+ // Re-serialised as there, but in canonical member order,
76
+ // so every packaging shows the same text.
77
+ arguments: canonicalJson(call.arguments ?? null),
78
+ },
79
+ ]
80
+ : []),
81
+ },
82
+ ];
83
+ });
84
+ }
85
+ /** A conversation, drawn as a chat (renderChat): who said what, each tool call and its result. */
86
+ export const conversationModule = {
87
+ id: "conversation",
88
+ matches: (content) => conversationTurns(content) !== undefined,
89
+ // Content only: what was checked is the core's to say, beside the block
90
+ // (presentation contract section 6.1).
91
+ render(content, w) {
92
+ const wrap = document.createElement("div");
93
+ wrap.className = "chat";
94
+ wrap.append(renderTurns(conversationTurns(content) ?? [], w));
95
+ return wrap;
96
+ },
97
+ };
98
+ /** The content modules the core picks from, in order. */
99
+ export const CONTENT_MODULES = [conversationModule];
100
+ /** The first module that takes this content, or undefined. */
101
+ export function pickContentModule(content, modules = CONTENT_MODULES) {
102
+ return modules.find((module) => module.matches(content));
103
+ }
104
+ /**
105
+ * Disclosed content in its content block: by its module when one takes it,
106
+ * otherwise as recorded: the verifier's parsed payload in canonical member
107
+ * order, indented. Indenting adds whitespace only; a number JSON cannot
108
+ * hold exactly was already rounded when the payload was parsed.
109
+ */
110
+ export function renderContent(content, w, modules = CONTENT_MODULES) {
111
+ const block = document.createElement("div");
112
+ block.className = "cv-content";
113
+ const module = pickContentModule(content, modules);
114
+ if (module !== undefined) {
115
+ block.dataset.contentModule = module.id;
116
+ block.append(module.render(content, w));
117
+ return block;
118
+ }
119
+ block.dataset.contentModule = "as-recorded";
120
+ const pre = document.createElement("pre");
121
+ let text;
122
+ try {
123
+ text = canonicalJson(content, 2);
124
+ }
125
+ catch {
126
+ text = String(content);
127
+ }
128
+ pre.textContent = text;
129
+ pre.dataset.exact = "as-parsed";
130
+ block.append(pre);
131
+ return block;
132
+ }
133
+ /**
134
+ * The content block's own stylesheet, scoped to `.cv-content`: the records
135
+ * section is the core's, drawn on every page, inside no module's frame, so
136
+ * a chat or a JSON value there cannot lean on a module's styles. Inserted
137
+ * once per page by the core (evidence-graph-view.ts) and listed in
138
+ * CORE_RUNTIME_STYLES, so the CSP carries its hash.
139
+ */
140
+ export const RECORD_CONTENT_CSS = `
141
+ .cv-content pre{margin:4px 0;white-space:pre-wrap;word-break:break-word;font-family:ui-monospace,Menlo,monospace;font-size:12px;max-height:420px;overflow:auto}
142
+ .cv-content .chat .chat-k{font-size:12.5px;margin:4px 0 6px}
143
+ .cv-content .chat ol.turns{list-style:none;margin:0;padding:10px;display:grid;gap:6px;max-height:620px;overflow:auto;border:1px solid #E3DED3;border-radius:10px;background:#FAF8F4}
144
+ .cv-content .chat li.turn{border-radius:10px;padding:6px 10px;max-width:86%;background:#fff;border:1px solid #E3DED3;font-size:13.5px}
145
+ .cv-content .chat li.turn.user{justify-self:end;background:#ECE8F7;border-color:transparent}
146
+ .cv-content .chat li.turn.assistant{justify-self:start}
147
+ .cv-content .chat li.turn.tool,.cv-content .chat li.turn.system{justify-self:center;max-width:96%;border-style:dashed}
148
+ .cv-content .chat li.turn .who{font-size:10.5px;letter-spacing:.06em;text-transform:uppercase;margin-bottom:2px}
149
+ .cv-content .chat li.turn .say{white-space:pre-wrap;word-break:break-word}
150
+ .cv-content .chat li.turn pre.say{margin:0;font-size:11.5px;max-height:180px}
151
+ .cv-content .chat .call{margin-top:4px;font-size:12.5px;background:#FBEFD9;border-radius:6px;padding:3px 8px;word-break:break-word}
152
+ `;
153
+ //# sourceMappingURL=record-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-content.js","sourceRoot":"","sources":["../src/record-content.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAsBjD,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,MAAe;IAC3D,MAAM,GAAG,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,CAAC,CAAU,EAAE,KAAa,EAAU,EAAE;QAClD,MAAM,IAAI,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;QAC5D,MAAM,KAAK,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,M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,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5C,KAAK,CAAC,SAAS,GAAG,YAAY,CAAC;IAC/B,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACnD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,KAAK,CAAC,OAAO,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC;QACxC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;IAC5C,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IACD,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC;IACvB,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,WAAW,CAAC;IAChC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAClB,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;CAYjC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type CitedRecord, type ConversationDate, type OutcomeReportDating, type ResultClaim, type ResultRoot } from "@action-state-group/agent-action-capsule";
2
+ /** The case record the reports name, when this bundle cites it and its capsule checks out. */
3
+ export declare function caseRecord(result: ResultRoot, claims: readonly ResultClaim[], sourceCapsuleId: string | undefined): CitedRecord | undefined;
4
+ /** See `ConversationDate`: source (backfilled), record (own timestamp), else the judged day. */
5
+ export declare function conversationDate(record: CitedRecord | undefined, judgedDay: string): ConversationDate;
6
+ /** How a set of dated conversations is dated as a whole. */
7
+ export declare function buildDating(conversations: readonly {
8
+ readonly dated: ConversationDate;
9
+ readonly judgedDay: string;
10
+ }[]): OutcomeReportDating;
@@ -0,0 +1,76 @@
1
+ // SPDX-License-Identifier: BSD-3-Clause
2
+ import { asString, zoneStatement, } from "@action-state-group/agent-action-capsule";
3
+ // The outcome card's record-dating rule (agent-action-capsule
4
+ // ts/src/outcome-report.ts: caseRecord, conversationDate, buildDating),
5
+ // repeated here so the obligations card dates a session the same way.
6
+ // Copied from ts/v0.5.0, where the three are identical to these. Neither
7
+ // the published 0.5.0 package nor agent-action-capsule's main exports them
8
+ // (checked 2026-10-21), and no agent-action-capsule issue tracks exporting
9
+ // them yet: this file tracks that export, listed as a follow-up on this
10
+ // pull request. Once a release exports them, import them instead and
11
+ // delete this file.
12
+ const STATED_DAY = /^(\d{4}-\d{2}-\d{2})/u;
13
+ /** The case record the reports name, when this bundle cites it and its capsule checks out. */
14
+ export function caseRecord(result, claims, sourceCapsuleId) {
15
+ if (sourceCapsuleId === undefined)
16
+ return undefined;
17
+ for (const claim of claims)
18
+ for (const ref of claim.evidence) {
19
+ const record = result.records.get(ref.digest);
20
+ if (record === undefined || record.stated === undefined)
21
+ continue;
22
+ if (record.carriedCapsuleId === sourceCapsuleId ||
23
+ (record.carriedCapsuleId === undefined &&
24
+ record.bookRecordId === undefined &&
25
+ record.capsuleId === sourceCapsuleId))
26
+ return record;
27
+ }
28
+ return undefined;
29
+ }
30
+ /** See `ConversationDate`: source (backfilled), record (own timestamp), else the judged day. */
31
+ export function conversationDate(record, judgedDay) {
32
+ const judged = { basis: "judged", date: judgedDay };
33
+ const stated = record?.stated;
34
+ if (stated === undefined)
35
+ return judged;
36
+ const mode = stated.provenanceMode;
37
+ if (asString(mode?.mode) === "backfilled") {
38
+ const source = asString(mode?.source_asserted_at);
39
+ const day = source === undefined ? undefined : STATED_DAY.exec(source)?.[1];
40
+ if (source === undefined || day === undefined)
41
+ return judged;
42
+ const importedAt = asString(mode?.imported_at);
43
+ return {
44
+ basis: "source",
45
+ date: day,
46
+ stated: source,
47
+ zone: zoneStatement(source),
48
+ ...(importedAt === undefined ? {} : { importedAt }),
49
+ };
50
+ }
51
+ const timestamp = stated.timestamp;
52
+ const day = timestamp === undefined ? undefined : STATED_DAY.exec(timestamp)?.[1];
53
+ if (timestamp === undefined || day === undefined)
54
+ return judged;
55
+ return {
56
+ basis: "record",
57
+ date: day,
58
+ stated: timestamp,
59
+ zone: zoneStatement(timestamp),
60
+ };
61
+ }
62
+ /** How a set of dated conversations is dated as a whole. */
63
+ export function buildDating(conversations) {
64
+ const counts = { source: 0, record: 0, judged: 0 };
65
+ for (const c of conversations)
66
+ counts[c.dated.basis] += 1;
67
+ const used = Object.keys(counts).filter((basis) => counts[basis] > 0);
68
+ return {
69
+ basis: used.length === 1 ? used[0] : used.length === 0 ? "judged" : "mixed",
70
+ counts,
71
+ judgedDays: [...new Set(conversations.map((c) => c.judgedDay))].sort(),
72
+ zoneNotStated: conversations.filter((c) => c.dated.zone === "not-stated")
73
+ .length,
74
+ };
75
+ }
76
+ //# sourceMappingURL=record-dating.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-dating.js","sourceRoot":"","sources":["../src/record-dating.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,EACL,QAAQ,EACR,aAAa,GAMd,MAAM,0CAA0C,CAAC;AAElD,8DAA8D;AAC9D,wEAAwE;AACxE,sEAAsE;AACtE,yEAAyE;AACzE,2EAA2E;AAC3E,2EAA2E;AAC3E,wEAAwE;AACxE,qEAAqE;AACrE,oBAAoB;AAEpB,MAAM,UAAU,GAAG,uBAAuB,CAAC;AAE3C,8FAA8F;AAC9F,MAAM,UAAU,UAAU,CACxB,MAAkB,EAClB,MAA8B,EAC9B,eAAmC;IAEnC,IAAI,eAAe,KAAK,SAAS;QAA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I,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO;QACvE,MAAM;QACN,UAAU,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;QACtE,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;aACtE,MAAM;KACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Styles for the pieces report-front.ts draws (the mock-judge mark, the
3
+ * sealed aggregate, the footnotes, the folded provenance line, rows that
4
+ * open, "Check this report yourself", the provenance row that opens
5
+ * L1, and the card that holds it when no section does), scoped under a grouping's frame class (`.oi` for
6
+ * Outcomes, `.cc` for the EU AI Act). Each frame's stylesheet appends this,
7
+ * so the CSP hashes of the frame stylesheets cover it.
8
+ */
9
+ export declare function frontCss(scope: string): string;
@@ -0,0 +1,55 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * Styles for the pieces report-front.ts draws (the mock-judge mark, the
4
+ * sealed aggregate, the footnotes, the folded provenance line, rows that
5
+ * open, "Check this report yourself", the provenance row that opens
6
+ * L1, and the card that holds it when no section does), scoped under a grouping's frame class (`.oi` for
7
+ * Outcomes, `.cc` for the EU AI Act). Each frame's stylesheet appends this,
8
+ * so the CSP hashes of the frame stylesheets cover it.
9
+ */
10
+ export function frontCss(scope) {
11
+ const s = scope;
12
+ return `
13
+ ${s}{--inset:clamp(20px,5vw,56px)}
14
+ ${s} .mockmark{display:inline-block;margin:8px 0 0;padding:3px 10px;border:1px solid #F0D7A8;background:var(--gold-l);color:#8A5A0B;border-radius:8px;font-weight:600;font-size:13px;line-height:1.45;text-align:left}
15
+ ${s} .front-card{background:#fff;max-width:1080px;margin:0 auto 16px;border:1px solid var(--line);border-radius:var(--r);padding:32px var(--inset)}
16
+ ${s} .prov-row{padding-bottom:16px;margin-bottom:12px;border-bottom:1px solid var(--line)}
17
+ ${s} .front-card > .prov-row:last-child{padding-bottom:0;margin-bottom:0;border-bottom:0}
18
+ ${s} .agg{margin:8px 0 28px;padding:14px 16px;border:1px solid var(--line);border-radius:10px;background:#FAF8F4}
19
+ ${s} .agg-line{font-size:14px;margin:0 0 12px;color:var(--ink)}
20
+ ${s} .agg-buckets{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px}
21
+ ${s} .agg-bucket{display:flex;flex-direction:column;gap:4px;border:1px solid var(--line);border-radius:10px;padding:10px 14px;background:#fff}
22
+ ${s} .agg-bucket b{font-family:Georgia,"Iowan Old Style",Cambria,serif;font-size:28px;line-height:1.1;font-variant-numeric:tabular-nums}
23
+ ${s} .agg-bucket span{font-size:12.5px;color:var(--slate);overflow-wrap:anywhere}
24
+ ${s} .agg .count.mismatch{font-size:12px;font-weight:600;color:var(--bad)}
25
+ ${s} .agg-note{font-size:12.5px;color:var(--slate);margin:6px 0 0}
26
+ ${s} .agg-bucket.met b{color:var(--ok)}
27
+ ${s} .agg-bucket.not_met b{color:var(--bad)}
28
+ ${s} .agg-bucket.not_evaluable b{color:#5F6672}
29
+ ${s} .findings{border:1px solid var(--line);border-left:4px solid var(--gold,#E8A33D);background:#FFFBF2;border-radius:var(--r);padding:32px calc(var(--inset) - 3px);margin:0 0 16px}
30
+ ${s} .findings h2{font-size:19px;margin:4px 0 10px}
31
+ ${s} .plabel{font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:#8A5A0B}
32
+ ${s} .footnotes{margin:22px 0 0;font-size:12.5px;color:var(--slate);display:grid;gap:4px}
33
+ ${s} details.prov-fold{border:0;margin:0;background:transparent}
34
+ ${s} details.prov-fold > summary{padding:2px 0;font-weight:500;color:var(--ink)}
35
+ ${s} details.prov-fold .prov-brief{font-size:13.5px}
36
+ ${s} tr.x{cursor:pointer}
37
+ ${s} tr.x:hover > td{background:#FAF8F4}
38
+ ${s} tr.x-detail{display:none}
39
+ ${s} tr.x:has(details.rx[open]) + tr.x-detail{display:table-row}
40
+ ${s} tr.x-detail > td{padding:0 10px 12px;border-bottom:1px solid var(--line)}
41
+ ${s} details.rx{display:inline;border:0;margin:0;padding:0;background:transparent}
42
+ ${s} details.rx > summary{display:inline;padding:0;font-size:inherit;font-weight:inherit;color:inherit}
43
+ ${s} table tr.x td details.rx > summary > *{display:inline}
44
+ ${s} details.rx > summary:focus-visible{outline:2px solid var(--navy);outline-offset:2px;border-radius:3px}
45
+ ${s} .rule-na{font-size:12.5px;color:var(--slate);margin:4px 0 8px}
46
+ ${s} .check h2{font-size:19px;margin:0 0 10px}
47
+ ${s} .anchors{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:10px}
48
+ ${s} .anchor{background:var(--cream);border-radius:8px;padding:8px 10px;font-size:12px;min-width:0}
49
+ ${s} .anchor .k{display:block;color:var(--slate);margin-bottom:2px}
50
+ ${s} .anchor code{font-size:11px;word-break:break-all}
51
+ ${s} .check .steps{margin:12px 0 0;padding-left:20px;font-size:14px;line-height:1.6}
52
+ @media (max-width:640px){${s} .front-card{padding:24px var(--inset)}${s} .agg-buckets{grid-template-columns:minmax(0,1fr)}${s} .agg-bucket{flex-direction:row;flex-wrap:wrap;align-items:baseline;gap:4px 10px}${s} .agg-bucket b{font-size:22px}}
53
+ `;
54
+ }
55
+ //# sourceMappingURL=report-front-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-front-styles.js","sourceRoot":"","sources":["../src/report-front-styles.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,MAAM,CAAC,GAAG,KAAK,CAAC;IAChB,OAAO;EACP,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;EACD,CAAC;2BACwB,CAAC,0CAA0C,CAAC,qDAAqD,CAAC,oFAAoF,CAAC;CACjN,CAAC;AACF,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The pieces of a contract report that every grouping shares, placed by the
3
+ * contract-report layout note (docs/design/contract-report-layout.md):
4
+ *
5
+ * - L0: the mock-judge mark in the header (decision D5 (b)) and the sealed aggregate,
6
+ * coverage first, then the buckets (contract-report/v1 section 2,
7
+ * evidence-result-v0 section 3).
8
+ * - Rows that open in place (expandableRow).
9
+ * - L2, after the core's verification section: "Check this report
10
+ * yourself", the bundle's anchors and the steps to re-check them.
11
+ * - The host's depth applied to the module's own toggles (presentation
12
+ * contract section 9.1). The core's section is never touched here.
13
+ */
14
+ import { type ResultRoot } from "@action-state-group/agent-action-capsule";
15
+ import type { Words } from "./contract-report-wording.js";
16
+ import { type JudgeTally } from "./report-provenance.js";
17
+ /** The three host regions a contract report writes into, and the host's depth. */
18
+ export interface ReportLevels {
19
+ readonly L0: HTMLElement;
20
+ readonly L1: HTMLElement;
21
+ readonly L2: HTMLElement;
22
+ readonly depth: "L0" | "L1" | "L2";
23
+ }
24
+ /**
25
+ * Decision D5 (b): one L0 mark, drawn only when the judge was a mock. It
26
+ * sits in the report's header right under the title (`placeMockMark`), so
27
+ * a reader meets it before any figure; the folded provenance line then
28
+ * leaves the judge out of its brief (report-provenance.ts).
29
+ */
30
+ export declare function renderMockJudgeLine(tally: JudgeTally, w: Words): HTMLElement | undefined;
31
+ /** Put the mock-judge mark right under the header's title; a header without one takes it first. */
32
+ export declare function placeMockMark(header: HTMLElement, mark: HTMLElement | undefined): void;
33
+ /**
34
+ * The folded provenance line opens L1: it becomes the first row of the
35
+ * section card that holds the report's rows, ruled off from them. Without
36
+ * that section it keeps a card of its own.
37
+ */
38
+ export declare function leadWithProvenance(host: HTMLElement, section: Element | null, provenance: HTMLElement): void;
39
+ /**
40
+ * The Result's sealed aggregate, coverage first and then the buckets, each
41
+ * count with its unit (evaluations); `unknown_count` is "evaluations with
42
+ * an unknown result", never "unresolved". The numbers are the producer's
43
+ * (`statedCoverage`, the `buckets` lists), with a marker wherever the
44
+ * claims give another. When a claim is dated, or the out-of-scope switch
45
+ * is on, a line says the date "in force" is relative to and that these are
46
+ * the producer's copy of the contract (ER sections 4.2 and 4.3).
47
+ */
48
+ export declare function renderAggregate(result: ResultRoot, w: Words): HTMLElement;
49
+ /**
50
+ * "Check this report yourself": the bundle's own anchors (producer key,
51
+ * log, checkpoint root and size, record count) and the steps to re-check
52
+ * them. Module detail: it goes in L2 after the core's verification section,
53
+ * never in its place. The comparison step is drawn as a comparison only
54
+ * when the bundle carries a witness receipt; otherwise it says only that
55
+ * the bundle carries none, never that no outside checkpoint exists.
56
+ */
57
+ export declare function renderCheckYourself(bundle: unknown, w: Words): HTMLElement;
58
+ /**
59
+ * A table row that opens its full-width detail row, with no script needed:
60
+ * the row's name (the rule, test or obligation it opens) becomes the
61
+ * summary of a level-1 disclosure in its first cell, and the stylesheet
62
+ * shows the detail row while that disclosure is open. The row stays a
63
+ * table row and the disclosure takes its name from the row's own words.
64
+ * The detail's body is built when it first opens (or at once with
65
+ * `eager`); a click anywhere on the row opens it too. `key` names the
66
+ * detail row's id from what the row is, so every packaging of one bundle
67
+ * draws the same ids.
68
+ */
69
+ export declare function expandableRow(row: HTMLElement, name: HTMLElement, detail: HTMLElement, build: () => Node, key: string, eager?: boolean): HTMLDetailsElement;
70
+ /** A front card: the frame's centred white card, for blocks outside the sheet. */
71
+ export declare function frontCard(...children: HTMLElement[]): HTMLElement;
72
+ /**
73
+ * Open the module's own toggles to the host's depth (presentation contract
74
+ * section 9.1): at L0 none; at L1 the toggles in the L1 region; at L2 every
75
+ * toggle in every region, including the ones a toggle builds when it opens
76
+ * (see `openBuiltToDepth`). The core's section is the core's.
77
+ */
78
+ export declare function applyDepth(levels: ReportLevels): void;