"""
Storm Development QA System Interfaces
Defines contracts for dependency injection and testing
"""

from abc import ABC, abstractmethod
from typing import Any


class ConsoleInterface(ABC):
    """Interface for console output systems"""

    @abstractmethod
    def print(self, *args: Any, **kwargs: Any) -> None:
        """Generic print method"""
        pass

    @abstractmethod
    def print_header(self, title: str, subtitle: str | None = None) -> None:
        """Print professional header"""
        pass

    @abstractmethod
    def print_business_context(self, context: str, technology: str = "django") -> None:
        """Print business context information"""
        pass

    @abstractmethod
    def print_analysis(self, analysis_type: str, details: str) -> None:
        """Print analysis information"""
        pass

    @abstractmethod
    def print_error(self, error_type: str, message: str, guidance: str | None = None) -> None:
        """Print error information"""
        pass

    @abstractmethod
    def print_success(self, title: str, message: str) -> None:
        """Print success message with Storm styling."""
        pass

    @abstractmethod
    def print_warning(self, title: str, message: str) -> None:
        """Print warning message with Storm styling."""
        pass

    @abstractmethod
    def print_business_metric(
        self,
        metric_name: str,
        value: Any,
        threshold: Any | None = None,
        context: str = "business",
    ) -> None:
        """Print business metric with professional formatting."""
        pass

    @abstractmethod
    def print_test_progress(
        self, test_name: str, status: str, duration: float | None = None
    ) -> None:
        """Print test progress with status-specific styling."""
        pass

    @abstractmethod
    def print_session_summary(
        self, tests_run: int, passed: int, failed: int, duration: float
    ) -> None:
        """Print test session summary"""
        pass

    @abstractmethod
    def print_business_recommendation(self, title: str, recommendations: list[str]) -> None:
        """Print business recommendations"""
        pass

    @abstractmethod
    def print_info(self, title: str, message: str) -> None:
        """Print info message with Storm styling."""
        pass

    @abstractmethod
    def print_panel(self, title: str, content: str, style: str = "storm.info") -> None:
        """Print a panel with Storm styling."""
        pass

    @abstractmethod
    def print_table(self, title: str, columns: list[str], rows: list[list[Any]]) -> None:
        """Print a table with Storm styling."""
        pass


class TestCategorizerInterface(ABC):
    """Interface for test categorization systems"""

    @abstractmethod
    def categorize_test(self, test_name: str, test_path: str = "") -> dict[str, Any]:
        """Categorize a test and return business context"""
        pass

    @abstractmethod
    def get_learning_path(self, category: str) -> list[str]:
        """Get learning resources for a category"""
        pass

    @abstractmethod
    def get_resolution_guidance(self, category: str) -> dict[str, str]:
        """Get resolution guidance for a category"""
        pass


class FailureAnalyzerInterface(ABC):
    """Interface for test failure analysis systems"""

    @abstractmethod
    def analyze_failure(
        self, test_name: str, error_type: str, error_message: str, traceback: list[str]
    ) -> dict[str, Any]:
        """Analyze a test failure and provide guidance"""
        pass

    @abstractmethod
    def generate_resolution_steps(self, error_type: str, error_message: str) -> list[str]:
        """Generate specific resolution steps"""
        pass

    @abstractmethod
    def generate_qa_guidance(self, error_type: str, error_message: str) -> dict[str, str]:
        """Generate QA learning guidance"""
        pass


class LoggerInterface(ABC):
    """Interface for logging systems"""

    @abstractmethod
    def info(self, message: str, **kwargs: Any) -> None:
        """Log info message"""
        pass

    @abstractmethod
    def error(self, message: str, **kwargs: Any) -> None:
        """Log error message"""
        pass

    @abstractmethod
    def warning(self, message: str, **kwargs: Any) -> None:
        """Log warning message"""
        pass

    @abstractmethod
    def debug(self, message: str, **kwargs: Any) -> None:
        """Log debug message"""
        pass

    @abstractmethod
    def critical(self, message: str, **kwargs: Any) -> None:
        """Log critical message"""
        pass

    @abstractmethod
    def log(self, level: int, message: str, **kwargs: Any) -> None:
        """Log at specific level"""
        pass

    @abstractmethod
    def isEnabledFor(self, level: int) -> bool:
        """Check if logging is enabled for level"""
        pass

    @abstractmethod
    def setLevel(self, level: int) -> None:
        """Set logging level"""
        pass

    @abstractmethod
    def getLevel(self) -> int:
        """Get current logging level"""
        pass


class FormatterInterface(ABC):
    """Interface for message formatting systems"""

    @abstractmethod
    def format(
        self, message: str, level: str | None = None, context: dict[str, Any] | None = None
    ) -> str:
        """Format a message with optional level and context"""
        pass

    @abstractmethod
    def format_message(self, message: str, **kwargs: Any) -> str:
        """Format a general message"""
        pass

    @abstractmethod
    def format_error(self, message: str, **kwargs: Any) -> str:
        """Format an error message"""
        pass

    @abstractmethod
    def format_success(self, message: str, **kwargs: Any) -> str:
        """Format a success message"""
        pass


class MetricsInterface(ABC):
    """Interface for metrics collection systems"""

    @abstractmethod
    def track_event(self, event_type: str, data: dict[str, Any]) -> None:
        """Track a business event"""
        pass

    @abstractmethod
    def track_metric(self, name: str, value: Any, **kwargs: Any) -> None:
        """Track a metric value"""
        pass

    @abstractmethod
    def track_performance(self, operation: str, duration: float) -> None:
        """Track performance metrics"""
        pass

    @abstractmethod
    def get_metrics(self, **filters: Any) -> list[dict[str, Any]]:
        """Get collected metrics with optional filters"""
        pass

    @abstractmethod
    def get_summary(self) -> dict[str, Any]:
        """Get metrics summary"""
        pass

    @abstractmethod
    def clear_metrics(self) -> None:
        """Clear all collected metrics"""
        pass
