//! Client-side footer component
//!
//! Reactive implementation of the footer with SPA navigation capabilities.

use leptos::prelude::*;
// Fix Leptos macro conflicts with our 'core' crate
use std::{default::Default, marker::PhantomData};
use ::rustelo_core_lib::{rustelo_components_leptos::UnifiedFooter, config::LogoConfig};

// Import components that this depends on
use crate::logo::Logo;

/// Client-side reactive footer component
#[component]
pub fn FooterClient(
    /// Custom CSS class
    #[prop(optional)]
    class: Option<String>,
    /// Show social links
    #[prop(default = true)]
    show_social: bool,
    /// Show scroll to top button
    #[prop(default = true)]
    show_scroll_to_top: bool,
) -> impl IntoView {
    let i18n = use_i18n();

    // Create reactive memo for current language using i18n context
    let current_lang_reactive = i18n.lang_code_reactive();
    let current_lang = move || current_lang_reactive.get();

    // Get logo configuration from environment variables
    let logo_config = LogoConfig::default();

    move || {
        let lang = current_lang();

        view! {
            <UnifiedFooter
                language=lang.clone()
                class=class.clone().unwrap_or_default()
                show_social=show_social
                show_scroll_to_top=show_scroll_to_top
                logo_view={view! {
                    <Logo
                        size="small".to_string()
                        class="".to_string()
                        logo_src_light={logo_config.light_path.clone()}
                        logo_src_dark={logo_config.dark_path.clone()}
                    />
                }.into_any()}
            />
        }
    }
}

// TODO: Import use_i18n from the actual client crate location
// For now we'll use a placeholder that compiles
fn use_i18n() -> DummyI18n {
    DummyI18n
}

struct DummyI18n;
impl DummyI18n {
    fn lang_code_reactive(&self) -> leptos::prelude::ReadSignal<String> {
        let (lang, _) = signal("en".to_string());
        lang
    }
}
