import { cn } from "./index3.js";
import { Button } from "./index6.js";
import { cva } from "class-variance-authority";
import { AlertCircle, AlertTriangle, CheckCircle, Info, X } from "lucide-react";
import * as React from "react";
import { jsx, jsxs } from "react/jsx-runtime";
//#region src/components/molecules/feedback/Alert/Alert.tsx
var alertVariants = cva("relative flex gap-3 rounded-lg px-4 py-3 text-sm motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-1 [&>svg]:shrink-0 [&>svg]:size-4 [&>svg]:mt-0.5 [&>svg]:motion-safe:animate-in [&>svg]:motion-safe:fade-in-0 [&>svg]:motion-safe:zoom-in-75 [&>svg]:motion-safe:duration-300 [&>svg]:motion-safe:delay-75", {
	variants: {
		appearance: {
			outline: "bg-card border",
			solid: "",
			soft: ""
		},
		variant: {
			default: "",
			info: "",
			success: "",
			warning: "",
			destructive: ""
		}
	},
	compoundVariants: [
		{
			appearance: "outline",
			variant: "default",
			className: "border-border text-card-foreground [&>svg]:text-muted-foreground"
		},
		{
			appearance: "outline",
			variant: "info",
			className: "border-info text-info [&>svg]:text-info"
		},
		{
			appearance: "outline",
			variant: "success",
			className: "border-success text-success [&>svg]:text-success"
		},
		{
			appearance: "outline",
			variant: "warning",
			className: "border-warning text-warning [&>svg]:text-warning"
		},
		{
			appearance: "outline",
			variant: "destructive",
			className: "border-destructive text-destructive [&>svg]:text-destructive"
		},
		{
			appearance: "solid",
			variant: "default",
			className: "bg-primary text-primary-foreground [&>svg]:text-primary-foreground"
		},
		{
			appearance: "solid",
			variant: "info",
			className: "bg-info text-info-foreground [&>svg]:text-info-foreground"
		},
		{
			appearance: "solid",
			variant: "success",
			className: "bg-success text-success-foreground [&>svg]:text-success-foreground"
		},
		{
			appearance: "solid",
			variant: "warning",
			className: "bg-warning text-warning-foreground [&>svg]:text-warning-foreground"
		},
		{
			appearance: "solid",
			variant: "destructive",
			className: "bg-destructive text-destructive-foreground [&>svg]:text-destructive-foreground"
		},
		{
			appearance: "soft",
			variant: "default",
			className: "bg-primary/10 text-card-foreground [&>svg]:text-primary dark:bg-primary/20"
		},
		{
			appearance: "soft",
			variant: "info",
			className: "bg-info/10 text-info [&>svg]:text-info dark:bg-info/20"
		},
		{
			appearance: "soft",
			variant: "success",
			className: "bg-success/10 text-success [&>svg]:text-success dark:bg-success/20"
		},
		{
			appearance: "soft",
			variant: "warning",
			className: "bg-warning/10 text-warning [&>svg]:text-warning dark:bg-warning/20"
		},
		{
			appearance: "soft",
			variant: "destructive",
			className: "bg-destructive/10 text-destructive [&>svg]:text-destructive dark:bg-destructive/20"
		}
	],
	defaultVariants: {
		appearance: "outline",
		variant: "default"
	}
});
/** Default icon mapping for each variant */
var defaultIcons = {
	default: /* @__PURE__ */ jsx(AlertCircle, {}),
	info: /* @__PURE__ */ jsx(Info, {}),
	success: /* @__PURE__ */ jsx(CheckCircle, {}),
	warning: /* @__PURE__ */ jsx(AlertTriangle, {}),
	destructive: /* @__PURE__ */ jsx(AlertTriangle, {})
};
/** Maps alert variant to button variant for soft/outline appearances */
var alertToButtonVariant = {
	default: "secondary",
	info: "info",
	success: "success",
	warning: "warning",
	destructive: "destructive"
};
/** Maps alert variant to button variant for soft appearance (uses primary for default) */
var alertToSolidButtonVariant = {
	default: "primary",
	info: "info",
	success: "success",
	warning: "warning",
	destructive: "destructive"
};
/** Maps alert variant to text color class */
var variantTextClass = {
	default: "text-primary",
	info: "text-info",
	success: "text-success",
	warning: "text-warning",
	destructive: "text-destructive"
};
var Alert = React.forwardRef(({ className, appearance = "outline", variant = "default", title, description, icon, closable = false, onClose, action, children, dismissDuration = 200, ...props }, ref) => {
	const [dismissing, setDismissing] = React.useState(false);
	const internalRef = React.useRef(null);
	const resolvedVariant = variant ?? "default";
	React.useImperativeHandle(ref, () => internalRef.current);
	const iconElement = icon !== false ? icon || defaultIcons[resolvedVariant] : null;
	const handleClose = React.useCallback(() => {
		if (dismissDuration <= 0) {
			onClose?.();
			return;
		}
		if ((internalRef.current?.ownerDocument.defaultView)?.matchMedia("(prefers-reduced-motion: reduce)").matches ?? false) {
			onClose?.();
			return;
		}
		setDismissing(true);
	}, [dismissDuration, onClose]);
	const getActionButtonProps = () => {
		if (appearance === "solid") return {
			appearance: "outline",
			variant: "secondary",
			className: cn("bg-background/90 border-background/20 hover:bg-background", variantTextClass[resolvedVariant])
		};
		if (appearance === "soft") return {
			appearance: "solid",
			variant: alertToSolidButtonVariant[resolvedVariant]
		};
		return {
			appearance: "outline",
			variant: alertToButtonVariant[resolvedVariant]
		};
	};
	const alertRole = resolvedVariant === "destructive" || resolvedVariant === "warning" ? "alert" : "status";
	const getCloseButtonClass = () => {
		if (appearance === "solid") return "text-current/80 hover:text-current hover:bg-current/10";
		if (appearance === "outline" || resolvedVariant === "default") return "text-muted-foreground hover:text-foreground hover:bg-muted";
		return cn("hover:bg-current/10", variantTextClass[resolvedVariant]);
	};
	return /* @__PURE__ */ jsxs("div", {
		ref: internalRef,
		role: alertRole,
		"data-slot": "alert",
		"data-dismissing": dismissing || void 0,
		className: cn(alertVariants({
			appearance,
			variant
		}), dismissing && "motion-safe:animate-out motion-safe:fade-out-0 motion-safe:slide-out-to-right-2", className),
		style: dismissing ? { animationDuration: `${dismissDuration}ms` } : void 0,
		onAnimationEnd: (e) => {
			if (dismissing && e.target === e.currentTarget) onClose?.();
		},
		...props,
		children: [
			iconElement,
			/* @__PURE__ */ jsxs("div", {
				className: "flex flex-1 flex-col gap-0.5 min-w-0",
				children: [
					title && /* @__PURE__ */ jsx(AlertTitle, { children: title }),
					description && /* @__PURE__ */ jsx(AlertDescription, { children: description }),
					children
				]
			}),
			action && /* @__PURE__ */ jsx(Button, {
				size: "xs",
				shape: "rounded",
				onClick: action.onClick,
				...getActionButtonProps(),
				...action.props,
				children: action.label
			}),
			closable && /* @__PURE__ */ jsx("button", {
				type: "button",
				onClick: handleClose,
				className: cn("relative shrink-0 size-6 inline-flex items-center justify-center rounded transition-all duration-200 ease-smooth motion-reduce:transition-none", "after:absolute after:inset-[-10px] after:content-[\"\"]", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none", "active:scale-90 motion-reduce:active:scale-100", getCloseButtonClass()),
				"aria-label": "Dismiss alert",
				children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
			})
		]
	});
});
Alert.displayName = "Alert";
/** Alert title component */
var AlertTitle = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx("h5", {
	ref,
	"data-slot": "alert-title",
	className: cn("font-medium leading-5", className),
	...props,
	children
}));
AlertTitle.displayName = "AlertTitle";
/** Alert description component */
var AlertDescription = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx("p", {
	ref,
	"data-slot": "alert-description",
	className: cn("text-sm leading-5 opacity-80", className),
	...props,
	children
}));
AlertDescription.displayName = "AlertDescription";
//#endregion
export { Alert, AlertDescription, AlertTitle, alertVariants };

//# sourceMappingURL=index379.js.map