import { jsx, jsxs } from "react/jsx-runtime";
import { memo, useCallback, useRef } from "react";
import { StageTask } from "./StageNode.styles.js";
import { TaskContent } from "./TaskContent.js";
import { TaskMenu } from "./TaskMenu.js";
const AdhocTaskItemComponent = ({ task, taskExecution, isSelected, getContextMenuItems, onTaskClick, onTaskPlay, isTaskLoading })=>{
    const taskRef = useRef(null);
    const menuRef = useRef(null);
    const handleClick = useCallback((e)=>{
        onTaskClick(e, task.id);
    }, [
        onTaskClick,
        task.id
    ]);
    const handleContextMenu = useCallback((e)=>{
        menuRef.current?.handleContextMenu(e);
    }, []);
    return /*#__PURE__*/ jsxs(StageTask, {
        ref: taskRef,
        "data-testid": `stage-task-${task.id}`,
        selected: isSelected,
        status: taskExecution?.status,
        isPlaceholder: task.isPlaceholder,
        onClick: handleClick,
        ...getContextMenuItems && !isTaskLoading && {
            onContextMenu: handleContextMenu
        },
        children: [
            /*#__PURE__*/ jsx(TaskContent, {
                task: task,
                taskExecution: taskExecution,
                onTaskPlay: onTaskPlay
            }),
            getContextMenuItems && /*#__PURE__*/ jsx(TaskMenu, {
                ref: menuRef,
                task: task,
                getContextMenuItems: getContextMenuItems,
                disabled: isTaskLoading
            })
        ]
    });
};
const AdhocTaskItem = /*#__PURE__*/ memo(AdhocTaskItemComponent);
export { AdhocTaskItem };
