// The magic numbers 299, 587, and 114 represent the luminance coefficients for the NTSC formula.
const LUMINANCE_RED = 299;
const LUMINANCE_GREEN = 587;
const LUMINANCE_BLUE = 114;
const BRIGHTNESS_THRESHOLD = 186;
export function isLightColor(hexColor) {
    if (!hexColor)
        return false;
    // Remove hash if present
    const hex = hexColor.replace(/^#/, "");
    // Parse r, g, b
    const bigint = parseInt(hex, 16);
    let r;
    let g;
    let b;
    if (hex.length === 6) {
        r = (bigint >> 16) & 255;
        g = (bigint >> 8) & 255;
        b = bigint & 255;
    }
    else if (hex.length === 3) {
        r = ((bigint >> 8) & 15) * 17;
        g = ((bigint >> 4) & 15) * 17;
        b = (bigint & 15) * 17;
    }
    else {
        return false;
    }
    // Perceived brightness formula
    const brightness = (r * LUMINANCE_RED + g * LUMINANCE_GREEN + b * LUMINANCE_BLUE) / 1000;
    return brightness > BRIGHTNESS_THRESHOLD;
}
//# sourceMappingURL=index.js.map