import { fmtPct } from "@/lib/format"; /** Écart estimation vs prix demandé — jamais « bonne affaire » : on dit ce que le modèle mesure, avec sa confiance. */ export function VerdictPill({ verdict, ratio, confidence, small = false }: { verdict: string | null; ratio: number | null; confidence: string | null; small?: boolean }) { if (!verdict || verdict === "na" || ratio == null) return null; const weak = confidence === "C" || confidence === "D"; const pct = ratio - 1; // estimation vs prix : +10 % = estimation 10 % au-dessus du prix demandé const cls = verdict === "aligne" ? "bg-info-soft text-info" : verdict === "sous" ? "bg-good-soft text-good" : "bg-warn-soft text-warn"; const full = verdict === "aligne" ? "Prix aligné sur l'estimation" : `Estimation ${fmtPct(pct)} vs prix`; const short = verdict === "aligne" ? "≈ estimation" : `${fmtPct(pct)} vs prix`; const title = `${full}${weak ? " · confiance du modèle faible : à interpréter avec prudence" : " · écart entre l'estimation Toveli et le prix demandé"}`; if (small) return {short}{weak ? " ·!" : ""}; return {full}{weak ? " · faible confiance" : ""}; }