// ─────────────────────────────────────────────────────────────────────────────
// General-purpose utility helpers
//
// Exposes a single `cn()` function that merges Tailwind class names while
// resolving conflicts (last-wins) and filtering falsy values.
// ─────────────────────────────────────────────────────────────────────────────

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

/**
 * Merge Tailwind CSS class names intelligently.
 *
 * Combines `clsx` (conditional class joining) with `tailwind-merge` (conflict
 * resolution – e.g. `px-2` + `px-4` → `px-4`).
 *
 * @param inputs - Class values (strings, objects, arrays, falsy values…).
 * @returns      A single merged class string.
 *
 * @example
 *   cn("px-2", isActive && "bg-blue-500", ["text-sm"])  // → "px-2 bg-blue-500 text-sm"
 */
export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}
