import type { ReactElement } from 'react' import { gatheredText, verificationMark, type Citation, type CompanyResult, type Criterion } from './screener' // One company's answers and what they rest on: per criterion the verdict, the rationale, what the // verifier made of it, and the quotes as citations. The server has already checked every quote // against the paragraph it cites, so a card shows it as it came, with the link the server built: // the filing on sec.gov, scrolled to the quote. /** What one evidence call brought back for a company. */ export interface Evidenced { company: CompanyResult citations: Record } interface Props { ticker: string evidence: Evidenced | null error: string | null questions: Criterion[] onClose: () => void /** Opens an https link in the browser; the view's own frame cannot. */ onLink: (url: string) => void } export function EvidencePane({ ticker, evidence, error, questions, onClose, onLink }: Props): ReactElement { const company = evidence?.company return (
{ticker} {company?.name && {company.name}} {company?.verdict && {company.verdict}}
{error &&

{error}

} {!error && !company &&

Reading the evidence…

} {company?.error &&

{company.error}

} {company && company.status !== 'done' && !company.error &&

This company has not been read yet.

} {company?.criteria.map((answer) => { const mark = verificationMark(answer.verification) return (

{questions.find((q) => q.id === answer.id)?.question ?? answer.id}

{answer.verdict} {' '} · {answer.verification || 'not verified'} {answer.confidence !== null && ` · confidence ${answer.confidence.toFixed(2)}`}

{answer.rationale &&

{answer.rationale}

} {mark &&

{mark}

} {answer.note &&

{answer.note}

} {answer.evidence.map((id) => { const citation = evidence?.citations[id] return citation ? : null })} {answer.gathered &&

{gatheredText(answer.gathered)}

}
) })}
) } function Card({ citation, onLink }: { citation: Citation; onLink: (url: string) => void }): ReactElement { const { url } = citation return (

“{citation.quote}”

{citation.title} {url && ( )}

) }