//! Host-agnostic terminal primitives (synchronous, no tokio dependency).
//!
//! Faithful Rust port of the clean-room TypeScript `src/ui/` subtree
//! (`indusagi/tui` subpath). This is the framework-agnostic terminal-primitive
//! layer: it has no ratatui/crossterm dependency and is pure string/byte logic.
//! Per W-8 the logical key model is preserved here, but raw terminal decode is
//! delegated to crossterm at the render layer — these primitives stay
//! decode-agnostic.
//!
//! Module map (mirrors `src/ui/index.ts`):
//! - [`keys`]        ← `keys.ts`           (logical key model + matching/parsing)
//! - [`keybindings`] ← `keybindings.ts`    (`EditorAction`, default table, resolver)
//! - [`fuzzy`]       ← `fuzzy.ts`          (subsequence fuzzy match + filter)
//! - [`autocomplete`]← `autocomplete.ts`   (combined slash/@file/path provider)
//! - [`editor`]      ← `editor-component.ts`(editor component trait surfaces)
//! - [`theme`]       ← `theme-types.ts`    (theme function-map contracts)
//! - [`contracts`]   ← `contracts.ts`      (`Component`, `TUI`, overlay options)
//! - [`utils`]       ← `utils.ts`          (width, wrap, truncate, slice, ANSI)
//!
//! M6a status: fully implemented + green (240 tests). The ratatui render layer
//! (12 dialogs, messages, footer/statusline/taskpanel, `InteractiveApp`,
//! ui-bridge projection) lives in the `indusagi-tui-render` crate (M6b).

pub mod autocomplete;
pub mod contracts;
pub mod editor;
pub mod fuzzy;
pub mod keybindings;
pub mod keys;
pub mod theme;
pub mod utils;

// Re-export the public surface at the crate root, matching `index.ts`.
pub use autocomplete::{
    AutocompleteItem, AutocompleteProvider, CombinedAutocompleteProvider, SlashCommand,
};
pub use contracts::{
    Component, OverlayAnchor, OverlayHandle, OverlayMargin, OverlayOptions, SizeValue, Tui,
};
pub use editor::EditorComponent;
pub use fuzzy::{FuzzyMatch, fuzzy_filter, fuzzy_match};
pub use keybindings::{
    DEFAULT_EDITOR_KEYBINDINGS, EditorAction, EditorKeybindingsConfig, EditorKeybindingsManager,
    get_editor_keybindings, set_editor_keybindings,
};
pub use keys::{
    Key, KeyEventType, KeyId, is_key_release, is_key_repeat, is_kitty_protocol_active, matches_key,
    parse_key, set_kitty_protocol_active,
};
pub use theme::{EditorTheme, MarkdownTheme, SelectListTheme, SettingsListTheme};
pub use utils::{truncate_to_width, visible_width, wrap_text_with_ansi};
