"use client";

import { cn } from "@/lib/utils";

interface ConfidenceIndicatorProps {
  confidence: number;
  className?: string;
}

function getConfidenceLevel(confidence: number): "high" | "medium" | "low" {
  if (confidence >= 0.8) return "high";
  if (confidence >= 0.5) return "medium";
  return "low";
}

const confidenceColors = {
  high: "text-green-500",
  medium: "text-yellow-500",
  low: "text-red-500",
};

export function ConfidenceIndicator({ confidence, className }: ConfidenceIndicatorProps) {
  const level = getConfidenceLevel(confidence);
  const color = confidenceColors[level];
  const percentage = (confidence * 100).toFixed(0);

  return (
    <span className={cn("font-mono text-sm", color, className)}>
      {percentage}%
    </span>
  );
}
