<?php

declare(strict_types=1);

namespace App\Framework\MachineLearning\ModelManagement\ValueObjects;

use App\Framework\Notification\ValueObjects\NotificationTypeInterface;

/**
 * ML-specific Notification Types
 *
 * Machine Learning model monitoring and alerting notification categories
 */
enum MLNotificationType: string implements NotificationTypeInterface
{
    case DRIFT_DETECTED = 'ml_drift_detected';
    case PERFORMANCE_DEGRADATION = 'ml_performance_degradation';
    case LOW_CONFIDENCE = 'ml_low_confidence';
    case LOW_ACCURACY = 'ml_low_accuracy';
    case MODEL_DEPLOYED = 'ml_model_deployed';
    case MODEL_RETIRED = 'ml_model_retired';
    case AUTO_TUNING_TRIGGERED = 'ml_auto_tuning_triggered';
    case BASELINE_UPDATED = 'ml_baseline_updated';

    public function toString(): string
    {
        return $this->value;
    }

    public function getDisplayName(): string
    {
        return match ($this) {
            self::DRIFT_DETECTED => 'ML Model Drift Detected',
            self::PERFORMANCE_DEGRADATION => 'ML Performance Degradation',
            self::LOW_CONFIDENCE => 'ML Low Confidence Warning',
            self::LOW_ACCURACY => 'ML Low Accuracy Warning',
            self::MODEL_DEPLOYED => 'ML Model Deployed',
            self::MODEL_RETIRED => 'ML Model Retired',
            self::AUTO_TUNING_TRIGGERED => 'ML Auto-Tuning Triggered',
            self::BASELINE_UPDATED => 'ML Baseline Updated',
        };
    }

    public function isCritical(): bool
    {
        return match ($this) {
            self::DRIFT_DETECTED,
            self::PERFORMANCE_DEGRADATION,
            self::LOW_ACCURACY => true,
            default => false,
        };
    }

    /**
     * Check if this notification requires immediate action
     */
    public function requiresImmediateAction(): bool
    {
        return match ($this) {
            self::DRIFT_DETECTED,
            self::PERFORMANCE_DEGRADATION => true,
            default => false,
        };
    }

    /**
     * Get recommended notification channels for this type
     */
    public function getRecommendedChannels(): array
    {
        return match ($this) {
            self::DRIFT_DETECTED,
            self::PERFORMANCE_DEGRADATION => [
                \App\Framework\Notification\ValueObjects\NotificationChannel::EMAIL,
                \App\Framework\Notification\ValueObjects\NotificationChannel::DATABASE,
            ],
            self::LOW_CONFIDENCE,
            self::LOW_ACCURACY => [
                \App\Framework\Notification\ValueObjects\NotificationChannel::DATABASE,
                \App\Framework\Notification\ValueObjects\NotificationChannel::EMAIL,
            ],
            self::MODEL_DEPLOYED,
            self::MODEL_RETIRED,
            self::AUTO_TUNING_TRIGGERED,
            self::BASELINE_UPDATED => [
                \App\Framework\Notification\ValueObjects\NotificationChannel::DATABASE,
            ],
        };
    }
}
