import { hsvToRgb, rgbToHsv } from "../../../../utils/color-utils.js";
class ColorParser {
    rgb() {
        return this.rgbString(this.red, this.green, this.blue);
    }
    rgbInverted() {
        return this.rgbString(255 - this.red, 255 - this.green, 255 - this.blue);
    }
    rgbSaturated() {
        const { h, s, v } = rgbToHsv(this.red, this.green, this.blue);
        let newSaturation = 2 * s;
        if (newSaturation > 1) newSaturation = 1;
        const { r, g, b } = hsvToRgb(h, newSaturation, v);
        return this.rgbString(r, g, b);
    }
    rgbString(r, g, b) {
        return `rgb(${r}, ${g}, ${b})`;
    }
    constructor(color){
        this.color = color;
        this.red = 255;
        this.green = 255;
        this.blue = 255;
        const rgb = this.color.match(ColorParser.REGEX);
        if (rgb) {
            this.red = parseInt(rgb[1], 10);
            this.green = parseInt(rgb[2], 10);
            this.blue = parseInt(rgb[3], 10);
        }
    }
}
ColorParser.REGEX = /\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/i;
export { ColorParser };
