"""TieMeasureFlow Client Configuration."""
import os
from dotenv import load_dotenv

load_dotenv(os.path.join(os.path.dirname(__file__), '..', '.env'))


class Config:
    """Flask client configuration."""

    # Flask
    SECRET_KEY = os.getenv("CLIENT_SECRET_KEY", "change-this-to-another-random-secret-key")
    DEBUG = os.getenv("FLASK_DEBUG", "0") == "1"

    # API Server connection
    API_SERVER_URL = os.getenv("API_SERVER_URL", "http://localhost:8000")

    # Session
    SESSION_COOKIE_HTTPONLY = True
    SESSION_COOKIE_SAMESITE = "Lax"
    SESSION_COOKIE_SECURE = not DEBUG  # Only secure cookies in production (HTTPS)
    PERMANENT_SESSION_LIFETIME = 28800  # 8 hours
    WTF_CSRF_TIME_LIMIT = 3600  # 1 hour

    # Station identity: each deployed client container sets this to the station
    # code it belongs to. Empty/None means "not configured".
    STATION_CODE: str | None = os.getenv("STATION_CODE") or None

    # Babel i18n
    BABEL_DEFAULT_LOCALE = "it"
    BABEL_DEFAULT_TIMEZONE = "Europe/Rome"
    LANGUAGES = {"it": "Italiano", "en": "English"}
