import { ExternalLink as ExternalLinkIcon } from 'lucide-react';
import type { ComponentProps } from 'react';
import { cn } from '@/lib/utils';

type Props = Omit<ComponentProps<'a'>, 'target' | 'rel'> & {
    href: string;
};

/**
 * A link that leaves the admin panel: to the public site, the log viewer or
 * another website. Those are separate front ends, so this is a plain <a>
 * opening in a new tab — never an Inertia <Link>.
 */
export function ExternalLink({ className, children, ...props }: Props) {
    return (
        <a
            {...props}
            target="_blank"
            rel="noopener noreferrer"
            className={cn(
                'inline-flex items-center gap-1 underline decoration-neutral-300 underline-offset-4 transition-colors hover:decoration-current dark:decoration-neutral-500',
                className,
            )}
        >
            {children}
            <ExternalLinkIcon
                aria-hidden="true"
                className="size-3.5 shrink-0"
            />
            <span className="sr-only"> (yeni sekmede açılır)</span>
        </a>
    );
}
