import { cn } from "../../utils/cn.mjs";
import { ExternalLink, MoveRight } from "lucide-react";
import { cva } from "class-variance-authority";
import { jsx, jsxs } from "react/jsx-runtime";
import { getLocalizedUrl } from "@intlayer/core";

//#region src/components/Link/Link.tsx
/**
* Visual style variants for Link component
*
* @enum {string}
*/
let LinkVariant = /* @__PURE__ */ function(LinkVariant$1) {
	/** Default underlined link with hover effects */
	LinkVariant$1["DEFAULT"] = "default";
	/** Link without visible underline or hover effects */
	LinkVariant$1["INVISIBLE_LINK"] = "invisible-link";
	/** Button-styled link with solid background */
	LinkVariant$1["BUTTON"] = "button";
	/** Button-styled link with outlined border */
	LinkVariant$1["BUTTON_OUTLINED"] = "button-outlined";
	/** Link with subtle hover background effect */
	LinkVariant$1["HOVERABLE"] = "hoverable";
	return LinkVariant$1;
}({});
/**
* Color theme variants for Link component
*
* @enum {string}
*/
let LinkColor = /* @__PURE__ */ function(LinkColor$1) {
	/** Primary brand color */
	LinkColor$1["PRIMARY"] = "primary";
	/** Secondary brand color */
	LinkColor$1["SECONDARY"] = "secondary";
	/** Destructive/danger color for critical actions */
	LinkColor$1["DESTRUCTIVE"] = "destructive";
	/** Neutral/muted color for less prominent links */
	LinkColor$1["NEUTRAL"] = "neutral";
	/** Light color for dark backgrounds */
	LinkColor$1["LIGHT"] = "light";
	/** Dark color for light backgrounds */
	LinkColor$1["DARK"] = "dark";
	/** Default text color */
	LinkColor$1["TEXT"] = "text";
	/** Inverse text color for opposite backgrounds */
	LinkColor$1["TEXT_INVERSE"] = "text-inverse";
	/** Error/red color for error states */
	LinkColor$1["ERROR"] = "error";
	/** Success/green color for positive actions */
	LinkColor$1["SUCCESS"] = "success";
	/** Custom color - no default styling applied */
	LinkColor$1["CUSTOM"] = "custom";
	return LinkColor$1;
}({});
/** Available rounded corner sizes for the container */
let LinkRoundedSize = /* @__PURE__ */ function(LinkRoundedSize$1) {
	LinkRoundedSize$1["NONE"] = "none";
	LinkRoundedSize$1["SM"] = "sm";
	LinkRoundedSize$1["MD"] = "md";
	LinkRoundedSize$1["LG"] = "lg";
	LinkRoundedSize$1["XL"] = "xl";
	LinkRoundedSize$1["TWO_XL"] = "2xl";
	LinkRoundedSize$1["THREE_XL"] = "3xl";
	LinkRoundedSize$1["FULL"] = "full";
	return LinkRoundedSize$1;
}({});
let LinkSize = /* @__PURE__ */ function(LinkSize$1) {
	LinkSize$1["SM"] = "sm";
	LinkSize$1["MD"] = "md";
	LinkSize$1["LG"] = "lg";
	LinkSize$1["XL"] = "xl";
	LinkSize$1["CUSTOM"] = "custom";
	return LinkSize$1;
}({});
/**
* Underline style options for Link component
*
* @enum {string}
*/
let LinkUnderlined = /* @__PURE__ */ function(LinkUnderlined$1) {
	/** Default underline behavior based on variant */
	LinkUnderlined$1["DEFAULT"] = "default";
	/** Always show underline */
	LinkUnderlined$1["TRUE"] = "true";
	/** Never show underline */
	LinkUnderlined$1["FALSE"] = "false";
	return LinkUnderlined$1;
}({});
/**
* Class variance authority configuration for Link component styling
* Defines the visual appearance based on variant, color, and underline options
*/
const linkVariants = cva("gap-3 transition-all duration-300 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50", {
	variants: {
		variant: {
			[`${LinkVariant.DEFAULT}`]: "h-auto justify-start border-inherit bg-current/0 px-1 underline-offset-4 hover:bg-current/0 hover:underline",
			[`${LinkVariant.INVISIBLE_LINK}`]: "h-auto justify-start border-inherit bg-current/0 px-1 underline-offset-4 hover:bg-current/0",
			[`${LinkVariant.BUTTON}`]: "relative flex cursor-pointer flex-row items-center justify-center gap-2 rounded-full bg-current text-center font-medium text-text ring-0 *:text-text-opposite hover:bg-current/90 hover:ring-5 aria-selected:ring-5",
			[`${LinkVariant.BUTTON_OUTLINED}`]: "relative flex cursor-pointer flex-row items-center justify-center gap-2 rounded-full border-[1.3px] border-current text-center font-medium text-text ring-0 *:text-text hover:bg-current/20 hover:ring-5 aria-selected:ring-5",
			[`${LinkVariant.HOVERABLE}`]: "block rounded-lg border-none bg-current/0 hover:bg-current/10 aria-[current]:bg-current/5"
		},
		roundedSize: {
			[`${LinkRoundedSize.NONE}`]: "rounded-none",
			[`${LinkRoundedSize.SM}`]: "rounded-lg [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-xl",
			[`${LinkRoundedSize.MD}`]: "rounded-xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-2xl",
			[`${LinkRoundedSize.LG}`]: "rounded-2xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-3xl",
			[`${LinkRoundedSize.XL}`]: "rounded-3xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-4xl",
			[`${LinkRoundedSize.TWO_XL}`]: "rounded-4xl [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[2.5rem]",
			[`${LinkRoundedSize.THREE_XL}`]: "rounded-[2.5rem] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[3rem]",
			[`${LinkRoundedSize.FULL}`]: "rounded-full"
		},
		color: {
			[`${LinkColor.PRIMARY}`]: "text-primary",
			[`${LinkColor.SECONDARY}`]: "text-secondary",
			[`${LinkColor.DESTRUCTIVE}`]: "text-destructive",
			[`${LinkColor.NEUTRAL}`]: "text-neutral",
			[`${LinkColor.LIGHT}`]: "text-white",
			[`${LinkColor.DARK}`]: "text-neutral-800",
			[`${LinkColor.TEXT}`]: "text-text",
			[`${LinkColor.TEXT_INVERSE}`]: "text-text-opposite",
			[`${LinkColor.ERROR}`]: "text-error",
			[`${LinkColor.SUCCESS}`]: "text-success",
			[`${LinkColor.CUSTOM}`]: ""
		},
		size: {
			[`${LinkSize.SM}`]: "text-sm",
			[`${LinkSize.MD}`]: "text-base",
			[`${LinkSize.LG}`]: "text-lg",
			[`${LinkSize.XL}`]: "text-xl",
			[`${LinkSize.CUSTOM}`]: ""
		},
		underlined: {
			[LinkUnderlined.DEFAULT]: "",
			[LinkUnderlined.TRUE]: "underline",
			[LinkUnderlined.FALSE]: "no-underline"
		}
	},
	compoundVariants: [
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			size: LinkSize.SM,
			class: "min-h-7 px-3 max-md:py-1"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			size: LinkSize.MD,
			class: "min-h-8 px-6 max-md:py-2"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			size: LinkSize.LG,
			class: "min-h-10 px-8 max-md:py-3"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			size: LinkSize.XL,
			class: "min-h-11 px-10 max-md:py-4"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			color: LinkColor.PRIMARY,
			class: "ring-primary/20"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			color: LinkColor.SECONDARY,
			class: "ring-secondary/20"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			color: LinkColor.DESTRUCTIVE,
			class: "ring-destructive/20"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			color: LinkColor.NEUTRAL,
			class: "ring-neutral/20"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			color: LinkColor.LIGHT,
			class: "ring-white/20"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			color: LinkColor.DARK,
			class: "ring-neutral-800/20"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			color: LinkColor.TEXT,
			class: "ring-text/20"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			color: LinkColor.TEXT_INVERSE,
			class: "ring-text-opposite/20"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			color: LinkColor.ERROR,
			class: "ring-error/20"
		},
		{
			variant: [LinkVariant.BUTTON, LinkVariant.BUTTON_OUTLINED],
			color: LinkColor.SUCCESS,
			class: "ring-success/20"
		}
	],
	defaultVariants: {
		variant: LinkVariant.DEFAULT,
		color: LinkColor.PRIMARY,
		roundedSize: LinkRoundedSize.MD,
		underlined: LinkUnderlined.DEFAULT,
		size: LinkSize.MD
	}
});
/**
* Utility function to determine if a link should be treated as external
*
* @param props - Link component props containing href and isExternalLink
* @returns {boolean} True if the link should open externally
*
* @example
* ```tsx
* checkIsExternalLink({ href: '[https://example.com](https://example.com)' }) // true
* checkIsExternalLink({ href: '/internal-page' }) // false
* checkIsExternalLink({ href: '/page', isExternalLink: true }) // true
* ```
*/
const checkIsExternalLink = ({ href, isExternalLink: isExternalLinkProp }) => {
	const isValidHref = typeof href === "string" && href.trim() !== "";
	return isExternalLinkProp === true || typeof isExternalLinkProp === "undefined" && isValidHref && /^https?:\/\//.test(href);
};
/**
* Link Component
*
* A versatile link component that handles both internal and external navigation
* with comprehensive internationalization support and multiple visual variants.
* ...
*/
const Link = (props) => {
	const { variant = LinkVariant.DEFAULT, color = LinkColor.PRIMARY, roundedSize, children, label, className, isActive, underlined, locale, size, isExternalLink: isExternalLinkProp, isPageSection: isPageSectionProp, href: hrefProp, ...otherProps } = props;
	const isExternalLink = isExternalLinkProp ?? checkIsExternalLink(props);
	const isPageSection = isPageSectionProp ?? hrefProp?.startsWith("#") ?? false;
	const isChildrenString = typeof children === "string";
	const rel = isExternalLink ? "noopener noreferrer nofollow" : void 0;
	const target = isExternalLink ? "_blank" : "_self";
	return /* @__PURE__ */ jsxs("a", {
		href: locale && hrefProp && !isExternalLink && !isPageSection ? getLocalizedUrl(hrefProp, locale) : hrefProp,
		"aria-label": label,
		rel,
		target,
		"aria-current": isActive ? "page" : void 0,
		className: cn(linkVariants({
			variant,
			color,
			roundedSize,
			underlined,
			size,
			className
		})),
		...otherProps,
		children: [
			children,
			isExternalLink && isChildrenString && /* @__PURE__ */ jsx(ExternalLink, { className: "ml-2 inline-block size-4" }),
			isPageSection && /* @__PURE__ */ jsx(MoveRight, { className: "ml-2 inline-block size-4" })
		]
	});
};

//#endregion
export { Link, LinkColor, LinkRoundedSize, LinkSize, LinkUnderlined, LinkVariant, checkIsExternalLink, linkVariants };
//# sourceMappingURL=Link.mjs.map