//! Client-side logo components
//!
//! Reactive implementations of logo components for client-side rendering.

use ::rustelo_core_lib::defs::LogoConfig;
use leptos::prelude::*;

/// Client-side reactive logo component
#[component]
pub fn LogoClient(
    #[prop(optional)] config: Option<LogoConfig>,
    #[prop(default = "h-8 w-auto".to_string())] class: String,
    #[prop(default = false)] as_link: bool,
) -> impl IntoView {
    let logo_config = config.unwrap_or_else(|| use_context::<LogoConfig>().unwrap_or_default());
    // Get reactive theme/language if needed
    let _current_lang = move || {
        #[cfg(target_arch = "wasm32")]
        {
            // Get current path from browser location
            if let Some(window) = web_sys::window() {
                if let Ok(pathname) = window.location().pathname() {
                    return rustelo_core_lib::routing::utils::detect_language_from_path(&pathname);
                }
            }
        }
        "en".to_string()
    };

    // Delegate to unified implementation
    view! {
        <crate::logo::unified::Logo
            config=logo_config
            class=class
            as_link=as_link
        />
    }
}

/// Client-side reactive logo link component
#[component]
pub fn LogoLinkClient(
    #[prop(optional)] config: Option<LogoConfig>,
    #[prop(default = "h-8 w-auto".to_string())] class: String,
) -> impl IntoView {
    let logo_config = config.unwrap_or_else(|| use_context::<LogoConfig>().unwrap_or_default());
    view! {
        <crate::logo::unified::LogoLink config=logo_config class=class />
    }
}

// Re-export as Logo and LogoLink for compatibility
pub use LogoClient as Logo;
pub use LogoLinkClient as LogoLink;
