import { cn } from "./index3.js";
import { useThemeOptional } from "./index35.js";
import { NotificationItem } from "./index381.js";
import { AlertCircle, AlertTriangle, CheckCircle, Loader2 } from "lucide-react";
import { jsx, jsxs } from "react/jsx-runtime";
import { Toaster, toast as sonnerToast } from "sonner";
//#region src/components/molecules/feedback/Sonner/Sonner.tsx
var Toaster$1 = ({ theme, dir, ...props }) => {
	const themeContext = useThemeOptional();
	return /* @__PURE__ */ jsx(Toaster, {
		theme: theme ?? themeContext?.theme ?? "light",
		dir,
		position: (dir ?? (typeof document !== "undefined" ? document.documentElement.dir || document.body.dir : void 0)) === "rtl" ? "bottom-left" : "bottom-right",
		className: "toaster group",
		closeButton: true,
		toastOptions: {
			unstyled: true,
			classNames: { toast: "w-full" }
		},
		...props
	});
};
Toaster$1.displayName = "Toaster";
function ToastContent({ title, description, icon, action, className }) {
	return /* @__PURE__ */ jsxs("div", {
		"data-slot": "toast-content",
		className: cn("flex items-center gap-2 rounded-xl border border-black/8 bg-background px-3.5 py-4 shadow-lg dark:border-white/10 delight-toast-stagger", className),
		children: [
			icon && /* @__PURE__ */ jsx("span", {
				className: "shrink-0 text-muted-foreground",
				children: icon
			}),
			/* @__PURE__ */ jsxs("div", {
				className: "flex min-w-0 flex-1 flex-col gap-1",
				children: [/* @__PURE__ */ jsx("p", {
					className: "text-sm font-medium text-foreground",
					children: title
				}), description && /* @__PURE__ */ jsx("p", {
					className: "text-xs text-muted-foreground/90",
					children: description
				})]
			}),
			action && /* @__PURE__ */ jsx("button", {
				type: "button",
				onClick: action.onClick,
				className: "relative shrink-0 cursor-pointer rounded-xl px-2 py-1 text-xs font-medium text-secondary-foreground transition-colors hover:bg-secondary focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none before:absolute before:-inset-2 before:content-[''] delight-click-ripple",
				children: action.label
			})
		]
	});
}
ToastContent.displayName = "ToastContent";
/**
* SonnerItem - A thin wrapper around NotificationItem for use with Sonner toasts.
*
* Usage:
* ```tsx
* toast.custom((t) => (
*   <SonnerItem
*     toastId={t}
*     variant="success"
*     title="Changes saved"
*     supportingText="Your profile has been updated."
*   />
* ));
* ```
*/
function SonnerItem({ toastId, ...props }) {
	return /* @__PURE__ */ jsx(NotificationItem, {
		...props,
		onClose: () => sonnerToast.dismiss(toastId)
	});
}
SonnerItem.displayName = "SonnerItem";
function getVariantIcon(variant) {
	switch (variant) {
		case "success": return /* @__PURE__ */ jsx(CheckCircle, { className: "size-5 text-success delight-bounce-in" });
		case "error": return /* @__PURE__ */ jsx(AlertCircle, { className: "size-5 text-destructive delight-shake" });
		case "warning": return /* @__PURE__ */ jsx(AlertTriangle, { className: "size-5 text-warning delight-attention-pulse" });
		case "loading": return /* @__PURE__ */ jsx(Loader2, { className: "size-5 animate-spin" });
		default: return null;
	}
}
function normalizeMessage(message) {
	if (typeof message === "string") return { title: message };
	return message;
}
function createToast(message, variant, options) {
	const { title, description } = normalizeMessage(message);
	const { description: optDescription, duration, id, onDismiss, onAutoClose, action } = options || {};
	const sonnerOptions = {
		duration: variant === "loading" ? duration ?? Number.POSITIVE_INFINITY : duration,
		id,
		onDismiss,
		onAutoClose
	};
	return sonnerToast.custom(() => /* @__PURE__ */ jsx(ToastContent, {
		title,
		description: optDescription ?? description,
		icon: getVariantIcon(variant),
		action: variant === "loading" ? void 0 : action
	}), sonnerOptions);
}
/**
* Lightweight toast notification API.
*
* @example
* ```tsx
* // Simple usage
* toast('Changes saved');
* toast.success('File uploaded successfully');
* toast.error('Failed to save changes');
*
* // With description
* toast.success({
*   title: 'File uploaded',
*   description: 'document.pdf has been uploaded successfully.'
* });
*
* // With action button
* toast.error('Something went wrong', {
*   action: { label: 'Try Again', onClick: () => {} },
* });
* ```
*/
function toast(message, options) {
	return createToast(message, "default", options);
}
toast.success = (message, options) => {
	return createToast(message, "success", options);
};
toast.error = (message, options) => {
	return createToast(message, "error", options);
};
toast.warning = (message, options) => {
	return createToast(message, "warning", options);
};
toast.info = (message, options) => {
	return createToast(message, "default", options);
};
toast.loading = (message, options) => {
	return createToast(message, "loading", options);
};
/**
* Promise-based toast that shows loading, success, or error states.
*
* @example
* ```tsx
* toast.promise(saveData(), {
*   loading: 'Saving...',
*   success: 'Changes saved!',
*   error: 'Failed to save',
* });
* ```
*/
toast.promise = (promise, messages, options) => {
	const id = toast.loading(messages.loading, options);
	(typeof promise === "function" ? promise() : promise).then((data) => {
		const successMessage = typeof messages.success === "function" ? messages.success(data) : messages.success;
		toast.success(successMessage, {
			...options,
			id
		});
	}).catch((error) => {
		const errorMessage = typeof messages.error === "function" ? messages.error(error) : messages.error;
		toast.error(errorMessage, {
			...options,
			id
		});
	});
	return id;
};
/** Dismiss a toast by ID, or all toasts if no ID provided */
toast.dismiss = sonnerToast.dismiss;
/** Render a fully custom toast via SonnerItem or any React node */
toast.custom = sonnerToast.custom;
//#endregion
export { SonnerItem, ToastContent, Toaster$1 as Toaster, sonnerToast, toast };

//# sourceMappingURL=index382.js.map