import {CssBaseline, GlobalStyles} from "@mui/material";
import {LocalizationProvider} from "../components/core/LocalizationProvider";
import {AuthProvider} from "../context/AuthContext";
import {createTTheme} from "../styles/theme/create-theme";
import {Experimental_CssVarsProvider as CssVarsProvider} from '@mui/material/styles';
import {BrowserRouter as Router} from "react-router-dom";
import {NavigationRoutes} from "../components/navigation/NavigationRoutes";
import {SnackbarProvider} from 'notistack';
import {UserProvider} from "../context/UserContext";
import {SelectProvider} from "../context/SelectContext";

function App() {
    const theme = createTTheme();

    return (
        // Провайдер времени
        <LocalizationProvider>
            {/*Провайдер уведомлений*/}
            <SnackbarProvider maxSnack={6} anchorOrigin={{vertical: 'bottom', horizontal: 'right'}}
                              style={{borderRadius: '10px'}}>
                {/*Провайдер авторизации*/}
                <AuthProvider>
                    {/*Провайдер пользователя*/}
                    <UserProvider>
                        {/*Провайдер темы*/}
                        <CssVarsProvider theme={theme}>
                            <CssBaseline/>
                            <GlobalStyles
                                styles={{
                                    body: {
                                        '--MainNav-height': '56px',
                                        '--MainNav-zIndex': 1000,
                                        '--SideNav-width': '280px',
                                        '--SideNav-zIndex': 1200,
                                        '--MobileNav-width': '320px',
                                        '--MobileNav-zIndex': 1200,
                                    },
                                }}
                            />
                            {/*Провайдер выбора*/}
                            <SelectProvider>
                                {/*Маршрутизация*/}
                                <Router>
                                    <NavigationRoutes/>
                                </Router>
                            </SelectProvider>
                        </CssVarsProvider>
                    </UserProvider>
                </AuthProvider>
            </SnackbarProvider>
        </LocalizationProvider>
    );
}

export default App;
