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

/**
 * Merges class names, letting later Tailwind utilities win over earlier ones.
 *
 * Without `twMerge`, `cn('p-2', 'p-4')` emits both and the winner depends on
 * stylesheet order — which is exactly the kind of bug that only shows up in
 * production builds.
 */
export function cn(...inputs: ClassValue[]): string {
  return twMerge(clsx(inputs));
}
