import e, { extend as t } from "./define.js";
import { Color as n, Rgb as r, rgbConvert as i } from "./color.js";
import { degrees as a, radians as o } from "./math.js";
//#region ../../node_modules/d3-color/src/lab.js
var s = 18, c = .96422, l = 1, u = .82521, d = 4 / 29, f = 6 / 29, p = 3 * f * f, m = f * f * f;
function h(e) {
	if (e instanceof _) return new _(e.l, e.a, e.b, e.opacity);
	if (e instanceof w) return T(e);
	e instanceof r || (e = i(e));
	var t = x(e.r), n = x(e.g), a = x(e.b), o = v((.2225045 * t + .7168786 * n + .0606169 * a) / l), s, d;
	return t === n && n === a ? s = d = o : (s = v((.4360747 * t + .3850649 * n + .1430804 * a) / c), d = v((.0139322 * t + .0971045 * n + .7141733 * a) / u)), new _(116 * o - 16, 500 * (s - o), 200 * (o - d), e.opacity);
}
function g(e, t, n, r) {
	return arguments.length === 1 ? h(e) : new _(e, t, n, r ?? 1);
}
function _(e, t, n, r) {
	this.l = +e, this.a = +t, this.b = +n, this.opacity = +r;
}
e(_, g, t(n, {
	brighter(e) {
		return new _(this.l + s * (e ?? 1), this.a, this.b, this.opacity);
	},
	darker(e) {
		return new _(this.l - s * (e ?? 1), this.a, this.b, this.opacity);
	},
	rgb() {
		var e = (this.l + 16) / 116, t = isNaN(this.a) ? e : e + this.a / 500, n = isNaN(this.b) ? e : e - this.b / 200;
		return t = c * y(t), e = l * y(e), n = u * y(n), new r(b(3.1338561 * t - 1.6168667 * e - .4906146 * n), b(-.9787684 * t + 1.9161415 * e + .033454 * n), b(.0719453 * t - .2289914 * e + 1.4052427 * n), this.opacity);
	}
}));
function v(e) {
	return e > m ? e ** (1 / 3) : e / p + d;
}
function y(e) {
	return e > f ? e * e * e : p * (e - d);
}
function b(e) {
	return 255 * (e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055);
}
function x(e) {
	return (e /= 255) <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
}
function S(e) {
	if (e instanceof w) return new w(e.h, e.c, e.l, e.opacity);
	if (e instanceof _ || (e = h(e)), e.a === 0 && e.b === 0) return new w(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity);
	var t = Math.atan2(e.b, e.a) * a;
	return new w(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity);
}
function C(e, t, n, r) {
	return arguments.length === 1 ? S(e) : new w(e, t, n, r ?? 1);
}
function w(e, t, n, r) {
	this.h = +e, this.c = +t, this.l = +n, this.opacity = +r;
}
function T(e) {
	if (isNaN(e.h)) return new _(e.l, 0, 0, e.opacity);
	var t = e.h * o;
	return new _(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity);
}
e(w, C, t(n, {
	brighter(e) {
		return new w(this.h, this.c, this.l + s * (e ?? 1), this.opacity);
	},
	darker(e) {
		return new w(this.h, this.c, this.l - s * (e ?? 1), this.opacity);
	},
	rgb() {
		return T(this).rgb();
	}
}));
//#endregion
export { g as default, C as hcl };
