bertrand 0.21.0 → 0.22.1
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.
- package/dist/bertrand.js +63 -32
- package/dist/dashboard/assets/{index-mg96b7q-.js → index-SB5vH7Ec.js} +2 -2
- package/dist/dashboard/index.html +1 -1
- package/dist/migrations/0004_dapper_apocalypse.sql +1 -0
- package/dist/migrations/meta/0004_snapshot.json +784 -0
- package/dist/migrations/meta/_journal.json +7 -0
- package/dist/run-screen.js +42 -5
- package/package.json +1 -1
package/dist/bertrand.js
CHANGED
|
@@ -653,6 +653,7 @@ var init_schema = __esm(() => {
|
|
|
653
653
|
enum: ["active", "waiting", "paused", "archived"]
|
|
654
654
|
}).notNull().default("paused"),
|
|
655
655
|
summary: text("summary"),
|
|
656
|
+
rating: integer("rating"),
|
|
656
657
|
pid: integer("pid"),
|
|
657
658
|
startedAt: text("started_at").notNull().default(sql`(datetime('now'))`),
|
|
658
659
|
endedAt: text("ended_at"),
|
|
@@ -1362,6 +1363,8 @@ var init_update = __esm(() => {
|
|
|
1362
1363
|
|
|
1363
1364
|
// src/lib/transcript.ts
|
|
1364
1365
|
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
|
|
1366
|
+
import { homedir as homedir2 } from "os";
|
|
1367
|
+
import { join as join6 } from "path";
|
|
1365
1368
|
function getContextWindowSize(model) {
|
|
1366
1369
|
for (const [prefix, size] of Object.entries(CONTEXT_WINDOW_SIZES)) {
|
|
1367
1370
|
if (model.startsWith(prefix))
|
|
@@ -1369,6 +1372,13 @@ function getContextWindowSize(model) {
|
|
|
1369
1372
|
}
|
|
1370
1373
|
return 200000;
|
|
1371
1374
|
}
|
|
1375
|
+
function claudeTranscriptPath(sessionId, cwd) {
|
|
1376
|
+
const dir = (cwd ?? process.cwd()).replace(/\//g, "-");
|
|
1377
|
+
return join6(homedir2(), ".claude", "projects", dir, `${sessionId}.jsonl`);
|
|
1378
|
+
}
|
|
1379
|
+
function claudeSessionExists(sessionId, cwd) {
|
|
1380
|
+
return existsSync5(claudeTranscriptPath(sessionId, cwd));
|
|
1381
|
+
}
|
|
1372
1382
|
function getLatestAssistantTurn(filePath) {
|
|
1373
1383
|
if (!existsSync5(filePath))
|
|
1374
1384
|
return null;
|
|
@@ -1711,7 +1721,7 @@ class NoopAdapter {
|
|
|
1711
1721
|
|
|
1712
1722
|
// src/terminal/index.ts
|
|
1713
1723
|
import { readFileSync as readFileSync5 } from "fs";
|
|
1714
|
-
import { join as
|
|
1724
|
+
import { join as join7 } from "path";
|
|
1715
1725
|
function getTerminalAdapter() {
|
|
1716
1726
|
if (cachedAdapter)
|
|
1717
1727
|
return cachedAdapter;
|
|
@@ -1730,7 +1740,7 @@ function getTerminalAdapter() {
|
|
|
1730
1740
|
}
|
|
1731
1741
|
function readConfigTerminal() {
|
|
1732
1742
|
try {
|
|
1733
|
-
const config = JSON.parse(readFileSync5(
|
|
1743
|
+
const config = JSON.parse(readFileSync5(join7(paths.root, "config.json"), "utf-8"));
|
|
1734
1744
|
return config.terminal ?? null;
|
|
1735
1745
|
} catch {
|
|
1736
1746
|
return null;
|
|
@@ -2090,7 +2100,7 @@ var init_session_archive = __esm(() => {
|
|
|
2090
2100
|
// src/server/index.ts
|
|
2091
2101
|
import { execFile } from "child_process";
|
|
2092
2102
|
import { existsSync as existsSync6 } from "fs";
|
|
2093
|
-
import { join as
|
|
2103
|
+
import { join as join8 } from "path";
|
|
2094
2104
|
function liveStats(sessionId) {
|
|
2095
2105
|
return {
|
|
2096
2106
|
sessionId,
|
|
@@ -2163,11 +2173,11 @@ function match(pathname, url) {
|
|
|
2163
2173
|
}
|
|
2164
2174
|
function findDashboardDir() {
|
|
2165
2175
|
const candidates = [
|
|
2166
|
-
|
|
2167
|
-
|
|
2176
|
+
join8(import.meta.dir, "dashboard"),
|
|
2177
|
+
join8(import.meta.dir, "..", "dashboard")
|
|
2168
2178
|
];
|
|
2169
2179
|
for (const dir of candidates) {
|
|
2170
|
-
if (existsSync6(
|
|
2180
|
+
if (existsSync6(join8(dir, "index.html")))
|
|
2171
2181
|
return dir;
|
|
2172
2182
|
}
|
|
2173
2183
|
return null;
|
|
@@ -2176,13 +2186,13 @@ async function serveDashboard(pathname) {
|
|
|
2176
2186
|
if (!DASHBOARD_DIR)
|
|
2177
2187
|
return null;
|
|
2178
2188
|
const requested = pathname === "/" ? "/index.html" : pathname;
|
|
2179
|
-
const filePath =
|
|
2189
|
+
const filePath = join8(DASHBOARD_DIR, requested);
|
|
2180
2190
|
if (!filePath.startsWith(DASHBOARD_DIR))
|
|
2181
2191
|
return null;
|
|
2182
2192
|
const file = Bun.file(filePath);
|
|
2183
2193
|
if (await file.exists())
|
|
2184
2194
|
return new Response(file);
|
|
2185
|
-
return new Response(Bun.file(
|
|
2195
|
+
return new Response(Bun.file(join8(DASHBOARD_DIR, "index.html")));
|
|
2186
2196
|
}
|
|
2187
2197
|
function startServer(port = PORT) {
|
|
2188
2198
|
const server = Bun.serve({
|
|
@@ -3341,7 +3351,7 @@ var init_spawn_context = __esm(() => {
|
|
|
3341
3351
|
// src/lib/server-lifecycle.ts
|
|
3342
3352
|
import { spawn as spawn3 } from "child_process";
|
|
3343
3353
|
import { readFileSync as readFileSync7, writeFileSync as writeFileSync4, unlinkSync as unlinkSync2 } from "fs";
|
|
3344
|
-
import { join as
|
|
3354
|
+
import { join as join9 } from "path";
|
|
3345
3355
|
function readPidFile() {
|
|
3346
3356
|
try {
|
|
3347
3357
|
const pid = Number(readFileSync7(deps.pidFile, "utf-8").trim());
|
|
@@ -3409,11 +3419,11 @@ var init_server_lifecycle = __esm(() => {
|
|
|
3409
3419
|
init_paths();
|
|
3410
3420
|
init_sessions();
|
|
3411
3421
|
defaultDeps = {
|
|
3412
|
-
pidFile:
|
|
3422
|
+
pidFile: join9(paths.root, "server.pid"),
|
|
3413
3423
|
port: Number(process.env.BERTRAND_PORT ?? 5200),
|
|
3414
3424
|
resolveBin() {
|
|
3415
3425
|
try {
|
|
3416
|
-
const config = JSON.parse(readFileSync7(
|
|
3426
|
+
const config = JSON.parse(readFileSync7(join9(paths.root, "config.json"), "utf-8"));
|
|
3417
3427
|
return typeof config?.bin === "string" ? config.bin : null;
|
|
3418
3428
|
} catch {
|
|
3419
3429
|
return null;
|
|
@@ -3523,6 +3533,7 @@ async function resume(opts) {
|
|
|
3523
3533
|
throw new Error(`Session not found: ${opts.sessionId}`);
|
|
3524
3534
|
const category = getCategory(session.categoryId);
|
|
3525
3535
|
const sessionName = category ? `${category.path}/${session.slug}` : session.name;
|
|
3536
|
+
const isFreshClaudeSession = !claudeSessionExists(opts.conversationId);
|
|
3526
3537
|
updateSession(session.id, { status: "active", pid: process.pid });
|
|
3527
3538
|
liveSession = { sessionId: session.id, claudeId: opts.conversationId };
|
|
3528
3539
|
installExitHandlers();
|
|
@@ -3531,6 +3542,17 @@ async function resume(opts) {
|
|
|
3531
3542
|
sessionId: session.id,
|
|
3532
3543
|
conversationId: opts.conversationId
|
|
3533
3544
|
});
|
|
3545
|
+
if (isFreshClaudeSession) {
|
|
3546
|
+
const spawnContext = await captureSpawnContext();
|
|
3547
|
+
emitClaudeStarted({
|
|
3548
|
+
sessionId: session.id,
|
|
3549
|
+
conversationId: opts.conversationId,
|
|
3550
|
+
model: spawnContext.model,
|
|
3551
|
+
claudeVersion: spawnContext.claudeVersion,
|
|
3552
|
+
git: spawnContext.git,
|
|
3553
|
+
cwd: spawnContext.cwd
|
|
3554
|
+
});
|
|
3555
|
+
}
|
|
3534
3556
|
const categoryPath = category?.path ?? "";
|
|
3535
3557
|
const siblingContext = buildSiblingContext(session.categoryId, categoryPath, session.id);
|
|
3536
3558
|
const contract = buildContract(sessionName, siblingContext);
|
|
@@ -3540,7 +3562,7 @@ async function resume(opts) {
|
|
|
3540
3562
|
sessionName,
|
|
3541
3563
|
sessionSlug: session.slug,
|
|
3542
3564
|
contract,
|
|
3543
|
-
resume:
|
|
3565
|
+
resume: !isFreshClaudeSession
|
|
3544
3566
|
});
|
|
3545
3567
|
finalizeSession(session.id, opts.conversationId, exitCode);
|
|
3546
3568
|
return session.id;
|
|
@@ -3584,16 +3606,17 @@ var init_session = __esm(() => {
|
|
|
3584
3606
|
init_timing();
|
|
3585
3607
|
init_server_lifecycle();
|
|
3586
3608
|
init_trigger();
|
|
3609
|
+
init_transcript();
|
|
3587
3610
|
});
|
|
3588
3611
|
|
|
3589
3612
|
// src/tui/app.tsx
|
|
3590
3613
|
import { spawn as spawn4 } from "child_process";
|
|
3591
3614
|
import { existsSync as existsSync8, readFileSync as readFileSync8, unlinkSync as unlinkSync3 } from "fs";
|
|
3592
3615
|
import { tmpdir } from "os";
|
|
3593
|
-
import { join as
|
|
3616
|
+
import { join as join10 } from "path";
|
|
3594
3617
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
3595
3618
|
async function runScreen(screen, ...args) {
|
|
3596
|
-
const tmpFile =
|
|
3619
|
+
const tmpFile = join10(tmpdir(), `bertrand-tui-${randomUUID2()}.json`);
|
|
3597
3620
|
if (process.env.BERTRAND_DEBUG_TUI) {
|
|
3598
3621
|
try {
|
|
3599
3622
|
const { appendFileSync } = await import("fs");
|
|
@@ -3750,8 +3773,8 @@ var init_app = __esm(() => {
|
|
|
3750
3773
|
init_create();
|
|
3751
3774
|
init_resolve();
|
|
3752
3775
|
SCREEN_ENTRY = (() => {
|
|
3753
|
-
const built =
|
|
3754
|
-
return existsSync8(built) ? built :
|
|
3776
|
+
const built = join10(import.meta.dir, "run-screen.js");
|
|
3777
|
+
return existsSync8(built) ? built : join10(import.meta.dir, "run-screen.tsx");
|
|
3755
3778
|
})();
|
|
3756
3779
|
});
|
|
3757
3780
|
|
|
@@ -3766,14 +3789,18 @@ function parseSessionName(input) {
|
|
|
3766
3789
|
throw new Error(`Session name must include at least one category: "category/session" (got "${trimmed}")`);
|
|
3767
3790
|
}
|
|
3768
3791
|
for (const segment of segments) {
|
|
3769
|
-
if (
|
|
3792
|
+
if (!SEGMENT_PATTERN.test(segment)) {
|
|
3770
3793
|
throw new Error(`Invalid segment "${segment}": must start with alphanumeric and contain only letters, digits, dots, underscores, or dashes`);
|
|
3771
3794
|
}
|
|
3772
3795
|
}
|
|
3773
|
-
const
|
|
3774
|
-
const
|
|
3796
|
+
const categoryPath = segments[0];
|
|
3797
|
+
const slug = segments.slice(1).join("/");
|
|
3775
3798
|
return { categoryPath, slug };
|
|
3776
3799
|
}
|
|
3800
|
+
var SEGMENT_PATTERN;
|
|
3801
|
+
var init_parse_session_name = __esm(() => {
|
|
3802
|
+
SEGMENT_PATTERN = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
3803
|
+
});
|
|
3777
3804
|
|
|
3778
3805
|
// src/engine/recovery.ts
|
|
3779
3806
|
function isProcessAlive2(pid) {
|
|
@@ -3820,6 +3847,7 @@ function reportFatal(err) {
|
|
|
3820
3847
|
var init_launch = __esm(() => {
|
|
3821
3848
|
init_router();
|
|
3822
3849
|
init_app();
|
|
3850
|
+
init_parse_session_name();
|
|
3823
3851
|
init_session();
|
|
3824
3852
|
init_recovery();
|
|
3825
3853
|
register("launch", async (args) => {
|
|
@@ -4138,12 +4166,12 @@ var init_scripts = __esm(() => {
|
|
|
4138
4166
|
|
|
4139
4167
|
// src/hooks/install.ts
|
|
4140
4168
|
import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync5, chmodSync as chmodSync2 } from "fs";
|
|
4141
|
-
import { join as
|
|
4169
|
+
import { join as join11 } from "path";
|
|
4142
4170
|
function installHookScripts(bin) {
|
|
4143
4171
|
mkdirSync7(paths.hooks, { recursive: true });
|
|
4144
4172
|
mkdirSync7(paths.runtime, { recursive: true });
|
|
4145
4173
|
for (const [filename, scriptFn] of Object.entries(HOOK_SCRIPTS)) {
|
|
4146
|
-
const filePath =
|
|
4174
|
+
const filePath = join11(paths.hooks, filename);
|
|
4147
4175
|
writeFileSync5(filePath, scriptFn(bin, paths.runtime));
|
|
4148
4176
|
chmodSync2(filePath, 493);
|
|
4149
4177
|
}
|
|
@@ -4156,8 +4184,8 @@ var init_install = __esm(() => {
|
|
|
4156
4184
|
|
|
4157
4185
|
// src/hooks/settings.ts
|
|
4158
4186
|
import { readFileSync as readFileSync9, writeFileSync as writeFileSync6, mkdirSync as mkdirSync8 } from "fs";
|
|
4159
|
-
import { join as
|
|
4160
|
-
import { homedir as
|
|
4187
|
+
import { join as join12, dirname as dirname4 } from "path";
|
|
4188
|
+
import { homedir as homedir3 } from "os";
|
|
4161
4189
|
function isBertrandGroup(group) {
|
|
4162
4190
|
return group.hooks?.some((h) => h.command?.includes(".bertrand/hooks/")) ?? false;
|
|
4163
4191
|
}
|
|
@@ -4181,7 +4209,7 @@ function installHookSettings() {
|
|
|
4181
4209
|
var SETTINGS_PATH, BERTRAND_HOOKS;
|
|
4182
4210
|
var init_settings = __esm(() => {
|
|
4183
4211
|
init_paths();
|
|
4184
|
-
SETTINGS_PATH =
|
|
4212
|
+
SETTINGS_PATH = join12(homedir3(), ".claude", "settings.json");
|
|
4185
4213
|
BERTRAND_HOOKS = {
|
|
4186
4214
|
PreToolUse: [
|
|
4187
4215
|
{
|
|
@@ -4226,7 +4254,7 @@ var init_settings = __esm(() => {
|
|
|
4226
4254
|
|
|
4227
4255
|
// src/lib/completions.ts
|
|
4228
4256
|
import { writeFileSync as writeFileSync7, mkdirSync as mkdirSync9 } from "fs";
|
|
4229
|
-
import { join as
|
|
4257
|
+
import { join as join13 } from "path";
|
|
4230
4258
|
function bashCompletion() {
|
|
4231
4259
|
return `# bertrand bash completion
|
|
4232
4260
|
_bertrand() {
|
|
@@ -4256,11 +4284,11 @@ function fishCompletion() {
|
|
|
4256
4284
|
`;
|
|
4257
4285
|
}
|
|
4258
4286
|
function generateCompletions() {
|
|
4259
|
-
const dir =
|
|
4287
|
+
const dir = join13(paths.root, "completions");
|
|
4260
4288
|
mkdirSync9(dir, { recursive: true });
|
|
4261
|
-
writeFileSync7(
|
|
4262
|
-
writeFileSync7(
|
|
4263
|
-
writeFileSync7(
|
|
4289
|
+
writeFileSync7(join13(dir, "bertrand.bash"), bashCompletion());
|
|
4290
|
+
writeFileSync7(join13(dir, "_bertrand"), zshCompletion());
|
|
4291
|
+
writeFileSync7(join13(dir, "bertrand.fish"), fishCompletion());
|
|
4264
4292
|
console.log(`Shell completions written to ${dir}`);
|
|
4265
4293
|
console.log(" Add to your shell config:");
|
|
4266
4294
|
console.log(` bash: source ${dir}/bertrand.bash`);
|
|
@@ -4291,7 +4319,7 @@ var init_completions = __esm(() => {
|
|
|
4291
4319
|
var exports_init = {};
|
|
4292
4320
|
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync8, chmodSync as chmodSync3 } from "fs";
|
|
4293
4321
|
import { execSync as execSync2 } from "child_process";
|
|
4294
|
-
import { join as
|
|
4322
|
+
import { join as join14 } from "path";
|
|
4295
4323
|
function detectTerminal() {
|
|
4296
4324
|
try {
|
|
4297
4325
|
execSync2("which wsh", { stdio: "ignore" });
|
|
@@ -4306,8 +4334,8 @@ function resolveBin() {
|
|
|
4306
4334
|
return onPath;
|
|
4307
4335
|
const entry = process.argv[1];
|
|
4308
4336
|
if (entry && SOURCE_ENTRY.test(entry)) {
|
|
4309
|
-
const launcherDir =
|
|
4310
|
-
const launcher =
|
|
4337
|
+
const launcherDir = join14(paths.root, "bin");
|
|
4338
|
+
const launcher = join14(launcherDir, "bertrand-dev");
|
|
4311
4339
|
mkdirSync10(launcherDir, { recursive: true });
|
|
4312
4340
|
writeFileSync8(launcher, `#!/usr/bin/env bash
|
|
4313
4341
|
exec ${process.execPath} ${JSON.stringify(entry)} "$@"
|
|
@@ -4908,6 +4936,7 @@ var init_log = __esm(() => {
|
|
|
4908
4936
|
init_catalog();
|
|
4909
4937
|
init_compact();
|
|
4910
4938
|
init_timing();
|
|
4939
|
+
init_parse_session_name();
|
|
4911
4940
|
init_format();
|
|
4912
4941
|
init_resolve();
|
|
4913
4942
|
init_cli_flag();
|
|
@@ -5066,6 +5095,7 @@ var init_stats2 = __esm(() => {
|
|
|
5066
5095
|
init_events();
|
|
5067
5096
|
init_timing();
|
|
5068
5097
|
init_format();
|
|
5098
|
+
init_parse_session_name();
|
|
5069
5099
|
ACTIVE_STATUSES2 = ["active", "waiting"];
|
|
5070
5100
|
register("stats", async (args) => {
|
|
5071
5101
|
const isJson = args.includes("--json");
|
|
@@ -5143,6 +5173,7 @@ var init_archive = __esm(() => {
|
|
|
5143
5173
|
init_router();
|
|
5144
5174
|
init_sessions();
|
|
5145
5175
|
init_categories();
|
|
5176
|
+
init_parse_session_name();
|
|
5146
5177
|
init_session_archive();
|
|
5147
5178
|
register("archive", async (args) => {
|
|
5148
5179
|
const isUndo = args.includes("--undo");
|
|
@@ -516,7 +516,7 @@ XID_Start XIDS`.split(/\s/).map(e=>[jy(e),e])),Pte=new Map([["s",kn(383)],[kn(38
|
|
|
516
516
|
`,...o.current()});return/^[\t ]/.test(f)&&(f=ph(f.charCodeAt(0))+f.slice(1)),f=f?a+" "+f:a,n.options.closeAtx&&(f+=" "+a),c(),u(),f}ZF.peek=Rme;function ZF(e){return e.value||""}function Rme(){return"<"}JF.peek=_me;function JF(e,t,n,r){const i=bE(n),o=i==='"'?"Quote":"Apostrophe",a=n.enter("image");let u=n.enter("label");const c=n.createTracker(r);let f=c.move("![");return f+=c.move(n.safe(e.alt,{before:f,after:"]",...c.current()})),f+=c.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),f+=c.move("<"),f+=c.move(n.safe(e.url,{before:f,after:">",...c.current()})),f+=c.move(">")):(u=n.enter("destinationRaw"),f+=c.move(n.safe(e.url,{before:f,after:e.title?" ":")",...c.current()}))),u(),e.title&&(u=n.enter(`title${o}`),f+=c.move(" "+i),f+=c.move(n.safe(e.title,{before:f,after:i,...c.current()})),f+=c.move(i),u()),f+=c.move(")"),a(),f}function _me(){return"!"}e6.peek=Tme;function e6(e,t,n,r){const i=e.referenceType,o=n.enter("imageReference");let a=n.enter("label");const u=n.createTracker(r);let c=u.move("![");const f=n.safe(e.alt,{before:c,after:"]",...u.current()});c+=u.move(f+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const p=n.safe(n.associationId(e),{before:c,after:"]",...u.current()});return a(),n.stack=h,o(),i==="full"||!f||f!==p?c+=u.move(p+"]"):i==="shortcut"?c=c.slice(0,-1):c+=u.move("]"),c}function Tme(){return"!"}t6.peek=Ame;function t6(e,t,n){let r=e.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const a=n.unsafe[o],u=n.compilePattern(a);let c;if(a.atBreak)for(;c=u.exec(r);){let f=c.index;r.charCodeAt(f)===10&&r.charCodeAt(f-1)===13&&f--,r=r.slice(0,f)+" "+r.slice(c.index+1)}}return i+r+i}function Ame(){return"`"}function n6(e,t){const n=cE(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}r6.peek=Dme;function r6(e,t,n,r){const i=bE(n),o=i==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let u,c;if(n6(e,n)){const h=n.stack;n.stack=[],u=n.enter("autolink");let p=a.move("<");return p+=a.move(n.containerPhrasing(e,{before:p,after:">",...a.current()})),p+=a.move(">"),u(),n.stack=h,p}u=n.enter("link"),c=n.enter("label");let f=a.move("[");return f+=a.move(n.containerPhrasing(e,{before:f,after:"](",...a.current()})),f+=a.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=a.move("<"),f+=a.move(n.safe(e.url,{before:f,after:">",...a.current()})),f+=a.move(">")):(c=n.enter("destinationRaw"),f+=a.move(n.safe(e.url,{before:f,after:e.title?" ":")",...a.current()}))),c(),e.title&&(c=n.enter(`title${o}`),f+=a.move(" "+i),f+=a.move(n.safe(e.title,{before:f,after:i,...a.current()})),f+=a.move(i),c()),f+=a.move(")"),u(),f}function Dme(e,t,n){return n6(e,n)?"<":"["}i6.peek=Mme;function i6(e,t,n,r){const i=e.referenceType,o=n.enter("linkReference");let a=n.enter("label");const u=n.createTracker(r);let c=u.move("[");const f=n.containerPhrasing(e,{before:c,after:"]",...u.current()});c+=u.move(f+"]["),a();const h=n.stack;n.stack=[],a=n.enter("reference");const p=n.safe(n.associationId(e),{before:c,after:"]",...u.current()});return a(),n.stack=h,o(),i==="full"||!f||f!==p?c+=u.move(p+"]"):i==="shortcut"?c=c.slice(0,-1):c+=u.move("]"),c}function Mme(){return"["}function vE(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Ome(e){const t=vE(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function $me(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function o6(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Pme(e,t,n,r){const i=n.enter("list"),o=n.bulletCurrent;let a=e.ordered?$me(n):vE(n);const u=e.ordered?a==="."?")":".":Ome(n);let c=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const h=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&h&&(!h.children||!h.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),o6(n)===a&&h){let p=-1;for(;++p<e.children.length;){const g=e.children[p];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(a=u),n.bulletCurrent=a;const f=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=o,i(),f}function Nme(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Ime(e,t,n,r){const i=Nme(n);let o=n.bulletCurrent||vE(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let a=o.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const u=n.createTracker(r);u.move(o+" ".repeat(a-o.length)),u.shift(a);const c=n.enter("listItem"),f=n.indentLines(n.containerFlow(e,u.current()),h);return c(),f;function h(p,g,y){return g?(y?"":" ".repeat(a))+p:(y?o:o+" ".repeat(a-o.length))+p}}function jme(e,t,n,r){const i=n.enter("paragraph"),o=n.enter("phrasing"),a=n.containerPhrasing(e,r);return o(),i(),a}const Lme=fb(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Fme(e,t,n,r){return(e.children.some(function(a){return Lme(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function zme(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}s6.peek=Bme;function s6(e,t,n,r){const i=zme(n),o=n.enter("strong"),a=n.createTracker(r),u=a.move(i+i);let c=a.move(n.containerPhrasing(e,{after:i,before:u,...a.current()}));const f=c.charCodeAt(0),h=my(r.before.charCodeAt(r.before.length-1),f,i);h.inside&&(c=ph(f)+c.slice(1));const p=c.charCodeAt(c.length-1),g=my(r.after.charCodeAt(0),p,i);g.inside&&(c=c.slice(0,-1)+ph(p));const y=a.move(i+i);return o(),n.attentionEncodeSurroundingInfo={after:g.outside,before:h.outside},u+c+y}function Bme(e,t,n){return n.options.strong||"*"}function Ume(e,t,n,r){return n.safe(e.value,r)}function Hme(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Gme(e,t,n){const r=(o6(n)+(n.options.ruleSpaces?" ":"")).repeat(Hme(n));return n.options.ruleSpaces?r.slice(0,-1):r}const a6={blockquote:hme,break:sO,code:vme,definition:wme,emphasis:QF,hardBreak:sO,heading:kme,html:ZF,image:JF,imageReference:e6,inlineCode:t6,link:r6,linkReference:i6,list:Pme,listItem:Ime,paragraph:jme,root:Fme,strong:s6,text:Ume,thematicBreak:Gme};function qme(){return{enter:{table:Vme,tableData:aO,tableHeader:aO,tableRow:Wme},exit:{codeText:Kme,table:Yme,tableData:nx,tableHeader:nx,tableRow:nx}}}function Vme(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function Yme(e){this.exit(e),this.data.inTable=void 0}function Wme(e){this.enter({type:"tableRow",children:[]},e)}function nx(e){this.exit(e)}function aO(e){this.enter({type:"tableCell",children:[]},e)}function Kme(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Xme));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Xme(e,t){return t==="|"?t:e}function Qme(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
517
517
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:a,tableCell:c,tableRow:u}};function a(y,b,v,S){return f(h(y,v,S),y.align)}function u(y,b,v,S){const x=p(y,v,S),_=f([x]);return _.slice(0,_.indexOf(`
|
|
518
518
|
`))}function c(y,b,v,S){const x=v.enter("tableCell"),_=v.enter("phrasing"),R=v.containerPhrasing(y,{...S,before:o,after:o});return _(),x(),R}function f(y,b){return fme(y,{align:b,alignDelimiters:r,padding:n,stringLength:i})}function h(y,b,v){const S=y.children;let x=-1;const _=[],R=b.enter("table");for(;++x<S.length;)_[x]=p(S[x],b,v);return R(),_}function p(y,b,v){const S=y.children;let x=-1;const _=[],R=b.enter("tableRow");for(;++x<S.length;)_[x]=c(S[x],y,b,v);return R(),_}function g(y,b,v){let S=a6.inlineCode(y,b,v);return v.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function Zme(){return{exit:{taskListCheckValueChecked:lO,taskListCheckValueUnchecked:lO,paragraph:ege}}}function Jme(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:tge}}}function lO(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function ege(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let o=-1,a;for(;++o<i.length;){const u=i[o];if(u.type==="paragraph"){a=u;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function tge(e,t,n,r){const i=e.children[0],o=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",u=n.createTracker(r);o&&u.move(a);let c=a6.listItem(e,t,n,{...r,...u.current()});return o&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),c;function f(h){return h+a}}function nge(){return[Ppe(),tme(),ome(),qme(),Zme()]}function rge(e){return{extensions:[Npe(),nme(e),sme(),Qme(e),Jme()]}}const ige={tokenize:cge,partial:!0},l6={tokenize:fge,partial:!0},u6={tokenize:dge,partial:!0},c6={tokenize:hge,partial:!0},oge={tokenize:pge,partial:!0},f6={name:"wwwAutolink",tokenize:lge,previous:h6},d6={name:"protocolAutolink",tokenize:uge,previous:p6},ls={name:"emailAutolink",tokenize:age,previous:m6},co={};function sge(){return{text:co}}let ll=48;for(;ll<123;)co[ll]=ls,ll++,ll===58?ll=65:ll===91&&(ll=97);co[43]=ls;co[45]=ls;co[46]=ls;co[95]=ls;co[72]=[ls,d6];co[104]=[ls,d6];co[87]=[ls,f6];co[119]=[ls,f6];function age(e,t,n){const r=this;let i,o;return a;function a(p){return!Kw(p)||!m6.call(r,r.previous)||xE(r.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(p))}function u(p){return Kw(p)?(e.consume(p),u):p===64?(e.consume(p),c):n(p)}function c(p){return p===46?e.check(oge,h,f)(p):p===45||p===95||Qn(p)?(o=!0,e.consume(p),c):h(p)}function f(p){return e.consume(p),i=!0,c}function h(p){return o&&i&&sr(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function lge(e,t,n){const r=this;return i;function i(a){return a!==87&&a!==119||!h6.call(r,r.previous)||xE(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(ige,e.attempt(l6,e.attempt(u6,o),n),n)(a))}function o(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function uge(e,t,n){const r=this;let i="",o=!1;return a;function a(p){return(p===72||p===104)&&p6.call(r,r.previous)&&!xE(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(p),e.consume(p),u):n(p)}function u(p){if(sr(p)&&i.length<5)return i+=String.fromCodePoint(p),e.consume(p),u;if(p===58){const g=i.toLowerCase();if(g==="http"||g==="https")return e.consume(p),c}return n(p)}function c(p){return p===47?(e.consume(p),o?f:(o=!0,c)):n(p)}function f(p){return p===null||dy(p)||Wt(p)||ql(p)||lb(p)?n(p):e.attempt(l6,e.attempt(u6,h),n)(p)}function h(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function cge(e,t,n){let r=0;return i;function i(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),i):a===46&&r===3?(e.consume(a),o):n(a)}function o(a){return a===null?n(a):t(a)}}function fge(e,t,n){let r,i,o;return a;function a(f){return f===46||f===95?e.check(c6,c,u)(f):f===null||Wt(f)||ql(f)||f!==45&&lb(f)?c(f):(o=!0,e.consume(f),a)}function u(f){return f===95?r=!0:(i=r,r=void 0),e.consume(f),a}function c(f){return i||r||!o?n(f):t(f)}}function dge(e,t){let n=0,r=0;return i;function i(a){return a===40?(n++,e.consume(a),i):a===41&&r<n?o(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(c6,t,o)(a):a===null||Wt(a)||ql(a)?t(a):(e.consume(a),i)}function o(a){return a===41&&r++,e.consume(a),i}}function hge(e,t,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(e.consume(u),r):u===38?(e.consume(u),o):u===93?(e.consume(u),i):u===60||u===null||Wt(u)||ql(u)?t(u):n(u)}function i(u){return u===null||u===40||u===91||Wt(u)||ql(u)?t(u):r(u)}function o(u){return sr(u)?a(u):n(u)}function a(u){return u===59?(e.consume(u),r):sr(u)?(e.consume(u),a):n(u)}}function pge(e,t,n){return r;function r(o){return e.consume(o),i}function i(o){return Qn(o)?n(o):t(o)}}function h6(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Wt(e)}function p6(e){return!sr(e)}function m6(e){return!(e===47||Kw(e))}function Kw(e){return e===43||e===45||e===46||e===95||Qn(e)}function xE(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const mge={tokenize:Cge,partial:!0};function gge(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:xge,continuation:{tokenize:wge},exit:Sge}},text:{91:{name:"gfmFootnoteCall",tokenize:vge},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:yge,resolveTo:bge}}}}function yge(e,t,n){const r=this;let i=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;i--;){const c=r.events[i][1];if(c.type==="labelImage"){a=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return u;function u(c){if(!a||!a._balanced)return n(c);const f=Fi(r.sliceSerialize({start:a.end,end:r.now()}));return f.codePointAt(0)!==94||!o.includes(f.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function bge(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},u=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",o,t],["enter",a,t],["exit",a,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...u),e}function vge(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,a;return u;function u(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),c}function c(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(p){if(o>999||p===93&&!a||p===null||p===91||Wt(p))return n(p);if(p===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return i.includes(Fi(r.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return Wt(p)||(a=!0),o++,e.consume(p),p===92?h:f}function h(p){return p===91||p===92||p===93?(e.consume(p),o++,f):f(p)}}function xge(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,a=0,u;return c;function c(b){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(b){return b===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(b)}function h(b){if(a>999||b===93&&!u||b===null||b===91||Wt(b))return n(b);if(b===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return o=Fi(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return Wt(b)||(u=!0),a++,e.consume(b),b===92?p:h}function p(b){return b===91||b===92||b===93?(e.consume(b),a++,h):h(b)}function g(b){return b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),i.includes(o)||i.push(o),_t(e,y,"gfmFootnoteDefinitionWhitespace")):n(b)}function y(b){return t(b)}}function wge(e,t,n){return e.check(qh,t,e.attempt(mge,t,n))}function Sge(e){e.exit("gfmFootnoteDefinition")}function Cge(e,t,n){const r=this;return _t(e,i,"gfmFootnoteDefinitionIndent",5);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(o):n(o)}}function Ege(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(a,u){let c=-1;for(;++c<a.length;)if(a[c][0]==="enter"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._close){let f=c;for(;f--;)if(a[f][0]==="exit"&&a[f][1].type==="strikethroughSequenceTemporary"&&a[f][1]._open&&a[c][1].end.offset-a[c][1].start.offset===a[f][1].end.offset-a[f][1].start.offset){a[c][1].type="strikethroughSequence",a[f][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},a[f][1].start),end:Object.assign({},a[c][1].end)},p={type:"strikethroughText",start:Object.assign({},a[f][1].end),end:Object.assign({},a[c][1].start)},g=[["enter",h,u],["enter",a[f][1],u],["exit",a[f][1],u],["enter",p,u]],y=u.parser.constructs.insideSpan.null;y&&Wr(g,g.length,0,ub(y,a.slice(f+1,c),u)),Wr(g,g.length,0,[["exit",p,u],["enter",a[c][1],u],["exit",a[c][1],u],["exit",h,u]]),Wr(a,f-1,c-f+3,g),c=f+g.length-2;break}}for(c=-1;++c<a.length;)a[c][1].type==="strikethroughSequenceTemporary"&&(a[c][1].type="data");return a}function o(a,u,c){const f=this.previous,h=this.events;let p=0;return g;function g(b){return f===126&&h[h.length-1][1].type!=="characterEscape"?c(b):(a.enter("strikethroughSequenceTemporary"),y(b))}function y(b){const v=Zc(f);if(b===126)return p>1?c(b):(a.consume(b),p++,y);if(p<2&&!n)return c(b);const S=a.exit("strikethroughSequenceTemporary"),x=Zc(b);return S._open=!x||x===2&&!!v,S._close=!v||v===2&&!!x,u(b)}}}class kge{constructor(){this.map=[]}add(t,n,r){Rge(this,t,n,r)}consume(t){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const o of i)t.push(o);i=r.pop()}this.map.length=0}}function Rge(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function _ge(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Tge(){return{flow:{null:{name:"table",tokenize:Age,resolveAll:Dge}}}}function Age(e,t,n){const r=this;let i=0,o=0,a;return u;function u(j){let I=r.events.length-1;for(;I>-1;){const G=r.events[I][1].type;if(G==="lineEnding"||G==="linePrefix")I--;else break}const M=I>-1?r.events[I][1].type:null,B=M==="tableHead"||M==="tableRow"?D:c;return B===D&&r.parser.lazy[r.now().line]?n(j):B(j)}function c(j){return e.enter("tableHead"),e.enter("tableRow"),f(j)}function f(j){return j===124||(a=!0,o+=1),h(j)}function h(j){return j===null?n(j):Je(j)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),y):n(j):wt(j)?_t(e,h,"whitespace")(j):(o+=1,a&&(a=!1,i+=1),j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),a=!0,h):(e.enter("data"),p(j)))}function p(j){return j===null||j===124||Wt(j)?(e.exit("data"),h(j)):(e.consume(j),j===92?g:p)}function g(j){return j===92||j===124?(e.consume(j),p):p(j)}function y(j){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(j):(e.enter("tableDelimiterRow"),a=!1,wt(j)?_t(e,b,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):b(j))}function b(j){return j===45||j===58?S(j):j===124?(a=!0,e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),v):A(j)}function v(j){return wt(j)?_t(e,S,"whitespace")(j):S(j)}function S(j){return j===58?(o+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),x):j===45?(o+=1,x(j)):j===null||Je(j)?T(j):A(j)}function x(j){return j===45?(e.enter("tableDelimiterFiller"),_(j)):A(j)}function _(j){return j===45?(e.consume(j),_):j===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(j),e.exit("tableDelimiterMarker"),R):(e.exit("tableDelimiterFiller"),R(j))}function R(j){return wt(j)?_t(e,T,"whitespace")(j):T(j)}function T(j){return j===124?b(j):j===null||Je(j)?!a||i!==o?A(j):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(j)):A(j)}function A(j){return n(j)}function D(j){return e.enter("tableRow"),O(j)}function O(j){return j===124?(e.enter("tableCellDivider"),e.consume(j),e.exit("tableCellDivider"),O):j===null||Je(j)?(e.exit("tableRow"),t(j)):wt(j)?_t(e,O,"whitespace")(j):(e.enter("data"),$(j))}function $(j){return j===null||j===124||Wt(j)?(e.exit("data"),O(j)):(e.consume(j),j===92?z:$)}function z(j){return j===92||j===124?(e.consume(j),$):$(j)}}function Dge(e,t){let n=-1,r=!0,i=0,o=[0,0,0,0],a=[0,0,0,0],u=!1,c=0,f,h,p;const g=new kge;for(;++n<e.length;){const y=e[n],b=y[1];y[0]==="enter"?b.type==="tableHead"?(u=!1,c!==0&&(uO(g,t,c,f,h),h=void 0,c=0),f={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},g.add(n,0,[["enter",f,t]])):b.type==="tableRow"||b.type==="tableDelimiterRow"?(r=!0,p=void 0,o=[0,0,0,0],a=[0,n+1,0,0],u&&(u=!1,h={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},g.add(n,0,[["enter",h,t]])),i=b.type==="tableDelimiterRow"?2:h?3:1):i&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(o[1]!==0&&(a[0]=a[1],p=Km(g,t,o,i,void 0,p),o=[0,0,0,0]),a[2]=n)):b.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(a[0]=a[1],p=Km(g,t,o,i,void 0,p)),o=a,a=[o[1],n,0,0])):b.type==="tableHead"?(u=!0,c=n):b.type==="tableRow"||b.type==="tableDelimiterRow"?(c=n,o[1]!==0?(a[0]=a[1],p=Km(g,t,o,i,n,p)):a[1]!==0&&(p=Km(g,t,a,i,n,p)),i=0):i&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(a[3]=n)}for(c!==0&&uO(g,t,c,f,h),g.consume(t.events),n=-1;++n<t.events.length;){const y=t.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=_ge(t.events,n))}return e}function Km(e,t,n,r,i,o){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(o.end=Object.assign({},nc(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const c=nc(t.events,n[1]);if(o={type:a,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const f=nc(t.events,n[2]),h=nc(t.events,n[3]),p={type:u,start:Object.assign({},f),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",p,t]]),r!==2){const g=t.events[n[2]],y=t.events[n[3]];if(g[1].end=Object.assign({},y[1].end),g[1].type="chunkText",g[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,v=n[3]-n[2]-1;e.add(b,v,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return i!==void 0&&(o.end=Object.assign({},nc(t.events,i)),e.add(i,0,[["exit",o,t]]),o=void 0),o}function uO(e,t,n,r,i){const o=[],a=nc(t.events,n);i&&(i.end=Object.assign({},a),o.push(["exit",i,t])),r.end=Object.assign({},a),o.push(["exit",r,t]),e.add(n+1,0,o)}function nc(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Mge={name:"tasklistCheck",tokenize:$ge};function Oge(){return{text:{91:Mge}}}function $ge(e,t,n){const r=this;return i;function i(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),o)}function o(c){return Wt(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),a):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),a):n(c)}function a(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),u):n(c)}function u(c){return Je(c)?t(c):wt(c)?e.check({tokenize:Pge},t,n)(c):n(c)}}function Pge(e,t,n){return _t(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function Nge(e){return kF([sge(),gge(),Ege(e),Tge(),Oge()])}const Ige={};function jge(e){const t=this,n=e||Ige,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Nge(n)),o.push(nge()),a.push(rge(n))}const Lge=new Set(Object.keys(HP)),cO={js:"javascript",ts:"typescript",py:"python",sh:"bash",shell:"bash",md:"markdown"};function Fge(e){const t=/language-([\w-]+)/.exec(e??"");if(!t)return;const n=t[1].toLowerCase();if(cO[n])return cO[n];if(Lge.has(n))return n}function g6(e){var t;return C.isValidElement(e)&&((t=e.props)==null?void 0:t.type)==="checkbox"}function zge(e){return C.isValidElement(e)&&e.type===Kc}function Bge(e){return C.Children.toArray(e).some(t=>{if(!C.isValidElement(t))return!1;const n=C.Children.toArray(t.props.children);return g6(n[0])})}function Xw(e){if(e==null||typeof e=="boolean")return"";if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(Array.isArray(e))return e.map(Xw).join("");if(C.isValidElement(e)){const t=e.props.children;return Xw(t)}return""}function fO(e){return C.Children.toArray(e).filter(t=>C.isValidElement(t)).map((t,n)=>{const r=C.Children.toArray(t.props.children),i=r[0];if(g6(i)){const a=!!i.props.checked,u=r.slice(1);return{value:`item-${n}`,label:E.jsxs(Xe,{ay:"center",gap:2,children:[E.jsx(OL,{checked:a,disabled:!0}),E.jsx(je,{size:1,children:u})]})}}const o=r.findIndex(zge);if(o>=0){const a=r[o],u=[...r.slice(0,o),...r.slice(o+1)];return{id:`group-${n}`,category:Xw(u).trim(),items:a.props.items??[]}}return{value:`item-${n}`,label:E.jsx(je,{size:1,children:r})}})}const Uge={p:({children:e})=>E.jsx(je,{my:1,size:1,render:E.jsx("p",{}),children:e}),h1:({children:e,id:t})=>E.jsx(je,{weight:"bold",size:4,my:2,render:E.jsx("h1",{id:t}),children:e}),h2:({children:e,id:t})=>E.jsx(je,{weight:"bold",size:3,mt:2,render:E.jsx("h2",{id:t}),children:e}),h3:({children:e,id:t})=>E.jsx(je,{weight:"bold",size:1,my:1,render:E.jsx("h3",{id:t}),children:e}),h4:({children:e,id:t})=>E.jsx(je,{weight:"bold",size:1,render:E.jsx("h4",{id:t}),children:e}),h5:({children:e,id:t})=>E.jsx(je,{weight:"bold",size:0,render:E.jsx("h5",{id:t}),children:e}),h6:({children:e,id:t})=>E.jsx(je,{weight:"bold",size:-1,render:E.jsx("h6",{id:t}),children:e}),strong:({children:e})=>E.jsx(je,{weight:"bold",children:e}),em:({children:e})=>E.jsx(je,{render:E.jsx("em",{}),children:e}),del:({children:e})=>E.jsx(je,{strikethrough:!0,render:E.jsx("del",{}),children:e}),a:({children:e,href:t})=>E.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:e}),ul:({children:e})=>E.jsx(Kc,{type:Bge(e)?"none":"unordered",size:"large",items:fO(e),style:{display:"block"},my:2}),ol:({children:e})=>E.jsx(Kc,{type:"ordered",size:"large",items:fO(e),style:{display:"block"},my:2}),blockquote:({children:e})=>E.jsx("blockquote",{children:e}),hr:()=>E.jsx(gS,{}),table:({children:e})=>E.jsx(eE,{children:E.jsx(tE,{bordered:!0,children:e})}),thead:({children:e})=>E.jsx(uF,{children:e}),tbody:({children:e})=>E.jsx(rE,{children:e}),tr:({children:e})=>E.jsx(nE,{children:e}),th:({children:e})=>E.jsx(cF,{children:e}),td:({children:e})=>E.jsx(fh,{children:e}),pre:({children:e})=>E.jsx(E.Fragment,{children:e}),code:({className:e,children:t,...n})=>{const r=String(t??"");return r.includes(`
|
|
519
|
-
`)?E.jsx(mC,{code:r.replace(/\n$/,""),language:Fge(e),rows:5,defaultExpanded:!1,HeaderProps:{copyable:!0},style:{width:"100%",marginBlockEnd:"0.5rem"}}):E.jsx(aI,{...n,children:t})}},Hge=[jge],Gge=[Tpe];function qge({children:e,components:t}){return E.jsx(Ye,{gap:4,fullwidth:!0,children:E.jsx(mpe,{remarkPlugins:Hge,rehypePlugins:Gge,components:{...Uge,...t},children:e})})}const ya=C.memo(qge),y6=()=>{var i;const e=yy(),{data:t=[]}=Si(mF),n=t.find(o=>o.active),r=async o=>{if((n==null?void 0:n.slug)!==o){try{await oce(o)}catch(a){console.error("Project switch failed:",a);return}e.invalidateQueries()}};return t.length===0?null:t.length===1?E.jsxs(Xe,{ay:"center",gap:2,px:2,children:[E.jsx(je,{size:-1,shade:"muted",children:"project"}),E.jsx(je,{size:-1,weight:"bold",children:(n==null?void 0:n.name)??((i=t[0])==null?void 0:i.name)??"default"})]}):E.jsxs(nb,{children:[E.jsx(rb,{render:E.jsx(Ci,{variant:"subtle",size:"small",fullwidth:!0,children:E.jsxs(Xe,{ay:"center",ax:"space-between",gap:2,fullwidth:!0,children:[E.jsxs(Xe,{ay:"center",gap:2,children:[E.jsx(je,{size:-1,shade:"muted",children:"project"}),E.jsx(je,{size:-1,weight:"bold",children:(n==null?void 0:n.name)??"—"})]}),E.jsx(xS,{size:14})]})})}),E.jsx(ah,{children:E.jsx(lh,{side:"bottom",align:"start",children:E.jsx(uh,{children:t.map(o=>E.jsx(Xc,{onClick:()=>{r(o.slug)},children:E.jsxs(Xe,{ay:"center",gap:2,children:[E.jsx(je,{size:-1,weight:o.active?"bold":"normal",children:o.name}),o.active&&E.jsx(je,{size:-1,shade:"muted",children:"(active)"})]})},o.slug))})})})]})};y6.displayName="ProjectSwitcher";const wE=({children:e,...t})=>E.jsx(Ye,{"data-slot":"sidebar",render:E.jsx("nav",{}),ax:"stretch",fullwidth:!0,gap:3,p:4,...t,children:e});wE.displayName="SidebarWrapper";const Vge=["active","waiting","paused","archived"],Yge={active:"Active",waiting:"Waiting",paused:"Paused",archived:"Archived"},Wge=["today","yesterday","thisWeek","earlier"],Kge={today:"Today",yesterday:"Yesterday",thisWeek:"This week",earlier:"Earlier"},Xge=1440*60*1e3;function Qge(e,t){const n=new Date(e),r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=new Date(n.getFullYear(),n.getMonth(),n.getDate()),o=Math.floor((r.getTime()-i.getTime())/Xge);return o<=0?"today":o===1?"yesterday":o<7?"thisWeek":"earlier"}function rx(e){const t=oE(e.session.status),n=e.session.status==="archived";return{value:e.session.id,label:E.jsx(v6,{session:e}),content:E.jsxs(Xe,{gap:2,ay:"center",mt:1,mb:2,children:[E.jsx(My,{color:t}),E.jsx(x6,{session:e})]}),action:E.jsx(w6,{session:e.session,categoryPath:e.categoryPath}),"data-archived":n?"":void 0,style:n?{opacity:.4}:void 0}}function Zge(e,t){if(t==="status"){const r=new Map;for(const i of e){const o=i.session.status,a=r.get(o);a?a.push(i):r.set(o,[i])}return Vge.filter(i=>r.has(i)).map(i=>({category:Yge[i],collapsible:!0,items:r.get(i).map(rx)}))}if(t==="recent"){const r=new Date,i=new Map;for(const o of e){const a=Qge(o.session.startedAt,r),u=i.get(a);u?u.push(o):i.set(a,[o])}return Wge.filter(o=>i.has(o)).map(o=>({category:Kge[o],collapsible:!0,items:i.get(o).map(rx)}))}const n=new Map;for(const r of e){const i=r.categoryPath,o=n.get(i);o?o.push(r):n.set(i,[r])}return Array.from(n,([r,i])=>({category:r,collapsible:!0,items:i.map(rx)}))}const dO=e=>e.id??e.category??"",b6=({WrapperProps:e})=>{const[t,n]=C.useState(""),[r,i]=C.useState("group"),[o,a]=C.useState(!1),[u,c]=C.useState({}),f=C.useRef(null),{data:h=[]}=Si(dh({includeArchived:o})),p=C.useMemo(()=>{const S=t.trim().toLowerCase(),x=S?h.filter(_=>_.session.slug.toLowerCase().includes(S)||_.session.name.toLowerCase().includes(S)||_.categoryPath.toLowerCase().includes(S)):h;return Zge(x,r)},[h,t,r]),g=p.map(dO),y=g.length>0&&g.every(S=>u[S]!==!1),b=()=>{const S=!y;c(x=>{const _={...x};for(const R of g)_[R]=S;return _})},v=p.map(S=>{const x=dO(S);return{...S,open:u[x]??!0,onOpenChange:_=>c(R=>({...R,[x]:_}))}});return C.useEffect(()=>{const S=x=>{var _,R;(x.metaKey||x.ctrlKey)&&x.key==="k"&&(x.preventDefault(),(_=f.current)==null||_.focus(),(R=f.current)==null||R.select())};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[]),E.jsxs(wE,{...e,children:[E.jsx(y6,{}),E.jsx(Xe,{ay:"center",gap:2,fullwidth:!0,children:E.jsx(II,{ref:f,placeholder:"Search for a session",before:E.jsx(XG,{}),after:E.jsx(yP,{hotkey:["meta","k"]}),size:"small",fullwidth:!0,style:{flex:1,minWidth:0},value:t,onChange:S=>n(S.target.value)})}),E.jsxs(Xe,{ay:"center",ax:"space-between",gap:2,children:[E.jsxs(VC,{size:"sm",value:[r],onValueChange:S=>{const x=S[0];x&&i(x)},children:[E.jsx(xc,{value:"group","aria-label":"Group by group",children:E.jsx($l,{trigger:E.jsx(OG,{}),children:"Group by group"})}),E.jsx(xc,{value:"status","aria-label":"Group by status",children:E.jsx($l,{trigger:E.jsx(nq,{}),children:"Group by status"})}),E.jsx(xc,{value:"recent","aria-label":"Group by recent",children:E.jsx($l,{trigger:E.jsx(Q3,{}),children:"Group by recent"})})]}),E.jsxs(Xe,{ay:"center",gap:1,children:[E.jsx(Qd,{size:"small",shape:"square",variant:"subtle",tooltip:o?"Hide archived":"Show archived",pressed:o,onPressedChange:a,icon:{unpressed:E.jsx(bG,{}),pressed:E.jsx(xG,{})}}),p.length>0&&E.jsx(Qd,{size:"small",shape:"square",variant:"subtle",tooltip:y?"Collapse all":"Expand all",pressed:!y,onPressedChange:()=>b(),icon:{unpressed:E.jsx(sG,{}),pressed:E.jsx(xS,{})}})]})]}),p.length===0?E.jsxs(je,{size:-1,shade:"muted",style:{padding:"0.5rem"},children:['No sessions match "',t,'".']}):E.jsx(Kc,{items:v,line:!0,size:"small"})]})};b6.displayName="Sidebar";const v6=({session:e})=>E.jsx(ef,{to:"/$",params:{_splat:`${e.categoryPath}/${e.session.slug}`},children:e.session.slug});v6.displayName="SessionLabel";const x6=({session:e})=>{const{data:t=[]}=Si(dh()),n=t.some(p=>p.session.status==="active"||p.session.status==="waiting"),{data:r}=Si(nce(n)),{data:i}=Si(ice),o=r==null?void 0:r[e.session.id],a=i==null?void 0:i[e.session.id],u=(o==null?void 0:o.linesAdded)??0,c=(o==null?void 0:o.linesRemoved)??0,f=(o==null?void 0:o.filesTouched)??0,h=u>0||c>0;return E.jsxs(Xe,{ay:"center",gap:2,children:[E.jsx(je,{size:-1,shade:"muted",children:Bw(e.session.startedAt)}),h&&E.jsxs(Xe,{ay:"center",gap:1,children:[E.jsx(je,{size:-1,family:"mono",color:"green",children:`+${u}`}),E.jsx(je,{size:-1,family:"mono",color:"red",children:`-${c}`})]}),f>0&&E.jsxs(Xe,{ay:"center",gap:1,children:[E.jsx(e4,{size:12}),E.jsx(je,{size:-1,family:"mono",shade:"muted",children:f})]}),a&&E.jsx(G$,{TriggerProps:{openOnHover:!0},trigger:E.jsx(zG,{size:12,"aria-label":"Session recap"}),title:"Session recap",description:Bw(a.createdAt),PositionerProps:{sideOffset:8,side:"right"},PopupProps:{style:{maxWidth:420}},children:E.jsx(Ye,{my:2,children:E.jsx(ya,{children:a.recap})})})]})};x6.displayName="SessionContent";const w6=({session:e,categoryPath:t})=>{const n=gF(e),{Icon:r}=n,i=e.status==="paused",o=`${t}/${e.slug}`;return E.jsxs(nb,{children:[E.jsx(rb,{render:E.jsx(Ci,{variant:"ghost",size:"xsmall",shape:"square","aria-label":"Session actions",children:E.jsx(pG,{})})}),E.jsx(ah,{children:E.jsx(lh,{side:"bottom",align:"end",children:E.jsxs(uh,{children:[E.jsxs(Xc,{disabled:n.disabled,onClick:n.onClick,render:E.jsx(Xe,{ay:"center",gap:2}),children:[E.jsx(r,{size:14}),n.label]}),E.jsxs(Xc,{disabled:!i,onClick:()=>{navigator.clipboard.writeText(o)},render:E.jsx(Xe,{ay:"center",gap:2}),children:[E.jsx(Eh,{size:14}),"Copy session path"]})]})})})]})};w6.displayName="SessionRowActions";const S6=({children:e,...t})=>E.jsx(Xe,{"data-slot":"top-bar-wrapper",fullwidth:!0,ay:"center",p:4,gap:4,bb:1,style:{position:"sticky",top:0,backgroundColor:"var(--shade-background)",zIndex:1,...t.style},...t,children:e});S6.displayName="TopBarWrapper";const Ud="uiid-theme";function Jge(){return localStorage.getItem(Ud)??"system"}function eye(e){const t=n=>{n.key===Ud&&e()};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)}function tye(e){e==="system"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",e)}function nye(){const e=C.useSyncExternalStore(eye,Jge),t=C.useCallback(n=>{n==="system"?localStorage.removeItem(Ud):localStorage.setItem(Ud,n),tye(n),window.dispatchEvent(new StorageEvent("storage",{key:Ud,newValue:n}))},[]);return{theme:e,setTheme:t}}const C6=()=>{const{theme:e,setTheme:t}=nye();return E.jsxs(VC,{value:[e],onValueChange:n=>{const r=n[0];r&&t(r)},size:"sm",children:[E.jsx(xc,{value:"light","aria-label":"Light mode",children:E.jsx(eq,{})}),E.jsx(xc,{value:"dark","aria-label":"Dark mode",children:E.jsx(VG,{})}),E.jsx(xc,{value:"system","aria-label":"System theme",children:E.jsx(GG,{})})]})};C6.displayName="ThemeToggle";const SE=({sessionCount:e})=>E.jsxs(S6,{children:[E.jsx(je,{size:2,weight:"bold",children:"bertrand"}),E.jsx(C.Activity,{mode:e?"visible":"hidden",children:E.jsxs(cn,{color:"blue",children:[e," session(s)"]})}),E.jsxs(Xe,{gap:3,ay:"center",ml:"auto",children:[E.jsxs(Xe,{gap:2,ay:"center",children:[E.jsx(ix,{to:"/",tooltip:"Session timeline",icon:E.jsx(nG,{})}),E.jsx(ix,{to:"/dev/markdown",tooltip:"Markdown viewer",icon:E.jsx(eG,{})}),E.jsx(ix,{to:"/dev/diff",tooltip:"Diff viewer",icon:E.jsx(J3,{})})]}),E.jsx(C6,{})]})]});SE.displayName="TopBar";const ix=({to:e,tooltip:t,icon:n})=>E.jsx(Ci,{render:E.jsx(ef,{to:e}),nativeButton:!1,tooltip:t,variant:"subtle",size:"small",shape:"square",children:n}),Yh=$7({component:rye});function rye(){return K7({select:t=>t.location.pathname}).startsWith("/dev/")?E.jsxs(Ye,{fullwidth:!0,style:{position:"fixed",inset:0,height:"100dvh"},children:[E.jsx(SE,{}),E.jsx(Ye,{render:E.jsx("main",{}),fullwidth:!0,style:{flex:1,overflow:"auto"},children:E.jsx(fS,{})})]}):E.jsx(iye,{})}function iye(){const{data:e=[]}=Si(dh());return E.jsxs(Ye,{fullwidth:!0,style:{position:"fixed",height:"100dvh"},children:[E.jsx(SE,{sessionCount:e.length}),E.jsxs(rF,{direction:"horizontal",children:[E.jsx(zw,{defaultSize:360,minSize:320,maxSize:540,children:E.jsx(b6,{})}),E.jsx(iF,{}),E.jsx(zw,{children:E.jsx(Ye,{render:E.jsx("main",{}),fullwidth:!0,fullheight:!0,children:E.jsx(fS,{})})})]})]})}const oye=new Set(["session.started","session.resumed","session.end"]),sye=e=>{const t=new Map;for(let r=0;r<e.length-1;r++){const i=e[r],o=e[r+1];i.event==="session.started"&&o.event==="claude.started"&&i.conversationId===o.conversationId&&t.set(r+1,{...i.meta??{},...o.meta??{}})}const n=[];for(let r=0;r<e.length;r++){const i=e[r];if(oye.has(i.event))continue;const o=t.get(r);n.push(o?{...i,meta:o}:i)}return n},aye=e=>{var r;const t=[],n=new Set;for(let i=0;i<e.length;i++){if(n.has(i))continue;const o=e[i];if(o.event==="session.waiting"){let a=i+1;const u=[];for(;a<e.length&&(e[a].event==="context.snapshot"||e[a].event==="assistant.recap");)e[a].event==="assistant.recap"&&u.push(e[a]),a++;if(a<e.length&&e[a].event==="session.answered"){for(const f of u)t.push(f);const c=(r=o.meta)==null?void 0:r.question;t.push({...e[a],meta:{...e[a].meta,question:c}});for(let f=i;f<=a;f++)n.add(f);continue}}t.push(o)}return t};function gy(e){return e.edits&&e.edits.length>0?e.edits:e.oldStr||e.newStr?[{oldStr:e.oldStr??"",newStr:e.newStr??""}]:[]}function hO(e){const t=e.meta,n=e.event==="permission.resolve"?"approved":e.event==="tool.used"?"auto":"pending";return{tool:(t==null?void 0:t.tool)??"unknown",detail:(t==null?void 0:t.detail)??"",outcome:(t==null?void 0:t.outcome)??n}}const E6={Bash:"ran",Edit:"edited",MultiEdit:"edited",Write:"wrote",Read:"read",Glob:"globbed",Grep:"grepped",WebFetch:"fetched",WebSearch:"searched",TodoWrite:"updated todos"},lye={Bash:"commands",Edit:"files",MultiEdit:"files",Write:"files",Read:"files",Glob:"patterns",Grep:"patterns",WebFetch:"urls",WebSearch:"queries"},uye=new Set(["Edit","MultiEdit","Write","Read"]);function cye(e){return e.split("/").filter(Boolean).pop()??e}function pO(e,t){return e.length<=t?e:e.slice(0,t-1)+"…"}function fye(e){const t=E6[e.tool]??e.tool;return e.detail?e.tool==="Bash"?`ran \`${pO(e.detail,60)}\``:uye.has(e.tool)?`${t} ${cye(e.detail)}`:`${t} ${pO(e.detail,60)}`:t}function dye(e){const t=[];for(const[n,r]of e){const i=E6[n]??n;if(r===1)t.push(i);else{const o=lye[n]??"calls";t.push(`${i} ${r} ${o}`)}}return t.join(", ")}const mO=new Set(["permission.request","permission.resolve","tool.used"]),hye=e=>{const t=[];let n=0;for(;n<e.length;){const r=e[n];if(!mO.has(r.event)){t.push(r),n++;continue}const i=[];for(;n<e.length;){const h=e[n];if(!mO.has(h.event))break;i.push(h),n++}const o=i.filter(h=>h.event==="permission.request"||h.event==="tool.used");if(o.length===0)continue;const a=o.map(hO),u=i.some(h=>h.event==="permission.resolve"),c=new Map;for(const h of a){const p=`${h.tool}::${h.detail}`,g=c.get(p);if(g){g.count++;const y=[...gy(g),...gy(h)];y.length>0&&(g.edits=y,g.oldStr=void 0,g.newStr=void 0)}else c.set(p,{...h,count:1})}const f=[...c.values()];if(f.length<=1){const h=f[0]??hO(i[0]),p=fye(h);t.push({...i[i.length-1],event:"tool.work",summary:p,meta:{...i[i.length-1].meta,permissions:f,outcome:u?"approved":"pending"}})}else{const h=new Map;for(const v of f)h.set(v.tool,(h.get(v.tool)??0)+v.count);const p=[...h.entries()].sort((v,S)=>S[1]-v[1]),g=dye(p),y=new Date(i[0].createdAt).getTime(),b=new Date(i[i.length-1].createdAt).getTime();t.push({...i[0],event:"tool.work",summary:g,meta:{permissions:f,outcome:u?"approved":"pending"},createdAt:new Date((y+b)/2).toISOString()})}}return t},pye={Edit:"edited a file",Write:"wrote a file",MultiEdit:"edited a file"},mye=e=>{const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r.event!=="tool.applied"){t.push(r),n++;continue}const i=[];for(;n<e.length&&e[n].event==="tool.applied";)i.push(e[n]),n++;if(i.length===1){t.push(i[0]);continue}const o=[];for(const f of i){const h=f.meta,p=h==null?void 0:h.permissions;if(Array.isArray(p))for(const g of p)o.push(g)}const a=new Map;for(const f of o){const h=`${f.tool}::${f.detail}`,p=a.get(h),g=f.count??1;if(p){p.count+=g;const y=[...gy(p),...gy(f)];y.length>0&&(p.edits=y,p.oldStr=void 0,p.newStr=void 0)}else a.set(h,{...f,count:g})}const u=[...a.values()],c=i[i.length-1];t.push({...c,meta:{...c.meta,permissions:u}})}return t},gye=e=>e.map(t=>{var o;if(t.event!=="tool.applied"||t.summary)return t;const n=t.meta,r=(n==null?void 0:n.permissions)??[];if(r.length>1)return{...t,summary:`edited ${r.length} files`};const i=(o=r[0])==null?void 0:o.tool;return i?{...t,summary:pye[i]??`${i} applied`}:t}),yye=e=>{const t=new Set(["claude.started","claude.ended","claude.discarded"]);return e.map((n,r)=>{if(!t.has(n.event))return n;const i=n.meta;if(i!=null&&i.model)return n;const o=(i==null?void 0:i.claude_id)??n.conversationId;if(!o)return n;const u=n.event==="claude.started"?e.slice(r+1):e.slice(0,r).reverse();for(const c of u){if(c.event!=="context.snapshot")continue;const f=c.meta;if(((f==null?void 0:f.claude_id)??c.conversationId)!==o)continue;const p=f==null?void 0:f.model;if(p)return{...n,meta:{...i,model:p}}}return n})},bye=[sye,aye,hye,mye,gye,yye];function vye(e){return bye.reduce((t,n)=>n(t),e)}function xye(e){return e<1500?"●○○":e<5e3?"●●○":"●●●"}const wye=/<recap>[\s\S]*?<\/recap>/gi;function k6({event:e}){var a;const t=e.meta;if(e.event==="assistant.recap"){const u=(a=t==null?void 0:t.recap)==null?void 0:a.trim();return u?E.jsx(Ye,{"data-slot":"assistant-recap",py:4,children:E.jsx(qt,{children:E.jsx(ya,{children:u})})}):null}const r=((t==null?void 0:t.text)??"").replace(wye,"").trim(),i=(t==null?void 0:t.thinkingBlocks)??0,o=(t==null?void 0:t.thinkingBytes)??0;return!r&&i===0?null:E.jsxs(Ye,{"data-slot":"assistant-content",gap:2,children:[i>0&&E.jsx(cn,{color:"indigo",children:`Thought ${xye(o)}`}),r&&E.jsx(ya,{children:r})]})}k6.displayName="AssistantContent";function R6({event:e}){const t=e.meta;if(!t)return null;const n=to(t.remaining_pct),r=to(t.context_window_tokens),i=to(t.input_tokens),o=to(t.cache_read_tokens),a=to(t.cache_creation_tokens),u=ab(t.model);return r===0?null:E.jsxs(Ye,{"data-slot":"context-content",gap:3,fullwidth:!0,children:[E.jsx(XS,{value:n,size:"small",color:yF(n)}),E.jsxs(Xe,{gap:2,children:[u&&E.jsx(cn,{size:"small",children:u}),i>0&&E.jsx(cn,{size:"small",color:"orange",children:`${Jo(i)} input`}),o>0&&E.jsx(cn,{size:"small",color:"blue",children:`${Jo(o)} cache read`}),a>0&&E.jsx(cn,{size:"small",color:"indigo",children:`${Jo(a)} cache write`})]})]})}R6.displayName="ContextContent";function gO(e,t){return e==null?void 0:e.find(n=>n.question===t)}function Sye(e,t,n){const r=[...t].sort((a,u)=>u.label.length-a.label.length),i=[];let o=e;for(;o;){const a=r.find(u=>o===u.label||o.startsWith(u.label+", "));if(!a)break;if(i.push(a.label),o===a.label){o="";break}if(o=o.slice(a.label.length+2),!n)break}return{selectedLabels:i,note:o||void 0}}function _6({event:e}){const t=e.meta;if(e.event==="session.answered"){const n=t==null?void 0:t.answers;if(!n||Object.keys(n).length===0)return null;const r=t==null?void 0:t.questions,i=Object.entries(n),o=(u,c)=>{const f=gO(r,u),h=(f==null?void 0:f.multiSelect)??!1,p=(f==null?void 0:f.options)??[],{selectedLabels:g,note:y}=Sye(c,p,h),b=g.length>0,v=b?void 0:y??c,S=b?y:void 0;return E.jsxs(Ye,{gap:4,fullwidth:!0,children:[v&&E.jsxs(Ye,{"data-slot":"interaction-content-note",gap:4,m:2,fullwidth:!0,children:[E.jsx(je,{color:"yellow",weight:"bold",size:1,children:"Answered manually:"}),E.jsx(ya,{children:v})]}),!b&&!v&&E.jsx(je,{color:"red",weight:"bold",size:1,m:2,children:"Didn't answer."}),p.length>0&&E.jsx(Kc,{type:"ordered",items:p.map(x=>({value:x.label,label:E.jsx(je,{weight:"bold",color:g.includes(x.label)?"green":void 0,children:x.label}),description:x.description,disabled:!g.includes(x.label)}))}),S&&E.jsxs(Ye,{"data-slot":"interaction-content-note",gap:4,m:2,fullwidth:!0,children:[E.jsx(je,{color:"green",weight:"bold",size:1,children:"Additional notes:"}),E.jsx(ya,{children:S})]})]})};if(i.length===1){const[u,c]=i[0];return E.jsx(Ye,{"data-slot":"interaction-content",gap:2,py:4,fullwidth:!0,children:E.jsx(qt,{gap:4,fullwidth:!0,children:o(u,c)})})}const a=i.map(([u,c],f)=>{const h=gO(r,u);return{label:(h==null?void 0:h.header)??`Question ${f+1}`,value:u,render:o(u,c)}});return E.jsx(Ye,{"data-slot":"interaction-content",gap:2,py:4,fullwidth:!0,children:E.jsx(qt,{gap:4,fullwidth:!0,children:E.jsx(qC,{items:a,ContainerProps:{fullwidth:!0,mt:6}})})})}if(e.event==="user.prompt"){const n=t==null?void 0:t.prompt;return n?E.jsx(T6,{children:E.jsx(ya,{children:n})}):null}return null}_6.displayName="InteractionContent";const T6=({children:e})=>E.jsx(Ye,{"data-slot":"interaction-content",py:4,fullwidth:!0,children:E.jsx(qt,{gap:4,fullwidth:!0,children:e})});T6.displayName="CardContainer";function Cye(e){if(e)return e.slice(0,8)}function A6({event:e}){if(e.event==="claude.started")return null;const t=e.meta;if(e.event==="session.recap"){const u=t==null?void 0:t.recap;return u?E.jsx(Ye,{py:4,children:E.jsx(qt,{children:E.jsx(ya,{children:u})})}):null}const n=(t==null?void 0:t.claude_id)??e.conversationId??void 0,r=ab(t==null?void 0:t.model),i=Cye(n??void 0),o=e.event==="claude.ended"?t==null?void 0:t.exit_code:void 0,a=typeof o=="number"&&o!==0;return!r&&!i&&!a?null:E.jsxs(Xe,{gap:2,ay:"center",children:[r&&E.jsx(cn,{color:"orange",size:"small",children:r}),i&&E.jsx(cn,{color:"neutral",size:"small",children:i}),a&&E.jsx(cn,{color:"red",size:"small",children:`exit ${o}`})]})}A6.displayName="LifecycleContent";function D6({event:e}){const t=e.meta;if(!t)return null;switch(e.event){case"gh.pr.created":{const n=t.pr_title,r=t.pr_url;return E.jsxs(E.Fragment,{children:[n&&E.jsx(je,{size:1,children:n}),r&&E.jsx(je,{size:-1,family:"mono",color:"neutral",children:r})]})}case"gh.pr.merged":{const n=t.branch;return n?E.jsx(je,{size:1,family:"mono",children:n}):null}case"vercel.deploy":{const n=t.project_name;return n?E.jsx(je,{size:1,children:n}):null}default:return null}}D6.displayName="MilestoneContent";function Eye({text:e}){const[t,n]=C.useState(!1);return E.jsx(Ci,{size:"small",variant:"ghost",shape:"square",tooltip:t?"Copied!":"Copy path",disabled:t,onClick:()=>{navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)},children:t?E.jsx(Ch,{color:"green"}):E.jsx(Eh,{})})}function kye(e){if(e)return e.slice(0,8)}function Rye(e){if(e)return e.slice(0,7)}function M6({event:e}){const t=e.meta;if(!t)return null;const n=t.labels??[],r=t.summary,i=t.claude_id??e.conversationId??void 0,o=ab(t.model),a=t.claude_version,u=kye(i),c=t.git??void 0,f=c==null?void 0:c.branch,h=Rye(c==null?void 0:c.sha),p=!!(c!=null&&c.dirty),g=t.cwd,y=[];if(n.length>0&&y.push({field:"Labels",value:n.join(", ")}),r&&y.push({field:"Summary",value:r}),o&&y.push({field:"Model",value:E.jsx(cn,{color:"orange",size:"small",children:o})}),a&&y.push({field:"Version",value:E.jsx(cn,{color:"neutral",size:"small",children:a})}),u&&y.push({field:"Claude ID",value:E.jsx(cn,{color:"neutral",size:"small",children:u})}),f&&y.push({field:"Branch",value:E.jsxs(Xe,{gap:2,ay:"center",children:[E.jsx(cn,{color:"neutral",size:"small",children:f}),h&&E.jsx(cn,{color:"neutral",size:"small",children:h}),p&&E.jsx(cn,{color:"red",size:"small",children:"dirty"})]})}),g&&y.push({field:"CWD",value:E.jsx(je,{family:"mono",size:-1,color:"neutral",children:g})}),y.length===0)return null;const b=x=>x.field==="CWD",v=(x,_)=>b(_)?x:E.jsx(E.Fragment,{}),S={primary:[{icon:gG,tooltip:"Open in Cursor",onClick:x=>{!b(x)||!g||window.open(`cursor://file/${encodeURI(g)}`,"_blank")},wrapper:v},{icon:EG,tooltip:"Open in Finder",onClick:x=>{!b(x)||!g||fetch(sb("/api/open"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:g})})},wrapper:v},{icon:Eh,tooltip:"Copy path",wrapper:(x,_)=>b(_)&&g?E.jsx(Eye,{text:g}):E.jsx(E.Fragment,{})}]};return E.jsx(Ye,{py:4,fullwidth:!0,children:E.jsx(qt,{trimmed:!0,fullwidth:!0,children:E.jsx(eE,{children:E.jsx(tE,{children:E.jsx(rE,{children:y.map(x=>E.jsxs(nE,{children:[E.jsx(fh,{children:E.jsx(je,{weight:"bold",children:x.field})}),E.jsx(fh,{children:x.value}),E.jsx(dF,{actions:S,item:x})]},x.field))})})})})})}M6.displayName="StartedContent";class O6{diff(t,n,r={}){let i;typeof r=="function"?(i=r,r={}):"callback"in r&&(i=r.callback);const o=this.castInput(t,r),a=this.castInput(n,r),u=this.removeEmpty(this.tokenize(o,r)),c=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(u,c,r,i)}diffWithOptionsObj(t,n,r,i){var o;const a=_=>{if(_=this.postProcess(_,r),i){setTimeout(function(){i(_)},0);return}else return _},u=n.length,c=t.length;let f=1,h=u+c;r.maxEditLength!=null&&(h=Math.min(h,r.maxEditLength));const p=(o=r.timeout)!==null&&o!==void 0?o:1/0,g=Date.now()+p,y=[{oldPos:-1,lastComponent:void 0}];let b=this.extractCommon(y[0],n,t,0,r);if(y[0].oldPos+1>=c&&b+1>=u)return a(this.buildValues(y[0].lastComponent,n,t));let v=-1/0,S=1/0;const x=()=>{for(let _=Math.max(v,-f);_<=Math.min(S,f);_+=2){let R;const T=y[_-1],A=y[_+1];T&&(y[_-1]=void 0);let D=!1;if(A){const $=A.oldPos-_;D=A&&0<=$&&$<u}const O=T&&T.oldPos+1<c;if(!D&&!O){y[_]=void 0;continue}if(!O||D&&T.oldPos<A.oldPos?R=this.addToPath(A,!0,!1,0,r):R=this.addToPath(T,!1,!0,1,r),b=this.extractCommon(R,n,t,_,r),R.oldPos+1>=c&&b+1>=u)return a(this.buildValues(R.lastComponent,n,t))||!0;y[_]=R,R.oldPos+1>=c&&(S=Math.min(S,_-1)),b+1>=u&&(v=Math.max(v,_+1))}f++};if(i)(function _(){setTimeout(function(){if(f>h||Date.now()>g)return i(void 0);x()||_()},0)})();else for(;f<=h&&Date.now()<=g;){const _=x();if(_)return _}}addToPath(t,n,r,i,o){const a=t.lastComponent;return a&&!o.oneChangePerToken&&a.added===n&&a.removed===r?{oldPos:t.oldPos+i,lastComponent:{count:a.count+1,added:n,removed:r,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:n,removed:r,previousComponent:a}}}extractCommon(t,n,r,i,o){const a=n.length,u=r.length;let c=t.oldPos,f=c-i,h=0;for(;f+1<a&&c+1<u&&this.equals(r[c+1],n[f+1],o);)f++,c++,h++,o.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return h&&!o.oneChangePerToken&&(t.lastComponent={count:h,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=c,f}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){const i=[];let o;for(;t;)i.push(t),o=t.previousComponent,delete t.previousComponent,t=o;i.reverse();const a=i.length;let u=0,c=0,f=0;for(;u<a;u++){const h=i[u];if(h.removed)h.value=this.join(r.slice(f,f+h.count)),f+=h.count;else{if(!h.added&&this.useLongestToken){let p=n.slice(c,c+h.count);p=p.map(function(g,y){const b=r[f+y];return b.length>g.length?b:g}),h.value=this.join(p)}else h.value=this.join(n.slice(c,c+h.count));c+=h.count,h.added||(f+=h.count)}}return i}}const yO="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class _ye extends O6{tokenize(t){const n=new RegExp(`(\\r?\\n)|[${yO}]+|[^\\S\\n\\r]+|[^${yO}]`,"ug");return t.match(n)||[]}}const Tye=new _ye;function Aye(e,t,n){return Tye.diff(e,t,n)}class Dye extends O6{constructor(){super(...arguments),this.tokenize=$ye}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
|
|
519
|
+
`)?E.jsx(mC,{code:r.replace(/\n$/,""),language:Fge(e),rows:5,defaultExpanded:!1,HeaderProps:{copyable:!0},style:{width:"100%",marginBlockEnd:"0.5rem"}}):E.jsx(aI,{...n,children:t})}},Hge=[jge],Gge=[Tpe];function qge({children:e,components:t}){return E.jsx(Ye,{gap:4,fullwidth:!0,children:E.jsx(mpe,{remarkPlugins:Hge,rehypePlugins:Gge,components:{...Uge,...t},children:e})})}const ya=C.memo(qge),y6=()=>{var i;const e=yy(),{data:t=[]}=Si(mF),n=t.find(o=>o.active),r=async o=>{if((n==null?void 0:n.slug)!==o){try{await oce(o)}catch(a){console.error("Project switch failed:",a);return}e.invalidateQueries()}};return t.length===0?null:t.length===1?E.jsxs(Xe,{ay:"center",gap:2,px:2,children:[E.jsx(je,{size:-1,shade:"muted",children:"project"}),E.jsx(je,{size:-1,weight:"bold",children:(n==null?void 0:n.name)??((i=t[0])==null?void 0:i.name)??"default"})]}):E.jsxs(nb,{children:[E.jsx(rb,{render:E.jsx(Ci,{variant:"subtle",size:"small",fullwidth:!0,children:E.jsxs(Xe,{ay:"center",ax:"space-between",gap:2,fullwidth:!0,children:[E.jsxs(Xe,{ay:"center",gap:2,children:[E.jsx(je,{size:-1,shade:"muted",children:"project"}),E.jsx(je,{size:-1,weight:"bold",children:(n==null?void 0:n.name)??"—"})]}),E.jsx(xS,{size:14})]})})}),E.jsx(ah,{children:E.jsx(lh,{side:"bottom",align:"start",children:E.jsx(uh,{children:t.map(o=>E.jsx(Xc,{onClick:()=>{r(o.slug)},children:E.jsxs(Xe,{ay:"center",gap:2,children:[E.jsx(je,{size:-1,weight:o.active?"bold":"normal",children:o.name}),o.active&&E.jsx(je,{size:-1,shade:"muted",children:"(active)"})]})},o.slug))})})})]})};y6.displayName="ProjectSwitcher";const wE=({children:e,...t})=>E.jsx(Ye,{"data-slot":"sidebar",render:E.jsx("nav",{}),ax:"stretch",fullwidth:!0,gap:3,p:4,...t,children:e});wE.displayName="SidebarWrapper";const Vge=["active","waiting","paused","archived"],Yge={active:"Active",waiting:"Waiting",paused:"Paused",archived:"Archived"},Wge=["today","yesterday","thisWeek","earlier"],Kge={today:"Today",yesterday:"Yesterday",thisWeek:"This week",earlier:"Earlier"},Xge=1440*60*1e3;function Qge(e,t){const n=new Date(e),r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=new Date(n.getFullYear(),n.getMonth(),n.getDate()),o=Math.floor((r.getTime()-i.getTime())/Xge);return o<=0?"today":o===1?"yesterday":o<7?"thisWeek":"earlier"}function rx(e){const t=oE(e.session.status),n=e.session.status==="archived";return{value:e.session.id,label:E.jsx(v6,{session:e}),content:E.jsxs(Xe,{gap:2,ay:"center",mb:2,children:[E.jsx(My,{color:t}),E.jsx(x6,{session:e})]}),action:E.jsx(w6,{session:e.session,categoryPath:e.categoryPath}),"data-archived":n?"":void 0,style:n?{opacity:.4}:void 0}}function Zge(e,t){if(t==="status"){const r=new Map;for(const i of e){const o=i.session.status,a=r.get(o);a?a.push(i):r.set(o,[i])}return Vge.filter(i=>r.has(i)).map(i=>({category:Yge[i],collapsible:!0,items:r.get(i).map(rx)}))}if(t==="recent"){const r=new Date,i=new Map;for(const o of e){const a=Qge(o.session.startedAt,r),u=i.get(a);u?u.push(o):i.set(a,[o])}return Wge.filter(o=>i.has(o)).map(o=>({category:Kge[o],collapsible:!0,items:i.get(o).map(rx)}))}const n=new Map;for(const r of e){const i=r.categoryPath,o=n.get(i);o?o.push(r):n.set(i,[r])}return Array.from(n,([r,i])=>({category:r,collapsible:!0,items:i.map(rx)}))}const dO=e=>e.id??e.category??"",b6=({WrapperProps:e})=>{const[t,n]=C.useState(""),[r,i]=C.useState("group"),[o,a]=C.useState(!1),[u,c]=C.useState({}),f=C.useRef(null),{data:h=[]}=Si(dh({includeArchived:o})),p=C.useMemo(()=>{const S=t.trim().toLowerCase(),x=S?h.filter(_=>_.session.slug.toLowerCase().includes(S)||_.session.name.toLowerCase().includes(S)||_.categoryPath.toLowerCase().includes(S)):h;return Zge(x,r)},[h,t,r]),g=p.map(dO),y=g.length>0&&g.every(S=>u[S]!==!1),b=()=>{const S=!y;c(x=>{const _={...x};for(const R of g)_[R]=S;return _})},v=p.map(S=>{const x=dO(S);return{...S,open:u[x]??!0,onOpenChange:_=>c(R=>({...R,[x]:_}))}});return C.useEffect(()=>{const S=x=>{var _,R;(x.metaKey||x.ctrlKey)&&x.key==="k"&&(x.preventDefault(),(_=f.current)==null||_.focus(),(R=f.current)==null||R.select())};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[]),E.jsxs(wE,{...e,children:[E.jsx(y6,{}),E.jsx(Xe,{ay:"center",gap:2,fullwidth:!0,children:E.jsx(II,{ref:f,placeholder:"Search for a session",before:E.jsx(XG,{}),after:E.jsx(yP,{hotkey:["meta","k"]}),size:"small",fullwidth:!0,style:{flex:1,minWidth:0},value:t,onChange:S=>n(S.target.value)})}),E.jsxs(Xe,{ay:"center",ax:"space-between",gap:2,children:[E.jsxs(VC,{size:"sm",value:[r],onValueChange:S=>{const x=S[0];x&&i(x)},children:[E.jsx(xc,{value:"group","aria-label":"Group by group",children:E.jsx($l,{trigger:E.jsx(OG,{}),children:"Group by group"})}),E.jsx(xc,{value:"status","aria-label":"Group by status",children:E.jsx($l,{trigger:E.jsx(nq,{}),children:"Group by status"})}),E.jsx(xc,{value:"recent","aria-label":"Group by recent",children:E.jsx($l,{trigger:E.jsx(Q3,{}),children:"Group by recent"})})]}),E.jsxs(Xe,{ay:"center",gap:1,children:[E.jsx(Qd,{size:"small",shape:"square",variant:"subtle",tooltip:o?"Hide archived":"Show archived",pressed:o,onPressedChange:a,icon:{unpressed:E.jsx(bG,{}),pressed:E.jsx(xG,{})}}),p.length>0&&E.jsx(Qd,{size:"small",shape:"square",variant:"subtle",tooltip:y?"Collapse all":"Expand all",pressed:!y,onPressedChange:()=>b(),icon:{unpressed:E.jsx(sG,{}),pressed:E.jsx(xS,{})}})]})]}),p.length===0?E.jsxs(je,{size:-1,shade:"muted",style:{padding:"0.5rem"},children:['No sessions match "',t,'".']}):E.jsx(Kc,{items:v,line:!0,size:"small"})]})};b6.displayName="Sidebar";const v6=({session:e})=>E.jsx(ef,{to:"/$",params:{_splat:`${e.categoryPath}/${e.session.slug}`},children:e.session.slug});v6.displayName="SessionLabel";const x6=({session:e})=>{const{data:t=[]}=Si(dh()),n=t.some(p=>p.session.status==="active"||p.session.status==="waiting"),{data:r}=Si(nce(n)),{data:i}=Si(ice),o=r==null?void 0:r[e.session.id],a=i==null?void 0:i[e.session.id],u=(o==null?void 0:o.linesAdded)??0,c=(o==null?void 0:o.linesRemoved)??0,f=(o==null?void 0:o.filesTouched)??0,h=u>0||c>0;return E.jsxs(Xe,{ay:"center",gap:2,children:[E.jsx(je,{size:-1,shade:"muted",children:Bw(e.session.startedAt)}),h&&E.jsxs(Xe,{ay:"center",gap:1,children:[E.jsx(je,{size:-1,family:"mono",color:"green",children:`+${u}`}),E.jsx(je,{size:-1,family:"mono",color:"red",children:`-${c}`})]}),f>0&&E.jsxs(Xe,{ay:"center",gap:1,children:[E.jsx(e4,{size:12}),E.jsx(je,{size:-1,family:"mono",shade:"muted",children:f})]}),a&&E.jsx(G$,{TriggerProps:{openOnHover:!0},trigger:E.jsx(zG,{size:12,"aria-label":"Session recap"}),title:"Session recap",description:Bw(a.createdAt),PositionerProps:{sideOffset:8,side:"right"},PopupProps:{style:{maxWidth:420}},children:E.jsx(Ye,{my:2,children:E.jsx(ya,{children:a.recap})})}),e.session.rating!==null&&e.session.rating!==void 0&&E.jsx(je,{"aria-label":`Rated ${e.session.rating} of 5 stars`,children:[1,2,3,4,5].map(p=>p<=e.session.rating?"★":"☆").join("")})]})};x6.displayName="SessionContent";const w6=({session:e,categoryPath:t})=>{const n=gF(e),{Icon:r}=n,i=e.status==="paused",o=`${t}/${e.slug}`;return E.jsxs(nb,{children:[E.jsx(rb,{render:E.jsx(Ci,{variant:"ghost",size:"xsmall",shape:"square","aria-label":"Session actions",children:E.jsx(pG,{})})}),E.jsx(ah,{children:E.jsx(lh,{side:"bottom",align:"end",children:E.jsxs(uh,{children:[E.jsxs(Xc,{disabled:n.disabled,onClick:n.onClick,render:E.jsx(Xe,{ay:"center",gap:2}),children:[E.jsx(r,{size:14}),n.label]}),E.jsxs(Xc,{disabled:!i,onClick:()=>{navigator.clipboard.writeText(o)},render:E.jsx(Xe,{ay:"center",gap:2}),children:[E.jsx(Eh,{size:14}),"Copy session path"]})]})})})]})};w6.displayName="SessionRowActions";const S6=({children:e,...t})=>E.jsx(Xe,{"data-slot":"top-bar-wrapper",fullwidth:!0,ay:"center",p:4,gap:4,bb:1,style:{position:"sticky",top:0,backgroundColor:"var(--shade-background)",zIndex:1,...t.style},...t,children:e});S6.displayName="TopBarWrapper";const Ud="uiid-theme";function Jge(){return localStorage.getItem(Ud)??"system"}function eye(e){const t=n=>{n.key===Ud&&e()};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)}function tye(e){e==="system"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",e)}function nye(){const e=C.useSyncExternalStore(eye,Jge),t=C.useCallback(n=>{n==="system"?localStorage.removeItem(Ud):localStorage.setItem(Ud,n),tye(n),window.dispatchEvent(new StorageEvent("storage",{key:Ud,newValue:n}))},[]);return{theme:e,setTheme:t}}const C6=()=>{const{theme:e,setTheme:t}=nye();return E.jsxs(VC,{value:[e],onValueChange:n=>{const r=n[0];r&&t(r)},size:"sm",children:[E.jsx(xc,{value:"light","aria-label":"Light mode",children:E.jsx(eq,{})}),E.jsx(xc,{value:"dark","aria-label":"Dark mode",children:E.jsx(VG,{})}),E.jsx(xc,{value:"system","aria-label":"System theme",children:E.jsx(GG,{})})]})};C6.displayName="ThemeToggle";const SE=({sessionCount:e})=>E.jsxs(S6,{children:[E.jsx(je,{size:2,weight:"bold",children:"bertrand"}),E.jsx(C.Activity,{mode:e?"visible":"hidden",children:E.jsxs(cn,{color:"blue",children:[e," session(s)"]})}),E.jsxs(Xe,{gap:3,ay:"center",ml:"auto",children:[E.jsxs(Xe,{gap:2,ay:"center",children:[E.jsx(ix,{to:"/",tooltip:"Session timeline",icon:E.jsx(nG,{})}),E.jsx(ix,{to:"/dev/markdown",tooltip:"Markdown viewer",icon:E.jsx(eG,{})}),E.jsx(ix,{to:"/dev/diff",tooltip:"Diff viewer",icon:E.jsx(J3,{})})]}),E.jsx(C6,{})]})]});SE.displayName="TopBar";const ix=({to:e,tooltip:t,icon:n})=>E.jsx(Ci,{render:E.jsx(ef,{to:e}),nativeButton:!1,tooltip:t,variant:"subtle",size:"small",shape:"square",children:n}),Yh=$7({component:rye});function rye(){return K7({select:t=>t.location.pathname}).startsWith("/dev/")?E.jsxs(Ye,{fullwidth:!0,style:{position:"fixed",inset:0,height:"100dvh"},children:[E.jsx(SE,{}),E.jsx(Ye,{render:E.jsx("main",{}),fullwidth:!0,style:{flex:1,overflow:"auto"},children:E.jsx(fS,{})})]}):E.jsx(iye,{})}function iye(){const{data:e=[]}=Si(dh());return E.jsxs(Ye,{fullwidth:!0,style:{position:"fixed",height:"100dvh"},children:[E.jsx(SE,{sessionCount:e.length}),E.jsxs(rF,{direction:"horizontal",children:[E.jsx(zw,{defaultSize:360,minSize:320,maxSize:540,children:E.jsx(b6,{})}),E.jsx(iF,{}),E.jsx(zw,{children:E.jsx(Ye,{render:E.jsx("main",{}),fullwidth:!0,fullheight:!0,children:E.jsx(fS,{})})})]})]})}const oye=new Set(["session.started","session.resumed","session.end"]),sye=e=>{const t=new Map;for(let r=0;r<e.length-1;r++){const i=e[r],o=e[r+1];i.event==="session.started"&&o.event==="claude.started"&&i.conversationId===o.conversationId&&t.set(r+1,{...i.meta??{},...o.meta??{}})}const n=[];for(let r=0;r<e.length;r++){const i=e[r];if(oye.has(i.event))continue;const o=t.get(r);n.push(o?{...i,meta:o}:i)}return n},aye=e=>{var r;const t=[],n=new Set;for(let i=0;i<e.length;i++){if(n.has(i))continue;const o=e[i];if(o.event==="session.waiting"){let a=i+1;const u=[];for(;a<e.length&&(e[a].event==="context.snapshot"||e[a].event==="assistant.recap");)e[a].event==="assistant.recap"&&u.push(e[a]),a++;if(a<e.length&&e[a].event==="session.answered"){for(const f of u)t.push(f);const c=(r=o.meta)==null?void 0:r.question;t.push({...e[a],meta:{...e[a].meta,question:c}});for(let f=i;f<=a;f++)n.add(f);continue}}t.push(o)}return t};function gy(e){return e.edits&&e.edits.length>0?e.edits:e.oldStr||e.newStr?[{oldStr:e.oldStr??"",newStr:e.newStr??""}]:[]}function hO(e){const t=e.meta,n=e.event==="permission.resolve"?"approved":e.event==="tool.used"?"auto":"pending";return{tool:(t==null?void 0:t.tool)??"unknown",detail:(t==null?void 0:t.detail)??"",outcome:(t==null?void 0:t.outcome)??n}}const E6={Bash:"ran",Edit:"edited",MultiEdit:"edited",Write:"wrote",Read:"read",Glob:"globbed",Grep:"grepped",WebFetch:"fetched",WebSearch:"searched",TodoWrite:"updated todos"},lye={Bash:"commands",Edit:"files",MultiEdit:"files",Write:"files",Read:"files",Glob:"patterns",Grep:"patterns",WebFetch:"urls",WebSearch:"queries"},uye=new Set(["Edit","MultiEdit","Write","Read"]);function cye(e){return e.split("/").filter(Boolean).pop()??e}function pO(e,t){return e.length<=t?e:e.slice(0,t-1)+"…"}function fye(e){const t=E6[e.tool]??e.tool;return e.detail?e.tool==="Bash"?`ran \`${pO(e.detail,60)}\``:uye.has(e.tool)?`${t} ${cye(e.detail)}`:`${t} ${pO(e.detail,60)}`:t}function dye(e){const t=[];for(const[n,r]of e){const i=E6[n]??n;if(r===1)t.push(i);else{const o=lye[n]??"calls";t.push(`${i} ${r} ${o}`)}}return t.join(", ")}const mO=new Set(["permission.request","permission.resolve","tool.used"]),hye=e=>{const t=[];let n=0;for(;n<e.length;){const r=e[n];if(!mO.has(r.event)){t.push(r),n++;continue}const i=[];for(;n<e.length;){const h=e[n];if(!mO.has(h.event))break;i.push(h),n++}const o=i.filter(h=>h.event==="permission.request"||h.event==="tool.used");if(o.length===0)continue;const a=o.map(hO),u=i.some(h=>h.event==="permission.resolve"),c=new Map;for(const h of a){const p=`${h.tool}::${h.detail}`,g=c.get(p);if(g){g.count++;const y=[...gy(g),...gy(h)];y.length>0&&(g.edits=y,g.oldStr=void 0,g.newStr=void 0)}else c.set(p,{...h,count:1})}const f=[...c.values()];if(f.length<=1){const h=f[0]??hO(i[0]),p=fye(h);t.push({...i[i.length-1],event:"tool.work",summary:p,meta:{...i[i.length-1].meta,permissions:f,outcome:u?"approved":"pending"}})}else{const h=new Map;for(const v of f)h.set(v.tool,(h.get(v.tool)??0)+v.count);const p=[...h.entries()].sort((v,S)=>S[1]-v[1]),g=dye(p),y=new Date(i[0].createdAt).getTime(),b=new Date(i[i.length-1].createdAt).getTime();t.push({...i[0],event:"tool.work",summary:g,meta:{permissions:f,outcome:u?"approved":"pending"},createdAt:new Date((y+b)/2).toISOString()})}}return t},pye={Edit:"edited a file",Write:"wrote a file",MultiEdit:"edited a file"},mye=e=>{const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r.event!=="tool.applied"){t.push(r),n++;continue}const i=[];for(;n<e.length&&e[n].event==="tool.applied";)i.push(e[n]),n++;if(i.length===1){t.push(i[0]);continue}const o=[];for(const f of i){const h=f.meta,p=h==null?void 0:h.permissions;if(Array.isArray(p))for(const g of p)o.push(g)}const a=new Map;for(const f of o){const h=`${f.tool}::${f.detail}`,p=a.get(h),g=f.count??1;if(p){p.count+=g;const y=[...gy(p),...gy(f)];y.length>0&&(p.edits=y,p.oldStr=void 0,p.newStr=void 0)}else a.set(h,{...f,count:g})}const u=[...a.values()],c=i[i.length-1];t.push({...c,meta:{...c.meta,permissions:u}})}return t},gye=e=>e.map(t=>{var o;if(t.event!=="tool.applied"||t.summary)return t;const n=t.meta,r=(n==null?void 0:n.permissions)??[];if(r.length>1)return{...t,summary:`edited ${r.length} files`};const i=(o=r[0])==null?void 0:o.tool;return i?{...t,summary:pye[i]??`${i} applied`}:t}),yye=e=>{const t=new Set(["claude.started","claude.ended","claude.discarded"]);return e.map((n,r)=>{if(!t.has(n.event))return n;const i=n.meta;if(i!=null&&i.model)return n;const o=(i==null?void 0:i.claude_id)??n.conversationId;if(!o)return n;const u=n.event==="claude.started"?e.slice(r+1):e.slice(0,r).reverse();for(const c of u){if(c.event!=="context.snapshot")continue;const f=c.meta;if(((f==null?void 0:f.claude_id)??c.conversationId)!==o)continue;const p=f==null?void 0:f.model;if(p)return{...n,meta:{...i,model:p}}}return n})},bye=[sye,aye,hye,mye,gye,yye];function vye(e){return bye.reduce((t,n)=>n(t),e)}function gO(e,t){const n=e.replace(/^\/+|\/+$/g,"");return n.includes("/")?t.find(r=>`${r.categoryPath}/${r.session.slug}`===n)??null:null}function xye(e){return e<1500?"●○○":e<5e3?"●●○":"●●●"}const wye=/<recap>[\s\S]*?<\/recap>/gi;function k6({event:e}){var a;const t=e.meta;if(e.event==="assistant.recap"){const u=(a=t==null?void 0:t.recap)==null?void 0:a.trim();return u?E.jsx(Ye,{"data-slot":"assistant-recap",py:4,children:E.jsx(qt,{children:E.jsx(ya,{children:u})})}):null}const r=((t==null?void 0:t.text)??"").replace(wye,"").trim(),i=(t==null?void 0:t.thinkingBlocks)??0,o=(t==null?void 0:t.thinkingBytes)??0;return!r&&i===0?null:E.jsxs(Ye,{"data-slot":"assistant-content",gap:2,children:[i>0&&E.jsx(cn,{color:"indigo",children:`Thought ${xye(o)}`}),r&&E.jsx(ya,{children:r})]})}k6.displayName="AssistantContent";function R6({event:e}){const t=e.meta;if(!t)return null;const n=to(t.remaining_pct),r=to(t.context_window_tokens),i=to(t.input_tokens),o=to(t.cache_read_tokens),a=to(t.cache_creation_tokens),u=ab(t.model);return r===0?null:E.jsxs(Ye,{"data-slot":"context-content",gap:3,fullwidth:!0,children:[E.jsx(XS,{value:n,size:"small",color:yF(n)}),E.jsxs(Xe,{gap:2,children:[u&&E.jsx(cn,{size:"small",children:u}),i>0&&E.jsx(cn,{size:"small",color:"orange",children:`${Jo(i)} input`}),o>0&&E.jsx(cn,{size:"small",color:"blue",children:`${Jo(o)} cache read`}),a>0&&E.jsx(cn,{size:"small",color:"indigo",children:`${Jo(a)} cache write`})]})]})}R6.displayName="ContextContent";function yO(e,t){return e==null?void 0:e.find(n=>n.question===t)}function Sye(e,t,n){const r=[...t].sort((a,u)=>u.label.length-a.label.length),i=[];let o=e;for(;o;){const a=r.find(u=>o===u.label||o.startsWith(u.label+", "));if(!a)break;if(i.push(a.label),o===a.label){o="";break}if(o=o.slice(a.label.length+2),!n)break}return{selectedLabels:i,note:o||void 0}}function _6({event:e}){const t=e.meta;if(e.event==="session.answered"){const n=t==null?void 0:t.answers;if(!n||Object.keys(n).length===0)return null;const r=t==null?void 0:t.questions,i=Object.entries(n),o=(u,c)=>{const f=yO(r,u),h=(f==null?void 0:f.multiSelect)??!1,p=(f==null?void 0:f.options)??[],{selectedLabels:g,note:y}=Sye(c,p,h),b=g.length>0,v=b?void 0:y??c,S=b?y:void 0;return E.jsxs(Ye,{gap:4,fullwidth:!0,children:[v&&E.jsxs(Ye,{"data-slot":"interaction-content-note",gap:4,m:2,fullwidth:!0,children:[E.jsx(je,{color:"yellow",weight:"bold",size:1,children:"Answered manually:"}),E.jsx(ya,{children:v})]}),!b&&!v&&E.jsx(je,{color:"red",weight:"bold",size:1,m:2,children:"Didn't answer."}),p.length>0&&E.jsx(Kc,{type:"ordered",items:p.map(x=>({value:x.label,label:E.jsx(je,{weight:"bold",color:g.includes(x.label)?"green":void 0,children:x.label}),description:x.description,disabled:!g.includes(x.label)}))}),S&&E.jsxs(Ye,{"data-slot":"interaction-content-note",gap:4,m:2,fullwidth:!0,children:[E.jsx(je,{color:"green",weight:"bold",size:1,children:"Additional notes:"}),E.jsx(ya,{children:S})]})]})};if(i.length===1){const[u,c]=i[0];return E.jsx(Ye,{"data-slot":"interaction-content",gap:2,py:4,fullwidth:!0,children:E.jsx(qt,{gap:4,fullwidth:!0,children:o(u,c)})})}const a=i.map(([u,c],f)=>{const h=yO(r,u);return{label:(h==null?void 0:h.header)??`Question ${f+1}`,value:u,render:o(u,c)}});return E.jsx(Ye,{"data-slot":"interaction-content",gap:2,py:4,fullwidth:!0,children:E.jsx(qt,{gap:4,fullwidth:!0,children:E.jsx(qC,{items:a,ContainerProps:{fullwidth:!0,mt:6}})})})}if(e.event==="user.prompt"){const n=t==null?void 0:t.prompt;return n?E.jsx(T6,{children:E.jsx(ya,{children:n})}):null}return null}_6.displayName="InteractionContent";const T6=({children:e})=>E.jsx(Ye,{"data-slot":"interaction-content",py:4,fullwidth:!0,children:E.jsx(qt,{gap:4,fullwidth:!0,children:e})});T6.displayName="CardContainer";function Cye(e){if(e)return e.slice(0,8)}function A6({event:e}){if(e.event==="claude.started")return null;const t=e.meta;if(e.event==="session.recap"){const u=t==null?void 0:t.recap;return u?E.jsx(Ye,{py:4,children:E.jsx(qt,{children:E.jsx(ya,{children:u})})}):null}const n=(t==null?void 0:t.claude_id)??e.conversationId??void 0,r=ab(t==null?void 0:t.model),i=Cye(n??void 0),o=e.event==="claude.ended"?t==null?void 0:t.exit_code:void 0,a=typeof o=="number"&&o!==0;return!r&&!i&&!a?null:E.jsxs(Xe,{gap:2,ay:"center",children:[r&&E.jsx(cn,{color:"orange",size:"small",children:r}),i&&E.jsx(cn,{color:"neutral",size:"small",children:i}),a&&E.jsx(cn,{color:"red",size:"small",children:`exit ${o}`})]})}A6.displayName="LifecycleContent";function D6({event:e}){const t=e.meta;if(!t)return null;switch(e.event){case"gh.pr.created":{const n=t.pr_title,r=t.pr_url;return E.jsxs(E.Fragment,{children:[n&&E.jsx(je,{size:1,children:n}),r&&E.jsx(je,{size:-1,family:"mono",color:"neutral",children:r})]})}case"gh.pr.merged":{const n=t.branch;return n?E.jsx(je,{size:1,family:"mono",children:n}):null}case"vercel.deploy":{const n=t.project_name;return n?E.jsx(je,{size:1,children:n}):null}default:return null}}D6.displayName="MilestoneContent";function Eye({text:e}){const[t,n]=C.useState(!1);return E.jsx(Ci,{size:"small",variant:"ghost",shape:"square",tooltip:t?"Copied!":"Copy path",disabled:t,onClick:()=>{navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)},children:t?E.jsx(Ch,{color:"green"}):E.jsx(Eh,{})})}function kye(e){if(e)return e.slice(0,8)}function Rye(e){if(e)return e.slice(0,7)}function M6({event:e}){const t=e.meta;if(!t)return null;const n=t.labels??[],r=t.summary,i=t.claude_id??e.conversationId??void 0,o=ab(t.model),a=t.claude_version,u=kye(i),c=t.git??void 0,f=c==null?void 0:c.branch,h=Rye(c==null?void 0:c.sha),p=!!(c!=null&&c.dirty),g=t.cwd,y=[];if(n.length>0&&y.push({field:"Labels",value:n.join(", ")}),r&&y.push({field:"Summary",value:r}),o&&y.push({field:"Model",value:E.jsx(cn,{color:"orange",size:"small",children:o})}),a&&y.push({field:"Version",value:E.jsx(cn,{color:"neutral",size:"small",children:a})}),u&&y.push({field:"Claude ID",value:E.jsx(cn,{color:"neutral",size:"small",children:u})}),f&&y.push({field:"Branch",value:E.jsxs(Xe,{gap:2,ay:"center",children:[E.jsx(cn,{color:"neutral",size:"small",children:f}),h&&E.jsx(cn,{color:"neutral",size:"small",children:h}),p&&E.jsx(cn,{color:"red",size:"small",children:"dirty"})]})}),g&&y.push({field:"CWD",value:E.jsx(je,{family:"mono",size:-1,color:"neutral",children:g})}),y.length===0)return null;const b=x=>x.field==="CWD",v=(x,_)=>b(_)?x:E.jsx(E.Fragment,{}),S={primary:[{icon:gG,tooltip:"Open in Cursor",onClick:x=>{!b(x)||!g||window.open(`cursor://file/${encodeURI(g)}`,"_blank")},wrapper:v},{icon:EG,tooltip:"Open in Finder",onClick:x=>{!b(x)||!g||fetch(sb("/api/open"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:g})})},wrapper:v},{icon:Eh,tooltip:"Copy path",wrapper:(x,_)=>b(_)&&g?E.jsx(Eye,{text:g}):E.jsx(E.Fragment,{})}]};return E.jsx(Ye,{py:4,fullwidth:!0,children:E.jsx(qt,{trimmed:!0,fullwidth:!0,children:E.jsx(eE,{children:E.jsx(tE,{children:E.jsx(rE,{children:y.map(x=>E.jsxs(nE,{children:[E.jsx(fh,{children:E.jsx(je,{weight:"bold",children:x.field})}),E.jsx(fh,{children:x.value}),E.jsx(dF,{actions:S,item:x})]},x.field))})})})})})}M6.displayName="StartedContent";class O6{diff(t,n,r={}){let i;typeof r=="function"?(i=r,r={}):"callback"in r&&(i=r.callback);const o=this.castInput(t,r),a=this.castInput(n,r),u=this.removeEmpty(this.tokenize(o,r)),c=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(u,c,r,i)}diffWithOptionsObj(t,n,r,i){var o;const a=_=>{if(_=this.postProcess(_,r),i){setTimeout(function(){i(_)},0);return}else return _},u=n.length,c=t.length;let f=1,h=u+c;r.maxEditLength!=null&&(h=Math.min(h,r.maxEditLength));const p=(o=r.timeout)!==null&&o!==void 0?o:1/0,g=Date.now()+p,y=[{oldPos:-1,lastComponent:void 0}];let b=this.extractCommon(y[0],n,t,0,r);if(y[0].oldPos+1>=c&&b+1>=u)return a(this.buildValues(y[0].lastComponent,n,t));let v=-1/0,S=1/0;const x=()=>{for(let _=Math.max(v,-f);_<=Math.min(S,f);_+=2){let R;const T=y[_-1],A=y[_+1];T&&(y[_-1]=void 0);let D=!1;if(A){const $=A.oldPos-_;D=A&&0<=$&&$<u}const O=T&&T.oldPos+1<c;if(!D&&!O){y[_]=void 0;continue}if(!O||D&&T.oldPos<A.oldPos?R=this.addToPath(A,!0,!1,0,r):R=this.addToPath(T,!1,!0,1,r),b=this.extractCommon(R,n,t,_,r),R.oldPos+1>=c&&b+1>=u)return a(this.buildValues(R.lastComponent,n,t))||!0;y[_]=R,R.oldPos+1>=c&&(S=Math.min(S,_-1)),b+1>=u&&(v=Math.max(v,_+1))}f++};if(i)(function _(){setTimeout(function(){if(f>h||Date.now()>g)return i(void 0);x()||_()},0)})();else for(;f<=h&&Date.now()<=g;){const _=x();if(_)return _}}addToPath(t,n,r,i,o){const a=t.lastComponent;return a&&!o.oneChangePerToken&&a.added===n&&a.removed===r?{oldPos:t.oldPos+i,lastComponent:{count:a.count+1,added:n,removed:r,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:n,removed:r,previousComponent:a}}}extractCommon(t,n,r,i,o){const a=n.length,u=r.length;let c=t.oldPos,f=c-i,h=0;for(;f+1<a&&c+1<u&&this.equals(r[c+1],n[f+1],o);)f++,c++,h++,o.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return h&&!o.oneChangePerToken&&(t.lastComponent={count:h,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=c,f}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){const i=[];let o;for(;t;)i.push(t),o=t.previousComponent,delete t.previousComponent,t=o;i.reverse();const a=i.length;let u=0,c=0,f=0;for(;u<a;u++){const h=i[u];if(h.removed)h.value=this.join(r.slice(f,f+h.count)),f+=h.count;else{if(!h.added&&this.useLongestToken){let p=n.slice(c,c+h.count);p=p.map(function(g,y){const b=r[f+y];return b.length>g.length?b:g}),h.value=this.join(p)}else h.value=this.join(n.slice(c,c+h.count));c+=h.count,h.added||(f+=h.count)}}return i}}const bO="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class _ye extends O6{tokenize(t){const n=new RegExp(`(\\r?\\n)|[${bO}]+|[^\\S\\n\\r]+|[^${bO}]`,"ug");return t.match(n)||[]}}const Tye=new _ye;function Aye(e,t,n){return Tye.diff(e,t,n)}class Dye extends O6{constructor(){super(...arguments),this.tokenize=$ye}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
|
|
520
520
|
`))&&(t=t.trim()),(!r.newlineIsToken||!n.includes(`
|
|
521
521
|
`))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(t.endsWith(`
|
|
522
522
|
`)&&(t=t.slice(0,-1)),n.endsWith(`
|
|
@@ -528,7 +528,7 @@ XID_Start XIDS`.split(/\s/).map(e=>[jy(e),e])),Pte=new Map([["s",kn(383)],[kn(38
|
|
|
528
528
|
`);return[i(e),i(t)]}function Nye(e,t){const n=[],r=[],i=[];function o(h,p){const g=n.length,b=(h.endsWith(`
|
|
529
529
|
`)?h.slice(0,-1):h).split(`
|
|
530
530
|
`);for(const v of b)n.push(v),r.push(p);return{startIdx:g,lns:b}}for(let h=0;h<e.length;h++){h>0&&(n.push("…"),r.push("separator"));const{oldStr:p,newStr:g}=e[h],[y,b]=Pye(p,g),v=Oye(y,b);let S=0;for(;S<v.length;){const x=v[S];if(x.removed&&S+1<v.length&&v[S+1].added){const _=o(x.value,"remove"),R=o(v[S+1].value,"add"),T=t?Math.min(_.lns.length,R.lns.length):0;for(let A=0;A<T;A++){const D=Aye(_.lns[A],R.lns[A]);let O=0,$=0;for(const z of D){const j=z.value.length;z.added?(j>0&&i.push({start:{line:R.startIdx+A,character:$},end:{line:R.startIdx+A,character:$+j},properties:{class:"diff-word add"}}),$+=j):z.removed?(j>0&&i.push({start:{line:_.startIdx+A,character:O},end:{line:_.startIdx+A,character:O+j},properties:{class:"diff-word remove"}}),O+=j):(O+=j,$+=j)}}S+=2}else x.removed?(o(x.value,"remove"),S+=1):x.added?(o(x.value,"add"),S+=1):(o(x.value,"context"),S+=1)}}const a=[];let u=1,c=1;for(const h of r)h==="separator"?a.push({old:null,new:null}):h==="remove"?a.push({old:u++,new:null}):h==="add"?a.push({old:null,new:c++}):a.push({old:u++,new:c++});const f=Math.max(u-1,c-1,1);return{code:n.join(`
|
|
531
|
-
`),lineKinds:r,lineNums:a,decorations:i,maxLineNum:f}}function ox(e,t){e.properties||(e.properties={});const n=e.properties.class;typeof n=="string"?e.properties.class=n?`${n} ${t}`:t:Array.isArray(n)?e.properties.class=[...n,t]:e.properties.class=t}function sx(e,t){return{type:"element",tagName:"span",properties:{class:e},children:[{type:"text",value:t}]}}const Iye={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",json:"json",md:"markdown",markdown:"markdown",css:"css",html:"html",htm:"html",py:"python",sh:"bash",bash:"bash",zsh:"bash"};function jye(e,t){if(!e)return t;const n=e.split("/").pop()??e,r=n.includes(".")?n.split(".").pop().toLowerCase():"";return Iye[r]??t}function CE({edits:e,oldStr:t,newStr:n,language:r,filename:i,wordDiff:o=!1,rows:a,defaultExpanded:u}){var v;const c=e&&e.length>0?e:[{oldStr:t??"",newStr:n??""}],f=r??jye(i,"tsx"),[h,p]=C.useState(""),[g,y]=C.useState(1);C.useEffect(()=>{let S=!1;return(async()=>{const{code:x,lineKinds:_,lineNums:R,decorations:T,maxLineNum:A}=Nye(c,o);await eI(f);const O=(await pC()).codeToHtml(x,{lang:f,themes:{light:"vitesse-light",dark:"vitesse-black"},defaultColor:!1,decorations:T,transformers:[{name:"diff-block:line-marks",pre($){ox($,"has-diff")},line($,z){const j=z-1,I=_[j],M=R[j];if(I==="add"||I==="remove")ox($,`diff ${I}`);else if(I==="separator")return ox($,"diff-separator"),$;const B=I==="add"?"diff-marker add":I==="remove"?"diff-marker remove":"diff-marker",G=I==="add"?"+":I==="remove"?"-":" ",L="diff-num diff-num-old"+(M.old==null?" diff-num-blank":""),F="diff-num diff-num-new"+(M.new==null?" diff-num-blank":""),U=[sx(L,M.old!=null?String(M.old):" "),sx(F,M.new!=null?String(M.new):" "),sx(B,G)];return $.children.unshift(...U),$}}]});S||(p(O),y(String(A).length))})(),()=>{S=!0}},[c,f,o]);const b=((v=c[c.length-1])==null?void 0:v.newStr)??"";return E.jsx("div",{className:"bertrand-diff-block",style:{"--diff-num-width":`${g+2}ch`,width:"100%"},children:E.jsx(mC,{code:b,language:f,filename:i,showLineNumbers:!1,rows:a,defaultExpanded:u,HeaderProps:{copyable:!1},html:h,style:{width:"100%"}})})}CE.displayName="DiffBlock";const Lye=5;function Qw(e){return!!(e.oldStr||e.newStr||e.edits&&e.edits.length>0)}function $6({permission:e}){const t=e.edits&&e.edits.length>0?e.edits.map(n=>({oldStr:n.oldStr??"",newStr:n.newStr??""})):[{oldStr:e.oldStr??"",newStr:e.newStr??""}];return E.jsx(CE,{edits:t,filename:e.detail,rows:Lye,defaultExpanded:!1})}function Fye(e){const t=e.count>1?`${e.count}× `:"";return e.detail?`${t}${e.detail}`:`${t}${e.tool}`}function P6({permission:e}){return E.jsx(je,{size:-1,family:"mono",shade:"muted",children:Fye(e)})}function N6({event:e}){const t=e.meta;if(!(t!=null&&t.permissions))return null;const n=t.permissions;if(n.length===0)return null;if(n.length===1){const r=n[0];return r.detail?Qw(r)?E.jsx($6,{permission:r}):E.jsx(P6,{permission:r}):null}return E.jsx(zye,{permissions:n})}function zye({permissions:e}){const t=e.filter(Qw),n=e.filter(r=>!Qw(r));return E.jsxs(Ye,{"data-slot":"work-content",gap:2,fullwidth:!0,children:[t.length>0&&E.jsx(Ye,{gap:2,fullwidth:!0,children:t.map((r,i)=>E.jsx($6,{permission:r},`diff-${i}`))}),n.length>0&&E.jsx(Ye,{gap:1,fullwidth:!0,children:n.map((r,i)=>E.jsx(P6,{permission:r},`info-${i}`))})]})}N6.displayName="WorkContent";function I6({event:e}){if(e.event==="claude.started")return E.jsx(M6,{event:e});switch(uce(e.event)){case"interaction":return E.jsx(_6,{event:e});case"work":return E.jsx(N6,{event:e});case"milestone":return E.jsx(D6,{event:e});case"assistant":return E.jsx(k6,{event:e});case"context":return E.jsx(R6,{event:e});case"lifecycle":return E.jsx(A6,{event:e});default:return null}}I6.displayName="EventContent";const j6=({sessionId:e,isLive:t,...n})=>{const{data:r}=Si({...tce(e,t),enabled:!!e}),{data:i}=Si({...rce(e,t),enabled:!!e});return E.jsx(wE,{"data-slot":"secondary-sidebar",...n,p:0,minw:540,children:r&&E.jsx(L6,{stats:r,engagement:i})})};j6.displayName="SecondarySidebar";function Bye(e){return Object.entries(e).sort(([,t],[,n])=>n-t).slice(0,3).map(([t,n])=>`${t} ${n}`).join(" · ")}const L6=({stats:e,engagement:t})=>{const n=e.linesAdded>0||e.linesRemoved>0,r=e.filesTouched>0,i=n||r||e.prCount>0,o=t?Object.values(t.toolUsage).reduce((p,g)=>p+g,0):0,a=((t==null?void 0:t.contextTokens.max)??0)>0,u=(t==null?void 0:t.permissionDenials)??0,c=(t==null?void 0:t.discardRate.total)??0,f=!!t&&(o>0||a||u>0||c>0),h=[{label:"Activity",value:"activity",render:E.jsxs(vg,{children:[E.jsx(qt,{title:"Conversations",description:"Distinct conversation threads",icon:LG,action:E.jsx(zr,{value:e.conversationCount})}),E.jsx(qt,{title:"Interactions",description:"User-Claude exchanges",icon:PG,action:E.jsx(zr,{value:e.interactionCount})}),E.jsx(qt,{title:"Events",description:"Total events emitted",icon:ZH,action:E.jsx(zr,{value:e.eventCount})}),E.jsx(qt,{title:"Duration",description:"Total session time",icon:Q3,action:E.jsx(zr,{label:z1(e.durationS)})}),E.jsx(qt,{title:"Claude work",description:"Time Claude spent active",icon:fG,action:E.jsx(zr,{label:z1(e.claudeWorkS)})}),E.jsx(qt,{title:"User wait",description:"Time user spent waiting",icon:IG,action:E.jsx(zr,{label:z1(e.userWaitS)})})]})}];return i&&h.push({label:"Code",value:"code",render:E.jsxs(vg,{children:[n&&E.jsx(qt,{title:"Lines changed",description:"Across all edits",icon:J3,action:E.jsx(F6,{added:e.linesAdded,removed:e.linesRemoved})}),r&&E.jsx(qt,{title:"Files touched",description:"Distinct files edited",icon:e4,action:E.jsx(zr,{value:e.filesTouched})}),e.prCount>0&&E.jsx(qt,{title:"PRs",description:"Pull requests created",icon:TG,action:E.jsx(zr,{value:e.prCount})})]})}),f&&h.push({label:"Engagement",value:"engagement",render:E.jsxs(vg,{children:[o>0&&E.jsx(qt,{title:"Tracked tool calls",description:Bye(t.toolUsage),icon:uq,action:E.jsx(zr,{value:o})}),a&&E.jsx(qt,{title:"Context tokens",description:`avg ${Jo(t.contextTokens.avg)} · max ${Jo(t.contextTokens.max)}`,icon:RG,action:E.jsx(zr,{label:Jo(t.contextTokens.latest)})}),u>0&&E.jsx(qt,{title:"Permission denials",description:"Tool requests denied",icon:ZG,action:E.jsx(zr,{value:u})}),c>0&&E.jsx(qt,{title:"Discarded conversations",description:`${t.discardRate.discarded} of ${c}`,icon:oq,action:E.jsx(zr,{value:t.discardRate.discarded})})]})}),E.jsx(qC,{items:h,fullwidth:!0,ContainerProps:{fullwidth:!0}})};L6.displayName="SessionStats";const vg=({children:e})=>E.jsx(Ye,{"data-slot":"section-stack",ax:"stretch",pt:4,fullwidth:!0,gap:2,children:e});vg.displayName="SectionStack";const zr=e=>E.jsx(je,{"data-slot":"stat",size:3,family:"mono",weight:"bold",children:"label"in e?e.label:e.value});zr.displayName="Stat";const F6=({added:e,removed:t})=>E.jsxs(je,{"data-slot":"diff-stat",size:3,family:"mono",weight:"bold",children:[E.jsx(je,{color:"green",family:"mono",weight:"bold",children:`+${e}`})," / ",E.jsx(je,{color:"red",family:"mono",weight:"bold",children:`-${t}`})]});F6.displayName="DiffStat";const EE=({session:e,categoryPath:t,size:n="small",variant:r="subtle",shape:i="square",...o})=>{const[a,u]=C.useState(!1);if(e.status!=="paused")return null;const c=`${t}/${e.slug}`;return E.jsx(Qd,{tooltip:a?"Copied!":"Copy session path",size:n,variant:r,shape:i,pressed:a,onPressedChange:f=>{f&&(navigator.clipboard.writeText(c),u(!0),setTimeout(()=>u(!1),2e3))},icon:{unpressed:E.jsx(Eh,{}),pressed:E.jsx(Ch,{color:"green"})},onClick:f=>{f.preventDefault(),f.stopPropagation()},...o})};EE.displayName="CopyResumeButton";const z6=({session:e,...t})=>{const{categoryPath:n,session:r}=e,i=oE(r.status);return E.jsxs(Xe,{"data-slot":"session-item",ay:"center",gap:2,ml:2,...t,children:[E.jsxs(Xe,{gap:2,ay:"center",children:[E.jsx(My,{"data-slot":"session-status",color:i}),E.jsx(Ye,{gap:2,children:E.jsxs(je,{"data-slot":"session-link",render:E.jsx(ef,{to:"/$",params:{_splat:`${n}/${r.slug}`}}),weight:"bold",children:[n," / ",r.slug]})}),E.jsx(je,{"data-slot":"session-time",size:-1,shade:"muted",children:Bw(r.startedAt)})]}),E.jsx(cn,{"data-slot":"session-badge",color:i,ml:"auto",children:r.status}),E.jsx(EE,{session:r,categoryPath:n})]})};z6.displayName="SessionItem";const B6=wy("/$")({component:Uye}),U6=({href:e,children:t})=>E.jsx(ef,{to:e,children:t});function H6(e,t,n){const r=t.split("/").filter(Boolean),i=[{label:e,value:"/"}];for(let o=0;o<r.length;o++)i.push({label:r[o],value:`/${r.slice(0,o+1).join("/")}`});return n!==void 0&&i.push({label:n,value:""}),i}function bO(e,t){const n=e.lastIndexOf("/");if(n<=0)return null;const r=e.slice(0,n),i=e.slice(n+1);return i?t.find(o=>o.categoryPath===r&&o.session.slug===i)??null:null}function Uye(){const{_splat:e=""}=B6.useParams(),{data:t=[]}=Si(dh()),{data:n=[]}=Si(dh({includeArchived:!0})),r=bO(e,t)??bO(e,n);return r?E.jsx(V6,{match:r}):E.jsx(q6,{categoryPath:e,sessions:t})}function G6(){var t;const{data:e=[]}=Si(mF);return((t=e.find(n=>n.active))==null?void 0:t.name)??"bertrand"}function q6({categoryPath:e,sessions:t}){const n=G6(),r=t.filter(o=>o.categoryPath===e),i=H6(n,e);return E.jsxs(Ye,{gap:4,ax:"stretch",fullwidth:!0,children:[E.jsx(Ye,{bb:1,p:4,style:{position:"sticky",top:0,backgroundColor:"var(--shade-background)",zIndex:1},children:E.jsx(JC,{items:i,linkAs:U6})}),E.jsx(Ye,{px:8,gap:2,style:{overflow:"auto"},children:r.length>0?r.map(o=>E.jsx(z6,{session:o},o.session.id)):E.jsx(je,{shade:"muted",children:"No sessions in this category."})})]})}q6.displayName="CategoryDetail";function V6({match:e}){const t=G6(),n=e.session.id,r=e.session.status==="active"||e.session.status==="waiting",{data:i=[]}=Si(ece(n,r)),o=C.useMemo(()=>vye(i),[i]),a=C.useMemo(()=>{for(let f=i.length-1;f>=0;f--)if(i[f].event==="context.snapshot")return i[f];return null},[i]),u=C.useMemo(()=>{var f;if(e.session.status!=="waiting")return null;for(let h=i.length-1;h>=0;h--)if(i[h].event==="session.waiting"){const p=(f=i[h].meta)==null?void 0:f.question;return typeof p=="string"?p:null}return null},[i,e.session.status]),c=H6(t,e.categoryPath,e.session.name);return E.jsxs(Ye,{ax:"stretch",fullwidth:!0,style:{overflow:"hidden"},children:[E.jsxs(Xe,{bb:1,px:4,py:2,ay:"center",ax:"space-between",fullwidth:!0,children:[E.jsx(JC,{items:c,linkAs:U6}),E.jsxs(Xe,{ay:"center",gap:2,children:[E.jsx(EE,{session:e.session,categoryPath:e.categoryPath}),E.jsx(Y6,{session:e.session}),E.jsx(X$,{side:"right",title:"Session stats",trigger:E.jsx(Ci,{tooltip:"Session stats",variant:"subtle",size:"small",shape:"square",children:E.jsx(WG,{})}),children:E.jsx(j6,{sessionId:n,isLive:r})})]})]}),E.jsx(Ye,{p:8,ax:"stretch",fullwidth:!0,style:{overflowY:"auto"},children:o.length>0&&E.jsx(FP,{activeIndex:o.length,items:o.map(f=>({title:yce(f),time:bce(f.createdAt),color:hce(f.event),content:E.jsx(I6,{event:f})})),ItemProps:{style:{width:"100%"}},ContentProps:{fullwidth:!0,maxw:860}})}),E.jsx(W6,{session:e.session,context:a,pendingQuestion:u})]})}V6.displayName="SessionDetail";function Y6({session:e}){const t=gF(e),{Icon:n}=t;return E.jsx(Ci,{tooltip:t.tooltip,variant:"subtle",size:"small",shape:"square",disabled:t.disabled,loading:t.loading,onClick:t.onClick,"aria-label":t.label,children:E.jsx(n,{})})}Y6.displayName="ArchiveToggle";function W6({session:e,context:t,pendingQuestion:n}){const r=oE(e.status),i=e.status==="active"||e.status==="waiting";return E.jsxs(Ye,{bt:1,p:4,gap:3,fullwidth:!0,children:[E.jsxs(Xe,{ay:"center",gap:2,fullwidth:!0,children:[E.jsx(My,{color:r,pulse:i}),E.jsx(cn,{color:r,children:e.status}),n&&E.jsx(je,{size:1,shade:"muted",children:n})]}),t&&E.jsx(K6,{event:t})]})}W6.displayName="SessionFooter";function K6({event:e}){const t=e.meta;if(!t)return null;const n=to(t.remaining_pct),r=to(t.context_window_tokens),i=to(t.input_tokens),o=to(t.cache_read_tokens),a=to(t.cache_creation_tokens),u=ab(t.model);return r===0?null:E.jsxs(E.Fragment,{children:[E.jsx(XS,{value:n,size:"small",color:yF(n)}),E.jsxs(Xe,{gap:2,children:[u&&E.jsx(cn,{size:"small",children:u}),i>0&&E.jsx(cn,{size:"small",color:"orange",children:`${Jo(i)} input`}),o>0&&E.jsx(cn,{size:"small",color:"blue",children:`${Jo(o)} cache read`}),a>0&&E.jsx(cn,{size:"small",color:"indigo",children:`${Jo(a)} cache write`})]})]})}K6.displayName="ContextStats";const Hye=wy("/")({component:()=>E.jsx("div",{style:{opacity:.5,fontSize:13},children:"Select a session"})}),Gye=`# Heading 1 — anchored
|
|
531
|
+
`),lineKinds:r,lineNums:a,decorations:i,maxLineNum:f}}function ox(e,t){e.properties||(e.properties={});const n=e.properties.class;typeof n=="string"?e.properties.class=n?`${n} ${t}`:t:Array.isArray(n)?e.properties.class=[...n,t]:e.properties.class=t}function sx(e,t){return{type:"element",tagName:"span",properties:{class:e},children:[{type:"text",value:t}]}}const Iye={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",json:"json",md:"markdown",markdown:"markdown",css:"css",html:"html",htm:"html",py:"python",sh:"bash",bash:"bash",zsh:"bash"};function jye(e,t){if(!e)return t;const n=e.split("/").pop()??e,r=n.includes(".")?n.split(".").pop().toLowerCase():"";return Iye[r]??t}function CE({edits:e,oldStr:t,newStr:n,language:r,filename:i,wordDiff:o=!1,rows:a,defaultExpanded:u}){var v;const c=e&&e.length>0?e:[{oldStr:t??"",newStr:n??""}],f=r??jye(i,"tsx"),[h,p]=C.useState(""),[g,y]=C.useState(1);C.useEffect(()=>{let S=!1;return(async()=>{const{code:x,lineKinds:_,lineNums:R,decorations:T,maxLineNum:A}=Nye(c,o);await eI(f);const O=(await pC()).codeToHtml(x,{lang:f,themes:{light:"vitesse-light",dark:"vitesse-black"},defaultColor:!1,decorations:T,transformers:[{name:"diff-block:line-marks",pre($){ox($,"has-diff")},line($,z){const j=z-1,I=_[j],M=R[j];if(I==="add"||I==="remove")ox($,`diff ${I}`);else if(I==="separator")return ox($,"diff-separator"),$;const B=I==="add"?"diff-marker add":I==="remove"?"diff-marker remove":"diff-marker",G=I==="add"?"+":I==="remove"?"-":" ",L="diff-num diff-num-old"+(M.old==null?" diff-num-blank":""),F="diff-num diff-num-new"+(M.new==null?" diff-num-blank":""),U=[sx(L,M.old!=null?String(M.old):" "),sx(F,M.new!=null?String(M.new):" "),sx(B,G)];return $.children.unshift(...U),$}}]});S||(p(O),y(String(A).length))})(),()=>{S=!0}},[c,f,o]);const b=((v=c[c.length-1])==null?void 0:v.newStr)??"";return E.jsx("div",{className:"bertrand-diff-block",style:{"--diff-num-width":`${g+2}ch`,width:"100%"},children:E.jsx(mC,{code:b,language:f,filename:i,showLineNumbers:!1,rows:a,defaultExpanded:u,HeaderProps:{copyable:!1},html:h,style:{width:"100%"}})})}CE.displayName="DiffBlock";const Lye=5;function Qw(e){return!!(e.oldStr||e.newStr||e.edits&&e.edits.length>0)}function $6({permission:e}){const t=e.edits&&e.edits.length>0?e.edits.map(n=>({oldStr:n.oldStr??"",newStr:n.newStr??""})):[{oldStr:e.oldStr??"",newStr:e.newStr??""}];return E.jsx(CE,{edits:t,filename:e.detail,rows:Lye,defaultExpanded:!1})}function Fye(e){const t=e.count>1?`${e.count}× `:"";return e.detail?`${t}${e.detail}`:`${t}${e.tool}`}function P6({permission:e}){return E.jsx(je,{size:-1,family:"mono",shade:"muted",children:Fye(e)})}function N6({event:e}){const t=e.meta;if(!(t!=null&&t.permissions))return null;const n=t.permissions;if(n.length===0)return null;if(n.length===1){const r=n[0];return r.detail?Qw(r)?E.jsx($6,{permission:r}):E.jsx(P6,{permission:r}):null}return E.jsx(zye,{permissions:n})}function zye({permissions:e}){const t=e.filter(Qw),n=e.filter(r=>!Qw(r));return E.jsxs(Ye,{"data-slot":"work-content",gap:2,fullwidth:!0,children:[t.length>0&&E.jsx(Ye,{gap:2,fullwidth:!0,children:t.map((r,i)=>E.jsx($6,{permission:r},`diff-${i}`))}),n.length>0&&E.jsx(Ye,{gap:1,fullwidth:!0,children:n.map((r,i)=>E.jsx(P6,{permission:r},`info-${i}`))})]})}N6.displayName="WorkContent";function I6({event:e}){if(e.event==="claude.started")return E.jsx(M6,{event:e});switch(uce(e.event)){case"interaction":return E.jsx(_6,{event:e});case"work":return E.jsx(N6,{event:e});case"milestone":return E.jsx(D6,{event:e});case"assistant":return E.jsx(k6,{event:e});case"context":return E.jsx(R6,{event:e});case"lifecycle":return E.jsx(A6,{event:e});default:return null}}I6.displayName="EventContent";const j6=({sessionId:e,isLive:t,...n})=>{const{data:r}=Si({...tce(e,t),enabled:!!e}),{data:i}=Si({...rce(e,t),enabled:!!e});return E.jsx(wE,{"data-slot":"secondary-sidebar",...n,p:0,minw:540,children:r&&E.jsx(L6,{stats:r,engagement:i})})};j6.displayName="SecondarySidebar";function Bye(e){return Object.entries(e).sort(([,t],[,n])=>n-t).slice(0,3).map(([t,n])=>`${t} ${n}`).join(" · ")}const L6=({stats:e,engagement:t})=>{const n=e.linesAdded>0||e.linesRemoved>0,r=e.filesTouched>0,i=n||r||e.prCount>0,o=t?Object.values(t.toolUsage).reduce((p,g)=>p+g,0):0,a=((t==null?void 0:t.contextTokens.max)??0)>0,u=(t==null?void 0:t.permissionDenials)??0,c=(t==null?void 0:t.discardRate.total)??0,f=!!t&&(o>0||a||u>0||c>0),h=[{label:"Activity",value:"activity",render:E.jsxs(vg,{children:[E.jsx(qt,{title:"Conversations",description:"Distinct conversation threads",icon:LG,action:E.jsx(zr,{value:e.conversationCount})}),E.jsx(qt,{title:"Interactions",description:"User-Claude exchanges",icon:PG,action:E.jsx(zr,{value:e.interactionCount})}),E.jsx(qt,{title:"Events",description:"Total events emitted",icon:ZH,action:E.jsx(zr,{value:e.eventCount})}),E.jsx(qt,{title:"Duration",description:"Total session time",icon:Q3,action:E.jsx(zr,{label:z1(e.durationS)})}),E.jsx(qt,{title:"Claude work",description:"Time Claude spent active",icon:fG,action:E.jsx(zr,{label:z1(e.claudeWorkS)})}),E.jsx(qt,{title:"User wait",description:"Time user spent waiting",icon:IG,action:E.jsx(zr,{label:z1(e.userWaitS)})})]})}];return i&&h.push({label:"Code",value:"code",render:E.jsxs(vg,{children:[n&&E.jsx(qt,{title:"Lines changed",description:"Across all edits",icon:J3,action:E.jsx(F6,{added:e.linesAdded,removed:e.linesRemoved})}),r&&E.jsx(qt,{title:"Files touched",description:"Distinct files edited",icon:e4,action:E.jsx(zr,{value:e.filesTouched})}),e.prCount>0&&E.jsx(qt,{title:"PRs",description:"Pull requests created",icon:TG,action:E.jsx(zr,{value:e.prCount})})]})}),f&&h.push({label:"Engagement",value:"engagement",render:E.jsxs(vg,{children:[o>0&&E.jsx(qt,{title:"Tracked tool calls",description:Bye(t.toolUsage),icon:uq,action:E.jsx(zr,{value:o})}),a&&E.jsx(qt,{title:"Context tokens",description:`avg ${Jo(t.contextTokens.avg)} · max ${Jo(t.contextTokens.max)}`,icon:RG,action:E.jsx(zr,{label:Jo(t.contextTokens.latest)})}),u>0&&E.jsx(qt,{title:"Permission denials",description:"Tool requests denied",icon:ZG,action:E.jsx(zr,{value:u})}),c>0&&E.jsx(qt,{title:"Discarded conversations",description:`${t.discardRate.discarded} of ${c}`,icon:oq,action:E.jsx(zr,{value:t.discardRate.discarded})})]})}),E.jsx(qC,{items:h,fullwidth:!0,ContainerProps:{fullwidth:!0}})};L6.displayName="SessionStats";const vg=({children:e})=>E.jsx(Ye,{"data-slot":"section-stack",ax:"stretch",pt:4,fullwidth:!0,gap:2,children:e});vg.displayName="SectionStack";const zr=e=>E.jsx(je,{"data-slot":"stat",size:3,family:"mono",weight:"bold",children:"label"in e?e.label:e.value});zr.displayName="Stat";const F6=({added:e,removed:t})=>E.jsxs(je,{"data-slot":"diff-stat",size:3,family:"mono",weight:"bold",children:[E.jsx(je,{color:"green",family:"mono",weight:"bold",children:`+${e}`})," / ",E.jsx(je,{color:"red",family:"mono",weight:"bold",children:`-${t}`})]});F6.displayName="DiffStat";const EE=({session:e,categoryPath:t,size:n="small",variant:r="subtle",shape:i="square",...o})=>{const[a,u]=C.useState(!1);if(e.status!=="paused")return null;const c=`${t}/${e.slug}`;return E.jsx(Qd,{tooltip:a?"Copied!":"Copy session path",size:n,variant:r,shape:i,pressed:a,onPressedChange:f=>{f&&(navigator.clipboard.writeText(c),u(!0),setTimeout(()=>u(!1),2e3))},icon:{unpressed:E.jsx(Eh,{}),pressed:E.jsx(Ch,{color:"green"})},onClick:f=>{f.preventDefault(),f.stopPropagation()},...o})};EE.displayName="CopyResumeButton";const z6=({session:e,...t})=>{const{categoryPath:n,session:r}=e,i=oE(r.status);return E.jsxs(Xe,{"data-slot":"session-item",ay:"center",gap:2,ml:2,...t,children:[E.jsxs(Xe,{gap:2,ay:"center",children:[E.jsx(My,{"data-slot":"session-status",color:i}),E.jsx(Ye,{gap:2,children:E.jsxs(je,{"data-slot":"session-link",render:E.jsx(ef,{to:"/$",params:{_splat:`${n}/${r.slug}`}}),weight:"bold",children:[n," / ",r.slug]})}),E.jsx(je,{"data-slot":"session-time",size:-1,shade:"muted",children:Bw(r.startedAt)})]}),E.jsx(cn,{"data-slot":"session-badge",color:i,ml:"auto",children:r.status}),E.jsx(EE,{session:r,categoryPath:n})]})};z6.displayName="SessionItem";const B6=wy("/$")({component:Uye}),U6=({href:e,children:t})=>E.jsx(ef,{to:e,children:t});function H6(e,t,n){const r=t.split("/").filter(Boolean),i=[{label:e,value:"/"}];for(let o=0;o<r.length;o++)i.push({label:r[o],value:`/${r.slice(0,o+1).join("/")}`});return n!==void 0&&i.push({label:n,value:""}),i}function Uye(){const{_splat:e=""}=B6.useParams(),{data:t=[]}=Si(dh()),{data:n=[]}=Si(dh({includeArchived:!0})),r=gO(e,t)??gO(e,n);return r?E.jsx(V6,{match:r}):E.jsx(q6,{categoryPath:e,sessions:t})}function G6(){var t;const{data:e=[]}=Si(mF);return((t=e.find(n=>n.active))==null?void 0:t.name)??"bertrand"}function q6({categoryPath:e,sessions:t}){const n=G6(),r=t.filter(o=>o.categoryPath===e),i=H6(n,e);return E.jsxs(Ye,{gap:4,ax:"stretch",fullwidth:!0,children:[E.jsx(Ye,{bb:1,p:4,style:{position:"sticky",top:0,backgroundColor:"var(--shade-background)",zIndex:1},children:E.jsx(JC,{items:i,linkAs:U6})}),E.jsx(Ye,{px:8,gap:2,style:{overflow:"auto"},children:r.length>0?r.map(o=>E.jsx(z6,{session:o},o.session.id)):E.jsx(je,{shade:"muted",children:"No sessions in this category."})})]})}q6.displayName="CategoryDetail";function V6({match:e}){const t=G6(),n=e.session.id,r=e.session.status==="active"||e.session.status==="waiting",{data:i=[]}=Si(ece(n,r)),o=C.useMemo(()=>vye(i),[i]),a=C.useMemo(()=>{for(let f=i.length-1;f>=0;f--)if(i[f].event==="context.snapshot")return i[f];return null},[i]),u=C.useMemo(()=>{var f;if(e.session.status!=="waiting")return null;for(let h=i.length-1;h>=0;h--)if(i[h].event==="session.waiting"){const p=(f=i[h].meta)==null?void 0:f.question;return typeof p=="string"?p:null}return null},[i,e.session.status]),c=H6(t,e.categoryPath,e.session.name);return E.jsxs(Ye,{ax:"stretch",fullwidth:!0,style:{overflow:"hidden"},children:[E.jsxs(Xe,{bb:1,px:4,py:2,ay:"center",ax:"space-between",fullwidth:!0,children:[E.jsx(JC,{items:c,linkAs:U6}),E.jsxs(Xe,{ay:"center",gap:2,children:[E.jsx(EE,{session:e.session,categoryPath:e.categoryPath}),E.jsx(Y6,{session:e.session}),E.jsx(X$,{side:"right",title:"Session stats",trigger:E.jsx(Ci,{tooltip:"Session stats",variant:"subtle",size:"small",shape:"square",children:E.jsx(WG,{})}),children:E.jsx(j6,{sessionId:n,isLive:r})})]})]}),E.jsx(Ye,{p:8,ax:"stretch",fullwidth:!0,style:{overflowY:"auto"},children:o.length>0&&E.jsx(FP,{activeIndex:o.length,items:o.map(f=>({title:yce(f),time:bce(f.createdAt),color:hce(f.event),content:E.jsx(I6,{event:f})})),ItemProps:{style:{width:"100%"}},ContentProps:{fullwidth:!0,maxw:860}})}),E.jsx(W6,{session:e.session,context:a,pendingQuestion:u})]})}V6.displayName="SessionDetail";function Y6({session:e}){const t=gF(e),{Icon:n}=t;return E.jsx(Ci,{tooltip:t.tooltip,variant:"subtle",size:"small",shape:"square",disabled:t.disabled,loading:t.loading,onClick:t.onClick,"aria-label":t.label,children:E.jsx(n,{})})}Y6.displayName="ArchiveToggle";function W6({session:e,context:t,pendingQuestion:n}){const r=oE(e.status),i=e.status==="active"||e.status==="waiting";return E.jsxs(Ye,{bt:1,p:4,gap:3,fullwidth:!0,children:[E.jsxs(Xe,{ay:"center",gap:2,fullwidth:!0,children:[E.jsx(My,{color:r,pulse:i}),E.jsx(cn,{color:r,children:e.status}),n&&E.jsx(je,{size:1,shade:"muted",children:n})]}),t&&E.jsx(K6,{event:t})]})}W6.displayName="SessionFooter";function K6({event:e}){const t=e.meta;if(!t)return null;const n=to(t.remaining_pct),r=to(t.context_window_tokens),i=to(t.input_tokens),o=to(t.cache_read_tokens),a=to(t.cache_creation_tokens),u=ab(t.model);return r===0?null:E.jsxs(E.Fragment,{children:[E.jsx(XS,{value:n,size:"small",color:yF(n)}),E.jsxs(Xe,{gap:2,children:[u&&E.jsx(cn,{size:"small",children:u}),i>0&&E.jsx(cn,{size:"small",color:"orange",children:`${Jo(i)} input`}),o>0&&E.jsx(cn,{size:"small",color:"blue",children:`${Jo(o)} cache read`}),a>0&&E.jsx(cn,{size:"small",color:"indigo",children:`${Jo(a)} cache write`})]})]})}K6.displayName="ContextStats";const Hye=wy("/")({component:()=>E.jsx("div",{style:{opacity:.5,fontSize:13},children:"Select a session"})}),Gye=`# Heading 1 — anchored
|
|
532
532
|
|
|
533
533
|
## Heading 2 — anchored
|
|
534
534
|
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
} catch (e) {}
|
|
20
20
|
})();
|
|
21
21
|
</script>
|
|
22
|
-
<script type="module" crossorigin src="/assets/index-
|
|
22
|
+
<script type="module" crossorigin src="/assets/index-SB5vH7Ec.js"></script>
|
|
23
23
|
<link rel="stylesheet" crossorigin href="/assets/index-D_l3EPhC.css">
|
|
24
24
|
</head>
|
|
25
25
|
<body>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `sessions` ADD `rating` integer;
|