import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Fragment } from "react";
import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbPageSubtitle, BreadcrumbSeparator, } from "../../components/ui/breadcrumb";
function ItemBody({ title, subtitle }) {
    return (_jsxs("span", { className: "flex min-w-0 flex-col items-start gap-0", children: [_jsx("span", { className: "w-full min-w-0 truncate leading-tight", children: title }), subtitle ? (_jsx(BreadcrumbPageSubtitle, { className: "hidden w-full min-w-0 truncate text-[11px] leading-tight md:block", children: subtitle })) : null] }));
}
export function TaskBoardBreadcrumb({ rootTitle = "Tasks", rootSubtitle, items, rootContent, currentItemContent, onRootClick, onItemClick, }) {
    const hasItems = items.length > 0;
    return (_jsx(Breadcrumb, { "aria-label": "Taskboard breadcrumb", className: "text-neutral-grey-50 min-w-0 flex-1 text-sm", "data-testid": "taskboard-breadcrumb", children: _jsxs(BreadcrumbList, { className: "flex-nowrap items-start gap-2", children: [_jsx(BreadcrumbItem, { className: "min-w-0 flex-col items-start gap-0 self-start leading-tight", children: !hasItems && rootContent ? (rootContent) : hasItems ? (_jsx(BreadcrumbLink, { asChild: true, className: "cursor-pointer rounded-sm", children: _jsx("button", { type: "button", onClick: onRootClick, className: "p-0 text-left leading-tight", children: _jsx(ItemBody, { title: rootTitle, subtitle: rootSubtitle }) }) })) : (_jsxs(_Fragment, { children: [_jsx(BreadcrumbPage, { className: "w-full min-w-0 truncate leading-tight", children: rootTitle }), rootSubtitle ? (_jsx(BreadcrumbPageSubtitle, { className: "hidden w-full min-w-0 truncate text-[11px] leading-tight md:block", children: rootSubtitle })) : null] })) }), items.map((item, index) => {
                    const isLastItem = index === items.length - 1;
                    return (_jsxs(Fragment, { children: [_jsx(BreadcrumbSeparator, { className: "text-neutral-grey-50 mt-1 shrink-0 self-start" }), _jsx(BreadcrumbItem, { className: "min-w-0 flex-col items-start gap-0 self-start leading-tight", children: isLastItem && currentItemContent ? (currentItemContent) : isLastItem ? (_jsxs(_Fragment, { children: [_jsx(BreadcrumbPage, { className: "w-full min-w-0 truncate leading-tight", children: item.title }), item.subtitle ? (_jsx(BreadcrumbPageSubtitle, { className: "hidden w-full min-w-0 truncate text-[11px] leading-tight md:block", children: item.subtitle })) : null] })) : (_jsx(BreadcrumbLink, { asChild: true, className: "cursor-pointer rounded-sm", children: _jsx("button", { type: "button", onClick: () => onItemClick(item.projectId), className: "p-0 text-left leading-tight", children: _jsx(ItemBody, { title: item.title, subtitle: item.subtitle }) }) })) })] }, item.projectId));
                })] }) }));
}
//# sourceMappingURL=TaskBoardBreadcrumb.js.map