export function formatCurrency(amount: number): string { return new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", }).format(amount); } export function formatPercentage(value: number): string { return `${(value * 100).toFixed(1)}%`; } export function formatDate(date: string | Date | null): string { if (!date) return "N/A"; return new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric", year: "numeric", hour: "2-digit", minute: "2-digit", }).format(new Date(date)); } export function formatDuration(seconds: number): string { if (seconds < 60) return `${seconds}s`; if (seconds < 3600) return `${Math.floor(seconds / 60)}m ${seconds % 60}s`; const hours = Math.floor(seconds / 3600); const minutes = Math.floor((seconds % 3600) / 60); return `${hours}h ${minutes}m`; } export function getConfidenceColor(confidence: number): string { if (confidence >= 0.8) return "text-[#14F195]"; if (confidence >= 0.5) return "text-[#00F5FF]"; if (confidence >= 0.3) return "text-[#B87333]"; return "text-red-400"; } export function getStatusColor(status: string): string { const colors: Record = { pending: "text-yellow-400", analyzing: "text-[#00F5FF]", negotiating: "text-[#9945FF]", approved: "text-[#14F195]", rejected: "text-red-400", transacting: "text-[#B87333]", completed: "text-[#14F195]", failed: "text-red-400", queued: "text-yellow-400", running: "text-[#00F5FF]", cancelled: "text-gray-400", }; return colors[status] || "text-gray-400"; } export function getStatusBg(status: string): string { const colors: Record = { pending: "bg-yellow-400/10", analyzing: "bg-[#00F5FF]/10", negotiating: "bg-[#9945FF]/10", approved: "bg-[#14F195]/10", rejected: "bg-red-400/10", transacting: "bg-[#B87333]/10", completed: "bg-[#14F195]/10", failed: "bg-red-400/10", queued: "bg-yellow-400/10", running: "bg-[#00F5FF]/10", cancelled: "bg-gray-400/10", }; return colors[status] || "bg-gray-400/10"; } export function truncate(str: string, length: number): string { if (str.length <= length) return str; return str.slice(0, length) + "..."; } export function extractDomain(url: string): string { try { return new URL(url).hostname.replace("www.", ""); } catch { return url; } } export function cn(...classes: (string | false | undefined | null)[]): string { return classes.filter(Boolean).join(" "); } export function calculateROI(buyPrice: number, sellPrice: number): number { if (buyPrice === 0) return 0; return (sellPrice - buyPrice) / buyPrice; } export function generateId(): string { return Math.random().toString(36).substring(2) + Date.now().toString(36); }