import 'core-js/modules/es.array.iterator.js';
import 'core-js/modules/web.dom-collections.iterator.js';
import 'core-js/modules/es.object.assign.js';
import { jsx, jsxs } from 'react/jsx-runtime';
import { ThemeProvider, StyledEngineProvider, CssBaseline } from '@mui/material';
import { createContext, useState, useCallback, useContext } from 'react';
import GlobalStyles from '../styles/GlobalStyles.js';
import createAppTheme from '../styles/theme/index.js';
import GlobalSnackAlertProvider from './GlobalSnackAlertProvider.js';

const ColorModeContext = /*#__PURE__*/createContext({
  colorMode: 'dark',
  toggleColorMode: () => void 0
});
const FutureverseThemeProvider = ({
  children
}) => {
  const [colorMode, setColorMode] = useState('dark');
  const toggleColorMode = useCallback(mode => {
    if (mode !== undefined) {
      setColorMode(mode);
    } else {
      setColorMode(prevMode => prevMode === 'dark' ? 'light' : 'dark');
    }
  }, []);
  const theme = createAppTheme(colorMode);
  return jsx(ColorModeContext.Provider, Object.assign({
    value: {
      colorMode,
      toggleColorMode
    }
  }, {
    children: jsx(ThemeProvider, Object.assign({
      theme: theme
    }, {
      children: jsxs(StyledEngineProvider, Object.assign({
        injectFirst: true
      }, {
        children: [jsx(CssBaseline, {}), jsx(GlobalStyles, {}), jsx(GlobalSnackAlertProvider, {
          children: children
        })]
      }))
    }))
  }));
};
const useColorMode = () => {
  const {
    colorMode,
    toggleColorMode
  } = useContext(ColorModeContext);
  return {
    colorMode,
    toggleColorMode
  };
};

export { ColorModeContext, FutureverseThemeProvider, FutureverseThemeProvider as default, useColorMode };
