"""
Configuration management for AI News Digest
"""

function load_config(config_path::String)
    """Load configuration from JSON file"""
    if !isfile(config_path)
        error("Config file not found: $config_path")
    end
    
    config_text = read(config_path, String)
    return JSON.parse(config_text)
end

function get_feeds_by_category(config::Dict, category::String)
    """Get RSS feeds filtered by category"""
    feeds = []
    
    if category == "all"
        # Return all feeds from both categories
        append!(feeds, config["feeds"]["tech"])
        append!(feeds, config["feeds"]["ai"])
    elseif category in ["tech", "ai"]
        feeds = config["feeds"][category]
    else
        error("Invalid category: $category. Use 'all', 'tech', or 'ai'")
    end
    
    return feeds
end

function get_ai_keywords(config::Dict)
    """Extract AI-related keywords from config"""
    return config["ai_filter"]["keywords"]
end

function get_ai_companies(config::Dict)
    """Extract AI company names from config"""
    return config["ai_filter"]["companies"]
end

function get_filter_config(config::Dict)
    """Extract filtering configuration"""
    return config["ai_filter"]
end