from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
    app_name: str = "Kids AI Posture Platform API"
    app_env: str = "development"
    app_debug: bool = True
    database_url: str = "mysql+pymysql://happy_up:happy_up@127.0.0.1:3306/happy_up?charset=utf8mb4"
    redis_url: str = "redis://127.0.0.1:6379/0"
    jwt_secret: str = "change-me-in-production-use-32-char-min"
    jwt_expire_minutes: int = 60 * 24 * 7
    demo_sms_code: str = "682139"
    analysis_inline_process: bool = True
    analysis_queue_key: str = "happy_up:analysis_tasks"
    webhook_secret: str = "dev-webhook-secret-change-me"
    cors_origins: str = "http://localhost:5173,http://127.0.0.1:5500,null"
    api_public_url: str = "http://127.0.0.1:8000"
    upload_local_dir: str = "data/uploads"
    upload_token_expire_minutes: int = 15
    oss_enabled: bool = False
    oss_provider: str = "minio"  # minio | aliyun
    oss_endpoint: str = "http://127.0.0.1:9000"
    oss_access_key: str = "minioadmin"
    oss_secret_key: str = "minioadmin"
    oss_bucket: str = "happy-up-videos"
    oss_region: str = "us-east-1"
    oss_cdn_base_url: str = ""

    model_config = SettingsConfigDict(env_file=".env", extra="ignore")

    @property
    def cors_origin_list(self) -> list[str]:
        return [o.strip() for o in self.cors_origins.split(",") if o.strip()]


settings = Settings()
