import "./math-CxsXa5xk.js";
import { a as e, c as t, d as n, f as r, h as i, i as a, l as o, m as s, n as c, o as l, p as u, r as d, s as f, t as p, u as m } from "./step-CAR_1X2-.js";
import { i as h, r as g, t as ee } from "./src-CiYEh6Gu.js";
import { C as te, D as ne, O as _, T as re, _ as ie, a as ae, c as oe, f as se, g as v, h as y, i as b, m as x, n as ce, o as le, p as ue, r as S, s as de, t as fe, v as pe, w as C, x as me } from "./_baseFor-Cankmnlb.js";
import { I as he, f as ge, m as w, r as _e, s as T } from "./chunk-ICPOFSXX-BGDNDwyb.js";
import { t as ve } from "./dist-6KEP7Sv7.js";
//#region ../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/bundle.js
function E(e, t) {
	this._basis = new m(e), this._beta = t;
}
E.prototype = {
	lineStart: function() {
		this._x = [], this._y = [], this._basis.lineStart();
	},
	lineEnd: function() {
		var e = this._x, t = this._y, n = e.length - 1;
		if (n > 0) for (var r = e[0], i = t[0], a = e[n] - r, o = t[n] - i, s = -1, c; ++s <= n;) c = s / n, this._basis.point(this._beta * e[s] + (1 - this._beta) * (r + c * a), this._beta * t[s] + (1 - this._beta) * (i + c * o));
		this._x = this._y = null, this._basis.lineEnd();
	},
	point: function(e, t) {
		this._x.push(+e), this._y.push(+t);
	}
};
var ye = (function e(t) {
	function n(e) {
		return t === 1 ? new m(e) : new E(e, t);
	}
	return n.beta = function(t) {
		return e(+t);
	}, n;
})(.85);
//#endregion
//#region ../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/cardinal.js
function D(e, t, n) {
	e._context.bezierCurveTo(e._x1 + e._k * (e._x2 - e._x0), e._y1 + e._k * (e._y2 - e._y0), e._x2 + e._k * (e._x1 - t), e._y2 + e._k * (e._y1 - n), e._x2, e._y2);
}
function O(e, t) {
	this._context = e, this._k = (1 - t) / 6;
}
O.prototype = {
	areaStart: function() {
		this._line = 0;
	},
	areaEnd: function() {
		this._line = NaN;
	},
	lineStart: function() {
		this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._point = 0;
	},
	lineEnd: function() {
		switch (this._point) {
			case 2:
				this._context.lineTo(this._x2, this._y2);
				break;
			case 3:
				D(this, this._x1, this._y1);
				break;
		}
		(this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
	},
	point: function(e, t) {
		switch (e = +e, t = +t, this._point) {
			case 0:
				this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
				break;
			case 1:
				this._point = 2, this._x1 = e, this._y1 = t;
				break;
			case 2: this._point = 3;
			default:
				D(this, e, t);
				break;
		}
		this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
	}
};
var be = (function e(t) {
	function n(e) {
		return new O(e, t);
	}
	return n.tension = function(t) {
		return e(+t);
	}, n;
})(0);
//#endregion
//#region ../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/cardinalClosed.js
function k(e, t) {
	this._context = e, this._k = (1 - t) / 6;
}
k.prototype = {
	areaStart: r,
	areaEnd: r,
	lineStart: function() {
		this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._point = 0;
	},
	lineEnd: function() {
		switch (this._point) {
			case 1:
				this._context.moveTo(this._x3, this._y3), this._context.closePath();
				break;
			case 2:
				this._context.lineTo(this._x3, this._y3), this._context.closePath();
				break;
			case 3:
				this.point(this._x3, this._y3), this.point(this._x4, this._y4), this.point(this._x5, this._y5);
				break;
		}
	},
	point: function(e, t) {
		switch (e = +e, t = +t, this._point) {
			case 0:
				this._point = 1, this._x3 = e, this._y3 = t;
				break;
			case 1:
				this._point = 2, this._context.moveTo(this._x4 = e, this._y4 = t);
				break;
			case 2:
				this._point = 3, this._x5 = e, this._y5 = t;
				break;
			default:
				D(this, e, t);
				break;
		}
		this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
	}
};
var xe = (function e(t) {
	function n(e) {
		return new k(e, t);
	}
	return n.tension = function(t) {
		return e(+t);
	}, n;
})(0);
//#endregion
//#region ../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/cardinalOpen.js
function A(e, t) {
	this._context = e, this._k = (1 - t) / 6;
}
A.prototype = {
	areaStart: function() {
		this._line = 0;
	},
	areaEnd: function() {
		this._line = NaN;
	},
	lineStart: function() {
		this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._point = 0;
	},
	lineEnd: function() {
		(this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
	},
	point: function(e, t) {
		switch (e = +e, t = +t, this._point) {
			case 0:
				this._point = 1;
				break;
			case 1:
				this._point = 2;
				break;
			case 2:
				this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
				break;
			case 3: this._point = 4;
			default:
				D(this, e, t);
				break;
		}
		this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
	}
};
var Se = (function e(t) {
	function n(e) {
		return new A(e, t);
	}
	return n.tension = function(t) {
		return e(+t);
	}, n;
})(0);
//#endregion
//#region ../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/catmullRom.js
function j(e, t, n) {
	var r = e._x1, i = e._y1, a = e._x2, o = e._y2;
	if (e._l01_a > 1e-12) {
		var s = 2 * e._l01_2a + 3 * e._l01_a * e._l12_a + e._l12_2a, c = 3 * e._l01_a * (e._l01_a + e._l12_a);
		r = (r * s - e._x0 * e._l12_2a + e._x2 * e._l01_2a) / c, i = (i * s - e._y0 * e._l12_2a + e._y2 * e._l01_2a) / c;
	}
	if (e._l23_a > 1e-12) {
		var l = 2 * e._l23_2a + 3 * e._l23_a * e._l12_a + e._l12_2a, u = 3 * e._l23_a * (e._l23_a + e._l12_a);
		a = (a * l + e._x1 * e._l23_2a - t * e._l12_2a) / u, o = (o * l + e._y1 * e._l23_2a - n * e._l12_2a) / u;
	}
	e._context.bezierCurveTo(r, i, a, o, e._x2, e._y2);
}
function M(e, t) {
	this._context = e, this._alpha = t;
}
M.prototype = {
	areaStart: function() {
		this._line = 0;
	},
	areaEnd: function() {
		this._line = NaN;
	},
	lineStart: function() {
		this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
	},
	lineEnd: function() {
		switch (this._point) {
			case 2:
				this._context.lineTo(this._x2, this._y2);
				break;
			case 3:
				this.point(this._x2, this._y2);
				break;
		}
		(this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
	},
	point: function(e, t) {
		if (e = +e, t = +t, this._point) {
			var n = this._x2 - e, r = this._y2 - t;
			this._l23_a = Math.sqrt(this._l23_2a = (n * n + r * r) ** +this._alpha);
		}
		switch (this._point) {
			case 0:
				this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
				break;
			case 1:
				this._point = 2;
				break;
			case 2: this._point = 3;
			default:
				j(this, e, t);
				break;
		}
		this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
	}
};
var N = (function e(t) {
	function n(e) {
		return t ? new M(e, t) : new O(e, 0);
	}
	return n.alpha = function(t) {
		return e(+t);
	}, n;
})(.5);
//#endregion
//#region ../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/catmullRomClosed.js
function P(e, t) {
	this._context = e, this._alpha = t;
}
P.prototype = {
	areaStart: r,
	areaEnd: r,
	lineStart: function() {
		this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
	},
	lineEnd: function() {
		switch (this._point) {
			case 1:
				this._context.moveTo(this._x3, this._y3), this._context.closePath();
				break;
			case 2:
				this._context.lineTo(this._x3, this._y3), this._context.closePath();
				break;
			case 3:
				this.point(this._x3, this._y3), this.point(this._x4, this._y4), this.point(this._x5, this._y5);
				break;
		}
	},
	point: function(e, t) {
		if (e = +e, t = +t, this._point) {
			var n = this._x2 - e, r = this._y2 - t;
			this._l23_a = Math.sqrt(this._l23_2a = (n * n + r * r) ** +this._alpha);
		}
		switch (this._point) {
			case 0:
				this._point = 1, this._x3 = e, this._y3 = t;
				break;
			case 1:
				this._point = 2, this._context.moveTo(this._x4 = e, this._y4 = t);
				break;
			case 2:
				this._point = 3, this._x5 = e, this._y5 = t;
				break;
			default:
				j(this, e, t);
				break;
		}
		this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
	}
};
var Ce = (function e(t) {
	function n(e) {
		return t ? new P(e, t) : new k(e, 0);
	}
	return n.alpha = function(t) {
		return e(+t);
	}, n;
})(.5);
//#endregion
//#region ../../node_modules/.pnpm/d3-shape@3.2.0/node_modules/d3-shape/src/curve/catmullRomOpen.js
function F(e, t) {
	this._context = e, this._alpha = t;
}
F.prototype = {
	areaStart: function() {
		this._line = 0;
	},
	areaEnd: function() {
		this._line = NaN;
	},
	lineStart: function() {
		this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
	},
	lineEnd: function() {
		(this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
	},
	point: function(e, t) {
		if (e = +e, t = +t, this._point) {
			var n = this._x2 - e, r = this._y2 - t;
			this._l23_a = Math.sqrt(this._l23_2a = (n * n + r * r) ** +this._alpha);
		}
		switch (this._point) {
			case 0:
				this._point = 1;
				break;
			case 1:
				this._point = 2;
				break;
			case 2:
				this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
				break;
			case 3: this._point = 4;
			default:
				j(this, e, t);
				break;
		}
		this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = e, this._y0 = this._y1, this._y1 = this._y2, this._y2 = t;
	}
};
var we = (function e(t) {
	function n(e) {
		return t ? new F(e, t) : new A(e, 0);
	}
	return n.alpha = function(t) {
		return e(+t);
	}, n;
})(.5), I = function() {
	try {
		var e = me(Object, "defineProperty");
		return e({}, "", {}), e;
	} catch {}
}();
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignValue.js
function L(e, t, n) {
	t == "__proto__" && I ? I(e, t, {
		configurable: !0,
		enumerable: !0,
		value: n,
		writable: !0
	}) : e[t] = n;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_assignMergeValue.js
function R(e, t, n) {
	(n !== void 0 && !_(e[t], n) || n === void 0 && !(t in e)) && L(e, t, n);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_cloneBuffer.js
var Te = typeof exports == "object" && exports && !exports.nodeType && exports, Ee = Te && typeof module == "object" && module && !module.nodeType && module, De = Ee && Ee.exports === Te ? ne.Buffer : void 0, Oe = De ? De.allocUnsafe : void 0;
function ke(e, t) {
	if (t) return e.slice();
	var n = e.length, r = Oe ? Oe(n) : new e.constructor(n);
	return e.copy(r), r;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_cloneArrayBuffer.js
function Ae(e) {
	var t = new e.constructor(e.byteLength);
	return new ie(t).set(new ie(e)), t;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_cloneTypedArray.js
function je(e, t) {
	var n = t ? Ae(e.buffer) : e.buffer;
	return new e.constructor(n, e.byteOffset, e.length);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_copyArray.js
function Me(e, t) {
	var n = -1, r = e.length;
	for (t ||= Array(r); ++n < r;) t[n] = e[n];
	return t;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_baseCreate.js
var Ne = Object.create, Pe = function() {
	function e() {}
	return function(t) {
		if (!C(t)) return {};
		if (Ne) return Ne(t);
		e.prototype = t;
		var n = new e();
		return e.prototype = void 0, n;
	};
}(), z = ae(Object.getPrototypeOf, Object);
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_initCloneObject.js
function Fe(e) {
	return typeof e.constructor == "function" && !le(e) ? Pe(z(e)) : {};
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/isArrayLikeObject.js
function Ie(e) {
	return y(e) && b(e);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/isPlainObject.js
var Le = "[object Object]", Re = Function.prototype, ze = Object.prototype, B = Re.toString, Be = ze.hasOwnProperty, Ve = B.call(Object);
function He(e) {
	if (!y(e) || re(e) != Le) return !1;
	var t = z(e);
	if (t === null) return !0;
	var n = Be.call(t, "constructor") && t.constructor;
	return typeof n == "function" && n instanceof n && B.call(n) == Ve;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_safeGet.js
function V(e, t) {
	if (!(t === "constructor" && typeof e[t] == "function") && t != "__proto__") return e[t];
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_assignValue.js
var Ue = Object.prototype.hasOwnProperty;
function We(e, t, n) {
	var r = e[t];
	(!(Ue.call(e, t) && _(r, n)) || n === void 0 && !(t in e)) && L(e, t, n);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_copyObject.js
function Ge(e, t, n, r) {
	var i = !n;
	n ||= {};
	for (var a = -1, o = t.length; ++a < o;) {
		var s = t[a], c = r ? r(n[s], e[s], s, n, e) : void 0;
		c === void 0 && (c = e[s]), i ? L(n, s, c) : We(n, s, c);
	}
	return n;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeysIn.js
function Ke(e) {
	var t = [];
	if (e != null) for (var n in Object(e)) t.push(n);
	return t;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_baseKeysIn.js
var qe = Object.prototype.hasOwnProperty;
function Je(e) {
	if (!C(e)) return Ke(e);
	var t = le(e), n = [];
	for (var r in e) r == "constructor" && (t || !qe.call(e, r)) || n.push(r);
	return n;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/keysIn.js
function H(e) {
	return b(e) ? de(e, !0) : Je(e);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/toPlainObject.js
function Ye(e) {
	return Ge(e, H(e));
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_baseMergeDeep.js
function Xe(e, t, n, r, i, a, o) {
	var s = V(e, n), c = V(t, n), l = o.get(c);
	if (l) {
		R(e, n, l);
		return;
	}
	var u = a ? a(s, c, n + "", e, t, o) : void 0, d = u === void 0;
	if (d) {
		var f = v(c), p = !f && ue(c), m = !f && !p && oe(c);
		u = c, f || p || m ? v(s) ? u = s : Ie(s) ? u = Me(s) : p ? (d = !1, u = ke(c, !0)) : m ? (d = !1, u = je(c, !0)) : u = [] : He(c) || x(c) ? (u = s, x(s) ? u = Ye(s) : (!C(s) || te(s)) && (u = Fe(c))) : d = !1;
	}
	d && (o.set(c, u), i(u, c, r, a, o), o.delete(c)), R(e, n, u);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_baseMerge.js
function Ze(e, t, n, r, i) {
	e !== t && fe(t, function(a, o) {
		if (i ||= new pe(), C(a)) Xe(e, t, o, n, Ze, r, i);
		else {
			var s = r ? r(V(e, o), a, o + "", e, t, i) : void 0;
			s === void 0 && (s = a), R(e, o, s);
		}
	}, H);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_apply.js
function Qe(e, t, n) {
	switch (n.length) {
		case 0: return e.call(t);
		case 1: return e.call(t, n[0]);
		case 2: return e.call(t, n[0], n[1]);
		case 3: return e.call(t, n[0], n[1], n[2]);
	}
	return e.apply(t, n);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_overRest.js
var $e = Math.max;
function et(e, t, n) {
	return t = $e(t === void 0 ? e.length - 1 : t, 0), function() {
		for (var r = arguments, i = -1, a = $e(r.length - t, 0), o = Array(a); ++i < a;) o[i] = r[t + i];
		i = -1;
		for (var s = Array(t + 1); ++i < t;) s[i] = r[i];
		return s[t] = n(o), Qe(e, this, s);
	};
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/constant.js
function tt(e) {
	return function() {
		return e;
	};
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_baseSetToString.js
var nt = I ? function(e, t) {
	return I(e, "toString", {
		configurable: !0,
		enumerable: !1,
		value: tt(t),
		writable: !0
	});
} : ce, rt = 800, it = 16, at = Date.now;
function ot(e) {
	var t = 0, n = 0;
	return function() {
		var r = at(), i = it - (r - n);
		if (n = r, i > 0) {
			if (++t >= rt) return arguments[0];
		} else t = 0;
		return e.apply(void 0, arguments);
	};
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_setToString.js
var st = ot(nt);
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_baseRest.js
function ct(e, t) {
	return st(et(e, t, ce), e + "");
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_isIterateeCall.js
function lt(e, t, n) {
	if (!C(n)) return !1;
	var r = typeof t;
	return (r == "number" ? b(n) && se(t, n.length) : r == "string" && t in n) ? _(n[t], e) : !1;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_createAssigner.js
function ut(e) {
	return ct(function(t, n) {
		var r = -1, i = n.length, a = i > 1 ? n[i - 1] : void 0, o = i > 2 ? n[2] : void 0;
		for (a = e.length > 3 && typeof a == "function" ? (i--, a) : void 0, o && lt(n[0], n[1], o) && (a = i < 3 ? void 0 : a, i = 1), t = Object(t); ++r < i;) {
			var s = n[r];
			s && e(t, s, r, a);
		}
		return t;
	});
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/merge.js
var dt = ut(function(e, t, n) {
	Ze(e, t, n);
}), ft = ve(), pt = {
	curveBasis: n,
	curveBasisClosed: o,
	curveBasisOpen: t,
	curveBumpX: u,
	curveBumpY: s,
	curveBundle: ye,
	curveCardinalClosed: xe,
	curveCardinalOpen: Se,
	curveCardinal: be,
	curveCatmullRomClosed: Ce,
	curveCatmullRomOpen: we,
	curveCatmullRom: N,
	curveLinear: i,
	curveLinearClosed: f,
	curveMonotoneX: e,
	curveMonotoneY: l,
	curveNatural: a,
	curveStep: d,
	curveStepAfter: p,
	curveStepBefore: c
}, mt = /\s*(?:(\w+)(?=:):|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi, ht = /* @__PURE__ */ g(function(e, t) {
	let n = gt(e, /(?:init\b)|(?:initialize\b)/), r = {};
	if (Array.isArray(n)) {
		let e = n.map((e) => e.args);
		he(e), r = _e(r, [...e]);
	} else r = n.args;
	if (!r) return;
	let i = ge(e, t), a = "config";
	return r[a] !== void 0 && (i === "flowchart-v2" && (i = "flowchart"), r[i] = r[a], delete r[a]), r;
}, "detectInit"), gt = /* @__PURE__ */ g(function(e, t = null) {
	try {
		let n = RegExp(`[%]{2}(?![{]${mt.source})(?=[}][%]{2}).*
`, "ig");
		e = e.trim().replace(n, "").replace(/'/gm, "\""), h.debug(`Detecting diagram directive${t === null ? "" : " type:" + t} based on the text:${e}`);
		let r, i = [];
		for (; (r = w.exec(e)) !== null;) if (r.index === w.lastIndex && w.lastIndex++, r && !t || t && r[1]?.match(t) || t && r[2]?.match(t)) {
			let e = r[1] ? r[1] : r[2], t = r[3] ? r[3].trim() : r[4] ? JSON.parse(r[4].trim()) : null;
			i.push({
				type: e,
				args: t
			});
		}
		return i.length === 0 ? {
			type: e,
			args: null
		} : i.length === 1 ? i[0] : i;
	} catch (n) {
		return h.error(`ERROR: ${n.message} - Unable to parse directive type: '${t}' based on the text: '${e}'`), {
			type: void 0,
			args: null
		};
	}
}, "detectDirective"), _t = /* @__PURE__ */ g(function(e) {
	return e.replace(w, "");
}, "removeDirectives"), vt = /* @__PURE__ */ g(function(e, t) {
	for (let [n, r] of t.entries()) if (r.match(e)) return n;
	return -1;
}, "isSubstringInArray");
function U(e, t) {
	return e ? pt[`curve${e.charAt(0).toUpperCase() + e.slice(1)}`] ?? t : t;
}
g(U, "interpolateToCurve");
function yt(e, t) {
	let n = e.trim();
	if (n) return t.securityLevel === "loose" ? n : (0, ft.sanitizeUrl)(n);
}
g(yt, "formatUrl");
var bt = /* @__PURE__ */ g((e, ...t) => {
	let n = e.split("."), r = n.length - 1, i = n[r], a = window;
	for (let t = 0; t < r; t++) if (a = a[n[t]], !a) {
		h.error(`Function name: ${e} not found in window`);
		return;
	}
	a[i](...t);
}, "runFunc");
function W(e, t) {
	return !e || !t ? 0 : Math.sqrt((t.x - e.x) ** 2 + (t.y - e.y) ** 2);
}
g(W, "distance");
function xt(e) {
	let t, n = 0;
	return e.forEach((e) => {
		n += W(e, t), t = e;
	}), G(e, n / 2);
}
g(xt, "traverseEdge");
function St(e) {
	return e.length === 1 ? e[0] : xt(e);
}
g(St, "calcLabelPosition");
var Ct = /* @__PURE__ */ g((e, t = 2) => {
	let n = 10 ** t;
	return Math.round(e * n) / n;
}, "roundNumber"), G = /* @__PURE__ */ g((e, t) => {
	let n, r = t;
	for (let t of e) {
		if (n) {
			let e = W(t, n);
			if (e === 0) return n;
			if (e < r) r -= e;
			else {
				let i = r / e;
				if (i <= 0) return n;
				if (i >= 1) return {
					x: t.x,
					y: t.y
				};
				if (i > 0 && i < 1) return {
					x: Ct((1 - i) * n.x + i * t.x, 5),
					y: Ct((1 - i) * n.y + i * t.y, 5)
				};
			}
		}
		n = t;
	}
	throw Error("Could not find a suitable point for the given distance");
}, "calculatePoint"), wt = /* @__PURE__ */ g((e, t, n) => {
	h.info(`our points ${JSON.stringify(t)}`), t[0] !== n && (t = t.reverse());
	let r = G(t, 25), i = e ? 10 : 5, a = Math.atan2(t[0].y - r.y, t[0].x - r.x), o = {
		x: 0,
		y: 0
	};
	return o.x = Math.sin(a) * i + (t[0].x + r.x) / 2, o.y = -Math.cos(a) * i + (t[0].y + r.y) / 2, o;
}, "calcCardinalityPosition");
function Tt(e, t, n) {
	let r = structuredClone(n);
	h.info("our points", r), t !== "start_left" && t !== "start_right" && r.reverse();
	let i = G(r, 25 + e), a = 10 + e * .5, o = Math.atan2(r[0].y - i.y, r[0].x - i.x), s = {
		x: 0,
		y: 0
	};
	return t === "start_left" ? (s.x = Math.sin(o + Math.PI) * a + (r[0].x + i.x) / 2, s.y = -Math.cos(o + Math.PI) * a + (r[0].y + i.y) / 2) : t === "end_right" ? (s.x = Math.sin(o - Math.PI) * a + (r[0].x + i.x) / 2 - 5, s.y = -Math.cos(o - Math.PI) * a + (r[0].y + i.y) / 2 - 5) : t === "end_left" ? (s.x = Math.sin(o) * a + (r[0].x + i.x) / 2 - 5, s.y = -Math.cos(o) * a + (r[0].y + i.y) / 2 - 5) : (s.x = Math.sin(o) * a + (r[0].x + i.x) / 2, s.y = -Math.cos(o) * a + (r[0].y + i.y) / 2), s;
}
g(Tt, "calcTerminalLabelPosition");
function K(e) {
	let t = "", n = "";
	for (let r of e) r !== void 0 && (r.startsWith("color:") || r.startsWith("text-align:") ? n = n + r + ";" : t = t + r + ";");
	return {
		style: t,
		labelStyle: n
	};
}
g(K, "getStylesFromArray");
var Et = 0, Dt = /* @__PURE__ */ g(() => (Et++, "id-" + Math.random().toString(36).substr(2, 12) + "-" + Et), "generateId");
function Ot(e) {
	let t = "";
	for (let n = 0; n < e; n++) t += "0123456789abcdef".charAt(Math.floor(Math.random() * 16));
	return t;
}
g(Ot, "makeRandomHex");
var kt = /* @__PURE__ */ g((e) => Ot(e.length), "random"), At = /* @__PURE__ */ g(function() {
	return {
		x: 0,
		y: 0,
		fill: void 0,
		anchor: "start",
		style: "#666",
		width: 100,
		height: 100,
		textMargin: 0,
		rx: 0,
		ry: 0,
		valign: void 0,
		text: ""
	};
}, "getTextObj"), jt = /* @__PURE__ */ g(function(e, t) {
	let n = t.text.replace(T.lineBreakRegex, " "), [, r] = Z(t.fontSize), i = e.append("text");
	i.attr("x", t.x), i.attr("y", t.y), i.style("text-anchor", t.anchor), i.style("font-family", t.fontFamily), i.style("font-size", r), i.style("font-weight", t.fontWeight), i.attr("fill", t.fill), t.class !== void 0 && i.attr("class", t.class);
	let a = i.append("tspan");
	return a.attr("x", t.x + t.textMargin * 2), a.attr("fill", t.fill), a.text(n), i;
}, "drawSimpleText"), Mt = S((e, t, n) => {
	if (!e || (n = Object.assign({
		fontSize: 12,
		fontWeight: 400,
		fontFamily: "Arial",
		joinWith: "<br/>"
	}, n), T.lineBreakRegex.test(e))) return e;
	let r = e.split(" ").filter(Boolean), i = [], a = "";
	return r.forEach((e, o) => {
		let s = J(`${e} `, n), c = J(a, n);
		if (s > t) {
			let { hyphenatedStrings: r, remainingWord: o } = Nt(e, t, "-", n);
			i.push(a, ...r), a = o;
		} else c + s >= t ? (i.push(a), a = e) : a = [a, e].filter(Boolean).join(" ");
		o + 1 === r.length && i.push(a);
	}), i.filter((e) => e !== "").join(n.joinWith);
}, (e, t, n) => `${e}${t}${n.fontSize}${n.fontWeight}${n.fontFamily}${n.joinWith}`), Nt = S((e, t, n = "-", r) => {
	r = Object.assign({
		fontSize: 12,
		fontWeight: 400,
		fontFamily: "Arial",
		margin: 0
	}, r);
	let i = [...e], a = [], o = "";
	return i.forEach((e, s) => {
		let c = `${o}${e}`;
		if (J(c, r) >= t) {
			let e = s + 1, t = i.length === e, r = `${c}${n}`;
			a.push(t ? c : r), o = "";
		} else o = c;
	}), {
		hyphenatedStrings: a,
		remainingWord: o
	};
}, (e, t, n = "-", r) => `${e}${t}${n}${r.fontSize}${r.fontWeight}${r.fontFamily}`);
function q(e, t) {
	return Y(e, t).height;
}
g(q, "calculateTextHeight");
function J(e, t) {
	return Y(e, t).width;
}
g(J, "calculateTextWidth");
var Y = S((e, t) => {
	let { fontSize: n = 12, fontFamily: r = "Arial", fontWeight: i = 400 } = t;
	if (!e) return {
		width: 0,
		height: 0
	};
	let [, a] = Z(n), o = ["sans-serif", r], s = e.split(T.lineBreakRegex), c = [], l = ee("body");
	if (!l.remove) return {
		width: 0,
		height: 0,
		lineHeight: 0
	};
	let u = l.append("svg");
	for (let e of o) {
		let t = 0, n = {
			width: 0,
			height: 0,
			lineHeight: 0
		};
		for (let r of s) {
			let o = At();
			o.text = r || "​";
			let s = jt(u, o).style("font-size", a).style("font-weight", i).style("font-family", e), c = (s._groups || s)[0][0].getBBox();
			if (c.width === 0 && c.height === 0) throw Error("svg element not in render tree");
			n.width = Math.round(Math.max(n.width, c.width)), t = Math.round(c.height), n.height += t, n.lineHeight = Math.round(Math.max(n.lineHeight, t));
		}
		c.push(n);
	}
	return u.remove(), c[isNaN(c[1].height) || isNaN(c[1].width) || isNaN(c[1].lineHeight) || c[0].height > c[1].height && c[0].width > c[1].width && c[0].lineHeight > c[1].lineHeight ? 0 : 1];
}, (e, t) => `${e}${t.fontSize}${t.fontWeight}${t.fontFamily}`), Pt = class {
	constructor(e = !1, t) {
		this.count = 0, this.count = t ? t.length : 0, this.next = e ? () => this.count++ : () => Date.now();
	}
	static {
		g(this, "InitIDGenerator");
	}
}, X, Ft = /* @__PURE__ */ g(function(e) {
	return X ||= document.createElement("div"), e = escape(e).replace(/%26/g, "&").replace(/%23/g, "#").replace(/%3B/g, ";"), X.innerHTML = e, unescape(X.textContent);
}, "entityDecode");
function It(e) {
	return "str" in e;
}
g(It, "isDetailedError");
var Lt = /* @__PURE__ */ g((e, t, n, r) => {
	if (!r) return;
	let i = e.node()?.getBBox();
	i && e.append("text").text(r).attr("text-anchor", "middle").attr("x", i.x + i.width / 2).attr("y", -n).attr("class", t);
}, "insertTitle"), Z = /* @__PURE__ */ g((e) => {
	if (typeof e == "number") return [e, e + "px"];
	let t = parseInt(e ?? "", 10);
	return Number.isNaN(t) ? [void 0, void 0] : e === String(t) ? [t, e + "px"] : [t, e];
}, "parseFontSize");
function Q(e, t) {
	return dt({}, e, t);
}
g(Q, "cleanAndMerge");
var Rt = {
	assignWithDepth: _e,
	wrapLabel: Mt,
	calculateTextHeight: q,
	calculateTextWidth: J,
	calculateTextDimensions: Y,
	cleanAndMerge: Q,
	detectInit: ht,
	detectDirective: gt,
	isSubstringInArray: vt,
	interpolateToCurve: U,
	calcLabelPosition: St,
	calcCardinalityPosition: wt,
	calcTerminalLabelPosition: Tt,
	formatUrl: yt,
	getStylesFromArray: K,
	generateId: Dt,
	random: kt,
	runFunc: bt,
	entityDecode: Ft,
	insertTitle: Lt,
	isLabelCoordinateInPath: $,
	parseFontSize: Z,
	InitIDGenerator: Pt
}, zt = /* @__PURE__ */ g(function(e) {
	let t = e;
	return t = t.replace(/style.*:\S*#.*;/g, function(e) {
		return e.substring(0, e.length - 1);
	}), t = t.replace(/classDef.*:\S*#.*;/g, function(e) {
		return e.substring(0, e.length - 1);
	}), t = t.replace(/#\w+;/g, function(e) {
		let t = e.substring(1, e.length - 1);
		return /^\+?\d+$/.test(t) ? "ﬂ°°" + t + "¶ß" : "ﬂ°" + t + "¶ß";
	}), t;
}, "encodeEntities"), Bt = /* @__PURE__ */ g(function(e) {
	return e.replace(/ﬂ°°/g, "&#").replace(/ﬂ°/g, "&").replace(/¶ß/g, ";");
}, "decodeEntities"), Vt = /* @__PURE__ */ g((e, t, { counter: n = 0, prefix: r, suffix: i }, a) => a || `${r ? `${r}_` : ""}${e}_${t}_${n}${i ? `_${i}` : ""}`, "getEdgeId");
function Ht(e) {
	return e ?? null;
}
g(Ht, "handleUndefinedAttr");
function $(e, t) {
	let n = Math.round(e.x), r = Math.round(e.y), i = t.replace(/(\d+\.\d+)/g, (e) => Math.round(parseFloat(e)).toString());
	return i.includes(n.toString()) || i.includes(r.toString());
}
g($, "isLabelCoordinateInPath");
//#endregion
export { je as A, H as C, Fe as D, Ie as E, be as F, ke as M, L as N, z as O, N as P, et as S, We as T, dt as _, zt as a, st as b, K as c, It as d, Z as f, Mt as g, Rt as h, Bt as i, Ae as j, Me as k, Ht as l, _t as m, J as n, Dt as o, kt as p, Q as r, Vt as s, q as t, U as u, lt as v, Ge as w, tt as x, ct as y };
