import utils_default from "../utils/index.js";
import { TYPE } from "../constants.js";
import type_default from "./type.js";
var channels_default = class {
	constructor(e, t) {
		this.color = t, this.changed = !1, this.data = e, this.type = new type_default();
	}
	set(e, n) {
		return this.color = n, this.changed = !1, this.data = e, this.type.type = TYPE.ALL, this;
	}
	_ensureHSL() {
		let t = this.data, { h: n, s: r, l: i } = t;
		n === void 0 && (t.h = utils_default.channel.rgb2hsl(t, "h")), r === void 0 && (t.s = utils_default.channel.rgb2hsl(t, "s")), i === void 0 && (t.l = utils_default.channel.rgb2hsl(t, "l"));
	}
	_ensureRGB() {
		let t = this.data, { r: n, g: r, b: i } = t;
		n === void 0 && (t.r = utils_default.channel.hsl2rgb(t, "r")), r === void 0 && (t.g = utils_default.channel.hsl2rgb(t, "g")), i === void 0 && (t.b = utils_default.channel.hsl2rgb(t, "b"));
	}
	get r() {
		let n = this.data, r = n.r;
		return !this.type.is(TYPE.HSL) && r !== void 0 ? r : (this._ensureHSL(), utils_default.channel.hsl2rgb(n, "r"));
	}
	get g() {
		let n = this.data, r = n.g;
		return !this.type.is(TYPE.HSL) && r !== void 0 ? r : (this._ensureHSL(), utils_default.channel.hsl2rgb(n, "g"));
	}
	get b() {
		let n = this.data, r = n.b;
		return !this.type.is(TYPE.HSL) && r !== void 0 ? r : (this._ensureHSL(), utils_default.channel.hsl2rgb(n, "b"));
	}
	get h() {
		let n = this.data, r = n.h;
		return !this.type.is(TYPE.RGB) && r !== void 0 ? r : (this._ensureRGB(), utils_default.channel.rgb2hsl(n, "h"));
	}
	get s() {
		let n = this.data, r = n.s;
		return !this.type.is(TYPE.RGB) && r !== void 0 ? r : (this._ensureRGB(), utils_default.channel.rgb2hsl(n, "s"));
	}
	get l() {
		let n = this.data, r = n.l;
		return !this.type.is(TYPE.RGB) && r !== void 0 ? r : (this._ensureRGB(), utils_default.channel.rgb2hsl(n, "l"));
	}
	get a() {
		return this.data.a;
	}
	set r(e) {
		this.type.set(TYPE.RGB), this.changed = !0, this.data.r = e;
	}
	set g(e) {
		this.type.set(TYPE.RGB), this.changed = !0, this.data.g = e;
	}
	set b(e) {
		this.type.set(TYPE.RGB), this.changed = !0, this.data.b = e;
	}
	set h(e) {
		this.type.set(TYPE.HSL), this.changed = !0, this.data.h = e;
	}
	set s(e) {
		this.type.set(TYPE.HSL), this.changed = !0, this.data.s = e;
	}
	set l(e) {
		this.type.set(TYPE.HSL), this.changed = !0, this.data.l = e;
	}
	set a(e) {
		this.changed = !0, this.data.a = e;
	}
};
export { channels_default as default };
