import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { Checkbox } from "../../components/ui/checkbox";
import { Button } from "../../components/ui/button";
import { Check, X, Clock, Lock, Calendar, Trash2, MessageSquare, Lightbulb, Globe, Users, ClipboardCheck, } from "lucide-react";
import { formatDate } from "../utils";
import { cn } from "../../lib/utils";
export function ReviewCard({ review, isSelected, onSelect, onClick, onDelete, canDelete, }) {
    const status = review.finalDecision ?? review.status ?? "In Progress";
    const getStatusInfo = () => {
        if (status === "Approved") {
            return {
                icon: _jsx(Check, { className: "h-3 w-3 text-green-600" }),
                text: "Approved",
                className: "text-green-600",
            };
        }
        if (status === "Rejected") {
            return {
                icon: _jsx(X, { className: "h-3 w-3 text-red-600" }),
                text: "Rejected",
                className: "text-red-600",
            };
        }
        return {
            icon: _jsx(Clock, { className: "h-3 w-3 text-gray-400" }),
            text: "In Progress",
            className: "text-gray-500",
        };
    };
    const statusInfo = getStatusInfo();
    return (_jsxs("div", { "data-testid": "review-card", "data-review-id": review.reviewId, onClick: () => onClick(review.reviewId), className: cn("group relative flex cursor-pointer flex-col rounded-lg border bg-white p-3 transition-shadow hover:shadow-md", isSelected
            ? "border-blue-500 bg-blue-50/30 ring-1 ring-blue-500/20"
            : "border-gray-200"), children: [_jsxs("div", { className: "mb-2 flex items-start gap-2", children: [_jsx("div", { onClick: (e) => {
                            e.stopPropagation();
                            if (canDelete) {
                                onSelect(review.reviewId, !isSelected);
                            }
                        }, className: cn("mt-1 shrink-0", !canDelete && "invisible"), children: _jsx(Checkbox, { checked: isSelected, onCheckedChange: (checked) => onSelect(review.reviewId, checked === true), disabled: !canDelete, onClick: (e) => e.stopPropagation() }) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "mb-0.5 flex items-center gap-2", children: [_jsx("h4", { "data-testid": "review-card-title", className: "truncate text-sm font-medium text-gray-900", children: review.title || `Review ${review.reviewId.slice(0, 8)}` }), review.requiresSecret && (_jsx(Lock, { className: "h-3 w-3 text-gray-400" }))] }), _jsxs("div", { className: "flex items-center gap-1.5 text-[11px] text-gray-500", children: [_jsxs("span", { className: "truncate", children: ["By ", review.createdBy] }), _jsx("span", { children: "\u2022" }), _jsx("span", { className: "whitespace-nowrap", children: formatDate(new Date(review.createdAt)) })] })] }), canDelete && (_jsx(Button, { variant: "ghost", size: "icon", onClick: (e) => onDelete(review.reviewId, e), className: "-mt-1 -mr-1 h-7 w-7 text-gray-400 opacity-0 transition-opacity group-hover:opacity-100 hover:text-red-500", children: _jsx(Trash2, { className: "h-3.5 w-3.5" }) }))] }), _jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-gray-50 pt-2", children: [_jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [statusInfo.icon, _jsx("span", { className: cn("text-[10px] font-bold tracking-tight uppercase", statusInfo.className), children: statusInfo.text })] }), _jsx("div", { className: "xs:block hidden h-3 w-px shrink-0 bg-gray-200" }), _jsx("div", { className: "flex shrink-0 items-center gap-2", children: review.commentsCount || review.suggestionsCount ? (_jsxs(_Fragment, { children: [review.commentsCount ? (_jsxs("div", { className: "flex items-center gap-1 text-[10px] text-gray-500", title: "Comments", children: [_jsx(MessageSquare, { className: "h-3 w-3" }), _jsx("span", { children: review.commentsCount })] })) : null, review.suggestionsCount ? (_jsxs("div", { className: "flex items-center gap-1 text-[10px] font-medium text-yellow-600", title: "Suggestions", children: [_jsx(Lightbulb, { className: "h-3 w-3" }), _jsx("span", { children: review.suggestionsCount })] })) : null] })) : (_jsx("span", { className: "text-[10px] text-gray-400 italic", children: "No feedback" })) }), _jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-2.5 text-gray-400", children: [_jsxs("div", { className: "flex items-center gap-1", title: "Language", children: [_jsx(Globe, { className: "h-3 w-3" }), _jsx("span", { className: "text-[10px] text-gray-600", children: review.language === "*"
                                            ? "All"
                                            : review.language === "mixed"
                                                ? "Mixed"
                                                : review.language })] }), _jsxs("div", { className: "flex items-center gap-1", title: "Reviewers", children: [_jsx(Users, { className: "h-3 w-3" }), _jsx("span", { className: "text-[10px] text-gray-600", children: review.reviewersCount })] }), _jsxs("div", { className: "flex items-center gap-1", title: "Pages", children: [_jsx(ClipboardCheck, { className: "h-3 w-3", strokeWidth: 1 }), _jsx("span", { className: "text-[10px] text-gray-600", children: review.pagesCount })] })] })] }), review.expiresAtUtc && !review.isExpired && (_jsxs("div", { className: "mt-2 flex items-center justify-center gap-1 rounded border border-orange-100/50 bg-orange-50/50 py-1 text-[10px] text-orange-600", children: [_jsx(Calendar, { className: "h-3 w-3" }), _jsxs("span", { children: ["Expires ", formatDate(new Date(review.expiresAtUtc))] })] })), review.isExpired && (_jsxs("div", { className: "mt-2 flex items-center justify-center gap-1 rounded border border-red-100/50 bg-red-50/50 py-1 text-[10px] font-medium text-red-600", children: [_jsx(X, { className: "h-3 w-3" }), _jsx("span", { children: "Expired" })] }))] }));
}
//# sourceMappingURL=ReviewCard.js.map