//! Unified navigation menu 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 leptos::prelude::*;
// Fix Leptos macro conflicts with our 'core' crate
use std::{default::Default, marker::PhantomData};

#[cfg(not(target_arch = "wasm32"))]
use crate::navigation::navmenu::ssr::NavMenuSSR;

#[cfg(target_arch = "wasm32")]
use crate::navigation::navmenu::client::NavMenuClient;

/// Unified navigation menu component that delegates to appropriate implementation
#[component]
pub fn NavMenu(
    #[prop(optional)] language: Option<String>,
    #[prop(optional)]
    #[allow(unused_variables)]
    set_path: Option<WriteSignal<String>>,
    #[prop(optional)]
    #[allow(unused_variables)]
    path: Option<ReadSignal<String>>,
) -> impl IntoView {
    #[cfg(not(target_arch = "wasm32"))]
    {
        // SSR context: use static implementation
        view! { <NavMenuSSR language=language.unwrap_or_default() /> }
    }

    #[cfg(target_arch = "wasm32")]
    {
        // Client context: use reactive implementation
        let set_path = set_path.unwrap_or_else(|| {
            // Provide default signal if not provided (client-side only)
            #[cfg(target_arch = "wasm32")]
            {
                let (_, set_path) = signal(String::new());
                set_path
            }
            #[cfg(not(target_arch = "wasm32"))]
            {
                |_: String| {} // No-op for SSR
            }
        });
        let path = path.unwrap_or_else(|| {
            // Provide default signal if not provided (client-side only)
            #[cfg(target_arch = "wasm32")]
            {
                let (path, _) = signal(String::new());
                path
            }
            #[cfg(not(target_arch = "wasm32"))]
            {
                || String::new() // Static value for SSR
            }
        });

        view! { <NavMenuClient _set_path=set_path _path=path /> }
    }
}
