import { h as e, p as t, r as n } from "./chunk-GEFDOKGD-8e2771NL.js";
import { g as r, h as i, p as a } from "./src-DI0MZP4m.js";
import { B as o, C as s, V as c, W as l, _ as u, a as d, d as f, q as ee, s as p, v as te, y as m } from "./chunk-7R4GIKGN-C19ZEV_b.js";
import { t as h } from "./chunk-4BX2VUAB-D3p73nhw.js";
import { t as g } from "./mermaid-parser.core-l4wHnGuN.js";
import { t as ne } from "./chunk-QZHKN3VN-3LiJhn2O.js";
//#region node_modules/mermaid/dist/chunks/mermaid.core/gitGraphDiagram-K3NZZRJ6.mjs
var _ = {
	NORMAL: 0,
	REVERSE: 1,
	HIGHLIGHT: 2,
	MERGE: 3,
	CHERRY_PICK: 4
}, re = f.gitGraph, v = /* @__PURE__ */ i(() => n({
	...re,
	...m().gitGraph
}), "getConfig"), y = new ne(() => {
	let e = v(), t = e.mainBranchName, n = e.mainBranchOrder;
	return {
		mainBranchName: t,
		commits: /* @__PURE__ */ new Map(),
		head: null,
		branchConfig: /* @__PURE__ */ new Map([[t, {
			name: t,
			order: n
		}]]),
		branches: /* @__PURE__ */ new Map([[t, null]]),
		currBranch: t,
		direction: "LR",
		seq: 0,
		options: {}
	};
});
function b() {
	return t({ length: 7 });
}
i(b, "getID");
function x(e, t) {
	let n = /* @__PURE__ */ Object.create(null);
	return e.reduce((e, r) => {
		let i = t(r);
		return n[i] || (n[i] = !0, e.push(r)), e;
	}, []);
}
i(x, "uniqBy");
var S = /* @__PURE__ */ i(function(e) {
	y.records.direction = e;
}, "setDirection"), C = /* @__PURE__ */ i(function(e) {
	r.debug("options str", e), e = e?.trim(), e ||= "{}";
	try {
		y.records.options = JSON.parse(e);
	} catch (e) {
		r.error("error while parsing gitGraph options", e.message);
	}
}, "setOptions"), ie = /* @__PURE__ */ i(function() {
	return y.records.options;
}, "getOptions"), ae = /* @__PURE__ */ i(function(e) {
	let t = e.msg, n = e.id, i = e.type, a = e.tags;
	r.info("commit", t, n, i, a), r.debug("Entering commit:", t, n, i, a);
	let o = v();
	n = p.sanitizeText(n, o), t = p.sanitizeText(t, o), a = a?.map((e) => p.sanitizeText(e, o));
	let s = {
		id: n || y.records.seq + "-" + b(),
		message: t,
		seq: y.records.seq++,
		type: i ?? _.NORMAL,
		tags: a ?? [],
		parents: y.records.head == null ? [] : [y.records.head.id],
		branch: y.records.currBranch
	};
	y.records.head = s, r.info("main branch", o.mainBranchName), y.records.commits.has(s.id) && r.warn(`Commit ID ${s.id} already exists`), y.records.commits.set(s.id, s), y.records.branches.set(y.records.currBranch, s.id), r.debug("in pushCommit " + s.id);
}, "commit"), oe = /* @__PURE__ */ i(function(e) {
	let t = e.name, n = e.order;
	if (t = p.sanitizeText(t, v()), y.records.branches.has(t)) throw Error(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${t}")`);
	y.records.branches.set(t, y.records.head == null ? null : y.records.head.id), y.records.branchConfig.set(t, {
		name: t,
		order: n
	}), w(t), r.debug("in createBranch");
}, "branch"), se = /* @__PURE__ */ i((e) => {
	let t = e.branch, n = e.id, i = e.type, a = e.tags, o = v();
	t = p.sanitizeText(t, o), n &&= p.sanitizeText(n, o);
	let s = y.records.branches.get(y.records.currBranch), c = y.records.branches.get(t), l = s ? y.records.commits.get(s) : void 0, u = c ? y.records.commits.get(c) : void 0;
	if (l && u && l.branch === t) throw Error(`Cannot merge branch '${t}' into itself.`);
	if (y.records.currBranch === t) {
		let e = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Cannot merge a branch to itself");
		throw e.hash = {
			text: `merge ${t}`,
			token: `merge ${t}`,
			expected: ["branch abc"]
		}, e;
	}
	if (l === void 0 || !l) {
		let e = /* @__PURE__ */ Error(`Incorrect usage of "merge". Current branch (${y.records.currBranch})has no commits`);
		throw e.hash = {
			text: `merge ${t}`,
			token: `merge ${t}`,
			expected: ["commit"]
		}, e;
	}
	if (!y.records.branches.has(t)) {
		let e = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Branch to be merged (" + t + ") does not exist");
		throw e.hash = {
			text: `merge ${t}`,
			token: `merge ${t}`,
			expected: [`branch ${t}`]
		}, e;
	}
	if (u === void 0 || !u) {
		let e = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Branch to be merged (" + t + ") has no commits");
		throw e.hash = {
			text: `merge ${t}`,
			token: `merge ${t}`,
			expected: ["\"commit\""]
		}, e;
	}
	if (l === u) {
		let e = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Both branches have same head");
		throw e.hash = {
			text: `merge ${t}`,
			token: `merge ${t}`,
			expected: ["branch abc"]
		}, e;
	}
	if (n && y.records.commits.has(n)) {
		let e = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Commit with id:" + n + " already exists, use different custom id");
		throw e.hash = {
			text: `merge ${t} ${n} ${i} ${a?.join(" ")}`,
			token: `merge ${t} ${n} ${i} ${a?.join(" ")}`,
			expected: [`merge ${t} ${n}_UNIQUE ${i} ${a?.join(" ")}`]
		}, e;
	}
	let d = c || "", f = {
		id: n || `${y.records.seq}-${b()}`,
		message: `merged branch ${t} into ${y.records.currBranch}`,
		seq: y.records.seq++,
		parents: y.records.head == null ? [] : [y.records.head.id, d],
		branch: y.records.currBranch,
		type: _.MERGE,
		customType: i,
		customId: !!n,
		tags: a ?? []
	};
	y.records.head = f, y.records.commits.set(f.id, f), y.records.branches.set(y.records.currBranch, f.id), r.debug(y.records.branches), r.debug("in mergeBranch");
}, "merge"), ce = /* @__PURE__ */ i(function(e) {
	let t = e.id, n = e.targetId, i = e.tags, a = e.parent;
	r.debug("Entering cherryPick:", t, n, i);
	let o = v();
	if (t = p.sanitizeText(t, o), n = p.sanitizeText(n, o), i = i?.map((e) => p.sanitizeText(e, o)), a = p.sanitizeText(a, o), !t || !y.records.commits.has(t)) {
		let e = /* @__PURE__ */ Error("Incorrect usage of \"cherryPick\". Source commit id should exist and provided");
		throw e.hash = {
			text: `cherryPick ${t} ${n}`,
			token: `cherryPick ${t} ${n}`,
			expected: ["cherry-pick abc"]
		}, e;
	}
	let s = y.records.commits.get(t);
	if (s === void 0 || !s) throw Error("Incorrect usage of \"cherryPick\". Source commit id should exist and provided");
	if (a && !(Array.isArray(s.parents) && s.parents.includes(a))) throw /* @__PURE__ */ Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");
	let c = s.branch;
	if (s.type === _.MERGE && !a) throw /* @__PURE__ */ Error("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.");
	if (!n || !y.records.commits.has(n)) {
		if (c === y.records.currBranch) {
			let e = /* @__PURE__ */ Error("Incorrect usage of \"cherryPick\". Source commit is already on current branch");
			throw e.hash = {
				text: `cherryPick ${t} ${n}`,
				token: `cherryPick ${t} ${n}`,
				expected: ["cherry-pick abc"]
			}, e;
		}
		let e = y.records.branches.get(y.records.currBranch);
		if (e === void 0 || !e) {
			let e = /* @__PURE__ */ Error(`Incorrect usage of "cherry-pick". Current branch (${y.records.currBranch})has no commits`);
			throw e.hash = {
				text: `cherryPick ${t} ${n}`,
				token: `cherryPick ${t} ${n}`,
				expected: ["cherry-pick abc"]
			}, e;
		}
		let o = y.records.commits.get(e);
		if (o === void 0 || !o) {
			let e = /* @__PURE__ */ Error(`Incorrect usage of "cherry-pick". Current branch (${y.records.currBranch})has no commits`);
			throw e.hash = {
				text: `cherryPick ${t} ${n}`,
				token: `cherryPick ${t} ${n}`,
				expected: ["cherry-pick abc"]
			}, e;
		}
		let l = {
			id: y.records.seq + "-" + b(),
			message: `cherry-picked ${s?.message} into ${y.records.currBranch}`,
			seq: y.records.seq++,
			parents: y.records.head == null ? [] : [y.records.head.id, s.id],
			branch: y.records.currBranch,
			type: _.CHERRY_PICK,
			tags: i ? i.filter(Boolean) : [`cherry-pick:${s.id}${s.type === _.MERGE ? `|parent:${a}` : ""}`]
		};
		y.records.head = l, y.records.commits.set(l.id, l), y.records.branches.set(y.records.currBranch, l.id), r.debug(y.records.branches), r.debug("in cherryPick");
	}
}, "cherryPick"), w = /* @__PURE__ */ i(function(e) {
	if (e = p.sanitizeText(e, v()), y.records.branches.has(e)) {
		y.records.currBranch = e;
		let t = y.records.branches.get(y.records.currBranch);
		t === void 0 || !t ? y.records.head = null : y.records.head = y.records.commits.get(t) ?? null;
	} else {
		let t = /* @__PURE__ */ Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${e}")`);
		throw t.hash = {
			text: `checkout ${e}`,
			token: `checkout ${e}`,
			expected: [`branch ${e}`]
		}, t;
	}
}, "checkout");
function T(e, t, n) {
	let r = e.indexOf(t);
	r === -1 ? e.push(n) : e.splice(r, 1, n);
}
i(T, "upsert");
function E(e) {
	let t = e.reduce((e, t) => e.seq > t.seq ? e : t, e[0]), n = "";
	e.forEach(function(e) {
		e === t ? n += "	*" : n += "	|";
	});
	let i = [
		n,
		t.id,
		t.seq
	];
	for (let e in y.records.branches) y.records.branches.get(e) === t.id && i.push(e);
	if (r.debug(i.join(" ")), t.parents && t.parents.length == 2 && t.parents[0] && t.parents[1]) {
		let n = y.records.commits.get(t.parents[0]);
		T(e, t, n), t.parents[1] && e.push(y.records.commits.get(t.parents[1]));
	} else if (t.parents.length == 0) return;
	else if (t.parents[0]) {
		let n = y.records.commits.get(t.parents[0]);
		T(e, t, n);
	}
	e = x(e, (e) => e.id), E(e);
}
i(E, "prettyPrintCommitHistory");
var le = /* @__PURE__ */ i(function() {
	r.debug(y.records.commits);
	let e = D()[0];
	E([e]);
}, "prettyPrint"), ue = /* @__PURE__ */ i(function() {
	y.reset(), d();
}, "clear"), de = /* @__PURE__ */ i(function() {
	return [...y.records.branchConfig.values()].map((e, t) => e.order !== null && e.order !== void 0 ? e : {
		...e,
		order: parseFloat(`0.${t}`)
	}).sort((e, t) => (e.order ?? 0) - (t.order ?? 0)).map(({ name: e }) => ({ name: e }));
}, "getBranchesAsObjArray"), fe = /* @__PURE__ */ i(function() {
	return y.records.branches;
}, "getBranches"), pe = /* @__PURE__ */ i(function() {
	return y.records.commits;
}, "getCommits"), D = /* @__PURE__ */ i(function() {
	let e = [...y.records.commits.values()];
	return e.forEach(function(e) {
		r.debug(e.id);
	}), e.sort((e, t) => e.seq - t.seq), e;
}, "getCommitsArray"), O = {
	commitType: _,
	getConfig: v,
	setDirection: S,
	setOptions: C,
	getOptions: ie,
	commit: ae,
	branch: oe,
	merge: se,
	cherryPick: ce,
	checkout: w,
	prettyPrint: le,
	clear: ue,
	getBranchesAsObjArray: de,
	getBranches: fe,
	getCommits: pe,
	getCommitsArray: D,
	getCurrentBranch: /* @__PURE__ */ i(function() {
		return y.records.currBranch;
	}, "getCurrentBranch"),
	getDirection: /* @__PURE__ */ i(function() {
		return y.records.direction;
	}, "getDirection"),
	getHead: /* @__PURE__ */ i(function() {
		return y.records.head;
	}, "getHead"),
	setAccTitle: c,
	getAccTitle: te,
	getAccDescription: u,
	setAccDescription: o,
	setDiagramTitle: l,
	getDiagramTitle: s
}, k = /* @__PURE__ */ i((e, t) => {
	h(e, t), e.dir && t.setDirection(e.dir);
	for (let n of e.statements) A(n, t);
}, "populate"), A = /* @__PURE__ */ i((e, t) => {
	let n = {
		Commit: /* @__PURE__ */ i((e) => t.commit(j(e)), "Commit"),
		Branch: /* @__PURE__ */ i((e) => t.branch(M(e)), "Branch"),
		Merge: /* @__PURE__ */ i((e) => t.merge(N(e)), "Merge"),
		Checkout: /* @__PURE__ */ i((e) => t.checkout(P(e)), "Checkout"),
		CherryPicking: /* @__PURE__ */ i((e) => t.cherryPick(F(e)), "CherryPicking")
	}[e.$type];
	n ? n(e) : r.error(`Unknown statement type: ${e.$type}`);
}, "parseStatement"), j = /* @__PURE__ */ i((e) => ({
	id: e.id,
	msg: e.message ?? "",
	type: e.type === void 0 ? _.NORMAL : _[e.type],
	tags: e.tags ?? void 0
}), "parseCommit"), M = /* @__PURE__ */ i((e) => ({
	name: e.name,
	order: e.order ?? 0
}), "parseBranch"), N = /* @__PURE__ */ i((e) => ({
	branch: e.branch,
	id: e.id ?? "",
	type: e.type === void 0 ? void 0 : _[e.type],
	tags: e.tags ?? void 0
}), "parseMerge"), P = /* @__PURE__ */ i((e) => e.branch, "parseCheckout"), F = /* @__PURE__ */ i((e) => ({
	id: e.id,
	targetId: "",
	tags: e.tags?.length === 0 ? void 0 : e.tags,
	parent: e.parent
}), "parseCherryPicking"), I = { parse: /* @__PURE__ */ i(async (e) => {
	let t = await g("gitGraph", e);
	r.debug(t), k(t, O);
}, "parse") }, L = 10, R = 40, z = 4, B = 2, V = 8, H = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map(), W = 30, G = /* @__PURE__ */ new Map(), K = [], q = 0, J = "LR", me = /* @__PURE__ */ i(() => {
	H.clear(), U.clear(), G.clear(), q = 0, K = [], J = "LR";
}, "clear"), Y = /* @__PURE__ */ i((e) => {
	let t = document.createElementNS("http://www.w3.org/2000/svg", "text");
	return (typeof e == "string" ? e.split(/\\n|\n|<br\s*\/?>/gi) : e).forEach((e) => {
		let n = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
		n.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"), n.setAttribute("dy", "1em"), n.setAttribute("x", "0"), n.setAttribute("class", "row"), n.textContent = e.trim(), t.appendChild(n);
	}), t;
}, "drawText"), X = /* @__PURE__ */ i((e) => {
	let t, n, r;
	return J === "BT" ? (n = /* @__PURE__ */ i((e, t) => e <= t, "comparisonFunc"), r = Infinity) : (n = /* @__PURE__ */ i((e, t) => e >= t, "comparisonFunc"), r = 0), e.forEach((e) => {
		let i = J === "TB" || J == "BT" ? U.get(e)?.y : U.get(e)?.x;
		i !== void 0 && n(i, r) && (t = e, r = i);
	}), t;
}, "findClosestParent"), he = /* @__PURE__ */ i((e) => {
	let t = "", n = Infinity;
	return e.forEach((e) => {
		let r = U.get(e).y;
		r <= n && (t = e, n = r);
	}), t || void 0;
}, "findClosestParentBT"), ge = /* @__PURE__ */ i((e, t, n) => {
	let r = n, i = n, a = [];
	e.forEach((e) => {
		let n = t.get(e);
		if (!n) throw Error(`Commit not found for key ${e}`);
		n.parents.length ? (r = ve(n), i = Math.max(r, i)) : a.push(n), ye(n, r);
	}), r = i, a.forEach((e) => {
		be(e, r, n);
	}), e.forEach((e) => {
		let n = t.get(e);
		if (n?.parents.length) {
			let e = he(n.parents);
			r = U.get(e).y - R, r <= i && (i = r);
			let t = H.get(n.branch).pos, a = r - L;
			U.set(n.id, {
				x: t,
				y: a
			});
		}
	});
}, "setParallelBTPos"), _e = /* @__PURE__ */ i((e) => {
	let t = X(e.parents.filter((e) => e !== null));
	if (!t) throw Error(`Closest parent not found for commit ${e.id}`);
	let n = U.get(t)?.y;
	if (n === void 0) throw Error(`Closest parent position not found for commit ${e.id}`);
	return n;
}, "findClosestParentPos"), ve = /* @__PURE__ */ i((e) => _e(e) + R, "calculateCommitPosition"), ye = /* @__PURE__ */ i((e, t) => {
	let n = H.get(e.branch);
	if (!n) throw Error(`Branch not found for commit ${e.id}`);
	let r = n.pos, i = t + L;
	return U.set(e.id, {
		x: r,
		y: i
	}), {
		x: r,
		y: i
	};
}, "setCommitPosition"), be = /* @__PURE__ */ i((e, t, n) => {
	let r = H.get(e.branch);
	if (!r) throw Error(`Branch not found for commit ${e.id}`);
	let i = t + n, a = r.pos;
	U.set(e.id, {
		x: a,
		y: i
	});
}, "setRootPosition"), xe = /* @__PURE__ */ i((e, t, n, r, i, a) => {
	if (a === _.HIGHLIGHT) e.append("rect").attr("x", n.x - 10).attr("y", n.y - 10).attr("width", 20).attr("height", 20).attr("class", `commit ${t.id} commit-highlight${i % V} ${r}-outer`), e.append("rect").attr("x", n.x - 6).attr("y", n.y - 6).attr("width", 12).attr("height", 12).attr("class", `commit ${t.id} commit${i % V} ${r}-inner`);
	else if (a === _.CHERRY_PICK) e.append("circle").attr("cx", n.x).attr("cy", n.y).attr("r", 10).attr("class", `commit ${t.id} ${r}`), e.append("circle").attr("cx", n.x - 3).attr("cy", n.y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${t.id} ${r}`), e.append("circle").attr("cx", n.x + 3).attr("cy", n.y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${t.id} ${r}`), e.append("line").attr("x1", n.x + 3).attr("y1", n.y + 1).attr("x2", n.x).attr("y2", n.y - 5).attr("stroke", "#fff").attr("class", `commit ${t.id} ${r}`), e.append("line").attr("x1", n.x - 3).attr("y1", n.y + 1).attr("x2", n.x).attr("y2", n.y - 5).attr("stroke", "#fff").attr("class", `commit ${t.id} ${r}`);
	else {
		let o = e.append("circle");
		if (o.attr("cx", n.x), o.attr("cy", n.y), o.attr("r", t.type === _.MERGE ? 9 : 10), o.attr("class", `commit ${t.id} commit${i % V}`), a === _.MERGE) {
			let a = e.append("circle");
			a.attr("cx", n.x), a.attr("cy", n.y), a.attr("r", 6), a.attr("class", `commit ${r} ${t.id} commit${i % V}`);
		}
		a === _.REVERSE && e.append("path").attr("d", `M ${n.x - 5},${n.y - 5}L${n.x + 5},${n.y + 5}M${n.x - 5},${n.y + 5}L${n.x + 5},${n.y - 5}`).attr("class", `commit ${r} ${t.id} commit${i % V}`);
	}
}, "drawCommitBullet"), Se = /* @__PURE__ */ i((e, t, n, r, i) => {
	if (t.type !== _.CHERRY_PICK && (t.customId && t.type === _.MERGE || t.type !== _.MERGE) && i.showCommitLabel) {
		let a = e.append("g"), o = a.insert("rect").attr("class", "commit-label-bkg"), s = a.append("text").attr("x", r).attr("y", n.y + 25).attr("class", "commit-label").text(t.id), c = s.node()?.getBBox();
		if (c && (o.attr("x", n.posWithOffset - c.width / 2 - B).attr("y", n.y + 13.5).attr("width", c.width + 2 * B).attr("height", c.height + 2 * B), J === "TB" || J === "BT" ? (o.attr("x", n.x - (c.width + 4 * z + 5)).attr("y", n.y - 12), s.attr("x", n.x - (c.width + 4 * z)).attr("y", n.y + c.height - 12)) : s.attr("x", n.posWithOffset - c.width / 2), i.rotateCommitLabel)) if (J === "TB" || J === "BT") s.attr("transform", "rotate(-45, " + n.x + ", " + n.y + ")"), o.attr("transform", "rotate(-45, " + n.x + ", " + n.y + ")");
		else {
			let e = -7.5 - (c.width + 10) / 25 * 9.5, t = 10 + c.width / 25 * 8.5;
			a.attr("transform", "translate(" + e + ", " + t + ") rotate(-45, " + r + ", " + n.y + ")");
		}
	}
}, "drawCommitLabel"), Z = /* @__PURE__ */ i((e, t, n, r) => {
	if (t.tags.length > 0) {
		let i = 0, a = 0, o = 0, s = [];
		for (let r of t.tags.reverse()) {
			let t = e.insert("polygon"), c = e.append("circle"), l = e.append("text").attr("y", n.y - 16 - i).attr("class", "tag-label").text(r), u = l.node()?.getBBox();
			if (!u) throw Error("Tag bbox not found");
			a = Math.max(a, u.width), o = Math.max(o, u.height), l.attr("x", n.posWithOffset - u.width / 2), s.push({
				tag: l,
				hole: c,
				rect: t,
				yOffset: i
			}), i += 20;
		}
		for (let { tag: e, hole: t, rect: i, yOffset: c } of s) {
			let s = o / 2, l = n.y - 19.2 - c;
			if (i.attr("class", "tag-label-bkg").attr("points", `
      ${r - a / 2 - z / 2},${l + B}  
      ${r - a / 2 - z / 2},${l - B}
      ${n.posWithOffset - a / 2 - z},${l - s - B}
      ${n.posWithOffset + a / 2 + z},${l - s - B}
      ${n.posWithOffset + a / 2 + z},${l + s + B}
      ${n.posWithOffset - a / 2 - z},${l + s + B}`), t.attr("cy", l).attr("cx", r - a / 2 + z / 2).attr("r", 1.5).attr("class", "tag-hole"), J === "TB" || J === "BT") {
				let o = r + c;
				i.attr("class", "tag-label-bkg").attr("points", `
        ${n.x},${o + 2}
        ${n.x},${o - 2}
        ${n.x + L},${o - s - 2}
        ${n.x + L + a + 4},${o - s - 2}
        ${n.x + L + a + 4},${o + s + 2}
        ${n.x + L},${o + s + 2}`).attr("transform", "translate(12,12) rotate(45, " + n.x + "," + r + ")"), t.attr("cx", n.x + z / 2).attr("cy", o).attr("transform", "translate(12,12) rotate(45, " + n.x + "," + r + ")"), e.attr("x", n.x + 5).attr("y", o + 3).attr("transform", "translate(14,14) rotate(45, " + n.x + "," + r + ")");
			}
		}
	}
}, "drawCommitTags"), Ce = /* @__PURE__ */ i((e) => {
	switch (e.customType ?? e.type) {
		case _.NORMAL: return "commit-normal";
		case _.REVERSE: return "commit-reverse";
		case _.HIGHLIGHT: return "commit-highlight";
		case _.MERGE: return "commit-merge";
		case _.CHERRY_PICK: return "commit-cherry-pick";
		default: return "commit-normal";
	}
}, "getCommitClassType"), we = /* @__PURE__ */ i((e, t, n, r) => {
	let i = {
		x: 0,
		y: 0
	};
	if (e.parents.length > 0) {
		let n = X(e.parents);
		if (n) {
			let a = r.get(n) ?? i;
			return t === "TB" ? a.y + R : t === "BT" ? (r.get(e.id) ?? i).y - R : a.x + R;
		}
	} else if (t === "TB") return W;
	else if (t === "BT") return (r.get(e.id) ?? i).y - R;
	else return 0;
	return 0;
}, "calculatePosition"), Te = /* @__PURE__ */ i((e, t, n) => {
	let r = J === "BT" && n ? t : t + L, i = J === "TB" || J === "BT" ? r : H.get(e.branch)?.pos, a = J === "TB" || J === "BT" ? H.get(e.branch)?.pos : r;
	if (a === void 0 || i === void 0) throw Error(`Position were undefined for commit ${e.id}`);
	return {
		x: a,
		y: i,
		posWithOffset: r
	};
}, "getCommitPosition"), Q = /* @__PURE__ */ i((e, t, n, r) => {
	let a = e.append("g").attr("class", "commit-bullets"), o = e.append("g").attr("class", "commit-labels"), s = J === "TB" || J === "BT" ? W : 0, c = [...t.keys()], l = r.parallelCommits ?? !1, u = /* @__PURE__ */ i((e, n) => {
		let r = t.get(e)?.seq, i = t.get(n)?.seq;
		return r !== void 0 && i !== void 0 ? r - i : 0;
	}, "sortKeys"), d = c.sort(u);
	J === "BT" && (l && ge(d, t, s), d = d.reverse()), d.forEach((e) => {
		let i = t.get(e);
		if (!i) throw Error(`Commit not found for key ${e}`);
		l && (s = we(i, J, s, U));
		let c = Te(i, s, l);
		if (n) {
			let e = Ce(i), t = i.customType ?? i.type;
			xe(a, i, c, e, H.get(i.branch)?.index ?? 0, t), Se(o, i, c, s, r), Z(o, i, c, s);
		}
		J === "TB" || J === "BT" ? U.set(i.id, {
			x: c.x,
			y: c.posWithOffset
		}) : U.set(i.id, {
			x: c.posWithOffset,
			y: c.y
		}), s = J === "BT" && l ? s + R : s + R + L, s > q && (q = s);
	});
}, "drawCommits"), Ee = /* @__PURE__ */ i((e, t, n, r, a) => {
	let o = (J === "TB" || J === "BT" ? n.x < r.x : n.y < r.y) ? t.branch : e.branch, s = /* @__PURE__ */ i((e) => e.branch === o, "isOnBranchToGetCurve"), c = /* @__PURE__ */ i((n) => n.seq > e.seq && n.seq < t.seq, "isBetweenCommits");
	return [...a.values()].some((e) => c(e) && s(e));
}, "shouldRerouteArrow"), $ = /* @__PURE__ */ i((e, t, n = 0) => {
	let r = e + Math.abs(e - t) / 2;
	return n > 5 ? r : K.every((e) => Math.abs(e - r) >= 10) ? (K.push(r), r) : $(e, t - Math.abs(e - t) / 5, n + 1);
}, "findLane"), De = /* @__PURE__ */ i((e, t, n, r) => {
	let i = U.get(t.id), a = U.get(n.id);
	if (i === void 0 || a === void 0) throw Error(`Commit positions not found for commits ${t.id} and ${n.id}`);
	let o = Ee(t, n, i, a, r), s = "", c = "", l = 0, u = 0, d = H.get(n.branch)?.index;
	n.type === _.MERGE && t.id !== n.parents[0] && (d = H.get(t.branch)?.index);
	let f;
	if (o) {
		s = "A 10 10, 0, 0, 0,", c = "A 10 10, 0, 0, 1,", l = 10, u = 10;
		let e = i.y < a.y ? $(i.y, a.y) : $(a.y, i.y), n = i.x < a.x ? $(i.x, a.x) : $(a.x, i.x);
		J === "TB" ? i.x < a.x ? f = `M ${i.x} ${i.y} L ${n - l} ${i.y} ${c} ${n} ${i.y + u} L ${n} ${a.y - l} ${s} ${n + u} ${a.y} L ${a.x} ${a.y}` : (d = H.get(t.branch)?.index, f = `M ${i.x} ${i.y} L ${n + l} ${i.y} ${s} ${n} ${i.y + u} L ${n} ${a.y - l} ${c} ${n - u} ${a.y} L ${a.x} ${a.y}`) : J === "BT" ? i.x < a.x ? f = `M ${i.x} ${i.y} L ${n - l} ${i.y} ${s} ${n} ${i.y - u} L ${n} ${a.y + l} ${c} ${n + u} ${a.y} L ${a.x} ${a.y}` : (d = H.get(t.branch)?.index, f = `M ${i.x} ${i.y} L ${n + l} ${i.y} ${c} ${n} ${i.y - u} L ${n} ${a.y + l} ${s} ${n - u} ${a.y} L ${a.x} ${a.y}`) : i.y < a.y ? f = `M ${i.x} ${i.y} L ${i.x} ${e - l} ${s} ${i.x + u} ${e} L ${a.x - l} ${e} ${c} ${a.x} ${e + u} L ${a.x} ${a.y}` : (d = H.get(t.branch)?.index, f = `M ${i.x} ${i.y} L ${i.x} ${e + l} ${c} ${i.x + u} ${e} L ${a.x - l} ${e} ${s} ${a.x} ${e - u} L ${a.x} ${a.y}`);
	} else s = "A 20 20, 0, 0, 0,", c = "A 20 20, 0, 0, 1,", l = 20, u = 20, J === "TB" ? (i.x < a.x && (f = n.type === _.MERGE && t.id !== n.parents[0] ? `M ${i.x} ${i.y} L ${i.x} ${a.y - l} ${s} ${i.x + u} ${a.y} L ${a.x} ${a.y}` : `M ${i.x} ${i.y} L ${a.x - l} ${i.y} ${c} ${a.x} ${i.y + u} L ${a.x} ${a.y}`), i.x > a.x && (s = "A 20 20, 0, 0, 0,", c = "A 20 20, 0, 0, 1,", l = 20, u = 20, f = n.type === _.MERGE && t.id !== n.parents[0] ? `M ${i.x} ${i.y} L ${i.x} ${a.y - l} ${c} ${i.x - u} ${a.y} L ${a.x} ${a.y}` : `M ${i.x} ${i.y} L ${a.x + l} ${i.y} ${s} ${a.x} ${i.y + u} L ${a.x} ${a.y}`), i.x === a.x && (f = `M ${i.x} ${i.y} L ${a.x} ${a.y}`)) : J === "BT" ? (i.x < a.x && (f = n.type === _.MERGE && t.id !== n.parents[0] ? `M ${i.x} ${i.y} L ${i.x} ${a.y + l} ${c} ${i.x + u} ${a.y} L ${a.x} ${a.y}` : `M ${i.x} ${i.y} L ${a.x - l} ${i.y} ${s} ${a.x} ${i.y - u} L ${a.x} ${a.y}`), i.x > a.x && (s = "A 20 20, 0, 0, 0,", c = "A 20 20, 0, 0, 1,", l = 20, u = 20, f = n.type === _.MERGE && t.id !== n.parents[0] ? `M ${i.x} ${i.y} L ${i.x} ${a.y + l} ${s} ${i.x - u} ${a.y} L ${a.x} ${a.y}` : `M ${i.x} ${i.y} L ${a.x + l} ${i.y} ${c} ${a.x} ${i.y - u} L ${a.x} ${a.y}`), i.x === a.x && (f = `M ${i.x} ${i.y} L ${a.x} ${a.y}`)) : (i.y < a.y && (f = n.type === _.MERGE && t.id !== n.parents[0] ? `M ${i.x} ${i.y} L ${a.x - l} ${i.y} ${c} ${a.x} ${i.y + u} L ${a.x} ${a.y}` : `M ${i.x} ${i.y} L ${i.x} ${a.y - l} ${s} ${i.x + u} ${a.y} L ${a.x} ${a.y}`), i.y > a.y && (f = n.type === _.MERGE && t.id !== n.parents[0] ? `M ${i.x} ${i.y} L ${a.x - l} ${i.y} ${s} ${a.x} ${i.y - u} L ${a.x} ${a.y}` : `M ${i.x} ${i.y} L ${i.x} ${a.y + l} ${c} ${i.x + u} ${a.y} L ${a.x} ${a.y}`), i.y === a.y && (f = `M ${i.x} ${i.y} L ${a.x} ${a.y}`));
	if (f === void 0) throw Error("Line definition not found");
	e.append("path").attr("d", f).attr("class", "arrow arrow" + d % V);
}, "drawArrow"), Oe = /* @__PURE__ */ i((e, t) => {
	let n = e.append("g").attr("class", "commit-arrows");
	[...t.keys()].forEach((e) => {
		let r = t.get(e);
		r.parents && r.parents.length > 0 && r.parents.forEach((e) => {
			De(n, t.get(e), r, t);
		});
	});
}, "drawArrows"), ke = /* @__PURE__ */ i((e, t, n) => {
	let r = e.append("g");
	t.forEach((e, t) => {
		let i = t % V, a = H.get(e.name)?.pos;
		if (a === void 0) throw Error(`Position not found for branch ${e.name}`);
		let o = r.append("line");
		o.attr("x1", 0), o.attr("y1", a), o.attr("x2", q), o.attr("y2", a), o.attr("class", "branch branch" + i), J === "TB" ? (o.attr("y1", W), o.attr("x1", a), o.attr("y2", q), o.attr("x2", a)) : J === "BT" && (o.attr("y1", q), o.attr("x1", a), o.attr("y2", W), o.attr("x2", a)), K.push(a);
		let s = e.name, c = Y(s), l = r.insert("rect"), u = r.insert("g").attr("class", "branchLabel").insert("g").attr("class", "label branch-label" + i);
		u.node().appendChild(c);
		let d = c.getBBox();
		l.attr("class", "branchLabelBkg label" + i).attr("rx", 4).attr("ry", 4).attr("x", -d.width - 4 - (n.rotateCommitLabel === !0 ? 30 : 0)).attr("y", -d.height / 2 + 8).attr("width", d.width + 18).attr("height", d.height + 4), u.attr("transform", "translate(" + (-d.width - 14 - (n.rotateCommitLabel === !0 ? 30 : 0)) + ", " + (a - d.height / 2 - 1) + ")"), J === "TB" ? (l.attr("x", a - d.width / 2 - 10).attr("y", 0), u.attr("transform", "translate(" + (a - d.width / 2 - 5) + ", 0)")) : J === "BT" ? (l.attr("x", a - d.width / 2 - 10).attr("y", q), u.attr("transform", "translate(" + (a - d.width / 2 - 5) + ", " + q + ")")) : l.attr("transform", "translate(-19, " + (a - d.height / 2) + ")");
	});
}, "drawBranches"), Ae = /* @__PURE__ */ i(function(e, t, n, r, i) {
	return H.set(e, {
		pos: t,
		index: n
	}), t += 50 + (i ? 40 : 0) + (J === "TB" || J === "BT" ? r.width / 2 : 0), t;
}, "setBranchPosition"), je = {
	parser: I,
	db: O,
	renderer: { draw: /* @__PURE__ */ i(function(t, n, i, o) {
		me(), r.debug("in gitgraph renderer", t + "\n", "id:", n, i);
		let s = o.db;
		if (!s.getConfig) {
			r.error("getConfig method is not available on db");
			return;
		}
		let c = s.getConfig(), l = c.rotateCommitLabel ?? !1;
		G = s.getCommits();
		let u = s.getBranchesAsObjArray();
		J = s.getDirection();
		let d = a(`[id="${n}"]`), f = 0;
		u.forEach((e, t) => {
			let n = Y(e.name), r = d.append("g"), i = r.insert("g").attr("class", "branchLabel"), a = i.insert("g").attr("class", "label branch-label");
			a.node()?.appendChild(n);
			let o = n.getBBox();
			f = Ae(e.name, f, t, o, l), a.remove(), i.remove(), r.remove();
		}), Q(d, G, !1, c), c.showBranches && ke(d, u, c), Oe(d, G), Q(d, G, !0, c), e.insertTitle(d, "gitTitleText", c.titleTopMargin ?? 0, s.getDiagramTitle()), ee(void 0, d, c.diagramPadding, c.useMaxWidth);
	}, "draw") },
	styles: /* @__PURE__ */ i((e) => `
  .commit-id,
  .commit-msg,
  .branch-label {
    fill: lightgrey;
    color: lightgrey;
    font-family: 'trebuchet ms', verdana, arial, sans-serif;
    font-family: var(--mermaid-font-family);
  }
  ${[
		0,
		1,
		2,
		3,
		4,
		5,
		6,
		7
	].map((t) => `
        .branch-label${t} { fill: ${e["gitBranchLabel" + t]}; }
        .commit${t} { stroke: ${e["git" + t]}; fill: ${e["git" + t]}; }
        .commit-highlight${t} { stroke: ${e["gitInv" + t]}; fill: ${e["gitInv" + t]}; }
        .label${t}  { fill: ${e["git" + t]}; }
        .arrow${t} { stroke: ${e["git" + t]}; }
        `).join("\n")}

  .branch {
    stroke-width: 1;
    stroke: ${e.lineColor};
    stroke-dasharray: 2;
  }
  .commit-label { font-size: ${e.commitLabelFontSize}; fill: ${e.commitLabelColor};}
  .commit-label-bkg { font-size: ${e.commitLabelFontSize}; fill: ${e.commitLabelBackground}; opacity: 0.5; }
  .tag-label { font-size: ${e.tagLabelFontSize}; fill: ${e.tagLabelColor};}
  .tag-label-bkg { fill: ${e.tagLabelBackground}; stroke: ${e.tagLabelBorder}; }
  .tag-hole { fill: ${e.textColor}; }

  .commit-merge {
    stroke: ${e.primaryColor};
    fill: ${e.primaryColor};
  }
  .commit-reverse {
    stroke: ${e.primaryColor};
    fill: ${e.primaryColor};
    stroke-width: 3;
  }
  .commit-highlight-outer {
  }
  .commit-highlight-inner {
    stroke: ${e.primaryColor};
    fill: ${e.primaryColor};
  }

  .arrow { stroke-width: 8; stroke-linecap: round; fill: none}
  .gitTitleText {
    text-anchor: middle;
    font-size: 18px;
    fill: ${e.textColor};
  }
`, "getStyles")
};
//#endregion
export { je as diagram };
