import type { NuzlockeRules } from '../types'
import { RULE_DEFINITIONS } from '../types/rules'

interface RuleBadgesProps {
  rules: NuzlockeRules
}

export function RuleBadges({ rules }: RuleBadgesProps) {
  const enabledRules = RULE_DEFINITIONS.filter((def) => rules[def.key])

  if (enabledRules.length === 0) {
    return <span className="text-sm text-text-tertiary">No rules enabled</span>
  }

  return (
    <div className="flex flex-wrap gap-1.5">
      {enabledRules.map((def) => (
        <span
          key={def.key}
          title={def.description}
          className={`px-2 py-0.5 rounded-full text-xs font-medium ${
            def.category === 'core'
              ? 'bg-blue-900/40 text-blue-300 light:bg-blue-100 light:text-blue-700'
              : 'bg-purple-900/40 text-purple-300 light:bg-purple-100 light:text-purple-700'
          }`}
        >
          {def.name}
        </span>
      ))}
    </div>
  )
}
