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, cssStyleSheetToString as c, defaultConfig as l, detectType as u, detectors as d, evaluate as ee, frontMatterRegex as f, getConfig as p, getDiagram as m, getDiagramLoader as h, getEffectiveHtmlLabels as g, getSiteConfig as _, registerDiagram as v, registerLazyLoadedDiagrams as y, reset as b, sanitizeCss as te, saveConfigFromInitialize as x, setConfig as S, setSiteConfig as ne, styles_default as re, themes_default as C, updateSiteConfig as w } from "./chunks/mermaid.core/chunk-CSCIHK7Q.js";
import T from "../../d3-selection/src/select.js";
import "../../d3/src/index.js";
import { selectSvgElement as ie } from "./chunks/mermaid.core/chunk-WU5MYG2G.js";
import { isEmpty as E } from "../../es-toolkit/dist/compat/predicate/isEmpty.js";
import { cleanAndMerge as ae, decodeEntities as D, encodeEntities as oe, isDetailedError as se, removeDirectives as ce, utils_default as O } from "./chunks/mermaid.core/chunk-5ZQYHXKU.js";
import le from "../../ts-dedent/esm/index.js";
import { registerIconPacks as ue } from "./chunks/mermaid.core/chunk-O5CBEL6O.js";
import "./chunks/mermaid.core/chunk-BSJP7CBP.js";
import "./chunks/mermaid.core/chunk-L5ZTLDWV.js";
import "./chunks/mermaid.core/chunk-NZK2D7GU.js";
import "./chunks/mermaid.core/chunk-3OPIFGDE.js";
import "./chunks/mermaid.core/chunk-KSCS5N6A.js";
import { registerLayoutLoaders as de } from "./chunks/mermaid.core/chunk-LZXEDZCA.js";
import { JSON_SCHEMA as fe, load as pe } from "./chunks/mermaid.core/chunk-XPW4576I.js";
import { COMMENT as me } from "../../stylis/src/Enum.js";
import { compile as he } from "../../stylis/src/Parser.js";
import { serialize as ge, stringify as _e } from "../../stylis/src/Serializer.js";
import { middleware as ve } from "../../stylis/src/Middleware.js";
//#region ../../node_modules/mermaid/dist/mermaid.core.mjs
var k = "c4", ye = {
	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-AAUBKEIU.js");
		return {
			id: k,
			diagram: e
		};
	}, "loader")
}, A = "flowchart", be = {
	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-I6XJVG4X.js");
		return {
			id: A,
			diagram: e
		};
	}, "loader")
}, j = "flowchart-v2", xe = {
	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-I6XJVG4X.js");
		return {
			id: j,
			diagram: e
		};
	}, "loader")
}, M = "er", Se = {
	id: M,
	detector: /* @__PURE__ */ e((e) => /^\s*erDiagram/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/erDiagram-TEJ5UH35.js");
		return {
			id: M,
			diagram: e
		};
	}, "loader")
}, N = "gitGraph", Ce = {
	id: N,
	detector: /* @__PURE__ */ e((e) => /^\s*gitGraph/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/gitGraphDiagram-PVQCEYII.js");
		return {
			id: N,
			diagram: e
		};
	}, "loader")
}, P = "gantt", we = {
	id: P,
	detector: /* @__PURE__ */ e((e) => /^\s*gantt/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/ganttDiagram-6RSMTGT7.js");
		return {
			id: P,
			diagram: e
		};
	}, "loader")
}, F = "info", Te = {
	id: F,
	detector: /* @__PURE__ */ e((e) => /^\s*info/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/infoDiagram-5YYISTIA.js");
		return {
			id: F,
			diagram: e
		};
	}, "loader")
}, I = "pie", Ee = {
	id: I,
	detector: /* @__PURE__ */ e((e) => /^\s*pie/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/pieDiagram-4H26LBE5.js");
		return {
			id: I,
			diagram: e
		};
	}, "loader")
}, L = "quadrantChart", De = {
	id: L,
	detector: /* @__PURE__ */ e((e) => /^\s*quadrantChart/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/quadrantDiagram-W4KKPZXB.js");
		return {
			id: L,
			diagram: e
		};
	}, "loader")
}, R = "xychart", Oe = {
	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-2RQKCTM6.js");
		return {
			id: R,
			diagram: e
		};
	}, "loader")
}, z = "requirement", ke = {
	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-4Y6WPE33.js");
		return {
			id: z,
			diagram: e
		};
	}, "loader")
}, B = "sequence", Ae = {
	id: B,
	detector: /* @__PURE__ */ e((e) => /^\s*sequenceDiagram/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/sequenceDiagram-3UESZ5HK.js");
		return {
			id: B,
			diagram: e
		};
	}, "loader")
}, V = "class", je = {
	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-4FO5ZUOK.js");
		return {
			id: V,
			diagram: e
		};
	}, "loader")
}, H = "classDiagram", Me = {
	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-Q7XG4LA2.js");
		return {
			id: H,
			diagram: e
		};
	}, "loader")
}, Ne = "state", Pe = {
	id: Ne,
	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-AJRCARHV.js");
		return {
			id: Ne,
			diagram: e
		};
	}, "loader")
}, Fe = "stateDiagram", Ie = {
	id: Fe,
	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-BHNVJYJU.js");
		return {
			id: Fe,
			diagram: e
		};
	}, "loader")
}, Le = "journey", Re = {
	id: Le,
	detector: /* @__PURE__ */ e((e) => /^\s*journey/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/journeyDiagram-JHISSGLW.js");
		return {
			id: Le,
			diagram: e
		};
	}, "loader")
}, ze = { draw: /* @__PURE__ */ e((e, n, r) => {
	t.debug("rendering svg for syntax error\n");
	let i = ie(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") }, Be = ze, Ve = {
	db: {},
	renderer: ze,
	parser: { parse: /* @__PURE__ */ e(() => {}, "parse") }
}, He = "flowchart-elk", Ue = {
	id: He,
	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-I6XJVG4X.js");
		return {
			id: He,
			diagram: e
		};
	}, "loader")
}, We = "timeline", Ge = {
	id: We,
	detector: /* @__PURE__ */ e((e) => /^\s*timeline/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/timeline-definition-PNZ67QCA.js");
		return {
			id: We,
			diagram: e
		};
	}, "loader")
}, Ke = "mindmap", qe = {
	id: Ke,
	detector: /* @__PURE__ */ e((e) => /^\s*mindmap/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/mindmap-definition-RKZ34NQL.js");
		return {
			id: Ke,
			diagram: e
		};
	}, "loader")
}, Je = "kanban", Ye = {
	id: Je,
	detector: /* @__PURE__ */ e((e) => /^\s*kanban/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/kanban-definition-UN3LZRKU.js");
		return {
			id: Je,
			diagram: e
		};
	}, "loader")
}, Xe = "sankey", Ze = {
	id: Xe,
	detector: /* @__PURE__ */ e((e) => /^\s*sankey(-beta)?/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/sankeyDiagram-5OEKKPKP.js");
		return {
			id: Xe,
			diagram: e
		};
	}, "loader")
}, Qe = "packet", $e = {
	id: Qe,
	detector: /* @__PURE__ */ e((e) => /^\s*packet(-beta)?/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/diagram-LMA3HP47.js");
		return {
			id: Qe,
			diagram: e
		};
	}, "loader")
}, et = "radar", tt = {
	id: et,
	detector: /* @__PURE__ */ e((e) => /^\s*radar-beta/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/diagram-2AECGRRQ.js");
		return {
			id: et,
			diagram: e
		};
	}, "loader")
}, nt = "block", rt = {
	id: nt,
	detector: /* @__PURE__ */ e((e) => /^\s*block(-beta)?/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/blockDiagram-GPEHLZMM.js");
		return {
			id: nt,
			diagram: e
		};
	}, "loader")
}, it = "treeView", at = {
	id: it,
	detector: /* @__PURE__ */ e((e) => /^\s*treeView-beta/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/diagram-5GNKFQAL.js");
		return {
			id: it,
			diagram: e
		};
	}, "loader")
}, ot = "architecture", st = {
	id: ot,
	detector: /* @__PURE__ */ e((e) => /^\s*architecture/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/architectureDiagram-3BPJPVTR.js");
		return {
			id: ot,
			diagram: e
		};
	}, "loader")
}, ct = "eventmodeling", lt = {
	id: ct,
	detector: /* @__PURE__ */ e((e) => /^\s*eventmodeling/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/diagram-KO2AKTUF.js");
		return {
			id: ct,
			diagram: e
		};
	}, "loader")
}, ut = "ishikawa", dt = {
	id: ut,
	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-YF4QCWOH.js");
		return {
			id: ut,
			diagram: e
		};
	}, "loader")
}, ft = "venn", pt = {
	id: ft,
	detector: /* @__PURE__ */ e((e) => /^\s*venn-beta/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/vennDiagram-CIIHVFJN.js");
		return {
			id: ft,
			diagram: e
		};
	}, "loader")
}, mt = "treemap", ht = {
	id: mt,
	detector: /* @__PURE__ */ e((e) => /^\s*treemap/.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/diagram-OG6HWLK6.js");
		return {
			id: mt,
			diagram: e
		};
	}, "loader")
}, gt = "wardley-beta", _t = {
	id: gt,
	detector: /* @__PURE__ */ e((e) => /^\s*wardley-beta/i.test(e), "detector"),
	loader: /* @__PURE__ */ e(async () => {
		let { diagram: e } = await import("./chunks/mermaid.core/wardleyDiagram-YWT4CUSO.js");
		return {
			id: gt,
			diagram: e
		};
	}, "loader")
}, vt = !1, U = /* @__PURE__ */ e(() => {
	vt || (vt = !0, v("error", Ve, (e) => e.toLowerCase().trim() === "error"), v("---", {
		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("---")), y(Ue, qe, st), y(ye, Ye, Me, je, Se, we, Te, Ee, ke, Ae, xe, be, Ge, Ce, Ie, Pe, Re, De, Ze, $e, Oe, rt, lt, at, tt, dt, ht, pt, _t));
}, "addDiagrams"), yt = /* @__PURE__ */ e(async () => {
	t.debug("Loading registered diagrams");
	let e = (await Promise.allSettled(Object.entries(d).map(async ([e, { detector: n, loader: r }]) => {
		if (r) try {
			m(e);
		} catch {
			try {
				let { diagram: e, id: t } = await r();
				v(t, e, n);
			} catch (n) {
				throw t.error(`Failed to load external diagram with key ${e}. Removing from detectors.`), delete d[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"), bt = "graphics-document document";
function xt(e, t) {
	e.attr("role", bt), t !== "" && e.attr("aria-roledescription", t);
}
e(xt, "setA11yDiagramInfo");
function St(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(St, "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 = p(), a = u(e, r);
		e = oe(e) + "\n";
		try {
			m(a);
		} catch {
			let e = h(a);
			if (!e) throw new i(`Diagram ${a} not found.`);
			let { id: t, diagram: n } = await e();
			v(t, n);
		}
		let { db: o, parser: s, renderer: c, init: l } = m(a);
		return s.parser && (s.parser.yy = o), o.clear?.(), l?.(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;
	}
}, Ct = [], wt = /* @__PURE__ */ e(() => {
	Ct.forEach((e) => {
		e();
	}), Ct = [];
}, "attachFunctions"), Tt = /* @__PURE__ */ e((e) => e.replace(/^\s*%%(?!{)[^\n]+\n?/gm, "").trimStart(), "cleanupComments");
function Et(e) {
	let t = e.match(f);
	if (!t) return {
		text: e,
		metadata: {}
	};
	let n = pe(t[1], { schema: fe }) ?? {};
	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(Et, "extractFrontMatter");
var Dt = /* @__PURE__ */ e((e) => e.replace(/\r\n?/g, "\n").replace(/<(\w+)([^>]*)>/g, (e, t, n) => "<" + t + n.replace(/="([^"]*)"/g, "='$1'") + ">"), "cleanupText"), Ot = /* @__PURE__ */ e((e) => {
	let { text: t, metadata: n } = Et(e), { displayMode: r, title: i, config: a = {} } = n;
	return r && (a.gantt ||= {}, a.gantt.displayMode = r), {
		title: i,
		config: a,
		text: t
	};
}, "processFrontmatter"), kt = /* @__PURE__ */ e((e) => {
	let t = O.detectInit(e) ?? {}, n = O.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 = Ot(Dt(e)), n = kt(t.text), r = ae(t.config, n.directive);
	return e = Tt(n.text), {
		code: e,
		title: t.title,
		config: r
	};
}
e(G, "preprocessDiagram");
function At(e) {
	let t = new TextEncoder().encode(e), n = Array.from(t, (e) => String.fromCodePoint(e)).join("");
	return btoa(n);
}
e(At, "toBase64");
var jt = 5e4, Mt = "graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa", Nt = "sandbox", Pt = "loose", Ft = "http://www.w3.org/2000/svg", It = "http://www.w3.org/1999/xlink", Lt = "http://www.w3.org/1999/xhtml", Rt = "100%", zt = "100%", Bt = "border:0;margin:0;", Vt = "margin:0", Ht = "allow-top-navigation-by-user-activation allow-popups", Ut = "The \"iframe\" tag is not supported by your browser.", Wt = ["foreignobject"], Gt = ["dominant-baseline"];
function K(e) {
	let t = G(e);
	return b(), a(t.config ?? {}), t;
}
e(K, "processAndSetConfigs");
async function Kt(e, t) {
	U();
	try {
		let { code: t, config: n } = K(e);
		return {
			diagramType: (await nn(t)).type,
			config: n
		};
	} catch (e) {
		if (t?.suppressErrors) return !1;
		throw e;
	}
}
e(Kt, "parse");
var qt = /* @__PURE__ */ e((e, t, n = []) => `.${e} ${t} ${te(`{ ${n.join(" !important; ")} !important; }`)}`, "cssImportantStyles"), Jt = /* @__PURE__ */ e((e, t = /* @__PURE__ */ new Map()) => {
	let n = new CSSStyleSheet();
	if (e.fontFamily !== void 0 && n.insertRule(`:root { --mermaid-font-family: ${e.fontFamily}}`, n.cssRules.length), e.altFontFamily !== void 0 && n.insertRule(`:root { --mermaid-alt-font-family: ${e.altFontFamily}}`, n.cssRules.length), t instanceof Map) {
		let r = g(e) ? ["> *", "span"] : [
			"rect",
			"polygon",
			"ellipse",
			"circle",
			"path"
		];
		t.forEach((e) => {
			E(e.styles) || r.forEach((t) => {
				n.insertRule(qt(e.id, t, e.styles), n.cssRules.length);
			}), E(e.textStyles) || n.insertRule(qt(e.id, "tspan", (e?.textStyles || []).map((e) => e.replace("color", "fill"))), n.cssRules.length);
		});
	}
	let r = "";
	if (e.themeCSS !== void 0) if (typeof n.replaceSync == "function") {
		let t = new CSSStyleSheet();
		t.replaceSync(e.themeCSS), r = c(t) + "\n";
	} else r += `${e.themeCSS}
`;
	return r + c(n);
}, "createCssStyles"), Yt = /* @__PURE__ */ e((n, r) => ge(he(`${n}{${r}}`), ve([/* @__PURE__ */ e(function(e, r, i, a) {
	if (e.type === "rule" && Array.isArray(e.props)) {
		if (e.parent && e.parent.type === "@keyframes") return;
		e.props = e.props.map((e) => e.startsWith(n) ? e : `${n} ${e}`);
	} else e.type.startsWith("@") && ([
		"@media",
		"@supports",
		"@layer",
		"@scope",
		"@container",
		"@starting-style",
		"@keyframes"
	].includes(e.type) || (t.warn(`Removing unsupported at-rule ${e.type} from CSS`), e.type = me));
}, "addNamespace"), _e])), "compileCSS"), Xt = /* @__PURE__ */ e((e, t, n, r) => Yt(r, re(t, Jt(e, n), {
	...e.themeVariables,
	theme: e.theme,
	look: e.look
}, r)), "createUserStyles"), Zt = /* @__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 = D(r), r = r.replace(/<br>/g, "<br/>"), r;
}, "cleanUpSvgCode"), Qt = /* @__PURE__ */ e((e = "", t) => `<iframe style="width:${Rt};height:${t?.viewBox?.baseVal?.height ? t.viewBox.baseVal.height + "px" : zt};${Bt}" src="data:text/html;charset=UTF-8;base64,${At(`<body style="${Vt}">${e}</body>`)}" sandbox="${Ht}">
  ${Ut}
</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", Ft);
	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 $t = /* @__PURE__ */ e((e, t, n, r) => {
	e.getElementById(t)?.remove(), e.getElementById(n)?.remove(), e.getElementById(r)?.remove();
}, "removeExistingElements"), en = /* @__PURE__ */ e(async function(n, i, a) {
	U();
	let o = K(i);
	i = o.code;
	let s = p();
	t.debug(s), i.length > (s?.maxTextSize ?? jt) && (i = Mt);
	let c = `#${n}`, l = "i" + n, u = "#" + l, d = "d" + n, f = "#" + d, m = /* @__PURE__ */ e(() => {
		let e = T(g ? u : f).node();
		e && "remove" in e && e.remove();
	}, "removeTempElements"), h = T(document.body), g = s.securityLevel === Nt, _ = s.securityLevel === Pt, v = s.fontFamily;
	a === void 0 ? ($t(document, n, d, l), g ? (h = T(J(T(document.body), l).nodes()[0].contentDocument.body), h.node().style.margin = "0") : h = T("body"), q(h, n, d)) : (a && (a.innerHTML = ""), g ? (h = T(J(T(a), l).nodes()[0].contentDocument.body), h.node().style.margin = "0") : h = T(a), q(h, n, d, `font-family: ${v}`, It));
	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(f).node(), x = y.type, S = te.firstChild, ne = S.firstChild, re = y.renderer.getClasses?.(i, y), C = Xt(s, x, re, c), w = document.createElement("style");
	w.innerHTML = C, S.insertBefore(w, ne);
	try {
		await y.renderer.draw(i, n, "11.15.0", y);
	} catch (e) {
		throw s.suppressErrorRendering ? m() : Be.draw(i, n, "11.15.0"), e;
	}
	let ie = h.select(`${f} svg`), E = y.db.getAccTitle?.(), ae = y.db.getAccDescription?.();
	rn(x, ie, E, ae), h.select(`[id="${n}"]`).selectAll("foreignobject > *").attr("xmlns", Lt);
	let D = h.select(f).node().innerHTML;
	if (t.debug("config.arrowMarkerAbsolute", s.arrowMarkerAbsolute), D = Zt(D, g, ee(s.arrowMarkerAbsolute)), g) {
		let e = h.select(f + " svg").node();
		D = Qt(D, e);
	} else _ || (D = r.sanitize(D, {
		ADD_TAGS: Wt,
		ADD_ATTR: Gt,
		HTML_INTEGRATION_POINTS: { foreignobject: !0 }
	}));
	if (wt(), b) throw b;
	return m(), {
		diagramType: x,
		svg: D,
		bindFunctions: y.db.bindFunctions
	};
}, "render");
function tn(e = {}) {
	let t = o({}, e);
	t?.fontFamily && !t.themeVariables?.fontFamily && (t.themeVariables ||= {}, t.themeVariables.fontFamily = t.fontFamily), x(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" ? ne(t) : _()).logLevel), U();
}
e(tn, "initialize");
var nn = /* @__PURE__ */ e((e, t = {}) => {
	let { code: n } = G(e);
	return W.fromText(n, t);
}, "getDiagramFromText");
function rn(e, t, n, r) {
	xt(t, e), St(t, n, r, t.attr("id"));
}
e(rn, "addA11yInfo");
var Y = Object.freeze({
	render: en,
	parse: Kt,
	getDiagramFromText: nn,
	initialize: tn,
	getConfig: p,
	setConfig: S,
	getSiteConfig: _,
	updateSiteConfig: w,
	reset: /* @__PURE__ */ e(() => {
		b();
	}, "reset"),
	globalReset: /* @__PURE__ */ e(() => {
		b(l);
	}, "globalReset"),
	defaultConfig: l
});
n(p().logLevel), b(p());
var an = /* @__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"), on = /* @__PURE__ */ e(async function(e = { querySelector: ".mermaid" }) {
	try {
		await sn(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"), sn = /* @__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 O.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(O.entityDecode(s)).trim().replace(/<br\s*\/?>/gi, "<br/>");
		let i = O.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) {
			an(e, c, $.parseError);
		}
	}
	if (c.length > 0) throw c[0];
}, "runThrowsErrors"), cn = /* @__PURE__ */ e(function(e) {
	Y.initialize(e);
}, "initialize"), ln = /* @__PURE__ */ e(async function(e, n, r) {
	t.warn("mermaid.init is deprecated. Please use run instead."), e && cn(e);
	let i = {
		postRenderCallback: r,
		querySelector: ".mermaid"
	};
	typeof n == "string" ? i.querySelector = n : n && (n instanceof HTMLElement ? i.nodes = [n] : i.nodes = n), await on(i);
}, "init"), un = /* @__PURE__ */ e(async (e, { lazyLoad: t = !0 } = {}) => {
	U(), y(...e), t === !1 && await yt();
}, "registerExternalDiagrams"), dn = /* @__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", dn, !1);
var fn = /* @__PURE__ */ e(function(e) {
	$.parseError = e;
}, "setParseErrorHandler"), X = [], Z = !1, pn = /* @__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"), mn = /* @__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), pn().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), pn().catch(o);
}), "render"), $ = {
	startOnLoad: !0,
	mermaidAPI: Y,
	parse: mn,
	render: Q,
	init: ln,
	run: on,
	registerExternalDiagrams: un,
	registerLayoutLoaders: de,
	initialize: cn,
	parseError: void 0,
	contentLoaded: dn,
	setParseErrorHandler: fn,
	detectType: u,
	registerIconPacks: ue,
	getRegisteredDiagramsMetadata: /* @__PURE__ */ e(() => Object.keys(d).map((e) => ({ id: e })), "getRegisteredDiagramsMetadata")
}, hn = $;
//#endregion
export { hn as default };

//# sourceMappingURL=mermaid.core.js.map