/**
 * FieldAuditIcon — designed to be dropped into the
 * `field_action_components.row_end` slot. Renders a small clock toggle that
 * opens/closes the audit history panel for the field.
 *
 * Visible whenever the field has at least one recorded entry. Hidden when
 * the audit provider is absent (so it can sit safely in a shared slot).
 */
'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useFieldAuditOptional } from './context.js';
export function FieldAuditIcon({ field }) {
    const audit = useFieldAuditOptional();
    if (!audit)
        return null;
    const list = audit.entries.get(field.id) ?? [];
    if (list.length === 0)
        return null;
    const is_open = audit.expanded.has(field.id);
    const count = list.length;
    return (_jsxs("button", { type: "button", "data-testid": `field_audit_icon_${field.id}`, "data-state": is_open ? 'open' : 'closed', "aria-expanded": is_open, "aria-label": `Show ${count} audit ${count === 1 ? 'entry' : 'entries'} for ${field.id}`, title: `${count} change${count === 1 ? '' : 's'} recorded`, onClick: () => audit.toggle_expanded(field.id), className: "cls_field_audit_icon inline-flex items-center justify-center gap-1 h-7 px-2 rounded-md text-[11px] font-medium text-amber-700 hover:bg-amber-50 hover:text-amber-900 transition-colors", children: [_jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "h-3.5 w-3.5", children: [_jsx("circle", { cx: "12", cy: "12", r: "9" }), _jsx("polyline", { points: "12 7 12 12 15 14" })] }), _jsx("span", { className: "font-mono", children: count }), _jsx("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: `h-3 w-3 transition-transform ${is_open ? 'rotate-180' : ''}`, children: _jsx("polyline", { points: "6 9 12 15 18 9" }) })] }));
}
//# sourceMappingURL=field_audit_icon.js.map