import { clsx, type ClassValue } from "clsx" import { twMerge } from "tailwind-merge" export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } // Cache de performance const perfCache = new Map() // Debounce utility export function debounce any>( func: T, wait: number ): (...args: Parameters) => void { let timeout: NodeJS.Timeout return (...args: Parameters) => { clearTimeout(timeout) timeout = setTimeout(() => func(...args), wait) } } // Memoização para cálculos pesados export function memoize any>( func: T, resolver?: (...args: Parameters) => string ): T { const cache = new Map>() return ((...args: Parameters) => { const key = resolver ? resolver(...args) : JSON.stringify(args) if (cache.has(key)) { return cache.get(key) } const result = func(...args) cache.set(key, result) return result }) as T } // Medição de performance export function measurePerformance(key: string, callback: () => void) { const start = performance.now() callback() const end = performance.now() perfCache.set(key, end - start) }