from decouple import config # Import the config function from python-decouple

class Config:
    """
    Base configuration class. Common settings for all environments.
    """
    DEBUG = config('DEBUG', default=False, cast=bool)  # Debug mode, default to False
    SECRET_KEY = config('SECRET_KEY', default='your-secret-key', cast=str)  # Secret key for Flask application, default to 'your-secret-key'
    JSONIFY_PRETTYPRINT_REGULAR = True
    #  
    LOG_FILE = config('LOG_FILE', default='app.log', cast=str) 
    # 
    SQLALCHEMY_DATABASE_URI = config('DATABASE_URI', default='sqlite:////tmp/video-service.db', cast=str)  # Database URI, default to SQLite in-memory database
    # 
    UPLOAD_DIR = "data"  # Specify the upload directory
    # 
    CHUNK_SIZE = 2 * 1024 * 1024  # Specify the chunk size for file uploads 
    # Define supported audio extensions
    SUPPORTED_AUDIO_EXTENSIONS = ['mp3', 'wav', 'ogg', 'flac', 'aac', 'm4a']
    # Define supported video extensions
    SUPPORTED_VIDEO_EXTENSIONS = ['mp4', 'avi', 'mkv', 'mov', 'wmv', 'flv']
    # 
    CELERY_BROKER_URL = config('CELERY_BROKER_URL', default='amqp://guest:guest@rabbitmq-service:5672//', cast=str)
    CELERY_RESULT_BACKEND  = config('CELERY_RESULT_BACKEND', default='redis://redis:6379/0', cast=str)


class DevelopmentConfig(Config):
    """
    Development configuration class.
    """
    DEBUG = True  # Enable debug mode
    TESTING = config('TESTING', default=False, cast=bool)  # Testing mode, default to False 


class ProductionConfig(Config):
    """
    Production configuration class.
    """
    DEBUG = True  # Disable debug mode
    TESTING = False  # Disable testing mode 


class TestingConfig(Config):
    TESTING = True
    DEBUG = True 


configurations = {
    'development': DevelopmentConfig,
    'production': ProductionConfig, 
    'testing': TestingConfig,
    'default': DevelopmentConfig,
}

def get_config():
    """
    Function to get the configuration based on the environment.
    """
    env = config('FLASK_ENV', default='development').lower()  # Get the environment from .env, default to 'development'
    return configurations[env]()  # Return the configuration instance based on the environment
