import { __require as A } from "../../../color-string@1.9.1/node_modules/color-string/index.js";
import { __require as F } from "../../../color-convert@2.0.1/node_modules/color-convert/index.js";
var m, w;
function O() {
  if (w) return m;
  w = 1;
  const u = A(), l = F(), d = [
    // To be honest, I don't really feel like keyword belongs in color convert, but eh.
    "keyword",
    // Gray conflicts with some method names, and has its own method defined.
    "gray",
    // Shouldn't really be in color-convert either...
    "hex"
  ], g = {};
  for (const r of Object.keys(l))
    g[[...l[r].labels].sort().join("")] = r;
  const p = {};
  function h(r, t) {
    if (!(this instanceof h))
      return new h(r, t);
    if (t && t in d && (t = null), t && !(t in l))
      throw new Error("Unknown model: " + t);
    let o, n;
    if (r == null)
      this.model = "rgb", this.color = [0, 0, 0], this.valpha = 1;
    else if (r instanceof h)
      this.model = r.model, this.color = [...r.color], this.valpha = r.valpha;
    else if (typeof r == "string") {
      const e = u.get(r);
      if (e === null)
        throw new Error("Unable to parse color from string: " + r);
      this.model = e.model, n = l[this.model].channels, this.color = e.value.slice(0, n), this.valpha = typeof e.value[n] == "number" ? e.value[n] : 1;
    } else if (r.length > 0) {
      this.model = t || "rgb", n = l[this.model].channels;
      const e = Array.prototype.slice.call(r, 0, n);
      this.color = b(e, n), this.valpha = typeof r[n] == "number" ? r[n] : 1;
    } else if (typeof r == "number")
      this.model = "rgb", this.color = [
        r >> 16 & 255,
        r >> 8 & 255,
        r & 255
      ], this.valpha = 1;
    else {
      this.valpha = 1;
      const e = Object.keys(r);
      "alpha" in r && (e.splice(e.indexOf("alpha"), 1), this.valpha = typeof r.alpha == "number" ? r.alpha : 0);
      const a = e.sort().join("");
      if (!(a in g))
        throw new Error("Unable to parse color from object: " + JSON.stringify(r));
      this.model = g[a];
      const { labels: f } = l[this.model], c = [];
      for (o = 0; o < f.length; o++)
        c.push(r[f[o]]);
      this.color = b(c);
    }
    if (p[this.model])
      for (n = l[this.model].channels, o = 0; o < n; o++) {
        const e = p[this.model][o];
        e && (this.color[o] = e(this.color[o]));
      }
    this.valpha = Math.max(0, Math.min(1, this.valpha)), Object.freeze && Object.freeze(this);
  }
  h.prototype = {
    toString() {
      return this.string();
    },
    toJSON() {
      return this[this.model]();
    },
    string(r) {
      let t = this.model in u.to ? this : this.rgb();
      t = t.round(typeof r == "number" ? r : 1);
      const o = t.valpha === 1 ? t.color : [...t.color, this.valpha];
      return u.to[t.model](o);
    },
    percentString(r) {
      const t = this.rgb().round(typeof r == "number" ? r : 1), o = t.valpha === 1 ? t.color : [...t.color, this.valpha];
      return u.to.rgb.percent(o);
    },
    array() {
      return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
    },
    object() {
      const r = {}, { channels: t } = l[this.model], { labels: o } = l[this.model];
      for (let n = 0; n < t; n++)
        r[o[n]] = this.color[n];
      return this.valpha !== 1 && (r.alpha = this.valpha), r;
    },
    unitArray() {
      const r = this.rgb().color;
      return r[0] /= 255, r[1] /= 255, r[2] /= 255, this.valpha !== 1 && r.push(this.valpha), r;
    },
    unitObject() {
      const r = this.rgb().object();
      return r.r /= 255, r.g /= 255, r.b /= 255, this.valpha !== 1 && (r.alpha = this.valpha), r;
    },
    round(r) {
      return r = Math.max(r || 0, 0), new h([...this.color.map(x(r)), this.valpha], this.model);
    },
    alpha(r) {
      return r !== void 0 ? new h([...this.color, Math.max(0, Math.min(1, r))], this.model) : this.valpha;
    },
    // Rgb
    red: s("rgb", 0, i(255)),
    green: s("rgb", 1, i(255)),
    blue: s("rgb", 2, i(255)),
    hue: s(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, (r) => (r % 360 + 360) % 360),
    saturationl: s("hsl", 1, i(100)),
    lightness: s("hsl", 2, i(100)),
    saturationv: s("hsv", 1, i(100)),
    value: s("hsv", 2, i(100)),
    chroma: s("hcg", 1, i(100)),
    gray: s("hcg", 2, i(100)),
    white: s("hwb", 1, i(100)),
    wblack: s("hwb", 2, i(100)),
    cyan: s("cmyk", 0, i(100)),
    magenta: s("cmyk", 1, i(100)),
    yellow: s("cmyk", 2, i(100)),
    black: s("cmyk", 3, i(100)),
    x: s("xyz", 0, i(95.047)),
    y: s("xyz", 1, i(100)),
    z: s("xyz", 2, i(108.833)),
    l: s("lab", 0, i(100)),
    a: s("lab", 1),
    b: s("lab", 2),
    keyword(r) {
      return r !== void 0 ? new h(r) : l[this.model].keyword(this.color);
    },
    hex(r) {
      return r !== void 0 ? new h(r) : u.to.hex(this.rgb().round().color);
    },
    hexa(r) {
      if (r !== void 0)
        return new h(r);
      const t = this.rgb().round().color;
      let o = Math.round(this.valpha * 255).toString(16).toUpperCase();
      return o.length === 1 && (o = "0" + o), u.to.hex(t) + o;
    },
    rgbNumber() {
      const r = this.rgb().color;
      return (r[0] & 255) << 16 | (r[1] & 255) << 8 | r[2] & 255;
    },
    luminosity() {
      const r = this.rgb().color, t = [];
      for (const [o, n] of r.entries()) {
        const e = n / 255;
        t[o] = e <= 0.04045 ? e / 12.92 : ((e + 0.055) / 1.055) ** 2.4;
      }
      return 0.2126 * t[0] + 0.7152 * t[1] + 0.0722 * t[2];
    },
    contrast(r) {
      const t = this.luminosity(), o = r.luminosity();
      return t > o ? (t + 0.05) / (o + 0.05) : (o + 0.05) / (t + 0.05);
    },
    level(r) {
      const t = this.contrast(r);
      return t >= 7 ? "AAA" : t >= 4.5 ? "AA" : "";
    },
    isDark() {
      const r = this.rgb().color;
      return (r[0] * 2126 + r[1] * 7152 + r[2] * 722) / 1e4 < 128;
    },
    isLight() {
      return !this.isDark();
    },
    negate() {
      const r = this.rgb();
      for (let t = 0; t < 3; t++)
        r.color[t] = 255 - r.color[t];
      return r;
    },
    lighten(r) {
      const t = this.hsl();
      return t.color[2] += t.color[2] * r, t;
    },
    darken(r) {
      const t = this.hsl();
      return t.color[2] -= t.color[2] * r, t;
    },
    saturate(r) {
      const t = this.hsl();
      return t.color[1] += t.color[1] * r, t;
    },
    desaturate(r) {
      const t = this.hsl();
      return t.color[1] -= t.color[1] * r, t;
    },
    whiten(r) {
      const t = this.hwb();
      return t.color[1] += t.color[1] * r, t;
    },
    blacken(r) {
      const t = this.hwb();
      return t.color[2] += t.color[2] * r, t;
    },
    grayscale() {
      const r = this.rgb().color, t = r[0] * 0.3 + r[1] * 0.59 + r[2] * 0.11;
      return h.rgb(t, t, t);
    },
    fade(r) {
      return this.alpha(this.valpha - this.valpha * r);
    },
    opaquer(r) {
      return this.alpha(this.valpha + this.valpha * r);
    },
    rotate(r) {
      const t = this.hsl();
      let o = t.color[0];
      return o = (o + r) % 360, o = o < 0 ? 360 + o : o, t.color[0] = o, t;
    },
    mix(r, t) {
      if (!r || !r.rgb)
        throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof r);
      const o = r.rgb(), n = this.rgb(), e = t === void 0 ? 0.5 : t, a = 2 * e - 1, f = o.alpha() - n.alpha(), c = ((a * f === -1 ? a : (a + f) / (1 + a * f)) + 1) / 2, y = 1 - c;
      return h.rgb(
        c * o.red() + y * n.red(),
        c * o.green() + y * n.green(),
        c * o.blue() + y * n.blue(),
        o.alpha() * e + n.alpha() * (1 - e)
      );
    }
  };
  for (const r of Object.keys(l)) {
    if (d.includes(r))
      continue;
    const { channels: t } = l[r];
    h.prototype[r] = function(...o) {
      return this.model === r ? new h(this) : o.length > 0 ? new h(o, r) : new h([...k(l[this.model][r].raw(this.color)), this.valpha], r);
    }, h[r] = function(...o) {
      let n = o[0];
      return typeof n == "number" && (n = b(o, t)), new h(n, r);
    };
  }
  function v(r, t) {
    return Number(r.toFixed(t));
  }
  function x(r) {
    return function(t) {
      return v(t, r);
    };
  }
  function s(r, t, o) {
    r = Array.isArray(r) ? r : [r];
    for (const n of r)
      (p[n] || (p[n] = []))[t] = o;
    return r = r[0], function(n) {
      let e;
      return n !== void 0 ? (o && (n = o(n)), e = this[r](), e.color[t] = n, e) : (e = this[r]().color[t], o && (e = o(e)), e);
    };
  }
  function i(r) {
    return function(t) {
      return Math.max(0, Math.min(r, t));
    };
  }
  function k(r) {
    return Array.isArray(r) ? r : [r];
  }
  function b(r, t) {
    for (let o = 0; o < t; o++)
      typeof r[o] != "number" && (r[o] = 0);
    return r;
  }
  return m = h, m;
}
export {
  O as __require
};
//# sourceMappingURL=index.js.map
