"use client";

// src/components/data-views/list-page-board-template.tsx
import * as React from "react";

// src/lib/utils.ts
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
function cn(...inputs) {
  return twMerge(clsx(inputs));
}

// src/components/ui/badge.tsx
import { cva } from "class-variance-authority";
import { Slot } from "radix-ui";
import { jsx } from "react/jsx-runtime";
var badgeVariants = cva(
  "group/badge inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-1 text-xs font-medium leading-none whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
  {
    variants: {
      variant: {
        default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
        secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
        destructive: "bg-destructive/10 text-[var(--chip-destructive)] focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:text-red-100 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
        outline: "border-border text-foreground [a]:hover:bg-interactive-hover [a]:hover:text-muted-foreground",
        ghost: "hover:bg-interactive-hover hover:text-muted-foreground dark:hover:bg-interactive-hover-subtle",
        link: "text-primary underline-offset-4 hover:underline"
      }
    },
    defaultVariants: {
      variant: "default"
    }
  }
);
function Badge({
  className,
  variant = "default",
  asChild = false,
  ...props
}) {
  const Comp = asChild ? Slot.Root : "span";
  return /* @__PURE__ */ jsx(
    Comp,
    {
      "data-slot": "badge",
      "data-variant": variant,
      className: cn(badgeVariants({ variant }), className),
      ...props
    }
  );
}

// src/components/data-views/board-card-primitives.tsx
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
function BoardNewCardPlaceholder({ position }) {
  return /* @__PURE__ */ jsxs(
    "button",
    {
      type: "button",
      className: cn(
        "flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-border bg-background/50 py-2 text-xs font-medium text-muted-foreground transition-colors",
        "hover:border-input hover:bg-muted/40 hover:text-foreground",
        position === "above" ? "mb-2" : "mt-2"
      ),
      children: [
        /* @__PURE__ */ jsx2("i", { className: "fa-light fa-plus text-xs", "aria-hidden": "true" }),
        "New card"
      ]
    }
  );
}

// src/components/data-views/list-page-board-template.tsx
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
function ListPageBoardColumnHeader({
  label,
  description,
  count,
  badgeClassName
}) {
  return /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between border-b border-border px-3 py-2.5", children: [
    /* @__PURE__ */ jsxs2("div", { className: "flex min-w-0 items-center gap-2", children: [
      /* @__PURE__ */ jsx3("span", { className: "truncate text-sm font-semibold text-foreground", children: label }),
      description ? /* @__PURE__ */ jsx3("span", { className: "hidden text-xs text-muted-foreground sm:inline", children: description }) : null
    ] }),
    /* @__PURE__ */ jsx3(
      Badge,
      {
        variant: "outline",
        className: cn(
          "inline-flex h-6 min-w-6 shrink-0 items-center justify-center border-0 bg-muted/70 px-2 text-xs font-semibold tabular-nums text-foreground",
          badgeClassName
        ),
        "aria-label": `${count} ${count === 1 ? "item" : "items"}`,
        children: count
      }
    )
  ] });
}
var EMPTY_COLUMN_BADGE_CLASS = {};
function BoardColumnCard({
  row,
  renderCard
}) {
  return /* @__PURE__ */ jsx3(Fragment, { children: renderCard(row) });
}
function ListPageBoardTemplate({
  columns,
  rows,
  getRowKey,
  renderCard,
  columnCountBadgeClassName = EMPTY_COLUMN_BADGE_CLASS,
  emptyColumnLabel = "No items"
}) {
  const grouped = React.useMemo(() => {
    const map = {};
    for (const col of columns) map[col.id] = [];
    for (const row of rows) {
      for (const col of columns) {
        if (col.filter(row)) {
          map[col.id].push(row);
          break;
        }
      }
    }
    return map;
  }, [columns, rows]);
  return /* @__PURE__ */ jsx3("div", { className: "flex min-h-0 flex-1 gap-3 overflow-x-auto px-4 pb-6 pt-2 lg:px-6", children: columns.map((col) => /* @__PURE__ */ jsxs2(
    "div",
    {
      className: "flex w-72 shrink-0 flex-col overflow-hidden rounded-xl border border-border bg-muted/30",
      children: [
        /* @__PURE__ */ jsx3(
          ListPageBoardColumnHeader,
          {
            label: col.label,
            description: col.description,
            count: grouped[col.id]?.length ?? 0,
            badgeClassName: columnCountBadgeClassName[col.id]
          }
        ),
        /* @__PURE__ */ jsxs2("div", { className: "flex flex-1 flex-col gap-2 overflow-y-auto p-2", children: [
          /* @__PURE__ */ jsx3(BoardNewCardPlaceholder, { position: "above" }),
          (grouped[col.id]?.length ?? 0) === 0 ? /* @__PURE__ */ jsx3("p", { className: "py-6 text-center text-xs text-muted-foreground", children: emptyColumnLabel }) : grouped[col.id].map((row) => /* @__PURE__ */ jsx3(BoardColumnCard, { row, renderCard }, String(getRowKey(row)))),
          /* @__PURE__ */ jsx3(BoardNewCardPlaceholder, { position: "below" })
        ] })
      ]
    },
    col.id
  )) });
}
export {
  ListPageBoardTemplate
};
//# sourceMappingURL=list-page-board-template.js.map