@devness/useai 0.8.5 → 0.8.7

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 (2) hide show
  1. package/dist/index.js +385 -794
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -39,545 +39,76 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
39
39
  mod
40
40
  ));
41
41
 
42
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
43
- function assembleStyles() {
44
- const codes = /* @__PURE__ */ new Map();
45
- for (const [groupName, group] of Object.entries(styles)) {
46
- for (const [styleName, style] of Object.entries(group)) {
47
- styles[styleName] = {
48
- open: `\x1B[${style[0]}m`,
49
- close: `\x1B[${style[1]}m`
50
- };
51
- group[styleName] = styles[styleName];
52
- codes.set(style[0], style[1]);
53
- }
54
- Object.defineProperty(styles, groupName, {
55
- value: group,
56
- enumerable: false
57
- });
58
- }
59
- Object.defineProperty(styles, "codes", {
60
- value: codes,
61
- enumerable: false
62
- });
63
- styles.color.close = "\x1B[39m";
64
- styles.bgColor.close = "\x1B[49m";
65
- styles.color.ansi = wrapAnsi16();
66
- styles.color.ansi256 = wrapAnsi256();
67
- styles.color.ansi16m = wrapAnsi16m();
68
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
69
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
70
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
71
- Object.defineProperties(styles, {
72
- rgbToAnsi256: {
73
- value(red, green, blue) {
74
- if (red === green && green === blue) {
75
- if (red < 8) {
76
- return 16;
77
- }
78
- if (red > 248) {
79
- return 231;
80
- }
81
- return Math.round((red - 8) / 247 * 24) + 232;
82
- }
83
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
84
- },
85
- enumerable: false
86
- },
87
- hexToRgb: {
88
- value(hex) {
89
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
90
- if (!matches) {
91
- return [0, 0, 0];
92
- }
93
- let [colorString] = matches;
94
- if (colorString.length === 3) {
95
- colorString = [...colorString].map((character) => character + character).join("");
96
- }
97
- const integer2 = Number.parseInt(colorString, 16);
98
- return [
99
- /* eslint-disable no-bitwise */
100
- integer2 >> 16 & 255,
101
- integer2 >> 8 & 255,
102
- integer2 & 255
103
- /* eslint-enable no-bitwise */
104
- ];
105
- },
106
- enumerable: false
107
- },
108
- hexToAnsi256: {
109
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
110
- enumerable: false
111
- },
112
- ansi256ToAnsi: {
113
- value(code) {
114
- if (code < 8) {
115
- return 30 + code;
116
- }
117
- if (code < 16) {
118
- return 90 + (code - 8);
119
- }
120
- let red;
121
- let green;
122
- let blue;
123
- if (code >= 232) {
124
- red = ((code - 232) * 10 + 8) / 255;
125
- green = red;
126
- blue = red;
127
- } else {
128
- code -= 16;
129
- const remainder = code % 36;
130
- red = Math.floor(code / 36) / 5;
131
- green = Math.floor(remainder / 6) / 5;
132
- blue = remainder % 6 / 5;
133
- }
134
- const value = Math.max(red, green, blue) * 2;
135
- if (value === 0) {
136
- return 30;
137
- }
138
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
139
- if (value === 2) {
140
- result += 60;
141
- }
142
- return result;
143
- },
144
- enumerable: false
145
- },
146
- rgbToAnsi: {
147
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
148
- enumerable: false
149
- },
150
- hexToAnsi: {
151
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
152
- enumerable: false
153
- }
154
- });
155
- return styles;
156
- }
157
- var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
158
- var init_ansi_styles = __esm({
159
- "../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
160
- "use strict";
161
- ANSI_BACKGROUND_OFFSET = 10;
162
- wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
163
- wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
164
- wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
165
- styles = {
166
- modifier: {
167
- reset: [0, 0],
168
- // 21 isn't widely supported and 22 does the same thing
169
- bold: [1, 22],
170
- dim: [2, 22],
171
- italic: [3, 23],
172
- underline: [4, 24],
173
- overline: [53, 55],
174
- inverse: [7, 27],
175
- hidden: [8, 28],
176
- strikethrough: [9, 29]
177
- },
178
- color: {
179
- black: [30, 39],
180
- red: [31, 39],
181
- green: [32, 39],
182
- yellow: [33, 39],
183
- blue: [34, 39],
184
- magenta: [35, 39],
185
- cyan: [36, 39],
186
- white: [37, 39],
187
- // Bright color
188
- blackBright: [90, 39],
189
- gray: [90, 39],
190
- // Alias of `blackBright`
191
- grey: [90, 39],
192
- // Alias of `blackBright`
193
- redBright: [91, 39],
194
- greenBright: [92, 39],
195
- yellowBright: [93, 39],
196
- blueBright: [94, 39],
197
- magentaBright: [95, 39],
198
- cyanBright: [96, 39],
199
- whiteBright: [97, 39]
200
- },
201
- bgColor: {
202
- bgBlack: [40, 49],
203
- bgRed: [41, 49],
204
- bgGreen: [42, 49],
205
- bgYellow: [43, 49],
206
- bgBlue: [44, 49],
207
- bgMagenta: [45, 49],
208
- bgCyan: [46, 49],
209
- bgWhite: [47, 49],
210
- // Bright color
211
- bgBlackBright: [100, 49],
212
- bgGray: [100, 49],
213
- // Alias of `bgBlackBright`
214
- bgGrey: [100, 49],
215
- // Alias of `bgBlackBright`
216
- bgRedBright: [101, 49],
217
- bgGreenBright: [102, 49],
218
- bgYellowBright: [103, 49],
219
- bgBlueBright: [104, 49],
220
- bgMagentaBright: [105, 49],
221
- bgCyanBright: [106, 49],
222
- bgWhiteBright: [107, 49]
223
- }
224
- };
225
- modifierNames = Object.keys(styles.modifier);
226
- foregroundColorNames = Object.keys(styles.color);
227
- backgroundColorNames = Object.keys(styles.bgColor);
228
- colorNames = [...foregroundColorNames, ...backgroundColorNames];
229
- ansiStyles = assembleStyles();
230
- ansi_styles_default = ansiStyles;
231
- }
232
- });
233
-
234
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
235
- import process2 from "process";
236
- import os from "os";
237
- import tty from "tty";
238
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
239
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
240
- const position = argv.indexOf(prefix + flag);
241
- const terminatorPosition = argv.indexOf("--");
242
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
243
- }
244
- function envForceColor() {
245
- if ("FORCE_COLOR" in env) {
246
- if (env.FORCE_COLOR === "true") {
247
- return 1;
248
- }
249
- if (env.FORCE_COLOR === "false") {
250
- return 0;
251
- }
252
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
253
- }
254
- }
255
- function translateLevel(level) {
256
- if (level === 0) {
257
- return false;
258
- }
259
- return {
260
- level,
261
- hasBasic: true,
262
- has256: level >= 2,
263
- has16m: level >= 3
264
- };
265
- }
266
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
267
- const noFlagForceColor = envForceColor();
268
- if (noFlagForceColor !== void 0) {
269
- flagForceColor = noFlagForceColor;
270
- }
271
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
272
- if (forceColor === 0) {
273
- return 0;
274
- }
275
- if (sniffFlags) {
276
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
277
- return 3;
278
- }
279
- if (hasFlag("color=256")) {
280
- return 2;
281
- }
282
- }
283
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
284
- return 1;
285
- }
286
- if (haveStream && !streamIsTTY && forceColor === void 0) {
287
- return 0;
288
- }
289
- const min = forceColor || 0;
290
- if (env.TERM === "dumb") {
291
- return min;
292
- }
293
- if (process2.platform === "win32") {
294
- const osRelease = os.release().split(".");
295
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
296
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
297
- }
298
- return 1;
299
- }
300
- if ("CI" in env) {
301
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
302
- return 3;
303
- }
304
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
305
- return 1;
306
- }
307
- return min;
308
- }
309
- if ("TEAMCITY_VERSION" in env) {
310
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
311
- }
312
- if (env.COLORTERM === "truecolor") {
313
- return 3;
314
- }
315
- if (env.TERM === "xterm-kitty") {
316
- return 3;
317
- }
318
- if (env.TERM === "xterm-ghostty") {
319
- return 3;
320
- }
321
- if (env.TERM === "wezterm") {
322
- return 3;
323
- }
324
- if ("TERM_PROGRAM" in env) {
325
- const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
326
- switch (env.TERM_PROGRAM) {
327
- case "iTerm.app": {
328
- return version2 >= 3 ? 3 : 2;
329
- }
330
- case "Apple_Terminal": {
331
- return 2;
332
- }
333
- }
334
- }
335
- if (/-256(color)?$/i.test(env.TERM)) {
336
- return 2;
337
- }
338
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
339
- return 1;
340
- }
341
- if ("COLORTERM" in env) {
342
- return 1;
343
- }
344
- return min;
345
- }
346
- function createSupportsColor(stream, options = {}) {
347
- const level = _supportsColor(stream, {
348
- streamIsTTY: stream && stream.isTTY,
349
- ...options
350
- });
351
- return translateLevel(level);
352
- }
353
- var env, flagForceColor, supportsColor, supports_color_default;
354
- var init_supports_color = __esm({
355
- "../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js"() {
356
- "use strict";
357
- ({ env } = process2);
358
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
359
- flagForceColor = 0;
360
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
361
- flagForceColor = 1;
362
- }
363
- supportsColor = {
364
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
365
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
366
- };
367
- supports_color_default = supportsColor;
368
- }
369
- });
370
-
371
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
372
- function stringReplaceAll(string3, substring, replacer) {
373
- let index = string3.indexOf(substring);
374
- if (index === -1) {
375
- return string3;
376
- }
377
- const substringLength = substring.length;
378
- let endIndex = 0;
379
- let returnValue = "";
380
- do {
381
- returnValue += string3.slice(endIndex, index) + substring + replacer;
382
- endIndex = index + substringLength;
383
- index = string3.indexOf(substring, endIndex);
384
- } while (index !== -1);
385
- returnValue += string3.slice(endIndex);
386
- return returnValue;
387
- }
388
- function stringEncaseCRLFWithFirstIndex(string3, prefix, postfix, index) {
389
- let endIndex = 0;
390
- let returnValue = "";
391
- do {
392
- const gotCR = string3[index - 1] === "\r";
393
- returnValue += string3.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
394
- endIndex = index + 1;
395
- index = string3.indexOf("\n", endIndex);
396
- } while (index !== -1);
397
- returnValue += string3.slice(endIndex);
398
- return returnValue;
399
- }
400
- var init_utilities = __esm({
401
- "../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js"() {
402
- "use strict";
403
- }
404
- });
405
-
406
- // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
407
- var source_exports = {};
408
- __export(source_exports, {
409
- Chalk: () => Chalk,
410
- backgroundColorNames: () => backgroundColorNames,
411
- backgroundColors: () => backgroundColorNames,
412
- chalkStderr: () => chalkStderr,
413
- colorNames: () => colorNames,
414
- colors: () => colorNames,
415
- default: () => source_default,
416
- foregroundColorNames: () => foregroundColorNames,
417
- foregroundColors: () => foregroundColorNames,
418
- modifierNames: () => modifierNames,
419
- modifiers: () => modifierNames,
420
- supportsColor: () => stdoutColor,
421
- supportsColorStderr: () => stderrColor
422
- });
423
- function createChalk(options) {
424
- return chalkFactory(options);
425
- }
426
- var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, Chalk, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default;
427
- var init_source = __esm({
428
- "../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js"() {
429
- "use strict";
430
- init_ansi_styles();
431
- init_supports_color();
432
- init_utilities();
433
- init_ansi_styles();
434
- ({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
435
- GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
436
- STYLER = /* @__PURE__ */ Symbol("STYLER");
437
- IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
438
- levelMapping = [
439
- "ansi",
440
- "ansi",
441
- "ansi256",
442
- "ansi16m"
443
- ];
444
- styles2 = /* @__PURE__ */ Object.create(null);
445
- applyOptions = (object3, options = {}) => {
446
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
447
- throw new Error("The `level` option should be an integer from 0 to 3");
448
- }
449
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
450
- object3.level = options.level === void 0 ? colorLevel : options.level;
451
- };
452
- Chalk = class {
453
- constructor(options) {
454
- return chalkFactory(options);
455
- }
456
- };
457
- chalkFactory = (options) => {
458
- const chalk2 = (...strings) => strings.join(" ");
459
- applyOptions(chalk2, options);
460
- Object.setPrototypeOf(chalk2, createChalk.prototype);
461
- return chalk2;
462
- };
463
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
464
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
465
- styles2[styleName] = {
466
- get() {
467
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
468
- Object.defineProperty(this, styleName, { value: builder });
469
- return builder;
470
- }
471
- };
472
- }
473
- styles2.visible = {
474
- get() {
475
- const builder = createBuilder(this, this[STYLER], true);
476
- Object.defineProperty(this, "visible", { value: builder });
477
- return builder;
478
- }
479
- };
480
- getModelAnsi = (model, level, type, ...arguments_) => {
481
- if (model === "rgb") {
482
- if (level === "ansi16m") {
483
- return ansi_styles_default[type].ansi16m(...arguments_);
484
- }
485
- if (level === "ansi256") {
486
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
487
- }
488
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
489
- }
490
- if (model === "hex") {
491
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
492
- }
493
- return ansi_styles_default[type][model](...arguments_);
494
- };
495
- usedModels = ["rgb", "hex", "ansi256"];
496
- for (const model of usedModels) {
497
- styles2[model] = {
498
- get() {
499
- const { level } = this;
500
- return function(...arguments_) {
501
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
502
- return createBuilder(this, styler, this[IS_EMPTY]);
503
- };
504
- }
505
- };
506
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
507
- styles2[bgModel] = {
508
- get() {
509
- const { level } = this;
510
- return function(...arguments_) {
511
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
512
- return createBuilder(this, styler, this[IS_EMPTY]);
513
- };
514
- }
515
- };
516
- }
517
- proto = Object.defineProperties(() => {
518
- }, {
519
- ...styles2,
520
- level: {
521
- enumerable: true,
522
- get() {
523
- return this[GENERATOR].level;
524
- },
525
- set(level) {
526
- this[GENERATOR].level = level;
527
- }
528
- }
529
- });
530
- createStyler = (open, close, parent) => {
531
- let openAll;
532
- let closeAll;
533
- if (parent === void 0) {
534
- openAll = open;
535
- closeAll = close;
536
- } else {
537
- openAll = parent.openAll + open;
538
- closeAll = close + parent.closeAll;
539
- }
42
+ // ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
43
+ var require_picocolors = __commonJS({
44
+ "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
45
+ "use strict";
46
+ var p = process || {};
47
+ var argv = p.argv || [];
48
+ var env = p.env || {};
49
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
50
+ var formatter = (open, close, replace = open) => (input) => {
51
+ let string3 = "" + input, index = string3.indexOf(close, open.length);
52
+ return ~index ? open + replaceClose(string3, close, replace, index) + close : open + string3 + close;
53
+ };
54
+ var replaceClose = (string3, close, replace, index) => {
55
+ let result = "", cursor = 0;
56
+ do {
57
+ result += string3.substring(cursor, index) + replace;
58
+ cursor = index + close.length;
59
+ index = string3.indexOf(close, cursor);
60
+ } while (~index);
61
+ return result + string3.substring(cursor);
62
+ };
63
+ var createColors = (enabled = isColorSupported) => {
64
+ let f = enabled ? formatter : () => String;
540
65
  return {
541
- open,
542
- close,
543
- openAll,
544
- closeAll,
545
- parent
66
+ isColorSupported: enabled,
67
+ reset: f("\x1B[0m", "\x1B[0m"),
68
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
69
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
70
+ italic: f("\x1B[3m", "\x1B[23m"),
71
+ underline: f("\x1B[4m", "\x1B[24m"),
72
+ inverse: f("\x1B[7m", "\x1B[27m"),
73
+ hidden: f("\x1B[8m", "\x1B[28m"),
74
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
75
+ black: f("\x1B[30m", "\x1B[39m"),
76
+ red: f("\x1B[31m", "\x1B[39m"),
77
+ green: f("\x1B[32m", "\x1B[39m"),
78
+ yellow: f("\x1B[33m", "\x1B[39m"),
79
+ blue: f("\x1B[34m", "\x1B[39m"),
80
+ magenta: f("\x1B[35m", "\x1B[39m"),
81
+ cyan: f("\x1B[36m", "\x1B[39m"),
82
+ white: f("\x1B[37m", "\x1B[39m"),
83
+ gray: f("\x1B[90m", "\x1B[39m"),
84
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
85
+ bgRed: f("\x1B[41m", "\x1B[49m"),
86
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
87
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
88
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
89
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
90
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
91
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
92
+ blackBright: f("\x1B[90m", "\x1B[39m"),
93
+ redBright: f("\x1B[91m", "\x1B[39m"),
94
+ greenBright: f("\x1B[92m", "\x1B[39m"),
95
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
96
+ blueBright: f("\x1B[94m", "\x1B[39m"),
97
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
98
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
99
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
100
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
101
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
102
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
103
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
104
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
105
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
106
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
107
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
546
108
  };
547
109
  };
548
- createBuilder = (self, _styler, _isEmpty) => {
549
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
550
- Object.setPrototypeOf(builder, proto);
551
- builder[GENERATOR] = self;
552
- builder[STYLER] = _styler;
553
- builder[IS_EMPTY] = _isEmpty;
554
- return builder;
555
- };
556
- applyStyle = (self, string3) => {
557
- if (self.level <= 0 || !string3) {
558
- return self[IS_EMPTY] ? "" : string3;
559
- }
560
- let styler = self[STYLER];
561
- if (styler === void 0) {
562
- return string3;
563
- }
564
- const { openAll, closeAll } = styler;
565
- if (string3.includes("\x1B")) {
566
- while (styler !== void 0) {
567
- string3 = stringReplaceAll(string3, styler.close, styler.open);
568
- styler = styler.parent;
569
- }
570
- }
571
- const lfIndex = string3.indexOf("\n");
572
- if (lfIndex !== -1) {
573
- string3 = stringEncaseCRLFWithFirstIndex(string3, closeAll, openAll, lfIndex);
574
- }
575
- return openAll + string3 + closeAll;
576
- };
577
- Object.defineProperties(createChalk.prototype, styles2);
578
- chalk = createChalk();
579
- chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
580
- source_default = chalk;
110
+ module.exports = createColors();
111
+ module.exports.createColors = createColors;
581
112
  }
582
113
  });
583
114
 
@@ -684,7 +215,7 @@ var VERSION;
684
215
  var init_version = __esm({
685
216
  "../shared/dist/constants/version.js"() {
686
217
  "use strict";
687
- VERSION = "0.8.5";
218
+ VERSION = "0.8.7";
688
219
  }
689
220
  });
690
221
 
@@ -5488,13 +5019,13 @@ function normalizeMcpClientName(mcpName) {
5488
5019
  return MCP_CLIENT_NAME_MAP[lower] ?? lower;
5489
5020
  }
5490
5021
  function detectClient() {
5491
- const env2 = process.env;
5022
+ const env = process.env;
5492
5023
  for (const [envVar, clientName] of Object.entries(AI_CLIENT_ENV_VARS)) {
5493
- if (env2[envVar])
5024
+ if (env[envVar])
5494
5025
  return clientName;
5495
5026
  }
5496
- if (env2.MCP_CLIENT_NAME)
5497
- return env2.MCP_CLIENT_NAME;
5027
+ if (env.MCP_CLIENT_NAME)
5028
+ return env.MCP_CLIENT_NAME;
5498
5029
  return "unknown";
5499
5030
  }
5500
5031
  var MCP_CLIENT_NAME_MAP;
@@ -14268,7 +13799,7 @@ function installVscodeHttp(configPath) {
14268
13799
  const config2 = readJsonFile(configPath);
14269
13800
  const servers = config2["servers"] ?? {};
14270
13801
  delete servers["useai"];
14271
- servers["UseAI"] = { type: "http", url: MCP_HTTP_URL };
13802
+ servers["UseAI"] = { ...MCP_HTTP_ENTRY };
14272
13803
  config2["servers"] = servers;
14273
13804
  writeJsonFile(configPath, config2);
14274
13805
  }
@@ -14384,7 +13915,7 @@ var init_tools2 = __esm({
14384
13915
  " - **task_type values**: coding, debugging, testing, planning, reviewing, documenting, learning, deployment, devops, research, migration, design, data, security, configuration, code_review, investigation, infrastructure, analysis, ops, setup, refactoring, other"
14385
13916
  ].join("\n");
14386
13917
  MCP_HTTP_URL = DAEMON_MCP_URL;
14387
- MCP_HTTP_ENTRY = { type: "http", url: MCP_HTTP_URL };
13918
+ MCP_HTTP_ENTRY = { type: "http", url: MCP_HTTP_URL, httpUrl: MCP_HTTP_URL };
14388
13919
  INSTRUCTIONS = {
14389
13920
  text: USEAI_INSTRUCTIONS_TEXT,
14390
13921
  startMarker: "<!-- useai:start -->",
@@ -14465,7 +13996,7 @@ var init_tools2 = __esm({
14465
13996
  name: "Copilot CLI",
14466
13997
  configFormat: "standard",
14467
13998
  configPath: join4(home, ".copilot", "mcp-config.json"),
14468
- detect: () => hasBinary("copilot") || existsSync6(join4(home, ".copilot")),
13999
+ detect: () => existsSync6(join4(home, ".copilot")) || hasBinary("copilot"),
14469
14000
  manualHint: "No global instructions file \u2014 add UseAI instructions to your project-level agent rules."
14470
14001
  }),
14471
14002
  createExtraTool({
@@ -14499,7 +14030,7 @@ var init_tools2 = __esm({
14499
14030
  name: "Crush",
14500
14031
  configFormat: "crush",
14501
14032
  configPath: join4(home, ".config", "crush", "crush.json"),
14502
- detect: () => hasBinary("crush") || existsSync6(join4(home, ".config", "crush")),
14033
+ detect: () => existsSync6(join4(home, ".config", "crush")) || hasBinary("crush"),
14503
14034
  manualHint: "No global instructions file \u2014 add UseAI instructions to your project-level .crush.json."
14504
14035
  })
14505
14036
  ];
@@ -14512,211 +14043,192 @@ var setup_exports = {};
14512
14043
  __export(setup_exports, {
14513
14044
  runSetup: () => runSetup
14514
14045
  });
14515
- import * as readline from "readline/promises";
14516
- async function getShared() {
14517
- if (!_shared) {
14518
- const { createSetupRunner } = await import("@devness/mcp-setup");
14519
- _shared = createSetupRunner({
14520
- productName: "UseAI",
14521
- tools: AI_TOOLS,
14522
- resolveTools,
14523
- instructionsText: USEAI_INSTRUCTIONS_TEXT
14524
- });
14525
- }
14526
- return _shared;
14046
+ async function getClack() {
14047
+ if (!_p) _p = await import("@clack/prompts");
14048
+ return _p;
14049
+ }
14050
+ function shortenPath(path) {
14051
+ const home2 = process.env["HOME"] ?? "";
14052
+ return home2 && path.startsWith(home2) ? "~" + path.slice(home2.length) : path;
14053
+ }
14054
+ function showManualHints(p, installedTools) {
14055
+ const hints = installedTools.map((t) => ({ name: t.name, hint: t.getManualHint() })).filter((h) => h.hint !== null);
14056
+ if (hints.length === 0) return;
14057
+ const lines = hints.map(({ name, hint }) => `${import_picocolors.default.bold(name)}: ${hint}`);
14058
+ lines.push("", ...USEAI_INSTRUCTIONS_TEXT.split("\n"));
14059
+ p.note(lines.join("\n"), `Manual setup needed for ${hints.length} tool${hints.length === 1 ? "" : "s"}`);
14527
14060
  }
14528
- async function multiSelect(message, choices) {
14061
+ function configureToolAndCollect(tool, useDaemon) {
14529
14062
  try {
14530
- const { checkbox } = await import("@inquirer/prompts");
14531
- return await checkbox({ message, choices });
14532
- } catch {
14533
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
14534
- try {
14535
- console.log(` ${message}
14536
- `);
14537
- choices.forEach((c, i) => {
14538
- const marker = c.checked !== false ? source_default.green("*") : " ";
14539
- console.log(` ${marker} ${i + 1}. ${c.name}`);
14540
- });
14541
- console.log();
14542
- const answer = await rl.question(" Enter numbers to select (comma-separated), or press Enter for all: ");
14543
- if (!answer.trim()) return choices.map((c) => c.value);
14544
- const indices = answer.split(",").map((n) => parseInt(n.trim(), 10) - 1);
14545
- return choices.filter((_, i) => indices.includes(i)).map((c) => c.value);
14546
- } finally {
14547
- rl.close();
14063
+ if (useDaemon && tool.supportsUrl) {
14064
+ tool.installHttp();
14065
+ return { tool, ok: true, mode: "http" };
14548
14066
  }
14067
+ tool.install();
14068
+ return { tool, ok: true, mode: "stdio" };
14069
+ } catch (e) {
14070
+ return { tool, ok: false, mode: "stdio", error: e.message };
14549
14071
  }
14550
14072
  }
14551
- function showManualHints(installedTools) {
14552
- const hints = installedTools.map((t) => ({ name: t.name, hint: t.getManualHint() })).filter((h) => h.hint !== null);
14553
- if (hints.length === 0) return;
14554
- console.log(source_default.yellow(`
14555
- \u26A0 Manual setup needed for ${hints.length} tool${hints.length === 1 ? "" : "s"}:
14556
- `));
14557
- for (const { name, hint } of hints) {
14558
- console.log(` ${source_default.bold(name)}: ${hint}`);
14073
+ function showGroupedResults(p, results) {
14074
+ const httpOk = results.filter((r) => r.ok && r.mode === "http");
14075
+ const stdioOk = results.filter((r) => r.ok && r.mode === "stdio");
14076
+ const failed = results.filter((r) => !r.ok);
14077
+ if (httpOk.length > 0) {
14078
+ p.log.success(`HTTP (daemon): ${httpOk.map((r) => r.tool.name).join(", ")}`);
14559
14079
  }
14560
- console.log();
14561
- for (const line of USEAI_INSTRUCTIONS_TEXT.split("\n")) {
14562
- console.log(` ${line}`);
14080
+ if (stdioOk.length > 0) {
14081
+ p.log.success(`stdio: ${stdioOk.map((r) => r.tool.name).join(", ")}`);
14563
14082
  }
14564
- console.log();
14565
- }
14566
- function startSpinner(message) {
14567
- let frame = 0;
14568
- const interval = setInterval(() => {
14569
- const symbol = source_default.cyan(SPINNER_FRAMES[frame % SPINNER_FRAMES.length]);
14570
- process.stdout.write(`\r ${symbol} ${source_default.dim(message)}`);
14571
- frame++;
14572
- }, 80);
14573
- return {
14574
- stop(finalMessage) {
14575
- clearInterval(interval);
14576
- process.stdout.write(`\r${" ".repeat(message.length + 10)}\r`);
14577
- console.log(finalMessage);
14083
+ if (failed.length > 0) {
14084
+ for (const r of failed) {
14085
+ p.log.error(`${r.tool.name} \u2014 ${r.error}`);
14578
14086
  }
14579
- };
14087
+ }
14580
14088
  }
14581
14089
  async function daemonInstallFlow(tools, autoYes, explicit) {
14582
- const spinner = startSpinner("Starting UseAI daemon...");
14090
+ const p = await getClack();
14091
+ p.intro(import_picocolors.default.bgCyan(import_picocolors.default.black(" useai ")));
14092
+ const s = p.spinner();
14093
+ s.start("Starting UseAI daemon...");
14583
14094
  const daemonOk = await ensureDaemon();
14584
14095
  if (!daemonOk) {
14585
- spinner.stop(source_default.red(` \u2717 Could not start daemon on port ${DAEMON_PORT}`));
14586
- console.log();
14587
- console.log(source_default.bold(" To debug, run the daemon in foreground mode:"));
14588
- console.log(source_default.cyan(` npx @devness/useai daemon --port ${DAEMON_PORT}`));
14589
- console.log();
14590
- console.log(source_default.dim(" If you need stdio mode (e.g. containers/CI), use: npx @devness/useai mcp --stdio"));
14096
+ s.stop("Could not start daemon");
14097
+ p.note(
14098
+ [
14099
+ "Check if the port is in use:",
14100
+ ` lsof -i :${DAEMON_PORT}`,
14101
+ "",
14102
+ "Run in foreground to debug:",
14103
+ ` npx @devness/useai daemon --port ${DAEMON_PORT}`,
14104
+ "",
14105
+ "For containers/CI, use stdio mode:",
14106
+ " npx @devness/useai mcp --stdio"
14107
+ ].join("\n"),
14108
+ "Troubleshooting"
14109
+ );
14110
+ p.outro("Setup failed.");
14591
14111
  return;
14592
14112
  }
14593
14113
  const useDaemon = true;
14594
- spinner.stop(source_default.green(` \u2713 Daemon running on port ${DAEMON_PORT}`));
14595
- console.log(source_default.dim(` Dashboard: http://127.0.0.1:${DAEMON_PORT}/dashboard`));
14596
- if (useDaemon) {
14597
- const platform = detectPlatform();
14598
- if (platform !== "unsupported") {
14599
- try {
14600
- installAutostart();
14601
- console.log(source_default.green(` \u2713 Auto-start service installed (${platform})`));
14602
- } catch {
14603
- console.log(source_default.yellow(` \u26A0 Could not install auto-start service`));
14604
- }
14114
+ s.stop(`Daemon running on port ${DAEMON_PORT}`);
14115
+ p.log.info(`Dashboard: ${import_picocolors.default.cyan(`http://127.0.0.1:${DAEMON_PORT}/dashboard`)}`);
14116
+ const platform = detectPlatform();
14117
+ if (platform !== "unsupported") {
14118
+ try {
14119
+ installAutostart();
14120
+ p.log.success(`Auto-start service installed (${platform})`);
14121
+ } catch {
14122
+ p.log.warn("Could not install auto-start service");
14605
14123
  }
14606
14124
  }
14607
14125
  if (explicit) {
14608
- console.log();
14609
- let configuredCount2 = 0;
14126
+ const results2 = [];
14610
14127
  for (const tool of tools) {
14611
- try {
14612
- configureToolDaemon(tool, useDaemon);
14613
- configuredCount2++;
14614
- } catch (e) {
14615
- console.log(source_default.red(` \u2717 ${tool.name.padEnd(18)} \u2014 ${e.message}`));
14616
- }
14128
+ results2.push(configureToolAndCollect(tool, useDaemon));
14617
14129
  }
14618
- installHooksAndFinish(tools, configuredCount2, useDaemon);
14130
+ showGroupedResults(p, results2);
14131
+ installHooksAndFinish(p, tools, results2.filter((r) => r.ok).length, useDaemon);
14619
14132
  return;
14620
14133
  }
14621
- console.log(source_default.dim("\n Scanning for AI tools...\n"));
14134
+ const scanSpinner = p.spinner();
14135
+ scanSpinner.start("Scanning for AI tools...");
14622
14136
  const detected = tools.filter((t) => t.detect());
14137
+ scanSpinner.stop(`Found ${detected.length} AI tool${detected.length === 1 ? "" : "s"}`);
14623
14138
  if (detected.length === 0) {
14624
- console.log(source_default.red(" No AI tools detected on this machine."));
14139
+ p.log.error("No AI tools detected on this machine.");
14140
+ p.outro("Setup complete.");
14625
14141
  return;
14626
14142
  }
14627
14143
  const alreadyConfigured = detected.filter((t) => t.isConfigured());
14628
14144
  const unconfigured = detected.filter((t) => !t.isConfigured());
14629
- console.log(` Found ${source_default.bold(String(detected.length))} AI tool${detected.length === 1 ? "" : "s"} on this machine:
14630
- `);
14631
- for (const tool of alreadyConfigured) {
14632
- console.log(source_default.green(` \u2705 ${tool.name}`) + source_default.dim(" (already configured)"));
14633
- }
14634
- for (const tool of unconfigured) {
14635
- console.log(source_default.dim(` \u2610 ${tool.name}`));
14636
- }
14637
- console.log();
14145
+ const toolLines = [
14146
+ ...alreadyConfigured.map((t) => `${import_picocolors.default.green("\u2713")} ${t.name} ${import_picocolors.default.dim("(already configured)")}`),
14147
+ ...unconfigured.map((t) => `${import_picocolors.default.dim("\u25CB")} ${t.name}`)
14148
+ ];
14149
+ p.note(toolLines.join("\n"), `${detected.length} AI tool${detected.length === 1 ? "" : "s"} detected`);
14638
14150
  if (unconfigured.length === 0) {
14639
- console.log(source_default.green(" All detected tools are already configured."));
14151
+ p.log.success("All detected tools are already configured.");
14640
14152
  for (const tool of alreadyConfigured) {
14641
14153
  try {
14642
- configureToolDaemon(tool, useDaemon);
14154
+ configureToolAndCollect(tool, useDaemon);
14643
14155
  } catch {
14644
14156
  }
14645
14157
  }
14646
- installHooksAndFinish(alreadyConfigured, alreadyConfigured.length, useDaemon);
14158
+ installHooksAndFinish(p, alreadyConfigured, alreadyConfigured.length, useDaemon);
14647
14159
  return;
14648
14160
  }
14649
14161
  let toInstall;
14650
14162
  if (autoYes) {
14651
14163
  toInstall = unconfigured;
14652
14164
  } else {
14653
- let selected;
14654
- try {
14655
- selected = await multiSelect(
14656
- "Select tools to configure:",
14657
- unconfigured.map((t) => ({ name: t.name, value: t.id, checked: true }))
14658
- );
14659
- } catch {
14660
- console.log("\n");
14165
+ const selected = await p.multiselect({
14166
+ message: `Select tools to configure ${import_picocolors.default.dim("(space to toggle)")}`,
14167
+ options: unconfigured.map((t) => ({
14168
+ value: t.id,
14169
+ label: t.name,
14170
+ hint: shortenPath(t.getConfigPath())
14171
+ })),
14172
+ initialValues: unconfigured.map((t) => t.id),
14173
+ required: true
14174
+ });
14175
+ if (p.isCancel(selected)) {
14176
+ p.cancel("Setup cancelled.");
14661
14177
  return;
14662
14178
  }
14663
14179
  toInstall = unconfigured.filter((t) => selected.includes(t.id));
14664
14180
  }
14665
14181
  if (toInstall.length === 0) {
14666
- console.log(source_default.dim(" No tools selected."));
14182
+ p.log.info("No tools selected.");
14183
+ p.outro("Setup complete.");
14667
14184
  return;
14668
14185
  }
14669
- console.log(`
14670
- Configuring ${toInstall.length} tool${toInstall.length === 1 ? "" : "s"}...
14671
- `);
14672
- let configuredCount = 0;
14186
+ const mode = useDaemon ? "HTTP (daemon)" : "stdio";
14187
+ const summaryLines = [
14188
+ `Tools: ${toInstall.map((t) => t.name).join(", ")}`,
14189
+ `Mode: ${mode}`
14190
+ ];
14191
+ if (useDaemon && platform !== "unsupported") {
14192
+ summaryLines.push(`Auto-start: ${platform}`);
14193
+ }
14194
+ summaryLines.push("Hooks: Claude Code (UserPromptSubmit + Stop + SessionEnd)");
14195
+ p.note(summaryLines.join("\n"), "Installation Summary");
14196
+ const shouldProceed = await p.confirm({ message: "Proceed with installation?" });
14197
+ if (p.isCancel(shouldProceed) || !shouldProceed) {
14198
+ p.cancel("Setup cancelled.");
14199
+ return;
14200
+ }
14201
+ const results = [];
14673
14202
  for (const tool of toInstall) {
14674
- try {
14675
- configureToolDaemon(tool, useDaemon);
14676
- configuredCount++;
14677
- } catch (e) {
14678
- console.log(source_default.red(` \u2717 ${tool.name.padEnd(18)} \u2014 ${e.message}`));
14679
- }
14203
+ results.push(configureToolAndCollect(tool, useDaemon));
14680
14204
  }
14681
14205
  for (const tool of alreadyConfigured) {
14682
14206
  try {
14683
- configureToolDaemon(tool, useDaemon);
14207
+ configureToolAndCollect(tool, useDaemon);
14684
14208
  } catch {
14685
14209
  }
14686
14210
  }
14687
- installHooksAndFinish([...toInstall, ...alreadyConfigured], configuredCount, useDaemon);
14211
+ showGroupedResults(p, results);
14212
+ installHooksAndFinish(p, [...toInstall, ...alreadyConfigured], results.filter((r) => r.ok).length, useDaemon);
14688
14213
  }
14689
- function configureToolDaemon(tool, useDaemon) {
14690
- if (useDaemon && tool.supportsUrl) {
14691
- tool.installHttp();
14692
- console.log(source_default.green(` \u2713 ${tool.name.padEnd(18)} \u2192 ${source_default.dim("HTTP (daemon)")}`));
14693
- } else if (useDaemon && !tool.supportsUrl) {
14694
- tool.install();
14695
- console.log(source_default.green(` \u2713 ${tool.name.padEnd(18)} \u2192 ${source_default.dim("stdio (no URL support)")}`));
14696
- } else {
14697
- tool.install();
14698
- console.log(source_default.green(` \u2713 ${tool.name.padEnd(18)} \u2192 ${source_default.dim("stdio")}`));
14699
- }
14700
- }
14701
- function installHooksAndFinish(allTools, configuredCount, useDaemon) {
14214
+ function installHooksAndFinish(p, allTools, configuredCount, useDaemon) {
14702
14215
  try {
14703
14216
  const hooksInstalled = installClaudeCodeHooks();
14704
14217
  if (hooksInstalled) {
14705
- console.log(source_default.green(" \u2713 Claude Code hooks installed (UserPromptSubmit + Stop + SessionEnd)"));
14218
+ p.log.success("Claude Code hooks installed (UserPromptSubmit + Stop + SessionEnd)");
14706
14219
  }
14707
14220
  } catch {
14708
- console.log(source_default.yellow(" \u26A0 Could not install Claude Code hooks"));
14221
+ p.log.warn("Could not install Claude Code hooks");
14709
14222
  }
14710
- showManualHints(allTools);
14223
+ showManualHints(p, allTools);
14711
14224
  const mode = useDaemon ? "daemon mode" : "stdio mode";
14712
- console.log(`
14713
- Done! UseAI configured in ${source_default.bold(String(configuredCount))} tool${configuredCount === 1 ? "" : "s"} (${mode}).`);
14714
- if (useDaemon) {
14715
- console.log(` Dashboard \u2192 ${source_default.cyan(`http://127.0.0.1:${DAEMON_PORT}/dashboard`)}`);
14716
- }
14717
- console.log();
14225
+ const dashboard = useDaemon ? `
14226
+ Dashboard \u2192 ${import_picocolors.default.cyan(`http://127.0.0.1:${DAEMON_PORT}/dashboard`)}` : "";
14227
+ p.outro(`UseAI configured in ${import_picocolors.default.bold(String(configuredCount))} tool${configuredCount === 1 ? "" : "s"} (${mode}).${dashboard}`);
14718
14228
  }
14719
14229
  async function fullRemoveFlow(tools, autoYes, explicit) {
14230
+ const p = await getClack();
14231
+ p.intro(import_picocolors.default.bgCyan(import_picocolors.default.black(" useai ")));
14720
14232
  if (explicit) {
14721
14233
  const toRemove = tools.filter((t) => {
14722
14234
  try {
@@ -14733,17 +14245,14 @@ async function fullRemoveFlow(tools, autoYes, explicit) {
14733
14245
  }
14734
14246
  });
14735
14247
  for (const tool of notConfigured) {
14736
- console.log(source_default.dim(` ${tool.name} is not configured \u2014 skipping.`));
14248
+ p.log.info(`${tool.name} is not configured \u2014 skipping.`);
14737
14249
  }
14738
- if (toRemove.length > 0) {
14739
- console.log();
14740
- for (const tool of toRemove) {
14741
- try {
14742
- tool.remove();
14743
- console.log(source_default.green(` \u2713 Removed from ${tool.name}`));
14744
- } catch (e) {
14745
- console.log(source_default.red(` \u2717 ${tool.name} \u2014 ${e.message}`));
14746
- }
14250
+ for (const tool of toRemove) {
14251
+ try {
14252
+ tool.remove();
14253
+ p.log.success(`Removed from ${tool.name}`);
14254
+ } catch (e) {
14255
+ p.log.error(`${tool.name} \u2014 ${e.message}`);
14747
14256
  }
14748
14257
  }
14749
14258
  } else {
@@ -14755,39 +14264,37 @@ async function fullRemoveFlow(tools, autoYes, explicit) {
14755
14264
  }
14756
14265
  });
14757
14266
  if (configured.length === 0) {
14758
- console.log(source_default.dim(" UseAI is not configured in any AI tools."));
14267
+ p.log.info("UseAI is not configured in any AI tools.");
14759
14268
  } else {
14760
- console.log(`
14761
- Found UseAI configured in ${source_default.bold(String(configured.length))} tool${configured.length === 1 ? "" : "s"}:
14762
- `);
14763
14269
  let toRemove;
14764
14270
  if (autoYes) {
14765
14271
  toRemove = configured;
14766
14272
  } else {
14767
- let selected;
14768
- try {
14769
- selected = await multiSelect(
14770
- "Select tools to remove UseAI from:",
14771
- configured.map((t) => ({ name: t.name, value: t.id, checked: true }))
14772
- );
14773
- } catch {
14774
- console.log("\n");
14273
+ const selected = await p.multiselect({
14274
+ message: `Select tools to remove UseAI from ${import_picocolors.default.dim("(space to toggle)")}`,
14275
+ options: configured.map((t) => ({
14276
+ value: t.id,
14277
+ label: t.name,
14278
+ hint: shortenPath(t.getConfigPath())
14279
+ })),
14280
+ initialValues: configured.map((t) => t.id),
14281
+ required: true
14282
+ });
14283
+ if (p.isCancel(selected)) {
14284
+ p.cancel("Removal cancelled.");
14775
14285
  return;
14776
14286
  }
14777
14287
  toRemove = configured.filter((t) => selected.includes(t.id));
14778
14288
  }
14779
14289
  if (toRemove.length === 0) {
14780
- console.log(source_default.dim(" No tools selected."));
14290
+ p.log.info("No tools selected.");
14781
14291
  } else {
14782
- console.log(`
14783
- Removing from ${toRemove.length} tool${toRemove.length === 1 ? "" : "s"}...
14784
- `);
14785
14292
  for (const tool of toRemove) {
14786
14293
  try {
14787
14294
  tool.remove();
14788
- console.log(source_default.green(` \u2713 Removed from ${tool.name}`));
14295
+ p.log.success(`Removed from ${tool.name}`);
14789
14296
  } catch (e) {
14790
- console.log(source_default.red(` \u2717 ${tool.name} \u2014 ${e.message}`));
14297
+ p.log.error(`${tool.name} \u2014 ${e.message}`);
14791
14298
  }
14792
14299
  }
14793
14300
  }
@@ -14800,43 +14307,42 @@ async function fullRemoveFlow(tools, autoYes, explicit) {
14800
14307
  return false;
14801
14308
  }
14802
14309
  });
14803
- if (anyRemaining) {
14804
- console.log(source_default.dim("\nDone! Other tools still configured \u2014 daemon and hooks kept running.\n"));
14805
- return;
14806
- }
14807
- try {
14808
- removeClaudeCodeHooks();
14809
- console.log(source_default.green(" \u2713 Claude Code hooks removed"));
14810
- } catch {
14811
- }
14812
- console.log();
14813
- try {
14814
- await killDaemon();
14815
- console.log(source_default.green(" \u2713 Daemon stopped"));
14816
- } catch {
14817
- console.log(source_default.dim(" Daemon was not running"));
14818
- }
14819
- if (isAutostartInstalled()) {
14310
+ if (!anyRemaining) {
14820
14311
  try {
14821
- removeAutostart();
14822
- console.log(source_default.green(" \u2713 Auto-start service removed"));
14312
+ removeClaudeCodeHooks();
14313
+ p.log.success("Claude Code hooks removed");
14823
14314
  } catch {
14824
- console.log(source_default.red(" \u2717 Failed to remove auto-start service"));
14825
14315
  }
14316
+ try {
14317
+ await killDaemon();
14318
+ p.log.success("Daemon stopped");
14319
+ } catch {
14320
+ p.log.info("Daemon was not running");
14321
+ }
14322
+ if (isAutostartInstalled()) {
14323
+ try {
14324
+ removeAutostart();
14325
+ p.log.success("Auto-start service removed");
14326
+ } catch {
14327
+ p.log.error("Failed to remove auto-start service");
14328
+ }
14329
+ }
14330
+ p.outro("UseAI fully removed.");
14331
+ } else {
14332
+ p.outro("Other tools still configured \u2014 daemon and hooks kept running.");
14826
14333
  }
14827
- console.log(source_default.dim("\nDone! UseAI fully removed.\n"));
14828
14334
  }
14829
14335
  function showHelp() {
14830
14336
  console.log(`
14831
- ${source_default.bold("Usage:")} npx @devness/useai mcp [tools...] [options]
14337
+ ${import_picocolors.default.bold("Usage:")} npx @devness/useai mcp [tools...] [options]
14832
14338
 
14833
14339
  Configure UseAI MCP server in your AI tools.
14834
14340
  Default: starts daemon, installs auto-start, configures tools with HTTP.
14835
14341
 
14836
- ${source_default.bold("Arguments:")}
14342
+ ${import_picocolors.default.bold("Arguments:")}
14837
14343
  tools Specific tool names (e.g. codex cursor vscode)
14838
14344
 
14839
- ${source_default.bold("Options:")}
14345
+ ${import_picocolors.default.bold("Options:")}
14840
14346
  --stdio Use stdio config (legacy mode for containers/CI)
14841
14347
  --remove Remove UseAI from configured tools, stop daemon, remove auto-start
14842
14348
  --status Show configuration status without modifying
@@ -14860,30 +14366,115 @@ async function runSetup(args) {
14860
14366
  if (explicit) {
14861
14367
  const { matched, unmatched } = resolveTools(toolNames);
14862
14368
  if (unmatched.length > 0) {
14863
- console.log(source_default.red(` Unknown tool${unmatched.length === 1 ? "" : "s"}: ${unmatched.join(", ")}`));
14864
- console.log(source_default.dim(` Available: ${AI_TOOLS.map((t) => t.id).join(", ")}`));
14369
+ console.log(import_picocolors.default.red(` Unknown tool${unmatched.length === 1 ? "" : "s"}: ${unmatched.join(", ")}`));
14370
+ console.log(import_picocolors.default.dim(` Available: ${AI_TOOLS.map((t) => t.id).join(", ")}`));
14865
14371
  return;
14866
14372
  }
14867
14373
  tools = matched;
14868
14374
  }
14869
14375
  if (isStatus) {
14870
- (await getShared()).showStatus(tools);
14376
+ const p = await getClack();
14377
+ const detected = tools.filter((t) => t.detect());
14378
+ if (detected.length === 0) {
14379
+ p.log.warn("No supported AI tools detected on this system.");
14380
+ return;
14381
+ }
14382
+ const nameWidth = Math.max(...detected.map((t) => t.name.length));
14383
+ const lines = detected.map((tool) => {
14384
+ const name = tool.name.padEnd(nameWidth);
14385
+ const path = import_picocolors.default.dim(shortenPath(tool.getConfigPath()));
14386
+ if (tool.isConfigured()) {
14387
+ return `${name} ${import_picocolors.default.green("\u2713 Configured")} ${path}`;
14388
+ }
14389
+ return `${name} ${import_picocolors.default.yellow("\u2717 Not set up")} ${path}`;
14390
+ });
14391
+ p.note(lines.join("\n"), "AI Tool MCP Status");
14871
14392
  } else if (isRemove) {
14872
14393
  await fullRemoveFlow(tools, autoYes, explicit);
14873
14394
  } else if (isStdio) {
14874
- await (await getShared()).installFlow(tools, autoYes, explicit);
14395
+ const p = await getClack();
14396
+ p.intro(import_picocolors.default.bgCyan(import_picocolors.default.black(" useai ")));
14397
+ if (explicit) {
14398
+ const results2 = [];
14399
+ for (const tool of tools) {
14400
+ results2.push(configureToolAndCollect(tool, false));
14401
+ }
14402
+ showGroupedResults(p, results2);
14403
+ showManualHints(p, tools);
14404
+ p.outro("Setup complete.");
14405
+ return;
14406
+ }
14407
+ const s = p.spinner();
14408
+ s.start("Scanning for AI tools...");
14409
+ const detected = tools.filter((t) => t.detect());
14410
+ s.stop(`Found ${detected.length} AI tool${detected.length === 1 ? "" : "s"}`);
14411
+ if (detected.length === 0) {
14412
+ p.log.error("No AI tools detected on this machine.");
14413
+ p.outro("Setup complete.");
14414
+ return;
14415
+ }
14416
+ const alreadyConfigured = detected.filter((t) => t.isConfigured());
14417
+ const unconfigured = detected.filter((t) => !t.isConfigured());
14418
+ const toolLines = [
14419
+ ...alreadyConfigured.map((t) => `${import_picocolors.default.green("\u2713")} ${t.name} ${import_picocolors.default.dim("(already configured)")}`),
14420
+ ...unconfigured.map((t) => `${import_picocolors.default.dim("\u25CB")} ${t.name}`)
14421
+ ];
14422
+ p.note(toolLines.join("\n"), `${detected.length} AI tool${detected.length === 1 ? "" : "s"} detected`);
14423
+ if (unconfigured.length === 0) {
14424
+ p.log.success("All detected tools are already configured.");
14425
+ p.outro("Nothing to do.");
14426
+ return;
14427
+ }
14428
+ let toInstall;
14429
+ if (autoYes) {
14430
+ toInstall = unconfigured;
14431
+ } else {
14432
+ const selected = await p.multiselect({
14433
+ message: `Select tools to configure ${import_picocolors.default.dim("(space to toggle)")}`,
14434
+ options: unconfigured.map((t) => ({
14435
+ value: t.id,
14436
+ label: t.name,
14437
+ hint: shortenPath(t.getConfigPath())
14438
+ })),
14439
+ initialValues: unconfigured.map((t) => t.id),
14440
+ required: true
14441
+ });
14442
+ if (p.isCancel(selected)) {
14443
+ p.cancel("Setup cancelled.");
14444
+ return;
14445
+ }
14446
+ toInstall = unconfigured.filter((t) => selected.includes(t.id));
14447
+ }
14448
+ if (toInstall.length === 0) {
14449
+ p.log.info("No tools selected.");
14450
+ p.outro("Setup complete.");
14451
+ return;
14452
+ }
14453
+ const results = [];
14454
+ for (const tool of toInstall) {
14455
+ results.push(configureToolAndCollect(tool, false));
14456
+ }
14457
+ for (const tool of alreadyConfigured) {
14458
+ try {
14459
+ tool.install();
14460
+ } catch {
14461
+ }
14462
+ }
14463
+ showGroupedResults(p, results);
14464
+ showManualHints(p, [...toInstall, ...alreadyConfigured]);
14465
+ const configuredCount = results.filter((r) => r.ok).length;
14466
+ p.outro(`UseAI configured in ${import_picocolors.default.bold(String(configuredCount))} tool${configuredCount === 1 ? "" : "s"} (stdio mode).`);
14875
14467
  } else {
14876
14468
  await daemonInstallFlow(tools, autoYes, explicit);
14877
14469
  }
14878
14470
  }
14879
- var _shared, SPINNER_FRAMES;
14471
+ var import_picocolors, _p;
14880
14472
  var init_setup = __esm({
14881
14473
  "src/setup.ts"() {
14882
14474
  "use strict";
14883
- init_source();
14475
+ import_picocolors = __toESM(require_picocolors(), 1);
14884
14476
  init_dist();
14885
14477
  init_tools2();
14886
- SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
14887
14478
  }
14888
14479
  });
14889
14480
 
@@ -26885,20 +26476,20 @@ var require_compile = __commonJS({
26885
26476
  var util_1 = require_util();
26886
26477
  var validate_1 = require_validate();
26887
26478
  var SchemaEnv = class {
26888
- constructor(env2) {
26479
+ constructor(env) {
26889
26480
  var _a;
26890
26481
  this.refs = {};
26891
26482
  this.dynamicAnchors = {};
26892
26483
  let schema;
26893
- if (typeof env2.schema == "object")
26894
- schema = env2.schema;
26895
- this.schema = env2.schema;
26896
- this.schemaId = env2.schemaId;
26897
- this.root = env2.root || this;
26898
- this.baseId = (_a = env2.baseId) !== null && _a !== void 0 ? _a : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env2.schemaId || "$id"]);
26899
- this.schemaPath = env2.schemaPath;
26900
- this.localRefs = env2.localRefs;
26901
- this.meta = env2.meta;
26484
+ if (typeof env.schema == "object")
26485
+ schema = env.schema;
26486
+ this.schema = env.schema;
26487
+ this.schemaId = env.schemaId;
26488
+ this.root = env.root || this;
26489
+ this.baseId = (_a = env.baseId) !== null && _a !== void 0 ? _a : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]);
26490
+ this.schemaPath = env.schemaPath;
26491
+ this.localRefs = env.localRefs;
26492
+ this.meta = env.meta;
26902
26493
  this.$async = schema === null || schema === void 0 ? void 0 : schema.$async;
26903
26494
  this.refs = {};
26904
26495
  }
@@ -27082,15 +26673,15 @@ var require_compile = __commonJS({
27082
26673
  baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
27083
26674
  }
27084
26675
  }
27085
- let env2;
26676
+ let env;
27086
26677
  if (typeof schema != "boolean" && schema.$ref && !(0, util_1.schemaHasRulesButRef)(schema, this.RULES)) {
27087
26678
  const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref);
27088
- env2 = resolveSchema.call(this, root, $ref);
26679
+ env = resolveSchema.call(this, root, $ref);
27089
26680
  }
27090
26681
  const { schemaId } = this.opts;
27091
- env2 = env2 || new SchemaEnv({ schema, schemaId, root, baseId });
27092
- if (env2.schema !== env2.root.schema)
27093
- return env2;
26682
+ env = env || new SchemaEnv({ schema, schemaId, root, baseId });
26683
+ if (env.schema !== env.root.schema)
26684
+ return env;
27094
26685
  return void 0;
27095
26686
  }
27096
26687
  }
@@ -27929,7 +27520,7 @@ var require_core = __commonJS({
27929
27520
  };
27930
27521
  var MAX_EXPRESSION = 200;
27931
27522
  function requiredOptions(o) {
27932
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
27523
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p2, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
27933
27524
  const s = o.strict;
27934
27525
  const _optz = (_a = o.code) === null || _a === void 0 ? void 0 : _a.optimize;
27935
27526
  const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0;
@@ -27940,7 +27531,7 @@ var require_core = __commonJS({
27940
27531
  strictNumbers: (_h = (_g = o.strictNumbers) !== null && _g !== void 0 ? _g : s) !== null && _h !== void 0 ? _h : true,
27941
27532
  strictTypes: (_k = (_j = o.strictTypes) !== null && _j !== void 0 ? _j : s) !== null && _k !== void 0 ? _k : "log",
27942
27533
  strictTuples: (_m = (_l = o.strictTuples) !== null && _l !== void 0 ? _l : s) !== null && _m !== void 0 ? _m : "log",
27943
- strictRequired: (_p = (_o = o.strictRequired) !== null && _o !== void 0 ? _o : s) !== null && _p !== void 0 ? _p : false,
27534
+ strictRequired: (_p2 = (_o = o.strictRequired) !== null && _o !== void 0 ? _o : s) !== null && _p2 !== void 0 ? _p2 : false,
27944
27535
  code: o.code ? { ...o.code, optimize, regExp } : { optimize, regExp },
27945
27536
  loopRequired: (_q = o.loopRequired) !== null && _q !== void 0 ? _q : MAX_EXPRESSION,
27946
27537
  loopEnum: (_r = o.loopEnum) !== null && _r !== void 0 ? _r : MAX_EXPRESSION,
@@ -28491,8 +28082,8 @@ var require_ref = __commonJS({
28491
28082
  schemaType: "string",
28492
28083
  code(cxt) {
28493
28084
  const { gen, schema: $ref, it } = cxt;
28494
- const { baseId, schemaEnv: env2, validateName, opts, self } = it;
28495
- const { root } = env2;
28085
+ const { baseId, schemaEnv: env, validateName, opts, self } = it;
28086
+ const { root } = env;
28496
28087
  if (($ref === "#" || $ref === "#/") && baseId === root.baseId)
28497
28088
  return callRootRef();
28498
28089
  const schOrEnv = compile_1.resolveRef.call(self, root, baseId, $ref);
@@ -28502,8 +28093,8 @@ var require_ref = __commonJS({
28502
28093
  return callValidate(schOrEnv);
28503
28094
  return inlineRefSchema(schOrEnv);
28504
28095
  function callRootRef() {
28505
- if (env2 === root)
28506
- return callRef(cxt, validateName, env2, env2.$async);
28096
+ if (env === root)
28097
+ return callRef(cxt, validateName, env, env.$async);
28507
28098
  const rootName = gen.scopeValue("root", { ref: root });
28508
28099
  return callRef(cxt, (0, codegen_1._)`${rootName}.validate`, root, root.$async);
28509
28100
  }
@@ -28533,14 +28124,14 @@ var require_ref = __commonJS({
28533
28124
  exports.getValidate = getValidate;
28534
28125
  function callRef(cxt, v, sch, $async) {
28535
28126
  const { gen, it } = cxt;
28536
- const { allErrors, schemaEnv: env2, opts } = it;
28127
+ const { allErrors, schemaEnv: env, opts } = it;
28537
28128
  const passCxt = opts.passContext ? names_1.default.this : codegen_1.nil;
28538
28129
  if ($async)
28539
28130
  callAsyncRef();
28540
28131
  else
28541
28132
  callSyncRef();
28542
28133
  function callAsyncRef() {
28543
- if (!env2.$async)
28134
+ if (!env.$async)
28544
28135
  throw new Error("async schema referenced by sync schema");
28545
28136
  const valid = gen.let("valid");
28546
28137
  gen.try(() => {
@@ -34796,7 +34387,7 @@ var gl={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24
34796
34387
  *
34797
34388
  * This source code is licensed under the ISC license.
34798
34389
  * See the LICENSE file in the root directory of this source tree.
34799
- */function kc(e){if(mc[e])return e;return wc.filter(t=>e.startsWith(t)).sort((e,t)=>t.length-e.length)[0]??e}var Sc=E(),jc=new Map;function Cc(e){let t=jc.get(e);return void 0===t&&(t=new Date(e).getTime(),jc.set(e,t)),t}function Nc(e){if(0===e.length)return 0;const t=new Set;for(const i of e)i.started_at&&t.add(i.started_at.slice(0,10));const n=[...t].sort().reverse();if(0===n.length)return 0;const r=(new Date).toISOString().slice(0,10),a=new Date(Date.now()-864e5).toISOString().slice(0,10);if(n[0]!==r&&n[0]!==a)return 0;let s=1;for(let i=1;i<n.length;i++){const e=new Date(n[i-1]),t=new Date(n[i]);if(1!==(e.getTime()-t.getTime())/864e5)break;s++}return s}function Tc(e){const t=e.filter(e=>e.session.evaluation);if(0===t.length)return null;let n=0,r=0,a=0,s=0,i=0,o=0;const l={};for(const u of t){const e=u.session.evaluation;n+=e.prompt_quality,r+=e.context_provided,a+=e.independence_level,s+=e.scope_quality,i+=e.tools_leveraged,o+=e.iteration_count,l[e.task_outcome]=(l[e.task_outcome]??0)+1}const c=t.length;return{prompt_quality:Math.round(n/c*10)/10,context_provided:Math.round(r/c*10)/10,independence_level:Math.round(a/c*10)/10,scope_quality:Math.round(s/c*10)/10,tools_leveraged:Math.round(i/c),total_iterations:o,outcomes:l,session_count:c}}function Ec({sessions:e,timeScale:t,effectiveTime:n,isLive:r,onDayClick:a,highlightDate:s}){const i="day"===t||"24h"===t||"12h"===t||"6h"===t,l=new Date(n).toISOString().slice(0,10),c=h.useMemo(()=>i?function(e,t){const n=new Date(\`\${t}T00:00:00\`).getTime(),r=n+864e5,a=[];for(let s=0;s<24;s++)a.push({hour:s,minutes:0});for(const s of e){const e=Cc(s.started_at),t=Cc(s.ended_at);if(t<n||e>r)continue;const i=Math.max(e,n),o=Math.min(t,r);for(let r=0;r<24;r++){const e=n+36e5*r,t=e+36e5,s=Math.max(i,e),l=Math.min(o,t);l>s&&(a[r].minutes+=(l-s)/6e4)}}return a}(e,l):[],[e,l,i]),u=h.useMemo(()=>i?[]:function(e,t){const n=new Date,r=[];for(let a=t-1;a>=0;a--){const t=new Date(n);t.setDate(t.getDate()-a);const s=t.toISOString().slice(0,10);let i=0;for(const n of e){const e=n.started_at?.slice(0,10);e&&e===s&&(i+=n.duration_seconds)}r.push({date:s,hours:i/3600})}return r}(e,7),[e,i]),d=i?\`Hourly \u2014 \${new Date(n).toLocaleDateString([],{month:"short",day:"numeric"})}\`:"Last 7 Days";if(i){const e=Math.max(...c.map(e=>e.minutes),1);return o.jsxs("div",{className:"mb-8 p-5 rounded-2xl bg-bg-surface-1/50 border border-border/50",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4 px-1",children:[o.jsx("div",{className:"text-xs text-text-muted uppercase tracking-widest font-bold",children:d}),o.jsxs("div",{className:"text-[10px] text-text-muted font-mono bg-bg-surface-2 px-2 py-0.5 rounded",children:[e.toFixed(0),"m peak"]})]}),o.jsx("div",{className:"flex items-end gap-[3px] h-16",children:c.map((t,n)=>{const r=e>0?t.minutes/e*100:0;return o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-end h-full group relative",children:[o.jsx("div",{className:"absolute -top-10 left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-20 pointer-events-none",children:o.jsxs("div",{className:"bg-bg-surface-3 text-text-primary text-[10px] font-mono px-2 py-1.5 rounded-lg shadow-xl whitespace-nowrap border border-border flex flex-col items-center",children:[o.jsxs("span",{className:"font-bold",children:[t.hour,":00"]}),o.jsxs("span",{className:"text-accent",children:[t.minutes.toFixed(0),"m active"]}),o.jsx("div",{className:"absolute -bottom-1 left-1/2 -translate-x-1/2 w-2 h-2 bg-bg-surface-3 border-r border-b border-border rotate-45"})]})}),o.jsx(pl.div,{initial:{height:0},animate:{height:\`\${Math.max(r,t.minutes>0?8:0)}%\`},transition:{delay:.01*n,duration:.5},className:"w-full rounded-t-sm transition-all duration-300 group-hover:bg-accent relative overflow-hidden",style:{minHeight:t.minutes>0?"4px":"0px",backgroundColor:t.minutes>0?\`rgba(var(--accent-rgb), \${.4+t.minutes/e*.6})\`:"var(--color-bg-surface-2)"},children:t.minutes>.5*e&&o.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-transparent to-white/10"})})]},t.hour)})}),o.jsx("div",{className:"flex gap-[3px] mt-2 border-t border-border/30 pt-2",children:c.map(e=>o.jsx("div",{className:"flex-1 text-center",children:e.hour%6==0&&o.jsx("span",{className:"text-[9px] text-text-muted font-bold font-mono uppercase",children:0===e.hour?"12a":e.hour<12?\`\${e.hour}a\`:12===e.hour?"12p":e.hour-12+"p"})},e.hour))})]})}const f=Math.max(...u.map(e=>e.hours),.1);return o.jsxs("div",{className:"mb-8 p-5 rounded-2xl bg-bg-surface-1/50 border border-border/50",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4 px-1",children:[o.jsx("div",{className:"text-xs text-text-muted uppercase tracking-widest font-bold",children:d}),o.jsx("div",{className:"text-[10px] text-text-muted font-mono bg-bg-surface-2 px-2 py-0.5 rounded",children:"Last 7 days"})]}),o.jsx("div",{className:"flex items-end gap-2 h-16",children:u.map((e,t)=>{const n=f>0?e.hours/f*100:0,r=e.date===s;return o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-end h-full group relative",children:[o.jsx("div",{className:"absolute -top-10 left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-20 pointer-events-none",children:o.jsxs("div",{className:"bg-bg-surface-3 text-text-primary text-[10px] font-mono px-2 py-1.5 rounded-lg shadow-xl whitespace-nowrap border border-border flex flex-col items-center",children:[o.jsx("span",{className:"font-bold",children:e.date}),o.jsxs("span",{className:"text-accent",children:[e.hours.toFixed(1),"h active"]}),o.jsx("div",{className:"absolute -bottom-1 left-1/2 -translate-x-1/2 w-2 h-2 bg-bg-surface-3 border-r border-b border-border rotate-45"})]})}),o.jsx(pl.div,{initial:{height:0},animate:{height:\`\${Math.max(n,e.hours>0?8:0)}%\`},transition:{delay:.05*t,duration:.5},className:"w-full rounded-t-md cursor-pointer transition-all duration-300 group-hover:scale-x-110 origin-bottom "+(r?"ring-2 ring-accent ring-offset-2 ring-offset-bg-base":""),style:{minHeight:e.hours>0?"4px":"0px",backgroundColor:r?"var(--color-accent-bright)":e.hours>0?\`rgba(var(--accent-rgb), \${.4+e.hours/f*.6})\`:"var(--color-bg-surface-2)"},onClick:()=>a?.(e.date)})]},e.date)})}),o.jsx("div",{className:"flex gap-2 mt-2 border-t border-border/30 pt-2",children:u.map(e=>o.jsx("div",{className:"flex-1 text-center",children:o.jsx("span",{className:"text-[10px] text-text-muted font-bold uppercase tracking-tighter",children:new Date(e.date+"T12:00:00").toLocaleDateString([],{weekday:"short"})})},e.date))})]})}var Mc=[{key:"simple",label:"Simple",color:"#34d399"},{key:"medium",label:"Medium",color:"#fbbf24"},{key:"complex",label:"Complex",color:"#f87171"}];function Pc({data:e}){const t=e.simple+e.medium+e.complex;if(0===t)return null;const n=Math.max(e.simple,e.medium,e.complex);return o.jsxs(pl.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.15},className:"rounded-xl bg-bg-surface-1 border border-border/50 p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx("div",{className:"p-1.5 rounded-lg bg-bg-surface-2",children:o.jsx(Ul,{className:"w-3.5 h-3.5 text-text-muted"})}),o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest",children:"Complexity"})]}),o.jsx("div",{className:"space-y-3",children:Mc.map((r,a)=>{const s=e[r.key],i=n>0?s/n*100:0,l=t>0?(s/t*100).toFixed(0):"0";return o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-xs text-text-secondary font-medium w-16 text-right shrink-0",children:r.label}),o.jsx("div",{className:"flex-1 h-5 rounded bg-bg-surface-2/50 overflow-hidden",children:o.jsx(pl.div,{className:"h-full rounded",style:{backgroundColor:r.color},initial:{width:0},animate:{width:\`\${i}%\`},transition:{duration:.6,delay:.08*a,ease:[.22,1,.36,1]}})}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.jsx("span",{className:"text-xs text-text-primary font-mono font-bold w-6 text-right",children:s}),o.jsxs("span",{className:"text-[10px] text-text-muted/70 font-mono w-8 text-right",children:[l,"%"]})]})]},r.key)})}),o.jsx("div",{className:"mt-4 flex h-2 rounded-full overflow-hidden bg-bg-surface-2/30",children:Mc.map(n=>{const r=e[n.key],a=t>0?r/t*100:0;return 0===a?null:o.jsx(pl.div,{className:"h-full",style:{backgroundColor:n.color},initial:{width:0},animate:{width:\`\${a}%\`},transition:{duration:.8,ease:[.22,1,.36,1]}},n.key)})})]})}var Lc=["1h","3h","6h","12h"],Dc=["day","week","month"],Ac=["1h","3h","6h","12h","24h","day","7d","week","30d","month"],_c={day:"24h",week:"7d",month:"30d"},zc={"24h":"day","7d":"week","30d":"month"};function Rc(e){return"day"===e||"week"===e||"month"===e}var Fc={"1h":36e5,"3h":108e5,"6h":216e5,"12h":432e5,"24h":864e5,"7d":6048e5,"30d":2592e6},Vc={"1h":"1 Hour","3h":"3 Hours","6h":"6 Hours","12h":"12 Hours","24h":"24 Hours",day:"Day","7d":"7 Days",week:"Week","30d":"30 Days",month:"Month"};function Ic(e,t){const n=Fc[e];if(void 0!==n)return{start:t-n,end:t};const r=new Date(t);if("day"===e){const e=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime();return{start:e,end:e+864e5}}if("week"===e){const e=r.getDay(),t=0===e?-6:1-e,n=new Date(r.getFullYear(),r.getMonth(),r.getDate()+t).getTime();return{start:n,end:n+6048e5}}return{start:new Date(r.getFullYear(),r.getMonth(),1).getTime(),end:new Date(r.getFullYear(),r.getMonth()+1,1).getTime()}}function Oc(e,t,n){const r=Fc[e];if(void 0!==r)return t+n*r;const a=new Date(t);return"day"===e?new Date(a.getFullYear(),a.getMonth(),a.getDate()+n,12).getTime():"week"===e?new Date(a.getFullYear(),a.getMonth(),a.getDate()+7*n,12).getTime():new Date(a.getFullYear(),a.getMonth()+n,Math.min(a.getDate(),28),12).getTime()}function $c(e,t){return Rc(e)?function(e,t){if(!Rc(e))return!1;const n=Ic(e,t),r=Date.now();return r>=n.start&&r<n.end}(e,t):t>=Date.now()-6e4}function Bc({label:e,value:t,suffix:n,decimals:r=0,icon:a,delay:s=0,variant:i="default",clickable:l=!1,selected:c=!1,onClick:u,subtitle:d}){const f=h.useRef(null),p=h.useRef(0);h.useEffect(()=>{f.current&&t!==p.current&&(!function(e,t,n){let r=null;requestAnimationFrame(function a(s){r||(r=s);const i=Math.min((s-r)/800,1),o=1-Math.pow(1-i,4),l=t*o;e.textContent=n>0?l.toFixed(n):String(Math.round(l)),i<1&&requestAnimationFrame(a)})}(f.current,t,r),p.current=t)},[t,r]);const m="accent"===i;return o.jsxs(pl.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:s},onClick:l&&t>0?u:void 0,className:\`px-3 py-2 rounded-lg border flex items-center gap-2.5 group transition-all duration-300 \${m?"shrink-0 bg-bg-surface-1 border-border/50 hover:border-accent/30":"flex-1 min-w-[120px] bg-bg-surface-1 border-border/50 hover:border-accent/30"} \${l&&t>0?"cursor-pointer":""} \${c?"border-accent/50 bg-accent/5":""}\`,children:[o.jsx("div",{className:"p-1.5 rounded-md transition-colors "+(c?"bg-accent/15":"bg-bg-surface-2 group-hover:bg-accent/10"),children:o.jsx(a,{className:"w-3.5 h-3.5 transition-colors "+(c?"text-accent":"text-text-muted group-hover:text-accent")})}),o.jsxs("div",{className:"flex flex-col min-w-0",children:[o.jsxs("div",{className:"flex items-baseline gap-0.5",children:[o.jsx("span",{ref:f,className:"text-lg font-bold text-text-primary tracking-tight leading-none",children:r>0?t.toFixed(r):Math.round(t)}),n&&o.jsx("span",{className:"text-[10px] text-text-muted font-medium",children:n})]}),o.jsx("span",{className:"text-[9px] font-mono text-text-muted uppercase tracking-wider leading-none mt-0.5",children:e}),d&&o.jsx("span",{className:"text-[8px] text-text-muted/50 leading-none mt-0.5 truncate",children:d})]})]})}function Uc({totalHours:e,coveredHours:t,aiMultiplier:n,featuresShipped:r,bugsFixed:a,complexSolved:s,currentStreak:i,totalMilestones:l,selectedCard:c,onCardClick:u}){const d=e=>{u?.(c===e?null:e)};return o.jsxs("div",{className:"flex gap-2 mb-4",children:[o.jsxs("div",{className:"grid grid-cols-3 lg:grid-cols-7 gap-2 flex-1",children:[o.jsx(Bc,{label:"User Time",value:t<1/60?0:t<1?Math.round(60*t):t,suffix:t<1?"min":"hrs",decimals:t>=1?1:0,icon:Pl,delay:.1,clickable:!0,selected:"activeTime"===c,onClick:()=>d("activeTime")}),o.jsx(Bc,{label:"AI Time",value:e<1?Math.round(60*e):e,suffix:e<1?"min":"hrs",decimals:e<1?0:1,icon:oc,delay:.12,clickable:!0,selected:"aiTime"===c,onClick:()=>d("aiTime")}),o.jsx(Bc,{label:"Multiplier",value:n,suffix:"x",decimals:1,icon:Ul,delay:.15,clickable:!0,selected:"parallel"===c,onClick:()=>d("parallel")}),o.jsx(Bc,{label:"Milestones",value:l,icon:ic,delay:.2,clickable:!0,selected:"milestones"===c,onClick:()=>d("milestones")}),o.jsx(Bc,{label:"Features",value:r,icon:Jl,delay:.25,clickable:!0,selected:"features"===c,onClick:()=>d("features")}),o.jsx(Bc,{label:"Bugs Fixed",value:a,icon:bl,delay:.3,clickable:!0,selected:"bugs"===c,onClick:()=>d("bugs")}),o.jsx(Bc,{label:"Complex",value:s,icon:xl,delay:.35,clickable:!0,selected:"complex"===c,onClick:()=>d("complex")})]}),o.jsx("div",{className:"w-px bg-border/30 self-stretch my-1"}),o.jsx(Bc,{label:"Streak",value:i,suffix:"days",icon:pc,delay:.45,variant:"accent",clickable:!0,selected:"streak"===c,onClick:()=>d("streak")})]})}var Hc={milestones:{title:"All Milestones",icon:ic,filter:()=>!0,emptyText:"No milestones in this time window.",accentColor:"#60a5fa"},features:{title:"Features Shipped",icon:Jl,filter:e=>"feature"===e.category,emptyText:"No features shipped in this time window.",accentColor:"#4ade80"},bugs:{title:"Bugs Fixed",icon:bl,filter:e=>"bugfix"===e.category,emptyText:"No bugs fixed in this time window.",accentColor:"#f87171"},complex:{title:"Complex Tasks",icon:xl,filter:e=>"complex"===e.complexity,emptyText:"No complex tasks in this time window.",accentColor:"#a78bfa"}},Wc={feature:"bg-success/10 text-success border-success/20",bugfix:"bg-error/10 text-error border-error/20",refactor:"bg-purple/10 text-purple border-purple/20",test:"bg-blue/10 text-blue border-blue/20",docs:"bg-accent/10 text-accent border-accent/20",setup:"bg-text-muted/10 text-text-muted border-text-muted/20",deployment:"bg-emerald/10 text-emerald border-emerald/20"};function qc(e){const t=new Date(e),n=(new Date).getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return"just now";if(r<60)return\`\${r}m ago\`;const a=Math.floor(r/60);if(a<24)return\`\${a}h ago\`;const s=Math.floor(a/24);return 1===s?"yesterday":s<7?\`\${s}d ago\`:t.toLocaleDateString([],{month:"short",day:"numeric"})}function Yc({type:e,milestones:t,showPublic:n=!1,onClose:r}){h.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]);const[a,s]=h.useState(25),i=h.useRef(null);h.useEffect(()=>{const e=i.current;if(!e)return;const t=new IntersectionObserver(([e])=>{e?.isIntersecting&&s(e=>e+25)},{rootMargin:"200px"});return t.observe(e),()=>t.disconnect()},[e,a]),h.useEffect(()=>{s(25)},[e]);if(!e||!("features"===e||"bugs"===e||"complex"===e||"milestones"===e))return null;const l=Hc[e],c=l.icon,u=t.filter(l.filter).sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime()),d=u.slice(0,a),f=a<u.length,p=new Map;for(const o of d){const e=new Date(o.created_at).toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"}),t=p.get(e);t?t.push(o):p.set(e,[o])}return o.jsx(Qi,{children:e&&o.jsxs(o.Fragment,{children:[o.jsx(pl.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 bg-black/40 backdrop-blur-sm z-40",onClick:r}),o.jsxs(pl.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:30,stiffness:300},className:"fixed top-0 right-0 h-full w-full max-w-md bg-bg-base border-l border-border/50 z-50 flex flex-col shadow-2xl",children:[o.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border/50",children:[o.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:\`\${l.accentColor}15\`},children:o.jsx(c,{className:"w-4 h-4",style:{color:l.accentColor}})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h2",{className:"text-sm font-bold text-text-primary",children:l.title}),o.jsxs("span",{className:"text-[10px] font-mono text-text-muted",children:[u.length," ",1===u.length?"item":"items"," in window"]})]}),o.jsx("button",{onClick:r,className:"p-1.5 rounded-md hover:bg-bg-surface-2 text-text-muted hover:text-text-primary transition-colors",children:o.jsx(fc,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"flex-1 overflow-y-auto overscroll-contain px-5 py-4",children:0===u.length?o.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[o.jsx(sc,{className:"w-8 h-8 text-text-muted/30 mb-3"}),o.jsx("p",{className:"text-sm text-text-muted",children:l.emptyText})]}):o.jsxs("div",{className:"space-y-5",children:[[...p.entries()].map(([t,r])=>o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] font-mono text-text-muted uppercase tracking-wider mb-2 px-1",children:t}),o.jsx("div",{className:"space-y-1",children:r.map((t,r)=>{const a=bc[t.category]??"#9c9588",s=Wc[t.category]??"bg-bg-surface-2 text-text-secondary border-border",i=kc(t.client),l=yc[i]??i.slice(0,2).toUpperCase(),c=mc[i]??"#91919a",u="cursor"===i?"var(--text-primary)":c,d=xc[i],h=n?t.title:t.private_title||t.title,f="complex"===t.complexity;return o.jsxs(pl.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,delay:.03*r},className:"flex items-start gap-2.5 py-2 px-2 rounded-lg hover:bg-bg-surface-1 transition-colors group",children:[o.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0 mt-1.5",style:{backgroundColor:a}}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm text-text-secondary group-hover:text-text-primary transition-colors leading-snug",children:h}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[("complex"===e||"milestones"===e)&&o.jsx("span",{className:\`text-[8px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded-full border \${s}\`,children:t.category}),f&&"complex"!==e&&o.jsxs("span",{className:"flex items-center gap-0.5 text-[8px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded-full border bg-purple/10 text-purple border-purple/20",children:[o.jsx(xl,{className:"w-2 h-2"}),"complex"]}),o.jsx("span",{className:"text-[10px] text-text-muted font-mono",children:qc(t.created_at)}),t.languages.length>0&&o.jsx("span",{className:"text-[9px] text-text-muted font-mono",children:t.languages.join(", ")}),o.jsx("div",{className:"w-4 h-4 rounded flex items-center justify-center text-[7px] font-bold font-mono flex-shrink-0 ml-auto",style:{backgroundColor:\`\${c}15\`,color:c,border:\`1px solid \${c}20\`},children:d?o.jsx("div",{className:"w-2.5 h-2.5",style:{backgroundColor:u,maskImage:\`url(\${d})\`,maskSize:"contain",maskRepeat:"no-repeat",maskPosition:"center",WebkitMaskImage:\`url(\${d})\`,WebkitMaskSize:"contain",WebkitMaskRepeat:"no-repeat",WebkitMaskPosition:"center"}}):l})]})]})]},t.id)})})]},t)),f&&o.jsx("div",{ref:i,className:"py-2 text-center",children:o.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Showing ",d.length," of ",u.length,"..."]})})]})})]})]})})}function Kc(e){return"activeTime"===e||"aiTime"===e||"parallel"===e||"streak"===e}var Xc={activeTime:{title:"User Time",icon:Pl,accentColor:"#60a5fa"},aiTime:{title:"AI Time",icon:oc,accentColor:"#4ade80"},parallel:{title:"Multiplier",icon:Ul,accentColor:"#a78bfa"},streak:{title:"Streak",icon:pc,accentColor:"#facc15"}};function Qc(e){if(e<60)return\`\${Math.round(e)}s\`;if(e<3600)return\`\${Math.round(e/60)}m\`;const t=Math.floor(e/3600),n=Math.round(e%3600/60);return n>0?\`\${t}h \${n}m\`:\`\${t}h\`}function Zc(e){return e<1/60?"< 1 min":e<1?\`\${Math.round(60*e)} min\`:\`\${e.toFixed(1)} hrs\`}function Gc(e){if(0===e.length)return[];const t=[];for(const s of e){const e=Cc(s.started_at),n=Cc(s.ended_at);n<=e||(t.push({time:e,delta:1}),t.push({time:n,delta:-1}))}t.sort((e,t)=>e.time-t.time||e.delta-t.delta);const n=[];let r=0,a=0;for(const s of t){const e=r>0;r+=s.delta,!e&&r>0?a=s.time:e&&0===r&&n.push({start:a,end:s.time})}return n}function Jc({children:e}){return o.jsx("div",{className:"px-3 py-2.5 rounded-lg bg-bg-surface-1 border border-border/50 text-xs text-text-secondary leading-relaxed",children:e})}function eu({label:e,value:t}){return o.jsxs("div",{className:"flex items-center justify-between py-1.5 px-1",children:[o.jsx("span",{className:"text-xs text-text-muted",children:e}),o.jsx("span",{className:"text-xs font-mono font-bold text-text-primary",children:t})]})}function tu({type:e,sessions:t,allSessions:n,currentStreak:r=0,stats:a,showPublic:s=!1,onClose:i}){if(h.useEffect(()=>{if(e&&Kc(e))return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),!e||!Kc(e))return null;const l=Xc[e],c=l.icon,u=[...t].sort((e,t)=>Cc(t.started_at)-Cc(e.started_at));return o.jsx(Qi,{children:e&&o.jsxs(o.Fragment,{children:[o.jsx(pl.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 bg-black/40 backdrop-blur-sm z-40",onClick:i}),o.jsxs(pl.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:30,stiffness:300},className:"fixed top-0 right-0 h-full w-full max-w-md bg-bg-base border-l border-border/50 z-50 flex flex-col shadow-2xl",children:[o.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border/50",children:[o.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:\`\${l.accentColor}15\`},children:o.jsx(c,{className:"w-4 h-4",style:{color:l.accentColor}})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h2",{className:"text-sm font-bold text-text-primary",children:l.title}),o.jsx("span",{className:"text-[10px] font-mono text-text-muted",children:"streak"===e?\`\${r} day\${1===r?"":"s"} consecutive\`:\`\${t.length} sessions in window\`})]}),o.jsx("button",{onClick:i,className:"p-1.5 rounded-md hover:bg-bg-surface-2 text-text-muted hover:text-text-primary transition-colors",children:o.jsx(fc,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-contain px-5 py-4 space-y-4",children:["activeTime"===e&&o.jsx(nu,{stats:a,sessions:t}),"aiTime"===e&&o.jsx(ru,{stats:a,sessions:u,showPublic:s}),"parallel"===e&&o.jsx(au,{stats:a,sessions:u,showPublic:s}),"streak"===e&&o.jsx(su,{allSessions:n??t,currentStreak:r})]})]})]})})}function nu({stats:e,sessions:t}){const n=Gc(t);return o.jsxs(o.Fragment,{children:[o.jsx(Jc,{children:"Real wall-clock time where at least one AI session was running. Gaps between sessions (breaks, thinking, context switches) are excluded."}),o.jsxs("div",{className:"rounded-lg border border-border/50 bg-bg-surface-1 divide-y divide-border/30",children:[o.jsx(eu,{label:"User time",value:Zc(e.coveredHours)}),o.jsx(eu,{label:"AI time",value:Zc(e.totalHours)}),o.jsx(eu,{label:"Active periods",value:String(n.length)}),o.jsx(eu,{label:"Sessions",value:String(t.length)})]}),n.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-[10px] font-mono text-text-muted uppercase tracking-wider px-1 pt-2",children:"Active Periods"}),o.jsx("div",{className:"space-y-1",children:n.map((e,t)=>{const n=(e.end-e.start)/6e4;return o.jsxs(pl.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,delay:.02*t},className:"flex items-center gap-3 py-2 px-2 rounded-lg hover:bg-bg-surface-1 transition-colors",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-accent/60 flex-shrink-0"}),o.jsxs("span",{className:"text-xs font-mono text-text-secondary flex-1",children:[new Date(e.start).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})," \u2192 ",new Date(e.end).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})]}),o.jsx("span",{className:"text-xs font-mono font-bold text-text-primary",children:n<1?"< 1m":n<60?\`\${Math.round(n)}m\`:\`\${(n/60).toFixed(1)}h\`})]},t)})})]})]})}function ru({stats:e,sessions:t,showPublic:n}){return o.jsxs(o.Fragment,{children:[o.jsx(Jc,{children:"Total accumulated AI session duration. When multiple sessions run in parallel, their durations add up \u2014 so AI Time can exceed User Time."}),o.jsxs("div",{className:"rounded-lg border border-border/50 bg-bg-surface-1 divide-y divide-border/30",children:[o.jsx(eu,{label:"AI time",value:Zc(e.totalHours)}),o.jsx(eu,{label:"User time",value:Zc(e.coveredHours)}),o.jsx(eu,{label:"Multiplier",value:\`\${e.aiMultiplier.toFixed(1)}x\`}),o.jsx(eu,{label:"Sessions",value:String(t.length)})]}),o.jsx(ou,{sessions:t,showPublic:n})]})}function au({stats:e,sessions:t,showPublic:n}){return o.jsxs(o.Fragment,{children:[o.jsx(Jc,{children:"Your AI multiplier \u2014 AI Time divided by User Time. Higher means more parallelization. You're running more AI sessions simultaneously."}),o.jsxs("div",{className:"rounded-lg border border-border/50 bg-bg-surface-1 divide-y divide-border/30",children:[o.jsx(eu,{label:"Multiplier",value:\`\${e.aiMultiplier.toFixed(1)}x\`}),o.jsx(eu,{label:"Peak concurrent",value:String(e.peakConcurrency)}),o.jsx(eu,{label:"Calculation",value:\`\${Zc(e.totalHours)} \xF7 \${Zc(e.coveredHours)}\`}),o.jsx(eu,{label:"Sessions",value:String(t.length)})]}),o.jsx(ou,{sessions:t,showPublic:n})]})}function su({allSessions:e,currentStreak:t}){const n=function(e){const t=new Map;for(const n of e){const e=new Date(Cc(n.started_at)),r=\`\${e.getFullYear()}-\${String(e.getMonth()+1).padStart(2,"0")}-\${String(e.getDate()).padStart(2,"0")}\`,a=t.get(r);a?a.push(n):t.set(r,[n])}return[...t.entries()].sort((e,t)=>t[0].localeCompare(e[0])).map(([e,t])=>{const n=new Date(e+"T12:00:00").toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"}),r=t.reduce((e,t)=>e+t.duration_seconds,0),a=Gc(t).reduce((e,t)=>e+(t.end-t.start),0)/1e3,s=a>0?r/a:0;return{date:e,label:n,count:t.length,gainedSeconds:r,spentSeconds:a,boost:s}})}(e),r=new Set,a=new Date;for(let s=0;s<t;s++){const e=new Date(a);e.setDate(e.getDate()-s),r.add(\`\${e.getFullYear()}-\${String(e.getMonth()+1).padStart(2,"0")}-\${String(e.getDate()).padStart(2,"0")}\`)}return o.jsxs(o.Fragment,{children:[o.jsx(Jc,{children:"Consecutive days with at least one AI session. Keep using AI daily to grow your streak!"}),o.jsxs("div",{className:"rounded-lg border border-border/50 bg-bg-surface-1 divide-y divide-border/30",children:[o.jsx(eu,{label:"Current streak",value:\`\${t} day\${1===t?"":"s"}\`}),o.jsx(eu,{label:"Total active days",value:String(n.length)}),o.jsx(eu,{label:"Total sessions",value:String(e.length)})]}),n.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-[10px] font-mono text-text-muted uppercase tracking-wider px-1 pt-2",children:"Active Days"}),o.jsx("div",{className:"space-y-1",children:n.map((e,t)=>{const n=r.has(e.date);return o.jsxs(pl.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,delay:Math.min(.02*t,.6)},className:"flex items-center gap-2 py-2 px-2 rounded-lg hover:bg-bg-surface-1 transition-colors",children:[n?o.jsx(pc,{className:"w-3 h-3 flex-shrink-0",style:{color:"#facc15"}}):o.jsx(wl,{className:"w-3 h-3 flex-shrink-0 text-text-muted"}),o.jsx("span",{className:"text-xs font-mono flex-1 min-w-0 "+(n?"text-text-primary":"text-text-secondary"),children:e.label}),o.jsx("span",{className:"text-[10px] text-text-muted font-mono whitespace-nowrap",title:"User time",children:Qc(e.spentSeconds)}),o.jsx("span",{className:"text-[10px] text-text-muted",children:"/"}),o.jsx("span",{className:"text-[10px] font-mono font-bold text-text-primary whitespace-nowrap",title:"AI time",children:Qc(e.gainedSeconds)}),e.boost>0&&o.jsxs("span",{className:"text-[10px] font-mono font-bold whitespace-nowrap",style:{color:"#a78bfa"},title:"Multiplier",children:[e.boost.toFixed(1),"x"]})]},e.date)})})]})]})}var iu=25;function ou({sessions:e,showPublic:t}){const[n,r]=h.useState(iu),a=h.useRef(null);if(h.useEffect(()=>{const e=a.current;if(!e)return;const t=new IntersectionObserver(([e])=>{e?.isIntersecting&&r(e=>e+iu)},{rootMargin:"200px"});return t.observe(e),()=>t.disconnect()},[e,n]),h.useEffect(()=>{r(iu)},[e.length]),0===e.length)return null;const s=e.slice(0,n),i=n<e.length;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-[10px] font-mono text-text-muted uppercase tracking-wider px-1 pt-2",children:"Sessions"}),o.jsxs("div",{className:"space-y-1",children:[s.map((e,n)=>{const r=kc(e.client),a=yc[r]??r.slice(0,2).toUpperCase(),s=mc[r]??"#91919a",i="cursor"===r?"var(--text-primary)":s,l=xc[r],c=t?e.title??"Untitled":e.private_title||e.title||"Untitled";return o.jsxs(pl.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,delay:Math.min(.02*n,.6)},className:"flex items-start gap-2.5 py-2 px-2 rounded-lg hover:bg-bg-surface-1 transition-colors group",children:[o.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center text-[7px] font-bold font-mono flex-shrink-0 mt-0.5",style:{backgroundColor:\`\${s}15\`,color:s,border:\`1px solid \${s}20\`},children:l?o.jsx("div",{className:"w-3 h-3",style:{backgroundColor:i,maskImage:\`url(\${l})\`,maskSize:"contain",maskRepeat:"no-repeat",maskPosition:"center",WebkitMaskImage:\`url(\${l})\`,WebkitMaskSize:"contain",WebkitMaskRepeat:"no-repeat",WebkitMaskPosition:"center"}}):a}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm text-text-secondary group-hover:text-text-primary transition-colors leading-snug truncate",children:c}),o.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[o.jsx("span",{className:"text-[10px] font-mono text-text-muted",children:Qc(e.duration_seconds)}),o.jsx("span",{className:"text-[10px] text-text-muted",children:(u=e.started_at,new Date(u).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}))}),e.project&&o.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate",children:e.project})]})]})]},e.session_id);var u}),i&&o.jsx("div",{ref:a,className:"py-2 text-center",children:o.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Showing ",s.length," of ",e.length,"..."]})})]})]})}var lu=[{id:"sessions",label:"Sessions"},{id:"insights",label:"Insights"}];function cu({activeTab:e,onTabChange:t,externalLinks:n,showSettings:r=!0}){return o.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 rounded-lg bg-bg-surface-1 border border-border/40",children:[lu.map(({id:n,label:r})=>{const a=e===n;return o.jsx("button",{onClick:()=>t(n),className:\`\\n px-3 py-1 rounded-md text-xs font-medium transition-all duration-150\\n \${a?"bg-bg-surface-2 text-text-primary shadow-sm":"text-text-muted hover:text-text-primary"}\\n \`,children:r},n)}),r&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),o.jsxs("button",{onClick:()=>t("settings"),className:\`\\n flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-medium transition-all duration-150\\n \${"settings"===e?"bg-bg-surface-2 text-text-primary shadow-sm":"text-text-muted hover:text-text-primary"}\\n \`,children:[o.jsx(rc,{className:"w-3 h-3"}),"Settings"]})]}),n&&n.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),n.map(({label:e,href:t})=>o.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-mono tracking-wide text-text-muted hover:text-accent transition-colors duration-150",children:[e,o.jsx(zl,{className:"w-2.5 h-2.5 opacity-50"})]},t))]})]})}function uu({label:e,active:t,onClick:n}){return o.jsx("button",{onClick:n,className:"text-[10px] font-bold uppercase tracking-wider px-3 py-1.5 rounded-full transition-all duration-200 cursor-pointer border "+(t?"bg-accent text-bg-base border-accent scale-105":"bg-bg-surface-1 border-border text-text-muted hover:text-text-primary hover:border-text-muted/50"),style:t?{boxShadow:"0 2px 10px rgba(var(--accent-rgb), 0.4)"}:void 0,children:e})}function du({sessions:e,filters:t,onFilterChange:n}){const r=h.useMemo(()=>[...new Set(e.map(e=>e.client))].sort(),[e]),a=h.useMemo(()=>[...new Set(e.flatMap(e=>e.languages))].sort(),[e]),s=h.useMemo(()=>[...new Set(e.map(e=>e.project).filter(e=>{if(!e)return!1;const t=e.trim().toLowerCase();return!["untitled","mcp","unknown","default","none"].includes(t)}))].sort(),[e]);return r.length>0||a.length>0||s.length>0?o.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-1",children:[o.jsx(uu,{label:"All",active:"all"===t.client&&"all"===t.language&&"all"===t.project,onClick:()=>{n("client","all"),n("language","all"),n("project","all")}}),r.map(e=>o.jsx(uu,{label:gc[e]??e,active:t.client===e,onClick:()=>n("client",t.client===e?"all":e)},e)),a.map(e=>o.jsx(uu,{label:e,active:t.language===e,onClick:()=>n("language",t.language===e?"all":e)},e)),s.map(e=>o.jsx(uu,{label:e,active:t.project===e,onClick:()=>n("project",t.project===e?"all":e)},e))]}):null}function hu({onDelete:e,size:t="md",className:n=""}){const[r,a]=h.useState(!1),s=h.useRef(void 0);h.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const i=t=>{t.stopPropagation(),s.current&&clearTimeout(s.current),a(!1),e()},l=e=>{e.stopPropagation(),s.current&&clearTimeout(s.current),a(!1)},c="sm"===t?"w-3 h-3":"w-3.5 h-3.5",u="sm"===t?"p-1":"p-1.5";return r?o.jsxs("span",{className:\`inline-flex items-center gap-0.5 \${n}\`,onClick:e=>e.stopPropagation(),children:[o.jsx("button",{onClick:i,className:\`\${u} rounded-lg transition-all bg-error/15 text-error hover:bg-error/25\`,title:"Confirm delete",children:o.jsx(jl,{className:c})}),o.jsx("button",{onClick:l,className:\`\${u} rounded-lg transition-all text-text-muted hover:bg-bg-surface-2\`,title:"Cancel",children:o.jsx(fc,{className:c})})]}):o.jsx("button",{onClick:e=>{e.stopPropagation(),a(!0),s.current=setTimeout(()=>a(!1),5e3)},className:\`\${u} rounded-lg transition-all text-text-muted hover:text-error/70 hover:bg-error/5 \${n}\`,title:"Delete",children:o.jsx(lc,{className:c})})}function fu({text:e,words:t}){if(!t?.length||!e)return o.jsx(o.Fragment,{children:e});const n=t.map(e=>e.replace(/[.*+?^\${}()|[\\]\\\\]/g,"\\\\$&")),r=new RegExp(\`(\${n.join("|")})\`,"gi"),a=e.split(r);return o.jsx(o.Fragment,{children:a.map((e,t)=>t%2==1?o.jsx("mark",{className:"bg-accent/30 text-inherit rounded-sm px-px",children:e},t):o.jsx("span",{children:e},t))})}function pu(e,t){const n=e=>new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0});return\`\${n(e)} \u2014 \${n(t)}\`}function mu(e){if(e<60)return\`\${e}s\`;const t=Math.round(e/60);if(t<60)return\`\${t}m\`;const n=Math.floor(t/60),r=t%60;return r>0?\`\${n}h \${r}m\`:\`\${n}h\`}var gu={feature:"bg-success/15 text-success border-success/30",bugfix:"bg-error/15 text-error border-error/30",refactor:"bg-purple/15 text-purple border-purple/30",test:"bg-blue/15 text-blue border-blue/30",docs:"bg-accent/15 text-accent border-accent/30",setup:"bg-text-muted/15 text-text-muted border-text-muted/20",deployment:"bg-emerald/15 text-emerald border-emerald/30"};function yu({category:e}){const t=gu[e]??"bg-bg-surface-2 text-text-secondary border-border";return o.jsx("span",{className:\`text-[10px] px-1.5 py-0.5 rounded-full border font-bold uppercase tracking-wider \${t}\`,children:e})}function vu(e){return e>=5?"text-text-secondary":e>=4?"text-amber-500":e>=3?"text-orange-500":"text-error"}function xu({score:e,decimal:t}){const n=e>=5,r=t?e.toFixed(1):String(Math.round(e)),a=r.endsWith(".0")?r.slice(0,-2):r;return o.jsxs("span",{className:"text-[10px] font-mono "+(n?"":"font-bold"),title:\`\${e.toFixed(1)}/5\`,children:[o.jsx("span",{className:vu(e),children:a}),o.jsx("span",{className:"text-text-muted/50",children:"/5"})]})}function bu({model:e}){return e?o.jsx("div",{className:"flex flex-wrap items-center gap-4",children:o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] whitespace-nowrap",children:[o.jsx(_l,{className:"w-3 h-3 text-text-muted/50 flex-shrink-0"}),o.jsx("span",{className:"text-text-secondary",children:"Model"}),o.jsx("span",{className:"text-text-secondary font-mono font-bold ml-0.5",children:e})]})}):null}function wu({evaluation:e,showPublic:t=!1,model:n}){const r=!!n,a=[{label:"Prompt",value:e.prompt_quality,reason:e.prompt_quality_reason,Icon:Xl},{label:"Context",value:e.context_provided,reason:e.context_provided_reason,Icon:Vl},{label:"Scope",value:e.scope_quality,reason:e.scope_quality_reason,Icon:ic},{label:"Independence",value:e.independence_level,reason:e.independence_level_reason,Icon:Dl}],s=a.some(e=>e.reason)||e.task_outcome_reason;return o.jsxs("div",{className:"px-2.5 py-2 bg-bg-surface-2/30 rounded-md mb-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-2",children:[a.map(({label:e,value:t,Icon:n})=>o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] whitespace-nowrap",children:[o.jsx(n,{className:"w-3 h-3 text-text-muted/60 flex-shrink-0"}),o.jsx("span",{className:"text-text-secondary whitespace-nowrap",children:e}),o.jsx(xu,{score:t})]},e)),r&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"hidden md:block h-3.5 w-px bg-border/30"}),o.jsx(bu,{model:n})]}),o.jsx("div",{className:"hidden md:block h-3.5 w-px bg-border/30"}),o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] whitespace-nowrap",children:[o.jsx(Gl,{className:"w-3 h-3 text-text-muted/50"}),o.jsx("span",{className:"text-text-muted",children:"Iterations"}),o.jsx("span",{className:"text-text-secondary font-mono font-bold ml-0.5",children:e.iteration_count})]}),o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] whitespace-nowrap",children:[o.jsx(hc,{className:"w-3 h-3 text-text-muted/50"}),o.jsx("span",{className:"text-text-muted",children:"Tools"}),o.jsx("span",{className:"text-text-secondary font-mono font-bold ml-0.5",children:e.tools_leveraged})]})]}),!t&&s&&o.jsx("div",{className:"mt-2 pt-2 border-t border-border/15",children:o.jsxs("div",{className:"grid grid-cols-[86px_minmax(0,1fr)] gap-x-2 gap-y-1 text-[10px]",children:[a.filter(e=>e.reason).map(({label:e,value:t,reason:n})=>o.jsxs("div",{className:"contents",children:[o.jsxs("span",{className:\`\${vu(t)} font-bold text-right\`,children:[e,":"]}),o.jsx("span",{className:"text-text-secondary leading-relaxed",children:n})]},e)),e.task_outcome_reason&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"col-span-2 border-t border-border/15 mt-0.5 mb-0.5"}),o.jsx("span",{className:"text-text-secondary font-bold text-right",children:"Outcome:"}),o.jsx("span",{className:"text-text-secondary leading-relaxed",children:e.task_outcome_reason})]})]})})]})}function ku({prompt:e,imageCount:t,images:n}){const[r,a]=h.useState(!1),s=e.length>300,i=s&&!r?e.slice(0,300)+"\u2026":e,l=t??n?.length??0;return o.jsxs("div",{className:"px-2.5 py-2 bg-bg-surface-2/20 rounded-md mb-2 border border-border/10",children:[o.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[o.jsx(Xl,{className:"w-3 h-3 text-text-muted/50"}),o.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-text-muted",children:"Prompt"}),l>0&&o.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-text-muted bg-bg-surface-2 px-1.5 py-0.5 rounded-full border border-border/20",children:[o.jsx(Bl,{className:"w-2.5 h-2.5"}),l]})]}),o.jsx("p",{className:"text-[11px] text-text-secondary leading-relaxed whitespace-pre-wrap break-words",children:i}),s&&o.jsx("button",{onClick:()=>a(!r),className:"text-[10px] text-accent hover:text-accent/80 mt-1 font-medium",children:r?"Show less":"Show more"}),n&&n.length>0&&o.jsx("div",{className:"mt-2 pt-1.5 border-t border-border/10 space-y-1",children:n.map((e,t)=>o.jsxs("div",{className:"flex items-start gap-1.5",children:[o.jsx(Bl,{className:"w-3 h-3 text-text-muted/50 flex-shrink-0 mt-0.5"}),o.jsx("span",{className:"text-[10px] text-text-secondary leading-relaxed",children:e.description})]},t))})]})}var Su=h.memo(function({session:e,milestones:t,defaultExpanded:n=!1,externalShowPublic:r,contextLabel:a,hideClientAvatar:s=!1,hideProject:i=!1,showFullDate:l=!1,highlightWords:c,onDeleteSession:u,onDeleteMilestone:d}){const[f,p]=h.useState(n),[m,g]=h.useState(!1),y=r??m,v=g,x=kc(e.client),b=mc[x]??"#91919a",w="cursor"===x,k=w?"var(--text-primary)":b,S=w?{backgroundColor:"var(--bg-surface-2)",color:"var(--text-primary)",border:"1px solid var(--border)"}:{backgroundColor:\`\${b}15\`,color:b,border:\`1px solid \${b}30\`},j=yc[x]??x.slice(0,2).toUpperCase(),C=xc[x],N=t.length>0||!!e.evaluation||!!e.model||!!e.prompt,T=e.project?.trim()||"",E=!T||["untitled","mcp","unknown","default","none","null","undefined"].includes(T.toLowerCase()),M=t[0],P=E&&M?M.title:T,L=E&&M?M.private_title||M.title:T;let D=e.private_title||e.title||L||"Untitled Session",A=e.title||P||"Untitled Session";const _=D!==A&&void 0===r,z=!!u||N||_,R=a?.replace(/^\\s*prompt\\s*/i,"").trim();return o.jsxs("div",{className:"group/card mb-2 rounded-xl border transition-all duration-200 "+(f?"bg-bg-surface-1 border-accent/35 shadow-md":"bg-bg-surface-1/35 border-border/50 hover:border-accent/30"),children:[o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{className:"flex-1 flex items-center gap-3 px-3.5 py-2.5 text-left min-w-0",onClick:()=>N&&p(!f),style:{cursor:N?"pointer":"default"},children:[!s&&o.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center text-[11px] font-black font-mono flex-shrink-0 shadow-sm",style:S,title:gc[x]??x,children:C?o.jsx("div",{className:"w-4 h-4",style:{backgroundColor:k,maskImage:\`url(\${C})\`,maskSize:"contain",maskRepeat:"no-repeat",maskPosition:"center",WebkitMaskImage:\`url(\${C})\`,WebkitMaskSize:"contain",WebkitMaskRepeat:"no-repeat",WebkitMaskPosition:"center"}}):j}),o.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[a&&o.jsx("span",{className:"inline-flex items-center rounded-md border border-accent/20 bg-accent/10 px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider text-accent/90",children:R||a}),o.jsx("div",{className:"flex items-center gap-1.5 min-w-0",children:o.jsx(Qi,{mode:"wait",children:o.jsxs(pl.div,{initial:{opacity:0,x:-5},animate:{opacity:1,x:0},exit:{opacity:0,x:5},transition:{duration:.1},className:"flex items-center gap-1.5 min-w-0",children:[y?o.jsx(ac,{className:"w-3 h-3 text-success/70 flex-shrink-0"}):o.jsx(ql,{className:"w-3 h-3 text-accent/70 flex-shrink-0"}),o.jsx("span",{className:"text-[15px] font-semibold truncate text-text-primary tracking-tight leading-tight",children:o.jsx(fu,{text:y?A:D,words:c})})]},y?"public":"private")})})]}),o.jsxs("div",{className:"flex items-center gap-3.5 text-[11px] text-text-secondary font-medium",children:[o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(Pl,{className:"w-3 h-3 opacity-75"}),mu(e.duration_seconds)]}),o.jsxs("span",{className:"text-text-secondary/80 font-mono tracking-tight",children:[l&&\`\${new Date(e.started_at).toLocaleDateString([],{month:"short",day:"numeric"})} \xB7 \`,pu(e.started_at,e.ended_at).split(" \u2014 ")[0]]}),!y&&!E&&!i&&o.jsxs("span",{className:"flex items-center gap-1 text-text-secondary/85",title:\`Project: \${T}\`,children:[o.jsx($l,{className:"w-2.5 h-2.5 opacity-70"}),o.jsx("span",{className:"max-w-[130px] truncate",children:T})]}),t.length>0&&o.jsxs("span",{className:"flex items-center gap-1 text-text-secondary/85",title:\`\${t.length} milestone\${1!==t.length?"s":""}\`,children:[o.jsx(Ol,{className:"w-2.5 h-2.5 opacity-70"}),t.length]}),e.evaluation&&o.jsx(xu,{score:(F=e.evaluation,(F.prompt_quality+F.context_provided+F.scope_quality+F.independence_level)/4),decimal:!0})]})]})]}),z&&o.jsxs("div",{className:"flex items-center px-2.5 gap-1.5 border-l border-border/30 h-9 self-center",children:[u&&o.jsx(hu,{onDelete:()=>u(e.session_id),className:"opacity-0 group-hover/card:opacity-100 focus-within:opacity-100"}),_&&o.jsx("button",{onClick:e=>{e.stopPropagation(),v(!y)},className:"p-1.5 rounded-lg transition-all "+(y?"bg-success/10 text-success":"text-text-secondary hover:text-text-primary hover:bg-bg-surface-2"),title:y?"Public title shown":"Private title shown","aria-label":y?"Show private title":"Show public title",children:y?o.jsx(Fl,{className:"w-3.5 h-3.5"}):o.jsx(Rl,{className:"w-3.5 h-3.5"})}),N&&o.jsx("button",{onClick:()=>p(!f),className:"p-1.5 rounded-lg transition-all "+(f?"text-accent bg-accent/8":"text-text-secondary hover:text-text-primary hover:bg-bg-surface-2"),title:f?"Collapse details":"Expand details","aria-label":f?"Collapse details":"Expand details",children:o.jsx(Cl,{className:"w-4 h-4 transition-transform duration-200 "+(f?"rotate-180":"")})})]})]}),o.jsx(Qi,{children:f&&N&&o.jsx(pl.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:o.jsxs("div",{className:"px-3.5 pb-3.5 pt-1.5 space-y-2",children:[o.jsx("div",{className:"h-px bg-border/20 mb-2 mx-1"}),!y&&e.prompt&&o.jsx(ku,{prompt:e.prompt,imageCount:e.prompt_image_count,images:e.prompt_images}),e.evaluation&&o.jsx(wu,{evaluation:e.evaluation,showPublic:y,model:e.model}),!e.evaluation&&o.jsx(bu,{model:e.model}),t.length>0&&o.jsx("div",{className:"space-y-0.5",children:t.map(e=>{const t=y?e.title:e.private_title||e.title,n=function(e){if(!e||e<=0)return"";if(e<60)return\`\${e}m\`;const t=Math.floor(e/60),n=e%60;return n>0?\`\${t}h \${n}m\`:\`\${t}h\`}(e.duration_minutes);return o.jsxs("div",{className:"group flex items-center gap-2 p-1.5 rounded-md hover:bg-bg-surface-2/40 transition-colors",children:[o.jsx("div",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:bc[e.category]??"#9c9588"}}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-text-secondary group-hover:text-text-primary truncate",children:o.jsx(fu,{text:t,words:c})}),o.jsx(yu,{category:e.category})]})}),n&&o.jsx("span",{className:"text-[10px] text-text-muted font-mono",children:n}),d&&o.jsx(hu,{onDelete:()=>d(e.id),size:"sm",className:"opacity-0 group-hover:opacity-100"})]},e.id)})})]})})})]});var F});function ju(e){if(e<60)return\`\${e}s\`;const t=Math.round(e/60);if(t<60)return\`\${t}m\`;const n=Math.floor(t/60),r=t%60;return r>0?\`\${n}h \${r}m\`:\`\${n}h\`}function Cu({score:e,decimal:t}){const n=e>=5,r=n?"text-text-secondary":e>=4?"text-amber-500":e>=3?"text-orange-500":"text-error",a=t?e.toFixed(1):String(Math.round(e)),s=a.endsWith(".0")?a.slice(0,-2):a;return o.jsxs("span",{className:"text-[10px] font-mono "+(n?"":"font-bold"),title:\`\${e.toFixed(1)}/5\`,children:[o.jsx("span",{className:r,children:s}),o.jsx("span",{className:"text-text-muted/50",children:"/5"})]})}var Nu=h.memo(function({group:e,defaultExpanded:t,globalShowPublic:n,showFullDate:r,highlightWords:a,onDeleteSession:s,onDeleteMilestone:i,onDeleteConversation:l}){const[c,u]=h.useState(t),[d,f]=h.useState(!1),p=n||d;if(1===e.sessions.length){const l=e.sessions[0];return o.jsx(Su,{session:l.session,milestones:l.milestones,defaultExpanded:t&&l.milestones.length>0,externalShowPublic:n||void 0,showFullDate:r,highlightWords:a,onDeleteSession:s,onDeleteMilestone:i})}const m=kc(e.sessions[0].session.client),g=mc[m]??"#91919a",y="cursor"===m,v=y?"var(--text-primary)":g,x=y?{backgroundColor:"var(--bg-surface-2)",color:"var(--text-primary)",border:"1px solid var(--border)"}:{backgroundColor:\`\${g}15\`,color:g,border:\`1px solid \${g}30\`},b=yc[m]??m.slice(0,2).toUpperCase(),w=xc[m],k=e.aggregateEval,S=k?(k.prompt_quality+k.context_provided+k.scope_quality+k.independence_level)/4:0,j=e.sessions[0].session,C=j.private_title||j.title||j.project||"Conversation",N=j.title||j.project||"Conversation",T=C!==N&&!n,E=j.project?.trim()||"",M=!!E&&!["untitled","mcp","unknown","default","none","null","undefined"].includes(E.toLowerCase());return o.jsxs("div",{className:"group/conv mb-2 rounded-xl border transition-all duration-200 "+(c?"bg-bg-surface-1 border-accent/35 shadow-md":"bg-bg-surface-1/35 border-border/50 hover:border-accent/30"),children:[o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{className:"flex-1 flex items-center gap-3 px-3.5 py-2.5 text-left min-w-0",onClick:()=>u(!c),children:[o.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center text-[11px] font-black font-mono flex-shrink-0 shadow-sm",style:x,title:gc[m]??m,children:w?o.jsx("div",{className:"w-4 h-4",style:{backgroundColor:v,maskImage:\`url(\${w})\`,maskSize:"contain",maskRepeat:"no-repeat",maskPosition:"center",WebkitMaskImage:\`url(\${w})\`,WebkitMaskSize:"contain",WebkitMaskRepeat:"no-repeat",WebkitMaskPosition:"center"}}):b}),o.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex items-center gap-1.5 min-w-0",children:o.jsx(Qi,{mode:"wait",children:o.jsxs(pl.div,{initial:{opacity:0,x:-5},animate:{opacity:1,x:0},exit:{opacity:0,x:5},transition:{duration:.1},className:"flex items-center gap-1.5 min-w-0",children:[p?o.jsx(ac,{className:"w-3 h-3 text-success/70 flex-shrink-0"}):o.jsx(ql,{className:"w-3 h-3 text-accent/70 flex-shrink-0"}),o.jsx("span",{className:"text-[15px] font-semibold truncate text-text-primary tracking-tight leading-tight",children:o.jsx(fu,{text:p?N:C,words:a})})]},p?"public":"private")})}),o.jsxs("span",{className:"text-[10px] font-bold text-accent/90 bg-accent/10 px-1.5 py-0.5 rounded border border-accent/20 flex-shrink-0",children:[e.sessions.length," prompts"]})]}),o.jsxs("div",{className:"flex items-center gap-3.5 text-[11px] text-text-secondary font-medium",children:[o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(Pl,{className:"w-3 h-3 opacity-75"}),ju(e.totalDuration)]}),o.jsxs("span",{className:"text-text-secondary/80 font-mono tracking-tight",children:[r&&\`\${new Date(e.lastSessionAt).toLocaleDateString([],{month:"short",day:"numeric"})} \xB7 \`,(P=e.lastSessionAt,new Date(P).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}))]}),!p&&M&&o.jsxs("span",{className:"flex items-center gap-1 text-text-secondary/85",title:\`Project: \${E}\`,children:[o.jsx($l,{className:"w-2.5 h-2.5 opacity-70"}),o.jsx("span",{className:"max-w-[130px] truncate",children:E})]}),e.totalMilestones>0&&o.jsxs("span",{className:"flex items-center gap-1 text-text-secondary/85",title:\`\${e.totalMilestones} milestone\${1!==e.totalMilestones?"s":""}\`,children:[o.jsx(Ol,{className:"w-2.5 h-2.5 opacity-70"}),e.totalMilestones]}),k&&o.jsx(Cu,{score:S,decimal:!0})]})]})]}),o.jsxs("div",{className:"flex items-center px-2.5 gap-1.5 border-l border-border/30 h-9 self-center",children:[l&&e.conversationId&&o.jsx(hu,{onDelete:()=>l(e.conversationId),className:"opacity-0 group-hover/conv:opacity-100 focus-within:opacity-100"}),T&&o.jsx("button",{onClick:e=>{e.stopPropagation(),f(!d)},className:"p-1.5 rounded-lg transition-all "+(p?"bg-success/10 text-success":"text-text-secondary hover:text-text-primary hover:bg-bg-surface-2"),title:p?"Public title shown":"Private title shown","aria-label":p?"Show private title":"Show public title",children:p?o.jsx(Fl,{className:"w-3.5 h-3.5"}):o.jsx(Rl,{className:"w-3.5 h-3.5"})}),o.jsx("button",{onClick:()=>u(!c),className:"p-1.5 rounded-lg transition-all "+(c?"text-accent bg-accent/8":"text-text-secondary hover:text-text-primary hover:bg-bg-surface-2"),title:c?"Collapse conversation":"Expand conversation","aria-label":c?"Collapse conversation":"Expand conversation",children:o.jsx(Cl,{className:"w-4 h-4 transition-transform duration-200 "+(c?"rotate-180":"")})})]})]}),o.jsx(Qi,{children:c&&o.jsx(pl.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:o.jsxs("div",{className:"px-3.5 pb-2.5 relative",children:[o.jsx("div",{className:"absolute left-[1.75rem] top-0 bottom-2 w-px",style:{backgroundColor:\`\${g}25\`}}),o.jsx("div",{className:"space-y-1 pl-10",children:e.sessions.map(e=>o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute -left-7 top-5 w-2 h-2 rounded-full border-2",style:{backgroundColor:g,borderColor:\`\${g}40\`}}),o.jsx(Su,{session:e.session,milestones:e.milestones,defaultExpanded:!1,externalShowPublic:p||void 0,hideClientAvatar:!0,hideProject:!0,showFullDate:r,highlightWords:a,onDeleteSession:s,onDeleteMilestone:i})]},e.session.session_id))})]})})})]});var P});function Tu({sessions:e,milestones:t,filters:n,globalShowPublic:r,showFullDate:a,highlightWords:s,outsideWindowCounts:i,onNavigateNewer:l,onNavigateOlder:c,onDeleteSession:u,onDeleteConversation:d,onDeleteMilestone:f}){const p=h.useMemo(()=>e.filter(e=>("all"===n.client||e.client===n.client)&&(!("all"!==n.language&&!e.languages.includes(n.language))&&("all"===n.project||(e.project??"")===n.project))),[e,n]),m=h.useMemo(()=>"all"===n.category?t:t.filter(e=>e.category===n.category),[t,n.category]),g=h.useMemo(()=>{const e=function(e,t){const n=new Map;for(const a of t){const e=n.get(a.session_id);e?e.push(a):n.set(a.session_id,[a])}const r=e.map(e=>({session:e,milestones:n.get(e.session_id)??[]}));return r.sort((e,t)=>Cc(t.session.started_at)-Cc(e.session.started_at)),r}(p,m);return function(e){const t=new Map,n=[];for(const a of e){const e=a.session.conversation_id;if(e){const n=t.get(e);n?n.push(a):t.set(e,[a])}else n.push(a)}const r=[];for(const[a,s]of t){s.sort((e,t)=>Cc(t.session.started_at)-Cc(e.session.started_at));const e=s.reduce((e,t)=>e+t.session.duration_seconds,0),t=s.reduce((e,t)=>e+t.milestones.length,0),n=s[s.length-1].session.started_at,i=s[0].session.ended_at,o=s[0].session.started_at;r.push({conversationId:a,sessions:s,aggregateEval:Tc(s),totalDuration:e,totalMilestones:t,startedAt:n,endedAt:i,lastSessionAt:o})}for(const a of n)r.push({conversationId:null,sessions:[a],aggregateEval:a.session.evaluation?Tc([a]):null,totalDuration:a.session.duration_seconds,totalMilestones:a.milestones.length,startedAt:a.session.started_at,endedAt:a.session.ended_at,lastSessionAt:a.session.started_at});return r.sort((e,t)=>Cc(t.lastSessionAt)-Cc(e.lastSessionAt)),r}(e)},[p,m]),[y,v]=h.useState(25),x=h.useRef(null);if(h.useEffect(()=>{v(25)},[g]),h.useEffect(()=>{const e=x.current;if(!e)return;const t=new IntersectionObserver(([e])=>{e?.isIntersecting&&v(e=>e+25)},{rootMargin:"200px"});return t.observe(e),()=>t.disconnect()},[g,y]),0===g.length){const e=i&&i.before>0,t=i&&i.after>0;return o.jsxs("div",{className:"text-center text-text-muted py-8 text-sm mb-4 space-y-3",children:[t&&o.jsxs("button",{onClick:l,className:"flex flex-col items-center gap-0.5 mx-auto text-[11px] text-text-muted/60 hover:text-accent transition-colors group",children:[o.jsx(El,{className:"w-3.5 h-3.5"}),o.jsxs("span",{children:[i.after," newer session",1!==i.after?"s":""]}),i.newerLabel&&o.jsx("span",{className:"text-[10px] opacity-70 group-hover:opacity-100",children:i.newerLabel})]}),o.jsx("div",{children:"No sessions in this window"}),e&&o.jsxs("button",{onClick:c,className:"flex flex-col items-center gap-0.5 mx-auto text-[11px] text-text-muted/60 hover:text-accent transition-colors group",children:[i.olderLabel&&o.jsx("span",{className:"text-[10px] opacity-70 group-hover:opacity-100",children:i.olderLabel}),o.jsxs("span",{children:[i.before," older session",1!==i.before?"s":""]}),o.jsx(Cl,{className:"w-3.5 h-3.5"})]})]})}const b=y<g.length,w=b?g.slice(0,y):g;return o.jsxs("div",{className:"space-y-2 mb-4",children:[i&&i.after>0&&o.jsxs("button",{onClick:l,className:"flex flex-col items-center gap-0.5 w-full text-[11px] text-text-muted/60 hover:text-accent py-1.5 transition-colors group",children:[o.jsx(El,{className:"w-3.5 h-3.5"}),o.jsxs("span",{children:[i.after," newer session",1!==i.after?"s":""]}),i.newerLabel&&o.jsx("span",{className:"text-[10px] opacity-70 group-hover:opacity-100",children:i.newerLabel})]}),w.map(e=>o.jsx(Nu,{group:e,defaultExpanded:!1,globalShowPublic:r,showFullDate:a,highlightWords:s,onDeleteSession:u,onDeleteMilestone:f,onDeleteConversation:d},e.conversationId??e.sessions[0].session.session_id)),b&&o.jsx("div",{ref:x,className:"h-px"}),g.length>25&&o.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 text-[11px] text-text-muted",children:[o.jsxs("span",{children:["Showing ",Math.min(y,g.length)," of ",g.length," conversations"]}),b&&o.jsx("button",{onClick:()=>v(g.length),className:"text-accent hover:text-accent/80 font-semibold transition-colors",children:"Show all"})]}),i&&i.before>0&&o.jsxs("button",{onClick:c,className:"flex flex-col items-center gap-0.5 w-full text-[11px] text-text-muted/60 hover:text-accent py-1.5 transition-colors group",children:[i.olderLabel&&o.jsx("span",{className:"text-[10px] opacity-70 group-hover:opacity-100",children:i.olderLabel}),o.jsxs("span",{children:[i.before," older session",1!==i.before?"s":""]}),o.jsx(Cl,{className:"w-3.5 h-3.5"})]})]})}var Eu={accent:{border:"border-accent/20",bg:"bg-[var(--accent-alpha)]",dot:"bg-accent"},success:{border:"border-success/20",bg:"bg-success/10",dot:"bg-success"},muted:{border:"border-border",bg:"bg-bg-surface-2/50",dot:"bg-text-muted"}};function Mu({label:e,color:t="accent",dot:n=!1,icon:r,glow:a=!1,className:s="","data-testid":i}){const l=Eu[t];return o.jsxs("div",{"data-testid":i,className:\`inline-flex items-center gap-2 px-3 py-1 rounded-full border \${l.border} \${l.bg} \${s}\`,style:a?{boxShadow:"0 0 10px rgba(var(--accent-rgb), 0.1)"}:void 0,children:[n&&o.jsx("span",{className:\`w-1.5 h-1.5 rounded-full \${l.dot} animate-pulse\`}),r,o.jsx("span",{className:"text-[10px] font-mono text-text-secondary tracking-widest uppercase",children:e})]})}var Pu={"1h":{visibleDuration:36e5,majorTickInterval:9e5,minorTickInterval:3e5,labelFormat:e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})},"3h":{visibleDuration:108e5,majorTickInterval:18e5,minorTickInterval:6e5,labelFormat:e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})},"6h":{visibleDuration:216e5,majorTickInterval:36e5,minorTickInterval:9e5,labelFormat:e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})},"12h":{visibleDuration:432e5,majorTickInterval:72e5,minorTickInterval:18e5,labelFormat:e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})},"24h":{visibleDuration:864e5,majorTickInterval:144e5,minorTickInterval:36e5,labelFormat:e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})},day:{visibleDuration:864e5,majorTickInterval:144e5,minorTickInterval:36e5,labelFormat:e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})},"7d":{visibleDuration:6048e5,majorTickInterval:864e5,minorTickInterval:216e5,labelFormat:e=>e.toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"})},week:{visibleDuration:6048e5,majorTickInterval:864e5,minorTickInterval:216e5,labelFormat:e=>e.toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"})},"30d":{visibleDuration:2592e6,majorTickInterval:6048e5,minorTickInterval:864e5,labelFormat:e=>e.toLocaleDateString([],{month:"short",day:"numeric"})},month:{visibleDuration:2592e6,majorTickInterval:6048e5,minorTickInterval:864e5,labelFormat:e=>e.toLocaleDateString([],{month:"short",day:"numeric"})}};function Lu(e){if(e<60)return\`\${e}s\`;const t=Math.round(e/60);if(t<60)return\`\${t}m\`;const n=Math.floor(t/60),r=t%60;return r>0?\`\${n}h \${r}m\`:\`\${n}h\`}function Du({value:e,onChange:t,scale:n,window:r,sessions:a=[],milestones:s=[],showPublic:i=!1}){const l=h.useRef(null),[c,u]=h.useState(0),d=void 0!==r;h.useEffect(()=>{if(!l.current)return;const e=new ResizeObserver(e=>{for(const t of e)u(t.contentRect.width)});return e.observe(l.current),u(l.current.getBoundingClientRect().width),()=>e.disconnect()},[]);const f=Pu[n],p=d?r.end-r.start:f.visibleDuration,m=d?r.end:e,g=d?r.start:e-f.visibleDuration,y=c>0?c/p:0,[v,x]=h.useState(!1),[b,w]=h.useState(0),k=h.useRef(0),S=h.useRef(0),j=h.useRef(null);h.useEffect(()=>()=>{j.current&&clearTimeout(j.current)},[]);const C=h.useCallback(e=>{x(!0),k.current=e.clientX,S.current=0,w(0),e.currentTarget.setPointerCapture(e.pointerId)},[]),N=h.useCallback(n=>{if(!v||0===y)return;const r=n.clientX-k.current;k.current=n.clientX,S.current+=r,w(e=>e+r),j.current||(j.current=setTimeout(()=>{j.current=null;const n=S.current;S.current=0,w(0);const r=e+-n/y,a=d?Math.max(Math.min(r,m),g):Math.min(r,Date.now());t(a)},80))},[v,y,e,m,g,d,t]),T=h.useCallback(()=>{if(x(!1),j.current&&(clearTimeout(j.current),j.current=null),0!==S.current&&y>0){const n=e+-S.current/y,r=d?Math.max(Math.min(n,m),g):Math.min(n,Date.now());S.current=0,t(r)}w(0)},[e,m,g,d,y,t]),E=h.useMemo(()=>{if(!c||0===y)return[];const e=g-f.majorTickInterval,t=m+f.majorTickInterval,n=[];for(let r=Math.ceil(e/f.majorTickInterval)*f.majorTickInterval;r<=t;r+=f.majorTickInterval)n.push({type:"major",time:r,position:(r-m)*y,label:f.labelFormat(new Date(r))});for(let r=Math.ceil(e/f.minorTickInterval)*f.minorTickInterval;r<=t;r+=f.minorTickInterval)r%f.majorTickInterval!==0&&n.push({type:"minor",time:r,position:(r-m)*y});return n},[g,m,c,y,f]),M=h.useMemo(()=>a.map(e=>({session:e,start:Cc(e.started_at),end:Cc(e.ended_at)})),[a]),P=h.useMemo(()=>{if(!c||0===y)return[];const e=M.filter(e=>e.start<=m&&e.end>=g).map(e=>({session:e.session,leftOffset:(Math.max(e.start,g)-m)*y,width:(Math.min(e.end,m)-Math.max(e.start,g))*y}));return e.length>100?(e.sort((e,t)=>t.width-e.width),e.slice(0,100)):e},[M,g,m,c,y]),L=h.useMemo(()=>s.map(e=>({milestone:e,time:Cc(e.created_at)})).sort((e,t)=>e.time-t.time),[s]),D=h.useMemo(()=>{if(!c||0===y||!L.length)return[];let e=0,t=L.length;for(;e<t;){const n=e+t>>1;L[n].time<g?e=n+1:t=n}const n=e;for(t=L.length;e<t;){const n=e+t>>1;L[n].time<=m?e=n+1:t=n}const r=e,a=[];for(let s=n;s<r;s++){const e=L[s];a.push({...e,offset:(e.time-m)*y})}return a},[L,g,m,c,y]),A=h.useMemo(()=>{if(!c||0===y)return null;const e=Date.now();return e<g||e>m?null:(e-m)*y},[g,m,c,y]),[_,z]=h.useState(null),R=h.useRef(e);return h.useEffect(()=>{_&&Math.abs(e-R.current)>1e3&&z(null),R.current=e},[e,_]),o.jsxs("div",{className:"relative h-16",children:[o.jsxs("div",{"data-testid":"time-scrubber",className:"absolute inset-0 bg-transparent border-t border-border/50 overflow-hidden select-none touch-none cursor-grab active:cursor-grabbing",ref:l,onPointerDown:C,onPointerMove:N,onPointerUp:T,style:{touchAction:"none"},children:[null!==A&&o.jsx("div",{className:"absolute top-0 bottom-0 w-[2px] bg-accent/50 z-30",style:{right:-A}}),null!==A&&A<-1&&o.jsx("div",{className:"absolute top-0 bottom-0 bg-bg-base/30 z-20",style:{right:0,width:-A}}),o.jsxs("div",{className:"absolute right-0 top-0 bottom-0 w-0 pointer-events-none",style:b?{transform:\`translateX(\${b}px)\`,willChange:"transform"}:void 0,children:[E.map(e=>o.jsx("div",{className:"absolute top-0 border-l "+("major"===e.type?"border-border/60":"border-border/30"),style:{left:e.position,height:"major"===e.type?"100%":"35%",bottom:0},children:"major"===e.type&&e.label&&o.jsx("span",{className:"absolute top-2 left-2 text-[9px] font-bold text-text-muted uppercase tracking-wider whitespace-nowrap bg-bg-surface-1/80 px-1 py-0.5 rounded",children:e.label})},e.time)),P.map(e=>o.jsx("div",{className:"absolute bottom-0 rounded-t-md pointer-events-auto cursor-pointer hover:opacity-80",style:{left:e.leftOffset,width:Math.max(e.width,3),height:"45%",backgroundColor:"rgba(var(--accent-rgb), 0.15)",borderTop:"2px solid rgba(var(--accent-rgb), 0.5)",boxShadow:"inset 0 1px 10px rgba(var(--accent-rgb), 0.05)"},onMouseEnter:t=>{const n=t.currentTarget.getBoundingClientRect();z({type:"session",data:e.session,x:n.left+n.width/2,y:n.top})},onMouseLeave:()=>z(null)},e.session.session_id)),D.map((e,n)=>o.jsx("div",{className:"absolute bottom-2 pointer-events-auto cursor-pointer z-40 transition-transform hover:scale-125",style:{left:e.offset,transform:"translateX(-50%)"},onMouseEnter:t=>{const n=t.currentTarget.getBoundingClientRect();z({type:"milestone",data:e.milestone,x:n.left+n.width/2,y:n.top})},onMouseLeave:()=>z(null),onClick:n=>{n.stopPropagation(),t(e.time)},children:o.jsx("div",{className:"w-3.5 h-3.5 rounded-full border-2 border-bg-surface-1 shadow-lg",style:{backgroundColor:bc[e.milestone.category]??"#9c9588",boxShadow:\`0 0 10px \${bc[e.milestone.category]}50\`}})},n))]})]}),_&&Sc.createPortal(o.jsx("div",{className:"fixed z-[9999] pointer-events-none",style:{left:_.x,top:_.y,transform:"translate(-50%, -100%)"},children:o.jsxs("div",{className:"mb-3 bg-bg-surface-3/95 backdrop-blur-md text-text-primary rounded-xl shadow-2xl px-3 py-2.5 text-[11px] min-w-[180px] max-w-[280px] border border-border/50 animate-in fade-in zoom-in-95 duration-200",children:["session"===_.type?o.jsx(Au,{session:_.data,showPublic:i}):o.jsx(_u,{milestone:_.data,showPublic:i}),o.jsx("div",{className:"absolute -bottom-1.5 left-1/2 -translate-x-1/2 w-3 h-3 bg-bg-surface-3/95 border-r border-b border-border/50 rotate-45"})]})}),document.body)]})}function Au({session:e,showPublic:t}){const n=gc[e.client]??e.client,r=t?e.title||e.project||\`\${n} Session\`:e.private_title||e.title||e.project||\`\${n} Session\`;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-bold text-xs text-accent uppercase tracking-widest",children:n}),o.jsx("span",{className:"text-[10px] text-text-muted font-mono",children:Lu(e.duration_seconds)})]}),o.jsx("div",{className:"h-px bg-border/50 my-0.5"}),o.jsx("div",{className:"text-text-primary font-medium",children:r}),o.jsx("div",{className:"text-text-secondary capitalize text-[10px]",children:e.task_type})]})}function _u({milestone:e,showPublic:t}){const n=t?e.title:e.private_title??e.title;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-bold text-[10px] uppercase tracking-widest",style:{color:bc[e.category]??"#9c9588"},children:e.category}),e.complexity&&o.jsx("span",{className:"text-[9px] font-mono text-text-muted font-bold border border-border/50 px-1 rounded uppercase",children:e.complexity})]}),o.jsx("div",{className:"h-px bg-border/50 my-0.5"}),o.jsx("div",{className:"font-bold text-xs break-words text-text-primary",children:n}),!t&&e.private_title&&o.jsxs("div",{className:"text-[10px] text-text-muted italic opacity-70",children:["Public: ",e.title]})]})}function zu(e,t){const n=e.trim();if(!n)return null;const r=new Date(t),a=n.match(/^(\\d{1,2}):(\\d{2})(?::(\\d{2}))?\\s*(AM|PM)$/i);if(a){let e=parseInt(a[1],10);const t=parseInt(a[2],10),n=a[3]?parseInt(a[3],10):0,s=a[4].toUpperCase();return e<1||e>12||t>59||n>59?null:("AM"===s&&12===e&&(e=0),"PM"===s&&12!==e&&(e+=12),r.setHours(e,t,n,0),r.getTime())}const s=n.match(/^(\\d{1,2}):(\\d{2})(?::(\\d{2}))?$/);if(s){const e=parseInt(s[1],10),t=parseInt(s[2],10),n=s[3]?parseInt(s[3],10):0;return e>23||t>59||n>59?null:(r.setHours(e,t,n,0),r.getTime())}return null}function Ru({value:e,onChange:t,scale:n,onScaleChange:r,sessions:a,showPublic:s=!1}){const i=null===e,l=Rc(n),[c,u]=h.useState(Date.now());h.useEffect(()=>{if(!i)return;const e=setInterval(()=>u(Date.now()),1e3);return()=>clearInterval(e)},[i]);const d=i?c:e,f=Ic(n,d),p=h.useMemo(()=>{const{start:e,end:t}=f,n=e=>new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}),r=e=>new Date(e).toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"}),a=new Date(e).toDateString()===new Date(t-1).toDateString();return i?a?\`\${n(e)} \u2013 Now\`:\`\${r(e)}, \${n(e)} \u2013 Now\`:a?\`\${n(e)} \u2013 \${n(t)}\`:\`\${r(e)}, \${n(e)} \u2013 \${r(t)}, \${n(t)}\`},[f,i]),[m,g]=h.useState(!1),[y,v]=h.useState(""),x=h.useRef(null),b=h.useRef(!1),w=h.useRef(""),k=h.useRef(!1),S=h.useRef(0),j=h.useCallback(e=>{if(l){if(e>=Date.now()-2e3)return void t(null);const a=_c[n];return a&&r(a),void t(e)}const a=Date.now();if(e>=a-2e3)return k.current=!0,S.current=a,void t(null);k.current&&a-S.current<300||k.current&&e>=a-1e4&&e<=a+2e3?t(null):(k.current=!1,t(e))},[t,r,l,n]),C=e=>{const r=Oc(n,d,e);$c(n,r)?t(null):t(r)},N=()=>{b.current=i,t(d);const e=new Date(d).toLocaleTimeString([],{hour12:!0,hour:"2-digit",minute:"2-digit",second:"2-digit"});w.current=e,v(e),g(!0),requestAnimationFrame(()=>x.current?.select())},T=()=>{if(g(!1),b.current&&y===w.current)return void t(null);const e=zu(y,d);null!==e&&t(Math.min(e,Date.now()))},E=e=>{if(l){const t=-1===e?"Previous":"Next";return"day"===n?\`\${t} Day\`:"week"===n?\`\${t} Week\`:\`\${t} Month\`}return\`\${-1===e?"Back":"Forward"} \${Vc[n].toLowerCase()}\`};return o.jsxs("div",{"data-testid":"time-travel-panel",className:"flex flex-col bg-bg-surface-1 border border-border/50 rounded-2xl overflow-hidden mb-8 shadow-sm",children:[o.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between px-6 py-3 border-b border-border/50 gap-4",children:[o.jsxs("div",{className:"flex flex-col items-start gap-0.5",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"flex items-center gap-2 h-8",children:[m?o.jsx("input",{ref:x,type:"text",value:y,onChange:e=>v(e.target.value),onBlur:T,onKeyDown:e=>{if("Enter"===e.key)return void T();if("Escape"===e.key)return e.preventDefault(),g(!1),void(b.current&&t(null));if("ArrowUp"!==e.key&&"ArrowDown"!==e.key)return;e.preventDefault();const n=x.current;if(!n)return;const r=n.selectionStart??0,a="ArrowUp"===e.key?1:-1,s=zu(y,d);if(null===s)return;const i=y.indexOf(":"),o=y.indexOf(":",i+1),l=y.lastIndexOf(" ");let c;c=r<=i?36e5*a:o>-1&&r<=o?6e4*a:l>-1&&r<=l?1e3*a:12*a*36e5;const u=Math.min(s+c,Date.now()),h=new Date(u).toLocaleTimeString([],{hour12:!0,hour:"2-digit",minute:"2-digit",second:"2-digit"});v(h),t(u),requestAnimationFrame(()=>{n&&n.setSelectionRange(r,r)})},className:"text-xl font-mono font-bold tracking-tight bg-bg-surface-2 border rounded-lg px-2 -ml-2 w-[155px] outline-none text-text-primary "+(i?"border-accent":"border-history"),style:{boxShadow:i?"0 0 10px rgba(var(--accent-rgb), 0.2)":"0 0 10px rgba(var(--history-rgb), 0.2)"}}):o.jsxs("button",{onClick:N,className:"group flex items-center gap-2 hover:bg-bg-surface-2/50 rounded-lg px-2 -ml-2 py-1 transition-all cursor-text",title:"Click to edit time",children:[o.jsx(Pl,{className:"w-5 h-5 "+(i?"text-text-muted":"text-history")}),o.jsx("span",{"data-testid":"time-display",className:"text-xl font-mono font-bold tracking-tight tabular-nums "+(i?"text-text-primary":"text-history"),children:new Date(d).toLocaleTimeString([],{hour12:!0,hour:"2-digit",minute:"2-digit",second:"2-digit"})})]}),o.jsx("button",{onClick:m?T:N,className:"p-1.5 rounded-lg transition-colors flex-shrink-0 "+(m?i?"bg-accent text-bg-base hover:bg-accent-bright":"bg-history text-white hover:brightness-110":"text-text-muted hover:text-text-primary hover:bg-bg-surface-2"),title:m?"Confirm time":"Edit time",children:o.jsx(Ql,{className:"w-3.5 h-3.5"})})]}),i?o.jsx(Mu,{label:"Live",color:"success",dot:!0,glow:!0,"data-testid":"live-badge"}):o.jsxs(o.Fragment,{children:[o.jsx(Mu,{label:"History",color:"muted","data-testid":"history-badge"}),o.jsxs("button",{"data-testid":"go-live-button",onClick:()=>t(null),className:"group flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-bold uppercase tracking-widest bg-history/10 hover:bg-history text-history hover:text-white rounded-xl transition-all border border-history/20",children:[o.jsx(ec,{className:"w-3 h-3 group-hover:-rotate-90 transition-transform duration-500"}),"Live"]})]})]}),o.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary font-medium px-0.5",children:[o.jsx(wl,{className:"w-3.5 h-3.5 text-text-muted"}),o.jsx("span",{"data-testid":"date-display",children:new Date(d).toLocaleDateString([],{weekday:"short",month:"long",day:"numeric",year:"numeric"})}),o.jsx("span",{className:"text-text-muted",children:"\xB7"}),o.jsx("span",{"data-testid":"period-label",className:"text-text-muted text-xs tabular-nums",children:p})]})]}),o.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[o.jsxs("div",{className:"flex items-center bg-bg-surface-2/50 border border-border/50 rounded-xl p-1 shadow-inner",children:[Lc.map(e=>o.jsx("button",{"data-testid":\`scale-\${e}\`,onClick:()=>r(e),className:"px-3 py-1.5 text-[10px] font-bold uppercase tracking-wider rounded-lg transition-all "+(n===e?"bg-bg-surface-3 text-text-primary shadow-sm":"text-text-muted hover:text-text-primary hover:bg-bg-surface-2"),title:Vc[e],children:e},e)),o.jsx("div",{className:"w-px h-5 bg-border/50 mx-1"}),Dc.map(e=>{const t=n===e||zc[n]===e;return o.jsx("button",{"data-testid":\`scale-\${e}\`,onClick:()=>r(e),className:"px-3 py-1.5 text-[10px] font-bold uppercase tracking-wider rounded-lg transition-all "+(t?"bg-bg-surface-3 text-text-primary shadow-sm":"text-text-muted hover:text-text-primary hover:bg-bg-surface-2"),title:Vc[e],children:e},e)})]}),o.jsx("div",{className:"flex items-center gap-2",children:o.jsxs("div",{className:"flex items-center gap-1 bg-bg-surface-2/50 border border-border/50 rounded-xl p-1",children:[o.jsx("button",{onClick:()=>C(-1),className:"p-2 text-text-muted hover:text-text-primary hover:bg-bg-surface-2 rounded-lg transition-colors",title:E(-1),children:o.jsx(Nl,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>C(1),className:"p-2 text-text-muted hover:text-text-primary hover:bg-bg-surface-2 rounded-lg transition-colors disabled:opacity-20 disabled:cursor-not-allowed",title:E(1),disabled:i||d>=Date.now()-1e3,children:o.jsx(Tl,{className:"w-4 h-4"})})]})})]})]}),o.jsx(Du,{value:d,onChange:j,scale:n,window:l?f:void 0,sessions:a,milestones:void 0,showPublic:s})]})}function Fu({children:e}){return o.jsx("span",{className:"text-text-primary font-medium",children:e})}function Vu(e){return e.reduce((e,t)=>e+t.duration_seconds,0)/3600}function Iu(e,t){const n=e.filter(e=>null!=e.evaluation);if(n.length<2)return null;return n.reduce((e,n)=>e+n.evaluation[t],0)/n.length}function Ou(e,t,n,r,a,s){var i;const l=[],c=a-(s-a),u=a,d=function(e,t,n){return e.filter(e=>{const r=new Date(e.started_at).getTime();return r>=t&&r<=n})}(n,c,u),h=function(e,t,n){return e.filter(e=>{const r=new Date(e.created_at).getTime();return r>=t&&r<=n})}(r,c,u),f=Vu(e),p=Vu(d),m=Iu(e,"prompt_quality"),g=Iu(d,"prompt_quality");if(null!==m&&null!==g&&m>g+.3&&l.push({priority:10,node:o.jsxs("span",{children:["Your prompt quality improved from ",o.jsx(Fu,{children:g.toFixed(1)})," to"," ",o.jsx(Fu,{children:m.toFixed(1)})," \u2014 clearer prompts mean faster results."]})}),d.length>0&&e.length>0){const e=t.length/Math.max(f,.1),n=h.length/Math.max(p,.1);e>1.2*n&&t.length>=2&&l.push({priority:9,node:o.jsxs("span",{children:["You're shipping ",o.jsxs(Fu,{children:[Math.round(100*(e/n-1)),"% faster"]})," ","this period \u2014 great momentum."]})})}const y=t.filter(e=>"complex"===e.complexity).length,v=h.filter(e=>"complex"===e.complexity).length;y>v&&y>=2&&l.push({priority:8,node:o.jsxs("span",{children:[o.jsx(Fu,{children:y})," complex ",1===y?"task":"tasks"," this period vs"," ",o.jsx(Fu,{children:v})," before \u2014 you're taking on harder problems."]})});const x=e.filter(e=>null!=e.evaluation),b=x.filter(e=>"completed"===e.evaluation.task_outcome&&e.evaluation.iteration_count<=3);if(x.length>=3&&b.length>0){const e=Math.round(b.length/x.length*100);e>=50&&l.push({priority:7,node:o.jsxs("span",{children:[o.jsxs(Fu,{children:[e,"%"]})," of your sessions completed in 3 or fewer turns \u2014 efficient prompting."]})})}const w=function(e){if(0===e.length)return null;const t={};for(const a of e){const e=a.task_type||"coding";t[e]=(t[e]??0)+a.duration_seconds}const n=e.reduce((e,t)=>e+t.duration_seconds,0),r=Object.entries(t).sort((e,t)=>t[1]-e[1])[0];return r&&0!==n?{type:r[0],pct:Math.round(r[1]/n*100)}:null}(e);if(w&&w.pct>=60&&e.length>=2){const e={coding:"building",debugging:"debugging",testing:"testing",planning:"planning",reviewing:"reviewing",documenting:"documenting",refactoring:"refactoring",research:"researching",analysis:"analyzing"}[w.type]??w.type;l.push({priority:6,node:o.jsxs("span",{children:["Deep focus: ",o.jsxs(Fu,{children:[w.pct,"%"]})," of your time spent ",e,"."]})})}const k={};for(const o of e)o.client&&(k[i=o.client]??(k[i]=[])).push(o);const S=Object.entries(k).filter(([,e])=>e.length>=2);if(S.length>=2){const e=S.map(([e,n])=>{const r=Vu(n),a=new Set(n.map(e=>e.session_id)),s=t.filter(e=>a.has(e.session_id));return{name:e,rate:s.length/Math.max(r,.1),count:s.length}}).filter(e=>e.count>0);if(e.length>=2){e.sort((e,t)=>t.rate-e.rate);const t=e[0],n=gc[t.name]??t.name;l.push({priority:5,node:o.jsxs("span",{children:[o.jsx(Fu,{children:n})," is your most productive tool this period \u2014 ",t.count," ",1===t.count?"milestone":"milestones"," shipped."]})})}}const j=Iu(e,"context_provided");if(null!==j&&j<3.5&&l.push({priority:4,node:o.jsxs("span",{children:["Tip: Your context score averages ",o.jsxs(Fu,{children:[j.toFixed(1),"/5"]})," \u2014 try including specific files and error messages for faster results."]})}),x.length>=3){const e=x.filter(e=>"completed"===e.evaluation.task_outcome).length,t=Math.round(e/x.length*100);100===t?l.push({priority:3,node:o.jsxs("span",{children:[o.jsx(Fu,{children:"100%"})," completion rate \u2014 every task landed."]})}):t<70&&l.push({priority:4,node:o.jsxs("span",{children:[o.jsxs(Fu,{children:[t,"%"]})," completion rate \u2014 try breaking tasks into smaller, well-scoped pieces."]})})}return p>0&&f>1.5*p&&f>=1&&l.push({priority:2,node:o.jsxs("span",{children:[o.jsxs(Fu,{children:[Math.round(100*(f/p-1)),"% more"]})," AI-paired time this period \u2014 you're leaning in."]})}),0===e.length&&l.push({priority:1,node:o.jsx("span",{className:"text-text-muted",children:"No sessions in this window. Start coding with AI to see insights here."})}),l.sort((e,t)=>t.priority-e.priority)}function $u({sessions:e,milestones:t,windowStart:n,windowEnd:r,allSessions:a,allMilestones:s}){const i=h.useMemo(()=>{const i=Ou(e,t,a??e,s??t,n,r);return i[0]?.node??null},[e,t,a,s,n,r]);return i?o.jsx(pl.div,{initial:{opacity:0},animate:{opacity:1},className:"rounded-xl bg-bg-surface-1 border border-border/50 px-4 py-3",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(sc,{className:"w-4 h-4 text-accent flex-shrink-0 mt-0.5"}),o.jsx("p",{className:"text-sm text-text-secondary leading-relaxed",children:i})]})}):null}function Bu(e){return e>=5?"var(--color-text-muted)":e>=4?"#f59e0b":e>=3?"#f97316":"var(--color-error)"}function Uu({sessions:e}){const{scores:t,summaryLine:n}=h.useMemo(()=>{const t=e.filter(e=>null!=e.evaluation);if(0===t.length)return{scores:null,summaryLine:null};let n=0,r=0,a=0,s=0,i=0,o=0;for(const e of t){const t=e.evaluation;n+=t.prompt_quality,r+=t.context_provided,a+=t.independence_level,s+=t.scope_quality,o+=t.iteration_count,"completed"===t.task_outcome&&i++}const l=t.length,c=Math.round(i/l*100);return{scores:[{label:"Prompt Quality",value:n/l,max:5},{label:"Context",value:r/l,max:5},{label:"Independence",value:a/l,max:5},{label:"Scope",value:s/l,max:5},{label:"Completion",value:c/20,max:5}],summaryLine:\`\${l} session\${1===l?"":"s"} evaluated \xB7 \${c}% completed \xB7 avg \${(o/l).toFixed(1)} iterations\`}},[e]);return o.jsxs(pl.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},className:"rounded-xl bg-bg-surface-1 border border-border/50 p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx("div",{className:"p-1.5 rounded-lg bg-bg-surface-2",children:o.jsx(ic,{className:"w-3.5 h-3.5 text-text-muted"})}),o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest",children:"AI Proficiency"})]}),null===t?o.jsx("p",{className:"text-xs text-text-muted py-2",children:"No evaluation data yet"}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"space-y-3",children:t.map((e,t)=>{const n=e.value/e.max*100,r="Completion"===e.label?\`\${Math.round(n)}%\`:e.value>=5?"5/5":\`\${e.value.toFixed(1)}/5\`,a=e.value>=e.max;return o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-xs text-text-secondary font-medium w-28 text-right shrink-0",children:e.label}),o.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-bg-surface-2/50 overflow-hidden",children:o.jsx(pl.div,{className:"h-full rounded-full",style:{backgroundColor:Bu(e.value)},initial:{width:0},animate:{width:\`\${n}%\`},transition:{duration:.6,delay:.05*t,ease:[.22,1,.36,1]}})}),o.jsx("span",{className:"text-xs font-mono w-10 text-right shrink-0 "+(a?"text-text-muted":"font-bold"),style:a?void 0:{color:Bu(e.value)},children:r})]},e.label)})}),o.jsx("p",{className:"text-[10px] text-text-muted mt-4 px-1 font-mono",children:n})]})]})}var Hu=["Output","Efficiency","Prompts","Consistency","Breadth"];function Wu(e,t,n,r,a){const s=2*Math.PI*e/5-Math.PI/2;return[n+a*t*Math.cos(s),r+a*t*Math.sin(s)]}function qu(e,t,n,r){const a=[];for(let s=0;s<5;s++){const[i,o]=Wu(s,e,t,n,r);a.push(\`\${i},\${o}\`)}return a.join(" ")}function Yu({sessions:e,milestones:t,streak:n}){const{values:r,hasEvalData:a}=h.useMemo(()=>{const r={simple:1,medium:2,complex:4};let a=0;for(const e of t)a+=r[e.complexity]??1;const s=Math.min(1,a/10),i=e.reduce((e,t)=>e+t.files_touched,0),o=e.reduce((e,t)=>e+t.duration_seconds,0)/3600,l=Math.min(1,i/Math.max(o,1)/20),c=e.filter(e=>null!=e.evaluation);let u=0;const d=c.length>0;if(d){u=c.reduce((e,t)=>e+t.evaluation.prompt_quality,0)/c.length/5}const h=Math.min(1,n/14),f=new Set;for(const t of e)for(const e of t.languages)f.add(e);return{values:[s,l,u,h,Math.min(1,f.size/5)],hasEvalData:d}},[e,t,n]),s=100,i=100,l=[];for(let o=0;o<5;o++){const e=Math.max(r[o],.02),[t,n]=Wu(o,e,s,i,70);l.push(\`\${t},\${n}\`)}const c=l.join(" ");return o.jsxs(pl.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.15},className:"rounded-xl bg-bg-surface-1 border border-border/50 p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx("div",{className:"p-1.5 rounded-lg bg-bg-surface-2",children:o.jsx(xl,{className:"w-3.5 h-3.5 text-text-muted"})}),o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest",children:"Skill Profile"})]}),o.jsx("div",{className:"flex justify-center",children:o.jsxs("svg",{viewBox:"0 0 200 200",width:200,height:200,className:"overflow-visible",children:[[.33,.66,1].map(e=>o.jsx("polygon",{points:qu(e,s,i,70),fill:"none",stroke:"var(--color-bg-surface-3)",strokeWidth:.5,opacity:.6},e)),Array.from({length:5}).map((e,t)=>{const[n,r]=Wu(t,1,s,i,70);return o.jsx("line",{x1:s,y1:i,x2:n,y2:r,stroke:"var(--color-bg-surface-3)",strokeWidth:.5,opacity:.4},\`axis-\${t}\`)}),o.jsx(pl.polygon,{points:c,fill:"var(--color-accent)",fillOpacity:.2,stroke:"var(--color-accent)",strokeWidth:1.5,strokeLinejoin:"round",initial:{opacity:0,scale:.5},animate:{opacity:1,scale:1},transition:{duration:.6,ease:[.22,1,.36,1]},style:{transformOrigin:"100px 100px"}}),r.map((e,t)=>{const n=Math.max(e,.02),[r,l]=Wu(t,n,s,i,70),c=2===t&&!a;return o.jsx("circle",{cx:r,cy:l,r:2.5,fill:c?"var(--color-text-muted)":"var(--color-accent-bright)",opacity:c?.4:1},\`point-\${t}\`)}),Hu.map((e,t)=>{const n=function(e,t,n,r){const[a,s]=Wu(e,1.28,t,n,r);let i="middle";return 1!==e&&2!==e||(i="start"),3!==e&&4!==e||(i="end"),{x:a,y:s,anchor:i}}(t,s,i,70),r=2===t&&!a;return o.jsx("text",{x:n.x,y:n.y,textAnchor:n.anchor,dominantBaseline:"central",className:"text-[9px] font-medium",fill:r?"var(--color-text-muted)":"var(--color-text-secondary)",opacity:r?.5:1,children:e},e)})]})}),o.jsx("div",{className:"flex justify-center gap-3 mt-2 flex-wrap",children:Hu.map((e,t)=>{const n=2===t&&!a,s=Math.round(100*r[t]);return o.jsxs("span",{className:"text-[10px] font-mono "+(n?"text-text-muted/50":"text-text-muted"),children:[s,"%"]},e)})})]})}var Ku={coding:"#b4f82c",debugging:"#f87171",testing:"#60a5fa",planning:"#a78bfa",reviewing:"#34d399",documenting:"#fbbf24",learning:"#f472b6",deployment:"#fb923c",devops:"#e879f9",research:"#22d3ee",migration:"#facc15",design:"#c084fc",data:"#2dd4bf",security:"#f43f5e",configuration:"#a3e635",other:"#94a3b8"};function Xu(e){if(e<60)return"<1m";const t=Math.round(e/60);if(t<60)return\`\${t}m\`;return\`\${(e/3600).toFixed(1)}h\`}function Qu({byTaskType:e}){const t=Object.entries(e).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]);if(0===t.length)return null;const n=t[0][1];return o.jsxs("div",{className:"rounded-xl bg-bg-surface-1 border border-border/50 p-4 mb-8",children:[o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest mb-4 px-1",children:"Task Types"}),o.jsx("div",{className:"space-y-2.5",children:t.map(([e,t],r)=>{const a=Ku[e]??Ku.other,s=t/n*100;return o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-xs text-text-secondary font-medium w-24 text-right shrink-0",children:(i=e,i.charAt(0).toUpperCase()+i.slice(1))}),o.jsx("div",{className:"flex-1 h-5 rounded bg-bg-surface-2/50 overflow-hidden",children:o.jsx(pl.div,{className:"h-full rounded",style:{backgroundColor:a},initial:{width:0},animate:{width:\`\${s}%\`},transition:{duration:.6,delay:.05*r,ease:[.22,1,.36,1]}})}),o.jsx("span",{className:"text-xs text-text-muted font-mono w-12 text-right shrink-0",children:Xu(t)})]},e);var i})})]})}var Zu=["#b4f82c","#60a5fa","#f87171","#a78bfa","#fbbf24","#34d399","#f472b6","#22d3ee"];function Gu(e){if(e<60)return"<1m";const t=Math.round(e/60);if(t<60)return\`\${t}m\`;return\`\${(e/3600).toFixed(1)}h\`}function Ju({sessions:e,byProject:t}){const[n,r]=h.useState("user"),[a,s]=h.useState(!1),i=h.useMemo(()=>{const t=[];for(const o of e){if(!o.project)continue;const e=new Date(o.started_at).getTime(),n=new Date(o.ended_at).getTime();n<=e||(t.push({time:e,project:o.project,delta:1}),t.push({time:n,project:o.project,delta:-1}))}t.sort((e,t)=>e.time-t.time||e.delta-t.delta);const n={},r={};let a=0,s=0;for(const e of t){if(a>0&&e.time>s){const t=e.time-s,a=Object.keys(r).filter(e=>r[e]>0),i=a.length;if(i>0){const e=t/i;for(const t of a)n[t]=(n[t]??0)+e}}s=e.time,r[e.project]=(r[e.project]??0)+e.delta,0===r[e.project]&&delete r[e.project],a=Object.values(r).reduce((e,t)=>e+t,0)}const i={};for(const[e,o]of Object.entries(n))o>0&&(i[e]=o/1e3);return i},[e]),l="user"===n?i:t,c=h.useMemo(()=>function(e){const t=Object.entries(e).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]);if(0===t.length)return[];const n=t.reduce((e,[,t])=>e+t,0);let r,a=0;t.length<=6?r=t:(r=t.slice(0,6),a=t.slice(6).reduce((e,[,t])=>e+t,0));const s=r.map(([e,t],r)=>({name:e,seconds:t,color:Zu[r%Zu.length],percentage:t/n*100}));return a>0&&s.push({name:"Other",seconds:a,color:"#64748b",percentage:a/n*100}),s}(l),[l]);if(0===c.length)return null;const u=c.reduce((e,t)=>e+t.seconds,0),d=140,f=2*Math.PI*52;let p=0;const m=c.map(e=>{const t=e.percentage/100*f,n=f-t,r=.25*f-p;return p+=t,{...e,dashLength:t,gap:n,offset:r}}),g={user:"User Time",ai:"AI Time"};return o.jsxs(pl.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},className:"rounded-xl bg-bg-surface-1 border border-border/50 p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4 px-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"p-1.5 rounded-lg bg-bg-surface-2",children:o.jsx($l,{className:"w-3.5 h-3.5 text-text-muted"})}),o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest",children:"Project Allocation"})]}),o.jsxs("div",{className:"relative",children:[o.jsxs("button",{onClick:()=>s(e=>!e),className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-border/50 bg-bg-surface-2 text-[11px] text-text-secondary font-medium hover:border-text-muted/50 transition-colors",children:[g[n],o.jsx(Cl,{className:"w-3 h-3 text-text-muted"})]}),a&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),o.jsx("div",{className:"absolute right-0 top-full mt-1 z-20 min-w-[120px] rounded-lg border border-border/50 bg-bg-surface-1 shadow-lg py-1",children:Object.entries(g).map(([e,t])=>o.jsx("button",{onClick:()=>{r(e),s(!1)},className:"w-full text-left px-3 py-1.5 text-xs transition-colors "+(e===n?"text-accent bg-accent/10 font-medium":"text-text-secondary hover:bg-bg-surface-2"),children:t},e))})]})]})]}),o.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-6",children:[o.jsxs("div",{className:"relative shrink-0",style:{width:d,height:d},children:[o.jsxs("svg",{width:d,height:d,viewBox:"0 0 140 140",children:[o.jsx("circle",{cx:70,cy:70,r:52,fill:"none",stroke:"var(--color-bg-surface-2, #1e293b)",strokeWidth:18,opacity:.3}),m.map((e,t)=>o.jsx(pl.circle,{cx:70,cy:70,r:52,fill:"none",stroke:e.color,strokeWidth:18,strokeDasharray:\`\${e.dashLength} \${e.gap}\`,strokeDashoffset:e.offset,strokeLinecap:"butt",initial:{opacity:0},animate:{opacity:1},transition:{duration:.5,delay:.1+.08*t,ease:[.22,1,.36,1]}},\`\${n}-\${e.name}\`))]}),o.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[o.jsx("span",{className:"text-lg font-bold text-text-primary leading-none",children:c.length}),o.jsx("span",{className:"text-[10px] text-text-muted mt-0.5",children:1===c.length?"project":"projects"})]})]}),o.jsx("div",{className:"flex-1 min-w-0 space-y-1.5 w-full",children:c.map((e,t)=>o.jsxs(pl.div,{className:"flex items-center gap-2.5",initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{duration:.4,delay:.15+.06*t,ease:[.22,1,.36,1]},children:[o.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:e.color}}),o.jsx("span",{className:"text-xs text-text-secondary font-medium truncate flex-1 min-w-0",children:e.name}),o.jsx("span",{className:"text-[10px] text-text-muted font-mono shrink-0",children:Gu(e.seconds)}),o.jsxs("span",{className:"text-[10px] text-text-muted/70 font-mono w-10 text-right shrink-0",children:[e.percentage.toFixed(0),"%"]})]},e.name))})]}),o.jsx("div",{className:"mt-4 flex h-2 rounded-full overflow-hidden bg-bg-surface-2/30",children:c.map(e=>{const t=u>0?e.seconds/u*100:0;return 0===t?null:o.jsx(pl.div,{className:"h-full",style:{backgroundColor:e.color},initial:{width:0},animate:{width:\`\${t}%\`},transition:{duration:.8,ease:[.22,1,.36,1]}},e.name)})})]})}var ed={feature:"bg-success/10 text-success border-success/20",bugfix:"bg-error/10 text-error border-error/20",refactor:"bg-purple/10 text-purple border-purple/20",test:"bg-blue/10 text-blue border-blue/20",docs:"bg-accent/10 text-accent border-accent/20",setup:"bg-text-muted/10 text-text-muted border-text-muted/20",deployment:"bg-emerald/10 text-emerald border-emerald/20"};function td(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return\`\${n}m ago\`;const r=Math.floor(n/60);if(r<24)return\`\${r}h ago\`;const a=Math.floor(r/24);return 1===a?"yesterday":a<7?\`\${a}d ago\`:new Date(e).toLocaleDateString([],{month:"short",day:"numeric"})}function nd({milestones:e,showPublic:t=!1}){const n=[...e].sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime()).slice(0,8);return o.jsxs(pl.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,ease:[.22,1,.36,1]},className:"rounded-xl bg-bg-surface-1 border border-border/50 p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[o.jsx(uc,{className:"w-4 h-4 text-accent"}),o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest",children:"Recent Achievements"}),o.jsxs("span",{className:"text-[10px] text-text-muted font-mono bg-bg-surface-2 px-2 py-0.5 rounded ml-auto",children:[e.length," total"]})]}),0===n.length?o.jsx("div",{className:"text-sm text-text-muted text-center py-6",children:"No milestones yet \u2014 complete your first session!"}):o.jsx("div",{className:"space-y-0.5",children:n.map((e,n)=>{const r=bc[e.category]??"#9c9588",a=ed[e.category]??"bg-bg-surface-2 text-text-secondary border-border",s=yc[e.client]??e.client.slice(0,2).toUpperCase(),i=mc[e.client]??"#91919a",l=t?e.title:e.private_title||e.title,c="complex"===e.complexity;return o.jsxs(pl.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{duration:.25,delay:.04*n},className:"flex items-center gap-3 py-2 px-2 rounded-lg hover:bg-bg-surface-2/40 transition-colors",children:[o.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:r}}),o.jsx("span",{className:"text-sm font-medium text-text-secondary hover:text-text-primary truncate flex-1 min-w-0",children:l}),o.jsx("span",{className:\`text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded-full border flex-shrink-0 \${a}\`,children:e.category}),c&&o.jsxs("span",{className:"flex items-center gap-0.5 text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded-full border bg-purple/10 text-purple border-purple/20 flex-shrink-0",children:[o.jsx(xl,{className:"w-2.5 h-2.5"}),"complex"]}),o.jsx("span",{className:"text-[10px] text-text-muted font-mono flex-shrink-0",children:td(e.created_at)}),o.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center text-[8px] font-bold font-mono flex-shrink-0",style:{backgroundColor:\`\${i}15\`,color:i,border:\`1px solid \${i}20\`},children:s})]},e.id)})})]})}function rd(e){const t=e/3600;return t<1?\`\${Math.round(60*t)}m\`:\`\${t.toFixed(1)}h\`}function ad(e,t){return Object.entries(e).sort((e,t)=>t[1]-e[1]).slice(0,t)}function sd({label:e,children:t}){return o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-widest font-bold whitespace-nowrap",children:e}),o.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-1 no-scrollbar",children:t})]})}function id({stats:e}){const t=ad(e.byClient,4),n=ad(e.byLanguage,4);return 0===t.length&&0===n.length?null:o.jsxs("div",{className:"flex flex-col gap-4 mb-8 p-4 rounded-xl bg-bg-surface-1/30 border border-border/50",children:[t.length>0&&o.jsx(sd,{label:"Top Clients",children:t.map(([e,t])=>{const n=mc[e];return o.jsxs("span",{className:"text-[11px] font-mono px-2.5 py-1 rounded-full bg-bg-surface-1 border border-border hover:border-accent/40 transition-colors shadow-sm whitespace-nowrap group cursor-default",style:n?{borderLeftWidth:"3px",borderLeftColor:n}:void 0,title:rd(t),children:[gc[e]??e,o.jsx("span",{className:"ml-1.5 text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:rd(t)})]},e)})}),n.length>0&&o.jsx(sd,{label:"Languages",children:n.map(([e,t])=>o.jsxs("span",{className:"text-[11px] font-mono px-2.5 py-1 rounded-full bg-bg-surface-1 border border-border hover:border-accent/40 transition-colors shadow-sm whitespace-nowrap group cursor-default",title:rd(t),children:[e,o.jsx("span",{className:"ml-1.5 text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:rd(t)})]},e))})]})}function od(e,t,n){try{const n="undefined"!=typeof window?localStorage.getItem(e):null;if(n&&t.includes(n))return n}catch{}return n}function ld(e,t){try{localStorage.setItem(e,t)}catch{}}function cd({sessions:e,milestones:t,onDeleteSession:n,onDeleteConversation:r,onDeleteMilestone:a,defaultTimeScale:s="day",activeTab:i,onActiveTabChange:l}){const[c,u]=h.useState(null),[d,f]=h.useState(()=>od("useai-time-scale",Ac,s)),[p,m]=h.useState({category:"all",client:"all",project:"all",language:"all"}),[g,y]=h.useState(()=>od("useai-active-tab",["sessions","insights"],"sessions")),[v,x]=h.useState(null),[b,w]=h.useState(!1),[k,S]=h.useState(!1),j=void 0!==i,C=i??g,N=h.useCallback(e=>{l?l(e):(ld("useai-active-tab",e),y(e))},[l]),T=h.useCallback(e=>{ld("useai-time-scale",e),f(e)},[]),E=h.useCallback((e,t)=>{m(n=>({...n,[e]:t}))},[]);h.useEffect(()=>{if(null===c){const e=zc[d];e&&T(e)}},[c,d,T]);const M=null===c,P=c??Date.now(),{start:L,end:D}=Ic(d,P),A=h.useMemo(()=>function(e,t,n){return e.filter(e=>{const r=Cc(e.started_at),a=Cc(e.ended_at);return r<=n&&a>=t})}(e,L,D),[e,L,D]),_=h.useMemo(()=>function(e,t,n){return e.filter(e=>{const r=Cc(e.created_at);return r>=t&&r<=n})}(t,L,D),[t,L,D]),z=h.useMemo(()=>function(e,t=[]){let n=0,r=0;const a={},s={},i={},o={};for(const y of e){n+=y.duration_seconds,r+=y.files_touched,a[y.client]=(a[y.client]??0)+y.duration_seconds;for(const e of y.languages)s[e]=(s[e]??0)+y.duration_seconds;i[y.task_type]=(i[y.task_type]??0)+y.duration_seconds,y.project&&(o[y.project]=(o[y.project]??0)+y.duration_seconds)}let l=0,c=0,u=0,d=0;if(e.length>0){let t=1/0,r=-1/0;const a=[];for(const n of e){const e=Cc(n.started_at),s=Cc(n.ended_at);e<t&&(t=e),s>r&&(r=s),a.push({time:e,delta:1}),a.push({time:s,delta:-1})}l=(r-t)/36e5,a.sort((e,t)=>e.time-t.time||e.delta-t.delta);let s=0,i=0,o=0;for(const e of a){const t=s>0;s+=e.delta,s>d&&(d=s),!t&&s>0?o=e.time:t&&0===s&&(i+=e.time-o)}c=i/36e5,u=c>0?n/3600/c:0}const h=function(e){let t=0,n=0,r=0;for(const a of e)"feature"===a.category&&t++,"bugfix"===a.category&&n++,"complex"===a.complexity&&r++;return{featuresShipped:t,bugsFixed:n,complexSolved:r}}(t),f=e.filter(e=>e.evaluation&&"object"==typeof e.evaluation),p=f.filter(e=>"completed"===e.evaluation.task_outcome).length,m=f.length>0?Math.round(p/f.length*100):0,g=Object.keys(o).length;return{totalHours:n/3600,totalSessions:e.length,actualSpanHours:l,coveredHours:c,aiMultiplier:u,peakConcurrency:d,currentStreak:Nc(e),filesTouched:Math.round(r),...h,totalMilestones:t.length,completionRate:m,activeProjects:g,byClient:a,byLanguage:s,byTaskType:i,byProject:o}}(A,_),[A,_]),R=h.useMemo(()=>Nc(e),[e]),F=h.useMemo(()=>{const t=function(e,t,n){let r=0,a=0;for(const s of e){const e=Cc(s.ended_at),i=Cc(s.started_at);e<t?r++:i>n&&a++}return{before:r,after:a}}(e,L,D);if(M&&0===t.before)return;const n=Vc[d],r=e=>new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}),a=Rc(d)||D-L>=864e5?e=>\`\${new Date(e).toLocaleDateString([],{month:"short",day:"numeric"})} \${r(e)}\`:r,s=Oc(d,P,-1),i=Ic(d,s),o=\`View prev \${n} \xB7 \${a(i.start)} \u2013 \${a(i.end)}\`;if(M)return{before:t.before,after:0,olderLabel:o};const l=Oc(d,P,1),c=Ic(d,l);return{...t,newerLabel:\`View next \${n} \xB7 \${a(c.start)} \u2013 \${a(c.end)}\`,olderLabel:o}},[e,L,D,P,M,d]),V=h.useCallback(()=>{const e=Oc(d,P,1);$c(d,e)?u(null):u(e)},[P,d]),I=h.useCallback(()=>{const e=Oc(d,P,-1);u(e)},[P,d]),O=h.useMemo(()=>{if(!M)return new Date(P).toISOString().slice(0,10)},[M,P]),$=h.useMemo(()=>{let e=0,t=0,n=0;for(const r of _)"simple"===r.complexity?e++:"medium"===r.complexity?t++:"complex"===r.complexity&&n++;return{simple:e,medium:t,complex:n}},[_]),B=h.useCallback(e=>{const t=new Date(\`\${e}T12:00:00\`).getTime();u(t),T("day")},[T]),U="all"!==p.client||"all"!==p.language||"all"!==p.project;return o.jsxs("div",{className:"space-y-3",children:[o.jsx(Ru,{value:c,onChange:u,scale:d,onScaleChange:T,sessions:e,milestones:t,showPublic:b}),o.jsx(Uc,{totalHours:z.totalHours,totalSessions:z.totalSessions,actualSpanHours:z.actualSpanHours,coveredHours:z.coveredHours,aiMultiplier:z.aiMultiplier,peakConcurrency:z.peakConcurrency,currentStreak:R,filesTouched:z.filesTouched,featuresShipped:z.featuresShipped,bugsFixed:z.bugsFixed,complexSolved:z.complexSolved,totalMilestones:z.totalMilestones,completionRate:z.completionRate,activeProjects:z.activeProjects,selectedCard:v,onCardClick:x}),o.jsx(Yc,{type:v,milestones:_,showPublic:b,onClose:()=>x(null)}),o.jsx(tu,{type:v,sessions:A,allSessions:e,currentStreak:R,stats:{totalHours:z.totalHours,coveredHours:z.coveredHours,aiMultiplier:z.aiMultiplier,peakConcurrency:z.peakConcurrency},showPublic:b,onClose:()=>x(null)}),!j&&o.jsx(cu,{activeTab:C,onTabChange:N}),"sessions"===C&&o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between px-1 pt-0.5",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest",children:"Activity Feed"}),o.jsxs("span",{className:"text-[10px] text-text-muted font-mono bg-bg-surface-2 px-2 py-0.5 rounded",children:[A.length," Sessions"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("button",{onClick:()=>w(e=>!e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border transition-all duration-200 "+(b?"bg-success/10 border-success/30 text-success":"bg-bg-surface-1 border-border/50 text-text-muted hover:text-text-primary hover:border-text-muted/50"),title:b?"Showing public titles":"Showing private titles","aria-label":b?"Switch to private titles":"Switch to public titles",children:[b?o.jsx(Fl,{className:"w-3.5 h-3.5"}):o.jsx(Rl,{className:"w-3.5 h-3.5"}),o.jsx("span",{className:"hidden sm:inline text-xs font-medium",children:b?"Public":"Private"})]}),o.jsxs("button",{onClick:()=>S(e=>!e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border transition-all duration-200 "+(k||U?"bg-accent/10 border-accent/30 text-accent":"bg-bg-surface-1 border-border/50 text-text-muted hover:text-text-primary hover:border-text-muted/50"),title:k?"Hide filters":"Show filters","aria-label":k?"Hide filters":"Show filters",children:[o.jsx(Il,{className:"w-3.5 h-3.5"}),o.jsx("span",{className:"hidden sm:inline text-xs font-medium",children:"Filters"})]})]})]}),k&&o.jsx(du,{sessions:A,filters:p,onFilterChange:E}),o.jsx(Tu,{sessions:A,milestones:_,filters:p,globalShowPublic:b,showFullDate:"week"===d||"7d"===d||"month"===d||"30d"===d,outsideWindowCounts:F,onNavigateNewer:V,onNavigateOlder:I,onDeleteSession:n,onDeleteConversation:r,onDeleteMilestone:a})]}),"insights"===C&&o.jsxs("div",{className:"space-y-4 pt-2",children:[o.jsx($u,{sessions:A,milestones:_,isLive:M,windowStart:L,windowEnd:D,allSessions:e,allMilestones:t}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsx(Uu,{sessions:A}),o.jsx(Yu,{sessions:A,milestones:_,streak:R})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsx(Pc,{data:$}),o.jsx(Ju,{sessions:A,byProject:z.byProject})]}),o.jsx(Qu,{byTaskType:z.byTaskType}),o.jsx(Ec,{sessions:e,timeScale:d,effectiveTime:P,isLive:M,onDayClick:B,highlightDate:O}),o.jsx(nd,{milestones:_,showPublic:b}),o.jsx(id,{stats:z})]})]})}function ud({className:e}){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 611.54 143.47",className:e,children:[o.jsxs("g",{fill:"var(--text-primary)",children:[o.jsx("path",{d:"M21.4,121.85c-4.57-4.57-6.85-10.02-6.85-16.37V17.23c0-3.1,1.55-4.65,4.64-4.65h25.55c3.1,0,4.65,1.55,4.65,4.65v76.64c0,3.25,1.12,6,3.37,8.25,2.24,2.25,4.99,3.37,8.25,3.37h27.87c3.25,0,6-1.12,8.25-3.37,2.24-2.24,3.37-4.99,3.37-8.25V17.23c0-3.1,1.55-4.65,4.64-4.65h25.55c3.1,0,4.65,1.55,4.65,4.65v88.25c0,6.35-2.29,11.81-6.85,16.37-4.57,4.57-10.03,6.85-16.37,6.85H37.78c-6.35,0-11.81-2.28-16.37-6.85Z"}),o.jsx("path",{d:"M146.93,124.06v-13.93c0-3.1,1.55-4.65,4.64-4.65h69.67c3.25,0,6-1.12,8.25-3.37,2.24-2.24,3.37-4.99,3.37-8.25s-1.12-6-3.37-8.25c-2.25-2.24-4.99-3.37-8.25-3.37h-51.09c-6.35,0-11.81-2.28-16.37-6.85-4.57-4.57-6.85-10.02-6.85-16.37v-23.22c0-6.35,2.28-11.81,6.85-16.37,4.56-4.57,10.02-6.85,16.37-6.85h92.9c3.1,0,4.65,1.55,4.65,4.65v13.94c0,3.1-1.55,4.65-4.65,4.65h-69.67c-3.25,0-6,1.12-8.25,3.37-2.25,2.25-3.37,4.99-3.37,8.25s1.12,6,3.37,8.25c2.24,2.25,4.99,3.37,8.25,3.37h51.09c6.35,0,11.8,2.29,16.37,6.85,4.57,4.57,6.85,10.03,6.85,16.37v23.22c0,6.35-2.29,11.81-6.85,16.37-4.57,4.57-10.03,6.85-16.37,6.85h-92.9c-3.1,0-4.64-1.55-4.64-4.65Z"}),o.jsx("path",{d:"M286.16,121.85c-4.57-4.57-6.85-10.02-6.85-16.37V35.81c0-6.35,2.28-11.81,6.85-16.37,4.56-4.57,10.02-6.85,16.37-6.85h74.32c6.35,0,11.8,2.29,16.37,6.85,4.57,4.57,6.85,10.03,6.85,16.37v23.22c0,6.35-2.29,11.81-6.85,16.37-4.57,4.57-10.03,6.85-16.37,6.85h-62.71v11.61c0,3.25,1.12,6,3.37,8.25,2.24,2.25,4.99,3.37,8.25,3.37h69.67c3.1,0,4.65,1.55,4.65,4.65v13.93c0,3.1-1.55,4.65-4.65,4.65h-92.9c-6.35,0-11.81-2.28-16.37-6.85ZM361.87,55.66c2.24-2.24,3.37-4.99,3.37-8.25s-1.12-6-3.37-8.25c-2.25-2.24-4.99-3.37-8.25-3.37h-27.87c-3.25,0-6,1.12-8.25,3.37-2.25,2.25-3.37,4.99-3.37,8.25v11.61h39.48c3.25,0,6-1.12,8.25-3.37Z"})]}),o.jsxs("g",{fill:"var(--accent)",children:[o.jsx("path",{d:"M432.08,126.44c-4.76-4.76-7.14-10.44-7.14-17.06v-24.2c0-6.61,2.38-12.3,7.14-17.06,4.76-4.76,10.44-7.14,17.06-7.14h65.34v-12.1c0-3.39-1.17-6.25-3.51-8.59-2.34-2.34-5.2-3.51-8.59-3.51h-72.6c-3.23,0-4.84-1.61-4.84-4.84v-14.52c0-3.23,1.61-4.84,4.84-4.84h96.8c6.61,0,12.3,2.38,17.06,7.14,4.76,4.76,7.14,10.45,7.14,17.06v72.6c0,6.62-2.38,12.3-7.14,17.06-4.76,4.76-10.45,7.14-17.06,7.14h-77.44c-6.62,0-12.3-2.38-17.06-7.14ZM510.97,105.87c2.34-2.34,3.51-5.2,3.51-8.59v-12.1h-41.14c-3.39,0-6.25,1.17-8.59,3.51-2.34,2.34-3.51,5.2-3.51,8.59s1.17,6.25,3.51,8.59c2.34,2.34,5.2,3.51,8.59,3.51h29.04c3.39,0,6.25-1.17,8.59-3.51Z"}),o.jsx("path",{d:"M562.87,128.74V17.42c0-3.23,1.61-4.84,4.84-4.84h26.62c3.23,0,4.84,1.61,4.84,4.84v111.32c0,3.23-1.61,4.84-4.84,4.84h-26.62c-3.23,0-4.84-1.61-4.84-4.84Z"})]})]})}var dd={category:"all",client:"all",project:"all",language:"all"};function hd({open:e,onClose:t,sessions:n,milestones:r,onDeleteSession:a,onDeleteConversation:s,onDeleteMilestone:i}){const[l,c]=h.useState(""),[u,d]=h.useState(""),[f,p]=h.useState(!1),m=h.useRef(null);h.useEffect(()=>{e&&(c(""),d(""),requestAnimationFrame(()=>m.current?.focus()))},[e]),h.useEffect(()=>{if(!e)return;const t=document.documentElement;return t.style.overflow="hidden",document.body.style.overflow="hidden",()=>{t.style.overflow="",document.body.style.overflow=""}},[e]),h.useEffect(()=>{if(!e)return;const n=e=>{"Escape"===e.key&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t]),h.useEffect(()=>{const e=setTimeout(()=>d(l),250);return()=>clearTimeout(e)},[l]);const g=h.useMemo(()=>{const e=new Map;for(const t of r){const n=e.get(t.session_id);n?n.push(t):e.set(t.session_id,[t])}return e},[r]),{filteredSessions:y,filteredMilestones:v,highlightWords:x}=h.useMemo(()=>{const e=u.trim().toLowerCase();if(!e)return{filteredSessions:[],filteredMilestones:[],highlightWords:[]};const t=e.split(/\\s+/),a=n.filter(e=>function(e,t,n,r){const a=(r?[e.title,e.client,e.task_type,...e.languages,...t.map(e=>e.title)]:[e.private_title,e.title,e.client,e.task_type,...e.languages,...t.map(e=>e.private_title),...t.map(e=>e.title)]).filter(Boolean).join(" ").toLowerCase();return n.every(e=>a.includes(e))}(e,g.get(e.session_id)??[],t,f)),s=new Set(a.map(e=>e.session_id));return{filteredSessions:a,filteredMilestones:r.filter(e=>s.has(e.session_id)),highlightWords:t}},[n,r,g,u,f]),b=u.trim().length>0;return o.jsx(Qi,{children:e&&o.jsxs(o.Fragment,{children:[o.jsx(pl.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"fixed inset-0 bg-black/40 backdrop-blur-sm z-[60]",onClick:t}),o.jsx(pl.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15},className:"fixed inset-0 z-[61] flex items-start justify-center pt-[10vh] px-4 pointer-events-none",children:o.jsxs("div",{className:"w-full max-w-2xl bg-bg-base border border-border/50 rounded-xl shadow-2xl flex flex-col max-h-[75vh] pointer-events-auto",onClick:e=>e.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/50",children:[o.jsx(nc,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),o.jsx("input",{ref:m,type:"text",value:l,onChange:e=>c(e.target.value),placeholder:f?"Search public titles...":"Search all sessions and milestones...",className:"flex-1 bg-transparent text-sm text-text-primary placeholder:text-text-muted/50 outline-none"}),l&&o.jsx("button",{onClick:()=>{c(""),m.current?.focus()},className:"p-1 rounded-md hover:bg-bg-surface-2 text-text-muted hover:text-text-primary transition-colors",children:o.jsx(fc,{className:"w-3.5 h-3.5"})}),o.jsx("button",{onClick:()=>p(e=>!e),className:"p-1.5 rounded-md border transition-all duration-200 flex-shrink-0 "+(f?"bg-success/10 border-success/30 text-success":"bg-bg-surface-1 border-border/50 text-text-muted hover:text-text-primary hover:border-text-muted/50"),title:f?"Searching public titles":"Searching private titles",children:f?o.jsx(Fl,{className:"w-3.5 h-3.5"}):o.jsx(Rl,{className:"w-3.5 h-3.5"})}),o.jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded border border-border bg-bg-surface-1 text-[10px] font-mono text-text-muted",children:"esc"})]}),o.jsx("div",{className:"flex-1 overflow-y-auto overscroll-none px-4 py-3",children:b?0===y.length?o.jsxs("div",{className:"text-center py-12 text-sm text-text-muted/60",children:["No results for \u201C",u.trim(),"\u201D"]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"text-[10px] font-mono text-text-muted uppercase tracking-wider mb-3 px-1",children:[y.length," result",1!==y.length?"s":""]}),o.jsx(Tu,{sessions:y,milestones:v,filters:dd,globalShowPublic:f||void 0,showFullDate:!0,highlightWords:x,onDeleteSession:a,onDeleteConversation:s,onDeleteMilestone:i})]}):o.jsx("div",{className:"text-center py-12 text-sm text-text-muted/60",children:"Type to search across all sessions"})})]})})]})})}const fd=(pd=(e,t)=>({sessions:[],milestones:[],config:null,health:null,updateInfo:null,loading:!0,timeTravelTime:null,timeScale:(()=>{try{const e=localStorage.getItem("useai-time-scale"),t=[...Ac];if(e&&t.includes(e))return e}catch{}return"day"})(),filters:{category:"all",client:"all",project:"all",language:"all"},activeTab:(()=>{try{const e=localStorage.getItem("useai-active-tab");if("sessions"===e||"insights"===e||"settings"===e)return e}catch{}return"sessions"})(),loadAll:async()=>{try{const[t,n,r]=await Promise.all([_("/api/local/sessions"),_("/api/local/milestones"),V()]);e({sessions:t,milestones:n,config:r,loading:!1})}catch{e({loading:!1})}},loadHealth:async()=>{try{const t=await _("/health");e({health:t})}catch{}},loadUpdateCheck:async()=>{try{const t=await _("/api/local/update-check");e({updateInfo:t})}catch{}},setTimeTravelTime:t=>e({timeTravelTime:t}),setTimeScale:t=>{try{localStorage.setItem("useai-time-scale",t)}catch{}e({timeScale:t})},setFilter:(t,n)=>e(e=>({filters:{...e.filters,[t]:n}})),setActiveTab:t=>{try{localStorage.setItem("useai-active-tab",t)}catch{}e({activeTab:t})},deleteSession:async n=>{const r={sessions:t().sessions,milestones:t().milestones};e({sessions:r.sessions.filter(e=>e.session_id!==n),milestones:r.milestones.filter(e=>e.session_id!==n)});try{await function(e){return F(\`/api/local/sessions/\${encodeURIComponent(e)}\`)}(n)}catch{e(r)}},deleteConversation:async n=>{const r={sessions:t().sessions,milestones:t().milestones},a=new Set(r.sessions.filter(e=>e.conversation_id===n).map(e=>e.session_id));e({sessions:r.sessions.filter(e=>e.conversation_id!==n),milestones:r.milestones.filter(e=>!a.has(e.session_id))});try{await function(e){return F(\`/api/local/conversations/\${encodeURIComponent(e)}\`)}(n)}catch{e(r)}},deleteMilestone:async n=>{const r={milestones:t().milestones};e({milestones:r.milestones.filter(e=>e.id!==n)});try{await function(e){return F(\`/api/local/milestones/\${encodeURIComponent(e)}\`)}(n)}catch{e(r)}}}))?A(pd):A;var pd;const md=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;function gd(e){if(!e)return"Never synced";const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"Just now";if(n<60)return\`\${n}m ago\`;const r=Math.floor(n/60);if(r<24)return\`\${r}h ago\`;return\`\${Math.floor(r/24)}d ago\`}function yd({config:e,onRefresh:t}){const n=!!e.username,[r,a]=h.useState(!n),[s,i]=h.useState(e.username??""),[l,c]=h.useState("idle"),[u,d]=h.useState(),[f,p]=h.useState(!1),m=h.useRef(void 0),g=h.useRef(void 0);h.useEffect(()=>{e.username&&(a(!1),i(e.username))},[e.username]);const y=h.useCallback(t=>{const n=function(e){return e.toLowerCase().replace(/[^a-z0-9-]/g,"")}(t);if(i(n),d(void 0),m.current&&clearTimeout(m.current),g.current&&g.current.abort(),!n)return void c("idle");const r=function(e){return 0===e.length?{valid:!1}:e.length<3?{valid:!1,reason:"At least 3 characters"}:e.length>32?{valid:!1,reason:"At most 32 characters"}:md.test(e)?{valid:!0}:{valid:!1,reason:"No leading/trailing hyphens"}}(n);if(!r.valid)return c("invalid"),void d(r.reason);n!==e.username?(c("checking"),m.current=setTimeout(async()=>{g.current=new AbortController;try{const e=await async function(e){return _(\`/api/local/users/check-username/\${encodeURIComponent(e)}\`)}(n);e.available?(c("available"),d(void 0)):(c("taken"),d(e.reason))}catch{c("invalid"),d("Check failed")}},400)):c("idle")},[e.username]),v=h.useCallback(async()=>{if("available"===l){p(!0);try{await async function(e){return R("/api/local/users/me",{username:e})}(s),t()}catch(e){c("invalid"),d(e.message)}finally{p(!1)}}},[s,l,t]),x=h.useCallback(()=>{a(!1),i(e.username??""),c("idle"),d(void 0)},[e.username]),b=h.useCallback(()=>{a(!0),i(e.username??""),c("idle"),d(void 0)},[e.username]);return!r&&n?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Hl,{className:"w-3.5 h-3.5 text-text-muted"}),o.jsxs("a",{href:\`https://useai.dev/\${e.username}\`,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-bold text-accent hover:text-accent-bright transition-colors",children:["useai.dev/",e.username]}),o.jsx("button",{onClick:b,className:"p-1 rounded hover:bg-bg-surface-2 text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Edit username",children:o.jsx(Zl,{className:"w-3 h-3"})})]}):o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-text-muted whitespace-nowrap",children:"useai.dev/"}),o.jsx("div",{className:"flex items-center bg-bg-base border border-border rounded-lg overflow-hidden focus-within:border-accent/50 transition-all",children:o.jsx("input",{type:"text",placeholder:"username",value:s,onChange:e=>y(e.target.value),onKeyDown:e=>"Enter"===e.key&&v(),autoFocus:r,maxLength:32,className:"px-2 py-1.5 text-xs bg-transparent text-text-primary outline-none w-28 placeholder:text-text-muted/50"})}),o.jsxs("div",{className:"w-4 h-4 flex items-center justify-center",children:["checking"===l&&o.jsx(Wl,{className:"w-3.5 h-3.5 text-text-muted animate-spin"}),"available"===l&&o.jsx(jl,{className:"w-3.5 h-3.5 text-success"}),("taken"===l||"invalid"===l)&&s.length>0&&o.jsx(fc,{className:"w-3.5 h-3.5 text-error"})]}),o.jsx("button",{onClick:v,disabled:"available"!==l||f,className:"px-3 py-1.5 bg-accent hover:bg-accent-bright text-bg-base text-[10px] font-bold uppercase tracking-wider rounded-lg transition-colors disabled:opacity-30 cursor-pointer",children:f?"...":n?"Save":"Claim"}),n&&o.jsx("button",{onClick:x,className:"px-2 py-1.5 text-[10px] font-bold uppercase tracking-wider text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"Cancel"}),u&&o.jsx("span",{className:"text-[10px] text-error/80 truncate max-w-[140px]",title:u,children:u})]})}const vd=h.forwardRef(function({config:e,onRefresh:t},n){const[r,a]=h.useState(!1),[s,i]=h.useState(""),[l,c]=h.useState(""),[u,d]=h.useState("email"),[f,p]=h.useState(!1),[m,g]=h.useState(null),y=h.useRef(null);h.useImperativeHandle(n,()=>({open:()=>a(!0)})),h.useEffect(()=>{if(!r)return;const e=e=>{y.current&&!y.current.contains(e.target)&&a(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]),h.useEffect(()=>{if(!r)return;const e=e=>{"Escape"===e.key&&a(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r]);const v=h.useCallback(async()=>{if(s.includes("@")){p(!0),g(null);try{await function(e){return z("/api/local/auth/send-otp",{email:e})}(s),d("otp")}catch(e){g(e.message)}finally{p(!1)}}},[s]),x=h.useCallback(async()=>{if(/^\\d{6}$/.test(l)){p(!0),g(null);try{await async function(e,t){return z("/api/local/auth/verify-otp",{email:e,code:t})}(s,l),t(),a(!1)}catch(e){g(e.message)}finally{p(!1)}}},[s,l,t]),b=h.useCallback(async()=>{p(!0),g(null);try{const e=await async function(){return z("/api/local/sync")}();e.success?(g("Synced!"),t(),setTimeout(()=>g(null),3e3)):g(e.error??"Sync failed")}catch(e){g(e.message)}finally{p(!1)}},[t]),w=h.useCallback(async()=>{await async function(){return z("/api/local/auth/logout")}(),t(),a(!1)},[t]);if(!e)return null;const k=e.authenticated;return o.jsxs("div",{className:"relative",ref:y,children:[k?o.jsxs("button",{onClick:()=>a(e=>!e),className:"flex items-center gap-1.5 rounded-full transition-colors cursor-pointer hover:opacity-80",children:[o.jsxs("div",{className:"relative w-7 h-7 rounded-full bg-accent/15 border border-accent/30 flex items-center justify-center",children:[o.jsx("span",{className:"text-xs font-bold text-accent leading-none",children:(e.email?.[0]??"?").toUpperCase()}),o.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full border-2 border-bg-base "+(e.last_sync_at?"bg-success":"bg-warning")})]}),o.jsx(Cl,{className:"w-3 h-3 text-text-muted transition-transform "+(r?"rotate-180":"")})]}):o.jsxs("button",{onClick:()=>a(e=>!e),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-accent hover:bg-accent-bright text-bg-base text-xs font-bold tracking-wide transition-colors cursor-pointer",children:[o.jsx(dc,{className:"w-3 h-3"}),"Sign in"]}),r&&o.jsx("div",{className:"absolute right-0 top-full mt-2 z-50 w-80 rounded-lg bg-bg-surface-1 border border-border shadow-lg",children:k?o.jsxs("div",{children:[o.jsx("div",{className:"px-4 pt-3 pb-2",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-accent/10 flex items-center justify-center border border-accent/20 shrink-0",children:o.jsx("span",{className:"text-sm font-bold text-accent",children:(e.email?.[0]??"?").toUpperCase()})}),o.jsx("div",{className:"flex flex-col min-w-0",children:o.jsx("span",{className:"text-xs font-bold text-text-primary truncate",children:e.email})})]})}),o.jsx("div",{className:"px-4 py-2 border-t border-border/50",children:o.jsx(yd,{config:e,onRefresh:t})}),o.jsx("div",{className:"px-4 py-2 border-t border-border/50",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("span",{className:"text-[10px] text-text-muted font-mono uppercase tracking-tighter",children:["Last sync: ",gd(e.last_sync_at)]}),o.jsxs("div",{className:"flex items-center gap-2",children:[m&&o.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest "+("Synced!"===m?"text-success":"text-error"),children:m}),o.jsxs("button",{onClick:b,disabled:f,className:"flex items-center gap-1.5 px-2.5 py-1 bg-accent hover:bg-accent-bright text-bg-base text-[10px] font-bold uppercase tracking-wider rounded-md transition-colors disabled:opacity-50 cursor-pointer",children:[o.jsx(Gl,{className:"w-3 h-3 "+(f?"animate-spin":"")}),f?"...":"Sync"]})]})]})}),o.jsx("div",{className:"px-4 py-2 border-t border-border/50",children:o.jsxs("button",{onClick:w,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-xs text-text-muted hover:text-error hover:bg-error/10 transition-colors cursor-pointer",children:[o.jsx(Yl,{className:"w-3.5 h-3.5"}),"Sign out"]})})]}):o.jsxs("div",{className:"p-4",children:[o.jsx("p",{className:"text-xs font-bold text-text-secondary uppercase tracking-widest mb-3",children:"Sign in to sync"}),m&&o.jsx("p",{className:"text-[10px] font-bold text-error uppercase tracking-widest mb-2",children:m}),"email"===u?o.jsxs("div",{className:"flex items-center bg-bg-base border border-border rounded-lg overflow-hidden focus-within:border-accent/50 focus-within:ring-1 focus-within:ring-accent/50 transition-all",children:[o.jsx("div",{className:"pl-3 py-2",children:o.jsx(Kl,{className:"w-3.5 h-3.5 text-text-muted"})}),o.jsx("input",{type:"email",placeholder:"you@email.com",value:s,onChange:e=>i(e.target.value),onKeyDown:e=>"Enter"===e.key&&v(),autoFocus:!0,className:"px-3 py-2 text-xs bg-transparent text-text-primary outline-none flex-1 placeholder:text-text-muted/50"}),o.jsx("button",{onClick:v,disabled:f||!s.includes("@"),className:"px-4 py-2 bg-bg-surface-2 hover:bg-bg-surface-3 text-text-primary text-[10px] font-bold uppercase tracking-wider transition-colors disabled:opacity-50 cursor-pointer border-l border-border",children:f?"...":"Send"})]}):o.jsxs("div",{className:"flex items-center bg-bg-base border border-border rounded-lg overflow-hidden focus-within:border-accent/50 focus-within:ring-1 focus-within:ring-accent/50 transition-all",children:[o.jsx("input",{type:"text",maxLength:6,placeholder:"000000",inputMode:"numeric",autoComplete:"one-time-code",value:l,onChange:e=>c(e.target.value),onKeyDown:e=>"Enter"===e.key&&x(),autoFocus:!0,className:"px-4 py-2 text-xs bg-transparent text-text-primary text-center font-mono tracking-widest outline-none flex-1 placeholder:text-text-muted/50"}),o.jsx("button",{onClick:x,disabled:f||6!==l.length,className:"px-4 py-2 bg-accent hover:bg-accent-bright text-bg-base text-[10px] font-bold uppercase tracking-wider transition-colors disabled:opacity-50 cursor-pointer",children:f?"...":"Verify"})]})]})})]})}),xd="npx -y @devness/useai update";function bd({updateInfo:e}){const[t,n]=h.useState(!1),[r,a]=h.useState(!1);return o.jsxs("div",{className:"relative",children:[o.jsxs("button",{onClick:()=>n(e=>!e),className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-accent/10 border border-accent/20 text-xs font-medium text-accent hover:bg-accent/15 transition-colors",children:[o.jsx(Ml,{className:"w-3 h-3"}),"v",e.latest," available"]}),t&&o.jsxs("div",{className:"absolute right-0 top-full mt-2 z-50 w-72 rounded-lg bg-bg-surface-1 border border-border shadow-lg p-3 space-y-2",children:[o.jsxs("p",{className:"text-xs text-text-muted",children:["Update from ",o.jsxs("span",{className:"font-mono text-text-secondary",children:["v",e.current]})," to ",o.jsxs("span",{className:"font-mono text-accent",children:["v",e.latest]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("code",{className:"flex-1 text-[11px] font-mono bg-bg-base px-2 py-1.5 rounded border border-border text-text-secondary truncate",children:xd}),o.jsx("button",{onClick:async()=>{try{await navigator.clipboard.writeText(xd),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},className:"p-1.5 rounded-md border border-border bg-bg-base text-text-muted hover:text-text-primary hover:border-text-muted/50 transition-colors shrink-0",title:"Copy command",children:r?o.jsx(jl,{className:"w-3.5 h-3.5 text-success"}):o.jsx(Al,{className:"w-3.5 h-3.5"})})]})]})]})}function wd({health:e,updateInfo:t,onSearchOpen:n,activeTab:r,onTabChange:a,config:s,onRefresh:i}){const l=h.useRef(null),c=h.useMemo(()=>{if(s?.username)return[{label:"Leaderboard",href:"https://useai.dev/leaderboard"},{label:"Profile",href:\`https://useai.dev/\${s.username}\`}]},[s?.username]);return o.jsx("header",{className:"sticky top-0 z-50 bg-bg-base/80 backdrop-blur-md border-b border-border mb-6",children:o.jsxs("div",{className:"max-w-[1240px] mx-auto px-4 sm:px-6 py-3 flex items-center justify-between relative",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(ud,{className:"h-6"}),e&&e.active_sessions>0&&o.jsx(Mu,{label:\`\${e.active_sessions} active session\${1!==e.active_sessions?"s":""}\`,color:"success",dot:!0})]}),o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:o.jsx(cu,{activeTab:r,onTabChange:a,externalLinks:c})}),o.jsxs("div",{className:"flex items-center gap-4",children:[s?.authenticated&&!s?.username&&o.jsxs("button",{onClick:()=>l.current?.open(),className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-accent/10 border border-accent/25 text-[11px] font-medium text-accent hover:bg-accent/15 transition-colors cursor-pointer",children:[o.jsx(sc,{className:"w-3 h-3"}),"Claim your username"]}),n&&o.jsxs("button",{onClick:n,className:"flex items-center gap-2 px-2.5 py-1.5 rounded-md border border-border/50 bg-bg-surface-1 text-text-muted hover:text-text-primary hover:border-text-muted/50 transition-colors text-xs",children:[o.jsx(nc,{className:"w-3 h-3"}),o.jsx("span",{className:"hidden sm:inline",children:"Search"}),o.jsx("kbd",{className:"hidden sm:inline-flex items-center px-1 py-0.5 rounded border border-border bg-bg-base text-[9px] font-mono leading-none",children:"\u2318K"})]}),t?.update_available&&o.jsx(bd,{updateInfo:t}),o.jsx(vd,{ref:l,config:s,onRefresh:i})]})]})})}function kd({label:e,description:t,checked:n,onChange:r,warning:a}){return o.jsxs("label",{className:"flex items-start justify-between gap-3 py-2 cursor-pointer group",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium text-text-primary",children:e}),o.jsx("div",{className:"text-[11px] text-text-muted leading-relaxed mt-0.5",children:t}),a&&n&&o.jsxs("div",{className:"flex items-center gap-1 mt-1 text-[11px] text-warning",children:[o.jsx(cc,{className:"w-3 h-3 shrink-0"}),a]})]}),o.jsx("button",{role:"switch","aria-checked":n,onClick:()=>r(!n),className:\`\\n relative inline-flex h-5 w-9 shrink-0 rounded-full border-2 border-transparent transition-colors duration-200\\n \${n?"bg-text-muted":"bg-bg-surface-2"}\\n \`,children:o.jsx("span",{className:\`\\n pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform duration-200\\n \${n?"translate-x-4":"translate-x-0"}\\n \`})})]})}function Sd({label:e,description:t,value:n,options:r,onChange:a}){return o.jsxs("div",{className:"flex items-start justify-between gap-3 py-2",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium text-text-primary",children:e}),o.jsx("div",{className:"text-[11px] text-text-muted leading-relaxed mt-0.5",children:t})]}),o.jsxs("div",{className:"relative",children:[o.jsx("select",{value:n,onChange:e=>a(e.target.value),className:"appearance-none bg-bg-surface-2 border border-border/50 rounded-md px-2.5 py-1 pr-7 text-xs text-text-primary cursor-pointer hover:border-border transition-colors",children:r.map(e=>o.jsx("option",{value:e.value,children:e.label},e.value))}),o.jsx(Cl,{className:"absolute right-1.5 top-1/2 -translate-y-1/2 w-3 h-3 text-text-muted pointer-events-none"})]})]})}function jd(){const[e,t]=h.useState(null),[n,r]=h.useState(null),[a,s]=h.useState("idle"),[i,l]=h.useState(null),[c,u]=h.useState(null);h.useEffect(()=>{_("/api/local/config/full").then(e=>{t(e),r(structuredClone(e))}).catch(e=>u(e.message))},[]);const d=!(!e||!n)&&(f=e,p=n,!(JSON.stringify(f)===JSON.stringify(p)));var f,p;const m=h.useCallback(async()=>{if(n&&e){s("saving"),l(null);try{const e=await(a={capture:n.capture,sync:n.sync,evaluation_framework:n.evaluation_framework},R("/api/local/config",a)),{instructions_updated:i,...o}=e;t(o),r(structuredClone(o)),l(i??[]),s("saved"),setTimeout(()=>s("idle"),3e3)}catch{s("error"),setTimeout(()=>s("idle"),3e3)}var a}},[n,e]),g=h.useCallback(()=>{e&&r(structuredClone(e))},[e]),y=h.useCallback(e=>{r(t=>t?{...t,capture:{...t.capture,...e}}:t)},[]),v=h.useCallback(e=>{r(t=>t?{...t,sync:{...t.sync,...e}}:t)},[]),x=h.useCallback(e=>{r(t=>t?{...t,evaluation_framework:e}:t)},[]);return c?o.jsx("div",{className:"max-w-xl mx-auto mt-12 text-center",children:o.jsxs("div",{className:"text-sm text-danger",children:["Failed to load config: ",c]})}):n?o.jsxs("div",{className:"max-w-xl mx-auto pt-2 pb-12 space-y-5",children:[o.jsxs("section",{className:"bg-bg-surface-1 border border-border/50 rounded-xl p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx(kl,{className:"w-4 h-4 text-text-muted"}),o.jsx("h2",{className:"text-xs font-bold text-text-muted uppercase tracking-widest",children:"Capture"})]}),o.jsx("p",{className:"text-[11px] text-text-muted mb-3",children:"What data to record locally for each session."}),o.jsxs("div",{className:"divide-y divide-border/30",children:[o.jsx(kd,{label:"Prompts",description:"Record prompt word count and content metadata",checked:n.capture.prompt,onChange:e=>y({prompt:e})}),o.jsx(kd,{label:"Prompt images",description:"Record image descriptions from prompts",checked:n.capture.prompt_images,onChange:e=>y({prompt_images:e})}),o.jsx(kd,{label:"Evaluation scores",description:"Record session quality scores (SPACE framework)",checked:n.capture.evaluation,onChange:e=>y({evaluation:e})}),o.jsx(Sd,{label:"Evaluation reasons",description:"When to include reason text for each score",value:n.capture.evaluation_reasons,options:[{value:"all",label:"All scores"},{value:"below_perfect",label:"Below perfect only"},{value:"none",label:"None"}],onChange:e=>y({evaluation_reasons:e})}),o.jsx(kd,{label:"Milestones",description:"Record milestones (accomplishments) from each session",checked:n.capture.milestones,onChange:e=>y({milestones:e})})]})]}),o.jsxs("section",{className:"bg-bg-surface-1 border border-border/50 rounded-xl p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx(Sl,{className:"w-4 h-4 text-text-muted"}),o.jsx("h2",{className:"text-xs font-bold text-text-muted uppercase tracking-widest",children:"Evaluation"})]}),o.jsx("p",{className:"text-[11px] text-text-muted mb-3",children:"How sessions are scored."}),o.jsx(Sd,{label:"Framework",description:"Scoring method used for session evaluations",value:n.evaluation_framework,options:[{value:"space",label:"SPACE (weighted)"},{value:"raw",label:"Raw (equal weight)"}],onChange:x})]}),o.jsxs("section",{className:"bg-bg-surface-1 border border-border/50 rounded-xl p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx(Ll,{className:"w-4 h-4 text-text-muted"}),o.jsx("h2",{className:"text-xs font-bold text-text-muted uppercase tracking-widest",children:"Cloud Sync"})]}),o.jsxs("p",{className:"text-[11px] text-text-muted mb-3",children:["Sync session data to useai.dev for leaderboards and public profiles.",!n.authenticated&&" Login first to enable sync."]}),o.jsxs("div",{className:"divide-y divide-border/30",children:[o.jsx(kd,{label:"Auto-sync",description:"Automatically sync data on a schedule",checked:n.sync.enabled,onChange:e=>v({enabled:e})}),n.sync.enabled&&o.jsx(o.Fragment,{children:o.jsx(Sd,{label:"Sync interval",description:"How often to sync data",value:String(n.sync.interval_hours),options:[{value:"0.25",label:"Every 15 minutes"},{value:"0.5",label:"Every 30 minutes"},{value:"1",label:"Every hour"},{value:"2",label:"Every 2 hours"},{value:"3",label:"Every 3 hours"},{value:"6",label:"Every 6 hours"},{value:"12",label:"Every 12 hours"},{value:"24",label:"Every 24 hours"}],onChange:e=>v({interval_hours:Number(e)})})})]})]}),d&&o.jsxs("div",{className:"sticky bottom-4 flex items-center justify-between gap-3 bg-bg-surface-1 border border-border/50 rounded-xl px-4 py-3 shadow-lg",children:[o.jsx("div",{className:"text-xs text-text-muted",children:"saved"===a&&i?\`Saved. Updated instructions in \${i.length} tool\${1!==i.length?"s":""}: \${i.join(", ")||"none installed"}\`:"error"===a?"Failed to save. Try again.":"You have unsaved changes"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:g,disabled:"saving"===a,className:"px-3 py-1.5 rounded-md text-xs font-medium text-text-muted hover:text-text-primary border border-border/50 hover:border-border transition-colors disabled:opacity-50",children:"Discard"}),o.jsxs("button",{onClick:m,disabled:"saving"===a,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-accent text-bg-base hover:bg-accent/90 transition-colors disabled:opacity-50",children:["saving"===a?o.jsx(Wl,{className:"w-3 h-3 animate-spin"}):"saved"===a?o.jsx(jl,{className:"w-3 h-3"}):o.jsx(tc,{className:"w-3 h-3"}),"saving"===a?"Saving...":"saved"===a?"Saved":"Save"]})]})]})]}):o.jsx("div",{className:"max-w-xl mx-auto mt-12 text-center",children:o.jsx("div",{className:"text-sm text-text-muted",children:"Loading settings..."})})}function Cd(){const{sessions:e,milestones:t,config:n,health:r,updateInfo:a,loading:s,loadAll:i,loadHealth:l,loadUpdateCheck:c,deleteSession:u,deleteConversation:d,deleteMilestone:f,activeTab:p,setActiveTab:m}=fd();h.useEffect(()=>{i(),l(),c()},[i,l,c]),h.useEffect(()=>{const e=setInterval(l,3e4),t=setInterval(i,3e4);return()=>{clearInterval(e),clearInterval(t)}},[i,l]);const[g,y]=h.useState(!1);return h.useEffect(()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),y(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),s?o.jsx("div",{className:"min-h-screen flex items-center justify-center",children:o.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."})}):o.jsxs("div",{className:"min-h-screen bg-bg-base selection:bg-accent/30 selection:text-text-primary",children:[o.jsx(wd,{health:r,updateInfo:a,onSearchOpen:()=>y(!0),activeTab:p,onTabChange:m,config:n,onRefresh:i}),o.jsx("div",{className:"max-w-[1240px] mx-auto px-4 sm:px-6 pb-6",children:"settings"===p?o.jsx(jd,{}):o.jsxs(o.Fragment,{children:[o.jsx(hd,{open:g,onClose:()=>y(!1),sessions:e,milestones:t,onDeleteSession:u,onDeleteConversation:d,onDeleteMilestone:f}),o.jsx(cd,{sessions:e,milestones:t,onDeleteSession:u,onDeleteConversation:d,onDeleteMilestone:f,activeTab:p,onActiveTabChange:m})]})})]})}P.createRoot(document.getElementById("root")).render(o.jsx(h.StrictMode,{children:o.jsx(Cd,{})}));</script>
34390
+ */function kc(e){if(mc[e])return e;return wc.filter(t=>e.startsWith(t)).sort((e,t)=>t.length-e.length)[0]??e}var Sc=E(),jc=new Map;function Cc(e){let t=jc.get(e);return void 0===t&&(t=new Date(e).getTime(),jc.set(e,t)),t}function Nc(e){if(0===e.length)return 0;const t=new Set;for(const i of e)i.started_at&&t.add(i.started_at.slice(0,10));const n=[...t].sort().reverse();if(0===n.length)return 0;const r=(new Date).toISOString().slice(0,10),a=new Date(Date.now()-864e5).toISOString().slice(0,10);if(n[0]!==r&&n[0]!==a)return 0;let s=1;for(let i=1;i<n.length;i++){const e=new Date(n[i-1]),t=new Date(n[i]);if(1!==(e.getTime()-t.getTime())/864e5)break;s++}return s}function Tc(e){const t=e.filter(e=>e.session.evaluation);if(0===t.length)return null;let n=0,r=0,a=0,s=0,i=0,o=0;const l={};for(const u of t){const e=u.session.evaluation;n+=e.prompt_quality,r+=e.context_provided,a+=e.independence_level,s+=e.scope_quality,i+=e.tools_leveraged,o+=e.iteration_count,l[e.task_outcome]=(l[e.task_outcome]??0)+1}const c=t.length;return{prompt_quality:Math.round(n/c*10)/10,context_provided:Math.round(r/c*10)/10,independence_level:Math.round(a/c*10)/10,scope_quality:Math.round(s/c*10)/10,tools_leveraged:Math.round(i/c),total_iterations:o,outcomes:l,session_count:c}}function Ec({sessions:e,timeScale:t,effectiveTime:n,isLive:r,onDayClick:a,highlightDate:s}){const i="day"===t||"24h"===t||"12h"===t||"6h"===t,l=new Date(n).toISOString().slice(0,10),c=h.useMemo(()=>i?function(e,t){const n=new Date(\`\${t}T00:00:00\`).getTime(),r=n+864e5,a=[];for(let s=0;s<24;s++)a.push({hour:s,minutes:0});for(const s of e){const e=Cc(s.started_at),t=Cc(s.ended_at);if(t<n||e>r)continue;const i=Math.max(e,n),o=Math.min(t,r);for(let r=0;r<24;r++){const e=n+36e5*r,t=e+36e5,s=Math.max(i,e),l=Math.min(o,t);l>s&&(a[r].minutes+=(l-s)/6e4)}}return a}(e,l):[],[e,l,i]),u=h.useMemo(()=>i?[]:function(e,t){const n=new Date,r=[];for(let a=t-1;a>=0;a--){const t=new Date(n);t.setDate(t.getDate()-a);const s=t.toISOString().slice(0,10);let i=0;for(const n of e){const e=n.started_at?.slice(0,10);e&&e===s&&(i+=n.duration_seconds)}r.push({date:s,hours:i/3600})}return r}(e,7),[e,i]),d=i?\`Hourly \u2014 \${new Date(n).toLocaleDateString([],{month:"short",day:"numeric"})}\`:"Last 7 Days";if(i){const e=Math.max(...c.map(e=>e.minutes),1);return o.jsxs("div",{className:"mb-8 p-5 rounded-2xl bg-bg-surface-1/50 border border-border/50",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4 px-1",children:[o.jsx("div",{className:"text-xs text-text-muted uppercase tracking-widest font-bold",children:d}),o.jsxs("div",{className:"text-[10px] text-text-muted font-mono bg-bg-surface-2 px-2 py-0.5 rounded",children:[e.toFixed(0),"m peak"]})]}),o.jsx("div",{className:"flex items-end gap-[3px] h-16",children:c.map((t,n)=>{const r=e>0?t.minutes/e*100:0;return o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-end h-full group relative",children:[o.jsx("div",{className:"absolute -top-10 left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-20 pointer-events-none",children:o.jsxs("div",{className:"bg-bg-surface-3 text-text-primary text-[10px] font-mono px-2 py-1.5 rounded-lg shadow-xl whitespace-nowrap border border-border flex flex-col items-center",children:[o.jsxs("span",{className:"font-bold",children:[t.hour,":00"]}),o.jsxs("span",{className:"text-accent",children:[t.minutes.toFixed(0),"m active"]}),o.jsx("div",{className:"absolute -bottom-1 left-1/2 -translate-x-1/2 w-2 h-2 bg-bg-surface-3 border-r border-b border-border rotate-45"})]})}),o.jsx(pl.div,{initial:{height:0},animate:{height:\`\${Math.max(r,t.minutes>0?8:0)}%\`},transition:{delay:.01*n,duration:.5},className:"w-full rounded-t-sm transition-all duration-300 group-hover:bg-accent relative overflow-hidden",style:{minHeight:t.minutes>0?"4px":"0px",backgroundColor:t.minutes>0?\`rgba(var(--accent-rgb), \${.4+t.minutes/e*.6})\`:"var(--color-bg-surface-2)"},children:t.minutes>.5*e&&o.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-transparent to-white/10"})})]},t.hour)})}),o.jsx("div",{className:"flex gap-[3px] mt-2 border-t border-border/30 pt-2",children:c.map(e=>o.jsx("div",{className:"flex-1 text-center",children:e.hour%6==0&&o.jsx("span",{className:"text-[9px] text-text-muted font-bold font-mono uppercase",children:0===e.hour?"12a":e.hour<12?\`\${e.hour}a\`:12===e.hour?"12p":e.hour-12+"p"})},e.hour))})]})}const f=Math.max(...u.map(e=>e.hours),.1);return o.jsxs("div",{className:"mb-8 p-5 rounded-2xl bg-bg-surface-1/50 border border-border/50",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4 px-1",children:[o.jsx("div",{className:"text-xs text-text-muted uppercase tracking-widest font-bold",children:d}),o.jsx("div",{className:"text-[10px] text-text-muted font-mono bg-bg-surface-2 px-2 py-0.5 rounded",children:"Last 7 days"})]}),o.jsx("div",{className:"flex items-end gap-2 h-16",children:u.map((e,t)=>{const n=f>0?e.hours/f*100:0,r=e.date===s;return o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-end h-full group relative",children:[o.jsx("div",{className:"absolute -top-10 left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-20 pointer-events-none",children:o.jsxs("div",{className:"bg-bg-surface-3 text-text-primary text-[10px] font-mono px-2 py-1.5 rounded-lg shadow-xl whitespace-nowrap border border-border flex flex-col items-center",children:[o.jsx("span",{className:"font-bold",children:e.date}),o.jsxs("span",{className:"text-accent",children:[e.hours.toFixed(1),"h active"]}),o.jsx("div",{className:"absolute -bottom-1 left-1/2 -translate-x-1/2 w-2 h-2 bg-bg-surface-3 border-r border-b border-border rotate-45"})]})}),o.jsx(pl.div,{initial:{height:0},animate:{height:\`\${Math.max(n,e.hours>0?8:0)}%\`},transition:{delay:.05*t,duration:.5},className:"w-full rounded-t-md cursor-pointer transition-all duration-300 group-hover:scale-x-110 origin-bottom "+(r?"ring-2 ring-accent ring-offset-2 ring-offset-bg-base":""),style:{minHeight:e.hours>0?"4px":"0px",backgroundColor:r?"var(--color-accent-bright)":e.hours>0?\`rgba(var(--accent-rgb), \${.4+e.hours/f*.6})\`:"var(--color-bg-surface-2)"},onClick:()=>a?.(e.date)})]},e.date)})}),o.jsx("div",{className:"flex gap-2 mt-2 border-t border-border/30 pt-2",children:u.map(e=>o.jsx("div",{className:"flex-1 text-center",children:o.jsx("span",{className:"text-[10px] text-text-muted font-bold uppercase tracking-tighter",children:new Date(e.date+"T12:00:00").toLocaleDateString([],{weekday:"short"})})},e.date))})]})}var Mc=[{key:"simple",label:"Simple",color:"#34d399"},{key:"medium",label:"Medium",color:"#fbbf24"},{key:"complex",label:"Complex",color:"#f87171"}];function Pc({data:e}){const t=e.simple+e.medium+e.complex;if(0===t)return null;const n=Math.max(e.simple,e.medium,e.complex);return o.jsxs(pl.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.15},className:"rounded-xl bg-bg-surface-1 border border-border/50 p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx("div",{className:"p-1.5 rounded-lg bg-bg-surface-2",children:o.jsx(Ul,{className:"w-3.5 h-3.5 text-text-muted"})}),o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest",children:"Complexity"})]}),o.jsx("div",{className:"space-y-3",children:Mc.map((r,a)=>{const s=e[r.key],i=n>0?s/n*100:0,l=t>0?(s/t*100).toFixed(0):"0";return o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-xs text-text-secondary font-medium w-16 text-right shrink-0",children:r.label}),o.jsx("div",{className:"flex-1 h-5 rounded bg-bg-surface-2/50 overflow-hidden",children:o.jsx(pl.div,{className:"h-full rounded",style:{backgroundColor:r.color},initial:{width:0},animate:{width:\`\${i}%\`},transition:{duration:.6,delay:.08*a,ease:[.22,1,.36,1]}})}),o.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o.jsx("span",{className:"text-xs text-text-primary font-mono font-bold w-6 text-right",children:s}),o.jsxs("span",{className:"text-[10px] text-text-muted/70 font-mono w-8 text-right",children:[l,"%"]})]})]},r.key)})}),o.jsx("div",{className:"mt-4 flex h-2 rounded-full overflow-hidden bg-bg-surface-2/30",children:Mc.map(n=>{const r=e[n.key],a=t>0?r/t*100:0;return 0===a?null:o.jsx(pl.div,{className:"h-full",style:{backgroundColor:n.color},initial:{width:0},animate:{width:\`\${a}%\`},transition:{duration:.8,ease:[.22,1,.36,1]}},n.key)})})]})}var Lc=["1h","3h","6h","12h"],Dc=["day","week","month"],Ac=["1h","3h","6h","12h","24h","day","7d","week","30d","month"],_c={day:"24h",week:"7d",month:"30d"},zc={"24h":"day","7d":"week","30d":"month"};function Rc(e){return"day"===e||"week"===e||"month"===e}var Fc={"1h":36e5,"3h":108e5,"6h":216e5,"12h":432e5,"24h":864e5,"7d":6048e5,"30d":2592e6},Vc={"1h":"1 Hour","3h":"3 Hours","6h":"6 Hours","12h":"12 Hours","24h":"24 Hours",day:"Day","7d":"7 Days",week:"Week","30d":"30 Days",month:"Month"};function Ic(e,t){const n=Fc[e];if(void 0!==n)return{start:t-n,end:t};const r=new Date(t);if("day"===e){const e=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime();return{start:e,end:e+864e5}}if("week"===e){const e=r.getDay(),t=0===e?-6:1-e,n=new Date(r.getFullYear(),r.getMonth(),r.getDate()+t).getTime();return{start:n,end:n+6048e5}}return{start:new Date(r.getFullYear(),r.getMonth(),1).getTime(),end:new Date(r.getFullYear(),r.getMonth()+1,1).getTime()}}function Oc(e,t,n){const r=Fc[e];if(void 0!==r)return t+n*r;const a=new Date(t);return"day"===e?new Date(a.getFullYear(),a.getMonth(),a.getDate()+n,12).getTime():"week"===e?new Date(a.getFullYear(),a.getMonth(),a.getDate()+7*n,12).getTime():new Date(a.getFullYear(),a.getMonth()+n,Math.min(a.getDate(),28),12).getTime()}function $c(e,t){return Rc(e)?function(e,t){if(!Rc(e))return!1;const n=Ic(e,t),r=Date.now();return r>=n.start&&r<n.end}(e,t):t>=Date.now()-6e4}function Bc({label:e,value:t,suffix:n,decimals:r=0,icon:a,delay:s=0,variant:i="default",clickable:l=!1,selected:c=!1,onClick:u,subtitle:d}){const f=h.useRef(null),p=h.useRef(0);h.useEffect(()=>{f.current&&t!==p.current&&(!function(e,t,n){let r=null;requestAnimationFrame(function a(s){r||(r=s);const i=Math.min((s-r)/800,1),o=1-Math.pow(1-i,4),l=t*o;e.textContent=n>0?l.toFixed(n):String(Math.round(l)),i<1&&requestAnimationFrame(a)})}(f.current,t,r),p.current=t)},[t,r]);const m="accent"===i;return o.jsxs(pl.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:s},onClick:l&&t>0?u:void 0,className:\`px-3 py-2 rounded-lg border flex items-center gap-2.5 group transition-all duration-300 \${m?"shrink-0 bg-bg-surface-1 border-border/50 hover:border-accent/30":"flex-1 min-w-[120px] bg-bg-surface-1 border-border/50 hover:border-accent/30"} \${l&&t>0?"cursor-pointer":""} \${c?"border-accent/50 bg-accent/5":""}\`,children:[o.jsx("div",{className:"p-1.5 rounded-md transition-colors "+(c?"bg-accent/15":"bg-bg-surface-2 group-hover:bg-accent/10"),children:o.jsx(a,{className:"w-3.5 h-3.5 transition-colors "+(c?"text-accent":"text-text-muted group-hover:text-accent")})}),o.jsxs("div",{className:"flex flex-col min-w-0",children:[o.jsxs("div",{className:"flex items-baseline gap-0.5",children:[o.jsx("span",{ref:f,className:"text-lg font-bold text-text-primary tracking-tight leading-none",children:r>0?t.toFixed(r):Math.round(t)}),n&&o.jsx("span",{className:"text-[10px] text-text-muted font-medium",children:n})]}),o.jsx("span",{className:"text-[9px] font-mono text-text-muted uppercase tracking-wider leading-none mt-0.5",children:e}),d&&o.jsx("span",{className:"text-[8px] text-text-muted/50 leading-none mt-0.5 truncate",children:d})]})]})}function Uc({totalHours:e,coveredHours:t,aiMultiplier:n,featuresShipped:r,bugsFixed:a,complexSolved:s,currentStreak:i,totalMilestones:l,selectedCard:c,onCardClick:u}){const d=e=>{u?.(c===e?null:e)};return o.jsxs("div",{className:"flex gap-2 mb-4",children:[o.jsxs("div",{className:"grid grid-cols-3 lg:grid-cols-7 gap-2 flex-1",children:[o.jsx(Bc,{label:"User Time",value:t<1/60?0:t<1?Math.round(60*t):t,suffix:t<1?"min":"hrs",decimals:t>=1?1:0,icon:Pl,delay:.1,clickable:!0,selected:"activeTime"===c,onClick:()=>d("activeTime")}),o.jsx(Bc,{label:"AI Time",value:e<1?Math.round(60*e):e,suffix:e<1?"min":"hrs",decimals:e<1?0:1,icon:oc,delay:.12,clickable:!0,selected:"aiTime"===c,onClick:()=>d("aiTime")}),o.jsx(Bc,{label:"Multiplier",value:n,suffix:"x",decimals:1,icon:Ul,delay:.15,clickable:!0,selected:"parallel"===c,onClick:()=>d("parallel")}),o.jsx(Bc,{label:"Milestones",value:l,icon:ic,delay:.2,clickable:!0,selected:"milestones"===c,onClick:()=>d("milestones")}),o.jsx(Bc,{label:"Features",value:r,icon:Jl,delay:.25,clickable:!0,selected:"features"===c,onClick:()=>d("features")}),o.jsx(Bc,{label:"Bugs Fixed",value:a,icon:bl,delay:.3,clickable:!0,selected:"bugs"===c,onClick:()=>d("bugs")}),o.jsx(Bc,{label:"Complex",value:s,icon:xl,delay:.35,clickable:!0,selected:"complex"===c,onClick:()=>d("complex")})]}),o.jsx("div",{className:"w-px bg-border/30 self-stretch my-1"}),o.jsx(Bc,{label:"Streak",value:i,suffix:"days",icon:pc,delay:.45,variant:"accent",clickable:!0,selected:"streak"===c,onClick:()=>d("streak")})]})}var Hc={milestones:{title:"All Milestones",icon:ic,filter:()=>!0,emptyText:"No milestones in this time window.",accentColor:"#60a5fa"},features:{title:"Features Shipped",icon:Jl,filter:e=>"feature"===e.category,emptyText:"No features shipped in this time window.",accentColor:"#4ade80"},bugs:{title:"Bugs Fixed",icon:bl,filter:e=>"bugfix"===e.category,emptyText:"No bugs fixed in this time window.",accentColor:"#f87171"},complex:{title:"Complex Tasks",icon:xl,filter:e=>"complex"===e.complexity,emptyText:"No complex tasks in this time window.",accentColor:"#a78bfa"}},Wc={feature:"bg-success/10 text-success border-success/20",bugfix:"bg-error/10 text-error border-error/20",refactor:"bg-purple/10 text-purple border-purple/20",test:"bg-blue/10 text-blue border-blue/20",docs:"bg-accent/10 text-accent border-accent/20",setup:"bg-text-muted/10 text-text-muted border-text-muted/20",deployment:"bg-emerald/10 text-emerald border-emerald/20"};function qc(e){const t=new Date(e),n=(new Date).getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return"just now";if(r<60)return\`\${r}m ago\`;const a=Math.floor(r/60);if(a<24)return\`\${a}h ago\`;const s=Math.floor(a/24);return 1===s?"yesterday":s<7?\`\${s}d ago\`:t.toLocaleDateString([],{month:"short",day:"numeric"})}function Yc({type:e,milestones:t,showPublic:n=!1,onClose:r}){h.useEffect(()=>{if(e)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]);const[a,s]=h.useState(25),i=h.useRef(null);h.useEffect(()=>{const e=i.current;if(!e)return;const t=new IntersectionObserver(([e])=>{e?.isIntersecting&&s(e=>e+25)},{rootMargin:"200px"});return t.observe(e),()=>t.disconnect()},[e,a]),h.useEffect(()=>{s(25)},[e]);if(!e||!("features"===e||"bugs"===e||"complex"===e||"milestones"===e))return null;const l=Hc[e],c=l.icon,u=t.filter(l.filter).sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime()),d=u.slice(0,a),f=a<u.length,p=new Map;for(const o of d){const e=new Date(o.created_at).toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"}),t=p.get(e);t?t.push(o):p.set(e,[o])}return o.jsx(Qi,{children:e&&o.jsxs(o.Fragment,{children:[o.jsx(pl.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 bg-black/40 backdrop-blur-sm z-40",onClick:r}),o.jsxs(pl.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:30,stiffness:300},className:"fixed top-0 right-0 h-full w-full max-w-md bg-bg-base border-l border-border/50 z-50 flex flex-col shadow-2xl",children:[o.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border/50",children:[o.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:\`\${l.accentColor}15\`},children:o.jsx(c,{className:"w-4 h-4",style:{color:l.accentColor}})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h2",{className:"text-sm font-bold text-text-primary",children:l.title}),o.jsxs("span",{className:"text-[10px] font-mono text-text-muted",children:[u.length," ",1===u.length?"item":"items"," in window"]})]}),o.jsx("button",{onClick:r,className:"p-1.5 rounded-md hover:bg-bg-surface-2 text-text-muted hover:text-text-primary transition-colors",children:o.jsx(fc,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"flex-1 overflow-y-auto overscroll-contain px-5 py-4",children:0===u.length?o.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[o.jsx(sc,{className:"w-8 h-8 text-text-muted/30 mb-3"}),o.jsx("p",{className:"text-sm text-text-muted",children:l.emptyText})]}):o.jsxs("div",{className:"space-y-5",children:[[...p.entries()].map(([t,r])=>o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] font-mono text-text-muted uppercase tracking-wider mb-2 px-1",children:t}),o.jsx("div",{className:"space-y-1",children:r.map((t,r)=>{const a=bc[t.category]??"#9c9588",s=Wc[t.category]??"bg-bg-surface-2 text-text-secondary border-border",i=kc(t.client),l=yc[i]??i.slice(0,2).toUpperCase(),c=mc[i]??"#91919a",u="cursor"===i?"var(--text-primary)":c,d=xc[i],h=n?t.title:t.private_title||t.title,f="complex"===t.complexity;return o.jsxs(pl.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,delay:.03*r},className:"flex items-start gap-2.5 py-2 px-2 rounded-lg hover:bg-bg-surface-1 transition-colors group",children:[o.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0 mt-1.5",style:{backgroundColor:a}}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm text-text-secondary group-hover:text-text-primary transition-colors leading-snug",children:h}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[("complex"===e||"milestones"===e)&&o.jsx("span",{className:\`text-[8px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded-full border \${s}\`,children:t.category}),f&&"complex"!==e&&o.jsxs("span",{className:"flex items-center gap-0.5 text-[8px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded-full border bg-purple/10 text-purple border-purple/20",children:[o.jsx(xl,{className:"w-2 h-2"}),"complex"]}),o.jsx("span",{className:"text-[10px] text-text-muted font-mono",children:qc(t.created_at)}),t.languages.length>0&&o.jsx("span",{className:"text-[9px] text-text-muted font-mono",children:t.languages.join(", ")}),o.jsx("div",{className:"w-4 h-4 rounded flex items-center justify-center text-[7px] font-bold font-mono flex-shrink-0 ml-auto",style:{backgroundColor:\`\${c}15\`,color:c,border:\`1px solid \${c}20\`},children:d?o.jsx("div",{className:"w-2.5 h-2.5",style:{backgroundColor:u,maskImage:\`url(\${d})\`,maskSize:"contain",maskRepeat:"no-repeat",maskPosition:"center",WebkitMaskImage:\`url(\${d})\`,WebkitMaskSize:"contain",WebkitMaskRepeat:"no-repeat",WebkitMaskPosition:"center"}}):l})]})]})]},t.id)})})]},t)),f&&o.jsx("div",{ref:i,className:"py-2 text-center",children:o.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Showing ",d.length," of ",u.length,"..."]})})]})})]})]})})}function Kc(e){return"activeTime"===e||"aiTime"===e||"parallel"===e||"streak"===e}var Xc={activeTime:{title:"User Time",icon:Pl,accentColor:"#60a5fa"},aiTime:{title:"AI Time",icon:oc,accentColor:"#4ade80"},parallel:{title:"Multiplier",icon:Ul,accentColor:"#a78bfa"},streak:{title:"Streak",icon:pc,accentColor:"#facc15"}};function Qc(e){if(e<60)return\`\${Math.round(e)}s\`;if(e<3600)return\`\${Math.round(e/60)}m\`;const t=Math.floor(e/3600),n=Math.round(e%3600/60);return n>0?\`\${t}h \${n}m\`:\`\${t}h\`}function Zc(e){return e<1/60?"< 1 min":e<1?\`\${Math.round(60*e)} min\`:\`\${e.toFixed(1)} hrs\`}function Gc(e){if(0===e.length)return[];const t=[];for(const s of e){const e=Cc(s.started_at),n=Cc(s.ended_at);n<=e||(t.push({time:e,delta:1}),t.push({time:n,delta:-1}))}t.sort((e,t)=>e.time-t.time||e.delta-t.delta);const n=[];let r=0,a=0;for(const s of t){const e=r>0;r+=s.delta,!e&&r>0?a=s.time:e&&0===r&&n.push({start:a,end:s.time})}return n}function Jc({children:e}){return o.jsx("div",{className:"px-3 py-2.5 rounded-lg bg-bg-surface-1 border border-border/50 text-xs text-text-secondary leading-relaxed",children:e})}function eu({label:e,value:t}){return o.jsxs("div",{className:"flex items-center justify-between py-1.5 px-1",children:[o.jsx("span",{className:"text-xs text-text-muted",children:e}),o.jsx("span",{className:"text-xs font-mono font-bold text-text-primary",children:t})]})}function tu({type:e,sessions:t,allSessions:n,currentStreak:r=0,stats:a,showPublic:s=!1,onClose:i}){if(h.useEffect(()=>{if(e&&Kc(e))return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[e]),!e||!Kc(e))return null;const l=Xc[e],c=l.icon,u=[...t].sort((e,t)=>Cc(t.started_at)-Cc(e.started_at));return o.jsx(Qi,{children:e&&o.jsxs(o.Fragment,{children:[o.jsx(pl.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 bg-black/40 backdrop-blur-sm z-40",onClick:i}),o.jsxs(pl.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",damping:30,stiffness:300},className:"fixed top-0 right-0 h-full w-full max-w-md bg-bg-base border-l border-border/50 z-50 flex flex-col shadow-2xl",children:[o.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 border-b border-border/50",children:[o.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:\`\${l.accentColor}15\`},children:o.jsx(c,{className:"w-4 h-4",style:{color:l.accentColor}})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h2",{className:"text-sm font-bold text-text-primary",children:l.title}),o.jsx("span",{className:"text-[10px] font-mono text-text-muted",children:"streak"===e?\`\${r} day\${1===r?"":"s"} consecutive\`:\`\${t.length} sessions in window\`})]}),o.jsx("button",{onClick:i,className:"p-1.5 rounded-md hover:bg-bg-surface-2 text-text-muted hover:text-text-primary transition-colors",children:o.jsx(fc,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-contain px-5 py-4 space-y-4",children:["activeTime"===e&&o.jsx(nu,{stats:a,sessions:t}),"aiTime"===e&&o.jsx(ru,{stats:a,sessions:u,showPublic:s}),"parallel"===e&&o.jsx(au,{stats:a,sessions:u,showPublic:s}),"streak"===e&&o.jsx(su,{allSessions:n??t,currentStreak:r})]})]})]})})}function nu({stats:e,sessions:t}){const n=Gc(t);return o.jsxs(o.Fragment,{children:[o.jsx(Jc,{children:"Real wall-clock time where at least one AI session was running. Gaps between sessions (breaks, thinking, context switches) are excluded."}),o.jsxs("div",{className:"rounded-lg border border-border/50 bg-bg-surface-1 divide-y divide-border/30",children:[o.jsx(eu,{label:"User time",value:Zc(e.coveredHours)}),o.jsx(eu,{label:"AI time",value:Zc(e.totalHours)}),o.jsx(eu,{label:"Active periods",value:String(n.length)}),o.jsx(eu,{label:"Sessions",value:String(t.length)})]}),n.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-[10px] font-mono text-text-muted uppercase tracking-wider px-1 pt-2",children:"Active Periods"}),o.jsx("div",{className:"space-y-1",children:n.map((e,t)=>{const n=(e.end-e.start)/6e4;return o.jsxs(pl.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,delay:.02*t},className:"flex items-center gap-3 py-2 px-2 rounded-lg hover:bg-bg-surface-1 transition-colors",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-accent/60 flex-shrink-0"}),o.jsxs("span",{className:"text-xs font-mono text-text-secondary flex-1",children:[new Date(e.start).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})," \u2192 ",new Date(e.end).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})]}),o.jsx("span",{className:"text-xs font-mono font-bold text-text-primary",children:n<1?"< 1m":n<60?\`\${Math.round(n)}m\`:\`\${(n/60).toFixed(1)}h\`})]},t)})})]})]})}function ru({stats:e,sessions:t,showPublic:n}){return o.jsxs(o.Fragment,{children:[o.jsx(Jc,{children:"Total accumulated AI session duration. When multiple sessions run in parallel, their durations add up \u2014 so AI Time can exceed User Time."}),o.jsxs("div",{className:"rounded-lg border border-border/50 bg-bg-surface-1 divide-y divide-border/30",children:[o.jsx(eu,{label:"AI time",value:Zc(e.totalHours)}),o.jsx(eu,{label:"User time",value:Zc(e.coveredHours)}),o.jsx(eu,{label:"Multiplier",value:\`\${e.aiMultiplier.toFixed(1)}x\`}),o.jsx(eu,{label:"Sessions",value:String(t.length)})]}),o.jsx(ou,{sessions:t,showPublic:n})]})}function au({stats:e,sessions:t,showPublic:n}){return o.jsxs(o.Fragment,{children:[o.jsx(Jc,{children:"Your AI multiplier \u2014 AI Time divided by User Time. Higher means more parallelization. You're running more AI sessions simultaneously."}),o.jsxs("div",{className:"rounded-lg border border-border/50 bg-bg-surface-1 divide-y divide-border/30",children:[o.jsx(eu,{label:"Multiplier",value:\`\${e.aiMultiplier.toFixed(1)}x\`}),o.jsx(eu,{label:"Peak concurrent",value:String(e.peakConcurrency)}),o.jsx(eu,{label:"Calculation",value:\`\${Zc(e.totalHours)} \xF7 \${Zc(e.coveredHours)}\`}),o.jsx(eu,{label:"Sessions",value:String(t.length)})]}),o.jsx(ou,{sessions:t,showPublic:n})]})}function su({allSessions:e,currentStreak:t}){const n=function(e){const t=new Map;for(const n of e){const e=new Date(Cc(n.started_at)),r=\`\${e.getFullYear()}-\${String(e.getMonth()+1).padStart(2,"0")}-\${String(e.getDate()).padStart(2,"0")}\`,a=t.get(r);a?a.push(n):t.set(r,[n])}return[...t.entries()].sort((e,t)=>t[0].localeCompare(e[0])).map(([e,t])=>{const n=new Date(e+"T12:00:00").toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"}),r=t.reduce((e,t)=>e+t.duration_seconds,0),a=Gc(t).reduce((e,t)=>e+(t.end-t.start),0)/1e3,s=a>0?r/a:0;return{date:e,label:n,count:t.length,gainedSeconds:r,spentSeconds:a,boost:s}})}(e),r=new Set,a=new Date;for(let s=0;s<t;s++){const e=new Date(a);e.setDate(e.getDate()-s),r.add(\`\${e.getFullYear()}-\${String(e.getMonth()+1).padStart(2,"0")}-\${String(e.getDate()).padStart(2,"0")}\`)}return o.jsxs(o.Fragment,{children:[o.jsx(Jc,{children:"Consecutive days with at least one AI session. Keep using AI daily to grow your streak!"}),o.jsxs("div",{className:"rounded-lg border border-border/50 bg-bg-surface-1 divide-y divide-border/30",children:[o.jsx(eu,{label:"Current streak",value:\`\${t} day\${1===t?"":"s"}\`}),o.jsx(eu,{label:"Total active days",value:String(n.length)}),o.jsx(eu,{label:"Total sessions",value:String(e.length)})]}),n.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-[10px] font-mono text-text-muted uppercase tracking-wider px-1 pt-2",children:"Active Days"}),o.jsx("div",{className:"space-y-1",children:n.map((e,t)=>{const n=r.has(e.date);return o.jsxs(pl.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,delay:Math.min(.02*t,.6)},className:"flex items-center gap-2 py-2 px-2 rounded-lg hover:bg-bg-surface-1 transition-colors",children:[n?o.jsx(pc,{className:"w-3 h-3 flex-shrink-0",style:{color:"#facc15"}}):o.jsx(wl,{className:"w-3 h-3 flex-shrink-0 text-text-muted"}),o.jsx("span",{className:"text-xs font-mono flex-1 min-w-0 "+(n?"text-text-primary":"text-text-secondary"),children:e.label}),o.jsx("span",{className:"text-[10px] text-text-muted font-mono whitespace-nowrap",title:"User time",children:Qc(e.spentSeconds)}),o.jsx("span",{className:"text-[10px] text-text-muted",children:"/"}),o.jsx("span",{className:"text-[10px] font-mono font-bold text-text-primary whitespace-nowrap",title:"AI time",children:Qc(e.gainedSeconds)}),e.boost>0&&o.jsxs("span",{className:"text-[10px] font-mono font-bold whitespace-nowrap",style:{color:"#a78bfa"},title:"Multiplier",children:[e.boost.toFixed(1),"x"]})]},e.date)})})]})]})}var iu=25;function ou({sessions:e,showPublic:t}){const[n,r]=h.useState(iu),a=h.useRef(null);if(h.useEffect(()=>{const e=a.current;if(!e)return;const t=new IntersectionObserver(([e])=>{e?.isIntersecting&&r(e=>e+iu)},{rootMargin:"200px"});return t.observe(e),()=>t.disconnect()},[e,n]),h.useEffect(()=>{r(iu)},[e.length]),0===e.length)return null;const s=e.slice(0,n),i=n<e.length;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-[10px] font-mono text-text-muted uppercase tracking-wider px-1 pt-2",children:"Sessions"}),o.jsxs("div",{className:"space-y-1",children:[s.map((e,n)=>{const r=kc(e.client),a=yc[r]??r.slice(0,2).toUpperCase(),s=mc[r]??"#91919a",i="cursor"===r?"var(--text-primary)":s,l=xc[r],c=t?e.title??"Untitled":e.private_title||e.title||"Untitled";return o.jsxs(pl.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,delay:Math.min(.02*n,.6)},className:"flex items-start gap-2.5 py-2 px-2 rounded-lg hover:bg-bg-surface-1 transition-colors group",children:[o.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center text-[7px] font-bold font-mono flex-shrink-0 mt-0.5",style:{backgroundColor:\`\${s}15\`,color:s,border:\`1px solid \${s}20\`},children:l?o.jsx("div",{className:"w-3 h-3",style:{backgroundColor:i,maskImage:\`url(\${l})\`,maskSize:"contain",maskRepeat:"no-repeat",maskPosition:"center",WebkitMaskImage:\`url(\${l})\`,WebkitMaskSize:"contain",WebkitMaskRepeat:"no-repeat",WebkitMaskPosition:"center"}}):a}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm text-text-secondary group-hover:text-text-primary transition-colors leading-snug truncate",children:c}),o.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[o.jsx("span",{className:"text-[10px] font-mono text-text-muted",children:Qc(e.duration_seconds)}),o.jsx("span",{className:"text-[10px] text-text-muted",children:(u=e.started_at,new Date(u).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}))}),e.project&&o.jsx("span",{className:"text-[10px] text-text-muted font-mono truncate",children:e.project})]})]})]},e.session_id);var u}),i&&o.jsx("div",{ref:a,className:"py-2 text-center",children:o.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Showing ",s.length," of ",e.length,"..."]})})]})]})}var lu=[{id:"sessions",label:"Sessions"},{id:"insights",label:"Insights"}];function cu({activeTab:e,onTabChange:t,externalLinks:n,showSettings:r=!0}){return o.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 rounded-lg bg-bg-surface-1 border border-border/40",children:[lu.map(({id:n,label:r})=>{const a=e===n;return o.jsx("button",{onClick:()=>t(n),className:\`\\n px-3 py-1 rounded-md text-xs font-medium transition-all duration-150\\n \${a?"bg-bg-surface-2 text-text-primary shadow-sm":"text-text-muted hover:text-text-primary"}\\n \`,children:r},n)}),r&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),o.jsxs("button",{onClick:()=>t("settings"),className:\`\\n flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-medium transition-all duration-150\\n \${"settings"===e?"bg-bg-surface-2 text-text-primary shadow-sm":"text-text-muted hover:text-text-primary"}\\n \`,children:[o.jsx(rc,{className:"w-3 h-3"}),"Settings"]})]}),n&&n.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"w-px h-4 bg-border/60 mx-1"}),n.map(({label:e,href:t})=>o.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-mono tracking-wide text-text-muted hover:text-accent transition-colors duration-150",children:[e,o.jsx(zl,{className:"w-2.5 h-2.5 opacity-50"})]},t))]})]})}function uu({label:e,active:t,onClick:n}){return o.jsx("button",{onClick:n,className:"text-[10px] font-bold uppercase tracking-wider px-3 py-1.5 rounded-full transition-all duration-200 cursor-pointer border "+(t?"bg-accent text-bg-base border-accent scale-105":"bg-bg-surface-1 border-border text-text-muted hover:text-text-primary hover:border-text-muted/50"),style:t?{boxShadow:"0 2px 10px rgba(var(--accent-rgb), 0.4)"}:void 0,children:e})}function du({sessions:e,filters:t,onFilterChange:n}){const r=h.useMemo(()=>[...new Set(e.map(e=>e.client))].sort(),[e]),a=h.useMemo(()=>[...new Set(e.flatMap(e=>e.languages))].sort(),[e]),s=h.useMemo(()=>[...new Set(e.map(e=>e.project).filter(e=>{if(!e)return!1;const t=e.trim().toLowerCase();return!["untitled","mcp","unknown","default","none"].includes(t)}))].sort(),[e]);return r.length>0||a.length>0||s.length>0?o.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-1",children:[o.jsx(uu,{label:"All",active:"all"===t.client&&"all"===t.language&&"all"===t.project,onClick:()=>{n("client","all"),n("language","all"),n("project","all")}}),r.map(e=>o.jsx(uu,{label:gc[e]??e,active:t.client===e,onClick:()=>n("client",t.client===e?"all":e)},e)),a.map(e=>o.jsx(uu,{label:e,active:t.language===e,onClick:()=>n("language",t.language===e?"all":e)},e)),s.map(e=>o.jsx(uu,{label:e,active:t.project===e,onClick:()=>n("project",t.project===e?"all":e)},e))]}):null}function hu({onDelete:e,size:t="md",className:n=""}){const[r,a]=h.useState(!1),s=h.useRef(void 0);h.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const i=t=>{t.stopPropagation(),s.current&&clearTimeout(s.current),a(!1),e()},l=e=>{e.stopPropagation(),s.current&&clearTimeout(s.current),a(!1)},c="sm"===t?"w-3 h-3":"w-3.5 h-3.5",u="sm"===t?"p-1":"p-1.5";return r?o.jsxs("span",{className:\`inline-flex items-center gap-0.5 \${n}\`,onClick:e=>e.stopPropagation(),children:[o.jsx("button",{onClick:i,className:\`\${u} rounded-lg transition-all bg-error/15 text-error hover:bg-error/25\`,title:"Confirm delete",children:o.jsx(jl,{className:c})}),o.jsx("button",{onClick:l,className:\`\${u} rounded-lg transition-all text-text-muted hover:bg-bg-surface-2\`,title:"Cancel",children:o.jsx(fc,{className:c})})]}):o.jsx("button",{onClick:e=>{e.stopPropagation(),a(!0),s.current=setTimeout(()=>a(!1),5e3)},className:\`\${u} rounded-lg transition-all text-text-muted hover:text-error/70 hover:bg-error/5 \${n}\`,title:"Delete",children:o.jsx(lc,{className:c})})}function fu({text:e,words:t}){if(!t?.length||!e)return o.jsx(o.Fragment,{children:e});const n=t.map(e=>e.replace(/[.*+?^\${}()|[\\]\\\\]/g,"\\\\$&")),r=new RegExp(\`(\${n.join("|")})\`,"gi"),a=e.split(r);return o.jsx(o.Fragment,{children:a.map((e,t)=>t%2==1?o.jsx("mark",{className:"bg-accent/30 text-inherit rounded-sm px-px",children:e},t):o.jsx("span",{children:e},t))})}function pu(e,t){const n=e=>new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0});return\`\${n(e)} \u2014 \${n(t)}\`}function mu(e){if(e<60)return\`\${e}s\`;const t=Math.round(e/60);if(t<60)return\`\${t}m\`;const n=Math.floor(t/60),r=t%60;return r>0?\`\${n}h \${r}m\`:\`\${n}h\`}var gu={feature:"bg-success/15 text-success border-success/30",bugfix:"bg-error/15 text-error border-error/30",refactor:"bg-purple/15 text-purple border-purple/30",test:"bg-blue/15 text-blue border-blue/30",docs:"bg-accent/15 text-accent border-accent/30",setup:"bg-text-muted/15 text-text-muted border-text-muted/20",deployment:"bg-emerald/15 text-emerald border-emerald/30"};function yu({category:e}){const t=gu[e]??"bg-bg-surface-2 text-text-secondary border-border";return o.jsx("span",{className:\`text-[10px] px-1.5 py-0.5 rounded-full border font-bold uppercase tracking-wider \${t}\`,children:e})}function vu(e){return e>=5?"text-text-secondary":e>=4?"text-amber-500":e>=3?"text-orange-500":"text-error"}function xu({score:e,decimal:t}){const n=e>=5,r=t?e.toFixed(1):String(Math.round(e)),a=r.endsWith(".0")?r.slice(0,-2):r;return o.jsxs("span",{className:"text-[10px] font-mono "+(n?"":"font-bold"),title:\`\${e.toFixed(1)}/5\`,children:[o.jsx("span",{className:vu(e),children:a}),o.jsx("span",{className:"text-text-muted/50",children:"/5"})]})}function bu({model:e}){return e?o.jsx("div",{className:"flex flex-wrap items-center gap-4",children:o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] whitespace-nowrap",children:[o.jsx(_l,{className:"w-3 h-3 text-text-muted/50 flex-shrink-0"}),o.jsx("span",{className:"text-text-secondary",children:"Model"}),o.jsx("span",{className:"text-text-secondary font-mono font-bold ml-0.5",children:e})]})}):null}function wu({evaluation:e,showPublic:t=!1,model:n}){const r=!!n,a=[{label:"Prompt",value:e.prompt_quality,reason:e.prompt_quality_reason,Icon:Xl},{label:"Context",value:e.context_provided,reason:e.context_provided_reason,Icon:Vl},{label:"Scope",value:e.scope_quality,reason:e.scope_quality_reason,Icon:ic},{label:"Independence",value:e.independence_level,reason:e.independence_level_reason,Icon:Dl}],s=a.some(e=>e.reason)||e.task_outcome_reason;return o.jsxs("div",{className:"px-2.5 py-2 bg-bg-surface-2/30 rounded-md mb-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-2",children:[a.map(({label:e,value:t,Icon:n})=>o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] whitespace-nowrap",children:[o.jsx(n,{className:"w-3 h-3 text-text-muted/60 flex-shrink-0"}),o.jsx("span",{className:"text-text-secondary whitespace-nowrap",children:e}),o.jsx(xu,{score:t})]},e)),r&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"hidden md:block h-3.5 w-px bg-border/30"}),o.jsx(bu,{model:n})]}),o.jsx("div",{className:"hidden md:block h-3.5 w-px bg-border/30"}),o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] whitespace-nowrap",children:[o.jsx(Gl,{className:"w-3 h-3 text-text-muted/50"}),o.jsx("span",{className:"text-text-muted",children:"Iterations"}),o.jsx("span",{className:"text-text-secondary font-mono font-bold ml-0.5",children:e.iteration_count})]}),o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] whitespace-nowrap",children:[o.jsx(hc,{className:"w-3 h-3 text-text-muted/50"}),o.jsx("span",{className:"text-text-muted",children:"Tools"}),o.jsx("span",{className:"text-text-secondary font-mono font-bold ml-0.5",children:e.tools_leveraged})]})]}),!t&&s&&o.jsx("div",{className:"mt-2 pt-2 border-t border-border/15",children:o.jsxs("div",{className:"grid grid-cols-[86px_minmax(0,1fr)] gap-x-2 gap-y-1 text-[10px]",children:[a.filter(e=>e.reason).map(({label:e,value:t,reason:n})=>o.jsxs("div",{className:"contents",children:[o.jsxs("span",{className:\`\${vu(t)} font-bold text-right\`,children:[e,":"]}),o.jsx("span",{className:"text-text-secondary leading-relaxed",children:n})]},e)),e.task_outcome_reason&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"col-span-2 border-t border-border/15 mt-0.5 mb-0.5"}),o.jsx("span",{className:"text-text-secondary font-bold text-right",children:"Outcome:"}),o.jsx("span",{className:"text-text-secondary leading-relaxed",children:e.task_outcome_reason})]})]})})]})}function ku({prompt:e,imageCount:t,images:n}){const[r,a]=h.useState(!1),s=e.length>300,i=s&&!r?e.slice(0,300)+"\u2026":e,l=t??n?.length??0;return o.jsxs("div",{className:"px-2.5 py-2 bg-bg-surface-2/20 rounded-md mb-2 border border-border/10",children:[o.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[o.jsx(Xl,{className:"w-3 h-3 text-text-muted/50"}),o.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-text-muted",children:"Prompt"}),l>0&&o.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-text-muted bg-bg-surface-2 px-1.5 py-0.5 rounded-full border border-border/20",children:[o.jsx(Bl,{className:"w-2.5 h-2.5"}),l]})]}),o.jsx("p",{className:"text-[11px] text-text-secondary leading-relaxed whitespace-pre-wrap break-words",children:i}),s&&o.jsx("button",{onClick:()=>a(!r),className:"text-[10px] text-accent hover:text-accent/80 mt-1 font-medium",children:r?"Show less":"Show more"}),n&&n.length>0&&o.jsx("div",{className:"mt-2 pt-1.5 border-t border-border/10 space-y-1",children:n.map((e,t)=>o.jsxs("div",{className:"flex items-start gap-1.5",children:[o.jsx(Bl,{className:"w-3 h-3 text-text-muted/50 flex-shrink-0 mt-0.5"}),o.jsx("span",{className:"text-[10px] text-text-secondary leading-relaxed",children:e.description})]},t))})]})}var Su=h.memo(function({session:e,milestones:t,defaultExpanded:n=!1,externalShowPublic:r,contextLabel:a,hideClientAvatar:s=!1,hideProject:i=!1,showFullDate:l=!1,highlightWords:c,onDeleteSession:u,onDeleteMilestone:d}){const[f,p]=h.useState(n),[m,g]=h.useState(!1),y=r??m,v=g,x=kc(e.client),b=mc[x]??"#91919a",w="cursor"===x,k=w?"var(--text-primary)":b,S=w?{backgroundColor:"var(--bg-surface-2)",color:"var(--text-primary)",border:"1px solid var(--border)"}:{backgroundColor:\`\${b}15\`,color:b,border:\`1px solid \${b}30\`},j=yc[x]??x.slice(0,2).toUpperCase(),C=xc[x],N=t.length>0||!!e.evaluation||!!e.model||!!e.prompt,T=e.project?.trim()||"",E=!T||["untitled","mcp","unknown","default","none","null","undefined"].includes(T.toLowerCase()),M=t[0],P=E&&M?M.title:T,L=E&&M?M.private_title||M.title:T;let D=e.private_title||e.title||L||"Untitled Session",A=e.title||P||"Untitled Session";const _=D!==A&&void 0===r,z=!!u||N||_,R=a?.replace(/^\\s*prompt\\s*/i,"").trim();return o.jsxs("div",{className:"group/card mb-2 rounded-xl border transition-all duration-200 "+(f?"bg-bg-surface-1 border-accent/35 shadow-md":"bg-bg-surface-1/35 border-border/50 hover:border-accent/30"),children:[o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{className:"flex-1 flex items-center gap-3 px-3.5 py-2.5 text-left min-w-0",onClick:()=>N&&p(!f),style:{cursor:N?"pointer":"default"},children:[!s&&o.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center text-[11px] font-black font-mono flex-shrink-0 shadow-sm",style:S,title:gc[x]??x,children:C?o.jsx("div",{className:"w-4 h-4",style:{backgroundColor:k,maskImage:\`url(\${C})\`,maskSize:"contain",maskRepeat:"no-repeat",maskPosition:"center",WebkitMaskImage:\`url(\${C})\`,WebkitMaskSize:"contain",WebkitMaskRepeat:"no-repeat",WebkitMaskPosition:"center"}}):j}),o.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[a&&o.jsx("span",{className:"inline-flex items-center rounded-md border border-accent/20 bg-accent/10 px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider text-accent/90",children:R||a}),o.jsx("div",{className:"flex items-center gap-1.5 min-w-0",children:o.jsx(Qi,{mode:"wait",children:o.jsxs(pl.div,{initial:{opacity:0,x:-5},animate:{opacity:1,x:0},exit:{opacity:0,x:5},transition:{duration:.1},className:"flex items-center gap-1.5 min-w-0",children:[y?o.jsx(ac,{className:"w-3 h-3 text-success/70 flex-shrink-0"}):o.jsx(ql,{className:"w-3 h-3 text-accent/70 flex-shrink-0"}),o.jsx("span",{className:"text-[15px] font-semibold truncate text-text-primary tracking-tight leading-tight",children:o.jsx(fu,{text:y?A:D,words:c})})]},y?"public":"private")})})]}),o.jsxs("div",{className:"flex items-center gap-3.5 text-[11px] text-text-secondary font-medium",children:[o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(Pl,{className:"w-3 h-3 opacity-75"}),mu(e.duration_seconds)]}),o.jsxs("span",{className:"text-text-secondary/80 font-mono tracking-tight",children:[l&&\`\${new Date(e.started_at).toLocaleDateString([],{month:"short",day:"numeric"})} \xB7 \`,pu(e.started_at,e.ended_at).split(" \u2014 ")[0]]}),!y&&!E&&!i&&o.jsxs("span",{className:"flex items-center gap-1 text-text-secondary/85",title:\`Project: \${T}\`,children:[o.jsx($l,{className:"w-2.5 h-2.5 opacity-70"}),o.jsx("span",{className:"max-w-[130px] truncate",children:T})]}),t.length>0&&o.jsxs("span",{className:"flex items-center gap-1 text-text-secondary/85",title:\`\${t.length} milestone\${1!==t.length?"s":""}\`,children:[o.jsx(Ol,{className:"w-2.5 h-2.5 opacity-70"}),t.length]}),e.evaluation&&o.jsx(xu,{score:(F=e.evaluation,(F.prompt_quality+F.context_provided+F.scope_quality+F.independence_level)/4),decimal:!0})]})]})]}),z&&o.jsxs("div",{className:"flex items-center px-2.5 gap-1.5 border-l border-border/30 h-9 self-center",children:[u&&o.jsx(hu,{onDelete:()=>u(e.session_id),className:"opacity-0 group-hover/card:opacity-100 focus-within:opacity-100"}),_&&o.jsx("button",{onClick:e=>{e.stopPropagation(),v(!y)},className:"p-1.5 rounded-lg transition-all "+(y?"bg-success/10 text-success":"text-text-secondary hover:text-text-primary hover:bg-bg-surface-2"),title:y?"Public title shown":"Private title shown","aria-label":y?"Show private title":"Show public title",children:y?o.jsx(Fl,{className:"w-3.5 h-3.5"}):o.jsx(Rl,{className:"w-3.5 h-3.5"})}),N&&o.jsx("button",{onClick:()=>p(!f),className:"p-1.5 rounded-lg transition-all "+(f?"text-accent bg-accent/8":"text-text-secondary hover:text-text-primary hover:bg-bg-surface-2"),title:f?"Collapse details":"Expand details","aria-label":f?"Collapse details":"Expand details",children:o.jsx(Cl,{className:"w-4 h-4 transition-transform duration-200 "+(f?"rotate-180":"")})})]})]}),o.jsx(Qi,{children:f&&N&&o.jsx(pl.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:o.jsxs("div",{className:"px-3.5 pb-3.5 pt-1.5 space-y-2",children:[o.jsx("div",{className:"h-px bg-border/20 mb-2 mx-1"}),!y&&e.prompt&&o.jsx(ku,{prompt:e.prompt,imageCount:e.prompt_image_count,images:e.prompt_images}),e.evaluation&&o.jsx(wu,{evaluation:e.evaluation,showPublic:y,model:e.model}),!e.evaluation&&o.jsx(bu,{model:e.model}),t.length>0&&o.jsx("div",{className:"space-y-0.5",children:t.map(e=>{const t=y?e.title:e.private_title||e.title,n=function(e){if(!e||e<=0)return"";if(e<60)return\`\${e}m\`;const t=Math.floor(e/60),n=e%60;return n>0?\`\${t}h \${n}m\`:\`\${t}h\`}(e.duration_minutes);return o.jsxs("div",{className:"group flex items-center gap-2 p-1.5 rounded-md hover:bg-bg-surface-2/40 transition-colors",children:[o.jsx("div",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:bc[e.category]??"#9c9588"}}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-text-secondary group-hover:text-text-primary truncate",children:o.jsx(fu,{text:t,words:c})}),o.jsx(yu,{category:e.category})]})}),n&&o.jsx("span",{className:"text-[10px] text-text-muted font-mono",children:n}),d&&o.jsx(hu,{onDelete:()=>d(e.id),size:"sm",className:"opacity-0 group-hover:opacity-100"})]},e.id)})})]})})})]});var F});function ju(e){if(e<60)return\`\${e}s\`;const t=Math.round(e/60);if(t<60)return\`\${t}m\`;const n=Math.floor(t/60),r=t%60;return r>0?\`\${n}h \${r}m\`:\`\${n}h\`}function Cu({score:e,decimal:t}){const n=e>=5,r=n?"text-text-secondary":e>=4?"text-amber-500":e>=3?"text-orange-500":"text-error",a=t?e.toFixed(1):String(Math.round(e)),s=a.endsWith(".0")?a.slice(0,-2):a;return o.jsxs("span",{className:"text-[10px] font-mono "+(n?"":"font-bold"),title:\`\${e.toFixed(1)}/5\`,children:[o.jsx("span",{className:r,children:s}),o.jsx("span",{className:"text-text-muted/50",children:"/5"})]})}var Nu=h.memo(function({group:e,defaultExpanded:t,globalShowPublic:n,showFullDate:r,highlightWords:a,onDeleteSession:s,onDeleteMilestone:i,onDeleteConversation:l}){const[c,u]=h.useState(t),[d,f]=h.useState(!1),p=n||d;if(1===e.sessions.length){const l=e.sessions[0];return o.jsx(Su,{session:l.session,milestones:l.milestones,defaultExpanded:t&&l.milestones.length>0,externalShowPublic:n||void 0,showFullDate:r,highlightWords:a,onDeleteSession:s,onDeleteMilestone:i})}const m=kc(e.sessions[0].session.client),g=mc[m]??"#91919a",y="cursor"===m,v=y?"var(--text-primary)":g,x=y?{backgroundColor:"var(--bg-surface-2)",color:"var(--text-primary)",border:"1px solid var(--border)"}:{backgroundColor:\`\${g}15\`,color:g,border:\`1px solid \${g}30\`},b=yc[m]??m.slice(0,2).toUpperCase(),w=xc[m],k=e.aggregateEval,S=k?(k.prompt_quality+k.context_provided+k.scope_quality+k.independence_level)/4:0,j=e.sessions[0].session,C=j.private_title||j.title||j.project||"Conversation",N=j.title||j.project||"Conversation",T=C!==N&&!n,E=j.project?.trim()||"",M=!!E&&!["untitled","mcp","unknown","default","none","null","undefined"].includes(E.toLowerCase());return o.jsxs("div",{className:"group/conv mb-2 rounded-xl border transition-all duration-200 "+(c?"bg-bg-surface-1 border-accent/35 shadow-md":"bg-bg-surface-1/35 border-border/50 hover:border-accent/30"),children:[o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{className:"flex-1 flex items-center gap-3 px-3.5 py-2.5 text-left min-w-0",onClick:()=>u(!c),children:[o.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center text-[11px] font-black font-mono flex-shrink-0 shadow-sm",style:x,title:gc[m]??m,children:w?o.jsx("div",{className:"w-4 h-4",style:{backgroundColor:v,maskImage:\`url(\${w})\`,maskSize:"contain",maskRepeat:"no-repeat",maskPosition:"center",WebkitMaskImage:\`url(\${w})\`,WebkitMaskSize:"contain",WebkitMaskRepeat:"no-repeat",WebkitMaskPosition:"center"}}):b}),o.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex items-center gap-1.5 min-w-0",children:o.jsx(Qi,{mode:"wait",children:o.jsxs(pl.div,{initial:{opacity:0,x:-5},animate:{opacity:1,x:0},exit:{opacity:0,x:5},transition:{duration:.1},className:"flex items-center gap-1.5 min-w-0",children:[p?o.jsx(ac,{className:"w-3 h-3 text-success/70 flex-shrink-0"}):o.jsx(ql,{className:"w-3 h-3 text-accent/70 flex-shrink-0"}),o.jsx("span",{className:"text-[15px] font-semibold truncate text-text-primary tracking-tight leading-tight",children:o.jsx(fu,{text:p?N:C,words:a})})]},p?"public":"private")})}),o.jsxs("span",{className:"text-[10px] font-bold text-accent/90 bg-accent/10 px-1.5 py-0.5 rounded border border-accent/20 flex-shrink-0",children:[e.sessions.length," prompts"]})]}),o.jsxs("div",{className:"flex items-center gap-3.5 text-[11px] text-text-secondary font-medium",children:[o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(Pl,{className:"w-3 h-3 opacity-75"}),ju(e.totalDuration)]}),o.jsxs("span",{className:"text-text-secondary/80 font-mono tracking-tight",children:[r&&\`\${new Date(e.lastSessionAt).toLocaleDateString([],{month:"short",day:"numeric"})} \xB7 \`,(P=e.lastSessionAt,new Date(P).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}))]}),!p&&M&&o.jsxs("span",{className:"flex items-center gap-1 text-text-secondary/85",title:\`Project: \${E}\`,children:[o.jsx($l,{className:"w-2.5 h-2.5 opacity-70"}),o.jsx("span",{className:"max-w-[130px] truncate",children:E})]}),e.totalMilestones>0&&o.jsxs("span",{className:"flex items-center gap-1 text-text-secondary/85",title:\`\${e.totalMilestones} milestone\${1!==e.totalMilestones?"s":""}\`,children:[o.jsx(Ol,{className:"w-2.5 h-2.5 opacity-70"}),e.totalMilestones]}),k&&o.jsx(Cu,{score:S,decimal:!0})]})]})]}),o.jsxs("div",{className:"flex items-center px-2.5 gap-1.5 border-l border-border/30 h-9 self-center",children:[l&&e.conversationId&&o.jsx(hu,{onDelete:()=>l(e.conversationId),className:"opacity-0 group-hover/conv:opacity-100 focus-within:opacity-100"}),T&&o.jsx("button",{onClick:e=>{e.stopPropagation(),f(!d)},className:"p-1.5 rounded-lg transition-all "+(p?"bg-success/10 text-success":"text-text-secondary hover:text-text-primary hover:bg-bg-surface-2"),title:p?"Public title shown":"Private title shown","aria-label":p?"Show private title":"Show public title",children:p?o.jsx(Fl,{className:"w-3.5 h-3.5"}):o.jsx(Rl,{className:"w-3.5 h-3.5"})}),o.jsx("button",{onClick:()=>u(!c),className:"p-1.5 rounded-lg transition-all "+(c?"text-accent bg-accent/8":"text-text-secondary hover:text-text-primary hover:bg-bg-surface-2"),title:c?"Collapse conversation":"Expand conversation","aria-label":c?"Collapse conversation":"Expand conversation",children:o.jsx(Cl,{className:"w-4 h-4 transition-transform duration-200 "+(c?"rotate-180":"")})})]})]}),o.jsx(Qi,{children:c&&o.jsx(pl.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:o.jsxs("div",{className:"px-3.5 pb-2.5 relative",children:[o.jsx("div",{className:"absolute left-[1.75rem] top-0 bottom-2 w-px",style:{backgroundColor:\`\${g}25\`}}),o.jsx("div",{className:"space-y-1 pl-10",children:e.sessions.map(e=>o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute -left-7 top-5 w-2 h-2 rounded-full border-2",style:{backgroundColor:g,borderColor:\`\${g}40\`}}),o.jsx(Su,{session:e.session,milestones:e.milestones,defaultExpanded:!1,externalShowPublic:p||void 0,hideClientAvatar:!0,hideProject:!0,showFullDate:r,highlightWords:a,onDeleteSession:s,onDeleteMilestone:i})]},e.session.session_id))})]})})})]});var P});function Tu({sessions:e,milestones:t,filters:n,globalShowPublic:r,showFullDate:a,highlightWords:s,outsideWindowCounts:i,onNavigateNewer:l,onNavigateOlder:c,onDeleteSession:u,onDeleteConversation:d,onDeleteMilestone:f}){const p=h.useMemo(()=>e.filter(e=>("all"===n.client||e.client===n.client)&&(!("all"!==n.language&&!e.languages.includes(n.language))&&("all"===n.project||(e.project??"")===n.project))),[e,n]),m=h.useMemo(()=>"all"===n.category?t:t.filter(e=>e.category===n.category),[t,n.category]),g=h.useMemo(()=>{const e=function(e,t){const n=new Map;for(const a of t){const e=n.get(a.session_id);e?e.push(a):n.set(a.session_id,[a])}const r=e.map(e=>({session:e,milestones:n.get(e.session_id)??[]}));return r.sort((e,t)=>Cc(t.session.started_at)-Cc(e.session.started_at)),r}(p,m);return function(e){const t=new Map,n=[];for(const a of e){const e=a.session.conversation_id;if(e){const n=t.get(e);n?n.push(a):t.set(e,[a])}else n.push(a)}const r=[];for(const[a,s]of t){s.sort((e,t)=>Cc(t.session.started_at)-Cc(e.session.started_at));const e=s.reduce((e,t)=>e+t.session.duration_seconds,0),t=s.reduce((e,t)=>e+t.milestones.length,0),n=s[s.length-1].session.started_at,i=s[0].session.ended_at,o=s[0].session.started_at;r.push({conversationId:a,sessions:s,aggregateEval:Tc(s),totalDuration:e,totalMilestones:t,startedAt:n,endedAt:i,lastSessionAt:o})}for(const a of n)r.push({conversationId:null,sessions:[a],aggregateEval:a.session.evaluation?Tc([a]):null,totalDuration:a.session.duration_seconds,totalMilestones:a.milestones.length,startedAt:a.session.started_at,endedAt:a.session.ended_at,lastSessionAt:a.session.started_at});return r.sort((e,t)=>Cc(t.lastSessionAt)-Cc(e.lastSessionAt)),r}(e)},[p,m]),[y,v]=h.useState(25),x=h.useRef(null);if(h.useEffect(()=>{v(25)},[g]),h.useEffect(()=>{const e=x.current;if(!e)return;const t=new IntersectionObserver(([e])=>{e?.isIntersecting&&v(e=>e+25)},{rootMargin:"200px"});return t.observe(e),()=>t.disconnect()},[g,y]),0===g.length){const e=i&&i.before>0,t=i&&i.after>0;return o.jsxs("div",{className:"text-center text-text-muted py-8 text-sm mb-4 space-y-3",children:[t&&o.jsxs("button",{onClick:l,className:"flex flex-col items-center gap-0.5 mx-auto text-[11px] text-text-muted/60 hover:text-accent transition-colors group",children:[o.jsx(El,{className:"w-3.5 h-3.5"}),o.jsxs("span",{children:[i.after," newer session",1!==i.after?"s":""]}),i.newerLabel&&o.jsx("span",{className:"text-[10px] opacity-70 group-hover:opacity-100",children:i.newerLabel})]}),o.jsx("div",{children:"No sessions in this window"}),e&&o.jsxs("button",{onClick:c,className:"flex flex-col items-center gap-0.5 mx-auto text-[11px] text-text-muted/60 hover:text-accent transition-colors group",children:[i.olderLabel&&o.jsx("span",{className:"text-[10px] opacity-70 group-hover:opacity-100",children:i.olderLabel}),o.jsxs("span",{children:[i.before," older session",1!==i.before?"s":""]}),o.jsx(Cl,{className:"w-3.5 h-3.5"})]})]})}const b=y<g.length,w=b?g.slice(0,y):g;return o.jsxs("div",{className:"space-y-2 mb-4",children:[i&&i.after>0&&o.jsxs("button",{onClick:l,className:"flex flex-col items-center gap-0.5 w-full text-[11px] text-text-muted/60 hover:text-accent py-1.5 transition-colors group",children:[o.jsx(El,{className:"w-3.5 h-3.5"}),o.jsxs("span",{children:[i.after," newer session",1!==i.after?"s":""]}),i.newerLabel&&o.jsx("span",{className:"text-[10px] opacity-70 group-hover:opacity-100",children:i.newerLabel})]}),w.map(e=>o.jsx(Nu,{group:e,defaultExpanded:!1,globalShowPublic:r,showFullDate:a,highlightWords:s,onDeleteSession:u,onDeleteMilestone:f,onDeleteConversation:d},e.conversationId??e.sessions[0].session.session_id)),b&&o.jsx("div",{ref:x,className:"h-px"}),g.length>25&&o.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 text-[11px] text-text-muted",children:[o.jsxs("span",{children:["Showing ",Math.min(y,g.length)," of ",g.length," conversations"]}),b&&o.jsx("button",{onClick:()=>v(g.length),className:"text-accent hover:text-accent/80 font-semibold transition-colors",children:"Show all"})]}),i&&i.before>0&&o.jsxs("button",{onClick:c,className:"flex flex-col items-center gap-0.5 w-full text-[11px] text-text-muted/60 hover:text-accent py-1.5 transition-colors group",children:[i.olderLabel&&o.jsx("span",{className:"text-[10px] opacity-70 group-hover:opacity-100",children:i.olderLabel}),o.jsxs("span",{children:[i.before," older session",1!==i.before?"s":""]}),o.jsx(Cl,{className:"w-3.5 h-3.5"})]})]})}var Eu={accent:{border:"border-accent/20",bg:"bg-[var(--accent-alpha)]",dot:"bg-accent"},success:{border:"border-success/20",bg:"bg-success/10",dot:"bg-success"},muted:{border:"border-border",bg:"bg-bg-surface-2/50",dot:"bg-text-muted"}};function Mu({label:e,color:t="accent",dot:n=!1,icon:r,glow:a=!1,className:s="","data-testid":i}){const l=Eu[t];return o.jsxs("div",{"data-testid":i,className:\`inline-flex items-center gap-2 px-3 py-1 rounded-full border \${l.border} \${l.bg} \${s}\`,style:a?{boxShadow:"0 0 10px rgba(var(--accent-rgb), 0.1)"}:void 0,children:[n&&o.jsx("span",{className:\`w-1.5 h-1.5 rounded-full \${l.dot} animate-pulse\`}),r,o.jsx("span",{className:"text-[10px] font-mono text-text-secondary tracking-widest uppercase",children:e})]})}var Pu={"1h":{visibleDuration:36e5,majorTickInterval:9e5,minorTickInterval:3e5,labelFormat:e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})},"3h":{visibleDuration:108e5,majorTickInterval:18e5,minorTickInterval:6e5,labelFormat:e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})},"6h":{visibleDuration:216e5,majorTickInterval:36e5,minorTickInterval:9e5,labelFormat:e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})},"12h":{visibleDuration:432e5,majorTickInterval:72e5,minorTickInterval:18e5,labelFormat:e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})},"24h":{visibleDuration:864e5,majorTickInterval:144e5,minorTickInterval:36e5,labelFormat:e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})},day:{visibleDuration:864e5,majorTickInterval:144e5,minorTickInterval:36e5,labelFormat:e=>e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})},"7d":{visibleDuration:6048e5,majorTickInterval:864e5,minorTickInterval:216e5,labelFormat:e=>e.toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"})},week:{visibleDuration:6048e5,majorTickInterval:864e5,minorTickInterval:216e5,labelFormat:e=>e.toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"})},"30d":{visibleDuration:2592e6,majorTickInterval:6048e5,minorTickInterval:864e5,labelFormat:e=>e.toLocaleDateString([],{month:"short",day:"numeric"})},month:{visibleDuration:2592e6,majorTickInterval:6048e5,minorTickInterval:864e5,labelFormat:e=>e.toLocaleDateString([],{month:"short",day:"numeric"})}};function Lu(e){if(e<60)return\`\${e}s\`;const t=Math.round(e/60);if(t<60)return\`\${t}m\`;const n=Math.floor(t/60),r=t%60;return r>0?\`\${n}h \${r}m\`:\`\${n}h\`}function Du({value:e,onChange:t,scale:n,window:r,sessions:a=[],milestones:s=[],showPublic:i=!1}){const l=h.useRef(null),[c,u]=h.useState(0),d=void 0!==r;h.useEffect(()=>{if(!l.current)return;const e=new ResizeObserver(e=>{for(const t of e)u(t.contentRect.width)});return e.observe(l.current),u(l.current.getBoundingClientRect().width),()=>e.disconnect()},[]);const f=Pu[n],p=d?r.end-r.start:f.visibleDuration,m=d?r.end:e,g=d?r.start:e-f.visibleDuration,y=c>0?c/p:0,[v,x]=h.useState(!1),[b,w]=h.useState(0),k=h.useRef(0),S=h.useRef(0),j=h.useRef(null);h.useEffect(()=>()=>{j.current&&clearTimeout(j.current)},[]);const C=h.useCallback(e=>{x(!0),k.current=e.clientX,S.current=0,w(0),e.currentTarget.setPointerCapture(e.pointerId)},[]),N=h.useCallback(n=>{if(!v||0===y)return;const r=n.clientX-k.current;k.current=n.clientX,S.current+=r,w(e=>e+r),j.current||(j.current=setTimeout(()=>{j.current=null;const n=S.current;S.current=0,w(0);const r=e+-n/y,a=d?Math.max(Math.min(r,m),g):Math.min(r,Date.now());t(a)},80))},[v,y,e,m,g,d,t]),T=h.useCallback(()=>{if(x(!1),j.current&&(clearTimeout(j.current),j.current=null),0!==S.current&&y>0){const n=e+-S.current/y,r=d?Math.max(Math.min(n,m),g):Math.min(n,Date.now());S.current=0,t(r)}w(0)},[e,m,g,d,y,t]),E=h.useMemo(()=>{if(!c||0===y)return[];const e=g-f.majorTickInterval,t=m+f.majorTickInterval,n=[];for(let r=Math.ceil(e/f.majorTickInterval)*f.majorTickInterval;r<=t;r+=f.majorTickInterval)n.push({type:"major",time:r,position:(r-m)*y,label:f.labelFormat(new Date(r))});for(let r=Math.ceil(e/f.minorTickInterval)*f.minorTickInterval;r<=t;r+=f.minorTickInterval)r%f.majorTickInterval!==0&&n.push({type:"minor",time:r,position:(r-m)*y});return n},[g,m,c,y,f]),M=h.useMemo(()=>a.map(e=>({session:e,start:Cc(e.started_at),end:Cc(e.ended_at)})),[a]),P=h.useMemo(()=>{if(!c||0===y)return[];const e=M.filter(e=>e.start<=m&&e.end>=g).map(e=>({session:e.session,leftOffset:(Math.max(e.start,g)-m)*y,width:(Math.min(e.end,m)-Math.max(e.start,g))*y}));return e.length>100?(e.sort((e,t)=>t.width-e.width),e.slice(0,100)):e},[M,g,m,c,y]),L=h.useMemo(()=>s.map(e=>({milestone:e,time:Cc(e.created_at)})).sort((e,t)=>e.time-t.time),[s]),D=h.useMemo(()=>{if(!c||0===y||!L.length)return[];let e=0,t=L.length;for(;e<t;){const n=e+t>>1;L[n].time<g?e=n+1:t=n}const n=e;for(t=L.length;e<t;){const n=e+t>>1;L[n].time<=m?e=n+1:t=n}const r=e,a=[];for(let s=n;s<r;s++){const e=L[s];a.push({...e,offset:(e.time-m)*y})}return a},[L,g,m,c,y]),A=h.useMemo(()=>{if(!c||0===y)return null;const e=Date.now();return e<g||e>m?null:(e-m)*y},[g,m,c,y]),[_,z]=h.useState(null),R=h.useRef(e);return h.useEffect(()=>{_&&Math.abs(e-R.current)>1e3&&z(null),R.current=e},[e,_]),o.jsxs("div",{className:"relative h-16",children:[o.jsxs("div",{"data-testid":"time-scrubber",className:"absolute inset-0 bg-transparent border-t border-border/50 overflow-hidden select-none touch-none cursor-grab active:cursor-grabbing",ref:l,onPointerDown:C,onPointerMove:N,onPointerUp:T,style:{touchAction:"none"},children:[null!==A&&o.jsx("div",{className:"absolute top-0 bottom-0 w-[2px] bg-accent/50 z-30",style:{right:-A}}),null!==A&&A<-1&&o.jsx("div",{className:"absolute top-0 bottom-0 bg-bg-base/30 z-20",style:{right:0,width:-A}}),o.jsxs("div",{className:"absolute right-0 top-0 bottom-0 w-0 pointer-events-none",style:b?{transform:\`translateX(\${b}px)\`,willChange:"transform"}:void 0,children:[E.map(e=>o.jsx("div",{className:"absolute top-0 border-l "+("major"===e.type?"border-border/60":"border-border/30"),style:{left:e.position,height:"major"===e.type?"100%":"35%",bottom:0},children:"major"===e.type&&e.label&&o.jsx("span",{className:"absolute top-2 left-2 text-[9px] font-bold text-text-muted uppercase tracking-wider whitespace-nowrap bg-bg-surface-1/80 px-1 py-0.5 rounded",children:e.label})},e.time)),P.map(e=>o.jsx("div",{className:"absolute bottom-0 rounded-t-md pointer-events-auto cursor-pointer hover:opacity-80",style:{left:e.leftOffset,width:Math.max(e.width,3),height:"45%",backgroundColor:"rgba(var(--accent-rgb), 0.15)",borderTop:"2px solid rgba(var(--accent-rgb), 0.5)",boxShadow:"inset 0 1px 10px rgba(var(--accent-rgb), 0.05)"},onMouseEnter:t=>{const n=t.currentTarget.getBoundingClientRect();z({type:"session",data:e.session,x:n.left+n.width/2,y:n.top})},onMouseLeave:()=>z(null)},e.session.session_id)),D.map((e,n)=>o.jsx("div",{className:"absolute bottom-2 pointer-events-auto cursor-pointer z-40 transition-transform hover:scale-125",style:{left:e.offset,transform:"translateX(-50%)"},onMouseEnter:t=>{const n=t.currentTarget.getBoundingClientRect();z({type:"milestone",data:e.milestone,x:n.left+n.width/2,y:n.top})},onMouseLeave:()=>z(null),onClick:n=>{n.stopPropagation(),t(e.time)},children:o.jsx("div",{className:"w-3.5 h-3.5 rounded-full border-2 border-bg-surface-1 shadow-lg",style:{backgroundColor:bc[e.milestone.category]??"#9c9588",boxShadow:\`0 0 10px \${bc[e.milestone.category]}50\`}})},n))]})]}),_&&Sc.createPortal(o.jsx("div",{className:"fixed z-[9999] pointer-events-none",style:{left:_.x,top:_.y,transform:"translate(-50%, -100%)"},children:o.jsxs("div",{className:"mb-3 bg-bg-surface-3/95 backdrop-blur-md text-text-primary rounded-xl shadow-2xl px-3 py-2.5 text-[11px] min-w-[180px] max-w-[280px] border border-border/50 animate-in fade-in zoom-in-95 duration-200",children:["session"===_.type?o.jsx(Au,{session:_.data,showPublic:i}):o.jsx(_u,{milestone:_.data,showPublic:i}),o.jsx("div",{className:"absolute -bottom-1.5 left-1/2 -translate-x-1/2 w-3 h-3 bg-bg-surface-3/95 border-r border-b border-border/50 rotate-45"})]})}),document.body)]})}function Au({session:e,showPublic:t}){const n=gc[e.client]??e.client,r=t?e.title||e.project||\`\${n} Session\`:e.private_title||e.title||e.project||\`\${n} Session\`;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-bold text-xs text-accent uppercase tracking-widest",children:n}),o.jsx("span",{className:"text-[10px] text-text-muted font-mono",children:Lu(e.duration_seconds)})]}),o.jsx("div",{className:"h-px bg-border/50 my-0.5"}),o.jsx("div",{className:"text-text-primary font-medium",children:r}),o.jsx("div",{className:"text-text-secondary capitalize text-[10px]",children:e.task_type})]})}function _u({milestone:e,showPublic:t}){const n=t?e.title:e.private_title??e.title;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-bold text-[10px] uppercase tracking-widest",style:{color:bc[e.category]??"#9c9588"},children:e.category}),e.complexity&&o.jsx("span",{className:"text-[9px] font-mono text-text-muted font-bold border border-border/50 px-1 rounded uppercase",children:e.complexity})]}),o.jsx("div",{className:"h-px bg-border/50 my-0.5"}),o.jsx("div",{className:"font-bold text-xs break-words text-text-primary",children:n}),!t&&e.private_title&&o.jsxs("div",{className:"text-[10px] text-text-muted italic opacity-70",children:["Public: ",e.title]})]})}function zu(e,t){const n=e.trim();if(!n)return null;const r=new Date(t),a=n.match(/^(\\d{1,2}):(\\d{2})(?::(\\d{2}))?\\s*(AM|PM)$/i);if(a){let e=parseInt(a[1],10);const t=parseInt(a[2],10),n=a[3]?parseInt(a[3],10):0,s=a[4].toUpperCase();return e<1||e>12||t>59||n>59?null:("AM"===s&&12===e&&(e=0),"PM"===s&&12!==e&&(e+=12),r.setHours(e,t,n,0),r.getTime())}const s=n.match(/^(\\d{1,2}):(\\d{2})(?::(\\d{2}))?$/);if(s){const e=parseInt(s[1],10),t=parseInt(s[2],10),n=s[3]?parseInt(s[3],10):0;return e>23||t>59||n>59?null:(r.setHours(e,t,n,0),r.getTime())}return null}function Ru({value:e,onChange:t,scale:n,onScaleChange:r,sessions:a,showPublic:s=!1}){const i=null===e,l=Rc(n),[c,u]=h.useState(Date.now());h.useEffect(()=>{if(!i)return;const e=setInterval(()=>u(Date.now()),1e3);return()=>clearInterval(e)},[i]);const d=i?c:e,f=Ic(n,d),p=h.useMemo(()=>{const{start:e,end:t}=f,n=e=>new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}),r=e=>new Date(e).toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"}),a=new Date(e).toDateString()===new Date(t-1).toDateString();return i?a?\`\${n(e)} \u2013 Now\`:\`\${r(e)}, \${n(e)} \u2013 Now\`:a?\`\${n(e)} \u2013 \${n(t)}\`:\`\${r(e)}, \${n(e)} \u2013 \${r(t)}, \${n(t)}\`},[f,i]),[m,g]=h.useState(!1),[y,v]=h.useState(""),x=h.useRef(null),b=h.useRef(!1),w=h.useRef(""),k=h.useRef(!1),S=h.useRef(0),j=h.useCallback(e=>{if(l){if(e>=Date.now()-2e3)return void t(null);const a=_c[n];return a&&r(a),void t(e)}const a=Date.now();if(e>=a-2e3)return k.current=!0,S.current=a,void t(null);k.current&&a-S.current<300||k.current&&e>=a-1e4&&e<=a+2e3?t(null):(k.current=!1,t(e))},[t,r,l,n]),C=e=>{const r=Oc(n,d,e);$c(n,r)?t(null):t(r)},N=()=>{b.current=i,t(d);const e=new Date(d).toLocaleTimeString([],{hour12:!0,hour:"2-digit",minute:"2-digit",second:"2-digit"});w.current=e,v(e),g(!0),requestAnimationFrame(()=>x.current?.select())},T=()=>{if(g(!1),b.current&&y===w.current)return void t(null);const e=zu(y,d);null!==e&&t(Math.min(e,Date.now()))},E=e=>{if(l){const t=-1===e?"Previous":"Next";return"day"===n?\`\${t} Day\`:"week"===n?\`\${t} Week\`:\`\${t} Month\`}return\`\${-1===e?"Back":"Forward"} \${Vc[n].toLowerCase()}\`};return o.jsxs("div",{"data-testid":"time-travel-panel",className:"flex flex-col bg-bg-surface-1 border border-border/50 rounded-2xl overflow-hidden mb-8 shadow-sm",children:[o.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between px-6 py-3 border-b border-border/50 gap-4",children:[o.jsxs("div",{className:"flex flex-col items-start gap-0.5",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"flex items-center gap-2 h-8",children:[m?o.jsx("input",{ref:x,type:"text",value:y,onChange:e=>v(e.target.value),onBlur:T,onKeyDown:e=>{if("Enter"===e.key)return void T();if("Escape"===e.key)return e.preventDefault(),g(!1),void(b.current&&t(null));if("ArrowUp"!==e.key&&"ArrowDown"!==e.key)return;e.preventDefault();const n=x.current;if(!n)return;const r=n.selectionStart??0,a="ArrowUp"===e.key?1:-1,s=zu(y,d);if(null===s)return;const i=y.indexOf(":"),o=y.indexOf(":",i+1),l=y.lastIndexOf(" ");let c;c=r<=i?36e5*a:o>-1&&r<=o?6e4*a:l>-1&&r<=l?1e3*a:12*a*36e5;const u=Math.min(s+c,Date.now()),h=new Date(u).toLocaleTimeString([],{hour12:!0,hour:"2-digit",minute:"2-digit",second:"2-digit"});v(h),t(u),requestAnimationFrame(()=>{n&&n.setSelectionRange(r,r)})},className:"text-xl font-mono font-bold tracking-tight bg-bg-surface-2 border rounded-lg px-2 -ml-2 w-[155px] outline-none text-text-primary "+(i?"border-accent":"border-history"),style:{boxShadow:i?"0 0 10px rgba(var(--accent-rgb), 0.2)":"0 0 10px rgba(var(--history-rgb), 0.2)"}}):o.jsxs("button",{onClick:N,className:"group flex items-center gap-2 hover:bg-bg-surface-2/50 rounded-lg px-2 -ml-2 py-1 transition-all cursor-text",title:"Click to edit time",children:[o.jsx(Pl,{className:"w-5 h-5 "+(i?"text-text-muted":"text-history")}),o.jsx("span",{"data-testid":"time-display",className:"text-xl font-mono font-bold tracking-tight tabular-nums "+(i?"text-text-primary":"text-history"),children:new Date(d).toLocaleTimeString([],{hour12:!0,hour:"2-digit",minute:"2-digit",second:"2-digit"})})]}),o.jsx("button",{onClick:m?T:N,className:"p-1.5 rounded-lg transition-colors flex-shrink-0 "+(m?i?"bg-accent text-bg-base hover:bg-accent-bright":"bg-history text-white hover:brightness-110":"text-text-muted hover:text-text-primary hover:bg-bg-surface-2"),title:m?"Confirm time":"Edit time",children:o.jsx(Ql,{className:"w-3.5 h-3.5"})})]}),i?o.jsx(Mu,{label:"Live",color:"success",dot:!0,glow:!0,"data-testid":"live-badge"}):o.jsxs(o.Fragment,{children:[o.jsx(Mu,{label:"History",color:"muted","data-testid":"history-badge"}),o.jsxs("button",{"data-testid":"go-live-button",onClick:()=>t(null),className:"group flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-bold uppercase tracking-widest bg-history/10 hover:bg-history text-history hover:text-white rounded-xl transition-all border border-history/20",children:[o.jsx(ec,{className:"w-3 h-3 group-hover:-rotate-90 transition-transform duration-500"}),"Live"]})]})]}),o.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary font-medium px-0.5",children:[o.jsx(wl,{className:"w-3.5 h-3.5 text-text-muted"}),o.jsx("span",{"data-testid":"date-display",children:new Date(d).toLocaleDateString([],{weekday:"short",month:"long",day:"numeric",year:"numeric"})}),o.jsx("span",{className:"text-text-muted",children:"\xB7"}),o.jsx("span",{"data-testid":"period-label",className:"text-text-muted text-xs tabular-nums",children:p})]})]}),o.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[o.jsxs("div",{className:"flex items-center bg-bg-surface-2/50 border border-border/50 rounded-xl p-1 shadow-inner",children:[Lc.map(e=>o.jsx("button",{"data-testid":\`scale-\${e}\`,onClick:()=>r(e),className:"px-3 py-1.5 text-[10px] font-bold uppercase tracking-wider rounded-lg transition-all "+(n===e?"bg-bg-surface-3 text-text-primary shadow-sm":"text-text-muted hover:text-text-primary hover:bg-bg-surface-2"),title:Vc[e],children:e},e)),o.jsx("div",{className:"w-px h-5 bg-border/50 mx-1"}),Dc.map(e=>{const t=n===e||zc[n]===e;return o.jsx("button",{"data-testid":\`scale-\${e}\`,onClick:()=>r(e),className:"px-3 py-1.5 text-[10px] font-bold uppercase tracking-wider rounded-lg transition-all "+(t?"bg-bg-surface-3 text-text-primary shadow-sm":"text-text-muted hover:text-text-primary hover:bg-bg-surface-2"),title:Vc[e],children:e},e)})]}),o.jsx("div",{className:"flex items-center gap-2",children:o.jsxs("div",{className:"flex items-center gap-1 bg-bg-surface-2/50 border border-border/50 rounded-xl p-1",children:[o.jsx("button",{onClick:()=>C(-1),className:"p-2 text-text-muted hover:text-text-primary hover:bg-bg-surface-2 rounded-lg transition-colors",title:E(-1),children:o.jsx(Nl,{className:"w-4 h-4"})}),o.jsx("button",{onClick:()=>C(1),className:"p-2 text-text-muted hover:text-text-primary hover:bg-bg-surface-2 rounded-lg transition-colors disabled:opacity-20 disabled:cursor-not-allowed",title:E(1),disabled:i||d>=Date.now()-1e3,children:o.jsx(Tl,{className:"w-4 h-4"})})]})})]})]}),o.jsx(Du,{value:d,onChange:j,scale:n,window:l?f:void 0,sessions:a,milestones:void 0,showPublic:s})]})}function Fu({children:e}){return o.jsx("span",{className:"text-text-primary font-medium",children:e})}function Vu(e){return e.reduce((e,t)=>e+t.duration_seconds,0)/3600}function Iu(e,t){const n=e.filter(e=>null!=e.evaluation);if(n.length<2)return null;return n.reduce((e,n)=>e+n.evaluation[t],0)/n.length}function Ou(e,t,n,r,a,s){var i;const l=[],c=a-(s-a),u=a,d=function(e,t,n){return e.filter(e=>{const r=new Date(e.started_at).getTime();return r>=t&&r<=n})}(n,c,u),h=function(e,t,n){return e.filter(e=>{const r=new Date(e.created_at).getTime();return r>=t&&r<=n})}(r,c,u),f=Vu(e),p=Vu(d),m=Iu(e,"prompt_quality"),g=Iu(d,"prompt_quality");if(null!==m&&null!==g&&m>g+.3&&l.push({priority:10,node:o.jsxs("span",{children:["Your prompt quality improved from ",o.jsx(Fu,{children:g.toFixed(1)})," to"," ",o.jsx(Fu,{children:m.toFixed(1)})," \u2014 clearer prompts mean faster results."]})}),d.length>0&&e.length>0){const e=t.length/Math.max(f,.1),n=h.length/Math.max(p,.1);e>1.2*n&&t.length>=2&&l.push({priority:9,node:o.jsxs("span",{children:["You're shipping ",o.jsxs(Fu,{children:[Math.round(100*(e/n-1)),"% faster"]})," ","this period \u2014 great momentum."]})})}const y=t.filter(e=>"complex"===e.complexity).length,v=h.filter(e=>"complex"===e.complexity).length;y>v&&y>=2&&l.push({priority:8,node:o.jsxs("span",{children:[o.jsx(Fu,{children:y})," complex ",1===y?"task":"tasks"," this period vs"," ",o.jsx(Fu,{children:v})," before \u2014 you're taking on harder problems."]})});const x=e.filter(e=>null!=e.evaluation),b=x.filter(e=>"completed"===e.evaluation.task_outcome&&e.evaluation.iteration_count<=3);if(x.length>=3&&b.length>0){const e=Math.round(b.length/x.length*100);e>=50&&l.push({priority:7,node:o.jsxs("span",{children:[o.jsxs(Fu,{children:[e,"%"]})," of your sessions completed in 3 or fewer turns \u2014 efficient prompting."]})})}const w=function(e){if(0===e.length)return null;const t={};for(const a of e){const e=a.task_type||"coding";t[e]=(t[e]??0)+a.duration_seconds}const n=e.reduce((e,t)=>e+t.duration_seconds,0),r=Object.entries(t).sort((e,t)=>t[1]-e[1])[0];return r&&0!==n?{type:r[0],pct:Math.round(r[1]/n*100)}:null}(e);if(w&&w.pct>=60&&e.length>=2){const e={coding:"building",debugging:"debugging",testing:"testing",planning:"planning",reviewing:"reviewing",documenting:"documenting",refactoring:"refactoring",research:"researching",analysis:"analyzing"}[w.type]??w.type;l.push({priority:6,node:o.jsxs("span",{children:["Deep focus: ",o.jsxs(Fu,{children:[w.pct,"%"]})," of your time spent ",e,"."]})})}const k={};for(const o of e)o.client&&(k[i=o.client]??(k[i]=[])).push(o);const S=Object.entries(k).filter(([,e])=>e.length>=2);if(S.length>=2){const e=S.map(([e,n])=>{const r=Vu(n),a=new Set(n.map(e=>e.session_id)),s=t.filter(e=>a.has(e.session_id));return{name:e,rate:s.length/Math.max(r,.1),count:s.length}}).filter(e=>e.count>0);if(e.length>=2){e.sort((e,t)=>t.rate-e.rate);const t=e[0],n=gc[t.name]??t.name;l.push({priority:5,node:o.jsxs("span",{children:[o.jsx(Fu,{children:n})," is your most productive tool this period \u2014 ",t.count," ",1===t.count?"milestone":"milestones"," shipped."]})})}}const j=Iu(e,"context_provided");if(null!==j&&j<3.5&&l.push({priority:4,node:o.jsxs("span",{children:["Tip: Your context score averages ",o.jsxs(Fu,{children:[j.toFixed(1),"/5"]})," \u2014 try including specific files and error messages for faster results."]})}),x.length>=3){const e=x.filter(e=>"completed"===e.evaluation.task_outcome).length,t=Math.round(e/x.length*100);100===t?l.push({priority:3,node:o.jsxs("span",{children:[o.jsx(Fu,{children:"100%"})," completion rate \u2014 every task landed."]})}):t<70&&l.push({priority:4,node:o.jsxs("span",{children:[o.jsxs(Fu,{children:[t,"%"]})," completion rate \u2014 try breaking tasks into smaller, well-scoped pieces."]})})}return p>0&&f>1.5*p&&f>=1&&l.push({priority:2,node:o.jsxs("span",{children:[o.jsxs(Fu,{children:[Math.round(100*(f/p-1)),"% more"]})," AI-paired time this period \u2014 you're leaning in."]})}),0===e.length&&l.push({priority:1,node:o.jsx("span",{className:"text-text-muted",children:"No sessions in this window. Start coding with AI to see insights here."})}),l.sort((e,t)=>t.priority-e.priority)}function $u({sessions:e,milestones:t,windowStart:n,windowEnd:r,allSessions:a,allMilestones:s}){const i=h.useMemo(()=>{const i=Ou(e,t,a??e,s??t,n,r);return i[0]?.node??null},[e,t,a,s,n,r]);return i?o.jsx(pl.div,{initial:{opacity:0},animate:{opacity:1},className:"rounded-xl bg-bg-surface-1 border border-border/50 px-4 py-3",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(sc,{className:"w-4 h-4 text-accent flex-shrink-0 mt-0.5"}),o.jsx("p",{className:"text-sm text-text-secondary leading-relaxed",children:i})]})}):null}function Bu(e){return e>=5?"var(--color-text-muted)":e>=4?"#f59e0b":e>=3?"#f97316":"var(--color-error)"}function Uu({sessions:e}){const{scores:t,summaryLine:n}=h.useMemo(()=>{const t=e.filter(e=>null!=e.evaluation);if(0===t.length)return{scores:null,summaryLine:null};let n=0,r=0,a=0,s=0,i=0,o=0;for(const e of t){const t=e.evaluation;n+=t.prompt_quality,r+=t.context_provided,a+=t.independence_level,s+=t.scope_quality,o+=t.iteration_count,"completed"===t.task_outcome&&i++}const l=t.length,c=Math.round(i/l*100);return{scores:[{label:"Prompt Quality",value:n/l,max:5},{label:"Context",value:r/l,max:5},{label:"Independence",value:a/l,max:5},{label:"Scope",value:s/l,max:5},{label:"Completion",value:c/20,max:5}],summaryLine:\`\${l} session\${1===l?"":"s"} evaluated \xB7 \${c}% completed \xB7 avg \${(o/l).toFixed(1)} iterations\`}},[e]);return o.jsxs(pl.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},className:"rounded-xl bg-bg-surface-1 border border-border/50 p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx("div",{className:"p-1.5 rounded-lg bg-bg-surface-2",children:o.jsx(ic,{className:"w-3.5 h-3.5 text-text-muted"})}),o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest",children:"AI Proficiency"})]}),null===t?o.jsx("p",{className:"text-xs text-text-muted py-2",children:"No evaluation data yet"}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"space-y-3",children:t.map((e,t)=>{const n=e.value/e.max*100,r="Completion"===e.label?\`\${Math.round(n)}%\`:e.value>=5?"5/5":\`\${e.value.toFixed(1)}/5\`,a=e.value>=e.max;return o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-xs text-text-secondary font-medium w-28 text-right shrink-0",children:e.label}),o.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-bg-surface-2/50 overflow-hidden",children:o.jsx(pl.div,{className:"h-full rounded-full",style:{backgroundColor:Bu(e.value)},initial:{width:0},animate:{width:\`\${n}%\`},transition:{duration:.6,delay:.05*t,ease:[.22,1,.36,1]}})}),o.jsx("span",{className:"text-xs font-mono w-10 text-right shrink-0 "+(a?"text-text-muted":"font-bold"),style:a?void 0:{color:Bu(e.value)},children:r})]},e.label)})}),o.jsx("p",{className:"text-[10px] text-text-muted mt-4 px-1 font-mono",children:n})]})]})}var Hu=["Output","Efficiency","Prompts","Consistency","Breadth"];function Wu(e,t,n,r,a){const s=2*Math.PI*e/5-Math.PI/2;return[n+a*t*Math.cos(s),r+a*t*Math.sin(s)]}function qu(e,t,n,r){const a=[];for(let s=0;s<5;s++){const[i,o]=Wu(s,e,t,n,r);a.push(\`\${i},\${o}\`)}return a.join(" ")}function Yu({sessions:e,milestones:t,streak:n}){const{values:r,hasEvalData:a}=h.useMemo(()=>{const r={simple:1,medium:2,complex:4};let a=0;for(const e of t)a+=r[e.complexity]??1;const s=Math.min(1,a/10),i=e.reduce((e,t)=>e+t.files_touched,0),o=e.reduce((e,t)=>e+t.duration_seconds,0)/3600,l=Math.min(1,i/Math.max(o,1)/20),c=e.filter(e=>null!=e.evaluation);let u=0;const d=c.length>0;if(d){u=c.reduce((e,t)=>e+t.evaluation.prompt_quality,0)/c.length/5}const h=Math.min(1,n/14),f=new Set;for(const t of e)for(const e of t.languages)f.add(e);return{values:[s,l,u,h,Math.min(1,f.size/5)],hasEvalData:d}},[e,t,n]),s=100,i=100,l=[];for(let o=0;o<5;o++){const e=Math.max(r[o],.02),[t,n]=Wu(o,e,s,i,70);l.push(\`\${t},\${n}\`)}const c=l.join(" ");return o.jsxs(pl.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.15},className:"rounded-xl bg-bg-surface-1 border border-border/50 p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx("div",{className:"p-1.5 rounded-lg bg-bg-surface-2",children:o.jsx(xl,{className:"w-3.5 h-3.5 text-text-muted"})}),o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest",children:"Skill Profile"})]}),o.jsx("div",{className:"flex justify-center",children:o.jsxs("svg",{viewBox:"0 0 200 200",width:200,height:200,className:"overflow-visible",children:[[.33,.66,1].map(e=>o.jsx("polygon",{points:qu(e,s,i,70),fill:"none",stroke:"var(--color-bg-surface-3)",strokeWidth:.5,opacity:.6},e)),Array.from({length:5}).map((e,t)=>{const[n,r]=Wu(t,1,s,i,70);return o.jsx("line",{x1:s,y1:i,x2:n,y2:r,stroke:"var(--color-bg-surface-3)",strokeWidth:.5,opacity:.4},\`axis-\${t}\`)}),o.jsx(pl.polygon,{points:c,fill:"var(--color-accent)",fillOpacity:.2,stroke:"var(--color-accent)",strokeWidth:1.5,strokeLinejoin:"round",initial:{opacity:0,scale:.5},animate:{opacity:1,scale:1},transition:{duration:.6,ease:[.22,1,.36,1]},style:{transformOrigin:"100px 100px"}}),r.map((e,t)=>{const n=Math.max(e,.02),[r,l]=Wu(t,n,s,i,70),c=2===t&&!a;return o.jsx("circle",{cx:r,cy:l,r:2.5,fill:c?"var(--color-text-muted)":"var(--color-accent-bright)",opacity:c?.4:1},\`point-\${t}\`)}),Hu.map((e,t)=>{const n=function(e,t,n,r){const[a,s]=Wu(e,1.28,t,n,r);let i="middle";return 1!==e&&2!==e||(i="start"),3!==e&&4!==e||(i="end"),{x:a,y:s,anchor:i}}(t,s,i,70),r=2===t&&!a;return o.jsx("text",{x:n.x,y:n.y,textAnchor:n.anchor,dominantBaseline:"central",className:"text-[9px] font-medium",fill:r?"var(--color-text-muted)":"var(--color-text-secondary)",opacity:r?.5:1,children:e},e)})]})}),o.jsx("div",{className:"flex justify-center gap-3 mt-2 flex-wrap",children:Hu.map((e,t)=>{const n=2===t&&!a,s=Math.round(100*r[t]);return o.jsxs("span",{className:"text-[10px] font-mono "+(n?"text-text-muted/50":"text-text-muted"),children:[s,"%"]},e)})})]})}var Ku={coding:"#b4f82c",debugging:"#f87171",testing:"#60a5fa",planning:"#a78bfa",reviewing:"#34d399",documenting:"#fbbf24",learning:"#f472b6",deployment:"#fb923c",devops:"#e879f9",research:"#22d3ee",migration:"#facc15",design:"#c084fc",data:"#2dd4bf",security:"#f43f5e",configuration:"#a3e635",other:"#94a3b8"};function Xu(e){if(e<60)return"<1m";const t=Math.round(e/60);if(t<60)return\`\${t}m\`;return\`\${(e/3600).toFixed(1)}h\`}function Qu({byTaskType:e}){const t=Object.entries(e).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]);if(0===t.length)return null;const n=t[0][1];return o.jsxs("div",{className:"rounded-xl bg-bg-surface-1 border border-border/50 p-4 mb-8",children:[o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest mb-4 px-1",children:"Task Types"}),o.jsx("div",{className:"space-y-2.5",children:t.map(([e,t],r)=>{const a=Ku[e]??Ku.other,s=t/n*100;return o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-xs text-text-secondary font-medium w-24 text-right shrink-0",children:(i=e,i.charAt(0).toUpperCase()+i.slice(1))}),o.jsx("div",{className:"flex-1 h-5 rounded bg-bg-surface-2/50 overflow-hidden",children:o.jsx(pl.div,{className:"h-full rounded",style:{backgroundColor:a},initial:{width:0},animate:{width:\`\${s}%\`},transition:{duration:.6,delay:.05*r,ease:[.22,1,.36,1]}})}),o.jsx("span",{className:"text-xs text-text-muted font-mono w-12 text-right shrink-0",children:Xu(t)})]},e);var i})})]})}var Zu=["#b4f82c","#60a5fa","#f87171","#a78bfa","#fbbf24","#34d399","#f472b6","#22d3ee"];function Gu(e){if(e<60)return"<1m";const t=Math.round(e/60);if(t<60)return\`\${t}m\`;return\`\${(e/3600).toFixed(1)}h\`}function Ju({sessions:e,byProject:t}){const[n,r]=h.useState("user"),[a,s]=h.useState(!1),i=h.useMemo(()=>{const t=[];for(const o of e){if(!o.project)continue;const e=new Date(o.started_at).getTime(),n=new Date(o.ended_at).getTime();n<=e||(t.push({time:e,project:o.project,delta:1}),t.push({time:n,project:o.project,delta:-1}))}t.sort((e,t)=>e.time-t.time||e.delta-t.delta);const n={},r={};let a=0,s=0;for(const e of t){if(a>0&&e.time>s){const t=e.time-s,a=Object.keys(r).filter(e=>r[e]>0),i=a.length;if(i>0){const e=t/i;for(const t of a)n[t]=(n[t]??0)+e}}s=e.time,r[e.project]=(r[e.project]??0)+e.delta,0===r[e.project]&&delete r[e.project],a=Object.values(r).reduce((e,t)=>e+t,0)}const i={};for(const[e,o]of Object.entries(n))o>0&&(i[e]=o/1e3);return i},[e]),l="user"===n?i:t,c=h.useMemo(()=>function(e){const t=Object.entries(e).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]);if(0===t.length)return[];const n=t.reduce((e,[,t])=>e+t,0);let r,a=0;t.length<=6?r=t:(r=t.slice(0,6),a=t.slice(6).reduce((e,[,t])=>e+t,0));const s=r.map(([e,t],r)=>({name:e,seconds:t,color:Zu[r%Zu.length],percentage:t/n*100}));return a>0&&s.push({name:"Other",seconds:a,color:"#64748b",percentage:a/n*100}),s}(l),[l]);if(0===c.length)return null;const u=c.reduce((e,t)=>e+t.seconds,0),d=140,f=2*Math.PI*52;let p=0;const m=c.map(e=>{const t=e.percentage/100*f,n=f-t,r=.25*f-p;return p+=t,{...e,dashLength:t,gap:n,offset:r}}),g={user:"User Time",ai:"AI Time"};return o.jsxs(pl.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},className:"rounded-xl bg-bg-surface-1 border border-border/50 p-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4 px-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"p-1.5 rounded-lg bg-bg-surface-2",children:o.jsx($l,{className:"w-3.5 h-3.5 text-text-muted"})}),o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest",children:"Project Allocation"})]}),o.jsxs("div",{className:"relative",children:[o.jsxs("button",{onClick:()=>s(e=>!e),className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-border/50 bg-bg-surface-2 text-[11px] text-text-secondary font-medium hover:border-text-muted/50 transition-colors",children:[g[n],o.jsx(Cl,{className:"w-3 h-3 text-text-muted"})]}),a&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>s(!1)}),o.jsx("div",{className:"absolute right-0 top-full mt-1 z-20 min-w-[120px] rounded-lg border border-border/50 bg-bg-surface-1 shadow-lg py-1",children:Object.entries(g).map(([e,t])=>o.jsx("button",{onClick:()=>{r(e),s(!1)},className:"w-full text-left px-3 py-1.5 text-xs transition-colors "+(e===n?"text-accent bg-accent/10 font-medium":"text-text-secondary hover:bg-bg-surface-2"),children:t},e))})]})]})]}),o.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-6",children:[o.jsxs("div",{className:"relative shrink-0",style:{width:d,height:d},children:[o.jsxs("svg",{width:d,height:d,viewBox:"0 0 140 140",children:[o.jsx("circle",{cx:70,cy:70,r:52,fill:"none",stroke:"var(--color-bg-surface-2, #1e293b)",strokeWidth:18,opacity:.3}),m.map((e,t)=>o.jsx(pl.circle,{cx:70,cy:70,r:52,fill:"none",stroke:e.color,strokeWidth:18,strokeDasharray:\`\${e.dashLength} \${e.gap}\`,strokeDashoffset:e.offset,strokeLinecap:"butt",initial:{opacity:0},animate:{opacity:1},transition:{duration:.5,delay:.1+.08*t,ease:[.22,1,.36,1]}},\`\${n}-\${e.name}\`))]}),o.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[o.jsx("span",{className:"text-lg font-bold text-text-primary leading-none",children:c.length}),o.jsx("span",{className:"text-[10px] text-text-muted mt-0.5",children:1===c.length?"project":"projects"})]})]}),o.jsx("div",{className:"flex-1 min-w-0 space-y-1.5 w-full",children:c.map((e,t)=>o.jsxs(pl.div,{className:"flex items-center gap-2.5",initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{duration:.4,delay:.15+.06*t,ease:[.22,1,.36,1]},children:[o.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:e.color}}),o.jsx("span",{className:"text-xs text-text-secondary font-medium truncate flex-1 min-w-0",children:e.name}),o.jsx("span",{className:"text-[10px] text-text-muted font-mono shrink-0",children:Gu(e.seconds)}),o.jsxs("span",{className:"text-[10px] text-text-muted/70 font-mono w-10 text-right shrink-0",children:[e.percentage.toFixed(0),"%"]})]},e.name))})]}),o.jsx("div",{className:"mt-4 flex h-2 rounded-full overflow-hidden bg-bg-surface-2/30",children:c.map(e=>{const t=u>0?e.seconds/u*100:0;return 0===t?null:o.jsx(pl.div,{className:"h-full",style:{backgroundColor:e.color},initial:{width:0},animate:{width:\`\${t}%\`},transition:{duration:.8,ease:[.22,1,.36,1]}},e.name)})})]})}var ed={feature:"bg-success/10 text-success border-success/20",bugfix:"bg-error/10 text-error border-error/20",refactor:"bg-purple/10 text-purple border-purple/20",test:"bg-blue/10 text-blue border-blue/20",docs:"bg-accent/10 text-accent border-accent/20",setup:"bg-text-muted/10 text-text-muted border-text-muted/20",deployment:"bg-emerald/10 text-emerald border-emerald/20"};function td(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return\`\${n}m ago\`;const r=Math.floor(n/60);if(r<24)return\`\${r}h ago\`;const a=Math.floor(r/24);return 1===a?"yesterday":a<7?\`\${a}d ago\`:new Date(e).toLocaleDateString([],{month:"short",day:"numeric"})}function nd({milestones:e,showPublic:t=!1}){const n=[...e].sort((e,t)=>new Date(t.created_at).getTime()-new Date(e.created_at).getTime()).slice(0,8);return o.jsxs(pl.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35,ease:[.22,1,.36,1]},className:"rounded-xl bg-bg-surface-1 border border-border/50 p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[o.jsx(uc,{className:"w-4 h-4 text-accent"}),o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest",children:"Recent Achievements"}),o.jsxs("span",{className:"text-[10px] text-text-muted font-mono bg-bg-surface-2 px-2 py-0.5 rounded ml-auto",children:[e.length," total"]})]}),0===n.length?o.jsx("div",{className:"text-sm text-text-muted text-center py-6",children:"No milestones yet \u2014 complete your first session!"}):o.jsx("div",{className:"space-y-0.5",children:n.map((e,n)=>{const r=bc[e.category]??"#9c9588",a=ed[e.category]??"bg-bg-surface-2 text-text-secondary border-border",s=yc[e.client]??e.client.slice(0,2).toUpperCase(),i=mc[e.client]??"#91919a",l=t?e.title:e.private_title||e.title,c="complex"===e.complexity;return o.jsxs(pl.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{duration:.25,delay:.04*n},className:"flex items-center gap-3 py-2 px-2 rounded-lg hover:bg-bg-surface-2/40 transition-colors",children:[o.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:r}}),o.jsx("span",{className:"text-sm font-medium text-text-secondary hover:text-text-primary truncate flex-1 min-w-0",children:l}),o.jsx("span",{className:\`text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded-full border flex-shrink-0 \${a}\`,children:e.category}),c&&o.jsxs("span",{className:"flex items-center gap-0.5 text-[9px] uppercase tracking-wider font-bold px-1.5 py-0.5 rounded-full border bg-purple/10 text-purple border-purple/20 flex-shrink-0",children:[o.jsx(xl,{className:"w-2.5 h-2.5"}),"complex"]}),o.jsx("span",{className:"text-[10px] text-text-muted font-mono flex-shrink-0",children:td(e.created_at)}),o.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center text-[8px] font-bold font-mono flex-shrink-0",style:{backgroundColor:\`\${i}15\`,color:i,border:\`1px solid \${i}20\`},children:s})]},e.id)})})]})}function rd(e){const t=e/3600;return t<1?\`\${Math.round(60*t)}m\`:\`\${t.toFixed(1)}h\`}function ad(e,t){return Object.entries(e).sort((e,t)=>t[1]-e[1]).slice(0,t)}function sd({label:e,children:t}){return o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-widest font-bold whitespace-nowrap",children:e}),o.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-1 no-scrollbar",children:t})]})}function id({stats:e}){const t=ad(e.byClient,4),n=ad(e.byLanguage,4);return 0===t.length&&0===n.length?null:o.jsxs("div",{className:"flex flex-col gap-4 mb-8 p-4 rounded-xl bg-bg-surface-1/30 border border-border/50",children:[t.length>0&&o.jsx(sd,{label:"Top Clients",children:t.map(([e,t])=>{const n=mc[e];return o.jsxs("span",{className:"text-[11px] font-mono px-2.5 py-1 rounded-full bg-bg-surface-1 border border-border hover:border-accent/40 transition-colors shadow-sm whitespace-nowrap group cursor-default",style:n?{borderLeftWidth:"3px",borderLeftColor:n}:void 0,title:rd(t),children:[gc[e]??e,o.jsx("span",{className:"ml-1.5 text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:rd(t)})]},e)})}),n.length>0&&o.jsx(sd,{label:"Languages",children:n.map(([e,t])=>o.jsxs("span",{className:"text-[11px] font-mono px-2.5 py-1 rounded-full bg-bg-surface-1 border border-border hover:border-accent/40 transition-colors shadow-sm whitespace-nowrap group cursor-default",title:rd(t),children:[e,o.jsx("span",{className:"ml-1.5 text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:rd(t)})]},e))})]})}function od(e,t,n){try{const n="undefined"!=typeof window?localStorage.getItem(e):null;if(n&&t.includes(n))return n}catch{}return n}function ld(e,t){try{localStorage.setItem(e,t)}catch{}}function cd({sessions:e,milestones:t,onDeleteSession:n,onDeleteConversation:r,onDeleteMilestone:a,defaultTimeScale:s="day",activeTab:i,onActiveTabChange:l}){const[c,u]=h.useState(null),[d,f]=h.useState(()=>od("useai-time-scale",Ac,s)),[p,m]=h.useState({category:"all",client:"all",project:"all",language:"all"}),[g,y]=h.useState(()=>od("useai-active-tab",["sessions","insights"],"sessions")),[v,x]=h.useState(null),[b,w]=h.useState(!1),[k,S]=h.useState(!1),j=void 0!==i,C=i??g,N=h.useCallback(e=>{l?l(e):(ld("useai-active-tab",e),y(e))},[l]),T=h.useCallback(e=>{ld("useai-time-scale",e),f(e)},[]),E=h.useCallback((e,t)=>{m(n=>({...n,[e]:t}))},[]);h.useEffect(()=>{if(null===c){const e=zc[d];e&&T(e)}},[c,d,T]);const M=null===c,P=c??Date.now(),{start:L,end:D}=Ic(d,P),A=h.useMemo(()=>function(e,t,n){return e.filter(e=>{const r=Cc(e.started_at),a=Cc(e.ended_at);return r<=n&&a>=t})}(e,L,D),[e,L,D]),_=h.useMemo(()=>function(e,t,n){return e.filter(e=>{const r=Cc(e.created_at);return r>=t&&r<=n})}(t,L,D),[t,L,D]),z=h.useMemo(()=>function(e,t=[]){let n=0,r=0;const a={},s={},i={},o={};for(const y of e){n+=y.duration_seconds,r+=y.files_touched,a[y.client]=(a[y.client]??0)+y.duration_seconds;for(const e of y.languages)s[e]=(s[e]??0)+y.duration_seconds;i[y.task_type]=(i[y.task_type]??0)+y.duration_seconds,y.project&&(o[y.project]=(o[y.project]??0)+y.duration_seconds)}let l=0,c=0,u=0,d=0;if(e.length>0){let t=1/0,r=-1/0;const a=[];for(const n of e){const e=Cc(n.started_at),s=Cc(n.ended_at);e<t&&(t=e),s>r&&(r=s),a.push({time:e,delta:1}),a.push({time:s,delta:-1})}l=(r-t)/36e5,a.sort((e,t)=>e.time-t.time||e.delta-t.delta);let s=0,i=0,o=0;for(const e of a){const t=s>0;s+=e.delta,s>d&&(d=s),!t&&s>0?o=e.time:t&&0===s&&(i+=e.time-o)}c=i/36e5,u=c>0?n/3600/c:0}const h=function(e){let t=0,n=0,r=0;for(const a of e)"feature"===a.category&&t++,"bugfix"===a.category&&n++,"complex"===a.complexity&&r++;return{featuresShipped:t,bugsFixed:n,complexSolved:r}}(t),f=e.filter(e=>e.evaluation&&"object"==typeof e.evaluation),p=f.filter(e=>"completed"===e.evaluation.task_outcome).length,m=f.length>0?Math.round(p/f.length*100):0,g=Object.keys(o).length;return{totalHours:n/3600,totalSessions:e.length,actualSpanHours:l,coveredHours:c,aiMultiplier:u,peakConcurrency:d,currentStreak:Nc(e),filesTouched:Math.round(r),...h,totalMilestones:t.length,completionRate:m,activeProjects:g,byClient:a,byLanguage:s,byTaskType:i,byProject:o}}(A,_),[A,_]),R=h.useMemo(()=>Nc(e),[e]),F=h.useMemo(()=>{const t=function(e,t,n){let r=0,a=0;for(const s of e){const e=Cc(s.ended_at),i=Cc(s.started_at);e<t?r++:i>n&&a++}return{before:r,after:a}}(e,L,D);if(M&&0===t.before)return;const n=Vc[d],r=e=>new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0}),a=Rc(d)||D-L>=864e5?e=>\`\${new Date(e).toLocaleDateString([],{month:"short",day:"numeric"})} \${r(e)}\`:r,s=Oc(d,P,-1),i=Ic(d,s),o=\`View prev \${n} \xB7 \${a(i.start)} \u2013 \${a(i.end)}\`;if(M)return{before:t.before,after:0,olderLabel:o};const l=Oc(d,P,1),c=Ic(d,l);return{...t,newerLabel:\`View next \${n} \xB7 \${a(c.start)} \u2013 \${a(c.end)}\`,olderLabel:o}},[e,L,D,P,M,d]),V=h.useCallback(()=>{const e=Oc(d,P,1);$c(d,e)?u(null):u(e)},[P,d]),I=h.useCallback(()=>{const e=Oc(d,P,-1);u(e)},[P,d]),O=h.useMemo(()=>{if(!M)return new Date(P).toISOString().slice(0,10)},[M,P]),$=h.useMemo(()=>{let e=0,t=0,n=0;for(const r of _)"simple"===r.complexity?e++:"medium"===r.complexity?t++:"complex"===r.complexity&&n++;return{simple:e,medium:t,complex:n}},[_]),B=h.useCallback(e=>{const t=new Date(\`\${e}T12:00:00\`).getTime();u(t),T("day")},[T]),U="all"!==p.client||"all"!==p.language||"all"!==p.project;return o.jsxs("div",{className:"space-y-3",children:[o.jsx(Ru,{value:c,onChange:u,scale:d,onScaleChange:T,sessions:e,milestones:t,showPublic:b}),o.jsx(Uc,{totalHours:z.totalHours,totalSessions:z.totalSessions,actualSpanHours:z.actualSpanHours,coveredHours:z.coveredHours,aiMultiplier:z.aiMultiplier,peakConcurrency:z.peakConcurrency,currentStreak:R,filesTouched:z.filesTouched,featuresShipped:z.featuresShipped,bugsFixed:z.bugsFixed,complexSolved:z.complexSolved,totalMilestones:z.totalMilestones,completionRate:z.completionRate,activeProjects:z.activeProjects,selectedCard:v,onCardClick:x}),o.jsx(Yc,{type:v,milestones:_,showPublic:b,onClose:()=>x(null)}),o.jsx(tu,{type:v,sessions:A,allSessions:e,currentStreak:R,stats:{totalHours:z.totalHours,coveredHours:z.coveredHours,aiMultiplier:z.aiMultiplier,peakConcurrency:z.peakConcurrency},showPublic:b,onClose:()=>x(null)}),!j&&o.jsx(cu,{activeTab:C,onTabChange:N}),"sessions"===C&&o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between px-1 pt-0.5",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h2",{className:"text-sm font-bold text-text-muted uppercase tracking-widest",children:"Activity Feed"}),o.jsxs("span",{className:"text-[10px] text-text-muted font-mono bg-bg-surface-2 px-2 py-0.5 rounded",children:[A.length," Sessions"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("button",{onClick:()=>w(e=>!e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border transition-all duration-200 "+(b?"bg-success/10 border-success/30 text-success":"bg-bg-surface-1 border-border/50 text-text-muted hover:text-text-primary hover:border-text-muted/50"),title:b?"Showing public titles":"Showing private titles","aria-label":b?"Switch to private titles":"Switch to public titles",children:[b?o.jsx(Fl,{className:"w-3.5 h-3.5"}):o.jsx(Rl,{className:"w-3.5 h-3.5"}),o.jsx("span",{className:"hidden sm:inline text-xs font-medium",children:b?"Public":"Private"})]}),o.jsxs("button",{onClick:()=>S(e=>!e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border transition-all duration-200 "+(k||U?"bg-accent/10 border-accent/30 text-accent":"bg-bg-surface-1 border-border/50 text-text-muted hover:text-text-primary hover:border-text-muted/50"),title:k?"Hide filters":"Show filters","aria-label":k?"Hide filters":"Show filters",children:[o.jsx(Il,{className:"w-3.5 h-3.5"}),o.jsx("span",{className:"hidden sm:inline text-xs font-medium",children:"Filters"})]})]})]}),k&&o.jsx(du,{sessions:A,filters:p,onFilterChange:E}),o.jsx(Tu,{sessions:A,milestones:_,filters:p,globalShowPublic:b,showFullDate:"week"===d||"7d"===d||"month"===d||"30d"===d,outsideWindowCounts:F,onNavigateNewer:V,onNavigateOlder:I,onDeleteSession:n,onDeleteConversation:r,onDeleteMilestone:a})]}),"insights"===C&&o.jsxs("div",{className:"space-y-4 pt-2",children:[o.jsx($u,{sessions:A,milestones:_,isLive:M,windowStart:L,windowEnd:D,allSessions:e,allMilestones:t}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsx(Uu,{sessions:A}),o.jsx(Yu,{sessions:A,milestones:_,streak:R})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsx(Pc,{data:$}),o.jsx(Ju,{sessions:A,byProject:z.byProject})]}),o.jsx(Qu,{byTaskType:z.byTaskType}),o.jsx(Ec,{sessions:e,timeScale:d,effectiveTime:P,isLive:M,onDayClick:B,highlightDate:O}),o.jsx(nd,{milestones:_,showPublic:b}),o.jsx(id,{stats:z})]})]})}function ud({className:e}){return o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 611.54 143.47",className:e,children:[o.jsxs("g",{fill:"var(--text-primary)",children:[o.jsx("path",{d:"M21.4,121.85c-4.57-4.57-6.85-10.02-6.85-16.37V17.23c0-3.1,1.55-4.65,4.64-4.65h25.55c3.1,0,4.65,1.55,4.65,4.65v76.64c0,3.25,1.12,6,3.37,8.25,2.24,2.25,4.99,3.37,8.25,3.37h27.87c3.25,0,6-1.12,8.25-3.37,2.24-2.24,3.37-4.99,3.37-8.25V17.23c0-3.1,1.55-4.65,4.64-4.65h25.55c3.1,0,4.65,1.55,4.65,4.65v88.25c0,6.35-2.29,11.81-6.85,16.37-4.57,4.57-10.03,6.85-16.37,6.85H37.78c-6.35,0-11.81-2.28-16.37-6.85Z"}),o.jsx("path",{d:"M146.93,124.06v-13.93c0-3.1,1.55-4.65,4.64-4.65h69.67c3.25,0,6-1.12,8.25-3.37,2.24-2.24,3.37-4.99,3.37-8.25s-1.12-6-3.37-8.25c-2.25-2.24-4.99-3.37-8.25-3.37h-51.09c-6.35,0-11.81-2.28-16.37-6.85-4.57-4.57-6.85-10.02-6.85-16.37v-23.22c0-6.35,2.28-11.81,6.85-16.37,4.56-4.57,10.02-6.85,16.37-6.85h92.9c3.1,0,4.65,1.55,4.65,4.65v13.94c0,3.1-1.55,4.65-4.65,4.65h-69.67c-3.25,0-6,1.12-8.25,3.37-2.25,2.25-3.37,4.99-3.37,8.25s1.12,6,3.37,8.25c2.24,2.25,4.99,3.37,8.25,3.37h51.09c6.35,0,11.8,2.29,16.37,6.85,4.57,4.57,6.85,10.03,6.85,16.37v23.22c0,6.35-2.29,11.81-6.85,16.37-4.57,4.57-10.03,6.85-16.37,6.85h-92.9c-3.1,0-4.64-1.55-4.64-4.65Z"}),o.jsx("path",{d:"M286.16,121.85c-4.57-4.57-6.85-10.02-6.85-16.37V35.81c0-6.35,2.28-11.81,6.85-16.37,4.56-4.57,10.02-6.85,16.37-6.85h74.32c6.35,0,11.8,2.29,16.37,6.85,4.57,4.57,6.85,10.03,6.85,16.37v23.22c0,6.35-2.29,11.81-6.85,16.37-4.57,4.57-10.03,6.85-16.37,6.85h-62.71v11.61c0,3.25,1.12,6,3.37,8.25,2.24,2.25,4.99,3.37,8.25,3.37h69.67c3.1,0,4.65,1.55,4.65,4.65v13.93c0,3.1-1.55,4.65-4.65,4.65h-92.9c-6.35,0-11.81-2.28-16.37-6.85ZM361.87,55.66c2.24-2.24,3.37-4.99,3.37-8.25s-1.12-6-3.37-8.25c-2.25-2.24-4.99-3.37-8.25-3.37h-27.87c-3.25,0-6,1.12-8.25,3.37-2.25,2.25-3.37,4.99-3.37,8.25v11.61h39.48c3.25,0,6-1.12,8.25-3.37Z"})]}),o.jsxs("g",{fill:"var(--accent)",children:[o.jsx("path",{d:"M432.08,126.44c-4.76-4.76-7.14-10.44-7.14-17.06v-24.2c0-6.61,2.38-12.3,7.14-17.06,4.76-4.76,10.44-7.14,17.06-7.14h65.34v-12.1c0-3.39-1.17-6.25-3.51-8.59-2.34-2.34-5.2-3.51-8.59-3.51h-72.6c-3.23,0-4.84-1.61-4.84-4.84v-14.52c0-3.23,1.61-4.84,4.84-4.84h96.8c6.61,0,12.3,2.38,17.06,7.14,4.76,4.76,7.14,10.45,7.14,17.06v72.6c0,6.62-2.38,12.3-7.14,17.06-4.76,4.76-10.45,7.14-17.06,7.14h-77.44c-6.62,0-12.3-2.38-17.06-7.14ZM510.97,105.87c2.34-2.34,3.51-5.2,3.51-8.59v-12.1h-41.14c-3.39,0-6.25,1.17-8.59,3.51-2.34,2.34-3.51,5.2-3.51,8.59s1.17,6.25,3.51,8.59c2.34,2.34,5.2,3.51,8.59,3.51h29.04c3.39,0,6.25-1.17,8.59-3.51Z"}),o.jsx("path",{d:"M562.87,128.74V17.42c0-3.23,1.61-4.84,4.84-4.84h26.62c3.23,0,4.84,1.61,4.84,4.84v111.32c0,3.23-1.61,4.84-4.84,4.84h-26.62c-3.23,0-4.84-1.61-4.84-4.84Z"})]})]})}var dd={category:"all",client:"all",project:"all",language:"all"};function hd({open:e,onClose:t,sessions:n,milestones:r,onDeleteSession:a,onDeleteConversation:s,onDeleteMilestone:i}){const[l,c]=h.useState(""),[u,d]=h.useState(""),[f,p]=h.useState(!1),m=h.useRef(null);h.useEffect(()=>{e&&(c(""),d(""),requestAnimationFrame(()=>m.current?.focus()))},[e]),h.useEffect(()=>{if(!e)return;const t=document.documentElement;return t.style.overflow="hidden",document.body.style.overflow="hidden",()=>{t.style.overflow="",document.body.style.overflow=""}},[e]),h.useEffect(()=>{if(!e)return;const n=e=>{"Escape"===e.key&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,t]),h.useEffect(()=>{const e=setTimeout(()=>d(l),250);return()=>clearTimeout(e)},[l]);const g=h.useMemo(()=>{const e=new Map;for(const t of r){const n=e.get(t.session_id);n?n.push(t):e.set(t.session_id,[t])}return e},[r]),{filteredSessions:y,filteredMilestones:v,highlightWords:x}=h.useMemo(()=>{const e=u.trim().toLowerCase();if(!e)return{filteredSessions:[],filteredMilestones:[],highlightWords:[]};const t=e.split(/\\s+/),a=n.filter(e=>function(e,t,n,r){const a=(r?[e.title,e.client,e.task_type,...e.languages,...t.map(e=>e.title)]:[e.private_title,e.title,e.client,e.task_type,...e.languages,...t.map(e=>e.private_title),...t.map(e=>e.title)]).filter(Boolean).join(" ").toLowerCase();return n.every(e=>a.includes(e))}(e,g.get(e.session_id)??[],t,f)),s=new Set(a.map(e=>e.session_id));return{filteredSessions:a,filteredMilestones:r.filter(e=>s.has(e.session_id)),highlightWords:t}},[n,r,g,u,f]),b=u.trim().length>0;return o.jsx(Qi,{children:e&&o.jsxs(o.Fragment,{children:[o.jsx(pl.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"fixed inset-0 bg-black/40 backdrop-blur-sm z-[60]",onClick:t}),o.jsx(pl.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.15},className:"fixed inset-0 z-[61] flex items-start justify-center pt-[10vh] px-4 pointer-events-none",children:o.jsxs("div",{className:"w-full max-w-2xl bg-bg-base border border-border/50 rounded-xl shadow-2xl flex flex-col max-h-[75vh] pointer-events-auto",onClick:e=>e.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/50",children:[o.jsx(nc,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),o.jsx("input",{ref:m,type:"text",value:l,onChange:e=>c(e.target.value),placeholder:f?"Search public titles...":"Search all sessions and milestones...",className:"flex-1 bg-transparent text-sm text-text-primary placeholder:text-text-muted/50 outline-none"}),l&&o.jsx("button",{onClick:()=>{c(""),m.current?.focus()},className:"p-1 rounded-md hover:bg-bg-surface-2 text-text-muted hover:text-text-primary transition-colors",children:o.jsx(fc,{className:"w-3.5 h-3.5"})}),o.jsx("button",{onClick:()=>p(e=>!e),className:"p-1.5 rounded-md border transition-all duration-200 flex-shrink-0 "+(f?"bg-success/10 border-success/30 text-success":"bg-bg-surface-1 border-border/50 text-text-muted hover:text-text-primary hover:border-text-muted/50"),title:f?"Searching public titles":"Searching private titles",children:f?o.jsx(Fl,{className:"w-3.5 h-3.5"}):o.jsx(Rl,{className:"w-3.5 h-3.5"})}),o.jsx("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded border border-border bg-bg-surface-1 text-[10px] font-mono text-text-muted",children:"esc"})]}),o.jsx("div",{className:"flex-1 overflow-y-auto overscroll-none px-4 py-3",children:b?0===y.length?o.jsxs("div",{className:"text-center py-12 text-sm text-text-muted/60",children:["No results for \u201C",u.trim(),"\u201D"]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"text-[10px] font-mono text-text-muted uppercase tracking-wider mb-3 px-1",children:[y.length," result",1!==y.length?"s":""]}),o.jsx(Tu,{sessions:y,milestones:v,filters:dd,globalShowPublic:f||void 0,showFullDate:!0,highlightWords:x,onDeleteSession:a,onDeleteConversation:s,onDeleteMilestone:i})]}):o.jsx("div",{className:"text-center py-12 text-sm text-text-muted/60",children:"Type to search across all sessions"})})]})})]})})}let fd=new Set;const pd=(md=(e,t)=>({sessions:[],milestones:[],config:null,health:null,updateInfo:null,loading:!0,timeTravelTime:null,timeScale:(()=>{try{const e=localStorage.getItem("useai-time-scale"),t=[...Ac];if(e&&t.includes(e))return e}catch{}return"day"})(),filters:{category:"all",client:"all",project:"all",language:"all"},activeTab:(()=>{try{const e=localStorage.getItem("useai-active-tab");if("sessions"===e||"insights"===e||"settings"===e)return e}catch{}return"sessions"})(),loadAll:async()=>{try{const[t,n,r]=await Promise.all([_("/api/local/sessions"),_("/api/local/milestones"),V()]);e({sessions:fd.size>0?t.filter(e=>!fd.has(e.session_id)):t,milestones:fd.size>0?n.filter(e=>!fd.has(e.session_id)):n,config:r,loading:!1})}catch{e({loading:!1})}},loadHealth:async()=>{try{const t=await _("/health");e({health:t})}catch{}},loadUpdateCheck:async()=>{try{const t=await _("/api/local/update-check");e({updateInfo:t})}catch{}},setTimeTravelTime:t=>e({timeTravelTime:t}),setTimeScale:t=>{try{localStorage.setItem("useai-time-scale",t)}catch{}e({timeScale:t})},setFilter:(t,n)=>e(e=>({filters:{...e.filters,[t]:n}})),setActiveTab:t=>{try{localStorage.setItem("useai-active-tab",t)}catch{}e({activeTab:t})},deleteSession:async n=>{fd.add(n),e({sessions:t().sessions.filter(e=>e.session_id!==n),milestones:t().milestones.filter(e=>e.session_id!==n)});try{await function(e){return F(\`/api/local/sessions/\${encodeURIComponent(e)}\`)}(n)}catch(r){console.error("Failed to delete session:",n,r),t().loadAll()}finally{fd.delete(n)}},deleteConversation:async n=>{const r=new Set(t().sessions.filter(e=>e.conversation_id===n).map(e=>e.session_id));for(const e of r)fd.add(e);e({sessions:t().sessions.filter(e=>e.conversation_id!==n),milestones:t().milestones.filter(e=>!r.has(e.session_id))});try{await function(e){return F(\`/api/local/conversations/\${encodeURIComponent(e)}\`)}(n)}catch(a){console.error("Failed to delete conversation:",n,a),t().loadAll()}finally{for(const e of r)fd.delete(e)}},deleteMilestone:async n=>{e({milestones:t().milestones.filter(e=>e.id!==n)});try{await function(e){return F(\`/api/local/milestones/\${encodeURIComponent(e)}\`)}(n)}catch(r){console.error("Failed to delete milestone:",n,r),t().loadAll()}}}))?A(md):A;var md;const gd=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;function yd(e){if(!e)return"Never synced";const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"Just now";if(n<60)return\`\${n}m ago\`;const r=Math.floor(n/60);if(r<24)return\`\${r}h ago\`;return\`\${Math.floor(r/24)}d ago\`}function vd({config:e,onRefresh:t}){const n=!!e.username,[r,a]=h.useState(!n),[s,i]=h.useState(e.username??""),[l,c]=h.useState("idle"),[u,d]=h.useState(),[f,p]=h.useState(!1),m=h.useRef(void 0),g=h.useRef(void 0);h.useEffect(()=>{e.username&&(a(!1),i(e.username))},[e.username]);const y=h.useCallback(t=>{const n=function(e){return e.toLowerCase().replace(/[^a-z0-9-]/g,"")}(t);if(i(n),d(void 0),m.current&&clearTimeout(m.current),g.current&&g.current.abort(),!n)return void c("idle");const r=function(e){return 0===e.length?{valid:!1}:e.length<3?{valid:!1,reason:"At least 3 characters"}:e.length>32?{valid:!1,reason:"At most 32 characters"}:gd.test(e)?{valid:!0}:{valid:!1,reason:"No leading/trailing hyphens"}}(n);if(!r.valid)return c("invalid"),void d(r.reason);n!==e.username?(c("checking"),m.current=setTimeout(async()=>{g.current=new AbortController;try{const e=await async function(e){return _(\`/api/local/users/check-username/\${encodeURIComponent(e)}\`)}(n);e.available?(c("available"),d(void 0)):(c("taken"),d(e.reason))}catch{c("invalid"),d("Check failed")}},400)):c("idle")},[e.username]),v=h.useCallback(async()=>{if("available"===l){p(!0);try{await async function(e){return R("/api/local/users/me",{username:e})}(s),t()}catch(e){c("invalid"),d(e.message)}finally{p(!1)}}},[s,l,t]),x=h.useCallback(()=>{a(!1),i(e.username??""),c("idle"),d(void 0)},[e.username]),b=h.useCallback(()=>{a(!0),i(e.username??""),c("idle"),d(void 0)},[e.username]);return!r&&n?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Hl,{className:"w-3.5 h-3.5 text-text-muted"}),o.jsxs("a",{href:\`https://useai.dev/\${e.username}\`,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-bold text-accent hover:text-accent-bright transition-colors",children:["useai.dev/",e.username]}),o.jsx("button",{onClick:b,className:"p-1 rounded hover:bg-bg-surface-2 text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Edit username",children:o.jsx(Zl,{className:"w-3 h-3"})})]}):o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-text-muted whitespace-nowrap",children:"useai.dev/"}),o.jsx("div",{className:"flex items-center bg-bg-base border border-border rounded-lg overflow-hidden focus-within:border-accent/50 transition-all",children:o.jsx("input",{type:"text",placeholder:"username",value:s,onChange:e=>y(e.target.value),onKeyDown:e=>"Enter"===e.key&&v(),autoFocus:r,maxLength:32,className:"px-2 py-1.5 text-xs bg-transparent text-text-primary outline-none w-28 placeholder:text-text-muted/50"})}),o.jsxs("div",{className:"w-4 h-4 flex items-center justify-center",children:["checking"===l&&o.jsx(Wl,{className:"w-3.5 h-3.5 text-text-muted animate-spin"}),"available"===l&&o.jsx(jl,{className:"w-3.5 h-3.5 text-success"}),("taken"===l||"invalid"===l)&&s.length>0&&o.jsx(fc,{className:"w-3.5 h-3.5 text-error"})]}),o.jsx("button",{onClick:v,disabled:"available"!==l||f,className:"px-3 py-1.5 bg-accent hover:bg-accent-bright text-bg-base text-[10px] font-bold uppercase tracking-wider rounded-lg transition-colors disabled:opacity-30 cursor-pointer",children:f?"...":n?"Save":"Claim"}),n&&o.jsx("button",{onClick:x,className:"px-2 py-1.5 text-[10px] font-bold uppercase tracking-wider text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"Cancel"}),u&&o.jsx("span",{className:"text-[10px] text-error/80 truncate max-w-[140px]",title:u,children:u})]})}const xd=h.forwardRef(function({config:e,onRefresh:t},n){const[r,a]=h.useState(!1),[s,i]=h.useState(""),[l,c]=h.useState(""),[u,d]=h.useState("email"),[f,p]=h.useState(!1),[m,g]=h.useState(null),y=h.useRef(null);h.useImperativeHandle(n,()=>({open:()=>a(!0)})),h.useEffect(()=>{if(!r)return;const e=e=>{y.current&&!y.current.contains(e.target)&&a(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]),h.useEffect(()=>{if(!r)return;const e=e=>{"Escape"===e.key&&a(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r]);const v=h.useCallback(async()=>{if(s.includes("@")){p(!0),g(null);try{await function(e){return z("/api/local/auth/send-otp",{email:e})}(s),d("otp")}catch(e){g(e.message)}finally{p(!1)}}},[s]),x=h.useCallback(async()=>{if(/^\\d{6}$/.test(l)){p(!0),g(null);try{await async function(e,t){return z("/api/local/auth/verify-otp",{email:e,code:t})}(s,l),t(),a(!1)}catch(e){g(e.message)}finally{p(!1)}}},[s,l,t]),b=h.useCallback(async()=>{p(!0),g(null);try{const e=await async function(){return z("/api/local/sync")}();e.success?(g("Synced!"),t(),setTimeout(()=>g(null),3e3)):g(e.error??"Sync failed")}catch(e){g(e.message)}finally{p(!1)}},[t]),w=h.useCallback(async()=>{await async function(){return z("/api/local/auth/logout")}(),t(),a(!1)},[t]);if(!e)return null;const k=e.authenticated;return o.jsxs("div",{className:"relative",ref:y,children:[k?o.jsxs("button",{onClick:()=>a(e=>!e),className:"flex items-center gap-1.5 rounded-full transition-colors cursor-pointer hover:opacity-80",children:[o.jsxs("div",{className:"relative w-7 h-7 rounded-full bg-accent/15 border border-accent/30 flex items-center justify-center",children:[o.jsx("span",{className:"text-xs font-bold text-accent leading-none",children:(e.email?.[0]??"?").toUpperCase()}),o.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full border-2 border-bg-base "+(e.last_sync_at?"bg-success":"bg-warning")})]}),o.jsx(Cl,{className:"w-3 h-3 text-text-muted transition-transform "+(r?"rotate-180":"")})]}):o.jsxs("button",{onClick:()=>a(e=>!e),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-accent hover:bg-accent-bright text-bg-base text-xs font-bold tracking-wide transition-colors cursor-pointer",children:[o.jsx(dc,{className:"w-3 h-3"}),"Sign in"]}),r&&o.jsx("div",{className:"absolute right-0 top-full mt-2 z-50 w-80 rounded-lg bg-bg-surface-1 border border-border shadow-lg",children:k?o.jsxs("div",{children:[o.jsx("div",{className:"px-4 pt-3 pb-2",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-8 h-8 rounded-full bg-accent/10 flex items-center justify-center border border-accent/20 shrink-0",children:o.jsx("span",{className:"text-sm font-bold text-accent",children:(e.email?.[0]??"?").toUpperCase()})}),o.jsx("div",{className:"flex flex-col min-w-0",children:o.jsx("span",{className:"text-xs font-bold text-text-primary truncate",children:e.email})})]})}),o.jsx("div",{className:"px-4 py-2 border-t border-border/50",children:o.jsx(vd,{config:e,onRefresh:t})}),o.jsx("div",{className:"px-4 py-2 border-t border-border/50",children:o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("span",{className:"text-[10px] text-text-muted font-mono uppercase tracking-tighter",children:["Last sync: ",yd(e.last_sync_at)]}),o.jsxs("div",{className:"flex items-center gap-2",children:[m&&o.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest "+("Synced!"===m?"text-success":"text-error"),children:m}),o.jsxs("button",{onClick:b,disabled:f,className:"flex items-center gap-1.5 px-2.5 py-1 bg-accent hover:bg-accent-bright text-bg-base text-[10px] font-bold uppercase tracking-wider rounded-md transition-colors disabled:opacity-50 cursor-pointer",children:[o.jsx(Gl,{className:"w-3 h-3 "+(f?"animate-spin":"")}),f?"...":"Sync"]})]})]})}),o.jsx("div",{className:"px-4 py-2 border-t border-border/50",children:o.jsxs("button",{onClick:w,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-xs text-text-muted hover:text-error hover:bg-error/10 transition-colors cursor-pointer",children:[o.jsx(Yl,{className:"w-3.5 h-3.5"}),"Sign out"]})})]}):o.jsxs("div",{className:"p-4",children:[o.jsx("p",{className:"text-xs font-bold text-text-secondary uppercase tracking-widest mb-3",children:"Sign in to sync"}),m&&o.jsx("p",{className:"text-[10px] font-bold text-error uppercase tracking-widest mb-2",children:m}),"email"===u?o.jsxs("div",{className:"flex items-center bg-bg-base border border-border rounded-lg overflow-hidden focus-within:border-accent/50 focus-within:ring-1 focus-within:ring-accent/50 transition-all",children:[o.jsx("div",{className:"pl-3 py-2",children:o.jsx(Kl,{className:"w-3.5 h-3.5 text-text-muted"})}),o.jsx("input",{type:"email",placeholder:"you@email.com",value:s,onChange:e=>i(e.target.value),onKeyDown:e=>"Enter"===e.key&&v(),autoFocus:!0,className:"px-3 py-2 text-xs bg-transparent text-text-primary outline-none flex-1 placeholder:text-text-muted/50"}),o.jsx("button",{onClick:v,disabled:f||!s.includes("@"),className:"px-4 py-2 bg-bg-surface-2 hover:bg-bg-surface-3 text-text-primary text-[10px] font-bold uppercase tracking-wider transition-colors disabled:opacity-50 cursor-pointer border-l border-border",children:f?"...":"Send"})]}):o.jsxs("div",{className:"flex items-center bg-bg-base border border-border rounded-lg overflow-hidden focus-within:border-accent/50 focus-within:ring-1 focus-within:ring-accent/50 transition-all",children:[o.jsx("input",{type:"text",maxLength:6,placeholder:"000000",inputMode:"numeric",autoComplete:"one-time-code",value:l,onChange:e=>c(e.target.value),onKeyDown:e=>"Enter"===e.key&&x(),autoFocus:!0,className:"px-4 py-2 text-xs bg-transparent text-text-primary text-center font-mono tracking-widest outline-none flex-1 placeholder:text-text-muted/50"}),o.jsx("button",{onClick:x,disabled:f||6!==l.length,className:"px-4 py-2 bg-accent hover:bg-accent-bright text-bg-base text-[10px] font-bold uppercase tracking-wider transition-colors disabled:opacity-50 cursor-pointer",children:f?"...":"Verify"})]})]})})]})}),bd="npx -y @devness/useai update";function wd({updateInfo:e}){const[t,n]=h.useState(!1),[r,a]=h.useState(!1);return o.jsxs("div",{className:"relative",children:[o.jsxs("button",{onClick:()=>n(e=>!e),className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-accent/10 border border-accent/20 text-xs font-medium text-accent hover:bg-accent/15 transition-colors",children:[o.jsx(Ml,{className:"w-3 h-3"}),"v",e.latest," available"]}),t&&o.jsxs("div",{className:"absolute right-0 top-full mt-2 z-50 w-72 rounded-lg bg-bg-surface-1 border border-border shadow-lg p-3 space-y-2",children:[o.jsxs("p",{className:"text-xs text-text-muted",children:["Update from ",o.jsxs("span",{className:"font-mono text-text-secondary",children:["v",e.current]})," to ",o.jsxs("span",{className:"font-mono text-accent",children:["v",e.latest]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("code",{className:"flex-1 text-[11px] font-mono bg-bg-base px-2 py-1.5 rounded border border-border text-text-secondary truncate",children:bd}),o.jsx("button",{onClick:async()=>{try{await navigator.clipboard.writeText(bd),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},className:"p-1.5 rounded-md border border-border bg-bg-base text-text-muted hover:text-text-primary hover:border-text-muted/50 transition-colors shrink-0",title:"Copy command",children:r?o.jsx(jl,{className:"w-3.5 h-3.5 text-success"}):o.jsx(Al,{className:"w-3.5 h-3.5"})})]})]})]})}function kd({health:e,updateInfo:t,onSearchOpen:n,activeTab:r,onTabChange:a,config:s,onRefresh:i}){const l=h.useRef(null),c=h.useMemo(()=>{if(s?.username)return[{label:"Leaderboard",href:"https://useai.dev/leaderboard"},{label:"Profile",href:\`https://useai.dev/\${s.username}\`}]},[s?.username]);return o.jsx("header",{className:"sticky top-0 z-50 bg-bg-base/80 backdrop-blur-md border-b border-border mb-6",children:o.jsxs("div",{className:"max-w-[1240px] mx-auto px-4 sm:px-6 py-3 flex items-center justify-between relative",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(ud,{className:"h-6"}),e&&e.active_sessions>0&&o.jsx(Mu,{label:\`\${e.active_sessions} active session\${1!==e.active_sessions?"s":""}\`,color:"success",dot:!0})]}),o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:o.jsx(cu,{activeTab:r,onTabChange:a,externalLinks:c})}),o.jsxs("div",{className:"flex items-center gap-4",children:[s?.authenticated&&!s?.username&&o.jsxs("button",{onClick:()=>l.current?.open(),className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-accent/10 border border-accent/25 text-[11px] font-medium text-accent hover:bg-accent/15 transition-colors cursor-pointer",children:[o.jsx(sc,{className:"w-3 h-3"}),"Claim your username"]}),n&&o.jsxs("button",{onClick:n,className:"flex items-center gap-2 px-2.5 py-1.5 rounded-md border border-border/50 bg-bg-surface-1 text-text-muted hover:text-text-primary hover:border-text-muted/50 transition-colors text-xs",children:[o.jsx(nc,{className:"w-3 h-3"}),o.jsx("span",{className:"hidden sm:inline",children:"Search"}),o.jsx("kbd",{className:"hidden sm:inline-flex items-center px-1 py-0.5 rounded border border-border bg-bg-base text-[9px] font-mono leading-none",children:"\u2318K"})]}),t?.update_available&&o.jsx(wd,{updateInfo:t}),o.jsx(xd,{ref:l,config:s,onRefresh:i})]})]})})}function Sd({label:e,description:t,checked:n,onChange:r,warning:a}){return o.jsxs("label",{className:"flex items-start justify-between gap-3 py-2 cursor-pointer group",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium text-text-primary",children:e}),o.jsx("div",{className:"text-[11px] text-text-muted leading-relaxed mt-0.5",children:t}),a&&n&&o.jsxs("div",{className:"flex items-center gap-1 mt-1 text-[11px] text-warning",children:[o.jsx(cc,{className:"w-3 h-3 shrink-0"}),a]})]}),o.jsx("button",{role:"switch","aria-checked":n,onClick:()=>r(!n),className:\`\\n relative inline-flex h-5 w-9 shrink-0 rounded-full border-2 border-transparent transition-colors duration-200\\n \${n?"bg-text-muted":"bg-bg-surface-2"}\\n \`,children:o.jsx("span",{className:\`\\n pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform duration-200\\n \${n?"translate-x-4":"translate-x-0"}\\n \`})})]})}function jd({label:e,description:t,value:n,options:r,onChange:a}){return o.jsxs("div",{className:"flex items-start justify-between gap-3 py-2",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium text-text-primary",children:e}),o.jsx("div",{className:"text-[11px] text-text-muted leading-relaxed mt-0.5",children:t})]}),o.jsxs("div",{className:"relative",children:[o.jsx("select",{value:n,onChange:e=>a(e.target.value),className:"appearance-none bg-bg-surface-2 border border-border/50 rounded-md px-2.5 py-1 pr-7 text-xs text-text-primary cursor-pointer hover:border-border transition-colors",children:r.map(e=>o.jsx("option",{value:e.value,children:e.label},e.value))}),o.jsx(Cl,{className:"absolute right-1.5 top-1/2 -translate-y-1/2 w-3 h-3 text-text-muted pointer-events-none"})]})]})}function Cd(){const[e,t]=h.useState(null),[n,r]=h.useState(null),[a,s]=h.useState("idle"),[i,l]=h.useState(null),[c,u]=h.useState(null);h.useEffect(()=>{_("/api/local/config/full").then(e=>{t(e),r(structuredClone(e))}).catch(e=>u(e.message))},[]);const d=!(!e||!n)&&(f=e,p=n,!(JSON.stringify(f)===JSON.stringify(p)));var f,p;const m=h.useCallback(async()=>{if(n&&e){s("saving"),l(null);try{const e=await(a={capture:n.capture,sync:n.sync,evaluation_framework:n.evaluation_framework},R("/api/local/config",a)),{instructions_updated:i,...o}=e;t(o),r(structuredClone(o)),l(i??[]),s("saved"),setTimeout(()=>s("idle"),3e3)}catch{s("error"),setTimeout(()=>s("idle"),3e3)}var a}},[n,e]),g=h.useCallback(()=>{e&&r(structuredClone(e))},[e]),y=h.useCallback(e=>{r(t=>t?{...t,capture:{...t.capture,...e}}:t)},[]),v=h.useCallback(e=>{r(t=>t?{...t,sync:{...t.sync,...e}}:t)},[]),x=h.useCallback(e=>{r(t=>t?{...t,evaluation_framework:e}:t)},[]);return c?o.jsx("div",{className:"max-w-xl mx-auto mt-12 text-center",children:o.jsxs("div",{className:"text-sm text-danger",children:["Failed to load config: ",c]})}):n?o.jsxs("div",{className:"max-w-xl mx-auto pt-2 pb-12 space-y-5",children:[o.jsxs("section",{className:"bg-bg-surface-1 border border-border/50 rounded-xl p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx(kl,{className:"w-4 h-4 text-text-muted"}),o.jsx("h2",{className:"text-xs font-bold text-text-muted uppercase tracking-widest",children:"Capture"})]}),o.jsx("p",{className:"text-[11px] text-text-muted mb-3",children:"What data to record locally for each session."}),o.jsxs("div",{className:"divide-y divide-border/30",children:[o.jsx(Sd,{label:"Prompts",description:"Record prompt word count and content metadata",checked:n.capture.prompt,onChange:e=>y({prompt:e})}),o.jsx(Sd,{label:"Prompt images",description:"Record image descriptions from prompts",checked:n.capture.prompt_images,onChange:e=>y({prompt_images:e})}),o.jsx(Sd,{label:"Evaluation scores",description:"Record session quality scores (SPACE framework)",checked:n.capture.evaluation,onChange:e=>y({evaluation:e})}),o.jsx(jd,{label:"Evaluation reasons",description:"When to include reason text for each score",value:n.capture.evaluation_reasons,options:[{value:"all",label:"All scores"},{value:"below_perfect",label:"Below perfect only"},{value:"none",label:"None"}],onChange:e=>y({evaluation_reasons:e})}),o.jsx(Sd,{label:"Milestones",description:"Record milestones (accomplishments) from each session",checked:n.capture.milestones,onChange:e=>y({milestones:e})})]})]}),o.jsxs("section",{className:"bg-bg-surface-1 border border-border/50 rounded-xl p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx(Sl,{className:"w-4 h-4 text-text-muted"}),o.jsx("h2",{className:"text-xs font-bold text-text-muted uppercase tracking-widest",children:"Evaluation"})]}),o.jsx("p",{className:"text-[11px] text-text-muted mb-3",children:"How sessions are scored."}),o.jsx(jd,{label:"Framework",description:"Scoring method used for session evaluations",value:n.evaluation_framework,options:[{value:"space",label:"SPACE (weighted)"},{value:"raw",label:"Raw (equal weight)"}],onChange:x})]}),o.jsxs("section",{className:"bg-bg-surface-1 border border-border/50 rounded-xl p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[o.jsx(Ll,{className:"w-4 h-4 text-text-muted"}),o.jsx("h2",{className:"text-xs font-bold text-text-muted uppercase tracking-widest",children:"Cloud Sync"})]}),o.jsxs("p",{className:"text-[11px] text-text-muted mb-3",children:["Sync session data to useai.dev for leaderboards and public profiles.",!n.authenticated&&" Login first to enable sync."]}),o.jsxs("div",{className:"divide-y divide-border/30",children:[o.jsx(Sd,{label:"Auto-sync",description:"Automatically sync data on a schedule",checked:n.sync.enabled,onChange:e=>v({enabled:e})}),n.sync.enabled&&o.jsx(o.Fragment,{children:o.jsx(jd,{label:"Sync interval",description:"How often to sync data",value:String(n.sync.interval_hours),options:[{value:"0.25",label:"Every 15 minutes"},{value:"0.5",label:"Every 30 minutes"},{value:"1",label:"Every hour"},{value:"2",label:"Every 2 hours"},{value:"3",label:"Every 3 hours"},{value:"6",label:"Every 6 hours"},{value:"12",label:"Every 12 hours"},{value:"24",label:"Every 24 hours"}],onChange:e=>v({interval_hours:Number(e)})})})]})]}),d&&o.jsxs("div",{className:"sticky bottom-4 flex items-center justify-between gap-3 bg-bg-surface-1 border border-border/50 rounded-xl px-4 py-3 shadow-lg",children:[o.jsx("div",{className:"text-xs text-text-muted",children:"saved"===a&&i?\`Saved. Updated instructions in \${i.length} tool\${1!==i.length?"s":""}: \${i.join(", ")||"none installed"}\`:"error"===a?"Failed to save. Try again.":"You have unsaved changes"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:g,disabled:"saving"===a,className:"px-3 py-1.5 rounded-md text-xs font-medium text-text-muted hover:text-text-primary border border-border/50 hover:border-border transition-colors disabled:opacity-50",children:"Discard"}),o.jsxs("button",{onClick:m,disabled:"saving"===a,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-accent text-bg-base hover:bg-accent/90 transition-colors disabled:opacity-50",children:["saving"===a?o.jsx(Wl,{className:"w-3 h-3 animate-spin"}):"saved"===a?o.jsx(jl,{className:"w-3 h-3"}):o.jsx(tc,{className:"w-3 h-3"}),"saving"===a?"Saving...":"saved"===a?"Saved":"Save"]})]})]})]}):o.jsx("div",{className:"max-w-xl mx-auto mt-12 text-center",children:o.jsx("div",{className:"text-sm text-text-muted",children:"Loading settings..."})})}function Nd(){const{sessions:e,milestones:t,config:n,health:r,updateInfo:a,loading:s,loadAll:i,loadHealth:l,loadUpdateCheck:c,deleteSession:u,deleteConversation:d,deleteMilestone:f,activeTab:p,setActiveTab:m}=pd();h.useEffect(()=>{i(),l(),c()},[i,l,c]),h.useEffect(()=>{const e=setInterval(l,3e4),t=setInterval(i,3e4);return()=>{clearInterval(e),clearInterval(t)}},[i,l]);const[g,y]=h.useState(!1);return h.useEffect(()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),y(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),s?o.jsx("div",{className:"min-h-screen flex items-center justify-center",children:o.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."})}):o.jsxs("div",{className:"min-h-screen bg-bg-base selection:bg-accent/30 selection:text-text-primary",children:[o.jsx(kd,{health:r,updateInfo:a,onSearchOpen:()=>y(!0),activeTab:p,onTabChange:m,config:n,onRefresh:i}),o.jsx("div",{className:"max-w-[1240px] mx-auto px-4 sm:px-6 pb-6",children:"settings"===p?o.jsx(Cd,{}):o.jsxs(o.Fragment,{children:[o.jsx(hd,{open:g,onClose:()=>y(!1),sessions:e,milestones:t,onDeleteSession:u,onDeleteConversation:d,onDeleteMilestone:f}),o.jsx(cd,{sessions:e,milestones:t,onDeleteSession:u,onDeleteConversation:d,onDeleteMilestone:f,activeTab:p,onActiveTabChange:m})]})})]})}P.createRoot(document.getElementById("root")).render(o.jsx(h.StrictMode,{children:o.jsx(Nd,{})}));</script>
34800
34391
  <style rel="stylesheet" crossorigin>/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial}}}@layer theme{:root,:host{--font-sans:"Inter",system-ui,-apple-system,sans-serif;--font-mono:"Geist Mono","JetBrains Mono","SF Mono","Fira Code",ui-monospace,monospace;--color-orange-500:oklch(70.5% .213 47.604);--color-amber-500:oklch(76.9% .188 70.08);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-md:28rem;--container-xl:36rem;--container-2xl:42rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--font-weight-black:900;--tracking-tighter:-.05em;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-tight:1.25;--leading-snug:1.375;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-sm:8px;--blur-md:12px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bg-base:var(--bg-base);--color-bg-surface-1:var(--bg-surface-1);--color-bg-surface-2:var(--bg-surface-2);--color-bg-surface-3:var(--bg-surface-3);--color-text-primary:var(--text-primary);--color-text-secondary:var(--text-secondary);--color-text-muted:var(--text-muted);--color-accent:var(--accent);--color-accent-bright:var(--accent-bright);--color-success:var(--success);--color-error:var(--error);--color-history:var(--history);--color-border:var(--border);--color-purple:#8b5cf6;--color-blue:#3b82f6;--color-emerald:#34d399}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:var(--color-border)}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing)*0)}.-top-10{top:calc(var(--spacing)*-10)}.top-0{top:calc(var(--spacing)*0)}.top-1\\/2{top:50%}.top-2{top:calc(var(--spacing)*2)}.top-5{top:calc(var(--spacing)*5)}.top-full{top:100%}.-right-0\\.5{right:calc(var(--spacing)*-.5)}.right-0{right:calc(var(--spacing)*0)}.right-1\\.5{right:calc(var(--spacing)*1.5)}.-bottom-0\\.5{bottom:calc(var(--spacing)*-.5)}.-bottom-1{bottom:calc(var(--spacing)*-1)}.-bottom-1\\.5{bottom:calc(var(--spacing)*-1.5)}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-2{bottom:calc(var(--spacing)*2)}.bottom-4{bottom:calc(var(--spacing)*4)}.-left-7{left:calc(var(--spacing)*-7)}.left-1\\/2{left:50%}.left-2{left:calc(var(--spacing)*2)}.left-\\[1\\.75rem\\]{left:1.75rem}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-\\[60\\]{z-index:60}.z-\\[61\\]{z-index:61}.z-\\[9999\\]{z-index:9999}.col-span-2{grid-column:span 2/span 2}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.mx-1{margin-inline:calc(var(--spacing)*1)}.mx-auto{margin-inline:auto}.my-0\\.5{margin-block:calc(var(--spacing)*.5)}.my-1{margin-block:calc(var(--spacing)*1)}.ms-1{margin-inline-start:calc(var(--spacing)*1)}.ms-2{margin-inline-start:calc(var(--spacing)*2)}.ms-3{margin-inline-start:calc(var(--spacing)*3)}.mt-0\\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-12{margin-top:calc(var(--spacing)*12)}.mb-0\\.5{margin-bottom:calc(var(--spacing)*.5)}.mb-1\\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.-ml-2{margin-left:calc(var(--spacing)*-2)}.ml-0\\.5{margin-left:calc(var(--spacing)*.5)}.ml-1\\.5{margin-left:calc(var(--spacing)*1.5)}.ml-auto{margin-left:auto}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.h-1\\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-2\\.5{height:calc(var(--spacing)*2.5)}.h-3{height:calc(var(--spacing)*3)}.h-3\\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-9{height:calc(var(--spacing)*9)}.h-16{height:calc(var(--spacing)*16)}.h-full{height:100%}.h-px{height:1px}.max-h-\\[75vh\\]{max-height:75vh}.min-h-screen{min-height:100vh}.w-0{width:calc(var(--spacing)*0)}.w-1\\.5{width:calc(var(--spacing)*1.5)}.w-2{width:calc(var(--spacing)*2)}.w-2\\.5{width:calc(var(--spacing)*2.5)}.w-3{width:calc(var(--spacing)*3)}.w-3\\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-12{width:calc(var(--spacing)*12)}.w-16{width:calc(var(--spacing)*16)}.w-24{width:calc(var(--spacing)*24)}.w-28{width:calc(var(--spacing)*28)}.w-72{width:calc(var(--spacing)*72)}.w-80{width:calc(var(--spacing)*80)}.w-\\[2px\\]{width:2px}.w-\\[155px\\]{width:155px}.w-full{width:100%}.w-px{width:1px}.max-w-2xl{max-width:var(--container-2xl)}.max-w-\\[130px\\]{max-width:130px}.max-w-\\[140px\\]{max-width:140px}.max-w-\\[280px\\]{max-width:280px}.max-w-\\[1240px\\]{max-width:1240px}.max-w-md{max-width:var(--container-md)}.max-w-xl{max-width:var(--container-xl)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-\\[100px\\]{min-width:100px}.min-w-\\[120px\\]{min-width:120px}.min-w-\\[180px\\]{min-width:180px}.flex-1{flex:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.grow{flex-grow:1}.origin-bottom{transform-origin:bottom}.-translate-x-1\\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-4{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.scale-105{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.rotate-45{rotate:45deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-pointer{cursor:pointer}.cursor-text{cursor:text}.touch-none{touch-action:none}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-\\[86px_minmax\\(0\\,1fr\\)\\]{grid-template-columns:86px minmax(0,1fr)}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-2\\.5{gap:calc(var(--spacing)*2.5)}.gap-3{gap:calc(var(--spacing)*3)}.gap-3\\.5{gap:calc(var(--spacing)*3.5)}.gap-4{gap:calc(var(--spacing)*4)}.gap-6{gap:calc(var(--spacing)*6)}.gap-\\[3px\\]{gap:3px}:where(.space-y-0\\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2\\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*5)*calc(1 - var(--tw-space-y-reverse)))}.gap-x-2{column-gap:calc(var(--spacing)*2)}.gap-x-5{column-gap:calc(var(--spacing)*5)}.gap-y-1{row-gap:calc(var(--spacing)*1)}.gap-y-2{row-gap:calc(var(--spacing)*2)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-border\\/30>:not(:last-child)){border-color:var(--color-border)}@supports (color:color-mix(in lab,red,red)){:where(.divide-border\\/30>:not(:last-child)){border-color:color-mix(in oklab,var(--color-border)30%,transparent)}}.self-center{align-self:center}.self-stretch{align-self:stretch}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overscroll-contain{overscroll-behavior:contain}.overscroll-none{overscroll-behavior:none}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-md{border-top-left-radius:var(--radius-md);border-top-right-radius:var(--radius-md)}.rounded-t-sm{border-top-left-radius:var(--radius-sm);border-top-right-radius:var(--radius-sm)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-accent,.border-accent\\/20{border-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.border-accent\\/20{border-color:color-mix(in oklab,var(--color-accent)20%,transparent)}}.border-accent\\/25{border-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.border-accent\\/25{border-color:color-mix(in oklab,var(--color-accent)25%,transparent)}}.border-accent\\/30{border-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.border-accent\\/30{border-color:color-mix(in oklab,var(--color-accent)30%,transparent)}}.border-accent\\/35{border-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.border-accent\\/35{border-color:color-mix(in oklab,var(--color-accent)35%,transparent)}}.border-accent\\/50{border-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.border-accent\\/50{border-color:color-mix(in oklab,var(--color-accent)50%,transparent)}}.border-bg-base{border-color:var(--color-bg-base)}.border-bg-surface-1{border-color:var(--color-bg-surface-1)}.border-blue\\/20{border-color:#3b82f633}@supports (color:color-mix(in lab,red,red)){.border-blue\\/20{border-color:color-mix(in oklab,var(--color-blue)20%,transparent)}}.border-blue\\/30{border-color:#3b82f64d}@supports (color:color-mix(in lab,red,red)){.border-blue\\/30{border-color:color-mix(in oklab,var(--color-blue)30%,transparent)}}.border-border,.border-border\\/10{border-color:var(--color-border)}@supports (color:color-mix(in lab,red,red)){.border-border\\/10{border-color:color-mix(in oklab,var(--color-border)10%,transparent)}}.border-border\\/15{border-color:var(--color-border)}@supports (color:color-mix(in lab,red,red)){.border-border\\/15{border-color:color-mix(in oklab,var(--color-border)15%,transparent)}}.border-border\\/20{border-color:var(--color-border)}@supports (color:color-mix(in lab,red,red)){.border-border\\/20{border-color:color-mix(in oklab,var(--color-border)20%,transparent)}}.border-border\\/30{border-color:var(--color-border)}@supports (color:color-mix(in lab,red,red)){.border-border\\/30{border-color:color-mix(in oklab,var(--color-border)30%,transparent)}}.border-border\\/40{border-color:var(--color-border)}@supports (color:color-mix(in lab,red,red)){.border-border\\/40{border-color:color-mix(in oklab,var(--color-border)40%,transparent)}}.border-border\\/50{border-color:var(--color-border)}@supports (color:color-mix(in lab,red,red)){.border-border\\/50{border-color:color-mix(in oklab,var(--color-border)50%,transparent)}}.border-border\\/60{border-color:var(--color-border)}@supports (color:color-mix(in lab,red,red)){.border-border\\/60{border-color:color-mix(in oklab,var(--color-border)60%,transparent)}}.border-emerald\\/20{border-color:#34d39933}@supports (color:color-mix(in lab,red,red)){.border-emerald\\/20{border-color:color-mix(in oklab,var(--color-emerald)20%,transparent)}}.border-emerald\\/30{border-color:#34d3994d}@supports (color:color-mix(in lab,red,red)){.border-emerald\\/30{border-color:color-mix(in oklab,var(--color-emerald)30%,transparent)}}.border-error\\/20{border-color:var(--color-error)}@supports (color:color-mix(in lab,red,red)){.border-error\\/20{border-color:color-mix(in oklab,var(--color-error)20%,transparent)}}.border-error\\/30{border-color:var(--color-error)}@supports (color:color-mix(in lab,red,red)){.border-error\\/30{border-color:color-mix(in oklab,var(--color-error)30%,transparent)}}.border-history,.border-history\\/20{border-color:var(--color-history)}@supports (color:color-mix(in lab,red,red)){.border-history\\/20{border-color:color-mix(in oklab,var(--color-history)20%,transparent)}}.border-purple\\/20{border-color:#8b5cf633}@supports (color:color-mix(in lab,red,red)){.border-purple\\/20{border-color:color-mix(in oklab,var(--color-purple)20%,transparent)}}.border-purple\\/30{border-color:#8b5cf64d}@supports (color:color-mix(in lab,red,red)){.border-purple\\/30{border-color:color-mix(in oklab,var(--color-purple)30%,transparent)}}.border-success\\/20{border-color:var(--color-success)}@supports (color:color-mix(in lab,red,red)){.border-success\\/20{border-color:color-mix(in oklab,var(--color-success)20%,transparent)}}.border-success\\/30{border-color:var(--color-success)}@supports (color:color-mix(in lab,red,red)){.border-success\\/30{border-color:color-mix(in oklab,var(--color-success)30%,transparent)}}.border-text-muted\\/20{border-color:var(--color-text-muted)}@supports (color:color-mix(in lab,red,red)){.border-text-muted\\/20{border-color:color-mix(in oklab,var(--color-text-muted)20%,transparent)}}.border-transparent{border-color:#0000}.bg-\\[var\\(--accent-alpha\\)\\]{background-color:var(--accent-alpha)}.bg-accent,.bg-accent\\/5{background-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.bg-accent\\/5{background-color:color-mix(in oklab,var(--color-accent)5%,transparent)}}.bg-accent\\/8{background-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.bg-accent\\/8{background-color:color-mix(in oklab,var(--color-accent)8%,transparent)}}.bg-accent\\/10{background-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.bg-accent\\/10{background-color:color-mix(in oklab,var(--color-accent)10%,transparent)}}.bg-accent\\/15{background-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.bg-accent\\/15{background-color:color-mix(in oklab,var(--color-accent)15%,transparent)}}.bg-accent\\/30{background-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.bg-accent\\/30{background-color:color-mix(in oklab,var(--color-accent)30%,transparent)}}.bg-accent\\/50{background-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.bg-accent\\/50{background-color:color-mix(in oklab,var(--color-accent)50%,transparent)}}.bg-accent\\/60{background-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.bg-accent\\/60{background-color:color-mix(in oklab,var(--color-accent)60%,transparent)}}.bg-bg-base,.bg-bg-base\\/30{background-color:var(--color-bg-base)}@supports (color:color-mix(in lab,red,red)){.bg-bg-base\\/30{background-color:color-mix(in oklab,var(--color-bg-base)30%,transparent)}}.bg-bg-base\\/80{background-color:var(--color-bg-base)}@supports (color:color-mix(in lab,red,red)){.bg-bg-base\\/80{background-color:color-mix(in oklab,var(--color-bg-base)80%,transparent)}}.bg-bg-surface-1,.bg-bg-surface-1\\/30{background-color:var(--color-bg-surface-1)}@supports (color:color-mix(in lab,red,red)){.bg-bg-surface-1\\/30{background-color:color-mix(in oklab,var(--color-bg-surface-1)30%,transparent)}}.bg-bg-surface-1\\/35{background-color:var(--color-bg-surface-1)}@supports (color:color-mix(in lab,red,red)){.bg-bg-surface-1\\/35{background-color:color-mix(in oklab,var(--color-bg-surface-1)35%,transparent)}}.bg-bg-surface-1\\/50{background-color:var(--color-bg-surface-1)}@supports (color:color-mix(in lab,red,red)){.bg-bg-surface-1\\/50{background-color:color-mix(in oklab,var(--color-bg-surface-1)50%,transparent)}}.bg-bg-surface-1\\/80{background-color:var(--color-bg-surface-1)}@supports (color:color-mix(in lab,red,red)){.bg-bg-surface-1\\/80{background-color:color-mix(in oklab,var(--color-bg-surface-1)80%,transparent)}}.bg-bg-surface-2,.bg-bg-surface-2\\/20{background-color:var(--color-bg-surface-2)}@supports (color:color-mix(in lab,red,red)){.bg-bg-surface-2\\/20{background-color:color-mix(in oklab,var(--color-bg-surface-2)20%,transparent)}}.bg-bg-surface-2\\/30{background-color:var(--color-bg-surface-2)}@supports (color:color-mix(in lab,red,red)){.bg-bg-surface-2\\/30{background-color:color-mix(in oklab,var(--color-bg-surface-2)30%,transparent)}}.bg-bg-surface-2\\/50{background-color:var(--color-bg-surface-2)}@supports (color:color-mix(in lab,red,red)){.bg-bg-surface-2\\/50{background-color:color-mix(in oklab,var(--color-bg-surface-2)50%,transparent)}}.bg-bg-surface-3,.bg-bg-surface-3\\/95{background-color:var(--color-bg-surface-3)}@supports (color:color-mix(in lab,red,red)){.bg-bg-surface-3\\/95{background-color:color-mix(in oklab,var(--color-bg-surface-3)95%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\\/40{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-blue\\/10{background-color:#3b82f61a}@supports (color:color-mix(in lab,red,red)){.bg-blue\\/10{background-color:color-mix(in oklab,var(--color-blue)10%,transparent)}}.bg-blue\\/15{background-color:#3b82f626}@supports (color:color-mix(in lab,red,red)){.bg-blue\\/15{background-color:color-mix(in oklab,var(--color-blue)15%,transparent)}}.bg-border\\/20{background-color:var(--color-border)}@supports (color:color-mix(in lab,red,red)){.bg-border\\/20{background-color:color-mix(in oklab,var(--color-border)20%,transparent)}}.bg-border\\/30{background-color:var(--color-border)}@supports (color:color-mix(in lab,red,red)){.bg-border\\/30{background-color:color-mix(in oklab,var(--color-border)30%,transparent)}}.bg-border\\/50{background-color:var(--color-border)}@supports (color:color-mix(in lab,red,red)){.bg-border\\/50{background-color:color-mix(in oklab,var(--color-border)50%,transparent)}}.bg-border\\/60{background-color:var(--color-border)}@supports (color:color-mix(in lab,red,red)){.bg-border\\/60{background-color:color-mix(in oklab,var(--color-border)60%,transparent)}}.bg-emerald\\/10{background-color:#34d3991a}@supports (color:color-mix(in lab,red,red)){.bg-emerald\\/10{background-color:color-mix(in oklab,var(--color-emerald)10%,transparent)}}.bg-emerald\\/15{background-color:#34d39926}@supports (color:color-mix(in lab,red,red)){.bg-emerald\\/15{background-color:color-mix(in oklab,var(--color-emerald)15%,transparent)}}.bg-error\\/10{background-color:var(--color-error)}@supports (color:color-mix(in lab,red,red)){.bg-error\\/10{background-color:color-mix(in oklab,var(--color-error)10%,transparent)}}.bg-error\\/15{background-color:var(--color-error)}@supports (color:color-mix(in lab,red,red)){.bg-error\\/15{background-color:color-mix(in oklab,var(--color-error)15%,transparent)}}.bg-history,.bg-history\\/10{background-color:var(--color-history)}@supports (color:color-mix(in lab,red,red)){.bg-history\\/10{background-color:color-mix(in oklab,var(--color-history)10%,transparent)}}.bg-purple\\/10{background-color:#8b5cf61a}@supports (color:color-mix(in lab,red,red)){.bg-purple\\/10{background-color:color-mix(in oklab,var(--color-purple)10%,transparent)}}.bg-purple\\/15{background-color:#8b5cf626}@supports (color:color-mix(in lab,red,red)){.bg-purple\\/15{background-color:color-mix(in oklab,var(--color-purple)15%,transparent)}}.bg-success,.bg-success\\/10{background-color:var(--color-success)}@supports (color:color-mix(in lab,red,red)){.bg-success\\/10{background-color:color-mix(in oklab,var(--color-success)10%,transparent)}}.bg-success\\/15{background-color:var(--color-success)}@supports (color:color-mix(in lab,red,red)){.bg-success\\/15{background-color:color-mix(in oklab,var(--color-success)15%,transparent)}}.bg-text-muted,.bg-text-muted\\/10{background-color:var(--color-text-muted)}@supports (color:color-mix(in lab,red,red)){.bg-text-muted\\/10{background-color:color-mix(in oklab,var(--color-text-muted)10%,transparent)}}.bg-text-muted\\/15{background-color:var(--color-text-muted)}@supports (color:color-mix(in lab,red,red)){.bg-text-muted\\/15{background-color:color-mix(in oklab,var(--color-text-muted)15%,transparent)}}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.bg-gradient-to-t{--tw-gradient-position:to top in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-transparent{--tw-gradient-from:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-white\\/10{--tw-gradient-to:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.to-white\\/10{--tw-gradient-to:color-mix(in oklab,var(--color-white)10%,transparent)}}.to-white\\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.p-0\\.5{padding:calc(var(--spacing)*.5)}.p-1{padding:calc(var(--spacing)*1)}.p-1\\.5{padding:calc(var(--spacing)*1.5)}.p-2{padding:calc(var(--spacing)*2)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.px-0\\.5{padding-inline:calc(var(--spacing)*.5)}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-2\\.5{padding-inline:calc(var(--spacing)*2.5)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-3\\.5{padding-inline:calc(var(--spacing)*3.5)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.px-px{padding-inline:1px}.py-0\\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.pt-0\\.5{padding-top:calc(var(--spacing)*.5)}.pt-1\\.5{padding-top:calc(var(--spacing)*1.5)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-\\[10vh\\]{padding-top:10vh}.pr-7{padding-right:calc(var(--spacing)*7)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-2\\.5{padding-bottom:calc(var(--spacing)*2.5)}.pb-3\\.5{padding-bottom:calc(var(--spacing)*3.5)}.pb-6{padding-bottom:calc(var(--spacing)*6)}.pb-12{padding-bottom:calc(var(--spacing)*12)}.pl-3{padding-left:calc(var(--spacing)*3)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[7px\\]{font-size:7px}.text-\\[8px\\]{font-size:8px}.text-\\[9px\\]{font-size:9px}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.text-\\[15px\\]{font-size:15px}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-black{--tw-font-weight:var(--font-weight-black);font-weight:var(--font-weight-black)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-tighter{--tw-tracking:var(--tracking-tighter);letter-spacing:var(--tracking-tighter)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-words{overflow-wrap:break-word}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-accent,.text-accent\\/70{color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.text-accent\\/70{color:color-mix(in oklab,var(--color-accent)70%,transparent)}}.text-accent\\/90{color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.text-accent\\/90{color:color-mix(in oklab,var(--color-accent)90%,transparent)}}.text-amber-500{color:var(--color-amber-500)}.text-bg-base{color:var(--color-bg-base)}.text-blue{color:var(--color-blue)}.text-emerald{color:var(--color-emerald)}.text-error,.text-error\\/80{color:var(--color-error)}@supports (color:color-mix(in lab,red,red)){.text-error\\/80{color:color-mix(in oklab,var(--color-error)80%,transparent)}}.text-history{color:var(--color-history)}.text-inherit{color:inherit}.text-orange-500{color:var(--color-orange-500)}.text-purple{color:var(--color-purple)}.text-success,.text-success\\/70{color:var(--color-success)}@supports (color:color-mix(in lab,red,red)){.text-success\\/70{color:color-mix(in oklab,var(--color-success)70%,transparent)}}.text-text-muted,.text-text-muted\\/30{color:var(--color-text-muted)}@supports (color:color-mix(in lab,red,red)){.text-text-muted\\/30{color:color-mix(in oklab,var(--color-text-muted)30%,transparent)}}.text-text-muted\\/50{color:var(--color-text-muted)}@supports (color:color-mix(in lab,red,red)){.text-text-muted\\/50{color:color-mix(in oklab,var(--color-text-muted)50%,transparent)}}.text-text-muted\\/60{color:var(--color-text-muted)}@supports (color:color-mix(in lab,red,red)){.text-text-muted\\/60{color:color-mix(in oklab,var(--color-text-muted)60%,transparent)}}.text-text-muted\\/70{color:var(--color-text-muted)}@supports (color:color-mix(in lab,red,red)){.text-text-muted\\/70{color:color-mix(in oklab,var(--color-text-muted)70%,transparent)}}.text-text-primary{color:var(--color-text-primary)}.text-text-secondary,.text-text-secondary\\/80{color:var(--color-text-secondary)}@supports (color:color-mix(in lab,red,red)){.text-text-secondary\\/80{color:color-mix(in oklab,var(--color-text-secondary)80%,transparent)}}.text-text-secondary\\/85{color:var(--color-text-secondary)}@supports (color:color-mix(in lab,red,red)){.text-text-secondary\\/85{color:color-mix(in oklab,var(--color-text-secondary)85%,transparent)}}.text-white{color:var(--color-white)}.capitalize{text-transform:capitalize}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-inner{--tw-shadow:inset 0 2px 4px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-accent{--tw-ring-color:var(--color-accent)}.ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-bg-base{--tw-ring-offset-color:var(--color-bg-base)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.backdrop-blur-md{--tw-backdrop-blur:blur(var(--blur-md));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.\\[daemon\\:err\\]{daemon:err}@media(hover:hover){.group-hover\\:scale-x-110:is(:where(.group):hover *){--tw-scale-x:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.group-hover\\:-rotate-90:is(:where(.group):hover *){rotate:-90deg}.group-hover\\:bg-accent:is(:where(.group):hover *),.group-hover\\:bg-accent\\/10:is(:where(.group):hover *){background-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.group-hover\\:bg-accent\\/10:is(:where(.group):hover *){background-color:color-mix(in oklab,var(--color-accent)10%,transparent)}}.group-hover\\:text-accent:is(:where(.group):hover *){color:var(--color-accent)}.group-hover\\:text-text-primary:is(:where(.group):hover *){color:var(--color-text-primary)}.group-hover\\:opacity-100:is(:where(.group):hover *),.group-hover\\/card\\:opacity-100:is(:where(.group\\/card):hover *),.group-hover\\/conv\\:opacity-100:is(:where(.group\\/conv):hover *){opacity:1}}.selection\\:bg-accent\\/30 ::selection{background-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.selection\\:bg-accent\\/30 ::selection{background-color:color-mix(in oklab,var(--color-accent)30%,transparent)}}.selection\\:bg-accent\\/30::selection{background-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.selection\\:bg-accent\\/30::selection{background-color:color-mix(in oklab,var(--color-accent)30%,transparent)}}.selection\\:text-text-primary ::selection{color:var(--color-text-primary)}.selection\\:text-text-primary::selection{color:var(--color-text-primary)}.placeholder\\:text-text-muted\\/50::placeholder{color:var(--color-text-muted)}@supports (color:color-mix(in lab,red,red)){.placeholder\\:text-text-muted\\/50::placeholder{color:color-mix(in oklab,var(--color-text-muted)50%,transparent)}}.focus-within\\:border-accent\\/50:focus-within{border-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.focus-within\\:border-accent\\/50:focus-within{border-color:color-mix(in oklab,var(--color-accent)50%,transparent)}}.focus-within\\:opacity-100:focus-within{opacity:1}.focus-within\\:ring-1:focus-within{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-within\\:ring-accent\\/50:focus-within{--tw-ring-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.focus-within\\:ring-accent\\/50:focus-within{--tw-ring-color:color-mix(in oklab,var(--color-accent)50%,transparent)}}@media(hover:hover){.hover\\:scale-125:hover{--tw-scale-x:125%;--tw-scale-y:125%;--tw-scale-z:125%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\\:border-accent\\/30:hover{border-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.hover\\:border-accent\\/30:hover{border-color:color-mix(in oklab,var(--color-accent)30%,transparent)}}.hover\\:border-accent\\/40:hover{border-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.hover\\:border-accent\\/40:hover{border-color:color-mix(in oklab,var(--color-accent)40%,transparent)}}.hover\\:border-border:hover{border-color:var(--color-border)}.hover\\:border-text-muted\\/50:hover{border-color:var(--color-text-muted)}@supports (color:color-mix(in lab,red,red)){.hover\\:border-text-muted\\/50:hover{border-color:color-mix(in oklab,var(--color-text-muted)50%,transparent)}}.hover\\:bg-accent-bright:hover{background-color:var(--color-accent-bright)}.hover\\:bg-accent\\/15:hover{background-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-accent\\/15:hover{background-color:color-mix(in oklab,var(--color-accent)15%,transparent)}}.hover\\:bg-accent\\/90:hover{background-color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-accent\\/90:hover{background-color:color-mix(in oklab,var(--color-accent)90%,transparent)}}.hover\\:bg-bg-surface-1:hover{background-color:var(--color-bg-surface-1)}.hover\\:bg-bg-surface-2:hover,.hover\\:bg-bg-surface-2\\/40:hover{background-color:var(--color-bg-surface-2)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-bg-surface-2\\/40:hover{background-color:color-mix(in oklab,var(--color-bg-surface-2)40%,transparent)}}.hover\\:bg-bg-surface-2\\/50:hover{background-color:var(--color-bg-surface-2)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-bg-surface-2\\/50:hover{background-color:color-mix(in oklab,var(--color-bg-surface-2)50%,transparent)}}.hover\\:bg-bg-surface-3:hover{background-color:var(--color-bg-surface-3)}.hover\\:bg-error\\/5:hover{background-color:var(--color-error)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-error\\/5:hover{background-color:color-mix(in oklab,var(--color-error)5%,transparent)}}.hover\\:bg-error\\/10:hover{background-color:var(--color-error)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-error\\/10:hover{background-color:color-mix(in oklab,var(--color-error)10%,transparent)}}.hover\\:bg-error\\/25:hover{background-color:var(--color-error)}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-error\\/25:hover{background-color:color-mix(in oklab,var(--color-error)25%,transparent)}}.hover\\:bg-history:hover{background-color:var(--color-history)}.hover\\:text-accent:hover{color:var(--color-accent)}.hover\\:text-accent-bright:hover{color:var(--color-accent-bright)}.hover\\:text-accent\\/80:hover{color:var(--color-accent)}@supports (color:color-mix(in lab,red,red)){.hover\\:text-accent\\/80:hover{color:color-mix(in oklab,var(--color-accent)80%,transparent)}}.hover\\:text-error:hover,.hover\\:text-error\\/70:hover{color:var(--color-error)}@supports (color:color-mix(in lab,red,red)){.hover\\:text-error\\/70:hover{color:color-mix(in oklab,var(--color-error)70%,transparent)}}.hover\\:text-text-primary:hover{color:var(--color-text-primary)}.hover\\:text-white:hover{color:var(--color-white)}.hover\\:opacity-80:hover{opacity:.8}.hover\\:brightness-110:hover{--tw-brightness:brightness(110%);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}}.active\\:cursor-grabbing:active{cursor:grabbing}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-20:disabled{opacity:.2}.disabled\\:opacity-30:disabled{opacity:.3}.disabled\\:opacity-50:disabled{opacity:.5}@media(min-width:40rem){.sm\\:inline{display:inline}.sm\\:inline-flex{display:inline-flex}.sm\\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\\:flex-row{flex-direction:row}.sm\\:px-6{padding-inline:calc(var(--spacing)*6)}}@media(min-width:48rem){.md\\:block{display:block}.md\\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\\:flex-row{flex-direction:row}.md\\:items-center{align-items:center}}@media(min-width:64rem){.lg\\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.lg\\:grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}}}:root{--text-primary:#fafafa;--text-secondary:#a1a1aa;--text-muted:#71717a;--accent:#b4f82c;--accent-bright:#d4fc6e;--accent-dim:#4d7c0f;--accent-rgb:180,248,44;--success:#b4f82c;--error:#ef4444;--streak:#f59e0b;--streak-bg:#f59e0b0f;--streak-border:#f59e0b33;--streak-muted:#f59e0b80;--history:#60a5fa;--history-rgb:96,165,250;--glass-border:#ffffff0d;--grid-color:#ffffff14;--glow-opacity:.15;--glow-blue:#3b82f626;--shadow-glow:rgba(var(--accent-rgb),.1);--accent-alpha:rgba(var(--accent-rgb),.05)}@media(prefers-color-scheme:light){:root{--text-primary:#09090b;--text-secondary:#52525b;--text-muted:#5f6068;--accent:#65a30d;--accent-bright:#84cc16;--accent-dim:#f7fee7;--accent-rgb:101,163,13;--success:#65a30d;--error:#dc2626;--streak:#b45309;--streak-bg:#b453090f;--streak-border:#b4530933;--streak-muted:#b4530980;--history:#2563eb;--history-rgb:37,99,235;--glass-border:#0000000d;--grid-color:#0000000a;--glow-opacity:.25;--glow-blue:#3b82f640;--shadow-glow:#00000014;--accent-alpha:rgba(var(--accent-rgb),.15)}}::selection{background-color:rgba(var(--accent-rgb),.3);color:var(--accent-bright)}.glass-card{background:var(--glass-bg);-webkit-backdrop-filter:blur(12px);border:1px solid var(--glass-border);box-shadow:0 4px 6px -1px #0000001a,0 2px 4px -1px #0000000f}.glass-panel{background:var(--glass-bg);-webkit-backdrop-filter:blur(20px);border:1px solid var(--glass-border);will-change:transform,backdrop-filter;transform:translateZ(0);box-shadow:0 8px 32px #0000004d,inset 0 0 0 1px #ffffff0d}.hud-border{background:var(--bg-surface-1);position:relative}.hud-border:before{content:"";border:1px solid rgba(var(--accent-rgb),.2);pointer-events:none;border-radius:inherit;position:absolute;inset:0;-webkit-mask-image:linear-gradient(#000,#0000);mask-image:linear-gradient(#000,#0000)}.hud-border:after{content:"";border-top:2px solid var(--accent);border-left:2px solid var(--accent);border-top-left-radius:inherit;width:10px;height:10px;position:absolute;top:-1px;left:-1px}.gradient-text{background:linear-gradient(135deg,var(--text-primary),var(--text-secondary));-webkit-text-fill-color:transparent;-webkit-background-clip:text;background-clip:text}.gradient-text-accent{background:linear-gradient(135deg,var(--accent),var(--accent-bright));-webkit-text-fill-color:transparent;text-shadow:0 0 20px rgba(var(--accent-rgb),.4);-webkit-background-clip:text;background-clip:text}.subtle-glow{position:relative}.subtle-glow:after{content:"";background:linear-gradient(45deg,transparent,rgba(var(--accent-rgb),.1),transparent);border-radius:inherit;z-index:-1;pointer-events:none;position:absolute;inset:-1px}:root{--bg-base:#040405;--bg-surface-1:#0e0e11;--bg-surface-2:#18181b;--bg-surface-3:#27272a;--border:#ffffff14;--border-accent:rgba(var(--accent-rgb),.3);--glass-bg:#0e0e1199}@media(prefers-color-scheme:light){:root{--bg-base:#fafafa;--bg-surface-1:#fff;--bg-surface-2:#f4f4f5;--bg-surface-3:#e4e4e7;--border:#e4e4e7;--border-accent:rgba(var(--accent-rgb),.4);--glass-bg:#ffffffb3}}::-webkit-scrollbar{width:5px;height:5px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background:var(--color-bg-surface-3);border-radius:10px}::-webkit-scrollbar-thumb:hover{background:var(--color-text-muted)}body{font-family:var(--font-sans);background:var(--color-bg-base);color:var(--color-text-primary);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;min-height:100vh;margin:0;line-height:1.6}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"<length-percentage>";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"<length-percentage>";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"<length-percentage>";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}}</style>
34801
34392
  </head>
34802
34393
  <body>
@@ -36629,14 +36220,14 @@ var stdio_exports = {};
36629
36220
  __export(stdio_exports, {
36630
36221
  StdioServerTransport: () => StdioServerTransport
36631
36222
  });
36632
- import process3 from "process";
36223
+ import process2 from "process";
36633
36224
  var StdioServerTransport;
36634
36225
  var init_stdio2 = __esm({
36635
36226
  "../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.26.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js"() {
36636
36227
  "use strict";
36637
36228
  init_stdio();
36638
36229
  StdioServerTransport = class {
36639
- constructor(_stdin = process3.stdin, _stdout = process3.stdout) {
36230
+ constructor(_stdin = process2.stdin, _stdout = process2.stdout) {
36640
36231
  this._stdin = _stdin;
36641
36232
  this._stdout = _stdout;
36642
36233
  this._readBuffer = new ReadBuffer();
@@ -36698,6 +36289,7 @@ var init_stdio2 = __esm({
36698
36289
  });
36699
36290
 
36700
36291
  // src/index.ts
36292
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
36701
36293
  var command = process.argv[2];
36702
36294
  if (command === "mcp" || command?.startsWith("--")) {
36703
36295
  const args = command === "mcp" ? process.argv.slice(3) : process.argv.slice(2);
@@ -36723,23 +36315,22 @@ if (!command && process.stdin.isTTY) {
36723
36315
  }
36724
36316
  }
36725
36317
  if (command === "update") {
36726
- const { default: chalk2 } = await Promise.resolve().then(() => (init_source(), source_exports));
36727
36318
  const { fetchLatestVersion: fetchLatestVersion2, fetchDaemonHealth: fetchDaemonHealth2, killDaemon: killDaemon2, ensureDaemon: ensureDaemon2, installClaudeCodeHooks: installClaudeCodeHooks2, VERSION: VERSION3 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
36728
36319
  const { AI_TOOLS: AI_TOOLS2 } = await Promise.resolve().then(() => (init_tools2(), tools_exports));
36729
- console.log(chalk2.dim(" Checking for updates..."));
36320
+ console.log(import_picocolors2.default.dim(" Checking for updates..."));
36730
36321
  const latest = await fetchLatestVersion2();
36731
36322
  if (!latest) {
36732
- console.log(chalk2.red(" \u2717 Could not reach npm registry"));
36323
+ console.log(import_picocolors2.default.red(" \u2717 Could not reach npm registry"));
36733
36324
  process.exit(1);
36734
36325
  }
36735
36326
  const healthBefore = await fetchDaemonHealth2();
36736
36327
  const runningVersion = healthBefore?.version ?? VERSION3;
36737
36328
  if (runningVersion === latest && VERSION3 === latest) {
36738
- console.log(chalk2.green(` \u2713 Already up to date (v${latest})`));
36329
+ console.log(import_picocolors2.default.green(` \u2713 Already up to date (v${latest})`));
36739
36330
  process.exit(0);
36740
36331
  }
36741
- console.log(` ${chalk2.dim("Current:")} v${runningVersion}`);
36742
- console.log(` ${chalk2.dim("Latest:")} v${latest}`);
36332
+ console.log(` ${import_picocolors2.default.dim("Current:")} v${runningVersion}`);
36333
+ console.log(` ${import_picocolors2.default.dim("Latest:")} v${latest}`);
36743
36334
  console.log();
36744
36335
  const configuredTools = AI_TOOLS2.filter((t) => {
36745
36336
  try {
@@ -36749,64 +36340,64 @@ if (command === "update") {
36749
36340
  }
36750
36341
  });
36751
36342
  if (configuredTools.length > 0) {
36752
- console.log(chalk2.dim(" Removing MCP configs from configured tools..."));
36343
+ console.log(import_picocolors2.default.dim(" Removing MCP configs from configured tools..."));
36753
36344
  for (const tool of configuredTools) {
36754
36345
  try {
36755
36346
  tool.remove();
36756
- console.log(chalk2.dim(` \u21BB ${tool.name}`));
36347
+ console.log(import_picocolors2.default.dim(` \u21BB ${tool.name}`));
36757
36348
  } catch {
36758
- console.log(chalk2.red(` \u2717 Failed to remove ${tool.name}`));
36349
+ console.log(import_picocolors2.default.red(` \u2717 Failed to remove ${tool.name}`));
36759
36350
  }
36760
36351
  }
36761
36352
  console.log();
36762
36353
  }
36763
- console.log(chalk2.dim(" Stopping daemon..."));
36354
+ console.log(import_picocolors2.default.dim(" Stopping daemon..."));
36764
36355
  await killDaemon2();
36765
- console.log(chalk2.dim(" Clearing npx cache..."));
36356
+ console.log(import_picocolors2.default.dim(" Clearing npx cache..."));
36766
36357
  const { execSync: execSync4 } = await import("child_process");
36767
36358
  try {
36768
36359
  execSync4("npm cache clean --force", { stdio: "ignore", timeout: 15e3 });
36769
36360
  } catch {
36770
36361
  }
36771
- console.log(chalk2.dim(" Starting updated daemon..."));
36362
+ console.log(import_picocolors2.default.dim(" Starting updated daemon..."));
36772
36363
  const daemonOk = await ensureDaemon2({ preferOnline: true });
36773
36364
  if (!daemonOk) {
36774
- console.log(chalk2.red(" \u2717 Failed to start updated daemon"));
36365
+ console.log(import_picocolors2.default.red(" \u2717 Failed to start updated daemon"));
36775
36366
  console.log();
36776
- console.log(chalk2.bold(" To debug, run the daemon in foreground mode:"));
36777
- console.log(chalk2.cyan(" npx @devness/useai daemon --port 19200"));
36367
+ console.log(import_picocolors2.default.bold(" To debug, run the daemon in foreground mode:"));
36368
+ console.log(import_picocolors2.default.cyan(" npx @devness/useai daemon --port 19200"));
36778
36369
  process.exit(1);
36779
36370
  }
36780
36371
  const healthAfter = await fetchDaemonHealth2();
36781
36372
  const newVersion = healthAfter?.version ?? "unknown";
36782
- console.log(chalk2.green(`
36373
+ console.log(import_picocolors2.default.green(`
36783
36374
  \u2713 Daemon updated: v${runningVersion} \u2192 v${newVersion}`));
36784
36375
  if (configuredTools.length > 0) {
36785
- console.log(chalk2.dim("\n Reinstalling MCP configs..."));
36376
+ console.log(import_picocolors2.default.dim("\n Reinstalling MCP configs..."));
36786
36377
  for (const tool of configuredTools) {
36787
36378
  try {
36788
36379
  if (tool.supportsUrl) {
36789
36380
  tool.installHttp();
36790
- console.log(chalk2.green(` \u2713 ${tool.name} \u2192 ${chalk2.dim("HTTP (daemon)")}`));
36381
+ console.log(import_picocolors2.default.green(` \u2713 ${tool.name} \u2192 ${import_picocolors2.default.dim("HTTP (daemon)")}`));
36791
36382
  } else {
36792
36383
  tool.install();
36793
- console.log(chalk2.green(` \u2713 ${tool.name} \u2192 ${chalk2.dim("stdio")}`));
36384
+ console.log(import_picocolors2.default.green(` \u2713 ${tool.name} \u2192 ${import_picocolors2.default.dim("stdio")}`));
36794
36385
  }
36795
36386
  } catch {
36796
- console.log(chalk2.red(` \u2717 ${tool.name}`));
36387
+ console.log(import_picocolors2.default.red(` \u2717 ${tool.name}`));
36797
36388
  }
36798
36389
  }
36799
36390
  }
36800
36391
  try {
36801
36392
  const hooksInstalled = installClaudeCodeHooks2();
36802
36393
  if (hooksInstalled) {
36803
- console.log(chalk2.green(" \u2713 Claude Code hooks reinstalled"));
36394
+ console.log(import_picocolors2.default.green(" \u2713 Claude Code hooks reinstalled"));
36804
36395
  }
36805
36396
  } catch {
36806
36397
  }
36807
36398
  console.log(`
36808
- Done! UseAI updated to v${newVersion} in ${chalk2.bold(String(configuredTools.length))} tool${configuredTools.length === 1 ? "" : "s"}.`);
36809
- console.log(chalk2.dim(` Dashboard: http://127.0.0.1:19200/dashboard
36399
+ Done! UseAI updated to v${newVersion} in ${import_picocolors2.default.bold(String(configuredTools.length))} tool${configuredTools.length === 1 ? "" : "s"}.`);
36400
+ console.log(import_picocolors2.default.dim(` Dashboard: http://127.0.0.1:19200/dashboard
36810
36401
  `));
36811
36402
  process.exit(0);
36812
36403
  }