/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-af8d194 | Cube Dev Team */
import { useId as useId$1 } from "../../../utils/react/useId.js";
import { useSyncRef } from "../../../_internal/hooks/use-sync-ref.js";
import { useEvent } from "../../../_internal/hooks/use-event.js";
import { useNotificationsApi } from "./hooks/use-notifications-api.js";
import { useEffect } from "react";
import { jsx } from "react/jsx-runtime";

//#region src/components/overlays/NewNotifications/Notification.tsx
/**
* Declarative wrap over the `useNotificationsApi` hook
*/
function Notification(props) {
	const { id: propsId, disableRemoveOnUnmount = false } = props;
	const defaultId = useId$1();
	const disableRemoveOnUnmountRef = useSyncRef(disableRemoveOnUnmount);
	const { notify, update, remove } = useNotificationsApi();
	const id = propsId ?? defaultId;
	const removeNotification = useEvent((id) => disableRemoveOnUnmountRef.current ? void 0 : remove(id));
	useEffect(() => {
		notify({
			id,
			...props
		});
	}, [id]);
	useEffect(() => () => removeNotification(id), [id, removeNotification]);
	useEffect(() => update(id, props));
	return null;
}
Notification.Success = function NotificationSuccess(props) {
	return /* @__PURE__ */ jsx(Notification, {
		type: "success",
		...props
	});
};
Notification.Danger = function NotificationDanger(props) {
	return /* @__PURE__ */ jsx(Notification, {
		type: "danger",
		...props
	});
};
Notification.Attention = function NotificationAttention(props) {
	return /* @__PURE__ */ jsx(Notification, {
		type: "attention",
		...props
	});
};

//#endregion
export { Notification };
//# sourceMappingURL=Notification.js.map