"""AUTO-GENERATED by scripts/codegen.py — DO NOT EDIT."""
from __future__ import annotations

from typing import Any, Callable

from zuzu.runtime.spec import _add_component
from zuzu.record import Record, RecordQuery
from zuzu.components._utils import _check_visible



def action_row(
    label: str,
    *,
    subtitle: str = '',
    icon: str = '',
    action: Callable[..., Any] | None = None,
    visible: Any = True,
) -> None:
    """Tappable row that triggers an action."""
    if not _check_visible(visible):
        return
    comp: dict[str, Any] = {"type": "action_row", "label": label, "subtitle": subtitle, "icon": icon}
    if action:
        comp["action"] = action.__name__ if callable(action) else str(action)
    _add_component(comp)


def alert(
    message: str,
    *,
    type: str = 'info',
    visible: Any = True,
) -> None:
    """Alert message. type: info|success|warning|error."""
    if not _check_visible(visible):
        return
    comp: dict[str, Any] = {"type": "alert", "message": message, "alert_type": type}
    _add_component(comp)


def button(
    label: str,
    *,
    variant: str = 'filled',
    size: str = 'md',
    icon: str | None = None,
    full_width: bool = False,
    action: Callable[..., Any] | None = None,
    confirm: bool = False,
    visible: Any = True,
) -> None:
    """Button. variant: filled|outlined|ghost. size: sm|md|lg."""
    if not _check_visible(visible):
        return
    comp: dict[str, Any] = {"type": "button", "label": label, "variant": variant, "size": size, "full_width": full_width, "confirm": confirm}
    if icon:
        comp["icon"] = icon
    if action:
        comp["action"] = action.__name__ if callable(action) else str(action)
    _add_component(comp)


def fab(
    icon: str = '+',
    *,
    label: str = '',
    action: Callable[..., Any] | None = None,
    visible: Any = True,
) -> None:
    """Floating action button fixed at bottom-right."""
    if not _check_visible(visible):
        return
    comp: dict[str, Any] = {"type": "fab", "icon": icon, "label": label}
    if action:
        comp["action"] = action.__name__ if callable(action) else str(action)
    _add_component(comp)


def go_to(page: str, *, visible: Any = True) -> None:
    """Navigate to another page."""
    if not _check_visible(visible):
        return
    comp: dict[str, Any] = {"type": "navigate", "page": page}
    _add_component(comp)


def link(
    text: str,
    url: str,
    *,
    visible: Any = True,
) -> None:
    """Inline clickable link."""
    if not _check_visible(visible):
        return
    comp: dict[str, Any] = {"type": "link", "text": text, "url": url}
    _add_component(comp)
