pi-mega-compact 0.20.1 → 0.20.2

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 (85) hide show
  1. package/dist/config/vector-cortex.js +13 -0
  2. package/dist/config.js +1 -1
  3. package/dist/extensions/dashboard-server/routes-rag-settings-helpers.js +1 -0
  4. package/dist/extensions/dashboard-server/routes-vector-cortex-reconstruct.js +33 -0
  5. package/dist/extensions/dashboard-server/routes-vector-cortex.js +1 -0
  6. package/dist/extensions/dashboard-server/routes.js +1 -1
  7. package/dist/extensions/dashboard-server/server.js +3 -1
  8. package/dist/src/config/vector-cortex.js +13 -0
  9. package/dist/src/config.js +1 -1
  10. package/dist/src/vector-cortex/reconstruct/_acceptance-helpers.js +365 -0
  11. package/dist/src/vector-cortex/reconstruct/assemble.js +137 -0
  12. package/dist/src/vector-cortex/reconstruct/closure.js +268 -0
  13. package/dist/src/vector-cortex/reconstruct/types.js +46 -0
  14. package/dist/src/vector-cortex/reconstruct/validate.js +152 -0
  15. package/dist/vector-cortex/reconstruct/_acceptance-helpers.js +365 -0
  16. package/dist/vector-cortex/reconstruct/assemble.js +137 -0
  17. package/dist/vector-cortex/reconstruct/closure.js +268 -0
  18. package/dist/vector-cortex/reconstruct/types.js +46 -0
  19. package/dist/vector-cortex/reconstruct/validate.js +152 -0
  20. package/extensions/dashboard-client/dist/assets/{AreaChart-n4z5w9Ox.js → AreaChart-XF3jPpvn.js} +2 -2
  21. package/extensions/dashboard-client/dist/assets/{AreaChart-n4z5w9Ox.js.map → AreaChart-XF3jPpvn.js.map} +1 -1
  22. package/extensions/dashboard-client/dist/assets/{BarChart-BLGjWWBr.js → BarChart-DnYYn0GF.js} +2 -2
  23. package/extensions/dashboard-client/dist/assets/{BarChart-BLGjWWBr.js.map → BarChart-DnYYn0GF.js.map} +1 -1
  24. package/extensions/dashboard-client/dist/assets/{CacheTab-CAnrKKVK.js → CacheTab-D3bVskCL.js} +2 -2
  25. package/extensions/dashboard-client/dist/assets/{CacheTab-CAnrKKVK.js.map → CacheTab-D3bVskCL.js.map} +1 -1
  26. package/extensions/dashboard-client/dist/assets/{EventsTab-D-GL7Ngq.js → EventsTab-CX_8myfc.js} +2 -2
  27. package/extensions/dashboard-client/dist/assets/{EventsTab-D-GL7Ngq.js.map → EventsTab-CX_8myfc.js.map} +1 -1
  28. package/extensions/dashboard-client/dist/assets/{HealthTab-C4x5qQ8s.js → HealthTab-CnVzBQvN.js} +2 -2
  29. package/extensions/dashboard-client/dist/assets/{HealthTab-C4x5qQ8s.js.map → HealthTab-CnVzBQvN.js.map} +1 -1
  30. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BSPs0eq5.js → MaintenanceTab-Cao--dtV.js} +2 -2
  31. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-BSPs0eq5.js.map → MaintenanceTab-Cao--dtV.js.map} +1 -1
  32. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-BWEUtTSu.js → MemoryMapTab-DZdI-9ig.js} +2 -2
  33. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-BWEUtTSu.js.map → MemoryMapTab-DZdI-9ig.js.map} +1 -1
  34. package/extensions/dashboard-client/dist/assets/{MetricsTab-Dhm1c3Cx.js → MetricsTab-SlpSmNU4.js} +2 -2
  35. package/extensions/dashboard-client/dist/assets/{MetricsTab-Dhm1c3Cx.js.map → MetricsTab-SlpSmNU4.js.map} +1 -1
  36. package/extensions/dashboard-client/dist/assets/{OverviewTab-Cm6cySiQ.js → OverviewTab-C_-_4au9.js} +2 -2
  37. package/extensions/dashboard-client/dist/assets/{OverviewTab-Cm6cySiQ.js.map → OverviewTab-C_-_4au9.js.map} +1 -1
  38. package/extensions/dashboard-client/dist/assets/{ReposTab-DxLN1N4K.js → ReposTab-CyWedWZC.js} +2 -2
  39. package/extensions/dashboard-client/dist/assets/{ReposTab-DxLN1N4K.js.map → ReposTab-CyWedWZC.js.map} +1 -1
  40. package/extensions/dashboard-client/dist/assets/{SessionsTab-CZuI4ISW.js → SessionsTab-wqPBMIJZ.js} +2 -2
  41. package/extensions/dashboard-client/dist/assets/{SessionsTab-CZuI4ISW.js.map → SessionsTab-wqPBMIJZ.js.map} +1 -1
  42. package/extensions/dashboard-client/dist/assets/{SetupTab-C_0VOomm.js → SetupTab-MojXmuUf.js} +2 -2
  43. package/extensions/dashboard-client/dist/assets/{SetupTab-C_0VOomm.js.map → SetupTab-MojXmuUf.js.map} +1 -1
  44. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-BhbaRLmi.js → TimeSavedCard-BxcplEOJ.js} +2 -2
  45. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-BhbaRLmi.js.map → TimeSavedCard-BxcplEOJ.js.map} +1 -1
  46. package/extensions/dashboard-client/dist/assets/{TurnsTab-CXJmbjje.js → TurnsTab-D8_qWbjY.js} +2 -2
  47. package/extensions/dashboard-client/dist/assets/{TurnsTab-CXJmbjje.js.map → TurnsTab-D8_qWbjY.js.map} +1 -1
  48. package/extensions/dashboard-client/dist/assets/VectorCortexTab-B3yisAyB.js +2 -0
  49. package/extensions/dashboard-client/dist/assets/VectorCortexTab-B3yisAyB.js.map +1 -0
  50. package/extensions/dashboard-client/dist/assets/{WikiTab-C5uvMCzp.js → WikiTab-Cfd-QZYz.js} +2 -2
  51. package/extensions/dashboard-client/dist/assets/{WikiTab-C5uvMCzp.js.map → WikiTab-Cfd-QZYz.js.map} +1 -1
  52. package/extensions/dashboard-client/dist/assets/{button-Cl_fxJcg.js → button-tX5ht0bb.js} +2 -2
  53. package/extensions/dashboard-client/dist/assets/{button-Cl_fxJcg.js.map → button-tX5ht0bb.js.map} +1 -1
  54. package/extensions/dashboard-client/dist/assets/{card-BH8Le5YM.js → card-BT3Z5dDg.js} +2 -2
  55. package/extensions/dashboard-client/dist/assets/{card-BH8Le5YM.js.map → card-BT3Z5dDg.js.map} +1 -1
  56. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-sZ6ZNtBi.js → generateCategoricalChart-B6p2WnkY.js} +2 -2
  57. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-sZ6ZNtBi.js.map → generateCategoricalChart-B6p2WnkY.js.map} +1 -1
  58. package/extensions/dashboard-client/dist/assets/{index-CX9zv8cJ.js → index-CFLekP12.js} +3 -3
  59. package/extensions/dashboard-client/dist/assets/{index-CX9zv8cJ.js.map → index-CFLekP12.js.map} +1 -1
  60. package/extensions/dashboard-client/dist/assets/{switch-CXJhcjhM.js → switch-B52oAMSw.js} +2 -2
  61. package/extensions/dashboard-client/dist/assets/{switch-CXJhcjhM.js.map → switch-B52oAMSw.js.map} +1 -1
  62. package/extensions/dashboard-client/dist/assets/{toggle-CoLtIc6y.js → toggle-VxxVc5Tp.js} +2 -2
  63. package/extensions/dashboard-client/dist/assets/{toggle-CoLtIc6y.js.map → toggle-VxxVc5Tp.js.map} +1 -1
  64. package/extensions/dashboard-client/dist/assets/{useSSE-fSXho606.js → useSSE-DAVdZnG7.js} +2 -2
  65. package/extensions/dashboard-client/dist/assets/{useSSE-fSXho606.js.map → useSSE-DAVdZnG7.js.map} +1 -1
  66. package/extensions/dashboard-client/dist/index.html +1 -1
  67. package/extensions/dashboard-client/src/api/vector-cortex.ts +9 -0
  68. package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +37 -0
  69. package/extensions/dashboard-client/src/types/vector-cortex.ts +16 -0
  70. package/extensions/dashboard-server/api-contracts/vector-cortex.ts +28 -0
  71. package/extensions/dashboard-server/routes-rag-settings-helpers.ts +6 -0
  72. package/extensions/dashboard-server/routes-vector-cortex-reconstruct.ts +41 -0
  73. package/extensions/dashboard-server/routes-vector-cortex.ts +1 -0
  74. package/extensions/dashboard-server/routes.ts +1 -0
  75. package/extensions/dashboard-server/server.ts +2 -0
  76. package/package.json +1 -1
  77. package/src/config/vector-cortex.ts +14 -0
  78. package/src/config.ts +1 -0
  79. package/src/vector-cortex/reconstruct/_acceptance-helpers.ts +455 -0
  80. package/src/vector-cortex/reconstruct/assemble.ts +170 -0
  81. package/src/vector-cortex/reconstruct/closure.ts +299 -0
  82. package/src/vector-cortex/reconstruct/types.ts +330 -0
  83. package/src/vector-cortex/reconstruct/validate.ts +184 -0
  84. package/extensions/dashboard-client/dist/assets/VectorCortexTab-BGe9hu3r.js +0 -2
  85. package/extensions/dashboard-client/dist/assets/VectorCortexTab-BGe9hu3r.js.map +0 -1
@@ -0,0 +1,268 @@
1
+ /**
2
+ * vector-cortex/reconstruct/closure.ts — mandatory conservative closure (VC4C).
3
+ *
4
+ * Task 2/3: a WORKLIST recursion that repeatedly adds every `depends`
5
+ * predecessor and every whole tool pair of an already-selected node until the
6
+ * selection stops growing (a FIXED POINT), tracking visited ids so a cyclic
7
+ * graph terminates instead of recursing forever. Task 3: contradictions are
8
+ * resolved by retaining the LATER exact source resolution; an explicit
9
+ * resolution event may name the loser directly; equal/unordered resolutions are
10
+ * an unresolved tie and return `CLO_CONTRADICTION_UNRESOLVED` so the candidate
11
+ * never goes live (CONTRACTS §plan and closure).
12
+ *
13
+ * Determinism: the worklist is drained in sorted id order and every returned
14
+ * array is sorted, so the closed set is identical regardless of the order seeds
15
+ * or edges were supplied in. Time is never read here — contradiction ordering
16
+ * uses the SOURCE `resolvedAtMs` fact carried on the node.
17
+ *
18
+ * OWNERSHIP: `mandatoryTokenEstimate` is CONTENT ONLY (no prompt framing) and is
19
+ * handed unchanged to VC5A, which owns framing + budget admission and returns
20
+ * `MANDATORY_CLOSURE_OVER_BUDGET` on overflow. Closure NEVER truncates a
21
+ * mandatory node.
22
+ *
23
+ * Pure/deterministic: no storage, no console, no network (PREVENT-PI-004 /
24
+ * PREVENT-011).
25
+ */
26
+ /** Sorted copy (bytewise id order) — every closure output is order-stable. */
27
+ function sortedIds(ids) {
28
+ return [...ids].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
29
+ }
30
+ /** Index the graph's nodes by id (last wins is impossible — ids are unique). */
31
+ function indexNodes(graph) {
32
+ const byId = new Map();
33
+ for (const n of graph.nodes)
34
+ byId.set(n.id, n);
35
+ return byId;
36
+ }
37
+ /**
38
+ * Build the "requirement" adjacency: for a selected node `x`, which nodes must
39
+ * ALSO be selected. Edges point prerequisite `from` → dependent `to`, so:
40
+ *
41
+ * - `depends` — selecting `to` requires `from` (walk BACKWARD to the
42
+ * prerequisite; this is the transitive dependency closure);
43
+ * - `tool-pair` — the pair is atomic, so selecting EITHER endpoint requires
44
+ * the other (walk BOTH directions — a pair is never split,
45
+ * PREVENT-PI-002).
46
+ *
47
+ * `contradicts` is deliberately absent: a contradiction never PULLS a node in,
48
+ * it removes one (resolved separately below).
49
+ */
50
+ function buildRequirements(edges) {
51
+ const req = new Map();
52
+ const add = (key, id, rule) => {
53
+ const list = req.get(key);
54
+ if (list === undefined)
55
+ req.set(key, [{ id, rule }]);
56
+ else
57
+ list.push({ id, rule });
58
+ };
59
+ for (const e of edges) {
60
+ if (e.kind === "depends") {
61
+ add(e.to, e.from, "depends");
62
+ continue;
63
+ }
64
+ if (e.kind === "tool-pair") {
65
+ add(e.to, e.from, "tool-pair");
66
+ add(e.from, e.to, "tool-pair");
67
+ }
68
+ }
69
+ return req;
70
+ }
71
+ /**
72
+ * Resolve one contradiction pair. Returns the loser id, or `null` when the pair
73
+ * is an unresolved tie.
74
+ *
75
+ * Precedence (CONTRACTS §plan and closure):
76
+ * 1. An explicit resolution event naming the loser wins outright.
77
+ * 2. Otherwise the LATER exact source resolution supersedes the earlier claim.
78
+ * "Exact" is required: a semantic node never supersedes an exact one, since
79
+ * semantic vectors never claim to recover exact text (RESIDUAL_CODEC).
80
+ * 3. Equal timestamps, missing timestamps, or two non-exact claims are
81
+ * UNORDERED — keep both and reject live use.
82
+ */
83
+ function resolveContradiction(a, b, explicit) {
84
+ // 1. Explicit resolution event names the loser directly.
85
+ const aLoses = explicit.get(a.id);
86
+ if (aLoses === b.id)
87
+ return a.id;
88
+ const bLoses = explicit.get(b.id);
89
+ if (bLoses === a.id)
90
+ return b.id;
91
+ // 2. Later EXACT source resolution supersedes the earlier claim. Both sides
92
+ // must be exact and both must carry a source resolution time.
93
+ const aExact = a.kind === "exact";
94
+ const bExact = b.kind === "exact";
95
+ const aAt = a.resolvedAtMs;
96
+ const bAt = b.resolvedAtMs;
97
+ if (aExact && bExact && aAt !== undefined && bAt !== undefined && aAt !== bAt) {
98
+ return aAt < bAt ? a.id : b.id;
99
+ }
100
+ // 3. Equal / unordered / non-exact — unresolved tie.
101
+ return null;
102
+ }
103
+ /**
104
+ * Close a selection conservatively to a fixed point (task 2 + 3).
105
+ *
106
+ * Algorithm: seed the worklist with the requested ids (plus the anchor floor,
107
+ * which is always mandatory), then repeatedly pop the smallest id and add every
108
+ * node it requires. A `visited` set makes each node expand exactly once, so a
109
+ * cycle (`a depends b`, `b depends a`) terminates at the fixed point rather than
110
+ * recursing forever. Contradictions among the CLOSED set are then resolved; an
111
+ * unresolved tie fails the closure.
112
+ */
113
+ export function closeSelection(input) {
114
+ const { graph, seeds } = input;
115
+ const byId = indexNodes(graph);
116
+ const failures = [];
117
+ // Structural validation: every edge endpoint and every seed must exist.
118
+ for (const e of graph.edges) {
119
+ if (!byId.has(e.from) || !byId.has(e.to)) {
120
+ if (!failures.includes("CLO_MISSING_NODE"))
121
+ failures.push("CLO_MISSING_NODE");
122
+ }
123
+ }
124
+ for (const s of seeds) {
125
+ if (!byId.has(s)) {
126
+ if (!failures.includes("CLO_UNKNOWN_SEED"))
127
+ failures.push("CLO_UNKNOWN_SEED");
128
+ }
129
+ }
130
+ if (failures.length > 0) {
131
+ return {
132
+ ok: false,
133
+ selected: [],
134
+ addedDependencies: [],
135
+ removedContradictions: [],
136
+ unresolved: [],
137
+ proof: [],
138
+ failures,
139
+ mandatoryTokenEstimate: 0,
140
+ };
141
+ }
142
+ const requirements = buildRequirements(graph.edges);
143
+ const selected = new Set();
144
+ const proof = [];
145
+ const seedSet = new Set(seeds);
146
+ // The anchor floor is ALWAYS mandatory: an anchor is never dropped by closure
147
+ // (PREVENT-PI-001's anchor-floor discipline restated for the closed prompt).
148
+ const anchorIds = graph.nodes.filter((n) => n.anchor === true).map((n) => n.id);
149
+ // Seed the worklist deterministically (sorted), anchors after explicit seeds
150
+ // so the proof reads "what was asked for, then what the floor forced".
151
+ const worklist = [];
152
+ for (const id of sortedIds(seedSet)) {
153
+ if (selected.has(id))
154
+ continue;
155
+ selected.add(id);
156
+ proof.push({ added: id, rule: "seed" });
157
+ worklist.push(id);
158
+ }
159
+ for (const id of sortedIds(anchorIds)) {
160
+ if (selected.has(id))
161
+ continue;
162
+ selected.add(id);
163
+ proof.push({ added: id, rule: "anchor-floor" });
164
+ worklist.push(id);
165
+ }
166
+ // ── Worklist recursion to a FIXED POINT (visited = `selected`) ─────────────
167
+ // Each id is expanded at most once because it can only enter the worklist at
168
+ // the moment it is inserted into `selected`. A cyclic graph therefore
169
+ // terminates: the second traversal of the cycle finds every node already
170
+ // selected and adds nothing.
171
+ while (worklist.length > 0) {
172
+ // Drain in sorted order so the proof is deterministic across input orders.
173
+ worklist.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
174
+ const current = worklist.shift();
175
+ if (current === undefined)
176
+ break;
177
+ const required = requirements.get(current) ?? [];
178
+ // Sort the requirements of one node so sibling additions are ordered too.
179
+ const ordered = [...required].sort((x, y) => x.id < y.id ? -1 : x.id > y.id ? 1 : x.rule < y.rule ? -1 : x.rule > y.rule ? 1 : 0);
180
+ for (const { id, rule } of ordered) {
181
+ if (selected.has(id))
182
+ continue; // already at the fixed point for this node
183
+ selected.add(id);
184
+ proof.push({ added: id, requiredBy: current, rule });
185
+ worklist.push(id);
186
+ }
187
+ }
188
+ // ── Contradiction resolution over the CLOSED set (task 3) ─────────────────
189
+ const explicit = new Map();
190
+ for (const r of graph.resolutions ?? [])
191
+ explicit.set(r.loserId, r.winnerId);
192
+ const removed = new Set();
193
+ const unresolved = new Set();
194
+ for (const e of graph.edges) {
195
+ if (e.kind !== "contradicts")
196
+ continue;
197
+ // Only contradictions BETWEEN TWO SELECTED nodes matter: an unselected claim
198
+ // cannot contradict the prompt that is actually being built.
199
+ if (!selected.has(e.from) || !selected.has(e.to))
200
+ continue;
201
+ const a = byId.get(e.from);
202
+ const b = byId.get(e.to);
203
+ if (a === undefined || b === undefined)
204
+ continue;
205
+ // A pair already decided by an earlier edge (duplicate contradiction) is
206
+ // skipped so one resolution is not re-litigated into a false tie.
207
+ if (removed.has(a.id) || removed.has(b.id))
208
+ continue;
209
+ const loser = resolveContradiction(a, b, explicit);
210
+ if (loser === null) {
211
+ unresolved.add(a.id);
212
+ unresolved.add(b.id);
213
+ continue;
214
+ }
215
+ removed.add(loser);
216
+ }
217
+ // A node that lost a contradiction leaves the selection. An unresolved tie
218
+ // keeps BOTH (CONTRACTS: "ties keep both and reject live use") and fails.
219
+ for (const id of removed)
220
+ selected.delete(id);
221
+ const selectedIds = sortedIds(selected);
222
+ const addedDependencies = selectedIds.filter((id) => !seedSet.has(id));
223
+ const mandatoryTokenEstimate = selectedIds.reduce((sum, id) => sum + (byId.get(id)?.tokenEstimate ?? 0), 0);
224
+ const ok = unresolved.size === 0;
225
+ return {
226
+ ok,
227
+ selected: selectedIds,
228
+ addedDependencies,
229
+ removedContradictions: sortedIds(removed),
230
+ unresolved: sortedIds(unresolved),
231
+ proof,
232
+ failures: ok ? [] : ["CLO_CONTRADICTION_UNRESOLVED"],
233
+ mandatoryTokenEstimate,
234
+ };
235
+ }
236
+ /**
237
+ * Whether a closure result is a genuine fixed point: re-running the closure over
238
+ * its own output adds nothing. Used by the acceptance invariant ("closure reaches
239
+ * a fixed point") — an independent CHECK rather than a restatement of the loop.
240
+ */
241
+ export function isFixedPoint(graph, result) {
242
+ if (!result.ok)
243
+ return true; // a rejected closure is not required to be closed
244
+ const again = closeSelection({ graph, seeds: result.selected });
245
+ if (!again.ok)
246
+ return false;
247
+ return (again.selected.length === result.selected.length &&
248
+ again.selected.every((id, i) => id === result.selected[i]));
249
+ }
250
+ /**
251
+ * Mode B: a GREEDY EXACT-ONLY closure, forced when semantic validation fails.
252
+ * Independent of mode A by construction — it consults no semantic node and no
253
+ * semantic index, deriving purely from the exact/event source tiers
254
+ * (TRIAD_RESILIENCE: A/B must not share the same algorithm or index).
255
+ */
256
+ export function closeExactOnly(input) {
257
+ const exactGraph = {
258
+ sessionId: input.graph.sessionId,
259
+ nodes: input.graph.nodes.filter((n) => n.kind !== "semantic"),
260
+ edges: input.graph.edges.filter((e) => {
261
+ const kinds = new Map(input.graph.nodes.map((n) => [n.id, n.kind]));
262
+ return kinds.get(e.from) !== "semantic" && kinds.get(e.to) !== "semantic";
263
+ }),
264
+ resolutions: input.graph.resolutions,
265
+ };
266
+ const seeds = input.seeds.filter((id) => exactGraph.nodes.some((n) => n.id === id));
267
+ return closeSelection({ graph: exactGraph, seeds });
268
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * vector-cortex/reconstruct/types.ts — conservative closure + reconstruction
3
+ * fidelity contract (VC4C).
4
+ *
5
+ * Owns `ClosureResult` / `ReconstructionV1` — the contract of the sprint failure
6
+ * triad:
7
+ *
8
+ * A = closed semantic + exact/residual reconstruction (the normal path);
9
+ * B = greedy EXACT-only closure, forced when semantic validation fails;
10
+ * C = legacy prompt, forced by an unresolved contradiction (states its loss of
11
+ * old semantic context — TRIAD_RESILIENCE: C is continuity, NOT semantic
12
+ * completeness).
13
+ *
14
+ * Closure is MANDATORY before VC5 (CONTRACTS §plan and closure): recursively add
15
+ * every `depends`/tool-pair predecessor until a fixed point; for contradictions
16
+ * keep the LATER exact source resolution unless an explicit resolution event
17
+ * names the loser; ties keep both and reject live use
18
+ * (`CLO_CONTRADICTION_UNRESOLVED`). The anchor floor is preserved, and the closed
19
+ * mandatory node set is returned with its deterministic token estimate.
20
+ *
21
+ * OWNERSHIP BOUNDARY (CONTRACTS §plan and closure): `mandatoryTokenEstimate`
22
+ * counts CONTENT ONLY — no prompt framing, no role tags, no separators, no
23
+ * budget admission. VC5A exclusively owns framing/budget: it adds framing cost
24
+ * to this estimate and returns `MANDATORY_CLOSURE_OVER_BUDGET` if the mandatory
25
+ * cost exceeds its `tokenBudget`. VC4C therefore NEVER truncates a mandatory
26
+ * node and never reasons about a budget.
27
+ *
28
+ * Consumes only reviewer-accepted predecessor contracts (VC1A `EventV2` byte
29
+ * authority, VC4A `ShardRange`/`ExactShardV1`, VC4B `ParityShardV1` residual
30
+ * decode) and the common contracts. Pure types + registered conformance IDs: no
31
+ * storage, no console, no network (PREVENT-PI-004 / PREVENT-011).
32
+ */
33
+ /**
34
+ * Registered CLO conformance ID range (CLO-001..030). The acceptance test reads
35
+ * these rows from the v2 manifest and asserts each returns its manifest
36
+ * `ok`/`code`.
37
+ */
38
+ export const CLO_IDS = Array.from({ length: 30 }, (_v, i) => `CLO-${String(i + 1).padStart(3, "0")}`);
39
+ /** Registered REC conformance ID range (REC-001..030). */
40
+ export const REC_IDS = Array.from({ length: 30 }, (_v, i) => `REC-${String(i + 1).padStart(3, "0")}`);
41
+ /** Named VC4C conformance assertions (the sprint's headline rows). */
42
+ export const RECONSTRUCT_NAMED_IDS = [
43
+ "CLO-TRANSITIVE-001",
44
+ "CLO-CONTRA-002",
45
+ "REC-ORDER-003",
46
+ ];
@@ -0,0 +1,152 @@
1
+ /**
2
+ * vector-cortex/reconstruct/validate.ts — reconstruction validation (VC4C).
3
+ *
4
+ * Task 5: a validator that rejects a closed selection that would corrupt a live
5
+ * prompt and emits exactly two events:
6
+ * - `vector_cortex_reconstruction_validated` (the good outcome)
7
+ * - `vector_cortex_closure_rejected` (a rejected/cancelled closure)
8
+ *
9
+ * Rejection reasons (the failure codes are the ONLY externally-visible detail):
10
+ * - REC_ANCHOR_MISSING an anchor-floor node is absent from the closure
11
+ * - REC_TOOL_PAIR_SPLIT a tool-pair is not contiguous (PREVENT-PI-002)
12
+ * - REC_DIGEST_MISMATCH a decoded shard's bytes disagree with its digest
13
+ * - REC_CONTRADICTION_UNRESOLVED an unresolved tie (closure already failed)
14
+ * - REC_SOURCE_UNAVAILABLE a required shard is missing/erased (failure inj.)
15
+ * - REC_SPAN_OVERLAP two spans intersect in source byte space
16
+ *
17
+ * The validator NEVER emits content; it exposes only a `ReconstructionSummary`
18
+ * (counts + digest + token estimate) or the failure `codes`. Assembly/closure
19
+ * errors are surfaced but the validator is the authoritative last gate.
20
+ *
21
+ * OWNERSHIP: this is a PURE function over its inputs — no storage, no network,
22
+ * no console. The dashboard/seams that consume it live in extensions/, which may
23
+ * emit observability; this module stays silent (structured logging contract).
24
+ */
25
+ import { createHash } from "node:crypto";
26
+ import { assembleSourceOrder } from "./assemble.js";
27
+ /** Flag-gated reporter — mirrors the VC4B residual reporter pattern. */
28
+ export function createReconstructReporter(emit) {
29
+ const fire = (event, fields) => {
30
+ if (!emit)
31
+ return;
32
+ try {
33
+ emit(event, fields);
34
+ }
35
+ catch {
36
+ /* non-fatal observability — never break the agent loop */
37
+ }
38
+ };
39
+ return {
40
+ reconstructionValidated: (fields) => fire("vector_cortex_reconstruction_validated", fields),
41
+ closureRejected: (fields) => fire("vector_cortex_closure_rejected", fields),
42
+ };
43
+ }
44
+ /** Sync SHA-256 hex (validator is sync except for assembly's concat digest). */
45
+ function sha256HexSync(bytes) {
46
+ return createHash("sha256").update(bytes).digest("hex");
47
+ }
48
+ /** Verify each decoded shard's bytes hash to its declared digest (REC_DIGEST_MISMATCH). */
49
+ function findDigestMismatch(shards) {
50
+ for (const s of shards) {
51
+ // A pinned digest of "0" is a placeholder: the source tier did not compute a
52
+ // per-shard digest, so the only guarantee is the post-assembly concatenation
53
+ // digest. Any other digest is a real pin that must match exactly.
54
+ if (s.digest === "0")
55
+ continue;
56
+ const computed = sha256HexSync(s.bytes);
57
+ if (computed !== s.digest)
58
+ return "REC_DIGEST_MISMATCH";
59
+ }
60
+ return null;
61
+ }
62
+ /**
63
+ * Validate a closed selection and, on success, assemble it into source order.
64
+ * Returns the discriminated `ReconstructionValidation`: ok -> summary only;
65
+ * fail -> failure codes only. Emits exactly one of the two events.
66
+ */
67
+ export async function validateAndAssemble(input) {
68
+ const { graph, closure, nodes, edges, shards, emit } = input;
69
+ const reporter = createReconstructReporter(emit);
70
+ // 1. A closure that failed its own contradiction resolution cannot go live.
71
+ if (!closure.ok) {
72
+ const codes = ["REC_CONTRADICTION_UNRESOLVED"];
73
+ reporter.closureRejected({ sessionId: graph.sessionId, codes, reason: "closure-not-ok" });
74
+ return {
75
+ validation: { ok: false, codes },
76
+ reconstruction: null,
77
+ };
78
+ }
79
+ // 2. Anchor-floor discipline (PREVENT-PI-001 restated): every anchor node must
80
+ // be present in the closed set, or the closure silently dropped a floor
81
+ // item and must be rejected.
82
+ const anchorMissing = nodes.some((n) => n.anchor === true && !closure.selected.includes(n.id));
83
+ if (anchorMissing) {
84
+ reporter.closureRejected({ sessionId: graph.sessionId, codes: ["REC_ANCHOR_MISSING"], reason: "anchor-missing" });
85
+ return {
86
+ validation: { ok: false, codes: ["REC_ANCHOR_MISSING"] },
87
+ reconstruction: null,
88
+ };
89
+ }
90
+ // 3. Unresolved contradiction present in the closed set.
91
+ if (closure.unresolved.length > 0) {
92
+ const codes = ["REC_CONTRADICTION_UNRESOLVED"];
93
+ reporter.closureRejected({ sessionId: graph.sessionId, codes, reason: "unresolved-contradiction" });
94
+ return {
95
+ validation: { ok: false, codes },
96
+ reconstruction: null,
97
+ };
98
+ }
99
+ // 4. Per-shard digest pre-check hook (REC_DIGEST_MISMATCH path preserved).
100
+ const digestCode = findDigestMismatch(shards);
101
+ if (digestCode !== null) {
102
+ reporter.closureRejected({ sessionId: graph.sessionId, codes: [digestCode], reason: "digest-mismatch" });
103
+ return {
104
+ validation: { ok: false, codes: [digestCode] },
105
+ reconstruction: null,
106
+ };
107
+ }
108
+ // 5. Assembly: missing source (REC_SOURCE_UNAVAILABLE) / split pair
109
+ // (REC_TOOL_PAIR_SPLIT) / overlap (REC_SPAN_OVERLAP) all surface here.
110
+ const assembled = await assembleSourceOrder({
111
+ sessionId: graph.sessionId,
112
+ selected: closure.selected,
113
+ nodes,
114
+ edges,
115
+ shards,
116
+ mandatoryTokenEstimate: closure.mandatoryTokenEstimate,
117
+ });
118
+ if (assembled.code !== null || assembled.reconstruction === null) {
119
+ const code = assembled.code ?? "REC_DIGEST_MISMATCH";
120
+ reporter.closureRejected({ sessionId: graph.sessionId, codes: [code], reason: "assembly-failed" });
121
+ return {
122
+ validation: { ok: false, codes: [code] },
123
+ reconstruction: null,
124
+ };
125
+ }
126
+ const rec = assembled.reconstruction;
127
+ const summary = buildSummary(rec);
128
+ reporter.reconstructionValidated({
129
+ sessionId: rec.sessionId,
130
+ spanCount: summary.spanCount,
131
+ protectedSpanCount: summary.protectedSpanCount,
132
+ byteTotal: summary.byteTotal,
133
+ mandatoryTokenEstimate: summary.mandatoryTokenEstimate,
134
+ digest: summary.digest,
135
+ bySource: summary.bySource,
136
+ });
137
+ return { validation: { ok: true, summary }, reconstruction: rec };
138
+ }
139
+ function buildSummary(rec) {
140
+ const exact = rec.spans.filter((s) => s.source === "exact").length;
141
+ const residual = rec.spans.filter((s) => s.source === "residual").length;
142
+ const semantic = rec.spans.filter((s) => s.source === "semantic").length;
143
+ return {
144
+ sessionId: rec.sessionId,
145
+ spanCount: rec.spans.length,
146
+ protectedSpanCount: rec.spans.filter((s) => s.protectedSpan).length,
147
+ byteTotal: rec.byteTotal,
148
+ mandatoryTokenEstimate: rec.mandatoryTokenEstimate,
149
+ digest: rec.digest,
150
+ bySource: { exact, residual, semantic },
151
+ };
152
+ }
@@ -1,2 +1,2 @@
1
- import{b as R,c as W,m as T,i as C,d as F,A as ie,e as B,h as q,j as oe,k as G,l as se,n as le,u as ue,o as K,G as ce,p as J,q as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-sZ6ZNtBi.js";import{R as p,F as ee,r as ve}from"./index-CX9zv8cJ.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(c)?p.createElement("rect",{x:u<l?u:u-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].y,l=o[o.length-1].y,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.x||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.x||0})),c)),C(c)?p.createElement("rect",{x:0,y:u<l?u:u-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,i,o){var s=this.props,u=s.layout,l=s.type,f=s.stroke,c=s.connectNulls,h=s.isRange;s.ref;var A=ae(s,ye);return p.createElement(W,{clipPath:i?"url(#clipPath-".concat(o,")"):null},p.createElement(F,D({},R(A,!0),{points:a,connectNulls:c,type:l,baseLine:n,layout:u,stroke:"none",className:"recharts-area-area"})),f!=="none"&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:a})),f!=="none"&&h&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var i=this,o=this.props,s=o.points,u=o.baseLine,l=o.isAnimationActive,f=o.animationBegin,c=o.animationDuration,h=o.animationEasing,A=o.animationId,g=this.state,x=g.prevPoints,v=g.prevBaseLine;return p.createElement(ie,{begin:f,duration:c,isActive:l,easing:h,from:{t:0},to:{t:1},key:"area-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var y=O.t;if(x){var _=x.length/s.length,d=s.map(function(P,N){var k=Math.floor(N*_);if(x[k]){var j=x[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P}),m;if(C(u)&&typeof u=="number"){var b=B(v,u);m=b(y)}else if(q(u)||oe(u)){var w=B(v,0);m=w(y)}else m=u.map(function(P,N){var k=Math.floor(N*_);if(v[k]){var j=v[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P});return i.renderAreaStatically(d,m,a,n)}return p.createElement(W,null,p.createElement("defs",null,p.createElement("clipPath",{id:"animationClipPath-".concat(n)},i.renderClipRect(y))),p.createElement(W,{clipPath:"url(#animationClipPath-".concat(n,")")},i.renderAreaStatically(s,u,a,n)))})}},{key:"renderArea",value:function(a,n){var i=this.props,o=i.points,s=i.baseLine,u=i.isAnimationActive,l=this.state,f=l.prevPoints,c=l.prevBaseLine,h=l.totalLength;return u&&o&&o.length&&(!f&&h>0||!G(f,o)||!G(c,s))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(o,s,a,n)}},{key:"render",value:function(){var a,n=this.props,i=n.hide,o=n.dot,s=n.points,u=n.className,l=n.top,f=n.left,c=n.xAxis,h=n.yAxis,A=n.width,g=n.height,x=n.isAnimationActive,v=n.id;if(i||!s||!s.length)return null;var O=this.state.isAnimationFinished,y=s.length===1,_=ee("recharts-area",u),d=c&&c.allowDataOverflow,m=h&&h.allowDataOverflow,b=d||m,w=q(v)?this.id:v,P=(a=R(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},N=P.r,k=N===void 0?3:N,j=P.strokeWidth,I=j===void 0?2:j,V=se(o)?o:{},Y=V.clipDot,H=Y===void 0?!0:Y,z=k*2+I;return p.createElement(W,{className:_},d||m?p.createElement("defs",null,p.createElement("clipPath",{id:"clipPath-".concat(w)},p.createElement("rect",{x:d?f:f-A/2,y:m?l:l-g/2,width:d?A:A*2,height:m?g:g*2})),!H&&p.createElement("clipPath",{id:"clipPath-dots-".concat(w)},p.createElement("rect",{x:f-z/2,y:l-z/2,width:A+z,height:g+z}))):null,y?null:this.renderArea(b,w),(o||y)&&this.renderDots(b,H,w),(!x||O)&&le.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])}(ve.PureComponent);te=L;E(L,"displayName","Area");E(L,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ce.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});E(L,"getBaseValue",function(e,t,r,a){var n=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(C(s)&&typeof s=="number")return s;var u=n==="horizontal"?a:r,l=u.scale.domain();if(u.type==="number"){var f=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]});E(L,"getComposedData",function(e){var t=e.props,r=e.item,a=e.xAxis,n=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,u=e.dataKey,l=e.stackedData,f=e.dataStartIndex,c=e.displayedData,h=e.offset,A=t.layout,g=l&&l.length,x=te.getBaseValue(t,r,a,n),v=A==="horizontal",O=!1,y=c.map(function(d,m){var b;g?b=l[f+m]:(b=J(d,u),Array.isArray(b)?O=!0:b=[x,b]);var w=b[1]==null||g&&J(d,u)==null;return v?{x:Q({axis:a,ticks:i,bandSize:s,entry:d,index:m}),y:w?null:n.scale(b[1]),value:b,payload:d}:{x:w?null:a.scale(b[1]),y:Q({axis:n,ticks:o,bandSize:s,entry:d,index:m}),value:b,payload:d}}),_;return g||O?_=y.map(function(d){var m=Array.isArray(d.value)?d.value[0]:null;return v?{x:d.x,y:m!=null&&d.y!=null?n.scale(m):null}:{x:m!=null?a.scale(m):null,y:d.y}}):_=v?n.scale(x):a.scale(x),S({points:y,baseLine:_,layout:A,isRange:O},h)});E(L,"renderDotItem",function(e,t){var r;if(p.isValidElement(e))r=p.cloneElement(e,t);else if(K(e))r=e(t);else{var a=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),n=t.key,i=ae(t,be);r=p.createElement(fe,D({},i,{key:n,className:a}))}return r});var ke=pe({chartName:"AreaChart",GraphicalChild:L,axisComponents:[{axisType:"xAxis",AxisComp:he},{axisType:"yAxis",AxisComp:de}],formatAxisMap:me});export{ke as A,L as a};
2
- //# sourceMappingURL=AreaChart-n4z5w9Ox.js.map
1
+ import{b as R,c as W,m as T,i as C,d as F,A as ie,e as B,h as q,j as oe,k as G,l as se,n as le,u as ue,o as K,G as ce,p as J,q as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-B6p2WnkY.js";import{R as p,F as ee,r as ve}from"./index-CFLekP12.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(c)?p.createElement("rect",{x:u<l?u:u-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].y,l=o[o.length-1].y,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.x||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.x||0})),c)),C(c)?p.createElement("rect",{x:0,y:u<l?u:u-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,i,o){var s=this.props,u=s.layout,l=s.type,f=s.stroke,c=s.connectNulls,h=s.isRange;s.ref;var A=ae(s,ye);return p.createElement(W,{clipPath:i?"url(#clipPath-".concat(o,")"):null},p.createElement(F,D({},R(A,!0),{points:a,connectNulls:c,type:l,baseLine:n,layout:u,stroke:"none",className:"recharts-area-area"})),f!=="none"&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:a})),f!=="none"&&h&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var i=this,o=this.props,s=o.points,u=o.baseLine,l=o.isAnimationActive,f=o.animationBegin,c=o.animationDuration,h=o.animationEasing,A=o.animationId,g=this.state,x=g.prevPoints,v=g.prevBaseLine;return p.createElement(ie,{begin:f,duration:c,isActive:l,easing:h,from:{t:0},to:{t:1},key:"area-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var y=O.t;if(x){var _=x.length/s.length,d=s.map(function(P,N){var k=Math.floor(N*_);if(x[k]){var j=x[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P}),m;if(C(u)&&typeof u=="number"){var b=B(v,u);m=b(y)}else if(q(u)||oe(u)){var w=B(v,0);m=w(y)}else m=u.map(function(P,N){var k=Math.floor(N*_);if(v[k]){var j=v[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P});return i.renderAreaStatically(d,m,a,n)}return p.createElement(W,null,p.createElement("defs",null,p.createElement("clipPath",{id:"animationClipPath-".concat(n)},i.renderClipRect(y))),p.createElement(W,{clipPath:"url(#animationClipPath-".concat(n,")")},i.renderAreaStatically(s,u,a,n)))})}},{key:"renderArea",value:function(a,n){var i=this.props,o=i.points,s=i.baseLine,u=i.isAnimationActive,l=this.state,f=l.prevPoints,c=l.prevBaseLine,h=l.totalLength;return u&&o&&o.length&&(!f&&h>0||!G(f,o)||!G(c,s))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(o,s,a,n)}},{key:"render",value:function(){var a,n=this.props,i=n.hide,o=n.dot,s=n.points,u=n.className,l=n.top,f=n.left,c=n.xAxis,h=n.yAxis,A=n.width,g=n.height,x=n.isAnimationActive,v=n.id;if(i||!s||!s.length)return null;var O=this.state.isAnimationFinished,y=s.length===1,_=ee("recharts-area",u),d=c&&c.allowDataOverflow,m=h&&h.allowDataOverflow,b=d||m,w=q(v)?this.id:v,P=(a=R(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},N=P.r,k=N===void 0?3:N,j=P.strokeWidth,I=j===void 0?2:j,V=se(o)?o:{},Y=V.clipDot,H=Y===void 0?!0:Y,z=k*2+I;return p.createElement(W,{className:_},d||m?p.createElement("defs",null,p.createElement("clipPath",{id:"clipPath-".concat(w)},p.createElement("rect",{x:d?f:f-A/2,y:m?l:l-g/2,width:d?A:A*2,height:m?g:g*2})),!H&&p.createElement("clipPath",{id:"clipPath-dots-".concat(w)},p.createElement("rect",{x:f-z/2,y:l-z/2,width:A+z,height:g+z}))):null,y?null:this.renderArea(b,w),(o||y)&&this.renderDots(b,H,w),(!x||O)&&le.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])}(ve.PureComponent);te=L;E(L,"displayName","Area");E(L,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ce.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});E(L,"getBaseValue",function(e,t,r,a){var n=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(C(s)&&typeof s=="number")return s;var u=n==="horizontal"?a:r,l=u.scale.domain();if(u.type==="number"){var f=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]});E(L,"getComposedData",function(e){var t=e.props,r=e.item,a=e.xAxis,n=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,u=e.dataKey,l=e.stackedData,f=e.dataStartIndex,c=e.displayedData,h=e.offset,A=t.layout,g=l&&l.length,x=te.getBaseValue(t,r,a,n),v=A==="horizontal",O=!1,y=c.map(function(d,m){var b;g?b=l[f+m]:(b=J(d,u),Array.isArray(b)?O=!0:b=[x,b]);var w=b[1]==null||g&&J(d,u)==null;return v?{x:Q({axis:a,ticks:i,bandSize:s,entry:d,index:m}),y:w?null:n.scale(b[1]),value:b,payload:d}:{x:w?null:a.scale(b[1]),y:Q({axis:n,ticks:o,bandSize:s,entry:d,index:m}),value:b,payload:d}}),_;return g||O?_=y.map(function(d){var m=Array.isArray(d.value)?d.value[0]:null;return v?{x:d.x,y:m!=null&&d.y!=null?n.scale(m):null}:{x:m!=null?a.scale(m):null,y:d.y}}):_=v?n.scale(x):a.scale(x),S({points:y,baseLine:_,layout:A,isRange:O},h)});E(L,"renderDotItem",function(e,t){var r;if(p.isValidElement(e))r=p.cloneElement(e,t);else if(K(e))r=e(t);else{var a=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),n=t.key,i=ae(t,be);r=p.createElement(fe,D({},i,{key:n,className:a}))}return r});var ke=pe({chartName:"AreaChart",GraphicalChild:L,axisComponents:[{axisType:"xAxis",AxisComp:he},{axisType:"yAxis",AxisComp:de}],formatAxisMap:me});export{ke as A,L as a};
2
+ //# sourceMappingURL=AreaChart-XF3jPpvn.js.map