import { useEffect, useState } from 'react';
export var useSavedState = function (getSavedState) {
    var _a = useState(false), isLoaded = _a[0], setIsLoaded = _a[1];
    var _b = useState({}), savedState = _b[0], setSavedState = _b[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 };
};
