from typing import Optional, Literal
from pydantic import BaseModel, Field

from uuid import uuid4

# Output to frontend
class Landmark(BaseModel) :
    
    # Properties of the landmark
    name : str
    type: Literal['sightseeing', 'nature', 'shopping', 'start', 'finish']
    location : tuple
    osm_type : str
    osm_id : int
    attractiveness : int
    n_tags : int
    image_url : Optional[str] = None                            # TODO future
    description : Optional[str] = None                          # TODO future
    duration : Optional[int] = 0                                # TODO future

    # Unique ID of a given landmark
    uuid: str = Field(default_factory=uuid4)                    # TODO implement this ASAP
    
    # Additional properties depending on specific tour
    must_do : Optional[bool] = False
    must_avoid : Optional[bool] = False
    is_secondary : Optional[bool] = False                       # TODO future   
    
    time_to_reach_next : Optional[int] = 0                      # TODO fix this in existing code
    next_uuid : Optional[str] = None                            # TODO implement this ASAP

    def __hash__(self) -> int:
        return self.uuid.int
    
    def __str__(self) -> str:
        time_to_next_str = f", time_to_next={self.time_to_reach_next}" if self.time_to_reach_next else ""
        return f'Landmark({self.type}): [{self.name} @{self.location}, score={self.attractiveness}{time_to_next_str}]'