import { jsx } from 'react/jsx-runtime';
import React__default, { useMemo } from 'react';
import { useReducedMotion, motion } from 'motion/react';
import { buttonTheme } from '../Button/Button.theme.js';
import { cn } from '../../../utils/cn.js';

const Link = React__default.forwardRef(({ children, className = "", size = "inherit", disabled = false, href, 
// Destructure motion-conflicting props to avoid type issues
onAnimationStart: _onAnimationStart, onAnimationEnd: _onAnimationEnd, onDrag: _onDrag, onDragStart: _onDragStart, onDragEnd: _onDragEnd, ...props }, ref) => {
    const shouldReduceMotion = useReducedMotion();
    const color = "primary"; // Default to primary, can be overridden by className
    // A link is essentially a button with variant="link"
    const resolvedVariant = "link";
    // Memoize theme classes for performance
    const themeClasses = useMemo(() => {
        var _a, _b, _c, _d, _e, _f;
        const sizeClasses = size === "inherit"
            ? "h-fit"
            : ((_b = (_a = buttonTheme.sizes) === null || _a === void 0 ? void 0 : _a[size]) === null || _b === void 0 ? void 0 : _b[resolvedVariant]) || "";
        const colorClasses = ((_d = (_c = buttonTheme.variantColors) === null || _c === void 0 ? void 0 : _c[resolvedVariant]) === null || _d === void 0 ? void 0 : _d[color]) || "";
        const variantClasses = ((_e = buttonTheme.variantStyles) === null || _e === void 0 ? void 0 : _e[resolvedVariant]) || "";
        const stateClasses = disabled ? ((_f = buttonTheme.states) === null || _f === void 0 ? void 0 : _f.disabled) || "" : "";
        return {
            sizeClasses,
            colorClasses,
            variantClasses,
            stateClasses,
        };
    }, [size, color, disabled]);
    const animationProps = useMemo(() => shouldReduceMotion
        ? {}
        : {
            whileHover: { scale: 1.02 },
            whileTap: { scale: 0.98 },
        }, [shouldReduceMotion]);
    return (jsx(motion.a, { ref: ref, href: disabled ? undefined : href, className: cn(buttonTheme.baseStyle, themeClasses.colorClasses, themeClasses.variantClasses, themeClasses.sizeClasses, themeClasses.stateClasses, 
        // Special case for link variant to have an underline
        "underline underline-offset-4 rounded-none font-semibold", className), "data-color": color, "data-variant": resolvedVariant, "data-size": size, "aria-disabled": disabled || undefined, ...(disabled ? {} : animationProps), ...props, children: children }));
});
Link.displayName = "Link";

export { Link };
