from __future__ import annotations

from dataclasses import dataclass, field
from typing import Any, Dict


@dataclass
class ClientConfig:
    api_key: str
    base_url: str = "https://grsai.dakka.com.cn"
    timeout: float = 60.0
    connect_timeout: float = 5.0
    retries: int = 3
    backoff_base: float = 1.0
    backoff_cap: float = 8.0


@dataclass
class DrawConfig:
    model: str = "nano-banana-fast"
    aspect_ratio: str = "16:9"
    image_size: str = "1K"
    web_hook: str = "-1"
    extra: Dict[str, Any] = field(default_factory=dict)

    def to_payload(self, prompt: str) -> Dict[str, Any]:
        payload: Dict[str, Any] = {
            "model": self.model,
            "prompt": prompt,
            "aspectRatio": self.aspect_ratio,
            "webHook": self.web_hook,
            "imageSize": self.image_size,
        }
        for key, value in (self.extra or {}).items():
            payload[key] = value
        return payload


@dataclass
class PollConfig:
    interval: float = 5.0
    max_wait: float = 300.0
    heartbeat: float = 15.0
