import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { useEditContext } from "../../client/editContext";
import { SimpleIconButton } from "../../ui/SimpleIconButton";
import { Check, MessageCirclePlus } from "lucide-react";
import { showCommentPopoverForTrigger } from "../../reviews/CommentPopover";
export function ReviewCommands() {
    const editContext = useEditContext();
    if (!editContext)
        return null;
    const reviewCommands = editContext.configuration.commands.reviewcommands;
    const contentEditorItem = editContext.item;
    if (!contentEditorItem || !reviewCommands?.length)
        return null;
    const executeReviewCommand = async (command, event) => {
        console.log("EXECUTING COMMAND", command);
        if (command && contentEditorItem) {
            await editContext.executeCommand({
                command: command,
                data: { items: [contentEditorItem] },
                event: event || null,
            });
        }
    };
    return (_jsxs(_Fragment, { children: [reviewCommands
                .filter((command) => {
                // Filter out approve/reject commands - they're only available in the review panel
                const commandId = command.id?.toLowerCase() || "";
                const commandLabel = command.label?.toLowerCase() || "";
                return (!commandId.includes("approve") &&
                    !commandId.includes("reject") &&
                    !commandLabel.includes("approve") &&
                    !commandLabel.includes("reject"));
            })
                .map((command) => {
                const isDisabled = editContext.isCommandDisabled({
                    command: command,
                    data: { items: [contentEditorItem] },
                });
                return (_jsx(SimpleIconButton, { icon: command.icon || (_jsx(Check, { className: "h-6 w-6 p-1", strokeWidth: 1 })), label: command.label, size: "large", disabled: isDisabled, onClick: (event) => executeReviewCommand(command, event) }, command.id));
            }), _jsx(SimpleIconButton, { icon: _jsx(MessageCirclePlus, { className: "h-6 w-6 p-1", strokeWidth: 1 }), label: "Add Comment", size: "large", onClick: (event) => showCommentPopoverForTrigger(event.currentTarget, editContext) })] }));
}
//# sourceMappingURL=ReviewCommands.js.map