"""
Menu island prop schemas.

Auto-generated from packages/lightwave-ui/src/islands/menu-registry.tsx
Manually refined: 2026-01-28

The menu registry is different from other islands - it uses MenuConfig
interface instead of BaseMenuProps pattern. This is because menus are
created via createMenuFromConfig() which extracts variant and passes
remaining props to the variant-specific component.

Islands are React components hydrated on the client. These schemas define
the props that Django passes to the React island via JSON serialization.
"""

from typing import Any, Literal

from pydantic import ConfigDict, Field

from lightwave.schema.pydantic.core.base import LightwaveBaseSchema

# =============================================================================
# Menu Variants
# =============================================================================

MENU_VARIANTS = [
    "simple",
    "simple-with-footer",
    "feature-card",
    "two-columns",
    "two-columns-with-footer",
    "featured-posts",
    "two-cols-links-footer",
]

MENU_VARIANT_TYPE = Literal[
    "simple",
    "simple-with-footer",
    "feature-card",
    "two-columns",
    "two-columns-with-footer",
    "featured-posts",
    "two-cols-links-footer",
]


# =============================================================================
# MenuConfig - Main Interface
# =============================================================================


class MenuConfig(LightwaveBaseSchema):
    """
    Menu configuration from YAML/CMS.

    Source: packages/lightwave-ui/src/islands/menu-registry.tsx

    Matches TypeScript:
        interface MenuConfig {
            variant: MenuVariant | string;
            items?: unknown[];
            featuredPosts?: unknown[];
            featureCard?: unknown;
            columns?: unknown[];
            quickLinks?: unknown[];
            [key: string]: unknown;
        }

    Note: This uses a flexible schema because different menu variants
    accept different props. The variant determines which props are used.
    """

    # Menu variant name (required)
    variant: str = Field(
        ...,
        description="Menu variant name (e.g., 'simple', 'featured-posts')",
    )

    # Menu items (varies by variant)
    items: list[dict[str, Any]] | None = Field(
        None,
        description="Menu items (structure varies by variant)",
    )

    # Featured posts (for featured-posts variant)
    featured_posts: list[dict[str, Any]] | None = Field(
        None,
        serialization_alias="featuredPosts",
        description="Featured posts for featured-posts variant",
    )

    # Feature card (for feature-card variant)
    feature_card: dict[str, Any] | None = Field(
        None,
        serialization_alias="featureCard",
        description="Feature card for feature-card variant",
    )

    # Columns (for column-based variants)
    columns: list[dict[str, Any]] | None = Field(
        None,
        description="Columns for two-column variants",
    )

    # Quick links (for two-cols-links-footer variant)
    quick_links: list[dict[str, Any]] | None = Field(
        None,
        serialization_alias="quickLinks",
        description="Quick links for two-cols-links-footer variant",
    )

    model_config = ConfigDict(
        populate_by_name=True,
        extra="allow",  # Allow additional props for flexibility
    )


# =============================================================================
# Backwards Compatibility Aliases
# =============================================================================

# Alias for backwards compatibility - MenuConfig is the primary interface
BaseMenuProps = MenuConfig


__all__ = [
    "MenuConfig",
    "BaseMenuProps",
    "MENU_VARIANTS",
    "MENU_VARIANT_TYPE",
]
