import { Progress, Box } from "@mantine/core" export interface ProgressBarProps { value: number max?: number buffer?: number showValue?: boolean animated?: boolean indeterminate?: boolean label?: string size?: "sm" | "md" | "lg" color?: "primary" | "success" | "warning" | "destructive" className?: string } const colorMap: Record, string> = { primary: "blue", success: "green", warning: "yellow", destructive: "red", } const sizeMap: Record, number> = { sm: 4, md: 8, lg: 12, } export function ProgressBar({ value, max = 100, buffer, showValue = false, animated = false, indeterminate = false, size = "md", color = "primary", label, className, }: ProgressBarProps) { const percentage = Math.min(100, Math.max(0, (value / max) * 100)) const bufferPercentage = buffer ? Math.min(100, Math.max(0, (buffer / max) * 100)) : undefined const mantineColor = colorMap[color] const mantineSize = sizeMap[size] if (bufferPercentage !== undefined) { return ( {showValue && !indeterminate && ( {Math.round(percentage)}% )} ) } return ( {showValue && !indeterminate && ( {Math.round(percentage)}% )} ) }