pi-mega-compact 0.20.82 → 0.20.83

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 (103) hide show
  1. package/dist/extensions/dashboard-server/routes-rag-settings-helpers.js +0 -1
  2. package/dist/extensions/mega-config.js +0 -2
  3. package/dist/extensions/mega-events/agent-handlers/turnEndHandler/recordTurnRow.js +0 -17
  4. package/dist/extensions/mega-events/register.js +0 -3
  5. package/extensions/dashboard-client/dist/assets/{AdminTab-BTCZLMCc.js → AdminTab-BsA8-_bX.js} +2 -2
  6. package/extensions/dashboard-client/dist/assets/{AdminTab-BTCZLMCc.js.map → AdminTab-BsA8-_bX.js.map} +1 -1
  7. package/extensions/dashboard-client/dist/assets/{AreaChart-BTMI0QnR.js → AreaChart-BRHEfWhc.js} +2 -2
  8. package/extensions/dashboard-client/dist/assets/{AreaChart-BTMI0QnR.js.map → AreaChart-BRHEfWhc.js.map} +1 -1
  9. package/extensions/dashboard-client/dist/assets/{BarChart-C1F8wLM3.js → BarChart-C-M0LaFc.js} +2 -2
  10. package/extensions/dashboard-client/dist/assets/{BarChart-C1F8wLM3.js.map → BarChart-C-M0LaFc.js.map} +1 -1
  11. package/extensions/dashboard-client/dist/assets/{CacheTab-ORjrhSbZ.js → CacheTab-Cj3n59U3.js} +2 -2
  12. package/extensions/dashboard-client/dist/assets/{CacheTab-ORjrhSbZ.js.map → CacheTab-Cj3n59U3.js.map} +1 -1
  13. package/extensions/dashboard-client/dist/assets/{ConfigTab-CtXVSxD_.js → ConfigTab-C016XTNC.js} +2 -2
  14. package/extensions/dashboard-client/dist/assets/{ConfigTab-CtXVSxD_.js.map → ConfigTab-C016XTNC.js.map} +1 -1
  15. package/extensions/dashboard-client/dist/assets/{EventsTab-DQdwa9IB.js → EventsTab-DE29fuqe.js} +2 -2
  16. package/extensions/dashboard-client/dist/assets/{EventsTab-DQdwa9IB.js.map → EventsTab-DE29fuqe.js.map} +1 -1
  17. package/extensions/dashboard-client/dist/assets/{HealthTab-BpVO7BeO.js → HealthTab-D4eVI8ar.js} +2 -2
  18. package/extensions/dashboard-client/dist/assets/{HealthTab-BpVO7BeO.js.map → HealthTab-D4eVI8ar.js.map} +1 -1
  19. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-Cl9mWaR8.js → MaintenanceTab-4fJ7M4S4.js} +2 -2
  20. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-Cl9mWaR8.js.map → MaintenanceTab-4fJ7M4S4.js.map} +1 -1
  21. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-D3kIPeCy.js → MemoryMapTab-CDbcK9e4.js} +2 -2
  22. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-D3kIPeCy.js.map → MemoryMapTab-CDbcK9e4.js.map} +1 -1
  23. package/extensions/dashboard-client/dist/assets/{MetricsCards-Cu1zDkfm.js → MetricsCards-VUEcgGzo.js} +2 -2
  24. package/extensions/dashboard-client/dist/assets/{MetricsCards-Cu1zDkfm.js.map → MetricsCards-VUEcgGzo.js.map} +1 -1
  25. package/extensions/dashboard-client/dist/assets/MetricsTab-CKqJ0Zl-.js +2 -0
  26. package/extensions/dashboard-client/dist/assets/{MetricsTab-BAvMzWuF.js.map → MetricsTab-CKqJ0Zl-.js.map} +1 -1
  27. package/extensions/dashboard-client/dist/assets/OverviewTab-9Kxo79mi.js +16 -0
  28. package/extensions/dashboard-client/dist/assets/OverviewTab-9Kxo79mi.js.map +1 -0
  29. package/extensions/dashboard-client/dist/assets/{ReposTab-BUESjauJ.js → ReposTab-C4iveqrP.js} +2 -2
  30. package/extensions/dashboard-client/dist/assets/{ReposTab-BUESjauJ.js.map → ReposTab-C4iveqrP.js.map} +1 -1
  31. package/extensions/dashboard-client/dist/assets/{SessionsTab-DyJmQ_78.js → SessionsTab-DSEwkMQm.js} +2 -2
  32. package/extensions/dashboard-client/dist/assets/{SessionsTab-DyJmQ_78.js.map → SessionsTab-DSEwkMQm.js.map} +1 -1
  33. package/extensions/dashboard-client/dist/assets/{SetupTab-q8wYL5A-.js → SetupTab-CCyWgy4O.js} +2 -2
  34. package/extensions/dashboard-client/dist/assets/{SetupTab-q8wYL5A-.js.map → SetupTab-CCyWgy4O.js.map} +1 -1
  35. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-DIRH1Pq7.js → TimeSavedCard-CyD8e_e_.js} +2 -2
  36. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-DIRH1Pq7.js.map → TimeSavedCard-CyD8e_e_.js.map} +1 -1
  37. package/extensions/dashboard-client/dist/assets/{TurnMemoryView-CrYSOcZX.js → TurnMemoryView-5tLbWkRv.js} +2 -2
  38. package/extensions/dashboard-client/dist/assets/{TurnMemoryView-CrYSOcZX.js.map → TurnMemoryView-5tLbWkRv.js.map} +1 -1
  39. package/extensions/dashboard-client/dist/assets/TurnsTab-C7pm92Hg.js +2 -0
  40. package/extensions/dashboard-client/dist/assets/{TurnsTab-C0jARSvU.js.map → TurnsTab-C7pm92Hg.js.map} +1 -1
  41. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-D83Fz939.js → VcStatusBadge-ObhcIyfN.js} +2 -2
  42. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-D83Fz939.js.map → VcStatusBadge-ObhcIyfN.js.map} +1 -1
  43. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-BFXh5Nu7.js → VectorCortexTab-BtHZb7o7.js} +2 -2
  44. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-BFXh5Nu7.js.map → VectorCortexTab-BtHZb7o7.js.map} +1 -1
  45. package/extensions/dashboard-client/dist/assets/{WikiTab-CEdJXkou.js → WikiTab-lQ4l3QIK.js} +2 -2
  46. package/extensions/dashboard-client/dist/assets/{WikiTab-CEdJXkou.js.map → WikiTab-lQ4l3QIK.js.map} +1 -1
  47. package/extensions/dashboard-client/dist/assets/{button-BlRKWQsj.js → button-DhQQAJGm.js} +2 -2
  48. package/extensions/dashboard-client/dist/assets/{button-BlRKWQsj.js.map → button-DhQQAJGm.js.map} +1 -1
  49. package/extensions/dashboard-client/dist/assets/{card-Cx6WA_2T.js → card-Cfhz9X31.js} +2 -2
  50. package/extensions/dashboard-client/dist/assets/{card-Cx6WA_2T.js.map → card-Cfhz9X31.js.map} +1 -1
  51. package/extensions/dashboard-client/dist/assets/{client-extra-BRFScIiK.js → client-extra-CKNOGEz_.js} +2 -2
  52. package/extensions/dashboard-client/dist/assets/{client-extra-BRFScIiK.js.map → client-extra-CKNOGEz_.js.map} +1 -1
  53. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DrkPNaOf.js → generateCategoricalChart-JKjK9_cB.js} +2 -2
  54. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-DrkPNaOf.js.map → generateCategoricalChart-JKjK9_cB.js.map} +1 -1
  55. package/extensions/dashboard-client/dist/assets/{index-DUnKr3wN.js → index-iuxgtzEW.js} +6 -6
  56. package/extensions/dashboard-client/dist/assets/index-iuxgtzEW.js.map +1 -0
  57. package/extensions/dashboard-client/dist/assets/{switch-Wr0u4HKw.js → switch-7EHEQMSP.js} +2 -2
  58. package/extensions/dashboard-client/dist/assets/{switch-Wr0u4HKw.js.map → switch-7EHEQMSP.js.map} +1 -1
  59. package/extensions/dashboard-client/dist/assets/{toggle-C_eSNeMT.js → toggle-z1lWY4UM.js} +2 -2
  60. package/extensions/dashboard-client/dist/assets/{toggle-C_eSNeMT.js.map → toggle-z1lWY4UM.js.map} +1 -1
  61. package/extensions/dashboard-client/dist/assets/{useSSE-C_oFqrwF.js → useSSE-sctOZuRM.js} +2 -2
  62. package/extensions/dashboard-client/dist/assets/{useSSE-C_oFqrwF.js.map → useSSE-sctOZuRM.js.map} +1 -1
  63. package/extensions/dashboard-client/dist/index.html +1 -1
  64. package/extensions/dashboard-client/src/App.tsx +1 -11
  65. package/extensions/dashboard-client/src/components/RepoContextStack.tsx +21 -28
  66. package/extensions/dashboard-client/src/tabs/dashHashRouter.ts +1 -31
  67. package/extensions/dashboard-server/routes-rag-settings-helpers.ts +0 -6
  68. package/extensions/mega-config-types.ts +0 -3
  69. package/extensions/mega-config.ts +0 -2
  70. package/extensions/mega-events/agent-handlers/turnEndHandler/recordTurnRow.ts +0 -17
  71. package/extensions/mega-events/register.ts +0 -3
  72. package/package.json +1 -1
  73. package/dist/extensions/mega-events/analytics-handler.js +0 -169
  74. package/dist/src/store/analytics/connection.js +0 -114
  75. package/dist/src/store/analytics/contract-compliance.test/_helpers.js +0 -39
  76. package/dist/src/store/analytics/index.js +0 -25
  77. package/dist/src/store/analytics/memory-store.js +0 -111
  78. package/dist/src/store/analytics/schema.js +0 -108
  79. package/dist/src/store/analytics/sqlite-store/admin.js +0 -84
  80. package/dist/src/store/analytics/sqlite-store/ctx.js +0 -1
  81. package/dist/src/store/analytics/sqlite-store/read.js +0 -25
  82. package/dist/src/store/analytics/sqlite-store/rows.js +0 -44
  83. package/dist/src/store/analytics/sqlite-store/write.js +0 -90
  84. package/dist/src/store/analytics/sqlite-store.js +0 -79
  85. package/dist/src/store/analytics/types.js +0 -17
  86. package/extensions/dashboard-client/dist/assets/MetricsTab-BAvMzWuF.js +0 -2
  87. package/extensions/dashboard-client/dist/assets/OverviewTab-CouEq0qi.js +0 -16
  88. package/extensions/dashboard-client/dist/assets/OverviewTab-CouEq0qi.js.map +0 -1
  89. package/extensions/dashboard-client/dist/assets/TurnsTab-C0jARSvU.js +0 -2
  90. package/extensions/dashboard-client/dist/assets/index-DUnKr3wN.js.map +0 -1
  91. package/extensions/mega-events/analytics-handler.ts +0 -236
  92. package/src/store/analytics/connection.ts +0 -128
  93. package/src/store/analytics/contract-compliance.test/_helpers.ts +0 -47
  94. package/src/store/analytics/index.ts +0 -61
  95. package/src/store/analytics/memory-store.ts +0 -161
  96. package/src/store/analytics/schema.ts +0 -132
  97. package/src/store/analytics/sqlite-store/admin.ts +0 -96
  98. package/src/store/analytics/sqlite-store/ctx.ts +0 -9
  99. package/src/store/analytics/sqlite-store/read.ts +0 -46
  100. package/src/store/analytics/sqlite-store/rows.ts +0 -58
  101. package/src/store/analytics/sqlite-store/write.ts +0 -111
  102. package/src/store/analytics/sqlite-store.ts +0 -119
  103. package/src/store/analytics/types.ts +0 -202
@@ -1,84 +0,0 @@
1
- /**
2
- * admin.ts — AnalyticsAdmin delegate bodies for the SQLite backend.
3
- * Destructive/maintenance operations: prune, vacuum, integrityCheck, backup, clear, close.
4
- */
5
- import { copyFileSync, existsSync } from "node:fs";
6
- import { withTx } from "../connection.js";
7
- import { analyticsDbPath } from "../connection.js";
8
- export function prune(ctx, policy) {
9
- const now = Date.now();
10
- const eventCutoff = now - policy.maxEventAgeMs;
11
- const measCutoff = now - policy.maxMeasurementAgeMs;
12
- const delEvents = ctx.db
13
- .prepare("DELETE FROM request_events WHERE observed_at < ?")
14
- .run(eventCutoff);
15
- const delMeas = ctx.db
16
- .prepare("DELETE FROM measurement_samples WHERE observed_at < ?")
17
- .run(measCutoff);
18
- // Identity observations are not age-pruned (they're low-volume snapshots).
19
- if (policy.vacuumAfterPrune) {
20
- try {
21
- ctx.db.exec("VACUUM");
22
- }
23
- catch {
24
- /* non-fatal */
25
- }
26
- }
27
- return {
28
- eventsRemoved: delEvents.changes ?? 0,
29
- measurementsRemoved: delMeas.changes ?? 0,
30
- identitiesRemoved: 0,
31
- freedBytes: 0,
32
- };
33
- }
34
- export function vacuum(ctx) {
35
- try {
36
- ctx.db.exec("VACUUM");
37
- return { ok: true, detail: "VACUUM completed" };
38
- }
39
- catch (e) {
40
- return { ok: false, detail: String(e) };
41
- }
42
- }
43
- export function integrityCheck(ctx) {
44
- try {
45
- const row = ctx.db.prepare("PRAGMA integrity_check").get();
46
- const result = row?.integrity_check ?? "ok";
47
- return { ok: result === "ok", detail: result };
48
- }
49
- catch (e) {
50
- return { ok: false, detail: String(e) };
51
- }
52
- }
53
- export function backup(ctx) {
54
- if (ctx.opts.inMemory) {
55
- return { ok: false, detail: "Cannot backup an in-memory database" };
56
- }
57
- try {
58
- // WAL-safe checkpoint before copy.
59
- ctx.db.exec("PRAGMA wal_checkpoint(TRUNCATE)");
60
- const src = analyticsDbPath(ctx.stateDir);
61
- if (!existsSync(src))
62
- return { ok: false, detail: "analytics.db not found" };
63
- const dest = `${src}.bak-${Date.now()}`;
64
- copyFileSync(src, dest);
65
- return { ok: true, path: dest, detail: `Backup written to ${dest}` };
66
- }
67
- catch (e) {
68
- return { ok: false, detail: String(e) };
69
- }
70
- }
71
- export function clear(ctx) {
72
- withTx(ctx.db, () => {
73
- ctx.db.exec("DELETE FROM request_events");
74
- ctx.db.exec("DELETE FROM measurement_samples");
75
- ctx.db.exec("DELETE FROM identity_observations");
76
- // Reset AUTOINCREMENT sequences for measurement_samples + identity_observations.
77
- try {
78
- ctx.db.exec("DELETE FROM sqlite_sequence WHERE name IN ('measurement_samples', 'identity_observations')");
79
- }
80
- catch {
81
- /* non-fatal: sqlite_sequence may not exist yet */
82
- }
83
- });
84
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,25 +0,0 @@
1
- import { getAnalyticsSchemaVersion } from "../schema.js";
2
- export function status(ctx) {
3
- const eventCount = ctx.db.prepare("SELECT COUNT(*) AS c FROM request_events").get().c;
4
- const measurementCount = ctx.db.prepare("SELECT COUNT(*) AS c FROM measurement_samples").get().c;
5
- const identityCount = ctx.db.prepare("SELECT COUNT(*) AS c FROM identity_observations").get().c;
6
- // Freshness: the most recent observed_at across all three fact tables.
7
- const lastEvent = ctx.db
8
- .prepare("SELECT MAX(observed_at) AS mx FROM request_events")
9
- .get().mx;
10
- const lastMeas = ctx.db
11
- .prepare("SELECT MAX(observed_at) AS mx FROM measurement_samples")
12
- .get().mx;
13
- const lastId = ctx.db
14
- .prepare("SELECT MAX(observed_at) AS mx FROM identity_observations")
15
- .get().mx;
16
- const freshThrough = Math.max(lastEvent ?? 0, lastMeas ?? 0, lastId ?? 0) || null;
17
- return {
18
- enabled: true,
19
- schemaVersion: getAnalyticsSchemaVersion(),
20
- requestEventCount: eventCount,
21
- measurementCount,
22
- identityCount,
23
- freshThrough,
24
- };
25
- }
@@ -1,44 +0,0 @@
1
- export function rowToRequestEvent(r) {
2
- return {
3
- id: r.id,
4
- correlationId: r.correlation_id ?? undefined,
5
- sessionId: r.session_id ?? undefined,
6
- repoId: r.repo_id ?? undefined,
7
- turnId: r.turn_id ?? undefined,
8
- eventKind: r.event_kind,
9
- observedAt: r.observed_at,
10
- provider: r.provider ?? undefined,
11
- model: r.model ?? undefined,
12
- status: r.status ?? undefined,
13
- inputTokens: r.input_tokens ?? undefined,
14
- outputTokens: r.output_tokens ?? undefined,
15
- cacheReadTokens: r.cache_read_tokens ?? undefined,
16
- cacheWriteTokens: r.cache_write_tokens ?? undefined,
17
- durationMs: r.duration_ms ?? undefined,
18
- ttftMs: r.ttft_ms ?? undefined,
19
- source: r.source,
20
- quality: JSON.parse(r.quality_json ?? "{}"),
21
- };
22
- }
23
- export function rowToMeasurement(r) {
24
- return {
25
- observedAt: r.observed_at,
26
- sampleKind: r.sample_kind,
27
- provider: r.provider ?? undefined,
28
- model: r.model ?? undefined,
29
- value: r.value,
30
- unit: r.unit,
31
- correlationId: r.correlation_id ?? undefined,
32
- source: r.source,
33
- quality: JSON.parse(r.quality_json ?? "{}"),
34
- };
35
- }
36
- export function rowToIdentity(r) {
37
- return {
38
- observedAt: r.observed_at,
39
- provider: r.provider ?? undefined,
40
- model: r.model ?? undefined,
41
- source: r.source,
42
- metadata: JSON.parse(r.metadata_json ?? "{}"),
43
- };
44
- }
@@ -1,90 +0,0 @@
1
- export function appendRequestEvent(ctx, fact) {
2
- try {
3
- const res = ctx.db
4
- .prepare(`INSERT OR IGNORE INTO request_events (
5
- id, correlation_id, session_id, repo_id, turn_id, event_kind,
6
- observed_at, provider, model, status,
7
- input_tokens, output_tokens, cache_read_tokens, cache_write_tokens,
8
- duration_ms, ttft_ms, source, quality_json
9
- ) VALUES (
10
- @id, @correlation_id, @session_id, @repo_id, @turn_id, @event_kind,
11
- @observed_at, @provider, @model, @status,
12
- @input_tokens, @output_tokens, @cache_read_tokens, @cache_write_tokens,
13
- @duration_ms, @ttft_ms, @source, @quality_json
14
- )`)
15
- .run({
16
- "@id": fact.id,
17
- "@correlation_id": fact.correlationId ?? null,
18
- "@session_id": fact.sessionId ?? null,
19
- "@repo_id": fact.repoId ?? null,
20
- "@turn_id": fact.turnId ?? null,
21
- "@event_kind": fact.eventKind,
22
- "@observed_at": fact.observedAt,
23
- "@provider": fact.provider ?? null,
24
- "@model": fact.model ?? null,
25
- "@status": fact.status ?? null,
26
- "@input_tokens": fact.inputTokens ?? null,
27
- "@output_tokens": fact.outputTokens ?? null,
28
- "@cache_read_tokens": fact.cacheReadTokens ?? null,
29
- "@cache_write_tokens": fact.cacheWriteTokens ?? null,
30
- "@duration_ms": fact.durationMs ?? null,
31
- "@ttft_ms": fact.ttftMs ?? null,
32
- "@source": fact.source,
33
- "@quality_json": JSON.stringify(fact.quality ?? {}),
34
- });
35
- return (res.changes ?? 0) > 0
36
- ? { status: "accepted", id: fact.id }
37
- : { status: "duplicate", id: fact.id };
38
- }
39
- catch (e) {
40
- return { status: "failed", error: String(e) };
41
- }
42
- }
43
- export function appendMeasurement(ctx, fact) {
44
- try {
45
- const res = ctx.db
46
- .prepare(`INSERT INTO measurement_samples (
47
- observed_at, sample_kind, provider, model, value, unit,
48
- correlation_id, source, quality_json
49
- ) VALUES (
50
- @observed_at, @sample_kind, @provider, @model, @value, @unit,
51
- @correlation_id, @source, @quality_json
52
- )`)
53
- .run({
54
- "@observed_at": fact.observedAt,
55
- "@sample_kind": fact.sampleKind,
56
- "@provider": fact.provider ?? null,
57
- "@model": fact.model ?? null,
58
- "@value": fact.value,
59
- "@unit": fact.unit,
60
- "@correlation_id": fact.correlationId ?? null,
61
- "@source": fact.source,
62
- "@quality_json": JSON.stringify(fact.quality ?? {}),
63
- });
64
- return { status: "accepted", id: Number(res.lastInsertRowid ?? 0) };
65
- }
66
- catch (e) {
67
- return { status: "failed", error: String(e) };
68
- }
69
- }
70
- export function appendIdentity(ctx, obs) {
71
- try {
72
- const res = ctx.db
73
- .prepare(`INSERT INTO identity_observations (
74
- observed_at, provider, model, source, metadata_json
75
- ) VALUES (
76
- @observed_at, @provider, @model, @source, @metadata_json
77
- )`)
78
- .run({
79
- "@observed_at": obs.observedAt,
80
- "@provider": obs.provider ?? null,
81
- "@model": obs.model ?? null,
82
- "@source": obs.source,
83
- "@metadata_json": JSON.stringify(obs.metadata ?? {}),
84
- });
85
- return { status: "accepted", id: Number(res.lastInsertRowid ?? 0) };
86
- }
87
- catch (e) {
88
- return { status: "failed", error: String(e) };
89
- }
90
- }
@@ -1,79 +0,0 @@
1
- import { openAnalyticsDb, closeAnalyticsDb } from "./connection.js";
2
- import * as read from "./sqlite-store/read.js";
3
- import * as write from "./sqlite-store/write.js";
4
- import * as admin from "./sqlite-store/admin.js";
5
- export class SqliteAnalyticsStore {
6
- db;
7
- stateDir;
8
- opts;
9
- constructor(options) {
10
- this.opts = options;
11
- this.stateDir = options.stateDir;
12
- this.db = openAnalyticsDb(options.stateDir, {
13
- dbPath: options.dbPath,
14
- inMemory: options.inMemory,
15
- });
16
- }
17
- ctx() {
18
- return { db: this.db, stateDir: this.stateDir, opts: this.opts };
19
- }
20
- // ── AnalyticsReader ───────────────────────────────────────────────
21
- status() {
22
- return read.status(this.ctx());
23
- }
24
- // ── AnalyticsWriter ───────────────────────────────────────────────
25
- appendRequestEvent(fact) {
26
- return write.appendRequestEvent(this.ctx(), fact);
27
- }
28
- appendMeasurement(sample) {
29
- return write.appendMeasurement(this.ctx(), sample);
30
- }
31
- appendIdentity(observation) {
32
- return write.appendIdentity(this.ctx(), observation);
33
- }
34
- // ── AnalyticsAdmin ────────────────────────────────────────────────
35
- prune(policy) {
36
- return admin.prune(this.ctx(), policy);
37
- }
38
- vacuum() {
39
- return admin.vacuum(this.ctx());
40
- }
41
- integrityCheck() {
42
- return admin.integrityCheck(this.ctx());
43
- }
44
- backup() {
45
- return admin.backup(this.ctx());
46
- }
47
- clear() {
48
- admin.clear(this.ctx());
49
- }
50
- close() {
51
- closeAnalyticsDb(this.stateDir, {
52
- dbPath: this.opts.dbPath,
53
- inMemory: this.opts.inMemory,
54
- });
55
- }
56
- // ── Capability views ──────────────────────────────────────────────
57
- asReader() {
58
- return {
59
- status: () => this.status(),
60
- };
61
- }
62
- asWriter() {
63
- return {
64
- appendRequestEvent: (f) => this.appendRequestEvent(f),
65
- appendMeasurement: (s) => this.appendMeasurement(s),
66
- appendIdentity: (o) => this.appendIdentity(o),
67
- };
68
- }
69
- asAdmin() {
70
- return {
71
- prune: (p) => this.prune(p),
72
- vacuum: () => this.vacuum(),
73
- integrityCheck: () => this.integrityCheck(),
74
- backup: () => this.backup(),
75
- clear: () => this.clear(),
76
- close: () => this.close(),
77
- };
78
- }
79
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * types.ts — PMA-1 contract module for the Provider/Model Analytics store.
3
- *
4
- * The source of truth. Every implementation (SQLite, in-memory) must satisfy
5
- * these interfaces. SQL schemas are private to implementations.
6
- *
7
- * Design principles (from docs/specs/provider-model-analytics-program.md):
8
- * 1. Contract-first — the interface IS the spec.
9
- * 2. Append-only — AnalyticsWriter.append* are the only write methods; no UPDATE.
10
- * 3. Capability-gated — asReader/asWriter/asAdmin return subset views.
11
- * 4. Host push/store pull — the host supplies facts; the store never initiates.
12
- * 5. Best effort — AppendResult identifies accepted/duplicate/failed without
13
- * throwing into the host; analytics never interrupts the agent loop.
14
- *
15
- * PREVENT-PI-004: zero network. PREVENT-002: no SQL here (private to impls).
16
- */
17
- export {};
@@ -1,2 +0,0 @@
1
- import{j as r}from"./index-DUnKr3wN.js";import{M as t}from"./MetricsCards-Cu1zDkfm.js";import"./card-Cx6WA_2T.js";import"./generateCategoricalChart-DrkPNaOf.js";import"./BarChart-C1F8wLM3.js";import"./AreaChart-BTMI0QnR.js";function e(){return r.jsx(t,{})}export{e as default};
2
- //# sourceMappingURL=MetricsTab-BAvMzWuF.js.map
@@ -1,16 +0,0 @@
1
- import{c as dn,r as l,j as s,u as un,f as Yn,R as K,a as _e,b as Vn,d as qn,B as Jn,N as Qn}from"./index-DUnKr3wN.js";import{u as Zn}from"./useSSE-C_oFqrwF.js";import{C as ye,a as Ae,b as Le,c as we}from"./card-Cx6WA_2T.js";import{f as Re,a as Ut}from"./format-COjDIVGj.js";import{T as er,C as tr}from"./TimeSavedCard-DIRH1Pq7.js";import{R as fn,C as hn,X as gn,Y as pn,T as mn,L as nr,B as rr}from"./generateCategoricalChart-DrkPNaOf.js";import{L as sr,B as or}from"./BarChart-C1F8wLM3.js";/**
2
- * @license lucide-react v0.400.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const ir=dn("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
7
- * @license lucide-react v0.400.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const ar=dn("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),vt=["#58a6ff","#3fb950","#d29922","#f85149","#bc8cff","#ff7b72","#79c0ff","#56d4dd","#e3b341","#a5d6ff","#7ee787","#ffa657"];function lr(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)>>>0;return t}function cr(e){return e?vt[lr(e)%vt.length]:vt[0]}function dr(e){if(!e)return"(unknown)";const t=e.replace(/[\\/]+$/,"");if(!t)return"(unknown)";const n=t.split(/[\\/]/);return n[n.length-1]||t}function ur(e){const t=new Map;for(const i of e){const a=i.repoRoot??"__null__",c=i.tokens??0,d=t.get(a);if(d)d.tokens+=c;else{const u=dr(i.repoRoot);t.set(a,{repoRoot:i.repoRoot,basename:u,tokens:c,color:cr(u)})}}const n=[...t.values()].sort((i,a)=>i.basename.localeCompare(a.basename)),r=n.reduce((i,a)=>i+a.tokens,0),o=e.reduce((i,a)=>Math.max(i,a.ctxWindow),0);return{repos:n,totalTokens:r,maxWindow:o,sessionCount:e.length}}function xt(e){return e>=1e5?`${(e/1e3).toFixed(0)}k`:e.toLocaleString()}function Gt({children:e}){return s.jsxs(ye,{className:"electric-hover",children:[s.jsx(Ae,{children:s.jsx(Le,{children:"Context per Repo (live)"})}),s.jsx(we,{children:e})]})}function fr({sessions:e,loading:t,error:n}){const r=l.useRef(null),o=e?.sessions??[],{repos:i,totalTokens:a,maxWindow:c,sessionCount:d}=ur(o);i.length>0&&(r.current={repos:i,totalTokens:a,maxWindow:c,sessionCount:d});const u=i.length>0?{repos:i,totalTokens:a,maxWindow:c,sessionCount:d}:r.current;if(!u){const p=n?`Error loading sessions: ${n.message}`:t&&!e?"Loading sessions…":"No active sessions.";return s.jsx(Gt,{children:s.jsx("span",{className:"text-sm text-muted-foreground",children:p})})}const f=n?s.jsxs("span",{className:"text-xs",style:{color:"#f85149"},children:["· reconnecting (",n.message,")"]}):i.length===0?s.jsx("span",{className:"text-xs text-muted-foreground",children:"· holding last data"}):null,h=u.maxWindow>0?Math.round(u.totalTokens/u.maxWindow*100):0;return s.jsxs(Gt,{children:[s.jsx("div",{className:"repo-stack-bar",role:"group","aria-label":"Per-repo context usage",children:u.repos.map(p=>{const g=u.totalTokens>0?p.tokens/u.totalTokens*100:0,m=u.totalTokens>0?g:0,v=`${p.basename}: ${xt(p.tokens)} tokens (${g.toFixed(1)}% of total)`;return s.jsx("div",{className:"repo-stack-segment",style:{width:`${Math.max(m,.5)}%`,backgroundColor:p.color},title:v,"aria-label":v},p.repoRoot??"__null__")})}),s.jsxs("p",{className:"repo-stack-total",children:[xt(u.totalTokens)," tokens across ",u.repos.length," ",u.repos.length===1?"repo":"repos"," /"," ",u.sessionCount," ",u.sessionCount===1?"session":"sessions"," ",s.jsxs("span",{className:"pct",children:["— ",h,"% of combined max window"]}),f]}),s.jsx("div",{className:"repo-stack-legend",children:u.repos.map(p=>{const g=u.totalTokens>0?p.tokens/u.totalTokens*100:0;return s.jsxs("div",{className:"repo-stack-legend-item",children:[s.jsx("span",{className:"repo-stack-legend-swatch",style:{backgroundColor:p.color}}),s.jsx("span",{className:"repo-stack-legend-name",children:p.basename}),s.jsxs("span",{children:[xt(p.tokens)," (",g.toFixed(0),"%)"]})]},p.repoRoot??"__null__")})})]})}function hr(e){return e>=90?"gauge-red":e>=70?"gauge-yellow":"gauge-green"}function gr(e){return e==null?"?":e>=1e5?`${(e/1e3).toFixed(0)}k`:e.toLocaleString()}function Yt(e){if(!e)return"(unknown)";const t=e.replace(/[\\/]+$/,"");if(!t)return"(unknown)";const n=t.split(/[\\/]/);return n[n.length-1]||t}function pr(e){const t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s ago`;const n=Math.floor(t/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ${n%60}m ago`}function mr({data:e}){const t=Math.round((e.percent??0)*10)/10,n=Math.max(t,1),r=hr(t),o=gr(e.tokens),i=e.contextWindow.toLocaleString(),a=`${o} / ${i} tokens`;return s.jsxs("div",{className:`session-gauge ${e.isSelf?"session-gauge-self":""}`,children:[s.jsxs("div",{className:"session-gauge-head",children:[s.jsx("span",{className:"session-gauge-label",title:e.label,children:e.label}),s.jsxs("span",{className:"session-gauge-pct",children:[t,"%"]})]}),s.jsx("div",{className:`gauge-bar ${r}`,role:"meter","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${e.label}: ${t}%`,children:s.jsx("div",{className:"gauge-fill",style:{width:`${n}%`}})}),s.jsx("p",{className:"gauge-label session-gauge-sub",children:a}),e.sublabel&&s.jsx("p",{className:"session-gauge-meta truncate",title:e.sublabel,children:e.sublabel})]})}function vr({sessions:e,loading:t,error:n,launcherSessionId:r,launcher:o}){const i=Date.now(),a=(e?.sessions??[]).find(m=>m.sessionId===r),d=[{key:"self",label:a?Yt(a.repoRoot):"this session",sublabel:r??"",tokens:o.tokens,percent:o.percent,contextWindow:o.contextWindow,isSelf:!0}],u=(e?.sessions??[]).filter(m=>m.sessionId!==r);u.sort((m,v)=>v.lastSeen-m.lastSeen);const f=new Set,h=u.filter(m=>{if(m.tokens==null&&m.percent==null||m.percent!=null&&m.percent===0&&m.tokens!=null&&m.tokens>0)return!1;const v=m.repoRoot??`(pid:${m.pid})`;return f.has(v)?!1:(f.add(v),!0)});for(const m of h)d.push({key:m.sessionId,label:Yt(m.repoRoot),sublabel:`pid ${m.pid} · ${pr(i-m.lastSeen)}${m.model?` · ${m.model}`:""}`,tokens:m.tokens,percent:m.percent,contextWindow:m.ctxWindow||0,isSelf:!1});const p=n&&!e,g=t&&!e;return s.jsxs(ye,{className:"electric-hover session-gauges-card w-full",children:[s.jsx(Ae,{children:s.jsx(Le,{children:"Context per Session (live)"})}),s.jsx(we,{children:p?s.jsxs("div",{className:"text-sm text-muted-foreground",children:["Error loading sessions: ",n.message]}):g?s.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading sessions…"}):s.jsx("div",{className:"session-gauges-scroll",children:s.jsx("div",{className:"session-gauges-grid",children:d.map(m=>s.jsx(mr,{data:m},m.key))})})})]})}function Vt({state:e,label:t}){const n=e==="on"?"bullet-on":e==="na"?"bullet-na":"bullet-off";return s.jsxs("div",{className:`bullet ${n}`,children:[s.jsx("span",{className:"bullet-dot","aria-hidden":"true"}),s.jsx("span",{className:"bullet-label",children:t})]})}function xr({armed:e,ready:t}){const n=e?"on":"off",r=t?"on":e?"off":"na",o=t?"THRESHOLD EXCEEDED — compacting next event":e?"past fast gate — monitoring token count":"idle — below fast gate";return s.jsxs("div",{className:"card trigger-status",children:[s.jsx("h3",{children:"Trigger Status"}),s.jsxs("div",{className:"bullet-row",children:[s.jsx(Vt,{state:n,label:"Armed"}),s.jsx(Vt,{state:r,label:"Ready"})]}),s.jsx("p",{className:"trigger-state-text",children:o})]})}function br(e){return e>=.9?"meter-green":e>=.6?"meter-yellow":"meter-red"}function ue({label:e,value:t,title:n}){return s.jsxs("div",{className:"ov-stat-row",children:[s.jsx("span",{className:"ov-stat-label",title:n,children:e}),s.jsx("span",{className:"ov-stat-value",children:t})]})}function yr(e){const t=e.compressionPct,n=br(t),r=Math.max(t*100,.5),o=`${Re(t)} tokens saved · dedup: ${Re(e.dedupPct)}`;return s.jsxs("div",{className:"card vector-store-card",children:[s.jsx("h3",{children:"Vector Store (session)"}),s.jsx(ue,{label:"Checkpoints",value:e.checkpointCount.toLocaleString(),title:"A saved summary of a chunk of your conversation that was compacted to free up space."}),s.jsx(ue,{label:"Original (dropped)",value:e.tokensIn.toLocaleString(),title:"Total size of the original conversation text dropped into compaction this session, including redundant regions skipped by dedup. This is the 'in'."}),s.jsx(ue,{label:"Kept (summaries)",value:e.tokensOut.toLocaleString(),title:"Compact summaries we are currently holding as 'memory' for this session (the 'out'). Smaller is better."}),s.jsx(ue,{label:"Freed",value:e.tokensFreed.toLocaleString(),title:"Conversation space freed = dropped − kept (the 'saved')."}),s.jsx(ue,{label:"Injected",value:e.injectedCount,title:"How many times old context was automatically brought back into the conversation because it was relevant to what you were doing."}),s.jsx(ue,{label:"Recall Relevance",value:Re(e.dedupHitRate),title:"Of the times we recalled old context, how often it was actually on-topic."}),s.jsx(ue,{label:"Storage Dedup",value:Re(e.storageDedupRate),title:"How often new content matched something we already had, so we skipped storing a duplicate copy. Higher = less wasted space."}),s.jsx(ue,{label:"Collapsed",value:e.dedupCollapsed,title:"How many duplicate chunks we collapsed into one instead of storing separately."}),s.jsx(ue,{label:"Last ID",value:e.lastCheckpointId??"—",title:"The ID of the most recent saved checkpoint."}),s.jsxs("div",{className:"ov-compression-meter",children:[s.jsx("div",{className:"meter-track",children:s.jsx("div",{className:`meter-fill ${n}`,style:{width:`${r}%`}})}),s.jsx("span",{className:"meter-sub",children:o})]})]})}function wr(e){return e>=.9?"meter-green":e>=.6?"meter-yellow":"meter-red"}function Se({label:e,value:t}){return s.jsxs("div",{className:"flex items-baseline justify-between border-b border-border py-1 text-sm",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:e}),s.jsx("span",{className:"font-semibold",children:t})]})}function jr(e){const t=e.compressionPct,n=wr(t),r=Math.max(t*100,.5),o=`${Re(t)} tokens saved · dedup: ${Re(e.dedupPct)}`;return s.jsxs(ye,{className:"electric-hover",children:[s.jsx(Ae,{children:s.jsx(Le,{children:"Repo (all sessions)"})}),s.jsxs(we,{children:[s.jsx(Se,{label:"Checkpoints",value:e.checkpointCount.toLocaleString()}),s.jsx(Se,{label:"Original",value:e.tokensIn.toLocaleString()}),s.jsx(Se,{label:"Kept",value:e.tokensOut.toLocaleString()}),s.jsx(Se,{label:"Freed",value:e.tokensFreed.toLocaleString()}),s.jsx(Se,{label:"Sessions",value:e.sessionCount.toLocaleString()}),s.jsx(Se,{label:"Collapsed",value:e.dedupCollapsed}),s.jsx(Se,{label:"Storage Dedup",value:Re(e.storageDedupRate)}),s.jsxs("div",{children:[s.jsx("div",{className:"mt-2 h-2 w-full overflow-hidden rounded-full bg-bg-elevated",children:s.jsx("div",{className:`meter-fill h-full ${n}`,style:{width:`${r}%`}})}),s.jsx("span",{className:"mt-1 block text-xs text-muted-foreground",children:o})]})]})]})}function Sr(e){return s.jsxs("div",{className:"card data-safety-card",children:[s.jsx("h3",{children:"🛡 Data Safety"}),s.jsxs("div",{className:"ov-stat-row",children:[s.jsx("span",{className:"ov-stat-label",children:"Regions Retained"}),s.jsx("span",{className:"ov-stat-value",children:e.regionsRetained.toLocaleString()})]}),s.jsxs("div",{className:"ov-stat-row",children:[s.jsx("span",{className:"ov-stat-label",children:"Compressed-Original"}),s.jsx("span",{className:"ov-stat-value",children:Ut(e.compressedOriginalBytes)})]}),s.jsxs("div",{className:"ov-stat-row",children:[s.jsx("span",{className:"ov-stat-label",children:"Dedup Duplicates"}),s.jsx("span",{className:"ov-stat-value",children:e.duplicatesCollapsed.toLocaleString()})]}),s.jsxs("div",{className:"ov-stat-row",children:[s.jsx("span",{className:"ov-stat-label",children:"Permanently Deleted"}),s.jsx("span",{className:"ov-stat-value ov-value-ok",children:Ut(e.bytesPermanentlyDeleted)})]}),s.jsx("p",{className:"safe-note",children:'Every compacted region is kept verbatim (compressed). "Drop" = removed from the live window only. We never delete your data.'})]})}function Ce({label:e,value:t,title:n}){return s.jsxs("div",{className:"ov-stat-row",children:[s.jsx("span",{className:"ov-stat-label",title:n,children:e}),s.jsx("span",{className:"ov-stat-value",children:t})]})}function Cr(e){const t=`${Math.round((e.pressure??0)*100)}%`;let n=e.thresholdTokens.toLocaleString();return e.tierPct!=null&&e.contextWindow>0&&(n+=` (${Math.round(e.tierPct*100)}% of ${e.contextWindow.toLocaleString()})`),s.jsxs("div",{className:"card config-summary-card",children:[s.jsx("h3",{children:"Configuration"}),s.jsx(Ce,{label:"Tier",value:`${e.tier} (live)`,title:"Live pressure band — climbs low→mega as context fills the window."}),s.jsx(Ce,{label:"Preset",value:e.presetTier,title:"The env-resolved base compaction preset (low/medium/high/ultra/mega) that set the token threshold."}),s.jsx(Ce,{label:"Pressure",value:t,title:"Live pressure = currentTokens / threshold — % of the model context window (threshold fires at the tier's % of window)."}),s.jsx(Ce,{label:"Threshold",value:n,title:"Compaction threshold = tierPct × model context window — mega-compact trims BELOW pi's native ~80% auto-compact for any model size."}),s.jsx(Ce,{label:"Fast Gate",value:`${e.fastGatePct}%`,title:"Fast-gate arming floor — the live trim arms once context passes this % of the window."}),s.jsx(Ce,{label:"Auto",value:e.auto?"enabled":"disabled"}),s.jsx(Ce,{label:"Anchor",value:String(e.anchorUserMessages)})]})}function rt({label:e,value:t,title:n}){return s.jsxs("div",{className:"flex items-baseline justify-between border-b border-border py-1 text-sm",children:[s.jsx("span",{className:"text-xs text-muted-foreground",title:n,children:e}),s.jsx("span",{className:"font-semibold",children:t})]})}function Rr(e){const t=e.repoTokensFreed||0;let n=0,r="0";if(e.inputRate&&t>0){n=t*e.inputRate;const a=e.contextWindow||0;r=a>0?(t/a).toFixed(1):"0"}const o=`≈ $${n.toFixed(4)} saved`,i=`${r} context-windows extended`;return s.jsxs(ye,{className:"electric-hover",children:[s.jsx(Ae,{children:s.jsx(Le,{children:"💰 Model & Cost Savings"})}),s.jsxs(we,{children:[s.jsx("div",{className:"text-neon text-xl font-semibold",children:o}),s.jsx("div",{className:"mb-2 text-xs text-muted-foreground",children:i}),s.jsx(rt,{label:"Model",value:e.name,title:"The model pi is currently using — its pricing drives the cost figure."}),s.jsx(rt,{label:"Provider",value:e.provider,title:"The provider serving the model."}),s.jsx(rt,{label:"Input Rate",value:`$${e.inputRate.toFixed(6)}`,title:"USD per input token, from the model's pricing."}),s.jsx(rt,{label:"Output Rate",value:`$${e.outputRate.toFixed(6)}`,title:"USD per output token, from the model's pricing."})]})]})}function Dr(e){const{activeAgents:t,currentTurn:n}=e,r=t>0?`▶ ${t} running`:"idle";return s.jsxs(ye,{className:"electric-hover",children:[s.jsx(Ae,{children:s.jsx(Le,{children:"Crew / Agents"})}),s.jsxs(we,{children:[s.jsxs("div",{className:"flex items-baseline justify-between border-b border-border py-1 text-sm",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:"Active Agents"}),s.jsx("span",{className:"font-semibold",children:t})]}),s.jsxs("div",{className:"flex items-baseline justify-between border-b border-border py-1 text-sm",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:"Current Turn"}),s.jsx("span",{className:"font-semibold",children:n})]}),s.jsxs("div",{className:"flex items-baseline justify-between py-1 text-sm",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:"Status"}),s.jsx("span",{className:"font-semibold",children:r})]})]})]})}const kr=[s.jsxs("li",{children:[s.jsx("b",{children:"Original (dropped)"}),' — everything compacted away (including duplicates caught by dedup). The "in."']},"1"),s.jsxs("li",{children:[s.jsx("b",{children:"Kept (summaries)"}),' — compact summaries still held as "memory" (the "out").']},"2"),s.jsxs("li",{children:[s.jsx("b",{children:"Freed"})," = dropped − kept — tokens saved so far (higher = better)."]},"3"),s.jsxs("li",{children:[s.jsx("b",{children:"Compression %"})," — Freed ÷ Dropped — the headline efficiency number. Higher = more space reclaimed."]},"4"),s.jsxs("li",{children:[s.jsx("b",{children:"Storage dedup %"})," — how often new content matched something already saved, so no duplicate copy was written."]},"5"),s.jsxs("li",{children:[s.jsx("b",{children:"Data safety"})," — every compacted region is kept verbatim (compressed). Nothing is permanently deleted; you can restore any of it."]},"6")];function Nr(){return s.jsx(ye,{children:s.jsx(we,{children:s.jsxs("details",{children:[s.jsx("summary",{className:"cursor-pointer text-sm font-semibold",children:"What these numbers mean"}),s.jsx("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm",children:kr}),s.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Hover any label above for a quick explanation."})]})})})}const Er=()=>{const{data:e}=un(l.useMemo(()=>()=>Yn(),[]),{pollInterval:3e4});if(!e)return s.jsx(ye,{children:s.jsx(we,{className:"text-sm text-muted-foreground",children:"Loading RAG health…"})});const{totals:t,flags:n}=e,r=n.hydeEnabled||n.recallMetricsEnabled;return s.jsxs(ye,{children:[s.jsx(Ae,{children:s.jsxs(Le,{className:"flex items-center gap-2",children:[s.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${r?"bg-success":"bg-muted-foreground"}`,"aria-hidden":"true"}),"RAG Health"]})}),s.jsx(we,{children:r?s.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs text-muted-foreground",children:"Pass rate"}),s.jsxs("dd",{className:"font-semibold text-foreground",children:[Math.round(t.recentPassRate*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs text-muted-foreground",children:"Avg lift"}),s.jsxs("dd",{className:"font-semibold text-foreground",children:[t.avgLift.toFixed(2),"×"]})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs text-muted-foreground",children:"Telemetry turns"}),s.jsx("dd",{className:"font-semibold text-foreground",children:t.telemetryTurns})]}),s.jsxs("div",{children:[s.jsx("dt",{className:"text-xs text-muted-foreground",children:"HyDE ran"}),s.jsx("dd",{className:"font-semibold text-foreground",children:t.hydeRanTurns})]})]}):s.jsx("div",{className:"text-sm text-muted-foreground",children:"All RAG recall feature flags are off."})})]})};function st({title:e,open:t,onClose:n,children:r}){return l.useEffect(()=>{if(!t)return;const o=i=>{i.key==="Escape"&&n()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t,n]),t?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onClick:n,role:"dialog","aria-modal":"true","aria-label":e,children:s.jsxs("div",{className:"max-h-[80vh] w-full max-w-3xl overflow-y-auto rounded-lg border border-border bg-bg-card p-5",onClick:o=>o.stopPropagation(),children:[s.jsxs("header",{className:"mb-4 flex items-center justify-between gap-4",children:[s.jsx("h2",{className:"font-heading text-lg font-semibold",children:e}),s.jsx("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground",onClick:n,"aria-label":"Close",children:s.jsx(ar,{size:22,strokeWidth:2})})]}),r]})}):s.jsx(s.Fragment,{})}const bt="#8b949e",Tr="#30363d",Mr={background:"#161b22",border:"1px solid #30363d",borderRadius:"6px",color:"#e6edf3"};function qt(e){return new Date(e).toLocaleTimeString()}function Jt(e){return Number.isFinite(e),String(e)}function yt({data:e,label:t="value",color:n="#58a6ff",height:r=280}){if(!e||e.length===0)return s.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No data available"});const o=`perf-line-${n.replace(/[^a-zA-Z0-9]/g,"")}`;return s.jsx(fn,{width:"100%",height:r,children:s.jsxs(sr,{data:e,margin:{top:8,right:16,left:0,bottom:0},children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:o,x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"5%",stopColor:n,stopOpacity:.7}),s.jsx("stop",{offset:"95%",stopColor:n,stopOpacity:.15})]})}),s.jsx(hn,{strokeDasharray:"3 3",stroke:Tr}),s.jsx(gn,{dataKey:"ts",type:"number",domain:["dataMin","dataMax"],scale:"time",tickFormatter:i=>qt(i),stroke:bt,tick:{fontSize:11}}),s.jsx(pn,{dataKey:"value",stroke:bt,tick:{fontSize:11},width:56,tickFormatter:i=>Jt(i)}),s.jsx(mn,{labelFormatter:i=>qt(i),formatter:i=>[Jt(i),t],contentStyle:Mr,labelStyle:{color:bt,fontSize:12}}),s.jsx(nr,{type:"monotone",dataKey:"value",name:t,stroke:n,strokeWidth:2,dot:!1,fill:`url(#${o})`,isAnimationActive:!1})]})})}const wt="#8b949e",Or="#30363d",Ar={background:"#161b22",border:"1px solid #30363d",borderRadius:"6px",color:"#e6edf3"};function Lr({data:e,color:t="#3fb950",height:n=280,valueFormatter:r}){const o=r??(i=>String(i));return!e||e.length===0?s.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No data available"}):s.jsx(fn,{width:"100%",height:n,children:s.jsxs(or,{data:e,margin:{top:8,right:16,left:0,bottom:0},children:[s.jsx(hn,{strokeDasharray:"3 3",stroke:Or}),s.jsx(gn,{dataKey:"label",stroke:wt,tick:{fontSize:11},interval:0,angle:-20,textAnchor:"end",height:56}),s.jsx(pn,{dataKey:"value",stroke:wt,tick:{fontSize:11},width:56,tickFormatter:i=>o(i)}),s.jsx(mn,{formatter:i=>[o(i),"value"],contentStyle:Ar,labelStyle:{color:wt,fontSize:12}}),s.jsx(rr,{dataKey:"value",fill:t,radius:[4,4,0,0],isAnimationActive:!1})]})})}function Ir(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const ut=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ie(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Mt(e){return"nodeType"in e}function U(e){var t,n;return e?Ie(e)?e:Mt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function Ot(e){const{Document:t}=U(e);return e instanceof t}function Je(e){return Ie(e)?!1:e instanceof U(e).HTMLElement}function vn(e){return e instanceof U(e).SVGElement}function Pe(e){return e?Ie(e)?e.document:Mt(e)?Ot(e)?e:Je(e)||vn(e)?e.ownerDocument:document:document:document}const ie=ut?l.useLayoutEffect:l.useEffect;function At(e){const t=l.useRef(e);return ie(()=>{t.current=e}),l.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function Pr(){const e=l.useRef(null),t=l.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=l.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Ye(e,t){t===void 0&&(t=[e]);const n=l.useRef(e);return ie(()=>{n.current!==e&&(n.current=e)},t),n}function Qe(e,t){const n=l.useRef();return l.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function at(e){const t=At(e),n=l.useRef(null),r=l.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function Dt(e){const t=l.useRef();return l.useEffect(()=>{t.current=e},[e]),t.current}let jt={};function Ze(e,t){return l.useMemo(()=>{if(t)return t;const n=jt[e]==null?0:jt[e]+1;return jt[e]=n,e+"-"+n},[e,t])}function xn(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,a)=>{const c=Object.entries(a);for(const[d,u]of c){const f=i[d];f!=null&&(i[d]=f+e*u)}return i},{...t})}}const Oe=xn(1),lt=xn(-1);function $r(e){return"clientX"in e&&"clientY"in e}function Lt(e){if(!e)return!1;const{KeyboardEvent:t}=U(e.target);return t&&e instanceof t}function Fr(e){if(!e)return!1;const{TouchEvent:t}=U(e.target);return t&&e instanceof t}function kt(e){if(Fr(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return $r(e)?{x:e.clientX,y:e.clientY}:null}const Ve=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Ve.Translate.toString(e),Ve.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Qt="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function zr(e){return e.matches(Qt)?e:e.querySelector(Qt)}const Br={display:"none"};function Wr(e){let{id:t,value:n}=e;return K.createElement("div",{id:t,style:Br},n)}function Hr(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return K.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function _r(){const[e,t]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const bn=l.createContext(null);function Xr(e){const t=l.useContext(bn);l.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Kr(){const[e]=l.useState(()=>new Set),t=l.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[l.useCallback(r=>{let{type:o,event:i}=r;e.forEach(a=>{var c;return(c=a[o])==null?void 0:c.call(a,i)})},[e]),t]}const Ur={draggable:`
12
- To pick up a draggable item, press the space bar.
13
- While dragging, use the arrow keys to move the item.
14
- Press space again to drop the item in its new position, or press escape to cancel.
15
- `},Gr={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Yr(e){let{announcements:t=Gr,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Ur}=e;const{announce:i,announcement:a}=_r(),c=Ze("DndLiveRegion"),[d,u]=l.useState(!1);if(l.useEffect(()=>{u(!0)},[]),Xr(l.useMemo(()=>({onDragStart(h){let{active:p}=h;i(t.onDragStart({active:p}))},onDragMove(h){let{active:p,over:g}=h;t.onDragMove&&i(t.onDragMove({active:p,over:g}))},onDragOver(h){let{active:p,over:g}=h;i(t.onDragOver({active:p,over:g}))},onDragEnd(h){let{active:p,over:g}=h;i(t.onDragEnd({active:p,over:g}))},onDragCancel(h){let{active:p,over:g}=h;i(t.onDragCancel({active:p,over:g}))}}),[i,t])),!d)return null;const f=K.createElement(K.Fragment,null,K.createElement(Wr,{id:r,value:o.draggable}),K.createElement(Hr,{id:c,announcement:a}));return n?_e.createPortal(f,n):f}var I;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(I||(I={}));function ct(){}const te=Object.freeze({x:0,y:0});function Vr(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function qr(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Jr(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),a=o-r,c=i-n;if(r<o&&n<i){const d=t.width*t.height,u=e.width*e.height,f=a*c,h=f/(d+u-f);return Number(h.toFixed(4))}return 0}const Qr=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:a}=i,c=n.get(a);if(c){const d=Jr(c,t);d>0&&o.push({id:a,data:{droppableContainer:i,value:d}})}}return o.sort(Vr)};function Zr(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function yn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:te}function es(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((a,c)=>({...a,top:a.top+e*c.y,bottom:a.bottom+e*c.y,left:a.left+e*c.x,right:a.right+e*c.x}),{...n})}}const ts=es(1);function ns(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function rs(e,t,n){const r=ns(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:c}=r,d=e.left-a-(1-o)*parseFloat(n),u=e.top-c-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),f=o?e.width/o:e.width,h=i?e.height/i:e.height;return{width:f,height:h,top:u,right:d+f,bottom:u+h,left:d}}const ss={ignoreTransform:!1};function $e(e,t){t===void 0&&(t=ss);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:f}=U(e).getComputedStyle(e);u&&(n=rs(n,u,f))}const{top:r,left:o,width:i,height:a,bottom:c,right:d}=n;return{top:r,left:o,width:i,height:a,bottom:c,right:d}}function Zt(e){return $e(e,{ignoreTransform:!0})}function os(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function is(e,t){return t===void 0&&(t=U(e).getComputedStyle(e)),t.position==="fixed"}function as(e,t){t===void 0&&(t=U(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function It(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(Ot(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Je(o)||vn(o)||n.includes(o))return n;const i=U(e).getComputedStyle(o);return o!==e&&as(o,i)&&n.push(o),is(o,i)?n:r(o.parentNode)}return e?r(e):n}function wn(e){const[t]=It(e,1);return t??null}function St(e){return!ut||!e?null:Ie(e)?e:Mt(e)?Ot(e)||e===Pe(e).scrollingElement?window:Je(e)?e:null:null}function jn(e){return Ie(e)?e.scrollX:e.scrollLeft}function Sn(e){return Ie(e)?e.scrollY:e.scrollTop}function Nt(e){return{x:jn(e),y:Sn(e)}}var $;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})($||($={}));function Cn(e){return!ut||!e?!1:e===document.scrollingElement}function Rn(e){const t={x:0,y:0},n=Cn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,a=e.scrollTop>=r.y,c=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:a,isRight:c,maxScroll:r,minScroll:t}}const ls={x:.2,y:.2};function cs(e,t,n,r,o){let{top:i,left:a,right:c,bottom:d}=n;r===void 0&&(r=10),o===void 0&&(o=ls);const{isTop:u,isBottom:f,isLeft:h,isRight:p}=Rn(e),g={x:0,y:0},m={x:0,y:0},v={height:t.height*o.y,width:t.width*o.x};return!u&&i<=t.top+v.height?(g.y=$.Backward,m.y=r*Math.abs((t.top+v.height-i)/v.height)):!f&&d>=t.bottom-v.height&&(g.y=$.Forward,m.y=r*Math.abs((t.bottom-v.height-d)/v.height)),!p&&c>=t.right-v.width?(g.x=$.Forward,m.x=r*Math.abs((t.right-v.width-c)/v.width)):!h&&a<=t.left+v.width&&(g.x=$.Backward,m.x=r*Math.abs((t.left+v.width-a)/v.width)),{direction:g,speed:m}}function ds(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:a}=window;return{top:0,left:0,right:i,bottom:a,width:i,height:a}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Dn(e){return e.reduce((t,n)=>Oe(t,Nt(n)),te)}function us(e){return e.reduce((t,n)=>t+jn(n),0)}function fs(e){return e.reduce((t,n)=>t+Sn(n),0)}function hs(e,t){if(t===void 0&&(t=$e),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);wn(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const gs=[["x",["left","right"],us],["y",["top","bottom"],fs]];class Pt{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=It(n),o=Dn(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,a,c]of gs)for(const d of a)Object.defineProperty(this,d,{get:()=>{const u=c(r),f=o[i]-u;return this.rect[d]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Xe{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function ps(e){const{EventTarget:t}=U(e);return e instanceof t?e:Pe(e)}function Ct(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var Q;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Q||(Q={}));function en(e){e.preventDefault()}function ms(e){e.stopPropagation()}var N;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(N||(N={}));const kn={start:[N.Space,N.Enter],cancel:[N.Esc],end:[N.Space,N.Enter,N.Tab]},vs=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case N.Right:return{...n,x:n.x+25};case N.Left:return{...n,x:n.x-25};case N.Down:return{...n,y:n.y+25};case N.Up:return{...n,y:n.y-25}}};class Nn{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Xe(Pe(n)),this.windowListeners=new Xe(U(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Q.Resize,this.handleCancel),this.windowListeners.add(Q.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Q.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&hs(r),n(te)}handleKeyDown(t){if(Lt(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=kn,coordinateGetter:a=vs,scrollBehavior:c="smooth"}=o,{code:d}=t;if(i.end.includes(d)){this.handleEnd(t);return}if(i.cancel.includes(d)){this.handleCancel(t);return}const{collisionRect:u}=r.current,f=u?{x:u.left,y:u.top}:te;this.referenceCoordinates||(this.referenceCoordinates=f);const h=a(t,{active:n,context:r.current,currentCoordinates:f});if(h){const p=lt(h,f),g={x:0,y:0},{scrollableAncestors:m}=r.current;for(const v of m){const x=t.code,{isTop:C,isRight:R,isLeft:S,isBottom:D,maxScroll:k,minScroll:y}=Rn(v),j=ds(v),b={x:Math.min(x===N.Right?j.right-j.width/2:j.right,Math.max(x===N.Right?j.left:j.left+j.width/2,h.x)),y:Math.min(x===N.Down?j.bottom-j.height/2:j.bottom,Math.max(x===N.Down?j.top:j.top+j.height/2,h.y))},M=x===N.Right&&!R||x===N.Left&&!S,O=x===N.Down&&!D||x===N.Up&&!C;if(M&&b.x!==h.x){const E=v.scrollLeft+p.x,_=x===N.Right&&E<=k.x||x===N.Left&&E>=y.x;if(_&&!p.y){v.scrollTo({left:E,behavior:c});return}_?g.x=v.scrollLeft-E:g.x=x===N.Right?v.scrollLeft-k.x:v.scrollLeft-y.x,g.x&&v.scrollBy({left:-g.x,behavior:c});break}else if(O&&b.y!==h.y){const E=v.scrollTop+p.y,_=x===N.Down&&E<=k.y||x===N.Up&&E>=y.y;if(_&&!p.x){v.scrollTo({top:E,behavior:c});return}_?g.y=v.scrollTop-E:g.y=x===N.Down?v.scrollTop-k.y:v.scrollTop-y.y,g.y&&v.scrollBy({top:-g.y,behavior:c});break}}this.handleMove(t,Oe(lt(h,this.referenceCoordinates),g))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Nn.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=kn,onActivation:o}=t,{active:i}=n;const{code:a}=e.nativeEvent;if(r.start.includes(a)){const c=i.activatorNode.current;return c&&e.target!==c?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function tn(e){return!!(e&&"distance"in e)}function nn(e){return!!(e&&"delay"in e)}class $t{constructor(t,n,r){var o;r===void 0&&(r=ps(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:a}=i;this.props=t,this.events=n,this.document=Pe(a),this.documentListeners=new Xe(this.document),this.listeners=new Xe(r),this.windowListeners=new Xe(U(a)),this.initialCoordinates=(o=kt(i))!=null?o:te,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Q.Resize,this.handleCancel),this.windowListeners.add(Q.DragStart,en),this.windowListeners.add(Q.VisibilityChange,this.handleCancel),this.windowListeners.add(Q.ContextMenu,en),this.documentListeners.add(Q.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(nn(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(tn(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(Q.Click,ms,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Q.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:a,options:{activationConstraint:c}}=i;if(!o)return;const d=(n=kt(t))!=null?n:te,u=lt(o,d);if(!r&&c){if(tn(c)){if(c.tolerance!=null&&Ct(u,c.tolerance))return this.handleCancel();if(Ct(u,c.distance))return this.handleStart()}if(nn(c)&&Ct(u,c.tolerance))return this.handleCancel();this.handlePending(c,u);return}t.cancelable&&t.preventDefault(),a(d)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===N.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const xs={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class En extends $t{constructor(t){const{event:n}=t,r=Pe(n.target);super(t,xs,r)}}En.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const bs={move:{name:"mousemove"},end:{name:"mouseup"}};var Et;(function(e){e[e.RightClick=2]="RightClick"})(Et||(Et={}));class ys extends $t{constructor(t){super(t,bs,Pe(t.event.target))}}ys.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Et.RightClick?!1:(r?.({event:n}),!0)}}];const Rt={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ws extends $t{constructor(t){super(t,Rt)}static setup(){return window.addEventListener(Rt.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Rt.move.name,t)};function t(){}}}ws.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Ke;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ke||(Ke={}));var dt;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(dt||(dt={}));function js(e){let{acceleration:t,activator:n=Ke.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:a=5,order:c=dt.TreeOrder,pointerCoordinates:d,scrollableAncestors:u,scrollableAncestorRects:f,delta:h,threshold:p}=e;const g=Cs({delta:h,disabled:!i}),[m,v]=Pr(),x=l.useRef({x:0,y:0}),C=l.useRef({x:0,y:0}),R=l.useMemo(()=>{switch(n){case Ke.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case Ke.DraggableRect:return o}},[n,o,d]),S=l.useRef(null),D=l.useCallback(()=>{const y=S.current;if(!y)return;const j=x.current.x*C.current.x,b=x.current.y*C.current.y;y.scrollBy(j,b)},[]),k=l.useMemo(()=>c===dt.TreeOrder?[...u].reverse():u,[c,u]);l.useEffect(()=>{if(!i||!u.length||!R){v();return}for(const y of k){if(r?.(y)===!1)continue;const j=u.indexOf(y),b=f[j];if(!b)continue;const{direction:M,speed:O}=cs(y,b,R,t,p);for(const E of["x","y"])g[E][M[E]]||(O[E]=0,M[E]=0);if(O.x>0||O.y>0){v(),S.current=y,m(D,a),x.current=O,C.current=M;return}}x.current={x:0,y:0},C.current={x:0,y:0},v()},[t,D,r,v,i,a,JSON.stringify(R),JSON.stringify(g),m,u,k,f,JSON.stringify(p)])}const Ss={x:{[$.Backward]:!1,[$.Forward]:!1},y:{[$.Backward]:!1,[$.Forward]:!1}};function Cs(e){let{delta:t,disabled:n}=e;const r=Dt(t);return Qe(o=>{if(n||!r||!o)return Ss;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[$.Backward]:o.x[$.Backward]||i.x===-1,[$.Forward]:o.x[$.Forward]||i.x===1},y:{[$.Backward]:o.y[$.Backward]||i.y===-1,[$.Forward]:o.y[$.Forward]||i.y===1}}},[n,t,r])}function Rs(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Qe(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function Ds(e,t){return l.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(a=>({eventName:a.eventName,handler:t(a.handler,r)}));return[...n,...i]},[]),[e,t])}var qe;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(qe||(qe={}));var Tt;(function(e){e.Optimized="optimized"})(Tt||(Tt={}));const rn=new Map;function ks(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,a]=l.useState(null),{frequency:c,measure:d,strategy:u}=o,f=l.useRef(e),h=x(),p=Ye(h),g=l.useCallback(function(C){C===void 0&&(C=[]),!p.current&&a(R=>R===null?C:R.concat(C.filter(S=>!R.includes(S))))},[p]),m=l.useRef(null),v=Qe(C=>{if(h&&!n)return rn;if(!C||C===rn||f.current!==e||i!=null){const R=new Map;for(let S of e){if(!S)continue;if(i&&i.length>0&&!i.includes(S.id)&&S.rect.current){R.set(S.id,S.rect.current);continue}const D=S.node.current,k=D?new Pt(d(D),D):null;S.rect.current=k,k&&R.set(S.id,k)}return R}return C},[e,i,n,h,d]);return l.useEffect(()=>{f.current=e},[e]),l.useEffect(()=>{h||g()},[n,h]),l.useEffect(()=>{i&&i.length>0&&a(null)},[JSON.stringify(i)]),l.useEffect(()=>{h||typeof c!="number"||m.current!==null||(m.current=setTimeout(()=>{g(),m.current=null},c))},[c,h,g,...r]),{droppableRects:v,measureDroppableContainers:g,measuringScheduled:i!=null};function x(){switch(u){case qe.Always:return!1;case qe.BeforeDragging:return n;default:return!n}}}function Tn(e,t){return Qe(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Ns(e,t){return Tn(e,t)}function Es(e){let{callback:t,disabled:n}=e;const r=At(t),o=l.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return l.useEffect(()=>()=>o?.disconnect(),[o]),o}function ft(e){let{callback:t,disabled:n}=e;const r=At(t),o=l.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return l.useEffect(()=>()=>o?.disconnect(),[o]),o}function Ts(e){return new Pt($e(e),e)}function sn(e,t,n){t===void 0&&(t=Ts);const[r,o]=l.useState(null);function i(){o(d=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=d??n)!=null?u:null}const f=t(e);return JSON.stringify(d)===JSON.stringify(f)?d:f})}const a=Es({callback(d){if(e)for(const u of d){const{type:f,target:h}=u;if(f==="childList"&&h instanceof HTMLElement&&h.contains(e)){i();break}}}}),c=ft({callback:i});return ie(()=>{i(),e?(c?.observe(e),a?.observe(document.body,{childList:!0,subtree:!0})):(c?.disconnect(),a?.disconnect())},[e]),r}function Ms(e){const t=Tn(e);return yn(e,t)}const on=[];function Os(e){const t=l.useRef(e),n=Qe(r=>e?r&&r!==on&&e&&t.current&&e.parentNode===t.current.parentNode?r:It(e):on,[e]);return l.useEffect(()=>{t.current=e},[e]),n}function As(e){const[t,n]=l.useState(null),r=l.useRef(e),o=l.useCallback(i=>{const a=St(i.target);a&&n(c=>c?(c.set(a,Nt(a)),new Map(c)):null)},[]);return l.useEffect(()=>{const i=r.current;if(e!==i){a(i);const c=e.map(d=>{const u=St(d);return u?(u.addEventListener("scroll",o,{passive:!0}),[u,Nt(u)]):null}).filter(d=>d!=null);n(c.length?new Map(c):null),r.current=e}return()=>{a(e),a(i)};function a(c){c.forEach(d=>{const u=St(d);u?.removeEventListener("scroll",o)})}},[o,e]),l.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,a)=>Oe(i,a),te):Dn(e):te,[e,t])}function an(e,t){t===void 0&&(t=[]);const n=l.useRef(null);return l.useEffect(()=>{n.current=null},t),l.useEffect(()=>{const r=e!==te;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?lt(e,n.current):te}function Ls(e){l.useEffect(()=>{if(!ut)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function Is(e,t){return l.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=a=>{i(a,t)},n},{}),[e,t])}function Mn(e){return l.useMemo(()=>e?os(e):null,[e])}const ln=[];function Ps(e,t){t===void 0&&(t=$e);const[n]=e,r=Mn(n?U(n):null),[o,i]=l.useState(ln);function a(){i(()=>e.length?e.map(d=>Cn(d)?r:new Pt(t(d),d)):ln)}const c=ft({callback:a});return ie(()=>{c?.disconnect(),a(),e.forEach(d=>c?.observe(d))},[e]),o}function $s(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Je(t)?t:e}function Fs(e){let{measure:t}=e;const[n,r]=l.useState(null),o=l.useCallback(u=>{for(const{target:f}of u)if(Je(f)){r(h=>{const p=t(f);return h?{...h,width:p.width,height:p.height}:p});break}},[t]),i=ft({callback:o}),a=l.useCallback(u=>{const f=$s(u);i?.disconnect(),f&&i?.observe(f),r(f?t(f):null)},[t,i]),[c,d]=at(a);return l.useMemo(()=>({nodeRef:c,rect:n,setRef:d}),[n,c,d])}const zs=[{sensor:En,options:{}},{sensor:Nn,options:{}}],Bs={current:{}},it={draggable:{measure:Zt},droppable:{measure:Zt,strategy:qe.WhileDragging,frequency:Tt.Optimized},dragOverlay:{measure:$e}};class Ue extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Ws={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ue,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ct},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:it,measureDroppableContainers:ct,windowRect:null,measuringScheduled:!1},Hs={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ct,draggableNodes:new Map,over:null,measureDroppableContainers:ct},ht=l.createContext(Hs),On=l.createContext(Ws);function _s(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ue}}}function Xs(e,t){switch(t.type){case I.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case I.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case I.DragEnd:case I.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case I.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Ue(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case I.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const a=new Ue(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case I.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Ue(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function Ks(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=l.useContext(ht),i=Dt(r),a=Dt(n?.id);return l.useEffect(()=>{if(!t&&!r&&i&&a!=null){if(!Lt(i)||document.activeElement===i.target)return;const c=o.get(a);if(!c)return;const{activatorNode:d,node:u}=c;if(!d.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[d.current,u.current]){if(!f)continue;const h=zr(f);if(h){h.focus();break}}})}},[r,t,o,a,i]),null}function Us(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function Gs(e){return l.useMemo(()=>({draggable:{...it.draggable,...e?.draggable},droppable:{...it.droppable,...e?.droppable},dragOverlay:{...it.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Ys(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=l.useRef(!1),{x:a,y:c}=typeof o=="boolean"?{x:o,y:o}:o;ie(()=>{if(!a&&!c||!t){i.current=!1;return}if(i.current||!r)return;const u=t?.node.current;if(!u||u.isConnected===!1)return;const f=n(u),h=yn(f,r);if(a||(h.x=0),c||(h.y=0),i.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const p=wn(u);p&&p.scrollBy({top:h.y,left:h.x})}},[t,a,c,r,n])}const An=l.createContext({...te,scaleX:1,scaleY:1});var be;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(be||(be={}));const Vs=l.memo(function(t){var n,r,o,i;let{id:a,accessibility:c,autoScroll:d=!0,children:u,sensors:f=zs,collisionDetection:h=Qr,measuring:p,modifiers:g,...m}=t;const v=l.useReducer(Xs,void 0,_s),[x,C]=v,[R,S]=Kr(),[D,k]=l.useState(be.Uninitialized),y=D===be.Initialized,{draggable:{active:j,nodes:b,translate:M},droppable:{containers:O}}=x,E=j!=null?b.get(j):null,_=l.useRef({initial:null,translated:null}),G=l.useMemo(()=>{var W;return j!=null?{id:j,data:(W=E?.data)!=null?W:Bs,rect:_}:null},[j,E]),z=l.useRef(null),[fe,ae]=l.useState(null),[P,je]=l.useState(null),X=Ye(m,Object.values(m)),ne=Ze("DndDescribedBy",a),Z=l.useMemo(()=>O.getEnabled(),[O]),B=Gs(p),{droppableRects:w,measureDroppableContainers:L,measuringScheduled:A}=ks(Z,{dragging:y,dependencies:[M.x,M.y],config:B.droppable}),H=Rs(b,j),et=l.useMemo(()=>P?kt(P):null,[P]),he=Gn(),le=Ns(H,B.draggable.measure);Ys({activeNode:j!=null?b.get(j):null,config:he.layoutShiftCompensation,initialRect:le,measure:B.draggable.measure});const T=sn(H,B.draggable.measure,le),Fe=sn(H?H.parentElement:null),re=l.useRef({activatorEvent:null,active:null,activeNode:H,collisionRect:null,collisions:null,droppableRects:w,draggableNodes:b,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),De=O.getNodeFor((n=re.current.over)==null?void 0:n.id),ce=Fs({measure:B.dragOverlay.measure}),ke=(r=ce.nodeRef.current)!=null?r:H,Ne=y?(o=ce.rect)!=null?o:T:null,Ft=!!(ce.nodeRef.current&&ce.rect),zt=Ms(Ft?null:T),gt=Mn(ke?U(ke):null),ge=Os(y?De??H:null),tt=Ps(ge),nt=Us(g,{transform:{x:M.x-zt.x,y:M.y-zt.y,scaleX:1,scaleY:1},activatorEvent:P,active:G,activeNodeRect:T,containerNodeRect:Fe,draggingNodeRect:Ne,over:re.current.over,overlayNodeRect:ce.rect,scrollableAncestors:ge,scrollableAncestorRects:tt,windowRect:gt}),Bt=et?Oe(et,M):null,Wt=As(ge),Bn=an(Wt),Wn=an(Wt,[T]),Ee=Oe(nt,Bn),Te=Ne?ts(Ne,nt):null,ze=G&&Te?h({active:G,collisionRect:Te,droppableRects:w,droppableContainers:Z,pointerCoordinates:Bt}):null,Ht=qr(ze,"id"),[pe,_t]=l.useState(null),Hn=Ft?nt:Oe(nt,Wn),_n=Zr(Hn,(i=pe?.rect)!=null?i:null,T),pt=l.useRef(null),Xt=l.useCallback((W,Y)=>{let{sensor:V,options:me}=Y;if(z.current==null)return;const J=b.get(z.current);if(!J)return;const q=W.nativeEvent,se=new V({active:z.current,activeNode:J,event:q,options:me,context:re,onAbort(F){if(!b.get(F))return;const{onDragAbort:oe}=X.current,de={id:F};oe?.(de),R({type:"onDragAbort",event:de})},onPending(F,ve,oe,de){if(!b.get(F))return;const{onDragPending:We}=X.current,xe={id:F,constraint:ve,initialCoordinates:oe,offset:de};We?.(xe),R({type:"onDragPending",event:xe})},onStart(F){const ve=z.current;if(ve==null)return;const oe=b.get(ve);if(!oe)return;const{onDragStart:de}=X.current,Be={activatorEvent:q,active:{id:ve,data:oe.data,rect:_}};_e.unstable_batchedUpdates(()=>{de?.(Be),k(be.Initializing),C({type:I.DragStart,initialCoordinates:F,active:ve}),R({type:"onDragStart",event:Be}),ae(pt.current),je(q)})},onMove(F){C({type:I.DragMove,coordinates:F})},onEnd:Me(I.DragEnd),onCancel:Me(I.DragCancel)});pt.current=se;function Me(F){return async function(){const{active:oe,collisions:de,over:Be,scrollAdjustedTranslate:We}=re.current;let xe=null;if(oe&&We){const{cancelDrop:He}=X.current;xe={activatorEvent:q,active:oe,collisions:de,delta:We,over:Be},F===I.DragEnd&&typeof He=="function"&&await Promise.resolve(He(xe))&&(F=I.DragCancel)}z.current=null,_e.unstable_batchedUpdates(()=>{C({type:F}),k(be.Uninitialized),_t(null),ae(null),je(null),pt.current=null;const He=F===I.DragEnd?"onDragEnd":"onDragCancel";if(xe){const mt=X.current[He];mt?.(xe),R({type:He,event:xe})}})}}},[b]),Xn=l.useCallback((W,Y)=>(V,me)=>{const J=V.nativeEvent,q=b.get(me);if(z.current!==null||!q||J.dndKit||J.defaultPrevented)return;const se={active:q};W(V,Y.options,se)===!0&&(J.dndKit={capturedBy:Y.sensor},z.current=me,Xt(V,Y))},[b,Xt]),Kt=Ds(f,Xn);Ls(f),ie(()=>{T&&D===be.Initializing&&k(be.Initialized)},[T,D]),l.useEffect(()=>{const{onDragMove:W}=X.current,{active:Y,activatorEvent:V,collisions:me,over:J}=re.current;if(!Y||!V)return;const q={active:Y,activatorEvent:V,collisions:me,delta:{x:Ee.x,y:Ee.y},over:J};_e.unstable_batchedUpdates(()=>{W?.(q),R({type:"onDragMove",event:q})})},[Ee.x,Ee.y]),l.useEffect(()=>{const{active:W,activatorEvent:Y,collisions:V,droppableContainers:me,scrollAdjustedTranslate:J}=re.current;if(!W||z.current==null||!Y||!J)return;const{onDragOver:q}=X.current,se=me.get(Ht),Me=se&&se.rect.current?{id:se.id,rect:se.rect.current,data:se.data,disabled:se.disabled}:null,F={active:W,activatorEvent:Y,collisions:V,delta:{x:J.x,y:J.y},over:Me};_e.unstable_batchedUpdates(()=>{_t(Me),q?.(F),R({type:"onDragOver",event:F})})},[Ht]),ie(()=>{re.current={activatorEvent:P,active:G,activeNode:H,collisionRect:Te,collisions:ze,droppableRects:w,draggableNodes:b,draggingNode:ke,draggingNodeRect:Ne,droppableContainers:O,over:pe,scrollableAncestors:ge,scrollAdjustedTranslate:Ee},_.current={initial:Ne,translated:Te}},[G,H,ze,Te,b,ke,Ne,w,O,pe,ge,Ee]),js({...he,delta:M,draggingRect:Te,pointerCoordinates:Bt,scrollableAncestors:ge,scrollableAncestorRects:tt});const Kn=l.useMemo(()=>({active:G,activeNode:H,activeNodeRect:T,activatorEvent:P,collisions:ze,containerNodeRect:Fe,dragOverlay:ce,draggableNodes:b,droppableContainers:O,droppableRects:w,over:pe,measureDroppableContainers:L,scrollableAncestors:ge,scrollableAncestorRects:tt,measuringConfiguration:B,measuringScheduled:A,windowRect:gt}),[G,H,T,P,ze,Fe,ce,b,O,w,pe,L,ge,tt,B,A,gt]),Un=l.useMemo(()=>({activatorEvent:P,activators:Kt,active:G,activeNodeRect:T,ariaDescribedById:{draggable:ne},dispatch:C,draggableNodes:b,over:pe,measureDroppableContainers:L}),[P,Kt,G,T,C,ne,b,pe,L]);return K.createElement(bn.Provider,{value:S},K.createElement(ht.Provider,{value:Un},K.createElement(On.Provider,{value:Kn},K.createElement(An.Provider,{value:_n},u)),K.createElement(Ks,{disabled:c?.restoreFocus===!1})),K.createElement(Yr,{...c,hiddenTextDescribedById:ne}));function Gn(){const W=fe?.autoScrollEnabled===!1,Y=typeof d=="object"?d.enabled===!1:d===!1,V=y&&!W&&!Y;return typeof d=="object"?{...d,enabled:V}:{enabled:V}}}),qs=l.createContext(null),cn="button",Js="Draggable";function Qs(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=Ze(Js),{activators:a,activatorEvent:c,active:d,activeNodeRect:u,ariaDescribedById:f,draggableNodes:h,over:p}=l.useContext(ht),{role:g=cn,roleDescription:m="draggable",tabIndex:v=0}=o??{},x=d?.id===t,C=l.useContext(x?An:qs),[R,S]=at(),[D,k]=at(),y=Is(a,t),j=Ye(n);ie(()=>(h.set(t,{id:t,key:i,node:R,activatorNode:D,data:j}),()=>{const M=h.get(t);M&&M.key===i&&h.delete(t)}),[h,t]);const b=l.useMemo(()=>({role:g,tabIndex:v,"aria-disabled":r,"aria-pressed":x&&g===cn?!0:void 0,"aria-roledescription":m,"aria-describedby":f.draggable}),[r,g,v,x,m,f.draggable]);return{active:d,activatorEvent:c,activeNodeRect:u,attributes:b,isDragging:x,listeners:r?void 0:y,node:R,over:p,setNodeRef:S,setActivatorNodeRef:k,transform:C}}function Zs(){return l.useContext(On)}const eo="Droppable",to={timeout:25};function no(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=Ze(eo),{active:a,dispatch:c,over:d,measureDroppableContainers:u}=l.useContext(ht),f=l.useRef({disabled:n}),h=l.useRef(!1),p=l.useRef(null),g=l.useRef(null),{disabled:m,updateMeasurementsFor:v,timeout:x}={...to,...o},C=Ye(v??r),R=l.useCallback(()=>{if(!h.current){h.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{u(Array.isArray(C.current)?C.current:[C.current]),g.current=null},x)},[x]),S=ft({callback:R,disabled:m||!a}),D=l.useCallback((b,M)=>{S&&(M&&(S.unobserve(M),h.current=!1),b&&S.observe(b))},[S]),[k,y]=at(D),j=Ye(t);return l.useEffect(()=>{!S||!k.current||(S.disconnect(),h.current=!1,S.observe(k.current))},[k,S]),l.useEffect(()=>(c({type:I.RegisterDroppable,element:{id:r,key:i,disabled:n,node:k,rect:p,data:j}}),()=>c({type:I.UnregisterDroppable,key:i,id:r})),[r]),l.useEffect(()=>{n!==f.current.disabled&&(c({type:I.SetDroppableDisabled,id:r,key:i,disabled:n}),f.current.disabled=n)},[r,i,n,c]),{active:a,rect:p,isOver:d?.id===r,node:k,over:d,setNodeRef:y}}function Ln(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function ro(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function ot(e){return e!==null&&e>=0}function so(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function oo(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const In=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=Ln(t,r,n),a=t[o],c=i[o];return!c||!a?null:{x:c.left-a.left,y:c.top-a.top,scaleX:c.width/a.width,scaleY:c.height/a.height}},Pn="Sortable",$n=K.createContext({activeIndex:-1,containerId:Pn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:In,disabled:{draggable:!1,droppable:!1}});function io(e){let{children:t,id:n,items:r,strategy:o=In,disabled:i=!1}=e;const{active:a,dragOverlay:c,droppableRects:d,over:u,measureDroppableContainers:f}=Zs(),h=Ze(Pn,n),p=c.rect!==null,g=l.useMemo(()=>r.map(y=>typeof y=="object"&&"id"in y?y.id:y),[r]),m=a!=null,v=a?g.indexOf(a.id):-1,x=u?g.indexOf(u.id):-1,C=l.useRef(g),R=!so(g,C.current),S=x!==-1&&v===-1||R,D=oo(i);ie(()=>{R&&m&&f(g)},[R,g,m,f]),l.useEffect(()=>{C.current=g},[g]);const k=l.useMemo(()=>({activeIndex:v,containerId:h,disabled:D,disableTransforms:S,items:g,overIndex:x,useDragOverlay:p,sortedRects:ro(g,d),strategy:o}),[v,h,D.draggable,D.droppable,S,g,x,d,p,o]);return K.createElement($n.Provider,{value:k},t)}const ao=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Ln(n,r,o).indexOf(t)},lo=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:a,previousItems:c,previousContainerId:d,transition:u}=e;return!u||!r||c!==i&&o===a?!1:n?!0:a!==o&&t===d},co={duration:200,easing:"ease"},Fn="transform",uo=Ve.Transition.toString({property:Fn,duration:0,easing:"linear"}),fo={roleDescription:"sortable"};function ho(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,a]=l.useState(null),c=l.useRef(n);return ie(()=>{if(!t&&n!==c.current&&r.current){const d=o.current;if(d){const u=$e(r.current,{ignoreTransform:!0}),f={x:d.left-u.left,y:d.top-u.top,scaleX:d.width/u.width,scaleY:d.height/u.height};(f.x||f.y)&&a(f)}}n!==c.current&&(c.current=n)},[t,n,r,o]),l.useEffect(()=>{i&&a(null)},[i]),i}function go(e){let{animateLayoutChanges:t=lo,attributes:n,disabled:r,data:o,getNewIndex:i=ao,id:a,strategy:c,resizeObserverConfig:d,transition:u=co}=e;const{items:f,containerId:h,activeIndex:p,disabled:g,disableTransforms:m,sortedRects:v,overIndex:x,useDragOverlay:C,strategy:R}=l.useContext($n),S=po(r,g),D=f.indexOf(a),k=l.useMemo(()=>({sortable:{containerId:h,index:D,items:f},...o}),[h,o,D,f]),y=l.useMemo(()=>f.slice(f.indexOf(a)),[f,a]),{rect:j,node:b,isOver:M,setNodeRef:O}=no({id:a,data:k,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:y,...d}}),{active:E,activatorEvent:_,activeNodeRect:G,attributes:z,setNodeRef:fe,listeners:ae,isDragging:P,over:je,setActivatorNodeRef:X,transform:ne}=Qs({id:a,data:k,attributes:{...fo,...n},disabled:S.draggable}),Z=Ir(O,fe),B=!!E,w=B&&!m&&ot(p)&&ot(x),L=!C&&P,A=L&&w?ne:null,et=w?A??(c??R)({rects:v,activeNodeRect:G,activeIndex:p,overIndex:x,index:D}):null,he=ot(p)&&ot(x)?i({id:a,items:f,activeIndex:p,overIndex:x}):D,le=E?.id,T=l.useRef({activeId:le,items:f,newIndex:he,containerId:h}),Fe=f!==T.current.items,re=t({active:E,containerId:h,isDragging:P,isSorting:B,id:a,index:D,items:f,newIndex:T.current.newIndex,previousItems:T.current.items,previousContainerId:T.current.containerId,transition:u,wasDragging:T.current.activeId!=null}),De=ho({disabled:!re,index:D,node:b,rect:j});return l.useEffect(()=>{B&&T.current.newIndex!==he&&(T.current.newIndex=he),h!==T.current.containerId&&(T.current.containerId=h),f!==T.current.items&&(T.current.items=f)},[B,he,h,f]),l.useEffect(()=>{if(le===T.current.activeId)return;if(le!=null&&T.current.activeId==null){T.current.activeId=le;return}const ke=setTimeout(()=>{T.current.activeId=le},50);return()=>clearTimeout(ke)},[le]),{active:E,activeIndex:p,attributes:z,data:k,rect:j,index:D,newIndex:he,items:f,isOver:M,isSorting:B,isDragging:P,listeners:ae,node:b,overIndex:x,over:je,setNodeRef:Z,setActivatorNodeRef:X,setDroppableNodeRef:O,setDraggableNodeRef:fe,transform:De??et,transition:ce()};function ce(){if(De||Fe&&T.current.newIndex===D)return uo;if(!(L&&!Lt(_)||!u)&&(B||re))return Ve.Transition.toString({...u,property:Fn})}}function po(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}N.Down,N.Right,N.Up,N.Left;const Ge=["trigger","vector","repo-all","data-safety","config","model","crew","cache-hits","time-saved","rag-health","legend"],zn="mega-compact-card-order";function mo(e){if(!Array.isArray(e)||e.length!==Ge.length)return!1;const t=new Set(Ge),n=new Set;for(const r of e){if(typeof r!="string"||!t.has(r)||n.has(r))return!1;n.add(r)}return!0}function vo(){try{const e=window.localStorage.getItem(zn);if(e==null)return Ge;const t=JSON.parse(e);return mo(t)?t:Ge}catch{return Ge}}function xo(){const[e,t]=l.useState(vo),n=l.useCallback((r,o)=>{t(i=>{const a=i.indexOf(r),c=i.indexOf(o);if(a===-1||c===-1||a===c)return i;const d=[...i];d.splice(a,1),d.splice(c,0,r);try{window.localStorage.setItem(zn,JSON.stringify(d))}catch{}return d})},[]);return{order:e,moveCard:n}}function ee({id:e,children:t,onClick:n}){const{attributes:r,listeners:o,setNodeRef:i,transform:a,transition:c,isDragging:d}=go({id:e}),u={transform:Ve.Transform.toString(a),transition:c,opacity:d?.5:1,zIndex:d?10:void 0},f=h=>{n&&(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),n())};return s.jsxs("div",{ref:i,style:u,className:"relative",children:[s.jsx("button",{type:"button","aria-label":`Reorder ${e} card`,className:"absolute right-2 top-2 z-10 cursor-grab rounded p-1 text-muted-foreground/50 hover:bg-foreground/5 hover:text-muted-foreground active:cursor-grabbing",...r,...o,children:s.jsx(ir,{size:16})}),n?s.jsx("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:f,className:"cursor-pointer rounded-lg outline-none transition-all duration-200 hover:ring-1 hover:ring-primary/60 focus-visible:ring-1 focus-visible:ring-primary/60",children:t}):s.jsx("div",{children:t})]})}function bo(e){return e.type==="session_sample"}function yo(e){switch(e){case"cache":return"cache_hit_pct";case"vector":return"turn_latency_ms";case"time":return"disk_write_ms";default:return null}}function wo(e){if(!e)return"never";try{return new Date(e).toLocaleString()}catch{return e}}function Eo({snapshot:e,loading:t,error:n}){const{data:r,error:o,loading:i,refetch:a}=un(l.useCallback(()=>Vn(),[]),{pollInterval:2e3}),{events:c}=Zn(),d=l.useMemo(()=>c.filter(bo),[c]),u=l.useMemo(()=>d.length===0?null:d[d.length-1].ts,[d]);l.useEffect(()=>{u!=null&&a()},[u,a]);const[f,h]=l.useState(null),[p,g]=l.useState([]),[m,v]=l.useState(!1),[x,C]=l.useState(null);l.useEffect(()=>{g([]),C(null);const w=f?yo(f):null;if(w===null){v(!1);return}let L=!1;return v(!0),qn(w,60).then(A=>{L||g(A.samples.map(H=>({ts:H.ts,value:H.value})))}).catch(A=>{L||C(A instanceof Error?A:new Error(String(A)))}).finally(()=>{L||v(!1)}),()=>{L=!0}},[f]);const{order:R,moveCard:S}=xo(),D=l.useCallback(w=>{const{active:L,over:A}=w;A&&L.id!==A.id&&S(L.id,A.id)},[S]),k=l.useMemo(()=>{const w=e,L=w?.compression,A=w?.model;return[{label:"Tokens freed",value:L?.repo.tokensFreed??0},{label:"Input rate",value:A?A.inputRate:0},{label:"Output rate",value:A?A.outputRate:0}]},[e]);if(t&&!e)return s.jsx("div",{className:"tab-stub",children:"Loading snapshot…"});if(n&&!e)return s.jsxs("div",{className:"tab-stub",children:[s.jsxs("p",{children:["Error loading snapshot: ",n.message]}),s.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Auto-retried with backoff and will re-poll every 5s — no action needed."})]});if(!e)return s.jsx("div",{className:"tab-stub",children:"No snapshot data."});const y=e,{context:j,compression:b,trigger:M,session:O,store:E,tier:_,updatedAt:G}=y,z=y.config,fe=y.crew,ae=y.integrity,P=y.cacheHits,je=y.compacts,X=y.timeSaved,ne=y.repo,Z=y.model,B=w=>{switch(w){case"trigger":return s.jsx(ee,{id:w,onClick:()=>h("cache"),children:s.jsx(xr,{armed:M.armed,ready:M.ready,currentTokens:M.currentTokens,thresholdTokens:M.thresholdTokens,fastGatePct:M.fastGatePct})});case"vector":return s.jsx(ee,{id:w,onClick:()=>h("vector"),children:s.jsx(yr,{checkpointCount:E.checkpointCount,tokensIn:b.session.tokensIn,tokensOut:b.session.tokensOut,tokensFreed:b.session.tokensFreed,injectedCount:E.injectedCount,dedupHitRate:E.dedupHitRate,storageDedupRate:E.storageDedupRate,dedupCollapsed:E.dedupCollapsed,lastCheckpointId:O.lastCheckpointId,compressionPct:b.session.compressionPct,dedupPct:b.session.dedupPct})});case"repo-all":return s.jsx(ee,{id:w,children:s.jsx(jr,{checkpointCount:ne.checkpointCount,tokensIn:b.repo.tokensIn,tokensOut:b.repo.tokensOut,tokensFreed:b.repo.tokensFreed,sessionCount:ne.sessionCount,dedupCollapsed:ne.dedupCollapsed,storageDedupRate:ne.storageDedupRate,compressionPct:b.repo.compressionPct,dedupPct:b.repo.dedupPct})});case"data-safety":return s.jsx(ee,{id:w,children:s.jsx(Sr,{regionsRetained:ae.regionsRetained,compressedOriginalBytes:ae.compressedOriginalBytes,duplicatesCollapsed:ae.duplicatesCollapsed,bytesPermanentlyDeleted:ae.bytesPermanentlyDeleted})});case"config":return s.jsx(ee,{id:w,children:s.jsx(Cr,{tier:_,presetTier:y.presetTier,pressure:y.pressure,thresholdTokens:z.thresholdTokens,tierPct:z.tierPct,contextWindow:j.contextWindow,fastGatePct:z.fastGatePct,auto:z.auto,anchorUserMessages:z.anchorUserMessages})});case"model":return Z?s.jsx(ee,{id:w,onClick:()=>h("model"),children:s.jsx(Rr,{name:Z.name,provider:Z.providerName||Z.provider,inputRate:Z.inputRate,outputRate:Z.outputRate,repoTokensFreed:b.repo.tokensFreed,contextWindow:j.contextWindow})}):null;case"crew":return s.jsx(ee,{id:w,children:s.jsx(Dr,{activeAgents:fe.activeAgents,currentTurn:fe.currentTurn})});case"cache-hits":return s.jsx(ee,{id:w,onClick:()=>h("cache"),children:s.jsx(tr,{cacheHitsSession:P.session,cacheHitsTotal:P.total,tokensSavedSession:P.sessionTokensSaved,tokensSavedTotal:P.totalTokensSaved,compactionsSession:je.session,compactionsTotal:je.total})});case"time-saved":return s.jsx(ee,{id:w,onClick:()=>h("time"),children:s.jsx(er,{compactSessionSec:X.compact.sessionSec,compactTotalSec:X.compact.totalSec,cacheHitSessionSec:X.cacheHit.sessionSec,cacheHitTotalSec:X.cacheHit.totalSec})});case"rag-health":return Qn()?s.jsx(ee,{id:w,children:s.jsx(Er,{})}):null;case"legend":return s.jsx(ee,{id:w,children:s.jsx(Nr,{})})}};return s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Jn,{variant:"accent",children:_}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:["updated ",wo(G)]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[s.jsx(vr,{sessions:r,loading:i,error:o,launcherSessionId:O.id,launcher:{tokens:j.tokens,percent:j.percent,contextWindow:j.contextWindow}}),s.jsx(fr,{sessions:r,loading:i,error:o})]}),s.jsx(Vs,{onDragEnd:D,children:s.jsx(io,{items:R,children:s.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",children:R.map(w=>({cardId:w,node:B(w)})).filter(({node:w})=>w!=null).map(({cardId:w,node:L})=>s.jsx("div",{children:L},w))})})}),s.jsx(st,{title:"Cache Hits Trend",open:f==="cache",onClose:()=>h(null),children:m?s.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"Loading…"}):x?s.jsx("p",{className:"py-8 text-center text-sm text-red-400",children:x.message}):s.jsx(yt,{data:p,label:"Cache hit %",color:"#58a6ff"})}),s.jsx(st,{title:"Turn Latency",open:f==="vector",onClose:()=>h(null),children:m?s.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"Loading…"}):x?s.jsx("p",{className:"py-8 text-center text-sm text-red-400",children:x.message}):s.jsx(yt,{data:p,label:"Turn latency (ms)",color:"#58a6ff"})}),s.jsx(st,{title:"Disk Write Time",open:f==="time",onClose:()=>h(null),children:m?s.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"Loading…"}):x?s.jsx("p",{className:"py-8 text-center text-sm text-red-400",children:x.message}):s.jsx(yt,{data:p,label:"Disk write (ms)",color:"#58a6ff"})}),s.jsx(st,{title:"Model & Cost",open:f==="model",onClose:()=>h(null),children:s.jsx(Lr,{data:k,color:"#3fb950",valueFormatter:w=>w.toLocaleString()})})]})}export{Eo as default};
16
- //# sourceMappingURL=OverviewTab-CouEq0qi.js.map