import { Chip } from '@mui/material'
import { CheckCircle2, MinusCircle } from 'lucide-react'
import type { MarketSignal } from '../../domain/marketSignal'
import { SignalProcessingStatus } from '../../domain/marketSignal'
import { SensitivityLevel } from '../../domain/enums'

interface FeedEligibilityBadgeProps {
  signal: MarketSignal
}

export function FeedEligibilityBadge({ signal }: FeedEligibilityBadgeProps) {
  const ELIGIBLE_STATUSES: SignalProcessingStatus[] = [
    SignalProcessingStatus.APPROVED_AS_SIGNAL,
    SignalProcessingStatus.CONVERTED_TO_FUTURE_AVAILABILITY,
  ]
  const BLOCKING_SENSITIVITY: SensitivityLevel[] = [
    SensitivityLevel.CONFIDENTIAL,
    SensitivityLevel.RESTRICTED,
  ]

  const isEligible =
    ELIGIBLE_STATUSES.includes(signal.processingStatus) &&
    !BLOCKING_SENSITIVITY.includes(signal.sensitivityLevel)

  if (isEligible) {
    return (
      <Chip
        size="small"
        label="Feed-fähig"
        icon={<CheckCircle2 size={11} color="#15803d" />}
        sx={{
          bgcolor: 'rgba(22,163,74,0.1)',
          color: '#15803d',
          border: 'none',
          fontSize: '0.7rem',
          fontWeight: 600,
          '& .MuiChip-icon': { ml: 0.75 },
        }}
      />
    )
  }

  return (
    <Chip
      size="small"
      label="Nicht Feed-fähig"
      icon={<MinusCircle size={11} color="#64748b" />}
      sx={{
        bgcolor: 'rgba(148,163,184,0.1)',
        color: '#64748b',
        border: 'none',
        fontSize: '0.7rem',
        fontWeight: 600,
        '& .MuiChip-icon': { ml: 0.75 },
      }}
    />
  )
}
