"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLogic = void 0;
const usePopover_1 = require("../../../components/usePopover");
const NOTE_TEXT = 'Редактировать';
const useLogic = ({ isLoading, iconPosition, }) => {
    const { isOpen, anchor, actions } = (0, usePopover_1.usePopover)();
    const isIconOnLeft = iconPosition === 'left';
    const tooltipTitle = isLoading ? undefined : NOTE_TEXT;
    const handleOpen = (event) => {
        if (isLoading) {
            return;
        }
        actions.open(event);
    };
    return {
        isIconOnLeft,
        onClose: actions.close,
        tooltipProps: {
            title: tooltipTitle,
        },
        displayValueProps: {
            $isEdited: isOpen,
            onClick: handleOpen,
        },
        popoverProps: {
            open: isOpen,
            onClose: actions.close,
            anchorEl: anchor,
            title: 'Изменение данных',
        },
    };
};
exports.useLogic = useLogic;
