import { __name as e } from "./chunk-AGHRB4JF.js";
import t from "../../../../khroma/dist/methods/is_dark.js";
import n from "../../../../khroma/dist/methods/lighten.js";
import r from "../../../../khroma/dist/methods/darken.js";
import i from "../../../../khroma/dist/methods/transparentize.js";
import { clear as a, configureSvgSize as o, defaultConfig_default as s, getAccDescription as c, getAccTitle as l, getConfig as u, getDiagramTitle as d, setAccDescription as f, setAccTitle as p, setDiagramTitle as m } from "./chunk-ICPOFSXX.js";
import h from "../../../../d3-selection/src/select.js";
import "../../../../d3/src/index.js";
import { selectSvgElement as g } from "./chunk-426QAEUC.js";
import { cleanAndMerge as _ } from "./chunk-5PVQY5BW.js";
import { at as v } from "../../../../roughjs/bundled/rough.esm.js";
import { VennDiagram as y, layout as b } from "../../../../@upsetjs/venn.js/build/venn.esm.js";
//#region ../../node_modules/mermaid/dist/chunks/mermaid.core/vennDiagram-DHZGUBPP.mjs
var x = (function() {
	var t = /* @__PURE__ */ e(function(e, t, n, r) {
		for (n ||= {}, r = e.length; r--; n[e[r]] = t);
		return n;
	}, "o"), n = [5, 8], r = [
		7,
		8,
		11,
		12,
		17,
		19,
		22,
		24
	], i = [1, 17], a = [1, 18], o = [
		7,
		8,
		11,
		12,
		14,
		15,
		16,
		17,
		19,
		20,
		21,
		22,
		24,
		27
	], s = [1, 31], c = [1, 39], l = [
		7,
		8,
		11,
		12,
		17,
		19,
		22,
		24,
		27
	], u = [1, 57], d = [1, 56], f = [1, 58], p = [1, 59], m = [1, 60], h = [
		7,
		8,
		11,
		12,
		16,
		17,
		19,
		20,
		22,
		24,
		27,
		31,
		32,
		33
	], g = {
		trace: /* @__PURE__ */ e(function() {}, "trace"),
		yy: {},
		symbols_: {
			error: 2,
			start: 3,
			optNewlines: 4,
			VENN: 5,
			document: 6,
			EOF: 7,
			NEWLINE: 8,
			line: 9,
			statement: 10,
			TITLE: 11,
			SET: 12,
			identifier: 13,
			BRACKET_LABEL: 14,
			COLON: 15,
			NUMERIC: 16,
			UNION: 17,
			identifierList: 18,
			TEXT: 19,
			IDENTIFIER: 20,
			STRING: 21,
			INDENT_TEXT: 22,
			indentedTextTail: 23,
			STYLE: 24,
			stylesOpt: 25,
			styleField: 26,
			COMMA: 27,
			styleValue: 28,
			valueTokens: 29,
			valueToken: 30,
			HEXCOLOR: 31,
			RGBCOLOR: 32,
			RGBACOLOR: 33,
			$accept: 0,
			$end: 1
		},
		terminals_: {
			2: "error",
			5: "VENN",
			7: "EOF",
			8: "NEWLINE",
			11: "TITLE",
			12: "SET",
			14: "BRACKET_LABEL",
			15: "COLON",
			16: "NUMERIC",
			17: "UNION",
			19: "TEXT",
			20: "IDENTIFIER",
			21: "STRING",
			22: "INDENT_TEXT",
			24: "STYLE",
			27: "COMMA",
			31: "HEXCOLOR",
			32: "RGBCOLOR",
			33: "RGBACOLOR"
		},
		productions_: [
			0,
			[3, 4],
			[4, 0],
			[4, 2],
			[6, 0],
			[6, 2],
			[9, 1],
			[9, 1],
			[10, 1],
			[10, 2],
			[10, 3],
			[10, 4],
			[10, 5],
			[10, 2],
			[10, 3],
			[10, 4],
			[10, 5],
			[10, 3],
			[10, 3],
			[10, 3],
			[10, 4],
			[10, 4],
			[10, 2],
			[10, 3],
			[23, 1],
			[23, 1],
			[23, 1],
			[23, 2],
			[23, 2],
			[25, 1],
			[25, 3],
			[26, 3],
			[28, 1],
			[28, 1],
			[29, 1],
			[29, 2],
			[30, 1],
			[30, 1],
			[30, 1],
			[30, 1],
			[30, 1],
			[18, 1],
			[18, 3],
			[13, 1],
			[13, 1]
		],
		performAction: /* @__PURE__ */ e(function(e, t, n, r, i, a, o) {
			var s = a.length - 1;
			switch (i) {
				case 1: return a[s - 1];
				case 2:
				case 3:
				case 4:
					this.$ = [];
					break;
				case 5:
					a[s - 1].push(a[s]), this.$ = a[s - 1];
					break;
				case 6:
					this.$ = [];
					break;
				case 7:
				case 22:
				case 32:
				case 36:
				case 37:
				case 38:
				case 39:
				case 40:
					this.$ = a[s];
					break;
				case 8:
					r.setDiagramTitle(a[s].substr(6)), this.$ = a[s].substr(6);
					break;
				case 9:
					r.addSubsetData([a[s]], void 0, void 0), r.setIndentMode && r.setIndentMode(!0);
					break;
				case 10:
					r.addSubsetData([a[s - 1]], a[s], void 0), r.setIndentMode && r.setIndentMode(!0);
					break;
				case 11:
					r.addSubsetData([a[s - 2]], void 0, parseFloat(a[s])), r.setIndentMode && r.setIndentMode(!0);
					break;
				case 12:
					r.addSubsetData([a[s - 3]], a[s - 2], parseFloat(a[s])), r.setIndentMode && r.setIndentMode(!0);
					break;
				case 13:
					if (a[s].length < 2) throw Error("union requires multiple identifiers");
					r.validateUnionIdentifiers && r.validateUnionIdentifiers(a[s]), r.addSubsetData(a[s], void 0, void 0), r.setIndentMode && r.setIndentMode(!0);
					break;
				case 14:
					if (a[s - 1].length < 2) throw Error("union requires multiple identifiers");
					r.validateUnionIdentifiers && r.validateUnionIdentifiers(a[s - 1]), r.addSubsetData(a[s - 1], a[s], void 0), r.setIndentMode && r.setIndentMode(!0);
					break;
				case 15:
					if (a[s - 2].length < 2) throw Error("union requires multiple identifiers");
					r.validateUnionIdentifiers && r.validateUnionIdentifiers(a[s - 2]), r.addSubsetData(a[s - 2], void 0, parseFloat(a[s])), r.setIndentMode && r.setIndentMode(!0);
					break;
				case 16:
					if (a[s - 3].length < 2) throw Error("union requires multiple identifiers");
					r.validateUnionIdentifiers && r.validateUnionIdentifiers(a[s - 3]), r.addSubsetData(a[s - 3], a[s - 2], parseFloat(a[s])), r.setIndentMode && r.setIndentMode(!0);
					break;
				case 17:
				case 18:
				case 19:
					r.addTextData(a[s - 1], a[s], void 0);
					break;
				case 20:
				case 21:
					r.addTextData(a[s - 2], a[s - 1], a[s]);
					break;
				case 23:
					r.addStyleData(a[s - 1], a[s]);
					break;
				case 24:
				case 25:
				case 26:
					var c = r.getCurrentSets();
					if (!c) throw Error("text requires set");
					r.addTextData(c, a[s], void 0);
					break;
				case 27:
				case 28:
					var c = r.getCurrentSets();
					if (!c) throw Error("text requires set");
					r.addTextData(c, a[s - 1], a[s]);
					break;
				case 29:
				case 41:
					this.$ = [a[s]];
					break;
				case 30:
				case 42:
					this.$ = [...a[s - 2], a[s]];
					break;
				case 31:
					this.$ = [a[s - 2], a[s]];
					break;
				case 33:
					this.$ = a[s].join(" ");
					break;
				case 34:
					this.$ = [a[s]];
					break;
				case 35:
					a[s - 1].push(a[s]), this.$ = a[s - 1];
					break;
				case 43:
				case 44:
					this.$ = a[s];
					break;
			}
		}, "anonymous"),
		table: [
			t(n, [2, 2], {
				3: 1,
				4: 2
			}),
			{ 1: [3] },
			{
				5: [1, 3],
				8: [1, 4]
			},
			t(r, [2, 4], { 6: 5 }),
			t(n, [2, 3]),
			{
				7: [1, 6],
				8: [1, 8],
				9: 7,
				10: 9,
				11: [1, 10],
				12: [1, 11],
				17: [1, 12],
				19: [1, 13],
				22: [1, 14],
				24: [1, 15]
			},
			{ 1: [2, 1] },
			t(r, [2, 5]),
			t(r, [2, 6]),
			t(r, [2, 7]),
			t(r, [2, 8]),
			{
				13: 16,
				20: i,
				21: a
			},
			{
				13: 20,
				18: 19,
				20: i,
				21: a
			},
			{
				13: 20,
				18: 21,
				20: i,
				21: a
			},
			{
				16: [1, 25],
				20: [1, 23],
				21: [1, 24],
				23: 22
			},
			{
				13: 20,
				18: 26,
				20: i,
				21: a
			},
			t(r, [2, 9], {
				14: [1, 27],
				15: [1, 28]
			}),
			t(o, [2, 43]),
			t(o, [2, 44]),
			t(r, [2, 13], {
				14: [1, 29],
				15: [1, 30],
				27: s
			}),
			t(o, [2, 41]),
			{
				16: [1, 34],
				20: [1, 32],
				21: [1, 33],
				27: s
			},
			t(r, [2, 22]),
			t(r, [2, 24], { 14: [1, 35] }),
			t(r, [2, 25], { 14: [1, 36] }),
			t(r, [2, 26]),
			{
				20: c,
				25: 37,
				26: 38,
				27: s
			},
			t(r, [2, 10], { 15: [1, 40] }),
			{ 16: [1, 41] },
			t(r, [2, 14], { 15: [1, 42] }),
			{ 16: [1, 43] },
			{
				13: 44,
				20: i,
				21: a
			},
			t(r, [2, 17], { 14: [1, 45] }),
			t(r, [2, 18], { 14: [1, 46] }),
			t(r, [2, 19]),
			t(r, [2, 27]),
			t(r, [2, 28]),
			t(r, [2, 23], { 27: [1, 47] }),
			t(l, [2, 29]),
			{ 15: [1, 48] },
			{ 16: [1, 49] },
			t(r, [2, 11]),
			{ 16: [1, 50] },
			t(r, [2, 15]),
			t(o, [2, 42]),
			t(r, [2, 20]),
			t(r, [2, 21]),
			{
				20: c,
				26: 51
			},
			{
				16: u,
				20: d,
				21: [1, 53],
				28: 52,
				29: 54,
				30: 55,
				31: f,
				32: p,
				33: m
			},
			t(r, [2, 12]),
			t(r, [2, 16]),
			t(l, [2, 30]),
			t(l, [2, 31]),
			t(l, [2, 32]),
			t(l, [2, 33], {
				30: 61,
				16: u,
				20: d,
				31: f,
				32: p,
				33: m
			}),
			t(h, [2, 34]),
			t(h, [2, 36]),
			t(h, [2, 37]),
			t(h, [2, 38]),
			t(h, [2, 39]),
			t(h, [2, 40]),
			t(h, [2, 35])
		],
		defaultActions: { 6: [2, 1] },
		parseError: /* @__PURE__ */ e(function(e, t) {
			if (t.recoverable) this.trace(e);
			else {
				var n = Error(e);
				throw n.hash = t, n;
			}
		}, "parseError"),
		parse: /* @__PURE__ */ e(function(t) {
			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(t, 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;
			}
			e(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;
			}
			e(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")
	};
	g.lexer = /* @__PURE__ */ (function() {
		return {
			EOF: 1,
			parseError: /* @__PURE__ */ e(function(e, t) {
				if (this.yy.parser) this.yy.parser.parseError(e, t);
				else throw Error(e);
			}, "parseError"),
			setInput: /* @__PURE__ */ e(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__ */ e(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__ */ e(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__ */ e(function() {
				return this._more = !0, this;
			}, "more"),
			reject: /* @__PURE__ */ e(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__ */ e(function(e) {
				this.unput(this.match.slice(e));
			}, "less"),
			pastInput: /* @__PURE__ */ e(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__ */ e(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__ */ e(function() {
				var e = this.pastInput(), t = Array(e.length + 1).join("-");
				return e + this.upcomingInput() + "\n" + t + "^";
			}, "showPosition"),
			test_match: /* @__PURE__ */ e(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__ */ e(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__ */ e(function() {
				return this.next() || this.lex();
			}, "lex"),
			begin: /* @__PURE__ */ e(function(e) {
				this.conditionStack.push(e);
			}, "begin"),
			popState: /* @__PURE__ */ e(function() {
				return this.conditionStack.length - 1 > 0 ? this.conditionStack.pop() : this.conditionStack[0];
			}, "popState"),
			_currentRules: /* @__PURE__ */ e(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__ */ e(function(e) {
				return e = this.conditionStack.length - 1 - Math.abs(e || 0), e >= 0 ? this.conditionStack[e] : "INITIAL";
			}, "topState"),
			pushState: /* @__PURE__ */ e(function(e) {
				this.begin(e);
			}, "pushState"),
			stateStackSize: /* @__PURE__ */ e(function() {
				return this.conditionStack.length;
			}, "stateStackSize"),
			options: { "case-insensitive": !0 },
			performAction: /* @__PURE__ */ e(function(e, t, n, r) {
				switch (n) {
					case 0: break;
					case 1: break;
					case 2: break;
					case 3:
						if (e.getIndentMode && e.getIndentMode()) return e.consumeIndentText = !0, this.begin("INITIAL"), 22;
						break;
					case 4: break;
					case 5:
						e.setIndentMode && e.setIndentMode(!1), this.begin("INITIAL"), this.unput(t.yytext);
						break;
					case 6: return this.begin("bol"), 8;
					case 7: break;
					case 8: break;
					case 9: return 7;
					case 10: return 11;
					case 11: return 5;
					case 12: return 12;
					case 13: return 17;
					case 14:
						if (e.consumeIndentText) e.consumeIndentText = !1;
						else return 19;
						break;
					case 15: return 24;
					case 16: return t.yytext = t.yytext.slice(2, -2), 14;
					case 17: return t.yytext = t.yytext.slice(1, -1).trim(), 14;
					case 18: return 16;
					case 19: return 31;
					case 20: return 33;
					case 21: return 32;
					case 22: return 20;
					case 23: return 21;
					case 24: return 27;
					case 25: return 15;
				}
			}, "anonymous"),
			rules: [
				/^(?:%%(?!\{)[^\n]*)/i,
				/^(?:[^\}]%%[^\n]*)/i,
				/^(?:[ \t]+(?=[\n\r]))/i,
				/^(?:[ \t]+(?=text\b))/i,
				/^(?:[ \t]+)/i,
				/^(?:[^ \t\n\r])/i,
				/^(?:[\n\r]+)/i,
				/^(?:%%[^\n]*)/i,
				/^(?:[ \t]+)/i,
				/^(?:$)/i,
				/^(?:title\s[^#\n;]+)/i,
				/^(?:venn-beta\b)/i,
				/^(?:set\b)/i,
				/^(?:union\b)/i,
				/^(?:text\b)/i,
				/^(?:style\b)/i,
				/^(?:\["[^\"]*"\])/i,
				/^(?:\[[^\]\"]+\])/i,
				/^(?:[+-]?(\d+(\.\d+)?|\.\d+))/i,
				/^(?:#[0-9a-fA-F]{3,8})/i,
				/^(?:rgba\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,
				/^(?:rgb\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,
				/^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i,
				/^(?:"[^\"]*")/i,
				/^(?:,)/i,
				/^(?::)/i
			],
			conditions: {
				bol: {
					rules: [
						0,
						1,
						2,
						3,
						4,
						5,
						6,
						7,
						8,
						9,
						10,
						11,
						12,
						13,
						14,
						15,
						16,
						17,
						18,
						19,
						20,
						21,
						22,
						23,
						24,
						25
					],
					inclusive: !0
				},
				INITIAL: {
					rules: [
						0,
						1,
						6,
						7,
						8,
						9,
						10,
						11,
						12,
						13,
						14,
						15,
						16,
						17,
						18,
						19,
						20,
						21,
						22,
						23,
						24,
						25
					],
					inclusive: !0
				}
			}
		};
	})();
	function _() {
		this.yy = {};
	}
	return e(_, "Parser"), _.prototype = g, g.Parser = _, new _();
})();
x.parser = x;
var S = x, C = [], w = [], T = [], E = /* @__PURE__ */ new Set(), D, O = !1, k = /* @__PURE__ */ e((e, t, n) => {
	let r = I(e).sort(), i = n ?? 10 / e.length ** 2;
	D = r, r.length === 1 && E.add(r[0]), C.push({
		sets: r,
		size: i,
		label: t ? j(t) : void 0
	});
}, "addSubsetData"), A = /* @__PURE__ */ e(() => C, "getSubsetData"), j = /* @__PURE__ */ e((e) => {
	let t = e.trim();
	return t.length >= 2 && t.startsWith("\"") && t.endsWith("\"") ? t.slice(1, -1) : t;
}, "normalizeText"), M = /* @__PURE__ */ e((e) => e && j(e), "normalizeStyleValue"), N = /* @__PURE__ */ e((e, t, n) => {
	let r = j(t);
	w.push({
		sets: I(e).sort(),
		id: r,
		label: n ? j(n) : void 0
	});
}, "addTextData"), P = /* @__PURE__ */ e((e, t) => {
	let n = I(e).sort(), r = {};
	for (let [e, n] of t) r[e] = M(n) ?? n;
	T.push({
		targets: n,
		styles: r
	});
}, "addStyleData"), F = /* @__PURE__ */ e(() => T, "getStyleData"), I = /* @__PURE__ */ e((e) => e.map((e) => j(e)), "normalizeIdentifierList"), L = /* @__PURE__ */ e((e) => {
	let t = I(e).filter((e) => !E.has(e));
	if (t.length > 0) throw Error(`unknown set identifier: ${t.join(", ")}`);
}, "validateUnionIdentifiers"), R = /* @__PURE__ */ e(() => w, "getTextData"), z = /* @__PURE__ */ e(() => D, "getCurrentSets"), B = /* @__PURE__ */ e(() => O, "getIndentMode"), V = /* @__PURE__ */ e((e) => {
	O = e;
}, "setIndentMode"), H = s.venn;
function U() {
	return _(H, u().venn);
}
e(U, "getConfig");
var W = {
	getConfig: U,
	clear: /* @__PURE__ */ e(() => {
		a(), C.length = 0, w.length = 0, T.length = 0, E.clear(), D = void 0, O = !1;
	}, "customClear"),
	setAccTitle: p,
	getAccTitle: l,
	setDiagramTitle: m,
	getDiagramTitle: d,
	getAccDescription: c,
	setAccDescription: f,
	addSubsetData: k,
	getSubsetData: A,
	addTextData: N,
	addStyleData: P,
	validateUnionIdentifiers: L,
	getTextData: R,
	getStyleData: F,
	getCurrentSets: z,
	getIndentMode: B,
	setIndentMode: V
}, G = /* @__PURE__ */ e((e) => `
  .venn-title {
    font-size: 32px;
    fill: ${e.vennTitleTextColor};
    font-family: ${e.fontFamily};
  }

  .venn-circle text {
    font-size: 48px;
    font-family: ${e.fontFamily};
  }

  .venn-intersection text {
    font-size: 48px;
    fill: ${e.vennSetTextColor};
    font-family: ${e.fontFamily};
  }

  .venn-text-node {
    font-family: ${e.fontFamily};
    color: ${e.vennSetTextColor};
  }
`, "getStyles");
function K(e) {
	let t = /* @__PURE__ */ new Map();
	for (let n of e) {
		let e = n.targets.join("|"), r = t.get(e);
		r ? Object.assign(r, n.styles) : t.set(e, { ...n.styles });
	}
	return t;
}
e(K, "buildStyleByKey");
var q = /* @__PURE__ */ e((e, a, s, c) => {
	let l = c.db, d = l.getConfig?.(), { themeVariables: f, look: p, handDrawnSeed: m } = u(), _ = p === "handDrawn", x = [
		f.venn1,
		f.venn2,
		f.venn3,
		f.venn4,
		f.venn5,
		f.venn6,
		f.venn7,
		f.venn8
	].filter(Boolean), S = l.getDiagramTitle?.(), C = l.getSubsetData(), w = l.getTextData(), T = K(l.getStyleData()), E = d?.width ?? 800, D = d?.height ?? 450, O = E / 1600, k = S ? 48 * O : 0, A = f.primaryTextColor ?? f.textColor, j = g(a);
	j.attr("viewBox", `0 0 ${E} ${D}`), S && j.append("text").text(S).attr("class", "venn-title").attr("font-size", `${32 * O}px`).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("x", "50%").attr("y", 32 * O).style("fill", f.vennTitleTextColor || f.titleColor);
	let M = h(document.createElement("div")), N = y().width(E).height(D - k);
	M.datum(C).call(N);
	let P = _ ? v.svg(M.select("svg").node()) : void 0, F = b(C, {
		width: E,
		height: D - k,
		padding: d?.padding ?? 15
	}), I = /* @__PURE__ */ new Map();
	for (let e of F) {
		let t = J([...e.data.sets].sort());
		I.set(t, e);
	}
	w.length > 0 && Y(d, I, M, w, O, T);
	let L = t(f.background || "#f4f4f4");
	M.selectAll(".venn-circle").each(function(e, t) {
		let a = h(this), o = J([...e.sets].sort()), s = T.get(o), c = s?.fill || x[t % x.length] || f.primaryColor;
		a.classed(`venn-set-${t % 8}`, !0);
		let l = s?.["fill-opacity"] ?? .1, u = s?.stroke || c, d = s?.["stroke-width"] || `${5 * O}`;
		if (_ && P) {
			let e = I.get(o);
			if (e && e.circles.length > 0) {
				let n = e.circles[0], r = P.circle(n.x, n.y, n.radius * 2, {
					roughness: .7,
					seed: m,
					fill: i(c, .7),
					fillStyle: "hachure",
					fillWeight: 2,
					hachureGap: 8,
					hachureAngle: -41 + t * 60,
					stroke: u,
					strokeWidth: parseFloat(String(d))
				});
				a.select("path").remove(), a.node()?.insertBefore(r, a.select("text").node());
			}
		} else a.select("path").style("fill", c).style("fill-opacity", l).style("stroke", u).style("stroke-width", d).style("stroke-opacity", .95);
		let p = s?.color || (L ? n(c, 30) : r(c, 30));
		a.select("text").style("font-size", `${48 * O}px`).style("fill", p);
	}), _ && P ? M.selectAll(".venn-intersection").each(function(e) {
		let t = h(this), n = J([...e.sets].sort()), r = T.get(n), a = r?.fill;
		if (a) {
			let e = t.select("path"), n = e.attr("d");
			if (n) {
				let t = P.path(n, {
					roughness: .7,
					seed: m,
					fill: i(a, .3),
					fillStyle: "cross-hatch",
					fillWeight: 2,
					hachureGap: 6,
					hachureAngle: 60,
					stroke: "none"
				}), r = e.node();
				r?.parentNode?.insertBefore(t, r), e.remove();
			}
		} else t.select("path").style("fill-opacity", 0);
		t.select("text").style("font-size", `${48 * O}px`).style("fill", r?.color ?? f.vennSetTextColor ?? A);
	}) : (M.selectAll(".venn-intersection text").style("font-size", `${48 * O}px`).style("fill", (e) => {
		let t = J([...e.sets].sort());
		return T.get(t)?.color ?? f.vennSetTextColor ?? A;
	}), M.selectAll(".venn-intersection path").style("fill-opacity", (e) => {
		let t = J([...e.sets].sort());
		return +!!T.get(t)?.fill;
	}).style("fill", (e) => {
		let t = J([...e.sets].sort());
		return T.get(t)?.fill ?? "transparent";
	}));
	let R = j.append("g").attr("transform", `translate(0, ${k})`), z = M.select("svg").node();
	if (z && "childNodes" in z) for (let e of [...z.childNodes]) R.node()?.appendChild(e);
	o(j, D, E, d?.useMaxWidth ?? !0);
}, "draw");
function J(e) {
	return e.join("|");
}
e(J, "stableSetsKey");
function Y(e, t, n, r, i, a) {
	let o = e?.useDebugLayout ?? !1, s = n.select("svg").append("g").attr("class", "venn-text-nodes"), c = /* @__PURE__ */ new Map();
	for (let e of r) {
		let t = J(e.sets), n = c.get(t);
		n ? n.push(e) : c.set(t, [e]);
	}
	for (let [e, n] of c.entries()) {
		let r = t.get(e);
		if (!r?.text) continue;
		let c = r.text.x, l = r.text.y, u = Math.min(...r.circles.map((e) => e.radius)), d = Math.min(...r.circles.map((e) => e.radius - Math.hypot(c - e.x, l - e.y))), f = Number.isFinite(d) ? Math.max(0, d) : 0;
		f === 0 && Number.isFinite(u) && (f = u * .6);
		let p = s.append("g").attr("class", "venn-text-area").attr("font-size", `${40 * i}px`);
		o && p.append("circle").attr("class", "venn-text-debug-circle").attr("cx", c).attr("cy", l).attr("r", f).attr("fill", "none").attr("stroke", "purple").attr("stroke-width", 1.5 * i).attr("stroke-dasharray", `${6 * i} ${4 * i}`);
		let m = Math.max(80 * i, f * 2 * .95), h = Math.max(60 * i, f * 2 * .95), g = (r.data.label && r.data.label.length > 0 ? Math.min(32 * i, f * .25) : 0) + (n.length <= 2 ? 30 * i : 0), _ = c - m / 2, v = l - h / 2 + g, y = Math.max(1, Math.ceil(Math.sqrt(n.length))), b = Math.max(1, Math.ceil(n.length / y)), x = m / y, S = h / b;
		for (let [e, t] of n.entries()) {
			let n = e % y, r = Math.floor(e / y), s = _ + x * (n + .5), c = v + S * (r + .5);
			o && p.append("rect").attr("class", "venn-text-debug-cell").attr("x", _ + x * n).attr("y", v + S * r).attr("width", x).attr("height", S).attr("fill", "none").attr("stroke", "teal").attr("stroke-width", 1 * i).attr("stroke-dasharray", `${4 * i} ${3 * i}`);
			let l = x * .9, u = S * .9, d = p.append("foreignObject").attr("class", "venn-text-node-fo").attr("width", l).attr("height", u).attr("x", s - l / 2).attr("y", c - u / 2).attr("overflow", "visible"), f = a.get(t.id)?.color, m = d.append("xhtml:span").attr("class", "venn-text-node").style("display", "flex").style("width", "100%").style("height", "100%").style("white-space", "normal").style("align-items", "center").style("justify-content", "center").style("text-align", "center").style("overflow-wrap", "normal").style("word-break", "normal").text(t.label ?? t.id);
			f && m.style("color", f);
		}
	}
}
e(Y, "renderTextNodes");
var X = {
	parser: S,
	db: W,
	renderer: { draw: q },
	styles: G
};
//#endregion
export { X as diagram };
