'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import React, { useEffect } from 'react';
import { useRouteCache } from '../../providers/RouteCache/index.js';
import { useRouteTransition } from '../../providers/RouteTransition/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-take-over';
const baseClass = 'document-take-over';
export const DocumentTakeOver = ({ handleBackToDashboard, isActive, onReadOnly })=>{
    const { closeModal, openModal } = useModal();
    const { t } = useTranslation();
    const { startRouteTransition } = useRouteTransition();
    const { clearRouteCache } = useRouteCache();
    useEffect(()=>{
        if (isActive) {
            openModal(modalSlug);
        } else {
            closeModal(modalSlug);
        }
    }, [
        isActive,
        openModal,
        closeModal
    ]);
    return /*#__PURE__*/ _jsxDEV(Modal, {
        className: baseClass,
        // // Fixes https://github.com/payloadcms/payload/issues/13778
        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:editingTakenOver')
                        }, void 0, false, {
                            fileName: "src/elements/DocumentTakeOver/index.tsx",
                            lineNumber: 42,
                            columnNumber: 11
                        }, this),
                        /*#__PURE__*/ _jsxDEV("p", {
                            children: t('general:anotherUserTakenOver')
                        }, void 0, false, {
                            fileName: "src/elements/DocumentTakeOver/index.tsx",
                            lineNumber: 43,
                            columnNumber: 11
                        }, this)
                    ]
                }, void 0, true, {
                    fileName: "src/elements/DocumentTakeOver/index.tsx",
                    lineNumber: 41,
                    columnNumber: 9
                }, this),
                /*#__PURE__*/ _jsxDEV("div", {
                    className: `${baseClass}__controls`,
                    children: [
                        /*#__PURE__*/ _jsxDEV(Button, {
                            buttonStyle: "primary",
                            id: `${modalSlug}-back-to-dashboard`,
                            onClick: ()=>{
                                startRouteTransition(()=>handleBackToDashboard());
                            },
                            size: "large",
                            children: t('general:backToDashboard')
                        }, void 0, false, {
                            fileName: "src/elements/DocumentTakeOver/index.tsx",
                            lineNumber: 46,
                            columnNumber: 11
                        }, this),
                        /*#__PURE__*/ _jsxDEV(Button, {
                            buttonStyle: "secondary",
                            id: `${modalSlug}-view-read-only`,
                            onClick: ()=>{
                                onReadOnly();
                                closeModal(modalSlug);
                                clearRouteCache();
                            },
                            size: "large",
                            children: t('general:viewReadOnly')
                        }, void 0, false, {
                            fileName: "src/elements/DocumentTakeOver/index.tsx",
                            lineNumber: 56,
                            columnNumber: 11
                        }, this)
                    ]
                }, void 0, true, {
                    fileName: "src/elements/DocumentTakeOver/index.tsx",
                    lineNumber: 45,
                    columnNumber: 9
                }, this)
            ]
        }, void 0, true, {
            fileName: "src/elements/DocumentTakeOver/index.tsx",
            lineNumber: 40,
            columnNumber: 7
        }, this)
    }, void 0, false, {
        fileName: "src/elements/DocumentTakeOver/index.tsx",
        lineNumber: 34,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map