import e, { extend as t } from "./define.js";
//#region ../../node_modules/d3-color/src/color.js
function n() {}
var r = .7, i = 1 / r, a = "\\s*([+-]?\\d+)\\s*", o = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", s = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", c = /^#([0-9a-f]{3,8})$/, l = RegExp(`^rgb\\(${a},${a},${a}\\)$`), u = RegExp(`^rgb\\(${s},${s},${s}\\)$`), d = RegExp(`^rgba\\(${a},${a},${a},${o}\\)$`), f = RegExp(`^rgba\\(${s},${s},${s},${o}\\)$`), p = RegExp(`^hsl\\(${o},${s},${s}\\)$`), m = RegExp(`^hsla\\(${o},${s},${s},${o}\\)$`), h = {
	aliceblue: 15792383,
	antiquewhite: 16444375,
	aqua: 65535,
	aquamarine: 8388564,
	azure: 15794175,
	beige: 16119260,
	bisque: 16770244,
	black: 0,
	blanchedalmond: 16772045,
	blue: 255,
	blueviolet: 9055202,
	brown: 10824234,
	burlywood: 14596231,
	cadetblue: 6266528,
	chartreuse: 8388352,
	chocolate: 13789470,
	coral: 16744272,
	cornflowerblue: 6591981,
	cornsilk: 16775388,
	crimson: 14423100,
	cyan: 65535,
	darkblue: 139,
	darkcyan: 35723,
	darkgoldenrod: 12092939,
	darkgray: 11119017,
	darkgreen: 25600,
	darkgrey: 11119017,
	darkkhaki: 12433259,
	darkmagenta: 9109643,
	darkolivegreen: 5597999,
	darkorange: 16747520,
	darkorchid: 10040012,
	darkred: 9109504,
	darksalmon: 15308410,
	darkseagreen: 9419919,
	darkslateblue: 4734347,
	darkslategray: 3100495,
	darkslategrey: 3100495,
	darkturquoise: 52945,
	darkviolet: 9699539,
	deeppink: 16716947,
	deepskyblue: 49151,
	dimgray: 6908265,
	dimgrey: 6908265,
	dodgerblue: 2003199,
	firebrick: 11674146,
	floralwhite: 16775920,
	forestgreen: 2263842,
	fuchsia: 16711935,
	gainsboro: 14474460,
	ghostwhite: 16316671,
	gold: 16766720,
	goldenrod: 14329120,
	gray: 8421504,
	green: 32768,
	greenyellow: 11403055,
	grey: 8421504,
	honeydew: 15794160,
	hotpink: 16738740,
	indianred: 13458524,
	indigo: 4915330,
	ivory: 16777200,
	khaki: 15787660,
	lavender: 15132410,
	lavenderblush: 16773365,
	lawngreen: 8190976,
	lemonchiffon: 16775885,
	lightblue: 11393254,
	lightcoral: 15761536,
	lightcyan: 14745599,
	lightgoldenrodyellow: 16448210,
	lightgray: 13882323,
	lightgreen: 9498256,
	lightgrey: 13882323,
	lightpink: 16758465,
	lightsalmon: 16752762,
	lightseagreen: 2142890,
	lightskyblue: 8900346,
	lightslategray: 7833753,
	lightslategrey: 7833753,
	lightsteelblue: 11584734,
	lightyellow: 16777184,
	lime: 65280,
	limegreen: 3329330,
	linen: 16445670,
	magenta: 16711935,
	maroon: 8388608,
	mediumaquamarine: 6737322,
	mediumblue: 205,
	mediumorchid: 12211667,
	mediumpurple: 9662683,
	mediumseagreen: 3978097,
	mediumslateblue: 8087790,
	mediumspringgreen: 64154,
	mediumturquoise: 4772300,
	mediumvioletred: 13047173,
	midnightblue: 1644912,
	mintcream: 16121850,
	mistyrose: 16770273,
	moccasin: 16770229,
	navajowhite: 16768685,
	navy: 128,
	oldlace: 16643558,
	olive: 8421376,
	olivedrab: 7048739,
	orange: 16753920,
	orangered: 16729344,
	orchid: 14315734,
	palegoldenrod: 15657130,
	palegreen: 10025880,
	paleturquoise: 11529966,
	palevioletred: 14381203,
	papayawhip: 16773077,
	peachpuff: 16767673,
	peru: 13468991,
	pink: 16761035,
	plum: 14524637,
	powderblue: 11591910,
	purple: 8388736,
	rebeccapurple: 6697881,
	red: 16711680,
	rosybrown: 12357519,
	royalblue: 4286945,
	saddlebrown: 9127187,
	salmon: 16416882,
	sandybrown: 16032864,
	seagreen: 3050327,
	seashell: 16774638,
	sienna: 10506797,
	silver: 12632256,
	skyblue: 8900331,
	slateblue: 6970061,
	slategray: 7372944,
	slategrey: 7372944,
	snow: 16775930,
	springgreen: 65407,
	steelblue: 4620980,
	tan: 13808780,
	teal: 32896,
	thistle: 14204888,
	tomato: 16737095,
	turquoise: 4251856,
	violet: 15631086,
	wheat: 16113331,
	white: 16777215,
	whitesmoke: 16119285,
	yellow: 16776960,
	yellowgreen: 10145074
};
e(n, b, {
	copy(e) {
		return Object.assign(new this.constructor(), this, e);
	},
	displayable() {
		return this.rgb().displayable();
	},
	hex: g,
	formatHex: g,
	formatHex8: _,
	formatHsl: v,
	formatRgb: y,
	toString: y
});
function g() {
	return this.rgb().formatHex();
}
function _() {
	return this.rgb().formatHex8();
}
function v() {
	return N(this).formatHsl();
}
function y() {
	return this.rgb().formatRgb();
}
function b(e) {
	var t, n;
	return e = (e + "").trim().toLowerCase(), (t = c.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), n === 6 ? x(t) : n === 3 ? new T(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : n === 8 ? S(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : n === 4 ? S(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, ((t & 15) << 4 | t & 15) / 255) : null) : (t = l.exec(e)) ? new T(t[1], t[2], t[3], 1) : (t = u.exec(e)) ? new T(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = d.exec(e)) ? S(t[1], t[2], t[3], t[4]) : (t = f.exec(e)) ? S(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = p.exec(e)) ? M(t[1], t[2] / 100, t[3] / 100, 1) : (t = m.exec(e)) ? M(t[1], t[2] / 100, t[3] / 100, t[4]) : h.hasOwnProperty(e) ? x(h[e]) : e === "transparent" ? new T(NaN, NaN, NaN, 0) : null;
}
function x(e) {
	return new T(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
}
function S(e, t, n, r) {
	return r <= 0 && (e = t = n = NaN), new T(e, t, n, r);
}
function C(e) {
	return e instanceof n || (e = b(e)), e ? (e = e.rgb(), new T(e.r, e.g, e.b, e.opacity)) : new T();
}
function w(e, t, n, r) {
	return arguments.length === 1 ? C(e) : new T(e, t, n, r ?? 1);
}
function T(e, t, n, r) {
	this.r = +e, this.g = +t, this.b = +n, this.opacity = +r;
}
e(T, w, t(n, {
	brighter(e) {
		return e = e == null ? i : i ** +e, new T(this.r * e, this.g * e, this.b * e, this.opacity);
	},
	darker(e) {
		return e = e == null ? r : r ** +e, new T(this.r * e, this.g * e, this.b * e, this.opacity);
	},
	rgb() {
		return this;
	},
	clamp() {
		return new T(A(this.r), A(this.g), A(this.b), k(this.opacity));
	},
	displayable() {
		return -.5 <= this.r && this.r < 255.5 && -.5 <= this.g && this.g < 255.5 && -.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
	},
	hex: E,
	formatHex: E,
	formatHex8: D,
	formatRgb: O,
	toString: O
}));
function E() {
	return `#${j(this.r)}${j(this.g)}${j(this.b)}`;
}
function D() {
	return `#${j(this.r)}${j(this.g)}${j(this.b)}${j((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function O() {
	let e = k(this.opacity);
	return `${e === 1 ? "rgb(" : "rgba("}${A(this.r)}, ${A(this.g)}, ${A(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function k(e) {
	return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
}
function A(e) {
	return Math.max(0, Math.min(255, Math.round(e) || 0));
}
function j(e) {
	return e = A(e), (e < 16 ? "0" : "") + e.toString(16);
}
function M(e, t, n, r) {
	return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new F(e, t, n, r);
}
function N(e) {
	if (e instanceof F) return new F(e.h, e.s, e.l, e.opacity);
	if (e instanceof n || (e = b(e)), !e) return new F();
	if (e instanceof F) return e;
	e = e.rgb();
	var t = e.r / 255, r = e.g / 255, i = e.b / 255, a = Math.min(t, r, i), o = Math.max(t, r, i), s = NaN, c = o - a, l = (o + a) / 2;
	return c ? (s = t === o ? (r - i) / c + (r < i) * 6 : r === o ? (i - t) / c + 2 : (t - r) / c + 4, c /= l < .5 ? o + a : 2 - o - a, s *= 60) : c = l > 0 && l < 1 ? 0 : s, new F(s, c, l, e.opacity);
}
function P(e, t, n, r) {
	return arguments.length === 1 ? N(e) : new F(e, t, n, r ?? 1);
}
function F(e, t, n, r) {
	this.h = +e, this.s = +t, this.l = +n, this.opacity = +r;
}
e(F, P, t(n, {
	brighter(e) {
		return e = e == null ? i : i ** +e, new F(this.h, this.s, this.l * e, this.opacity);
	},
	darker(e) {
		return e = e == null ? r : r ** +e, new F(this.h, this.s, this.l * e, this.opacity);
	},
	rgb() {
		var e = this.h % 360 + (this.h < 0) * 360, t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < .5 ? n : 1 - n) * t, i = 2 * n - r;
		return new T(R(e >= 240 ? e - 240 : e + 120, i, r), R(e, i, r), R(e < 120 ? e + 240 : e - 120, i, r), this.opacity);
	},
	clamp() {
		return new F(I(this.h), L(this.s), L(this.l), k(this.opacity));
	},
	displayable() {
		return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
	},
	formatHsl() {
		let e = k(this.opacity);
		return `${e === 1 ? "hsl(" : "hsla("}${I(this.h)}, ${L(this.s) * 100}%, ${L(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
	}
}));
function I(e) {
	return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function L(e) {
	return Math.max(0, Math.min(1, e || 0));
}
function R(e, t, n) {
	return (e < 60 ? t + (n - t) * e / 60 : e < 180 ? n : e < 240 ? t + (n - t) * (240 - e) / 60 : t) * 255;
}
//#endregion
export { n as Color, T as Rgb, b as default, P as hsl, w as rgb, C as rgbConvert };
