agent-relay-server 0.65.2 → 0.67.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-CG_eCKDI.js +3 -0
- package/public/assets/MessageBubble-CG_eCKDI.js.map +1 -0
- package/public/assets/{PlanGraphPanel-DrHNFbg6.js → PlanGraphPanel-Ba9qh-if.js} +2 -2
- package/public/assets/{PlanGraphPanel-DrHNFbg6.js.map → PlanGraphPanel-Ba9qh-if.js.map} +1 -1
- package/public/assets/{activity-CECdsDpd.js → activity-8eZ4FhxO.js} +2 -2
- package/public/assets/{activity-CECdsDpd.js.map → activity-8eZ4FhxO.js.map} +1 -1
- package/public/assets/{agent-profiles-CHitqihm.js → agent-profiles-1Nx8ROA_.js} +2 -2
- package/public/assets/{agent-profiles-CHitqihm.js.map → agent-profiles-1Nx8ROA_.js.map} +1 -1
- package/public/assets/{agents-GG-aJj6Z.js → agents-C8fM2VwM.js} +2 -2
- package/public/assets/{agents-GG-aJj6Z.js.map → agents-C8fM2VwM.js.map} +1 -1
- package/public/assets/{analytics-y0Yf26cD.js → analytics-D6ffu1ji.js} +2 -2
- package/public/assets/{analytics-y0Yf26cD.js.map → analytics-D6ffu1ji.js.map} +1 -1
- package/public/assets/{automation-CmzftGBn.js → automation-BVmzNi6H.js} +2 -2
- package/public/assets/{automation-CmzftGBn.js.map → automation-BVmzNi6H.js.map} +1 -1
- package/public/assets/{branch-state-badge-Biam17QK.js → branch-state-badge-DrwCnoKR.js} +2 -2
- package/public/assets/{branch-state-badge-Biam17QK.js.map → branch-state-badge-DrwCnoKR.js.map} +1 -1
- package/public/assets/{channels-CmAXppQu.js → channels-BuqbbyaO.js} +2 -2
- package/public/assets/{channels-CmAXppQu.js.map → channels-BuqbbyaO.js.map} +1 -1
- package/public/assets/chat-DCnEGe-x.js +2 -0
- package/public/assets/chat-DCnEGe-x.js.map +1 -0
- package/public/assets/{connectors-bZ0YsSqg.js → connectors-_LpoKQNb.js} +2 -2
- package/public/assets/{connectors-bZ0YsSqg.js.map → connectors-_LpoKQNb.js.map} +1 -1
- package/public/assets/formatted-body-impl-C7ftpr0y.js +3 -0
- package/public/assets/formatted-body-impl-C7ftpr0y.js.map +1 -0
- package/public/assets/index-eCpWfoCA.css +2 -0
- package/public/assets/{index-BSWui_-2.js → index-ksV0Snw6.js} +10 -10
- package/public/assets/index-ksV0Snw6.js.map +1 -0
- package/public/assets/{insights-cC2lVGUs.js → insights-BjRehGVP.js} +2 -2
- package/public/assets/{insights-cC2lVGUs.js.map → insights-BjRehGVP.js.map} +1 -1
- package/public/assets/{integrations--k7_eYP2.js → integrations-DCyxAv8c.js} +2 -2
- package/public/assets/{integrations--k7_eYP2.js.map → integrations-DCyxAv8c.js.map} +1 -1
- package/public/assets/{maintenance-B6wOij_l.js → maintenance-CKiNcUMS.js} +2 -2
- package/public/assets/{maintenance-B6wOij_l.js.map → maintenance-CKiNcUMS.js.map} +1 -1
- package/public/assets/{managed-agents-CDzLSKp1.js → managed-agents-Os_T-7w7.js} +2 -2
- package/public/assets/{managed-agents-CDzLSKp1.js.map → managed-agents-Os_T-7w7.js.map} +1 -1
- package/public/assets/{markdown-preview-impl-D3Y4uUgk.js → markdown-preview-impl-grkpBldu.js} +2 -2
- package/public/assets/{markdown-preview-impl-D3Y4uUgk.js.map → markdown-preview-impl-grkpBldu.js.map} +1 -1
- package/public/assets/{memory-DYzw5EXn.js → memory-YiYlqWUZ.js} +2 -2
- package/public/assets/{memory-DYzw5EXn.js.map → memory-YiYlqWUZ.js.map} +1 -1
- package/public/assets/{messages-ATbJw7jy.js → messages-CVDtrrub.js} +2 -2
- package/public/assets/messages-CVDtrrub.js.map +1 -0
- package/public/assets/orchestrators-Dzup-DDB.js +2 -0
- package/public/assets/{orchestrators-Dtr4zNWI.js.map → orchestrators-Dzup-DDB.js.map} +1 -1
- package/public/assets/{overview-B071A7FM.js → overview-DZltfAFn.js} +2 -2
- package/public/assets/{overview-B071A7FM.js.map → overview-DZltfAFn.js.map} +1 -1
- package/public/assets/{pairs-DgiNK9mA.js → pairs-Q2CmriBh.js} +2 -2
- package/public/assets/{pairs-DgiNK9mA.js.map → pairs-Q2CmriBh.js.map} +1 -1
- package/public/assets/{projects-DhQUdwcb.js → projects-DtJmrhI0.js} +2 -2
- package/public/assets/projects-DtJmrhI0.js.map +1 -0
- package/public/assets/{security-COHkbWIm.js → security-Bur19Sp4.js} +2 -2
- package/public/assets/{security-COHkbWIm.js.map → security-Bur19Sp4.js.map} +1 -1
- package/public/assets/{select-CKPIes_u.js → select-CuzWJuBz.js} +2 -2
- package/public/assets/{select-CKPIes_u.js.map → select-CuzWJuBz.js.map} +1 -1
- package/public/assets/settings-CEMCJ31_.js +4 -0
- package/public/assets/settings-CEMCJ31_.js.map +1 -0
- package/public/assets/store-BeKcuJ2q.js +9 -0
- package/public/assets/store-BeKcuJ2q.js.map +1 -0
- package/public/assets/{tasks-DdVsKCUN.js → tasks-DjwAusKz.js} +2 -2
- package/public/assets/{tasks-DdVsKCUN.js.map → tasks-DjwAusKz.js.map} +1 -1
- package/public/assets/{teams-BLQeR-qJ.js → teams-CFCnB12u.js} +2 -2
- package/public/assets/{teams-BLQeR-qJ.js.map → teams-CFCnB12u.js.map} +1 -1
- package/public/assets/{terminal-viewer-impl-eFq9PBWV.js → terminal-viewer-impl-CWu5RTp2.js} +2 -2
- package/public/assets/{terminal-viewer-impl-eFq9PBWV.js.map → terminal-viewer-impl-CWu5RTp2.js.map} +1 -1
- package/public/assets/{work-queue-OFw-Hwir.js → work-queue-TZQ5Gz0t.js} +2 -2
- package/public/assets/{work-queue-OFw-Hwir.js.map → work-queue-TZQ5Gz0t.js.map} +1 -1
- package/public/assets/{workspaces-zum4lO_O.js → workspaces-Bu4uVUcu.js} +2 -2
- package/public/assets/{workspaces-zum4lO_O.js.map → workspaces-Bu4uVUcu.js.map} +1 -1
- package/public/index.html +3 -3
- package/src/agent-issue-repo.ts +29 -0
- package/src/branch-landed.ts +69 -2
- package/src/cli/index.ts +6 -4
- package/src/config.ts +1 -0
- package/src/context-advisory.ts +93 -15
- package/src/context-threshold-config.ts +14 -2
- package/src/db/migrations.ts +24 -0
- package/src/db/projects.ts +34 -6
- package/src/db/schema.ts +1 -0
- package/src/mcp/tools-workspace.ts +3 -3
- package/src/mcp-project-tools.ts +2 -0
- package/src/notification-router.ts +2 -0
- package/src/provider-catalog-store.ts +35 -0
- package/src/routes/agents.ts +3 -2
- package/src/routes/commands.ts +6 -1
- package/src/routes/provider-config.ts +27 -0
- package/src/services/git-remote.ts +46 -0
- package/src/services/issue-lifecycle.ts +5 -36
- package/src/services/project.ts +23 -3
- package/src/services/register-agent.ts +7 -1
- package/src/services/spawn-agent.ts +7 -9
- package/src/services/spawn-registration-watchdog.ts +34 -12
- package/src/settings/registry.ts +2 -0
- package/src/sse.ts +9 -4
- package/src/workspace-phase.ts +17 -9
- package/public/assets/MessageBubble-DLF9fJLb.js +0 -2
- package/public/assets/MessageBubble-DLF9fJLb.js.map +0 -1
- package/public/assets/chat-C-FI9bLO.js +0 -2
- package/public/assets/chat-C-FI9bLO.js.map +0 -1
- package/public/assets/formatted-body-impl-D--5zVSd.js +0 -3
- package/public/assets/formatted-body-impl-D--5zVSd.js.map +0 -1
- package/public/assets/index-BSWui_-2.js.map +0 -1
- package/public/assets/index-B_On3Osd.css +0 -2
- package/public/assets/messages-ATbJw7jy.js.map +0 -1
- package/public/assets/orchestrators-Dtr4zNWI.js +0 -2
- package/public/assets/projects-DhQUdwcb.js.map +0 -1
- package/public/assets/settings-B4SN1TpB.js +0 -4
- package/public/assets/settings-B4SN1TpB.js.map +0 -1
- package/public/assets/store-DnHOGovN.js +0 -9
- package/public/assets/store-DnHOGovN.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageBubble-DLF9fJLb.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\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// 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 }: { steps: ActivityStep[]; showReasoning: boolean }) {\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 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} 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 }: { entry: ChatHistoryImportEntry; sourceLabel?: 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} 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 }: { msg: Message }) {\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} className=\"text-sm leading-relaxed text-foreground\" />\n </div>\n </div>\n )\n}\n\nexport function StickyPromptBanner({ scrollRef, timeline }: { scrollRef: React.RefObject<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(true)\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') 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 useEffect(() => {\n const scrollEl = scrollRef.current\n if (!lastOutbound || !scrollEl) { setHidden(true); return }\n const target = scrollEl.querySelector(`[data-msg-id=\"${lastOutbound.id}\"]`)\n if (!target) { setHidden(true); return }\n const observer = new IntersectionObserver(\n ([e]) => {\n if (!e) return\n setHidden(e.isIntersecting)\n if (!e.isIntersecting) {\n const rootTop = e.rootBounds?.top ?? scrollEl.getBoundingClientRect().top\n setPromptAbove(e.boundingClientRect.top < rootTop)\n }\n },\n { root: scrollEl, threshold: 0 }\n )\n observer.observe(target)\n const onScroll = () => {\n const r = target.getBoundingClientRect()\n const sr = scrollEl.getBoundingClientRect()\n setPromptAbove(r.top < sr.top)\n }\n scrollEl.addEventListener('scroll', onScroll, { passive: true })\n return () => { observer.disconnect(); scrollEl.removeEventListener('scroll', onScroll) }\n }, [lastOutbound?.id, scrollRef])\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 const scrollEl = scrollRef.current\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=\"sticky top-0 z-10 -mx-3 md:-mx-4 -mt-3 md:-mt-4 bg-background\">\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 border-b border-primary/10 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 <div className=\"sticky top-0 z-10 -mx-3 md:-mx-4 -mt-3 md:-mt-4 px-2 md:px-3 pt-2 pb-1.5 bg-background border-b border-primary/10\">\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 </div>\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 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} 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 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 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,02GAyMA,SAAA,GAAA,EAAA,EAAA,uFClTA,SAAgB,GAAY,EAAsB,CAGhD,OAFI,EAAO,KAAa,GAAG,EAAK,IAC5B,EAAO,KAAO,KAAa,IAAI,EAAO,MAAM,QAAQ,EAAE,CAAC,KACpD,IAAI,EAAO,KAAO,MAAM,QAAQ,EAAE,CAAC,KAG5C,SAAgB,GAAoB,EAAa,EAAsB,CACrE,GAAI,EAAK,WAAW,IAAI,CAAE,OAAO,EACjC,IAAM,EAAQ,GAAG,EAAI,QAAQ,OAAQ,GAAG,CAAC,GAAG,IAAO,MAAM,IAAI,CACvD,EAAkB,EAAE,CAC1B,IAAK,IAAM,KAAQ,EACb,CAAC,GAAQ,IAAS,MAClB,IAAS,KAAM,EAAM,KAAK,CACzB,EAAM,KAAK,EAAK,EAEvB,MAAO,IAAM,EAAM,KAAK,IAAI,CAG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CAAA,EAER"}
|
|
@@ -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 D,fn as ee,h as te,i as O,it as ne,jn as re,kn as ie,kt as ae,ln as oe,lt as se,nn as ce,pn as le,r as ue,rt as de,s as fe,un as pe,wn as me,x as he}from"./lucide-react-BbMYCUlW.js";import{t as ge}from"./react-dom-HJwa4sZ-.js";import{c as _e,d as ve,h as ye,m as be,p as xe,t as k}from"./store-DnHOGovN.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 j,w as Fe}from"./display-LAWaAboe.js";import{t as Ie}from"./badge-C6NJQ60B.js";import{t as M}from"./button-DD2CCM3t.js";import{t as Le}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-BSWui_-2.js";import{t as ct}from"./use-keyboard-viewport-CEmOxaNm.js";import{_ as lt,a as ut,b as dt,c as ft,d as pt,f as mt,g as ht,h as gt,i as _t,l as vt,m as yt,n as bt,o as xt,p as St,r as Ct,s as wt,t as Tt,u as Et,v as Dt,x as Ot,y as kt}from"./MessageBubble-DLF9fJLb.js";import{n as At,t as jt}from"./branch-state-badge-Biam17QK.js";import{t as Mt}from"./PlanGraphPanel-DrHNFbg6.js";var N=e(m(),1);function Nt(){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`?(Ae(t.lastSeen)-Ae(e.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(),Pt=[{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 Ft(e,t=`i`){let n=null;for(let t of Pt){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?Ft(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(...Ft(a,`${t}r`)),r}var It=`agent-relay.chat.collapsedChildren`;function Lt(){if(typeof window>`u`)return new Set;try{let e=JSON.parse(window.localStorage.getItem(It)||`[]`);return new Set(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])}catch{return new Set}}function Rt(e){if(!(typeof window>`u`))try{window.localStorage.setItem(It,JSON.stringify([...e]))}catch{}}function zt({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=_e(),C=Nt(),[T,E]=(0,N.useState)(Lt);function D(e){E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),Rt(n),n})}let te=(0,N.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.peer,n);return t},[e]),O=(0,N.useMemo)(()=>{if(s!==`lastMessage`)return C;let e=c===`desc`?-1:1;return[...C].sort((t,n)=>{let r=dt(te.get(t.id));return(dt(te.get(n.id))-r)*e||A(t).localeCompare(A(n))})},[C,s,c,te]),ne=(0,N.useMemo)(()=>[...new Set(C.flatMap(e=>e.tags||[]))],[C]),re=(0,N.useMemo)(()=>[...new Set(C.flatMap(e=>Te(e.capabilities||[])))],[C]),ae=qe(),se=(0,N.useMemo)(()=>{if(y!==`project`)return null;let e=new Map;for(let t of O){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]))},[O,y]),ce=[u,p,m,_,v].filter(Boolean).length,le=(0,N.useMemo)(()=>Ze(O,x,S),[O,x,S]);function ue(e){r(e,te.get(e)?.messages),t?.(e)}function de(e){let{agent:t}=e;if(e.depth===1&&e.parent&&T.has(e.parent.id))return null;let n=te.get(t.id),r=n?.attention.unread||0,i=j(t),o=n?.previewMessage,s=yt(n)||dt(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(),D(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)(pe,{className:`h-3.5 w-3.5`}):(0,P.jsx)(ee,{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:()=>ue(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)(Ie,{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)(Ie,{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)(Ie,{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)(Ie,{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: `:``,Ft(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)(Le,{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)(he,{className:`w-3.5 h-3.5`}),`Filters & sort`,ce>0&&(0,P.jsx)(Ie,{className:`bg-primary/20 text-primary text-[10px] h-4 min-w-4 px-1 flex items-center justify-center`,children:ce})]}),b?(0,P.jsx)(ee,{className:`w-3.5 h-3.5`}):(0,P.jsx)(oe,{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)(M,{variant:`ghost`,size:`icon-xs`,onClick:()=>n({chatAgentSortDir:c===`asc`?`desc`:`asc`}),children:c===`asc`?(0,P.jsx)(ie,{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`})]}),ae.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`}),ae.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]})]}),(ne.length>0||re.length>0)&&(0,P.jsxs)(`div`,{className:`flex gap-1`,children:[ne.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`}),ne.map(e=>(0,P.jsxs)(`option`,{value:e,children:[`#`,e]},e))]}),re.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`}),re.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:O.length===0?(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 text-center px-4`,children:[(0,P.jsx)(me,{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`})]}):se?se.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(de)})]},e)):(0,P.jsx)(`ul`,{children:le.map(de)})})]})}var Bt=[{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`}],Vt=[{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`}],Ht=[{name:`/compact`,source:`builtin`,description:`Compact the conversation to reclaim context`},{name:`/new`,source:`builtin`,description:`Start a new thread`}];function Ut(e){return[...e===`claude`?Vt:e===`codex`?Ht:[],...Bt]}function Wt({selectedInboxThread:e,agent:t,now:r,blockedState:i,thread:a,exportableThread:l,importedHistory:d,showBackButton:f,onBack:p,openAgentDetail:m,openWorkspaceFocus:h,voiceTtsEnabled:g,setVoiceTtsEnabled:_,canOpenTerminal:y,terminalOpening:x,handleOpenTerminal:S,canInterrupt:w,interruptAgent:T,canCompact:E,canClearContext:D,canShutdown:ee,openConfirm:O,workspaceAction:ie,doAgentAction:oe,openFilesForAgent:se,forkFromAgent:le,markInboxThreadUnread:ue,markInboxThreadRead:pe,exportThread:me}){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:[f&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:p,className:`shrink-0 -ml-1`,children:(0,P.jsx)(re,{className:`w-4 h-4`})}),(0,P.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 md:gap-2.5 min-w-0 hover:opacity-80 transition-opacity`,onClick:()=>t&&m(t),disabled:!t,children:[(0,P.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,P.jsx)(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)(jt,{state:t.branchState,className:`shrink-0`,onClick:()=>void h(t.branchWorkspaceId)}),a?.attention.unread?(0,P.jsxs)(Ie,{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`}),ye.available&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,title:g?`Speaking agent responses aloud — click to mute (engine & voice in Settings)`:`Speak agent responses aloud (active chat) — engine & voice in Settings`,className:g?`text-primary`:``,onClick:()=>_(!g),children:g?(0,P.jsx)(C,{className:`w-3.5 h-3.5`}):(0,P.jsx)(fe,{className:`w-3.5 h-3.5`})}),y&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,disabled:x,title:`Terminal`,onClick:()=>void S(),children:(0,P.jsx)(te,{className:`w-3.5 h-3.5`})}),w&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`text-red-400 hover:text-red-300`,title:`Interrupt`,onClick:T,children:(0,P.jsx)(ce,{className:`w-3.5 h-3.5`})}),(t.branchState===`changes`||t.branchState===`idle`)&&t.branchWorkspaceId&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex text-amber-400 hover:text-amber-300`,title:`Mark workspace ready — hand off to the auto-merge`,onClick:()=>O(`Mark Workspace Ready`,`Mark ${A(t)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>ie(t.branchWorkspaceId,`ready`)),children:(0,P.jsx)(u,{className:`w-3.5 h-3.5`})}),E&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Compact`,onClick:()=>O(`Compact Agent`,`Compact context for ${A(t)}?`,()=>oe(t,`compact`)),children:(0,P.jsx)(c,{className:`w-3.5 h-3.5`})}),D&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Clear context`,onClick:()=>O(`Clear Context`,`Clear context for ${A(t)}?`,()=>oe(t,`clearContext`)),children:(0,P.jsx)(v,{className:`w-3.5 h-3.5`})}),ee&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Shutdown`,onClick:()=>O(`Shutdown Agent`,`Shutdown ${A(t)}?`,()=>oe(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)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Open ${t.meta.cwd} in Files`,onClick:()=>void se(t),children:(0,P.jsx)(ae,{className:`w-3.5 h-3.5`})}),t&&a&&a.messages.length>0&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Fork — spawn new agent with this chat history`,onClick:()=>le(t.id,a.messages),children:(0,P.jsx)(n,{className:`w-3.5 h-3.5`})}),a&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Mark unread`,onClick:()=>ue(e),children:(0,P.jsx)(de,{className:`w-3.5 h-3.5`})}),a&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Mark read`,onClick:()=>pe(a.peer,a.messages),children:(0,P.jsx)(ne,{className:`w-3.5 h-3.5`})}),l&&(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Export thread`,onClick:()=>me({...l,importedHistory:d},`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)(M,{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:[y&&(0,P.jsxs)(et,{disabled:x,onClick:()=>void S(),children:[(0,P.jsx)(te,{className:`w-3.5 h-3.5`}),`Terminal`]}),w&&(0,P.jsxs)(et,{onClick:T,children:[(0,P.jsx)(ce,{className:`w-3.5 h-3.5`}),`Interrupt`]}),(t.branchState===`changes`||t.branchState===`idle`)&&t.branchWorkspaceId&&(0,P.jsxs)(et,{onClick:()=>O(`Mark Workspace Ready`,`Mark ${A(t)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>ie(t.branchWorkspaceId,`ready`)),children:[(0,P.jsx)(u,{className:`w-3.5 h-3.5`}),`Mark Ready`]}),E&&(0,P.jsxs)(et,{onClick:()=>O(`Compact Agent`,`Compact context for ${A(t)}?`,()=>oe(t,`compact`)),children:[(0,P.jsx)(c,{className:`w-3.5 h-3.5`}),`Compact`]}),D&&(0,P.jsxs)(et,{onClick:()=>O(`Clear Context`,`Clear context for ${A(t)}?`,()=>oe(t,`clearContext`)),children:[(0,P.jsx)(v,{className:`w-3.5 h-3.5`}),`Clear Context`]}),ee&&(0,P.jsxs)(et,{onClick:()=>O(`Shutdown Agent`,`Shutdown ${A(t)}?`,()=>oe(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 se(t),children:[(0,P.jsx)(ae,{className:`w-3.5 h-3.5`}),`Open Files`]}),t&&a&&a.messages.length>0&&(0,P.jsxs)(et,{onClick:()=>le(t.id,a.messages),children:[(0,P.jsx)(n,{className:`w-3.5 h-3.5`}),`Fork`]}),(y||E||D||ee)&&(0,P.jsx)(Ue,{}),a&&(0,P.jsxs)(et,{onClick:()=>ue(e),children:[(0,P.jsx)(de,{className:`w-3.5 h-3.5`}),`Mark Unread`]}),a&&(0,P.jsxs)(et,{onClick:()=>pe(a.peer,a.messages),children:[(0,P.jsx)(ne,{className:`w-3.5 h-3.5`}),`Mark Read`]}),l&&(0,P.jsxs)(et,{onClick:()=>me({...l,importedHistory:d},`json`),children:[(0,P.jsx)(b,{className:`w-3.5 h-3.5`}),`Download`]})]})]})]})})]})}function Gt({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 Kt({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 qt({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)(ue,{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`:St(e.size))})]}),(0,P.jsx)(M,{variant:`ghost`,size:`icon-sm`,title:`Remove attachment`,onClick:t,children:(0,P.jsx)(O,{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)(O,{className:`w-4 h-4`})})]})]})})]})}function Jt({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 D=(0,N.useRef)(null),[ee,te]=(0,N.useState)(!1),O=!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`,ee&&`bg-primary/5 ring-1 ring-primary/40`),onDragOver:e=>{e.preventDefault(),te(!0)},onDragLeave:()=>te(!1),onDrop:e=>{e.preventDefault(),te(!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)(qt,{item:e,onRemove:()=>_(e.id)},e.id))}),(0,P.jsx)(`input`,{ref:D,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&h(e.target.files),e.currentTarget.value=``}}),(0,P.jsx)(Gt,{matches:u,activeIndex:d,onAccept:b,onHover:S}),(0,P.jsxs)(`div`,{className:`hidden md:flex items-end gap-2`,children:[(0,P.jsx)(M,{variant:`ghost`,size:`icon`,title:`Attach files`,disabled:n,onClick:()=>D.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)(Kt,{value:e,onChange:e=>f(e.target.value),onKeyDown:p,onPaste:m,placeholder:t,className:`flex-1`}),c&&(0,P.jsx)(M,{variant:`ghost`,size:`icon`,title:l===`recording`?`Release to transcribe`:`Hold to talk`,disabled:n||l===`transcribing`,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),C()},onPointerUp:e=>{e.preventDefault();try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}w()},className:`shrink-0 mb-0.5 rounded-xl h-[42px] w-[42px] ${l===`recording`?`text-red-400 animate-pulse`:``}`,children:l===`transcribing`?(0,P.jsx)(T,{className:`w-4 h-4 animate-spin`}):(0,P.jsx)(x,{className:`w-4 h-4`})}),(0,P.jsx)(M,{size:`icon`,disabled:O,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)(Kt,{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)(M,{variant:`ghost`,size:`icon`,title:`Attach files`,disabled:n,onClick:()=>D.current?.click(),className:`rounded-xl h-9 w-9`,children:(0,P.jsx)(y,{className:`w-4 h-4`})}),c&&(0,P.jsx)(M,{variant:`ghost`,size:`icon`,title:l===`recording`?`Release to transcribe`:`Hold to talk`,disabled:n||l===`transcribing`,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),C()},onPointerUp:e=>{e.preventDefault();try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}w()},className:`rounded-xl h-9 w-9 ${l===`recording`?`text-red-400 animate-pulse`:``}`,children:l===`transcribing`?(0,P.jsx)(T,{className:`w-4 h-4 animate-spin`}):(0,P.jsx)(x,{className:`w-4 h-4`})})]}),(0,P.jsx)(M,{size:`icon`,disabled:O,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 Yt=e(ge(),1);function Xt({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,Yt.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 Zt=[];function Qt(e){return k(t=>t.chatStatusEvents[e]??Zt)}function $t(e,t){let n=(0,N.useRef)(!1);(0,N.useEffect)(()=>{if(!e)return;n.current||=(window.history.pushState({chatGuard:!0},``),!0);function r(e){(e.state?.chatGuard!==void 0||!n.current)&&(window.history.pushState({chatGuard:!0},``),t())}function i(e){e.preventDefault()}return window.addEventListener(`popstate`,r),window.addEventListener(`beforeunload`,i),()=>{window.removeEventListener(`popstate`,r),window.removeEventListener(`beforeunload`,i)}},[e,t]),(0,N.useEffect)(()=>{!e&&n.current&&(n.current=!1)},[e])}var en=0,tn=1,nn=2,rn=4;function an(e){return()=>e}function on(e){e()}function sn(e,t){return n=>e(t(n))}function cn(e,t){return()=>e(t)}function ln(e,t){return n=>e(t,n)}function un(e){return e!==void 0}function dn(...e){return()=>{e.map(on)}}function fn(){}function pn(e,t){return t(e),e}function mn(e,t){return t(e)}function F(...e){return e}function I(e,t){return e(tn,t)}function L(e,t){e(en,t)}function hn(e){e(nn)}function R(e){return e(rn)}function z(e,t){return I(e,ln(t,en))}function gn(e,t){let n=e(tn,e=>{n(),t(e)});return n}function _n(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function vn(e,t){return e===t}function B(e=vn){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=>sn(t,e)}function yn(e){return t=>()=>{t(e)}}function U(e,...t){let n=Cn(...t);return((t,r)=>{switch(t){case nn:hn(e);return;case tn:return I(e,n(r))}})}function bn(e,t){return n=>r=>{n(t=e(t,r))}}function xn(e){return t=>n=>{e>0?e--:t(n)}}function Sn(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 Cn(...e){return t=>e.reduceRight(mn,t)}function wn(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case tn:return a?n===a?void 0:(r(),n=a,t=I(e,a),t):(r(),fn);case nn:r(),n=null;return}}}function G(e){let t=e,n=K();return((e,r)=>{switch(e){case en:t=r;break;case tn:r(t);break;case rn:return t}return n(e,r)})}function Tn(e,t){return pn(G(t),t=>z(e,t))}function K(){let e=[];return((t,n)=>{switch(t){case en:e.slice().forEach(e=>{e(n)});return;case nn:e.splice(0,e.length);return;case tn:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function En(e){return pn(K(),t=>z(e,t))}function q(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Dn(),singleton:n}}var Dn=()=>Symbol();function On(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 kn(...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 nn:hn(t);return;case tn:return r===i&&a(n),I(t,a)}}}function J(e,t=vn){return U(e,B(t))}function An(...e){return function(t,n){switch(t){case nn:return;case tn:return dn(...e.map(e=>I(e,n)))}}}var jn={DEBUG:0,INFO:1,WARN:2,ERROR:3},Mn={[jn.DEBUG]:`debug`,[jn.ERROR]:`error`,[jn.INFO]:`log`,[jn.WARN]:`warn`},Nn=()=>typeof globalThis>`u`?window:globalThis,Pn=q(()=>{let e=G(jn.ERROR);return{log:G((t,n,r=jn.INFO)=>{r>=(Nn().VIRTUOSO_LOG_LEVEL??R(e))&&console[Mn[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0}),Fn=new WeakMap;function In(e){return`self`in e?e.document.documentElement:e}function Ln(e){let t=In(e),n=Fn.get(t);if(n!==void 0)return n;let r=t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`;return Fn.set(t,r),r}function Rn(e){Fn.delete(In(e))}function zn(e,t){return Ln(e)?-t:t}var Bn=zn;function Vn(e,t){return zn(e,t)}function Hn(e,t,n){return Un(e,t,n).callbackRef}function Un(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 Wn(e,t,n,r,i,a,o,s,c){return Un(N.useCallback(n=>{let c=Gn(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?Bn(o,o.scrollLeft):o.scrollTop:u?s?Bn(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?Bn(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?Kn(`column-gap`,getComputedStyle(n).columnGap,i):Kn(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function Gn(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},jn.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 Kn(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,jn.WARN),t===`normal`?0:parseInt(t??`0`,10)}function qn(e,t,n){let r=N.useRef(null),i=N.useCallback(n=>{if(!n?.offsetParent)return;let i=n.getBoundingClientRect(),a=i.width,s,c;if(t){let e=t.getBoundingClientRect(),n=i.top-e.top;c=e.height-Math.max(0,n),s=n+t.scrollTop}else{let e=o.current.ownerDocument.defaultView;c=e.innerHeight-Math.max(0,i.top),s=i.top+e.scrollY}r.current={listHeight:i.height,offsetTop:s,visibleHeight:c,visibleWidth:a},e(r.current)},[e,t]),{callbackRef:a,ref:o}=Un(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 Jn=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}),Yn={lvl:0};function Xn(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===Yn}function Zn(e,t){if(!Y(e))return t===e.k?e.v:t<e.k?Zn(e.l,t):Zn(e.r,t)}function Qn(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=Qn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Qn(e.l,t,n)}function $n(e,t,n){return Y(e)?ur(t,n,1):t===e.k?or(e,{k:t,v:n}):t<e.k?dr(or(e,{l:$n(e.l,t,n)})):dr(or(e,{r:$n(e.r,t,n)}))}function er(){return Yn}function tr(e,t,n){if(Y(e))return[];let r=Qn(e,t)[0];return mr(ir(e,r,n))}function nr(e,t){if(Y(e))return Yn;let{k:n,l:r,r:i}=e;if(t===n){if(Y(r))return i;if(Y(i))return r;let[t,n]=lr(r);return ar(or(e,{k:t,l:sr(r),v:n}))}return ar(t<n?or(e,{l:nr(r,t)}):or(e,{r:nr(i,t)}))}function rr(e){return Y(e)?[]:[...rr(e.l),{k:e.k,v:e.v},...rr(e.r)]}function ir(e,t,n){if(Y(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(ir(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(ir(a,t,n))),s}function ar(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(cr(t))return fr(or(e,{lvl:n-1}));if(!Y(t)&&!Y(t.r))return or(t.r,{l:or(t,{r:t.r.l}),lvl:n,r:or(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(cr(e))return pr(or(e,{lvl:n-1}));if(!Y(r)&&!Y(r.l)){let t=r.l,i=cr(t)?r.lvl-1:r.lvl;return or(t,{l:or(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:pr(or(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function or(e,t){return ur(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 sr(e){return Y(e.r)?e.l:ar(or(e,{r:sr(e.r)}))}function cr(e){return Y(e)||e.lvl>e.r.lvl}function lr(e){return Y(e.r)?[e.k,e.v]:lr(e.r)}function ur(e,t,n,r=Yn,i=Yn){return{k:e,l:r,lvl:n,r:i,v:t}}function dr(e){return pr(fr(e))}function fr(e){let{l:t}=e;return!Y(t)&&t.lvl===e.lvl?or(t,{r:or(e,{l:t.r})}):e}function pr(e){let{lvl:t,r:n}=e;return!Y(n)&&!Y(n.r)&&n.lvl===t&&n.r.lvl===t?or(n,{l:or(e,{r:n.l}),lvl:t+1}):e}function mr(e){return Xn(e,({k:e,v:t})=>({index:e,value:t}))}function hr(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function gr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var _r=q(()=>({recalcInProgress:G(!1)}),[],{singleton:!0});function vr(e,t,n){return e[yr(e,t,n)]}function yr(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 br(e,t,n,r){let i=yr(e,t,r),a=yr(e,n,r,i);return e.slice(i,a+1)}function xr(e,t){return Math.round(e.getBoundingClientRect()[t])}function Sr(e){return!Y(e.groupOffsetTree)}function Cr({index:e},t){return t===e?0:t<e?-1:1}function wr(){return{groupIndices:[],groupOffsetTree:er(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:er()}}function Tr(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=$n(e,0,i);continue}let o=tr(e,a-1,t+1);if(o.some(Lr(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=nr(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=$n(e,t+1,a));c&&(e=$n(e,a,i))}return[e,n]}function Er(e){return typeof e.groupIndex<`u`}function Dr({offset:e},t){return t===e?0:t<e?-1:1}function Or(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=vr(t,e,Cr),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function kr(e,t){if(!Sr(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Ar(e,t,n){if(Er(e))return t.groupIndices[e.groupIndex]+1;let r=kr(e.index===`LAST`?n:e.index,t);return r=Math.max(0,r,Math.min(n,r)),r}function jr(e,t,n,r=0){return r>0&&(t=Math.max(t,vr(e,r,Cr).offset)),Xn(br(e,t,n,Dr),Ir)}function Mr(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,jn.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)=>$n($n(t,n,e),n+1,r),o)}else [o,s]=Tr(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=Fr(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>$n(e,t,Or(t,d,i)),er()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function Nr(e){return rr(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 Pr(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 Fr(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t!==0){c=yr(i,t-1,Cr),s=i[c].offset;let e=Qn(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===Qn(n,t)[1]&&--c,i=i.slice(0,c+1)}else i=[];for(let{start:e,value:c}of tr(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 Ir(e){return{index:e.index,value:e}}function Lr(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 Rr={offsetHeight:`height`,offsetWidth:`width`},zr=q(([{log:e},{recalcInProgress:t}])=>{let n=K(),r=K(),i=Tn(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)=>xr(e,Rr[t])),m=G(void 0),h=G(0),g=wr(),_=Tn(U(n,W(c,e,h),bn(Mr,g),B()),g),v=Tn(U(c,B(),bn((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)=>$n(e,r,Or(r,t.offsetTree,n)||i),er());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=Tn(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=En(U(n,W(_),bn(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),H(e=>e.changed)));I(U(s,bn((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+Pr(e,n));else if(e<0){let t=R(v);t.length>0&&(e-=Pr(-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},jn.ERROR)});let x=En(a);z(U(a,W(_),H(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=Zn(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=rr(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 rr(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=En(U(o,W(_,h),H(([e,{offsetTree:t},n])=>Or(-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=er(),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=rr(t.sizeTree).reduce((t,{k:n,v:r})=>$n(t,Math.max(0,n+e),r),r),a!==-e){let n=Zn(t.sizeTree,s);r=$n(r,0,n);let i=Qn(t.sizeTree,-e+1)[1];r=$n(r,1,i)}return{...t,sizeTree:r,...Fr(t.offsetTree,0,r,n)}}let r=rr(t.sizeTree).reduce((t,{k:n,v:r})=>$n(t,Math.max(0,n+e),r),er());return{...t,sizeTree:r,...Fr(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(Pn,_r),{singleton:!0});function Br(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var Vr=q(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=K(),o=K(),s=En(U(a,H(Br)));return z(U(s,H(e=>e.totalCount)),n),z(U(s,H(e=>e.groupIndices)),e),z(U(kn(i,t,r),V(([e,t])=>Sr(t)),H(([e,t,n])=>Qn(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),B(),H(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},F(zr,Jn)),Hr=q(([{log:e}])=>{let t=G(!1),n=En(U(t,V(e=>e),B()));return I(t,t=>{t&&R(e)(`props updated`,{},jn.DEBUG)}),{didMount:n,propsReady:t}},F(Pn),{singleton:!0}),Ur=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function Wr(e){let t=typeof e==`number`?{index:e}:e;return t.align||=`start`,(!t.behavior||!Ur)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var Gr=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=Wr(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=Ar(b,n,w),E=Or(T,n.offsetTree,d)+o;x===`end`?(E+=f+Qn(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+Qn(n.sizeTree,T)[1]-r+h)/2:E-=a,C!==void 0&&C!==0&&(E+=C);let D=t=>{y(),t?(l(`retrying to scroll to`,{location:e},jn.DEBUG),L(p,e)):(L(m,!0),l(`list did not change, scroll successful`,{},jn.DEBUG))};if(y(),S===`smooth`){let e=!1;v=I(t,t=>{e||=t}),g=gn(u,()=>{D(e)})}else g=gn(U(t,Kr(150)),D);return _=setTimeout(()=>{y()},1200),L(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},jn.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},F(zr,Jn,Pn),{singleton:!0});function Kr(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function qr(e,t){e===0?t():requestAnimationFrame(()=>{qr(e-1,t)})}function Jr(e,t){let n=t-1;return typeof e==`number`?e:e.index===`LAST`?n:e.index}var Yr=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),yn(!1)),s),z(U(o,W(c),V(([e,t])=>t!==0),yn(!1)),l),I(U(kn(t,o),W(s,n,e,l),V(([[,e],t,{sizeTree:n},r,i])=>e&&(!Y(n)||un(r))&&!t&&!i),W(c)),([,e])=>{gn(i,()=>{L(l,!0)}),qr(4,()=>{gn(r,()=>{L(s,!0)}),L(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},F(zr,Jn,Gr,Hr),{singleton:!0});function Xr(e,t){return Math.abs(e-t)<1.01}var Zr=`up`,Qr=`down`,$r=`none`,ei={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ti=0,ni=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(ti),f=Tn(U(An(U(J(i),xn(1),yn(!0)),U(J(i),xn(1),yn(!1),_n(100))),B()),!1),p=Tn(U(An(U(n,yn(!0)),U(n,yn(!1),_n(200))),B()),!1);z(U(kn(J(i),J(d)),H(([e,t])=>e<=t),B()),s),z(U(s,Sn(50)),l);let m=En(U(kn(r,J(a),J(t),J(e),J(u)),bn((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}},ei),B((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=Tn(U(r,bn((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!Xr(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,Sn(50)),c);let g=G(Qr);z(U(r,H(({scrollTop:e})=>e),B(),bn((e,t)=>R(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?Zr:Qr,prevScrollTop:t},{direction:Qr,prevScrollTop:0}),H(e=>e.direction)),g),z(U(r,Sn(50),yn($r)),g);let _=G(0);return z(U(f,V(e=>!e),yn(0)),_),z(U(i,Sn(100),W(f),V(([e,t])=>t),bn(([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(Jn)),ri=`top`,ii=`bottom`,ai=`none`;function oi(e,t,n){return typeof e==`number`?n===Zr&&t===ri||n===Qr&&t===ii?e:0:n===Zr?t===ri?e.main:e.reverse:t===ii?e.main:e.reverse}function si(e,t){return typeof e==`number`?e:e[t]??0}var ci=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:Tn(U(kn(J(r),J(i),J(n),J(a,gr),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=ai,m=si(l,ri),h=si(l,ii);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=Zr),i<e-f+t+h&&(p=Qr),p===ai?null:[Math.max(u-n-oi(a,ri,p)-m,0),u-f-s+t+oi(a,ii,p)+h]}),V(e=>e!==null),B(gr)),[0,0])}},F(Jn),{singleton:!0});function li(e,t,n){if(Sr(t)){let r=kr(e,t);return[{index:Qn(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 ui={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function di(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:pi(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:pi(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function fi(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=Jr(t,s);return di(Array.from({length:s}).map((e,t)=>({data:a[t+c],index:t+c,offset:0,size:0})),[],s,i,n,r)}function pi(e,t,n){if(e.length===0)return[];if(!Sr(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=tr(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 mi(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var hi=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=Tn(U(kn(p,m,J(c,gr),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{...ui,totalCount:n};if(e===0&&t===0)return m===0?{...ui,totalCount:n}:fi(m,i,r,s,c,u||[]);if(Y(p))return m>0?null:di(li(Jr(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 tr(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 di([],h,n,c,d,s);let _=o.length>0?o[o.length-1]+1:0,v=jr(f,e,t,_);if(v.length===0)return null;let y=n-1,b=pn([],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=mi(l,ri),S=mi(l,ii);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=tr(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=tr(p,r,r)[0]?.value??t.size;b.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return di(b,h,n,c,d,s)}),V(e=>e!==null),B()),ui);z(U(e,V(un),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=En(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(gr),H(([e])=>e))),x=En(U(y,Sn(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:En(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(hr))),startReached:x,topItemsIndexes:h,...f}},F(zr,Vr,ci,Yr,Gr,ni,Hr,_r),{singleton:!0}),gi=q(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=K(),o=Tn(U(kn(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(Jn,hi),{singleton:!0}),_i=q(([{viewportHeight:e},{totalListHeight:t}])=>{let n=G(!1);return{alignToBottom:n,paddingTopAddition:Tn(U(kn(n,e,t),V(([e])=>e),H(([,e,t])=>Math.max(0,e-t)),Sn(0),B()),0)}},F(Jn,gi),{singleton:!0}),vi=q(()=>({context:G(null)})),yi=({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,bi=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=yi,done:d,...f}=e,p=Ar(e,t,r-1),m=Or(p,t.offsetTree,l)+i+a,h=m+Qn(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&gn(U(o,V(e=>!e),xn(R(o)?1:2)),d),_}),V(e=>e!==null)),l),{scrollIntoView:u}},F(zr,Jn,Gr,hi,Pn),{singleton:!0});function xi(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var Si=(e,t)=>typeof e==`function`?xi(e(t)):t&&xi(e),Ci=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(kn(U(J(t),xn(1)),c),W(J(m),a,s,d),H(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=Si(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=gn(e,()=>{R(u)(`following output to `,{totalCount:r},jn.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{R(u)(`following output to `,{totalCount:r},jn.DEBUG),_(t)})});function v(e){let t=gn(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(R(u)(`scrolling to bottom due to increased size`,{},jn.DEBUG),_(`auto`))});setTimeout(t,100)}I(U(kn(J(m),t,l),V(([e,,t])=>e!==!1&&t),bn(({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(kn(J(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=G(null),b=K();return z(An(U(J(r),H(e=>e?.length??0)),U(J(t))),b),I(U(kn(U(b,xn(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),Sn(0)),t=>{g!==null&&(g(),g=null),R(n)===void 0?g=gn(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(zr,ni,Gr,Yr,Hr,Pn,Jn,vi,bi)),wi=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=[]])=>fi(e,t,n,r,i,a))),o),{}),F(zr,Yr,hi,Hr),{singleton:!0}),Ti=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=>{gn(U(n,xn(1),V(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{L(t,e)})})}),{initialScrollTop:r}},F(Hr,Jn,hi),{singleton:!0}),Ei=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(kn(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(ni),{singleton:!0}),Di=q(([{scrollContainerState:e,scrollTo:t}])=>{let n=K(),r=K(),i=K(),a=G(!1),o=G(void 0);return z(U(kn(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(Jn)),Oi=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=Nr(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),z(U(u,V(un),H(ki)),i),z(U(a,W(u),V(([,e])=>e!==void 0),B(),H(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},F(zr,Jn,Yr,Hr,Di));function ki(e){return{align:`start`,index:0,offset:e.scrollTop}}var Ai=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(hi));function ji(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var Mi=ji(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Ni=q(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:i,gap:a,groupIndices:o,heightEstimates:s,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g},_,v,y,b,{scrollToIndex:x},S,{topItemCount:C},{groupCounts:w},T])=>{let{listState:E,minOverscanItemCount:D,topItemsIndexes:ee,rangeChanged:te,...O}=b;return z(te,T.scrollSeekRangeChanged),z(U(T.windowViewportRect,H(e=>e.visibleHeight)),_.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:i,gap:a,groupCounts:w,heightEstimates:s,initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g,sizeRanges:l,topItemCount:C,topItemsIndexes:ee,totalCount:f,...y,groupIndices:o,itemSize:c,listState:E,minOverscanItemCount:D,scrollToIndex:x,statefulTotalCount:d,trackItemSizes:p,rangeChanged:te,...O,...T,..._,sizes:u,...v}},F(zr,Yr,Jn,Oi,Ci,hi,Gr,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=En(U(c,W(o),bn(([,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===Zr),H(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},jn.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&&Mi()?L(e,n-t):g(-t)}),I(U(kn(Tn(a,!1),e,m),V(([e,t,n])=>!e&&!n&&t!==0),H(([e,t])=>t),Sn(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=Zn(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(Jn,ni,hi,zr,Pn,_r)),Ai,Vr,q(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),F(ci,wi,Hr,Ei,gi,Ti,_i,Di,bi,Pn,vi))));function Pi(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 Fi=typeof document<`u`?N.useLayoutEffect:N.useEffect;function Ii(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]=wn(e[t.events[r]]),n),{})}return{Component:N.forwardRef(function(t,a){let{children:d,...f}=t,[p]=N.useState(()=>pn(On(e),e=>{c(e,f)})),[m]=N.useState(cn(u,p));Fi(()=>{for(let e of o)e in f&&I(m[e],f[e]);return()=>{Object.values(m).map(hn)}},[f,m,p]),Fi(()=>{c(p,f)}),N.useImperativeHandle(a,an(l(p)));let h=n;return(0,P.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,P.jsx)(h,{...Pi([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=N.useContext(s)[e];Fi(()=>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 Li=N.createContext(void 0),Ri=N.createContext(void 0),zi=`-webkit-sticky`,Bi=`sticky`,Vi=ji(()=>{if(typeof document>`u`)return Bi;let e=document.createElement(`div`);return e.style.position=zi,e.style.position===zi?zi:Bi}),Hi=typeof document<`u`?N.useLayoutEffect:N.useEffect;function Ui(e){return`self`in e}function Wi(e){return`body`in e}function Gi(e,t,n,r=fn,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(Wi(l)||Ui(l)){let e=Ui(l)?l:l.defaultView;o=a===!0?Bn(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?Bn(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():Yt.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 Rn(e),r(i||o.current),l({suppressFlushSync:!0,target:e}),e.addEventListener(`scroll`,l,{passive:!0}),()=>{Rn(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;Ui(r)?(u=Math.max(xr(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?Bn(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=xr(r,a===!0?`width`:`height`),d=a===!0?Bn(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,Xr(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:Vn(r,p)}),r.scrollTo(n)}function d(e){a===!0&&(e={...e.behavior===void 0?{}:{behavior:e.behavior},...e.top===void 0?{}:{left:Vn(o.current,e.top)}}),o.current.scrollBy(e)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}function Ki(e){return e}var qi=q(([e,t])=>({...e,...t}),F(Ni,q(()=>{let e=G(e=>`Item ${e}`),t=G(e=>`Group ${e}`),n=G({}),r=G(Ki),i=G(`div`),a=G(fn),o=(e,t=null)=>Tn(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`)}}))),Ji=({height:e})=>(0,P.jsx)(`div`,{style:{height:e}}),Yi={overflowAnchor:`none`,position:Vi(),zIndex:1},Xi={overflowAnchor:`none`},Zi={...Xi,display:`inline-block`,height:`100%`},Qi=N.memo(function({showTopList:e=!1}){let t=Z(`listState`),n=ma(`sizeRanges`),r=Z(`useWindowScroll`),i=Z(`customScrollParent`),a=ma(`windowScrollContainerState`),o=ma(`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=ma(`gap`),h=Z(`horizontalDirection`),{callbackRef:g}=Wn(n,f,d,e?fn:s,p,m,i,h,Z(`skipAnimationFrameInResizeObserver`)),[_,v]=N.useState(0);pa(`deviation`,e=>{_!==e&&v(e)});let y=Z(`EmptyPlaceholder`),b=Z(`ScrollSeekPlaceholder`)??Ji,x=Z(`ListComponent`),S=Z(`ItemComponent`),C=Z(`GroupComponent`),w=Z(`computeItemKey`),T=Z(`isSeeking`),E=Z(`groupIndices`).length>0,D=Z(`alignToBottom`),ee=Z(`initialItemFinalLocationReached`),te=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginInlineStart:_===0?D?`auto`:0:_,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:`nowrap`}:{marginTop:_===0?D?`auto`:0:_,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...ee?{}:{visibility:`hidden`}};return!e&&t.totalCount===0&&y!=null?(0,P.jsx)(y,{...X(y,l)}):(0,P.jsx)(x,{...X(x,l),"data-testid":e?`virtuoso-top-item-list`:`virtuoso-item-list`,ref:g,style:te,children:(e?t.topItems:t.items).map(e=>{let n=e.originalIndex,r=w(n+t.firstItemIndex,e.data,l);return T?(0,N.createElement)(b,{...X(b,l),height:e.size,index:e.index,key:r,type:e.type||`item`,...e.type===`group`?{}:{groupIndex:e.groupIndex}}):e.type===`group`?(0,N.createElement)(C,{...X(C,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:Yi},u(e.index,l)):(0,N.createElement)(S,{...X(S,l),...ia(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?Zi:Xi},E?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),$i={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},ea={outline:`none`,overflowX:`auto`,position:`relative`},ta=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),na=(e,t,n=0)=>({...ta(e),position:t?`relative`:`absolute`,top:t?-n:0}),ra={position:Vi(),top:0,width:`100%`,zIndex:1};function X(e,t){if(typeof e!=`string`)return{context:t}}function ia(e,t){return{item:typeof e==`string`?void 0:t}}var aa=N.memo(function(){let e=Z(`HeaderComponent`),t=ma(`headerHeight`),n=Z(`HeaderFooterTag`),r=Hn(N.useMemo(()=>e=>{t(xr(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)})})}),oa=N.memo(function(){let e=Z(`FooterComponent`),t=ma(`footerHeight`),n=Z(`HeaderFooterTag`),r=Hn(N.useMemo(()=>e=>{t(xr(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 sa({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}=Gi(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?ea:$i,...i},tabIndex:0,...o,...X(c,a),children:r})})}function ca({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}=Gi(s,l,c,t(`scrollerRef`),f);return Hi(()=>(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 la=({children:e})=>{let t=N.useContext(Li),n=ma(`viewportHeight`),r=ma(`fixedItemHeight`),i=Z(`alignToBottom`),a=Z(`horizontalDirection`),o=Hn(N.useMemo(()=>sn(n,e=>xr(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:ta(i),children:e})},ua=({children:e})=>{let t=N.useContext(Li),n=ma(`windowViewportRect`),r=ma(`fixedItemHeight`),i=Z(`customScrollParent`),a=Z(`useWindowScroll`),o=Z(`topListHeight`),s=qn(n,i,Z(`skipAnimationFrameInResizeObserver`)),c=Z(`alignToBottom`);return N.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,P.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:na(c,a,o),children:e})},da=({children:e})=>{let t=Z(`TopItemListComponent`)??`div`,n=Z(`headerHeight`);return(0,P.jsx)(t,{style:{...ra,marginTop:`${n}px`},...X(t,Z(`context`)),children:e})},{Component:fa,useEmitter:pa,useEmitterValue:Z,usePublisher:ma}=Ii(qi,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,scrollIntoViewOnChange:`scrollIntoViewOnChange`,itemContent:`itemContent`,groupContent:`groupContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,groupCounts:`groupCounts`,topItemCount:`topItemCount`,firstItemIndex:`firstItemIndex`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,heightEstimates:`heightEstimates`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`HeaderFooterTag`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,horizontalDirection:`horizontalDirection`,skipAnimationFrameInResizeObserver:`skipAnimationFrameInResizeObserver`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,autoscrollToBottom:`autoscrollToBottom`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},N.memo(function(e){let t=Z(`useWindowScroll`),n=Z(`topItemsIndexes`).length>0,r=Z(`customScrollParent`),i=Z(`context`);return(0,P.jsxs)(r||t?ga:ha,{...e,context:i,children:[n&&(0,P.jsx)(da,{children:(0,P.jsx)(Qi,{showTopList:!0})}),(0,P.jsxs)(r||t?ua:la,{children:[(0,P.jsx)(aa,{}),(0,P.jsx)(Qi,{}),(0,P.jsx)(oa,{})]})]})})),ha=sa({useEmitter:pa,useEmitterValue:Z,usePublisher:ma}),ga=ca({useEmitter:pa,useEmitterValue:Z,usePublisher:ma}),_a=fa,va=q(([e,t])=>({...e,...t}),F(Ni,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(Ki),s=G(fn),c=(e,t=null)=>Tn(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`)}}))),ya=({height:e})=>(0,P.jsx)(`tr`,{children:(0,P.jsx)(`td`,{style:{height:e}})}),ba=({height:e})=>(0,P.jsx)(`tr`,{children:(0,P.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),xa={overflowAnchor:`none`},Sa={position:Vi(),zIndex:2,overflowAnchor:`none`},Ca=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`)??ya,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:{...Sa,top:o}},l(t.index,i)):(0,N.createElement)(f,{...X(f,i),...ia(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?{...Sa,top:o+g}:xa},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),wa=N.memo(function(){let e=Q(`listState`),t=Q(`topItemsIndexes`).length>0,n=ka(`sizeRanges`),r=Q(`useWindowScroll`),i=Q(`customScrollParent`),a=ka(`windowScrollContainerState`),o=ka(`scrollContainerState`),s=i||r?a:o,c=Q(`trackItemSizes`),{callbackRef:l,ref:u}=Wn(n,Q(`itemSize`),c,s,Q(`log`),void 0,i,!1,Q(`skipAnimationFrameInResizeObserver`)),[d,f]=N.useState(0);Oa(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=Q(`EmptyPlaceholder`),m=Q(`FillerRow`)??ba,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)(Ca,{showTopList:!0}),(0,P.jsx)(Ca,{}),C]})}),Ta=({children:e})=>{let t=N.useContext(Li),n=ka(`viewportHeight`),r=ka(`fixedItemHeight`),i=Hn(N.useMemo(()=>sn(n,e=>xr(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:ta(!1),children:e})},Ea=({children:e})=>{let t=N.useContext(Li),n=ka(`windowViewportRect`),r=ka(`fixedItemHeight`),i=Q(`customScrollParent`),a=Q(`useWindowScroll`),o=qn(n,i,Q(`skipAnimationFrameInResizeObserver`));return N.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,P.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:na(!1,a),children:e})},{Component:Da,useEmitter:Oa,useEmitterValue:Q,usePublisher:ka}=Ii(va,{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=ka(`fixedHeaderHeight`),i=ka(`fixedFooterHeight`),a=Q(`fixedHeaderContent`),o=Q(`fixedFooterContent`),s=Q(`context`),c=Hn(N.useMemo(()=>sn(r,e=>xr(e,`height`)),[r]),!0,Q(`skipAnimationFrameInResizeObserver`)),l=Hn(N.useMemo(()=>sn(i,e=>xr(e,`height`)),[i]),!0,Q(`skipAnimationFrameInResizeObserver`)),u=n||t?ja:Aa,d=n||t?Ea:Ta,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)(wa,{},`TableBody`),g]})})})})),Aa=sa({useEmitter:Oa,useEmitterValue:Q,usePublisher:ka}),ja=ca({useEmitter:Oa,useEmitterValue:Q,usePublisher:ka}),Ma={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Na={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Pa,floor:Fa,max:Ia,min:La,round:Ra}=Math;function za(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function Ba(e){return{...Na,items:e}}function Va(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function Ha(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var Ua=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(Ma),T=G({height:0,width:0}),E=G({height:0,width:0}),D=K(),ee=K(),te=G(0),O=G(null),ne=G({column:0,row:0}),re=K(),ie=K(),ae=G(!1),oe=G(0),se=G(!0),ce=G(!1),le=G(!1);I(U(m,W(oe),V(([e,t])=>t!==0)),()=>{L(se,!1)}),I(U(kn(m,se,E,T,oe,ce),V(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{L(ce,!0),qr(1,()=>{L(D,e)}),gn(U(l),()=>{L(t,[0,0]),L(se,!0)})}),z(U(ie,V(e=>e!=null&&e.scrollTop>0),yn(0)),C),I(U(m,W(ie),V(([,e])=>e!=null)),([,e])=>{e&&(L(T,e.viewport),L(E,e.item),L(ne,e.gap),e.scrollTop>0&&(L(ae,!0),gn(U(l,xn(1)),e=>{L(ae,!1)}),L(c,{top:e.scrollTop})))}),z(U(T,H(({height:e})=>e)),d),z(U(kn(J(T,Va),J(E,Va),J(ne,(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}))),re),z(U(kn(J(S),r,J(ne,Ha),J(E,Va),J(T,Va),J(O),J(C),J(ae),J(se),J(oe)),V(([,,,,,,,e])=>!e),H(([e,[t,n],r,i,a,o,s,,c,l])=>{let{column:u,row:d}=r,{height:f,width:p}=i,{width:m}=a;if(s===0&&(e===0||m===0))return Ma;if(p===0){let t=Jr(l,e);return Ba(za(t,t+Math.max(s-1,0),o))}let h=Wa(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*Fa((t+d)/(f+d)),_=h*Pa((n+d)/(f+d))-1,_=La(e-1,Ia(_,h-1)),g=La(_,Ia(0,g))):(g=0,_=-1);let v=za(g,_,o),{bottom:y,top:b}=Ga(a,r,i,v),x=Pa(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(O,V(e=>e!==null),H(e=>e.length)),S),z(U(kn(T,E,w,ne),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}=Ga(e,r,t,n);return[a,i]}),B(gr)),t);let ue=G(!1);z(U(l,W(ue),H(([e,t])=>t||e!==0)),ue);let de=En(U(kn(w,S),V(([{items:e}])=>e.length>0),W(ue),V(([[e,t],n])=>{let r=e.items[e.items.length-1].index===t-1;return(n||e.bottom>0&&e.itemHeight>0&&e.offsetBottom===0&&e.items.length===t)&&r}),H(([[,e]])=>e-1),B())),fe=En(U(J(w),V(({items:e})=>e.length>0&&e[0].index===0),yn(0),B())),pe=En(U(J(w),W(ae),V(([{items:e},t])=>e.length>0&&!t),H(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),B(hr),Sn(0)));z(pe,p.scrollSeekRangeChanged),z(U(D,W(T,E,S,ne),H(([e,t,n,r,i])=>{let a=Wr(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=Ia(0,l,La(r-1,l));let u=Ka(t,i,n,l);return o===`end`?u=Ra(u-t.height+n.height):o===`center`&&(u=Ra(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let me=Tn(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:O,deviation:te,footerHeight:i,gap:ne,headerHeight:a,increaseViewportBy:e,initialItemCount:C,itemDimensions:E,overscan:n,restoreStateFrom:ie,scrollBy:o,scrollContainerState:s,scrollHeight:ee,scrollTo:c,scrollToIndex:D,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:_,viewportDimensions:T,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b,...p,gridState:w,horizontalDirection:le,initialTopMostItemIndex:oe,totalListHeight:me,...f,endReached:de,propsReady:h,rangeChanged:pe,startReached:fe,stateChanged:re,stateRestoreInProgress:ae,...x}},F(ci,Jn,ni,Ei,Hr,Di,Pn));function Wa(e,t,n){return Ia(1,Fa((e+n)/(Fa(t)+n)))}function Ga(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=Ka(e,t,n,r[0].index);return{bottom:Ka(e,t,n,r[r.length-1].index)+i,top:a}}function Ka(e,t,n,r){let i=Fa(r/Wa(e.width,n.width,t.column)),a=i*n.height+Ia(0,i-1)*t.row;return a>0?a+t.row:a}var qa=q(([e,t])=>({...e,...t}),F(Ua,q(()=>{let e=G(e=>`Item ${e}`),t=G({}),n=G(null),r=G(`virtuoso-grid-item`),i=G(`virtuoso-grid-list`),a=G(Ki),o=G(`div`),s=G(fn),c=(e,n=null)=>Tn(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`)}}))),Ja=N.memo(function(){let e=$(`gridState`),t=$(`listClassName`),n=$(`itemClassName`),r=$(`itemContent`),i=$(`computeItemKey`),a=$(`isSeeking`),o=to(`scrollHeight`),s=$(`ItemComponent`),c=$(`ListComponent`),l=$(`ScrollSeekPlaceholder`),u=$(`context`),d=to(`itemDimensions`),f=to(`gap`),p=$(`log`),m=$(`stateRestoreInProgress`),h=to(`reportReadyState`),g=Hn(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:io(`column-gap`,getComputedStyle(e).columnGap,p),row:io(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return Hi(()=>{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))})})}),Ya=N.memo(function(){let e=$(`HeaderComponent`),t=to(`headerHeight`),n=$(`headerFooterTag`),r=Hn(N.useMemo(()=>e=>{t(xr(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)})})}),Xa=N.memo(function(){let e=$(`FooterComponent`),t=to(`footerHeight`),n=$(`headerFooterTag`),r=Hn(N.useMemo(()=>e=>{t(xr(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)})})}),Za=({children:e})=>{let t=N.useContext(Ri),n=to(`itemDimensions`),r=to(`viewportDimensions`),i=Hn(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:ta(!1),children:e})},Qa=({children:e})=>{let t=N.useContext(Ri),n=to(`windowViewportRect`),r=to(`itemDimensions`),i=$(`customScrollParent`),a=$(`useWindowScroll`),o=qn(n,i,!1);return N.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),(0,P.jsx)(`div`,{ref:o,style:na(!1,a),children:e})},{Component:$a,useEmitter:eo,useEmitterValue:$,usePublisher:to}=Ii(qa,{optional:{context:`context`,totalCount:`totalCount`,overscan:`overscan`,itemContent:`itemContent`,components:`components`,computeItemKey:`computeItemKey`,data:`data`,initialItemCount:`initialItemCount`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`headerFooterTag`,listClassName:`listClassName`,itemClassName:`itemClassName`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,restoreStateFrom:`restoreStateFrom`,initialTopMostItemIndex:`initialTopMostItemIndex`,increaseViewportBy:`increaseViewportBy`},methods:{scrollTo:`scrollTo`,scrollBy:`scrollBy`,scrollToIndex:`scrollToIndex`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,stateChanged:`stateChanged`,readyStateChanged:`readyStateChanged`}},N.memo(function({...e}){let t=$(`useWindowScroll`),n=$(`customScrollParent`),r=n||t?ro:no,i=n||t?Qa:Za,a=$(`context`);return(0,P.jsx)(r,{...e,...X(r,a),children:(0,P.jsxs)(i,{children:[(0,P.jsx)(Ya,{}),(0,P.jsx)(Ja,{}),(0,P.jsx)(Xa,{})]})})})),no=sa({useEmitter:eo,useEmitterValue:$,usePublisher:to}),ro=ca({useEmitter:eo,useEmitterValue:$,usePublisher:to});function io(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,jn.WARN),t===`normal`?0:parseInt(t??`0`,10)}function ao({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)(co,{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)(se,{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)(M,{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 oo(e){return e?e.otherActive&&e.other.trim()?!0:e.labels.length>0:!1}function so(e){let t=[...e.labels];return e.otherActive&&e.other.trim()&&t.push(e.other.trim()),t.join(`, `)}function co({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=oo(d),_=n.every((e,t)=>oo(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]=so(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)(D,{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)(Ie,{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)(le,{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)(le,{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)(M,{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)(M,{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)(M,{size:`sm`,disabled:v||!h,onClick:()=>a(e=>e+1),className:`h-7 px-2 text-xs`,children:[`Next`,(0,P.jsx)(pe,{className:`ml-1 h-3 w-3`})]}),(0,P.jsxs)(M,{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 lo=1e6,uo=new Map,fo=`px-3 md:px-4`;function po({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:`${fo} pb-3 md:pb-4`,children:[r&&(0,P.jsx)(ao,{agentId:t,approval:r},r.id),s&&(0,P.jsx)(_t,{blockedLabel:i,onInterrupt:a?o:void 0})]})}function mo(e){return e.type===`message`?`msg-${e.msg.id}`:e.type===`initial-prompt`?`initprompt-${e.msg.id}`:e.type===`notice`?`notice-${e.msg.id}`:e.type===`agent-action`?`agent-action-${e.direction}-${e.agentId}`:e.type===`activity`?`act-${e.steps[0]?.id??e.timestamp}`:e.type===`import-boundary`?`import-${e.history.id}`:e.type===`imported-message`?`import-msg-${e.history.id}-${e.entry.originalMessageId}-${e.entry.position}`:e.type===`status`?`status-${e.event.id}`:e.type===`date`?`date-${e.date}`:`created-${e.timestamp}`}function ho(e){let t=e.findIndex(e=>e.type!==`date`&&e.type!==`created`),n=t>=0?t:0,r=e[n];return{key:r?mo(r):null,index:n}}function go(e,t){let[n,r]=(0,N.useState)(()=>lo-t.length),i=(0,N.useRef)({agentId:e,anchor:ho(t)});return(0,N.useLayoutEffect)(()=>{let n=ho(t),a=i.current;r(n=>{if(a.agentId!==e)return lo-t.length;if(!a.anchor.key)return n;let r=t.findIndex(e=>mo(e)===a.anchor.key)-a.anchor.index;return r>0?n-r:n}),i.current={agentId:e,anchor:n}},[e,t]),n}function _o({agentId:e,agentStatus:t,timeline:n,hasMore:r,loading:a,loadedInitial:o,showReasoning:s,pendingApproval:c,blockedLabel:l,canInterrupt:u,onAtBottomChange:d,onLoadOlder:f,onInterrupt:p,onOpenReferencedPath:m,onPreviewReferencedPath:h,onPreviewReferencedPathEnd:g}){let _=(0,N.useRef)(null),v=(0,N.useRef)(null),[y,b]=(0,N.useState)(!0),x=t===`busy`,[C,w]=(0,N.useState)(x);(0,N.useLayoutEffect)(()=>{if(x){w(!0);return}let e=setTimeout(()=>w(!1),600);return()=>clearTimeout(e)},[x]);let E=go(e,n),D=n.length>0?n[n.length-1]:null,ee=D?mo(D):null,te=D?.type===`message`&&D.msg.from===`user`,O=(0,N.useRef)(n);O.current=n;let ne=(0,N.useRef)(E);ne.current=E;let re=(0,N.useRef)(null),ie=(0,N.useCallback)(e=>{let t=e.startIndex-ne.current,n=O.current[t];re.current=n?mo(n):null},[]),ae=(0,N.useRef)(null);if(ae.current===null){let t=uo.get(e),r=-1;t&&!t.stick&&t.topKey&&(r=n.findIndex(e=>mo(e)===t.topKey)),ae.current=r>=0?r:Math.max(0,n.length-1)}let oe=(0,N.useRef)(ee),se=(0,N.useRef)(e);se.current!==e&&(se.current=e,oe.current=ee);let ce=oe.current?n.findIndex(e=>mo(e)===oe.current):-1,le=!y&&ce>=0?n.slice(ce+1).filter(e=>e.type===`message`&&e.msg.from!==`user`).length:0;(0,N.useLayoutEffect)(()=>{y&&(oe.current=ee)},[y,ee]);let ue=(0,N.useRef)(y);ue.current=y;let de=(0,N.useRef)(uo.get(e)?.stick??!0),fe=(0,N.useRef)(!1),pe=(0,N.useRef)(0),me=(0,N.useRef)(0),he=(0,N.useCallback)(()=>{me.current=performance.now()+150},[]),ge=(0,N.useCallback)(()=>{he(),_.current?.scrollToIndex({index:`LAST`,align:`end`});let e=performance.now(),t=0,n=!1,r=!1,i=()=>{if(n)return;let a=v.current;if(a){let e=a.scrollHeight-a.clientHeight-a.scrollTop,t=a.scrollHeight-a.clientHeight>64;if(e<=64&&t&&(r=!0,fe.current=!0),r&&e>300)return;he(),a.scrollTo({top:a.scrollHeight,behavior:`auto`})}performance.now()-e>800||(t=requestAnimationFrame(i))};return t=requestAnimationFrame(i),()=>{n=!0,cancelAnimationFrame(t)}},[he]);(0,N.useLayoutEffect)(()=>{if(te&&(de.current=!0),de.current)return ge()},[ee,te,ge]),(0,N.useLayoutEffect)(()=>{let t=uo.get(e);if(!t||t.stick||!t.topKey)return;let n=t.topKey,r=0,i=performance.now(),a=()=>{let e=O.current.findIndex(e=>mo(e)===n);if(e>=0){he(),_.current?.scrollToIndex({index:e,align:`start`});return}performance.now()-i<1500&&(r=requestAnimationFrame(a))};return r=requestAnimationFrame(a),()=>cancelAnimationFrame(r)},[]),(0,N.useEffect)(()=>()=>{uo.set(e,{stick:de.current,topKey:re.current})},[e]);let _e=c?.id;(0,N.useLayoutEffect)(()=>{if(!C&&!_e||!de.current)return;let e=0,t=performance.now(),n=()=>{let r=v.current;r&&de.current&&r.scrollHeight-r.clientHeight-r.scrollTop>2&&(he(),r.scrollTo({top:r.scrollHeight,behavior:`auto`})),performance.now()-t<300&&(e=requestAnimationFrame(n))};return e=requestAnimationFrame(n),()=>cancelAnimationFrame(e)},[C,_e,he]);let ve=(0,N.useRef)(null),ye=(0,N.useCallback)(e=>{let t=e instanceof HTMLElement?e:null;if(v.current=t,ve.current?.(),ve.current=null,!t)return;pe.current=t.scrollTop;let n=()=>{let e=t.scrollTop,n=t.scrollHeight-t.clientHeight-e,r=performance.now()<me.current;n<=64?de.current=!0:!r&&e<pe.current-1&&(de.current=!1),pe.current=e};t.addEventListener(`scroll`,n,{passive:!0}),ve.current=()=>t.removeEventListener(`scroll`,n)},[]),be=(0,N.useCallback)(e=>{b(e),e&&(de.current=!0),d?.(e)},[d]),xe=(0,N.useCallback)(()=>{!r||a||f()},[r,a,f]),k=(0,N.useCallback)(()=>{oe.current=ee,de.current=!0,ge()},[ee,ge]),Se=(0,N.useMemo)(()=>function(){return(0,P.jsxs)(`div`,{className:fo,children:[(0,P.jsx)(mt,{scrollRef:v,timeline:n}),(0,P.jsx)(vo,{hasMore:r,loading:a,loadedInitial:o,hasItems:n.length>0})]})},[r,o,a,n]),Ce=(0,N.useMemo)(()=>({agentId:e,busy:C,pendingApproval:c,blockedLabel:l,canInterrupt:u,onInterrupt:p}),[e,C,l,u,p,c]),we=(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]),Te=(0,N.useMemo)(()=>({Header:Se,Footer:po,EmptyPlaceholder:we}),[we,Se]);return(0,P.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,P.jsx)(_a,{ref:_,scrollerRef:ye,className:`h-full py-3 md:py-4`,style:{height:`100%`,overflowX:`hidden`,overscrollBehavior:`contain`},context:Ce,data:n,firstItemIndex:E,initialTopMostItemIndex:ae.current??Math.max(0,n.length-1),computeItemKey:(e,t)=>mo(t),rangeChanged:ie,itemContent:(t,n)=>(0,P.jsx)(`div`,{className:fo,children:(0,P.jsx)(yo,{entry:n,agentId:e,showReasoning:s,onOpenReferencedPath:m,onPreviewReferencedPath:h,onPreviewReferencedPathEnd:g})}),components:Te,startReached:xe,atBottomStateChange:be,atBottomThreshold:64,followOutput:()=>de.current?`auto`:!1,totalListHeightChanged:()=>{if(!de.current)return;let e=v.current;if(!e)return;let t=e.scrollHeight-e.clientHeight-e.scrollTop;t>=0&&t<=240&&(he(),e.scrollTo({top:e.scrollHeight,behavior:`auto`}))},increaseViewportBy:{top:600,bottom:600}},e),!y&&n.length>0&&(0,P.jsxs)(M,{type:`button`,size:`sm`,variant:`secondary`,className:`absolute bottom-3 right-4 z-20 h-8 gap-1.5 rounded-full border border-border/70 bg-background/95 px-3 text-xs shadow-lg backdrop-blur`,onClick:k,children:[(0,P.jsx)(i,{className:`h-3.5 w-3.5`}),`Latest`,le>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:le>99?`99+`:le})]})]})}function vo({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 yo({entry:e,agentId:t,showReasoning:n,onOpenReferencedPath:r,onPreviewReferencedPath:i,onPreviewReferencedPathEnd:a}){return e.type===`message`?(0,P.jsx)(Tt,{msg:e.msg,peer:t,onOpenReferencedPath:r,onPreviewReferencedPath:i,onPreviewReferencedPathEnd:a}):e.type===`initial-prompt`?(0,P.jsx)(vt,{msg:e.msg}):e.type===`notice`?(0,P.jsx)(Et,{msg:e.msg}):e.type===`agent-action`?(0,P.jsx)(Ct,{entry:e}):e.type===`activity`?(0,P.jsx)(bt,{steps:e.steps,showReasoning:n}):e.type===`import-boundary`?(0,P.jsx)(wt,{history:e.history}):e.type===`imported-message`?(0,P.jsx)(ft,{entry:e.entry,sourceLabel:e.history.sourceAgentLabel||e.history.sourcePeerId}):e.type===`status`?(0,P.jsx)(pt,{event:e.event}):e.type===`date`?(0,P.jsx)(xt,{date:e.date}):(0,P.jsx)(ut,{timestamp:e.timestamp})}var bo=[],xo=15e3;function So(e){return e.kind===`session`&&e.payload?.session?.type===`prompt`}function Co(e){let t=e.filter(e=>e.kind===`chat`&&e.from===`user`);return t.length?e.filter(e=>{if(!So(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)<=xo)}):e}function wo({threads:e,onBack:t,showBackButton:n}){let r=k(e=>e.selectedInboxThread),i=k(e=>e.agentsById),o=k(e=>e.inboxDrafts),s=_e(),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??bo,E=k(e=>e.loadOlder),D=k(e=>e.openConfirm),ee=k(e=>e.showError),te=k(e=>e.orchestrators),ne=k(e=>e.fetchOrchestrators),re=k(e=>e.showReasoning),ie=k(e=>e.voiceTtsEnabled),ae=k(e=>e.setVoiceTtsEnabled),oe=k(e=>e.voiceInputMode),se=k(e=>e.plansByThread);(0,N.useRef)(null);let ce=(0,N.useRef)(null),[le,ue]=(0,N.useState)(`idle`),de=(0,N.useRef)([]),[fe,pe]=(0,N.useState)([]),[me,he]=(0,N.useState)(!1),[ge,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=Qt(r),Ne=(0,N.useMemo)(()=>e.find(e=>e.peer===r)||null,[e,r]),Pe=(0,N.useMemo)(()=>Co(T.filter(e=>De(r,e)&&!Fe(e)).sort((e,t)=>e.id-t.id)),[T,r]),j=i[r]||null,Ie=typeof j?.meta?.lifecycleAction==`string`&&j.meta.lifecycleAction.startsWith(`finalizing-`),{terminalOpen:Le,terminalTarget:Re,terminalOpening:ze,openTerminal:Be,closeTerminal:He}=At(j?.id),Ue=typeof j?.meta?.spawnRequestId==`string`?j.meta.spawnRequestId:``,We=(0,N.useMemo)(()=>C.filter(e=>e.targetAgentId===r||!!(Ue&&e.targetSpawnRequestId===Ue)),[Ue,C,r]),Ge=Ee(j),qe=Ge?.pendingApproval,Je=(0,N.useMemo)(()=>{if(!r||!Ne&&Pe.length===0)return null;let e=Pe[Pe.length-1]??Ne?.lastMessage??null,t=Ne?.previewMessage&&Pe.some(e=>e.id===Ne.previewMessage?.id)?Ne.previewMessage:e;return{id:Ne?.id??r,peer:r,messages:Pe,lastMessage:e,previewMessage:t,attention:Ne?.attention??{unread:0,needsHumanResponse:!1,score:0},archived:Ne?.archived??!1,draft:Ne?.draft??``}},[r,Ne,Pe]),Ye=Je||(We.length>0?{peer:r,messages:[],importedHistory:We}:null),Xe=o[r]||``,Ze=typeof j?.meta?.tmuxSession==`string`&&j.meta.tmuxSession.trim()?j.meta.tmuxSession:null,$e=Ze?te.find(e=>e.managedAgents?.some(e=>e.agentId===j.id||e.tmuxSession===Ze))??null:null,et=!!(Ze&&$e?.status===`online`&&j?.providerCapabilities?.terminal?.live?.read),tt=j?.providerCapabilities?.model?.provider??(typeof j?.meta?.provider==`string`?j.meta.provider:void 0),nt=!!(et&&(j?.providerCapabilities?.terminal?.live?.write||tt===`claude`)),rt=j?.providerCapabilities?.terminal?.attach?.create===!0,it=et||rt,at=je(j,`compact`),ot=je(j,`clearContext`),st=je(j,`shutdown`),ct=je(j,`interrupt`),ut=()=>{j&&v(j,`interrupt`)},[dt,ft]=(0,N.useState)(0),[pt,mt]=(0,N.useState)(!1),_t=j?.providerCapabilities?.liveSession?.slashCommands===!0,vt=j?.providerCapabilities?.model?.provider??(typeof j?.meta?.provider==`string`?j.meta.provider:void 0),yt=_t&&!pt&&/^\/\S*$/.test(Xe)?Ut(vt).filter(e=>e.name.toLowerCase().startsWith(Xe.toLowerCase())):[],bt=yt.length?Math.min(dt,yt.length-1):0;function xt(e){h(r,`${e.name} `),ft(0)}function St(e){h(r,e),pt&&mt(!1),ft(0)}let Ct=fe.some(e=>e.uploading),wt=fe.filter(e=>e.artifact);$t(Xe.trim().length>0||fe.length>0,(0,N.useCallback)(()=>{},[])),de.current=fe,(0,N.useEffect)(()=>()=>{Dt(de.current)},[]),(0,N.useEffect)(()=>{j?.meta?.tmuxSession&&te.length===0&&ne()},[j?.id,j?.meta?.tmuxSession,te.length]),(0,N.useEffect)(()=>()=>{ke.current!==null&&window.clearTimeout(ke.current)},[]);let Tt=typeof j?.spawnedBy==`string`?j.spawnedBy:void 0,Et=Tt?i[Tt]?.meta?.provider:void 0,jt=(0,N.useMemo)(()=>Ot(Pe,Me,j?.createdAt,We,Tt?{spawnedBy:{agentId:Tt,provider:Et}}:void 0),[Pe,Me,j?.createdAt,We,Tt,Et]),Nt=(0,N.useMemo)(()=>lt(j,Pe,Je?.lastMessage,se),[j,Je?.lastMessage,se,Pe]),Pt=(0,N.useCallback)(()=>{!r||!w?.hasMore||w.loading||E(r)},[w?.hasMore,w?.loading,E,r]),Ft=(0,N.useCallback)(()=>{ke.current!==null&&(window.clearTimeout(ke.current),ke.current=null)},[]),It=(0,N.useCallback)(async e=>{let t=gt(te,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}},[te]),Lt=(0,N.useCallback)((e,t,n)=>{if(!kt()||!n)return;let r=++Ae.current;It(e).then(e=>{Ae.current===r&&e&&(Ft(),we({...e,line:t||0,anchor:n}),Oe(``))})},[Ft,It]),Rt=(0,N.useCallback)(()=>{Ae.current+=1,Ft(),ke.current=window.setTimeout(()=>{we(null)},250)},[Ft]),zt=(0,N.useCallback)((e,t)=>{It(e).then(n=>{if(!n){ee(`File Not Found`,e);return}if(kt()){Ae.current+=1,Ft(),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:ht(n.path),selectedPath:n.path,line:t,overlay:!0})})},[Ft,l,It,ee]);function Bt(){Se(null),Oe(``)}async function Vt(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}));pe(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`});pe(t=>t.map(t=>t.id===i.id?{...t,artifact:e,uploading:!1}:t))}catch(e){pe(t=>t.map(t=>t.id===i.id?{...t,error:e.message,uploading:!1}:t))}}}function Ht(e){pe(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})}function Gt(){Dt(fe),pe([])}function Kt(){if(!Xe.trim()&&wt.length===0||!r||f||Ct||Ie)return;let e=wt.map(e=>({artifactId:e.artifact.id,kind:e.artifact.kind,role:`media`,title:e.artifact.filename||e.fileName}));c(Xe,{peer:r,lastMessage:Je?.lastMessage||null},e),Gt()}function qt(e){if(yt.length){if(e.key===`ArrowDown`){e.preventDefault(),ft(e=>Math.min(e+1,yt.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),ft(e=>Math.max(e-1,0));return}if(e.key===`Escape`){e.preventDefault(),mt(!0);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=yt[bt];t&&xt(t);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Kt())}function Yt(e){let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),Vt(t))}async function Zt(){if(!xe||le!==`idle`||!r)return;ye.bargeIn();let e=new ve;try{await e.start(),ce.current=e,ue(`recording`)}catch(e){ce.current=null,ue(`idle`),ee(`Microphone unavailable`,e?.message||`Could not access the microphone.`)}}async function en(){let e=ce.current;if(!(!e||le!==`recording`)){ce.current=null,ue(`transcribing`);try{let t=await e.stop();if(!t)return;let n=await be(t);if(!n)return;let i=Xe?`${Xe} ${n}`:n;if(oe===`autosend`&&!f&&!Ct){let e=wt.map(e=>({artifactId:e.artifact.id,kind:e.artifact.kind,role:`media`,title:e.artifact.filename||e.fileName}));c(i,{peer:r,lastMessage:Je?.lastMessage||null},e),Gt()}else h(r,i)}catch(e){ee(`Transcription failed`,e?.message||`Could not transcribe audio.`)}finally{ue(`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)(Wt,{selectedInboxThread:r,agent:j,now:s,blockedState:Ge,thread:Je,exportableThread:Ye,importedHistory:We,showBackButton:n,onBack:t,openAgentDetail:d,openWorkspaceFocus:b,voiceTtsEnabled:ie,setVoiceTtsEnabled:ae,canOpenTerminal:it,terminalOpening:ze,handleOpenTerminal:Be,canInterrupt:ct,interruptAgent:ut,canCompact:at,canClearContext:ot,canShutdown:st,openConfirm:D,workspaceAction:y,doAgentAction:v,openFilesForAgent:u,forkFromAgent:x,markInboxThreadUnread:m,markInboxThreadRead:p,exportThread:g}),(0,P.jsx)(Mt,{threadId:Nt&&`threadId`in Nt?Nt.threadId:null,teamId:Nt&&`teamId`in Nt?Nt.teamId:void 0,channel:Nt?.channel}),(0,P.jsx)(_o,{agentId:r,agentStatus:j?.status,timeline:jt,hasMore:w?.hasMore??!1,loading:w?.loading??!1,loadedInitial:w?.loadedInitial??!1,showReasoning:re,pendingApproval:qe,blockedLabel:Ge?.label,canInterrupt:ct,onLoadOlder:Pt,onInterrupt:ut,onOpenReferencedPath:zt,onPreviewReferencedPath:Lt,onPreviewReferencedPathEnd:Rt}),(0,P.jsx)(Jt,{draft:Xe,placeholder:`Message ${j?A(j):r}…`,chatSending:f,disabled:Ie,hasPendingUploads:Ct,readyAttachmentCount:wt.length,pendingAttachments:fe,micAvailable:xe,micState:le,slashMatches:yt,slashActiveIndex:bt,onDraftChange:St,onKeyDown:qt,onPaste:Yt,onUploadFiles:e=>{Vt(e)},onRemovePendingAttachment:Ht,onSend:Kt,onAcceptSlash:xt,onSlashHover:ft,onStartPtt:()=>{Zt()},onStopPtt:()=>{en()},footerText:Ie?`${j?A(j):`Agent`} is wrapping up (${(j?.meta?.lifecycleAction).slice(11)}) — messaging paused`:`Enter to send · Shift+Enter for newline`})]}),ge&&(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)(M,{variant:`ghost`,size:`icon-sm`,title:`Close preview`,onClick:Bt,children:(0,P.jsx)(O,{className:`h-3.5 w-3.5`})})]}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1`,children:ge.type===`directory`?(0,P.jsx)(Ke,{orchestratorId:ge.orchestratorId,selectedPath:ge.path,onReadError:Oe}):(0,P.jsx)(Ve,{orchestratorId:ge.orchestratorId,selectedPath:ge.path,line:ge.line,onReadError:Oe})})]})]}),Ce&&(0,P.jsx)(Xt,{preview:Ce,error:Te,onReadError:Oe,onMouseEnter:Ft,onMouseLeave:Rt}),Re&&(0,P.jsx)(Qe,{open:Le,onOpenChange:He,orchestratorId:Re.orchestratorId,session:Re.session,interactive:Re.interactive||nt})]}):(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 To(){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 Eo(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 Do(){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;To(),(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 Eo(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)(zt,{threads:e})}),(0,P.jsx)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:(0,P.jsx)(wo,{threads:e},t||`empty`)})]}),(0,P.jsx)(`div`,{className:`md:hidden flex w-full overflow-hidden`,children:a?(0,P.jsx)(Oo,{children:(0,P.jsx)(wo,{threads:e,onBack:o,showBackButton:!0},t||`empty`)}):(0,P.jsx)(`div`,{className:`w-full flex flex-col overflow-hidden`,children:(0,P.jsx)(zt,{threads:e})})})]})}function Oo({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{Do as ChatView};
|
|
2
|
-
//# sourceMappingURL=chat-C-FI9bLO.js.map
|