"use client";
'use strict';

const jsxRuntime = require('react/jsx-runtime');
const LucideIcons = require('lucide-react');
const button = require('../../../../../../../ui/src/components/button.cjs');
const card = require('../../../../../../../ui/src/components/card.cjs');
const kanbanHooks = require('../../hooks/kanban-hooks.cjs');
const context = require('@btst/stack/context');
const emptyState = require('../shared/empty-state.cjs');
const pageWrapper = require('../shared/page-wrapper.cjs');
const dateFns = require('date-fns');

function BoardsListPage() {
  const { data: boards, error, isFetching } = kanbanHooks.useSuspenseBoards();
  if (error && !isFetching) {
    throw error;
  }
  const { Link: OverrideLink, navigate: overrideNavigate } = context.usePluginOverrides("kanban");
  const Link = OverrideLink || "a";
  const navigate = overrideNavigate || ((path) => {
    window.location.href = path;
  });
  const handleNewBoard = () => {
    navigate("/pages/kanban/new");
  };
  return /* @__PURE__ */ jsxRuntime.jsxs(pageWrapper.PageWrapper, { "data-testid": "boards-list-page", children: [
    /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex items-center justify-between mb-8", children: [
      /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
        /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-3xl font-bold", "data-testid": "page-header", children: "Kanban Boards" }),
        /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground mt-1", children: "Manage your projects and tasks" })
      ] }),
      /* @__PURE__ */ jsxRuntime.jsxs(button.Button, { onClick: handleNewBoard, children: [
        /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Plus, { className: "mr-2 h-4 w-4" }),
        "New Board"
      ] })
    ] }),
    boards.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3", children: boards.map((board) => /* @__PURE__ */ jsxRuntime.jsx(
      Link,
      {
        href: `/pages/kanban/${board.id}`,
        className: "block group",
        children: /* @__PURE__ */ jsxRuntime.jsxs(card.Card, { className: "h-full transition-shadow hover:shadow-md cursor-pointer", children: [
          /* @__PURE__ */ jsxRuntime.jsxs(card.CardHeader, { children: [
            /* @__PURE__ */ jsxRuntime.jsx(card.CardTitle, { className: "group-hover:text-primary transition-colors", children: board.name }),
            board.description && /* @__PURE__ */ jsxRuntime.jsx(card.CardDescription, { className: "line-clamp-2", children: board.description })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsx(card.CardContent, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm text-muted-foreground", children: [
            /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
              board.columns?.length || 0,
              " columns"
            ] }),
            /* @__PURE__ */ jsxRuntime.jsx("span", { children: dateFns.format(new Date(board.createdAt), "MMM d, yyyy") })
          ] }) })
        ] })
      },
      board.id
    )) }) : /* @__PURE__ */ jsxRuntime.jsx(
      emptyState.EmptyState,
      {
        title: "No boards yet",
        description: "Create your first kanban board to start organizing your tasks.",
        action: /* @__PURE__ */ jsxRuntime.jsxs(button.Button, { onClick: handleNewBoard, children: [
          /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Plus, { className: "mr-2 h-4 w-4" }),
          "Create Board"
        ] })
      }
    )
  ] });
}

exports.BoardsListPage = BoardsListPage;
