pub mod dispatch;
pub mod engine;
pub mod error;
pub mod ir;
pub mod lifecycle;
pub mod logger;
pub mod reactive;
pub mod reconcile;
pub mod render;
pub mod serialize;
pub mod state;

// WASM bindings module
// The FFI types (wasm::ffi) are always available for testing and cross-platform use.
// The actual WASM bindings are conditionally compiled:
// - `js` feature: JavaScript bindings via wasm-bindgen (Node.js, Bun, browsers)
// - `wasi` feature: WASI-compatible C FFI (Go, Python, Rust, etc.)
pub mod wasm;

// UniFFI bindings for native platforms (Kotlin, Swift, Python, Ruby)
#[cfg(feature = "uniffi")]
pub mod uniffi;

// UniFFI scaffolding must be in crate root
#[cfg(feature = "uniffi")]
::uniffi::setup_scaffolding!();

pub use engine::Engine;
pub use error::EngineError;

pub use ir::{ast_to_ir, Element, Value};
pub use lifecycle::{Module, ModuleInstance};
pub use reconcile::Patch;
pub use state::StateChange;

#[cfg(test)]
mod tailwind_tests {
    use hypen_tailwind_parse::parse_classes;

    #[test]
    fn test_tailwind_parse_basic() {
        let output = parse_classes("p-4 text-blue-500 bg-white");
        assert_eq!(output.base.len(), 3);

        let props = output.to_props();
        assert_eq!(props.get("padding"), Some(&"1rem".to_string()));
        assert_eq!(props.get("color"), Some(&"#3b82f6".to_string()));
        assert_eq!(props.get("background-color"), Some(&"#ffffff".to_string()));
    }

    #[test]
    fn test_tailwind_parse_with_breakpoints() {
        let output = parse_classes("p-4 md:p-8 lg:p-12");

        let props = output.to_props();
        assert_eq!(props.get("padding"), Some(&"1rem".to_string()));
        assert_eq!(props.get("padding@md"), Some(&"2rem".to_string()));
        assert_eq!(props.get("padding@lg"), Some(&"3rem".to_string()));
    }

    #[test]
    fn test_tailwind_parse_with_hover() {
        let output = parse_classes("bg-white hover:bg-blue-500");

        let props = output.to_props();
        assert_eq!(props.get("background-color"), Some(&"#ffffff".to_string()));
        assert_eq!(
            props.get("background-color:hover"),
            Some(&"#3b82f6".to_string())
        );
    }

    #[test]
    fn test_tailwind_parse_layout() {
        let output = parse_classes("flex justify-center items-center gap-4");

        let props = output.to_props();
        assert_eq!(props.get("display"), Some(&"flex".to_string()));
        assert_eq!(props.get("justify-content"), Some(&"center".to_string()));
        assert_eq!(props.get("align-items"), Some(&"center".to_string()));
        assert_eq!(props.get("gap"), Some(&"1rem".to_string()));
    }

    #[test]
    fn test_tailwind_parse_sizing() {
        let output = parse_classes("w-full h-screen max-w-lg");

        let props = output.to_props();
        assert_eq!(props.get("width"), Some(&"100%".to_string()));
        assert_eq!(props.get("height"), Some(&"100vh".to_string()));
        assert_eq!(props.get("max-width"), Some(&"32rem".to_string()));
    }
}
