import { __name as e, log as t, setLogLevel as n } from "./chunks/mermaid.core/chunk-AGHRB4JF.js";
import { purify as r } from "../../dompurify/dist/purify.es.js";
import { UnknownDiagramError as i, addDirective as a, assignWithDepth_default as o, configureSvgSize as s, defaultConfig as c, detectType as l, detectors as u, evaluate as ee, frontMatterRegex as d, getConfig as f, getDiagram as p, getDiagramLoader as m, getEffectiveHtmlLabels as h, getSiteConfig as g, registerDiagram as _, registerLazyLoadedDiagrams as v, reset as y, saveConfigFromInitialize as b, setConfig as te, setSiteConfig as x, styles_default as S, themes_default as C, updateSiteConfig as ne } from "./chunks/mermaid.core/chunk-ICPOFSXX.js";
import w from "../../d3-selection/src/select.js";
import "../../d3/src/index.js";
import { selectSvgElement as re } from "./chunks/mermaid.core/chunk-426QAEUC.js";
import { JSON_SCHEMA as T, load as ie } from "./chunks/mermaid.core/chunk-XPW4576I.js";
import "./chunks/mermaid.core/chunk-BSJP7CBP.js";
import { cleanAndMerge as ae, decodeEntities as oe, encodeEntities as E, isDetailedError as se, removeDirectives as ce, utils_default as D } from "./chunks/mermaid.core/chunk-5PVQY5BW.js";
import "./chunks/mermaid.core/chunk-ZZ45TVLE.js";
import "./chunks/mermaid.core/chunk-X2U36JSP.js";
import le from "../../ts-dedent/esm/index.js";
import { registerIconPacks as ue } from "./chunks/mermaid.core/chunk-U2HBQHQK.js";
import "./chunks/mermaid.core/chunk-5FUZZQ4R.js";
import "./chunks/mermaid.core/chunk-ENJZ2VHE.js";
import { registerLayoutLoaders as de } from "./chunks/mermaid.core/chunk-336JU56O.js";
import { compile as fe } from "../../stylis/src/Parser.js";
import { serialize as pe, stringify as me } from "../../stylis/src/Serializer.js";
import O from "../../lodash-es/isEmpty.js";
//#region ../../node_modules/mermaid/dist/mermaid.core.mjs
var k = "c4", he = {
	id: k,
	detector: /* @__PURE__ */ e((e) => /^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/c4Diagram-AHTNJAMY.js");
		return {
			id: k,
			diagram: e
		};
	}, "loader")
}, A = "flowchart", ge = {
	id: A,
	detector: /* @__PURE__ */ e((e, t) => t?.flowchart?.defaultRenderer === "dagre-wrapper" || t?.flowchart?.defaultRenderer === "elk" ? !1 : /^\s*graph/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/flowDiagram-DWJPFMVM.js");
		return {
			id: A,
			diagram: e
		};
	}, "loader")
}, j = "flowchart-v2", _e = {
	id: j,
	detector: /* @__PURE__ */ e((e, t) => t?.flowchart?.defaultRenderer === "dagre-d3" ? !1 : (t?.flowchart?.defaultRenderer === "elk" && (t.layout = "elk"), /^\s*graph/.test(e) && t?.flowchart?.defaultRenderer === "dagre-wrapper" ? !0 : /^\s*flowchart/.test(e)), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/flowDiagram-DWJPFMVM.js");
		return {
			id: j,
			diagram: e
		};
	}, "loader")
}, M = "er", ve = {
	id: M,
	detector: /* @__PURE__ */ e((e) => /^\s*erDiagram/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/erDiagram-SMLLAGMA.js");
		return {
			id: M,
			diagram: e
		};
	}, "loader")
}, N = "gitGraph", ye = {
	id: N,
	detector: /* @__PURE__ */ e((e) => /^\s*gitGraph/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/gitGraphDiagram-UUTBAWPF.js");
		return {
			id: N,
			diagram: e
		};
	}, "loader")
}, P = "gantt", be = {
	id: P,
	detector: /* @__PURE__ */ e((e) => /^\s*gantt/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/ganttDiagram-T4ZO3ILL.js");
		return {
			id: P,
			diagram: e
		};
	}, "loader")
}, F = "info", xe = {
	id: F,
	detector: /* @__PURE__ */ e((e) => /^\s*info/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/infoDiagram-42DDH7IO.js");
		return {
			id: F,
			diagram: e
		};
	}, "loader")
}, I = "pie", Se = {
	id: I,
	detector: /* @__PURE__ */ e((e) => /^\s*pie/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/pieDiagram-DEJITSTG.js");
		return {
			id: I,
			diagram: e
		};
	}, "loader")
}, L = "quadrantChart", Ce = {
	id: L,
	detector: /* @__PURE__ */ e((e) => /^\s*quadrantChart/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/quadrantDiagram-34T5L4WZ.js");
		return {
			id: L,
			diagram: e
		};
	}, "loader")
}, R = "xychart", we = {
	id: R,
	detector: /* @__PURE__ */ e((e) => /^\s*xychart(-beta)?/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/xychartDiagram-5P7HB3ND.js");
		return {
			id: R,
			diagram: e
		};
	}, "loader")
}, z = "requirement", Te = {
	id: z,
	detector: /* @__PURE__ */ e((e) => /^\s*requirement(Diagram)?/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/requirementDiagram-MS252O5E.js");
		return {
			id: z,
			diagram: e
		};
	}, "loader")
}, B = "sequence", Ee = {
	id: B,
	detector: /* @__PURE__ */ e((e) => /^\s*sequenceDiagram/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/sequenceDiagram-FGHM5R23.js");
		return {
			id: B,
			diagram: e
		};
	}, "loader")
}, V = "class", De = {
	id: V,
	detector: /* @__PURE__ */ e((e, t) => t?.class?.defaultRenderer === "dagre-wrapper" ? !1 : /^\s*classDiagram/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/classDiagram-6PBFFD2Q.js");
		return {
			id: V,
			diagram: e
		};
	}, "loader")
}, H = "classDiagram", Oe = {
	id: H,
	detector: /* @__PURE__ */ e((e, t) => /^\s*classDiagram/.test(e) && t?.class?.defaultRenderer === "dagre-wrapper" ? !0 : /^\s*classDiagram-v2/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/classDiagram-v2-HSJHXN6E.js");
		return {
			id: H,
			diagram: e
		};
	}, "loader")
}, ke = "state", Ae = {
	id: ke,
	detector: /* @__PURE__ */ e((e, t) => t?.state?.defaultRenderer === "dagre-wrapper" ? !1 : /^\s*stateDiagram/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/stateDiagram-FHFEXIEX.js");
		return {
			id: ke,
			diagram: e
		};
	}, "loader")
}, je = "stateDiagram", Me = {
	id: je,
	detector: /* @__PURE__ */ e((e, t) => !!(/^\s*stateDiagram-v2/.test(e) || /^\s*stateDiagram/.test(e) && t?.state?.defaultRenderer === "dagre-wrapper"), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/stateDiagram-v2-QKLJ7IA2.js");
		return {
			id: je,
			diagram: e
		};
	}, "loader")
}, Ne = "journey", Pe = {
	id: Ne,
	detector: /* @__PURE__ */ e((e) => /^\s*journey/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/journeyDiagram-VCZTEJTY.js");
		return {
			id: Ne,
			diagram: e
		};
	}, "loader")
}, Fe = { draw: /* @__PURE__ */ e((e, n, r) => {
	t.debug("rendering svg for syntax error\n");
	let i = re(n), a = i.append("g");
	i.attr("viewBox", "0 0 2412 512"), s(i, 100, 512, !0), a.append("path").attr("class", "error-icon").attr("d", "m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"), a.append("path").attr("class", "error-icon").attr("d", "m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"), a.append("path").attr("class", "error-icon").attr("d", "m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"), a.append("path").attr("class", "error-icon").attr("d", "m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"), a.append("path").attr("class", "error-icon").attr("d", "m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"), a.append("path").attr("class", "error-icon").attr("d", "m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"), a.append("text").attr("class", "error-text").attr("x", 1440).attr("y", 250).attr("font-size", "150px").style("text-anchor", "middle").text("Syntax error in text"), a.append("text").attr("class", "error-text").attr("x", 1250).attr("y", 400).attr("font-size", "100px").style("text-anchor", "middle").text(`mermaid version ${r}`);
}, "draw") }, Ie = Fe, Le = {
	db: {},
	renderer: Fe,
	parser: { parse: /* @__PURE__ */ e(() => {}, "parse") }
}, Re = "flowchart-elk", ze = {
	id: Re,
	detector: /* @__PURE__ */ e((e, t = {}) => /^\s*flowchart-elk/.test(e) || /^\s*(flowchart|graph)/.test(e) && t?.flowchart?.defaultRenderer === "elk" ? (t.layout = "elk", !0) : !1, "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/flowDiagram-DWJPFMVM.js");
		return {
			id: Re,
			diagram: e
		};
	}, "loader")
}, Be = "timeline", Ve = {
	id: Be,
	detector: /* @__PURE__ */ e((e) => /^\s*timeline/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/timeline-definition-GMOUNBTQ.js");
		return {
			id: Be,
			diagram: e
		};
	}, "loader")
}, He = "mindmap", Ue = {
	id: He,
	detector: /* @__PURE__ */ e((e) => /^\s*mindmap/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/mindmap-definition-QFDTVHPH.js");
		return {
			id: He,
			diagram: e
		};
	}, "loader")
}, We = "kanban", Ge = {
	id: We,
	detector: /* @__PURE__ */ e((e) => /^\s*kanban/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/kanban-definition-6JOO6SKY.js");
		return {
			id: We,
			diagram: e
		};
	}, "loader")
}, Ke = "sankey", qe = {
	id: Ke,
	detector: /* @__PURE__ */ e((e) => /^\s*sankey(-beta)?/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/sankeyDiagram-XADWPNL6.js");
		return {
			id: Ke,
			diagram: e
		};
	}, "loader")
}, Je = "packet", Ye = {
	id: Je,
	detector: /* @__PURE__ */ e((e) => /^\s*packet(-beta)?/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/diagram-TYMM5635.js");
		return {
			id: Je,
			diagram: e
		};
	}, "loader")
}, Xe = "radar", Ze = {
	id: Xe,
	detector: /* @__PURE__ */ e((e) => /^\s*radar-beta/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/diagram-MMDJMWI5.js");
		return {
			id: Xe,
			diagram: e
		};
	}, "loader")
}, Qe = "block", $e = {
	id: Qe,
	detector: /* @__PURE__ */ e((e) => /^\s*block(-beta)?/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/blockDiagram-DXYQGD6D.js");
		return {
			id: Qe,
			diagram: e
		};
	}, "loader")
}, et = "treeView", tt = {
	id: et,
	detector: /* @__PURE__ */ e((e) => /^\s*treeView-beta/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/diagram-5BDNPKRD.js");
		return {
			id: et,
			diagram: e
		};
	}, "loader")
}, nt = "architecture", rt = {
	id: nt,
	detector: /* @__PURE__ */ e((e) => /^\s*architecture/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/architectureDiagram-Q4EWVU46.js");
		return {
			id: nt,
			diagram: e
		};
	}, "loader")
}, it = "ishikawa", at = {
	id: it,
	detector: /* @__PURE__ */ e((e) => /^\s*ishikawa(-beta)?\b/i.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/ishikawaDiagram-UXIWVN3A.js");
		return {
			id: it,
			diagram: e
		};
	}, "loader")
}, ot = "venn", st = {
	id: ot,
	detector: /* @__PURE__ */ e((e) => /^\s*venn-beta/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/vennDiagram-DHZGUBPP.js");
		return {
			id: ot,
			diagram: e
		};
	}, "loader")
}, ct = "treemap", lt = {
	id: ct,
	detector: /* @__PURE__ */ e((e) => /^\s*treemap/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/diagram-G4DWMVQ6.js");
		return {
			id: ct,
			diagram: e
		};
	}, "loader")
}, ut = "wardley-beta", dt = {
	id: ut,
	detector: /* @__PURE__ */ e((e) => /^\s*wardley-beta/i.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/wardleyDiagram-NUSXRM2D.js");
		return {
			id: ut,
			diagram: e
		};
	}, "loader")
}, ft = !1, U = /* @__PURE__ */ e(() => {
	ft || (ft = !0, _("error", Le, (e) => e.toLowerCase().trim() === "error"), _("---", {
		db: { clear: /* @__PURE__ */ e(() => {}, "clear") },
		styles: {},
		renderer: { draw: /* @__PURE__ */ e(() => {}, "draw") },
		parser: { parse: /* @__PURE__ */ e(() => {
			throw Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks");
		}, "parse") },
		init: /* @__PURE__ */ e(() => null, "init")
	}, (e) => e.toLowerCase().trimStart().startsWith("---")), v(ze, Ue, rt), v(he, Ge, Oe, De, ve, be, xe, Se, Te, Ee, _e, ge, Ve, ye, Me, Ae, Pe, Ce, qe, Ye, we, $e, tt, Ze, at, lt, st, dt));
}, "addDiagrams"), pt = /* @__PURE__ */ e(async () => {
	t.debug("Loading registered diagrams");
	let e = (await Promise.allSettled(Object.entries(u).map(async ([e, { detector: n, loader: r }]) => {
		if (r) try {
			p(e);
		} catch {
			try {
				let { diagram: e, id: t } = await r();
				_(t, e, n);
			} catch (n) {
				throw t.error(`Failed to load external diagram with key ${e}. Removing from detectors.`), delete u[e], n;
			}
		}
	}))).filter((e) => e.status === "rejected");
	if (e.length > 0) {
		t.error(`Failed to load ${e.length} external diagrams`);
		for (let n of e) t.error(n);
		throw Error(`Failed to load ${e.length} external diagrams`);
	}
}, "loadRegisteredDiagrams"), mt = "graphics-document document";
function ht(e, t) {
	e.attr("role", mt), t !== "" && e.attr("aria-roledescription", t);
}
e(ht, "setA11yDiagramInfo");
function gt(e, t, n, r) {
	if (e.insert !== void 0) {
		if (n) {
			let t = `chart-desc-${r}`;
			e.attr("aria-describedby", t), e.insert("desc", ":first-child").attr("id", t).text(n);
		}
		if (t) {
			let n = `chart-title-${r}`;
			e.attr("aria-labelledby", n), e.insert("title", ":first-child").attr("id", n).text(t);
		}
	}
}
e(gt, "addSVGa11yTitleDescription");
var W = class t {
	constructor(e, t, n, r, i) {
		this.type = e, this.text = t, this.db = n, this.parser = r, this.renderer = i;
	}
	static {
		e(this, "Diagram");
	}
	static async fromText(e, n = {}) {
		let r = f(), a = l(e, r);
		e = E(e) + "\n";
		try {
			p(a);
		} catch {
			let e = m(a);
			if (!e) throw new i(`Diagram ${a} not found.`);
			let { id: t, diagram: n } = await e();
			_(t, n);
		}
		let { db: o, parser: s, renderer: c, init: u } = p(a);
		return s.parser && (s.parser.yy = o), o.clear?.(), u?.(r), n.title && o.setDiagramTitle?.(n.title), await s.parse(e), new t(a, e, o, s, c);
	}
	async render(e, t) {
		await this.renderer.draw(this.text, e, t, this);
	}
	getParser() {
		return this.parser;
	}
	getType() {
		return this.type;
	}
}, _t = [], vt = /* @__PURE__ */ e(() => {
	_t.forEach((e) => {
		e();
	}), _t = [];
}, "attachFunctions"), yt = /* @__PURE__ */ e((e) => e.replace(/^\s*%%(?!{)[^\n]+\n?/gm, "").trimStart(), "cleanupComments");
function bt(e) {
	let t = e.match(d);
	if (!t) return {
		text: e,
		metadata: {}
	};
	let n = ie(t[1], { schema: T }) ?? {};
	n = typeof n == "object" && !Array.isArray(n) ? n : {};
	let r = {};
	return n.displayMode && (r.displayMode = n.displayMode.toString()), n.title && (r.title = n.title.toString()), n.config && (r.config = n.config), {
		text: e.slice(t[0].length),
		metadata: r
	};
}
e(bt, "extractFrontMatter");
var xt = /* @__PURE__ */ e((e) => e.replace(/\r\n?/g, "\n").replace(/<(\w+)([^>]*)>/g, (e, t, n) => "<" + t + n.replace(/="([^"]*)"/g, "='$1'") + ">"), "cleanupText"), St = /* @__PURE__ */ e((e) => {
	let { text: t, metadata: n } = bt(e), { displayMode: r, title: i, config: a = {} } = n;
	return r && (a.gantt ||= {}, a.gantt.displayMode = r), {
		title: i,
		config: a,
		text: t
	};
}, "processFrontmatter"), Ct = /* @__PURE__ */ e((e) => {
	let t = D.detectInit(e) ?? {}, n = D.detectDirective(e, "wrap");
	return Array.isArray(n) ? t.wrap = n.some(({ type: e }) => e === "wrap") : n?.type === "wrap" && (t.wrap = !0), {
		text: ce(e),
		directive: t
	};
}, "processDirectives");
function G(e) {
	let t = St(xt(e)), n = Ct(t.text), r = ae(t.config, n.directive);
	return e = yt(n.text), {
		code: e,
		title: t.title,
		config: r
	};
}
e(G, "preprocessDiagram");
function wt(e) {
	let t = new TextEncoder().encode(e), n = Array.from(t, (e) => String.fromCodePoint(e)).join("");
	return btoa(n);
}
e(wt, "toBase64");
var Tt = 5e4, Et = "graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa", Dt = "sandbox", Ot = "loose", kt = "http://www.w3.org/2000/svg", At = "http://www.w3.org/1999/xlink", jt = "http://www.w3.org/1999/xhtml", Mt = "100%", Nt = "100%", Pt = "border:0;margin:0;", Ft = "margin:0", It = "allow-top-navigation-by-user-activation allow-popups", Lt = "The \"iframe\" tag is not supported by your browser.", Rt = ["foreignobject"], zt = ["dominant-baseline"];
function K(e) {
	let t = G(e);
	return y(), a(t.config ?? {}), t;
}
e(K, "processAndSetConfigs");
async function Bt(e, t) {
	U();
	try {
		let { code: t, config: n } = K(e);
		return {
			diagramType: (await Yt(t)).type,
			config: n
		};
	} catch (e) {
		if (t?.suppressErrors) return !1;
		throw e;
	}
}
e(Bt, "parse");
var Vt = /* @__PURE__ */ e((e, t, n = []) => `
.${e} ${t} { ${n.join(" !important; ")} !important; }`, "cssImportantStyles"), Ht = /* @__PURE__ */ e((e, t = /* @__PURE__ */ new Map()) => {
	let n = "";
	if (e.themeCSS !== void 0 && (n += `
${e.themeCSS}`), e.fontFamily !== void 0 && (n += `
:root { --mermaid-font-family: ${e.fontFamily}}`), e.altFontFamily !== void 0 && (n += `
:root { --mermaid-alt-font-family: ${e.altFontFamily}}`), t instanceof Map) {
		let r = h(e) ? ["> *", "span"] : [
			"rect",
			"polygon",
			"ellipse",
			"circle",
			"path"
		];
		t.forEach((e) => {
			O(e.styles) || r.forEach((t) => {
				n += Vt(e.id, t, e.styles);
			}), O(e.textStyles) || (n += Vt(e.id, "tspan", (e?.textStyles || []).map((e) => e.replace("color", "fill"))));
		});
	}
	return n;
}, "createCssStyles"), Ut = /* @__PURE__ */ e((e, t, n, r) => pe(fe(`${r}{${S(t, Ht(e, n), {
	...e.themeVariables,
	theme: e.theme,
	look: e.look
}, r)}}`), me), "createUserStyles"), Wt = /* @__PURE__ */ e((e = "", t, n) => {
	let r = e;
	return !n && !t && (r = r.replace(/marker-end="url\([\d+./:=?A-Za-z-]*?#/g, "marker-end=\"url(#")), r = oe(r), r = r.replace(/<br>/g, "<br/>"), r;
}, "cleanUpSvgCode"), Gt = /* @__PURE__ */ e((e = "", t) => `<iframe style="width:${Mt};height:${t?.viewBox?.baseVal?.height ? t.viewBox.baseVal.height + "px" : Nt};${Pt}" src="data:text/html;charset=UTF-8;base64,${wt(`<body style="${Ft}">${e}</body>`)}" sandbox="${It}">
  ${Lt}
</iframe>`, "putIntoIFrame"), q = /* @__PURE__ */ e((e, t, n, r, i) => {
	let a = e.append("div");
	a.attr("id", n), r && a.attr("style", r);
	let o = a.append("svg").attr("id", t).attr("width", "100%").attr("xmlns", kt);
	return i && o.attr("xmlns:xlink", i), o.append("g"), e;
}, "appendDivSvgG");
function J(e, t) {
	return e.append("iframe").attr("id", t).attr("style", "width: 100%; height: 100%;").attr("sandbox", "");
}
e(J, "sandboxedIframe");
var Kt = /* @__PURE__ */ e((e, t, n, r) => {
	e.getElementById(t)?.remove(), e.getElementById(n)?.remove(), e.getElementById(r)?.remove();
}, "removeExistingElements"), qt = /* @__PURE__ */ e(async function(n, i, a) {
	U();
	let o = K(i);
	i = o.code;
	let s = f();
	t.debug(s), i.length > (s?.maxTextSize ?? Tt) && (i = Et);
	let c = "#" + n, l = "i" + n, u = "#" + l, d = "d" + n, p = "#" + d, m = /* @__PURE__ */ e(() => {
		let e = w(g ? u : p).node();
		e && "remove" in e && e.remove();
	}, "removeTempElements"), h = w("body"), g = s.securityLevel === Dt, _ = s.securityLevel === Ot, v = s.fontFamily;
	a === void 0 ? (Kt(document, n, d, l), g ? (h = w(J(w("body"), l).nodes()[0].contentDocument.body), h.node().style.margin = 0) : h = w("body"), q(h, n, d)) : (a && (a.innerHTML = ""), g ? (h = w(J(w(a), l).nodes()[0].contentDocument.body), h.node().style.margin = 0) : h = w(a), q(h, n, d, `font-family: ${v}`, At));
	let y, b;
	try {
		y = await W.fromText(i, { title: o.title });
	} catch (e) {
		if (s.suppressErrorRendering) throw m(), e;
		y = await W.fromText("error"), b = e;
	}
	let te = h.select(p).node(), x = y.type, S = te.firstChild, C = S.firstChild, ne = y.renderer.getClasses?.(i, y), re = Ut(s, x, ne, c), T = document.createElement("style");
	T.innerHTML = re, S.insertBefore(T, C);
	try {
		await y.renderer.draw(i, n, "11.14.0", y);
	} catch (e) {
		throw s.suppressErrorRendering ? m() : Ie.draw(i, n, "11.14.0"), e;
	}
	let ie = h.select(`${p} svg`), ae = y.db.getAccTitle?.(), oe = y.db.getAccDescription?.();
	Xt(x, ie, ae, oe), h.select(`[id="${n}"]`).selectAll("foreignobject > *").attr("xmlns", jt);
	let E = h.select(p).node().innerHTML;
	if (t.debug("config.arrowMarkerAbsolute", s.arrowMarkerAbsolute), E = Wt(E, g, ee(s.arrowMarkerAbsolute)), g) {
		let e = h.select(p + " svg").node();
		E = Gt(E, e);
	} else _ || (E = r.sanitize(E, {
		ADD_TAGS: Rt,
		ADD_ATTR: zt,
		HTML_INTEGRATION_POINTS: { foreignobject: !0 }
	}));
	if (vt(), b) throw b;
	return m(), {
		diagramType: x,
		svg: E,
		bindFunctions: y.db.bindFunctions
	};
}, "render");
function Jt(e = {}) {
	let t = o({}, e);
	t?.fontFamily && !t.themeVariables?.fontFamily && (t.themeVariables ||= {}, t.themeVariables.fontFamily = t.fontFamily), b(t), t?.theme && t.theme in C ? t.themeVariables = C[t.theme].getThemeVariables(t.themeVariables) : t && (t.themeVariables = C.default.getThemeVariables(t.themeVariables)), n((typeof t == "object" ? x(t) : g()).logLevel), U();
}
e(Jt, "initialize");
var Yt = /* @__PURE__ */ e((e, t = {}) => {
	let { code: n } = G(e);
	return W.fromText(n, t);
}, "getDiagramFromText");
function Xt(e, t, n, r) {
	ht(t, e), gt(t, n, r, t.attr("id"));
}
e(Xt, "addA11yInfo");
var Y = Object.freeze({
	render: qt,
	parse: Bt,
	getDiagramFromText: Yt,
	initialize: Jt,
	getConfig: f,
	setConfig: te,
	getSiteConfig: g,
	updateSiteConfig: ne,
	reset: /* @__PURE__ */ e(() => {
		y();
	}, "reset"),
	globalReset: /* @__PURE__ */ e(() => {
		y(c);
	}, "globalReset"),
	defaultConfig: c
});
n(f().logLevel), y(f());
var Zt = /* @__PURE__ */ e((e, n, r) => {
	t.warn(e), se(e) ? (r && r(e.str, e.hash), n.push({
		...e,
		message: e.str,
		error: e
	})) : (r && r(e), e instanceof Error && n.push({
		str: e.message,
		message: e.message,
		hash: e.name,
		error: e
	}));
}, "handleError"), Qt = /* @__PURE__ */ e(async function(e = { querySelector: ".mermaid" }) {
	try {
		await $t(e);
	} catch (n) {
		if (se(n) && t.error(n.str), $.parseError && $.parseError(n), !e.suppressErrors) throw t.error("Use the suppressErrors option to suppress these errors"), n;
	}
}, "run"), $t = /* @__PURE__ */ e(async function({ postRenderCallback: e, querySelector: n, nodes: r } = { querySelector: ".mermaid" }) {
	let i = Y.getConfig();
	t.debug(`${e ? "" : "No "}Callback function found`);
	let a;
	if (r) a = r;
	else if (n) a = document.querySelectorAll(n);
	else throw Error("Nodes and querySelector are both undefined");
	t.debug(`Found ${a.length} diagrams`), i?.startOnLoad !== void 0 && (t.debug("Start On Load: " + i?.startOnLoad), Y.updateSiteConfig({ startOnLoad: i?.startOnLoad }));
	let o = new D.InitIDGenerator(i.deterministicIds, i.deterministicIDSeed), s, c = [];
	for (let n of Array.from(a)) {
		if (t.info("Rendering diagram: " + n.id), n.getAttribute("data-processed")) continue;
		n.setAttribute("data-processed", "true");
		let r = `mermaid-${o.next()}`;
		s = n.innerHTML, s = le(D.entityDecode(s)).trim().replace(/<br\s*\/?>/gi, "<br/>");
		let i = D.detectInit(s);
		i && t.debug("Detected early reinit: ", i);
		try {
			let { svg: t, bindFunctions: i } = await Q(r, s, n);
			n.innerHTML = t, e && await e(r), i && i(n);
		} catch (e) {
			Zt(e, c, $.parseError);
		}
	}
	if (c.length > 0) throw c[0];
}, "runThrowsErrors"), en = /* @__PURE__ */ e(function(e) {
	Y.initialize(e);
}, "initialize"), tn = /* @__PURE__ */ e(async function(e, n, r) {
	t.warn("mermaid.init is deprecated. Please use run instead."), e && en(e);
	let i = {
		postRenderCallback: r,
		querySelector: ".mermaid"
	};
	typeof n == "string" ? i.querySelector = n : n && (n instanceof HTMLElement ? i.nodes = [n] : i.nodes = n), await Qt(i);
}, "init"), nn = /* @__PURE__ */ e(async (e, { lazyLoad: t = !0 } = {}) => {
	U(), v(...e), t === !1 && await pt();
}, "registerExternalDiagrams"), rn = /* @__PURE__ */ e(function() {
	if ($.startOnLoad) {
		let { startOnLoad: e } = Y.getConfig();
		e && $.run().catch((e) => t.error("Mermaid failed to initialize", e));
	}
}, "contentLoaded");
typeof document < "u" && window.addEventListener("load", rn, !1);
var an = /* @__PURE__ */ e(function(e) {
	$.parseError = e;
}, "setParseErrorHandler"), X = [], Z = !1, on = /* @__PURE__ */ e(async () => {
	if (!Z) {
		for (Z = !0; X.length > 0;) {
			let e = X.shift();
			if (e) try {
				await e();
			} catch (e) {
				t.error("Error executing queue", e);
			}
		}
		Z = !1;
	}
}, "executeQueue"), sn = /* @__PURE__ */ e(async (n, r) => new Promise((i, a) => {
	let o = /* @__PURE__ */ e(() => new Promise((e, o) => {
		Y.parse(n, r).then((t) => {
			e(t), i(t);
		}, (e) => {
			t.error("Error parsing", e), $.parseError?.(e), o(e), a(e);
		});
	}), "performCall");
	X.push(o), on().catch(a);
}), "parse"), Q = /* @__PURE__ */ e((n, r, i) => new Promise((a, o) => {
	let s = /* @__PURE__ */ e(() => new Promise((e, s) => {
		Y.render(n, r, i).then((t) => {
			e(t), a(t);
		}, (e) => {
			t.error("Error parsing", e), $.parseError?.(e), s(e), o(e);
		});
	}), "performCall");
	X.push(s), on().catch(o);
}), "render"), $ = {
	startOnLoad: !0,
	mermaidAPI: Y,
	parse: sn,
	render: Q,
	init: tn,
	run: Qt,
	registerExternalDiagrams: nn,
	registerLayoutLoaders: de,
	initialize: en,
	parseError: void 0,
	contentLoaded: rn,
	setParseErrorHandler: an,
	detectType: l,
	registerIconPacks: ue,
	getRegisteredDiagramsMetadata: /* @__PURE__ */ e(() => Object.keys(u).map((e) => ({ id: e })), "getRegisteredDiagramsMetadata")
}, cn = $;
//#endregion
export { cn as mermaid_default };
