"""Bridge to import scripts/lib/ modules from the mounted volume."""
import sys
from pathlib import Path

SCRIPTS_DIR = Path("/app/scripts")
if not SCRIPTS_DIR.exists():
    SCRIPTS_DIR = Path(__file__).parent.parent.parent / "scripts"
sys.path.insert(0, str(SCRIPTS_DIR))

from lib.portainer import (
    list_containers as portainer_list_containers,
    get_container_logs as portainer_get_container_logs,
    restart_container as portainer_restart_container,
    inspect_container as portainer_inspect_container,
    ENDPOINTS,
)
from lib.prometheus import prom_query, prom_query_range
from lib.ollama import ollama_available, DEFAULT_URL as OLLAMA_URL, DEFAULT_MODEL as OLLAMA_MODEL

# DB paths
GMAIL_DB = SCRIPTS_DIR / "gmail-organizer" / "processed.db"
DVISH_DB = SCRIPTS_DIR / "gmail-organizer-dvish" / "processed.db"
PROTON_DB = SCRIPTS_DIR / "proton-organizer" / "processed.db"
RESTART_DB = SCRIPTS_DIR / "stack-restart.db"

# Data paths
DATA_DIR = Path("/app/data")
if not DATA_DIR.exists():
    DATA_DIR = Path(__file__).parent.parent.parent / "data"
EXPENSES_CSV = DATA_DIR / "expenses.csv"

# Log paths
LOG_DIR = Path("/app/logs")
if not LOG_DIR.exists():
    LOG_DIR = Path("/tmp")
