// Players modal — list of all participants with status const { useState: usePMState } = React; function PlayersModal({ tournament, onClose }) { if (!tournament) return null; const champ = getChampion(tournament.bracket); function statusFor(f) { if (champ && champ.name === f.name && champ.seed === f.seed) return { label: 'Campeão', tone: 'champ' }; for (const r of tournament.bracket.rounds) { for (const m of r.matches) { if (m.status === 'done' && m.winner) { const inMatch = (m.a?.name === f.name && m.a?.seed === f.seed) || (m.b?.name === f.name && m.b?.seed === f.seed); const isWinner = m.winner.name === f.name && m.winner.seed === f.seed; if (inMatch && !isWinner) return { label: 'Eliminado', tone: 'out' }; } } } for (const r of tournament.bracket.rounds) { for (const m of r.matches) { const inMatch = (m.a?.name === f.name && m.a?.seed === f.seed) || (m.b?.name === f.name && m.b?.seed === f.seed); if (!inMatch) continue; if (m.status === 'ready') return { label: r.name, tone: 'live' }; if (m.status === 'waiting') return { label: r.name, tone: 'wait' }; } } return { label: '—', tone: 'idle' }; } return (
e.stopPropagation()}>
Lista completa

Participantes {tournament.fighters.length}

{tournament.fighters.map((entry, i) => { // Support both string[] (prototype) and Fighter[] (API) const name = typeof entry === 'string' ? entry : entry.name; const seed = typeof entry === 'string' ? i + 1 : (entry.seed ?? entry.id ?? i + 1); const f = { name, seed }; const c = fighterColor(f.seed, name); const st = statusFor(f); return (
{name} #{String(f.seed).padStart(2, '0')} {st.tone === 'live' && } {st.label}
); })}
); } window.PlayersModal = PlayersModal;