import * as React from 'react';
import { cva, type VariantProps } from '@/lib/cva';

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

const badgeVariants = cva(
  'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-medium font-body transition-colors focus:outline-none focus:shadow-focus',
  {
    variants: {
      variant: {
        default: 'border-transparent bg-slate-900 text-white',
        secondary: 'border-transparent bg-slate-100 text-slate-700',
        destructive: 'border-transparent bg-error-muted text-error-text',
        outline: 'border-slate-300 text-slate-600',
        success: 'border-transparent bg-success-muted text-success-text',
        warning: 'border-transparent bg-warning-muted text-warning-text',
        error: 'border-transparent bg-error-muted text-error-text',
        info: 'border-transparent bg-info-muted text-info-text',
        trigger: 'border-transparent bg-trigger-muted text-trigger-text',
        action: 'border-transparent bg-action-muted text-action-text',
        operator: 'border-transparent bg-operator-muted text-operator-text',
      },
    },
    defaultVariants: {
      variant: 'default',
    },
  },
);

export interface BadgeProps
  extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}

function Badge({ className, variant, ...props }: BadgeProps) {
  return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
}

export { Badge, badgeVariants };
