import { __export as e, __name as t, log as n } from "./chunk-AGHRB4JF.js";
import r from "../../../../khroma/dist/methods/is_dark.js";
import i from "../../../../khroma/dist/methods/lighten.js";
import a from "../../../../khroma/dist/methods/darken.js";
import { clear as o, commonDb_exports as s, getConfig as c, getConfig2 as l, setupGraphViewbox as u } from "./chunk-ICPOFSXX.js";
import d from "../../../../d3-selection/src/select.js";
import f from "../../../../d3-shape/src/arc.js";
import "../../../../d3/src/index.js";
import { selectSvgElement as p } from "./chunk-426QAEUC.js";
import { parseFontSize as m } from "./chunk-5PVQY5BW.js";
//#region ../../node_modules/mermaid/dist/chunks/mermaid.core/timeline-definition-GMOUNBTQ.mjs
var h = (function() {
	var e = /* @__PURE__ */ t(function(e, t, n, r) {
		for (n ||= {}, r = e.length; r--; n[e[r]] = t);
		return n;
	}, "o"), n = [
		6,
		11,
		13,
		14,
		15,
		17,
		19,
		20,
		23,
		24
	], r = [1, 12], i = [1, 13], a = [1, 14], o = [1, 15], s = [1, 16], c = [1, 19], l = [1, 20], u = {
		trace: /* @__PURE__ */ t(function() {}, "trace"),
		yy: {},
		symbols_: {
			error: 2,
			start: 3,
			timeline_header: 4,
			document: 5,
			EOF: 6,
			timeline: 7,
			timeline_lr: 8,
			timeline_td: 9,
			line: 10,
			SPACE: 11,
			statement: 12,
			NEWLINE: 13,
			title: 14,
			acc_title: 15,
			acc_title_value: 16,
			acc_descr: 17,
			acc_descr_value: 18,
			acc_descr_multiline_value: 19,
			section: 20,
			period_statement: 21,
			event_statement: 22,
			period: 23,
			event: 24,
			$accept: 0,
			$end: 1
		},
		terminals_: {
			2: "error",
			6: "EOF",
			7: "timeline",
			8: "timeline_lr",
			9: "timeline_td",
			11: "SPACE",
			13: "NEWLINE",
			14: "title",
			15: "acc_title",
			16: "acc_title_value",
			17: "acc_descr",
			18: "acc_descr_value",
			19: "acc_descr_multiline_value",
			20: "section",
			23: "period",
			24: "event"
		},
		productions_: [
			0,
			[3, 3],
			[4, 1],
			[4, 1],
			[4, 1],
			[5, 0],
			[5, 2],
			[10, 2],
			[10, 1],
			[10, 1],
			[10, 1],
			[12, 1],
			[12, 2],
			[12, 2],
			[12, 1],
			[12, 1],
			[12, 1],
			[12, 1],
			[21, 1],
			[22, 1]
		],
		performAction: /* @__PURE__ */ t(function(e, t, n, r, i, a, o) {
			var s = a.length - 1;
			switch (i) {
				case 1: return a[s - 1];
				case 3:
					r.setDirection("LR");
					break;
				case 4:
					r.setDirection("TD");
					break;
				case 5:
					this.$ = [];
					break;
				case 6:
					a[s - 1].push(a[s]), this.$ = a[s - 1];
					break;
				case 7:
				case 8:
					this.$ = a[s];
					break;
				case 9:
				case 10:
					this.$ = [];
					break;
				case 11:
					r.getCommonDb().setDiagramTitle(a[s].substr(6)), this.$ = a[s].substr(6);
					break;
				case 12:
					this.$ = a[s].trim(), r.getCommonDb().setAccTitle(this.$);
					break;
				case 13:
				case 14:
					this.$ = a[s].trim(), r.getCommonDb().setAccDescription(this.$);
					break;
				case 15:
					r.addSection(a[s].substr(8)), this.$ = a[s].substr(8);
					break;
				case 18:
					r.addTask(a[s], 0, ""), this.$ = a[s];
					break;
				case 19:
					r.addEvent(a[s].substr(2)), this.$ = a[s];
					break;
			}
		}, "anonymous"),
		table: [
			{
				3: 1,
				4: 2,
				7: [1, 3],
				8: [1, 4],
				9: [1, 5]
			},
			{ 1: [3] },
			e(n, [2, 5], { 5: 6 }),
			e(n, [2, 2]),
			e(n, [2, 3]),
			e(n, [2, 4]),
			{
				6: [1, 7],
				10: 8,
				11: [1, 9],
				12: 10,
				13: [1, 11],
				14: r,
				15: i,
				17: a,
				19: o,
				20: s,
				21: 17,
				22: 18,
				23: c,
				24: l
			},
			e(n, [2, 10], { 1: [2, 1] }),
			e(n, [2, 6]),
			{
				12: 21,
				14: r,
				15: i,
				17: a,
				19: o,
				20: s,
				21: 17,
				22: 18,
				23: c,
				24: l
			},
			e(n, [2, 8]),
			e(n, [2, 9]),
			e(n, [2, 11]),
			{ 16: [1, 22] },
			{ 18: [1, 23] },
			e(n, [2, 14]),
			e(n, [2, 15]),
			e(n, [2, 16]),
			e(n, [2, 17]),
			e(n, [2, 18]),
			e(n, [2, 19]),
			e(n, [2, 7]),
			e(n, [2, 12]),
			e(n, [2, 13])
		],
		defaultActions: {},
		parseError: /* @__PURE__ */ t(function(e, t) {
			if (t.recoverable) this.trace(e);
			else {
				var n = Error(e);
				throw n.hash = t, n;
			}
		}, "parseError"),
		parse: /* @__PURE__ */ t(function(e) {
			var n = this, r = [0], i = [], a = [null], o = [], s = this.table, c = "", l = 0, u = 0, d = 0, f = 2, p = 1, m = o.slice.call(arguments, 1), h = Object.create(this.lexer), g = { yy: {} };
			for (var _ in this.yy) Object.prototype.hasOwnProperty.call(this.yy, _) && (g.yy[_] = this.yy[_]);
			h.setInput(e, g.yy), g.yy.lexer = h, g.yy.parser = this, h.yylloc === void 0 && (h.yylloc = {});
			var v = h.yylloc;
			o.push(v);
			var y = h.options && h.options.ranges;
			typeof g.yy.parseError == "function" ? this.parseError = g.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
			function b(e) {
				r.length -= 2 * e, a.length -= e, o.length -= e;
			}
			t(b, "popStack");
			function x() {
				var e = i.pop() || h.lex() || p;
				return typeof e != "number" && (e instanceof Array && (i = e, e = i.pop()), e = n.symbols_[e] || e), e;
			}
			t(x, "lex");
			for (var S, C, w, T, E, D = {}, O, k, A, j;;) {
				if (w = r[r.length - 1], this.defaultActions[w] ? T = this.defaultActions[w] : (S ??= x(), T = s[w] && s[w][S]), T === void 0 || !T.length || !T[0]) {
					var M = "";
					for (O in j = [], s[w]) this.terminals_[O] && O > f && j.push("'" + this.terminals_[O] + "'");
					M = h.showPosition ? "Parse error on line " + (l + 1) + ":\n" + h.showPosition() + "\nExpecting " + j.join(", ") + ", got '" + (this.terminals_[S] || S) + "'" : "Parse error on line " + (l + 1) + ": Unexpected " + (S == p ? "end of input" : "'" + (this.terminals_[S] || S) + "'"), this.parseError(M, {
						text: h.match,
						token: this.terminals_[S] || S,
						line: h.yylineno,
						loc: v,
						expected: j
					});
				}
				if (T[0] instanceof Array && T.length > 1) throw Error("Parse Error: multiple actions possible at state: " + w + ", token: " + S);
				switch (T[0]) {
					case 1:
						r.push(S), a.push(h.yytext), o.push(h.yylloc), r.push(T[1]), S = null, C ? (S = C, C = null) : (u = h.yyleng, c = h.yytext, l = h.yylineno, v = h.yylloc, d > 0 && d--);
						break;
					case 2:
						if (k = this.productions_[T[1]][1], D.$ = a[a.length - k], D._$ = {
							first_line: o[o.length - (k || 1)].first_line,
							last_line: o[o.length - 1].last_line,
							first_column: o[o.length - (k || 1)].first_column,
							last_column: o[o.length - 1].last_column
						}, y && (D._$.range = [o[o.length - (k || 1)].range[0], o[o.length - 1].range[1]]), E = this.performAction.apply(D, [
							c,
							u,
							l,
							g.yy,
							T[1],
							a,
							o
						].concat(m)), E !== void 0) return E;
						k && (r = r.slice(0, -1 * k * 2), a = a.slice(0, -1 * k), o = o.slice(0, -1 * k)), r.push(this.productions_[T[1]][0]), a.push(D.$), o.push(D._$), A = s[r[r.length - 2]][r[r.length - 1]], r.push(A);
						break;
					case 3: return !0;
				}
			}
			return !0;
		}, "parse")
	};
	u.lexer = /* @__PURE__ */ (function() {
		return {
			EOF: 1,
			parseError: /* @__PURE__ */ t(function(e, t) {
				if (this.yy.parser) this.yy.parser.parseError(e, t);
				else throw Error(e);
			}, "parseError"),
			setInput: /* @__PURE__ */ t(function(e, t) {
				return this.yy = t || this.yy || {}, this._input = e, this._more = this._backtrack = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = {
					first_line: 1,
					first_column: 0,
					last_line: 1,
					last_column: 0
				}, this.options.ranges && (this.yylloc.range = [0, 0]), this.offset = 0, this;
			}, "setInput"),
			input: /* @__PURE__ */ t(function() {
				var e = this._input[0];
				return this.yytext += e, this.yyleng++, this.offset++, this.match += e, this.matched += e, e.match(/(?:\r\n?|\n).*/g) ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), e;
			}, "input"),
			unput: /* @__PURE__ */ t(function(e) {
				var t = e.length, n = e.split(/(?:\r\n?|\n)/g);
				this._input = e + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - t), this.offset -= t;
				var r = this.match.split(/(?:\r\n?|\n)/g);
				this.match = this.match.substr(0, this.match.length - 1), this.matched = this.matched.substr(0, this.matched.length - 1), n.length - 1 && (this.yylineno -= n.length - 1);
				var i = this.yylloc.range;
				return this.yylloc = {
					first_line: this.yylloc.first_line,
					last_line: this.yylineno + 1,
					first_column: this.yylloc.first_column,
					last_column: n ? (n.length === r.length ? this.yylloc.first_column : 0) + r[r.length - n.length].length - n[0].length : this.yylloc.first_column - t
				}, this.options.ranges && (this.yylloc.range = [i[0], i[0] + this.yyleng - t]), this.yyleng = this.yytext.length, this;
			}, "unput"),
			more: /* @__PURE__ */ t(function() {
				return this._more = !0, this;
			}, "more"),
			reject: /* @__PURE__ */ t(function() {
				if (this.options.backtrack_lexer) this._backtrack = !0;
				else return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), {
					text: "",
					token: null,
					line: this.yylineno
				});
				return this;
			}, "reject"),
			less: /* @__PURE__ */ t(function(e) {
				this.unput(this.match.slice(e));
			}, "less"),
			pastInput: /* @__PURE__ */ t(function() {
				var e = this.matched.substr(0, this.matched.length - this.match.length);
				return (e.length > 20 ? "..." : "") + e.substr(-20).replace(/\n/g, "");
			}, "pastInput"),
			upcomingInput: /* @__PURE__ */ t(function() {
				var e = this.match;
				return e.length < 20 && (e += this._input.substr(0, 20 - e.length)), (e.substr(0, 20) + (e.length > 20 ? "..." : "")).replace(/\n/g, "");
			}, "upcomingInput"),
			showPosition: /* @__PURE__ */ t(function() {
				var e = this.pastInput(), t = Array(e.length + 1).join("-");
				return e + this.upcomingInput() + "\n" + t + "^";
			}, "showPosition"),
			test_match: /* @__PURE__ */ t(function(e, t) {
				var n, r, i;
				if (this.options.backtrack_lexer && (i = {
					yylineno: this.yylineno,
					yylloc: {
						first_line: this.yylloc.first_line,
						last_line: this.last_line,
						first_column: this.yylloc.first_column,
						last_column: this.yylloc.last_column
					},
					yytext: this.yytext,
					match: this.match,
					matches: this.matches,
					matched: this.matched,
					yyleng: this.yyleng,
					offset: this.offset,
					_more: this._more,
					_input: this._input,
					yy: this.yy,
					conditionStack: this.conditionStack.slice(0),
					done: this.done
				}, this.options.ranges && (i.yylloc.range = this.yylloc.range.slice(0))), r = e[0].match(/(?:\r\n?|\n).*/g), r && (this.yylineno += r.length), this.yylloc = {
					first_line: this.yylloc.last_line,
					last_line: this.yylineno + 1,
					first_column: this.yylloc.last_column,
					last_column: r ? r[r.length - 1].length - r[r.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + e[0].length
				}, this.yytext += e[0], this.match += e[0], this.matches = e, this.yyleng = this.yytext.length, this.options.ranges && (this.yylloc.range = [this.offset, this.offset += this.yyleng]), this._more = !1, this._backtrack = !1, this._input = this._input.slice(e[0].length), this.matched += e[0], n = this.performAction.call(this, this.yy, this, t, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), n) return n;
				if (this._backtrack) {
					for (var a in i) this[a] = i[a];
					return !1;
				}
				return !1;
			}, "test_match"),
			next: /* @__PURE__ */ t(function() {
				if (this.done) return this.EOF;
				this._input || (this.done = !0);
				var e, t, n, r;
				this._more || (this.yytext = "", this.match = "");
				for (var i = this._currentRules(), a = 0; a < i.length; a++) if (n = this._input.match(this.rules[i[a]]), n && (!t || n[0].length > t[0].length)) {
					if (t = n, r = a, this.options.backtrack_lexer) {
						if (e = this.test_match(n, i[a]), e !== !1) return e;
						if (this._backtrack) {
							t = !1;
							continue;
						} else return !1;
					} else if (!this.options.flex) break;
				}
				return t ? (e = this.test_match(t, i[r]), e === !1 ? !1 : e) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
					text: "",
					token: null,
					line: this.yylineno
				});
			}, "next"),
			lex: /* @__PURE__ */ t(function() {
				return this.next() || this.lex();
			}, "lex"),
			begin: /* @__PURE__ */ t(function(e) {
				this.conditionStack.push(e);
			}, "begin"),
			popState: /* @__PURE__ */ t(function() {
				return this.conditionStack.length - 1 > 0 ? this.conditionStack.pop() : this.conditionStack[0];
			}, "popState"),
			_currentRules: /* @__PURE__ */ t(function() {
				return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules;
			}, "_currentRules"),
			topState: /* @__PURE__ */ t(function(e) {
				return e = this.conditionStack.length - 1 - Math.abs(e || 0), e >= 0 ? this.conditionStack[e] : "INITIAL";
			}, "topState"),
			pushState: /* @__PURE__ */ t(function(e) {
				this.begin(e);
			}, "pushState"),
			stateStackSize: /* @__PURE__ */ t(function() {
				return this.conditionStack.length;
			}, "stateStackSize"),
			options: { "case-insensitive": !0 },
			performAction: /* @__PURE__ */ t(function(e, t, n, r) {
				switch (n) {
					case 0: break;
					case 1: break;
					case 2: return 13;
					case 3: break;
					case 4: break;
					case 5: return 8;
					case 6: return 9;
					case 7: return 7;
					case 8: return 14;
					case 9: return this.begin("acc_title"), 15;
					case 10: return this.popState(), "acc_title_value";
					case 11: return this.begin("acc_descr"), 17;
					case 12: return this.popState(), "acc_descr_value";
					case 13:
						this.begin("acc_descr_multiline");
						break;
					case 14:
						this.popState();
						break;
					case 15: return "acc_descr_multiline_value";
					case 16: return 20;
					case 17: return 24;
					case 18: return 23;
					case 19: return 6;
					case 20: return "INVALID";
				}
			}, "anonymous"),
			rules: [
				/^(?:%(?!\{)[^\n]*)/i,
				/^(?:[^\}]%%[^\n]*)/i,
				/^(?:[\n]+)/i,
				/^(?:\s+)/i,
				/^(?:#[^\n]*)/i,
				/^(?:timeline[ \t]+LR\b)/i,
				/^(?:timeline[ \t]+TD\b)/i,
				/^(?:timeline\b)/i,
				/^(?:title\s[^\n]+)/i,
				/^(?:accTitle\s*:\s*)/i,
				/^(?:(?!\n||)*[^\n]*)/i,
				/^(?:accDescr\s*:\s*)/i,
				/^(?:(?!\n||)*[^\n]*)/i,
				/^(?:accDescr\s*\{\s*)/i,
				/^(?:[\}])/i,
				/^(?:[^\}]*)/i,
				/^(?:section\s[^:\n]+)/i,
				/^(?::\s(?:[^:\n]|:(?!\s))+)/i,
				/^(?:[^#:\n]+)/i,
				/^(?:$)/i,
				/^(?:.)/i
			],
			conditions: {
				acc_descr_multiline: {
					rules: [14, 15],
					inclusive: !1
				},
				acc_descr: {
					rules: [12],
					inclusive: !1
				},
				acc_title: {
					rules: [10],
					inclusive: !1
				},
				INITIAL: {
					rules: [
						0,
						1,
						2,
						3,
						4,
						5,
						6,
						7,
						8,
						9,
						11,
						13,
						16,
						17,
						18,
						19,
						20
					],
					inclusive: !0
				}
			}
		};
	})();
	function d() {
		this.yy = {};
	}
	return t(d, "Parser"), d.prototype = u, u.Parser = d, new d();
})();
h.parser = h;
var g = h, _ = {};
e(_, {
	addEvent: () => M,
	addSection: () => O,
	addTask: () => j,
	addTaskOrg: () => N,
	clear: () => T,
	default: () => ee,
	getCommonDb: () => w,
	getDirection: () => D,
	getSections: () => k,
	getTasks: () => A,
	setDirection: () => E
});
var v = "", y = 0, b = "LR", x = [], S = [], C = [], w = /* @__PURE__ */ t(() => s, "getCommonDb"), T = /* @__PURE__ */ t(function() {
	x.length = 0, S.length = 0, v = "", C.length = 0, b = "LR", o();
}, "clear"), E = /* @__PURE__ */ t(function(e) {
	b = e;
}, "setDirection"), D = /* @__PURE__ */ t(function() {
	return b;
}, "getDirection"), O = /* @__PURE__ */ t(function(e) {
	v = e, x.push(e);
}, "addSection"), k = /* @__PURE__ */ t(function() {
	return x;
}, "getSections"), A = /* @__PURE__ */ t(function() {
	let e = P(), t = 0;
	for (; !e && t < 100;) e = P(), t++;
	return S.push(...C), S;
}, "getTasks"), j = /* @__PURE__ */ t(function(e, t, n) {
	let r = {
		id: y++,
		section: v,
		type: v,
		task: e,
		score: t || 0,
		events: n ? [n] : []
	};
	C.push(r);
}, "addTask"), M = /* @__PURE__ */ t(function(e) {
	C.find((e) => e.id === y - 1).events.push(e);
}, "addEvent"), N = /* @__PURE__ */ t(function(e) {
	let t = {
		section: v,
		type: v,
		description: e,
		task: e,
		classes: []
	};
	S.push(t);
}, "addTaskOrg"), P = /* @__PURE__ */ t(function() {
	let e = /* @__PURE__ */ t(function(e) {
		return C[e].processed;
	}, "compileTask"), n = !0;
	for (let [t, r] of C.entries()) e(t), n &&= r.processed;
	return n;
}, "compileTasks"), ee = {
	clear: T,
	getCommonDb: w,
	getDirection: D,
	setDirection: E,
	addSection: O,
	getSections: k,
	getTasks: A,
	addTask: j,
	addTaskOrg: N,
	addEvent: M
}, F = 0, I = /* @__PURE__ */ t(function(e, t) {
	let n = e.append("rect");
	return n.attr("x", t.x), n.attr("y", t.y), n.attr("fill", t.fill), n.attr("stroke", t.stroke), n.attr("width", t.width), n.attr("height", t.height), n.attr("rx", t.rx), n.attr("ry", t.ry), t.class !== void 0 && n.attr("class", t.class), n;
}, "drawRect"), te = /* @__PURE__ */ t(function(e, n) {
	let r = e.append("circle").attr("cx", n.cx).attr("cy", n.cy).attr("class", "face").attr("r", 15).attr("stroke-width", 2).attr("overflow", "visible"), i = e.append("g");
	i.append("circle").attr("cx", n.cx - 15 / 3).attr("cy", n.cy - 15 / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"), i.append("circle").attr("cx", n.cx + 15 / 3).attr("cy", n.cy - 15 / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666");
	function a(e) {
		let t = f().startAngle(Math.PI / 2).endAngle(Math.PI / 2 * 3).innerRadius(15 / 2).outerRadius(15 / 2.2);
		e.append("path").attr("class", "mouth").attr("d", t).attr("transform", "translate(" + n.cx + "," + (n.cy + 2) + ")");
	}
	t(a, "smile");
	function o(e) {
		let t = f().startAngle(3 * Math.PI / 2).endAngle(Math.PI / 2 * 5).innerRadius(15 / 2).outerRadius(15 / 2.2);
		e.append("path").attr("class", "mouth").attr("d", t).attr("transform", "translate(" + n.cx + "," + (n.cy + 7) + ")");
	}
	t(o, "sad");
	function s(e) {
		e.append("line").attr("class", "mouth").attr("stroke", 2).attr("x1", n.cx - 5).attr("y1", n.cy + 7).attr("x2", n.cx + 5).attr("y2", n.cy + 7).attr("class", "mouth").attr("stroke-width", "1px").attr("stroke", "#666");
	}
	return t(s, "ambivalent"), n.score > 3 ? a(i) : n.score < 3 ? o(i) : s(i), r;
}, "drawFace"), ne = /* @__PURE__ */ t(function(e, t) {
	let n = e.append("circle");
	return n.attr("cx", t.cx), n.attr("cy", t.cy), n.attr("class", "actor-" + t.pos), n.attr("fill", t.fill), n.attr("stroke", t.stroke), n.attr("r", t.r), n.class !== void 0 && n.attr("class", n.class), t.title !== void 0 && n.append("title").text(t.title), n;
}, "drawCircle"), L = /* @__PURE__ */ t(function(e, t) {
	let n = t.text.replace(/<br\s*\/?>/gi, " "), r = e.append("text");
	r.attr("x", t.x), r.attr("y", t.y), r.attr("class", "legend"), r.style("text-anchor", t.anchor), t.class !== void 0 && r.attr("class", t.class);
	let i = r.append("tspan");
	return i.attr("x", t.x + t.textMargin * 2), i.text(n), r;
}, "drawText"), re = /* @__PURE__ */ t(function(e, n) {
	function r(e, t, n, r, i) {
		return e + "," + t + " " + (e + n) + "," + t + " " + (e + n) + "," + (t + r - i) + " " + (e + n - i * 1.2) + "," + (t + r) + " " + e + "," + (t + r);
	}
	t(r, "genPoints");
	let i = e.append("polygon");
	i.attr("points", r(n.x, n.y, 50, 20, 7)), i.attr("class", "labelBox"), n.y += n.labelMargin, n.x += .5 * n.labelMargin, L(e, n);
}, "drawLabel"), R = /* @__PURE__ */ t(function(e, t, n) {
	let r = e.append("g"), i = B();
	i.x = t.x, i.y = t.y, i.fill = t.fill, i.width = n.width, i.height = n.height, i.class = "journey-section section-type-" + t.num, i.rx = 3, i.ry = 3, I(r, i), V(n)(t.text, r, i.x, i.y, i.width, i.height, { class: "journey-section section-type-" + t.num }, n, t.colour);
}, "drawSection"), z = -1, ie = /* @__PURE__ */ t(function(e, t, n, r) {
	let i = t.x + n.width / 2, a = e.append("g");
	z++, a.append("line").attr("id", r + "-task" + z).attr("x1", i).attr("y1", t.y).attr("x2", i).attr("y2", 450).attr("class", "task-line").attr("stroke-width", "1px").attr("stroke-dasharray", "4 2").attr("stroke", "#666"), te(a, {
		cx: i,
		cy: 300 + (5 - t.score) * 30,
		score: t.score
	});
	let o = B();
	o.x = t.x, o.y = t.y, o.fill = t.fill, o.width = n.width, o.height = n.height, o.class = "task task-type-" + t.num, o.rx = 3, o.ry = 3, I(a, o), V(n)(t.task, a, o.x, o.y, o.width, o.height, { class: "task" }, n, t.colour);
}, "drawTask"), ae = /* @__PURE__ */ t(function(e, t) {
	I(e, {
		x: t.startx,
		y: t.starty,
		width: t.stopx - t.startx,
		height: t.stopy - t.starty,
		fill: t.fill,
		class: "rect"
	}).lower();
}, "drawBackgroundRect"), oe = /* @__PURE__ */ t(function() {
	return {
		x: 0,
		y: 0,
		fill: void 0,
		"text-anchor": "start",
		width: 100,
		height: 100,
		textMargin: 0,
		rx: 0,
		ry: 0
	};
}, "getTextObj"), B = /* @__PURE__ */ t(function() {
	return {
		x: 0,
		y: 0,
		width: 100,
		anchor: "start",
		height: 100,
		rx: 0,
		ry: 0
	};
}, "getNoteRect"), V = /* @__PURE__ */ (function() {
	function e(e, t, n, r, a, o, s, c) {
		i(t.append("text").attr("x", n + a / 2).attr("y", r + o / 2 + 5).style("font-color", c).style("text-anchor", "middle").text(e), s);
	}
	t(e, "byText");
	function n(e, t, n, r, a, o, s, c, l) {
		let { taskFontSize: u, taskFontFamily: d } = c, f = e.split(/<br\s*\/?>/gi);
		for (let e = 0; e < f.length; e++) {
			let c = e * u - u * (f.length - 1) / 2, p = t.append("text").attr("x", n + a / 2).attr("y", r).attr("fill", l).style("text-anchor", "middle").style("font-size", u).style("font-family", d);
			p.append("tspan").attr("x", n + a / 2).attr("dy", c).text(f[e]), p.attr("y", r + o / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"), i(p, s);
		}
	}
	t(n, "byTspan");
	function r(e, t, r, a, o, s, c, l) {
		let u = t.append("switch"), d = u.append("foreignObject").attr("x", r).attr("y", a).attr("width", o).attr("height", s).attr("position", "fixed").append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
		d.append("div").attr("class", "label").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(e), n(e, u, r, a, o, s, c, l), i(d, c);
	}
	t(r, "byFo");
	function i(e, t) {
		for (let n in t) n in t && e.attr(n, t[n]);
	}
	return t(i, "_setTextAttrs"), function(t) {
		return t.textPlacement === "fo" ? r : t.textPlacement === "old" ? e : n;
	};
})(), se = /* @__PURE__ */ t(function(e, t) {
	F = 0, z = -1, e.append("defs").append("marker").attr("id", t + "-arrowhead").attr("refX", 5).attr("refY", 2).attr("markerWidth", 6).attr("markerHeight", 4).attr("orient", "auto").append("path").attr("d", "M 0,0 V 4 L6,2 Z");
}, "initGraphics");
function H(e, t) {
	e.each(function() {
		var e = d(this), n = e.text().split(/(\s+|<br>)/).reverse(), r, i = [], a = 1.1, o = e.attr("y"), s = parseFloat(e.attr("dy")), c = e.text(null).append("tspan").attr("x", 0).attr("y", o).attr("dy", s + "em");
		for (let s = 0; s < n.length; s++) r = n[n.length - 1 - s], i.push(r), c.text(i.join(" ").trim()), (c.node().getComputedTextLength() > t || r === "<br>") && (i.pop(), c.text(i.join(" ").trim()), i = r === "<br>" ? [""] : [r], c = e.append("tspan").attr("x", 0).attr("y", o).attr("dy", a + "em").text(r));
	});
}
t(H, "wrap");
var ce = /* @__PURE__ */ t(function(e, t, n, r, i, a = !1) {
	let { theme: o, look: s } = r, c = o?.includes("redux"), l = n % (r?.themeVariables?.THEME_COLOR_LIMIT ?? 12) - 1, u = e.append("g");
	t.section = l, u.attr("class", (t.class ? t.class + " " : "") + "timeline-node " + ("section-" + l));
	let f = u.append("g"), p = u.append("g"), m = p.append("text").text(t.descr).attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle").call(H, t.width).node().getBBox(), h = r.fontSize?.replace ? r.fontSize.replace("px", "") : r.fontSize;
	if (t.height = m.height + h * 1.1 * .5 + t.padding, t.height = Math.max(t.height, t.maxHeight), t.width += 2 * t.padding, p.attr("transform", "translate(" + t.width / 2 + ", " + t.padding / 2 + ")"), c && p.attr("transform", `translate(${t.width / 2}, ${a ? t.padding / 2 + 3 : t.padding})`), ue(f, t, l, i, r), s === "neo" && (u.attr("data-look", "neo"), c)) {
		let t = o.includes("dark"), n = d(e.node()?.ownerSVGElement ?? e.node()), r = n.attr("id") ?? "", i = r ? `${r}-drop-shadow` : "drop-shadow";
		if (n.select(`#${i}`).empty()) {
			let e = n.select("defs");
			(e.empty() ? n.append("defs") : e).append("filter").attr("id", i).attr("height", "130%").attr("width", "130%").append("feDropShadow").attr("dx", "4").attr("dy", "4").attr("stdDeviation", 0).attr("flood-opacity", t ? "0.2" : "0.06").attr("flood-color", t ? "#FFFFFF" : "#000000");
		}
	}
	return t;
}, "drawNode"), le = /* @__PURE__ */ t(function(e, t, n) {
	let r = e.append("g"), i = r.append("text").text(t.descr).attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle").call(H, t.width).node().getBBox(), a = n.fontSize?.replace ? n.fontSize.replace("px", "") : n.fontSize;
	return r.remove(), i.height + a * 1.1 * .5 + t.padding;
}, "getVirtualNodeHeight"), ue = /* @__PURE__ */ t(function(e, t, n, r, i) {
	let { theme: a } = i, o = a?.includes("redux") ? 0 : 5, s = o > 0 ? `M0 ${t.height - 5} v${-t.height + 10} q0,-${o},${o},-${o} h${t.width - 10} q${o},0,${o},${o} v${t.height - 5} H0 Z` : `M0 ${t.height - 5} v${-(t.height - 5)} h${t.width} v${t.height} H0 Z`;
	e.append("path").attr("id", r + "-node-" + F++).attr("class", "node-bkg node-" + t.type).attr("d", s), a?.includes("redux") || e.append("line").attr("class", "node-line-" + n).attr("x1", 0).attr("y1", t.height).attr("x2", t.width).attr("y2", t.height);
}, "defaultBkg"), U = {
	drawRect: I,
	drawCircle: ne,
	drawSection: R,
	drawText: L,
	drawLabel: re,
	drawTask: ie,
	drawBackgroundRect: ae,
	getTextObj: oe,
	getNoteRect: B,
	initGraphics: se,
	drawNode: ce,
	getVirtualNodeHeight: le
}, de = /* @__PURE__ */ t(function(e, t, r, i) {
	let a = l(), { look: o, theme: s, themeVariables: c } = a, { useGradient: f, gradientStart: p, gradientStop: m } = c, h = a.timeline?.leftMargin ?? 50;
	n.debug("timeline", i.db);
	let g = a.securityLevel, _;
	g === "sandbox" && (_ = d("#i" + t));
	let v = d(g === "sandbox" ? _.nodes()[0].contentDocument.body : "body").select("#" + t);
	v.append("g");
	let y = i.db.getTasks(), b = i.db.getCommonDb().getDiagramTitle();
	n.debug("task", y), U.initGraphics(v, t);
	let x = i.db.getSections();
	n.debug("sections", x);
	let S = 0, C = 0, w = 0, T = 0, E = 50 + h, D = 50;
	T = 50;
	let O = 0, k = !0;
	x.forEach(function(e) {
		let t = {
			number: O,
			descr: e,
			section: O,
			width: 150,
			padding: 20,
			maxHeight: S
		}, r = U.getVirtualNodeHeight(v, t, a);
		n.debug("sectionHeight before draw", r), S = Math.max(S, r + 20);
	});
	let A = 0, j = 0;
	n.debug("tasks.length", y.length);
	for (let [e, t] of y.entries()) {
		let r = {
			number: e,
			descr: t,
			section: t.section,
			width: 150,
			padding: 20,
			maxHeight: C
		}, i = U.getVirtualNodeHeight(v, r, a);
		n.debug("taskHeight before draw", i), C = Math.max(C, i + 20), A = Math.max(A, t.events.length);
		let o = 0;
		for (let e of t.events) {
			let n = {
				descr: e,
				section: t.section,
				number: t.section,
				width: 150,
				padding: 20,
				maxHeight: 50
			};
			o += U.getVirtualNodeHeight(v, n, a);
		}
		t.events.length > 0 && (o += (t.events.length - 1) * 10), j = Math.max(j, o);
	}
	n.debug("maxSectionHeight before draw", S), n.debug("maxTaskHeight before draw", C), x && x.length > 0 ? x.forEach((e) => {
		let r = y.filter((t) => t.section === e), i = {
			number: O,
			descr: e,
			section: O,
			width: 200 * Math.max(r.length, 1) - 50,
			padding: 20,
			maxHeight: S
		};
		n.debug("sectionNode", i);
		let o = v.append("g"), s = U.drawNode(o, i, O, a, t);
		n.debug("sectionNode output", s), o.attr("transform", `translate(${E}, ${T})`), D += S + 50, r.length > 0 && W(v, r, O, E, D, C, a, A, j, S, !1, t), E += 200 * Math.max(r.length, 1), D = T, O++;
	}) : (k = !1, W(v, y, O, E, D, C, a, A, j, S, !0, t));
	let M = v.node().getBBox();
	if (n.debug("bounds", M), b && v.append("text").text(b).attr("x", o === "neo" ? M.x * 2 + h : M.width / 2 - h).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 20), w = k ? S + C + 150 : C + 100, v.append("g").attr("class", "lineWrapper").append("line").attr("x1", h).attr("y1", w).attr("x2", M.width + 3 * h).attr("y2", w).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", `url(#${t}-arrowhead)`), o === "neo" && f && s !== "neutral") {
		let e = v.select("defs"), t = (e.empty() ? v.append("defs") : e).append("linearGradient").attr("id", v.attr("id") + "-gradient").attr("gradientUnits", "objectBoundingBox").attr("x1", "0%").attr("y1", "0%").attr("x2", "100%").attr("y2", "0%");
		t.append("stop").attr("offset", "0%").attr("stop-color", p).attr("stop-opacity", 1), t.append("stop").attr("offset", "100%").attr("stop-color", m).attr("stop-opacity", 1);
	}
	u(void 0, v, a.timeline?.padding ?? 50, a.timeline?.useMaxWidth ?? !1);
}, "draw"), W = /* @__PURE__ */ t(function(e, t, r, i, a, o, s, c, l, u, d, f) {
	for (let c of t) {
		let t = {
			descr: c.task,
			section: r,
			number: r,
			width: 150,
			padding: 20,
			maxHeight: o
		};
		n.debug("taskNode", t);
		let u = e.append("g").attr("class", "taskWrapper"), p = U.drawNode(u, t, r, s, f).height;
		if (n.debug("taskHeight after draw", p), u.attr("transform", `translate(${i}, ${a})`), o = Math.max(o, p), c.events) {
			let t = e.append("g").attr("class", "lineWrapper"), n = o;
			a += 100, n += fe(e, c.events, r, i, a, s, f), a -= 100, t.append("line").attr("x1", i + 190 / 2).attr("y1", a + o).attr("x2", i + 190 / 2).attr("y2", a + o + 100 + l + 100).attr("stroke-width", 2).attr("stroke", "black").attr("marker-end", `url(#${f}-arrowhead)`).attr("stroke-dasharray", "5,5");
		}
		i += 200, d && !s.timeline?.disableMulticolor && r++;
	}
	a -= 10;
}, "drawTasks"), fe = /* @__PURE__ */ t(function(e, t, r, i, a, o, s) {
	let c = 0, l = a;
	a += 100;
	for (let l of t) {
		let t = {
			descr: l,
			section: r,
			number: r,
			width: 150,
			padding: 20,
			maxHeight: 50
		};
		n.debug("eventNode", t);
		let u = e.append("g").attr("class", "eventWrapper"), d = U.drawNode(u, t, r, o, s, !0).height;
		c += d, u.attr("transform", `translate(${i}, ${a})`), a = a + 10 + d;
	}
	return a = l, c;
}, "drawEvents"), pe = {
	setConf: /* @__PURE__ */ t(() => {}, "setConf"),
	draw: de
}, G = 200, K = 5, me = G + K * 2, q = G + 100, he = q + K * 2, J = 10, ge = 0, Y = 20, X = 20, Z = 30, Q = 50, _e = /* @__PURE__ */ t(function(e, t, r, i) {
	let a = l(), o = a.timeline?.leftMargin ?? 50;
	n.debug("timeline", i.db);
	let s = p(t);
	s.append("g");
	let c = i.db.getTasks(), d = i.db.getCommonDb().getDiagramTitle();
	n.debug("task", c), U.initGraphics(s);
	let f = i.db.getSections();
	n.debug("sections", f);
	let h = 0, g = 0, _ = 50 + o, v = 50, y = v, b = _, x = me + X, S = he + Q, C = b + x, w = 0, T = f && f.length > 0, E = T ? C : _ + x, D = Math.max(50, x + S - K * 2);
	f.forEach(function(e) {
		let t = {
			number: w,
			descr: e,
			section: w,
			width: D,
			padding: K,
			maxHeight: h
		}, r = U.getVirtualNodeHeight(s, t, a);
		n.debug("sectionHeight before draw", r), h = Math.max(h, r);
	});
	let O = 0;
	n.debug("tasks.length", c.length);
	for (let [e, t] of c.entries()) {
		let r = {
			number: e,
			descr: t,
			section: t.section,
			width: G,
			padding: K,
			maxHeight: g
		}, i = U.getVirtualNodeHeight(s, r, a);
		n.debug("taskHeight before draw", i), g = Math.max(g, i);
		let o = 0;
		for (let e of t.events) {
			let n = {
				descr: e,
				section: t.section,
				number: t.section,
				width: q,
				padding: K,
				maxHeight: 50
			};
			o += U.getVirtualNodeHeight(s, n, a);
		}
		t.events.length > 0 && (o += (t.events.length - 1) * J), O = Math.max(O, o) + ge;
	}
	n.debug("maxSectionHeight before draw", h), n.debug("maxTaskHeight before draw", g);
	let k = Math.max(g, O) + Z;
	T ? f.forEach((e) => {
		let t = c.filter((t) => t.section === e), r = {
			number: w,
			descr: e,
			section: w,
			width: D,
			padding: K,
			maxHeight: h
		};
		n.debug("sectionNode", r);
		let i = s.append("g"), o = U.drawNode(i, r, w, a);
		n.debug("sectionNode output", o);
		let l = E - x;
		i.attr("transform", `translate(${l}, ${v})`);
		let u = v + o.height + Y;
		t.length > 0 && $(s, t, w, E, u, g, a, k, !1);
		let d = t.length, f = o.height + Y + k * Math.max(d, 1) - (d > 0 ? Z * 2 : 0);
		v += f, w++;
	}) : $(s, c, w, E, v, g, a, k, !0);
	let A = s.node()?.getBBox();
	if (!A) throw Error("bbox not found");
	if (n.debug("bounds", A), d) {
		if (s.append("text").text(d).attr("x", A.width / 2 - o).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 20), A = s.node()?.getBBox(), !A) throw Error("bbox not found");
		n.debug("bounds after title", A);
	}
	let [j] = m(a.fontSize), M = (j ?? 16) * 2, N = (j ?? 16) * .5 + 20, P = s.append("g").attr("class", "lineWrapper");
	P.append("line").attr("x1", E).attr("y1", y - M).attr("x2", E).attr("y2", A.y + A.height + N).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", "url(#arrowhead)"), P.lower(), u(void 0, s, a.timeline?.padding ?? 50, a.timeline?.useMaxWidth ?? !1);
}, "draw"), $ = /* @__PURE__ */ t(function(e, t, r, i, a, o, s, c, l) {
	for (let u of t) {
		let t = {
			descr: u.task,
			section: r,
			number: r,
			width: G,
			padding: K,
			maxHeight: o
		};
		n.debug("taskNode", t);
		let d = e.append("g").attr("class", "taskWrapper"), f = U.drawNode(d, t, r, s), p = f.height;
		n.debug("taskHeight after draw", p);
		let m = i - X - f.width;
		if (d.attr("transform", `translate(${m}, ${a})`), o = Math.max(o, p), u.events && u.events.length > 0) {
			let t = a, n = i + Q;
			ve(e, u.events, r, i, n, t, s);
		}
		a += c, l && !s.timeline?.disableMulticolor && r++;
	}
}, "drawTasks"), ve = /* @__PURE__ */ t(function(e, t, r, i, a, o, s) {
	let c = o;
	for (let o of t) {
		let t = {
			descr: o,
			section: r,
			number: r,
			width: q,
			padding: K,
			maxHeight: 0
		};
		n.debug("eventNode", t);
		let l = e.append("g").attr("class", "eventWrapper"), u = U.drawNode(l, t, r, s).height;
		l.attr("transform", `translate(${a}, ${c})`);
		let d = e.append("g").attr("class", "lineWrapper"), f = c + u / 2;
		d.append("line").attr("x1", i).attr("y1", f).attr("x2", a).attr("y2", f).attr("stroke-width", 2).attr("stroke", "black").attr("marker-end", "url(#arrowhead)").attr("stroke-dasharray", "5,5"), c = c + u + J;
	}
	return c - o;
}, "drawEvents"), ye = {
	setConf: /* @__PURE__ */ t(() => {}, "setConf"),
	draw: _e
}, be = /* @__PURE__ */ t((e) => {
	let { theme: t } = c(), n = t?.includes("dark"), r = t?.includes("color"), i = e.svgId?.replace(/^#/, "") ?? "", a = i ? `url(#${i}-drop-shadow)` : e.dropShadow ?? "none", o = "";
	for (let t = 0; t < e.THEME_COLOR_LIMIT; t++) {
		let i = `${17 - 3 * t}`, s = r ? e.borderColorArray[t] : e.mainBkg, c = r ? e.borderColorArray[t] : e.nodeBorder;
		o += `
    .section-${t - 1} rect,
    .section-${t - 1} path,
    .section-${t - 1} circle {
      fill: ${n && r ? e.mainBkg : s};
      stroke: ${c};
      stroke-width: ${e.strokeWidth};
      filter: ${a};
    }

    .section-${t - 1} text {
      fill: ${e.nodeBorder};
      font-weight: ${e.fontWeight}
    }

    .node-icon-${t - 1} {
      font-size: 40px;
      color: ${e["cScaleLabel" + t]};
    }

    .section-edge-${t - 1} {
      stroke: ${e["cScale" + t]};
    }

    .edge-depth-${t - 1} {
      stroke-width: ${i};
    }

    .section-${t - 1} line {
      stroke: ${e["cScaleInv" + t]};
      stroke-width: 3;
    }

    .lineWrapper line {
      stroke: ${e.nodeBorder};
      stroke-width:${e.strokeWidth}
    }

    .disabled,
    .disabled circle,
    .disabled text {
      fill: ${e.tertiaryColor ?? "lightgray"};
    }

    .disabled text {
      fill: ${e.clusterBorder ?? "#efefef"};
    }
    `;
	}
	return o;
}, "genReduxSections"), xe = /* @__PURE__ */ t((e) => {
	let t = "";
	for (let t = 0; t < e.THEME_COLOR_LIMIT; t++) e["lineColor" + t] = e["lineColor" + t] || e["cScaleInv" + t], r(e["lineColor" + t]) ? e["lineColor" + t] = i(e["lineColor" + t], 20) : e["lineColor" + t] = a(e["lineColor" + t], 20);
	for (let n = 0; n < e.THEME_COLOR_LIMIT; n++) {
		let r = "" + (17 - 3 * n);
		t += `
    .section-${n - 1} rect, .section-${n - 1} path, .section-${n - 1} circle, .section-${n - 1} path  {
      fill: ${e["cScale" + n]};
    }
    .section-${n - 1} text {
     fill: ${e["cScaleLabel" + n]};
    }
    .node-icon-${n - 1} {
      font-size: 40px;
      color: ${e["cScaleLabel" + n]};
    }
    .section-edge-${n - 1}{
      stroke: ${e["cScale" + n]};
    }
    .edge-depth-${n - 1}{
      stroke-width: ${r};
    }
    .section-${n - 1} line {
      stroke: ${e["cScaleInv" + n]} ;
      stroke-width: 3;
    }

    .lineWrapper line{
      stroke: ${e["cScaleLabel" + n]} ;
    }

    .disabled, .disabled circle, .disabled text {
      fill: ${e.tertiaryColor ?? "lightgray"};
    }
    .disabled text {
      fill: ${e.clusterBorder ?? "#efefef"};
    }
    `;
	}
	return t;
}, "genSections"), Se = {
	db: _,
	renderer: {
		setConf: /* @__PURE__ */ t(() => {}, "setConf"),
		draw: /* @__PURE__ */ t((e, t, n, r) => (r?.db?.getDirection?.() ?? "LR") === "TD" ? ye.draw(e, t, n, r) : pe.draw(e, t, n, r), "draw")
	},
	parser: g,
	styles: /* @__PURE__ */ t((e) => {
		let { theme: t } = c(), n = t?.includes("redux"), r = t === "neutral", i = e.svgId?.replace(/^#/, "") ?? "", a = "";
		if (e.useGradient && i && e.THEME_COLOR_LIMIT && !r) for (let t = 0; t < e.THEME_COLOR_LIMIT; t++) a += `
      .section-${t - 1}[data-look="neo"] rect,
      .section-${t - 1}[data-look="neo"] path,
      .section-${t - 1}[data-look="neo"] circle {
        fill: ${e.mainBkg};
        stroke: url(#${i}-gradient);
        stroke-width: 2;
      }
      .section-${t - 1}[data-look="neo"] line {
        stroke: url(#${i}-gradient);
        stroke-width: 2;
      }`;
		return `
  .edge {
    stroke-width: 3;
  }
  ${n ? be(e) : xe(e)}
  ${a}
  .section-root rect, .section-root path, .section-root circle  {
    fill: ${e.git0};
  }
  .section-root text {
    fill: ${e.gitBranchLabel0};
  }
  .icon-container {
    height:100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .edge {
    fill: none;
  }
  .eventWrapper  {
   filter: brightness(120%);
  }
`;
	}, "getStyles")
};
//#endregion
export { Se as diagram };
