import Link from 'next/link';
import { CompareButton } from '@/components/compare/compare-button';
import { ComparabilityBadge, ConfigChipEl, OpennessChip, TrustBadge } from '@/components/models/badges';
import { configChipsOf, fmtScoreUnit, refToSummary } from '@/components/models/shared';
import { FrontierLineChart } from './client-charts';
import { ScrollX } from '@/components/models/scroll-x';
import { EntityLink } from '@/components/ui/entity';
import { Pagination } from '@/components/ui/pagination';
import { SourceCell } from '@/components/ui/provenance';
import { Note } from '@/components/ui/section';
import { EmptyState } from '@/components/ui/unavailable';
import { cn } from '@/lib/cn';
import { fmtDate, fmtInt, fmtSigned } from '@/lib/format';
import { routes } from '@/lib/site';
import type { BenchmarkFrontierPayload, Group, LeaderboardRow } from '@/lib/types';
/*
Leaderboard 2.0 (server): one row per canonical model — rank (+Δ vs closed rows) · model · score bar · trust · config chips ·
comparability vs leader · evaluated/observed · source · History · Compare. Mobile stacks (rank + model + score first).
*/
export function Leaderboard2({ rows, group, total, limit, offset, makeHref, historyHref, activeModel, unit }: { rows: LeaderboardRow[]; group: Group | null; total: number; limit: number; offset: number; makeHref: (offset: number) => string; historyHref: (slug: string) => string; activeModel?: string; unit?: string | null }) {
if (!rows.length) return
{rows.map((r) => {
const on = activeModel === r.model.slug;
const chips = configChipsOf(r.config, group?.config ?? null, 4);
const openness = typeof r.model.attributes?.openness === 'string' ? r.model.attributes.openness : null;
return (
#
Model
Score
Trust
Configuration
vs leader
Evaluated
Source
Actions
);
})}
{fmtInt(r.rank)}
{r.delta_rank !== null && r.delta_rank !== 0 && (
0 ? 'text-positive' : 'text-danger')} title={`Rank moved ${fmtSigned(r.delta_rank)} vs the closed rows of this group${r.previous_rank ? ` (was ${r.previous_rank})` : ''}`}>
{r.delta_rank > 0 ? '▲' : '▼'}
{Math.abs(r.delta_rank)}
)}
{fmtScoreUnit(r.score, u)}
{chips.length ? chips.map((c) =>
{r.rank === 1 ? leader :
{r.evaluated_at ? fmtDate(r.evaluated_at) : obs. {fmtDate(r.observed_at)}}
History