import os
from pathlib import Path

APP_NAME = "HexaWetter"
APP_VERSION = "1.1.0"

DATA_DIR = Path(os.getenv("DATA_DIR", "/data"))
RAW_RADAR_DIR = DATA_DIR / "raw" / "radar"
RENDERED_RADAR_DIR = DATA_DIR / "processed" / "radar"

OPEN_METEO_BASE_URL = os.getenv("OPEN_METEO_BASE_URL", "https://api.open-meteo.com/v1").rstrip("/")
BRIGHTSKY_BASE_URL = os.getenv("BRIGHTSKY_BASE_URL", "https://api.brightsky.dev").rstrip("/")
DWD_RADAR_BASE_URL = os.getenv("DWD_RADAR_BASE_URL", "https://opendata.dwd.de/weather/radar/composite").rstrip("/")
DWD_WMS_URL = os.getenv("DWD_WMS_URL", "https://maps.dwd.de/geoserver/dwd/wms").rstrip("/")
DWD_WARNINGS_URL = os.getenv(
    "DWD_WARNINGS_URL",
    "https://www.dwd.de/DWD/warnungen/warnapp_landkreise/json/warnings.json",
).rstrip("/")
NOMINATIM_BASE_URL = os.getenv("NOMINATIM_BASE_URL", "https://nominatim.openstreetmap.org").rstrip("/")
NOMINATIM_USER_AGENT = os.getenv("NOMINATIM_USER_AGENT", "HexaWetter/1.0 (selfhosted weather)")

DEFAULT_LAT = float(os.getenv("DEFAULT_LAT", "48.6546"))
DEFAULT_LON = float(os.getenv("DEFAULT_LON", "13.6252"))
DEFAULT_PLACE = os.getenv("DEFAULT_PLACE", "Hauzenberg")

RADAR_PRODUCT = os.getenv("RADAR_PRODUCT", "rv")
RADAR_RETENTION_HOURS = int(os.getenv("RADAR_RETENTION_HOURS", "48"))

DATABASE_URL = os.getenv(
    "DATABASE_URL",
    "postgresql://hexawetter:hexawetter@postgres:5432/hexawetter",
)
REDIS_URL = os.getenv("REDIS_URL", "redis://redis:6379/0")

CACHE_TTL_FORECAST = int(os.getenv("CACHE_TTL_FORECAST", "600"))
CACHE_TTL_OBSERVATIONS = int(os.getenv("CACHE_TTL_OBSERVATIONS", "300"))
CACHE_TTL_WARNINGS = int(os.getenv("CACHE_TTL_WARNINGS", "120"))
CACHE_TTL_GEOCODE = int(os.getenv("CACHE_TTL_GEOCODE", "86400"))
CACHE_TTL_WMS_TIMES = int(os.getenv("CACHE_TTL_WMS_TIMES", "120"))
CACHE_TTL_HEALTH_SOURCES = int(os.getenv("CACHE_TTL_HEALTH_SOURCES", "90"))
CACHE_TTL_DASHBOARD = int(os.getenv("CACHE_TTL_DASHBOARD", "60"))

RATE_LIMIT_PER_MINUTE = int(os.getenv("RATE_LIMIT_PER_MINUTE", "120"))

ADMIN_USERNAME = os.getenv("ADMIN_USERNAME", "admin")
ADMIN_PASSWORD_HASH = os.getenv("ADMIN_PASSWORD_HASH", "")
ADMIN_JWT_SECRET = os.getenv("ADMIN_JWT_SECRET", "")
ADMIN_JWT_EXPIRE_HOURS = int(os.getenv("ADMIN_JWT_EXPIRE_HOURS", "8"))
