memhouse 0.20.0 → 0.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/bin/memhouse.js +209 -30
  3. package/docs/guides/install.md +3 -0
  4. package/docs/guides/invite.md +7 -0
  5. package/docs/guides/search-and-resume.md +30 -0
  6. package/docs/guides/share.md +5 -0
  7. package/docs/releases/README.md +2 -0
  8. package/docs/releases/v0.20.1.md +114 -0
  9. package/docs/releases/v0.20.2.md +134 -0
  10. package/memhouse/codex-plugin.js +194 -0
  11. package/memhouse/delivery/INVITATION.md.tpl +1 -1
  12. package/memhouse/delivery/codex/AGENTS-BLOCK.md +11 -0
  13. package/memhouse/delivery/codex/SKILL.md +50 -0
  14. package/memhouse/delivery/plugin/reference/HOUSE.md +7 -9
  15. package/memhouse/delivery/plugin/skills/access/SKILL.md +1 -1
  16. package/memhouse/flags.js +1 -1
  17. package/memhouse/help.js +37 -0
  18. package/memhouse/house/q-cli.js +14 -1
  19. package/memhouse/house/records-to-profile.js +14 -3
  20. package/memhouse/house/schema-choice.js +15 -6
  21. package/memhouse/house/schema-profile-views.sql.tpl +53 -0
  22. package/memhouse/house/schema-profile.js +46 -6
  23. package/memhouse/house/schema-profile.sql.tpl +8 -1
  24. package/memhouse/invitation.js +8 -2
  25. package/memhouse/plugin-copies.js +13 -1
  26. package/memhouse/release-hint.js +24 -0
  27. package/memhouse/share.js +36 -4
  28. package/memhouse/shipper/capture.js +39 -9
  29. package/memhouse/shipper/log-adapter.js +18 -7
  30. package/memhouse/shipper/normalise-run.js +8 -2
  31. package/memhouse/version-notice.js +66 -0
  32. package/package.json +3 -3
  33. package/public/assets/{index-CQSJ3nhV.js → index-CcNnhfM3.js} +1 -1
  34. package/public/index.html +1 -1
  35. package/ui/package-lock.json +264 -318
  36. package/ui/package.json +5 -4
  37. package/ui/src/lib/dashboard-token.js +7 -2
@@ -14,7 +14,9 @@
14
14
  // A line longer than the read cap is read whole: a read always makes progress
15
15
  // derive the log's records as sessions-model records, the last line of a key winning:
16
16
  // session title, cwd, version, created, updated, archived, mode, kind, engine, client; its
17
- // `links` (stated on the child) as link records
17
+ // `links` (stated on the child) as link records; its `children` (a child no message
18
+ // names, Cursor's sub-agents) as links stated on the origin, one per child: a `child`
19
+ // record for the same child that says where it was found is the one kept
18
20
  // message order_key the native `order`, then the line's offset; ts the source's or null; a
19
21
  // `tool` part as a tool_call part and, once it has an output or an error, a
20
22
  // tool_result part; `file` as an attachment, `error` and `notice` as theirs; its
@@ -31,7 +33,7 @@ const path = require('path');
31
33
  const slog = require('../../editors/sessions-log');
32
34
 
33
35
  const ADAPTER = 'memhouse-bridge';
34
- const ADAPTER_VER = '1.0.1';
36
+ const ADAPTER_VER = '1.0.2';
35
37
  const STATE_VER = 1;
36
38
  const MAX_READ_BYTES = 64 * 1024 * 1024;
37
39
  const UNFLAGGED = { 'gemini-cli': { input_includes_cache: true, output_includes_reasoning: false } };
@@ -70,6 +72,12 @@ function usageRecord(id, anchor, u, harness, model) {
70
72
  reasoning: num(u.reasoning), cost: num(u.cost), input_includes_cache: iic, output_includes_reasoning: oir, granularity: 'per_message', model: String(model || '') };
71
73
  }
72
74
 
75
+ /** A child the session started, as a link stated on the origin: a `child` record, or one of the session record's `children`. */
76
+ function originLink(c, harness) {
77
+ return { type: 'link', kind: String(c.kind || ''), stated_on: 'origin', origin: {}, child: { harness, session_id: String(c.session_id || '') },
78
+ at: String(c.at || ''), evidence: c.evidence === 'inferred' ? 'inferred' : 'explicit' };
79
+ }
80
+
73
81
  /** One log line (its offset `at`) as sessions-model records. */
74
82
  function recordsOf(o, at, harness) {
75
83
  if (!o || typeof o !== 'object') return [];
@@ -80,16 +88,14 @@ function recordsOf(o, at, harness) {
80
88
  const links = (Array.isArray(o.links) ? o.links : []).map((l) => ({ type: 'link', kind: String(l.kind || ''), stated_on: 'child', child: {},
81
89
  origin: { harness, session_id: String(l.origin || ''), ...(l.origin_store ? { harness_path: String(l.origin_store) } : {}) }, at: String(l.at || ''),
82
90
  inherits: l.through ? { through_message_id: String(l.through) } : {}, evidence: l.evidence === 'inferred' ? 'inferred' : 'explicit' }));
83
- return [s, ...links];
91
+ const children = (Array.isArray(o.children) ? o.children : []).map((c) => originLink(c, harness));
92
+ return [s, ...links, ...children];
84
93
  }
85
94
  if (o.k === 'usage') {
86
95
  if (!o.usage) return [];
87
96
  return [usageRecord(o.usage_id != null && o.usage_id !== '' ? `usage:${o.usage_id}` : `usage:@${at}`, {}, o.usage, harness, o.model)];
88
97
  }
89
- if (o.k === 'child') {
90
- return [{ type: 'link', kind: String(o.kind || ''), stated_on: 'origin', origin: {}, child: { harness, session_id: String(o.session_id || '') },
91
- at: String(o.at || ''), evidence: o.evidence === 'inferred' ? 'inferred' : 'explicit' }];
92
- }
98
+ if (o.k === 'child') return [originLink(o, harness)];
93
99
  if (o.k !== 'message' || o.message_id == null) return [];
94
100
  const id = String(o.message_id);
95
101
  const parts = [];
@@ -204,6 +210,11 @@ function logAdapter(home, harness, { maxReadBytes = MAX_READ_BYTES } = {}) {
204
210
  for (const at of Object.keys(st.lines).sort((a, b) => Number(a) - Number(b))) {
205
211
  for (const r of recordsOf(st.lines[at], Number(at), harness)) byKey.set(`${r.type}\u0000${keyOf(r)}`, r);
206
212
  }
213
+ // One link per child: a link with no `at` (a session record's child) gives way to one of the
214
+ // same kind and child that says where it was found (a `child` record).
215
+ const placed = new Set();
216
+ for (const r of byKey.values()) if (r.type === 'link' && r.stated_on === 'origin' && r.at) placed.add(canon([r.kind, r.child]));
217
+ for (const [k, r] of byKey) if (r.type === 'link' && r.stated_on === 'origin' && !r.at && placed.has(canon([r.kind, r.child]))) byKey.delete(k);
207
218
  const changed = []; const live = {}; const emitted = {};
208
219
  for (const [k, r] of byKey) {
209
220
  const j = JSON.stringify(r);
@@ -56,10 +56,16 @@ const RETRY_MS = 5 * 60 * 1000;
56
56
  const BUDGET_MS = 30 * 1000;
57
57
  const keyOf = (s, inc = '') => `${s.harness}\t${s.harness_path}\t${s.session_id}\t${inc}`;
58
58
 
59
- /** Messages in an existing log (0 when there is none). */
59
+ /**
60
+ * Messages in an existing log (0 when there is none). A log that is there but cannot be read throws:
61
+ * counted as 0, it would disarm the refusal to rewrite a log of messages into none.
62
+ */
60
63
  function messagesIn(file) {
61
64
  let s;
62
- try { s = fs.readFileSync(file, 'utf-8'); } catch { return 0; }
65
+ try { s = fs.readFileSync(file, 'utf-8'); } catch (e) {
66
+ if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return 0;
67
+ throw new Error(`cannot read the existing log (${(e && e.code) || 'error'}): ${path.basename(file)}`);
68
+ }
63
69
  let n = 0;
64
70
  for (const l of s.split('\n')) if (l.startsWith('{"k":"message"') || /"k"\s*:\s*"message"/.test(l.slice(0, 200))) n++;
65
71
  return n;
@@ -0,0 +1,66 @@
1
+ // A new minor (or major) version's first run says so, once, and points at its release notes.
2
+ //
3
+ // `npm install -g memhouse` never runs `update`, so nothing told a machine that crossed a minor
4
+ // version (0.20 is a different house layout from 0.18) what had changed or what to do. A stamp in
5
+ // the home records the last version that ran here; when the line (major.minor) is newer, the
6
+ // first CLI call prints one notice to stderr (so --json stays clean) and moves the stamp. A patch
7
+ // release and a downgrade move the stamp silently.
8
+ //
9
+ // Versions before this notice wrote no stamp, so with none the previous version is inferred:
10
+ // skills-checked the version 0.20.0's /mem skills refresh recorded (memhouse/plugin-copies.js);
11
+ // read before that refresh moves it, so this runs first
12
+ // the env file MEMHOUSE_SCHEMA=3 means a 0.20 install; any other install ran 0.18 or earlier
13
+ // neither a fresh install: stamped silently, there is nothing to compare with
14
+
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+
18
+ const STAMP = 'version-seen';
19
+ const SKILLS_STAMP = 'skills-checked';
20
+ const lineOf = (v) => { const m = /^(\d+)\.(\d+)/.exec(String(v || '')); return m ? `${m[1]}.${m[2]}` : null; };
21
+ const lineNum = (l) => l.split('.').map(Number);
22
+
23
+ /**
24
+ * The notice for going from `seen` to `version`, or null: only for a newer major.minor. `seenLabel`
25
+ * is how the previous version is named when it was inferred ("0.18 or earlier"). Pure.
26
+ */
27
+ function noticeFor({ seen, version, notesPath = null, seenLabel = null }) {
28
+ const a = lineOf(seen); const b = lineOf(version);
29
+ if (!a || !b || a === b || seen === version) return null;
30
+ const [am, an] = lineNum(a); const [bm, bn] = lineNum(b);
31
+ if (bm < am || (bm === am && bn < an)) return null; // a downgrade is not news about a release
32
+ return `memhouse ${version} is new on this machine (it ran ${seenLabel || seen} before). What changed and what to do: ${notesPath || `docs/releases/v${version}.md`}`;
33
+ }
34
+
35
+ /** The version that ran here before, when no stamp says it: { seen, label } or null (fresh). */
36
+ function inferPrevious(home) {
37
+ try { const v = fs.readFileSync(path.join(home, SKILLS_STAMP), 'utf-8').trim(); if (lineOf(v)) return { seen: v, label: null }; } catch { /* none */ }
38
+ let env;
39
+ try { env = fs.readFileSync(path.join(home, 'env'), 'utf-8'); } catch { return null; }
40
+ if (/^MEMHOUSE_SCHEMA=['"]?3['"]?\s*$/m.test(env)) return { seen: '0.20.0', label: '0.20' };
41
+ return { seen: '0.18.0', label: '0.18 or earlier' };
42
+ }
43
+
44
+ /**
45
+ * Check, print once, and stamp. `home` is the memhouse home; nothing happens when it does not
46
+ * exist (no install here) or from a git checkout. Never throws.
47
+ */
48
+ function checkVersionNotice({ home, version, repoRoot, log = () => {} }) {
49
+ try {
50
+ if (!home || !fs.existsSync(home)) return null;
51
+ // From a git checkout, nothing: a development run must not stamp a real home with its version.
52
+ if (repoRoot && fs.existsSync(path.join(repoRoot, '.git'))) return null;
53
+ const stamp = path.join(home, STAMP);
54
+ let prev = null;
55
+ try { const v = fs.readFileSync(stamp, 'utf-8').trim(); if (v) prev = { seen: v, label: null }; } catch { /* none yet */ }
56
+ if (!prev) prev = inferPrevious(home);
57
+ if (prev && prev.seen === version) return null;
58
+ const notes = repoRoot ? path.join(repoRoot, 'docs', 'releases', `v${String(version).split('-')[0]}.md`) : null;
59
+ const msg = prev ? noticeFor({ seen: prev.seen, version, seenLabel: prev.label, notesPath: notes && fs.existsSync(notes) ? notes : null }) : null;
60
+ if (msg) log(msg);
61
+ try { fs.writeFileSync(stamp, `${version}\n`); } catch { /* not writable: asked again next run */ }
62
+ return msg;
63
+ } catch { return null; }
64
+ }
65
+
66
+ module.exports = { STAMP, SKILLS_STAMP, lineOf, noticeFor, inferPrevious, checkVersionNotice };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memhouse",
3
- "version": "0.20.0",
3
+ "version": "0.20.2",
4
4
  "description": "memhouse — agent conversation memory across 17 editors: parse-on-client shippers, a typed ClickHouse store with one set of rooms per member, and the agentlytics dashboard",
5
5
  "main": "bin/memhouse.js",
6
6
  "bin": {
@@ -40,7 +40,7 @@
40
40
  "start": "node bin/memhouse.js",
41
41
  "build": "cd ui && npm install && npm run build",
42
42
  "dev": "cd ui && npm run dev",
43
- "test": "node misc/syntax-check.js && node misc/unit-test.js && node misc/v3-read-unit.js && node misc/v3-cli-unit.js && node misc/capture-test.js && node misc/dedupe-test.js && node misc/dedupe-profile-test.js && node misc/profile-edges-test.js && node misc/profile-routing-test.js && node misc/log-adapter-test.js && node misc/bridge-test.js && node misc/layout32-test.js && node misc/v4-opencode-test.js && node misc/normalise/run-all.js && node misc/maintenance-test.js && node misc/no-credentials-test.js && node misc/kav-test.js && node misc/publish-guard-test.js && node misc/records-to-rows-test.js && node misc/adapter-capture-test.js && node misc/import-claude-ai-test.js && node misc/records-to-profile-test.js && node misc/profile-capture-twin-test.js && node misc/profile-vanished-test.js && node misc/env-guard-test.js && node misc/skill-allowlist-test.js && node misc/plugin-copies-test.js && node misc/host-alias-test.js && node misc/registry-test.js && node misc/doctor-tail-test.js && node misc/dashboard-auth-test.js",
43
+ "test": "node misc/syntax-check.js && node misc/unit-test.js && node misc/v3-read-unit.js && node misc/v3-cli-unit.js && node misc/capture-test.js && node misc/dedupe-test.js && node misc/dedupe-profile-test.js && node misc/profile-edges-test.js && node misc/profile-routing-test.js && node misc/log-adapter-test.js && node misc/bridge-test.js && node misc/layout32-test.js && node misc/v4-opencode-test.js && node misc/normalise/run-all.js && node misc/maintenance-test.js && node misc/no-credentials-test.js && node misc/kav-test.js && node misc/publish-guard-test.js && node misc/records-to-rows-test.js && node misc/adapter-capture-test.js && node misc/import-claude-ai-test.js && node misc/records-to-profile-test.js && node misc/profile-capture-twin-test.js && node misc/profile-vanished-test.js && node misc/env-guard-test.js && node misc/skill-allowlist-test.js && node misc/plugin-copies-test.js && node misc/codex-plugin-test.js && node misc/host-alias-test.js && node misc/registry-test.js && node misc/doctor-tail-test.js && node misc/dashboard-auth-test.js",
44
44
  "test:house": "node misc/house-test.js",
45
45
  "prepack": "cd ui && npm install --no-audit --no-fund && npm run build",
46
46
  "prepublishOnly": "node misc/publish-guard.js"
@@ -66,7 +66,7 @@
66
66
  "email": "security@memhouse.io"
67
67
  },
68
68
  "dependencies": {
69
- "@agent-realm/harness-session-adapters": "1.0.0",
69
+ "@agent-realm/harness-session-adapters": "1.1.0",
70
70
  "@clickhouse/client": "^1.23.1",
71
71
  "express": "^4.22.1"
72
72
  }
@@ -75,4 +75,4 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
75
75
  `]},t)})})}function nD(e){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!t)return{frontmatter:null,body:e};let n=[],r=t[1].split(`
76
76
  `);for(let e=0;e<r.length;e++){let t=r[e].match(/^(\w[\w-]*):\s*(.*)/);if(t){let i=t[1],a=t[2].replace(/^["']|["']$/g,``).trim();if(a)n.push([i,a]);else{let t=[];for(;e+1<r.length&&/^\s+-\s/.test(r[e+1]);){e++;let n=r[e].replace(/^\s+-\s*/,``),i=n.match(/^\[([ xX])\]\s*(.*)/);if(i)t.push({type:`checkbox`,checked:i[1]!==` `,text:i[2]});else{let i=n.match(/^(\w[\w-]*):\s*(.*)/);if(i){let n={[i[1]]:i[2].replace(/^["']|["']$/g,``)};for(;e+1<r.length&&/^\s{4,}\w/.test(r[e+1])&&!/^\s+-/.test(r[e+1]);){e++;let t=r[e].trim().match(/^(\w[\w-]*):\s*(.*)/);t&&(n[t[1]]=t[2].replace(/^["']|["']$/g,``))}t.push({type:`object`,data:n})}else t.push({type:`text`,text:n})}}n.push([i,t.length?t:``])}}}return{frontmatter:n.length?n:null,body:t[2]}}var rD={completed:{bg:`rgba(34,197,94,0.12)`,color:`#22c55e`,icon:`✓`},in_progress:{bg:`rgba(99,102,241,0.12)`,color:`#818cf8`,icon:`◐`},pending:{bg:`rgba(250,204,21,0.12)`,color:`#facc15`,icon:`○`},blocked:{bg:`rgba(239,68,68,0.12)`,color:`#ef4444`,icon:`✕`}};function iD({val:e}){return typeof e==`string`?(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:e}):Array.isArray(e)?e.some(e=>e.type===`object`)?(0,F.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4,width:`100%`},children:e.map((e,t)=>{if(e.type!==`object`)return(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:e.text||``},t);let n=e.data,r=(n.status||``).toLowerCase().replace(/\s+/g,`_`),i=rD[r]||rD.pending,a=r===`completed`;return(0,F.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`3px 0`},children:[(0,F.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:16,height:16,borderRadius:3,flexShrink:0,background:i.bg,color:i.color,fontSize:10,fontWeight:700},children:i.icon}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`,opacity:a?.55:1,textDecoration:a?`line-through`:`none`,flex:1},children:n.content||n.title||n.name||n.id||JSON.stringify(n)}),n.status&&(0,F.jsx)(`span`,{style:{fontSize:10,padding:`1px 6px`,borderRadius:3,background:i.bg,color:i.color,flexShrink:0},children:n.status})]},t)})}):(0,F.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:e.map((e,t)=>(0,F.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,color:`var(--c-text2)`,cursor:`default`},children:[e.type===`checkbox`?(0,F.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:14,height:14,borderRadius:3,flexShrink:0,border:e.checked?`none`:`1.5px solid var(--c-text3)`,background:e.checked?`#6366f1`:`transparent`,color:`#fff`,fontSize:10,lineHeight:1},children:e.checked?`✓`:``}):(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`•`}),(0,F.jsx)(`span`,{style:{textDecoration:e.checked?`line-through`:`none`,opacity:e.checked?.5:1},children:e.text})]},t))}):null}function aD({content:e}){let{frontmatter:t,body:n}=nD(e);return(0,F.jsxs)(`div`,{className:`artifact-markdown`,style:{color:`var(--c-text)`,fontSize:14,lineHeight:1.7,maxWidth:720,margin:`0 auto`},children:[t&&(0,F.jsx)(`div`,{style:{background:`var(--c-bg)`,border:`1px solid var(--c-border)`,borderRadius:6,padding:`10px 14px`,marginBottom:16,fontSize:12,fontFamily:JE},children:t.map(([e,t],n)=>(0,F.jsxs)(`div`,{style:{display:`flex`,gap:8,padding:`3px 0`,alignItems:Array.isArray(t)?`flex-start`:`center`},children:[(0,F.jsx)(`span`,{style:{color:`#818cf8`,minWidth:100,flexShrink:0,paddingTop:Array.isArray(t)?1:0},children:e}),(0,F.jsx)(iD,{val:t})]},n))}),(0,F.jsx)(MS,{remarkPlugins:[IT],components:{h1:({children:e})=>(0,F.jsx)(`h1`,{style:{fontSize:22,fontWeight:700,margin:`0 0 12px 0`,paddingBottom:8,borderBottom:`1px solid var(--c-border)`,color:`var(--c-white)`},children:e}),h2:({children:e})=>(0,F.jsx)(`h2`,{style:{fontSize:18,fontWeight:600,margin:`20px 0 8px 0`,paddingBottom:6,borderBottom:`1px solid var(--c-border)`,color:`var(--c-white)`},children:e}),h3:({children:e})=>(0,F.jsx)(`h3`,{style:{fontSize:15,fontWeight:600,margin:`16px 0 6px 0`,color:`var(--c-white)`},children:e}),h4:({children:e})=>(0,F.jsx)(`h4`,{style:{fontSize:14,fontWeight:600,margin:`12px 0 4px 0`,color:`var(--c-white)`},children:e}),p:({children:e})=>(0,F.jsx)(`p`,{style:{margin:`0 0 10px 0`},children:e}),ul:({children:e})=>(0,F.jsx)(`ul`,{style:{margin:`0 0 10px 0`,paddingLeft:24,listStyleType:`disc`},children:e}),ol:({children:e})=>(0,F.jsx)(`ol`,{style:{margin:`0 0 10px 0`,paddingLeft:24,listStyleType:`decimal`},children:e}),li:({children:e,className:t})=>{let n=t===`task-list-item`;return(0,F.jsx)(`li`,{style:{margin:`2px 0`,listStyleType:n?`none`:void 0,marginLeft:n?-20:0},children:e})},input:({type:e,checked:t})=>e===`checkbox`?(0,F.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:15,height:15,borderRadius:3,marginRight:6,verticalAlign:-2,flexShrink:0,border:t?`none`:`1.5px solid var(--c-text3)`,background:t?`#6366f1`:`transparent`,color:`#fff`,fontSize:10},children:t?`✓`:``}):null,pre:({children:e})=>(0,F.jsx)(`pre`,{style:{background:`var(--c-bg)`,border:`1px solid var(--c-border)`,borderRadius:6,padding:12,margin:`8px 0 12px 0`,overflow:`auto`,fontFamily:JE,fontSize:12,color:`var(--c-text)`,lineHeight:1.6},children:e}),code:({node:e,children:t})=>e?.position&&e.position.start.line!==e.position.end.line?(0,F.jsx)(`code`,{children:t}):(0,F.jsx)(`code`,{style:{background:`var(--c-bg3)`,padding:`1px 5px`,borderRadius:4,fontFamily:JE,fontSize:12,color:`#818cf8`},children:t}),blockquote:({children:e})=>(0,F.jsx)(`blockquote`,{style:{borderLeft:`3px solid #6366f1`,paddingLeft:12,margin:`8px 0`,color:`var(--c-text2)`,fontStyle:`italic`},children:e}),table:({children:e})=>(0,F.jsx)(`div`,{style:{overflow:`auto`,margin:`8px 0 12px 0`},children:(0,F.jsx)(`table`,{style:{borderCollapse:`collapse`,width:`100%`,fontSize:13},children:e})}),thead:({children:e})=>(0,F.jsx)(`thead`,{style:{borderBottom:`2px solid var(--c-border)`},children:e}),th:({children:e})=>(0,F.jsx)(`th`,{style:{textAlign:`left`,padding:`6px 12px`,fontWeight:600,color:`var(--c-white)`},children:e}),td:({children:e})=>(0,F.jsx)(`td`,{style:{padding:`5px 12px`,borderBottom:`1px solid var(--c-border)`},children:e}),a:({href:e,children:t})=>(0,F.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,style:{color:`#818cf8`,textDecoration:`underline`,textUnderlineOffset:2},children:t}),hr:()=>(0,F.jsx)(`hr`,{style:{border:`none`,borderTop:`1px solid var(--c-border)`,margin:`16px 0`}}),strong:({children:e})=>(0,F.jsx)(`strong`,{style:{color:`var(--c-white)`,fontWeight:600},children:e}),img:({src:e,alt:t})=>(0,F.jsx)(`img`,{src:e,alt:t,style:{maxWidth:`100%`,borderRadius:6,margin:`8px 0`}})},children:n})]})}function oD({content:e,fileName:t,viewRaw:n}){if(n)return(0,F.jsx)(`pre`,{className:`text-[12px] whitespace-pre-wrap break-words leading-relaxed`,style:{color:`var(--c-text)`,fontFamily:JE},children:e});let r=eD(t);return r===`json`?(0,F.jsx)(tD,{content:e}):r===`markdown`?(0,F.jsx)(aD,{content:e}):(0,F.jsx)(`pre`,{className:`text-[12px] whitespace-pre-wrap break-words leading-relaxed`,style:{color:`var(--c-text)`,fontFamily:JE},children:e})}function sD(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)(``),[i,a]=(0,S.useState)(new Set),[o,s]=(0,S.useState)(new Set),[c,l]=(0,S.useState)(null),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(!1),[m,h]=(0,S.useState)(!1);(0,S.useEffect)(()=>{ua().then(e=>{t(e),e&&e.length>0&&(a(new Set([e[0].folder])),e[0].editors.length>0&&s(new Set([e[0].folder+`::`+e[0].editors[0].editor])))})},[]);let g=async e=>{l(e),h(!1),p(!0);try{d(await da(e.path))}catch{d({error:`Failed to load file content`})}p(!1)},_=e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};if(!e)return(0,F.jsx)(ja,{label:`Scanning project artifacts...`});let y=e.filter(e=>{if(!n)return!0;let t=n.toLowerCase();return e.name.toLowerCase().includes(t)||e.folder.toLowerCase().includes(t)?!0:e.editors.some(e=>e.label.toLowerCase().includes(t)||e.files.some(e=>e.name.toLowerCase().includes(t)))}),b=e.reduce((e,t)=>e+t.totalArtifacts,0),x=e.length,C=new Set;for(let t of e)for(let e of t.editors)C.add(e.editor);return(0,F.jsxs)(`div`,{className:`h-full`,children:[(0,F.jsx)(`div`,{className:`px-4 py-3`,style:{borderBottom:`1px solid var(--c-border)`},children:(0,F.jsxs)(sE,{icon:li,title:`Artifacts`,children:[(0,F.jsxs)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:[b,` artifacts · `,x,` projects · `,C.size,` editors`]}),(0,F.jsxs)(`div`,{className:`ml-auto relative`,children:[(0,F.jsx)(hi,{size:12,className:`absolute left-2.5 top-1/2 -translate-y-1/2`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`input`,{type:`text`,placeholder:`Search artifacts...`,value:n,onChange:e=>r(e.target.value),className:`pl-7 pr-3 py-1 text-[12px] outline-none w-[200px]`,style:{background:`var(--c-bg3)`,border:`1px solid var(--c-border)`,color:`var(--c-text)`}})]})]})}),y.length===0?(0,F.jsx)(`div`,{className:`text-sm py-12 text-center`,style:{color:`var(--c-text3)`},children:n?`No artifacts match your search`:`No AI artifacts found in any project folders`}):null,(0,F.jsxs)(`div`,{className:`flex`,style:{height:`calc(100vh - 130px)`},children:[(0,F.jsxs)(`div`,{className:`w-[340px] shrink-0 flex flex-col`,style:{background:`var(--c-card)`,borderRight:`1px solid var(--c-border)`},children:[(0,F.jsx)(`div`,{className:`px-3 py-2 text-[11px] font-semibold uppercase tracking-wider`,style:{color:`var(--c-text3)`,borderBottom:`1px solid var(--c-border)`},children:`Project Tree`}),(0,F.jsx)(`div`,{className:`overflow-y-auto flex-1`,children:y.map(e=>{let t=i.has(e.folder);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{onClick:()=>_(e.folder),className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-[var(--c-bg3)] transition`,style:{borderBottom:`1px solid var(--c-border)`},children:[t?(0,F.jsx)(Or,{size:12,style:{color:`var(--c-text3)`}}):(0,F.jsx)(kr,{size:12,style:{color:`var(--c-text3)`}}),(0,F.jsx)(Jr,{size:13,style:{color:`#6366f1`}}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`text-[12px] font-medium truncate`,style:{color:`var(--c-white)`},children:e.name}),(0,F.jsx)(`div`,{className:`text-[10px] truncate`,style:{color:`var(--c-text3)`,fontFamily:JE},children:e.folder})]}),(0,F.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded`,style:{background:`rgba(99,102,241,0.12)`,color:`#818cf8`},children:e.totalArtifacts})]}),t&&e.editors.map(t=>{let n=e.folder+`::`+t.editor,r=o.has(n);return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{onClick:()=>v(n),className:`w-full flex items-center gap-2 pl-7 pr-3 py-1.5 text-left hover:bg-[var(--c-bg3)] transition`,children:[r?(0,F.jsx)(Or,{size:10,style:{color:`var(--c-text3)`}}):(0,F.jsx)(kr,{size:10,style:{color:`var(--c-text3)`}}),t.editor===`_general`?(0,F.jsx)(Gr,{size:12,style:{color:`var(--c-text2)`}}):(0,F.jsx)($h,{source:t.editor,size:12}),(0,F.jsx)(`span`,{className:`text-[11px] font-medium`,style:{color:t.editor===`_general`?`var(--c-text2)`:Ih(t.editor)},children:t.editor===`_general`?t.label:q(t.editor)}),(0,F.jsx)(`span`,{className:`text-[10px] ml-auto`,style:{color:`var(--c-text3)`},children:t.files.length})]}),r&&t.files.map(e=>(0,F.jsxs)(`button`,{onClick:()=>g(e),className:`w-full flex items-center gap-2 pl-12 pr-3 py-1.5 text-left hover:bg-[var(--c-bg3)] transition`,style:{background:c?.path===e.path?`var(--c-bg3)`:`transparent`,borderLeft:c?.path===e.path?`2px solid #6366f1`:`2px solid transparent`},children:[(0,F.jsx)(Gr,{size:11,style:{color:`var(--c-text3)`}}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`text-[11px] truncate`,style:{color:`var(--c-text)`,fontFamily:JE},children:e.relativePath}),(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[YE(e.size),` · `,e.lines,` lines`]})]})]},e.path))]},n)})]},e.folder)})})]}),(0,F.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,style:{background:`var(--c-card)`},children:c?(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(Gr,{size:14,style:{color:`#6366f1`}}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-[12px] font-medium`,style:{color:`var(--c-white)`,fontFamily:JE},children:c.relativePath}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(`span`,{children:YE(c.size)}),(0,F.jsxs)(`span`,{children:[c.lines,` lines`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(Fr,{size:9}),XE(c.modifiedAt)]})]})]}),u?.content&&(()=>{let e=ZE(u.content);return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] px-2 py-0.5 rounded`,style:{background:`rgba(99,102,241,0.08)`,border:`1px solid rgba(99,102,241,0.15)`,color:`#818cf8`},children:[(0,F.jsx)(Ai,{size:9}),QE(e),` tokens`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] px-2 py-0.5 rounded`,style:{background:`rgba(34,197,94,0.08)`,border:`1px solid rgba(34,197,94,0.15)`,color:`#22c55e`},children:[(0,F.jsx)(Vr,{size:9}),$E(e)]})]})})(),(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] px-2 py-0.5 rounded`,style:{background:`${Ih(c.editor)}15`,color:Ih(c.editor)},children:[c.editor!==`_general`&&(0,F.jsx)($h,{source:c.editor,size:11}),c.editorLabel]}),(0,F.jsxs)(`button`,{onClick:()=>h(e=>!e),className:`flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition`,style:{background:m?`rgba(99,102,241,0.15)`:`var(--c-bg3)`,color:m?`#818cf8`:`var(--c-text2)`,border:`1px solid `+(m?`rgba(99,102,241,0.3)`:`var(--c-border)`)},title:m?`Switch to rendered view`:`Switch to raw view`,children:[m?(0,F.jsx)(Wr,{size:12}):(0,F.jsx)(Ir,{size:12}),m?`Rendered`:`Raw`]}),(0,F.jsx)(`button`,{onClick:()=>{l(null),d(null)},className:`p-1 rounded hover:bg-[var(--c-bg3)] transition`,style:{color:`var(--c-text3)`},children:(0,F.jsx)(Pi,{size:14})})]}),(0,F.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:f?(0,F.jsx)(`div`,{className:`text-[12px] py-8 text-center`,style:{color:`var(--c-text3)`},children:`Loading...`}):u?.error?(0,F.jsx)(`div`,{className:`text-[12px] py-8 text-center`,style:{color:`#ef4444`},children:u.error}):u?.content?(0,F.jsx)(oD,{content:u.content,fileName:c.name,viewRaw:m}):null})]}):(0,F.jsx)(`div`,{className:`flex items-center justify-center flex-1 text-[13px]`,style:{color:`var(--c-text3)`},children:(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(li,{size:32,className:`mx-auto mb-3 opacity-30`}),(0,F.jsx)(`div`,{children:`Select an artifact to view its contents`}),(0,F.jsx)(`div`,{className:`text-[11px] mt-1 opacity-60`,children:`Click any file in the sidebar tree`})]})})})]})]})}function cD(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)([]),[i,a]=(0,S.useState)(!0),[o,s]=(0,S.useState)(!1),[c,l]=(0,S.useState)(``),[u,d]=(0,S.useState)(!1);if((0,S.useEffect)(()=>{Promise.all([ta(),ra()]).then(([e,n])=>{t(e),r(n),a(!1)}).catch(()=>a(!1))},[]),i||!e)return(0,F.jsx)(ja,{label:`Loading settings...`});let f=e.hiddenProjects||[],p=async e=>{s(!0),t(await na({hiddenProjects:f.includes(e)?f.filter(t=>t!==e):[...f,e]})),s(!1)},m=[...n.filter(e=>{if(!c)return!0;let t=c.toLowerCase();return e.folder.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)})].sort((e,t)=>e.name.localeCompare(t.name)),h=!!e.allowSubscriptionAccess;return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsx)(sE,{icon:vi,title:`Settings`}),(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsxs)($,{children:[h?(0,F.jsx)(bi,{size:11,className:`inline mr-1`}):(0,F.jsx)(xi,{size:11,className:`inline mr-1`}),`subscription access`]}),(0,F.jsx)(`button`,{onClick:()=>d(!0),disabled:o,className:`text-[11px] px-2 py-0.5 rounded transition`,style:{background:h?`rgba(34,197,94,0.08)`:`rgba(239,68,68,0.08)`,color:h?`#22c55e`:`#ef4444`,border:`1px solid ${h?`rgba(34,197,94,0.15)`:`rgba(239,68,68,0.15)`}`},children:h?`Enabled`:`Disabled`})]}),(0,F.jsxs)(`div`,{className:`text-[11px] px-3 py-2`,style:{color:`var(--c-text3)`},children:[`When enabled, Agentlytics reads locally stored auth tokens (Keychain, SQLite, config files) to show your plan and usage info for each editor. Tokens are kept in-memory only and `,(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`never sent to any third-party service`}),`.`]})]}),(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsxs)($,{children:[(0,F.jsx)(Jr,{size:11,className:`inline mr-1`}),`projects (`,n.length,`)`]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f.length>0&&(0,F.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5`,style:{background:`rgba(239,68,68,0.08)`,color:`#ef4444`,border:`1px solid rgba(239,68,68,0.15)`},children:[f.length,` hidden`]}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(hi,{size:11,className:`absolute left-2 top-1/2 -translate-y-1/2`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`Filter projects...`,className:`pl-6 pr-2 py-1 text-[11px] outline-none w-[180px]`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`}})]})]})]}),(0,F.jsx)(`div`,{className:`text-[11px] px-3 py-1.5`,style:{color:`var(--c-text3)`,borderBottom:`1px solid var(--c-border)`,background:`var(--c-bg3)`},children:`Hidden projects are excluded from all dashboard stats, sessions, costs, and analytics.`}),m.map(e=>(0,F.jsx)(uD,{project:e,hidden:f.includes(e.folder),onToggle:p,saving:o},e.folder)),m.length===0&&(0,F.jsx)(`div`,{className:`text-center py-6 text-[12px]`,style:{color:`var(--c-text3)`},children:`no projects match filter`})]}),u&&(0,F.jsx)(lD,{enabling:!h,saving:o,onConfirm:async()=>{s(!0),t(await na({allowSubscriptionAccess:!h})),s(!1),d(!1)},onCancel:()=>d(!1)})]})}function lD({enabling:e,saving:t,onConfirm:n,onCancel:r}){return(0,F.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,style:{background:`rgba(0,0,0,0.6)`},onClick:r,children:(0,F.jsxs)(`div`,{className:`card w-[420px] mx-4`,onClick:e=>e.stopPropagation(),style:{background:`var(--c-bg2)`,border:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] font-medium`,style:{color:`var(--c-white)`},children:[(0,F.jsx)(ki,{size:14,style:{color:e?`#fbbf24`:`#ef4444`}}),e?`Enable`:`Disable`,` Subscription Access`]}),(0,F.jsx)(`button`,{onClick:r,className:`p-1 rounded hover:bg-[var(--c-bg3)]`,style:{color:`var(--c-text3)`},children:(0,F.jsx)(Pi,{size:14})})]}),(0,F.jsx)(`div`,{className:`px-4 py-3 text-[11px] space-y-2`,style:{color:`var(--c-text2)`},children:e?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{children:`This will allow Agentlytics to read locally stored auth tokens from:`}),(0,F.jsxs)(`ul`,{className:`space-y-1 pl-3`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(`li`,{children:`Claude Code – macOS Keychain / Linux secret-tool`}),(0,F.jsx)(`li`,{children:`Cursor – local SQLite (state.vscdb)`}),(0,F.jsx)(`li`,{children:`Copilot / VS Code – ~/.config/github-copilot/apps.json`}),(0,F.jsx)(`li`,{children:`Codex – local auth.json (JWT decode only)`}),(0,F.jsx)(`li`,{children:`Devin – local SQLite (state.vscdb)`})]}),(0,F.jsxs)(`p`,{style:{color:`var(--c-text2)`},children:[`Tokens are kept `,(0,F.jsx)(`strong`,{children:`in-memory only`}),` and never sent to any third-party service.`]})]}):(0,F.jsx)(`p`,{children:`This will stop Agentlytics from reading any local auth tokens. Subscription and plan details will no longer be collected.`})}),(0,F.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsx)(`button`,{onClick:r,className:`text-[11px] px-3 py-1 rounded transition`,style:{color:`var(--c-text3)`,border:`1px solid var(--c-border)`},children:`Cancel`}),(0,F.jsx)(`button`,{onClick:n,disabled:t,className:`text-[11px] px-3 py-1 rounded transition font-medium`,style:{background:e?`rgba(34,197,94,0.12)`:`rgba(239,68,68,0.12)`,color:e?`#22c55e`:`#ef4444`,border:`1px solid ${e?`rgba(34,197,94,0.2)`:`rgba(239,68,68,0.2)`}`},children:t?`Saving...`:e?`Yes, enable`:`Yes, disable`})]})]})})}function uD({project:e,hidden:t,onToggle:n,saving:r}){let i=Object.entries(e.editors||{}).sort((e,t)=>t[1]-e[1]);return(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 transition`,style:{borderBottom:`1px solid var(--c-border)`,opacity:t?.5:1},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,children:[(0,F.jsx)(`button`,{onClick:()=>n(e.folder),disabled:r,className:`shrink-0 p-1 rounded transition hover:bg-[var(--c-bg)]`,style:{color:t?`#ef4444`:`var(--c-text3)`,border:`1px solid var(--c-border)`},title:t?`Show this project`:`Hide this project`,children:t?(0,F.jsx)(Ur,{size:12}):(0,F.jsx)(Wr,{size:12})}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`text-[12px] font-medium truncate`,style:{color:t?`var(--c-text3)`:`var(--c-white)`},children:e.name}),(0,F.jsx)(`div`,{className:`text-[10px] truncate`,style:{color:`var(--c-text3)`},title:e.folder,children:e.folder})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:i.slice(0,3).map(([e,t])=>(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)($h,{source:e,size:10}),t]},e))}),(0,F.jsx)(`div`,{className:`text-[11px] font-mono shrink-0`,style:{color:`var(--c-text2)`},children:J(e.totalSessions)}),(0,F.jsx)(`div`,{className:`text-[10px] shrink-0 w-[80px] text-right`,style:{color:`var(--c-text3)`},children:Rh(e.lastSeen)})]})}function dD({value:e,max:t=100,color:n,label:r}){let i=t>0?Math.min(e/t*100,100):0;return(0,F.jsxs)(`div`,{children:[r&&(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text2)`},children:r}),(0,F.jsxs)(`span`,{className:`text-[10px] font-mono`,style:{color:`var(--c-white)`},children:[typeof e==`number`?e.toFixed(1):e,`%`]})]}),(0,F.jsx)(`div`,{className:`h-1.5 w-full`,style:{background:`var(--c-bg3)`},children:(0,F.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${i}%`,background:n||`#6366f1`}})})]})}function fD({date:e}){if(!e)return null;let t=new Date(e)-new Date;if(t<=0)return(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:`expired`});let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>24?(0,F.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[`resets in `,Math.floor(n/24),`d `,n%24,`h`]}):(0,F.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[`resets in `,n,`h `,r,`m`]})}function pD({name:e}){if(!e)return null;let t=(e||``).toLowerCase(),n=`rgba(99,102,241,0.12)`,r=`#818cf8`;return t.includes(`pro`)&&(n=`rgba(168,85,247,0.12)`,r=`#a855f7`),(t.includes(`max`)||t.includes(`ultra`))&&(n=`rgba(234,179,8,0.12)`,r=`#eab308`),t.includes(`plus`)&&(n=`rgba(34,197,94,0.12)`,r=`#22c55e`),t.includes(`free`)&&(n=`rgba(107,114,128,0.12)`,r=`#6b7280`),(0,F.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wider px-2 py-0.5`,style:{background:n,color:r},children:e})}function mD({label:e,enabled:t}){return(0,F.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5`,style:{background:t?`rgba(34,197,94,0.08)`:`rgba(107,114,128,0.06)`,color:t?`#22c55e`:`var(--c-text3)`,border:`1px solid ${t?`rgba(34,197,94,0.15)`:`var(--c-border)`}`},children:e})}function hD({data:e}){let t=e.usage||{},n=Object.keys(t);return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsx)(pD,{name:e.plan?.name}),e.plan?.status&&(0,F.jsxs)(`span`,{className:`text-[10px]`,style:{color:e.plan.status===`active`?`#22c55e`:`var(--c-text3)`},children:[`● `,e.plan.status]}),e.plan?.isYearlyPlan&&(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:`yearly`})]}),e.startOfMonth&&(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Fr,{size:9,className:`inline mr-1`}),`billing started `,new Date(e.startOfMonth).toLocaleDateString()]}),n.length>0&&(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(`div`,{className:`text-[10px] font-medium`,style:{color:`var(--c-text2)`},children:`model usage`}),n.map(e=>{let n=t[e];return n.maxRequestUsage&&Math.round(n.numRequests/n.maxRequestUsage*100),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,F.jsx)(`span`,{className:`font-mono`,style:{color:`var(--c-white)`},children:e}),(0,F.jsxs)(`span`,{style:{color:`var(--c-text2)`},children:[n.numRequests,n.maxRequestUsage?` / ${n.maxRequestUsage}`:``,` requests`]})]},e)})]})]})}function gD({data:e}){let t=e.usage||{},n=e.billingCycle||{};return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsx)(pD,{name:e.plan?.name}),e.user?.name&&(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:e.user.name})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[t.promptCredits&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex justify-between text-[10px] mb-0.5`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`prompt credits`}),(0,F.jsxs)(`span`,{className:`font-mono`,style:{color:`var(--c-white)`},children:[t.promptCredits.remaining,` / `,t.promptCredits.allocated]})]}),(0,F.jsx)(dD,{value:t.promptCredits.allocated>0?t.promptCredits.remaining/t.promptCredits.allocated*100:0,color:`#06b6d4`})]}),t.flexCredits&&t.flexCredits.allocated>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex justify-between text-[10px] mb-0.5`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:`flex credits`}),(0,F.jsxs)(`span`,{className:`font-mono`,style:{color:`var(--c-white)`},children:[t.flexCredits.remaining,` / `,t.flexCredits.allocated]})]}),(0,F.jsx)(dD,{value:t.flexCredits.allocated>0?t.flexCredits.remaining/t.flexCredits.allocated*100:0,color:`#a78bfa`})]}),t.totalRemainingCredits!=null&&(0,F.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium`,style:{color:`var(--c-text2)`},children:`total remaining`}),(0,F.jsx)(`span`,{className:`text-[13px] font-bold font-mono`,style:{color:`var(--c-white)`},children:t.totalRemainingCredits})]})]}),(n.start||n.end)&&(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Fr,{size:9,className:`inline mr-1`}),n.start&&new Date(n.start).toLocaleDateString(),` → `,n.end&&new Date(n.end).toLocaleDateString()]}),e.features&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.entries(e.features).map(([e,t])=>(0,F.jsx)(mD,{label:e.replace(/([A-Z])/g,` $1`).trim(),enabled:t},e))})]})}function _D({data:e}){let t=e.usage||{};return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(pD,{name:e.plan?.name}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[t.fiveHour&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(dD,{value:t.fiveHour.utilization,color:t.fiveHour.utilization>80?`#ef4444`:`#f97316`,label:`5-hour limit`}),(0,F.jsx)(fD,{date:t.fiveHour.resetsAt})]}),t.sevenDay&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(dD,{value:t.sevenDay.utilization,color:t.sevenDay.utilization>80?`#ef4444`:`#f97316`,label:`7-day limit`}),(0,F.jsx)(fD,{date:t.sevenDay.resetsAt})]}),t.sevenDaySonnet&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(dD,{value:t.sevenDaySonnet.utilization,color:`#a78bfa`,label:`7-day Sonnet`}),(0,F.jsx)(fD,{date:t.sevenDaySonnet.resetsAt})]}),t.sevenDayOpus&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(dD,{value:t.sevenDayOpus.utilization,color:`#c084fc`,label:`7-day Opus`}),(0,F.jsx)(fD,{date:t.sevenDayOpus.resetsAt})]})]}),e.extraUsage&&(0,F.jsxs)(`div`,{className:`text-[10px] flex items-center gap-1.5`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Fi,{size:9}),`extra usage: `,e.extraUsage.isEnabled?(0,F.jsxs)(`span`,{style:{color:`#22c55e`},children:[`enabled`,e.extraUsage.utilization==null?``:` (${e.extraUsage.utilization}% used)`]}):(0,F.jsx)(`span`,{children:`disabled`})]})]})}function vD({data:e}){return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsx)(pD,{name:e.plan?.name}),e.plan?.individual&&(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:`individual`})]}),e.user?.login&&(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[`@`,e.user.login]}),e.features&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.entries(e.features).map(([e,t])=>(0,F.jsx)(mD,{label:e.replace(/([A-Z])/g,` $1`).trim(),enabled:t},e))}),e.limits?.quotas&&(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text2)`},children:[(0,F.jsx)(Si,{size:9,className:`inline mr-1`}),`quotas: `,JSON.stringify(e.limits.quotas),e.limits.resetDate&&(0,F.jsxs)(`span`,{children:[` (resets `,new Date(e.limits.resetDate).toLocaleDateString(),`)`]})]})]})}function yD({data:e}){let t=e.plan||{};return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsx)(pD,{name:t.name}),e.authMode&&(0,F.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[`via `,e.authMode]})]}),e.user?.email&&(0,F.jsx)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:e.user.email}),(t.subscriptionStart||t.subscriptionEnd)&&(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Fr,{size:9,className:`inline mr-1`}),t.subscriptionStart&&new Date(t.subscriptionStart).toLocaleDateString(),` → `,t.subscriptionEnd&&new Date(t.subscriptionEnd).toLocaleDateString()]})]})}function bD({data:e}){return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[e.plan?.name&&(0,F.jsx)(pD,{name:e.plan.name}),e.user&&(0,F.jsx)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:e.user.email||e.user.login||e.user.name||e.user.id||``}),(0,F.jsx)(`pre`,{className:`text-[10px] overflow-auto p-2`,style:{background:`var(--c-bg3)`,color:`var(--c-text2)`,maxHeight:120},children:JSON.stringify(e,null,2)})]})}function xD({data:e}){let[t,n]=(0,S.useState)(!1),r=e.source,i=Ih(r),a=q(r),o=()=>{switch(r){case`cursor`:return(0,F.jsx)(hD,{data:e});case`devin`:case`devin-next`:case`antigravity`:return(0,F.jsx)(gD,{data:e});case`claude-code`:return(0,F.jsx)(_D,{data:e});case`vscode`:case`vscode-insiders`:return(0,F.jsx)(vD,{data:e});case`copilot-cli`:return(0,F.jsx)(vD,{data:e});case`codex`:return(0,F.jsx)(yD,{data:e});default:return(0,F.jsx)(bD,{data:e})}},s=e.models||[];return(0,F.jsxs)(`div`,{className:`card p-4 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)($h,{source:r,size:20}),(0,F.jsx)(`span`,{className:`text-[13px] font-bold`,style:{color:`var(--c-white)`},children:a})]}),(0,F.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:i}})]}),o(),s.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`button`,{onClick:()=>n(!t),className:`flex items-center gap-1 text-[10px] transition hover:opacity-80`,style:{color:`var(--c-text2)`},children:[t?(0,F.jsx)(Ar,{size:10}):(0,F.jsx)(Or,{size:10}),s.length,` models`]}),t&&(0,F.jsx)(`div`,{className:`mt-2 space-y-1`,children:s.map((e,t)=>(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] py-0.5`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(`span`,{style:{color:`var(--c-white)`},children:e.label||e.model}),e.remainingFraction!=null&&(0,F.jsxs)(`span`,{className:`font-mono`,style:{color:e.remainingFraction>.5?`#22c55e`:e.remainingFraction>.2?`#eab308`:`#ef4444`},children:[(e.remainingFraction*100).toFixed(0),`%`]})]},t))})]})]})}function SD(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)(!0),[i,a]=(0,S.useState)(null),o=()=>{r(!0),a(null),la().then(e=>{t(e),r(!1)}).catch(e=>{a(e.message),r(!1)})};return(0,S.useEffect)(()=>{o()},[]),(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsxs)(sE,{icon:zr,title:`Subscriptions`,children:[(0,F.jsxs)(`button`,{onClick:o,disabled:n,className:`flex items-center gap-1 px-2 py-0.5 text-[11px] transition hover:bg-[var(--c-card)]`,style:{color:`var(--c-text2)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(mi,{size:10,className:n?`animate-spin`:``}),`Refresh`]}),e&&(0,F.jsxs)(`span`,{className:`text-[11px] ml-auto`,style:{color:`var(--c-text3)`},children:[e.length,` subscription`,e.length===1?``:`s`,` detected`]})]}),n&&!e&&(0,F.jsx)(ja,{label:`Loading subscriptions...`}),i&&(0,F.jsx)(`div`,{className:`text-[12px] px-3 py-2`,style:{background:`rgba(239,68,68,0.08)`,border:`1px solid rgba(239,68,68,0.15)`,color:`#ef4444`},children:i}),e&&e.length===0&&(0,F.jsx)(`div`,{className:`text-sm py-12 text-center`,style:{color:`var(--c-text3)`},children:`No subscriptions detected. Make sure your editors are installed and logged in.`}),e&&e.length>0&&(0,F.jsx)(`div`,{className:`grid gap-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(340px, 1fr))`},children:e.map((e,t)=>(0,F.jsx)(xD,{data:e},e.source+`-`+t))})]})}Gf.register(tp,Mm,fm,Lm,Vm,Ep);var CD=`JetBrains Mono, monospace`,wD=[`#6366f1`,`#22c55e`,`#f59e0b`,`#ec4899`,`#3b82f6`,`#a855f7`,`#14b8a6`,`#f43f5e`,`#84cc16`,`#06b6d4`,`#e879f9`,`#fb923c`];function TD({server:e,matchedTools:t}){let[n,r]=(0,S.useState)(!1),i=t||[],a=i.reduce((e,t)=>e+t.count,0),o=e.tools||[],s=o.length>0||i.length>0;return(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsxs)(`button`,{onClick:()=>s&&r(!n),className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-[var(--c-bg3)] transition`,children:[(0,F.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6`,style:{background:`${Ih(e.editor)}15`},children:(0,F.jsx)(_i,{size:11,style:{color:Ih(e.editor)}})}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`text-[12px] font-semibold truncate`,style:{color:`var(--c-white)`},children:e.name}),(0,F.jsx)(`span`,{className:`text-[10px] px-1 py-px`,style:{background:e.scope===`global`?`rgba(99,102,241,0.12)`:`rgba(34,197,94,0.12)`,color:e.scope===`global`?`#818cf8`:`#22c55e`},children:e.scope}),(0,F.jsx)(`span`,{className:`text-[10px] px-1 py-px`,style:{background:e.transport===`stdio`?`rgba(234,179,8,0.12)`:`rgba(59,130,246,0.12)`,color:e.transport===`stdio`?`#eab308`:`#3b82f6`},children:e.transport}),e.disabled&&(0,F.jsx)(`span`,{className:`text-[10px] px-1 py-px`,style:{background:`rgba(239,68,68,0.12)`,color:`#ef4444`},children:`disabled`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-px`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)($h,{source:e.editor,size:10}),e.editorLabel]}),e.command&&(0,F.jsxs)(`span`,{className:`text-[10px] truncate`,style:{color:`var(--c-text3)`,fontFamily:CD},children:[e.command,` `,(e.args||[]).slice(0,2).join(` `)]}),e.url&&(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] truncate`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Zr,{size:9}),e.url]})]})]}),(0,F.jsxs)(`div`,{className:`text-right shrink-0`,children:[a>0&&(0,F.jsx)(`div`,{className:`text-[12px] font-semibold`,style:{color:`var(--c-white)`},children:J(a)}),(0,F.jsxs)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[o.length>0?`${o.length} tools`:`offline`,i.length>0?` · ${i.length} matched`:``]})]}),s?n?(0,F.jsx)(Or,{size:12,style:{color:`var(--c-text3)`}}):(0,F.jsx)(kr,{size:12,style:{color:`var(--c-text3)`}}):(0,F.jsx)(`div`,{className:`w-3`})]}),n&&s&&(0,F.jsxs)(`div`,{className:`px-3 pb-2 pt-1`,style:{borderTop:`1px solid var(--c-border)`},children:[o.length>0&&(0,F.jsxs)(`div`,{className:`mb-1.5`,children:[(0,F.jsxs)(`div`,{className:`text-[10px] font-medium mb-0.5`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Ni,{size:9,className:`inline mr-0.5`}),`Available (`,o.length,`)`]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-0.5`,children:o.map(e=>(0,F.jsx)(`span`,{className:`text-[10px] px-1 py-px`,style:{background:`var(--c-bg3)`,color:`var(--c-text3)`,fontFamily:CD},children:e},e))})]}),i.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`text-[10px] font-medium mb-0.5`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(Qr,{size:9,className:`inline mr-0.5`}),`Matched Calls`]}),(0,F.jsx)(`div`,{className:`space-y-0.5`,children:i.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center justify-between py-0.5 px-1.5`,style:{background:`var(--c-bg3)`},children:[(0,F.jsx)(`span`,{className:`text-[10px] truncate`,style:{fontFamily:CD,color:`var(--c-text)`},children:e.name}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 ml-2`,children:[(0,F.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:[e.sessionCount,`s`]}),(0,F.jsx)(`span`,{className:`text-[11px] font-semibold`,style:{color:`var(--c-white)`},children:J(e.count)})]})]},e.name))})]})]})]})}function ED(){let e=gt(),[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(!0),[a,o]=(0,S.useState)(``),[s,c]=(0,S.useState)(`servers`),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(``),{dark:p}=or(),m=p?`#a0a0a0`:`#444`,h=p?`#555`:`#999`,g=p?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`,_=p?`#9ca3af`:`#555`;(0,S.useEffect)(()=>{fa().then(e=>{n(e),i(!1)}).catch(()=>i(!1))},[]);let v=(0,S.useMemo)(()=>{if(!t)return[];let e=a.toLowerCase();return t.servers.filter(t=>!e||t.name.toLowerCase().includes(e)||t.editor.toLowerCase().includes(e)||(t.command||``).toLowerCase().includes(e))},[t,a]),y=(0,S.useMemo)(()=>{if(!t)return{};let e={};for(let[n,r]of Object.entries(t.matchedTools||{}))for(let t of r)e[t.name]=n;return e},[t]),b=(0,S.useMemo)(()=>{if(!t)return{projects:[],servers:[]};let e=new Set,n=new Set;for(let r of t.toolCalls){for(let t of r.folders||[])e.add(t);let t=y[r.name];t?n.add(t):n.add(`__builtin__`)}return{projects:[...e].sort((e,t)=>e.split(`/`).pop().localeCompare(t.split(`/`).pop())),servers:[...n].filter(e=>e!==`__builtin__`).sort(),hasBuiltIn:n.has(`__builtin__`)}},[t,y]),x=(0,S.useMemo)(()=>{if(!t)return[];let e=a.toLowerCase();return t.toolCalls.filter(t=>!(e&&!t.name.toLowerCase().includes(e)||l&&!(t.folders||[]).includes(l)||d===`__builtin__`&&y[t.name]||d&&d!==`__builtin__`&&y[t.name]!==d))},[t,a,l,d,y]),C=(0,S.useMemo)(()=>{if(!t)return[];let e=a.toLowerCase();return t.topSessions.filter(t=>!e||(t.name||``).toLowerCase().includes(e)||t.source.toLowerCase().includes(e)||(t.folder||``).toLowerCase().includes(e))},[t,a]),w=(0,S.useMemo)(()=>{let e={};for(let t of v)e[t.editor]||(e[t.editor]=[]),e[t.editor].push(t);return e},[v]),T=(0,S.useMemo)(()=>{if(!t)return null;let e={};for(let n of t.servers){let r=(t.matchedTools[n.name]||[]).reduce((e,t)=>e+t.count,0);r!==0&&(e[n.name]||(e[n.name]={}),e[n.name][n.editor]=(e[n.name][n.editor]||0)+r)}let n=Object.entries(e).map(([e,t])=>({name:e,byEditor:t,total:Object.values(t).reduce((e,t)=>e+t,0)})).sort((e,t)=>t.total-e.total).slice(0,10);if(n.length===0)return null;let r=[...new Set(n.flatMap(e=>Object.keys(e.byEditor)))];return{labels:n.map(e=>e.name),datasets:r.map(e=>({label:q(e),data:n.map(t=>t.byEditor[e]||0),backgroundColor:Ih(e)+`CC`,borderRadius:2}))}},[t]),E=(0,S.useMemo)(()=>t?t.servers.filter(e=>(t.matchedTools[e.name]||[]).length===0):[],[t]),D=(0,S.useMemo)(()=>{if(!t)return[];let e=[];for(let[n,r]of Object.entries(t.matchedTools))for(let t of r)e.push({...t,server:n});return e.sort((e,t)=>t.count-e.count).slice(0,12)},[t]),O=(0,S.useMemo)(()=>{if(!t)return[];let e=new Set;for(let n of Object.values(t.matchedTools))for(let t of n)e.add(t.name);let n=[];for(let r of t.servers){let t=r.tools||[];if(t.length!==0)for(let i of t)e.has(i)||n.push({name:i,server:r.name,editor:r.editor})}return n},[t]),k=(0,S.useMemo)(()=>{if(!t)return null;let e={};for(let n of t.servers){let t=q(n.editor);e[t]=(e[t]||0)+1}let n=Object.entries(e).sort((e,t)=>t[1]-e[1]);return n.length===0?null:{labels:n.map(e=>e[0]),colors:n.map(e=>{let n=t.servers.find(t=>q(t.editor)===e[0]);return n?Ih(n.editor):`#666`}),values:n.map(e=>e[1])}},[t]),A=(0,S.useMemo)(()=>{if(!t)return null;let e={};for(let n of t.servers)e[n.transport]=(e[n.transport]||0)+1;let n=Object.entries(e).sort((e,t)=>t[1]-e[1]);if(n.length===0)return null;let r={stdio:`#eab308`,http:`#3b82f6`,sse:`#a855f7`};return{labels:n.map(e=>e[0]),colors:n.map(e=>r[e[0]]||`#666`),values:n.map(e=>e[1])}},[t]);if(r)return(0,F.jsx)(ja,{label:`Loading MCP data...`});if(!t)return(0,F.jsx)(`div`,{className:`text-center py-20 text-[13px]`,style:{color:`var(--c-text3)`},children:`Failed to load MCP data`});let{summary:j,matchedTools:ee}=t,te=[{id:`servers`,label:`Servers`,count:t.servers.length},{id:`tools`,label:`Tools`,count:t.toolCalls.length},{id:`sessions`,label:`Sessions`,count:t.topSessions.length}];return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsx)(sE,{icon:di,title:`MCPs`}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`servers`,value:j.totalServers,sub:`${j.editorsWithServers.length} editors`}),(0,F.jsx)(K,{label:`unique tools`,value:J(j.uniqueTools)}),(0,F.jsx)(K,{label:`tool calls`,value:J(j.totalToolCalls)}),(0,F.jsx)(K,{label:`sessions`,value:J(j.sessionsWithTools)}),(0,F.jsx)(K,{label:`matched`,value:Object.values(ee).reduce((e,t)=>e+t.length,0),sub:`${Object.keys(ee).length} servers`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-2`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)($,{children:[`most used servers `,(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`(by editor)`})]}),T?(0,F.jsx)(`div`,{style:{height:Math.max(T.labels.length*22+10,80)},children:(0,F.jsx)(Mh,{data:T,options:{indexAxis:`y`,responsive:!0,maintainAspectRatio:!1,scales:{x:{stacked:!0,grid:{color:g},ticks:{color:h,font:{size:9,family:CD}}},y:{stacked:!0,grid:{display:!1},ticks:{color:m,font:{size:9,family:CD}}}},plugins:{legend:{position:`top`,labels:{color:_,font:{size:9,family:CD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{mode:`index`,bodyFont:{family:CD,size:10},titleFont:{family:CD,size:10}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-6`,style:{color:`var(--c-text3)`},children:`No MCP server usage`})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`most used tools`}),D.length>0?(0,F.jsx)(`div`,{style:{height:Math.max(D.length*22+10,80)},children:(0,F.jsx)(Mh,{data:{labels:D.map(e=>e.name),datasets:[{data:D.map(e=>e.count),backgroundColor:wD.slice(0,D.length),borderRadius:2}]},options:{indexAxis:`y`,responsive:!0,maintainAspectRatio:!1,scales:{x:{grid:{color:g},ticks:{color:h,font:{size:9,family:CD}}},y:{grid:{display:!1},ticks:{color:m,font:{size:9,family:CD}}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:CD,size:10},titleFont:{family:CD,size:10},callbacks:{afterLabel:e=>`Server: ${D[e.dataIndex]?.server||`?`}`}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-6`,style:{color:`var(--c-text3)`},children:`No MCP tool usage`})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`servers by editor`}),k?(0,F.jsx)(`div`,{style:{height:110},children:(0,F.jsx)(Nh,{data:{labels:k.labels,datasets:[{data:k.values,backgroundColor:k.colors,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`55%`,plugins:{legend:{position:`right`,labels:{color:_,font:{size:9,family:CD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:CD,size:10},titleFont:{family:CD,size:10}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-4`,style:{color:`var(--c-text3)`},children:`no data`})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`servers by transport`}),A?(0,F.jsx)(`div`,{style:{height:90},children:(0,F.jsx)(Nh,{data:{labels:A.labels,datasets:[{data:A.values,backgroundColor:A.colors,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`55%`,plugins:{legend:{position:`right`,labels:{color:_,font:{size:9,family:CD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:CD,size:10},titleFont:{family:CD,size:10}}}}})}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-4`,style:{color:`var(--c-text3)`},children:`no data`})]})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-2`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)($,{children:[`never used servers `,(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`(`,E.length,`)`]})]}),E.length>0?(0,F.jsx)(`div`,{className:`space-y-0.5 max-h-[160px] overflow-y-auto scrollbar-thin`,children:E.map((e,t)=>(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 py-0.5 px-1.5`,style:{background:`var(--c-bg3)`},children:[(0,F.jsx)(vr,{size:9,style:{color:`#ef4444`,opacity:.5}}),(0,F.jsx)(`span`,{className:`text-[10px] font-medium truncate`,style:{color:`var(--c-text)`},children:e.name}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1 ml-auto shrink-0`,children:[(0,F.jsx)($h,{source:e.editor,size:10}),(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:e.editorLabel})]}),e.disabled&&(0,F.jsx)(`span`,{className:`text-[9px] px-0.5`,style:{background:`rgba(239,68,68,0.12)`,color:`#ef4444`},children:`off`})]},`${e.name}-${e.editor}-${t}`))}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-4`,style:{color:`var(--c-text3)`},children:`All servers have been used`})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)($,{children:[`never used tools `,(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`(`,O.length,`)`]})]}),O.length>0?(0,F.jsx)(`div`,{className:`space-y-0.5 max-h-[160px] overflow-y-auto scrollbar-thin`,children:O.map((e,t)=>(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 py-0.5 px-1.5`,style:{background:`var(--c-bg3)`},children:[(0,F.jsx)(vr,{size:9,style:{color:`#f59e0b`,opacity:.5}}),(0,F.jsx)(`span`,{className:`text-[10px] truncate`,style:{fontFamily:CD,color:`var(--c-text)`},children:e.name}),(0,F.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] px-1 py-px`,style:{background:`rgba(99,102,241,0.12)`,color:`#818cf8`},children:e.server})]},`${e.name}-${e.server}-${t}`))}):(0,F.jsx)(`div`,{className:`text-[11px] text-center py-4`,style:{color:`var(--c-text3)`},children:`All queried tools have been used`})]})]}),t.projectMcps&&t.projectMcps.length>0&&(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsx)(`div`,{className:`px-3 py-2`,style:{borderBottom:`1px solid var(--c-border)`},children:(0,F.jsxs)($,{children:[`MCP servers by project `,(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`(`,t.projectMcps.length,`)`]})]})}),(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider`,style:{borderBottom:`1px solid var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`project`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`config`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`servers`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`mcp calls`})]})}),(0,F.jsx)(`tbody`,{children:t.projectMcps.map(t=>t.configs.map((n,r)=>(0,F.jsxs)(`tr`,{className:`transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,children:[r===0?(0,F.jsx)(`td`,{className:`px-3 py-2`,rowSpan:t.configs.length,children:(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 cursor-pointer hover:underline`,style:{color:`var(--c-accent)`},onClick:()=>e(`/projects/detail?folder=${encodeURIComponent(t.folder)}`),children:[(0,F.jsx)(Jr,{size:11}),(0,F.jsx)(`span`,{className:`font-medium truncate max-w-[200px]`,children:t.name})]})}):null,(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)($h,{source:n.editor,size:12}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:n.file})]})}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.serverNames.map(e=>(0,F.jsxs)(`span`,{className:`text-[11px] px-1.5 py-px`,style:{background:ee[e]?`rgba(99,102,241,0.12)`:`var(--c-bg3)`,color:ee[e]?`#818cf8`:`var(--c-text2)`},children:[(0,F.jsx)(di,{size:8,className:`inline mr-0.5`}),e,ee[e]&&(0,F.jsx)(`span`,{className:`ml-1 opacity-60`,children:ee[e].reduce((e,t)=>e+t.count,0)})]},e))})}),r===0?(0,F.jsx)(`td`,{className:`px-3 py-2 text-right`,rowSpan:t.configs.length,children:t.mcpToolCalls>0?(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--c-white)`},children:J(t.mcpToolCalls)}):(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`—`})}):null]},`${t.folder}-${n.file}`)))})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`div`,{className:`flex gap-0.5`,children:te.map(e=>(0,F.jsxs)(`button`,{onClick:()=>c(e.id),className:`px-2.5 py-1 text-[12px] transition`,style:{background:s===e.id?`var(--c-card)`:`transparent`,color:s===e.id?`var(--c-white)`:`var(--c-text3)`,border:s===e.id?`1px solid var(--c-border)`:`1px solid transparent`},children:[e.label,` `,(0,F.jsx)(`span`,{className:`opacity-40 ml-0.5`,children:e.count})]},e.id))}),(0,F.jsx)(`div`,{className:`flex-1`}),s===`tools`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,border:`1px solid var(--c-border)`,color:`var(--c-text)`},children:[(0,F.jsx)(`option`,{value:``,children:`All Projects`}),b.projects.map(e=>(0,F.jsx)(`option`,{value:e,children:e.split(`/`).pop()},e))]}),(0,F.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),className:`px-2 py-1 text-[12px] outline-none`,style:{background:`var(--c-bg3)`,border:`1px solid var(--c-border)`,color:`var(--c-text)`},children:[(0,F.jsx)(`option`,{value:``,children:`All Servers`}),b.hasBuiltIn&&(0,F.jsx)(`option`,{value:`__builtin__`,children:`built-in`}),b.servers.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})]}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(hi,{size:12,className:`absolute left-2.5 top-1/2 -translate-y-1/2`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`Search...`,className:`pl-7 pr-3 py-1 text-[12px] outline-none w-[180px]`,style:{background:`var(--c-bg3)`,border:`1px solid var(--c-border)`,color:`var(--c-text)`}})]})]}),s===`servers`&&(0,F.jsx)(`div`,{children:v.length===0?(0,F.jsxs)(`div`,{className:`text-center py-12 text-[12px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(_i,{size:24,className:`mx-auto mb-2 opacity-30`}),(0,F.jsx)(`div`,{children:`No MCP servers detected`}),(0,F.jsx)(`div`,{className:`text-[10px] mt-0.5 opacity-60`,children:`Configure MCP servers in your editors`})]}):Object.entries(w).map(([e,t])=>(0,F.jsxs)(`div`,{className:`mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,F.jsx)($h,{source:e,size:13}),(0,F.jsx)(`span`,{className:`text-[12px] font-semibold`,style:{color:`var(--c-white)`},children:q(e)}),(0,F.jsxs)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:[`(`,t.length,`)`]})]}),(0,F.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>(0,F.jsx)(TD,{server:e,matchedTools:ee[e.name]},`${e.name}-${e.editor}-${e.scope}`))})]},e))}),s===`tools`&&(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider`,style:{borderBottom:`1px solid var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`tool`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`calls`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`sessions`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`editors`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`server`})]})}),(0,F.jsx)(`tbody`,{children:x.slice(0,100).map((e,t)=>{let n=y[e.name];return(0,F.jsxs)(`tr`,{className:`transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,children:[(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(`span`,{style:{fontFamily:CD,color:`var(--c-white)`},children:e.name})}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right`,children:(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--c-white)`},children:J(e.count)})}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right`,style:{color:`var(--c-text2)`},children:e.sessionCount}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(`div`,{className:`flex items-center gap-1`,children:e.editors.map(e=>(0,F.jsx)(`span`,{className:`inline-flex items-center gap-0.5`,children:(0,F.jsx)($h,{source:e,size:12})},e))})}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:n?(0,F.jsxs)(`span`,{className:`text-[11px] px-1.5 py-px`,style:{background:`rgba(99,102,241,0.12)`,color:`#818cf8`},children:[(0,F.jsx)(di,{size:9,className:`inline mr-0.5`}),n]}):(0,F.jsx)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text2)`},children:`built-in`})})]},e.name)})})]}),x.length>100&&(0,F.jsxs)(`div`,{className:`px-3 py-1 text-[10px] text-center`,style:{color:`var(--c-text3)`,background:`var(--c-card)`},children:[`Showing 100 of `,x.length]})]}),s===`sessions`&&(0,F.jsxs)(`div`,{className:`card overflow-hidden`,children:[(0,F.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[10px] uppercase tracking-wider`,style:{borderBottom:`1px solid var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`session`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`editor`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`project`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`calls`}),(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`top tools`})]})}),(0,F.jsx)(`tbody`,{children:C.map((t,n)=>{let r=Object.entries(t.tools).sort((e,t)=>t[1]-e[1]).slice(0,3);return(0,F.jsxs)(`tr`,{className:`transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,children:[(0,F.jsx)(`td`,{className:`px-3 py-2 max-w-[220px] font-medium`,children:(0,F.jsx)(`span`,{className:`truncate block`,style:{color:`var(--c-white)`},children:t.name||(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`,fontStyle:`italic`},children:`Untitled`})})}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)($h,{source:t.source,size:12}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:q(t.source)})]})}),(0,F.jsx)(`td`,{className:`px-3 py-2 truncate max-w-[160px]`,title:t.folder,children:t.folder?(0,F.jsx)(`span`,{className:`cursor-pointer hover:underline`,style:{color:`var(--c-accent)`},onClick:n=>{n.stopPropagation(),e(`/projects/detail?folder=${encodeURIComponent(t.folder)}`)},children:t.folder.split(/[/\\]/).pop()}):(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`—`})}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right`,children:(0,F.jsx)(`span`,{className:`font-semibold`,style:{color:`var(--c-white)`},children:J(t.totalToolCalls)})}),(0,F.jsx)(`td`,{className:`px-3 py-2`,children:(0,F.jsx)(`div`,{className:`flex gap-0.5 flex-wrap`,children:r.map(([e,t])=>(0,F.jsxs)(`span`,{className:`text-[10px] px-1 py-px`,style:{background:`var(--c-bg3)`,color:`var(--c-text2)`,fontFamily:CD},children:[e,` `,(0,F.jsxs)(`span`,{style:{opacity:.5},children:[`×`,t]})]},e))})})]},t.composerId)})})]}),t.topSessions.length===0&&(0,F.jsx)(`div`,{className:`text-center py-8 text-[11px]`,style:{color:`var(--c-text3)`},children:`No sessions with tool calls`})]})]})}function DD({source:e,showLabel:t=!1,size:n=8}){return(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,F.jsx)($h,{source:e,size:n}),t&&(0,F.jsx)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text)`},children:q(e)})]})}function OD(e){return e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``}function kD({onSessionClick:e}){let[t,n]=(0,S.useState)([]),r=(0,S.useRef)(null);(0,S.useEffect)(()=>{let e=()=>{Ta({limit:80}).then(e=>{Array.isArray(e)&&n(e)}).catch(()=>{})};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[]);let i=Date.now(),a=[],o=null;for(let e of t){let t=i-e.lastUpdatedAt,n;n=t<3e5?`Just now`:t<36e5?`${Math.floor(t/6e4)} min ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e.lastUpdatedAt).toLocaleDateString(),(!o||o.label!==n)&&(o={label:n,items:[]},a.push(o)),o.items.push(e)}return(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 shrink-0`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(pi,{size:12,style:{color:`#22c55e`}}),(0,F.jsx)(`span`,{className:`text-[12px] font-medium uppercase tracking-wider`,style:{color:`var(--c-text2)`},children:`Live Feed`}),(0,F.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full pulse-dot ml-auto`,style:{background:`#22c55e`}})]}),(0,F.jsxs)(`div`,{ref:r,className:`flex-1 overflow-y-auto scrollbar-thin`,children:[t.length===0&&(0,F.jsx)(`div`,{className:`text-[12px] py-8 text-center`,style:{color:`var(--c-text3)`},children:`No recent activity`}),a.map((t,n)=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`sticky top-0 px-3 py-1.5 text-[10px] font-medium uppercase tracking-wider`,style:{background:`var(--c-bg)`,color:`var(--c-text3)`,borderBottom:`1px solid var(--c-border)`},children:t.label}),t.items.map(t=>(0,F.jsxs)(`div`,{className:`px-3 py-2.5 cursor-pointer transition hover:bg-[var(--c-card)]`,style:{borderBottom:`1px solid var(--c-border)`},onClick:()=>e&&e(t.id,t.username),children:[(0,F.jsx)(`div`,{className:`text-[12px] font-medium truncate mb-1`,style:{color:`var(--c-white)`},children:t.name||`Untitled`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium px-1 py-0.5 shrink-0 truncate max-w-[120px]`,style:{background:`rgba(99,102,241,0.12)`,color:`#818cf8`},title:t.username,children:t.username}),(0,F.jsx)(DD,{source:t.source,size:6}),(0,F.jsx)(`span`,{className:`text-[10px] truncate`,style:{color:`var(--c-text2)`},children:q(t.source)}),(0,F.jsx)(`span`,{className:`text-[10px] ml-auto shrink-0`,style:{color:`var(--c-text3)`},children:OD(t.lastUpdatedAt)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px]`,style:{color:`var(--c-text3)`},children:[t.totalMessages>0&&(0,F.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,F.jsx)(si,{size:8}),` `,t.totalMessages]}),t.folder&&(0,F.jsxs)(`span`,{className:`flex items-center gap-0.5 truncate`,children:[(0,F.jsx)(Jr,{size:8}),` `,t.folder.split(`/`).pop()]}),t.mode&&(0,F.jsx)(`span`,{className:`px-1 py-0`,style:{background:`rgba(168,85,247,0.1)`,color:`#a855f7`},children:t.mode}),t.models?.[0]&&(0,F.jsxs)(`span`,{className:`flex items-center gap-0.5 ml-auto truncate`,style:{color:`#818cf8`},children:[(0,F.jsx)(Rr,{size:8}),` `,t.models[0]]})]})]},`${t.id}-${t.username}`))]},n))]})]})}Gf.register(tp,Mm,fm,Lm,Vm,Ep);var AD=`JetBrains Mono, monospace`,jD=[`#6366f1`,`#a78bfa`,`#818cf8`,`#c084fc`,`#e879f9`,`#f472b6`,`#fb7185`,`#f87171`,`#fbbf24`,`#34d399`],MD=[`#6366f1`,`#8b5cf6`,`#a855f7`,`#c084fc`,`#d8b4fe`,`#e879f9`,`#f472b6`,`#fb7185`];function ND({segments:e,height:t=6}){let n=e.reduce((e,t)=>e+t.value,0);return n===0?null:(0,F.jsx)(`div`,{className:`flex w-full rounded-full overflow-hidden`,style:{height:t},children:e.filter(e=>e.value>0).map((e,t)=>(0,F.jsx)(`div`,{title:`${e.label}: ${J(e.value)}`,className:`h-full transition-all`,style:{width:`${(e.value/n*100).toFixed(1)}%`,background:e.color}},t))})}function PD({userList:e,userColorMap:t,selectedUser:n}){let[r,i]=(0,S.useState)(new Set),a=gt(),{projectGroups:o,ungrouped:s}=(0,S.useMemo)(()=>{let t={},n=new Set;for(let r of e){let e=r.sharedProjects||[];if(e.length===0){n.add(r.username);continue}for(let i of e){let e=typeof i==`string`?i:i.name||i;t[e]||(t[e]=[]),t[e].push(r),n.add(r.username)}}let r=e.filter(e=>!(e.sharedProjects?.length>0));return{projectGroups:Object.entries(t).sort((e,t)=>t[1].length-e[1].length),ungrouped:r}},[e]),c=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},l=({u:r})=>{e.indexOf(r);let i=t[r.username]||`#6366f1`,o=Object.entries(r.editors||{}).sort((e,t)=>t[1]-e[1]);return(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1.5 cursor-pointer transition rounded-sm`,style:{background:n===r.username?`rgba(99,102,241,0.12)`:`transparent`},onMouseEnter:e=>{n!==r.username&&(e.currentTarget.style.background=`var(--c-bg3)`)},onMouseLeave:e=>{n!==r.username&&(e.currentTarget.style.background=`transparent`)},onClick:()=>a(`/relay/user/${r.username}`),children:[(0,F.jsx)(`div`,{className:`w-5 h-5 flex items-center justify-center text-[8px] font-bold rounded-sm flex-shrink-0`,style:{background:`${i}20`,color:i},children:r.username.charAt(0).toUpperCase()}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-[11px] font-medium truncate`,style:{color:`var(--c-white)`},children:r.username}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsxs)(`span`,{children:[r.sessions,`s`]}),(0,F.jsx)(`span`,{children:`·`}),(0,F.jsxs)(`span`,{children:[J(r.totalMessages),`m`]})]}),o.length>0&&(0,F.jsx)(`div`,{className:`flex items-center gap-1 mt-0.5`,children:o.slice(0,4).map(([e])=>(0,F.jsx)($h,{source:e,size:9},e))})]})]})};return(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 shrink-0`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(Mi,{size:12,style:{color:`var(--c-accent)`}}),(0,F.jsx)(`span`,{className:`text-[12px] font-medium uppercase tracking-wider`,style:{color:`var(--c-text2)`},children:`Team`}),(0,F.jsx)(`span`,{className:`text-[10px] ml-auto`,style:{color:`var(--c-text3)`},children:e.length})]}),(0,F.jsxs)(`div`,{className:`flex-1 overflow-y-auto scrollbar-thin py-1`,children:[o.map(([e,t])=>{let n=r.has(e),i=e.split(`/`).pop();return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1.5 cursor-pointer transition`,onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,onClick:()=>c(e),children:[n?(0,F.jsx)(kr,{size:10,style:{color:`var(--c-text3)`}}):(0,F.jsx)(Or,{size:10,style:{color:`var(--c-text3)`}}),(0,F.jsx)(Jr,{size:10,style:{color:`#818cf8`}}),(0,F.jsx)(`span`,{className:`text-[11px] font-medium truncate flex-1`,style:{color:`var(--c-text2)`},title:e,children:i}),(0,F.jsx)(`span`,{className:`text-[8px]`,style:{color:`var(--c-text3)`},children:t.length})]}),!n&&(0,F.jsx)(`div`,{className:`pl-3`,children:t.map(t=>(0,F.jsx)(l,{u:t},`${e}-${t.username}`))})]},e)}),s.length>0&&(0,F.jsxs)(`div`,{children:[o.length>0&&(0,F.jsx)(`div`,{className:`px-2 py-1.5 text-[10px] uppercase tracking-wider`,style:{color:`var(--c-text3)`},children:`unassigned`}),(0,F.jsx)(`div`,{className:o.length>0?`pl-1`:``,children:s.map(e=>(0,F.jsx)(l,{u:e},e.username))})]}),e.length===0&&(0,F.jsx)(`div`,{className:`text-[11px] py-6 text-center`,style:{color:`var(--c-text3)`},children:`No team members yet`})]}),e.length>=2&&(0,F.jsx)(FD,{userList:e})]})}function FD({userList:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(!1),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)(!1);return(0,F.jsxs)(`div`,{className:`shrink-0 px-2 py-2`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 cursor-pointer text-[10px] uppercase tracking-wider`,style:{color:`var(--c-text3)`},onClick:()=>u(!l),children:[l?(0,F.jsx)(Or,{size:9}):(0,F.jsx)(kr,{size:9}),(0,F.jsx)(oi,{size:9}),(0,F.jsx)(`span`,{children:`merge users`})]}),l&&(0,F.jsxs)(`div`,{className:`mt-2 space-y-1.5`,children:[(0,F.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value),className:`w-full text-[11px] px-1.5 py-1 outline-none rounded-sm`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(`option`,{value:``,children:`from...`}),e.filter(e=>e.username!==r).map(e=>(0,F.jsx)(`option`,{value:e.username,children:e.username},e.username))]}),(0,F.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`w-full text-[11px] px-1.5 py-1 outline-none rounded-sm`,style:{background:`var(--c-bg3)`,color:`var(--c-text)`,border:`1px solid var(--c-border)`},children:[(0,F.jsx)(`option`,{value:``,children:`into...`}),e.filter(e=>e.username!==t).map(e=>(0,F.jsx)(`option`,{value:e.username,children:e.username},e.username))]}),(0,F.jsx)(`button`,{disabled:!t||!r||a,onClick:async()=>{if(confirm(`Merge "${t}" → "${r}"? Cannot undo.`)){o(!0),c(null);try{c(await Ea(t,r)),n(``),i(``)}catch(e){c({error:e.message})}o(!1)}},className:`w-full text-[11px] px-2 py-1 font-medium transition rounded-sm`,style:{background:t&&r?`rgba(239,68,68,0.15)`:`var(--c-bg3)`,color:t&&r?`#ef4444`:`var(--c-text3)`,border:`1px solid var(--c-border)`,cursor:!t||!r||a?`not-allowed`:`pointer`,opacity:!t||!r||a?.5:1},children:a?`Merging...`:`Merge`}),s&&(0,F.jsx)(`div`,{className:`text-[10px]`,style:{color:s.error?`#ef4444`:`#22c55e`},children:s.error?`Error: ${s.error}`:`Merged!`})]})]})}function ID(){let e=gt(),[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(!1),[l,u]=(0,S.useState)(null),[d,f]=(0,S.useState)(null),{dark:p}=or(),m=p?`#888`:`#555`,h=p?`rgba(255,255,255,0.04)`:`rgba(0,0,0,0.06)`,g=p?`#555`:`#999`,_=p?`#888`:`#555`;(0,S.useEffect)(()=>{Sa().then(n);let e=setInterval(()=>Sa().then(n),15e3);return()=>clearInterval(e)},[]);let v=async e=>{if(e.preventDefault(),r.trim()){c(!0);try{o(await wa(r.trim(),{limit:30}))}catch{o([])}c(!1)}},y=t?.users||[],b=(0,S.useMemo)(()=>{let e={};return y.forEach((t,n)=>{e[t.username]=MD[n%MD.length]}),e},[y]);if(!t)return(0,F.jsx)(ja,{label:`Loading relay data...`});let x=t.editors||[],C=t.topModels||[],w=(t.totalInputTokens||0)+(t.totalOutputTokens||0),T=t.totalSessions>0?(t.totalMessages/t.totalSessions).toFixed(1):0,E=t.totalSessions>0?Math.round(w/t.totalSessions):0,D=y.length>0?Math.max(...y.map(e=>e.sessions)):1,O=(e,t)=>{u(e),f(t)},k=`calc(100vh - 42px)`;return(0,F.jsxs)(`div`,{className:`fade-in flex`,style:{height:k},children:[(0,F.jsx)(`div`,{className:`hidden lg:flex flex-col w-[250px] shrink-0 sticky top-[42px] self-start`,style:{height:k,borderRight:`1px solid var(--c-border)`,background:`var(--c-bg)`},children:(0,F.jsx)(PD,{userList:y,userColorMap:b,selectedUser:d,onUserClick:t=>e(`/relay/user/${t}`)})}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-y-auto p-4 space-y-3`,children:[(0,F.jsx)(sE,{icon:Mi,title:`Team Relay`}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`team members`,value:t.totalUsers}),(0,F.jsx)(K,{label:`sessions`,value:J(t.totalSessions),sub:`${T} msgs/session`}),(0,F.jsx)(K,{label:`active users`,value:t.activeUsers}),(0,F.jsx)(K,{label:`projects`,value:t.totalProjects}),(0,F.jsx)(K,{label:`messages`,value:J(t.totalMessages)}),(0,F.jsx)(K,{label:`tokens`,value:J(w),sub:`${J(E)}/session`})]}),w>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsx)($,{children:`team token usage`}),(0,F.jsxs)(`span`,{className:`text-[11px] font-bold`,style:{color:`var(--c-white)`},children:[J(w),` total`]})]}),(0,F.jsx)(ND,{height:10,segments:[{label:`Input`,value:t.totalInputTokens,color:`#6366f1`},{label:`Output`,value:t.totalOutputTokens,color:`#a78bfa`}]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mt-1.5 text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#6366f1`}}),` input `,J(t.totalInputTokens)]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#a78bfa`}}),` output `,J(t.totalOutputTokens)]})]}),y.length>1&&(0,F.jsxs)(`div`,{className:`mt-3 pt-2`,style:{borderTop:`1px solid var(--c-border)`},children:[(0,F.jsx)(`div`,{className:`text-[10px] mb-1.5`,style:{color:`var(--c-text3)`},children:`per-user contribution`}),(0,F.jsx)(ND,{height:8,segments:y.map(e=>({label:e.username,value:e.totalInputTokens+e.totalOutputTokens,color:b[e.username]}))}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-3 mt-1 text-[10px]`,children:y.map(e=>(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,style:{color:`var(--c-text3)`},children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:b[e.username]}}),e.username]},e.username))})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-3 gap-3`,children:[x.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`editors`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(Nh,{data:{labels:x.map(e=>q(e.source)),datasets:[{data:x.map(e=>e.count),backgroundColor:x.map(e=>Ih(e.source)),borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:m,font:{size:9,family:AD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:AD,size:10},titleFont:{family:AD,size:10}}}}})})]}),C.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`models`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(Nh,{data:{labels:C.slice(0,10).map(e=>e.name),datasets:[{data:C.slice(0,10).map(e=>e.count),backgroundColor:jD,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:m,font:{size:8,family:AD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:AD,size:10},titleFont:{family:AD,size:10}}}}})})]}),y.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`sessions per user`}),(0,F.jsx)(`div`,{style:{height:Math.max(120,y.length*28)},children:(0,F.jsx)(Mh,{data:{labels:y.map(e=>e.username),datasets:[{data:y.map(e=>e.sessions),backgroundColor:y.map(e=>b[e.username]),borderRadius:2}]},options:{responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,plugins:{legend:{display:!1},tooltip:{bodyFont:{family:AD,size:10},titleFont:{family:AD,size:10}}},scales:{x:{grid:{color:h},ticks:{color:g,font:{size:8,family:AD}},beginAtZero:!0},y:{grid:{display:!1},ticks:{color:_,font:{size:9,family:AD}}}}}})})]})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`search across team`}),(0,F.jsxs)(`form`,{onSubmit:v,className:`flex gap-2 mt-1`,children:[(0,F.jsxs)(`div`,{className:`relative flex-1`,children:[(0,F.jsx)(hi,{size:11,className:`absolute left-2.5 top-1/2 -translate-y-1/2`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`Search messages, files, topics across all users...`,className:`w-full pl-7 pr-3 py-1.5 text-[12px] outline-none rounded-sm`,style:{background:`var(--c-bg3)`,color:`var(--c-white)`,border:`1px solid var(--c-border)`}})]}),(0,F.jsx)(`button`,{type:`submit`,disabled:s,className:`px-3 py-1.5 text-[11px] font-medium transition rounded-sm`,style:{background:`var(--c-card)`,border:`1px solid var(--c-border)`,color:`var(--c-white)`},children:s?`Searching...`:`Search`})]}),a&&(0,F.jsx)(`div`,{className:`mt-3 max-h-[300px] overflow-y-auto scrollbar-thin`,children:a.length===0?(0,F.jsx)(`div`,{className:`text-[12px] py-2`,style:{color:`var(--c-text3)`},children:`No results found`}):(0,F.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,F.jsx)(`tbody`,{children:a.map((e,t)=>(0,F.jsxs)(`tr`,{className:`cursor-pointer transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,onClick:()=>{u(e.chatId),f(e.username)},children:[(0,F.jsx)(`td`,{className:`py-2 px-2 w-[80px]`,children:(0,F.jsx)(`span`,{className:`text-[10px] font-medium px-1.5 py-0.5`,style:{background:`rgba(99,102,241,0.15)`,color:`#818cf8`},children:e.username})}),(0,F.jsx)(`td`,{className:`py-2 px-2 w-[24px]`,children:(0,F.jsx)($h,{source:e.source,size:11})}),(0,F.jsxs)(`td`,{className:`py-2 px-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] truncate`,style:{color:`var(--c-text3)`},children:e.chatName}),(0,F.jsx)(`div`,{className:`text-[11px] line-clamp-1 mt-0.5`,style:{color:`var(--c-text)`},children:e.content})]}),(0,F.jsx)(`td`,{className:`py-2 px-2 text-[10px] whitespace-nowrap`,style:{color:`var(--c-text3)`},children:e.role})]},t))})})})]}),(0,F.jsx)($,{children:`team overview`}),(0,F.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3`,children:y.map(t=>{let n=t.totalInputTokens+t.totalOutputTokens,r=b[t.username],i=Object.entries(t.editors||{}).sort((e,t)=>t[1]-e[1]);return(0,F.jsxs)(`div`,{className:`card p-3 cursor-pointer transition hover:opacity-90`,onClick:()=>e(`/relay/user/${t.username}`),children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,F.jsx)(`div`,{className:`w-7 h-7 flex items-center justify-center text-[12px] font-bold rounded-sm flex-shrink-0`,style:{background:`${r}20`,color:r},children:t.username.charAt(0).toUpperCase()}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-[12px] font-bold truncate`,style:{color:`var(--c-white)`},children:t.username}),(0,F.jsx)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:t.lastActive?Rh(t.lastActive):`No activity`})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-0.5 flex-shrink-0`,children:i.slice(0,3).map(([e])=>(0,F.jsx)($h,{source:e,size:11},e))})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-4 gap-1 text-center mb-2`,children:[[t.sessions,`sessions`],[J(t.totalMessages),`messages`],[t.projects,`projects`],[J(n),`tokens`]].map(([e,t])=>(0,F.jsxs)(`div`,{className:`p-1 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsx)(`div`,{className:`text-[11px] font-bold`,style:{color:`var(--c-white)`},children:e}),(0,F.jsx)(`div`,{className:`text-[7px]`,style:{color:`var(--c-text3)`},children:t})]},t))}),(0,F.jsx)(`div`,{className:`h-1.5 rounded-full overflow-hidden`,style:{background:`var(--c-code-bg)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${(t.sessions/D*100).toFixed(0)}%`,background:r}})}),t.topModels&&t.topModels.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:t.topModels.slice(0,2).map(e=>(0,F.jsx)(`span`,{className:`text-[8px] px-1.5 py-0.5 rounded-sm`,style:{background:`rgba(99,102,241,0.08)`,color:`#818cf8`},children:e.name},e.name))})]},t.username)})}),y.length===0&&(0,F.jsxs)(`div`,{className:`card p-8 text-center`,children:[(0,F.jsx)(Mi,{size:32,className:`mx-auto mb-3`,style:{color:`var(--c-text3)`}}),(0,F.jsx)(`div`,{className:`text-[12px] font-medium mb-1`,style:{color:`var(--c-white)`},children:`No team members yet`}),(0,F.jsx)(`div`,{className:`text-[11px]`,style:{color:`var(--c-text3)`},children:`Share the join command with your team to start collecting data`})]})]}),(0,F.jsx)(`div`,{className:`hidden xl:flex flex-col w-[300px] shrink-0 sticky top-[42px] self-start`,style:{height:k,borderLeft:`1px solid var(--c-border)`,background:`var(--c-bg)`},children:(0,F.jsx)(kD,{onSessionClick:O})}),(0,F.jsx)(iE,{chatId:l,onClose:()=>{u(null),f(null)},fetchFn:d?e=>Da(e,d):void 0,username:d,extraHeader:d?(0,F.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 shrink-0`,style:{background:`rgba(99,102,241,0.15)`,color:`#818cf8`},children:d}):null})]})}Gf.register(tp,Mm,fm,Lm,Vm,Ep);var LD=`JetBrains Mono, monospace`,RD=[`#6366f1`,`#a78bfa`,`#818cf8`,`#c084fc`,`#e879f9`,`#f472b6`,`#fb7185`,`#f87171`,`#fbbf24`,`#34d399`];function zD({segments:e,height:t=6}){let n=e.reduce((e,t)=>e+t.value,0);return n===0?null:(0,F.jsx)(`div`,{className:`flex w-full rounded-full overflow-hidden`,style:{height:t},children:e.filter(e=>e.value>0).map((e,t)=>(0,F.jsx)(`div`,{title:`${e.label}: ${J(e.value)}`,className:`h-full transition-all`,style:{width:`${(e.value/n*100).toFixed(1)}%`,background:e.color}},t))})}function BD({sessions:e,projects:t,selectedChat:n,onSelectChat:r}){let[i,a]=(0,S.useState)(new Set),o=e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},s=(0,S.useMemo)(()=>{let t={},n=[];for(let r of e)r.folder?(t[r.folder]||(t[r.folder]=[]),t[r.folder].push(r)):n.push(r);return{sorted:Object.entries(t).sort((e,t)=>t[1].length-e[1].length),noProject:n}},[e]),c=({s:e})=>(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1.5 cursor-pointer transition rounded-sm`,style:{background:n===e.id?`rgba(99,102,241,0.12)`:`transparent`},onMouseEnter:t=>{n!==e.id&&(t.currentTarget.style.background=`var(--c-bg3)`)},onMouseLeave:t=>{n!==e.id&&(t.currentTarget.style.background=`transparent`)},onClick:()=>r(e.id),children:[(0,F.jsx)($h,{source:e.source,size:10}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-[11px] font-medium truncate`,style:{color:`var(--c-white)`},children:e.name||`Untitled`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px]`,style:{color:`var(--c-text3)`},children:[e.totalMessages>0&&(0,F.jsxs)(`span`,{children:[e.totalMessages,`m`]}),e.totalMessages>0&&e.lastUpdatedAt&&(0,F.jsx)(`span`,{children:`·`}),e.lastUpdatedAt&&(0,F.jsx)(`span`,{children:Rh(e.lastUpdatedAt)})]})]})]});return(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 shrink-0`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(Qr,{size:12,style:{color:`var(--c-accent)`}}),(0,F.jsx)(`span`,{className:`text-[12px] font-medium uppercase tracking-wider`,style:{color:`var(--c-text2)`},children:`Sessions`}),(0,F.jsx)(`span`,{className:`text-[10px] ml-auto`,style:{color:`var(--c-text3)`},children:e.length})]}),(0,F.jsxs)(`div`,{className:`flex-1 overflow-y-auto scrollbar-thin py-1`,children:[s.sorted.map(([e,t])=>{let n=i.has(e),r=e.split(`/`).pop();return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1.5 cursor-pointer transition`,onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,onClick:()=>o(e),children:[n?(0,F.jsx)(kr,{size:10,style:{color:`var(--c-text3)`}}):(0,F.jsx)(Or,{size:10,style:{color:`var(--c-text3)`}}),(0,F.jsx)(Jr,{size:10,style:{color:`#818cf8`}}),(0,F.jsx)(`span`,{className:`text-[11px] font-medium truncate flex-1`,style:{color:`var(--c-text2)`},title:e,children:r}),(0,F.jsx)(`span`,{className:`text-[8px]`,style:{color:`var(--c-text3)`},children:t.length})]}),!n&&(0,F.jsx)(`div`,{className:`pl-3`,children:t.map(e=>(0,F.jsx)(c,{s:e},e.id))})]},e)}),s.noProject.length>0&&(0,F.jsxs)(`div`,{children:[s.sorted.length>0&&(0,F.jsx)(`div`,{className:`px-2 py-1.5 text-[10px] uppercase tracking-wider`,style:{color:`var(--c-text3)`},children:`no project`}),(0,F.jsx)(`div`,{className:s.sorted.length>0?`pl-1`:``,children:s.noProject.map(e=>(0,F.jsx)(c,{s:e},e.id))})]})]})]})}function VD(){let{username:e}=vt(),t=gt(),[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)(null),{dark:o}=or(),s=o?`#888`:`#555`,c=o?`rgba(255,255,255,0.04)`:`rgba(0,0,0,0.06)`,l=o?`#555`:`#999`;(0,S.useEffect)(()=>{e&&Ca(e,{limit:200}).then(r)},[e]);let u=(0,S.useCallback)(t=>Da(t,e),[e]);if(!n)return(0,F.jsx)(`div`,{className:`text-sm py-12 text-center`,style:{color:`var(--c-text2)`},children:`loading...`});let d=n.length,f=n.reduce((e,t)=>e+(t.totalMessages||0),0),p=n.reduce((e,t)=>e+(t.totalInputTokens||0),0),m=n.reduce((e,t)=>e+(t.totalOutputTokens||0),0),h=p+m,g=d>0?(f/d).toFixed(1):0,_=d>0?Math.round(h/d):0,v={};for(let e of n)e.source&&(v[e.source]=(v[e.source]||0)+1);let y=Object.entries(v).sort((e,t)=>t[1]-e[1]),b={};for(let e of n)e.folder&&(b[e.folder]||(b[e.folder]={count:0,lastActive:0,messages:0,tokens:0}),b[e.folder].count++,b[e.folder].messages+=e.totalMessages||0,b[e.folder].tokens+=(e.totalInputTokens||0)+(e.totalOutputTokens||0),e.lastUpdatedAt>b[e.folder].lastActive&&(b[e.folder].lastActive=e.lastUpdatedAt));let x=Object.entries(b).sort((e,t)=>t[1].count-e[1].count),C=x.length>0?Math.max(...x.map(([,e])=>e.count)):1,w={};for(let e of n)if(e.models)for(let t of e.models)w[t]=(w[t]||0)+1;let T=Object.entries(w).sort((e,t)=>t[1]-e[1]).slice(0,10),E={};for(let e of n)if(e.toolCalls)for(let t of e.toolCalls)E[t]=(E[t]||0)+1;let D=Object.entries(E).sort((e,t)=>t[1]-e[1]).slice(0,15),O={};for(let e of n){let t=new Date(e.lastUpdatedAt||e.createdAt).toISOString().slice(0,10);O[t]=(O[t]||0)+1}let k=Object.entries(O).sort((e,t)=>e[0].localeCompare(t[0])).slice(-14),A=e=>{a(e)},j=`calc(100vh - 42px)`;return(0,F.jsxs)(`div`,{className:`fade-in flex`,style:{height:j},children:[(0,F.jsx)(`div`,{className:`hidden lg:flex flex-col w-[250px] shrink-0 sticky top-[42px] self-start`,style:{height:j,borderRight:`1px solid var(--c-border)`,background:`var(--c-bg)`},children:(0,F.jsx)(BD,{sessions:n,projects:x,selectedChat:i,onSelectChat:a})}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-y-auto p-4 space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`button`,{onClick:()=>t(`/`),className:`p-1.5 transition hover:bg-[var(--c-card)] rounded-sm`,style:{border:`1px solid var(--c-border)`,color:`var(--c-text2)`},children:(0,F.jsx)(gr,{size:14})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,F.jsx)(`div`,{className:`w-9 h-9 flex items-center justify-center text-[14px] font-bold rounded-sm`,style:{background:`rgba(99,102,241,0.15)`,color:`#818cf8`},children:e.charAt(0).toUpperCase()}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`text-[14px] font-bold`,style:{color:`var(--c-white)`},children:e}),(0,F.jsx)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:y.map(([e])=>(0,F.jsx)($h,{source:e,size:11},e))})]})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`sessions`,value:d}),(0,F.jsx)(K,{label:`messages`,value:J(f),sub:`${g}/session`}),(0,F.jsx)(K,{label:`editors`,value:y.length}),(0,F.jsx)(K,{label:`projects`,value:x.length}),(0,F.jsx)(K,{label:`tokens`,value:J(h),sub:`${J(_)}/session`}),(0,F.jsx)(K,{label:`models`,value:T.length})]}),h>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsx)($,{children:`token usage`}),(0,F.jsxs)(`span`,{className:`text-[11px] font-bold`,style:{color:`var(--c-white)`},children:[J(h),` total`]})]}),(0,F.jsx)(zD,{height:10,segments:[{label:`Input`,value:p,color:`#6366f1`},{label:`Output`,value:m,color:`#a78bfa`}]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mt-1.5 text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#6366f1`}}),` input `,J(p)]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-sm`,style:{background:`#a78bfa`}}),` output `,J(m)]})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-2 gap-3`,children:[y.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`editors`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(Nh,{data:{labels:y.map(([e])=>q(e)),datasets:[{data:y.map(([,e])=>e),backgroundColor:y.map(([e])=>Ih(e)),borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:s,font:{size:9,family:LD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:LD,size:10},titleFont:{family:LD,size:10}}}}})})]}),T.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`models`}),(0,F.jsx)(`div`,{style:{height:160},children:(0,F.jsx)(Nh,{data:{labels:T.map(([e])=>e),datasets:[{data:T.map(([,e])=>e),backgroundColor:RD,borderWidth:0}]},options:{responsive:!0,maintainAspectRatio:!1,cutout:`60%`,plugins:{legend:{position:`right`,labels:{color:s,font:{size:8,family:LD},usePointStyle:!0,pointStyle:`circle`,padding:6}},tooltip:{bodyFont:{family:LD,size:10},titleFont:{family:LD,size:10}}}}})})]})]}),k.length>1&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`daily activity (last 14 days)`}),(0,F.jsx)(`div`,{style:{height:120},children:(0,F.jsx)(Mh,{data:{labels:k.map(([e])=>e.slice(5)),datasets:[{data:k.map(([,e])=>e),backgroundColor:`#6366f1`,borderRadius:2}]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1},tooltip:{bodyFont:{family:LD,size:10},titleFont:{family:LD,size:10}}},scales:{x:{grid:{display:!1},ticks:{color:l,font:{size:8,family:LD}}},y:{grid:{color:c},ticks:{color:l,font:{size:8,family:LD},stepSize:1},beginAtZero:!0}}}})})]}),x.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)($,{children:`projects`}),(0,F.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2 mt-2`,children:x.map(([e,t])=>(0,F.jsxs)(`div`,{className:`card px-3 py-2.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,F.jsx)(Jr,{size:11,style:{color:`#818cf8`}}),(0,F.jsx)(`span`,{className:`text-[12px] font-medium truncate`,style:{color:`var(--c-white)`},children:e.split(`/`).pop()})]}),(0,F.jsx)(`div`,{className:`text-[8px] truncate mb-2`,style:{color:`var(--c-text3)`},children:e}),(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-1 text-center mb-1.5`,children:[(0,F.jsxs)(`div`,{className:`p-1 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsx)(`div`,{className:`text-[11px] font-bold`,style:{color:`var(--c-white)`},children:t.count}),(0,F.jsx)(`div`,{className:`text-[7px]`,style:{color:`var(--c-text3)`},children:`sessions`})]}),(0,F.jsxs)(`div`,{className:`p-1 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsx)(`div`,{className:`text-[11px] font-bold`,style:{color:`var(--c-white)`},children:J(t.messages)}),(0,F.jsx)(`div`,{className:`text-[7px]`,style:{color:`var(--c-text3)`},children:`messages`})]}),(0,F.jsxs)(`div`,{className:`p-1 rounded-sm`,style:{background:`var(--c-code-bg)`},children:[(0,F.jsx)(`div`,{className:`text-[11px] font-bold`,style:{color:`var(--c-white)`},children:J(t.tokens)}),(0,F.jsx)(`div`,{className:`text-[7px]`,style:{color:`var(--c-text3)`},children:`tokens`})]})]}),(0,F.jsx)(`div`,{className:`h-1.5 rounded-full overflow-hidden`,style:{background:`var(--c-code-bg)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${(t.count/C*100).toFixed(0)}%`,background:`#6366f1`}})}),(0,F.jsx)(`div`,{className:`text-[8px] mt-1`,style:{color:`var(--c-text3)`},children:Rh(t.lastActive)})]},e))})]}),D.length>0&&(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`top tools`}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:D.map(([e,t])=>(0,F.jsxs)(`span`,{className:`text-[10px] px-2 py-1 rounded-sm`,style:{background:`var(--c-code-bg)`,color:`var(--c-text2)`},children:[e,` `,(0,F.jsxs)(`span`,{style:{color:`var(--c-text3)`},children:[`×`,t]})]},e))})]}),(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`recent sessions`}),(0,F.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto scrollbar-thin`,children:(0,F.jsx)(`table`,{className:`w-full text-[12px]`,children:(0,F.jsx)(`tbody`,{children:n.slice(0,50).map(e=>(0,F.jsxs)(`tr`,{className:`cursor-pointer transition`,style:{borderBottom:`1px solid var(--c-border)`},onMouseEnter:e=>e.currentTarget.style.background=`var(--c-bg3)`,onMouseLeave:e=>e.currentTarget.style.background=`transparent`,onClick:()=>a(e.id),children:[(0,F.jsx)(`td`,{className:`py-2 px-2 w-[24px]`,children:(0,F.jsx)($h,{source:e.source,size:11})}),(0,F.jsxs)(`td`,{className:`py-2 px-2`,children:[(0,F.jsx)(`div`,{className:`text-[11px] font-medium truncate`,style:{color:`var(--c-white)`},children:e.name||`Untitled`}),(0,F.jsx)(`div`,{className:`text-[10px] truncate`,style:{color:`var(--c-text3)`},children:e.folder?e.folder.split(`/`).pop():``})]}),(0,F.jsx)(`td`,{className:`py-2 px-2 text-[10px] whitespace-nowrap`,style:{color:`var(--c-text3)`},children:e.totalMessages>0&&(0,F.jsxs)(`span`,{children:[e.totalMessages,`m`]})}),(0,F.jsx)(`td`,{className:`py-2 px-2`,children:e.mode&&(0,F.jsx)(`span`,{className:`text-[8px] px-1.5 py-0.5 rounded-sm`,style:{background:`rgba(168,85,247,0.1)`,color:`#a855f7`},children:e.mode})}),(0,F.jsx)(`td`,{className:`py-2 px-2 text-[10px] whitespace-nowrap text-right`,style:{color:`var(--c-text3)`},children:Rh(e.lastUpdatedAt)})]},e.id))})})})]})]}),(0,F.jsx)(`div`,{className:`hidden xl:flex flex-col w-[300px] shrink-0 sticky top-[42px] self-start`,style:{height:j,borderLeft:`1px solid var(--c-border)`,background:`var(--c-bg)`},children:(0,F.jsx)(kD,{onSessionClick:A})}),(0,F.jsx)(iE,{chatId:i,onClose:()=>a(null),fetchFn:u,username:e,extraHeader:(0,F.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 shrink-0`,style:{background:`rgba(99,102,241,0.15)`,color:`#818cf8`},children:e})})]})}Gf.register(tp,Mm,fm,Lm,Vm,Ep);var HD=`JetBrains Mono, monospace`;function UD(e){if(!e)return`—`;let t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function WD(e){return e===`completed`?`#22c55e`:e===`executing`?`#f59e0b`:`var(--c-text3)`}function GD({value:e,total:t,color:n=`#6366f1`}){return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`div`,{className:`flex-1 h-1 rounded-full overflow-hidden`,style:{background:`var(--c-bg3)`},children:(0,F.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${t>0?Math.round(e/t*100):0}%`,background:n}})}),(0,F.jsxs)(`span`,{className:`text-[10px] tabular-nums`,style:{color:`var(--c-text3)`,fontFamily:HD,minWidth:36},children:[e,`/`,t]})]})}function KD({title:e,subtitle:t,content:n,loading:r,onClose:i}){let a=(0,S.useRef)(null);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`fixed inset-0 z-40 transition-opacity`,style:{background:`rgba(0,0,0,0.3)`},onClick:i}),(0,F.jsxs)(`div`,{className:`fixed top-0 right-0 bottom-0 z-50 flex flex-col shadow-2xl sidebar-slide-in cursor-default`,style:{width:`min(620px, 92vw)`,background:`var(--c-bg)`,borderLeft:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 shrink-0`,style:{borderBottom:`1px solid var(--c-border)`},children:[(0,F.jsx)(`button`,{onClick:i,className:`p-1 rounded transition hover:bg-[var(--c-bg3)]`,style:{color:`var(--c-text2)`},children:(0,F.jsx)(Pi,{size:14})}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-[13px] font-semibold`,style:{color:`var(--c-white)`},children:e}),t&&(0,F.jsx)(`div`,{className:`text-[11px] capitalize`,style:{color:`var(--c-text2)`,fontFamily:HD},children:t})]})]}),(0,F.jsxs)(`div`,{ref:a,className:`flex-1 overflow-y-auto scrollbar-thin px-4 py-3`,children:[r&&(0,F.jsx)(`div`,{className:`text-[12px] py-12 text-center`,style:{color:`var(--c-text3)`},children:`Loading…`}),!r&&n===null&&(0,F.jsx)(`div`,{className:`text-[12px] py-12 text-center`,style:{color:`var(--c-text3)`},children:`File not found.`}),!r&&n!==null&&(0,F.jsx)(`pre`,{className:`text-[11px] leading-relaxed whitespace-pre-wrap break-words`,style:{color:`var(--c-text)`,fontFamily:HD},children:n})]})]})]})}var qD={mode:`Mode`,model_profile:`Model profile`,granularity:`Granularity`,parallelization:`Parallelization`,commit_docs:`Commit docs`},JD={research:`Research`,plan_check:`Plan check`,verifier:`Verifier`,nyquist_validation:`Nyquist`,auto_advance:`Auto advance`,ui_phase:`UI phase`,skip_discuss:`Skip discuss`};function YD({folder:e,anchor:t,onClose:n}){let[r,i]=(0,S.useState)(void 0),a=(0,S.useRef)(null);(0,S.useEffect)(()=>{_a(e).then(i).catch(()=>i(null))},[e]),(0,S.useEffect)(()=>{function e(e){a.current&&!a.current.contains(e.target)&&n()}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]);let o=t?t.bottom+6:0,s=t?window.innerWidth-t.right:0;function c(e){return e===!0?(0,F.jsx)(`span`,{style:{color:`#22c55e`},children:`on`}):e===!1?(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`off`}):(0,F.jsx)(`span`,{style:{color:`var(--c-white)`},children:String(e)})}return(0,F.jsxs)(`div`,{ref:a,className:`p-3 shadow-xl text-[11px]`,style:{position:`fixed`,top:o,right:s,zIndex:9999,width:240,background:`var(--c-bg)`,border:`1px solid var(--c-border)`,boxShadow:`0 8px 32px rgba(0,0,0,0.4)`},onClick:e=>e.stopPropagation(),children:[r===void 0&&(0,F.jsx)(`div`,{style:{color:`var(--c-text3)`},children:`Loading…`}),r===null&&(0,F.jsx)(`div`,{style:{color:`var(--c-text3)`},children:`No config.json found.`}),r&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`div`,{className:`space-y-1`,children:Object.entries(qD).map(([e,t])=>e in r?(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:t}),c(r[e])]},e):null)}),r.workflow&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`border-t pt-2`,style:{borderColor:`var(--c-border)`,color:`var(--c-text3)`},children:`workflow`}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1`,children:Object.entries(JD).map(([e,t])=>e in r.workflow?(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-1`,children:[(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:t}),c(r.workflow[e])]},e):null)})]})]})]})}function XD({phase:e,tokenData:t,onOpenFile:n}){let r=e.total_tasks??0,i=e.completed_tasks??0,a=!!e.has_plan,o=!!e.has_research,s=!!e.has_verification,c=e.status??`planned`;return(0,F.jsxs)(`div`,{className:`flex items-center px-3 py-2 border-b text-[12px] hover:bg-[var(--c-bg3)] transition`,style:{borderColor:`var(--c-border)`,gap:0},children:[(0,F.jsx)(`div`,{style:{width:28,flexShrink:0},children:(0,F.jsx)(c===`completed`?Mr:c===`executing`?ii:Pr,{size:12,style:{color:WD(c)},className:c===`executing`?`animate-spin`:``})}),(0,F.jsx)(`div`,{style:{width:32,flexShrink:0},children:(0,F.jsx)(`span`,{className:`text-[10px] font-bold tabular-nums`,style:{color:`var(--c-text3)`,fontFamily:HD},children:e.phase_number??`?`})}),(0,F.jsx)(`div`,{className:`flex-1 min-w-0 pr-3`,children:(0,F.jsx)(`span`,{className:`block truncate capitalize text-[12px]`,style:{color:`var(--c-white)`},children:e.phase_name})}),(0,F.jsx)(`div`,{style:{width:100,flexShrink:0,paddingRight:12},children:r>0?(0,F.jsx)(GD,{value:i,total:r,color:WD(c)}):null}),(0,F.jsxs)(`div`,{style:{width:88,flexShrink:0},className:`flex items-center gap-1`,children:[a&&(0,F.jsxs)(`button`,{onClick:()=>n(e,`plan`),className:`flex items-center gap-1 px-1.5 py-px text-[10px] transition hover:opacity-80 cursor-pointer`,style:{background:`rgba(99,102,241,0.12)`,color:`#818cf8`},title:`View PLAN.md`,children:[(0,F.jsx)(Gr,{size:9}),`plan`]}),o&&(0,F.jsx)(`button`,{onClick:()=>n(e,`research`),className:`px-1 py-px transition hover:opacity-80 cursor-pointer`,style:{background:`rgba(245,158,11,0.1)`,color:`#f59e0b`},title:`View RESEARCH.md`,children:(0,F.jsx)(yr,{size:9})}),s&&(0,F.jsx)(`button`,{onClick:()=>n(e,`verification`),className:`px-1 py-px transition hover:opacity-80 cursor-pointer`,style:{background:`rgba(34,197,94,0.1)`,color:`#22c55e`},title:`View VERIFICATION.md`,children:(0,F.jsx)(bi,{size:9})})]}),(0,F.jsx)(`div`,{style:{width:64,flexShrink:0,textAlign:`right`},children:t&&t.cost>0?(0,F.jsx)(`span`,{className:`text-[10px] tabular-nums`,style:{color:`var(--c-text2)`,fontFamily:HD},children:Lh(t.cost)}):null}),(0,F.jsx)(`div`,{style:{width:56,flexShrink:0,textAlign:`right`},children:(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:UD(e.last_modified)})})]})}function ZD(e){return e.total_phases===0?`var(--c-border)`:e.completed_phases===e.total_phases?`#22c55e`:e.completed_phases>0?`#f59e0b`:`var(--c-border)`}function QD({project:e,isExpanded:t,onToggle:n,onOpenFile:r,onOpenConfig:i,onOpenState:a}){let[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(null),u=(0,S.useRef)(null),d=(0,S.useRef)(null),f=e.total_phases>0?Math.round(e.completed_phases/e.total_phases*100):0,p=e.total_phases-e.completed_phases;return(0,S.useEffect)(()=>{t&&o===null&&(ma(e.folder).then(s),va(e.folder).then(e=>{let t={};for(let n of e)t[n.id]=n;l(t)}).catch(()=>l({})))},[t,o,e.folder]),(0,F.jsxs)(`div`,{className:`card overflow-hidden`,style:{borderLeft:`2px solid ${ZD(e)}`},children:[(0,F.jsxs)(`div`,{className:`flex items-center w-full px-3 py-3`,style:{gap:0},children:[(0,F.jsx)(`button`,{onClick:n,className:`flex items-center justify-center hover:bg-[var(--c-bg3)] transition rounded cursor-pointer`,style:{width:24,height:24,flexShrink:0,color:`var(--c-text3)`},children:t?(0,F.jsx)(Or,{size:13}):(0,F.jsx)(kr,{size:13})}),(0,F.jsxs)(`button`,{onClick:n,className:`flex-1 min-w-0 text-left px-2 cursor-pointer`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`text-[13px] font-semibold truncate`,style:{color:`var(--c-white)`},children:e.name}),e.milestone&&(0,F.jsx)(`span`,{className:`text-[10px] px-1.5 py-px shrink-0`,style:{background:`rgba(99,102,241,0.12)`,color:`#818cf8`},children:e.milestone})]}),(0,F.jsx)(`div`,{className:`text-[10px] truncate mt-0.5`,style:{color:`var(--c-text3)`,fontFamily:HD},children:e.folder})]}),(0,F.jsx)(`div`,{style:{width:36,flexShrink:0,textAlign:`right`},children:(0,F.jsxs)(`span`,{className:`text-[11px] font-bold tabular-nums`,style:{color:f===100?`#22c55e`:f>0?`#f59e0b`:`var(--c-text3)`,fontFamily:HD},children:[f,`%`]})}),(0,F.jsx)(`div`,{style:{width:112,flexShrink:0,padding:`0 10px`},children:(0,F.jsx)(GD,{value:e.completed_phases,total:e.total_phases,color:f===100?`#22c55e`:`#6366f1`})}),(0,F.jsxs)(`div`,{style:{width:80,flexShrink:0},className:`flex items-center gap-1`,children:[e.completed_phases>0&&(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] px-1.5 py-px`,style:{background:`rgba(34,197,94,0.08)`,color:`#22c55e`},children:[(0,F.jsx)(Mr,{size:9}),` `,e.completed_phases]}),p>0&&(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] px-1.5 py-px`,style:{background:`rgba(255,255,255,0.04)`,color:`var(--c-text3)`},children:[(0,F.jsx)(Pr,{size:9}),` `,p]})]}),(0,F.jsxs)(`div`,{style:{width:52,flexShrink:0},className:`flex items-center gap-2`,children:[e.todos>0&&(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},title:`Todos / Seeds`,children:[(0,F.jsx)(ni,{size:10}),` `,e.todos]}),e.notes>0&&(0,F.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px]`,style:{color:`var(--c-text3)`},title:`Quick tasks`,children:[(0,F.jsx)(Ci,{size:10}),` `,e.notes]})]}),(0,F.jsx)(`div`,{style:{width:60,flexShrink:0,textAlign:`right`},children:(0,F.jsx)(`span`,{className:`text-[11px] tabular-nums`,style:{color:e.total_cost>0?`#a78bfa`:`var(--c-text3)`,fontFamily:HD},children:e.total_cost>0?Lh(e.total_cost):`—`})}),(0,F.jsx)(`div`,{style:{width:56,flexShrink:0,textAlign:`right`},children:(0,F.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:UD(e.last_modified)})}),(0,F.jsxs)(`div`,{style:{width:52,flexShrink:0},className:`flex items-center justify-end gap-0.5`,onClick:e=>e.stopPropagation(),children:[(0,F.jsx)(`button`,{ref:d,onClick:()=>a(e.folder,e.name),className:`p-1 rounded transition hover:bg-[var(--c-bg3)] cursor-pointer`,style:{color:`var(--c-text3)`},title:`View STATE.md`,children:(0,F.jsx)(ei,{size:13})}),(0,F.jsx)(`button`,{ref:u,onClick:()=>i(e.folder,u.current?.getBoundingClientRect()),className:`p-1 rounded transition hover:bg-[var(--c-bg3)] cursor-pointer`,style:{color:`var(--c-text3)`},title:`GSD config`,children:(0,F.jsx)(Nr,{size:13})})]})]}),t&&(0,F.jsxs)(`div`,{className:`border-t`,style:{borderColor:`var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center px-3 py-1 text-[10px]`,style:{background:`var(--c-bg2)`,color:`var(--c-text3)`,gap:0},children:[(0,F.jsx)(`div`,{style:{width:28,flexShrink:0}}),(0,F.jsx)(`div`,{style:{width:32,flexShrink:0},children:`#`}),(0,F.jsx)(`div`,{className:`flex-1 pr-3`,children:`phase`}),(0,F.jsx)(`div`,{style:{width:100,flexShrink:0,paddingRight:12},children:`plans`}),(0,F.jsx)(`div`,{style:{width:88,flexShrink:0},children:`artifacts`}),(0,F.jsx)(`div`,{style:{width:64,flexShrink:0,textAlign:`right`},children:`est. cost`}),(0,F.jsx)(`div`,{style:{width:56,flexShrink:0,textAlign:`right`},children:`updated`})]}),o===null?(0,F.jsx)(`div`,{className:`px-4 py-3 text-[12px]`,style:{color:`var(--c-text3)`},children:`Loading phases…`}):o.length===0?(0,F.jsx)(`div`,{className:`px-4 py-3 text-[12px]`,style:{color:`var(--c-text3)`},children:`No phases found.`}):o.map(t=>(0,F.jsx)(XD,{phase:t,tokenData:c?.[t.id]??null,onOpenFile:(t,n)=>r(t,e.folder,n)},t.id))]})]})}function $D(){let{dark:e}=or(),[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(null),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)(null),[d,f]=(0,S.useState)(null),[p,m]=(0,S.useState)(!0),h=e?`#888`:`#555`,g=e?`#555`:`#999`,_=e?`rgba(255,255,255,0.03)`:`rgba(0,0,0,0.06)`;(0,S.useEffect)(()=>{Promise.all([pa(),ga()]).then(([e,t])=>{n(e),i(t),m(!1),o({totalCost:(e||[]).reduce((e,t)=>e+(t.total_cost||0),0)})}).catch(()=>m(!1))},[]);function v(e,t){f(n=>n?.folder===e?null:{folder:e,anchor:t})}function y(e,t,n){let r=e.id?.split(`::`)?.[1]||``,i=e.phase_name??e.name??``;u({title:{plan:`PLAN.md`,research:`RESEARCH.md`,verification:`VERIFICATION.md`,summary:`SUMMARY.md`}[n]??n.toUpperCase()+`.md`,subtitle:i,content:null,loading:!0}),n===`plan`?ha(t,r).then(e=>u(t=>t?{...t,content:e?.content??null,loading:!1}:null)).catch(()=>u(e=>e?{...e,loading:!1}:null)):ya(t,n,r).then(e=>u(t=>t?{...t,content:e?.content??null,loading:!1}:null)).catch(()=>u(e=>e?{...e,loading:!1}:null))}function b(e,t){u({title:`STATE.md`,subtitle:t,content:null,loading:!0}),ya(e,`state`).then(e=>u(t=>t?{...t,content:e?.content??null,loading:!1}:null)).catch(()=>u(e=>e?{...e,loading:!1}:null))}if(p)return(0,F.jsx)(ja,{label:`Loading GSD projects...`});if(!t||t.length===0)return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsx)(sE,{icon:Ei,title:`GSD Workflow`}),(0,F.jsxs)(`div`,{className:`card p-8 text-center space-y-3`,children:[(0,F.jsx)(Ei,{size:32,style:{color:`var(--c-text3)`,margin:`0 auto`}}),(0,F.jsx)(`div`,{className:`text-[14px] font-semibold`,style:{color:`var(--c-white)`},children:`No GSD projects found`}),(0,F.jsxs)(`div`,{className:`text-[12px] max-w-sm mx-auto`,style:{color:`var(--c-text2)`},children:[`GSD (Get Shit Done) is a structured AI workflow system that stores project plans and phases inside a `,(0,F.jsx)(`code`,{style:{fontFamily:HD},children:`.planning/`}),` directory. Run a data scan after initializing a GSD project and it will appear here.`]})]})]});let x=r&&r.totalPhases>0?Math.round(r.completedPhases/r.totalPhases*100):0,C={completed:r?.completedPhases??0,executing:r?.executingPhases??0,planned:r?.plannedPhases??0},w={labels:[`Completed`,`Executing`,`Planned`],datasets:[{data:[C.completed,C.executing,C.planned],backgroundColor:[`#22c55e`,`#f59e0b`,`rgba(255,255,255,0.08)`],borderWidth:0}]},T=[...t].sort((e,t)=>t.total_phases-e.total_phases).slice(0,8),E={labels:T.map(e=>e.name.length>16?e.name.slice(0,15)+`…`:e.name),datasets:[{label:`Completed`,data:T.map(e=>e.completed_phases),backgroundColor:`#22c55e`,borderRadius:2},{label:`Remaining`,data:T.map(e=>e.total_phases-e.completed_phases),backgroundColor:`rgba(99,102,241,0.3)`,borderRadius:2}]},D={responsive:!0,maintainAspectRatio:!1,cutout:`72%`,plugins:{legend:{display:!1},tooltip:{bodyFont:{family:HD,size:10},titleFont:{family:HD,size:10}}}},O={responsive:!0,maintainAspectRatio:!1,indexAxis:`y`,scales:{x:{stacked:!0,grid:{color:_},ticks:{color:g,font:{size:8,family:HD}}},y:{stacked:!0,grid:{display:!1},ticks:{color:h,font:{size:8,family:HD}}}},plugins:{legend:{display:!1},tooltip:{bodyFont:{family:HD,size:10},titleFont:{family:HD,size:10}}}};return(0,F.jsxs)(`div`,{className:`fade-in space-y-3`,children:[(0,F.jsx)(sE,{icon:Ei,title:`GSD Workflow`}),(0,F.jsxs)(`div`,{className:`grid gap-2`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`},children:[(0,F.jsx)(K,{label:`projects`,value:r?.totalProjects??t.length}),(0,F.jsx)(K,{label:`total phases`,value:r?.totalPhases??`—`}),(0,F.jsx)(K,{label:`completed`,value:r?.completedPhases??`—`}),(0,F.jsx)(K,{label:`completion`,value:r?.totalPhases>0?`${x}%`:`—`}),(0,F.jsx)(K,{label:`total cost`,value:a?Lh(a.totalCost):`—`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-3`,children:[(0,F.jsxs)(`div`,{className:`card p-3`,children:[(0,F.jsx)($,{children:`phase status`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,F.jsx)(`div`,{style:{height:110,width:110,flexShrink:0},children:(0,F.jsx)(Nh,{data:w,options:D})}),(0,F.jsx)(`div`,{className:`space-y-2 text-[11px]`,children:[{label:`Completed`,count:C.completed,color:`#22c55e`},{label:`Executing`,count:C.executing,color:`#f59e0b`},{label:`Planned`,count:C.planned,color:`var(--c-text3)`}].map(({label:e,count:t,color:n})=>(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{background:n}}),(0,F.jsx)(`span`,{style:{color:`var(--c-text2)`},children:e}),(0,F.jsx)(`span`,{className:`ml-auto font-bold tabular-nums`,style:{color:n,fontFamily:HD},children:t})]},e))})]})]}),(0,F.jsxs)(`div`,{className:`card p-3 lg:col-span-2`,children:[(0,F.jsxs)($,{children:[`projects `,(0,F.jsx)(`span`,{style:{color:`var(--c-text3)`},children:`by phases`})]}),(0,F.jsx)(`div`,{style:{height:130},children:(0,F.jsx)(Mh,{data:E,options:O})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4 mt-2 text-[10px]`,style:{color:`var(--c-text3)`},children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm`,style:{background:`#22c55e`}}),` Completed`]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm`,style:{background:`rgba(99,102,241,0.3)`}}),` Remaining`]})]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)($,{children:`projects`}),t.map(e=>(0,F.jsx)(QD,{project:e,isExpanded:s===e.folder,onToggle:()=>c(t=>t===e.folder?null:e.folder),onOpenFile:y,onOpenConfig:v,onOpenState:b},e.folder))]}),d&&(0,F.jsx)(YD,{folder:d.folder,anchor:d.anchor,onClose:()=>f(null)}),l&&(0,F.jsx)(KD,{title:l.title,subtitle:l.subtitle,content:l.content,loading:l.loading,onClose:()=>u(null)})]})}function eO({icon:e,label:t,items:n}){let[r,i]=(0,S.useState)(!1),a=pt(),o=n.some(e=>e.to===a.pathname),s=(0,S.useRef)(null);return(0,F.jsxs)(`div`,{className:`relative`,onMouseEnter:()=>{clearTimeout(s.current),i(!0)},onMouseLeave:()=>{s.current=setTimeout(()=>i(!1),150)},children:[(0,F.jsxs)(`button`,{className:`flex items-center gap-1.5 px-2.5 py-1 text-[12px] rounded transition ${o?`bg-[var(--c-card)] text-[var(--c-white)]`:`text-[var(--c-text2)] hover:text-[var(--c-white)]`}`,children:[(0,F.jsx)(e,{size:12}),t,(0,F.jsx)(Or,{size:10,style:{opacity:.5}})]}),r&&(0,F.jsx)(`div`,{className:`absolute top-full left-0 mt-1 py-1 rounded shadow-lg min-w-[160px] z-[100]`,style:{background:`var(--c-bg)`,border:`1px solid var(--c-border)`},children:n.map(({to:e,icon:t,label:n})=>(0,F.jsxs)(Ln,{to:e,onClick:()=>i(!1),className:({isActive:e})=>`flex items-center gap-2 px-3 py-1.5 text-[12px] transition ${e?`bg-[var(--c-bg3)] text-[var(--c-white)]`:`text-[var(--c-text2)] hover:text-[var(--c-white)] hover:bg-[var(--c-bg3)]`}`,children:[(0,F.jsx)(t,{size:12}),n]},e))})]})}function tO(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)(null),{live:i,toggle:a}=ka(),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(!!L()),f=(0,S.useRef)(null),{dark:p,toggle:m}=or(),[h,g]=(0,S.useState)(!1),[_,v]=(0,S.useState)(!1),[y,b]=(0,S.useState)(0),x=(0,S.useRef)(null);(0,S.useEffect)(()=>{zi(()=>d(!1))},[]),(0,S.useEffect)(()=>{xa().then(e=>{s(e.mode||`local`),l(!!e.auth)})},[]);let C=(0,S.useCallback)(()=>{Ui().then(t).catch(()=>{})},[]);(0,S.useEffect)(()=>{o===`local`&&C()},[o]);let w=(0,S.useCallback)(()=>{C(),b(e=>e+1)},[C]),T=(0,S.useCallback)(async e=>{await Qi(e),w()},[w]);(0,S.useEffect)(()=>(i&&o===`local`?(Ki().then(e=>{x.current=e.token}).catch(()=>{}),f.current=setInterval(()=>{Ki().then(e=>{x.current!==null&&e.token!==x.current&&w(),x.current=e.token}).catch(()=>{})},6e4)):(f.current&&clearInterval(f.current),f.current=null),()=>{f.current&&clearInterval(f.current)}),[i,o,w]);let E=async()=>{r({scanned:0,total:0});try{await T(e=>r({scanned:e.scanned,total:e.total}))}catch(e){console.error(e)}r(null)},D=o===`relay`,O=D&&c&&!u,k=pt().pathname===`/artifacts`,A=D?[{to:`/`,icon:Mi,label:`Team`}]:[{to:`/`,icon:mr,label:`Dashboard`},{to:`/sessions`,icon:si,label:`Sessions`},{to:`/projects`,icon:Jr,label:`Projects`},{icon:Vr,label:`Costs`,children:[{to:`/costs`,icon:Vr,label:`Cost Analysis`},{to:`/subscriptions`,icon:zr,label:`Subscriptions`}]},{icon:wr,label:`Insights`,children:[{to:`/analysis`,icon:wr,label:`Deep Analysis`},{to:`/compare`,icon:Yr,label:`Compare`}]},{to:`/artifacts`,icon:li,label:`Artifacts`},{to:`/gsd`,icon:Ei,label:`GSD`},{to:`/mcps`,icon:di,label:`MCPs`},{to:`/sql`,icon:Br,label:`SQL`}];return O?(0,F.jsx)(Ma,{onSuccess:()=>d(!0)}):(0,F.jsxs)(`div`,{className:`min-h-screen`,children:[(0,F.jsxs)(`header`,{className:`border-b px-4 py-1.5 flex items-center gap-3 sticky top-0 z-50 backdrop-blur-xl`,style:{borderColor:`var(--c-border)`,background:`var(--c-header)`},children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs font-bold tracking-tight`,style:{color:`var(--c-white)`},children:[(0,F.jsx)(Aa,{size:18}),`Agentlytics`,D&&(0,F.jsx)(`span`,{className:`ml-1.5 text-[10px] font-medium px-1.5 py-0.5`,style:{background:`rgba(99,102,241,0.15)`,color:`#818cf8`},children:`relay`})]}),(0,F.jsx)(`nav`,{className:`flex gap-0.5 ml-2`,children:A.map(e=>e.children?(0,F.jsx)(eO,{icon:e.icon,label:e.label,items:e.children},e.label):(0,F.jsxs)(Ln,{to:e.to,end:e.to===`/`,className:({isActive:e})=>`flex items-center gap-1.5 px-2.5 py-1 text-[12px] rounded transition ${e?`bg-[var(--c-card)] text-[var(--c-white)]`:`text-[var(--c-text2)] hover:text-[var(--c-white)]`}`,children:[(0,F.jsx)(e.icon,{size:12}),e.label]},e.to))}),(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[!D&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{onClick:a,className:`flex items-center gap-1.5 px-2 py-0.5 text-[11px] transition`,style:{color:i?`#22c55e`:`var(--c-text3)`,border:i?`1px solid rgba(34,197,94,0.3)`:`1px solid var(--c-border)`,background:i?`rgba(34,197,94,0.08)`:`transparent`},title:i?`Disable live refresh`:`Enable live refresh (every 60s)`,children:[(0,F.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${i?`pulse-dot`:``}`,style:{background:i?`#22c55e`:`var(--c-text3)`}}),`Live`]}),(0,F.jsxs)(`button`,{onClick:E,disabled:!!n,className:`flex items-center gap-1 px-2 py-0.5 text-[11px] rounded transition hover:bg-[var(--c-card)]`,style:{color:`var(--c-text2)`,border:`1px solid var(--c-border)`},title:`Run an incremental pass and re-read`,children:[(0,F.jsx)(mi,{size:10,className:n?`animate-spin`:``}),n?`Refetching (${n.scanned}/${n.total})...`:`Refetch`]}),(0,F.jsx)(`span`,{className:`text-[11px]`,style:{color:`var(--c-text2)`},children:e?`${e.totalChats} sessions`:`...`})]}),D&&(0,F.jsxs)(`button`,{onClick:()=>{g(!0),v(!1)},className:`flex items-center gap-1.5 px-2 py-0.5 text-[11px] transition hover:bg-[var(--c-card)]`,style:{color:`#818cf8`,border:`1px solid var(--c-border)`},title:`MCP Connection`,children:[(0,F.jsx)(di,{size:10}),`Connect`]}),(0,F.jsx)(Ln,{to:`/settings`,className:`p-1 rounded transition hover:bg-[var(--c-card)]`,style:({isActive:e})=>({color:e?`#6366f1`:`var(--c-text2)`}),title:`Settings`,children:(0,F.jsx)(vi,{size:13})}),(0,F.jsx)(`button`,{onClick:m,className:`p-1 rounded transition hover:bg-[var(--c-card)]`,style:{color:`var(--c-text2)`},title:p?`Light mode`:`Dark mode`,children:p?(0,F.jsx)(wi,{size:13}):(0,F.jsx)(ci,{size:13})})]})]}),n&&(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-1.5 text-[12px]`,style:{background:`rgba(234,179,8,0.08)`,borderBottom:`1px solid rgba(234,179,8,0.15)`,color:`#ca8a04`},children:[(0,F.jsx)(ki,{size:12}),(0,F.jsx)(`span`,{children:`Devin, Devin Next, and Antigravity require their app to be running during refetch — otherwise their sessions won't be detected.`})]}),(0,F.jsx)(`main`,{className:D?`px-0`:k?`p-0 overflow-hidden`:`p-4 max-w-[1400px] mx-auto`,children:o===null?(0,F.jsx)(ja,{label:`Loading...`}):D?(0,F.jsxs)(Wt,{children:[(0,F.jsx)(Ht,{path:`/`,element:(0,F.jsx)(ID,{})}),(0,F.jsx)(Ht,{path:`/relay`,element:(0,F.jsx)(ID,{})}),(0,F.jsx)(Ht,{path:`/relay/user/:username`,element:(0,F.jsx)(VD,{})})]}):(0,F.jsxs)(Wt,{children:[(0,F.jsx)(Ht,{path:`/`,element:(0,F.jsx)(dE,{overview:e,refreshKey:y})}),(0,F.jsx)(Ht,{path:`/projects`,element:(0,F.jsx)(ME,{overview:e})}),(0,F.jsx)(Ht,{path:`/projects/detail`,element:(0,F.jsx)(BE,{})}),(0,F.jsx)(Ht,{path:`/sessions`,element:(0,F.jsx)(pE,{overview:e})}),(0,F.jsx)(Ht,{path:`/costs`,element:(0,F.jsx)(UE,{overview:e})}),(0,F.jsx)(Ht,{path:`/analysis`,element:(0,F.jsx)(TE,{overview:e})}),(0,F.jsx)(Ht,{path:`/compare`,element:(0,F.jsx)(kE,{overview:e})}),(0,F.jsx)(Ht,{path:`/subscriptions`,element:(0,F.jsx)(SD,{})}),(0,F.jsx)(Ht,{path:`/artifacts`,element:(0,F.jsx)(sD,{})}),(0,F.jsx)(Ht,{path:`/mcps`,element:(0,F.jsx)(ED,{})}),(0,F.jsx)(Ht,{path:`/sql`,element:(0,F.jsx)(KE,{})}),(0,F.jsx)(Ht,{path:`/gsd`,element:(0,F.jsx)($D,{})}),(0,F.jsx)(Ht,{path:`/settings`,element:(0,F.jsx)(cD,{})})]})}),(0,F.jsxs)(`footer`,{className:`border-t mt-8 px-4 py-3 flex items-center justify-between text-[11px]${k?` hidden`:``}`,style:{borderColor:`var(--c-border)`,color:`var(--c-text3)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsxs)(`a`,{href:`https://github.com/f/agentlytics`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 hover:text-[var(--c-text)] transition`,children:[(0,F.jsx)(Xr,{size:11}),(0,F.jsx)(`span`,{children:`GitHub`})]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(Di,{size:11}),(0,F.jsx)(`code`,{style:{fontFamily:`JetBrains Mono, monospace`},children:`npx agentlytics`})]})]}),(0,F.jsxs)(`span`,{children:[`built by `,(0,F.jsx)(`a`,{href:`https://github.com/f`,target:`_blank`,rel:`noopener noreferrer`,className:`hover:text-[var(--c-text)] transition`,style:{color:`var(--c-text2)`},children:`fkadev`})]})]}),h&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`fixed inset-0 z-[60]`,style:{background:`rgba(0,0,0,0.5)`},onClick:()=>g(!1)}),(0,F.jsxs)(`div`,{className:`fixed z-[70] w-[440px] max-w-[90vw] p-5 rounded shadow-2xl`,style:{top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,background:`var(--c-bg)`,border:`1px solid var(--c-border)`},children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,F.jsxs)(`div`,{className:`text-[13px] font-bold`,style:{color:`var(--c-white)`},children:[(0,F.jsx)(di,{size:13,className:`inline mr-1.5`,style:{color:`#818cf8`}}),`Connection Config`]}),(0,F.jsx)(`button`,{onClick:()=>g(!1),className:`text-[18px] leading-none px-1 hover:opacity-70 transition`,style:{color:`var(--c-text3)`},children:`×`})]}),(0,F.jsx)(`div`,{className:`text-[12px] font-medium mb-1.5`,style:{color:`var(--c-white)`},children:`MCP Config`}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,F.jsx)(`div`,{className:`text-[10px]`,style:{color:`var(--c-text3)`},children:`Add to your AI client's MCP settings`}),(0,F.jsx)(`button`,{onClick:()=>{let e=localStorage.getItem(`agentlytics_relay_token`),t={url:`${window.location.origin}/mcp`};e&&(t.headers={Authorization:`Bearer ${e}`});let n=JSON.stringify({mcpServers:{agentlytics:t}},null,2);navigator.clipboard.writeText(n),v(!0),setTimeout(()=>v(!1),2e3)},className:`flex items-center gap-1 px-1.5 py-0.5 text-[10px] transition hover:bg-[var(--c-bg3)]`,style:{border:`1px solid var(--c-border)`,color:_?`#22c55e`:`var(--c-text2)`},children:_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Dr,{size:9}),` Copied`]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Lr,{size:9}),` Copy`]})})]}),(0,F.jsx)(`pre`,{className:`text-[11px] px-3 py-2 overflow-x-auto mb-4`,style:{background:`var(--c-bg3)`,border:`1px solid var(--c-border)`,color:`var(--c-text)`,fontFamily:`JetBrains Mono, monospace`,lineHeight:1.6},children:localStorage.getItem(`agentlytics_relay_token`)?`{\n "mcpServers": {\n "agentlytics": {\n "url": "${window.location.origin}/mcp",\n "headers": { "Authorization": "Bearer ${localStorage.getItem(`agentlytics_relay_token`)}" }\n }\n }\n}`:`{\n "mcpServers": {\n "agentlytics": {\n "url": "${window.location.origin}/mcp"\n }\n }\n}`}),(0,F.jsx)(`div`,{className:`text-[12px] font-medium mb-1.5`,style:{color:`var(--c-white)`},children:`Team Sharing`}),(0,F.jsx)(`div`,{className:`text-[10px] mb-1`,style:{color:`var(--c-text3)`},children:`Relay join is not supported in memhouse. Each member owns their own rooms and shares by granting SELECT on them (memhouse share). A kernel house (memhouse/delivery/kernel-install.md) requires the Ultimagent kernel, not yet public.`}),(0,F.jsx)(`pre`,{className:`text-[11px] px-3 py-2 overflow-x-auto`,style:{background:`var(--c-bg3)`,border:`1px solid var(--c-border)`,color:`var(--c-text)`,fontFamily:`JetBrains Mono, monospace`,lineHeight:1.6},children:`# each member ships with their own credential:
77
77
  MEMHOUSE_URL=<realm-url> MEMHOUSE_USER=<member> MEMHOUSE_PASSWORD=<credential> \\
78
- memhouse ship --loop`})]})]})]})}var nO=`memhouse_dashboard_token`;function rO(){let e=/(?:^#|&)token=([0-9a-f]{64})(?:&|$)/.exec(window.location.hash||``);if(e){try{window.sessionStorage.setItem(nO,e[1])}catch{}window.history.replaceState(null,``,window.location.pathname+window.location.search)}}function iO(){try{return window.sessionStorage.getItem(nO)}catch{return null}}function aO(){let e=window.fetch.bind(window);window.fetch=(t,n={})=>{let r=new URL(typeof t==`string`?t:t.url,window.location.href);if(r.origin===window.location.origin&&r.pathname.startsWith(`/api/`)){let e=iO();if(e){let r=new Headers(n.headers||(typeof t==`string`?void 0:t.headers));r.set(`Authorization`,`Bearer ${e}`),n={...n,headers:r}}}return e(t,n)}}rO(),aO();function oO(){return(0,F.jsxs)(`div`,{style:{fontFamily:`system-ui, sans-serif`,maxWidth:`34em`,margin:`4em auto`,lineHeight:1.5},children:[(0,F.jsx)(`h1`,{style:{fontSize:`1.3em`},children:`memhouse dashboard`}),(0,F.jsxs)(`p`,{children:[`Open the dashboard with `,(0,F.jsx)(`code`,{children:`memhouse dashboard`}),`.`]})]})}rr.createRoot(document.getElementById(`root`)).render((0,F.jsx)(S.StrictMode,{children:iO()?(0,F.jsx)(ar,{children:(0,F.jsx)(Pn,{children:(0,F.jsx)(tO,{})})}):(0,F.jsx)(oO,{})}));
78
+ memhouse ship --loop`})]})]})]})}var nO=`memhouse_dashboard_token`,rO=null;function iO(){let e=/(?:^#|&)token=([0-9a-f]{64})(?:&|$)/.exec(window.location.hash||``);if(e){rO=e[1];try{window.sessionStorage.setItem(nO,e[1])}catch{}window.history.replaceState(null,``,window.location.pathname+window.location.search)}}function aO(){try{return window.sessionStorage.getItem(nO)||rO}catch{return rO}}function oO(){let e=window.fetch.bind(window);window.fetch=(t,n={})=>{let r=new URL(typeof t==`string`?t:t.url,window.location.href);if(r.origin===window.location.origin&&r.pathname.startsWith(`/api/`)){let e=aO();if(e){let r=new Headers(n.headers||(typeof t==`string`?void 0:t.headers));r.set(`Authorization`,`Bearer ${e}`),n={...n,headers:r}}}return e(t,n)}}iO(),oO();function sO(){return(0,F.jsxs)(`div`,{style:{fontFamily:`system-ui, sans-serif`,maxWidth:`34em`,margin:`4em auto`,lineHeight:1.5},children:[(0,F.jsx)(`h1`,{style:{fontSize:`1.3em`},children:`memhouse dashboard`}),(0,F.jsxs)(`p`,{children:[`Open the dashboard with `,(0,F.jsx)(`code`,{children:`memhouse dashboard`}),`.`]})]})}rr.createRoot(document.getElementById(`root`)).render((0,F.jsx)(S.StrictMode,{children:aO()?(0,F.jsx)(ar,{children:(0,F.jsx)(Pn,{children:(0,F.jsx)(tO,{})})}):(0,F.jsx)(sO,{})}));
package/public/index.html CHANGED
@@ -7,7 +7,7 @@
7
7
  <link rel="preconnect" href="https://fonts.googleapis.com" />
8
8
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9
9
  <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
10
- <script type="module" crossorigin src="/assets/index-CQSJ3nhV.js"></script>
10
+ <script type="module" crossorigin src="/assets/index-CcNnhfM3.js"></script>
11
11
  <link rel="stylesheet" crossorigin href="/assets/index-DV6ONi_F.css">
12
12
  </head>
13
13
  <body>