import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
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 (_jsxs("div", { children: [_jsx("h3", { className: "mb-2 text-sm font-medium text-gray-700", children: "Recent Batches" }), _jsx("div", { className: "space-y-2 overflow-y-auto", children: batches.map((batch) => (_jsxs("div", { className: "rounded bg-gray-50 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: `rounded px-2 py-0.5 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-gray-600", children: [batch.numberOfItems ?? 0, " items"] }), _jsx("div", { className: "text-xs text-gray-500", children: batch.created
                                                ? formatDateOnly(new Date(batch.created))
                                                : "Unknown" })] })] }), ((batch.firstErrors && batch.firstErrors.length > 0) ||
                            batch.errorMessage) && (_jsx("div", { className: "mt-1 text-xs text-red-600", 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