import { g as e, h as t, p as n } from "./src-BuisGndr.js";
import { B as r, C as i, K as a, U as o, _ as s, a as c, b as l, d as u, s as d, v as f, y as p, z as ee } from "./chunk-ABZYJK2D-DDrmE3Q7.js";
import { h as m, p as h, r as g } from "./chunk-S3R3BYOJ-CG6GoSCd.js";
import { t as _ } from "./mermaid-parser.core-B84fnaGG.js";
import { t as te } from "./chunk-4BX2VUAB-BZTgbbzC.js";
import { t as ne } from "./chunk-QZHKN3VN-Dal4kx9B.js";
//#region node_modules/.pnpm/mermaid@11.12.0/node_modules/mermaid/dist/chunks/mermaid.core/gitGraphDiagram-NY62KEGX.mjs
var v = {
	NORMAL: 0,
	REVERSE: 1,
	HIGHLIGHT: 2,
	MERGE: 3,
	CHERRY_PICK: 4
}, re = u.gitGraph, y = /* @__PURE__ */ t(() => g({
	...re,
	...p().gitGraph
}), "getConfig"), b = new ne(() => {
	let e = y(), 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 x() {
	return h({ length: 7 });
}
t(x, "getID");
function S(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;
	}, []);
}
t(S, "uniqBy");
var ie = /* @__PURE__ */ t(function(e) {
	b.records.direction = e;
}, "setDirection"), ae = /* @__PURE__ */ t(function(t) {
	e.debug("options str", t), t = t?.trim(), t ||= "{}";
	try {
		b.records.options = JSON.parse(t);
	} catch (t) {
		e.error("error while parsing gitGraph options", t.message);
	}
}, "setOptions"), oe = /* @__PURE__ */ t(function() {
	return b.records.options;
}, "getOptions"), se = /* @__PURE__ */ t(function(t) {
	let n = t.msg, r = t.id, i = t.type, a = t.tags;
	e.info("commit", n, r, i, a), e.debug("Entering commit:", n, r, i, a);
	let o = y();
	r = d.sanitizeText(r, o), n = d.sanitizeText(n, o), a = a?.map((e) => d.sanitizeText(e, o));
	let s = {
		id: r || b.records.seq + "-" + x(),
		message: n,
		seq: b.records.seq++,
		type: i ?? v.NORMAL,
		tags: a ?? [],
		parents: b.records.head == null ? [] : [b.records.head.id],
		branch: b.records.currBranch
	};
	b.records.head = s, e.info("main branch", o.mainBranchName), b.records.commits.has(s.id) && e.warn(`Commit ID ${s.id} already exists`), b.records.commits.set(s.id, s), b.records.branches.set(b.records.currBranch, s.id), e.debug("in pushCommit " + s.id);
}, "commit"), ce = /* @__PURE__ */ t(function(t) {
	let n = t.name, r = t.order;
	if (n = d.sanitizeText(n, y()), b.records.branches.has(n)) 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 ${n}")`);
	b.records.branches.set(n, b.records.head == null ? null : b.records.head.id), b.records.branchConfig.set(n, {
		name: n,
		order: r
	}), C(n), e.debug("in createBranch");
}, "branch"), le = /* @__PURE__ */ t((t) => {
	let n = t.branch, r = t.id, i = t.type, a = t.tags, o = y();
	n = d.sanitizeText(n, o), r &&= d.sanitizeText(r, o);
	let s = b.records.branches.get(b.records.currBranch), c = b.records.branches.get(n), l = s ? b.records.commits.get(s) : void 0, u = c ? b.records.commits.get(c) : void 0;
	if (l && u && l.branch === n) throw Error(`Cannot merge branch '${n}' into itself.`);
	if (b.records.currBranch === n) {
		let e = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Cannot merge a branch to itself");
		throw e.hash = {
			text: `merge ${n}`,
			token: `merge ${n}`,
			expected: ["branch abc"]
		}, e;
	}
	if (l === void 0 || !l) {
		let e = /* @__PURE__ */ Error(`Incorrect usage of "merge". Current branch (${b.records.currBranch})has no commits`);
		throw e.hash = {
			text: `merge ${n}`,
			token: `merge ${n}`,
			expected: ["commit"]
		}, e;
	}
	if (!b.records.branches.has(n)) {
		let e = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Branch to be merged (" + n + ") does not exist");
		throw e.hash = {
			text: `merge ${n}`,
			token: `merge ${n}`,
			expected: [`branch ${n}`]
		}, e;
	}
	if (u === void 0 || !u) {
		let e = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Branch to be merged (" + n + ") has no commits");
		throw e.hash = {
			text: `merge ${n}`,
			token: `merge ${n}`,
			expected: ["\"commit\""]
		}, e;
	}
	if (l === u) {
		let e = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Both branches have same head");
		throw e.hash = {
			text: `merge ${n}`,
			token: `merge ${n}`,
			expected: ["branch abc"]
		}, e;
	}
	if (r && b.records.commits.has(r)) {
		let e = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Commit with id:" + r + " already exists, use different custom id");
		throw e.hash = {
			text: `merge ${n} ${r} ${i} ${a?.join(" ")}`,
			token: `merge ${n} ${r} ${i} ${a?.join(" ")}`,
			expected: [`merge ${n} ${r}_UNIQUE ${i} ${a?.join(" ")}`]
		}, e;
	}
	let f = c || "", p = {
		id: r || `${b.records.seq}-${x()}`,
		message: `merged branch ${n} into ${b.records.currBranch}`,
		seq: b.records.seq++,
		parents: b.records.head == null ? [] : [b.records.head.id, f],
		branch: b.records.currBranch,
		type: v.MERGE,
		customType: i,
		customId: !!r,
		tags: a ?? []
	};
	b.records.head = p, b.records.commits.set(p.id, p), b.records.branches.set(b.records.currBranch, p.id), e.debug(b.records.branches), e.debug("in mergeBranch");
}, "merge"), ue = /* @__PURE__ */ t(function(t) {
	let n = t.id, r = t.targetId, i = t.tags, a = t.parent;
	e.debug("Entering cherryPick:", n, r, i);
	let o = y();
	if (n = d.sanitizeText(n, o), r = d.sanitizeText(r, o), i = i?.map((e) => d.sanitizeText(e, o)), a = d.sanitizeText(a, o), !n || !b.records.commits.has(n)) {
		let e = /* @__PURE__ */ Error("Incorrect usage of \"cherryPick\". Source commit id should exist and provided");
		throw e.hash = {
			text: `cherryPick ${n} ${r}`,
			token: `cherryPick ${n} ${r}`,
			expected: ["cherry-pick abc"]
		}, e;
	}
	let s = b.records.commits.get(n);
	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 === v.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 (!r || !b.records.commits.has(r)) {
		if (c === b.records.currBranch) {
			let e = /* @__PURE__ */ Error("Incorrect usage of \"cherryPick\". Source commit is already on current branch");
			throw e.hash = {
				text: `cherryPick ${n} ${r}`,
				token: `cherryPick ${n} ${r}`,
				expected: ["cherry-pick abc"]
			}, e;
		}
		let t = b.records.branches.get(b.records.currBranch);
		if (t === void 0 || !t) {
			let e = /* @__PURE__ */ Error(`Incorrect usage of "cherry-pick". Current branch (${b.records.currBranch})has no commits`);
			throw e.hash = {
				text: `cherryPick ${n} ${r}`,
				token: `cherryPick ${n} ${r}`,
				expected: ["cherry-pick abc"]
			}, e;
		}
		let o = b.records.commits.get(t);
		if (o === void 0 || !o) {
			let e = /* @__PURE__ */ Error(`Incorrect usage of "cherry-pick". Current branch (${b.records.currBranch})has no commits`);
			throw e.hash = {
				text: `cherryPick ${n} ${r}`,
				token: `cherryPick ${n} ${r}`,
				expected: ["cherry-pick abc"]
			}, e;
		}
		let l = {
			id: b.records.seq + "-" + x(),
			message: `cherry-picked ${s?.message} into ${b.records.currBranch}`,
			seq: b.records.seq++,
			parents: b.records.head == null ? [] : [b.records.head.id, s.id],
			branch: b.records.currBranch,
			type: v.CHERRY_PICK,
			tags: i ? i.filter(Boolean) : [`cherry-pick:${s.id}${s.type === v.MERGE ? `|parent:${a}` : ""}`]
		};
		b.records.head = l, b.records.commits.set(l.id, l), b.records.branches.set(b.records.currBranch, l.id), e.debug(b.records.branches), e.debug("in cherryPick");
	}
}, "cherryPick"), C = /* @__PURE__ */ t(function(e) {
	if (e = d.sanitizeText(e, y()), b.records.branches.has(e)) {
		b.records.currBranch = e;
		let t = b.records.branches.get(b.records.currBranch);
		t === void 0 || !t ? b.records.head = null : b.records.head = b.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 w(e, t, n) {
	let r = e.indexOf(t);
	r === -1 ? e.push(n) : e.splice(r, 1, n);
}
t(w, "upsert");
function T(t) {
	let n = t.reduce((e, t) => e.seq > t.seq ? e : t, t[0]), r = "";
	t.forEach(function(e) {
		e === n ? r += "	*" : r += "	|";
	});
	let i = [
		r,
		n.id,
		n.seq
	];
	for (let e in b.records.branches) b.records.branches.get(e) === n.id && i.push(e);
	if (e.debug(i.join(" ")), n.parents && n.parents.length == 2 && n.parents[0] && n.parents[1]) {
		let e = b.records.commits.get(n.parents[0]);
		w(t, n, e), n.parents[1] && t.push(b.records.commits.get(n.parents[1]));
	} else if (n.parents.length == 0) return;
	else if (n.parents[0]) {
		let e = b.records.commits.get(n.parents[0]);
		w(t, n, e);
	}
	t = S(t, (e) => e.id), T(t);
}
t(T, "prettyPrintCommitHistory");
var de = /* @__PURE__ */ t(function() {
	e.debug(b.records.commits);
	let t = E()[0];
	T([t]);
}, "prettyPrint"), fe = /* @__PURE__ */ t(function() {
	b.reset(), c();
}, "clear"), pe = /* @__PURE__ */ t(function() {
	return [...b.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"), me = /* @__PURE__ */ t(function() {
	return b.records.branches;
}, "getBranches"), he = /* @__PURE__ */ t(function() {
	return b.records.commits;
}, "getCommits"), E = /* @__PURE__ */ t(function() {
	let t = [...b.records.commits.values()];
	return t.forEach(function(t) {
		e.debug(t.id);
	}), t.sort((e, t) => e.seq - t.seq), t;
}, "getCommitsArray"), D = {
	commitType: v,
	getConfig: y,
	setDirection: ie,
	setOptions: ae,
	getOptions: oe,
	commit: se,
	branch: ce,
	merge: le,
	cherryPick: ue,
	checkout: C,
	prettyPrint: de,
	clear: fe,
	getBranchesAsObjArray: pe,
	getBranches: me,
	getCommits: he,
	getCommitsArray: E,
	getCurrentBranch: /* @__PURE__ */ t(function() {
		return b.records.currBranch;
	}, "getCurrentBranch"),
	getDirection: /* @__PURE__ */ t(function() {
		return b.records.direction;
	}, "getDirection"),
	getHead: /* @__PURE__ */ t(function() {
		return b.records.head;
	}, "getHead"),
	setAccTitle: r,
	getAccTitle: f,
	getAccDescription: s,
	setAccDescription: ee,
	setDiagramTitle: o,
	getDiagramTitle: i
}, O = /* @__PURE__ */ t((e, t) => {
	te(e, t), e.dir && t.setDirection(e.dir);
	for (let n of e.statements) k(n, t);
}, "populate"), k = /* @__PURE__ */ t((n, r) => {
	let i = {
		Commit: /* @__PURE__ */ t((e) => r.commit(A(e)), "Commit"),
		Branch: /* @__PURE__ */ t((e) => r.branch(j(e)), "Branch"),
		Merge: /* @__PURE__ */ t((e) => r.merge(M(e)), "Merge"),
		Checkout: /* @__PURE__ */ t((e) => r.checkout(N(e)), "Checkout"),
		CherryPicking: /* @__PURE__ */ t((e) => r.cherryPick(P(e)), "CherryPicking")
	}[n.$type];
	i ? i(n) : e.error(`Unknown statement type: ${n.$type}`);
}, "parseStatement"), A = /* @__PURE__ */ t((e) => ({
	id: e.id,
	msg: e.message ?? "",
	type: e.type === void 0 ? v.NORMAL : v[e.type],
	tags: e.tags ?? void 0
}), "parseCommit"), j = /* @__PURE__ */ t((e) => ({
	name: e.name,
	order: e.order ?? 0
}), "parseBranch"), M = /* @__PURE__ */ t((e) => ({
	branch: e.branch,
	id: e.id ?? "",
	type: e.type === void 0 ? void 0 : v[e.type],
	tags: e.tags ?? void 0
}), "parseMerge"), N = /* @__PURE__ */ t((e) => e.branch, "parseCheckout"), P = /* @__PURE__ */ t((e) => ({
	id: e.id,
	targetId: "",
	tags: e.tags?.length === 0 ? void 0 : e.tags,
	parent: e.parent
}), "parseCherryPicking"), F = { parse: /* @__PURE__ */ t(async (t) => {
	let n = await _("gitGraph", t);
	e.debug(n), O(n, D);
}, "parse") }, I = l()?.gitGraph, 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", ge = /* @__PURE__ */ t(() => {
	H.clear(), U.clear(), G.clear(), q = 0, K = [], J = "LR";
}, "clear"), Y = /* @__PURE__ */ t((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__ */ t((e) => {
	let n, r, i;
	return J === "BT" ? (r = /* @__PURE__ */ t((e, t) => e <= t, "comparisonFunc"), i = Infinity) : (r = /* @__PURE__ */ t((e, t) => e >= t, "comparisonFunc"), i = 0), e.forEach((e) => {
		let t = J === "TB" || J == "BT" ? U.get(e)?.y : U.get(e)?.x;
		t !== void 0 && r(t, i) && (n = e, i = t);
	}), n;
}, "findClosestParent"), _e = /* @__PURE__ */ t((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"), ve = /* @__PURE__ */ t((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 = be(n), i = Math.max(r, i)) : a.push(n), xe(n, r);
	}), r = i, a.forEach((e) => {
		Se(e, r, n);
	}), e.forEach((e) => {
		let n = t.get(e);
		if (n?.parents.length) {
			let e = _e(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"), ye = /* @__PURE__ */ t((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"), be = /* @__PURE__ */ t((e) => ye(e) + R, "calculateCommitPosition"), xe = /* @__PURE__ */ t((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"), Se = /* @__PURE__ */ t((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"), Ce = /* @__PURE__ */ t((e, t, n, r, i, a) => {
	if (a === v.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 === v.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 === v.MERGE ? 9 : 10), o.attr("class", `commit ${t.id} commit${i % V}`), a === v.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 === v.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"), we = /* @__PURE__ */ t((e, t, n, r) => {
	if (t.type !== v.CHERRY_PICK && (t.customId && t.type === v.MERGE || t.type !== v.MERGE) && I?.showCommitLabel) {
		let i = e.append("g"), a = i.insert("rect").attr("class", "commit-label-bkg"), o = i.append("text").attr("x", r).attr("y", n.y + 25).attr("class", "commit-label").text(t.id), s = o.node()?.getBBox();
		if (s && (a.attr("x", n.posWithOffset - s.width / 2 - B).attr("y", n.y + 13.5).attr("width", s.width + 2 * B).attr("height", s.height + 2 * B), J === "TB" || J === "BT" ? (a.attr("x", n.x - (s.width + 4 * z + 5)).attr("y", n.y - 12), o.attr("x", n.x - (s.width + 4 * z)).attr("y", n.y + s.height - 12)) : o.attr("x", n.posWithOffset - s.width / 2), I.rotateCommitLabel)) if (J === "TB" || J === "BT") o.attr("transform", "rotate(-45, " + n.x + ", " + n.y + ")"), a.attr("transform", "rotate(-45, " + n.x + ", " + n.y + ")");
		else {
			let e = -7.5 - (s.width + 10) / 25 * 9.5, t = 10 + s.width / 25 * 8.5;
			i.attr("transform", "translate(" + e + ", " + t + ") rotate(-45, " + r + ", " + n.y + ")");
		}
	}
}, "drawCommitLabel"), Te = /* @__PURE__ */ t((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"), Ee = /* @__PURE__ */ t((e) => {
	switch (e.customType ?? e.type) {
		case v.NORMAL: return "commit-normal";
		case v.REVERSE: return "commit-reverse";
		case v.HIGHLIGHT: return "commit-highlight";
		case v.MERGE: return "commit-merge";
		case v.CHERRY_PICK: return "commit-cherry-pick";
		default: return "commit-normal";
	}
}, "getCommitClassType"), De = /* @__PURE__ */ t((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"), Oe = /* @__PURE__ */ t((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"), Z = /* @__PURE__ */ t((e, n, r) => {
	if (!I) throw Error("GitGraph config not found");
	let i = e.append("g").attr("class", "commit-bullets"), a = e.append("g").attr("class", "commit-labels"), o = J === "TB" || J === "BT" ? W : 0, s = [...n.keys()], c = I?.parallelCommits ?? !1, l = /* @__PURE__ */ t((e, t) => {
		let r = n.get(e)?.seq, i = n.get(t)?.seq;
		return r !== void 0 && i !== void 0 ? r - i : 0;
	}, "sortKeys"), u = s.sort(l);
	J === "BT" && (c && ve(u, n, o), u = u.reverse()), u.forEach((e) => {
		let t = n.get(e);
		if (!t) throw Error(`Commit not found for key ${e}`);
		c && (o = De(t, J, o, U));
		let s = Oe(t, o, c);
		if (r) {
			let e = Ee(t), n = t.customType ?? t.type;
			Ce(i, t, s, e, H.get(t.branch)?.index ?? 0, n), we(a, t, s, o), Te(a, t, s, o);
		}
		J === "TB" || J === "BT" ? U.set(t.id, {
			x: s.x,
			y: s.posWithOffset
		}) : U.set(t.id, {
			x: s.posWithOffset,
			y: s.y
		}), o = J === "BT" && c ? o + R : o + R + L, o > q && (q = o);
	});
}, "drawCommits"), Q = /* @__PURE__ */ t((e, n, r, i, a) => {
	let o = (J === "TB" || J === "BT" ? r.x < i.x : r.y < i.y) ? n.branch : e.branch, s = /* @__PURE__ */ t((e) => e.branch === o, "isOnBranchToGetCurve"), c = /* @__PURE__ */ t((t) => t.seq > e.seq && t.seq < n.seq, "isBetweenCommits");
	return [...a.values()].some((e) => c(e) && s(e));
}, "shouldRerouteArrow"), $ = /* @__PURE__ */ t((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"), ke = /* @__PURE__ */ t((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 = Q(t, n, i, a, r), s = "", c = "", l = 0, u = 0, d = H.get(n.branch)?.index;
	n.type === v.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 === v.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 === v.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 === v.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 === v.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} ${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}`)) : (i.y < a.y && (f = n.type === v.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 === v.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"), Ae = /* @__PURE__ */ t((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) => {
			ke(n, t.get(e), r, t);
		});
	});
}, "drawArrows"), je = /* @__PURE__ */ t((e, t) => {
	let n = e.append("g");
	t.forEach((e, t) => {
		let r = t % V, i = H.get(e.name)?.pos;
		if (i === void 0) throw Error(`Position not found for branch ${e.name}`);
		let a = n.append("line");
		a.attr("x1", 0), a.attr("y1", i), a.attr("x2", q), a.attr("y2", i), a.attr("class", "branch branch" + r), J === "TB" ? (a.attr("y1", W), a.attr("x1", i), a.attr("y2", q), a.attr("x2", i)) : J === "BT" && (a.attr("y1", q), a.attr("x1", i), a.attr("y2", W), a.attr("x2", i)), K.push(i);
		let o = e.name, s = Y(o), c = n.insert("rect"), l = n.insert("g").attr("class", "branchLabel").insert("g").attr("class", "label branch-label" + r);
		l.node().appendChild(s);
		let u = s.getBBox();
		c.attr("class", "branchLabelBkg label" + r).attr("rx", 4).attr("ry", 4).attr("x", -u.width - 4 - (I?.rotateCommitLabel === !0 ? 30 : 0)).attr("y", -u.height / 2 + 8).attr("width", u.width + 18).attr("height", u.height + 4), l.attr("transform", "translate(" + (-u.width - 14 - (I?.rotateCommitLabel === !0 ? 30 : 0)) + ", " + (i - u.height / 2 - 1) + ")"), J === "TB" ? (c.attr("x", i - u.width / 2 - 10).attr("y", 0), l.attr("transform", "translate(" + (i - u.width / 2 - 5) + ", 0)")) : J === "BT" ? (c.attr("x", i - u.width / 2 - 10).attr("y", q), l.attr("transform", "translate(" + (i - u.width / 2 - 5) + ", " + q + ")")) : c.attr("transform", "translate(-19, " + (i - u.height / 2) + ")");
	});
}, "drawBranches"), Me = /* @__PURE__ */ t(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"), Ne = {
	parser: F,
	db: D,
	renderer: { draw: /* @__PURE__ */ t(function(t, r, i, o) {
		if (ge(), e.debug("in gitgraph renderer", t + "\n", "id:", r, i), !I) throw Error("GitGraph config not found");
		let s = I.rotateCommitLabel ?? !1, c = o.db;
		G = c.getCommits();
		let l = c.getBranchesAsObjArray();
		J = c.getDirection();
		let u = n(`[id="${r}"]`), d = 0;
		l.forEach((e, t) => {
			let n = Y(e.name), r = u.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();
			d = Me(e.name, d, t, o, s), a.remove(), i.remove(), r.remove();
		}), Z(u, G, !1), I.showBranches && je(u, l), Ae(u, G), Z(u, G, !0), m.insertTitle(u, "gitTitleText", I.titleTopMargin ?? 0, c.getDiagramTitle()), a(void 0, u, I.diagramPadding, I.useMaxWidth);
	}, "draw") },
	styles: /* @__PURE__ */ t((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 { Ne as diagram };
