mind-elixir
Version:
Mind elixir is a free open source mind map core.
1,400 lines • 117 kB
JavaScript
const Jo = 0, Zo = 1, Qo = 2, be = {
name: "Latte",
type: "light",
palette: ["#dd7878", "#ea76cb", "#8839ef", "#e64553", "#fe640b", "#df8e1d", "#40a02b", "#209fb5", "#1e66f5", "#7287fd"],
cssVar: {
"--node-gap-x": "30px",
"--node-gap-y": "10px",
"--main-gap-x": "65px",
"--main-gap-y": "45px",
"--root-radius": "30px",
"--main-radius": "20px",
"--root-color": "#ffffff",
"--root-bgcolor": "#4c4f69",
"--root-border-color": "rgba(0, 0, 0, 0)",
"--main-color": "#444446",
"--main-bgcolor": "#ffffff",
"--main-bgcolor-transparent": "rgba(255, 255, 255, 0.8)",
"--topic-padding": "3px",
"--color": "#777777",
"--bgcolor": "#f6f6f6",
"--selected": "#4dc4ff",
"--accent-color": "#e64553",
"--panel-color": "#444446",
"--panel-bgcolor": "#ffffff",
"--panel-border-color": "#eaeaea",
"--map-padding": "50px 80px"
}
}, we = {
name: "Dark",
type: "dark",
palette: ["#848FA0", "#748BE9", "#D2F9FE", "#4145A5", "#789AFA", "#706CF4", "#EF987F", "#775DD5", "#FCEECF", "#DA7FBC"],
cssVar: {
"--node-gap-x": "30px",
"--node-gap-y": "10px",
"--main-gap-x": "65px",
"--main-gap-y": "45px",
"--root-radius": "30px",
"--main-radius": "20px",
"--root-color": "#ffffff",
"--root-bgcolor": "#2d3748",
"--root-border-color": "rgba(255, 255, 255, 0.1)",
"--main-color": "#ffffff",
"--main-bgcolor": "#4c4f69",
"--main-bgcolor-transparent": "rgba(76, 79, 105, 0.8)",
"--topic-padding": "3px",
"--color": "#cccccc",
"--bgcolor": "#252526",
"--selected": "#4dc4ff",
"--accent-color": "#789AFA",
"--panel-color": "#ffffff",
"--panel-bgcolor": "#2d3748",
"--panel-border-color": "#696969",
"--map-padding": "50px 80px"
}
};
function me(e) {
return e.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
}
const le = function(e, t) {
if (t.id === e)
return t;
if (t.children && t.children.length) {
for (let n = 0; n < t.children.length; n++) {
const o = le(e, t.children[n]);
if (o) return o;
}
return null;
} else
return null;
}, G = (e, t) => {
if (e.parent = t, e.children)
for (let n = 0; n < e.children.length; n++)
G(e.children[n], e);
}, U = (e, t, n) => {
if (e.expanded = t, e.children)
if (n === void 0 || n > 0) {
const o = n !== void 0 ? n - 1 : void 0;
e.children.forEach((s) => {
U(s, t, o);
});
} else
e.children.forEach((o) => {
U(o, !1);
});
};
function xe(e) {
if (e.id = V(), e.children)
for (let t = 0; t < e.children.length; t++)
xe(e.children[t]);
}
function ce(e, t, n, o) {
const s = n - e, i = o - t, c = Math.atan2(i, s) * 180 / Math.PI, r = 12, a = 30, d = (c + 180 - a) * Math.PI / 180, h = (c + 180 + a) * Math.PI / 180;
return {
x1: n + Math.cos(d) * r,
y1: o + Math.sin(d) * r,
x2: n + Math.cos(h) * r,
y2: o + Math.sin(h) * r
};
}
function V() {
return ((/* @__PURE__ */ new Date()).getTime().toString(16) + Math.random().toString(16).substring(2)).substring(2, 18);
}
const gt = function() {
const e = V();
return {
topic: this.newTopicName,
id: e
};
};
function Ce(e) {
return JSON.parse(
JSON.stringify(e, (n, o) => {
if (n !== "parent")
return o;
})
);
}
const j = (e, t) => {
let n = 0, o = 0;
for (; t && t !== e; )
n += t.offsetLeft, o += t.offsetTop, t = t.offsetParent;
return { offsetLeft: n, offsetTop: o };
}, A = (e, t) => {
for (const n in t)
e.setAttribute(n, t[n]);
}, re = (e) => e ? e.tagName === "ME-TPC" : !1, Ee = (e) => e.filter((t) => t.nodeObj.parent).filter((t, n, o) => {
for (let s = 0; s < o.length; s++) {
if (t === o[s]) continue;
const { parent: i } = t.nodeObj;
if (i === o[s].nodeObj)
return !1;
}
return !0;
}), Se = (e) => {
const t = /translate3d\(([^,]+),\s*([^,]+)/, n = e.match(t);
return n ? { x: parseFloat(n[1]), y: parseFloat(n[2]) } : { x: 0, y: 0 };
}, Qe = function(e) {
for (let t = 0; t < e.length; t++) {
const { dom: n, evt: o, func: s } = e[t];
n.addEventListener(o, s);
}
return function() {
for (let n = 0; n < e.length; n++) {
const { dom: o, evt: s, func: i } = e[n];
o.removeEventListener(s, i);
}
};
}, Pe = (e, t) => {
const n = e.x - t.x, o = e.y - t.y;
return Math.sqrt(n * n + o * o);
}, B = {
LHS: "lhs",
RHS: "rhs"
}, mt = function() {
this.nodes.innerHTML = "";
const e = this.createTopic(this.nodeData);
Ne.call(this, e, this.nodeData), e.draggable = !1;
const t = document.createElement("me-root");
t.appendChild(e);
const n = this.nodeData.children || [];
if (this.direction === 2) {
let o = 0, s = 0;
n.map((i) => {
i.direction === 0 ? o += 1 : i.direction === 1 ? s += 1 : o <= s ? (i.direction = 0, o += 1) : (i.direction = 1, s += 1);
});
}
yt(this, n, t);
}, yt = function(e, t, n) {
const o = document.createElement("me-main");
o.className = B.LHS;
const s = document.createElement("me-main");
s.className = B.RHS;
for (let i = 0; i < t.length; i++) {
const l = t[i], { grp: c } = e.createWrapper(l);
e.direction === 2 ? l.direction === 0 ? o.appendChild(c) : s.appendChild(c) : e.direction === 0 ? o.appendChild(c) : s.appendChild(c);
}
e.nodes.appendChild(o), e.nodes.appendChild(n), e.nodes.appendChild(s), e.nodes.appendChild(e.lines), e.nodes.appendChild(e.labelContainer);
}, vt = function(e, t) {
const n = document.createElement("me-children");
for (let o = 0; o < t.length; o++) {
const s = t[o], { grp: i } = e.createWrapper(s);
n.appendChild(i);
}
return n;
}, et = function(e, t) {
const o = (this?.el ? this.el : t || document).querySelector(`[data-nodeid="me${e}"]`);
if (!o) throw new Error(`FindEle: Node ${e} not found, maybe it's collapsed.`);
return o;
}, Ne = function(e, t) {
if (e.innerHTML = "", t.style) {
const n = t.style;
for (const o in n)
e.style[o] = n[o];
}
if (t.dangerouslySetInnerHTML) {
e.innerHTML = t.dangerouslySetInnerHTML;
return;
}
if (t.image) {
const n = t.image;
if (n.url && n.width && n.height) {
const o = document.createElement("img");
o.src = this.imageProxy ? this.imageProxy(n.url) : n.url, o.style.width = n.width + "px", o.style.height = n.height + "px", n.fit && (o.style.objectFit = n.fit), e.appendChild(o), e.image = o;
}
} else e.image && (e.image = void 0);
{
const n = document.createElement("span");
n.className = "text", this.markdown ? n.innerHTML = this.markdown(t.topic, t) : n.textContent = t.topic, e.appendChild(n), e.text = n;
}
if (t.hyperLink) {
const n = document.createElement("a");
n.className = "hyper-link", n.target = "_blank", n.innerText = "🔗", n.href = t.hyperLink, e.appendChild(n), e.link = n;
} else e.link && (e.link = void 0);
if (t.icons && t.icons.length) {
const n = document.createElement("span");
n.className = "icons", n.innerHTML = t.icons.map((o) => `<span>${me(o)}</span>`).join(""), e.appendChild(n), e.icons = n;
} else e.icons && (e.icons = void 0);
if (t.tags && t.tags.length) {
const n = document.createElement("div");
n.className = "tags", t.tags.forEach((o) => {
const s = document.createElement("span");
typeof o == "string" ? s.textContent = o : (s.textContent = o.text, o.className && (s.className = o.className), o.style && Object.assign(s.style, o.style)), n.appendChild(s);
}), e.appendChild(n), e.tags = n;
} else e.tags && (e.tags = void 0);
}, bt = function(e, t) {
const n = document.createElement("me-wrapper"), { p: o, tpc: s } = this.createParent(e);
if (n.appendChild(o), !t && e.children && e.children.length > 0) {
const i = ke(e.expanded);
if (o.appendChild(i), e.expanded !== !1) {
const l = vt(this, e.children);
n.appendChild(l);
}
}
return { grp: n, top: o, tpc: s };
}, wt = function(e) {
const t = document.createElement("me-parent"), n = this.createTopic(e);
return Ne.call(this, n, e), t.appendChild(n), { p: t, tpc: n };
}, xt = function(e) {
const t = document.createElement("me-children");
return t.append(...e), t;
}, Ct = function(e) {
const t = document.createElement("me-tpc");
return t.nodeObj = e, t.dataset.nodeid = "me" + e.id, t;
};
function tt(e) {
const t = document.createRange();
t.selectNodeContents(e);
const n = window.getSelection();
n && (n.removeAllRanges(), n.addRange(t));
}
const Et = function(e) {
if (!e) return;
const t = document.createElement("div"), n = e.nodeObj, o = n.topic, { offsetLeft: s, offsetTop: i } = j(this.nodes, e);
this.nodes.appendChild(t), t.id = "input-box", t.textContent = o, t.contentEditable = "plaintext-only", t.spellcheck = !1;
const l = getComputedStyle(e);
t.style.cssText = `
left: ${s}px;
top: ${i}px;
min-width:${e.offsetWidth - 8}px;
color:${l.color};
font-size:${l.fontSize};
padding:${l.padding};
margin:${l.margin};
background-color:${l.backgroundColor !== "rgba(0, 0, 0, 0)" && l.backgroundColor};
border: ${l.border};
border-radius:${l.borderRadius}; `, this.direction === 0 && (t.style.right = "0"), tt(t), this.bus.fire("operation", {
name: "beginEdit",
obj: e.nodeObj
}), t.addEventListener("keydown", (c) => {
c.stopPropagation();
const r = c.key;
if (r === "Enter" || r === "Tab") {
if (c.shiftKey) return;
c.preventDefault(), t.blur(), this.container.focus();
} else r === "Escape" && (c.preventDefault(), t.textContent = o, t.blur(), this.container.focus());
}), t.addEventListener("blur", () => {
if (!t) return;
t.remove();
const c = t.innerText?.trim() || "";
c === o || c === "" || (n.topic = c, this.markdown ? e.text.innerHTML = this.markdown(n.topic, n) : e.text.textContent = c, this.linkDiv(), this.bus.fire("operation", {
name: "finishEdit",
obj: n,
origin: o
}));
});
}, ke = function(e) {
const t = document.createElement("me-epd");
return t.expanded = e !== !1, t.className = e !== !1 ? "minus" : "", t;
}, J = (e) => {
const t = e.parent?.children, n = t?.indexOf(e) ?? 0;
return { siblings: t, index: n };
};
function St(e) {
const { siblings: t, index: n } = J(e);
if (t === void 0) return;
const o = t[n];
n === 0 ? (t[n] = t[t.length - 1], t[t.length - 1] = o) : (t[n] = t[n - 1], t[n - 1] = o);
}
function Nt(e) {
const { siblings: t, index: n } = J(e);
if (t === void 0) return;
const o = t[n];
n === t.length - 1 ? (t[n] = t[0], t[0] = o) : (t[n] = t[n + 1], t[n + 1] = o);
}
function nt(e) {
const { siblings: t, index: n } = J(e);
return t === void 0 ? 0 : (t.splice(n, 1), t.length);
}
function kt(e, t, n) {
const { siblings: o, index: s } = J(n);
o !== void 0 && (t === "before" ? o.splice(s, 0, e) : o.splice(s + 1, 0, e));
}
function Tt(e, t) {
const { siblings: n, index: o } = J(e);
n !== void 0 && (n[o] = t, t.children = [e]);
}
function _t(e, t, n) {
if (nt(t), n.parent?.parent || (t.direction = n.direction), e === "in")
n.children ? n.children.push(t) : n.children = [t];
else {
t.direction !== void 0 && (t.direction = n.direction);
const { siblings: o, index: s } = J(n);
if (o === void 0) return;
e === "before" ? o.splice(s, 0, t) : o.splice(s + 1, 0, t);
}
}
const Lt = function({ map: e, direction: t }, n) {
if (t === 0)
return 0;
if (t === 1)
return 1;
if (t === 2) {
const o = e.querySelector(".lhs")?.childElementCount || 0, s = e.querySelector(".rhs")?.childElementCount || 0;
return o <= s ? (n.direction = 0, 0) : (n.direction = 1, 1);
}
}, ot = function(e, t, n) {
const o = n.children[0].children[0], s = t.parentElement;
if (s.tagName === "ME-PARENT") {
if (ee(o), s.children[1])
s.nextSibling.appendChild(n);
else {
const i = e.createChildren([n]);
s.appendChild(ke(!0)), s.insertAdjacentElement("afterend", i);
}
e.linkDiv(n.offsetParent);
} else s.tagName === "ME-ROOT" && (Lt(e, o.nodeObj) === 0 ? e.container.querySelector(".lhs")?.appendChild(n) : e.container.querySelector(".rhs")?.appendChild(n), e.linkDiv());
}, At = function(e, t) {
const n = e.parentNode;
if (t === 0) {
const o = n.parentNode.parentNode;
o.tagName !== "ME-MAIN" && (o.previousSibling.children[1].remove(), o.remove());
}
n.parentNode.remove();
}, st = {
before: "beforebegin",
after: "afterend"
}, ee = function(e) {
const n = e.parentElement.parentElement.lastElementChild;
n?.tagName === "svg" && n?.remove();
}, Dt = function(e, t) {
const n = e.nodeObj, o = Ce(n);
o.style && t.style && (t.style = Object.assign(o.style, t.style));
const s = Object.assign(n, t);
Ne.call(this, e, s), this.linkDiv(), this.bus.fire("operation", {
name: "reshapeNode",
obj: s,
origin: o
});
}, Te = function(e, t, n) {
if (!t) return null;
const o = t.nodeObj;
o.expanded === !1 && (e.expandNode(t, !0), t = e.findEle(o.id));
const s = n || e.generateNewObj();
o.children ? o.children.push(s) : o.children = [s], G(e.nodeData);
const { grp: i, top: l } = e.createWrapper(s);
return ot(e, t, i), { newTop: l, newNodeObj: s };
}, Mt = function(e, t, n) {
const o = t || this.currentNode;
if (!o) return;
const s = o.nodeObj;
if (s.parent) {
if (!s.parent?.parent && this.direction === 2) {
const a = this.map.querySelector(".lhs")?.childElementCount || 0, d = this.map.querySelector(".rhs")?.childElementCount || 0;
if (!a || !d) {
this.addChild(this.findEle(s.parent.id), n);
return;
}
}
} else {
this.addChild();
return;
}
const i = n || this.generateNewObj();
if (!s.parent?.parent) {
const a = o.closest("me-main").className === B.LHS ? 0 : 1;
i.direction = a;
}
kt(i, e, s), G(this.nodeData);
const l = o.parentElement, { grp: c, top: r } = this.createWrapper(i);
l.parentElement.insertAdjacentElement(st[e], c), this.linkDiv(c.offsetParent), n || this.editTopic(r.firstChild), this.bus.fire("operation", {
name: "insertSibling",
type: e,
obj: i
}), this.selectNode(r.firstChild, !0);
}, Pt = function(e, t) {
const n = e || this.currentNode;
if (!n) return;
ee(n);
const o = n.nodeObj;
if (!o.parent)
return;
const s = t || this.generateNewObj();
Tt(o, s), G(this.nodeData);
const i = n.parentElement.parentElement, { grp: l, top: c } = this.createWrapper(s, !0);
c.appendChild(ke(!0)), i.insertAdjacentElement("afterend", l);
const r = this.createChildren([i]);
c.insertAdjacentElement("afterend", r), this.linkDiv(), t || this.editTopic(c.firstChild), this.selectNode(c.firstChild, !0), this.bus.fire("operation", {
name: "insertParent",
obj: s
});
}, Ot = function(e, t) {
const n = e || this.currentNode;
if (!n) return;
const o = Te(this, n, t);
if (!o) return;
const { newTop: s, newNodeObj: i } = o;
this.bus.fire("operation", {
name: "addChild",
obj: i
}), t || this.editTopic(s.firstChild), this.selectNode(s.firstChild, !0);
}, $t = function(e, t) {
const n = Ce(e.nodeObj);
xe(n);
const o = Te(this, t, n);
if (!o) return;
const { newNodeObj: s } = o;
this.selectNode(this.findEle(s.id)), this.bus.fire("operation", {
name: "copyNode",
obj: s
});
}, jt = function(e, t) {
const n = [];
for (let o = 0; o < e.length; o++) {
const s = e[o], i = Ce(s.nodeObj);
xe(i);
const l = Te(this, t, i);
if (!l) return;
const { newNodeObj: c } = l;
n.push(c);
}
this.unselectNodes(this.currentNodes), this.selectNodes(n.map((o) => this.findEle(o.id))), this.bus.fire("operation", {
name: "copyNodes",
objs: n
});
}, Ht = function(e) {
const t = e || this.currentNode;
if (!t) return;
const n = t.nodeObj;
St(n);
const o = t.parentNode.parentNode;
o.parentNode.insertBefore(o, o.previousSibling), this.linkDiv(), this.bus.fire("operation", {
name: "moveUpNode",
obj: n
});
}, It = function(e) {
const t = e || this.currentNode;
if (!t) return;
const n = t.nodeObj;
Nt(n);
const o = t.parentNode.parentNode;
o.nextSibling ? o.nextSibling.insertAdjacentElement("afterend", o) : o.parentNode.prepend(o), this.linkDiv(), this.bus.fire("operation", {
name: "moveDownNode",
obj: n
});
}, Rt = function(e) {
if (e = Ee(e), e.length === 0) return;
for (const n of e) {
const o = n.nodeObj, s = nt(o);
At(n, s);
}
const t = e[e.length - 1];
this.selectNode(this.findEle(t.nodeObj.parent.id)), this.linkDiv(), this.bus.fire("operation", {
name: "removeNodes",
objs: e.map((n) => n.nodeObj)
});
}, _e = (e, t, n, o) => {
e = Ee(e);
let s = n.nodeObj;
t === "in" && s.expanded === !1 && (o.expandNode(n, !0), n = o.findEle(s.id), s = n.nodeObj), t === "after" && (e = e.reverse());
const i = [];
for (const c of e) {
const r = c.nodeObj;
if (_t(t, r, s), G(o.nodeData), t === "in") {
const a = c.parentElement;
ot(o, n, a.parentElement);
} else {
ee(c);
const a = c.parentElement.parentNode;
i.includes(a.parentElement) || i.push(a.parentElement), n.parentElement.parentNode.insertAdjacentElement(st[t], a);
}
}
for (const c of i)
c.childElementCount === 0 && c.tagName !== "ME-MAIN" && (c.previousSibling.children[1].remove(), c.remove());
o.linkDiv(), o.scrollIntoView(e[e.length - 1]);
const l = t === "before" ? "moveNodeBefore" : t === "after" ? "moveNodeAfter" : "moveNodeIn";
o.bus.fire("operation", {
name: l,
objs: e.map((c) => c.nodeObj),
toObj: s
});
}, Bt = function(e, t) {
_e(e, "in", t, this);
}, Ft = function(e, t) {
_e(e, "before", t, this);
}, Yt = function(e, t) {
_e(e, "after", t, this);
}, Wt = function(e) {
const t = e || this.currentNode;
t && (t.nodeObj.dangerouslySetInnerHTML || this.editTopic(t));
}, Xt = function(e, t) {
e.text.textContent = t, e.nodeObj.topic = t, this.linkDiv();
}, it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
addChild: Ot,
beginEdit: Wt,
copyNode: $t,
copyNodes: jt,
insertParent: Pt,
insertSibling: Mt,
moveDownNode: It,
moveNodeAfter: Yt,
moveNodeBefore: Ft,
moveNodeIn: Bt,
moveUpNode: Ht,
removeNodes: Rt,
reshapeNode: Dt,
rmSubline: ee,
setNodeTopic: Xt
}, Symbol.toStringTag, { value: "Module" }));
function zt(e) {
return {
nodeData: e.isFocusMode ? e.nodeDataBackup : e.nodeData,
arrows: e.arrows,
summaries: e.summaries,
direction: e.direction,
theme: e.theme
};
}
const Gt = function(e) {
const t = this.container, n = e.getBoundingClientRect(), o = t.getBoundingClientRect();
if (n.top > o.bottom - 50 || n.bottom < o.top + 50 || n.left > o.right - 50 || n.right < o.left + 50) {
const i = n.left + n.width / 2, l = n.top + n.height / 2, c = o.left + o.width / 2, r = o.top + o.height / 2, a = i - c, d = l - r;
this.move(-a, -d, !0);
}
}, Vt = function(e, t, n) {
this.clearSelection(), this.scrollIntoView(e), this.selection?.select(e), t && this.bus.fire("selectNewNode", e.nodeObj);
}, qt = function(e) {
this.selection?.select(e);
}, Kt = function(e) {
this.selection?.deselect(e);
}, Ut = function() {
this.unselectNodes(this.currentNodes), this.unselectSummary(), this.unselectArrow();
}, Le = function(e) {
return JSON.stringify(e, (t, n) => {
if (!(t === "parent" && typeof n != "string"))
return n;
});
}, Jt = function() {
const e = zt(this);
return Le(e);
}, Zt = function() {
return JSON.parse(this.getDataString());
}, Qt = function() {
this.editable = !0;
}, en = function() {
this.editable = !1;
}, tn = function(e, t = { x: 0, y: 0 }) {
if (e < this.scaleMin && e < this.scaleVal || e > this.scaleMax && e > this.scaleVal) return;
const n = this.container.getBoundingClientRect(), o = t.x ? t.x - n.left - n.width / 2 : 0, s = t.y ? t.y - n.top - n.height / 2 : 0, { dx: i, dy: l } = Ae(this), c = this.map.style.transform, { x: r, y: a } = Se(c), d = r - i, h = a - l, u = this.scaleVal, y = (-o + d) * (1 - e / u), v = (-s + h) * (1 - e / u);
this.map.style.transform = `translate3d(${r - y}px, ${a - v}px, 0) scale(${e})`, this.scaleVal = e, this.bus.fire("scale", e);
}, nn = function() {
const e = this.nodes.offsetHeight / this.container.offsetHeight, t = this.nodes.offsetWidth / this.container.offsetWidth, n = 1 / Math.max(1, Math.max(e, t));
this.scaleVal = n;
const { dx: o, dy: s } = Ae(this, !0);
this.map.style.transform = `translate3d(${o}px, ${s}px, 0) scale(${n})`, this.bus.fire("scale", n);
}, on = function(e, t, n = !1) {
const { map: o, scaleVal: s, bus: i, container: l, nodes: c } = this;
if (n && o.style.transition === "transform 0.3s")
return;
const r = o.style.transform;
let { x: a, y: d } = Se(r);
const h = l.getBoundingClientRect(), u = c.getBoundingClientRect(), y = u.left < h.right && u.right > h.left, v = u.top < h.bottom && u.bottom > h.top;
if (y) {
const p = u.left + e, g = u.right + e;
(p >= h.right || g <= h.left) && (e = 0);
}
if (v) {
const p = u.top + t, g = u.bottom + t;
(p >= h.bottom || g <= h.top) && (t = 0);
}
a += e, d += t, n && (o.style.transition = "transform 0.3s", setTimeout(() => {
o.style.transition = "none";
}, 300)), o.style.transform = `translate3d(${a}px, ${d}px, 0) scale(${s})`, i.fire("move", { dx: e, dy: t });
}, Ae = (e, t = !1) => {
const { container: n, map: o, nodes: s } = e;
let i, l;
if (e.alignment === "nodes" || t)
i = (n.offsetWidth - s.offsetWidth) / 2, l = (n.offsetHeight - s.offsetHeight) / 2, o.style.transformOrigin = "50% 50%";
else {
const c = o.querySelector("me-root"), r = c.offsetTop, a = c.offsetLeft, d = c.offsetWidth, h = c.offsetHeight;
i = n.offsetWidth / 2 - a - d / 2, l = n.offsetHeight / 2 - r - h / 2, o.style.transformOrigin = `${a + d / 2}px 50%`;
}
return { dx: i, dy: l };
}, sn = function() {
const { map: e, container: t } = this, { dx: n, dy: o } = Ae(this);
t.scrollTop = 0, t.scrollLeft = 0, e.style.transform = `translate3d(${n}px, ${o}px, 0) scale(${this.scaleVal})`;
}, rn = function(e) {
e(this);
}, ln = function(e) {
e.nodeObj.parent && (this.clearSelection(), this.tempDirection === null && (this.tempDirection = this.direction), this.isFocusMode || (this.nodeDataBackup = this.nodeData, this.isFocusMode = !0), this.nodeData = e.nodeObj, this.initRight(), this.toCenter());
}, cn = function() {
this.isFocusMode = !1, this.tempDirection !== null && (this.nodeData = this.nodeDataBackup, this.direction = this.tempDirection, this.tempDirection = null, this.refresh(), this.toCenter());
}, an = function() {
this.direction = 0, this.refresh(), this.toCenter(), this.bus.fire("changeDirection", this.direction);
}, dn = function() {
this.direction = 1, this.refresh(), this.toCenter(), this.bus.fire("changeDirection", this.direction);
}, hn = function() {
this.direction = 2, this.refresh(), this.toCenter(), this.bus.fire("changeDirection", this.direction);
}, fn = function(e) {
this.locale = e, this.refresh();
}, un = function(e, t) {
const n = e.nodeObj;
typeof t == "boolean" ? n.expanded = t : n.expanded !== !1 ? n.expanded = !1 : n.expanded = !0;
const o = e.getBoundingClientRect(), s = {
x: o.left,
y: o.top
}, i = e.parentNode, l = i.children[1];
if (l.expanded = n.expanded, l.className = n.expanded ? "minus" : "", ee(e), n.expanded) {
const h = this.createChildren(
n.children.map((u) => this.createWrapper(u).grp)
);
i.parentNode.appendChild(h);
} else
i.parentNode.children[1].remove();
this.linkDiv(e.closest("me-main > me-wrapper"));
const c = e.getBoundingClientRect(), r = {
x: c.left,
y: c.top
}, a = s.x - r.x, d = s.y - r.y;
this.move(a, d), this.bus.fire("expandNode", n);
}, pn = function(e, t) {
const n = e.nodeObj, o = e.getBoundingClientRect(), s = {
x: o.left,
y: o.top
};
U(n, t ?? !n.expanded), this.refresh();
const i = this.findEle(n.id).getBoundingClientRect(), l = {
x: i.left,
y: i.top
}, c = s.x - l.x, r = s.y - l.y;
this.move(c, r);
}, gn = function(e) {
this.clearSelection(), e && (e = JSON.parse(JSON.stringify(e)), this.nodeData = e.nodeData, this.arrows = e.arrows || [], this.summaries = e.summaries || [], e.theme && this.changeTheme(e.theme)), G(this.nodeData), this.layout(), this.linkDiv();
}, mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
cancelFocus: cn,
clearSelection: Ut,
disableEdit: en,
enableEdit: Qt,
expandNode: un,
expandNodeAll: pn,
focusNode: ln,
getData: Zt,
getDataString: Jt,
initLeft: an,
initRight: dn,
initSide: hn,
install: rn,
move: on,
refresh: gn,
scale: tn,
scaleFit: nn,
scrollIntoView: Gt,
selectNode: Vt,
selectNodes: qt,
setLocale: fn,
stringifyData: Le,
toCenter: sn,
unselectNodes: Kt
}, Symbol.toStringTag, { value: "Module" })), Oe = "MIND-ELIXIR-WAIT-COPY", yn = (e, t) => {
const n = e.map.querySelectorAll(`.${t}>me-wrapper>me-parent>me-tpc`);
n.length !== 0 && e.selectNode(n[Math.ceil(n.length / 2) - 1]);
}, vn = (e) => {
e.selectNode(e.map.querySelector("me-root>me-tpc"));
}, bn = function(e, t) {
const n = t.parentElement.parentElement.parentElement.previousSibling;
if (n) {
const o = n.firstChild;
e.selectNode(o);
}
}, wn = function(e, t) {
const n = t.parentElement.nextSibling;
if (n && n.firstChild) {
const o = n.firstChild.firstChild.firstChild;
e.selectNode(o);
}
}, $e = function(e, t) {
const n = e.currentNode || e.currentNodes?.[0];
if (!n) return;
const o = n.nodeObj, s = n.offsetParent.offsetParent.parentElement;
o.parent ? s.className === t ? wn(e, n) : o.parent?.parent ? bn(e, n) : vn(e) : yn(e, t);
}, je = function(e, t) {
const n = e.currentNode;
if (!n || !n.nodeObj.parent) return;
const s = t + "Sibling", i = n.parentElement.parentElement[s];
i ? e.selectNode(i.firstChild.firstChild) : e.selectNode(n);
}, ae = function(e, t, n) {
const { scaleVal: o, scaleSensitivity: s } = e;
switch (t) {
case "in":
e.scale(o + s, n);
break;
case "out":
e.scale(o - s, n);
}
};
function xn(e, t) {
t = t === !0 ? {} : t;
const n = () => {
e.currentArrow ? e.removeArrow() : e.currentSummary ? e.removeSummary(e.currentSummary.summaryObj.id) : e.currentNodes && e.removeNodes(e.currentNodes);
};
let o = !1, s = null;
const i = (r) => {
const a = e.nodeData;
if (r.key === "0")
for (const d of a.children)
U(d, !1);
if (r.key === "=")
for (const d of a.children)
U(d, !0);
if (["1", "2", "3", "4", "5", "6", "7", "8", "9"].includes(r.key))
for (const d of a.children)
U(d, !0, Number(r.key) - 1);
e.refresh(), e.toCenter(), o = !1, s && (clearTimeout(s), s = null, e.container.removeEventListener("keydown", i));
}, l = {
Enter: (r) => {
r.shiftKey ? e.insertSibling("before") : r.ctrlKey || r.metaKey ? e.insertParent() : e.insertSibling("after");
},
Tab: () => {
e.addChild();
},
F1: () => {
e.toCenter();
},
F2: () => {
e.currentSummary ? e.editSummary(e.currentSummary) : e.currentArrow ? e.editArrowLabel(e.currentArrow) : e.beginEdit();
},
ArrowUp: (r) => {
if (r.altKey)
e.moveUpNode();
else {
if (r.metaKey || r.ctrlKey)
return e.initSide();
je(e, "previous");
}
},
ArrowDown: (r) => {
r.altKey ? e.moveDownNode() : je(e, "next");
},
ArrowLeft: (r) => {
if (r.metaKey || r.ctrlKey)
return e.initLeft();
$e(e, B.LHS);
},
ArrowRight: (r) => {
if (r.metaKey || r.ctrlKey)
return e.initRight();
$e(e, B.RHS);
},
PageUp: () => e.moveUpNode(),
PageDown: () => {
e.moveDownNode();
},
"=": (r) => {
(r.metaKey || r.ctrlKey) && ae(e, "in");
},
"-": (r) => {
(r.metaKey || r.ctrlKey) && ae(e, "out");
},
0: (r) => {
if (r.metaKey || r.ctrlKey) {
if (o)
return;
e.scale(1);
}
},
k: (r) => {
(r.metaKey || r.ctrlKey) && (o = !0, s && (clearTimeout(s), e.container.removeEventListener("keydown", i)), s = window.setTimeout(() => {
o = !1, s = null;
}, 2e3), e.container.addEventListener("keydown", i));
},
Delete: n,
Backspace: n,
...t
};
e.container.onkeydown = (r) => {
if ((r.ctrlKey || r.metaKey) && ["c", "v", "x"].includes(r.key) || r.preventDefault(), !e.editable) return;
const d = l[r.key];
d && d(r);
};
const c = (r) => {
if (r.target instanceof HTMLElement && r.target.id === "input-box" || e.currentNodes.length === 0) return !1;
if (r.clipboardData) {
const a = Ee(e.currentNodes).map((h) => h.nodeObj), d = Le({
magic: Oe,
data: a
});
return r.clipboardData.setData("text/plain", d), r.preventDefault(), !0;
}
return !1;
};
e.container.addEventListener("copy", c), e.container.addEventListener("cut", (r) => {
c(r) && n();
}), e.container.addEventListener("paste", (r) => {
const a = r.clipboardData?.getData("text/plain");
if (a)
try {
const d = JSON.parse(a);
if (d && d.magic === Oe && Array.isArray(d.data)) {
const h = d.data, u = h.map((y) => ({ nodeObj: y }));
h.length > 0 && e.currentNode && (e.copyNodes(u, e.currentNode), r.preventDefault());
return;
}
} catch {
}
e.pasteHandler && e.pasteHandler(r);
});
}
const Cn = function(e, t) {
if (!t)
return he(e), e;
let n = e.querySelector(".insert-preview");
const o = `insert-preview ${t} show`;
return n || (n = document.createElement("div"), e.appendChild(n)), n.className = o, e;
}, he = function(e) {
if (!e) return;
const t = e.querySelectorAll(".insert-preview");
for (const n of t || [])
n.remove();
}, He = function(e, t) {
for (const n of t) {
const o = n.parentElement.parentElement.contains(e);
if (!(e && e.tagName === "ME-TPC" && e !== n && !o && e.nodeObj.parent)) return !1;
}
return !0;
}, En = function(e) {
const t = document.createElement("div");
return t.className = "mind-elixir-ghost", e.container.appendChild(t), t;
};
class Sn {
mind;
isMoving = !1;
interval = null;
speed = 20;
constructor(t) {
this.mind = t;
}
move(t, n) {
this.isMoving || (this.isMoving = !0, this.interval = setInterval(() => {
this.mind.move(t * this.speed * this.mind.scaleVal, n * this.speed * this.mind.scaleVal);
}, 100));
}
stop() {
this.isMoving = !1, this.interval && (clearInterval(this.interval), this.interval = null);
}
}
function Nn(e) {
return {
isDragging: !1,
insertType: null,
meet: null,
ghost: En(e),
edgeMoveController: new Sn(e),
startX: 0,
startY: 0,
pointerId: null
};
}
const kn = 5;
function Ie(e, t, n, o = !1) {
if (e.spacePressed) return !1;
const s = n.target;
if (s?.tagName !== "ME-TPC" || !s.nodeObj.parent) return !1;
t.startX = n.clientX, t.startY = n.clientY, t.pointerId = n.pointerId, e.selection?.cancel();
let i = e.currentNodes;
return i?.includes(s) || (e.selectNode(s), i = e.currentNodes), e.dragged = i, o && lt(e, t), !0;
}
function rt(e, t, n) {
e.style.transform = `translate(${t - 10}px, ${n - 10}px)`, e.style.display = "block";
}
function lt(e, t) {
const { dragged: n } = e;
if (!n) return;
const o = document.activeElement;
o && o.isContentEditable && o.blur(), t.isDragging = !0, n.length > 1 ? t.ghost.innerHTML = n.length + "" : t.ghost.innerHTML = n[0].innerHTML;
for (const s of n)
s.parentElement.parentElement.style.opacity = "0.5";
e.dragMoveHelper.clear();
}
function Tn(e, t, n) {
const { dragged: o } = e;
if (!o || t.pointerId !== n.pointerId) return;
const s = n.clientX - t.startX, i = n.clientY - t.startY, l = Math.sqrt(s * s + i * i);
if (!t.isDragging && l > kn && lt(e, t), !t.isDragging) return;
const c = e.container.getBoundingClientRect();
rt(t.ghost, n.clientX - c.x, n.clientY - c.y), n.clientX < c.x + 50 ? t.edgeMoveController.move(1, 0) : n.clientX > c.x + c.width - 50 ? t.edgeMoveController.move(-1, 0) : n.clientY < c.y + 50 ? t.edgeMoveController.move(0, 1) : n.clientY > c.y + c.height - 50 ? t.edgeMoveController.move(0, -1) : t.edgeMoveController.stop(), he(t.meet);
const r = 12 * e.scaleVal, a = document.elementFromPoint(n.clientX, n.clientY - r);
if (He(a, o)) {
t.meet = a;
const d = a.getBoundingClientRect(), h = d.y;
n.clientY > h + d.height ? t.insertType = "after" : t.insertType = "in";
} else {
const d = document.elementFromPoint(n.clientX, n.clientY + r);
if (He(d, o)) {
t.meet = d;
const u = d.getBoundingClientRect().y;
n.clientY < u ? t.insertType = "before" : t.insertType = "in";
} else
t.insertType = null, t.meet = null;
}
t.meet && Cn(t.meet, t.insertType);
}
function _n(e, t, n) {
const { dragged: o } = e;
if (!(!o || t.pointerId !== n.pointerId)) {
t.edgeMoveController.stop();
for (const s of o)
s.parentElement.parentElement.style.opacity = "1";
t.ghost.style.display = "none", t.ghost.innerHTML = "", t.isDragging && t.meet && (he(t.meet), t.insertType === "before" ? e.moveNodeBefore(o, t.meet) : t.insertType === "after" ? e.moveNodeAfter(o, t.meet) : t.insertType === "in" && e.moveNodeIn(o, t.meet)), e.dragged = null, t.isDragging = !1, t.insertType = null, t.meet = null, t.pointerId = null;
}
}
function pe(e, t) {
const { dragged: n } = e;
if (n) {
t.edgeMoveController.stop();
for (const o of n)
o.parentElement.parentElement.style.opacity = "1";
t.meet && he(t.meet), t.ghost.style.display = "none", t.ghost.innerHTML = "", e.dragged = null, t.isDragging = !1, t.insertType = null, t.meet = null, t.pointerId = null;
}
}
function Ln(e) {
return () => {
};
}
function An(e) {
const { dragMoveHelper: t } = e;
let n = 0;
e.spacePressed = !1;
let o = null;
const s = /* @__PURE__ */ new Map(), i = Nn(e);
let l = null, c = null, r = null, a = null;
const d = 500, h = 10, u = () => {
l !== null && (clearTimeout(l), l = null, c = null, r = null, a = null);
}, y = (f, w) => {
f.hasPointerCapture && f.hasPointerCapture(w) && f.releasePointerCapture(w);
}, v = (f, w) => {
if (f.id === "input-box" || f.closest("#input-box")) return !1;
const k = f.closest(".svg-label");
if (k) {
const M = k.dataset.svgId, te = k.dataset.type, Z = document.getElementById(M);
if (Z) {
if (te === "arrow")
return w ? e.editArrowLabel(Z) : e.selectArrow(Z), !0;
if (te === "summary")
return w ? e.editSummary(Z) : e.selectSummary(Z), !0;
}
}
if (f.closest(".topiclinks")) {
const M = f.closest("g");
if (M)
return w ? e.editArrowLabel(M) : e.selectArrow(M), !0;
}
if (f.closest(".summary")) {
const M = f.closest("g");
if (M)
return w ? e.editSummary(M) : e.selectSummary(M), !0;
}
return !1;
}, p = (f) => {
if (f.button !== 0) return;
if (e.helper1?.moved) {
e.helper1.clear();
return;
}
if (e.helper2?.moved) {
e.helper2.clear();
return;
}
if (t.moved) {
t.clear();
return;
}
if (i?.isDragging)
return;
const w = f.target;
if (w.tagName === "ME-EPD")
f.ctrlKey || f.metaKey ? e.expandNodeAll(w.previousSibling) : e.expandNode(w.previousSibling);
else if (w.tagName === "ME-TPC" && e.currentNodes.length > 1)
e.selectNode(w);
else if (!e.editable)
return;
v(w, !1);
}, g = (f) => {
if (!e.editable) return;
const w = f.target;
re(w) && e.beginEdit(w), v(w, !0);
}, m = (f) => {
if (f.pointerType === "mouse" || s.size > 1) return;
const w = (/* @__PURE__ */ new Date()).getTime(), k = w - n;
k < 300 && k > 0 && g(f), n = w;
}, b = (f) => {
f.code === "Space" && (e.spacePressed = !0, e.container.classList.add("space-pressed"));
}, x = (f) => {
f.code === "Space" && (e.spacePressed = !1, e.container.classList.remove("space-pressed"));
}, L = (f) => {
if (f.pointerType === "touch" && (s.set(f.pointerId, { x: f.clientX, y: f.clientY }), s.size === 2)) {
const [M, te] = Array.from(s.values());
o = Pe(M, te), u();
}
t.moved = !1;
const w = f.target, k = e.mouseSelectionButton === 0 ? 2 : 0;
if (e.editable && i && (f.button === 0 || f.pointerType === "touch")) {
if (f.pointerType === "touch" && s.size > 1)
(i.isDragging || i.pointerId !== null) && pe(e, i);
else if (f.pointerType === "touch" && s.size === 1)
(re(w) || w.closest("me-tpc")) && (c = { x: f.clientX, y: f.clientY }, r = w, a = f.pointerId, l = window.setTimeout(() => {
Ie(e, i, f, !0) && (r && r.setPointerCapture(f.pointerId), rt(i.ghost, f.clientX, f.clientY)), l = null, c = null, r = null, a = null;
}, d));
else if (f.pointerType === "mouse" && Ie(e, i, f, !1)) {
w.setPointerCapture(f.pointerId);
return;
}
}
const O = e.spacePressed && f.button === 0 && f.pointerType === "mouse", W = !e.editable || f.button === k && f.pointerType === "mouse" || f.pointerType === "touch";
!O && !W || (t.x = f.clientX, t.y = f.clientY, w.className !== "circle" && w.contentEditable !== "plaintext-only" && (t.mousedown = !0, w.setPointerCapture(f.pointerId)));
}, T = (f) => {
if (f.pointerType === "touch" && s.has(f.pointerId)) {
if (s.set(f.pointerId, { x: f.clientX, y: f.clientY }), l !== null && c !== null && f.pointerId === a) {
const w = f.clientX - c.x, k = f.clientY - c.y;
Math.sqrt(w * w + k * k) > h && u();
}
if (s.size >= 2) {
const [w, k] = Array.from(s.values()), O = Pe(w, k);
if (o == null)
o = O;
else {
if (o > 0) {
const W = O / o;
e.scale(e.scaleVal * W, {
x: (w.x + k.x) / 2,
y: (w.y + k.y) / 2
});
}
o = O;
}
return;
}
}
if (!(i && i.pointerId !== null && (Tn(e, i, f), i.isDragging))) {
if (f.target.contentEditable !== "plaintext-only" || e.spacePressed && t.mousedown) {
const w = f.clientX - t.x, k = f.clientY - t.y;
t.onMove(w, k);
}
t.x = f.clientX, t.y = f.clientY;
}
}, E = (f) => {
if (f.pointerType === "touch" && (s.delete(f.pointerId), s.size < 2 && (o = null), u()), i && i.pointerId !== null) {
const w = i.isDragging;
if (_n(e, i, f), y(f.target, f.pointerId), w)
return;
}
t.mousedown && (y(f.target, f.pointerId), t.clear());
}, C = () => {
u(), t.mousedown && t.clear(), i && (i.isDragging || i.pointerId !== null) && pe(e, i);
}, S = (f) => {
f.pointerType === "touch" && (s.delete(f.pointerId), s.size < 2 && (o = null), u()), i && i.pointerId === f.pointerId && pe(e, i), E(f);
}, N = (f) => {
if (f.preventDefault(), f.button !== 2 || !e.editable) return;
const w = f.target;
re(w) && !w.classList.contains("selected") && e.selectNode(w), setTimeout(() => {
e.dragMoveHelper.moved || e.bus.fire("showContextMenu", f);
}, 200);
}, D = (f) => {
f.stopPropagation(), f.preventDefault(), f.ctrlKey || f.metaKey ? f.deltaY < 0 ? ae(e, "in", e.dragMoveHelper) : e.scaleVal - e.scaleSensitivity > 0 && ae(e, "out", e.dragMoveHelper) : f.shiftKey ? e.move(-f.deltaY, 0) : e.move(-f.deltaX, -f.deltaY);
}, { container: _ } = e;
return Qe([
{ dom: _, evt: "pointerdown", func: L },
{ dom: _, evt: "pointermove", func: T },
{ dom: _, evt: "pointerup", func: E },
{ dom: _, evt: "pointercancel", func: S },
{ dom: _, evt: "pointerdown", func: m },
{ dom: _, evt: "click", func: p },
{ dom: _, evt: "dblclick", func: g },
{ dom: _, evt: "contextmenu", func: N },
{ dom: _, evt: "wheel", func: typeof e.handleWheel == "function" ? e.handleWheel : D },
{ dom: _, evt: "blur", func: C },
{ dom: _, evt: "keydown", func: b },
{ dom: _, evt: "keyup", func: x }
]);
}
function Dn() {
return {
handlers: {},
addListener: function(e, t) {
this.handlers[e] === void 0 && (this.handlers[e] = []), this.handlers[e].push(t);
},
fire: function(e, ...t) {
if (this.handlers[e] instanceof Array) {
const n = this.handlers[e];
for (let o = 0; o < n.length; o++)
n[o](...t);
}
},
removeListener: function(e, t) {
if (!this.handlers[e]) return;
const n = this.handlers[e];
if (!t)
n.length = 0;
else if (n.length)
for (let o = 0; o < n.length; o++)
n[o] === t && this.handlers[e].splice(o, 1);
}
};
}
const H = "http://www.w3.org/2000/svg", fe = function(e) {
const t = e.clientWidth, n = e.clientHeight, o = e.dataset, s = Number(o.x), i = Number(o.y), l = o.anchor;
let c = s;
l === "middle" ? c = s - t / 2 : l === "end" && (c = s - t), e.style.left = `${c}px`, e.style.top = `${i - n / 2}px`, e.style.visibility = "visible";
}, ye = function(e, t, n, o) {
const { anchor: s = "middle", color: i, dataType: l, svgId: c } = o, r = document.createElement("div");
r.className = "svg-label", r.style.color = i || "#666";
const a = "label-" + c;
return r.id = a, r.innerHTML = e, r.dataset.type = l, r.dataset.svgId = c, r.dataset.x = t.toString(), r.dataset.y = n.toString(), r.dataset.anchor = s, r;
}, ct = function(e, t, n) {
const o = document.createElementNS(H, "path");
return A(o, {
d: e,
stroke: t || "#666",
fill: "none",
"stroke-width": n
}), o;
}, Q = function(e) {
const t = document.createElementNS(H, "svg");
return t.setAttribute("class", e), t.setAttribute("overflow", "visible"), t;
}, Re = function() {
const e = document.createElementNS(H, "line");
return e.setAttribute("stroke", "#4dc4ff"), e.setAttribute("fill", "none"), e.setAttribute("stroke-width", "2"), e.setAttribute("opacity", "0.45"), e;
}, Mn = function(e, t, n, o) {
const s = document.createElementNS(H, "g");
return [
{
name: "line",
d: e
},
{
name: "arrow1",
d: t
},
{
name: "arrow2",
d: n
}
].forEach((l, c) => {
const r = l.d, a = document.createElementNS(H, "path"), d = {
d: r,
stroke: o?.stroke || "rgb(227, 125, 116)",
fill: "none",
"stroke-linecap": o?.strokeLinecap || "cap",
"stroke-width": String(o?.strokeWidth || "2")
};
o?.opacity !== void 0 && (d.opacity = String(o.opacity)), A(a, d), c === 0 && a.setAttribute("stroke-dasharray", o?.strokeDasharray || "8,2");
const h = document.createElementNS(H, "path");
A(h, {
d: r,
stroke: "transparent",
fill: "none",
"stroke-width": "15"
}), s.appendChild(h), s.appendChild(a), s[l.name] = a;
}), s;
}, at = function(e, t, n) {
if (!t) return;
const o = n.label, s = t.cloneNode(!0);
e.nodes.appendChild(s), s.id = "input-box", s.textContent = o, s.contentEditable = "plaintext-only", s.spellcheck = !1, s.style.cssText = `
left:${t.style.left};
top:${t.style.top};
max-width: 200px;
`, tt(s), e.scrollIntoView(s), s.addEventListener("keydown", (i) => {
i.stopPropagation();
const l = i.key;
if (l === "Enter" || l === "Tab") {
if (i.shiftKey) return;
i.preventDefault(), s.blur(), e.container.focus();
}
}), s.addEventListener("blur", () => {
if (!s) return;
const i = s.innerText?.trim() || "";
i === "" ? n.label = o : n.label = i, s.remove(), i !== o && (e.markdown ? t.innerHTML = e.markdown(n.label, n) : t.textContent = n.label, fe(t), "parent" in n ? e.bus.fire("operation", {
name: "finishEditSummary",
obj: n
}) : e.bus.fire("operation", {
name: "finishEditArrowLabel",
obj: n
}));
});
}, Pn = function(e) {
const t = this.map.querySelector("me-root"), n = t.offsetTop, o = t.offsetLeft, s = t.offsetWidth, i = t.offsetHeight, l = this.map.querySelectorAll("me-main > me-wrapper");
this.lines.innerHTML = "";
for (let c = 0; c < l.length; c++) {
const r = l[c], a = r.querySelector("me-tpc"), { offsetLeft: d, offsetTop: h } = j(this.nodes, a), u = a.offsetWidth, y = a.offsetHeight, v = r.parentNode.className, p = this.generateMainBranch({ pT: n, pL: o, pW: s, pH: i, cT: h, cL: d, cW: u, cH: y, direction: v, containerHeight: this.nodes.offsetHeight }), g = this.theme.palette, m = a.nodeObj.branchColor || g[c % g.length];
if (a.style.borderColor = m, this.lines.appendChild(ct(p, m, "3")), e && e !== r)
continue;
const b = Q("subLines"), x = r.lastChild;
x.tagName === "svg" && x.remove(), r.appendChild(b), dt(this, b, m, r, v, !0);
}
this.labelContainer.innerHTML = "", this.renderArrow(), this.renderSummary(), this.bus.fire("linkDiv");
}, dt = function(e, t, n, o, s, i) {
const l = o.firstChild, c = o.children[1].children;
if (c.length === 0) return;
const r = l.offsetTop, a = l.offsetLeft, d = l.offsetWidth, h = l.offsetHeight;
for (let u = 0; u < c.length; u++) {
const y = c[u], v = y.firstChild, p = v.offsetTop, g = v.offsetLeft, m = v.offsetWidth, b = v.offsetHeight, x = v.firstChild.nodeObj.branchColor || n, L = e.generateSubBranch({ pT: r, pL: a, pW: d, pH: h, cT: p, cL: g, cW: m, cH: b, direction: s, isFirst: i });
t.appendChild(ct(L, x, "2"));
const T = v.children[1];
if (T) {
if (!T.expanded) continue;
} else
continue;
dt(e, t, x, y, s);
}
}, Be = {
addChild: "插入子节点",
addParent: "插入父节点",
addSibling: "插入同级节点",
removeNode: "删除节点",
focus: "专注",
cancelFocus: "取消专注",
moveUp: "上移",
moveDown: "下移",
link: "连接",
linkBidirectional: "双向连接",
clickTips: "请点击目标节点",
summary: "摘要"
}, Fe = {
cn: Be,
zh_CN: Be,
zh_TW: {
addChild: "插入子節點",
addParent: "插入父節點",
addSibling: "插入同級節點",
removeNode: "刪除節點",
focus: "專注",
cancelFocus: "取消專注",
moveUp: "上移",
moveDown: "下移",
link: "連接",
linkBidirectional: "雙向連接",
clickTips: "請點擊目標節點",
summary: "摘要"
},
en: {
addChild: "Add child",
addParent: "Add parent",
addSibling: "Add sibling",
removeNode: "Remove node",
focus: "Focus Mode",
cancelFocus: "Cancel Focus Mode",
moveUp: "Move up",
moveDown: "Move down",
link: "Link",
linkBidirectional: "Bidirectional Link",
clickTips: "Please click the target node",
summary: "Summary"
},
ru: {
addChild: "Добавить дочерний элемент",
addParent: "Добавить родительский элемент",
addSibling: "Добавить на этом уровне",
removeNode: "Удалить узел",
focus: "Режим фокусировки",
cancelFocus: "Отменить режим фокусировки",
moveUp: "Поднять выше",
moveDown: "Опустить ниже",
link: "Ссылка",
linkBidirectional: "Двунаправленная ссылка",
clickTips: "Пожалуйста, нажмите на целевой узел",
summary: "Описание"
},
ja: {
addChild: "子ノードを追加する",
addParent: "親ノードを追加します",
addSibling: "兄弟ノードを追加する",
removeNode: "ノードを削除",
focus: "集中",
cancelFocus: "集中解除",
moveUp: "上へ移動",
moveDown: "下へ移動",
link: "コネクト",
linkBidirectional: "双方向リンク",
clickTips: "ターゲットノードをクリックしてください",
summary: "概要"
},
pt: {
addChild: "Adicionar item filho",
addParent: "Adicionar item pai",
addSibling: "Adicionar item irmao",
removeNode: "Remover item",
focus: "Modo Foco",
cancelFocus: "Cancelar Modo Foco",
moveUp: "Mover para cima",
moveDown: "Mover para baixo",
link: "Link",
linkBidirectional: "Link bidirecional",
clickTips: "Favor clicar no item alvo",
summary: "Resumo"
},
it: {
addChild: "Aggiungi figlio",
addParent: "Aggiungi genitore",
addSibling: "Aggiungi fratello",
removeNode: "Rimuovi nodo",
focus: "Modalità Focus",
cancelFocus: "Annulla Modalità Focus",
moveUp: "Sposta su",
moveDown: "Sposta giù",
link: "Collega",
linkBidirectional: "Collegamento bidirezionale",
clickTips: "Si prega di fare clic sul nodo di destinazione",
summary: "Unisci nodi"
},
es: {
addChild: "Agregar hijo",
addParent: "Agregar padre",
addSibling: "Agregar hermano",
removeNode: "Eliminar nodo",
focus: "Modo Enfoque",
cancelFocus: "Cancelar Modo Enfoque",
moveUp: "Mover hacia arriba",
moveDown: "Mover hacia abajo",
link: "Enlace",
linkBidirectional: "Enlace bidireccional",
clickTips: "Por favor haga clic en el nodo de destino",
summary: "Resumen"
},
fr: {
addChild: "Ajout enfant",
addParent: "Ajout parent",
addSibling: "Ajout voisin",
removeNode: "Supprimer",
focus: "Cibler",
cancelFocus: "Retour",
moveUp: "Monter",
moveDown: "Descendre",
link: "Lier",
linkBidirectional: "Lien bidirectionnel",
clickTips: "Cliquer sur le noeud cible",
summary: "Annoter"
},
ko: {
addChild: "자식 추가",
addParent: "부모 추가",
addSibling: "형제 추가",
removeNode: "노드 삭제",
focus: "포커스 모드",
cancelFocus: "포커스 모드 취소",
moveUp: "위로 이동",
moveDown: "아래로 이동",
link: "연결",
linkBidirectional: "양방향 연결",
clickTips: "대상 노드를 클릭하십시오",
summary: "요약"
},
ro: {
addChild: "Adaugă sub-nod",
addParent: "Adaugă nod părinte",
addSibling: "Adaugă nod la același nivel",
removeNode: "Șterge nodul",
focus: "Focalizare",
cancelFocus: "Anulează focalizarea",
moveUp: "Mută în sus",
moveDown: "Mută în jos",
link: "Creează legătură",
linkBidirectional: "Creează legătură bidirecțională",
clickTips: "Click pe nodul țintă",
summary: "Rezumat"
}
};
function On(e, t) {
t = t === !0 ? {
focus: !0,
li