@clawos-dev/clawd 0.2.678 → 0.2.680
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/cli.cjs
CHANGED
|
@@ -48360,7 +48360,7 @@ function pushEventToBufferInPlace(next, event, deps) {
|
|
|
48360
48360
|
}
|
|
48361
48361
|
next.turnOpen = false;
|
|
48362
48362
|
next.turnStartedAt = null;
|
|
48363
|
-
} else if (!isBackgroundEvent && !
|
|
48363
|
+
} else if (!isBackgroundEvent && !isSessionInit && !next.turnOpen) {
|
|
48364
48364
|
next.turnOpen = true;
|
|
48365
48365
|
next.turnStartedAt = deps.now();
|
|
48366
48366
|
next.turnSelfWoke = next.status === "running-idle";
|
|
@@ -49199,6 +49199,9 @@ var SessionRunner = class {
|
|
|
49199
49199
|
return this.state;
|
|
49200
49200
|
}
|
|
49201
49201
|
input(inputMsg) {
|
|
49202
|
+
if (inputMsg.kind === "proc-exit") {
|
|
49203
|
+
this.hooks.logger?.info("session.process.exited", { ...this.lifecycleMetadata(), exitCode: inputMsg.code });
|
|
49204
|
+
}
|
|
49202
49205
|
const adapter = this.hooks.adapter;
|
|
49203
49206
|
const deps = {
|
|
49204
49207
|
parseLine: (l2) => {
|
|
@@ -49226,7 +49229,7 @@ var SessionRunner = class {
|
|
|
49226
49229
|
};
|
|
49227
49230
|
const { state, effects } = reduceSession(this.state, inputMsg, deps);
|
|
49228
49231
|
this.state = state;
|
|
49229
|
-
for (const e of effects) this.applyEffect(e);
|
|
49232
|
+
for (const e of effects) this.applyEffect(e, inputMsg);
|
|
49230
49233
|
if (!this.state.procAlive && this.stopWaiters.length > 0) {
|
|
49231
49234
|
const waiters = this.stopWaiters;
|
|
49232
49235
|
this.stopWaiters = [];
|
|
@@ -49290,6 +49293,10 @@ var SessionRunner = class {
|
|
|
49290
49293
|
// session:interrupt 的 SDK 通道分流:codex → AgentSession.interrupt();claude → control_request('interrupt')。
|
|
49291
49294
|
// TUI(pty) 路径在 manager.interrupt() 里先走 stop() SIGKILL,不进这里。
|
|
49292
49295
|
async interrupt() {
|
|
49296
|
+
this.hooks.logger?.info("session.interrupt.requested", {
|
|
49297
|
+
...this.lifecycleMetadata(),
|
|
49298
|
+
mechanism: this.session ? "agent-session" : "control-request"
|
|
49299
|
+
});
|
|
49293
49300
|
if (this.session) {
|
|
49294
49301
|
this.session.interrupt();
|
|
49295
49302
|
return;
|
|
@@ -49412,12 +49419,42 @@ var SessionRunner = class {
|
|
|
49412
49419
|
}
|
|
49413
49420
|
this.pendingControlRequests.clear();
|
|
49414
49421
|
}
|
|
49415
|
-
|
|
49422
|
+
lifecycleMetadata() {
|
|
49423
|
+
const state = this.state;
|
|
49424
|
+
let turnId;
|
|
49425
|
+
for (let index = state.buffer.length - 1; index >= 0; index--) {
|
|
49426
|
+
const event = state.buffer[index].event;
|
|
49427
|
+
if (event.turnId) {
|
|
49428
|
+
turnId = event.turnId;
|
|
49429
|
+
break;
|
|
49430
|
+
}
|
|
49431
|
+
if (event.kind === "user_text") break;
|
|
49432
|
+
}
|
|
49433
|
+
return {
|
|
49434
|
+
sessionId: state.file.sessionId,
|
|
49435
|
+
tool: state.file.tool,
|
|
49436
|
+
toolSessionId: state.file.toolSessionId,
|
|
49437
|
+
turnId,
|
|
49438
|
+
status: state.status,
|
|
49439
|
+
turnOpen: state.turnOpen,
|
|
49440
|
+
procAlive: state.procAlive
|
|
49441
|
+
};
|
|
49442
|
+
}
|
|
49443
|
+
applyEffect(effect, input) {
|
|
49416
49444
|
switch (effect.kind) {
|
|
49417
49445
|
case "spawn":
|
|
49418
49446
|
this.doSpawn(effect.ctx);
|
|
49419
49447
|
break;
|
|
49420
49448
|
case "kill":
|
|
49449
|
+
this.hooks.logger?.warn("session.process.kill", {
|
|
49450
|
+
...this.lifecycleMetadata(),
|
|
49451
|
+
signal: effect.signal,
|
|
49452
|
+
inputKind: input.kind,
|
|
49453
|
+
...input.kind === "command" ? {
|
|
49454
|
+
commandKind: input.command.kind,
|
|
49455
|
+
...input.command.kind === "update" ? { patchKeys: Object.keys(input.command.patch) } : {}
|
|
49456
|
+
} : {}
|
|
49457
|
+
});
|
|
49421
49458
|
if (this.session) {
|
|
49422
49459
|
void this.session.stop(effect.signal);
|
|
49423
49460
|
break;
|
|
@@ -49483,9 +49520,20 @@ var SessionRunner = class {
|
|
|
49483
49520
|
this.hooks.logger?.warn("delete-file failed", { err: err.message });
|
|
49484
49521
|
}
|
|
49485
49522
|
break;
|
|
49486
|
-
case "emit-frame":
|
|
49523
|
+
case "emit-frame": {
|
|
49524
|
+
const event = effect.frame.type === "session:event" ? effect.frame.event : void 0;
|
|
49525
|
+
if (event?.kind === "turn_end" && event.reason === "interrupted") {
|
|
49526
|
+
this.hooks.logger?.warn("session.turn.interrupted", {
|
|
49527
|
+
...this.lifecycleMetadata(),
|
|
49528
|
+
inputKind: input.kind,
|
|
49529
|
+
...event.turnId ? { turnId: event.turnId } : {},
|
|
49530
|
+
durationMs: event.durationMs,
|
|
49531
|
+
...input.kind === "command" ? { commandKind: input.command.kind } : {}
|
|
49532
|
+
});
|
|
49533
|
+
}
|
|
49487
49534
|
this.hooks.broadcastFrame(effect.frame, effect.target ?? "broadcast");
|
|
49488
49535
|
break;
|
|
49536
|
+
}
|
|
49489
49537
|
case "schedule-tick": {
|
|
49490
49538
|
const now = this.hooks.now ?? Date.now;
|
|
49491
49539
|
setTimeout(() => this.input({ kind: "tick", nowMs: now() }), effect.delayMs).unref();
|
|
@@ -54551,7 +54599,10 @@ function driveCodexThread(opts) {
|
|
|
54551
54599
|
});
|
|
54552
54600
|
if (threadId !== void 0 && ownerThreadId === threadId && method === "turn/started") {
|
|
54553
54601
|
const id = params?.turn?.id;
|
|
54554
|
-
if (id)
|
|
54602
|
+
if (id) {
|
|
54603
|
+
turnId = id;
|
|
54604
|
+
sink.pushEvents([{ kind: "session_init", toolSessionId: threadId, turnId }]);
|
|
54605
|
+
}
|
|
54555
54606
|
activeTrace?.("native.turn.started", { threadId, turnId });
|
|
54556
54607
|
}
|
|
54557
54608
|
const events = route === "subagent" && ownerThreadId ? subagents.handleChildNotification(ownerThreadId, method, params) : route === "foreground" ? [
|
|
@@ -57159,7 +57210,8 @@ function writeRpcToolMcpConfig(args) {
|
|
|
57159
57210
|
}
|
|
57160
57211
|
};
|
|
57161
57212
|
import_node_fs33.default.mkdirSync(args.dataDir, { recursive: true });
|
|
57162
|
-
import_node_fs33.default.writeFileSync(cfgPath, JSON.stringify(content, null, 2), "utf8");
|
|
57213
|
+
import_node_fs33.default.writeFileSync(cfgPath, JSON.stringify(content, null, 2), { encoding: "utf8", mode: 384 });
|
|
57214
|
+
import_node_fs33.default.chmodSync(cfgPath, 384);
|
|
57163
57215
|
return cfgPath;
|
|
57164
57216
|
}
|
|
57165
57217
|
|
|
@@ -72775,6 +72827,17 @@ function canReadSearchHit(ctx, file) {
|
|
|
72775
72827
|
var DEFAULT_SEARCH_LIMIT = 9;
|
|
72776
72828
|
function buildSessionHandlers(deps) {
|
|
72777
72829
|
const { manager, observer, getAdapter: getAdapter2, store, ownerPrincipalId } = deps;
|
|
72830
|
+
const logControlRequest = (method, sessionId, client, ctx, patchKeys) => {
|
|
72831
|
+
deps.logger?.info("session.control.requested", {
|
|
72832
|
+
sessionId,
|
|
72833
|
+
method,
|
|
72834
|
+
clientId: client.id,
|
|
72835
|
+
transport: client.transport,
|
|
72836
|
+
principalKind: ctx?.principal?.kind,
|
|
72837
|
+
principalId: ctx?.principal?.id,
|
|
72838
|
+
...patchKeys ? { patchKeys } : {}
|
|
72839
|
+
});
|
|
72840
|
+
};
|
|
72778
72841
|
const ensureSessionAccess = (ctx, sessionId, action) => {
|
|
72779
72842
|
if (!ctx) return;
|
|
72780
72843
|
const ok = canAccessSession(ctx, sessionId, action, {
|
|
@@ -72937,12 +73000,14 @@ function buildSessionHandlers(deps) {
|
|
|
72937
73000
|
`${MASTER_PERSONA_ID} \u7684\u5FEB\u901F\u95EE\u7B54\u4F1A\u8BDD\u4E0D\u80FD\u8F6C\u6B63\uFF1A\u8F6C\u6B63\u540E\u5C31\u662F\u4E00\u6761\u6CA1\u6709\u8BDD\u9898\u5F52\u5C5E\u3001\u4E5F\u56DE\u6536\u4E0D\u6389\u7684\u4F1A\u8BDD`
|
|
72938
73001
|
);
|
|
72939
73002
|
}
|
|
73003
|
+
logControlRequest("session:update", args.sessionId, _client, ctx, Object.keys(args.patch));
|
|
72940
73004
|
const { response, broadcast } = manager.update(args);
|
|
72941
73005
|
return { response: { type: "session:info", ...response }, broadcast };
|
|
72942
73006
|
};
|
|
72943
73007
|
const del = async (frame, _client, ctx) => {
|
|
72944
73008
|
const args = SessionIdArgs.parse(frame);
|
|
72945
73009
|
ensureSessionAccess(ctx, args.sessionId, "send");
|
|
73010
|
+
logControlRequest("session:delete", args.sessionId, _client, ctx);
|
|
72946
73011
|
const { broadcast } = await manager.deleteWithCloudCancel(args);
|
|
72947
73012
|
return {
|
|
72948
73013
|
response: { type: "session:deleted", sessionId: args.sessionId },
|
|
@@ -72984,12 +73049,14 @@ ${attribution}` } : args;
|
|
|
72984
73049
|
const stop = async (frame, _client, ctx) => {
|
|
72985
73050
|
const args = SessionIdArgs.parse(frame);
|
|
72986
73051
|
ensureSessionAccess(ctx, args.sessionId, "send");
|
|
73052
|
+
logControlRequest("session:stop", args.sessionId, _client, ctx);
|
|
72987
73053
|
const { broadcast } = await manager.stop(args);
|
|
72988
73054
|
return { response: { type: "session:stop", ok: true }, broadcast };
|
|
72989
73055
|
};
|
|
72990
73056
|
const interrupt = async (frame, _client, ctx) => {
|
|
72991
73057
|
const args = SessionIdArgs.parse(frame);
|
|
72992
73058
|
ensureSessionAccess(ctx, args.sessionId, "send");
|
|
73059
|
+
logControlRequest("session:interrupt", args.sessionId, _client, ctx);
|
|
72993
73060
|
const { response, broadcast } = await manager.interrupt(args);
|
|
72994
73061
|
const queued = response.queued ?? [];
|
|
72995
73062
|
return { response: { type: "session:interrupt", ok: true, queued }, broadcast };
|
|
@@ -73086,6 +73153,7 @@ ${attribution}` } : args;
|
|
|
73086
73153
|
const newSession = async (frame, _client, ctx) => {
|
|
73087
73154
|
const args = SessionIdArgs.parse(frame);
|
|
73088
73155
|
ensureSessionAccess(ctx, args.sessionId, "send");
|
|
73156
|
+
logControlRequest("session:new", args.sessionId, _client, ctx);
|
|
73089
73157
|
observer.stop(args.sessionId);
|
|
73090
73158
|
const { response, broadcast } = await manager.newSessionWithCloudCancel(args);
|
|
73091
73159
|
return { response: { type: "session:info", ...response }, broadcast };
|
|
@@ -73093,6 +73161,7 @@ ${attribution}` } : args;
|
|
|
73093
73161
|
const resume = async (frame, _client, ctx) => {
|
|
73094
73162
|
const args = SessionResumeArgs.parse(frame);
|
|
73095
73163
|
ensureSessionAccess(ctx, args.sessionId, "send");
|
|
73164
|
+
logControlRequest("session:resume", args.sessionId, _client, ctx);
|
|
73096
73165
|
const { response, broadcast } = manager.resume(args);
|
|
73097
73166
|
return { response: { type: "session:info", ...response }, broadcast };
|
|
73098
73167
|
};
|
|
@@ -75267,7 +75336,7 @@ function computeMethodAccess(args) {
|
|
|
75267
75336
|
}
|
|
75268
75337
|
|
|
75269
75338
|
// src/version.ts
|
|
75270
|
-
var version = "0.2.
|
|
75339
|
+
var version = "0.2.680".length > 0 ? "0.2.680" : "dev";
|
|
75271
75340
|
|
|
75272
75341
|
// src/cli-probe/probe.ts
|
|
75273
75342
|
var fs86 = __toESM(require("fs"), 1);
|
|
@@ -75350,9 +75419,11 @@ function buildReadyFrame(deps, client) {
|
|
|
75350
75419
|
};
|
|
75351
75420
|
}
|
|
75352
75421
|
function buildMetaHandlers(deps) {
|
|
75353
|
-
const info = async () =>
|
|
75354
|
-
|
|
75355
|
-
|
|
75422
|
+
const info = async (_frame, client) => {
|
|
75423
|
+
const frame = buildReadyFrame(deps);
|
|
75424
|
+
if (client.transport === "http") delete frame.httpToken;
|
|
75425
|
+
return { response: { type: "info", ...frame } };
|
|
75426
|
+
};
|
|
75356
75427
|
const ping = async () => ({
|
|
75357
75428
|
response: { type: "pong", at: Date.now() }
|
|
75358
75429
|
});
|
|
@@ -21125,6 +21125,17 @@ function log(msg, extra) {
|
|
|
21125
21125
|
} catch {
|
|
21126
21126
|
}
|
|
21127
21127
|
}
|
|
21128
|
+
var DEFAULT_TIMEOUT_MS = 6e4;
|
|
21129
|
+
var DEFAULT_MAX_RESULT_CHARS = 6e4;
|
|
21130
|
+
function positiveIntFromEnv(name, fallback) {
|
|
21131
|
+
const n = Number(process.env[name]);
|
|
21132
|
+
return Number.isInteger(n) && n > 0 ? n : fallback;
|
|
21133
|
+
}
|
|
21134
|
+
function truncateResult(text, max) {
|
|
21135
|
+
if (max === void 0 || text.length <= max) return text;
|
|
21136
|
+
return text.slice(0, max) + `
|
|
21137
|
+
\u2026[truncated: ${text.length - max} of ${text.length} chars omitted. Narrow the call: pass \`slim:true\` to history:read, or use limit/offset/cursor where the method supports them.]`;
|
|
21138
|
+
}
|
|
21128
21139
|
async function handleCallToolCall(input, ctx) {
|
|
21129
21140
|
const f = ctx.fetch ?? fetch;
|
|
21130
21141
|
const args = input.args ?? {};
|
|
@@ -21142,9 +21153,23 @@ async function handleCallToolCall(input, ctx) {
|
|
|
21142
21153
|
"content-type": "application/json",
|
|
21143
21154
|
authorization: `Bearer ${ctx.daemonToken}`
|
|
21144
21155
|
},
|
|
21145
|
-
body: JSON.stringify(body)
|
|
21156
|
+
body: JSON.stringify(body),
|
|
21157
|
+
signal: AbortSignal.timeout(ctx.timeoutMs ?? DEFAULT_TIMEOUT_MS)
|
|
21146
21158
|
});
|
|
21147
21159
|
} catch (err) {
|
|
21160
|
+
if (err instanceof Error && err.name === "TimeoutError") {
|
|
21161
|
+
const secs = Math.round((ctx.timeoutMs ?? DEFAULT_TIMEOUT_MS) / 1e3);
|
|
21162
|
+
log("call timed out", { url, secs });
|
|
21163
|
+
return {
|
|
21164
|
+
content: [
|
|
21165
|
+
{
|
|
21166
|
+
type: "text",
|
|
21167
|
+
text: `RPC timed out after ${secs}s waiting for ${input.method}. The daemon may still be running it \u2014 check the result before retrying a method that writes.`
|
|
21168
|
+
}
|
|
21169
|
+
],
|
|
21170
|
+
isError: true
|
|
21171
|
+
};
|
|
21172
|
+
}
|
|
21148
21173
|
const msg = err instanceof Error ? err.message : String(err);
|
|
21149
21174
|
log("call fetch threw", { url, msg });
|
|
21150
21175
|
return {
|
|
@@ -21170,9 +21195,27 @@ async function handleCallToolCall(input, ctx) {
|
|
|
21170
21195
|
};
|
|
21171
21196
|
}
|
|
21172
21197
|
log("call ok", { url });
|
|
21173
|
-
return { content: [{ type: "text", text: JSON.stringify(json.result) }] };
|
|
21198
|
+
return { content: [{ type: "text", text: truncateResult(JSON.stringify(json.result), ctx.maxResultChars) }] };
|
|
21174
21199
|
}
|
|
21175
|
-
|
|
21200
|
+
var SUMMARY_MAX_CHARS = 100;
|
|
21201
|
+
function summarize(description) {
|
|
21202
|
+
const end = description.search(/。|\. |\n/);
|
|
21203
|
+
const first = end === -1 ? description : description.slice(0, end + (description[end] === "." ? 1 : 0));
|
|
21204
|
+
return first.length > SUMMARY_MAX_CHARS ? first.slice(0, SUMMARY_MAX_CHARS) + "\u2026" : first;
|
|
21205
|
+
}
|
|
21206
|
+
async function handleListToolCall(callerCtx, opts = {}) {
|
|
21207
|
+
const ctx = { ...callerCtx, maxResultChars: void 0 };
|
|
21208
|
+
if (opts.method) {
|
|
21209
|
+
const one = await handleCallToolCall({ method: "meta:methods", args: { method: opts.method } }, ctx);
|
|
21210
|
+
if (one.isError) return one;
|
|
21211
|
+
try {
|
|
21212
|
+
const entry = JSON.parse(one.content[0].text).methods[0];
|
|
21213
|
+
if (!entry) throw new Error("empty");
|
|
21214
|
+
return { content: [{ type: "text", text: JSON.stringify(entry, null, 2) }] };
|
|
21215
|
+
} catch {
|
|
21216
|
+
return { content: [{ type: "text", text: "meta:methods returned an unexpected shape" }], isError: true };
|
|
21217
|
+
}
|
|
21218
|
+
}
|
|
21176
21219
|
const raw = await handleCallToolCall({ method: "meta:methods" }, ctx);
|
|
21177
21220
|
if (raw.isError) return raw;
|
|
21178
21221
|
let methods;
|
|
@@ -21181,6 +21224,13 @@ async function handleListToolCall(ctx) {
|
|
|
21181
21224
|
} catch {
|
|
21182
21225
|
return { content: [{ type: "text", text: "meta:methods returned an unexpected shape" }], isError: true };
|
|
21183
21226
|
}
|
|
21227
|
+
if (opts.prefix) {
|
|
21228
|
+
const prefix = opts.prefix;
|
|
21229
|
+
methods = methods.filter((m) => m.name.startsWith(prefix));
|
|
21230
|
+
if (methods.length === 0) {
|
|
21231
|
+
return { content: [{ type: "text", text: `No methods start with "${prefix}". Call list with no arguments to see all.` }] };
|
|
21232
|
+
}
|
|
21233
|
+
}
|
|
21184
21234
|
return { content: [{ type: "text", text: formatMethodList(methods) }] };
|
|
21185
21235
|
}
|
|
21186
21236
|
function formatMethodList(methods) {
|
|
@@ -21199,7 +21249,7 @@ function formatMethodList(methods) {
|
|
|
21199
21249
|
for (const [reason, group2] of byReason) {
|
|
21200
21250
|
if (reason) lines.push(`(${reason})`);
|
|
21201
21251
|
for (const m of group2) {
|
|
21202
|
-
lines.push(m.description ? `- ${m.name} \u2014 ${m.description}` : `- ${m.name}`);
|
|
21252
|
+
lines.push(m.description ? `- ${m.name} \u2014 ${summarize(m.description)}` : `- ${m.name}`);
|
|
21203
21253
|
if (m.args && m.args.length > 0) {
|
|
21204
21254
|
lines.push(` args: ${m.args.map((a) => a.required ? `${a.name}*` : a.name).join(", ")}`);
|
|
21205
21255
|
} else if (m.args === null) {
|
|
@@ -21211,35 +21261,42 @@ function formatMethodList(methods) {
|
|
|
21211
21261
|
}
|
|
21212
21262
|
lines.push("");
|
|
21213
21263
|
}
|
|
21214
|
-
lines.push(
|
|
21264
|
+
lines.push(
|
|
21265
|
+
"Call any of these with the `call` tool: call({ method, args }). `*` marks required args. Descriptions are shortened here: list({ method }) returns one method in full with its args schema."
|
|
21266
|
+
);
|
|
21215
21267
|
return lines.join("\n");
|
|
21216
21268
|
}
|
|
21217
21269
|
async function main() {
|
|
21218
21270
|
const daemonUrl = process.env.CLAWD_DAEMON_URL;
|
|
21219
21271
|
const daemonToken = process.env.CLAWD_DAEMON_TOKEN;
|
|
21220
21272
|
const sessionId = process.env.CLAWD_SESSION_ID;
|
|
21221
|
-
|
|
21273
|
+
const timeoutMs = positiveIntFromEnv("CLAWD_RPC_TIMEOUT_MS", DEFAULT_TIMEOUT_MS);
|
|
21274
|
+
const maxResultChars = positiveIntFromEnv("CLAWD_RPC_MAX_RESULT_CHARS", DEFAULT_MAX_RESULT_CHARS);
|
|
21275
|
+
log("boot", { pid: process.pid, hasSessionId: Boolean(sessionId), logPath: RPC_LOG ?? "(stderr)", timeoutMs, maxResultChars });
|
|
21222
21276
|
const server = new McpServer({ name: "clawd-rpc", version: "0.1.0" });
|
|
21223
21277
|
server.registerTool(
|
|
21224
21278
|
"call",
|
|
21225
21279
|
{
|
|
21226
21280
|
title: "Call a clawd daemon RPC method",
|
|
21227
|
-
description: 'Call a clawd daemon RPC method over the authenticated local channel. `method` is the canonical method name (e.g. "attachment.signUrl", "persona:list", "session:list"); `args` is the JSON body for that method. sessionId is auto-filled from this session unless explicitly provided in args. The daemon is the sole authority on method existence and authorization \u2014 unknown methods or missing permissions surface as errors from the daemon.',
|
|
21281
|
+
description: 'Call a clawd daemon RPC method over the authenticated local channel. `method` is the canonical method name (e.g. "attachment.signUrl", "persona:list", "session:list"); `args` is the JSON body for that method. sessionId is auto-filled from this session unless explicitly provided in args. The daemon is the sole authority on method existence and authorization \u2014 unknown methods or missing permissions surface as errors from the daemon. Gives up after the timeout, and long results are truncated with a hint to narrow the call.',
|
|
21228
21282
|
inputSchema: {
|
|
21229
21283
|
method: external_exports.string().min(1).describe('canonical RPC method name, e.g. "persona:list"'),
|
|
21230
21284
|
args: external_exports.record(external_exports.unknown()).optional().describe("JSON arguments for the method")
|
|
21231
21285
|
}
|
|
21232
21286
|
},
|
|
21233
|
-
async (input) => handleCallToolCall(input, { daemonUrl, daemonToken, sessionId })
|
|
21287
|
+
async (input) => handleCallToolCall(input, { daemonUrl, daemonToken, sessionId, timeoutMs, maxResultChars })
|
|
21234
21288
|
);
|
|
21235
21289
|
server.registerTool(
|
|
21236
21290
|
"list",
|
|
21237
21291
|
{
|
|
21238
21292
|
title: "List callable clawd daemon RPC methods",
|
|
21239
|
-
description:
|
|
21240
|
-
inputSchema: {
|
|
21293
|
+
description: 'List the RPC methods this daemon exposes, grouped by whether THIS connection can call it, one shortened line per method. The daemon has 100+ methods and `call` does no local validation, so prefer `prefix` (e.g. "session:") to narrow the list, and `method` to get one method in full with its args schema. With no arguments it lists everything.',
|
|
21294
|
+
inputSchema: {
|
|
21295
|
+
prefix: external_exports.string().min(1).optional().describe('only methods whose name starts with this, e.g. "session:"'),
|
|
21296
|
+
method: external_exports.string().min(1).optional().describe("one exact method name: returns its full description and args schema")
|
|
21297
|
+
}
|
|
21241
21298
|
},
|
|
21242
|
-
async () => handleListToolCall({ daemonUrl, daemonToken, sessionId })
|
|
21299
|
+
async (input) => handleListToolCall({ daemonUrl, daemonToken, sessionId, timeoutMs }, input)
|
|
21243
21300
|
);
|
|
21244
21301
|
await server.connect(new StdioServerTransport());
|
|
21245
21302
|
}
|
|
@@ -538,7 +538,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
538
538
|
`)},jk=function(){var e=parseInt(document.body.getAttribute(Ya)||"0",10);return isFinite(e)?e:0},bq=function(){g.useEffect(function(){return document.body.setAttribute(Ya,(jk()+1).toString()),function(){var e=jk()-1;e<=0?document.body.removeAttribute(Ya):document.body.setAttribute(Ya,e.toString())}},[])},wq=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;bq();var s=g.useMemo(function(){return xq(i)},[i]);return g.createElement(yq,{styles:_q(s,!t,i,n?"":"!important")})},xx=!1;if(typeof window<"u")try{var Yd=Object.defineProperty({},"passive",{get:function(){return xx=!0,!0}});window.addEventListener("test",Yd,Yd),window.removeEventListener("test",Yd,Yd)}catch{xx=!1}var pa=xx?{passive:!1}:!1,Sq=function(e){return e.tagName==="TEXTAREA"},p3=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Sq(e)&&n[t]==="visible")},kq=function(e){return p3(e,"overflowY")},Cq=function(e){return p3(e,"overflowX")},Lk=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=m3(e,r);if(i){var s=g3(e,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Eq=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Iq=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},m3=function(e,t){return e==="v"?kq(t):Cq(t)},g3=function(e,t){return e==="v"?Eq(t):Iq(t)},Nq=function(e,t){return e==="h"&&t==="rtl"?-1:1},Tq=function(e,t,n,r,i){var s=Nq(e,window.getComputedStyle(t).direction),o=s*r,a=n.target,l=t.contains(a),c=!1,u=o>0,d=0,f=0;do{if(!a)break;var p=g3(e,a),m=p[0],x=p[1],w=p[2],v=x-w-s*m;(m||v)&&m3(e,a)&&(d+=v,f+=m);var _=a.parentNode;a=_&&_.nodeType===Node.DOCUMENT_FRAGMENT_NODE?_.host:_}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&Math.abs(d)<1||!u&&Math.abs(f)<1)&&(c=!0),c},Xd=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Dk=function(e){return[e.deltaX,e.deltaY]},Ok=function(e){return e&&"current"in e?e.current:e},Pq=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Rq=function(e){return`
|
|
539
539
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
540
540
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
541
|
-
`)},Aq=0,ma=[];function Mq(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(Aq++)[0],s=g.useState(f3)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var x=eq([e.lockRef.current],(e.shards||[]).map(Ok),!0).filter(Boolean);return x.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),x.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(x,w){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!o.current.allowPinchZoom;var v=Xd(x),_=n.current,b="deltaX"in x?x.deltaX:_[0]-v[0],S="deltaY"in x?x.deltaY:_[1]-v[1],C,k=x.target,I=Math.abs(b)>Math.abs(S)?"h":"v";if("touches"in x&&I==="h"&&k.type==="range")return!1;var E=window.getSelection(),A=E&&E.anchorNode,P=A?A===k||A.contains(k):!1;if(P)return!1;var D=Lk(I,k);if(!D)return!0;if(D?C=I:(C=I==="v"?"h":"v",D=Lk(I,k)),!D)return!1;if(!r.current&&"changedTouches"in x&&(b||S)&&(r.current=C),!C)return!0;var R=r.current||C;return Tq(R,w,x,R==="h"?b:S)},[]),l=g.useCallback(function(x){var w=x;if(!(!ma.length||ma[ma.length-1]!==s)){var v="deltaY"in w?Dk(w):Xd(w),_=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&Pq(C.delta,v)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var b=(o.current.shards||[]).map(Ok).filter(Boolean).filter(function(C){return C.contains(w.target)}),S=b.length>0?a(w,b[0]):!o.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),c=g.useCallback(function(x,w,v,_){var b={name:x,delta:w,target:v,should:_,shadowParent:jq(v)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(S){return S!==b})},1)},[]),u=g.useCallback(function(x){n.current=Xd(x),r.current=void 0},[]),d=g.useCallback(function(x){c(x.type,Dk(x),x.target,a(x,e.lockRef.current))},[]),f=g.useCallback(function(x){c(x.type,Xd(x),x.target,a(x,e.lockRef.current))},[]);g.useEffect(function(){return ma.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,pa),document.addEventListener("touchmove",l,pa),document.addEventListener("touchstart",u,pa),function(){ma=ma.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,pa),document.removeEventListener("touchmove",l,pa),document.removeEventListener("touchstart",u,pa)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:Rq(i)}):null,p?g.createElement(wq,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function jq(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Lq=cq(h3,Mq);var um=g.forwardRef(function(e,t){return g.createElement(cm,pi({},e,{ref:t,sideCar:Lq}))});um.classNames=cm.classNames;var yx=["Enter"," "],Dq=["ArrowDown","PageUp","Home"],v3=["ArrowUp","PageDown","End"],Oq=[...Dq,...v3],Bq={ltr:[...yx,"ArrowRight"],rtl:[...yx,"ArrowLeft"]},$q={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Yu="Menu",[ku,zq,Fq]=R4(Yu),[ta,x3]=ro(Yu,[Fq,Hl,i3]),Xu=Hl(),y3=i3(),[_3,io]=ta(Yu),[Hq,Zu]=ta(Yu),b3=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Xu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=Ii(s),f=A4(i);return g.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),h.jsx(om,{...a,children:h.jsx(_3,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(Hq,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};b3.displayName=Yu;var Uq="MenuAnchor",y_=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Xu(n);return h.jsx(am,{...i,...r,ref:t})});y_.displayName=Uq;var __="MenuPortal",[Wq,w3]=ta(__,{forceMount:void 0}),S3=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=io(__,t);return h.jsx(Wq,{scope:t,forceMount:n,children:h.jsx(Jr,{present:n||s.open,children:h.jsx(lm,{asChild:!0,container:i,children:r})})})};S3.displayName=__;var Tr="MenuContent",[qq,b_]=ta(Tr),k3=g.forwardRef((e,t)=>{const n=w3(Tr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=io(Tr,e.__scopeMenu),o=Zu(Tr,e.__scopeMenu);return h.jsx(ku.Provider,{scope:e.__scopeMenu,children:h.jsx(Jr,{present:r||s.open,children:h.jsx(ku.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(Vq,{...i,ref:t}):h.jsx(Kq,{...i,ref:t})})})})}),Vq=g.forwardRef((e,t)=>{const n=io(Tr,e.__scopeMenu),r=g.useRef(null),i=Ot(t,r);return g.useEffect(()=>{const s=r.current;if(s)return x_(s)},[]),h.jsx(w_,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Kq=g.forwardRef((e,t)=>{const n=io(Tr,e.__scopeMenu);return h.jsx(w_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Gq=pl("MenuContent.ScrollLock"),w_=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...x}=e,w=io(Tr,n),v=Zu(Tr,n),_=Xu(n),b=y3(n),S=zq(n),[C,k]=g.useState(null),I=g.useRef(null),E=Ot(t,I,w.onContentChange),A=g.useRef(0),P=g.useRef(""),D=g.useRef(0),R=g.useRef(null),j=g.useRef("right"),M=g.useRef(0),L=m?um:g.Fragment,z=m?{as:Gq,allowPinchZoom:!0}:void 0,F=B=>{var ye,Ce;const N=P.current+B,U=S().filter(oe=>!oe.disabled),V=document.activeElement,O=(ye=U.find(oe=>oe.ref.current===V))==null?void 0:ye.textValue,ne=U.map(oe=>oe.textValue),ae=oV(ne,N,O),Y=(Ce=U.find(oe=>oe.textValue===ae))==null?void 0:Ce.ref.current;(function oe(je){P.current=je,window.clearTimeout(A.current),je!==""&&(A.current=window.setTimeout(()=>oe(""),1e3))})(N),Y&&setTimeout(()=>Y.focus())};g.useEffect(()=>()=>window.clearTimeout(A.current),[]),a_();const $=g.useCallback(B=>{var U,V;return j.current===((U=R.current)==null?void 0:U.side)&&lV(B,(V=R.current)==null?void 0:V.area)},[]);return h.jsx(qq,{scope:n,searchRef:P,onItemEnter:g.useCallback(B=>{$(B)&&B.preventDefault()},[$]),onItemLeave:g.useCallback(B=>{var N;$(B)||((N=I.current)==null||N.focus(),k(null))},[$]),onTriggerLeave:g.useCallback(B=>{$(B)&&B.preventDefault()},[$]),pointerGraceTimerRef:D,onPointerGraceIntentChange:g.useCallback(B=>{R.current=B},[]),children:h.jsx(L,{...z,children:h.jsx(tm,{asChild:!0,trapped:i,onMountAutoFocus:Ie(s,B=>{var N;B.preventDefault(),(N=I.current)==null||N.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(Vu,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(YW,{asChild:!0,...b,dir:v.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:Ie(l,B=>{v.isUsingKeyboardRef.current||B.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(g_,{role:"menu","aria-orientation":"vertical","data-state":F3(w.open),"data-radix-menu-content":"",dir:v.dir,..._,...x,ref:E,style:{outline:"none",...x.style},onKeyDown:Ie(x.onKeyDown,B=>{const U=B.target.closest("[data-radix-menu-content]")===B.currentTarget,V=B.ctrlKey||B.altKey||B.metaKey,O=B.key.length===1;U&&(B.key==="Tab"&&B.preventDefault(),!V&&O&&F(B.key));const ne=I.current;if(B.target!==ne||!Oq.includes(B.key))return;B.preventDefault();const Y=S().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);v3.includes(B.key)&&Y.reverse(),iV(Y)}),onBlur:Ie(e.onBlur,B=>{B.currentTarget.contains(B.target)||(window.clearTimeout(A.current),P.current="")}),onPointerMove:Ie(e.onPointerMove,Cu(B=>{const N=B.target,U=M.current!==B.clientX;if(B.currentTarget.contains(N)&&U){const V=B.clientX>M.current?"right":"left";j.current=V,M.current=B.clientX}}))})})})})})})});k3.displayName=Tr;var Yq="MenuGroup",S_=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(wt.div,{role:"group",...r,ref:t})});S_.displayName=Yq;var Xq="MenuLabel",C3=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(wt.div,{...r,ref:t})});C3.displayName=Xq;var Kf="MenuItem",Bk="menu.itemSelect",dm=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Zu(Kf,e.__scopeMenu),a=b_(Kf,e.__scopeMenu),l=Ot(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(Bk,{bubbles:!0,cancelable:!0});d.addEventListener(Bk,p=>r==null?void 0:r(p),{once:!0}),P4(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(E3,{...i,ref:l,disabled:n,onClick:Ie(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Ie(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Ie(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||yx.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});dm.displayName=Kf;var E3=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=b_(Kf,n),a=y3(n),l=g.useRef(null),c=Ot(t,l),[u,d]=g.useState(!1),[f,p]=g.useState("");return g.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(ku.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(XW,{asChild:!0,...a,focusable:!r,children:h.jsx(wt.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Ie(e.onPointerMove,Cu(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ie(e.onPointerLeave,Cu(m=>o.onItemLeave(m))),onFocus:Ie(e.onFocus,()=>d(!0)),onBlur:Ie(e.onBlur,()=>d(!1))})})})}),Zq="MenuCheckboxItem",I3=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(A3,{scope:e.__scopeMenu,checked:n,children:h.jsx(dm,{role:"menuitemcheckbox","aria-checked":Gf(n)?"mixed":n,...i,ref:t,"data-state":E_(n),onSelect:Ie(i.onSelect,()=>r==null?void 0:r(Gf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});I3.displayName=Zq;var N3="MenuRadioGroup",[Qq,Jq]=ta(N3,{value:void 0,onValueChange:()=>{}}),T3=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=Ii(r);return h.jsx(Qq,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(S_,{...i,ref:t})})});T3.displayName=N3;var P3="MenuRadioItem",R3=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=Jq(P3,e.__scopeMenu),s=n===i.value;return h.jsx(A3,{scope:e.__scopeMenu,checked:s,children:h.jsx(dm,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":E_(s),onSelect:Ie(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});R3.displayName=P3;var k_="MenuItemIndicator",[A3,eV]=ta(k_,{checked:!1}),M3=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=eV(k_,n);return h.jsx(Jr,{present:r||Gf(s.checked)||s.checked===!0,children:h.jsx(wt.span,{...i,ref:t,"data-state":E_(s.checked)})})});M3.displayName=k_;var tV="MenuSeparator",j3=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(wt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});j3.displayName=tV;var nV="MenuArrow",L3=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Xu(n);return h.jsx(v_,{...i,...r,ref:t})});L3.displayName=nV;var C_="MenuSub",[rV,D3]=ta(C_),O3=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=io(C_,t),o=Xu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=Ii(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(om,{...o,children:h.jsx(_3,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(rV,{scope:t,contentId:wi(),triggerId:wi(),trigger:a,onTriggerChange:l,children:n})})})};O3.displayName=C_;var kc="MenuSubTrigger",B3=g.forwardRef((e,t)=>{const n=io(kc,e.__scopeMenu),r=Zu(kc,e.__scopeMenu),i=D3(kc,e.__scopeMenu),s=b_(kc,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(y_,{asChild:!0,...c,children:h.jsx(E3,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":F3(n.open),...e,ref:qu(t,i.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ie(e.onPointerMove,Cu(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Ie(e.onPointerLeave,Cu(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const x=(m=n.content)==null?void 0:m.dataset.side,w=x==="right",v=w?-5:5,_=f[w?"left":"right"],b=f[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+v,y:d.clientY},{x:_,y:f.top},{x:b,y:f.top},{x:b,y:f.bottom},{x:_,y:f.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Ie(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||Bq[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});B3.displayName=kc;var $3="MenuSubContent",z3=g.forwardRef((e,t)=>{const n=w3(Tr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=io(Tr,e.__scopeMenu),o=Zu(Tr,e.__scopeMenu),a=D3($3,e.__scopeMenu),l=g.useRef(null),c=Ot(t,l);return h.jsx(ku.Provider,{scope:e.__scopeMenu,children:h.jsx(Jr,{present:r||s.open,children:h.jsx(ku.Slot,{scope:e.__scopeMenu,children:h.jsx(w_,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Ie(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Ie(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Ie(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=$q[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});z3.displayName=$3;function F3(e){return e?"open":"closed"}function Gf(e){return e==="indeterminate"}function E_(e){return Gf(e)?"indeterminate":e?"checked":"unchecked"}function iV(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function sV(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function oV(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=sV(e,Math.max(s,0));i.length===1&&(o=o.filter(c=>c!==n));const l=o.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function aV(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function lV(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return aV(n,t)}function Cu(e){return t=>t.pointerType==="mouse"?e(t):void 0}var cV=b3,uV=y_,dV=S3,hV=k3,fV=S_,pV=C3,mV=dm,gV=I3,vV=T3,xV=R3,yV=M3,_V=j3,bV=L3,wV=O3,SV=B3,kV=z3,hm="DropdownMenu",[CV]=ro(hm,[x3]),Rn=x3(),[EV,H3]=CV(hm),U3=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Rn(t),c=g.useRef(null),[u,d]=$l({prop:i,defaultProp:s??!1,onChange:o,caller:hm});return h.jsx(EV,{scope:t,triggerId:wi(),triggerRef:c,contentId:wi(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(cV,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};U3.displayName=hm;var W3="DropdownMenuTrigger",q3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=H3(W3,n),o=Rn(n);return h.jsx(uV,{asChild:!0,...o,children:h.jsx(wt.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:qu(t,s.triggerRef),onPointerDown:Ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});q3.displayName=W3;var IV="DropdownMenuPortal",V3=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Rn(t);return h.jsx(dV,{...r,...n})};V3.displayName=IV;var K3="DropdownMenuContent",G3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=H3(K3,n),s=Rn(n),o=g.useRef(!1);return h.jsx(hV,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Ie(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Ie(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});G3.displayName=K3;var NV="DropdownMenuGroup",TV=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(fV,{...i,...r,ref:t})});TV.displayName=NV;var PV="DropdownMenuLabel",Y3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(pV,{...i,...r,ref:t})});Y3.displayName=PV;var RV="DropdownMenuItem",X3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(mV,{...i,...r,ref:t})});X3.displayName=RV;var AV="DropdownMenuCheckboxItem",Z3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(gV,{...i,...r,ref:t})});Z3.displayName=AV;var MV="DropdownMenuRadioGroup",jV=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(vV,{...i,...r,ref:t})});jV.displayName=MV;var LV="DropdownMenuRadioItem",DV=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(xV,{...i,...r,ref:t})});DV.displayName=LV;var OV="DropdownMenuItemIndicator",Q3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(yV,{...i,...r,ref:t})});Q3.displayName=OV;var BV="DropdownMenuSeparator",J3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(_V,{...i,...r,ref:t})});J3.displayName=BV;var $V="DropdownMenuArrow",zV=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(bV,{...i,...r,ref:t})});zV.displayName=$V;var FV=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=Rn(t),[a,l]=$l({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(wV,{...o,open:a,onOpenChange:l,children:n})},HV="DropdownMenuSubTrigger",eP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(SV,{...i,...r,ref:t})});eP.displayName=HV;var UV="DropdownMenuSubContent",tP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(kV,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});tP.displayName=UV;var WV=U3,qV=q3,nP=V3,rP=G3,iP=Y3,sP=X3,oP=Z3,VV=Q3,aP=J3,KV=FV,lP=eP,cP=tP;const uP=WV,dP=qV,I_=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(nP,{children:h.jsx(rP,{ref:r,sideOffset:t,className:re("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));I_.displayName=rP.displayName;const hP=KV,N_=g.forwardRef(({className:e,...t},n)=>h.jsx(lP,{ref:n,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100 data-[state=open]:bg-bg-200","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));N_.displayName=lP.displayName;const T_=g.forwardRef(({className:e,...t},n)=>h.jsx(nP,{children:h.jsx(cP,{ref:n,className:re("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));T_.displayName=cP.displayName;const Wr=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(sP,{ref:r,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Wr.displayName=sP.displayName;const GV=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(oP,{ref:i,checked:n,className:re("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(VV,{children:h.jsx(Qo,{className:"h-3.5 w-3.5"})})}),t]}));GV.displayName=oP.displayName;const fm=g.forwardRef(({className:e,...t},n)=>h.jsx(aP,{ref:n,className:re("-mx-1 my-1 h-px bg-border",e),...t}));fm.displayName=aP.displayName;const P_=g.forwardRef(({className:e,...t},n)=>h.jsx(iP,{ref:n,className:re("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));P_.displayName=iP.displayName;function YV({tool:e,className:t}){const n=UH(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?s_(e):"未知引擎",className:re("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",em(e),t),children:h.jsx(Jp,{tool:e,className:"w-full h-full"})})}function XV({sessionId:e,hasUnread:t,running:n=!1,awaitingUser:r=!1,style:i}){return r?h.jsx(s7,{"data-testid":`awaiting-dot-${e}`,style:i,className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):t?h.jsx("span",{"data-testid":`unread-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):n?h.jsx("span",{"data-testid":`running-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null}function fP(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function pP(e){return e.key==="Enter"&&!e.shiftKey&&!fP(e)}function Qu(e,t){const n=g.useRef(!1),r=g.useCallback(()=>{n.current=!0},[]),i=g.useCallback(()=>{setTimeout(()=>{n.current=!1},0)},[]);return{onKeyDown:g.useCallback(o=>{const a=o.nativeEvent;if(pP({key:o.key,shiftKey:o.shiftKey,compositionActive:n.current,nativeIsComposing:a.isComposing,keyCode:a.keyCode})){o.preventDefault(),e();return}t&&o.key==="Escape"&&(o.preventDefault(),t())},[e,t]),onCompositionStart:r,onCompositionEnd:i}}function ZV({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i,title:s="Edit session",fieldLabel:o="Label",testId:a="session-edit-dialog",requireNonEmpty:l=!1}){const[c,u]=g.useState(t);g.useEffect(()=>{e&&u(t)},[e,t]);const d=c.trim(),f=l&&d==="",p=()=>{f||r({label:d})},m=Qu(p,i);return e?Oo.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:i,"data-testid":`${a}-overlay`,children:h.jsxs("div",{"data-testid":a,className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:x=>x.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:s}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:o}),h.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:x=>u(x.target.value),...m,placeholder:n,"data-testid":`${a}-label`,className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:i,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:p,disabled:f,"data-testid":`${a}-save`,className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer disabled:cursor-not-allowed disabled:opacity-40",children:"Save"})]})]})}),document.body):null}var QV=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),JV="VisuallyHidden",mP=g.forwardRef((e,t)=>h.jsx(wt.span,{...e,ref:t,style:{...QV,...e.style}}));mP.displayName=JV;var eK=mP,[pm]=ro("Tooltip",[Hl]),mm=Hl(),gP="TooltipProvider",tK=700,_x="tooltip.open",[nK,R_]=pm(gP),vP=e=>{const{__scopeTooltip:t,delayDuration:n=tK,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx(nK,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:g.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};vP.displayName=gP;var Eu="Tooltip",[rK,gm]=pm(Eu),xP=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=R_(Eu,e.__scopeTooltip),c=mm(t),[u,d]=g.useState(null),f=wi(),p=g.useRef(0),m=o??l.disableHoverableContent,x=a??l.delayDuration,w=g.useRef(!1),[v,_]=$l({prop:r,defaultProp:i??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(_x))):l.onClose(),s==null||s(I)},caller:Eu}),b=g.useMemo(()=>v?w.current?"delayed-open":"instant-open":"closed",[v]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,_(!0)},[_]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,_(!0),p.current=0},x)},[x,_]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(om,{...c,children:h.jsx(rK,{scope:t,contentId:f,open:v,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():S()},[l.isOpenDelayedRef,k,S]),onTriggerLeave:g.useCallback(()=>{m?C():(window.clearTimeout(p.current),p.current=0)},[C,m]),onOpen:S,onClose:C,disableHoverableContent:m,children:n})})};xP.displayName=Eu;var bx="TooltipTrigger",yP=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=gm(bx,n),s=R_(bx,n),o=mm(n),a=g.useRef(null),l=Ot(t,a,i.onTriggerChange),c=g.useRef(!1),u=g.useRef(!1),d=g.useCallback(()=>c.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),h.jsx(am,{asChild:!0,...o,children:h.jsx(wt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Ie(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Ie(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Ie(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Ie(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Ie(e.onBlur,i.onClose),onClick:Ie(e.onClick,i.onClose)})})});yP.displayName=bx;var iK="TooltipPortal",[Ade,sK]=pm(iK,{forceMount:void 0}),gl="TooltipContent",_P=g.forwardRef((e,t)=>{const n=sK(gl,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=gm(gl,e.__scopeTooltip);return h.jsx(Jr,{present:r||o.open,children:o.disableHoverableContent?h.jsx(bP,{side:i,...s,ref:t}):h.jsx(oK,{side:i,...s,ref:t})})}),oK=g.forwardRef((e,t)=>{const n=gm(gl,e.__scopeTooltip),r=R_(gl,e.__scopeTooltip),i=g.useRef(null),s=Ot(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,x)=>{const w=m.currentTarget,v={x:m.clientX,y:m.clientY},_=dK(v,w.getBoundingClientRect()),b=hK(v,_),S=fK(x.getBoundingClientRect()),C=mK([...b,...S]);a(C),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=w=>p(w,u),x=w=>p(w,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",x),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",x)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=x=>{const w=x.target,v={x:x.clientX,y:x.clientY},_=(l==null?void 0:l.contains(w))||(u==null?void 0:u.contains(w)),b=!pK(v,o);_?f():b&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(bP,{...e,ref:s})}),[aK,lK]=pm(Eu,{isInside:!1}),cK=JH("TooltipContent"),bP=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=gm(gl,n),c=mm(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(_x,u),()=>document.removeEventListener(_x,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(Vu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(g_,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(cK,{children:r}),h.jsx(aK,{scope:n,isInside:!0,children:h.jsx(eK,{id:l.contentId,role:"tooltip",children:i||r})})]})})});_P.displayName=gl;var wP="TooltipArrow",uK=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=mm(n);return lK(wP,n).isInside?null:h.jsx(v_,{...i,...r,ref:t})});uK.displayName=wP;function dK(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function hK(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function fK(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function pK(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function mK(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),gK(t)}function gK(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var vK=vP,xK=xP,yK=yP,SP=_P;const Iu=vK,Ju=xK,ed=yK,Ul=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(SP,{ref:r,sideOffset:t,className:re("z-50 overflow-hidden rounded-sm border border-border bg-bg-0 px-2 py-1 text-xs text-text-300 shadow-md",e),...n}));Ul.displayName=SP.displayName;const _K={held:!1,indexBySessionId:new Map},bK=g.createContext(_K);function wK(){return g.useContext(bK)}const SK=Array.from({length:9},(e,t)=>({id:`switch-session-${t+1}`,combo:{key:String(t+1),mod:!0},label:`切换到第 ${t+1} 个会话`,group:"会话",desktopOnly:!0,hiddenInList:!0})),kK=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},{id:"open-search",combo:{key:"k",mod:!0},label:"全局搜索",description:"搜会话内容 / persona / 联系人",group:"通用",desktopOnly:!0},{id:"search-tab-prev",combo:{key:"ArrowLeft",mod:!0},label:"搜索:上一组",description:"搜索浮层里切到左边那个 tab(会话 / persona / 联系人)",group:"通用"},{id:"search-tab-next",combo:{key:"ArrowRight",mod:!0},label:"搜索:下一组",description:"搜索浮层里切到右边那个 tab",group:"通用"},...SK,{id:"archive-session",combo:{key:"Backspace",mod:!0,shift:!0},label:"归档当前会话",description:"归档当前聊天区的会话,Enter 确认 / Esc 取消",group:"会话",desktopOnly:!0},{id:"tab-prev",combo:{key:"ArrowLeft",mod:!0,shift:!0},label:"上一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"tab-next",combo:{key:"ArrowRight",mod:!0,shift:!0},label:"下一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"toggle-hive",combo:{key:"h",mod:!0,shift:!0},label:"Hive 看板",description:"全屏看所有 agent 在干什么;Esc 或点任意行退出",group:"通用"},{id:"send-message",combo:{key:"Enter"},label:"发送消息",description:"在输入框中发送当前内容",group:"输入",displayOnly:!0},{id:"newline",combo:{key:"Enter",shift:!0},label:"换行",description:"在输入框中插入换行",group:"输入",displayOnly:!0},{id:"interrupt",combo:{key:"Escape"},label:"打断回复",description:"打断当前回复;2 秒内按两次停止任务",group:"输入",displayOnly:!0}];kK.filter(e=>!e.displayOnly);function CK(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const EK=10,IK=20,NK=16,$k=20,zk=60,TK=4;function Zd({testId:e,label:t,children:n}){return h.jsxs(Ju,{children:[h.jsx(ed,{asChild:!0,children:h.jsx("span",{"data-testid":e,role:"img","aria-label":t,tabIndex:0,className:"inline-flex shrink-0",children:n})}),h.jsx(Ul,{side:"bottom",children:t})]})}function PK({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,quickAction:u,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m,ownerPrincipalId:x,creatorDisplayName:w,dispatchedFromSessionTitle:v}){const[_,b]=g.useState(!1),S=wK(),C=S.held?S.indexBySessionId.get(e.sessionId):void 0,k=!!e.pinnedAt,I=d===0,E=d===0&&!!c,A=EK+d*IK;let P=null;u==="pin"&&I&&l?P={icon:k?h.jsx(rk,{className:"w-4 h-4"}):h.jsx(ik,{className:"w-4 h-4"}),label:k?"取消置顶":"置顶",run:()=>l(e.sessionId,!k)}:u==="archive"&&E&&c?P={icon:h.jsx(ek,{className:"w-4 h-4"}),label:"归档",run:()=>c(e.sessionId,!0)}:u==="rename"&&o&&(P={icon:h.jsx(ux,{className:"w-4 h-4"}),label:"重命名",run:()=>b(!0)});const D=g.useCallback(async()=>{const z=N4(e);if(z)try{await navigator.clipboard.writeText(z)}catch{}},[e]),R=o_(e),j=e.originOwnerPrincipalId,M=j?`@${m??`…${j.slice(-8)}`}`:null,L=!!(e.ownerPersonaId&&x&&e.creatorPrincipalId&&e.creatorPrincipalId!==x&&!e.larkChatId&&!e.shiftFiredFromSessionId&&!e.dispatchedFromSessionId);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:A,display:"grid",gridTemplateColumns:f?`${NK}px ${$k}px 1fr auto ${zk}px`:`${$k}px 1fr auto ${zk}px`,gridTemplateAreas:f?'"chev icon name dot time"':'"icon name dot time"',columnGap:`${TK}px`,alignItems:"center"},className:re("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:f??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(YV,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[h.jsxs(Iu,{delayDuration:200,skipDelayDuration:100,children:[e.dispatchedFromSessionId?h.jsx(Zd,{testId:`dispatched-icon-${e.sessionId}`,label:`来自【${v??"另一会话"}】dispatch`,children:h.jsx(P7,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.shiftFiredFromSessionId?h.jsx(Zd,{testId:`shift-fired-icon-${e.sessionId}`,label:"定时任务",children:h.jsx(Zz,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.larkChatId?h.jsx(Zd,{testId:`lark-chat-icon-${e.sessionId}`,label:e.larkChatType==="p2p"?"来自飞书DM":"来自飞书群",children:h.jsx(uF,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,L?h.jsx(Zd,{testId:`guest-created-icon-${e.sessionId}`,label:w?`${w}创建`:"其他人创建",children:h.jsx(VF,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null]}),h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:re("text-[13px] truncate min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-words",t?"text-text-100 font-medium":"text-text-200"),children:R}),M?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${M.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:M}):null]}),h.jsx(XV,{sessionId:e.sessionId,hasUnread:n,running:r,awaitingUser:i,style:{gridArea:"dot"}}),C!=null?h.jsx("span",{style:{gridArea:"time"},"data-testid":`session-quick-switch-badge-${e.sessionId}`,className:"text-right shrink-0 transition-opacity duration-150 group-hover:opacity-0",children:h.jsx("span",{className:"inline-flex items-center justify-center h-[18px] px-1.5 rounded-[5px] border border-border bg-bg-200/70 text-[11px] text-text-200 font-medium leading-none",children:CK()?`⌘${C}`:`Ctrl+${C}`})}):h.jsx("span",{style:{gridArea:"time"},className:re("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?WH(e.updatedAt):""}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-[3px] flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[P?h.jsx(Iu,{delayDuration:200,skipDelayDuration:100,children:h.jsxs(Ju,{children:[h.jsx(ed,{asChild:!0,children:h.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),P.run()},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":P.label,"data-testid":`quick-action-${u}-${e.sessionId}`,children:P.icon})}),h.jsx(Ul,{side:"bottom",children:P.label})]})}):null,h.jsxs(uP,{modal:!1,children:[h.jsx(dP,{asChild:!0,children:h.jsx("button",{type:"button",onClick:z=>z.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(r4,{className:"w-4 h-4"})})}),h.jsxs(I_,{align:"end",onClick:z=>z.stopPropagation(),children:[l&&I&&h.jsxs(Wr,{onSelect:()=>l(e.sessionId,!k),"data-testid":`session-${k?"unpin":"pin"}-${e.sessionId}`,children:[k?h.jsx(rk,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(ik,{className:"w-3 h-3 mr-2 text-text-400"}),k?"Unpin":"Pin"]}),E&&c&&h.jsxs(Wr,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(ek,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(Wr,{onSelect:()=>b(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(ux,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(Wr,{onSelect:()=>void D(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(Jy,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(fm,{}),a&&h.jsxs(Wr,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(n_,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(ZV,{open:_,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:z=>{o(e.sessionId,z),b(!1)},onCancel:()=>b(!1)}):null]})}function A_({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:x,getSessionDisplayName:w,parentSession:v}){const _=e.children.length>0,{isCollapsed:b,toggle:S}=Wz(),C=!b(e.session.sessionId),k=g.useCallback(E=>{E.stopPropagation(),S(e.session.sessionId)},[S,e.session.sessionId]),I=_?h.jsx("button",{type:"button",onClick:k,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":C?"collapse":"expand","aria-expanded":C,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:C?h.jsx(Pn,{className:"w-3 h-3"}):h.jsx(Fn,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(PK,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,showCopyResume:p,ownerPrincipalId:m,creatorDisplayName:e.session.creatorPrincipalId?x==null?void 0:x(e.session.creatorPrincipalId):void 0,dispatchedFromSessionTitle:e.session.dispatchedFromSessionId?(w==null?void 0:w(e.session.dispatchedFromSessionId))??((v==null?void 0:v.sessionId)===e.session.dispatchedFromSessionId?o_(v):void 0):void 0,depth:t,chevron:I,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),_&&C?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(E=>h.jsx(A_,{node:E,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:x,getSessionDisplayName:w,parentSession:e.session},E.session.sessionId))}):null]})}function RK(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function M_(e,t){return e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function kP(e){e=e.filter(s=>!s.ephemeral&&s.deployId===void 0&&s.testReleaseId===void 0);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=RK(s);if(o&&t.has(o)){const a=n.get(o)??[];a.push(s),n.set(o,a)}else r.push(s)}const i=s=>{const a=[...n.get(s.sessionId)??[]].sort(M_);return{session:s,children:a.map(i)}};return[...r].sort(AK).map(i)}function CP(e){return[...e].sort((t,n)=>M_(t.session,n.session))}function AK(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r?1:M_(e,t)}function MK(e){return e.label?e.label:e.aiLabel?e.aiLabel:e.cwd.split("/").filter(Boolean).pop()??""}function Fk(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const jK={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function LK({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:x,onPinSession:w,showCopyResume:v,treatSessionsAsRoots:_,searchQuery:b}){const[S,C]=g.useState(null),[k,I]=g.useState(()=>new Set),E=p??(L=>k.has(L)),A=g.useCallback(L=>{if(m){m(L);return}I(z=>{const F=new Set(z);return F.has(L)?F.delete(L):F.add(L),F})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(L=>!L.ephemeral),[i]),D=g.useMemo(()=>new Map((P??[]).map(L=>[L.sessionId,o_(L)])),[P]),R=g.useCallback(L=>f==null?void 0:f.get(L),[f]),j=g.useCallback(L=>D.get(L),[D]);if(e.length===0)return h.jsx(DK,{});const M=(b??"").trim();return M?h.jsx(Zy.Provider,{value:jK,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const z=P?P.filter(N=>N.ownerPersonaId===L.personaId).sort((N,U)=>U.updatedAt>N.updatedAt?1:-1):[],F=Fk(L.label,M),$=z.filter(N=>Fk(MK(N),M));if(!F&&$.length===0)return null;const B=F?z:$;return h.jsx(Hk,{persona:L,active:L.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:B,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:x,onPinSession:w,showCopyResume:v,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:j},L.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const z=P?P.filter(F=>F.ownerPersonaId===L.personaId).sort((F,$)=>$.updatedAt>F.updatedAt?1:-1):[];return h.jsx(Hk,{persona:L,active:L.personaId===t,editing:L.personaId===S,onSelectPersona:n,onStartCreateSession:r?()=>C(L.personaId):void 0,onSubmitCreateSession:F=>{C(null),r==null||r(L.personaId,F)},onCancelCreateSession:()=>C(null),personaSessions:z,collapsed:!E(L.personaId),onToggleCollapsed:()=>A(L.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:x,onPinSession:w,showCopyResume:v,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:j},L.personaId)})})}function DK(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function Hk({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:x,onEditSession:w,onPinSession:v,showCopyResume:_,treatSessionsAsRoots:b,ownerPrincipalId:S,creatorDisplayNameByOwnerId:C,getCreatorDisplayName:k,getSessionDisplayName:I}){const E=a.length>0,A=!l,P=g.useMemo(()=>{const j=[],M=new Map;for(const L of a){const z=L.creatorPrincipalId;if(L.larkChatId!=null||!z||S&&z===S){j.push(L);continue}const F=z,$=(C==null?void 0:C.get(F))??`…${F.slice(-8)}`,B=M.get(F);B?B.sessions.push(L):M.set(F,{groupKey:F,displayName:$,sessions:[L]})}return{self:j,byPeer:[...M.values()]}},[a,S,C]),D=P.byPeer.length>0,R=g.useMemo(()=>A&&!D?CP(kP(a)):[],[A,D,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:re("group flex items-center gap-1 px-2 py-1.5 cursor-pointer",t?"bg-accent-dim text-text-100":"hover:bg-bg-200 text-text-200"),onClick:()=>r==null?void 0:r(e.personaId),role:"button",tabIndex:0,children:[E?h.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),c()},"aria-label":A?"collapse":"expand","aria-expanded":A,"data-testid":`persona-chevron-${e.personaId}`,className:"flex h-4 w-4 shrink-0 items-center justify-center text-text-400 hover:text-text-100",children:A?h.jsx(Pn,{className:"h-3 w-3"}):h.jsx(Fn,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(Jp,{tool:e.tool,className:re("h-3.5 w-3.5 shrink-0",em(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),E?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),i()},"aria-label":"新建会话",title:"新建会话","data-testid":`persona-create-session-${e.personaId}`,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-text-400 opacity-0 hover:bg-text-100/10 hover:text-text-100 focus-visible:opacity-100 group-hover:opacity-100",children:h.jsx(e_,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(OK,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,E&&A?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:D?h.jsxs(h.Fragment,{children:[P.self.length>0&&h.jsx(Uk,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:P.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:x,onEditSession:w,onPinSession:v,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:I}),P.byPeer.map(j=>h.jsx(Uk,{groupKey:`${e.personaId}-peer-${j.groupKey}`,label:j.displayName,testId:`persona-sessions-${e.personaId}-peer-${j.groupKey}`,sessions:j.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:x,onEditSession:w,onPinSession:v,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:I},`${e.personaId}-peer-${j.groupKey}`))]}):R.map(j=>h.jsx(A_,{node:j,depth:b?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:M=>m==null?void 0:m(M),onDelete:x,onEdit:w,onPin:v,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:I},j.session.sessionId))}):null]})}function Uk({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m}){const[x,w]=g.useState(!1),v=!x,_=g.useMemo(()=>v?CP(kP(n)):[],[v,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>w(b=>!b),"aria-label":v?"collapse":"expand","aria-expanded":v,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[v?h.jsx(Pn,{className:"h-3 w-3"}):h.jsx(Fn,{className:"h-3 w-3"}),h.jsx(u4,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),v&&h.jsx("div",{children:_.map(b=>h.jsx(A_,{node:b,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:S=>a==null?void 0:a(S),onDelete:l,onEdit:c,onPin:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m},b.session.sessionId))})]})}function OK({personaId:e,tool:t,onSubmit:n,onCancel:r}){const[i,s]=g.useState(""),o=g.useRef(null),a=i.trim(),l=a.length>0;g.useEffect(()=>{var d;(d=o.current)==null||d.focus()},[]);const c=g.useCallback(()=>{l&&n(a)},[l,a,n]),u=Qu(c,r);return h.jsxs("div",{className:"flex items-center gap-1.5 pl-9 pr-2 py-1","data-testid":`persona-new-session-row-${e}`,children:[h.jsx(Jp,{tool:t,className:re("h-3 w-3 shrink-0",em(t))}),h.jsx("input",{ref:o,type:"text",value:i,onChange:d=>s(d.target.value),...u,onBlur:r,placeholder:"session label...","data-testid":`persona-new-session-input-${e}`,className:"flex-1 min-w-0 bg-bg-100 border border-text-100/15 rounded px-1.5 py-0.5 text-[12px] text-text-100 placeholder:text-text-400 focus:outline-none focus:border-text-100/40"}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),c()},disabled:!l,"aria-label":"确认",title:"确认(Enter)","data-testid":`persona-new-session-confirm-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-300",children:h.jsx(Qo,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),r()},"aria-label":"取消",title:"取消(Esc)","data-testid":`persona-new-session-cancel-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100",children:h.jsx(Qr,{className:"h-3 w-3"})})]})}function BK(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function $K(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function zK(e){return e/100*window.innerHeight}function FK(e){return e/100*window.innerWidth}function HK(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Cc({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=HK(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=$K(t,i);break}case"em":{r=BK(t,i);break}case"vh":{r=zK(i);break}case"vw":{r=FK(i);break}}return r}function Dn(e){return parseFloat(e.toFixed(3))}function vl({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function wx(e){const{panels:t}=e,n=vl({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let o=0;if(s.collapsedSize!==void 0){const u=Cc({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=Dn(u/n*100)}let a;if(s.defaultSize!==void 0){const u=Cc({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=Dn(u/n*100)}let l=0;if(s.minSize!==void 0){const u=Cc({groupSize:n,panelElement:i,styleProp:s.minSize});l=Dn(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=Cc({groupSize:n,panelElement:i,styleProp:s.maxSize});c=Dn(u/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:o,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:l,maxSize:c,panelId:r.id}})}function ut(e,t="Assertion error"){if(!e)throw Error(t)}function Sx(e,t){return Array.from(t).sort(e==="horizontal"?UK:WK)}function UK(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function WK(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function EP(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function IP(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function qK({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const o of t){const{x:a,y:l}=IP(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return ut(i,"No rect found"),i}let Qd;function VK(){return Qd===void 0&&(typeof matchMedia=="function"?Qd=!!matchMedia("(pointer:coarse)").matches:Qd=!1),Qd}function NP(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=Sx(n,Array.from(t.children).filter(EP).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const x of s)x.hasAttribute("data-panel")&&(m++,x.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const x of s)if(x.hasAttribute("data-panel")){m++;const w=r.find(v=>v.element===x);if(w){if(f){const v=f.element.getBoundingClientRect(),_=x.getBoundingClientRect();let b;if(l){const S=n==="horizontal"?new DOMRect(v.right,v.top,0,v.height):new DOMRect(v.left,v.bottom,v.width,0),C=n==="horizontal"?new DOMRect(_.left,_.top,0,_.height):new DOMRect(_.left,_.top,_.width,0);switch(p.length){case 0:{b=[S,C];break}case 1:{const k=p[0],I=qK({orientation:n,rects:[v,_],targetRect:k.element.getBoundingClientRect()});b=[k,I===v?C:S];break}default:{b=p;break}}}else p.length?b=p:b=[n==="horizontal"?new DOMRect(v.right,_.top,_.left-v.right,_.height):new DOMRect(_.left,v.bottom,_.width,_.top-v.bottom)];for(const S of b){let C="width"in S?S:S.element.getBoundingClientRect();const k=VK()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<k){const E=k-C.width;C=new DOMRect(C.x-E/2,C.y,C.width+E,C.height)}if(C.height<k){const E=k-C.height;C=new DOMRect(C.x,C.y-E/2,C.width,C.height+E)}const I=m<=c||m>u;!a&&!I&&o.push({group:e,groupSize:vl({group:e}),panels:[f,w],separator:"width"in S?void 0:S,rect:C}),a=!1}}l=!1,f=w,p=[]}}else if(x.hasAttribute("data-separator")){x.ariaDisabled!==null&&(a=!0);const w=i.find(v=>v.element===x);w?p.push(w):(f=void 0,p=[])}else l=!0}return o}var Ts;class TP{constructor(){Ob(this,Ts,{})}addListener(t,n){const r=Ql(this,Ts)[t];return r===void 0?Ql(this,Ts)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=Ql(this,Ts)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const o=Array.from(r);for(let a=0;a<o.length;a++){const l=o[a];try{l.call(null,n)}catch(c){s===null&&(i=!0,s=c)}}if(i)throw s}}removeAllListeners(){Bb(this,Ts,{})}removeListener(t,n){const r=Ql(this,Ts)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}Ts=new WeakMap;let Xa={cursorFlags:0,state:"inactive"};const j_=new TP;function Ho(){return Xa}function KK(e){return j_.addListener("change",e)}function GK(e){const t=Xa,n={...Xa};n.cursorFlags=e,Xa=n,j_.emit("change",{prev:t,next:n})}function Za(e){const t=Xa;Xa=e,j_.emit("change",{prev:t,next:e})}const YK=e=>e,Dg=()=>{},PP=1,RP=2,AP=4,MP=8,Wk=3,qk=12;let Jd;function Vk(){return Jd===void 0&&(Jd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Jd=!0)),Jd}function XK({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&Vk()){const s=(e&PP)!==0,o=(e&RP)!==0,a=(e&AP)!==0,l=(e&MP)!==0;if(s)return a?"se-resize":l?"ne-resize":"e-resize";if(o)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return Vk()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const Kk=new WeakMap;function L_(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Kk.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=Ho();switch(r.state){case"active":case"hover":{const i=XK({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}Kk.set(e,{prevStyle:t,styleSheet:n})}let gi=new Map;const jP=new TP;function ZK(e){gi=new Map(gi),gi.delete(e)}function Gk(e,t){for(const[n]of gi)if(n.id===e)return n}function Us(e,t){for(const[n,r]of gi)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function na(){return gi}function D_(e,t){return jP.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function is(e,t,n){const r=gi.get(e);gi=new Map(gi),gi.set(e,t),jP.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function LP(e){const t=Ho();let n=!1;switch(t.state){case"active":Za({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(L_(e),n=!0,t.hitRegions.forEach(r=>{const i=Us(r.group.id,!0);is(r.group,i,{isUserInteraction:!0})}))}return n}function Yk(e){e.defaultPrevented||LP(e.currentTarget)}function QK(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=IP(n,s.rect);switch(e){case"horizontal":{o.x<=i.x&&(r=s,i=o);break}case"vertical":{o.y<=i.y&&(r=s,i=o);break}}}return r?{distance:i,hitRegion:r}:void 0}function JK(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function eG(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Qk(e),b:Qk(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();ut(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Zk(Xk(n.a)),b:Zk(Xk(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const tG=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function nG(e){const t=getComputedStyle(DP(e)??e).display;return t==="flex"||t==="inline-flex"}function rG(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||nG(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||tG.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Xk(e){let t=e.length;for(;t--;){const n=e[t];if(ut(n,"Missing node"),rG(n))return n}return null}function Zk(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Qk(e){const t=[];for(;e;)t.push(e),e=DP(e);return t}function DP(e){const{parentNode:t}=e;return JK(t)?t.host:t}function iG(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function sG({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!EP(n)||n.contains(e)||e.contains(n))return!0;if(eG(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(iG(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function O_(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=NP(i),o=QK(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&sG({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function oG(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Cn(e,t,n=0){return Math.abs(Dn(e)-Dn(t))<=n}function hi(e,t){return Cn(e,t)?0:e>t?1:-1}function Ba({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:o,maxSize:a=100,minSize:l=0}=t;if(o&&!e)return n;if(hi(r,l)<0)if(s){const c=(i+l)/2;hi(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=Dn(r),r}function Nu({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Cn(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;ut(u!=null,"Invalid first pivot index"),ut(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const x=e<0?d:u,w=n[x];ut(w,`Panel constraints not found for index ${x}`);const{collapsedSize:v=0,collapsible:_,minSize:b=0}=w;if(_){const S=a[x];if(ut(S!=null,`Previous layout not found for panel index ${x}`),Cn(S,v)){const C=b-S;hi(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const x=e<0?u:d,w=n[x];ut(w,`No panel constraints found for index ${x}`);const{collapsedSize:v=0,collapsible:_,minSize:b=0}=w;if(_){const S=a[x];if(ut(S!=null,`Previous layout not found for panel index ${x}`),Cn(S,b)){const C=S-v;hi(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const x=e<0?d:u,w=n[x];ut(w,`Panel constraints not found for index ${x}`);const v=a[x],{collapsible:_,collapsedSize:b,minSize:S}=w;if(_&&hi(v,S)<0)if(e>0){const C=S-b,k=C/2,I=v+e;hi(I,S)<0&&(e=hi(e,k)<=0?0:C)}else{const C=S-b,k=100-C/2,I=v-e;hi(I,S)<0&&(e=hi(100+e,k)>0?0:-C)}break}}{const x=e<0?1:-1;let w=e<0?d:u,v=0;for(;;){const b=a[w];ut(b!=null,`Previous layout not found for panel index ${w}`);const S=Ba({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:b,size:100})-b;if(v+=S,w+=x,w<0||w>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-_:_}{let x=e<0?u:d;for(;x>=0&&x<n.length;){const w=Math.abs(e)-Math.abs(f),v=a[x];ut(v!=null,`Previous layout not found for panel index ${x}`);const _=v-w,b=Ba({overrideDisabledPanels:o,panelConstraints:n[x],prevSize:v,size:_});if(!Cn(v,b)&&(f+=v-b,c[x]=b,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?x--:x++}}if(oG(l,c))return i;{const x=e<0?d:u,w=a[x];ut(w!=null,`Previous layout not found for panel index ${x}`);const v=w+f,_=Ba({overrideDisabledPanels:o,panelConstraints:n[x],prevSize:w,size:v});if(c[x]=_,!Cn(_,v)){let b=v-_,S=e<0?d:u;for(;S>=0&&S<n.length;){const C=c[S];ut(C!=null,`Previous layout not found for panel index ${S}`);const k=C+b,I=Ba({overrideDisabledPanels:o,panelConstraints:n[S],prevSize:C,size:k});if(Cn(C,I)||(b-=I-C,c[S]=I),Cn(b,0))break;e>0?S--:S++}}}const p=Object.values(c).reduce((x,w)=>w+x,0);if(!Cn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((x,w,v)=>(x[m[v]]=w,x),{})}function Uo(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||hi(e[n],t[n])!==0)return!1;return!0}function Wo({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!Cn(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];ut(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];ut(l!=null,`No layout data found for index ${a}`);const c=r[a];ut(c!=null,`No layout data found for index ${a}`);const u=Ba({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!Cn(s,0))for(let a=0;a<t.length;a++){const l=r[a];ut(l!=null,`No layout data found for index ${a}`);const c=l+s,u=Ba({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,Cn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function OP({groupId:e,panelId:t}){const n=()=>{const l=na();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(w=>w.id===t),m=p===0,x=p===c.length-1;if(x&&l<f&&(m||c.slice(0,p).every((w,v)=>{const _=d[v];return(_==null?void 0:_.collapsible)&&Cn(_.collapsedSize,u[_.panelId])}))){const w=c.slice(0,p).reduce((v,_)=>v+u[_.id],0);return{...u,[t]:Dn(100-w)}}return Nu({delta:x?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:x?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:x}=n(),w=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),v=Wo({layout:w,panelConstraints:d});Uo(m,v)||is(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:v,separatorToPanels:x})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&Cn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=vl({group:c}),f=Cc({groupSize:d,panelElement:u,styleProp:l}),p=Dn(f/d*100);a(p)}}}function Jk(e){if(e.defaultPrevented)return;const t=na();O_(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const r=n.panels.find(i=>i.panelConstraints.defaultSize!==void 0);if(r){const i=r.panelConstraints.defaultSize,s=OP({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function Bh(e){const t=na();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function BP({groupId:e}){const t=()=>{const n=na();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:o,layout:a,separatorToPanels:l}=t(),c=Wo({layout:n,panelConstraints:i});return r?a:(Uo(a,c)||is(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function po(e,t){const n=Bh(e),r=Us(n.id,!0),i=n.separators.find(u=>u.element===e);ut(i,"Matching separator not found");const s=r.separatorToPanels.get(i);ut(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=BP({groupId:n.id}).getLayout(),l=Nu({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=Wo({layout:l,panelConstraints:r.derivedPanelConstraints});Uo(a,c)||is(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function eC(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Bh(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&po(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&po(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&po(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&po(t,-5);break}case"End":{e.preventDefault(),po(t,100);break}case"Enter":{e.preventDefault();const r=Bh(t),i=Us(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);ut(l,"Matching separator not found");const c=a.get(l);ut(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(ut(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;po(t,p-f)}break}case"F6":{e.preventDefault();const r=Bh(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);ut(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),po(t,-100);break}}}function tC(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=na(),n=O_(e,t),r=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const o=t.get(s.group);o&&r.set(s.group,o.layout)}),Za({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function $P({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let x=0;s?f==="horizontal"?x=(t.clientX-s.x)/d*100:x=(t.clientY-s.y)/d*100:f==="horizontal"?x=t.clientX<0?-100:100:x=t.clientY<0?-100:100;const w=r.get(u),v=i.get(u);if(!w||!v)return;const{defaultLayoutDeferred:_,derivedPanelConstraints:b,groupSize:S,layout:C,separatorToPanels:k}=v;if(b&&C&&k){const I=Nu({delta:x,initialLayout:w,panelConstraints:b,pivotIndices:c.panels.map(E=>p.indexOf(E)),prevLayout:C,trigger:"mouse-or-touch"});if(Uo(I,C)){if(x!==0&&!m)switch(f){case"horizontal":{a|=x<0?PP:RP;break}case"vertical":{a|=x<0?AP:MP;break}}}else is(c.group,{defaultLayoutDeferred:_,derivedPanelConstraints:b,groupSize:S,layout:I,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&Wk:l|=a&Wk,t.movementY===0?l|=o&qk:l|=a&qk,GK(l),L_(e)}function nC(e){const t=na(),n=Ho();switch(n.state){case"active":$P({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function rC(e){var r,i;if(e.defaultPrevented)return;const t=Ho(),n=na();switch(t.state){case"active":{if(e.buttons===0){Za({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=Us(s.group.id,!0);is(s.group,o,{isUserInteraction:!0})});return}for(const s of t.hitRegions)if(s.separator){const{element:o}=s.separator;(r=o.hasPointerCapture)!=null&&r.call(o,e.pointerId)||((i=o.setPointerCapture)==null||i.call(o,e.pointerId))}$P({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=O_(e,n);s.length===0?t.state!=="inactive"&&Za({cursorFlags:0,state:"inactive"}):Za({cursorFlags:0,hitRegions:s,state:"hover"}),L_(e.currentTarget);break}}}function iC(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Ho().state){case"hover":Za({cursorFlags:0,state:"inactive"})}}function sC(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||LP(e.currentTarget)&&e.preventDefault()}function oC(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=Dn(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Dn((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function aG(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=vl({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:Dn(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function lG(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function cG({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,s=0,o=!1;const a=new Map,l=[];for(const d of e.panels){const f=r[d.id]??0;switch(d.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{o=!0;const p=f/100*n,m=Dn(p/t*100);a.set(d.id,m),i+=m;break}case"preserve-relative-size":default:{l.push(d.id),s+=f;break}}}if(!o||l.length===0)return r;const c=100-i,u={...r};if(a.forEach((d,f)=>{u[f]=d}),s>0)for(const d of l){const f=r[d]??0;u[d]=Dn(f/s*c)}else{const d=Dn(c/l.length);for(const f of l)u[f]=d}return u}function uG(e,t){const n=e.map(i=>i.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!r.includes(i))return!1;return!0}const ga=new Map;function dG(e){let t=!0;ut(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const x of m){const{borderBoxSize:w,target:v}=x;if(v===e.element){if(t){const _=vl({group:e});if(_===0)return;const b=Us(e.id);if(!b)return;const S=wx(e),C=b.defaultLayoutDeferred?oC(S):b.layout,k=cG({group:e,nextGroupSize:_,prevGroupSize:b.groupSize,prevLayout:C}),I=Wo({layout:k,panelConstraints:S});if(!b.defaultLayoutDeferred&&Uo(b.layout,I)&&lG(b.derivedPanelConstraints,S)&&b.groupSize===_)return;is(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:_,layout:I,separatorToPanels:b.separatorToPanels})}}else aG(e,v,w)}});s.observe(e.element),e.panels.forEach(m=>{ut(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=vl({group:e}),a=wx(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(uG(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??oC(a),d=Wo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;ga.set(f,(ga.get(f)??0)+1);const p=new Map;return NP(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),is(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{ut(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",eC)}),ga.get(f)===1&&(f.addEventListener("contextmenu",Yk,!0),f.addEventListener("dblclick",Jk,!0),f.addEventListener("pointerdown",tC,!0),f.addEventListener("pointerleave",nC),f.addEventListener("pointermove",rC),f.addEventListener("pointerout",iC),f.addEventListener("pointerup",sC,!0)),function(){t=!1,ga.set(f,Math.max(0,(ga.get(f)??0)-1)),ZK(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",eC)}),ga.get(f)||(f.removeEventListener("contextmenu",Yk,!0),f.removeEventListener("dblclick",Jk,!0),f.removeEventListener("pointerdown",tC,!0),f.removeEventListener("pointerleave",nC),f.removeEventListener("pointermove",rC),f.removeEventListener("pointerout",iC),f.removeEventListener("pointerup",sC,!0)),s.disconnect()}}function hG(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function B_(e){const t=g.useId();return`${e??t}`}const ra=typeof window<"u"?g.useLayoutEffect:g.useEffect;function Wc(e){const t=g.useRef(e);return ra(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function $_(...e){return Wc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function z_(e){const t=g.useRef({...e});return ra(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const zP=g.createContext(null);function fG(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:YK});g.useImperativeHandle(t,()=>n.current,[]),ra(()=>{Object.assign(n.current,BP({groupId:e}))})}function F_({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:o,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){const m=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),x=Wc(D=>{Uo(m.current.onLayoutChange,D)||(m.current.onLayoutChange=D,l==null||l(D))}),w=Wc((D,R)=>{Uo(m.current.onLayoutChanged,D)||(m.current.onLayoutChanged=D,c==null||c(D,{isUserInteraction:R}))}),v=B_(a),_=g.useRef(null),[b,S]=hG(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=$_(_,s);fG(v,o);const I=Wc((D,R)=>{const j=Ho(),M=Gk(D),L=Us(D);if(L){let z=!1;switch(j.state){case"active":{z=j.hitRegions.some(F=>F.group===M);break}}return{flexGrow:L.layout[R]??1,pointerEvents:z?"none":void 0}}if(n!=null&&n[R])return{flexGrow:n==null?void 0:n[R]}}),E=z_({defaultLayout:n,disableCursor:r}),A=g.useMemo(()=>({get disableCursor(){return!!E.disableCursor},getPanelStyles:I,id:v,orientation:u,registerPanel:D=>{const R=C.current;return R.panels=Sx(u,[...R.panels,D]),S(),()=>{R.panels=R.panels.filter(j=>j!==D),S()}},registerSeparator:D=>{const R=C.current;return R.separators=Sx(u,[...R.separators,D]),S(),()=>{R.separators=R.separators.filter(j=>j!==D),S()}},updatePanelProps:(D,{disabled:R})=>{const j=C.current.panels.find(z=>z.id===D);j&&(j.panelConstraints.disabled=R);const M=Gk(v),L=Us(v);M&&L&&is(M,{...L,derivedPanelConstraints:wx(M)})},updateSeparatorProps:(D,{disabled:R,disableDoubleClick:j})=>{const M=C.current.separators.find(L=>L.id===D);M&&(M.disabled=R,M.disableDoubleClick=j)}}),[I,v,S,u,E]),P=g.useRef(null);return ra(()=>{const D=_.current;if(D===null)return;const R=C.current;let j;if(E.defaultLayout!==void 0&&Object.keys(E.defaultLayout).length===R.panels.length){j={};for(const N of R.panels){const U=E.defaultLayout[N.id];U!==void 0&&(j[N.id]=U)}}const M={disabled:!!i,element:D,id:v,mutableState:{defaultLayout:j,disableCursor:!!E.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:u,panels:R.panels,resizeTargetMinimumSize:R.resizeTargetMinimumSize,separators:R.separators};P.current=M;const L=dG(M),{defaultLayoutDeferred:z,derivedPanelConstraints:F,layout:$}=Us(M.id,!0);!z&&F.length>0&&(x($),w($,!1));const B=D_(v,N=>{const{defaultLayoutDeferred:U,derivedPanelConstraints:V,layout:O}=N.next;if(U||V.length===0)return;const ne=M.panels.map(({id:Y})=>Y).join(",");M.mutableState.layouts[ne]=O,V.forEach(Y=>{if(Y.collapsible){const{layout:ye}=N.prev??{};if(ye){const Ce=Cn(Y.collapsedSize,O[Y.panelId]),oe=Cn(Y.collapsedSize,ye[Y.panelId]);Ce&&!oe&&(M.mutableState.expandedPanelSizes[Y.panelId]=ye[Y.panelId])}}});const ae=Ho().state!=="active";x(O),ae&&w(O,N.isUserInteraction)});return()=>{P.current=null,L(),B()}},[i,v,w,x,u,b,E]),g.useEffect(()=>{const D=P.current;D&&(D.mutableState.defaultLayout=n,D.mutableState.disableCursor=!!r)}),h.jsx(zP.Provider,{value:A,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":v,id:v,ref:k,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}F_.displayName="Group";function H_(){const e=g.useContext(zP);return ut(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function pG(e,t){const{id:n}=H_(),r=g.useRef({collapse:Dg,expand:Dg,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Dg});g.useImperativeHandle(t,()=>r.current,[]),ra(()=>{Object.assign(r.current,OP({groupId:n,panelId:e}))})}function Yf({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const x=!!l,w=B_(l),v=z_({disabled:s}),_=g.useRef(null),b=$_(_,o),{getPanelStyles:S,id:C,orientation:k,registerPanel:I,updatePanelProps:E}=H_(),A=d!==null,P=Wc((M,L,z)=>{d==null||d(M,l,z)});ra(()=>{const M=_.current;if(M!==null){const L={element:M,id:w,idIsStable:x,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:A?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:v.disabled,maxSize:c,minSize:u}};return I(L)}},[a,n,r,i,A,w,x,c,u,P,I,v]),g.useEffect(()=>{E(w,{disabled:s})},[s,w,E]),pG(w,f);const D=()=>{const M=S(C,w);if(M)return JSON.stringify(M)},R=g.useSyncExternalStore(M=>D_(C,M),D,D);let j;return R?j=JSON.parse(R):i!==void 0?j={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:j={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":w,id:w,ref:b,style:{...mG,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...j},children:h.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...p,touchAction:k==="horizontal"?"pan-y":"pan-x"},children:e})})}Yf.displayName="Panel";const mG={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function gG({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const o=e[n],a=t.find(l=>l.panelId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[r,r+1];s=Wo({layout:Nu({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Wo({layout:Nu({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function FP({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=B_(s),c=z_({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,x]=g.useState(!1),w=g.useRef(null),v=$_(w,i),{disableCursor:_,id:b,orientation:S,registerSeparator:C,updateSeparatorProps:k}=H_(),I=S==="horizontal"?"vertical":"horizontal";ra(()=>{const P=w.current;if(P!==null){const D={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},R=C(D),j=KK(L=>{p(L.next.state!=="inactive"&&L.next.hitRegions.some(z=>z.separator===D)?L.next.state:"inactive")}),M=D_(b,L=>{const{derivedPanelConstraints:z,layout:F,separatorToPanels:$}=L.next,B=$.get(D);if(B){const N=B[0],U=B.indexOf(N);d(gG({layout:F,panelConstraints:z,panelId:N.id,panelIndex:U}))}});return()=>{j(),M(),R()}}},[b,l,C,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let E;n&&!_&&(E="not-allowed");let A;if(n)A="disabled";else switch(f){case"active":{A="active";break}default:m?A="focus":A=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":I,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":A,"data-testid":l,id:l,onBlur:()=>x(!1),onFocus:()=>x(!0),ref:v,role:"separator",style:{flexBasis:"auto",cursor:E,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}FP.displayName="Separator";function vG(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function HP(e,t){const n=as(),r=e?`session/${e}`:"",i=ts(r)??bu,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>YT(f??bu,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function xG(e){return e.kind!=="user-text"?!1:e.meta===void 0||e.meta==="slash-command"||Yp(e.meta)}function yG(e,t={}){let n=0;if(t.implicitCloseOnUserText){for(const r of e)xG(r)&&n++;return n}for(const r of e)r.kind==="turn-end"&&n++;return n}const _G=g.createContext(null);function UP(){return g.useContext(_G)}const bG=50;function wG({api:e,sessionId:t,focused:n=!0,toolSessionId:r,initialTurns:i,implicitCloseOnUserText:s,pageSize:o=bG,enabled:a=!0,refreshVersion:l=0}){const c=UP(),[u,d]=g.useState({messages:[],total:0,loading:!1,error:null}),f=g.useRef(r),p=g.useRef(n),m=g.useRef(null),x=g.useRef(l),w=g.useRef(0),v=g.useRef(!0);return g.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]),g.useEffect(()=>{const _=f.current;f.current=r;const b=n&&!p.current;if(p.current=n,!a){m.current!==null&&(m.current=null,++w.current,d({messages:[],total:0,loading:!1,error:null}));return}const S=m.current!==t,C=x.current!==l;x.current=l;const k=typeof _=="string"&&_!==r,I=b&&u.error!==null;if(_!==r&&(c==null||c.push({level:"info",msg:"chatflow.history.identity",sessionId:t,meta:{previousToolSessionId:_??null,toolSessionId:r??null,willReload:S||k}})),!S&&!k&&!I&&!C)return;if((S||k)&&d({messages:[],total:0,loading:!1,error:null}),!t){m.current=null;return}m.current=t;const E=++w.current;c==null||c.push({level:"info",msg:"chatflow.history.read.start",sessionId:t,meta:{toolSessionId:r??null,initialTurns:i??null,pageSize:i===void 0?null:o,readSeq:E}}),d(A=>({...A,loading:!0,error:null})),(async()=>{var M;let A=[],P=!1,D,R=i===void 0?{}:{limit:o},j=Number.POSITIVE_INFINITY;for(;;){let L;try{L=await e.historyRead({sessionId:t,...R})}catch(V){if(E!==w.current||!v.current)return;const O=V.message??"history load failed";c==null||c.push({level:"warn",msg:"chatflow.history.read.error",sessionId:t,meta:{readSeq:E,shown:P,errorCode:V&&typeof V=="object"&&"code"in V?String(V.code):null}}),d(ne=>({...ne,loading:!1,error:O}));return}if(E!==w.current||!v.current)return;c==null||c.push({level:"info",msg:"chatflow.history.read.result",sessionId:t,meta:{readSeq:E,pageMessages:((M=L.messages)==null?void 0:M.length)??0,total:L.total??0,offset:L.offset??null}}),D&&L.snapshotId&&D!==L.snapshotId&&(A=[],P=!1,j=Number.POSITIVE_INFINITY,d({messages:[],total:0,loading:!0,error:null})),D=L.snapshotId,A=[...L.messages??[],...A];const z=L.total??0,F=typeof L.offset=="number"?L.offset:0,$=F>=j,B=F<=0||$;j=F;const N=i!==void 0&&yG(A,{implicitCloseOnUserText:s})>=i;if(P?d({messages:A,total:z,loading:!1,error:null}):(B||N)&&(P=!0,d({messages:A,total:z,loading:!1,error:null})),B)return;const U=Math.max(0,F-o);R={offset:U,limit:F-U,...D?{snapshotId:D}:{}}}})()},[e,t,r,n,o,i,a,l,c]),u}const SG=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function kG(e){return SG.includes(e)}function WP(e){return e==="in_progress"||e==="completed"?e:"pending"}function CG(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.subject=="string"&&n.subject?n.subject:typeof n.content=="string"&&n.content?n.content:null;if(!r)return e;const i=typeof n.activeForm=="string"?n.activeForm:void 0,s=typeof n.description=="string"?n.description:void 0;return[...e,{id:String(e.length+1),content:r,status:WP(n.status),activeForm:i,description:s}]}function EG(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.taskId=="string"&&n.taskId?n.taskId:typeof n.id=="string"&&n.id?n.id:null;if(!r)return e;const i=e.findIndex(a=>a.id===r);if(i<0)return e;const s=[...e],o={...s[i]};return"status"in n&&(o.status=WP(n.status)),typeof n.subject=="string"&&(o.content=n.subject),typeof n.content=="string"&&(o.content=n.content),typeof n.activeForm=="string"&&(o.activeForm=n.activeForm),typeof n.description=="string"&&(o.description=n.description),s[i]=o,s}function IG(e){let t=[],n=-1;for(let r=0;r<e.length;r++){const i=e[r];if(i.kind==="task-event")switch(n=r,i.name){case"TaskCreate":t=CG(t,i.input);break;case"TaskUpdate":t=EG(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function NG(e){return e==="TodoWrite"}function TG(e){if(!e||typeof e!="object")return null;const t=e;if(!Array.isArray(t.todos))return null;const n=[];for(const r of t.todos){if(!r||typeof r!="object")continue;const i=r,s=typeof i.content=="string"?i.content:"";if(!s)continue;const o=i.status==="in_progress"||i.status==="completed"?i.status:"pending",a=typeof i.activeForm=="string"?i.activeForm:void 0;n.push({content:s,status:o,activeForm:a})}return n}function $h(e,t,n){var o;const r=[],i=new Map;for(let a=0;a<e.length;a++){const l=e[a],c=typeof l.seq=="number"?l.seq:a;switch(l.kind){case"session_init":r.push({kind:"session-init",seq:c,toolSessionId:l.toolSessionId});break;case"text":aC(r,c,"assistant-text",l.text,l.partialId,l.uuid);break;case"thinking":aC(r,c,"assistant-thinking",l.text,l.partialId);break;case"user_text":{l.meta==="task-notification"?r.push({kind:"agent-notification",seq:c,text:l.text,taskId:l.taskId,parentToolUseId:l.parentToolUseId}):l.meta?r.push({kind:"user-meta",seq:c,metaKind:l.meta,text:l.text}):r.push({kind:"user-text",seq:c,text:l.text,uuid:l.uuid,...l.sender&&(l.sender.principal!=="owner"||zT.test(l.text))?{senderDisplayName:l.sender.displayName}:{},senderPrincipal:((o=l.sender)==null?void 0:o.principal)==="guest"?"guest":"owner"});break}case"tool_call":qP(r,c,l.toolUseId,l.tool,l.input,l.toolKind);break;case"tool_result":{const u=i.get(l.toolUseId);if(u!==void 0){if(l.askQuestionAnswers){const f=r[u];f.submittedAnswers=l.askQuestionAnswers}i.delete(l.toolUseId);break}const d={kind:"tool-result",seq:c,toolUseId:l.toolUseId,output:l.output,error:l.error};l.toolResultExtra&&(d.toolResultExtra=l.toolResultExtra),r.push(d);break}case"attachment_memories":r.push({kind:"memory-callout",seq:c,memories:l.memories});break;case"permission_request":{if(!t||l.requestId!==t)break;r.push({kind:"permission-inline",seq:c,requestId:l.requestId,tool:l.tool,input:l.input});break}case"ask_user_question":i.set(l.toolUseId,r.length),r.push({kind:"question-card",seq:c,toolUseId:l.toolUseId,questions:l.questions});break;case"turn_end":{const u={kind:"turn-end",seq:c};l.durationMs!==void 0&&(u.durationMs=l.durationMs),l.reason!==void 0&&(u.reason=l.reason),l.turnId!==void 0&&(u.turnId=l.turnId),r.push(u);break}case"subagent_progress":{const u={kind:"agent-progress",seq:c,toolUseId:l.toolUseId,agentId:l.agentId,status:l.status};l.description&&(u.description=l.description),l.lastToolName&&(u.lastToolName=l.lastToolName),l.prompt&&(u.prompt=l.prompt),l.stats&&(u.stats=l.stats),r.push(u);break}case"error":r.push({kind:"error",seq:c,message:l.message});break}}const s=new Map(e.flatMap((a,l)=>a.turnId?[[a.seq??l,a.turnId]]:[]));for(const a of r){const l=s.get(a.seq);l&&(a.turnId=l)}return r}function qP(e,t,n,r,i,s){if(NG(r)){const o=TG(i);if(o){e.push({kind:"todo-checklist",seq:t,toolUseId:n,todos:o});return}}if(r==="Agent"){const o=i??{},a=typeof o.description=="string"&&o.description?o.description:typeof o.subagent_type=="string"&&o.subagent_type?o.subagent_type:"Subagent";e.push({kind:"agent-call",seq:t,toolUseId:n,description:a,input:i});return}if(kG(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function aC(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const PG="AskUserQuestion";function U_(e,t=0,n){var o;const r=[],i=new Map;let s=t;for(const a of e){const l=s++,c=a.toolUseId??`hist-${l}`;switch(a.kind){case"user-text":if(a.meta==="task-notification")r.push({kind:"agent-notification",seq:l,text:a.text??"",taskId:a.taskId,parentToolUseId:a.parentToolUseId});else if(a.meta)r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text??""});else{const u=zT.exec(a.text??""),d=(o=F$.exec(a.text??""))==null?void 0:o[1],f=(u==null?void 0:u[2])??d,p=(u==null?void 0:u[1])==="guest"||d?"guest":"owner";r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...f?{senderDisplayName:f}:{},senderPrincipal:p})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===PG){const u=a.input??{},d=Array.isArray(u.questions)?u.questions:[];i.set(c,r.length),r.push({kind:"question-card",seq:l,toolUseId:c,questions:d});break}qP(r,l,c,a.tool??"",a.input,n);break}case"tool_result":{const u=i.get(c);if(u!==void 0){if(a.askQuestionAnswers){const f=r[u];f.submittedAnswers=a.askQuestionAnswers}i.delete(c);break}const d={kind:"tool-result",seq:l,toolUseId:c,output:a.output};a.error!==void 0&&(d.error=a.error),a.toolResultExtra&&(d.toolResultExtra=a.toolResultExtra),r.push(d);break}case"attachment_memories":a.memories&&a.memories.length>0&&r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"summary":break;case"turn-end":{const u={kind:"turn-end",seq:l};typeof a.durationMs=="number"&&(u.durationMs=a.durationMs),typeof a.turnId=="string"&&(u.turnId=a.turnId),r.push(u);break}}}return r}const RG=5e5;function AG(e){const t=RG-e.length;return e.map(n=>({...n,seq:n.seq+t}))}const lC=/\[attachment:(image|file):([^\]]+)\]/g;function cC(e){try{return decodeURIComponent(e)}catch{return e}}function MG(e){var n,r;if(e.startsWith("data:")){const i=e.slice(5,e.indexOf(",")),s=(n=/;name=([^;]+)/i.exec(i))==null?void 0:n[1];if(s)return cC(s);const o=(r=i.split(";")[0])==null?void 0:r.toLowerCase(),a={"text/plain":"txt","application/pdf":"pdf","image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp"}[o??""];return(o!=null&&o.startsWith("image/")?"图片":"附件")+(a?"."+a:"")}const t=e.split(/[?#]/,1)[0];return cC(t.split("/").pop()||"附件")}function Xf(e){const t=[];let n;for(;(n=lC.exec(e))!==null;){const i=n[2],s=MG(i);t.push({type:n[1],url:i,fileName:s})}const r=e.replace(lC,"").trim();return{attachments:t,text:r}}function jG(e,t){const n=t.filter(i=>i.status==="done"&&i.url);return n.length===0?e:n.map(i=>`[attachment:${i.mimeType.startsWith("image/")?"image":"file"}:${i.url}]`).join(`
|
|
541
|
+
`)},Aq=0,ma=[];function Mq(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(Aq++)[0],s=g.useState(f3)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var x=eq([e.lockRef.current],(e.shards||[]).map(Ok),!0).filter(Boolean);return x.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),x.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(x,w){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!o.current.allowPinchZoom;var v=Xd(x),_=n.current,b="deltaX"in x?x.deltaX:_[0]-v[0],S="deltaY"in x?x.deltaY:_[1]-v[1],C,k=x.target,I=Math.abs(b)>Math.abs(S)?"h":"v";if("touches"in x&&I==="h"&&k.type==="range")return!1;var E=window.getSelection(),A=E&&E.anchorNode,P=A?A===k||A.contains(k):!1;if(P)return!1;var D=Lk(I,k);if(!D)return!0;if(D?C=I:(C=I==="v"?"h":"v",D=Lk(I,k)),!D)return!1;if(!r.current&&"changedTouches"in x&&(b||S)&&(r.current=C),!C)return!0;var R=r.current||C;return Tq(R,w,x,R==="h"?b:S)},[]),l=g.useCallback(function(x){var w=x;if(!(!ma.length||ma[ma.length-1]!==s)){var v="deltaY"in w?Dk(w):Xd(w),_=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&Pq(C.delta,v)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var b=(o.current.shards||[]).map(Ok).filter(Boolean).filter(function(C){return C.contains(w.target)}),S=b.length>0?a(w,b[0]):!o.current.noIsolation;S&&w.cancelable&&w.preventDefault()}}},[]),c=g.useCallback(function(x,w,v,_){var b={name:x,delta:w,target:v,should:_,shadowParent:jq(v)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(S){return S!==b})},1)},[]),u=g.useCallback(function(x){n.current=Xd(x),r.current=void 0},[]),d=g.useCallback(function(x){c(x.type,Dk(x),x.target,a(x,e.lockRef.current))},[]),f=g.useCallback(function(x){c(x.type,Xd(x),x.target,a(x,e.lockRef.current))},[]);g.useEffect(function(){return ma.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,pa),document.addEventListener("touchmove",l,pa),document.addEventListener("touchstart",u,pa),function(){ma=ma.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,pa),document.removeEventListener("touchmove",l,pa),document.removeEventListener("touchstart",u,pa)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:Rq(i)}):null,p?g.createElement(wq,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function jq(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Lq=cq(h3,Mq);var um=g.forwardRef(function(e,t){return g.createElement(cm,pi({},e,{ref:t,sideCar:Lq}))});um.classNames=cm.classNames;var yx=["Enter"," "],Dq=["ArrowDown","PageUp","Home"],v3=["ArrowUp","PageDown","End"],Oq=[...Dq,...v3],Bq={ltr:[...yx,"ArrowRight"],rtl:[...yx,"ArrowLeft"]},$q={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Yu="Menu",[ku,zq,Fq]=R4(Yu),[ta,x3]=ro(Yu,[Fq,Hl,i3]),Xu=Hl(),y3=i3(),[_3,io]=ta(Yu),[Hq,Zu]=ta(Yu),b3=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Xu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=Ii(s),f=A4(i);return g.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),h.jsx(om,{...a,children:h.jsx(_3,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(Hq,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};b3.displayName=Yu;var Uq="MenuAnchor",y_=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Xu(n);return h.jsx(am,{...i,...r,ref:t})});y_.displayName=Uq;var __="MenuPortal",[Wq,w3]=ta(__,{forceMount:void 0}),S3=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=io(__,t);return h.jsx(Wq,{scope:t,forceMount:n,children:h.jsx(Jr,{present:n||s.open,children:h.jsx(lm,{asChild:!0,container:i,children:r})})})};S3.displayName=__;var Tr="MenuContent",[qq,b_]=ta(Tr),k3=g.forwardRef((e,t)=>{const n=w3(Tr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=io(Tr,e.__scopeMenu),o=Zu(Tr,e.__scopeMenu);return h.jsx(ku.Provider,{scope:e.__scopeMenu,children:h.jsx(Jr,{present:r||s.open,children:h.jsx(ku.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(Vq,{...i,ref:t}):h.jsx(Kq,{...i,ref:t})})})})}),Vq=g.forwardRef((e,t)=>{const n=io(Tr,e.__scopeMenu),r=g.useRef(null),i=Ot(t,r);return g.useEffect(()=>{const s=r.current;if(s)return x_(s)},[]),h.jsx(w_,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Kq=g.forwardRef((e,t)=>{const n=io(Tr,e.__scopeMenu);return h.jsx(w_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Gq=pl("MenuContent.ScrollLock"),w_=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...x}=e,w=io(Tr,n),v=Zu(Tr,n),_=Xu(n),b=y3(n),S=zq(n),[C,k]=g.useState(null),I=g.useRef(null),E=Ot(t,I,w.onContentChange),A=g.useRef(0),P=g.useRef(""),D=g.useRef(0),R=g.useRef(null),j=g.useRef("right"),M=g.useRef(0),L=m?um:g.Fragment,z=m?{as:Gq,allowPinchZoom:!0}:void 0,F=B=>{var ye,Ce;const N=P.current+B,U=S().filter(oe=>!oe.disabled),V=document.activeElement,O=(ye=U.find(oe=>oe.ref.current===V))==null?void 0:ye.textValue,ne=U.map(oe=>oe.textValue),ae=oV(ne,N,O),Y=(Ce=U.find(oe=>oe.textValue===ae))==null?void 0:Ce.ref.current;(function oe(je){P.current=je,window.clearTimeout(A.current),je!==""&&(A.current=window.setTimeout(()=>oe(""),1e3))})(N),Y&&setTimeout(()=>Y.focus())};g.useEffect(()=>()=>window.clearTimeout(A.current),[]),a_();const $=g.useCallback(B=>{var U,V;return j.current===((U=R.current)==null?void 0:U.side)&&lV(B,(V=R.current)==null?void 0:V.area)},[]);return h.jsx(qq,{scope:n,searchRef:P,onItemEnter:g.useCallback(B=>{$(B)&&B.preventDefault()},[$]),onItemLeave:g.useCallback(B=>{var N;$(B)||((N=I.current)==null||N.focus(),k(null))},[$]),onTriggerLeave:g.useCallback(B=>{$(B)&&B.preventDefault()},[$]),pointerGraceTimerRef:D,onPointerGraceIntentChange:g.useCallback(B=>{R.current=B},[]),children:h.jsx(L,{...z,children:h.jsx(tm,{asChild:!0,trapped:i,onMountAutoFocus:Ie(s,B=>{var N;B.preventDefault(),(N=I.current)==null||N.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(Vu,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(YW,{asChild:!0,...b,dir:v.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:Ie(l,B=>{v.isUsingKeyboardRef.current||B.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(g_,{role:"menu","aria-orientation":"vertical","data-state":F3(w.open),"data-radix-menu-content":"",dir:v.dir,..._,...x,ref:E,style:{outline:"none",...x.style},onKeyDown:Ie(x.onKeyDown,B=>{const U=B.target.closest("[data-radix-menu-content]")===B.currentTarget,V=B.ctrlKey||B.altKey||B.metaKey,O=B.key.length===1;U&&(B.key==="Tab"&&B.preventDefault(),!V&&O&&F(B.key));const ne=I.current;if(B.target!==ne||!Oq.includes(B.key))return;B.preventDefault();const Y=S().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);v3.includes(B.key)&&Y.reverse(),iV(Y)}),onBlur:Ie(e.onBlur,B=>{B.currentTarget.contains(B.target)||(window.clearTimeout(A.current),P.current="")}),onPointerMove:Ie(e.onPointerMove,Cu(B=>{const N=B.target,U=M.current!==B.clientX;if(B.currentTarget.contains(N)&&U){const V=B.clientX>M.current?"right":"left";j.current=V,M.current=B.clientX}}))})})})})})})});k3.displayName=Tr;var Yq="MenuGroup",S_=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(wt.div,{role:"group",...r,ref:t})});S_.displayName=Yq;var Xq="MenuLabel",C3=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(wt.div,{...r,ref:t})});C3.displayName=Xq;var Kf="MenuItem",Bk="menu.itemSelect",dm=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Zu(Kf,e.__scopeMenu),a=b_(Kf,e.__scopeMenu),l=Ot(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(Bk,{bubbles:!0,cancelable:!0});d.addEventListener(Bk,p=>r==null?void 0:r(p),{once:!0}),P4(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(E3,{...i,ref:l,disabled:n,onClick:Ie(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Ie(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Ie(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||yx.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});dm.displayName=Kf;var E3=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=b_(Kf,n),a=y3(n),l=g.useRef(null),c=Ot(t,l),[u,d]=g.useState(!1),[f,p]=g.useState("");return g.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(ku.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(XW,{asChild:!0,...a,focusable:!r,children:h.jsx(wt.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Ie(e.onPointerMove,Cu(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ie(e.onPointerLeave,Cu(m=>o.onItemLeave(m))),onFocus:Ie(e.onFocus,()=>d(!0)),onBlur:Ie(e.onBlur,()=>d(!1))})})})}),Zq="MenuCheckboxItem",I3=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(A3,{scope:e.__scopeMenu,checked:n,children:h.jsx(dm,{role:"menuitemcheckbox","aria-checked":Gf(n)?"mixed":n,...i,ref:t,"data-state":E_(n),onSelect:Ie(i.onSelect,()=>r==null?void 0:r(Gf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});I3.displayName=Zq;var N3="MenuRadioGroup",[Qq,Jq]=ta(N3,{value:void 0,onValueChange:()=>{}}),T3=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=Ii(r);return h.jsx(Qq,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(S_,{...i,ref:t})})});T3.displayName=N3;var P3="MenuRadioItem",R3=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=Jq(P3,e.__scopeMenu),s=n===i.value;return h.jsx(A3,{scope:e.__scopeMenu,checked:s,children:h.jsx(dm,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":E_(s),onSelect:Ie(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});R3.displayName=P3;var k_="MenuItemIndicator",[A3,eV]=ta(k_,{checked:!1}),M3=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=eV(k_,n);return h.jsx(Jr,{present:r||Gf(s.checked)||s.checked===!0,children:h.jsx(wt.span,{...i,ref:t,"data-state":E_(s.checked)})})});M3.displayName=k_;var tV="MenuSeparator",j3=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(wt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});j3.displayName=tV;var nV="MenuArrow",L3=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Xu(n);return h.jsx(v_,{...i,...r,ref:t})});L3.displayName=nV;var C_="MenuSub",[rV,D3]=ta(C_),O3=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=io(C_,t),o=Xu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=Ii(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(om,{...o,children:h.jsx(_3,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(rV,{scope:t,contentId:wi(),triggerId:wi(),trigger:a,onTriggerChange:l,children:n})})})};O3.displayName=C_;var kc="MenuSubTrigger",B3=g.forwardRef((e,t)=>{const n=io(kc,e.__scopeMenu),r=Zu(kc,e.__scopeMenu),i=D3(kc,e.__scopeMenu),s=b_(kc,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(y_,{asChild:!0,...c,children:h.jsx(E3,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":F3(n.open),...e,ref:qu(t,i.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ie(e.onPointerMove,Cu(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Ie(e.onPointerLeave,Cu(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const x=(m=n.content)==null?void 0:m.dataset.side,w=x==="right",v=w?-5:5,_=f[w?"left":"right"],b=f[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+v,y:d.clientY},{x:_,y:f.top},{x:b,y:f.top},{x:b,y:f.bottom},{x:_,y:f.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Ie(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||Bq[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});B3.displayName=kc;var $3="MenuSubContent",z3=g.forwardRef((e,t)=>{const n=w3(Tr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=io(Tr,e.__scopeMenu),o=Zu(Tr,e.__scopeMenu),a=D3($3,e.__scopeMenu),l=g.useRef(null),c=Ot(t,l);return h.jsx(ku.Provider,{scope:e.__scopeMenu,children:h.jsx(Jr,{present:r||s.open,children:h.jsx(ku.Slot,{scope:e.__scopeMenu,children:h.jsx(w_,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Ie(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Ie(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Ie(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=$q[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});z3.displayName=$3;function F3(e){return e?"open":"closed"}function Gf(e){return e==="indeterminate"}function E_(e){return Gf(e)?"indeterminate":e?"checked":"unchecked"}function iV(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function sV(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function oV(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=sV(e,Math.max(s,0));i.length===1&&(o=o.filter(c=>c!==n));const l=o.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function aV(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function lV(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return aV(n,t)}function Cu(e){return t=>t.pointerType==="mouse"?e(t):void 0}var cV=b3,uV=y_,dV=S3,hV=k3,fV=S_,pV=C3,mV=dm,gV=I3,vV=T3,xV=R3,yV=M3,_V=j3,bV=L3,wV=O3,SV=B3,kV=z3,hm="DropdownMenu",[CV]=ro(hm,[x3]),Rn=x3(),[EV,H3]=CV(hm),U3=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Rn(t),c=g.useRef(null),[u,d]=$l({prop:i,defaultProp:s??!1,onChange:o,caller:hm});return h.jsx(EV,{scope:t,triggerId:wi(),triggerRef:c,contentId:wi(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(cV,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};U3.displayName=hm;var W3="DropdownMenuTrigger",q3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=H3(W3,n),o=Rn(n);return h.jsx(uV,{asChild:!0,...o,children:h.jsx(wt.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:qu(t,s.triggerRef),onPointerDown:Ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});q3.displayName=W3;var IV="DropdownMenuPortal",V3=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Rn(t);return h.jsx(dV,{...r,...n})};V3.displayName=IV;var K3="DropdownMenuContent",G3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=H3(K3,n),s=Rn(n),o=g.useRef(!1);return h.jsx(hV,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Ie(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Ie(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});G3.displayName=K3;var NV="DropdownMenuGroup",TV=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(fV,{...i,...r,ref:t})});TV.displayName=NV;var PV="DropdownMenuLabel",Y3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(pV,{...i,...r,ref:t})});Y3.displayName=PV;var RV="DropdownMenuItem",X3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(mV,{...i,...r,ref:t})});X3.displayName=RV;var AV="DropdownMenuCheckboxItem",Z3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(gV,{...i,...r,ref:t})});Z3.displayName=AV;var MV="DropdownMenuRadioGroup",jV=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(vV,{...i,...r,ref:t})});jV.displayName=MV;var LV="DropdownMenuRadioItem",DV=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(xV,{...i,...r,ref:t})});DV.displayName=LV;var OV="DropdownMenuItemIndicator",Q3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(yV,{...i,...r,ref:t})});Q3.displayName=OV;var BV="DropdownMenuSeparator",J3=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(_V,{...i,...r,ref:t})});J3.displayName=BV;var $V="DropdownMenuArrow",zV=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(bV,{...i,...r,ref:t})});zV.displayName=$V;var FV=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=Rn(t),[a,l]=$l({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(wV,{...o,open:a,onOpenChange:l,children:n})},HV="DropdownMenuSubTrigger",eP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(SV,{...i,...r,ref:t})});eP.displayName=HV;var UV="DropdownMenuSubContent",tP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Rn(n);return h.jsx(kV,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});tP.displayName=UV;var WV=U3,qV=q3,nP=V3,rP=G3,iP=Y3,sP=X3,oP=Z3,VV=Q3,aP=J3,KV=FV,lP=eP,cP=tP;const uP=WV,dP=qV,I_=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(nP,{children:h.jsx(rP,{ref:r,sideOffset:t,className:re("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));I_.displayName=rP.displayName;const hP=KV,N_=g.forwardRef(({className:e,...t},n)=>h.jsx(lP,{ref:n,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100 data-[state=open]:bg-bg-200","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));N_.displayName=lP.displayName;const T_=g.forwardRef(({className:e,...t},n)=>h.jsx(nP,{children:h.jsx(cP,{ref:n,className:re("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));T_.displayName=cP.displayName;const Wr=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(sP,{ref:r,className:re("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Wr.displayName=sP.displayName;const GV=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(oP,{ref:i,checked:n,className:re("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(VV,{children:h.jsx(Qo,{className:"h-3.5 w-3.5"})})}),t]}));GV.displayName=oP.displayName;const fm=g.forwardRef(({className:e,...t},n)=>h.jsx(aP,{ref:n,className:re("-mx-1 my-1 h-px bg-border",e),...t}));fm.displayName=aP.displayName;const P_=g.forwardRef(({className:e,...t},n)=>h.jsx(iP,{ref:n,className:re("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));P_.displayName=iP.displayName;function YV({tool:e,className:t}){const n=UH(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?s_(e):"未知引擎",className:re("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",em(e),t),children:h.jsx(Jp,{tool:e,className:"w-full h-full"})})}function XV({sessionId:e,hasUnread:t,running:n=!1,awaitingUser:r=!1,style:i}){return r?h.jsx(s7,{"data-testid":`awaiting-dot-${e}`,style:i,className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):t?h.jsx("span",{"data-testid":`unread-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):n?h.jsx("span",{"data-testid":`running-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null}function fP(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function pP(e){return e.key==="Enter"&&!e.shiftKey&&!fP(e)}function Qu(e,t){const n=g.useRef(!1),r=g.useCallback(()=>{n.current=!0},[]),i=g.useCallback(()=>{setTimeout(()=>{n.current=!1},0)},[]);return{onKeyDown:g.useCallback(o=>{const a=o.nativeEvent;if(pP({key:o.key,shiftKey:o.shiftKey,compositionActive:n.current,nativeIsComposing:a.isComposing,keyCode:a.keyCode})){o.preventDefault(),e();return}t&&o.key==="Escape"&&(o.preventDefault(),t())},[e,t]),onCompositionStart:r,onCompositionEnd:i}}function ZV({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i,title:s="Edit session",fieldLabel:o="Label",testId:a="session-edit-dialog",requireNonEmpty:l=!1}){const[c,u]=g.useState(t);g.useEffect(()=>{e&&u(t)},[e,t]);const d=c.trim(),f=l&&d==="",p=()=>{f||r({label:d})},m=Qu(p,i);return e?Oo.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:i,"data-testid":`${a}-overlay`,children:h.jsxs("div",{"data-testid":a,className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:x=>x.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:s}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:o}),h.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:x=>u(x.target.value),...m,placeholder:n,"data-testid":`${a}-label`,className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:i,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:p,disabled:f,"data-testid":`${a}-save`,className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer disabled:cursor-not-allowed disabled:opacity-40",children:"Save"})]})]})}),document.body):null}var QV=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),JV="VisuallyHidden",mP=g.forwardRef((e,t)=>h.jsx(wt.span,{...e,ref:t,style:{...QV,...e.style}}));mP.displayName=JV;var eK=mP,[pm]=ro("Tooltip",[Hl]),mm=Hl(),gP="TooltipProvider",tK=700,_x="tooltip.open",[nK,R_]=pm(gP),vP=e=>{const{__scopeTooltip:t,delayDuration:n=tK,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx(nK,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:g.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};vP.displayName=gP;var Eu="Tooltip",[rK,gm]=pm(Eu),xP=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=R_(Eu,e.__scopeTooltip),c=mm(t),[u,d]=g.useState(null),f=wi(),p=g.useRef(0),m=o??l.disableHoverableContent,x=a??l.delayDuration,w=g.useRef(!1),[v,_]=$l({prop:r,defaultProp:i??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(_x))):l.onClose(),s==null||s(I)},caller:Eu}),b=g.useMemo(()=>v?w.current?"delayed-open":"instant-open":"closed",[v]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w.current=!1,_(!0)},[_]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{w.current=!0,_(!0),p.current=0},x)},[x,_]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(om,{...c,children:h.jsx(rK,{scope:t,contentId:f,open:v,stateAttribute:b,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():S()},[l.isOpenDelayedRef,k,S]),onTriggerLeave:g.useCallback(()=>{m?C():(window.clearTimeout(p.current),p.current=0)},[C,m]),onOpen:S,onClose:C,disableHoverableContent:m,children:n})})};xP.displayName=Eu;var bx="TooltipTrigger",yP=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=gm(bx,n),s=R_(bx,n),o=mm(n),a=g.useRef(null),l=Ot(t,a,i.onTriggerChange),c=g.useRef(!1),u=g.useRef(!1),d=g.useCallback(()=>c.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),h.jsx(am,{asChild:!0,...o,children:h.jsx(wt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Ie(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Ie(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Ie(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Ie(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Ie(e.onBlur,i.onClose),onClick:Ie(e.onClick,i.onClose)})})});yP.displayName=bx;var iK="TooltipPortal",[Ade,sK]=pm(iK,{forceMount:void 0}),gl="TooltipContent",_P=g.forwardRef((e,t)=>{const n=sK(gl,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=gm(gl,e.__scopeTooltip);return h.jsx(Jr,{present:r||o.open,children:o.disableHoverableContent?h.jsx(bP,{side:i,...s,ref:t}):h.jsx(oK,{side:i,...s,ref:t})})}),oK=g.forwardRef((e,t)=>{const n=gm(gl,e.__scopeTooltip),r=R_(gl,e.__scopeTooltip),i=g.useRef(null),s=Ot(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,x)=>{const w=m.currentTarget,v={x:m.clientX,y:m.clientY},_=dK(v,w.getBoundingClientRect()),b=hK(v,_),S=fK(x.getBoundingClientRect()),C=mK([...b,...S]);a(C),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=w=>p(w,u),x=w=>p(w,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",x),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",x)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=x=>{const w=x.target,v={x:x.clientX,y:x.clientY},_=(l==null?void 0:l.contains(w))||(u==null?void 0:u.contains(w)),b=!pK(v,o);_?f():b&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(bP,{...e,ref:s})}),[aK,lK]=pm(Eu,{isInside:!1}),cK=JH("TooltipContent"),bP=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=gm(gl,n),c=mm(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(_x,u),()=>document.removeEventListener(_x,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(Vu,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(g_,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(cK,{children:r}),h.jsx(aK,{scope:n,isInside:!0,children:h.jsx(eK,{id:l.contentId,role:"tooltip",children:i||r})})]})})});_P.displayName=gl;var wP="TooltipArrow",uK=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=mm(n);return lK(wP,n).isInside?null:h.jsx(v_,{...i,...r,ref:t})});uK.displayName=wP;function dK(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function hK(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function fK(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function pK(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function mK(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),gK(t)}function gK(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var vK=vP,xK=xP,yK=yP,SP=_P;const Iu=vK,Ju=xK,ed=yK,Ul=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(SP,{ref:r,sideOffset:t,className:re("z-50 overflow-hidden rounded-sm border border-border bg-bg-0 px-2 py-1 text-xs text-text-300 shadow-md",e),...n}));Ul.displayName=SP.displayName;const _K={held:!1,indexBySessionId:new Map},bK=g.createContext(_K);function wK(){return g.useContext(bK)}const SK=Array.from({length:9},(e,t)=>({id:`switch-session-${t+1}`,combo:{key:String(t+1),mod:!0},label:`切换到第 ${t+1} 个会话`,group:"会话",desktopOnly:!0,hiddenInList:!0})),kK=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},{id:"open-search",combo:{key:"k",mod:!0},label:"全局搜索",description:"搜会话内容 / persona / 联系人",group:"通用",desktopOnly:!0},{id:"search-tab-prev",combo:{key:"ArrowLeft",mod:!0},label:"搜索:上一组",description:"搜索浮层里切到左边那个 tab(会话 / persona / 联系人)",group:"通用"},{id:"search-tab-next",combo:{key:"ArrowRight",mod:!0},label:"搜索:下一组",description:"搜索浮层里切到右边那个 tab",group:"通用"},...SK,{id:"archive-session",combo:{key:"Backspace",mod:!0,shift:!0},label:"归档当前会话",description:"归档当前聊天区的会话,Enter 确认 / Esc 取消",group:"会话",desktopOnly:!0},{id:"tab-prev",combo:{key:"ArrowLeft",mod:!0,shift:!0},label:"上一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"tab-next",combo:{key:"ArrowRight",mod:!0,shift:!0},label:"下一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"toggle-hive",combo:{key:"h",mod:!0,shift:!0},label:"Hive 看板",description:"全屏看所有 agent 在干什么;Esc 或点任意行退出",group:"通用"},{id:"send-message",combo:{key:"Enter"},label:"发送消息",description:"在输入框中发送当前内容",group:"输入",displayOnly:!0},{id:"newline",combo:{key:"Enter",shift:!0},label:"换行",description:"在输入框中插入换行",group:"输入",displayOnly:!0},{id:"interrupt",combo:{key:"Escape"},label:"打断回复",description:"打断当前回复;2 秒内按两次停止任务",group:"输入",displayOnly:!0}];kK.filter(e=>!e.displayOnly);function CK(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const EK=10,IK=20,NK=16,$k=20,zk=60,TK=4;function Zd({testId:e,label:t,children:n}){return h.jsxs(Ju,{children:[h.jsx(ed,{asChild:!0,children:h.jsx("span",{"data-testid":e,role:"img","aria-label":t,tabIndex:0,className:"inline-flex shrink-0",children:n})}),h.jsx(Ul,{side:"bottom",children:t})]})}function PK({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,quickAction:u,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m,ownerPrincipalId:x,creatorDisplayName:w,dispatchedFromSessionTitle:v}){const[_,b]=g.useState(!1),S=wK(),C=S.held?S.indexBySessionId.get(e.sessionId):void 0,k=!!e.pinnedAt,I=d===0,E=d===0&&!!c,A=EK+d*IK;let P=null;u==="pin"&&I&&l?P={icon:k?h.jsx(rk,{className:"w-4 h-4"}):h.jsx(ik,{className:"w-4 h-4"}),label:k?"取消置顶":"置顶",run:()=>l(e.sessionId,!k)}:u==="archive"&&E&&c?P={icon:h.jsx(ek,{className:"w-4 h-4"}),label:"归档",run:()=>c(e.sessionId,!0)}:u==="rename"&&o&&(P={icon:h.jsx(ux,{className:"w-4 h-4"}),label:"重命名",run:()=>b(!0)});const D=g.useCallback(async()=>{const z=N4(e);if(z)try{await navigator.clipboard.writeText(z)}catch{}},[e]),R=o_(e),j=e.originOwnerPrincipalId,M=j?`@${m??`…${j.slice(-8)}`}`:null,L=!!(e.ownerPersonaId&&x&&e.creatorPrincipalId&&e.creatorPrincipalId!==x&&!e.larkChatId&&!e.shiftFiredFromSessionId&&!e.dispatchedFromSessionId);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:A,display:"grid",gridTemplateColumns:f?`${NK}px ${$k}px 1fr auto ${zk}px`:`${$k}px 1fr auto ${zk}px`,gridTemplateAreas:f?'"chev icon name dot time"':'"icon name dot time"',columnGap:`${TK}px`,alignItems:"center"},className:re("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:f??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(YV,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[h.jsxs(Iu,{delayDuration:200,skipDelayDuration:100,children:[e.dispatchedFromSessionId?h.jsx(Zd,{testId:`dispatched-icon-${e.sessionId}`,label:`来自【${v??"另一会话"}】dispatch`,children:h.jsx(P7,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.shiftFiredFromSessionId?h.jsx(Zd,{testId:`shift-fired-icon-${e.sessionId}`,label:"定时任务",children:h.jsx(Zz,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.larkChatId?h.jsx(Zd,{testId:`lark-chat-icon-${e.sessionId}`,label:e.larkChatType==="p2p"?"来自飞书DM":"来自飞书群",children:h.jsx(uF,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,L?h.jsx(Zd,{testId:`guest-created-icon-${e.sessionId}`,label:w?`${w}创建`:"其他人创建",children:h.jsx(VF,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null]}),h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:re("text-[13px] truncate min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-words",t?"text-text-100 font-medium":"text-text-200"),children:R}),M?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${M.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:M}):null]}),h.jsx(XV,{sessionId:e.sessionId,hasUnread:n,running:r,awaitingUser:i,style:{gridArea:"dot"}}),C!=null?h.jsx("span",{style:{gridArea:"time"},"data-testid":`session-quick-switch-badge-${e.sessionId}`,className:"text-right shrink-0 transition-opacity duration-150 group-hover:opacity-0",children:h.jsx("span",{className:"inline-flex items-center justify-center h-[18px] px-1.5 rounded-[5px] border border-border bg-bg-200/70 text-[11px] text-text-200 font-medium leading-none",children:CK()?`⌘${C}`:`Ctrl+${C}`})}):h.jsx("span",{style:{gridArea:"time"},className:re("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?WH(e.updatedAt):""}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-[3px] flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[P?h.jsx(Iu,{delayDuration:200,skipDelayDuration:100,children:h.jsxs(Ju,{children:[h.jsx(ed,{asChild:!0,children:h.jsx("button",{type:"button",onClick:z=>{z.stopPropagation(),P.run()},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":P.label,"data-testid":`quick-action-${u}-${e.sessionId}`,children:P.icon})}),h.jsx(Ul,{side:"bottom",children:P.label})]})}):null,h.jsxs(uP,{modal:!1,children:[h.jsx(dP,{asChild:!0,children:h.jsx("button",{type:"button",onClick:z=>z.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(r4,{className:"w-4 h-4"})})}),h.jsxs(I_,{align:"end",onClick:z=>z.stopPropagation(),children:[l&&I&&h.jsxs(Wr,{onSelect:()=>l(e.sessionId,!k),"data-testid":`session-${k?"unpin":"pin"}-${e.sessionId}`,children:[k?h.jsx(rk,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(ik,{className:"w-3 h-3 mr-2 text-text-400"}),k?"Unpin":"Pin"]}),E&&c&&h.jsxs(Wr,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(ek,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(Wr,{onSelect:()=>b(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(ux,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(Wr,{onSelect:()=>void D(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(Jy,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(fm,{}),a&&h.jsxs(Wr,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(n_,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(ZV,{open:_,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:z=>{o(e.sessionId,z),b(!1)},onCancel:()=>b(!1)}):null]})}function A_({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:x,getSessionDisplayName:w,parentSession:v}){const _=e.children.length>0,{isCollapsed:b,toggle:S}=Wz(),C=!b(e.session.sessionId),k=g.useCallback(E=>{E.stopPropagation(),S(e.session.sessionId)},[S,e.session.sessionId]),I=_?h.jsx("button",{type:"button",onClick:k,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":C?"collapse":"expand","aria-expanded":C,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:C?h.jsx(Pn,{className:"w-3 h-3"}):h.jsx(Fn,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(PK,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,showCopyResume:p,ownerPrincipalId:m,creatorDisplayName:e.session.creatorPrincipalId?x==null?void 0:x(e.session.creatorPrincipalId):void 0,dispatchedFromSessionTitle:e.session.dispatchedFromSessionId?(w==null?void 0:w(e.session.dispatchedFromSessionId))??((v==null?void 0:v.sessionId)===e.session.dispatchedFromSessionId?o_(v):void 0):void 0,depth:t,chevron:I,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),_&&C?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(E=>h.jsx(A_,{node:E,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:x,getSessionDisplayName:w,parentSession:e.session},E.session.sessionId))}):null]})}function RK(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function M_(e,t){return e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function kP(e){e=e.filter(s=>!s.ephemeral&&s.deployId===void 0&&s.testReleaseId===void 0);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=RK(s);if(o&&t.has(o)){const a=n.get(o)??[];a.push(s),n.set(o,a)}else r.push(s)}const i=s=>{const a=[...n.get(s.sessionId)??[]].sort(M_);return{session:s,children:a.map(i)}};return[...r].sort(AK).map(i)}function CP(e){return[...e].sort((t,n)=>M_(t.session,n.session))}function AK(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r?1:M_(e,t)}function MK(e){return e.label?e.label:e.aiLabel?e.aiLabel:e.cwd.split("/").filter(Boolean).pop()??""}function Fk(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const jK={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function LK({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:x,onPinSession:w,showCopyResume:v,treatSessionsAsRoots:_,searchQuery:b}){const[S,C]=g.useState(null),[k,I]=g.useState(()=>new Set),E=p??(L=>k.has(L)),A=g.useCallback(L=>{if(m){m(L);return}I(z=>{const F=new Set(z);return F.has(L)?F.delete(L):F.add(L),F})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(L=>!L.ephemeral),[i]),D=g.useMemo(()=>new Map((P??[]).map(L=>[L.sessionId,o_(L)])),[P]),R=g.useCallback(L=>f==null?void 0:f.get(L),[f]),j=g.useCallback(L=>D.get(L),[D]);if(e.length===0)return h.jsx(DK,{});const M=(b??"").trim();return M?h.jsx(Zy.Provider,{value:jK,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const z=P?P.filter(N=>N.ownerPersonaId===L.personaId).sort((N,U)=>U.updatedAt>N.updatedAt?1:-1):[],F=Fk(L.label,M),$=z.filter(N=>Fk(MK(N),M));if(!F&&$.length===0)return null;const B=F?z:$;return h.jsx(Hk,{persona:L,active:L.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:B,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:x,onPinSession:w,showCopyResume:v,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:j},L.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const z=P?P.filter(F=>F.ownerPersonaId===L.personaId).sort((F,$)=>$.updatedAt>F.updatedAt?1:-1):[];return h.jsx(Hk,{persona:L,active:L.personaId===t,editing:L.personaId===S,onSelectPersona:n,onStartCreateSession:r?()=>C(L.personaId):void 0,onSubmitCreateSession:F=>{C(null),r==null||r(L.personaId,F)},onCancelCreateSession:()=>C(null),personaSessions:z,collapsed:!E(L.personaId),onToggleCollapsed:()=>A(L.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:x,onPinSession:w,showCopyResume:v,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:j},L.personaId)})})}function DK(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function Hk({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:x,onEditSession:w,onPinSession:v,showCopyResume:_,treatSessionsAsRoots:b,ownerPrincipalId:S,creatorDisplayNameByOwnerId:C,getCreatorDisplayName:k,getSessionDisplayName:I}){const E=a.length>0,A=!l,P=g.useMemo(()=>{const j=[],M=new Map;for(const L of a){const z=L.creatorPrincipalId;if(L.larkChatId!=null||!z||S&&z===S){j.push(L);continue}const F=z,$=(C==null?void 0:C.get(F))??`…${F.slice(-8)}`,B=M.get(F);B?B.sessions.push(L):M.set(F,{groupKey:F,displayName:$,sessions:[L]})}return{self:j,byPeer:[...M.values()]}},[a,S,C]),D=P.byPeer.length>0,R=g.useMemo(()=>A&&!D?CP(kP(a)):[],[A,D,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:re("group flex items-center gap-1 px-2 py-1.5 cursor-pointer",t?"bg-accent-dim text-text-100":"hover:bg-bg-200 text-text-200"),onClick:()=>r==null?void 0:r(e.personaId),role:"button",tabIndex:0,children:[E?h.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),c()},"aria-label":A?"collapse":"expand","aria-expanded":A,"data-testid":`persona-chevron-${e.personaId}`,className:"flex h-4 w-4 shrink-0 items-center justify-center text-text-400 hover:text-text-100",children:A?h.jsx(Pn,{className:"h-3 w-3"}):h.jsx(Fn,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(Jp,{tool:e.tool,className:re("h-3.5 w-3.5 shrink-0",em(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),E?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),i()},"aria-label":"新建会话",title:"新建会话","data-testid":`persona-create-session-${e.personaId}`,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-text-400 opacity-0 hover:bg-text-100/10 hover:text-text-100 focus-visible:opacity-100 group-hover:opacity-100",children:h.jsx(e_,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(OK,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,E&&A?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:D?h.jsxs(h.Fragment,{children:[P.self.length>0&&h.jsx(Uk,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:P.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:x,onEditSession:w,onPinSession:v,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:I}),P.byPeer.map(j=>h.jsx(Uk,{groupKey:`${e.personaId}-peer-${j.groupKey}`,label:j.displayName,testId:`persona-sessions-${e.personaId}-peer-${j.groupKey}`,sessions:j.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:x,onEditSession:w,onPinSession:v,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:I},`${e.personaId}-peer-${j.groupKey}`))]}):R.map(j=>h.jsx(A_,{node:j,depth:b?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:M=>m==null?void 0:m(M),onDelete:x,onEdit:w,onPin:v,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:I},j.session.sessionId))}):null]})}function Uk({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m}){const[x,w]=g.useState(!1),v=!x,_=g.useMemo(()=>v?CP(kP(n)):[],[v,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>w(b=>!b),"aria-label":v?"collapse":"expand","aria-expanded":v,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[v?h.jsx(Pn,{className:"h-3 w-3"}):h.jsx(Fn,{className:"h-3 w-3"}),h.jsx(u4,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),v&&h.jsx("div",{children:_.map(b=>h.jsx(A_,{node:b,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:S=>a==null?void 0:a(S),onDelete:l,onEdit:c,onPin:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m},b.session.sessionId))})]})}function OK({personaId:e,tool:t,onSubmit:n,onCancel:r}){const[i,s]=g.useState(""),o=g.useRef(null),a=i.trim(),l=a.length>0;g.useEffect(()=>{var d;(d=o.current)==null||d.focus()},[]);const c=g.useCallback(()=>{l&&n(a)},[l,a,n]),u=Qu(c,r);return h.jsxs("div",{className:"flex items-center gap-1.5 pl-9 pr-2 py-1","data-testid":`persona-new-session-row-${e}`,children:[h.jsx(Jp,{tool:t,className:re("h-3 w-3 shrink-0",em(t))}),h.jsx("input",{ref:o,type:"text",value:i,onChange:d=>s(d.target.value),...u,onBlur:r,placeholder:"session label...","data-testid":`persona-new-session-input-${e}`,className:"flex-1 min-w-0 bg-bg-100 border border-text-100/15 rounded px-1.5 py-0.5 text-[12px] text-text-100 placeholder:text-text-400 focus:outline-none focus:border-text-100/40"}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),c()},disabled:!l,"aria-label":"确认",title:"确认(Enter)","data-testid":`persona-new-session-confirm-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-300",children:h.jsx(Qo,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),r()},"aria-label":"取消",title:"取消(Esc)","data-testid":`persona-new-session-cancel-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100",children:h.jsx(Qr,{className:"h-3 w-3"})})]})}function BK(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function $K(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function zK(e){return e/100*window.innerHeight}function FK(e){return e/100*window.innerWidth}function HK(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Cc({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=HK(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=$K(t,i);break}case"em":{r=BK(t,i);break}case"vh":{r=zK(i);break}case"vw":{r=FK(i);break}}return r}function Dn(e){return parseFloat(e.toFixed(3))}function vl({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function wx(e){const{panels:t}=e,n=vl({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let o=0;if(s.collapsedSize!==void 0){const u=Cc({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=Dn(u/n*100)}let a;if(s.defaultSize!==void 0){const u=Cc({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=Dn(u/n*100)}let l=0;if(s.minSize!==void 0){const u=Cc({groupSize:n,panelElement:i,styleProp:s.minSize});l=Dn(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=Cc({groupSize:n,panelElement:i,styleProp:s.maxSize});c=Dn(u/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:o,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:l,maxSize:c,panelId:r.id}})}function ut(e,t="Assertion error"){if(!e)throw Error(t)}function Sx(e,t){return Array.from(t).sort(e==="horizontal"?UK:WK)}function UK(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function WK(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function EP(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function IP(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function qK({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const o of t){const{x:a,y:l}=IP(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return ut(i,"No rect found"),i}let Qd;function VK(){return Qd===void 0&&(typeof matchMedia=="function"?Qd=!!matchMedia("(pointer:coarse)").matches:Qd=!1),Qd}function NP(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=Sx(n,Array.from(t.children).filter(EP).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const x of s)x.hasAttribute("data-panel")&&(m++,x.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const x of s)if(x.hasAttribute("data-panel")){m++;const w=r.find(v=>v.element===x);if(w){if(f){const v=f.element.getBoundingClientRect(),_=x.getBoundingClientRect();let b;if(l){const S=n==="horizontal"?new DOMRect(v.right,v.top,0,v.height):new DOMRect(v.left,v.bottom,v.width,0),C=n==="horizontal"?new DOMRect(_.left,_.top,0,_.height):new DOMRect(_.left,_.top,_.width,0);switch(p.length){case 0:{b=[S,C];break}case 1:{const k=p[0],I=qK({orientation:n,rects:[v,_],targetRect:k.element.getBoundingClientRect()});b=[k,I===v?C:S];break}default:{b=p;break}}}else p.length?b=p:b=[n==="horizontal"?new DOMRect(v.right,_.top,_.left-v.right,_.height):new DOMRect(_.left,v.bottom,_.width,_.top-v.bottom)];for(const S of b){let C="width"in S?S:S.element.getBoundingClientRect();const k=VK()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<k){const E=k-C.width;C=new DOMRect(C.x-E/2,C.y,C.width+E,C.height)}if(C.height<k){const E=k-C.height;C=new DOMRect(C.x,C.y-E/2,C.width,C.height+E)}const I=m<=c||m>u;!a&&!I&&o.push({group:e,groupSize:vl({group:e}),panels:[f,w],separator:"width"in S?void 0:S,rect:C}),a=!1}}l=!1,f=w,p=[]}}else if(x.hasAttribute("data-separator")){x.ariaDisabled!==null&&(a=!0);const w=i.find(v=>v.element===x);w?p.push(w):(f=void 0,p=[])}else l=!0}return o}var Ts;class TP{constructor(){Ob(this,Ts,{})}addListener(t,n){const r=Ql(this,Ts)[t];return r===void 0?Ql(this,Ts)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=Ql(this,Ts)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const o=Array.from(r);for(let a=0;a<o.length;a++){const l=o[a];try{l.call(null,n)}catch(c){s===null&&(i=!0,s=c)}}if(i)throw s}}removeAllListeners(){Bb(this,Ts,{})}removeListener(t,n){const r=Ql(this,Ts)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}Ts=new WeakMap;let Xa={cursorFlags:0,state:"inactive"};const j_=new TP;function Ho(){return Xa}function KK(e){return j_.addListener("change",e)}function GK(e){const t=Xa,n={...Xa};n.cursorFlags=e,Xa=n,j_.emit("change",{prev:t,next:n})}function Za(e){const t=Xa;Xa=e,j_.emit("change",{prev:t,next:e})}const YK=e=>e,Dg=()=>{},PP=1,RP=2,AP=4,MP=8,Wk=3,qk=12;let Jd;function Vk(){return Jd===void 0&&(Jd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Jd=!0)),Jd}function XK({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&Vk()){const s=(e&PP)!==0,o=(e&RP)!==0,a=(e&AP)!==0,l=(e&MP)!==0;if(s)return a?"se-resize":l?"ne-resize":"e-resize";if(o)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return Vk()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const Kk=new WeakMap;function L_(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Kk.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=Ho();switch(r.state){case"active":case"hover":{const i=XK({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}Kk.set(e,{prevStyle:t,styleSheet:n})}let gi=new Map;const jP=new TP;function ZK(e){gi=new Map(gi),gi.delete(e)}function Gk(e,t){for(const[n]of gi)if(n.id===e)return n}function Us(e,t){for(const[n,r]of gi)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function na(){return gi}function D_(e,t){return jP.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function is(e,t,n){const r=gi.get(e);gi=new Map(gi),gi.set(e,t),jP.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function LP(e){const t=Ho();let n=!1;switch(t.state){case"active":Za({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(L_(e),n=!0,t.hitRegions.forEach(r=>{const i=Us(r.group.id,!0);is(r.group,i,{isUserInteraction:!0})}))}return n}function Yk(e){e.defaultPrevented||LP(e.currentTarget)}function QK(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=IP(n,s.rect);switch(e){case"horizontal":{o.x<=i.x&&(r=s,i=o);break}case"vertical":{o.y<=i.y&&(r=s,i=o);break}}}return r?{distance:i,hitRegion:r}:void 0}function JK(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function eG(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Qk(e),b:Qk(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();ut(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Zk(Xk(n.a)),b:Zk(Xk(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const tG=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function nG(e){const t=getComputedStyle(DP(e)??e).display;return t==="flex"||t==="inline-flex"}function rG(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||nG(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||tG.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Xk(e){let t=e.length;for(;t--;){const n=e[t];if(ut(n,"Missing node"),rG(n))return n}return null}function Zk(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Qk(e){const t=[];for(;e;)t.push(e),e=DP(e);return t}function DP(e){const{parentNode:t}=e;return JK(t)?t.host:t}function iG(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function sG({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!EP(n)||n.contains(e)||e.contains(n))return!0;if(eG(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(iG(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function O_(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=NP(i),o=QK(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&sG({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function oG(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Cn(e,t,n=0){return Math.abs(Dn(e)-Dn(t))<=n}function hi(e,t){return Cn(e,t)?0:e>t?1:-1}function Ba({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:o,maxSize:a=100,minSize:l=0}=t;if(o&&!e)return n;if(hi(r,l)<0)if(s){const c=(i+l)/2;hi(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=Dn(r),r}function Nu({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(Cn(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;ut(u!=null,"Invalid first pivot index"),ut(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const x=e<0?d:u,w=n[x];ut(w,`Panel constraints not found for index ${x}`);const{collapsedSize:v=0,collapsible:_,minSize:b=0}=w;if(_){const S=a[x];if(ut(S!=null,`Previous layout not found for panel index ${x}`),Cn(S,v)){const C=b-S;hi(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const x=e<0?u:d,w=n[x];ut(w,`No panel constraints found for index ${x}`);const{collapsedSize:v=0,collapsible:_,minSize:b=0}=w;if(_){const S=a[x];if(ut(S!=null,`Previous layout not found for panel index ${x}`),Cn(S,b)){const C=S-v;hi(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const x=e<0?d:u,w=n[x];ut(w,`Panel constraints not found for index ${x}`);const v=a[x],{collapsible:_,collapsedSize:b,minSize:S}=w;if(_&&hi(v,S)<0)if(e>0){const C=S-b,k=C/2,I=v+e;hi(I,S)<0&&(e=hi(e,k)<=0?0:C)}else{const C=S-b,k=100-C/2,I=v-e;hi(I,S)<0&&(e=hi(100+e,k)>0?0:-C)}break}}{const x=e<0?1:-1;let w=e<0?d:u,v=0;for(;;){const b=a[w];ut(b!=null,`Previous layout not found for panel index ${w}`);const S=Ba({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:b,size:100})-b;if(v+=S,w+=x,w<0||w>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-_:_}{let x=e<0?u:d;for(;x>=0&&x<n.length;){const w=Math.abs(e)-Math.abs(f),v=a[x];ut(v!=null,`Previous layout not found for panel index ${x}`);const _=v-w,b=Ba({overrideDisabledPanels:o,panelConstraints:n[x],prevSize:v,size:_});if(!Cn(v,b)&&(f+=v-b,c[x]=b,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?x--:x++}}if(oG(l,c))return i;{const x=e<0?d:u,w=a[x];ut(w!=null,`Previous layout not found for panel index ${x}`);const v=w+f,_=Ba({overrideDisabledPanels:o,panelConstraints:n[x],prevSize:w,size:v});if(c[x]=_,!Cn(_,v)){let b=v-_,S=e<0?d:u;for(;S>=0&&S<n.length;){const C=c[S];ut(C!=null,`Previous layout not found for panel index ${S}`);const k=C+b,I=Ba({overrideDisabledPanels:o,panelConstraints:n[S],prevSize:C,size:k});if(Cn(C,I)||(b-=I-C,c[S]=I),Cn(b,0))break;e>0?S--:S++}}}const p=Object.values(c).reduce((x,w)=>w+x,0);if(!Cn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((x,w,v)=>(x[m[v]]=w,x),{})}function Uo(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||hi(e[n],t[n])!==0)return!1;return!0}function Wo({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!Cn(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];ut(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];ut(l!=null,`No layout data found for index ${a}`);const c=r[a];ut(c!=null,`No layout data found for index ${a}`);const u=Ba({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!Cn(s,0))for(let a=0;a<t.length;a++){const l=r[a];ut(l!=null,`No layout data found for index ${a}`);const c=l+s,u=Ba({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,Cn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function OP({groupId:e,panelId:t}){const n=()=>{const l=na();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(w=>w.id===t),m=p===0,x=p===c.length-1;if(x&&l<f&&(m||c.slice(0,p).every((w,v)=>{const _=d[v];return(_==null?void 0:_.collapsible)&&Cn(_.collapsedSize,u[_.panelId])}))){const w=c.slice(0,p).reduce((v,_)=>v+u[_.id],0);return{...u,[t]:Dn(100-w)}}return Nu({delta:x?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:x?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:x}=n(),w=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),v=Wo({layout:w,panelConstraints:d});Uo(m,v)||is(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:v,separatorToPanels:x})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&Cn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=vl({group:c}),f=Cc({groupSize:d,panelElement:u,styleProp:l}),p=Dn(f/d*100);a(p)}}}function Jk(e){if(e.defaultPrevented)return;const t=na();O_(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const r=n.panels.find(i=>i.panelConstraints.defaultSize!==void 0);if(r){const i=r.panelConstraints.defaultSize,s=OP({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function Bh(e){const t=na();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function BP({groupId:e}){const t=()=>{const n=na();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:o,layout:a,separatorToPanels:l}=t(),c=Wo({layout:n,panelConstraints:i});return r?a:(Uo(a,c)||is(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function po(e,t){const n=Bh(e),r=Us(n.id,!0),i=n.separators.find(u=>u.element===e);ut(i,"Matching separator not found");const s=r.separatorToPanels.get(i);ut(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=BP({groupId:n.id}).getLayout(),l=Nu({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=Wo({layout:l,panelConstraints:r.derivedPanelConstraints});Uo(a,c)||is(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function eC(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Bh(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&po(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&po(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&po(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&po(t,-5);break}case"End":{e.preventDefault(),po(t,100);break}case"Enter":{e.preventDefault();const r=Bh(t),i=Us(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);ut(l,"Matching separator not found");const c=a.get(l);ut(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(ut(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;po(t,p-f)}break}case"F6":{e.preventDefault();const r=Bh(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);ut(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),po(t,-100);break}}}function tC(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=na(),n=O_(e,t),r=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const o=t.get(s.group);o&&r.set(s.group,o.layout)}),Za({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function $P({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let x=0;s?f==="horizontal"?x=(t.clientX-s.x)/d*100:x=(t.clientY-s.y)/d*100:f==="horizontal"?x=t.clientX<0?-100:100:x=t.clientY<0?-100:100;const w=r.get(u),v=i.get(u);if(!w||!v)return;const{defaultLayoutDeferred:_,derivedPanelConstraints:b,groupSize:S,layout:C,separatorToPanels:k}=v;if(b&&C&&k){const I=Nu({delta:x,initialLayout:w,panelConstraints:b,pivotIndices:c.panels.map(E=>p.indexOf(E)),prevLayout:C,trigger:"mouse-or-touch"});if(Uo(I,C)){if(x!==0&&!m)switch(f){case"horizontal":{a|=x<0?PP:RP;break}case"vertical":{a|=x<0?AP:MP;break}}}else is(c.group,{defaultLayoutDeferred:_,derivedPanelConstraints:b,groupSize:S,layout:I,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&Wk:l|=a&Wk,t.movementY===0?l|=o&qk:l|=a&qk,GK(l),L_(e)}function nC(e){const t=na(),n=Ho();switch(n.state){case"active":$P({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function rC(e){var r,i;if(e.defaultPrevented)return;const t=Ho(),n=na();switch(t.state){case"active":{if(e.buttons===0){Za({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=Us(s.group.id,!0);is(s.group,o,{isUserInteraction:!0})});return}for(const s of t.hitRegions)if(s.separator){const{element:o}=s.separator;(r=o.hasPointerCapture)!=null&&r.call(o,e.pointerId)||((i=o.setPointerCapture)==null||i.call(o,e.pointerId))}$P({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=O_(e,n);s.length===0?t.state!=="inactive"&&Za({cursorFlags:0,state:"inactive"}):Za({cursorFlags:0,hitRegions:s,state:"hover"}),L_(e.currentTarget);break}}}function iC(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Ho().state){case"hover":Za({cursorFlags:0,state:"inactive"})}}function sC(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||LP(e.currentTarget)&&e.preventDefault()}function oC(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=Dn(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Dn((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function aG(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=vl({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:Dn(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function lG(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function cG({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,s=0,o=!1;const a=new Map,l=[];for(const d of e.panels){const f=r[d.id]??0;switch(d.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{o=!0;const p=f/100*n,m=Dn(p/t*100);a.set(d.id,m),i+=m;break}case"preserve-relative-size":default:{l.push(d.id),s+=f;break}}}if(!o||l.length===0)return r;const c=100-i,u={...r};if(a.forEach((d,f)=>{u[f]=d}),s>0)for(const d of l){const f=r[d]??0;u[d]=Dn(f/s*c)}else{const d=Dn(c/l.length);for(const f of l)u[f]=d}return u}function uG(e,t){const n=e.map(i=>i.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!r.includes(i))return!1;return!0}const ga=new Map;function dG(e){let t=!0;ut(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const x of m){const{borderBoxSize:w,target:v}=x;if(v===e.element){if(t){const _=vl({group:e});if(_===0)return;const b=Us(e.id);if(!b)return;const S=wx(e),C=b.defaultLayoutDeferred?oC(S):b.layout,k=cG({group:e,nextGroupSize:_,prevGroupSize:b.groupSize,prevLayout:C}),I=Wo({layout:k,panelConstraints:S});if(!b.defaultLayoutDeferred&&Uo(b.layout,I)&&lG(b.derivedPanelConstraints,S)&&b.groupSize===_)return;is(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:_,layout:I,separatorToPanels:b.separatorToPanels})}}else aG(e,v,w)}});s.observe(e.element),e.panels.forEach(m=>{ut(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=vl({group:e}),a=wx(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(uG(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??oC(a),d=Wo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;ga.set(f,(ga.get(f)??0)+1);const p=new Map;return NP(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),is(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{ut(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",eC)}),ga.get(f)===1&&(f.addEventListener("contextmenu",Yk,!0),f.addEventListener("dblclick",Jk,!0),f.addEventListener("pointerdown",tC,!0),f.addEventListener("pointerleave",nC),f.addEventListener("pointermove",rC),f.addEventListener("pointerout",iC),f.addEventListener("pointerup",sC,!0)),function(){t=!1,ga.set(f,Math.max(0,(ga.get(f)??0)-1)),ZK(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",eC)}),ga.get(f)||(f.removeEventListener("contextmenu",Yk,!0),f.removeEventListener("dblclick",Jk,!0),f.removeEventListener("pointerdown",tC,!0),f.removeEventListener("pointerleave",nC),f.removeEventListener("pointermove",rC),f.removeEventListener("pointerout",iC),f.removeEventListener("pointerup",sC,!0)),s.disconnect()}}function hG(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function B_(e){const t=g.useId();return`${e??t}`}const ra=typeof window<"u"?g.useLayoutEffect:g.useEffect;function Wc(e){const t=g.useRef(e);return ra(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function $_(...e){return Wc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function z_(e){const t=g.useRef({...e});return ra(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const zP=g.createContext(null);function fG(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:YK});g.useImperativeHandle(t,()=>n.current,[]),ra(()=>{Object.assign(n.current,BP({groupId:e}))})}function F_({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:o,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){const m=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),x=Wc(D=>{Uo(m.current.onLayoutChange,D)||(m.current.onLayoutChange=D,l==null||l(D))}),w=Wc((D,R)=>{Uo(m.current.onLayoutChanged,D)||(m.current.onLayoutChanged=D,c==null||c(D,{isUserInteraction:R}))}),v=B_(a),_=g.useRef(null),[b,S]=hG(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=$_(_,s);fG(v,o);const I=Wc((D,R)=>{const j=Ho(),M=Gk(D),L=Us(D);if(L){let z=!1;switch(j.state){case"active":{z=j.hitRegions.some(F=>F.group===M);break}}return{flexGrow:L.layout[R]??1,pointerEvents:z?"none":void 0}}if(n!=null&&n[R])return{flexGrow:n==null?void 0:n[R]}}),E=z_({defaultLayout:n,disableCursor:r}),A=g.useMemo(()=>({get disableCursor(){return!!E.disableCursor},getPanelStyles:I,id:v,orientation:u,registerPanel:D=>{const R=C.current;return R.panels=Sx(u,[...R.panels,D]),S(),()=>{R.panels=R.panels.filter(j=>j!==D),S()}},registerSeparator:D=>{const R=C.current;return R.separators=Sx(u,[...R.separators,D]),S(),()=>{R.separators=R.separators.filter(j=>j!==D),S()}},updatePanelProps:(D,{disabled:R})=>{const j=C.current.panels.find(z=>z.id===D);j&&(j.panelConstraints.disabled=R);const M=Gk(v),L=Us(v);M&&L&&is(M,{...L,derivedPanelConstraints:wx(M)})},updateSeparatorProps:(D,{disabled:R,disableDoubleClick:j})=>{const M=C.current.separators.find(L=>L.id===D);M&&(M.disabled=R,M.disableDoubleClick=j)}}),[I,v,S,u,E]),P=g.useRef(null);return ra(()=>{const D=_.current;if(D===null)return;const R=C.current;let j;if(E.defaultLayout!==void 0&&Object.keys(E.defaultLayout).length===R.panels.length){j={};for(const N of R.panels){const U=E.defaultLayout[N.id];U!==void 0&&(j[N.id]=U)}}const M={disabled:!!i,element:D,id:v,mutableState:{defaultLayout:j,disableCursor:!!E.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:u,panels:R.panels,resizeTargetMinimumSize:R.resizeTargetMinimumSize,separators:R.separators};P.current=M;const L=dG(M),{defaultLayoutDeferred:z,derivedPanelConstraints:F,layout:$}=Us(M.id,!0);!z&&F.length>0&&(x($),w($,!1));const B=D_(v,N=>{const{defaultLayoutDeferred:U,derivedPanelConstraints:V,layout:O}=N.next;if(U||V.length===0)return;const ne=M.panels.map(({id:Y})=>Y).join(",");M.mutableState.layouts[ne]=O,V.forEach(Y=>{if(Y.collapsible){const{layout:ye}=N.prev??{};if(ye){const Ce=Cn(Y.collapsedSize,O[Y.panelId]),oe=Cn(Y.collapsedSize,ye[Y.panelId]);Ce&&!oe&&(M.mutableState.expandedPanelSizes[Y.panelId]=ye[Y.panelId])}}});const ae=Ho().state!=="active";x(O),ae&&w(O,N.isUserInteraction)});return()=>{P.current=null,L(),B()}},[i,v,w,x,u,b,E]),g.useEffect(()=>{const D=P.current;D&&(D.mutableState.defaultLayout=n,D.mutableState.disableCursor=!!r)}),h.jsx(zP.Provider,{value:A,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":v,id:v,ref:k,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}F_.displayName="Group";function H_(){const e=g.useContext(zP);return ut(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function pG(e,t){const{id:n}=H_(),r=g.useRef({collapse:Dg,expand:Dg,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Dg});g.useImperativeHandle(t,()=>r.current,[]),ra(()=>{Object.assign(r.current,OP({groupId:n,panelId:e}))})}function Yf({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const x=!!l,w=B_(l),v=z_({disabled:s}),_=g.useRef(null),b=$_(_,o),{getPanelStyles:S,id:C,orientation:k,registerPanel:I,updatePanelProps:E}=H_(),A=d!==null,P=Wc((M,L,z)=>{d==null||d(M,l,z)});ra(()=>{const M=_.current;if(M!==null){const L={element:M,id:w,idIsStable:x,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:A?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:v.disabled,maxSize:c,minSize:u}};return I(L)}},[a,n,r,i,A,w,x,c,u,P,I,v]),g.useEffect(()=>{E(w,{disabled:s})},[s,w,E]),pG(w,f);const D=()=>{const M=S(C,w);if(M)return JSON.stringify(M)},R=g.useSyncExternalStore(M=>D_(C,M),D,D);let j;return R?j=JSON.parse(R):i!==void 0?j={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:j={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":w,id:w,ref:b,style:{...mG,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...j},children:h.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...p,touchAction:k==="horizontal"?"pan-y":"pan-x"},children:e})})}Yf.displayName="Panel";const mG={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function gG({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const o=e[n],a=t.find(l=>l.panelId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[r,r+1];s=Wo({layout:Nu({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Wo({layout:Nu({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function FP({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=B_(s),c=z_({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,x]=g.useState(!1),w=g.useRef(null),v=$_(w,i),{disableCursor:_,id:b,orientation:S,registerSeparator:C,updateSeparatorProps:k}=H_(),I=S==="horizontal"?"vertical":"horizontal";ra(()=>{const P=w.current;if(P!==null){const D={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},R=C(D),j=KK(L=>{p(L.next.state!=="inactive"&&L.next.hitRegions.some(z=>z.separator===D)?L.next.state:"inactive")}),M=D_(b,L=>{const{derivedPanelConstraints:z,layout:F,separatorToPanels:$}=L.next,B=$.get(D);if(B){const N=B[0],U=B.indexOf(N);d(gG({layout:F,panelConstraints:z,panelId:N.id,panelIndex:U}))}});return()=>{j(),M(),R()}}},[b,l,C,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let E;n&&!_&&(E="not-allowed");let A;if(n)A="disabled";else switch(f){case"active":{A="active";break}default:m?A="focus":A=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":I,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":A,"data-testid":l,id:l,onBlur:()=>x(!1),onFocus:()=>x(!0),ref:v,role:"separator",style:{flexBasis:"auto",cursor:E,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}FP.displayName="Separator";function vG(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function HP(e,t){const n=as(),r=e?`session/${e}`:"",i=ts(r)??bu,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>YT(f??bu,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function xG(e){return e.kind!=="user-text"?!1:e.meta===void 0||e.meta==="slash-command"||Yp(e.meta)}function yG(e,t={}){let n=0;if(t.implicitCloseOnUserText){for(const r of e)xG(r)&&n++;return n}for(const r of e)r.kind==="turn-end"&&n++;return n}const _G=g.createContext(null);function UP(){return g.useContext(_G)}const bG=50;function wG({api:e,sessionId:t,focused:n=!0,toolSessionId:r,initialTurns:i,implicitCloseOnUserText:s,pageSize:o=bG,enabled:a=!0,refreshVersion:l=0}){const c=UP(),[u,d]=g.useState({messages:[],total:0,loading:!1,error:null}),f=g.useRef(r),p=g.useRef(n),m=g.useRef(null),x=g.useRef(l),w=g.useRef(0),v=g.useRef(!0);return g.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]),g.useEffect(()=>{const _=f.current;f.current=r;const b=n&&!p.current;if(p.current=n,!a){m.current!==null&&(m.current=null,++w.current,d({messages:[],total:0,loading:!1,error:null}));return}const S=m.current!==t,C=x.current!==l;x.current=l;const k=typeof _=="string"&&_!==r,I=b&&u.error!==null;if(_!==r&&(c==null||c.push({level:"info",msg:"chatflow.history.identity",sessionId:t,meta:{previousToolSessionId:_??null,toolSessionId:r??null,willReload:S||k}})),!S&&!k&&!I&&!C)return;if((S||k)&&d({messages:[],total:0,loading:!1,error:null}),!t){m.current=null;return}m.current=t;const E=++w.current;c==null||c.push({level:"info",msg:"chatflow.history.read.start",sessionId:t,meta:{toolSessionId:r??null,initialTurns:i??null,pageSize:i===void 0?null:o,readSeq:E}}),d(A=>({...A,loading:!0,error:null})),(async()=>{var M;let A=[],P=!1,D,R=i===void 0?{}:{limit:o},j=Number.POSITIVE_INFINITY;for(;;){let L;try{L=await e.historyRead({sessionId:t,...R})}catch(V){if(E!==w.current||!v.current)return;const O=V.message??"history load failed";c==null||c.push({level:"warn",msg:"chatflow.history.read.error",sessionId:t,meta:{readSeq:E,shown:P,errorCode:V&&typeof V=="object"&&"code"in V?String(V.code):null}}),d(ne=>({...ne,loading:!1,error:O}));return}if(E!==w.current||!v.current)return;c==null||c.push({level:"info",msg:"chatflow.history.read.result",sessionId:t,meta:{readSeq:E,pageMessages:((M=L.messages)==null?void 0:M.length)??0,total:L.total??0,offset:L.offset??null}}),D&&L.snapshotId&&D!==L.snapshotId&&(A=[],P=!1,j=Number.POSITIVE_INFINITY,d({messages:[],total:0,loading:!0,error:null})),D=L.snapshotId,A=[...L.messages??[],...A];const z=L.total??0,F=typeof L.offset=="number"?L.offset:0,$=F>=j,B=F<=0||$;j=F;const N=i!==void 0&&yG(A,{implicitCloseOnUserText:s})>=i;if(P?d({messages:A,total:z,loading:!1,error:null}):(B||N)&&(P=!0,d({messages:A,total:z,loading:!1,error:null})),B)return;const U=Math.max(0,F-o);R={offset:U,limit:F-U,...D?{snapshotId:D}:{}}}})()},[e,t,r,n,o,i,a,l,c]),u}const SG=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function kG(e){return SG.includes(e)}function WP(e){return e==="in_progress"||e==="completed"?e:"pending"}function CG(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.subject=="string"&&n.subject?n.subject:typeof n.content=="string"&&n.content?n.content:null;if(!r)return e;const i=typeof n.activeForm=="string"?n.activeForm:void 0,s=typeof n.description=="string"?n.description:void 0;return[...e,{id:String(e.length+1),content:r,status:WP(n.status),activeForm:i,description:s}]}function EG(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.taskId=="string"&&n.taskId?n.taskId:typeof n.id=="string"&&n.id?n.id:null;if(!r)return e;const i=e.findIndex(a=>a.id===r);if(i<0)return e;const s=[...e],o={...s[i]};return"status"in n&&(o.status=WP(n.status)),typeof n.subject=="string"&&(o.content=n.subject),typeof n.content=="string"&&(o.content=n.content),typeof n.activeForm=="string"&&(o.activeForm=n.activeForm),typeof n.description=="string"&&(o.description=n.description),s[i]=o,s}function IG(e){let t=[],n=-1;for(let r=0;r<e.length;r++){const i=e[r];if(i.kind==="task-event")switch(n=r,i.name){case"TaskCreate":t=CG(t,i.input);break;case"TaskUpdate":t=EG(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function NG(e){return e==="TodoWrite"}function TG(e){if(!e||typeof e!="object")return null;const t=e;if(!Array.isArray(t.todos))return null;const n=[];for(const r of t.todos){if(!r||typeof r!="object")continue;const i=r,s=typeof i.content=="string"?i.content:"";if(!s)continue;const o=i.status==="in_progress"||i.status==="completed"?i.status:"pending",a=typeof i.activeForm=="string"?i.activeForm:void 0;n.push({content:s,status:o,activeForm:a})}return n}function $h(e,t,n){var o;const r=[],i=new Map;for(let a=0;a<e.length;a++){const l=e[a],c=typeof l.seq=="number"?l.seq:a;switch(l.kind){case"session_init":r.push({kind:"session-init",seq:c,toolSessionId:l.toolSessionId});break;case"text":aC(r,c,"assistant-text",l.text,l.partialId,l.uuid);break;case"thinking":aC(r,c,"assistant-thinking",l.text,l.partialId);break;case"user_text":{l.meta==="task-notification"?r.push({kind:"agent-notification",seq:c,text:l.text,taskId:l.taskId,parentToolUseId:l.parentToolUseId}):l.meta?r.push({kind:"user-meta",seq:c,metaKind:l.meta,text:l.text}):r.push({kind:"user-text",seq:c,text:l.text,uuid:l.uuid,...l.sender&&(l.sender.principal!=="owner"||zT.test(l.text))?{senderDisplayName:l.sender.displayName}:{},senderPrincipal:((o=l.sender)==null?void 0:o.principal)==="guest"?"guest":"owner"});break}case"tool_call":qP(r,c,l.toolUseId,l.tool,l.input,l.toolKind);break;case"tool_result":{const u=i.get(l.toolUseId);if(u!==void 0){if(l.askQuestionAnswers){const f=r[u];f.submittedAnswers=l.askQuestionAnswers}i.delete(l.toolUseId);break}const d={kind:"tool-result",seq:c,toolUseId:l.toolUseId,output:l.output,error:l.error};l.toolResultExtra&&(d.toolResultExtra=l.toolResultExtra),r.push(d);break}case"attachment_memories":r.push({kind:"memory-callout",seq:c,memories:l.memories});break;case"permission_request":{if(!t||l.requestId!==t)break;r.push({kind:"permission-inline",seq:c,requestId:l.requestId,tool:l.tool,input:l.input});break}case"ask_user_question":i.set(l.toolUseId,r.length),r.push({kind:"question-card",seq:c,toolUseId:l.toolUseId,questions:l.questions});break;case"turn_end":{const u={kind:"turn-end",seq:c};l.durationMs!==void 0&&(u.durationMs=l.durationMs),l.reason!==void 0&&(u.reason=l.reason),l.turnId!==void 0&&(u.turnId=l.turnId),r.push(u);break}case"subagent_progress":{const u={kind:"agent-progress",seq:c,toolUseId:l.toolUseId,agentId:l.agentId,status:l.status};l.description&&(u.description=l.description),l.lastToolName&&(u.lastToolName=l.lastToolName),l.prompt&&(u.prompt=l.prompt),l.stats&&(u.stats=l.stats),r.push(u);break}case"error":r.push({kind:"error",seq:c,message:l.message});break}}const s=new Map(e.flatMap((a,l)=>a.turnId?[[a.seq??l,a.turnId]]:[]));for(const a of r){const l=s.get(a.seq);l&&(a.turnId=l)}for(let a=1;a<r.length;a++){const l=r[a],c=r[a-1];if(l.kind!=="session-init"||!l.turnId||c.kind!=="turn-end"||c.reason!=="interrupted"||c.turnId)continue;let u=a-1;for(;u>0&&r[u-1].kind!=="turn-end";)u--;for(;u<a-1&&r[u].kind==="session-init";)u++;const d=r.slice(u,a);if(!d.some(f=>f.turnId&&f.turnId!==l.turnId)){for(const f of d)f.turnId=l.turnId;r.splice(a,1),a--}}return r}function qP(e,t,n,r,i,s){if(NG(r)){const o=TG(i);if(o){e.push({kind:"todo-checklist",seq:t,toolUseId:n,todos:o});return}}if(r==="Agent"){const o=i??{},a=typeof o.description=="string"&&o.description?o.description:typeof o.subagent_type=="string"&&o.subagent_type?o.subagent_type:"Subagent";e.push({kind:"agent-call",seq:t,toolUseId:n,description:a,input:i});return}if(kG(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function aC(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const PG="AskUserQuestion";function U_(e,t=0,n){var o;const r=[],i=new Map;let s=t;for(const a of e){const l=s++,c=a.toolUseId??`hist-${l}`;switch(a.kind){case"user-text":if(a.meta==="task-notification")r.push({kind:"agent-notification",seq:l,text:a.text??"",taskId:a.taskId,parentToolUseId:a.parentToolUseId});else if(a.meta)r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text??""});else{const u=zT.exec(a.text??""),d=(o=F$.exec(a.text??""))==null?void 0:o[1],f=(u==null?void 0:u[2])??d,p=(u==null?void 0:u[1])==="guest"||d?"guest":"owner";r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...f?{senderDisplayName:f}:{},senderPrincipal:p})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===PG){const u=a.input??{},d=Array.isArray(u.questions)?u.questions:[];i.set(c,r.length),r.push({kind:"question-card",seq:l,toolUseId:c,questions:d});break}qP(r,l,c,a.tool??"",a.input,n);break}case"tool_result":{const u=i.get(c);if(u!==void 0){if(a.askQuestionAnswers){const f=r[u];f.submittedAnswers=a.askQuestionAnswers}i.delete(c);break}const d={kind:"tool-result",seq:l,toolUseId:c,output:a.output};a.error!==void 0&&(d.error=a.error),a.toolResultExtra&&(d.toolResultExtra=a.toolResultExtra),r.push(d);break}case"attachment_memories":a.memories&&a.memories.length>0&&r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"summary":break;case"turn-end":{const u={kind:"turn-end",seq:l};typeof a.durationMs=="number"&&(u.durationMs=a.durationMs),typeof a.turnId=="string"&&(u.turnId=a.turnId),r.push(u);break}}}return r}const RG=5e5;function AG(e){const t=RG-e.length;return e.map(n=>({...n,seq:n.seq+t}))}const lC=/\[attachment:(image|file):([^\]]+)\]/g;function cC(e){try{return decodeURIComponent(e)}catch{return e}}function MG(e){var n,r;if(e.startsWith("data:")){const i=e.slice(5,e.indexOf(",")),s=(n=/;name=([^;]+)/i.exec(i))==null?void 0:n[1];if(s)return cC(s);const o=(r=i.split(";")[0])==null?void 0:r.toLowerCase(),a={"text/plain":"txt","application/pdf":"pdf","image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp"}[o??""];return(o!=null&&o.startsWith("image/")?"图片":"附件")+(a?"."+a:"")}const t=e.split(/[?#]/,1)[0];return cC(t.split("/").pop()||"附件")}function Xf(e){const t=[];let n;for(;(n=lC.exec(e))!==null;){const i=n[2],s=MG(i);t.push({type:n[1],url:i,fileName:s})}const r=e.replace(lC,"").trim();return{attachments:t,text:r}}function jG(e,t){const n=t.filter(i=>i.status==="done"&&i.url);return n.length===0?e:n.map(i=>`[attachment:${i.mimeType.startsWith("image/")?"image":"file"}:${i.url}]`).join(`
|
|
542
542
|
`)+`
|
|
543
543
|
`+e}const br=e=>typeof e=="string"?e:"",uC=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[];function LG(e){var s;if(e.type==="userMessage"){const a=(Array.isArray(e.content)?e.content:[]).map(c=>c.type==="text"?br(c.text):c.type==="image"?`[attachment:image:${br(c.url)}]`:c.type==="localImage"?`[图片](${br(c.path)})`:"").filter(Boolean).join(`
|
|
544
544
|
`),l=H$(a);return U_([{kind:"user-text",text:a,uuid:e.id,...l?{meta:l==="task"?"dispatch-task":"dispatch-result"}:{}}],0,"codex")}if(e.type==="agentMessage")return[{kind:"assistant-text",seq:0,text:br(e.text),uuid:e.id}];if(e.type==="reasoning")return[{kind:"assistant-thinking",seq:0,text:[...uC(e.summary),...uC(e.content)].join(`
|
package/dist/share-ui/guest.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Clawd 分享</title>
|
|
7
|
-
<script type="module" crossorigin src="/share-ui/assets/guest-
|
|
7
|
+
<script type="module" crossorigin src="/share-ui/assets/guest-CHVpuO59.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/share-ui/assets/guest-Cd_FvZem.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body style="margin: 0">
|