'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import React, { useEffect } from 'react';
import { useRouteCache } from '../../providers/RouteCache/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import { Button } from '../Button/index.js';
import { Modal, useModal } from '../Modal/index.js';
import './index.scss';
const modalSlug = 'document-stale-data';
const baseClass = 'document-stale-data';
export const DocumentStaleData = ({ isActive, onReload })=>{
    const { closeModal, openModal } = useModal();
    const { clearRouteCache } = useRouteCache();
    const { t } = useTranslation();
    useEffect(()=>{
        if (isActive) {
            openModal(modalSlug);
        } else {
            closeModal(modalSlug);
        }
    }, [
        isActive,
        openModal,
        closeModal
    ]);
    return /*#__PURE__*/ _jsxDEV(Modal, {
        className: baseClass,
        closeOnBlur: false,
        slug: modalSlug,
        children: /*#__PURE__*/ _jsxDEV("div", {
            className: `${baseClass}__wrapper`,
            children: [
                /*#__PURE__*/ _jsxDEV("div", {
                    className: `${baseClass}__content`,
                    children: [
                        /*#__PURE__*/ _jsxDEV("h1", {
                            children: t('general:documentModified')
                        }, void 0, false, {
                            fileName: "src/elements/DocumentStaleData/index.tsx",
                            lineNumber: 34,
                            columnNumber: 11
                        }, this),
                        /*#__PURE__*/ _jsxDEV("p", {
                            children: t('general:documentOutOfDate')
                        }, void 0, false, {
                            fileName: "src/elements/DocumentStaleData/index.tsx",
                            lineNumber: 35,
                            columnNumber: 11
                        }, this)
                    ]
                }, void 0, true, {
                    fileName: "src/elements/DocumentStaleData/index.tsx",
                    lineNumber: 33,
                    columnNumber: 9
                }, this),
                /*#__PURE__*/ _jsxDEV("div", {
                    className: `${baseClass}__controls`,
                    children: /*#__PURE__*/ _jsxDEV(Button, {
                        buttonStyle: "primary",
                        id: `${modalSlug}-reload`,
                        margin: false,
                        onClick: async ()=>{
                            closeModal(modalSlug);
                            clearRouteCache();
                            await onReload();
                        },
                        size: "medium",
                        children: t('general:reloadDocument')
                    }, void 0, false, {
                        fileName: "src/elements/DocumentStaleData/index.tsx",
                        lineNumber: 38,
                        columnNumber: 11
                    }, this)
                }, void 0, false, {
                    fileName: "src/elements/DocumentStaleData/index.tsx",
                    lineNumber: 37,
                    columnNumber: 9
                }, this)
            ]
        }, void 0, true, {
            fileName: "src/elements/DocumentStaleData/index.tsx",
            lineNumber: 32,
            columnNumber: 7
        }, this)
    }, void 0, false, {
        fileName: "src/elements/DocumentStaleData/index.tsx",
        lineNumber: 31,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map