//! Low-level primitives and utilities
//!
//! This module contains syntax highlighting, ANSI handling,
//! and text manipulation utilities.
//!
//! # WASM Compatibility
//!
//! Most primitives are WASM-compatible. Tree-sitter-based features have
//! pure-Rust fallbacks:
//!
//! | Feature | WASM Module | Runtime Module |
//! |---------|-------------|----------------|
//! | Syntax highlighting | `textmate_engine` | `highlight_engine` |
//! | Auto-indentation | `indent_pattern` | `indent` |
//! | Reference highlighting | `reference_highlight_text` | `reference_highlighter` |

// Pure modules - available for both runtime and WASM
pub mod display_width;
pub mod glob_match;
pub mod grapheme;
pub mod line_wrapping;
pub mod path_utils;
pub mod snippet;
pub mod text_property;

// Modules depending on model::buffer - available for both runtime and WASM
pub mod line_iterator;
pub mod word_navigation;

// Reusable text-editing primitive shared by the legacy Settings UI
// and the plugin widget framework.
pub mod text_edit;

// The single `key → text-editing operation` table shared by the Settings
// input handler and the plugin widget runtime. Runtime-gated because it
// speaks crossterm's `KeyEvent`; both callers are `runtime`-only.
#[cfg(feature = "runtime")]
pub mod text_key;

// Modules using ratatui types (Color, Style, etc.) - available for both runtime and WASM
// since ratatui core is WASM-compatible (only the crossterm backend is native-only)
#[cfg(any(feature = "runtime", feature = "wasm"))]
pub mod ansi;
#[cfg(any(feature = "runtime", feature = "wasm"))]
pub mod ansi_background;
#[cfg(any(feature = "runtime", feature = "wasm"))]
pub mod visual_layout;

// Grammar module - uses syntect which is WASM-compatible with fancy-regex feature
#[cfg(any(feature = "runtime", feature = "wasm"))]
pub mod grammar;
#[cfg(any(feature = "runtime", feature = "wasm"))]
pub use grammar::GrammarRegistry;

// Common highlight types - WASM-compatible
#[cfg(any(feature = "runtime", feature = "wasm"))]
pub mod highlight_types;

// WASM-compatible highlighting, indentation, and reference highlighting
// These provide pure-Rust implementations without tree-sitter
#[cfg(any(feature = "runtime", feature = "wasm"))]
pub mod indent_pattern;
// Per-language regex indentation rules (VS Code style). Pure Rust; works with
// or without tree-sitter. See docs/internal/indentation-rules-design.md.
#[cfg(any(feature = "runtime", feature = "wasm"))]
pub mod indent_rules;
#[cfg(any(feature = "runtime", feature = "wasm"))]
pub mod reference_highlight_text;
#[cfg(any(feature = "runtime", feature = "wasm"))]
pub mod textmate_engine;

// Runtime-only modules (depend on tree-sitter)
// These provide enhanced features using AST analysis
#[cfg(feature = "runtime")]
pub mod detected_language;
#[cfg(feature = "runtime")]
pub mod highlight_engine;
#[cfg(feature = "runtime")]
pub mod highlighter;
#[cfg(feature = "runtime")]
pub mod indent;
#[cfg(feature = "runtime")]
pub mod reference_highlighter;
