agent-relay-server 0.37.0 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/openapi.json +1 -1
- package/package.json +2 -2
- package/public/assets/{activity-BgkmA1lh.js → activity-b8kUF4hR.js} +2 -2
- package/public/assets/{activity-BgkmA1lh.js.map → activity-b8kUF4hR.js.map} +1 -1
- package/public/assets/{agent-profiles-DS4_jLPT.js → agent-profiles-kb5H23CF.js} +2 -2
- package/public/assets/{agent-profiles-DS4_jLPT.js.map → agent-profiles-kb5H23CF.js.map} +1 -1
- package/public/assets/{agents-B7HnuAXx.js → agents-C_ZSRXRa.js} +2 -2
- package/public/assets/{agents-B7HnuAXx.js.map → agents-C_ZSRXRa.js.map} +1 -1
- package/public/assets/{analytics-0-akxJCJ.js → analytics-3JbZ6M41.js} +3 -3
- package/public/assets/{analytics-0-akxJCJ.js.map → analytics-3JbZ6M41.js.map} +1 -1
- package/public/assets/{automation-CaE1z_-M.js → automation-CVu2C3sk.js} +2 -2
- package/public/assets/{automation-CaE1z_-M.js.map → automation-CVu2C3sk.js.map} +1 -1
- package/public/assets/{branch-state-badge-D8-T2c1K.js → branch-state-badge-B1K7aIzF.js} +2 -2
- package/public/assets/{branch-state-badge-D8-T2c1K.js.map → branch-state-badge-B1K7aIzF.js.map} +1 -1
- package/public/assets/{channels-ppN8k4hu.js → channels-DyPw9JsY.js} +2 -2
- package/public/assets/{channels-ppN8k4hu.js.map → channels-DyPw9JsY.js.map} +1 -1
- package/public/assets/chat-BiCWbMPO.js +2 -0
- package/public/assets/chat-BiCWbMPO.js.map +1 -0
- package/public/assets/{connectors-CL9BALhF.js → connectors-k7JYCrrl.js} +2 -2
- package/public/assets/{connectors-CL9BALhF.js.map → connectors-k7JYCrrl.js.map} +1 -1
- package/public/assets/display-ConJ9cJB.js.map +1 -1
- package/public/assets/{formatted-body-impl-DExNPNsL.js → formatted-body-impl-CSAGn8zM.js} +2 -2
- package/public/assets/{formatted-body-impl-DExNPNsL.js.map → formatted-body-impl-CSAGn8zM.js.map} +1 -1
- package/public/assets/index-Bins8N_5.css +2 -0
- package/public/assets/index-n5wxGWSq.js +21 -0
- package/public/assets/index-n5wxGWSq.js.map +1 -0
- package/public/assets/{integrations-DX55ARy0.js → integrations-BEkyjBAs.js} +2 -2
- package/public/assets/{integrations-DX55ARy0.js.map → integrations-BEkyjBAs.js.map} +1 -1
- package/public/assets/{maintenance-DpTdJxQp.js → maintenance-CCcvsBbm.js} +2 -2
- package/public/assets/{maintenance-DpTdJxQp.js.map → maintenance-CCcvsBbm.js.map} +1 -1
- package/public/assets/managed-agents-DHfO5gVD.js +2 -0
- package/public/assets/managed-agents-DHfO5gVD.js.map +1 -0
- package/public/assets/{markdown-preview-impl-D0Zj7c3T.js → markdown-preview-impl-C1jNXAEL.js} +2 -2
- package/public/assets/{markdown-preview-impl-D0Zj7c3T.js.map → markdown-preview-impl-C1jNXAEL.js.map} +1 -1
- package/public/assets/{memory-TATN2vZf.js → memory-VmjJ-YZ8.js} +2 -2
- package/public/assets/{memory-TATN2vZf.js.map → memory-VmjJ-YZ8.js.map} +1 -1
- package/public/assets/{messages-3rS1lxIf.js → messages-DXN6Rkjt.js} +2 -2
- package/public/assets/{messages-3rS1lxIf.js.map → messages-DXN6Rkjt.js.map} +1 -1
- package/public/assets/{orchestrators-CRIV0g5y.js → orchestrators-CLyYvfn1.js} +2 -2
- package/public/assets/{orchestrators-CRIV0g5y.js.map → orchestrators-CLyYvfn1.js.map} +1 -1
- package/public/assets/{overview-CmHC_5oM.js → overview-DZmVU2Fh.js} +2 -2
- package/public/assets/{overview-CmHC_5oM.js.map → overview-DZmVU2Fh.js.map} +1 -1
- package/public/assets/{pairs-DBPAhXTI.js → pairs-BeEORfZF.js} +2 -2
- package/public/assets/{pairs-DBPAhXTI.js.map → pairs-BeEORfZF.js.map} +1 -1
- package/public/assets/{security-572X5MNX.js → security-DIe-a7rD.js} +2 -2
- package/public/assets/{security-572X5MNX.js.map → security-DIe-a7rD.js.map} +1 -1
- package/public/assets/{settings-vTBu8w3O.js → settings-BeFPCFUZ.js} +2 -2
- package/public/assets/{settings-vTBu8w3O.js.map → settings-BeFPCFUZ.js.map} +1 -1
- package/public/assets/{store-DKVWC6Uh.js → store-Bo72e9My.js} +2 -2
- package/public/assets/{store-DKVWC6Uh.js.map → store-Bo72e9My.js.map} +1 -1
- package/public/assets/{tasks-C0bPrDgN.js → tasks-BVXiBzUI.js} +2 -2
- package/public/assets/{tasks-C0bPrDgN.js.map → tasks-BVXiBzUI.js.map} +1 -1
- package/public/assets/{terminal-viewer-impl-rVPA6Fsx.js → terminal-viewer-impl-CN311GDZ.js} +2 -2
- package/public/assets/{terminal-viewer-impl-rVPA6Fsx.js.map → terminal-viewer-impl-CN311GDZ.js.map} +1 -1
- package/public/assets/{work-queue-BxkpTt_A.js → work-queue-BnQftDAS.js} +2 -2
- package/public/assets/{work-queue-BxkpTt_A.js.map → work-queue-BnQftDAS.js.map} +1 -1
- package/public/assets/{workspaces-CoC2nflZ.js → workspaces-Df0xJuIo.js} +2 -2
- package/public/assets/{workspaces-CoC2nflZ.js.map → workspaces-Df0xJuIo.js.map} +1 -1
- package/public/index.html +3 -3
- package/src/automations.ts +17 -2
- package/src/cli/index.ts +1 -1
- package/src/cli/workspace.ts +36 -3
- package/src/config-store.ts +47 -1
- package/src/lifecycle-manager.ts +74 -6
- package/src/maintenance.ts +28 -24
- package/src/mcp.ts +7 -2
- package/src/reviewer-pipeline.ts +197 -0
- package/src/routes/commands.ts +6 -0
- package/src/routes/workspaces.ts +4 -1
- package/src/services/managed-running.ts +1 -0
- package/src/services/send-message.ts +19 -1
- package/src/services/spawn-agent.ts +6 -0
- package/src/workspace-actions.ts +5 -1
- package/src/workspace-merge.ts +102 -3
- package/src/workspace-phase.ts +15 -1
- package/public/assets/chat-BANKUW05.js +0 -2
- package/public/assets/chat-BANKUW05.js.map +0 -1
- package/public/assets/index-3pO43nJo.css +0 -2
- package/public/assets/index-DEZdON6c.js +0 -21
- package/public/assets/index-DEZdON6c.js.map +0 -1
- package/public/assets/managed-agents-B3df2xfk.js +0 -2
- package/public/assets/managed-agents-B3df2xfk.js.map +0 -1
|
@@ -53,10 +53,28 @@ export interface SendMessageOptions {
|
|
|
53
53
|
* the runner reporting an agent's turn ON ITS BEHALF, so the wire `from` (the reported agent) is
|
|
54
54
|
* authoritative there and the token's own identity must NOT override it. This is the relay's own
|
|
55
55
|
* lane (not agent-directed), the agentId authz predicate is dropped for it too, and it preserves
|
|
56
|
-
* the pre-convergence behavior — a steward/runner token managing other agents can still mirror.
|
|
56
|
+
* the pre-convergence behavior — a steward/runner token managing other agents can still mirror.
|
|
57
|
+
*
|
|
58
|
+
* LINEAGE GATE (#362): the reserved-sink exception is NOT blanket lane access — the wire `from`
|
|
59
|
+
* must be an agent the caller is authorised to speak as. The caller qualifies when the wire
|
|
60
|
+
* `from` matches its own resolved identity (`callerAgentId`), OR when `from` is explicitly
|
|
61
|
+
* listed in the token's managed set (`constraints.agents`), OR when the caller carries no
|
|
62
|
+
* agent-level constraints at all (admin/server/integration). Any other combination is an
|
|
63
|
+
* impersonation attempt and is rejected. */
|
|
57
64
|
function resolveFrom(input: SendMessageInput, ctx: AuthContext, reservedSink: boolean): string {
|
|
58
65
|
const from = reservedSink ? (input.from || ctx.callerAgentId) : (ctx.callerAgentId ?? input.from);
|
|
59
66
|
if (!from) throw new ValidationError("from is required");
|
|
67
|
+
if (reservedSink && from !== ctx.callerAgentId) {
|
|
68
|
+
// Constrained component tokens: the wire `from` must be in the token's managed agents list.
|
|
69
|
+
// Unconstrained callers (admin, server, integration — ctx.constraints is undefined) are
|
|
70
|
+
// allowed through unchanged; they hold full reach by design.
|
|
71
|
+
const managed = ctx.constraints?.agents;
|
|
72
|
+
if (managed !== undefined && !managed.includes(from)) {
|
|
73
|
+
throw new ServiceAuthError(
|
|
74
|
+
`reserved-sink wire from "${from}" is not in the caller's managed agents — impersonation rejected (#362)`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
60
78
|
return from;
|
|
61
79
|
}
|
|
62
80
|
|
|
@@ -190,6 +190,12 @@ export async function spawnAgent(input: SpawnAgentInput, ctx: AuthContext): Prom
|
|
|
190
190
|
policyName: input.policyName,
|
|
191
191
|
spawnRequestId,
|
|
192
192
|
createdBy: requestedBy,
|
|
193
|
+
// Thread the resolved profile into the mint so the spawn grant (command:spawn/shutdown +
|
|
194
|
+
// maxSpawnedAgents quota) is honored — parity with the HTTP path (agent-sessions.ts). #349
|
|
195
|
+
// dropped this when it unified the spawn service, silently un-spawning every default-spawner
|
|
196
|
+
// (P0 regression #364). For an agent caller, agentInitiated still forces a non-spawn-capable
|
|
197
|
+
// child regardless of profile (no grandchildren).
|
|
198
|
+
profile: input.profile || undefined,
|
|
193
199
|
...(callerId ? { agentInitiated: true, spawnedBy: callerId } : {}),
|
|
194
200
|
});
|
|
195
201
|
|
package/src/workspace-actions.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { isOwnerAlive, requestWorkspaceMerge } from "./workspace-merge";
|
|
|
25
25
|
export { LAND_STRATEGIES, DEFAULT_MERGE_STRATEGY } from "./workspace-merge";
|
|
26
26
|
import { claimMetadataPatch, workspaceActiveClaim } from "./workspace-claim";
|
|
27
27
|
import { TERMINAL_WORKSPACE_STATUSES } from "./workspace-phase";
|
|
28
|
-
import type { Command, WorkspaceMergeStrategy, WorkspaceRecord, WorkspaceStatus } from "./types";
|
|
28
|
+
import type { Command, WorkspaceAutoMergePolicy, WorkspaceMergeStrategy, WorkspaceRecord, WorkspaceStatus } from "./types";
|
|
29
29
|
|
|
30
30
|
// Single source of truth for the action verb set. The route's `optionalEnum` and
|
|
31
31
|
// the MCP tool surface both import this so they can never drift out of sync.
|
|
@@ -54,6 +54,8 @@ interface ApplyWorkspaceActionInput {
|
|
|
54
54
|
deleteBranch?: boolean;
|
|
55
55
|
prTitle?: string;
|
|
56
56
|
prBody?: string;
|
|
57
|
+
autoMerge?: WorkspaceAutoMergePolicy;
|
|
58
|
+
reviewer?: string;
|
|
57
59
|
// cleanup
|
|
58
60
|
force?: boolean;
|
|
59
61
|
// claim / release-claim
|
|
@@ -171,6 +173,8 @@ export function applyWorkspaceAction(workspace: WorkspaceRecord, input: ApplyWor
|
|
|
171
173
|
deleteBranch: input.deleteBranch !== false,
|
|
172
174
|
prTitle: input.prTitle,
|
|
173
175
|
prBody: input.prBody,
|
|
176
|
+
autoMerge: input.autoMerge,
|
|
177
|
+
reviewer: input.reviewer,
|
|
174
178
|
metadata: { ...metadata, ...(detail ? { detail } : {}), ...(agentId ? { updatedByAgentId: agentId } : {}) },
|
|
175
179
|
});
|
|
176
180
|
if (!result.ok) return { ok: false, httpStatus: result.status, error: result.error };
|
package/src/workspace-merge.ts
CHANGED
|
@@ -7,9 +7,21 @@ import {
|
|
|
7
7
|
setMergeLeaseCommand,
|
|
8
8
|
updateWorkspaceStatus,
|
|
9
9
|
} from "./db";
|
|
10
|
-
import
|
|
10
|
+
import { getLandingConfig } from "./config-store";
|
|
11
|
+
import type {
|
|
12
|
+
Command,
|
|
13
|
+
WorkspaceAutoMergePolicy,
|
|
14
|
+
WorkspaceLandingPolicy,
|
|
15
|
+
WorkspaceMergeStrategy,
|
|
16
|
+
WorkspaceRecord,
|
|
17
|
+
} from "./types";
|
|
18
|
+
import { AUTO_MERGE_POLICIES } from "./types";
|
|
11
19
|
import { isPathWithinBase } from "./utils";
|
|
12
20
|
|
|
21
|
+
// Re-export so consumers can import the tuple from the strategy home without a
|
|
22
|
+
// second import hop.
|
|
23
|
+
export { AUTO_MERGE_POLICIES } from "./types";
|
|
24
|
+
|
|
13
25
|
// One home for the land-strategy contract, shared by BOTH land surfaces — the HTTP
|
|
14
26
|
// route (`POST /api/workspaces/:id/actions`, driven by `agent-relay workspace land`)
|
|
15
27
|
// and the `relay_workspace_land` MCP tool. They validate against the same tuple and
|
|
@@ -21,6 +33,60 @@ import { isPathWithinBase } from "./utils";
|
|
|
21
33
|
export const LAND_STRATEGIES = ["pr", "rebase-ff", "auto"] as const;
|
|
22
34
|
export const DEFAULT_MERGE_STRATEGY: WorkspaceMergeStrategy = "auto";
|
|
23
35
|
|
|
36
|
+
/** Normalize a user-facing policy word or a raw WorkspaceMergeStrategy to a WorkspaceMergeStrategy. */
|
|
37
|
+
function normalizeToMergeStrategy(value: string): WorkspaceMergeStrategy {
|
|
38
|
+
if (value === "direct") return "auto";
|
|
39
|
+
if (value === "pr" || value === "rebase-ff" || value === "auto") return value;
|
|
40
|
+
return "auto";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Resolve the effective merge strategy from the three-level precedence chain.
|
|
45
|
+
*
|
|
46
|
+
* Precedence (highest → lowest):
|
|
47
|
+
* explicit (per-invocation --strategy or relay_workspace_land.strategy)
|
|
48
|
+
* > profileStrategy (per-profile landingStrategy)
|
|
49
|
+
* > instanceStrategy (instance-wide landing.strategy from config-store)
|
|
50
|
+
* > "direct" (hard-coded default, which maps to "auto")
|
|
51
|
+
*
|
|
52
|
+
* `explicit` accepts BOTH raw WorkspaceMergeStrategy literals ("pr", "rebase-ff",
|
|
53
|
+
* "auto") and policy words ("direct", "pr") so callers don't need to pre-normalise.
|
|
54
|
+
*/
|
|
55
|
+
export function resolveLandStrategy(opts: {
|
|
56
|
+
explicit?: string;
|
|
57
|
+
profileStrategy?: WorkspaceLandingPolicy;
|
|
58
|
+
instanceStrategy?: WorkspaceLandingPolicy;
|
|
59
|
+
}): WorkspaceMergeStrategy {
|
|
60
|
+
if (opts.explicit !== undefined && opts.explicit !== null) {
|
|
61
|
+
return normalizeToMergeStrategy(opts.explicit);
|
|
62
|
+
}
|
|
63
|
+
if (opts.profileStrategy !== undefined) {
|
|
64
|
+
return normalizeToMergeStrategy(opts.profileStrategy);
|
|
65
|
+
}
|
|
66
|
+
if (opts.instanceStrategy !== undefined) {
|
|
67
|
+
return normalizeToMergeStrategy(opts.instanceStrategy);
|
|
68
|
+
}
|
|
69
|
+
return DEFAULT_MERGE_STRATEGY;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Derive the issue number from a workspace metadata bag.
|
|
74
|
+
* Checks `metadata.issueNumber` (number or numeric string) and
|
|
75
|
+
* `metadata.taskId` (number or numeric string) — both common shapes.
|
|
76
|
+
* Returns the integer if found, otherwise undefined.
|
|
77
|
+
*/
|
|
78
|
+
function resolveIssueNumber(metadata: Record<string, unknown>): number | undefined {
|
|
79
|
+
for (const key of ["issueNumber", "taskId"]) {
|
|
80
|
+
const raw = metadata[key];
|
|
81
|
+
if (typeof raw === "number" && Number.isSafeInteger(raw) && raw > 0) return raw;
|
|
82
|
+
if (typeof raw === "string") {
|
|
83
|
+
const n = Number.parseInt(raw, 10);
|
|
84
|
+
if (Number.isSafeInteger(n) && n > 0) return n;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
24
90
|
interface RequestWorkspaceMergeOptions {
|
|
25
91
|
/** Who asked for the merge (lease holder + audit). e.g. an agent id, "dashboard", "auto-merge". */
|
|
26
92
|
requestedBy: string;
|
|
@@ -33,6 +99,15 @@ interface RequestWorkspaceMergeOptions {
|
|
|
33
99
|
push?: boolean;
|
|
34
100
|
prTitle?: string;
|
|
35
101
|
prBody?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Auto-merge policy for a PR-strategy land. When the effective strategy is "pr" and
|
|
104
|
+
* this is unset, defaults to "on-green" — a pr land MUST always reach a terminal
|
|
105
|
+
* state and should not block on a human hitting the merge button. Ignored for non-pr
|
|
106
|
+
* strategies (omitted from the command params entirely so the host stays clean).
|
|
107
|
+
*/
|
|
108
|
+
autoMerge?: WorkspaceAutoMergePolicy;
|
|
109
|
+
/** Optional reviewer handle (GitHub login or team slug) to request on the opened PR. */
|
|
110
|
+
reviewer?: string;
|
|
36
111
|
/** Extra metadata merged onto the workspace row when moving to merge_planned. */
|
|
37
112
|
metadata?: Record<string, unknown>;
|
|
38
113
|
}
|
|
@@ -101,6 +176,28 @@ export function requestWorkspaceMerge(workspace: WorkspaceRecord, opts: RequestW
|
|
|
101
176
|
releaseMergeLease({ repoRoot: workspace.repoRoot, workspaceId: workspace.id });
|
|
102
177
|
return { ok: false, status: 404, error: "workspace not found" };
|
|
103
178
|
}
|
|
179
|
+
const effectiveStrategy = opts.strategy ?? DEFAULT_MERGE_STRATEGY;
|
|
180
|
+
|
|
181
|
+
// Slice 6 — issue auto-linkage: append "Closes #N" to the PR body when the
|
|
182
|
+
// workspace metadata carries an issue number, WITHOUT clobbering an explicit body.
|
|
183
|
+
const issueNumber = resolveIssueNumber(workspace.metadata);
|
|
184
|
+
let prBody = opts.prBody;
|
|
185
|
+
if (issueNumber !== undefined) {
|
|
186
|
+
const closesLine = `Closes #${issueNumber}`;
|
|
187
|
+
if (!prBody) {
|
|
188
|
+
prBody = closesLine;
|
|
189
|
+
} else if (!prBody.includes(closesLine)) {
|
|
190
|
+
prBody = `${prBody}\n\n${closesLine}`;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Slice 3 — auto-merge default for PR lands: a pr-strategy land MUST reach a
|
|
195
|
+
// terminal state; default to "on-green" so CI can close the loop automatically.
|
|
196
|
+
const isPrStrategy = effectiveStrategy === "pr";
|
|
197
|
+
const autoMerge: WorkspaceAutoMergePolicy | undefined = isPrStrategy
|
|
198
|
+
? (opts.autoMerge ?? "on-green")
|
|
199
|
+
: undefined;
|
|
200
|
+
|
|
104
201
|
const command = createCommand({
|
|
105
202
|
type: "workspace.merge",
|
|
106
203
|
source: "system",
|
|
@@ -114,11 +211,13 @@ export function requestWorkspaceMerge(workspace: WorkspaceRecord, opts: RequestW
|
|
|
114
211
|
branch: workspace.branch,
|
|
115
212
|
baseRef: workspace.baseRef,
|
|
116
213
|
baseSha: workspace.baseSha,
|
|
117
|
-
strategy:
|
|
214
|
+
strategy: effectiveStrategy,
|
|
118
215
|
deleteBranch,
|
|
119
216
|
push: opts.push !== false,
|
|
120
217
|
prTitle: opts.prTitle,
|
|
121
|
-
prBody
|
|
218
|
+
prBody,
|
|
219
|
+
...(autoMerge !== undefined ? { autoMerge } : {}),
|
|
220
|
+
...(opts.reviewer !== undefined ? { reviewer: opts.reviewer } : {}),
|
|
122
221
|
requestedBy: opts.requestedBy,
|
|
123
222
|
requestedAt: Date.now(),
|
|
124
223
|
},
|
package/src/workspace-phase.ts
CHANGED
|
@@ -80,6 +80,7 @@ export function worktreeReapable(state: WorktreeReapState | null | undefined): b
|
|
|
80
80
|
// an unpushed branch, a wedged steward) and the agent/human should be told —
|
|
81
81
|
// instead of the old behavior where it looked healthy for 90 minutes.
|
|
82
82
|
export const LAND_PENDING_STALL_MS = 15 * 60 * 1000;
|
|
83
|
+
export const DIRTY_WORKTREE_LAND_SKIP_REASON = "worktree has uncommitted changes";
|
|
83
84
|
|
|
84
85
|
type WorkspacePhase =
|
|
85
86
|
| "working" // active — your turn: commit, then mark ready
|
|
@@ -134,7 +135,7 @@ const READY_ACTION: WorkspaceNextAction = {
|
|
|
134
135
|
// marks ready, immune to the heartbeat `updated_at` bump) — not `updatedAt`, which
|
|
135
136
|
// keeps ticking on every heartbeat and made the stall look fresh forever.
|
|
136
137
|
export function describeWorkspacePhase(
|
|
137
|
-
workspace: Pick<WorkspaceRecord, "status" | "branch" | "stewardAgentId" | "readyAt"
|
|
138
|
+
workspace: Pick<WorkspaceRecord, "status" | "branch" | "stewardAgentId" | "readyAt"> & { metadata?: Record<string, unknown> },
|
|
138
139
|
opts: { now?: number; stallMs?: number } = {},
|
|
139
140
|
): WorkspacePhaseView {
|
|
140
141
|
switch (workspace.status) {
|
|
@@ -160,6 +161,19 @@ export function describeWorkspacePhase(
|
|
|
160
161
|
// the agent (and the dashboard) stop reporting a wedged land as healthy.
|
|
161
162
|
if (pendingMs !== undefined && pendingMs > stallMs) {
|
|
162
163
|
const mins = Math.round(pendingMs / 60_000);
|
|
164
|
+
const lastLandSkipReason = typeof workspace.metadata?.lastLandSkipReason === "string"
|
|
165
|
+
? workspace.metadata.lastLandSkipReason
|
|
166
|
+
: undefined;
|
|
167
|
+
if (lastLandSkipReason === DIRTY_WORKTREE_LAND_SKIP_REASON) {
|
|
168
|
+
return {
|
|
169
|
+
phase: "land-pending",
|
|
170
|
+
headline: `Stalled — handed off ${mins} min ago but auto-merge is blocked by uncommitted worktree changes.`,
|
|
171
|
+
hint: "Commit or stash your uncommitted changes in the worktree, then wait for Relay to retry the auto-merge. Do NOT merge, push, rebase, or touch the main checkout yourself.",
|
|
172
|
+
actionNeeded: true,
|
|
173
|
+
nextActions: [WAIT_ACTION],
|
|
174
|
+
blockers: ["owner worktree has uncommitted changes — commit or stash them in the worktree"],
|
|
175
|
+
};
|
|
176
|
+
}
|
|
163
177
|
return {
|
|
164
178
|
phase: "land-pending",
|
|
165
179
|
headline: `Stalled — handed off ${mins} min ago but still hasn't landed. A clean auto-merge runs every ~2 min, so this is past the healthy window and likely stuck (no online orchestrator, an unpushed branch, or a wedged merge/steward).`,
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./chunk-CilyBKbf.js";import{$t as t,An as n,D as r,Dt as i,E as a,Et as o,Fn as s,Ft as c,G as l,H as u,Hn as d,I as f,It as p,J as m,Jt as h,K as g,Lt as _,Mn as v,On as y,P as b,Tn as x,Wt as S,Z as C,an as w,at as T,b as E,c as D,dn as ee,en as te,et as ne,g as re,i as ie,in as ae,it as O,jn as oe,kt as se,mn as ce,nn as le,qt as ue,r as de,rn as fe,s as pe,tn as me,tt as he,wn as ge,x as _e,xn as ve,yn as ye,yt as be}from"./lucide-react-DLQFnqNm.js";import{t as xe}from"./react-dom-CzfKBOnw.js";import{d as Se,i as Ce,l as we,s as Te,t as k,u as Ee}from"./store-DKVWC6Uh.js";import{A as De,B as Oe,D as ke,F as Ae,G as A,H as je,I as Me,K as Ne,R as Pe,U as Fe,Z as Ie,_ as Le,a as Re,d as j,h as ze,j as Be,k as Ve,o as He,r as Ue,rt as We,w as Ge}from"./display-ConJ9cJB.js";import{t as Ke}from"./badge-JVybSpzR.js";import{t as M}from"./button-BsMqBNJb.js";import{t as qe}from"./input-dPzf0luy.js";import{t as Je}from"./copy-button-B-XlL8nF.js";import{C as Ye,E as Xe,I as Ze,S as Qe,T as $e,_ as et,a as tt,d as nt,g as rt,h as it,i as at,k as ot,l as st,m as ct,o as lt,p as ut,r as dt,t as ft,v as pt,w as mt,y as ht}from"./index-DEZdON6c.js";import{t as gt}from"./use-keyboard-viewport-bZ1J-ZnH.js";import{n as _t,t as vt}from"./branch-state-badge-D8-T2c1K.js";var N=e(d(),1);function yt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function bt(e,t){if(t.startsWith(`/`))return t;let n=`${e.replace(/\/+$/,``)}/${t}`.split(`/`),r=[];for(let e of n)!e||e===`.`||(e===`..`?r.pop():r.push(e));return`/`+r.join(`/`)}function xt(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>0?t.slice(0,n):`/`}function St(e,t){return e.filter(e=>e.status===`online`&&Ae(t,e.baseDir)).sort((e,t)=>De(t.baseDir).length-De(e.baseDir).length)[0]||e.find(e=>e.status===`online`)}function Ct(){return typeof window<`u`&&window.matchMedia(`(min-width: 1280px)`).matches}function wt(){return typeof window<`u`&&!!window.getSelection()?.toString()}function Tt(e){let t=e.payload?.attachments;return Array.isArray(t)?t.filter(e=>!!(e&&typeof e==`object`&&typeof e.artifactId==`string`)):[]}var Et=[`👍`,`❤️`,`✅`,`👀`];function Dt(e){let t=new Map;for(let n of e.reactions||[]){let e=Be(n.emoji),r=t.get(e)??{emoji:e,count:0,mine:!1,actors:[]};r.count+=1,r.mine=r.mine||n.actorId===`user`,r.actors.push(n.actorId),t.set(e,r)}return[...t.values()].sort((e,t)=>t.count-e.count||e.emoji.localeCompare(t.emoji))}function Ot(e){return Ge(e)}function kt(e,n){let r=e.readBy||[],i=e.resolvedToAgent||n||e.to,a=i?r.includes(i):!1,o=r.some(e=>e!==We);if(a||o){let e=a?i:r.find(e=>e!==We);return{label:`read`,title:e?`Read by ${e}`:`Read by agent`,tone:`ok`,icon:w}}if(e.deliveryStatus===`delivered`)return{label:`delivered`,title:`Delivered to agent inbox`,tone:`ok`,icon:w};if(e.deliveryStatus===`queued`)return{label:`queued`,title:`Queued until the target agent is available`,tone:`warn`,icon:S};if(e.deliveryStatus===`failed`||e.deliveryStatus===`dead`){let n=e.deliveryPoisonReason||e.deliveryLastError||e.deliveryStatus;return{label:e.deliveryStatus,title:n,tone:`danger`,icon:t}}return{label:`sent`,title:`Accepted by Relay`,tone:`muted`,icon:ae}}function At(e){let t=Fe(e.createdAt);return(e.reactions||[]).reduce((e,t)=>Math.max(e,Fe(t.updatedAt||t.createdAt)),t)}function jt(e){return e?e.messages.reduce((e,t)=>Math.max(e,At(t)),0):0}function Mt(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Nt(e){for(let t of e)t.previewUrl&&URL.revokeObjectURL(t.previewUrl)}function Pt(){let e=k(e=>e.agents),t=k(e=>e.showBuiltIns),n=k(e=>e.showOffline),r=k(e=>e.chatAgentSearch),i=k(e=>e.chatAgentProviderFilter),a=k(e=>e.chatAgentStatusFilter),o=k(e=>e.chatAgentTagFilter),s=k(e=>e.chatAgentCapFilter),c=k(e=>e.chatAgentHostFilter),l=k(e=>e.chatAgentSort),u=k(e=>e.chatAgentSortDir),d=k(e=>e.managedPolicies);return(0,N.useMemo)(()=>{let f=Ne(e,t,d);if(n||(f=f.filter(e=>e.status!==`offline`)),r){let e=r.toLowerCase();f=f.filter(t=>t.id.toLowerCase().includes(e)||(t.name||``).toLowerCase().includes(e)||(t.label||``).toLowerCase().includes(e)||(t.tags||[]).some(t=>t.toLowerCase().includes(e))||(t.capabilities||[]).some(t=>t.toLowerCase().includes(e)))}i&&(f=f.filter(e=>He(e)===i)),a&&(f=f.filter(e=>e.status===a)),o&&(f=f.filter(e=>(e.tags||[]).includes(o))),s&&(f=f.filter(e=>(e.capabilities||[]).includes(s))),c&&(f=f.filter(e=>(e.machine||``)===c));let p=u===`desc`?-1:1;return[...f].sort((e,t)=>l===`name`?j(e).localeCompare(j(t))*p:l===`lastSeen`?(Fe(t.lastSeen)-Fe(e.lastSeen))*p||j(e).localeCompare(j(t)):((Ie[e.status]??9)-(Ie[t.status]??9))*p||j(e).localeCompare(j(t)))},[e,t,n,d,r,i,a,o,s,c,l,u])}var P=n();function Ft({threads:e,onSelectAgent:n}){let i=k(e=>e.set),a=k(e=>e.openInboxThread),o=k(e=>e.openAgentSpawn),s=k(e=>e.selectedInboxThread),c=k(e=>e.chatAgentSearch),l=k(e=>e.chatAgentSort),u=k(e=>e.chatAgentSortDir),d=k(e=>e.chatAgentProviderFilter),p=k(e=>e.chatAgentStatusFilter),m=k(e=>e.chatAgentTagFilter),h=k(e=>e.chatAgentCapFilter),g=k(e=>e.chatAgentHostFilter),_=k(e=>e.chatAgentGroupBy),v=k(e=>e.chatAgentFiltersCollapsed),b=Ce(),x=Pt(),S=(0,N.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.peer,n);return t},[e]),C=(0,N.useMemo)(()=>{if(l!==`lastMessage`)return x;let e=u===`desc`?-1:1;return[...x].sort((t,n)=>{let r=jt(S.get(t.id));return(jt(S.get(n.id))-r)*e||j(t).localeCompare(j(n))})},[x,l,u,S]),w=(0,N.useMemo)(()=>[...new Set(x.flatMap(e=>e.tags||[]))],[x]),T=(0,N.useMemo)(()=>[...new Set(x.flatMap(e=>A(e.capabilities||[])))],[x]),E=Ze(),D=(0,N.useMemo)(()=>{if(_!==`project`)return null;let e=new Map;for(let t of C){let n=ct(t)||`No project`,r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[C,_]),ee=[d,p,m,h,g].filter(Boolean).length;function ne(e){a(e,S.get(e)?.messages),n?.(e)}function re(e){let n=S.get(e.id),r=n?.attention.unread||0,i=Ue(e),a=n?.previewMessage,o=jt(n),c=s===e.id,l=it(e),u=ct(e),d=l.Icon;return(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{className:y(`w-full text-left px-3 py-2.5 flex items-start gap-2.5 hover:bg-muted/50 transition-colors border-b border-border/50`,c&&`bg-muted/60`),onClick:()=>ne(e.id),children:[(0,P.jsxs)(`div`,{className:`relative shrink-0 mt-0.5`,children:[(0,P.jsx)(rt,{agent:e}),(0,P.jsx)(et,{agent:e,now:b,className:`absolute -bottom-0.5 -right-0.5 w-2 h-2`})]}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-0.5`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium truncate`,children:j(e)}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[o>0&&(0,P.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,title:ze(o),children:je(b,o)}),r>0&&(0,P.jsx)(Ke,{className:`bg-red-500 text-white text-xs min-w-[18px] h-[18px] flex items-center justify-center shrink-0 px-1`,children:r}),!r&&i&&(0,P.jsx)(Ke,{className:`bg-amber-500 text-black text-xs min-w-[18px] h-[18px] flex items-center justify-center shrink-0 px-1`,title:`Needs response`,children:(0,P.jsx)(t,{className:`h-3 w-3`})})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-0.5 text-[10px] text-muted-foreground`,children:[(0,P.jsx)(`span`,{title:l.title,className:`inline-flex shrink-0`,children:(0,P.jsx)(d,{className:y(`h-3 w-3`,l.iconColor)})}),(0,P.jsx)(`span`,{className:`truncate`,children:u||l.label}),e.context&&(0,P.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,P.jsx)(ut,{utilization:e.context.utilization,size:18})})]}),a&&(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:[a.from===`user`?`You: `:``,Ve(a)]}),e.status!==`offline`&&(0,P.jsx)(`div`,{className:`mt-1`,children:(0,P.jsx)(`span`,{className:y(`text-xs`,e.status===`busy`?`text-yellow-400`:`text-emerald-400`),children:e.status})})]})]})},e.id)}return(0,P.jsxs)(`div`,{className:`flex flex-col h-full border-r border-border min-w-0`,children:[(0,P.jsxs)(`div`,{className:`p-3 border-b border-border space-y-2`,children:[(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(r,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground pointer-events-none`}),(0,P.jsx)(qe,{placeholder:`Search agents...`,value:c,onChange:e=>i({chatAgentSearch:e.target.value}),className:`pl-8 h-7 text-xs`})]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i({chatAgentFiltersCollapsed:!v}),className:`sm:hidden flex w-full items-center justify-between h-6 px-1.5 text-xs rounded-md border border-border bg-background text-muted-foreground`,children:[(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,P.jsx)(_e,{className:`w-3.5 h-3.5`}),`Filters & sort`,ee>0&&(0,P.jsx)(Ke,{className:`bg-primary/20 text-primary text-[10px] h-4 min-w-4 px-1 flex items-center justify-center`,children:ee})]}),v?(0,P.jsx)(fe,{className:`w-3.5 h-3.5`}):(0,P.jsx)(te,{className:`w-3.5 h-3.5`})]}),(0,P.jsxs)(`div`,{className:y(`space-y-2`,v?`hidden`:`block`,`sm:block`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsxs)(`select`,{value:l,onChange:e=>i({chatAgentSort:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:`status`,children:`By status`}),(0,P.jsx)(`option`,{value:`name`,children:`By name`}),(0,P.jsx)(`option`,{value:`lastSeen`,children:`By last seen`}),(0,P.jsx)(`option`,{value:`lastMessage`,children:`By last activity`})]}),(0,P.jsx)(M,{variant:`ghost`,size:`icon-xs`,onClick:()=>i({chatAgentSortDir:u===`asc`?`desc`:`asc`}),children:u===`asc`?(0,P.jsx)(ye,{className:`w-3.5 h-3.5`}):(0,P.jsx)(ge,{className:`w-3.5 h-3.5`})})]}),(0,P.jsxs)(`select`,{value:_,onChange:e=>i({chatAgentGroupBy:e.target.value}),className:`w-full h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:``,children:`No grouping`}),(0,P.jsx)(`option`,{value:`project`,children:`Group by project`})]}),(0,P.jsxs)(`div`,{className:`flex gap-1`,children:[(0,P.jsxs)(`select`,{value:d,onChange:e=>i({chatAgentProviderFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:``,children:`All types`}),(0,P.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,P.jsx)(`option`,{value:`codex`,children:`Codex`}),(0,P.jsx)(`option`,{value:`agent`,children:`Agent`}),(0,P.jsx)(`option`,{value:`user`,children:`User`})]}),(0,P.jsxs)(`select`,{value:p,onChange:e=>i({chatAgentStatusFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:``,children:`All status`}),(0,P.jsx)(`option`,{value:`online`,children:`Online`}),(0,P.jsx)(`option`,{value:`idle`,children:`Idle`}),(0,P.jsx)(`option`,{value:`busy`,children:`Busy`}),(0,P.jsx)(`option`,{value:`offline`,children:`Offline`})]}),E.length>1&&(0,P.jsxs)(`select`,{value:g,onChange:e=>i({chatAgentHostFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:``,children:`All hosts`}),E.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]})]}),(w.length>0||T.length>0)&&(0,P.jsxs)(`div`,{className:`flex gap-1`,children:[w.length>0&&(0,P.jsxs)(`select`,{value:m,onChange:e=>i({chatAgentTagFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:``,children:`All tags`}),w.map(e=>(0,P.jsxs)(`option`,{value:e,children:[`#`,e]},e))]}),T.length>0&&(0,P.jsxs)(`select`,{value:h,onChange:e=>i({chatAgentCapFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,P.jsx)(`option`,{value:``,children:`All caps`}),T.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,P.jsxs)(`button`,{type:`button`,className:`flex w-full shrink-0 items-center gap-2.5 border-b border-border px-3 py-2 text-left transition-colors hover:bg-muted/50`,onClick:o,children:[(0,P.jsx)(`div`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-dashed border-primary/50 bg-primary/10 text-primary`,children:(0,P.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium`,children:`New Agent`}),(0,P.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:`Spawn a fresh chat agent`})]})]}),(0,P.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:C.length===0?(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 text-center px-4`,children:[(0,P.jsx)(ce,{className:`w-8 h-8 text-zinc-600 mb-2`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No agents match filters`})]}):D?D.map(([e,t])=>(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-1.5 border-b border-border/50 bg-background/95 px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground backdrop-blur`,children:[(0,P.jsx)(`span`,{className:`truncate`,children:e}),(0,P.jsx)(`span`,{className:`text-muted-foreground/50`,children:t.length})]}),(0,P.jsx)(`ul`,{children:t.map(re)})]},e)):(0,P.jsx)(`ul`,{children:C.map(re)})})]})}var It=[{name:`/reply`,source:`skill`,description:`Reply to a relay message by id`,argumentHint:`<messageId> <body>`},{name:`/message`,source:`skill`,description:`Send a relay message to an agent, label, tag, or broadcast`,argumentHint:`<target> <body>`},{name:`/pair`,source:`skill`,description:`Start or manage a two-agent pair session`},{name:`/react`,source:`skill`,description:`Add a reaction to a relay message`,argumentHint:`<messageId> <emoji>`},{name:`/read-message`,source:`skill`,description:`Fetch a full relay message by id`,argumentHint:`<messageId>`},{name:`/send-claimable`,source:`skill`,description:`Enqueue a claimable work item for one agent to claim`},{name:`/status`,source:`skill`,description:`Show this agent's relay status`},{name:`/tags`,source:`skill`,description:`List or update this agent's relay tags`},{name:`/label`,source:`skill`,description:`Read, set, or clear this agent's relay label`},{name:`/disconnect`,source:`skill`,description:`End the current relay pair session`}],Lt=[{name:`/clear`,source:`builtin`,description:`Clear conversation history and free up context`},{name:`/compact`,source:`builtin`,description:`Compact the conversation to reclaim context`,argumentHint:`[instructions]`},{name:`/model`,source:`builtin`,description:`Switch the active model`,argumentHint:`[model]`},{name:`/help`,source:`builtin`,description:`Show help`}],Rt=[{name:`/compact`,source:`builtin`,description:`Compact the conversation to reclaim context`},{name:`/new`,source:`builtin`,description:`Start a new thread`}];function zt(e){return[...e===`claude`?Lt:e===`codex`?Rt:[],...It]}function Bt({selectedInboxThread:e,agent:t,now:n,blockedState:r,thread:a,exportableThread:s,importedHistory:u,showBackButton:d,onBack:f,openAgentDetail:m,openWorkspaceFocus:g,voiceTtsEnabled:v,setVoiceTtsEnabled:y,canOpenTerminal:x,terminalOpening:S,handleOpenTerminal:C,canInterrupt:w,interruptAgent:T,canCompact:E,canClearContext:ee,canShutdown:te,openConfirm:ie,workspaceAction:ae,doAgentAction:O,openFilesForAgent:oe,forkFromAgent:se,markInboxThreadUnread:ce,markInboxThreadRead:le,exportThread:ue}){return(0,P.jsxs)(`div`,{className:`flex items-center justify-between px-3 md:px-4 py-2.5 md:py-3 border-b border-border shrink-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 md:gap-2.5 min-w-0`,children:[d&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:f,className:`shrink-0 -ml-1`,children:(0,P.jsx)(ve,{className:`w-4 h-4`})}),(0,P.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 md:gap-2.5 min-w-0 hover:opacity-80 transition-opacity`,onClick:()=>t&&m(t),disabled:!t,children:[(0,P.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,P.jsx)(rt,{agent:t}),(0,P.jsx)(et,{agent:t,now:n,className:`absolute -bottom-0.5 -right-0.5 w-2 h-2`})]}),(0,P.jsxs)(`div`,{className:`min-w-0 text-left`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium truncate`,children:t?j(t):e}),t&&(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate`,children:[r?`blocked: ${r.label}`:t.status,t.machine&&` · ${t.machine}`,typeof t.meta?.cwd==`string`&&t.meta.cwd&&` · ${Oe(t.meta.cwd,1)}`]})]})]}),t&&(0,P.jsx)(nt,{agent:t,compact:!0,className:`hidden @4xl/chat:flex shrink-0`}),t?.context&&(0,P.jsx)(ut,{utilization:t.context.utilization}),t?.branchState&&t.branchWorkspaceId&&(0,P.jsx)(vt,{state:t.branchState,className:`shrink-0`,onClick:()=>void g(t.branchWorkspaceId)}),a?.attention.unread?(0,P.jsxs)(Ke,{className:`bg-red-500/20 text-red-400 text-xs shrink-0 hidden @2xl/chat:flex`,children:[a.attention.unread,` unread`]}):null]}),(0,P.jsx)(`div`,{className:`flex items-center gap-0.5 md:gap-1 shrink-0`,children:t&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Je,{value:t.id,label:`Copy agent ID`,size:`icon-sm`}),Se.available&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,title:v?`Speaking agent responses aloud — click to mute (engine & voice in Settings)`:`Speak agent responses aloud (active chat) — engine & voice in Settings`,className:v?`text-primary`:``,onClick:()=>y(!v),children:v?(0,P.jsx)(D,{className:`w-3.5 h-3.5`}):(0,P.jsx)(pe,{className:`w-3.5 h-3.5`})}),x&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,disabled:S,title:`Terminal`,onClick:()=>void C(),children:(0,P.jsx)(re,{className:`w-3.5 h-3.5`})}),w&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`text-red-400 hover:text-red-300`,title:`Interrupt`,onClick:T,children:(0,P.jsx)(h,{className:`w-3.5 h-3.5`})}),(t.branchState===`changes`||t.branchState===`idle`)&&t.branchWorkspaceId&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex text-amber-400 hover:text-amber-300`,title:`Mark workspace ready — hand off to the auto-merge`,onClick:()=>ie(`Mark Workspace Ready`,`Mark ${j(t)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>ae(t.branchWorkspaceId,`ready`)),children:(0,P.jsx)(i,{className:`w-3.5 h-3.5`})}),E&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Compact`,onClick:()=>ie(`Compact Agent`,`Compact context for ${j(t)}?`,()=>O(t,`compact`)),children:(0,P.jsx)(l,{className:`w-3.5 h-3.5`})}),ee&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Clear context`,onClick:()=>ie(`Clear Context`,`Clear context for ${j(t)}?`,()=>O(t,`clearContext`)),children:(0,P.jsx)(c,{className:`w-3.5 h-3.5`})}),te&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Shutdown`,onClick:()=>ie(`Shutdown Agent`,`Shutdown ${j(t)}?`,()=>O(t,`shutdown`)),children:(0,P.jsx)(b,{className:`w-3.5 h-3.5`})}),t&&typeof t.meta?.cwd==`string`&&t.meta.cwd&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Open ${t.meta.cwd} in Files`,onClick:()=>void oe(t),children:(0,P.jsx)(o,{className:`w-3.5 h-3.5`})}),t&&a&&a.messages.length>0&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Fork — spawn new agent with this chat history`,onClick:()=>se(t.id,a.messages),children:(0,P.jsx)(be,{className:`w-3.5 h-3.5`})}),a&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Mark unread`,onClick:()=>ce(e),children:(0,P.jsx)(ne,{className:`w-3.5 h-3.5`})}),a&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Mark read`,onClick:()=>le(a.peer,a.messages),children:(0,P.jsx)(he,{className:`w-3.5 h-3.5`})}),s&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Export thread`,onClick:()=>ue({...s,importedHistory:u},`json`),children:(0,P.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,P.jsxs)(Qe,{children:[(0,P.jsx)(Xe,{asChild:!0,children:(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`@4xl/chat:hidden`,children:(0,P.jsx)(p,{className:`w-3.5 h-3.5`})})}),(0,P.jsxs)(Ye,{align:`end`,children:[x&&(0,P.jsxs)(mt,{disabled:S,onClick:()=>void C(),children:[(0,P.jsx)(re,{className:`w-3.5 h-3.5`}),`Terminal`]}),w&&(0,P.jsxs)(mt,{onClick:T,children:[(0,P.jsx)(h,{className:`w-3.5 h-3.5`}),`Interrupt`]}),(t.branchState===`changes`||t.branchState===`idle`)&&t.branchWorkspaceId&&(0,P.jsxs)(mt,{onClick:()=>ie(`Mark Workspace Ready`,`Mark ${j(t)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>ae(t.branchWorkspaceId,`ready`)),children:[(0,P.jsx)(i,{className:`w-3.5 h-3.5`}),`Mark Ready`]}),E&&(0,P.jsxs)(mt,{onClick:()=>ie(`Compact Agent`,`Compact context for ${j(t)}?`,()=>O(t,`compact`)),children:[(0,P.jsx)(l,{className:`w-3.5 h-3.5`}),`Compact`]}),ee&&(0,P.jsxs)(mt,{onClick:()=>ie(`Clear Context`,`Clear context for ${j(t)}?`,()=>O(t,`clearContext`)),children:[(0,P.jsx)(c,{className:`w-3.5 h-3.5`}),`Clear Context`]}),te&&(0,P.jsxs)(mt,{onClick:()=>ie(`Shutdown Agent`,`Shutdown ${j(t)}?`,()=>O(t,`shutdown`)),children:[(0,P.jsx)(b,{className:`w-3.5 h-3.5`}),`Shutdown`]}),t&&typeof t.meta?.cwd==`string`&&t.meta.cwd&&(0,P.jsxs)(mt,{onClick:()=>void oe(t),children:[(0,P.jsx)(o,{className:`w-3.5 h-3.5`}),`Open Files`]}),t&&a&&a.messages.length>0&&(0,P.jsxs)(mt,{onClick:()=>se(t.id,a.messages),children:[(0,P.jsx)(be,{className:`w-3.5 h-3.5`}),`Fork`]}),(x||E||ee||te)&&(0,P.jsx)($e,{}),a&&(0,P.jsxs)(mt,{onClick:()=>ce(e),children:[(0,P.jsx)(ne,{className:`w-3.5 h-3.5`}),`Mark Unread`]}),a&&(0,P.jsxs)(mt,{onClick:()=>le(a.peer,a.messages),children:[(0,P.jsx)(he,{className:`w-3.5 h-3.5`}),`Mark Read`]}),s&&(0,P.jsxs)(mt,{onClick:()=>ue({...s,importedHistory:u},`json`),children:[(0,P.jsx)(_,{className:`w-3.5 h-3.5`}),`Download`]})]})]})]})})]})}function Vt({matches:e,activeIndex:t,onAccept:n,onHover:r}){return e.length===0?null:(0,P.jsx)(`div`,{className:`absolute bottom-full left-3 right-3 md:left-4 md:right-4 mb-2 z-20 max-h-64 overflow-auto rounded-xl border border-border bg-popover shadow-lg`,children:e.map((e,i)=>(0,P.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),n(e)},onMouseEnter:()=>r(i),className:y(`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm`,i===t?`bg-accent`:`hover:bg-accent/50`),children:[(0,P.jsx)(`span`,{className:`font-medium shrink-0`,children:e.name}),e.argumentHint&&(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:e.argumentHint}),e.description&&(0,P.jsx)(`span`,{className:`ml-auto truncate text-xs text-muted-foreground/70`,children:e.description})]},e.name))})}function Ht({value:e,onChange:t,onKeyDown:n,onPaste:r,placeholder:i,className:a}){let o=(0,N.useRef)(null);return(0,N.useEffect)(()=>{let e=o.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,200)+`px`)},[e]),(0,N.useEffect)(()=>{let e=window.visualViewport;if(!e)return;function t(){let e=o.current;!e||document.activeElement!==e||requestAnimationFrame(()=>{e.scrollIntoView({block:`nearest`,behavior:`smooth`})})}return e.addEventListener(`resize`,t),()=>e.removeEventListener(`resize`,t)},[]),(0,P.jsx)(`textarea`,{ref:o,value:e,onChange:t,onKeyDown:n,onPaste:r,placeholder:i,rows:1,className:y(`w-full resize-none rounded-xl border border-border bg-background px-3.5 py-2.5 text-sm`,`placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,`min-h-[42px] max-h-[200px] overflow-y-auto`,a)})}function Ut({item:e,onRemove:n}){let[r,i]=(0,N.useState)(!1),a=!!(e.previewUrl&&!e.error);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 text-xs`,children:[(0,P.jsx)(`button`,{type:`button`,disabled:!a,onClick:()=>i(!0),className:`group/pending relative flex h-9 w-9 shrink-0 items-center justify-center overflow-hidden rounded bg-muted disabled:cursor-default`,title:a?`Preview image`:e.fileName,children:e.previewUrl?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`img`,{src:e.previewUrl,alt:e.fileName,className:`h-full w-full object-cover`}),(0,P.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 group-hover/pending:bg-black/30 transition-colors`,children:(0,P.jsx)(de,{className:`h-3.5 w-3.5 text-white opacity-0 group-hover/pending:opacity-100 transition-opacity drop-shadow-md`})})]}):e.error?(0,P.jsx)(t,{className:`h-4 w-4 text-red-400`}):e.uploading?(0,P.jsx)(O,{className:`h-4 w-4 animate-spin text-muted-foreground`}):(0,P.jsx)(se,{className:`h-4 w-4 text-muted-foreground`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`p`,{className:`truncate font-medium`,children:e.fileName}),(0,P.jsx)(`p`,{className:y(`truncate text-muted-foreground`,e.error&&`text-red-400`),children:e.error||(e.uploading?`Uploading`:yt(e.size))})]}),(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,title:`Remove attachment`,onClick:n,children:(0,P.jsx)(ie,{className:`h-3.5 w-3.5`})})]}),e.previewUrl&&(0,P.jsx)(at,{open:r,onOpenChange:i,children:(0,P.jsxs)(tt,{className:`max-w-[95vw] max-h-[95vh] w-auto p-0 bg-black/95 border-zinc-800 gap-0 overflow-hidden`,showCloseButton:!1,children:[(0,P.jsx)(lt,{className:`sr-only`,children:e.fileName}),(0,P.jsxs)(`div`,{className:`relative flex items-center justify-center min-h-[200px]`,children:[(0,P.jsx)(`img`,{src:e.previewUrl,alt:e.fileName,className:`max-w-[93vw] max-h-[90vh] object-contain`}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>i(!1),className:`absolute top-2 right-2 rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Close`,children:(0,P.jsx)(ie,{className:`w-4 h-4`})})]})]})})]})}function Wt({draft:e,placeholder:t,chatSending:n,disabled:r,hasPendingUploads:i,readyAttachmentCount:o,pendingAttachments:s,micAvailable:c,micState:l,slashMatches:d,slashActiveIndex:f,onDraftChange:p,onKeyDown:m,onPaste:h,onUploadFiles:_,onRemovePendingAttachment:v,onSend:b,onAcceptSlash:x,onSlashHover:S,onStartPtt:C,onStopPtt:w,footerText:T}){let E=(0,N.useRef)(null),[D,ee]=(0,N.useState)(!1),te=!e.trim()&&o===0||i||n||r;return(0,P.jsxs)(`div`,{className:y(`relative shrink-0 border-t border-border px-3 md:px-4 py-2.5 md:py-3 safe-area-bottom`,D&&`bg-primary/5 ring-1 ring-primary/40`),onDragOver:e=>{e.preventDefault(),ee(!0)},onDragLeave:()=>ee(!1),onDrop:e=>{e.preventDefault(),ee(!1),_(e.dataTransfer.files)},children:[s.length>0&&(0,P.jsx)(`div`,{className:`mb-2 grid gap-2 sm:grid-cols-2`,children:s.map(e=>(0,P.jsx)(Ut,{item:e,onRemove:()=>v(e.id)},e.id))}),(0,P.jsx)(`input`,{ref:E,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&_(e.target.files),e.currentTarget.value=``}}),(0,P.jsx)(Vt,{matches:d,activeIndex:f,onAccept:x,onHover:S}),(0,P.jsxs)(`div`,{className:`hidden md:flex items-end gap-2`,children:[(0,P.jsx)(M,{variant:`ghost`,size:`icon`,title:`Attach files`,disabled:n,onClick:()=>E.current?.click(),className:`shrink-0 mb-0.5 rounded-xl h-[42px] w-[42px]`,children:(0,P.jsx)(u,{className:`w-4 h-4`})}),(0,P.jsx)(Ht,{value:e,onChange:e=>p(e.target.value),onKeyDown:m,onPaste:h,placeholder:t,className:`flex-1`}),c&&(0,P.jsx)(M,{variant:`ghost`,size:`icon`,title:l===`recording`?`Release to transcribe`:`Hold to talk`,disabled:n||l===`transcribing`,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),C()},onPointerUp:e=>{e.preventDefault();try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}w()},className:`shrink-0 mb-0.5 rounded-xl h-[42px] w-[42px] ${l===`recording`?`text-red-400 animate-pulse`:``}`,children:l===`transcribing`?(0,P.jsx)(O,{className:`w-4 h-4 animate-spin`}):(0,P.jsx)(g,{className:`w-4 h-4`})}),(0,P.jsx)(M,{size:`icon`,disabled:te,onClick:b,className:`shrink-0 mb-0.5 rounded-xl h-[42px] w-[42px]`,children:(0,P.jsx)(a,{className:`w-4 h-4`})})]}),(0,P.jsxs)(`div`,{className:`md:hidden space-y-2`,children:[(0,P.jsx)(Ht,{value:e,onChange:e=>p(e.target.value),onKeyDown:m,onPaste:h,placeholder:t,className:`w-full`}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(M,{variant:`ghost`,size:`icon`,title:`Attach files`,disabled:n,onClick:()=>E.current?.click(),className:`rounded-xl h-9 w-9`,children:(0,P.jsx)(u,{className:`w-4 h-4`})}),c&&(0,P.jsx)(M,{variant:`ghost`,size:`icon`,title:l===`recording`?`Release to transcribe`:`Hold to talk`,disabled:n||l===`transcribing`,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),C()},onPointerUp:e=>{e.preventDefault();try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}w()},className:`rounded-xl h-9 w-9 ${l===`recording`?`text-red-400 animate-pulse`:``}`,children:l===`transcribing`?(0,P.jsx)(O,{className:`w-4 h-4 animate-spin`}):(0,P.jsx)(g,{className:`w-4 h-4`})})]}),(0,P.jsx)(M,{size:`icon`,disabled:te,onClick:b,className:`rounded-xl h-9 w-9`,children:(0,P.jsx)(a,{className:`w-4 h-4`})})]})]}),T&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5 hidden md:block`,children:T})]})}var Gt=e(xe(),1);function Kt({preview:e,error:t,onReadError:n,onMouseEnter:r,onMouseLeave:i}){let{anchor:a}=e,o=Math.min(560,window.innerWidth-24),s=Math.min(380,window.innerHeight-24),c=Math.max(12,Math.min(a.left,window.innerWidth-o-12));return(0,Gt.createPortal)((0,P.jsxs)(`div`,{className:`fixed z-50 flex flex-col overflow-hidden rounded-lg border border-border bg-background shadow-xl`,style:{top:window.innerHeight-a.bottom>=s+8?a.bottom+8:a.top-8-s>=12?a.top-8-s:Math.max(12,window.innerHeight-s-12),left:c,width:o,height:s},onMouseEnter:r,onMouseLeave:i,children:[(0,P.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b border-border px-2.5`,children:[(0,P.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-medium text-muted-foreground`,children:e.path}),t&&(0,P.jsx)(`span`,{className:`max-w-[12rem] truncate text-[11px] text-red-400`,children:t}),(0,P.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/70`,children:`click to pin`})]}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1`,children:e.type===`directory`?(0,P.jsx)(pt,{orchestratorId:e.orchestratorId,selectedPath:e.path,onReadError:n}):(0,P.jsx)(ht,{orchestratorId:e.orchestratorId,selectedPath:e.path,line:e.line,onReadError:n})})]}),document.body)}var qt={online:`came online`,offline:`went offline`,shutdown:`shut down`,restarted:`restarted`,"compaction-requested":`compaction requested`,compacting:`compaction started`,compacted:`context compacted`,"compaction-stalled":`compaction stalled — may need manual intervention`,"clear-requested":`clear requested`,"clearing-context":`clear started`,"context-cleared":`context cleared`,"clear-stalled":`context clear stalled — may need manual intervention`,"shutting-down":`shutting down`},Jt=new Set(Object.keys(qt)),Yt=3e3;function Xt(e){return new Date(e.occurredAt??e.createdAt).getTime()}function Zt(e){if(e.kind!==`session`)return null;let t=e.payload?.session;return!t||t.type!==`narration`&&t.type!==`reasoning`&&t.type!==`tool`?null:{id:e.id,kind:t.type,label:typeof t.label==`string`?t.label:void 0,text:e.body,ts:Xt(e),turnId:typeof t.turnId==`string`?t.turnId:void 0}}function Qt(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function $t(e){let t=e.filter(e=>Jt.has(e.status)).slice().sort((e,t)=>e.timestamp-t.timestamp),n=[];for(let e of t)n.some(t=>t.id===e.id)||n.some(t=>t.status===e.status&&Math.abs(t.timestamp-e.timestamp)<=Yt)||n.push(e);return n}function en(e,t,n,r=[]){let i=[];for(let e of r){let t=e.entries.reduce((e,t)=>Math.min(e,Fe(t.originalCreatedAt)),1/0),n=Number.isFinite(t)?t-1:e.importedAt;i.push({ts:n,entry:{type:`import-boundary`,history:e,timestamp:n}});for(let t of e.entries)i.push({ts:Fe(t.originalCreatedAt),entry:{type:`imported-message`,history:e,entry:t}})}if(n){let e=new Date(n).getTime();Number.isFinite(e)&&i.push({ts:e,entry:{type:`created`,timestamp:e}})}let a=new Map;for(let t of e){if(t.kind!==`session`)continue;let e=t.payload?.session;if(e?.type===`response`&&typeof e.turnId==`string`){let n=a.get(e.turnId)??[];n.push(t.body.trim()),a.set(e.turnId,n)}}for(let t of e){let e=Zt(t);if(e){if(e.kind===`narration`&&e.turnId&&a.get(e.turnId)?.some(t=>Pe(t,e.text)))continue;i.push({ts:e.ts,entry:{type:`activity`,steps:[e],timestamp:e.ts}});continue}i.push({ts:Xt(t),entry:{type:`message`,msg:t}})}for(let e of $t(t))i.push({ts:e.timestamp,entry:{type:`status`,event:e}});let o={created:0,date:1,"import-boundary":2,"imported-message":3,message:4,activity:4,status:5};i.sort((e,t)=>{let n=e.ts-t.ts;return Math.abs(n)<3e3&&o[e.entry.type]-o[t.entry.type]||n});let s=[],c=``;for(let{ts:e,entry:t}of i){if(t.type===`created`){s.push(t);continue}let n=Qt(e);if(n!==c&&(s.push({type:`date`,date:n,timestamp:e}),c=n),t.type===`activity`){let e=s[s.length-1];if(e&&e.type===`activity`&&tn(e,t)){e.steps.push(...t.steps);continue}}s.push(t)}return s}function tn(e,t){let n=e.steps[e.steps.length-1]?.turnId,r=t.steps[0]?.turnId;return n&&r?n===r:!n&&!r}var nn=[];function rn(e){return k(t=>t.chatStatusEvents[e]??nn)}function an(e,t){let n=(0,N.useRef)(!1);(0,N.useEffect)(()=>{if(!e)return;n.current||=(window.history.pushState({chatGuard:!0},``),!0);function r(e){(e.state?.chatGuard!==void 0||!n.current)&&(window.history.pushState({chatGuard:!0},``),t())}function i(e){e.preventDefault()}return window.addEventListener(`popstate`,r),window.addEventListener(`beforeunload`,i),()=>{window.removeEventListener(`popstate`,r),window.removeEventListener(`beforeunload`,i)}},[e,t]),(0,N.useEffect)(()=>{!e&&n.current&&(n.current=!1)},[e])}var on=0,sn=1,cn=2,ln=4;function un(e){return()=>e}function dn(e){e()}function fn(e,t){return n=>e(t(n))}function pn(e,t){return()=>e(t)}function mn(e,t){return n=>e(t,n)}function hn(e){return e!==void 0}function gn(...e){return()=>{e.map(dn)}}function _n(){}function vn(e,t){return t(e),e}function yn(e,t){return t(e)}function F(...e){return e}function I(e,t){return e(sn,t)}function L(e,t){e(on,t)}function bn(e){e(cn)}function R(e){return e(ln)}function z(e,t){return I(e,mn(t,on))}function xn(e,t){let n=e(sn,e=>{n(),t(e)});return n}function Sn(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Cn(e,t){return e===t}function B(e=Cn){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function V(e){return t=>n=>{e(n)&&t(n)}}function H(e){return t=>fn(t,e)}function wn(e){return t=>()=>{t(e)}}function U(e,...t){let n=On(...t);return((t,r)=>{switch(t){case cn:bn(e);return;case sn:return I(e,n(r))}})}function Tn(e,t){return n=>r=>{n(t=e(t,r))}}function En(e){return t=>n=>{e>0?e--:t(n)}}function Dn(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function W(...e){let t=Array(e.length),n=0,r=null,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;I(e,e=>{let s=n;n|=o,t[a]=e,s!==i&&n===i&&r&&(r(),r=null)})}),e=>a=>{let o=()=>{e([a].concat(t))};n===i?o():r=o}}function On(...e){return t=>e.reduceRight(yn,t)}function kn(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case sn:return a?n===a?void 0:(r(),n=a,t=I(e,a),t):(r(),_n);case cn:r(),n=null;return}}}function G(e){let t=e,n=K();return((e,r)=>{switch(e){case on:t=r;break;case sn:r(t);break;case ln:return t}return n(e,r)})}function An(e,t){return vn(G(t),t=>z(e,t))}function K(){let e=[];return((t,n)=>{switch(t){case on:e.slice().forEach(e=>{e(n)});return;case cn:e.splice(0,e.length);return;case sn:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function jn(e){return vn(K(),t=>z(e,t))}function q(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Mn(),singleton:n}}var Mn=()=>Symbol();function Nn(e){let t=new Map,n=({constructor:e,dependencies:r,id:i,singleton:a})=>{if(a&&t.has(i))return t.get(i);let o=e(r.map(e=>n(e)));return a&&t.set(i,o),o};return n(e)}function Pn(...e){let t=K(),n=Array(e.length),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;I(e,e=>{n[a]=e,r|=o,r===i&&L(t,n)})}),function(e,a){switch(e){case cn:bn(t);return;case sn:return r===i&&a(n),I(t,a)}}}function J(e,t=Cn){return U(e,B(t))}function Fn(...e){return function(t,n){switch(t){case cn:return;case sn:return gn(...e.map(e=>I(e,n)))}}}var In={DEBUG:0,INFO:1,WARN:2,ERROR:3},Ln={[In.DEBUG]:`debug`,[In.ERROR]:`error`,[In.INFO]:`log`,[In.WARN]:`warn`},Rn=()=>typeof globalThis>`u`?window:globalThis,zn=q(()=>{let e=G(In.ERROR);return{log:G((t,n,r=In.INFO)=>{r>=(Rn().VIRTUOSO_LOG_LEVEL??R(e))&&console[Ln[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0}),Bn=new WeakMap;function Vn(e){return`self`in e?e.document.documentElement:e}function Hn(e){let t=Vn(e),n=Bn.get(t);if(n!==void 0)return n;let r=t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`;return Bn.set(t,r),r}function Un(e){Bn.delete(Vn(e))}function Wn(e,t){return Hn(e)?-t:t}var Gn=Wn;function Kn(e,t){return Wn(e,t)}function qn(e,t,n){return Jn(e,t,n).callbackRef}function Jn(e,t,n){let r=N.useRef(null),i=e=>{},a=N.useMemo(()=>typeof ResizeObserver<`u`?new ResizeObserver(t=>{let r=()=>{let n=t[0].target;n.offsetParent!==null&&e(n)};n?r():requestAnimationFrame(r)}):null,[e,n]);return i=e=>{e&&t?(a?.observe(e),r.current=e):(r.current&&a?.unobserve(r.current),r.current=null)},{callbackRef:i,ref:r}}function Yn(e,t,n,r,i,a,o,s,c){return Jn(N.useCallback(n=>{let c=Xn(n.children,t,s?`offsetWidth`:`offsetHeight`,i),l=n.parentElement;for(;l.dataset.virtuosoScroller===void 0;)l=l.parentElement;let u=l.lastElementChild.dataset.viewportType===`window`,d;u&&(d=l.ownerDocument.defaultView);let f=o?s?o.scrollWidth:o.scrollHeight:u?s?d.document.documentElement.scrollWidth:d.document.documentElement.scrollHeight:s?l.scrollWidth:l.scrollHeight,p=o?s?o.offsetWidth:o.offsetHeight:u?s?d.innerWidth:d.innerHeight:s?l.offsetWidth:l.offsetHeight,m=o?s?Gn(o,o.scrollLeft):o.scrollTop:u?s?Gn(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?Gn(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?Zn(`column-gap`,getComputedStyle(n).columnGap,i):Zn(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function Xn(e,t,n,r){let i=e.length;if(i===0)return null;let a=[];for(let o=0;o<i;o++){let i=e.item(o);if(i.dataset.index===void 0)continue;let s=parseInt(i.dataset.index),c=parseFloat(i.dataset.knownSize),l=t(i,n);if(l===0&&r(`Zero-sized element, this should not happen`,{child:i},In.ERROR),l===c)continue;let u=a[a.length-1];a.length===0||u.size!==l||u.endIndex!==s-1?a.push({endIndex:s,size:l,startIndex:s}):a[a.length-1].endIndex++}return a}function Zn(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,In.WARN),t===`normal`?0:parseInt(t??`0`,10)}function Qn(e,t,n){let r=N.useRef(null),i=N.useCallback(n=>{if(!n?.offsetParent)return;let i=n.getBoundingClientRect(),a=i.width,s,c;if(t){let e=t.getBoundingClientRect(),n=i.top-e.top;c=e.height-Math.max(0,n),s=n+t.scrollTop}else{let e=o.current.ownerDocument.defaultView;c=e.innerHeight-Math.max(0,i.top),s=i.top+e.scrollY}r.current={listHeight:i.height,offsetTop:s,visibleHeight:c,visibleWidth:a},e(r.current)},[e,t]),{callbackRef:a,ref:o}=Jn(i,!0,n),s=N.useCallback(()=>{i(o.current)},[i,o]);return N.useEffect(()=>{if(t){t.addEventListener(`scroll`,s);let e=new ResizeObserver(()=>{requestAnimationFrame(s)});return e.observe(t),()=>{t.removeEventListener(`scroll`,s),e.unobserve(t)}}let e=o.current?.ownerDocument.defaultView;return e?.addEventListener(`scroll`,s),e?.addEventListener(`resize`,s),()=>{e?.removeEventListener(`scroll`,s),e?.removeEventListener(`resize`,s)}},[s,t,o]),a}var $n=q(()=>{let e=K(),t=K(),n=G(0),r=K(),i=G(0),a=K(),o=K(),s=G(0),c=G(0),l=G(0),u=G(0),d=K(),f=K(),p=G(!1),m=G(!1),h=G(!1);return z(U(e,H(({scrollTop:e})=>e)),t),z(U(e,H(({scrollHeight:e})=>e)),o),z(t,i),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:s,horizontalDirection:m,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:p,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:h,smoothScrollTargetReached:r,statefulScrollTop:i,viewportHeight:a}},[],{singleton:!0}),er={lvl:0};function tr(e,t){let n=e.length;if(n===0)return[];let{index:r,value:i}=t(e[0]),a=[];for(let o=1;o<n;o++){let{index:n,value:s}=t(e[o]);a.push({end:n-1,start:r,value:i}),r=n,i=s}return a.push({end:1/0,start:r,value:i}),a}function Y(e){return e===er}function nr(e,t){if(!Y(e))return t===e.k?e.v:t<e.k?nr(e.l,t):nr(e.r,t)}function rr(e,t,n=`k`){if(Y(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){let r=rr(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return rr(e.l,t,n)}function ir(e,t,n){return Y(e)?hr(t,n,1):t===e.k?dr(e,{k:t,v:n}):t<e.k?gr(dr(e,{l:ir(e.l,t,n)})):gr(dr(e,{r:ir(e.r,t,n)}))}function ar(){return er}function or(e,t,n){if(Y(e))return[];let r=rr(e,t)[0];return yr(lr(e,r,n))}function sr(e,t){if(Y(e))return er;let{k:n,l:r,r:i}=e;if(t===n){if(Y(r))return i;if(Y(i))return r;let[t,n]=mr(r);return ur(dr(e,{k:t,l:fr(r),v:n}))}return ur(t<n?dr(e,{l:sr(r,t)}):dr(e,{r:sr(i,t)}))}function cr(e){return Y(e)?[]:[...cr(e.l),{k:e.k,v:e.v},...cr(e.r)]}function lr(e,t,n){if(Y(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(lr(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(lr(a,t,n))),s}function ur(e){let{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(pr(t))return _r(dr(e,{lvl:n-1}));if(!Y(t)&&!Y(t.r))return dr(t.r,{l:dr(t,{r:t.r.l}),lvl:n,r:dr(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(pr(e))return vr(dr(e,{lvl:n-1}));if(!Y(r)&&!Y(r.l)){let t=r.l,i=pr(t)?r.lvl-1:r.lvl;return dr(t,{l:dr(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:vr(dr(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function dr(e,t){return hr(t.k===void 0?e.k:t.k,t.v===void 0?e.v:t.v,t.lvl===void 0?e.lvl:t.lvl,t.l===void 0?e.l:t.l,t.r===void 0?e.r:t.r)}function fr(e){return Y(e.r)?e.l:ur(dr(e,{r:fr(e.r)}))}function pr(e){return Y(e)||e.lvl>e.r.lvl}function mr(e){return Y(e.r)?[e.k,e.v]:mr(e.r)}function hr(e,t,n,r=er,i=er){return{k:e,l:r,lvl:n,r:i,v:t}}function gr(e){return vr(_r(e))}function _r(e){let{l:t}=e;return!Y(t)&&t.lvl===e.lvl?dr(t,{r:dr(e,{l:t.r})}):e}function vr(e){let{lvl:t,r:n}=e;return!Y(n)&&!Y(n.r)&&n.lvl===t&&n.r.lvl===t?dr(n,{l:dr(e,{r:n.l}),lvl:t+1}):e}function yr(e){return tr(e,({k:e,v:t})=>({index:e,value:t}))}function br(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function xr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var Sr=q(()=>({recalcInProgress:G(!1)}),[],{singleton:!0});function Cr(e,t,n){return e[wr(e,t,n)]}function wr(e,t,n,r=0){let i=e.length-1;for(;r<=i;){let a=Math.floor((r+i)/2),o=e[a],s=n(o,t);if(s===0)return a;if(s===-1){if(i-r<2)return a-1;i=a-1}else{if(i===r)return a;r=a+1}}throw Error(`Failed binary finding record in array - ${e.join(`,`)}, searched for ${t}`)}function Tr(e,t,n,r){let i=wr(e,t,r),a=wr(e,n,r,i);return e.slice(i,a+1)}function Er(e,t){return Math.round(e.getBoundingClientRect()[t])}function Dr(e){return!Y(e.groupOffsetTree)}function Or({index:e},t){return t===e?0:t<e?-1:1}function kr(){return{groupIndices:[],groupOffsetTree:ar(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:ar()}}function Ar(e,t){let n=Y(e)?0:1/0;for(let r of t){let{endIndex:t,size:i,startIndex:a}=r;if(n=Math.min(n,a),Y(e)){e=ir(e,0,i);continue}let o=or(e,a-1,t+1);if(o.some(Hr(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=sr(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=ir(e,t+1,a));c&&(e=ir(e,a,i))}return[e,n]}function jr(e){return typeof e.groupIndex<`u`}function Mr({offset:e},t){return t===e?0:t<e?-1:1}function Nr(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=Cr(t,e,Or),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function Pr(e,t){if(!Dr(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Fr(e,t,n){if(jr(e))return t.groupIndices[e.groupIndex]+1;let r=Pr(e.index===`LAST`?n:e.index,t);return r=Math.max(0,r,Math.min(n,r)),r}function Ir(e,t,n,r=0){return r>0&&(t=Math.max(t,Cr(e,r,Or).offset)),tr(Tr(e,t,n,Mr),Vr)}function Lr(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,In.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&Y(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>ir(ir(t,n,e),n+1,r),o)}else [o,s]=Ar(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=Br(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>ir(e,t,Nr(t,d,i)),ar()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function Rr(e){return cr(e).map(({k:e,v:t},n,r)=>{let i=r[n+1];return{endIndex:i===void 0?1/0:i.k-1,size:t,startIndex:e}})}function zr(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function Br(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t!==0){c=wr(i,t-1,Or),s=i[c].offset;let e=rr(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===rr(n,t)[1]&&--c,i=i.slice(0,c+1)}else i=[];for(let{start:e,value:c}of or(n,t,1/0)){let t=e-a,n=t*o+s+t*r;i.push({index:e,offset:n,size:c}),a=e,s=n,o=c}return{lastIndex:a,lastOffset:s,lastSize:o,offsetTree:i}}function Vr(e){return{index:e.index,value:e}}function Hr(e){let{endIndex:t,size:n,startIndex:r}=e;return e=>e.start===r&&(e.end===t||e.end===1/0)&&e.value===n}var Ur={offsetHeight:`height`,offsetWidth:`width`},Wr=q(([{log:e},{recalcInProgress:t}])=>{let n=K(),r=K(),i=An(r,0),a=K(),o=K(),s=G(0),c=G([]),l=G(void 0),u=G(void 0),d=G(void 0),f=G(void 0),p=G((e,t)=>Er(e,Ur[t])),m=G(void 0),h=G(0),g=kr(),_=An(U(n,W(c,e,h),Tn(Lr,g),B()),g),v=An(U(c,B(),Tn((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),H(({prev:e})=>e)),[]);z(U(c,V(e=>e.length>0),W(_,h),H(([e,t,n])=>{let r=e.reduce((e,r,i)=>ir(e,r,Nr(r,t.offsetTree,n)||i),ar());return{...t,groupIndices:e,groupOffsetTree:r}})),_),z(U(r,W(_),V(([e,{lastIndex:t}])=>e<t),H(([e,{lastIndex:t,lastSize:n}])=>[{endIndex:t,size:n,startIndex:e}])),n),z(l,u);let y=An(U(l,H(e=>e===void 0)),!0);z(U(u,V(e=>e!==void 0&&Y(R(_).sizeTree)),H(e=>{let t=R(d),n=R(c).length>0;return t!==void 0&&t!==0?n?[{endIndex:0,size:t,startIndex:0},{endIndex:1,size:e,startIndex:1}]:[]:[{endIndex:0,size:e,startIndex:0}]})),n),z(U(f,V(e=>e!==void 0&&e.length>0&&Y(R(_).sizeTree)),H(e=>{let t=[],n=e[0],r=0;for(let i=1;i<e.length;i++){let a=e[i];a!==n&&(t.push({endIndex:i-1,size:n,startIndex:r}),n=a,r=i)}return t.push({endIndex:e.length-1,size:n,startIndex:r}),t})),n),z(U(c,W(d,u),V(([,e,t])=>e!==void 0&&t!==void 0),H(([e,t,n])=>{let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=e[i+1];r.push({startIndex:a,endIndex:a,size:t}),o!==void 0&&r.push({startIndex:a+1,endIndex:o-1,size:n})}return r})),n);let b=jn(U(n,W(_),Tn(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),H(e=>e.changed)));I(U(s,Tn((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),H(e=>e.diff)),e=>{let{groupIndices:n}=R(_);if(e>0)L(t,!0),L(a,e+zr(e,n));else if(e<0){let t=R(v);t.length>0&&(e-=zr(-e,t)),L(o,e)}}),I(U(s,W(e)),([e,t])=>{e<0&&t("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:s},In.ERROR)});let x=jn(a);z(U(a,W(_),H(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=nr(t.sizeTree,0),a=0,o=0;for(;a<e;){let e=t.groupIndices[o],s=t.groupIndices.length===o+1?1/0:t.groupIndices[o+1]-e-1;r.push({endIndex:e,size:n,startIndex:e}),r.push({endIndex:e+1+s-1,size:i,startIndex:e+1}),o++,a+=s+1}let s=cr(t.sizeTree);return a!==e&&s.shift(),s.reduce((t,{k:n,v:r})=>{let i=t.ranges;return t.prevSize!==0&&(i=[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]),{prevIndex:n+e,prevSize:r,ranges:i}},{prevIndex:e,prevSize:0,ranges:r}).ranges}return cr(t.sizeTree).reduce((t,{k:n,v:r})=>({prevIndex:n+e,prevSize:r,ranges:[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]}),{prevIndex:0,prevSize:i,ranges:[]}).ranges})),n);let S=jn(U(o,W(_,h),H(([e,{offsetTree:t},n])=>Nr(-e,t,n))));return z(U(o,W(_,h),H(([e,t,n])=>{if(t.groupIndices.length>0){if(Y(t.sizeTree))return t;let r=ar(),i=R(v),a=0,o=0,s=0;for(;a<-e;){s=i[o];let e=i[o+1]-s-1;o++,a+=e+1}if(r=cr(t.sizeTree).reduce((t,{k:n,v:r})=>ir(t,Math.max(0,n+e),r),r),a!==-e){let n=nr(t.sizeTree,s);r=ir(r,0,n);let i=rr(t.sizeTree,-e+1)[1];r=ir(r,1,i)}return{...t,sizeTree:r,...Br(t.offsetTree,0,r,n)}}let r=cr(t.sizeTree).reduce((t,{k:n,v:r})=>ir(t,Math.max(0,n+e),r),ar());return{...t,sizeTree:r,...Br(t.offsetTree,0,r,n)}})),_),{beforeUnshiftWith:x,data:m,defaultItemSize:u,firstItemIndex:s,fixedItemSize:l,fixedGroupSize:d,gap:h,groupIndices:c,heightEstimates:f,itemSize:p,listRefresh:b,shiftWith:o,shiftWithOffset:S,sizeRanges:n,sizes:_,statefulTotalCount:i,totalCount:r,trackItemSizes:y,unshiftWith:a}},F(zn,Sr),{singleton:!0});function Gr(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var Kr=q(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=K(),o=K(),s=jn(U(a,H(Gr)));return z(U(s,H(e=>e.totalCount)),n),z(U(s,H(e=>e.groupIndices)),e),z(U(Pn(i,t,r),V(([e,t])=>Dr(t)),H(([e,t,n])=>rr(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),B(),H(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},F(Wr,$n)),qr=q(([{log:e}])=>{let t=G(!1),n=jn(U(t,V(e=>e),B()));return I(t,t=>{t&&R(e)(`props updated`,{},In.DEBUG)}),{didMount:n,propsReady:t}},F(zn),{singleton:!0}),Jr=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function Yr(e){let t=typeof e==`number`?{index:e}:e;return t.align||=`start`,(!t.behavior||!Jr)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var Xr=q(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:i,fixedHeaderHeight:a,footerHeight:o,headerHeight:s,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{let p=K(),m=K(),h=G(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),L(c,!1)}return z(U(p,W(n,d,r,h,s,o,f),W(e,a,i),H(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=Yr(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=Fr(b,n,w),E=Nr(T,n.offsetTree,d)+o;x===`end`?(E+=f+rr(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+rr(n.sizeTree,T)[1]-r+h)/2:E-=a,C!==void 0&&C!==0&&(E+=C);let D=t=>{y(),t?(l(`retrying to scroll to`,{location:e},In.DEBUG),L(p,e)):(L(m,!0),l(`list did not change, scroll successful`,{},In.DEBUG))};if(y(),S===`smooth`){let e=!1;v=I(t,t=>{e||=t}),g=xn(u,()=>{D(e)})}else g=xn(U(t,Zr(150)),D);return _=setTimeout(()=>{y()},1200),L(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},In.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},F(Wr,$n,zn),{singleton:!0});function Zr(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function Qr(e,t){e===0?t():requestAnimationFrame(()=>{Qr(e-1,t)})}function $r(e,t){let n=t-1;return typeof e==`number`?e:e.index===`LAST`?n:e.index}var ei=q(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=G(!0),c=G(0),l=G(!0);return z(U(o,W(c),V(([e,t])=>t!==0),wn(!1)),s),z(U(o,W(c),V(([e,t])=>t!==0),wn(!1)),l),I(U(Pn(t,o),W(s,n,e,l),V(([[,e],t,{sizeTree:n},r,i])=>e&&(!Y(n)||hn(r))&&!t&&!i),W(c)),([,e])=>{xn(i,()=>{L(l,!0)}),Qr(4,()=>{xn(r,()=>{L(s,!0)}),L(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},F(Wr,$n,Xr,qr),{singleton:!0});function ti(e,t){return Math.abs(e-t)<1.01}var ni=`up`,ri=`down`,ii=`none`,ai={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},oi=0,si=q(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=G(!1),s=G(!0),c=K(),l=K(),u=G(4),d=G(oi),f=An(U(Fn(U(J(i),En(1),wn(!0)),U(J(i),En(1),wn(!1),Sn(100))),B()),!1),p=An(U(Fn(U(n,wn(!0)),U(n,wn(!1),Sn(200))),B()),!1);z(U(Pn(J(i),J(d)),H(([e,t])=>e<=t),B()),s),z(U(s,Dn(50)),l);let m=jn(U(Pn(r,J(a),J(t),J(e),J(u)),Tn((e,[{scrollHeight:t,scrollTop:n},r,i,a,o])=>{let s=n+r-t>-o,c={scrollHeight:t,scrollTop:n,viewportHeight:r};if(s){let t,r;return n>e.state.scrollTop?(t=`SCROLLED_DOWN`,r=e.state.scrollTop-n):(t=`SIZE_DECREASED`,r=e.state.scrollTop-n||e.scrollTopDelta),{atBottom:!0,atBottomBecause:t,scrollTopDelta:r,state:c}}let l;return l=c.scrollHeight>e.state.scrollHeight?`SIZE_INCREASED`:r<e.state.viewportHeight?`VIEWPORT_HEIGHT_DECREASING`:n<e.state.scrollTop?`SCROLLING_UPWARDS`:`NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM`,{atBottom:!1,notAtBottomBecause:l,state:c}},ai),B((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=An(U(r,Tn((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!ti(e.scrollHeight,t)){let i=t-(n+r)<1;return e.scrollTop!==n&&i?{changed:!0,jump:e.scrollTop-n,scrollHeight:t,scrollTop:n}:{changed:!0,jump:0,scrollHeight:t,scrollTop:n}}return{changed:!1,jump:0,scrollHeight:t,scrollTop:n}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),V(e=>e.changed),H(e=>e.jump)),0);z(U(m,H(e=>e.atBottom)),o),z(U(o,Dn(50)),c);let g=G(ri);z(U(r,H(({scrollTop:e})=>e),B(),Tn((e,t)=>R(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?ni:ri,prevScrollTop:t},{direction:ri,prevScrollTop:0}),H(e=>e.direction)),g),z(U(r,Dn(50),wn(ii)),g);let _=G(0);return z(U(f,V(e=>!e),wn(0)),_),z(U(i,Dn(100),W(f),V(([e,t])=>t),Tn(([e,t],[n])=>[t,n],[0,0]),H(([e,t])=>t-e)),_),{atBottomState:m,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:s,isScrolling:f,lastJumpDueToItemResize:h,scrollDirection:g,scrollVelocity:_}},F($n)),ci=`top`,li=`bottom`,ui=`none`;function di(e,t,n){return typeof e==`number`?n===ni&&t===ci||n===ri&&t===li?e:0:n===ni?t===ci?e.main:e.reverse:t===li?e.main:e.reverse}function fi(e,t){return typeof e==`number`?e:e[t]??0}var pi=q(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=K(),o=G(0),s=G(0),c=G(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:An(U(Pn(J(r),J(i),J(n),J(a,xr),J(c),J(o),J(t),J(e),J(s)),H(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=ui,m=fi(l,ci),h=fi(l,li);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=ni),i<e-f+t+h&&(p=ri),p===ui?null:[Math.max(u-n-di(a,ci,p)-m,0),u-f-s+t+di(a,li,p)+h]}),V(e=>e!==null),B(xr)),[0,0])}},F($n),{singleton:!0});function mi(e,t,n){if(Dr(t)){let r=Pr(e,t);return[{index:rr(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n?.[0],index:r,offset:0,size:0}]}return[{data:n?.[0],index:e,offset:0,size:0}]}var hi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function gi(e,t,n,r,i,a){let{lastIndex:o,lastOffset:s,lastSize:c}=i,l=0,u=0;if(e.length>0){l=e[0].offset;let t=e[e.length-1];u=t.offset+t.size}let d=n-o,f=s+d*c+(d-1)*r,p=l,m=f-u;return{bottom:u,firstItemIndex:a,items:vi(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:vi(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function _i(e,t,n,r,i,a){let o=0;if(n.groupIndices.length>0)for(let t of n.groupIndices){if(t-o>=e)break;o++}let s=e+o,c=$r(t,s);return gi(Array.from({length:s}).map((e,t)=>({data:a[t+c],index:t+c,offset:0,size:0})),[],s,i,n,r)}function vi(e,t,n){if(e.length===0)return[];if(!Dr(t))return e.map(e=>({...e,index:e.index+n,originalIndex:e.index}));let r=e[0].index,i=e[e.length-1].index,a=[],o=or(t.groupOffsetTree,r,i),s,c=0;for(let r of e){(!s||s.end<r.index)&&(s=o.shift(),c=t.groupIndices.indexOf(s.start));let e;e=r.index===s.start?{index:c,type:`group`}:{groupIndex:c,index:r.index-(c+1)+n},a.push({...e,data:r.data,offset:r.offset,originalIndex:r.index,size:r.size})}return a}function yi(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var bi=q(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:i},a,{listBoundary:o,topListHeight:s,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:d},f,{didMount:p},{recalcInProgress:m}])=>{let h=G([]),g=G(0),_=K(),v=G(0);z(a.topItemsIndexes,h);let y=An(U(Pn(p,m,J(c,xr),J(i),J(r),J(l),u,J(h),J(t),J(n),J(v),e),V(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),H(([,,[e,t],n,r,i,a,o,s,c,l,u])=>{let d=r,{offsetTree:f,sizeTree:p}=d,m=R(g);if(n===0)return{...hi,totalCount:n};if(e===0&&t===0)return m===0?{...hi,totalCount:n}:_i(m,i,r,s,c,u||[]);if(Y(p))return m>0?null:gi(mi($r(i,n),d,u),[],n,c,d,s);let h=[];if(o.length>0){let e=o[0],t=o[o.length-1],n=0;for(let r of or(p,e,t)){let i=r.value,a=Math.max(r.start,e),o=Math.min(r.end,t);for(let e=a;e<=o;e++)h.push({data:u?.[e],index:e,offset:n,size:i}),n+=i}}if(!a)return gi([],h,n,c,d,s);let _=o.length>0?o[o.length-1]+1:0,v=Ir(f,e,t,_);if(v.length===0)return null;let y=n-1,b=vn([],n=>{for(let r of v){let i=r.value,a=i.offset,o=r.start,s=i.size;if(i.offset<e){o+=Math.floor((e-i.offset+c)/(s+c));let t=o-r.start;a+=t*s+t*c}o<_&&(a+=(_-o)*s,o=_);let l=Math.min(r.end,y);for(let e=o;e<=l&&!(a>=t);e++)n.push({data:u?.[e],index:e,offset:a,size:s}),a+=s+c}}),x=yi(l,ci),S=yi(l,li);if(b.length>0&&(x>0||S>0)){let e=b[0],t=b[b.length-1];if(x>0&&e.index>_){let t=Math.min(x,e.index-_),n=[],r=e.offset;for(let i=e.index-1;i>=e.index-t;i--){let t=or(p,i,i)[0]?.value??e.size;r-=t+c,n.unshift({data:u?.[i],index:i,offset:r,size:t})}b.unshift(...n)}if(S>0&&t.index<y){let e=Math.min(S,y-t.index),n=t.offset+t.size+c;for(let r=t.index+1;r<=t.index+e;r++){let e=or(p,r,r)[0]?.value??t.size;b.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return gi(b,h,n,c,d,s)}),V(e=>e!==null),B()),hi);z(U(e,V(hn),H(e=>e?.length)),i),z(U(y,H(e=>e.topListHeight)),d),z(d,s),z(U(y,H(e=>[e.top,e.bottom])),o),z(U(y,H(e=>e.items)),_);let b=jn(U(y,V(({items:e})=>e.length>0),W(i,e),V(([{items:e},t])=>e[e.length-1].originalIndex===t-1),H(([,e,t])=>[e-1,t]),B(xr),H(([e])=>e))),x=jn(U(y,Dn(200),V(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),H(({items:e})=>e[0].index),B()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:jn(U(y,V(({items:e})=>e.length>0),H(({items:e})=>{let t=0,n=e.length-1;for(;e[t].type===`group`&&t<n;)t++;for(;e[n].type===`group`&&n>t;)n--;return{endIndex:e[n].index,startIndex:e[t].index}}),B(br))),startReached:x,topItemsIndexes:h,...f}},F(Wr,Kr,pi,ei,Xr,si,qr,Sr),{singleton:!0}),xi=q(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=K(),o=An(U(Pn(n,e,r,t,i),H(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return z(J(o),a),{totalListHeight:o,totalListHeightChanged:a}},F($n,bi),{singleton:!0}),Si=q(([{viewportHeight:e},{totalListHeight:t}])=>{let n=G(!1);return{alignToBottom:n,paddingTopAddition:An(U(Pn(n,e,t),V(([e])=>e),H(([,e,t])=>Math.max(0,e-t)),Dn(0),B()),0)}},F($n,xi),{singleton:!0}),Ci=q(()=>({context:G(null)})),wi=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...i},viewportBottom:a,viewportTop:o})=>t<o?{...i,align:n??`start`,...r===void 0?{}:{behavior:r}}:e>a?{...i,align:n??`end`,...r===void 0?{}:{behavior:r}}:null,Ti=q(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=K();return z(U(u,W(t,c,n,a,i,r,s),W(e),H(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=wi,done:d,...f}=e,p=Fr(e,t,r-1),m=Nr(p,t.offsetTree,l)+i+a,h=m+rr(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&xn(U(o,V(e=>!e),En(R(o)?1:2)),d),_}),V(e=>e!==null)),l),{scrollIntoView:u}},F(Wr,$n,Xr,bi,zn),{singleton:!0});function Ei(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var Di=(e,t)=>typeof e==`function`?Ei(e(t)):t&&Ei(e),Oi=q(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:i,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:s},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:p}])=>{let m=G(!1),h=K(),g=null;function _(e){L(o,{align:`end`,behavior:e,index:`LAST`})}I(U(Pn(U(J(t),En(1)),c),W(J(m),a,s,d),H(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=Di(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),V(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),R(n)===void 0?g=xn(e,()=>{R(u)(`following output to `,{totalCount:r},In.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{R(u)(`following output to `,{totalCount:r},In.DEBUG),_(t)})});function v(e){let t=xn(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(R(u)(`scrolling to bottom due to increased size`,{},In.DEBUG),_(`auto`))});setTimeout(t,100)}I(U(Pn(J(m),t,l),V(([e,,t])=>e!==!1&&t),Tn(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),V(({refreshed:e})=>e),W(m,t)),([,e])=>{R(s)&&v(e!==!1)}),I(h,()=>{v(R(m)!==!1)}),I(Pn(J(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=G(null),b=K();return z(Fn(U(J(r),H(e=>e?.length??0)),U(J(t))),b),I(U(Pn(U(b,En(1)),c),W(J(y),s,d,f),H(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),V(e=>!!e),Dn(0)),t=>{g!==null&&(g(),g=null),R(n)===void 0?g=xn(e,()=>{R(u)(`scrolling into view`,{}),L(p,t),g=null}):requestAnimationFrame(()=>{R(u)(`scrolling into view`,{}),L(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},F(Wr,si,Xr,ei,qr,zn,$n,Ci,Ti)),ki=q(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(z(U(s,W(a),V(([,e])=>e!==0),W(i,r,t,n,e),H(([[,e],t,n,r,i,a=[]])=>_i(e,t,n,r,i,a))),o),{}),F(Wr,ei,bi,qr),{singleton:!0}),Ai=q(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=G(0);return I(U(e,W(r),V(([,e])=>e!==0),H(([,e])=>({top:e}))),e=>{xn(U(n,En(1),V(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{L(t,e)})})}),{initialScrollTop:r}},F(qr,$n,bi),{singleton:!0}),ji=q(([{scrollVelocity:e}])=>{let t=G(!1),n=K(),r=G(!1);return z(U(e,W(r,t,n),V(([e,t])=>t!==!1&&t!==void 0),H(([e,t,n,r])=>{let{enter:i,exit:a}=t;if(n){if(a(e,r))return!1}else if(i(e,r))return!0;return n}),B()),t),I(U(Pn(t,e,n),W(r)),([[e,t,n],r])=>{e&&r!==!1&&r!==void 0&&r.change&&r.change(t,n)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},F(si),{singleton:!0}),Mi=q(([{scrollContainerState:e,scrollTo:t}])=>{let n=K(),r=K(),i=K(),a=G(!1),o=G(void 0);return z(U(Pn(n,r),H(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),z(U(t,W(r),H(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},F($n)),Ni=q(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=K(),u=G(void 0),d=G(null),f=G(null);return z(s,d),z(c,f),I(U(l,W(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=Rr(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),z(U(u,V(hn),H(Pi)),i),z(U(a,W(u),V(([,e])=>e!==void 0),B(),H(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},F(Wr,$n,ei,qr,Mi));function Pi(e){return{align:`start`,index:0,offset:e.scrollTop}}var Fi=q(([{topItemsIndexes:e}])=>{let t=G(0);return z(U(t,V(e=>e>=0),H(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},F(bi));function Ii(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var Li=Ii(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Ri=q(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:i,gap:a,groupIndices:o,heightEstimates:s,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g},_,v,y,b,{scrollToIndex:x},S,{topItemCount:C},{groupCounts:w},T])=>{let{listState:E,minOverscanItemCount:D,topItemsIndexes:ee,rangeChanged:te,...ne}=b;return z(te,T.scrollSeekRangeChanged),z(U(T.windowViewportRect,H(e=>e.visibleHeight)),_.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:i,gap:a,groupCounts:w,heightEstimates:s,initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g,sizeRanges:l,topItemCount:C,topItemsIndexes:ee,totalCount:f,...y,groupIndices:o,itemSize:c,listState:E,minOverscanItemCount:D,scrollToIndex:x,statefulTotalCount:d,trackItemSizes:p,rangeChanged:te,...ne,...T,..._,sizes:u,...v}},F(Wr,ei,$n,Ni,Oi,bi,Xr,q(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:i,isScrolling:a,lastJumpDueToItemResize:o,scrollDirection:s},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:d,sizes:f},{log:p},{recalcInProgress:m}])=>{let h=jn(U(c,W(o),Tn(([,e,t,n],[{bottom:r,items:i,offsetBottom:a,totalCount:o},s])=>{let c=r+a,l=0;return t===o&&e.length>0&&i.length>0&&(i[0].originalIndex===0&&e[0].originalIndex===0||(l=c-n,l!==0&&(l+=s))),[l,i,o,c]},[0,[],0,0]),V(([e])=>e!==0),W(r,s,n,i,p,m),V(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===ni),H(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},In.DEBUG),e))));function g(n){n>0?(L(t,{behavior:`auto`,top:-n}),L(e,0)):(L(e,0),L(t,{behavior:`auto`,top:-n}))}return I(U(h,W(e,a)),([t,n,r])=>{r&&Li()?L(e,n-t):g(-t)}),I(U(Pn(An(a,!1),e,m),V(([e,t,n])=>!e&&!n&&t!==0),H(([e,t])=>t),Dn(1)),g),z(U(d,H(e=>({top:-e}))),t),I(U(l,W(f,u),H(([e,{groupIndices:t,lastSize:n,sizeTree:r},i])=>{function a(e){return e*(n+i)}if(t.length===0)return a(e);let o=0,s=nr(r,0),c=0,l=0;for(;c<e;){c++,o+=s;let n=t.length===l+1?1/0:t[l+1]-t[l]-1;c+n>e&&(o-=s,n=e-c+1),c+=n,o+=a(n),l++}return o})),n=>{L(e,n),requestAnimationFrame(()=>{L(t,{top:n}),requestAnimationFrame(()=>{L(e,0),L(m,!1)})})}),{deviation:e}},F($n,si,bi,Wr,zn,Sr)),Fi,Kr,q(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),F(pi,ki,qr,ji,xi,Ai,Si,Mi,Ti,zn,Ci))));function zi(e,t){let n={},r={},i=0,a=e.length;for(;i<a;)r[e[i]]=1,i+=1;for(let e in t)Object.hasOwn(r,e)||(n[e]=t[e]);return n}var Bi=typeof document<`u`?N.useLayoutEffect:N.useEffect;function Vi(e,t,n){let r=Object.keys(t.required||{}),i=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),o=Object.keys(t.events||{}),s=N.createContext({});function c(e,n){e.propsReady!==void 0&&L(e.propsReady,!1);for(let i of r){let r=e[t.required[i]];L(r,n[i])}for(let r of i)if(r in n){let i=e[t.optional[r]];L(i,n[r])}e.propsReady!==void 0&&L(e.propsReady,!0)}function l(e){return a.reduce((n,r)=>(n[r]=n=>{let i=e[t.methods[r]];L(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=kn(e[t.events[r]]),n),{})}return{Component:N.forwardRef(function(t,a){let{children:d,...f}=t,[p]=N.useState(()=>vn(Nn(e),e=>{c(e,f)})),[m]=N.useState(pn(u,p));Bi(()=>{for(let e of o)e in f&&I(m[e],f[e]);return()=>{Object.values(m).map(bn)}},[f,m,p]),Bi(()=>{c(p,f)}),N.useImperativeHandle(a,un(l(p)));let h=n;return(0,P.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,P.jsx)(h,{...zi([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=N.useContext(s)[e];Bi(()=>I(n,t),[t,n])},useEmitterValue:e=>{let t=N.useContext(s)[e],n=N.useCallback(e=>I(t,e),[t]);return N.useSyncExternalStore(n,()=>R(t),()=>R(t))},usePublisher:e=>{let t=N.useContext(s);return N.useCallback(n=>{L(t[e],n)},[t,e])}}}var Hi=N.createContext(void 0),Ui=N.createContext(void 0),Wi=`-webkit-sticky`,Gi=`sticky`,Ki=Ii(()=>{if(typeof document>`u`)return Gi;let e=document.createElement(`div`);return e.style.position=Wi,e.style.position===Wi?Wi:Gi}),qi=typeof document<`u`?N.useLayoutEffect:N.useEffect;function Ji(e){return`self`in e}function Yi(e){return`body`in e}function Xi(e,t,n,r=_n,i,a){let o=N.useRef(null),s=N.useRef(null),c=N.useRef(null),l=N.useCallback(n=>{let r,i,o,l=n.target;if(Yi(l)||Ji(l)){let e=Ji(l)?l:l.defaultView;o=a===!0?Gn(e,e.scrollX):e.scrollY,r=a===!0?e.document.documentElement.scrollWidth:e.document.documentElement.scrollHeight,i=a===!0?e.innerWidth:e.innerHeight}else o=a===!0?Gn(l,l.scrollLeft):l.scrollTop,r=a===!0?l.scrollWidth:l.scrollHeight,i=a===!0?l.offsetWidth:l.offsetHeight;let u=()=>{e({scrollHeight:r,scrollTop:Math.max(o,0),viewportHeight:i})};n.suppressFlushSync===!0?u():Gt.flushSync(u),s.current!==null&&(o===s.current||o<=0||o===r-i)&&(s.current=null,t(!0),c.current&&=(clearTimeout(c.current),null))},[e,t,a]);N.useEffect(()=>{let e=i||o.current;return Un(e),r(i||o.current),l({suppressFlushSync:!0,target:e}),e.addEventListener(`scroll`,l,{passive:!0}),()=>{Un(e),r(null),e.removeEventListener(`scroll`,l)}},[o,l,n,r,i]);function u(n){let r=o.current;if(!r||(a===!0?`offsetWidth`in r&&r.offsetWidth===0:`offsetHeight`in r&&r.offsetHeight===0))return;let i=n.behavior===`smooth`,l,u,d;Ji(r)?(u=Math.max(Er(r.document.documentElement,a===!0?`width`:`height`),a===!0?r.document.documentElement.scrollWidth:r.document.documentElement.scrollHeight),l=a===!0?r.innerWidth:r.innerHeight,d=a===!0?Gn(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=Er(r,a===!0?`width`:`height`),d=a===!0?Gn(r,r.scrollLeft):r.scrollTop);let f=u-l;if(n.top===void 0){r.scrollTo(n);return}let p=Math.ceil(Math.max(Math.min(f,n.top),0));if(n.top=p,ti(l,u)||p===d){e({scrollHeight:u,scrollTop:d,viewportHeight:l}),i&&t(!0);return}i?(s.current=p,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,s.current=null,t(!0)},1e3)):s.current=null,a===!0&&(n={...n.behavior===void 0?{}:{behavior:n.behavior},left:Kn(r,p)}),r.scrollTo(n)}function d(e){a===!0&&(e={...e.behavior===void 0?{}:{behavior:e.behavior},...e.top===void 0?{}:{left:Kn(o.current,e.top)}}),o.current.scrollBy(e)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}function Zi(e){return e}var Qi=q(([e,t])=>({...e,...t}),F(Ri,q(()=>{let e=G(e=>`Item ${e}`),t=G(e=>`Group ${e}`),n=G({}),r=G(Zi),i=G(`div`),a=G(_n),o=(e,t=null)=>An(U(n,H(t=>t[e]),B()),t);return{components:n,computeItemKey:r,EmptyPlaceholder:o(`EmptyPlaceholder`),FooterComponent:o(`Footer`),GroupComponent:o(`Group`,`div`),groupContent:t,HeaderComponent:o(`Header`),HeaderFooterTag:i,ItemComponent:o(`Item`,`div`),itemContent:e,ListComponent:o(`List`,`div`),ScrollerComponent:o(`Scroller`,`div`),scrollerRef:a,ScrollSeekPlaceholder:o(`ScrollSeekPlaceholder`),TopItemListComponent:o(`TopItemList`)}}))),$i=({height:e})=>(0,P.jsx)(`div`,{style:{height:e}}),ea={overflowAnchor:`none`,position:Ki(),zIndex:1},ta={overflowAnchor:`none`},na={...ta,display:`inline-block`,height:`100%`},ra=N.memo(function({showTopList:e=!1}){let t=Z(`listState`),n=ya(`sizeRanges`),r=Z(`useWindowScroll`),i=Z(`customScrollParent`),a=ya(`windowScrollContainerState`),o=ya(`scrollContainerState`),s=i||r?a:o,c=Z(`itemContent`),l=Z(`context`),u=Z(`groupContent`),d=Z(`trackItemSizes`),f=Z(`itemSize`),p=Z(`log`),m=ya(`gap`),h=Z(`horizontalDirection`),{callbackRef:g}=Yn(n,f,d,e?_n:s,p,m,i,h,Z(`skipAnimationFrameInResizeObserver`)),[_,v]=N.useState(0);va(`deviation`,e=>{_!==e&&v(e)});let y=Z(`EmptyPlaceholder`),b=Z(`ScrollSeekPlaceholder`)??$i,x=Z(`ListComponent`),S=Z(`ItemComponent`),C=Z(`GroupComponent`),w=Z(`computeItemKey`),T=Z(`isSeeking`),E=Z(`groupIndices`).length>0,D=Z(`alignToBottom`),ee=Z(`initialItemFinalLocationReached`),te=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginInlineStart:_===0?D?`auto`:0:_,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:`nowrap`}:{marginTop:_===0?D?`auto`:0:_,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...ee?{}:{visibility:`hidden`}};return!e&&t.totalCount===0&&y!=null?(0,P.jsx)(y,{...X(y,l)}):(0,P.jsx)(x,{...X(x,l),"data-testid":e?`virtuoso-top-item-list`:`virtuoso-item-list`,ref:g,style:te,children:(e?t.topItems:t.items).map(e=>{let n=e.originalIndex,r=w(n+t.firstItemIndex,e.data,l);return T?(0,N.createElement)(b,{...X(b,l),height:e.size,index:e.index,key:r,type:e.type||`item`,...e.type===`group`?{}:{groupIndex:e.groupIndex}}):e.type===`group`?(0,N.createElement)(C,{...X(C,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:ea},u(e.index,l)):(0,N.createElement)(S,{...X(S,l),...la(S,e.data),"data-index":n,"data-item-group-index":e.groupIndex,"data-item-index":e.index,"data-known-size":e.size,key:r,style:h?na:ta},E?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),ia={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},aa={outline:`none`,overflowX:`auto`,position:`relative`},oa=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),sa=(e,t,n=0)=>({...oa(e),position:t?`relative`:`absolute`,top:t?-n:0}),ca={position:Ki(),top:0,width:`100%`,zIndex:1};function X(e,t){if(typeof e!=`string`)return{context:t}}function la(e,t){return{item:typeof e==`string`?void 0:t}}var ua=N.memo(function(){let e=Z(`HeaderComponent`),t=ya(`headerHeight`),n=Z(`HeaderFooterTag`),r=qn(N.useMemo(()=>e=>{t(Er(e,`height`))},[t]),!0,Z(`skipAnimationFrameInResizeObserver`)),i=Z(`context`);return e==null?null:(0,P.jsx)(n,{ref:r,children:(0,P.jsx)(e,{...X(e,i)})})}),da=N.memo(function(){let e=Z(`FooterComponent`),t=ya(`footerHeight`),n=Z(`HeaderFooterTag`),r=qn(N.useMemo(()=>e=>{t(Er(e,`height`))},[t]),!0,Z(`skipAnimationFrameInResizeObserver`)),i=Z(`context`);return e==null?null:(0,P.jsx)(n,{ref:r,children:(0,P.jsx)(e,{...X(e,i)})})});function fa({useEmitter:e,useEmitterValue:t,usePublisher:n}){return N.memo(function({children:r,style:i,context:a,...o}){let s=n(`scrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`scrollerRef`),d=t(`horizontalDirection`)||!1,{scrollByCallback:f,scrollerRef:p,scrollToCallback:m}=Xi(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,P.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?aa:ia,...i},tabIndex:0,...o,...X(c,a),children:r})})}function pa({useEmitter:e,useEmitterValue:t,usePublisher:n}){return N.memo(function({children:r,style:i,context:a,...o}){let s=n(`windowScrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`totalListHeight`),d=t(`deviation`),f=t(`customScrollParent`),p=N.useRef(null),{scrollByCallback:m,scrollerRef:h,scrollToCallback:g}=Xi(s,l,c,t(`scrollerRef`),f);return qi(()=>(h.current=f||p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,P.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...X(c,a),children:r})})}var ma=({children:e})=>{let t=N.useContext(Hi),n=ya(`viewportHeight`),r=ya(`fixedItemHeight`),i=Z(`alignToBottom`),a=Z(`horizontalDirection`),o=qn(N.useMemo(()=>fn(n,e=>Er(e,a?`width`:`height`)),[n,a]),!0,Z(`skipAnimationFrameInResizeObserver`));return N.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,P.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:oa(i),children:e})},ha=({children:e})=>{let t=N.useContext(Hi),n=ya(`windowViewportRect`),r=ya(`fixedItemHeight`),i=Z(`customScrollParent`),a=Z(`useWindowScroll`),o=Z(`topListHeight`),s=Qn(n,i,Z(`skipAnimationFrameInResizeObserver`)),c=Z(`alignToBottom`);return N.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,P.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:sa(c,a,o),children:e})},ga=({children:e})=>{let t=Z(`TopItemListComponent`)??`div`,n=Z(`headerHeight`);return(0,P.jsx)(t,{style:{...ca,marginTop:`${n}px`},...X(t,Z(`context`)),children:e})},{Component:_a,useEmitter:va,useEmitterValue:Z,usePublisher:ya}=Vi(Qi,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,scrollIntoViewOnChange:`scrollIntoViewOnChange`,itemContent:`itemContent`,groupContent:`groupContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,groupCounts:`groupCounts`,topItemCount:`topItemCount`,firstItemIndex:`firstItemIndex`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,heightEstimates:`heightEstimates`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`HeaderFooterTag`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,horizontalDirection:`horizontalDirection`,skipAnimationFrameInResizeObserver:`skipAnimationFrameInResizeObserver`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,autoscrollToBottom:`autoscrollToBottom`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},N.memo(function(e){let t=Z(`useWindowScroll`),n=Z(`topItemsIndexes`).length>0,r=Z(`customScrollParent`),i=Z(`context`);return(0,P.jsxs)(r||t?xa:ba,{...e,context:i,children:[n&&(0,P.jsx)(ga,{children:(0,P.jsx)(ra,{showTopList:!0})}),(0,P.jsxs)(r||t?ha:ma,{children:[(0,P.jsx)(ua,{}),(0,P.jsx)(ra,{}),(0,P.jsx)(da,{})]})]})})),ba=fa({useEmitter:va,useEmitterValue:Z,usePublisher:ya}),xa=pa({useEmitter:va,useEmitterValue:Z,usePublisher:ya}),Sa=_a,Ca=q(([e,t])=>({...e,...t}),F(Ri,q(()=>{let e=G(e=>(0,P.jsxs)(`td`,{children:[`Item $`,e]})),t=G(null),n=G(e=>(0,P.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=G(null),i=G(null),a=G({}),o=G(Zi),s=G(_n),c=(e,t=null)=>An(U(a,H(t=>t[e]),B()),t);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c(`EmptyPlaceholder`),FillerRow:c(`FillerRow`),fixedFooterContent:i,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`),TableBodyComponent:c(`TableBody`,`tbody`),TableComponent:c(`Table`,`table`),TableFooterComponent:c(`TableFoot`,`tfoot`),TableHeadComponent:c(`TableHead`,`thead`),TableRowComponent:c(`TableRow`,`tr`),GroupComponent:c(`Group`,`tr`)}}))),wa=({height:e})=>(0,P.jsx)(`tr`,{children:(0,P.jsx)(`td`,{style:{height:e}})}),Ta=({height:e})=>(0,P.jsx)(`tr`,{children:(0,P.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),Ea={overflowAnchor:`none`},Da={position:Ki(),zIndex:2,overflowAnchor:`none`},Oa=N.memo(function({showTopList:e=!1}){let t=Q(`listState`),n=Q(`computeItemKey`),r=Q(`firstItemIndex`),i=Q(`context`),a=Q(`isSeeking`),o=Q(`fixedHeaderHeight`),s=Q(`groupIndices`).length>0,c=Q(`itemContent`),l=Q(`groupContent`),u=Q(`ScrollSeekPlaceholder`)??wa,d=Q(`GroupComponent`),f=Q(`TableRowComponent`),p=(e?t.topItems:[]).reduce((e,t,n)=>(n===0?e.push(t.size):e.push(e[n-1]+t.size),e),[]);return(e?t.topItems:t.items).map(t=>{let m=t.originalIndex,h=n(m+r,t.data,i),g=e?m===0?0:p[m-1]:0;return a?(0,N.createElement)(u,{...X(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,N.createElement)(d,{...X(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...Da,top:o}},l(t.index,i)):(0,N.createElement)(f,{...X(f,i),...la(f,t.data),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,"data-item-group-index":t.groupIndex,key:h,style:e?{...Da,top:o+g}:Ea},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),ka=N.memo(function(){let e=Q(`listState`),t=Q(`topItemsIndexes`).length>0,n=Pa(`sizeRanges`),r=Q(`useWindowScroll`),i=Q(`customScrollParent`),a=Pa(`windowScrollContainerState`),o=Pa(`scrollContainerState`),s=i||r?a:o,c=Q(`trackItemSizes`),{callbackRef:l,ref:u}=Yn(n,Q(`itemSize`),c,s,Q(`log`),void 0,i,!1,Q(`skipAnimationFrameInResizeObserver`)),[d,f]=N.useState(0);Na(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=Q(`EmptyPlaceholder`),m=Q(`FillerRow`)??Ta,h=Q(`TableBodyComponent`),g=Q(`paddingTopAddition`),_=Q(`statefulTotalCount`),v=Q(`context`);if(_===0&&p!=null)return(0,P.jsx)(p,{...X(p,v)});let y=(t?e.topItems:[]).reduce((e,t)=>e+t.size,0),b=e.offsetTop+g+d-y,x=e.offsetBottom,S=b>0?(0,P.jsx)(m,{context:v,height:b},`padding-top`):null,C=x>0?(0,P.jsx)(m,{context:v,height:x},`padding-bottom`):null;return(0,P.jsxs)(h,{"data-testid":`virtuoso-item-list`,ref:l,...X(h,v),children:[S,t&&(0,P.jsx)(Oa,{showTopList:!0}),(0,P.jsx)(Oa,{}),C]})}),Aa=({children:e})=>{let t=N.useContext(Hi),n=Pa(`viewportHeight`),r=Pa(`fixedItemHeight`),i=qn(N.useMemo(()=>fn(n,e=>Er(e,`height`)),[n]),!0,Q(`skipAnimationFrameInResizeObserver`));return N.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,P.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:oa(!1),children:e})},ja=({children:e})=>{let t=N.useContext(Hi),n=Pa(`windowViewportRect`),r=Pa(`fixedItemHeight`),i=Q(`customScrollParent`),a=Q(`useWindowScroll`),o=Qn(n,i,Q(`skipAnimationFrameInResizeObserver`));return N.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,P.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:sa(!1,a),children:e})},{Component:Ma,useEmitter:Na,useEmitterValue:Q,usePublisher:Pa}=Vi(Ca,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,firstItemIndex:`firstItemIndex`,itemContent:`itemContent`,groupContent:`groupContent`,fixedHeaderContent:`fixedHeaderContent`,fixedFooterContent:`fixedFooterContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,topItemCount:`topItemCount`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,groupCounts:`groupCounts`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},N.memo(function(e){let t=Q(`useWindowScroll`),n=Q(`customScrollParent`),r=Pa(`fixedHeaderHeight`),i=Pa(`fixedFooterHeight`),a=Q(`fixedHeaderContent`),o=Q(`fixedFooterContent`),s=Q(`context`),c=qn(N.useMemo(()=>fn(r,e=>Er(e,`height`)),[r]),!0,Q(`skipAnimationFrameInResizeObserver`)),l=qn(N.useMemo(()=>fn(i,e=>Er(e,`height`)),[i]),!0,Q(`skipAnimationFrameInResizeObserver`)),u=n||t?Ia:Fa,d=n||t?ja:Aa,f=Q(`TableComponent`),p=Q(`TableHeadComponent`),m=Q(`TableFooterComponent`),h=a?(0,P.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...X(p,s),children:a()},`TableHead`):null,g=o?(0,P.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...X(m,s),children:o()},`TableFoot`):null;return(0,P.jsx)(u,{...e,...X(u,s),children:(0,P.jsx)(d,{children:(0,P.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...X(f,s),children:[h,(0,P.jsx)(ka,{},`TableBody`),g]})})})})),Fa=fa({useEmitter:Na,useEmitterValue:Q,usePublisher:Pa}),Ia=pa({useEmitter:Na,useEmitterValue:Q,usePublisher:Pa}),La={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Ra={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:za,floor:Ba,max:Va,min:Ha,round:Ua}=Math;function Wa(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function Ga(e){return{...Ra,items:e}}function Ka(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function qa(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var Ja=q(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:i,headerHeight:a,scrollBy:o,scrollContainerState:s,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,p,{didMount:m,propsReady:h},{customScrollParent:g,useWindowScroll:_,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b},x])=>{let S=G(0),C=G(0),w=G(La),T=G({height:0,width:0}),E=G({height:0,width:0}),D=K(),ee=K(),te=G(0),ne=G(null),re=G({column:0,row:0}),ie=K(),ae=K(),O=G(!1),oe=G(0),se=G(!0),ce=G(!1),le=G(!1);I(U(m,W(oe),V(([e,t])=>t!==0)),()=>{L(se,!1)}),I(U(Pn(m,se,E,T,oe,ce),V(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{L(ce,!0),Qr(1,()=>{L(D,e)}),xn(U(l),()=>{L(t,[0,0]),L(se,!0)})}),z(U(ae,V(e=>e!=null&&e.scrollTop>0),wn(0)),C),I(U(m,W(ae),V(([,e])=>e!=null)),([,e])=>{e&&(L(T,e.viewport),L(E,e.item),L(re,e.gap),e.scrollTop>0&&(L(O,!0),xn(U(l,En(1)),e=>{L(O,!1)}),L(c,{top:e.scrollTop})))}),z(U(T,H(({height:e})=>e)),d),z(U(Pn(J(T,Ka),J(E,Ka),J(re,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),J(l)),H(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),ie),z(U(Pn(J(S),r,J(re,qa),J(E,Ka),J(T,Ka),J(ne),J(C),J(O),J(se),J(oe)),V(([,,,,,,,e])=>!e),H(([e,[t,n],r,i,a,o,s,,c,l])=>{let{column:u,row:d}=r,{height:f,width:p}=i,{width:m}=a;if(s===0&&(e===0||m===0))return La;if(p===0){let t=$r(l,e);return Ga(Wa(t,t+Math.max(s-1,0),o))}let h=Ya(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*Ba((t+d)/(f+d)),_=h*za((n+d)/(f+d))-1,_=Ha(e-1,Va(_,h-1)),g=Ha(_,Va(0,g))):(g=0,_=-1);let v=Wa(g,_,o),{bottom:y,top:b}=Xa(a,r,i,v),x=za(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),z(U(ne,V(e=>e!==null),H(e=>e.length)),S),z(U(Pn(T,E,w,re),V(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),H(([e,t,{items:n},r])=>{let{bottom:i,top:a}=Xa(e,r,t,n);return[a,i]}),B(xr)),t);let ue=G(!1);z(U(l,W(ue),H(([e,t])=>t||e!==0)),ue);let de=jn(U(Pn(w,S),V(([{items:e}])=>e.length>0),W(ue),V(([[e,t],n])=>{let r=e.items[e.items.length-1].index===t-1;return(n||e.bottom>0&&e.itemHeight>0&&e.offsetBottom===0&&e.items.length===t)&&r}),H(([[,e]])=>e-1),B())),fe=jn(U(J(w),V(({items:e})=>e.length>0&&e[0].index===0),wn(0),B())),pe=jn(U(J(w),W(O),V(([{items:e},t])=>e.length>0&&!t),H(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),B(br),Dn(0)));z(pe,p.scrollSeekRangeChanged),z(U(D,W(T,E,S,re),H(([e,t,n,r,i])=>{let a=Yr(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=Va(0,l,Ha(r-1,l));let u=Za(t,i,n,l);return o===`end`?u=Ua(u-t.height+n.height):o===`center`&&(u=Ua(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let me=An(U(w,H(e=>e.offsetBottom+e.bottom)),0);return z(U(b,H(e=>({height:e.visibleHeight,width:e.visibleWidth}))),T),{customScrollParent:g,data:ne,deviation:te,footerHeight:i,gap:re,headerHeight:a,increaseViewportBy:e,initialItemCount:C,itemDimensions:E,overscan:n,restoreStateFrom:ae,scrollBy:o,scrollContainerState:s,scrollHeight:ee,scrollTo:c,scrollToIndex:D,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:_,viewportDimensions:T,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b,...p,gridState:w,horizontalDirection:le,initialTopMostItemIndex:oe,totalListHeight:me,...f,endReached:de,propsReady:h,rangeChanged:pe,startReached:fe,stateChanged:ie,stateRestoreInProgress:O,...x}},F(pi,$n,si,ji,qr,Mi,zn));function Ya(e,t,n){return Va(1,Ba((e+n)/(Ba(t)+n)))}function Xa(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=Za(e,t,n,r[0].index);return{bottom:Za(e,t,n,r[r.length-1].index)+i,top:a}}function Za(e,t,n,r){let i=Ba(r/Ya(e.width,n.width,t.column)),a=i*n.height+Va(0,i-1)*t.row;return a>0?a+t.row:a}var Qa=q(([e,t])=>({...e,...t}),F(Ja,q(()=>{let e=G(e=>`Item ${e}`),t=G({}),n=G(null),r=G(`virtuoso-grid-item`),i=G(`virtuoso-grid-list`),a=G(Zi),o=G(`div`),s=G(_n),c=(e,n=null)=>An(U(t,H(t=>t[e]),B()),n),l=G(!1),u=G(!1);return z(J(u),l),{components:t,computeItemKey:a,context:n,FooterComponent:c(`Footer`),HeaderComponent:c(`Header`),headerFooterTag:o,itemClassName:r,ItemComponent:c(`Item`,`div`),itemContent:e,listClassName:i,ListComponent:c(`List`,`div`),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`,`div`)}}))),$a=N.memo(function(){let e=$(`gridState`),t=$(`listClassName`),n=$(`itemClassName`),r=$(`itemContent`),i=$(`computeItemKey`),a=$(`isSeeking`),o=oo(`scrollHeight`),s=$(`ItemComponent`),c=$(`ListComponent`),l=$(`ScrollSeekPlaceholder`),u=$(`context`),d=oo(`itemDimensions`),f=oo(`gap`),p=$(`log`),m=$(`stateRestoreInProgress`),h=oo(`reportReadyState`),g=qn(N.useMemo(()=>e=>{let t=e.parentElement.parentElement.scrollHeight;o(t);let n=e.firstChild;if(n!==null){let{height:e,width:t}=n.getBoundingClientRect();d({height:e,width:t})}f({column:lo(`column-gap`,getComputedStyle(e).columnGap,p),row:lo(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return qi(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,P.jsx)(c,{className:t,ref:g,...X(c,u),"data-testid":`virtuoso-item-list`,style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(t=>{let o=i(t.index,t.data,u);return a?(0,P.jsx)(l,{...X(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,N.createElement)(s,{...X(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),eo=N.memo(function(){let e=$(`HeaderComponent`),t=oo(`headerHeight`),n=$(`headerFooterTag`),r=qn(N.useMemo(()=>e=>{t(Er(e,`height`))},[t]),!0,!1),i=$(`context`);return e==null?null:(0,P.jsx)(n,{ref:r,children:(0,P.jsx)(e,{...X(e,i)})})}),to=N.memo(function(){let e=$(`FooterComponent`),t=oo(`footerHeight`),n=$(`headerFooterTag`),r=qn(N.useMemo(()=>e=>{t(Er(e,`height`))},[t]),!0,!1),i=$(`context`);return e==null?null:(0,P.jsx)(n,{ref:r,children:(0,P.jsx)(e,{...X(e,i)})})}),no=({children:e})=>{let t=N.useContext(Ui),n=oo(`itemDimensions`),r=oo(`viewportDimensions`),i=qn(N.useMemo(()=>e=>{r(e.getBoundingClientRect())},[r]),!0,!1);return N.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),(0,P.jsx)(`div`,{ref:i,style:oa(!1),children:e})},ro=({children:e})=>{let t=N.useContext(Ui),n=oo(`windowViewportRect`),r=oo(`itemDimensions`),i=$(`customScrollParent`),a=$(`useWindowScroll`),o=Qn(n,i,!1);return N.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),(0,P.jsx)(`div`,{ref:o,style:sa(!1,a),children:e})},{Component:io,useEmitter:ao,useEmitterValue:$,usePublisher:oo}=Vi(Qa,{optional:{context:`context`,totalCount:`totalCount`,overscan:`overscan`,itemContent:`itemContent`,components:`components`,computeItemKey:`computeItemKey`,data:`data`,initialItemCount:`initialItemCount`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`headerFooterTag`,listClassName:`listClassName`,itemClassName:`itemClassName`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,restoreStateFrom:`restoreStateFrom`,initialTopMostItemIndex:`initialTopMostItemIndex`,increaseViewportBy:`increaseViewportBy`},methods:{scrollTo:`scrollTo`,scrollBy:`scrollBy`,scrollToIndex:`scrollToIndex`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,stateChanged:`stateChanged`,readyStateChanged:`readyStateChanged`}},N.memo(function({...e}){let t=$(`useWindowScroll`),n=$(`customScrollParent`),r=n||t?co:so,i=n||t?ro:no,a=$(`context`);return(0,P.jsx)(r,{...e,...X(r,a),children:(0,P.jsxs)(i,{children:[(0,P.jsx)(eo,{}),(0,P.jsx)($a,{}),(0,P.jsx)(to,{})]})})})),so=fa({useEmitter:ao,useEmitterValue:$,usePublisher:oo}),co=pa({useEmitter:ao,useEmitterValue:$,usePublisher:oo});function lo(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,In.WARN),t===`normal`?0:parseInt(t??`0`,10)}function uo(){return(0,N.useSyncExternalStore)(e=>Se.subscribe(e),()=>Se.getPlayingKey(),()=>null)}function fo({attachment:e,outbound:n}){let r=e.kind===`image`,i=e.title||e.artifactId,[a,o]=(0,N.useState)(null),[s,c]=(0,N.useState)(null),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(!1);(0,N.useEffect)(()=>{let t=!1,n=null;async function r(){u(!0),c(null),o(null);try{let r=await v(`/artifacts/${encodeURIComponent(e.artifactId)}/content`);if(t)return;n=URL.createObjectURL(r),o(n)}catch(e){t||c(e.message)}finally{t||u(!1)}}return r(),()=>{t=!0,n&&URL.revokeObjectURL(n)}},[e.artifactId]);function p(){if(!a)return;let e=document.createElement(`a`);e.href=a,e.download=i,document.body.appendChild(e),e.click(),e.remove()}return r?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>a&&f(!0),disabled:!a,className:`group/img mt-2 block overflow-hidden rounded-md border border-foreground/10 bg-black/10 text-left disabled:cursor-default relative`,children:a?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`img`,{src:a,alt:i,loading:`lazy`,className:`block max-h-72 max-w-full object-contain`}),(0,P.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 group-hover/img:bg-black/30 transition-colors`,children:(0,P.jsx)(de,{className:`w-6 h-6 text-white opacity-0 group-hover/img:opacity-100 transition-opacity drop-shadow-md`})})]}):(0,P.jsxs)(`span`,{className:y(`flex min-h-20 items-center gap-2 px-3 py-2 text-xs`,s?`text-red-400`:`text-muted-foreground`),children:[l?(0,P.jsx)(O,{className:`h-4 w-4 animate-spin`}):(0,P.jsx)(t,{className:`h-4 w-4`}),s||`Loading image`]})}),a&&(0,P.jsx)(at,{open:d,onOpenChange:f,children:(0,P.jsxs)(tt,{className:`max-w-[95vw] max-h-[95vh] w-auto p-0 bg-black/95 border-zinc-800 gap-0 overflow-hidden`,showCloseButton:!1,children:[(0,P.jsx)(lt,{className:`sr-only`,children:i}),(0,P.jsxs)(`div`,{className:`relative flex items-center justify-center min-h-[200px]`,children:[(0,P.jsx)(`img`,{src:a,alt:i,className:`max-w-[93vw] max-h-[90vh] object-contain`}),(0,P.jsxs)(`div`,{className:`absolute top-2 right-2 flex gap-1`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:p,className:`rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Download`,children:(0,P.jsx)(_,{className:`w-4 h-4`})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>f(!1),className:`rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Close`,children:(0,P.jsx)(ie,{className:`w-4 h-4`})})]})]})]})})]}):(0,P.jsxs)(`button`,{type:`button`,onClick:p,disabled:!a,className:y(`mt-2 flex w-full items-center gap-2 rounded-md border px-2.5 py-2 text-left text-xs transition-colors disabled:cursor-default disabled:opacity-70`,n?`border-primary-foreground/20 bg-primary-foreground/10 hover:bg-primary-foreground/15`:`border-border bg-background hover:bg-muted`),children:[l?(0,P.jsx)(O,{className:`h-4 w-4 shrink-0 animate-spin`}):s?(0,P.jsx)(t,{className:`h-4 w-4 shrink-0 text-red-400`}):(0,P.jsx)(se,{className:`h-4 w-4 shrink-0`}),(0,P.jsx)(`span`,{className:y(`min-w-0 flex-1 truncate`,s&&`text-red-400`),children:s||i}),(0,P.jsx)(_,{className:`h-3.5 w-3.5 shrink-0`})]})}function po({open:e,onToggle:t,onReact:n}){return(0,P.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,P.jsx)(`button`,{type:`button`,title:`Add reaction`,onClick:t,className:y(`inline-flex h-5 w-6 items-center justify-center rounded-full border border-border bg-popover text-muted-foreground shadow-sm transition hover:bg-muted hover:text-foreground`,e?`opacity-100`:`opacity-0 pointer-events-none md:group-hover/msg:opacity-100 md:group-hover/msg:pointer-events-auto`),children:(0,P.jsx)(E,{className:`h-3 w-3`})}),e&&(0,P.jsx)(`div`,{className:`absolute bottom-full left-0 z-30 mb-1 flex gap-0.5 rounded-full border border-border bg-popover p-0.5 shadow-md`,children:Et.map(e=>(0,P.jsx)(`button`,{type:`button`,title:`React ${e}`,onClick:()=>n(e),className:`inline-flex h-6 w-7 items-center justify-center rounded-full text-xs transition-colors hover:bg-muted`,children:e},e))})]})}var mo=(0,N.memo)(function({msg:e,peer:t,onOpenReferencedPath:n,onPreviewReferencedPath:r,onPreviewReferencedPathEnd:i}){let a=e.from===We,o=k(e=>e.reactToMessage),s=k(e=>e.voiceTtsEnabled),c=uo(),l=k(e=>{let n=e.agentsById[t]?.meta?.cwd;return typeof n==`string`?n:``}),[u,d]=(0,N.useState)(!1),f=(0,N.useRef)(null),p=(0,N.useRef)(null),m=(0,N.useRef)(!1),g=ke(e),_=Mt(e.occurredAt??e.createdAt),v=Tt(e),b=Dt(e),x=a?kt(e,t):null,S=x?.icon,C=c===String(e.id),w=s&&!a&&!Ot(e)&&g.trim().length>0;function T(t){t.stopPropagation(),C?Se.bargeIn():Se.speak(e.body,String(e.id))}(0,N.useEffect)(()=>{if(!u)return;function e(e){wt()||f.current&&!f.current.contains(e.target)&&d(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[u]);function E(e){return bt(l||`/`,e)}function ee(e,t){let r=E(e);n?.(r,t)}function te(e,t,n){let i=E(e);r?.(i,t,n)}function ne(t){o(e,t),d(!1)}function re(e){e.button===0&&(p.current={x:e.clientX,y:e.clientY},m.current=!1)}function ie(e){let t=p.current;t&&(Math.abs(e.clientX-t.x)>3||Math.abs(e.clientY-t.y)>3)&&(m.current=!0)}function ae(t){if(!(Ot(e)||a)&&!t.target.closest(`a,button,input,textarea,select,[role="button"]`)){if(m.current||wt()){m.current=!1;return}d(e=>!e)}}return(0,P.jsx)(`div`,{"data-msg-id":e.id,className:y(`group/msg flex mb-3`,a?`justify-end`:`justify-start`),children:(0,P.jsxs)(`div`,{ref:f,className:`relative max-w-[85%] md:max-w-[75%]`,children:[w&&(0,P.jsx)(`button`,{type:`button`,title:C?`Stop playback`:`Play aloud`,onClick:T,className:y(`absolute -top-2 -right-2 z-20 inline-flex h-6 w-6 items-center justify-center rounded-full border bg-popover shadow-sm transition`,C?`border-primary/50 text-primary opacity-100`:`border-border text-muted-foreground opacity-70 hover:bg-muted hover:text-foreground hover:opacity-100 [@media(hover:hover)]:md:opacity-0 [@media(hover:hover)]:md:group-hover/msg:opacity-100`),children:C?(0,P.jsx)(h,{className:`h-3.5 w-3.5 animate-pulse`}):(0,P.jsx)(D,{className:`h-3.5 w-3.5`})}),(0,P.jsxs)(`div`,{className:y(`rounded-2xl px-3.5 py-2 text-sm select-text`,!a&&!Ot(e)&&`cursor-pointer`,a?`bg-primary text-primary-foreground rounded-br-sm`:`bg-card ring-1 ring-foreground/10 rounded-bl-sm`),onPointerDown:re,onPointerMove:ie,onClick:ae,children:[e.subject&&(0,P.jsx)(`p`,{className:y(`text-xs font-semibold mb-1`,a?`text-primary-foreground/70`:`text-muted-foreground`),children:e.subject}),(0,P.jsx)(ft,{text:g,rawBody:e.body,className:`leading-relaxed`,onOpenPath:ee,onPreviewPath:te,onPreviewPathEnd:i,resolvePathTitle:(e,t)=>`${E(e)}${t?`:${t}`:``}`}),v.map(t=>(0,P.jsx)(fo,{attachment:t,outbound:a},`${e.id}-${t.artifactId}-${t.role||``}`)),(0,P.jsxs)(`p`,{className:y(`text-xs mt-1 flex items-center gap-1.5`,a?`justify-end text-primary-foreground/60`:`justify-end text-muted-foreground`),children:[(0,P.jsxs)(`span`,{className:`opacity-40`,children:[`#`,e.id]}),(0,P.jsx)(`span`,{children:_}),x&&S&&(0,P.jsxs)(`span`,{className:y(`inline-flex items-center gap-1`,x.tone===`ok`&&`text-emerald-300`,x.tone===`warn`&&`text-amber-200`,x.tone===`danger`&&`text-red-200`),title:x.title,children:[(0,P.jsx)(S,{className:`h-3 w-3`}),x.label]})]})]}),!Ot(e)&&b.length>0&&(0,P.jsxs)(`div`,{className:y(`flex flex-wrap items-center gap-0.5 -mt-1 relative z-10`,a?`justify-end pr-2`:`justify-start pl-2`),children:[!a&&(0,P.jsx)(po,{open:u,onToggle:()=>d(e=>!e),onReact:ne}),b.map(e=>(0,P.jsxs)(`button`,{type:`button`,title:e.actors.join(`, `),onClick:()=>ne(e.emoji),className:y(`inline-flex h-5 items-center gap-0.5 rounded-full border px-1.5 text-[11px] shadow-sm transition-colors`,e.mine?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-background hover:bg-muted text-foreground`),children:[(0,P.jsx)(`span`,{children:e.emoji}),e.count>1&&(0,P.jsx)(`span`,{children:e.count})]},e.emoji))]}),!Ot(e)&&!a&&b.length===0&&(0,P.jsx)(`div`,{className:`absolute -bottom-2.5 left-1 z-20`,children:(0,P.jsx)(po,{open:u,onToggle:()=>d(e=>!e),onReact:ne})})]})})});function ho({agentId:e,approval:n}){let r=k(e=>e.sendPermissionDecision),[i,a]=(0,N.useState)(null);if(!n)return null;if(n.questions&&n.questions.length)return(0,P.jsx)(vo,{agentId:e,approval:n,questions:n.questions});let o=n,s=n.choices.length?n.choices:[{id:`approve`,label:`Approve`},{id:`deny`,label:`Deny`}];async function c(t){if(!i){a(t.id);try{await r(e,o.id,t.id)}finally{a(null)}}}let l=n.kind===`plan`;return(0,P.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,P.jsx)(`div`,{className:`max-w-[92%] md:max-w-[78%] rounded-2xl rounded-bl-sm bg-card ring-1 ring-amber-500/35 px-3.5 py-3 text-sm`,children:(0,P.jsxs)(`div`,{className:`flex items-start gap-2`,children:[l?(0,P.jsx)(T,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-400`}):(0,P.jsx)(t,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-400`}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-100`,children:n.title}),n.body&&(l?(0,P.jsx)(`div`,{className:`mt-2 max-h-72 overflow-auto rounded-md bg-background/60 p-2.5 text-xs leading-relaxed`,children:(0,P.jsx)(ft,{text:n.body,rawBody:n.body,className:`leading-relaxed`})}):(0,P.jsx)(`pre`,{className:`mt-2 max-h-44 overflow-auto whitespace-pre-wrap break-words rounded-md bg-background/80 p-2 font-mono text-xs leading-relaxed text-muted-foreground`,children:n.body})),(0,P.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:s.map(e=>(0,P.jsxs)(M,{size:`sm`,variant:e.id===`deny`||e.id===`abort`?`outline`:`default`,disabled:!!i,onClick:()=>void c(e),className:`h-7 px-2 text-xs`,children:[i===e.id&&(0,P.jsx)(O,{className:`mr-1.5 h-3 w-3 animate-spin`}),e.label]},e.id))})]})]})})})}function go(e){return e?e.otherActive&&e.other.trim()?!0:e.labels.length>0:!1}function _o(e){let t=[...e.labels];return e.otherActive&&e.other.trim()&&t.push(e.other.trim()),t.join(`, `)}function vo({agentId:e,approval:t,questions:n}){let r=k(e=>e.sendPermissionDecision),[i,a]=(0,N.useState)(0),[o,s]=(0,N.useState)({}),[c,l]=(0,N.useState)(null),u=n[Math.min(i,n.length-1)],d=o[i];if(!u)return null;let f=!!u.multiSelect,p=n.length,m=i===p-1,h=go(d),g=n.every((e,t)=>go(o[t])),_=!!c;function v(e){s(t=>{let n=t[i]??{labels:[],other:``,otherActive:!1};return{...t,[i]:{...n,...e}}})}function b(e){if(f){let t=d?.labels.includes(e);v({labels:t?(d?.labels??[]).filter(t=>t!==e):[...d?.labels??[],e]})}else v({labels:[e],otherActive:!1})}function x(){v(f?{otherActive:!d?.otherActive}:{labels:[],otherActive:!0})}async function S(){if(!(!g||_)){l(`answer`);try{let i={};n.forEach((e,t)=>{let n=o[t];n&&(i[e.question]=_o(n))}),await r(e,t.id,`answer`,i)}finally{l(null)}}}async function w(){if(!_){l(`dismiss`);try{await r(e,t.id,`deny`)}finally{l(null)}}}let T=!!d?.otherActive;return(0,P.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,P.jsxs)(`div`,{className:`w-full max-w-[92%] md:max-w-[78%] rounded-2xl rounded-bl-sm bg-card ring-1 ring-amber-500/35 px-3.5 py-3 text-sm`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(C,{className:`h-4 w-4 shrink-0 text-amber-400`}),(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-100`,children:t.title}),p>1&&(0,P.jsxs)(Ke,{variant:`outline`,className:`ml-auto h-5 px-1.5 text-[10px] text-muted-foreground`,children:[i+1,` / `,p]})]}),(0,P.jsxs)(`div`,{className:`mt-3`,children:[u.header&&(0,P.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-amber-300/80`,children:u.header}),(0,P.jsx)(`div`,{className:`mt-0.5 text-sm text-foreground whitespace-pre-wrap break-words`,children:u.question}),f&&(0,P.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:`Select all that apply`}),(0,P.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:[u.options.map(e=>{let t=!!d?.labels.includes(e.label);return(0,P.jsxs)(`button`,{type:`button`,disabled:_,onClick:()=>b(e.label),className:y(`flex items-start gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors`,t?`border-amber-500/60 bg-amber-500/10`:`border-border bg-background/60 hover:bg-background`,_&&`opacity-60`),children:[(0,P.jsx)(`span`,{className:y(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center border text-amber-300`,f?`rounded`:`rounded-full`,t?`border-amber-400 bg-amber-400/20`:`border-muted-foreground/40`),children:t&&(0,P.jsx)(ae,{className:`h-3 w-3`})}),(0,P.jsxs)(`span`,{className:`min-w-0`,children:[(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:e.label}),e.description&&(0,P.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description})]})]},e.label)}),(0,P.jsxs)(`button`,{type:`button`,disabled:_,onClick:x,className:y(`flex items-start gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors`,T?`border-amber-500/60 bg-amber-500/10`:`border-border bg-background/60 hover:bg-background`,_&&`opacity-60`),children:[(0,P.jsx)(`span`,{className:y(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center border text-amber-300`,f?`rounded`:`rounded-full`,T?`border-amber-400 bg-amber-400/20`:`border-muted-foreground/40`),children:T&&(0,P.jsx)(ae,{className:`h-3 w-3`})}),(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:`Other…`})]}),T&&(0,P.jsx)(dt,{autoFocus:!0,rows:2,disabled:_,value:d?.other??``,onChange:e=>v({other:e.target.value,otherActive:!0}),placeholder:`Type your answer`,className:`mt-1 text-sm`})]})]}),(0,P.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[i>0&&(0,P.jsxs)(M,{size:`sm`,variant:`outline`,disabled:_,onClick:()=>a(e=>e-1),className:`h-7 px-2 text-xs`,children:[(0,P.jsx)(le,{className:`mr-1 h-3 w-3`}),`Back`]}),m?(0,P.jsxs)(M,{size:`sm`,disabled:_||!g,onClick:()=>void S(),className:`h-7 px-2 text-xs`,children:[c===`answer`&&(0,P.jsx)(O,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Send answer`,p>1?`s`:``]}):(0,P.jsxs)(M,{size:`sm`,disabled:_||!h,onClick:()=>a(e=>e+1),className:`h-7 px-2 text-xs`,children:[`Next`,(0,P.jsx)(me,{className:`ml-1 h-3 w-3`})]}),(0,P.jsxs)(M,{size:`sm`,variant:`ghost`,disabled:_,onClick:()=>void w(),className:`ml-auto h-7 px-2 text-xs text-muted-foreground`,children:[c===`dismiss`&&(0,P.jsx)(O,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Dismiss`]})]})]})})}var yo={online:`text-emerald-400`,offline:`text-zinc-400`,shutdown:`text-zinc-400`,restarted:`text-blue-400`,"compaction-requested":`text-zinc-400`,compacting:`text-amber-400`,compacted:`text-amber-400`,"compaction-stalled":`text-red-400`,"clear-requested":`text-zinc-400`,"clearing-context":`text-amber-400`,"context-cleared":`text-amber-400`,"clear-stalled":`text-red-400`,"shutting-down":`text-zinc-400`};function bo(e){let t=new Date,[n,r,i]=e.split(`-`).map(Number),a=new Date(n,r-1,i);if(e===Qt(t.getTime()))return`Today`;let o=new Date(t);return o.setDate(o.getDate()-1),e===Qt(o.getTime())?`Yesterday`:a.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,year:a.getFullYear()===t.getFullYear()?void 0:`numeric`})}function xo({event:e}){return(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,P.jsx)(ue,{className:y(`w-2 h-2 fill-current`,yo[e.status]||`text-zinc-400`)}),(0,P.jsx)(`span`,{children:qt[e.status]||e.status}),(0,P.jsx)(`span`,{className:`text-muted-foreground/60`,children:Mt(e.timestamp)})]}),(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function So({blockedLabel:e,onInterrupt:n}){return e?(0,P.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-red-500/30 px-4 py-2.5`,children:[(0,P.jsx)(t,{className:`w-3.5 h-3.5 text-red-400`}),(0,P.jsxs)(`span`,{className:`text-xs text-red-300`,children:[`blocked: `,e]})]})}):(0,P.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-foreground/10 px-4 py-2.5`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_infinite]`}),(0,P.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_0.2s_infinite]`}),(0,P.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_0.4s_infinite]`})]}),(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`working`}),n&&(0,P.jsxs)(`button`,{onClick:n,title:`Interrupt`,className:`ml-1 flex items-center gap-1 rounded-full px-1.5 py-0.5 text-xs text-muted-foreground hover:text-red-300 hover:bg-red-500/10 transition-colors`,children:[(0,P.jsx)(h,{className:`w-3.5 h-3.5`}),`Stop`]})]})})}var Co=`agent-relay:chat-hide-tools`,wo=(()=>{let e=new Set,t=(()=>{try{return window.localStorage.getItem(Co)===`on`}catch{return!1}})(),n=()=>e.forEach(e=>e());return typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===Co&&(t=e.newValue===`on`,n())}),{subscribe(t){return e.add(t),()=>e.delete(t)},get:()=>t,toggle(){t=!t;try{window.localStorage.setItem(Co,t?`on`:`off`)}catch{}n()}}})();function To(){return[(0,N.useSyncExternalStore)(wo.subscribe,wo.get,()=>!1),wo.toggle]}function Eo({steps:e,showReasoning:t}){let[n,r]=To(),i=t?e:e.filter(e=>e.kind!==`reasoning`);if(!i.length)return null;let a=i.filter(e=>e.kind===`tool`).length;return(0,P.jsx)(`div`,{className:`flex justify-start mb-2`,children:(0,P.jsxs)(`div`,{className:`max-w-[85%] md:max-w-[75%] min-w-0 space-y-1.5`,children:[i.map(e=>e.kind===`narration`?(0,P.jsx)(`div`,{className:`text-sm leading-relaxed whitespace-pre-wrap break-words text-foreground/90 min-w-0`,children:e.text},e.id):e.kind===`reasoning`?(0,P.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground/80`,children:[(0,P.jsx)(ee,{className:`w-3.5 h-3.5 mt-0.5 shrink-0 opacity-70`}),(0,P.jsx)(`span`,{className:`italic whitespace-pre-wrap break-words min-w-0`,children:e.text})]},e.id):n?null:(0,P.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground`,children:[(0,P.jsx)(re,{className:`w-3 h-3 mt-0.5 shrink-0 opacity-70`}),(0,P.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,P.jsx)(`span`,{className:`font-medium`,children:e.label||`tool`}),e.text?(0,P.jsxs)(`span`,{className:`opacity-70`,children:[` — `,e.text]}):null]})]},e.id)),a>0&&(0,P.jsxs)(`button`,{onClick:r,className:`flex items-center gap-1 text-[11px] text-muted-foreground/50 hover:text-muted-foreground transition-colors text-left`,children:[(0,P.jsx)(me,{className:y(`w-3 h-3 shrink-0 transition-transform`,!n&&`rotate-90`)}),(0,P.jsx)(`span`,{children:n?`show ${a} tool step${a===1?``:`s`}`:`hide tool steps`})]})]})})}function Do({date:e}){return(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-3 my-1`,children:[(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,P.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:bo(e)}),(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Oo({timestamp:e}){let t=new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`});return(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,P.jsxs)(`span`,{className:`text-xs text-muted-foreground/60`,children:[`created `,t]}),(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function ko({history:e}){let t=e.sourceAgentLabel||e.sourcePeerId,n=e.entries.length;return(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-full border border-dashed border-border bg-muted/30 px-2 py-1 text-[11px] text-muted-foreground`,children:[(0,P.jsx)(be,{className:`h-3 w-3`}),(0,P.jsxs)(`span`,{children:[`forked history from `,t]}),(0,P.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[n,` `,n===1?`entry`:`entries`]})]}),(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Ao({entry:e,sourceLabel:t}){let n=e.message,r=ke(n),i=e.originalFrom===We;return(0,P.jsx)(`div`,{className:y(`flex mb-3 opacity-80`,i?`justify-end`:`justify-start`),children:(0,P.jsx)(`div`,{className:`max-w-[85%] md:max-w-[75%]`,children:(0,P.jsxs)(`div`,{className:y(`rounded-2xl border border-dashed px-3.5 py-2 text-sm select-text`,i?`border-primary/25 bg-primary/10 text-foreground rounded-br-sm`:`border-border bg-card/70 rounded-bl-sm`),children:[(0,P.jsxs)(`div`,{className:y(`mb-1 text-[10px] uppercase tracking-normal`,i?`text-primary/70`:`text-muted-foreground`),children:[`forked history · `,i?`you`:t||e.originalFrom]}),(0,P.jsx)(ft,{text:r,rawBody:n.body,className:`leading-relaxed`}),(0,P.jsxs)(`p`,{className:y(`mt-1 flex items-center justify-end gap-1.5 text-xs`,i?`text-primary/60`:`text-muted-foreground`),children:[(0,P.jsxs)(`span`,{className:`opacity-40`,children:[`#`,e.originalMessageId]}),(0,P.jsx)(`span`,{children:Mt(e.originalCreatedAt)})]})]})})})}function jo({scrollRef:e,timeline:t}){let[n,r]=(0,N.useState)(!0),[i,a]=(0,N.useState)(null),[o,s]=(0,N.useState)(null),[c,l]=(0,N.useState)(!0),u=(0,N.useMemo)(()=>{for(let e=t.length-1;e>=0;e--){let n=t[e];if(!(!n||n.type!==`message`)&&n.msg.from===`user`)return{id:n.msg.id,body:ke(n.msg)}}return null},[t]);if((0,N.useEffect)(()=>{let t=e.current;if(!u||!t){r(!0);return}let n=t.querySelector(`[data-msg-id="${u.id}"]`);if(!n){r(!0);return}let i=new IntersectionObserver(([e])=>{if(e&&(r(e.isIntersecting),!e.isIntersecting)){let n=e.rootBounds?.top??t.getBoundingClientRect().top;l(e.boundingClientRect.top<n)}},{root:t,threshold:0});i.observe(n);let a=()=>{let e=n.getBoundingClientRect(),r=t.getBoundingClientRect();l(e.top<r.top)};return t.addEventListener(`scroll`,a,{passive:!0}),()=>{i.disconnect(),t.removeEventListener(`scroll`,a)}},[u?.id,e]),n||!u||!u.body.trim())return null;let d=i?.id===u.id?i.value:!1,f=o?.id===u.id?o.value:!1;function p(){let t=e.current;!t||!u||t.querySelector(`[data-msg-id="${u.id}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`})}let m=c?`↑`:`↓`;return f?(0,P.jsx)(`div`,{className:`sticky top-0 z-10 -mx-3 md:-mx-4 -mt-3 md:-mt-4 bg-background`,children:(0,P.jsxs)(`button`,{type:`button`,className:`w-full flex items-center justify-center gap-1.5 py-1 text-[11px] text-primary/60 hover:text-primary border-b border-primary/10 transition-colors`,onClick:()=>s({id:u.id,value:!1}),children:[(0,P.jsx)(`span`,{children:`Your prompt`}),(0,P.jsx)(fe,{className:`w-3 h-3`})]})}):(0,P.jsxs)(`div`,{className:`sticky top-0 z-10 -mx-3 md:-mx-4 -mt-3 md:-mt-4 px-2 md:px-3 pt-2 pb-1.5 bg-background border-b border-primary/10`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground mb-0.5`,children:[(0,P.jsx)(`span`,{className:`font-medium text-primary/70`,children:`Your prompt`}),(0,P.jsxs)(`button`,{type:`button`,className:`ml-auto hover:text-foreground transition-colors`,onClick:p,children:[m,` scroll to original`]}),(0,P.jsx)(`button`,{type:`button`,className:`hover:text-foreground transition-colors`,onClick:()=>s({id:u.id,value:!0}),title:`Minimize`,children:(0,P.jsx)(te,{className:`w-3 h-3`})})]}),(0,P.jsx)(`p`,{className:y(`text-sm text-foreground leading-snug cursor-pointer`,!d&&`line-clamp-2`),onClick:()=>a({id:u.id,value:!d}),children:u.body})]})}var Mo=1e6,No=`px-3 md:px-4`;function Po({context:e}){if(!e)return null;let{agentId:t,agentStatus:n,pendingApproval:r,blockedLabel:i,canInterrupt:a,onInterrupt:o}=e;return(0,P.jsxs)(`div`,{className:No,children:[r&&(0,P.jsx)(ho,{agentId:t,approval:r},r.id),n===`busy`&&!r&&(0,P.jsx)(So,{blockedLabel:i,onInterrupt:a?o:void 0})]})}function Fo(e){return e.type===`message`?`msg-${e.msg.id}`:e.type===`activity`?`act-${e.steps[0]?.id??e.timestamp}`:e.type===`import-boundary`?`import-${e.history.id}`:e.type===`imported-message`?`import-msg-${e.history.id}-${e.entry.originalMessageId}-${e.entry.position}`:e.type===`status`?`status-${e.event.id}`:e.type===`date`?`date-${e.date}`:`created-${e.timestamp}`}function Io(e){let t=e.findIndex(e=>e.type!==`date`&&e.type!==`created`),n=t>=0?t:0,r=e[n];return{key:r?Fo(r):null,index:n}}function Lo(e,t){let[n,r]=(0,N.useState)(()=>Mo-t.length),i=(0,N.useRef)({agentId:e,anchor:Io(t)});return(0,N.useLayoutEffect)(()=>{let n=Io(t),a=i.current;r(n=>{if(a.agentId!==e)return Mo-t.length;if(!a.anchor.key)return n;let r=t.findIndex(e=>Fo(e)===a.anchor.key)-a.anchor.index;return r>0?n-r:n}),i.current={agentId:e,anchor:n}},[e,t]),n}function Ro({agentId:e,agentStatus:t,timeline:n,hasMore:r,loading:i,loadedInitial:a,showReasoning:o,pendingApproval:s,blockedLabel:c,canInterrupt:l,onAtBottomChange:u,onLoadOlder:d,onInterrupt:f,onOpenReferencedPath:p,onPreviewReferencedPath:h,onPreviewReferencedPathEnd:g}){let _=(0,N.useRef)(null),v=(0,N.useRef)(null),[y,b]=(0,N.useState)(!0),S=Lo(e,n),C=n.length>0?Fo(n[n.length-1]):null,w=(0,N.useRef)(C),T=(0,N.useRef)(e);T.current!==e&&(T.current=e,w.current=C);let E=w.current?n.findIndex(e=>Fo(e)===w.current):-1,D=!y&&E>=0?n.slice(E+1).filter(e=>e.type===`message`).length:0;(0,N.useLayoutEffect)(()=>{y&&(w.current=C)},[y,C]);let ee=(0,N.useCallback)(e=>{v.current=e instanceof HTMLElement?e:null},[]),te=(0,N.useCallback)(e=>{b(e),u?.(e)},[u]),ne=(0,N.useCallback)(()=>{!r||i||d()},[r,i,d]),re=(0,N.useCallback)(()=>{w.current=C;let e=v.current;if(e){e.scrollTo({top:e.scrollHeight,behavior:`smooth`});return}_.current?.scrollToIndex({index:`LAST`,align:`end`,behavior:`smooth`})},[C]),ie=(0,N.useMemo)(()=>function(){return(0,P.jsxs)(`div`,{className:No,children:[(0,P.jsx)(jo,{scrollRef:v,timeline:n}),(0,P.jsx)(zo,{hasMore:r,loading:i,loadedInitial:a,hasItems:n.length>0})]})},[r,a,i,n]),ae=(0,N.useMemo)(()=>({agentId:e,agentStatus:t,pendingApproval:s,blockedLabel:c,canInterrupt:l,onInterrupt:f}),[e,t,c,l,f,s]),oe=(0,N.useMemo)(()=>function(){return(0,P.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center`,children:[i?(0,P.jsx)(O,{className:`mb-2 h-5 w-5 animate-spin text-muted-foreground`}):(0,P.jsx)(m,{className:`mb-2 h-8 w-8 text-zinc-600`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i?`Loading messages`:`No messages yet`})]})},[i]),se=(0,N.useMemo)(()=>({Header:ie,Footer:Po,EmptyPlaceholder:oe}),[oe,ie]);return(0,P.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,P.jsx)(Sa,{ref:_,scrollerRef:ee,className:`h-full py-3 md:py-4`,style:{height:`100%`,overflowX:`hidden`},context:ae,data:n,firstItemIndex:S,initialTopMostItemIndex:Math.max(0,n.length-1),computeItemKey:(e,t)=>Fo(t),itemContent:(t,n)=>(0,P.jsx)(`div`,{className:No,children:(0,P.jsx)(Bo,{entry:n,agentId:e,showReasoning:o,onOpenReferencedPath:p,onPreviewReferencedPath:h,onPreviewReferencedPathEnd:g})}),components:se,startReached:ne,atBottomStateChange:te,atBottomThreshold:64,followOutput:e=>e?`smooth`:!1,increaseViewportBy:{top:600,bottom:600}},e),!y&&n.length>0&&(0,P.jsxs)(M,{type:`button`,size:`sm`,variant:`secondary`,className:`absolute bottom-3 right-4 z-20 h-8 gap-1.5 rounded-full border border-border/70 bg-background/95 px-3 text-xs shadow-lg backdrop-blur`,onClick:re,children:[(0,P.jsx)(x,{className:`h-3.5 w-3.5`}),`Latest`,D>0&&(0,P.jsx)(`span`,{className:`ml-0.5 min-w-4 rounded-full bg-primary px-1.5 py-0.5 text-[10px] font-medium leading-none text-primary-foreground`,children:D>99?`99+`:D})]})]})}function zo({hasMore:e,loading:t,loadedInitial:n,hasItems:r}){return t?(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-2 pb-3 text-xs text-muted-foreground`,children:[(0,P.jsx)(O,{className:`h-3.5 w-3.5 animate-spin`}),(0,P.jsx)(`span`,{children:`Loading earlier messages`})]}):!e&&n&&r?(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-2 pb-3 text-xs text-muted-foreground/70`,children:[(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,P.jsx)(`span`,{children:`Beginning of conversation`}),(0,P.jsx)(`div`,{className:`h-px flex-1 bg-border`})]}):null}function Bo({entry:e,agentId:t,showReasoning:n,onOpenReferencedPath:r,onPreviewReferencedPath:i,onPreviewReferencedPathEnd:a}){return e.type===`message`?(0,P.jsx)(mo,{msg:e.msg,peer:t,onOpenReferencedPath:r,onPreviewReferencedPath:i,onPreviewReferencedPathEnd:a}):e.type===`activity`?(0,P.jsx)(Eo,{steps:e.steps,showReasoning:n}):e.type===`import-boundary`?(0,P.jsx)(ko,{history:e.history}):e.type===`imported-message`?(0,P.jsx)(Ao,{entry:e.entry,sourceLabel:e.history.sourceAgentLabel||e.history.sourcePeerId}):e.type===`status`?(0,P.jsx)(xo,{event:e.event}):e.type===`date`?(0,P.jsx)(Do,{date:e.date}):(0,P.jsx)(Oo,{timestamp:e.timestamp})}var Vo=[];function Ho({threads:e,onBack:t,showBackButton:n}){let r=k(e=>e.selectedInboxThread),i=k(e=>e.agentsById),a=k(e=>e.inboxDrafts),o=Ce(),c=k(e=>e.sendChatMessage),l=k(e=>e.openFilesAt),u=k(e=>e.openFilesForAgent),d=k(e=>e.openAgentDetail),f=k(e=>e.chatSending),p=k(e=>e.markInboxThreadRead),h=k(e=>e.markInboxThreadUnread),g=k(e=>e.setReplyDraft),_=k(e=>e.exportThread),v=k(e=>e.doAgentAction),y=k(e=>e.workspaceAction),b=k(e=>e.openWorkspaceFocus),x=k(e=>e.forkFromAgent),S=k(e=>e.chatHistoryImports),C=k(e=>e.agentChatByAgent[e.selectedInboxThread]),w=C?.messages??Vo,T=k(e=>e.loadOlder),E=k(e=>e.openConfirm),D=k(e=>e.showError),ee=k(e=>e.orchestrators),te=k(e=>e.fetchOrchestrators),ne=k(e=>e.showReasoning),re=k(e=>e.voiceTtsEnabled),ae=k(e=>e.setVoiceTtsEnabled),O=k(e=>e.voiceInputMode);(0,N.useRef)(null);let se=(0,N.useRef)(null),[ce,le]=(0,N.useState)(`idle`),ue=(0,N.useRef)([]),[de,fe]=(0,N.useState)([]),[pe,me]=(0,N.useState)(!1),[he,ge]=(0,N.useState)(null),[_e,ve]=(0,N.useState)(null),[ye,be]=(0,N.useState)(``),xe=(0,N.useRef)(null),De=(0,N.useRef)(0),Oe=rn(r),ke=(0,N.useMemo)(()=>e.find(e=>e.peer===r)||null,[e,r]),Ae=(0,N.useMemo)(()=>w.filter(e=>Le(e)===r&&!Ge(e)).sort((e,t)=>e.id-t.id),[w,r]),A=i[r]||null,je=typeof A?.meta?.lifecycleAction==`string`&&A.meta.lifecycleAction.startsWith(`finalizing-`),{terminalOpen:Ne,terminalTarget:Pe,terminalOpening:Fe,openTerminal:Ie,closeTerminal:ze}=_t(A?.id),Be=typeof A?.meta?.spawnRequestId==`string`?A.meta.spawnRequestId:``,Ve=(0,N.useMemo)(()=>S.filter(e=>e.targetAgentId===r||!!(Be&&e.targetSpawnRequestId===Be)),[Be,S,r]),He=Me(A),Ue=He?.pendingApproval,We=(0,N.useMemo)(()=>{if(!r||!ke&&Ae.length===0)return null;let e=Ae[Ae.length-1]??ke?.lastMessage??null,t=ke?.previewMessage&&Ae.some(e=>e.id===ke.previewMessage?.id)?ke.previewMessage:e;return{id:ke?.id??r,peer:r,messages:Ae,lastMessage:e,previewMessage:t,attention:ke?.attention??{unread:0,needsHumanResponse:!1,score:0},archived:ke?.archived??!1,draft:ke?.draft??``}},[r,ke,Ae]),Ke=We||(Ve.length>0?{peer:r,messages:[],importedHistory:Ve}:null),qe=a[r]||``,Je=typeof A?.meta?.tmuxSession==`string`&&A.meta.tmuxSession.trim()?A.meta.tmuxSession:null,Ye=Je?ee.find(e=>e.managedAgents?.some(e=>e.agentId===A.id||e.tmuxSession===Je))??null:null,Xe=!!(Je&&Ye?.status===`online`&&A?.providerCapabilities?.terminal?.live?.read),Ze=A?.providerCapabilities?.model?.provider??(typeof A?.meta?.provider==`string`?A.meta.provider:void 0),Qe=!!(Xe&&(A?.providerCapabilities?.terminal?.live?.write||Ze===`claude`)),$e=A?.providerCapabilities?.terminal?.attach?.create===!0,et=Xe||$e,tt=Re(A,`compact`),nt=Re(A,`clearContext`),rt=Re(A,`shutdown`),it=Re(A,`interrupt`),at=()=>{A&&v(A,`interrupt`)},[ot,ct]=(0,N.useState)(0),[lt,ut]=(0,N.useState)(!1),dt=A?.providerCapabilities?.liveSession?.slashCommands===!0,ft=A?.providerCapabilities?.model?.provider??(typeof A?.meta?.provider==`string`?A.meta.provider:void 0),mt=dt&&!lt&&/^\/\S*$/.test(qe)?zt(ft).filter(e=>e.name.toLowerCase().startsWith(qe.toLowerCase())):[],gt=mt.length?Math.min(ot,mt.length-1):0;function vt(e){g(r,`${e.name} `),ct(0)}function yt(e){g(r,e),lt&&ut(!1),ct(0)}let bt=de.some(e=>e.uploading),wt=de.filter(e=>e.artifact);an(qe.trim().length>0||de.length>0,(0,N.useCallback)(()=>{},[])),ue.current=de,(0,N.useEffect)(()=>()=>{Nt(ue.current)},[]),(0,N.useEffect)(()=>{A?.meta?.tmuxSession&&ee.length===0&&te()},[A?.id,A?.meta?.tmuxSession,ee.length]),(0,N.useEffect)(()=>()=>{xe.current!==null&&window.clearTimeout(xe.current)},[]);let Tt=(0,N.useMemo)(()=>en(Ae,Oe,A?.createdAt,Ve),[Ae,Oe,A?.createdAt,Ve]),Et=(0,N.useCallback)(()=>{!r||!C?.hasMore||C.loading||T(r)},[C?.hasMore,C?.loading,T,r]),Dt=(0,N.useCallback)(()=>{xe.current!==null&&(window.clearTimeout(xe.current),xe.current=null)},[]),Ot=(0,N.useCallback)(async e=>{let t=St(ee,e);if(!t)return null;try{let n=await oe(`GET`,`/orchestrators/${encodeURIComponent(t.id)}/files/stat?path=${encodeURIComponent(e)}`);return{orchestratorId:t.id,path:n.path,type:n.type}}catch{return null}},[ee]),kt=(0,N.useCallback)((e,t,n)=>{if(!Ct()||!n)return;let r=++De.current;Ot(e).then(e=>{De.current===r&&e&&(Dt(),ve({...e,line:t||0,anchor:n}),be(``))})},[Dt,Ot]),At=(0,N.useCallback)(()=>{De.current+=1,Dt(),xe.current=window.setTimeout(()=>{ve(null)},250)},[Dt]),jt=(0,N.useCallback)((e,t)=>{Ot(e).then(n=>{if(!n){D(`File Not Found`,e);return}if(Ct()){De.current+=1,Dt(),ve(null),ge({...n,line:t||0}),be(``);return}n.type===`directory`?l({orchestratorId:n.orchestratorId,path:n.path,overlay:!0}):l({orchestratorId:n.orchestratorId,path:xt(n.path),selectedPath:n.path,line:t,overlay:!0})})},[Dt,l,Ot,D]);function Mt(){ge(null),be(``)}async function Pt(e){let t=Array.from(e).filter(e=>e.size>0);if(!t.length)return;let n=t.map(e=>({id:`${Date.now()}-${e.name}-${Math.random().toString(16).slice(2)}`,fileName:e.name,size:e.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,uploading:!0}));fe(e=>[...e,...n]);for(let e=0;e<t.length;e+=1){let r=t[e],i=n[e];try{let e=await s(`/artifacts`,r,{filename:r.name,sensitivity:`normal`});fe(t=>t.map(t=>t.id===i.id?{...t,artifact:e,uploading:!1}:t))}catch(e){fe(t=>t.map(t=>t.id===i.id?{...t,error:e.message,uploading:!1}:t))}}}function Ft(e){fe(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})}function It(){Nt(de),fe([])}function Lt(){if(!qe.trim()&&wt.length===0||!r||f||bt||je)return;let e=wt.map(e=>({artifactId:e.artifact.id,kind:e.artifact.kind,role:`media`,title:e.artifact.filename||e.fileName}));c(qe,{peer:r,lastMessage:We?.lastMessage||null},e),It()}function Rt(e){if(mt.length){if(e.key===`ArrowDown`){e.preventDefault(),ct(e=>Math.min(e+1,mt.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),ct(e=>Math.max(e-1,0));return}if(e.key===`Escape`){e.preventDefault(),ut(!0);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=mt[gt];t&&vt(t);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Lt())}function Vt(e){let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),Pt(t))}async function Ht(){if(!we||ce!==`idle`||!r)return;Se.bargeIn();let e=new Te;try{await e.start(),se.current=e,le(`recording`)}catch(e){se.current=null,le(`idle`),D(`Microphone unavailable`,e?.message||`Could not access the microphone.`)}}async function Ut(){let e=se.current;if(!(!e||ce!==`recording`)){se.current=null,le(`transcribing`);try{let t=await e.stop();if(!t)return;let n=await Ee(t);if(!n)return;let i=qe?`${qe} ${n}`:n;if(O===`autosend`&&!f&&!bt){let e=wt.map(e=>({artifactId:e.artifact.id,kind:e.artifact.kind,role:`media`,title:e.artifact.filename||e.fileName}));c(i,{peer:r,lastMessage:We?.lastMessage||null},e),It()}else g(r,i)}catch(e){D(`Transcription failed`,e?.message||`Could not transcribe audio.`)}finally{le(`idle`)}}}return r?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`flex h-full min-w-0`,children:[(0,P.jsxs)(`div`,{className:`@container/chat flex h-full min-w-0 flex-1 flex-col`,children:[(0,P.jsx)(Bt,{selectedInboxThread:r,agent:A,now:o,blockedState:He,thread:We,exportableThread:Ke,importedHistory:Ve,showBackButton:n,onBack:t,openAgentDetail:d,openWorkspaceFocus:b,voiceTtsEnabled:re,setVoiceTtsEnabled:ae,canOpenTerminal:et,terminalOpening:Fe,handleOpenTerminal:Ie,canInterrupt:it,interruptAgent:at,canCompact:tt,canClearContext:nt,canShutdown:rt,openConfirm:E,workspaceAction:y,doAgentAction:v,openFilesForAgent:u,forkFromAgent:x,markInboxThreadUnread:h,markInboxThreadRead:p,exportThread:_}),(0,P.jsx)(Ro,{agentId:r,agentStatus:A?.status,timeline:Tt,hasMore:C?.hasMore??!1,loading:C?.loading??!1,loadedInitial:C?.loadedInitial??!1,showReasoning:ne,pendingApproval:Ue,blockedLabel:He?.label,canInterrupt:it,onLoadOlder:Et,onInterrupt:at,onOpenReferencedPath:jt,onPreviewReferencedPath:kt,onPreviewReferencedPathEnd:At}),(0,P.jsx)(Wt,{draft:qe,placeholder:`Message ${A?j(A):r}…`,chatSending:f,disabled:je,hasPendingUploads:bt,readyAttachmentCount:wt.length,pendingAttachments:de,micAvailable:we,micState:ce,slashMatches:mt,slashActiveIndex:gt,onDraftChange:yt,onKeyDown:Rt,onPaste:Vt,onUploadFiles:e=>{Pt(e)},onRemovePendingAttachment:Ft,onSend:Lt,onAcceptSlash:vt,onSlashHover:ct,onStartPtt:()=>{Ht()},onStopPtt:()=>{Ut()},footerText:je?`${A?j(A):`Agent`} is wrapping up (${(A?.meta?.lifecycleAction).slice(11)}) — messaging paused`:`Enter to send · Shift+Enter for newline`})]}),he&&(0,P.jsxs)(`aside`,{className:`hidden h-full w-[min(44vw,720px)] min-w-[360px] shrink-0 flex-col border-l border-border bg-background xl:flex`,children:[(0,P.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-xs font-medium text-muted-foreground`,children:`File preview`}),ye&&(0,P.jsx)(`span`,{className:`max-w-[18rem] truncate text-xs text-red-400`,children:ye}),(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,title:`Close preview`,onClick:Mt,children:(0,P.jsx)(ie,{className:`h-3.5 w-3.5`})})]}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1`,children:he.type===`directory`?(0,P.jsx)(pt,{orchestratorId:he.orchestratorId,selectedPath:he.path,onReadError:be}):(0,P.jsx)(ht,{orchestratorId:he.orchestratorId,selectedPath:he.path,line:he.line,onReadError:be})})]})]}),_e&&(0,P.jsx)(Kt,{preview:_e,error:ye,onReadError:be,onMouseEnter:Dt,onMouseLeave:At}),Pe&&(0,P.jsx)(st,{open:Ne,onOpenChange:ze,orchestratorId:Pe.orchestratorId,session:Pe.session,interactive:Pe.interactive||Qe})]}):(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center px-4`,children:[(0,P.jsx)(m,{className:`w-12 h-12 text-zinc-600 mb-3`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Select an agent to start chatting`})]})}function Uo(){let e=k(e=>e.inboxDrafts),t=k(e=>e.agentsById),n=k(e=>e.set);(0,N.useEffect)(()=>{let r=Object.keys(e);if(r.length===0)return;let i=r.filter(e=>!t[e]&&e!==`user`);if(i.length===0)return;let a=setTimeout(()=>{let e=k.getState().agentsById,t={...k.getState().inboxDrafts},r=!1;for(let n of i)e[n]||(delete t[n],r=!0);r&&n({inboxDrafts:t})},3e4);return()=>clearTimeout(a)},[])}function Wo(){let e=ot(),t=k(e=>e.selectedInboxThread),n=k(e=>e.set),r=k(e=>e.loadAgentChat),i=Pt(),a=!!t;Uo(),(0,N.useEffect)(()=>{t&&r(t)},[t,r]),(0,N.useEffect)(()=>{t&&(i.some(e=>e.id===t)||n({selectedInboxThread:``}))},[t,i,n]);function o(){n({selectedInboxThread:``})}return(0,P.jsxs)(`div`,{className:`flex -m-4 md:-m-6`,style:{height:`calc(100dvh - var(--header-h) - var(--sat))`},children:[(0,P.jsxs)(`div`,{className:`hidden md:flex w-full`,children:[(0,P.jsx)(`div`,{className:`w-1/3 min-w-[240px] max-w-xs flex flex-col overflow-hidden`,children:(0,P.jsx)(Ft,{threads:e})}),(0,P.jsx)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:(0,P.jsx)(Ho,{threads:e},t||`empty`)})]}),(0,P.jsx)(`div`,{className:`md:hidden flex w-full overflow-hidden`,children:a?(0,P.jsx)(Go,{children:(0,P.jsx)(Ho,{threads:e,onBack:o,showBackButton:!0},t||`empty`)}):(0,P.jsx)(`div`,{className:`w-full flex flex-col overflow-hidden`,children:(0,P.jsx)(Ft,{threads:e})})})]})}function Go({children:e}){let t=gt();return(0,P.jsx)(`div`,{className:`fixed inset-x-0 top-0 z-40 flex flex-col bg-background pt-[var(--sat)]`,style:{height:t?`${t}px`:`100dvh`},children:e})}export{Wo as ChatView};
|
|
2
|
-
//# sourceMappingURL=chat-BANKUW05.js.map
|