"""Settings — 환경변수 로드."""
from __future__ import annotations

import os
from dataclasses import dataclass

_DEFAULT_TOKEN_URL = (
    "https://new.land.naver.com/houses?ms=37.489,126.921,16&a=APT:ABYG:JGC:PRE&e=RETAIL"
)


@dataclass
class Settings:
    nas_base_url: str
    internal_api_key: str
    redis_url: str
    fetch_interval_hours: float
    daytime_start: str
    daytime_end: str
    naver_real_estate_type: str
    naver_token_url: str
    naver_headless: bool


def load_settings() -> Settings:
    return Settings(
        nas_base_url=os.getenv("NAS_BASE_URL", "http://192.168.45.54:18500"),
        internal_api_key=os.getenv("INTERNAL_API_KEY", ""),
        redis_url=os.getenv("REDIS_URL", "redis://192.168.45.54:6379"),
        fetch_interval_hours=float(os.getenv("FETCH_INTERVAL_HOURS", "2.5")),
        daytime_start=os.getenv("DAYTIME_START", "08:00"),
        daytime_end=os.getenv("DAYTIME_END", "20:00"),
        naver_real_estate_type=os.getenv("NAVER_REAL_ESTATE_TYPE", "APT:ABYG:JGC:PRE"),
        naver_token_url=os.getenv("NAVER_TOKEN_URL", _DEFAULT_TOKEN_URL),
        naver_headless=os.getenv("NAVER_HEADLESS", "1") == "1",
    )
