pi-mega-compact 0.19.2 → 0.20.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 (98) hide show
  1. package/dist/config/vector-cortex.js +24 -0
  2. package/dist/config.js +1 -1
  3. package/dist/extensions/dashboard-server/routes-cache.test/_helpers.js +2 -0
  4. package/dist/extensions/dashboard-server/routes-rag-settings-helpers.js +2 -0
  5. package/dist/extensions/dashboard-server/routes-vector-cortex-helpers.js +100 -0
  6. package/dist/extensions/dashboard-server/routes-vector-cortex-query.js +46 -0
  7. package/dist/extensions/dashboard-server/routes-vector-cortex-shards.js +48 -0
  8. package/dist/extensions/dashboard-server/routes-vector-cortex.js +2 -0
  9. package/dist/extensions/dashboard-server/routes.js +1 -1
  10. package/dist/extensions/dashboard-server/server.js +41 -16
  11. package/dist/extensions/dashboard-server/tailscale.js +32 -0
  12. package/dist/src/config/vector-cortex.js +24 -0
  13. package/dist/src/config.js +1 -1
  14. package/dist/src/tieredRouter.js +8 -0
  15. package/dist/src/vector-cortex/migrations/router-generation-v2.js +252 -0
  16. package/dist/src/vector-cortex/shards/exact.js +134 -0
  17. package/dist/src/vector-cortex/shards/manifest.js +237 -0
  18. package/dist/src/vector-cortex/shards/semantic.js +137 -0
  19. package/dist/src/vector-cortex/shards/types.js +51 -0
  20. package/dist/src/vector-cortex/topology/query.js +342 -0
  21. package/dist/vector-cortex/migrations/router-generation-v2.js +252 -0
  22. package/dist/vector-cortex/shards/exact.js +134 -0
  23. package/dist/vector-cortex/shards/manifest.js +237 -0
  24. package/dist/vector-cortex/shards/semantic.js +137 -0
  25. package/dist/vector-cortex/shards/types.js +51 -0
  26. package/dist/vector-cortex/topology/query.js +342 -0
  27. package/extensions/dashboard-client/dist/assets/{AreaChart-CSaJZXru.js → AreaChart-n4z5w9Ox.js} +2 -2
  28. package/extensions/dashboard-client/dist/assets/{AreaChart-CSaJZXru.js.map → AreaChart-n4z5w9Ox.js.map} +1 -1
  29. package/extensions/dashboard-client/dist/assets/{BarChart-CQouNj1g.js → BarChart-BLGjWWBr.js} +2 -2
  30. package/extensions/dashboard-client/dist/assets/{BarChart-CQouNj1g.js.map → BarChart-BLGjWWBr.js.map} +1 -1
  31. package/extensions/dashboard-client/dist/assets/{CacheTab-m_eiCYoL.js → CacheTab-CAnrKKVK.js} +2 -2
  32. package/extensions/dashboard-client/dist/assets/{CacheTab-m_eiCYoL.js.map → CacheTab-CAnrKKVK.js.map} +1 -1
  33. package/extensions/dashboard-client/dist/assets/{EventsTab-DRyOwjYN.js → EventsTab-D-GL7Ngq.js} +2 -2
  34. package/extensions/dashboard-client/dist/assets/{EventsTab-DRyOwjYN.js.map → EventsTab-D-GL7Ngq.js.map} +1 -1
  35. package/extensions/dashboard-client/dist/assets/{HealthTab-Dj9k40TJ.js → HealthTab-C4x5qQ8s.js} +2 -2
  36. package/extensions/dashboard-client/dist/assets/{HealthTab-Dj9k40TJ.js.map → HealthTab-C4x5qQ8s.js.map} +1 -1
  37. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-Bk9mhYfD.js → MaintenanceTab-BSPs0eq5.js} +2 -2
  38. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-Bk9mhYfD.js.map → MaintenanceTab-BSPs0eq5.js.map} +1 -1
  39. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-C7ve49VG.js → MemoryMapTab-BWEUtTSu.js} +2 -2
  40. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-C7ve49VG.js.map → MemoryMapTab-BWEUtTSu.js.map} +1 -1
  41. package/extensions/dashboard-client/dist/assets/{MetricsTab-DzjhqZA9.js → MetricsTab-Dhm1c3Cx.js} +2 -2
  42. package/extensions/dashboard-client/dist/assets/{MetricsTab-DzjhqZA9.js.map → MetricsTab-Dhm1c3Cx.js.map} +1 -1
  43. package/extensions/dashboard-client/dist/assets/{OverviewTab-CFQdfIm_.js → OverviewTab-Cm6cySiQ.js} +2 -2
  44. package/extensions/dashboard-client/dist/assets/{OverviewTab-CFQdfIm_.js.map → OverviewTab-Cm6cySiQ.js.map} +1 -1
  45. package/extensions/dashboard-client/dist/assets/{ReposTab-DyjwEFUr.js → ReposTab-DxLN1N4K.js} +2 -2
  46. package/extensions/dashboard-client/dist/assets/{ReposTab-DyjwEFUr.js.map → ReposTab-DxLN1N4K.js.map} +1 -1
  47. package/extensions/dashboard-client/dist/assets/{SessionsTab-njLIy7ab.js → SessionsTab-CZuI4ISW.js} +2 -2
  48. package/extensions/dashboard-client/dist/assets/{SessionsTab-njLIy7ab.js.map → SessionsTab-CZuI4ISW.js.map} +1 -1
  49. package/extensions/dashboard-client/dist/assets/{SetupTab-UHIs8-Lh.js → SetupTab-C_0VOomm.js} +2 -2
  50. package/extensions/dashboard-client/dist/assets/{SetupTab-UHIs8-Lh.js.map → SetupTab-C_0VOomm.js.map} +1 -1
  51. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-inWHjCxg.js → TimeSavedCard-BhbaRLmi.js} +2 -2
  52. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-inWHjCxg.js.map → TimeSavedCard-BhbaRLmi.js.map} +1 -1
  53. package/extensions/dashboard-client/dist/assets/{TurnsTab-CXJYugBu.js → TurnsTab-CXJmbjje.js} +2 -2
  54. package/extensions/dashboard-client/dist/assets/{TurnsTab-CXJYugBu.js.map → TurnsTab-CXJmbjje.js.map} +1 -1
  55. package/extensions/dashboard-client/dist/assets/VectorCortexTab-BGe9hu3r.js +2 -0
  56. package/extensions/dashboard-client/dist/assets/VectorCortexTab-BGe9hu3r.js.map +1 -0
  57. package/extensions/dashboard-client/dist/assets/{WikiTab-BJ4A2oi9.js → WikiTab-C5uvMCzp.js} +2 -2
  58. package/extensions/dashboard-client/dist/assets/{WikiTab-BJ4A2oi9.js.map → WikiTab-C5uvMCzp.js.map} +1 -1
  59. package/extensions/dashboard-client/dist/assets/{button-BWl-moyn.js → button-Cl_fxJcg.js} +2 -2
  60. package/extensions/dashboard-client/dist/assets/{button-BWl-moyn.js.map → button-Cl_fxJcg.js.map} +1 -1
  61. package/extensions/dashboard-client/dist/assets/{card-C58RVPOk.js → card-BH8Le5YM.js} +2 -2
  62. package/extensions/dashboard-client/dist/assets/{card-C58RVPOk.js.map → card-BH8Le5YM.js.map} +1 -1
  63. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-vgeOQU3L.js → generateCategoricalChart-sZ6ZNtBi.js} +2 -2
  64. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-vgeOQU3L.js.map → generateCategoricalChart-sZ6ZNtBi.js.map} +1 -1
  65. package/extensions/dashboard-client/dist/assets/{index-lVrWQjpu.js → index-CX9zv8cJ.js} +3 -3
  66. package/extensions/dashboard-client/dist/assets/{index-lVrWQjpu.js.map → index-CX9zv8cJ.js.map} +1 -1
  67. package/extensions/dashboard-client/dist/assets/{switch-CSeplFQT.js → switch-CXJhcjhM.js} +2 -2
  68. package/extensions/dashboard-client/dist/assets/{switch-CSeplFQT.js.map → switch-CXJhcjhM.js.map} +1 -1
  69. package/extensions/dashboard-client/dist/assets/{toggle-CQRxgVRi.js → toggle-CoLtIc6y.js} +2 -2
  70. package/extensions/dashboard-client/dist/assets/{toggle-CQRxgVRi.js.map → toggle-CoLtIc6y.js.map} +1 -1
  71. package/extensions/dashboard-client/dist/assets/{useSSE-BUz6IOI-.js → useSSE-fSXho606.js} +2 -2
  72. package/extensions/dashboard-client/dist/assets/{useSSE-BUz6IOI-.js.map → useSSE-fSXho606.js.map} +1 -1
  73. package/extensions/dashboard-client/dist/index.html +1 -1
  74. package/extensions/dashboard-client/src/api/vector-cortex.ts +18 -0
  75. package/extensions/dashboard-client/src/tabs/VectorCortexTab.tsx +62 -0
  76. package/extensions/dashboard-client/src/types/vector-cortex.ts +25 -0
  77. package/extensions/dashboard-server/api-contracts/vector-cortex.ts +41 -0
  78. package/extensions/dashboard-server/routes-cache.test/_helpers.ts +2 -0
  79. package/extensions/dashboard-server/routes-rag-settings-helpers.ts +12 -0
  80. package/extensions/dashboard-server/routes-vector-cortex-helpers.ts +110 -0
  81. package/extensions/dashboard-server/routes-vector-cortex-query.ts +54 -0
  82. package/extensions/dashboard-server/routes-vector-cortex-shards.ts +57 -0
  83. package/extensions/dashboard-server/routes-vector-cortex.ts +2 -0
  84. package/extensions/dashboard-server/routes.ts +2 -0
  85. package/extensions/dashboard-server/server.ts +46 -17
  86. package/extensions/dashboard-server/tailscale.ts +32 -0
  87. package/package.json +1 -1
  88. package/src/config/vector-cortex.ts +26 -0
  89. package/src/config.ts +2 -0
  90. package/src/tieredRouter.ts +9 -0
  91. package/src/vector-cortex/migrations/router-generation-v2.ts +317 -0
  92. package/src/vector-cortex/shards/exact.ts +141 -0
  93. package/src/vector-cortex/shards/manifest.ts +276 -0
  94. package/src/vector-cortex/shards/semantic.ts +156 -0
  95. package/src/vector-cortex/shards/types.ts +212 -0
  96. package/src/vector-cortex/topology/query.ts +485 -0
  97. package/extensions/dashboard-client/dist/assets/VectorCortexTab-DkS0Azx9.js +0 -2
  98. package/extensions/dashboard-client/dist/assets/VectorCortexTab-DkS0Azx9.js.map +0 -1
@@ -0,0 +1,137 @@
1
+ /**
2
+ * vector-cortex/shards/semantic.ts — semantic tier partition (VC4A, mode A/B).
3
+ *
4
+ * Partitions a session's canonical EventV2 stream into `SemanticShardV1`
5
+ * chunks, cutting ONLY at complete record boundaries. Every shard's `range`
6
+ * names the exact inclusive seq span and the half-open source byte window it
7
+ * covers in canonical stream order; a shard NEVER splits a record (or a tool
8
+ * call/result pair). Semantic shards carry DERIVED aggregate content (a
9
+ * deterministic digest + token estimate + byte/event counts) and never
10
+ * reproduce exact text — exact bytes are the exact tier's job.
11
+ *
12
+ * The partition is deterministic and size-bounded: it walks the sorted events,
13
+ * accrues each record's bytes, and closes a shard the moment adding the next
14
+ * complete record would exceed `targetSize`. A single record that is already
15
+ * over the budget gets its own shard (a shard is always at least one complete
16
+ * record, so over-budget records are never split).
17
+ *
18
+ * Triad: A = this semantic tier plus exact shards; B = the same range shape
19
+ * derived from extractive heads with the semantic encoder disabled (the caller
20
+ * may substitute the derived payload, since the range+digest contract is
21
+ * identical); C = exact anchors/current transcript only (no semantic shards at
22
+ * all, handled by the exact tier alone).
23
+ *
24
+ * Pure/deterministic: hashes + array walking only, no storage, no console, no
25
+ * network (PREVENT-PI-004 / PREVENT-011).
26
+ */
27
+ import { createHash } from "node:crypto";
28
+ /**
29
+ * Compute the canonical per-record byte offsets for a session's sorted events.
30
+ * Events are sorted by seq (ascending) defensively; the byte stream is the
31
+ * concatenation of each event's `originalBytes` in that order. A shared pure
32
+ * helper so semantic + exact tiers agree on source ranges (the two partitioning
33
+ * algorithms remain otherwise independent). Returns `undefined`-guarding lookup
34
+ * plus the total length; empty input yields an empty map with total 0.
35
+ */
36
+ export function cumulativeOffsets(events) {
37
+ const map = new Map();
38
+ let off = 0;
39
+ const sorted = [...events].sort((a, b) => (a.seq < b.seq ? -1 : a.seq > b.seq ? 1 : 0));
40
+ for (const e of sorted) {
41
+ const len = e.originalBytes.length;
42
+ map.set(e.seq.toString(), { byteStart: off, byteEnd: off + len });
43
+ off += len;
44
+ }
45
+ return {
46
+ of: (seq) => map.get(seq.toString()),
47
+ total: off,
48
+ };
49
+ }
50
+ /** Approximate token count for a valid UTF-8 text (whitespace-separated runs). */
51
+ function approxTokens(text) {
52
+ if (text.length === 0)
53
+ return 0;
54
+ const runs = text.match(/\S+/g);
55
+ return runs ? runs.length : 0;
56
+ }
57
+ /** Deterministic SHARD digest over a semantic shard's derived payload. */
58
+ function sealedSemanticDigest(sessionId, events, range, tokenEstimate) {
59
+ const h = createHash("sha256");
60
+ h.update(`semantic-shard-v1|${sessionId}|`);
61
+ h.update(`${range.seqStart.toString()}|${range.seqEnd.toString()}|`);
62
+ h.update(`${range.byteStart}|${range.byteEnd}|`);
63
+ h.update(`${tokenEstimate}|`);
64
+ // One `~`-joined run of the covered records' authoritative byte digests in
65
+ // seq order, so the shard digest depends on exactly which records it covers.
66
+ for (const e of [...events].sort((a, b) => (a.seq < b.seq ? -1 : a.seq > b.seq ? 1 : 0))) {
67
+ h.update(`${e.seq.toString()}:${e.bytesDigest}~`);
68
+ }
69
+ return `sha256:${h.digest("hex")}`;
70
+ }
71
+ /**
72
+ * Partition the semantic tier (task 2). Returns `ok:true` with a list of
73
+ * `SemanticShardV1` whose (sorted) ranges are contiguous, non-overlapping and
74
+ * jointly cover every event exactly once. Failures are defensive: a non-positive
75
+ * or non-finite `targetSize` rejects with `SHD_INVALID_TARGET_SIZE`; mixed-session
76
+ * events reject with `SHD_CROSS_SESSION`.
77
+ */
78
+ export function partitionSemantic(input) {
79
+ const { sessionId, events, targetSize } = input;
80
+ if (!Number.isFinite(targetSize) || targetSize <= 0) {
81
+ return { ok: false, code: "SHD_INVALID_TARGET_SIZE" };
82
+ }
83
+ if (events.some((e) => e.sessionId !== sessionId)) {
84
+ return { ok: false, code: "SHD_CROSS_SESSION" };
85
+ }
86
+ const offsets = cumulativeOffsets(events);
87
+ const sorted = [...events].sort((a, b) => (a.seq < b.seq ? -1 : a.seq > b.seq ? 1 : 0));
88
+ if (sorted.length === 0)
89
+ return { ok: true, shards: [] };
90
+ const shards = [];
91
+ let batch = [];
92
+ let batchBytes = 0;
93
+ let batchTokens = 0;
94
+ const flush = () => {
95
+ if (batch.length === 0)
96
+ return;
97
+ const first = batch[0];
98
+ const last = batch[batch.length - 1];
99
+ const start = offsets.of(first.seq);
100
+ const end = offsets.of(last.seq);
101
+ const byteStart = start ? start.byteStart : 0;
102
+ const byteEnd = end ? end.byteEnd : byteStart;
103
+ const tokenEstimate = batchTokens;
104
+ shards.push({
105
+ schema: "semantic-shard-v1",
106
+ sessionId,
107
+ range: {
108
+ sessionId,
109
+ seqStart: first.seq,
110
+ seqEnd: last.seq,
111
+ byteStart,
112
+ byteEnd,
113
+ },
114
+ kind: "semantic",
115
+ digest: sealedSemanticDigest(sessionId, batch, { seqStart: first.seq, seqEnd: last.seq, byteStart, byteEnd }, tokenEstimate),
116
+ byteCount: batchBytes,
117
+ eventCount: batch.length,
118
+ tokenEstimate,
119
+ });
120
+ batch = [];
121
+ batchBytes = 0;
122
+ batchTokens = 0;
123
+ };
124
+ for (const e of sorted) {
125
+ const len = e.originalBytes.length;
126
+ const tokens = e.utf8.valid ? approxTokens(e.utf8.text) : Math.ceil(len / 4);
127
+ // A batch that already has a complete record and would exceed the budget
128
+ // (and the next record itself fits, or it doesn't) closes at a boundary.
129
+ if (batch.length > 0 && batchBytes + len > targetSize)
130
+ flush();
131
+ batch.push(e);
132
+ batchBytes += len;
133
+ batchTokens += tokens;
134
+ }
135
+ flush();
136
+ return { ok: true, shards };
137
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * vector-cortex/shards/types.ts — dual-tier shard contract (VC4A).
3
+ *
4
+ * Owns `SemanticShardV1` / `ExactShardV1` / `ShardManifestV1` — the shared
5
+ * partition contract of the sprint failure triad:
6
+ *
7
+ * A = semantic + exact shards (normal path);
8
+ * B = extractive + exact shards with the semantic encoder disabled;
9
+ * C = exact anchors/current transcript only.
10
+ *
11
+ * A session's canonical byte stream is partitioned ONLY at complete EventV2
12
+ * record boundaries (VC1A byte authority — an EventV2's `originalBytes` + its
13
+ * SHA-256 `bytesDigest` are authoritative, invalid UTF-8 is never normalized).
14
+ * A `ShardRange` names a contiguous run of complete records by inclusive
15
+ * seq `[seqStart..seqEnd]` and by the half-open source byte range
16
+ * `[byteStart, byteEnd)` they occupy in canonical stream order (record `seq`
17
+ * carries every byte from `offset(seq)` to `offset(seq)+len(seq)`).
18
+ *
19
+ * Semantic shards carry derived aggregate vectors/token estimates and NEVER
20
+ * reproduce exact text (the RESIDUAL_CODEC / exact-payload shards own exact
21
+ * bytes). Exact shards carry the EXACT original bytes, unchanged, for the
22
+ * protected spans: every tool call/result pair, every anchor, and every invalid
23
+ * UTF-8 event (SHD-UTF8-002 — invalid bytes are exact-only and never
24
+ * normalized/re-encoded). A tool call/result pair that straddles a target-size
25
+ * boundary stays in ONE exact shard (SHD-PAIR-001).
26
+ *
27
+ * Consumes only reviewer-accepted predecessor contracts (VC1A EventV2) and the
28
+ * [common contracts](../../../../docs/vector-cortex/CONTRACTS.md). Pure
29
+ * types/schema + small predicates: no storage, no console, no network
30
+ * (PREVENT-PI-004 / PREVENT-011). The acceptance contract and the conformance
31
+ * IDs (SHD-001..020 + named SHD-PAIR-001 / SHD-UTF8-002 / SHD-RANGE-003) live
32
+ * here.
33
+ */
34
+ /**
35
+ * Registered SHD conformance ID range (SHD-001..020). The acceptance test reads
36
+ * these rows from the v2 manifest and asserts each returns its manifest
37
+ * `ok`/`code`. The named assertions (SHD-PAIR-001 / SHD-UTF8-002 /
38
+ * SHD-RANGE-003) live in the acceptance test.
39
+ */
40
+ export const SHD_IDS = [
41
+ "SHD-001", "SHD-002", "SHD-003", "SHD-004", "SHD-005",
42
+ "SHD-006", "SHD-007", "SHD-008", "SHD-009", "SHD-010",
43
+ "SHD-011", "SHD-012", "SHD-013", "SHD-014", "SHD-015",
44
+ "SHD-016", "SHD-017", "SHD-018", "SHD-019", "SHD-020",
45
+ ];
46
+ /** Named SHD conformance assertions. */
47
+ export const SHD_NAMED_IDS = [
48
+ "SHD-PAIR-001",
49
+ "SHD-UTF8-002",
50
+ "SHD-RANGE-003",
51
+ ];
@@ -0,0 +1,342 @@
1
+ /**
2
+ * vector-cortex/topology/query.ts — topology query + router invalidation (VC3C).
3
+ *
4
+ * Owns `RouterKeyV2` (the structured router key) and `TopologyQueryV1` (the
5
+ * generation query/index surface that serves graphs and invalidates stale
6
+ * generations). This is the degradation seam of the sprint's failure triad:
7
+ *
8
+ * A = topology index at current generation (serve the active graph);
9
+ * B = fresh linear scan forced when a key targets a STALE generation;
10
+ * C = authority sequence scan forced when the derived store is unavailable.
11
+ *
12
+ * Key encoding is length-delimited with unsigned-byte (prefix) ordering and a
13
+ * FIXED five-field arity, so no field value can ambiguously prefix another and
14
+ * two sessions `a` / `aa` can never prefix-collide at the key level
15
+ * (M6-KEY-001). Invalidation matches the exact `(session,generation)` identity
16
+ * bytes — never a string-prefix — and a query whose key carries a generation
17
+ * older than the session's active one is rejected with `TOP_GENERATION_STALE`
18
+ * (M6-STALE-002), which forces mode B.
19
+ *
20
+ * Pure src/ logic over an injected `TopologyQueryHost` (the source of graphs +
21
+ * linear/authority scans) and an optional `TopologyQueryEmit`. Deterministic,
22
+ * pi-agnostic, no console, no network (PREVENT-PI-004), no `any`
23
+ * (PREVENT-011). The caller owns durability; every store write on the caller
24
+ * side is best-effort and never breaks the agent loop.
25
+ */
26
+ import { createHash } from "node:crypto";
27
+ /** Query rejected: the key's generation is stale relative to the active one. */
28
+ export const TOP_GENERATION_STALE = "TOP_GENERATION_STALE";
29
+ /** Query rejected: a key could not be decoded (malformed length-delimited bytes). */
30
+ export const TOP_KEY_DECODE_FAILED = "TOP_KEY_DECODE_FAILED";
31
+ /** Query rejected: the derived store is unavailable and no authority scan is possible. */
32
+ export const TOP_AUTHORITY_UNAVAILABLE = "TOP_AUTHORITY_UNAVAILABLE";
33
+ /** Frozen router key schema version carried in every encoded key. */
34
+ export const ROUTER_KEY_VERSION = 2;
35
+ /**
36
+ * Create the query surface. `emit` is optional and flag-gated (the caller passes
37
+ * a reporter produced by the same pattern VC3A/VC3B use — zero emissions when
38
+ * `MEGACOMPACT_VC3C=0`, byte-identical to the predecessor). Pure in-memory index
39
+ * over the injected host; durability of invalidation is the caller's job.
40
+ */
41
+ export function createTopologyQuery(host, emit) {
42
+ // session -> Set of indexed generation strings (exact, byte-identity).
43
+ const generations = new Map();
44
+ const fire = (event, fields) => {
45
+ if (!emit)
46
+ return;
47
+ try {
48
+ emit(event, fields);
49
+ }
50
+ catch {
51
+ /* non-fatal observability — never break the agent loop */
52
+ }
53
+ };
54
+ const query = (key) => {
55
+ const active = host.activeGeneration(key.session);
56
+ // Mode C: derived store unavailable -> authority sequence scan.
57
+ if (!host.derivedAvailable(key.session)) {
58
+ const cDigest = host.authorityScan(key.session, key.sourceStart, key.sourceEnd);
59
+ if (cDigest === undefined) {
60
+ return { ok: false, code: TOP_AUTHORITY_UNAVAILABLE, mode: "C" };
61
+ }
62
+ fire("vector_cortex_topology_query_demoted", {
63
+ session: key.session,
64
+ generation: key.generation.toString(),
65
+ code: "DERIVED_UNAVAILABLE",
66
+ toMode: "C",
67
+ });
68
+ return {
69
+ ok: true,
70
+ mode: "C",
71
+ session: key.session,
72
+ generation: key.generation,
73
+ algorithm: key.algorithm,
74
+ matchedKey: encodeRouterKeyV2(key),
75
+ digest: cDigest.digest,
76
+ };
77
+ }
78
+ // A key is stale when its generation is below the active one (or the active
79
+ // generation is unset and the requested generation is non-zero).
80
+ const stale = active === undefined
81
+ ? key.generation !== 0n
82
+ : key.generation < active;
83
+ if (stale) {
84
+ // Mode B: fresh linear scan forced by a stale A key.
85
+ const bDigest = host.linearScan(key.session, key.sourceStart, key.sourceEnd);
86
+ fire("vector_cortex_topology_query_demoted", {
87
+ session: key.session,
88
+ generation: key.generation.toString(),
89
+ activeGeneration: active === undefined ? null : active.toString(),
90
+ code: "STALE_GENERATION",
91
+ toMode: "B",
92
+ });
93
+ return {
94
+ ok: true,
95
+ mode: "B",
96
+ session: key.session,
97
+ generation: key.generation,
98
+ algorithm: key.algorithm,
99
+ matchedKey: encodeRouterKeyV2(key),
100
+ digest: bDigest.digest,
101
+ };
102
+ }
103
+ // Mode A: topology index at the current generation. If the derived store is
104
+ // up but has not indexed this exact (generation, algorithm) yet, that is a
105
+ // mode-A miss (no graph to serve) — force the fresh linear scan rather than
106
+ // fabricate a graph or report a false staleness (Q03: the index cannot be
107
+ // trusted to hold every current generation; B recomputes from source).
108
+ const graph = host.graphAt(key.session, key.generation, key.algorithm);
109
+ if (graph === undefined) {
110
+ const bDigest = host.linearScan(key.session, key.sourceStart, key.sourceEnd);
111
+ fire("vector_cortex_topology_query_demoted", {
112
+ session: key.session,
113
+ generation: key.generation.toString(),
114
+ code: "GENERATION_MISS",
115
+ toMode: "B",
116
+ });
117
+ return {
118
+ ok: true,
119
+ mode: "B",
120
+ session: key.session,
121
+ generation: key.generation,
122
+ algorithm: key.algorithm,
123
+ matchedKey: encodeRouterKeyV2(key),
124
+ digest: bDigest.digest,
125
+ };
126
+ }
127
+ return {
128
+ ok: true,
129
+ mode: "A",
130
+ session: key.session,
131
+ generation: key.generation,
132
+ algorithm: key.algorithm,
133
+ matchedKey: encodeRouterKeyV2(key),
134
+ digest: graph.digest,
135
+ };
136
+ };
137
+ const invalidate = (session, generation) => {
138
+ const invalidationIdentity = invalidationKey(session, generation);
139
+ const set = generations.get(session);
140
+ if (set)
141
+ set.delete(invalidationIdentity);
142
+ fire("vector_cortex_router_generation_invalidated", {
143
+ session,
144
+ generation: generation.toString(),
145
+ key: invalidationIdentity,
146
+ });
147
+ };
148
+ const generationalCount = (session) => {
149
+ return generations.get(session)?.size ?? 0;
150
+ };
151
+ return { query, invalidate, generationalCount };
152
+ }
153
+ // ---------------------------------------------------------------------------
154
+ // Length-delimited, unsigned-byte-ordered key encoding (M6-KEY-001)
155
+ // ---------------------------------------------------------------------------
156
+ /**
157
+ * Encode one field: `u32BE(byteLength) || bytes`. Non-negative numbers are
158
+ * encoded as their unsigned big-endian byte form (leading zeros trimmed). This
159
+ * is the standard big-endian length-prefixed encoding: two fields compare in
160
+ * unsigned-byte order exactly as their values do, and no value is an ambiguous
161
+ * prefix of another.
162
+ */
163
+ function encodeLengthDelimited(bytes) {
164
+ const out = new Uint8Array(4 + bytes.length);
165
+ const view = new DataView(out.buffer);
166
+ view.setUint32(0, bytes.length, false);
167
+ out.set(bytes, 4);
168
+ return out;
169
+ }
170
+ /** Big-endian unsigned bytes of a non-negative bigint (length-prefixed below). */
171
+ function bigintBytes(n) {
172
+ let v = n;
173
+ const out = [];
174
+ if (v === 0n)
175
+ return new Uint8Array([0]);
176
+ while (v > 0n) {
177
+ out.unshift(Number(v & 0xffn));
178
+ v >>= 8n;
179
+ }
180
+ return Uint8Array.from(out);
181
+ }
182
+ /** UTF-8 bytes of a string. */
183
+ function strBytes(s) {
184
+ return new TextEncoder().encode(s);
185
+ }
186
+ function concat(parts) {
187
+ let len = 0;
188
+ for (const p of parts)
189
+ len += p.length;
190
+ const out = new Uint8Array(len);
191
+ let off = 0;
192
+ for (const p of parts) {
193
+ out.set(p, off);
194
+ off += p.length;
195
+ }
196
+ return out;
197
+ }
198
+ /**
199
+ * Encode a RouterKeyV2 into its canonical, length-delimited, unsigned-byte-ordered
200
+ * byte form. Version-prefixed (1 byte) + five length-delimited fields in fixed
201
+ * order (session, sourceStart, sourceEnd, generation, algorithm). Fixed arity +
202
+ * length-delimiting means no key is a strict prefix of another and sessions `a`
203
+ * and `aa` never collide (M6-KEY-001).
204
+ */
205
+ export function encodeRouterKeyV2(key) {
206
+ const version = Uint8Array.of(ROUTER_KEY_VERSION);
207
+ const session = encodeLengthDelimited(strBytes(key.session));
208
+ const sourceStart = encodeLengthDelimited(bigintBytes(key.sourceStart));
209
+ const sourceEnd = encodeLengthDelimited(bigintBytes(key.sourceEnd));
210
+ const generation = encodeLengthDelimited(bigintBytes(key.generation));
211
+ const algorithm = encodeLengthDelimited(strBytes(key.algorithm));
212
+ return "rk2:" + Buffer.from(concat([version, session, sourceStart, sourceEnd, generation, algorithm])).toString("hex");
213
+ }
214
+ /**
215
+ * Decode a RouterKeyV2 from its canonical byte form. Returns
216
+ * TOP_KEY_DECODE_FAILED on malformed bytes (bad version, truncated length, or
217
+ * trailing garbage). Never parses by string prefix.
218
+ */
219
+ export function decodeRouterKeyV2(encoded) {
220
+ if (!encoded.startsWith("rk2:"))
221
+ return { ok: false, code: "TOP_KEY_DECODE_FAILED" };
222
+ const hex = encoded.slice(4);
223
+ if (!/^[0-9a-f]*$/.test(hex) || hex.length % 2 !== 0) {
224
+ return { ok: false, code: "TOP_KEY_DECODE_FAILED" };
225
+ }
226
+ const buf = Buffer.from(hex, "hex");
227
+ const bytes = new Uint8Array(buf);
228
+ const reader = new Reader(bytes);
229
+ const version = reader.u8();
230
+ if (version !== ROUTER_KEY_VERSION)
231
+ return { ok: false, code: "TOP_KEY_DECODE_FAILED" };
232
+ const sessionBytes = reader.lenPrefixed();
233
+ const ssBytes = reader.lenPrefixed();
234
+ const seBytes = reader.lenPrefixed();
235
+ const genBytes = reader.lenPrefixed();
236
+ const algoBytes = reader.lenPrefixed();
237
+ if (reader.remaining() !== 0)
238
+ return { ok: false, code: "TOP_KEY_DECODE_FAILED" };
239
+ if (sessionBytes === null || ssBytes === null || seBytes === null || genBytes === null || algoBytes === null) {
240
+ return { ok: false, code: "TOP_KEY_DECODE_FAILED" };
241
+ }
242
+ const session = new TextDecoder().decode(sessionBytes);
243
+ const sourceStart = bytesToBigint(ssBytes);
244
+ const sourceEnd = bytesToBigint(seBytes);
245
+ const generation = bytesToBigint(genBytes);
246
+ const algorithm = new TextDecoder().decode(algoBytes);
247
+ return { ok: true, key: { session, sourceStart, sourceEnd, generation, algorithm } };
248
+ }
249
+ /** Sequential length-delimited byte reader. */
250
+ class Reader {
251
+ bytes;
252
+ off = 0;
253
+ constructor(bytes) {
254
+ this.bytes = bytes;
255
+ }
256
+ u8() {
257
+ const v = this.bytes[this.off];
258
+ this.off += 1;
259
+ return v;
260
+ }
261
+ lenPrefixed() {
262
+ if (this.off + 4 > this.bytes.length)
263
+ return null;
264
+ const view = new DataView(this.bytes.buffer, this.bytes.byteOffset + this.off, 4);
265
+ const len = view.getUint32(0, false);
266
+ this.off += 4;
267
+ if (this.off + len > this.bytes.length)
268
+ return null;
269
+ const out = this.bytes.slice(this.off, this.off + len);
270
+ this.off += len;
271
+ return out;
272
+ }
273
+ remaining() {
274
+ return this.bytes.length - this.off;
275
+ }
276
+ }
277
+ /** Non-negative bigint from its unsigned big-endian bytes. */
278
+ function bytesToBigint(bytes) {
279
+ let n = 0n;
280
+ for (const b of bytes)
281
+ n = (n << 8n) | BigInt(b);
282
+ return n;
283
+ }
284
+ /**
285
+ * Canonical invalidation identity for an exact (session,generation) pair, using
286
+ * the SAME length-delimited scheme so two pairs can only match by exact byte
287
+ * equality (never by string prefix — `a` never matches `aa`). Returned as hex
288
+ * for use as a registry key.
289
+ */
290
+ export function invalidationKey(session, generation) {
291
+ const sessionF = encodeLengthDelimited(strBytes(session));
292
+ const genF = encodeLengthDelimited(bigintBytes(generation));
293
+ return "inv:" + Buffer.from(concat([sessionF, genF])).toString("hex");
294
+ }
295
+ /** One deterministic SHA-256 (hex) digest over the canonical key bytes. */
296
+ export function keyDigest(key) {
297
+ return `sha256:${createHash("sha256").update(Buffer.from(encodeRouterKeyV2(key).slice(4), "hex")).digest("hex")}`;
298
+ }
299
+ /**
300
+ * Shared invalidation-capability seam (narrow delegate, no routing rewrite).
301
+ * Records the EXACT (session,generation) identity and, when `enabled`, best-effort
302
+ * emits `vector_cortex_router_generation_invalidated`. Falsy `enabled` (flag OFF)
303
+ * is a strict no-op so the predecessor keying is byte-identical to pre-sprint.
304
+ * Exactness is enforced by `invalidationKey` (length-delimited, never a string
305
+ * prefix — `a` never matches `aa`), the same identity M6 validates.
306
+ */
307
+ export function routerGenerationInvalidationSeam(key, enabled, emit) {
308
+ if (!enabled)
309
+ return;
310
+ const identity = invalidationKey(key.session, key.generation);
311
+ if (emit) {
312
+ try {
313
+ emit("vector_cortex_router_generation_invalidated", {
314
+ session: key.session,
315
+ generation: key.generation.toString(),
316
+ key: identity,
317
+ });
318
+ }
319
+ catch {
320
+ /* non-fatal observability — never break the agent loop */
321
+ }
322
+ }
323
+ }
324
+ /** Registered TOP query conformance ID range (TOP-021..030). */
325
+ export const TOP_QUERY_IDS = [
326
+ "TOP-021",
327
+ "TOP-022",
328
+ "TOP-023",
329
+ "TOP-024",
330
+ "TOP-025",
331
+ "TOP-026",
332
+ "TOP-027",
333
+ "TOP-028",
334
+ "TOP-029",
335
+ "TOP-030",
336
+ ];
337
+ /** Registered named TOP-query conformance IDs. */
338
+ export const TOP_QUERY_NAMED_IDS = [
339
+ "TOP-QUERY-003",
340
+ "M6-KEY-001",
341
+ "M6-STALE-002",
342
+ ];
@@ -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-vgeOQU3L.js";import{R as p,F as ee,r as ve}from"./index-lVrWQjpu.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-CSaJZXru.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-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