"use client";
import { jsxs, jsx } from 'react/jsx-runtime';
import { memo } from 'react';
import { GripVertical, MoreVertical, Pencil, Plus, Trash2 } from 'lucide-react';
import { Button } from '../../../../../../../ui/src/components/button.mjs';
import { Badge } from '../../../../../../../ui/src/components/badge.mjs';
import { KanbanColumn, KanbanColumnHandle } from '../../../../../../../ui/src/components/kanban.mjs';
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from '../../../../../../../ui/src/components/dropdown-menu.mjs';
import { TaskCard } from './task-card.mjs';

function ColumnContentComponent({
  column,
  onAddTask,
  onEditTask,
  onEditColumn,
  onDeleteColumn
}) {
  const hasTasks = column.tasks && column.tasks.length > 0;
  return /* @__PURE__ */ jsxs(KanbanColumn, { value: column.id, children: [
    /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
      /* @__PURE__ */ jsx(KanbanColumnHandle, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ jsx(GripVertical, { className: "h-4 w-4" }) }) }),
      /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-1", children: [
        /* @__PURE__ */ jsx("span", { className: "font-bold text-lg line-clamp-1 flex-1 text-left", children: column.title }),
        /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "pointer-events-none rounded-sm", children: column.tasks?.length || 0 })
      ] }),
      /* @__PURE__ */ jsxs(DropdownMenu, { children: [
        /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-4 w-4" }) }) }),
        /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", children: [
          /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onEditColumn, children: [
            /* @__PURE__ */ jsx(Pencil, { className: "mr-2 h-4 w-4" }),
            "Edit Column"
          ] }),
          /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: onAddTask, children: [
            /* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
            "Add Task"
          ] }),
          /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
          /* @__PURE__ */ jsxs(
            DropdownMenuItem,
            {
              onClick: onDeleteColumn,
              className: "text-red-600 focus:text-red-600",
              children: [
                /* @__PURE__ */ jsx(Trash2, { className: "mr-2 h-4 w-4" }),
                "Delete Column"
              ]
            }
          )
        ] })
      ] })
    ] }),
    /* @__PURE__ */ jsx("div", { className: "p-0.5 space-y-2", children: hasTasks ? column.tasks.map((task) => /* @__PURE__ */ jsx(
      TaskCard,
      {
        task,
        onClick: () => onEditTask(task.id)
      },
      task.id
    )) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-1 md:py-8 text-center", children: [
      /* @__PURE__ */ jsx("div", { className: "rounded-full bg-muted p-4 mb-3 hidden md:block", children: /* @__PURE__ */ jsx(Plus, { className: "h-5 w-5 text-muted-foreground" }) }),
      /* @__PURE__ */ jsxs("div", { className: "space-y-1 mb-2 md:space-y-2 md:mb-4", children: [
        /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No tasks yet" }),
        /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Add a task to get started" })
      ] }),
      /* @__PURE__ */ jsxs(Button, { onClick: onAddTask, size: "sm", children: [
        /* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
        "Add Task"
      ] })
    ] }) })
  ] }, column.id);
}
const ColumnContent = memo(ColumnContentComponent);

export { ColumnContent };
