const colorEnum = {
    critical: {
        R: 255,
        G: 87,
        B: 77,
        A: 1,
    },
    warning: {
        R: 254,
        G: 138,
        B: 55,
        A: 1,
    },
    major: {
        R: 67,
        G: 128,
        B: 229,
        A: 1,
    },
    info: {
        R: 85,
        G: 251,
        B: 170,
        A: 1,
    },
};

const getColor = (key: string = 'info', alpha: number = 1) => {
    return `rgba(${colorEnum[key].R}, ${colorEnum[key].G}, ${colorEnum[key].B}, ${alpha || colorEnum[key].A})`;
};

const cptColor = (value: number, alpha: number = 1) => {
    let color = '';
    switch (true) {
        case value < 70:
            color = getColor('critical', alpha);
            break;
        case value >= 70 && value < 80:
            color = getColor('warning', alpha);
            break;
        case value >= 80 && value < 90:
            color = getColor('major', alpha);
            break;
        case value >= 90:
            color = getColor('info', alpha);
            break;
    }
    return color;
};

const keyColor = (value, alpha = 1) => {
    return getColor(value, alpha);
};

export { colorEnum, getColor, cptColor, keyColor };
