import React, { useState } from 'react'; import { Shuffle, Eye, Flame, TrendingUp, MinusCircle, Award, Info, ChevronDown, ChevronUp } from 'lucide-react'; import type { GameConfig } from '../types'; interface GameConfigPanelProps { config: GameConfig; onChange: (config: GameConfig) => void; questionCount: number; compact?: boolean; } interface TooltipProps { content: string; } const Tooltip: React.FC = ({ content }) => { const [show, setShow] = useState(false); const [coords, setCoords] = useState({ top: 0, left: 0 }); const buttonRef = React.useRef(null); const updatePosition = () => { if (buttonRef.current) { const rect = buttonRef.current.getBoundingClientRect(); setCoords({ top: rect.top + rect.height / 2, left: rect.right + 8, }); } }; const handleMouseEnter = () => { updatePosition(); setShow(true); }; const handleClick = (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); updatePosition(); setShow(!show); }; return (
{show && (
{content}
)}
); }; interface ToggleRowProps { icon: React.ReactNode; iconActive: boolean; label: string; description: string; checked: boolean; onChange: (checked: boolean) => void; tooltip?: string; children?: React.ReactNode; } const ToggleRow: React.FC = ({ icon, iconActive, label: labelText, description, checked, onChange, tooltip, children, }) => { const inputId = React.useId(); return (
{tooltip && }
); }; interface NumberInputProps { label: string; value: number; onChange: (value: number) => void; min?: number; max?: number; step?: number; suffix?: string; } const NumberInput: React.FC = ({ label, value, onChange, min, max, step = 1, suffix }) => (
{label}
onChange(Number(e.target.value))} min={min} max={max} step={step} className="w-20 px-3 py-1.5 border-2 border-gray-200 rounded-lg text-center font-bold text-gray-900 bg-white focus:border-theme-primary focus:ring-2 focus:ring-theme-primary/20 outline-none" /> {suffix && {suffix}}
); export const GameConfigPanel: React.FC = ({ config, onChange, questionCount, compact = false, }) => { const [expanded, setExpanded] = useState(!compact); const update = (partial: Partial) => { onChange({ ...config, ...partial }); }; const suggestedComebackBonus = Math.round(50 + (questionCount * 5)); const suggestedFirstCorrectBonus = Math.round(25 + (questionCount * 2.5)); if (compact && !expanded) { return ( ); } return (
{compact && ( )} } iconActive={config.shuffleQuestions} label="Shuffle Questions" description="Randomize question order when starting" checked={config.shuffleQuestions} onChange={(v) => update({ shuffleQuestions: v })} /> } iconActive={config.shuffleAnswers} label="Shuffle Answers" description="Randomize answer positions for each question" checked={config.shuffleAnswers} onChange={(v) => update({ shuffleAnswers: v })} /> } iconActive={config.hostParticipates} label="Host Participates" description="Join as a player and answer questions" checked={config.hostParticipates} onChange={(v) => update({ hostParticipates: v })} /> } iconActive={config.streakBonusEnabled} label="Streak Bonus" description="Multiply points for consecutive correct answers" checked={config.streakBonusEnabled} onChange={(v) => update({ streakBonusEnabled: v })} tooltip={`After ${config.streakThreshold} correct answers in a row, points are multiplied by ${config.streakMultiplier}x. The multiplier increases by ${((config.streakMultiplier - 1) * 100).toFixed(0)}% for each additional correct answer.`} >
update({ streakThreshold: v })} min={2} max={10} suffix="correct" /> update({ streakMultiplier: v })} min={1.05} max={2} step={0.05} suffix="x" />
} iconActive={config.comebackBonusEnabled} label="Comeback Bonus" description="Extra points for players not in top 3" checked={config.comebackBonusEnabled} onChange={(v) => update({ comebackBonusEnabled: v })} >
update({ comebackBonusPoints: v })} min={10} max={500} suffix="pts" />

Suggested for {questionCount} questions: {suggestedComebackBonus} pts

} iconActive={config.penaltyForWrongAnswer} label="Wrong Answer Penalty" description="Deduct points for incorrect answers" checked={config.penaltyForWrongAnswer} onChange={(v) => update({ penaltyForWrongAnswer: v })} >
update({ penaltyPercent: v })} min={5} max={100} suffix="%" />

Deducts {config.penaltyPercent}% of max points ({Math.round(1000 * config.penaltyPercent / 100)} pts)

} iconActive={config.firstCorrectBonusEnabled} label="First Correct Bonus" description="Extra points for first player to answer correctly" checked={config.firstCorrectBonusEnabled} onChange={(v) => update({ firstCorrectBonusEnabled: v })} >
update({ firstCorrectBonusPoints: v })} min={10} max={500} suffix="pts" />

Suggested for {questionCount} questions: {suggestedFirstCorrectBonus} pts

); };