import { Chip } from '@mui/material'
import { ShieldCheck, Globe, Sparkles } from 'lucide-react'
import type { ResultType } from '../../domain/enums'
import { RESULT_TYPE_LABELS } from '../../lib/constants'

interface SourceTypeBadgeProps {
  type: ResultType
  size?: 'small' | 'medium'
}

const CONFIG: Record<string, { bg: string; color: string; Icon: React.ElementType }> = {
  VERIFIED_PORTFOLIO:  { bg: 'rgba(30,58,95,0.1)',   color: '#1e3a5f', Icon: ShieldCheck },
  EXTERNAL_MARKET:     { bg: 'rgba(217,119,6,0.1)',  color: '#b45309', Icon: Globe },
  FUTURE_AVAILABILITY: { bg: 'rgba(124,58,237,0.1)', color: '#6d28d9', Icon: Sparkles },
}

export function SourceTypeBadge({ type, size = 'small' }: SourceTypeBadgeProps) {
  const { bg, color, Icon } = CONFIG[type] ?? { bg: '#f1f5f9', color: '#475569', Icon: Globe }
  return (
    <Chip
      icon={<Icon size={11} color={color} />}
      label={RESULT_TYPE_LABELS[type] ?? type}
      size={size}
      sx={{ bgcolor: bg, color, fontWeight: 600, border: 'none', '& .MuiChip-icon': { ml: 0.5 } }}
    />
  )
}
