from __future__ import annotations

from datetime import date
from decimal import Decimal
from typing import Dict, List, Optional
from uuid import UUID

from pydantic import BaseModel, Field


class GenerateRequest(BaseModel):
    family_profile_id: UUID
    week_start_date: date


class RegenerateRequest(BaseModel):
    family_profile_id: UUID
    week_start_date: date
    exclude_recipe_ids: List[UUID] = Field(default_factory=list)
    relax_time_max_minutes: Optional[int] = Field(default=None, ge=0)
    relax_calorie_pct: Optional[int] = Field(default=None, ge=0, le=100)
    relax_max_meal_cost: Optional[float] = Field(default=None, ge=0)


class GenerationItem(BaseModel):
    recipe_id: UUID
    day_of_week: int
    estimated_cost: Decimal
    score: float
    components: Dict[str, float]


class GenerationDebug(BaseModel):
    feasible_count: int
    rejected_summary: Dict[str, int]
    set_score: float


class GenerationResponse(BaseModel):
    meal_plan_id: UUID
    week_start_date: date
    items: List[GenerationItem]
    debug: GenerationDebug
