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

/**
 * The font sizes and shadows the theme adds (`text-page-title`,
 * `shadow-large`, see styles/theme.css). tailwind-merge has to be told: it
 * would otherwise read `text-page-title` as a text colour and drop it beside
 * `text-foreground`, and keep `shadow-large` beside the `shadow-sm` it is
 * meant to replace. The dashboard's utils.test.ts fails when a name is in the
 * theme and not here.
 */
export const DESIGN_SYSTEM_TEXT_SIZES = [
  "page-title",
  "page-title-phone",
  "section-title",
  "card-title",
  "figure",
  "figure-lg",
  "ui-text",
  "ui-small",
  "ui-caption",
  "ui-overline",
] as const;

export const DESIGN_SYSTEM_SHADOWS = [
  "medium",
  "large",
  "blue-pricing",
  "mobile",
  "blue-mobile",
] as const;

const twMerge = extendTailwindMerge({
  extend: {
    theme: {
      text: [...DESIGN_SYSTEM_TEXT_SIZES],
      shadow: [...DESIGN_SYSTEM_SHADOWS],
    },
  },
});

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