<?php

namespace App\Enums;

enum EstadoSolicitud: string
{
    case BORRADOR           = 'borrador';
    case RADICADA           = 'radicada';
    case EN_REVISION        = 'en_revision';
    case ACOMPANAMIENTO     = 'acompanamiento_solidario';
    case APROBADA           = 'aprobada_comite';
    case RECHAZADA          = 'rechazada';
    case EN_EJECUCION       = 'en_ejecucion';
    case INFORME_1          = 'informe_1';
    case INFORME_2          = 'informe_2';
    case INFORME_3          = 'informe_3';
    case INFORME_4          = 'informe_4';
    case INFORME_5          = 'informe_5';
    case INFORME_6          = 'informe_6';
    case EN_CONDONACION     = 'en_condonacion';
    case CONDONADA          = 'condonada';
    case DESEMBOLSADA       = 'desembolsada';

    public function label(): string
    {
        return match($this) {
            self::BORRADOR       => 'Borrador',
            self::RADICADA       => 'Radicada',
            self::EN_REVISION    => 'En revisión',
            self::ACOMPANAMIENTO => 'Acompañamiento SOY SOLIDARIO',
            self::APROBADA       => 'Aprobada por Comité',
            self::RECHAZADA      => 'Rechazada',
            self::EN_EJECUCION   => 'En ejecución (período de gracia)',
            self::INFORME_1      => 'Informe mensual #1',
            self::INFORME_2      => 'Informe mensual #2',
            self::INFORME_3      => 'Informe mensual #3',
            self::INFORME_4      => 'Informe mensual #4',
            self::INFORME_5      => 'Informe mensual #5',
            self::INFORME_6      => 'Informe mensual #6',
            self::EN_CONDONACION => 'En proceso de condonación',
            self::CONDONADA      => 'Condonada',
            self::DESEMBOLSADA   => 'Desembolsada',
        };
    }

    public function color(): string
    {
        return match($this) {
            self::BORRADOR       => 'gray',
            self::RADICADA       => 'blue',
            self::EN_REVISION    => 'yellow',
            self::ACOMPANAMIENTO => 'purple',
            self::APROBADA       => 'green',
            self::RECHAZADA      => 'red',
            self::EN_EJECUCION   => 'indigo',
            self::INFORME_1, self::INFORME_2, self::INFORME_3,
            self::INFORME_4, self::INFORME_5, self::INFORME_6 => 'orange',
            self::EN_CONDONACION => 'teal',
            self::CONDONADA      => 'emerald',
            self::DESEMBOLSADA   => 'cyan',
        };
    }

    public function transicionesPermitidas(): array
    {
        return match($this) {
            self::BORRADOR       => [self::RADICADA],
            self::RADICADA       => [self::EN_REVISION, self::RECHAZADA],
            self::EN_REVISION    => [self::ACOMPANAMIENTO, self::RECHAZADA],
            self::ACOMPANAMIENTO => [self::APROBADA, self::RECHAZADA],
            self::APROBADA       => [self::EN_EJECUCION],
            self::EN_EJECUCION   => [self::INFORME_1],
            self::INFORME_1      => [self::INFORME_2],
            self::INFORME_2      => [self::INFORME_3],
            self::INFORME_3      => [self::INFORME_4],
            self::INFORME_4      => [self::INFORME_5],
            self::INFORME_5      => [self::INFORME_6],
            self::INFORME_6      => [self::EN_CONDONACION, self::DESEMBOLSADA],
            self::EN_CONDONACION => [self::CONDONADA, self::DESEMBOLSADA],
            default              => [],
        };
    }

    public static function informes(): array
    {
        return [
            self::INFORME_1, self::INFORME_2, self::INFORME_3,
            self::INFORME_4, self::INFORME_5, self::INFORME_6,
        ];
    }
}
