<?php

namespace App\Enums;

enum WaMessageStatus: string
{
    case Queued = 'queued';       // created, awaiting send
    case Sent = 'sent';           // accepted by provider
    case Delivered = 'delivered'; // delivered to handset
    case Read = 'read';           // read receipt
    case Failed = 'failed';       // permanent failure (after retries)
    case Retrying = 'retrying';   // transient failure, scheduled to retry

    public function label(): string
    {
        return __(match ($this) {
            self::Queued => 'Queued',
            self::Sent => 'Sent',
            self::Delivered => 'Delivered',
            self::Read => 'Read',
            self::Failed => 'Failed',
            self::Retrying => 'Retrying',
        });
    }

    public function color(): string
    {
        return match ($this) {
            self::Queued, self::Retrying => '#F5A524',
            self::Sent => '#0EA5E9',
            self::Delivered => '#8B5CF6',
            self::Read => '#22C55E',
            self::Failed => '#EF4444',
        };
    }

    public function isTerminal(): bool
    {
        return in_array($this, [self::Delivered, self::Read, self::Failed], true);
    }
}
