import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}

export function formatDateTime(date: string | Date | number, format: 'full' | 'date' | 'time' = 'full') {
  const d = new Date(date);
  
  const options: Intl.DateTimeFormatOptions = {
    day: '2-digit',
    month: 'short',
    year: 'numeric',
  };

  if (format === 'full' || format === 'time') {
    options.hour = '2-digit';
    options.minute = '2-digit';
    options.hour12 = true;
  }

  if (format === 'time') {
    return d.toLocaleTimeString('en-IN', { hour: '2-digit', minute: '2-digit', hour12: true });
  }

  if (format === 'full') {
    return d.toLocaleString('en-IN', options);
  }

  return d.toLocaleDateString('en-IN', options);
}
