import { type ClassValue, clsx } from "clsx" import { twMerge } from "tailwind-merge" /** * Merge Tailwind classes with clsx */ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } /** * Format price */ export function formatPrice(price: number | string, currency: string = 'USD'): string { const numPrice = typeof price === 'string' ? parseFloat(price) : price; return new Intl.NumberFormat('en-US', { style: 'currency', currency: currency, }).format(numPrice); } /** * Format date */ export function formatDate(date: string | Date): string { const dateObj = typeof date === 'string' ? new Date(date) : date; return new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric', }).format(dateObj); } /** * Debounce function */ export function debounce any>( func: T, wait: number ): (...args: Parameters) => void { let timeout: ReturnType; return function executedFunction(...args: Parameters) { const later = () => { clearTimeout(timeout); func(...args); }; clearTimeout(timeout); timeout = setTimeout(later, wait); }; }