import { Evidence } from '@/components/evidence/evidence'; import { cn } from '@/lib/cn'; import { fmtAgo } from '@/lib/format'; import type { ProvenanceEntry } from '@/lib/types'; import { TierBadge } from './badges'; function domain(url: string | null | undefined): string | null { if (!url) return null; try { return new URL(url).hostname.replace(/^www\./, ''); } catch { return null; } } /** * One-line provenance: "Source: docs.claude.com · T1 · observed 3 h ago · high". Server-safe. * With `slug` + `property` it appends an "Evidence" trigger that opens the drawer (`components/evidence`). */ export function ProvenanceInline({ p, className, showConfidence = true, slug, property, value, entity, }: { p: ProvenanceEntry; className?: string; showConfidence?: boolean; slug?: string; property?: string; value?: unknown; entity?: { name?: string; entity_type?: string } | null; }) { const name = p.source_name ?? domain(p.url) ?? 'source'; return (

Source: {p.url ? ( {name} ) : ( {name} )} · · observed {fmtAgo(p.observed_at)} {showConfidence && p.confidence && ( <> · {p.confidence} )} {p.extractor && p.extractor.startsWith('llm') && ( <> · LLM-extracted )} {slug && property && ( <> · Evidence )}

); } /** Compact source cell for tables: domain link + tier. */ export function SourceCell({ url, tier, name, observedAt, className }: { url: string | null | undefined; tier?: number | null; name?: string | null; observedAt?: string | null; className?: string }) { const label = name ?? domain(url); return ( {url && label ? ( {label} ) : label ? ( {label} ) : ( — )} {tier !== undefined && } {observedAt && {fmtAgo(observedAt)}} ); }