import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } export const formatDate = (date: Date) => date.toLocaleString("en-EN", { year: "numeric", month: "short", day: "numeric", hour: "numeric", minute: "numeric", }); export const getBaseUrl = () => { if (typeof window !== "undefined") return window.location.origin; if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`; return `http://localhost:${process.env.PORT ?? 3000}`; }; export const debounce = any>( callback: T, waitFor: number, ) => { let timeout: ReturnType; return (...args: Parameters): ReturnType => { let result: any; timeout && clearTimeout(timeout); timeout = setTimeout(() => { result = callback(...args); }, waitFor); return result; }; };