from pydantic import BaseModel, Field
from typing import Optional, List
from datetime import datetime
from uuid import UUID
from enum import Enum

class DocType(str, Enum):
    NOTICE = "NOTICE"
    COURT_ORDER = "COURT_ORDER"
    GENERAL_INQUIRY = "GENERAL_INQUIRY"

class ThreadType(str, Enum):
    TEXT_CHAT = "TEXT_CHAT"
    CALLBACK_REQUEST = "CALLBACK_REQUEST"
    APPOINTMENT = "APPOINTMENT"

class MetadataInput(BaseModel):
    authorityId: str = Field(..., example="Finanzamt-Muenchen-I")
    referenceNumber: str = Field(..., example="123/456/789")
    docType: DocType
    issuedAt: datetime

class DocumentCreate(BaseModel):
    metadata: MetadataInput
    encryptedPayload: str 

class ThreadCreate(BaseModel):
    type: ThreadType
    initialMessage: str
    preferredTimeSlot: Optional[datetime] = None

class DocumentResponse(BaseModel):
    id: UUID
    status: str
    assignedUnit: Optional[str] = None

class MessageResponse(BaseModel):
    id: UUID
    senderRole: str
    content: str
    timestamp: datetime

class MessageListResponse(BaseModel):
    data: List[MessageResponse]
    nextCursor: Optional[datetime] = None