@statforge/claudestat 1.6.1 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +36 -3
  2. package/dashboard/dist/assets/AnalyticsView-DDGLDoCN.js +7 -0
  3. package/dashboard/dist/assets/HistoryView-DkPfrNrv.js +1 -0
  4. package/dashboard/dist/assets/LineChart-BOWYkkEW.js +2 -0
  5. package/dashboard/dist/assets/ProjectsView-VRoRiEL4.js +6 -0
  6. package/dashboard/dist/assets/SystemView-B2zbIxhY.js +1 -0
  7. package/dashboard/dist/assets/TopView-C2qdsy0Y.js +1 -0
  8. package/dashboard/dist/assets/index-CMhe3KaT.js +84 -0
  9. package/dashboard/dist/assets/shared-BbBtsdh1.js +1 -0
  10. package/dashboard/dist/assets/{vendor-lucide-Cym0q5l_.js → vendor-lucide-ClCW-axQ.js} +79 -64
  11. package/dashboard/dist/assets/{vendor-react-B_Jzs0gY.js → vendor-react-gHSHIE2L.js} +1 -1
  12. package/dashboard/dist/index.html +3 -3
  13. package/dist/config.d.ts +7 -0
  14. package/dist/config.js +36 -0
  15. package/dist/daemon.js +113 -9
  16. package/dist/db.d.ts +87 -2
  17. package/dist/db.js +325 -65
  18. package/dist/doctor.js +21 -3
  19. package/dist/enricher.d.ts +3 -2
  20. package/dist/enricher.js +10 -5
  21. package/dist/export.d.ts +2 -1
  22. package/dist/export.js +41 -6
  23. package/dist/index.js +406 -20
  24. package/dist/insights.d.ts +1 -0
  25. package/dist/insights.js +26 -0
  26. package/dist/install.js +28 -1
  27. package/dist/intelligence.d.ts +66 -4
  28. package/dist/intelligence.js +205 -17
  29. package/dist/logger.d.ts +6 -0
  30. package/dist/logger.js +49 -0
  31. package/dist/notifier.d.ts +15 -0
  32. package/dist/notifier.js +26 -0
  33. package/dist/paths.d.ts +23 -0
  34. package/dist/paths.js +42 -0
  35. package/dist/pricing.d.ts +2 -0
  36. package/dist/pricing.js +12 -1
  37. package/dist/routes/events.js +136 -5
  38. package/dist/routes/helpers.d.ts +5 -0
  39. package/dist/routes/helpers.js +21 -1
  40. package/dist/routes/history.js +6 -2
  41. package/dist/routes/intents.d.ts +1 -0
  42. package/dist/routes/intents.js +155 -0
  43. package/dist/routes/misc.js +150 -4
  44. package/dist/routes/opencode-reader.js +39 -3
  45. package/dist/routes/projects.js +19 -1
  46. package/dist/routes/replay.d.ts +1 -0
  47. package/dist/routes/replay.js +29 -0
  48. package/dist/routes/reports.js +7 -0
  49. package/dist/routes/top.js +8 -1
  50. package/dist/service.js +11 -0
  51. package/dist/watchers/adapter.d.ts +1 -0
  52. package/dist/watchers/claude-code.d.ts +16 -1
  53. package/dist/watchers/claude-code.js +201 -76
  54. package/dist/watchers/opencode.d.ts +1 -0
  55. package/dist/watchers/opencode.js +152 -14
  56. package/hooks/event.js +44 -26
  57. package/package.json +1 -1
  58. package/dashboard/dist/assets/AnalyticsView-5bUM3UHp.js +0 -8
  59. package/dashboard/dist/assets/HistoryView-C-AsEqos.js +0 -1
  60. package/dashboard/dist/assets/ProjectsView-D9bZBdY2.js +0 -6
  61. package/dashboard/dist/assets/SystemView-DIYDCCF3.js +0 -1
  62. package/dashboard/dist/assets/TopView-DhdLpsiA.js +0 -1
  63. package/dashboard/dist/assets/index-DgbWvj42.js +0 -84
@@ -11,9 +11,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.opencodeAdapter = void 0;
14
+ exports.isSessionArchived = isSessionArchived;
14
15
  const fs_1 = __importDefault(require("fs"));
16
+ const os_1 = __importDefault(require("os"));
15
17
  const adapter_1 = require("./adapter");
16
18
  const paths_1 = require("../paths");
19
+ const pricing_1 = require("../pricing");
20
+ const db_1 = require("../db");
21
+ const helpers_1 = require("../routes/helpers");
17
22
  function openDb() {
18
23
  const { DatabaseSync } = require('node:sqlite');
19
24
  return new DatabaseSync((0, paths_1.getOpencodeDb)(), { open: true });
@@ -29,6 +34,101 @@ function parseModel(raw) {
29
34
  return 'unknown';
30
35
  }
31
36
  }
37
+ const HOME = os_1.default.homedir();
38
+ function inferProjectFromParts(db, sessionId) {
39
+ if (!db)
40
+ return undefined;
41
+ const parts = db.prepare(`
42
+ SELECT p.data FROM part p
43
+ JOIN message m ON p.message_id = m.id
44
+ WHERE m.session_id = ?
45
+ AND json_extract(p.data, '$.type') = 'tool'
46
+ AND json_extract(p.data, '$.tool') IN ('read', 'write', 'edit', 'glob', 'grep')
47
+ ORDER BY p.time_created DESC
48
+ LIMIT 30
49
+ `).all(sessionId);
50
+ const roots = new Map();
51
+ for (const { data } of parts) {
52
+ try {
53
+ const input = JSON.parse(data).state?.input;
54
+ if (!input)
55
+ continue;
56
+ const filePath = input.filePath || input.path || input.file_path;
57
+ if (!filePath || typeof filePath !== 'string' || !filePath.startsWith('/'))
58
+ continue;
59
+ const root = (0, helpers_1.findProjectCwdForFile)(filePath);
60
+ if (root)
61
+ roots.set(root, (roots.get(root) ?? 0) + 1);
62
+ }
63
+ catch { }
64
+ }
65
+ if (roots.size === 0)
66
+ return undefined;
67
+ return [...roots.entries()].sort((a, b) => b[1] - a[1])[0][0];
68
+ }
69
+ function importToolEvents(ocDb, sessionId, targetSessionId) {
70
+ const parts = ocDb.prepare(`
71
+ SELECT p.id, p.data, p.time_created
72
+ FROM part p
73
+ JOIN message m ON p.message_id = m.id
74
+ WHERE m.session_id = ?
75
+ AND json_extract(p.data, '$.type') = 'tool'
76
+ AND json_extract(p.data, '$.state') IS NOT NULL
77
+ `).all(sessionId);
78
+ const destId = targetSessionId ?? sessionId;
79
+ for (const part of parts) {
80
+ try {
81
+ const toolName = JSON.parse(part.data).tool;
82
+ if (!toolName)
83
+ continue;
84
+ db_1.dbOps.insertOcEvent(destId, toolName, part.time_created, part.id);
85
+ }
86
+ catch { }
87
+ }
88
+ }
89
+ // ─── Session grouping: merge consecutive OC sessions from same conversation ────
90
+ // OpenCode creates a new session row per prompt, even within the same conversation.
91
+ // We group sessions by directory + close time_created (<60s apart) into one.
92
+ function groupOcSessions(rows) {
93
+ const sorted = [...rows].sort((a, b) => a.time_created - b.time_created);
94
+ const groups = new Map(); // master id → group
95
+ const grouped = new Set();
96
+ for (let i = 0; i < sorted.length; i++) {
97
+ if (grouped.has(sorted[i].id))
98
+ continue;
99
+ const group = [sorted[i]];
100
+ grouped.add(sorted[i].id);
101
+ for (let j = i + 1; j < sorted.length; j++) {
102
+ const prev = group[group.length - 1];
103
+ const curr = sorted[j];
104
+ if (grouped.has(curr.id))
105
+ continue;
106
+ if (curr.directory !== prev.directory)
107
+ continue;
108
+ const gap = curr.time_created - prev.time_created;
109
+ if (gap > 60000)
110
+ break; // too far apart, stop looking
111
+ group.push(curr);
112
+ grouped.add(curr.id);
113
+ }
114
+ groups.set(group[0].id, group);
115
+ }
116
+ // Flatten: return only master (first) rows, with aggregated cost/tokens
117
+ return [...groups.values()].map(group => {
118
+ const master = { ...group[0] };
119
+ for (let k = 1; k < group.length; k++) {
120
+ const s = group[k];
121
+ master.cost += s.cost;
122
+ master.tokens_input += s.tokens_input;
123
+ master.tokens_output += s.tokens_output;
124
+ master.tokens_cache_read += s.tokens_cache_read;
125
+ master.tokens_cache_write += s.tokens_cache_write;
126
+ if (s.time_updated > master.time_updated)
127
+ master.time_updated = s.time_updated;
128
+ }
129
+ return master;
130
+ });
131
+ }
32
132
  exports.opencodeAdapter = {
33
133
  name: 'opencode',
34
134
  label: 'OpenCode',
@@ -54,23 +154,50 @@ exports.opencodeAdapter = {
54
154
  let db = null;
55
155
  try {
56
156
  db = openDb();
57
- const rows = db.prepare(`SELECT id, model, cost, tokens_input, tokens_output, tokens_cache_read, tokens_cache_write, time_updated
157
+ const rows = db.prepare(`SELECT id, directory, model, cost, tokens_input, tokens_output, tokens_cache_read, tokens_cache_write,
158
+ time_created, time_updated
58
159
  FROM session
59
160
  WHERE time_updated >= ?
60
161
  AND time_archived IS NULL`).all(since);
61
- return rows.map(row => ({
62
- sessionId: row.id,
63
- cost: {
64
- input_tokens: row.tokens_input,
65
- output_tokens: row.tokens_output,
66
- cache_read: row.tokens_cache_read,
67
- cache_creation: row.tokens_cache_write,
68
- cost_usd: row.cost,
69
- context_used: 0,
70
- context_window: 200000,
71
- lastModel: parseModel(row.model),
72
- },
73
- }));
162
+ const grouped = groupOcSessions(rows);
163
+ // Build master lookup: original session id → master session id
164
+ const masterMap = new Map();
165
+ for (let i = 0; i < rows.length; i++) {
166
+ const masterId = grouped.find(g => g.id === rows[i].id)?.id
167
+ ?? rows[i].id;
168
+ masterMap.set(rows[i].id, masterId);
169
+ }
170
+ // Import tool events into the master session ID
171
+ for (const s of rows) {
172
+ const masterId = masterMap.get(s.id) ?? s.id;
173
+ try {
174
+ importToolEvents(db, s.id, masterId);
175
+ }
176
+ catch { }
177
+ }
178
+ return grouped.map(row => {
179
+ const modelId = parseModel(row.model);
180
+ const dir = row.directory;
181
+ const shouldInfer = !dir || dir === HOME || dir.split('/').filter(Boolean).length <= 3;
182
+ const inferred = shouldInfer ? inferProjectFromParts(db, row.id) : undefined;
183
+ const projectCwd = inferred ?? dir ?? undefined;
184
+ return {
185
+ sessionId: row.id,
186
+ cwd: projectCwd,
187
+ cost: {
188
+ input_tokens: row.tokens_input,
189
+ output_tokens: row.tokens_output,
190
+ cache_read: row.tokens_cache_read,
191
+ cache_creation: row.tokens_cache_write,
192
+ cost_usd: row.cost,
193
+ context_used: row.tokens_input + row.tokens_cache_read + row.tokens_cache_write,
194
+ context_window: (0, pricing_1.getContextWindow)(modelId),
195
+ lastModel: modelId,
196
+ firstTs: row.time_created,
197
+ lastTs: row.time_updated,
198
+ },
199
+ };
200
+ });
74
201
  }
75
202
  catch {
76
203
  return [];
@@ -80,4 +207,15 @@ exports.opencodeAdapter = {
80
207
  }
81
208
  },
82
209
  };
210
+ function isSessionArchived(sessionId) {
211
+ try {
212
+ const db = openDb();
213
+ const row = db.prepare('SELECT time_archived FROM session WHERE id = ?').get(sessionId);
214
+ db.close();
215
+ return row === undefined || row.time_archived !== null;
216
+ }
217
+ catch {
218
+ return false;
219
+ }
220
+ }
83
221
  (0, adapter_1.registerAdapter)(exports.opencodeAdapter);
package/hooks/event.js CHANGED
@@ -14,8 +14,19 @@
14
14
  */
15
15
 
16
16
  const eventType = process.argv[2] || 'Unknown'
17
- const DAEMON_URL = 'http://localhost:7337/event'
18
- const KILL_SWITCH_URL = 'http://localhost:7337/kill-switch'
17
+ const fs = require('fs')
18
+ const os = require('os')
19
+
20
+ // Read port from ~/.claudestat/port (written by daemon on startup). Fallback: 7337.
21
+ let DAEMON_PORT = 7337
22
+ try {
23
+ const portFile = require('path').join(os.homedir(), '.claudestat', 'port')
24
+ const raw = fs.readFileSync(portFile, 'utf8').trim()
25
+ const parsed = parseInt(raw, 10)
26
+ if (!isNaN(parsed) && parsed >= 1024 && parsed <= 65535) DAEMON_PORT = parsed
27
+ } catch {}
28
+
29
+ const DAEMON_URL = `http://localhost:${DAEMON_PORT}/event`
19
30
 
20
31
  let rawData = ''
21
32
  process.stdin.on('data', chunk => { rawData += chunk })
@@ -29,36 +40,43 @@ process.stdin.on('end', () => {
29
40
  ...hookData
30
41
  }
31
42
 
32
- // Para PreToolUse: enviamos el evento Y consultamos el kill-switch en paralelo.
33
- // Si el daemon bloquea, salimos con exit(2) para cancelar la acción.
43
+ // Para PreToolUse: enviamos el evento Y leemos el archivo de pausa local.
44
+ // Si existe pause.signal, mostramos warning y salimos según killSwitchForce.
34
45
  if (eventType === 'PreToolUse') {
35
- Promise.all([
36
- // 1. Registrar el evento (fire-and-forget, no nos importa el resultado)
37
- fetch(DAEMON_URL, {
38
- method: 'POST',
39
- headers: { 'Content-Type': 'application/json' },
40
- body: JSON.stringify(payload),
41
- signal: AbortSignal.timeout(1500),
42
- }).catch(() => null),
46
+ fetch(DAEMON_URL, {
47
+ method: 'POST',
48
+ headers: { 'Content-Type': 'application/json' },
49
+ body: JSON.stringify(payload),
50
+ signal: AbortSignal.timeout(1500),
51
+ }).catch(() => null)
52
+
53
+ // Check pause signal file (written by daemon when quota threshold reached)
54
+ const signalFile = require('path').join(os.homedir(), '.claudestat', 'pause.signal')
55
+ let signalMsg = null
56
+ try { signalMsg = fs.readFileSync(signalFile, 'utf8').trim() } catch {}
57
+
58
+ if (signalMsg) {
59
+ process.stderr.write(`\n⚠️ claudestat — quota warning\n`)
60
+ process.stderr.write(` ${signalMsg}\n`)
43
61
 
44
- // 2. Consultar el kill-switch con timeout corto para no retrasar a Claude
45
- fetch(KILL_SWITCH_URL, {
46
- signal: AbortSignal.timeout(1500),
47
- })
48
- .then(r => r.json())
49
- .catch(() => ({ blocked: false })), // daemon no disponible → fail-open
50
- ])
51
- .then(([_, ks]) => {
52
- if (ks && ks.blocked) {
53
- process.stderr.write(`\n🚫 claudestat kill switch active\n`)
54
- process.stderr.write(` ${ks.reason ?? 'Usage quota exceeded.'}\n`)
55
- process.stderr.write(` To disable: claudestat config --kill-switch false\n\n`)
62
+ // Read config to check killSwitchForce
63
+ let forceBlock = false
64
+ try {
65
+ const cfgPath = require('path').join(os.homedir(), '.claudestat', 'config.json')
66
+ const cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf8'))
67
+ forceBlock = cfg.killSwitchForce === true
68
+ } catch {}
69
+
70
+ if (forceBlock) {
71
+ process.stderr.write(` Blocked (killSwitchForce is enabled). Run: claudestat resume\n\n`)
56
72
  process.exit(2)
57
73
  } else {
74
+ process.stderr.write(` Continuing. To pause manually: claudestat resume (removes signal)\n\n`)
58
75
  process.exit(0)
59
76
  }
60
- })
61
- .catch(() => process.exit(0)) // cualquier error → no bloquear
77
+ } else {
78
+ process.exit(0)
79
+ }
62
80
 
63
81
  } else {
64
82
  // Para todos los demás tipos (SessionStart, PostToolUse, Stop):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statforge/claudestat",
3
- "version": "1.6.1",
3
+ "version": "1.8.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,8 +0,0 @@
1
- import{u as Ut,a as Xt,b as Jt,i as D,c as Zt,d as Qt,e as te,w as Je,g as mt,f as xt,h as vt,C as gt,k as W,l as ke,D as bt,m as He,E as jt,L as R,n as xe,A as Ke,o as I,p as _e,q as K,r as kt,s as Ge,t as ee,v as Ve,G as Ye,x as ue,y as we,z as qt,S as Ze,B as ei,F as ti,H as ii,I as ni,J as St,X as $e,Y as ve,K as wt,M as At,j as n,T as N,R as Qe,N as qe,O as ri}from"./index-DgbWvj42.js";import{x as g,a as T,_ as Pt,d as Ue,y as Se,q as oi,$ as ai,p as si,M as li,a0 as Ot,W as ci,Z as Xe,a1 as di,U as et,f as zt,I as _t,s as ui,a2 as fi,b as $t,a3 as tt,a4 as hi,F as pi,n as it,V as yi,Y as mi,a5 as xi,X as vi}from"./vendor-lucide-Cym0q5l_.js";import"./vendor-react-B_Jzs0gY.js";var gi=["x1","y1","x2","y2","key"],bi=["offset"];function re(e){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},re(e)}function nt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,i)}return r}function C(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?nt(Object(r),!0).forEach(function(i){ji(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):nt(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function ji(e,t,r){return t=ki(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ki(e){var t=Si(e,"string");return re(t)=="symbol"?t:t+""}function Si(e,t){if(re(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(re(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ie(){return ie=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ie.apply(this,arguments)}function rt(e,t){if(e==null)return{};var r=wi(e,t),i,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)i=a[o],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function wi(e,t){if(e==null)return{};var r={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){if(t.indexOf(i)>=0)continue;r[i]=e[i]}return r}var Ai=function(t){var r=t.fill;if(!r||r==="none")return null;var i=t.fillOpacity,o=t.x,a=t.y,s=t.width,l=t.height,d=t.ry;return g.createElement("rect",{x:o,y:a,ry:d,width:s,height:l,stroke:"none",fill:r,fillOpacity:i,className:"recharts-cartesian-grid-bg"})};function Tt(e,t){var r;if(g.isValidElement(e))r=g.cloneElement(e,t);else if(te(e))r=e(t);else{var i=t.x1,o=t.y1,a=t.x2,s=t.y2,l=t.key,d=rt(t,gi),u=W(d,!1);u.offset;var c=rt(u,bi);r=g.createElement("line",ie({},c,{x1:i,y1:o,x2:a,y2:s,fill:"none",key:l}))}return r}function Pi(e){var t=e.x,r=e.width,i=e.horizontal,o=i===void 0?!0:i,a=e.horizontalPoints;if(!o||!a||!a.length)return null;var s=a.map(function(l,d){var u=C(C({},e),{},{x1:t,y1:l,x2:t+r,y2:l,key:"line-".concat(d),index:d});return Tt(o,u)});return g.createElement("g",{className:"recharts-cartesian-grid-horizontal"},s)}function Oi(e){var t=e.y,r=e.height,i=e.vertical,o=i===void 0?!0:i,a=e.verticalPoints;if(!o||!a||!a.length)return null;var s=a.map(function(l,d){var u=C(C({},e),{},{x1:l,y1:t,x2:l,y2:t+r,key:"line-".concat(d),index:d});return Tt(o,u)});return g.createElement("g",{className:"recharts-cartesian-grid-vertical"},s)}function zi(e){var t=e.horizontalFill,r=e.fillOpacity,i=e.x,o=e.y,a=e.width,s=e.height,l=e.horizontalPoints,d=e.horizontal,u=d===void 0?!0:d;if(!u||!t||!t.length)return null;var c=l.map(function(f){return Math.round(f+o-o)}).sort(function(f,p){return f-p});o!==c[0]&&c.unshift(0);var h=c.map(function(f,p){var m=!c[p+1],y=m?o+s-f:c[p+1]-f;if(y<=0)return null;var j=p%t.length;return g.createElement("rect",{key:"react-".concat(p),y:f,x:i,height:y,width:a,stroke:"none",fill:t[j],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return g.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},h)}function _i(e){var t=e.vertical,r=t===void 0?!0:t,i=e.verticalFill,o=e.fillOpacity,a=e.x,s=e.y,l=e.width,d=e.height,u=e.verticalPoints;if(!r||!i||!i.length)return null;var c=u.map(function(f){return Math.round(f+a-a)}).sort(function(f,p){return f-p});a!==c[0]&&c.unshift(0);var h=c.map(function(f,p){var m=!c[p+1],y=m?a+l-f:c[p+1]-f;if(y<=0)return null;var j=p%i.length;return g.createElement("rect",{key:"react-".concat(p),x:f,y:s,width:y,height:d,stroke:"none",fill:i[j],fillOpacity:o,className:"recharts-cartesian-grid-bg"})});return g.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},h)}var $i=function(t,r){var i=t.xAxis,o=t.width,a=t.height,s=t.offset;return mt(xt(C(C(C({},gt.defaultProps),i),{},{ticks:vt(i,!0),viewBox:{x:0,y:0,width:o,height:a}})),s.left,s.left+s.width,r)},Ti=function(t,r){var i=t.yAxis,o=t.width,a=t.height,s=t.offset;return mt(xt(C(C(C({},gt.defaultProps),i),{},{ticks:vt(i,!0),viewBox:{x:0,y:0,width:o,height:a}})),s.top,s.top+s.height,r)},se={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function Be(e){var t,r,i,o,a,s,l=Ut(),d=Xt(),u=Jt(),c=C(C({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:se.stroke,fill:(r=e.fill)!==null&&r!==void 0?r:se.fill,horizontal:(i=e.horizontal)!==null&&i!==void 0?i:se.horizontal,horizontalFill:(o=e.horizontalFill)!==null&&o!==void 0?o:se.horizontalFill,vertical:(a=e.vertical)!==null&&a!==void 0?a:se.vertical,verticalFill:(s=e.verticalFill)!==null&&s!==void 0?s:se.verticalFill,x:D(e.x)?e.x:u.left,y:D(e.y)?e.y:u.top,width:D(e.width)?e.width:u.width,height:D(e.height)?e.height:u.height}),h=c.x,f=c.y,p=c.width,m=c.height,y=c.syncWithTicks,j=c.horizontalValues,k=c.verticalValues,x=Zt(),b=Qt();if(!D(p)||p<=0||!D(m)||m<=0||!D(h)||h!==+h||!D(f)||f!==+f)return null;var w=c.verticalCoordinatesGenerator||$i,A=c.horizontalCoordinatesGenerator||Ti,P=c.horizontalPoints,O=c.verticalPoints;if((!P||!P.length)&&te(A)){var z=j&&j.length,_=A({yAxis:b?C(C({},b),{},{ticks:z?j:b.ticks}):void 0,width:l,height:d,offset:u},z?!0:y);Je(Array.isArray(_),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(re(_),"]")),Array.isArray(_)&&(P=_)}if((!O||!O.length)&&te(w)){var $=k&&k.length,v=w({xAxis:x?C(C({},x),{},{ticks:$?k:x.ticks}):void 0,width:l,height:d,offset:u},$?!0:y);Je(Array.isArray(v),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(re(v),"]")),Array.isArray(v)&&(O=v)}return g.createElement("g",{className:"recharts-cartesian-grid"},g.createElement(Ai,{fill:c.fill,fillOpacity:c.fillOpacity,x:c.x,y:c.y,width:c.width,height:c.height,ry:c.ry}),g.createElement(Pi,ie({},c,{offset:u,horizontalPoints:P,xAxis:x,yAxis:b})),g.createElement(Oi,ie({},c,{offset:u,verticalPoints:O,xAxis:x,yAxis:b})),g.createElement(zi,ie({},c,{horizontalPoints:P})),g.createElement(_i,ie({},c,{verticalPoints:O})))}Be.displayName="CartesianGrid";var Ci=["type","layout","connectNulls","ref"],Ei=["key"];function fe(e){"@babel/helpers - typeof";return fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fe(e)}function ot(e,t){if(e==null)return{};var r=Ii(e,t),i,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)i=a[o],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function Ii(e,t){if(e==null)return{};var r={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){if(t.indexOf(i)>=0)continue;r[i]=e[i]}return r}function ge(){return ge=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ge.apply(this,arguments)}function at(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,i)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?at(Object(r),!0).forEach(function(i){H(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):at(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function le(e){return Ri(e)||Bi(e)||Wi(e)||Di()}function Di(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Wi(e,t){if(e){if(typeof e=="string")return Re(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Re(e,t)}}function Bi(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Ri(e){if(Array.isArray(e))return Re(e)}function Re(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function Li(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function st(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,Et(i.key),i)}}function Ni(e,t,r){return t&&st(e.prototype,t),r&&st(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Mi(e,t,r){return t=Te(t),Fi(e,Ct()?Reflect.construct(t,r||[],Te(e).constructor):t.apply(e,r))}function Fi(e,t){if(t&&(fe(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Hi(e)}function Hi(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ct=function(){return!!e})()}function Te(e){return Te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Te(e)}function Ki(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Le(e,t)}function Le(e,t){return Le=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},Le(e,t)}function H(e,t,r){return t=Et(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Et(e){var t=Gi(e,"string");return fe(t)=="symbol"?t:t+""}function Gi(e,t){if(fe(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(fe(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var oe=(function(e){function t(){var r;Li(this,t);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return r=Mi(this,t,[].concat(o)),H(r,"state",{isAnimationFinished:!0,totalLength:0}),H(r,"generateSimpleStrokeDasharray",function(s,l){return"".concat(l,"px ").concat(s-l,"px")}),H(r,"getStrokeDasharray",function(s,l,d){var u=d.reduce(function(k,x){return k+x});if(!u)return r.generateSimpleStrokeDasharray(l,s);for(var c=Math.floor(s/u),h=s%u,f=l-s,p=[],m=0,y=0;m<d.length;y+=d[m],++m)if(y+d[m]>h){p=[].concat(le(d.slice(0,m)),[h-y]);break}var j=p.length%2===0?[0,f]:[f];return[].concat(le(t.repeat(d,c)),le(p),j).map(function(k){return"".concat(k,"px")}).join(", ")}),H(r,"id",Ve("recharts-line-")),H(r,"pathRef",function(s){r.mainCurve=s}),H(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),H(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return Ki(t,e),Ni(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var i=this.getTotalLength();this.setState({totalLength:i})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var i=this.getTotalLength();i!==this.state.totalLength&&this.setState({totalLength:i})}}},{key:"getTotalLength",value:function(){var i=this.mainCurve;try{return i&&i.getTotalLength&&i.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(i,o){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var a=this.props,s=a.points,l=a.xAxis,d=a.yAxis,u=a.layout,c=a.children,h=He(c,jt);if(!h)return null;var f=function(y,j){return{x:y.x,y:y.y,value:y.value,errorVal:ee(y.payload,j)}},p={clipPath:i?"url(#clipPath-".concat(o,")"):null};return g.createElement(R,p,h.map(function(m){return g.cloneElement(m,{key:"bar-".concat(m.props.dataKey),data:s,xAxis:l,yAxis:d,layout:u,dataPointFormatter:f})}))}},{key:"renderDots",value:function(i,o,a){var s=this.props.isAnimationActive;if(s&&!this.state.isAnimationFinished)return null;var l=this.props,d=l.dot,u=l.points,c=l.dataKey,h=W(this.props,!1),f=W(d,!0),p=u.map(function(y,j){var k=B(B(B({key:"dot-".concat(j),r:3},h),f),{},{index:j,cx:y.x,cy:y.y,value:y.value,dataKey:c,payload:y.payload,points:u});return t.renderDotItem(d,k)}),m={clipPath:i?"url(#clipPath-".concat(o?"":"dots-").concat(a,")"):null};return g.createElement(R,ge({className:"recharts-line-dots",key:"dots"},m),p)}},{key:"renderCurveStatically",value:function(i,o,a,s){var l=this.props,d=l.type,u=l.layout,c=l.connectNulls;l.ref;var h=ot(l,Ci),f=B(B(B({},W(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:o?"url(#clipPath-".concat(a,")"):null,points:i},s),{},{type:d,layout:u,connectNulls:c});return g.createElement(xe,ge({},f,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(i,o){var a=this,s=this.props,l=s.points,d=s.strokeDasharray,u=s.isAnimationActive,c=s.animationBegin,h=s.animationDuration,f=s.animationEasing,p=s.animationId,m=s.animateNewValues,y=s.width,j=s.height,k=this.state,x=k.prevPoints,b=k.totalLength;return g.createElement(Ke,{begin:c,duration:h,isActive:u,easing:f,from:{t:0},to:{t:1},key:"line-".concat(p),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(w){var A=w.t;if(x){var P=x.length/l.length,O=l.map(function(S,E){var J=Math.floor(E*P);if(x[J]){var Z=x[J],F=I(Z.x,S.x),Gt=I(Z.y,S.y);return B(B({},S),{},{x:F(A),y:Gt(A)})}if(m){var Vt=I(y*2,S.x),Yt=I(j/2,S.y);return B(B({},S),{},{x:Vt(A),y:Yt(A)})}return B(B({},S),{},{x:S.x,y:S.y})});return a.renderCurveStatically(O,i,o)}var z=I(0,b),_=z(A),$;if(d){var v="".concat(d).split(/[,\s]+/gim).map(function(S){return parseFloat(S)});$=a.getStrokeDasharray(_,b,v)}else $=a.generateSimpleStrokeDasharray(b,_);return a.renderCurveStatically(l,i,o,{strokeDasharray:$})})}},{key:"renderCurve",value:function(i,o){var a=this.props,s=a.points,l=a.isAnimationActive,d=this.state,u=d.prevPoints,c=d.totalLength;return l&&s&&s.length&&(!u&&c>0||!_e(u,s))?this.renderCurveWithAnimation(i,o):this.renderCurveStatically(s,i,o)}},{key:"render",value:function(){var i,o=this.props,a=o.hide,s=o.dot,l=o.points,d=o.className,u=o.xAxis,c=o.yAxis,h=o.top,f=o.left,p=o.width,m=o.height,y=o.isAnimationActive,j=o.id;if(a||!l||!l.length)return null;var k=this.state.isAnimationFinished,x=l.length===1,b=ke("recharts-line",d),w=u&&u.allowDataOverflow,A=c&&c.allowDataOverflow,P=w||A,O=K(j)?this.id:j,z=(i=W(s,!1))!==null&&i!==void 0?i:{r:3,strokeWidth:2},_=z.r,$=_===void 0?3:_,v=z.strokeWidth,S=v===void 0?2:v,E=kt(s)?s:{},J=E.clipDot,Z=J===void 0?!0:J,F=$*2+S;return g.createElement(R,{className:b},w||A?g.createElement("defs",null,g.createElement("clipPath",{id:"clipPath-".concat(O)},g.createElement("rect",{x:w?f:f-p/2,y:A?h:h-m/2,width:w?p:p*2,height:A?m:m*2})),!Z&&g.createElement("clipPath",{id:"clipPath-dots-".concat(O)},g.createElement("rect",{x:f-F/2,y:h-F/2,width:p+F,height:m+F}))):null,!x&&this.renderCurve(P,O),this.renderErrorBar(P,O),(x||s)&&this.renderDots(P,Z,O),(!y||k)&&Ge.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(i,o){return i.animationId!==o.prevAnimationId?{prevAnimationId:i.animationId,curPoints:i.points,prevPoints:o.curPoints}:i.points!==o.curPoints?{curPoints:i.points}:null}},{key:"repeat",value:function(i,o){for(var a=i.length%2!==0?[].concat(le(i),[0]):i,s=[],l=0;l<o;++l)s=[].concat(le(s),le(a));return s}},{key:"renderDotItem",value:function(i,o){var a;if(g.isValidElement(i))a=g.cloneElement(i,o);else if(te(i))a=i(o);else{var s=o.key,l=ot(o,Ei),d=ke("recharts-line-dot",typeof i!="boolean"?i.className:"");a=g.createElement(bt,ge({key:s},l,{className:d}))}return a}}])})(T.PureComponent);H(oe,"displayName","Line");H(oe,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Ye.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});H(oe,"getComposedData",function(e){var t=e.props,r=e.xAxis,i=e.yAxis,o=e.xAxisTicks,a=e.yAxisTicks,s=e.dataKey,l=e.bandSize,d=e.displayedData,u=e.offset,c=t.layout,h=d.map(function(f,p){var m=ee(f,s);return c==="horizontal"?{x:ue({axis:r,ticks:o,bandSize:l,entry:f,index:p}),y:K(m)?null:i.scale(m),value:m,payload:f}:{x:K(m)?null:r.scale(m),y:ue({axis:i,ticks:a,bandSize:l,entry:f,index:p}),value:m,payload:f}});return B({points:h,layout:c},u)});var Vi=["layout","type","stroke","connectNulls","isRange","ref"],Yi=["key"],It;function he(e){"@babel/helpers - typeof";return he=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},he(e)}function Dt(e,t){if(e==null)return{};var r=Ui(e,t),i,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)i=a[o],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function Ui(e,t){if(e==null)return{};var r={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){if(t.indexOf(i)>=0)continue;r[i]=e[i]}return r}function ne(){return ne=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},ne.apply(this,arguments)}function lt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,i)}return r}function Q(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?lt(Object(r),!0).forEach(function(i){V(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):lt(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Xi(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ct(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,Bt(i.key),i)}}function Ji(e,t,r){return t&&ct(e.prototype,t),r&&ct(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Zi(e,t,r){return t=Ce(t),Qi(e,Wt()?Reflect.construct(t,r||[],Ce(e).constructor):t.apply(e,r))}function Qi(e,t){if(t&&(he(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return qi(e)}function qi(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Wt(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Wt=function(){return!!e})()}function Ce(e){return Ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ce(e)}function en(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ne(e,t)}function Ne(e,t){return Ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},Ne(e,t)}function V(e,t,r){return t=Bt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Bt(e){var t=tn(e,"string");return he(t)=="symbol"?t:t+""}function tn(e,t){if(he(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(he(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ae=(function(e){function t(){var r;Xi(this,t);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return r=Zi(this,t,[].concat(o)),V(r,"state",{isAnimationFinished:!0}),V(r,"id",Ve("recharts-area-")),V(r,"handleAnimationEnd",function(){var s=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),te(s)&&s()}),V(r,"handleAnimationStart",function(){var s=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),te(s)&&s()}),r}return en(t,e),Ji(t,[{key:"renderDots",value:function(i,o,a){var s=this.props.isAnimationActive,l=this.state.isAnimationFinished;if(s&&!l)return null;var d=this.props,u=d.dot,c=d.points,h=d.dataKey,f=W(this.props,!1),p=W(u,!0),m=c.map(function(j,k){var x=Q(Q(Q({key:"dot-".concat(k),r:3},f),p),{},{index:k,cx:j.x,cy:j.y,dataKey:h,value:j.value,payload:j.payload,points:c});return t.renderDotItem(u,x)}),y={clipPath:i?"url(#clipPath-".concat(o?"":"dots-").concat(a,")"):null};return g.createElement(R,ne({className:"recharts-area-dots"},y),m)}},{key:"renderHorizontalRect",value:function(i){var o=this.props,a=o.baseLine,s=o.points,l=o.strokeWidth,d=s[0].x,u=s[s.length-1].x,c=i*Math.abs(d-u),h=we(s.map(function(f){return f.y||0}));return D(a)&&typeof a=="number"?h=Math.max(a,h):a&&Array.isArray(a)&&a.length&&(h=Math.max(we(a.map(function(f){return f.y||0})),h)),D(h)?g.createElement("rect",{x:d<u?d:d-c,y:0,width:c,height:Math.floor(h+(l?parseInt("".concat(l),10):1))}):null}},{key:"renderVerticalRect",value:function(i){var o=this.props,a=o.baseLine,s=o.points,l=o.strokeWidth,d=s[0].y,u=s[s.length-1].y,c=i*Math.abs(d-u),h=we(s.map(function(f){return f.x||0}));return D(a)&&typeof a=="number"?h=Math.max(a,h):a&&Array.isArray(a)&&a.length&&(h=Math.max(we(a.map(function(f){return f.x||0})),h)),D(h)?g.createElement("rect",{x:0,y:d<u?d:d-c,width:h+(l?parseInt("".concat(l),10):1),height:Math.floor(c)}):null}},{key:"renderClipRect",value:function(i){var o=this.props.layout;return o==="vertical"?this.renderVerticalRect(i):this.renderHorizontalRect(i)}},{key:"renderAreaStatically",value:function(i,o,a,s){var l=this.props,d=l.layout,u=l.type,c=l.stroke,h=l.connectNulls,f=l.isRange;l.ref;var p=Dt(l,Vi);return g.createElement(R,{clipPath:a?"url(#clipPath-".concat(s,")"):null},g.createElement(xe,ne({},W(p,!0),{points:i,connectNulls:h,type:u,baseLine:o,layout:d,stroke:"none",className:"recharts-area-area"})),c!=="none"&&g.createElement(xe,ne({},W(this.props,!1),{className:"recharts-area-curve",layout:d,type:u,connectNulls:h,fill:"none",points:i})),c!=="none"&&f&&g.createElement(xe,ne({},W(this.props,!1),{className:"recharts-area-curve",layout:d,type:u,connectNulls:h,fill:"none",points:o})))}},{key:"renderAreaWithAnimation",value:function(i,o){var a=this,s=this.props,l=s.points,d=s.baseLine,u=s.isAnimationActive,c=s.animationBegin,h=s.animationDuration,f=s.animationEasing,p=s.animationId,m=this.state,y=m.prevPoints,j=m.prevBaseLine;return g.createElement(Ke,{begin:c,duration:h,isActive:u,easing:f,from:{t:0},to:{t:1},key:"area-".concat(p),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(k){var x=k.t;if(y){var b=y.length/l.length,w=l.map(function(z,_){var $=Math.floor(_*b);if(y[$]){var v=y[$],S=I(v.x,z.x),E=I(v.y,z.y);return Q(Q({},z),{},{x:S(x),y:E(x)})}return z}),A;if(D(d)&&typeof d=="number"){var P=I(j,d);A=P(x)}else if(K(d)||qt(d)){var O=I(j,0);A=O(x)}else A=d.map(function(z,_){var $=Math.floor(_*b);if(j[$]){var v=j[$],S=I(v.x,z.x),E=I(v.y,z.y);return Q(Q({},z),{},{x:S(x),y:E(x)})}return z});return a.renderAreaStatically(w,A,i,o)}return g.createElement(R,null,g.createElement("defs",null,g.createElement("clipPath",{id:"animationClipPath-".concat(o)},a.renderClipRect(x))),g.createElement(R,{clipPath:"url(#animationClipPath-".concat(o,")")},a.renderAreaStatically(l,d,i,o)))})}},{key:"renderArea",value:function(i,o){var a=this.props,s=a.points,l=a.baseLine,d=a.isAnimationActive,u=this.state,c=u.prevPoints,h=u.prevBaseLine,f=u.totalLength;return d&&s&&s.length&&(!c&&f>0||!_e(c,s)||!_e(h,l))?this.renderAreaWithAnimation(i,o):this.renderAreaStatically(s,l,i,o)}},{key:"render",value:function(){var i,o=this.props,a=o.hide,s=o.dot,l=o.points,d=o.className,u=o.top,c=o.left,h=o.xAxis,f=o.yAxis,p=o.width,m=o.height,y=o.isAnimationActive,j=o.id;if(a||!l||!l.length)return null;var k=this.state.isAnimationFinished,x=l.length===1,b=ke("recharts-area",d),w=h&&h.allowDataOverflow,A=f&&f.allowDataOverflow,P=w||A,O=K(j)?this.id:j,z=(i=W(s,!1))!==null&&i!==void 0?i:{r:3,strokeWidth:2},_=z.r,$=_===void 0?3:_,v=z.strokeWidth,S=v===void 0?2:v,E=kt(s)?s:{},J=E.clipDot,Z=J===void 0?!0:J,F=$*2+S;return g.createElement(R,{className:b},w||A?g.createElement("defs",null,g.createElement("clipPath",{id:"clipPath-".concat(O)},g.createElement("rect",{x:w?c:c-p/2,y:A?u:u-m/2,width:w?p:p*2,height:A?m:m*2})),!Z&&g.createElement("clipPath",{id:"clipPath-dots-".concat(O)},g.createElement("rect",{x:c-F/2,y:u-F/2,width:p+F,height:m+F}))):null,x?null:this.renderArea(P,O),(s||x)&&this.renderDots(P,Z,O),(!y||k)&&Ge.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(i,o){return i.animationId!==o.prevAnimationId?{prevAnimationId:i.animationId,curPoints:i.points,curBaseLine:i.baseLine,prevPoints:o.curPoints,prevBaseLine:o.curBaseLine}:i.points!==o.curPoints||i.baseLine!==o.curBaseLine?{curPoints:i.points,curBaseLine:i.baseLine}:null}}])})(T.PureComponent);It=ae;V(ae,"displayName","Area");V(ae,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!Ye.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});V(ae,"getBaseValue",function(e,t,r,i){var o=e.layout,a=e.baseValue,s=t.props.baseValue,l=s??a;if(D(l)&&typeof l=="number")return l;var d=o==="horizontal"?i:r,u=d.scale.domain();if(d.type==="number"){var c=Math.max(u[0],u[1]),h=Math.min(u[0],u[1]);return l==="dataMin"?h:l==="dataMax"||c<0?c:Math.max(Math.min(u[0],u[1]),0)}return l==="dataMin"?u[0]:l==="dataMax"?u[1]:u[0]});V(ae,"getComposedData",function(e){var t=e.props,r=e.item,i=e.xAxis,o=e.yAxis,a=e.xAxisTicks,s=e.yAxisTicks,l=e.bandSize,d=e.dataKey,u=e.stackedData,c=e.dataStartIndex,h=e.displayedData,f=e.offset,p=t.layout,m=u&&u.length,y=It.getBaseValue(t,r,i,o),j=p==="horizontal",k=!1,x=h.map(function(w,A){var P;m?P=u[c+A]:(P=ee(w,d),Array.isArray(P)?k=!0:P=[y,P]);var O=P[1]==null||m&&ee(w,d)==null;return j?{x:ue({axis:i,ticks:a,bandSize:l,entry:w,index:A}),y:O?null:o.scale(P[1]),value:P,payload:w}:{x:O?null:i.scale(P[1]),y:ue({axis:o,ticks:s,bandSize:l,entry:w,index:A}),value:P,payload:w}}),b;return m||k?b=x.map(function(w){var A=Array.isArray(w.value)?w.value[0]:null;return j?{x:w.x,y:A!=null&&w.y!=null?o.scale(A):null}:{x:A!=null?i.scale(A):null,y:w.y}}):b=j?o.scale(y):i.scale(y),Q({points:x,baseLine:b,layout:p,isRange:k},f)});V(ae,"renderDotItem",function(e,t){var r;if(g.isValidElement(e))r=g.cloneElement(e,t);else if(te(e))r=e(t);else{var i=ke("recharts-area-dot",typeof e!="boolean"?e.className:""),o=t.key,a=Dt(t,Yi);r=g.createElement(bt,ne({},a,{key:o,className:i}))}return r});function pe(e){"@babel/helpers - typeof";return pe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pe(e)}function nn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function rn(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,Nt(i.key),i)}}function on(e,t,r){return t&&rn(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function an(e,t,r){return t=Ee(t),sn(e,Rt()?Reflect.construct(t,r||[],Ee(e).constructor):t.apply(e,r))}function sn(e,t){if(t&&(pe(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ln(e)}function ln(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Rt(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Rt=function(){return!!e})()}function Ee(e){return Ee=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ee(e)}function cn(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Me(e,t)}function Me(e,t){return Me=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},Me(e,t)}function Lt(e,t,r){return t=Nt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Nt(e){var t=dn(e,"string");return pe(t)=="symbol"?t:t+""}function dn(e,t){if(pe(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(pe(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var De=(function(e){function t(){return nn(this,t),an(this,t,arguments)}return cn(t,e),on(t,[{key:"render",value:function(){return null}}])})(T.Component);Lt(De,"displayName","ZAxis");Lt(De,"defaultProps",{zAxisId:0,range:[64,64],scale:"auto",type:"number"});var un=["option","isActive"];function be(){return be=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},be.apply(this,arguments)}function fn(e,t){if(e==null)return{};var r=hn(e,t),i,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)i=a[o],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function hn(e,t){if(e==null)return{};var r={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){if(t.indexOf(i)>=0)continue;r[i]=e[i]}return r}function pn(e){var t=e.option,r=e.isActive,i=fn(e,un);return typeof t=="string"?T.createElement(Ze,be({option:T.createElement(ei,be({type:t},i)),isActive:r,shapeType:"symbols"},i)):T.createElement(Ze,be({option:t,isActive:r,shapeType:"symbols"},i))}function ye(e){"@babel/helpers - typeof";return ye=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ye(e)}function je(){return je=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},je.apply(this,arguments)}function dt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,i)}return r}function L(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?dt(Object(r),!0).forEach(function(i){q(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dt(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function yn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ut(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,Ft(i.key),i)}}function mn(e,t,r){return t&&ut(e.prototype,t),r&&ut(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function xn(e,t,r){return t=Ie(t),vn(e,Mt()?Reflect.construct(t,r||[],Ie(e).constructor):t.apply(e,r))}function vn(e,t){if(t&&(ye(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return gn(e)}function gn(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Mt(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Mt=function(){return!!e})()}function Ie(e){return Ie=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ie(e)}function bn(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Fe(e,t)}function Fe(e,t){return Fe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,o){return i.__proto__=o,i},Fe(e,t)}function q(e,t,r){return t=Ft(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ft(e){var t=jn(e,"string");return ye(t)=="symbol"?t:t+""}function jn(e,t){if(ye(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(ye(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var We=(function(e){function t(){var r;yn(this,t);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return r=xn(this,t,[].concat(o)),q(r,"state",{isAnimationFinished:!1}),q(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0})}),q(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1})}),q(r,"id",Ve("recharts-scatter-")),r}return bn(t,e),mn(t,[{key:"renderSymbolsStatically",value:function(i){var o=this,a=this.props,s=a.shape,l=a.activeShape,d=a.activeIndex,u=W(this.props,!1);return i.map(function(c,h){var f=d===h,p=f?l:s,m=L(L({},u),c);return g.createElement(R,je({className:"recharts-scatter-symbol",key:"symbol-".concat(c==null?void 0:c.cx,"-").concat(c==null?void 0:c.cy,"-").concat(c==null?void 0:c.size,"-").concat(h)},ti(o.props,c,h),{role:"img"}),g.createElement(pn,je({option:p,isActive:f,key:"symbol-".concat(h)},m)))})}},{key:"renderSymbolsWithAnimation",value:function(){var i=this,o=this.props,a=o.points,s=o.isAnimationActive,l=o.animationBegin,d=o.animationDuration,u=o.animationEasing,c=o.animationId,h=this.state.prevPoints;return g.createElement(Ke,{begin:l,duration:d,isActive:s,easing:u,from:{t:0},to:{t:1},key:"pie-".concat(c),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(f){var p=f.t,m=a.map(function(y,j){var k=h&&h[j];if(k){var x=I(k.cx,y.cx),b=I(k.cy,y.cy),w=I(k.size,y.size);return L(L({},y),{},{cx:x(p),cy:b(p),size:w(p)})}var A=I(0,y.size);return L(L({},y),{},{size:A(p)})});return g.createElement(R,null,i.renderSymbolsStatically(m))})}},{key:"renderSymbols",value:function(){var i=this.props,o=i.points,a=i.isAnimationActive,s=this.state.prevPoints;return a&&o&&o.length&&(!s||!_e(s,o))?this.renderSymbolsWithAnimation():this.renderSymbolsStatically(o)}},{key:"renderErrorBar",value:function(){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var o=this.props,a=o.points,s=o.xAxis,l=o.yAxis,d=o.children,u=He(d,jt);return u?u.map(function(c,h){var f=c.props,p=f.direction,m=f.dataKey;return g.cloneElement(c,{key:"".concat(p,"-").concat(m,"-").concat(a[h]),data:a,xAxis:s,yAxis:l,layout:p==="x"?"vertical":"horizontal",dataPointFormatter:function(j,k){return{x:j.cx,y:j.cy,value:p==="x"?+j.node.x:+j.node.y,errorVal:ee(j,k)}}})}):null}},{key:"renderLine",value:function(){var i=this.props,o=i.points,a=i.line,s=i.lineType,l=i.lineJointType,d=W(this.props,!1),u=W(a,!1),c,h;if(s==="joint")c=o.map(function(b){return{x:b.cx,y:b.cy}});else if(s==="fitting"){var f=ii(o),p=f.xmin,m=f.xmax,y=f.a,j=f.b,k=function(w){return y*w+j};c=[{x:p,y:k(p)},{x:m,y:k(m)}]}var x=L(L(L({},d),{},{fill:"none",stroke:d&&d.fill},u),{},{points:c});return g.isValidElement(a)?h=g.cloneElement(a,x):te(a)?h=a(x):h=g.createElement(xe,je({},x,{type:l})),g.createElement(R,{className:"recharts-scatter-line",key:"recharts-scatter-line"},h)}},{key:"render",value:function(){var i=this.props,o=i.hide,a=i.points,s=i.line,l=i.className,d=i.xAxis,u=i.yAxis,c=i.left,h=i.top,f=i.width,p=i.height,m=i.id,y=i.isAnimationActive;if(o||!a||!a.length)return null;var j=this.state.isAnimationFinished,k=ke("recharts-scatter",l),x=d&&d.allowDataOverflow,b=u&&u.allowDataOverflow,w=x||b,A=K(m)?this.id:m;return g.createElement(R,{className:k,clipPath:w?"url(#clipPath-".concat(A,")"):null},x||b?g.createElement("defs",null,g.createElement("clipPath",{id:"clipPath-".concat(A)},g.createElement("rect",{x:x?c:c-f/2,y:b?h:h-p/2,width:x?f:f*2,height:b?p:p*2}))):null,s&&this.renderLine(),this.renderErrorBar(),g.createElement(R,{key:"recharts-scatter-symbols"},this.renderSymbols()),(!y||j)&&Ge.renderCallByParent(this.props,a))}}],[{key:"getDerivedStateFromProps",value:function(i,o){return i.animationId!==o.prevAnimationId?{prevAnimationId:i.animationId,curPoints:i.points,prevPoints:o.curPoints}:i.points!==o.curPoints?{curPoints:i.points}:null}}])})(T.PureComponent);q(We,"displayName","Scatter");q(We,"defaultProps",{xAxisId:0,yAxisId:0,zAxisId:0,legendType:"circle",lineType:"joint",lineJointType:"linear",data:[],shape:"circle",hide:!1,isAnimationActive:!Ye.isSsr,animationBegin:0,animationDuration:400,animationEasing:"linear"});q(We,"getComposedData",function(e){var t=e.xAxis,r=e.yAxis,i=e.zAxis,o=e.item,a=e.displayedData,s=e.xAxisTicks,l=e.yAxisTicks,d=e.offset,u=o.props.tooltipType,c=He(o.props.children,ni),h=K(t.dataKey)?o.props.dataKey:t.dataKey,f=K(r.dataKey)?o.props.dataKey:r.dataKey,p=i&&i.dataKey,m=i?i.range:De.defaultProps.range,y=m&&m[0],j=t.scale.bandwidth?t.scale.bandwidth():0,k=r.scale.bandwidth?r.scale.bandwidth():0,x=a.map(function(b,w){var A=ee(b,h),P=ee(b,f),O=!K(p)&&ee(b,p)||"-",z=[{name:K(t.dataKey)?o.props.name:t.name||t.dataKey,unit:t.unit||"",value:A,payload:b,dataKey:h,type:u},{name:K(r.dataKey)?o.props.name:r.name||r.dataKey,unit:r.unit||"",value:P,payload:b,dataKey:f,type:u}];O!=="-"&&z.push({name:i.name||i.dataKey,unit:i.unit||"",value:O,payload:b,dataKey:p,type:u});var _=ue({axis:t,ticks:s,bandSize:j,entry:b,index:w,dataKey:h}),$=ue({axis:r,ticks:l,bandSize:k,entry:b,index:w,dataKey:f}),v=O!=="-"?i.scale(O):y,S=Math.sqrt(Math.max(v,0)/Math.PI);return L(L({},b),{},{cx:_,cy:$,x:_-S,y:$-S,xAxis:t,yAxis:r,zAxis:i,width:2*S,height:2*S,size:v,node:{x:A,y:P,z:O},tooltipPayload:z,tooltipPosition:{x:_,y:$},payload:b},c&&c[w]&&c[w].props)});return L({points:x},d)});var kn=St({chartName:"LineChart",GraphicalChild:oe,axisComponents:[{axisType:"xAxis",AxisComp:$e},{axisType:"yAxis",AxisComp:ve}],formatAxisMap:wt}),Sn=St({chartName:"ComposedChart",GraphicalChild:[oe,ae,At,We],axisComponents:[{axisType:"xAxis",AxisComp:$e},{axisType:"yAxis",AxisComp:ve},{axisType:"zAxis",AxisComp:De}],formatAxisMap:wt});const U={sonnet:6.6,haiku:1.76,opus:33};function Ht(e){return e!=null&&e.includes("opus")?13.5:e!=null&&e.includes("haiku")?.22:2.7}function wn(e){return e.includes("opus")?U.opus:e.includes("haiku")?U.haiku:U.sonnet}function An(e){return e.includes("opus")?"Opus":e.includes("haiku")?"Haiku":"Sonnet"}function X(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function Y(e){return e===0?"$0.00":e<.001?"<$0.001":e<.01?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function Pn(e,t=5){const r=[];let i=0,o=[];function a(s,l){if(l.length===0)return;let d=0;for(;d<l.length;){const u=l[d].tool_name;let c=d+1;for(;c<l.length&&l[c].tool_name===u;)c++;const h=c-d;if(h>=t){const f=l.slice(d,c);let p,m=!1;if(["Read","Edit","Write","Glob","Grep"].includes(u)){const y=new Set;for(const j of f)try{const k=JSON.parse(j.tool_input||"{}"),x=k.file_path||k.pattern||k.path||"";x&&y.add(x.split("/").pop()||x)}catch{}if(m=y.size>1,p=y.size===1?[...y][0]:y.size>1?`${y.size} different files`:void 0,m&&h<6){d=c;continue}}else if(u.includes("mem_save")){const y=new Set;for(const j of f)try{const k=JSON.parse(j.tool_input||"{}");k.topic&&y.add(k.topic)}catch{}if(m=y.size>1,p=y.size===1?[...y][0]:void 0,m){d=c;continue}}else if(u==="Bash")try{const y=JSON.parse(f[0].tool_input||"{}").command||"";p=y.length>50?y.slice(0,48)+"…":y}catch{}r.push({blockIndex:s+1,toolName:u,count:h,detail:p,multiFile:m})}d=c}}for(const s of e)s.type==="Stop"?(a(i,o),i++,o=[]):(s.type==="Done"||s.type==="PreToolUse")&&s.tool_name&&o.push(s);return o.length>0&&a(i,o),r}function ft(e,t,r){switch(e){case"Read":return t?"Claude is reading different files in sequence without processing information between reads. Group exploration with Glob/Grep first to reduce the number of Reads.":`"${r||"the file"}" was read multiple times in a row. Use offset+limit to read only the necessary section, or Grep to search without reading the entire file. Re-reading the same file wastes context tokens.`;case"Edit":return`"${r||"the file"}" was edited multiple times in a row. This happens when instructions are imprecise — Claude attempts the edit, fails or it doesn't match expectations, and retries. Be more specific: indicate the exact change (old_string → new_string) instead of describing the result.`;case"Write":return`"${r||"the file"}" was overwritten multiple times. Consolidate all changes into a single instruction instead of writing intermediate versions.`;case"Bash":return`Repeated command: "${r||"…"}". Bash loops are usually retries due to error. Verify that the previous command succeeded before continuing, or ask Claude to show the error output.`;case"Grep":case"Glob":return"Repeated searches with similar patterns. Claude is searching for something it can't find. Try a broader pattern or use Read to see the directory structure directly.";default:return e.includes("mem_save")?`The same topic "${r||"…"}" was saved in Engram multiple times in a row. Use mem_update to edit an existing observation instead of creating duplicates.`:`The tool ${e} was executed multiple times in a row. Check if Claude is ignoring previous results.`}}function On(e,t,r,i){var a;const o=[];if(r&&r.length>0){const s=Pn(r,5),l=new Map;for(const d of s){const u=l.get(d.toolName)||[];u.push(d),l.set(d.toolName,u)}for(const[d,u]of l){const c=u.map(m=>`#${m.blockIndex}`).join(", "),h=u.reduce((m,y)=>m+y.count,0),f=u[0],p=(a=i==null?void 0:i.find(m=>m.index===f.blockIndex))==null?void 0:a.text;o.push({level:"error",title:`Loop: ${d} ×${h} — bloques ${c}`,text:ft(d,f.multiFile,f.detail),prompt:p,blockIndex:f.blockIndex})}}else if(e!=null&&e.loops&&e.loops.length>0)for(const s of e.loops)o.push({level:"error",title:`Loop: ${s.toolName} ×${s.count}`,text:ft(s.toolName,!1)});if(r&&r.length>0){const s=new Map;for(const d of r)if(d.tool_name==="Read"&&d.type==="Done"&&d.tool_input)try{const u=JSON.parse(d.tool_input).file_path||"";u&&s.set(u,(s.get(u)||0)+1)}catch{}const l=[...s.entries()].filter(([,d])=>d>=5);if(l.length>0){const d=l.map(([u,c])=>`${u.split("/").pop()} (×${c})`).join(", ");o.push({level:"warning",title:`Scattered re-reads: ${l.length} file${l.length>1?"s":""}`,text:`${d}. These reads are not consecutive but add up to many context tokens. Consider saving the structure mentally before continuing to edit, or use Grep instead of reading the entire file.`})}}if(e){const s=e.input_tokens+e.cache_read+e.cache_creation,l=s>5e3?e.cache_read/s:-1;l>=0&&l<.3&&o.push({level:"warning",title:`Low cache hit: ${Math.round(l*100)}%`,text:"Claude caches context automatically in long sessions. Avoid manually clearing history and work in continuous sessions to accumulate cache."})}if(e&&e.efficiency_score>0&&e.efficiency_score<70&&o.push({level:"warning",title:`Low efficiency: ${e.efficiency_score}/100`,text:"Loops and re-reads are consuming tokens unnecessarily. Check if Claude is repeating steps or if instructions are ambiguous."}),t&&t.burnRateTokensPerMin>6e3&&o.push({level:"info",title:`High burn rate: ${t.burnRateTokensPerMin.toLocaleString()} tok/min`,text:"You are consuming tokens very quickly. Consider asking for more concise responses, avoid attaching large complete files, or break the task into steps."}),r&&r.length>0){const s=r.filter(c=>c.type==="Done"),l=s.filter(c=>c.tool_name==="Bash").length,d=s.filter(c=>c.tool_name==="Read").length,u=s.filter(c=>c.tool_name==="Grep").length;l>6&&u<Math.floor(l*.3)&&d>4&&o.push({level:"info",title:`Bash+Read without Grep (${l} Bash, ${d} Read)`,text:"You are combining Bash and Read to search for information. Grep is more efficient for searching within files — use Grep before Read when you don't know what line something is on."})}if(t&&t.cyclePct>70&&o.push({level:t.cyclePct>85?"error":"warning",title:`Quota at ${t.cyclePct}%`,text:`You used ${t.cyclePrompts}/${t.cycleLimit} prompts in the 5h window. Group several changes in a single message instead of sending one by one.`}),e&&e.cache_read>3e4){const s=e.cache_read/1e6*Ht(e.model);s>.02&&o.push({level:"success",title:`Optimal cache — saving ${Y(s)}`,text:"You are making good use of prompt cache. Long and continuous sessions maximize savings."})}return e&&e.efficiency_score>=90&&o.push({level:"success",title:`Excellent efficiency: ${e.efficiency_score}/100`,text:"No loops detected in this session. Good work pace."}),o}function M({children:e,style:t}){return n.jsx("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"14px 16px",...t},children:e})}function G({icon:e,title:t,subtitle:r,color:i="#58a6ff"}){return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:12},children:[n.jsx(e,{size:13,color:i}),n.jsx("span",{style:{fontSize:12,color:"#e6edf3",fontWeight:700},children:t}),r&&n.jsx("span",{style:{fontSize:10,color:"#484f58",marginLeft:2},children:r})]})}function ze({content:e,position:t="bottom",align:r="left",style:i}){return n.jsx(N,{position:t,align:r,content:e,children:n.jsx(_t,{size:9,color:"#3d444d",style:{cursor:"help",...i}})})}function zn({quota:e,cost:t}){const r=(t==null?void 0:t.context_used)??0,i=(t==null?void 0:t.context_window)??2e5,o=Math.round(i*.85),a=r>0&&o>0?Math.min(100,Math.round(r/o*100)):null,s=a!==null?100-a:null,l=s===null?"#484f58":s<20?"#f85149":s<40?"#d29922":"#3fb950",d=(t==null?void 0:t.cost_usd)??0,u=(t==null?void 0:t.input_tokens)??0,c=(t==null?void 0:t.output_tokens)??0,h=(t==null?void 0:t.cache_read)??0,f=(t==null?void 0:t.model)??null,p=e.burnRateTokensPerMin??0,m=f?f.replace("claude-","").replace(/-\d{8}$/,""):null;return n.jsxs(M,{style:{borderColor:"#30363d"},children:[n.jsx(G,{icon:Se,title:"Current status",subtitle:"real-time",color:"#58a6ff"}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:12},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6},children:[n.jsx(oi,{size:10,color:"#484f58"}),n.jsx("span",{style:{fontSize:10,color:"#484f58",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Context"}),n.jsx(ze,{position:"bottom",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:4},children:"Free context space"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.6},children:["Percentage available before Claude activates auto-compact.",n.jsx("br",{}),"Compact occurs at 85% of the window limit (normally 200K tokens).",n.jsx("br",{}),n.jsx("span",{style:{color:"#d29922"},children:"Below 20%: consider using /clear."})]})]})})]}),s!==null?n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{fontSize:26,fontWeight:700,color:l,lineHeight:1,fontVariantNumeric:"tabular-nums"},children:[s,"%"]}),n.jsx("div",{style:{fontSize:9,color:l,opacity:.7,lineHeight:1,marginBottom:4},children:"free"}),n.jsxs("div",{style:{fontSize:9,color:"#484f58",marginBottom:6},children:[Math.round(r/1e3),"k used · limit ",Math.round(o/1e3),"k"]}),n.jsx("div",{style:{width:"100%",height:4,background:"#21262d",borderRadius:2,overflow:"hidden"},children:n.jsx("div",{style:{width:`${a}%`,height:"100%",background:l,borderRadius:2,transition:"width 0.5s"}})}),n.jsx("div",{style:{fontSize:9,color:"#3d444d",marginTop:4},children:s<20?"⚠ Consider /clear soon":s<40?"Moderate — ok for now":"No context pressure"})]}):n.jsx("div",{style:{fontSize:12,color:"#484f58"},children:"Waiting for data…"})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6},children:[n.jsx(Se,{size:10,color:"#484f58"}),n.jsx("span",{style:{fontSize:10,color:"#484f58",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Current session"}),n.jsx(ze,{position:"bottom",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:4},children:"Cost of this session"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.6},children:["Accumulated from the first message of the active session.",n.jsx("br",{}),n.jsx("span",{style:{color:"#79c0ff"},children:"in"})," = tokens sent to Claude (context + message).",n.jsx("br",{}),n.jsx("span",{style:{color:"#56d364"},children:"out"})," = tokens generated by Claude.",n.jsx("br",{}),"cache = tokens reused (~10× cheaper than fresh input)."]})]})})]}),d>0?n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:26,fontWeight:700,color:"#e6edf3",lineHeight:1,fontVariantNumeric:"tabular-nums"},children:Y(d)}),n.jsxs("div",{style:{fontSize:9,color:"#484f58",marginTop:6,lineHeight:2},children:[n.jsx("span",{style:{color:"#79c0ff"},children:"in"})," ",X(u),h>0&&n.jsxs("span",{style:{color:"#3d444d"},children:[" · ",X(h)," cache"]}),n.jsx("br",{}),n.jsx("span",{style:{color:"#56d364"},children:"out"})," ",X(c)]})]}):n.jsx("div",{style:{fontSize:12,color:"#484f58"},children:"No active session"})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:6},children:[n.jsx(ai,{size:10,color:"#484f58"}),n.jsx("span",{style:{fontSize:10,color:"#484f58",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Model"}),n.jsx(ze,{position:"bottom",align:"right",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:4},children:"Active model"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.6},children:["Claude model used in the current session.",n.jsx("br",{}),"The ",n.jsx("span",{style:{color:"#d29922"},children:"burn rate"})," indicates tokens consumed per minute in real time — useful for estimating how long the quota will last before the next 5h reset."]})]})})]}),m?n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{fontSize:15,fontWeight:700,color:"#e6edf3",lineHeight:1.3},children:m}),n.jsx("div",{style:{fontSize:9,color:"#3d444d",marginTop:3,wordBreak:"break-all"},children:f})]}):n.jsx("div",{style:{fontSize:12,color:"#484f58"},children:"—"}),p>0&&n.jsx(N,{position:"top",align:"right",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#d29922",fontWeight:700,fontSize:11,marginBottom:3},children:"Current burn rate"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Tokens consumed per minute in this session.",n.jsx("br",{}),"High burn rate = large context or long responses.",n.jsx("br",{}),"More than 6,000 tok/min can drain quota quickly."]})]}),children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:8,cursor:"help"},children:[n.jsx(si,{size:9,color:"#d29922"}),n.jsxs("span",{style:{fontSize:10,color:"#d29922",fontWeight:600,fontVariantNumeric:"tabular-nums"},children:[p.toLocaleString()," tok/min"]})]})})]})]})]})}function _n({stats:e}){const t=e.today,r=e.todayLabel,i=e.last7;if(!t&&i.messages===0)return n.jsxs(M,{children:[n.jsx(G,{icon:Se,title:"Activity (stats-cache.json)"}),n.jsx("span",{style:{fontSize:12,color:"#484f58"},children:"No data yet in stats-cache.json"})]});const o=[{label:"Messages",icon:li,today:(t==null?void 0:t.messages)??0,week:i.messages,color:"#58a6ff",tooltip:`Total messages (human + assistant).
3
- Divide by 2 to estimate real prompts.
4
- Source: ~/.claude/stats-cache.json`},{label:"Sessions",icon:Ot,today:(t==null?void 0:t.sessions)??0,week:i.sessions,color:"#3fb950",tooltip:`Different conversations started with Claude Code.
5
- Each time you run "claude" in a directory counts as a session.`},{label:"Tools",icon:ci,today:(t==null?void 0:t.tools)??0,week:i.tools,color:"#d29922",tooltip:`Tool calls executed (Read, Edit, Bash, Grep…).
6
- High number indicates code-intensive sessions.`},{label:"Out tokens",icon:Xe,today:(t==null?void 0:t.outputTokens)??0,week:i.outputTokens,color:"#a371f7",fmt:X,tooltip:`Tokens generated by Claude in responses.
7
- These most influence session cost.`}];return n.jsxs(M,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[n.jsx(di,{size:13,color:"#58a6ff"}),n.jsx("span",{style:{fontSize:12,color:"#e6edf3",fontWeight:700},children:"Activity"}),r&&n.jsxs("span",{style:{fontSize:10,color:"#484f58",marginLeft:2},children:[r," / 7 days"]})]}),e.cacheDate&&n.jsxs("span",{style:{fontSize:9,color:"#3d444d"},children:["cache: ",e.cacheDate]})]}),n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10,justifyItems:"center"},children:o.map(a=>{const s=a.fmt??(l=>l.toLocaleString());return n.jsx(N,{position:"bottom",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:a.color,fontWeight:700,fontSize:11,marginBottom:4},children:a.label}),n.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5,whiteSpace:"pre-line"},children:a.tooltip})]}),children:n.jsxs("div",{style:{textAlign:"center",cursor:"help"},children:[n.jsx(a.icon,{size:11,color:a.color,style:{marginBottom:4}}),n.jsx("div",{style:{fontSize:9,color:"#6e7681",marginBottom:2,fontWeight:600},children:a.label}),n.jsx("div",{style:{fontSize:16,fontWeight:700,color:a.color,lineHeight:1,fontVariantNumeric:"tabular-nums"},children:s(a.today)}),n.jsx("div",{style:{fontSize:9,color:"#484f58",marginBottom:4},children:r??"—"}),n.jsx("div",{style:{fontSize:11,color:"#6e7681",fontVariantNumeric:"tabular-nums"},children:s(a.week)}),n.jsx("div",{style:{fontSize:9,color:"#3d444d"},children:"7 days"})]})},a.label)})}),n.jsxs("div",{style:{fontSize:9,color:"#3d444d",marginTop:10},children:["Source: ~/.claude/stats-cache.json · Messages include human + assistant (÷2 ≈ real prompts) · ",e.allTime.sessions," total sessions"]}),e.cacheIsStale&&n.jsxs("div",{style:{fontSize:9,color:"#d29922",marginTop:4},children:["⚠ Stale cache (",e.cacheDate,") — Claude Code updates this file when each CLI session ends"]})]})}function $n({quota:e}){const t=[{label:"Sonnet",color:"#58a6ff",hours:e.weeklyHoursSonnet,limit:e.weeklyLimitSonnet,tokens:e.weeklyTokensSonnet??0,price:U.sonnet},{label:"Haiku",color:"#3fb950",hours:e.weeklyHoursHaiku,limit:0,tokens:e.weeklyTokensHaiku??0,price:U.haiku},{label:"Opus",color:"#d29922",hours:e.weeklyHoursOpus,limit:e.weeklyLimitOpus,tokens:e.weeklyTokensOpus??0,price:U.opus}].filter(o=>o.hours>0||o.tokens>0),r=t.reduce((o,a)=>o+a.tokens/1e6*a.price,0),i=t.reduce((o,a)=>o+a.tokens,0);return n.jsxs(M,{children:[n.jsx(G,{icon:fi,title:"Models this week"}),t.length===0?n.jsx("span",{style:{fontSize:12,color:"#484f58"},children:"No activity this week"}):n.jsxs(n.Fragment,{children:[t.map(o=>{const a=o.limit>0?Math.min(100,o.hours/o.limit*100):0,s=o.tokens/1e6*o.price,l=i>0?Math.round(o.tokens/i*100):0;return n.jsxs("div",{style:{marginBottom:10},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[n.jsx(N,{position:"bottom",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:o.color,fontWeight:700,fontSize:11,marginBottom:3},children:o.label}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Estimated price: ~$",o.price,"/M tokens (blended input/output)",n.jsx("br",{}),"Hours = 5 min windows where Claude used this model",n.jsx("br",{}),o.limit>0?`Max weekly limit: ${o.limit}h`:"No weekly limit configured"]})]}),children:n.jsx("span",{style:{width:46,fontSize:11,color:o.color,fontWeight:700,flexShrink:0,cursor:"help"},children:o.label})}),n.jsx("span",{style:{fontSize:13,color:"#e6edf3",fontWeight:600},children:o.hours>0?`${o.hours}h`:"—"}),o.limit>0&&n.jsxs("span",{style:{fontSize:10,color:"#484f58"},children:["/ ",o.limit,"h"]}),n.jsx("div",{style:{flex:1}}),n.jsx("span",{style:{fontSize:10,color:"#6e7681"},children:X(o.tokens)}),n.jsx("span",{style:{fontSize:10,color:"#3d444d"},children:"·"}),n.jsxs("span",{style:{fontSize:10,color:"#484f58"},children:[l,"%"]}),n.jsxs("span",{style:{fontSize:10,color:"#3fb950",marginLeft:4},children:["~",Y(s)]})]}),o.limit>0&&o.hours>0&&n.jsx("div",{style:{height:3,background:"#21262d",borderRadius:2,overflow:"hidden"},children:n.jsx("div",{style:{width:`${a}%`,height:"100%",background:a>85?"#f85149":a>65?"#d29922":o.color,borderRadius:2}})}),o.limit===0&&o.tokens>0&&n.jsx("div",{style:{height:3,background:"#21262d",borderRadius:2,overflow:"hidden"},children:n.jsx("div",{style:{width:`${l}%`,height:"100%",background:o.color+"aa",borderRadius:2}})})]},o.label)}),n.jsxs("div",{style:{borderTop:"1px solid #21262d",paddingTop:8,marginTop:4,display:"flex",gap:16},children:[n.jsxs("div",{children:[n.jsxs("div",{style:{fontSize:11,color:"#8b949e"},children:[X(i)," tokens"]}),n.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"total week"})]}),n.jsxs("div",{children:[n.jsxs("div",{style:{fontSize:11,color:"#3fb950"},children:["~",Y(r)]}),n.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"estimated cost"})]})]}),n.jsx("div",{style:{fontSize:9,color:"#3d444d",marginTop:6},children:"Hours = 5 min active windows · Tokens = input + output · Estimated blended price"})]})]})}const Tn={"cache hit":'Tokens served from prompt cache. They are ~10× cheaper than fresh input. Indicates how much context Claude already "remembered" without reprocessing.',"cache create":"Tokens written to cache for the first time. Paid once and reused in subsequent reads. More expensive than fresh input but amortize over time.","input fresh":"New context that Claude processed without prior cache — full input price.",output:"Tokens generated by Claude in responses. They are the most expensive (~3× more than input in Sonnet)."};function Cn({cost:e}){const{input_tokens:t,cache_read:r,cache_creation:i,output_tokens:o}=e,a=t+r+i+o,s=a>0?Math.round(r/(t+r+i)*100):0,l=r/1e6*Ht(e.model),d=s>=70?"#3fb950":s>=40?"#d29922":"#f85149",u=[{label:"cache hit",color:"#3fb95099",tokens:r,pct:a>0?r/a*100:0},{label:"cache create",color:"#58a6ff55",tokens:i,pct:a>0?i/a*100:0},{label:"input fresh",color:"#8b949e55",tokens:t,pct:a>0?t/a*100:0},{label:"output",color:"#d2992255",tokens:o,pct:a>0?o/a*100:0}].filter(c=>c.tokens>0);return n.jsxs(M,{children:[n.jsx(G,{icon:Pt,title:"Cache efficiency",subtitle:"current session",color:d}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:10},children:[n.jsxs("span",{style:{fontSize:28,fontWeight:700,color:d,fontVariantNumeric:"tabular-nums",lineHeight:1},children:[s,"%"]}),n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:11,color:"#e6edf3"},children:"cache hit rate"}),l>.001&&n.jsxs("div",{style:{fontSize:10,color:"#3fb950"},children:["~",Y(l)," saved"]}),n.jsx(N,{position:"bottom",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:3},children:"Why 70%?"}),n.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:"Below 70% cache savings are marginal. In long and continuous sessions hit rate naturally rises. Avoid using /clear in the middle of a session to not lose accumulated cache."})]}),children:n.jsx("span",{style:{fontSize:9,color:"#484f58",cursor:"help",textDecoration:"underline dotted"},children:"target ≥70%"})})]})]}),n.jsx("div",{style:{height:8,background:"#21262d",borderRadius:4,overflow:"hidden",display:"flex",marginBottom:10},children:u.map(c=>n.jsx("div",{style:{width:`${c.pct}%`,height:"100%",background:c.color}},c.label))}),n.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 14px"},children:u.map(c=>n.jsx(N,{position:"top",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:c.color.substring(0,7),fontWeight:700,fontSize:11,marginBottom:3},children:c.label}),n.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:Tn[c.label]??""})]}),children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,cursor:"help"},children:[n.jsx("div",{style:{width:8,height:8,borderRadius:2,background:c.color,flexShrink:0}}),n.jsx("span",{style:{fontSize:10,color:"#6e7681"},children:X(c.tokens)}),n.jsx("span",{style:{fontSize:10,color:"#484f58"},children:c.label})]})},c.label))})]})}function En({cost:e}){const{loops:t,efficiency_score:r}=e,i=(t==null?void 0:t.reduce((s,l)=>s+l.count,0))??0,o=i*1200/1e6*U.sonnet,a=r>=90?"#3fb950":r>=70?"#d29922":"#f85149";return n.jsxs(M,{children:[n.jsx(G,{icon:Ue,title:"Loops and efficiency",subtitle:"current session",color:i>0?"#f85149":"#3fb950"}),n.jsxs("div",{style:{display:"flex",gap:16,marginBottom:i>0?10:0},children:[n.jsxs("div",{children:[n.jsx("div",{style:{fontSize:26,fontWeight:700,color:i>0?"#f85149":"#3fb950",lineHeight:1},children:i}),n.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"loops detected"})]}),n.jsx(N,{position:"bottom",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:a,fontWeight:700,fontSize:11,marginBottom:3},children:"Efficiency score"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["100 = no loops detected.",n.jsx("br",{}),"~5 points deducted for each repeated tool in a block.",n.jsx("br",{}),"Below 70 indicates inefficient session with wasted tokens."]})]}),children:n.jsxs("div",{style:{cursor:"help"},children:[n.jsx("div",{style:{fontSize:26,fontWeight:700,color:a,lineHeight:1},children:r}),n.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"efficiency /100"})]})}),i>0&&n.jsx(N,{position:"bottom",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#d29922",fontWeight:700,fontSize:11,marginBottom:3},children:"Lost cost estimate"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Calculated as: loops × ~1,200 tokens × blended Sonnet price.",n.jsx("br",{}),"This is a conservative estimate — actual cost may be higher if loops involve large files."]})]}),children:n.jsxs("div",{style:{cursor:"help"},children:[n.jsxs("div",{style:{fontSize:16,fontWeight:600,color:"#d29922",lineHeight:1},children:["~",Y(o)]}),n.jsx("div",{style:{fontSize:9,color:"#484f58"},children:"wasted tokens"})]})})]}),i>0&&t&&n.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5,marginBottom:8},children:t.map((s,l)=>n.jsxs("span",{style:{fontSize:11,color:"#f85149",background:"#f8514914",border:"1px solid #f8514930",borderRadius:4,padding:"2px 7px"},children:[s.toolName," ×",s.count]},l))}),n.jsx("div",{style:{height:3,background:"#21262d",borderRadius:2,overflow:"hidden"},children:n.jsx("div",{style:{width:`${r}%`,height:"100%",background:a,borderRadius:2,transition:"width 0.5s"}})})]})}const In={Reading:"Read, Grep, Glob — tools for reading and searching files. High % may indicate excessive exploration before editing.",Editing:"Edit, Write, NotebookEdit — tools that modify files. This is the real productive work.",Terminal:"Bash — shell commands executed directly. Many Bash + few Grep may indicate inefficient searches.",Search:"WebFetch, WebSearch — internet and web page searches.",Agents:"Agent, Task, SendMessage — sub-agents launched for parallel tasks. They consume their own context quota.",Others:"Tools that don't fit in previous categories (Config, ToolSearch, etc.)."},de=[{label:"Reading",tools:["Read","Grep","Glob"],color:"#58a6ff"},{label:"Editing",tools:["Edit","Write","NotebookEdit"],color:"#3fb950"},{label:"Terminal",tools:["Bash"],color:"#d29922"},{label:"Search",tools:["WebFetch","WebSearch"],color:"#bc8cff"},{label:"Agents",tools:["Agent","Task","SendMessage"],color:"#f0883e"}];function Dn(e){for(let t=0;t<de.length;t++)if(de[t].tools.some(r=>e.startsWith(r)))return t;return de.length}function Wn({events:e,cost:t}){const r=e.filter(l=>l.type==="Done"&&l.tool_name);if(r.length===0)return null;const i=new Array(de.length+1).fill(0);for(const l of r)i[Dn(l.tool_name)]++;const o=r.length,a=(t==null?void 0:t.output_tokens)??0,s=[...de.map((l,d)=>({...l,count:i[d]})),{label:"Others",color:"#484f58",count:i[de.length]}].filter(l=>l.count>0).sort((l,d)=>d.count-l.count);return n.jsxs(M,{children:[n.jsx(G,{icon:Se,title:"Activity distribution",subtitle:"current session"}),n.jsx("div",{style:{height:8,background:"#21262d",borderRadius:4,overflow:"hidden",display:"flex",marginBottom:12},children:s.map(l=>n.jsx("div",{style:{width:`${l.count/o*100}%`,height:"100%",background:l.color}},l.label))}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[s.map(l=>{const d=Math.round(l.count/o*100),u=a>0?Math.round(a*l.count/o):0;return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx("div",{style:{width:8,height:8,borderRadius:2,background:l.color,flexShrink:0}}),n.jsx("span",{style:{fontSize:11,color:"#8b949e",minWidth:70},children:l.label}),n.jsx("div",{style:{flex:1,height:3,background:"#21262d",borderRadius:2,overflow:"hidden"},children:n.jsx("div",{style:{width:`${d}%`,height:"100%",background:l.color,opacity:.7,borderRadius:2}})}),n.jsxs("span",{style:{fontSize:10,color:"#6e7681",fontVariantNumeric:"tabular-nums",minWidth:28,textAlign:"right"},children:[d,"%"]}),n.jsx("span",{style:{fontSize:10,color:"#484f58",fontVariantNumeric:"tabular-nums",minWidth:42,textAlign:"right"},children:u>0?`~${X(u)}`:`${l.count}×`}),n.jsx(ze,{position:"top",align:"right",style:{flexShrink:0},content:n.jsxs("div",{children:[n.jsx("div",{style:{color:l.color,fontWeight:700,fontSize:11,marginBottom:3},children:l.label}),n.jsx("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:In[l.label]??""})]})})]},l.label)}),n.jsxs("div",{style:{fontSize:9,color:"#3d444d",marginTop:2},children:[o," tool calls · ",a>0?`~${X(a)} estimated output tokens`:"tokens pending from active session"]})]})]})}function Bn({quota:e,cost:t}){const r=(e.weeklyTokensSonnet??0)+(e.weeklyTokensOpus??0)+(e.weeklyTokensHaiku??0),i=(e.weeklyTokensSonnet??0)/1e6*U.sonnet+(e.weeklyTokensOpus??0)/1e6*U.opus+(e.weeklyTokensHaiku??0)/1e6*U.haiku,o=i*4.3,a=i/7,s=wn((t==null?void 0:t.model)??""),l=An((t==null?void 0:t.model)??""),d=e.burnRateTokensPerMin>0?e.burnRateTokensPerMin*60/1e6*s:0;return n.jsxs(M,{children:[n.jsx(G,{icon:$t,title:"Monthly projection",subtitle:"based on this week"}),n.jsxs("div",{style:{display:"flex",gap:20,flexWrap:"wrap",marginBottom:10},children:[n.jsx(N,{position:"top",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#58a6ff",fontWeight:700,fontSize:11,marginBottom:3},children:"Monthly projection"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Weekly consumption × 4.3 (weeks/month).",n.jsx("br",{}),"Assumes upcoming weeks will have the same pace.",n.jsx("br",{}),"Based on actual Sonnet, Opus, and Haiku tokens with blended prices."]})]}),children:n.jsxs("div",{style:{cursor:"help"},children:[n.jsx("div",{style:{fontSize:24,fontWeight:700,color:"#e6edf3",fontVariantNumeric:"tabular-nums",lineHeight:1},children:i>0?`~${Y(o)}`:"—"}),n.jsxs("div",{style:{fontSize:9,color:"#484f58"},children:["/month · ",i>0?`${Y(i)}/week · ${Y(a)}/day`:"no data"]})]})}),d>0&&n.jsx(N,{position:"top",align:"left",content:n.jsxs("div",{children:[n.jsx("div",{style:{color:"#d29922",fontWeight:700,fontSize:11,marginBottom:3},children:"Cost per hour (now)"}),n.jsxs("div",{style:{color:"#8b949e",fontSize:10,lineHeight:1.5},children:["Calculated with active model (",l,") at blended price.",n.jsx("br",{}),e.burnRateTokensPerMin.toLocaleString()," tok/min × 60 ÷ 1M × price/M"]})]}),children:n.jsxs("div",{style:{cursor:"help"},children:[n.jsxs("div",{style:{fontSize:18,fontWeight:700,color:"#d29922",fontVariantNumeric:"tabular-nums",lineHeight:1},children:["~",Y(d),"/h"]}),n.jsxs("div",{style:{fontSize:9,color:"#484f58"},children:["now · ",e.burnRateTokensPerMin.toLocaleString()," tok/min"]})]})})]}),r>0&&n.jsxs("div",{style:{fontSize:10,color:"#484f58"},children:[X(r)," tokens this week · estimated blended input/output prices"]})]})}const Rn={error:{color:"#f85149",bg:"#3d1717",border:"#f8514940",Icon:ui},warning:{color:"#d29922",bg:"#2d2008",border:"#d2992240",Icon:Ue},info:{color:"#58a6ff",bg:"#0d1e33",border:"#58a6ff30",Icon:_t},success:{color:"#3fb950",bg:"#0d1f10",border:"#3fb95030",Icon:zt}};function Ln({tips:e}){return e.length===0?n.jsxs(M,{children:[n.jsx(G,{icon:et,title:"Real-time optimizer",color:"#d29922"}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:"#484f58",fontSize:12},children:[n.jsx(zt,{size:14,color:"#3fb950"}),"Clean session — no optimization suggestions at this time"]})]}):n.jsxs(M,{children:[n.jsx(G,{icon:et,title:"Real-time optimizer",subtitle:`${e.length} suggestion${e.length>1?"s":""}`,color:"#d29922"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:e.map((t,r)=>{const i=Rn[t.level];return n.jsxs("div",{style:{background:i.bg,border:`1px solid ${i.border}`,borderLeft:`3px solid ${i.color}`,borderRadius:6,padding:"8px 10px"},children:[n.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start"},children:[n.jsx(i.Icon,{size:13,color:i.color,style:{flexShrink:0,marginTop:2}}),n.jsxs("div",{style:{flex:1},children:[n.jsx("div",{style:{fontSize:11,fontWeight:700,color:i.color,marginBottom:3},children:t.title}),n.jsx("div",{style:{fontSize:11,color:"#8b949e",lineHeight:1.5},children:t.text})]})]}),t.prompt&&n.jsxs("div",{style:{marginTop:8,padding:"6px 10px",background:"#0d1117",border:"1px solid #30363d",borderRadius:5},children:[n.jsxs("div",{style:{fontSize:9,color:"#484f58",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",marginBottom:4},children:["Prompt that caused it — Block #",t.blockIndex]}),n.jsxs("div",{style:{fontSize:11,color:"#7d8590",fontStyle:"italic",lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:80,overflow:"hidden",WebkitMaskImage:"linear-gradient(to bottom, black 60%, transparent 100%)"},children:['"',t.prompt,'"']})]})]},r)})})]})}function Nn({quota:e,cost:t,events:r,prompts:i,claudeStats:o}){if(!e)return n.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#484f58",fontSize:13},children:"Loading usage data…"});const a=On(t,e,r,i);return n.jsx("div",{style:{padding:"16px 20px"},children:n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gridTemplateRows:"auto",gap:12,maxWidth:1200,margin:"0 auto"},children:[n.jsx("div",{style:{gridColumn:"1 / -1"},children:n.jsx(zn,{quota:e,cost:t})}),o&&n.jsx("div",{style:{gridColumn:"1 / -1"},children:n.jsx(_n,{stats:o})}),n.jsx("div",{style:{gridColumn:"1 / -1"},children:n.jsx(Ln,{tips:a})}),r&&r.length>0?n.jsx(Wn,{events:r,cost:t}):n.jsx("div",{}),t?n.jsx(Cn,{cost:t}):n.jsxs(M,{children:[n.jsx(G,{icon:Pt,title:"Cache efficiency"}),n.jsx("span",{style:{fontSize:12,color:"#484f58"},children:"No active session data"})]}),n.jsx($n,{quota:e}),t?n.jsx(En,{cost:t}):n.jsxs(M,{children:[n.jsx(G,{icon:Ue,title:"Loops and efficiency"}),n.jsx("span",{style:{fontSize:12,color:"#484f58"},children:"No active session data"})]}),n.jsx("div",{style:{gridColumn:"1 / -1"},children:n.jsx(Bn,{quota:e,cost:t})})]})})}const Ae={7:"7 days",30:"30 days",90:"90 days"},ht={haiku:"#3fb950",sonnet:"#58a6ff",opus:"#d29922"};function Kt(e){return e.includes("haiku")?"haiku":e.includes("opus")?"opus":"sonnet"}function Pe(e){return e>=10?`$${e.toFixed(2)}`:`$${e.toFixed(3)}`}function me(e){if(e>=1e6)return`${(e/1e6).toFixed(1)}M`;if(e>=1e3){const t=Math.round(e/1e3);return t>=1e3?`${(t/1e3).toFixed(1)}M`:`${t}K`}return String(e)}function pt(e){return e<1?`${Math.round(e*60)}m`:`${e.toFixed(1)}h`}function Mn(e){return e==="No project"?e:e.split("/").filter(Boolean).pop()??e}function Fn(e){const t=new Map;for(const r of e){const i=Kt(r.model),o=t.get(r.date)??{date:r.date,haiku:0,sonnet:0,opus:0};o[i]=o[i]+r.tokens,t.set(r.date,o)}return[...t.values()]}function Hn(e){const t={};for(const i of e){const o=Kt(i.model);t[o]||(t[o]={tokens:0,cost:0}),t[o].tokens+=i.tokens,t[o].cost+=i.cost}const r={sonnet:"Sonnet",haiku:"Haiku",opus:"Opus"};return Object.entries(t).map(([i,o])=>({key:i,label:r[i]??i,...o})).filter(i=>i.tokens>0).sort((i,o)=>o.tokens-i.tokens)}const Oe={fontSize:11,fontWeight:600,color:"#6e7681",marginBottom:14,textTransform:"uppercase",letterSpacing:"0.05em"},yt={contentStyle:{background:"#161b22",border:"1px solid #30363d",borderRadius:6,fontSize:11},labelStyle:{color:"#e6edf3",fontWeight:600},itemStyle:{color:"#8b949e"}};function ce({icon:e,label:t,value:r,sub:i,color:o="#58a6ff",tip:a}){return n.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"14px 16px",flex:1,minWidth:140},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[n.jsx("span",{style:{color:o,opacity:.8},children:e}),n.jsx(N,{content:a,position:"bottom",align:"left",children:n.jsx("span",{style:{fontSize:10,color:"#6e7681",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",cursor:"default",borderBottom:"1px dotted #484f58"},children:t})})]}),n.jsx("div",{style:{fontSize:22,fontWeight:700,color:"#e6edf3",lineHeight:1},children:r}),i&&n.jsx("div",{style:{fontSize:10,color:"#484f58",marginTop:4},children:i})]})}function Kn({content:e}){return n.jsx("div",{style:{fontFamily:"inherit",lineHeight:1.7,color:"#c9d1d9"},children:e.split(`
8
- `).map((t,r)=>t.startsWith("# ")?n.jsx("h1",{style:{fontSize:18,fontWeight:700,color:"#e6edf3",margin:"20px 0 8px",borderBottom:"1px solid #21262d",paddingBottom:6},children:t.slice(2)},r):t.startsWith("## ")?n.jsx("h2",{style:{fontSize:15,fontWeight:600,color:"#e6edf3",margin:"16px 0 6px"},children:t.slice(3)},r):t.startsWith("### ")?n.jsx("h3",{style:{fontSize:13,fontWeight:600,color:"#8b949e",margin:"12px 0 4px"},children:t.slice(4)},r):t.startsWith("- [x] ")?n.jsxs("div",{style:{display:"flex",gap:8,margin:"3px 0",color:"#3fb950",fontSize:12},children:["✅ ",n.jsx("span",{style:{textDecoration:"line-through",color:"#6e7681"},children:t.slice(6)})]},r):t.startsWith("- [ ] ")?n.jsxs("div",{style:{display:"flex",gap:8,margin:"3px 0",fontSize:12},children:["⬜ ",n.jsx("span",{children:t.slice(6)})]},r):t.startsWith("- ")?n.jsxs("div",{style:{margin:"3px 0",paddingLeft:16,fontSize:12},children:["· ",t.slice(2)]},r):t.startsWith("> ")?n.jsx("blockquote",{style:{margin:"8px 0",paddingLeft:12,borderLeft:"3px solid #30363d",color:"#8b949e",fontSize:12},children:t.slice(2)},r):t.startsWith("---")?n.jsx("hr",{style:{border:"none",borderTop:"1px solid #21262d",margin:"14px 0"}},r):t.trim()===""?n.jsx("div",{style:{height:6}},r):n.jsx("p",{style:{margin:"3px 0",fontSize:12},children:t},r))})}function Gn(){const[e,t]=T.useState([]),[r,i]=T.useState(!1),[o,a]=T.useState(null),[s,l]=T.useState(!1),[d,u]=T.useState(!1),[c,h]=T.useState(null);function f(){fetch("/api/weekly-reports").then(x=>x.json()).then(t).catch(()=>{})}T.useEffect(()=>{f()},[]);async function p(){l(!0),h(null);try{const x=await fetch("/api/weekly-reports/generate-now",{method:"POST"}).then(b=>b.json());h(x.skipped?`Ya existe: ${x.date}`:`Generado: ${x.date}`),x.skipped||f()}catch{h("Error generating")}l(!1)}async function m(){u(!0),h(null);try{const x=await fetch("/api/weekly-reports/import-local",{method:"POST"}).then(b=>b.json());h(`${x.imported} imported, ${x.skipped} already existed`),x.imported>0&&f()}catch{h("Error importing")}u(!1)}async function y(x){const b=await fetch(`/api/weekly-reports/${x}`);b.ok&&(a(await b.json()),i(!1))}async function j(x,b){b.stopPropagation(),await fetch(`/api/weekly-reports/${x}`,{method:"DELETE"}).catch(()=>{}),(o==null?void 0:o.date)===x&&a(null),f()}const k={display:"inline-flex",alignItems:"center",gap:5,padding:"4px 10px",borderRadius:5,fontSize:11,fontWeight:600,cursor:"pointer",border:"1px solid #30363d",background:"none",color:"#8b949e",transition:"color 0.15s, border-color 0.15s"};return n.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,marginBottom:0},children:[n.jsxs("div",{style:{padding:"10px 14px",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[n.jsx(it,{size:12,color:"#6e7681"}),n.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#8b949e"},children:"Weekly reports"}),c&&n.jsx("span",{style:{fontSize:11,color:"#3fb950"},children:c}),n.jsx("div",{style:{flex:1}}),n.jsxs("button",{style:{...k,color:s?"#484f58":"#58a6ff",borderColor:s?"#30363d":"#58a6ff30"},onClick:p,disabled:s,children:[n.jsx(Xe,{size:11}),s?"Generating…":"Generate"]}),n.jsx("button",{style:k,onClick:m,disabled:d,children:d?"Importing…":"Import"}),n.jsxs("button",{style:{...k,color:r?"#e6edf3":"#6e7681",borderColor:r?"#30363d":"#21262d"},onClick:()=>i(x=>!x),children:[e.length," reports",r?n.jsx(yi,{size:11}):n.jsx(mi,{size:11})]})]}),r&&n.jsx("div",{style:{borderTop:"1px solid #21262d",padding:"8px 10px",display:"flex",flexDirection:"column",gap:4,maxHeight:200,overflowY:"auto"},children:e.length===0?n.jsx("span",{style:{fontSize:11,color:"#484f58",padding:"4px 4px"},children:'No reports — use "Generate" to create one'}):e.map(x=>n.jsxs("div",{style:{border:"1px solid #21262d",borderRadius:5,display:"flex",alignItems:"center",transition:"background 0.1s"},onMouseEnter:b=>{b.currentTarget.style.background="#21262d"},onMouseLeave:b=>{b.currentTarget.style.background="none"},children:[n.jsxs("button",{onClick:()=>y(x.date),style:{background:"none",border:"none",padding:"7px 10px",cursor:"pointer",textAlign:"left",display:"flex",gap:10,alignItems:"center",color:"inherit",flex:1,minWidth:0},children:[n.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#58a6ff",minWidth:90,flexShrink:0},children:x.date}),n.jsx("span",{style:{fontSize:11,color:"#6e7681",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.preview})]}),n.jsx("button",{onClick:b=>j(x.date,b),title:"Delete report",style:{background:"none",border:"none",cursor:"pointer",padding:"7px 10px",display:"flex",alignItems:"center",color:"#6e7681",flexShrink:0},onMouseEnter:b=>{b.currentTarget.style.color="#f85149"},onMouseLeave:b=>{b.currentTarget.style.color="#6e7681"},children:n.jsx(xi,{size:12})})]},x.id))}),o&&n.jsx("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"#00000088",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>a(null),children:n.jsxs("div",{style:{background:"#161b22",border:"1px solid #30363d",borderRadius:10,width:"80%",maxWidth:820,maxHeight:"82vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px #00000088"},onClick:x=>x.stopPropagation(),children:[n.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid #21262d",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n.jsx(it,{size:13,color:"#58a6ff"}),n.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"#e6edf3"},children:["Informe semanal — ",o.date]})]}),n.jsx("button",{onClick:()=>a(null),style:{background:"none",border:"none",cursor:"pointer",color:"#6e7681",padding:4},children:n.jsx(vi,{size:16})})]}),n.jsx("div",{style:{flex:1,overflow:"auto",padding:"16px 24px"},children:n.jsx(Kn,{content:o.report_markdown})})]})})]})}function Xn({quota:e,cost:t,events:r,prompts:i,claudeStats:o}){const[a,s]=T.useState("30"),[l,d]=T.useState("30"),[u,c]=T.useState([]),[h,f]=T.useState([]),[p,m]=T.useState([]),[y,j]=T.useState(null),[k,x]=T.useState(!0);T.useEffect(()=>{x(!0),fetch(`/api/analytics?days=${a}&project_days=${l}`).then(v=>v.json()).then(v=>{c(v.daily??[]),f(v.by_model??[]),m(v.project_hours??[]),j(v.kpis??null)}).catch(()=>{}).finally(()=>x(!1))},[a,l]),Fn(h);const b=Hn(h),w=u.reduce((v,S)=>v+S.input_tokens,0),A=u.reduce((v,S)=>v+S.output_tokens,0),P=u.reduce((v,S)=>v+S.cache_read,0),O=w+A+P,z=w+P>0?Math.round(P/(w+P)*100):0,_=p.reduce((v,S)=>v+S.hours,0),$=u.map(v=>({date:v.date,tokens:v.input_tokens+v.output_tokens+v.cache_read,sessions:v.sessions}));return n.jsxs("div",{style:{height:"100%",overflowY:"auto",background:"#0d1117"},children:[n.jsx("div",{style:{padding:"16px 20px 12px"},children:n.jsx(Gn,{})}),n.jsx("div",{style:{padding:"0 20px 2px"},children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[n.jsx("span",{style:{fontSize:10,fontWeight:600,color:"#484f58",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Real time"}),n.jsx("div",{style:{flex:1,height:1,background:"#21262d"}})]})}),n.jsx(Nn,{quota:e,cost:t,events:r,prompts:i,claudeStats:o}),n.jsxs("div",{style:{padding:"0 20px 20px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 0 16px",borderTop:"1px solid #21262d"},children:[n.jsx($t,{size:12,color:"#484f58"}),n.jsx("span",{style:{fontSize:10,fontWeight:600,color:"#484f58",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Historical analysis"}),n.jsx("div",{style:{flex:1}}),n.jsx("div",{style:{display:"flex",gap:4},children:["7","30","90"].map(v=>n.jsx("button",{onClick:()=>s(v),style:{padding:"3px 9px",borderRadius:4,fontSize:11,cursor:"pointer",background:a===v?"#1f6feb":"none",border:`1px solid ${a===v?"#1f6feb":"#30363d"}`,color:a===v?"#fff":"#8b949e",transition:"all 0.15s"},children:Ae[v]},v))})]}),k&&n.jsx("div",{style:{color:"#484f58",fontSize:12,textAlign:"center",padding:"20px 0"},children:"Loading…"}),!k&&y&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",gap:10,marginBottom:20,flexWrap:"wrap"},children:[n.jsx(ce,{icon:n.jsx(tt,{size:13}),label:"Real spend 7d",value:Pe(y.week_cost),sub:`${y.week_sessions} sessions · DB`,color:"#58a6ff",tip:"Real spend in the last 7 days from the claudestat database. Complements the projection above that uses stats-cache."}),n.jsx(ce,{icon:n.jsx(tt,{size:13}),label:"Real spend 30d",value:Pe(y.month_cost),sub:`${y.month_sessions} sessions`,color:"#a371f7",tip:"Real spend in the last 30 days recorded in the claudestat database."}),n.jsx(ce,{icon:n.jsx(Se,{size:13}),label:`Tokens ${Ae[a]}`,value:me(O),sub:`In+Out: ${me(w+A)}`,color:"#d29922",tip:"Total tokens for the period (input + output + cache read). Cache is ~10× cheaper than fresh tokens."}),n.jsx(ce,{icon:n.jsx(Ot,{size:13}),label:`Hours ${Ae[a]}`,value:pt(_),sub:`${p.length} projects`,color:"#3fb950",tip:"Total estimated work time in Claude Code (sum of durations of all sessions in the period)."}),n.jsx(ce,{icon:n.jsx(hi,{size:13}),label:"Loops 7d",value:String(y.week_loops),sub:y.week_loops>20?"High — review":"Normal",color:y.week_loops>20?"#f85149":"#3fb950",tip:"Loops detected in the last week (same tool repeated ≥4 times without progress). Each loop wastes tokens and cost."}),n.jsx(ce,{icon:n.jsx(Xe,{size:13}),label:"Avg efficiency",value:`${y.avg_efficiency}%`,sub:`Cache: ${z}%`,color:y.avg_efficiency>=80?"#3fb950":y.avg_efficiency>=60?"#d29922":"#f85149",tip:`Average efficiency for the period (100% = no loops or redundancy). Cache: ${z}% of tokens come from cache (cheaper).`})]}),n.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"16px 20px",marginBottom:14},children:[n.jsx("div",{style:Oe,children:"Daily cost (USD)"}),n.jsx(Qe,{width:"100%",height:130,children:n.jsxs(kn,{data:u,margin:{top:4,right:4,left:-24,bottom:0},children:[n.jsx(Be,{strokeDasharray:"3 3",stroke:"#21262d"}),n.jsx($e,{dataKey:"date",tick:{fontSize:9,fill:"#6e7681"},tickFormatter:v=>v.slice(5),axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),n.jsx(ve,{tick:{fontSize:9,fill:"#6e7681"},axisLine:!1,tickLine:!1,tickFormatter:v=>`$${v.toFixed(1)}`}),n.jsx(qe,{...yt,cursor:{stroke:"#30363d"},formatter:v=>[Pe(v),"Cost"]}),n.jsx(oe,{type:"monotone",dataKey:"cost",stroke:"#58a6ff",dot:!1,strokeWidth:2})]})})]}),n.jsxs("div",{style:{display:"flex",gap:14,marginBottom:14},children:[n.jsxs("div",{style:{flex:1,background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"16px 20px"},children:[n.jsx("div",{style:Oe,children:"Tokens per day · fluctuation"}),n.jsx(Qe,{width:"100%",height:130,children:n.jsxs(Sn,{data:$,margin:{top:4,right:14,left:-24,bottom:0},children:[n.jsx(Be,{strokeDasharray:"3 3",stroke:"#21262d"}),n.jsx($e,{dataKey:"date",tick:{fontSize:9,fill:"#6e7681"},tickFormatter:v=>v.slice(5),axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),n.jsx(ve,{yAxisId:"left",tick:{fontSize:9,fill:"#6e7681"},axisLine:!1,tickLine:!1,tickFormatter:me}),n.jsx(ve,{yAxisId:"right",orientation:"right",tick:{fontSize:9,fill:"#6e7681"},axisLine:!1,tickLine:!1}),n.jsx(qe,{...yt,cursor:{fill:"#21262d"},formatter:(v,S)=>[S==="Tokens"?me(v):v,S]}),n.jsx(ri,{iconSize:8,wrapperStyle:{fontSize:10,color:"#8b949e"}}),n.jsx(At,{yAxisId:"left",dataKey:"tokens",name:"Tokens",fill:"#1f6feb88",radius:[2,2,0,0]}),n.jsx(oe,{yAxisId:"right",dataKey:"sessions",name:"Sessions",stroke:"#3fb950",dot:!1,strokeWidth:2})]})})]}),n.jsxs("div",{style:{flex:1,background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"16px 20px"},children:[n.jsx("div",{style:Oe,children:"Token share by model"}),(()=>{const v=b.reduce((S,E)=>S+E.tokens,0);return n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:b.map(S=>{const E=v>0?S.tokens/v*100:0;return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[n.jsx("span",{style:{fontSize:11,fontWeight:600,color:ht[S.key]??"#8b949e"},children:S.label}),n.jsxs("span",{style:{fontSize:11,color:"#8b949e"},children:[me(S.tokens)," · ",E.toFixed(1),"%"]})]}),n.jsx("div",{style:{height:6,background:"#21262d",borderRadius:3},children:n.jsx("div",{style:{height:"100%",width:`${E}%`,background:ht[S.key]??"#8b949e",borderRadius:3,minWidth:E>0?3:0}})})]},S.key)})})})()]})]}),p.length>0&&n.jsxs("div",{style:{background:"#161b22",border:"1px solid #21262d",borderRadius:8,padding:"16px 20px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:14},children:[n.jsx(pi,{size:11,color:"#6e7681"}),n.jsx(N,{content:"Only includes sessions tracked by claudestat (since install). Full project history available in the Projects tab.",children:n.jsx("span",{style:Oe,children:"Hours by project ⓘ"})}),n.jsx("div",{style:{flex:1}}),n.jsx("div",{style:{display:"flex",gap:4},children:["7","30","90"].map(v=>n.jsx("button",{onClick:()=>d(v),style:{padding:"2px 7px",borderRadius:4,fontSize:10,cursor:"pointer",background:l===v?"#1f6feb":"none",border:`1px solid ${l===v?"#1f6feb":"#30363d"}`,color:l===v?"#fff":"#8b949e",transition:"all 0.15s"},children:Ae[v]},v))})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:p.map(v=>{const S=_>0?v.hours/_*100:0;return n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[n.jsx("span",{style:{fontSize:11,color:"#c9d1d9",fontWeight:500},children:Mn(v.project)}),n.jsxs("div",{style:{display:"flex",gap:12},children:[n.jsxs("span",{style:{fontSize:10,color:"#6e7681"},children:[v.sessions," sessions"]}),n.jsx("span",{style:{fontSize:10,color:"#d29922",minWidth:40,textAlign:"right"},children:Pe(v.cost)}),n.jsx("span",{style:{fontSize:11,color:"#e6edf3",fontWeight:600,minWidth:36,textAlign:"right"},children:pt(v.hours)})]})]}),n.jsx("div",{style:{height:4,background:"#21262d",borderRadius:2,overflow:"hidden"},children:n.jsx("div",{style:{height:"100%",width:`${S}%`,background:"#58a6ff",borderRadius:2,transition:"width 0.3s"}})})]},v.project)})})]})]}),!k&&u.length===0&&n.jsx("div",{style:{color:"#484f58",fontSize:12,textAlign:"center",padding:"40px 0"},children:"No data for the selected period"})]})]})}export{Xn as AnalyticsView};