//! Server-side footer wrapper
//!
//! This is a thin wrapper that prepares SSR-specific data (static language)
//! and delegates to the unified implementation.

use ::rustelo_core_lib::{
    config::get_default_language,
    i18n::{build_page_content_patterns, SsrTranslator},
};
use leptos::prelude::*;

use crate::navigation::footer::unified::UnifiedFooter;

/// Server-side footer wrapper
#[component]
pub fn FooterSSR(
    #[prop(default = get_default_language().to_string())] language: String,
    /// 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 ssr_i18n = SsrTranslator::new(language.clone());
    let patterns = ["footer-", "lang-"];
    let lang_content = build_page_content_patterns(&ssr_i18n, &patterns);
    let class_str = class.unwrap_or_default();

    // Wrap in a DynChild closure to match FooterClient's `move || { view! {
    // <UnifiedFooter /> } }` structure — both SSR and WASM must emit identical
    // reactive-node (DynChild marker) counts.
    move || {
        view! {
            <UnifiedFooter
                language=language.clone()
                lang_content=lang_content.clone()
                class=class_str.clone()
                show_social=show_social
                show_scroll_to_top=show_scroll_to_top
            />
        }
    }
}

// Re-export as Footer for compatibility
// pub use FooterSSR as Footer;
