import { GenericBadge } from '../shared/GenericBadge'
import type { AIOutputError } from '../../domain/aiOutput'

const ERROR_CONFIG: Record<string, { label: string; color: string }> = {
  SCHEMA_VALIDATION: { label: 'Schema',     color: '#ea580c' },
  PROVIDER_TIMEOUT:  { label: 'Timeout',    color: '#c0392b' },
  INVALID_JSON:      { label: 'JSON',       color: '#c0392b' },
  EMPTY_RESPONSE:    { label: 'Leer',       color: '#d97706' },
  RATE_LIMIT:        { label: 'Rate Limit', color: '#7c3aed' },
}

export function AIErrorBadge({ error }: { error: AIOutputError }) {
  const { label, color } = ERROR_CONFIG[error.type] ?? { label: error.type, color: '#c0392b' }
  return <GenericBadge label={label} color={color} bold tooltip={error.message} />
}
