"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    getDivider: ()=>getDivider,
    getMenuItem: ()=>getMenuItem,
    transformMenuItems: ()=>transformMenuItems,
    getContextMenuItems: ()=>getContextMenuItems
});
const GroupModificationUtils_cjs_namespaceObject = require("../../utils/GroupModificationUtils.cjs");
const getContextMenuItems = ({ isParallelGroup, groupIndex, tasksLength, groupIndexInAllTasks, taskIndexInAllTasks, isAboveParallel, isBelowParallel, reGroupTaskFunction, hideParallelOptions = false, labels })=>{
    const CONTEXT_MENU_ITEMS = {
        MOVE_UP: getMenuItem('move-up', labels.moveUp, ()=>reGroupTaskFunction(GroupModificationUtils_cjs_namespaceObject.GroupModificationType.TASK_GROUP_UP, groupIndexInAllTasks, taskIndexInAllTasks)),
        MOVE_DOWN: getMenuItem('move-down', labels.moveDown, ()=>reGroupTaskFunction(GroupModificationUtils_cjs_namespaceObject.GroupModificationType.TASK_GROUP_DOWN, groupIndexInAllTasks, taskIndexInAllTasks)),
        UNGROUP_ALL: getMenuItem('ungroup', labels.ungroupParallelTasks, ()=>reGroupTaskFunction(GroupModificationUtils_cjs_namespaceObject.GroupModificationType.UNGROUP_ALL_TASKS, groupIndexInAllTasks, taskIndexInAllTasks)),
        SPLIT_TASK: getMenuItem('split', labels.removeFromParallelGroup, ()=>reGroupTaskFunction(GroupModificationUtils_cjs_namespaceObject.GroupModificationType.SPLIT_GROUP, groupIndexInAllTasks, taskIndexInAllTasks)),
        REMOVE_GROUP: getMenuItem('remove-group', labels.removeGroupFromStage, ()=>reGroupTaskFunction(GroupModificationUtils_cjs_namespaceObject.GroupModificationType.REMOVE_GROUP, groupIndexInAllTasks, taskIndexInAllTasks)),
        REMOVE_TASK: getMenuItem('remove-task', labels.deleteTask, ()=>reGroupTaskFunction(GroupModificationUtils_cjs_namespaceObject.GroupModificationType.REMOVE_TASK, groupIndexInAllTasks, taskIndexInAllTasks)),
        CREATE_PARALLEL_GROUP_ABOVE: getMenuItem('group-with-up', labels.createParallelGroupWithTaskAbove, ()=>reGroupTaskFunction(GroupModificationUtils_cjs_namespaceObject.GroupModificationType.MERGE_GROUP_UP, groupIndexInAllTasks, taskIndexInAllTasks)),
        CREATE_PARALLEL_GROUP_BELOW: getMenuItem('group-with-down', labels.createParallelGroupWithTaskBelow, ()=>reGroupTaskFunction(GroupModificationUtils_cjs_namespaceObject.GroupModificationType.MERGE_GROUP_DOWN, groupIndexInAllTasks, taskIndexInAllTasks)),
        ADD_TO_PARALLEL_GROUP_ABOVE: getMenuItem('add-to-group-with-up', labels.addTaskToParallelGroupAbove, ()=>reGroupTaskFunction(GroupModificationUtils_cjs_namespaceObject.GroupModificationType.MERGE_GROUP_UP, groupIndexInAllTasks, taskIndexInAllTasks)),
        ADD_TO_PARALLEL_GROUP_BELOW: getMenuItem('add-to-group-with-down', labels.addTaskToParallelGroupBelow, ()=>reGroupTaskFunction(GroupModificationUtils_cjs_namespaceObject.GroupModificationType.MERGE_GROUP_DOWN, groupIndexInAllTasks, taskIndexInAllTasks)),
        DIVIDER: getDivider()
    };
    const items = [];
    if (groupIndex > 0) items.push(CONTEXT_MENU_ITEMS.MOVE_UP);
    if (groupIndex < tasksLength - 1) items.push(CONTEXT_MENU_ITEMS.MOVE_DOWN);
    if (items.length) items.push(CONTEXT_MENU_ITEMS.DIVIDER);
    if (isParallelGroup && !hideParallelOptions) items.push(CONTEXT_MENU_ITEMS.UNGROUP_ALL, CONTEXT_MENU_ITEMS.SPLIT_TASK, CONTEXT_MENU_ITEMS.DIVIDER, CONTEXT_MENU_ITEMS.REMOVE_GROUP, CONTEXT_MENU_ITEMS.REMOVE_TASK);
    else if (isParallelGroup || hideParallelOptions) items.push(CONTEXT_MENU_ITEMS.REMOVE_TASK);
    else {
        if (groupIndex > 0) items.push(isAboveParallel ? CONTEXT_MENU_ITEMS.ADD_TO_PARALLEL_GROUP_ABOVE : CONTEXT_MENU_ITEMS.CREATE_PARALLEL_GROUP_ABOVE);
        if (groupIndex < tasksLength - 1) items.push(isBelowParallel ? CONTEXT_MENU_ITEMS.ADD_TO_PARALLEL_GROUP_BELOW : CONTEXT_MENU_ITEMS.CREATE_PARALLEL_GROUP_BELOW);
        if (items.length) items.push(CONTEXT_MENU_ITEMS.DIVIDER);
        items.push(CONTEXT_MENU_ITEMS.REMOVE_TASK);
    }
    return items;
};
function getMenuItem(id = 'id', label = 'label', onClick, isDisabled = false) {
    return {
        id,
        label,
        onClick,
        disabled: isDisabled
    };
}
const getDivider = ()=>({
        type: 'divider'
    });
const transformMenuItems = (menuItems, onItemClick)=>{
    if (!menuItems) return [];
    return menuItems.map((item, index)=>{
        if ('type' in item && 'divider' === item.type) return {
            divider: true,
            key: `divider-${index}`,
            variant: 'separator'
        };
        const actionItem = item;
        return {
            key: actionItem.id,
            title: actionItem.label,
            startIcon: actionItem.icon,
            disabled: actionItem.disabled,
            onClick: ()=>onItemClick(actionItem),
            variant: 'item'
        };
    });
};
exports.getContextMenuItems = __webpack_exports__.getContextMenuItems;
exports.getDivider = __webpack_exports__.getDivider;
exports.getMenuItem = __webpack_exports__.getMenuItem;
exports.transformMenuItems = __webpack_exports__.transformMenuItems;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "getContextMenuItems",
    "getDivider",
    "getMenuItem",
    "transformMenuItems"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
