import defaultTheme_default from "../../theme/defaultTheme.js";
import "../../theme/index.js";
import { VuiContextProvider } from "./context.js";
import globalStyle_default from "./globalStyle.js";
import resetCSS_default from "./resetCSS.js";
import { Portal } from "../../portal/portal.js";
import "../../portal/index.js";
import toast_default from "../../toast/toast.js";
import "../../toast/index.js";
import notifyOffline_default from "./notifyOffline.js";
import { genericReducer, toastsReducer } from "./reducers.js";
import { useReducer } from "react";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
import { ThemeProvider } from "styled-components";

//#region src/core/vuiProvider/vuiProvider.tsx
/** Provides theme to all wrapped components and by default includes CSS reset and global styles. */
const VuiProvider = ({ children, globalStyle = true, resetCSS = true, theme = defaultTheme_default, notifyOffline = false }) => {
	const [toasts, toastsDispatch] = useReducer(toastsReducer, { list: [] });
	const [portalSlot, setPortalSlot] = useReducer(genericReducer, null);
	const addToast = (toast) => toastsDispatch({
		type: "add",
		toast
	});
	const removeToast = (id) => toastsDispatch({
		type: "remove",
		toast: { id }
	});
	return /* @__PURE__ */ jsx(VuiContextProvider, {
		value: {
			toasts,
			addToast,
			removeToast,
			setPortalSlot
		},
		children: /* @__PURE__ */ jsx(ThemeProvider, {
			theme,
			children: /* @__PURE__ */ jsxs(Fragment$1, { children: [
				resetCSS && /* @__PURE__ */ jsx(resetCSS_default, {}),
				/* @__PURE__ */ jsx(globalStyle_default, { globalStyle }),
				children,
				notifyOffline && /* @__PURE__ */ jsx(notifyOffline_default, {}),
				/* @__PURE__ */ jsxs(Portal, { children: [portalSlot, /* @__PURE__ */ jsx(toast_default, {})] })
			] })
		})
	});
};
var vuiProvider_default = VuiProvider;

//#endregion
export { vuiProvider_default as default };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=vuiProvider.js.map