import { CheckCircle2Icon, MinusIcon, TrendingDownIcon, TrendingUpIcon, TriangleAlertIcon, } from 'lucide-react' import { Alert, AlertDescription, AlertTitle } from '@/components/ui/Alert' import { computeGapVs2022, computeVoteTrend, formatElectionNumber, formatVoteTrendSeries, voteTrendAlertVariant, } from '@/lib/electionInsights' import { cn } from '@/lib/utils' import type { NucleusElectoralBaselineViewModel } from '@/utilities/nucleusViewModels' export const NucleusInsights = ({ baseline, confirmedVoteEstimate, }: { baseline: NucleusElectoralBaselineViewModel | null confirmedVoteEstimate: number | null }) => { const gap = computeGapVs2022(baseline, confirmedVoteEstimate) const GapIcon = gap.status === 'above' ? CheckCircle2Icon : TriangleAlertIcon const trend = baseline ? computeVoteTrend(baseline.series) : null const TrendIcon = trend?.status === 'increase' ? TrendingUpIcon : trend?.status === 'decline' ? TrendingDownIcon : trend?.status === 'stable' ? MinusIcon : TriangleAlertIcon let supportLine: string | null = null if ((gap.status === 'above' || gap.status === 'below') && baseline && confirmedVoteEstimate !== null) { supportLine = `Estimativa atual (${formatElectionNumber(confirmedVoteEstimate)}) · resultado 2022 (${formatElectionNumber(baseline.candidate.votes)})` } return (

Insights do território

{baseline && trend && trend.status !== 'noBaseline' ? ( ) : null}
) }