/**
 * Type definitions for HazoCollabFormView - Unified form view component
 *
 * Supports multiple view modes:
 * - edit: Full form editing (current FormSet functionality)
 * - summary: Read-only summary display (current Summary functionality)
 * - print: Print/PDF optimized view
 * - approval: Workflow view focused on data_ok and reviewer actions
 */
import type * as React from 'react';
import type { ReactNode } from 'react';
import type { IconsBehaviour, ControlName } from '../../types/icons_behaviour.js';
import type { FieldMetadata, FieldMetadataInput, DataOkState, FieldMetadataChange, ConfirmState } from '../shared/field_state/types.js';
import type { NoteEntry, ChatStatus, FileData } from '../hazo_collab_form_base.js';
import type { DateFormat } from '../hazo_collab_form_date.js';
import type { DataTableConfig } from '../hazo_collab_form_data_table.js';
import type { DialogComponents, ComboboxComponents } from '../hazo_add_field_dialog/types.js';
import type { FormFileAttachment } from '../../types/file_attachment.js';
import type { FileManagerConfig } from '../../types/file_manager.js';
import type { FileAcceptMode } from '../../types/file_accept_mode.js';
import type { StylesConfig } from '../../types/style_variant.js';
import type { FieldTypesConfig } from '../../types/field_type_definition.js';
import type { DocLink, DocLinkClickEvent, UploadedFile } from '../../types/doc_link.js';
import type { StyleVariant } from '../../types/style_variant.js';
import type { ClarificationCallbacks, ClarificationTemplate, ClarificationItem, ClarificationResponse } from '../../types/clarification.js';
import type { ExternalUploadManager } from '../autofill_dropzone/external_upload_manager.js';
import type { FieldAction, FieldAuditConfig } from '../../types/field_action.js';
/**
 * Global settings for the form view
 * Replaces the old `global_validations` prop with a structured settings object
 */
export interface FormGlobalSettings {
    /** Validation rule IDs that apply document-wide (not tied to a specific field) */
    file_validations?: string[];
    /** When true, file upload accordions default to open even when no files exist */
    default_file_accordion_open?: boolean;
}
export type { FieldMetadata, FieldMetadataInput, DataOkState, FieldMetadataChange, ConfirmState, NoteEntry, ChatStatus, FileData, FormFileAttachment, FileManagerConfig, FileAcceptMode, IconsBehaviour, ControlName, DateFormat, DialogComponents, ComboboxComponents, StylesConfig, FieldTypesConfig, DocLink, DocLinkClickEvent, UploadedFile, StyleVariant, ClarificationCallbacks, ClarificationTemplate, ClarificationItem, ClarificationResponse, };
/**
 * View mode for HazoCollabFormView
 */
export type ViewMode = 'edit' | 'summary' | 'print' | 'approval';
/**
 * Context passed to every field action slot component.
 *
 * The action component receives this object whenever a field row is rendered,
 * so it can reflect on the field's identity, current value, render mode, and
 * its position in the section/group hierarchy.
 */
export interface FieldActionContext {
    /** Field config — the same `ViewFieldConfig` rendered in the row. */
    field: ViewFieldConfig;
    /** Current value for this field, taken from `form_data[field.id]`. */
    value: unknown;
    /**
     * Effective render mode. `HazoCollabFormView` emits one of
     * `'edit' | 'summary' | 'print' | 'approval'`. `HazoDataForm` emits
     * `'edit' | 'view'`. The union is widened so the same slot component can
     * handle both forms.
     */
    mode: ViewMode | 'edit' | 'view';
    /** `section.section_name`, when available. */
    section_id?: string;
    /** Id of the nearest enclosing group (`field_type='group'`), when available. */
    group_id?: string;
}
/**
 * Consumer-supplied per-field action slots. Each slot receives a
 * `FieldActionContext` and may return any ReactNode (including `null`).
 *
 * Use this to inject per-field actions (audit history icons, RFI buttons,
 * custom popovers, inline audit-log panels) that the form itself does not
 * own. Both slots may be combined — e.g. a clock icon at `row_end` plus an
 * expandable detail panel at `row_below`.
 */
export interface FieldActionComponents {
    /**
     * Rendered at the end of every field row, after the field's value column,
     * file column, data_ok controls, and UnifiedFieldControls. Return `null`
     * to render nothing for a given field.
     */
    row_end?: React.ComponentType<FieldActionContext>;
    /**
     * Rendered as a full-width block immediately below every field row,
     * before the next field begins. Use this for inline audit logs,
     * validation explanations, or any per-field detail panel.
     * Return `null` to render nothing for a given field.
     */
    row_below?: React.ComponentType<FieldActionContext>;
}
/**
 * Reference value data for a single field
 * Used to display reference/comparison values (e.g., prior year tax data) below form fields
 */
export interface ReferenceValueData {
    /** Optional unique identifier for this reference entry (used for deletion) */
    id?: string;
    /** The reference value to display. Arrays are used for table field references. */
    value: string | number | boolean | Record<string, unknown>[];
    /** Label shown before the value (e.g., "Prior Year (2023)") */
    label?: string;
    /** Tax year this reference is from (for display formatting) */
    tax_year?: number;
    /** Background color for the reference tag (default: "bg-muted") */
    background_color?: string;
}
/**
 * Reference data keyed by field ID
 * Allows passing reference values at the form level rather than in field definitions
 */
export type ReferenceData = Record<string, ReferenceValueData | ReferenceValueData[]>;
/**
 * Minimal field structure for the view
 */
export interface ViewFieldConfig {
    id: string;
    field_type?: 'field' | 'inputbox' | 'textarea' | 'checkbox' | 'combo' | 'radio' | 'date' | 'group' | 'data_table' | 'doc' | 'currency' | 'percentage' | 'computed' | 'static_text' | 'summary_row' | 'masked' | 'table';
    component_type?: string;
    label?: string;
    /** Custom React nodes rendered next to the field label (e.g. help icons). */
    label_actions?: React.ReactNode;
    fields?: ViewFieldConfig[];
    dependency?: string;
    visibility?: 'visible' | 'hidden';
    value?: unknown;
    input_options?: Array<{
        value: string;
        label: string;
    }>;
    enable_lock?: boolean;
    enable_visibility_toggle?: boolean;
    enable_delete?: boolean;
    enable_data_ok?: boolean;
    enable_skip?: boolean;
    enable_notes?: boolean;
    enable_chat?: boolean;
    /** @deprecated Use `show_edit_icons` and `show_control_icons` instead */
    show_icons?: boolean;
    /** Override: false to force-hide edit icons (edit_field, edit_group, delete_field) */
    show_edit_icons?: boolean;
    /** Override: false to force-hide control icons (data_ok, skip, notes, chat, lock, visibility, delete) */
    show_control_icons?: boolean;
    /** Public file accept mode: 'none' | 'ai_upload' | 'basic_upload' */
    accept_public_files?: FileAcceptMode;
    /** Private file accept mode: 'none' | 'basic_upload' (ai_upload not supported) */
    accept_private_files?: FileAcceptMode;
    /** @deprecated Use accept_public_files instead */
    accept_files_public?: boolean;
    /** @deprecated Use accept_private_files instead */
    accept_files_private?: boolean;
    private_files_permission?: string;
    /** Table configuration for data_table fields (columns, aggregation, etc.) */
    table_config?: DataTableConfig;
    /** Prompt area for LLM context */
    prompt_area?: string;
    /** Prompt key for LLM context */
    prompt_key?: string;
    /** Classification tag ID for FB form file routing — files with this tag are routed to this group */
    tag_id?: string;
    /** Currency symbol for currency fields (default: '$') */
    currency_symbol?: string;
    /** Decimal places for numeric formatting */
    decimal_places?: number;
    /** Whether field displays as percentage */
    is_percentage?: boolean;
    /** Formula for computed fields (e.g., "salary + bonus") */
    computed_formula?: string;
    /** Field IDs this computed field depends on */
    computed_dependencies?: string[];
    /** Label position relative to input */
    label_position?: 'stacked' | 'inline';
    /** Field group orientation */
    orientation?: 'horizontal' | 'vertical';
    /** Fixed width for badge column alignment */
    badge_column_width?: string;
    /** Fixed width for value column alignment */
    value_column_width?: string;
    /** Field-level value width override */
    value_width?: string;
    /** Paired field for dual-column layouts (e.g., Capital gains / Capital losses) */
    paired_field?: ViewFieldConfig;
    /** Row variant for special row styling */
    row_variant?: 'highlight' | 'normal';
    /** Column headers for paired field layouts */
    column_headers?: Array<{
        label: string;
        width?: string;
    }>;
    /** Doc link display mode for groups: 'field' shows per-field icons, 'row' consolidates into one icon at end of row */
    doc_link_display?: 'field' | 'row';
    /** Style variant for hierarchical styling (e.g., 'header_h1', 'total_h3') */
    style_variant?: StyleVariant;
    /** Item code box prefix (e.g., '1', '10') */
    item_code?: string;
    /** Badge letter/text (e.g., 'J', 'M') */
    badge?: string;
    /** Plain text formula annotation (e.g., "P less (Q + F + U)") */
    formula_label?: string;
    /** Static content for display-only fields */
    static_content?: string;
    /** Display variant for field layout */
    display_variant?: 'label_only' | 'value_only' | 'inline';
    /** Text alignment */
    text_align?: 'left' | 'center' | 'right';
    /** Whether this is a worksheet-style table */
    is_worksheet?: boolean;
    /** Field IDs to summarize in summary_row */
    summary_fields?: string[];
    /** Note displayed next to summary row label */
    summary_note?: string;
    /** Masked input type (e.g., 'tfn', 'abn', or custom) */
    masked_type?: string;
    /** Display format with X/# placeholders (e.g., 'XXX XXX XXX') */
    display_format?: string;
    /** Help tooltip with message and/or formula display */
    help_tooltip?: {
        text?: string;
        link?: string;
        show_formula?: boolean;
        formula_display?: string;
    };
    /** Context key for hazo_ihelp inline help icon in the label */
    ihelp_context_key?: string;
    /** Document links for field-level file references */
    doc_links?: DocLink[];
    /** Client-facing label (different from internal label) */
    client_label?: string;
    /** Client-facing description */
    client_description?: string;
    /** Client-facing help text */
    client_help_text?: string;
    /** Whether this field is client-eligible */
    client_eligible?: boolean;
    /** Tags for field categorization */
    tags?: string[];
    /** Scope for field filtering */
    scope?: string;
    /** Table columns for data form table fields */
    table_columns?: DataFormTableColumn[];
    /** Minimum rows for table */
    table_min_rows?: number;
    /** Maximum rows for table */
    table_max_rows?: number;
    /** Title displayed above data form table */
    table_title?: string;
    /** Whether field is required */
    required?: boolean;
    /** Minimum value for numeric fields */
    min?: number;
    /** Maximum value for numeric fields */
    max?: number;
    /** Minimum length for text fields */
    min_length?: number;
    /** Maximum length for text fields */
    max_length?: number;
    /** Regex pattern for validation */
    pattern?: string;
    /** Placeholder text */
    placeholder?: string;
    /** Whether field is disabled */
    disabled?: boolean;
    /** Default value */
    default_value?: unknown;
    /** Enable file upload icon for this field (overrides form-level default_accept_files) */
    accept_files?: boolean;
    /**
     * Extra CSS classes applied to the outermost `cls_collab_field_container` wrapper div.
     * Use Tailwind utility classes (e.g. `'[grid-column-start:1]'`) to force grid
     * positioning when field_columns > 1.  Has no effect in single-column mode.
     */
    container_class_name?: string;
    /** Wrap this field in a collapsible accordion */
    accordion?: boolean;
    /** Accordion starts open (default: false — starts collapsed) */
    accordion_default_open?: boolean;
    /** Per-group override: enable collapse for this group */
    collapsible?: boolean;
    /** Per-group override: start collapsed */
    initial_collapsed?: boolean;
    /** Input type for renderer resolution (e.g., 'combo', 'radio', 'alpha').
     *  Used when field_type is generic ('field') to resolve the correct renderer. */
    input_type?: string;
    /**
     * IDs of validation rules that apply to this field or group.
     * Rules are defined in the validation rule editor and referenced here by their slug ID.
     * @example ['check_payg_coverage', 'verify_abn_format']
     */
    validation_rules?: string[];
    /**
     * Override for file upload accordion default open state.
     * When true, file accordion starts open even with no files.
     * Cascade: field > group > section > global_settings
     */
    default_file_accordion_open?: boolean;
}
/**
 * Data form table column definition
 */
export interface DataFormTableColumn {
    id: string;
    label: string;
    field_type?: string;
    width?: string;
    required?: boolean;
    options?: Array<{
        value: string;
        label: string;
    }>;
    decimal_places?: number;
    currency_symbol?: string;
    subtotal?: boolean;
    default_value?: unknown;
    reference_value?: string;
}
/**
 * Section structure for the view
 */
export interface ViewSection {
    section_name?: string;
    groups?: ViewFieldConfig[];
    icon?: string;
    /** Public file accept mode: 'none' | 'ai_upload' | 'basic_upload' */
    accept_public_files?: FileAcceptMode;
    /** Private file accept mode: 'none' | 'basic_upload' (ai_upload not supported) */
    accept_private_files?: FileAcceptMode;
    /** @deprecated Use accept_public_files instead */
    accept_files_public?: boolean;
    /** @deprecated Use accept_private_files instead */
    accept_files_private?: boolean;
    files_dir?: string;
    icons_behaviour?: IconsBehaviour;
    /** Sub-section layout direction for data form rendering */
    sub_section_layout?: 'vertical' | 'horizontal';
    /** Style variant for section header styling */
    style_variant?: StyleVariant;
    /**
     * Override for file upload accordion default open state at section level.
     * Cascade: field > group > section > global_settings
     */
    default_file_accordion_open?: boolean;
}
/**
 * Chat configuration
 */
export interface ChatConfig {
    group_id: string;
    api_base_url?: string;
    timezone?: string;
    realtime_mode?: 'polling' | 'manual';
    polling_interval?: number;
    read_only?: boolean;
    hide_references?: boolean;
    hide_sidebar?: boolean;
    hide_preview?: boolean;
    display_mode?: 'embedded' | 'side_panel' | 'overlay';
    container_element?: HTMLElement | null;
    log_polling?: boolean;
}
/**
 * View settings shared across all modes
 */
export interface ViewSettings {
    date_format: DateFormat;
    show_empty_fields: boolean;
    empty_field_text: string;
    empty_section_text: string;
    empty_table_text: string;
    check_dependencies: boolean;
    controls_display: 'inline' | 'popover';
    enable_data_ok: boolean;
    data_ok_mode: 'checkbox' | 'multi_state';
    data_ok_editable: boolean;
    data_ok_hidden_states?: DataOkState[];
    enable_notes: boolean;
    notes_panel_style?: 'popover' | 'slide_panel';
    notes_background_color?: string;
    notes_save_mode?: 'explicit' | 'auto';
    notes_mode?: 'controlled' | 'api';
    enable_chat: boolean;
    enable_visibility_toggle: boolean;
    visibility_editable: boolean;
    enable_lock: boolean;
    lock_editable: boolean;
    enable_delete: boolean;
    enable_skip: boolean;
    skip_editable: boolean;
    data_ok_row_color: string | 'none';
    data_not_ok_row_color: string | 'none';
    pending_row_color: string | 'none';
    highlight_empty_required: boolean;
    on_data_ok_hidden: boolean;
    on_data_ok_protected: boolean;
    include_chat_in_dropdown?: boolean;
    include_notes_in_dropdown?: boolean;
    extract_active_chat?: boolean;
    extract_active_notes?: boolean;
    action_buttons_borderless?: boolean;
    active_role?: string;
    user_role?: 'author' | 'responder';
}
/**
 * Callbacks for form view interactions
 */
export interface ViewCallbacks {
    on_field_change?: (field_id: string, value: unknown) => void;
    on_form_data_change?: (data: Record<string, unknown>) => void;
    on_metadata_change?: (change: FieldMetadataChange) => void;
    on_data_ok_change?: (field_id: string, value: boolean | DataOkState) => void;
    on_notes_change?: (field_id: string, notes: NoteEntry[]) => void;
    on_visibility_change?: (field_id: string, visibility: 'visible' | 'hidden') => void;
    on_lock_change?: (field_id: string, locked: boolean) => void;
    on_delete?: (field_id: string) => void;
    on_skip_change?: (field_id: string, skipped: boolean) => void;
    on_edit_section?: (section_index: number) => void;
    on_edit_field?: (field_id: string) => void;
    on_add_field?: (after_field_id: string, field_definition: unknown) => void;
    on_add_group_config?: (position_id: string, group_config: ViewFieldConfig) => void;
    /** Callback when edit field icon is clicked - opens edit dialog with current field config */
    on_edit_field_config?: (field_id: string, current_config: ViewFieldConfig) => void;
    /** Callback when delete field icon is clicked - removes field from form structure */
    on_delete_field?: (field_id: string) => void;
    /** Callback when edit elements icon is clicked - opens unified edit dialog for field or group */
    on_edit_elements?: (element_id: string, element_type: 'field' | 'group') => void;
    /** Callback when re-validate icon is clicked - re-runs validation rules for a field/group */
    on_revalidate?: (field_id: string, validation_rule_ids: string[]) => void;
    /** Callback when files change for any field */
    on_field_files_change?: (field_id: string, files: FormFileAttachment[]) => void;
    /** Callback when private files change */
    on_field_private_files_change?: (field_id: string, files: FormFileAttachment[]) => void;
}
/**
 * Context value for FormView
 * Provides shared state and configuration to all view components
 */
export interface FormViewContextValue {
    mode: ViewMode;
    sections: ViewSection[];
    form_data: Record<string, unknown>;
    field_metadata: Record<string, FieldMetadata>;
    reference_data?: ReferenceData;
    icons_behaviour?: IconsBehaviour;
    chat_config?: ChatConfig;
    current_user?: {
        id?: string;
        name: string;
        email: string;
        profile_image?: string;
    };
    /**
     * Whether the current role can access private files
     * Resolved from active_role's can_access_private_files setting in icons_behaviour
     */
    can_access_private_files: boolean;
    settings: ViewSettings;
    callbacks: ViewCallbacks;
    file_manager?: FileManagerConfig;
    styles_config?: StylesConfig;
    field_types_config?: FieldTypesConfig;
    autofill_api_endpoint?: string;
    upload_manager?: ExternalUploadManager;
    render_icon?: (icon_name: string) => ReactNode;
    render_field_value?: (field: ViewFieldConfig, value: unknown, default_render: ReactNode) => ReactNode;
    render_files?: (files: FormFileAttachment[], field_id: string) => ReactNode;
    dialog_components?: DialogComponents;
    combobox_components?: ComboboxComponents;
    /** @deprecated Use `field_actions` instead. Will be removed in a future major. */
    field_action_components?: FieldActionComponents;
    /** Merged array of composable per-field actions (new v5.10 path). */
    field_actions?: FieldAction[];
    /**
     * Audit configuration forwarded from the top-level form props.
     * Available to view-layer hooks and callbacks for intent emission.
     */
    field_audit?: FieldAuditConfig;
    /**
     * Stable form ID forwarded from the top-level form props.
     * Included in audit intent payloads.
     */
    form_id?: string;
    /**
     * Look up a field's config and its enclosing section/group by id. Built
     * from `sections` so consumers (e.g. BaseFieldLayout) can resolve a row's
     * FieldActionContext without re-walking the section tree per render.
     */
    field_lookup?: ReadonlyMap<string, {
        field: ViewFieldConfig;
        section_id?: string;
        group_id?: string;
    }>;
    enable_library?: boolean;
    library_api_base_url?: string;
    library_table_name?: string;
    library_scope_id?: string | null;
    enable_clarifications: boolean;
    clarification_display: 'both' | 'badge_only' | 'section_only';
    clarification_callbacks?: ClarificationCallbacks;
    clarification_templates: Record<string, ClarificationTemplate>;
    show_confirm_action?: boolean;
    /** Strip the bordered card chrome from EditSection when true. */
    disable_section_card?: boolean;
    /** Hide the section title header bar inside EditSection when true. */
    hide_section_header?: boolean;
    on_reference_delete?: (field_id: string, index: number, reference_id?: string) => void;
    global_settings?: FormGlobalSettings;
}
/**
 * Props for HazoCollabFormView component
 */
export interface HazoCollabFormViewProps {
    /**
     * View mode - determines rendering behavior
     * - 'edit': Full form editing
     * - 'summary': Read-only summary display
     * - 'print': Print/PDF optimized
     * - 'approval': Workflow focused on data_ok
     */
    mode: ViewMode;
    /**
     * Number of fields to display per row in `edit` mode.
     *
     * - `1` (default): each field spans the full row width. The standard
     *   3-column chat-aligned grid is used so that chat panels appear beside
     *   the field.
     * - `2`: fields are laid out 2 per row using a CSS `grid-cols-2` layout.
     * - `3`: fields are laid out 3 per row using a CSS `grid-cols-3` layout.
     *
     * Wide fields (textareas, data tables, file upload groups) should have
     * `force_full_row` set to always span the full row regardless of this
     * setting. In practice you can pass `container_class_name="col-span-full"`
     * for any field that must not share a row.
     *
     * Currently only affects `edit` mode. Summary, print and approval views
     * are unaffected.
     *
     * @default 1
     */
    field_columns?: 1 | 2 | 3;
    /**
     * Sections to render
     */
    sections: ViewSection[];
    /**
     * Form data values keyed by field ID
     */
    form_data: Record<string, unknown>;
    /**
     * Field metadata keyed by field ID
     * Accepts both normalized and input formats
     */
    field_metadata?: Record<string, FieldMetadataInput>;
    /**
     * Reference data to display below form fields
     * Keyed by field ID, each entry shows a reference value with optional label
     * Example use case: displaying prior year tax values for comparison
     * Note: Field-level reference props (reference_value, reference_label) take precedence
     */
    reference_data?: ReferenceData;
    /**
     * Icons behaviour configuration
     */
    icons_behaviour?: IconsBehaviour;
    /**
     * Active role for role-based control visibility
     */
    active_role?: string;
    /**
     * User role for visibility filtering
     */
    user_role?: 'author' | 'responder';
    /**
     * Current user for chat/notes attribution
     */
    current_user?: {
        id?: string;
        name: string;
        email: string;
        profile_image?: string;
    };
    /** Styles configuration for data form and financial field rendering */
    styles_config?: StylesConfig;
    /** Field types configuration for custom field types (TFN, ABN, etc.) */
    field_types_config?: FieldTypesConfig;
    /** Date format for date fields */
    date_format?: DateFormat;
    /** Show fields with empty values (default: true) */
    show_empty_fields?: boolean;
    /** Text for empty field values (default: "Not provided") */
    empty_field_text?: string;
    /** Text for empty sections (default: "No information entered in this section") */
    empty_section_text?: string;
    /** Text for empty tables (default: "No entries") */
    empty_table_text?: string;
    /** Check field dependencies (default: true) */
    check_dependencies?: boolean;
    /** How to display controls (default: 'inline') */
    controls_display?: 'inline' | 'popover';
    /** Enable data OK control */
    enable_data_ok?: boolean;
    /** Data OK mode */
    data_ok_mode?: 'checkbox' | 'multi_state';
    /** Data OK is editable */
    data_ok_editable?: boolean;
    /** States to hide from data OK selection */
    data_ok_hidden_states?: DataOkState[];
    /** Enable notes */
    enable_notes?: boolean;
    /** Notes panel style */
    notes_panel_style?: 'popover' | 'slide_panel';
    /** Notes background color */
    notes_background_color?: string;
    /** Notes save mode */
    notes_save_mode?: 'explicit' | 'auto';
    /** Notes management mode */
    notes_mode?: 'controlled' | 'api';
    /** Enable chat */
    enable_chat?: boolean;
    /** Chat group ID */
    chat_group_id?: string;
    /** Chat API base URL */
    chat_api_base_url?: string;
    /** Chat timezone */
    chat_timezone?: string;
    /** Chat realtime mode */
    chat_realtime_mode?: 'polling' | 'manual';
    /** Chat polling interval */
    chat_polling_interval?: number;
    /** Chat read only mode */
    chat_read_only?: boolean;
    /** Chat hide references - when true, hides the references section */
    chat_hide_references?: boolean;
    /** Chat hide sidebar - when true, hides the entire document viewer sidebar (v5.2.0+) */
    chat_hide_sidebar?: boolean;
    /** Chat hide preview - when true, hides message preview/attachment preview */
    chat_hide_preview?: boolean;
    /** Chat display mode - controls how chat is rendered */
    chat_display_mode?: 'embedded' | 'side_panel' | 'overlay';
    /** Chat container element - container for portal rendering */
    chat_container_element?: HTMLElement | null;
    /** Chat log polling - when true, logs polling activity to console (default: false) */
    chat_log_polling?: boolean;
    /** Enable visibility toggle */
    enable_visibility_toggle?: boolean;
    /** Visibility is editable */
    visibility_editable?: boolean;
    /** Enable lock */
    enable_lock?: boolean;
    /** Lock is editable */
    lock_editable?: boolean;
    /** Enable delete */
    enable_delete?: boolean;
    /** Enable skip/N/A */
    enable_skip?: boolean;
    /** Skip is editable */
    skip_editable?: boolean;
    /** Background color for OK rows */
    data_ok_row_color?: string | 'none';
    /** Background color for not OK rows */
    data_not_ok_row_color?: string | 'none';
    /** Background color for pending rows */
    pending_row_color?: string | 'none';
    /**
     * When true, required fields that are empty or have a validation error
     * get a light pink (bg-red-50) background on their input element.
     * Default: false.
     */
    highlight_empty_required?: boolean;
    /** Auto-hide when data_ok is OK */
    on_data_ok_hidden?: boolean;
    /**
     * Auto-lock field when data_ok='ok', unlock when data_ok='not_ok' (default: true)
     * Works symmetrically: lock on 'ok', unlock on 'not_ok'
     */
    protect_on_dataok?: boolean;
    /** @deprecated Use protect_on_dataok instead */
    on_data_ok_protected?: boolean;
    /** Include chat in kebab dropdown */
    include_chat_in_dropdown?: boolean;
    /** Include notes in kebab dropdown */
    include_notes_in_dropdown?: boolean;
    /** Extract chat when active */
    extract_active_chat?: boolean;
    /** Extract notes when active */
    extract_active_notes?: boolean;
    /** Remove borders from action buttons */
    action_buttons_borderless?: boolean;
    /** Field value change (edit mode) */
    on_field_change?: (field_id: string, value: unknown) => void;
    /** Form data change */
    on_form_data_change?: (data: Record<string, unknown>) => void;
    /** Metadata change */
    on_metadata_change?: (change: FieldMetadataChange) => void;
    /** Data OK change */
    on_data_ok_change?: (field_id: string, value: boolean | DataOkState) => void;
    /** Notes change */
    on_notes_change?: (field_id: string, notes: NoteEntry[]) => void;
    /** Visibility change */
    on_visibility_change?: (field_id: string, visibility: 'visible' | 'hidden') => void;
    /** Lock change */
    on_lock_change?: (field_id: string, locked: boolean) => void;
    /** Delete */
    on_delete?: (field_id: string) => void;
    /** Skip change */
    on_skip_change?: (field_id: string, skipped: boolean) => void;
    /** Edit section navigation */
    on_edit_section?: (section_index: number) => void;
    /** Edit field navigation */
    on_edit_field?: (field_id: string) => void;
    /** Add field */
    on_add_field?: (after_field_id: string, field_definition: unknown) => void;
    /** Add group at section level - for adding groups to section.groups */
    on_add_group_config?: (position_id: string, group_config: ViewFieldConfig) => void;
    /** Edit field config - opens edit dialog with current field properties */
    on_edit_field_config?: (field_id: string, current_config: ViewFieldConfig) => void;
    /** Delete field - removes field from form structure (not soft delete) */
    on_delete_field?: (field_id: string) => void;
    /** Re-validate - re-runs validation rules for a field/group */
    on_revalidate?: (field_id: string, validation_rule_ids: string[]) => void;
    /** Callback when a reference entry is deleted */
    on_reference_delete?: (field_id: string, index: number, reference_id?: string) => void;
    /** File manager configuration for hazo_files integration */
    file_manager?: FileManagerConfig;
    /**
     * Consumer-provided API endpoint for LLM-based autofill extraction.
     * When provided along with `accept_public_files: 'ai_upload'` on a group config,
     * a dropzone is rendered at the top of the group.
     */
    autofill_api_endpoint?: string;
    /**
     * Optional background upload manager. When provided, AutofillDropzone
     * submits files to this manager instead of running its inline pipeline.
     * The on_autofill_complete callback is NOT called in manager mode — the
     * consuming app handles merging via its own job:completed subscription.
     */
    upload_manager?: ExternalUploadManager;
    /** Callback when files change for any field */
    on_field_files_change?: (field_id: string, files: FormFileAttachment[]) => void;
    /** Callback when private files change */
    on_field_private_files_change?: (field_id: string, files: FormFileAttachment[]) => void;
    /** Optional shadcn Dialog components */
    dialog_components?: DialogComponents;
    /** Optional shadcn Popover/Command components for field type selector */
    combobox_components?: ComboboxComponents;
    /**
     * @deprecated Use `field_actions` instead. Will be removed in a future major.
     *
     * Optional consumer-supplied components rendered inline next to every field.
     * Each slot receives the field's config, current value, and mode.
     *
     * Use this to inject per-field actions (audit history, RFI buttons, etc.)
     * that the form itself does not own.
     */
    field_action_components?: FieldActionComponents;
    /**
     * Composable array of per-field action descriptors (v5.10+).
     * Replaces `field_action_components` for new integrations.
     * Built-in actions (audit icon) are added automatically when `field_audit` is set.
     */
    field_actions?: FieldAction[];
    /**
     * Configuration for the hazo_audit integration.
     * When set, mounts a FieldAuditIcon in the row_end slot via `field_actions`.
     * Also enables intent emission on form lifecycle events.
     * Requires hazo_audit to be installed as a peer dependency.
     */
    field_audit?: FieldAuditConfig;
    /**
     * Stable form ID passed as `form_id` in audit intent payloads.
     * Optional — payload field is omitted when absent.
     */
    form_id?: string;
    /**
     * @deprecated
     * Convenience flag that turns on the built-in `FieldAudit` feature.
     * When `true` the view mounts a `FieldAuditProvider`, auto-records every
     * change to `form_data` as a `manual` entry, and overlays the audit
     * icon (`row_end`) + history panel (`row_below`) into the
     * `field_action_components` slot. Any consumer-supplied slot components
     * win on collision.
     *
     * The audit lives in-session — no persistence. Pair with a backend write
     * inside `on_field_change` if you need durability. Intended for the
     * tax-agent side of a workflow only; omit the flag on the client portal
     * to hide audit history.
     *
     * @default false
     */
    enable_field_audit?: boolean;
    /**
     * @deprecated
     * Idle window (ms) before the built-in audit watcher records a `manual`
     * entry. Controlled inputs fire on every keystroke; without debouncing
     * each character would produce its own entry. The default of 750ms
     * coalesces a typing burst into one entry whose `prev_value` is the
     * value at the start of the burst and `new_value` is the value when
     * typing stopped.
     *
     * Set to a small value (e.g. 50) in tests to assert debouncing without
     * waiting. Has no effect unless `enable_field_audit` is true.
     *
     * @default 750
     */
    audit_debounce_ms?: number;
    /**
     * Enable Library/Custom tabs in Add Field and Add Group dialogs
     * When true, shows a Library tab for selecting pre-defined fields from the Field Library
     * @default true
     */
    enable_library?: boolean;
    /**
     * API endpoint for the field library
     * @default '/api/hazo_connect/sqlite/data'
     */
    library_api_base_url?: string;
    /**
     * Database table name for the field library
     * @default 'hazo_collab_form_elts'
     */
    library_table_name?: string;
    /**
     * Scope ID for filtering library elements
     */
    library_scope_id?: string | null;
    /** Enable clarification section and badges (default: false) */
    enable_clarifications?: boolean;
    /**
     * Controls how clarifications are displayed in the form.
     * - 'both' (default): Show badges on fields AND inline ClarificationSection
     * - 'badge_only': Show only badges on fields (no inline section)
     * - 'section_only': Show only the inline ClarificationSection (no badges)
     * @default 'both'
     */
    clarification_display?: 'both' | 'badge_only' | 'section_only';
    /** Callbacks for clarification lifecycle events */
    clarification_callbacks?: ClarificationCallbacks;
    /** Override default clarification templates (merged with defaults) */
    clarification_templates?: Record<string, ClarificationTemplate>;
    /**
     * @deprecated Use `global_settings.file_validations` instead
     */
    global_validations?: string[];
    /**
     * Global settings for the form view.
     * Includes file_validations (replaces global_validations) and default_file_accordion_open.
     */
    global_settings?: FormGlobalSettings;
    /** Custom icon renderer */
    render_icon?: (icon_name: string) => ReactNode;
    /** Custom field value renderer */
    render_field_value?: (field: ViewFieldConfig, value: unknown, default_render: ReactNode) => ReactNode;
    /** Custom files renderer */
    render_files?: (files: FormFileAttachment[], field_id: string) => ReactNode;
    /** Custom section header renderer */
    render_section_header?: (section: ViewSection, index: number, default_header: ReactNode) => ReactNode;
    /** Custom section footer renderer */
    render_section_footer?: (section: ViewSection, index: number) => ReactNode;
    /** Custom empty section renderer */
    render_empty_section?: (section: ViewSection) => ReactNode;
    /**
     * When true, fields whose metadata has confirm_state === 'prefilled' render an inline
     * Check button. Clicking it fires on_metadata_change({ field_id, changes: { confirm_state: 'confirmed' } }).
     * Form-level only — no per-field override. Defaults to false.
     */
    show_confirm_action?: boolean;
    /**
     * When true, `EditSection` renders without the bordered card chrome.
     * Removes `border rounded-lg bg-card shadow-sm` from the wrapper div.
     * `cls_edit_section` and `overflow-hidden` are always kept.
     * Only affects `edit` mode. Defaults to false.
     */
    disable_section_card?: boolean;
    /**
     * When true, the section title bar (icon + section name) inside `EditSection`
     * is not rendered. Only affects `edit` mode. Defaults to false.
     */
    hide_section_header?: boolean;
    /** Show edit buttons (summary mode) */
    show_edit_buttons?: boolean;
    /** Edit button text */
    edit_button_text?: string;
    /** Edit button icon */
    edit_button_icon?: ReactNode;
    /** Header slot for print mode */
    print_header?: ReactNode;
    /** Footer slot for print mode */
    print_footer?: ReactNode;
    /** Page break between sections (print mode) */
    print_page_break_between_sections?: boolean;
    /** Group fields by approval status */
    approval_group_by_status?: boolean;
    /** Show progress indicator */
    approval_show_progress?: boolean;
    /** Callback for "next pending" navigation */
    on_next_pending?: () => void;
    /** Enable bulk approve for sections */
    enable_bulk_approve?: boolean;
    /** Callback for bulk approve */
    on_bulk_approve?: (section_index: number) => void;
    /** Root container class */
    class_name?: string;
    /** Section class */
    section_class_name?: string;
    /** Section header class */
    section_header_class_name?: string;
    /** Section content class */
    section_content_class_name?: string;
    /** Field class */
    field_class_name?: string;
    /** Group class */
    group_class_name?: string;
    /** Table class */
    table_class_name?: string;
    /** Field separator color */
    field_separator_color?: string;
    /** Icon background color */
    icon_background_color?: string;
    /** Icon color */
    icon_color?: string;
    /** Default icon */
    default_icon?: ReactNode;
}
/**
 * Ref interface for HazoCollabFormView
 */
export interface HazoCollabFormViewRef {
    /** Get current form data */
    get_form_data: () => Record<string, unknown>;
    /** Get field metadata */
    get_field_metadata: () => Record<string, FieldMetadata>;
    /** Get current sections configuration (for template export) */
    get_sections: () => ViewSection[];
    /** Scroll to section */
    scroll_to_section: (section_index: number) => void;
    /** Scroll to field */
    scroll_to_field: (field_id: string) => void;
    /** Get current mode */
    get_mode: () => ViewMode;
    /** Set mode */
    set_mode: (mode: ViewMode) => void;
    /** Get all files data - extracted from form_data with __files_ prefix */
    get_files_data: () => Record<string, FormFileAttachment[]>;
    /** Get all private files data - extracted from form_data with __private_files_ prefix */
    get_private_files_data: () => Record<string, FormFileAttachment[]>;
    /** Get all clarification items from form_data */
    get_clarifications: () => ClarificationItem[];
    /** Scroll to a specific clarification card by ID */
    scroll_to_clarification: (id: string) => void;
    /**
     * Mark every field currently in confirm_state === 'prefilled' as 'confirmed'.
     * Fires one on_metadata_change per affected field.
     * Returns the field IDs that were transitioned.
     */
    confirm_all_prefilled(): string[];
}
//# sourceMappingURL=types.d.ts.map