'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Switch } from '../ui/switch.js';
import { EditorSection, SwitchCard, LABEL_ICONS, } from '../../../shared/editor_theme/index.js';
export function ControlsTab({ field, is_group, on_update, on_commit, readonly = false }) {
    // Resolve effective values (new props fall back to deprecated show_icons)
    const edit_icons_value = field.show_edit_icons ?? field.show_icons;
    const control_icons_value = field.show_control_icons ?? field.show_icons;
    // Show data ok default when control icons are not force-hidden
    const show_data_ok_section = control_icons_value !== false;
    return (_jsxs("div", { children: [_jsx(EditorSection, { children: _jsxs("p", { className: "text-xs text-muted-foreground p-2 bg-muted/30 rounded", children: ["Icons show automatically based on ", _jsx("span", { className: "font-medium", children: "icons_behaviour" }), " role config. Use the overrides below to force-hide icon categories on this ", is_group ? 'group' : 'field', "."] }) }), _jsx(EditorSection, { children: _jsx(SwitchCard, { icon: LABEL_ICONS.show_edit_icons, label: "Show Edit Icons", description: is_group
                        ? 'Edit group, delete group icons on the group header'
                        : 'Edit field, delete field icons on this field', children: _jsx(Switch, { checked: edit_icons_value !== false, onCheckedChange: (v) => {
                            // When turning on, remove the override (undefined = role-driven)
                            // When turning off, explicitly set false to force-hide
                            on_update({ show_edit_icons: v ? undefined : false, show_icons: undefined });
                            on_commit(`${v ? 'Enable' : 'Disable'} edit icons on ${is_group ? 'group' : 'field'}`);
                        }, disabled: readonly }) }) }), _jsx(EditorSection, { last: !show_data_ok_section, children: _jsx(SwitchCard, { icon: LABEL_ICONS.show_control_icons, label: "Show Control Icons", description: is_group
                        ? 'Data OK, notes, chat, lock, visibility icons on the group header'
                        : 'Data OK, notes, chat, lock, visibility icons on this field', children: _jsx(Switch, { checked: control_icons_value !== false, onCheckedChange: (v) => {
                            on_update({ show_control_icons: v ? undefined : false, show_icons: undefined });
                            on_commit(`${v ? 'Enable' : 'Disable'} control icons on ${is_group ? 'group' : 'field'}`);
                        }, disabled: readonly }) }) }), show_data_ok_section && (_jsxs(EditorSection, { last: true, children: [_jsx(SwitchCard, { icon: LABEL_ICONS.data_ok, label: "Default to OK", description: is_group
                            ? 'Set the initial Data OK state for this group'
                            : 'Set the initial Data OK state for this field', children: _jsx(Switch, { checked: field.data_ok_default === 'ok', onCheckedChange: (checked) => {
                                on_update({ data_ok_default: checked ? 'ok' : 'not_ok' });
                                on_commit(`Set default to ${checked ? 'OK' : 'Not OK'}`);
                            }, disabled: readonly }) }), _jsxs("p", { className: "text-xs text-muted-foreground p-2 bg-muted/30 rounded", children: ["Data OK mode (checkbox vs multistate) is configured in the", ' ', _jsx("span", { className: "font-medium", children: "Icons Behaviour" }), " tab at section level."] })] }))] }));
}
//# sourceMappingURL=controls_tab.js.map