"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
const icon_1 = require("@cocalc/frontend/components/icon");
const react_1 = require("react");
const mounted_1 = __importDefault(require("lib/hooks/mounted"));
function Loading({ delay, style }) {
    const [show, setShow] = (0, react_1.useState)(false);
    const isMounted = (0, mounted_1.default)();
    (0, react_1.useEffect)(() => {
        setTimeout(() => {
            if (!isMounted.current)
                return;
            setShow(true);
        }, delay ?? 500);
    }, []);
    if (!show) {
        return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
    }
    return ((0, jsx_runtime_1.jsxs)("div", { style: { color: "#666", ...style }, children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { name: "spinner", spin: true }), " Saving..."] }));
}
exports.default = Loading;
//# sourceMappingURL=saving.js.map