"use client";

import { cn } from "@/lib/utils";
import { type SourceTier, tierColors } from "./constants";

interface SourceTierBadgeProps {
  tier: number;
  size?: "sm" | "xs";
}

export function SourceTierBadge({ tier, size = "sm" }: SourceTierBadgeProps) {
  const safeTier = (tier >= 0 && tier <= 5 ? tier : 5) as SourceTier;

  return (
    <span
      className={cn(
        "font-mono font-semibold rounded border",
        tierColors[safeTier],
        size === "sm" ? "px-1.5 py-0.5 text-xs" : "px-1 py-0.5 text-[10px]"
      )}
    >
      T{safeTier}
    </span>
  );
}
