import { Chip } from '@mui/material'
import { CheckCircle2, Clock, Sparkles, XCircle, HelpCircle } from 'lucide-react'
import type { AvailabilityStatus } from '../../domain/enums'
import { DS_COLORS } from '../../lib/ds'
import { AVAILABILITY_LABELS } from '../../lib/constants'

interface AvailabilityBadgeProps {
  status: AvailabilityStatus
  size?: 'small' | 'medium'
}

const ICONS: Record<AvailabilityStatus, React.ElementType> = {
  AVAILABLE_NOW:  CheckCircle2,
  AVAILABLE_SOON: Clock,
  FUTURE_SIGNAL:  Sparkles,
  OCCUPIED:       XCircle,
  UNKNOWN:        HelpCircle,
}

export function AvailabilityBadge({ status, size = 'small' }: AvailabilityBadgeProps) {
  const { bg, fg } = DS_COLORS.availability[status]
  const Icon = ICONS[status]
  return (
    <Chip
      size={size}
      label={AVAILABILITY_LABELS[status] ?? status}
      icon={<Icon size={11} color={fg} />}
      aria-label={`Verfügbarkeit: ${AVAILABILITY_LABELS[status] ?? status}`}
      sx={{
        bgcolor: bg,
        color: fg,
        border: 'none',
        fontWeight: 600,
        fontSize: '0.7rem',
        '& .MuiChip-icon': { ml: 0.5 },
      }}
    />
  )
}
