'use client';
import * as facelessUIImport from '@faceless-ui/modal';
import React from 'react';
import { toast } from 'react-toastify';
import { useDocumentInfo } from '../../providers/DocumentInfo/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import { MinimalTemplate } from '../../templates/Minimal/index.js';
import { Button } from '../Button/index.js';
import { Translation } from '../Translation/index.js';
const baseClass = 'generate-confirmation';
const GenerateConfirmation = (props)=>{
    const { Modal, useModal } = facelessUIImport;
    const { highlightField, setKey } = props;
    const { id } = useDocumentInfo();
    const { toggleModal } = useModal();
    const { t } = useTranslation();
    const modalSlug = `generate-confirmation-${id}`;
    const handleGenerate = ()=>{
        setKey();
        toggleModal(modalSlug);
        toast.success(t('authentication:newAPIKeyGenerated'), {
            autoClose: 3000
        });
        highlightField(true);
    };
    return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Button, {
        buttonStyle: "secondary",
        onClick: ()=>{
            toggleModal(modalSlug);
        },
        size: "small"
    }, t('authentication:generateNewAPIKey')), /*#__PURE__*/ React.createElement(Modal, {
        className: baseClass,
        slug: modalSlug
    }, /*#__PURE__*/ React.createElement(MinimalTemplate, {
        className: `${baseClass}__template`
    }, /*#__PURE__*/ React.createElement("h1", null, t('authentication:confirmGeneration')), /*#__PURE__*/ React.createElement("p", null, /*#__PURE__*/ React.createElement(Translation, {
        elements: {
            1: ({ children })=>/*#__PURE__*/ React.createElement("strong", {
                    children: children
                })
        },
        i18nKey: "authentication:generatingNewAPIKeyWillInvalidate",
        t: t
    })), /*#__PURE__*/ React.createElement(Button, {
        buttonStyle: "secondary",
        onClick: ()=>{
            toggleModal(modalSlug);
        },
        type: "button"
    }, t('general:cancel')), /*#__PURE__*/ React.createElement(Button, {
        onClick: handleGenerate
    }, t('authentication:generate')))));
};
export default GenerateConfirmation;

//# sourceMappingURL=index.js.map