import { Archive, ChevronRight, Flag, Radio } from 'lucide-react' import type { LiveTimingRow } from '../../lib/live' import { driverCode } from '../../lib/live' import type { LiveWeekendContext } from '../../lib/weekendContext' import type { TransportHealth } from '../../lib/liveState' import { feedHealthLabel } from '../../lib/liveState' import { formatSessionScheduleTime } from '../../lib/schedule' interface Props { /** 'settling' immediately after a session; 'inactive' when nothing is retained. */ phase: 'settling' | 'inactive' transport: TransportHealth context: LiveWeekendContext /** Top rows of the final snapshot (settling only), already position-sorted. */ rows: LiveTimingRow[] capturedAt?: string | null hasArchive: boolean onViewArchive: () => void } function formatCapturedAt(capturedAt: string | null | undefined): string { if (!capturedAt) return '' const date = new Date(capturedAt) if (Number.isNaN(date.getTime())) return '' return date.toLocaleString() } export function LiveHandoff({ phase, transport, context, rows, capturedAt, hasArchive, onViewArchive, }: Props) { const isSettling = phase === 'settling' const testid = isSettling ? 'live-settling' : 'live-inactive' const capturedLabel = formatCapturedAt(capturedAt) const title = context.meetingName || 'Live Timing' const topRows = rows.slice(0, 3) const analysisKey = context.analysisSessionKey const analysisName = context.analysisSessionName || 'session' const analysisReady = context.analysisReady return (
{isSettling ? ( <> SESSION SETTLING ) : ( <> NO LIVE SESSION )}

{title}

{isSettling && capturedLabel && (

Final feed snapshot captured {capturedLabel}

)} {!isSettling && (

The timing feed is quiet between sessions. Here's where the weekend stands.

)}
{isSettling && topRows.length > 0 && (
Provisional order at chequered
    {topRows.map((row) => (
  1. P{row.Position} {driverCode(row)}
  2. ))}
)}
{analysisKey ? ( {isSettling ? `Open ${analysisName} analysis` : `Open ${analysisName} in Race Hub`} {analysisReady ? 'Full timing, strategy & story ready' : 'Settling — analysis will fill in as data ingests'} ) : (
Analysis not ready yet The completed session will appear in Race Hub once it is ingested.
)} {context.nextSession && (
Up next · {context.nextSession.name} {formatSessionScheduleTime(context.nextSession.startsAt)}
)} {context.previousSession && context.previousSession.sessionKey !== analysisKey && ( Recap · {context.previousSession.name} Review the last completed session )} {hasArchive && ( )} {!analysisKey && !context.nextSession && !context.previousSession && !hasArchive && (
Command Center Weekend schedule & standings
)}
) }