export default function (...args: any[]): string {
    const routes = (window as any).Laravel?.routes || {};
    const name = args.shift();

    if (routes[name] === undefined) {
        console.error('Route not found ', name);
        throw new Error(`Route not found: ${String(name)}`);
    }

    const prefixSlash = routes[name] !== '/' ? '/' : '';

    return (window as any).Laravel.baseUrl + prefixSlash + routes[name]
        .split('/')
        .map((s: string) => s[0] === '{' ? args.shift() : s)
        .join('/');
}
