import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { RefreshCw, AlertTriangle, ChevronDown, Settings } from "lucide-react";
import { cn } from "../../../lib/utils";
import { presentEmbeddingError } from "./embeddingErrors";
/**
 * Displays queue errors with retry functionality
 */
export function QueueErrorsDisplay({ queueStatus, showQueueErrors, onToggleErrors, onRetryFailed, onGoToSettings, isRetryingFailed, retryFailedMessage, }) {
    const errors = queueStatus.recentErrors.map(presentEmbeddingError);
    const primaryError = errors[errors.length - 1];
    const itemLabel = queueStatus.errorCount === 1 ? "item" : "items";
    return (_jsxs("div", { className: "border-feedback-red bg-feedback-red-light overflow-hidden rounded-lg border", children: [_jsxs("button", { type: "button", className: "flex w-full cursor-pointer items-start justify-between gap-4 p-3 text-left", onClick: onToggleErrors, "aria-expanded": showQueueErrors, children: [_jsxs("div", { className: "flex min-w-0 items-start gap-2", children: [_jsx(AlertTriangle, { className: "text-feedback-red mt-0.5 h-4 w-4 shrink-0", strokeWidth: 1 }), _jsxs("div", { children: [_jsx("div", { className: "text-feedback-red text-sm font-medium", children: "Embedding generation failed" }), _jsxs("div", { className: "text-neutral-grey-100 mt-0.5 text-xs", children: [queueStatus.errorCount.toLocaleString(), " ", itemLabel, " could not be processed."] })] })] }), _jsxs("div", { className: "text-feedback-red flex shrink-0 items-center gap-1 text-xs font-medium", children: ["Technical details", _jsx(ChevronDown, { className: cn("h-4 w-4 transition-transform duration-200", showQueueErrors ? "rotate-180" : ""), strokeWidth: 1 })] })] }), primaryError && (_jsxs("div", { className: "border-feedback-red mx-3 rounded border bg-white p-3", children: [_jsx("div", { className: "text-neutral-grey-100 text-sm font-medium", children: primaryError.title }), _jsx("div", { className: "text-neutral-grey-100 mt-1 text-xs", children: primaryError.message }), _jsx("div", { className: "text-neutral-grey-50 mt-1 text-xs", children: primaryError.suggestion })] })), _jsxs("div", { className: "flex flex-wrap items-center gap-2 p-3", children: [_jsxs("button", { type: "button", onClick: onGoToSettings, className: "bg-neutral-grey-100 hover:bg-neutral-grey-100 flex items-center gap-2 rounded px-3 py-1.5 text-sm font-medium text-white", children: [_jsx(Settings, { className: "h-4 w-4", strokeWidth: 1 }), "Review search settings"] }), _jsxs("button", { type: "button", onClick: onRetryFailed, disabled: isRetryingFailed, className: "border-feedback-red text-feedback-red flex items-center gap-2 rounded border bg-transparent px-3 py-1.5 text-sm font-medium hover:bg-white/60 disabled:cursor-not-allowed disabled:opacity-60", children: [_jsx(RefreshCw, { className: cn("h-4 w-4", isRetryingFailed ? "animate-spin" : ""), strokeWidth: 1 }), isRetryingFailed ? "Retrying..." : "Retry failed items"] }), retryFailedMessage && (_jsx("div", { className: "text-neutral-grey-100 text-xs", children: retryFailedMessage }))] }), showQueueErrors && (_jsxs("div", { className: "border-feedback-red border-t bg-white/50 p-3", children: [_jsx("div", { className: "text-neutral-grey-100 mb-2 text-xs font-medium", children: "Technical details" }), _jsx("div", { className: "space-y-2", children: errors.map((error, idx) => (_jsx("pre", { className: "border-border-default bg-neutral-grey-5 text-neutral-grey-100 overflow-x-auto rounded border p-2 text-xs whitespace-pre-wrap", children: error.technicalDetails }, `${error.technicalDetails}-${idx}`))) })] }))] }));
}
//# sourceMappingURL=QueueErrorsDisplay.js.map