import e from "../utils/index.js";
import t from "../channels/reusable.js";
//#region ../../node_modules/khroma/dist/color/rgb.js
var n = {
	re: /^rgba?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?)))?\s*?\)$/i,
	parse: (r) => {
		let i = r.charCodeAt(0);
		if (i !== 114 && i !== 82) return;
		let a = r.match(n.re);
		if (!a) return;
		let [, o, s, c, l, u, d, f, p] = a;
		return t.set({
			r: e.channel.clamp.r(s ? parseFloat(o) * 2.55 : parseFloat(o)),
			g: e.channel.clamp.g(l ? parseFloat(c) * 2.55 : parseFloat(c)),
			b: e.channel.clamp.b(d ? parseFloat(u) * 2.55 : parseFloat(u)),
			a: f ? e.channel.clamp.a(p ? parseFloat(f) / 100 : parseFloat(f)) : 1
		}, r);
	},
	stringify: (t) => {
		let { r: n, g: r, b: i, a } = t;
		return a < 1 ? `rgba(${e.lang.round(n)}, ${e.lang.round(r)}, ${e.lang.round(i)}, ${e.lang.round(a)})` : `rgb(${e.lang.round(n)}, ${e.lang.round(r)}, ${e.lang.round(i)})`;
	}
};
//#endregion
export { n as default };
