'use client'; import { useId } from 'react'; import styles from './battle-wheel.module.css'; export type BattleWheelProps = { value: number; onChange: (value: number) => void; max: number; min?: number; sliderLabel?: string; step: number; disabled?: boolean; id?: string; }; const point = (angle: number, radius: number) => ({ x: 100 + Math.sin((angle * Math.PI) / 180) * radius, y: 100 - Math.cos((angle * Math.PI) / 180) * radius, }); /** The parent supplies the dial limits and labels the numeric input by its ID. */ export function BattleWheel({ value, onChange, max, min = 0, sliderLabel = 'Forces dialed slider', step, disabled = false, id = 'forces-dialed', }: BattleWheelProps) { const graphicId = useId(); const rimId = `${graphicId}-rim`; const faceId = `${graphicId}-face`; const fraction = max > min ? Math.min(1, Math.max(0, (value - min) / (max - min))) : 0; const angle = -135 + fraction * 270; // This caps decorative detail only; the native controls keep the supplied step. const divisions = Math.min(80, Math.max(1, Math.ceil((max - min) / step))); const labels = [ ...new Set( [0, 0.25, 0.5, 0.75, 1].map((position) => Math.min(max, min + Math.round(((max - min) * position) / step) * step), ), ), ]; return (