import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Layers } from "lucide-react";
import { Card } from "../../../components/ui/card";
import { formatDateOnly } from "../../utils";
import { getBatchStatusIcon, getBatchStatusLabelStyles } from "./utils";
/**
 * Displays a list of recent embedding batches
 */
export function RecentBatchesList({ batches }) {
    if (!batches || batches.length === 0) {
        return null;
    }
    return (_jsx(Card, { icon: _jsx(Layers, { strokeWidth: 1, className: "h-5 w-5" }), title: "Recent batches", description: "The most recent embedding batch runs and their results.", children: _jsx("div", { className: "space-y-2 overflow-y-auto", children: batches.map((batch) => (_jsxs("div", { className: "bg-neutral-grey-5 rounded p-2 text-sm", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsxs("div", { className: "flex flex-1 flex-wrap items-center gap-2", children: [getBatchStatusIcon(batch.status), _jsx("span", { className: `badge-pad-sm rounded text-xs font-medium ${getBatchStatusLabelStyles(batch.status)}`, children: batch.status ?? "Unknown" }), _jsx("span", { className: "font-mono text-xs", children: batch.id?.slice(-8) ?? "Unknown" })] }), _jsxs("div", { className: "shrink-0 text-right", children: [_jsxs("div", { className: "text-neutral-grey-50", children: [batch.numberOfItems ?? 0, " items"] }), _jsx("div", { className: "text-neutral-grey-50 text-xs", children: batch.created
                                            ? formatDateOnly(new Date(batch.created))
                                            : "Unknown" })] })] }), ((batch.firstErrors && batch.firstErrors.length > 0) ||
                        batch.errorMessage) && (_jsx("div", { className: "text-feedback-red mt-1 text-xs", children: (() => {
                            const messages = batch.firstErrors && batch.firstErrors.length > 0
                                ? batch.firstErrors.slice(0, 3)
                                : batch.errorMessage
                                    ? [batch.errorMessage]
                                    : [];
                            const shownCount = messages.length;
                            const totalCount = batch.errorCount && batch.errorCount > 0
                                ? batch.errorCount
                                : shownCount;
                            const suffix = totalCount > shownCount
                                ? ` (+${totalCount - shownCount} more)`
                                : "";
                            return `${messages.join(" · ")}${suffix}`;
                        })() }))] }, batch.id))) }) }));
}
//# sourceMappingURL=RecentBatchesList.js.map