agent-relay-server 0.71.0 → 0.73.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/MessageBubble-BWdM9UCM.js +3 -0
- package/public/assets/MessageBubble-BWdM9UCM.js.map +1 -0
- package/public/assets/{PlanGraphPanel-BYmE8ldg.js → PlanGraphPanel-icESxd82.js} +2 -2
- package/public/assets/{PlanGraphPanel-BYmE8ldg.js.map → PlanGraphPanel-icESxd82.js.map} +1 -1
- package/public/assets/{activity-BzU196gP.js → activity-BR9I23hc.js} +2 -2
- package/public/assets/{activity-BzU196gP.js.map → activity-BR9I23hc.js.map} +1 -1
- package/public/assets/{agent-profiles-CQuoP8Nr.js → agent-profiles-BB0V-Tg1.js} +2 -2
- package/public/assets/{agent-profiles-CQuoP8Nr.js.map → agent-profiles-BB0V-Tg1.js.map} +1 -1
- package/public/assets/{agents-qH6q44nK.js → agents-Clkboz93.js} +2 -2
- package/public/assets/{agents-qH6q44nK.js.map → agents-Clkboz93.js.map} +1 -1
- package/public/assets/{analytics-EJH9GFID.js → analytics-DRlHs5ho.js} +3 -3
- package/public/assets/{analytics-EJH9GFID.js.map → analytics-DRlHs5ho.js.map} +1 -1
- package/public/assets/{automation-Dahmxg07.js → automation-DlnH_MPy.js} +2 -2
- package/public/assets/{automation-Dahmxg07.js.map → automation-DlnH_MPy.js.map} +1 -1
- package/public/assets/{badge-C6NJQ60B.js → badge-YQhT30dy.js} +2 -2
- package/public/assets/{badge-C6NJQ60B.js.map → badge-YQhT30dy.js.map} +1 -1
- package/public/assets/branch-state-badge-Dg1qnmF5.js +2 -0
- package/public/assets/{branch-state-badge-C7H8HY22.js.map → branch-state-badge-Dg1qnmF5.js.map} +1 -1
- package/public/assets/{button-DD2CCM3t.js → button-CaFI76Ja.js} +2 -2
- package/public/assets/{button-DD2CCM3t.js.map → button-CaFI76Ja.js.map} +1 -1
- package/public/assets/{card-GZqj3rMm.js → card-B_fQtKce.js} +2 -2
- package/public/assets/{card-GZqj3rMm.js.map → card-B_fQtKce.js.map} +1 -1
- package/public/assets/{channels-VhlwES_A.js → channels-BVYLrKUL.js} +2 -2
- package/public/assets/{channels-VhlwES_A.js.map → channels-BVYLrKUL.js.map} +1 -1
- package/public/assets/chat-ml_YzbK4.js +2 -0
- package/public/assets/chat-ml_YzbK4.js.map +1 -0
- package/public/assets/{connectors-C03pRoXx.js → connectors-BOyk5hC3.js} +2 -2
- package/public/assets/{connectors-C03pRoXx.js.map → connectors-BOyk5hC3.js.map} +1 -1
- package/public/assets/copy-button-m00JmflM.js +2 -0
- package/public/assets/{copy-button-DqAoeiPC.js.map → copy-button-m00JmflM.js.map} +1 -1
- package/public/assets/display-LAWaAboe.js.map +1 -1
- package/public/assets/{dist-DByqf8W0.js → dist-B_yrHbsb.js} +2 -2
- package/public/assets/{dist-DByqf8W0.js.map → dist-B_yrHbsb.js.map} +1 -1
- package/public/assets/{dist-C_XTOHbv.js → dist-C-viWls-.js} +2 -2
- package/public/assets/{dist-C_XTOHbv.js.map → dist-C-viWls-.js.map} +1 -1
- package/public/assets/{dist-DMD9fD99.js → dist-CYS2puT9.js} +2 -2
- package/public/assets/{dist-DMD9fD99.js.map → dist-CYS2puT9.js.map} +1 -1
- package/public/assets/{dist-CpugiXtB.js → dist-ChP4KvKi.js} +2 -2
- package/public/assets/{dist-CpugiXtB.js.map → dist-ChP4KvKi.js.map} +1 -1
- package/public/assets/{dist-CePvvSwo.js → dist-Cnlh_NpI.js} +2 -2
- package/public/assets/{dist-CePvvSwo.js.map → dist-Cnlh_NpI.js.map} +1 -1
- package/public/assets/{dist-DJ6ZVqRl.js → dist-CydxJz3m.js} +2 -2
- package/public/assets/{dist-DJ6ZVqRl.js.map → dist-CydxJz3m.js.map} +1 -1
- package/public/assets/{dist-Djf_WfhW.js → dist-D7K3qgp7.js} +2 -2
- package/public/assets/{dist-Djf_WfhW.js.map → dist-D7K3qgp7.js.map} +1 -1
- package/public/assets/{dist-otKoCUDq.js → dist-D8Yr1AIJ.js} +2 -2
- package/public/assets/{dist-otKoCUDq.js.map → dist-D8Yr1AIJ.js.map} +1 -1
- package/public/assets/{dist-BauUE17c.js → dist-DeAdFM5_.js} +2 -2
- package/public/assets/{dist-BauUE17c.js.map → dist-DeAdFM5_.js.map} +1 -1
- package/public/assets/{dist-CROpCfON.js → dist-DeM72J6a.js} +2 -2
- package/public/assets/{dist-CROpCfON.js.map → dist-DeM72J6a.js.map} +1 -1
- package/public/assets/{dist-CW_EpVCQ.js → dist-DfQP9-VC.js} +2 -2
- package/public/assets/{dist-CW_EpVCQ.js.map → dist-DfQP9-VC.js.map} +1 -1
- package/public/assets/{es2015-t3pwjvKi.js → es2015-C3DnXBqu.js} +2 -2
- package/public/assets/{es2015-t3pwjvKi.js.map → es2015-C3DnXBqu.js.map} +1 -1
- package/public/assets/{formatted-body-impl-DhvR8Z-A.js → formatted-body-impl-D2F76gPY.js} +2 -2
- package/public/assets/{formatted-body-impl-DhvR8Z-A.js.map → formatted-body-impl-D2F76gPY.js.map} +1 -1
- package/public/assets/index-CQQTCZxg.css +2 -0
- package/public/assets/index-DYmgI4s4.js +22 -0
- package/public/assets/{index-VGRP16ua.js.map → index-DYmgI4s4.js.map} +1 -1
- package/public/assets/{input-08ItMIki.js → input-Cqqq0OFl.js} +2 -2
- package/public/assets/{input-08ItMIki.js.map → input-Cqqq0OFl.js.map} +1 -1
- package/public/assets/{insights-v9noub5E.js → insights-DylYp2q4.js} +2 -2
- package/public/assets/{insights-v9noub5E.js.map → insights-DylYp2q4.js.map} +1 -1
- package/public/assets/{integrations-BEa3ArUw.js → integrations-B9ViWoJy.js} +2 -2
- package/public/assets/{integrations-BEa3ArUw.js.map → integrations-B9ViWoJy.js.map} +1 -1
- package/public/assets/{lib-CMqRPJG-.js → lib-6L4m0E3M.js} +2 -2
- package/public/assets/{lib-CMqRPJG-.js.map → lib-6L4m0E3M.js.map} +1 -1
- package/public/assets/{lucide-react-BbMYCUlW.js → lucide-react-DI8kTavp.js} +2 -2
- package/public/assets/{lucide-react-BbMYCUlW.js.map → lucide-react-DI8kTavp.js.map} +1 -1
- package/public/assets/{maintenance-DyRfVkhp.js → maintenance-inyZGLys.js} +2 -2
- package/public/assets/{maintenance-DyRfVkhp.js.map → maintenance-inyZGLys.js.map} +1 -1
- package/public/assets/{managed-agents-BSdMoBgG.js → managed-agents-CEFvMPN-.js} +2 -2
- package/public/assets/{managed-agents-BSdMoBgG.js.map → managed-agents-CEFvMPN-.js.map} +1 -1
- package/public/assets/{markdown-preview-impl-DidsrMmn.js → markdown-preview-impl-CniyG4_g.js} +2 -2
- package/public/assets/{markdown-preview-impl-DidsrMmn.js.map → markdown-preview-impl-CniyG4_g.js.map} +1 -1
- package/public/assets/memory-DDYGuRzr.js +2 -0
- package/public/assets/{memory-DM8muGVW.js.map → memory-DDYGuRzr.js.map} +1 -1
- package/public/assets/{messages-BqjAkcBF.js → messages-BMFcsMMa.js} +2 -2
- package/public/assets/{messages-BqjAkcBF.js.map → messages-BMFcsMMa.js.map} +1 -1
- package/public/assets/{orchestrators-C_mjUDZg.js → orchestrators-D5nL4a52.js} +2 -2
- package/public/assets/{orchestrators-C_mjUDZg.js.map → orchestrators-D5nL4a52.js.map} +1 -1
- package/public/assets/{overview-Cpu2plX-.js → overview-DywDrPKE.js} +2 -2
- package/public/assets/{overview-Cpu2plX-.js.map → overview-DywDrPKE.js.map} +1 -1
- package/public/assets/{pairs--8_0A0lq.js → pairs-UvIyBk4w.js} +2 -2
- package/public/assets/{pairs--8_0A0lq.js.map → pairs-UvIyBk4w.js.map} +1 -1
- package/public/assets/{projects-nCww9PG1.js → projects-DXBjwPU5.js} +2 -2
- package/public/assets/{projects-nCww9PG1.js.map → projects-DXBjwPU5.js.map} +1 -1
- package/public/assets/{react-dom-HJwa4sZ-.js → react-dom-Ct8qXivQ.js} +2 -2
- package/public/assets/{react-dom-HJwa4sZ-.js.map → react-dom-Ct8qXivQ.js.map} +1 -1
- package/public/assets/{security-CwgoEvJT.js → security-Boe7MEIz.js} +2 -2
- package/public/assets/{security-CwgoEvJT.js.map → security-Boe7MEIz.js.map} +1 -1
- package/public/assets/{select-Bhx6zSZr.js → select-Dh5Q8rJ8.js} +2 -2
- package/public/assets/{select-Bhx6zSZr.js.map → select-Dh5Q8rJ8.js.map} +1 -1
- package/public/assets/{settings-BNQBnKXg.js → settings-Ch4jMDrE.js} +3 -3
- package/public/assets/{settings-BNQBnKXg.js.map → settings-Ch4jMDrE.js.map} +1 -1
- package/public/assets/{store-BB-YW24l.js → store-BRvMMH5T.js} +2 -2
- package/public/assets/{store-BB-YW24l.js.map → store-BRvMMH5T.js.map} +1 -1
- package/public/assets/{tasks-C5Kv18N7.js → tasks-DrW8R52c.js} +2 -2
- package/public/assets/{tasks-C5Kv18N7.js.map → tasks-DrW8R52c.js.map} +1 -1
- package/public/assets/{teams-D_Ttv7qD.js → teams-CJqpAwmO.js} +2 -2
- package/public/assets/{teams-D_Ttv7qD.js.map → teams-CJqpAwmO.js.map} +1 -1
- package/public/assets/{terminal-viewer-impl-5y8v9jNx.js → terminal-viewer-impl-1_7v8GfU.js} +3 -3
- package/public/assets/{terminal-viewer-impl-5y8v9jNx.js.map → terminal-viewer-impl-1_7v8GfU.js.map} +1 -1
- package/public/assets/{use-keyboard-viewport-CEmOxaNm.js → use-keyboard-viewport-DxmCAbQi.js} +2 -2
- package/public/assets/{use-keyboard-viewport-CEmOxaNm.js.map → use-keyboard-viewport-DxmCAbQi.js.map} +1 -1
- package/public/assets/work-queue-BnIi7evb.js +2 -0
- package/public/assets/{work-queue-BB7bYLIK.js.map → work-queue-BnIi7evb.js.map} +1 -1
- package/public/assets/workspaces-u5j6mOlA.js +3 -0
- package/public/assets/{workspaces-CrtAeVnv.js.map → workspaces-u5j6mOlA.js.map} +1 -1
- package/public/index.html +21 -21
- package/runner/src/adapter.ts +7 -1
- package/runner/src/config.ts +4 -0
- package/src/db/message-reads.ts +8 -46
- package/src/db/messages.ts +208 -0
- package/src/db/notification-subscriptions.ts +68 -12
- package/src/index.ts +1 -1
- package/src/mcp/tools-spawn.ts +1 -1
- package/src/mcp-notification-subscription-tools.ts +90 -4
- package/src/memory-service.ts +14 -0
- package/src/notification-router.ts +9 -75
- package/src/notification-rules.ts +3 -3
- package/src/notification-subscription-rules.ts +11 -0
- package/src/notification-types.ts +70 -0
- package/src/project-instructions.ts +82 -9
- package/src/services/send-message.ts +5 -0
- package/src/services/spawn-agent.ts +13 -12
- package/src/spawn-command.ts +2 -0
- package/src/sse.ts +39 -2
- package/public/assets/MessageBubble-DPcJxTJj.js +0 -3
- package/public/assets/MessageBubble-DPcJxTJj.js.map +0 -1
- package/public/assets/branch-state-badge-C7H8HY22.js +0 -2
- package/public/assets/chat-DJqvtoFT.js +0 -2
- package/public/assets/chat-DJqvtoFT.js.map +0 -1
- package/public/assets/copy-button-DqAoeiPC.js +0 -2
- package/public/assets/index-Dh7NjR-l.css +0 -2
- package/public/assets/index-VGRP16ua.js +0 -22
- package/public/assets/memory-DM8muGVW.js +0 -2
- package/public/assets/work-queue-BB7bYLIK.js +0 -2
- package/public/assets/workspaces-CrtAeVnv.js +0 -3
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageBubble-DPcJxTJj.js","names":[],"sources":["../../dashboard/src/components/chat/sessionTrace.ts","../../dashboard/src/components/chat/helpers.ts","../../dashboard/src/components/chat/TraceView.tsx","../../dashboard/src/components/chat/hooks/useTtsPlayingKey.ts","../../dashboard/src/components/chat/MessageBubble.tsx"],"sourcesContent":["\nimport { isReactionEventMessage, messageBody, toTimestamp, responseBodyContainsBlock } from '@/lib/display'\nimport { HUMAN_AGENT_ID } from '@/lib/constants'\nimport type { ChatStatusEvent as StatusEvent } from '@/store'\nimport type { ChatHistoryImport, ChatHistoryImportEntry, Message } from '@/types'\n\nexport interface ActivityStep { id: number; kind: 'narration' | 'reasoning' | 'tool'; label?: string; text: string; ts: number; turnId?: string }\n\nexport type TimelineEntry =\n | { type: 'message'; msg: Message }\n | { type: 'initial-prompt'; msg: Message }\n | { type: 'notice'; msg: Message }\n | { type: 'agent-action'; direction: 'spawned-child' | 'spawned-by'; agentId: string; provider?: string; status: 'ready' | 'exited' | 'failed'; reason?: string; timestamp: number }\n | { type: 'activity'; steps: ActivityStep[]; timestamp: number }\n | { type: 'import-boundary'; history: ChatHistoryImport; timestamp: number }\n | { type: 'imported-message'; history: ChatHistoryImport; entry: ChatHistoryImportEntry }\n | { type: 'status'; event: StatusEvent }\n | { type: 'date'; date: string; timestamp: number }\n | { type: 'created'; timestamp: number }\n\nexport const TIMELINE_STATUS_LABELS: Record<string, string> = {\n online: 'came online',\n offline: 'went offline',\n shutdown: 'shut down',\n restarted: 'restarted',\n 'compaction-requested': 'compaction requested',\n compacting: 'compaction started',\n compacted: 'context compacted',\n 'compaction-stalled': 'compaction stalled — may need manual intervention',\n 'clear-requested': 'clear requested',\n 'clearing-context': 'clear started',\n 'context-cleared': 'context cleared',\n 'clear-stalled': 'context clear stalled — may need manual intervention',\n 'shutting-down': 'shutting down',\n}\n\nconst TIMELINE_STATUSES = new Set(Object.keys(TIMELINE_STATUS_LABELS))\nconst STATUS_DEDUPE_WINDOW_MS = 3000\n\n// True event time of a message: occurredAt (set when a Runner backfilled a message it had\n// queued during an outage, #196) falling back to the server receive time. Used for chat\n// timeline ordering + display so a backfilled turn lands where it actually happened in the\n// conversation, not at the bottom. Display-only — DB poll cursors still use created_at.\nfunction messageEventTime(msg: Message): number {\n return new Date(msg.occurredAt ?? msg.createdAt).getTime()\n}\n\n// Narration/reasoning/tool session events are mirrored as `kind:\"session\"` messages\n// but must not become chat bubbles — they render inline in the turn's activity trace.\n// (`narration` = the agent's intermediate spoken text; `reasoning` = its thinking.)\nexport function sessionActivityStep(msg: Message): ActivityStep | null {\n if (msg.kind !== 'session') return null\n const s = msg.payload?.session as { type?: string; label?: string; turnId?: string } | undefined\n if (!s || (s.type !== 'narration' && s.type !== 'reasoning' && s.type !== 'tool')) return null\n return {\n id: msg.id,\n kind: s.type,\n label: typeof s.label === 'string' ? s.label : undefined,\n text: msg.body,\n ts: messageEventTime(msg),\n turnId: typeof s.turnId === 'string' ? s.turnId : undefined,\n }\n}\n\n// A `notice` session event (e.g. the runner's durable \"context compacted\" marker) renders\n// as a discreet timeline marker, reusing the StatusMarker path. Its `label` carries a\n// timeline-status key (e.g. \"compacted\"); we surface it as a StatusEvent so it dedupes with\n// the ephemeral live timeline-status decoration and survives a reload (the ephemeral one does\n// not). Returns null for non-notice messages or labels we don't render.\nexport function sessionNoticeStatusEvent(msg: Message): StatusEvent | null {\n if (msg.kind !== 'session') return null\n const s = msg.payload?.session as { type?: string; label?: string } | undefined\n if (s?.type !== 'notice') return null\n const status = typeof s.label === 'string' && s.label ? s.label : 'compacted'\n return { id: `notice-${msg.id}`, status, timestamp: messageEventTime(msg) }\n}\n\nfunction stripLeadingResponseBlocks(body: string, blocks: string[]): string {\n let remaining = body.trim()\n for (const raw of blocks) {\n const block = raw.trim()\n if (!block) continue\n if (remaining === block) break\n if (remaining.startsWith(`${block}\\n\\n`)) {\n remaining = remaining.slice(block.length + 2).trimStart()\n }\n }\n return remaining.trim() || body.trim()\n}\n\n// Bus-level system signals (kind:\"system\", from:\"system\") — e.g. branch.landed,\n// agent.context_threshold, workspace.* events. Rendered as notice pills (NoticePill\n// labels/humanizes the kind, #507), NOT chat bubbles or session status markers.\nexport function isBusSignalMessage(msg: Message): boolean {\n return msg.kind === 'system' && msg.from === 'system'\n}\n\n// Spawn lifecycle signals routed to the parent: agent.ready / agent.exited / agent.spawn_failed.\n// These are richer than generic bus signals and get their own agent-action timeline entry.\nconst LIFECYCLE_KINDS = new Set(['agent.ready', 'agent.exited', 'agent.spawn_failed'])\n\nexport function dateKey(ts: number): string {\n const d = new Date(ts)\n return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`\n}\n\nexport function dedupeStatusEvents(statusEvents: StatusEvent[]): StatusEvent[] {\n const events = statusEvents\n .filter((event) => TIMELINE_STATUSES.has(event.status))\n .slice()\n .sort((a, b) => a.timestamp - b.timestamp)\n const result: StatusEvent[] = []\n for (const event of events) {\n if (result.some((existing) => existing.id === event.id)) continue\n if (result.some((existing) => existing.status === event.status && Math.abs(existing.timestamp - event.timestamp) <= STATUS_DEDUPE_WINDOW_MS)) continue\n result.push(event)\n }\n return result\n}\n\nexport function buildTimeline(\n messages: Message[],\n statusEvents: StatusEvent[],\n createdAt?: string | number | null,\n importedHistory: ChatHistoryImport[] = [],\n options?: { spawnedBy?: { agentId: string; provider?: string } },\n): TimelineEntry[] {\n const raw: Array<{ ts: number; entry: TimelineEntry }> = []\n\n for (const history of importedHistory) {\n const firstImportedAt = history.entries.reduce((min, entry) => Math.min(min, toTimestamp(entry.originalCreatedAt)), Number.POSITIVE_INFINITY)\n const boundaryAt = Number.isFinite(firstImportedAt) ? firstImportedAt - 1 : history.importedAt\n raw.push({ ts: boundaryAt, entry: { type: 'import-boundary', history, timestamp: boundaryAt } })\n for (const entry of history.entries) {\n raw.push({ ts: toTimestamp(entry.originalCreatedAt), entry: { type: 'imported-message', history, entry } })\n }\n }\n\n if (createdAt) {\n const ts = new Date(createdAt as string).getTime()\n if (Number.isFinite(ts)) raw.push({ ts, entry: { type: 'created', timestamp: ts } })\n }\n\n // Synthetic \"spawned by\" lead entry for child agents — derives from the agent's spawnedBy\n // metadata (no inbound system message exists for this direction). Placed at createdAt so it\n // sorts as the first real entry after the created/date markers.\n if (options?.spawnedBy) {\n const ts = createdAt ? new Date(createdAt as string).getTime() : 0\n const spawnedByTs = Number.isFinite(ts) ? ts : 0\n raw.push({ ts: spawnedByTs, entry: { type: 'agent-action', direction: 'spawned-by', agentId: options.spawnedBy.agentId, provider: options.spawnedBy.provider, status: 'ready', timestamp: spawnedByTs } })\n }\n\n // The initial/spawn prompt (#513): the earliest real prompt that kicked off the\n // session — a human prompt, or (for a spawned agent) the first message from the spawn\n // parent. Tagged so it renders with a distinct title instead of as a normal bubble or\n // a folded peer one-liner. Skip session events, bus signals, reactions, and empty bodies.\n const spawnParentId = options?.spawnedBy?.agentId\n let initialPromptId: number | null = null\n let initialPromptTs = Number.POSITIVE_INFINITY\n for (const msg of messages) {\n if (msg.kind === 'session' || isBusSignalMessage(msg) || isReactionEventMessage(msg)) continue\n const fromInitiator = msg.from === HUMAN_AGENT_ID || (spawnParentId !== undefined && msg.from === spawnParentId)\n if (!fromInitiator || !messageBody(msg).trim()) continue\n const ts = messageEventTime(msg)\n if (ts < initialPromptTs) { initialPromptTs = ts; initialPromptId = msg.id }\n }\n\n // A full-capture response stores the turn's narration blocks plus the final\n // answer. Keep the stored message intact, but derive what the response bubble\n // should show: strip leading narration blocks and leave the final visible block.\n // Narration suppression then compares against that visible block only, preserving\n // the live chronological trace after the turn completes.\n const responseBodiesByTurn = new Map<string, string[]>()\n const narrationByTurn = new Map<string, Array<{ id: number; body: string }>>()\n const responseDisplayBodyByMessageId = new Map<number, string>()\n for (const msg of messages) {\n if (msg.kind !== 'session') continue\n const s = msg.payload?.session as { type?: string; turnId?: string } | undefined\n if (s?.type === 'narration' && typeof s.turnId === 'string') {\n const list = narrationByTurn.get(s.turnId) ?? []\n list.push({ id: msg.id, body: msg.body.trim() })\n narrationByTurn.set(s.turnId, list)\n } else if (s?.type === 'response' && typeof s.turnId === 'string') {\n const list = responseBodiesByTurn.get(s.turnId) ?? []\n list.push(msg.body.trim())\n responseBodiesByTurn.set(s.turnId, list)\n }\n }\n const responseDisplayBodiesByTurn = new Map<string, string[]>()\n for (const [turnId, bodies] of responseBodiesByTurn) {\n const narrationBodies = (narrationByTurn.get(turnId) ?? []).map((item) => item.body)\n responseDisplayBodiesByTurn.set(turnId, bodies.map((body) => stripLeadingResponseBlocks(body, narrationBodies)))\n }\n for (const msg of messages) {\n if (msg.kind !== 'session') continue\n const s = msg.payload?.session as { type?: string; turnId?: string } | undefined\n if (s?.type !== 'response' || typeof s.turnId !== 'string') continue\n const displayBody = stripLeadingResponseBlocks(msg.body, (narrationByTurn.get(s.turnId) ?? []).map((item) => item.body))\n if (displayBody && displayBody !== msg.body) responseDisplayBodyByMessageId.set(msg.id, displayBody)\n }\n const suppressedNarrationIds = new Set<number>()\n for (const [turnId, bodies] of responseDisplayBodiesByTurn) {\n const narrations = narrationByTurn.get(turnId) ?? []\n for (const body of bodies) {\n for (let i = narrations.length - 1; i >= 0; i--) {\n const narration = narrations[i]!\n if (suppressedNarrationIds.has(narration.id)) continue\n if (!responseBodyContainsBlock(body, narration.body)) continue\n suppressedNarrationIds.add(narration.id)\n break\n }\n }\n }\n\n // Tracks in-progress agent-action entries by child id so ready→exited coalesces into one entry.\n type RawAgentAction = { ts: number; entry: Extract<TimelineEntry, { type: 'agent-action' }> }\n const agentActionByChild = new Map<string, RawAgentAction>()\n\n const noticeStatusEvents: StatusEvent[] = []\n for (const msg of messages) {\n if (isBusSignalMessage(msg)) {\n const kind = typeof msg.payload?.kind === 'string' ? msg.payload.kind : ''\n if (LIFECYCLE_KINDS.has(kind)) {\n const p = msg.payload as { kind: string; agentId?: string; provider?: string; reason?: string }\n const childId = typeof p.agentId === 'string' ? p.agentId : ''\n const ts = messageEventTime(msg)\n if (!childId) {\n // agent.spawn_failed without a child id (command-level failure): fall through to notice\n raw.push({ ts, entry: { type: 'notice', msg } })\n continue\n }\n const status: 'ready' | 'exited' | 'failed' = kind === 'agent.ready' ? 'ready' : kind === 'agent.exited' ? 'exited' : 'failed'\n const existing = agentActionByChild.get(childId)\n if (existing) {\n // Coalesce: evolve the same entry to the final status in place\n existing.entry.status = status\n if (typeof p.reason === 'string') existing.entry.reason = p.reason\n existing.entry.timestamp = ts\n existing.ts = ts\n } else {\n const item: RawAgentAction = {\n ts,\n entry: {\n type: 'agent-action',\n direction: 'spawned-child',\n agentId: childId,\n provider: typeof p.provider === 'string' ? p.provider : undefined,\n status,\n reason: typeof p.reason === 'string' ? p.reason : undefined,\n timestamp: ts,\n },\n }\n agentActionByChild.set(childId, item)\n raw.push(item)\n }\n continue\n }\n raw.push({ ts: messageEventTime(msg), entry: { type: 'notice', msg } })\n continue\n }\n const notice = sessionNoticeStatusEvent(msg)\n if (notice) {\n noticeStatusEvents.push(notice)\n continue\n }\n const step = sessionActivityStep(msg)\n if (step) {\n if (step.kind === 'narration' && suppressedNarrationIds.has(step.id)) continue\n raw.push({ ts: step.ts, entry: { type: 'activity', steps: [step], timestamp: step.ts } })\n continue\n }\n if (msg.kind === 'session') {\n const s = msg.payload?.session as { type?: string; turnId?: string } | undefined\n if (s?.type === 'response' && typeof s.turnId === 'string') {\n const body = responseDisplayBodyByMessageId.get(msg.id)\n if (body && body !== msg.body) {\n raw.push({ ts: messageEventTime(msg), entry: { type: 'message', msg: { ...msg, body } } })\n continue\n }\n }\n }\n const entryType = msg.id === initialPromptId ? 'initial-prompt' : 'message'\n raw.push({ ts: messageEventTime(msg), entry: { type: entryType, msg } })\n }\n for (const event of dedupeStatusEvents([...statusEvents, ...noticeStatusEvents])) {\n raw.push({ ts: event.timestamp, entry: { type: 'status', event } })\n }\n\n const typeOrder = { created: 0, date: 1, 'import-boundary': 2, 'imported-message': 3, 'initial-prompt': 4, message: 4, activity: 4, notice: 4, 'agent-action': 4, status: 5 } as const\n raw.sort((a, b) => {\n const dt = a.ts - b.ts\n if (Math.abs(dt) < 3000) return typeOrder[a.entry.type] - typeOrder[b.entry.type] || dt\n return dt\n })\n\n const entries: TimelineEntry[] = []\n let lastDate = ''\n for (const { ts, entry } of raw) {\n if (entry.type === 'created') {\n entries.push(entry)\n continue\n }\n const dk = dateKey(ts)\n if (dk !== lastDate) {\n entries.push({ type: 'date', date: dk, timestamp: ts })\n lastDate = dk\n }\n // Coalesce consecutive activity steps from the same turn into one trace.\n if (entry.type === 'activity') {\n const prev = entries[entries.length - 1]\n if (prev && prev.type === 'activity' && sameActivityTurn(prev, entry)) {\n prev.steps.push(...entry.steps)\n continue\n }\n }\n entries.push(entry)\n }\n\n return entries\n}\n\n// Stable per-entry key — used by Virtuoso for reconciliation AND by chat search to\n// address a match back to its timeline row. Lives here (pure logic) rather than in\n// VirtualTimeline so the search layer can reuse it without pulling in react-virtuoso.\nexport function timelineEntryKey(entry: TimelineEntry): string {\n if (entry.type === 'message') return `msg-${entry.msg.id}`\n if (entry.type === 'initial-prompt') return `initprompt-${entry.msg.id}`\n if (entry.type === 'notice') return `notice-${entry.msg.id}`\n if (entry.type === 'agent-action') return `agent-action-${entry.direction}-${entry.agentId}`\n // Key by the FIRST step only — stable as the turn streams. Including the last\n // step's id rekeyed the entry on every appended step, so virtuoso treated the\n // in-place-growing turn as a replaced item and lost its resize anchoring: the\n // viewport jumped down by the added height while scrolled up reading history.\n if (entry.type === 'activity') return `act-${entry.steps[0]?.id ?? entry.timestamp}`\n if (entry.type === 'import-boundary') return `import-${entry.history.id}`\n if (entry.type === 'imported-message') return `import-msg-${entry.history.id}-${entry.entry.originalMessageId}-${entry.entry.position}`\n if (entry.type === 'status') return `status-${entry.event.id}`\n if (entry.type === 'date') return `date-${entry.date}`\n return `created-${entry.timestamp}`\n}\n\n// Searchable plain text for an entry — what chat search matches against. Only entries\n// that carry human-readable content contribute; structural rows (date/status/created/\n// agent-action/import-boundary) return '' so they're never search targets.\nexport function timelineEntryText(entry: TimelineEntry): string {\n if (entry.type === 'message' || entry.type === 'initial-prompt' || entry.type === 'notice') {\n const subject = entry.msg.subject ? `${entry.msg.subject} ` : ''\n return subject + messageBody(entry.msg)\n }\n if (entry.type === 'imported-message') return messageBody(entry.entry.message)\n if (entry.type === 'activity') {\n return entry.steps.map((step) => [step.label, step.text].filter(Boolean).join(' ')).join('\\n')\n }\n return ''\n}\n\nexport function sameActivityTurn(a: Extract<TimelineEntry, { type: 'activity' }>, b: Extract<TimelineEntry, { type: 'activity' }>): boolean {\n const at = a.steps[a.steps.length - 1]?.turnId\n const bt = b.steps[0]?.turnId\n if (at && bt) return at === bt\n // No turn id on either side: group adjacent steps regardless.\n return !at && !bt\n}\n","\nimport { AlertCircle, Check, CheckCheck, Clock } from 'lucide-react'\nimport { HUMAN_AGENT_ID } from '@/lib/constants'\nimport {\n isBadgeWorthy,\n isReactionEventMessage,\n normalizePathForCompare,\n normalizeReactionEmoji,\n pathWithinBase,\n toTimestamp,\n} from '@/lib/display'\nimport { planLookupKey } from '@/store/slices/plans'\nimport type { Agent, AttachmentRef, InboxThread, Message, Orchestrator, Plan } from '@/types'\nimport type { PendingAttachment } from './types'\n\nexport function formatBytes(size: number): string {\n if (size < 1024) return `${size} B`\n if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`\n return `${(size / 1024 / 1024).toFixed(1)} MB`\n}\n\nexport function resolveRelativePath(cwd: string, path: string): string {\n if (path.startsWith('/')) return path\n const parts = `${cwd.replace(/\\/+$/, '')}/${path}`.split('/')\n const stack: string[] = []\n for (const part of parts) {\n if (!part || part === '.') continue\n if (part === '..') stack.pop()\n else stack.push(part)\n }\n return '/' + stack.join('/')\n}\n\nexport function parentPath(path: string): string {\n const trimmed = path.replace(/\\/+$/, '')\n const index = trimmed.lastIndexOf('/')\n return index > 0 ? trimmed.slice(0, index) : '/'\n}\n\nexport function orchestratorForFilePreview(orchestrators: Orchestrator[], path: string): Orchestrator | undefined {\n return orchestrators\n .filter((orch) => orch.status === 'online' && pathWithinBase(path, orch.baseDir))\n .sort((a, b) => normalizePathForCompare(b.baseDir).length - normalizePathForCompare(a.baseDir).length)[0] ||\n orchestrators.find((orch) => orch.status === 'online')\n}\n\nexport function supportsSideFilePreview(): boolean {\n return typeof window !== 'undefined' && window.matchMedia('(min-width: 1280px)').matches\n}\n\nexport function hasActiveTextSelection(): boolean {\n return typeof window !== 'undefined' && Boolean(window.getSelection()?.toString())\n}\n\nexport function messageAttachments(msg: Message): AttachmentRef[] {\n const attachments = msg.payload?.attachments\n if (!Array.isArray(attachments)) return []\n return attachments.filter((item): item is AttachmentRef => Boolean(item && typeof item === 'object' && typeof (item as AttachmentRef).artifactId === 'string'))\n}\n\nexport const QUICK_REACTIONS = ['👍', '❤️', '✅', '👀'] as const\n\nexport function groupedReactions(msg: Message): Array<{ emoji: string; count: number; mine: boolean; actors: string[] }> {\n const groups = new Map<string, { emoji: string; count: number; mine: boolean; actors: string[] }>()\n for (const reaction of msg.reactions || []) {\n const emoji = normalizeReactionEmoji(reaction.emoji)\n const current = groups.get(emoji) ?? { emoji, count: 0, mine: false, actors: [] }\n current.count += 1\n current.mine = current.mine || reaction.actorId === HUMAN_AGENT_ID\n current.actors.push(reaction.actorId)\n groups.set(emoji, current)\n }\n return [...groups.values()].sort((a, b) => b.count - a.count || a.emoji.localeCompare(b.emoji))\n}\n\nexport function isReactionEvent(msg: Message): boolean {\n return isReactionEventMessage(msg)\n}\n\nexport function outboundReceipt(msg: Message, peer: string): { label: string; title: string; tone: 'muted' | 'ok' | 'warn' | 'danger'; icon: typeof Check } {\n const readBy = msg.readBy || []\n const expectedReader = msg.resolvedToAgent || peer || msg.to\n const readByExpected = expectedReader ? readBy.includes(expectedReader) : false\n const readBySomeone = readBy.some((id) => id !== HUMAN_AGENT_ID)\n if (readByExpected || readBySomeone) {\n const reader = readByExpected ? expectedReader : readBy.find((id) => id !== HUMAN_AGENT_ID)\n return { label: 'read', title: reader ? `Read by ${reader}` : 'Read by agent', tone: 'ok', icon: CheckCheck }\n }\n if (msg.deliveryStatus === 'delivered') {\n return { label: 'delivered', title: 'Delivered to agent inbox', tone: 'ok', icon: CheckCheck }\n }\n if (msg.deliveryStatus === 'queued') {\n return { label: 'queued', title: 'Queued until the target agent is available', tone: 'warn', icon: Clock }\n }\n if (msg.deliveryStatus === 'failed' || msg.deliveryStatus === 'dead') {\n const detail = msg.deliveryPoisonReason || msg.deliveryLastError || msg.deliveryStatus\n return { label: msg.deliveryStatus, title: detail, tone: 'danger', icon: AlertCircle }\n }\n return { label: 'sent', title: 'Accepted by Relay', tone: 'muted', icon: Check }\n}\n\nfunction messageActivityTimestamp(msg: Message): number {\n const messageAt = toTimestamp(msg.createdAt)\n return (msg.reactions || []).reduce((latest, reaction) => {\n return Math.max(latest, toTimestamp(reaction.updatedAt || reaction.createdAt))\n }, messageAt)\n}\n\nexport function threadActivityTimestamp(thread: InboxThread | undefined): number {\n if (!thread) return 0\n return thread.messages.reduce((latest, msg) => Math.max(latest, messageActivityTimestamp(msg)), 0)\n}\n\n// Ascending-by-time comparator for the conversations-list sorts (last activity, last seen).\n// Older timestamp sorts first, so 'asc' (the default, SortAsc icon) reads oldest→newest and a\n// conversation whose agent just finished a turn appends at the bottom instead of being yanked\n// to the top on every turn-completion (#541). dir=-1 ('desc') flips it to newest-first.\nexport function compareConversationActivity(ta: number, tb: number, dir: number): number {\n return (ta - tb) * dir\n}\n\n// Time of the agent's last *final response* (`kind:\"session\"`, `type:\"response\"`) — what\n// the conversations list shows instead of a heartbeat/last-seen or any-message activity.\n// 0 when the agent hasn't produced a response yet (caller falls back to thread activity).\nexport function lastFinalResponseTimestamp(thread: InboxThread | undefined): number {\n if (!thread) return 0\n let latest = 0\n for (const msg of thread.messages) {\n if (isBadgeWorthy(msg)) latest = Math.max(latest, toTimestamp(msg.createdAt))\n }\n return latest\n}\n\nexport function chatTimestamp(iso: string | number): string {\n const d = new Date(iso as string)\n return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })\n}\n\nexport function revokePendingAttachmentUrls(items: PendingAttachment[]): void {\n for (const item of items) if (item.previewUrl) URL.revokeObjectURL(item.previewUrl)\n}\n\ntype ChatPlanContext = { threadId: string | number; channel?: string } | { teamId: string; channel?: string }\n\nexport function resolveChatPlanContext(\n agent: Agent | null,\n messages: Message[],\n lastMessage: Message | null | undefined,\n plansByThread: Record<string, Plan | null>,\n): ChatPlanContext | null {\n if (agent?.teamId) return { teamId: agent.teamId }\n const ordered = [...messages]\n if (lastMessage && !ordered.some((message) => message.id === lastMessage.id)) ordered.push(lastMessage)\n const threaded = ordered.filter((message) => message.threadId).reverse()\n const knownPlanMessage = threaded.find((message) => Boolean(plansByThread[planLookupKey(message.threadId!, message.channel)]))\n const selected = knownPlanMessage ?? threaded[0]\n if (!selected?.threadId) return null\n return {\n threadId: selected.threadId,\n ...(selected.channel ? { channel: selected.channel } : {}),\n }\n}\n","\nimport { useEffect, useMemo, useState, useSyncExternalStore } from 'react'\nimport type React from 'react'\nimport { AlertCircle, AlertTriangle, ArrowLeft, Brain, ChevronDown, ChevronRight, ChevronUp, Circle, CircleStop, GitFork, GitMerge, LogOut, PlugZap, Plus, Radio, Sparkles, Terminal } from 'lucide-react'\nimport type { LucideIcon } from 'lucide-react'\nimport { FormattedBody } from '@/components/shared/formatted-body'\nimport { HUMAN_AGENT_ID } from '@/lib/constants'\nimport { displayName, messageBody } from '@/lib/display'\nimport type { ChatHistoryImport, ChatHistoryImportEntry } from '@/types'\nimport { cn } from '@/lib/utils'\nimport { chatTimestamp } from './helpers'\nimport { dateKey, TIMELINE_STATUS_LABELS, type ActivityStep, type TimelineEntry } from './sessionTrace'\nimport type { Message } from '@/types'\nimport type { ChatStatusEvent as StatusEvent } from '@/store'\nimport { useRelayStore } from '@/store'\nimport { AgentTypeIcon } from '@/components/shared/agent-type-icon'\n\nconst TIMELINE_STATUS_COLORS: Record<string, string> = {\n online: 'text-emerald-400',\n offline: 'text-zinc-400',\n shutdown: 'text-zinc-400',\n restarted: 'text-blue-400',\n 'compaction-requested': 'text-zinc-400',\n compacting: 'text-amber-400',\n compacted: 'text-amber-400',\n 'compaction-stalled': 'text-red-400',\n 'clear-requested': 'text-zinc-400',\n 'clearing-context': 'text-amber-400',\n 'context-cleared': 'text-amber-400',\n 'clear-stalled': 'text-red-400',\n 'shutting-down': 'text-zinc-400',\n}\n\nfunction dateSeparatorLabel(dateStr: string): string {\n const today = new Date()\n const [y, m, d] = dateStr.split('-').map(Number)\n const target = new Date(y!, m! - 1, d)\n const todayKey = dateKey(today.getTime())\n if (dateStr === todayKey) return 'Today'\n const yesterday = new Date(today)\n yesterday.setDate(yesterday.getDate() - 1)\n if (dateStr === dateKey(yesterday.getTime())) return 'Yesterday'\n return target.toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric', year: target.getFullYear() !== today.getFullYear() ? 'numeric' : undefined })\n}\n\nexport function StatusMarker({ event }: { event: StatusEvent }) {\n return (\n <div className=\"flex items-center justify-center gap-2 py-2 my-1\">\n <div className=\"h-px flex-1 bg-border\" />\n <div className=\"flex items-center gap-1.5 text-xs text-muted-foreground\">\n <Circle className={cn('w-2 h-2 fill-current', TIMELINE_STATUS_COLORS[event.status] || 'text-zinc-400')} />\n <span>{TIMELINE_STATUS_LABELS[event.status] || event.status}</span>\n <span className=\"text-muted-foreground/60\">{chatTimestamp(event.timestamp)}</span>\n </div>\n <div className=\"h-px flex-1 bg-border\" />\n </div>\n )\n}\n\nconst BUS_SIGNAL_ICON: Record<string, LucideIcon> = {\n 'branch.landed': GitMerge,\n 'context.warning': AlertTriangle,\n 'agent.context_threshold': AlertTriangle,\n 'agent.resume_budget_exhausted': AlertTriangle,\n 'agent.rate_limit_resume': PlugZap,\n}\n\n// Explicit overrides for kinds that read better with custom wording; every other bus\n// signal is humanized from its kind (see humanizeSignalKind) so no event renders as a\n// raw dotted identifier and nothing is silently dropped (#507).\nconst BUS_SIGNAL_LABEL: Record<string, string> = {\n 'branch.landed': 'branch landed',\n 'context.warning': 'context warning',\n 'agent.context_threshold': 'context threshold reached',\n}\n\n// Turn an unmapped bus-signal kind into a readable label: drop the leading namespace\n// segment and normalize separators. e.g. `agent.rate_limit_resume` → \"rate limit resume\",\n// `workspace.review-request` → \"review request\". Falls back to \"system signal\" if empty.\nfunction humanizeSignalKind(kind: string): string {\n if (!kind) return 'system signal'\n const withoutNamespace = kind.includes('.') ? kind.slice(kind.indexOf('.') + 1) : kind\n const words = withoutNamespace.replace(/[._-]+/g, ' ').trim()\n return words || 'system signal'\n}\n\n// Inline, clickable agent reference — the ONE place chat resolves an agent id to a\n// label (#522: prefer label everywhere) and links it to that agent's chat (#522: every\n// reference links). Falls back to the raw id only when the agent is unknown and no\n// fallback label was supplied. Reused by NoticePill, AgentActionEntry, and MessageBubble.\nexport function AgentLink({ agentId, fallbackLabel, className }: { agentId: string; fallbackLabel?: string; className?: string }) {\n const agent = useRelayStore((s) => s.agentsById[agentId]) || null\n const openInboxThread = useRelayStore((s) => s.openInboxThread)\n const switchView = useRelayStore((s) => s.switchView)\n const label = agent ? displayName(agent) : (fallbackLabel || agentId)\n return (\n <button\n type=\"button\"\n className={cn('inline-flex max-w-full items-center gap-1 rounded px-1 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground', className)}\n onClick={(e) => { e.stopPropagation(); openInboxThread(agentId); void switchView('chat') }}\n title={`Open chat for ${label}`}\n >\n <AgentTypeIcon agent={agent} className=\"w-4 h-4 text-[10px]\" />\n <span className=\"max-w-[160px] truncate\">{label}</span>\n </button>\n )\n}\n\n// Branch-landed gets a richer pill than the generic notice: the short merge SHA plus a\n// linked \"by {agent}\" attribution (#509). The payload (src/branch-landed.ts) carries\n// sha (mergedSha), author (ownerAgentId), branch, base — all previously dropped.\nfunction BranchLandedPill({ msg }: { msg: Message }) {\n const payload = (msg.payload ?? {}) as Record<string, unknown>\n const sha = typeof payload.sha === 'string' ? payload.sha : ''\n const shortSha = sha ? sha.slice(0, 7) : ''\n const author = typeof payload.author === 'string' ? payload.author : ''\n const branch = typeof payload.branch === 'string' ? payload.branch : ''\n const base = typeof payload.base === 'string' ? payload.base : ''\n const pushed = payload.pushed\n return (\n <div className=\"flex items-center justify-center gap-2 py-2 my-1\">\n <div className=\"h-px flex-1 bg-border\" />\n <div className=\"flex max-w-full flex-wrap items-center justify-center gap-x-1.5 gap-y-0.5 rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1 text-xs text-emerald-300/90\">\n <GitMerge className=\"h-3 w-3 shrink-0 text-emerald-400\" />\n <span className=\"text-emerald-300\">branch landed</span>\n {branch && base && (\n <span className=\"font-mono text-emerald-200/70\" title={`${branch} → ${base}`}>\n {branch}<span className=\"opacity-50\"> → </span>{base}\n </span>\n )}\n {shortSha && (\n <span className=\"rounded bg-emerald-500/15 px-1 font-mono text-emerald-200\" title={sha}>{shortSha}</span>\n )}\n {author && (\n <span className=\"inline-flex items-center gap-1 text-emerald-300/80\">\n <span className=\"opacity-70\">by</span>\n <AgentLink agentId={author} className=\"text-emerald-300/90 hover:text-emerald-100\" />\n </span>\n )}\n {pushed === false && <span className=\"text-amber-300/80\" title=\"Local-only land — not pushed to origin\">· local only</span>}\n <span className=\"text-emerald-300/50\">{chatTimestamp(msg.occurredAt ?? (msg.createdAt as string))}</span>\n </div>\n <div className=\"h-px flex-1 bg-border\" />\n </div>\n )\n}\n\nexport function NoticePill({ msg }: { msg: Message }) {\n const signalKind = typeof msg.payload?.kind === 'string' ? msg.payload.kind : ''\n if (signalKind === 'branch.landed') return <BranchLandedPill msg={msg} />\n const Icon: LucideIcon = BUS_SIGNAL_ICON[signalKind] ?? Radio\n const label = BUS_SIGNAL_LABEL[signalKind] ?? humanizeSignalKind(signalKind)\n return (\n <div className=\"flex items-center justify-center gap-2 py-2 my-1\">\n <div className=\"h-px flex-1 bg-border\" />\n <div className=\"flex items-center gap-1.5 rounded-full border border-border bg-muted/30 px-2.5 py-1 text-xs text-muted-foreground\">\n <Icon className=\"h-3 w-3\" />\n <span>{label}</span>\n <span className=\"text-muted-foreground/60\">{chatTimestamp(msg.occurredAt ?? (msg.createdAt as string))}</span>\n </div>\n <div className=\"h-px flex-1 bg-border\" />\n </div>\n )\n}\n\nconst AGENT_ACTION_VERB: Record<string, Record<string, string>> = {\n 'spawned-child': { ready: 'spawned', exited: 'spawned · exited', failed: 'spawn failed' },\n 'spawned-by': { ready: 'spawned by', exited: 'spawned by', failed: 'spawned by' },\n}\n\nconst AGENT_ACTION_ICON: Record<string, LucideIcon> = {\n 'spawned-child-ready': Plus,\n 'spawned-child-exited': LogOut,\n 'spawned-child-failed': AlertCircle,\n 'spawned-by-ready': ArrowLeft,\n 'spawned-by-exited': ArrowLeft,\n 'spawned-by-failed': ArrowLeft,\n}\n\nconst AGENT_ACTION_COLOR: Record<string, string> = {\n 'spawned-child-ready': 'text-emerald-400',\n 'spawned-child-exited': 'text-zinc-400',\n 'spawned-child-failed': 'text-red-400',\n 'spawned-by-ready': 'text-blue-400',\n 'spawned-by-exited': 'text-blue-400',\n 'spawned-by-failed': 'text-blue-400',\n}\n\nexport function AgentActionEntry({ entry }: { entry: Extract<TimelineEntry, { type: 'agent-action' }> }) {\n const key = `${entry.direction}-${entry.status}`\n const verb = AGENT_ACTION_VERB[entry.direction]?.[entry.status] ?? entry.direction\n const Icon: LucideIcon = AGENT_ACTION_ICON[key] ?? Radio\n const color = AGENT_ACTION_COLOR[key] ?? 'text-muted-foreground'\n const isError = entry.status === 'failed'\n\n return (\n <div className=\"flex items-center justify-center gap-2 py-2 my-1\">\n <div className=\"h-px flex-1 bg-border\" />\n <div className={cn('flex items-center gap-1.5 rounded-full border bg-muted/30 px-2.5 py-1 text-xs', isError ? 'border-red-500/30' : 'border-border')}>\n <Icon className={cn('h-3 w-3 shrink-0', color)} />\n <span className=\"text-muted-foreground\">{verb}</span>\n <AgentLink agentId={entry.agentId} />\n {entry.reason && isError && (\n <span className=\"text-red-400/80 max-w-[120px] truncate\" title={entry.reason}>— {entry.reason}</span>\n )}\n <span className=\"text-muted-foreground/60 shrink-0\">{chatTimestamp(entry.timestamp)}</span>\n </div>\n <div className=\"h-px flex-1 bg-border\" />\n </div>\n )\n}\n\nexport function BusyIndicator({ blockedLabel, onInterrupt }: { blockedLabel?: string; onInterrupt?: () => void }) {\n if (blockedLabel) {\n return (\n <div className=\"flex justify-start mb-3 animate-in fade-in slide-in-from-bottom-1 duration-150\">\n <div className=\"flex h-9 items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-red-500/30 px-4\">\n <AlertCircle className=\"w-3.5 h-3.5 text-red-400\" />\n <span className=\"text-xs text-red-300\">blocked: {blockedLabel}</span>\n </div>\n </div>\n )\n }\n\n return (\n <div className=\"flex justify-start mb-3 animate-in fade-in slide-in-from-bottom-1 duration-150\">\n <div className=\"flex h-9 items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-foreground/10 px-4\">\n <div className=\"flex items-center gap-1\">\n <span className=\"w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_infinite]\" />\n <span className=\"w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_0.2s_infinite]\" />\n <span className=\"w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_0.4s_infinite]\" />\n </div>\n <span className=\"text-xs text-muted-foreground\">working</span>\n {onInterrupt && (\n <button\n onClick={onInterrupt}\n title=\"Interrupt\"\n 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\"\n >\n <CircleStop className=\"w-3.5 h-3.5\" />\n Stop\n </button>\n )}\n </div>\n </div>\n )\n}\n\nconst HIDE_TOOLS_KEY = 'agent-relay:chat-hide-tools'\nconst hideToolsStore = (() => {\n const listeners = new Set<() => void>()\n let value = (() => {\n try {\n return window.localStorage.getItem(HIDE_TOOLS_KEY) === 'on'\n } catch {\n return false\n }\n })()\n const emit = () => listeners.forEach((l) => l())\n if (typeof window !== 'undefined') {\n window.addEventListener('storage', (e) => {\n if (e.key !== HIDE_TOOLS_KEY) return\n value = e.newValue === 'on'\n emit()\n })\n }\n return {\n subscribe(cb: () => void) {\n listeners.add(cb)\n return () => listeners.delete(cb)\n },\n get: () => value,\n toggle() {\n value = !value\n try {\n window.localStorage.setItem(HIDE_TOOLS_KEY, value ? 'on' : 'off')\n } catch {}\n emit()\n },\n }\n})()\n\nfunction useHideTools(): [boolean, () => void] {\n const hideTools = useSyncExternalStore(hideToolsStore.subscribe, hideToolsStore.get, () => false)\n return [hideTools, hideToolsStore.toggle]\n}\n\nexport function ActivityTrace({ steps, showReasoning, issueRepo }: { steps: ActivityStep[]; showReasoning: boolean; issueRepo?: string }) {\n const [hideTools, toggleHideTools] = useHideTools()\n const visible = showReasoning ? steps : steps.filter((s) => s.kind !== 'reasoning')\n if (!visible.length) return null\n const toolCount = visible.filter((s) => s.kind === 'tool').length\n return (\n <div className=\"flex justify-start mb-2\">\n <div className=\"max-w-[85%] md:max-w-[75%] min-w-0 space-y-1.5\">\n {visible.map((step) => {\n if (step.kind === 'narration') {\n return (\n <FormattedBody\n key={step.id}\n text={step.text}\n issueRepo={issueRepo}\n className=\"text-sm leading-relaxed break-words text-foreground/90 min-w-0\"\n />\n )\n }\n if (step.kind === 'reasoning') {\n return (\n <div key={step.id} className=\"flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground/80\">\n <Brain className=\"w-3.5 h-3.5 mt-0.5 shrink-0 opacity-70\" />\n <FormattedBody text={step.text} issueRepo={issueRepo} className=\"italic break-words min-w-0\" />\n </div>\n )\n }\n if (hideTools) return null\n return (\n <div key={step.id} className=\"flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground\">\n <Terminal className=\"w-3 h-3 mt-0.5 shrink-0 opacity-70\" />\n <span className=\"min-w-0 break-words\">\n <span className=\"font-medium\">{step.label || 'tool'}</span>\n {step.text && step.text.trim() && step.text.trim() !== (step.label ?? '').trim() ? <span className=\"opacity-70\"> — {step.text}</span> : null}\n </span>\n </div>\n )\n })}\n {toolCount > 0 && (\n <button\n onClick={toggleHideTools}\n className=\"flex items-center gap-1 text-[11px] text-muted-foreground/50 hover:text-muted-foreground transition-colors text-left\"\n >\n <ChevronRight className={cn('w-3 h-3 shrink-0 transition-transform', !hideTools && 'rotate-90')} />\n <span>{hideTools ? `show ${toolCount} tool step${toolCount === 1 ? '' : 's'}` : 'hide tool steps'}</span>\n </button>\n )}\n </div>\n </div>\n )\n}\n\nexport function DateSeparator({ date }: { date: string }) {\n return (\n <div className=\"flex items-center justify-center gap-3 py-3 my-1\">\n <div className=\"h-px flex-1 bg-border\" />\n <span className=\"text-xs font-medium text-muted-foreground\">{dateSeparatorLabel(date)}</span>\n <div className=\"h-px flex-1 bg-border\" />\n </div>\n )\n}\n\nexport function CreatedMarker({ timestamp }: { timestamp: number }) {\n const d = new Date(timestamp)\n const label = d.toLocaleString(undefined, { month: 'short', day: 'numeric', year: 'numeric', hour: '2-digit', minute: '2-digit' })\n return (\n <div className=\"flex items-center justify-center gap-2 py-2 my-1\">\n <div className=\"h-px flex-1 bg-border\" />\n <span className=\"text-xs text-muted-foreground/60\">created {label}</span>\n <div className=\"h-px flex-1 bg-border\" />\n </div>\n )\n}\n\nexport function ImportedHistoryMarker({ history }: { history: ChatHistoryImport }) {\n const source = history.sourceAgentLabel || history.sourcePeerId\n const count = history.entries.length\n return (\n <div className=\"flex items-center justify-center gap-2 py-2 my-1\">\n <div className=\"h-px flex-1 bg-border\" />\n <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\">\n <GitFork className=\"h-3 w-3\" />\n <span>forked history from {source}</span>\n <span className=\"text-muted-foreground/60\">{count} {count === 1 ? 'entry' : 'entries'}</span>\n </div>\n <div className=\"h-px flex-1 bg-border\" />\n </div>\n )\n}\n\nexport function ImportedMessageBubble({ entry, sourceLabel, issueRepo }: { entry: ChatHistoryImportEntry; sourceLabel?: string; issueRepo?: string }) {\n const msg = entry.message\n const body = messageBody(msg)\n const isOriginalHuman = entry.originalFrom === HUMAN_AGENT_ID\n return (\n <div className={cn('flex mb-3 opacity-80', isOriginalHuman ? 'justify-end' : 'justify-start')}>\n <div className=\"max-w-[85%] md:max-w-[75%]\">\n <div\n className={cn(\n 'rounded-2xl border border-dashed px-3.5 py-2 text-sm select-text',\n isOriginalHuman\n ? 'border-primary/25 bg-primary/10 text-foreground rounded-br-sm'\n : 'border-border bg-card/70 rounded-bl-sm'\n )}\n >\n <div className={cn('mb-1 text-[10px] uppercase tracking-normal', isOriginalHuman ? 'text-primary/70' : 'text-muted-foreground')}>\n forked history · {isOriginalHuman ? 'you' : (sourceLabel || entry.originalFrom)}\n </div>\n <FormattedBody text={body} rawBody={msg.body} issueRepo={issueRepo} className=\"leading-relaxed\" />\n <p className={cn('mt-1 flex items-center justify-end gap-1.5 text-xs', isOriginalHuman ? 'text-primary/60' : 'text-muted-foreground')}>\n <span className=\"opacity-40\">#{entry.originalMessageId}</span>\n <span>{chatTimestamp(entry.originalCreatedAt)}</span>\n </p>\n </div>\n </div>\n </div>\n )\n}\n\n// The initial/spawn prompt (#513) — the message that kicked off the session — gets a\n// distinct titled panel instead of a plain user bubble, so it reads as the brief at the\n// top of the conversation. data-msg-id is preserved for the scroll/measurement logic.\nexport function InitialPromptBubble({ msg, issueRepo }: { msg: Message; issueRepo?: string }) {\n const body = messageBody(msg)\n const time = chatTimestamp(msg.occurredAt ?? (msg.createdAt as string))\n return (\n <div data-msg-id={msg.id} className=\"mb-3\">\n <div className=\"rounded-xl border border-primary/30 bg-primary/[0.06] px-3.5 py-2.5 shadow-sm\">\n <div className=\"mb-1.5 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-primary/80\">\n <Sparkles className=\"h-3.5 w-3.5\" />\n <span>Initial prompt</span>\n <span className=\"ml-auto text-[10px] font-normal normal-case text-muted-foreground/60\">{time}</span>\n </div>\n <FormattedBody text={body} rawBody={msg.body} issueRepo={issueRepo} className=\"text-sm leading-relaxed text-foreground\" />\n </div>\n </div>\n )\n}\n\n// Pinned \"Last prompt\" reminder. Rendered as a shrink-0 flex sibling ABOVE the timeline in\n// ChatPanel — the SAME mechanism as the chat search bar (ChatSearchBar) — so it stays put\n// above the conversation instead of scrolling away (#545). It previously lived inside the\n// scroll container as a position:sticky child, which broke when the timeline was virtualized\n// (b0ef5c5): a Virtuoso Header item scrolls/unmounts, so sticky no longer pinned it and it was\n// only glimpsed at the very top. `scrollEl` is the Virtuoso scroller (lifted up from\n// VirtualTimeline), used to observe whether the original prompt is on-screen and to scroll to it.\nexport function StickyPromptBanner({ scrollEl, timeline }: { scrollEl: HTMLElement | null; timeline: TimelineEntry[] }) {\n const [hidden, setHidden] = useState(true)\n const [expandedByPrompt, setExpandedByPrompt] = useState<{ id: number; value: boolean } | null>(null)\n const [collapsedByPrompt, setCollapsedByPrompt] = useState<{ id: number; value: boolean } | null>(null)\n const [promptAbove, setPromptAbove] = useState(false)\n\n const lastOutbound = useMemo(() => {\n for (let i = timeline.length - 1; i >= 0; i--) {\n const entry = timeline[i]\n if (!entry || (entry.type !== 'message' && entry.type !== 'initial-prompt')) continue\n if (entry.msg.from === HUMAN_AGENT_ID) {\n return { id: entry.msg.id, body: messageBody(entry.msg) }\n }\n }\n return null\n }, [timeline])\n\n // Auto-hide while the original prompt is on-screen (no reminder needed), show it once the\n // prompt scrolls out of view. The timeline is virtualized, so the prompt row mounts/unmounts\n // as you scroll — re-resolve the target on every scroll and re-attach the observer when the\n // row swaps. When the row is unmounted entirely it's definitely off-screen, so show the banner.\n useEffect(() => {\n if (!lastOutbound || !scrollEl) { setHidden(true); return }\n let observer: IntersectionObserver | null = null\n let observed: Element | null = null\n const sync = () => {\n const target = scrollEl.querySelector(`[data-msg-id=\"${lastOutbound.id}\"]`)\n if (!target) {\n observer?.disconnect()\n observer = null\n observed = null\n setHidden(false) // prompt row virtualized away → off-screen → show the reminder\n return\n }\n const r = target.getBoundingClientRect()\n const sr = scrollEl.getBoundingClientRect()\n setPromptAbove(r.top < sr.top)\n if (target === observed) return\n observer?.disconnect()\n observed = target\n observer = new IntersectionObserver(\n ([e]) => { if (e) setHidden(e.isIntersecting) },\n { root: scrollEl, threshold: 0 }\n )\n observer.observe(target)\n }\n sync()\n scrollEl.addEventListener('scroll', sync, { passive: true })\n return () => { observer?.disconnect(); scrollEl.removeEventListener('scroll', sync) }\n }, [lastOutbound?.id, scrollEl])\n\n if (hidden || !lastOutbound || !lastOutbound.body.trim()) return null\n\n const expanded = expandedByPrompt?.id === lastOutbound.id ? expandedByPrompt.value : false\n const collapsed = collapsedByPrompt?.id === lastOutbound.id ? collapsedByPrompt.value : false\n\n function scrollToPrompt() {\n if (!scrollEl || !lastOutbound) return\n const target = scrollEl.querySelector(`[data-msg-id=\"${lastOutbound.id}\"]`)\n target?.scrollIntoView({ behavior: 'smooth', block: 'center' })\n }\n\n const arrow = promptAbove ? '↑' : '↓'\n\n if (collapsed) {\n return (\n <div className=\"flex shrink-0 bg-card/45 border-b border-border\">\n <button\n type=\"button\"\n className=\"w-full flex items-center justify-center gap-1.5 py-1 text-[11px] text-primary/60 hover:text-primary transition-colors\"\n onClick={() => setCollapsedByPrompt({ id: lastOutbound.id, value: false })}\n >\n <span>Your prompt</span>\n <ChevronDown className=\"w-3 h-3\" />\n </button>\n </div>\n )\n }\n\n return (\n <section className=\"flex shrink-0 flex-col border-b border-border bg-card/45 px-3 py-2\">\n <div className=\"flex items-center gap-2 text-[11px] text-muted-foreground mb-0.5\">\n <span className=\"font-medium text-primary/70\">Your prompt</span>\n <button\n type=\"button\"\n className=\"ml-auto hover:text-foreground transition-colors\"\n onClick={scrollToPrompt}\n >\n {arrow} scroll to original\n </button>\n <button\n type=\"button\"\n className=\"hover:text-foreground transition-colors\"\n onClick={() => setCollapsedByPrompt({ id: lastOutbound.id, value: true })}\n title=\"Minimize\"\n >\n <ChevronUp className=\"w-3 h-3\" />\n </button>\n </div>\n <p\n className={cn('text-sm text-foreground leading-snug cursor-pointer', !expanded && 'line-clamp-2')}\n onClick={() => setExpandedByPrompt({ id: lastOutbound.id, value: !expanded })}\n >\n {lastOutbound.body}\n </p>\n </section>\n )\n}\n","\nimport { useSyncExternalStore } from 'react'\nimport { voiceTts } from '@/lib/voice'\n\nexport function useTtsPlayingKey(): string | null {\n return useSyncExternalStore(\n (cb) => voiceTts.subscribe(cb),\n () => voiceTts.getPlayingKey(),\n () => null,\n )\n}\n","\nimport { memo, useEffect, useRef, useState } from 'react'\nimport { AlertCircle, ArrowLeft, ArrowRight, ChevronRight, CircleStop, Download, FileText, Loader2, SmilePlus, Volume2, X, ZoomIn } from 'lucide-react'\nimport { voiceTts } from '@/lib/voice'\nimport { useRelayStore } from '@/store'\nimport { FormattedBody } from '@/components/shared/formatted-body'\nimport { AgentLink } from './TraceView'\nimport { Button } from '@/components/ui/button'\nimport { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog'\nimport { apiBlob } from '@/lib/api'\nimport { HUMAN_AGENT_ID } from '@/lib/constants'\nimport { displayTarget, messageBody } from '@/lib/display'\nimport type { AttachmentRef, Message } from '@/types'\nimport { cn } from '@/lib/utils'\nimport type { ReferencedPathInfo } from './types'\nimport {\n chatTimestamp,\n groupedReactions,\n hasActiveTextSelection,\n isReactionEvent,\n messageAttachments,\n outboundReceipt,\n QUICK_REACTIONS,\n resolveRelativePath,\n} from './helpers'\nimport { useTtsPlayingKey } from './hooks/useTtsPlayingKey'\n\nfunction AttachmentPreview({ attachment, outbound }: { attachment: AttachmentRef; outbound: boolean }) {\n const isImage = attachment.kind === 'image'\n const title = attachment.title || attachment.artifactId\n const [objectUrl, setObjectUrl] = useState<string | null>(null)\n const [error, setError] = useState<string | null>(null)\n const [loading, setLoading] = useState(false)\n const [lightboxOpen, setLightboxOpen] = useState(false)\n\n useEffect(() => {\n let cancelled = false\n let url: string | null = null\n\n async function load() {\n setLoading(true)\n setError(null)\n setObjectUrl(null)\n try {\n const blob = await apiBlob(`/artifacts/${encodeURIComponent(attachment.artifactId)}/content`)\n if (cancelled) return\n url = URL.createObjectURL(blob)\n setObjectUrl(url)\n } catch (e) {\n if (!cancelled) setError((e as Error).message)\n } finally {\n if (!cancelled) setLoading(false)\n }\n }\n\n void load()\n return () => {\n cancelled = true\n if (url) URL.revokeObjectURL(url)\n }\n }, [attachment.artifactId])\n\n function download() {\n if (!objectUrl) return\n const a = document.createElement('a')\n a.href = objectUrl\n a.download = title\n document.body.appendChild(a)\n a.click()\n a.remove()\n }\n\n if (isImage) {\n return (\n <>\n <button\n type=\"button\"\n onClick={() => objectUrl && setLightboxOpen(true)}\n disabled={!objectUrl}\n className=\"group/img mt-2 block overflow-hidden rounded-md border border-foreground/10 bg-black/10 text-left disabled:cursor-default relative\"\n >\n {objectUrl ? (\n <>\n <img src={objectUrl} alt={title} loading=\"lazy\" className=\"block max-h-72 max-w-full object-contain\" />\n <span className=\"absolute inset-0 flex items-center justify-center bg-black/0 group-hover/img:bg-black/30 transition-colors\">\n <ZoomIn className=\"w-6 h-6 text-white opacity-0 group-hover/img:opacity-100 transition-opacity drop-shadow-md\" />\n </span>\n </>\n ) : (\n <span className={cn('flex min-h-20 items-center gap-2 px-3 py-2 text-xs', error ? 'text-red-400' : 'text-muted-foreground')}>\n {loading ? <Loader2 className=\"h-4 w-4 animate-spin\" /> : <AlertCircle className=\"h-4 w-4\" />}\n {error || 'Loading image'}\n </span>\n )}\n </button>\n {objectUrl && (\n <Dialog open={lightboxOpen} onOpenChange={setLightboxOpen}>\n <DialogContent className=\"max-w-[95vw] max-h-[95vh] w-auto p-0 bg-black/95 border-zinc-800 gap-0 overflow-hidden\" showCloseButton={false}>\n <DialogTitle className=\"sr-only\">{title}</DialogTitle>\n <div className=\"relative flex items-center justify-center min-h-[200px]\">\n <img src={objectUrl} alt={title} className=\"max-w-[93vw] max-h-[90vh] object-contain\" />\n <div className=\"absolute top-2 right-2 flex gap-1\">\n <button type=\"button\" onClick={download} className=\"rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors\" title=\"Download\">\n <Download className=\"w-4 h-4\" />\n </button>\n <button type=\"button\" onClick={() => setLightboxOpen(false)} className=\"rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors\" title=\"Close\">\n <X className=\"w-4 h-4\" />\n </button>\n </div>\n </div>\n </DialogContent>\n </Dialog>\n )}\n </>\n )\n }\n\n return (\n <button\n type=\"button\"\n onClick={download}\n disabled={!objectUrl}\n className={cn(\n '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 outbound ? 'border-primary-foreground/20 bg-primary-foreground/10 hover:bg-primary-foreground/15' : 'border-border bg-background hover:bg-muted'\n )}\n >\n {loading ? <Loader2 className=\"h-4 w-4 shrink-0 animate-spin\" /> : error ? <AlertCircle className=\"h-4 w-4 shrink-0 text-red-400\" /> : <FileText className=\"h-4 w-4 shrink-0\" />}\n <span className={cn('min-w-0 flex-1 truncate', error && 'text-red-400')}>{error || title}</span>\n <Download className=\"h-3.5 w-3.5 shrink-0\" />\n </button>\n )\n}\n\nfunction AddReaction({ open, onToggle, onReact }: { open: boolean; onToggle: () => void; onReact: (emoji: string) => void }) {\n return (\n <div className=\"relative shrink-0\">\n <button\n type=\"button\"\n title=\"Add reaction\"\n onClick={onToggle}\n className={cn(\n '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',\n open ? 'opacity-100' : 'opacity-0 pointer-events-none md:group-hover/msg:opacity-100 md:group-hover/msg:pointer-events-auto'\n )}\n >\n <SmilePlus className=\"h-3 w-3\" />\n </button>\n {open && (\n <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\">\n {QUICK_REACTIONS.map((emoji) => (\n <button\n key={emoji}\n type=\"button\"\n title={`React ${emoji}`}\n onClick={() => onReact(emoji)}\n className=\"inline-flex h-6 w-7 items-center justify-center rounded-full text-xs transition-colors hover:bg-muted\"\n >\n {emoji}\n </button>\n ))}\n </div>\n )}\n </div>\n )\n}\n\n// Inter-agent (peer↔peer) messages render as a compact, foldable one-liner — distinct\n// from the user↔agent bubbles, never persisted-open (#508). The other party is shown via\n// AgentLink (label-preferred + clickable, #522); fan-out targets (broadcast/tag:/cap:/…)\n// fall back to a plain displayTarget label since they don't resolve to one agent.\nfunction PeerMessageLine({ msg, peer }: { msg: Message; peer: string }) {\n const [expanded, setExpanded] = useState(false)\n const agentsById = useRelayStore((s) => s.agentsById)\n const isOutbound = msg.from === peer\n const otherParty = (isOutbound ? msg.to : msg.from) || ''\n // Per-project #NNN linkify (#533/#543): outbound folded lines use the selected\n // peer's repo; inbound inter-agent lines use the originating agent's repo.\n const issueRepo = agentsById[isOutbound ? peer : otherParty]?.issueRepo ?? agentsById[peer]?.issueRepo\n const isSelector = !otherParty || otherParty === 'broadcast' || otherParty.includes(':')\n const body = messageBody(msg)\n const time = chatTimestamp(msg.occurredAt ?? (msg.createdAt as string))\n const DirIcon = isOutbound ? ArrowRight : ArrowLeft\n\n return (\n <div data-msg-id={msg.id} className=\"flex justify-center mb-1.5\">\n <div className=\"w-full max-w-[94%] rounded-md border border-border/50 bg-muted/15 px-2.5 py-1\">\n <div className=\"flex items-center gap-1.5 text-xs cursor-pointer select-none\" onClick={() => setExpanded((v) => !v)}>\n <ChevronRight className={cn('h-3 w-3 shrink-0 text-muted-foreground/60 transition-transform', expanded && 'rotate-90')} />\n <DirIcon className=\"h-3 w-3 shrink-0 text-muted-foreground/70\" />\n <span className=\"shrink-0 text-muted-foreground\">Message {isOutbound ? 'to' : 'from'}</span>\n {isSelector\n ? <span className=\"shrink-0 font-medium text-muted-foreground\">{displayTarget(otherParty, agentsById)}</span>\n : <AgentLink agentId={otherParty} className=\"shrink-0 px-0.5 text-foreground/80\" />}\n {!expanded && <span className=\"min-w-0 flex-1 truncate text-muted-foreground/50\">{body}</span>}\n <span className=\"ml-auto shrink-0 text-muted-foreground/40\">{time}</span>\n </div>\n {expanded && (\n <div className=\"mt-1.5 pl-5\">\n <FormattedBody text={body} rawBody={msg.body} issueRepo={issueRepo} className=\"text-sm leading-relaxed text-foreground/90\" />\n </div>\n )}\n </div>\n </div>\n )\n}\n\nexport const MessageBubble = memo(function MessageBubble({\n msg,\n peer,\n onOpenReferencedPath,\n onPreviewReferencedPath,\n onPreviewReferencedPathEnd,\n}: {\n msg: Message\n peer: string\n onOpenReferencedPath?: (path: string, line?: number, type?: ReferencedPathInfo['type']) => void\n onPreviewReferencedPath?: (path: string, line?: number, anchor?: DOMRect) => void\n onPreviewReferencedPathEnd?: () => void\n}) {\n // Inter-agent (peer↔peer) messages get a folded one-liner instead of a bubble (#508).\n // This early-return precedes all hooks, which is safe here: the timeline keys each\n // MessageBubble by msg id (VirtualTimeline.timelineEntryKey), and from/to are immutable\n // for a given id — so a mounted instance never flips between the two render paths.\n if (msg.from !== HUMAN_AGENT_ID && msg.to !== HUMAN_AGENT_ID) {\n return <PeerMessageLine msg={msg} peer={peer} />\n }\n const isOutbound = msg.from === HUMAN_AGENT_ID\n const reactToMessage = useRelayStore((s) => s.reactToMessage)\n const voiceTtsEnabled = useRelayStore((s) => s.voiceTtsEnabled)\n const ttsPlayingKey = useTtsPlayingKey()\n const peerCwd = useRelayStore((s) => {\n const cwd = s.agentsById[peer]?.meta?.cwd\n return typeof cwd === 'string' ? cwd : ''\n })\n // Per-project #NNN linkify (#533): the peer agent's resolved project repo.\n const peerIssueRepo = useRelayStore((s) => s.agentsById[peer]?.issueRepo)\n const [showQuickReact, setShowQuickReact] = useState(false)\n const bubbleRef = useRef<HTMLDivElement>(null)\n const pointerStartRef = useRef<{ x: number; y: number } | null>(null)\n const suppressBubbleClickRef = useRef(false)\n const body = messageBody(msg)\n const time = chatTimestamp(msg.occurredAt ?? (msg.createdAt as string))\n const attachments = messageAttachments(msg)\n const reactions = groupedReactions(msg)\n const receipt = isOutbound ? outboundReceipt(msg, peer) : null\n const ReceiptIcon = receipt?.icon\n // On-demand TTS: replay any agent response through the same Kokoro/browser\n // pipeline. Only when the speaker is on, and only for inbound non-reaction text.\n const isTtsPlaying = ttsPlayingKey === String(msg.id)\n const showPlayButton = voiceTtsEnabled && !isOutbound && !isReactionEvent(msg) && body.trim().length > 0\n function togglePlay(e: React.MouseEvent) {\n e.stopPropagation()\n if (isTtsPlaying) voiceTts.bargeIn()\n else voiceTts.speak(msg.body, String(msg.id))\n }\n useEffect(() => {\n if (!showQuickReact) return\n function dismiss(e: MouseEvent | TouchEvent) {\n if (hasActiveTextSelection()) return\n if (bubbleRef.current && !bubbleRef.current.contains(e.target as Node)) setShowQuickReact(false)\n }\n document.addEventListener('mousedown', dismiss)\n document.addEventListener('touchstart', dismiss)\n return () => { document.removeEventListener('mousedown', dismiss); document.removeEventListener('touchstart', dismiss) }\n }, [showQuickReact])\n\n function resolvedReferencedPath(path: string): string {\n return resolveRelativePath(peerCwd || '/', path)\n }\n\n function openReferencedPath(path: string, line?: number) {\n const absolute = resolvedReferencedPath(path)\n onOpenReferencedPath?.(absolute, line)\n }\n\n function previewReferencedPath(path: string, line?: number, anchor?: DOMRect) {\n const absolute = resolvedReferencedPath(path)\n onPreviewReferencedPath?.(absolute, line, anchor)\n }\n\n function handleReact(emoji: string) {\n reactToMessage(msg, emoji)\n setShowQuickReact(false)\n }\n\n function handleBubblePointerDown(e: React.PointerEvent<HTMLDivElement>) {\n if (e.button !== 0) return\n pointerStartRef.current = { x: e.clientX, y: e.clientY }\n suppressBubbleClickRef.current = false\n }\n\n function handleBubblePointerMove(e: React.PointerEvent<HTMLDivElement>) {\n const start = pointerStartRef.current\n if (!start) return\n if (Math.abs(e.clientX - start.x) > 3 || Math.abs(e.clientY - start.y) > 3) {\n suppressBubbleClickRef.current = true\n }\n }\n\n function handleBubbleClick(e: React.MouseEvent<HTMLDivElement>) {\n if (isReactionEvent(msg) || isOutbound) return\n const target = e.target as HTMLElement\n if (target.closest('a,button,input,textarea,select,[role=\"button\"]')) return\n if (suppressBubbleClickRef.current || hasActiveTextSelection()) {\n suppressBubbleClickRef.current = false\n return\n }\n setShowQuickReact((v) => !v)\n }\n\n return (\n <div data-msg-id={msg.id} className={cn('group/msg flex mb-3', isOutbound ? 'justify-end' : 'justify-start')}>\n <div ref={bubbleRef} className=\"relative max-w-[85%] md:max-w-[75%]\">\n {showPlayButton && (\n <button\n type=\"button\"\n title={isTtsPlaying ? 'Stop playback' : 'Play aloud'}\n onClick={togglePlay}\n className={cn(\n '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',\n isTtsPlaying\n ? 'border-primary/50 text-primary opacity-100'\n // Hide-until-hover only on hover-capable devices; touch screens (iPad)\n // have no hover, so keep the button visible there instead of opacity-0.\n : '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'\n )}\n >\n {isTtsPlaying ? <CircleStop className=\"h-3.5 w-3.5 animate-pulse\" /> : <Volume2 className=\"h-3.5 w-3.5\" />}\n </button>\n )}\n <div\n className={cn(\n 'rounded-2xl px-3.5 py-2 text-sm select-text',\n !isOutbound && !isReactionEvent(msg) && 'cursor-pointer',\n isOutbound\n ? 'bg-primary text-primary-foreground rounded-br-sm'\n : 'bg-card ring-1 ring-foreground/10 rounded-bl-sm'\n )}\n onPointerDown={handleBubblePointerDown}\n onPointerMove={handleBubblePointerMove}\n onClick={handleBubbleClick}\n >\n {msg.subject && (\n <p className={cn('text-xs font-semibold mb-1', isOutbound ? 'text-primary-foreground/70' : 'text-muted-foreground')}>\n {msg.subject}\n </p>\n )}\n <FormattedBody\n text={body}\n rawBody={msg.body}\n issueRepo={peerIssueRepo}\n className=\"leading-relaxed\"\n onOpenPath={openReferencedPath}\n onPreviewPath={previewReferencedPath}\n onPreviewPathEnd={onPreviewReferencedPathEnd}\n resolvePathTitle={(path, line) => `${resolvedReferencedPath(path)}${line ? `:${line}` : ''}`}\n />\n {attachments.map((attachment) => (\n <AttachmentPreview key={`${msg.id}-${attachment.artifactId}-${attachment.role || ''}`} attachment={attachment} outbound={isOutbound} />\n ))}\n <p className={cn('text-xs mt-1 flex items-center gap-1.5', isOutbound ? 'justify-end text-primary-foreground/60' : 'justify-end text-muted-foreground')}>\n <span className=\"opacity-40\">#{msg.id}</span>\n <span>{time}</span>\n {receipt && ReceiptIcon && (\n <span\n className={cn(\n 'inline-flex items-center gap-1',\n receipt.tone === 'ok' && 'text-emerald-300',\n receipt.tone === 'warn' && 'text-amber-200',\n receipt.tone === 'danger' && 'text-red-200'\n )}\n title={receipt.title}\n >\n <ReceiptIcon className=\"h-3 w-3\" />\n {receipt.label}\n </span>\n )}\n </p>\n </div>\n {!isReactionEvent(msg) && reactions.length > 0 && (\n <div className={cn('flex flex-wrap items-center gap-0.5 -mt-1 relative z-10', isOutbound ? 'justify-end pr-2' : 'justify-start pl-2')}>\n {!isOutbound && <AddReaction open={showQuickReact} onToggle={() => setShowQuickReact((v) => !v)} onReact={handleReact} />}\n {reactions.map((reaction) => (\n <button\n key={reaction.emoji}\n type=\"button\"\n title={reaction.actors.join(', ')}\n onClick={() => handleReact(reaction.emoji)}\n className={cn(\n 'inline-flex h-5 items-center gap-0.5 rounded-full border px-1.5 text-[11px] shadow-sm transition-colors',\n reaction.mine\n ? 'border-primary/40 bg-primary/10 text-primary'\n : 'border-border bg-background hover:bg-muted text-foreground'\n )}\n >\n <span>{reaction.emoji}</span>\n {reaction.count > 1 && <span>{reaction.count}</span>}\n </button>\n ))}\n </div>\n )}\n {!isReactionEvent(msg) && !isOutbound && reactions.length === 0 && (\n <div className=\"absolute -bottom-2.5 left-1 z-20\">\n <AddReaction open={showQuickReact} onToggle={() => setShowQuickReact((v) => !v)} onReact={handleReact} />\n </div>\n )}\n </div>\n </div>\n )\n})\n"],"mappings":"2kBAoBA,EAAA,geAgBA,GAAA,IAAA,IAAA,OAAA,KAAA,EAAA,CAAA,CACA,GAAA,IAMA,SAAA,EAAA,EAAA,sDAOA,SAAA,GAAA,EAAA,gRAmBA,SAAA,GAAA,EAAA,8MAQA,SAAA,EAAA,EAAA,EAAA,6JAgBA,SAAA,EAAA,EAAA,6CAMA,IAAA,GAAA,IAAA,IAAA,qDAEA,SAAA,EAAA,EAAA,+HAKA,SAAA,GAAA,EAAA,wNAcA,SAAA,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA,EAAA,02GA4MA,SAAA,GAAA,EAAA,ogBAoBA,SAAA,GAAA,EAAA;MAYA,SAAA,GAAA,EAAA,EAAA,uFCrVA,SAAgB,GAAY,EAA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AA,KAAC,GAAD,CAAa,KAAM,EAAgB,aAAgB,EAAmB,GAAM,CAAC,EAAE,CAAE,QAAS,EAAe,CAAA,CACxH,EAAU,IAAK,IACd,EAAA,EAAA,MAAC,SAAD,CAEE,KAAK,SACL,MAAO,EAAS,OAAO,KAAK,KAAK,CACjC,YAAe,EAAY,EAAS,MAAM,CAC1C,UAAW,EACT,0GACA,EAAS,KACL,+CACA,6DACL,UAVH,EAYE,EAAA,EAAA,KAAC,OAAD,CAAA,SAAO,EAAS,MAAa,CAAA,CAC5B,EAAS,MAAQ,IAAK,EAAA,EAAA,KAAC,OAAD,CAAA,SAAO,EAAS,MAAa,CAAA,CAC7C,EAbF,EAAS,MAaP,CACT,CACE,GAEP,CAAC,EAAgB,EAAI,EAAI,CAAC,GAAc,EAAU,SAAW,IAC5D,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,6CACb,EAAA,EAAA,KAAC,GAAD,CAAa,KAAM,EAAgB,aAAgB,EAAmB,GAAM,CAAC,EAAE,CAAE,QAAS,EAAe,CAAA,CACrG,CAAA,CAEJ,GACF,CAAA,EAER"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./chunk-CilyBKbf.js";import{Bn as t,Qn as n,Rn as r,Vn as i,a,p as o,sn as s,tn as c,wt as l}from"./lucide-react-BbMYCUlW.js";import{t as u}from"./store-BB-YW24l.js";var d=e(n(),1);function f(e){let t=u(e=>e.showError),[n,r]=(0,d.useState)(!1),[a,o]=(0,d.useState)(null),[s,c]=(0,d.useState)(!1);async function l(){if(!(!e||s)){c(!0);try{o(await i(`POST`,`/agents/`+encodeURIComponent(e)+`/terminal-session`)),r(!0)}catch(e){t(`Terminal Failed`,e.message)}finally{c(!1)}}}function f(t){if(t){r(!0);return}r(!1);let n=a;o(null),e&&n?.mode===`guest`&&i(`DELETE`,`/agents/`+encodeURIComponent(e)+`/terminal-session/`+encodeURIComponent(n.session)).catch(()=>{})}return{terminalOpen:n,terminalTarget:a,terminalOpening:s,openTerminal:l,closeTerminal:f}}var p=t(),m={idle:{label:`idle`,tip:`Branch worktree — nothing to land yet.`,className:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`,Icon:c},changes:{label:`changes`,tip:`Unlanded work in this branch — use "Mark workspace ready" to land it.`,className:`bg-amber-500/10 text-amber-400 border-amber-500/20`,Icon:l},ready:{label:`ready`,tip:`Handed off — the relay auto-merge will land it (~2 min sweep).`,className:`bg-blue-500/10 text-blue-400 border-blue-500/20`,Icon:s},steward:{label:`steward`,tip:`Under reconciliation — a steward is landing it. No action needed.`,className:`bg-orange-500/10 text-orange-400 border-orange-500/20`,Icon:a},blocked:{label:`blocked`,tip:`Escalated — the auto-merge/steward path is stuck. Needs human attention.`,className:`bg-red-500/10 text-red-400 border-red-500/20`,Icon:o}};function h({state:e,onClick:t,iconOnly:n=!1,className:i}){let a=m[e],{Icon:o}=a,s=!!t,c=s?`${a.tip} Click to open this workspace.`:a.tip;return(0,p.jsxs)(`span`,{role:s?`button`:void 0,tabIndex:s?0:void 0,title:c,onClick:t,onKeyDown:s?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t?.(e))}:void 0,className:r(`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium leading-none`,a.className,s&&`cursor-pointer hover:brightness-125 focus:outline-none focus:ring-1 focus:ring-current`,i),children:[(0,p.jsx)(o,{className:`h-2.5 w-2.5 shrink-0`}),!n&&(0,p.jsx)(`span`,{children:a.label})]})}export{f as n,h as t};
|
|
2
|
-
//# sourceMappingURL=branch-state-badge-C7H8HY22.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./chunk-CilyBKbf.js";import{Bn as t,Ct as n,D as r,Fn as i,Gn as a,Ht as o,I as s,J as c,Jt as l,Mt as u,O as d,Pn as f,Pt as p,Qn as m,R as h,Rn as g,Vn as _,Vt as v,W as y,Wt as b,Y as x,Z as S,c as C,cn as w,ct as T,dn as E,et as ee,fn as te,h as D,i as ne,it as re,jn as ie,kn as ae,kt as oe,ln as se,lt as ce,nn as le,pn as ue,r as de,rt as fe,s as pe,un as me,wn as he,x as ge}from"./lucide-react-BbMYCUlW.js";import{t as O}from"./react-dom-HJwa4sZ-.js";import{f as _e,g as ve,h as ye,l as be,m as xe,t as k}from"./store-BB-YW24l.js";import{$ as Se,A as Ce,D as we,K as Te,L as Ee,O as De,U as Oe,V as ke,W as Ae,a as je,d as A,h as Me,o as Ne,q as Pe,r as Fe,w as Ie}from"./display-LAWaAboe.js";import{t as Le}from"./badge-C6NJQ60B.js";import{t as j}from"./button-DD2CCM3t.js";import{t as M}from"./input-08ItMIki.js";import{t as Re}from"./copy-button-DqAoeiPC.js";import{A as ze,C as Be,E as Ve,L as He,M as Ue,N as We,S as Ge,T as Ke,W as qe,_ as Je,a as Ye,b as Xe,c as Ze,h as Qe,i as $e,j as et,k as tt,o as nt,r as rt,t as it,w as at,x as ot,y as st}from"./index-VGRP16ua.js";import{t as ct}from"./use-keyboard-viewport-CEmOxaNm.js";import{C as lt,S as ut,_ as dt,a as ft,b as pt,c as mt,d as ht,f as gt,g as _t,h as vt,i as yt,l as bt,m as xt,n as St,o as Ct,p as wt,r as Tt,s as Et,t as Dt,u as Ot,v as kt,w as At,x as jt,y as Mt}from"./MessageBubble-DPcJxTJj.js";import{n as Nt,t as Pt}from"./branch-state-badge-C7H8HY22.js";import{t as Ft}from"./PlanGraphPanel-BYmE8ldg.js";var N=e(m(),1);function It(){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=Pe(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=>Ne(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`?A(e).localeCompare(A(t))*p:l===`lastSeen`?wt(Ae(e.lastSeen),Ae(t.lastSeen),p)||A(e).localeCompare(A(t)):((Se[e.status]??9)-(Se[t.status]??9))*p||A(e).localeCompare(A(t)))},[e,t,n,d,r,i,a,o,s,c,l,u])}var P=t(),Lt=[{re:/`([^`]+)`/,recurse:!1,wrap:(e,t)=>(0,P.jsx)(`code`,{className:`rounded bg-muted px-1 font-mono text-[0.9em]`,children:e},t)},{re:/\*\*([^*]+)\*\*/,recurse:!0,wrap:(e,t)=>(0,P.jsx)(`strong`,{className:`font-semibold text-foreground/90`,children:e},t)},{re:/__([^_]+)__/,recurse:!0,wrap:(e,t)=>(0,P.jsx)(`strong`,{className:`font-semibold text-foreground/90`,children:e},t)},{re:/~~([^~]+)~~/,recurse:!0,wrap:(e,t)=>(0,P.jsx)(`s`,{children:e},t)},{re:/\*([^*]+)\*/,recurse:!0,wrap:(e,t)=>(0,P.jsx)(`em`,{children:e},t)},{re:/_([^_]+)_/,recurse:!0,wrap:(e,t)=>(0,P.jsx)(`em`,{children:e},t)},{re:/\[([^\]]+)\]\([^)]+\)/,recurse:!0,wrap:(e,t)=>(0,P.jsx)(`span`,{className:`underline decoration-dotted underline-offset-2`,children:e},t)}];function Rt(e,t=`i`){let n=null;for(let t of Lt){let r=t.re.exec(e);r&&r[1]&&(n===null||r.index<n.index)&&(n={index:r.index,length:r[0].length,inner:r[1],pattern:t})}if(!n)return[e];let r=[];n.index>0&&r.push(e.slice(0,n.index));let i=n.pattern.recurse?Rt(n.inner,`${t}x`):n.inner;r.push(n.pattern.wrap(i,`${t}m`));let a=e.slice(n.index+n.length);return a&&r.push(...Rt(a,`${t}r`)),r}var zt=`agent-relay.chat.collapsedChildren`;function Bt(){if(typeof window>`u`)return new Set;try{let e=JSON.parse(window.localStorage.getItem(zt)||`[]`);return new Set(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])}catch{return new Set}}function Vt(e){if(!(typeof window>`u`))try{window.localStorage.setItem(zt,JSON.stringify([...e]))}catch{}}function Ht({threads:e,onSelectAgent:t}){let n=k(e=>e.set),r=k(e=>e.openInboxThread),i=k(e=>e.openAgentSpawn),a=k(e=>e.selectedInboxThread),o=k(e=>e.chatAgentSearch),s=k(e=>e.chatAgentSort),c=k(e=>e.chatAgentSortDir),u=k(e=>e.chatAgentProviderFilter),p=k(e=>e.chatAgentStatusFilter),m=k(e=>e.chatAgentTagFilter),_=k(e=>e.chatAgentCapFilter),v=k(e=>e.chatAgentHostFilter),y=k(e=>e.chatAgentGroupBy),b=k(e=>e.chatAgentFiltersCollapsed),x=k(e=>e.agentsById),S=be(),C=It(),[T,E]=(0,N.useState)(Bt);function ee(e){E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),Vt(n),n})}let D=(0,N.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.peer,n);return t},[e]),ne=(0,N.useMemo)(()=>{if(s!==`lastMessage`)return C;let e=c===`desc`?-1:1;return[...C].sort((t,n)=>wt(jt(D.get(t.id)),jt(D.get(n.id)),e)||A(t).localeCompare(A(n)))},[C,s,c,D]),re=(0,N.useMemo)(()=>[...new Set(C.flatMap(e=>e.tags||[]))],[C]),ie=(0,N.useMemo)(()=>[...new Set(C.flatMap(e=>Te(e.capabilities||[])))],[C]),oe=qe(),ce=(0,N.useMemo)(()=>{if(y!==`project`)return null;let e=new Map;for(let t of ne){let n=ot(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]))},[ne,y]),le=[u,p,m,_,v].filter(Boolean).length,ue=(0,N.useMemo)(()=>Ze(ne,x,S),[ne,x,S]);function de(e){r(e,D.get(e)?.messages),t?.(e)}function fe(e){let{agent:t}=e;if(e.depth===1&&e.parent&&T.has(e.parent.id))return null;let n=D.get(t.id),r=n?.attention.unread||0,i=Fe(t),o=n?.previewMessage,s=vt(n)||jt(n),c=a===t.id,u=Ge(t),d=ot(t),f=u.Icon,p=e.parent?A(e.parent):t.spawnedBy,m=e.children.length,h=e.depth===0&&m>0,_=T.has(t.id);return(0,P.jsxs)(`li`,{className:g(`relative`,e.depth===1&&`pl-4`),children:[e.depth===1&&(0,P.jsx)(`div`,{className:`absolute left-2 top-3.5 text-muted-foreground/55`,children:(0,P.jsx)(l,{className:`h-3.5 w-3.5`})}),h&&(0,P.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ee(t.id)},className:`absolute left-0.5 top-2.5 z-10 flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground`,title:_?`Show ${m} child ${m===1?`agent`:`agents`}`:`Hide children`,"aria-expanded":!_,children:_?(0,P.jsx)(me,{className:`h-3.5 w-3.5`}):(0,P.jsx)(te,{className:`h-3.5 w-3.5`})}),(0,P.jsxs)(`button`,{className:g(`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`,e.depth===1&&`bg-muted/15`,h&&`pl-6`,c&&`bg-muted/60`),onClick:()=>de(t.id),children:[(0,P.jsxs)(`div`,{className:`relative shrink-0 mt-0.5`,children:[(0,P.jsx)(Be,{agent:t}),(0,P.jsx)(at,{agent:t,now:S,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:A(t)}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[s>0&&(0,P.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,title:Me(s),children:Oe(S,s)}),r>0&&(0,P.jsx)(Le,{className:`bg-red-500 text-white text-xs min-w-[18px] h-[18px] flex items-center justify-center shrink-0 px-1`,children:r}),m>0&&(0,P.jsx)(Le,{variant:`secondary`,className:`text-[10px] h-[18px] px-1.5`,title:`${m} live child ${m===1?`agent`:`agents`}`,children:m}),!r&&i&&(0,P.jsx)(Le,{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)(w,{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:u.title,className:`inline-flex shrink-0`,children:(0,P.jsx)(f,{className:g(`h-3 w-3`,u.iconColor)})}),(0,P.jsx)(`span`,{className:`truncate`,children:d||u.label}),Xe(t)&&(0,P.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,P.jsx)(st,{context:t.context,expected:!0,size:18})})]}),e.depth===0&&t.spawnedBy&&p&&(0,P.jsx)(`div`,{className:`mb-0.5`,children:(0,P.jsx)(Le,{variant:`outline`,className:`max-w-full text-[9px] h-4 px-1.5 text-muted-foreground`,children:(0,P.jsxs)(`span`,{className:`truncate`,children:[`spawned by `,p]})})}),o&&(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:[o.from===`user`?`You: `:``,Rt(Ce(o).replace(/\s+/g,` `))]}),t.status!==`offline`&&(0,P.jsx)(`div`,{className:`mt-1`,children:(0,P.jsx)(`span`,{className:g(`text-xs`,t.status===`busy`?`text-yellow-400`:`text-emerald-400`),children:t.status})})]})]})]},t.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)(d,{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)(M,{placeholder:`Search agents...`,value:o,onChange:e=>n({chatAgentSearch:e.target.value}),className:`pl-8 h-7 text-xs`})]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>n({chatAgentFiltersCollapsed:!b}),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)(ge,{className:`w-3.5 h-3.5`}),`Filters & sort`,le>0&&(0,P.jsx)(Le,{className:`bg-primary/20 text-primary text-[10px] h-4 min-w-4 px-1 flex items-center justify-center`,children:le})]}),b?(0,P.jsx)(te,{className:`w-3.5 h-3.5`}):(0,P.jsx)(se,{className:`w-3.5 h-3.5`})]}),(0,P.jsxs)(`div`,{className:g(`space-y-2`,b?`hidden`:`block`,`sm:block`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsxs)(`select`,{value:s,onChange:e=>n({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)(j,{variant:`ghost`,size:`icon-xs`,onClick:()=>n({chatAgentSortDir:c===`asc`?`desc`:`asc`}),children:c===`asc`?(0,P.jsx)(ae,{className:`w-3.5 h-3.5`}):(0,P.jsx)(f,{className:`w-3.5 h-3.5`})})]}),(0,P.jsxs)(`select`,{value:y,onChange:e=>n({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:u,onChange:e=>n({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=>n({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`})]}),oe.length>1&&(0,P.jsxs)(`select`,{value:v,onChange:e=>n({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`}),oe.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]})]}),(re.length>0||ie.length>0)&&(0,P.jsxs)(`div`,{className:`flex gap-1`,children:[re.length>0&&(0,P.jsxs)(`select`,{value:m,onChange:e=>n({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`}),re.map(e=>(0,P.jsxs)(`option`,{value:e,children:[`#`,e]},e))]}),ie.length>0&&(0,P.jsxs)(`select`,{value:_,onChange:e=>n({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`}),ie.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:i,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)(h,{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:ne.length===0?(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 text-center px-4`,children:[(0,P.jsx)(he,{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`})]}):ce?ce.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:Ze(t,x,S).map(fe)})]},e)):(0,P.jsx)(`ul`,{children:ue.map(fe)})})]})}var Ut=[{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`}],Wt=[{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`}],Gt=[{name:`/compact`,source:`builtin`,description:`Compact the conversation to reclaim context`},{name:`/new`,source:`builtin`,description:`Start a new thread`}];function Kt(e){return[...e===`claude`?Wt:e===`codex`?Gt:[],...Ut]}function qt({selectedInboxThread:e,agent:t,now:r,blockedState:i,thread:a,exportableThread:l,importedHistory:f,showBackButton:p,onBack:m,openAgentDetail:h,openWorkspaceFocus:g,voiceTtsEnabled:_,setVoiceTtsEnabled:y,canOpenTerminal:x,terminalOpening:S,handleOpenTerminal:w,canInterrupt:T,interruptAgent:E,canCompact:ee,canClearContext:te,canShutdown:ne,openConfirm:ae,workspaceAction:se,doAgentAction:ce,openFilesForAgent:ue,forkFromAgent:de,markInboxThreadUnread:me,markInboxThreadRead:he,exportThread:ge,onOpenSearch:O}){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:[p&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,onClick:m,className:`shrink-0 -ml-1`,children:(0,P.jsx)(ie,{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&&h(t),disabled:!t,children:[(0,P.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,P.jsx)(Be,{agent:t}),(0,P.jsx)(at,{agent:t,now:r,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?A(t):e}),t&&(0,P.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate`,children:[i?`blocked: ${i.label}`:t.status,t.machine&&` · ${t.machine}`,typeof t.meta?.cwd==`string`&&t.meta.cwd&&` · ${ke(t.meta.cwd,1)}`]})]})]}),t&&(0,P.jsx)(Je,{agent:t,compact:!0,className:`hidden @4xl/chat:flex shrink-0`}),t&&Xe(t)&&(0,P.jsx)(st,{context:t.context,expected:!0}),t?.branchState&&t.branchWorkspaceId&&(0,P.jsx)(Pt,{state:t.branchState,className:`shrink-0`,onClick:()=>void g(t.branchWorkspaceId)}),a?.attention.unread?(0,P.jsxs)(Le,{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)(Re,{value:t.id,label:`Copy agent ID`,size:`icon-sm`}),O&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,title:`Search this chat`,onClick:O,children:(0,P.jsx)(d,{className:`w-3.5 h-3.5`})}),ve.available&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,title:_?`Speaking agent responses aloud — click to mute (engine & voice in Settings)`:`Speak agent responses aloud (active chat) — engine & voice in Settings`,className:_?`text-primary`:``,onClick:()=>y(!_),children:_?(0,P.jsx)(C,{className:`w-3.5 h-3.5`}):(0,P.jsx)(pe,{className:`w-3.5 h-3.5`})}),x&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,disabled:S,title:`Terminal`,onClick:()=>void w(),children:(0,P.jsx)(D,{className:`w-3.5 h-3.5`})}),T&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,className:`text-red-400 hover:text-red-300`,title:`Interrupt`,onClick:E,children:(0,P.jsx)(le,{className:`w-3.5 h-3.5`})}),(t.branchState===`changes`||t.branchState===`idle`)&&t.branchWorkspaceId&&(0,P.jsx)(j,{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:()=>ae(`Mark Workspace Ready`,`Mark ${A(t)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>se(t.branchWorkspaceId,`ready`)),children:(0,P.jsx)(u,{className:`w-3.5 h-3.5`})}),ee&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Compact`,onClick:()=>ae(`Compact Agent`,`Compact context for ${A(t)}?`,()=>ce(t,`compact`)),children:(0,P.jsx)(c,{className:`w-3.5 h-3.5`})}),te&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Clear context`,onClick:()=>ae(`Clear Context`,`Clear context for ${A(t)}?`,()=>ce(t,`clearContext`)),children:(0,P.jsx)(v,{className:`w-3.5 h-3.5`})}),ne&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Shutdown`,onClick:()=>ae(`Shutdown Agent`,`Shutdown ${A(t)}?`,()=>ce(t,`shutdown`)),children:(0,P.jsx)(s,{className:`w-3.5 h-3.5`})}),t&&typeof t.meta?.cwd==`string`&&t.meta.cwd&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Open ${t.meta.cwd} in Files`,onClick:()=>void ue(t),children:(0,P.jsx)(oe,{className:`w-3.5 h-3.5`})}),t&&a&&a.messages.length>0&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Fork — spawn new agent with this chat history`,onClick:()=>de(t.id,a.messages),children:(0,P.jsx)(n,{className:`w-3.5 h-3.5`})}),a&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Mark unread`,onClick:()=>me(e),children:(0,P.jsx)(fe,{className:`w-3.5 h-3.5`})}),a&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Mark read`,onClick:()=>he(a.peer,a.messages),children:(0,P.jsx)(re,{className:`w-3.5 h-3.5`})}),l&&(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Export thread`,onClick:()=>ge({...l,importedHistory:f},`json`),children:(0,P.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,P.jsxs)(tt,{children:[(0,P.jsx)(We,{asChild:!0,children:(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,className:`@4xl/chat:hidden`,children:(0,P.jsx)(o,{className:`w-3.5 h-3.5`})})}),(0,P.jsxs)(ze,{align:`end`,children:[x&&(0,P.jsxs)(et,{disabled:S,onClick:()=>void w(),children:[(0,P.jsx)(D,{className:`w-3.5 h-3.5`}),`Terminal`]}),T&&(0,P.jsxs)(et,{onClick:E,children:[(0,P.jsx)(le,{className:`w-3.5 h-3.5`}),`Interrupt`]}),(t.branchState===`changes`||t.branchState===`idle`)&&t.branchWorkspaceId&&(0,P.jsxs)(et,{onClick:()=>ae(`Mark Workspace Ready`,`Mark ${A(t)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>se(t.branchWorkspaceId,`ready`)),children:[(0,P.jsx)(u,{className:`w-3.5 h-3.5`}),`Mark Ready`]}),ee&&(0,P.jsxs)(et,{onClick:()=>ae(`Compact Agent`,`Compact context for ${A(t)}?`,()=>ce(t,`compact`)),children:[(0,P.jsx)(c,{className:`w-3.5 h-3.5`}),`Compact`]}),te&&(0,P.jsxs)(et,{onClick:()=>ae(`Clear Context`,`Clear context for ${A(t)}?`,()=>ce(t,`clearContext`)),children:[(0,P.jsx)(v,{className:`w-3.5 h-3.5`}),`Clear Context`]}),ne&&(0,P.jsxs)(et,{onClick:()=>ae(`Shutdown Agent`,`Shutdown ${A(t)}?`,()=>ce(t,`shutdown`)),children:[(0,P.jsx)(s,{className:`w-3.5 h-3.5`}),`Shutdown`]}),t&&typeof t.meta?.cwd==`string`&&t.meta.cwd&&(0,P.jsxs)(et,{onClick:()=>void ue(t),children:[(0,P.jsx)(oe,{className:`w-3.5 h-3.5`}),`Open Files`]}),t&&a&&a.messages.length>0&&(0,P.jsxs)(et,{onClick:()=>de(t.id,a.messages),children:[(0,P.jsx)(n,{className:`w-3.5 h-3.5`}),`Fork`]}),(x||ee||te||ne)&&(0,P.jsx)(Ue,{}),a&&(0,P.jsxs)(et,{onClick:()=>me(e),children:[(0,P.jsx)(fe,{className:`w-3.5 h-3.5`}),`Mark Unread`]}),a&&(0,P.jsxs)(et,{onClick:()=>he(a.peer,a.messages),children:[(0,P.jsx)(re,{className:`w-3.5 h-3.5`}),`Mark Read`]}),l&&(0,P.jsxs)(et,{onClick:()=>ge({...l,importedHistory:f},`json`),children:[(0,P.jsx)(b,{className:`w-3.5 h-3.5`}),`Download`]})]})]})]})})]})}function Jt({query:e,position:t,total:n,onQueryChange:r,onNext:i,onPrev:a,onClose:o}){let s=(0,N.useRef)(null),c=e.trim().length>0,l=c&&n===0;function u(e){if(e.key===`Escape`){e.preventDefault(),o();return}e.key===`Enter`&&(e.preventDefault(),e.shiftKey?a():i())}return(0,P.jsxs)(`section`,{className:`flex shrink-0 items-center gap-2 border-b border-border bg-card/45 px-3 py-2`,children:[(0,P.jsx)(d,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,P.jsx)(M,{ref:s,autoFocus:!0,value:e,onChange:e=>r(e.target.value),onKeyDown:u,placeholder:`Search this chat…`,"aria-label":`Search this chat`,className:`h-7 flex-1 text-sm`}),(0,P.jsx)(`span`,{className:`shrink-0 tabular-nums text-xs `+(l?`text-red-400`:`text-muted-foreground`),children:c?l?`No results`:`${t}/${n}`:``}),(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,P.jsx)(j,{type:`button`,variant:`ghost`,size:`icon-sm`,title:`Previous match (Shift+Enter)`,disabled:n===0,onClick:a,children:(0,P.jsx)(se,{className:`h-3.5 w-3.5`})}),(0,P.jsx)(j,{type:`button`,variant:`ghost`,size:`icon-sm`,title:`Next match (Enter)`,disabled:n===0,onClick:i,children:(0,P.jsx)(te,{className:`h-3.5 w-3.5`})}),(0,P.jsx)(j,{type:`button`,variant:`ghost`,size:`icon-sm`,title:`Close search (Esc)`,onClick:o,children:(0,P.jsx)(ne,{className:`h-3.5 w-3.5`})})]})]})}function Yt({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:g(`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 Xt({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:g(`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 Zt({item:e,onRemove:t}){let[n,r]=(0,N.useState)(!1),i=!!(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:!i,onClick:()=>r(!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:i?`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)(w,{className:`h-4 w-4 text-red-400`}):e.uploading?(0,P.jsx)(T,{className:`h-4 w-4 animate-spin text-muted-foreground`}):(0,P.jsx)(p,{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:g(`truncate text-muted-foreground`,e.error&&`text-red-400`),children:e.error||(e.uploading?`Uploading`:xt(e.size))})]}),(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,title:`Remove attachment`,onClick:t,children:(0,P.jsx)(ne,{className:`h-3.5 w-3.5`})})]}),e.previewUrl&&(0,P.jsx)($e,{open:n,onOpenChange:r,children:(0,P.jsxs)(Ye,{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)(nt,{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:()=>r(!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)(ne,{className:`w-4 h-4`})})]})]})})]})}function Qt({draft:e,placeholder:t,chatSending:n,disabled:i,hasPendingUploads:a,readyAttachmentCount:o,pendingAttachments:s,micAvailable:c,micState:l,slashMatches:u,slashActiveIndex:d,onDraftChange:f,onKeyDown:p,onPaste:m,onUploadFiles:h,onRemovePendingAttachment:_,onSend:v,onAcceptSlash:b,onSlashHover:S,onStartPtt:C,onStopPtt:w,footerText:E}){let ee=(0,N.useRef)(null),[te,D]=(0,N.useState)(!1),ne=!e.trim()&&o===0||a||n||i;return(0,P.jsxs)(`div`,{className:g(`relative shrink-0 border-t border-border px-3 md:px-4 py-2.5 md:py-3 safe-area-bottom`,te&&`bg-primary/5 ring-1 ring-primary/40`),onDragOver:e=>{e.preventDefault(),D(!0)},onDragLeave:()=>D(!1),onDrop:e=>{e.preventDefault(),D(!1),h(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)(Zt,{item:e,onRemove:()=>_(e.id)},e.id))}),(0,P.jsx)(`input`,{ref:ee,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&h(e.target.files),e.currentTarget.value=``}}),(0,P.jsx)(Yt,{matches:u,activeIndex:d,onAccept:b,onHover:S}),(0,P.jsxs)(`div`,{className:`hidden md:flex items-end gap-2`,children:[(0,P.jsx)(j,{variant:`ghost`,size:`icon`,title:`Attach files`,disabled:n,onClick:()=>ee.current?.click(),className:`shrink-0 mb-0.5 rounded-xl h-[42px] w-[42px]`,children:(0,P.jsx)(y,{className:`w-4 h-4`})}),(0,P.jsx)(Xt,{value:e,onChange:e=>f(e.target.value),onKeyDown:p,onPaste:m,placeholder:t,className:`flex-1`}),c&&(0,P.jsx)(j,{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)(T,{className:`w-4 h-4 animate-spin`}):(0,P.jsx)(x,{className:`w-4 h-4`})}),(0,P.jsx)(j,{size:`icon`,disabled:ne,onClick:v,className:`shrink-0 mb-0.5 rounded-xl h-[42px] w-[42px]`,children:(0,P.jsx)(r,{className:`w-4 h-4`})})]}),(0,P.jsxs)(`div`,{className:`md:hidden space-y-2`,children:[(0,P.jsx)(Xt,{value:e,onChange:e=>f(e.target.value),onKeyDown:p,onPaste:m,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)(j,{variant:`ghost`,size:`icon`,title:`Attach files`,disabled:n,onClick:()=>ee.current?.click(),className:`rounded-xl h-9 w-9`,children:(0,P.jsx)(y,{className:`w-4 h-4`})}),c&&(0,P.jsx)(j,{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)(T,{className:`w-4 h-4 animate-spin`}):(0,P.jsx)(x,{className:`w-4 h-4`})})]}),(0,P.jsx)(j,{size:`icon`,disabled:ne,onClick:v,className:`rounded-xl h-9 w-9`,children:(0,P.jsx)(r,{className:`w-4 h-4`})})]})]}),E&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5 hidden md:block`,children:E})]})}var $t=e(O(),1);function en({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,$t.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)(Ke,{orchestratorId:e.orchestratorId,selectedPath:e.path,onReadError:n}):(0,P.jsx)(Ve,{orchestratorId:e.orchestratorId,selectedPath:e.path,line:e.line,onReadError:n})})]}),document.body)}var tn=[];function nn(e){return k(t=>t.chatStatusEvents[e]??tn)}function rn(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])}function an(e,t){let n=e.toLowerCase(),r=t.trim().toLowerCase();return r?n.includes(r)?!0:/\s/.test(r)||r.length<4?!1:on(n,r):!1}function on(e,t,n=4){let r=0,i=-1;for(let a=0;a<e.length&&r<t.length;a+=1)if(e[a]===t[r]){if(i!==-1&&a-i-1>n)return!1;i=a,r+=1}return r===t.length}function sn(e,t){let n=t.trim();if(!n)return[];let r=[];for(let t of e){let e=At(t);e&&an(e,n)&&r.push(lt(t))}return r}function cn(e){let[t,n]=(0,N.useState)(!1),[r,i]=(0,N.useState)(``),[a,o]=(0,N.useState)(0),s=(0,N.useMemo)(()=>t?sn(e,r):[],[t,r,e]),c=(0,N.useMemo)(()=>new Set(s),[s]),l=s.length,u=l?Math.min(a,l-1):0,d=l?s[u]??null:null,f=(0,N.useCallback)(()=>n(!0),[]),p=(0,N.useCallback)(()=>{n(!1),i(``),o(0)},[]),m=(0,N.useCallback)(e=>{i(e),o(0)},[]),h=(0,N.useCallback)(()=>{o(e=>l?(e+1)%l:0)},[l]),g=(0,N.useCallback)(()=>{o(e=>l?(e-1+l)%l:0)},[l]);return{open:t,query:r,matchKeys:s,matchKeySet:c,total:l,position:l?u+1:0,currentKey:d,openSearch:f,close:p,setQuery:m,next:h,prev:g}}var ln=0,un=1,dn=2,fn=4;function pn(e){return()=>e}function mn(e){e()}function hn(e,t){return n=>e(t(n))}function gn(e,t){return()=>e(t)}function _n(e,t){return n=>e(t,n)}function vn(e){return e!==void 0}function yn(...e){return()=>{e.map(mn)}}function bn(){}function xn(e,t){return t(e),e}function Sn(e,t){return t(e)}function F(...e){return e}function I(e,t){return e(un,t)}function L(e,t){e(ln,t)}function Cn(e){e(dn)}function R(e){return e(fn)}function z(e,t){return I(e,_n(t,ln))}function wn(e,t){let n=e(un,e=>{n(),t(e)});return n}function Tn(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function En(e,t){return e===t}function B(e=En){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=>hn(t,e)}function Dn(e){return t=>()=>{t(e)}}function U(e,...t){let n=jn(...t);return((t,r)=>{switch(t){case dn:Cn(e);return;case un:return I(e,n(r))}})}function On(e,t){return n=>r=>{n(t=e(t,r))}}function kn(e){return t=>n=>{e>0?e--:t(n)}}function An(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 jn(...e){return t=>e.reduceRight(Sn,t)}function Mn(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case un:return a?n===a?void 0:(r(),n=a,t=I(e,a),t):(r(),bn);case dn:r(),n=null;return}}}function G(e){let t=e,n=K();return((e,r)=>{switch(e){case ln:t=r;break;case un:r(t);break;case fn:return t}return n(e,r)})}function Nn(e,t){return xn(G(t),t=>z(e,t))}function K(){let e=[];return((t,n)=>{switch(t){case ln:e.slice().forEach(e=>{e(n)});return;case dn:e.splice(0,e.length);return;case un:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function Pn(e){return xn(K(),t=>z(e,t))}function q(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Fn(),singleton:n}}var Fn=()=>Symbol();function In(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 Ln(...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 dn:Cn(t);return;case un:return r===i&&a(n),I(t,a)}}}function J(e,t=En){return U(e,B(t))}function Rn(...e){return function(t,n){switch(t){case dn:return;case un:return yn(...e.map(e=>I(e,n)))}}}var zn={DEBUG:0,INFO:1,WARN:2,ERROR:3},Bn={[zn.DEBUG]:`debug`,[zn.ERROR]:`error`,[zn.INFO]:`log`,[zn.WARN]:`warn`},Vn=()=>typeof globalThis>`u`?window:globalThis,Hn=q(()=>{let e=G(zn.ERROR);return{log:G((t,n,r=zn.INFO)=>{r>=(Vn().VIRTUOSO_LOG_LEVEL??R(e))&&console[Bn[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0}),Un=new WeakMap;function Wn(e){return`self`in e?e.document.documentElement:e}function Gn(e){let t=Wn(e),n=Un.get(t);if(n!==void 0)return n;let r=t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`;return Un.set(t,r),r}function Kn(e){Un.delete(Wn(e))}function qn(e,t){return Gn(e)?-t:t}var Jn=qn;function Yn(e,t){return qn(e,t)}function Xn(e,t,n){return Zn(e,t,n).callbackRef}function Zn(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 Qn(e,t,n,r,i,a,o,s,c){return Zn(N.useCallback(n=>{let c=$n(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?Jn(o,o.scrollLeft):o.scrollTop:u?s?Jn(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?Jn(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?er(`column-gap`,getComputedStyle(n).columnGap,i):er(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function $n(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},zn.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 er(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,zn.WARN),t===`normal`?0:parseInt(t??`0`,10)}function tr(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}=Zn(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 nr=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}),rr={lvl:0};function ir(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===rr}function ar(e,t){if(!Y(e))return t===e.k?e.v:t<e.k?ar(e.l,t):ar(e.r,t)}function or(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=or(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return or(e.l,t,n)}function sr(e,t,n){return Y(e)?vr(t,n,1):t===e.k?mr(e,{k:t,v:n}):t<e.k?yr(mr(e,{l:sr(e.l,t,n)})):yr(mr(e,{r:sr(e.r,t,n)}))}function cr(){return rr}function lr(e,t,n){if(Y(e))return[];let r=or(e,t)[0];return Sr(fr(e,r,n))}function ur(e,t){if(Y(e))return rr;let{k:n,l:r,r:i}=e;if(t===n){if(Y(r))return i;if(Y(i))return r;let[t,n]=_r(r);return pr(mr(e,{k:t,l:hr(r),v:n}))}return pr(t<n?mr(e,{l:ur(r,t)}):mr(e,{r:ur(i,t)}))}function dr(e){return Y(e)?[]:[...dr(e.l),{k:e.k,v:e.v},...dr(e.r)]}function fr(e,t,n){if(Y(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(fr(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(fr(a,t,n))),s}function pr(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(gr(t))return br(mr(e,{lvl:n-1}));if(!Y(t)&&!Y(t.r))return mr(t.r,{l:mr(t,{r:t.r.l}),lvl:n,r:mr(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(gr(e))return xr(mr(e,{lvl:n-1}));if(!Y(r)&&!Y(r.l)){let t=r.l,i=gr(t)?r.lvl-1:r.lvl;return mr(t,{l:mr(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:xr(mr(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function mr(e,t){return vr(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 hr(e){return Y(e.r)?e.l:pr(mr(e,{r:hr(e.r)}))}function gr(e){return Y(e)||e.lvl>e.r.lvl}function _r(e){return Y(e.r)?[e.k,e.v]:_r(e.r)}function vr(e,t,n,r=rr,i=rr){return{k:e,l:r,lvl:n,r:i,v:t}}function yr(e){return xr(br(e))}function br(e){let{l:t}=e;return!Y(t)&&t.lvl===e.lvl?mr(t,{r:mr(e,{l:t.r})}):e}function xr(e){let{lvl:t,r:n}=e;return!Y(n)&&!Y(n.r)&&n.lvl===t&&n.r.lvl===t?mr(n,{l:mr(e,{r:n.l}),lvl:t+1}):e}function Sr(e){return ir(e,({k:e,v:t})=>({index:e,value:t}))}function Cr(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function wr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var Tr=q(()=>({recalcInProgress:G(!1)}),[],{singleton:!0});function Er(e,t,n){return e[Dr(e,t,n)]}function Dr(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 Or(e,t,n,r){let i=Dr(e,t,r),a=Dr(e,n,r,i);return e.slice(i,a+1)}function kr(e,t){return Math.round(e.getBoundingClientRect()[t])}function Ar(e){return!Y(e.groupOffsetTree)}function jr({index:e},t){return t===e?0:t<e?-1:1}function Mr(){return{groupIndices:[],groupOffsetTree:cr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:cr()}}function Nr(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=sr(e,0,i);continue}let o=lr(e,a-1,t+1);if(o.some(Gr(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=ur(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=sr(e,t+1,a));c&&(e=sr(e,a,i))}return[e,n]}function Pr(e){return typeof e.groupIndex<`u`}function Fr({offset:e},t){return t===e?0:t<e?-1:1}function Ir(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=Er(t,e,jr),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function Lr(e,t){if(!Ar(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Rr(e,t,n){if(Pr(e))return t.groupIndices[e.groupIndex]+1;let r=Lr(e.index===`LAST`?n:e.index,t);return r=Math.max(0,r,Math.min(n,r)),r}function zr(e,t,n,r=0){return r>0&&(t=Math.max(t,Er(e,r,jr).offset)),ir(Or(e,t,n,Fr),Wr)}function Br(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,zn.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)=>sr(sr(t,n,e),n+1,r),o)}else [o,s]=Nr(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=Ur(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>sr(e,t,Ir(t,d,i)),cr()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function Vr(e){return dr(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 Hr(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 Ur(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t!==0){c=Dr(i,t-1,jr),s=i[c].offset;let e=or(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===or(n,t)[1]&&--c,i=i.slice(0,c+1)}else i=[];for(let{start:e,value:c}of lr(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 Wr(e){return{index:e.index,value:e}}function Gr(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 Kr={offsetHeight:`height`,offsetWidth:`width`},qr=q(([{log:e},{recalcInProgress:t}])=>{let n=K(),r=K(),i=Nn(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)=>kr(e,Kr[t])),m=G(void 0),h=G(0),g=Mr(),_=Nn(U(n,W(c,e,h),On(Br,g),B()),g),v=Nn(U(c,B(),On((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)=>sr(e,r,Ir(r,t.offsetTree,n)||i),cr());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=Nn(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=Pn(U(n,W(_),On(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),H(e=>e.changed)));I(U(s,On((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+Hr(e,n));else if(e<0){let t=R(v);t.length>0&&(e-=Hr(-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},zn.ERROR)});let x=Pn(a);z(U(a,W(_),H(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=ar(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=dr(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 dr(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=Pn(U(o,W(_,h),H(([e,{offsetTree:t},n])=>Ir(-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=cr(),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=dr(t.sizeTree).reduce((t,{k:n,v:r})=>sr(t,Math.max(0,n+e),r),r),a!==-e){let n=ar(t.sizeTree,s);r=sr(r,0,n);let i=or(t.sizeTree,-e+1)[1];r=sr(r,1,i)}return{...t,sizeTree:r,...Ur(t.offsetTree,0,r,n)}}let r=dr(t.sizeTree).reduce((t,{k:n,v:r})=>sr(t,Math.max(0,n+e),r),cr());return{...t,sizeTree:r,...Ur(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(Hn,Tr),{singleton:!0});function Jr(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var Yr=q(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=K(),o=K(),s=Pn(U(a,H(Jr)));return z(U(s,H(e=>e.totalCount)),n),z(U(s,H(e=>e.groupIndices)),e),z(U(Ln(i,t,r),V(([e,t])=>Ar(t)),H(([e,t,n])=>or(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),B(),H(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},F(qr,nr)),Xr=q(([{log:e}])=>{let t=G(!1),n=Pn(U(t,V(e=>e),B()));return I(t,t=>{t&&R(e)(`props updated`,{},zn.DEBUG)}),{didMount:n,propsReady:t}},F(Hn),{singleton:!0}),Zr=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function Qr(e){let t=typeof e==`number`?{index:e}:e;return t.align||=`start`,(!t.behavior||!Zr)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var $r=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=Qr(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=Rr(b,n,w),E=Ir(T,n.offsetTree,d)+o;x===`end`?(E+=f+or(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+or(n.sizeTree,T)[1]-r+h)/2:E-=a,C!==void 0&&C!==0&&(E+=C);let ee=t=>{y(),t?(l(`retrying to scroll to`,{location:e},zn.DEBUG),L(p,e)):(L(m,!0),l(`list did not change, scroll successful`,{},zn.DEBUG))};if(y(),S===`smooth`){let e=!1;v=I(t,t=>{e||=t}),g=wn(u,()=>{ee(e)})}else g=wn(U(t,ei(150)),ee);return _=setTimeout(()=>{y()},1200),L(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},zn.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},F(qr,nr,Hn),{singleton:!0});function ei(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function ti(e,t){e===0?t():requestAnimationFrame(()=>{ti(e-1,t)})}function ni(e,t){let n=t-1;return typeof e==`number`?e:e.index===`LAST`?n:e.index}var ri=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),Dn(!1)),s),z(U(o,W(c),V(([e,t])=>t!==0),Dn(!1)),l),I(U(Ln(t,o),W(s,n,e,l),V(([[,e],t,{sizeTree:n},r,i])=>e&&(!Y(n)||vn(r))&&!t&&!i),W(c)),([,e])=>{wn(i,()=>{L(l,!0)}),ti(4,()=>{wn(r,()=>{L(s,!0)}),L(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},F(qr,nr,$r,Xr),{singleton:!0});function ii(e,t){return Math.abs(e-t)<1.01}var ai=`up`,oi=`down`,si=`none`,ci={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},li=0,ui=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(li),f=Nn(U(Rn(U(J(i),kn(1),Dn(!0)),U(J(i),kn(1),Dn(!1),Tn(100))),B()),!1),p=Nn(U(Rn(U(n,Dn(!0)),U(n,Dn(!1),Tn(200))),B()),!1);z(U(Ln(J(i),J(d)),H(([e,t])=>e<=t),B()),s),z(U(s,An(50)),l);let m=Pn(U(Ln(r,J(a),J(t),J(e),J(u)),On((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}},ci),B((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=Nn(U(r,On((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!ii(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,An(50)),c);let g=G(oi);z(U(r,H(({scrollTop:e})=>e),B(),On((e,t)=>R(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?ai:oi,prevScrollTop:t},{direction:oi,prevScrollTop:0}),H(e=>e.direction)),g),z(U(r,An(50),Dn(si)),g);let _=G(0);return z(U(f,V(e=>!e),Dn(0)),_),z(U(i,An(100),W(f),V(([e,t])=>t),On(([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(nr)),di=`top`,fi=`bottom`,pi=`none`;function mi(e,t,n){return typeof e==`number`?n===ai&&t===di||n===oi&&t===fi?e:0:n===ai?t===di?e.main:e.reverse:t===fi?e.main:e.reverse}function hi(e,t){return typeof e==`number`?e:e[t]??0}var gi=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:Nn(U(Ln(J(r),J(i),J(n),J(a,wr),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=pi,m=hi(l,di),h=hi(l,fi);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=ai),i<e-f+t+h&&(p=oi),p===pi?null:[Math.max(u-n-mi(a,di,p)-m,0),u-f-s+t+mi(a,fi,p)+h]}),V(e=>e!==null),B(wr)),[0,0])}},F(nr),{singleton:!0});function _i(e,t,n){if(Ar(t)){let r=Lr(e,t);return[{index:or(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 vi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function yi(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:xi(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:xi(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function bi(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=ni(t,s);return yi(Array.from({length:s}).map((e,t)=>({data:a[t+c],index:t+c,offset:0,size:0})),[],s,i,n,r)}function xi(e,t,n){if(e.length===0)return[];if(!Ar(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=lr(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 Si(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var Ci=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=Nn(U(Ln(p,m,J(c,wr),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{...vi,totalCount:n};if(e===0&&t===0)return m===0?{...vi,totalCount:n}:bi(m,i,r,s,c,u||[]);if(Y(p))return m>0?null:yi(_i(ni(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 lr(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 yi([],h,n,c,d,s);let _=o.length>0?o[o.length-1]+1:0,v=zr(f,e,t,_);if(v.length===0)return null;let y=n-1,b=xn([],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=Si(l,di),S=Si(l,fi);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=lr(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=lr(p,r,r)[0]?.value??t.size;b.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return yi(b,h,n,c,d,s)}),V(e=>e!==null),B()),vi);z(U(e,V(vn),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=Pn(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(wr),H(([e])=>e))),x=Pn(U(y,An(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:Pn(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(Cr))),startReached:x,topItemsIndexes:h,...f}},F(qr,Yr,gi,ri,$r,ui,Xr,Tr),{singleton:!0}),wi=q(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=K(),o=Nn(U(Ln(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(nr,Ci),{singleton:!0}),Ti=q(([{viewportHeight:e},{totalListHeight:t}])=>{let n=G(!1);return{alignToBottom:n,paddingTopAddition:Nn(U(Ln(n,e,t),V(([e])=>e),H(([,e,t])=>Math.max(0,e-t)),An(0),B()),0)}},F(nr,wi),{singleton:!0}),Ei=q(()=>({context:G(null)})),Di=({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,Oi=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=Di,done:d,...f}=e,p=Rr(e,t,r-1),m=Ir(p,t.offsetTree,l)+i+a,h=m+or(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&wn(U(o,V(e=>!e),kn(R(o)?1:2)),d),_}),V(e=>e!==null)),l),{scrollIntoView:u}},F(qr,nr,$r,Ci,Hn),{singleton:!0});function ki(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var Ai=(e,t)=>typeof e==`function`?ki(e(t)):t&&ki(e),ji=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(Ln(U(J(t),kn(1)),c),W(J(m),a,s,d),H(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=Ai(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=wn(e,()=>{R(u)(`following output to `,{totalCount:r},zn.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{R(u)(`following output to `,{totalCount:r},zn.DEBUG),_(t)})});function v(e){let t=wn(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(R(u)(`scrolling to bottom due to increased size`,{},zn.DEBUG),_(`auto`))});setTimeout(t,100)}I(U(Ln(J(m),t,l),V(([e,,t])=>e!==!1&&t),On(({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(Ln(J(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=G(null),b=K();return z(Rn(U(J(r),H(e=>e?.length??0)),U(J(t))),b),I(U(Ln(U(b,kn(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),An(0)),t=>{g!==null&&(g(),g=null),R(n)===void 0?g=wn(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(qr,ui,$r,ri,Xr,Hn,nr,Ei,Oi)),Mi=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=[]])=>bi(e,t,n,r,i,a))),o),{}),F(qr,ri,Ci,Xr),{singleton:!0}),Ni=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=>{wn(U(n,kn(1),V(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{L(t,e)})})}),{initialScrollTop:r}},F(Xr,nr,Ci),{singleton:!0}),Pi=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(Ln(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(ui),{singleton:!0}),Fi=q(([{scrollContainerState:e,scrollTo:t}])=>{let n=K(),r=K(),i=K(),a=G(!1),o=G(void 0);return z(U(Ln(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(nr)),Ii=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=Vr(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),z(U(u,V(vn),H(Li)),i),z(U(a,W(u),V(([,e])=>e!==void 0),B(),H(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},F(qr,nr,ri,Xr,Fi));function Li(e){return{align:`start`,index:0,offset:e.scrollTop}}var Ri=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(Ci));function zi(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var Bi=zi(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Vi=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:ee,topItemsIndexes:te,rangeChanged:D,...ne}=b;return z(D,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:te,totalCount:f,...y,groupIndices:o,itemSize:c,listState:E,minOverscanItemCount:ee,scrollToIndex:x,statefulTotalCount:d,trackItemSizes:p,rangeChanged:D,...ne,...T,..._,sizes:u,...v}},F(qr,ri,nr,Ii,ji,Ci,$r,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=Pn(U(c,W(o),On(([,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===ai),H(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},zn.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&&Bi()?L(e,n-t):g(-t)}),I(U(Ln(Nn(a,!1),e,m),V(([e,t,n])=>!e&&!n&&t!==0),H(([e,t])=>t),An(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=ar(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(nr,ui,Ci,qr,Hn,Tr)),Ri,Yr,q(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),F(gi,Mi,Xr,Pi,wi,Ni,Ti,Fi,Oi,Hn,Ei))));function Hi(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 Ui=typeof document<`u`?N.useLayoutEffect:N.useEffect;function Wi(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]=Mn(e[t.events[r]]),n),{})}return{Component:N.forwardRef(function(t,a){let{children:d,...f}=t,[p]=N.useState(()=>xn(In(e),e=>{c(e,f)})),[m]=N.useState(gn(u,p));Ui(()=>{for(let e of o)e in f&&I(m[e],f[e]);return()=>{Object.values(m).map(Cn)}},[f,m,p]),Ui(()=>{c(p,f)}),N.useImperativeHandle(a,pn(l(p)));let h=n;return(0,P.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,P.jsx)(h,{...Hi([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=N.useContext(s)[e];Ui(()=>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 Gi=N.createContext(void 0),Ki=N.createContext(void 0),qi=`-webkit-sticky`,Ji=`sticky`,Yi=zi(()=>{if(typeof document>`u`)return Ji;let e=document.createElement(`div`);return e.style.position=qi,e.style.position===qi?qi:Ji}),Xi=typeof document<`u`?N.useLayoutEffect:N.useEffect;function Zi(e){return`self`in e}function Qi(e){return`body`in e}function $i(e,t,n,r=bn,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(Qi(l)||Zi(l)){let e=Zi(l)?l:l.defaultView;o=a===!0?Jn(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?Jn(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():$t.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 Kn(e),r(i||o.current),l({suppressFlushSync:!0,target:e}),e.addEventListener(`scroll`,l,{passive:!0}),()=>{Kn(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;Zi(r)?(u=Math.max(kr(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?Jn(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=kr(r,a===!0?`width`:`height`),d=a===!0?Jn(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,ii(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:Yn(r,p)}),r.scrollTo(n)}function d(e){a===!0&&(e={...e.behavior===void 0?{}:{behavior:e.behavior},...e.top===void 0?{}:{left:Yn(o.current,e.top)}}),o.current.scrollBy(e)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}function ea(e){return e}var ta=q(([e,t])=>({...e,...t}),F(Vi,q(()=>{let e=G(e=>`Item ${e}`),t=G(e=>`Group ${e}`),n=G({}),r=G(ea),i=G(`div`),a=G(bn),o=(e,t=null)=>Nn(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`)}}))),na=({height:e})=>(0,P.jsx)(`div`,{style:{height:e}}),ra={overflowAnchor:`none`,position:Yi(),zIndex:1},ia={overflowAnchor:`none`},aa={...ia,display:`inline-block`,height:`100%`},oa=N.memo(function({showTopList:e=!1}){let t=Z(`listState`),n=Sa(`sizeRanges`),r=Z(`useWindowScroll`),i=Z(`customScrollParent`),a=Sa(`windowScrollContainerState`),o=Sa(`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=Sa(`gap`),h=Z(`horizontalDirection`),{callbackRef:g}=Qn(n,f,d,e?bn:s,p,m,i,h,Z(`skipAnimationFrameInResizeObserver`)),[_,v]=N.useState(0);xa(`deviation`,e=>{_!==e&&v(e)});let y=Z(`EmptyPlaceholder`),b=Z(`ScrollSeekPlaceholder`)??na,x=Z(`ListComponent`),S=Z(`ItemComponent`),C=Z(`GroupComponent`),w=Z(`computeItemKey`),T=Z(`isSeeking`),E=Z(`groupIndices`).length>0,ee=Z(`alignToBottom`),te=Z(`initialItemFinalLocationReached`),D=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginInlineStart:_===0?ee?`auto`:0:_,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:`nowrap`}:{marginTop:_===0?ee?`auto`:0:_,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...te?{}:{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:D,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:ra},u(e.index,l)):(0,N.createElement)(S,{...X(S,l),...fa(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?aa:ia},E?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),sa={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},ca={outline:`none`,overflowX:`auto`,position:`relative`},la=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),ua=(e,t,n=0)=>({...la(e),position:t?`relative`:`absolute`,top:t?-n:0}),da={position:Yi(),top:0,width:`100%`,zIndex:1};function X(e,t){if(typeof e!=`string`)return{context:t}}function fa(e,t){return{item:typeof e==`string`?void 0:t}}var pa=N.memo(function(){let e=Z(`HeaderComponent`),t=Sa(`headerHeight`),n=Z(`HeaderFooterTag`),r=Xn(N.useMemo(()=>e=>{t(kr(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)})})}),ma=N.memo(function(){let e=Z(`FooterComponent`),t=Sa(`footerHeight`),n=Z(`HeaderFooterTag`),r=Xn(N.useMemo(()=>e=>{t(kr(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 ha({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}=$i(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?ca:sa,...i},tabIndex:0,...o,...X(c,a),children:r})})}function ga({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}=$i(s,l,c,t(`scrollerRef`),f);return Xi(()=>(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 _a=({children:e})=>{let t=N.useContext(Gi),n=Sa(`viewportHeight`),r=Sa(`fixedItemHeight`),i=Z(`alignToBottom`),a=Z(`horizontalDirection`),o=Xn(N.useMemo(()=>hn(n,e=>kr(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:la(i),children:e})},va=({children:e})=>{let t=N.useContext(Gi),n=Sa(`windowViewportRect`),r=Sa(`fixedItemHeight`),i=Z(`customScrollParent`),a=Z(`useWindowScroll`),o=Z(`topListHeight`),s=tr(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:ua(c,a,o),children:e})},ya=({children:e})=>{let t=Z(`TopItemListComponent`)??`div`,n=Z(`headerHeight`);return(0,P.jsx)(t,{style:{...da,marginTop:`${n}px`},...X(t,Z(`context`)),children:e})},{Component:ba,useEmitter:xa,useEmitterValue:Z,usePublisher:Sa}=Wi(ta,{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?wa:Ca,{...e,context:i,children:[n&&(0,P.jsx)(ya,{children:(0,P.jsx)(oa,{showTopList:!0})}),(0,P.jsxs)(r||t?va:_a,{children:[(0,P.jsx)(pa,{}),(0,P.jsx)(oa,{}),(0,P.jsx)(ma,{})]})]})})),Ca=ha({useEmitter:xa,useEmitterValue:Z,usePublisher:Sa}),wa=ga({useEmitter:xa,useEmitterValue:Z,usePublisher:Sa}),Ta=ba,Ea=q(([e,t])=>({...e,...t}),F(Vi,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(ea),s=G(bn),c=(e,t=null)=>Nn(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`)}}))),Da=({height:e})=>(0,P.jsx)(`tr`,{children:(0,P.jsx)(`td`,{style:{height:e}})}),Oa=({height:e})=>(0,P.jsx)(`tr`,{children:(0,P.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),ka={overflowAnchor:`none`},Aa={position:Yi(),zIndex:2,overflowAnchor:`none`},ja=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`)??Da,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:{...Aa,top:o}},l(t.index,i)):(0,N.createElement)(f,{...X(f,i),...fa(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?{...Aa,top:o+g}:ka},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),Ma=N.memo(function(){let e=Q(`listState`),t=Q(`topItemsIndexes`).length>0,n=La(`sizeRanges`),r=Q(`useWindowScroll`),i=Q(`customScrollParent`),a=La(`windowScrollContainerState`),o=La(`scrollContainerState`),s=i||r?a:o,c=Q(`trackItemSizes`),{callbackRef:l,ref:u}=Qn(n,Q(`itemSize`),c,s,Q(`log`),void 0,i,!1,Q(`skipAnimationFrameInResizeObserver`)),[d,f]=N.useState(0);Ia(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=Q(`EmptyPlaceholder`),m=Q(`FillerRow`)??Oa,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)(ja,{showTopList:!0}),(0,P.jsx)(ja,{}),C]})}),Na=({children:e})=>{let t=N.useContext(Gi),n=La(`viewportHeight`),r=La(`fixedItemHeight`),i=Xn(N.useMemo(()=>hn(n,e=>kr(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:la(!1),children:e})},Pa=({children:e})=>{let t=N.useContext(Gi),n=La(`windowViewportRect`),r=La(`fixedItemHeight`),i=Q(`customScrollParent`),a=Q(`useWindowScroll`),o=tr(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:ua(!1,a),children:e})},{Component:Fa,useEmitter:Ia,useEmitterValue:Q,usePublisher:La}=Wi(Ea,{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=La(`fixedHeaderHeight`),i=La(`fixedFooterHeight`),a=Q(`fixedHeaderContent`),o=Q(`fixedFooterContent`),s=Q(`context`),c=Xn(N.useMemo(()=>hn(r,e=>kr(e,`height`)),[r]),!0,Q(`skipAnimationFrameInResizeObserver`)),l=Xn(N.useMemo(()=>hn(i,e=>kr(e,`height`)),[i]),!0,Q(`skipAnimationFrameInResizeObserver`)),u=n||t?za:Ra,d=n||t?Pa:Na,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)(Ma,{},`TableBody`),g]})})})})),Ra=ha({useEmitter:Ia,useEmitterValue:Q,usePublisher:La}),za=ga({useEmitter:Ia,useEmitterValue:Q,usePublisher:La}),Ba={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Va={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ha,floor:Ua,max:Wa,min:Ga,round:Ka}=Math;function qa(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function Ja(e){return{...Va,items:e}}function Ya(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function Xa(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var Za=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(Ba),T=G({height:0,width:0}),E=G({height:0,width:0}),ee=K(),te=K(),D=G(0),ne=G(null),re=G({column:0,row:0}),ie=K(),ae=K(),oe=G(!1),se=G(0),ce=G(!0),le=G(!1),ue=G(!1);I(U(m,W(se),V(([e,t])=>t!==0)),()=>{L(ce,!1)}),I(U(Ln(m,ce,E,T,se,le),V(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{L(le,!0),ti(1,()=>{L(ee,e)}),wn(U(l),()=>{L(t,[0,0]),L(ce,!0)})}),z(U(ae,V(e=>e!=null&&e.scrollTop>0),Dn(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(oe,!0),wn(U(l,kn(1)),e=>{L(oe,!1)}),L(c,{top:e.scrollTop})))}),z(U(T,H(({height:e})=>e)),d),z(U(Ln(J(T,Ya),J(E,Ya),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(Ln(J(S),r,J(re,Xa),J(E,Ya),J(T,Ya),J(ne),J(C),J(oe),J(ce),J(se)),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 Ba;if(p===0){let t=ni(l,e);return Ja(qa(t,t+Math.max(s-1,0),o))}let h=Qa(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*Ua((t+d)/(f+d)),_=h*Ha((n+d)/(f+d))-1,_=Ga(e-1,Wa(_,h-1)),g=Ga(_,Wa(0,g))):(g=0,_=-1);let v=qa(g,_,o),{bottom:y,top:b}=$a(a,r,i,v),x=Ha(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(Ln(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}=$a(e,r,t,n);return[a,i]}),B(wr)),t);let de=G(!1);z(U(l,W(de),H(([e,t])=>t||e!==0)),de);let fe=Pn(U(Ln(w,S),V(([{items:e}])=>e.length>0),W(de),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())),pe=Pn(U(J(w),V(({items:e})=>e.length>0&&e[0].index===0),Dn(0),B())),me=Pn(U(J(w),W(oe),V(([{items:e},t])=>e.length>0&&!t),H(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),B(Cr),An(0)));z(me,p.scrollSeekRangeChanged),z(U(ee,W(T,E,S,re),H(([e,t,n,r,i])=>{let a=Qr(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=Wa(0,l,Ga(r-1,l));let u=eo(t,i,n,l);return o===`end`?u=Ka(u-t.height+n.height):o===`center`&&(u=Ka(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let he=Nn(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:D,footerHeight:i,gap:re,headerHeight:a,increaseViewportBy:e,initialItemCount:C,itemDimensions:E,overscan:n,restoreStateFrom:ae,scrollBy:o,scrollContainerState:s,scrollHeight:te,scrollTo:c,scrollToIndex:ee,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:_,viewportDimensions:T,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b,...p,gridState:w,horizontalDirection:ue,initialTopMostItemIndex:se,totalListHeight:he,...f,endReached:fe,propsReady:h,rangeChanged:me,startReached:pe,stateChanged:ie,stateRestoreInProgress:oe,...x}},F(gi,nr,ui,Pi,Xr,Fi,Hn));function Qa(e,t,n){return Wa(1,Ua((e+n)/(Ua(t)+n)))}function $a(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=eo(e,t,n,r[0].index);return{bottom:eo(e,t,n,r[r.length-1].index)+i,top:a}}function eo(e,t,n,r){let i=Ua(r/Qa(e.width,n.width,t.column)),a=i*n.height+Wa(0,i-1)*t.row;return a>0?a+t.row:a}var to=q(([e,t])=>({...e,...t}),F(Za,q(()=>{let e=G(e=>`Item ${e}`),t=G({}),n=G(null),r=G(`virtuoso-grid-item`),i=G(`virtuoso-grid-list`),a=G(ea),o=G(`div`),s=G(bn),c=(e,n=null)=>Nn(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`)}}))),no=N.memo(function(){let e=$(`gridState`),t=$(`listClassName`),n=$(`itemClassName`),r=$(`itemContent`),i=$(`computeItemKey`),a=$(`isSeeking`),o=lo(`scrollHeight`),s=$(`ItemComponent`),c=$(`ListComponent`),l=$(`ScrollSeekPlaceholder`),u=$(`context`),d=lo(`itemDimensions`),f=lo(`gap`),p=$(`log`),m=$(`stateRestoreInProgress`),h=lo(`reportReadyState`),g=Xn(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:po(`column-gap`,getComputedStyle(e).columnGap,p),row:po(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return Xi(()=>{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))})})}),ro=N.memo(function(){let e=$(`HeaderComponent`),t=lo(`headerHeight`),n=$(`headerFooterTag`),r=Xn(N.useMemo(()=>e=>{t(kr(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)})})}),io=N.memo(function(){let e=$(`FooterComponent`),t=lo(`footerHeight`),n=$(`headerFooterTag`),r=Xn(N.useMemo(()=>e=>{t(kr(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)})})}),ao=({children:e})=>{let t=N.useContext(Ki),n=lo(`itemDimensions`),r=lo(`viewportDimensions`),i=Xn(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:la(!1),children:e})},oo=({children:e})=>{let t=N.useContext(Ki),n=lo(`windowViewportRect`),r=lo(`itemDimensions`),i=$(`customScrollParent`),a=$(`useWindowScroll`),o=tr(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:ua(!1,a),children:e})},{Component:so,useEmitter:co,useEmitterValue:$,usePublisher:lo}=Wi(to,{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?fo:uo,i=n||t?oo:ao,a=$(`context`);return(0,P.jsx)(r,{...e,...X(r,a),children:(0,P.jsxs)(i,{children:[(0,P.jsx)(ro,{}),(0,P.jsx)(no,{}),(0,P.jsx)(io,{})]})})})),uo=ha({useEmitter:co,useEmitterValue:$,usePublisher:lo}),fo=ga({useEmitter:co,useEmitterValue:$,usePublisher:lo});function po(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,zn.WARN),t===`normal`?0:parseInt(t??`0`,10)}function mo({agentId:e,approval:t}){let n=k(e=>e.sendPermissionDecision),[r,i]=(0,N.useState)(null);if(!t)return null;if(t.questions&&t.questions.length)return(0,P.jsx)(_o,{agentId:e,approval:t,questions:t.questions});let a=t,o=t.choices.length?t.choices:[{id:`approve`,label:`Approve`},{id:`deny`,label:`Deny`}];async function s(t){if(!r){i(t.id);try{await n(e,a.id,t.id)}finally{i(null)}}}let c=t.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:[c?(0,P.jsx)(ce,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-400`}):(0,P.jsx)(w,{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:t.title}),t.body&&(c?(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)(it,{text:t.body,rawBody:t.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:t.body})),(0,P.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.map(e=>(0,P.jsxs)(j,{size:`sm`,variant:e.id===`deny`||e.id===`abort`?`outline`:`default`,disabled:!!r,onClick:()=>void s(e),className:`h-7 px-2 text-xs`,children:[r===e.id&&(0,P.jsx)(T,{className:`mr-1.5 h-3 w-3 animate-spin`}),e.label]},e.id))})]})]})})})}function ho(e){return e?e.otherActive&&e.other.trim()?!0:e.labels.length>0:!1}function go(e){let t=[...e.labels];return e.otherActive&&e.other.trim()&&t.push(e.other.trim()),t.join(`, `)}function _o({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=ho(d),_=n.every((e,t)=>ho(o[t])),v=!!c;function y(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);y({labels:t?(d?.labels??[]).filter(t=>t!==e):[...d?.labels??[],e]})}else y({labels:[e],otherActive:!1})}function x(){y(f?{otherActive:!d?.otherActive}:{labels:[],otherActive:!0})}async function S(){if(!(!_||v)){l(`answer`);try{let i={};n.forEach((e,t)=>{let n=o[t];n&&(i[e.question]=go(n))}),await r(e,t.id,`answer`,i)}finally{l(null)}}}async function C(){if(!v){l(`dismiss`);try{await r(e,t.id,`deny`)}finally{l(null)}}}let w=!!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)(ee,{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)(Le,{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:v,onClick:()=>b(e.label),className:g(`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`,v&&`opacity-60`),children:[(0,P.jsx)(`span`,{className:g(`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)(ue,{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:v,onClick:x,className:g(`flex items-start gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors`,w?`border-amber-500/60 bg-amber-500/10`:`border-border bg-background/60 hover:bg-background`,v&&`opacity-60`),children:[(0,P.jsx)(`span`,{className:g(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center border text-amber-300`,f?`rounded`:`rounded-full`,w?`border-amber-400 bg-amber-400/20`:`border-muted-foreground/40`),children:w&&(0,P.jsx)(ue,{className:`h-3 w-3`})}),(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:`Other…`})]}),w&&(0,P.jsx)(rt,{autoFocus:!0,rows:2,disabled:v,value:d?.other??``,onChange:e=>y({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)(j,{size:`sm`,variant:`outline`,disabled:v,onClick:()=>a(e=>e-1),className:`h-7 px-2 text-xs`,children:[(0,P.jsx)(E,{className:`mr-1 h-3 w-3`}),`Back`]}),m?(0,P.jsxs)(j,{size:`sm`,disabled:v||!_,onClick:()=>void S(),className:`h-7 px-2 text-xs`,children:[c===`answer`&&(0,P.jsx)(T,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Send answer`,p>1?`s`:``]}):(0,P.jsxs)(j,{size:`sm`,disabled:v||!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)(j,{size:`sm`,variant:`ghost`,disabled:v,onClick:()=>void C(),className:`ml-auto h-7 px-2 text-xs text-muted-foreground`,children:[c===`dismiss`&&(0,P.jsx)(T,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Dismiss`]})]})]})})}var vo=1e6,yo=new Map,bo=`px-3 md:px-4`;function xo({context:e}){if(!e)return null;let{agentId:t,busy:n,pendingApproval:r,blockedLabel:i,canInterrupt:a,onInterrupt:o}=e,s=n&&!r;return!r&&!s?null:(0,P.jsxs)(`div`,{className:`${bo} pb-3 md:pb-4`,children:[r&&(0,P.jsx)(mo,{agentId:t,approval:r},r.id),s&&(0,P.jsx)(yt,{blockedLabel:i,onInterrupt:a?o:void 0})]})}function So(e){let t=e.findIndex(e=>e.type!==`date`&&e.type!==`created`),n=t>=0?t:0,r=e[n];return{key:r?lt(r):null,index:n}}function Co(e,t){let[n,r]=(0,N.useState)(()=>vo-t.length),i=(0,N.useRef)({agentId:e,anchor:So(t)});return(0,N.useLayoutEffect)(()=>{let n=So(t),a=i.current;r(n=>{if(a.agentId!==e)return vo-t.length;if(!a.anchor.key)return n;let r=t.findIndex(e=>lt(e)===a.anchor.key)-a.anchor.index;return r>0?n-r:n}),i.current={agentId:e,anchor:n}},[e,t]),n}function wo({agentId:e,agentStatus:t,timeline:n,hasMore:r,loading:a,loadedInitial:o,showReasoning:s,pendingApproval:c,blockedLabel:l,canInterrupt:u,searchActive:d,searchCurrentKey:f,searchMatchKeys:p,onAtBottomChange:m,onScrollerRef:h,onLoadOlder:_,onInterrupt:v,onOpenReferencedPath:y,onPreviewReferencedPath:b,onPreviewReferencedPathEnd:x}){let C=(0,N.useRef)(null),w=(0,N.useRef)(null),[E,ee]=(0,N.useState)(!0),te=t===`busy`,[D,ne]=(0,N.useState)(te);(0,N.useLayoutEffect)(()=>{if(te){ne(!0);return}let e=setTimeout(()=>ne(!1),600);return()=>clearTimeout(e)},[te]);let re=Co(e,n),ie=n.length>0?n[n.length-1]:null,ae=ie?lt(ie):null,oe=(ie?.type===`message`||ie?.type===`initial-prompt`)&&ie.msg.from===`user`,se=(0,N.useRef)(n);se.current=n;let ce=(0,N.useRef)(re);ce.current=re;let le=(0,N.useRef)(null),ue=(0,N.useCallback)(e=>{let t=e.startIndex-ce.current,n=se.current[t];le.current=n?lt(n):null},[]),de=(0,N.useRef)(null);if(de.current===null){let t=yo.get(e),r=-1;t&&!t.stick&&t.topKey&&(r=n.findIndex(e=>lt(e)===t.topKey)),de.current=r>=0?r:Math.max(0,n.length-1)}let fe=(0,N.useRef)(ae),pe=(0,N.useRef)(e);pe.current!==e&&(pe.current=e,fe.current=ae);let me=fe.current?n.findIndex(e=>lt(e)===fe.current):-1,he=!E&&me>=0?n.slice(me+1).filter(e=>e.type===`message`&&e.msg.from!==`user`).length:0;(0,N.useLayoutEffect)(()=>{E&&(fe.current=ae)},[E,ae]);let ge=(0,N.useRef)(E);ge.current=E;let O=(0,N.useRef)(yo.get(e)?.stick??!0),_e=(0,N.useRef)(!1),ve=(0,N.useRef)(0),ye=(0,N.useRef)(0),be=(0,N.useCallback)(()=>{ye.current=performance.now()+150},[]),xe=(0,N.useCallback)(()=>{be(),C.current?.scrollToIndex({index:`LAST`,align:`end`});let e=performance.now(),t=0,n=!1,r=!1,i=()=>{if(n)return;let a=w.current;if(a){let e=a.scrollHeight-a.clientHeight-a.scrollTop,t=a.scrollHeight-a.clientHeight>64;if(e<=64&&t&&(r=!0,_e.current=!0),r&&e>300)return;be(),a.scrollTo({top:a.scrollHeight,behavior:`auto`})}performance.now()-e>800||(t=requestAnimationFrame(i))};return t=requestAnimationFrame(i),()=>{n=!0,cancelAnimationFrame(t)}},[be]);(0,N.useLayoutEffect)(()=>{if(oe&&(O.current=!0),O.current)return xe()},[ae,oe,xe]),(0,N.useLayoutEffect)(()=>{let t=yo.get(e);if(!t||t.stick||!t.topKey)return;let n=t.topKey,r=0,i=performance.now(),a=()=>{let e=se.current.findIndex(e=>lt(e)===n);if(e>=0){be(),C.current?.scrollToIndex({index:e,align:`start`});return}performance.now()-i<1500&&(r=requestAnimationFrame(a))};return r=requestAnimationFrame(a),()=>cancelAnimationFrame(r)},[]),(0,N.useEffect)(()=>()=>{yo.set(e,{stick:O.current,topKey:le.current})},[e]);let k=c?.id;(0,N.useLayoutEffect)(()=>{if(!D&&!k||!O.current)return;let e=0,t=performance.now(),n=()=>{let r=w.current;r&&O.current&&r.scrollHeight-r.clientHeight-r.scrollTop>2&&(be(),r.scrollTo({top:r.scrollHeight,behavior:`auto`})),performance.now()-t<300&&(e=requestAnimationFrame(n))};return e=requestAnimationFrame(n),()=>cancelAnimationFrame(e)},[D,k,be]),(0,N.useLayoutEffect)(()=>{if(!d||!f)return;let e=se.current.findIndex(e=>lt(e)===f);e<0||(O.current=!1,be(),C.current?.scrollToIndex({index:e,align:`center`}))},[d,f,be]);let Se=(0,N.useRef)(null),Ce=(0,N.useCallback)(e=>{let t=e instanceof HTMLElement?e:null;if(w.current=t,h?.(t),Se.current?.(),Se.current=null,!t)return;ve.current=t.scrollTop;let n=()=>{let e=t.scrollTop,n=t.scrollHeight-t.clientHeight-e,r=performance.now()<ye.current;n<=64?O.current=!0:!r&&e<ve.current-1&&(O.current=!1),ve.current=e};t.addEventListener(`scroll`,n,{passive:!0}),Se.current=()=>t.removeEventListener(`scroll`,n)},[h]),we=(0,N.useCallback)(e=>{ee(e),e&&(O.current=!0),m?.(e)},[m]),Te=(0,N.useCallback)(()=>{!r||a||_()},[r,a,_]),Ee=(0,N.useCallback)(()=>{fe.current=ae,O.current=!0,xe()},[ae,xe]),De=(0,N.useMemo)(()=>function(){return(0,P.jsx)(`div`,{className:bo,children:(0,P.jsx)(To,{hasMore:r,loading:a,loadedInitial:o,hasItems:n.length>0})})},[r,o,a,n]),Oe=(0,N.useMemo)(()=>({agentId:e,busy:D,pendingApproval:c,blockedLabel:l,canInterrupt:u,onInterrupt:v}),[e,D,l,u,v,c]),ke=(0,N.useMemo)(()=>function(){return(0,P.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center`,children:[a?(0,P.jsx)(T,{className:`mb-2 h-5 w-5 animate-spin text-muted-foreground`}):(0,P.jsx)(S,{className:`mb-2 h-8 w-8 text-zinc-600`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a?`Loading messages`:`No messages yet`})]})},[a]),Ae=(0,N.useMemo)(()=>({Header:De,Footer:xo,EmptyPlaceholder:ke}),[ke,De]);return(0,P.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,P.jsx)(Ta,{ref:C,scrollerRef:Ce,className:`h-full py-3 md:py-4`,style:{height:`100%`,overflowX:`hidden`,overscrollBehavior:`contain`},context:Oe,data:n,firstItemIndex:re,initialTopMostItemIndex:de.current??Math.max(0,n.length-1),computeItemKey:(e,t)=>lt(t),rangeChanged:ue,itemContent:(t,n)=>{let r=d?lt(n):``,i=d&&p?.has(r);return(0,P.jsx)(`div`,{className:bo,children:(0,P.jsx)(`div`,{className:g(i&&`rounded-xl ring-1 ring-amber-400/40 transition-shadow`,i&&r===f&&`ring-2 ring-amber-400 bg-amber-400/5`),children:(0,P.jsx)(Eo,{entry:n,agentId:e,showReasoning:s,onOpenReferencedPath:y,onPreviewReferencedPath:b,onPreviewReferencedPathEnd:x})})})},components:Ae,startReached:Te,atBottomStateChange:we,atBottomThreshold:64,followOutput:()=>O.current?`auto`:!1,totalListHeightChanged:()=>{if(!O.current)return;let e=w.current;if(!e)return;let t=e.scrollHeight-e.clientHeight-e.scrollTop;t>=0&&t<=240&&(be(),e.scrollTo({top:e.scrollHeight,behavior:`auto`}))},increaseViewportBy:{top:600,bottom:600}},e),!E&&n.length>0&&(0,P.jsxs)(j,{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:Ee,children:[(0,P.jsx)(i,{className:`h-3.5 w-3.5`}),`Latest`,he>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:he>99?`99+`:he})]})]})}function To({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)(T,{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 Eo({entry:e,agentId:t,showReasoning:n,onOpenReferencedPath:r,onPreviewReferencedPath:i,onPreviewReferencedPathEnd:a}){let o=k(e=>e.agentsById[t]?.issueRepo);return e.type===`message`?(0,P.jsx)(Dt,{msg:e.msg,peer:t,onOpenReferencedPath:r,onPreviewReferencedPath:i,onPreviewReferencedPathEnd:a}):e.type===`initial-prompt`?(0,P.jsx)(bt,{msg:e.msg,issueRepo:o}):e.type===`notice`?(0,P.jsx)(Ot,{msg:e.msg}):e.type===`agent-action`?(0,P.jsx)(Tt,{entry:e}):e.type===`activity`?(0,P.jsx)(St,{steps:e.steps,showReasoning:n,issueRepo:o}):e.type===`import-boundary`?(0,P.jsx)(Et,{history:e.history}):e.type===`imported-message`?(0,P.jsx)(mt,{entry:e.entry,sourceLabel:e.history.sourceAgentLabel||e.history.sourcePeerId,issueRepo:o}):e.type===`status`?(0,P.jsx)(ht,{event:e.event}):e.type===`date`?(0,P.jsx)(Ct,{date:e.date}):(0,P.jsx)(ft,{timestamp:e.timestamp})}var Do=[],Oo=15e3;function ko(e){return e.kind===`session`&&e.payload?.session?.type===`prompt`}function Ao(e){let t=e.filter(e=>e.kind===`chat`&&e.from===`user`);return t.length?e.filter(e=>{if(!ko(e)||e.from!==`user`)return!0;let n=we(e).trim();if(!n)return!0;let r=Ae(e.createdAt);return!t.some(e=>we(e).trim()===n&&Math.abs(Ae(e.createdAt)-r)<=Oo)}):e}function jo({threads:e,onBack:t,showBackButton:n}){let r=k(e=>e.selectedInboxThread),i=k(e=>e.agentsById),o=k(e=>e.inboxDrafts),s=be(),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),m=k(e=>e.markInboxThreadUnread),h=k(e=>e.setReplyDraft),g=k(e=>e.exportThread),v=k(e=>e.doAgentAction),y=k(e=>e.workspaceAction),b=k(e=>e.openWorkspaceFocus),x=k(e=>e.forkFromAgent),C=k(e=>e.chatHistoryImports),w=k(e=>e.agentChatByAgent[e.selectedInboxThread]),T=w?.messages??Do,E=k(e=>e.loadOlder),ee=k(e=>e.openConfirm),te=k(e=>e.showError),D=k(e=>e.orchestrators),re=k(e=>e.fetchOrchestrators),ie=k(e=>e.showReasoning),ae=k(e=>e.voiceTtsEnabled),oe=k(e=>e.setVoiceTtsEnabled),se=k(e=>e.voiceInputMode),ce=k(e=>e.plansByThread);(0,N.useRef)(null);let le=(0,N.useRef)(null),[ue,de]=(0,N.useState)(`idle`),fe=(0,N.useRef)([]),[pe,me]=(0,N.useState)([]),[he,ge]=(0,N.useState)(!1),[O,Se]=(0,N.useState)(null),[Ce,we]=(0,N.useState)(null),[Te,Oe]=(0,N.useState)(``),ke=(0,N.useRef)(null),Ae=(0,N.useRef)(0),[Me,Ne]=(0,N.useState)(null),Pe=nn(r),Fe=(0,N.useMemo)(()=>e.find(e=>e.peer===r)||null,[e,r]),Le=(0,N.useMemo)(()=>Ao(T.filter(e=>De(r,e)&&!Ie(e)).sort((e,t)=>e.id-t.id)),[T,r]),M=i[r]||null,Re=typeof M?.meta?.lifecycleAction==`string`&&M.meta.lifecycleAction.startsWith(`finalizing-`),{terminalOpen:ze,terminalTarget:Be,terminalOpening:He,openTerminal:Ue,closeTerminal:We}=Nt(M?.id),Ge=typeof M?.meta?.spawnRequestId==`string`?M.meta.spawnRequestId:``,qe=(0,N.useMemo)(()=>C.filter(e=>e.targetAgentId===r||!!(Ge&&e.targetSpawnRequestId===Ge)),[Ge,C,r]),Je=Ee(M),Ye=Je?.pendingApproval,Xe=(0,N.useMemo)(()=>{if(!r||!Fe&&Le.length===0)return null;let e=Le[Le.length-1]??Fe?.lastMessage??null,t=Fe?.previewMessage&&Le.some(e=>e.id===Fe.previewMessage?.id)?Fe.previewMessage:e;return{id:Fe?.id??r,peer:r,messages:Le,lastMessage:e,previewMessage:t,attention:Fe?.attention??{unread:0,needsHumanResponse:!1,score:0},archived:Fe?.archived??!1,draft:Fe?.draft??``}},[r,Fe,Le]),Ze=Xe||(qe.length>0?{peer:r,messages:[],importedHistory:qe}:null),$e=o[r]||``,et=typeof M?.meta?.tmuxSession==`string`&&M.meta.tmuxSession.trim()?M.meta.tmuxSession:null,tt=et?D.find(e=>e.managedAgents?.some(e=>e.agentId===M.id||e.tmuxSession===et))??null:null,nt=!!(et&&tt?.status===`online`&&M?.providerCapabilities?.terminal?.live?.read),rt=M?.providerCapabilities?.model?.provider??(typeof M?.meta?.provider==`string`?M.meta.provider:void 0),it=!!(nt&&(M?.providerCapabilities?.terminal?.live?.write||rt===`claude`)),at=M?.providerCapabilities?.terminal?.attach?.create===!0,ot=nt||at,st=je(M,`compact`),ct=je(M,`clearContext`),lt=je(M,`shutdown`),ft=je(M,`interrupt`),mt=()=>{M&&v(M,`interrupt`)},[ht,vt]=(0,N.useState)(0),[yt,bt]=(0,N.useState)(!1),xt=M?.providerCapabilities?.liveSession?.slashCommands===!0,St=M?.providerCapabilities?.model?.provider??(typeof M?.meta?.provider==`string`?M.meta.provider:void 0),Ct=xt&&!yt&&/^\/\S*$/.test($e)?Kt(St).filter(e=>e.name.toLowerCase().startsWith($e.toLowerCase())):[],wt=Ct.length?Math.min(ht,Ct.length-1):0;function Tt(e){h(r,`${e.name} `),vt(0)}function Et(e){h(r,e),yt&&bt(!1),vt(0)}let Dt=pe.some(e=>e.uploading),Ot=pe.filter(e=>e.artifact);rn($e.trim().length>0||pe.length>0,(0,N.useCallback)(()=>{},[])),fe.current=pe,(0,N.useEffect)(()=>()=>{Mt(fe.current)},[]),(0,N.useEffect)(()=>{M?.meta?.tmuxSession&&D.length===0&&re()},[M?.id,M?.meta?.tmuxSession,D.length]),(0,N.useEffect)(()=>()=>{ke.current!==null&&window.clearTimeout(ke.current)},[]);let At=typeof M?.spawnedBy==`string`?M.spawnedBy:void 0,jt=At?i[At]?.meta?.provider:void 0,Pt=(0,N.useMemo)(()=>ut(Le,Pe,M?.createdAt,qe,At?{spawnedBy:{agentId:At,provider:jt}}:void 0),[Le,Pe,M?.createdAt,qe,At,jt]),It=(0,N.useMemo)(()=>kt(M,Le,Xe?.lastMessage,ce),[M,Xe?.lastMessage,ce,Le]),Lt=cn(Pt),Rt=(0,N.useCallback)(()=>{!r||!w?.hasMore||w.loading||E(r)},[w?.hasMore,w?.loading,E,r]),zt=(0,N.useCallback)(()=>{ke.current!==null&&(window.clearTimeout(ke.current),ke.current=null)},[]),Bt=(0,N.useCallback)(async e=>{let t=_t(D,e);if(!t)return null;try{let n=await _(`GET`,`/orchestrators/${encodeURIComponent(t.id)}/files/stat?path=${encodeURIComponent(e)}`);return{orchestratorId:t.id,path:n.path,type:n.type}}catch{return null}},[D]),Vt=(0,N.useCallback)((e,t,n)=>{if(!pt()||!n)return;let r=++Ae.current;Bt(e).then(e=>{Ae.current===r&&e&&(zt(),we({...e,line:t||0,anchor:n}),Oe(``))})},[zt,Bt]),Ht=(0,N.useCallback)(()=>{Ae.current+=1,zt(),ke.current=window.setTimeout(()=>{we(null)},250)},[zt]),Ut=(0,N.useCallback)((e,t)=>{Bt(e).then(n=>{if(!n){te(`File Not Found`,e);return}if(pt()){Ae.current+=1,zt(),we(null),Se({...n,line:t||0}),Oe(``);return}n.type===`directory`?l({orchestratorId:n.orchestratorId,path:n.path,overlay:!0}):l({orchestratorId:n.orchestratorId,path:dt(n.path),selectedPath:n.path,line:t,overlay:!0})})},[zt,l,Bt,te]);function Wt(){Se(null),Oe(``)}async function Gt(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}));me(e=>[...e,...n]);for(let e=0;e<t.length;e+=1){let r=t[e],i=n[e];try{let e=await a(`/artifacts`,r,{filename:r.name,sensitivity:`normal`});me(t=>t.map(t=>t.id===i.id?{...t,artifact:e,uploading:!1}:t))}catch(e){me(t=>t.map(t=>t.id===i.id?{...t,error:e.message,uploading:!1}:t))}}}function Yt(e){me(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})}function Xt(){Mt(pe),me([])}function Zt(){if(!$e.trim()&&Ot.length===0||!r||f||Dt||Re)return;let e=Ot.map(e=>({artifactId:e.artifact.id,kind:e.artifact.kind,role:`media`,title:e.artifact.filename||e.fileName}));c($e,{peer:r,lastMessage:Xe?.lastMessage||null},e),Xt()}function $t(e){if(Ct.length){if(e.key===`ArrowDown`){e.preventDefault(),vt(e=>Math.min(e+1,Ct.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),vt(e=>Math.max(e-1,0));return}if(e.key===`Escape`){e.preventDefault(),bt(!0);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=Ct[wt];t&&Tt(t);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Zt())}function tn(e){let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),Gt(t))}async function an(){if(!xe||ue!==`idle`||!r)return;ve.bargeIn();let e=new _e;try{await e.start(),le.current=e,de(`recording`)}catch(e){le.current=null,de(`idle`),te(`Microphone unavailable`,e?.message||`Could not access the microphone.`)}}async function on(){let e=le.current;if(!(!e||ue!==`recording`)){le.current=null,de(`transcribing`);try{let t=await e.stop();if(!t)return;let n=await ye(t);if(!n)return;let i=$e?`${$e} ${n}`:n;if(se===`autosend`&&!f&&!Dt){let e=Ot.map(e=>({artifactId:e.artifact.id,kind:e.artifact.kind,role:`media`,title:e.artifact.filename||e.fileName}));c(i,{peer:r,lastMessage:Xe?.lastMessage||null},e),Xt()}else h(r,i)}catch(e){te(`Transcription failed`,e?.message||`Could not transcribe audio.`)}finally{de(`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)(qt,{selectedInboxThread:r,agent:M,now:s,blockedState:Je,thread:Xe,exportableThread:Ze,importedHistory:qe,showBackButton:n,onBack:t,openAgentDetail:d,openWorkspaceFocus:b,voiceTtsEnabled:ae,setVoiceTtsEnabled:oe,canOpenTerminal:ot,terminalOpening:He,handleOpenTerminal:Ue,canInterrupt:ft,interruptAgent:mt,canCompact:st,canClearContext:ct,canShutdown:lt,openConfirm:ee,workspaceAction:y,doAgentAction:v,openFilesForAgent:u,forkFromAgent:x,markInboxThreadUnread:m,markInboxThreadRead:p,exportThread:g,onOpenSearch:Lt.openSearch}),(0,P.jsx)(Ft,{threadId:It&&`threadId`in It?It.threadId:null,teamId:It&&`teamId`in It?It.teamId:void 0,channel:It?.channel}),Lt.open&&(0,P.jsx)(Jt,{query:Lt.query,position:Lt.position,total:Lt.total,onQueryChange:Lt.setQuery,onNext:Lt.next,onPrev:Lt.prev,onClose:Lt.close}),(0,P.jsx)(gt,{scrollEl:Me,timeline:Pt}),(0,P.jsx)(wo,{agentId:r,agentStatus:M?.status,timeline:Pt,hasMore:w?.hasMore??!1,loading:w?.loading??!1,loadedInitial:w?.loadedInitial??!1,showReasoning:ie,pendingApproval:Ye,blockedLabel:Je?.label,canInterrupt:ft,searchActive:Lt.open,searchCurrentKey:Lt.currentKey,searchMatchKeys:Lt.matchKeySet,onScrollerRef:Ne,onLoadOlder:Rt,onInterrupt:mt,onOpenReferencedPath:Ut,onPreviewReferencedPath:Vt,onPreviewReferencedPathEnd:Ht}),(0,P.jsx)(Qt,{draft:$e,placeholder:`Message ${M?A(M):r}…`,chatSending:f,disabled:Re,hasPendingUploads:Dt,readyAttachmentCount:Ot.length,pendingAttachments:pe,micAvailable:xe,micState:ue,slashMatches:Ct,slashActiveIndex:wt,onDraftChange:Et,onKeyDown:$t,onPaste:tn,onUploadFiles:e=>{Gt(e)},onRemovePendingAttachment:Yt,onSend:Zt,onAcceptSlash:Tt,onSlashHover:vt,onStartPtt:()=>{an()},onStopPtt:()=>{on()},footerText:Re?`${M?A(M):`Agent`} is wrapping up (${(M?.meta?.lifecycleAction).slice(11)}) — messaging paused`:`Enter to send · Shift+Enter for newline`})]}),O&&(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`}),Te&&(0,P.jsx)(`span`,{className:`max-w-[18rem] truncate text-xs text-red-400`,children:Te}),(0,P.jsx)(j,{variant:`ghost`,size:`icon-sm`,title:`Close preview`,onClick:Wt,children:(0,P.jsx)(ne,{className:`h-3.5 w-3.5`})})]}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1`,children:O.type===`directory`?(0,P.jsx)(Ke,{orchestratorId:O.orchestratorId,selectedPath:O.path,onReadError:Oe}):(0,P.jsx)(Ve,{orchestratorId:O.orchestratorId,selectedPath:O.path,line:O.line,onReadError:Oe})})]})]}),Ce&&(0,P.jsx)(en,{preview:Ce,error:Te,onReadError:Oe,onMouseEnter:zt,onMouseLeave:Ht}),Be&&(0,P.jsx)(Qe,{open:ze,onOpenChange:We,orchestratorId:Be.orchestratorId,session:Be.session,interactive:Be.interactive||it})]}):(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center px-4`,children:[(0,P.jsx)(S,{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 Mo(){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 No(e,t){(0,N.useEffect)(()=>{if(typeof window>`u`||!e||!window.matchMedia(`(max-width: 767px)`).matches)return;window.history.pushState({chatOpen:!0},``);function n(){t()}return window.addEventListener(`popstate`,n),()=>{window.removeEventListener(`popstate`,n),window.history.state?.chatOpen&&window.history.back()}},[e,t])}function Po(){let e=He(),t=k(e=>e.selectedInboxThread),n=k(e=>e.set),r=k(e=>e.loadAgentChat),i=k(e=>e.agentsById),a=!!t;Mo(),(0,N.useEffect)(()=>{t&&r(t)},[t,r]),(0,N.useEffect)(()=>{t&&(i[t]||n({selectedInboxThread:``}))},[t,i,n]);let o=(0,N.useCallback)(()=>{n({selectedInboxThread:``})},[n]);return No(a,o),(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)(Ht,{threads:e})}),(0,P.jsx)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:(0,P.jsx)(jo,{threads:e},t||`empty`)})]}),(0,P.jsx)(`div`,{className:`md:hidden flex w-full overflow-hidden`,children:a?(0,P.jsx)(Fo,{children:(0,P.jsx)(jo,{threads:e,onBack:o,showBackButton:!0},t||`empty`)}):(0,P.jsx)(`div`,{className:`w-full flex flex-col overflow-hidden`,children:(0,P.jsx)(Ht,{threads:e})})})]})}function Fo({children:e}){let t=ct();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{Po as ChatView};
|
|
2
|
-
//# sourceMappingURL=chat-DJqvtoFT.js.map
|