from __future__ import annotations

import os
from pathlib import Path


class Config:
    host: str = os.getenv("NP4_HOST", "0.0.0.0")
    port: int = int(os.getenv("NP4_PORT", "8080"))
    api_token: str = os.getenv("NP4_API_TOKEN", "").strip()

    data_dir: Path = Path(os.getenv("NP4_DATA_DIR", "./v4_data")).resolve()
    ui_dir: Path = Path(
        os.getenv(
            "NP4_UI_DIR",
            str((Path(__file__).resolve().parents[3] / "ui").resolve()),
        )
    )
    pwa_dir: Path = Path(
        os.getenv(
            "NP4_PWA_DIR",
            str((Path(__file__).resolve().parents[3] / "pwa").resolve()),
        )
    )

    @classmethod
    def ensure_dirs(cls) -> None:
        cls.data_dir.mkdir(parents=True, exist_ok=True)

