import { SectionCard } from '@overdeck/deck-ui'
import type { FactoryRunView } from '../../lib/factory-types'
import { FactoryDecisionPanel } from './FactoryDecisionPanel'
import { FactoryEventTable } from './FactoryEventTable'
import { FactoryPhaseTable } from './FactoryPhaseTable'
import { FactoryRunMetadata } from './FactoryRunMetadata'
import { FactoryTimeline } from './FactoryTimeline'
import { FactoryAttemptTable, FactoryDiffTable, FactoryGateTable, FactoryProcessTable } from './FactoryTraceTables'
export function FactoryRawTrace({run}:{run:FactoryRunView}) { const unavailable=new Set(run.unavailableTables ?? []); return <div className="flex flex-col gap-3"><FactoryRunMetadata run={run}/><FactoryTimeline run={run}/><FactoryDecisionPanel decisions={run.decisions}/><SectionCard title="Phases">{run.phases.length?<FactoryPhaseTable phases={run.phases} attempts={run.attempts ?? []}/>:<p>No phases recorded for this run.</p>}</SectionCard><SectionCard title="Agent attempts">{unavailable.has('agent_attempts')?<p>Not recorded by this run&apos;s factory version.</p>:run.attempts?.length?<FactoryAttemptTable attempts={run.attempts} runAttempts={run.attempts}/>:<p>No agent attempts recorded.</p>}</SectionCard><SectionCard title="Gates">{unavailable.has('gate_results')?<p>Not recorded by this run&apos;s factory version.</p>:run.gates?.length?<FactoryGateTable gates={run.gates}/>:<p>No gates recorded.</p>}</SectionCard><SectionCard title="Diffs">{unavailable.has('phase_diffs')?<p>Not recorded by this run&apos;s factory version.</p>:run.diffs?.length?<FactoryDiffTable diffs={run.diffs}/>:<p>No diffs recorded.</p>}</SectionCard><SectionCard title="Processes">{unavailable.has('processes')?<p>Not recorded by this run&apos;s factory version.</p>:run.processes?.length?<FactoryProcessTable processes={run.processes}/>:<p>No processes recorded.</p>}</SectionCard><SectionCard title="Events">{run.events.length?<FactoryEventTable events={run.events} runStartedAt={run.startedAt} phases={run.phases}/>:<p>No events recorded for this run.</p>}</SectionCard></div> }
