import { confidenceLabel, fmtRelative, cn } from '@/lib/format'; import { Badge } from './primitives'; /** §191: every estimate carries sample size, confidence and freshness. */ export function Evidence({ confidence, sampleSize, updatedAt, sampleLabel = 'sales', className }: { confidence: number | null | undefined; sampleSize: number | null | undefined; updatedAt: Date | string | null | undefined; sampleLabel?: string; className?: string }) { const label = confidenceLabel(confidence); const tone = label === 'High' ? 'gain' : label === 'Medium' ? 'index' : label === 'Low' ? 'alert' : 'neutral'; return (
Confidence: {label} {sampleSize !== null && sampleSize !== undefined ? ( {sampleSize.toLocaleString('en-US')} {sampleLabel} used ) : null} {updatedAt ? Updated {fmtRelative(updatedAt)} : null}
); } export function ScoreMeter({ value, label, tone = 'index', className }: { value: number | null | undefined; label: string; tone?: 'index' | 'rarity' | 'gain' | 'alert'; className?: string }) { const fill = tone === 'rarity' ? 'var(--ri-rarity)' : tone === 'gain' ? 'var(--ri-gain)' : tone === 'alert' ? 'var(--ri-alert)' : 'var(--ri-index)'; const track = tone === 'rarity' ? 'var(--ri-rarity-bg)' : tone === 'gain' ? 'var(--ri-gain-bg)' : tone === 'alert' ? 'var(--ri-alert-bg)' : 'var(--ri-index-bg)'; return (
{label} {value === null || value === undefined ? '—' : `${Math.round(value)}/100`}
{value !== null && value !== undefined ?
: null}
); }