import { BadgeCheck, Mic } from "lucide-react"; import type { CitationVerification } from "../../lib/citations/schema"; import { cn } from "../../lib/utils"; // What checking a citation found (its COMPUTED `verification` block, written by // compose — lib/citations/schema.ts): the quote's match against the record's // transcript as a percentage, whether the voice was checked, and when. Renders // nothing when the citation was never checked, so an unchecked citation reads // as unchecked rather than as a zero. // // Pure/presentational: server-rendered or in a client tree alike. export const QUOTE_SCORE_TOOLTIP = "How closely the quoted words match the record's transcript at the cited place: checked against the transcript, 100% is verbatim."; export function quoteScorePercent(score: number): number { return Math.round(Math.min(1, Math.max(0, score)) * 100); } // `2026-10-04T12:00:00Z` → `2026-10-04`; anything else as given. function dateOf(v: string): string { return /^\d{4}-\d{2}-\d{2}/.test(v) ? v.slice(0, 10) : v; } export function VerificationBadge({ verification, className, }: { verification: CitationVerification | undefined; className?: string; }) { const v = verification; if (!v) return null; const hasScore = typeof v.quoteScore === "number" && Number.isFinite(v.quoteScore); if (!hasScore && !v.voiceChecked) return null; const checked = v.quoteCheckedAt ? dateOf(v.quoteCheckedAt) : null; return ( {hasScore && ( Quote {quoteScorePercent(v.quoteScore!)}% match, checked against the transcript )} {v.voiceChecked && ( Voice checked )} {checked && checked {checked}} ); }