"use client" import { useState, useEffect } from 'react' interface GaugeProps { value: number max: number unit: string color: string label: string size?: 'small' | 'medium' | 'large' } export default function SpeedometerGauge({ value, max, unit, color, label, size = 'medium' }: GaugeProps) { const [percentage, setPercentage] = useState((value / max) * 100) const [animationValue, setAnimationValue] = useState(0) useEffect(() => { const target = (value / max) * 100 setAnimationValue(target) }, [value, max]) const sizeMap = { small: { width: 150, height: 100, strokeWidth: 8, fontSize: 24 }, medium: { width: 200, height: 140, strokeWidth: 10, fontSize: 32 }, large: { width: 300, height: 200, strokeWidth: 15, fontSize: 48 } } const s = sizeMap[size] // Calculate gauge angle (0-180 degrees) const startAngle = 0.75 * Math.PI const endAngle = 2.25 * Math.PI const currentAngle = startAngle + (endAngle - startAngle) * (animationValue / 100) const x1 = s.width / 2 + (s.width / 2 - 10) * Math.cos(startAngle) const y1 = s.height / 2 + (s.height / 2 - 10) * Math.sin(startAngle) const x2 = s.width / 2 + (s.width / 2 - 10) * Math.cos(currentAngle) const y2 = s.height / 2 + (s.height / 2 - 10) * Math.sin(currentAngle) return (