"""
App View island prop schemas.

Mirrors lightwave-ui/src/islands/app-page-registry.tsx.

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

from pydantic import BaseModel, ConfigDict, Field

from lightwave.schema.pydantic.ui.types import NavItem


class BaseAppViewProps(BaseModel):
    """
    Base props that all app view layouts should support.

    Matches TypeScript:
        interface BaseAppViewProps {
            title?: string;
            description?: string;
            breadcrumbs?: NavItem[];
            actions?: any[];
        }
    """

    title: str | None = Field(None, description="Page title")
    description: str | None = Field(None, description="Page description")
    breadcrumbs: list[NavItem] | None = Field(None, description="Breadcrumb navigation")
    actions: list[dict[str, Any]] | None = Field(None, description="Page action buttons")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


class AppViewDefault01Props(BaseAppViewProps):
    """Default app view layout."""

    show_sidebar: bool | None = Field(True, serialization_alias="showSidebar", description="Show sidebar navigation")


class AppViewFullWidth01Props(BaseAppViewProps):
    """Full width app view layout."""

    max_width: str | None = Field(None, serialization_alias="maxWidth", description="Maximum content width")


class AppViewDashboard01Props(BaseAppViewProps):
    """Dashboard-style app view."""

    widgets: list[dict[str, Any]] | None = Field(None, description="Dashboard widgets configuration")


class AppViewIslandProps(BaseModel):
    """
    App view island configuration as received from Django.

    This wraps the variant selection with the variant-specific props.
    """

    variant: str = Field("default-01", description="App view variant identifier")
    props: BaseAppViewProps | None = Field(None, description="App view props (variant-specific)")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


__all__ = [
    "BaseAppViewProps",
    "AppViewDefault01Props",
    "AppViewFullWidth01Props",
    "AppViewDashboard01Props",
    "AppViewIslandProps",
]
