"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index = require("./dist-utils-index.cjs");
const type = require("./dist-channels-type.cjs");
const constants = require("./dist-constants.cjs");
class Channels {
  /* CONSTRUCTOR */
  constructor(data, color) {
    this.color = color;
    this.changed = false;
    this.data = data;
    this.type = new type.default();
  }
  /* API */
  set(data, color) {
    this.color = color;
    this.changed = false;
    this.data = data;
    this.type.type = constants.TYPE.ALL;
    return this;
  }
  /* HELPERS */
  _ensureHSL() {
    const data = this.data;
    const { h, s, l } = data;
    if (h === void 0)
      data.h = index.default.channel.rgb2hsl(data, "h");
    if (s === void 0)
      data.s = index.default.channel.rgb2hsl(data, "s");
    if (l === void 0)
      data.l = index.default.channel.rgb2hsl(data, "l");
  }
  _ensureRGB() {
    const data = this.data;
    const { r, g, b } = data;
    if (r === void 0)
      data.r = index.default.channel.hsl2rgb(data, "r");
    if (g === void 0)
      data.g = index.default.channel.hsl2rgb(data, "g");
    if (b === void 0)
      data.b = index.default.channel.hsl2rgb(data, "b");
  }
  /* GETTERS */
  get r() {
    const data = this.data;
    const r = data.r;
    if (!this.type.is(constants.TYPE.HSL) && r !== void 0)
      return r;
    this._ensureHSL();
    return index.default.channel.hsl2rgb(data, "r");
  }
  get g() {
    const data = this.data;
    const g = data.g;
    if (!this.type.is(constants.TYPE.HSL) && g !== void 0)
      return g;
    this._ensureHSL();
    return index.default.channel.hsl2rgb(data, "g");
  }
  get b() {
    const data = this.data;
    const b = data.b;
    if (!this.type.is(constants.TYPE.HSL) && b !== void 0)
      return b;
    this._ensureHSL();
    return index.default.channel.hsl2rgb(data, "b");
  }
  get h() {
    const data = this.data;
    const h = data.h;
    if (!this.type.is(constants.TYPE.RGB) && h !== void 0)
      return h;
    this._ensureRGB();
    return index.default.channel.rgb2hsl(data, "h");
  }
  get s() {
    const data = this.data;
    const s = data.s;
    if (!this.type.is(constants.TYPE.RGB) && s !== void 0)
      return s;
    this._ensureRGB();
    return index.default.channel.rgb2hsl(data, "s");
  }
  get l() {
    const data = this.data;
    const l = data.l;
    if (!this.type.is(constants.TYPE.RGB) && l !== void 0)
      return l;
    this._ensureRGB();
    return index.default.channel.rgb2hsl(data, "l");
  }
  get a() {
    return this.data.a;
  }
  /* SETTERS */
  set r(r) {
    this.type.set(constants.TYPE.RGB);
    this.changed = true;
    this.data.r = r;
  }
  set g(g) {
    this.type.set(constants.TYPE.RGB);
    this.changed = true;
    this.data.g = g;
  }
  set b(b) {
    this.type.set(constants.TYPE.RGB);
    this.changed = true;
    this.data.b = b;
  }
  set h(h) {
    this.type.set(constants.TYPE.HSL);
    this.changed = true;
    this.data.h = h;
  }
  set s(s) {
    this.type.set(constants.TYPE.HSL);
    this.changed = true;
    this.data.s = s;
  }
  set l(l) {
    this.type.set(constants.TYPE.HSL);
    this.changed = true;
    this.data.l = l;
  }
  set a(a) {
    this.changed = true;
    this.data.a = a;
  }
}
exports.default = Channels;
//# sourceMappingURL=dist-channels-index.cjs.map
