"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getContrastTextColor = exports.lightOrDark = exports.getAccentOverrideStyleContent = exports.Color = void 0;
var Color;
(function (Color) {
    Color["Accent"] = "var(--rs-color-accent-1)";
    Color["Accent2"] = "var(--rs-color-accent-2)";
    Color["Accent3"] = "var(--rs-color-accent-3)";
    Color["Success"] = "var(--rs-color-success)";
    Color["SuccessTint"] = "var(--rs-color-success-tint)";
    Color["Danger"] = "var(--rs-color-danger)";
    Color["Warning"] = "var(--rs-color-warning)";
    Color["Alert"] = "var(--rs-color-alert)";
    Color["Graphite"] = "var(--rs-color-graphite)";
    Color["DarkGrey"] = "var(--rs-color-dark-grey)";
    Color["Grey"] = "var(--rs-color-grey)";
    Color["LightGrey"] = "var(--rs-color-light-grey)";
    Color["Snow"] = "var(--rs-color-snow)";
    Color["Navy"] = "var(--rs-color-navy)";
    Color["White"] = "var(--rs-color-white)";
})(Color || (exports.Color = Color = {}));
/** Returns the style tag content for overriding default colors. Insert this in an existing style tag, you'll need to specify your own target */
const getAccentOverrideStyleContent = (color) => {
    let headerOverrides = '';
    if (color.navbar) {
        headerOverrides = `
        --rs-color-header-background: ${color.navbar.background}!important;
        --rs-color-header-text: ${color.navbar.text}!important;
        --rs-color-header-text-active: ${color.navbar.textActive}!important;
        `;
    }
    return `
        --rs-color-accent-1: ${color.accent}!important;
        --rs-color-accent-2: ${color.accent2}!important;
        --rs-color-accent-3: ${color.accent3}!important;

        ${headerOverrides}

        ${color.success ? `--rs-color-success: ${color.success}!important;` : ''}`;
};
exports.getAccentOverrideStyleContent = getAccentOverrideStyleContent;
const lightOrDark = (hc) => {
    if (hc[0] === '#') {
        hc = hc.replace('#', '');
    }
    const [r, g, b] = [0, 2, 4].map((p) => parseInt(hc.substring(p, p + 2), 16));
    const yiq = (r * 299 + g * 587 + b * 114) / 1000;
    return yiq >= 128 ? 'light' : 'dark';
};
exports.lightOrDark = lightOrDark;
const getContrastTextColor = (backgroundColor) => backgroundColor ? ((0, exports.lightOrDark)(backgroundColor) === 'light' ? Color.Navy : Color.White) : Color.Navy;
exports.getContrastTextColor = getContrastTextColor;
//# sourceMappingURL=Color.js.map