"use client";
import * as React from "react";
import { Coins, Timer, Trophy, Type } from "lucide-react";
import { ProviderIcon } from "@/components/brand/provider-icon";
import { Badge } from "@/components/ui/badge";
import { criterionById, type Criterion, type WinnerResult } from "@/lib/arena/scoring";
import { formatDelta } from "@/lib/arena/metrics";
import { cn } from "@/lib/utils";
import { BlindAvatar } from "./blind";
interface Props {
winner: WinnerResult;
name: string;
provider: string | null;
/** Blind Arena, identity still hidden → neutral avatar and letter label. */
hidden?: boolean;
blindIndex?: number;
customCriteria?: Criterion[];
showCosts?: boolean;
className?: string;
}
/**
* Arena Winner card: shown once every response is final and at least one vote exists.
* Most criteria won; ties go to the fastest first token. Deltas compare the winner with the mean of the others.
*/
export function WinnerCard({ winner, name, provider, hidden, blindIndex = 0, customCriteria = [], showCosts = true, className }: Props) {
const criteria = winner.criteriaWon.map((id) => criterionById(id, customCriteria));
const d = winner.deltas;
const better = (v: number | null) => (v === null ? null : v < 0);
return (
Arena winner
Won {criteria.length} of your criteri{criteria.length === 1 ? "on" : "a"}
{winner.tieBreak === "fastest" ? " — tie broken by time to first token" : winner.tieBreak === "order" ? " — tie broken by order" : ""}.
{name}
{criteria.map((c) => (
{showCosts ?
) : null}