/* Player-name normalization (Session 46) — frontend copy of src/utils/playerName.js (the Next bundle can't import from src/). Keep the two in sync; tests/unit cross-checks they agree. CommonJS so .tsx imports it AND Jest requires it directly. */ const SUFFIXES = new Set(['jr', 'sr', 'ii', 'iii', 'iv', 'v']); function normalizeName(raw) { const display = String(raw == null ? '' : raw) .replace(/\./g, '') .replace(/\s+/g, ' ') .trim(); const folded = display.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase(); const key = folded.split(' ').filter((t) => t && !SUFFIXES.has(t)).join(' '); return { display, key }; } function nameKey(raw) { return normalizeName(raw).key; } module.exports = { normalizeName, nameKey, SUFFIXES };