"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdaptableLoadingScreen = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const Dialog_1 = tslib_1.__importDefault(require("../../../components/Dialog"));
const rebass_1 = require("rebass");
function AdaptableLoadingScreen(props) {
    const { showLoadingScreen, loadingScreenDelay, loadingScreenTitle, loadingScreenText } = props;
    const [delayElapsed, setDelayElapsed] = React.useState(typeof loadingScreenDelay === 'number' ? false : showLoadingScreen);
    React.useEffect(() => {
        if (typeof loadingScreenDelay === 'number') {
            const timeoutId = setTimeout(() => {
                setDelayElapsed(true);
            }, loadingScreenDelay);
            return () => {
                clearTimeout(timeoutId);
            };
        }
    }, [loadingScreenDelay]);
    return (React.createElement(Dialog_1.default, { modal: true, isOpen: delayElapsed ? showLoadingScreen : false, onDismiss: props.onClose, showCloseButton: false, className: "ab-LoadingScreen", style: {
            minHeight: 'auto',
        } },
        React.createElement(rebass_1.Box, { padding: 3 },
            React.createElement("h4", null, loadingScreenTitle !== null && loadingScreenTitle !== void 0 ? loadingScreenTitle : 'Initialising Grid'),
            React.createElement("p", null, loadingScreenText !== null && loadingScreenText !== void 0 ? loadingScreenText : 'Retrieving your settings and setting up the grid...'))));
}
exports.AdaptableLoadingScreen = AdaptableLoadingScreen;
