/* Brainstorm X — Shortlist board (Finalists). */ (function () { const { useState } = React; const DS = window.BrainstormXDesignSystem_f2a458; const { Button, Card, NameCard, Chip, Badge, HeatBadge } = DS; const I = window.BXIcons; const FILTERS = ['Most liked', 'Most debated', 'Shortest', 'Most brandable', 'Best for .com']; function Shortlist({ names, setNames, goto, project = 'Pickle Paws' }) { const [filter, setFilter] = useState('Most liked'); const sorted = [...names].sort((a, b) => { if (filter === 'Shortest') return a.name.length - b.name.length; if (filter === 'Most debated') return (b.counts.down + b.counts.ice) - (a.counts.down + a.counts.ice); if (filter === 'Most brandable') return (b.style === 'brandable') - (a.style === 'brandable'); return b.score - a.score; }); const finalists = sorted.filter((n) => n.shortlisted || n.score >= 8).slice(0, 4); const rest = sorted.filter((n) => !finalists.includes(n)); const vote = (id, type) => setNames((ns) => ns.map((n) => { if (n.id !== id) return n; const heatFn = window.BXheatFromVotes || window.BXheatFromScore; if (type === 'star') { const sl = !n.shortlisted; const up = n.counts.up || 0, down = n.counts.down || 0; const score = up * 2 - down * 2 + (sl ? 5 : 0); return { ...n, shortlisted: sl, score, heat: heatFn(up, down) }; } if (type !== 'up' && type !== 'down') return n; const counts = { ...n.counts, [type]: (n.counts[type] || 0) + 1 }; const score = (counts.up || 0) * 2 - (counts.down || 0) * 2 + (n.shortlisted ? 5 : 0); return { ...n, counts, score, heat: heatFn(counts.up || 0, counts.down || 0) }; })); return (