<?php

declare(strict_types=1);

namespace App\Enums;

enum CreatorMilestoneType: string
{
    // ── v1 milestones ─────────────────────────────────────────────────────────
    case FirstUpload = 'first_upload';
    case FirstFeaturedArtwork = 'first_featured_artwork';
    case FirstGroupRelease = 'first_group_release';
    case BiggestDownloadSpike = 'biggest_download_spike';
    case BestPerformingWork = 'best_performing_work';
    case MostProductiveYear = 'most_productive_year';
    case YearlyRecap = 'yearly_recap';

    // ── v2: Comeback milestones ────────────────────────────────────────────────
    case ComebackMinor = 'comeback_minor';           // 180–364 days gap
    case ComebackMajor = 'comeback_major';           // 365–1094 days gap (1–3 years)
    case ComebackLegendary = 'comeback_legendary';   // 1095+ days gap (3+ years)

    // ── v2: Streak milestones ─────────────────────────────────────────────────
    case UploadStreak3 = 'upload_streak_3';
    case UploadStreak6 = 'upload_streak_6';
    case UploadStreak12 = 'upload_streak_12';
    case ActiveYearStreak3 = 'active_year_streak_3';
    case ActiveYearStreak5 = 'active_year_streak_5';

    // ── v2: Evolution / Era milestones ────────────────────────────────────────
    case BeforeNow = 'before_now';
    case EraStarted = 'era_started';

    public function priority(): int
    {
        return match ($this) {
            self::BestPerformingWork       => 100,
            self::BiggestDownloadSpike     => 95,
            self::FirstFeaturedArtwork     => 90,
            self::ComebackLegendary        => 88,
            self::UploadStreak12           => 87,
            self::ActiveYearStreak5        => 86,
            self::MostProductiveYear       => 85,
            self::ActiveYearStreak3        => 84,
            self::UploadStreak6            => 83,
            self::FirstGroupRelease        => 80,
            self::BeforeNow                => 78,
            self::ComebackMajor            => 77,
            self::EraStarted               => 76,
            self::FirstUpload              => 75,
            self::UploadStreak3            => 72,
            self::ComebackMinor            => 70,
            self::YearlyRecap              => 60,
        };
    }

    public function isV2(): bool
    {
        return match ($this) {
            self::ComebackMinor,
            self::ComebackMajor,
            self::ComebackLegendary,
            self::UploadStreak3,
            self::UploadStreak6,
            self::UploadStreak12,
            self::ActiveYearStreak3,
            self::ActiveYearStreak5,
            self::BeforeNow,
            self::EraStarted => true,
            default => false,
        };
    }
}