<?php

namespace App\Enums;

enum MatchStatus: string
{
    // ── Used in both JobNotification and FreelanceMatch ────────
    case Pending    = 'pending';    // Waiting for the other party to respond
    case Interested = 'interested'; // Freelancer wants to connect (freelance only)
    case Accepted   = 'accepted';   // Professional accepted job interest (jobs only)
    case Declined   = 'declined';   // Not interested — no contact shared
    case Connected  = 'connected';  // Both consented — contact details shared

    public function label(): string
    {
        return match($this) {
            MatchStatus::Pending    => 'Pending',
            MatchStatus::Interested => 'Interested',
            MatchStatus::Accepted   => 'Accepted',
            MatchStatus::Declined   => 'Declined',
            MatchStatus::Connected  => 'Connected',
        };
    }

    public function labelAr(): string
    {
        return match($this) {
            MatchStatus::Pending    => 'في الانتظار',
            MatchStatus::Interested => 'مهتم',
            MatchStatus::Accepted   => 'تم القبول',
            MatchStatus::Declined   => 'تم الرفض',
            MatchStatus::Connected  => 'تم التواصل',
        };
    }

    // Badge color for the UI
    public function color(): string
    {
        return match($this) {
            MatchStatus::Pending    => 'gray',
            MatchStatus::Interested => 'blue',
            MatchStatus::Accepted   => 'amber',
            MatchStatus::Declined   => 'red',
            MatchStatus::Connected  => 'green',
        };
    }

    // Has this match resulted in contact being shared?
    public function isConnected(): bool
    {
        return $this === MatchStatus::Connected;
    }

    // Is this match still in progress (not resolved yet)?
    public function isActive(): bool
    {
        return in_array($this, [
            MatchStatus::Pending,
            MatchStatus::Interested,
            MatchStatus::Accepted,
        ]);
    }

    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }
}
