var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { Box, Dialog, Typography } from '@mui/material';
import { useSelector } from 'react-redux';
import { Route, Switch } from 'react-router-dom';
import CircularProgress from '@mui/material/CircularProgress';
import routes from '../config/routes';
import { loadingData } from '../store/sw-ui-reducer';
function MainDialog(_a) {
    var container = _a.container, open = _a.open, handleClose = _a.handleClose;
    var loadingState = useSelector(loadingData);
    return (_jsx(_Fragment, { children: _jsxs(Dialog, __assign({ maxWidth: "xs", fullWidth: true, container: container, open: open, onClose: handleClose }, { children: [_jsxs(Box, __assign({ sx: {
                        width: '99%',
                        minHeight: '460px',
                        minWidth: '480px',
                        display: loadingState.loading ? 'flex' : 'none',
                        justifyContent: 'center',
                        flexDirection: 'column',
                        alignItems: 'center',
                    } }, { children: [loadingState.loadingMessage && (_jsx(Typography, __assign({ align: "center", sx: { mb: '26px', width: '90%' }, variant: "h2" }, { children: loadingState.loadingMessage }), void 0)), _jsx(CircularProgress, { color: "secondary" }, void 0)] }), void 0), _jsx(Box, __assign({ sx: { display: !loadingState.loading ? 'flex' : 'none', alignContent: 'center', justifyContent: 'center' } }, { children: _jsx(Switch, { children: routes.map(function (route, index) {
                            return (_jsx(Route, { path: route.path, exact: route.exact, render: function (props) { return _jsx(route.component, __assign({}, props, route.props), void 0); } }, index));
                        }) }, void 0) }), void 0)] }), void 0) }, void 0));
}
export default MainDialog;
