"""Harbor Viewer - Web UI for browsing jobs and trajectories."""

import os
from pathlib import Path

from harbor.viewer.server import create_app


def create_app_from_env():
    """Factory function for uvicorn reload mode.

    Reads HARBOR_VIEWER_JOBS_DIR from environment and creates the app.
    This is needed because uvicorn reload requires an import string, not an app instance.
    """
    jobs_dir = os.environ.get("HARBOR_VIEWER_JOBS_DIR")
    if not jobs_dir:
        raise RuntimeError("HARBOR_VIEWER_JOBS_DIR environment variable not set")
    return create_app(Path(jobs_dir))


__all__ = ["create_app", "create_app_from_env"]
