import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { cn } from "../../lib/utils";
import { User, Shield, GitBranch } from "lucide-react";
import { ParheliaAgentIcon } from "../../editor/ui/Icons";
import { DeleteIcon } from "../../components/ui/delete-icon";
import { getDisplayableAssignee } from "../assigneeDisplay";
import { Badge } from "../../components/ui/badge";
import { normalizeTaskStatus, getTaskStatusLabel } from "../taskStatus";
import { TaskAssigneePicker } from "./TaskAssigneePicker";
import { getTaskPriorityBadgeClass, getTaskPriorityLabel, } from "../taskPriority";
const statusBadgeColors = {
    Todo: "border-transparent bg-neutral-grey-5 text-neutral-grey-50",
    Waiting: "border-transparent bg-feedback-orange-light text-feedback-orange",
    InProgress: "border-transparent bg-feedback-blue-light text-feedback-blue",
    Review: "border-transparent bg-highlight-10 text-highlight-100",
    Done: "border-transparent bg-feedback-green-light text-feedback-green",
};
export function TaskRow(props) {
    const { task, selected, onClick, onDelete, projectId, canEditAssignee = false, onAssigneeChange, } = props;
    const taskStatus = normalizeTaskStatus(task.status, task.executionState);
    const isPlanTask = String(task.taskType ?? "").toLowerCase() === "plan" ||
        task.title === "Project Plan";
    const isDecisionPointTask = String(task.taskType ?? "").toLowerCase() === "decisionpoint";
    const assigneeValue = getDisplayableAssignee(task, { isPlanTask });
    const priorityLabel = getTaskPriorityLabel(task.priority);
    const priorityBadgeColor = getTaskPriorityBadgeClass(task.priority);
    const canEditInlineAssignee = !!projectId && !!onAssigneeChange && canEditAssignee && !isPlanTask;
    return (_jsxs("div", { "data-testid": `taskboard-task-row-${task.taskId}`, className: cn("grid w-full grid-cols-[minmax(0,1fr)_5.5rem_6rem_10rem_2.5rem] gap-2.5 overflow-hidden px-3.5 py-1.5 text-xs transition-colors", selected ? "bg-neutral-grey-5" : "hover:bg-neutral-grey-5"), children: [_jsxs("button", { type: "button", onClick: onClick, className: "contents text-left", "data-testid": `taskboard-task-row-button-${task.taskId}`, children: [_jsxs("div", { className: "flex min-w-0 items-center gap-1.5", children: [_jsx("span", { "data-testid": `taskboard-task-title-${task.taskId}`, className: cn("truncate font-medium tracking-tight", "text-neutral-grey-100"), title: task.description
                                    ? `${task.title} - ${task.description}`
                                    : task.title, children: task.title }), isDecisionPointTask && (_jsx(GitBranch, { strokeWidth: 1, className: "text-highlight-100 h-3.5 w-3.5 shrink-0" }))] }), _jsx("div", { className: "flex items-center", children: priorityLabel && (_jsx(Badge, { variant: "outline", size: "sm", className: cn("font-medium", priorityBadgeColor), "data-testid": `taskboard-task-priority-${task.taskId}`, children: priorityLabel })) }), _jsx("div", { className: "flex items-center", children: _jsx(Badge, { variant: "outline", size: "sm", className: cn("text-2xs font-medium", statusBadgeColors[taskStatus]), "data-testid": `taskboard-task-status-${task.taskId}`, children: getTaskStatusLabel(taskStatus) }) })] }), _jsx("div", { className: "text-neutral-grey-50 flex items-center gap-1.5", children: canEditInlineAssignee ? (_jsx(TaskAssigneePicker, { projectId: projectId, assigneeType: task.assigneeType ?? null, value: task.assigneeId ?? null, displayValue: task.assigneeDisplayName ?? task.assigneeId ?? null, onChange: onAssigneeChange, placeholder: "Assign user or agent", buttonClassName: "h-[29px] w-full min-w-0 justify-between rounded-[4px] bg-white text-2xs font-medium", buttonTestId: `taskboard-task-assignee-${task.taskId}` })) : (_jsxs(_Fragment, { children: [task.assigneeType === "Agent" ? (_jsx(ParheliaAgentIcon, { className: "text-neutral-grey-50 h-3 w-3 shrink-0" })) : task.assigneeType === "Role" ? (_jsx(Shield, { strokeWidth: 1, className: "text-neutral-grey-50 h-3 w-3 shrink-0" })) : (_jsx(User, { strokeWidth: 1, className: "text-neutral-grey-50 h-3 w-3 shrink-0" })), _jsx("span", { className: "truncate text-[11px] font-medium", title: assigneeValue, "data-testid": `taskboard-task-assignee-${task.taskId}`, children: assigneeValue })] })) }), _jsx("div", { className: "flex items-center justify-end", children: onDelete ? (_jsx("button", { type: "button", className: "text-neutral-grey-50 hover:bg-neutral-grey-5 hover:text-neutral-grey-50 rounded-md p-1 transition-colors", title: "Delete task", onClick: onDelete, "data-testid": `taskboard-task-delete-${task.taskId}`, children: _jsx(DeleteIcon, { size: "md" }) })) : null })] }));
}
//# sourceMappingURL=TaskRow.js.map