import { jsx as _jsx } from "react/jsx-runtime";
import { isLatestVersion, ReloadConnectToast, toast, } from "@powerhousedao/connect";
import { connectConfig } from "@powerhousedao/connect/config";
import { logger } from "document-drive";
import { useEffect } from "react";
export const useCheckLatestVersion = () => {
    async function checkLatestVersion() {
        const result = await isLatestVersion();
        if (result === null)
            return;
        // ignore dev/staging versions
        if (result.isLatest || result.currentVersion.includes("-")) {
            return true;
        }
        if (import.meta.env.MODE === "development" ||
            connectConfig.studioMode ||
            !connectConfig.warnOutdatedApp) {
            logger.warn(`Connect is outdated: \nCurrent: ${result.currentVersion}\nLatest: ${result.latestVersion}`);
        }
        else {
            toast(_jsx(ReloadConnectToast, {}), {
                type: "connect-warning",
                toastId: "outdated-app",
                autoClose: false,
            });
        }
    }
    useEffect(() => {
        checkLatestVersion().catch(console.error);
    }, []);
};
//# sourceMappingURL=useCheckLatestVersion.js.map