//! Unified menu item component interface using shared delegation patterns
//!
//! This module provides a unified interface that automatically selects between
//! client-side reactive and server-side static implementations based on
//! context.

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

#[cfg(target_arch = "wasm32")]
use crate::ui::menu_item::client::menu_item_view;
#[cfg(not(target_arch = "wasm32"))]
use crate::ui::menu_item::ssr::menu_item_view_ssr;

/// Unified menu item renderer that delegates to appropriate implementation
pub fn render_menu_item(item: MenuItem, language: Option<&str>) -> impl IntoView {
    #[cfg(not(target_arch = "wasm32"))]
    {
        // SSR context: use static implementation with language parameter
        let lang = language.unwrap_or("en");
        menu_item_view_ssr(item, lang)
    }

    #[cfg(target_arch = "wasm32")]
    {
        // Client context: use reactive implementation
        let _ = language; // Ignore language parameter in client context
        menu_item_view(item)
    }
}
