import NextLink, { type LinkProps as NextLinkProps } from 'next/link'
import { type ComponentProps } from 'react'

import { Slot } from 'radix-ui'

import { type RootStylesProps, rootStyles } from './Link.styles'

type LinkProps = ComponentProps<'a'> &
	NextLinkProps &
	RootStylesProps & {
		asChild?: boolean
	}

function Link({ asChild, size, disabled, className, ...props }: LinkProps) {
	const Comp = asChild ? Slot.Root : NextLink

	return (
		<Comp
			className={rootStyles({ size, disabled, className })}
			{...props}
		/>
	)
}

export { Link }
