import React__default, { useCallback } from 'react';
import { Button } from '../components/Button.mjs';
import { FlexBox } from '../shared/components/FlexBox.mjs';
import { SettingsContainer } from '../components/SettingsContainer.mjs';
import { Typography } from '../components/Typography.mjs';
import { useRbac } from '../utils/useRbac.mjs';
import { useSelf } from '../utils/useSelf.mjs';
import { useMemberManagementRouterController } from './MemberManagementRouter.mjs';
import { useMemberActivation, getActionCopy } from './useMemberActivation.mjs';

const DangerZoneSection$1 = ({ member })=>{
    const { isSelf } = useSelf();
    const { data: canCreateMemberPerm } = useRbac('stytch.member', 'create');
    const { data: canDeleteMemberPerm } = useRbac('stytch.member', 'delete');
    const { data: canDeleteSelfPerm } = useRbac('stytch.self', 'delete');
    const canDelete = canDeleteMemberPerm || canDeleteSelfPerm && isSelf(member.member_id);
    const canCreate = canCreateMemberPerm;
    const isMemberDeleted = member.status === 'deleted';
    const canMemberBeReactivated = member.email_address_verified;
    const canPerformAction = isMemberDeleted ? canCreate : canDelete;
    const { openModal, modal } = useMemberActivation();
    const actionCopy = getActionCopy({
        status: member.status,
        isEmailVerified: member.email_address_verified
    });
    const handleActionClick = useCallback(()=>{
        openModal(member);
    }, [
        member,
        openModal
    ]);
    const { useBlockNavigation } = useMemberManagementRouterController();
    return canPerformAction ? /*#__PURE__*/ React__default.createElement(SettingsContainer, {
        title: "Danger zone",
        useBlockNavigation: useBlockNavigation
    }, /*#__PURE__*/ React__default.createElement(FlexBox, {
        flexDirection: "column",
        gap: 2
    }, !isMemberDeleted || canMemberBeReactivated ? /*#__PURE__*/ React__default.createElement(React__default.Fragment, null, modal, /*#__PURE__*/ React__default.createElement(Typography, {
        variant: "body2"
    }, actionCopy.description), /*#__PURE__*/ React__default.createElement(Button, {
        compact: true,
        variant: "ghost",
        warning: true,
        onClick: handleActionClick
    }, actionCopy.action)) : /*#__PURE__*/ React__default.createElement(Typography, {
        variant: "body2"
    }, "The Member’s email address was not verified. You cannot reactivate an unverified Member."))) : null;
};

export { DangerZoneSection$1 as DangerZoneSection };
//# sourceMappingURL=DangerZoneSection.mjs.map
