import { t as e } from "./utils-B7XIe3qq.js";
import { t } from "./dist-BCCeHAQm.js";
import { t as n } from "./createLucideIcon-wKpAnzBe.js";
import { n as r, r as i, t as a } from "./triangle-alert-CKjGAvtd.js";
import { t as o } from "./x-BleQvk5v.js";
import * as s from "react";
import { jsx as c, jsxs as l } from "react/jsx-runtime";
var u = n("info", [
	["circle", {
		cx: "12",
		cy: "12",
		r: "10",
		key: "1mglay"
	}],
	["path", {
		d: "M12 16v-4",
		key: "1dtifu"
	}],
	["path", {
		d: "M12 8h.01",
		key: "e9boi3"
	}]
]), d = t("group pointer-events-auto relative flex w-full items-start gap-3 overflow-hidden rounded-xl border p-4 shadow-xl backdrop-blur-xl transition-all", {
	variants: { level: {
		success: "border-accent-cyan/30 bg-accent-cyan/5 text-foreground",
		error: "border-accent-rose/30 bg-accent-rose/5 text-foreground",
		warning: "border-accent-amber/30 bg-accent-amber/5 text-foreground",
		info: "border-border-glass bg-glass text-foreground"
	} },
	defaultVariants: { level: "info" }
}), f = s.createContext(null);
function p() {
	let e = s.useContext(f);
	if (!e) throw Error("useToast must be used within a <ToastProvider>");
	return e;
}
var m = 0;
function h({ children: e, position: t = "top-right", maxVisible: n = 5, defaultDuration: r = 5e3 }) {
	let [i, a] = s.useState([]), o = s.useCallback((e) => {
		a((t) => t.filter((t) => t.id !== e));
	}, []), u = s.useCallback(() => {
		a([]);
	}, []), d = s.useCallback((e) => {
		let t = `toast-${String(++m)}`, r = {
			id: t,
			...e
		};
		return a((e) => {
			let t = [...e, r];
			return t.length > n ? t.slice(t.length - n) : t;
		}), t;
	}, [n]), p = s.useCallback((e) => d(e), [d]), h = s.useCallback((e, t) => {
		let n = {
			level: "success",
			title: e
		};
		return t !== void 0 && (n.description = t), d(n);
	}, [d]), _ = s.useCallback((e, t) => {
		let n = {
			level: "error",
			title: e
		};
		return t !== void 0 && (n.description = t), d(n);
	}, [d]), v = s.useCallback((e, t) => {
		let n = {
			level: "warning",
			title: e
		};
		return t !== void 0 && (n.description = t), d(n);
	}, [d]), y = s.useCallback((e, t) => {
		let n = {
			level: "info",
			title: e
		};
		return t !== void 0 && (n.description = t), d(n);
	}, [d]), b = s.useMemo(() => ({
		toasts: i,
		toast: p,
		success: h,
		error: _,
		warning: v,
		info: y,
		dismiss: o,
		dismissAll: u
	}), [
		i,
		p,
		h,
		_,
		v,
		y,
		o,
		u
	]);
	return /* @__PURE__ */ l(f.Provider, {
		value: b,
		children: [e, /* @__PURE__ */ c(g, {
			position: t,
			toasts: i,
			dismiss: o,
			defaultDuration: r
		})]
	});
}
function g({ position: t, toasts: n, dismiss: r, defaultDuration: i }) {
	let a = {
		"top-right": "top-4 right-4",
		"top-left": "top-4 left-4",
		"bottom-right": "bottom-4 right-4",
		"bottom-left": "bottom-4 left-4"
	};
	return /* @__PURE__ */ c("div", {
		"data-slot": "toast-viewport",
		role: "region",
		"aria-label": "Notifications",
		"aria-live": "polite",
		className: e("fixed z-[9999] flex flex-col gap-2 pointer-events-none w-full max-w-sm", a[t]),
		children: n.map((e) => /* @__PURE__ */ c(_, {
			data: e,
			onDismiss: () => {
				r(e.id);
			},
			defaultDuration: i
		}, e.id))
	});
}
function _({ data: e, onDismiss: t, defaultDuration: n }) {
	let o = e.duration ?? n, f = s.useRef(null), p = s.useRef(Date.now()), m = s.useRef(o), h = s.useRef(t);
	s.useEffect(() => {
		h.current = t;
	}, [t]);
	let g = s.useCallback(() => {
		e.persistent !== !0 && (f.current &&= (clearTimeout(f.current), null), !(m.current <= 0) && (p.current = Date.now(), f.current = setTimeout(() => {
			f.current = null, h.current();
		}, m.current)));
	}, [e.persistent]), _ = s.useCallback(() => {
		f.current && (clearTimeout(f.current), f.current = null, m.current -= Date.now() - p.current, m.current < 0 && (m.current = 0));
	}, []);
	s.useEffect(() => (g(), () => {
		f.current && clearTimeout(f.current);
	}), [g]);
	let b = {
		success: /* @__PURE__ */ c(i, { className: "size-5 text-accent-cyan shrink-0" }),
		error: /* @__PURE__ */ c(r, { className: "size-5 text-accent-rose shrink-0" }),
		warning: /* @__PURE__ */ c(a, { className: "size-5 text-accent-amber shrink-0" }),
		info: /* @__PURE__ */ c(u, { className: "size-5 text-foreground-secondary shrink-0" })
	};
	return /* @__PURE__ */ l("div", {
		"data-slot": "toast",
		role: e.level === "error" || e.level === "warning" ? "alert" : "status",
		"aria-live": e.level === "error" ? "assertive" : "polite",
		"aria-atomic": "true",
		className: d({ level: e.level }),
		onMouseEnter: _,
		onMouseLeave: g,
		onFocus: _,
		onBlur: g,
		onKeyDown: (e) => {
			e.key === "Escape" && (e.preventDefault(), t());
		},
		tabIndex: 0,
		children: [
			b[e.level],
			/* @__PURE__ */ l("div", {
				className: "flex-1 min-w-0",
				children: [
					/* @__PURE__ */ c(v, { children: e.title }),
					e.description !== void 0 && /* @__PURE__ */ c(y, { children: e.description }),
					e.action !== void 0 && /* @__PURE__ */ c("div", {
						className: "mt-2",
						children: e.action
					})
				]
			}),
			/* @__PURE__ */ c(x, { onClick: t })
		]
	});
}
function v({ className: t, ...n }) {
	return /* @__PURE__ */ c("div", {
		"data-slot": "toast-title",
		className: e("text-sm font-semibold", t),
		...n
	});
}
function y({ className: t, ...n }) {
	return /* @__PURE__ */ c("div", {
		"data-slot": "toast-description",
		className: e("text-sm text-foreground-secondary mt-0.5", t),
		...n
	});
}
function b({ className: t, ...n }) {
	return /* @__PURE__ */ c("button", {
		"data-slot": "toast-action",
		type: "button",
		className: e("inline-flex h-7 items-center rounded-lg border border-border-glass bg-glass px-3 text-xs font-medium transition-colors hover:bg-glass-hover", t),
		...n
	});
}
function x({ className: t, onClick: n, ...r }) {
	return /* @__PURE__ */ c("button", {
		"data-slot": "toast-close",
		type: "button",
		"aria-label": "Dismiss notification",
		onClick: n,
		className: e("shrink-0 rounded-lg p-1 text-foreground-muted opacity-60 transition-opacity hover:opacity-100", t),
		...r,
		children: /* @__PURE__ */ c(o, { className: "size-4" })
	});
}
//#endregion
export { h as a, p as c, y as i, b as n, v as o, x as r, d as s, _ as t };

//# sourceMappingURL=toast-DRNPdj-R.js.map