import { Check, X } from '@sim/emcn/icons' import type { Fact } from '@/lib/compare/data' import { SourceLink } from '@/app/(landing)/comparison/components/source-info' import { parseFactValue } from '@/app/(landing)/comparison/fact-status' export interface FactValueProps { fact: Fact } /** * Renders one {@link Fact} for a glancing reader while keeping the full * granular fact server-rendered for crawlers and AI answer engines. * * - A true "Yes"/"No" fact renders as an icon alone (a monochrome check or * muted cross, no colored pass/fail styling), no visible text, since the * label column and surrounding context already say what's being asked. * - Any other fact shows its `shortValue` (a compact, pre-authored * restatement of `value`), never the full sentence. * - `Tooltip` here is a cursor-following mini-bubble meant for a short * one-line label (see its own docs/usages: "Refresh", "last updated: X") * . It is deliberately NOT used to hold paragraph-length detail text, only * the compact source citation, which is exactly what it's designed for. * - When a source exists, the visible glance (icon or `shortValue` text) * IS the hover/click target for that source, via `SourceLink`, rather * than a separate info-icon next to every value. One affordance per * fact keeps a 58-row table from reading as icon-cluttered. * - A `sr-only` span always carries the complete value, detail, and source * in the initial server-rendered HTML, independent of hover/JS state, so * an LLM or crawler reading the page gets full granularity even though a * human sees only the compact glance. */ export function FactValue({ fact }: FactValueProps) { const { status, text } = parseFactValue(fact.value) const isBoolean = status === 'yes' || status === 'no' const primarySource = fact.sources[0] const fullText = [fact.value, fact.detail].filter(Boolean).join('. ') const glance = isBoolean ? ( status === 'yes' ? (