"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FloatingMenuControl = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const icons_1 = require("@gravity-ui/icons");
const uikit_1 = require("@gravity-ui/uikit");
const yfm_table_1 = require("../../../../../../../i18n/yfm-table/index.js");
const FloatingMenu_1 = require("../FloatingMenu/FloatingMenu.js");
const FloatingMenuControl = function YfmTableFloatingMenuControl({ type, multiple, dndHandler, acnhorElement, onMenuOpenToggle, onClearCellsClick, onInsertBeforeClick, onInsertAfterClick, onRemoveRangeClick, onRemoveTableClick, }) {
    const dropdownItems = (0, react_1.useMemo)(() => [
        [
            {
                text: (0, yfm_table_1.i18n)(`${type}.add.before`),
                qa: `g-md-yfm-table-action-add-${type}-before`,
                action: onInsertBeforeClick,
                iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: type === 'row' ? icons_1.ArrowUp : icons_1.ArrowLeft }),
            },
            {
                text: (0, yfm_table_1.i18n)(`${type}.add.after`),
                qa: `g-md-yfm-table-action-add-${type}-after`,
                action: onInsertAfterClick,
                iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: type === 'row' ? icons_1.ArrowDown : icons_1.ArrowRight }),
            },
        ],
        [
            {
                text: (0, yfm_table_1.i18n)('cells.clear'),
                qa: `g-md-yfm-table-${type}-clear-cells`,
                action: onClearCellsClick,
                iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.BroomMotion }),
            },
        ],
        [
            {
                text: (0, yfm_table_1.i18n)(`${type}.remove${multiple ? '.multiple' : ''}`),
                qa: `g-md-yfm-table-action-remove-${type}`,
                action: onRemoveRangeClick,
                iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.Xmark }),
            },
            {
                theme: 'danger',
                text: (0, yfm_table_1.i18n)('table.remove'),
                qa: 'g-md-yfm-table-action-remove-table',
                action: onRemoveTableClick,
                iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.TrashBin }),
            },
        ],
    ], [
        type,
        multiple,
        onClearCellsClick,
        onInsertAfterClick,
        onInsertBeforeClick,
        onRemoveRangeClick,
        onRemoveTableClick,
    ]);
    return ((0, jsx_runtime_1.jsx)(FloatingMenu_1.FloatingMenu, { dirtype: type, canDrag: dndHandler ? dndHandler.canDrag() : false, onOpenToggle: onMenuOpenToggle, anchorElement: acnhorElement, switcherMouseProps: dndHandler
            ? {
                onMouseLeave: dndHandler.control_handleMouseLeave,
                onMouseDown: dndHandler.control_handleMouseDown,
                onMouseMove: dndHandler.control_handleMouseMove,
                onMouseUp: dndHandler.control_handleMouseUp,
            }
            : undefined, dropdownItems: dropdownItems }));
};
exports.FloatingMenuControl = FloatingMenuControl;
//# sourceMappingURL=FloatingMenuControl.js.map
