from __future__ import annotations

from typing import Any, Dict, List, Optional
from pydantic import BaseModel


class RiffDataSource(BaseModel):
    endpoint_name: str
    method: str = "GET"
    description: str
    params: List[str] = []


class RiffLayout(BaseModel):
    x: float
    y: float
    width: float
    height: float
    z: int = 0
    tabOrder: Optional[int] = None


class RiffStyle(BaseModel):
    background_color: Optional[str] = None
    title_color: Optional[str] = None
    value_color: Optional[str] = None
    transparency: Optional[float] = None


class RiffComponentProps(BaseModel):
    title: str
    type: str
    xAxis: Optional[str] = None
    yAxis: Optional[List[str]] = None
    colors: Optional[List[str]] = None
    dataKey: Optional[str] = None
    valueKey: Optional[str] = None


class RiffComponent(BaseModel):
    id: str
    type: str
    visual_type_source: str
    props: RiffComponentProps
    dataSource: RiffDataSource
    layout: Optional[RiffLayout] = None
    style: Optional[RiffStyle] = None
    description: str


class RiffPage(BaseModel):
    id: str
    name: str
    width: Optional[float] = None
    height: Optional[float] = None
    style: Optional[RiffStyle] = None
    components: List[RiffComponent] = []
    layout: str = "grid"


class RiffAppPlan(BaseModel):
    app_name: str
    pages: List[RiffPage]
    global_filters: List[Dict[str, Any]] = []
