import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); }; /** * Convierte una ruta relativa del backend en una URL completa * @param path Ruta relativa (ej: "/uploads/avatars/file.png") * @returns URL completa del backend (ej: "http://localhost:8000/uploads/avatars/file.png") */ export function getBackendAssetUrl(path: string | null | undefined): string { if (!path) return ''; // Si ya es una URL completa, retornarla tal cual if (path.startsWith('http://') || path.startsWith('https://')) { return path; } // Eliminar la / inicial si existe para evitar // const cleanPath = path.startsWith('/') ? path.slice(1) : path; // Obtener la base URL del API y limpiar el / final si existe let baseUrl = import.meta.env.VITE_API_URL || 'http://localhost:8000'; baseUrl = baseUrl.replace(/\/+$/, ''); // Eliminar todas las / del final return `${baseUrl}/${cleanPath}`; } // eslint-disable-next-line @typescript-eslint/no-explicit-any export type WithoutChild = T extends { child?: any } ? Omit : T; // eslint-disable-next-line @typescript-eslint/no-explicit-any export type WithoutChildren = T extends { children?: any } ? Omit : T; export type WithoutChildrenOrChild = WithoutChildren>; export type WithElementRef = T & { ref?: U | null };