import logging
import os
import sys

import dotenv
from minio import Minio

from app.models import AvailableSource, AvailableSourcesResponse

dotenv.load_dotenv()

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    datefmt="%Y-%m-%d %H:%M:%S",
    stream=sys.stdout
)

logger = logging.getLogger("base_logger")

available_sources = AvailableSourcesResponse(
    sources=[
        AvailableSource(
            display_name="LinkedIn Shares",
            name="linkedin_shares",
            format="csv",
        ),
        AvailableSource(
            display_name="LinkedIn Comments",
            name="linkedin_comments",
            format="csv",
        ),
        AvailableSource(
            display_name="Facebook Posts", name="facebook_posts", format="json"
        ),
        AvailableSource(
            display_name="Facebook Comments",
            name="facebook_comments",
            format="json",
        ),
        AvailableSource(
            display_name="Instagram Posts",
            name="instagram_posts",
            format="json",
        ),
        AvailableSource(
            display_name="Instagram Comments",
            name="instagram_comments",
            format="json",
        ),
        AvailableSource(
            display_name="Instagram Stories",
            name="instagram_stories",
            format="json",
        ),
        AvailableSource(
            display_name="Instagram Reels",
            name="instagram_reels",
            format="json",
        ),
        AvailableSource(
            display_name="Instagram Stories",
            name="instagram_stories",
            format="image",
        ),
        AvailableSource(
            display_name="Instagram Reels",
            name="instagram_reels",
            format="video",
        ),
        AvailableSource(display_name="Bluesky", name="bluesky", format="car"),
        AvailableSource(
            display_name="Youtube Video", name="youtube_video", format="video"
        ),
        AvailableSource(
            display_name="Youtube Shorts",
            name="youtube_shorts",
            format="video",
        ),
        AvailableSource(
            display_name="Markdown", name="markdown", format="markdown"
        ),
        AvailableSource(
            display_name="Wordpress", name="wordpress", format="xml"
        ),
        AvailableSource(display_name="Ebook", name="ebook_pdf", format="pdf"),
        AvailableSource(
            display_name="Ebook", name="ebook_epub", format="epub"
        ),
        AvailableSource(
            display_name="Website", name="ebook_html", format="html"
        ),
    ],
)

minio_alias_url = os.environ.get("MINIO_ALIAS_URL", "minio:9000")
minio_bucket_name = os.environ.get(
    "BACKEND_MINIO_BUCKET_NAME", "backend-retro-contenu"
)
minio_access_key = os.environ.get("MINIO_ROOT_USER", "minioadmin")
minio_secret_key = os.environ.get("MINIO_ROOT_PASSWORD", "minioadmin")
minio_secure = os.environ.get("MINIO_SECURE") == "True"

minio_client = Minio(
    endpoint=minio_alias_url,
    access_key=minio_access_key,
    secret_key=minio_secret_key,
    secure=minio_secure
)

ollama_url = os.environ.get("OLLAMA_URL", "http://host.docker.internal:11434")

embedding_model_name = os.environ.get("OLLAMA_EMBEDDING_MODEL_NAME",
                                      "snowflake-arctic-embed2")
