"""
Consolidated schemas for Pedimento catalog responses
"""

from typing import List, Optional
from pydantic import BaseModel

# Import DTOs for catalog items
from api.v1.modules.public.reference_data.pedimento_codes.dto import PedimentoCodeDTO
from api.v1.modules.public.reference_data.customs_sections.dto import CustomsSectionDTO
from api.v1.modules.public.reference_data.code_pedimento_regimens.dto import CodePedimentoRegimenDTO
from api.v1.modules.a76.customs_brokers.dto import CustomsBrokerResponseDTO
from api.v1.modules.a76.clients_and_providers.dto import ClientProviderResponseDTO
from api.v1.modules.public.reference_data.transport_types.dto import TransportTypeDTO
from api.v1.modules.public.reference_data.transport_modes.dto import TransportModeDTO
from api.v1.modules.public.reference_data.pedimento_transport_catalog.dto import (
    PedimentoTransportCatalogDTO,
)
from .dtos.pedimentos import PedimentosResponse


class PedimentoCatalogsResponse(BaseModel):
    """Base response containing all catalogs needed for pedimento views"""
    
    pedimento_codes: List[PedimentoCodeDTO] = []
    customs_sections: List[CustomsSectionDTO] = []
    code_pedimento_regimens: List[CodePedimentoRegimenDTO] = []
    customs_brokers: List[CustomsBrokerResponseDTO] = []
    clients: List[ClientProviderResponseDTO] = []
    transport_types: List[TransportTypeDTO] = []
    transport_modes: List[TransportModeDTO] = []
    pedimento_transport_catalog: List[PedimentoTransportCatalogDTO] = []


class PedimentoCreationResponse(PedimentoCatalogsResponse):
    """Response for creating a new pedimento (catalogs only)"""
    
    is_create: bool = True


class PedimentoEditionResponse(PedimentoCatalogsResponse):
    """Response for editing an existing pedimento (catalogs + pedimento data)"""
    
    is_create: bool = False
    pedimento: Optional[PedimentosResponse] = None
    pedimento_id: Optional[int] = None
