"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSavedState = void 0;
var react_1 = require("react");
var useSavedState = function (getSavedState) {
    var _a = (0, react_1.useState)(false), isLoaded = _a[0], setIsLoaded = _a[1];
    var _b = (0, react_1.useState)({}), savedState = _b[0], setSavedState = _b[1];
    (0, react_1.useEffect)(function () {
        getSavedState()
            .then(function (savedState) {
            setSavedState(savedState || {});
        })
            .catch(function (error) {
            console.warn("Can't load saved state", error);
        })
            .finally(function () {
            setIsLoaded(true);
        });
    }, []); // eslint-disable-line react-hooks/exhaustive-deps
    return { isLoaded: isLoaded, savedState: savedState };
};
exports.useSavedState = useSavedState;
