"""
Constants and configuration values for MusicBrainz Data Cleaner.
"""

from enum import Enum
from typing import Dict, Tuple

# API Configuration (Legacy - for fallback)
DEFAULT_MUSICBRAINZ_URL = "http://localhost:5001"
API_REQUEST_DELAY = 0.1
MAX_RETRY_ATTEMPTS = 3
REQUEST_TIMEOUT = 30

# Database Configuration (Primary - Direct PostgreSQL access)
# Note: For Docker setups, database port needs to be exposed to host
DB_HOST = "172.18.0.2"  # Docker container IP that works
DB_PORT = 5432
DB_NAME = "musicbrainz_db"  # Updated to match actual database name
DB_USER = "musicbrainz"
DB_PASSWORD = "musicbrainz"  # Default password, should be overridden
DB_CONNECTION_TIMEOUT = 30

# Fuzzy Search Configuration
FUZZY_SEARCH_THRESHOLD = 0.8  # Minimum similarity score (0.0 to 1.0)
MAX_SEARCH_RESULTS = 10  # Maximum results to return from fuzzy search
TITLE_SIMILARITY_THRESHOLD = 0.85  # Higher threshold for title matching
ARTIST_SIMILARITY_THRESHOLD = 0.8  # Lower threshold for artist matching

# Data file paths
KNOWN_ARTISTS_FILE = "data/known_artists.json"
KNOWN_RECORDINGS_FILE = "data/known_recordings.json"

# CLI Configuration
class ExitCode(int, Enum):
    SUCCESS = 0
    ERROR = 1
    USAGE_ERROR = 2

# Progress Indicators
PROGRESS_SEPARATOR = "=" * 50

# Messages
SUCCESS_MESSAGES = {
    'processing_complete': "✅ Processing complete!",
    'output_saved': "📁 Output saved to: {file_path}",
    'db_connected': "✅ Connected to MusicBrainz database",
    'fuzzy_match_found': "🎯 Fuzzy match found: {original} → {matched} (score: {score:.2f})",
}

ERROR_MESSAGES = {
    'file_not_found': "Error: File '{file_path}' not found",
    'invalid_json': "Error: Invalid JSON in file '{file_path}'",
    'not_array': "Error: Input file should contain a JSON array of songs",
    'db_connection_failed': "❌ Failed to connect to MusicBrainz database",
    'db_query_failed': "❌ Database query failed: {error}",
    'no_fuzzy_match': "❌ No fuzzy match found for: {query}",
}
