/**
 * Text extraction table — displays AI-extracted structured data from text input.
 * Agent-only. Read-only with edit toggle. Shows categories, fields, issues.
 */
'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useState } from 'react';
import { cn, DocumentIcon } from './shared.js';
export function TextExtraction({ result, on_accept, on_send_to_client, on_dismiss }) {
    const [editing, set_editing] = useState(false);
    if (!result.extracted_data || result.extracted_data.length === 0)
        return null;
    const issue_count = result.extracted_data.reduce((n, g) => n + g.fields.filter(f => f.issue).length, 0);
    return (_jsxs("div", { className: "rounded-md border border-[#E2E8F0] overflow-hidden", children: [_jsxs("div", { className: "px-3 py-2 bg-[#F1F5F9] flex items-center justify-between border-b border-[#E2E8F0]", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(DocumentIcon, {}), _jsx("span", { className: "text-[12px] font-medium text-[#334155]", children: "Extracted Data" }), issue_count > 0 && (_jsxs("span", { className: "text-[10px] text-amber-600 bg-amber-50 px-1.5 py-0.5 rounded-full font-medium", children: [issue_count, " issue", issue_count !== 1 ? 's' : ''] }))] }), _jsx("button", { onClick: () => set_editing(!editing), className: "text-[11px] text-[#2563EB] font-medium hover:underline cursor-pointer", children: editing ? 'Done' : 'Edit' })] }), result.extracted_data.map(group => (_jsxs("div", { children: [_jsx("div", { className: "px-3 py-1.5 bg-[#FAFBFC] text-[10px] text-[#64748B] uppercase tracking-wider font-medium border-b border-[#F1F5F9]", children: group.category }), group.fields.map(field => (_jsxs("div", { className: cn('flex items-center gap-3 px-3 py-2 text-[13px] border-b border-[#F1F5F9] last:border-b-0', field.issue && 'bg-amber-50/30'), children: [_jsx("span", { className: "text-[#64748B] w-28 flex-shrink-0 text-[12px]", children: field.label }), editing ? (_jsx("input", { className: "flex-1 text-[13px] font-medium text-[#0F172A] border-b border-[#E2E8F0] bg-transparent focus:outline-none focus:border-[#2563EB] py-0.5", defaultValue: field.value })) : (_jsx("span", { className: "text-[#0F172A] font-medium flex-1", children: field.value })), field.issue ? (_jsxs("span", { className: "text-amber-600 text-[11px] flex items-center gap-1 flex-shrink-0 max-w-48 truncate", title: field.issue, children: [_jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-amber-400 flex-shrink-0" }), field.issue] })) : (_jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-[#059669] flex-shrink-0" }))] }, field.key)))] }, group.category))), result.review_status === 'pending' && (_jsxs("div", { className: "px-3 py-2 bg-[#F8FAFC] flex gap-2 border-t border-[#E2E8F0]", children: [_jsx("button", { onClick: () => on_accept?.(result.content_ref), className: "text-[11px] font-medium text-[#2563EB] hover:underline cursor-pointer", children: "Accept" }), _jsx("button", { onClick: () => on_send_to_client?.(result.content_ref), className: "text-[11px] font-medium text-[#2563EB] hover:underline cursor-pointer", children: "Send issues to Client" }), _jsx("button", { onClick: () => on_dismiss?.(result.content_ref), className: "text-[11px] text-[#94A3B8] hover:underline cursor-pointer", children: "Dismiss" })] }))] }));
}
//# sourceMappingURL=text_extraction.js.map