/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-af8d194 | Cube Dev Team */
import { Portal } from "../../../portal/Portal.js";
import { NotificationsContext } from "./NotificationsContext.js";
import { NotificationsBar } from "../Bar/NotificationsBar.js";
import { useNotifications } from "./use-notifications.js";
import { useMemo } from "react";
import { jsx, jsxs } from "react/jsx-runtime";

//#region src/components/overlays/NewNotifications/NotificationsContext/NotificationsProvider.tsx
function NotificationsProvider(props) {
	const { children, rootRef } = props;
	const { notifications, api, addOnDismissListener, onDismissNotification } = useNotifications(rootRef);
	const providerValue = useMemo(() => ({
		api,
		addOnDismissListener
	}), []);
	return /* @__PURE__ */ jsxs(NotificationsContext.Provider, {
		value: providerValue,
		children: [/* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(NotificationsBar, {
			items: notifications,
			onRemoveNotification: api.remove,
			onDismissNotification,
			children: (notification) => /* @__PURE__ */ jsx(NotificationsBar.Item, { ...notification }, notification.id)
		}) }), children]
	});
}

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