import type { GameStats, SolverReplay } from '@wordle/shared'; import { getMessages } from '../messages/index.js'; import { LangSwitch } from '../components/LangSwitch.js'; interface Screen3ResultsProps { won: boolean; attemptCount: number; revealedWord: string | null; stats: GameStats; replays?: SolverReplay[]; onPlayAgain?: () => void; } const MINI_COLORS: Record = { g: '#6aaa64', y: '#c9b458', x: '#787c7e' }; function MiniBoard({ replay }: { replay: SolverReplay }) { return (
{replay.solver}
{replay.steps.map((step, rowIdx) => (
{step.guess.split('').map((letter, colIdx) => { const c = step.colors[colIdx]; return (
{letter}
); })}
))}
); } function Histogram({ stats }: { stats: GameStats }) { if (stats.gamesPlayed === 0) return

{getMessages().results.noGames}

; const maxCount = Math.max(...stats.histogram, 1); return (
{stats.histogram.map((count, idx) => { const label = idx < 6 ? `${idx + 1}` : 'X'; const pct = (count / maxCount) * 100; return (
{label}
0 ? '#6aaa64' : '#d3d6da', width: `${Math.max(pct, count > 0 ? 5 : 0)}%`, minWidth: count > 0 ? '12px' : '4px', borderRadius: '2px' }} /> {count}
); })}
); } export function Screen3Results({ won, attemptCount, revealedWord, stats, replays, onPlayAgain }: Screen3ResultsProps) { const r = getMessages().results; return (

{won ? r.congratulations : r.betterLuck}

{won ? (

{r.solvedIn(attemptCount)}

) : ( revealedWord &&

{r.theWordWas(revealedWord)}

)}

{r.statistics}

{stats.gamesPlayed}
{r.played}
{stats.gamesPlayed > 0 ? Math.round((stats.wins / stats.gamesPlayed) * 100) : 0}%
{r.winRate}
{stats.currentStreak}
{r.streak}
{stats.maxStreak}
{r.maxStreak}
{replays && replays.length > 0 && (

{r.solverCaption}

{replays.map((rp) => ( ))}
)} {onPlayAgain && ( )}
); }